#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 acos(double);
double sqrt(double);
double calc_dihedral_radians(double atom1x, double atom1y, double atom1z,
                             double atom2x, double atom2y, double atom2z,
                             double atom3x, double atom3y, double atom3z,
                             double atom4x, double atom4y, double atom4z) {
  double vector1x, vector1y, vector1z;
  double vector2x, vector2y, vector2z;
  double vector3x, vector3y, vector3z;
  double v1Xv2xv2Xv3;
  double v1Xv2;
  double v2Xv3;
  double cosdihe;
  double dihedral;
  double sign;
  vector1x = atom2x - atom1x;
  vector1y = atom2y - atom1y;
  vector1z = atom2z - atom1z;
  vector2x = atom2x - atom3x;
  vector2y = atom2y - atom3y;
  vector2z = atom2z - atom3z;
  vector3x = atom3x - atom4x;
  vector3y = atom3y - atom4y;
  vector3z = atom3z - atom4z;
  v1Xv2xv2Xv3 = (vector1y * vector2z - vector1z * vector2y) *
                    (vector2y * vector3z - vector2z * vector3y) +
                (vector2x * vector1z - vector1x * vector2z) *
                    (vector3x * vector2z - vector2x * vector3z) +
                (vector1x * vector2y - vector2x * vector1y) *
                    (vector2x * vector3y - vector3x * vector2y);
  v1Xv2 = (vector1y * vector2z - vector1z * vector2y) *
              (vector1y * vector2z - vector1z * vector2y) +
          (vector2x * vector1z - vector1x * vector2z) *
              (vector2x * vector1z - vector1x * vector2z) +
          (vector1x * vector2y - vector2x * vector1y) *
              (vector1x * vector2y - vector2x * vector1y);
  v2Xv3 = (vector2y * vector3z - vector2z * vector3y) *
              (vector2y * vector3z - vector2z * vector3y) +
          (vector3x * vector2z - vector2x * vector3z) *
              (vector3x * vector2z - vector2x * vector3z) +
          (vector2x * vector3y - vector3x * vector2y) *
              (vector2x * vector3y - vector3x * vector2y);
  cosdihe = v1Xv2xv2Xv3 / sqrt(v1Xv2 * v2Xv3);
  if (cosdihe > 1.0)
    cosdihe = 1.0;
  if (cosdihe < -1.0)
    cosdihe = -1.0;
  dihedral = acos(cosdihe);
  sign = vector1x * (vector2y * vector3z - vector3y * vector2z) -
         vector1y * (vector2x * vector3z - vector3x * vector2z) +
         vector1z * (vector2x * vector3y - vector3x * vector2y);
  if (sign > 0) {
    if (dihedral >= 0)
      return dihedral;
    if (dihedral < 0)
      return -dihedral;
  } else if (sign < 0) {
    if (dihedral > 0)
      return -dihedral;
    if (dihedral <= 0)
      return dihedral;
  }
  return dihedral;
}


x86 assembly (clang, -O0):
<calc_dihedral_radians>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
movsd  0x28(%rbp),%xmm8
movsd  0x20(%rbp),%xmm8
movsd  0x18(%rbp),%xmm8
movsd  0x10(%rbp),%xmm8
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  %xmm6,-0x40(%rbp)
movsd  %xmm7,-0x48(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x30(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x38(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x30(%rbp),%xmm0
subsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x38(%rbp),%xmm0
subsd  0x10(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x40(%rbp),%xmm0
subsd  0x18(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x48(%rbp),%xmm0
subsd  0x20(%rbp),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  0x10(%rbp),%xmm0
subsd  0x28(%rbp),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x58(%rbp),%xmm1
movsd  -0x78(%rbp),%xmm2
movsd  -0x60(%rbp),%xmm0
mulsd  -0x70(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x70(%rbp),%xmm2
movsd  -0x90(%rbp),%xmm3
ff
movsd  -0x78(%rbp),%xmm0
mulsd  -0x88(%rbp),%xmm0
ff
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm3,%xmm2
addsd  %xmm0,%xmm2
movsd  -0x68(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm4
movsd  -0x50(%rbp),%xmm3
mulsd  -0x78(%rbp),%xmm3
movq   %xmm3,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm3
mulsd  %xmm4,%xmm0
addsd  %xmm3,%xmm0
movsd  -0x80(%rbp),%xmm3
movsd  -0x78(%rbp),%xmm5
movsd  -0x68(%rbp),%xmm4
mulsd  -0x90(%rbp),%xmm4
ff
movq   %xmm4,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm4
mulsd  %xmm5,%xmm3
addsd  %xmm4,%xmm3
mulsd  %xmm3,%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
movsd  -0x70(%rbp),%xmm3
movsd  -0x68(%rbp),%xmm2
mulsd  -0x58(%rbp),%xmm2
movq   %xmm2,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
mulsd  %xmm3,%xmm0
addsd  %xmm2,%xmm0
movsd  -0x68(%rbp),%xmm2
movsd  -0x88(%rbp),%xmm4
ff
movsd  -0x80(%rbp),%xmm3
mulsd  -0x70(%rbp),%xmm3
movq   %xmm3,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm3
mulsd  %xmm4,%xmm2
addsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x58(%rbp),%xmm1
movsd  -0x78(%rbp),%xmm2
movsd  -0x60(%rbp),%xmm0
mulsd  -0x70(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm2
movsd  -0x78(%rbp),%xmm3
movsd  -0x60(%rbp),%xmm0
mulsd  -0x70(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm3,%xmm2
addsd  %xmm0,%xmm2
movsd  -0x68(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm4
movsd  -0x50(%rbp),%xmm3
mulsd  -0x78(%rbp),%xmm3
movq   %xmm3,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm3
mulsd  %xmm4,%xmm0
addsd  %xmm3,%xmm0
movsd  -0x68(%rbp),%xmm3
movsd  -0x60(%rbp),%xmm5
movsd  -0x50(%rbp),%xmm4
mulsd  -0x78(%rbp),%xmm4
movq   %xmm4,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm4
mulsd  %xmm5,%xmm3
addsd  %xmm4,%xmm3
mulsd  %xmm3,%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
movsd  -0x70(%rbp),%xmm3
movsd  -0x68(%rbp),%xmm2
mulsd  -0x58(%rbp),%xmm2
movq   %xmm2,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
mulsd  %xmm3,%xmm0
addsd  %xmm2,%xmm0
movsd  -0x50(%rbp),%xmm2
movsd  -0x70(%rbp),%xmm4
movsd  -0x68(%rbp),%xmm3
mulsd  -0x58(%rbp),%xmm3
movq   %xmm3,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm3
mulsd  %xmm4,%xmm2
addsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0x70(%rbp),%xmm1
movsd  -0x90(%rbp),%xmm2
ff
movsd  -0x78(%rbp),%xmm0
mulsd  -0x88(%rbp),%xmm0
ff
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x70(%rbp),%xmm2
movsd  -0x90(%rbp),%xmm3
ff
movsd  -0x78(%rbp),%xmm0
mulsd  -0x88(%rbp),%xmm0
ff
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm3,%xmm2
addsd  %xmm0,%xmm2
movsd  -0x80(%rbp),%xmm0
movsd  -0x78(%rbp),%xmm4
movsd  -0x68(%rbp),%xmm3
mulsd  -0x90(%rbp),%xmm3
ff
movq   %xmm3,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm3
mulsd  %xmm4,%xmm0
addsd  %xmm3,%xmm0
movsd  -0x80(%rbp),%xmm3
movsd  -0x78(%rbp),%xmm5
movsd  -0x68(%rbp),%xmm4
mulsd  -0x90(%rbp),%xmm4
ff
movq   %xmm4,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm4
mulsd  %xmm5,%xmm3
addsd  %xmm4,%xmm3
mulsd  %xmm3,%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
movsd  -0x88(%rbp),%xmm3
ff
movsd  -0x80(%rbp),%xmm2
mulsd  -0x70(%rbp),%xmm2
movq   %xmm2,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
mulsd  %xmm3,%xmm0
addsd  %xmm2,%xmm0
movsd  -0x68(%rbp),%xmm2
movsd  -0x88(%rbp),%xmm4
ff
movsd  -0x80(%rbp),%xmm3
mulsd  -0x70(%rbp),%xmm3
movq   %xmm3,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm3
mulsd  %xmm4,%xmm2
addsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
movsd  -0x98(%rbp),%xmm0
ff
movsd  %xmm0,-0xc8(%rbp)
ff
movsd  -0xa0(%rbp),%xmm0
ff
mulsd  -0xa8(%rbp),%xmm0
ff
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0xc8(%rbp),%xmm0
ff
divsd  %xmm1,%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  -0xb0(%rbp),%xmm0
ff
movsd  0x9ae(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    166c <calc_dihedral_radians+0x54c>
movsd  0x99c(%rip),%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  0x994(%rip),%xmm0
ucomisd -0xb0(%rbp),%xmm0
ff
jbe    1692 <calc_dihedral_radians+0x572>
movsd  0x97e(%rip),%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  -0xb0(%rbp),%xmm0
ff
call   1030 <acos@plt>
movsd  %xmm0,-0xb8(%rbp)
ff
movsd  -0x50(%rbp),%xmm1
movsd  -0x70(%rbp),%xmm2
movsd  -0x90(%rbp),%xmm3
ff
movsd  -0x88(%rbp),%xmm0
ff
mulsd  -0x78(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm3,%xmm2
addsd  %xmm0,%xmm2
movsd  -0x58(%rbp),%xmm0
movsd  -0x68(%rbp),%xmm3
movsd  -0x90(%rbp),%xmm5
ff
movsd  -0x80(%rbp),%xmm4
mulsd  -0x78(%rbp),%xmm4
movq   %xmm4,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm4
mulsd  %xmm5,%xmm3
addsd  %xmm4,%xmm3
mulsd  %xmm3,%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
movsd  -0x68(%rbp),%xmm2
movsd  -0x88(%rbp),%xmm4
ff
movsd  -0x80(%rbp),%xmm3
mulsd  -0x70(%rbp),%xmm3
movq   %xmm3,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm3
mulsd  %xmm4,%xmm2
addsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xc0(%rbp)
ff
movsd  -0xc0(%rbp),%xmm0
ff
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1809 <calc_dihedral_radians+0x6e9>
movsd  -0xb8(%rbp),%xmm0
ff
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     17ca <calc_dihedral_radians+0x6aa>
movsd  -0xb8(%rbp),%xmm0
ff
movsd  %xmm0,-0x8(%rbp)
jmp    1892 <calc_dihedral_radians+0x772>
xorps  %xmm0,%xmm0
ucomisd -0xb8(%rbp),%xmm0
ff
jbe    1804 <calc_dihedral_radians+0x6e4>
movsd  -0xb8(%rbp),%xmm0
ff
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1892 <calc_dihedral_radians+0x772>
jmp    1885 <calc_dihedral_radians+0x765>
xorps  %xmm0,%xmm0
ucomisd -0xc0(%rbp),%xmm0
ff
jbe    1880 <calc_dihedral_radians+0x760>
movsd  -0xb8(%rbp),%xmm0
ff
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1858 <calc_dihedral_radians+0x738>
movsd  -0xb8(%rbp),%xmm0
ff
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1892 <calc_dihedral_radians+0x772>
xorps  %xmm0,%xmm0
ucomisd -0xb8(%rbp),%xmm0
ff
jb     187b <calc_dihedral_radians+0x75b>
movsd  -0xb8(%rbp),%xmm0
ff
movsd  %xmm0,-0x8(%rbp)
jmp    1892 <calc_dihedral_radians+0x772>
jmp    1880 <calc_dihedral_radians+0x760>
jmp    1885 <calc_dihedral_radians+0x765>
movsd  -0xb8(%rbp),%xmm0
ff
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calc_dihedral_radians>:
sub    $0x98,%rsp
movapd %xmm4,%xmm9
subsd  %xmm1,%xmm9
movapd %xmm5,%xmm1
subsd  %xmm2,%xmm1
unpcklpd %xmm3,%xmm3
unpcklpd %xmm6,%xmm0
subpd  %xmm0,%xmm3
subsd  0xa8(%rsp),%xmm6
unpcklpd %xmm7,%xmm4
movhpd 0xb0(%rsp),%xmm7
subpd  %xmm7,%xmm4
movsd  0xa0(%rsp),%xmm0
unpcklpd %xmm0,%xmm5
movhpd 0xb8(%rsp),%xmm0
subpd  %xmm0,%xmm5
movapd %xmm1,0x80(%rsp)
movapd %xmm1,%xmm0
unpcklpd %xmm5,%xmm0
movapd %xmm4,%xmm8
mulpd  %xmm0,%xmm8
movapd %xmm9,0x50(%rsp)
movapd %xmm9,%xmm2
unpcklpd %xmm4,%xmm2
movapd 0xe53(%rip),%xmm9
movapd %xmm3,%xmm1
xorpd  %xmm9,%xmm1
movapd %xmm3,%xmm7
shufpd $0x1,%xmm6,%xmm7
xorpd  %xmm7,%xmm9
mulpd  %xmm7,%xmm0
mulpd  %xmm2,%xmm7
mulpd  %xmm5,%xmm2
subpd  %xmm8,%xmm2
movapd %xmm3,%xmm6
unpckhpd %xmm3,%xmm6
movapd %xmm6,0x30(%rsp)
movapd %xmm9,0x40(%rsp)
unpcklpd %xmm9,%xmm1
movapd %xmm5,0x60(%rsp)
mulpd  %xmm5,%xmm1
addpd  %xmm1,%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm2,%xmm5
unpckhpd %xmm2,%xmm5
movapd %xmm5,0x20(%rsp)
mulsd  %xmm2,%xmm5
addsd  %xmm1,%xmm5
movapd %xmm3,0x70(%rsp)
mulpd  %xmm3,%xmm4
subpd  %xmm7,%xmm4
movapd %xmm4,%xmm1
unpckhpd %xmm4,%xmm1
movapd %xmm1,0x10(%rsp)
movapd %xmm1,%xmm3
mulsd  %xmm4,%xmm3
addsd  %xmm5,%xmm3
mulpd  %xmm0,%xmm0
mulpd  %xmm2,%xmm2
addpd  %xmm0,%xmm2
mulpd  %xmm4,%xmm4
addpd  %xmm2,%xmm4
movapd %xmm4,%xmm0
unpckhpd %xmm4,%xmm0
mulsd  %xmm4,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1277 <calc_dihedral_radians+0x157>
sqrtsd %xmm0,%xmm0
jmp    1286 <calc_dihedral_radians+0x166>
movapd %xmm3,(%rsp)
call   1040 <sqrt@plt>
movapd (%rsp),%xmm3
divsd  %xmm0,%xmm3
movsd  0xd7e(%rip),%xmm1
minsd  %xmm3,%xmm1
movsd  0xd7a(%rip),%xmm0
maxsd  %xmm1,%xmm0
call   1030 <acos@plt>
movapd 0x40(%rsp),%xmm2
unpckhpd %xmm2,%xmm2
movapd 0x60(%rsp),%xmm1
mulsd  %xmm1,%xmm2
unpckhpd %xmm1,%xmm1
movapd 0x30(%rsp),%xmm3
mulsd  %xmm1,%xmm3
addsd  %xmm2,%xmm3
mulsd  0x50(%rsp),%xmm3
movapd 0x70(%rsp),%xmm1
mulsd  0x20(%rsp),%xmm1
subsd  %xmm3,%xmm1
movapd 0x80(%rsp),%xmm2
mulsd  0x10(%rsp),%xmm2
addsd  %xmm1,%xmm2
ucomisd 0xd22(%rip),%xmm2
jbe    1311 <calc_dihedral_radians+0x1f1>
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
seta   %al
test   %al,%al
jne    1329 <calc_dihedral_radians+0x209>
jmp    1331 <calc_dihedral_radians+0x211>
xorpd  %xmm1,%xmm1
ucomisd %xmm2,%xmm1
seta   %cl
ucomisd %xmm1,%xmm0
seta   %al
and    %cl,%al
test   %al,%al
je     1331 <calc_dihedral_radians+0x211>
xorpd  0xccf(%rip),%xmm0
add    $0x98,%rsp
ret

LLVM IR (-O0):
define double @calc_dihedral_radians(double %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7, double %8, double %9, double %10, double %11) {
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca double
%22 = alloca double
%23 = alloca double
%24 = alloca double
%25 = alloca double
%26 = alloca double
%27 = alloca double
%28 = alloca double
%29 = alloca double
%30 = alloca double
%31 = alloca double
%32 = alloca double
%33 = alloca double
%34 = alloca double
%35 = alloca double
%36 = alloca double
%37 = alloca double
%38 = alloca double
%39 = alloca double
%40 = alloca double
store double %0, double* %14
store double %1, double* %15
store double %2, double* %16
store double %3, double* %17
store double %4, double* %18
store double %5, double* %19
store double %6, double* %20
store double %7, double* %21
store double %8, double* %22
store double %9, double* %23
store double %10, double* %24
store double %11, double* %25
%41 = load double, double* %17
%42 = load double, double* %14
%43 = fsub double %41, %42
store double %43, double* %26
%44 = load double, double* %18
%45 = load double, double* %15
%46 = fsub double %44, %45
store double %46, double* %27
%47 = load double, double* %19
%48 = load double, double* %16
%49 = fsub double %47, %48
store double %49, double* %28
%50 = load double, double* %17
%51 = load double, double* %20
%52 = fsub double %50, %51
store double %52, double* %29
%53 = load double, double* %18
%54 = load double, double* %21
%55 = fsub double %53, %54
store double %55, double* %30
%56 = load double, double* %19
%57 = load double, double* %22
%58 = fsub double %56, %57
store double %58, double* %31
%59 = load double, double* %20
%60 = load double, double* %23
%61 = fsub double %59, %60
store double %61, double* %32
%62 = load double, double* %21
%63 = load double, double* %24
%64 = fsub double %62, %63
store double %64, double* %33
%65 = load double, double* %22
%66 = load double, double* %25
%67 = fsub double %65, %66
store double %67, double* %34
%68 = load double, double* %27
%69 = load double, double* %31
%70 = load double, double* %28
%71 = load double, double* %30
%72 = fmul double %70, %71
%73 = fneg double %72
%74 = call double @llvm.fmuladd.f64(double %68, double %69, double %73)
%75 = load double, double* %30
%76 = load double, double* %34
%77 = load double, double* %31
%78 = load double, double* %33
%79 = fmul double %77, %78
%80 = fneg double %79
%81 = call double @llvm.fmuladd.f64(double %75, double %76, double %80)
%82 = load double, double* %29
%83 = load double, double* %28
%84 = load double, double* %26
%85 = load double, double* %31
%86 = fmul double %84, %85
%87 = fneg double %86
%88 = call double @llvm.fmuladd.f64(double %82, double %83, double %87)
%89 = load double, double* %32
%90 = load double, double* %31
%91 = load double, double* %29
%92 = load double, double* %34
%93 = fmul double %91, %92
%94 = fneg double %93
%95 = call double @llvm.fmuladd.f64(double %89, double %90, double %94)
%96 = fmul double %88, %95
%97 = call double @llvm.fmuladd.f64(double %74, double %81, double %96)
%98 = load double, double* %26
%99 = load double, double* %30
%100 = load double, double* %29
%101 = load double, double* %27
%102 = fmul double %100, %101
%103 = fneg double %102
%104 = call double @llvm.fmuladd.f64(double %98, double %99, double %103)
%105 = load double, double* %29
%106 = load double, double* %33
%107 = load double, double* %32
%108 = load double, double* %30
%109 = fmul double %107, %108
%110 = fneg double %109
%111 = call double @llvm.fmuladd.f64(double %105, double %106, double %110)
%112 = call double @llvm.fmuladd.f64(double %104, double %111, double %97)
store double %112, double* %35
%113 = load double, double* %27
%114 = load double, double* %31
%115 = load double, double* %28
%116 = load double, double* %30
%117 = fmul double %115, %116
%118 = fneg double %117
%119 = call double @llvm.fmuladd.f64(double %113, double %114, double %118)
%120 = load double, double* %27
%121 = load double, double* %31
%122 = load double, double* %28
%123 = load double, double* %30
%124 = fmul double %122, %123
%125 = fneg double %124
%126 = call double @llvm.fmuladd.f64(double %120, double %121, double %125)
%127 = load double, double* %29
%128 = load double, double* %28
%129 = load double, double* %26
%130 = load double, double* %31
%131 = fmul double %129, %130
%132 = fneg double %131
%133 = call double @llvm.fmuladd.f64(double %127, double %128, double %132)
%134 = load double, double* %29
%135 = load double, double* %28
%136 = load double, double* %26
%137 = load double, double* %31
%138 = fmul double %136, %137
%139 = fneg double %138
%140 = call double @llvm.fmuladd.f64(double %134, double %135, double %139)
%141 = fmul double %133, %140
%142 = call double @llvm.fmuladd.f64(double %119, double %126, double %141)
%143 = load double, double* %26
%144 = load double, double* %30
%145 = load double, double* %29
%146 = load double, double* %27
%147 = fmul double %145, %146
%148 = fneg double %147
%149 = call double @llvm.fmuladd.f64(double %143, double %144, double %148)
%150 = load double, double* %26
%151 = load double, double* %30
%152 = load double, double* %29
%153 = load double, double* %27
%154 = fmul double %152, %153
%155 = fneg double %154
%156 = call double @llvm.fmuladd.f64(double %150, double %151, double %155)
%157 = call double @llvm.fmuladd.f64(double %149, double %156, double %142)
store double %157, double* %36
%158 = load double, double* %30
%159 = load double, double* %34
%160 = load double, double* %31
%161 = load double, double* %33
%162 = fmul double %160, %161
%163 = fneg double %162
%164 = call double @llvm.fmuladd.f64(double %158, double %159, double %163)
%165 = load double, double* %30
%166 = load double, double* %34
%167 = load double, double* %31
%168 = load double, double* %33
%169 = fmul double %167, %168
%170 = fneg double %169
%171 = call double @llvm.fmuladd.f64(double %165, double %166, double %170)
%172 = load double, double* %32
%173 = load double, double* %31
%174 = load double, double* %29
%175 = load double, double* %34
%176 = fmul double %174, %175
%177 = fneg double %176
%178 = call double @llvm.fmuladd.f64(double %172, double %173, double %177)
%179 = load double, double* %32
%180 = load double, double* %31
%181 = load double, double* %29
%182 = load double, double* %34
%183 = fmul double %181, %182
%184 = fneg double %183
%185 = call double @llvm.fmuladd.f64(double %179, double %180, double %184)
%186 = fmul double %178, %185
%187 = call double @llvm.fmuladd.f64(double %164, double %171, double %186)
%188 = load double, double* %29
%189 = load double, double* %33
%190 = load double, double* %32
%191 = load double, double* %30
%192 = fmul double %190, %191
%193 = fneg double %192
%194 = call double @llvm.fmuladd.f64(double %188, double %189, double %193)
%195 = load double, double* %29
%196 = load double, double* %33
%197 = load double, double* %32
%198 = load double, double* %30
%199 = fmul double %197, %198
%200 = fneg double %199
%201 = call double @llvm.fmuladd.f64(double %195, double %196, double %200)
%202 = call double @llvm.fmuladd.f64(double %194, double %201, double %187)
store double %202, double* %37
%203 = load double, double* %35
%204 = load double, double* %36
%205 = load double, double* %37
%206 = fmul double %204, %205
%207 = call double @sqrt(double %206)
%208 = fdiv double %203, %207
store double %208, double* %38
%209 = load double, double* %38
%210 = fcmp ogt double %209, 1.000000e+00
br i1 %210, label %211, label %212
211: ; preds = %12
store double 1.000000e+00, double* %38
br label %212
212: ; preds = %211, %12
%213 = load double, double* %38
%214 = fcmp olt double %213, -1.000000e+00
br i1 %214, label %215, label %216
215: ; preds = %212
store double -1.000000e+00, double* %38
br label %216
216: ; preds = %215, %212
%217 = load double, double* %38
%218 = call double @acos(double %217)
store double %218, double* %39
%219 = load double, double* %26
%220 = load double, double* %30
%221 = load double, double* %34
%222 = load double, double* %33
%223 = load double, double* %31
%224 = fmul double %222, %223
%225 = fneg double %224
%226 = call double @llvm.fmuladd.f64(double %220, double %221, double %225)
%227 = load double, double* %27
%228 = load double, double* %29
%229 = load double, double* %34
%230 = load double, double* %32
%231 = load double, double* %31
%232 = fmul double %230, %231
%233 = fneg double %232
%234 = call double @llvm.fmuladd.f64(double %228, double %229, double %233)
%235 = fmul double %227, %234
%236 = fneg double %235
%237 = call double @llvm.fmuladd.f64(double %219, double %226, double %236)
%238 = load double, double* %28
%239 = load double, double* %29
%240 = load double, double* %33
%241 = load double, double* %32
%242 = load double, double* %30
%243 = fmul double %241, %242
%244 = fneg double %243
%245 = call double @llvm.fmuladd.f64(double %239, double %240, double %244)
%246 = call double @llvm.fmuladd.f64(double %238, double %245, double %237)
store double %246, double* %40
%247 = load double, double* %40
%248 = fcmp ogt double %247, 0.000000e+00
br i1 %248, label %249, label %261
249: ; preds = %216
%250 = load double, double* %39
%251 = fcmp oge double %250, 0.000000e+00
br i1 %251, label %252, label %254
252: ; preds = %249
%253 = load double, double* %39
store double %253, double* %13
br label %279
254: ; preds = %249
%255 = load double, double* %39
%256 = fcmp olt double %255, 0.000000e+00
br i1 %256, label %257, label %260
257: ; preds = %254
%258 = load double, double* %39
%259 = fneg double %258
store double %259, double* %13
br label %279
260: ; preds = %254
br label %277
261: ; preds = %216
%262 = load double, double* %40
%263 = fcmp olt double %262, 0.000000e+00
br i1 %263, label %264, label %276
264: ; preds = %261
%265 = load double, double* %39
%266 = fcmp ogt double %265, 0.000000e+00
br i1 %266, label %267, label %270
267: ; preds = %264
%268 = load double, double* %39
%269 = fneg double %268
store double %269, double* %13
br label %279
270: ; preds = %264
%271 = load double, double* %39
%272 = fcmp ole double %271, 0.000000e+00
br i1 %272, label %273, label %275
273: ; preds = %270
%274 = load double, double* %39
store double %274, double* %13
br label %279
275: ; preds = %270
br label %276
276: ; preds = %275, %261
br label %277
277: ; preds = %276, %260
%278 = load double, double* %39
store double %278, double* %13
br label %279
279: ; preds = %277, %273, %267, %257, %252
%280 = load double, double* %13
ret double %280
}

LLVM IR (-O2):
define double @calc_dihedral_radians(double %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7, double %8, double %9, double %10, double %11) {
%13 = fsub double %4, %1
%14 = fsub double %5, %2
%15 = insertelement <2 x double> poison, double %3, i64 0
%16 = shufflevector <2 x double> %15, <2 x double> poison, <2 x i32> zeroinitializer
%17 = insertelement <2 x double> poison, double %0, i64 0
%18 = insertelement <2 x double> %17, double %6, i64 1
%19 = fsub <2 x double> %16, %18
%20 = fsub double %6, %9
%21 = insertelement <2 x double> poison, double %4, i64 0
%22 = insertelement <2 x double> %21, double %7, i64 1
%23 = insertelement <2 x double> poison, double %7, i64 0
%24 = insertelement <2 x double> %23, double %10, i64 1
%25 = fsub <2 x double> %22, %24
%26 = insertelement <2 x double> poison, double %5, i64 0
%27 = insertelement <2 x double> %26, double %8, i64 1
%28 = insertelement <2 x double> poison, double %8, i64 0
%29 = insertelement <2 x double> %28, double %11, i64 1
%30 = fsub <2 x double> %27, %29
%31 = insertelement <2 x double> poison, double %14, i64 0
%32 = shufflevector <2 x double> %31, <2 x double> %30, <2 x i32> <i32 0, i32 2>
%33 = fneg <2 x double> %32
%34 = fmul <2 x double> %25, %33
%35 = insertelement <2 x double> poison, double %13, i64 0
%36 = shufflevector <2 x double> %35, <2 x double> %25, <2 x i32> <i32 0, i32 2>
%37 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %36, <2 x double> %30, <2 x double> %34)
%38 = extractelement <2 x double> %19, i64 0
%39 = fneg double %38
%40 = extractelement <2 x double> %19, i64 1
%41 = insertelement <2 x double> poison, double %40, i64 0
%42 = insertelement <2 x double> %41, double %20, i64 1
%43 = fneg <2 x double> %42
%44 = insertelement <2 x double> poison, double %39, i64 0
%45 = shufflevector <2 x double> %44, <2 x double> %43, <2 x i32> <i32 0, i32 2>
%46 = fmul <2 x double> %30, %45
%47 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %42, <2 x double> %32, <2 x double> %46)
%48 = shufflevector <2 x double> %47, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%49 = fmul <2 x double> %47, %48
%50 = extractelement <2 x double> %49, i64 0
%51 = extractelement <2 x double> %37, i64 0
%52 = extractelement <2 x double> %37, i64 1
%53 = tail call double @llvm.fmuladd.f64(double %51, double %52, double %50)
%54 = fmul <2 x double> %36, %43
%55 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %19, <2 x double> %25, <2 x double> %54)
%56 = extractelement <2 x double> %55, i64 0
%57 = extractelement <2 x double> %55, i64 1
%58 = tail call double @llvm.fmuladd.f64(double %56, double %57, double %53)
%59 = fmul <2 x double> %47, %47
%60 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %37, <2 x double> %37, <2 x double> %59)
%61 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %55, <2 x double> %55, <2 x double> %60)
%62 = shufflevector <2 x double> %61, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%63 = fmul <2 x double> %61, %62
%64 = extractelement <2 x double> %63, i64 0
%65 = tail call double @sqrt(double %64)
%66 = fdiv double %58, %65
%67 = fcmp ogt double %66, 1.000000e+00
%68 = select i1 %67, double 1.000000e+00, double %66
%69 = fcmp olt double %68, -1.000000e+00
%70 = select i1 %69, double -1.000000e+00, double %68
%71 = tail call double @acos(double %70)
%72 = shufflevector <2 x double> %43, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%73 = fmul <2 x double> %30, %72
%74 = extractelement <2 x double> %73, i64 0
%75 = extractelement <2 x double> %30, i64 1
%76 = tail call double @llvm.fmuladd.f64(double %40, double %75, double %74)
%77 = fneg double %13
%78 = fmul double %76, %77
%79 = tail call double @llvm.fmuladd.f64(double %38, double %52, double %78)
%80 = tail call double @llvm.fmuladd.f64(double %14, double %57, double %79)
%81 = fcmp ogt double %80, 0.000000e+00
br i1 %81, label %82, label %84
82: ; preds = %12
%83 = fcmp olt double %71, 0.000000e+00
br label %88
84: ; preds = %12
%85 = fcmp olt double %80, 0.000000e+00
%86 = fcmp ogt double %71, 0.000000e+00
%87 = select i1 %85, i1 %86, i1 false
br label %88
88: ; preds = %84, %82
%89 = phi i1 [ %87, %84 ], [ %83, %82 ]
%90 = fneg double %71
%91 = select i1 %89, double %90, double %71
ret double %91
}