#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);
PH(double PH) {
  double Q2, A = 0.05421, B = 1.23, C = -0.09873;
  if (PH >= 12) {
    return 3.0;
  } else if (PH < 2) {
    return 2.0;
  } else {
    Q2 = A * pow(PH, ((B * PH) + (C * pow(PH, 2)))) + 5.213;
    return Q2;
  }
}


x86 assembly (clang, -O0):
<PH>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  0xef3(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xede(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xec9(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xeaf(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1167 <PH+0x57>
movl   $0x3,-0x4(%rbp)
jmp    1217 <PH+0x107>
movsd  0xeb1(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1186 <PH+0x76>
movl   $0x2,-0x4(%rbp)
jmp    1217 <PH+0x107>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe5b(%rip),%xmm1
call   1030 <pow@plt>
movsd  -0x58(%rbp),%xmm2
movsd  -0x50(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm3
movaps %xmm0,%xmm4
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm4,%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
call   1030 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe22(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
cvttsd2si -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PH>:
push   %rax
mov    $0x3,%eax
ucomisd 0xee2(%rip),%xmm0
jae    116c <PH+0x5c>
mov    $0x2,%eax
movsd  0xedb(%rip),%xmm1
ucomisd %xmm0,%xmm1
ja     116c <PH+0x5c>
movapd %xmm0,%xmm2
mulsd  %xmm0,%xmm2
mulsd  0xecd(%rip),%xmm2
movsd  0xecd(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  %xmm2,%xmm1
call   1030 <pow@plt>
mulsd  0xec0(%rip),%xmm0
addsd  0xec0(%rip),%xmm0
cvttsd2si %xmm0,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @PH(double %0) {
%2 = alloca i32
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
store double %0, double* %3
store double 5.421000e-02, double* %5
store double 1.230000e+00, double* %6
store double 0xBFB9465E89225311, double* %7
%8 = load double, double* %3
%9 = fcmp oge double %8, 1.200000e+01
br i1 %9, label %10, label %11
10: ; preds = %1
store i32 3, i32* %2
br label %29
11: ; preds = %1
%12 = load double, double* %3
%13 = fcmp olt double %12, 2.000000e+00
br i1 %13, label %14, label %15
14: ; preds = %11
store i32 2, i32* %2
br label %29
15: ; preds = %11
%16 = load double, double* %5
%17 = load double, double* %3
%18 = load double, double* %6
%19 = load double, double* %3
%20 = load double, double* %7
%21 = load double, double* %3
%22 = call double @pow(double %21, double 2.000000e+00)
%23 = fmul double %20, %22
%24 = call double @llvm.fmuladd.f64(double %18, double %19, double %23)
%25 = call double @pow(double %17, double %24)
%26 = call double @llvm.fmuladd.f64(double %16, double %25, double 5.213000e+00)
store double %26, double* %4
%27 = load double, double* %4
%28 = fptosi double %27 to i32
store i32 %28, i32* %2
br label %29
29: ; preds = %15, %14, %10
%30 = load i32, i32* %2
ret i32 %30
}

LLVM IR (-O2):
define i32 @PH(double %0) {
%2 = fcmp ult double %0, 1.200000e+01
br i1 %2, label %3, label %12
3: ; preds = %1
%4 = fcmp olt double %0, 2.000000e+00
br i1 %4, label %12, label %5
5: ; preds = %3
%6 = fmul double %0, %0
%7 = fmul double %6, 0xBFB9465E89225311
%8 = tail call double @llvm.fmuladd.f64(double %0, double 1.230000e+00, double %7)
%9 = tail call double @pow(double %0, double %8)
%10 = tail call double @llvm.fmuladd.f64(double %9, double 5.421000e-02, double 5.213000e+00)
%11 = fptosi double %10 to i32
br label %12
12: ; preds = %3, %1, %5
%13 = phi i32 [ %11, %5 ], [ 3, %1 ], [ 2, %3 ]
ret i32 %13
}