#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(int, int);
void ft_putnbr_fd(int n, int fd) {
  if (n < 0) {
    ft_putchar_fd('-', fd);
    n = -n;
  }
  if (n / 10 > 0)
    ft_putnbr_fd(n / 10, fd);
  ft_putchar_fd('0' + n % 10, 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    114d <ft_putnbr_fd+0x2d>
mov    -0x8(%rbp),%esi
mov    $0x2d,%edi
call   1040 <ft_putchar_fd@plt>
xor    %eax,%eax
sub    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x0,%eax
jle    1176 <ft_putnbr_fd+0x56>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
mov    -0x8(%rbp),%esi
call   1030 <ft_putnbr_fd@plt>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %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
jns    113c <ft_putnbr_fd+0x1c>
mov    $0x2d,%edi
mov    %r14d,%esi
call   1040 <ft_putchar_fd@plt>
neg    %ebp
mov    %ebp,%ebx
cmp    $0xa,%ebp
jb     1158 <ft_putnbr_fd+0x38>
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
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %12
7: ; preds = %2
%8 = load i32, i32* %4
%9 = call i32 @ft_putchar_fd(i32 45, i32 %8)
%10 = load i32, i32* %3
%11 = sub nsw i32 0, %10
store i32 %11, i32* %3
br label %12
12: ; preds = %7, %2
%13 = load i32, i32* %3
%14 = sdiv i32 %13, 10
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %12
%17 = load i32, i32* %3
%18 = sdiv i32 %17, 10
%19 = load i32, i32* %4
br label %20
20: ; preds = %16, %12
%21 = load i32, i32* %3
%22 = srem i32 %21, 10
%23 = add nsw i32 48, %22
%24 = load i32, i32* %4
%25 = call i32 @ft_putchar_fd(i32 %23, i32 %24)
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 = %4, %2
%8 = phi i32 [ %6, %4 ], [ %0, %2 ]
%9 = icmp ugt i32 %8, 9
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = udiv i32 %8, 10
tail call void @ft_putnbr_fd(i32 %11, i32 %1)
br label %12
12: ; preds = %10, %7
%13 = urem i32 %8, 10
%14 = or i32 %13, 48
%15 = tail call i32 @ft_putchar_fd(i32 %14, i32 %1)
ret void
}