#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) {
  unsigned int nb;
  nb = (unsigned int)n;
  if (n < 0) {
    write(fd, "-", 1);
    nb = -n;
  }
  if (nb > 9) {
    ft_putnbr_fd((nb / 10), fd);
    ft_putnbr_fd((nb % 10), fd);
  } else {
    nb = nb + '0';
    write(fd, &nb, 1);
  }
}


x86 assembly (clang, -O0):
<ft_putnbr_fd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    115c <ft_putnbr_fd+0x3c>
mov    -0x8(%rbp),%edi
lea    0xeb8(%rip),%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   1040 <write@plt>
xor    %eax,%eax
sub    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x9,-0xc(%rbp)
jbe    1197 <ft_putnbr_fd+0x77>
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,%edi
mov    -0x8(%rbp),%esi
call   1030 <ft_putnbr_fd@plt>
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
mov    %edx,%edi
mov    -0x8(%rbp),%esi
call   1030 <ft_putnbr_fd@plt>
jmp    11b3 <ft_putnbr_fd+0x93>
mov    -0xc(%rbp),%eax
add    $0x30,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%edi
lea    -0xc(%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   %r14
push   %rbx
sub    $0x10,%rsp
mov    %esi,%r14d
mov    %edi,%ebp
test   %edi,%edi
js     1168 <ft_putnbr_fd+0x48>
cmp    $0xa,%ebp
jb     1185 <ft_putnbr_fd+0x65>
mov    %ebp,%eax
mov    $0xcccccccd,%ebx
imul   %rax,%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
mov    %ebp,%edi
mov    %r14d,%esi
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <ft_putnbr_fd@plt>
lea    0xe91(%rip),%rsi
mov    %r14d,%edi
mov    $0x1,%edx
xor    %eax,%eax
call   1040 <write@plt>
neg    %ebp
cmp    $0xa,%ebp
jae    1136 <ft_putnbr_fd+0x16>
add    $0x30,%ebp
mov    %ebp,0xc(%rsp)
lea    0xc(%rsp),%rsi
mov    %r14d,%edi
mov    $0x1,%edx
xor    %eax,%eax
call   1040 <write@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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