#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_Scatter(void *sendbuf, int sendcount, int sendtype, void *recvbuf,
                int recvcount, int recvtype, int root, int comm) {
  int n = recvcount * stubtypesize(recvtype);
  if (sendbuf == NULL || recvbuf == NULL)
    return 0;
  memcpy(recvbuf, sendbuf, n);
  return 0;
}


x86 assembly (clang, -O0):
<MPI_Scatter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
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    %r8d,-0x24(%rbp)
mov    %r9d,-0x28(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x28(%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     1173 <MPI_Scatter+0x53>
cmpq   $0x0,-0x20(%rbp)
jne    117f <MPI_Scatter+0x5f>
movl   $0x0,-0x4(%rbp)
jmp    1196 <MPI_Scatter+0x76>
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_Scatter>:
push   %rbp
push   %r14
push   %rbx
mov    %r8d,%ebp
mov    %rcx,%r14
mov    %rdi,%rbx
mov    %r9d,%edi
call   1040 <stubtypesize@plt>
test   %rbx,%rbx
je     114f <MPI_Scatter+0x2f>
test   %r14,%r14
je     114f <MPI_Scatter+0x2f>
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_Scatter(i8* %0, i32 %1, i32 %2, i8* %3, i32 %4, i32 %5, i32 %6, i32 %7) {
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
store i8* %0, i8** %10
store i32 %1, i32* %11
store i32 %2, i32* %12
store i8* %3, i8** %13
store i32 %4, i32* %14
store i32 %5, i32* %15
store i32 %6, i32* %16
store i32 %7, i32* %17
%19 = load i32, i32* %14
%20 = load i32, i32* %15
%21 = call i32 @stubtypesize(i32 %20)
%22 = mul nsw i32 %19, %21
store i32 %22, i32* %18
%23 = load i8*, i8** %10
%24 = icmp eq i8* %23, null
br i1 %24, label %28, label %25
25: ; preds = %8
%26 = load i8*, i8** %13
%27 = icmp eq i8* %26, null
br i1 %27, label %28, label %29
28: ; preds = %25, %8
store i32 0, i32* %9
br label %34
29: ; preds = %25
%30 = load i8*, i8** %13
%31 = load i8*, i8** %10
%32 = load i32, i32* %18
%33 = call i32 @memcpy(i8* %30, i8* %31, i32 %32)
store i32 0, i32* %9
br label %34
34: ; preds = %29, %28
%35 = load i32, i32* %9
ret i32 %35
}

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