#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 *, int);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ stdin;
char *strtok(char *, char *);
scalar_t__ strtol(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;
  int sum = 0;
  char *endptr;
  num_str = strtok(num_string, " ");
  for (int i = 0; i < num_items; i++, num_str = strtok(NULL, " "))
    sum += strtol(num_str, &endptr, 10);
  printf("%d\n", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1040,%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>
movl   $0x0,-0x102c(%rbp)
lea    -0x1020(%rbp),%rdi
lea    0xe59(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x1028(%rbp)
movl   $0x0,-0x103c(%rbp)
mov    -0x103c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1226 <main+0xd6>
mov    -0x1028(%rbp),%rdi
lea    -0x1038(%rbp),%rsi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %rax,%rcx
movslq -0x102c(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x102c(%rbp)
mov    -0x103c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x103c(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xdef(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x1028(%rbp)
jmp    11c1 <main+0x71>
mov    -0x102c(%rbp),%esi
lea    0xdcd(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x1040,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x1018,%rsp
lea    0xe9c(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x2e73(%rip),%rax
mov    (%rax),%edx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0xfff,%esi
call   1040 <fgets@plt>
lea    0xe74(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strtok@plt>
cmpl   $0x0,0x4(%rsp)
jle    11d7 <main+0x87>
xor    %ebx,%ebx
lea    0x8(%rsp),%r14
lea    0xe57(%rip),%r15
xor    %ebp,%ebp
nop
mov    %rax,%rdi
mov    %r14,%rsi
mov    $0xa,%edx
call   1050 <strtol@plt>
add    %eax,%ebp
add    $0x1,%ebx
xor    %edi,%edi
mov    %r15,%rsi
call   1070 <strtok@plt>
cmp    0x4(%rsp),%ebx
jl     11b0 <main+0x60>
jmp    11d9 <main+0x89>
xor    %ebp,%ebp
lea    0xe20(%rip),%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x1018,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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