int angle_between(v1, v2, angle)
float *angle, v1[], v2[];
{
  double d, d1, d2, dt, n, result = 0.0, t;
  char response[80];
  n = v1[0] * v2[0] + v1[1] * v2[1] + v1[2] * v2[2];
  dt = v1[0] * v1[0] + v1[1] * v1[1] + v1[2] * v1[2];
  d1 = sqrt(dt);
  dt = v2[0] * v2[0] + v2[1] * v2[1] + v2[2] * v2[2];
  d2 = sqrt(dt);
  d = d1 * d2;
  t = n / d;
  if (t <= -1.0)
    t = -0.999;
  if (t > 1.0)
    t = 1.0;
  result = acos(t);
  *angle = result;
  return (1);
}


x86 assembly (clang, -O0):
<angle_between>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm1
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm2
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm0
mov    -0x10(%rbp),%rax
mulss  0x4(%rax),%xmm0
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
movss  0x8(%rax),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm1
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm2
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm0
mov    -0x8(%rbp),%rax
mulss  0x4(%rax),%xmm0
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm0
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1040 <sqrt@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm1
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm2
mov    -0x10(%rbp),%rax
movss  0x4(%rax),%xmm0
mov    -0x10(%rbp),%rax
mulss  0x4(%rax),%xmm0
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
mov    -0x10(%rbp),%rax
movss  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
movss  0x8(%rax),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1040 <sqrt@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x40(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xd96(%rip),%xmm0
ucomisd -0x50(%rbp),%xmm0
jb     1282 <angle_between+0x162>
movsd  0xd8b(%rip),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  0xd81(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    12a6 <angle_between+0x186>
movsd  0xd6f(%rip),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
call   1030 <acos@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
mov    $0x1,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<angle_between>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
movss  (%rdi),%xmm0
movss  0x4(%rdi),%xmm1
movss  0x4(%rsi),%xmm2
mulss  %xmm1,%xmm2
movss  (%rsi),%xmm3
mulss  %xmm0,%xmm3
addss  %xmm2,%xmm3
movss  0x8(%rdi),%xmm2
movss  0x8(%rsi),%xmm4
mulss  %xmm2,%xmm4
addss  %xmm3,%xmm4
mulss  %xmm1,%xmm1
mulss  %xmm0,%xmm0
addss  %xmm1,%xmm0
mulss  %xmm2,%xmm2
addss  %xmm0,%xmm2
xorps  %xmm0,%xmm0
cvtss2sd %xmm2,%xmm0
xorpd  %xmm5,%xmm5
ucomisd %xmm5,%xmm0
jb     118b <angle_between+0x6b>
xorps  %xmm3,%xmm3
sqrtsd %xmm0,%xmm3
jmp    11a2 <angle_between+0x82>
movss  %xmm4,(%rsp)
call   1040 <sqrt@plt>
xorpd  %xmm5,%xmm5
movss  (%rsp),%xmm4
movapd %xmm0,%xmm3
xorps  %xmm2,%xmm2
cvtss2sd %xmm4,%xmm2
movss  (%rbx),%xmm0
movss  0x4(%rbx),%xmm1
mulss  %xmm1,%xmm1
mulss  %xmm0,%xmm0
addss  %xmm1,%xmm0
movss  0x8(%rbx),%xmm1
mulss  %xmm1,%xmm1
addss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
ucomisd %xmm5,%xmm0
jb     11de <angle_between+0xbe>
sqrtsd %xmm0,%xmm0
jmp    11f7 <angle_between+0xd7>
movaps %xmm2,(%rsp)
movsd  %xmm3,0x10(%rsp)
call   1040 <sqrt@plt>
movsd  0x10(%rsp),%xmm3
movaps (%rsp),%xmm2
mulsd  %xmm0,%xmm3
divsd  %xmm3,%xmm2
movapd %xmm2,%xmm1
cmpnlesd 0xdf4(%rip),%xmm1
andpd  %xmm1,%xmm2
movsd  0xdf0(%rip),%xmm0
andnpd %xmm0,%xmm1
orpd   %xmm2,%xmm1
movsd  0xde8(%rip),%xmm0
minsd  %xmm1,%xmm0
call   1030 <acos@plt>
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%r14)
mov    $0x1,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @angle_between(float* %0, float* %1, float* %2) {
%4 = alloca float*
%5 = alloca float*
%6 = alloca float*
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca [80 x i8]
store float* %0, float** %4
store float* %1, float** %5
store float* %2, float** %6
store double 0.000000e+00, double* %12
%15 = load float*, float** %4
%16 = getelementptr inbounds float, float* %15, i64 0
%17 = load float, float* %16
%18 = load float*, float** %5
%19 = getelementptr inbounds float, float* %18, i64 0
%20 = load float, float* %19
%21 = load float*, float** %4
%22 = getelementptr inbounds float, float* %21, i64 1
%23 = load float, float* %22
%24 = load float*, float** %5
%25 = getelementptr inbounds float, float* %24, i64 1
%26 = load float, float* %25
%27 = fmul float %23, %26
%28 = call float @llvm.fmuladd.f32(float %17, float %20, float %27)
%29 = load float*, float** %4
%30 = getelementptr inbounds float, float* %29, i64 2
%31 = load float, float* %30
%32 = load float*, float** %5
%33 = getelementptr inbounds float, float* %32, i64 2
%34 = load float, float* %33
%35 = call float @llvm.fmuladd.f32(float %31, float %34, float %28)
%36 = fpext float %35 to double
store double %36, double* %11
%37 = load float*, float** %4
%38 = getelementptr inbounds float, float* %37, i64 0
%39 = load float, float* %38
%40 = load float*, float** %4
%41 = getelementptr inbounds float, float* %40, i64 0
%42 = load float, float* %41
%43 = load float*, float** %4
%44 = getelementptr inbounds float, float* %43, i64 1
%45 = load float, float* %44
%46 = load float*, float** %4
%47 = getelementptr inbounds float, float* %46, i64 1
%48 = load float, float* %47
%49 = fmul float %45, %48
%50 = call float @llvm.fmuladd.f32(float %39, float %42, float %49)
%51 = load float*, float** %4
%52 = getelementptr inbounds float, float* %51, i64 2
%53 = load float, float* %52
%54 = load float*, float** %4
%55 = getelementptr inbounds float, float* %54, i64 2
%56 = load float, float* %55
%57 = call float @llvm.fmuladd.f32(float %53, float %56, float %50)
%58 = fpext float %57 to double
store double %58, double* %10
%59 = load double, double* %10
%60 = call double @sqrt(double %59)
store double %60, double* %8
%61 = load float*, float** %5
%62 = getelementptr inbounds float, float* %61, i64 0
%63 = load float, float* %62
%64 = load float*, float** %5
%65 = getelementptr inbounds float, float* %64, i64 0
%66 = load float, float* %65
%67 = load float*, float** %5
%68 = getelementptr inbounds float, float* %67, i64 1
%69 = load float, float* %68
%70 = load float*, float** %5
%71 = getelementptr inbounds float, float* %70, i64 1
%72 = load float, float* %71
%73 = fmul float %69, %72
%74 = call float @llvm.fmuladd.f32(float %63, float %66, float %73)
%75 = load float*, float** %5
%76 = getelementptr inbounds float, float* %75, i64 2
%77 = load float, float* %76
%78 = load float*, float** %5
%79 = getelementptr inbounds float, float* %78, i64 2
%80 = load float, float* %79
%81 = call float @llvm.fmuladd.f32(float %77, float %80, float %74)
%82 = fpext float %81 to double
store double %82, double* %10
%83 = load double, double* %10
%84 = call double @sqrt(double %83)
store double %84, double* %9
%85 = load double, double* %8
%86 = load double, double* %9
%87 = fmul double %85, %86
store double %87, double* %7
%88 = load double, double* %11
%89 = load double, double* %7
%90 = fdiv double %88, %89
store double %90, double* %13
%91 = load double, double* %13
%92 = fcmp ole double %91, -1.000000e+00
br i1 %92, label %93, label %94
93: ; preds = %3
store double 0xBFEFF7CED916872B, double* %13
br label %94
94: ; preds = %93, %3
%95 = load double, double* %13
%96 = fcmp ogt double %95, 1.000000e+00
br i1 %96, label %97, label %98
97: ; preds = %94
store double 1.000000e+00, double* %13
br label %98
98: ; preds = %97, %94
%99 = load double, double* %13
%100 = call double @acos(double %99)
store double %100, double* %12
%101 = load double, double* %12
%102 = fptrunc double %101 to float
%103 = load float*, float** %6
store float %102, float* %103
ret i32 1
}

LLVM IR (-O2):
define i32 @angle_between(float* nocapture %0, float* nocapture %1, float* nocapture writeonly %2) {
%4 = load float, float* %0
%5 = load float, float* %1
%6 = getelementptr inbounds float, float* %0, i64 1
%7 = load float, float* %6
%8 = getelementptr inbounds float, float* %1, i64 1
%9 = load float, float* %8
%10 = fmul float %7, %9
%11 = tail call float @llvm.fmuladd.f32(float %4, float %5, float %10)
%12 = getelementptr inbounds float, float* %0, i64 2
%13 = load float, float* %12
%14 = getelementptr inbounds float, float* %1, i64 2
%15 = load float, float* %14
%16 = tail call float @llvm.fmuladd.f32(float %13, float %15, float %11)
%17 = fpext float %16 to double
%18 = fmul float %7, %7
%19 = tail call float @llvm.fmuladd.f32(float %4, float %4, float %18)
%20 = tail call float @llvm.fmuladd.f32(float %13, float %13, float %19)
%21 = fpext float %20 to double
%22 = tail call double @sqrt(double %21)
%23 = load float, float* %1
%24 = load float, float* %8
%25 = fmul float %24, %24
%26 = tail call float @llvm.fmuladd.f32(float %23, float %23, float %25)
%27 = load float, float* %14
%28 = tail call float @llvm.fmuladd.f32(float %27, float %27, float %26)
%29 = fpext float %28 to double
%30 = tail call double @sqrt(double %29)
%31 = fmul double %22, %30
%32 = fdiv double %17, %31
%33 = fcmp ugt double %32, -1.000000e+00
%34 = select i1 %33, double %32, double 0xBFEFF7CED916872B
%35 = fcmp ogt double %34, 1.000000e+00
%36 = select i1 %35, double 1.000000e+00, double %34
%37 = tail call double @acos(double %36)
%38 = fptrunc double %37 to float
store float %38, float* %2
ret i32 1
}