#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 max_subarray(int *, int);
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char const *argv[]) {
  int a[] = {1, 2, 3, 4, 5, 6};
  int b[] = {6, 5, 4, 3, 2, 1};
  int c[] = {-6, -5, -3, -4, -2, -1};
  int d[] = {-6, -5, -3, 4, 2, -1};
  printf("Max of a %d\n", max_subarray(a, 6));
  printf("Max of b %d\n", max_subarray(b, 6));
  printf("Max of c %d\n", max_subarray(c, 6));
  printf("Max of d %d\n", max_subarray(d, 6));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xec0(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xebd(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xeba(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xebf(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0xebc(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    0xeb9(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xebe(%rip),%rax
mov    %rax,-0x70(%rbp)
mov    0xebb(%rip),%rax
mov    %rax,-0x68(%rbp)
mov    0xeb8(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    0xebd(%rip),%rax
mov    %rax,-0x90(%rbp)
mov    0xeb7(%rip),%rax
mov    %rax,-0x88(%rbp)
mov    0xeb1(%rip),%rax
mov    %rax,-0x80(%rbp)
lea    -0x30(%rbp),%rdi
mov    $0x6,%esi
call   1040 <max_subarray@plt>
mov    %eax,%esi
lea    0xe9e(%rip),%rdi
call   1030 <printf@plt>
lea    -0x50(%rbp),%rdi
mov    $0x6,%esi
call   1040 <max_subarray@plt>
mov    %eax,%esi
lea    0xe8f(%rip),%rdi
call   1030 <printf@plt>
lea    -0x70(%rbp),%rdi
mov    $0x6,%esi
call   1040 <max_subarray@plt>
mov    %eax,%esi
lea    0xe80(%rip),%rdi
call   1030 <printf@plt>
lea    -0x90(%rbp),%rdi
mov    $0x6,%esi
call   1040 <max_subarray@plt>
mov    %eax,%esi
lea    0xe6e(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x78,%rsp
mov    0xee5(%rip),%rax
mov    %rax,0x70(%rsp)
movaps 0xec9(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
mov    0xeed(%rip),%rax
mov    %rax,0x50(%rsp)
movaps 0xed1(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
mov    0xef5(%rip),%rax
mov    %rax,0x30(%rsp)
movaps 0xed9(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
mov    0xefd(%rip),%rax
mov    %rax,0x10(%rsp)
movaps 0xee1(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0x60(%rsp),%rdi
mov    $0x6,%esi
call   1040 <max_subarray@plt>
lea    0xedf(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
lea    0x40(%rsp),%rdi
mov    $0x6,%esi
call   1040 <max_subarray@plt>
lea    0xecf(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
lea    0x20(%rsp),%rdi
mov    $0x6,%esi
call   1040 <max_subarray@plt>
lea    0xebf(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %rsp,%rdi
mov    $0x6,%esi
call   1040 <max_subarray@plt>
lea    0xeb1(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x78,%rsp
ret

LLVM IR (-O0):
@__const.main.a = [6 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5, i32 6]
@__const.main.b = [6 x i32] [i32 6, i32 5, i32 4, i32 3, i32 2, i32 1]
@__const.main.c = [6 x i32] [i32 -6, i32 -5, i32 -3, i32 -4, i32 -2, i32 -1]
@__const.main.d = [6 x i32] [i32 -6, i32 -5, i32 -3, i32 4, i32 2, i32 -1]
@.str = [13 x i8] c"Max of a %d\0A\00"
@.str.1 = [13 x i8] c"Max of b %d\0A\00"
@.str.2 = [13 x i8] c"Max of c %d\0A\00"
@.str.3 = [13 x i8] c"Max of d %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [6 x i32]
%7 = alloca [6 x i32]
%8 = alloca [6 x i32]
%9 = alloca [6 x i32]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = bitcast [6 x i32]* %6 to i8*
%11 = bitcast [6 x i32]* %7 to i8*
%12 = bitcast [6 x i32]* %8 to i8*
%13 = bitcast [6 x i32]* %9 to i8*
%14 = getelementptr inbounds [6 x i32], [6 x i32]* %6, i64 0, i64 0
%15 = call i32 @max_subarray(i32* %14, i32 6)
%16 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds [6 x i32], [6 x i32]* %7, i64 0, i64 0
%18 = call i32 @max_subarray(i32* %17, i32 6)
%19 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %18)
%20 = getelementptr inbounds [6 x i32], [6 x i32]* %8, i64 0, i64 0
%21 = call i32 @max_subarray(i32* %20, i32 6)
%22 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %21)
%23 = getelementptr inbounds [6 x i32], [6 x i32]* %9, i64 0, i64 0
%24 = call i32 @max_subarray(i32* %23, i32 6)
%25 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %24)
ret i32 0
}

LLVM IR (-O2):
@__const.main.a = [6 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5, i32 6]
@__const.main.b = [6 x i32] [i32 6, i32 5, i32 4, i32 3, i32 2, i32 1]
@__const.main.c = [6 x i32] [i32 -6, i32 -5, i32 -3, i32 -4, i32 -2, i32 -1]
@__const.main.d = [6 x i32] [i32 -6, i32 -5, i32 -3, i32 4, i32 2, i32 -1]
@.str = [13 x i8] c"Max of a %d\0A\00"
@.str.1 = [13 x i8] c"Max of b %d\0A\00"
@.str.2 = [13 x i8] c"Max of c %d\0A\00"
@.str.3 = [13 x i8] c"Max of d %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [6 x i32]
%4 = alloca [6 x i32]
%5 = alloca [6 x i32]
%6 = alloca [6 x i32]
%7 = bitcast [6 x i32]* %3 to i8*
%8 = bitcast [6 x i32]* %4 to i8*
%9 = bitcast [6 x i32]* %5 to i8*
%10 = bitcast [6 x i32]* %6 to i8*
%11 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 0
%12 = call i32 @max_subarray(i32* %11, i32 6)
%13 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = getelementptr inbounds [6 x i32], [6 x i32]* %4, i64 0, i64 0
%15 = call i32 @max_subarray(i32* %14, i32 6)
%16 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds [6 x i32], [6 x i32]* %5, i64 0, i64 0
%18 = call i32 @max_subarray(i32* %17, i32 6)
%19 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %18)
%20 = getelementptr inbounds [6 x i32], [6 x i32]* %6, i64 0, i64 0
%21 = call i32 @max_subarray(i32* %20, i32 6)
%22 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %21)
ret i32 0
}