#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(long, int);
void ft_putnbr_fd(int n, int fd) {
  long int nb;
  nb = n;
  if (nb < 0) {
    ft_putchar_fd('-', fd);
    nb = -nb;
  }
  if (nb > 9) {
    ft_putnbr_fd(nb / 10, fd);
    ft_putnbr_fd(nb % 10, fd);
  } else
    ft_putchar_fd(nb + '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)
movslq -0x4(%rbp),%rax
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jge    1158 <ft_putnbr_fd+0x38>
mov    -0x8(%rbp),%esi
mov    $0x2d,%edi
call   1040 <ft_putchar_fd@plt>
xor    %eax,%eax
sub    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
cmpq   $0x9,-0x10(%rbp)
jle    1198 <ft_putnbr_fd+0x78>
mov    -0x10(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
mov    %eax,%edi
mov    -0x8(%rbp),%esi
call   1030 <ft_putnbr_fd@plt>
mov    -0x10(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
mov    %edx,%edi
mov    -0x8(%rbp),%esi
call   1030 <ft_putnbr_fd@plt>
jmp    11a8 <ft_putnbr_fd+0x88>
mov    -0x10(%rbp),%rdi
add    $0x30,%rdi
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   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %edi,%ebx
mov    $0xcccccccd,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movslq %ebx,%rbx
test   %ebx,%ebx
jns    1157 <ft_putnbr_fd+0x37>
mov    $0x2d,%edi
mov    %r14d,%esi
call   1040 <ft_putchar_fd@plt>
neg    %rbx
cmp    $0xa,%rbx
jl     117b <ft_putnbr_fd+0x5b>
mov    %ebx,%ebp
imul   %r15,%rbp
shr    $0x23,%rbp
mov    %ebp,%edi
mov    %r14d,%esi
call   1030 <ft_putnbr_fd@plt>
add    %ebp,%ebp
lea    0x0(%rbp,%rbp,4),%eax
sub    %eax,%ebx
jmp    1140 <ft_putnbr_fd+0x20>
add    $0x30,%rbx
mov    %rbx,%rdi
mov    %r14d,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
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 i64
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = load i32, i32* %3
%7 = sext i32 %6 to i64
store i64 %7, i64* %5
%8 = load i64, i64* %5
%9 = icmp slt i64 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = load i32, i32* %4
%12 = call i32 @ft_putchar_fd(i64 45, i32 %11)
%13 = load i64, i64* %5
%14 = sub nsw i64 0, %13
store i64 %14, i64* %5
br label %15
15: ; preds = %10, %2
%16 = load i64, i64* %5
%17 = icmp sgt i64 %16, 9
br i1 %17, label %18, label %27
18: ; preds = %15
%19 = load i64, i64* %5
%20 = sdiv i64 %19, 10
%21 = trunc i64 %20 to i32
%22 = load i32, i32* %4
%23 = load i64, i64* %5
%24 = srem i64 %23, 10
%25 = trunc i64 %24 to i32
%26 = load i32, i32* %4
br label %32
27: ; preds = %15
%28 = load i64, i64* %5
%29 = add nsw i64 %28, 48
%30 = load i32, i32* %4
%31 = call i32 @ft_putchar_fd(i64 %29, i32 %30)
br label %32
32: ; preds = %27, %18
ret void
}

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