#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 main() {
  int numOfLines = 100;
  int n;
  int arr[100];
  int i;
  for (i = 0; i < numOfLines; i++) {
    scanf("%d ", &n);
    arr[i] = n;
  }
  numOfLines--;
  while (numOfLines > 0) {
    for (i = 0; i < numOfLines; i++) {
      scanf("%d ", &n);
      arr[i] = n + (arr[i] > arr[i + 1] ? arr[i] : arr[i + 1]);
    }
    numOfLines--;
  }
  printf("sum: %d\n", arr[0]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x64,-0x8(%rbp)
movl   $0x0,-0x1a4(%rbp)
mov    -0x1a4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1187 <main+0x67>
lea    0xea7(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%ecx
movslq -0x1a4(%rbp),%rax
mov    %ecx,-0x1a0(%rbp,%rax,4)
mov    -0x1a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a4(%rbp)
jmp    1143 <main+0x23>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    1262 <main+0x142>
movl   $0x0,-0x1a4(%rbp)
mov    -0x1a4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1254 <main+0x134>
lea    0xe46(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x1a8(%rbp)
movslq -0x1a4(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%eax
mov    -0x1a4(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
cmp    -0x1a0(%rbp,%rcx,4),%eax
jle    120c <main+0xec>
movslq -0x1a4(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%eax
mov    %eax,-0x1ac(%rbp)
jmp    1224 <main+0x104>
mov    -0x1a4(%rbp),%eax
add    $0x1,%eax
cltq
mov    -0x1a0(%rbp,%rax,4),%eax
mov    %eax,-0x1ac(%rbp)
mov    -0x1a8(%rbp),%ecx
mov    -0x1ac(%rbp),%eax
add    %eax,%ecx
movslq -0x1a4(%rbp),%rax
mov    %ecx,-0x1a0(%rbp,%rax,4)
mov    -0x1a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a4(%rbp)
jmp    11a4 <main+0x84>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    1190 <main+0x70>
mov    -0x1a0(%rbp),%esi
lea    0xd95(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1a8,%rsp
xor    %ebx,%ebx
lea    0xec9(%rip),%r14
lea    0xc(%rsp),%r15
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
mov    %eax,0x10(%rsp,%rbx,4)
add    $0x1,%rbx
cmp    $0x64,%rbx
jne    1140 <main+0x20>
mov    $0x63,%r12d
lea    0xe96(%rip),%r14
lea    0xc(%rsp),%r15
nop
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
mov    0x10(%rsp,%rbx,4),%eax
mov    0x14(%rsp,%rbx,4),%ecx
cmp    %ecx,%eax
cmovg  %eax,%ecx
add    0xc(%rsp),%ecx
mov    %ecx,0x10(%rsp,%rbx,4)
lea    0x1(%rbx),%rax
mov    %rax,%rbx
cmp    %rax,%r12
jne    1180 <main+0x60>
lea    -0x1(%r12),%rax
cmp    $0x1,%r12
mov    %rax,%r12
ja     1170 <main+0x50>
mov    0x10(%rsp),%esi
lea    0xe3f(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x1a8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d \00"
@.str.1 = [9 x i8] c"sum: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [100 x i32]
%5 = alloca i32
store i32 0, i32* %1
store i32 100, i32* %2
store i32 0, i32* %5
br label %6
6: ; preds = %16, %0
%7 = load i32, i32* %5
%8 = load i32, i32* %2
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %19
10: ; preds = %6
%11 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %3)
%12 = load i32, i32* %3
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 %14
store i32 %12, i32* %15
br label %16
16: ; preds = %10
%17 = load i32, i32* %5
%18 = add nsw i32 %17, 1
store i32 %18, i32* %5
br label %6
19: ; preds = %6
%20 = load i32, i32* %2
%21 = add nsw i32 %20, -1
store i32 %21, i32* %2
br label %22
22: ; preds = %63, %19
%23 = load i32, i32* %2
%24 = icmp sgt i32 %23, 0
br i1 %24, label %25, label %66
25: ; preds = %22
store i32 0, i32* %5
br label %26
26: ; preds = %60, %25
%27 = load i32, i32* %5
%28 = load i32, i32* %2
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %63
30: ; preds = %26
%31 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %3)
%32 = load i32, i32* %3
%33 = load i32, i32* %5
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 %34
%36 = load i32, i32* %35
%37 = load i32, i32* %5
%38 = add nsw i32 %37, 1
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 %39
%41 = load i32, i32* %40
%42 = icmp sgt i32 %36, %41
br i1 %42, label %43, label %48
43: ; preds = %30
%44 = load i32, i32* %5
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 %45
%47 = load i32, i32* %46
br label %54
48: ; preds = %30
%49 = load i32, i32* %5
%50 = add nsw i32 %49, 1
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 %51
%53 = load i32, i32* %52
br label %54
54: ; preds = %48, %43
%55 = phi i32 [ %47, %43 ], [ %53, %48 ]
%56 = add nsw i32 %32, %55
%57 = load i32, i32* %5
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 %58
store i32 %56, i32* %59
br label %60
60: ; preds = %54
%61 = load i32, i32* %5
%62 = add nsw i32 %61, 1
store i32 %62, i32* %5
br label %26
63: ; preds = %26
%64 = load i32, i32* %2
%65 = add nsw i32 %64, -1
store i32 %65, i32* %2
br label %22
66: ; preds = %22
%67 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 0
%68 = load i32, i32* %67
%69 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %68)
ret i32 0
}

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