void VectorSphereCoordinates3f(float vx, float vy, float vz, float *alpha,
                               float *beta) {
  float modZX;
  VectorNormalize(&vx, &vy, &vz);
  modZX = (float)sqrt((vx) * (vx) + (0) * (0) + (vz) * (vz));
  if (modZX < 0.00873) {
    *alpha = 0.0f;
    *beta = 3.14159265359f / 2.0f;
    if (vy < 0.0f)
      *beta = -(*beta);
  } else {
    *beta = atan2f(vy, modZX);
    *alpha = atan2f(vx, vz);
  }
}


x86 assembly (clang, -O0):
<VectorSphereCoordinates3f>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
mov    %rdi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
lea    -0x4(%rbp),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
mov    $0x0,%al
call   1030 <VectorNormalize@plt>
movss  -0x4(%rbp),%xmm1
movss  -0x4(%rbp),%xmm0
mulss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
addss  %xmm0,%xmm1
movss  -0xc(%rbp),%xmm0
movss  -0xc(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
call   1040 <sqrt@plt>
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe54(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1200 <VectorSphereCoordinates3f+0xd0>
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
movss  0xe3b(%rip),%xmm0
movss  %xmm0,(%rax)
xorps  %xmm0,%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    11fb <VectorSphereCoordinates3f+0xcb>
mov    -0x20(%rbp),%rax
movss  (%rax),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mov    -0x20(%rbp),%rax
movss  %xmm0,(%rax)
jmp    122e <VectorSphereCoordinates3f+0xfe>
movss  -0x8(%rbp),%xmm0
movss  -0x24(%rbp),%xmm1
call   1050 <atan2f@plt>
mov    -0x20(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x4(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
call   1050 <atan2f@plt>
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<VectorSphereCoordinates3f>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
movss  %xmm0,0x14(%rsp)
movss  %xmm1,0x10(%rsp)
movss  %xmm2,0xc(%rsp)
lea    0x14(%rsp),%rdi
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
xor    %eax,%eax
call   1030 <VectorNormalize@plt>
movss  0x14(%rsp),%xmm1
mulss  %xmm1,%xmm1
xorps  %xmm2,%xmm2
addss  %xmm2,%xmm1
movss  0xc(%rsp),%xmm0
mulss  %xmm0,%xmm0
addss  %xmm1,%xmm0
ucomiss %xmm2,%xmm0
jb     1192 <VectorSphereCoordinates3f+0x62>
xorps  %xmm1,%xmm1
sqrtss %xmm0,%xmm1
jmp    119a <VectorSphereCoordinates3f+0x6a>
call   1040 <sqrtf@plt>
movaps %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
movsd  0xe57(%rip),%xmm2
ucomisd %xmm0,%xmm2
jbe    11ce <VectorSphereCoordinates3f+0x9e>
movl   $0x0,(%r14)
movl   $0x3fc90fdb,(%rbx)
xorps  %xmm0,%xmm0
ucomiss 0x10(%rsp),%xmm0
jbe    11f3 <VectorSphereCoordinates3f+0xc3>
movl   $0xbfc90fdb,(%rbx)
jmp    11f3 <VectorSphereCoordinates3f+0xc3>
movss  0x10(%rsp),%xmm0
call   1050 <atan2f@plt>
movss  %xmm0,(%rbx)
movss  0x14(%rsp),%xmm0
movss  0xc(%rsp),%xmm1
call   1050 <atan2f@plt>
movss  %xmm0,(%r14)
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @VectorSphereCoordinates3f(float %0, float %1, float %2, float* %3, float* %4) {
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float*
%10 = alloca float*
%11 = alloca float
store float %0, float* %6
store float %1, float* %7
store float %2, float* %8
store float* %3, float** %9
store float* %4, float** %10
%12 = call i32 (float*, float*, float*, ...) bitcast (i32 (...)* @VectorNormalize to i32 (float*, float*, float*, ...)*)(float* %6, float* %7, float* %8)
%13 = load float, float* %6
%14 = load float, float* %6
%15 = call float @llvm.fmuladd.f32(float %13, float %14, float 0.000000e+00)
%16 = load float, float* %8
%17 = load float, float* %8
%18 = call float @llvm.fmuladd.f32(float %16, float %17, float %15)
%19 = fpext float %18 to double
%20 = call double @sqrt(double %19)
%21 = fptrunc double %20 to float
store float %21, float* %11
%22 = load float, float* %11
%23 = fpext float %22 to double
%24 = fcmp olt double %23, 0x3F81E108C3F3E037
br i1 %24, label %25, label %36
25: ; preds = %5
%26 = load float*, float** %9
store float 0.000000e+00, float* %26
%27 = load float*, float** %10
store float 0x3FF921FB60000000, float* %27
%28 = load float, float* %7
%29 = fcmp olt float %28, 0.000000e+00
br i1 %29, label %30, label %35
30: ; preds = %25
%31 = load float*, float** %10
%32 = load float, float* %31
%33 = fneg float %32
%34 = load float*, float** %10
store float %33, float* %34
br label %35
35: ; preds = %30, %25
br label %45
36: ; preds = %5
%37 = load float, float* %7
%38 = load float, float* %11
%39 = call float @atan2f(float %37, float %38)
%40 = load float*, float** %10
store float %39, float* %40
%41 = load float, float* %6
%42 = load float, float* %8
%43 = call float @atan2f(float %41, float %42)
%44 = load float*, float** %9
store float %43, float* %44
br label %45
45: ; preds = %36, %35
ret void
}

LLVM IR (-O2):
define void @VectorSphereCoordinates3f(float %0, float %1, float %2, float* nocapture writeonly %3, float* nocapture writeonly %4) {
%6 = alloca float
%7 = alloca float
%8 = alloca float
store float %0, float* %6
store float %1, float* %7
store float %2, float* %8
%9 = call i32 (float*, float*, float*, ...) bitcast (i32 (...)* @VectorNormalize to i32 (float*, float*, float*, ...)*)(float* %6, float* %7, float* %8)
%10 = load float, float* %6
%11 = call float @llvm.fmuladd.f32(float %10, float %10, float 0.000000e+00)
%12 = load float, float* %8
%13 = call float @llvm.fmuladd.f32(float %12, float %12, float %11)
%14 = call float @sqrtf(float %13)
%15 = fpext float %14 to double
%16 = fcmp olt double %15, 0x3F81E108C3F3E037
br i1 %16, label %17, label %21
17: ; preds = %5
store float 0.000000e+00, float* %3
store float 0x3FF921FB60000000, float* %4
%18 = load float, float* %7
%19 = fcmp olt float %18, 0.000000e+00
br i1 %19, label %20, label %27
20: ; preds = %17
store float 0xBFF921FB60000000, float* %4
br label %27
21: ; preds = %5
%22 = load float, float* %7
%23 = call float @atan2f(float %22, float %14)
store float %23, float* %4
%24 = load float, float* %6
%25 = load float, float* %8
%26 = call float @atan2f(float %24, float %25)
store float %26, float* %3
br label %27
27: ; preds = %17, %20, %21
ret void
}