#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 */
long ang2pix_nest_z_phi(long, double const, int /*<<< orphan*/);
int /*<<< orphan*/ atan2(double const, double const);
double sqrt(double const);
void vec2pix_nest(long nside, const double *vec, long *ipix) {
  double vlen = sqrt(vec[0] * vec[0] + vec[1] * vec[1] + vec[2] * vec[2]);
  *ipix = ang2pix_nest_z_phi(nside, vec[2] / vlen, atan2(vec[1], vec[0]));
}


x86 assembly (clang, -O0):
<vec2pix_nest>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
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
call   1050 <sqrt@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
divsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm1
call   1040 <atan2@plt>
mov    -0x30(%rbp),%rdi
movsd  -0x28(%rbp),%xmm0
mov    %eax,%esi
call   1030 <ang2pix_nest_z_phi@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vec2pix_nest>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
movsd  (%rsi),%xmm1
movsd  0x8(%rsi),%xmm0
mulsd  %xmm0,%xmm0
mulsd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
movsd  0x10(%rsi),%xmm0
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1174 <vec2pix_nest+0x44>
sqrtsd %xmm0,%xmm0
jmp    1179 <vec2pix_nest+0x49>
call   1050 <sqrt@plt>
movsd  0x10(%rbx),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  (%rbx),%xmm1
movsd  0x8(%rbx),%xmm0
call   1040 <atan2@plt>
mov    %r15,%rdi
movsd  0x8(%rsp),%xmm0
mov    %eax,%esi
call   1030 <ang2pix_nest_z_phi@plt>
mov    %rax,(%r14)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @vec2pix_nest(i64 %0, double* %1, i64* %2) {
%4 = alloca i64
%5 = alloca double*
%6 = alloca i64*
%7 = alloca double
store i64 %0, i64* %4
store double* %1, double** %5
store i64* %2, i64** %6
%8 = load double*, double** %5
%9 = getelementptr inbounds double, double* %8, i64 0
%10 = load double, double* %9
%11 = load double*, double** %5
%12 = getelementptr inbounds double, double* %11, i64 0
%13 = load double, double* %12
%14 = load double*, double** %5
%15 = getelementptr inbounds double, double* %14, i64 1
%16 = load double, double* %15
%17 = load double*, double** %5
%18 = getelementptr inbounds double, double* %17, i64 1
%19 = load double, double* %18
%20 = fmul double %16, %19
%21 = call double @llvm.fmuladd.f64(double %10, double %13, double %20)
%22 = load double*, double** %5
%23 = getelementptr inbounds double, double* %22, i64 2
%24 = load double, double* %23
%25 = load double*, double** %5
%26 = getelementptr inbounds double, double* %25, i64 2
%27 = load double, double* %26
%28 = call double @llvm.fmuladd.f64(double %24, double %27, double %21)
%29 = call double @sqrt(double %28)
store double %29, double* %7
%30 = load i64, i64* %4
%31 = load double*, double** %5
%32 = getelementptr inbounds double, double* %31, i64 2
%33 = load double, double* %32
%34 = load double, double* %7
%35 = fdiv double %33, %34
%36 = load double*, double** %5
%37 = getelementptr inbounds double, double* %36, i64 1
%38 = load double, double* %37
%39 = load double*, double** %5
%40 = getelementptr inbounds double, double* %39, i64 0
%41 = load double, double* %40
%42 = call i32 @atan2(double %38, double %41)
%43 = call i64 @ang2pix_nest_z_phi(i64 %30, double %35, i32 %42)
%44 = load i64*, i64** %6
store i64 %43, i64* %44
ret void
}

LLVM IR (-O2):
define void @vec2pix_nest(i64 %0, double* nocapture %1, i64* nocapture writeonly %2) {
%4 = load double, double* %1
%5 = getelementptr inbounds double, double* %1, i64 1
%6 = load double, double* %5
%7 = fmul double %6, %6
%8 = tail call double @llvm.fmuladd.f64(double %4, double %4, double %7)
%9 = getelementptr inbounds double, double* %1, i64 2
%10 = load double, double* %9
%11 = tail call double @llvm.fmuladd.f64(double %10, double %10, double %8)
%12 = tail call double @sqrt(double %11)
%13 = load double, double* %9
%14 = fdiv double %13, %12
%15 = load double, double* %5
%16 = load double, double* %1
%17 = tail call i32 @atan2(double %15, double %16)
%18 = tail call i64 @ang2pix_nest_z_phi(i64 %0, double %14, i32 %17)
store i64 %18, i64* %2
ret void
}