#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 */
typedef int /*<<< orphan*/ int64_t;

/* Variables and functions */
double cos(double);
int /*<<< orphan*/ pix2ang_nest_z_phi64(int /*<<< orphan*/, int /*<<< orphan*/,
                                        double *, double *, double *);
double sin(double);
double sqrt(int);
void pix2vec_nest64(int64_t nside, int64_t ipix, double *vec) {
  double z, phi, stheta;
  pix2ang_nest_z_phi64(nside, ipix, &z, &stheta, &phi);
  if (stheta < -2)
    stheta = sqrt((1. - z) * (1. + z));
  vec[0] = stheta * cos(phi);
  vec[1] = stheta * sin(phi);
  vec[2] = z;
}


x86 assembly (clang, -O0):
<pix2vec_nest64>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
lea    -0x18(%rbp),%rdx
lea    -0x28(%rbp),%rcx
lea    -0x20(%rbp),%r8
call   1040 <pix2ang_nest_z_phi64@plt>
movsd  0xe8f(%rip),%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    11a8 <pix2vec_nest64+0x68>
movsd  0xe84(%rip),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  0xe77(%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   1030 <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):
<pix2vec_nest64>:
push   %rbx
sub    $0x20,%rsp
mov    %rdx,%rbx
lea    0x18(%rsp),%rdx
lea    0x8(%rsp),%rcx
lea    0x10(%rsp),%r8
call   1040 <pix2ang_nest_z_phi64@plt>
movsd  0x8(%rsp),%xmm0
movsd  0xe96(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    119d <pix2vec_nest64+0x5d>
movsd  0x18(%rsp),%xmm0
movsd  0xe8a(%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  %xmm0,(%rsp)
movsd  0x10(%rsp),%xmm0
call   1050 <cos@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%rbx)
movsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x10(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  (%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 @pix2vec_nest64(i32 %0, i32 %1, double* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca double*
%7 = alloca double
%8 = alloca double
%9 = alloca double
store i32 %0, i32* %4
store i32 %1, i32* %5
store double* %2, double** %6
%10 = load i32, i32* %4
%11 = load i32, i32* %5
%12 = call i32 @pix2ang_nest_z_phi64(i32 %10, i32 %11, double* %7, double* %9, double* %8)
%13 = load double, double* %9
%14 = fcmp olt double %13, -2.000000e+00
br i1 %14, label %15, label %23
15: ; preds = %3
%16 = load double, double* %7
%17 = fsub double 1.000000e+00, %16
%18 = load double, double* %7
%19 = fadd double 1.000000e+00, %18
%20 = fmul double %17, %19
%21 = fptosi double %20 to i32
%22 = call double @sqrt(i32 %21)
store double %22, double* %9
br label %23
23: ; preds = %15, %3
%24 = load double, double* %9
%25 = load double, double* %8
%26 = call double @cos(double %25)
%27 = fmul double %24, %26
%28 = load double*, double** %6
%29 = getelementptr inbounds double, double* %28, i64 0
store double %27, double* %29
%30 = load double, double* %9
%31 = load double, double* %8
%32 = call double @sin(double %31)
%33 = fmul double %30, %32
%34 = load double*, double** %6
%35 = getelementptr inbounds double, double* %34, i64 1
store double %33, double* %35
%36 = load double, double* %7
%37 = load double*, double** %6
%38 = getelementptr inbounds double, double* %37, i64 2
store double %36, double* %38
ret void
}

LLVM IR (-O2):
define void @pix2vec_nest64(i32 %0, i32 %1, double* nocapture writeonly %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = bitcast double* %4 to i8*
%8 = bitcast double* %5 to i8*
%9 = bitcast double* %6 to i8*
%10 = call i32 @pix2ang_nest_z_phi64(i32 %0, i32 %1, double* %4, double* %6, double* %5)
%11 = load double, double* %6
%12 = fcmp olt double %11, -2.000000e+00
br i1 %12, label %13, label %20
13: ; preds = %3
%14 = load double, double* %4
%15 = fsub double 1.000000e+00, %14
%16 = fadd double %14, 1.000000e+00
%17 = fmul double %15, %16
%18 = fptosi double %17 to i32
%19 = call double @sqrt(i32 %18)
store double %19, double* %6
br label %20
20: ; preds = %13, %3
%21 = phi double [ %19, %13 ], [ %11, %3 ]
%22 = load double, double* %5
%23 = call double @cos(double %22)
%24 = fmul double %21, %23
store double %24, double* %2
%25 = load double, double* %6
%26 = load double, double* %5
%27 = call double @sin(double %26)
%28 = fmul double %25, %27
%29 = getelementptr inbounds double, double* %2, i64 1
store double %28, double* %29
%30 = load double, double* %4
%31 = getelementptr inbounds double, double* %2, i64 2
store double %30, double* %31
ret void
}