#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(char);
void ft_putnbr(int nb) {
  char minus;
  int i;
  int cutter;
  char cookie;
  if (nb > 2147483647 || nb < -2147483648)
    return;
  if (nb < 0) {
    nb *= -1;
    minus = '\x002D';
    ft_putchar(minus);
  }
  cutter = 1;
  while (nb / (cutter * 10) > 0)
    cutter *= 10;
  i = 1;
  while (i) {
    cookie = (nb / cutter) + '0';
    ft_putchar(cookie);
    nb -= (nb / cutter) * cutter;
    i = cutter < 10 ? 0 : 1;
    cutter /= 10;
  }
}


x86 assembly (clang, -O0):
<ft_putnbr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x7fffffff,-0x4(%rbp)
jg     1138 <ft_putnbr+0x28>
movslq -0x4(%rbp),%rax
cmp    $0xffffffff80000000,%rax
jge    113d <ft_putnbr+0x2d>
jmp    11e3 <ft_putnbr+0xd3>
cmpl   $0x0,-0x4(%rbp)
jge    115b <ft_putnbr+0x4b>
imul   $0xffffffff,-0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
movb   $0x2d,-0x5(%rbp)
movsbl -0x5(%rbp),%edi
call   1030 <ft_putchar@plt>
movl   $0x1,-0x10(%rbp)
mov    -0x4(%rbp),%eax
imul   $0xa,-0x10(%rbp),%ecx
cltd
idiv   %ecx
cmp    $0x0,%eax
jle    1181 <ft_putnbr+0x71>
imul   $0xa,-0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    1162 <ft_putnbr+0x52>
movl   $0x1,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     11e3 <ft_putnbr+0xd3>
mov    -0x4(%rbp),%eax
cltd
idivl  -0x10(%rbp)
add    $0x30,%eax
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%edi
call   1030 <ft_putchar@plt>
mov    -0x4(%rbp),%eax
cltd
idivl  -0x10(%rbp)
mov    %eax,%ecx
imul   -0x10(%rbp),%ecx
mov    -0x4(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x10(%rbp),%edx
mov    $0x1,%eax
xor    %ecx,%ecx
cmp    $0xa,%edx
cmovl  %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
jmp    1188 <ft_putnbr+0x78>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_putnbr>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
test   %edi,%edi
jns    1125 <ft_putnbr+0x15>
neg    %ebp
mov    $0x2d,%edi
call   1030 <ft_putchar@plt>
mov    $0x1,%ecx
nopw   0x0(%rax,%rax,1)
mov    %ecx,%ebx
lea    (%rbx,%rbx,1),%eax
lea    (%rax,%rax,4),%ecx
mov    %ebp,%eax
cltd
idiv   %ecx
test   %eax,%eax
jg     1130 <ft_putnbr+0x20>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebp,%eax
cltd
idiv   %ebx
add    $0x30,%al
movsbl %al,%edi
mov    %edx,%ebp
call   1030 <ft_putchar@plt>
movslq %ebx,%rax
imul   $0x66666667,%rax,%rbx
mov    %rbx,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rbx
add    %ecx,%ebx
cmp    $0x9,%eax
jg     1150 <ft_putnbr+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @ft_putnbr(i32 %0) {
%2 = alloca i32
%3 = alloca i8
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8
store i32 %0, i32* %2
%7 = load i32, i32* %2
%8 = icmp sgt i32 %7, 2147483647
br i1 %8, label %13, label %9
9: ; preds = %1
%10 = load i32, i32* %2
%11 = sext i32 %10 to i64
%12 = icmp slt i64 %11, -2147483648
br i1 %12, label %13, label %14
13: ; preds = %9, %1
br label %57
14: ; preds = %9
%15 = load i32, i32* %2
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %14
%18 = load i32, i32* %2
%19 = mul nsw i32 %18, -1
store i32 %19, i32* %2
store i8 45, i8* %3
%20 = load i8, i8* %3
%21 = call i32 @ft_putchar(i8 signext %20)
br label %22
22: ; preds = %17, %14
store i32 1, i32* %5
br label %23
23: ; preds = %29, %22
%24 = load i32, i32* %2
%25 = load i32, i32* %5
%26 = mul nsw i32 %25, 10
%27 = sdiv i32 %24, %26
%28 = icmp sgt i32 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %23
%30 = load i32, i32* %5
%31 = mul nsw i32 %30, 10
store i32 %31, i32* %5
br label %23
32: ; preds = %23
store i32 1, i32* %4
br label %33
33: ; preds = %36, %32
%34 = load i32, i32* %4
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %57
36: ; preds = %33
%37 = load i32, i32* %2
%38 = load i32, i32* %5
%39 = sdiv i32 %37, %38
%40 = add nsw i32 %39, 48
%41 = trunc i32 %40 to i8
store i8 %41, i8* %6
%42 = load i8, i8* %6
%43 = call i32 @ft_putchar(i8 signext %42)
%44 = load i32, i32* %2
%45 = load i32, i32* %5
%46 = sdiv i32 %44, %45
%47 = load i32, i32* %5
%48 = mul nsw i32 %46, %47
%49 = load i32, i32* %2
%50 = sub nsw i32 %49, %48
store i32 %50, i32* %2
%51 = load i32, i32* %5
%52 = icmp slt i32 %51, 10
%53 = zext i1 %52 to i64
%54 = select i1 %52, i32 0, i32 1
store i32 %54, i32* %4
%55 = load i32, i32* %5
%56 = sdiv i32 %55, 10
store i32 %56, i32* %5
br label %33
57: ; preds = %13, %33
ret void
}

LLVM IR (-O2):
define void @ft_putnbr(i32 %0) {
%2 = icmp slt i32 %0, 0
br i1 %2, label %3, label %6
3: ; preds = %1
%4 = sub nsw i32 0, %0
%5 = tail call i32 @ft_putchar(i8 signext 45)
br label %6
6: ; preds = %3, %1
%7 = phi i32 [ %4, %3 ], [ %0, %1 ]
br label %8
8: ; preds = %8, %6
%9 = phi i32 [ 1, %6 ], [ %10, %8 ]
%10 = mul nuw nsw i32 %9, 10
%11 = sdiv i32 %7, %10
%12 = icmp sgt i32 %11, 0
br i1 %12, label %8, label %13
13: ; preds = %8, %13
%14 = phi i32 [ %21, %13 ], [ %7, %8 ]
%15 = phi i32 [ %23, %13 ], [ %9, %8 ]
%16 = sdiv i32 %14, %15
%17 = trunc i32 %16 to i8
%18 = add i8 %17, 48
%19 = tail call i32 @ft_putchar(i8 signext %18)
%20 = mul nsw i32 %16, %15
%21 = srem i32 %14, %15
%22 = icmp slt i32 %15, 10
%23 = sdiv i32 %15, 10
br i1 %22, label %24, label %13
24: ; preds = %13
ret void
}