#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__ EOF;
int /*<<< orphan*/ printf(char *, int);
scalar_t__ scanf(char *, int *);
int sum(int *, int);
int main() {
  int i, n, in[10000];
  while (scanf("%d", &n) != EOF) {
    for (i = 0; i < n; i++) {
      scanf("%d", &in[i]);
    }
    printf("%d\n", sum(in, n));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x9c50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
mov    0x2e8f(%rip),%rcx
cmp    (%rcx),%rax
je     11c3 <main+0x93>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11a1 <main+0x71>
movslq -0x8(%rbp),%rax
lea    -0x9c50(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe72(%rip),%rdi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1169 <main+0x39>
lea    -0x9c50(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1040 <sum@plt>
mov    %eax,%esi
lea    0xe4a(%rip),%rdi
call   1030 <printf@plt>
jmp    1142 <main+0x12>
xor    %eax,%eax
add    $0x9c50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x9c58,%rsp
lea    0xeb8(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x2e8f(%rip),%rcx
cmp    (%rcx),%rax
jne    1172 <main+0x42>
xor    %eax,%eax
add    $0x9c58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x10(%rsp),%r14
lea    0xe82(%rip),%r13
lea    0xe7e(%rip),%r15
lea    0xc(%rsp),%r12
jmp    11b9 <main+0x89>
nopl   0x0(%rax)
mov    %r14,%rdi
call   1040 <sum@plt>
mov    %r15,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %r13,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
mov    0x2e34(%rip),%rcx
cmp    (%rcx),%rax
je     115e <main+0x2e>
mov    0xc(%rsp),%esi
test   %esi,%esi
jle    1190 <main+0x60>
mov    %r14,%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
add    $0x1,%rbp
movslq 0xc(%rsp),%rsi
add    $0x4,%rbx
cmp    %rsi,%rbp
jl     11d0 <main+0xa0>
jmp    1190 <main+0x60>

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() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [10000 x i32]
store i32 0, i32* %1
br label %5
5: ; preds = %22, %0
%6 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%7 = load i64, i64* @EOF
%8 = icmp ne i64 %6, %7
br i1 %8, label %9, label %27
9: ; preds = %5
store i32 0, i32* %2
br label %10
10: ; preds = %19, %9
%11 = load i32, i32* %2
%12 = load i32, i32* %3
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %22
14: ; preds = %10
%15 = load i32, i32* %2
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [10000 x i32], [10000 x i32]* %4, i64 0, i64 %16
%18 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %17)
br label %19
19: ; preds = %14
%20 = load i32, i32* %2
%21 = add nsw i32 %20, 1
store i32 %21, i32* %2
br label %10
22: ; preds = %10
%23 = getelementptr inbounds [10000 x i32], [10000 x i32]* %4, i64 0, i64 0
%24 = load i32, i32* %3
%25 = call i32 @sum(i32* %23, i32 %24)
%26 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %25)
br label %5
27: ; preds = %5
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() {
%1 = alloca i32
%2 = alloca [10000 x i32]
%3 = bitcast i32* %1 to i8*
%4 = bitcast [10000 x i32]* %2 to i8*
%5 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%6 = load i64, i64* @EOF
%7 = icmp eq i64 %5, %6
br i1 %7, label %28, label %8
8: ; preds = %0
%9 = getelementptr inbounds [10000 x i32], [10000 x i32]* %2, i64 0, i64 0
br label %10
10: ; preds = %8, %21
%11 = load i32, i32* %1
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %21
13: ; preds = %10, %13
%14 = phi i64 [ %17, %13 ], [ 0, %10 ]
%15 = getelementptr inbounds [10000 x i32], [10000 x i32]* %2, i64 0, i64 %14
%16 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %15)
%17 = add nuw nsw i64 %14, 1
%18 = load i32, i32* %1
%19 = sext i32 %18 to i64
%20 = icmp slt i64 %17, %19
br i1 %20, label %13, label %21
21: ; preds = %13, %10
%22 = phi i32 [ %11, %10 ], [ %18, %13 ]
%23 = call i32 @sum(i32* %9, i32 %22)
%24 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %23)
%25 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%26 = load i64, i64* @EOF
%27 = icmp eq i64 %25, %26
br i1 %27, label %28, label %10
28: ; preds = %21, %0
ret i32 0
}