#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(long n, int fd) {
  if (n < 0) {
    ft_putchar_fd('-', fd);
    if ((n / 10) != 0)
      ft_putnbr_fd(((n / 10) * -1), fd);
    ft_putnbr_fd(((n % 10) * -1), fd);
  } else if (n > 9) {
    ft_putnbr_fd((n / 10), fd);
    ft_putnbr_fd((n % 10), fd);
  } else if (n >= 0 && n <= 9) {
    ft_putchar_fd((n + 48), fd);
  }
}


x86 assembly (clang, -O0):
<ft_putnbr_fd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpq   $0x0,-0x8(%rbp)
jge    1198 <ft_putnbr_fd+0x78>
mov    -0xc(%rbp),%esi
mov    $0x2d,%edi
call   1040 <ft_putchar_fd@plt>
mov    -0x8(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
cmp    $0x0,%rax
je     1179 <ft_putnbr_fd+0x59>
mov    -0x8(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
imul   $0xffffffffffffffff,%rax,%rdi
mov    -0xc(%rbp),%esi
call   1030 <ft_putnbr_fd@plt>
mov    -0x8(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
imul   $0xffffffffffffffff,%rdx,%rdi
mov    -0xc(%rbp),%esi
call   1030 <ft_putnbr_fd@plt>
jmp    120a <ft_putnbr_fd+0xea>
cmpq   $0x9,-0x8(%rbp)
jle    11da <ft_putnbr_fd+0xba>
mov    -0x8(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
mov    %rax,%rdi
mov    -0xc(%rbp),%esi
call   1030 <ft_putnbr_fd@plt>
mov    -0x8(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
mov    %rdx,%rdi
mov    -0xc(%rbp),%esi
call   1030 <ft_putnbr_fd@plt>
jmp    1205 <ft_putnbr_fd+0xe5>
cmpq   $0x0,-0x8(%rbp)
jl     1200 <ft_putnbr_fd+0xe0>
cmpq   $0x9,-0x8(%rbp)
jg     1200 <ft_putnbr_fd+0xe0>
mov    -0x8(%rbp),%rdi
add    $0x30,%rdi
mov    -0xc(%rbp),%esi
call   1040 <ft_putchar_fd@plt>
jmp    1205 <ft_putnbr_fd+0xe5>
jmp    120a <ft_putnbr_fd+0xea>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_putnbr_fd>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %rdi,%rbx
movabs $0xcccccccccccccccd,%r14
cc cc cc
jmp    116f <ft_putnbr_fd+0x4f>
cs nopw 0x0(%rax,%rax,1)
nop
cmp    $0x9,%rbx
jbe    118f <ft_putnbr_fd+0x6f>
mov    %rbx,%rax
mul    %r14
mov    %rdx,%rdi
shr    $0x3,%rdi
mov    %ebp,%esi
call   1030 <ft_putnbr_fd@plt>
mov    %rbx,%rax
mul    %r14
shr    $0x2,%rdx
and    $0xfffffffffffffffe,%rdx
lea    (%rdx,%rdx,4),%rax
sub    %rax,%rbx
test   %rbx,%rbx
jns    1140 <ft_putnbr_fd+0x20>
mov    $0x2d,%edi
mov    %ebp,%esi
call   1040 <ft_putchar_fd@plt>
lea    0x9(%rbx),%rax
neg    %rbx
cmp    $0x13,%rax
jae    1146 <ft_putnbr_fd+0x26>
jmp    115a <ft_putnbr_fd+0x3a>
add    $0x30,%rbx
mov    %rbx,%rdi
mov    %ebp,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <ft_putchar_fd@plt>

LLVM IR (-O0):
define void @ft_putnbr_fd(i64 %0, i32 %1) {
%3 = alloca i64
%4 = alloca i32
store i64 %0, i64* %3
store i32 %1, i32* %4
%5 = load i64, i64* %3
%6 = icmp slt i64 %5, 0
br i1 %6, label %7, label %23
7: ; preds = %2
%8 = load i32, i32* %4
%9 = call i32 @ft_putchar_fd(i64 45, i32 %8)
%10 = load i64, i64* %3
%11 = sdiv i64 %10, 10
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %7
%14 = load i64, i64* %3
%15 = sdiv i64 %14, 10
%16 = mul nsw i64 %15, -1
%17 = load i32, i32* %4
br label %18
18: ; preds = %13, %7
%19 = load i64, i64* %3
%20 = srem i64 %19, 10
%21 = mul nsw i64 %20, -1
%22 = load i32, i32* %4
br label %46
23: ; preds = %2
%24 = load i64, i64* %3
%25 = icmp sgt i64 %24, 9
br i1 %25, label %26, label %33
26: ; preds = %23
%27 = load i64, i64* %3
%28 = sdiv i64 %27, 10
%29 = load i32, i32* %4
%30 = load i64, i64* %3
%31 = srem i64 %30, 10
%32 = load i32, i32* %4
br label %45
33: ; preds = %23
%34 = load i64, i64* %3
%35 = icmp sge i64 %34, 0
br i1 %35, label %36, label %44
36: ; preds = %33
%37 = load i64, i64* %3
%38 = icmp sle i64 %37, 9
br i1 %38, label %39, label %44
39: ; preds = %36
%40 = load i64, i64* %3
%41 = add nsw i64 %40, 48
%42 = load i32, i32* %4
%43 = call i32 @ft_putchar_fd(i64 %41, i32 %42)
br label %44
44: ; preds = %39, %36, %33
br label %45
45: ; preds = %44, %26
br label %46
46: ; preds = %45, %18
ret void
}

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