#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*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, long long);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ stdin;
char *strtok(char *, char *);
long long strtoll(char *, char **, int);
int main(int argc, char const *argv[]) {
  int num_items;
  scanf("%d\n", &num_items);
  char num_string[4096];
  fgets(num_string, 4095, stdin);
  char *num_str;
  long long sum = 0;
  char *endptr;
  num_str = strtok(num_string, " ");
  long long test;
  for (int i = 0; i < num_items; i++, num_str = strtok(NULL, " ")) {
    test = strtoll(num_str, &endptr, 10);
    sum += test;
  }
  printf("%lld\n", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1050,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe90(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1060 <scanf@plt>
lea    -0x1020(%rbp),%rdi
mov    0x2e61(%rip),%rax
mov    (%rax),%edx
mov    $0xfff,%esi
call   1040 <fgets@plt>
movq   $0x0,-0x1030(%rbp)
lea    -0x1020(%rbp),%rdi
lea    0xe58(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x1028(%rbp)
movl   $0x0,-0x1044(%rbp)
mov    -0x1044(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1230 <main+0xe0>
mov    -0x1028(%rbp),%rdi
lea    -0x1038(%rbp),%rsi
mov    $0xa,%edx
call   1050 <strtoll@plt>
mov    %rax,-0x1040(%rbp)
mov    -0x1040(%rbp),%rax
add    -0x1030(%rbp),%rax
mov    %rax,-0x1030(%rbp)
mov    -0x1044(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1044(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xde5(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x1028(%rbp)
jmp    11c2 <main+0x72>
mov    -0x1030(%rbp),%rsi
lea    0xdc8(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x1050,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1018,%rsp
lea    0xe9b(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x2e72(%rip),%rax
mov    (%rax),%edx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0xfff,%esi
call   1040 <fgets@plt>
lea    0xe73(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strtok@plt>
xor    %ebx,%ebx
cmpl   $0x0,0x4(%rsp)
jle    11e8 <main+0x98>
lea    0x8(%rsp),%r14
lea    0xe56(%rip),%r15
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rax,%rdi
mov    %r14,%rsi
mov    $0xa,%edx
call   1050 <strtoll@plt>
add    %rax,%r12
add    $0x1,%ebx
xor    %edi,%edi
mov    %r15,%rsi
call   1070 <strtok@plt>
cmp    0x4(%rsp),%ebx
jl     11c0 <main+0x70>
jmp    11eb <main+0x9b>
xor    %r12d,%r12d
lea    0xe14(%rip),%rdi
mov    %r12,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x1018,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
@stdin = global i32 0
@.str.1 = [2 x i8] c" \00"
@.str.2 = [6 x i8] c"%lld\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [4096 x i8]
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %6)
%14 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%15 = load i32, i32* @stdin
%16 = call i32 @fgets(i8* %14, i32 4095, i32 %15)
store i64 0, i64* %9
%17 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%18 = call i8* @strtok(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %18, i8** %8
store i32 0, i32* %12
br label %19
19: ; preds = %29, %2
%20 = load i32, i32* %12
%21 = load i32, i32* %6
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %33
23: ; preds = %19
%24 = load i8*, i8** %8
%25 = call i64 @strtoll(i8* %24, i8** %10, i32 10)
store i64 %25, i64* %11
%26 = load i64, i64* %11
%27 = load i64, i64* %9
%28 = add nsw i64 %27, %26
store i64 %28, i64* %9
br label %29
29: ; preds = %23
%30 = load i32, i32* %12
%31 = add nsw i32 %30, 1
store i32 %31, i32* %12
%32 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %32, i8** %8
br label %19
33: ; preds = %19
%34 = load i64, i64* %9
%35 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i64 %34)
ret i32 0
}

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