#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(char);
void ft_putnbr_base(unsigned int nbr) {
  char resault[2048];
  long int nbr_t;
  int it;
  nbr_t = nbr;
  it = 0;
  while (nbr_t / 16 >= 16) {
    resault[it++] = "0123456789abcdef"[nbr_t % 16];
    nbr_t /= 16;
  }
  resault[it++] = "0123456789abcdef"[nbr_t % 16];
  resault[it] = "0123456789abcdef"[nbr_t / 16];
  while (it >= 0)
    ft_putchar(resault[it--]);
}


x86 assembly (clang, -O0):
<ft_putnbr_base>:
push   %rbp
mov    %rsp,%rbp
sub    $0x820,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %rax,-0x818(%rbp)
movl   $0x0,-0x81c(%rbp)
mov    -0x818(%rbp),%rax
mov    $0x10,%ecx
cqto
idiv   %rcx
cmp    $0x10,%rax
jl     119f <ft_putnbr_base+0x8f>
mov    -0x818(%rbp),%rax
mov    $0x10,%ecx
cqto
idiv   %rcx
lea    0xe9b(%rip),%rax
mov    (%rax,%rdx,1),%cl
mov    -0x81c(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x81c(%rbp)
cltq
mov    %cl,-0x810(%rbp,%rax,1)
mov    -0x818(%rbp),%rax
mov    $0x10,%ecx
cqto
idiv   %rcx
mov    %rax,-0x818(%rbp)
jmp    1132 <ft_putnbr_base+0x22>
mov    -0x818(%rbp),%rax
mov    $0x10,%ecx
cqto
idiv   %rcx
lea    0xe49(%rip),%rax
mov    (%rax,%rdx,1),%cl
mov    -0x81c(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x81c(%rbp)
cltq
mov    %cl,-0x810(%rbp,%rax,1)
mov    -0x818(%rbp),%rax
mov    $0x10,%ecx
cqto
idiv   %rcx
mov    %rax,%rcx
lea    0xe11(%rip),%rax
mov    (%rax,%rcx,1),%cl
movslq -0x81c(%rbp),%rax
mov    %cl,-0x810(%rbp,%rax,1)
cmpl   $0x0,-0x81c(%rbp)
jl     1232 <ft_putnbr_base+0x122>
mov    -0x81c(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x81c(%rbp)
cltq
movsbl -0x810(%rbp,%rax,1),%edi
ff
call   1030 <ft_putchar@plt>
jmp    1200 <ft_putnbr_base+0xf0>
add    $0x820,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_putnbr_base>:
push   %rbp
push   %rbx
sub    $0x808,%rsp
mov    %edi,%edx
mov    %rdx,%rcx
shr    $0x4,%rcx
xor    %eax,%eax
cmp    $0x100,%edi
jb     1169 <ft_putnbr_base+0x59>
xor    %eax,%eax
lea    0xecb(%rip),%rsi
cs nopw 0x0(%rax,%rax,1)
nop
and    $0xf,%edx
movzbl (%rdx,%rsi,1),%ebx
mov    %rcx,%rdx
mov    %bl,(%rsp,%rax,1)
add    $0x1,%rax
add    $0xf,%rcx
test   %rdx,%rdx
cmovns %rdx,%rcx
sar    $0x4,%rcx
cmp    $0xff,%rdx
jg     1140 <ft_putnbr_base+0x30>
lea    0xf(%rdx),%rsi
test   %rdx,%rdx
cmovns %rdx,%rsi
and    $0xfffffffffffffff0,%rsi
sub    %rsi,%rdx
lea    0xe7e(%rip),%rsi
mov    (%rsi,%rdx,1),%bl
mov    %eax,%edx
mov    %bl,(%rsp,%rdx,1)
mov    (%rcx,%rsi,1),%cl
mov    %cl,0x1(%rsp,%rdx,1)
cmp    $0xffffffff,%eax
jl     11c3 <ft_putnbr_base+0xb3>
lea    0x2(%rdx),%ebp
mov    %rsp,%rax
lea    (%rdx,%rax,1),%rbx
add    $0x1,%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl (%rbx),%edi
call   1030 <ft_putchar@plt>
add    $0xffffffff,%ebp
add    $0xffffffffffffffff,%rbx
test   %ebp,%ebp
jg     11b0 <ft_putnbr_base+0xa0>
add    $0x808,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"0123456789abcdef\00"
define void @ft_putnbr_base(i32 %0) {
%2 = alloca i32
%3 = alloca [2048 x i8]
%4 = alloca i64
%5 = alloca i32
store i32 %0, i32* %2
%6 = load i32, i32* %2
%7 = zext i32 %6 to i64
store i64 %7, i64* %4
store i32 0, i32* %5
br label %8
8: ; preds = %12, %1
%9 = load i64, i64* %4
%10 = sdiv i64 %9, 16
%11 = icmp sge i64 %10, 16
br i1 %11, label %12, label %23
12: ; preds = %8
%13 = load i64, i64* %4
%14 = srem i64 %13, 16
%15 = getelementptr inbounds [17 x i8], [17 x i8]* @.str, i64 0, i64 %14
%16 = load i8, i8* %15
%17 = load i32, i32* %5
%18 = add nsw i32 %17, 1
store i32 %18, i32* %5
%19 = sext i32 %17 to i64
%20 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 %19
store i8 %16, i8* %20
%21 = load i64, i64* %4
%22 = sdiv i64 %21, 16
store i64 %22, i64* %4
br label %8
23: ; preds = %8
%24 = load i64, i64* %4
%25 = srem i64 %24, 16
%26 = getelementptr inbounds [17 x i8], [17 x i8]* @.str, i64 0, i64 %25
%27 = load i8, i8* %26
%28 = load i32, i32* %5
%29 = add nsw i32 %28, 1
store i32 %29, i32* %5
%30 = sext i32 %28 to i64
%31 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 %30
store i8 %27, i8* %31
%32 = load i64, i64* %4
%33 = sdiv i64 %32, 16
%34 = getelementptr inbounds [17 x i8], [17 x i8]* @.str, i64 0, i64 %33
%35 = load i8, i8* %34
%36 = load i32, i32* %5
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 %37
store i8 %35, i8* %38
br label %39
39: ; preds = %42, %23
%40 = load i32, i32* %5
%41 = icmp sge i32 %40, 0
br i1 %41, label %42, label %49
42: ; preds = %39
%43 = load i32, i32* %5
%44 = add nsw i32 %43, -1
store i32 %44, i32* %5
%45 = sext i32 %43 to i64
%46 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 %45
%47 = load i8, i8* %46
%48 = call i32 @ft_putchar(i8 signext %47)
br label %39
49: ; preds = %39
ret void
}

LLVM IR (-O2):
@.str = [17 x i8] c"0123456789abcdef\00"
define void @ft_putnbr_base(i32 %0) {
%2 = alloca [2048 x i8]
%3 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 0
%4 = zext i32 %0 to i64
%5 = lshr i64 %4, 4
%6 = icmp ugt i32 %0, 255
br i1 %6, label %7, label %20
7: ; preds = %1, %7
%8 = phi i64 [ %14, %7 ], [ 0, %1 ]
%9 = phi i64 [ %16, %7 ], [ %5, %1 ]
%10 = phi i64 [ %9, %7 ], [ %4, %1 ]
%11 = and i64 %10, 15
%12 = getelementptr inbounds [17 x i8], [17 x i8]* @.str, i64 0, i64 %11
%13 = load i8, i8* %12
%14 = add nuw i64 %8, 1
%15 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 %8
store i8 %13, i8* %15
%16 = sdiv i64 %9, 16
%17 = icmp sgt i64 %9, 255
br i1 %17, label %7, label %18
18: ; preds = %7
%19 = trunc i64 %14 to i32
br label %20
20: ; preds = %18, %1
%21 = phi i64 [ %4, %1 ], [ %9, %18 ]
%22 = phi i32 [ 0, %1 ], [ %19, %18 ]
%23 = phi i64 [ %5, %1 ], [ %16, %18 ]
%24 = srem i64 %21, 16
%25 = getelementptr inbounds [17 x i8], [17 x i8]* @.str, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = add nuw nsw i32 %22, 1
%28 = zext i32 %22 to i64
%29 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 %28
store i8 %26, i8* %29
%30 = getelementptr inbounds [17 x i8], [17 x i8]* @.str, i64 0, i64 %23
%31 = load i8, i8* %30
%32 = zext i32 %27 to i64
%33 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 %32
store i8 %31, i8* %33
%34 = icmp sgt i32 %22, -2
br i1 %34, label %35, label %45
35: ; preds = %20
%36 = add nuw nsw i64 %28, 1
br label %37
37: ; preds = %35, %37
%38 = phi i64 [ %36, %35 ], [ %39, %37 ]
%39 = add nsw i64 %38, -1
%40 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 %38
%41 = load i8, i8* %40
%42 = tail call i32 @ft_putchar(i8 signext %41)
%43 = trunc i64 %38 to i32
%44 = icmp sgt i32 %43, 0
br i1 %44, label %37, label %45
45: ; preds = %37, %20
ret void
}