#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(char);
void ft_putnbr(int n) {
  char val;
  int add_minus;
  add_minus = -1;
  if (n < 0) {
    add_minus = 1;
    n *= -1;
    ft_putchar('-');
  }
  if (n >= 10) {
    ft_putnbr(n / 10);
    ft_putnbr(n % 10);
  } else {
    val = n + 48;
    ft_putchar(val);
  }
}


x86 assembly (clang, -O0):
<ft_putnbr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0xffffffff,-0xc(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    1154 <ft_putnbr+0x34>
movl   $0x1,-0xc(%rbp)
imul   $0xffffffff,-0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    $0x2d,%edi
call   1030 <ft_putchar@plt>
cmpl   $0xa,-0x4(%rbp)
jl     1187 <ft_putnbr+0x67>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1040 <ft_putnbr@plt>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
call   1040 <ft_putnbr@plt>
jmp    1199 <ft_putnbr+0x79>
mov    -0x4(%rbp),%eax
add    $0x30,%eax
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%edi
call   1030 <ft_putchar@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_putnbr>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebp
mov    $0xcccccccd,%r14d
test   %ebp,%ebp
jns    113c <ft_putnbr+0x1c>
neg    %ebp
mov    $0x2d,%edi
call   1030 <ft_putchar@plt>
cmp    $0xa,%ebp
jb     115f <ft_putnbr+0x3f>
mov    %ebp,%ebx
imul   %r14,%rbx
shr    $0x23,%rbx
mov    %ebx,%edi
call   1040 <ft_putnbr@plt>
add    %ebx,%ebx
lea    (%rbx,%rbx,4),%eax
sub    %eax,%ebp
test   %ebp,%ebp
jns    113c <ft_putnbr+0x1c>
jmp    1130 <ft_putnbr+0x10>
add    $0x30,%bpl
movsbl %bpl,%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <ft_putchar@plt>

LLVM IR (-O0):
define void @ft_putnbr(i32 %0) {
%2 = alloca i32
%3 = alloca i8
%4 = alloca i32
store i32 %0, i32* %2
store i32 -1, i32* %4
%5 = load i32, i32* %2
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %1
store i32 1, i32* %4
%8 = load i32, i32* %2
%9 = mul nsw i32 %8, -1
store i32 %9, i32* %2
%10 = call i32 @ft_putchar(i8 signext 45)
br label %11
11: ; preds = %7, %1
%12 = load i32, i32* %2
%13 = icmp sge i32 %12, 10
br i1 %13, label %14, label %19
14: ; preds = %11
%15 = load i32, i32* %2
%16 = sdiv i32 %15, 10
%17 = load i32, i32* %2
%18 = srem i32 %17, 10
br label %25
19: ; preds = %11
%20 = load i32, i32* %2
%21 = add nsw i32 %20, 48
%22 = trunc i32 %21 to i8
store i8 %22, i8* %3
%23 = load i8, i8* %3
%24 = call i32 @ft_putchar(i8 signext %23)
br label %25
25: ; preds = %19, %14
ret void
}

LLVM IR (-O2):
define void @ft_putnbr(i32 %0) {
br label %2
2: ; preds = %11, %1
%3 = phi i32 [ %0, %1 ], [ %13, %11 ]
%4 = icmp slt i32 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = sub nsw i32 0, %3
%7 = tail call i32 @ft_putchar(i8 signext 45)
br label %8
8: ; preds = %5, %2
%9 = phi i32 [ %6, %5 ], [ %3, %2 ]
%10 = icmp ugt i32 %9, 9
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = udiv i32 %9, 10
tail call void @ft_putnbr(i32 %12)
%13 = urem i32 %9, 10
br label %2
14: ; preds = %8
%15 = trunc i32 %9 to i8
%16 = add nuw nsw i8 %15, 48
%17 = tail call i32 @ft_putchar(i8 signext %16)
ret void
}