#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 */
double const sqrt(double const);
double distances_to_dihedral(double d01, double d02, double d03, double d12,
                             double d13, double d23) {
  if (d03 == 0.0)
    return 1.0;
  const double a = 0.5 * (d01 * d01 + d13 * d13 - d03 * d03) / (d01 * d13);
  const double b = 0.5 * (d13 * d13 + d12 * d12 - d23 * d23) / (d13 * d12);
  const double c = 0.5 * (d01 * d01 + d12 * d12 - d02 * d02) / (d01 * d12);
  const double e = 1.0 - b * b;
  const double f = 1.0 - c * c;
  return (a - b * c) / sqrt(e * f);
}


x86 assembly (clang, -O0):
<distances_to_dihedral>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
movsd  %xmm4,-0x30(%rbp)
movsd  %xmm5,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1160 <distances_to_dihedral+0x50>
jp     1160 <distances_to_dihedral+0x50>
movsd  0xeaa(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    134b <distances_to_dihedral+0x23b>
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm1
mulsd  -0x30(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xe5b(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  -0x10(%rbp),%xmm1
mulsd  -0x30(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm1
mulsd  -0x28(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x38(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm2
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xdf7(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  -0x30(%rbp),%xmm1
mulsd  -0x28(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm1
mulsd  -0x28(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xd93(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  -0x10(%rbp),%xmm1
mulsd  -0x28(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xd47(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xd11(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x40(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x58(%rbp),%xmm0
mulsd  -0x60(%rbp),%xmm0
call   1030 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<distances_to_dihedral>:
sub    $0x18,%rsp
xorpd  %xmm8,%xmm8
ucomisd %xmm8,%xmm2
jne    112f <distances_to_dihedral+0x1f>
jp     112f <distances_to_dihedral+0x1f>
movsd  0xed6(%rip),%xmm2
jmp    11f6 <distances_to_dihedral+0xe6>
movapd %xmm4,%xmm6
mulsd  %xmm4,%xmm6
movapd %xmm0,%xmm7
mulsd  %xmm0,%xmm7
addsd  %xmm6,%xmm7
mulsd  %xmm2,%xmm2
subsd  %xmm2,%xmm7
mulsd  0xeb5(%rip),%xmm7
movapd %xmm0,%xmm9
mulsd  %xmm4,%xmm9
movapd %xmm3,%xmm6
mulsd  %xmm3,%xmm6
unpcklpd %xmm0,%xmm4
unpcklpd %xmm6,%xmm6
movapd %xmm4,%xmm2
mulpd  %xmm4,%xmm2
addpd  %xmm6,%xmm2
unpcklpd %xmm1,%xmm5
mulpd  %xmm5,%xmm5
subpd  %xmm5,%xmm2
mulpd  0xe83(%rip),%xmm2
divsd  %xmm9,%xmm7
unpcklpd %xmm3,%xmm3
mulpd  %xmm4,%xmm3
divpd  %xmm3,%xmm2
movapd 0xe7a(%rip),%xmm0
xorpd  %xmm2,%xmm0
movapd %xmm2,%xmm1
mulpd  %xmm2,%xmm1
movapd 0xe76(%rip),%xmm3
subpd  %xmm1,%xmm3
unpckhpd %xmm2,%xmm2
mulsd  %xmm0,%xmm2
addsd  %xmm7,%xmm2
movapd %xmm3,%xmm0
unpckhpd %xmm3,%xmm0
mulsd  %xmm3,%xmm0
ucomisd %xmm8,%xmm0
jb     11e3 <distances_to_dihedral+0xd3>
sqrtsd %xmm0,%xmm0
jmp    11f2 <distances_to_dihedral+0xe2>
movapd %xmm2,(%rsp)
call   1030 <sqrt@plt>
movapd (%rsp),%xmm2
divsd  %xmm0,%xmm2
movapd %xmm2,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @distances_to_dihedral(double %0, double %1, double %2, double %3, double %4, double %5) {
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
store double %0, double* %8
store double %1, double* %9
store double %2, double* %10
store double %3, double* %11
store double %4, double* %12
store double %5, double* %13
%19 = load double, double* %10
%20 = fcmp oeq double %19, 0.000000e+00
br i1 %20, label %21, label %22
21: ; preds = %6
store double 1.000000e+00, double* %7
br label %86
22: ; preds = %6
%23 = load double, double* %8
%24 = load double, double* %8
%25 = load double, double* %12
%26 = load double, double* %12
%27 = fmul double %25, %26
%28 = call double @llvm.fmuladd.f64(double %23, double %24, double %27)
%29 = load double, double* %10
%30 = load double, double* %10
%31 = fneg double %29
%32 = call double @llvm.fmuladd.f64(double %31, double %30, double %28)
%33 = fmul double 5.000000e-01, %32
%34 = load double, double* %8
%35 = load double, double* %12
%36 = fmul double %34, %35
%37 = fdiv double %33, %36
store double %37, double* %14
%38 = load double, double* %12
%39 = load double, double* %12
%40 = load double, double* %11
%41 = load double, double* %11
%42 = fmul double %40, %41
%43 = call double @llvm.fmuladd.f64(double %38, double %39, double %42)
%44 = load double, double* %13
%45 = load double, double* %13
%46 = fneg double %44
%47 = call double @llvm.fmuladd.f64(double %46, double %45, double %43)
%48 = fmul double 5.000000e-01, %47
%49 = load double, double* %12
%50 = load double, double* %11
%51 = fmul double %49, %50
%52 = fdiv double %48, %51
store double %52, double* %15
%53 = load double, double* %8
%54 = load double, double* %8
%55 = load double, double* %11
%56 = load double, double* %11
%57 = fmul double %55, %56
%58 = call double @llvm.fmuladd.f64(double %53, double %54, double %57)
%59 = load double, double* %9
%60 = load double, double* %9
%61 = fneg double %59
%62 = call double @llvm.fmuladd.f64(double %61, double %60, double %58)
%63 = fmul double 5.000000e-01, %62
%64 = load double, double* %8
%65 = load double, double* %11
%66 = fmul double %64, %65
%67 = fdiv double %63, %66
store double %67, double* %16
%68 = load double, double* %15
%69 = load double, double* %15
%70 = fneg double %68
%71 = call double @llvm.fmuladd.f64(double %70, double %69, double 1.000000e+00)
store double %71, double* %17
%72 = load double, double* %16
%73 = load double, double* %16
%74 = fneg double %72
%75 = call double @llvm.fmuladd.f64(double %74, double %73, double 1.000000e+00)
store double %75, double* %18
%76 = load double, double* %14
%77 = load double, double* %15
%78 = load double, double* %16
%79 = fneg double %77
%80 = call double @llvm.fmuladd.f64(double %79, double %78, double %76)
%81 = load double, double* %17
%82 = load double, double* %18
%83 = fmul double %81, %82
%84 = call double @sqrt(double %83)
%85 = fdiv double %80, %84
store double %85, double* %7
br label %86
86: ; preds = %22, %21
%87 = load double, double* %7
ret double %87
}

LLVM IR (-O2):
define double @distances_to_dihedral(double %0, double %1, double %2, double %3, double %4, double %5) {
%7 = fcmp oeq double %2, 0.000000e+00
br i1 %7, label %41, label %8
8: ; preds = %6
%9 = fmul double %4, %4
%10 = tail call double @llvm.fmuladd.f64(double %0, double %0, double %9)
%11 = fneg double %2
%12 = tail call double @llvm.fmuladd.f64(double %11, double %2, double %10)
%13 = fmul double %12, 5.000000e-01
%14 = fmul double %0, %4
%15 = fdiv double %13, %14
%16 = fmul double %3, %3
%17 = insertelement <2 x double> poison, double %4, i64 0
%18 = insertelement <2 x double> %17, double %0, i64 1
%19 = insertelement <2 x double> poison, double %16, i64 0
%20 = shufflevector <2 x double> %19, <2 x double> poison, <2 x i32> zeroinitializer
%21 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %18, <2 x double> %18, <2 x double> %20)
%22 = insertelement <2 x double> poison, double %5, i64 0
%23 = insertelement <2 x double> %22, double %1, i64 1
%24 = fneg <2 x double> %23
%25 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %24, <2 x double> %23, <2 x double> %21)
%26 = fmul <2 x double> %25, <double 5.000000e-01, double 5.000000e-01>
%27 = insertelement <2 x double> poison, double %3, i64 0
%28 = shufflevector <2 x double> %27, <2 x double> poison, <2 x i32> zeroinitializer
%29 = fmul <2 x double> %18, %28
%30 = fdiv <2 x double> %26, %29
%31 = fneg <2 x double> %30
%32 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %31, <2 x double> %30, <2 x double> <double 1.000000e+00, double 1.000000e+00>)
%33 = extractelement <2 x double> %31, i64 0
%34 = extractelement <2 x double> %30, i64 1
%35 = tail call double @llvm.fmuladd.f64(double %33, double %34, double %15)
%36 = shufflevector <2 x double> %32, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%37 = fmul <2 x double> %32, %36
%38 = extractelement <2 x double> %37, i64 0
%39 = tail call double @sqrt(double %38)
%40 = fdiv double %35, %39
br label %41
41: ; preds = %6, %8
%42 = phi double [ %40, %8 ], [ 1.000000e+00, %6 ]
ret double %42
}