#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 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 * 3.14159265358979323846, pi = 3.14159265358979323846,
         twopi = 2.0 * 3.14159265358979323846;
  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/ezralanglois/arachnid/refs/heads/master/"
            "arachnid/core/orient/core/healpix/ang2pix_nest.c",
            66, 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/ezralanglois/arachnid/refs/heads/master/"
            "arachnid/core/orient/core/healpix/ang2pix_nest.c",
            70, 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  0xe6b(%rip),%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  0xe53(%rip),%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  0xe3b(%rip),%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
movl   $0x2000,-0xac(%rbp)
cmpq   $0x1,-0x8(%rbp)
jl     11f6 <ang2pix_nest+0x76>
mov    -0x8(%rbp),%rax
movslq -0xac(%rbp),%rcx
cmp    %rcx,%rax
jle    1222 <ang2pix_nest+0xa2>
mov    0x2de3(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%r8
lea    0xe46(%rip),%rsi
lea    0xe61(%rip),%rdx
mov    $0x42,%ecx
call   1050 <fprintf@plt>
xor    %edi,%edi
call   1090 <exit@plt>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
ja     1243 <ang2pix_nest+0xc3>
movsd  -0x10(%rbp),%xmm0
ucomisd -0xa0(%rbp),%xmm0
ff
jbe    1271 <ang2pix_nest+0xf1>
mov    0x2d96(%rip),%rax
mov    (%rax),%edi
cvttsd2si -0x10(%rbp),%r8
lea    0xecc(%rip),%rsi
lea    0xe12(%rip),%rdx
mov    $0x46,%ecx
call   1050 <fprintf@plt>
xor    %edi,%edi
call   1090 <exit@plt>
cmpb   $0x0,0x31f8(%rip)
jne    1298 <ang2pix_nest+0x118>
lea    0x2deb(%rip),%rdi
lea    0x2fe4(%rip),%rsi
call   1040 <mk_xy2pix@plt>
movb   $0x1,0x31d8(%rip)
movsd  -0x10(%rbp),%xmm0
call   1060 <cos@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movaps 0xd8d(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xd54(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
ucomisd -0xa8(%rbp),%xmm0
ff
jb     12ee <ang2pix_nest+0x16e>
movsd  -0x18(%rbp),%xmm0
subsd  -0xa8(%rbp),%xmm0
ff
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    130e <ang2pix_nest+0x18e>
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     148a <ang2pix_nest+0x30a>
cvtsi2sdl -0xac(%rbp),%xmm0
ff
movsd  0xcf4(%rip),%xmm2
addsd  -0x40(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  0xcc3(%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  0xca3(%rip),%xmm2
addsd  -0x40(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm1
movsd  0xc89(%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    1408 <ang2pix_nest+0x288>
mov    -0x68(%rbp),%rax
mov    %eax,%edi
mov    $0x4,%esi
call   1030 <fmod@plt>
add    $0x4,%eax
mov    %eax,-0x54(%rbp)
jmp    1449 <ang2pix_nest+0x2c9>
mov    -0x68(%rbp),%rax
cmp    -0x70(%rbp),%rax
jge    142e <ang2pix_nest+0x2ae>
mov    -0x68(%rbp),%rax
mov    %eax,%edi
mov    $0x4,%esi
call   1030 <fmod@plt>
mov    %eax,-0x54(%rbp)
jmp    1444 <ang2pix_nest+0x2c4>
mov    -0x70(%rbp),%rax
mov    %eax,%edi
mov    $0x4,%esi
call   1030 <fmod@plt>
add    $0x8,%eax
mov    %eax,-0x54(%rbp)
jmp    1449 <ang2pix_nest+0x2c9>
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    1605 <ang2pix_nest+0x485>
cvttsd2si -0x40(%rbp),%edi
call   10a0 <floor@plt>
mov    %eax,-0x90(%rbp)
cmpl   $0x4,-0x90(%rbp)
jl     14b1 <ang2pix_nest+0x331>
movl   $0x3,-0x90(%rbp)
movsd  -0x40(%rbp),%xmm0
cvtsi2sdl -0x90(%rbp),%xmm1
ff
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xb51(%rip),%xmm1
subsd  -0x30(%rbp),%xmm1
movsd  0xb4c(%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  0xb04(%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    1558 <ang2pix_nest+0x3d8>
mov    -0x58(%rbp),%eax
mov    %eax,-0xb4(%rbp)
jmp    1567 <ang2pix_nest+0x3e7>
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    1592 <ang2pix_nest+0x412>
mov    -0x5c(%rbp),%eax
mov    %eax,-0xb8(%rbp)
jmp    15a1 <ang2pix_nest+0x421>
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     15e8 <ang2pix_nest+0x468>
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    1600 <ang2pix_nest+0x480>
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    1605 <ang2pix_nest+0x485>
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    0x2a1e(%rip),%rax
mov    (%rax,%rcx,4),%eax
movslq -0x88(%rbp),%rdx
lea    0x2c0d(%rip),%rcx
add    (%rcx,%rdx,4),%eax
shl    $0xe,%eax
movslq -0x7c(%rbp),%rdx
lea    0x29fc(%rip),%rcx
mov    (%rcx,%rdx,4),%ecx
movslq -0x84(%rbp),%rsi
lea    0x2beb(%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    14d6 <ang2pix_nest+0x356>
xorpd  %xmm2,%xmm2
ucomisd %xmm0,%xmm2
ja     14f7 <ang2pix_nest+0x377>
ucomisd 0xe46(%rip),%xmm0
ja     14f7 <ang2pix_nest+0x377>
mov    %rsi,%rbx
movaps %xmm1,(%rsp)
cmpb   $0x0,0x32a2(%rip)
jne    11f6 <ang2pix_nest+0x76>
lea    0x2e99(%rip),%rdi
lea    0x3092(%rip),%rsi
movsd  %xmm0,0x18(%rsp)
call   1040 <mk_xy2pix@plt>
movsd  0x18(%rsp),%xmm0
movb   $0x1,0x327a(%rip)
mov    %rbx,0x18(%rsp)
call   1060 <cos@plt>
movapd 0xe58(%rip),%xmm5
movsd  0xdf8(%rip),%xmm3
movapd (%rsp),%xmm4
addsd  %xmm4,%xmm3
movsd  0xdef(%rip),%xmm1
movapd %xmm1,%xmm2
cmpnlesd %xmm4,%xmm2
andpd  %xmm2,%xmm4
andnpd %xmm3,%xmm2
orpd   %xmm4,%xmm2
addsd  %xmm2,%xmm1
xorpd  %xmm3,%xmm3
movapd %xmm2,%xmm4
cmpltsd %xmm3,%xmm4
andpd  %xmm4,%xmm1
andnpd %xmm2,%xmm4
orpd   %xmm1,%xmm4
divsd  0xdbd(%rip),%xmm4
andpd  %xmm0,%xmm5
movsd  0xdb9(%rip),%xmm1
ucomisd %xmm5,%xmm1
jae    134b <ang2pix_nest+0x1cb>
cvttsd2si %xmm4,%edi
movapd %xmm0,0x30(%rsp)
movapd %xmm4,(%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  0xd8a(%rip),%xmm0
subsd  0x20(%rsp),%xmm0
mulsd  0xd84(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1080 <sqrt@plt>
movsd  %xmm0,0x20(%rsp)
movapd (%rsp),%xmm1
mulsd  0xd58(%rip),%xmm1
mulsd  %xmm0,%xmm1
cvttsd2si %xmm1,%edi
call   10a0 <floor@plt>
mov    %rax,%rbp
movsd  0xd48(%rip),%xmm0
subsd  (%rsp),%xmm0
mulsd  0xd33(%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 0xd14(%rip),%xmm0
jae    13d6 <ang2pix_nest+0x256>
add    $0x8,%r12d
jmp    142c <ang2pix_nest+0x2ac>
addsd  0xcd5(%rip),%xmm4
movapd %xmm4,(%rsp)
mulsd  0xcd0(%rip),%xmm0
movapd %xmm0,0x30(%rsp)
movapd %xmm4,%xmm1
subsd  %xmm0,%xmm1
mulsd  0xcc2(%rip),%xmm1
cvttsd2si %xmm1,%edi
call   10a0 <floor@plt>
mov    %rax,%r13
movapd 0x30(%rsp),%xmm0
addsd  (%rsp),%xmm0
mulsd  0xca3(%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    13e5 <ang2pix_nest+0x265>
mov    $0x4,%esi
call   1030 <fmod@plt>
mov    %rax,%r12
add    $0x4,%r12d
jmp    1409 <ang2pix_nest+0x289>
sub    %ebp,%eax
mov    $0x1fff,%ecx
sub    %ebx,%ecx
mov    %eax,%ebx
mov    %ecx,%ebp
jmp    142c <ang2pix_nest+0x2ac>
jge    13f6 <ang2pix_nest+0x276>
mov    $0x4,%esi
call   1030 <fmod@plt>
mov    %rax,%r12
jmp    1409 <ang2pix_nest+0x289>
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    0x2c06(%rip),%rsi
movslq %ecx,%rcx
lea    0x2dfc(%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    0x2b03(%rip),%rax
mov    (%rax),%edi
lea    0xb8a(%rip),%rsi
lea    0xba5(%rip),%rdx
mov    $0x42,%ecx
mov    %r15,%r8
jmp    1518 <ang2pix_nest+0x398>
mov    0x2ae2(%rip),%rax
mov    (%rax),%edi
cvttsd2si %xmm0,%r8
lea    0xc39(%rip),%rsi
lea    0xb7f(%rip),%rdx
mov    $0x46,%ecx
call   1050 <fprintf@plt>
xor    %edi,%edi
call   1090 <exit@plt>

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

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