#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 pow(double, double);
double sqrt(double);
double Unilateral_PF(double p_star, double p, double density) {
  if (p_star > p) {
    return (p_star - p) /
           (density * (sqrt((p / density) * (0.5 * (1.4 + 1) * (p_star / p) +
                                             0.5 * (1.4 - 1)))));
  } else {
    return (2.0 / (1.4 - 1)) * sqrt(1.4 * p / density) *
           (pow((p_star / p), (1.4 - 1) / (2 * 1.4)) - 1);
  }
}


x86 assembly (clang, -O0):
<Unilateral_PF>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    11b4 <Unilateral_PF+0x94>
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
divsd  -0x18(%rbp),%xmm1
movsd  0xe9c(%rip),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xe98(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
movsd  -0x30(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x28(%rbp),%xmm0
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    120b <Unilateral_PF+0xeb>
movsd  0xe54(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  0xe32(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
movsd  0xe0f(%rip),%xmm1
call   1030 <pow@plt>
movsd  -0x38(%rbp),%xmm0
sub    $0x1,%eax
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Unilateral_PF>:
sub    $0x18,%rsp
movapd %xmm0,%xmm4
ucomisd %xmm1,%xmm0
jbe    1165 <Unilateral_PF+0x45>
movapd %xmm4,%xmm3
subsd  %xmm1,%xmm3
divsd  %xmm1,%xmm4
divsd  %xmm2,%xmm1
mulsd  0xed2(%rip),%xmm4
addsd  0xed2(%rip),%xmm4
mulsd  %xmm1,%xmm4
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm4
jb     1185 <Unilateral_PF+0x65>
xorps  %xmm0,%xmm0
sqrtsd %xmm4,%xmm0
jmp    11a6 <Unilateral_PF+0x86>
movsd  0xe93(%rip),%xmm0
mulsd  %xmm1,%xmm0
divsd  %xmm2,%xmm0
xorpd  %xmm3,%xmm3
ucomisd %xmm3,%xmm0
jb     11b0 <Unilateral_PF+0x90>
sqrtsd %xmm0,%xmm0
jmp    11cd <Unilateral_PF+0xad>
movapd %xmm4,%xmm0
movsd  %xmm2,0x8(%rsp)
movsd  %xmm3,0x10(%rsp)
call   1040 <sqrt@plt>
movsd  0x10(%rsp),%xmm3
movsd  0x8(%rsp),%xmm2
mulsd  %xmm2,%xmm0
divsd  %xmm0,%xmm3
jmp    1200 <Unilateral_PF+0xe0>
movsd  %xmm4,0x8(%rsp)
movsd  %xmm1,0x10(%rsp)
call   1040 <sqrt@plt>
movsd  0x10(%rsp),%xmm1
movsd  0x8(%rsp),%xmm4
mulsd  0xe33(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
divsd  %xmm1,%xmm4
movsd  0xe29(%rip),%xmm1
movapd %xmm4,%xmm0
call   1030 <pow@plt>
add    $0xffffffff,%eax
xorps  %xmm3,%xmm3
cvtsi2sd %eax,%xmm3
mulsd  0x8(%rsp),%xmm3
movapd %xmm3,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @Unilateral_PF(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
%8 = load double, double* %5
%9 = load double, double* %6
%10 = fcmp ogt double %8, %9
br i1 %10, label %11, label %27
11: ; preds = %3
%12 = load double, double* %5
%13 = load double, double* %6
%14 = fsub double %12, %13
%15 = load double, double* %7
%16 = load double, double* %6
%17 = load double, double* %7
%18 = fdiv double %16, %17
%19 = load double, double* %5
%20 = load double, double* %6
%21 = fdiv double %19, %20
%22 = call double @llvm.fmuladd.f64(double 1.200000e+00, double %21, double 0x3FC9999999999998)
%23 = fmul double %18, %22
%24 = call double @sqrt(double %23)
%25 = fmul double %15, %24
%26 = fdiv double %14, %25
store double %26, double* %4
br label %41
27: ; preds = %3
%28 = load double, double* %6
%29 = fmul double 1.400000e+00, %28
%30 = load double, double* %7
%31 = fdiv double %29, %30
%32 = call double @sqrt(double %31)
%33 = fmul double 0x4014000000000001, %32
%34 = load double, double* %5
%35 = load double, double* %6
%36 = fdiv double %34, %35
%37 = call i32 @pow(double %36, double 0x3FC2492492492491)
%38 = sub nsw i32 %37, 1
%39 = sitofp i32 %38 to double
%40 = fmul double %33, %39
store double %40, double* %4
br label %41
41: ; preds = %27, %11
%42 = load double, double* %4
ret double %42
}

LLVM IR (-O2):
define double @Unilateral_PF(double %0, double %1, double %2) {
%4 = fcmp ogt double %0, %1
br i1 %4, label %5, label %14
5: ; preds = %3
%6 = fsub double %0, %1
%7 = fdiv double %1, %2
%8 = fdiv double %0, %1
%9 = tail call double @llvm.fmuladd.f64(double %8, double 1.200000e+00, double 0x3FC9999999999998)
%10 = fmul double %7, %9
%11 = tail call double @sqrt(double %10)
%12 = fmul double %11, %2
%13 = fdiv double %6, %12
br label %24
14: ; preds = %3
%15 = fmul double %1, 1.400000e+00
%16 = fdiv double %15, %2
%17 = tail call double @sqrt(double %16)
%18 = fmul double %17, 0x4014000000000001
%19 = fdiv double %0, %1
%20 = tail call i32 @pow(double %19, double 0x3FC2492492492491)
%21 = add nsw i32 %20, -1
%22 = sitofp i32 %21 to double
%23 = fmul double %18, %22
br label %24
24: ; preds = %14, %5
%25 = phi double [ %13, %5 ], [ %23, %14 ]
ret double %25
}