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


x86 assembly (clang, -O0):
<MPI_Scan>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9d,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x20(%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     116d <MPI_Scan+0x4d>
cmpq   $0x0,-0x18(%rbp)
jne    1179 <MPI_Scan+0x59>
movl   $0x0,-0x4(%rbp)
jmp    1190 <MPI_Scan+0x70>
mov    -0x18(%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_Scan>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %ecx,%edi
call   1040 <stubtypesize@plt>
test   %rbx,%rbx
je     114d <MPI_Scan+0x2d>
test   %r14,%r14
je     114d <MPI_Scan+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_Scan(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* %11
%17 = call i32 @stubtypesize(i32 %16)
%18 = mul nsw i32 %15, %17
store i32 %18, i32* %14
%19 = load i8*, i8** %8
%20 = icmp eq i8* %19, null
br i1 %20, label %24, label %21
21: ; preds = %6
%22 = load i8*, i8** %9
%23 = icmp eq i8* %22, null
br i1 %23, label %24, label %25
24: ; preds = %21, %6
store i32 0, i32* %7
br label %30
25: ; preds = %21
%26 = load i8*, i8** %9
%27 = load i8*, i8** %8
%28 = load i32, i32* %14
%29 = call i32 @memcpy(i8* %26, i8* %27, i32 %28)
store i32 0, i32* %7
br label %30
30: ; preds = %25, %24
%31 = load i32, i32* %7
ret i32 %31
}

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