#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 && n != -2147483648) {
    ft_putchar_fd('-', fd);
    ft_putnbr_fd(-n, fd);
  } else if (n == -2147483648)
    ft_putstr_fd("-2147483648", fd);
  else if (n > 9) {
    ft_putnbr_fd(n / 10, fd);
    ft_putchar_fd((n % 10) + '0', fd);
  } else
    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    1177 <ft_putnbr_fd+0x47>
movslq -0x4(%rbp),%rax
cmp    $0xffffffff80000000,%rax
je     1177 <ft_putnbr_fd+0x47>
mov    -0x8(%rbp),%esi
mov    $0x2d,%edi
call   1050 <ft_putchar_fd@plt>
xor    %edi,%edi
sub    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1030 <ft_putnbr_fd@plt>
jmp    11f9 <ft_putnbr_fd+0xc9>
movslq -0x4(%rbp),%rax
cmp    $0xffffffff80000000,%rax
jne    119b <ft_putnbr_fd+0x6b>
mov    -0x8(%rbp),%esi
lea    0xe6f(%rip),%rdi
call   1040 <ft_putstr_fd@plt>
jmp    11f4 <ft_putnbr_fd+0xc4>
cmpl   $0x9,-0x4(%rbp)
jle    11d7 <ft_putnbr_fd+0xa7>
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>
jmp    11ef <ft_putnbr_fd+0xbf>
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>
jmp    11f4 <ft_putnbr_fd+0xc4>
jmp    11f9 <ft_putnbr_fd+0xc9>
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
cmp    $0x80000001,%edi
jb     1152 <ft_putnbr_fd+0x22>
mov    $0x2d,%edi
mov    %r14d,%esi
call   1050 <ft_putchar_fd@plt>
neg    %ebp
jmp    116d <ft_putnbr_fd+0x3d>
cmp    $0x80000000,%ebp
jne    116d <ft_putnbr_fd+0x3d>
lea    0xe9f(%rip),%rdi
mov    %r14d,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <ft_putstr_fd@plt>
cmp    $0xa,%ebp
jb     1199 <ft_putnbr_fd+0x69>
mov    %ebp,%eax
mov    $0xcccccccd,%ebx
imul   %rax,%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
or     $0x30,%ebp
mov    %ebp,%edi
jmp    11b3 <ft_putnbr_fd+0x83>
movzbl %bpl,%eax
imul   $0xcd,%eax,%ecx
shr    $0xa,%ecx
and    $0xfffffffe,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %cl,%al
or     $0x30,%al
movzbl %al,%edi
mov    %r14d,%esi
pop    %rbx
pop    %r14
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 = icmp slt i32 %5, 0
br i1 %6, label %7, label %17
7: ; preds = %2
%8 = load i32, i32* %3
%9 = sext i32 %8 to i64
%10 = icmp ne i64 %9, -2147483648
br i1 %10, label %11, label %17
11: ; preds = %7
%12 = load i32, i32* %4
%13 = call i32 @ft_putchar_fd(i32 45, i32 %12)
%14 = load i32, i32* %3
%15 = sub nsw i32 0, %14
%16 = load i32, i32* %4
br label %44
17: ; preds = %7, %2
%18 = load i32, i32* %3
%19 = sext i32 %18 to i64
%20 = icmp eq i64 %19, -2147483648
br i1 %20, label %21, label %24
21: ; preds = %17
%22 = load i32, i32* %4
%23 = call i32 @ft_putstr_fd(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %22)
br label %43
24: ; preds = %17
%25 = load i32, i32* %3
%26 = icmp sgt i32 %25, 9
br i1 %26, label %27, label %36
27: ; preds = %24
%28 = load i32, i32* %3
%29 = sdiv i32 %28, 10
%30 = load i32, i32* %4
%31 = load i32, i32* %3
%32 = srem i32 %31, 10
%33 = add nsw i32 %32, 48
%34 = load i32, i32* %4
%35 = call i32 @ft_putchar_fd(i32 %33, i32 %34)
br label %42
36: ; preds = %24
%37 = load i32, i32* %3
%38 = srem i32 %37, 10
%39 = add nsw i32 %38, 48
%40 = load i32, i32* %4
%41 = call i32 @ft_putchar_fd(i32 %39, i32 %40)
br label %42
42: ; preds = %36, %27
br label %43
43: ; preds = %42, %21
br label %44
44: ; preds = %43, %11
ret void
}

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