#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) {
  int flag;
  flag = 0;
  if (n == -2147483648) {
    n /= 10;
    flag = 1;
  }
  if (n < 0) {
    ft_putchar_fd('-', fd);
    n *= -1;
  }
  if (n > 9)
    ft_putnbr_fd(n / 10, fd);
  ft_putchar_fd(n % 10 + 48, fd);
  if (flag)
    ft_putchar_fd(8 + 48, fd);
}


x86 assembly (clang, -O0):
<ft_putnbr_fd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movslq -0x4(%rbp),%rax
cmp    $0xffffffff80000000,%rax
jne    115a <ft_putnbr_fd+0x3a>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
movl   $0x1,-0xc(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    1178 <ft_putnbr_fd+0x58>
mov    -0x8(%rbp),%esi
mov    $0x2d,%edi
call   1040 <ft_putchar_fd@plt>
imul   $0xffffffff,-0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
cmpl   $0x9,-0x4(%rbp)
jle    1197 <ft_putnbr_fd+0x77>
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>
cmpl   $0x0,-0xc(%rbp)
je     11c6 <ft_putnbr_fd+0xa6>
mov    -0x8(%rbp),%esi
mov    $0x38,%edi
call   1040 <ft_putchar_fd@plt>
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,%r15d
cmp    $0x80000000,%edi
mov    $0xf3333334,%ebx
cmovne %edi,%ebx
test   %ebx,%ebx
jns    114e <ft_putnbr_fd+0x2e>
mov    $0x2d,%edi
mov    %r14d,%esi
call   1040 <ft_putchar_fd@plt>
neg    %ebx
mov    %ebx,%ebp
cmp    $0xa,%ebx
jb     116a <ft_putnbr_fd+0x4a>
mov    $0xcccccccd,%edi
imul   %rbp,%rdi
shr    $0x23,%rdi
mov    %r14d,%esi
call   1030 <ft_putnbr_fd@plt>
mov    $0xcccccccd,%eax
imul   %rbp,%rax
shr    $0x23,%rax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%ebx
or     $0x30,%ebx
mov    %ebx,%edi
mov    %r14d,%esi
call   1040 <ft_putchar_fd@plt>
cmp    $0x80000000,%r15d
jne    11ab <ft_putnbr_fd+0x8b>
mov    $0x38,%edi
mov    %r14d,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <ft_putchar_fd@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @ft_putnbr_fd(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32 0, i32* %5
%6 = load i32, i32* %3
%7 = sext i32 %6 to i64
%8 = icmp eq i64 %7, -2147483648
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i32, i32* %3
%11 = sdiv i32 %10, 10
store i32 %11, i32* %3
store i32 1, i32* %5
br label %12
12: ; preds = %9, %2
%13 = load i32, i32* %3
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %12
%16 = load i32, i32* %4
%17 = call i32 @ft_putchar_fd(i32 45, i32 %16)
%18 = load i32, i32* %3
%19 = mul nsw i32 %18, -1
store i32 %19, i32* %3
br label %20
20: ; preds = %15, %12
%21 = load i32, i32* %3
%22 = icmp sgt i32 %21, 9
br i1 %22, label %23, label %27
23: ; preds = %20
%24 = load i32, i32* %3
%25 = sdiv i32 %24, 10
%26 = load i32, i32* %4
br label %27
27: ; preds = %23, %20
%28 = load i32, i32* %3
%29 = srem i32 %28, 10
%30 = add nsw i32 %29, 48
%31 = load i32, i32* %4
%32 = call i32 @ft_putchar_fd(i32 %30, i32 %31)
%33 = load i32, i32* %5
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %38
35: ; preds = %27
%36 = load i32, i32* %4
%37 = call i32 @ft_putchar_fd(i32 56, i32 %36)
br label %38
38: ; preds = %35, %27
ret void
}

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