#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 *, int, double);
void print_number(double x) {
  double y = x;
  int c = 0;
  if (y < 0.0) {
    y = -y;
  }
  while (y > 0 && y < 100.0) {
    y *= 10.0;
    c++;
  }
  printf("%.*f", c, x);
}


x86 assembly (clang, -O0):
<print_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    115d <print_number+0x4d>
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    1162 <print_number+0x52>
movsd  -0x10(%rbp),%xmm0
xor    %eax,%eax
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x15(%rbp)
jbe    118c <print_number+0x7c>
movsd  0xe7f(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
seta   %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    119c <print_number+0x8c>
jmp    11bc <print_number+0xac>
movsd  0xe64(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1162 <print_number+0x52>
mov    -0x14(%rbp),%esi
movsd  -0x8(%rbp),%xmm0
lea    0xe45(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_number>:
movapd 0xee8(%rip),%xmm2
xorpd  %xmm0,%xmm2
xorpd  %xmm3,%xmm3
movapd %xmm0,%xmm1
cmpltsd %xmm3,%xmm1
andpd  %xmm1,%xmm2
andnpd %xmm0,%xmm1
orpd   %xmm2,%xmm1
xor    %esi,%esi
ucomisd %xmm3,%xmm1
jbe    1173 <print_number+0x63>
movsd  0xecb(%rip),%xmm2
ucomisd %xmm1,%xmm2
jbe    1173 <print_number+0x63>
xor    %esi,%esi
movsd  0xec3(%rip),%xmm3
xorpd  %xmm4,%xmm4
nopl   0x0(%rax)
mulsd  %xmm3,%xmm1
add    $0x1,%esi
ucomisd %xmm4,%xmm1
jbe    1173 <print_number+0x63>
ucomisd %xmm1,%xmm2
ja     1160 <print_number+0x50>
lea    0xea6(%rip),%rdi
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"%.*f\00"
define void @print_number(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca i32
store double %0, double* %2
%5 = load double, double* %2
store double %5, double* %3
store i32 0, i32* %4
%6 = load double, double* %3
%7 = fcmp olt double %6, 0.000000e+00
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = load double, double* %3
%10 = fneg double %9
store double %10, double* %3
br label %11
11: ; preds = %8, %1
br label %12
12: ; preds = %20, %11
%13 = load double, double* %3
%14 = fcmp ogt double %13, 0.000000e+00
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = load double, double* %3
%17 = fcmp olt double %16, 1.000000e+02
br label %18
18: ; preds = %15, %12
%19 = phi i1 [ false, %12 ], [ %17, %15 ]
br i1 %19, label %20, label %25
20: ; preds = %18
%21 = load double, double* %3
%22 = fmul double %21, 1.000000e+01
store double %22, double* %3
%23 = load i32, i32* %4
%24 = add nsw i32 %23, 1
store i32 %24, i32* %4
br label %12
25: ; preds = %18
%26 = load i32, i32* %4
%27 = load double, double* %2
%28 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %26, double %27)
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"%.*f\00"
define void @print_number(double %0) {
%2 = fcmp olt double %0, 0.000000e+00
%3 = fneg double %0
%4 = select i1 %2, double %3, double %0
%5 = fcmp ogt double %4, 0.000000e+00
%6 = fcmp olt double %4, 1.000000e+02
%7 = and i1 %5, %6
br i1 %7, label %8, label %16
8: ; preds = %1, %8
%9 = phi i32 [ %12, %8 ], [ 0, %1 ]
%10 = phi double [ %11, %8 ], [ %4, %1 ]
%11 = fmul double %10, 1.000000e+01
%12 = add nuw nsw i32 %9, 1
%13 = fcmp ogt double %11, 0.000000e+00
%14 = fcmp olt double %11, 1.000000e+02
%15 = and i1 %13, %14
br i1 %15, label %8, label %16
16: ; preds = %8, %1
%17 = phi i32 [ 0, %1 ], [ %12, %8 ]
%18 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %17, double %0)
ret void
}