#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);
int /*<<< orphan*/ printf(char *, int, ...);
int main(void) {
  char s[128] = {0};
  int tests[6] = {186, -125, 8763, -379, 17, 93};
  int bases[6] = {2, 8, 10, 16, 24, 36};
  printf("field width: %d\n", 10);
  itob(tests[0], s, bases[0], 10);
  printf("%d base %d = %s\n\n", tests[0], bases[0], s);
  printf("field width: %d\n", 5);
  itob(tests[1], s, bases[1], 5);
  printf("%d base %d = %s\n\n", tests[1], bases[1], s);
  printf("field width: %d\n", 6);
  itob(tests[2], s, bases[2], 6);
  printf("%d base %d = %s\n\n", tests[2], bases[2], s);
  printf("field width: %d\n", 8);
  itob(tests[3], s, bases[3], 8);
  printf("%d base %d = %s\n\n", tests[3], bases[3], s);
  printf("field width: %d\n", 15);
  itob(tests[4], s, bases[0], 15);
  printf("%d base %d = %s\n\n", tests[4], bases[4], s);
  printf("field width: %d\n", 2);
  itob(tests[5], s, bases[5], 2);
  printf("%d base %d = %s\n", tests[5], bases[5], s);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1040 <memset@plt>
mov    0xea4(%rip),%rax
mov    %rax,-0xb0(%rbp)
mov    0xe9e(%rip),%rax
mov    %rax,-0xa8(%rbp)
mov    0xe98(%rip),%rax
mov    %rax,-0xa0(%rbp)
mov    0xe9a(%rip),%rax
mov    %rax,-0xd0(%rbp)
mov    0xe94(%rip),%rax
mov    %rax,-0xc8(%rbp)
mov    0xe8e(%rip),%rax
mov    %rax,-0xc0(%rbp)
lea    0xe88(%rip),%rdi
mov    $0xa,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xb0(%rbp),%edi
lea    -0x90(%rbp),%rsi
mov    -0xd0(%rbp),%edx
mov    $0xa,%ecx
call   1050 <itob@plt>
mov    -0xb0(%rbp),%esi
mov    -0xd0(%rbp),%edx
lea    -0x90(%rbp),%rcx
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe37(%rip),%rdi
mov    $0x5,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xac(%rbp),%edi
lea    -0x90(%rbp),%rsi
mov    -0xcc(%rbp),%edx
mov    $0x5,%ecx
call   1050 <itob@plt>
mov    -0xac(%rbp),%esi
mov    -0xcc(%rbp),%edx
lea    -0x90(%rbp),%rcx
lea    0xe05(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xde6(%rip),%rdi
mov    $0x6,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xa8(%rbp),%edi
lea    -0x90(%rbp),%rsi
mov    -0xc8(%rbp),%edx
mov    $0x6,%ecx
call   1050 <itob@plt>
mov    -0xa8(%rbp),%esi
mov    -0xc8(%rbp),%edx
lea    -0x90(%rbp),%rcx
lea    0xdb4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd95(%rip),%rdi
mov    $0x8,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xa4(%rbp),%edi
lea    -0x90(%rbp),%rsi
mov    -0xc4(%rbp),%edx
mov    $0x8,%ecx
call   1050 <itob@plt>
mov    -0xa4(%rbp),%esi
mov    -0xc4(%rbp),%edx
lea    -0x90(%rbp),%rcx
lea    0xd63(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd44(%rip),%rdi
mov    $0xf,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xa0(%rbp),%edi
lea    -0x90(%rbp),%rsi
mov    -0xd0(%rbp),%edx
mov    $0xf,%ecx
call   1050 <itob@plt>
mov    -0xa0(%rbp),%esi
mov    -0xc0(%rbp),%edx
lea    -0x90(%rbp),%rcx
lea    0xd12(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xcf3(%rip),%rdi
mov    $0x2,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x9c(%rbp),%edi
lea    -0x90(%rbp),%rsi
mov    -0xbc(%rbp),%edx
mov    $0x2,%ecx
call   1050 <itob@plt>
mov    -0x9c(%rbp),%esi
mov    -0xbc(%rbp),%edx
lea    -0x90(%rbp),%rcx
lea    0xcd3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x80,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
lea    0xea3(%rip),%r14
mov    %r14,%rdi
mov    $0xa,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rsp,%rbx
mov    $0xba,%edi
mov    %rbx,%rsi
mov    $0x2,%edx
mov    $0xa,%ecx
call   1040 <itob@plt>
lea    0xe84(%rip),%r15
mov    %r15,%rdi
mov    $0xba,%esi
mov    $0x2,%edx
mov    %rbx,%rcx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r14,%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0xffffff83,%edi
mov    %rbx,%rsi
mov    $0x8,%edx
mov    $0x5,%ecx
call   1040 <itob@plt>
mov    %r15,%rdi
mov    $0xffffff83,%esi
mov    $0x8,%edx
mov    %rbx,%rcx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r14,%rdi
mov    $0x6,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x223b,%edi
mov    %rbx,%rsi
mov    $0xa,%edx
mov    $0x6,%ecx
call   1040 <itob@plt>
mov    %r15,%rdi
mov    $0x223b,%esi
mov    $0xa,%edx
mov    %rbx,%rcx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r14,%rdi
mov    $0x8,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0xfffffe85,%edi
mov    %rbx,%rsi
mov    $0x10,%edx
mov    $0x8,%ecx
call   1040 <itob@plt>
mov    %r15,%rdi
mov    $0xfffffe85,%esi
mov    $0x10,%edx
mov    %rbx,%rcx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r14,%rdi
mov    $0xf,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x11,%edi
mov    %rbx,%rsi
mov    $0x2,%edx
mov    $0xf,%ecx
call   1040 <itob@plt>
mov    %r15,%rdi
mov    $0x11,%esi
mov    $0x18,%edx
mov    %rbx,%rcx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r14,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x5d,%edi
mov    %rbx,%rsi
mov    $0x24,%edx
mov    $0x2,%ecx
call   1040 <itob@plt>
lea    0xd5e(%rip),%rdi
mov    $0x5d,%esi
mov    $0x24,%edx
mov    %rbx,%rcx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.tests = [6 x i32] [i32 186, i32 -125, i32 8763, i32 -379, i32 17, i32 93]
@__const.main.bases = [6 x i32] [i32 2, i32 8, i32 10, i32 16, i32 24, i32 36]
@.str = [17 x i8] c"field width: %d\0A\00"
@.str.1 = [18 x i8] c"%d base %d = %s\0A\0A\00"
@.str.2 = [17 x i8] c"%d base %d = %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [128 x i8]
%3 = alloca [6 x i32]
%4 = alloca [6 x i32]
store i32 0, i32* %1
%5 = bitcast [128 x i8]* %2 to i8*
%6 = bitcast [6 x i32]* %3 to i8*
%7 = bitcast [6 x i32]* %4 to i8*
%8 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 10)
%9 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 0
%10 = load i32, i32* %9
%11 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%12 = getelementptr inbounds [6 x i32], [6 x i32]* %4, i64 0, i64 0
%13 = load i32, i32* %12
%14 = call i32 @itob(i32 %10, i8* %11, i32 %13, i32 10)
%15 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 0
%16 = load i32, i32* %15
%17 = getelementptr inbounds [6 x i32], [6 x i32]* %4, i64 0, i64 0
%18 = load i32, i32* %17
%19 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%20 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %16, i32 %18, i8* %19)
%21 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 5)
%22 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 1
%23 = load i32, i32* %22
%24 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%25 = getelementptr inbounds [6 x i32], [6 x i32]* %4, i64 0, i64 1
%26 = load i32, i32* %25
%27 = call i32 @itob(i32 %23, i8* %24, i32 %26, i32 5)
%28 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 1
%29 = load i32, i32* %28
%30 = getelementptr inbounds [6 x i32], [6 x i32]* %4, i64 0, i64 1
%31 = load i32, i32* %30
%32 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%33 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %29, i32 %31, i8* %32)
%34 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 6)
%35 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 2
%36 = load i32, i32* %35
%37 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%38 = getelementptr inbounds [6 x i32], [6 x i32]* %4, i64 0, i64 2
%39 = load i32, i32* %38
%40 = call i32 @itob(i32 %36, i8* %37, i32 %39, i32 6)
%41 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 2
%42 = load i32, i32* %41
%43 = getelementptr inbounds [6 x i32], [6 x i32]* %4, i64 0, i64 2
%44 = load i32, i32* %43
%45 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%46 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %42, i32 %44, i8* %45)
%47 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 8)
%48 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 3
%49 = load i32, i32* %48
%50 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%51 = getelementptr inbounds [6 x i32], [6 x i32]* %4, i64 0, i64 3
%52 = load i32, i32* %51
%53 = call i32 @itob(i32 %49, i8* %50, i32 %52, i32 8)
%54 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 3
%55 = load i32, i32* %54
%56 = getelementptr inbounds [6 x i32], [6 x i32]* %4, i64 0, i64 3
%57 = load i32, i32* %56
%58 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%59 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %55, i32 %57, i8* %58)
%60 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 15)
%61 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 4
%62 = load i32, i32* %61
%63 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%64 = getelementptr inbounds [6 x i32], [6 x i32]* %4, i64 0, i64 0
%65 = load i32, i32* %64
%66 = call i32 @itob(i32 %62, i8* %63, i32 %65, i32 15)
%67 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 4
%68 = load i32, i32* %67
%69 = getelementptr inbounds [6 x i32], [6 x i32]* %4, i64 0, i64 4
%70 = load i32, i32* %69
%71 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%72 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %68, i32 %70, i8* %71)
%73 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 2)
%74 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 5
%75 = load i32, i32* %74
%76 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%77 = getelementptr inbounds [6 x i32], [6 x i32]* %4, i64 0, i64 5
%78 = load i32, i32* %77
%79 = call i32 @itob(i32 %75, i8* %76, i32 %78, i32 2)
%80 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 5
%81 = load i32, i32* %80
%82 = getelementptr inbounds [6 x i32], [6 x i32]* %4, i64 0, i64 5
%83 = load i32, i32* %82
%84 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%85 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %81, i32 %83, i8* %84)
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"field width: %d\0A\00"
@.str.1 = [18 x i8] c"%d base %d = %s\0A\0A\00"
@.str.2 = [17 x i8] c"%d base %d = %s\0A\00"
define i32 @main() {
%1 = alloca [128 x i8]
%2 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 10)
%4 = call i32 @itob(i32 186, i8* %2, i32 2, i32 10)
%5 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 186, i32 2, i8* %2)
%6 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 5)
%7 = call i32 @itob(i32 -125, i8* %2, i32 8, i32 5)
%8 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 -125, i32 8, i8* %2)
%9 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 6)
%10 = call i32 @itob(i32 8763, i8* %2, i32 10, i32 6)
%11 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 8763, i32 10, i8* %2)
%12 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 8)
%13 = call i32 @itob(i32 -379, i8* %2, i32 16, i32 8)
%14 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 -379, i32 16, i8* %2)
%15 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 15)
%16 = call i32 @itob(i32 17, i8* %2, i32 2, i32 15)
%17 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 17, i32 24, i8* %2)
%18 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 2)
%19 = call i32 @itob(i32 93, i8* %2, i32 36, i32 2)
%20 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 93, i32 36, i8* %2)
ret i32 0
}