#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 */
scalar_t__ EOF;
char *calloc(int const, int);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ itob(int, char *, int);
char *malloc(int const);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ scanf(char *, int *, int *);
int main(void) {
  const int max_size = 4;
  char *s;
  s = malloc(max_size * sizeof(char));
  int n, b;
  printf("\n_____CONVERT_____\n\n");
  while ((scanf("%d%d", &n, &b)) != EOF) {
    itob(n, s, b);
    printf("%s\n\n", s);
    s = calloc(max_size, sizeof(char));
  }
  free(s);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x4,-0x8(%rbp)
mov    $0x4,%edi
call   1070 <malloc@plt>
mov    %rax,-0x10(%rbp)
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe7c(%rip),%rdi
lea    -0x14(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1080 <scanf@plt>
mov    0x2e3b(%rip),%rcx
cmp    (%rcx),%rax
je     11ef <main+0x8f>
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%edx
call   1060 <itob@plt>
mov    -0x10(%rbp),%rsi
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x4,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,-0x10(%rbp)
jmp    1192 <main+0x32>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x4,%edi
call   1080 <malloc@plt>
mov    %rax,%rbx
lea    0xe7b(%rip),%rdi
call   1040 <puts@plt>
lea    0xe65(%rip),%rdi
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
call   1090 <scanf@plt>
mov    0x2e39(%rip),%rbp
cmp    0x0(%rbp),%rax
je     1212 <main+0xa2>
lea    0xe49(%rip),%r14
lea    0xe3d(%rip),%r15
lea    0x4(%rsp),%r12
mov    %rsp,%r13
nopl   0x0(%rax,%rax,1)
mov    0x4(%rsp),%edi
mov    (%rsp),%edx
mov    %rbx,%rsi
call   1070 <itob@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x4,%edi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1090 <scanf@plt>
cmp    0x0(%rbp),%rax
jne    11d0 <main+0x60>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str.1 = [5 x i8] c"%d%d\00"
@EOF = global i64 0
@.str.2 = [5 x i8] c"%s\0A\0A\00"
@str = [20 x i8] c"\0A_____CONVERT_____\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = tail call dereferenceable_or_null(4) i8* @malloc(i32 4)
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%7 = call i64 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2)
%8 = load i64, i64* @EOF
%9 = icmp eq i64 %7, %8
br i1 %9, label %20, label %10
10: ; preds = %0, %10
%11 = phi i8* [ %16, %10 ], [ %3, %0 ]
%12 = load i32, i32* %1
%13 = load i32, i32* %2
%14 = call i32 @itob(i32 %12, i8* %11, i32 %13)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %11)
%16 = call dereferenceable_or_null(4) i8* @calloc(i32 4, i32 1)
%17 = call i64 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2)
%18 = load i64, i64* @EOF
%19 = icmp eq i64 %17, %18
br i1 %19, label %20, label %10
20: ; preds = %10, %0
%21 = phi i8* [ %3, %0 ], [ %16, %10 ]
%22 = call i32 @free(i8* %21)
ret i32 0
}