#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 int, int);
void ft_putnbr_fd(int n, int fd) {
  unsigned int b;
  if (n < 0) {
    ft_putchar_fd('-', fd);
    b = -n;
  } else
    b = n;
  if (b < 10)
    ft_putchar_fd((b + '0'), fd);
  else {
    ft_putnbr_fd(b / 10, fd);
    ft_putchar_fd(b % 10 + '0', fd);
  }
}


x86 assembly (clang, -O0):
<ft_putnbr_fd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    1152 <ft_putnbr_fd+0x32>
mov    -0x8(%rbp),%esi
mov    $0x2d,%edi
call   1040 <ft_putchar_fd@plt>
xor    %eax,%eax
sub    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    1158 <ft_putnbr_fd+0x38>
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jae    1175 <ft_putnbr_fd+0x55>
mov    -0xc(%rbp),%edi
add    $0x30,%edi
mov    -0x8(%rbp),%esi
call   1040 <ft_putchar_fd@plt>
jmp    11a4 <ft_putnbr_fd+0x84>
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,%edi
mov    -0x8(%rbp),%esi
call   1030 <ft_putnbr_fd@plt>
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
mov    %edx,%edi
add    $0x30,%edi
mov    -0x8(%rbp),%esi
call   1040 <ft_putchar_fd@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_putnbr_fd>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %edi,%ebp
test   %edi,%edi
js     1137 <ft_putnbr_fd+0x17>
cmp    $0x9,%ebp
ja     114b <ft_putnbr_fd+0x2b>
add    $0x30,%ebp
jmp    116e <ft_putnbr_fd+0x4e>
mov    $0x2d,%edi
mov    %r14d,%esi
call   1040 <ft_putchar_fd@plt>
neg    %ebp
cmp    $0x9,%ebp
jbe    1132 <ft_putnbr_fd+0x12>
mov    %ebp,%eax
mov    $0xcccccccd,%ebx
imul   %rax,%rbx
shr    $0x23,%rbx
mov    %ebx,%edi
mov    %r14d,%esi
call   1030 <ft_putnbr_fd@plt>
add    %ebx,%ebx
lea    (%rbx,%rbx,4),%eax
sub    %eax,%ebp
or     $0x30,%ebp
mov    %ebp,%edi
mov    %r14d,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <ft_putchar_fd@plt>

LLVM IR (-O0):
define void @ft_putnbr_fd(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 slt i32 %6, 0
br i1 %7, label %8, label %13
8: ; preds = %2
%9 = load i32, i32* %4
%10 = call i32 @ft_putchar_fd(i32 45, i32 %9)
%11 = load i32, i32* %3
%12 = sub nsw i32 0, %11
store i32 %12, i32* %5
br label %15
13: ; preds = %2
%14 = load i32, i32* %3
store i32 %14, i32* %5
br label %15
15: ; preds = %13, %8
%16 = load i32, i32* %5
%17 = icmp ult i32 %16, 10
br i1 %17, label %18, label %23
18: ; preds = %15
%19 = load i32, i32* %5
%20 = add i32 %19, 48
%21 = load i32, i32* %4
%22 = call i32 @ft_putchar_fd(i32 %20, i32 %21)
br label %32
23: ; preds = %15
%24 = load i32, i32* %5
%25 = udiv i32 %24, 10
%26 = load i32, i32* %4
%27 = load i32, i32* %5
%28 = urem i32 %27, 10
%29 = add i32 %28, 48
%30 = load i32, i32* %4
%31 = call i32 @ft_putchar_fd(i32 %29, i32 %30)
br label %32
32: ; preds = %23, %18
ret void
}

LLVM IR (-O2):
define void @ft_putnbr_fd(i32 %0, i32 %1) {
%3 = icmp slt i32 %0, 0
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = tail call i32 @ft_putchar_fd(i32 45, i32 %1)
%6 = sub nsw i32 0, %0
br label %7
7: ; preds = %2, %4
%8 = phi i32 [ %6, %4 ], [ %0, %2 ]
%9 = icmp ult i32 %8, 10
br i1 %9, label %10, label %15
10: ; preds = %7
%11 = add nuw nsw i32 %8, 48
br label %12
12: ; preds = %10, %15
%13 = phi i32 [ %11, %10 ], [ %18, %15 ]
%14 = tail call i32 @ft_putchar_fd(i32 %13, i32 %1)
ret void
15: ; preds = %7
%16 = udiv i32 %8, 10
tail call void @ft_putnbr_fd(i32 %16, i32 %1)
%17 = urem i32 %8, 10
%18 = or i32 %17, 48
br label %12
}