#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_Reduce_scatter(void *sendbuf, void *recvbuf, int *recvcounts,
                       int datatype, int op, int comm) {
  int n = *recvcounts * stubtypesize(datatype);
  if (sendbuf == NULL || recvbuf == NULL)
    return 0;
  memcpy(recvbuf, sendbuf, n);
  return 0;
}


x86 assembly (clang, -O0):
<MPI_Reduce_scatter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    %r8d,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x24(%rbp),%edi
call   1040 <stubtypesize@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x30(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1171 <MPI_Reduce_scatter+0x51>
cmpq   $0x0,-0x18(%rbp)
jne    117d <MPI_Reduce_scatter+0x5d>
movl   $0x0,-0x4(%rbp)
jmp    1194 <MPI_Reduce_scatter+0x74>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x30(%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_Reduce_scatter>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
mov    (%rdx),%ebp
mov    %ecx,%edi
call   1040 <stubtypesize@plt>
test   %rbx,%rbx
je     114d <MPI_Reduce_scatter+0x2d>
test   %r14,%r14
je     114d <MPI_Reduce_scatter+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_Reduce_scatter(i8* %0, i8* %1, i32* %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i8* %0, i8** %8
store i8* %1, i8** %9
store i32* %2, i32** %10
store i32 %3, i32* %11
store i32 %4, i32* %12
store i32 %5, i32* %13
%15 = load i32*, i32** %10
%16 = load i32, i32* %15
%17 = load i32, i32* %11
%18 = call i32 @stubtypesize(i32 %17)
%19 = mul nsw i32 %16, %18
store i32 %19, i32* %14
%20 = load i8*, i8** %8
%21 = icmp eq i8* %20, null
br i1 %21, label %25, label %22
22: ; preds = %6
%23 = load i8*, i8** %9
%24 = icmp eq i8* %23, null
br i1 %24, label %25, label %26
25: ; preds = %22, %6
store i32 0, i32* %7
br label %31
26: ; preds = %22
%27 = load i8*, i8** %9
%28 = load i8*, i8** %8
%29 = load i32, i32* %14
%30 = call i32 @memcpy(i8* %27, i8* %28, i32 %29)
store i32 0, i32* %7
br label %31
31: ; preds = %26, %25
%32 = load i32, i32* %7
ret i32 %32
}

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