#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 */
typedef double uint16_t;
typedef int uint;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
float sorh_to_relative_humidity(uint16_t sorh, float temperature,
                                uint rh_resolution) {
  float rh_linear, rh_true;
  if (rh_resolution == 8) {
    rh_linear = -2.0468 + 0.5872 * sorh + -0.00040845 * sorh * sorh;
    rh_true = (temperature - 25.0) * (0.01 + 0.00128 * sorh) + rh_linear;
  } else if (rh_resolution == 12) {
    rh_linear = -2.0468 + 0.0367 * sorh + -0.0000015966 * sorh * sorh;
    rh_true = (temperature - 25.0) * (0.01 + 0.00008 * sorh) + rh_linear;
  } else {
    printf("[ERROR] Relative humidity resolution must be 8 or 12 bit.  %d was "
           "selected.\n",
           rh_resolution);
    return -1;
  }
  return rh_true;
}


x86 assembly (clang, -O0):
<sorh_to_relative_humidity>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
movss  %xmm1,-0x14(%rbp)
mov    %edi,-0x18(%rbp)
cmpl   $0x8,-0x18(%rbp)
jne    11c0 <sorh_to_relative_humidity+0xb0>
movsd  -0x10(%rbp),%xmm1
movsd  0xf0c(%rip),%xmm0
mulsd  %xmm0,%xmm1
movsd  0xee8(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  0xeec(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe98(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  -0x10(%rbp),%xmm2
movsd  0xea7(%rip),%xmm1
mulsd  %xmm1,%xmm2
movsd  0xe73(%rip),%xmm1
addsd  %xmm1,%xmm2
movss  -0x1c(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
jmp    1281 <sorh_to_relative_humidity+0x171>
cmpl   $0xc,-0x18(%rbp)
jne    125b <sorh_to_relative_humidity+0x14b>
movsd  -0x10(%rbp),%xmm1
movsd  0xe51(%rip),%xmm0
mulsd  %xmm0,%xmm1
movsd  0xe4d(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  0xe31(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xdfd(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  -0x10(%rbp),%xmm2
movsd  0xddc(%rip),%xmm1
mulsd  %xmm1,%xmm2
movsd  0xdd8(%rip),%xmm1
addsd  %xmm1,%xmm2
movss  -0x1c(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
jmp    127c <sorh_to_relative_humidity+0x16c>
mov    -0x18(%rbp),%esi
lea    0xdeb(%rip),%rdi
call   1030 <printf@plt>
movss  0xd8e(%rip),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    128b <sorh_to_relative_humidity+0x17b>
jmp    1281 <sorh_to_relative_humidity+0x171>
movss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sorh_to_relative_humidity>:
push   %rax
cmp    $0xc,%edi
je     1166 <sorh_to_relative_humidity+0x56>
mov    %edi,%esi
cmp    $0x8,%edi
jne    11c9 <sorh_to_relative_humidity+0xb9>
movsd  0xf07(%rip),%xmm2
mulsd  %xmm0,%xmm2
addsd  0xed3(%rip),%xmm2
movsd  0xefb(%rip),%xmm3
mulsd  %xmm0,%xmm3
mulsd  %xmm0,%xmm3
addsd  %xmm2,%xmm3
xorps  %xmm2,%xmm2
cvtsd2ss %xmm3,%xmm2
cvtss2sd %xmm1,%xmm1
addsd  0xebc(%rip),%xmm1
mulsd  0xedc(%rip),%xmm0
jmp    11a9 <sorh_to_relative_humidity+0x99>
movsd  0xe92(%rip),%xmm2
mulsd  %xmm0,%xmm2
addsd  0xe8e(%rip),%xmm2
movsd  0xe8e(%rip),%xmm3
mulsd  %xmm0,%xmm3
mulsd  %xmm0,%xmm3
addsd  %xmm2,%xmm3
xorps  %xmm2,%xmm2
cvtsd2ss %xmm3,%xmm2
cvtss2sd %xmm1,%xmm1
addsd  0xe77(%rip),%xmm1
mulsd  0xe77(%rip),%xmm0
addsd  0xe77(%rip),%xmm0
mulsd  %xmm1,%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm2,%xmm1
addsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
pop    %rax
ret
lea    0xe7c(%rip),%rdi
call   1030 <printf@plt>
movss  0xe6b(%rip),%xmm0
pop    %rax
ret

LLVM IR (-O0):
@.str = [77 x i8] c"[ERROR] Relative humidity resolution must be 8 or 12 bit. %d was selected.\0A\00"
define float @sorh_to_relative_humidity(double %0, float %1, i32 %2) {
%4 = alloca float
%5 = alloca double
%6 = alloca float
%7 = alloca i32
%8 = alloca float
%9 = alloca float
store double %0, double* %5
store float %1, float* %6
store i32 %2, i32* %7
%10 = load i32, i32* %7
%11 = icmp eq i32 %10, 8
br i1 %11, label %12, label %29
12: ; preds = %3
%13 = load double, double* %5
%14 = call double @llvm.fmuladd.f64(double 5.872000e-01, double %13, double -2.046800e+00)
%15 = load double, double* %5
%16 = fmul double -4.084500e-04, %15
%17 = load double, double* %5
%18 = call double @llvm.fmuladd.f64(double %16, double %17, double %14)
%19 = fptrunc double %18 to float
store float %19, float* %8
%20 = load float, float* %6
%21 = fpext float %20 to double
%22 = fsub double %21, 2.500000e+01
%23 = load double, double* %5
%24 = call double @llvm.fmuladd.f64(double 1.280000e-03, double %23, double 1.000000e-02)
%25 = load float, float* %8
%26 = fpext float %25 to double
%27 = call double @llvm.fmuladd.f64(double %22, double %24, double %26)
%28 = fptrunc double %27 to float
store float %28, float* %9
br label %53
29: ; preds = %3
%30 = load i32, i32* %7
%31 = icmp eq i32 %30, 12
br i1 %31, label %32, label %49
32: ; preds = %29
%33 = load double, double* %5
%34 = call double @llvm.fmuladd.f64(double 3.670000e-02, double %33, double -2.046800e+00)
%35 = load double, double* %5
%36 = fmul double -1.596600e-06, %35
%37 = load double, double* %5
%38 = call double @llvm.fmuladd.f64(double %36, double %37, double %34)
%39 = fptrunc double %38 to float
store float %39, float* %8
%40 = load float, float* %6
%41 = fpext float %40 to double
%42 = fsub double %41, 2.500000e+01
%43 = load double, double* %5
%44 = call double @llvm.fmuladd.f64(double 8.000000e-05, double %43, double 1.000000e-02)
%45 = load float, float* %8
%46 = fpext float %45 to double
%47 = call double @llvm.fmuladd.f64(double %42, double %44, double %46)
%48 = fptrunc double %47 to float
store float %48, float* %9
br label %52
49: ; preds = %29
%50 = load i32, i32* %7
%51 = call i32 @printf(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str, i64 0, i64 0), i32 %50)
store float -1.000000e+00, float* %4
br label %55
52: ; preds = %32
br label %53
53: ; preds = %52, %12
%54 = load float, float* %9
store float %54, float* %4
br label %55
55: ; preds = %53, %49
%56 = load float, float* %4
ret float %56
}

LLVM IR (-O2):
@.str = [77 x i8] c"[ERROR] Relative humidity resolution must be 8 or 12 bit. %d was selected.\0A\00"
define float @sorh_to_relative_humidity(double %0, float %1, i32 %2) {
switch i32 %2, label %24 [
i32 8, label %4
i32 12, label %14
]
4: ; preds = %3
%5 = tail call double @llvm.fmuladd.f64(double %0, double 5.872000e-01, double -2.046800e+00)
%6 = fmul double %0, -4.084500e-04
%7 = tail call double @llvm.fmuladd.f64(double %6, double %0, double %5)
%8 = fptrunc double %7 to float
%9 = fpext float %1 to double
%10 = fadd double %9, -2.500000e+01
%11 = tail call double @llvm.fmuladd.f64(double %0, double 1.280000e-03, double 1.000000e-02)
%12 = fpext float %8 to double
%13 = tail call double @llvm.fmuladd.f64(double %10, double %11, double %12)
br label %26
14: ; preds = %3
%15 = tail call double @llvm.fmuladd.f64(double %0, double 3.670000e-02, double -2.046800e+00)
%16 = fmul double %0, -1.596600e-06
%17 = tail call double @llvm.fmuladd.f64(double %16, double %0, double %15)
%18 = fptrunc double %17 to float
%19 = fpext float %1 to double
%20 = fadd double %19, -2.500000e+01
%21 = tail call double @llvm.fmuladd.f64(double %0, double 8.000000e-05, double 1.000000e-02)
%22 = fpext float %18 to double
%23 = tail call double @llvm.fmuladd.f64(double %20, double %21, double %22)
br label %26
24: ; preds = %3
%25 = tail call i32 @printf(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str, i64 0, i64 0), i32 %2)
br label %29
26: ; preds = %14, %4
%27 = phi double [ %13, %4 ], [ %23, %14 ]
%28 = fptrunc double %27 to float
br label %29
29: ; preds = %26, %24
%30 = phi float [ %28, %26 ], [ -1.000000e+00, %24 ]
ret float %30
}