#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 == -2147483648) {
    ft_putchar_fd('2', fd);
    n %= 1000000000;
    n = -n;
  }
  if (n >= 10) {
    ft_putnbr_fd(n / 10, fd);
    ft_putnbr_fd(n % 10, fd);
  } else
    ft_putchar_fd(n + '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    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)
movslq -0x4(%rbp),%rax
cmp    $0xffffffff80000000,%rax
jne    1180 <ft_putnbr_fd+0x60>
mov    -0x8(%rbp),%esi
mov    $0x32,%edi
call   1040 <ft_putchar_fd@plt>
mov    -0x4(%rbp),%eax
mov    $0x3b9aca00,%ecx
cltd
idiv   %ecx
mov    %edx,-0x4(%rbp)
xor    %eax,%eax
sub    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
cmpl   $0xa,-0x4(%rbp)
jl     11b9 <ft_putnbr_fd+0x99>
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
mov    -0x8(%rbp),%esi
call   1030 <ft_putnbr_fd@plt>
jmp    11c7 <ft_putnbr_fd+0xa7>
mov    -0x4(%rbp),%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   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %edi,%ebp
mov    $0xcccccccd,%r15d
test   %ebp,%ebp
jns    114f <ft_putnbr_fd+0x2f>
cs nopw 0x0(%rax,%rax,1)
mov    $0x2d,%edi
mov    %r14d,%esi
call   1040 <ft_putchar_fd@plt>
neg    %ebp
cmp    $0xa,%ebp
jb     1175 <ft_putnbr_fd+0x55>
mov    %ebp,%ebx
imul   %r15,%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
test   %ebp,%ebp
jns    114f <ft_putnbr_fd+0x2f>
jmp    1140 <ft_putnbr_fd+0x20>
add    $0x30,%ebp
mov    %ebp,%edi
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
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 = sext i32 %13 to i64
%15 = icmp eq i64 %14, -2147483648
br i1 %15, label %16, label %23
16: ; preds = %12
%17 = load i32, i32* %4
%18 = call i32 @ft_putchar_fd(i32 50, i32 %17)
%19 = load i32, i32* %3
%20 = srem i32 %19, 1000000000
store i32 %20, i32* %3
%21 = load i32, i32* %3
%22 = sub nsw i32 0, %21
store i32 %22, i32* %3
br label %23
23: ; preds = %16, %12
%24 = load i32, i32* %3
%25 = icmp sge i32 %24, 10
br i1 %25, label %26, label %33
26: ; preds = %23
%27 = load i32, i32* %3
%28 = sdiv i32 %27, 10
%29 = load i32, i32* %4
%30 = load i32, i32* %3
%31 = srem i32 %30, 10
%32 = load i32, i32* %4
br label %38
33: ; preds = %23
%34 = load i32, i32* %3
%35 = add nsw i32 %34, 48
%36 = load i32, i32* %4
%37 = call i32 @ft_putchar_fd(i32 %35, i32 %36)
br label %38
38: ; preds = %33, %26
ret void
}

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