#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 pow(double, double);
double quality_to_mse(long quality) {
  if (quality == 0) {
    return 1e20;
  }
  if (quality == 100) {
    return 0;
  }
  const double extra_low_quality_fudge =
      ((0) > (0.016 / (0.001 + quality) - 0.001)
           ? (0)
           : (0.016 / (0.001 + quality) - 0.001));
  return extra_low_quality_fudge +
         2.5 / pow(210.0 + quality, 1.2) * (100.1 - quality) / 100.0;
}


x86 assembly (clang, -O0):
<quality_to_mse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1139 <quality_to_mse+0x29>
movsd  0xf09(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1236 <quality_to_mse+0x126>
cmpq   $0x64,-0x10(%rbp)
jne    1151 <quality_to_mse+0x41>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1236 <quality_to_mse+0x126>
cvtsi2sdq -0x10(%rbp),%xmm1
movsd  0xea1(%rip),%xmm0
addsd  %xmm1,%xmm0
movsd  0xe9d(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  0xe89(%rip),%xmm0
subsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    1195 <quality_to_mse+0x85>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11c4 <quality_to_mse+0xb4>
cvtsi2sdq -0x10(%rbp),%xmm0
movsd  0xe5d(%rip),%xmm1
addsd  %xmm0,%xmm1
movsd  0xe59(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  0xe45(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
cvtsi2sdq -0x10(%rbp),%xmm1
movsd  0xe4a(%rip),%xmm0
addsd  %xmm1,%xmm0
movsd  0xe36(%rip),%xmm1
call   1030 <pow@plt>
movaps %xmm0,%xmm2
movsd  -0x28(%rbp),%xmm0
movsd  0xe19(%rip),%xmm1
divsd  %xmm2,%xmm1
cvtsi2sdq -0x10(%rbp),%xmm3
movsd  0xdff(%rip),%xmm2
subsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm1
movsd  0xde7(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<quality_to_mse>:
sub    $0x18,%rsp
test   %rdi,%rdi
je     1127 <quality_to_mse+0x17>
cmp    $0x64,%rdi
jne    1134 <quality_to_mse+0x24>
xorps  %xmm0,%xmm0
add    $0x18,%rsp
ret
movsd  0xed1(%rip),%xmm0
add    $0x18,%rsp
ret
cvtsi2sd %rdi,%xmm1
movsd  0xec7(%rip),%xmm0
addsd  %xmm1,%xmm0
movapd %xmm1,%xmm2
movsd  %xmm1,0x8(%rsp)
movsd  0xeb9(%rip),%xmm1
divsd  %xmm0,%xmm1
addsd  0xeb5(%rip),%xmm1
xorpd  %xmm0,%xmm0
maxsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0xea7(%rip),%xmm0
addsd  %xmm2,%xmm0
movsd  0xea3(%rip),%xmm1
call   1030 <pow@plt>
movsd  0xe9e(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  0xe9a(%rip),%xmm0
subsd  0x8(%rsp),%xmm0
mulsd  %xmm1,%xmm0
divsd  0xe90(%rip),%xmm0
addsd  0x10(%rsp),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @quality_to_mse(i64 %0) {
%2 = alloca double
%3 = alloca i64
%4 = alloca double
store i64 %0, i64* %3
%5 = load i64, i64* %3
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %1
store double 1.000000e+20, double* %2
br label %40
8: ; preds = %1
%9 = load i64, i64* %3
%10 = icmp eq i64 %9, 100
br i1 %10, label %11, label %12
11: ; preds = %8
store double 0.000000e+00, double* %2
br label %40
12: ; preds = %8
%13 = load i64, i64* %3
%14 = sitofp i64 %13 to double
%15 = fadd double 1.000000e-03, %14
%16 = fdiv double 1.600000e-02, %15
%17 = fsub double %16, 1.000000e-03
%18 = fcmp ogt double 0.000000e+00, %17
br i1 %18, label %19, label %20
19: ; preds = %12
br label %26
20: ; preds = %12
%21 = load i64, i64* %3
%22 = sitofp i64 %21 to double
%23 = fadd double 1.000000e-03, %22
%24 = fdiv double 1.600000e-02, %23
%25 = fsub double %24, 1.000000e-03
br label %26
26: ; preds = %20, %19
%27 = phi double [ 0.000000e+00, %19 ], [ %25, %20 ]
store double %27, double* %4
%28 = load double, double* %4
%29 = load i64, i64* %3
%30 = sitofp i64 %29 to double
%31 = fadd double 2.100000e+02, %30
%32 = call double @pow(double %31, double 1.200000e+00)
%33 = fdiv double 2.500000e+00, %32
%34 = load i64, i64* %3
%35 = sitofp i64 %34 to double
%36 = fsub double 1.001000e+02, %35
%37 = fmul double %33, %36
%38 = fdiv double %37, 1.000000e+02
%39 = fadd double %28, %38
store double %39, double* %2
br label %40
40: ; preds = %26, %11, %7
%41 = load double, double* %2
ret double %41
}

LLVM IR (-O2):
define double @quality_to_mse(i64 %0) {
switch i64 %0, label %3 [
i64 0, label %17
i64 100, label %2
]
2: ; preds = %1
br label %17
3: ; preds = %1
%4 = sitofp i64 %0 to double
%5 = fadd double %4, 1.000000e-03
%6 = fdiv double 1.600000e-02, %5
%7 = fadd double %6, -1.000000e-03
%8 = fcmp olt double %7, 0.000000e+00
%9 = select i1 %8, double 0.000000e+00, double %7
%10 = fadd double %4, 2.100000e+02
%11 = tail call double @pow(double %10, double 1.200000e+00)
%12 = fdiv double 2.500000e+00, %11
%13 = fsub double 1.001000e+02, %4
%14 = fmul double %13, %12
%15 = fdiv double %14, 1.000000e+02
%16 = fadd double %9, %15
br label %17
17: ; preds = %1, %3, %2
%18 = phi double [ 0.000000e+00, %2 ], [ %16, %3 ], [ 1.000000e+20, %1 ]
ret double %18
}