#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__ atoi(char *);
int /*<<< orphan*/ fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, long long);
int main(int argc, char **argv) {
  char *path = argv[1];
  long long sum = 0;
  for (unsigned i = 2; i < argc; ++i) {
    sum += atoi(argv[i]);
  }
  fprintf(fopen(path, "w"), "%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)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x2,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jae    1193 <main+0x63>
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
mov    (%rax,%rcx,8),%rdi
call   1050 <atoi@plt>
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1161 <main+0x31>
mov    -0x18(%rbp),%rdi
lea    0xe62(%rip),%rsi
call   1040 <fopen@plt>
mov    %eax,%edi
mov    -0x20(%rbp),%rdx
lea    0xe52(%rip),%rsi
call   1030 <fprintf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    0x8(%rsi),%r14
cmp    $0x3,%edi
jb     1167 <main+0x37>
mov    %rsi,%r15
mov    %edi,%r12d
mov    $0x2,%ebx
xor    %r13d,%r13d
mov    (%r15,%rbx,8),%rdi
call   1050 <atoi@plt>
add    %rax,%r13
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1150 <main+0x20>
jmp    116a <main+0x3a>
xor    %r13d,%r13d
lea    0xe8f(%rip),%rsi
mov    %r14,%rdi
call   1040 <fopen@plt>
lea    0xe82(%rip),%rsi
mov    %eax,%edi
mov    %r13,%rdx
call   1030 <fprintf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c"w\00"
@.str.1 = [6 x i8] c"%lld\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = icmp ugt i32 %0, 2
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = zext i32 %0 to i64
br label %12
8: ; preds = %12, %2
%9 = phi i64 [ 0, %2 ], [ %18, %12 ]
%10 = tail call i32 @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i64 %9)
ret i32 0
12: ; preds = %6, %12
%13 = phi i64 [ 2, %6 ], [ %19, %12 ]
%14 = phi i64 [ 0, %6 ], [ %18, %12 ]
%15 = getelementptr inbounds i8*, i8** %1, i64 %13
%16 = load i8*, i8** %15
%17 = tail call i64 @atoi(i8* %16)
%18 = add nsw i64 %17, %14
%19 = add nuw nsw i64 %13, 1
%20 = icmp eq i64 %19, %7
br i1 %20, label %8, label %12
}