#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*/ write(int, ...);
void ft_putnbr_fd(int n, int fd) {
  if (n <= -2147483648) {
    write(fd, "-2", 2);
    n = 147483648;
  }
  if (n < 0) {
    write(fd, "-", 1);
    n = -n;
  }
  if (n >= 10) {
    ft_putnbr_fd(n / 10, fd);
    ft_putnbr_fd(n % 10, fd);
  } else {
    n += 48;
    write(fd, &n, 1);
  }
}


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
jg     115b <ft_putnbr_fd+0x3b>
mov    -0x8(%rbp),%edi
lea    0xeb8(%rip),%rsi
mov    $0x2,%edx
mov    $0x0,%al
call   1040 <write@plt>
movl   $0x8ca6c00,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    1183 <ft_putnbr_fd+0x63>
mov    -0x8(%rbp),%edi
lea    0xe94(%rip),%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   1040 <write@plt>
xor    %eax,%eax
sub    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
cmpl   $0xa,-0x4(%rbp)
jl     11bc <ft_putnbr_fd+0x9c>
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    11d8 <ft_putnbr_fd+0xb8>
mov    -0x4(%rbp),%eax
add    $0x30,%eax
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x4(%rbp),%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   1040 <write@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_putnbr_fd>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r12d
mov    %edi,%ebp
lea    0xec9(%rip),%r14
mov    $0xcccccccd,%r13d
lea    0xebf(%rip),%r15
jmp    1174 <ft_putnbr_fd+0x54>
cs nopw 0x0(%rax,%rax,1)
test   %ebp,%ebp
js     1195 <ft_putnbr_fd+0x75>
cmp    $0xa,%ebp
jb     11ae <ft_putnbr_fd+0x8e>
mov    %ebp,%ebx
imul   %r13,%rbx
shr    $0x23,%rbx
mov    %ebx,%edi
mov    %r12d,%esi
call   1030 <ft_putnbr_fd@plt>
add    %ebx,%ebx
lea    (%rbx,%rbx,4),%eax
sub    %eax,%ebp
cmp    $0x80000000,%ebp
jne    1150 <ft_putnbr_fd+0x30>
mov    %r12d,%edi
mov    %r14,%rsi
mov    $0x2,%edx
xor    %eax,%eax
call   1040 <write@plt>
mov    $0x8ca6c00,%ebp
jmp    1159 <ft_putnbr_fd+0x39>
mov    %r12d,%edi
mov    %r15,%rsi
mov    $0x1,%edx
xor    %eax,%eax
call   1040 <write@plt>
neg    %ebp
cmp    $0xa,%ebp
jae    1159 <ft_putnbr_fd+0x39>
add    $0x30,%ebp
mov    %ebp,0x4(%rsp)
lea    0x4(%rsp),%rsi
mov    %r12d,%edi
mov    $0x1,%edx
xor    %eax,%eax
call   1040 <write@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"-2\00"
@.str.1 = [2 x i8] c"-\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 sle i64 %6, -2147483648
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = load i32, i32* %4
%10 = call i32 (i32, ...) @write(i32 %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
store i32 147483648, i32* %3
br label %11
11: ; preds = %8, %2
%12 = load i32, i32* %3
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %11
%15 = load i32, i32* %4
%16 = call i32 (i32, ...) @write(i32 %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%17 = load i32, i32* %3
%18 = sub nsw i32 0, %17
store i32 %18, i32* %3
br label %19
19: ; preds = %14, %11
%20 = load i32, i32* %3
%21 = icmp sge i32 %20, 10
br i1 %21, label %22, label %29
22: ; preds = %19
%23 = load i32, i32* %3
%24 = sdiv i32 %23, 10
%25 = load i32, i32* %4
%26 = load i32, i32* %3
%27 = srem i32 %26, 10
%28 = load i32, i32* %4
br label %34
29: ; preds = %19
%30 = load i32, i32* %3
%31 = add nsw i32 %30, 48
store i32 %31, i32* %3
%32 = load i32, i32* %4
%33 = call i32 (i32, ...) @write(i32 %32, i32* %3, i32 1)
br label %34
34: ; preds = %29, %22
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"-2\00"
@.str.1 = [2 x i8] c"-\00"
define void @ft_putnbr_fd(i32 %0, i32 %1) {
%3 = alloca i32
br label %4
4: ; preds = %17, %2
%5 = phi i32 [ %0, %2 ], [ %20, %17 ]
%6 = icmp eq i32 %5, -2147483648
br i1 %6, label %7, label %9
7: ; preds = %4
%8 = tail call i32 (i32, ...) @write(i32 %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
br label %17
9: ; preds = %4
%10 = icmp slt i32 %5, 0
br i1 %10, label %11, label %14
11: ; preds = %9
%12 = tail call i32 (i32, ...) @write(i32 %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%13 = sub nsw i32 0, %5
br label %14
14: ; preds = %11, %9
%15 = phi i32 [ %13, %11 ], [ %5, %9 ]
%16 = icmp ugt i32 %15, 9
br i1 %16, label %17, label %21
17: ; preds = %7, %14
%18 = phi i32 [ 147483648, %7 ], [ %15, %14 ]
%19 = udiv i32 %18, 10
tail call void @ft_putnbr_fd(i32 %19, i32 %1)
%20 = urem i32 %18, 10
br label %4
21: ; preds = %14
%22 = add nuw nsw i32 %15, 48
store i32 %22, i32* %3
%23 = call i32 (i32, ...) @write(i32 %1, i32* %3, i32 1)
ret void
}