#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);
int /*<<< orphan*/ ft_putstr_fd(char *, int);
void ft_putnbr_fd(int n, int fd) {
  if (n < 0) {
    if (n == -2147483648) {
      ft_putstr_fd("-2147483648", fd);
      return;
    } else {
      ft_putchar_fd('-', fd);
      n = n * -1;
    }
  }
  if (n > 9) {
    ft_putnbr_fd(n / 10, fd);
    ft_putnbr_fd(n % 10, fd);
  } else
    ft_putchar_fd(n + 48, 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    1185 <ft_putnbr_fd+0x55>
movslq -0x4(%rbp),%rax
cmp    $0xffffffff80000000,%rax
jne    116c <ft_putnbr_fd+0x3c>
mov    -0x8(%rbp),%esi
lea    0xe9e(%rip),%rdi
call   1040 <ft_putstr_fd@plt>
jmp    11cc <ft_putnbr_fd+0x9c>
mov    -0x8(%rbp),%esi
mov    $0x2d,%edi
call   1050 <ft_putchar_fd@plt>
imul   $0xffffffff,-0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1185 <ft_putnbr_fd+0x55>
cmpl   $0x9,-0x4(%rbp)
jle    11be <ft_putnbr_fd+0x8e>
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    11cc <ft_putnbr_fd+0x9c>
mov    -0x4(%rbp),%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   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %edi,%ebp
mov    $0xcccccccd,%r15d
test   %ebp,%ebp
jns    1167 <ft_putnbr_fd+0x37>
cs nopw 0x0(%rax,%rax,1)
cmp    $0x80000000,%ebp
je     11a4 <ft_putnbr_fd+0x74>
mov    $0x2d,%edi
mov    %r14d,%esi
call   1050 <ft_putchar_fd@plt>
neg    %ebp
cmp    $0xa,%ebp
jb     118d <ft_putnbr_fd+0x5d>
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    1167 <ft_putnbr_fd+0x37>
jmp    1150 <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    1050 <ft_putchar_fd@plt>
lea    0xe55(%rip),%rdi
mov    %r14d,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <ft_putstr_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 = icmp slt i32 %5, 0
br i1 %6, label %7, label %20
7: ; preds = %2
%8 = load i32, i32* %3
%9 = sext i32 %8 to i64
%10 = icmp eq i64 %9, -2147483648
br i1 %10, label %11, label %14
11: ; preds = %7
%12 = load i32, i32* %4
%13 = call i32 @ft_putstr_fd(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %12)
br label %35
14: ; preds = %7
%15 = load i32, i32* %4
%16 = call i32 @ft_putchar_fd(i32 45, i32 %15)
%17 = load i32, i32* %3
%18 = mul nsw i32 %17, -1
store i32 %18, i32* %3
br label %19
19: ; preds = %14
br label %20
20: ; preds = %19, %2
%21 = load i32, i32* %3
%22 = icmp sgt i32 %21, 9
br i1 %22, label %23, label %30
23: ; preds = %20
%24 = load i32, i32* %3
%25 = sdiv i32 %24, 10
%26 = load i32, i32* %4
%27 = load i32, i32* %3
%28 = srem i32 %27, 10
%29 = load i32, i32* %4
br label %35
30: ; preds = %20
%31 = load i32, i32* %3
%32 = add nsw i32 %31, 48
%33 = load i32, i32* %4
%34 = call i32 @ft_putchar_fd(i32 %32, i32 %33)
br label %35
35: ; preds = %11, %30, %23
ret void
}

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