#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) {
  if (n <= -2147483648) {
    write(1, "-2", 2);
    n = 147483648;
  }
  if (n < 0) {
    write(1, "-", 1);
    n = -n;
  }
  if (n >= 10) {
    ft_putnbr(n / 10);
    ft_putnbr(n % 10);
  } else {
    n += 48;
    write(1, &n, 1);
  }
}


x86 assembly (clang, -O0):
<ft_putnbr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movslq -0x4(%rbp),%rax
cmp    $0xffffffff80000000,%rax
jg     115a <ft_putnbr+0x3a>
mov    $0x1,%edi
lea    0xeb9(%rip),%rsi
mov    $0x2,%edx
mov    $0x0,%al
call   1030 <write@plt>
movl   $0x8ca6c00,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    1181 <ft_putnbr+0x61>
mov    $0x1,%edx
lea    0xe93(%rip),%rsi
mov    %edx,%edi
mov    $0x0,%al
call   1030 <write@plt>
xor    %eax,%eax
sub    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
cmpl   $0xa,-0x4(%rbp)
jl     11b4 <ft_putnbr+0x94>
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    11cf <ft_putnbr+0xaf>
mov    -0x4(%rbp),%eax
add    $0x30,%eax
mov    %eax,-0x4(%rbp)
mov    $0x1,%edx
lea    -0x4(%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   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebp
lea    0xecb(%rip),%r15
mov    $0xcccccccd,%r12d
lea    0xec1(%rip),%r14
jmp    1171 <ft_putnbr+0x51>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
test   %ebp,%ebp
js     1194 <ft_putnbr+0x74>
cmp    $0xa,%ebp
jb     11af <ft_putnbr+0x8f>
mov    %ebp,%ebx
imul   %r12,%rbx
shr    $0x23,%rbx
mov    %ebx,%edi
call   1040 <ft_putnbr@plt>
add    %ebx,%ebx
lea    (%rbx,%rbx,4),%eax
sub    %eax,%ebp
cmp    $0x80000000,%ebp
jne    1150 <ft_putnbr+0x30>
mov    $0x1,%edi
mov    %r15,%rsi
mov    $0x2,%edx
xor    %eax,%eax
call   1030 <write@plt>
mov    $0x8ca6c00,%ebp
jmp    1159 <ft_putnbr+0x39>
mov    $0x1,%edi
mov    %r14,%rsi
mov    $0x1,%edx
xor    %eax,%eax
call   1030 <write@plt>
neg    %ebp
cmp    $0xa,%ebp
jae    1159 <ft_putnbr+0x39>
add    $0x30,%ebp
mov    %ebp,0xc(%rsp)
lea    0xc(%rsp),%rsi
mov    $0x1,%edi
mov    $0x1,%edx
xor    %eax,%eax
call   1030 <write@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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