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


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,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jge    1149 <ft_putnbr+0x39>
mov    $0x2d,%edi
call   1030 <ft_putchar@plt>
imul   $0xffffffffffffffff,-0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    115e <ft_putnbr+0x4e>
mov    $0x30,%edi
call   1030 <ft_putchar@plt>
jmp    1163 <ft_putnbr+0x53>
mov    -0x18(%rbp),%rax
cqto
idivq  -0x10(%rbp)
cmp    $0x0,%rax
je     1185 <ft_putnbr+0x75>
imul   $0xa,-0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
jmp    1163 <ft_putnbr+0x53>
jmp    118a <ft_putnbr+0x7a>
cmpq   $0x1,-0x10(%rbp)
jle    11f0 <ft_putnbr+0xe0>
mov    -0x10(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11c4 <ft_putnbr+0xb4>
mov    -0x18(%rbp),%rdi
add    $0x30,%rdi
call   1030 <ft_putchar@plt>
jmp    11da <ft_putnbr+0xca>
mov    -0x18(%rbp),%rax
cqto
idivq  -0x10(%rbp)
mov    %rax,%rdi
add    $0x30,%rdi
call   1030 <ft_putchar@plt>
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%rax
cqto
idiv   %rcx
mov    %rdx,-0x18(%rbp)
jmp    118a <ft_putnbr+0x7a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_putnbr>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
movslq %edi,%r14
test   %r14d,%r14d
js     11ce <ft_putnbr+0xbe>
test   %r14,%r14
je     11e4 <ft_putnbr+0xd4>
mov    $0x1,%ebx
jmp    114d <ft_putnbr+0x3d>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rax
cqto
idiv   %rbx
test   %rax,%rax
je     116c <ft_putnbr+0x5c>
add    %rbx,%rbx
lea    (%rbx,%rbx,4),%rbx
mov    %r14,%rax
or     %rbx,%rax
shr    $0x20,%rax
jne    1140 <ft_putnbr+0x30>
mov    %r14d,%eax
xor    %edx,%edx
div    %ebx
test   %rax,%rax
jne    114d <ft_putnbr+0x3d>
movabs $0xcccccccccccccccd,%r12
cc cc cc
jmp    11a0 <ft_putnbr+0x90>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rax
cqto
idiv   %r15
mov    %rax,%rdi
mov    %rdx,%r14
add    $0x30,%rdi
call   1030 <ft_putchar@plt>
cmp    $0x13,%rbx
mov    %r15,%rbx
jbe    11ec <ft_putnbr+0xdc>
mov    %rbx,%rax
mul    %r12
cmp    $0x9,%rbx
jbe    11f8 <ft_putnbr+0xe8>
mov    %rdx,%r15
shr    $0x3,%r15
mov    %r14,%rax
or     %r15,%rax
shr    $0x20,%rax
jne    1180 <ft_putnbr+0x70>
mov    %r14d,%eax
xor    %edx,%edx
div    %r15d
mov    %eax,%edi
mov    %edx,%r14d
jmp    118e <ft_putnbr+0x7e>
mov    $0x2d,%edi
call   1030 <ft_putchar@plt>
neg    %r14
test   %r14,%r14
jne    112d <ft_putnbr+0x1d>
mov    $0x30,%r14d
jmp    11fc <ft_putnbr+0xec>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
add    $0x30,%r14
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <ft_putchar@plt>

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

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