#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 n, int fd) {
  if (n < 0) {
    ft_putchar_fd('-', fd);
    if (n == -2147483648) {
      ft_putchar_fd('2', fd);
      ft_putnbr_fd(147483648, fd);
    } else
      ft_putnbr_fd(-n, fd);
  } else {
    if (n >= 10) {
      ft_putnbr_fd(n / 10, fd);
      ft_putnbr_fd(n % 10, fd);
    } else
      ft_putchar_fd(n + '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    1186 <ft_putnbr_fd+0x66>
mov    -0x8(%rbp),%esi
mov    $0x2d,%edi
call   1040 <ft_putchar_fd@plt>
movslq -0x4(%rbp),%rax
cmp    $0xffffffff80000000,%rax
jne    1174 <ft_putnbr_fd+0x54>
mov    -0x8(%rbp),%esi
mov    $0x32,%edi
call   1040 <ft_putchar_fd@plt>
mov    -0x8(%rbp),%esi
mov    $0x8ca6c00,%edi
call   1030 <ft_putnbr_fd@plt>
jmp    1181 <ft_putnbr_fd+0x61>
xor    %edi,%edi
sub    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1030 <ft_putnbr_fd@plt>
jmp    11d2 <ft_putnbr_fd+0xb2>
cmpl   $0xa,-0x4(%rbp)
jl     11bf <ft_putnbr_fd+0x9f>
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
mov    -0x8(%rbp),%esi
call   1030 <ft_putnbr_fd@plt>
jmp    11cd <ft_putnbr_fd+0xad>
mov    -0x4(%rbp),%edi
add    $0x30,%edi
mov    -0x8(%rbp),%esi
call   1040 <ft_putchar_fd@plt>
jmp    11d2 <ft_putnbr_fd+0xb2>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_putnbr_fd>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %edi,%ebp
mov    $0xcccccccd,%r15d
jmp    1150 <ft_putnbr_fd+0x30>
mov    $0x32,%edi
mov    %r14d,%esi
call   1040 <ft_putchar_fd@plt>
mov    $0x8ca6c00,%ebp
cs nopw 0x0(%rax,%rax,1)
test   %ebp,%ebp
js     1180 <ft_putnbr_fd+0x60>
cmp    $0xa,%ebp
jb     1199 <ft_putnbr_fd+0x79>
mov    %ebp,%ebx
imul   %r15,%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
jmp    1150 <ft_putnbr_fd+0x30>
cs nopw 0x0(%rax,%rax,1)
mov    $0x2d,%edi
mov    %r14d,%esi
call   1040 <ft_putchar_fd@plt>
cmp    $0x80000000,%ebp
je     1134 <ft_putnbr_fd+0x14>
neg    %ebp
jmp    1150 <ft_putnbr_fd+0x30>
add    $0x30,%ebp
mov    %ebp,%edi
mov    %r14d,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
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 = icmp slt i32 %5, 0
br i1 %6, label %7, label %22
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 %17
13: ; preds = %7
%14 = load i32, i32* %4
%15 = call i32 @ft_putchar_fd(i32 50, i32 %14)
%16 = load i32, i32* %4
br label %21
17: ; preds = %7
%18 = load i32, i32* %3
%19 = sub nsw i32 0, %18
%20 = load i32, i32* %4
br label %21
21: ; preds = %17, %13
br label %38
22: ; preds = %2
%23 = load i32, i32* %3
%24 = icmp sge i32 %23, 10
br i1 %24, label %25, label %32
25: ; preds = %22
%26 = load i32, i32* %3
%27 = sdiv i32 %26, 10
%28 = load i32, i32* %4
%29 = load i32, i32* %3
%30 = srem i32 %29, 10
%31 = load i32, i32* %4
br label %37
32: ; preds = %22
%33 = load i32, i32* %3
%34 = add nsw i32 %33, 48
%35 = load i32, i32* %4
%36 = call i32 @ft_putchar_fd(i32 %34, i32 %35)
br label %37
37: ; preds = %32, %25
br label %38
38: ; preds = %37, %21
ret void
}

LLVM IR (-O2):
define void @ft_putnbr_fd(i32 %0, i32 %1) {
br label %3
3: ; preds = %11, %2
%4 = phi i32 [ %0, %2 ], [ %12, %11 ]
%5 = icmp slt i32 %4, 0
br i1 %5, label %6, label %15
6: ; preds = %3
%7 = tail call i32 @ft_putchar_fd(i32 45, i32 %1)
%8 = icmp eq i32 %4, -2147483648
br i1 %8, label %9, label %13
9: ; preds = %6
%10 = tail call i32 @ft_putchar_fd(i32 50, i32 %1)
br label %11
11: ; preds = %9, %13, %17
%12 = phi i32 [ 147483648, %9 ], [ %14, %13 ], [ %19, %17 ]
br label %3
13: ; preds = %6
%14 = sub nsw i32 0, %4
br label %11
15: ; preds = %3
%16 = icmp ugt i32 %4, 9
br i1 %16, label %17, label %20
17: ; preds = %15
%18 = udiv i32 %4, 10
tail call void @ft_putnbr_fd(i32 %18, i32 %1)
%19 = urem i32 %4, 10
br label %11
20: ; preds = %15
%21 = add nuw nsw i32 %4, 48
%22 = tail call i32 @ft_putchar_fd(i32 %21, i32 %1)
ret void
}