#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 const, double const);
double const sqrt(double const);
double fk(const double p, const double pk, const double Ak, const double Bk,
          const double ak, const double z, const double g) {
  if (p > pk) {
    return (p - pk) * sqrt(Ak / (p + Bk));
  } else {
    return 2 * ak / (g - 1) * (pow(p / pk, z) - 1);
  }
}


x86 assembly (clang, -O0):
<fk>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
movsd  %xmm4,-0x30(%rbp)
movsd  %xmm5,-0x38(%rbp)
movsd  %xmm6,-0x40(%rbp)
movsd  -0x10(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    1198 <fk+0x78>
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
addsd  -0x28(%rbp),%xmm1
divsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11e8 <fk+0xc8>
movsd  0xe68(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
movsd  0xe4e(%rip),%xmm2
subsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x10(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
call   1030 <pow@plt>
movsd  -0x50(%rbp),%xmm0
sub    $0x1,%eax
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fk>:
push   %rax
ucomisd %xmm1,%xmm0
jbe    114a <fk+0x2a>
movapd %xmm0,%xmm4
subsd  %xmm1,%xmm4
addsd  %xmm0,%xmm3
divsd  %xmm3,%xmm2
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm2
jb     117d <fk+0x5d>
xorps  %xmm0,%xmm0
sqrtsd %xmm2,%xmm0
jmp    1190 <fk+0x70>
addsd  %xmm4,%xmm4
addsd  0xeaa(%rip),%xmm6
divsd  %xmm6,%xmm4
movsd  %xmm4,(%rsp)
divsd  %xmm1,%xmm0
movapd %xmm5,%xmm1
call   1030 <pow@plt>
add    $0xffffffff,%eax
xorps  %xmm4,%xmm4
cvtsi2sd %eax,%xmm4
mulsd  (%rsp),%xmm4
jmp    1194 <fk+0x74>
movapd %xmm2,%xmm0
movsd  %xmm4,(%rsp)
call   1040 <sqrt@plt>
movsd  (%rsp),%xmm4
mulsd  %xmm0,%xmm4
movapd %xmm4,%xmm0
pop    %rax
ret

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

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