#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*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *);
int zuidaziliehe() {
  int arrSize;
  scanf("%d", &arrSize);
  int num, tmpSum = 0, maxSum = 0;
  while (arrSize-- > 0) {
    scanf("%d", &num);
    tmpSum += num;
    tmpSum = (tmpSum < 0) ? 0 : tmpSum;
    maxSum = (tmpSum > maxSum) ? tmpSum : maxSum;
  }
  printf("%d", maxSum);
  return 0;
}


x86 assembly (clang, -O0):
<zuidaziliehe>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xed1(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x4(%rbp)
cmp    $0x0,%eax
jle    11bb <zuidaziliehe+0x9b>
lea    0xe9f(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    1187 <zuidaziliehe+0x67>
xor    %eax,%eax
mov    %eax,-0x14(%rbp)
jmp    118d <zuidaziliehe+0x6d>
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jle    11aa <zuidaziliehe+0x8a>
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    11b0 <zuidaziliehe+0x90>
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    1146 <zuidaziliehe+0x26>
mov    -0x10(%rbp),%esi
lea    0xe3b(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<zuidaziliehe>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xecd(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x8(%rsp),%eax
lea    -0x1(%rax),%ecx
mov    %ecx,0x8(%rsp)
test   %eax,%eax
jle    1189 <zuidaziliehe+0x69>
xor    %r12d,%r12d
lea    0xeaa(%rip),%r14
lea    0xc(%rsp),%r15
xor    %ebx,%ebx
xor    %ebp,%ebp
nop
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
add    0xc(%rsp),%ebp
cmovs  %r12d,%ebp
cmp    %ebx,%ebp
cmova  %ebp,%ebx
mov    0x8(%rsp),%eax
lea    -0x1(%rax),%ecx
mov    %ecx,0x8(%rsp)
test   %eax,%eax
jg     1160 <zuidaziliehe+0x40>
jmp    118b <zuidaziliehe+0x6b>
xor    %ebx,%ebx
lea    0xe6e(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @zuidaziliehe() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%5 = bitcast i32* %2 to i8*
%6 = load i32, i32* %1
%7 = add nsw i32 %6, -1
store i32 %7, i32* %1
%8 = icmp sgt i32 %6, 0
br i1 %8, label %9, label %22
9: ; preds = %0, %9
%10 = phi i32 [ %18, %9 ], [ 0, %0 ]
%11 = phi i32 [ %16, %9 ], [ 0, %0 ]
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%13 = load i32, i32* %2
%14 = add nsw i32 %13, %11
%15 = icmp sgt i32 %14, 0
%16 = select i1 %15, i32 %14, i32 0
%17 = icmp ugt i32 %16, %10
%18 = select i1 %17, i32 %16, i32 %10
%19 = load i32, i32* %1
%20 = add nsw i32 %19, -1
store i32 %20, i32* %1
%21 = icmp sgt i32 %19, 0
br i1 %21, label %9, label %22
22: ; preds = %9, %0
%23 = phi i32 [ 0, %0 ], [ %18, %9 ]
%24 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %23)
ret i32 0
}