#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 x;
  if (n < 0) {
    ft_putchar_fd('-', fd);
    x = n * -1;
  } else
    x = n;
  if (x >= 10) {
    ft_putnbr_fd(x / 10, fd);
    ft_putnbr_fd(x % 10, fd);
  } else
    ft_putchar_fd(x + '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)
cmpl   $0x0,-0x4(%rbp)
jge    1151 <ft_putnbr_fd+0x31>
mov    -0x8(%rbp),%esi
mov    $0x2d,%edi
call   1040 <ft_putchar_fd@plt>
imul   $0xffffffff,-0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    1157 <ft_putnbr_fd+0x37>
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jb     1192 <ft_putnbr_fd+0x72>
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    11a0 <ft_putnbr_fd+0x80>
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
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 %13
8: ; preds = %2
%9 = load i32, i32* %4
%10 = call i32 @ft_putchar_fd(i32 45, i32 %9)
%11 = load i32, i32* %3
%12 = mul nsw i32 %11, -1
store i32 %12, i32* %5
br label %15
13: ; preds = %2
%14 = load i32, i32* %3
store i32 %14, i32* %5
br label %15
15: ; preds = %13, %8
%16 = load i32, i32* %5
%17 = icmp uge i32 %16, 10
br i1 %17, label %18, label %25
18: ; preds = %15
%19 = load i32, i32* %5
%20 = udiv i32 %19, 10
%21 = load i32, i32* %4
%22 = load i32, i32* %5
%23 = urem i32 %22, 10
%24 = load i32, i32* %4
br label %30
25: ; preds = %15
%26 = load i32, i32* %5
%27 = add i32 %26, 48
%28 = load i32, i32* %4
%29 = call i32 @ft_putchar_fd(i32 %27, i32 %28)
br label %30
30: ; preds = %25, %18
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 = %3, %6
%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
}