#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 atoi(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, ...);
int /*<<< orphan*/ printf(char *, int);
int process(int, int);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  int arg1 = 0, arg2 = 0;
  if (argc > 1)
    arg1 = atoi(argv[1]);
  if (argc == 3)
    arg2 = atoi(argv[2]);
  fprintf(stderr, "processed %i arguments\n", argc - 1);
  fprintf(stderr, "arg1 = %i, arg2 = %i\n", arg1, arg2);
  printf("%i\n", process(arg1, arg2));
  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)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    117e <main+0x3e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x3,-0x8(%rbp)
jne    1198 <main+0x58>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    0x2e41(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%edx
sub    $0x1,%edx
lea    0xe52(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2e24(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xe4d(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1040 <process@plt>
mov    %eax,%esi
lea    0xe44(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebp
xor    %r15d,%r15d
cmp    $0x2,%edi
jl     1173 <main+0x33>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1060 <atoi@plt>
mov    %eax,%r14d
cmp    $0x3,%ebp
jne    1176 <main+0x36>
mov    0x10(%rbx),%rdi
call   1060 <atoi@plt>
mov    %eax,%r15d
jmp    1176 <main+0x36>
xor    %r14d,%r14d
mov    0x2e63(%rip),%rbx
mov    (%rbx),%edi
add    $0xffffffff,%ebp
lea    0xe77(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe7d(%rip),%rsi
mov    %r14d,%edx
mov    %r15d,%ecx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    %r14d,%edi
mov    %r15d,%esi
call   1040 <process@plt>
lea    0xe70(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [24 x i8] c"processed %i arguments\0A\00"
@.str.1 = [22 x i8] c"arg1 = %i, arg2 = %i\0A\00"
@.str.2 = [4 x i8] c"%i\0A\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
store i32 0, i32* %6
store i32 0, i32* %7
%8 = load i32, i32* %4
%9 = icmp sgt i32 %8, 1
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i32 @atoi(i8* %13)
store i32 %14, i32* %6
br label %15
15: ; preds = %10, %2
%16 = load i32, i32* %4
%17 = icmp eq i32 %16, 3
br i1 %17, label %18, label %23
18: ; preds = %15
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 2
%21 = load i8*, i8** %20
%22 = call i32 @atoi(i8* %21)
store i32 %22, i32* %7
br label %23
23: ; preds = %18, %15
%24 = load i32, i32* @stderr
%25 = load i32, i32* %4
%26 = sub nsw i32 %25, 1
%27 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %26)
%28 = load i32, i32* @stderr
%29 = load i32, i32* %6
%30 = load i32, i32* %7
%31 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %29, i32 %30)
%32 = load i32, i32* %6
%33 = load i32, i32* %7
%34 = call i32 @process(i32 %32, i32 %33)
%35 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %34)
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [24 x i8] c"processed %i arguments\0A\00"
@.str.1 = [22 x i8] c"arg1 = %i, arg2 = %i\0A\00"
@.str.2 = [4 x i8] c"%i\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %13
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @atoi(i8* %6)
%8 = icmp eq i32 %0, 3
br i1 %8, label %9, label %13
9: ; preds = %4
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = load i8*, i8** %10
%12 = tail call i32 @atoi(i8* %11)
br label %13
13: ; preds = %2, %9, %4
%14 = phi i32 [ %7, %9 ], [ %7, %4 ], [ 0, %2 ]
%15 = phi i32 [ %12, %9 ], [ 0, %4 ], [ 0, %2 ]
%16 = load i32, i32* @stderr
%17 = add nsw i32 %0, -1
%18 = tail call i32 (i32, i8*, i32, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = load i32, i32* @stderr
%20 = tail call i32 (i32, i8*, i32, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %14, i32 %15)
%21 = tail call i32 @process(i32 %14, i32 %15)
%22 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %21)
ret i32 0
}