#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) {
    ft_putchar_fd('-', fd);
    if (n == -2147483648) {
      ft_putstr_fd("MIN_INT", fd);
      return;
    }
    n = -n;
  }
  if (n > 9)
    ft_putnbr_fd(n / 10, fd);
  ft_putchar_fd(n % 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)
cmpl   $0x0,-0x4(%rbp)
jge    1181 <ft_putnbr_fd+0x51>
mov    -0x8(%rbp),%esi
mov    $0x2d,%edi
call   1050 <ft_putchar_fd@plt>
movslq -0x4(%rbp),%rax
cmp    $0xffffffff80000000,%rax
jne    1179 <ft_putnbr_fd+0x49>
mov    -0x8(%rbp),%esi
lea    0xe91(%rip),%rdi
call   1040 <ft_putstr_fd@plt>
jmp    11b8 <ft_putnbr_fd+0x88>
xor    %eax,%eax
sub    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
cmpl   $0x9,-0x4(%rbp)
jle    11a0 <ft_putnbr_fd+0x70>
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   %r14
push   %rbx
mov    %esi,%r14d
mov    %edi,%ebp
test   %edi,%edi
jns    1167 <ft_putnbr_fd+0x37>
mov    $0x2d,%edi
mov    %r14d,%esi
call   1050 <ft_putchar_fd@plt>
cmp    $0x80000000,%ebp
jne    1165 <ft_putnbr_fd+0x35>
lea    0xea7(%rip),%rdi
mov    %r14d,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <ft_putstr_fd@plt>
neg    %ebp
mov    %ebp,%ebx
cmp    $0xa,%ebp
jb     1183 <ft_putnbr_fd+0x53>
mov    $0xcccccccd,%edi
imul   %rbx,%rdi
shr    $0x23,%rdi
mov    %r14d,%esi
call   1030 <ft_putnbr_fd@plt>
mov    $0xcccccccd,%eax
imul   %rbx,%rax
shr    $0x23,%rax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%ebp
or     $0x30,%ebp
mov    %ebp,%edi
mov    %r14d,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <ft_putchar_fd@plt>

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

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