#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 DoubleFactorial(int);
double M_PI;
double PowerOfTwo(int);
double pow(double, double);
double sqrt(double);
double BoysAsymptotic(double x, int n) {
  double f = 0.0;
  if (x < 1.0e-9) {
    f = 1.0 / (2 * n + 1);
  } else {
    double a = DoubleFactorial(2 * n - 1);
    double b = PowerOfTwo(n + 1);
    double c = pow(x, (double)(2 * n + 1));
    double d = sqrt(M_PI / c);
    double e = a / b;
    f = d * e;
  }
  return f;
}


x86 assembly (clang, -O0):
<BoysAsymptotic>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xea0(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    118e <BoysAsymptotic+0x4e>
mov    -0xc(%rbp),%eax
shl    $0x1,%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm1
movsd  0xe88(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    1205 <BoysAsymptotic+0xc5>
mov    -0xc(%rbp),%edi
shl    $0x1,%edi
sub    $0x1,%edi
call   1030 <DoubleFactorial@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0xc(%rbp),%edi
add    $0x1,%edi
call   1040 <PowerOfTwo@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    -0xc(%rbp),%eax
shl    $0x1,%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm1
call   1050 <pow@plt>
movsd  %xmm0,-0x30(%rbp)
mov    0x2e14(%rip),%rax
movsd  (%rax),%xmm0
divsd  -0x30(%rbp),%xmm0
call   1060 <sqrt@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BoysAsymptotic>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %edi,%r14d
lea    (%r14,%r14,1),%ebx
movsd  0xeaa(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    1174 <BoysAsymptotic+0x34>
or     $0x1,%ebx
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
movsd  0xe9a(%rip),%xmm1
divsd  %xmm0,%xmm1
jmp    11e5 <BoysAsymptotic+0xa5>
lea    -0x1(%rbx),%edi
movsd  %xmm0,(%rsp)
call   1030 <DoubleFactorial@plt>
movsd  %xmm0,0x10(%rsp)
add    $0x1,%r14d
mov    %r14d,%edi
call   1040 <PowerOfTwo@plt>
movsd  %xmm0,0x8(%rsp)
or     $0x1,%ebx
xorps  %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
movsd  (%rsp),%xmm0
call   1050 <pow@plt>
movapd %xmm0,%xmm1
mov    0x2e30(%rip),%rax
movsd  (%rax),%xmm0
divsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11d0 <BoysAsymptotic+0x90>
sqrtsd %xmm0,%xmm0
jmp    11d5 <BoysAsymptotic+0x95>
call   1060 <sqrt@plt>
movsd  0x10(%rsp),%xmm1
divsd  0x8(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
define double @BoysAsymptotic(double %0, i32 %1) {
%3 = fcmp olt double %0, 1.000000e-09
%4 = shl nsw i32 %1, 1
br i1 %3, label %5, label %9
5: ; preds = %2
%6 = or i32 %4, 1
%7 = sitofp i32 %6 to double
%8 = fdiv double 1.000000e+00, %7
br label %22
9: ; preds = %2
%10 = add nsw i32 %4, -1
%11 = tail call double @DoubleFactorial(i32 %10)
%12 = add nsw i32 %1, 1
%13 = tail call double @PowerOfTwo(i32 %12)
%14 = or i32 %4, 1
%15 = sitofp i32 %14 to double
%16 = tail call double @pow(double %0, double %15)
%17 = load double, double* @M_PI
%18 = fdiv double %17, %16
%19 = tail call double @sqrt(double %18)
%20 = fdiv double %11, %13
%21 = fmul double %20, %19
br label %22
22: ; preds = %9, %5
%23 = phi double [ %8, %5 ], [ %21, %9 ]
ret double %23
}