#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, char *, int);
int /*<<< orphan*/ printf(char *, int, int, char *);
int main() {
  char s[1000];
  int i = 0;
  int b = 2;
  itob(i, s, b);
  printf("%d into string base %d is: %s\n", i, b, s);
  i = 256;
  b = 16;
  itob(i, s, b);
  printf("%d into string base %d is: %s\n", i, b, s);
  i = -256;
  b = 16;
  itob(i, s, b);
  printf("%d into string base %d is: %s\n", i, b, s);
  i = 1023;
  b = 8;
  itob(i, s, b);
  printf("%d into string base %d is: %s\n", i, b, s);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
movl   $0x0,-0x3f4(%rbp)
movl   $0x2,-0x3f8(%rbp)
mov    -0x3f4(%rbp),%edi
lea    -0x3f0(%rbp),%rsi
mov    -0x3f8(%rbp),%edx
call   1040 <itob@plt>
mov    -0x3f4(%rbp),%esi
mov    -0x3f8(%rbp),%edx
lea    -0x3f0(%rbp),%rcx
lea    0xe8f(%rip),%rdi
call   1030 <printf@plt>
movl   $0x100,-0x3f4(%rbp)
movl   $0x10,-0x3f8(%rbp)
mov    -0x3f4(%rbp),%edi
lea    -0x3f0(%rbp),%rsi
mov    -0x3f8(%rbp),%edx
call   1040 <itob@plt>
mov    -0x3f4(%rbp),%esi
mov    -0x3f8(%rbp),%edx
lea    -0x3f0(%rbp),%rcx
lea    0xe44(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffff00,-0x3f4(%rbp)
ff ff ff
movl   $0x10,-0x3f8(%rbp)
mov    -0x3f4(%rbp),%edi
lea    -0x3f0(%rbp),%rsi
mov    -0x3f8(%rbp),%edx
call   1040 <itob@plt>
mov    -0x3f4(%rbp),%esi
mov    -0x3f8(%rbp),%edx
lea    -0x3f0(%rbp),%rcx
lea    0xdf9(%rip),%rdi
call   1030 <printf@plt>
movl   $0x3ff,-0x3f4(%rbp)
movl   $0x8,-0x3f8(%rbp)
mov    -0x3f4(%rbp),%edi
lea    -0x3f0(%rbp),%rsi
mov    -0x3f8(%rbp),%edx
call   1040 <itob@plt>
mov    -0x3f4(%rbp),%esi
mov    -0x3f8(%rbp),%edx
lea    -0x3f0(%rbp),%rcx
lea    0xdae(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x3e8,%rsp
mov    %rsp,%rbx
xor    %edi,%edi
mov    %rbx,%rsi
mov    $0x2,%edx
call   1040 <itob@plt>
lea    0xebd(%rip),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x2,%edx
mov    %rbx,%rcx
call   1030 <printf@plt>
mov    $0x100,%edi
mov    %rbx,%rsi
mov    $0x10,%edx
call   1040 <itob@plt>
mov    %r14,%rdi
mov    $0x100,%esi
mov    $0x10,%edx
mov    %rbx,%rcx
call   1030 <printf@plt>
mov    $0xffffff00,%edi
mov    %rbx,%rsi
mov    $0x10,%edx
call   1040 <itob@plt>
mov    %r14,%rdi
mov    $0xffffff00,%esi
mov    $0x10,%edx
mov    %rbx,%rcx
call   1030 <printf@plt>
mov    $0x3ff,%edi
mov    %rbx,%rsi
mov    $0x8,%edx
call   1040 <itob@plt>
mov    %r14,%rdi
mov    $0x3ff,%esi
mov    $0x8,%edx
mov    %rbx,%rcx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x3e8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [31 x i8] c"%d into string base %d is: %s\0A\00"
define i32 @main() {
%1 = alloca [1000 x i8]
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %2
store i32 2, i32* %3
%4 = load i32, i32* %2
%5 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%6 = load i32, i32* %3
%7 = call i32 @itob(i32 %4, i8* %5, i32 %6)
%8 = load i32, i32* %2
%9 = load i32, i32* %3
%10 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%11 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %9, i8* %10)
store i32 256, i32* %2
store i32 16, i32* %3
%12 = load i32, i32* %2
%13 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%14 = load i32, i32* %3
%15 = call i32 @itob(i32 %12, i8* %13, i32 %14)
%16 = load i32, i32* %2
%17 = load i32, i32* %3
%18 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%19 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %16, i32 %17, i8* %18)
store i32 -256, i32* %2
store i32 16, i32* %3
%20 = load i32, i32* %2
%21 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%22 = load i32, i32* %3
%23 = call i32 @itob(i32 %20, i8* %21, i32 %22)
%24 = load i32, i32* %2
%25 = load i32, i32* %3
%26 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%27 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %24, i32 %25, i8* %26)
store i32 1023, i32* %2
store i32 8, i32* %3
%28 = load i32, i32* %2
%29 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%30 = load i32, i32* %3
%31 = call i32 @itob(i32 %28, i8* %29, i32 %30)
%32 = load i32, i32* %2
%33 = load i32, i32* %3
%34 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%35 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %32, i32 %33, i8* %34)
ret i32 0
}

LLVM IR (-O2):
@.str = [31 x i8] c"%d into string base %d is: %s\0A\00"
define i32 @main() {
%1 = alloca [1000 x i8]
%2 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%3 = call i32 @itob(i32 0, i8* %2, i32 2)
%4 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 0, i32 2, i8* %2)
%5 = call i32 @itob(i32 256, i8* %2, i32 16)
%6 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 256, i32 16, i8* %2)
%7 = call i32 @itob(i32 -256, i8* %2, i32 16)
%8 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 -256, i32 16, i8* %2)
%9 = call i32 @itob(i32 1023, i8* %2, i32 8)
%10 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 1023, i32 8, i8* %2)
ret i32 0
}