#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*/ FILE;

/* Variables and functions */
char EOF;
int INT_MIN;
int /*<<< orphan*/ *fopen(char *, char *);
char fscanf(int /*<<< orphan*/ *, char *, int *);
char getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  FILE *fp;
  int a, l = 0, m = INT_MIN;
  if (argc != 2) {
    printf("Usage: %s [FILE]\n", argv[0]);
    return 1;
  }
  fp = fopen(*++argv, "r");
  while (fscanf(fp, "%d", &a) != EOF || m > INT_MIN) {
    char c = getc(fp);
    if (a + l > m)
      m = a + l;
    if (a + l > 0)
      l += a;
    else
      l = 0;
    if (c == '\n' || c == EOF) {
      printf("%d\n", m);
      l = 0;
      m = INT_MIN;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x20(%rbp)
mov    0x2e7c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1194 <main+0x54>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12a2 <main+0x162>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rdi
lea    0xe64(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe52(%rip),%rsi
lea    -0x1c(%rbp),%rdx
call   1040 <fscanf@plt>
movsbl %al,%ecx
mov    0x2e13(%rip),%rax
movsbl (%rax),%edx
mov    $0x1,%al
cmp    %edx,%ecx
mov    %al,-0x26(%rbp)
jne    11f7 <main+0xb7>
mov    -0x24(%rbp),%eax
mov    0x2df1(%rip),%rcx
cmp    (%rcx),%eax
setg   %al
mov    %al,-0x26(%rbp)
mov    -0x26(%rbp),%al
test   $0x1,%al
jne    1207 <main+0xc7>
jmp    129b <main+0x15b>
mov    -0x18(%rbp),%rdi
call   1060 <getc@plt>
mov    %al,-0x25(%rbp)
mov    -0x1c(%rbp),%eax
add    -0x20(%rbp),%eax
cmp    -0x24(%rbp),%eax
jle    122b <main+0xeb>
mov    -0x1c(%rbp),%eax
add    -0x20(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x1c(%rbp),%eax
add    -0x20(%rbp),%eax
cmp    $0x0,%eax
jle    1248 <main+0x108>
mov    -0x1c(%rbp),%eax
add    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    124f <main+0x10f>
movl   $0x0,-0x20(%rbp)
movsbl -0x25(%rbp),%eax
cmp    $0xa,%eax
je     1272 <main+0x132>
movsbl -0x25(%rbp),%eax
mov    0x2d81(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    1296 <main+0x156>
mov    -0x24(%rbp),%esi
lea    0xd9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x20(%rbp)
mov    0x2d4f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
jmp    11b7 <main+0x77>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    1211 <main+0xd1>
mov    0x2e85(%rip),%rbp
mov    0x0(%rbp),%ebx
mov    0x8(%rsi),%rdi
lea    0xea9(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%r14
lea    0xe9c(%rip),%rsi
lea    0x4(%rsp),%rdx
mov    %rax,%rdi
call   1040 <fscanf@plt>
mov    0x2e5c(%rip),%r15
cmp    (%r15),%al
jne    119c <main+0x5c>
xor    %eax,%eax
cmp    0x0(%rbp),%ebx
jle    1227 <main+0xe7>
lea    0xe71(%rip),%r12
lea    0x4(%rsp),%r13
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1060 <getc@plt>
add    0x4(%rsp),%ebp
cmp    %ebx,%ebp
cmovg  %ebp,%ebx
test   %ebp,%ebp
mov    $0x0,%ecx
cmovs  %ecx,%ebp
cmp    $0xa,%al
je     11d4 <main+0x94>
cmp    (%r15),%al
jne    11ef <main+0xaf>
xor    %ebp,%ebp
lea    0xe3a(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2df3(%rip),%rax
mov    (%rax),%ebx
mov    %r14,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1040 <fscanf@plt>
cmp    (%r15),%al
jne    11b0 <main+0x70>
mov    0x2dd7(%rip),%rax
cmp    (%rax),%ebx
jg     11b0 <main+0x70>
xor    %eax,%eax
jmp    1227 <main+0xe7>
mov    (%rsi),%rsi
lea    0xde5(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@INT_MIN = global i32 0
@.str = [18 x i8] c"Usage: %s [FILE]\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%d\00"
@EOF = global i8 0
@.str.3 = [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 i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
%11 = load i32, i32* @INT_MIN
store i32 %11, i32* %9
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 2
br i1 %13, label %14, label %19
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %17)
store i32 1, i32* %3
br label %75
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i32 1
store i8** %21, i8*** %5
%22 = load i8*, i8** %21
%23 = call i32* @fopen(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %23, i32** %6
br label %24
24: ; preds = %73, %19
%25 = load i32*, i32** %6
%26 = call signext i8 @fscanf(i32* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %7)
%27 = sext i8 %26 to i32
%28 = load i8, i8* @EOF
%29 = sext i8 %28 to i32
%30 = icmp ne i32 %27, %29
br i1 %30, label %35, label %31
31: ; preds = %24
%32 = load i32, i32* %9
%33 = load i32, i32* @INT_MIN
%34 = icmp sgt i32 %32, %33
br label %35
35: ; preds = %31, %24
%36 = phi i1 [ true, %24 ], [ %34, %31 ]
br i1 %36, label %37, label %74
37: ; preds = %35
%38 = load i32*, i32** %6
%39 = call signext i8 @getc(i32* %38)
store i8 %39, i8* %10
%40 = load i32, i32* %7
%41 = load i32, i32* %8
%42 = add nsw i32 %40, %41
%43 = load i32, i32* %9
%44 = icmp sgt i32 %42, %43
br i1 %44, label %45, label %49
45: ; preds = %37
%46 = load i32, i32* %7
%47 = load i32, i32* %8
%48 = add nsw i32 %46, %47
store i32 %48, i32* %9
br label %49
49: ; preds = %45, %37
%50 = load i32, i32* %7
%51 = load i32, i32* %8
%52 = add nsw i32 %50, %51
%53 = icmp sgt i32 %52, 0
br i1 %53, label %54, label %58
54: ; preds = %49
%55 = load i32, i32* %7
%56 = load i32, i32* %8
%57 = add nsw i32 %56, %55
store i32 %57, i32* %8
br label %59
58: ; preds = %49
store i32 0, i32* %8
br label %59
59: ; preds = %58, %54
%60 = load i8, i8* %10
%61 = sext i8 %60 to i32
%62 = icmp eq i32 %61, 10
br i1 %62, label %69, label %63
63: ; preds = %59
%64 = load i8, i8* %10
%65 = sext i8 %64 to i32
%66 = load i8, i8* @EOF
%67 = sext i8 %66 to i32
%68 = icmp eq i32 %65, %67
br i1 %68, label %69, label %73
69: ; preds = %63, %59
%70 = load i32, i32* %9
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %70)
store i32 0, i32* %8
%72 = load i32, i32* @INT_MIN
store i32 %72, i32* %9
br label %73
73: ; preds = %69, %63
br label %24
74: ; preds = %35
store i32 0, i32* %3
br label %75
75: ; preds = %74, %14
%76 = load i32, i32* %3
ret i32 %76
}

LLVM IR (-O2):
@INT_MIN = global i32 0
@.str = [18 x i8] c"Usage: %s [FILE]\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%d\00"
@EOF = global i8 0
@.str.3 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = icmp eq i32 %0, 2
br i1 %5, label %9, label %6
6: ; preds = %2
%7 = load i8*, i8** %1
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %7)
br label %46
9: ; preds = %2
%10 = load i32, i32* @INT_MIN
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%14 = call signext i8 @fscanf(i32* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%15 = load i8, i8* @EOF
%16 = icmp ne i8 %14, %15
%17 = load i32, i32* @INT_MIN
%18 = icmp sgt i32 %10, %17
%19 = select i1 %16, i1 true, i1 %18
br i1 %19, label %20, label %46
20: ; preds = %9, %37
%21 = phi i32 [ %39, %37 ], [ %10, %9 ]
%22 = phi i32 [ %38, %37 ], [ 0, %9 ]
%23 = call signext i8 @getc(i32* %13)
%24 = load i32, i32* %3
%25 = add nsw i32 %24, %22
%26 = icmp sgt i32 %25, %21
%27 = select i1 %26, i32 %25, i32 %21
%28 = icmp sgt i32 %25, 0
%29 = select i1 %28, i32 %25, i32 0
%30 = icmp eq i8 %23, 10
%31 = load i8, i8* @EOF
%32 = icmp eq i8 %23, %31
%33 = select i1 %30, i1 true, i1 %32
br i1 %33, label %34, label %37
34: ; preds = %20
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %27)
%36 = load i32, i32* @INT_MIN
br label %37
37: ; preds = %20, %34
%38 = phi i32 [ 0, %34 ], [ %29, %20 ]
%39 = phi i32 [ %36, %34 ], [ %27, %20 ]
%40 = call signext i8 @fscanf(i32* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%41 = load i8, i8* @EOF
%42 = icmp ne i8 %40, %41
%43 = load i32, i32* @INT_MIN
%44 = icmp sgt i32 %39, %43
%45 = select i1 %42, i1 true, i1 %44
br i1 %45, label %20, label %46
46: ; preds = %37, %9, %6
%47 = phi i32 [ 1, %6 ], [ 0, %9 ], [ 0, %37 ]
ret i32 %47
}