#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 *);
char *itoan(int, char *, int, unsigned int);
int /*<<< orphan*/ printf(char *, char *);
int main(int argc, char **argv) {
  char buf[255];
  int i;
  unsigned base;
  i = (argc > 1) ? atoi(argv[1]) : 0;
  base = (argc > 2) ? (unsigned)atoi(argv[2]) : 10;
  printf("i:%s\n", itoan(i, buf, 255, base));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    116b <main+0x3b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x11c(%rbp)
jmp    1178 <main+0x48>
xor    %eax,%eax
mov    %eax,-0x11c(%rbp)
jmp    1178 <main+0x48>
mov    -0x11c(%rbp),%eax
mov    %eax,-0x114(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    11a6 <main+0x76>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x120(%rbp)
jmp    11b6 <main+0x86>
mov    $0xa,%eax
mov    %eax,-0x120(%rbp)
jmp    11b6 <main+0x86>
mov    -0x120(%rbp),%eax
mov    %eax,-0x118(%rbp)
mov    -0x114(%rbp),%edi
lea    -0x110(%rbp),%rsi
mov    -0x118(%rbp),%ecx
mov    $0xff,%edx
call   1050 <itoan@plt>
mov    %rax,%rsi
lea    0xe17(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    $0xa,%r14d
xor    %ebp,%ebp
cmp    $0x2,%edi
jl     116b <main+0x3b>
mov    %rsi,%r15
mov    %edi,%ebx
mov    0x8(%rsi),%rdi
call   1040 <atoi@plt>
mov    %eax,%ebp
cmp    $0x2,%ebx
je     116b <main+0x3b>
mov    0x10(%r15),%rdi
call   1040 <atoi@plt>
mov    %eax,%r14d
mov    %rsp,%rsi
mov    %ebp,%edi
mov    $0xff,%edx
mov    %r14d,%ecx
call   1050 <itoan@plt>
lea    0xe7c(%rip),%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"i:%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [255 x i8]
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp sgt i32 %9, 1
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @atoi(i8* %14)
br label %17
16: ; preds = %2
br label %17
17: ; preds = %16, %11
%18 = phi i32 [ %15, %11 ], [ 0, %16 ]
store i32 %18, i32* %7
%19 = load i32, i32* %4
%20 = icmp sgt i32 %19, 2
br i1 %20, label %21, label %26
21: ; preds = %17
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 2
%24 = load i8*, i8** %23
%25 = call i32 @atoi(i8* %24)
br label %27
26: ; preds = %17
br label %27
27: ; preds = %26, %21
%28 = phi i32 [ %25, %21 ], [ 10, %26 ]
store i32 %28, i32* %8
%29 = load i32, i32* %7
%30 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
%31 = load i32, i32* %8
%32 = call i8* @itoan(i32 %29, i8* %30, i32 255, i32 %31)
%33 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %32)
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"i:%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [255 x i8]
%4 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %15
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @atoi(i8* %8)
%10 = icmp eq i32 %0, 2
br i1 %10, label %15, label %11
11: ; preds = %6
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
%14 = tail call i32 @atoi(i8* %13)
br label %15
15: ; preds = %2, %6, %11
%16 = phi i32 [ %9, %11 ], [ %9, %6 ], [ 0, %2 ]
%17 = phi i32 [ %14, %11 ], [ 10, %6 ], [ 10, %2 ]
%18 = call i8* @itoan(i32 %16, i8* %4, i32 255, i32 %17)
%19 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %18)
ret i32 0
}