#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 cos(double);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
double fabs(double);
scalar_t__ floor(int);
scalar_t__ fmod(int, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int, long const);
int /*<<< orphan*/ mk_xy2pix(int *, int *);
int pow(long const, int);
double sqrt(int);
int /*<<< orphan*/ stderr;
void ang2pix_nest(const long nside, double theta, double phi, long *ipix) {
  double z, za, z0, tt, tp, tmp;
  int face_num, jp, jm;
  long ifp, ifm;
  int ix, iy, ix_low, ix_hi, iy_low, iy_hi, ipf, ntt;
  double piover2 = 0.5 * M_PI, pi = M_PI, twopi = 2.0 * M_PI;
  int ns_max = 8192;
  static int x2pix[128], y2pix[128];
  static char setup_done = 0;
  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/ang2pix_nest.c",
            62, nside);
    exit(0);
  }
  if (theta < 0. || theta > pi) {
    fprintf(stderr, "%s (%d): theta out of range: %f\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/ang2pix_nest.c",
            66, theta);
    exit(0);
  }
  if (!setup_done) {
    mk_xy2pix(x2pix, y2pix);
    setup_done = 1;
  }
  z = cos(theta);
  za = fabs(z);
  z0 = 2. / 3.;
  if (phi >= twopi)
    phi = phi - twopi;
  if (phi < 0.)
    phi = phi + twopi;
  tt = phi / piover2;
  if (za <= z0) {
    jp = (int)floor(ns_max * (0.5 + tt - z * 0.75));
    jm = (int)floor(ns_max * (0.5 + tt + z * 0.75));
    ifp = jp / ns_max;
    ifm = jm / ns_max;
    if (ifp == ifm)
      face_num = (int)fmod(ifp, 4) + 4;
    else if (ifp < ifm)
      face_num = (int)fmod(ifp, 4);
    else
      face_num = (int)fmod(ifm, 4) + 8;
    ix = (int)fmod(jm, ns_max);
    iy = ns_max - (int)fmod(jp, ns_max) - 1;
  } else {
    ntt = (int)floor(tt);
    if (ntt >= 4)
      ntt = 3;
    tp = tt - ntt;
    tmp = sqrt(3. * (1. - za));
    jp = (int)floor(ns_max * tp * tmp);
    jm = (int)floor(ns_max * (1. - tp) * tmp);
    jp = (int)(jp < ns_max - 1 ? jp : ns_max - 1);
    jm = (int)(jm < ns_max - 1 ? jm : ns_max - 1);
    if (z >= 0) {
      face_num = ntt;
      ix = ns_max - jm - 1;
      iy = ns_max - jp - 1;
    } else {
      face_num = ntt + 8;
      ix = jp;
      iy = jm;
    }
  }
  ix_low = (int)fmod(ix, 128);
  ix_hi = ix / 128;
  iy_low = (int)fmod(iy, 128);
  iy_hi = iy / 128;
  ipf = (x2pix[ix_hi] + y2pix[iy_hi]) * (128 * 128) +
        (x2pix[ix_low] + y2pix[iy_low]);
  ipf = (long)(ipf / pow(ns_max / nside, 2));
  *ipix = (long)(ipf + face_num * pow(nside, 2));
}


x86 assembly (clang, -O0):
<ang2pix_nest>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
movsd  0xe63(%rip),%xmm0
mov    0x2e3c(%rip),%rax
mulsd  (%rax),%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
mov    0x2e29(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  0xe2d(%rip),%xmm0
mov    0x2e0e(%rip),%rax
mulsd  (%rax),%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
movl   $0x2000,-0xac(%rbp)
cmpq   $0x1,-0x8(%rbp)
jl     120f <ang2pix_nest+0x8f>
mov    -0x8(%rbp),%rax
movslq -0xac(%rbp),%rcx
cmp    %rcx,%rax
jle    123b <ang2pix_nest+0xbb>
mov    0x2dc2(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%r8
lea    0xe1d(%rip),%rsi
lea    0xe38(%rip),%rdx
mov    $0x3e,%ecx
call   1050 <fprintf@plt>
xor    %edi,%edi
call   1090 <exit@plt>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
ja     125c <ang2pix_nest+0xdc>
movsd  -0x10(%rbp),%xmm0
ucomisd -0xa0(%rbp),%xmm0
ff
jbe    128a <ang2pix_nest+0x10a>
mov    0x2d75(%rip),%rax
mov    (%rax),%edi
cvttsd2si -0x10(%rbp),%r8
lea    0xe8c(%rip),%rsi
lea    0xde9(%rip),%rdx
mov    $0x42,%ecx
call   1050 <fprintf@plt>
xor    %edi,%edi
call   1090 <exit@plt>
cmpb   $0x0,0x31ef(%rip)
jne    12b1 <ang2pix_nest+0x131>
lea    0x2de2(%rip),%rdi
lea    0x2fdb(%rip),%rsi
call   1040 <mk_xy2pix@plt>
movb   $0x1,0x31cf(%rip)
movsd  -0x10(%rbp),%xmm0
call   1060 <cos@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movaps 0xd64(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xd33(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
ucomisd -0xa8(%rbp),%xmm0
ff
jb     1307 <ang2pix_nest+0x187>
movsd  -0x18(%rbp),%xmm0
subsd  -0xa8(%rbp),%xmm0
ff
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    1327 <ang2pix_nest+0x1a7>
movsd  -0x18(%rbp),%xmm0
addsd  -0xa8(%rbp),%xmm0
ff
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
divsd  -0x98(%rbp),%xmm0
ff
movsd  %xmm0,-0x40(%rbp)
movsd  -0x30(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     14a3 <ang2pix_nest+0x323>
cvtsi2sdl -0xac(%rbp),%xmm0
ff
movsd  0xcab(%rip),%xmm2
addsd  -0x40(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  0xca2(%rip),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   10a0 <floor@plt>
mov    %eax,-0x58(%rbp)
cvtsi2sdl -0xac(%rbp),%xmm0
ff
movsd  0xc5a(%rip),%xmm2
addsd  -0x40(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm1
movsd  0xc68(%rip),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   10a0 <floor@plt>
mov    %eax,-0x5c(%rbp)
mov    -0x58(%rbp),%eax
cltd
idivl  -0xac(%rbp)
cltq
mov    %rax,-0x68(%rbp)
mov    -0x5c(%rbp),%eax
cltd
idivl  -0xac(%rbp)
cltq
mov    %rax,-0x70(%rbp)
mov    -0x68(%rbp),%rax
cmp    -0x70(%rbp),%rax
jne    1421 <ang2pix_nest+0x2a1>
mov    -0x68(%rbp),%rax
mov    %eax,%edi
mov    $0x4,%esi
call   1030 <fmod@plt>
add    $0x4,%eax
mov    %eax,-0x54(%rbp)
jmp    1462 <ang2pix_nest+0x2e2>
mov    -0x68(%rbp),%rax
cmp    -0x70(%rbp),%rax
jge    1447 <ang2pix_nest+0x2c7>
mov    -0x68(%rbp),%rax
mov    %eax,%edi
mov    $0x4,%esi
call   1030 <fmod@plt>
mov    %eax,-0x54(%rbp)
jmp    145d <ang2pix_nest+0x2dd>
mov    -0x70(%rbp),%rax
mov    %eax,%edi
mov    $0x4,%esi
call   1030 <fmod@plt>
add    $0x8,%eax
mov    %eax,-0x54(%rbp)
jmp    1462 <ang2pix_nest+0x2e2>
mov    -0x5c(%rbp),%edi
mov    -0xac(%rbp),%esi
call   1030 <fmod@plt>
mov    %eax,-0x74(%rbp)
mov    -0xac(%rbp),%eax
mov    %eax,-0xb0(%rbp)
mov    -0x58(%rbp),%edi
mov    -0xac(%rbp),%esi
call   1030 <fmod@plt>
mov    %rax,%rcx
mov    -0xb0(%rbp),%eax
sub    %ecx,%eax
sub    $0x1,%eax
mov    %eax,-0x78(%rbp)
jmp    161e <ang2pix_nest+0x49e>
cvttsd2si -0x40(%rbp),%edi
call   10a0 <floor@plt>
mov    %eax,-0x90(%rbp)
cmpl   $0x4,-0x90(%rbp)
jl     14ca <ang2pix_nest+0x34a>
movl   $0x3,-0x90(%rbp)
movsd  -0x40(%rbp),%xmm0
cvtsi2sdl -0x90(%rbp),%xmm1
ff
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xb30(%rip),%xmm1
subsd  -0x30(%rbp),%xmm1
movsd  0xb2b(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1080 <sqrt@plt>
movsd  %xmm0,-0x50(%rbp)
cvtsi2sdl -0xac(%rbp),%xmm0
ff
mulsd  -0x48(%rbp),%xmm0
mulsd  -0x50(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   10a0 <floor@plt>
mov    %eax,-0x58(%rbp)
cvtsi2sdl -0xac(%rbp),%xmm0
ff
movsd  0xae3(%rip),%xmm1
subsd  -0x48(%rbp),%xmm1
mulsd  %xmm1,%xmm0
mulsd  -0x50(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   10a0 <floor@plt>
mov    %eax,-0x5c(%rbp)
mov    -0x58(%rbp),%eax
mov    -0xac(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1571 <ang2pix_nest+0x3f1>
mov    -0x58(%rbp),%eax
mov    %eax,-0xb4(%rbp)
jmp    1580 <ang2pix_nest+0x400>
mov    -0xac(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0xb4(%rbp)
mov    -0xb4(%rbp),%eax
mov    %eax,-0x58(%rbp)
mov    -0x5c(%rbp),%eax
mov    -0xac(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    15ab <ang2pix_nest+0x42b>
mov    -0x5c(%rbp),%eax
mov    %eax,-0xb8(%rbp)
jmp    15ba <ang2pix_nest+0x43a>
mov    -0xac(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0xb8(%rbp)
mov    -0xb8(%rbp),%eax
mov    %eax,-0x5c(%rbp)
movsd  -0x28(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1601 <ang2pix_nest+0x481>
mov    -0x90(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0xac(%rbp),%eax
sub    -0x5c(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x74(%rbp)
mov    -0xac(%rbp),%eax
sub    -0x58(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x78(%rbp)
jmp    1619 <ang2pix_nest+0x499>
mov    -0x90(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x54(%rbp)
mov    -0x58(%rbp),%eax
mov    %eax,-0x74(%rbp)
mov    -0x5c(%rbp),%eax
mov    %eax,-0x78(%rbp)
jmp    161e <ang2pix_nest+0x49e>
mov    -0x74(%rbp),%edi
mov    $0x80,%esi
call   1030 <fmod@plt>
mov    %eax,-0x7c(%rbp)
mov    -0x74(%rbp),%eax
mov    $0x80,%ecx
cltd
idiv   %ecx
mov    %eax,-0x80(%rbp)
mov    -0x78(%rbp),%edi
mov    $0x80,%esi
call   1030 <fmod@plt>
mov    %eax,-0x84(%rbp)
mov    -0x78(%rbp),%eax
mov    $0x80,%ecx
cltd
idiv   %ecx
mov    %eax,-0x88(%rbp)
movslq -0x80(%rbp),%rcx
lea    0x2a15(%rip),%rax
mov    (%rax,%rcx,4),%eax
movslq -0x88(%rbp),%rdx
lea    0x2c04(%rip),%rcx
add    (%rcx,%rdx,4),%eax
shl    $0xe,%eax
movslq -0x7c(%rbp),%rdx
lea    0x29f3(%rip),%rcx
mov    (%rcx,%rdx,4),%ecx
movslq -0x84(%rbp),%rsi
lea    0x2be2(%rip),%rdx
add    (%rdx,%rsi,4),%ecx
add    %ecx,%eax
mov    %eax,-0x8c(%rbp)
mov    -0x8c(%rbp),%eax
mov    %eax,-0xc4(%rbp)
movslq -0xac(%rbp),%rax
cqto
idivq  -0x8(%rbp)
mov    %rax,%rdi
mov    $0x2,%esi
call   1070 <pow@plt>
mov    %eax,%ecx
mov    -0xc4(%rbp),%eax
cltd
idiv   %ecx
cltq
mov    %eax,-0x8c(%rbp)
mov    -0x8c(%rbp),%eax
mov    %eax,-0xbc(%rbp)
mov    -0x54(%rbp),%eax
mov    %eax,-0xc0(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x2,%esi
call   1070 <pow@plt>
mov    -0xc0(%rbp),%ecx
mov    %eax,%edx
mov    -0xbc(%rbp),%eax
imul   %edx,%ecx
add    %ecx,%eax
movslq %eax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ang2pix_nest>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rdi,%r15
lea    -0x2001(%rdi),%rax
cmp    $0xffffffffffffdfff,%rax
jbe    14ee <ang2pix_nest+0x36e>
xorpd  %xmm2,%xmm2
ucomisd %xmm0,%xmm2
ja     150f <ang2pix_nest+0x38f>
mov    0x2e2f(%rip),%rax
movsd  (%rax),%xmm2
ucomisd %xmm2,%xmm0
ja     150f <ang2pix_nest+0x38f>
mov    %rsi,%rbx
movsd  %xmm1,(%rsp)
movsd  0xe29(%rip),%xmm1
mulsd  %xmm2,%xmm1
movsd  %xmm1,0x20(%rsp)
addsd  %xmm2,%xmm2
movapd %xmm2,0x30(%rsp)
cmpb   $0x0,0x328e(%rip)
jne    121a <ang2pix_nest+0x9a>
lea    0x2e85(%rip),%rdi
lea    0x307e(%rip),%rsi
movsd  %xmm0,0x18(%rsp)
call   1040 <mk_xy2pix@plt>
movsd  0x18(%rsp),%xmm0
movb   $0x1,0x3266(%rip)
mov    %rbx,0x18(%rsp)
call   1060 <cos@plt>
movapd 0xe14(%rip),%xmm5
andpd  %xmm0,%xmm5
movapd 0x30(%rsp),%xmm4
movapd %xmm4,%xmm1
movsd  (%rsp),%xmm3
cmpnlesd %xmm3,%xmm1
andnpd %xmm4,%xmm1
subsd  %xmm1,%xmm3
xorpd  %xmm1,%xmm1
movapd %xmm3,%xmm2
cmpltsd %xmm1,%xmm2
andpd  %xmm2,%xmm4
movsd  0xda3(%rip),%xmm1
andnpd %xmm1,%xmm2
orpd   %xmm4,%xmm2
addsd  %xmm3,%xmm2
divsd  0x20(%rsp),%xmm2
movsd  0xd91(%rip),%xmm1
ucomisd %xmm5,%xmm1
jae    1363 <ang2pix_nest+0x1e3>
cvttsd2si %xmm2,%edi
movapd %xmm0,0x30(%rsp)
movapd %xmm2,(%rsp)
movapd %xmm5,0x20(%rsp)
call   10a0 <floor@plt>
cmp    $0x3,%eax
mov    $0x3,%r12d
cmovl  %eax,%r12d
xorps  %xmm0,%xmm0
cvtsi2sd %r12d,%xmm0
movapd (%rsp),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,(%rsp)
movsd  0xd5a(%rip),%xmm0
subsd  0x20(%rsp),%xmm0
mulsd  0xd54(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1080 <sqrt@plt>
movsd  %xmm0,0x20(%rsp)
movapd (%rsp),%xmm1
mulsd  0xd28(%rip),%xmm1
mulsd  %xmm0,%xmm1
cvttsd2si %xmm1,%edi
call   10a0 <floor@plt>
mov    %rax,%rbp
movsd  0xd18(%rip),%xmm0
subsd  (%rsp),%xmm0
mulsd  0xd03(%rip),%xmm0
mulsd  0x20(%rsp),%xmm0
cvttsd2si %xmm0,%edi
call   10a0 <floor@plt>
mov    %rax,%rbx
cmp    $0x1fff,%ebp
mov    $0x1fff,%eax
cmovge %eax,%ebp
cmp    $0x1fff,%ebx
cmovge %eax,%ebx
movapd 0x30(%rsp),%xmm0
ucomisd 0xce4(%rip),%xmm0
jae    13ee <ang2pix_nest+0x26e>
add    $0x8,%r12d
jmp    1444 <ang2pix_nest+0x2c4>
addsd  0xc95(%rip),%xmm2
movapd %xmm2,(%rsp)
mulsd  0xca0(%rip),%xmm0
movapd %xmm0,0x30(%rsp)
movapd %xmm2,%xmm1
subsd  %xmm0,%xmm1
mulsd  0xc92(%rip),%xmm1
cvttsd2si %xmm1,%edi
call   10a0 <floor@plt>
mov    %rax,%r13
movapd 0x30(%rsp),%xmm0
addsd  (%rsp),%xmm0
mulsd  0xc73(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   10a0 <floor@plt>
lea    0x1fff(%r13),%edi
test   %r13d,%r13d
cmovns %r13d,%edi
mov    %rax,%rbx
sar    $0xd,%edi
add    $0x1fff,%eax
test   %ebx,%ebx
cmovns %ebx,%eax
sar    $0xd,%eax
cmp    %eax,%edi
jne    13fd <ang2pix_nest+0x27d>
mov    $0x4,%esi
call   1030 <fmod@plt>
mov    %rax,%r12
add    $0x4,%r12d
jmp    1421 <ang2pix_nest+0x2a1>
sub    %ebp,%eax
mov    $0x1fff,%ecx
sub    %ebx,%ecx
mov    %eax,%ebx
mov    %ecx,%ebp
jmp    1444 <ang2pix_nest+0x2c4>
jge    140e <ang2pix_nest+0x28e>
mov    $0x4,%esi
call   1030 <fmod@plt>
mov    %rax,%r12
jmp    1421 <ang2pix_nest+0x2a1>
mov    %eax,%edi
mov    $0x4,%esi
call   1030 <fmod@plt>
mov    %rax,%r12
add    $0x8,%r12d
mov    %ebx,%edi
mov    $0x2000,%esi
call   1030 <fmod@plt>
mov    %rax,%rbp
mov    %r13d,%edi
mov    $0x2000,%esi
call   1030 <fmod@plt>
mov    $0x1fff,%ebx
sub    %eax,%ebx
mov    %ebp,%edi
mov    $0x80,%esi
call   1030 <fmod@plt>
mov    %rax,%r13
lea    0x7f(%rbp),%r14d
test   %ebp,%ebp
cmovns %ebp,%r14d
sar    $0x7,%r14d
mov    %ebx,%edi
mov    $0x80,%esi
call   1030 <fmod@plt>
lea    0x7f(%rbx),%ecx
test   %ebx,%ebx
cmovns %ebx,%ecx
sar    $0x7,%ecx
movslq %r14d,%rdx
lea    0x2bfe(%rip),%rsi
movslq %ecx,%rcx
lea    0x2df4(%rip),%rdi
mov    (%rdi,%rcx,4),%ecx
add    (%rsi,%rdx,4),%ecx
shl    $0xe,%ecx
movslq %r13d,%rdx
cltq
mov    (%rdi,%rax,4),%ebx
add    (%rsi,%rdx,4),%ebx
add    %ecx,%ebx
mov    $0x2000,%ax
xor    %edx,%edx
div    %r15w
movzwl %ax,%edi
mov    $0x2,%esi
call   1070 <pow@plt>
mov    %eax,%ecx
mov    %ebx,%eax
cltd
idiv   %ecx
mov    %eax,%ebx
mov    %r15,%rdi
mov    $0x2,%esi
call   1070 <pow@plt>
imul   %r12d,%eax
add    %ebx,%eax
cltq
mov    0x18(%rsp),%rcx
mov    %rax,(%rcx)
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2ae3(%rip),%rax
mov    (%rax),%edi
lea    0xb52(%rip),%rsi
lea    0xb6d(%rip),%rdx
mov    $0x3e,%ecx
mov    %r15,%r8
jmp    1530 <ang2pix_nest+0x3b0>
mov    0x2ac2(%rip),%rax
mov    (%rax),%edi
cvttsd2si %xmm0,%r8
lea    0xbea(%rip),%rsi
lea    0xb47(%rip),%rdx
mov    $0x42,%ecx
call   1050 <fprintf@plt>
xor    %edi,%edi
call   1090 <exit@plt>

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

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
@ang2pix_nest.x2pix = internal global [128 x i32] zeroinitializer
@ang2pix_nest.y2pix = internal global [128 x i32] zeroinitializer
@ang2pix_nest.setup_done = internal unnamed_addr global i1 false
@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/ang2pix_nest.c\00"
@.str.2 = [33 x i8] c"%s (%d): theta out of range: %f\0A\00"
define void @ang2pix_nest(i64 %0, double %1, double %2, i64* nocapture writeonly %3) {
%5 = load double, double* @M_PI
%6 = fmul double %5, 5.000000e-01
%7 = fmul double %5, 2.000000e+00
%8 = add i64 %0, -8193
%9 = icmp ult i64 %8, -8192
br i1 %9, label %10, label %14
10: ; preds = %4
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, 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 62, i64 %0)
%13 = tail call i32 @exit(i32 0)
unreachable
14: ; preds = %4
%15 = fcmp olt double %1, 0.000000e+00
%16 = fcmp olt double %5, %1
%17 = select i1 %15, i1 true, i1 %16
br i1 %17, label %18, label %23
18: ; preds = %14
%19 = load i32, i32* @stderr
%20 = fptosi double %1 to i64
%21 = tail call i32 @fprintf(i32 %19, 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 66, i64 %20)
%22 = tail call i32 @exit(i32 0)
unreachable
23: ; preds = %14
%24 = load i1, i1* @ang2pix_nest.setup_done
br i1 %24, label %27, label %25
25: ; preds = %23
%26 = tail call i32 @mk_xy2pix(i32* getelementptr inbounds ([128 x i32], [128 x i32]* @ang2pix_nest.x2pix, i64 0, i64 0), i32* getelementptr inbounds ([128 x i32], [128 x i32]* @ang2pix_nest.y2pix, i64 0, i64 0))
store i1 true, i1* @ang2pix_nest.setup_done
br label %27
27: ; preds = %25, %23
%28 = tail call double @cos(double %1)
%29 = tail call double @llvm.fabs.f64(double %28)
%30 = fcmp ugt double %7, %2
%31 = select i1 %30, double 0.000000e+00, double %7
%32 = fsub double %2, %31
%33 = fcmp olt double %32, 0.000000e+00
%34 = select i1 %33, double %7, double -0.000000e+00
%35 = fadd double %32, %34
%36 = fdiv double %35, %6
%37 = fcmp ugt double %29, 0x3FE5555555555555
br i1 %37, label %74, label %38
38: ; preds = %27
%39 = fadd double %36, 5.000000e-01
%40 = fneg double %28
%41 = tail call double @llvm.fmuladd.f64(double %40, double 7.500000e-01, double %39)
%42 = fmul double %41, 8.192000e+03
%43 = fptosi double %42 to i32
%44 = tail call i64 @floor(i32 %43)
%45 = trunc i64 %44 to i32
%46 = tail call double @llvm.fmuladd.f64(double %28, double 7.500000e-01, double %39)
%47 = fmul double %46, 8.192000e+03
%48 = fptosi double %47 to i32
%49 = tail call i64 @floor(i32 %48)
%50 = trunc i64 %49 to i32
%51 = sdiv i32 %45, 8192
%52 = sdiv i32 %50, 8192
%53 = icmp eq i32 %51, %52
br i1 %53, label %54, label %58
54: ; preds = %38
%55 = tail call i64 @fmod(i32 %51, i32 4)
%56 = trunc i64 %55 to i32
%57 = add nsw i32 %56, 4
br label %67
58: ; preds = %38
%59 = icmp slt i32 %51, %52
br i1 %59, label %60, label %63
60: ; preds = %58
%61 = tail call i64 @fmod(i32 %51, i32 4)
%62 = trunc i64 %61 to i32
br label %67
63: ; preds = %58
%64 = tail call i64 @fmod(i32 %52, i32 4)
%65 = trunc i64 %64 to i32
%66 = add nsw i32 %65, 8
br label %67
67: ; preds = %60, %63, %54
%68 = phi i32 [ %57, %54 ], [ %62, %60 ], [ %66, %63 ]
%69 = tail call i64 @fmod(i32 %50, i32 8192)
%70 = trunc i64 %69 to i32
%71 = tail call i64 @fmod(i32 %45, i32 8192)
%72 = trunc i64 %71 to i32
%73 = sub i32 8191, %72
br label %107
74: ; preds = %27
%75 = fptosi double %36 to i32
%76 = tail call i64 @floor(i32 %75)
%77 = trunc i64 %76 to i32
%78 = icmp slt i32 %77, 3
%79 = select i1 %78, i32 %77, i32 3
%80 = sitofp i32 %79 to double
%81 = fsub double %36, %80
%82 = fsub double 1.000000e+00, %29
%83 = fmul double %82, 3.000000e+00
%84 = fptosi double %83 to i32
%85 = tail call double @sqrt(i32 %84)
%86 = fmul double %81, 8.192000e+03
%87 = fmul double %85, %86
%88 = fptosi double %87 to i32
%89 = tail call i64 @floor(i32 %88)
%90 = trunc i64 %89 to i32
%91 = fsub double 1.000000e+00, %81
%92 = fmul double %91, 8.192000e+03
%93 = fmul double %85, %92
%94 = fptosi double %93 to i32
%95 = tail call i64 @floor(i32 %94)
%96 = trunc i64 %95 to i32
%97 = icmp slt i32 %90, 8191
%98 = select i1 %97, i32 %90, i32 8191
%99 = icmp slt i32 %96, 8191
%100 = select i1 %99, i32 %96, i32 8191
%101 = fcmp ult double %28, 0.000000e+00
br i1 %101, label %105, label %102
102: ; preds = %74
%103 = sub i32 8191, %100
%104 = sub i32 8191, %98
br label %107
105: ; preds = %74
%106 = add nsw i32 %79, 8
br label %107
107: ; preds = %102, %105, %67
%108 = phi i32 [ %73, %67 ], [ %104, %102 ], [ %100, %105 ]
%109 = phi i32 [ %70, %67 ], [ %103, %102 ], [ %98, %105 ]
%110 = phi i32 [ %68, %67 ], [ %79, %102 ], [ %106, %105 ]
%111 = tail call i64 @fmod(i32 %109, i32 128)
%112 = sdiv i32 %109, 128
%113 = tail call i64 @fmod(i32 %108, i32 128)
%114 = sdiv i32 %108, 128
%115 = sext i32 %112 to i64
%116 = getelementptr inbounds [128 x i32], [128 x i32]* @ang2pix_nest.x2pix, i64 0, i64 %115
%117 = load i32, i32* %116
%118 = sext i32 %114 to i64
%119 = getelementptr inbounds [128 x i32], [128 x i32]* @ang2pix_nest.y2pix, i64 0, i64 %118
%120 = load i32, i32* %119
%121 = add nsw i32 %120, %117
%122 = shl nsw i32 %121, 14
%123 = shl i64 %111, 32
%124 = ashr exact i64 %123, 32
%125 = getelementptr inbounds [128 x i32], [128 x i32]* @ang2pix_nest.x2pix, i64 0, i64 %124
%126 = load i32, i32* %125
%127 = shl i64 %113, 32
%128 = ashr exact i64 %127, 32
%129 = getelementptr inbounds [128 x i32], [128 x i32]* @ang2pix_nest.y2pix, i64 0, i64 %128
%130 = load i32, i32* %129
%131 = add nsw i32 %130, %126
%132 = add nsw i32 %131, %122
%133 = trunc i64 %0 to i16
%134 = udiv i16 8192, %133
%135 = zext i16 %134 to i64
%136 = tail call i32 @pow(i64 %135, i32 2)
%137 = sdiv i32 %132, %136
%138 = tail call i32 @pow(i64 %0, i32 2)
%139 = mul nsw i32 %138, %110
%140 = add nsw i32 %139, %137
%141 = sext i32 %140 to i64
store i64 %141, i64* %3
ret void
}