#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*/ printf(char *, ...);
void print_f(double x) {
  long i, j = 6;
  long p;
  i = (long)x;
  printf("%d.", i);
  x = x - i;
  while (j--) {
    x *= 10;
    p = (long)(x);
    x = x - p;
    printf("%d", p);
  }
  printf("   ");
}


x86 assembly (clang, -O0):
<print_f>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
movq   $0x6,-0x18(%rbp)
cvttsd2si -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xece(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsd  -0x8(%rbp),%xmm0
cvtsi2sdq -0x10(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x18(%rbp)
cmp    $0x0,%rax
je     11b5 <print_f+0xa5>
movsd  0xe8a(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
cvttsd2si -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
cvtsi2sdq -0x20(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1155 <print_f+0x45>
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_f>:
push   %rbx
sub    $0x10,%rsp
movsd  %xmm0,0x8(%rsp)
cvttsd2si %xmm0,%rbx
lea    0xee1(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rbx,%xmm0
movsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
mulsd  0xeb5(%rip),%xmm1
cvttsd2si %xmm1,%rsi
xorps  %xmm0,%xmm0
cvtsi2sd %rsi,%xmm0
subsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
lea    0xea3(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
movsd  0x8(%rsp),%xmm1
mulsd  0xe7f(%rip),%xmm1
cvttsd2si %xmm1,%rsi
xorps  %xmm0,%xmm0
cvtsi2sd %rsi,%xmm0
subsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
movsd  0x8(%rsp),%xmm1
mulsd  0xe50(%rip),%xmm1
cvttsd2si %xmm1,%rsi
xorps  %xmm0,%xmm0
cvtsi2sd %rsi,%xmm0
subsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
movsd  0x8(%rsp),%xmm1
mulsd  0xe21(%rip),%xmm1
cvttsd2si %xmm1,%rsi
xorps  %xmm0,%xmm0
cvtsi2sd %rsi,%xmm0
subsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
movsd  0x8(%rsp),%xmm1
mulsd  0xdf2(%rip),%xmm1
cvttsd2si %xmm1,%rsi
xorps  %xmm0,%xmm0
cvtsi2sd %rsi,%xmm0
subsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
movsd  0x8(%rsp),%xmm0
mulsd  0xdc3(%rip),%xmm0
cvttsd2si %xmm0,%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xdbc(%rip),%rdi
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"%d.\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c" \00"
define void @print_f(double %0) {
%2 = alloca double
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
store double %0, double* %2
store i64 6, i64* %4
%6 = load double, double* %2
%7 = fptosi double %6 to i64
store i64 %7, i64* %3
%8 = load i64, i64* %3
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 %8)
%10 = load double, double* %2
%11 = load i64, i64* %3
%12 = sitofp i64 %11 to double
%13 = fsub double %10, %12
store double %13, double* %2
br label %14
14: ; preds = %18, %1
%15 = load i64, i64* %4
%16 = add nsw i64 %15, -1
store i64 %16, i64* %4
%17 = icmp ne i64 %15, 0
br i1 %17, label %18, label %29
18: ; preds = %14
%19 = load double, double* %2
%20 = fmul double %19, 1.000000e+01
store double %20, double* %2
%21 = load double, double* %2
%22 = fptosi double %21 to i64
store i64 %22, i64* %5
%23 = load double, double* %2
%24 = load i64, i64* %5
%25 = sitofp i64 %24 to double
%26 = fsub double %23, %25
store double %26, double* %2
%27 = load i64, i64* %5
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i64 %27)
br label %14
29: ; preds = %14
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d.\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c" \00"
define void @print_f(double %0) {
%2 = fptosi double %0 to i64
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 %2)
%4 = sitofp i64 %2 to double
%5 = fsub double %0, %4
%6 = fmul double %5, 1.000000e+01
%7 = fptosi double %6 to i64
%8 = sitofp i64 %7 to double
%9 = fsub double %6, %8
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i64 %7)
%11 = fmul double %9, 1.000000e+01
%12 = fptosi double %11 to i64
%13 = sitofp i64 %12 to double
%14 = fsub double %11, %13
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i64 %12)
%16 = fmul double %14, 1.000000e+01
%17 = fptosi double %16 to i64
%18 = sitofp i64 %17 to double
%19 = fsub double %16, %18
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i64 %17)
%21 = fmul double %19, 1.000000e+01
%22 = fptosi double %21 to i64
%23 = sitofp i64 %22 to double
%24 = fsub double %21, %23
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i64 %22)
%26 = fmul double %24, 1.000000e+01
%27 = fptosi double %26 to i64
%28 = sitofp i64 %27 to double
%29 = fsub double %26, %28
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i64 %27)
%31 = fmul double %29, 1.000000e+01
%32 = fptosi double %31 to i64
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i64 %32)
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
ret void
}