#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*/ abort();
int add(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ atoi(char *);
int main(int argc, char **argv) {
  switch (argc) {
  case 1:
    return 0;
  case 2:
    return add(0, atoi(*(++argv)));
  case 3:
    return add(atoi(*(++argv)), atoi(*(++argv)));
  default:
    abort();
  }
}


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)
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
sub    $0x1,%eax
je     117c <main+0x4c>
jmp    115a <main+0x2a>
mov    -0x14(%rbp),%eax
sub    $0x2,%eax
je     1188 <main+0x58>
jmp    116b <main+0x3b>
mov    -0x14(%rbp),%eax
sub    $0x3,%eax
je     11b1 <main+0x81>
jmp    11f6 <main+0xc6>
movl   $0x0,-0x4(%rbp)
jmp    11fd <main+0xcd>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,%esi
xor    %edi,%edi
call   1040 <add@plt>
mov    %eax,-0x4(%rbp)
jmp    11fd <main+0xcd>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    -0x18(%rbp),%edi
mov    %eax,%esi
call   1040 <add@plt>
mov    %eax,-0x4(%rbp)
jmp    11fd <main+0xcd>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x1,%edi
je     1157 <main+0x27>
mov    %rsi,%rbx
cmp    $0x2,%edi
je     1160 <main+0x30>
cmp    $0x3,%edi
jne    117f <main+0x4f>
mov    0x8(%rbx),%rdi
call   1050 <atoi@plt>
mov    %eax,%ebp
mov    $0x2,%eax
jmp    1167 <main+0x37>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
xor    %ebp,%ebp
mov    $0x1,%eax
mov    (%rbx,%rax,8),%rdi
call   1050 <atoi@plt>
mov    %ebp,%edi
mov    %eax,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <add@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
switch i32 %6, label %24 [
i32 1, label %7
i32 2, label %8
i32 3, label %14
]
7: ; preds = %2
store i32 0, i32* %3
br label %26
8: ; preds = %2
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i32 1
store i8** %10, i8*** %5
%11 = load i8*, i8** %10
%12 = call i32 @atoi(i8* %11)
%13 = call i32 @add(i32 0, i32 %12)
store i32 %13, i32* %3
br label %26
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i32 1
store i8** %16, i8*** %5
%17 = load i8*, i8** %16
%18 = call i32 @atoi(i8* %17)
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i32 1
store i8** %20, i8*** %5
%21 = load i8*, i8** %20
%22 = call i32 @atoi(i8* %21)
%23 = call i32 @add(i32 %18, i32 %22)
store i32 %23, i32* %3
br label %26
24: ; preds = %2
%25 = call i32 (...) @abort()
unreachable
26: ; preds = %14, %8, %7
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture %1) {
switch i32 %0, label %7 [
i32 1, label %16
i32 2, label %9
i32 3, label %3
]
3: ; preds = %2
%4 = getelementptr inbounds i8*, i8** %1, i64 1
%5 = load i8*, i8** %4
%6 = tail call i32 @atoi(i8* %5)
br label %9
7: ; preds = %2
%8 = tail call i32 (...) @abort()
unreachable
9: ; preds = %2, %3
%10 = phi i64 [ 2, %3 ], [ 1, %2 ]
%11 = phi i32 [ %6, %3 ], [ 0, %2 ]
%12 = getelementptr inbounds i8*, i8** %1, i64 %10
%13 = load i8*, i8** %12
%14 = tail call i32 @atoi(i8* %13)
%15 = tail call i32 @add(i32 %11, i32 %14)
br label %16
16: ; preds = %9, %2
%17 = phi i32 [ 0, %2 ], [ %15, %9 ]
ret i32 %17
}