#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ memcpy(void *, void *, int);
int stubtypesize(int);
int MPI_Gatherv(void *sendbuf, int sendcount, int sendtype, void *recvbuf,
                int *recvcounts, int *displs, int recvtype, int root,
                int comm) {
  int n = sendcount * stubtypesize(sendtype);
  if (sendbuf == NULL || recvbuf == NULL)
    return 0;
  memcpy(recvbuf, sendbuf, n);
  return 0;
}


x86 assembly (clang, -O0):
<MPI_Gatherv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x18(%rbp),%edi
call   1040 <stubtypesize@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x34(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1176 <MPI_Gatherv+0x56>
cmpq   $0x0,-0x20(%rbp)
jne    1182 <MPI_Gatherv+0x62>
movl   $0x0,-0x4(%rbp)
jmp    1199 <MPI_Gatherv+0x79>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x34(%rbp),%edx
call   1030 <memcpy@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MPI_Gatherv>:
push   %rbp
push   %r14
push   %rbx
mov    %rcx,%r14
mov    %esi,%ebp
mov    %rdi,%rbx
mov    %edx,%edi
call   1040 <stubtypesize@plt>
test   %rbx,%rbx
je     114d <MPI_Gatherv+0x2d>
test   %r14,%r14
je     114d <MPI_Gatherv+0x2d>
imul   %ebp,%eax
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <memcpy@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @MPI_Gatherv(i8* %0, i32 %1, i32 %2, i8* %3, i32* %4, i32* %5, i32 %6, i32 %7, i32 %8) {
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i8*
%15 = alloca i32*
%16 = alloca i32*
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
store i8* %0, i8** %11
store i32 %1, i32* %12
store i32 %2, i32* %13
store i8* %3, i8** %14
store i32* %4, i32** %15
store i32* %5, i32** %16
store i32 %6, i32* %17
store i32 %7, i32* %18
store i32 %8, i32* %19
%21 = load i32, i32* %12
%22 = load i32, i32* %13
%23 = call i32 @stubtypesize(i32 %22)
%24 = mul nsw i32 %21, %23
store i32 %24, i32* %20
%25 = load i8*, i8** %11
%26 = icmp eq i8* %25, null
br i1 %26, label %30, label %27
27: ; preds = %9
%28 = load i8*, i8** %14
%29 = icmp eq i8* %28, null
br i1 %29, label %30, label %31
30: ; preds = %27, %9
store i32 0, i32* %10
br label %36
31: ; preds = %27
%32 = load i8*, i8** %14
%33 = load i8*, i8** %11
%34 = load i32, i32* %20
%35 = call i32 @memcpy(i8* %32, i8* %33, i32 %34)
store i32 0, i32* %10
br label %36
36: ; preds = %31, %30
%37 = load i32, i32* %10
ret i32 %37
}

LLVM IR (-O2):
define i32 @MPI_Gatherv(i8* %0, i32 %1, i32 %2, i8* %3, i32* nocapture readnone %4, i32* nocapture readnone %5, i32 %6, i32 %7, i32 %8) {
%10 = tail call i32 @stubtypesize(i32 %2)
%11 = icmp eq i8* %0, null
%12 = icmp eq i8* %3, null
%13 = or i1 %11, %12
br i1 %13, label %17, label %14
14: ; preds = %9
%15 = mul nsw i32 %10, %1
%16 = tail call i32 @memcpy(i8* %3, i8* %0, i32 %15)
br label %17
17: ; preds = %9, %14
ret i32 0
}