#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*/ write(int, char *, int);
void ft_putnbr(int n) {
  char c;
  if (n >= 0 && n <= 9) {
    c = n + '0';
    write(1, &c, 1);
  }
  if (n > 9 || n < 0) {
    ft_putnbr(n / 10);
    c = (n % 10) + '0';
    ft_putnbr(n % 10);
  }
}


x86 assembly (clang, -O0):
<ft_putnbr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jl     1158 <ft_putnbr+0x38>
cmpl   $0x9,-0x4(%rbp)
jg     1158 <ft_putnbr+0x38>
mov    -0x4(%rbp),%eax
add    $0x30,%eax
mov    %al,-0x5(%rbp)
mov    $0x1,%edx
lea    -0x5(%rbp),%rsi
mov    %edx,%edi
call   1030 <write@plt>
cmpl   $0x9,-0x4(%rbp)
jg     116c <ft_putnbr+0x4c>
cmpl   $0x0,-0x4(%rbp)
jge    11a3 <ft_putnbr+0x83>
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
add    $0x30,%edx
mov    %dl,%al
mov    %al,-0x5(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
call   1040 <ft_putnbr@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_putnbr>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
cmp    $0x9,%edi
ja     114e <ft_putnbr+0x2e>
add    $0x30,%bpl
mov    %bpl,0x7(%rsp)
lea    0x7(%rsp),%rsi
mov    $0x1,%edi
mov    $0x1,%edx
call   1030 <write@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
movslq %ebp,%rax
imul   $0x66666667,%rax,%rbx
mov    %rbx,%rax
shr    $0x3f,%rax
sar    $0x22,%rbx
add    %eax,%ebx
mov    %ebx,%edi
call   1040 <ft_putnbr@plt>
add    %ebx,%ebx
lea    (%rbx,%rbx,4),%eax
sub    %eax,%ebp
mov    %ebp,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <ft_putnbr@plt>

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

LLVM IR (-O2):
define void @ft_putnbr(i32 %0) {
%2 = alloca i8
%3 = icmp ult i32 %0, 10
br i1 %3, label %4, label %8
4: ; preds = %1
%5 = trunc i32 %0 to i8
%6 = add nuw nsw i8 %5, 48
store i8 %6, i8* %2
%7 = call i32 @write(i32 1, i8* %2, i32 1)
br label %11
8: ; preds = %1
%9 = sdiv i32 %0, 10
tail call void @ft_putnbr(i32 %9)
%10 = srem i32 %0, 10
tail call void @ft_putnbr(i32 %10)
br label %11
11: ; preds = %4, %8
ret void
}