/* -*- Mode: C; c-basic-offset:4 ; -*- */
/*
 *  (C) 2014 by Argonne National Laboratory.
 *      See COPYRIGHT in top-level directory.
 *
 * This file is automatically generated by buildiface
 * DO NOT EDIT
 */

#include "cdesc.h"

int MPIR_Unpack_external_cdesc(const char x0[], CFI_cdesc_t* x1, MPI_Aint x2, MPI_Aint * x3, CFI_cdesc_t* x4, int x5, MPI_Datatype x6)
{
    int err = MPI_SUCCESS;
    void *buf1 = x1->base_addr;
    void *buf4 = x4->base_addr;
    int count4 = x5;
    MPI_Datatype dtype4 = x6;

    if (buf1 == &MPIR_F08_MPI_BOTTOM) {
        buf1 = MPI_BOTTOM;
    }

    if (buf4 == &MPIR_F08_MPI_BOTTOM) {
        buf4 = MPI_BOTTOM;
    }

    if (x4->rank != 0 && !CFI_is_contiguous(x4)) {
        err = cdesc_create_datatype(x4, x5, x6, &dtype4);
        count4 = 1;
    }

    err = MPI_Unpack_external(x0, buf1, x2, x3, buf4, count4, dtype4);

    if (dtype4 != x6)  MPI_Type_free(&dtype4);
    return err;
}
