#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_Alltoall(void *sendbuf, int sendcount, int sendtype, void *recvbuf,
                 int recvcount, int recvtype, 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_Alltoall>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9d,-0x28(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x18(%rbp),%edi
call   1040 <stubtypesize@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x2c(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1170 <MPI_Alltoall+0x50>
cmpq   $0x0,-0x20(%rbp)
jne    117c <MPI_Alltoall+0x5c>
movl   $0x0,-0x4(%rbp)
jmp    1193 <MPI_Alltoall+0x73>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x2c(%rbp),%edx
call   1030 <memcpy@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MPI_Alltoall>:
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_Alltoall+0x2d>
test   %r14,%r14
je     114d <MPI_Alltoall+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_Alltoall(i8* %0, i32 %1, i32 %2, i8* %3, i32 %4, i32 %5, i32 %6) {
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
store i8* %0, i8** %9
store i32 %1, i32* %10
store i32 %2, i32* %11
store i8* %3, i8** %12
store i32 %4, i32* %13
store i32 %5, i32* %14
store i32 %6, i32* %15
%17 = load i32, i32* %10
%18 = load i32, i32* %11
%19 = call i32 @stubtypesize(i32 %18)
%20 = mul nsw i32 %17, %19
store i32 %20, i32* %16
%21 = load i8*, i8** %9
%22 = icmp eq i8* %21, null
br i1 %22, label %26, label %23
23: ; preds = %7
%24 = load i8*, i8** %12
%25 = icmp eq i8* %24, null
br i1 %25, label %26, label %27
26: ; preds = %23, %7
store i32 0, i32* %8
br label %32
27: ; preds = %23
%28 = load i8*, i8** %12
%29 = load i8*, i8** %9
%30 = load i32, i32* %16
%31 = call i32 @memcpy(i8* %28, i8* %29, i32 %30)
store i32 0, i32* %8
br label %32
32: ; preds = %27, %26
%33 = load i32, i32* %8
ret i32 %33
}

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