#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*/ Log(int, char *, double);
double calculate_itu_mos(double rating) {
  double mos;
  Log(7, "Calculating ITU MOS with R: %.02f", rating);
  if (rating < 0) {
    mos = 1;
  } else if (rating > 100) {
    mos = 4.5;
  } else {
    mos = 1 + (0.035 * rating) +
          (rating * (rating - 60) * (100 - rating) * 7 * 0.000001);
  }
  return mos;
}


x86 assembly (clang, -O0):
<calculate_itu_mos>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    $0x7,%edi
lea    0xf0a(%rip),%rsi
call   1030 <Log@plt>
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    1153 <calculate_itu_mos+0x43>
movsd  0xedf(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    11ea <calculate_itu_mos+0xda>
movsd  -0x8(%rbp),%xmm0
movsd  0xea0(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    117c <calculate_itu_mos+0x6c>
movsd  0xebe(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    11e5 <calculate_itu_mos+0xd5>
movsd  -0x8(%rbp),%xmm1
movsd  0xe97(%rip),%xmm0
mulsd  %xmm0,%xmm1
movsd  0xe93(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  -0x8(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm2
movsd  0xe6d(%rip),%xmm3
subsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm0
movsd  0xe45(%rip),%xmm2
subsd  -0x8(%rbp),%xmm2
mulsd  %xmm2,%xmm0
movsd  0xe44(%rip),%xmm2
mulsd  %xmm2,%xmm0
movsd  0xe30(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    11ea <calculate_itu_mos+0xda>
movsd  -0x10(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calculate_itu_mos>:
push   %rax
movsd  %xmm0,(%rsp)
lea    0xf1b(%rip),%rsi
mov    $0x7,%edi
call   1030 <Log@plt>
movsd  (%rsp),%xmm3
xorpd  %xmm0,%xmm0
ucomisd %xmm3,%xmm0
jbe    1140 <calculate_itu_mos+0x30>
movsd  0xec2(%rip),%xmm0
pop    %rax
ret
ucomisd 0xec8(%rip),%xmm3
jbe    1154 <calculate_itu_mos+0x44>
movsd  0xeb6(%rip),%xmm0
pop    %rax
ret
movsd  0xebc(%rip),%xmm1
mulsd  %xmm3,%xmm1
addsd  0xe98(%rip),%xmm1
movsd  0xeb0(%rip),%xmm2
addsd  %xmm3,%xmm2
mulsd  %xmm3,%xmm2
movsd  0xe90(%rip),%xmm0
subsd  %xmm3,%xmm0
mulsd  %xmm2,%xmm0
mulsd  0xe98(%rip),%xmm0
mulsd  0xe98(%rip),%xmm0
addsd  %xmm1,%xmm0
pop    %rax
ret

LLVM IR (-O0):
@.str = [34 x i8] c"Calculating ITU MOS with R: %.02f\00"
define double @calculate_itu_mos(double %0) {
%2 = alloca double
%3 = alloca double
store double %0, double* %2
%4 = load double, double* %2
%5 = call i32 @Log(i32 7, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), double %4)
%6 = load double, double* %2
%7 = fcmp olt double %6, 0.000000e+00
br i1 %7, label %8, label %9
8: ; preds = %1
store double 1.000000e+00, double* %3
br label %26
9: ; preds = %1
%10 = load double, double* %2
%11 = fcmp ogt double %10, 1.000000e+02
br i1 %11, label %12, label %13
12: ; preds = %9
store double 4.500000e+00, double* %3
br label %25
13: ; preds = %9
%14 = load double, double* %2
%15 = call double @llvm.fmuladd.f64(double 3.500000e-02, double %14, double 1.000000e+00)
%16 = load double, double* %2
%17 = load double, double* %2
%18 = fsub double %17, 6.000000e+01
%19 = fmul double %16, %18
%20 = load double, double* %2
%21 = fsub double 1.000000e+02, %20
%22 = fmul double %19, %21
%23 = fmul double %22, 7.000000e+00
%24 = call double @llvm.fmuladd.f64(double %23, double 0x3EB0C6F7A0B5ED8D, double %15)
store double %24, double* %3
br label %25
25: ; preds = %13, %12
br label %26
26: ; preds = %25, %8
%27 = load double, double* %3
ret double %27
}

LLVM IR (-O2):
@.str = [34 x i8] c"Calculating ITU MOS with R: %.02f\00"
define double @calculate_itu_mos(double %0) {
%2 = tail call i32 @Log(i32 7, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), double %0)
%3 = fcmp olt double %0, 0.000000e+00
br i1 %3, label %14, label %4
4: ; preds = %1
%5 = fcmp ogt double %0, 1.000000e+02
br i1 %5, label %14, label %6
6: ; preds = %4
%7 = tail call double @llvm.fmuladd.f64(double %0, double 3.500000e-02, double 1.000000e+00)
%8 = fadd double %0, -6.000000e+01
%9 = fmul double %8, %0
%10 = fsub double 1.000000e+02, %0
%11 = fmul double %10, %9
%12 = fmul double %11, 7.000000e+00
%13 = tail call double @llvm.fmuladd.f64(double %12, double 0x3EB0C6F7A0B5ED8D, double %7)
br label %14
14: ; preds = %4, %1, %6
%15 = phi double [ %13, %6 ], [ 1.000000e+00, %1 ], [ 4.500000e+00, %4 ]
ret double %15
}