#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 atan2(double, double);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
double fabs(double);
double floor(long const);
int fmod(int, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int, long const);
double sqrt(int);
int /*<<< orphan*/ stderr;
void vec2pix_ring(const long nside, double *vec, long *ipix) {
  int nl2, nl4, ncap, npix, jp, jm, ipix1;
  double z, za, tt, tp, tmp, phi;
  int ir, ip, kshift;
  double piover2 = 0.5 * M_PI;
  double twopi = 2.0 * M_PI;
  double z0 = 2.0 / 3.0;
  long 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/vec2pix_ring.c",
            55, nside);
    exit(0);
  }
  z = vec[2] / sqrt(vec[0] * vec[0] + vec[1] * vec[1] + vec[2] * vec[2]);
  phi = 0.0;
  if (vec[0] != 0.0 || vec[1] != 0.0) {
    phi = atan2(vec[1], vec[0]);
    if (phi < 0.0)
      phi += twopi;
  }
  za = fabs(z);
  tt = phi / piover2;
  nl2 = 2 * nside;
  nl4 = 4 * nside;
  ncap = nl2 * (nside - 1);
  npix = 12 * nside * nside;
  if (za <= z0) {
    jp = (int)floor(nside * (0.5 + tt - z * 0.75));
    jm = (int)floor(nside * (0.5 + tt + z * 0.75));
    ir = nside + 1 + jp - jm;
    kshift = 0;
    if (fmod(ir, 2) == 0.)
      kshift = 1;
    ip = (int)floor((jp + jm - nside + kshift + 1) / 2) + 1;
    if (ip > nl4)
      ip = ip - nl4;
    ipix1 = ncap + nl4 * (ir - 1) + ip;
  } else {
    tp = tt - floor(tt);
    tmp = sqrt(3. * (1. - za));
    jp = (int)floor(nside * tp * tmp);
    jm = (int)floor(nside * (1. - tp) * tmp);
    ir = jp + jm + 1;
    ip = (int)floor(tt * ir) + 1;
    if (ip > 4 * ir)
      ip = ip - 4 * ir;
    ipix1 = 2 * ir * (ir - 1) + ip;
    if (z <= 0.) {
      ipix1 = npix - 2 * ir * (ir + 1) + ip;
    }
  }
  *ipix = ipix1 - 1;
}


x86 assembly (clang, -O0):
<vec2pix_ring>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movsd  0xe91(%rip),%xmm0
mov    0x2e62(%rip),%rax
mulsd  (%rax),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  0xe71(%rip),%xmm0
mov    0x2e4a(%rip),%rax
mulsd  (%rax),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  0xe4e(%rip),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movq   $0x2000,-0x98(%rbp)
cmpq   $0x1,-0x8(%rbp)
jl     11e1 <vec2pix_ring+0x81>
mov    -0x8(%rbp),%rax
cmp    -0x98(%rbp),%rax
jle    120d <vec2pix_ring+0xad>
mov    0x2df0(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%r8
lea    0xe4b(%rip),%rsi
lea    0xe66(%rip),%rdx
mov    $0x37,%ecx
call   1050 <fprintf@plt>
xor    %edi,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x8(%rax),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1060 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0xa0(%rbp),%xmm0
ff
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    12c3 <vec2pix_ring+0x163>
jp     12c3 <vec2pix_ring+0x163>
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    12c3 <vec2pix_ring+0x163>
jp     12c3 <vec2pix_ring+0x163>
jmp    1303 <vec2pix_ring+0x1a3>
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm1
call   1030 <atan2@plt>
movsd  %xmm0,-0x68(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x68(%rbp),%xmm0
jbe    12fe <vec2pix_ring+0x19e>
movsd  -0x88(%rbp),%xmm0
ff
addsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
jmp    1303 <vec2pix_ring+0x1a3>
movsd  -0x40(%rbp),%xmm0
movaps 0xd21(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x68(%rbp),%xmm0
divsd  -0x80(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x8(%rbp),%rax
shl    $0x1,%rax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,-0x20(%rbp)
movslq -0x1c(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    $0x1,%rcx
imul   %rcx,%rax
mov    %eax,-0x24(%rbp)
imul   $0xc,-0x8(%rbp),%rax
imul   -0x8(%rbp),%rax
mov    %eax,-0x28(%rbp)
movsd  -0x48(%rbp),%xmm1
movsd  -0x90(%rbp),%xmm0
ff
ucomisd %xmm1,%xmm0
jb     14b4 <vec2pix_ring+0x354>
cvtsi2sdq -0x8(%rbp),%xmm0
movsd  0xc8e(%rip),%xmm2
addsd  -0x50(%rbp),%xmm2
movsd  -0x40(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  0xc7d(%rip),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rdi
call   1080 <floor@plt>
cvttsd2si %xmm0,%eax
mov    %eax,-0x2c(%rbp)
cvtsi2sdq -0x8(%rbp),%xmm0
movsd  0xc3a(%rip),%xmm2
addsd  -0x50(%rbp),%xmm2
movsd  -0x40(%rbp),%xmm1
movsd  0xc40(%rip),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rdi
call   1080 <floor@plt>
cvttsd2si %xmm0,%eax
mov    %eax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
movslq -0x2c(%rbp),%rcx
add    %rcx,%rax
movslq -0x30(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x6c(%rbp)
movl   $0x0,-0x74(%rbp)
mov    -0x6c(%rbp),%edi
mov    $0x2,%esi
call   1040 <fmod@plt>
cvtsi2sd %eax,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1450 <vec2pix_ring+0x2f0>
jp     1450 <vec2pix_ring+0x2f0>
movl   $0x1,-0x74(%rbp)
mov    -0x2c(%rbp),%eax
add    -0x30(%rbp),%eax
cltq
sub    -0x8(%rbp),%rax
movslq -0x74(%rbp),%rcx
add    %rcx,%rax
add    $0x1,%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,%rdi
call   1080 <floor@plt>
cvttsd2si %xmm0,%eax
add    $0x1,%eax
mov    %eax,-0x70(%rbp)
mov    -0x70(%rbp),%eax
cmp    -0x20(%rbp),%eax
jle    1498 <vec2pix_ring+0x338>
mov    -0x70(%rbp),%eax
sub    -0x20(%rbp),%eax
mov    %eax,-0x70(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x20(%rbp),%ecx
mov    -0x6c(%rbp),%edx
sub    $0x1,%edx
imul   %edx,%ecx
add    %ecx,%eax
add    -0x70(%rbp),%eax
mov    %eax,-0x34(%rbp)
jmp    15e4 <vec2pix_ring+0x484>
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
cvttsd2si -0x50(%rbp),%rdi
call   1080 <floor@plt>
movaps %xmm0,%xmm1
movsd  -0xa8(%rbp),%xmm0
ff
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  0xb30(%rip),%xmm1
subsd  -0x48(%rbp),%xmm1
movsd  0xb2b(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1060 <sqrt@plt>
movsd  %xmm0,-0x60(%rbp)
cvtsi2sdq -0x8(%rbp),%xmm0
mulsd  -0x58(%rbp),%xmm0
mulsd  -0x60(%rbp),%xmm0
cvttsd2si %xmm0,%rdi
call   1080 <floor@plt>
cvttsd2si %xmm0,%eax
mov    %eax,-0x2c(%rbp)
cvtsi2sdq -0x8(%rbp),%xmm0
movsd  0xae2(%rip),%xmm1
subsd  -0x58(%rbp),%xmm1
mulsd  %xmm1,%xmm0
mulsd  -0x60(%rbp),%xmm0
cvttsd2si %xmm0,%rdi
call   1080 <floor@plt>
cvttsd2si %xmm0,%eax
mov    %eax,-0x30(%rbp)
mov    -0x2c(%rbp),%eax
add    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
movsd  -0x50(%rbp),%xmm0
cvtsi2sdl -0x6c(%rbp),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rdi
call   1080 <floor@plt>
cvttsd2si %xmm0,%eax
add    $0x1,%eax
mov    %eax,-0x70(%rbp)
mov    -0x70(%rbp),%eax
mov    -0x6c(%rbp),%ecx
shl    $0x2,%ecx
cmp    %ecx,%eax
jle    15a2 <vec2pix_ring+0x442>
mov    -0x70(%rbp),%eax
mov    -0x6c(%rbp),%ecx
shl    $0x2,%ecx
sub    %ecx,%eax
mov    %eax,-0x70(%rbp)
mov    -0x6c(%rbp),%eax
shl    $0x1,%eax
mov    -0x6c(%rbp),%ecx
sub    $0x1,%ecx
imul   %ecx,%eax
add    -0x70(%rbp),%eax
mov    %eax,-0x34(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x40(%rbp),%xmm0
jb     15df <vec2pix_ring+0x47f>
mov    -0x28(%rbp),%eax
mov    -0x6c(%rbp),%ecx
shl    $0x1,%ecx
mov    -0x6c(%rbp),%edx
add    $0x1,%edx
imul   %edx,%ecx
sub    %ecx,%eax
add    -0x70(%rbp),%eax
mov    %eax,-0x34(%rbp)
jmp    15e4 <vec2pix_ring+0x484>
mov    -0x34(%rbp),%eax
sub    $0x1,%eax
movslq %eax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vec2pix_ring>:
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    145b <vec2pix_ring+0x2fb>
mov    %rsi,%rbx
mov    %rdx,0x18(%rsp)
mov    0x2e55(%rip),%rax
movsd  (%rax),%xmm1
movsd  0xe61(%rip),%xmm0
movsd  %xmm1,0x8(%rsp)
mulsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x10(%rsi),%xmm2
movapd %xmm2,0x20(%rsp)
movsd  (%rsi),%xmm0
movsd  0x8(%rsi),%xmm1
mulsd  %xmm1,%xmm1
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
movapd %xmm2,%xmm1
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
cvttsd2si %xmm1,%edi
call   1060 <sqrt@plt>
movapd 0x20(%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,0x20(%rsp)
movsd  (%rbx),%xmm1
movsd  0x8(%rbx),%xmm0
xorpd  %xmm3,%xmm3
ucomisd %xmm3,%xmm1
jne    1215 <vec2pix_ring+0xb5>
jp     1215 <vec2pix_ring+0xb5>
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm0
jne    1215 <vec2pix_ring+0xb5>
jnp    1236 <vec2pix_ring+0xd6>
call   1030 <atan2@plt>
movapd %xmm0,%xmm3
xorpd  %xmm0,%xmm0
ucomisd %xmm3,%xmm0
jbe    1236 <vec2pix_ring+0xd6>
movsd  0x8(%rsp),%xmm0
addsd  %xmm0,%xmm0
addsd  %xmm0,%xmm3
divsd  0x10(%rsp),%xmm3
movapd 0xdec(%rip),%xmm2
movapd 0x20(%rsp),%xmm1
andpd  %xmm1,%xmm2
movsd  0xdb2(%rip),%xmm0
ucomisd %xmm2,%xmm0
jae    1353 <vec2pix_ring+0x1f3>
cvttsd2si %xmm3,%rdi
movsd  %xmm3,0x10(%rsp)
movapd %xmm2,0x30(%rsp)
call   1080 <floor@plt>
movsd  0x10(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0xd8a(%rip),%xmm0
subsd  0x30(%rsp),%xmm0
mulsd  0xd84(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1060 <sqrt@plt>
movsd  %xmm0,0x30(%rsp)
xorps  %xmm2,%xmm2
cvtsi2sd %r15,%xmm2
movsd  %xmm2,0x40(%rsp)
movsd  0x8(%rsp),%xmm1
mulsd  %xmm2,%xmm1
mulsd  %xmm0,%xmm1
cvttsd2si %xmm1,%rdi
call   1080 <floor@plt>
cvttsd2si %xmm0,%ebx
movsd  0xd3b(%rip),%xmm0
subsd  0x8(%rsp),%xmm0
mulsd  0x40(%rsp),%xmm0
mulsd  0x30(%rsp),%xmm0
cvttsd2si %xmm0,%rdi
call   1080 <floor@plt>
cvttsd2si %xmm0,%eax
lea    (%rax,%rbx,1),%ecx
add    $0x1,%ecx
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
add    %eax,%ebx
mulsd  0x10(%rsp),%xmm0
cvttsd2si %xmm0,%rdi
call   1080 <floor@plt>
cvttsd2si %xmm0,%eax
lea    0x4(,%rbx,4),%ecx
xor    %edx,%edx
cmp    %eax,%ecx
cmovle %ecx,%edx
lea    (%rbx,%rbx,1),%ecx
add    $0x2,%ecx
xorpd  %xmm0,%xmm0
ucomisd 0x20(%rsp),%xmm0
jae    141e <vec2pix_ring+0x2be>
sub    %edx,%eax
imul   %ebx,%ecx
add    %ecx,%eax
add    $0x1,%eax
jmp    143f <vec2pix_ring+0x2df>
lea    0x0(,%r15,4),%r13d
lea    -0x1(%r15),%r12d
imul   %r15d,%r12d
xorps  %xmm2,%xmm2
cvtsi2sd %r15,%xmm2
movsd  %xmm2,0x8(%rsp)
addsd  0xc87(%rip),%xmm3
movsd  %xmm3,0x10(%rsp)
mulsd  0xc89(%rip),%xmm1
movapd %xmm1,0x20(%rsp)
subsd  %xmm1,%xmm3
mulsd  %xmm2,%xmm3
cvttsd2si %xmm3,%rdi
call   1080 <floor@plt>
cvttsd2si %xmm0,%ebp
movapd 0x20(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
mulsd  0x8(%rsp),%xmm0
cvttsd2si %xmm0,%rdi
call   1080 <floor@plt>
cvttsd2si %xmm0,%r14d
lea    (%r15,%rbp,1),%ebx
sub    %r14d,%ebx
lea    0x1(%rbx),%edi
mov    $0x2,%esi
call   1040 <fmod@plt>
add    %ebp,%r14d
movslq %r14d,%rcx
sub    %r15,%rcx
cmp    $0x1,%eax
adc    $0x0,%rcx
lea    0x1(%rcx),%rax
shr    $0x3f,%rax
lea    (%rcx,%rax,1),%rdi
add    $0x1,%rdi
sar    %rdi
call   1080 <floor@plt>
cvttsd2si %xmm0,%eax
xor    %ecx,%ecx
cmp    %eax,%r13d
cmovle %r13d,%ecx
imul   %r13d,%ebx
lea    (%rax,%r12,2),%eax
add    %ebx,%eax
sub    %ecx,%eax
add    $0x1,%eax
jmp    143f <vec2pix_ring+0x2df>
imul   %r15d,%r15d
shl    $0x2,%r15d
lea    (%r15,%r15,2),%esi
neg    %edx
add    %eax,%edx
add    $0x1,%edx
mov    $0xfffffffe,%eax
sub    %ebx,%eax
imul   %ecx,%eax
add    %esi,%eax
add    %edx,%eax
mov    0x18(%rsp),%rcx
add    $0xffffffff,%eax
cltq
mov    %rax,(%rcx)
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2b76(%rip),%rax
mov    (%rax),%edi
lea    0xbd5(%rip),%rsi
lea    0xbf0(%rip),%rdx
mov    $0x37,%ecx
mov    %r15,%r8
call   1050 <fprintf@plt>
xor    %edi,%edi
call   1070 <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/vec2pix_ring.c\00"
define void @vec2pix_ring(i64 %0, double* %1, i64* %2) {
%4 = alloca i64
%5 = alloca double*
%6 = alloca i64*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca double
%24 = alloca double
%25 = alloca double
%26 = alloca i64
store i64 %0, i64* %4
store double* %1, double** %5
store i64* %2, i64** %6
%27 = load double, double* @M_PI
%28 = fmul double 5.000000e-01, %27
store double %28, double* %23
%29 = load double, double* @M_PI
%30 = fmul double 2.000000e+00, %29
store double %30, double* %24
store double 0x3FE5555555555555, double* %25
store i64 8192, i64* %26
%31 = load i64, i64* %4
%32 = icmp slt i64 %31, 1
br i1 %32, label %37, label %33
33: ; preds = %3
%34 = load i64, i64* %4
%35 = load i64, i64* %26
%36 = icmp sgt i64 %34, %35
br i1 %36, label %37, label %42
37: ; preds = %33, %3
%38 = load i32, i32* @stderr
%39 = load i64, i64* %4
%40 = call i32 @fprintf(i32 %38, 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 55, i64 %39)
%41 = call i32 @exit(i32 0)
unreachable
42: ; preds = %33
%43 = load double*, double** %5
%44 = getelementptr inbounds double, double* %43, i64 2
%45 = load double, double* %44
%46 = load double*, double** %5
%47 = getelementptr inbounds double, double* %46, i64 0
%48 = load double, double* %47
%49 = load double*, double** %5
%50 = getelementptr inbounds double, double* %49, i64 0
%51 = load double, double* %50
%52 = load double*, double** %5
%53 = getelementptr inbounds double, double* %52, i64 1
%54 = load double, double* %53
%55 = load double*, double** %5
%56 = getelementptr inbounds double, double* %55, i64 1
%57 = load double, double* %56
%58 = fmul double %54, %57
%59 = call double @llvm.fmuladd.f64(double %48, double %51, double %58)
%60 = load double*, double** %5
%61 = getelementptr inbounds double, double* %60, i64 2
%62 = load double, double* %61
%63 = load double*, double** %5
%64 = getelementptr inbounds double, double* %63, i64 2
%65 = load double, double* %64
%66 = call double @llvm.fmuladd.f64(double %62, double %65, double %59)
%67 = fptosi double %66 to i32
%68 = call double @sqrt(i32 %67)
%69 = fdiv double %45, %68
store double %69, double* %14
store double 0.000000e+00, double* %19
%70 = load double*, double** %5
%71 = getelementptr inbounds double, double* %70, i64 0
%72 = load double, double* %71
%73 = fcmp une double %72, 0.000000e+00
br i1 %73, label %79, label %74
74: ; preds = %42
%75 = load double*, double** %5
%76 = getelementptr inbounds double, double* %75, i64 1
%77 = load double, double* %76
%78 = fcmp une double %77, 0.000000e+00
br i1 %78, label %79, label %94
79: ; preds = %74, %42
%80 = load double*, double** %5
%81 = getelementptr inbounds double, double* %80, i64 1
%82 = load double, double* %81
%83 = load double*, double** %5
%84 = getelementptr inbounds double, double* %83, i64 0
%85 = load double, double* %84
%86 = call double @atan2(double %82, double %85)
store double %86, double* %19
%87 = load double, double* %19
%88 = fcmp olt double %87, 0.000000e+00
br i1 %88, label %89, label %93
89: ; preds = %79
%90 = load double, double* %24
%91 = load double, double* %19
%92 = fadd double %91, %90
store double %92, double* %19
br label %93
93: ; preds = %89, %79
br label %94
94: ; preds = %93, %74
%95 = load double, double* %14
%96 = call double @llvm.fabs.f64(double %95)
store double %96, double* %15
%97 = load double, double* %19
%98 = load double, double* %23
%99 = fdiv double %97, %98
store double %99, double* %16
%100 = load i64, i64* %4
%101 = mul nsw i64 2, %100
%102 = trunc i64 %101 to i32
store i32 %102, i32* %7
%103 = load i64, i64* %4
%104 = mul nsw i64 4, %103
%105 = trunc i64 %104 to i32
store i32 %105, i32* %8
%106 = load i32, i32* %7
%107 = sext i32 %106 to i64
%108 = load i64, i64* %4
%109 = sub nsw i64 %108, 1
%110 = mul nsw i64 %107, %109
%111 = trunc i64 %110 to i32
store i32 %111, i32* %9
%112 = load i64, i64* %4
%113 = mul nsw i64 12, %112
%114 = load i64, i64* %4
%115 = mul nsw i64 %113, %114
%116 = trunc i64 %115 to i32
store i32 %116, i32* %10
%117 = load double, double* %15
%118 = load double, double* %25
%119 = fcmp ole double %117, %118
br i1 %119, label %120, label %187
120: ; preds = %94
%121 = load i64, i64* %4
%122 = sitofp i64 %121 to double
%123 = load double, double* %16
%124 = fadd double 5.000000e-01, %123
%125 = load double, double* %14
%126 = fneg double %125
%127 = call double @llvm.fmuladd.f64(double %126, double 7.500000e-01, double %124)
%128 = fmul double %122, %127
%129 = fptosi double %128 to i64
%130 = call double @floor(i64 %129)
%131 = fptosi double %130 to i32
store i32 %131, i32* %11
%132 = load i64, i64* %4
%133 = sitofp i64 %132 to double
%134 = load double, double* %16
%135 = fadd double 5.000000e-01, %134
%136 = load double, double* %14
%137 = call double @llvm.fmuladd.f64(double %136, double 7.500000e-01, double %135)
%138 = fmul double %133, %137
%139 = fptosi double %138 to i64
%140 = call double @floor(i64 %139)
%141 = fptosi double %140 to i32
store i32 %141, i32* %12
%142 = load i64, i64* %4
%143 = add nsw i64 %142, 1
%144 = load i32, i32* %11
%145 = sext i32 %144 to i64
%146 = add nsw i64 %143, %145
%147 = load i32, i32* %12
%148 = sext i32 %147 to i64
%149 = sub nsw i64 %146, %148
%150 = trunc i64 %149 to i32
store i32 %150, i32* %20
store i32 0, i32* %22
%151 = load i32, i32* %20
%152 = call i32 @fmod(i32 %151, i32 2)
%153 = sitofp i32 %152 to double
%154 = fcmp oeq double %153, 0.000000e+00
br i1 %154, label %155, label %156
155: ; preds = %120
store i32 1, i32* %22
br label %156
156: ; preds = %155, %120
%157 = load i32, i32* %11
%158 = load i32, i32* %12
%159 = add nsw i32 %157, %158
%160 = sext i32 %159 to i64
%161 = load i64, i64* %4
%162 = sub nsw i64 %160, %161
%163 = load i32, i32* %22
%164 = sext i32 %163 to i64
%165 = add nsw i64 %162, %164
%166 = add nsw i64 %165, 1
%167 = sdiv i64 %166, 2
%168 = call double @floor(i64 %167)
%169 = fptosi double %168 to i32
%170 = add nsw i32 %169, 1
store i32 %170, i32* %21
%171 = load i32, i32* %21
%172 = load i32, i32* %8
%173 = icmp sgt i32 %171, %172
br i1 %173, label %174, label %178
174: ; preds = %156
%175 = load i32, i32* %21
%176 = load i32, i32* %8
%177 = sub nsw i32 %175, %176
store i32 %177, i32* %21
br label %178
178: ; preds = %174, %156
%179 = load i32, i32* %9
%180 = load i32, i32* %8
%181 = load i32, i32* %20
%182 = sub nsw i32 %181, 1
%183 = mul nsw i32 %180, %182
%184 = add nsw i32 %179, %183
%185 = load i32, i32* %21
%186 = add nsw i32 %184, %185
store i32 %186, i32* %13
br label %259
187: ; preds = %94
%188 = load double, double* %16
%189 = load double, double* %16
%190 = fptosi double %189 to i64
%191 = call double @floor(i64 %190)
%192 = fsub double %188, %191
store double %192, double* %17
%193 = load double, double* %15
%194 = fsub double 1.000000e+00, %193
%195 = fmul double 3.000000e+00, %194
%196 = fptosi double %195 to i32
%197 = call double @sqrt(i32 %196)
store double %197, double* %18
%198 = load i64, i64* %4
%199 = sitofp i64 %198 to double
%200 = load double, double* %17
%201 = fmul double %199, %200
%202 = load double, double* %18
%203 = fmul double %201, %202
%204 = fptosi double %203 to i64
%205 = call double @floor(i64 %204)
%206 = fptosi double %205 to i32
store i32 %206, i32* %11
%207 = load i64, i64* %4
%208 = sitofp i64 %207 to double
%209 = load double, double* %17
%210 = fsub double 1.000000e+00, %209
%211 = fmul double %208, %210
%212 = load double, double* %18
%213 = fmul double %211, %212
%214 = fptosi double %213 to i64
%215 = call double @floor(i64 %214)
%216 = fptosi double %215 to i32
store i32 %216, i32* %12
%217 = load i32, i32* %11
%218 = load i32, i32* %12
%219 = add nsw i32 %217, %218
%220 = add nsw i32 %219, 1
store i32 %220, i32* %20
%221 = load double, double* %16
%222 = load i32, i32* %20
%223 = sitofp i32 %222 to double
%224 = fmul double %221, %223
%225 = fptosi double %224 to i64
%226 = call double @floor(i64 %225)
%227 = fptosi double %226 to i32
%228 = add nsw i32 %227, 1
store i32 %228, i32* %21
%229 = load i32, i32* %21
%230 = load i32, i32* %20
%231 = mul nsw i32 4, %230
%232 = icmp sgt i32 %229, %231
br i1 %232, label %233, label %238
233: ; preds = %187
%234 = load i32, i32* %21
%235 = load i32, i32* %20
%236 = mul nsw i32 4, %235
%237 = sub nsw i32 %234, %236
store i32 %237, i32* %21
br label %238
238: ; preds = %233, %187
%239 = load i32, i32* %20
%240 = mul nsw i32 2, %239
%241 = load i32, i32* %20
%242 = sub nsw i32 %241, 1
%243 = mul nsw i32 %240, %242
%244 = load i32, i32* %21
%245 = add nsw i32 %243, %244
store i32 %245, i32* %13
%246 = load double, double* %14
%247 = fcmp ole double %246, 0.000000e+00
br i1 %247, label %248, label %258
248: ; preds = %238
%249 = load i32, i32* %10
%250 = load i32, i32* %20
%251 = mul nsw i32 2, %250
%252 = load i32, i32* %20
%253 = add nsw i32 %252, 1
%254 = mul nsw i32 %251, %253
%255 = sub nsw i32 %249, %254
%256 = load i32, i32* %21
%257 = add nsw i32 %255, %256
store i32 %257, i32* %13
br label %258
258: ; preds = %248, %238
br label %259
259: ; preds = %258, %178
%260 = load i32, i32* %13
%261 = sub nsw i32 %260, 1
%262 = sext i32 %261 to i64
%263 = load i64*, i64** %6
store i64 %262, i64* %263
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/vec2pix_ring.c\00"
define void @vec2pix_ring(i64 %0, double* nocapture %1, i64* nocapture writeonly %2) {
%4 = load double, double* @M_PI
%5 = fmul double %4, 5.000000e-01
%6 = fmul double %4, 2.000000e+00
%7 = add i64 %0, -8193
%8 = icmp ult i64 %7, -8192
br i1 %8, label %9, label %13
9: ; preds = %3
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, 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 55, i64 %0)
%12 = tail call i32 @exit(i32 0)
unreachable
13: ; preds = %3
%14 = getelementptr inbounds double, double* %1, i64 2
%15 = load double, double* %14
%16 = load double, double* %1
%17 = getelementptr inbounds double, double* %1, i64 1
%18 = load double, double* %17
%19 = fmul double %18, %18
%20 = tail call double @llvm.fmuladd.f64(double %16, double %16, double %19)
%21 = tail call double @llvm.fmuladd.f64(double %15, double %15, double %20)
%22 = fptosi double %21 to i32
%23 = tail call double @sqrt(i32 %22)
%24 = fdiv double %15, %23
%25 = load double, double* %1
%26 = fcmp une double %25, 0.000000e+00
%27 = load double, double* %17
%28 = fcmp une double %27, 0.000000e+00
%29 = select i1 %26, i1 true, i1 %28
br i1 %29, label %30, label %35
30: ; preds = %13
%31 = tail call double @atan2(double %27, double %25)
%32 = fcmp olt double %31, 0.000000e+00
br i1 %32, label %33, label %35
33: ; preds = %30
%34 = fadd double %6, %31
br label %35
35: ; preds = %13, %30, %33
%36 = phi double [ %34, %33 ], [ %31, %30 ], [ 0.000000e+00, %13 ]
%37 = tail call double @llvm.fabs.f64(double %24)
%38 = fdiv double %36, %5
%39 = trunc i64 %0 to i32
%40 = shl nuw nsw i32 %39, 2
%41 = mul nuw nsw i64 %0, 12
%42 = mul nuw nsw i64 %41, %0
%43 = trunc i64 %42 to i32
%44 = fcmp ugt double %37, 0x3FE5555555555555
br i1 %44, label %86, label %45
45: ; preds = %35
%46 = shl nuw nsw i64 %0, 1
%47 = and i64 %46, 4294967294
%48 = add nsw i64 %0, -1
%49 = mul nuw nsw i64 %47, %48
%50 = trunc i64 %49 to i32
%51 = sitofp i64 %0 to double
%52 = fadd double %38, 5.000000e-01
%53 = fneg double %24
%54 = tail call double @llvm.fmuladd.f64(double %53, double 7.500000e-01, double %52)
%55 = fmul double %54, %51
%56 = fptosi double %55 to i64
%57 = tail call double @floor(i64 %56)
%58 = fptosi double %57 to i32
%59 = tail call double @llvm.fmuladd.f64(double %24, double 7.500000e-01, double %52)
%60 = fmul double %59, %51
%61 = fptosi double %60 to i64
%62 = tail call double @floor(i64 %61)
%63 = fptosi double %62 to i32
%64 = add nuw nsw i32 %39, 1
%65 = add i32 %64, %58
%66 = sub i32 %65, %63
%67 = tail call i32 @fmod(i32 %66, i32 2)
%68 = icmp eq i32 %67, 0
%69 = zext i1 %68 to i64
%70 = add nsw i32 %63, %58
%71 = sext i32 %70 to i64
%72 = sub nsw i64 1, %0
%73 = add nsw i64 %72, %71
%74 = add nsw i64 %73, %69
%75 = sdiv i64 %74, 2
%76 = tail call double @floor(i64 %75)
%77 = fptosi double %76 to i32
%78 = icmp sgt i32 %40, %77
%79 = select i1 %78, i32 0, i32 %40
%80 = add nsw i32 %66, -1
%81 = mul nsw i32 %80, %40
%82 = or i32 %50, 1
%83 = add i32 %82, %77
%84 = add i32 %83, %81
%85 = sub i32 %84, %79
br label %127
86: ; preds = %35
%87 = fptosi double %38 to i64
%88 = tail call double @floor(i64 %87)
%89 = fsub double %38, %88
%90 = fsub double 1.000000e+00, %37
%91 = fmul double %90, 3.000000e+00
%92 = fptosi double %91 to i32
%93 = tail call double @sqrt(i32 %92)
%94 = sitofp i64 %0 to double
%95 = fmul double %89, %94
%96 = fmul double %93, %95
%97 = fptosi double %96 to i64
%98 = tail call double @floor(i64 %97)
%99 = fptosi double %98 to i32
%100 = fsub double 1.000000e+00, %89
%101 = fmul double %100, %94
%102 = fmul double %93, %101
%103 = fptosi double %102 to i64
%104 = tail call double @floor(i64 %103)
%105 = fptosi double %104 to i32
%106 = add nsw i32 %105, %99
%107 = add nsw i32 %106, 1
%108 = sitofp i32 %107 to double
%109 = fmul double %38, %108
%110 = fptosi double %109 to i64
%111 = tail call double @floor(i64 %110)
%112 = fptosi double %111 to i32
%113 = add nsw i32 %112, 1
%114 = shl nsw i32 %107, 2
%115 = icmp sgt i32 %114, %112
%116 = select i1 %115, i32 0, i32 %114
%117 = sub i32 %113, %116
%118 = shl nsw i32 %107, 1
%119 = mul nsw i32 %118, %106
%120 = add nsw i32 %117, %119
%121 = fcmp ugt double %24, 0.000000e+00
br i1 %121, label %127, label %122
122: ; preds = %86
%123 = sub i32 -2, %106
%124 = mul i32 %123, %118
%125 = add i32 %124, %43
%126 = add nsw i32 %125, %117
br label %127
127: ; preds = %86, %122, %45
%128 = phi i32 [ %85, %45 ], [ %126, %122 ], [ %120, %86 ]
%129 = add nsw i32 %128, -1
%130 = sext i32 %129 to i64
store i64 %130, i64* %2
ret void
}