#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*/ printf(char *, int);
void convert(int n, int base) {
  if (n <= 1) {
    printf("%d", n);
    return;
  }
  convert(n / base, base);
  int rem = n % base;
  if (rem <= 9)
    printf("%d", rem);
  else
    printf("%c", rem + 55);
}


x86 assembly (clang, -O0):
<convert>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cmpl   $0x1,-0x4(%rbp)
jg     114c <convert+0x2c>
mov    -0x4(%rbp),%esi
lea    0xebe(%rip),%rdi
call   1040 <printf@plt>
jmp    1197 <convert+0x77>
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    %eax,%edi
mov    -0x8(%rbp),%esi
call   1030 <convert@plt>
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    %edx,-0xc(%rbp)
cmpl   $0x9,-0xc(%rbp)
jg     1185 <convert+0x65>
mov    -0xc(%rbp),%esi
lea    0xe85(%rip),%rdi
call   1040 <printf@plt>
jmp    1197 <convert+0x77>
mov    -0xc(%rbp),%esi
add    $0x37,%esi
lea    0xe71(%rip),%rdi
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convert>:
push   %rbx
mov    %edi,%eax
cmp    $0x1,%edi
jg     1137 <convert+0x17>
lea    0xed1(%rip),%rdi
mov    %eax,%esi
pop    %rbx
jmp    1040 <printf@plt>
cltd
idiv   %esi
mov    %edx,%ebx
mov    %eax,%edi
call   1030 <convert@plt>
cmp    $0x9,%ebx
ja     1151 <convert+0x31>
lea    0xeb1(%rip),%rdi
jmp    115b <convert+0x3b>
add    $0x37,%ebx
lea    0xea8(%rip),%rdi
mov    %ebx,%esi
pop    %rbx
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%c\00"
define void @convert(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = load i32, i32* %3
%7 = icmp sle i32 %6, 1
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = load i32, i32* %3
%10 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %9)
br label %28
11: ; preds = %2
%12 = load i32, i32* %3
%13 = load i32, i32* %4
%14 = sdiv i32 %12, %13
%15 = load i32, i32* %4
%16 = load i32, i32* %3
%17 = load i32, i32* %4
%18 = srem i32 %16, %17
store i32 %18, i32* %5
%19 = load i32, i32* %5
%20 = icmp sle i32 %19, 9
br i1 %20, label %21, label %24
21: ; preds = %11
%22 = load i32, i32* %5
%23 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %22)
br label %28
24: ; preds = %11
%25 = load i32, i32* %5
%26 = add nsw i32 %25, 55
%27 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %26)
br label %28
28: ; preds = %8, %24, %21
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%c\00"
define void @convert(i32 %0, i32 %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %0)
br label %15
6: ; preds = %2
%7 = sdiv i32 %0, %1
tail call void @convert(i32 %7, i32 %1)
%8 = srem i32 %0, %1
%9 = icmp ult i32 %8, 10
br i1 %9, label %10, label %12
10: ; preds = %6
%11 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %8)
br label %15
12: ; preds = %6
%13 = add nuw nsw i32 %8, 55
%14 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %13)
br label %15
15: ; preds = %10, %12, %4
ret void
}