#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 M_PI;
double cos(double);
double sqrt(double const);
double modified_plgndr_a(int l, int m, double t) {
  int i, ll;
  double x, fact1, fact2, fact, pll, pmm, pmmp1, somx2, plgndr;
  const double three = 3.0;
  const double two = 2.0;
  const double one = 1.0;
  x = cos(t);
  pmm = one;
  if (m > 0) {
    somx2 = sqrt((one - x) * (one + x));
    fact1 = three;
    fact2 = two;
    for (i = 1; i <= m; i++) {
      fact = sqrt(fact1 / fact2);
      pmm = -pmm * fact * somx2;
      fact1 += two;
      fact2 += two;
    }
  }
  if (l == m)
    plgndr = pmm;
  else {
    pmmp1 = x * sqrt(two * m + three) * pmm;
    if (l == m + 1)
      plgndr = pmmp1;
    else {
      for (ll = m + 2; ll <= l; ll++) {
        fact1 =
            sqrt((4.0 * ll * ll - one) * (double)(ll - m) / (double)(ll + m));
        fact2 = sqrt((2.0 * ll + one) * (ll - m) * (ll + m - one) *
                     (ll - m - one) / (double)((two * ll - three) * (ll + m)));
        pll = (x * fact1 * pmmp1 - fact2 * pmm) / (ll - m);
        pmm = pmmp1;
        pmmp1 = pll;
      }
      plgndr = pll;
    }
  }
  plgndr /= sqrt(4.0 * M_PI);
  if (m != 0)
    plgndr *= sqrt(two);
  return plgndr;
}


x86 assembly (clang, -O0):
<modified_plgndr_a>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  0xed2(%rip),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  0xebd(%rip),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  0xea8(%rip),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <cos@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  0xe8c(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    124e <modified_plgndr_a+0x12e>
movsd  0xe75(%rip),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  0xe68(%rip),%xmm1
addsd  -0x20(%rbp),%xmm1
mulsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  0xe5d(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe48(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     1249 <modified_plgndr_a+0x129>
movsd  -0x28(%rbp),%xmm0
divsd  -0x30(%rbp),%xmm0
call   1040 <sqrt@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x48(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x38(%rbp),%xmm0
mulsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xde9(%rip),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xdd7(%rip),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11cc <modified_plgndr_a+0xac>
jmp    124e <modified_plgndr_a+0x12e>
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    1269 <modified_plgndr_a+0x149>
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
jmp    1428 <modified_plgndr_a+0x308>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
cvtsi2sdl -0x8(%rbp),%xmm0
addsd  %xmm0,%xmm0
movsd  0xd8c(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x80(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x4(%rbp),%eax
mov    -0x8(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jne    12c3 <modified_plgndr_a+0x1a3>
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
jmp    1423 <modified_plgndr_a+0x303>
mov    -0x8(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     1419 <modified_plgndr_a+0x2f9>
cvtsi2sdl -0x18(%rbp),%xmm1
movsd  0xd43(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x18(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd26(%rip),%xmm1
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%eax
sub    -0x8(%rbp),%eax
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
mov    -0x18(%rbp),%eax
add    -0x8(%rbp),%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
movsd  %xmm0,-0x28(%rbp)
cvtsi2sdl -0x18(%rbp),%xmm0
addsd  %xmm0,%xmm0
movsd  0xccb(%rip),%xmm1
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%eax
sub    -0x8(%rbp),%eax
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
mov    -0x18(%rbp),%eax
add    -0x8(%rbp),%eax
cvtsi2sd %eax,%xmm1
movsd  0xca7(%rip),%xmm2
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
mov    -0x18(%rbp),%eax
sub    -0x8(%rbp),%eax
cvtsi2sd %eax,%xmm1
movsd  0xc8d(%rip),%xmm2
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x18(%rbp),%xmm1
addsd  %xmm1,%xmm1
movsd  0xc8c(%rip),%xmm2
addsd  %xmm2,%xmm1
mov    -0x18(%rbp),%eax
add    -0x8(%rbp),%eax
cvtsi2sd %eax,%xmm2
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm1
mulsd  -0x48(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%eax
sub    -0x8(%rbp),%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    12cc <modified_plgndr_a+0x1ac>
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
jmp    1428 <modified_plgndr_a+0x308>
movsd  0xbf8(%rip),%xmm0
mov    0x2bb1(%rip),%rax
mulsd  (%rax),%xmm0
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1472 <modified_plgndr_a+0x352>
movsd  0xba5(%rip),%xmm0
call   1040 <sqrt@plt>
mulsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<modified_plgndr_a>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x68,%rsp
mov    %esi,%r15d
mov    %edi,%r14d
call   1030 <cos@plt>
test   %r15d,%r15d
movsd  %xmm0,0x48(%rsp)
movsd  0xeba(%rip),%xmm2
jle    12ee <modified_plgndr_a+0x1ce>
movapd %xmm2,%xmm1
subsd  %xmm0,%xmm1
addsd  %xmm2,%xmm0
mulsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     116c <modified_plgndr_a+0x4c>
sqrtsd %xmm0,%xmm0
jmp    1179 <modified_plgndr_a+0x59>
call   1040 <sqrt@plt>
movsd  0xe87(%rip),%xmm2
movapd %xmm0,(%rsp)
cmp    $0x1,%r15d
jne    11bc <modified_plgndr_a+0x9c>
movapd 0xea4(%rip),%xmm3
test   $0x1,%r15b
je     12ee <modified_plgndr_a+0x1ce>
movapd %xmm3,%xmm0
unpckhpd %xmm3,%xmm0
divsd  %xmm0,%xmm3
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm3
jb     12c8 <modified_plgndr_a+0x1a8>
xorps  %xmm0,%xmm0
sqrtsd %xmm3,%xmm0
jmp    12dd <modified_plgndr_a+0x1bd>
mov    %r15d,%ebx
and    $0xfffffffe,%ebx
movapd 0xe76(%rip),%xmm0
xorpd  (%rsp),%xmm0
movapd %xmm0,0x50(%rsp)
movapd 0xe53(%rip),%xmm3
movsd  0xe1b(%rip),%xmm6
xorpd  %xmm4,%xmm4
movapd 0xe5f(%rip),%xmm5
jmp    125b <modified_plgndr_a+0x13b>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movapd %xmm2,0x10(%rsp)
movapd %xmm3,0x20(%rsp)
call   1040 <sqrt@plt>
movapd 0xe37(%rip),%xmm5
xorpd  %xmm4,%xmm4
movapd 0x20(%rsp),%xmm3
movapd 0x10(%rsp),%xmm2
movapd 0x30(%rsp),%xmm1
xorpd  0xe09(%rip),%xmm1
mulsd  %xmm1,%xmm2
mulsd  0x50(%rsp),%xmm2
mulsd  %xmm0,%xmm2
mulsd  (%rsp),%xmm2
addpd  %xmm5,%xmm3
movapd %xmm2,%xmm6
add    $0xfffffffe,%ebx
je     118c <modified_plgndr_a+0x6c>
movapd %xmm3,%xmm1
unpckhpd %xmm3,%xmm1
movapd %xmm3,%xmm0
divsd  %xmm1,%xmm0
ucomisd %xmm4,%xmm0
movapd %xmm6,0x30(%rsp)
jb     1280 <modified_plgndr_a+0x160>
xorps  %xmm2,%xmm2
sqrtsd %xmm0,%xmm2
jmp    12a1 <modified_plgndr_a+0x181>
movapd %xmm3,0x20(%rsp)
call   1040 <sqrt@plt>
movapd 0xdbd(%rip),%xmm5
xorpd  %xmm4,%xmm4
movapd 0x20(%rsp),%xmm3
movapd %xmm0,%xmm2
addpd  %xmm5,%xmm3
movapd %xmm3,%xmm1
unpckhpd %xmm3,%xmm1
movapd %xmm3,%xmm0
divsd  %xmm1,%xmm0
ucomisd %xmm4,%xmm0
jb     1200 <modified_plgndr_a+0xe0>
sqrtsd %xmm0,%xmm0
jmp    1229 <modified_plgndr_a+0x109>
movapd %xmm3,%xmm0
movapd %xmm2,0x10(%rsp)
call   1040 <sqrt@plt>
movapd 0x10(%rsp),%xmm2
xorpd  0xd5b(%rip),%xmm2
mulsd  %xmm0,%xmm2
mulsd  (%rsp),%xmm2
cmp    %r15d,%r14d
jne    12f9 <modified_plgndr_a+0x1d9>
movapd %xmm2,%xmm3
jmp    1351 <modified_plgndr_a+0x231>
xorps  %xmm0,%xmm0
cvtsi2sd %r15d,%xmm0
addsd  %xmm0,%xmm0
addsd  0xcfb(%rip),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1320 <modified_plgndr_a+0x200>
xorps  %xmm3,%xmm3
sqrtsd %xmm0,%xmm3
jmp    1335 <modified_plgndr_a+0x215>
movapd %xmm2,0x10(%rsp)
call   1040 <sqrt@plt>
movapd 0x10(%rsp),%xmm2
movapd %xmm0,%xmm3
mulsd  0x48(%rsp),%xmm3
mulsd  %xmm2,%xmm3
lea    0x1(%r15),%eax
cmp    %r14d,%eax
je     1351 <modified_plgndr_a+0x231>
lea    0x2(%r15),%eax
cmp    %r14d,%eax
jle    13a3 <modified_plgndr_a+0x283>
mov    0x2c90(%rip),%rax
movsd  (%rax),%xmm0
mulsd  0xcac(%rip),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1374 <modified_plgndr_a+0x254>
sqrtsd %xmm0,%xmm0
jmp    1383 <modified_plgndr_a+0x263>
movsd  %xmm3,(%rsp)
call   1040 <sqrt@plt>
movsd  (%rsp),%xmm3
divsd  %xmm0,%xmm3
test   %r15d,%r15d
je     1394 <modified_plgndr_a+0x274>
mulsd  0xc94(%rip),%xmm3
movapd %xmm3,%xmm0
add    $0x68,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r15d,%ebx
sub    %r14d,%ebx
lea    (%r15,%r15,1),%r14d
mov    $0x2,%ebp
movsd  0xc5e(%rip),%xmm4
xorpd  %xmm8,%xmm8
jmp    142a <modified_plgndr_a+0x30a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  %xmm3,(%rsp)
call   1040 <sqrt@plt>
movsd  0x20(%rsp),%xmm6
xorpd  %xmm8,%xmm8
movsd  0xc2b(%rip),%xmm4
movsd  (%rsp),%xmm3
movapd 0x10(%rsp),%xmm1
movsd  0x30(%rsp),%xmm2
mulsd  %xmm0,%xmm1
mulsd  0x48(%rsp),%xmm3
mulsd  %xmm2,%xmm3
subsd  %xmm1,%xmm3
divsd  %xmm6,%xmm3
lea    (%rbx,%rbp,1),%eax
add    $0x1,%eax
mov    %ebp,%ecx
add    $0x1,%ecx
mov    %ecx,%ebp
cmp    $0x1,%eax
je     1351 <modified_plgndr_a+0x231>
lea    (%r15,%rbp,1),%eax
xorps  %xmm7,%xmm7
cvtsi2sd %eax,%xmm7
movapd %xmm7,%xmm0
mulsd  0xbcf(%rip),%xmm0
mulsd  %xmm7,%xmm0
xorps  %xmm6,%xmm6
cvtsi2sd %ebp,%xmm6
addsd  %xmm4,%xmm0
lea    (%r14,%rbp,1),%eax
xorps  %xmm5,%xmm5
cvtsi2sd %eax,%xmm5
mulsd  %xmm6,%xmm0
divsd  %xmm5,%xmm0
ucomisd %xmm8,%xmm0
movapd %xmm2,0x10(%rsp)
movsd  %xmm3,0x30(%rsp)
movsd  %xmm6,0x20(%rsp)
jb     1490 <modified_plgndr_a+0x370>
xorps  %xmm3,%xmm3
sqrtsd %xmm0,%xmm3
jmp    14c2 <modified_plgndr_a+0x3a2>
cs nopw 0x0(%rax,%rax,1)
nop
movsd  %xmm7,(%rsp)
movsd  %xmm5,0x50(%rsp)
call   1040 <sqrt@plt>
movsd  0x50(%rsp),%xmm5
movsd  (%rsp),%xmm7
movsd  0x20(%rsp),%xmm6
xorpd  %xmm8,%xmm8
movsd  0xb5a(%rip),%xmm4
movapd %xmm0,%xmm3
addsd  %xmm7,%xmm7
movapd %xmm7,%xmm0
addsd  0xb2e(%rip),%xmm0
mulsd  %xmm6,%xmm0
movapd %xmm5,%xmm1
addsd  %xmm4,%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm6,%xmm0
addsd  %xmm4,%xmm0
mulsd  %xmm1,%xmm0
addsd  0xb2a(%rip),%xmm7
mulsd  %xmm5,%xmm7
divsd  %xmm7,%xmm0
ucomisd %xmm8,%xmm0
jb     13d0 <modified_plgndr_a+0x2b0>
sqrtsd %xmm0,%xmm0
jmp    13f2 <modified_plgndr_a+0x2d2>

LLVM IR (-O0):
@M_PI = global double 0.000000e+00
define double @modified_plgndr_a(i32 %0, i32 %1, double %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca double
%7 = alloca i32
%8 = alloca i32
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
store i32 %0, i32* %4
store i32 %1, i32* %5
store double %2, double* %6
store double 3.000000e+00, double* %18
store double 2.000000e+00, double* %19
store double 1.000000e+00, double* %20
%21 = load double, double* %6
%22 = call double @cos(double %21)
store double %22, double* %9
store double 1.000000e+00, double* %14
%23 = load i32, i32* %5
%24 = icmp sgt i32 %23, 0
br i1 %24, label %25, label %55
25: ; preds = %3
%26 = load double, double* %9
%27 = fsub double 1.000000e+00, %26
%28 = load double, double* %9
%29 = fadd double 1.000000e+00, %28
%30 = fmul double %27, %29
%31 = call double @sqrt(double %30)
store double %31, double* %16
store double 3.000000e+00, double* %10
store double 2.000000e+00, double* %11
store i32 1, i32* %7
br label %32
32: ; preds = %51, %25
%33 = load i32, i32* %7
%34 = load i32, i32* %5
%35 = icmp sle i32 %33, %34
br i1 %35, label %36, label %54
36: ; preds = %32
%37 = load double, double* %10
%38 = load double, double* %11
%39 = fdiv double %37, %38
%40 = call double @sqrt(double %39)
store double %40, double* %12
%41 = load double, double* %14
%42 = fneg double %41
%43 = load double, double* %12
%44 = fmul double %42, %43
%45 = load double, double* %16
%46 = fmul double %44, %45
store double %46, double* %14
%47 = load double, double* %10
%48 = fadd double %47, 2.000000e+00
store double %48, double* %10
%49 = load double, double* %11
%50 = fadd double %49, 2.000000e+00
store double %50, double* %11
br label %51
51: ; preds = %36
%52 = load i32, i32* %7
%53 = add nsw i32 %52, 1
store i32 %53, i32* %7
br label %32
54: ; preds = %32
br label %55
55: ; preds = %54, %3
%56 = load i32, i32* %4
%57 = load i32, i32* %5
%58 = icmp eq i32 %56, %57
br i1 %58, label %59, label %61
59: ; preds = %55
%60 = load double, double* %14
store double %60, double* %17
br label %153
61: ; preds = %55
%62 = load double, double* %9
%63 = load i32, i32* %5
%64 = sitofp i32 %63 to double
%65 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %64, double 3.000000e+00)
%66 = call double @sqrt(double %65)
%67 = fmul double %62, %66
%68 = load double, double* %14
%69 = fmul double %67, %68
store double %69, double* %15
%70 = load i32, i32* %4
%71 = load i32, i32* %5
%72 = add nsw i32 %71, 1
%73 = icmp eq i32 %70, %72
br i1 %73, label %74, label %76
74: ; preds = %61
%75 = load double, double* %15
store double %75, double* %17
br label %152
76: ; preds = %61
%77 = load i32, i32* %5
%78 = add nsw i32 %77, 2
store i32 %78, i32* %8
br label %79
79: ; preds = %147, %76
%80 = load i32, i32* %8
%81 = load i32, i32* %4
%82 = icmp sle i32 %80, %81
br i1 %82, label %83, label %150
83: ; preds = %79
%84 = load i32, i32* %8
%85 = sitofp i32 %84 to double
%86 = fmul double 4.000000e+00, %85
%87 = load i32, i32* %8
%88 = sitofp i32 %87 to double
%89 = call double @llvm.fmuladd.f64(double %86, double %88, double -1.000000e+00)
%90 = load i32, i32* %8
%91 = load i32, i32* %5
%92 = sub nsw i32 %90, %91
%93 = sitofp i32 %92 to double
%94 = fmul double %89, %93
%95 = load i32, i32* %8
%96 = load i32, i32* %5
%97 = add nsw i32 %95, %96
%98 = sitofp i32 %97 to double
%99 = fdiv double %94, %98
%100 = call double @sqrt(double %99)
store double %100, double* %10
%101 = load i32, i32* %8
%102 = sitofp i32 %101 to double
%103 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %102, double 1.000000e+00)
%104 = load i32, i32* %8
%105 = load i32, i32* %5
%106 = sub nsw i32 %104, %105
%107 = sitofp i32 %106 to double
%108 = fmul double %103, %107
%109 = load i32, i32* %8
%110 = load i32, i32* %5
%111 = add nsw i32 %109, %110
%112 = sitofp i32 %111 to double
%113 = fsub double %112, 1.000000e+00
%114 = fmul double %108, %113
%115 = load i32, i32* %8
%116 = load i32, i32* %5
%117 = sub nsw i32 %115, %116
%118 = sitofp i32 %117 to double
%119 = fsub double %118, 1.000000e+00
%120 = fmul double %114, %119
%121 = load i32, i32* %8
%122 = sitofp i32 %121 to double
%123 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %122, double -3.000000e+00)
%124 = load i32, i32* %8
%125 = load i32, i32* %5
%126 = add nsw i32 %124, %125
%127 = sitofp i32 %126 to double
%128 = fmul double %123, %127
%129 = fdiv double %120, %128
%130 = call double @sqrt(double %129)
store double %130, double* %11
%131 = load double, double* %9
%132 = load double, double* %10
%133 = fmul double %131, %132
%134 = load double, double* %15
%135 = load double, double* %11
%136 = load double, double* %14
%137 = fmul double %135, %136
%138 = fneg double %137
%139 = call double @llvm.fmuladd.f64(double %133, double %134, double %138)
%140 = load i32, i32* %8
%141 = load i32, i32* %5
%142 = sub nsw i32 %140, %141
%143 = sitofp i32 %142 to double
%144 = fdiv double %139, %143
store double %144, double* %13
%145 = load double, double* %15
store double %145, double* %14
%146 = load double, double* %13
store double %146, double* %15
br label %147
147: ; preds = %83
%148 = load i32, i32* %8
%149 = add nsw i32 %148, 1
store i32 %149, i32* %8
br label %79
150: ; preds = %79
%151 = load double, double* %13
store double %151, double* %17
br label %152
152: ; preds = %150, %74
br label %153
153: ; preds = %152, %59
%154 = load double, double* @M_PI
%155 = fmul double 4.000000e+00, %154
%156 = call double @sqrt(double %155)
%157 = load double, double* %17
%158 = fdiv double %157, %156
store double %158, double* %17
%159 = load i32, i32* %5
%160 = icmp ne i32 %159, 0
br i1 %160, label %161, label %165
161: ; preds = %153
%162 = call double @sqrt(double 2.000000e+00)
%163 = load double, double* %17
%164 = fmul double %163, %162
store double %164, double* %17
br label %165
165: ; preds = %161, %153
%166 = load double, double* %17
ret double %166
}

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
define double @modified_plgndr_a(i32 %0, i32 %1, double %2) {
%4 = tail call double @cos(double %2)
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %50
6: ; preds = %3
%7 = fsub double 1.000000e+00, %4
%8 = fadd double %4, 1.000000e+00
%9 = fmul double %7, %8
%10 = tail call double @sqrt(double %9)
%11 = and i32 %1, 1
%12 = icmp eq i32 %1, 1
br i1 %12, label %37, label %13
13: ; preds = %6
%14 = and i32 %1, -2
%15 = fneg double %10
br label %16
16: ; preds = %16, %13
%17 = phi double [ 1.000000e+00, %13 ], [ %33, %16 ]
%18 = phi <2 x double> [ <double 3.000000e+00, double 2.000000e+00>, %13 ], [ %34, %16 ]
%19 = phi i32 [ 0, %13 ], [ %35, %16 ]
%20 = extractelement <2 x double> %18, i64 0
%21 = extractelement <2 x double> %18, i64 1
%22 = fdiv double %20, %21
%23 = tail call double @sqrt(double %22)
%24 = fneg double %17
%25 = fmul double %23, %24
%26 = fadd <2 x double> %18, <double 2.000000e+00, double 2.000000e+00>
%27 = extractelement <2 x double> %26, i64 0
%28 = extractelement <2 x double> %26, i64 1
%29 = fdiv double %27, %28
%30 = tail call double @sqrt(double %29)
%31 = fmul double %25, %15
%32 = fmul double %30, %31
%33 = fmul double %10, %32
%34 = fadd <2 x double> %26, <double 2.000000e+00, double 2.000000e+00>
%35 = add i32 %19, 2
%36 = icmp eq i32 %35, %14
br i1 %36, label %37, label %16
37: ; preds = %16, %6
%38 = phi double [ undef, %6 ], [ %33, %16 ]
%39 = phi double [ 1.000000e+00, %6 ], [ %33, %16 ]
%40 = phi <2 x double> [ <double 3.000000e+00, double 2.000000e+00>, %6 ], [ %34, %16 ]
%41 = icmp eq i32 %11, 0
br i1 %41, label %50, label %42
42: ; preds = %37
%43 = extractelement <2 x double> %40, i64 0
%44 = extractelement <2 x double> %40, i64 1
%45 = fdiv double %43, %44
%46 = tail call double @sqrt(double %45)
%47 = fneg double %39
%48 = fmul double %46, %47
%49 = fmul double %10, %48
br label %50
50: ; preds = %42, %37, %3
%51 = phi double [ 1.000000e+00, %3 ], [ %38, %37 ], [ %49, %42 ]
%52 = icmp eq i32 %0, %1
br i1 %52, label %95, label %53
53: ; preds = %50
%54 = sitofp i32 %1 to double
%55 = tail call double @llvm.fmuladd.f64(double %54, double 2.000000e+00, double 3.000000e+00)
%56 = tail call double @sqrt(double %55)
%57 = fmul double %4, %56
%58 = fmul double %51, %57
%59 = add nsw i32 %1, 1
%60 = icmp eq i32 %59, %0
br i1 %60, label %95, label %61
61: ; preds = %53
%62 = add nsw i32 %1, 2
%63 = icmp sgt i32 %62, %0
br i1 %63, label %95, label %64
64: ; preds = %61, %64
%65 = phi i32 [ %93, %64 ], [ %62, %61 ]
%66 = phi double [ %92, %64 ], [ %58, %61 ]
%67 = phi double [ %66, %64 ], [ %51, %61 ]
%68 = sitofp i32 %65 to double
%69 = fmul double %68, 4.000000e+00
%70 = tail call double @llvm.fmuladd.f64(double %69, double %68, double -1.000000e+00)
%71 = sub nsw i32 %65, %1
%72 = sitofp i32 %71 to double
%73 = fmul double %70, %72
%74 = add nsw i32 %65, %1
%75 = sitofp i32 %74 to double
%76 = fdiv double %73, %75
%77 = tail call double @sqrt(double %76)
%78 = tail call double @llvm.fmuladd.f64(double %68, double 2.000000e+00, double 1.000000e+00)
%79 = fmul double %78, %72
%80 = fadd double %75, -1.000000e+00
%81 = fmul double %79, %80
%82 = fadd double %72, -1.000000e+00
%83 = fmul double %82, %81
%84 = tail call double @llvm.fmuladd.f64(double %68, double 2.000000e+00, double -3.000000e+00)
%85 = fmul double %84, %75
%86 = fdiv double %83, %85
%87 = tail call double @sqrt(double %86)
%88 = fmul double %4, %77
%89 = fneg double %87
%90 = fmul double %67, %89
%91 = tail call double @llvm.fmuladd.f64(double %88, double %66, double %90)
%92 = fdiv double %91, %72
%93 = add i32 %65, 1
%94 = icmp eq i32 %65, %0
br i1 %94, label %95, label %64
95: ; preds = %64, %61, %53, %50
%96 = phi double [ %51, %50 ], [ %58, %53 ], [ undef, %61 ], [ %92, %64 ]
%97 = load double, double* @M_PI
%98 = fmul double %97, 4.000000e+00
%99 = tail call double @sqrt(double %98)
%100 = fdiv double %96, %99
%101 = icmp eq i32 %1, 0
%102 = fmul double %100, 0x3FF6A09E667F3BCD
%103 = select i1 %101, double %100, double %102
ret double %103
}