#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) {
  int div;
  div = 1;
  if (n < 0)
    ft_putchar_fd('-', fd);
  else
    n *= -1;
  while (n / div < -9)
    div *= 10;
  while (div >= 1) {
    ft_putchar_fd('0' - n / div % 10, fd);
    div /= 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)
cmpl   $0x0,-0x4(%rbp)
jge    1141 <ft_putnbr_fd+0x31>
mov    -0x8(%rbp),%esi
mov    $0x2d,%edi
call   1030 <ft_putchar_fd@plt>
jmp    1148 <ft_putnbr_fd+0x38>
imul   $0xffffffff,-0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    114d <ft_putnbr_fd+0x3d>
mov    -0x4(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0xfffffff7,%eax
jge    1169 <ft_putnbr_fd+0x59>
imul   $0xa,-0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    114d <ft_putnbr_fd+0x3d>
jmp    116e <ft_putnbr_fd+0x5e>
cmpl   $0x1,-0xc(%rbp)
jl     11a9 <ft_putnbr_fd+0x99>
mov    -0x4(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    $0x30,%edi
sub    %edx,%edi
mov    -0x8(%rbp),%esi
call   1030 <ft_putchar_fd@plt>
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
jmp    116e <ft_putnbr_fd+0x5e>
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
mov    %edi,%ebp
test   %edi,%edi
js     1124 <ft_putnbr_fd+0x14>
neg    %ebp
jmp    1131 <ft_putnbr_fd+0x21>
mov    $0x2d,%edi
mov    %r14d,%esi
call   1030 <ft_putchar_fd@plt>
mov    $0x1,%ebx
cmp    $0xfffffff6,%ebp
jg     114f <ft_putnbr_fd+0x3f>
mov    $0x1,%ebx
add    %ebx,%ebx
lea    (%rbx,%rbx,4),%ebx
mov    %ebp,%eax
cltd
idiv   %ebx
cmp    $0xfffffff7,%eax
jl     1140 <ft_putnbr_fd+0x30>
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),%edi
sub    %eax,%edi
add    $0x30,%edi
mov    %r14d,%esi
call   1030 <ft_putchar_fd@plt>
mov    %ebx,%eax
imul   %r15,%rax
shr    $0x23,%rax
cmp    $0x9,%ebx
mov    %eax,%ebx
ja     1160 <ft_putnbr_fd+0x50>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
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 = icmp slt i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = load i32, i32* %4
%10 = call i32 @ft_putchar_fd(i32 45, i32 %9)
br label %14
11: ; preds = %2
%12 = load i32, i32* %3
%13 = mul nsw i32 %12, -1
store i32 %13, i32* %3
br label %14
14: ; preds = %11, %8
br label %15
15: ; preds = %20, %14
%16 = load i32, i32* %3
%17 = load i32, i32* %5
%18 = sdiv i32 %16, %17
%19 = icmp slt i32 %18, -9
br i1 %19, label %20, label %23
20: ; preds = %15
%21 = load i32, i32* %5
%22 = mul nsw i32 %21, 10
store i32 %22, i32* %5
br label %15
23: ; preds = %15
br label %24
24: ; preds = %27, %23
%25 = load i32, i32* %5
%26 = icmp sge i32 %25, 1
br i1 %26, label %27, label %37
27: ; preds = %24
%28 = load i32, i32* %3
%29 = load i32, i32* %5
%30 = sdiv i32 %28, %29
%31 = srem i32 %30, 10
%32 = sub nsw i32 48, %31
%33 = load i32, i32* %4
%34 = call i32 @ft_putchar_fd(i32 %32, i32 %33)
%35 = load i32, i32* %5
%36 = sdiv i32 %35, 10
store i32 %36, i32* %5
br label %24
37: ; preds = %24
ret void
}

LLVM IR (-O2):
define void @ft_putnbr_fd(i32 %0, i32 %1) {
%3 = icmp slt i32 %0, 0
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @ft_putchar_fd(i32 45, i32 %1)
br label %8
6: ; preds = %2
%7 = sub nsw i32 0, %0
br label %8
8: ; preds = %6, %4
%9 = phi i32 [ %0, %4 ], [ %7, %6 ]
%10 = icmp slt i32 %9, -9
br i1 %10, label %11, label %16
11: ; preds = %8, %11
%12 = phi i32 [ %13, %11 ], [ 1, %8 ]
%13 = mul nuw nsw i32 %12, 10
%14 = sdiv i32 %9, %13
%15 = icmp slt i32 %14, -9
br i1 %15, label %11, label %16
16: ; preds = %11, %8
%17 = phi i32 [ 1, %8 ], [ %13, %11 ]
br label %18
18: ; preds = %16, %18
%19 = phi i32 [ %24, %18 ], [ %17, %16 ]
%20 = sdiv i32 %9, %19
%21 = srem i32 %20, 10
%22 = sub nsw i32 48, %21
%23 = tail call i32 @ft_putchar_fd(i32 %22, i32 %1)
%24 = udiv i32 %19, 10
%25 = icmp ult i32 %19, 10
br i1 %25, label %26, label %18
26: ; preds = %18
ret void
}