#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 rho_nlm(double, double, double, int, int, int);
double sin(int);
double sqrt(double);
void scf_density_helper(double *xyz, int K, double M, double r_s, double *Snlm,
                        double *Tnlm, int nmax, int lmax, double *dens) {
  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]);
    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;
          }
          dens[k] += rho_nlm(s, phi, X, n, l, m) *
                     (Snlm[i] * cosmphi[m] + Tnlm[i] * sinmphi[m]);
        }
      }
    }
    dens[k] *= M / (r_s * r_s * r_s);
  }
}


x86 assembly (clang, -O0):
<scf_density_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)
mov    %rdx,-0x28(%rbp)
mov    %rcx,-0x30(%rbp)
mov    %r8d,-0x34(%rbp)
mov    %r9d,-0x38(%rbp)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %rsp,%rcx
mov    %rcx,-0x78(%rbp)
lea    0xf(,%rax,8),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x98(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x80(%rbp)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x90(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x88(%rbp)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1040 <memset@plt>
mov    -0x90(%rbp),%rdi
mov    -0x38(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1040 <memset@plt>
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1523 <scf_density_helper+0x3c3>
imul   $0x3,-0x44(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x40(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x8(%rbp),%rax
movslq -0x40(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x8(%rbp),%rax
mov    -0x40(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x40(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mulsd  (%rax,%rcx,8),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x8(%rbp),%rax
mov    -0x40(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x40(%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,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x40(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
divsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x40(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x40(%rbp),%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
call   1030 <atan2@plt>
movsd  %xmm0,-0x70(%rbp)
movl   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%eax
mov    -0x38(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    1372 <scf_density_helper+0x212>
cvtsi2sdl -0x50(%rbp),%xmm0
mulsd  -0x70(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1070 <cos@plt>
mov    -0x98(%rbp),%rax
movslq -0x50(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
cvtsi2sdl -0x50(%rbp),%xmm0
mulsd  -0x70(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1060 <sin@plt>
mov    -0x90(%rbp),%rax
movslq -0x50(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    130d <scf_density_helper+0x1ad>
movl   $0x0,-0x48(%rbp)
mov    -0x48(%rbp),%eax
mov    -0x34(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    14eb <scf_density_helper+0x38b>
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
mov    -0x38(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    14d8 <scf_density_helper+0x378>
movl   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%eax
mov    -0x38(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    14c5 <scf_density_helper+0x365>
mov    -0x50(%rbp),%eax
cmp    -0x4c(%rbp),%eax
jle    13cb <scf_density_helper+0x26b>
jmp    14b7 <scf_density_helper+0x357>
mov    -0x50(%rbp),%eax
mov    -0x38(%rbp),%ecx
add    $0x1,%ecx
mov    -0x4c(%rbp),%edx
mov    -0x38(%rbp),%esi
add    $0x1,%esi
imul   -0x48(%rbp),%esi
add    %esi,%edx
imul   %edx,%ecx
add    %ecx,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x3c(%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    -0x30(%rbp),%rcx
movslq -0x3c(%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     143e <scf_density_helper+0x2de>
jmp    14b7 <scf_density_helper+0x357>
movsd  -0x60(%rbp),%xmm0
movsd  -0x70(%rbp),%xmm1
movsd  -0x68(%rbp),%xmm2
mov    -0x48(%rbp),%edi
mov    -0x4c(%rbp),%esi
mov    -0x50(%rbp),%edx
call   1050 <rho_nlm@plt>
mov    -0x98(%rbp),%rcx
mov    -0x90(%rbp),%rax
mov    -0x28(%rbp),%rdx
movslq -0x3c(%rbp),%rsi
movsd  (%rdx,%rsi,8),%xmm2
movslq -0x50(%rbp),%rdx
movsd  (%rcx,%rdx,8),%xmm3
mov    -0x30(%rbp),%rcx
movslq -0x3c(%rbp),%rdx
movsd  (%rcx,%rdx,8),%xmm1
movslq -0x50(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm3,%xmm2
addsd  %xmm1,%xmm2
mov    0x10(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    13a9 <scf_density_helper+0x249>
jmp    14ca <scf_density_helper+0x36a>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    1391 <scf_density_helper+0x231>
jmp    14dd <scf_density_helper+0x37d>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    1379 <scf_density_helper+0x219>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
mulsd  -0x20(%rbp),%xmm1
mulsd  -0x20(%rbp),%xmm1
divsd  %xmm1,%xmm0
mov    0x10(%rbp),%rax
movslq -0x44(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    121e <scf_density_helper+0xbe>
mov    -0x78(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scf_density_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  %xmm1,-0x60(%rbp)
movsd  %xmm0,-0x48(%rbp)
mov    %esi,-0x30(%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   1040 <memset@plt>
mov    %r14,-0x50(%rbp)
mov    %r14,%rdi
xor    %esi,%esi
mov    %ebx,%edx
call   1040 <memset@plt>
mov    -0x30(%rbp),%edx
test   %edx,%edx
jle    1551 <scf_density_helper+0x3f1>
movsd  -0x60(%rbp),%xmm1
movapd %xmm1,%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
movsd  -0x48(%rbp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,-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    %ecx,%ecx
xorpd  %xmm2,%xmm2
mov    %r12,-0xb0(%rbp)
mov    %r13,-0x88(%rbp)
jmp    12a9 <scf_density_helper+0x149>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x10(%rbp),%rax
mov    -0x90(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
add    $0x1,%rcx
cmp    -0xa8(%rbp),%rcx
mov    -0xb0(%rbp),%r12
mov    -0x88(%rbp),%r13
je     1551 <scf_density_helper+0x3f1>
mov    %rcx,-0x90(%rbp)
lea    (%rcx,%rcx,2),%rbx
movsd  (%r12,%rbx,8),%xmm1
movsd  0x8(%r12,%rbx,8),%xmm0
mulsd  %xmm0,%xmm0
mulsd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
movsd  0x10(%r12,%rbx,8),%xmm0
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
ucomisd %xmm2,%xmm0
jb     12f0 <scf_density_helper+0x190>
sqrtsd %xmm0,%xmm0
jmp    12f5 <scf_density_helper+0x195>
nopl   0x0(%rax,%rax,1)
call   1080 <sqrt@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  0x10(%r12,%rbx,8),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  (%r12,%rbx,8),%xmm1
movsd  0x8(%r12,%rbx,8),%xmm0
call   1030 <atan2@plt>
cmpl   $0x0,-0x70(%rbp)
xorpd  %xmm2,%xmm2
movsd  %xmm0,-0x40(%rbp)
js     13ec <scf_density_helper+0x28c>
je     1540 <scf_density_helper+0x3e0>
xor    %ebx,%ebx
mov    -0x50(%rbp),%r12
nopw   0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  -0x40(%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  -0x40(%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_density_helper+0x1e0>
xorpd  %xmm2,%xmm2
test   $0x1,%r15b
je     13ec <scf_density_helper+0x28c>
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  -0x40(%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     1270 <scf_density_helper+0x110>
movsd  -0x38(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,-0x58(%rbp)
divsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0xa0(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x98(%rbp),%rax
mov    %rax,-0x78(%rbp)
xor    %eax,%eax
mov    %rax,-0x30(%rbp)
jmp    146b <scf_density_helper+0x30b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    -0x30(%rbp),%rcx
add    $0x1,%rcx
mov    -0xc0(%rbp),%rax
add    %rax,-0x78(%rbp)
add    %rax,-0x80(%rbp)
mov    %rcx,%rax
mov    %rcx,-0x30(%rbp)
cmp    -0xc8(%rbp),%rcx
je     1270 <scf_density_helper+0x110>
cmpl   $0x0,-0x70(%rbp)
js     1440 <scf_density_helper+0x2e0>
mov    -0x80(%rbp),%r12
mov    -0x78(%rbp),%r14
xor    %r13d,%r13d
jmp    1496 <scf_density_helper+0x336>
xchg   %ax,%ax
add    $0x1,%r13
mov    -0xd0(%rbp),%rax
add    %rax,%r14
add    %rax,%r12
cmp    %r15,%r13
je     1440 <scf_density_helper+0x2e0>
xor    %ebx,%ebx
jmp    150c <scf_density_helper+0x3ac>
nopw   0x0(%rax,%rax,1)
movsd  -0x38(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm2
mov    -0x30(%rbp),%rdi
mov    %r13d,%esi
mov    %ebx,%edx
call   1050 <rho_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_density_helper+0x320>
cmp    %r13,%rbx
ja     14ff <scf_density_helper+0x39f>
movsd  (%r14,%rbx,8),%xmm0
ucomisd %xmm2,%xmm0
jne    14a0 <scf_density_helper+0x340>
jp     14a0 <scf_density_helper+0x340>
movsd  (%r12,%rbx,8),%xmm0
ucomisd %xmm2,%xmm0
jne    14a0 <scf_density_helper+0x340>
jnp    14ff <scf_density_helper+0x39f>
jmp    14a0 <scf_density_helper+0x340>
cs nopw 0x0(%rax,%rax,1)
xor    %ebx,%ebx
test   $0x1,%r15b
jne    13b7 <scf_density_helper+0x257>
jmp    13ec <scf_density_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_density_helper(double* %0, i32 %1, double %2, double %3, double* %4, double* %5, i32 %6, i32 %7, double* %8) {
%10 = alloca double*
%11 = alloca i32
%12 = alloca double
%13 = alloca double
%14 = alloca double*
%15 = alloca double*
%16 = alloca i32
%17 = alloca i32
%18 = alloca double*
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca double
%26 = alloca double
%27 = alloca double
%28 = alloca double
%29 = alloca i8*
%30 = alloca i64
%31 = alloca i64
store double* %0, double** %10
store i32 %1, i32* %11
store double %2, double* %12
store double %3, double* %13
store double* %4, double** %14
store double* %5, double** %15
store i32 %6, i32* %16
store i32 %7, i32* %17
store double* %8, double** %18
%32 = load i32, i32* %17
%33 = add nsw i32 %32, 1
%34 = zext i32 %33 to i64
%35 = call i8* @llvm.stacksave()
store i8* %35, i8** %29
%36 = alloca double, i64 %34
store i64 %34, i64* %30
%37 = load i32, i32* %17
%38 = add nsw i32 %37, 1
%39 = zext i32 %38 to i64
%40 = alloca double, i64 %39
store i64 %39, i64* %31
%41 = load i32, i32* %17
%42 = add nsw i32 %41, 1
%43 = sext i32 %42 to i64
%44 = mul i64 %43, 8
%45 = trunc i64 %44 to i32
%46 = call i32 @memset(double* %36, i32 0, i32 %45)
%47 = load i32, i32* %17
%48 = add nsw i32 %47, 1
%49 = sext i32 %48 to i64
%50 = mul i64 %49, 8
%51 = trunc i64 %50 to i32
%52 = call i32 @memset(double* %40, i32 0, i32 %51)
store i32 0, i32* %21
br label %53
53: ; preds = %260, %9
%54 = load i32, i32* %21
%55 = load i32, i32* %11
%56 = icmp slt i32 %54, %55
br i1 %56, label %57, label %263
57: ; preds = %53
%58 = load i32, i32* %21
%59 = mul nsw i32 3, %58
store i32 %59, i32* %20
%60 = load double*, double** %10
%61 = load i32, i32* %20
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds double, double* %60, i64 %62
%64 = load double, double* %63
%65 = load double*, double** %10
%66 = load i32, i32* %20
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds double, double* %65, i64 %67
%69 = load double, double* %68
%70 = load double*, double** %10
%71 = load i32, i32* %20
%72 = add nsw i32 %71, 1
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds double, double* %70, i64 %73
%75 = load double, double* %74
%76 = load double*, double** %10
%77 = load i32, i32* %20
%78 = add nsw i32 %77, 1
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds double, double* %76, i64 %79
%81 = load double, double* %80
%82 = fmul double %75, %81
%83 = call double @llvm.fmuladd.f64(double %64, double %69, double %82)
%84 = load double*, double** %10
%85 = load i32, i32* %20
%86 = add nsw i32 %85, 2
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds double, double* %84, i64 %87
%89 = load double, double* %88
%90 = load double*, double** %10
%91 = load i32, i32* %20
%92 = add nsw i32 %91, 2
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds double, double* %90, i64 %93
%95 = load double, double* %94
%96 = call double @llvm.fmuladd.f64(double %89, double %95, double %83)
%97 = call double @sqrt(double %96)
store double %97, double* %25
%98 = load double, double* %25
%99 = load double, double* %13
%100 = fdiv double %98, %99
store double %100, double* %26
%101 = load double*, double** %10
%102 = load i32, i32* %20
%103 = add nsw i32 %102, 2
%104 = sext i32 %103 to i64
%105 = getelementptr inbounds double, double* %101, i64 %104
%106 = load double, double* %105
%107 = load double, double* %25
%108 = fdiv double %106, %107
store double %108, double* %27
%109 = load double*, double** %10
%110 = load i32, i32* %20
%111 = add nsw i32 %110, 1
%112 = sext i32 %111 to i64
%113 = getelementptr inbounds double, double* %109, i64 %112
%114 = load double, double* %113
%115 = load double*, double** %10
%116 = load i32, i32* %20
%117 = add nsw i32 %116, 0
%118 = sext i32 %117 to i64
%119 = getelementptr inbounds double, double* %115, i64 %118
%120 = load double, double* %119
%121 = call double @atan2(double %114, double %120)
store double %121, double* %28
store i32 0, i32* %24
br label %122
122: ; preds = %146, %57
%123 = load i32, i32* %24
%124 = load i32, i32* %17
%125 = add nsw i32 %124, 1
%126 = icmp slt i32 %123, %125
br i1 %126, label %127, label %149
127: ; preds = %122
%128 = load i32, i32* %24
%129 = sitofp i32 %128 to double
%130 = load double, double* %28
%131 = fmul double %129, %130
%132 = fptosi double %131 to i32
%133 = call double @cos(i32 %132)
%134 = load i32, i32* %24
%135 = sext i32 %134 to i64
%136 = getelementptr inbounds double, double* %36, i64 %135
store double %133, double* %136
%137 = load i32, i32* %24
%138 = sitofp i32 %137 to double
%139 = load double, double* %28
%140 = fmul double %138, %139
%141 = fptosi double %140 to i32
%142 = call double @sin(i32 %141)
%143 = load i32, i32* %24
%144 = sext i32 %143 to i64
%145 = getelementptr inbounds double, double* %40, i64 %144
store double %142, double* %145
br label %146
146: ; preds = %127
%147 = load i32, i32* %24
%148 = add nsw i32 %147, 1
store i32 %148, i32* %24
br label %122
149: ; preds = %122
store i32 0, i32* %22
br label %150
150: ; preds = %243, %149
%151 = load i32, i32* %22
%152 = load i32, i32* %16
%153 = add nsw i32 %152, 1
%154 = icmp slt i32 %151, %153
br i1 %154, label %155, label %246
155: ; preds = %150
store i32 0, i32* %23
br label %156
156: ; preds = %239, %155
%157 = load i32, i32* %23
%158 = load i32, i32* %17
%159 = add nsw i32 %158, 1
%160 = icmp slt i32 %157, %159
br i1 %160, label %161, label %242
161: ; preds = %156
store i32 0, i32* %24
br label %162
162: ; preds = %235, %161
%163 = load i32, i32* %24
%164 = load i32, i32* %17
%165 = add nsw i32 %164, 1
%166 = icmp slt i32 %163, %165
br i1 %166, label %167, label %238
167: ; preds = %162
%168 = load i32, i32* %24
%169 = load i32, i32* %23
%170 = icmp sgt i32 %168, %169
br i1 %170, label %171, label %172
171: ; preds = %167
br label %235
172: ; preds = %167
%173 = load i32, i32* %24
%174 = load i32, i32* %17
%175 = add nsw i32 %174, 1
%176 = load i32, i32* %23
%177 = load i32, i32* %17
%178 = add nsw i32 %177, 1
%179 = load i32, i32* %22
%180 = mul nsw i32 %178, %179
%181 = add nsw i32 %176, %180
%182 = mul nsw i32 %175, %181
%183 = add nsw i32 %173, %182
store i32 %183, i32* %19
%184 = load double*, double** %14
%185 = load i32, i32* %19
%186 = sext i32 %185 to i64
%187 = getelementptr inbounds double, double* %184, i64 %186
%188 = load double, double* %187
%189 = fcmp oeq double %188, 0.000000e+00
%190 = zext i1 %189 to i32
%191 = load double*, double** %15
%192 = load i32, i32* %19
%193 = sext i32 %192 to i64
%194 = getelementptr inbounds double, double* %191, i64 %193
%195 = load double, double* %194
%196 = fcmp oeq double %195, 0.000000e+00
%197 = zext i1 %196 to i32
%198 = and i32 %190, %197
%199 = icmp ne i32 %198, 0
br i1 %199, label %200, label %201
200: ; preds = %172
br label %235
201: ; preds = %172
%202 = load double, double* %26
%203 = load double, double* %28
%204 = load double, double* %27
%205 = load i32, i32* %22
%206 = load i32, i32* %23
%207 = load i32, i32* %24
%208 = call double @rho_nlm(double %202, double %203, double %204, i32 %205, i32 %206, i32 %207)
%209 = load double*, double** %14
%210 = load i32, i32* %19
%211 = sext i32 %210 to i64
%212 = getelementptr inbounds double, double* %209, i64 %211
%213 = load double, double* %212
%214 = load i32, i32* %24
%215 = sext i32 %214 to i64
%216 = getelementptr inbounds double, double* %36, i64 %215
%217 = load double, double* %216
%218 = load double*, double** %15
%219 = load i32, i32* %19
%220 = sext i32 %219 to i64
%221 = getelementptr inbounds double, double* %218, i64 %220
%222 = load double, double* %221
%223 = load i32, i32* %24
%224 = sext i32 %223 to i64
%225 = getelementptr inbounds double, double* %40, i64 %224
%226 = load double, double* %225
%227 = fmul double %222, %226
%228 = call double @llvm.fmuladd.f64(double %213, double %217, double %227)
%229 = load double*, double** %18
%230 = load i32, i32* %21
%231 = sext i32 %230 to i64
%232 = getelementptr inbounds double, double* %229, i64 %231
%233 = load double, double* %232
%234 = call double @llvm.fmuladd.f64(double %208, double %228, double %233)
store double %234, double* %232
br label %235
235: ; preds = %201, %200, %171
%236 = load i32, i32* %24
%237 = add nsw i32 %236, 1
store i32 %237, i32* %24
br label %162
238: ; preds = %162
br label %239
239: ; preds = %238
%240 = load i32, i32* %23
%241 = add nsw i32 %240, 1
store i32 %241, i32* %23
br label %156
242: ; preds = %156
br label %243
243: ; preds = %242
%244 = load i32, i32* %22
%245 = add nsw i32 %244, 1
store i32 %245, i32* %22
br label %150
246: ; preds = %150
%247 = load double, double* %12
%248 = load double, double* %13
%249 = load double, double* %13
%250 = fmul double %248, %249
%251 = load double, double* %13
%252 = fmul double %250, %251
%253 = fdiv double %247, %252
%254 = load double*, double** %18
%255 = load i32, i32* %21
%256 = sext i32 %255 to i64
%257 = getelementptr inbounds double, double* %254, i64 %256
%258 = load double, double* %257
%259 = fmul double %258, %253
store double %259, double* %257
br label %260
260: ; preds = %246
%261 = load i32, i32* %21
%262 = add nsw i32 %261, 1
store i32 %262, i32* %21
br label %53
263: ; preds = %53
%264 = load i8*, i8** %29
ret void
}

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