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


x86 assembly (clang, -O0):
<ft_putnbr_fd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
movslq -0x4(%rbp),%rax
cmp    $0xffffffff80000000,%rax
jne    1159 <ft_putnbr_fd+0x39>
mov    -0x8(%rbp),%esi
lea    0xeb1(%rip),%rdi
call   1030 <ft_putstr_fd@plt>
jmp    11d6 <ft_putnbr_fd+0xb6>
cmpl   $0x0,-0x4(%rbp)
jge    1177 <ft_putnbr_fd+0x57>
mov    -0x8(%rbp),%esi
mov    $0x2d,%edi
call   1040 <ft_putchar_fd@plt>
imul   $0xffffffff,-0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    117c <ft_putnbr_fd+0x5c>
mov    -0x4(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0xa,%eax
jl     1198 <ft_putnbr_fd+0x78>
imul   $0xa,-0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    117c <ft_putnbr_fd+0x5c>
jmp    119d <ft_putnbr_fd+0x7d>
cmpl   $0x0,-0xc(%rbp)
jle    11d6 <ft_putnbr_fd+0xb6>
mov    -0x4(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
add    $0x30,%edi
mov    -0x8(%rbp),%esi
call   1040 <ft_putchar_fd@plt>
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
jmp    119d <ft_putnbr_fd+0x7d>
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
cmp    $0x80000000,%edi
jne    114b <ft_putnbr_fd+0x2b>
lea    0xec7(%rip),%rdi
mov    %r14d,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <ft_putstr_fd@plt>
mov    %edi,%ebp
test   %edi,%edi
jns    1160 <ft_putnbr_fd+0x40>
mov    $0x2d,%edi
mov    %r14d,%esi
call   1040 <ft_putchar_fd@plt>
neg    %ebp
mov    $0x1,%ebx
cmp    $0xa,%ebp
jb     117f <ft_putnbr_fd+0x5f>
mov    $0x1,%ebx
nop
add    %ebx,%ebx
lea    (%rbx,%rbx,4),%ebx
mov    %ebp,%eax
cltd
idiv   %ebx
cmp    $0x9,%eax
jg     1170 <ft_putnbr_fd+0x50>
mov    $0xcccccccd,%r15d
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebp,%eax
cltd
idiv   %ebx
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
neg    %ecx
lea    (%rax,%rcx,1),%edi
add    $0x30,%edi
mov    %r14d,%esi
call   1040 <ft_putchar_fd@plt>
mov    %ebx,%eax
imul   %r15,%rax
shr    $0x23,%rax
cmp    $0x9,%ebx
mov    %eax,%ebx
ja     1190 <ft_putnbr_fd+0x70>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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
%5 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32 1, 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* %4
%11 = call i32 @ft_putstr_fd(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %10)
br label %43
12: ; preds = %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
br label %21
21: ; preds = %26, %20
%22 = load i32, i32* %3
%23 = load i32, i32* %5
%24 = sdiv i32 %22, %23
%25 = icmp sge i32 %24, 10
br i1 %25, label %26, label %29
26: ; preds = %21
%27 = load i32, i32* %5
%28 = mul nsw i32 %27, 10
store i32 %28, i32* %5
br label %21
29: ; preds = %21
br label %30
30: ; preds = %33, %29
%31 = load i32, i32* %5
%32 = icmp sgt i32 %31, 0
br i1 %32, label %33, label %43
33: ; preds = %30
%34 = load i32, i32* %3
%35 = load i32, i32* %5
%36 = sdiv i32 %34, %35
%37 = srem i32 %36, 10
%38 = add nsw i32 %37, 48
%39 = load i32, i32* %4
%40 = call i32 @ft_putchar_fd(i32 %38, i32 %39)
%41 = load i32, i32* %5
%42 = sdiv i32 %41, 10
store i32 %42, i32* %5
br label %30
43: ; preds = %9, %30
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 %29
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 ugt i32 %12, 9
br i1 %13, label %14, label %19
14: ; preds = %11, %14
%15 = phi i32 [ %16, %14 ], [ 1, %11 ]
%16 = mul nuw nsw i32 %15, 10
%17 = sdiv i32 %12, %16
%18 = icmp sgt i32 %17, 9
br i1 %18, label %14, label %19
19: ; preds = %14, %11
%20 = phi i32 [ 1, %11 ], [ %16, %14 ]
br label %21
21: ; preds = %19, %21
%22 = phi i32 [ %27, %21 ], [ %20, %19 ]
%23 = sdiv i32 %12, %22
%24 = srem i32 %23, 10
%25 = add nsw i32 %24, 48
%26 = tail call i32 @ft_putchar_fd(i32 %25, i32 %1)
%27 = udiv i32 %22, 10
%28 = icmp ult i32 %22, 10
br i1 %28, label %29, label %21
29: ; preds = %21, %4
ret void
}