#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*/ ft_putchar(unsigned int);
int /*<<< orphan*/ ft_putstr(char *);
void ft_putbase(unsigned int n, unsigned int base) {
  unsigned int tmp;
  if (n >= base)
    ft_putbase(n / base, base);
  else {
    if (base == 8)
      ft_putchar('0');
    else if (base == 16)
      ft_putstr("0x");
  }
  tmp = n % base;
  if (tmp <= 9)
    ft_putchar(tmp + '0');
  else if (tmp > 9 && tmp <= 9 + 26)
    ft_putchar(tmp + 'A' - 10);
}


x86 assembly (clang, -O0):
<ft_putbase>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jb     1161 <ft_putbase+0x31>
mov    -0x4(%rbp),%eax
xor    %edx,%edx
divl   -0x8(%rbp)
mov    %eax,%edi
mov    -0x8(%rbp),%esi
call   1030 <ft_putbase@plt>
jmp    119a <ft_putbase+0x6a>
cmpl   $0x8,-0x8(%rbp)
jne    117a <ft_putbase+0x4a>
mov    $0x30,%edi
call   1040 <ft_putchar@plt>
jmp    1195 <ft_putbase+0x65>
cmpl   $0x10,-0x8(%rbp)
jne    1190 <ft_putbase+0x60>
lea    0xe75(%rip),%rdi
call   1050 <ft_putstr@plt>
jmp    1195 <ft_putbase+0x65>
jmp    119a <ft_putbase+0x6a>
mov    -0x4(%rbp),%eax
xor    %edx,%edx
divl   -0x8(%rbp)
mov    %edx,-0xc(%rbp)
cmpl   $0x9,-0xc(%rbp)
ja     11bf <ft_putbase+0x8f>
mov    -0xc(%rbp),%edi
add    $0x30,%edi
call   1040 <ft_putchar@plt>
jmp    11e6 <ft_putbase+0xb6>
cmpl   $0x9,-0xc(%rbp)
jbe    11e1 <ft_putbase+0xb1>
cmpl   $0x23,-0xc(%rbp)
ja     11e1 <ft_putbase+0xb1>
mov    -0xc(%rbp),%edi
add    $0x41,%edi
sub    $0xa,%edi
call   1040 <ft_putchar@plt>
jmp    11e6 <ft_putbase+0xb6>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_putbase>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
cmp    %esi,%edi
jae    1151 <ft_putbase+0x21>
cmp    $0x10,%ebx
je     1162 <ft_putbase+0x32>
cmp    $0x8,%ebx
jne    116e <ft_putbase+0x3e>
mov    $0x30,%edi
call   1040 <ft_putchar@plt>
jmp    116e <ft_putbase+0x3e>
mov    %ebp,%eax
xor    %edx,%edx
div    %ebx
mov    %eax,%edi
mov    %ebx,%esi
call   1030 <ft_putbase@plt>
jmp    116e <ft_putbase+0x3e>
lea    0xe97(%rip),%rdi
call   1050 <ft_putstr@plt>
mov    %ebp,%eax
xor    %edx,%edx
div    %ebx
mov    $0x30,%eax
cmp    $0xa,%edx
jb     1188 <ft_putbase+0x58>
mov    $0x37,%eax
cmp    $0x23,%edx
ja     1197 <ft_putbase+0x67>
add    %eax,%edx
mov    %edx,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <ft_putchar@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"0x\00"
define void @ft_putbase(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 = load i32, i32* %4
%8 = icmp uge i32 %6, %7
br i1 %8, label %9, label %14
9: ; preds = %2
%10 = load i32, i32* %3
%11 = load i32, i32* %4
%12 = udiv i32 %10, %11
%13 = load i32, i32* %4
br label %26
14: ; preds = %2
%15 = load i32, i32* %4
%16 = icmp eq i32 %15, 8
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = call i32 @ft_putchar(i32 48)
br label %25
19: ; preds = %14
%20 = load i32, i32* %4
%21 = icmp eq i32 %20, 16
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = call i32 @ft_putstr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %24
24: ; preds = %22, %19
br label %25
25: ; preds = %24, %17
br label %26
26: ; preds = %25, %9
%27 = load i32, i32* %3
%28 = load i32, i32* %4
%29 = urem i32 %27, %28
store i32 %29, i32* %5
%30 = load i32, i32* %5
%31 = icmp ule i32 %30, 9
br i1 %31, label %32, label %36
32: ; preds = %26
%33 = load i32, i32* %5
%34 = add i32 %33, 48
%35 = call i32 @ft_putchar(i32 %34)
br label %48
36: ; preds = %26
%37 = load i32, i32* %5
%38 = icmp ugt i32 %37, 9
br i1 %38, label %39, label %47
39: ; preds = %36
%40 = load i32, i32* %5
%41 = icmp ule i32 %40, 35
br i1 %41, label %42, label %47
42: ; preds = %39
%43 = load i32, i32* %5
%44 = add i32 %43, 65
%45 = sub i32 %44, 10
%46 = call i32 @ft_putchar(i32 %45)
br label %47
47: ; preds = %42, %39, %36
br label %48
48: ; preds = %47, %32
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"0x\00"
define void @ft_putbase(i32 %0, i32 %1) {
%3 = icmp ult i32 %0, %1
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = udiv i32 %0, %1
tail call void @ft_putbase(i32 %5, i32 %1)
br label %11
6: ; preds = %2
switch i32 %1, label %11 [
i32 8, label %7
i32 16, label %9
]
7: ; preds = %6
%8 = tail call i32 @ft_putchar(i32 48)
br label %11
9: ; preds = %6
%10 = tail call i32 @ft_putstr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %6, %7, %9, %4
%12 = urem i32 %0, %1
%13 = icmp ult i32 %12, 10
br i1 %13, label %16, label %14
14: ; preds = %11
%15 = icmp ult i32 %12, 36
br i1 %15, label %16, label %20
16: ; preds = %14, %11
%17 = phi i32 [ 48, %11 ], [ 55, %14 ]
%18 = add nuw nsw i32 %12, %17
%19 = tail call i32 @ft_putchar(i32 %18)
br label %20
20: ; preds = %16, %14
ret void
}