#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(unsigned int, int);
void ft_putnbr_fd(int n, int fd) {
  unsigned int max;
  int sign;
  sign = -1;
  max = n;
  if (n < 0) {
    ft_putchar_fd('-', fd);
    max = sign * n;
  }
  if (max >= 10) {
    ft_putnbr_fd(max / 10, fd);
    ft_putnbr_fd(max % 10, fd);
  } else
    ft_putchar_fd(max + '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)
movl   $0xffffffff,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    115c <ft_putnbr_fd+0x3c>
mov    -0x8(%rbp),%esi
mov    $0x2d,%edi
call   1040 <ft_putchar_fd@plt>
mov    -0x10(%rbp),%eax
imul   -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jb     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    11a5 <ft_putnbr_fd+0x85>
mov    -0xc(%rbp),%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   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %edi,%ebp
mov    $0xcccccccd,%r15d
test   %ebp,%ebp
jns    114f <ft_putnbr_fd+0x2f>
cs nopw 0x0(%rax,%rax,1)
mov    $0x2d,%edi
mov    %r14d,%esi
call   1040 <ft_putchar_fd@plt>
neg    %ebp
cmp    $0xa,%ebp
jb     1175 <ft_putnbr_fd+0x55>
mov    %ebp,%ebx
imul   %r15,%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
test   %ebp,%ebp
jns    114f <ft_putnbr_fd+0x2f>
jmp    1140 <ft_putnbr_fd+0x20>
add    $0x30,%ebp
mov    %ebp,%edi
mov    %r14d,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <ft_putchar_fd@plt>

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
store i32 -1, i32* %6
%7 = load i32, i32* %3
store i32 %7, i32* %5
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %16
10: ; preds = %2
%11 = load i32, i32* %4
%12 = call i32 @ft_putchar_fd(i32 45, i32 %11)
%13 = load i32, i32* %6
%14 = load i32, i32* %3
%15 = mul nsw i32 %13, %14
store i32 %15, i32* %5
br label %16
16: ; preds = %10, %2
%17 = load i32, i32* %5
%18 = icmp uge i32 %17, 10
br i1 %18, label %19, label %26
19: ; preds = %16
%20 = load i32, i32* %5
%21 = udiv i32 %20, 10
%22 = load i32, i32* %4
%23 = load i32, i32* %5
%24 = urem i32 %23, 10
%25 = load i32, i32* %4
br label %31
26: ; preds = %16
%27 = load i32, i32* %5
%28 = add i32 %27, 48
%29 = load i32, i32* %4
%30 = call i32 @ft_putchar_fd(i32 %28, i32 %29)
br label %31
31: ; preds = %26, %19
ret void
}

LLVM IR (-O2):
define void @ft_putnbr_fd(i32 %0, i32 %1) {
br label %3
3: ; preds = %12, %2
%4 = phi i32 [ %0, %2 ], [ %14, %12 ]
%5 = icmp slt i32 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %3
%7 = tail call i32 @ft_putchar_fd(i32 45, i32 %1)
%8 = sub nsw i32 0, %4
br label %9
9: ; preds = %6, %3
%10 = phi i32 [ %8, %6 ], [ %4, %3 ]
%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
br label %3
15: ; preds = %9
%16 = add nuw nsw i32 %10, 48
%17 = tail call i32 @ft_putchar_fd(i32 %16, i32 %1)
ret void
}