#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*/ assert(int);
int maxSubarray(int *, int);
int /*<<< orphan*/ printf(char *);
int main(void) {
  int arr1[] = {-2, 1, -3, 4, -1, 2, 1, -5, 4};
  int arr2[] = {0};
  assert(maxSubarray(arr1, 9) == 6);
  assert(maxSubarray(arr2, 1) == 0);
  printf("All passed\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xe96(%rip),%rsi
mov    $0x24,%edx
call   1070 <memcpy@plt>
lea    -0x34(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1050 <memset@plt>
lea    -0x30(%rbp),%rdi
mov    $0x9,%esi
call   1030 <maxSubarray@plt>
cmp    $0x6,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    -0x34(%rbp),%rdi
mov    $0x1,%esi
call   1030 <maxSubarray@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    0xe5d(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x38,%rsp
mov    0xee6(%rip),%eax
mov    %eax,0x30(%rsp)
movaps 0xecb(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xeaf(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movl   $0x0,0xc(%rsp)
lea    0x10(%rsp),%rdi
mov    $0x9,%esi
call   1040 <maxSubarray@plt>
xor    %edi,%edi
cmp    $0x6,%eax
sete   %dil
call   1050 <assert@plt>
lea    0xc(%rsp),%rdi
mov    $0x1,%esi
call   1040 <maxSubarray@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1050 <assert@plt>
lea    0xe86(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x38,%rsp
ret

LLVM IR (-O0):
@__const.main.arr1 = [9 x i32] [i32 -2, i32 1, i32 -3, i32 4, i32 -1, i32 2, i32 1, i32 -5, i32 4]
@.str = [12 x i8] c"All passed\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [9 x i32]
%3 = alloca [1 x i32]
store i32 0, i32* %1
%4 = bitcast [9 x i32]* %2 to i8*
%5 = bitcast [1 x i32]* %3 to i8*
%6 = getelementptr inbounds [9 x i32], [9 x i32]* %2, i64 0, i64 0
%7 = call i32 @maxSubarray(i32* %6, i32 9)
%8 = icmp eq i32 %7, 6
%9 = zext i1 %8 to i32
%10 = call i32 @assert(i32 %9)
%11 = getelementptr inbounds [1 x i32], [1 x i32]* %3, i64 0, i64 0
%12 = call i32 @maxSubarray(i32* %11, i32 1)
%13 = icmp eq i32 %12, 0
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@__const.main.arr1 = [9 x i32] [i32 -2, i32 1, i32 -3, i32 4, i32 -1, i32 2, i32 1, i32 -5, i32 4]
@str = [11 x i8] c"All passed\00"
define i32 @main() {
%1 = alloca [9 x i32]
%2 = alloca [1 x i32]
%3 = bitcast [9 x i32]* %1 to i8*
%4 = bitcast [1 x i32]* %2 to i8*
%5 = getelementptr inbounds [1 x i32], [1 x i32]* %2, i64 0, i64 0
store i32 0, i32* %5
%6 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 0, i64 0
%7 = call i32 @maxSubarray(i32* %6, i32 9)
%8 = icmp eq i32 %7, 6
%9 = zext i1 %8 to i32
%10 = call i32 @assert(i32 %9)
%11 = call i32 @maxSubarray(i32* %5, i32 1)
%12 = icmp eq i32 %11, 0
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
ret i32 0
}