float get_arm_angle(float x0, float y0, float z0, float rf, float re) {
  float a = (x0 * x0 + y0 * y0 + z0 * z0 + rf * rf - re * re) / (2 * z0);
  float b = -y0 / z0;
  float d = -(a) * (a) + rf * (b * b * rf + rf);
  float yj = (-a * b - sqrtf(d)) / (b * b + 1.f);
  float zj = a + b * yj;
  return atan2f(-zj, -yj);
}


x86 assembly (clang, -O0):
<get_arm_angle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
movss  %xmm3,-0x10(%rbp)
movss  %xmm4,-0x14(%rbp)
movss  -0x4(%rbp),%xmm1
movss  -0x4(%rbp),%xmm2
movss  -0x8(%rbp),%xmm0
mulss  -0x8(%rbp),%xmm0
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
movss  -0xc(%rbp),%xmm0
movss  -0xc(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  -0x10(%rbp),%xmm1
movss  -0x10(%rbp),%xmm2
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
movss  -0x14(%rbp),%xmm0
movss  -0x14(%rbp),%xmm2
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  0xe5c(%rip),%xmm1
mulss  -0xc(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x8(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
divss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x18(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  -0x18(%rbp),%xmm2
movss  -0x10(%rbp),%xmm1
movss  -0x1c(%rbp),%xmm3
mulss  -0x1c(%rbp),%xmm3
movss  -0x10(%rbp),%xmm5
movss  -0x10(%rbp),%xmm4
mulss  %xmm5,%xmm3
addss  %xmm4,%xmm3
mulss  %xmm3,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x18(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x30(%rbp)
movss  -0x20(%rbp),%xmm0
call   1030 <sqrtf@plt>
movss  -0x30(%rbp),%xmm2
movaps %xmm0,%xmm1
movss  -0x2c(%rbp),%xmm0
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  -0x1c(%rbp),%xmm1
movss  -0x1c(%rbp),%xmm2
mulss  %xmm2,%xmm1
movss  0xd82(%rip),%xmm2
addss  %xmm2,%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x18(%rbp),%xmm1
movss  -0x1c(%rbp),%xmm0
movss  -0x24(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x28(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  -0x24(%rbp),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
call   1040 <atan2f@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_arm_angle>:
sub    $0x48,%rsp
movaps %xmm1,%xmm5
mulss  %xmm1,%xmm1
mulss  %xmm0,%xmm0
addss  %xmm1,%xmm0
movaps %xmm2,%xmm1
movaps 0xec3(%rip),%xmm6
xorps  %xmm6,%xmm5
divss  %xmm2,%xmm5
mulss  %xmm2,%xmm2
addss  %xmm0,%xmm2
movaps %xmm5,%xmm7
mulss  %xmm5,%xmm7
movaps %xmm7,%xmm0
mulss  %xmm3,%xmm0
addss  %xmm3,%xmm0
mulss  %xmm3,%xmm0
mulss  %xmm3,%xmm3
addss  %xmm2,%xmm3
mulss  %xmm4,%xmm4
subss  %xmm4,%xmm3
addss  %xmm1,%xmm1
divss  %xmm1,%xmm3
movaps %xmm3,%xmm1
xorps  %xmm6,%xmm1
movaps %xmm3,%xmm2
mulss  %xmm3,%xmm2
subss  %xmm2,%xmm0
xorps  %xmm2,%xmm2
ucomiss %xmm2,%xmm0
jb     1199 <get_arm_angle+0x79>
sqrtss %xmm0,%xmm0
jmp    11cb <get_arm_angle+0xab>
movaps %xmm5,0x30(%rsp)
movaps %xmm1,0x20(%rsp)
movaps %xmm7,0x10(%rsp)
movaps %xmm3,(%rsp)
call   1030 <sqrtf@plt>
movaps (%rsp),%xmm3
movaps 0x10(%rsp),%xmm7
movaps 0x20(%rsp),%xmm1
movaps 0xe3a(%rip),%xmm6
movaps 0x30(%rsp),%xmm5
mulss  %xmm5,%xmm1
subss  %xmm0,%xmm1
addss  0xe35(%rip),%xmm7
divss  %xmm7,%xmm1
mulss  %xmm1,%xmm5
addss  %xmm3,%xmm5
xorps  %xmm6,%xmm5
xorps  %xmm6,%xmm1
movaps %xmm5,%xmm0
add    $0x48,%rsp
jmp    1040 <atan2f@plt>

LLVM IR (-O0):
define float @get_arm_angle(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
%12 = alloca float
%13 = alloca float
%14 = alloca float
%15 = 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
%16 = load float, float* %6
%17 = load float, float* %6
%18 = load float, float* %7
%19 = load float, float* %7
%20 = fmul float %18, %19
%21 = call float @llvm.fmuladd.f32(float %16, float %17, float %20)
%22 = load float, float* %8
%23 = load float, float* %8
%24 = call float @llvm.fmuladd.f32(float %22, float %23, float %21)
%25 = load float, float* %9
%26 = load float, float* %9
%27 = call float @llvm.fmuladd.f32(float %25, float %26, float %24)
%28 = load float, float* %10
%29 = load float, float* %10
%30 = fneg float %28
%31 = call float @llvm.fmuladd.f32(float %30, float %29, float %27)
%32 = load float, float* %8
%33 = fmul float 2.000000e+00, %32
%34 = fdiv float %31, %33
store float %34, float* %11
%35 = load float, float* %7
%36 = fneg float %35
%37 = load float, float* %8
%38 = fdiv float %36, %37
store float %38, float* %12
%39 = load float, float* %11
%40 = fneg float %39
%41 = load float, float* %11
%42 = load float, float* %9
%43 = load float, float* %12
%44 = load float, float* %12
%45 = fmul float %43, %44
%46 = load float, float* %9
%47 = load float, float* %9
%48 = call float @llvm.fmuladd.f32(float %45, float %46, float %47)
%49 = fmul float %42, %48
%50 = call float @llvm.fmuladd.f32(float %40, float %41, float %49)
store float %50, float* %13
%51 = load float, float* %11
%52 = fneg float %51
%53 = load float, float* %12
%54 = load float, float* %13
%55 = call float @sqrtf(float %54)
%56 = fneg float %55
%57 = call float @llvm.fmuladd.f32(float %52, float %53, float %56)
%58 = load float, float* %12
%59 = load float, float* %12
%60 = call float @llvm.fmuladd.f32(float %58, float %59, float 1.000000e+00)
%61 = fdiv float %57, %60
store float %61, float* %14
%62 = load float, float* %11
%63 = load float, float* %12
%64 = load float, float* %14
%65 = call float @llvm.fmuladd.f32(float %63, float %64, float %62)
store float %65, float* %15
%66 = load float, float* %15
%67 = fneg float %66
%68 = load float, float* %14
%69 = fneg float %68
%70 = call float @atan2f(float %67, float %69)
ret float %70
}

LLVM IR (-O2):
define float @get_arm_angle(float %0, float %1, float %2, float %3, float %4) {
%6 = fmul float %1, %1
%7 = tail call float @llvm.fmuladd.f32(float %0, float %0, float %6)
%8 = tail call float @llvm.fmuladd.f32(float %2, float %2, float %7)
%9 = tail call float @llvm.fmuladd.f32(float %3, float %3, float %8)
%10 = fneg float %4
%11 = tail call float @llvm.fmuladd.f32(float %10, float %4, float %9)
%12 = fmul float %2, 2.000000e+00
%13 = fdiv float %11, %12
%14 = fneg float %1
%15 = fdiv float %14, %2
%16 = fneg float %13
%17 = fmul float %15, %15
%18 = tail call float @llvm.fmuladd.f32(float %17, float %3, float %3)
%19 = fmul float %18, %3
%20 = tail call float @llvm.fmuladd.f32(float %16, float %13, float %19)
%21 = tail call float @sqrtf(float %20)
%22 = fneg float %21
%23 = tail call float @llvm.fmuladd.f32(float %16, float %15, float %22)
%24 = tail call float @llvm.fmuladd.f32(float %15, float %15, float 1.000000e+00)
%25 = fdiv float %23, %24
%26 = tail call float @llvm.fmuladd.f32(float %15, float %25, float %13)
%27 = fneg float %26
%28 = fneg float %25
%29 = tail call float @atan2f(float %27, float %28)
ret float %29
}