#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 */
size_t indx(int, int);
double sqrt(int);
void lgndr(double t, int NMAX, double *P_bar_nm, double *SQT, int *IX) {
  int n, m;
  double t2 = t * t;
  if (*IX == 0) {
    *IX = 1;
    int NSQRTS = NMAX + NMAX + 1;
#pragma omp parallel for
    for (m = 1; m <= NSQRTS; m++)
      SQT[m] = sqrt(m);
  }
  P_bar_nm[0] = 1.0;
  P_bar_nm[1] = SQT[3] * t;
  P_bar_nm[2] = SQT[3] * sqrt(1.0 - t2);
  if (NMAX == 1)
    return;
  for (n = 2; n <= NMAX; n++) {
    for (m = 0; m < n - 1; m++) {
      P_bar_nm[indx(n, m)] =
          ((SQT[2 * n - 1] / SQT[n - m]) * (SQT[2 * n + 1] / SQT[n + m])) * t *
              P_bar_nm[indx(n - 1, m)] -
          ((SQT[2 * n + 1] / SQT[2 * n - 3]) * (SQT[n + m - 1] / SQT[n + m]) *
           (SQT[n - m - 1] / SQT[n - m])) *
              P_bar_nm[indx(n - 2, m)];
    }
    P_bar_nm[indx(n, n - 1)] =
        SQT[2 * n + 1] * t * P_bar_nm[indx(n - 1, n - 1)];
    P_bar_nm[indx(n, n)] =
        sqrt((2 * n + 1.0) * (1 - t2) / (2 * n)) * P_bar_nm[indx(n - 1, n - 1)];
  }
}


x86 assembly (clang, -O0):
<lgndr>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x28(%rbp),%rax
cmpl   $0x0,(%rax)
jne    11ac <lgndr+0x8c>
mov    -0x28(%rbp),%rax
movl   $0x1,(%rax)
mov    -0xc(%rbp),%eax
add    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
movl   $0x1,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jg     11a7 <lgndr+0x87>
mov    -0x30(%rbp),%edi
call   1040 <sqrt@plt>
mov    -0x20(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1178 <lgndr+0x58>
jmp    11ac <lgndr+0x8c>
mov    -0x18(%rbp),%rax
movsd  0xe48(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
movsd  0x18(%rax),%xmm0
mulsd  -0x8(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x20(%rbp),%rax
movsd  0x18(%rax),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xe17(%rip),%xmm0
subsd  -0x38(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x10(%rax)
cmpl   $0x1,-0xc(%rbp)
jne    121b <lgndr+0xfb>
jmp    151e <lgndr+0x3fe>
movl   $0x2,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     151e <lgndr+0x3fe>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
mov    -0x2c(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    13d5 <lgndr+0x2b5>
mov    -0x20(%rbp),%rax
mov    -0x2c(%rbp),%ecx
shl    $0x1,%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
mov    -0x2c(%rbp),%ecx
sub    -0x30(%rbp),%ecx
movslq %ecx,%rcx
divsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
mov    -0x2c(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x20(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    -0x30(%rbp),%ecx
movslq %ecx,%rcx
divsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm1,%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x2c(%rbp),%edi
sub    $0x1,%edi
mov    -0x30(%rbp),%esi
call   1030 <indx@plt>
mov    %rax,%rcx
mov    -0x80(%rbp),%rax
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x2c(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
mov    -0x2c(%rbp),%ecx
shl    $0x1,%ecx
sub    $0x3,%ecx
movslq %ecx,%rcx
divsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    -0x30(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x20(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    -0x30(%rbp),%ecx
movslq %ecx,%rcx
divsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
mov    -0x2c(%rbp),%ecx
sub    -0x30(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x20(%rbp),%rax
mov    -0x2c(%rbp),%ecx
sub    -0x30(%rbp),%ecx
movslq %ecx,%rcx
divsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x78(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x2c(%rbp),%edi
sub    $0x2,%edi
mov    -0x30(%rbp),%esi
call   1030 <indx@plt>
movsd  -0x78(%rbp),%xmm1
movsd  -0x70(%rbp),%xmm0
movsd  -0x68(%rbp),%xmm2
mov    %rax,%rcx
mov    -0x60(%rbp),%rax
mulsd  (%rax,%rcx,8),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x2c(%rbp),%edi
mov    -0x30(%rbp),%esi
call   1030 <indx@plt>
movsd  -0x58(%rbp),%xmm0
mov    %rax,%rcx
mov    -0x50(%rbp),%rax
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1235 <lgndr+0x115>
mov    -0x20(%rbp),%rax
mov    -0x2c(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0xc0(%rbp)
ff
mov    -0x18(%rbp),%rax
mov    %rax,-0xb8(%rbp)
mov    -0x2c(%rbp),%edi
sub    $0x1,%edi
mov    -0x2c(%rbp),%esi
sub    $0x1,%esi
call   1030 <indx@plt>
movsd  -0xc0(%rbp),%xmm0
ff
mov    %rax,%rcx
mov    -0xb8(%rbp),%rax
mulsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
mov    -0x18(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    -0x2c(%rbp),%edi
mov    -0x2c(%rbp),%esi
sub    $0x1,%esi
call   1030 <indx@plt>
movsd  -0xb0(%rbp),%xmm0
ff
mov    %rax,%rcx
mov    -0xa8(%rbp),%rax
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  0xb8c(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xb80(%rip),%xmm1
subsd  -0x38(%rbp),%xmm1
mulsd  %xmm1,%xmm0
mov    -0x2c(%rbp),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sqrt@plt>
movsd  %xmm0,-0xa0(%rbp)
ff
mov    -0x18(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    -0x2c(%rbp),%edi
sub    $0x1,%edi
mov    -0x2c(%rbp),%esi
sub    $0x1,%esi
call   1030 <indx@plt>
movsd  -0xa0(%rbp),%xmm0
ff
mov    %rax,%rcx
mov    -0x98(%rbp),%rax
mulsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
mov    -0x18(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    -0x2c(%rbp),%edi
mov    -0x2c(%rbp),%esi
call   1030 <indx@plt>
movsd  -0x90(%rbp),%xmm0
mov    %rax,%rcx
mov    -0x88(%rbp),%rax
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1222 <lgndr+0x102>
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lgndr>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %rdx,%r12
mov    %rsi,%r13
mov    %rdi,0x8(%rsp)
movsd  %xmm0,0x20(%rsp)
mulsd  %xmm0,%xmm0
movsd  %xmm0,(%rsp)
cmpl   $0x0,(%rcx)
jne    1207 <lgndr+0xe7>
movl   $0x1,(%rcx)
mov    0x8(%rsp),%rax
add    %eax,%eax
add    $0x1,%eax
test   %eax,%eax
jle    1207 <lgndr+0xe7>
mov    0x8(%rsp),%rax
add    %eax,%eax
add    $0x2,%eax
lea    -0x1(%rax),%r14
add    $0xfffffffffffffffe,%rax
mov    %r14d,%ebx
and    $0x3,%ebx
mov    $0x1,%ebp
cmp    $0x3,%rax
jb     11f0 <lgndr+0xd0>
and    $0xfffffffffffffffc,%r14
mov    $0x1,%ebp
xor    %r15d,%r15d
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
call   1040 <sqrt@plt>
movsd  %xmm0,(%r12,%rbp,8)
lea    0x1(%rbp),%edi
call   1040 <sqrt@plt>
movsd  %xmm0,0x8(%r12,%rbp,8)
lea    0x2(%rbp),%edi
call   1040 <sqrt@plt>
movsd  %xmm0,0x10(%r12,%rbp,8)
lea    0x3(%rbp),%edi
call   1040 <sqrt@plt>
movsd  %xmm0,0x18(%r12,%rbp,8)
add    $0x4,%rbp
add    $0x4,%r15
cmp    %r14,%r15
jne    11a0 <lgndr+0x80>
nopw   0x0(%rax,%rax,1)
mov    %ebp,%edi
call   1040 <sqrt@plt>
movsd  %xmm0,(%r12,%rbp,8)
add    $0x1,%rbp
add    $0xffffffffffffffff,%rbx
jne    11f0 <lgndr+0xd0>
movabs $0x3ff0000000000000,%rax
mov    %rax,0x0(%r13)
movsd  0x18(%r12),%xmm0
mulsd  0x20(%rsp),%xmm0
movsd  %xmm0,0x8(%r13)
mov    %r12,0x38(%rsp)
movsd  0x18(%r12),%xmm0
movsd  %xmm0,0x28(%rsp)
movsd  0xdbe(%rip),%xmm0
subsd  (%rsp),%xmm0
movsd  %xmm0,0x50(%rsp)
cvttsd2si %xmm0,%edi
call   1040 <sqrt@plt>
mulsd  0x28(%rsp),%xmm0
movsd  %xmm0,0x10(%r13)
cmpl   $0x2,0x8(%rsp)
jl     14cd <lgndr+0x3ad>
mov    0x8(%rsp),%rax
add    $0x1,%eax
mov    %rax,0x8(%rsp)
mov    $0x2,%eax
mov    %rax,0x18(%rsp)
xor    %r15d,%r15d
mov    0x38(%rsp),%r12
mov    %r13,0x40(%rsp)
mov    0x38(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
mov    0x18(%rsp),%rax
lea    -0x1(%rax),%ecx
mov    %ecx,0x14(%rsp)
lea    (%rax,%rax,1),%rcx
mov    %rcx,0x58(%rsp)
mov    %rax,%rdx
shl    $0x21,%rdx
movabs $0xffffffff00000000,%rcx
ff ff ff
add    %rdx,%rcx
sar    $0x20,%rcx
mov    %rcx,0x60(%rsp)
lea    (%rax,%rax,1),%rcx
add    $0x1,%rcx
mov    %rcx,0x48(%rsp)
movabs $0xfffffffd00000000,%rcx
ff ff ff
add    %rcx,%rdx
sar    $0x20,%rdx
mov    %rdx,0x68(%rsp)
add    $0xfffffffe,%eax
mov    %eax,0x34(%rsp)
mov    $0x10,%ebp
mov    $0x2,%r13d
mov    %r15,0x70(%rsp)
nopl   0x0(%rax)
mov    0x60(%rsp),%rax
movsd  (%r14,%rax,8),%xmm0
divsd  (%r12,%rbp,1),%xmm0
mov    0x48(%rsp),%rbx
movsd  (%r14,%rbx,8),%xmm1
divsd  (%r12,%r13,8),%xmm1
mulsd  %xmm0,%xmm1
mulsd  0x20(%rsp),%xmm1
movsd  %xmm1,(%rsp)
lea    -0x2(%r13),%r15d
mov    0x14(%rsp),%edi
mov    %r15d,%esi
call   1030 <indx@plt>
movsd  (%r14,%rbx,8),%xmm2
movsd  -0x8(%r12,%r13,8),%xmm0
divsd  (%r12,%r13,8),%xmm0
movsd  -0x8(%r12,%rbp,1),%xmm1
divsd  (%r12,%rbp,1),%xmm1
mov    0x68(%rsp),%rcx
divsd  (%r14,%rcx,8),%xmm2
mulsd  %xmm0,%xmm2
mulsd  %xmm1,%xmm2
movsd  %xmm2,0x28(%rsp)
mov    %r12,%rbx
mov    0x40(%rsp),%r12
movsd  (%rsp),%xmm0
mulsd  (%r12,%rax,8),%xmm0
movsd  %xmm0,(%rsp)
mov    0x34(%rsp),%edi
mov    %r15d,%esi
call   1030 <indx@plt>
movsd  0x28(%rsp),%xmm1
mulsd  (%r12,%rax,8),%xmm1
movsd  (%rsp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,(%rsp)
mov    0x18(%rsp),%rdi
mov    %r15d,%esi
mov    0x70(%rsp),%r15
call   1030 <indx@plt>
movsd  (%rsp),%xmm0
movsd  %xmm0,(%r12,%rax,8)
mov    %rbx,%r12
add    $0xfffffffffffffff8,%rbp
lea    (%r15,%r13,1),%rax
add    $0x1,%rax
add    $0x1,%r13
cmp    $0x3,%rax
jne    1310 <lgndr+0x1f0>
mov    0x48(%rsp),%rax
movsd  (%r14,%rax,8),%xmm0
mulsd  0x20(%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    0x14(%rsp),%ebx
mov    %ebx,%edi
mov    %ebx,%esi
call   1030 <indx@plt>
mov    0x40(%rsp),%r13
movsd  (%rsp),%xmm0
mulsd  0x0(%r13,%rax,8),%xmm0
movsd  %xmm0,(%rsp)
mov    0x18(%rsp),%rbp
mov    %ebp,%edi
mov    %ebx,%esi
call   1030 <indx@plt>
movsd  (%rsp),%xmm0
movsd  %xmm0,0x0(%r13,%rax,8)
xorps  %xmm0,%xmm0
cvtsi2sdl 0x58(%rsp),%xmm0
movapd %xmm0,%xmm1
addsd  0xb96(%rip),%xmm1
mulsd  0x50(%rsp),%xmm1
divsd  %xmm0,%xmm1
cvttsd2si %xmm1,%edi
call   1040 <sqrt@plt>
movsd  %xmm0,(%rsp)
mov    %ebx,%edi
mov    %ebx,%esi
call   1030 <indx@plt>
movsd  (%rsp),%xmm0
mulsd  0x0(%r13,%rax,8),%xmm0
movsd  %xmm0,(%rsp)
mov    %ebp,%edi
mov    %ebp,%esi
call   1030 <indx@plt>
movsd  (%rsp),%xmm0
movsd  %xmm0,0x0(%r13,%rax,8)
add    $0x1,%rbp
add    $0x8,%r12
add    $0xffffffffffffffff,%r15
mov    %rbp,0x18(%rsp)
cmp    0x8(%rsp),%rbp
jne    12a0 <lgndr+0x180>
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @lgndr(double %0, i32 %1, double* %2, double* %3, i32* %4) {
%6 = alloca double
%7 = alloca i32
%8 = alloca double*
%9 = alloca double*
%10 = alloca i32*
%11 = alloca i32
%12 = alloca i32
%13 = alloca double
%14 = alloca i32
store double %0, double* %6
store i32 %1, i32* %7
store double* %2, double** %8
store double* %3, double** %9
store i32* %4, i32** %10
%15 = load double, double* %6
%16 = load double, double* %6
%17 = fmul double %15, %16
store double %17, double* %13
%18 = load i32*, i32** %10
%19 = load i32, i32* %18
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %42
21: ; preds = %5
%22 = load i32*, i32** %10
store i32 1, i32* %22
%23 = load i32, i32* %7
%24 = load i32, i32* %7
%25 = add nsw i32 %23, %24
%26 = add nsw i32 %25, 1
store i32 %26, i32* %14
store i32 1, i32* %12
br label %27
27: ; preds = %38, %21
%28 = load i32, i32* %12
%29 = load i32, i32* %14
%30 = icmp sle i32 %28, %29
br i1 %30, label %31, label %41
31: ; preds = %27
%32 = load i32, i32* %12
%33 = call double @sqrt(i32 %32)
%34 = load double*, double** %9
%35 = load i32, i32* %12
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds double, double* %34, i64 %36
store double %33, double* %37
br label %38
38: ; preds = %31
%39 = load i32, i32* %12
%40 = add nsw i32 %39, 1
store i32 %40, i32* %12
br label %27
41: ; preds = %27
br label %42
42: ; preds = %41, %5
%43 = load double*, double** %8
%44 = getelementptr inbounds double, double* %43, i64 0
store double 1.000000e+00, double* %44
%45 = load double*, double** %9
%46 = getelementptr inbounds double, double* %45, i64 3
%47 = load double, double* %46
%48 = load double, double* %6
%49 = fmul double %47, %48
%50 = load double*, double** %8
%51 = getelementptr inbounds double, double* %50, i64 1
store double %49, double* %51
%52 = load double*, double** %9
%53 = getelementptr inbounds double, double* %52, i64 3
%54 = load double, double* %53
%55 = load double, double* %13
%56 = fsub double 1.000000e+00, %55
%57 = fptosi double %56 to i32
%58 = call double @sqrt(i32 %57)
%59 = fmul double %54, %58
%60 = load double*, double** %8
%61 = getelementptr inbounds double, double* %60, i64 2
store double %59, double* %61
%62 = load i32, i32* %7
%63 = icmp eq i32 %62, 1
br i1 %63, label %64, label %65
64: ; preds = %42
br label %239
65: ; preds = %42
store i32 2, i32* %11
br label %66
66: ; preds = %236, %65
%67 = load i32, i32* %11
%68 = load i32, i32* %7
%69 = icmp sle i32 %67, %68
br i1 %69, label %70, label %239
70: ; preds = %66
store i32 0, i32* %12
br label %71
71: ; preds = %181, %70
%72 = load i32, i32* %12
%73 = load i32, i32* %11
%74 = sub nsw i32 %73, 1
%75 = icmp slt i32 %72, %74
br i1 %75, label %76, label %184
76: ; preds = %71
%77 = load double*, double** %9
%78 = load i32, i32* %11
%79 = mul nsw i32 2, %78
%80 = sub nsw i32 %79, 1
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds double, double* %77, i64 %81
%83 = load double, double* %82
%84 = load double*, double** %9
%85 = load i32, i32* %11
%86 = load i32, i32* %12
%87 = sub nsw i32 %85, %86
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds double, double* %84, i64 %88
%90 = load double, double* %89
%91 = fdiv double %83, %90
%92 = load double*, double** %9
%93 = load i32, i32* %11
%94 = mul nsw i32 2, %93
%95 = add nsw i32 %94, 1
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds double, double* %92, i64 %96
%98 = load double, double* %97
%99 = load double*, double** %9
%100 = load i32, i32* %11
%101 = load i32, i32* %12
%102 = add nsw i32 %100, %101
%103 = sext i32 %102 to i64
%104 = getelementptr inbounds double, double* %99, i64 %103
%105 = load double, double* %104
%106 = fdiv double %98, %105
%107 = fmul double %91, %106
%108 = load double, double* %6
%109 = fmul double %107, %108
%110 = load double*, double** %8
%111 = load i32, i32* %11
%112 = sub nsw i32 %111, 1
%113 = load i32, i32* %12
%114 = call i64 @indx(i32 %112, i32 %113)
%115 = getelementptr inbounds double, double* %110, i64 %114
%116 = load double, double* %115
%117 = load double*, double** %9
%118 = load i32, i32* %11
%119 = mul nsw i32 2, %118
%120 = add nsw i32 %119, 1
%121 = sext i32 %120 to i64
%122 = getelementptr inbounds double, double* %117, i64 %121
%123 = load double, double* %122
%124 = load double*, double** %9
%125 = load i32, i32* %11
%126 = mul nsw i32 2, %125
%127 = sub nsw i32 %126, 3
%128 = sext i32 %127 to i64
%129 = getelementptr inbounds double, double* %124, i64 %128
%130 = load double, double* %129
%131 = fdiv double %123, %130
%132 = load double*, double** %9
%133 = load i32, i32* %11
%134 = load i32, i32* %12
%135 = add nsw i32 %133, %134
%136 = sub nsw i32 %135, 1
%137 = sext i32 %136 to i64
%138 = getelementptr inbounds double, double* %132, i64 %137
%139 = load double, double* %138
%140 = load double*, double** %9
%141 = load i32, i32* %11
%142 = load i32, i32* %12
%143 = add nsw i32 %141, %142
%144 = sext i32 %143 to i64
%145 = getelementptr inbounds double, double* %140, i64 %144
%146 = load double, double* %145
%147 = fdiv double %139, %146
%148 = fmul double %131, %147
%149 = load double*, double** %9
%150 = load i32, i32* %11
%151 = load i32, i32* %12
%152 = sub nsw i32 %150, %151
%153 = sub nsw i32 %152, 1
%154 = sext i32 %153 to i64
%155 = getelementptr inbounds double, double* %149, i64 %154
%156 = load double, double* %155
%157 = load double*, double** %9
%158 = load i32, i32* %11
%159 = load i32, i32* %12
%160 = sub nsw i32 %158, %159
%161 = sext i32 %160 to i64
%162 = getelementptr inbounds double, double* %157, i64 %161
%163 = load double, double* %162
%164 = fdiv double %156, %163
%165 = fmul double %148, %164
%166 = load double*, double** %8
%167 = load i32, i32* %11
%168 = sub nsw i32 %167, 2
%169 = load i32, i32* %12
%170 = call i64 @indx(i32 %168, i32 %169)
%171 = getelementptr inbounds double, double* %166, i64 %170
%172 = load double, double* %171
%173 = fmul double %165, %172
%174 = fneg double %173
%175 = call double @llvm.fmuladd.f64(double %109, double %116, double %174)
%176 = load double*, double** %8
%177 = load i32, i32* %11
%178 = load i32, i32* %12
%179 = call i64 @indx(i32 %177, i32 %178)
%180 = getelementptr inbounds double, double* %176, i64 %179
store double %175, double* %180
br label %181
181: ; preds = %76
%182 = load i32, i32* %12
%183 = add nsw i32 %182, 1
store i32 %183, i32* %12
br label %71
184: ; preds = %71
%185 = load double*, double** %9
%186 = load i32, i32* %11
%187 = mul nsw i32 2, %186
%188 = add nsw i32 %187, 1
%189 = sext i32 %188 to i64
%190 = getelementptr inbounds double, double* %185, i64 %189
%191 = load double, double* %190
%192 = load double, double* %6
%193 = fmul double %191, %192
%194 = load double*, double** %8
%195 = load i32, i32* %11
%196 = sub nsw i32 %195, 1
%197 = load i32, i32* %11
%198 = sub nsw i32 %197, 1
%199 = call i64 @indx(i32 %196, i32 %198)
%200 = getelementptr inbounds double, double* %194, i64 %199
%201 = load double, double* %200
%202 = fmul double %193, %201
%203 = load double*, double** %8
%204 = load i32, i32* %11
%205 = load i32, i32* %11
%206 = sub nsw i32 %205, 1
%207 = call i64 @indx(i32 %204, i32 %206)
%208 = getelementptr inbounds double, double* %203, i64 %207
store double %202, double* %208
%209 = load i32, i32* %11
%210 = mul nsw i32 2, %209
%211 = sitofp i32 %210 to double
%212 = fadd double %211, 1.000000e+00
%213 = load double, double* %13
%214 = fsub double 1.000000e+00, %213
%215 = fmul double %212, %214
%216 = load i32, i32* %11
%217 = mul nsw i32 2, %216
%218 = sitofp i32 %217 to double
%219 = fdiv double %215, %218
%220 = fptosi double %219 to i32
%221 = call double @sqrt(i32 %220)
%222 = load double*, double** %8
%223 = load i32, i32* %11
%224 = sub nsw i32 %223, 1
%225 = load i32, i32* %11
%226 = sub nsw i32 %225, 1
%227 = call i64 @indx(i32 %224, i32 %226)
%228 = getelementptr inbounds double, double* %222, i64 %227
%229 = load double, double* %228
%230 = fmul double %221, %229
%231 = load double*, double** %8
%232 = load i32, i32* %11
%233 = load i32, i32* %11
%234 = call i64 @indx(i32 %232, i32 %233)
%235 = getelementptr inbounds double, double* %231, i64 %234
store double %230, double* %235
br label %236
236: ; preds = %184
%237 = load i32, i32* %11
%238 = add nsw i32 %237, 1
store i32 %238, i32* %11
br label %66
239: ; preds = %64, %66
ret void
}

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