#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 == -2147483648) {
    ft_putstr_fd("-2147483648", fd);
    return;
  }
  if (n < 0 && n > -2147483648) {
    ft_putchar_fd('-', fd);
    n = n * -1;
  }
  if (n < 10 && n >= 0) {
    ft_putchar_fd(n + '0', fd);
    return;
  }
  ft_putnbr_fd(n / 10, fd);
  ft_putchar_fd(n % 10 + '0', fd);
  return;
}


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    11e4 <ft_putnbr_fd+0xb4>
cmpl   $0x0,-0x4(%rbp)
jge    1190 <ft_putnbr_fd+0x60>
movslq -0x4(%rbp),%rax
cmp    $0xffffffff80000000,%rax
jle    1190 <ft_putnbr_fd+0x60>
mov    -0x8(%rbp),%esi
mov    $0x2d,%edi
call   1050 <ft_putchar_fd@plt>
imul   $0xffffffff,-0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
cmpl   $0xa,-0x4(%rbp)
jge    11b7 <ft_putnbr_fd+0x87>
cmpl   $0x0,-0x4(%rbp)
jl     11b7 <ft_putnbr_fd+0x87>
mov    -0x4(%rbp),%edi
add    $0x30,%edi
mov    -0x8(%rbp),%esi
call   1050 <ft_putchar_fd@plt>
jmp    11e4 <ft_putnbr_fd+0xb4>
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
cmp    $0x80000000,%edi
jne    1152 <ft_putnbr_fd+0x22>
lea    0xeba(%rip),%rdi
mov    %r14d,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <ft_putstr_fd@plt>
mov    %edi,%ebp
test   %edi,%edi
js     1162 <ft_putnbr_fd+0x32>
cmp    $0x9,%ebp
ja     1176 <ft_putnbr_fd+0x46>
add    $0x30,%ebp
jmp    1199 <ft_putnbr_fd+0x69>
mov    $0x2d,%edi
mov    %r14d,%esi
call   1050 <ft_putchar_fd@plt>
neg    %ebp
cmp    $0x9,%ebp
jbe    115d <ft_putnbr_fd+0x2d>
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
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 = 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 %43
11: ; preds = %2
%12 = load i32, i32* %3
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %23
14: ; preds = %11
%15 = load i32, i32* %3
%16 = sext i32 %15 to i64
%17 = icmp sgt i64 %16, -2147483648
br i1 %17, label %18, label %23
18: ; preds = %14
%19 = load i32, i32* %4
%20 = call i32 @ft_putchar_fd(i32 45, i32 %19)
%21 = load i32, i32* %3
%22 = mul nsw i32 %21, -1
store i32 %22, i32* %3
br label %23
23: ; preds = %18, %14, %11
%24 = load i32, i32* %3
%25 = icmp slt i32 %24, 10
br i1 %25, label %26, label %34
26: ; preds = %23
%27 = load i32, i32* %3
%28 = icmp sge i32 %27, 0
br i1 %28, label %29, label %34
29: ; preds = %26
%30 = load i32, i32* %3
%31 = add nsw i32 %30, 48
%32 = load i32, i32* %4
%33 = call i32 @ft_putchar_fd(i32 %31, i32 %32)
br label %43
34: ; preds = %26, %23
%35 = load i32, i32* %3
%36 = sdiv i32 %35, 10
%37 = load i32, i32* %4
%38 = load i32, i32* %3
%39 = srem i32 %38, 10
%40 = add nsw i32 %39, 48
%41 = load i32, i32* %4
%42 = call i32 @ft_putchar_fd(i32 %40, i32 %41)
br label %43
43: ; preds = %34, %29, %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 %17
6: ; preds = %2
%7 = icmp slt i32 %0, 0
br i1 %7, label %8, label %11
8: ; preds = %6
%9 = tail call i32 @ft_putchar_fd(i32 45, i32 %1)
%10 = sub nsw i32 0, %0
br label %11
11: ; preds = %8, %6
%12 = phi i32 [ %10, %8 ], [ %0, %6 ]
%13 = icmp ult i32 %12, 10
br i1 %13, label %14, label %18
14: ; preds = %11
%15 = add nuw nsw i32 %12, 48
%16 = tail call i32 @ft_putchar_fd(i32 %15, i32 %1)
br label %17
17: ; preds = %4, %14, %18
ret void
18: ; preds = %11
%19 = udiv i32 %12, 10
tail call void @ft_putnbr_fd(i32 %19, i32 %1)
%20 = urem i32 %12, 10
%21 = or i32 %20, 48
%22 = tail call i32 @ft_putchar_fd(i32 %21, i32 %1)
br label %17
}