#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) {
  long l;
  l = n;
  if (l < 0) {
    ft_putchar_fd('-', fd);
    l *= -1;
  }
  if (l > 9) {
    ft_putnbr_fd((int)(l / 10), fd);
  }
  ft_putchar_fd((int)(l % 10) + 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)
movslq -0x4(%rbp),%rax
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jge    1157 <ft_putnbr_fd+0x37>
mov    -0x8(%rbp),%esi
mov    $0x2d,%edi
call   1040 <ft_putchar_fd@plt>
imul   $0xffffffffffffffff,-0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
cmpq   $0x9,-0x10(%rbp)
jle    117a <ft_putnbr_fd+0x5a>
mov    -0x10(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
mov    %eax,%edi
mov    -0x8(%rbp),%esi
call   1030 <ft_putnbr_fd@plt>
mov    -0x10(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
mov    %edx,%edi
add    $0x30,%edi
mov    -0x8(%rbp),%esi
call   1040 <ft_putchar_fd@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_putnbr_fd>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
movslq %edi,%rbx
test   %ebx,%ebx
js     117e <ft_putnbr_fd+0x5e>
cmp    $0xa,%rbx
jl     1148 <ft_putnbr_fd+0x28>
mov    %ebx,%eax
mov    $0xcccccccd,%edi
imul   %rax,%rdi
shr    $0x23,%rdi
mov    %ebp,%esi
call   1030 <ft_putnbr_fd@plt>
movabs $0x6666666666666667,%rcx
66 66 66
mov    %rbx,%rax
imul   %rcx
mov    %rdx,%rax
shr    $0x3f,%rax
shr    $0x2,%rdx
add    %eax,%edx
add    %edx,%edx
lea    (%rdx,%rdx,4),%eax
sub    %eax,%ebx
add    $0x30,%ebx
mov    %ebx,%edi
mov    %ebp,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <ft_putchar_fd@plt>
mov    $0x2d,%edi
mov    %ebp,%esi
call   1040 <ft_putchar_fd@plt>
neg    %rbx
cmp    $0xa,%rbx
jge    1132 <ft_putnbr_fd+0x12>
jmp    1148 <ft_putnbr_fd+0x28>

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

LLVM IR (-O2):
define void @ft_putnbr_fd(i32 %0, i32 %1) {
%3 = sext i32 %0 to i64
%4 = icmp slt i32 %0, 0
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = tail call i32 @ft_putchar_fd(i32 45, i32 %1)
%7 = sub nsw i64 0, %3
br label %8
8: ; preds = %5, %2
%9 = phi i64 [ %7, %5 ], [ %3, %2 ]
%10 = icmp sgt i64 %9, 9
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = trunc i64 %9 to i32
%13 = udiv i32 %12, 10
tail call void @ft_putnbr_fd(i32 %13, i32 %1)
br label %14
14: ; preds = %11, %8
%15 = srem i64 %9, 10
%16 = trunc i64 %15 to i32
%17 = add nsw i32 %16, 48
%18 = tail call i32 @ft_putchar_fd(i32 %17, i32 %1)
ret void
}