#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 floor(double);
int fmod(double, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int, long);
double sin(double);
double sqrt(double);
int /*<<< orphan*/ stderr;
void pix2vec_ring(long nside, long ipix, double *vec) {
  int nl2, nl4, npix, ncap, iring, iphi, ip, ipix1;
  double fact1, fact2, fodd, hip, fihip;
  double PI = M_PI;
  double z, sz, phi;
  int ns_max = 8192;
  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/pix2vec_ring.c",
            51, 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/pix2vec_ring.c",
            56, ipix);
    exit(0);
  }
  ipix1 = ipix + 1;
  nl2 = 2 * nside;
  nl4 = 4 * nside;
  ncap = 2 * nside * (nside - 1);
  fact1 = 1.5 * nside;
  fact2 = 3.0 * nside * nside;
  if (ipix1 <= ncap) {
    hip = ipix1 / 2.;
    fihip = floor(hip);
    iring = (int)floor(sqrt(hip - sqrt(fihip))) + 1;
    iphi = ipix1 - 2 * iring * (iring - 1);
    z = 1. - iring * iring / fact2;
    phi = (1. * iphi - 0.5) * PI / (2. * iring);
  } else if (ipix1 <= nl2 * (5 * nside + 1)) {
    ip = ipix1 - ncap - 1;
    iring = (int)floor(ip / nl4) + nside;
    iphi = (int)fmod(ip, nl4) + 1;
    fodd = 0.5 * (1 + fmod((double)(iring + nside), 2));
    z = (nl2 - iring) / fact1;
    phi = (1. * iphi - fodd) * PI / (2. * nside);
  } else {
    ip = npix - ipix1 + 1;
    hip = ip / 2.;
    fihip = floor(hip);
    iring = (int)floor(sqrt(hip - sqrt(fihip))) + 1;
    iphi = (int)(4. * iring + 1 - (ip - 2. * iring * (iring - 1)));
    z = -1. + iring * iring / fact2;
    phi = (1. * iphi - 0.5) * PI / (2. * iring);
  }
  sz = sqrt(1.0 - z * z);
  vec[0] = sz * cos(phi);
  vec[1] = sz * sin(phi);
  vec[2] = z;
}


x86 assembly (clang, -O0):
<pix2vec_ring>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    0x2e5a(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x68(%rbp)
movl   $0x2000,-0x84(%rbp)
cmpq   $0x1,-0x8(%rbp)
jl     11c0 <pix2vec_ring+0x50>
mov    -0x8(%rbp),%rax
movslq -0x84(%rbp),%rcx
cmp    %rcx,%rax
jle    11ec <pix2vec_ring+0x7c>
mov    0x2e11(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%r8
lea    0xe6c(%rip),%rsi
lea    0xe87(%rip),%rdx
mov    $0x33,%ecx
call   1040 <fprintf@plt>
xor    %edi,%edi
call   1080 <exit@plt>
imul   $0xc,-0x8(%rbp),%rax
imul   -0x8(%rbp),%rax
mov    %eax,-0x24(%rbp)
cmpq   $0x0,-0x10(%rbp)
jl     121a <pix2vec_ring+0xaa>
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
cmp    %rcx,%rax
jle    1246 <pix2vec_ring+0xd6>
mov    0x2db7(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%r8
lea    0xed0(%rip),%rsi
lea    0xe2d(%rip),%rdx
mov    $0x38,%ecx
call   1040 <fprintf@plt>
xor    %edi,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %eax,-0x38(%rbp)
mov    -0x8(%rbp),%rax
shl    $0x1,%rax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
shl    $0x1,%rax
mov    -0x8(%rbp),%rcx
sub    $0x1,%rcx
imul   %rcx,%rax
mov    %eax,-0x28(%rbp)
cvtsi2sdq -0x8(%rbp),%xmm1
movsd  0xd7c(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
cvtsi2sdq -0x8(%rbp),%xmm1
movsd  0xd5d(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsi2sdq -0x8(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x28(%rbp),%eax
jg     138e <pix2vec_ring+0x21e>
cvtsi2sdl -0x38(%rbp),%xmm0
movsd  0xd41(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
call   1090 <floor@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x60(%rbp),%xmm0
call   1070 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x90(%rbp),%xmm0
ff
subsd  %xmm1,%xmm0
call   1070 <sqrt@plt>
call   1090 <floor@plt>
cvttsd2si %xmm0,%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x38(%rbp),%eax
mov    -0x2c(%rbp),%ecx
shl    $0x1,%ecx
mov    -0x2c(%rbp),%edx
sub    $0x1,%edx
imul   %edx,%ecx
sub    %ecx,%eax
mov    %eax,-0x30(%rbp)
mov    -0x2c(%rbp),%eax
imul   -0x2c(%rbp),%eax
cvtsi2sd %eax,%xmm1
divsd  -0x48(%rbp),%xmm1
movsd  0xce0(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
cvtsi2sdl -0x30(%rbp),%xmm0
movsd  0xcb2(%rip),%xmm1
addsd  %xmm1,%xmm0
mulsd  -0x68(%rbp),%xmm0
cvtsi2sdl -0x2c(%rbp),%xmm2
movsd  0xc94(%rip),%xmm1
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
jmp    159d <pix2vec_ring+0x42d>
movslq -0x38(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   $0x5,-0x8(%rbp),%rdx
add    $0x1,%rdx
imul   %rdx,%rcx
cmp    %rcx,%rax
jg     1475 <pix2vec_ring+0x305>
mov    -0x38(%rbp),%eax
sub    -0x28(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cltd
idivl  -0x20(%rbp)
cvtsi2sd %eax,%xmm0
call   1090 <floor@plt>
cvttsd2si %xmm0,%eax
cltq
add    -0x8(%rbp),%rax
mov    %eax,-0x2c(%rbp)
cvtsi2sdl -0x34(%rbp),%xmm0
mov    -0x20(%rbp),%edi
call   1030 <fmod@plt>
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
movslq -0x2c(%rbp),%rax
add    -0x8(%rbp),%rax
cvtsi2sd %rax,%xmm0
mov    $0x2,%edi
call   1030 <fmod@plt>
add    $0x1,%eax
cvtsi2sd %eax,%xmm1
movsd  0xc2a(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x1c(%rbp),%eax
sub    -0x2c(%rbp),%eax
cvtsi2sd %eax,%xmm0
divsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
cvtsi2sdl -0x30(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
addsd  %xmm1,%xmm0
mulsd  -0x68(%rbp),%xmm0
cvtsi2sdq -0x8(%rbp),%xmm2
movsd  0xbad(%rip),%xmm1
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
jmp    1598 <pix2vec_ring+0x428>
mov    -0x24(%rbp),%eax
sub    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
cvtsi2sdl -0x34(%rbp),%xmm0
movsd  0xb82(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
call   1090 <floor@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x60(%rbp),%xmm0
call   1070 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x98(%rbp),%xmm0
ff
subsd  %xmm1,%xmm0
call   1070 <sqrt@plt>
call   1090 <floor@plt>
cvttsd2si %xmm0,%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
cvtsi2sdl -0x2c(%rbp),%xmm0
movsd  0xb3b(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xb37(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsi2sdl -0x34(%rbp),%xmm2
cvtsi2sdl -0x2c(%rbp),%xmm3
movsd  0xb01(%rip),%xmm1
mulsd  %xmm3,%xmm1
mov    -0x2c(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm3
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x30(%rbp)
mov    -0x2c(%rbp),%eax
imul   -0x2c(%rbp),%eax
cvtsi2sd %eax,%xmm1
divsd  -0x48(%rbp),%xmm1
movsd  0xac1(%rip),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
cvtsi2sdl -0x30(%rbp),%xmm0
movsd  0xaa3(%rip),%xmm1
addsd  %xmm1,%xmm0
mulsd  -0x68(%rbp),%xmm0
cvtsi2sdl -0x2c(%rbp),%xmm2
movsd  0xa85(%rip),%xmm1
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
jmp    159d <pix2vec_ring+0x42d>
movsd  -0x70(%rbp),%xmm0
movsd  -0x70(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xa66(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1070 <sqrt@plt>
movsd  %xmm0,-0x78(%rbp)
movsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
movsd  -0x80(%rbp),%xmm0
call   1060 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0xa8(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0x80(%rbp),%xmm0
call   1050 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0xa0(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x70(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x10(%rax)
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pix2vec_ring>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%rbx
lea    -0x2001(%rdi),%rax
cmp    $0xffffffffffffdfff,%rax
jbe    14e0 <pix2vec_ring+0x370>
mov    %rsi,%r8
test   %rsi,%rsi
js     14c2 <pix2vec_ring+0x352>
mov    %rbx,%rax
imul   %rbx,%rax
shl    $0x2,%rax
lea    (%rax,%rax,2),%rax
lea    -0x1(%rax),%ecx
cmp    %r8,%rcx
jb     14c2 <pix2vec_ring+0x352>
mov    %rdx,%r14
mov    0x2e25(%rip),%rcx
movsd  (%rcx),%xmm0
movsd  %xmm0,0x8(%rsp)
lea    0x1(%r8),%ebp
lea    (%rbx,%rbx,1),%r12
lea    -0x1(%rbx),%ecx
imul   %r12d,%ecx
cvtsi2sd %rbx,%xmm1
movsd  0xe1f(%rip),%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
cmp    %ecx,%ebp
jle    1252 <pix2vec_ring+0xe2>
movslq %ebp,%rdx
mov    %r12d,%esi
and    $0xfffffffe,%esi
lea    (%rbx,%rbx,4),%rdi
add    $0x1,%rdi
imul   %rsi,%rdi
cmp    %rdx,%rdi
jge    1288 <pix2vec_ring+0x118>
movsd  %xmm0,(%rsp)
sub    %r8d,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movsd  0xdea(%rip),%xmm0
movsd  %xmm1,0x10(%rsp)
mulsd  %xmm1,%xmm0
movsd  %xmm0,0x18(%rsp)
call   1090 <floor@plt>
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm0
jb     13a5 <pix2vec_ring+0x235>
sqrtsd %xmm0,%xmm0
jmp    13ae <pix2vec_ring+0x23e>
movsd  %xmm0,(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
mulsd  0xdaa(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
call   1090 <floor@plt>
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm0
jb     131c <pix2vec_ring+0x1ac>
sqrtsd %xmm0,%xmm0
jmp    1325 <pix2vec_ring+0x1b5>
lea    0x0(,%rbx,4),%edi
movsd  0xd69(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,(%rsp)
sub    %ecx,%r8d
mov    %r8d,%eax
cltd
idiv   %edi
mov    %eax,%ebp
add    %ebx,%ebp
xorps  %xmm0,%xmm0
cvtsi2sd %r8d,%xmm0
movsd  %xmm1,0x10(%rsp)
call   1030 <fmod@plt>
mov    %eax,%r15d
add    $0x1,%r15d
movslq %ebp,%rbp
add    %rbp,%rbx
xorps  %xmm0,%xmm0
cvtsi2sd %rbx,%xmm0
mov    $0x2,%edi
call   1030 <fmod@plt>
add    $0x1,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
sub    %ebp,%r12d
cvtsi2sd %r12d,%xmm3
divsd  (%rsp),%xmm3
xorps  %xmm1,%xmm1
cvtsi2sd %r15d,%xmm1
mulsd  0xd1a(%rip),%xmm0
addsd  %xmm1,%xmm0
movsd  0x8(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  0x10(%rsp),%xmm0
jmp    1392 <pix2vec_ring+0x222>
call   1070 <sqrt@plt>
xorpd  %xmm2,%xmm2
movsd  0x10(%rsp),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
ucomisd %xmm2,%xmm1
jb     133f <pix2vec_ring+0x1cf>
sqrtsd %xmm0,%xmm0
jmp    1344 <pix2vec_ring+0x1d4>
call   1070 <sqrt@plt>
call   1090 <floor@plt>
cvttsd2si %xmm0,%eax
lea    0x1(%rax),%ecx
imul   %ecx,%eax
add    %eax,%eax
sub    %eax,%ebp
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
imul   %ecx,%ecx
xorps  %xmm1,%xmm1
cvtsi2sd %ecx,%xmm1
divsd  (%rsp),%xmm1
movsd  0xca3(%rip),%xmm3
xorps  %xmm2,%xmm2
cvtsi2sd %ebp,%xmm2
addsd  0xc9c(%rip),%xmm2
subsd  %xmm1,%xmm3
movsd  0x8(%rsp),%xmm1
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm0
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
jmp    144a <pix2vec_ring+0x2da>
call   1070 <sqrt@plt>
xorpd  %xmm2,%xmm2
movsd  0x18(%rsp),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
ucomisd %xmm2,%xmm1
jb     13c8 <pix2vec_ring+0x258>
sqrtsd %xmm0,%xmm0
jmp    13cd <pix2vec_ring+0x25d>
call   1070 <sqrt@plt>
call   1090 <floor@plt>
cvttsd2si %xmm0,%eax
add    $0x1,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movsd  0xc40(%rip),%xmm2
mulsd  %xmm1,%xmm2
addsd  0xc24(%rip),%xmm2
cvttpd2dq %xmm0,%xmm0
addsd  %xmm1,%xmm1
cvtdq2pd %xmm0,%xmm0
mulsd  %xmm1,%xmm0
movsd  0x10(%rsp),%xmm4
subsd  %xmm0,%xmm4
imul   %eax,%eax
cvtsi2sd %eax,%xmm3
subsd  %xmm4,%xmm2
divsd  (%rsp),%xmm3
addsd  0xc0a(%rip),%xmm3
cvttpd2dq %xmm2,%xmm0
cvtdq2pd %xmm0,%xmm0
addsd  0xbea(%rip),%xmm0
movsd  0x8(%rsp),%xmm2
mulsd  %xmm0,%xmm2
divsd  %xmm1,%xmm2
movsd  %xmm2,0x8(%rsp)
movsd  %xmm3,0x10(%rsp)
movapd %xmm3,%xmm1
mulsd  %xmm3,%xmm1
movsd  0xbb8(%rip),%xmm0
subsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1474 <pix2vec_ring+0x304>
sqrtsd %xmm0,%xmm0
jmp    1479 <pix2vec_ring+0x309>
call   1070 <sqrt@plt>
movsd  %xmm0,(%rsp)
movsd  0x8(%rsp),%xmm0
call   1060 <cos@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%r14)
movsd  0x8(%rsp),%xmm0
call   1050 <sin@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,0x8(%r14)
movsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%r14)
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2b0f(%rip),%rax
mov    (%rax),%edi
lea    0xc24(%rip),%rsi
lea    0xb81(%rip),%rdx
mov    $0x38,%ecx
jmp    14ff <pix2vec_ring+0x38f>
mov    0x2af1(%rip),%rax
mov    (%rax),%edi
lea    0xb48(%rip),%rsi
lea    0xb63(%rip),%rdx
mov    $0x33,%ecx
mov    %rbx,%r8
call   1040 <fprintf@plt>
xor    %edi,%edi
call   1080 <exit@plt>

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

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