#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 sqrt(double);
void mid_pt3_cart(const double *p1, const double *p2, double *e) {
  double dd;
  e[0] = p1[0] + p2[0];
  e[1] = p1[1] + p2[1];
  e[2] = p1[2] + p2[2];
  dd = sqrt(e[0] * e[0] + e[1] * e[1] + e[2] * e[2]);
  e[0] /= dd;
  e[1] /= dd;
  e[2] /= dd;
}


x86 assembly (clang, -O0):
<mid_pt3_cart>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
addsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
addsd  0x8(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
addsd  0x10(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x10(%rax)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x18(%rbp),%rax
mulsd  0x8(%rax),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm1
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rax)
movsd  -0x20(%rbp),%xmm1
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rax)
movsd  -0x20(%rbp),%xmm1
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mid_pt3_cart>:
push   %rbx
mov    %rdx,%rbx
movsd  (%rdi),%xmm1
addsd  (%rsi),%xmm1
movsd  %xmm1,(%rdx)
movsd  0x8(%rdi),%xmm2
addsd  0x8(%rsi),%xmm2
movsd  %xmm2,0x8(%rdx)
movsd  0x10(%rdi),%xmm0
addsd  0x10(%rsi),%xmm0
movsd  %xmm0,0x10(%rdx)
mulsd  %xmm2,%xmm2
mulsd  %xmm1,%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1162 <mid_pt3_cart+0x52>
sqrtsd %xmm0,%xmm0
jmp    1167 <mid_pt3_cart+0x57>
call   1030 <sqrt@plt>
movupd (%rbx),%xmm1
movapd %xmm0,%xmm2
unpcklpd %xmm0,%xmm2
divpd  %xmm2,%xmm1
movupd %xmm1,(%rbx)
movsd  0x10(%rbx),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rbx)
pop    %rbx
ret

LLVM IR (-O0):
define void @mid_pt3_cart(double* %0, double* %1, double* %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca double*
%7 = alloca double
store double* %0, double** %4
store double* %1, double** %5
store double* %2, double** %6
%8 = load double*, double** %4
%9 = getelementptr inbounds double, double* %8, i64 0
%10 = load double, double* %9
%11 = load double*, double** %5
%12 = getelementptr inbounds double, double* %11, i64 0
%13 = load double, double* %12
%14 = fadd double %10, %13
%15 = load double*, double** %6
%16 = getelementptr inbounds double, double* %15, i64 0
store double %14, double* %16
%17 = load double*, double** %4
%18 = getelementptr inbounds double, double* %17, i64 1
%19 = load double, double* %18
%20 = load double*, double** %5
%21 = getelementptr inbounds double, double* %20, i64 1
%22 = load double, double* %21
%23 = fadd double %19, %22
%24 = load double*, double** %6
%25 = getelementptr inbounds double, double* %24, i64 1
store double %23, double* %25
%26 = load double*, double** %4
%27 = getelementptr inbounds double, double* %26, i64 2
%28 = load double, double* %27
%29 = load double*, double** %5
%30 = getelementptr inbounds double, double* %29, i64 2
%31 = load double, double* %30
%32 = fadd double %28, %31
%33 = load double*, double** %6
%34 = getelementptr inbounds double, double* %33, i64 2
store double %32, double* %34
%35 = load double*, double** %6
%36 = getelementptr inbounds double, double* %35, i64 0
%37 = load double, double* %36
%38 = load double*, double** %6
%39 = getelementptr inbounds double, double* %38, i64 0
%40 = load double, double* %39
%41 = load double*, double** %6
%42 = getelementptr inbounds double, double* %41, i64 1
%43 = load double, double* %42
%44 = load double*, double** %6
%45 = getelementptr inbounds double, double* %44, i64 1
%46 = load double, double* %45
%47 = fmul double %43, %46
%48 = call double @llvm.fmuladd.f64(double %37, double %40, double %47)
%49 = load double*, double** %6
%50 = getelementptr inbounds double, double* %49, i64 2
%51 = load double, double* %50
%52 = load double*, double** %6
%53 = getelementptr inbounds double, double* %52, i64 2
%54 = load double, double* %53
%55 = call double @llvm.fmuladd.f64(double %51, double %54, double %48)
%56 = call double @sqrt(double %55)
store double %56, double* %7
%57 = load double, double* %7
%58 = load double*, double** %6
%59 = getelementptr inbounds double, double* %58, i64 0
%60 = load double, double* %59
%61 = fdiv double %60, %57
store double %61, double* %59
%62 = load double, double* %7
%63 = load double*, double** %6
%64 = getelementptr inbounds double, double* %63, i64 1
%65 = load double, double* %64
%66 = fdiv double %65, %62
store double %66, double* %64
%67 = load double, double* %7
%68 = load double*, double** %6
%69 = getelementptr inbounds double, double* %68, i64 2
%70 = load double, double* %69
%71 = fdiv double %70, %67
store double %71, double* %69
ret void
}

LLVM IR (-O2):
define void @mid_pt3_cart(double* nocapture %0, double* nocapture %1, double* nocapture %2) {
%4 = load double, double* %0
%5 = load double, double* %1
%6 = fadd double %4, %5
store double %6, double* %2
%7 = getelementptr inbounds double, double* %0, i64 1
%8 = load double, double* %7
%9 = getelementptr inbounds double, double* %1, i64 1
%10 = load double, double* %9
%11 = fadd double %8, %10
%12 = getelementptr inbounds double, double* %2, i64 1
store double %11, double* %12
%13 = getelementptr inbounds double, double* %0, i64 2
%14 = load double, double* %13
%15 = getelementptr inbounds double, double* %1, i64 2
%16 = load double, double* %15
%17 = fadd double %14, %16
%18 = getelementptr inbounds double, double* %2, i64 2
store double %17, double* %18
%19 = fmul double %11, %11
%20 = tail call double @llvm.fmuladd.f64(double %6, double %6, double %19)
%21 = tail call double @llvm.fmuladd.f64(double %17, double %17, double %20)
%22 = tail call double @sqrt(double %21)
%23 = bitcast double* %2 to <2 x double>*
%24 = load <2 x double>, <2 x double>* %23
%25 = insertelement <2 x double> poison, double %22, i64 0
%26 = shufflevector <2 x double> %25, <2 x double> poison, <2 x i32> zeroinitializer
%27 = fdiv <2 x double> %24, %26
%28 = bitcast double* %2 to <2 x double>*
store <2 x double> %27, <2 x double>* %28
%29 = load double, double* %18
%30 = fdiv double %29, %22
store double %30, double* %18
ret void
}