#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 dot_product(double *, double *);
double vector_norm(double *);
double radius_of_curvature(double *start, double *middle, double *end) {
  double radius, seg_disp[3];
  double chord;
  double chord_disp[3];
  double height;
  double height_disp[3];
  double mu;
  seg_disp[0] = middle[0] - start[0];
  seg_disp[1] = middle[1] - start[1];
  seg_disp[2] = middle[2] - start[2];
  chord_disp[0] = end[0] - start[0];
  chord_disp[1] = end[1] - start[1];
  chord_disp[2] = end[2] - start[2];
  chord = vector_norm(chord_disp);
  chord_disp[0] = chord_disp[0] / chord;
  chord_disp[1] = chord_disp[1] / chord;
  chord_disp[2] = chord_disp[2] / chord;
  mu = dot_product(seg_disp, chord_disp);
  height_disp[0] = seg_disp[0] - chord_disp[0] * mu;
  height_disp[1] = seg_disp[1] - chord_disp[1] * mu;
  height_disp[2] = seg_disp[2] - chord_disp[2] * mu;
  height = vector_norm(height_disp);
  radius = height / 2 + chord * chord / (8 * height);
  return radius;
}


x86 assembly (clang, -O0):
<radius_of_curvature>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%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    -0x8(%rbp),%rax
subsd  (%rax),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x8(%rbp),%rax
subsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x8(%rbp),%rax
subsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x50(%rbp)
lea    -0x60(%rbp),%rdi
call   1030 <vector_norm@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x60(%rbp),%xmm0
divsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x58(%rbp),%xmm0
divsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x50(%rbp),%xmm0
divsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
lea    -0x40(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1040 <dot_product@plt>
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x40(%rbp),%xmm1
movsd  -0x60(%rbp),%xmm0
movsd  -0x88(%rbp),%xmm2
ff
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x38(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm0
movsd  -0x88(%rbp),%xmm2
ff
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x30(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm0
movsd  -0x88(%rbp),%xmm2
ff
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
lea    -0x80(%rbp),%rdi
call   1030 <vector_norm@plt>
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
movsd  0xd3e(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  -0x48(%rbp),%xmm1
mulsd  -0x48(%rbp),%xmm1
movsd  0xd20(%rip),%xmm2
mulsd  -0x68(%rbp),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<radius_of_curvature>:
push   %rbx
sub    $0x70,%rsp
movupd (%rsi),%xmm0
movupd (%rdi),%xmm1
subpd  %xmm1,%xmm0
movapd %xmm0,0x20(%rsp)
movsd  0x10(%rsi),%xmm0
movsd  0x10(%rdi),%xmm2
subsd  %xmm2,%xmm0
movsd  %xmm0,0x30(%rsp)
movupd (%rdx),%xmm0
subpd  %xmm1,%xmm0
movapd %xmm0,(%rsp)
movsd  0x10(%rdx),%xmm0
subsd  %xmm2,%xmm0
movsd  %xmm0,0x10(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <vector_norm@plt>
movapd %xmm0,0x40(%rsp)
movapd (%rsp),%xmm2
movapd %xmm0,%xmm1
unpcklpd %xmm0,%xmm1
divpd  %xmm1,%xmm2
movapd %xmm2,(%rsp)
movsd  0x10(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
lea    0x20(%rsp),%rdi
mov    %rbx,%rsi
call   1040 <dot_product@plt>
movapd %xmm0,%xmm1
unpcklpd %xmm0,%xmm1
mulpd  (%rsp),%xmm1
movapd 0x20(%rsp),%xmm2
subpd  %xmm1,%xmm2
movapd %xmm2,0x50(%rsp)
movsd  0x30(%rsp),%xmm1
mulsd  0x10(%rsp),%xmm0
subsd  %xmm0,%xmm1
movsd  %xmm1,0x60(%rsp)
lea    0x50(%rsp),%rdi
call   1030 <vector_norm@plt>
movsd  0xe10(%rip),%xmm1
mulsd  %xmm0,%xmm1
movapd 0x40(%rsp),%xmm2
mulsd  %xmm2,%xmm2
mulsd  0xe02(%rip),%xmm0
divsd  %xmm0,%xmm2
addsd  %xmm1,%xmm2
movapd %xmm2,%xmm0
add    $0x70,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @radius_of_curvature(double* %0, double* %1, double* %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca double*
%7 = alloca double
%8 = alloca [3 x double]
%9 = alloca double
%10 = alloca [3 x double]
%11 = alloca double
%12 = alloca [3 x double]
%13 = alloca double
store double* %0, double** %4
store double* %1, double** %5
store double* %2, double** %6
%14 = load double*, double** %5
%15 = getelementptr inbounds double, double* %14, i64 0
%16 = load double, double* %15
%17 = load double*, double** %4
%18 = getelementptr inbounds double, double* %17, i64 0
%19 = load double, double* %18
%20 = fsub double %16, %19
%21 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 0
store double %20, double* %21
%22 = load double*, double** %5
%23 = getelementptr inbounds double, double* %22, i64 1
%24 = load double, double* %23
%25 = load double*, double** %4
%26 = getelementptr inbounds double, double* %25, i64 1
%27 = load double, double* %26
%28 = fsub double %24, %27
%29 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 1
store double %28, double* %29
%30 = load double*, double** %5
%31 = getelementptr inbounds double, double* %30, i64 2
%32 = load double, double* %31
%33 = load double*, double** %4
%34 = getelementptr inbounds double, double* %33, i64 2
%35 = load double, double* %34
%36 = fsub double %32, %35
%37 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 2
store double %36, double* %37
%38 = load double*, double** %6
%39 = getelementptr inbounds double, double* %38, i64 0
%40 = load double, double* %39
%41 = load double*, double** %4
%42 = getelementptr inbounds double, double* %41, i64 0
%43 = load double, double* %42
%44 = fsub double %40, %43
%45 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 0
store double %44, double* %45
%46 = load double*, double** %6
%47 = getelementptr inbounds double, double* %46, i64 1
%48 = load double, double* %47
%49 = load double*, double** %4
%50 = getelementptr inbounds double, double* %49, i64 1
%51 = load double, double* %50
%52 = fsub double %48, %51
%53 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 1
store double %52, double* %53
%54 = load double*, double** %6
%55 = getelementptr inbounds double, double* %54, i64 2
%56 = load double, double* %55
%57 = load double*, double** %4
%58 = getelementptr inbounds double, double* %57, i64 2
%59 = load double, double* %58
%60 = fsub double %56, %59
%61 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 2
store double %60, double* %61
%62 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 0
%63 = call double @vector_norm(double* %62)
store double %63, double* %9
%64 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 0
%65 = load double, double* %64
%66 = load double, double* %9
%67 = fdiv double %65, %66
%68 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 0
store double %67, double* %68
%69 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 1
%70 = load double, double* %69
%71 = load double, double* %9
%72 = fdiv double %70, %71
%73 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 1
store double %72, double* %73
%74 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 2
%75 = load double, double* %74
%76 = load double, double* %9
%77 = fdiv double %75, %76
%78 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 2
store double %77, double* %78
%79 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 0
%80 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 0
%81 = call double @dot_product(double* %79, double* %80)
store double %81, double* %13
%82 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 0
%83 = load double, double* %82
%84 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 0
%85 = load double, double* %84
%86 = load double, double* %13
%87 = fneg double %85
%88 = call double @llvm.fmuladd.f64(double %87, double %86, double %83)
%89 = getelementptr inbounds [3 x double], [3 x double]* %12, i64 0, i64 0
store double %88, double* %89
%90 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 1
%91 = load double, double* %90
%92 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 1
%93 = load double, double* %92
%94 = load double, double* %13
%95 = fneg double %93
%96 = call double @llvm.fmuladd.f64(double %95, double %94, double %91)
%97 = getelementptr inbounds [3 x double], [3 x double]* %12, i64 0, i64 1
store double %96, double* %97
%98 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 2
%99 = load double, double* %98
%100 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 2
%101 = load double, double* %100
%102 = load double, double* %13
%103 = fneg double %101
%104 = call double @llvm.fmuladd.f64(double %103, double %102, double %99)
%105 = getelementptr inbounds [3 x double], [3 x double]* %12, i64 0, i64 2
store double %104, double* %105
%106 = getelementptr inbounds [3 x double], [3 x double]* %12, i64 0, i64 0
%107 = call double @vector_norm(double* %106)
store double %107, double* %11
%108 = load double, double* %11
%109 = fdiv double %108, 2.000000e+00
%110 = load double, double* %9
%111 = load double, double* %9
%112 = fmul double %110, %111
%113 = load double, double* %11
%114 = fmul double 8.000000e+00, %113
%115 = fdiv double %112, %114
%116 = fadd double %109, %115
store double %116, double* %7
%117 = load double, double* %7
ret double %117
}

LLVM IR (-O2):
define double @radius_of_curvature(double* nocapture %0, double* nocapture %1, double* nocapture %2) {
%4 = alloca [3 x double]
%5 = alloca [3 x double]
%6 = alloca [3 x double]
%7 = bitcast [3 x double]* %4 to i8*
%8 = bitcast [3 x double]* %5 to i8*
%9 = bitcast [3 x double]* %6 to i8*
%10 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 0
%11 = bitcast double* %1 to <2 x double>*
%12 = load <2 x double>, <2 x double>* %11
%13 = bitcast double* %0 to <2 x double>*
%14 = load <2 x double>, <2 x double>* %13
%15 = fsub <2 x double> %12, %14
%16 = bitcast [3 x double]* %4 to <2 x double>*
store <2 x double> %15, <2 x double>* %16
%17 = getelementptr inbounds double, double* %1, i64 2
%18 = load double, double* %17
%19 = getelementptr inbounds double, double* %0, i64 2
%20 = load double, double* %19
%21 = fsub double %18, %20
%22 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 2
store double %21, double* %22
%23 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 0
%24 = bitcast double* %2 to <2 x double>*
%25 = load <2 x double>, <2 x double>* %24
%26 = fsub <2 x double> %25, %14
%27 = bitcast [3 x double]* %5 to <2 x double>*
store <2 x double> %26, <2 x double>* %27
%28 = getelementptr inbounds double, double* %2, i64 2
%29 = load double, double* %28
%30 = fsub double %29, %20
%31 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 2
store double %30, double* %31
%32 = call double @vector_norm(double* %23)
%33 = bitcast [3 x double]* %5 to <2 x double>*
%34 = load <2 x double>, <2 x double>* %33
%35 = insertelement <2 x double> poison, double %32, i64 0
%36 = shufflevector <2 x double> %35, <2 x double> poison, <2 x i32> zeroinitializer
%37 = fdiv <2 x double> %34, %36
%38 = bitcast [3 x double]* %5 to <2 x double>*
store <2 x double> %37, <2 x double>* %38
%39 = load double, double* %31
%40 = fdiv double %39, %32
store double %40, double* %31
%41 = call double @dot_product(double* %10, double* %23)
%42 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 0
%43 = bitcast [3 x double]* %4 to <2 x double>*
%44 = load <2 x double>, <2 x double>* %43
%45 = bitcast [3 x double]* %5 to <2 x double>*
%46 = load <2 x double>, <2 x double>* %45
%47 = fneg <2 x double> %46
%48 = insertelement <2 x double> poison, double %41, i64 0
%49 = shufflevector <2 x double> %48, <2 x double> poison, <2 x i32> zeroinitializer
%50 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %47, <2 x double> %49, <2 x double> %44)
%51 = bitcast [3 x double]* %6 to <2 x double>*
store <2 x double> %50, <2 x double>* %51
%52 = load double, double* %22
%53 = load double, double* %31
%54 = fneg double %53
%55 = call double @llvm.fmuladd.f64(double %54, double %41, double %52)
%56 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 2
store double %55, double* %56
%57 = call double @vector_norm(double* %42)
%58 = fmul double %57, 5.000000e-01
%59 = fmul double %32, %32
%60 = fmul double %57, 8.000000e+00
%61 = fdiv double %59, %60
%62 = fadd double %58, %61
ret double %62
}