#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(int);
void ft_putnbr(int nb) {
  int len;
  len = 1;
  if (nb == -2147483648) {
    ft_putnbr(-2);
    ft_putnbr(147483648);
    return;
  }
  if (nb < 0) {
    ft_putchar('-');
    ft_putnbr(-nb);
    return;
  }
  while (nb / len != 0)
    len *= 10;
  while (len > 1) {
    ft_putchar(nb / (len / 10) - (nb / len) * 10 + 48);
    len /= 10;
  }
}


x86 assembly (clang, -O0):
<ft_putnbr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
movslq -0x4(%rbp),%rax
cmp    $0xffffffff80000000,%rax
jne    115b <ft_putnbr+0x3b>
mov    $0xfffffffe,%edi
call   1040 <ft_putnbr@plt>
mov    $0x8ca6c00,%edi
call   1040 <ft_putnbr@plt>
jmp    11f0 <ft_putnbr+0xd0>
cmpl   $0x0,-0x4(%rbp)
jge    117e <ft_putnbr+0x5e>
mov    $0x2d,%edi
call   1030 <ft_putchar@plt>
xor    %edi,%edi
sub    -0x4(%rbp),%edi
call   1040 <ft_putnbr@plt>
jmp    11f0 <ft_putnbr+0xd0>
jmp    1183 <ft_putnbr+0x63>
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
cmp    $0x0,%eax
je     119f <ft_putnbr+0x7f>
imul   $0xa,-0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    1183 <ft_putnbr+0x63>
jmp    11a4 <ft_putnbr+0x84>
cmpl   $0x1,-0x8(%rbp)
jle    11f0 <ft_putnbr+0xd0>
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0xc(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,%edi
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
imul   $0xa,%eax,%eax
sub    %eax,%edi
add    $0x30,%edi
call   1030 <ft_putchar@plt>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
jmp    11a4 <ft_putnbr+0x84>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_putnbr>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0x80000000,%edi
je     1160 <ft_putnbr+0x40>
mov    %edi,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
test   %r15d,%r15d
jns    11bf <ft_putnbr+0x9f>
mov    $0x2d,%edi
call   1030 <ft_putchar@plt>
mov    %r15d,%eax
neg    %eax
cmp    $0x80000000,%r15d
mov    %eax,%r15d
jne    1140 <ft_putnbr+0x20>
mov    $0xfffffffe,%edi
call   1040 <ft_putnbr@plt>
mov    $0x3b9aca00,%ebp
mov    $0xcccccccd,%r14d
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebp,%ebx
imul   %r14,%rbx
shr    $0x23,%rbx
mov    $0x8ca6c00,%eax
xor    %edx,%edx
div    %ebx
mov    %eax,%edi
mov    $0x8ca6c00,%eax
xor    %edx,%edx
div    %ebp
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%edi
add    $0x30,%edi
call   1030 <ft_putchar@plt>
cmp    $0x13,%ebp
mov    %ebx,%ebp
ja     1180 <ft_putnbr+0x60>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
je     11b4 <ft_putnbr+0x94>
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
add    %ebx,%ebx
lea    (%rbx,%rbx,4),%ebx
mov    %r15d,%eax
cltd
idiv   %ebx
test   %eax,%eax
jne    11d0 <ft_putnbr+0xb0>
mov    $0xcccccccd,%r14d
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebx,%ebp
imul   %r14,%rbp
shr    $0x23,%rbp
mov    %r15d,%eax
cltd
idiv   %ebp
mov    %eax,%edi
mov    %r15d,%eax
cltd
idiv   %ebx
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%edi
add    $0x30,%edi
call   1030 <ft_putchar@plt>
cmp    $0x13,%ebx
mov    %ebp,%ebx
ja     11f0 <ft_putnbr+0xd0>
jmp    11b4 <ft_putnbr+0x94>

LLVM IR (-O0):
define void @ft_putnbr(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 1, i32* %3
%4 = load i32, i32* %2
%5 = sext i32 %4 to i64
%6 = icmp eq i64 %5, -2147483648
br i1 %6, label %7, label %8
7: ; preds = %1
br label %42
8: ; preds = %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 @ft_putchar(i32 45)
%13 = load i32, i32* %2
%14 = sub nsw i32 0, %13
br label %42
15: ; preds = %8
br label %16
16: ; preds = %21, %15
%17 = load i32, i32* %2
%18 = load i32, i32* %3
%19 = sdiv i32 %17, %18
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %16
%22 = load i32, i32* %3
%23 = mul nsw i32 %22, 10
store i32 %23, i32* %3
br label %16
24: ; preds = %16
br label %25
25: ; preds = %28, %24
%26 = load i32, i32* %3
%27 = icmp sgt i32 %26, 1
br i1 %27, label %28, label %42
28: ; preds = %25
%29 = load i32, i32* %2
%30 = load i32, i32* %3
%31 = sdiv i32 %30, 10
%32 = sdiv i32 %29, %31
%33 = load i32, i32* %2
%34 = load i32, i32* %3
%35 = sdiv i32 %33, %34
%36 = mul nsw i32 %35, 10
%37 = sub nsw i32 %32, %36
%38 = add nsw i32 %37, 48
%39 = call i32 @ft_putchar(i32 %38)
%40 = load i32, i32* %3
%41 = sdiv i32 %40, 10
store i32 %41, i32* %3
br label %25
42: ; preds = %7, %11, %25
ret void
}

LLVM IR (-O2):
define void @ft_putnbr(i32 %0) {
%2 = icmp eq i32 %0, -2147483648
br i1 %2, label %3, label %14
3: ; preds = %19, %1
tail call void @ft_putnbr(i32 -2)
br label %4
4: ; preds = %3, %4
%5 = phi i32 [ %6, %4 ], [ 1000000000, %3 ]
%6 = udiv i32 %5, 10
%7 = udiv i32 147483648, %6
%8 = udiv i32 147483648, %5
%9 = mul nsw i32 %8, -10
%10 = add nuw nsw i32 %7, 48
%11 = add nsw i32 %10, %9
%12 = tail call i32 @ft_putchar(i32 %11)
%13 = icmp ugt i32 %5, 19
br i1 %13, label %4, label %38
14: ; preds = %1, %19
%15 = phi i32 [ %21, %19 ], [ %0, %1 ]
%16 = icmp slt i32 %15, 0
br i1 %16, label %19, label %17
17: ; preds = %14
%18 = icmp eq i32 %15, 0
br i1 %18, label %38, label %23
19: ; preds = %14
%20 = tail call i32 @ft_putchar(i32 45)
%21 = sub nsw i32 0, %15
%22 = icmp eq i32 %15, -2147483648
br i1 %22, label %3, label %14
23: ; preds = %17, %23
%24 = phi i32 [ %25, %23 ], [ 1, %17 ]
%25 = mul nuw nsw i32 %24, 10
%26 = sdiv i32 %15, %25
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %23
28: ; preds = %23, %28
%29 = phi i32 [ %30, %28 ], [ %25, %23 ]
%30 = udiv i32 %29, 10
%31 = sdiv i32 %15, %30
%32 = sdiv i32 %15, %29
%33 = mul i32 %32, -10
%34 = add i32 %31, 48
%35 = add i32 %34, %33
%36 = tail call i32 @ft_putchar(i32 %35)
%37 = icmp ugt i32 %29, 19
br i1 %37, label %28, label %38
38: ; preds = %28, %4, %17
ret void
}