#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*/ my_put_char(char);
int /*<<< orphan*/ my_put_number(int);
void my_put_float(double num) {
  int temp = num;
  int div = 1;
  if (temp < 0) {
    my_put_char('-');
    temp = -temp;
  }
  while (temp / div > 9 || temp / div < -9)
    div = div * 10;
  while (div >= 1) {
    if (temp > 0)
      my_put_number((temp / div) % 10);
    else
      my_put_number((temp / div) % 10);
    div = div / 10;
  }
  my_put_char('.');
  temp = num * 100;
  my_put_number((temp / 10) % 10);
  my_put_number((temp / 1) % 10);
}


x86 assembly (clang, -O0):
<my_put_float>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
cvttsd2si -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    1158 <my_put_float+0x38>
mov    $0x2d,%edi
call   1040 <my_put_char@plt>
xor    %eax,%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    115d <my_put_float+0x3d>
mov    -0xc(%rbp),%eax
cltd
idivl  -0x10(%rbp)
mov    %eax,%ecx
mov    $0x1,%al
cmp    $0x9,%ecx
mov    %al,-0x11(%rbp)
jg     1184 <my_put_float+0x64>
mov    -0xc(%rbp),%eax
cltd
idivl  -0x10(%rbp)
cmp    $0xfffffff7,%eax
setl   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1194 <my_put_float+0x74>
jmp    11a0 <my_put_float+0x80>
imul   $0xa,-0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    115d <my_put_float+0x3d>
jmp    11a5 <my_put_float+0x85>
cmpl   $0x1,-0x10(%rbp)
jl     11fd <my_put_float+0xdd>
cmpl   $0x0,-0xc(%rbp)
jle    11d4 <my_put_float+0xb4>
mov    -0xc(%rbp),%eax
cltd
idivl  -0x10(%rbp)
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
call   1030 <my_put_number@plt>
jmp    11ea <my_put_float+0xca>
mov    -0xc(%rbp),%eax
cltd
idivl  -0x10(%rbp)
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
call   1030 <my_put_number@plt>
mov    -0x10(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
jmp    11a5 <my_put_float+0x85>
mov    $0x2e,%edi
call   1040 <my_put_char@plt>
movsd  0xdf1(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
call   1030 <my_put_number@plt>
mov    -0xc(%rbp),%eax
mov    $0x1,%ecx
cltd
idiv   %ecx
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
call   1030 <my_put_number@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_put_float>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
movsd  %xmm0,(%rsp)
cvttsd2si %xmm0,%ebx
test   %ebx,%ebx
jns    1140 <my_put_float+0x20>
mov    $0x2d,%edi
call   1040 <my_put_char@plt>
neg    %ebx
lea    -0xa(%rbx),%eax
mov    $0x1,%ebp
cmp    $0xffffffec,%eax
ja     1173 <my_put_float+0x53>
mov    $0x1,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    %ebp,%ebp
lea    0x0(%rbp,%rbp,4),%ebp
mov    %ebx,%eax
cltd
idiv   %ebp
add    $0xfffffff6,%eax
cmp    $0xffffffed,%eax
jb     1160 <my_put_float+0x40>
mov    %ebx,%r14d
neg    %r14d
mov    $0xcccccccd,%r15d
jmp    11bf <my_put_float+0x9f>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14d,%eax
xor    %edx,%edx
div    %ebp
mov    %rax,%rcx
imul   %r15,%rcx
shr    $0x23,%rcx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%edi
sub    %eax,%edi
call   1030 <my_put_number@plt>
mov    %ebp,%eax
imul   %r15,%rax
shr    $0x23,%rax
cmp    $0x9,%ebp
mov    %eax,%ebp
jbe    11df <my_put_float+0xbf>
test   %ebx,%ebx
jle    1190 <my_put_float+0x70>
mov    %ebx,%eax
xor    %edx,%edx
div    %ebp
mov    %eax,%edi
mov    %rdi,%rax
imul   %r15,%rax
shr    $0x23,%rax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%edi
jmp    11a9 <my_put_float+0x89>
mov    $0x2e,%edi
call   1040 <my_put_char@plt>
movsd  (%rsp),%xmm0
mulsd  0xe0a(%rip),%xmm0
cvttsd2si %xmm0,%eax
movslq %eax,%rbx
imul   $0x66666667,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
movslq %eax,%rbp
imul   $0x66666667,%rbp,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
mov    %ebp,%edi
sub    %eax,%edi
call   1030 <my_put_number@plt>
add    %ebp,%ebp
lea    0x0(%rbp,%rbp,4),%eax
sub    %eax,%ebx
mov    %ebx,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <my_put_number@plt>

LLVM IR (-O0):
define void @my_put_float(double %0) {
%2 = alloca double
%3 = alloca i32
%4 = alloca i32
store double %0, double* %2
%5 = load double, double* %2
%6 = fptosi double %5 to i32
store i32 %6, i32* %3
store i32 1, i32* %4
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %1
%10 = call i32 @my_put_char(i8 signext 45)
%11 = load i32, i32* %3
%12 = sub nsw i32 0, %11
store i32 %12, i32* %3
br label %13
13: ; preds = %9, %1
br label %14
14: ; preds = %26, %13
%15 = load i32, i32* %3
%16 = load i32, i32* %4
%17 = sdiv i32 %15, %16
%18 = icmp sgt i32 %17, 9
br i1 %18, label %24, label %19
19: ; preds = %14
%20 = load i32, i32* %3
%21 = load i32, i32* %4
%22 = sdiv i32 %20, %21
%23 = icmp slt i32 %22, -9
br label %24
24: ; preds = %19, %14
%25 = phi i1 [ true, %14 ], [ %23, %19 ]
br i1 %25, label %26, label %29
26: ; preds = %24
%27 = load i32, i32* %4
%28 = mul nsw i32 %27, 10
store i32 %28, i32* %4
br label %14
29: ; preds = %24
br label %30
30: ; preds = %48, %29
%31 = load i32, i32* %4
%32 = icmp sge i32 %31, 1
br i1 %32, label %33, label %51
33: ; preds = %30
%34 = load i32, i32* %3
%35 = icmp sgt i32 %34, 0
br i1 %35, label %36, label %42
36: ; preds = %33
%37 = load i32, i32* %3
%38 = load i32, i32* %4
%39 = sdiv i32 %37, %38
%40 = srem i32 %39, 10
%41 = call i32 @my_put_number(i32 %40)
br label %48
42: ; preds = %33
%43 = load i32, i32* %3
%44 = load i32, i32* %4
%45 = sdiv i32 %43, %44
%46 = srem i32 %45, 10
%47 = call i32 @my_put_number(i32 %46)
br label %48
48: ; preds = %42, %36
%49 = load i32, i32* %4
%50 = sdiv i32 %49, 10
store i32 %50, i32* %4
br label %30
51: ; preds = %30
%52 = call i32 @my_put_char(i8 signext 46)
%53 = load double, double* %2
%54 = fmul double %53, 1.000000e+02
%55 = fptosi double %54 to i32
store i32 %55, i32* %3
%56 = load i32, i32* %3
%57 = sdiv i32 %56, 10
%58 = srem i32 %57, 10
%59 = call i32 @my_put_number(i32 %58)
%60 = load i32, i32* %3
%61 = sdiv i32 %60, 1
%62 = srem i32 %61, 10
%63 = call i32 @my_put_number(i32 %62)
ret void
}

LLVM IR (-O2):
define void @my_put_float(double %0) {
%2 = fptosi double %0 to i32
%3 = icmp slt i32 %2, 0
br i1 %3, label %4, label %7
4: ; preds = %1
%5 = tail call i32 @my_put_char(i8 signext 45)
%6 = sub nsw i32 0, %2
br label %7
7: ; preds = %4, %1
%8 = phi i32 [ %6, %4 ], [ %2, %1 ]
%9 = add nsw i32 %8, -10
%10 = icmp ult i32 %9, -19
br i1 %10, label %15, label %11
11: ; preds = %15, %7
%12 = phi i32 [ 1, %7 ], [ %17, %15 ]
%13 = icmp sgt i32 %8, 0
%14 = sub i32 0, %8
br label %21
15: ; preds = %7, %15
%16 = phi i32 [ %17, %15 ], [ 1, %7 ]
%17 = mul nuw nsw i32 %16, 10
%18 = sdiv i32 %8, %17
%19 = add i32 %18, -10
%20 = icmp ult i32 %19, -19
br i1 %20, label %15, label %11
21: ; preds = %11, %30
%22 = phi i32 [ %12, %11 ], [ %33, %30 ]
br i1 %13, label %23, label %26
23: ; preds = %21
%24 = udiv i32 %8, %22
%25 = urem i32 %24, 10
br label %30
26: ; preds = %21
%27 = udiv i32 %14, %22
%28 = urem i32 %27, 10
%29 = sub nsw i32 0, %28
br label %30
30: ; preds = %26, %23
%31 = phi i32 [ %29, %26 ], [ %25, %23 ]
%32 = tail call i32 @my_put_number(i32 %31)
%33 = udiv i32 %22, 10
%34 = icmp ult i32 %22, 10
br i1 %34, label %35, label %21
35: ; preds = %30
%36 = tail call i32 @my_put_char(i8 signext 46)
%37 = fmul double %0, 1.000000e+02
%38 = fptosi double %37 to i32
%39 = sdiv i32 %38, 10
%40 = srem i32 %39, 10
%41 = tail call i32 @my_put_number(i32 %40)
%42 = srem i32 %38, 10
%43 = tail call i32 @my_put_number(i32 %42)
ret void
}