#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(const int nb, int fd) {
  unsigned int n;
  n = nb < 0 ? -nb : nb;
  if (nb < 0)
    ft_putchar_fd('-', fd);
  if (n >= 10)
    ft_putnbr_fd(n / 10, fd);
  ft_putchar_fd(n % 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    1145 <ft_putnbr_fd+0x25>
xor    %eax,%eax
sub    -0x4(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    114b <ft_putnbr_fd+0x2b>
mov    -0x4(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    1168 <ft_putnbr_fd+0x48>
mov    -0x8(%rbp),%esi
mov    $0x2d,%edi
call   1040 <ft_putchar_fd@plt>
cmpl   $0xa,-0xc(%rbp)
jb     1188 <ft_putnbr_fd+0x68>
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
neg    %ebp
cmovs  %edi,%ebp
test   %edi,%edi
jns    113f <ft_putnbr_fd+0x1f>
mov    $0x2d,%edi
mov    %r14d,%esi
call   1040 <ft_putchar_fd@plt>
mov    %ebp,%ebx
cmp    $0xa,%ebp
jb     115b <ft_putnbr_fd+0x3b>
mov    $0xcccccccd,%edi
imul   %rbx,%rdi
shr    $0x23,%rdi
mov    %r14d,%esi
call   1030 <ft_putnbr_fd@plt>
mov    $0xcccccccd,%eax
imul   %rbx,%rax
shr    $0x23,%rax
add    %eax,%eax
lea    (%rax,%rax,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 %11
8: ; preds = %2
%9 = load i32, i32* %3
%10 = sub nsw i32 0, %9
br label %13
11: ; preds = %2
%12 = load i32, i32* %3
br label %13
13: ; preds = %11, %8
%14 = phi i32 [ %10, %8 ], [ %12, %11 ]
store i32 %14, i32* %5
%15 = load i32, i32* %3
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %13
%18 = load i32, i32* %4
%19 = call i32 @ft_putchar_fd(i32 45, i32 %18)
br label %20
20: ; preds = %17, %13
%21 = load i32, i32* %5
%22 = icmp uge i32 %21, 10
br i1 %22, label %23, label %27
23: ; preds = %20
%24 = load i32, i32* %5
%25 = udiv i32 %24, 10
%26 = load i32, i32* %4
br label %27
27: ; preds = %23, %20
%28 = load i32, i32* %5
%29 = urem i32 %28, 10
%30 = add i32 %29, 48
%31 = load i32, i32* %4
%32 = call i32 @ft_putchar_fd(i32 %30, i32 %31)
ret void
}

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