#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 dot_product(double *, double *);
int /*<<< orphan*/ normalize(double *);
double angle_between_points(double *start, double *middle, double *end) {
  double angle, dp, v1[3], v2[3];
  v1[0] = middle[0] - start[0];
  v1[1] = middle[1] - start[1];
  v1[2] = middle[2] - start[2];
  v2[0] = end[0] - middle[0];
  v2[1] = end[1] - middle[1];
  v2[2] = end[2] - middle[2];
  normalize(v1);
  normalize(v2);
  dp = dot_product(v1, v2);
  if (dp >= 1.0) {
    angle = 0;
  } else {
    angle = acos(dp);
  }
  angle = angle * 180 / 3.14159265359;
  return angle;
}


x86 assembly (clang, -O0):
<angle_between_points>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
subsd  (%rax),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x8(%rbp),%rax
subsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x8(%rbp),%rax
subsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
subsd  (%rax),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
subsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
subsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x50(%rbp)
lea    -0x40(%rbp),%rdi
call   1040 <normalize@plt>
lea    -0x60(%rbp),%rdi
call   1040 <normalize@plt>
lea    -0x40(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1050 <dot_product@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xe05(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1212 <angle_between_points+0xe2>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1221 <angle_between_points+0xf1>
movsd  -0x28(%rbp),%xmm0
call   1030 <acos@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  0xde7(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  0xdd2(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<angle_between_points>:
push   %r14
push   %rbx
sub    $0x38,%rsp
movupd (%rsi),%xmm0
movupd (%rdi),%xmm1
movapd %xmm0,%xmm2
subpd  %xmm1,%xmm2
movapd %xmm2,0x20(%rsp)
movsd  0x10(%rsi),%xmm1
movapd %xmm1,%xmm2
subsd  0x10(%rdi),%xmm2
movsd  %xmm2,0x30(%rsp)
movupd (%rdx),%xmm2
subpd  %xmm0,%xmm2
movapd %xmm2,(%rsp)
movsd  0x10(%rdx),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%rsp)
lea    0x20(%rsp),%r14
mov    %r14,%rdi
call   1040 <normalize@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1040 <normalize@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <dot_product@plt>
movapd %xmm0,%xmm1
xorpd  %xmm0,%xmm0
ucomisd 0xe50(%rip),%xmm1
jae    11c3 <angle_between_points+0x93>
movapd %xmm1,%xmm0
call   1030 <acos@plt>
mulsd  0xe45(%rip),%xmm0
divsd  0xe45(%rip),%xmm0
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define double @angle_between_points(double* %0, double* %1, double* %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca double*
%7 = alloca double
%8 = alloca double
%9 = alloca [3 x double]
%10 = alloca [3 x double]
store double* %0, double** %4
store double* %1, double** %5
store double* %2, double** %6
%11 = load double*, double** %5
%12 = getelementptr inbounds double, double* %11, i64 0
%13 = load double, double* %12
%14 = load double*, double** %4
%15 = getelementptr inbounds double, double* %14, i64 0
%16 = load double, double* %15
%17 = fsub double %13, %16
%18 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0, i64 0
store double %17, double* %18
%19 = load double*, double** %5
%20 = getelementptr inbounds double, double* %19, i64 1
%21 = load double, double* %20
%22 = load double*, double** %4
%23 = getelementptr inbounds double, double* %22, i64 1
%24 = load double, double* %23
%25 = fsub double %21, %24
%26 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0, i64 1
store double %25, double* %26
%27 = load double*, double** %5
%28 = getelementptr inbounds double, double* %27, i64 2
%29 = load double, double* %28
%30 = load double*, double** %4
%31 = getelementptr inbounds double, double* %30, i64 2
%32 = load double, double* %31
%33 = fsub double %29, %32
%34 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0, i64 2
store double %33, double* %34
%35 = load double*, double** %6
%36 = getelementptr inbounds double, double* %35, i64 0
%37 = load double, double* %36
%38 = load double*, double** %5
%39 = getelementptr inbounds double, double* %38, i64 0
%40 = load double, double* %39
%41 = fsub double %37, %40
%42 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 0
store double %41, double* %42
%43 = load double*, double** %6
%44 = getelementptr inbounds double, double* %43, i64 1
%45 = load double, double* %44
%46 = load double*, double** %5
%47 = getelementptr inbounds double, double* %46, i64 1
%48 = load double, double* %47
%49 = fsub double %45, %48
%50 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 1
store double %49, double* %50
%51 = load double*, double** %6
%52 = getelementptr inbounds double, double* %51, i64 2
%53 = load double, double* %52
%54 = load double*, double** %5
%55 = getelementptr inbounds double, double* %54, i64 2
%56 = load double, double* %55
%57 = fsub double %53, %56
%58 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 2
store double %57, double* %58
%59 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0, i64 0
%60 = call i32 @normalize(double* %59)
%61 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 0
%62 = call i32 @normalize(double* %61)
%63 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0, i64 0
%64 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 0
%65 = call double @dot_product(double* %63, double* %64)
store double %65, double* %8
%66 = load double, double* %8
%67 = fcmp oge double %66, 1.000000e+00
br i1 %67, label %68, label %69
68: ; preds = %3
store double 0.000000e+00, double* %7
br label %72
69: ; preds = %3
%70 = load double, double* %8
%71 = call double @acos(double %70)
store double %71, double* %7
br label %72
72: ; preds = %69, %68
%73 = load double, double* %7
%74 = fmul double %73, 1.800000e+02
%75 = fdiv double %74, 0x400921FB54442EEA
store double %75, double* %7
%76 = load double, double* %7
ret double %76
}

LLVM IR (-O2):
define double @angle_between_points(double* nocapture %0, double* nocapture %1, double* nocapture %2) {
%4 = alloca [3 x double]
%5 = alloca [3 x double]
%6 = bitcast [3 x double]* %4 to i8*
%7 = bitcast [3 x double]* %5 to i8*
%8 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 0
%9 = bitcast double* %1 to <2 x double>*
%10 = load <2 x double>, <2 x double>* %9
%11 = bitcast double* %0 to <2 x double>*
%12 = load <2 x double>, <2 x double>* %11
%13 = fsub <2 x double> %10, %12
%14 = bitcast [3 x double]* %4 to <2 x double>*
store <2 x double> %13, <2 x double>* %14
%15 = getelementptr inbounds double, double* %1, i64 2
%16 = load double, double* %15
%17 = getelementptr inbounds double, double* %0, i64 2
%18 = load double, double* %17
%19 = fsub double %16, %18
%20 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 2
store double %19, double* %20
%21 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 0
%22 = bitcast double* %2 to <2 x double>*
%23 = load <2 x double>, <2 x double>* %22
%24 = fsub <2 x double> %23, %10
%25 = bitcast [3 x double]* %5 to <2 x double>*
store <2 x double> %24, <2 x double>* %25
%26 = getelementptr inbounds double, double* %2, i64 2
%27 = load double, double* %26
%28 = fsub double %27, %16
%29 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 2
store double %28, double* %29
%30 = call i32 @normalize(double* %8)
%31 = call i32 @normalize(double* %21)
%32 = call double @dot_product(double* %8, double* %21)
%33 = fcmp ult double %32, 1.000000e+00
br i1 %33, label %34, label %37
34: ; preds = %3
%35 = call double @acos(double %32)
%36 = fmul double %35, 1.800000e+02
br label %37
37: ; preds = %3, %34
%38 = phi double [ %36, %34 ], [ 0.000000e+00, %3 ]
%39 = fdiv double %38, 0x400921FB54442EEA
ret double %39
}