#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 exp(double const);
double sqrt(int);
double find_rayleigh_peirce_limit(const double a, const double b,
                                  const double log_P, const int n) {
  const double log_R = -.5;
  const double tval = exp(b * (log_P - (double)n * log_R));
  return (sqrt(1. + a * (1 - tval)));
}


x86 assembly (clang, -O0):
<find_rayleigh_peirce_limit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
mov    %edi,-0x1c(%rbp)
movsd  0xec6(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
cvtsi2sdl -0x1c(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  0xe93(%rip),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
call   1030 <exp@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xe68(%rip),%xmm1
subsd  -0x30(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe57(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sqrt@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_rayleigh_peirce_limit>:
push   %rax
movsd  %xmm0,(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %edi,%xmm0
mulsd  0xecb(%rip),%xmm0
addsd  %xmm2,%xmm0
mulsd  %xmm1,%xmm0
call   1030 <exp@plt>
movsd  0xebe(%rip),%xmm1
movapd %xmm1,%xmm2
subsd  %xmm0,%xmm2
mulsd  (%rsp),%xmm2
addsd  %xmm1,%xmm2
cvttsd2si %xmm2,%edi
pop    %rax
jmp    1040 <sqrt@plt>

LLVM IR (-O0):
define double @find_rayleigh_peirce_limit(double %0, double %1, double %2, i32 %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca i32
%9 = alloca double
%10 = alloca double
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
store i32 %3, i32* %8
store double -5.000000e-01, double* %9
%11 = load double, double* %6
%12 = load double, double* %7
%13 = load i32, i32* %8
%14 = sitofp i32 %13 to double
%15 = fneg double %14
%16 = call double @llvm.fmuladd.f64(double %15, double -5.000000e-01, double %12)
%17 = fmul double %11, %16
%18 = call double @exp(double %17)
store double %18, double* %10
%19 = load double, double* %5
%20 = load double, double* %10
%21 = fsub double 1.000000e+00, %20
%22 = call double @llvm.fmuladd.f64(double %19, double %21, double 1.000000e+00)
%23 = fptosi double %22 to i32
%24 = call double @sqrt(i32 %23)
ret double %24
}

LLVM IR (-O2):
define double @find_rayleigh_peirce_limit(double %0, double %1, double %2, i32 %3) {
%5 = sitofp i32 %3 to double
%6 = fneg double %5
%7 = tail call double @llvm.fmuladd.f64(double %6, double -5.000000e-01, double %2)
%8 = fmul double %7, %1
%9 = tail call double @exp(double %8)
%10 = fsub double 1.000000e+00, %9
%11 = tail call double @llvm.fmuladd.f64(double %0, double %10, double 1.000000e+00)
%12 = fptosi double %11 to i32
%13 = tail call double @sqrt(i32 %12)
ret double %13
}