#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_sub_array(int *, int);
int /*<<< orphan*/ print_array(int *, int);
int /*<<< orphan*/ printf(char *, int);
int main() {
  int arr_a[10] = {-2, 1, -3, 4, -1, 2, 1, -5, 4, -1};
  int arr_b[10] = {-3, -2, -1, -2, -3, -4, -5, -6, -7, -8};
  int arr_c[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
  print_array(arr_a, 10);
  printf("max sub array is: %d\n", max_sub_array(arr_a, 10));
  print_array(arr_b, 10);
  printf("max sub array is: %d\n", max_sub_array(arr_b, 10));
  print_array(arr_c, 10);
  printf("max sub array is: %d\n", max_sub_array(arr_c, 10));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xea3(%rip),%rsi
mov    $0x28,%edx
call   1050 <memcpy@plt>
lea    -0x60(%rbp),%rdi
lea    0xebe(%rip),%rsi
mov    $0x28,%edx
call   1050 <memcpy@plt>
lea    -0x90(%rbp),%rdi
lea    0xed6(%rip),%rsi
mov    $0x28,%edx
call   1050 <memcpy@plt>
lea    -0x30(%rbp),%rdi
mov    $0xa,%esi
call   1030 <print_array@plt>
lea    -0x30(%rbp),%rdi
mov    $0xa,%esi
call   1060 <max_sub_array@plt>
mov    %eax,%esi
lea    0xecf(%rip),%rdi
call   1040 <printf@plt>
lea    -0x60(%rbp),%rdi
mov    $0xa,%esi
call   1030 <print_array@plt>
lea    -0x60(%rbp),%rdi
mov    $0xa,%esi
call   1060 <max_sub_array@plt>
mov    %eax,%esi
lea    0xea5(%rip),%rdi
call   1040 <printf@plt>
lea    -0x90(%rbp),%rdi
mov    $0xa,%esi
call   1030 <print_array@plt>
lea    -0x90(%rbp),%rdi
mov    $0xa,%esi
call   1060 <max_sub_array@plt>
mov    %eax,%esi
lea    0xe75(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x88,%rsp
mov    0xedf(%rip),%rax
mov    %rax,0x80(%rsp)
movaps 0xec0(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0xea4(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
mov    0xee8(%rip),%rax
mov    %rax,0x50(%rsp)
movaps 0xecc(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xeb0(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
mov    0xef4(%rip),%rax
mov    %rax,0x20(%rsp)
movaps 0xed8(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xebc(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0x60(%rsp),%rbx
mov    %rbx,%rdi
mov    $0xa,%esi
call   1030 <print_array@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1050 <max_sub_array@plt>
lea    0xeba(%rip),%r14
mov    %r14,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
mov    $0xa,%esi
call   1030 <print_array@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1050 <max_sub_array@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0xa,%esi
call   1030 <print_array@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1050 <max_sub_array@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.arr_a = [10 x i32] [i32 -2, i32 1, i32 -3, i32 4, i32 -1, i32 2, i32 1, i32 -5, i32 4, i32 -1]
@__const.main.arr_b = [10 x i32] [i32 -3, i32 -2, i32 -1, i32 -2, i32 -3, i32 -4, i32 -5, i32 -6, i32 -7, i32 -8]
@__const.main.arr_c = [10 x i32] [i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9]
@.str = [22 x i8] c"max sub array is: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i32]
%3 = alloca [10 x i32]
%4 = alloca [10 x i32]
store i32 0, i32* %1
%5 = bitcast [10 x i32]* %2 to i8*
%6 = bitcast [10 x i32]* %3 to i8*
%7 = bitcast [10 x i32]* %4 to i8*
%8 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%9 = call i32 @print_array(i32* %8, i32 10)
%10 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%11 = call i32 @max_sub_array(i32* %10, i32 10)
%12 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
%14 = call i32 @print_array(i32* %13, i32 10)
%15 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
%16 = call i32 @max_sub_array(i32* %15, i32 10)
%17 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 0
%19 = call i32 @print_array(i32* %18, i32 10)
%20 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 0
%21 = call i32 @max_sub_array(i32* %20, i32 10)
%22 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %21)
ret i32 0
}

LLVM IR (-O2):
@__const.main.arr_a = [10 x i32] [i32 -2, i32 1, i32 -3, i32 4, i32 -1, i32 2, i32 1, i32 -5, i32 4, i32 -1]
@__const.main.arr_b = [10 x i32] [i32 -3, i32 -2, i32 -1, i32 -2, i32 -3, i32 -4, i32 -5, i32 -6, i32 -7, i32 -8]
@__const.main.arr_c = [10 x i32] [i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9]
@.str = [22 x i8] c"max sub array is: %d\0A\00"
define i32 @main() {
%1 = alloca [10 x i32]
%2 = alloca [10 x i32]
%3 = alloca [10 x i32]
%4 = bitcast [10 x i32]* %1 to i8*
%5 = bitcast [10 x i32]* %2 to i8*
%6 = bitcast [10 x i32]* %3 to i8*
%7 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%8 = call i32 @print_array(i32* %7, i32 10)
%9 = call i32 @max_sub_array(i32* %7, i32 10)
%10 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%12 = call i32 @print_array(i32* %11, i32 10)
%13 = call i32 @max_sub_array(i32* %11, i32 10)
%14 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
%16 = call i32 @print_array(i32* %15, i32 10)
%17 = call i32 @max_sub_array(i32* %15, i32 10)
%18 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %17)
ret i32 0
}