#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);
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 heal_ang2pix_ring(const long nside, double theta, double phi, long *ipix) {
  int nl2, nl4, ncap, npix, jp, jm, ipix1;
  double z, za, tt, tp, tmp;
  int ir, ip, kshift;
  double piover2 = 0.5 * M_PI;
  double PI = 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/joezuntz/cmbview/refs/heads/master/src/"
            "HEALPix sources/ang2pix_ring.c",
            60, 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/joezuntz/cmbview/refs/heads/master/src/"
            "HEALPix sources/ang2pix_ring.c",
            65, theta);
    exit(0);
  }
  z = cos(theta);
  za = fabs(z);
  if (phi >= twopi)
    phi = phi - twopi;
  if (phi < 0.)
    phi = phi + twopi;
  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):
<heal_ang2pix_ring>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
movsd  0xe8b(%rip),%xmm0
mov    0x2e5c(%rip),%rax
mulsd  (%rax),%xmm0
movsd  %xmm0,-0x80(%rbp)
mov    0x2e4c(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  0xe58(%rip),%xmm0
mov    0x2e31(%rip),%rax
mulsd  (%rax),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  0xe35(%rip),%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movq   $0x2000,-0xa0(%rbp)
cmpq   $0x1,-0x8(%rbp)
jl     11fa <heal_ang2pix_ring+0x9a>
mov    -0x8(%rbp),%rax
cmp    -0xa0(%rbp),%rax
jle    1226 <heal_ang2pix_ring+0xc6>
mov    0x2dd7(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%r8
lea    0xe32(%rip),%rsi
lea    0xe4d(%rip),%rdx
mov    $0x3c,%ecx
call   1040 <fprintf@plt>
xor    %edi,%edi
call   1070 <exit@plt>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
ja     1247 <heal_ang2pix_ring+0xe7>
movsd  -0x10(%rbp),%xmm0
ucomisd -0x88(%rbp),%xmm0
ff
jbe    1275 <heal_ang2pix_ring+0x115>
mov    0x2d8a(%rip),%rax
mov    (%rax),%edi
cvttsd2si -0x10(%rbp),%r8
lea    0xea5(%rip),%rsi
lea    0xdfe(%rip),%rdx
mov    $0x41,%ecx
call   1040 <fprintf@plt>
xor    %edi,%edi
call   1070 <exit@plt>
movsd  -0x10(%rbp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movaps 0xda0(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x18(%rbp),%xmm0
ucomisd -0x90(%rbp),%xmm0
ff
jb     12be <heal_ang2pix_ring+0x15e>
movsd  -0x18(%rbp),%xmm0
subsd  -0x90(%rbp),%xmm0
ff
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    12de <heal_ang2pix_ring+0x17e>
movsd  -0x18(%rbp),%xmm0
addsd  -0x90(%rbp),%xmm0
ff
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
divsd  -0x80(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x8(%rbp),%rax
shl    $0x1,%rax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,-0x28(%rbp)
movslq -0x24(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    $0x1,%rcx
imul   %rcx,%rax
mov    %eax,-0x2c(%rbp)
imul   $0xc,-0x8(%rbp),%rax
imul   -0x8(%rbp),%rax
mov    %eax,-0x30(%rbp)
movsd  -0x50(%rbp),%xmm1
movsd  -0x98(%rbp),%xmm0
ff
ucomisd %xmm1,%xmm0
jb     147a <heal_ang2pix_ring+0x31a>
cvtsi2sdq -0x8(%rbp),%xmm0
movsd  0xcc8(%rip),%xmm2
addsd  -0x58(%rbp),%xmm2
movsd  -0x48(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  0xcb7(%rip),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rdi
call   1080 <floor@plt>
cvttsd2si %xmm0,%eax
mov    %eax,-0x34(%rbp)
cvtsi2sdq -0x8(%rbp),%xmm0
movsd  0xc74(%rip),%xmm2
addsd  -0x58(%rbp),%xmm2
movsd  -0x48(%rbp),%xmm1
movsd  0xc7a(%rip),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rdi
call   1080 <floor@plt>
cvttsd2si %xmm0,%eax
mov    %eax,-0x38(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
movslq -0x34(%rbp),%rcx
add    %rcx,%rax
movslq -0x38(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x6c(%rbp)
movl   $0x0,-0x74(%rbp)
mov    -0x6c(%rbp),%edi
mov    $0x2,%esi
call   1030 <fmod@plt>
cvtsi2sd %eax,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1416 <heal_ang2pix_ring+0x2b6>
jp     1416 <heal_ang2pix_ring+0x2b6>
movl   $0x1,-0x74(%rbp)
mov    -0x34(%rbp),%eax
add    -0x38(%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    -0x28(%rbp),%eax
jle    145e <heal_ang2pix_ring+0x2fe>
mov    -0x70(%rbp),%eax
sub    -0x28(%rbp),%eax
mov    %eax,-0x70(%rbp)
mov    -0x2c(%rbp),%eax
mov    -0x28(%rbp),%ecx
mov    -0x6c(%rbp),%edx
sub    $0x1,%edx
imul   %edx,%ecx
add    %ecx,%eax
add    -0x70(%rbp),%eax
mov    %eax,-0x3c(%rbp)
jmp    15aa <heal_ang2pix_ring+0x44a>
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
cvttsd2si -0x58(%rbp),%rdi
call   1080 <floor@plt>
movaps %xmm0,%xmm1
movsd  -0xa8(%rbp),%xmm0
ff
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  0xb6a(%rip),%xmm1
subsd  -0x50(%rbp),%xmm1
movsd  0xb65(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1060 <sqrt@plt>
movsd  %xmm0,-0x68(%rbp)
cvtsi2sdq -0x8(%rbp),%xmm0
mulsd  -0x60(%rbp),%xmm0
mulsd  -0x68(%rbp),%xmm0
cvttsd2si %xmm0,%rdi
call   1080 <floor@plt>
cvttsd2si %xmm0,%eax
mov    %eax,-0x34(%rbp)
cvtsi2sdq -0x8(%rbp),%xmm0
movsd  0xb1c(%rip),%xmm1
subsd  -0x60(%rbp),%xmm1
mulsd  %xmm1,%xmm0
mulsd  -0x68(%rbp),%xmm0
cvttsd2si %xmm0,%rdi
call   1080 <floor@plt>
cvttsd2si %xmm0,%eax
mov    %eax,-0x38(%rbp)
mov    -0x34(%rbp),%eax
add    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
movsd  -0x58(%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    1568 <heal_ang2pix_ring+0x408>
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,-0x3c(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x48(%rbp),%xmm0
jb     15a5 <heal_ang2pix_ring+0x445>
mov    -0x30(%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,-0x3c(%rbp)
jmp    15aa <heal_ang2pix_ring+0x44a>
mov    -0x3c(%rbp),%eax
sub    $0x1,%eax
movslq %eax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<heal_ang2pix_ring>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rdi,%rbx
lea    -0x2001(%rdi),%rax
cmp    $0xffffffffffffdfff,%rax
jbe    1433 <heal_ang2pix_ring+0x2d3>
movsd  %xmm1,0x10(%rsp)
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
ja     1454 <heal_ang2pix_ring+0x2f4>
mov    0x2e49(%rip),%rax
movsd  (%rax),%xmm1
ucomisd %xmm1,%xmm0
ja     1454 <heal_ang2pix_ring+0x2f4>
mov    %rsi,0x50(%rsp)
movsd  0xe46(%rip),%xmm2
mulsd  %xmm1,%xmm2
movsd  %xmm2,0x20(%rsp)
addsd  %xmm1,%xmm1
movapd %xmm1,(%rsp)
call   1050 <cos@plt>
movapd 0xe66(%rip),%xmm4
andpd  %xmm0,%xmm4
movapd (%rsp),%xmm5
movapd %xmm5,%xmm1
movsd  0x10(%rsp),%xmm3
cmpnlesd %xmm3,%xmm1
andnpd %xmm5,%xmm1
subsd  %xmm1,%xmm3
xorpd  %xmm1,%xmm1
movapd %xmm3,%xmm2
cmpltsd %xmm1,%xmm2
andpd  %xmm2,%xmm5
movsd  0xdf5(%rip),%xmm1
andnpd %xmm1,%xmm2
orpd   %xmm5,%xmm2
addsd  %xmm3,%xmm2
divsd  0x20(%rsp),%xmm2
movsd  0xde3(%rip),%xmm1
ucomisd %xmm4,%xmm1
jae    132b <heal_ang2pix_ring+0x1cb>
cvttsd2si %xmm2,%rdi
movapd %xmm0,0x20(%rsp)
movapd %xmm2,0x10(%rsp)
movapd %xmm4,0x30(%rsp)
call   1080 <floor@plt>
movapd 0x10(%rsp),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,(%rsp)
movsd  0xdb6(%rip),%xmm0
subsd  0x30(%rsp),%xmm0
mulsd  0xdb0(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1060 <sqrt@plt>
movsd  %xmm0,0x30(%rsp)
xorps  %xmm2,%xmm2
cvtsi2sd %rbx,%xmm2
movsd  %xmm2,0x48(%rsp)
movapd (%rsp),%xmm1
mulsd  %xmm2,%xmm1
mulsd  %xmm0,%xmm1
cvttsd2si %xmm1,%rdi
call   1080 <floor@plt>
cvttsd2si %xmm0,%ebp
movsd  0xd68(%rip),%xmm0
subsd  (%rsp),%xmm0
mulsd  0x48(%rsp),%xmm0
mulsd  0x30(%rsp),%xmm0
cvttsd2si %xmm0,%rdi
call   1080 <floor@plt>
cvttsd2si %xmm0,%eax
lea    (%rax,%rbp,1),%ecx
add    $0x1,%ecx
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
add    %eax,%ebp
mulsd  0x10(%rsp),%xmm0
cvttsd2si %xmm0,%rdi
call   1080 <floor@plt>
cvttsd2si %xmm0,%eax
lea    0x4(,%rbp,4),%ecx
xor    %edx,%edx
cmp    %eax,%ecx
cmovle %ecx,%edx
lea    0x2(%rbp,%rbp,1),%ecx
xorpd  %xmm0,%xmm0
ucomisd 0x20(%rsp),%xmm0
jae    13f9 <heal_ang2pix_ring+0x299>
sub    %edx,%eax
imul   %ebp,%ecx
add    %ecx,%eax
add    $0x1,%eax
jmp    1417 <heal_ang2pix_ring+0x2b7>
lea    0x0(,%rbx,4),%r12d
lea    -0x1(%rbx),%r15d
imul   %ebx,%r15d
xorps  %xmm3,%xmm3
cvtsi2sd %rbx,%xmm3
movsd  %xmm3,(%rsp)
addsd  0xcb0(%rip),%xmm2
movapd %xmm2,0x10(%rsp)
mulsd  0xcba(%rip),%xmm0
movapd %xmm0,0x20(%rsp)
movapd %xmm2,%xmm1
subsd  %xmm0,%xmm1
mulsd  %xmm3,%xmm1
cvttsd2si %xmm1,%rdi
call   1080 <floor@plt>
cvttsd2si %xmm0,%r13d
movapd 0x20(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
mulsd  (%rsp),%xmm0
cvttsd2si %xmm0,%rdi
call   1080 <floor@plt>
cvttsd2si %xmm0,%r14d
lea    (%rbx,%r13,1),%ebp
sub    %r14d,%ebp
lea    0x1(%rbp),%edi
mov    $0x2,%esi
call   1030 <fmod@plt>
add    %r13d,%r14d
movslq %r14d,%rcx
sub    %rbx,%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,%r12d
cmovle %r12d,%ecx
imul   %r12d,%ebp
lea    (%rax,%r15,2),%eax
add    %ebp,%eax
sub    %ecx,%eax
add    $0x1,%eax
jmp    1417 <heal_ang2pix_ring+0x2b7>
imul   %ebx,%ebx
shl    $0x2,%ebx
lea    (%rbx,%rbx,2),%esi
neg    %edx
add    %eax,%edx
add    $0x1,%edx
mov    $0xfffffffe,%eax
sub    %ebp,%eax
imul   %ecx,%eax
add    %esi,%eax
add    %edx,%eax
add    $0xffffffff,%eax
cltq
mov    0x50(%rsp),%rcx
mov    %rax,(%rcx)
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2b9e(%rip),%rax
mov    (%rax),%edi
lea    0xc0d(%rip),%rsi
lea    0xc28(%rip),%rdx
mov    $0x3c,%ecx
mov    %rbx,%r8
jmp    1475 <heal_ang2pix_ring+0x315>
mov    0x2b7d(%rip),%rax
mov    (%rax),%edi
cvttsd2si %xmm0,%r8
lea    0xca9(%rip),%rsi
lea    0xc02(%rip),%rdx
mov    $0x41,%ecx
call   1040 <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 = [160 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/joezuntz/cmbview/refs/heads/master/src/HEALPix sources/ang2pix_ring.c\00"
@.str.2 = [33 x i8] c"%s (%d): theta out of range: %f\0A\00"
define void @heal_ang2pix_ring(i64 %0, double %1, double %2, i64* %3) {
%5 = alloca i64
%6 = alloca double
%7 = alloca double
%8 = alloca i64*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca double
%25 = alloca double
%26 = alloca double
%27 = alloca double
%28 = alloca i64
store i64 %0, i64* %5
store double %1, double* %6
store double %2, double* %7
store i64* %3, i64** %8
%29 = load double, double* @M_PI
%30 = fmul double 5.000000e-01, %29
store double %30, double* %24
%31 = load double, double* @M_PI
store double %31, double* %25
%32 = load double, double* @M_PI
%33 = fmul double 2.000000e+00, %32
store double %33, double* %26
store double 0x3FE5555555555555, double* %27
store i64 8192, i64* %28
%34 = load i64, i64* %5
%35 = icmp slt i64 %34, 1
br i1 %35, label %40, label %36
36: ; preds = %4
%37 = load i64, i64* %5
%38 = load i64, i64* %28
%39 = icmp sgt i64 %37, %38
br i1 %39, label %40, label %45
40: ; preds = %36, %4
%41 = load i32, i32* @stderr
%42 = load i64, i64* %5
%43 = call i32 @fprintf(i32 %41, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([160 x i8], [160 x i8]* @.str.1, i64 0, i64 0), i32 60, i64 %42)
%44 = call i32 @exit(i32 0)
unreachable
45: ; preds = %36
%46 = load double, double* %6
%47 = fcmp olt double %46, 0.000000e+00
br i1 %47, label %52, label %48
48: ; preds = %45
%49 = load double, double* %6
%50 = load double, double* %25
%51 = fcmp ogt double %49, %50
br i1 %51, label %52, label %58
52: ; preds = %48, %45
%53 = load i32, i32* @stderr
%54 = load double, double* %6
%55 = fptosi double %54 to i64
%56 = call i32 @fprintf(i32 %53, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([160 x i8], [160 x i8]* @.str.1, i64 0, i64 0), i32 65, i64 %55)
%57 = call i32 @exit(i32 0)
unreachable
58: ; preds = %48
%59 = load double, double* %6
%60 = call double @cos(double %59)
store double %60, double* %16
%61 = load double, double* %16
%62 = call double @llvm.fabs.f64(double %61)
store double %62, double* %17
%63 = load double, double* %7
%64 = load double, double* %26
%65 = fcmp oge double %63, %64
br i1 %65, label %66, label %70
66: ; preds = %58
%67 = load double, double* %7
%68 = load double, double* %26
%69 = fsub double %67, %68
store double %69, double* %7
br label %70
70: ; preds = %66, %58
%71 = load double, double* %7
%72 = fcmp olt double %71, 0.000000e+00
br i1 %72, label %73, label %77
73: ; preds = %70
%74 = load double, double* %7
%75 = load double, double* %26
%76 = fadd double %74, %75
store double %76, double* %7
br label %77
77: ; preds = %73, %70
%78 = load double, double* %7
%79 = load double, double* %24
%80 = fdiv double %78, %79
store double %80, double* %18
%81 = load i64, i64* %5
%82 = mul nsw i64 2, %81
%83 = trunc i64 %82 to i32
store i32 %83, i32* %9
%84 = load i64, i64* %5
%85 = mul nsw i64 4, %84
%86 = trunc i64 %85 to i32
store i32 %86, i32* %10
%87 = load i32, i32* %9
%88 = sext i32 %87 to i64
%89 = load i64, i64* %5
%90 = sub nsw i64 %89, 1
%91 = mul nsw i64 %88, %90
%92 = trunc i64 %91 to i32
store i32 %92, i32* %11
%93 = load i64, i64* %5
%94 = mul nsw i64 12, %93
%95 = load i64, i64* %5
%96 = mul nsw i64 %94, %95
%97 = trunc i64 %96 to i32
store i32 %97, i32* %12
%98 = load double, double* %17
%99 = load double, double* %27
%100 = fcmp ole double %98, %99
br i1 %100, label %101, label %168
101: ; preds = %77
%102 = load i64, i64* %5
%103 = sitofp i64 %102 to double
%104 = load double, double* %18
%105 = fadd double 5.000000e-01, %104
%106 = load double, double* %16
%107 = fneg double %106
%108 = call double @llvm.fmuladd.f64(double %107, double 7.500000e-01, double %105)
%109 = fmul double %103, %108
%110 = fptosi double %109 to i64
%111 = call double @floor(i64 %110)
%112 = fptosi double %111 to i32
store i32 %112, i32* %13
%113 = load i64, i64* %5
%114 = sitofp i64 %113 to double
%115 = load double, double* %18
%116 = fadd double 5.000000e-01, %115
%117 = load double, double* %16
%118 = call double @llvm.fmuladd.f64(double %117, double 7.500000e-01, double %116)
%119 = fmul double %114, %118
%120 = fptosi double %119 to i64
%121 = call double @floor(i64 %120)
%122 = fptosi double %121 to i32
store i32 %122, i32* %14
%123 = load i64, i64* %5
%124 = add nsw i64 %123, 1
%125 = load i32, i32* %13
%126 = sext i32 %125 to i64
%127 = add nsw i64 %124, %126
%128 = load i32, i32* %14
%129 = sext i32 %128 to i64
%130 = sub nsw i64 %127, %129
%131 = trunc i64 %130 to i32
store i32 %131, i32* %21
store i32 0, i32* %23
%132 = load i32, i32* %21
%133 = call i32 @fmod(i32 %132, i32 2)
%134 = sitofp i32 %133 to double
%135 = fcmp oeq double %134, 0.000000e+00
br i1 %135, label %136, label %137
136: ; preds = %101
store i32 1, i32* %23
br label %137
137: ; preds = %136, %101
%138 = load i32, i32* %13
%139 = load i32, i32* %14
%140 = add nsw i32 %138, %139
%141 = sext i32 %140 to i64
%142 = load i64, i64* %5
%143 = sub nsw i64 %141, %142
%144 = load i32, i32* %23
%145 = sext i32 %144 to i64
%146 = add nsw i64 %143, %145
%147 = add nsw i64 %146, 1
%148 = sdiv i64 %147, 2
%149 = call double @floor(i64 %148)
%150 = fptosi double %149 to i32
%151 = add nsw i32 %150, 1
store i32 %151, i32* %22
%152 = load i32, i32* %22
%153 = load i32, i32* %10
%154 = icmp sgt i32 %152, %153
br i1 %154, label %155, label %159
155: ; preds = %137
%156 = load i32, i32* %22
%157 = load i32, i32* %10
%158 = sub nsw i32 %156, %157
store i32 %158, i32* %22
br label %159
159: ; preds = %155, %137
%160 = load i32, i32* %11
%161 = load i32, i32* %10
%162 = load i32, i32* %21
%163 = sub nsw i32 %162, 1
%164 = mul nsw i32 %161, %163
%165 = add nsw i32 %160, %164
%166 = load i32, i32* %22
%167 = add nsw i32 %165, %166
store i32 %167, i32* %15
br label %240
168: ; preds = %77
%169 = load double, double* %18
%170 = load double, double* %18
%171 = fptosi double %170 to i64
%172 = call double @floor(i64 %171)
%173 = fsub double %169, %172
store double %173, double* %19
%174 = load double, double* %17
%175 = fsub double 1.000000e+00, %174
%176 = fmul double 3.000000e+00, %175
%177 = fptosi double %176 to i32
%178 = call double @sqrt(i32 %177)
store double %178, double* %20
%179 = load i64, i64* %5
%180 = sitofp i64 %179 to double
%181 = load double, double* %19
%182 = fmul double %180, %181
%183 = load double, double* %20
%184 = fmul double %182, %183
%185 = fptosi double %184 to i64
%186 = call double @floor(i64 %185)
%187 = fptosi double %186 to i32
store i32 %187, i32* %13
%188 = load i64, i64* %5
%189 = sitofp i64 %188 to double
%190 = load double, double* %19
%191 = fsub double 1.000000e+00, %190
%192 = fmul double %189, %191
%193 = load double, double* %20
%194 = fmul double %192, %193
%195 = fptosi double %194 to i64
%196 = call double @floor(i64 %195)
%197 = fptosi double %196 to i32
store i32 %197, i32* %14
%198 = load i32, i32* %13
%199 = load i32, i32* %14
%200 = add nsw i32 %198, %199
%201 = add nsw i32 %200, 1
store i32 %201, i32* %21
%202 = load double, double* %18
%203 = load i32, i32* %21
%204 = sitofp i32 %203 to double
%205 = fmul double %202, %204
%206 = fptosi double %205 to i64
%207 = call double @floor(i64 %206)
%208 = fptosi double %207 to i32
%209 = add nsw i32 %208, 1
store i32 %209, i32* %22
%210 = load i32, i32* %22
%211 = load i32, i32* %21
%212 = mul nsw i32 4, %211
%213 = icmp sgt i32 %210, %212
br i1 %213, label %214, label %219
214: ; preds = %168
%215 = load i32, i32* %22
%216 = load i32, i32* %21
%217 = mul nsw i32 4, %216
%218 = sub nsw i32 %215, %217
store i32 %218, i32* %22
br label %219
219: ; preds = %214, %168
%220 = load i32, i32* %21
%221 = mul nsw i32 2, %220
%222 = load i32, i32* %21
%223 = sub nsw i32 %222, 1
%224 = mul nsw i32 %221, %223
%225 = load i32, i32* %22
%226 = add nsw i32 %224, %225
store i32 %226, i32* %15
%227 = load double, double* %16
%228 = fcmp ole double %227, 0.000000e+00
br i1 %228, label %229, label %239
229: ; preds = %219
%230 = load i32, i32* %12
%231 = load i32, i32* %21
%232 = mul nsw i32 2, %231
%233 = load i32, i32* %21
%234 = add nsw i32 %233, 1
%235 = mul nsw i32 %232, %234
%236 = sub nsw i32 %230, %235
%237 = load i32, i32* %22
%238 = add nsw i32 %236, %237
store i32 %238, i32* %15
br label %239
239: ; preds = %229, %219
br label %240
240: ; preds = %239, %159
%241 = load i32, i32* %15
%242 = sub nsw i32 %241, 1
%243 = sext i32 %242 to i64
%244 = load i64*, i64** %8
store i64 %243, i64* %244
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 = [160 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/joezuntz/cmbview/refs/heads/master/src/HEALPix sources/ang2pix_ring.c\00"
@.str.2 = [33 x i8] c"%s (%d): theta out of range: %f\0A\00"
define void @heal_ang2pix_ring(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 ([160 x i8], [160 x i8]* @.str.1, i64 0, i64 0), i32 60, 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 ([160 x i8], [160 x i8]* @.str.1, i64 0, i64 0), i32 65, i64 %20)
%22 = tail call i32 @exit(i32 0)
unreachable
23: ; preds = %14
%24 = tail call double @cos(double %1)
%25 = tail call double @llvm.fabs.f64(double %24)
%26 = fcmp ugt double %7, %2
%27 = select i1 %26, double 0.000000e+00, double %7
%28 = fsub double %2, %27
%29 = fcmp olt double %28, 0.000000e+00
%30 = select i1 %29, double %7, double -0.000000e+00
%31 = fadd double %28, %30
%32 = fdiv double %31, %6
%33 = trunc i64 %0 to i32
%34 = shl nuw nsw i32 %33, 2
%35 = mul nuw nsw i64 %0, 12
%36 = mul nuw nsw i64 %35, %0
%37 = trunc i64 %36 to i32
%38 = fcmp ugt double %25, 0x3FE5555555555555
br i1 %38, label %80, label %39
39: ; preds = %23
%40 = shl nuw nsw i64 %0, 1
%41 = and i64 %40, 4294967294
%42 = add nsw i64 %0, -1
%43 = mul nuw nsw i64 %41, %42
%44 = trunc i64 %43 to i32
%45 = sitofp i64 %0 to double
%46 = fadd double %32, 5.000000e-01
%47 = fneg double %24
%48 = tail call double @llvm.fmuladd.f64(double %47, double 7.500000e-01, double %46)
%49 = fmul double %48, %45
%50 = fptosi double %49 to i64
%51 = tail call double @floor(i64 %50)
%52 = fptosi double %51 to i32
%53 = tail call double @llvm.fmuladd.f64(double %24, double 7.500000e-01, double %46)
%54 = fmul double %53, %45
%55 = fptosi double %54 to i64
%56 = tail call double @floor(i64 %55)
%57 = fptosi double %56 to i32
%58 = add nuw nsw i32 %33, 1
%59 = add i32 %58, %52
%60 = sub i32 %59, %57
%61 = tail call i32 @fmod(i32 %60, i32 2)
%62 = icmp eq i32 %61, 0
%63 = zext i1 %62 to i64
%64 = add nsw i32 %57, %52
%65 = sext i32 %64 to i64
%66 = sub nsw i64 1, %0
%67 = add nsw i64 %66, %65
%68 = add nsw i64 %67, %63
%69 = sdiv i64 %68, 2
%70 = tail call double @floor(i64 %69)
%71 = fptosi double %70 to i32
%72 = icmp sgt i32 %34, %71
%73 = select i1 %72, i32 0, i32 %34
%74 = add nsw i32 %60, -1
%75 = mul nsw i32 %74, %34
%76 = or i32 %44, 1
%77 = add i32 %76, %71
%78 = add i32 %77, %75
%79 = sub i32 %78, %73
br label %121
80: ; preds = %23
%81 = fptosi double %32 to i64
%82 = tail call double @floor(i64 %81)
%83 = fsub double %32, %82
%84 = fsub double 1.000000e+00, %25
%85 = fmul double %84, 3.000000e+00
%86 = fptosi double %85 to i32
%87 = tail call double @sqrt(i32 %86)
%88 = sitofp i64 %0 to double
%89 = fmul double %83, %88
%90 = fmul double %87, %89
%91 = fptosi double %90 to i64
%92 = tail call double @floor(i64 %91)
%93 = fptosi double %92 to i32
%94 = fsub double 1.000000e+00, %83
%95 = fmul double %94, %88
%96 = fmul double %87, %95
%97 = fptosi double %96 to i64
%98 = tail call double @floor(i64 %97)
%99 = fptosi double %98 to i32
%100 = add nsw i32 %99, %93
%101 = add nsw i32 %100, 1
%102 = sitofp i32 %101 to double
%103 = fmul double %32, %102
%104 = fptosi double %103 to i64
%105 = tail call double @floor(i64 %104)
%106 = fptosi double %105 to i32
%107 = add nsw i32 %106, 1
%108 = shl nsw i32 %101, 2
%109 = icmp sgt i32 %108, %106
%110 = select i1 %109, i32 0, i32 %108
%111 = sub i32 %107, %110
%112 = shl nsw i32 %101, 1
%113 = mul nsw i32 %112, %100
%114 = add nsw i32 %111, %113
%115 = fcmp ugt double %24, 0.000000e+00
br i1 %115, label %121, label %116
116: ; preds = %80
%117 = sub i32 -2, %100
%118 = mul i32 %117, %112
%119 = add i32 %118, %37
%120 = add nsw i32 %119, %111
br label %121
121: ; preds = %80, %116, %39
%122 = phi i32 [ %79, %39 ], [ %120, %116 ], [ %114, %80 ]
%123 = add nsw i32 %122, -1
%124 = sext i32 %123 to i64
store i64 %124, i64* %3
ret void
}