#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(long long);
void ft_putnbr(int n) {
  long long nbr;
  nbr = n;
  if (nbr < 0) {
    ft_putchar('-');
    nbr *= -1;
  }
  if (nbr > 9) {
    ft_putnbr(nbr / 10);
  }
  ft_putchar((nbr % 10) + '0');
}


x86 assembly (clang, -O0):
<ft_putnbr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movslq -0x4(%rbp),%rax
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jge    1151 <ft_putnbr+0x31>
mov    $0x2d,%edi
call   1030 <ft_putchar@plt>
imul   $0xffffffffffffffff,-0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
cmpq   $0x9,-0x10(%rbp)
jle    1171 <ft_putnbr+0x51>
mov    -0x10(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
mov    %eax,%edi
call   1040 <ft_putnbr@plt>
mov    -0x10(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
mov    %rdx,%rdi
add    $0x30,%rdi
call   1030 <ft_putchar@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_putnbr>:
push   %rbx
movslq %edi,%rbx
test   %ebx,%ebx
js     1178 <ft_putnbr+0x58>
cmp    $0xa,%rbx
jl     1142 <ft_putnbr+0x22>
mov    %ebx,%eax
mov    $0xcccccccd,%edi
imul   %rax,%rdi
shr    $0x23,%rdi
call   1040 <ft_putnbr@plt>
movabs $0x6666666666666667,%rcx
66 66 66
mov    %rbx,%rax
imul   %rcx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x2,%rdx
add    %rax,%rdx
add    %rdx,%rdx
lea    (%rdx,%rdx,4),%rax
neg    %rax
lea    (%rbx,%rax,1),%rdi
add    $0x30,%rdi
pop    %rbx
jmp    1030 <ft_putchar@plt>
mov    $0x2d,%edi
call   1030 <ft_putchar@plt>
neg    %rbx
cmp    $0xa,%rbx
jge    112e <ft_putnbr+0xe>
jmp    1142 <ft_putnbr+0x22>

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

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