#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*/ healpix_xy2_z_phi(double const *, double *, double *);
double sin(double);
double sqrt(int);
void healpix_xy2vec(const double xy[2], double out[3]) {
  double z, phi, stheta;
  healpix_xy2_z_phi(xy, &z, &phi);
  stheta = sqrt((1 - z) * (1 + z));
  out[0] = stheta * cos(phi);
  out[1] = stheta * sin(phi);
  out[2] = z;
}


x86 assembly (clang, -O0):
<healpix_xy2vec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   1030 <healpix_xy2_z_phi@plt>
movsd  0xe97(%rip),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  0xe8a(%rip),%xmm1
addsd  -0x18(%rbp),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1060 <sqrt@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1050 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1040 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x18(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x10(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<healpix_xy2vec>:
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%rbx
lea    0x18(%rsp),%rsi
lea    0x10(%rsp),%rdx
call   1030 <healpix_xy2_z_phi@plt>
movsd  0x18(%rsp),%xmm0
movsd  0xe9b(%rip),%xmm1
movapd %xmm1,%xmm2
subsd  %xmm0,%xmm2
addsd  %xmm1,%xmm0
mulsd  %xmm2,%xmm0
cvttsd2si %xmm0,%edi
call   1060 <sqrt@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
call   1050 <cos@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%rbx)
movsd  0x10(%rsp),%xmm0
call   1040 <sin@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rbx)
movsd  0x18(%rsp),%xmm0
movsd  %xmm0,0x10(%rbx)
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @healpix_xy2vec(double* %0, double* %1) {
%3 = alloca double*
%4 = alloca double*
%5 = alloca double
%6 = alloca double
%7 = alloca double
store double* %0, double** %3
store double* %1, double** %4
%8 = load double*, double** %3
%9 = call i32 @healpix_xy2_z_phi(double* %8, double* %5, double* %6)
%10 = load double, double* %5
%11 = fsub double 1.000000e+00, %10
%12 = load double, double* %5
%13 = fadd double 1.000000e+00, %12
%14 = fmul double %11, %13
%15 = fptosi double %14 to i32
%16 = call double @sqrt(i32 %15)
store double %16, double* %7
%17 = load double, double* %7
%18 = load double, double* %6
%19 = call double @cos(double %18)
%20 = fmul double %17, %19
%21 = load double*, double** %4
%22 = getelementptr inbounds double, double* %21, i64 0
store double %20, double* %22
%23 = load double, double* %7
%24 = load double, double* %6
%25 = call double @sin(double %24)
%26 = fmul double %23, %25
%27 = load double*, double** %4
%28 = getelementptr inbounds double, double* %27, i64 1
store double %26, double* %28
%29 = load double, double* %5
%30 = load double*, double** %4
%31 = getelementptr inbounds double, double* %30, i64 2
store double %29, double* %31
ret void
}

LLVM IR (-O2):
define void @healpix_xy2vec(double* %0, double* nocapture writeonly %1) {
%3 = alloca double
%4 = alloca double
%5 = bitcast double* %3 to i8*
%6 = bitcast double* %4 to i8*
%7 = call i32 @healpix_xy2_z_phi(double* %0, double* %3, double* %4)
%8 = load double, double* %3
%9 = fsub double 1.000000e+00, %8
%10 = fadd double %8, 1.000000e+00
%11 = fmul double %9, %10
%12 = fptosi double %11 to i32
%13 = call double @sqrt(i32 %12)
%14 = load double, double* %4
%15 = call double @cos(double %14)
%16 = fmul double %13, %15
store double %16, double* %1
%17 = load double, double* %4
%18 = call double @sin(double %17)
%19 = fmul double %13, %18
%20 = getelementptr inbounds double, double* %1, i64 1
store double %19, double* %20
%21 = load double, double* %3
%22 = getelementptr inbounds double, double* %1, i64 2
store double %21, double* %22
ret void
}