#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 const, int);
int /*<<< orphan*/ ft_putstr_fd(char *, int);
void ft_putnbr_fd(const int nb, int fd) {
  if (nb == -2147483648)
    ft_putstr_fd("-2147483648", fd);
  else {
    if (nb < 0)
      ft_putchar_fd('-', fd);
    if (nb >= 10)
      ft_putnbr_fd(nb / 10, fd);
    ft_putchar_fd(nb % 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)
movslq -0x4(%rbp),%rax
cmp    $0xffffffff80000000,%rax
jne    1162 <ft_putnbr_fd+0x32>
mov    -0x8(%rbp),%esi
lea    0xea8(%rip),%rdi
call   1040 <ft_putstr_fd@plt>
jmp    11b0 <ft_putnbr_fd+0x80>
cmpl   $0x0,-0x4(%rbp)
jge    1179 <ft_putnbr_fd+0x49>
mov    -0x8(%rbp),%esi
mov    $0x2d,%edi
call   1050 <ft_putchar_fd@plt>
cmpl   $0xa,-0x4(%rbp)
jl     1198 <ft_putnbr_fd+0x68>
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   1050 <ft_putchar_fd@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_putnbr_fd>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
cmp    $0x80000000,%edi
jne    1151 <ft_putnbr_fd+0x21>
lea    0xebc(%rip),%rdi
mov    %ebp,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <ft_putstr_fd@plt>
mov    %edi,%ebx
test   %edi,%edi
js     1174 <ft_putnbr_fd+0x44>
cmp    $0xa,%ebx
jb     1180 <ft_putnbr_fd+0x50>
mov    %ebx,%eax
mov    $0xcccccccd,%edi
imul   %rax,%rdi
shr    $0x23,%rdi
mov    %ebp,%esi
call   1030 <ft_putnbr_fd@plt>
jmp    1180 <ft_putnbr_fd+0x50>
mov    $0x2d,%edi
mov    %ebp,%esi
call   1050 <ft_putchar_fd@plt>
movslq %ebx,%rax
imul   $0x66666667,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
neg    %eax
lea    (%rbx,%rax,1),%edi
add    $0x30,%edi
mov    %ebp,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <ft_putchar_fd@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"-2147483648\00"
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 = sext i32 %5 to i64
%7 = icmp eq i64 %6, -2147483648
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = load i32, i32* %4
%10 = call i32 @ft_putstr_fd(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %9)
br label %30
11: ; preds = %2
%12 = load i32, i32* %3
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = load i32, i32* %4
%16 = call i32 @ft_putchar_fd(i32 45, i32 %15)
br label %17
17: ; preds = %14, %11
%18 = load i32, i32* %3
%19 = icmp sge i32 %18, 10
br i1 %19, label %20, label %24
20: ; preds = %17
%21 = load i32, i32* %3
%22 = sdiv i32 %21, 10
%23 = load i32, i32* %4
br label %24
24: ; preds = %20, %17
%25 = load i32, i32* %3
%26 = srem i32 %25, 10
%27 = add nsw i32 %26, 48
%28 = load i32, i32* %4
%29 = call i32 @ft_putchar_fd(i32 %27, i32 %28)
br label %30
30: ; preds = %24, %8
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"-2147483648\00"
define void @ft_putnbr_fd(i32 %0, i32 %1) {
%3 = icmp eq i32 %0, -2147483648
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @ft_putstr_fd(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %1)
br label %18
6: ; preds = %2
%7 = icmp slt i32 %0, 0
br i1 %7, label %8, label %10
8: ; preds = %6
%9 = tail call i32 @ft_putchar_fd(i32 45, i32 %1)
br label %14
10: ; preds = %6
%11 = icmp ugt i32 %0, 9
br i1 %11, label %12, label %14
12: ; preds = %10
%13 = udiv i32 %0, 10
tail call void @ft_putnbr_fd(i32 %13, i32 %1)
br label %14
14: ; preds = %8, %12, %10
%15 = srem i32 %0, 10
%16 = add nsw i32 %15, 48
%17 = tail call i32 @ft_putchar_fd(i32 %16, i32 %1)
br label %18
18: ; preds = %14, %4
ret void
}