#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*/ free(float *);
int /*<<< orphan*/ initialData(float *, int);
scalar_t__ malloc(size_t);
int /*<<< orphan*/ sumArraysOnHost(float *, float *, float *, int);
int main(int argc, char **argv) {
  int nElem = 1024;
  size_t nBytes = nElem * sizeof(float);
  float *h_A, *h_B, *h_C;
  h_A = (float *)malloc(nBytes);
  h_B = (float *)malloc(nBytes);
  h_C = (float *)malloc(nBytes);
  initialData(h_A, nElem);
  initialData(h_B, nElem);
  sumArraysOnHost(h_A, h_B, h_C, nElem);
  free(h_A);
  free(h_B);
  free(h_C);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x400,-0x14(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1050 <initialData@plt>
mov    -0x30(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1050 <initialData@plt>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rdx
mov    -0x14(%rbp),%ecx
call   1040 <sumArraysOnHost@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    $0x1000,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
mov    $0x1000,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    $0x1000,%edi
call   1060 <malloc@plt>
mov    %rax,%r15
mov    %r14,%rdi
mov    $0x400,%esi
call   1050 <initialData@plt>
mov    %rbx,%rdi
mov    $0x400,%esi
call   1050 <initialData@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
mov    $0x400,%ecx
call   1040 <sumArraysOnHost@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i64
%8 = alloca float*
%9 = alloca float*
%10 = alloca float*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1024, i32* %6
%11 = load i32, i32* %6
%12 = sext i32 %11 to i64
%13 = mul i64 %12, 4
store i64 %13, i64* %7
%14 = load i64, i64* %7
%15 = call i64 @malloc(i64 %14)
%16 = inttoptr i64 %15 to float*
store float* %16, float** %8
%17 = load i64, i64* %7
%18 = call i64 @malloc(i64 %17)
%19 = inttoptr i64 %18 to float*
store float* %19, float** %9
%20 = load i64, i64* %7
%21 = call i64 @malloc(i64 %20)
%22 = inttoptr i64 %21 to float*
store float* %22, float** %10
%23 = load float*, float** %8
%24 = load i32, i32* %6
%25 = call i32 @initialData(float* %23, i32 %24)
%26 = load float*, float** %9
%27 = load i32, i32* %6
%28 = call i32 @initialData(float* %26, i32 %27)
%29 = load float*, float** %8
%30 = load float*, float** %9
%31 = load float*, float** %10
%32 = load i32, i32* %6
%33 = call i32 @sumArraysOnHost(float* %29, float* %30, float* %31, i32 %32)
%34 = load float*, float** %8
%35 = call i32 @free(float* %34)
%36 = load float*, float** %9
%37 = call i32 @free(float* %36)
%38 = load float*, float** %10
%39 = call i32 @free(float* %38)
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i64 @malloc(i64 4096)
%4 = inttoptr i64 %3 to float*
%5 = tail call i64 @malloc(i64 4096)
%6 = inttoptr i64 %5 to float*
%7 = tail call i64 @malloc(i64 4096)
%8 = inttoptr i64 %7 to float*
%9 = tail call i32 @initialData(float* %4, i32 1024)
%10 = tail call i32 @initialData(float* %6, i32 1024)
%11 = tail call i32 @sumArraysOnHost(float* %4, float* %6, float* %8, i32 1024)
%12 = tail call i32 @free(float* %4)
%13 = tail call i32 @free(float* %6)
%14 = tail call i32 @free(float* %8)
ret i32 0
}