#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_angle_radians(double atom1x, double atom1y, double atom1z,
                          double atom2x, double atom2y, double atom2z,
                          double atom3x, double atom3y, double atom3z) {
  double temp_angle;
  double vector1[3];
  double vector2[3];
  double modvector1;
  double modvector2;
  double vectordot;
  vector1[0] = atom1x - atom2x;
  vector1[1] = atom1y - atom2y;
  vector1[2] = atom1z - atom2z;
  vector2[0] = atom3x - atom2x;
  vector2[1] = atom3y - atom2y;
  vector2[2] = atom3z - atom2z;
  modvector1 = sqrt((vector1[0] * vector1[0]) + (vector1[1] * vector1[1]) +
                    (vector1[2] * vector1[2]));
  modvector2 = sqrt((vector2[0] * vector2[0]) + (vector2[1] * vector2[1]) +
                    (vector2[2] * vector2[2]));
  vectordot = (vector1[0] * vector2[0]) + (vector1[1] * vector2[1]) +
              (vector1[2] * vector2[2]);
  temp_angle = acos(vectordot / (modvector1 * modvector2));
  return temp_angle;
}


x86 assembly (clang, -O0):
<calc_angle_radians>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movsd  0x10(%rbp),%xmm8
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  %xmm4,-0x28(%rbp)
movsd  %xmm5,-0x30(%rbp)
movsd  %xmm6,-0x38(%rbp)
movsd  %xmm7,-0x40(%rbp)
movsd  -0x8(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x38(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x40(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  0x10(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x60(%rbp),%xmm1
movsd  -0x60(%rbp),%xmm2
movsd  -0x58(%rbp),%xmm0
mulsd  -0x58(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x80(%rbp),%xmm1
movsd  -0x80(%rbp),%xmm2
movsd  -0x78(%rbp),%xmm0
mulsd  -0x78(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x70(%rbp),%xmm0
movsd  -0x70(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x60(%rbp),%xmm1
movsd  -0x80(%rbp),%xmm2
movsd  -0x58(%rbp),%xmm0
mulsd  -0x78(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
movsd  -0x70(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x98(%rbp),%xmm0
ff
movsd  -0x88(%rbp),%xmm1
ff
mulsd  -0x90(%rbp),%xmm1
ff
divsd  %xmm1,%xmm0
call   1030 <acos@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calc_angle_radians>:
sub    $0x38,%rsp
movsd  0x40(%rsp),%xmm8
subsd  %xmm3,%xmm0
subsd  %xmm4,%xmm1
subsd  %xmm5,%xmm2
subsd  %xmm3,%xmm6
subsd  %xmm4,%xmm7
subsd  %xmm5,%xmm8
movsd  %xmm1,0x20(%rsp)
movapd %xmm1,%xmm3
mulsd  %xmm1,%xmm3
movsd  %xmm0,0x28(%rsp)
movapd %xmm0,%xmm1
mulsd  %xmm0,%xmm1
addsd  %xmm3,%xmm1
movsd  %xmm2,0x30(%rsp)
movapd %xmm2,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
xorpd  %xmm3,%xmm3
ucomisd %xmm3,%xmm0
movsd  %xmm6,0x10(%rsp)
movsd  %xmm7,0x8(%rsp)
movsd  %xmm8,(%rsp)
jb     119b <calc_angle_radians+0x7b>
xorps  %xmm2,%xmm2
sqrtsd %xmm0,%xmm2
jmp    11ba <calc_angle_radians+0x9a>
call   1040 <sqrt@plt>
xorpd  %xmm3,%xmm3
movsd  (%rsp),%xmm8
movsd  0x8(%rsp),%xmm7
movsd  0x10(%rsp),%xmm6
movapd %xmm0,%xmm2
movapd %xmm7,%xmm0
mulsd  %xmm7,%xmm0
movapd %xmm6,%xmm1
mulsd  %xmm6,%xmm1
addsd  %xmm0,%xmm1
movapd %xmm8,%xmm0
mulsd  %xmm8,%xmm0
addsd  %xmm1,%xmm0
ucomisd %xmm3,%xmm0
jb     11e8 <calc_angle_radians+0xc8>
sqrtsd %xmm0,%xmm0
jmp    120b <calc_angle_radians+0xeb>
movsd  %xmm2,0x18(%rsp)
call   1040 <sqrt@plt>
movsd  0x18(%rsp),%xmm2
movsd  (%rsp),%xmm8
movsd  0x8(%rsp),%xmm7
movsd  0x10(%rsp),%xmm6
mulsd  %xmm0,%xmm2
movsd  0x20(%rsp),%xmm0
mulsd  %xmm7,%xmm0
movsd  0x28(%rsp),%xmm1
mulsd  %xmm6,%xmm1
addsd  %xmm0,%xmm1
movsd  0x30(%rsp),%xmm0
mulsd  %xmm8,%xmm0
addsd  %xmm1,%xmm0
divsd  %xmm2,%xmm0
add    $0x38,%rsp
jmp    1030 <acos@plt>

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

LLVM IR (-O2):
define double @calc_angle_radians(double %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7, double %8) {
%10 = fsub double %0, %3
%11 = fsub double %1, %4
%12 = fsub double %2, %5
%13 = fsub double %6, %3
%14 = fsub double %7, %4
%15 = fsub double %8, %5
%16 = fmul double %11, %11
%17 = tail call double @llvm.fmuladd.f64(double %10, double %10, double %16)
%18 = tail call double @llvm.fmuladd.f64(double %12, double %12, double %17)
%19 = tail call double @sqrt(double %18)
%20 = fmul double %14, %14
%21 = tail call double @llvm.fmuladd.f64(double %13, double %13, double %20)
%22 = tail call double @llvm.fmuladd.f64(double %15, double %15, double %21)
%23 = tail call double @sqrt(double %22)
%24 = fmul double %11, %14
%25 = tail call double @llvm.fmuladd.f64(double %10, double %13, double %24)
%26 = tail call double @llvm.fmuladd.f64(double %12, double %15, double %25)
%27 = fmul double %19, %23
%28 = fdiv double %26, %27
%29 = tail call double @acos(double %28)
ret double %29
}