#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, "-2147483648", 11);
  else {
    if (n < 0) {
      write(fd, "-", 1);
      n = -n;
    }
    if (n < 10) {
      n = n + 48;
      write(fd, &n, 1);
    } else {
      ft_putnbr_fd(n / 10, fd);
      ft_putnbr_fd(n % 10, 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    1159 <ft_putnbr_fd+0x39>
mov    -0x8(%rbp),%edi
lea    0xeb8(%rip),%rsi
mov    $0xb,%edx
mov    $0x0,%al
call   1040 <write@plt>
jmp    11db <ft_putnbr_fd+0xbb>
cmpl   $0x0,-0x4(%rbp)
jge    1181 <ft_putnbr_fd+0x61>
mov    -0x8(%rbp),%edi
lea    0xe9f(%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)
jge    11ac <ft_putnbr_fd+0x8c>
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>
jmp    11d6 <ft_putnbr_fd+0xb6>
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    11db <ft_putnbr_fd+0xbb>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_putnbr_fd>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %esi,%r15d
cmp    $0x80000000,%edi
jne    1161 <ft_putnbr_fd+0x41>
movl   $0x80000000,0xc(%rsp)
80
lea    0xeba(%rip),%rsi
mov    %r15d,%edi
mov    $0xb,%edx
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <write@plt>
mov    %edi,%ebp
lea    0xea2(%rip),%r14
mov    $0xcccccccd,%r12d
test   %ebp,%ebp
jns    1194 <ft_putnbr_fd+0x74>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15d,%edi
mov    %r14,%rsi
mov    $0x1,%edx
xor    %eax,%eax
call   1040 <write@plt>
neg    %ebp
cmp    $0x9,%ebp
jbe    11ba <ft_putnbr_fd+0x9a>
mov    %ebp,%ebx
imul   %r12,%rbx
shr    $0x23,%rbx
mov    %ebx,%edi
mov    %r15d,%esi
call   1030 <ft_putnbr_fd@plt>
add    %ebx,%ebx
lea    (%rbx,%rbx,4),%eax
sub    %eax,%ebp
test   %ebp,%ebp
jns    1194 <ft_putnbr_fd+0x74>
jmp    1180 <ft_putnbr_fd+0x60>
add    $0x30,%ebp
mov    %ebp,0xc(%rsp)
lea    0xc(%rsp),%rsi
mov    %r15d,%edi
mov    $0x1,%edx
xor    %eax,%eax
call   1040 <write@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"-2147483648\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 eq 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 ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 11)
br label %35
11: ; preds = %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 slt i32 %20, 10
br i1 %21, label %22, label %27
22: ; preds = %19
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 48
store i32 %24, i32* %3
%25 = load i32, i32* %4
%26 = call i32 (i32, ...) @write(i32 %25, i32* %3, i32 1)
br label %34
27: ; preds = %19
%28 = load i32, i32* %3
%29 = sdiv i32 %28, 10
%30 = load i32, i32* %4
%31 = load i32, i32* %3
%32 = srem i32 %31, 10
%33 = load i32, i32* %4
br label %34
34: ; preds = %27, %22
br label %35
35: ; preds = %34, %8
ret void
}

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