#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 exp(int);
double ratio_to_val(double value) {
  double x = 0.0;
  if (value <= 484.0) {
    x = value / 484.0;
    x = exp(2. * 2.302585093 * (x * 484.0 - 10.) / 484.0);
    x = ((int)((x + 0.05) * 10)) / 10.0;
  } else if (value >= 516.0) {
    x = (1000.0 - value) / 484.0;
    x = exp(2. * 2.302585093 * (x * 484.0 - 10.) / 484.0);
    x = ((int)((x + 0.05) * 10)) / 10.0;
  } else {
    x = 10000.0;
  }
  return x;
}


x86 assembly (clang, -O0):
<ratio_to_val>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movsd  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xed3(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jb     11c8 <ratio_to_val+0xb8>
movsd  -0x8(%rbp),%xmm0
movsd  0xebb(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm1
movsd  0xea5(%rip),%xmm0
mulsd  %xmm0,%xmm1
movsd  0xec9(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  0xeb5(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe81(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <exp@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  0xe87(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  0xe72(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
cvtsi2sd %eax,%xmm0
movsd  0xe5e(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    1289 <ratio_to_val+0x179>
movsd  -0x8(%rbp),%xmm0
movsd  0xe33(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1277 <ratio_to_val+0x167>
movsd  0xe51(%rip),%xmm0
subsd  -0x8(%rbp),%xmm0
movsd  0xe0c(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm1
movsd  0xdf6(%rip),%xmm0
mulsd  %xmm0,%xmm1
movsd  0xe1a(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  0xe06(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xdd2(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <exp@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  0xdd8(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  0xdc3(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
cvtsi2sd %eax,%xmm0
movsd  0xdaf(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    1284 <ratio_to_val+0x174>
movsd  0xd91(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    1289 <ratio_to_val+0x179>
movsd  -0x10(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ratio_to_val>:
push   %rax
movsd  0xee7(%rip),%xmm1
ucomisd %xmm0,%xmm1
jae    1143 <ratio_to_val+0x33>
ucomisd 0xee9(%rip),%xmm0
jae    1133 <ratio_to_val+0x23>
movsd  0xed7(%rip),%xmm0
pop    %rax
ret
movsd  0xedd(%rip),%xmm2
subsd  %xmm0,%xmm2
movapd %xmm2,%xmm0
divsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
addsd  0xecd(%rip),%xmm0
mulsd  0xecd(%rip),%xmm0
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <exp@plt>
addsd  0xec0(%rip),%xmm0
movsd  0xec0(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttpd2dq %xmm0,%xmm0
cvtdq2pd %xmm0,%xmm0
divsd  %xmm1,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define double @ratio_to_val(double %0) {
%2 = alloca double
%3 = alloca double
store double %0, double* %2
store double 0.000000e+00, double* %3
%4 = load double, double* %2
%5 = fcmp ole double %4, 4.840000e+02
br i1 %5, label %6, label %21
6: ; preds = %1
%7 = load double, double* %2
%8 = fdiv double %7, 4.840000e+02
store double %8, double* %3
%9 = load double, double* %3
%10 = call double @llvm.fmuladd.f64(double %9, double 4.840000e+02, double -1.000000e+01)
%11 = fmul double 0x40126BB1BBB58975, %10
%12 = fdiv double %11, 4.840000e+02
%13 = fptosi double %12 to i32
%14 = call double @exp(i32 %13)
store double %14, double* %3
%15 = load double, double* %3
%16 = fadd double %15, 5.000000e-02
%17 = fmul double %16, 1.000000e+01
%18 = fptosi double %17 to i32
%19 = sitofp i32 %18 to double
%20 = fdiv double %19, 1.000000e+01
store double %20, double* %3
br label %42
21: ; preds = %1
%22 = load double, double* %2
%23 = fcmp oge double %22, 5.160000e+02
br i1 %23, label %24, label %40
24: ; preds = %21
%25 = load double, double* %2
%26 = fsub double 1.000000e+03, %25
%27 = fdiv double %26, 4.840000e+02
store double %27, double* %3
%28 = load double, double* %3
%29 = call double @llvm.fmuladd.f64(double %28, double 4.840000e+02, double -1.000000e+01)
%30 = fmul double 0x40126BB1BBB58975, %29
%31 = fdiv double %30, 4.840000e+02
%32 = fptosi double %31 to i32
%33 = call double @exp(i32 %32)
store double %33, double* %3
%34 = load double, double* %3
%35 = fadd double %34, 5.000000e-02
%36 = fmul double %35, 1.000000e+01
%37 = fptosi double %36 to i32
%38 = sitofp i32 %37 to double
%39 = fdiv double %38, 1.000000e+01
store double %39, double* %3
br label %41
40: ; preds = %21
store double 1.000000e+04, double* %3
br label %41
41: ; preds = %40, %24
br label %42
42: ; preds = %41, %6
%43 = load double, double* %3
ret double %43
}

LLVM IR (-O2):
define double @ratio_to_val(double %0) {
%2 = fcmp ugt double %0, 4.840000e+02
br i1 %2, label %3, label %7
3: ; preds = %1
%4 = fcmp ult double %0, 5.160000e+02
br i1 %4, label %20, label %5
5: ; preds = %3
%6 = fsub double 1.000000e+03, %0
br label %7
7: ; preds = %1, %5
%8 = phi double [ %6, %5 ], [ %0, %1 ]
%9 = fdiv double %8, 4.840000e+02
%10 = tail call double @llvm.fmuladd.f64(double %9, double 4.840000e+02, double -1.000000e+01)
%11 = fmul double %10, 0x40126BB1BBB58975
%12 = fdiv double %11, 4.840000e+02
%13 = fptosi double %12 to i32
%14 = tail call double @exp(i32 %13)
%15 = fadd double %14, 5.000000e-02
%16 = fmul double %15, 1.000000e+01
%17 = fptosi double %16 to i32
%18 = sitofp i32 %17 to double
%19 = fdiv double %18, 1.000000e+01
br label %20
20: ; preds = %7, %3
%21 = phi double [ 1.000000e+04, %3 ], [ %19, %7 ]
ret double %21
}