#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*/ itob(int, int, char *);
int /*<<< orphan*/ printf(char *, int, int, char *);
int main() {
  int num = 42;
  char str[100] = {0};
  for (int base = 2; base <= 16; ++base) {
    itob(num, base, str);
    printf("%d to base %d = %s\n", num, base, str);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x2a,-0x8(%rbp)
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1040 <memset@plt>
movl   $0x2,-0x74(%rbp)
cmpl   $0x10,-0x74(%rbp)
jg     119d <main+0x6d>
mov    -0x8(%rbp),%edi
mov    -0x74(%rbp),%esi
lea    -0x70(%rbp),%rdx
call   1050 <itob@plt>
mov    -0x8(%rbp),%esi
mov    -0x74(%rbp),%edx
lea    -0x70(%rbp),%rcx
lea    0xe76(%rip),%rdi
call   1030 <printf@plt>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    1160 <main+0x30>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x70,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movl   $0x0,0x60(%rsp)
mov    $0x2,%ebx
mov    %rsp,%r14
lea    0xea0(%rip),%r15
mov    $0x2a,%edi
mov    %ebx,%esi
mov    %r14,%rdx
call   1040 <itob@plt>
mov    %r15,%rdi
mov    $0x2a,%esi
mov    %ebx,%edx
mov    %r14,%rcx
call   1030 <printf@plt>
add    $0x1,%ebx
cmp    $0x11,%ebx
jne    1160 <main+0x40>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [20 x i8] c"%d to base %d = %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [100 x i8]
%4 = alloca i32
store i32 0, i32* %1
store i32 42, i32* %2
%5 = bitcast [100 x i8]* %3 to i8*
store i32 2, i32* %4
br label %6
6: ; preds = %18, %0
%7 = load i32, i32* %4
%8 = icmp sle i32 %7, 16
br i1 %8, label %9, label %21
9: ; preds = %6
%10 = load i32, i32* %2
%11 = load i32, i32* %4
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%13 = call i32 @itob(i32 %10, i32 %11, i8* %12)
%14 = load i32, i32* %2
%15 = load i32, i32* %4
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%17 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %14, i32 %15, i8* %16)
br label %18
18: ; preds = %9
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 1
store i32 %20, i32* %4
br label %6
21: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
@.str = [20 x i8] c"%d to base %d = %s\0A\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
br label %4
3: ; preds = %4
ret i32 0
4: ; preds = %0, %4
%5 = phi i32 [ 2, %0 ], [ %8, %4 ]
%6 = call i32 @itob(i32 42, i32 %5, i8* %2)
%7 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 42, i32 %5, i8* %2)
%8 = add nuw nsw i32 %5, 1
%9 = icmp eq i32 %8, 17
br i1 %9, label %3, label %4
}