#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 atan2(double, double);
double cos(int);
int /*<<< orphan*/ memset(double *, int /*<<< orphan*/, int);
double phi_nlm(double, double, double, int, int, int);
double sin(int);
double sqrt(double);
void scf_potential_helper(double *xyz, int K, double G, double M, double r_s,
                          double *Snlm, double *Tnlm, int nmax, int lmax,
                          double *val) {
  int i, j, k, n, l, m;
  double r, s, X, phi;
  double cosmphi[lmax + 1], sinmphi[lmax + 1];
  memset(cosmphi, 0, (lmax + 1) * sizeof(double));
  memset(sinmphi, 0, (lmax + 1) * sizeof(double));
  for (k = 0; k < K; k++) {
    j = 3 * k;
    r = sqrt(xyz[j] * xyz[j] + xyz[j + 1] * xyz[j + 1] +
             xyz[j + 2] * xyz[j + 2]);
    s = r / r_s;
    X = xyz[j + 2] / r;
    phi = atan2(xyz[j + 1], xyz[j + 0]);
    val[k] = 0.;
    for (m = 0; m < (lmax + 1); m++) {
      cosmphi[m] = cos(m * phi);
      sinmphi[m] = sin(m * phi);
    }
    for (n = 0; n < (nmax + 1); n++) {
      for (l = 0; l < (lmax + 1); l++) {
        for (m = 0; m < (lmax + 1); m++) {
          if (m > l) {
            continue;
          }
          i = m + (lmax + 1) * (l + (lmax + 1) * n);
          if ((Snlm[i] == 0.) & (Tnlm[i] == 0.)) {
            continue;
          }
          val[k] += phi_nlm(s, phi, X, n, l, m) *
                    (Snlm[i] * cosmphi[m] + Tnlm[i] * sinmphi[m]);
        }
      }
    }
    val[k] *= G * M / r_s;
  }
}


x86 assembly (clang, -O0):
<scf_potential_helper>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
movsd  %xmm2,-0x28(%rbp)
mov    %rdx,-0x30(%rbp)
mov    %rcx,-0x38(%rbp)
mov    %r8d,-0x3c(%rbp)
mov    %r9d,-0x40(%rbp)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %rsp,%rcx
mov    %rcx,-0x80(%rbp)
lea    0xf(,%rax,8),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0xa0(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x88(%rbp)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x98(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x90(%rbp)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1050 <memset@plt>
mov    -0x98(%rbp),%rdi
mov    -0x40(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1050 <memset@plt>
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1532 <scf_potential_helper+0x3d2>
imul   $0x3,-0x4c(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x48(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x8(%rbp),%rax
movslq -0x48(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x8(%rbp),%rax
mov    -0x48(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x48(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mulsd  (%rax,%rcx,8),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x8(%rbp),%rax
mov    -0x48(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x48(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1080 <sqrt@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x48(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
divsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x48(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x48(%rbp),%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
call   1040 <atan2@plt>
movsd  %xmm0,-0x78(%rbp)
mov    0x10(%rbp),%rax
movslq -0x4c(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movl   $0x0,-0x58(%rbp)
mov    -0x58(%rbp),%eax
mov    -0x40(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    138a <scf_potential_helper+0x22a>
cvtsi2sdl -0x58(%rbp),%xmm0
mulsd  -0x78(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1070 <cos@plt>
mov    -0xa0(%rbp),%rax
movslq -0x58(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
cvtsi2sdl -0x58(%rbp),%xmm0
mulsd  -0x78(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1060 <sin@plt>
mov    -0x98(%rbp),%rax
movslq -0x58(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    1325 <scf_potential_helper+0x1c5>
movl   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%eax
mov    -0x3c(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    1503 <scf_potential_helper+0x3a3>
movl   $0x0,-0x54(%rbp)
mov    -0x54(%rbp),%eax
mov    -0x40(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    14f0 <scf_potential_helper+0x390>
movl   $0x0,-0x58(%rbp)
mov    -0x58(%rbp),%eax
mov    -0x40(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    14dd <scf_potential_helper+0x37d>
mov    -0x58(%rbp),%eax
cmp    -0x54(%rbp),%eax
jle    13e3 <scf_potential_helper+0x283>
jmp    14cf <scf_potential_helper+0x36f>
mov    -0x58(%rbp),%eax
mov    -0x40(%rbp),%ecx
add    $0x1,%ecx
mov    -0x54(%rbp),%edx
mov    -0x40(%rbp),%esi
add    $0x1,%esi
imul   -0x50(%rbp),%esi
add    %esi,%edx
imul   %edx,%ecx
add    %ecx,%eax
mov    %eax,-0x44(%rbp)
mov    -0x30(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
sete   %al
setnp  %cl
and    %cl,%al
and    $0x1,%al
movzbl %al,%eax
mov    -0x38(%rbp),%rcx
movslq -0x44(%rbp),%rdx
movsd  (%rcx,%rdx,8),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
sete   %cl
setnp  %dl
and    %dl,%cl
and    $0x1,%cl
movzbl %cl,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1456 <scf_potential_helper+0x2f6>
jmp    14cf <scf_potential_helper+0x36f>
movsd  -0x68(%rbp),%xmm0
movsd  -0x78(%rbp),%xmm1
movsd  -0x70(%rbp),%xmm2
mov    -0x50(%rbp),%edi
mov    -0x54(%rbp),%esi
mov    -0x58(%rbp),%edx
call   1030 <phi_nlm@plt>
mov    -0xa0(%rbp),%rcx
mov    -0x98(%rbp),%rax
mov    -0x30(%rbp),%rdx
movslq -0x44(%rbp),%rsi
movsd  (%rdx,%rsi,8),%xmm2
movslq -0x58(%rbp),%rdx
movsd  (%rcx,%rdx,8),%xmm3
mov    -0x38(%rbp),%rcx
movslq -0x44(%rbp),%rdx
movsd  (%rcx,%rdx,8),%xmm1
movslq -0x58(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm3,%xmm2
addsd  %xmm1,%xmm2
mov    0x10(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    13c1 <scf_potential_helper+0x261>
jmp    14e2 <scf_potential_helper+0x382>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    13a9 <scf_potential_helper+0x249>
jmp    14f5 <scf_potential_helper+0x395>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    1391 <scf_potential_helper+0x231>
movsd  -0x18(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
divsd  -0x28(%rbp),%xmm0
mov    0x10(%rbp),%rax
movslq -0x4c(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    1226 <scf_potential_helper+0xc6>
mov    -0x80(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scf_potential_helper>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xa8,%rsp
mov    %r8,-0x68(%rbp)
mov    %rcx,-0xa0(%rbp)
mov    %rdx,-0x98(%rbp)
movsd  %xmm2,-0x60(%rbp)
movsd  %xmm1,-0x30(%rbp)
movsd  %xmm0,-0x48(%rbp)
mov    %esi,-0x38(%rbp)
mov    %rdi,%r12
lea    0x1(%r9),%r15d
mov    %rsp,%r13
lea    0xf(,%r15,8),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
mov    %rsp,%r14
sub    %rax,%r14
mov    %r14,%rsp
mov    %r9,-0x70(%rbp)
lea    0x8(,%r9,8),%ebx
mov    %r13,%rdi
xor    %esi,%esi
mov    %ebx,%edx
call   1050 <memset@plt>
mov    %r14,-0x50(%rbp)
mov    %r14,%rdi
xor    %esi,%esi
mov    %ebx,%edx
call   1050 <memset@plt>
mov    -0x38(%rbp),%edx
test   %edx,%edx
jle    1551 <scf_potential_helper+0x3f1>
movsd  -0x48(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
divsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movslq %r15d,%rcx
mov    -0x68(%rbp),%rax
add    $0x1,%eax
mov    %rax,-0xc8(%rbp)
mov    %edx,%eax
mov    %rax,-0xa8(%rbp)
mov    %ecx,%eax
and    $0xfffffffe,%eax
mov    %rax,-0xb8(%rbp)
mov    %rcx,%rax
imul   %rcx,%rax
shl    $0x3,%rax
mov    %rax,-0xc0(%rbp)
shl    $0x3,%rcx
mov    %rcx,-0xd0(%rbp)
xor    %ebx,%ebx
xorpd  %xmm2,%xmm2
mov    %r12,-0xb0(%rbp)
mov    %r13,-0x88(%rbp)
jmp    1299 <scf_potential_helper+0x139>
nopl   (%rax)
mov    0x10(%rbp),%rax
mov    -0x90(%rbp),%rbx
movsd  (%rax,%rbx,8),%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  %xmm0,(%rax,%rbx,8)
add    $0x1,%rbx
cmp    -0xa8(%rbp),%rbx
mov    -0xb0(%rbp),%r12
mov    -0x88(%rbp),%r13
je     1551 <scf_potential_helper+0x3f1>
lea    (%rbx,%rbx,2),%r14
movsd  (%r12,%r14,8),%xmm1
movsd  0x8(%r12,%r14,8),%xmm0
mulsd  %xmm0,%xmm0
mulsd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
movsd  0x10(%r12,%r14,8),%xmm0
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
ucomisd %xmm2,%xmm0
jb     12e0 <scf_potential_helper+0x180>
sqrtsd %xmm0,%xmm0
jmp    12e5 <scf_potential_helper+0x185>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
call   1080 <sqrt@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  0x10(%r12,%r14,8),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  (%r12,%r14,8),%xmm1
movsd  0x8(%r12,%r14,8),%xmm0
call   1040 <atan2@plt>
mov    0x10(%rbp),%rax
movq   $0x0,(%rax,%rbx,8)
cmpl   $0x0,-0x70(%rbp)
mov    %rbx,-0x90(%rbp)
xorpd  %xmm2,%xmm2
movsd  %xmm0,-0x30(%rbp)
js     13ec <scf_potential_helper+0x28c>
je     1540 <scf_potential_helper+0x3e0>
xor    %ebx,%ebx
mov    -0x50(%rbp),%r12
nopw   0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  -0x30(%rbp),%xmm0
cvttsd2si %xmm0,%r14d
mov    %r14d,%edi
call   1070 <cos@plt>
movsd  %xmm0,0x0(%r13,%rbx,8)
mov    %r14d,%edi
call   1060 <sin@plt>
lea    0x1(%rbx),%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movsd  %xmm0,(%r12,%rbx,8)
mulsd  -0x30(%rbp),%xmm1
cvttsd2si %xmm1,%r14d
mov    %r14d,%edi
call   1070 <cos@plt>
movsd  %xmm0,0x8(%r13,%rbx,8)
mov    %r14d,%edi
call   1060 <sin@plt>
movsd  %xmm0,0x8(%r12,%rbx,8)
add    $0x2,%rbx
cmp    -0xb8(%rbp),%rbx
jne    1340 <scf_potential_helper+0x1e0>
xorpd  %xmm2,%xmm2
test   $0x1,%r15b
je     13ec <scf_potential_helper+0x28c>
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  -0x30(%rbp),%xmm0
cvttsd2si %xmm0,%r14d
mov    %r14d,%edi
call   1070 <cos@plt>
movsd  %xmm0,0x0(%r13,%rbx,8)
mov    %r14d,%edi
call   1060 <sin@plt>
xorpd  %xmm2,%xmm2
mov    -0x50(%rbp),%rax
movsd  %xmm0,(%rax,%rbx,8)
cmpl   $0x0,-0x68(%rbp)
js     1260 <scf_potential_helper+0x100>
movsd  -0x40(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,-0x58(%rbp)
divsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0xa0(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x98(%rbp),%rax
mov    %rax,-0x78(%rbp)
xor    %eax,%eax
mov    %rax,-0x38(%rbp)
jmp    146b <scf_potential_helper+0x30b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    -0x38(%rbp),%rcx
add    $0x1,%rcx
mov    -0xc0(%rbp),%rax
add    %rax,-0x78(%rbp)
add    %rax,-0x80(%rbp)
mov    %rcx,%rax
mov    %rcx,-0x38(%rbp)
cmp    -0xc8(%rbp),%rcx
je     1260 <scf_potential_helper+0x100>
cmpl   $0x0,-0x70(%rbp)
js     1440 <scf_potential_helper+0x2e0>
mov    -0x80(%rbp),%r12
mov    -0x78(%rbp),%r14
xor    %r13d,%r13d
jmp    1496 <scf_potential_helper+0x336>
xchg   %ax,%ax
add    $0x1,%r13
mov    -0xd0(%rbp),%rax
add    %rax,%r14
add    %rax,%r12
cmp    %r15,%r13
je     1440 <scf_potential_helper+0x2e0>
xor    %ebx,%ebx
jmp    150c <scf_potential_helper+0x3ac>
nopw   0x0(%rax,%rax,1)
movsd  -0x40(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm2
mov    -0x38(%rbp),%rdi
mov    %r13d,%esi
mov    %ebx,%edx
call   1030 <phi_nlm@plt>
movsd  (%r12,%rbx,8),%xmm1
mov    -0x50(%rbp),%rax
mulsd  (%rax,%rbx,8),%xmm1
movsd  (%r14,%rbx,8),%xmm2
mov    -0x88(%rbp),%rax
mulsd  (%rax,%rbx,8),%xmm2
addsd  %xmm1,%xmm2
mulsd  %xmm0,%xmm2
mov    0x10(%rbp),%rax
mov    -0x90(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm2
movsd  %xmm2,(%rax,%rcx,8)
xorpd  %xmm2,%xmm2
add    $0x1,%rbx
cmp    %rbx,%r15
je     1480 <scf_potential_helper+0x320>
cmp    %r13,%rbx
ja     14ff <scf_potential_helper+0x39f>
movsd  (%r14,%rbx,8),%xmm0
ucomisd %xmm2,%xmm0
jne    14a0 <scf_potential_helper+0x340>
jp     14a0 <scf_potential_helper+0x340>
movsd  (%r12,%rbx,8),%xmm0
ucomisd %xmm2,%xmm0
jne    14a0 <scf_potential_helper+0x340>
jnp    14ff <scf_potential_helper+0x39f>
jmp    14a0 <scf_potential_helper+0x340>
cs nopw 0x0(%rax,%rax,1)
xor    %ebx,%ebx
test   $0x1,%r15b
jne    13b7 <scf_potential_helper+0x257>
jmp    13ec <scf_potential_helper+0x28c>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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