#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 a[1000], i, n, sum = 0;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    sum = sum + a[i];
  }
  printf("%d", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xfc0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xfbc(%rbp)
lea    0xebd(%rip),%rdi
lea    -0xfb8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0xfb4(%rbp)
mov    -0xfb4(%rbp),%eax
cmp    -0xfb8(%rbp),%eax
jge    11ba <main+0x9a>
movslq -0xfb4(%rbp),%rax
lea    -0xfb0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe79(%rip),%rdi
call   1040 <scanf@plt>
mov    -0xfbc(%rbp),%eax
movslq -0xfb4(%rbp),%rcx
add    -0xfb0(%rbp,%rcx,4),%eax
mov    %eax,-0xfbc(%rbp)
mov    -0xfb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xfb4(%rbp)
jmp    1159 <main+0x39>
mov    -0xfbc(%rbp),%esi
lea    0xe39(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xfc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0xfb8,%rsp
lea    0xecc(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    1182 <main+0x62>
xor    %ebp,%ebp
lea    0x10(%rsp),%rbx
lea    0xead(%rip),%r14
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
add    (%rbx),%r15d
add    $0x1,%rbp
movslq 0xc(%rsp),%rax
add    $0x4,%rbx
cmp    %rax,%rbp
jl     1160 <main+0x40>
jmp    1185 <main+0x65>
xor    %r15d,%r15d
lea    0xe74(%rip),%rdi
mov    %r15d,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xfb8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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