#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 m;
  if (n < 0) {
    ft_putchar_fd('-', fd);
    if (n < -9) {
      m = n / 10;
      m = -m;
      ft_putnbr_fd(m, fd);
    }
    n = n % 10;
    ft_putchar_fd(-n + '0', fd);
    return;
  }
  if (n > 9)
    ft_putnbr_fd(n / 10, fd);
  ft_putchar_fd(n % 10 + '0', fd);
  return;
}


x86 assembly (clang, -O0):
<ft_putnbr_fd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    1193 <ft_putnbr_fd+0x73>
mov    -0x8(%rbp),%esi
mov    $0x2d,%edi
call   1040 <ft_putchar_fd@plt>
cmpl   $0xfffffff7,-0x4(%rbp)
jge    1170 <ft_putnbr_fd+0x50>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
xor    %eax,%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1030 <ft_putnbr_fd@plt>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x4(%rbp)
xor    %edi,%edi
sub    -0x4(%rbp),%edi
add    $0x30,%edi
mov    -0x8(%rbp),%esi
call   1040 <ft_putchar_fd@plt>
jmp    11ca <ft_putnbr_fd+0xaa>
cmpl   $0x9,-0x4(%rbp)
jle    11b2 <ft_putnbr_fd+0x92>
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
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,%ebx
mov    %edi,%ebp
test   %edi,%edi
js     116e <ft_putnbr_fd+0x4e>
cmp    $0xa,%ebp
jb     1146 <ft_putnbr_fd+0x26>
mov    %ebp,%eax
mov    $0xcccccccd,%edi
imul   %rax,%rdi
shr    $0x23,%rdi
mov    %ebx,%esi
call   1030 <ft_putnbr_fd@plt>
mov    %ebp,%eax
mov    $0xcccccccd,%ecx
imul   %rax,%rcx
shr    $0x23,%rcx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%eax
sub    %eax,%ebp
or     $0x30,%ebp
mov    %ebp,%edi
mov    %ebx,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <ft_putchar_fd@plt>
mov    $0x2d,%edi
mov    %ebx,%esi
call   1040 <ft_putchar_fd@plt>
mov    %ebp,%eax
neg    %eax
cmp    $0xfffffff7,%ebp
mov    %eax,%ebp
jb     1130 <ft_putnbr_fd+0x10>
jmp    1146 <ft_putnbr_fd+0x26>

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
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %28
8: ; preds = %2
%9 = load i32, i32* %4
%10 = call i32 @ft_putchar_fd(i32 45, i32 %9)
%11 = load i32, i32* %3
%12 = icmp slt i32 %11, -9
br i1 %12, label %13, label %20
13: ; preds = %8
%14 = load i32, i32* %3
%15 = sdiv i32 %14, 10
store i32 %15, i32* %5
%16 = load i32, i32* %5
%17 = sub nsw i32 0, %16
store i32 %17, i32* %5
%18 = load i32, i32* %5
%19 = load i32, i32* %4
br label %20
20: ; preds = %13, %8
%21 = load i32, i32* %3
%22 = srem i32 %21, 10
store i32 %22, i32* %3
%23 = load i32, i32* %3
%24 = sub nsw i32 0, %23
%25 = add nsw i32 %24, 48
%26 = load i32, i32* %4
%27 = call i32 @ft_putchar_fd(i32 %25, i32 %26)
br label %41
28: ; preds = %2
%29 = load i32, i32* %3
%30 = icmp sgt i32 %29, 9
br i1 %30, label %31, label %35
31: ; preds = %28
%32 = load i32, i32* %3
%33 = sdiv i32 %32, 10
%34 = load i32, i32* %4
br label %35
35: ; preds = %31, %28
%36 = load i32, i32* %3
%37 = srem i32 %36, 10
%38 = add nsw i32 %37, 48
%39 = load i32, i32* %4
%40 = call i32 @ft_putchar_fd(i32 %38, i32 %39)
br label %41
41: ; preds = %35, %20
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 %8
4: ; preds = %2
%5 = tail call i32 @ft_putchar_fd(i32 45, i32 %1)
%6 = icmp ult i32 %0, -9
%7 = sub i32 0, %0
br i1 %6, label %10, label %13
8: ; preds = %2
%9 = icmp ugt i32 %0, 9
br i1 %9, label %10, label %13
10: ; preds = %8, %4
%11 = phi i32 [ %7, %4 ], [ %0, %8 ]
%12 = udiv i32 %11, 10
tail call void @ft_putnbr_fd(i32 %12, i32 %1)
br label %13
13: ; preds = %10, %8, %4
%14 = phi i32 [ %7, %4 ], [ %0, %8 ], [ %11, %10 ]
%15 = urem i32 %14, 10
%16 = or i32 %15, 48
%17 = tail call i32 @ft_putchar_fd(i32 %16, i32 %1)
ret void
}