#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*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ freopen(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ sscanf(char *, char *, int *);
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  int a, b;
  if (argc == 4) {
    freopen(argv[3], "w", stdout);
    sscanf(argv[1], "%d", &a);
    sscanf(argv[2], "%d", &b);
    fprintf(stdout, "%d", (a + b));
  } else {
    fprintf(stdout, "%d", 0);
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
jne    11bd <main+0x8d>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
mov    0x2e81(%rip),%rax
mov    (%rax),%edx
lea    0xe98(%rip),%rsi
call   1030 <freopen@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe86(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1050 <sscanf@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe6e(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1050 <sscanf@plt>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
add    -0x18(%rbp),%edx
lea    0xe4f(%rip),%rsi
call   1040 <fprintf@plt>
jmp    11e0 <main+0xb0>
mov    0x2e1c(%rip),%rax
mov    (%rax),%edi
lea    0xe35(%rip),%rsi
xor    %edx,%edx
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e7 <main+0xb7>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
cmp    $0x4,%edi
jne    119b <main+0x6b>
mov    %rsi,%rbx
mov    0x18(%rsi),%rdi
mov    0x2e94(%rip),%r15
mov    (%r15),%edx
lea    0xeaa(%rip),%rsi
call   1030 <freopen@plt>
mov    0x8(%rbx),%rdi
lea    0xe9c(%rip),%r14
lea    0xc(%rsp),%rdx
mov    %r14,%rsi
call   1050 <sscanf@plt>
mov    0x10(%rbx),%rdi
lea    0x8(%rsp),%rdx
mov    %r14,%rsi
call   1050 <sscanf@plt>
mov    (%r15),%edi
mov    0x8(%rsp),%edx
add    0xc(%rsp),%edx
mov    %r14,%rsi
call   1040 <fprintf@plt>
xor    %eax,%eax
jmp    11b7 <main+0x87>
mov    0x2e3e(%rip),%rax
mov    (%rax),%edi
lea    0xe57(%rip),%rsi
xor    %edx,%edx
call   1040 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

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