#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*/ FillArray(int *, int);
int SumArray(int *, int);
int SumArray2(int *, int);
int atoi(char *);
int /*<<< orphan*/ free(int *);
int *malloc(int);
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char **argv) {
  int size;
  int *MyArray;
  size = (argc < 2) ? 100 : atoi(argv[1]);
  MyArray = malloc(sizeof(int) * size);
  FillArray(MyArray, size);
  printf("Sum1 = %d\n", SumArray(MyArray, 100));
  printf("Sum2 = %d\n", SumArray2(MyArray, 100));
  free(MyArray);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    119d <main+0x2d>
mov    $0x64,%eax
mov    %eax,-0x24(%rbp)
jmp    11ad <main+0x3d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x14(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1070 <FillArray@plt>
mov    -0x20(%rbp),%rdi
mov    $0x64,%esi
call   1080 <SumArray@plt>
mov    %eax,%esi
lea    0xe17(%rip),%rdi
call   1050 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    $0x64,%esi
call   1040 <SumArray2@plt>
mov    %eax,%esi
lea    0xe06(%rip),%rdi
call   1050 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x64,%r14d
cmp    $0x2,%edi
jl     118b <main+0x1b>
mov    0x8(%rsi),%rdi
call   1090 <atoi@plt>
mov    %eax,%r14d
lea    0x0(,%r14,4),%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14d,%esi
call   1070 <FillArray@plt>
mov    %rbx,%rdi
mov    $0x64,%esi
call   1080 <SumArray@plt>
lea    0xe46(%rip),%rdi
mov    %eax,%esi
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x64,%esi
call   1040 <SumArray2@plt>
lea    0xe36(%rip),%rdi
mov    %eax,%esi
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [11 x i8] c"Sum1 = %d\0A\00"
@.str.1 = [11 x i8] c"Sum2 = %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %11
10: ; preds = %2
br label %16
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @atoi(i8* %14)
br label %16
16: ; preds = %11, %10
%17 = phi i32 [ 100, %10 ], [ %15, %11 ]
store i32 %17, i32* %6
%18 = load i32, i32* %6
%19 = sext i32 %18 to i64
%20 = mul i64 4, %19
%21 = trunc i64 %20 to i32
%22 = call i32* @malloc(i32 %21)
store i32* %22, i32** %7
%23 = load i32*, i32** %7
%24 = load i32, i32* %6
%25 = call i32 @FillArray(i32* %23, i32 %24)
%26 = load i32*, i32** %7
%27 = call i32 @SumArray(i32* %26, i32 100)
%28 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %27)
%29 = load i32*, i32** %7
%30 = call i32 @SumArray2(i32* %29, i32 100)
%31 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %30)
%32 = load i32*, i32** %7
%33 = call i32 @free(i32* %32)
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"Sum1 = %d\0A\00"
@.str.1 = [11 x i8] c"Sum2 = %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @atoi(i8* %6)
br label %8
8: ; preds = %2, %4
%9 = phi i32 [ %7, %4 ], [ 100, %2 ]
%10 = shl i32 %9, 2
%11 = tail call i32* @malloc(i32 %10)
%12 = tail call i32 @FillArray(i32* %11, i32 %9)
%13 = tail call i32 @SumArray(i32* %11, i32 100)
%14 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = tail call i32 @SumArray2(i32* %11, i32 100)
%16 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = tail call i32 @free(i32* %11)
ret i32 0
}