float torsion(xyz1, xyz2, xyz3, xyz4)
float xyz1[3], xyz2[3], xyz3[3], xyz4[3];
{
  int i;
  float v12[3], v23[3], v34[3], plane123[3], plane234[3], v1234[3], c, s, x, y;
  if ((unit_vector(xyz1, xyz2, v12) <= 0.0001) ||
      (unit_vector(xyz2, xyz3, v23) <= 0.0001) ||
      (unit_vector(xyz3, xyz4, v34) <= 0.0001))
    return (0.0);
  if ((vector_product(v12, v23, plane123) <= 0.0001) ||
      (vector_product(v23, v34, plane234) <= 0.0001))
    return (0.0);
  x = normalize(plane123, plane123);
  y = normalize(plane234, plane234);
  c = scalar_product(plane123, plane234);
  if (fabs(c + 1.0) < 0.0001)
    return (180.0);
  else if (fabs(c - 1.0) < 0.0001)
    return (0.0);
  s = vector_product(plane123, plane234, v1234);
  s = normalize(v1234, v1234);
  s = s * scalar_product(v1234, v23);
  return ((float)(57.29577951 * atan((double)s / c)));
}


x86 assembly (clang, -O0):
<torsion>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x38(%rbp),%rdx
mov    $0x0,%al
call   1070 <unit_vector@plt>
cvtsi2sd %eax,%xmm1
movsd  0xe76(%rip),%xmm0
ucomisd %xmm1,%xmm0
jae    11e6 <torsion+0x96>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
lea    -0x44(%rbp),%rdx
mov    $0x0,%al
call   1070 <unit_vector@plt>
cvtsi2sd %eax,%xmm1
movsd  0xe4d(%rip),%xmm0
ucomisd %xmm1,%xmm0
jae    11e6 <torsion+0x96>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
lea    -0x50(%rbp),%rdx
mov    $0x0,%al
call   1070 <unit_vector@plt>
cvtsi2sd %eax,%xmm1
movsd  0xe24(%rip),%xmm0
ucomisd %xmm1,%xmm0
jb     11f3 <torsion+0xa3>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    13bd <torsion+0x26d>
lea    -0x38(%rbp),%rdi
lea    -0x44(%rbp),%rsi
lea    -0x5c(%rbp),%rdx
mov    $0x0,%al
call   1030 <vector_product@plt>
cvtsi2sd %eax,%xmm1
movsd  0xdee(%rip),%xmm0
ucomisd %xmm1,%xmm0
jae    1245 <torsion+0xf5>
lea    -0x44(%rbp),%rdi
lea    -0x50(%rbp),%rsi
lea    -0x68(%rbp),%rdx
mov    $0x0,%al
call   1030 <vector_product@plt>
cvtsi2sd %eax,%xmm1
movsd  0xdc5(%rip),%xmm0
ucomisd %xmm1,%xmm0
jb     1252 <torsion+0x102>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    13bd <torsion+0x26d>
lea    -0x5c(%rbp),%rdi
lea    -0x5c(%rbp),%rsi
mov    $0x0,%al
call   1040 <normalize@plt>
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x80(%rbp)
lea    -0x68(%rbp),%rdi
lea    -0x68(%rbp),%rsi
mov    $0x0,%al
call   1040 <normalize@plt>
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x84(%rbp)
ff
lea    -0x5c(%rbp),%rdi
lea    -0x68(%rbp),%rsi
mov    $0x0,%al
call   1060 <scalar_product@plt>
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x78(%rbp)
movss  -0x78(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xd5a(%rip),%xmm0
addsd  %xmm0,%xmm1
movaps 0xd67(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xd3b(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    12e1 <torsion+0x191>
movss  0xd59(%rip),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    13bd <torsion+0x26d>
movss  -0x78(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xd16(%rip),%xmm0
subsd  %xmm0,%xmm1
movaps 0xd23(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xcf7(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1320 <torsion+0x1d0>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    13bd <torsion+0x26d>
jmp    1325 <torsion+0x1d5>
lea    -0x5c(%rbp),%rdi
lea    -0x68(%rbp),%rsi
lea    -0x74(%rbp),%rdx
mov    $0x0,%al
call   1030 <vector_product@plt>
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x7c(%rbp)
lea    -0x74(%rbp),%rdi
lea    -0x74(%rbp),%rsi
mov    $0x0,%al
call   1040 <normalize@plt>
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x7c(%rbp)
movss  -0x7c(%rbp),%xmm0
movss  %xmm0,-0x88(%rbp)
ff
lea    -0x74(%rbp),%rdi
lea    -0x44(%rbp),%rsi
mov    $0x0,%al
call   1060 <scalar_product@plt>
movss  -0x88(%rbp),%xmm0
ff
cvtsi2ss %eax,%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x7c(%rbp)
movss  -0x7c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x78(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
divsd  %xmm1,%xmm0
call   1050 <atan@plt>
movaps %xmm0,%xmm1
movsd  0xc60(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<torsion>:
push   %r15
push   %r14
push   %rbx
sub    $0x60,%rsp
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%rbx
lea    0x48(%rsp),%rdx
xor    %eax,%eax
call   1070 <unit_vector@plt>
xorpd  %xmm0,%xmm0
test   %eax,%eax
jle    1252 <torsion+0x102>
lea    0xc(%rsp),%rdx
mov    %rbx,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1070 <unit_vector@plt>
test   %eax,%eax
jle    124e <torsion+0xfe>
lea    0x3c(%rsp),%rdx
mov    %r15,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1070 <unit_vector@plt>
test   %eax,%eax
jle    124e <torsion+0xfe>
lea    0x48(%rsp),%rdi
lea    0xc(%rsp),%rsi
lea    0x30(%rsp),%rdx
xor    %eax,%eax
call   1030 <vector_product@plt>
test   %eax,%eax
jle    124e <torsion+0xfe>
lea    0xc(%rsp),%rdi
lea    0x3c(%rsp),%rsi
lea    0x24(%rsp),%rdx
xor    %eax,%eax
call   1030 <vector_product@plt>
test   %eax,%eax
jle    124e <torsion+0xfe>
lea    0x30(%rsp),%r14
mov    %r14,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <normalize@plt>
lea    0x24(%rsp),%rbx
mov    %rbx,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <normalize@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <scalar_product@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
cvtss2sd %xmm0,%xmm2
movsd  0xdd6(%rip),%xmm1
addsd  %xmm2,%xmm1
andpd  0xdea(%rip),%xmm1
movsd  0xdca(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    125c <torsion+0x10c>
movss  0xde4(%rip),%xmm0
jmp    1252 <torsion+0x102>
xorpd  %xmm0,%xmm0
add    $0x60,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
movsd  0xdac(%rip),%xmm1
addsd  %xmm2,%xmm1
andpd  0xdb0(%rip),%xmm1
ucomisd %xmm1,%xmm0
xorpd  %xmm0,%xmm0
ja     1252 <torsion+0x102>
lea    0x30(%rsp),%rdi
lea    0x24(%rsp),%rsi
lea    0x54(%rsp),%rbx
mov    %rbx,%rdx
xor    %eax,%eax
movsd  %xmm2,0x18(%rsp)
call   1030 <vector_product@plt>
mov    %rbx,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <normalize@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  %xmm0,0x8(%rsp)
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <scalar_product@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
mulss  0x8(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
divsd  0x18(%rsp),%xmm0
call   1050 <atan@plt>
mulsd  0xd32(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
jmp    1252 <torsion+0x102>

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

LLVM IR (-O2):
define float @torsion(float* %0, float* %1, float* %2, float* %3) {
%5 = alloca [3 x float]
%6 = alloca [3 x float]
%7 = alloca [3 x float]
%8 = alloca [3 x float]
%9 = alloca [3 x float]
%10 = alloca [3 x float]
%11 = bitcast [3 x float]* %5 to i8*
%12 = bitcast [3 x float]* %6 to i8*
%13 = bitcast [3 x float]* %7 to i8*
%14 = bitcast [3 x float]* %8 to i8*
%15 = bitcast [3 x float]* %9 to i8*
%16 = bitcast [3 x float]* %10 to i8*
%17 = getelementptr inbounds [3 x float], [3 x float]* %5, i64 0, i64 0
%18 = call i32 (float*, float*, float*, ...) bitcast (i32 (...)* @unit_vector to i32 (float*, float*, float*, ...)*)(float* %0, float* %1, float* %17)
%19 = icmp slt i32 %18, 1
br i1 %19, label %62, label %20
20: ; preds = %4
%21 = getelementptr inbounds [3 x float], [3 x float]* %6, i64 0, i64 0
%22 = call i32 (float*, float*, float*, ...) bitcast (i32 (...)* @unit_vector to i32 (float*, float*, float*, ...)*)(float* %1, float* %2, float* %21)
%23 = icmp slt i32 %22, 1
br i1 %23, label %62, label %24
24: ; preds = %20
%25 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 0
%26 = call i32 (float*, float*, float*, ...) bitcast (i32 (...)* @unit_vector to i32 (float*, float*, float*, ...)*)(float* %2, float* %3, float* %25)
%27 = icmp slt i32 %26, 1
br i1 %27, label %62, label %28
28: ; preds = %24
%29 = getelementptr inbounds [3 x float], [3 x float]* %8, i64 0, i64 0
%30 = call i32 (float*, float*, float*, ...) bitcast (i32 (...)* @vector_product to i32 (float*, float*, float*, ...)*)(float* %17, float* %21, float* %29)
%31 = icmp slt i32 %30, 1
br i1 %31, label %62, label %32
32: ; preds = %28
%33 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 0
%34 = call i32 (float*, float*, float*, ...) bitcast (i32 (...)* @vector_product to i32 (float*, float*, float*, ...)*)(float* %21, float* %25, float* %33)
%35 = icmp slt i32 %34, 1
br i1 %35, label %62, label %36
36: ; preds = %32
%37 = call i32 (float*, float*, ...) bitcast (i32 (...)* @normalize to i32 (float*, float*, ...)*)(float* %29, float* %29)
%38 = call i32 (float*, float*, ...) bitcast (i32 (...)* @normalize to i32 (float*, float*, ...)*)(float* %33, float* %33)
%39 = call i32 (float*, float*, ...) bitcast (i32 (...)* @scalar_product to i32 (float*, float*, ...)*)(float* %29, float* %33)
%40 = sitofp i32 %39 to float
%41 = fpext float %40 to double
%42 = fadd double %41, 1.000000e+00
%43 = call double @llvm.fabs.f64(double %42)
%44 = fcmp olt double %43, 1.000000e-04
br i1 %44, label %62, label %45
45: ; preds = %36
%46 = fadd double %41, -1.000000e+00
%47 = call double @llvm.fabs.f64(double %46)
%48 = fcmp olt double %47, 1.000000e-04
br i1 %48, label %62, label %49
49: ; preds = %45
%50 = getelementptr inbounds [3 x float], [3 x float]* %10, i64 0, i64 0
%51 = call i32 (float*, float*, float*, ...) bitcast (i32 (...)* @vector_product to i32 (float*, float*, float*, ...)*)(float* %29, float* %33, float* %50)
%52 = call i32 (float*, float*, ...) bitcast (i32 (...)* @normalize to i32 (float*, float*, ...)*)(float* %50, float* %50)
%53 = sitofp i32 %52 to float
%54 = call i32 (float*, float*, ...) bitcast (i32 (...)* @scalar_product to i32 (float*, float*, ...)*)(float* %50, float* %21)
%55 = sitofp i32 %54 to float
%56 = fmul float %53, %55
%57 = fpext float %56 to double
%58 = fdiv double %57, %41
%59 = call double @atan(double %58)
%60 = fmul double %59, 0x404CA5DC1A5D2372
%61 = fptrunc double %60 to float
br label %62
62: ; preds = %45, %36, %28, %32, %4, %20, %24, %49
%63 = phi float [ %61, %49 ], [ 0.000000e+00, %24 ], [ 0.000000e+00, %20 ], [ 0.000000e+00, %4 ], [ 0.000000e+00, %32 ], [ 0.000000e+00, %28 ], [ 1.800000e+02, %36 ], [ 0.000000e+00, %45 ]
ret float %63
}