#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, ...);
void ft_putnbr(int n) {
  unsigned int nb;
  nb = (unsigned int)n;
  if (n < 0) {
    write(1, "-", 1);
    nb = -n;
  }
  if (nb > 9) {
    ft_putnbr(nb / 10);
    ft_putnbr(nb % 10);
  } else {
    nb = nb + '0';
    write(1, &nb, 1);
  }
}


x86 assembly (clang, -O0):
<ft_putnbr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    1158 <ft_putnbr+0x38>
mov    $0x1,%edx
lea    0xeb9(%rip),%rsi
mov    %edx,%edi
mov    $0x0,%al
call   1030 <write@plt>
xor    %eax,%eax
sub    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x9,-0x8(%rbp)
jbe    118d <ft_putnbr+0x6d>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,%edi
call   1040 <ft_putnbr@plt>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
mov    %edx,%edi
call   1040 <ft_putnbr@plt>
jmp    11a8 <ft_putnbr+0x88>
mov    -0x8(%rbp),%eax
add    $0x30,%eax
mov    %eax,-0x8(%rbp)
mov    $0x1,%edx
lea    -0x8(%rbp),%rsi
mov    %edx,%edi
mov    $0x0,%al
call   1030 <write@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_putnbr>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
test   %edi,%edi
js     1158 <ft_putnbr+0x38>
cmp    $0xa,%ebp
jb     1177 <ft_putnbr+0x57>
mov    %ebp,%eax
mov    $0xcccccccd,%ebx
imul   %rax,%rbx
shr    $0x23,%rbx
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>
lea    0xea1(%rip),%rsi
mov    $0x1,%edi
mov    $0x1,%edx
xor    %eax,%eax
call   1030 <write@plt>
neg    %ebp
cmp    $0xa,%ebp
jae    112e <ft_putnbr+0xe>
add    $0x30,%ebp
mov    %ebp,0x4(%rsp)
lea    0x4(%rsp),%rsi
mov    $0x1,%edi
mov    $0x1,%edx
xor    %eax,%eax
call   1030 <write@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"-\00"
define void @ft_putnbr(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
store i32 %4, i32* %3
%5 = load i32, i32* %2
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %1
%8 = call i32 (i32, ...) @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%9 = load i32, i32* %2
%10 = sub nsw i32 0, %9
store i32 %10, i32* %3
br label %11
11: ; preds = %7, %1
%12 = load i32, i32* %3
%13 = icmp ugt i32 %12, 9
br i1 %13, label %14, label %19
14: ; preds = %11
%15 = load i32, i32* %3
%16 = udiv i32 %15, 10
%17 = load i32, i32* %3
%18 = urem i32 %17, 10
br label %23
19: ; preds = %11
%20 = load i32, i32* %3
%21 = add i32 %20, 48
store i32 %21, i32* %3
%22 = call i32 (i32, ...) @write(i32 1, i32* %3, i32 1)
br label %23
23: ; preds = %19, %14
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"-\00"
define void @ft_putnbr(i32 %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = icmp slt i32 %0, 0
br i1 %4, label %5, label %8
5: ; preds = %1
%6 = tail call i32 (i32, ...) @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%7 = sub nsw i32 0, %0
br label %8
8: ; preds = %5, %1
%9 = phi i32 [ %7, %5 ], [ %0, %1 ]
%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
tail call void @ft_putnbr(i32 %13)
br label %17
14: ; preds = %8
%15 = add nuw nsw i32 %9, 48
store i32 %15, i32* %2
%16 = call i32 (i32, ...) @write(i32 1, i32* %2, i32 1)
br label %17
17: ; preds = %14, %11
ret void
}