#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 largestSumContinousSubArray(int *, int);
int /*<<< orphan*/ printf(char *, int);
int rand();
int main() {
  int array[10];
  for (int k = 0; k < 10; k++) {
    array[k] = rand() % 10;
  }
  printf("%d", largestSumContinousSubArray(array, 10));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x34(%rbp)
cmpl   $0xa,-0x34(%rbp)
jge    1175 <main+0x45>
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0xa,%ecx
cltd
idiv   %ecx
movslq -0x34(%rbp),%rax
mov    %edx,-0x30(%rbp,%rax,4)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1146 <main+0x16>
lea    -0x30(%rbp),%rdi
mov    $0xa,%esi
call   1040 <largestSumContinousSubArray@plt>
mov    %eax,%esi
lea    0xe74(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x28,%rsp
xor    %eax,%eax
call   1050 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x2,%ecx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
mov    %eax,(%rsp)
xor    %eax,%eax
call   1050 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x2,%ecx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
mov    %eax,0x4(%rsp)
xor    %eax,%eax
call   1050 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x2,%ecx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
mov    %eax,0x8(%rsp)
xor    %eax,%eax
call   1050 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x2,%ecx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
mov    %eax,0xc(%rsp)
xor    %eax,%eax
call   1050 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x2,%ecx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
mov    %eax,0x10(%rsp)
xor    %eax,%eax
call   1050 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x2,%ecx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
mov    %eax,0x14(%rsp)
xor    %eax,%eax
call   1050 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x2,%ecx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
mov    %eax,0x18(%rsp)
xor    %eax,%eax
call   1050 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x2,%ecx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
mov    %eax,0x1c(%rsp)
xor    %eax,%eax
call   1050 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x2,%ecx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
mov    %eax,0x20(%rsp)
xor    %eax,%eax
call   1050 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x2,%ecx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
mov    %eax,0x24(%rsp)
mov    %rsp,%rdi
mov    $0xa,%esi
call   1040 <largestSumContinousSubArray@plt>
lea    0xd0b(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i32]
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
br label %4
4: ; preds = %13, %0
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 10
br i1 %6, label %7, label %16
7: ; preds = %4
%8 = call i32 (...) @rand()
%9 = srem i32 %8, 10
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %11
store i32 %9, i32* %12
br label %13
13: ; preds = %7
%14 = load i32, i32* %3
%15 = add nsw i32 %14, 1
store i32 %15, i32* %3
br label %4
16: ; preds = %4
%17 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%18 = call i32 @largestSumContinousSubArray(i32* %17, i32 10)
%19 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = load i32, i32* %1
ret i32 %20
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca [10 x i32]
%2 = bitcast [10 x i32]* %1 to i8*
%3 = tail call i32 (...) @rand()
%4 = srem i32 %3, 10
%5 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
store i32 %4, i32* %5
%6 = tail call i32 (...) @rand()
%7 = srem i32 %6, 10
%8 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 1
store i32 %7, i32* %8
%9 = tail call i32 (...) @rand()
%10 = srem i32 %9, 10
%11 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 2
store i32 %10, i32* %11
%12 = tail call i32 (...) @rand()
%13 = srem i32 %12, 10
%14 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 3
store i32 %13, i32* %14
%15 = tail call i32 (...) @rand()
%16 = srem i32 %15, 10
%17 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 4
store i32 %16, i32* %17
%18 = tail call i32 (...) @rand()
%19 = srem i32 %18, 10
%20 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 5
store i32 %19, i32* %20
%21 = tail call i32 (...) @rand()
%22 = srem i32 %21, 10
%23 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 6
store i32 %22, i32* %23
%24 = tail call i32 (...) @rand()
%25 = srem i32 %24, 10
%26 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 7
store i32 %25, i32* %26
%27 = tail call i32 (...) @rand()
%28 = srem i32 %27, 10
%29 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 8
store i32 %28, i32* %29
%30 = tail call i32 (...) @rand()
%31 = srem i32 %30, 10
%32 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 9
store i32 %31, i32* %32
%33 = call i32 @largestSumContinousSubArray(i32* %5, i32 10)
%34 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %33)
ret i32 0
}