#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_fd(unsigned long long, int);
void ft_putubase_fd(unsigned long long n, unsigned long long base, int fd,
                    char hex) {
  if (base > 32)
    return;
  if (n > (base - 1)) {
    ft_putubase_fd(n / base, base, fd, hex);
    ft_putubase_fd(n % base, base, fd, hex);
  } else if (n <= 9)
    ft_putchar_fd(n + '0', fd);
  else if (hex == 0)
    ft_putchar_fd(n + 'a' - 10, fd);
  else if (hex == 1)
    ft_putchar_fd(n + 'A' - 10, fd);
}


x86 assembly (clang, -O0):
<ft_putubase_fd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %cl,%al
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %al,-0x15(%rbp)
cmpq   $0x20,-0x10(%rbp)
jbe    1148 <ft_putubase_fd+0x28>
jmp    1216 <ft_putubase_fd+0xf6>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    $0x1,%rcx
cmp    %rcx,%rax
jbe    11a0 <ft_putubase_fd+0x80>
mov    -0x8(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x10(%rbp)
mov    %rax,%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
movsbl -0x15(%rbp),%ecx
call   1030 <ft_putubase_fd@plt>
mov    -0x8(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x10(%rbp)
mov    %rdx,%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
movsbl -0x15(%rbp),%ecx
call   1030 <ft_putubase_fd@plt>
jmp    1216 <ft_putubase_fd+0xf6>
cmpq   $0x9,-0x8(%rbp)
ja     11c0 <ft_putubase_fd+0xa0>
mov    -0x8(%rbp),%rdi
add    $0x30,%rdi
mov    -0x14(%rbp),%esi
call   1040 <ft_putchar_fd@plt>
jmp    1211 <ft_putubase_fd+0xf1>
movsbl -0x15(%rbp),%eax
cmp    $0x0,%eax
jne    11e6 <ft_putubase_fd+0xc6>
mov    -0x8(%rbp),%rdi
add    $0x61,%rdi
sub    $0xa,%rdi
mov    -0x14(%rbp),%esi
call   1040 <ft_putchar_fd@plt>
jmp    120c <ft_putubase_fd+0xec>
movsbl -0x15(%rbp),%eax
cmp    $0x1,%eax
jne    1207 <ft_putubase_fd+0xe7>
mov    -0x8(%rbp),%rdi
add    $0x41,%rdi
sub    $0xa,%rdi
mov    -0x14(%rbp),%esi
call   1040 <ft_putchar_fd@plt>
jmp    120c <ft_putubase_fd+0xec>
jmp    1211 <ft_putubase_fd+0xf1>
jmp    1216 <ft_putubase_fd+0xf6>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_putubase_fd>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x20,%rsi
jbe    1140 <ft_putubase_fd+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %ecx,%r14d
mov    %edx,%r15d
mov    %rsi,%rbp
mov    %rdi,%rbx
lea    -0x1(%rsi),%r13
cmp    %rdi,%r13
jae    1199 <ft_putubase_fd+0x79>
movsbl %r14b,%r12d
jmp    1181 <ft_putubase_fd+0x61>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rax
xor    %edx,%edx
div    %rbp
mov    %rax,%rdi
mov    %rdx,%rbx
mov    %rbp,%rsi
mov    %r15d,%edx
mov    %r12d,%ecx
call   1030 <ft_putubase_fd@plt>
cmp    %rbx,%r13
jae    1199 <ft_putubase_fd+0x79>
mov    %rbx,%rax
or     %rbp,%rax
shr    $0x20,%rax
jne    1160 <ft_putubase_fd+0x40>
mov    %ebx,%eax
xor    %edx,%edx
div    %ebp
mov    %eax,%edi
mov    %edx,%ebx
jmp    116e <ft_putubase_fd+0x4e>
mov    $0x30,%eax
cmp    $0xa,%rbx
jb     11bb <ft_putubase_fd+0x9b>
test   %r14b,%r14b
je     11b6 <ft_putubase_fd+0x96>
cmp    $0x1,%r14b
jne    1131 <ft_putubase_fd+0x11>
mov    $0x37,%eax
jmp    11bb <ft_putubase_fd+0x9b>
mov    $0x57,%eax
add    %rax,%rbx
mov    %rbx,%rdi
mov    %r15d,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <ft_putchar_fd@plt>

LLVM IR (-O0):
define void @ft_putubase_fd(i64 %0, i64 %1, i32 %2, i8 signext %3) {
%5 = alloca i64
%6 = alloca i64
%7 = alloca i32
%8 = alloca i8
store i64 %0, i64* %5
store i64 %1, i64* %6
store i32 %2, i32* %7
store i8 %3, i8* %8
%9 = load i64, i64* %6
%10 = icmp ugt i64 %9, 32
br i1 %10, label %11, label %12
11: ; preds = %4
br label %61
12: ; preds = %4
%13 = load i64, i64* %5
%14 = load i64, i64* %6
%15 = sub i64 %14, 1
%16 = icmp ugt i64 %13, %15
br i1 %16, label %17, label %30
17: ; preds = %12
%18 = load i64, i64* %5
%19 = load i64, i64* %6
%20 = udiv i64 %18, %19
%21 = load i64, i64* %6
%22 = load i32, i32* %7
%23 = load i8, i8* %8
%24 = load i64, i64* %5
%25 = load i64, i64* %6
%26 = urem i64 %24, %25
%27 = load i64, i64* %6
%28 = load i32, i32* %7
%29 = load i8, i8* %8
br label %61
30: ; preds = %12
%31 = load i64, i64* %5
%32 = icmp ule i64 %31, 9
br i1 %32, label %33, label %38
33: ; preds = %30
%34 = load i64, i64* %5
%35 = add i64 %34, 48
%36 = load i32, i32* %7
%37 = call i32 @ft_putchar_fd(i64 %35, i32 %36)
br label %60
38: ; preds = %30
%39 = load i8, i8* %8
%40 = sext i8 %39 to i32
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %48
42: ; preds = %38
%43 = load i64, i64* %5
%44 = add i64 %43, 97
%45 = sub i64 %44, 10
%46 = load i32, i32* %7
%47 = call i32 @ft_putchar_fd(i64 %45, i32 %46)
br label %59
48: ; preds = %38
%49 = load i8, i8* %8
%50 = sext i8 %49 to i32
%51 = icmp eq i32 %50, 1
br i1 %51, label %52, label %58
52: ; preds = %48
%53 = load i64, i64* %5
%54 = add i64 %53, 65
%55 = sub i64 %54, 10
%56 = load i32, i32* %7
%57 = call i32 @ft_putchar_fd(i64 %55, i32 %56)
br label %58
58: ; preds = %52, %48
br label %59
59: ; preds = %58, %42
br label %60
60: ; preds = %59, %33
br label %61
61: ; preds = %11, %60, %17
ret void
}

LLVM IR (-O2):
define void @ft_putubase_fd(i64 %0, i64 %1, i32 %2, i8 signext %3) {
%5 = icmp ugt i64 %1, 32
br i1 %5, label %23, label %6
6: ; preds = %4
%7 = add nsw i64 %1, -1
%8 = icmp ult i64 %7, %0
br i1 %8, label %9, label %14
9: ; preds = %6, %9
%10 = phi i64 [ %12, %9 ], [ %0, %6 ]
%11 = udiv i64 %10, %1
tail call void @ft_putubase_fd(i64 %11, i64 %1, i32 %2, i8 signext %3)
%12 = urem i64 %10, %1
%13 = icmp ult i64 %7, %12
br i1 %13, label %9, label %14
14: ; preds = %9, %6
%15 = phi i64 [ %0, %6 ], [ %12, %9 ]
%16 = icmp ult i64 %15, 10
br i1 %16, label %19, label %17
17: ; preds = %14
switch i8 %3, label %23 [
i8 0, label %19
i8 1, label %18
]
18: ; preds = %17
br label %19
19: ; preds = %17, %14, %18
%20 = phi i64 [ 55, %18 ], [ 48, %14 ], [ 87, %17 ]
%21 = add i64 %15, %20
%22 = tail call i32 @ft_putchar_fd(i64 %21, i32 %2)
br label %23
23: ; preds = %19, %4, %17
ret void
}