#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*/ printf(char *);
int /*<<< orphan*/ test_arraySum(int *, int, int);
void test_00_arraySum() {
  printf("Testing arraySum(...)\n");
  int array1[] = {-4, -1, 0, 1, 5, 10, 20, 21};
  int len1 = 8;
  int expected1 = 52;
  test_arraySum(array1, len1, expected1);
  int array2[] = {};
  int len2 = 0;
  int expected2 = 0;
  test_arraySum(array2, len2, expected2);
  int array3[] = {-4, -15, -21, -5, 68, 123, -500, 2, 3, 0, 0, 5};
  int len3 = 12;
  int expected3 = -344;
  test_arraySum(array3, len3, expected3);
  printf("\n");
}


x86 assembly (clang, -O0):
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
lea    0xebe(%rip),%rdi
call   1030 <printf@plt>
mov    0xed2(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xecf(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xecc(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xec9(%rip),%rax
mov    %rax,-0x8(%rbp)
movl   $0x8,-0x24(%rbp)
movl   $0x34,-0x28(%rbp)
lea    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x28(%rbp),%edx
call   1050 <test_arraySum@plt>
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
lea    -0x2c(%rbp),%rdi
mov    -0x30(%rbp),%esi
mov    -0x34(%rbp),%edx
call   1050 <test_arraySum@plt>
lea    -0x70(%rbp),%rdi
lea    0xe88(%rip),%rsi
mov    $0x30,%edx
call   1040 <memcpy@plt>
movl   $0xc,-0x74(%rbp)
movl   $0xfffffea8,-0x78(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x74(%rbp),%esi
mov    -0x78(%rbp),%edx
call   1050 <test_arraySum@plt>
lea    0xe2f(%rip),%rdi
call   1030 <printf@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
sub    $0x68,%rsp
lea    0xf15(%rip),%rdi
call   1040 <puts@plt>
movaps 0xec9(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xead(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0x10(%rsp),%rdi
mov    $0x8,%esi
mov    $0x34,%edx
call   1050 <test_arraySum@plt>
lea    0xc(%rsp),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1050 <test_arraySum@plt>
movaps 0xebf(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xea3(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xe87(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
lea    0x30(%rsp),%rdi
mov    $0xc,%esi
mov    $0xfffffea8,%edx
call   1050 <test_arraySum@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x68,%rsp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Testing arraySum(...)\0A\00"
@__const.test_00_arraySum.array1 = [8 x i32] [i32 -4, i32 -1, i32 0, i32 1, i32 5, i32 10, i32 20, i32 21]
@__const.test_00_arraySum.array3 = [12 x i32] [i32 -4, i32 -15, i32 -21, i32 -5, i32 68, i32 123, i32 -500, i32 2, i32 3, i32 0, i32 0, i32 5]
@.str.1 = [2 x i8] c"\0A\00"
define void @test_00_arraySum() {
%1 = alloca [8 x i32]
%2 = alloca i32
%3 = alloca i32
%4 = alloca [0 x i32]
%5 = alloca i32
%6 = alloca i32
%7 = alloca [12 x i32]
%8 = alloca i32
%9 = alloca i32
%10 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%11 = bitcast [8 x i32]* %1 to i8*
store i32 8, i32* %2
store i32 52, i32* %3
%12 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 0
%13 = load i32, i32* %2
%14 = load i32, i32* %3
%15 = call i32 @test_arraySum(i32* %12, i32 %13, i32 %14)
%16 = bitcast [0 x i32]* %4 to i8*
store i32 0, i32* %5
store i32 0, i32* %6
%17 = getelementptr inbounds [0 x i32], [0 x i32]* %4, i64 0, i64 0
%18 = load i32, i32* %5
%19 = load i32, i32* %6
%20 = call i32 @test_arraySum(i32* %17, i32 %18, i32 %19)
%21 = bitcast [12 x i32]* %7 to i8*
store i32 12, i32* %8
store i32 -344, i32* %9
%22 = getelementptr inbounds [12 x i32], [12 x i32]* %7, i64 0, i64 0
%23 = load i32, i32* %8
%24 = load i32, i32* %9
%25 = call i32 @test_arraySum(i32* %22, i32 %23, i32 %24)
%26 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@__const.test_00_arraySum.array1 = [8 x i32] [i32 -4, i32 -1, i32 0, i32 1, i32 5, i32 10, i32 20, i32 21]
@__const.test_00_arraySum.array3 = [12 x i32] [i32 -4, i32 -15, i32 -21, i32 -5, i32 68, i32 123, i32 -500, i32 2, i32 3, i32 0, i32 0, i32 5]
@str = [22 x i8] c"Testing arraySum(...)\00"
define void @test_00_arraySum() {
%1 = alloca [0 x i32]
%2 = alloca [8 x i32]
%3 = alloca [12 x i32]
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%5 = bitcast [8 x i32]* %2 to i8*
%6 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 0
%7 = call i32 @test_arraySum(i32* %6, i32 8, i32 52)
%8 = bitcast [0 x i32]* %1 to i8*
%9 = getelementptr inbounds [0 x i32], [0 x i32]* %1, i64 0, i64 0
%10 = call i32 @test_arraySum(i32* %9, i32 0, i32 0)
%11 = bitcast [12 x i32]* %3 to i8*
%12 = getelementptr inbounds [12 x i32], [12 x i32]* %3, i64 0, i64 0
%13 = call i32 @test_arraySum(i32* %12, i32 12, i32 -344)
%14 = call i32 @putchar(i32 10)
ret void
}