#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);
int /*<<< orphan*/ ft_putstr(char *);
void ft_putnbr(int n) {
  int i;
  i = 1;
  if (n == -2147483648) {
    ft_putstr("-2147483648");
    return;
  }
  if (n < 0) {
    ft_putchar('-');
    n = n * -1;
  }
  while ((n / i) >= 10) {
    i = i * 10;
  }
  while (i > 0) {
    ft_putchar((n / i) % 10 + '0');
    i = i / 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    1153 <ft_putnbr+0x33>
lea    0xeb7(%rip),%rdi
call   1040 <ft_putstr@plt>
jmp    11ca <ft_putnbr+0xaa>
cmpl   $0x0,-0x4(%rbp)
jge    116e <ft_putnbr+0x4e>
mov    $0x2d,%edi
call   1030 <ft_putchar@plt>
imul   $0xffffffff,-0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1173 <ft_putnbr+0x53>
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
cmp    $0xa,%eax
jl     118f <ft_putnbr+0x6f>
imul   $0xa,-0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    1173 <ft_putnbr+0x53>
jmp    1194 <ft_putnbr+0x74>
cmpl   $0x0,-0x8(%rbp)
jle    11ca <ft_putnbr+0xaa>
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
add    $0x30,%edi
call   1030 <ft_putchar@plt>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
jmp    1194 <ft_putnbr+0x74>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_putnbr>:
cmp    $0x80000000,%edi
jne    1134 <ft_putnbr+0x14>
lea    0xed1(%rip),%rdi
jmp    1040 <ft_putstr@plt>
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebp
test   %edi,%edi
jns    114a <ft_putnbr+0x2a>
mov    $0x2d,%edi
call   1030 <ft_putchar@plt>
neg    %ebp
mov    $0x1,%ebx
cmp    $0xa,%ebp
jb     116f <ft_putnbr+0x4f>
mov    $0x1,%ebx
nopl   0x0(%rax)
add    %ebx,%ebx
lea    (%rbx,%rbx,4),%ebx
mov    %ebp,%eax
cltd
idiv   %ebx
cmp    $0x9,%eax
jg     1160 <ft_putnbr+0x40>
mov    $0xcccccccd,%r14d
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebp,%eax
cltd
idiv   %ebx
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
neg    %ecx
lea    (%rax,%rcx,1),%edi
add    $0x30,%edi
call   1030 <ft_putchar@plt>
mov    %ebx,%eax
imul   %r14,%rax
shr    $0x23,%rax
cmp    $0x9,%ebx
mov    %eax,%ebx
ja     1180 <ft_putnbr+0x60>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"-2147483648\00"
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 %9
7: ; preds = %1
%8 = call i32 @ft_putstr(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %38
9: ; preds = %1
%10 = load i32, i32* %2
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %9
%13 = call i32 @ft_putchar(i32 45)
%14 = load i32, i32* %2
%15 = mul nsw i32 %14, -1
store i32 %15, i32* %2
br label %16
16: ; preds = %12, %9
br label %17
17: ; preds = %22, %16
%18 = load i32, i32* %2
%19 = load i32, i32* %3
%20 = sdiv i32 %18, %19
%21 = icmp sge i32 %20, 10
br i1 %21, label %22, label %25
22: ; preds = %17
%23 = load i32, i32* %3
%24 = mul nsw i32 %23, 10
store i32 %24, i32* %3
br label %17
25: ; preds = %17
br label %26
26: ; preds = %29, %25
%27 = load i32, i32* %3
%28 = icmp sgt i32 %27, 0
br i1 %28, label %29, label %38
29: ; preds = %26
%30 = load i32, i32* %2
%31 = load i32, i32* %3
%32 = sdiv i32 %30, %31
%33 = srem i32 %32, 10
%34 = add nsw i32 %33, 48
%35 = call i32 @ft_putchar(i32 %34)
%36 = load i32, i32* %3
%37 = sdiv i32 %36, 10
store i32 %37, i32* %3
br label %26
38: ; preds = %7, %26
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"-2147483648\00"
define void @ft_putnbr(i32 %0) {
%2 = icmp eq i32 %0, -2147483648
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = tail call i32 @ft_putstr(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %28
5: ; preds = %1
%6 = icmp slt i32 %0, 0
br i1 %6, label %7, label %10
7: ; preds = %5
%8 = tail call i32 @ft_putchar(i32 45)
%9 = sub nsw i32 0, %0
br label %10
10: ; preds = %7, %5
%11 = phi i32 [ %9, %7 ], [ %0, %5 ]
%12 = icmp ugt i32 %11, 9
br i1 %12, label %13, label %18
13: ; preds = %10, %13
%14 = phi i32 [ %15, %13 ], [ 1, %10 ]
%15 = mul nuw nsw i32 %14, 10
%16 = sdiv i32 %11, %15
%17 = icmp sgt i32 %16, 9
br i1 %17, label %13, label %18
18: ; preds = %13, %10
%19 = phi i32 [ 1, %10 ], [ %15, %13 ]
br label %20
20: ; preds = %18, %20
%21 = phi i32 [ %26, %20 ], [ %19, %18 ]
%22 = sdiv i32 %11, %21
%23 = srem i32 %22, 10
%24 = add nsw i32 %23, 48
%25 = tail call i32 @ft_putchar(i32 %24)
%26 = udiv i32 %21, 10
%27 = icmp ult i32 %21, 10
br i1 %27, label %28, label %20
28: ; preds = %20, %3
ret void
}