#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 */
unsigned int ft_pop_sign(int, int *);
int /*<<< orphan*/ ft_putchar_fd(unsigned int, int);
void ft_putnbr_fd(int n, int fd) {
  int sign;
  unsigned int num;
  num = ft_pop_sign(n, &sign);
  if (sign)
    ft_putchar_fd('-', fd);
  if (num >= 10)
    ft_putnbr_fd(num / 10, fd);
  ft_putchar_fd((num % 10) + '0', fd);
}


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),%edi
lea    -0xc(%rbp),%rsi
call   1040 <ft_pop_sign@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1164 <ft_putnbr_fd+0x34>
mov    -0x8(%rbp),%esi
mov    $0x2d,%edi
call   1050 <ft_putchar_fd@plt>
cmpl   $0xa,-0x10(%rbp)
jb     1184 <ft_putnbr_fd+0x54>
mov    -0x10(%rbp),%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,%edi
mov    -0x8(%rbp),%esi
call   1030 <ft_putnbr_fd@plt>
mov    -0x10(%rbp),%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
mov    %edx,%edi
add    $0x30,%edi
mov    -0x8(%rbp),%esi
call   1050 <ft_putchar_fd@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
lea    0xc(%rsp),%rsi
call   1040 <ft_pop_sign@plt>
mov    %eax,%ebp
cmpl   $0x0,0xc(%rsp)
je     115b <ft_putnbr_fd+0x2b>
mov    $0x2d,%edi
mov    %r14d,%esi
call   1050 <ft_putchar_fd@plt>
mov    %ebp,%ebx
cmp    $0xa,%ebp
jb     1177 <ft_putnbr_fd+0x47>
mov    $0xcccccccd,%edi
imul   %rbx,%rdi
shr    $0x23,%rdi
mov    %r14d,%esi
call   1030 <ft_putnbr_fd@plt>
mov    $0xcccccccd,%eax
imul   %rbx,%rax
shr    $0x23,%rax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%ebp
or     $0x30,%ebp
mov    %ebp,%edi
mov    %r14d,%esi
call   1050 <ft_putchar_fd@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @ft_putnbr_fd(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load i32, i32* %3
%8 = call i32 @ft_pop_sign(i32 %7, i32* %5)
store i32 %8, i32* %6
%9 = load i32, i32* %5
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = load i32, i32* %4
%13 = call i32 @ft_putchar_fd(i32 45, i32 %12)
br label %14
14: ; preds = %11, %2
%15 = load i32, i32* %6
%16 = icmp uge i32 %15, 10
br i1 %16, label %17, label %21
17: ; preds = %14
%18 = load i32, i32* %6
%19 = udiv i32 %18, 10
%20 = load i32, i32* %4
br label %21
21: ; preds = %17, %14
%22 = load i32, i32* %6
%23 = urem i32 %22, 10
%24 = add i32 %23, 48
%25 = load i32, i32* %4
%26 = call i32 @ft_putchar_fd(i32 %24, i32 %25)
ret void
}

LLVM IR (-O2):
define void @ft_putnbr_fd(i32 %0, i32 %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = call i32 @ft_pop_sign(i32 %0, i32* %3)
%6 = load i32, i32* %3
%7 = icmp eq i32 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %2
%9 = call i32 @ft_putchar_fd(i32 45, i32 %1)
br label %10
10: ; preds = %8, %2
%11 = icmp ugt i32 %5, 9
br i1 %11, label %12, label %14
12: ; preds = %10
%13 = udiv i32 %5, 10
br label %14
14: ; preds = %12, %10
%15 = urem i32 %5, 10
%16 = or i32 %15, 48
%17 = call i32 @ft_putchar_fd(i32 %16, i32 %1)
ret void
}