#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 */
typedef int lmax;
typedef int l2;
typedef int l1;

/* Variables and functions */
double M_PI;
double *calloc(unsigned int, int);
double sqrt(double);
double *TM_poly2sph(double *M, int lmax, const int *const xyz,
                    const double *fac2) {
  unsigned int c1, c2, ijk;
  unsigned int l1, l2, lx1, ly1, lz1, m;
  unsigned int lx2, ly2, lz2;
  unsigned int lx, ly, lz;
  double s, s1, s2;
  double sum;
  unsigned int cdim = ((lmax) + 1) * ((lmax) + 2) * ((lmax) + 3) / 6;
  unsigned int ldim = ((lmax) + 1) * ((lmax) + 1);
  double *TM, *T, *TCS;
  T = TM = calloc(cdim * ldim, sizeof(double));
  for (l1 = 0; l1 <= lmax; l1++) {
    for (c1 = 0; c1 < ((l1) + 1) * ((l1) + 2) / 2; c1++) {
      ijk = ((((l1)-1) + 1) * (((l1)-1) + 2) * (((l1)-1) + 3) / 6 + (c1)) * 3;
      lx1 = xyz[ijk];
      ly1 = xyz[ijk + 1];
      lz1 = xyz[ijk + 2];
      T = TM +
          (((l1 - 1) + 1) * ((l1 - 1) + 2) * ((l1 - 1) + 3) / 6 + c1) * ldim;
      TCS = M;
      for (l2 = 0; l2 <= l1; l2++) {
        s1 = 4.0 * M_PI * fac2[2 * l2 + 1];
        for (m = 0; m < 2 * l2 + 1; m++) {
          sum = 0.0;
          cdim = ((l2) + 1) * ((l2) + 2) / 2;
          for (c2 = 0; c2 < cdim; c2++) {
            ijk =
                ((((l2)-1) + 1) * (((l2)-1) + 2) * (((l2)-1) + 3) / 6 + (c2)) *
                3;
            lx2 = xyz[ijk];
            ly2 = xyz[ijk + 1];
            lz2 = xyz[ijk + 2];
            lx = lx1 + lx2;
            ly = ly1 + ly2;
            lz = lz1 + lz2;
            if ((lx % 2 == 0) && (ly % 2 == 0) && (lz % 2 == 0)) {
              s = s1;
              s2 = 1.0 / fac2[l1 + l2 + 1];
              if (lx > 2)
                s2 *= fac2[lx - 1];
              if (ly > 2)
                s2 *= fac2[ly - 1];
              if (lz > 2)
                s2 *= fac2[lz - 1];
              if (lx2 > 1)
                s /= fac2[2 * lx2 - 1];
              if (ly2 > 1)
                s /= fac2[2 * ly2 - 1];
              if (lz2 > 1)
                s /= fac2[2 * lz2 - 1];
              sum += sqrt(s) * s2 * (*TCS);
            }
            TCS++;
          }
          (*T) = sum;
          T++;
        }
      }
    }
  }
  return TM;
}


x86 assembly (clang, -O0):
<TM_poly2sph>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    -0xc(%rbp),%ecx
add    $0x2,%ecx
imul   %ecx,%eax
mov    -0xc(%rbp),%ecx
add    $0x3,%ecx
imul   %ecx,%eax
mov    $0x6,%ecx
cltd
idiv   %ecx
mov    %eax,-0x84(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
imul   %ecx,%eax
mov    %eax,-0x88(%rbp)
mov    -0x84(%rbp),%edi
imul   -0x88(%rbp),%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,-0x90(%rbp)
mov    %rax,-0x98(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0xc(%rbp),%eax
ja     15aa <TM_poly2sph+0x48a>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x30(%rbp),%ecx
add    $0x1,%ecx
mov    -0x30(%rbp),%edx
add    $0x2,%edx
imul   %edx,%ecx
shr    $0x1,%ecx
cmp    %ecx,%eax
jae    1597 <TM_poly2sph+0x477>
mov    -0x30(%rbp),%eax
sub    $0x1,%eax
add    $0x1,%eax
mov    -0x30(%rbp),%ecx
sub    $0x1,%ecx
add    $0x2,%ecx
imul   %ecx,%eax
mov    -0x30(%rbp),%ecx
sub    $0x1,%ecx
add    $0x3,%ecx
imul   %ecx,%eax
mov    $0x6,%ecx
xor    %edx,%edx
div    %ecx
add    -0x24(%rbp),%eax
imul   $0x3,%eax,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x2c(%rbp),%ecx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x38(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,%ecx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    $0x2,%ecx
mov    %ecx,%ecx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x40(%rbp)
mov    -0x90(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    -0x30(%rbp),%eax
sub    $0x1,%eax
add    $0x1,%eax
mov    -0x30(%rbp),%ecx
sub    $0x1,%ecx
add    $0x2,%ecx
imul   %ecx,%eax
mov    -0x30(%rbp),%ecx
sub    $0x1,%ecx
add    $0x3,%ecx
imul   %ecx,%eax
mov    $0x6,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,%ecx
mov    -0xa8(%rbp),%rax
add    -0x24(%rbp),%ecx
imul   -0x88(%rbp),%ecx
mov    %ecx,%ecx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x98(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0xa0(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x30(%rbp),%eax
ja     1584 <TM_poly2sph+0x464>
movsd  0xd4a(%rip),%xmm0
mov    0x2d2b(%rip),%rax
mulsd  (%rax),%xmm0
mov    -0x20(%rbp),%rax
mov    -0x34(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
mov    %ecx,%ecx
mulsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x70(%rbp)
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
mov    -0x34(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jae    1571 <TM_poly2sph+0x451>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x80(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    -0x34(%rbp),%ecx
add    $0x2,%ecx
imul   %ecx,%eax
shr    $0x1,%eax
mov    %eax,-0x84(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x84(%rbp),%eax
jae    1541 <TM_poly2sph+0x421>
mov    -0x34(%rbp),%eax
sub    $0x1,%eax
add    $0x1,%eax
mov    -0x34(%rbp),%ecx
sub    $0x1,%ecx
add    $0x2,%ecx
imul   %ecx,%eax
mov    -0x34(%rbp),%ecx
sub    $0x1,%ecx
add    $0x3,%ecx
imul   %ecx,%eax
mov    $0x6,%ecx
xor    %edx,%edx
div    %ecx
add    -0x28(%rbp),%eax
imul   $0x3,%eax,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x2c(%rbp),%ecx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x48(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,%ecx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    $0x2,%ecx
mov    %ecx,%ecx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x50(%rbp)
mov    -0x38(%rbp),%eax
add    -0x48(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x3c(%rbp),%eax
add    -0x4c(%rbp),%eax
mov    %eax,-0x58(%rbp)
mov    -0x40(%rbp),%eax
add    -0x50(%rbp),%eax
mov    %eax,-0x5c(%rbp)
mov    -0x54(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
jne    1521 <TM_poly2sph+0x401>
mov    -0x58(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
jne    1521 <TM_poly2sph+0x401>
mov    -0x5c(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
jne    1521 <TM_poly2sph+0x401>
movsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x30(%rbp),%ecx
add    -0x34(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,%ecx
movsd  0xc10(%rip),%xmm0
divsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x78(%rbp)
cmpl   $0x2,-0x54(%rbp)
jbe    1427 <TM_poly2sph+0x307>
mov    -0x20(%rbp),%rax
mov    -0x54(%rbp),%ecx
sub    $0x1,%ecx
mov    %ecx,%ecx
movsd  (%rax,%rcx,8),%xmm0
mulsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
cmpl   $0x2,-0x58(%rbp)
jbe    144c <TM_poly2sph+0x32c>
mov    -0x20(%rbp),%rax
mov    -0x58(%rbp),%ecx
sub    $0x1,%ecx
mov    %ecx,%ecx
movsd  (%rax,%rcx,8),%xmm0
mulsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
cmpl   $0x2,-0x5c(%rbp)
jbe    1471 <TM_poly2sph+0x351>
mov    -0x20(%rbp),%rax
mov    -0x5c(%rbp),%ecx
sub    $0x1,%ecx
mov    %ecx,%ecx
movsd  (%rax,%rcx,8),%xmm0
mulsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
cmpl   $0x1,-0x48(%rbp)
jbe    149d <TM_poly2sph+0x37d>
mov    -0x20(%rbp),%rax
mov    -0x48(%rbp),%ecx
shl    $0x1,%ecx
sub    $0x1,%ecx
mov    %ecx,%ecx
movsd  (%rax,%rcx,8),%xmm1
movsd  -0x68(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
cmpl   $0x1,-0x4c(%rbp)
jbe    14c9 <TM_poly2sph+0x3a9>
mov    -0x20(%rbp),%rax
mov    -0x4c(%rbp),%ecx
shl    $0x1,%ecx
sub    $0x1,%ecx
mov    %ecx,%ecx
movsd  (%rax,%rcx,8),%xmm1
movsd  -0x68(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
cmpl   $0x1,-0x50(%rbp)
jbe    14f5 <TM_poly2sph+0x3d5>
mov    -0x20(%rbp),%rax
mov    -0x50(%rbp),%ecx
shl    $0x1,%ecx
sub    $0x1,%ecx
mov    %ecx,%ecx
movsd  (%rax,%rcx,8),%xmm1
movsd  -0x68(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
call   1040 <sqrt@plt>
mulsd  -0x78(%rbp),%xmm0
mov    -0xa0(%rbp),%rax
movsd  (%rax),%xmm2
movsd  -0x80(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
mov    -0xa0(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0xa0(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    131c <TM_poly2sph+0x1fc>
movsd  -0x80(%rbp),%xmm0
mov    -0x98(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x98(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x98(%rbp)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    12e1 <TM_poly2sph+0x1c1>
jmp    1576 <TM_poly2sph+0x456>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    12a2 <TM_poly2sph+0x182>
jmp    1589 <TM_poly2sph+0x469>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11b4 <TM_poly2sph+0x94>
jmp    159c <TM_poly2sph+0x47c>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    11a1 <TM_poly2sph+0x81>
mov    -0x90(%rbp),%rax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<TM_poly2sph>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xb8,%rsp
mov    %rcx,%rbx
mov    %rdx,%r14
mov    %rdi,0x48(%rsp)
lea    0x1(%rsi),%edx
lea    0x2(%rsi),%eax
imul   %edx,%eax
mov    %rsi,0x38(%rsp)
lea    0x3(%rsi),%ecx
imul   %eax,%ecx
movslq %ecx,%rax
imul   $0x2aaaaaab,%rax,%rdi
mov    %rdi,%rax
shr    $0x3f,%rax
shr    $0x20,%rdi
add    %eax,%edi
imul   %edx,%edx
mov    %edx,(%rsp)
imul   %edx,%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rbx,%r8
mov    %rax,0x20(%rsp)
xor    %eax,%eax
movsd  0xe7c(%rip),%xmm1
xorpd  %xmm2,%xmm2
mov    %r14,0x80(%rsp)
jmp    11af <TM_poly2sph+0x8f>
nopw   0x0(%rax,%rax,1)
mov    0x40(%rsp),%rax
cmp    0x38(%rsp),%eax
ja     14f3 <TM_poly2sph+0x3d3>
mov    %eax,%esi
lea    0x1(%rsi),%eax
lea    0x2(%rsi),%ecx
mov    %rax,0x40(%rsp)
imul   %eax,%ecx
cmp    $0x2,%ecx
jb     11a0 <TM_poly2sph+0x80>
mov    %rcx,%rax
shr    %eax
mov    %rax,0x50(%rsp)
imul   %esi,%ecx
mov    $0xaaaaaaab,%eax
imul   %rax,%rcx
shr    $0x22,%rcx
mov    %rcx,0x58(%rsp)
xor    %ecx,%ecx
mov    %rsi,0x70(%rsp)
jmp    1200 <TM_poly2sph+0xe0>
nopl   0x0(%rax)
mov    0x60(%rsp),%rcx
add    $0x1,%rcx
cmp    0x50(%rsp),%rcx
jae    11a0 <TM_poly2sph+0x80>
mov    0x58(%rsp),%rax
mov    %rcx,0x60(%rsp)
add    %ecx,%eax
lea    (%rax,%rax,2),%ecx
mov    (%r14,%rcx,4),%r9d
lea    0x1(%rax,%rax,2),%ecx
mov    (%r14,%rcx,4),%r10d
lea    (%rax,%rax,2),%ecx
add    $0x2,%ecx
mov    (%r14,%rcx,4),%r11d
imul   (%rsp),%eax
mov    0x20(%rsp),%rcx
lea    (%rcx,%rax,8),%rdi
mov    $0x1,%ecx
mov    $0xc,%eax
mov    %rax,0x28(%rsp)
mov    $0x6,%eax
xor    %edx,%edx
mov    0x48(%rsp),%rbx
mov    %rbx,0x30(%rsp)
xor    %ebx,%ebx
mov    %r10,0x88(%rsp)
jmp    128f <TM_poly2sph+0x16f>
xchg   %ax,%ax
mov    0xc(%rsp),%ecx
add    $0x2,%ecx
mov    0x8(%rsp),%ebx
mov    0x68(%rsp),%rax
add    %eax,%ebx
mov    0x28(%rsp),%rdx
add    %edx,%eax
add    $0x6,%edx
mov    %rdx,0x28(%rsp)
mov    %ebx,%edx
mov    0x4(%rsp),%ebx
cmp    %esi,%ebx
ja     11f0 <TM_poly2sph+0xd0>
mov    %rax,0x68(%rsp)
mov    %ebx,%eax
mov    %ecx,%ebx
mov    %edx,0x8(%rsp)
mov    %edx,%ecx
mov    $0xaaaaaaab,%edx
imul   %rdx,%rcx
shr    $0x22,%rcx
cmp    $0x2,%ebx
mov    $0x1,%edx
mov    %ebx,0xc(%rsp)
cmovae %ebx,%edx
lea    (%rcx,%rcx,2),%ecx
mov    %ecx,0x14(%rsp)
mov    0x2d20(%rip),%rcx
movsd  (%rcx),%xmm3
mulsd  0xd2c(%rip),%xmm3
lea    0x1(%rax,%rax,1),%ecx
mulsd  (%r8,%rcx,8),%xmm3
mov    %eax,%ecx
lea    (%rax,%rsi,1),%ebx
add    $0x1,%ebx
mov    %rbx,0xa8(%rsp)
add    $0x1,%eax
add    $0x2,%ecx
mov    %eax,0x4(%rsp)
imul   %eax,%ecx
mov    %ecx,%eax
shr    %eax
mov    %rax,0xb0(%rsp)
xor    %eax,%eax
mov    %edx,0x18(%rsp)
movsd  %xmm3,0x90(%rsp)
mov    %ecx,0x10(%rsp)
jmp    134e <TM_poly2sph+0x22e>
nopl   0x0(%rax)
add    %r12,0x30(%rsp)
mov    0x70(%rsp),%rsi
mov    0x78(%rsp),%rdi
mov    0x18(%rsp),%edx
mov    0x10(%rsp),%ecx
mov    0x1c(%rsp),%eax
movsd  %xmm4,(%rdi)
add    $0x8,%rdi
add    $0x1,%eax
cmp    %edx,%eax
je     1260 <TM_poly2sph+0x140>
xorpd  %xmm4,%xmm4
cmp    $0x2,%ecx
jb     133b <TM_poly2sph+0x21b>
mov    %eax,0x1c(%rsp)
mov    %rdi,0x78(%rsp)
xorpd  %xmm4,%xmm4
xor    %r12d,%r12d
mov    0x14(%rsp),%eax
mov    %eax,%r15d
xor    %r13d,%r13d
jmp    140d <TM_poly2sph+0x2ed>
cs nopw 0x0(%rax,%rax,1)
mov    %r8,%rbx
mov    %r9,%rbp
mov    %r11,%r14
movsd  %xmm4,0xa0(%rsp)
movsd  %xmm5,0x98(%rsp)
call   1040 <sqrt@plt>
movsd  0x98(%rsp),%xmm5
movsd  0xa0(%rsp),%xmm4
movsd  0x90(%rsp),%xmm3
mov    %r14,%r11
mov    0x88(%rsp),%r10
mov    0x80(%rsp),%r14
mov    %rbp,%r9
xorpd  %xmm2,%xmm2
movsd  0xc2b(%rip),%xmm1
mov    %rbx,%r8
mulsd  %xmm0,%xmm5
mov    0x30(%rsp),%rax
mulsd  (%rax,%r13,8),%xmm5
addsd  %xmm5,%xmm4
add    $0x1,%r13
add    $0x3,%r15d
add    $0x8,%r12
cmp    0xb0(%rsp),%r13
jae    1320 <TM_poly2sph+0x200>
mov    %r15d,%eax
mov    (%r14,%rax,4),%ecx
lea    (%rcx,%r9,1),%ebp
test   $0x1,%bpl
jne    13f3 <TM_poly2sph+0x2d3>
lea    0x1(%r15),%eax
mov    (%r14,%rax,4),%edx
lea    (%rdx,%r10,1),%edi
mov    %edi,%eax
and    $0x1,%eax
jne    13f3 <TM_poly2sph+0x2d3>
lea    0x2(%r15),%eax
mov    (%r14,%rax,4),%eax
lea    (%rax,%r11,1),%esi
mov    %esi,%ebx
and    $0x1,%ebx
jne    13f3 <TM_poly2sph+0x2d3>
movapd %xmm1,%xmm5
mov    0xa8(%rsp),%rbx
divsd  (%r8,%rbx,8),%xmm5
cmp    $0x3,%ebp
jae    1490 <TM_poly2sph+0x370>
cmp    $0x3,%edi
jae    149e <TM_poly2sph+0x37e>
cmp    $0x3,%esi
jb     146e <TM_poly2sph+0x34e>
add    $0xffffffff,%esi
mulsd  (%r8,%rsi,8),%xmm5
movapd %xmm3,%xmm0
cmp    $0x2,%ecx
jae    14b0 <TM_poly2sph+0x390>
cmp    $0x2,%edx
jae    14c4 <TM_poly2sph+0x3a4>
cmp    $0x2,%eax
jae    14d5 <TM_poly2sph+0x3b5>
ucomisd %xmm2,%xmm0
jb     1380 <TM_poly2sph+0x260>
jmp    14ea <TM_poly2sph+0x3ca>
nopl   (%rax)
add    $0xffffffff,%ebp
mulsd  (%r8,%rbp,8),%xmm5
cmp    $0x3,%edi
jb     1460 <TM_poly2sph+0x340>
add    $0xffffffff,%edi
mulsd  (%r8,%rdi,8),%xmm5
cmp    $0x3,%esi
jae    1465 <TM_poly2sph+0x345>
jmp    146e <TM_poly2sph+0x34e>
xchg   %ax,%ax
add    %ecx,%ecx
add    $0xffffffff,%ecx
movapd %xmm3,%xmm0
divsd  (%r8,%rcx,8),%xmm0
cmp    $0x2,%edx
jb     147c <TM_poly2sph+0x35c>
lea    (%rdx,%rdx,1),%ecx
add    $0xffffffff,%ecx
divsd  (%r8,%rcx,8),%xmm0
cmp    $0x2,%eax
jb     1481 <TM_poly2sph+0x361>
add    %eax,%eax
add    $0xffffffff,%eax
divsd  (%r8,%rax,8),%xmm0
ucomisd %xmm2,%xmm0
jb     1380 <TM_poly2sph+0x260>
sqrtsd %xmm0,%xmm0
jmp    13e0 <TM_poly2sph+0x2c0>
mov    0x20(%rsp),%rax
add    $0xb8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@M_PI = global double 0.000000e+00
define double* @TM_poly2sph(double* %0, i32 %1, i32* %2, double* %3) {
%5 = alloca double*
%6 = alloca i32
%7 = alloca i32*
%8 = alloca double*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca double
%25 = alloca double
%26 = alloca double
%27 = alloca double
%28 = alloca i32
%29 = alloca i32
%30 = alloca double*
%31 = alloca double*
%32 = alloca double*
store double* %0, double** %5
store i32 %1, i32* %6
store i32* %2, i32** %7
store double* %3, double** %8
%33 = load i32, i32* %6
%34 = add nsw i32 %33, 1
%35 = load i32, i32* %6
%36 = add nsw i32 %35, 2
%37 = mul nsw i32 %34, %36
%38 = load i32, i32* %6
%39 = add nsw i32 %38, 3
%40 = mul nsw i32 %37, %39
%41 = sdiv i32 %40, 6
store i32 %41, i32* %28
%42 = load i32, i32* %6
%43 = add nsw i32 %42, 1
%44 = load i32, i32* %6
%45 = add nsw i32 %44, 1
%46 = mul nsw i32 %43, %45
store i32 %46, i32* %29
%47 = load i32, i32* %28
%48 = load i32, i32* %29
%49 = mul i32 %47, %48
%50 = call double* @calloc(i32 %49, i32 8)
store double* %50, double** %30
store double* %50, double** %31
store i32 0, i32* %12
br label %51
51: ; preds = %320, %4
%52 = load i32, i32* %12
%53 = load i32, i32* %6
%54 = icmp ule i32 %52, %53
br i1 %54, label %55, label %323
55: ; preds = %51
store i32 0, i32* %9
br label %56
56: ; preds = %316, %55
%57 = load i32, i32* %9
%58 = load i32, i32* %12
%59 = add i32 %58, 1
%60 = load i32, i32* %12
%61 = add i32 %60, 2
%62 = mul i32 %59, %61
%63 = udiv i32 %62, 2
%64 = icmp ult i32 %57, %63
br i1 %64, label %65, label %319
65: ; preds = %56
%66 = load i32, i32* %12
%67 = sub i32 %66, 1
%68 = add i32 %67, 1
%69 = load i32, i32* %12
%70 = sub i32 %69, 1
%71 = add i32 %70, 2
%72 = mul i32 %68, %71
%73 = load i32, i32* %12
%74 = sub i32 %73, 1
%75 = add i32 %74, 3
%76 = mul i32 %72, %75
%77 = udiv i32 %76, 6
%78 = load i32, i32* %9
%79 = add i32 %77, %78
%80 = mul i32 %79, 3
store i32 %80, i32* %11
%81 = load i32*, i32** %7
%82 = load i32, i32* %11
%83 = zext i32 %82 to i64
%84 = getelementptr inbounds i32, i32* %81, i64 %83
%85 = load i32, i32* %84
store i32 %85, i32* %14
%86 = load i32*, i32** %7
%87 = load i32, i32* %11
%88 = add i32 %87, 1
%89 = zext i32 %88 to i64
%90 = getelementptr inbounds i32, i32* %86, i64 %89
%91 = load i32, i32* %90
store i32 %91, i32* %15
%92 = load i32*, i32** %7
%93 = load i32, i32* %11
%94 = add i32 %93, 2
%95 = zext i32 %94 to i64
%96 = getelementptr inbounds i32, i32* %92, i64 %95
%97 = load i32, i32* %96
store i32 %97, i32* %16
%98 = load double*, double** %30
%99 = load i32, i32* %12
%100 = sub i32 %99, 1
%101 = add i32 %100, 1
%102 = load i32, i32* %12
%103 = sub i32 %102, 1
%104 = add i32 %103, 2
%105 = mul i32 %101, %104
%106 = load i32, i32* %12
%107 = sub i32 %106, 1
%108 = add i32 %107, 3
%109 = mul i32 %105, %108
%110 = udiv i32 %109, 6
%111 = load i32, i32* %9
%112 = add i32 %110, %111
%113 = load i32, i32* %29
%114 = mul i32 %112, %113
%115 = zext i32 %114 to i64
%116 = getelementptr inbounds double, double* %98, i64 %115
store double* %116, double** %31
%117 = load double*, double** %5
store double* %117, double** %32
store i32 0, i32* %13
br label %118
118: ; preds = %312, %65
%119 = load i32, i32* %13
%120 = load i32, i32* %12
%121 = icmp ule i32 %119, %120
br i1 %121, label %122, label %315
122: ; preds = %118
%123 = load double, double* @M_PI
%124 = fmul double 4.000000e+00, %123
%125 = load double*, double** %8
%126 = load i32, i32* %13
%127 = mul i32 2, %126
%128 = add i32 %127, 1
%129 = zext i32 %128 to i64
%130 = getelementptr inbounds double, double* %125, i64 %129
%131 = load double, double* %130
%132 = fmul double %124, %131
store double %132, double* %25
store i32 0, i32* %17
br label %133
133: ; preds = %308, %122
%134 = load i32, i32* %17
%135 = load i32, i32* %13
%136 = mul i32 2, %135
%137 = add i32 %136, 1
%138 = icmp ult i32 %134, %137
br i1 %138, label %139, label %311
139: ; preds = %133
store double 0.000000e+00, double* %27
%140 = load i32, i32* %13
%141 = add i32 %140, 1
%142 = load i32, i32* %13
%143 = add i32 %142, 2
%144 = mul i32 %141, %143
%145 = udiv i32 %144, 2
store i32 %145, i32* %28
store i32 0, i32* %10
br label %146
146: ; preds = %300, %139
%147 = load i32, i32* %10
%148 = load i32, i32* %28
%149 = icmp ult i32 %147, %148
br i1 %149, label %150, label %303
150: ; preds = %146
%151 = load i32, i32* %13
%152 = sub i32 %151, 1
%153 = add i32 %152, 1
%154 = load i32, i32* %13
%155 = sub i32 %154, 1
%156 = add i32 %155, 2
%157 = mul i32 %153, %156
%158 = load i32, i32* %13
%159 = sub i32 %158, 1
%160 = add i32 %159, 3
%161 = mul i32 %157, %160
%162 = udiv i32 %161, 6
%163 = load i32, i32* %10
%164 = add i32 %162, %163
%165 = mul i32 %164, 3
store i32 %165, i32* %11
%166 = load i32*, i32** %7
%167 = load i32, i32* %11
%168 = zext i32 %167 to i64
%169 = getelementptr inbounds i32, i32* %166, i64 %168
%170 = load i32, i32* %169
store i32 %170, i32* %18
%171 = load i32*, i32** %7
%172 = load i32, i32* %11
%173 = add i32 %172, 1
%174 = zext i32 %173 to i64
%175 = getelementptr inbounds i32, i32* %171, i64 %174
%176 = load i32, i32* %175
store i32 %176, i32* %19
%177 = load i32*, i32** %7
%178 = load i32, i32* %11
%179 = add i32 %178, 2
%180 = zext i32 %179 to i64
%181 = getelementptr inbounds i32, i32* %177, i64 %180
%182 = load i32, i32* %181
store i32 %182, i32* %20
%183 = load i32, i32* %14
%184 = load i32, i32* %18
%185 = add i32 %183, %184
store i32 %185, i32* %21
%186 = load i32, i32* %15
%187 = load i32, i32* %19
%188 = add i32 %186, %187
store i32 %188, i32* %22
%189 = load i32, i32* %16
%190 = load i32, i32* %20
%191 = add i32 %189, %190
store i32 %191, i32* %23
%192 = load i32, i32* %21
%193 = urem i32 %192, 2
%194 = icmp eq i32 %193, 0
br i1 %194, label %195, label %297
195: ; preds = %150
%196 = load i32, i32* %22
%197 = urem i32 %196, 2
%198 = icmp eq i32 %197, 0
br i1 %198, label %199, label %297
199: ; preds = %195
%200 = load i32, i32* %23
%201 = urem i32 %200, 2
%202 = icmp eq i32 %201, 0
br i1 %202, label %203, label %297
203: ; preds = %199
%204 = load double, double* %25
store double %204, double* %24
%205 = load double*, double** %8
%206 = load i32, i32* %12
%207 = load i32, i32* %13
%208 = add i32 %206, %207
%209 = add i32 %208, 1
%210 = zext i32 %209 to i64
%211 = getelementptr inbounds double, double* %205, i64 %210
%212 = load double, double* %211
%213 = fdiv double 1.000000e+00, %212
store double %213, double* %26
%214 = load i32, i32* %21
%215 = icmp ugt i32 %214, 2
br i1 %215, label %216, label %225
216: ; preds = %203
%217 = load double*, double** %8
%218 = load i32, i32* %21
%219 = sub i32 %218, 1
%220 = zext i32 %219 to i64
%221 = getelementptr inbounds double, double* %217, i64 %220
%222 = load double, double* %221
%223 = load double, double* %26
%224 = fmul double %223, %222
store double %224, double* %26
br label %225
225: ; preds = %216, %203
%226 = load i32, i32* %22
%227 = icmp ugt i32 %226, 2
br i1 %227, label %228, label %237
228: ; preds = %225
%229 = load double*, double** %8
%230 = load i32, i32* %22
%231 = sub i32 %230, 1
%232 = zext i32 %231 to i64
%233 = getelementptr inbounds double, double* %229, i64 %232
%234 = load double, double* %233
%235 = load double, double* %26
%236 = fmul double %235, %234
store double %236, double* %26
br label %237
237: ; preds = %228, %225
%238 = load i32, i32* %23
%239 = icmp ugt i32 %238, 2
br i1 %239, label %240, label %249
240: ; preds = %237
%241 = load double*, double** %8
%242 = load i32, i32* %23
%243 = sub i32 %242, 1
%244 = zext i32 %243 to i64
%245 = getelementptr inbounds double, double* %241, i64 %244
%246 = load double, double* %245
%247 = load double, double* %26
%248 = fmul double %247, %246
store double %248, double* %26
br label %249
249: ; preds = %240, %237
%250 = load i32, i32* %18
%251 = icmp ugt i32 %250, 1
br i1 %251, label %252, label %262
252: ; preds = %249
%253 = load double*, double** %8
%254 = load i32, i32* %18
%255 = mul i32 2, %254
%256 = sub i32 %255, 1
%257 = zext i32 %256 to i64
%258 = getelementptr inbounds double, double* %253, i64 %257
%259 = load double, double* %258
%260 = load double, double* %24
%261 = fdiv double %260, %259
store double %261, double* %24
br label %262
262: ; preds = %252, %249
%263 = load i32, i32* %19
%264 = icmp ugt i32 %263, 1
br i1 %264, label %265, label %275
265: ; preds = %262
%266 = load double*, double** %8
%267 = load i32, i32* %19
%268 = mul i32 2, %267
%269 = sub i32 %268, 1
%270 = zext i32 %269 to i64
%271 = getelementptr inbounds double, double* %266, i64 %270
%272 = load double, double* %271
%273 = load double, double* %24
%274 = fdiv double %273, %272
store double %274, double* %24
br label %275
275: ; preds = %265, %262
%276 = load i32, i32* %20
%277 = icmp ugt i32 %276, 1
br i1 %277, label %278, label %288
278: ; preds = %275
%279 = load double*, double** %8
%280 = load i32, i32* %20
%281 = mul i32 2, %280
%282 = sub i32 %281, 1
%283 = zext i32 %282 to i64
%284 = getelementptr inbounds double, double* %279, i64 %283
%285 = load double, double* %284
%286 = load double, double* %24
%287 = fdiv double %286, %285
store double %287, double* %24
br label %288
288: ; preds = %278, %275
%289 = load double, double* %24
%290 = call double @sqrt(double %289)
%291 = load double, double* %26
%292 = fmul double %290, %291
%293 = load double*, double** %32
%294 = load double, double* %293
%295 = load double, double* %27
%296 = call double @llvm.fmuladd.f64(double %292, double %294, double %295)
store double %296, double* %27
br label %297
297: ; preds = %288, %199, %195, %150
%298 = load double*, double** %32
%299 = getelementptr inbounds double, double* %298, i32 1
store double* %299, double** %32
br label %300
300: ; preds = %297
%301 = load i32, i32* %10
%302 = add i32 %301, 1
store i32 %302, i32* %10
br label %146
303: ; preds = %146
%304 = load double, double* %27
%305 = load double*, double** %31
store double %304, double* %305
%306 = load double*, double** %31
%307 = getelementptr inbounds double, double* %306, i32 1
store double* %307, double** %31
br label %308
308: ; preds = %303
%309 = load i32, i32* %17
%310 = add i32 %309, 1
store i32 %310, i32* %17
br label %133
311: ; preds = %133
br label %312
312: ; preds = %311
%313 = load i32, i32* %13
%314 = add i32 %313, 1
store i32 %314, i32* %13
br label %118
315: ; preds = %118
br label %316
316: ; preds = %315
%317 = load i32, i32* %9
%318 = add i32 %317, 1
store i32 %318, i32* %9
br label %56
319: ; preds = %56
br label %320
320: ; preds = %319
%321 = load i32, i32* %12
%322 = add i32 %321, 1
store i32 %322, i32* %12
br label %51
323: ; preds = %51
%324 = load double*, double** %30
ret double* %324
}

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
define noalias double* @TM_poly2sph(double* nocapture %0, i32 %1, i32* nocapture %2, double* nocapture %3) {
%5 = add nsw i32 %1, 1
%6 = add nsw i32 %1, 2
%7 = mul nsw i32 %5, %6
%8 = add nsw i32 %1, 3
%9 = mul nsw i32 %7, %8
%10 = sdiv i32 %9, 6
%11 = mul nsw i32 %5, %5
%12 = mul i32 %10, %11
%13 = tail call double* @calloc(i32 %12, i32 8)
br label %16
14: ; preds = %182, %16
%15 = icmp ugt i32 %18, %1
br i1 %15, label %185, label %16
16: ; preds = %4, %14
%17 = phi i32 [ 0, %4 ], [ %18, %14 ]
%18 = add i32 %17, 1
%19 = add i32 %17, 2
%20 = mul i32 %18, %19
%21 = icmp ult i32 %20, 2
br i1 %21, label %14, label %22
22: ; preds = %16
%23 = lshr i32 %20, 1
%24 = mul i32 %20, %17
%25 = udiv i32 %24, 6
%26 = zext i32 %23 to i64
br label %27
27: ; preds = %22, %182
%28 = phi i64 [ 0, %22 ], [ %183, %182 ]
%29 = trunc i64 %28 to i32
%30 = add i32 %25, %29
%31 = mul i32 %30, 3
%32 = zext i32 %31 to i64
%33 = getelementptr inbounds i32, i32* %2, i64 %32
%34 = load i32, i32* %33
%35 = add i32 %31, 1
%36 = zext i32 %35 to i64
%37 = getelementptr inbounds i32, i32* %2, i64 %36
%38 = load i32, i32* %37
%39 = add i32 %31, 2
%40 = zext i32 %39 to i64
%41 = getelementptr inbounds i32, i32* %2, i64 %40
%42 = load i32, i32* %41
%43 = mul i32 %30, %11
%44 = zext i32 %43 to i64
%45 = getelementptr inbounds double, double* %13, i64 %44
br label %46
46: ; preds = %27, %179
%47 = phi i32 [ 1, %27 ], [ %181, %179 ]
%48 = phi double* [ %0, %27 ], [ %175, %179 ]
%49 = phi double* [ %45, %27 ], [ %176, %179 ]
%50 = phi i32 [ 0, %27 ], [ %60, %179 ]
%51 = call i32 @llvm.umax.i32(i32 %47, i32 1)
%52 = load double, double* @M_PI
%53 = fmul double %52, 4.000000e+00
%54 = shl i32 %50, 1
%55 = or i32 %54, 1
%56 = zext i32 %55 to i64
%57 = getelementptr inbounds double, double* %3, i64 %56
%58 = load double, double* %57
%59 = fmul double %53, %58
%60 = add i32 %50, 1
%61 = add i32 %50, 2
%62 = mul i32 %60, %61
%63 = lshr i32 %62, 1
%64 = icmp ult i32 %62, 2
%65 = mul i32 %62, %50
%66 = udiv i32 %65, 6
%67 = add i32 %60, %17
%68 = zext i32 %67 to i64
%69 = getelementptr inbounds double, double* %3, i64 %68
%70 = zext i32 %63 to i64
br label %71
71: ; preds = %46, %173
%72 = phi double* [ %48, %46 ], [ %175, %173 ]
%73 = phi double* [ %49, %46 ], [ %176, %173 ]
%74 = phi i32 [ 0, %46 ], [ %177, %173 ]
br i1 %64, label %173, label %75
75: ; preds = %71, %168
%76 = phi i64 [ %171, %168 ], [ 0, %71 ]
%77 = phi double* [ %170, %168 ], [ %72, %71 ]
%78 = phi double [ %169, %168 ], [ 0.000000e+00, %71 ]
%79 = trunc i64 %76 to i32
%80 = add i32 %66, %79
%81 = mul i32 %80, 3
%82 = zext i32 %81 to i64
%83 = getelementptr inbounds i32, i32* %2, i64 %82
%84 = load i32, i32* %83
%85 = add i32 %81, 1
%86 = zext i32 %85 to i64
%87 = getelementptr inbounds i32, i32* %2, i64 %86
%88 = load i32, i32* %87
%89 = add i32 %81, 2
%90 = zext i32 %89 to i64
%91 = getelementptr inbounds i32, i32* %2, i64 %90
%92 = load i32, i32* %91
%93 = add i32 %84, %34
%94 = add i32 %88, %38
%95 = add i32 %92, %42
%96 = and i32 %93, 1
%97 = icmp eq i32 %96, 0
%98 = and i32 %94, 1
%99 = icmp eq i32 %98, 0
%100 = select i1 %97, i1 %99, i1 false
%101 = and i32 %95, 1
%102 = icmp eq i32 %101, 0
%103 = select i1 %100, i1 %102, i1 false
br i1 %103, label %104, label %168
104: ; preds = %75
%105 = load double, double* %69
%106 = fdiv double 1.000000e+00, %105
%107 = icmp ugt i32 %93, 2
br i1 %107, label %108, label %114
108: ; preds = %104
%109 = add i32 %93, -1
%110 = zext i32 %109 to i64
%111 = getelementptr inbounds double, double* %3, i64 %110
%112 = load double, double* %111
%113 = fmul double %106, %112
br label %114
114: ; preds = %108, %104
%115 = phi double [ %113, %108 ], [ %106, %104 ]
%116 = icmp ugt i32 %94, 2
br i1 %116, label %117, label %123
117: ; preds = %114
%118 = add i32 %94, -1
%119 = zext i32 %118 to i64
%120 = getelementptr inbounds double, double* %3, i64 %119
%121 = load double, double* %120
%122 = fmul double %115, %121
br label %123
123: ; preds = %117, %114
%124 = phi double [ %122, %117 ], [ %115, %114 ]
%125 = icmp ugt i32 %95, 2
br i1 %125, label %126, label %132
126: ; preds = %123
%127 = add i32 %95, -1
%128 = zext i32 %127 to i64
%129 = getelementptr inbounds double, double* %3, i64 %128
%130 = load double, double* %129
%131 = fmul double %124, %130
br label %132
132: ; preds = %126, %123
%133 = phi double [ %131, %126 ], [ %124, %123 ]
%134 = icmp ugt i32 %84, 1
br i1 %134, label %135, label %142
135: ; preds = %132
%136 = shl i32 %84, 1
%137 = add i32 %136, -1
%138 = zext i32 %137 to i64
%139 = getelementptr inbounds double, double* %3, i64 %138
%140 = load double, double* %139
%141 = fdiv double %59, %140
br label %142
142: ; preds = %135, %132
%143 = phi double [ %141, %135 ], [ %59, %132 ]
%144 = icmp ugt i32 %88, 1
br i1 %144, label %145, label %152
145: ; preds = %142
%146 = shl i32 %88, 1
%147 = add i32 %146, -1
%148 = zext i32 %147 to i64
%149 = getelementptr inbounds double, double* %3, i64 %148
%150 = load double, double* %149
%151 = fdiv double %143, %150
br label %152
152: ; preds = %145, %142
%153 = phi double [ %151, %145 ], [ %143, %142 ]
%154 = icmp ugt i32 %92, 1
br i1 %154, label %155, label %162
155: ; preds = %152
%156 = shl i32 %92, 1
%157 = add i32 %156, -1
%158 = zext i32 %157 to i64
%159 = getelementptr inbounds double, double* %3, i64 %158
%160 = load double, double* %159
%161 = fdiv double %153, %160
br label %162
162: ; preds = %155, %152
%163 = phi double [ %161, %155 ], [ %153, %152 ]
%164 = tail call double @sqrt(double %163)
%165 = fmul double %133, %164
%166 = load double, double* %77
%167 = tail call double @llvm.fmuladd.f64(double %165, double %166, double %78)
br label %168
168: ; preds = %162, %75
%169 = phi double [ %167, %162 ], [ %78, %75 ]
%170 = getelementptr inbounds double, double* %77, i64 1
%171 = add nuw nsw i64 %76, 1
%172 = icmp ult i64 %171, %70
br i1 %172, label %75, label %173
173: ; preds = %168, %71
%174 = phi double [ 0.000000e+00, %71 ], [ %169, %168 ]
%175 = phi double* [ %72, %71 ], [ %170, %168 ]
store double %174, double* %73
%176 = getelementptr inbounds double, double* %73, i64 1
%177 = add nuw i32 %74, 1
%178 = icmp eq i32 %177, %51
br i1 %178, label %179, label %71
179: ; preds = %173
%180 = icmp ugt i32 %60, %17
%181 = add i32 %47, 2
br i1 %180, label %182, label %46
182: ; preds = %179
%183 = add nuw nsw i64 %28, 1
%184 = icmp ult i64 %183, %26
br i1 %184, label %27, label %14
185: ; preds = %14
ret double* %13
}