#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(long);
void ft_putnbr(int nb) {
  long int del;
  long int tmp;
  long int nb_m;
  del = 1;
  nb_m = nb;
  while (nb_m / (del * 10) != 0) {
    del = del * 10;
  }
  if (nb_m < 0) {
    ft_putchar('-');
    nb_m *= -1;
  }
  while (del >= 1) {
    tmp = nb_m / del;
    ft_putchar(tmp + 48);
    nb_m = nb_m % del;
    del /= 10;
  }
}


x86 assembly (clang, -O0):
<ft_putnbr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movq   $0x1,-0x10(%rbp)
movslq -0x4(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
imul   $0xa,-0x10(%rbp),%rcx
cqto
idiv   %rcx
cmp    $0x0,%rax
je     1151 <ft_putnbr+0x41>
imul   $0xa,-0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
jmp    112b <ft_putnbr+0x1b>
cmpq   $0x0,-0x20(%rbp)
jge    116f <ft_putnbr+0x5f>
mov    $0x2d,%edi
call   1030 <ft_putchar@plt>
imul   $0xffffffffffffffff,-0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    1174 <ft_putnbr+0x64>
cmpq   $0x1,-0x10(%rbp)
jl     11bf <ft_putnbr+0xaf>
mov    -0x20(%rbp),%rax
cqto
idivq  -0x10(%rbp)
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
add    $0x30,%rdi
call   1030 <ft_putchar@plt>
mov    -0x20(%rbp),%rax
cqto
idivq  -0x10(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
mov    %rax,-0x10(%rbp)
jmp    1174 <ft_putnbr+0x64>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_putnbr>:
push   %r14
push   %rbx
push   %rax
movslq %edi,%r14
mov    $0x1,%ecx
jmp    112d <ft_putnbr+0x1d>
xchg   %ax,%ax
mov    %r14,%rax
cqto
idiv   %rcx
test   %rax,%rax
je     114f <ft_putnbr+0x3f>
mov    %rcx,%rbx
lea    (%rcx,%rcx,1),%rax
lea    (%rax,%rax,4),%rcx
mov    %r14,%rax
or     %rcx,%rax
shr    $0x20,%rax
jne    1120 <ft_putnbr+0x10>
mov    %edi,%eax
xor    %edx,%edx
div    %ecx
test   %rax,%rax
jne    112d <ft_putnbr+0x1d>
test   %edi,%edi
jns    11a4 <ft_putnbr+0x94>
mov    $0x2d,%edi
call   1030 <ft_putchar@plt>
neg    %r14
jmp    11a4 <ft_putnbr+0x94>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rax
cqto
idiv   %rbx
mov    %rax,%rdi
mov    %rdx,%r14
add    $0x30,%rdi
call   1030 <ft_putchar@plt>
movabs $0xcccccccccccccccd,%rcx
cc cc cc
mov    %rbx,%rax
mul    %rcx
shr    $0x3,%rdx
cmp    $0x9,%rbx
mov    %rdx,%rbx
jbe    11be <ft_putnbr+0xae>
mov    %r14,%rax
or     %rbx,%rax
shr    $0x20,%rax
jne    1170 <ft_putnbr+0x60>
mov    %r14d,%eax
xor    %edx,%edx
div    %ebx
mov    %eax,%edi
mov    %edx,%r14d
jmp    117e <ft_putnbr+0x6e>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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