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


x86 assembly (clang, -O0):
<ft_putnbr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    1137 <ft_putnbr+0x27>
mov    $0x2d,%edi
call   1030 <ft_putchar@plt>
xor    %eax,%eax
sub    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0xc(%rbp),%eax
cmp    %ecx,%eax
jg     1168 <ft_putnbr+0x58>
imul   $0xa,-0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    113e <ft_putnbr+0x2e>
jmp    116d <ft_putnbr+0x5d>
cmpl   $0x1,-0x8(%rbp)
jl     11b0 <ft_putnbr+0xa0>
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    %eax,%edi
add    $0x30,%edi
call   1030 <ft_putchar@plt>
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    %eax,%ecx
imul   -0x8(%rbp),%ecx
mov    -0x4(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
jmp    116d <ft_putnbr+0x5d>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_putnbr>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebp
test   %edi,%edi
jns    1126 <ft_putnbr+0x16>
mov    $0x2d,%edi
call   1030 <ft_putchar@plt>
neg    %ebp
mov    $0xcccccccd,%r14d
mov    $0x1,%ebx
cmp    $0xa,%ebp
jb     1160 <ft_putnbr+0x50>
mov    %ebp,%eax
imul   %r14,%rax
shr    $0x23,%rax
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
add    %ebx,%ebx
lea    (%rbx,%rbx,4),%ebx
cmp    %eax,%ebx
jbe    1150 <ft_putnbr+0x40>
nopl   0x0(%rax)
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     1160 <ft_putnbr+0x50>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @ft_putnbr(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = icmp slt i32 %4, 0
br i1 %5, label %6, label %10
6: ; preds = %1
%7 = call i32 @ft_putchar(i32 45)
%8 = load i32, i32* %2
%9 = sub nsw i32 0, %8
store i32 %9, i32* %2
br label %10
10: ; preds = %6, %1
store i32 1, i32* %3
br label %11
11: ; preds = %16, %10
%12 = load i32, i32* %3
%13 = load i32, i32* %2
%14 = sdiv i32 %13, 10
%15 = icmp sle i32 %12, %14
br i1 %15, label %16, label %19
16: ; preds = %11
%17 = load i32, i32* %3
%18 = mul nsw i32 %17, 10
store i32 %18, i32* %3
br label %11
19: ; preds = %11
br label %20
20: ; preds = %23, %19
%21 = load i32, i32* %3
%22 = icmp sge i32 %21, 1
br i1 %22, label %23, label %38
23: ; preds = %20
%24 = load i32, i32* %2
%25 = load i32, i32* %3
%26 = sdiv i32 %24, %25
%27 = add nsw i32 %26, 48
%28 = call i32 @ft_putchar(i32 %27)
%29 = load i32, i32* %2
%30 = load i32, i32* %3
%31 = sdiv i32 %29, %30
%32 = load i32, i32* %3
%33 = mul nsw i32 %31, %32
%34 = load i32, i32* %2
%35 = sub nsw i32 %34, %33
store i32 %35, i32* %2
%36 = load i32, i32* %3
%37 = sdiv i32 %36, 10
store i32 %37, i32* %3
br label %20
38: ; preds = %20
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 = tail call i32 @ft_putchar(i32 45)
%5 = sub nsw i32 0, %0
br label %6
6: ; preds = %3, %1
%7 = phi i32 [ %5, %3 ], [ %0, %1 ]
%8 = udiv i32 %7, 10
%9 = icmp ult i32 %7, 10
br i1 %9, label %14, label %10
10: ; preds = %6, %10
%11 = phi i32 [ %12, %10 ], [ 1, %6 ]
%12 = mul nsw i32 %11, 10
%13 = icmp ugt i32 %12, %8
br i1 %13, label %14, label %10
14: ; preds = %10, %6
%15 = phi i32 [ 1, %6 ], [ %12, %10 ]
br label %16
16: ; preds = %14, %16
%17 = phi i32 [ %24, %16 ], [ %15, %14 ]
%18 = phi i32 [ %23, %16 ], [ %7, %14 ]
%19 = sdiv i32 %18, %17
%20 = add nsw i32 %19, 48
%21 = tail call i32 @ft_putchar(i32 %20)
%22 = mul nsw i32 %19, %17
%23 = srem i32 %18, %17
%24 = udiv i32 %17, 10
%25 = icmp ult i32 %17, 10
br i1 %25, label %26, label %16
26: ; preds = %16
ret void
}