#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, long long);
int /*<<< orphan*/ scanf(char *, ...);
int main(int argc, char **argv) {
  long long sum = -1;
  if (2 >= argc) {
    unsigned n;
    scanf("%u", &n);
    sum = 0;
    int current = 0;
    for (unsigned i = 0; i < n; ++i) {
      scanf("%i", &current);
      sum += current;
    }
  }
  FILE *out = fopen(argv[1], "w");
  fprintf(out, "%lld\n", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0xffffffffffffffff,-0x18(%rbp)
ff
mov    $0x2,%eax
cmp    -0x8(%rbp),%eax
jl     11c1 <main+0x91>
lea    0xe9d(%rip),%rdi
lea    -0x1c(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movq   $0x0,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jae    11bc <main+0x8c>
lea    0xe6c(%rip),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movslq -0x20(%rbp),%rax
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1184 <main+0x54>
jmp    11c1 <main+0x91>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe36(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe20(%rip),%rsi
call   1030 <fprintf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    $0xffffffffffffffff,%rbx
cmp    $0x2,%edi
jg     11a2 <main+0x72>
lea    0xeae(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
movl   $0x0,0x8(%rsp)
cmpl   $0x0,0xc(%rsp)
je     11a0 <main+0x70>
lea    0xe8f(%rip),%r15
lea    0x8(%rsp),%r12
xor    %ebx,%ebx
xor    %ebp,%ebp
nopl   (%rax)
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
movslq 0x8(%rsp),%rax
add    %rax,%rbx
add    $0x1,%ebp
cmp    0xc(%rsp),%ebp
jb     1180 <main+0x50>
jmp    11a2 <main+0x72>
xor    %ebx,%ebx
mov    0x8(%r14),%rdi
lea    0xe59(%rip),%rsi
call   1050 <fopen@plt>
lea    0xe4f(%rip),%rsi
mov    %rax,%rdi
mov    %rbx,%rdx
call   1030 <fprintf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%u\00"
@.str.1 = [3 x i8] c"%i\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [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 i64
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 -1, i64* %6
%11 = load i32, i32* %4
%12 = icmp sge i32 2, %11
br i1 %12, label %13, label %29
13: ; preds = %2
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %7)
store i64 0, i64* %6
store i32 0, i32* %8
store i32 0, i32* %9
br label %15
15: ; preds = %25, %13
%16 = load i32, i32* %9
%17 = load i32, i32* %7
%18 = icmp ult i32 %16, %17
br i1 %18, label %19, label %28
19: ; preds = %15
%20 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %8)
%21 = load i32, i32* %8
%22 = sext i32 %21 to i64
%23 = load i64, i64* %6
%24 = add nsw i64 %23, %22
store i64 %24, i64* %6
br label %25
25: ; preds = %19
%26 = load i32, i32* %9
%27 = add i32 %26, 1
store i32 %27, i32* %9
br label %15
28: ; preds = %15
br label %29
29: ; preds = %28, %2
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
%33 = call i32* @fopen(i8* %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %33, i32** %10
%34 = load i32*, i32** %10
%35 = load i64, i64* %6
%36 = call i32 @fprintf(i32* %34, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i64 %35)
ret i32 0
}

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