#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, ...);
int ft_putnbr(int nbr) {
  if (nbr < 0) {
    write(1, "-", 1);
    nbr = nbr * -1;
  }
  if (nbr >= 10) {
    return nbr = ft_putnbr(nbr / 10) - ft_putnbr(nbr % 10);
  }
  nbr += 48;
  write(1, &nbr, 1);
  return (0);
}


x86 assembly (clang, -O0):
<ft_putnbr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    1151 <ft_putnbr+0x31>
mov    $0x1,%edx
lea    0xebf(%rip),%rsi
mov    %edx,%edi
mov    $0x0,%al
call   1030 <write@plt>
imul   $0xffffffff,-0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jl     1194 <ft_putnbr+0x74>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1040 <ft_putnbr@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
call   1040 <ft_putnbr@plt>
mov    %eax,%ecx
mov    -0xc(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    %eax,-0x4(%rbp)
jmp    11b6 <ft_putnbr+0x96>
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>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
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     115c <ft_putnbr+0x3c>
cmp    $0x9,%ebp
jbe    117b <ft_putnbr+0x5b>
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
call   1040 <ft_putnbr@plt>
movl   $0x0,0x4(%rsp)
jmp    1198 <ft_putnbr+0x78>
lea    0xe9d(%rip),%rsi
mov    $0x1,%edi
mov    $0x1,%edx
xor    %eax,%eax
call   1030 <write@plt>
neg    %ebp
cmp    $0x9,%ebp
ja     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>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

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