#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(char, int);
int /*<<< orphan*/ ft_putstr_fd(char *, int);
void ft_putnbr_fd(int n, int fd) {
  if (n > 0) {
    if ((n / 10)) {
      ft_putnbr_fd(n / 10, fd);
      ft_putchar_fd((n % 10) + '0', fd);
    } else
      ft_putchar_fd(n + '0', fd);
  } else if (n == -2147483648) {
    ft_putstr_fd("-2", fd);
    ft_putnbr_fd(147483648, fd);
  } else if (n < 0) {
    ft_putchar_fd('-', fd);
    ft_putnbr_fd(-n, fd);
  }
  if (n == 0)
    ft_putchar_fd('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)
jle    11a7 <ft_putnbr_fd+0x77>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x0,%eax
je     1191 <ft_putnbr_fd+0x61>
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
add    $0x30,%edx
mov    %dl,%al
mov    -0x8(%rbp),%esi
movsbl %al,%edi
call   1050 <ft_putchar_fd@plt>
jmp    11a2 <ft_putnbr_fd+0x72>
mov    -0x4(%rbp),%eax
add    $0x30,%eax
mov    -0x8(%rbp),%esi
movsbl %al,%edi
call   1050 <ft_putchar_fd@plt>
jmp    1206 <ft_putnbr_fd+0xd6>
movslq -0x4(%rbp),%rax
cmp    $0xffffffff80000000,%rax
jne    11d8 <ft_putnbr_fd+0xa8>
mov    -0x8(%rbp),%esi
lea    0xe3f(%rip),%rdi
call   1040 <ft_putstr_fd@plt>
mov    -0x8(%rbp),%esi
mov    $0x8ca6c00,%edi
call   1030 <ft_putnbr_fd@plt>
jmp    1201 <ft_putnbr_fd+0xd1>
cmpl   $0x0,-0x4(%rbp)
jge    11fc <ft_putnbr_fd+0xcc>
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    1201 <ft_putnbr_fd+0xd1>
jmp    1206 <ft_putnbr_fd+0xd6>
cmpl   $0x0,-0x4(%rbp)
jne    121d <ft_putnbr_fd+0xed>
mov    -0x8(%rbp),%esi
mov    $0x30,%edi
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
jle    1148 <ft_putnbr_fd+0x18>
cmp    $0xa,%ebp
jae    1164 <ft_putnbr_fd+0x34>
add    $0x30,%bpl
jmp    1188 <ft_putnbr_fd+0x58>
cmp    $0x80000000,%ebp
jne    1199 <ft_putnbr_fd+0x69>
lea    0xea9(%rip),%rdi
mov    %r14d,%esi
call   1040 <ft_putstr_fd@plt>
mov    $0x8ca6c00,%ebp
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,%bpl
mov    %ebp,%eax
movsbl %al,%edi
mov    %r14d,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <ft_putchar_fd@plt>
mov    $0x30,%al
test   %ebp,%ebp
jns    118a <ft_putnbr_fd+0x5a>
mov    $0x2d,%edi
mov    %r14d,%esi
call   1050 <ft_putchar_fd@plt>
neg    %ebp
cmp    $0xa,%ebp
jb     1142 <ft_putnbr_fd+0x12>
jmp    1164 <ft_putnbr_fd+0x34>

LLVM IR (-O0):
@.str = [3 x i8] c"-2\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 sgt i32 %5, 0
br i1 %6, label %7, label %28
7: ; preds = %2
%8 = load i32, i32* %3
%9 = sdiv i32 %8, 10
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %21
11: ; preds = %7
%12 = load i32, i32* %3
%13 = sdiv i32 %12, 10
%14 = load i32, i32* %4
%15 = load i32, i32* %3
%16 = srem i32 %15, 10
%17 = add nsw i32 %16, 48
%18 = trunc i32 %17 to i8
%19 = load i32, i32* %4
%20 = call i32 @ft_putchar_fd(i8 signext %18, i32 %19)
br label %27
21: ; preds = %7
%22 = load i32, i32* %3
%23 = add nsw i32 %22, 48
%24 = trunc i32 %23 to i8
%25 = load i32, i32* %4
%26 = call i32 @ft_putchar_fd(i8 signext %24, i32 %25)
br label %27
27: ; preds = %21, %11
br label %47
28: ; preds = %2
%29 = load i32, i32* %3
%30 = sext i32 %29 to i64
%31 = icmp eq i64 %30, -2147483648
br i1 %31, label %32, label %36
32: ; preds = %28
%33 = load i32, i32* %4
%34 = call i32 @ft_putstr_fd(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %33)
%35 = load i32, i32* %4
br label %46
36: ; preds = %28
%37 = load i32, i32* %3
%38 = icmp slt i32 %37, 0
br i1 %38, label %39, label %45
39: ; preds = %36
%40 = load i32, i32* %4
%41 = call i32 @ft_putchar_fd(i8 signext 45, i32 %40)
%42 = load i32, i32* %3
%43 = sub nsw i32 0, %42
%44 = load i32, i32* %4
br label %45
45: ; preds = %39, %36
br label %46
46: ; preds = %45, %32
br label %47
47: ; preds = %46, %27
%48 = load i32, i32* %3
%49 = icmp eq i32 %48, 0
br i1 %49, label %50, label %53
50: ; preds = %47
%51 = load i32, i32* %4
%52 = call i32 @ft_putchar_fd(i8 signext 48, i32 %51)
br label %53
53: ; preds = %50, %47
ret void
}

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