#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 */
scalar_t__ abs(int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int a[10], sum1 = 0, sum2 = 0, i;
  for (i = 0; i < 10; i++) {
    sum2 = sum1;
    scanf("%d", &a[i]);
    if (sum1 < 100)
      sum1 += a[i];
    if (abs(sum2 - 100) < abs(sum1 - 100)) {
      sum1 -= a[i];
      break;
    }
  }
  printf("%d\n", sum1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
cmpl   $0xa,-0x3c(%rbp)
jge    11e9 <main+0xb9>
mov    -0x34(%rbp),%eax
mov    %eax,-0x38(%rbp)
movslq -0x3c(%rbp),%rax
lea    -0x30(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe86(%rip),%rdi
call   1050 <scanf@plt>
cmpl   $0x64,-0x34(%rbp)
jge    1197 <main+0x67>
movslq -0x3c(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
add    -0x34(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x38(%rbp),%edi
sub    $0x64,%edi
call   1030 <abs@plt>
mov    %rax,-0x48(%rbp)
mov    -0x34(%rbp),%edi
sub    $0x64,%edi
call   1030 <abs@plt>
mov    %rax,%rcx
mov    -0x48(%rbp),%rax
cmp    %rcx,%rax
jge    11d6 <main+0xa6>
movslq -0x3c(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%ecx
mov    -0x34(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x34(%rbp)
jmp    11e9 <main+0xb9>
jmp    11db <main+0xab>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1154 <main+0x24>
mov    -0x34(%rbp),%esi
lea    0xe10(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x30,%rsp
xor    %ebx,%ebx
lea    0xebb(%rip),%r14
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
lea    (%rsp,%rbx,1),%r12
mov    %r14,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
mov    %ebp,%r15d
cmp    $0x63,%ebp
jg     116e <main+0x3e>
mov    (%r12),%r15d
add    %ebp,%r15d
add    $0xffffff9c,%ebp
mov    %ebp,%edi
call   1030 <abs@plt>
mov    %rax,%rbp
lea    -0x64(%r15),%edi
call   1030 <abs@plt>
cmp    %rax,%rbp
jl     1198 <main+0x68>
add    $0x4,%rbx
mov    %r15d,%ebp
cmp    $0x28,%rbx
jne    1150 <main+0x20>
jmp    119c <main+0x6c>
sub    (%rsp,%rbx,1),%r15d
lea    0xe60(%rip),%rdi
mov    %r15d,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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