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


x86 assembly (clang, -O0):
<ft_putnbr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
mov    -0x4(%rbp),%eax
imul   $0xa,-0x8(%rbp),%ecx
cltd
idiv   %ecx
cmp    $0x0,%eax
je     1141 <ft_putnbr+0x31>
imul   $0xa,-0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    1122 <ft_putnbr+0x12>
cmpl   $0x0,-0x4(%rbp)
jge    1155 <ft_putnbr+0x45>
mov    $0x2d,%edi
call   1030 <ft_putchar@plt>
jmp    115a <ft_putnbr+0x4a>
cmpl   $0x1,-0x8(%rbp)
jl     1196 <ft_putnbr+0x86>
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
add    $0x30,%edi
call   1030 <ft_putchar@plt>
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    %edx,-0x4(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
jmp    115a <ft_putnbr+0x4a>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_putnbr>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebp
mov    $0x1,%ecx
nopl   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
jne    1120 <ft_putnbr+0x10>
test   %ebp,%ebp
jns    113f <ft_putnbr+0x2f>
mov    $0x2d,%edi
call   1030 <ft_putchar@plt>
mov    $0xcccccccd,%r14d
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebp,%eax
cltd
idiv   %ebx
lea    0x30(%rax),%edi
mov    %edx,%ebp
call   1030 <ft_putchar@plt>
mov    %ebx,%eax
imul   %r14,%rax
shr    $0x23,%rax
cmp    $0x9,%ebx
mov    %eax,%ebx
ja     1150 <ft_putnbr+0x40>
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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