#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 SumWithFor(int *, int);
int SumWithRecursion(int *, int);
int SumWithWhile(int *, int);
int /*<<< orphan*/ printf(char *, int, int, int);
int main() {
  int arr[5] = {1, 3, 5, 9, 12};
  printf("SumWithFor: %d\nSumWithWhile: %d\nSumWithRecursion: %d\n",
         SumWithFor(arr, 5), SumWithWhile(arr, 5), SumWithRecursion(arr, 5));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0xeb1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeae(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xeac(%rip),%eax
mov    %eax,-0x10(%rbp)
lea    -0x20(%rbp),%rdi
mov    $0x5,%esi
call   1060 <SumWithFor@plt>
mov    %eax,-0x28(%rbp)
lea    -0x20(%rbp),%rdi
mov    $0x5,%esi
call   1040 <SumWithWhile@plt>
mov    %eax,-0x24(%rbp)
lea    -0x20(%rbp),%rdi
mov    $0x5,%esi
call   1050 <SumWithRecursion@plt>
mov    -0x28(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    %eax,%ecx
lea    0xe6e(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    0xec2(%rip),%eax
mov    %eax,0x10(%rsp)
movaps 0xea7(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x5,%esi
call   1060 <SumWithFor@plt>
mov    %eax,%r14d
mov    %rbx,%rdi
mov    $0x5,%esi
call   1040 <SumWithWhile@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    $0x5,%esi
call   1050 <SumWithRecursion@plt>
lea    0xe81(%rip),%rdi
mov    %r14d,%esi
mov    %ebp,%edx
mov    %eax,%ecx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.arr = [5 x i32] [i32 1, i32 3, i32 5, i32 9, i32 12]
@.str = [54 x i8] c"SumWithFor: %d\0ASumWithWhile: %d\0ASumWithRecursion: %d\0A\00"
define i32 @main() {
%1 = alloca [5 x i32]
%2 = bitcast [5 x i32]* %1 to i8*
%3 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 0
%4 = call i32 @SumWithFor(i32* %3, i32 5)
%5 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 0
%6 = call i32 @SumWithWhile(i32* %5, i32 5)
%7 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 0
%8 = call i32 @SumWithRecursion(i32* %7, i32 5)
%9 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0), i32 %4, i32 %6, i32 %8)
ret i32 0
}

LLVM IR (-O2):
@__const.main.arr = [5 x i32] [i32 1, i32 3, i32 5, i32 9, i32 12]
@.str = [54 x i8] c"SumWithFor: %d\0ASumWithWhile: %d\0ASumWithRecursion: %d\0A\00"
define i32 @main() {
%1 = alloca [5 x i32]
%2 = bitcast [5 x i32]* %1 to i8*
%3 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 0
%4 = call i32 @SumWithFor(i32* %3, i32 5)
%5 = call i32 @SumWithWhile(i32* %3, i32 5)
%6 = call i32 @SumWithRecursion(i32* %3, i32 5)
%7 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0), i32 %4, i32 %5, i32 %6)
ret i32 0
}