#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 M_PI;
double acos(double);
double matCalcDot(double *, double *);
double matCalcLen(double *);
double matCalcAngle(double *v1, double *v2, double *v3, double *v4) {
  double d1[3], d2[3], l1, l2, r;
  d1[0] = v1[0] - v2[0];
  d1[1] = v1[1] - v2[1];
  d1[2] = v1[2] - v2[2];
  d2[0] = v3[0] - v4[0];
  d2[1] = v3[1] - v4[1];
  d2[2] = v3[2] - v4[2];
  l1 = matCalcLen(d1);
  l2 = matCalcLen(d2);
  if (l1 == 0.0 || l2 == 0.0) {
    return 0.0;
  }
  r = acos(matCalcDot(d1, d2) / (l1 * l2));
  return r * 180.0 / M_PI;
}


x86 assembly (clang, -O0):
<matCalcAngle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
subsd  (%rax),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x18(%rbp),%rax
subsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x18(%rbp),%rax
subsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x28(%rbp),%rax
subsd  (%rax),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x20(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x28(%rbp),%rax
subsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x20(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x28(%rbp),%rax
subsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x50(%rbp)
lea    -0x40(%rbp),%rdi
call   1030 <matCalcLen@plt>
movsd  %xmm0,-0x68(%rbp)
lea    -0x60(%rbp),%rdi
call   1030 <matCalcLen@plt>
movsd  %xmm0,-0x70(%rbp)
movsd  -0x68(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    120a <matCalcAngle+0xda>
jp     120a <matCalcAngle+0xda>
jmp    1222 <matCalcAngle+0xf2>
movsd  -0x70(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    122f <matCalcAngle+0xff>
jp     122f <matCalcAngle+0xff>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1271 <matCalcAngle+0x141>
lea    -0x40(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1050 <matCalcDot@plt>
movsd  -0x68(%rbp),%xmm1
mulsd  -0x70(%rbp),%xmm1
divsd  %xmm1,%xmm0
call   1040 <acos@plt>
movsd  %xmm0,-0x78(%rbp)
movsd  0xda4(%rip),%xmm0
mulsd  -0x78(%rbp),%xmm0
mov    0x2d80(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<matCalcAngle>:
sub    $0x48,%rsp
movupd (%rdi),%xmm0
movupd (%rsi),%xmm1
subpd  %xmm1,%xmm0
movapd %xmm0,0x30(%rsp)
movsd  0x10(%rdi),%xmm0
subsd  0x10(%rsi),%xmm0
movsd  %xmm0,0x40(%rsp)
movupd (%rdx),%xmm0
movupd (%rcx),%xmm1
subpd  %xmm1,%xmm0
movapd %xmm0,0x10(%rsp)
movsd  0x10(%rdx),%xmm0
subsd  0x10(%rcx),%xmm0
movsd  %xmm0,0x20(%rsp)
lea    0x30(%rsp),%rdi
call   1030 <matCalcLen@plt>
movsd  %xmm0,(%rsp)
lea    0x10(%rsp),%rdi
call   1030 <matCalcLen@plt>
movapd %xmm0,%xmm2
xorpd  %xmm0,%xmm0
movsd  (%rsp),%xmm1
ucomisd %xmm0,%xmm1
jne    11a6 <matCalcAngle+0x76>
jnp    11ee <matCalcAngle+0xbe>
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm2
jne    11b2 <matCalcAngle+0x82>
jnp    11ee <matCalcAngle+0xbe>
lea    0x30(%rsp),%rdi
lea    0x10(%rsp),%rsi
movsd  %xmm2,0x8(%rsp)
call   1050 <matCalcDot@plt>
movsd  (%rsp),%xmm1
mulsd  0x8(%rsp),%xmm1
divsd  %xmm1,%xmm0
call   1040 <acos@plt>
mulsd  0xe1d(%rip),%xmm0
mov    0x2dfe(%rip),%rax
divsd  (%rax),%xmm0
add    $0x48,%rsp
ret

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

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
define double @matCalcAngle(double* nocapture %0, double* nocapture %1, double* nocapture %2, double* nocapture %3) {
%5 = alloca [3 x double]
%6 = alloca [3 x double]
%7 = bitcast [3 x double]* %5 to i8*
%8 = bitcast [3 x double]* %6 to i8*
%9 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 0
%10 = bitcast double* %0 to <2 x double>*
%11 = load <2 x double>, <2 x double>* %10
%12 = bitcast double* %1 to <2 x double>*
%13 = load <2 x double>, <2 x double>* %12
%14 = fsub <2 x double> %11, %13
%15 = bitcast [3 x double]* %5 to <2 x double>*
store <2 x double> %14, <2 x double>* %15
%16 = getelementptr inbounds double, double* %0, i64 2
%17 = load double, double* %16
%18 = getelementptr inbounds double, double* %1, i64 2
%19 = load double, double* %18
%20 = fsub double %17, %19
%21 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 2
store double %20, double* %21
%22 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 0
%23 = bitcast double* %2 to <2 x double>*
%24 = load <2 x double>, <2 x double>* %23
%25 = bitcast double* %3 to <2 x double>*
%26 = load <2 x double>, <2 x double>* %25
%27 = fsub <2 x double> %24, %26
%28 = bitcast [3 x double]* %6 to <2 x double>*
store <2 x double> %27, <2 x double>* %28
%29 = getelementptr inbounds double, double* %2, i64 2
%30 = load double, double* %29
%31 = getelementptr inbounds double, double* %3, i64 2
%32 = load double, double* %31
%33 = fsub double %30, %32
%34 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 2
store double %33, double* %34
%35 = call double @matCalcLen(double* %9)
%36 = call double @matCalcLen(double* %22)
%37 = fcmp oeq double %35, 0.000000e+00
%38 = fcmp oeq double %36, 0.000000e+00
%39 = select i1 %37, i1 true, i1 %38
br i1 %39, label %48, label %40
40: ; preds = %4
%41 = call double @matCalcDot(double* %9, double* %22)
%42 = fmul double %35, %36
%43 = fdiv double %41, %42
%44 = call double @acos(double %43)
%45 = fmul double %44, 1.800000e+02
%46 = load double, double* @M_PI
%47 = fdiv double %45, %46
br label %48
48: ; preds = %4, %40
%49 = phi double [ %47, %40 ], [ 0.000000e+00, %4 ]
ret double %49
}