#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);
void ft_putnbr_fd(int i, int fd) {
  if (i == -2147483648) {
    ft_putchar_fd('-', fd);
    ft_putchar_fd('2', fd);
    ft_putchar_fd('1', fd);
    ft_putchar_fd('4', fd);
    ft_putchar_fd('7', fd);
    ft_putchar_fd('4', fd);
    ft_putchar_fd('8', fd);
    ft_putchar_fd('3', fd);
    ft_putchar_fd('6', fd);
    ft_putchar_fd('4', fd);
    ft_putchar_fd('8', fd);
    return;
  }
  if (i < 0) {
    i = -i;
    ft_putchar_fd('-', fd);
  }
  if (i >= 10)
    ft_putnbr_fd(i / 10, fd);
  ft_putchar_fd(i % 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)
movslq -0x4(%rbp),%rax
cmp    $0xffffffff80000000,%rax
jne    11d2 <ft_putnbr_fd+0xb2>
mov    -0x8(%rbp),%esi
mov    $0x2d,%edi
call   1040 <ft_putchar_fd@plt>
mov    -0x8(%rbp),%esi
mov    $0x32,%edi
call   1040 <ft_putchar_fd@plt>
mov    -0x8(%rbp),%esi
mov    $0x31,%edi
call   1040 <ft_putchar_fd@plt>
mov    -0x8(%rbp),%esi
mov    $0x34,%edi
call   1040 <ft_putchar_fd@plt>
mov    -0x8(%rbp),%esi
mov    $0x37,%edi
call   1040 <ft_putchar_fd@plt>
mov    -0x8(%rbp),%esi
mov    $0x34,%edi
call   1040 <ft_putchar_fd@plt>
mov    -0x8(%rbp),%esi
mov    $0x38,%edi
call   1040 <ft_putchar_fd@plt>
mov    -0x8(%rbp),%esi
mov    $0x33,%edi
call   1040 <ft_putchar_fd@plt>
mov    -0x8(%rbp),%esi
mov    $0x36,%edi
call   1040 <ft_putchar_fd@plt>
mov    -0x8(%rbp),%esi
mov    $0x34,%edi
call   1040 <ft_putchar_fd@plt>
mov    -0x8(%rbp),%esi
mov    $0x38,%edi
call   1040 <ft_putchar_fd@plt>
jmp    1228 <ft_putnbr_fd+0x108>
cmpl   $0x0,-0x4(%rbp)
jge    11f1 <ft_putnbr_fd+0xd1>
xor    %eax,%eax
sub    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%esi
mov    $0x2d,%edi
call   1040 <ft_putchar_fd@plt>
cmpl   $0xa,-0x4(%rbp)
jl     1210 <ft_putnbr_fd+0xf0>
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   1040 <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,%ebx
cmp    $0x80000000,%edi
jne    11ad <ft_putnbr_fd+0x8d>
mov    $0x2d,%edi
mov    %ebx,%esi
call   1040 <ft_putchar_fd@plt>
mov    $0x32,%edi
mov    %ebx,%esi
call   1040 <ft_putchar_fd@plt>
mov    $0x31,%edi
mov    %ebx,%esi
call   1040 <ft_putchar_fd@plt>
mov    $0x34,%edi
mov    %ebx,%esi
call   1040 <ft_putchar_fd@plt>
mov    $0x37,%edi
mov    %ebx,%esi
call   1040 <ft_putchar_fd@plt>
mov    $0x34,%edi
mov    %ebx,%esi
call   1040 <ft_putchar_fd@plt>
mov    $0x38,%ebp
mov    $0x38,%edi
mov    %ebx,%esi
call   1040 <ft_putchar_fd@plt>
mov    $0x33,%edi
mov    %ebx,%esi
call   1040 <ft_putchar_fd@plt>
mov    $0x36,%edi
mov    %ebx,%esi
call   1040 <ft_putchar_fd@plt>
mov    $0x34,%edi
mov    %ebx,%esi
call   1040 <ft_putchar_fd@plt>
jmp    11f4 <ft_putnbr_fd+0xd4>
mov    %edi,%ebp
test   %edi,%edi
jns    11c1 <ft_putnbr_fd+0xa1>
neg    %ebp
mov    $0x2d,%edi
mov    %ebx,%esi
call   1040 <ft_putchar_fd@plt>
mov    %ebp,%r14d
cmp    $0xa,%ebp
jb     11dd <ft_putnbr_fd+0xbd>
mov    $0xcccccccd,%edi
imul   %r14,%rdi
shr    $0x23,%rdi
mov    %ebx,%esi
call   1030 <ft_putnbr_fd@plt>
mov    $0xcccccccd,%eax
imul   %r14,%rax
shr    $0x23,%rax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%ebp
or     $0x30,%ebp
mov    %ebp,%edi
mov    %ebx,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <ft_putchar_fd@plt>

LLVM IR (-O0):
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 %31
8: ; preds = %2
%9 = load i32, i32* %4
%10 = call i32 @ft_putchar_fd(i32 45, i32 %9)
%11 = load i32, i32* %4
%12 = call i32 @ft_putchar_fd(i32 50, i32 %11)
%13 = load i32, i32* %4
%14 = call i32 @ft_putchar_fd(i32 49, i32 %13)
%15 = load i32, i32* %4
%16 = call i32 @ft_putchar_fd(i32 52, i32 %15)
%17 = load i32, i32* %4
%18 = call i32 @ft_putchar_fd(i32 55, i32 %17)
%19 = load i32, i32* %4
%20 = call i32 @ft_putchar_fd(i32 52, i32 %19)
%21 = load i32, i32* %4
%22 = call i32 @ft_putchar_fd(i32 56, i32 %21)
%23 = load i32, i32* %4
%24 = call i32 @ft_putchar_fd(i32 51, i32 %23)
%25 = load i32, i32* %4
%26 = call i32 @ft_putchar_fd(i32 54, i32 %25)
%27 = load i32, i32* %4
%28 = call i32 @ft_putchar_fd(i32 52, i32 %27)
%29 = load i32, i32* %4
%30 = call i32 @ft_putchar_fd(i32 56, i32 %29)
br label %52
31: ; preds = %2
%32 = load i32, i32* %3
%33 = icmp slt i32 %32, 0
br i1 %33, label %34, label %39
34: ; preds = %31
%35 = load i32, i32* %3
%36 = sub nsw i32 0, %35
store i32 %36, i32* %3
%37 = load i32, i32* %4
%38 = call i32 @ft_putchar_fd(i32 45, i32 %37)
br label %39
39: ; preds = %34, %31
%40 = load i32, i32* %3
%41 = icmp sge i32 %40, 10
br i1 %41, label %42, label %46
42: ; preds = %39
%43 = load i32, i32* %3
%44 = sdiv i32 %43, 10
%45 = load i32, i32* %4
br label %46
46: ; preds = %42, %39
%47 = load i32, i32* %3
%48 = srem i32 %47, 10
%49 = add nsw i32 %48, 48
%50 = load i32, i32* %4
%51 = call i32 @ft_putchar_fd(i32 %49, i32 %50)
br label %52
52: ; preds = %46, %8
ret void
}

LLVM IR (-O2):
define void @ft_putnbr_fd(i32 %0, i32 %1) {
%3 = icmp eq i32 %0, -2147483648
br i1 %3, label %4, label %15
4: ; preds = %2
%5 = tail call i32 @ft_putchar_fd(i32 45, i32 %1)
%6 = tail call i32 @ft_putchar_fd(i32 50, i32 %1)
%7 = tail call i32 @ft_putchar_fd(i32 49, i32 %1)
%8 = tail call i32 @ft_putchar_fd(i32 52, i32 %1)
%9 = tail call i32 @ft_putchar_fd(i32 55, i32 %1)
%10 = tail call i32 @ft_putchar_fd(i32 52, i32 %1)
%11 = tail call i32 @ft_putchar_fd(i32 56, i32 %1)
%12 = tail call i32 @ft_putchar_fd(i32 51, i32 %1)
%13 = tail call i32 @ft_putchar_fd(i32 54, i32 %1)
%14 = tail call i32 @ft_putchar_fd(i32 52, i32 %1)
br label %28
15: ; preds = %2
%16 = icmp slt i32 %0, 0
br i1 %16, label %17, label %20
17: ; preds = %15
%18 = sub nsw i32 0, %0
%19 = tail call i32 @ft_putchar_fd(i32 45, i32 %1)
br label %20
20: ; preds = %17, %15
%21 = phi i32 [ %18, %17 ], [ %0, %15 ]
%22 = icmp ugt i32 %21, 9
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = udiv i32 %21, 10
tail call void @ft_putnbr_fd(i32 %24, i32 %1)
br label %25
25: ; preds = %23, %20
%26 = urem i32 %21, 10
%27 = or i32 %26, 48
br label %28
28: ; preds = %25, %4
%29 = phi i32 [ %27, %25 ], [ 56, %4 ]
%30 = tail call i32 @ft_putchar_fd(i32 %29, i32 %1)
ret void
}