#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 */
double floor(double);
double log10(double);
double pow(int, double);
double size_round_off(double size, double median_size,
                      double log_size_increment) {
  double rat, lograt;
  if (size < .5)
    size = .5;
  rat = size / median_size;
  if (rat < 1e-3)
    rat = 1e-3;
  if (rat > 1e5)
    rat = 1e5;
  lograt = floor(log10(rat) / log_size_increment + .5);
  return (median_size * pow(10., lograt * log_size_increment));
}


x86 assembly (clang, -O0):
<size_round_off>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  0xeb1(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    1167 <size_round_off+0x37>
movsd  0xe9e(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe8a(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    1196 <size_round_off+0x66>
movsd  0xe77(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xe6d(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11ba <size_round_off+0x8a>
movsd  0xe5b(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1040 <log10@plt>
divsd  -0x18(%rbp),%xmm0
movsd  0xe2f(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1050 <floor@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
mov    $0xa,%edi
call   1030 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm1,%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<size_round_off>:
sub    $0x18,%rsp
movsd  %xmm2,0x8(%rsp)
movsd  %xmm1,0x10(%rsp)
movsd  0xeb8(%rip),%xmm3
maxsd  %xmm0,%xmm3
divsd  %xmm1,%xmm3
movsd  0xeb0(%rip),%xmm2
maxsd  %xmm3,%xmm2
movsd  0xeac(%rip),%xmm0
minsd  %xmm2,%xmm0
call   1040 <log10@plt>
divsd  0x8(%rsp),%xmm0
addsd  0xe85(%rip),%xmm0
call   1050 <floor@plt>
mulsd  0x8(%rsp),%xmm0
mov    $0xa,%edi
call   1030 <pow@plt>
mulsd  0x10(%rsp),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @size_round_off(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store double %0, double* %4
store double %1, double* %5
store double %2, double* %6
%9 = load double, double* %4
%10 = fcmp olt double %9, 5.000000e-01
br i1 %10, label %11, label %12
11: ; preds = %3
store double 5.000000e-01, double* %4
br label %12
12: ; preds = %11, %3
%13 = load double, double* %4
%14 = load double, double* %5
%15 = fdiv double %13, %14
store double %15, double* %7
%16 = load double, double* %7
%17 = fcmp olt double %16, 1.000000e-03
br i1 %17, label %18, label %19
18: ; preds = %12
store double 1.000000e-03, double* %7
br label %19
19: ; preds = %18, %12
%20 = load double, double* %7
%21 = fcmp ogt double %20, 1.000000e+05
br i1 %21, label %22, label %23
22: ; preds = %19
store double 1.000000e+05, double* %7
br label %23
23: ; preds = %22, %19
%24 = load double, double* %7
%25 = call double @log10(double %24)
%26 = load double, double* %6
%27 = fdiv double %25, %26
%28 = fadd double %27, 5.000000e-01
%29 = call double @llvm.floor.f64(double %28)
store double %29, double* %8
%30 = load double, double* %5
%31 = load double, double* %8
%32 = load double, double* %6
%33 = fmul double %31, %32
%34 = call double @pow(i32 10, double %33)
%35 = fmul double %30, %34
ret double %35
}

LLVM IR (-O2):
define double @size_round_off(double %0, double %1, double %2) {
%4 = fcmp olt double %0, 5.000000e-01
%5 = select i1 %4, double 5.000000e-01, double %0
%6 = fdiv double %5, %1
%7 = fcmp olt double %6, 1.000000e-03
%8 = select i1 %7, double 1.000000e-03, double %6
%9 = fcmp ogt double %8, 1.000000e+05
%10 = select i1 %9, double 1.000000e+05, double %8
%11 = tail call double @log10(double %10)
%12 = fdiv double %11, %2
%13 = fadd double %12, 5.000000e-01
%14 = tail call double @llvm.floor.f64(double %13)
%15 = fmul double %14, %2
%16 = tail call double @pow(i32 10, double %15)
%17 = fmul double %16, %1
ret double %17
}