#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 main() {
  int n, sum, a;
  while (EOF != scanf("%d", &n) && n != 0) {
    sum = 0;
    while (n--) {
      scanf("%d", &a);
      sum += a;
    }
    printf("%d\n", sum);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2eb2(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
lea    0xebc(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x20(%rbp),%rcx
mov    %rax,%rdx
xor    %eax,%eax
cmp    %rdx,%rcx
mov    %al,-0x11(%rbp)
je     116c <main+0x4c>
cmpl   $0x0,-0x8(%rbp)
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    117c <main+0x5c>
jmp    11c9 <main+0xa9>
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
je     11b5 <main+0x95>
lea    0xe62(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x10(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    1183 <main+0x63>
mov    -0xc(%rbp),%esi
lea    0xe44(%rip),%rdi
call   1030 <printf@plt>
jmp    112f <main+0xf>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x2eb6(%rip),%r13
mov    0x0(%r13),%rbx
lea    0xec3(%rip),%rdi
mov    %rsp,%rsi
call   1040 <scanf@plt>
cmp    %rax,%rbx
je     11ba <main+0x9a>
mov    (%rsp),%eax
test   %eax,%eax
je     11ba <main+0x9a>
lea    0xea8(%rip),%rbx
lea    0x4(%rsp),%r14
lea    0xe9f(%rip),%r15
mov    %rsp,%r12
nopw   0x0(%rax,%rax,1)
add    $0xffffffff,%eax
mov    %eax,(%rsp)
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <scanf@plt>
add    0x4(%rsp),%ebp
subl   $0x1,(%rsp)
jae    1180 <main+0x60>
mov    %r15,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
mov    0x0(%r13),%rbp
mov    %rbx,%rdi
mov    %r12,%rsi
call   1040 <scanf@plt>
cmp    %rax,%rbp
je     11ba <main+0x9a>
mov    (%rsp),%eax
test   %eax,%eax
jne    1170 <main+0x50>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i64 0
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
br label %5
5: ; preds = %24, %0
%6 = load i64, i64* @EOF
%7 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%8 = icmp ne i64 %6, %7
br i1 %8, label %9, label %12
9: ; preds = %5
%10 = load i32, i32* %2
%11 = icmp ne i32 %10, 0
br label %12
12: ; preds = %9, %5
%13 = phi i1 [ false, %5 ], [ %11, %9 ]
br i1 %13, label %14, label %27
14: ; preds = %12
store i32 0, i32* %3
br label %15
15: ; preds = %19, %14
%16 = load i32, i32* %2
%17 = add nsw i32 %16, -1
store i32 %17, i32* %2
%18 = icmp ne i32 %16, 0
br i1 %18, label %19, label %24
19: ; preds = %15
%20 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%21 = load i32, i32* %4
%22 = load i32, i32* %3
%23 = add nsw i32 %22, %21
store i32 %23, i32* %3
br label %15
24: ; preds = %15
%25 = load i32, i32* %3
%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 = %12
ret i32 0
}

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