#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 < 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  0xe96(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1195 <print_number+0x85>
movsd  0xe8b(%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    0xe6c(%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
movsd  0xed1(%rip),%xmm2
ucomisd %xmm1,%xmm2
jbe    115d <print_number+0x4d>
xor    %esi,%esi
movsd  0xec9(%rip),%xmm3
nop
mulsd  %xmm3,%xmm1
add    $0x1,%esi
ucomisd %xmm1,%xmm2
ja     1150 <print_number+0x40>
lea    0xebc(%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 = %15, %11
%13 = load double, double* %3
%14 = fcmp olt double %13, 1.000000e+02
br i1 %14, label %15, label %20
15: ; preds = %12
%16 = load double, double* %3
%17 = fmul double %16, 1.000000e+01
store double %17, double* %3
%18 = load i32, i32* %4
%19 = add nsw i32 %18, 1
store i32 %19, i32* %4
br label %12
20: ; preds = %12
%21 = load i32, i32* %4
%22 = load double, double* %2
%23 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %21, double %22)
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 olt double %4, 1.000000e+02
br i1 %5, label %6, label %12
6: ; preds = %1, %6
%7 = phi i32 [ %10, %6 ], [ 0, %1 ]
%8 = phi double [ %9, %6 ], [ %4, %1 ]
%9 = fmul double %8, 1.000000e+01
%10 = add nuw nsw i32 %7, 1
%11 = fcmp olt double %9, 1.000000e+02
br i1 %11, label %6, label %12
12: ; preds = %6, %1
%13 = phi i32 [ 0, %1 ], [ %10, %6 ]
%14 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %13, double %0)
ret void
}