#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 fabs(double);
int floor(double);
void healpix_xy2_z_phi(const double xy[2], double *z, double *phi) {
  double x = xy[0], y = xy[1];
  double sigma, xc;
  if (fabs(y) > 3.14159265358979323846264338327950288 / 4) {
    sigma = 2 - fabs(y * 4) / 3.14159265358979323846264338327950288;
    *z = (y > 0 ? 1 : -1) * (1 - sigma * sigma / 3);
    xc = -3.14159265358979323846264338327950288 +
         (2 * floor((x + 3.14159265358979323846264338327950288) * 4 /
                    (2 * 3.14159265358979323846264338327950288)) +
          1) *
             3.14159265358979323846264338327950288 / 4;
    *phi = sigma ? (xc + (x - xc) / sigma) : x;
  } else {
    *phi = x;
    *z = y * 8 / (3.14159265358979323846264338327950288 * 3);
  }
}


x86 assembly (clang, -O0):
<healpix_xy2_z_phi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movaps 0xf05(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xea9(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1299 <healpix_xy2_z_phi+0x189>
movsd  0xeb7(%rip),%xmm1
mulsd  -0x28(%rbp),%xmm1
movaps 0xedb(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xea7(%rip),%xmm0
divsd  %xmm0,%xmm1
movsd  0xebb(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
xorps  %xmm1,%xmm1
mov    $0xffffffff,%eax
mov    $0x1,%ecx
ucomisd %xmm1,%xmm0
cmova  %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  -0x30(%rbp),%xmm2
mulsd  -0x30(%rbp),%xmm2
movsd  0xe7b(%rip),%xmm1
divsd  %xmm1,%xmm2
movsd  0xe67(%rip),%xmm1
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  0xe3f(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  0xe2a(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe2e(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <floor@plt>
shl    $0x1,%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm1
movsd  0xe0b(%rip),%xmm0
mulsd  %xmm0,%xmm1
movsd  0xdf7(%rip),%xmm0
divsd  %xmm0,%xmm1
movsd  0xde3(%rip),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    125b <healpix_xy2_z_phi+0x14b>
jp     125b <healpix_xy2_z_phi+0x14b>
jmp    127d <healpix_xy2_z_phi+0x16d>
movsd  -0x38(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
subsd  -0x38(%rbp),%xmm1
divsd  -0x30(%rbp),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    1287 <healpix_xy2_z_phi+0x177>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    12c7 <healpix_xy2_z_phi+0x1b7>
movsd  -0x20(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  0xd62(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  0xd4d(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<healpix_xy2_z_phi>:
push   %rbx
sub    $0x20,%rsp
mov    %rdx,%rbx
movsd  (%rdi),%xmm5
movsd  0x8(%rdi),%xmm0
movapd 0xed7(%rip),%xmm1
andpd  %xmm0,%xmm1
ucomisd 0xeeb(%rip),%xmm1
jbe    1217 <healpix_xy2_z_phi+0x107>
movsd  0xef5(%rip),%xmm1
movapd %xmm0,%xmm2
mulsd  %xmm1,%xmm2
andpd  0xead(%rip),%xmm2
divsd  0xee5(%rip),%xmm2
addsd  0xee5(%rip),%xmm2
movapd %xmm2,0x10(%rsp)
mulsd  %xmm2,%xmm2
divsd  0xedb(%rip),%xmm2
addsd  0xedb(%rip),%xmm2
movapd 0xe8b(%rip),%xmm3
xorpd  %xmm2,%xmm3
xorpd  %xmm4,%xmm4
cmpltsd %xmm0,%xmm4
andpd  %xmm4,%xmm2
andnpd %xmm3,%xmm4
orpd   %xmm2,%xmm4
movlpd %xmm4,(%rsi)
movapd %xmm5,%xmm0
addsd  0xeb2(%rip),%xmm0
mulsd  %xmm1,%xmm0
divsd  0xeae(%rip),%xmm0
movsd  %xmm5,0x8(%rsp)
call   1030 <floor@plt>
movapd 0x10(%rsp),%xmm1
ucomisd 0xea5(%rip),%xmm1
jne    11d7 <healpix_xy2_z_phi+0xc7>
jnp    1231 <healpix_xy2_z_phi+0x121>
add    %eax,%eax
add    $0x1,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xe75(%rip),%xmm0
mulsd  0xe7d(%rip),%xmm0
addsd  0xe45(%rip),%xmm0
movsd  0x8(%rsp),%xmm2
subsd  %xmm0,%xmm2
divsd  %xmm1,%xmm2
addsd  %xmm0,%xmm2
movapd %xmm2,%xmm0
movsd  %xmm2,(%rbx)
jmp    123b <healpix_xy2_z_phi+0x12b>
mulsd  0xe09(%rip),%xmm0
movsd  %xmm5,(%rbx)
divsd  0xe05(%rip),%xmm0
movsd  %xmm0,(%rsi)
jmp    123b <healpix_xy2_z_phi+0x12b>
movsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%rbx)
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @healpix_xy2_z_phi(double* %0, double* %1, double* %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca double*
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
store double* %0, double** %4
store double* %1, double** %5
store double* %2, double** %6
%11 = load double*, double** %4
%12 = getelementptr inbounds double, double* %11, i64 0
%13 = load double, double* %12
store double %13, double* %7
%14 = load double*, double** %4
%15 = getelementptr inbounds double, double* %14, i64 1
%16 = load double, double* %15
store double %16, double* %8
%17 = load double, double* %8
%18 = call double @llvm.fabs.f64(double %17)
%19 = fcmp ogt double %18, 0x3FE921FB54442D18
br i1 %19, label %20, label %64
20: ; preds = %3
%21 = load double, double* %8
%22 = fmul double %21, 4.000000e+00
%23 = call double @llvm.fabs.f64(double %22)
%24 = fdiv double %23, 0x400921FB54442D18
%25 = fsub double 2.000000e+00, %24
store double %25, double* %9
%26 = load double, double* %8
%27 = fcmp ogt double %26, 0.000000e+00
%28 = zext i1 %27 to i64
%29 = select i1 %27, i32 1, i32 -1
%30 = sitofp i32 %29 to double
%31 = load double, double* %9
%32 = load double, double* %9
%33 = fmul double %31, %32
%34 = fdiv double %33, 3.000000e+00
%35 = fsub double 1.000000e+00, %34
%36 = fmul double %30, %35
%37 = load double*, double** %5
store double %36, double* %37
%38 = load double, double* %7
%39 = fadd double %38, 0x400921FB54442D18
%40 = fmul double %39, 4.000000e+00
%41 = fdiv double %40, 0x401921FB54442D18
%42 = call i32 @floor(double %41)
%43 = mul nsw i32 2, %42
%44 = add nsw i32 %43, 1
%45 = sitofp i32 %44 to double
%46 = fmul double %45, 0x400921FB54442D18
%47 = fdiv double %46, 4.000000e+00
%48 = fadd double 0xC00921FB54442D18, %47
store double %48, double* %10
%49 = load double, double* %9
%50 = fcmp une double %49, 0.000000e+00
br i1 %50, label %51, label %59
51: ; preds = %20
%52 = load double, double* %10
%53 = load double, double* %7
%54 = load double, double* %10
%55 = fsub double %53, %54
%56 = load double, double* %9
%57 = fdiv double %55, %56
%58 = fadd double %52, %57
br label %61
59: ; preds = %20
%60 = load double, double* %7
br label %61
61: ; preds = %59, %51
%62 = phi double [ %58, %51 ], [ %60, %59 ]
%63 = load double*, double** %6
store double %62, double* %63
br label %71
64: ; preds = %3
%65 = load double, double* %7
%66 = load double*, double** %6
store double %65, double* %66
%67 = load double, double* %8
%68 = fmul double %67, 8.000000e+00
%69 = fdiv double %68, 0x4022D97C7F3321D2
%70 = load double*, double** %5
store double %69, double* %70
br label %71
71: ; preds = %64, %61
ret void
}

LLVM IR (-O2):
define void @healpix_xy2_z_phi(double* nocapture %0, double* nocapture writeonly %1, double* nocapture writeonly %2) {
%4 = load double, double* %0
%5 = getelementptr inbounds double, double* %0, i64 1
%6 = load double, double* %5
%7 = tail call double @llvm.fabs.f64(double %6)
%8 = fcmp ogt double %7, 0x3FE921FB54442D18
br i1 %8, label %9, label %37
9: ; preds = %3
%10 = fmul double %6, 4.000000e+00
%11 = tail call double @llvm.fabs.f64(double %10)
%12 = fdiv double %11, 0x400921FB54442D18
%13 = fsub double 2.000000e+00, %12
%14 = fcmp ogt double %6, 0.000000e+00
%15 = fmul double %13, %13
%16 = fdiv double %15, 3.000000e+00
%17 = fsub double 1.000000e+00, %16
%18 = fneg double %17
%19 = select i1 %14, double %17, double %18
store double %19, double* %1
%20 = fadd double %4, 0x400921FB54442D18
%21 = fmul double %20, 4.000000e+00
%22 = fdiv double %21, 0x401921FB54442D18
%23 = tail call i32 @floor(double %22)
%24 = shl nsw i32 %23, 1
%25 = or i32 %24, 1
%26 = sitofp i32 %25 to double
%27 = fmul double %26, 0x400921FB54442D18
%28 = fmul double %27, 2.500000e-01
%29 = fadd double %28, 0xC00921FB54442D18
%30 = fcmp une double %13, 0.000000e+00
br i1 %30, label %31, label %35
31: ; preds = %9
%32 = fsub double %4, %29
%33 = fdiv double %32, %13
%34 = fadd double %29, %33
br label %35
35: ; preds = %9, %31
%36 = phi double [ %34, %31 ], [ %4, %9 ]
store double %36, double* %2
br label %40
37: ; preds = %3
store double %4, double* %2
%38 = fmul double %6, 8.000000e+00
%39 = fdiv double %38, 0x4022D97C7F3321D2
store double %39, double* %1
br label %40
40: ; preds = %37, %35
ret void
}