#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 */
typedef int /*<<< orphan*/ a;

/* Variables and functions */
scalar_t__ EOF;
int maxSubArray(int *, int);
int /*<<< orphan*/ memset(int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, int);
scalar_t__ scanf(char *, int *);
int main(int argc, char **argv) {
  int a[20], n;
  memset(a, 0, sizeof(a));
  while (scanf("%d", &n) != EOF) {
    for (int i = 0; i < n; ++i)
      scanf("%d", &a[i]);
    printf("%d\n", maxSubArray(a, n));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x50,%edx
call   1040 <memset@plt>
lea    0xe93(%rip),%rdi
lea    -0x64(%rbp),%rsi
call   1060 <scanf@plt>
mov    0x2e6b(%rip),%rcx
cmp    (%rcx),%rax
je     11e1 <main+0xa1>
movl   $0x0,-0x68(%rbp)
mov    -0x68(%rbp),%eax
cmp    -0x64(%rbp),%eax
jge    11c2 <main+0x82>
movslq -0x68(%rbp),%rax
lea    -0x60(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe51(%rip),%rdi
call   1060 <scanf@plt>
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    118d <main+0x4d>
lea    -0x60(%rbp),%rdi
mov    -0x64(%rbp),%esi
call   1050 <maxSubArray@plt>
mov    %eax,%esi
lea    0xe2c(%rip),%rdi
call   1030 <printf@plt>
jmp    1166 <main+0x26>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
lea    0x10(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x50,%edx
call   1040 <memset@plt>
lea    0xe97(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x2e6e(%rip),%rcx
cmp    (%rcx),%rax
jne    1190 <main+0x50>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe69(%rip),%r13
lea    0xe65(%rip),%r15
lea    0xc(%rsp),%r12
jmp    11d9 <main+0x99>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
call   1050 <maxSubArray@plt>
mov    %r15,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %r13,%rdi
mov    %r12,%rsi
call   1060 <scanf@plt>
mov    0x2e14(%rip),%rcx
cmp    (%rcx),%rax
je     117f <main+0x3f>
mov    0xc(%rsp),%esi
test   %esi,%esi
jle    11b0 <main+0x70>
mov    %r14,%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
add    $0x1,%rbp
movslq 0xc(%rsp),%rsi
add    $0x4,%rbx
cmp    %rsi,%rbp
jl     11f0 <main+0xb0>
jmp    11b0 <main+0x70>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@EOF = global i64 0
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [20 x i32]
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = getelementptr inbounds [20 x i32], [20 x i32]* %6, i64 0, i64 0
%10 = call i32 @memset(i32* %9, i32 0, i32 80)
br label %11
11: ; preds = %28, %2
%12 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %7)
%13 = load i64, i64* @EOF
%14 = icmp ne i64 %12, %13
br i1 %14, label %15, label %33
15: ; preds = %11
store i32 0, i32* %8
br label %16
16: ; preds = %25, %15
%17 = load i32, i32* %8
%18 = load i32, i32* %7
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %28
20: ; preds = %16
%21 = load i32, i32* %8
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [20 x i32], [20 x i32]* %6, i64 0, i64 %22
%24 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %23)
br label %25
25: ; preds = %20
%26 = load i32, i32* %8
%27 = add nsw i32 %26, 1
store i32 %27, i32* %8
br label %16
28: ; preds = %16
%29 = getelementptr inbounds [20 x i32], [20 x i32]* %6, i64 0, i64 0
%30 = load i32, i32* %7
%31 = call i32 @maxSubArray(i32* %29, i32 %30)
%32 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %31)
br label %11
33: ; preds = %11
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@EOF = global i64 0
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [20 x i32]
%4 = alloca i32
%5 = bitcast [20 x i32]* %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = getelementptr inbounds [20 x i32], [20 x i32]* %3, i64 0, i64 0
%8 = call i32 @memset(i32* %7, i32 0, i32 80)
%9 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%10 = load i64, i64* @EOF
%11 = icmp eq i64 %9, %10
br i1 %11, label %30, label %12
12: ; preds = %2, %15
%13 = load i32, i32* %4
%14 = icmp sgt i32 %13, 0
br i1 %14, label %22, label %15
15: ; preds = %22, %12
%16 = phi i32 [ %13, %12 ], [ %27, %22 ]
%17 = call i32 @maxSubArray(i32* %7, i32 %16)
%18 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %17)
%19 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%20 = load i64, i64* @EOF
%21 = icmp eq i64 %19, %20
br i1 %21, label %30, label %12
22: ; preds = %12, %22
%23 = phi i64 [ %26, %22 ], [ 0, %12 ]
%24 = getelementptr inbounds [20 x i32], [20 x i32]* %3, i64 0, i64 %23
%25 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %24)
%26 = add nuw nsw i64 %23, 1
%27 = load i32, i32* %4
%28 = sext i32 %27 to i64
%29 = icmp slt i64 %26, %28
br i1 %29, label %22, label %15
30: ; preds = %15, %2
ret i32 0
}