#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 getopt(int, char **, char *);
int /*<<< orphan*/ itoa(int, char *, int, int);
int /*<<< orphan*/ itoa_rec(int, char *, int, int);
int /*<<< orphan*/ printf(char *, char *);
int scanf(char *, int *, int *, int *);
int main(int argc, char **argv) {
  int num = 0;
  int base = 0;
  int width = 0;
  bool recursive = false;
  int arg = 0;
  while ((arg = getopt(argc, argv, "r")) != -1) {
    switch (arg) {
    case 'r':
      recursive = true;
      break;
    case '?':
    default:
      break;
    }
  }
  while (scanf("%d %d %d", &num, &base, &width) == 3) {
    int len = width > 20 ? width : 20;
    char str[len + 1];
    if (recursive)
      itoa_rec(num, str, base, width);
    else
      itoa(num, str, base, width);
    printf("Converted: %s\n", str);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe69(%rip),%rdx
call   1060 <getopt@plt>
mov    %eax,-0x24(%rbp)
cmp    $0xffffffff,%eax
je     11e8 <main+0x98>
mov    -0x24(%rbp),%eax
mov    %eax,-0x3c(%rbp)
sub    $0x3f,%eax
je     11d9 <main+0x89>
jmp    11bc <main+0x6c>
mov    -0x3c(%rbp),%eax
sub    $0x72,%eax
jne    11de <main+0x8e>
jmp    11cd <main+0x7d>
movl   $0x1,-0x20(%rbp)
jmp    11e3 <main+0x93>
jmp    11de <main+0x8e>
jmp    11e3 <main+0x93>
jmp    1189 <main+0x39>
jmp    11ed <main+0x9d>
lea    0xe0e(%rip),%rdi
lea    -0x14(%rbp),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x1c(%rbp),%rcx
call   1050 <scanf@plt>
cmp    $0x3,%eax
jne    12ae <main+0x15e>
cmpl   $0x14,-0x1c(%rbp)
jle    1223 <main+0xd3>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x40(%rbp)
jmp    1230 <main+0xe0>
mov    $0x14,%eax
mov    %eax,-0x40(%rbp)
jmp    1230 <main+0xe0>
mov    -0x40(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %rsp,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     1280 <main+0x130>
mov    -0x48(%rbp),%rsi
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
call   1030 <itoa_rec@plt>
jmp    1292 <main+0x142>
mov    -0x48(%rbp),%rsi
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
call   1070 <itoa@plt>
mov    -0x48(%rbp),%rsi
lea    0xd6e(%rip),%rdi
call   1040 <printf@plt>
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
jmp    11ed <main+0x9d>
xor    %eax,%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %edi,%ebx
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    $0x1,%r12b
lea    0xe7b(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebx,%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   1060 <getopt@plt>
cmp    $0x72,%eax
je     11a9 <main+0x59>
cmp    $0xffffffff,%eax
jne    1190 <main+0x40>
jmp    11ae <main+0x5e>
xor    %r12d,%r12d
jmp    1190 <main+0x40>
lea    0xe4d(%rip),%rdi
lea    -0x34(%rbp),%rsi
lea    -0x30(%rbp),%rdx
lea    -0x2c(%rbp),%rcx
call   1050 <scanf@plt>
cmp    $0x3,%eax
jne    124d <main+0xfd>
lea    -0x30(%rbp),%r13
lea    -0x2c(%rbp),%rbx
jmp    1212 <main+0xc2>
nopl   0x0(%rax)
call   1070 <itoa@plt>
lea    0xe1f(%rip),%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
mov    %r15,%rsp
lea    0xe04(%rip),%rdi
lea    -0x34(%rbp),%rsi
mov    %r13,%rdx
mov    %rbx,%rcx
call   1050 <scanf@plt>
cmp    $0x3,%eax
jne    124d <main+0xfd>
mov    %rsp,%r15
mov    -0x2c(%rbp),%eax
cmp    $0x15,%eax
mov    $0x14,%ecx
cmovl  %ecx,%eax
add    $0x10,%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%r14
sub    %rax,%r14
mov    %r14,%rsp
mov    -0x34(%rbp),%edi
mov    -0x30(%rbp),%edx
mov    -0x2c(%rbp),%ecx
mov    %r14,%rsi
test   $0x1,%r12b
jne    11e0 <main+0x90>
call   1030 <itoa_rec@plt>
jmp    11e5 <main+0x95>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [9 x i8] c"%d %d %d\00"
@.str.2 = [15 x i8] c"Converted: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i64
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
store i32 0, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
br label %14
14: ; preds = %24, %2
%15 = load i32, i32* %4
%16 = load i8**, i8*** %5
%17 = call i32 @getopt(i32 %15, i8** %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 %17, i32* %10
%18 = icmp ne i32 %17, -1
br i1 %18, label %19, label %25
19: ; preds = %14
%20 = load i32, i32* %10
switch i32 %20, label %23 [
i32 114, label %21
i32 63, label %22
]
21: ; preds = %19
store i32 1, i32* %9
br label %24
22: ; preds = %19
br label %23
23: ; preds = %19, %22
br label %24
24: ; preds = %23, %21
br label %14
25: ; preds = %14
br label %26
26: ; preds = %54, %25
%27 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %6, i32* %7, i32* %8)
%28 = icmp eq i32 %27, 3
br i1 %28, label %29, label %57
29: ; preds = %26
%30 = load i32, i32* %8
%31 = icmp sgt i32 %30, 20
br i1 %31, label %32, label %34
32: ; preds = %29
%33 = load i32, i32* %8
br label %35
34: ; preds = %29
br label %35
35: ; preds = %34, %32
%36 = phi i32 [ %33, %32 ], [ 20, %34 ]
store i32 %36, i32* %11
%37 = load i32, i32* %11
%38 = add nsw i32 %37, 1
%39 = zext i32 %38 to i64
%40 = call i8* @llvm.stacksave()
store i8* %40, i8** %12
%41 = alloca i8, i64 %39
store i64 %39, i64* %13
%42 = load i32, i32* %9
%43 = icmp ne i32 %42, 0
br i1 %43, label %44, label %49
44: ; preds = %35
%45 = load i32, i32* %6
%46 = load i32, i32* %7
%47 = load i32, i32* %8
%48 = call i32 @itoa_rec(i32 %45, i8* %41, i32 %46, i32 %47)
br label %54
49: ; preds = %35
%50 = load i32, i32* %6
%51 = load i32, i32* %7
%52 = load i32, i32* %8
%53 = call i32 @itoa(i32 %50, i8* %41, i32 %51, i32 %52)
br label %54
54: ; preds = %49, %44
%55 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %41)
%56 = load i8*, i8** %12
br label %26
57: ; preds = %26
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [9 x i8] c"%d %d %d\00"
@.str.2 = [15 x i8] c"Converted: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%7 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%8 = bitcast i32* %5 to i8*
store i32 0, i32* %5
br label %9
9: ; preds = %11, %2
%10 = phi i1 [ true, %2 ], [ false, %11 ]
br label %11
11: ; preds = %9, %11
%12 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
switch i32 %12, label %11 [
i32 -1, label %13
i32 114, label %9
]
13: ; preds = %11
%14 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32* %4, i32* %5)
%15 = icmp eq i32 %14, 3
br i1 %15, label %16, label %35
16: ; preds = %13, %31
%17 = load i32, i32* %5
%18 = icmp sgt i32 %17, 20
%19 = select i1 %18, i32 %17, i32 20
%20 = add nuw nsw i32 %19, 1
%21 = zext i32 %20 to i64
%22 = call i8* @llvm.stacksave()
%23 = alloca i8, i64 %21
%24 = load i32, i32* %3
%25 = load i32, i32* %4
%26 = load i32, i32* %5
br i1 %10, label %29, label %27
27: ; preds = %16
%28 = call i32 @itoa_rec(i32 %24, i8* %23, i32 %25, i32 %26)
br label %31
29: ; preds = %16
%30 = call i32 @itoa(i32 %24, i8* %23, i32 %25, i32 %26)
br label %31
31: ; preds = %29, %27
%32 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %23)
%33 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32* %4, i32* %5)
%34 = icmp eq i32 %33, 3
br i1 %34, label %16, label %35
35: ; preds = %31, %13
ret i32 0
}