#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);
int /*<<< orphan*/ write(int, char *, int);
void ft_putnbr(int n) {
  unsigned long int exp;
  unsigned int temp;
  float f;
  if (!(temp = n) && n < 0) {
    temp = -n;
    write(1, "-", 1);
  }
  if (n == 0) {
    write(1, "0", 1);
    return;
  }
  exp = 1;
  while (temp >= exp)
    exp *= 10;
  exp /= 10;
  while (exp >= 1) {
    f = temp / exp;
    ft_putchar((long int)f + '0');
    temp -= ((long int)f) * exp;
    exp /= 10;
  }
}


x86 assembly (clang, -O0):
<ft_putnbr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jne    115f <ft_putnbr+0x3f>
cmpl   $0x0,-0x4(%rbp)
jge    115f <ft_putnbr+0x3f>
xor    %eax,%eax
sub    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    $0x1,%edx
lea    0xea8(%rip),%rsi
mov    %edx,%edi
call   1030 <write@plt>
cmpl   $0x0,-0x4(%rbp)
jne    1181 <ft_putnbr+0x61>
mov    $0x1,%edx
lea    0xe8d(%rip),%rsi
mov    %edx,%edi
call   1030 <write@plt>
jmp    1211 <ft_putnbr+0xf1>
movq   $0x1,-0x10(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%rax
jb     11a4 <ft_putnbr+0x84>
imul   $0xa,-0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
jmp    1189 <ft_putnbr+0x69>
mov    -0x10(%rbp),%rax
mov    $0xa,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,-0x10(%rbp)
cmpq   $0x1,-0x10(%rbp)
jb     1211 <ft_putnbr+0xf1>
mov    -0x14(%rbp),%eax
mov    -0x10(%rbp),%rcx
xor    %edx,%edx
div    %rcx
cvtsi2ss %rax,%xmm0
movss  %xmm0,-0x18(%rbp)
cvttss2si -0x18(%rbp),%rdi
add    $0x30,%rdi
call   1040 <ft_putchar@plt>
cvttss2si -0x18(%rbp),%rcx
imul   -0x10(%rbp),%rcx
mov    -0x14(%rbp),%eax
sub    %rcx,%rax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    $0xa,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,-0x10(%rbp)
jmp    11b6 <ft_putnbr+0x96>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_putnbr>:
test   %edi,%edi
je     115c <ft_putnbr+0x3c>
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %edi,%r14d
mov    %edi,%eax
mov    $0x1,%ebx
nopw   0x0(%rax,%rax,1)
add    %rbx,%rbx
lea    (%rbx,%rbx,4),%rbx
cmp    %rax,%rbx
jbe    1140 <ft_putnbr+0x20>
cmp    $0xa,%rbx
jae    1172 <ft_putnbr+0x52>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0xe9d(%rip),%rsi
mov    $0x1,%edi
mov    $0x1,%edx
jmp    1030 <write@plt>
movabs $0xcccccccccccccccd,%r12
cc cc cc
jmp    11ae <ft_putnbr+0x8e>
xchg   %ax,%ax
mov    %r14d,%eax
xor    %edx,%edx
div    %r15d
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
cvttss2si %xmm0,%r13
lea    0x30(%r13),%rdi
call   1040 <ft_putchar@plt>
imul   %r15d,%r13d
sub    %r13d,%r14d
cmp    $0x63,%rbx
mov    %r15,%rbx
jbe    1152 <ft_putnbr+0x32>
mov    %rbx,%rax
mul    %r12
mov    %rdx,%r15
shr    $0x3,%r15
mov    %r14d,%r14d
cmp    %r15,%r14
jae    1180 <ft_putnbr+0x60>
xor    %eax,%eax
jmp    1188 <ft_putnbr+0x68>

LLVM IR (-O0):
@.str = [2 x i8] c"-\00"
@.str.1 = [2 x i8] c"0\00"
define void @ft_putnbr(i32 %0) {
%2 = alloca i32
%3 = alloca i64
%4 = alloca i32
%5 = alloca float
store i32 %0, i32* %2
%6 = load i32, i32* %2
store i32 %6, i32* %4
%7 = icmp ne i32 %6, 0
br i1 %7, label %15, label %8
8: ; preds = %1
%9 = load i32, i32* %2
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %8
%12 = load i32, i32* %2
%13 = sub nsw i32 0, %12
store i32 %13, i32* %4
%14 = call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
br label %15
15: ; preds = %11, %8, %1
%16 = load i32, i32* %2
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
br label %55
20: ; preds = %15
store i64 1, i64* %3
br label %21
21: ; preds = %26, %20
%22 = load i32, i32* %4
%23 = zext i32 %22 to i64
%24 = load i64, i64* %3
%25 = icmp uge i64 %23, %24
br i1 %25, label %26, label %29
26: ; preds = %21
%27 = load i64, i64* %3
%28 = mul i64 %27, 10
store i64 %28, i64* %3
br label %21
29: ; preds = %21
%30 = load i64, i64* %3
%31 = udiv i64 %30, 10
store i64 %31, i64* %3
br label %32
32: ; preds = %35, %29
%33 = load i64, i64* %3
%34 = icmp uge i64 %33, 1
br i1 %34, label %35, label %55
35: ; preds = %32
%36 = load i32, i32* %4
%37 = zext i32 %36 to i64
%38 = load i64, i64* %3
%39 = udiv i64 %37, %38
%40 = uitofp i64 %39 to float
store float %40, float* %5
%41 = load float, float* %5
%42 = fptosi float %41 to i64
%43 = add nsw i64 %42, 48
%44 = call i32 @ft_putchar(i64 %43)
%45 = load float, float* %5
%46 = fptosi float %45 to i64
%47 = load i64, i64* %3
%48 = mul i64 %46, %47
%49 = load i32, i32* %4
%50 = zext i32 %49 to i64
%51 = sub i64 %50, %48
%52 = trunc i64 %51 to i32
store i32 %52, i32* %4
%53 = load i64, i64* %3
%54 = udiv i64 %53, 10
store i64 %54, i64* %3
br label %32
55: ; preds = %18, %32
ret void
}

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