#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
double M_PI;
double acos(double);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ fmod(int, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int, long);
int /*<<< orphan*/ mk_pix2xy(int *, int *);
int /*<<< orphan*/ stderr;
void pix2ang_nest(long nside, long ipix, double *theta, double *phi) {
  int npix, npface, face_num;
  int ipf, ip_low, ip_trunc, ip_med, ip_hi;
  int ix, iy, jrt, jr, nr, jpt, jp, kshift, nl4;
  double z, fn, fact1, fact2;
  double piover2 = 0.5 * M_PI;
  int ns_max = 8192;
  static int pix2x[1024], pix2y[1024];
  int jrll[12], jpll[12];
  jrll[0] = 2;
  jrll[1] = 2;
  jrll[2] = 2;
  jrll[3] = 2;
  jrll[4] = 3;
  jrll[5] = 3;
  jrll[6] = 3;
  jrll[7] = 3;
  jrll[8] = 4;
  jrll[9] = 4;
  jrll[10] = 4;
  jrll[11] = 4;
  jpll[0] = 1;
  jpll[1] = 3;
  jpll[2] = 5;
  jpll[3] = 7;
  jpll[4] = 0;
  jpll[5] = 2;
  jpll[6] = 4;
  jpll[7] = 6;
  jpll[8] = 1;
  jpll[9] = 3;
  jpll[10] = 5;
  jpll[11] = 7;
  if (nside < 1 || nside > ns_max) {
    fprintf(stderr, "%s (%d): nside out of range: %ld\n",
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/bkloppenborg/simtoi/refs/heads/master/"
            "lib/chealpix/pix2ang_nest.c",
            87, nside);
    exit(0);
  }
  npix = 12 * nside * nside;
  if (ipix < 0 || ipix > npix - 1) {
    fprintf(stderr, "%s (%d): ipix out of range: %ld\n",
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/bkloppenborg/simtoi/refs/heads/master/"
            "lib/chealpix/pix2ang_nest.c",
            92, ipix);
    exit(0);
  }
  if (pix2x[1023] <= 0)
    mk_pix2xy(pix2x, pix2y);
  fn = 1. * nside;
  fact1 = 1. / (3. * fn * fn);
  fact2 = 2. / (3. * fn);
  nl4 = 4 * nside;
  npface = nside * nside;
  face_num = ipix / npface;
  ipf = (int)fmod(ipix, npface);
  ip_low = (int)fmod(ipf, 1024);
  ip_trunc = ipf / 1024;
  ip_med = (int)fmod(ip_trunc, 1024);
  ip_hi = ip_trunc / 1024;
  ix = 1024 * pix2x[ip_hi] + 32 * pix2x[ip_med] + pix2x[ip_low];
  iy = 1024 * pix2y[ip_hi] + 32 * pix2y[ip_med] + pix2y[ip_low];
  jrt = ix + iy;
  jpt = ix - iy;
  jr = jrll[face_num] * nside - jrt - 1;
  nr = nside;
  z = (2 * nside - jr) * fact2;
  kshift = (int)fmod(jr - nside, 2);
  if (jr < nside) {
    nr = jr;
    z = 1. - nr * nr * fact1;
    kshift = 0;
  } else {
    if (jr > 3 * nside) {
      nr = nl4 - jr;
      z = -1. + nr * nr * fact1;
      kshift = 0;
    }
  }
  *theta = acos(z);
  jp = (jpll[face_num] * nr + jpt + 1 + kshift) / 2;
  if (jp > nl4)
    jp = jp - nl4;
  if (jp < 1)
    jp = jp + nl4;
  *phi = (jp - (kshift + 1) * 0.5) * (piover2 / nr);
}


x86 assembly (clang, -O0):
<pix2ang_nest>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movsd  0xe8d(%rip),%xmm0
mov    0x2e6e(%rip),%rax
mulsd  (%rax),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movl   $0x2000,-0x94(%rbp)
movl   $0x2,-0xd0(%rbp)
movl   $0x2,-0xcc(%rbp)
movl   $0x2,-0xc8(%rbp)
movl   $0x2,-0xc4(%rbp)
movl   $0x3,-0xc0(%rbp)
movl   $0x3,-0xbc(%rbp)
movl   $0x3,-0xb8(%rbp)
movl   $0x3,-0xb4(%rbp)
movl   $0x4,-0xb0(%rbp)
movl   $0x4,-0xac(%rbp)
movl   $0x4,-0xa8(%rbp)
movl   $0x4,-0xa4(%rbp)
movl   $0x1,-0x100(%rbp)
movl   $0x3,-0xfc(%rbp)
movl   $0x5,-0xf8(%rbp)
movl   $0x7,-0xf4(%rbp)
movl   $0x0,-0xf0(%rbp)
movl   $0x2,-0xec(%rbp)
movl   $0x4,-0xe8(%rbp)
movl   $0x6,-0xe4(%rbp)
movl   $0x1,-0xe0(%rbp)
movl   $0x3,-0xdc(%rbp)
movl   $0x5,-0xd8(%rbp)
movl   $0x7,-0xd4(%rbp)
cmpq   $0x1,-0x8(%rbp)
jl     129f <pix2ang_nest+0x14f>
mov    -0x8(%rbp),%rax
movslq -0x94(%rbp),%rcx
cmp    %rcx,%rax
jle    12cb <pix2ang_nest+0x17b>
mov    0x2d32(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%r8
lea    0xd75(%rip),%rsi
lea    0xd90(%rip),%rdx
mov    $0x57,%ecx
call   1060 <fprintf@plt>
xor    %edi,%edi
call   1070 <exit@plt>
imul   $0xc,-0x8(%rbp),%rax
imul   -0x8(%rbp),%rax
mov    %eax,-0x24(%rbp)
cmpq   $0x0,-0x10(%rbp)
jl     12f9 <pix2ang_nest+0x1a9>
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
cmp    %rcx,%rax
jle    1325 <pix2ang_nest+0x1d5>
mov    0x2cd8(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%r8
lea    0xdd9(%rip),%rsi
lea    0xd36(%rip),%rdx
mov    $0x5c,%ecx
call   1060 <fprintf@plt>
xor    %edi,%edi
call   1070 <exit@plt>
cmpl   $0x0,0x3d40(%rip)
jg     1345 <pix2ang_nest+0x1f5>
lea    0x2d37(%rip),%rdi
lea    0x3d30(%rip),%rsi
call   1050 <mk_pix2xy@plt>
cvtsi2sdq -0x8(%rbp),%xmm1
movsd  0xcc5(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  0xcac(%rip),%xmm1
mulsd  -0x78(%rbp),%xmm1
mulsd  -0x78(%rbp),%xmm1
movsd  0xca2(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  0xc89(%rip),%xmm1
mulsd  -0x78(%rbp),%xmm1
movsd  0xc74(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
mov    -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,-0x64(%rbp)
mov    -0x8(%rbp),%rax
imul   -0x8(%rbp),%rax
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
cqto
idiv   %rcx
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    %eax,%edi
mov    -0x28(%rbp),%esi
call   1030 <fmod@plt>
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%edi
mov    $0x400,%esi
call   1030 <fmod@plt>
mov    %eax,-0x34(%rbp)
mov    -0x30(%rbp),%eax
mov    $0x400,%ecx
cltd
idiv   %ecx
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%edi
mov    $0x400,%esi
call   1030 <fmod@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x38(%rbp),%eax
mov    $0x400,%ecx
cltd
idiv   %ecx
mov    %eax,-0x40(%rbp)
movslq -0x40(%rbp),%rcx
lea    0x2c51(%rip),%rax
mov    (%rax,%rcx,4),%eax
shl    $0xa,%eax
movslq -0x3c(%rbp),%rdx
lea    0x2c40(%rip),%rcx
mov    (%rcx,%rdx,4),%ecx
shl    $0x5,%ecx
add    %ecx,%eax
movslq -0x34(%rbp),%rdx
lea    0x2c2d(%rip),%rcx
add    (%rcx,%rdx,4),%eax
mov    %eax,-0x44(%rbp)
movslq -0x40(%rbp),%rcx
lea    0x3c1c(%rip),%rax
mov    (%rax,%rcx,4),%eax
shl    $0xa,%eax
movslq -0x3c(%rbp),%rdx
lea    0x3c0b(%rip),%rcx
mov    (%rcx,%rdx,4),%ecx
shl    $0x5,%ecx
add    %ecx,%eax
movslq -0x34(%rbp),%rdx
lea    0x3bf8(%rip),%rcx
add    (%rcx,%rdx,4),%eax
mov    %eax,-0x48(%rbp)
mov    -0x44(%rbp),%eax
add    -0x48(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x44(%rbp),%eax
sub    -0x48(%rbp),%eax
mov    %eax,-0x58(%rbp)
movslq -0x2c(%rbp),%rax
movslq -0xd0(%rbp,%rax,4),%rax
ff
imul   -0x8(%rbp),%rax
movslq -0x4c(%rbp),%rcx
sub    %rcx,%rax
sub    $0x1,%rax
mov    %eax,-0x50(%rbp)
mov    -0x8(%rbp),%rax
mov    %eax,-0x54(%rbp)
mov    -0x8(%rbp),%rax
shl    $0x1,%rax
movslq -0x50(%rbp),%rcx
sub    %rcx,%rax
cvtsi2sd %rax,%xmm0
mulsd  -0x88(%rbp),%xmm0
ff
movsd  %xmm0,-0x70(%rbp)
movslq -0x50(%rbp),%rax
sub    -0x8(%rbp),%rax
mov    %eax,%edi
mov    $0x2,%esi
call   1030 <fmod@plt>
mov    %eax,-0x60(%rbp)
movslq -0x50(%rbp),%rax
cmp    -0x8(%rbp),%rax
jge    154a <pix2ang_nest+0x3fa>
mov    -0x50(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x54(%rbp),%eax
imul   -0x54(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  -0x80(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xae3(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
movl   $0x0,-0x60(%rbp)
jmp    1596 <pix2ang_nest+0x446>
movslq -0x50(%rbp),%rax
imul   $0x3,-0x8(%rbp),%rcx
cmp    %rcx,%rax
jle    1591 <pix2ang_nest+0x441>
mov    -0x64(%rbp),%eax
sub    -0x50(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x54(%rbp),%eax
imul   -0x54(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  -0x80(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xa9f(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
movl   $0x0,-0x60(%rbp)
jmp    1596 <pix2ang_nest+0x446>
movsd  -0x70(%rbp),%xmm0
call   1040 <acos@plt>
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movslq -0x2c(%rbp),%rax
mov    -0x100(%rbp,%rax,4),%eax
imul   -0x54(%rbp),%eax
add    -0x58(%rbp),%eax
add    $0x1,%eax
add    -0x60(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
cmp    -0x64(%rbp),%eax
jle    15e0 <pix2ang_nest+0x490>
mov    -0x5c(%rbp),%eax
sub    -0x64(%rbp),%eax
mov    %eax,-0x5c(%rbp)
cmpl   $0x1,-0x5c(%rbp)
jge    15f3 <pix2ang_nest+0x4a3>
mov    -0x5c(%rbp),%eax
add    -0x64(%rbp),%eax
mov    %eax,-0x5c(%rbp)
cvtsi2sdl -0x5c(%rbp),%xmm1
mov    -0x60(%rbp),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0x9df(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x90(%rbp),%xmm1
ff
cvtsi2sdl -0x54(%rbp),%xmm2
divsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pix2ang_nest>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    %rdi,%r13
mov    0x2e7d(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,0x28(%rsp)
movaps 0xe84(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xe88(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0xe8c(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
movaps 0xe8d(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xe91(%rip),%xmm1
movaps %xmm1,0x40(%rsp)
movaps %xmm0,0x50(%rsp)
lea    -0x2001(%rdi),%rax
cmp    $0xffffffffffffdfff,%rax
jbe    145f <pix2ang_nest+0x30f>
mov    %rsi,%rbx
test   %rsi,%rsi
js     143e <pix2ang_nest+0x2ee>
mov    %r13,%rbp
imul   %r13,%rbp
lea    0x0(%rbp,%rbp,2),%eax
lea    -0x1(,%rax,4),%eax
cmp    %rbx,%rax
jb     143e <pix2ang_nest+0x2ee>
mov    %rcx,%r14
mov    %rdx,%r15
cmpl   $0x0,0x3e6c(%rip)
jg     1215 <pix2ang_nest+0xc5>
lea    0x2e67(%rip),%rdi
lea    0x3e60(%rip),%rsi
call   1050 <mk_pix2xy@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %r13,%xmm0
movsd  0xe2b(%rip),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
mulsd  %xmm1,%xmm0
movsd  0xe1d(%rip),%xmm1
mov    %rbx,%rax
or     %rbp,%rax
shr    $0x20,%rax
mov    %r14,0x20(%rsp)
mov    %r15,0x18(%rsp)
je     125e <pix2ang_nest+0x10e>
mov    %rbx,%rax
xor    %edx,%edx
div    %rbp
mov    %rax,%r12
jmp    1267 <pix2ang_nest+0x117>
mov    %ebx,%eax
xor    %edx,%edx
div    %ebp
mov    %eax,%r12d
movapd %xmm1,%xmm2
divsd  %xmm0,%xmm2
movsd  %xmm2,(%rsp)
lea    0x0(,%r13,4),%r14d
mov    %ebx,%edi
mov    %ebp,%esi
call   1030 <fmod@plt>
mov    %rax,%rbp
mov    %ebp,%edi
mov    $0x400,%esi
call   1030 <fmod@plt>
mov    %rax,%r15
lea    0x3ff(%rbp),%edi
test   %ebp,%ebp
cmovns %ebp,%edi
lea    0xfffff(%rbp),%ebx
cmovns %ebp,%ebx
sar    $0xa,%edi
mov    $0x400,%esi
call   1030 <fmod@plt>
sar    $0x14,%ebx
movslq %ebx,%rcx
lea    0x2dab(%rip),%rdx
mov    (%rdx,%rcx,4),%esi
shl    $0xa,%esi
cltq
mov    (%rdx,%rax,4),%ebp
shl    $0x5,%ebp
add    %esi,%ebp
movslq %r15d,%rsi
add    (%rdx,%rsi,4),%ebp
lea    0x3d8e(%rip),%rdx
mov    (%rdx,%rcx,4),%ecx
shl    $0xa,%ecx
mov    (%rdx,%rax,4),%r15d
shl    $0x5,%r15d
add    %ecx,%r15d
add    (%rdx,%rsi,4),%r15d
lea    (%r15,%rbp,1),%eax
mov    %r12d,%ecx
not    %eax
mov    %rcx,0x10(%rsp)
mov    0x60(%rsp,%rcx,4),%ebx
imul   %r13d,%ebx
add    %eax,%ebx
movslq %ebx,%r12
mov    %r12d,%edi
sub    %r13d,%edi
mov    $0x2,%esi
call   1030 <fmod@plt>
mov    %r13,%rcx
cmp    %r13,%r12
jge    134d <pix2ang_nest+0x1fd>
mov    %ebx,%eax
imul   %ebx,%eax
cvtsi2sd %eax,%xmm0
mulsd  (%rsp),%xmm0
movsd  0xd18(%rip),%xmm1
subsd  %xmm0,%xmm1
xor    %r13d,%r13d
movapd %xmm1,%xmm0
jmp    13a2 <pix2ang_nest+0x252>
mov    %rax,%r13
movsd  (%rsp),%xmm1
lea    (%rcx,%rcx,2),%rax
cmp    %r12,%rax
jge    137d <pix2ang_nest+0x22d>
mov    %r14d,%eax
sub    %ebx,%eax
mov    %eax,%ebx
imul   %eax,%eax
cvtsi2sd %eax,%xmm0
mulsd  %xmm1,%xmm0
addsd  0xcf0(%rip),%xmm0
xor    %r13d,%r13d
jmp    13a2 <pix2ang_nest+0x252>
mov    %rcx,%rax
add    %rcx,%rax
sub    %r12,%rax
xorps  %xmm1,%xmm1
cvtsi2sd %rax,%xmm1
movsd  0xcca(%rip),%xmm0
divsd  0x8(%rsp),%xmm0
mulsd  %xmm1,%xmm0
mov    %ecx,%ebx
call   1040 <acos@plt>
mov    0x18(%rsp),%rax
movsd  %xmm0,(%rax)
mov    0x10(%rsp),%rax
mov    0x30(%rsp,%rax,4),%eax
imul   %ebx,%eax
mov    %r13d,%ecx
add    $0x1,%ecx
lea    0x1(%r13,%rbp,1),%edx
sub    %r15d,%edx
add    %eax,%edx
mov    %edx,%eax
shr    $0x1f,%eax
add    %edx,%eax
sar    %eax
xor    %edx,%edx
cmp    %r14d,%eax
mov    $0x0,%esi
cmovg  %r14d,%esi
sub    %esi,%eax
test   %eax,%eax
cmovg  %edx,%r14d
add    %eax,%r14d
movsd  0xc7a(%rip),%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %r14d,%xmm1
cvtsi2sd %ecx,%xmm2
movsd  0x28(%rsp),%xmm3
mulsd  %xmm0,%xmm3
mulsd  %xmm0,%xmm2
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
subsd  %xmm2,%xmm1
divsd  %xmm0,%xmm3
mulsd  %xmm1,%xmm3
mov    0x20(%rsp),%rax
movsd  %xmm3,(%rax)
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2b93(%rip),%rax
mov    (%rax),%edi
lea    0xce8(%rip),%rsi
lea    0xc45(%rip),%rdx
mov    $0x5c,%ecx
mov    %rbx,%r8
jmp    147e <pix2ang_nest+0x32e>
mov    0x2b72(%rip),%rax
mov    (%rax),%edi
lea    0xc09(%rip),%rsi
lea    0xc24(%rip),%rdx
mov    $0x57,%ecx
mov    %r13,%r8
call   1060 <fprintf@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@M_PI = global double 0.000000e+00
@pix2ang_nest.pix2x = internal global [1024 x i32] zeroinitializer
@pix2ang_nest.pix2y = internal global [1024 x i32] zeroinitializer
@stderr = global i32 0
@.str = [34 x i8] c"%s (%d): nside out of range: %ld\0A\00"
@.str.1 = [156 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/bkloppenborg/simtoi/refs/heads/master/lib/chealpix/pix2ang_nest.c\00"
@.str.2 = [33 x i8] c"%s (%d): ipix out of range: %ld\0A\00"
define void @pix2ang_nest(i64 %0, i64 %1, double* %2, double* %3) {
%5 = alloca i64
%6 = alloca i64
%7 = alloca double*
%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 i32
%25 = alloca i32
%26 = alloca double
%27 = alloca double
%28 = alloca double
%29 = alloca double
%30 = alloca double
%31 = alloca i32
%32 = alloca [12 x i32]
%33 = alloca [12 x i32]
store i64 %0, i64* %5
store i64 %1, i64* %6
store double* %2, double** %7
store double* %3, double** %8
%34 = load double, double* @M_PI
%35 = fmul double 5.000000e-01, %34
store double %35, double* %30
store i32 8192, i32* %31
%36 = getelementptr inbounds [12 x i32], [12 x i32]* %32, i64 0, i64 0
store i32 2, i32* %36
%37 = getelementptr inbounds [12 x i32], [12 x i32]* %32, i64 0, i64 1
store i32 2, i32* %37
%38 = getelementptr inbounds [12 x i32], [12 x i32]* %32, i64 0, i64 2
store i32 2, i32* %38
%39 = getelementptr inbounds [12 x i32], [12 x i32]* %32, i64 0, i64 3
store i32 2, i32* %39
%40 = getelementptr inbounds [12 x i32], [12 x i32]* %32, i64 0, i64 4
store i32 3, i32* %40
%41 = getelementptr inbounds [12 x i32], [12 x i32]* %32, i64 0, i64 5
store i32 3, i32* %41
%42 = getelementptr inbounds [12 x i32], [12 x i32]* %32, i64 0, i64 6
store i32 3, i32* %42
%43 = getelementptr inbounds [12 x i32], [12 x i32]* %32, i64 0, i64 7
store i32 3, i32* %43
%44 = getelementptr inbounds [12 x i32], [12 x i32]* %32, i64 0, i64 8
store i32 4, i32* %44
%45 = getelementptr inbounds [12 x i32], [12 x i32]* %32, i64 0, i64 9
store i32 4, i32* %45
%46 = getelementptr inbounds [12 x i32], [12 x i32]* %32, i64 0, i64 10
store i32 4, i32* %46
%47 = getelementptr inbounds [12 x i32], [12 x i32]* %32, i64 0, i64 11
store i32 4, i32* %47
%48 = getelementptr inbounds [12 x i32], [12 x i32]* %33, i64 0, i64 0
store i32 1, i32* %48
%49 = getelementptr inbounds [12 x i32], [12 x i32]* %33, i64 0, i64 1
store i32 3, i32* %49
%50 = getelementptr inbounds [12 x i32], [12 x i32]* %33, i64 0, i64 2
store i32 5, i32* %50
%51 = getelementptr inbounds [12 x i32], [12 x i32]* %33, i64 0, i64 3
store i32 7, i32* %51
%52 = getelementptr inbounds [12 x i32], [12 x i32]* %33, i64 0, i64 4
store i32 0, i32* %52
%53 = getelementptr inbounds [12 x i32], [12 x i32]* %33, i64 0, i64 5
store i32 2, i32* %53
%54 = getelementptr inbounds [12 x i32], [12 x i32]* %33, i64 0, i64 6
store i32 4, i32* %54
%55 = getelementptr inbounds [12 x i32], [12 x i32]* %33, i64 0, i64 7
store i32 6, i32* %55
%56 = getelementptr inbounds [12 x i32], [12 x i32]* %33, i64 0, i64 8
store i32 1, i32* %56
%57 = getelementptr inbounds [12 x i32], [12 x i32]* %33, i64 0, i64 9
store i32 3, i32* %57
%58 = getelementptr inbounds [12 x i32], [12 x i32]* %33, i64 0, i64 10
store i32 5, i32* %58
%59 = getelementptr inbounds [12 x i32], [12 x i32]* %33, i64 0, i64 11
store i32 7, i32* %59
%60 = load i64, i64* %5
%61 = icmp slt i64 %60, 1
br i1 %61, label %67, label %62
62: ; preds = %4
%63 = load i64, i64* %5
%64 = load i32, i32* %31
%65 = sext i32 %64 to i64
%66 = icmp sgt i64 %63, %65
br i1 %66, label %67, label %72
67: ; preds = %62, %4
%68 = load i32, i32* @stderr
%69 = load i64, i64* %5
%70 = call i32 @fprintf(i32 %68, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([156 x i8], [156 x i8]* @.str.1, i64 0, i64 0), i32 87, i64 %69)
%71 = call i32 @exit(i32 0)
unreachable
72: ; preds = %62
%73 = load i64, i64* %5
%74 = mul nsw i64 12, %73
%75 = load i64, i64* %5
%76 = mul nsw i64 %74, %75
%77 = trunc i64 %76 to i32
store i32 %77, i32* %9
%78 = load i64, i64* %6
%79 = icmp slt i64 %78, 0
br i1 %79, label %86, label %80
80: ; preds = %72
%81 = load i64, i64* %6
%82 = load i32, i32* %9
%83 = sub nsw i32 %82, 1
%84 = sext i32 %83 to i64
%85 = icmp sgt i64 %81, %84
br i1 %85, label %86, label %91
86: ; preds = %80, %72
%87 = load i32, i32* @stderr
%88 = load i64, i64* %6
%89 = call i32 @fprintf(i32 %87, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([156 x i8], [156 x i8]* @.str.1, i64 0, i64 0), i32 92, i64 %88)
%90 = call i32 @exit(i32 0)
unreachable
91: ; preds = %80
%92 = load i32, i32* getelementptr inbounds ([1024 x i32], [1024 x i32]* @pix2ang_nest.pix2x, i64 0, i64 1023)
%93 = icmp sle i32 %92, 0
br i1 %93, label %94, label %96
94: ; preds = %91
%95 = call i32 @mk_pix2xy(i32* getelementptr inbounds ([1024 x i32], [1024 x i32]* @pix2ang_nest.pix2x, i64 0, i64 0), i32* getelementptr inbounds ([1024 x i32], [1024 x i32]* @pix2ang_nest.pix2y, i64 0, i64 0))
br label %96
96: ; preds = %94, %91
%97 = load i64, i64* %5
%98 = sitofp i64 %97 to double
%99 = fmul double 1.000000e+00, %98
store double %99, double* %27
%100 = load double, double* %27
%101 = fmul double 3.000000e+00, %100
%102 = load double, double* %27
%103 = fmul double %101, %102
%104 = fdiv double 1.000000e+00, %103
store double %104, double* %28
%105 = load double, double* %27
%106 = fmul double 3.000000e+00, %105
%107 = fdiv double 2.000000e+00, %106
store double %107, double* %29
%108 = load i64, i64* %5
%109 = mul nsw i64 4, %108
%110 = trunc i64 %109 to i32
store i32 %110, i32* %25
%111 = load i64, i64* %5
%112 = load i64, i64* %5
%113 = mul nsw i64 %111, %112
%114 = trunc i64 %113 to i32
store i32 %114, i32* %10
%115 = load i64, i64* %6
%116 = load i32, i32* %10
%117 = sext i32 %116 to i64
%118 = sdiv i64 %115, %117
%119 = trunc i64 %118 to i32
store i32 %119, i32* %11
%120 = load i64, i64* %6
%121 = trunc i64 %120 to i32
%122 = load i32, i32* %10
%123 = call i64 @fmod(i32 %121, i32 %122)
%124 = trunc i64 %123 to i32
store i32 %124, i32* %12
%125 = load i32, i32* %12
%126 = call i64 @fmod(i32 %125, i32 1024)
%127 = trunc i64 %126 to i32
store i32 %127, i32* %13
%128 = load i32, i32* %12
%129 = sdiv i32 %128, 1024
store i32 %129, i32* %14
%130 = load i32, i32* %14
%131 = call i64 @fmod(i32 %130, i32 1024)
%132 = trunc i64 %131 to i32
store i32 %132, i32* %15
%133 = load i32, i32* %14
%134 = sdiv i32 %133, 1024
store i32 %134, i32* %16
%135 = load i32, i32* %16
%136 = sext i32 %135 to i64
%137 = getelementptr inbounds [1024 x i32], [1024 x i32]* @pix2ang_nest.pix2x, i64 0, i64 %136
%138 = load i32, i32* %137
%139 = mul nsw i32 1024, %138
%140 = load i32, i32* %15
%141 = sext i32 %140 to i64
%142 = getelementptr inbounds [1024 x i32], [1024 x i32]* @pix2ang_nest.pix2x, i64 0, i64 %141
%143 = load i32, i32* %142
%144 = mul nsw i32 32, %143
%145 = add nsw i32 %139, %144
%146 = load i32, i32* %13
%147 = sext i32 %146 to i64
%148 = getelementptr inbounds [1024 x i32], [1024 x i32]* @pix2ang_nest.pix2x, i64 0, i64 %147
%149 = load i32, i32* %148
%150 = add nsw i32 %145, %149
store i32 %150, i32* %17
%151 = load i32, i32* %16
%152 = sext i32 %151 to i64
%153 = getelementptr inbounds [1024 x i32], [1024 x i32]* @pix2ang_nest.pix2y, i64 0, i64 %152
%154 = load i32, i32* %153
%155 = mul nsw i32 1024, %154
%156 = load i32, i32* %15
%157 = sext i32 %156 to i64
%158 = getelementptr inbounds [1024 x i32], [1024 x i32]* @pix2ang_nest.pix2y, i64 0, i64 %157
%159 = load i32, i32* %158
%160 = mul nsw i32 32, %159
%161 = add nsw i32 %155, %160
%162 = load i32, i32* %13
%163 = sext i32 %162 to i64
%164 = getelementptr inbounds [1024 x i32], [1024 x i32]* @pix2ang_nest.pix2y, i64 0, i64 %163
%165 = load i32, i32* %164
%166 = add nsw i32 %161, %165
store i32 %166, i32* %18
%167 = load i32, i32* %17
%168 = load i32, i32* %18
%169 = add nsw i32 %167, %168
store i32 %169, i32* %19
%170 = load i32, i32* %17
%171 = load i32, i32* %18
%172 = sub nsw i32 %170, %171
store i32 %172, i32* %22
%173 = load i32, i32* %11
%174 = sext i32 %173 to i64
%175 = getelementptr inbounds [12 x i32], [12 x i32]* %32, i64 0, i64 %174
%176 = load i32, i32* %175
%177 = sext i32 %176 to i64
%178 = load i64, i64* %5
%179 = mul nsw i64 %177, %178
%180 = load i32, i32* %19
%181 = sext i32 %180 to i64
%182 = sub nsw i64 %179, %181
%183 = sub nsw i64 %182, 1
%184 = trunc i64 %183 to i32
store i32 %184, i32* %20
%185 = load i64, i64* %5
%186 = trunc i64 %185 to i32
store i32 %186, i32* %21
%187 = load i64, i64* %5
%188 = mul nsw i64 2, %187
%189 = load i32, i32* %20
%190 = sext i32 %189 to i64
%191 = sub nsw i64 %188, %190
%192 = sitofp i64 %191 to double
%193 = load double, double* %29
%194 = fmul double %192, %193
store double %194, double* %26
%195 = load i32, i32* %20
%196 = sext i32 %195 to i64
%197 = load i64, i64* %5
%198 = sub nsw i64 %196, %197
%199 = trunc i64 %198 to i32
%200 = call i64 @fmod(i32 %199, i32 2)
%201 = trunc i64 %200 to i32
store i32 %201, i32* %24
%202 = load i32, i32* %20
%203 = sext i32 %202 to i64
%204 = load i64, i64* %5
%205 = icmp slt i64 %203, %204
br i1 %205, label %206, label %215
206: ; preds = %96
%207 = load i32, i32* %20
store i32 %207, i32* %21
%208 = load i32, i32* %21
%209 = load i32, i32* %21
%210 = mul nsw i32 %208, %209
%211 = sitofp i32 %210 to double
%212 = load double, double* %28
%213 = fneg double %211
%214 = call double @llvm.fmuladd.f64(double %213, double %212, double 1.000000e+00)
store double %214, double* %26
store i32 0, i32* %24
br label %232
215: ; preds = %96
%216 = load i32, i32* %20
%217 = sext i32 %216 to i64
%218 = load i64, i64* %5
%219 = mul nsw i64 3, %218
%220 = icmp sgt i64 %217, %219
br i1 %220, label %221, label %231
221: ; preds = %215
%222 = load i32, i32* %25
%223 = load i32, i32* %20
%224 = sub nsw i32 %222, %223
store i32 %224, i32* %21
%225 = load i32, i32* %21
%226 = load i32, i32* %21
%227 = mul nsw i32 %225, %226
%228 = sitofp i32 %227 to double
%229 = load double, double* %28
%230 = call double @llvm.fmuladd.f64(double %228, double %229, double -1.000000e+00)
store double %230, double* %26
store i32 0, i32* %24
br label %231
231: ; preds = %221, %215
br label %232
232: ; preds = %231, %206
%233 = load double, double* %26
%234 = call double @acos(double %233)
%235 = load double*, double** %7
store double %234, double* %235
%236 = load i32, i32* %11
%237 = sext i32 %236 to i64
%238 = getelementptr inbounds [12 x i32], [12 x i32]* %33, i64 0, i64 %237
%239 = load i32, i32* %238
%240 = load i32, i32* %21
%241 = mul nsw i32 %239, %240
%242 = load i32, i32* %22
%243 = add nsw i32 %241, %242
%244 = add nsw i32 %243, 1
%245 = load i32, i32* %24
%246 = add nsw i32 %244, %245
%247 = sdiv i32 %246, 2
store i32 %247, i32* %23
%248 = load i32, i32* %23
%249 = load i32, i32* %25
%250 = icmp sgt i32 %248, %249
br i1 %250, label %251, label %255
251: ; preds = %232
%252 = load i32, i32* %23
%253 = load i32, i32* %25
%254 = sub nsw i32 %252, %253
store i32 %254, i32* %23
br label %255
255: ; preds = %251, %232
%256 = load i32, i32* %23
%257 = icmp slt i32 %256, 1
br i1 %257, label %258, label %262
258: ; preds = %255
%259 = load i32, i32* %23
%260 = load i32, i32* %25
%261 = add nsw i32 %259, %260
store i32 %261, i32* %23
br label %262
262: ; preds = %258, %255
%263 = load i32, i32* %23
%264 = sitofp i32 %263 to double
%265 = load i32, i32* %24
%266 = add nsw i32 %265, 1
%267 = sitofp i32 %266 to double
%268 = fneg double %267
%269 = call double @llvm.fmuladd.f64(double %268, double 5.000000e-01, double %264)
%270 = load double, double* %30
%271 = load i32, i32* %21
%272 = sitofp i32 %271 to double
%273 = fdiv double %270, %272
%274 = fmul double %269, %273
%275 = load double*, double** %8
store double %274, double* %275
ret void
}

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
@pix2ang_nest.pix2x = internal global [1024 x i32] zeroinitializer
@pix2ang_nest.pix2y = internal global [1024 x i32] zeroinitializer
@stderr = global i32 0
@.str = [34 x i8] c"%s (%d): nside out of range: %ld\0A\00"
@.str.1 = [156 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/bkloppenborg/simtoi/refs/heads/master/lib/chealpix/pix2ang_nest.c\00"
@.str.2 = [33 x i8] c"%s (%d): ipix out of range: %ld\0A\00"
define void @pix2ang_nest(i64 %0, i64 %1, double* nocapture writeonly %2, double* nocapture writeonly %3) {
%5 = alloca [12 x i32]
%6 = alloca [12 x i32]
%7 = load double, double* @M_PI
%8 = bitcast [12 x i32]* %5 to i8*
%9 = bitcast [12 x i32]* %6 to i8*
%10 = bitcast [12 x i32]* %5 to <4 x i32>*
store <4 x i32> <i32 2, i32 2, i32 2, i32 2>, <4 x i32>* %10
%11 = getelementptr inbounds [12 x i32], [12 x i32]* %5, i64 0, i64 4
%12 = bitcast i32* %11 to <4 x i32>*
store <4 x i32> <i32 3, i32 3, i32 3, i32 3>, <4 x i32>* %12
%13 = getelementptr inbounds [12 x i32], [12 x i32]* %5, i64 0, i64 8
%14 = bitcast i32* %13 to <4 x i32>*
store <4 x i32> <i32 4, i32 4, i32 4, i32 4>, <4 x i32>* %14
%15 = bitcast [12 x i32]* %6 to <4 x i32>*
store <4 x i32> <i32 1, i32 3, i32 5, i32 7>, <4 x i32>* %15
%16 = getelementptr inbounds [12 x i32], [12 x i32]* %6, i64 0, i64 4
%17 = bitcast i32* %16 to <4 x i32>*
store <4 x i32> <i32 0, i32 2, i32 4, i32 6>, <4 x i32>* %17
%18 = getelementptr inbounds [12 x i32], [12 x i32]* %6, i64 0, i64 8
%19 = bitcast i32* %18 to <4 x i32>*
store <4 x i32> <i32 1, i32 3, i32 5, i32 7>, <4 x i32>* %19
%20 = add i64 %0, -8193
%21 = icmp ult i64 %20, -8192
br i1 %21, label %22, label %26
22: ; preds = %4
%23 = load i32, i32* @stderr
%24 = tail call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([156 x i8], [156 x i8]* @.str.1, i64 0, i64 0), i32 87, i64 %0)
%25 = tail call i32 @exit(i32 0)
unreachable
26: ; preds = %4
%27 = icmp slt i64 %1, 0
br i1 %27, label %34, label %28
28: ; preds = %26
%29 = mul nuw nsw i64 %0, %0
%30 = mul nuw nsw i64 %29, 12
%31 = add nuw nsw i64 %30, 4294967295
%32 = and i64 %31, 4294967295
%33 = icmp ult i64 %32, %1
br i1 %33, label %34, label %38
34: ; preds = %28, %26
%35 = load i32, i32* @stderr
%36 = tail call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([156 x i8], [156 x i8]* @.str.1, i64 0, i64 0), i32 92, i64 %1)
%37 = tail call i32 @exit(i32 0)
unreachable
38: ; preds = %28
%39 = load i32, i32* getelementptr inbounds ([1024 x i32], [1024 x i32]* @pix2ang_nest.pix2x, i64 0, i64 1023)
%40 = icmp slt i32 %39, 1
br i1 %40, label %41, label %43
41: ; preds = %38
%42 = tail call i32 @mk_pix2xy(i32* getelementptr inbounds ([1024 x i32], [1024 x i32]* @pix2ang_nest.pix2x, i64 0, i64 0), i32* getelementptr inbounds ([1024 x i32], [1024 x i32]* @pix2ang_nest.pix2y, i64 0, i64 0))
br label %43
43: ; preds = %41, %38
%44 = sitofp i64 %0 to double
%45 = fmul double %44, 3.000000e+00
%46 = fmul double %45, %44
%47 = fdiv double 1.000000e+00, %46
%48 = trunc i64 %0 to i32
%49 = shl nuw nsw i32 %48, 2
%50 = trunc i64 %29 to i32
%51 = udiv i64 %1, %29
%52 = trunc i64 %1 to i32
%53 = tail call i64 @fmod(i32 %52, i32 %50)
%54 = trunc i64 %53 to i32
%55 = tail call i64 @fmod(i32 %54, i32 1024)
%56 = sdiv i32 %54, 1024
%57 = tail call i64 @fmod(i32 %56, i32 1024)
%58 = sdiv i32 %54, 1048576
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [1024 x i32], [1024 x i32]* @pix2ang_nest.pix2x, i64 0, i64 %59
%61 = load i32, i32* %60
%62 = shl nsw i32 %61, 10
%63 = shl i64 %57, 32
%64 = ashr exact i64 %63, 32
%65 = getelementptr inbounds [1024 x i32], [1024 x i32]* @pix2ang_nest.pix2x, i64 0, i64 %64
%66 = load i32, i32* %65
%67 = shl nsw i32 %66, 5
%68 = add nsw i32 %67, %62
%69 = shl i64 %55, 32
%70 = ashr exact i64 %69, 32
%71 = getelementptr inbounds [1024 x i32], [1024 x i32]* @pix2ang_nest.pix2x, i64 0, i64 %70
%72 = load i32, i32* %71
%73 = add nsw i32 %68, %72
%74 = getelementptr inbounds [1024 x i32], [1024 x i32]* @pix2ang_nest.pix2y, i64 0, i64 %59
%75 = load i32, i32* %74
%76 = shl nsw i32 %75, 10
%77 = getelementptr inbounds [1024 x i32], [1024 x i32]* @pix2ang_nest.pix2y, i64 0, i64 %64
%78 = load i32, i32* %77
%79 = shl nsw i32 %78, 5
%80 = add nsw i32 %79, %76
%81 = getelementptr inbounds [1024 x i32], [1024 x i32]* @pix2ang_nest.pix2y, i64 0, i64 %70
%82 = load i32, i32* %81
%83 = add nsw i32 %80, %82
%84 = add nsw i32 %83, %73
%85 = and i64 %51, 4294967295
%86 = getelementptr inbounds [12 x i32], [12 x i32]* %5, i64 0, i64 %85
%87 = load i32, i32* %86
%88 = xor i32 %84, -1
%89 = mul i32 %87, %48
%90 = add i32 %89, %88
%91 = sext i32 %90 to i64
%92 = sub i32 %90, %48
%93 = tail call i64 @fmod(i32 %92, i32 2)
%94 = icmp slt i64 %91, %0
br i1 %94, label %95, label %100
95: ; preds = %43
%96 = mul nsw i32 %90, %90
%97 = sitofp i32 %96 to double
%98 = fneg double %97
%99 = tail call double @llvm.fmuladd.f64(double %98, double %47, double 1.000000e+00)
br label %114
100: ; preds = %43
%101 = trunc i64 %93 to i32
%102 = shl nuw nsw i64 %0, 1
%103 = sub nsw i64 %102, %91
%104 = sitofp i64 %103 to double
%105 = fdiv double 2.000000e+00, %45
%106 = fmul double %105, %104
%107 = mul nuw nsw i64 %0, 3
%108 = icmp slt i64 %107, %91
br i1 %108, label %109, label %114
109: ; preds = %100
%110 = sub nsw i32 %49, %90
%111 = mul nsw i32 %110, %110
%112 = sitofp i32 %111 to double
%113 = tail call double @llvm.fmuladd.f64(double %112, double %47, double -1.000000e+00)
br label %114
114: ; preds = %100, %109, %95
%115 = phi double [ %99, %95 ], [ %113, %109 ], [ %106, %100 ]
%116 = phi i32 [ 0, %95 ], [ 0, %109 ], [ %101, %100 ]
%117 = phi i32 [ %90, %95 ], [ %110, %109 ], [ %48, %100 ]
%118 = tail call double @acos(double %115)
store double %118, double* %2
%119 = getelementptr inbounds [12 x i32], [12 x i32]* %6, i64 0, i64 %85
%120 = load i32, i32* %119
%121 = mul nsw i32 %120, %117
%122 = add i32 %116, 1
%123 = add i32 %122, %73
%124 = sub i32 %123, %83
%125 = add i32 %124, %121
%126 = sdiv i32 %125, 2
%127 = icmp sgt i32 %126, %49
%128 = select i1 %127, i32 %49, i32 0
%129 = sub nsw i32 %126, %128
%130 = icmp sgt i32 %129, 0
%131 = select i1 %130, i32 0, i32 %49
%132 = add nsw i32 %131, %129
%133 = fmul double %7, 5.000000e-01
%134 = sitofp i32 %132 to double
%135 = sitofp i32 %122 to double
%136 = fneg double %135
%137 = tail call double @llvm.fmuladd.f64(double %136, double 5.000000e-01, double %134)
%138 = sitofp i32 %117 to double
%139 = fdiv double %133, %138
%140 = fmul double %139, %137
store double %140, double* %3
ret void
}