#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 */
char *itoa(int, char *, int);
int /*<<< orphan*/ kprintf(char *, ...);
int /*<<< orphan*/ kputc(char);
int /*<<< orphan*/ kputs(char *);
void debug_test() {
  char buffer[64];
  kputs("itoa test:\n");
  kputs("10 =   ");
  kputs(itoa(10, buffer, 10));
  kputc('\n');
  kputs("10 = 0x");
  kputs(itoa(10, buffer, 16));
  kputc('\n');
  kputs("10 = 0b");
  kputs(itoa(10, buffer, 2));
  kputc('\n');
  kputs("10 = 0o");
  kputs(itoa(10, buffer, 8));
  kputc('\n');
  kputs("printf test:\n");
  kprintf("This %s %c test line.\n", "is", 'a');
  kprintf("Numbers: %d %i %x %b\n", 15, 15, 15, 15);
}


x86 assembly (clang, -O0):
<debug_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
lea    0xeb1(%rip),%rdi
call   1030 <kputs@plt>
lea    0xeb1(%rip),%rdi
call   1030 <kputs@plt>
lea    -0x40(%rbp),%rsi
mov    $0xa,%edx
mov    %edx,%edi
call   1060 <itoa@plt>
mov    %rax,%rdi
call   1030 <kputs@plt>
mov    $0xa,%edi
call   1040 <kputc@plt>
lea    0xe8b(%rip),%rdi
call   1030 <kputs@plt>
lea    -0x40(%rbp),%rsi
mov    $0xa,%edi
mov    $0x10,%edx
call   1060 <itoa@plt>
mov    %rax,%rdi
call   1030 <kputs@plt>
mov    $0xa,%edi
call   1040 <kputc@plt>
lea    0xe62(%rip),%rdi
call   1030 <kputs@plt>
lea    -0x40(%rbp),%rsi
mov    $0xa,%edi
mov    $0x2,%edx
call   1060 <itoa@plt>
mov    %rax,%rdi
call   1030 <kputs@plt>
mov    $0xa,%edi
call   1040 <kputc@plt>
lea    0xe39(%rip),%rdi
call   1030 <kputs@plt>
lea    -0x40(%rbp),%rsi
mov    $0xa,%edi
mov    $0x8,%edx
call   1060 <itoa@plt>
mov    %rax,%rdi
call   1030 <kputs@plt>
mov    $0xa,%edi
call   1040 <kputc@plt>
lea    0xe10(%rip),%rdi
call   1030 <kputs@plt>
lea    0xe12(%rip),%rdi
lea    0xe22(%rip),%rsi
mov    $0x61,%edx
mov    $0x0,%al
call   1050 <kprintf@plt>
lea    0xe12(%rip),%rdi
mov    $0xf,%r8d
mov    %r8d,%esi
mov    %r8d,%edx
mov    %r8d,%ecx
mov    $0x0,%al
call   1050 <kprintf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<debug_test>:
push   %rbx
sub    $0x40,%rsp
lea    0xeb4(%rip),%rdi
call   1030 <kputs@plt>
lea    0xeb4(%rip),%rdi
call   1030 <kputs@plt>
mov    %rsp,%rbx
mov    $0xa,%edi
mov    %rbx,%rsi
mov    $0xa,%edx
call   1060 <itoa@plt>
mov    %rax,%rdi
call   1030 <kputs@plt>
mov    $0xa,%edi
call   1040 <kputc@plt>
lea    0xe89(%rip),%rdi
call   1030 <kputs@plt>
mov    $0xa,%edi
mov    %rbx,%rsi
mov    $0x10,%edx
call   1060 <itoa@plt>
mov    %rax,%rdi
call   1030 <kputs@plt>
mov    $0xa,%edi
call   1040 <kputc@plt>
lea    0xe61(%rip),%rdi
call   1030 <kputs@plt>
mov    $0xa,%edi
mov    %rbx,%rsi
mov    $0x2,%edx
call   1060 <itoa@plt>
mov    %rax,%rdi
call   1030 <kputs@plt>
mov    $0xa,%edi
call   1040 <kputc@plt>
lea    0xe39(%rip),%rdi
call   1030 <kputs@plt>
mov    $0xa,%edi
mov    %rbx,%rsi
mov    $0x8,%edx
call   1060 <itoa@plt>
mov    %rax,%rdi
call   1030 <kputs@plt>
mov    $0xa,%edi
call   1040 <kputc@plt>
lea    0xe11(%rip),%rdi
call   1030 <kputs@plt>
lea    0xe13(%rip),%rdi
lea    0xe23(%rip),%rsi
mov    $0x61,%edx
xor    %eax,%eax
call   1050 <kprintf@plt>
lea    0xe13(%rip),%rdi
mov    $0xf,%esi
mov    $0xf,%edx
mov    $0xf,%ecx
mov    $0xf,%r8d
xor    %eax,%eax
call   1050 <kprintf@plt>
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [12 x i8] c"itoa test:\0A\00"
@.str.1 = [8 x i8] c"10 = \00"
@.str.2 = [8 x i8] c"10 = 0x\00"
@.str.3 = [8 x i8] c"10 = 0b\00"
@.str.4 = [8 x i8] c"10 = 0o\00"
@.str.5 = [14 x i8] c"printf test:\0A\00"
@.str.6 = [23 x i8] c"This %s %c test line.\0A\00"
@.str.7 = [3 x i8] c"is\00"
@.str.8 = [22 x i8] c"Numbers: %d %i %x %b\0A\00"
define void @debug_test() {
%1 = alloca [64 x i8]
%2 = call i32 @kputs(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @kputs(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%4 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%5 = call i8* @itoa(i32 10, i8* %4, i32 10)
%6 = call i32 @kputs(i8* %5)
%7 = call i32 @kputc(i8 signext 10)
%8 = call i32 @kputs(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%9 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%10 = call i8* @itoa(i32 10, i8* %9, i32 16)
%11 = call i32 @kputs(i8* %10)
%12 = call i32 @kputc(i8 signext 10)
%13 = call i32 @kputs(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%14 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%15 = call i8* @itoa(i32 10, i8* %14, i32 2)
%16 = call i32 @kputs(i8* %15)
%17 = call i32 @kputc(i8 signext 10)
%18 = call i32 @kputs(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%19 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%20 = call i8* @itoa(i32 10, i8* %19, i32 8)
%21 = call i32 @kputs(i8* %20)
%22 = call i32 @kputc(i8 signext 10)
%23 = call i32 @kputs(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
%24 = call i32 (i8*, ...) @kprintf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32 97)
%25 = call i32 (i8*, ...) @kprintf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), i32 15, i32 15, i32 15, i32 15)
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"itoa test:\0A\00"
@.str.1 = [8 x i8] c"10 = \00"
@.str.2 = [8 x i8] c"10 = 0x\00"
@.str.3 = [8 x i8] c"10 = 0b\00"
@.str.4 = [8 x i8] c"10 = 0o\00"
@.str.5 = [14 x i8] c"printf test:\0A\00"
@.str.6 = [23 x i8] c"This %s %c test line.\0A\00"
@.str.7 = [3 x i8] c"is\00"
@.str.8 = [22 x i8] c"Numbers: %d %i %x %b\0A\00"
define void @debug_test() {
%1 = alloca [64 x i8]
%2 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @kputs(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @kputs(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%5 = call i8* @itoa(i32 10, i8* %2, i32 10)
%6 = call i32 @kputs(i8* %5)
%7 = call i32 @kputc(i8 signext 10)
%8 = call i32 @kputs(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%9 = call i8* @itoa(i32 10, i8* %2, i32 16)
%10 = call i32 @kputs(i8* %9)
%11 = call i32 @kputc(i8 signext 10)
%12 = call i32 @kputs(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%13 = call i8* @itoa(i32 10, i8* %2, i32 2)
%14 = call i32 @kputs(i8* %13)
%15 = call i32 @kputc(i8 signext 10)
%16 = call i32 @kputs(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%17 = call i8* @itoa(i32 10, i8* %2, i32 8)
%18 = call i32 @kputs(i8* %17)
%19 = call i32 @kputc(i8 signext 10)
%20 = call i32 @kputs(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
%21 = call i32 (i8*, ...) @kprintf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32 97)
%22 = call i32 (i8*, ...) @kprintf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), i32 15, i32 15, i32 15, i32 15)
ret void
}