#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 orient2d(double *, double *, double *);
double normvec(double x1, double y1, double z1, double x2, double y2, double z2,
               double *px, double *py, double *pz) {
  double w1[4], w2[4], w3[4], x, y, z;
  w1[0] = x1, w2[0] = x2, w3[0] = 0.0;
  w1[1] = y1, w2[1] = y2, w3[1] = 0.0;
  w1[2] = z1, w2[2] = z2, w3[2] = 0.0;
  w1[3] = x1, w2[3] = x2, w3[3] = 0.0;
  *px = x = orient2d(w3 + 1, w2 + 1, w1 + 1);
  *py = y = orient2d(w3 + 2, w2 + 2, w1 + 2);
  *pz = z = orient2d(w3 + 0, w2 + 0, w1 + 0);
  return x * x + y * y + z * z;
}


x86 assembly (clang, -O0):
<normvec>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  %xmm4,-0x28(%rbp)
movsd  %xmm5,-0x30(%rbp)
mov    %rdi,-0x38(%rbp)
mov    %rsi,-0x40(%rbp)
mov    %rdx,-0x48(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
xorps  %xmm0,%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
xorps  %xmm0,%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
lea    -0xb0(%rbp),%rdi
add    $0x8,%rdi
lea    -0x90(%rbp),%rsi
add    $0x8,%rsi
lea    -0x70(%rbp),%rdx
add    $0x8,%rdx
call   1030 <orient2d@plt>
movsd  %xmm0,-0xb8(%rbp)
ff
mov    -0x38(%rbp),%rax
movsd  %xmm0,(%rax)
lea    -0xb0(%rbp),%rdi
add    $0x10,%rdi
lea    -0x90(%rbp),%rsi
add    $0x10,%rsi
lea    -0x70(%rbp),%rdx
add    $0x10,%rdx
call   1030 <orient2d@plt>
movsd  %xmm0,-0xc0(%rbp)
ff
mov    -0x40(%rbp),%rax
movsd  %xmm0,(%rax)
lea    -0xb0(%rbp),%rdi
lea    -0x90(%rbp),%rsi
lea    -0x70(%rbp),%rdx
call   1030 <orient2d@plt>
movsd  %xmm0,-0xc8(%rbp)
ff
mov    -0x48(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0xb8(%rbp),%xmm1
ff
movsd  -0xb8(%rbp),%xmm2
ff
movsd  -0xc0(%rbp),%xmm0
ff
mulsd  -0xc0(%rbp),%xmm0
ff
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0xc8(%rbp),%xmm0
ff
movsd  -0xc8(%rbp),%xmm2
ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<normvec>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
movsd  %xmm0,0x30(%rsp)
movsd  %xmm3,0x10(%rsp)
lea    0x38(%rsp),%rdx
movsd  %xmm1,0x38(%rsp)
lea    0x18(%rsp),%rsi
movsd  %xmm4,0x18(%rsp)
lea    0x58(%rsp),%rdi
xorps  %xmm1,%xmm1
movaps %xmm1,0x50(%rsp)
lea    0x40(%rsp),%r12
movsd  %xmm2,0x40(%rsp)
lea    0x20(%rsp),%r13
movsd  %xmm5,0x20(%rsp)
lea    0x60(%rsp),%rbp
movsd  %xmm0,0x48(%rsp)
movsd  %xmm3,0x28(%rsp)
movaps %xmm1,0x60(%rsp)
call   1030 <orient2d@plt>
movsd  %xmm0,0x8(%rsp)
movsd  %xmm0,(%rbx)
mov    %rbp,%rdi
mov    %r13,%rsi
mov    %r12,%rdx
call   1030 <orient2d@plt>
movsd  %xmm0,(%rsp)
movsd  %xmm0,(%r15)
lea    0x50(%rsp),%rdi
lea    0x10(%rsp),%rsi
lea    0x30(%rsp),%rdx
call   1030 <orient2d@plt>
movsd  %xmm0,(%r14)
movsd  (%rsp),%xmm2
mulsd  %xmm2,%xmm2
movsd  0x8(%rsp),%xmm1
mulsd  %xmm1,%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @normvec(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 [4 x double]
%20 = alloca [4 x double]
%21 = alloca [4 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 = getelementptr inbounds [4 x double], [4 x double]* %19, i64 0, i64 0
store double %25, double* %26
%27 = load double, double* %13
%28 = getelementptr inbounds [4 x double], [4 x double]* %20, i64 0, i64 0
store double %27, double* %28
%29 = getelementptr inbounds [4 x double], [4 x double]* %21, i64 0, i64 0
store double 0.000000e+00, double* %29
%30 = load double, double* %11
%31 = getelementptr inbounds [4 x double], [4 x double]* %19, i64 0, i64 1
store double %30, double* %31
%32 = load double, double* %14
%33 = getelementptr inbounds [4 x double], [4 x double]* %20, i64 0, i64 1
store double %32, double* %33
%34 = getelementptr inbounds [4 x double], [4 x double]* %21, i64 0, i64 1
store double 0.000000e+00, double* %34
%35 = load double, double* %12
%36 = getelementptr inbounds [4 x double], [4 x double]* %19, i64 0, i64 2
store double %35, double* %36
%37 = load double, double* %15
%38 = getelementptr inbounds [4 x double], [4 x double]* %20, i64 0, i64 2
store double %37, double* %38
%39 = getelementptr inbounds [4 x double], [4 x double]* %21, i64 0, i64 2
store double 0.000000e+00, double* %39
%40 = load double, double* %10
%41 = getelementptr inbounds [4 x double], [4 x double]* %19, i64 0, i64 3
store double %40, double* %41
%42 = load double, double* %13
%43 = getelementptr inbounds [4 x double], [4 x double]* %20, i64 0, i64 3
store double %42, double* %43
%44 = getelementptr inbounds [4 x double], [4 x double]* %21, i64 0, i64 3
store double 0.000000e+00, double* %44
%45 = getelementptr inbounds [4 x double], [4 x double]* %21, i64 0, i64 0
%46 = getelementptr inbounds double, double* %45, i64 1
%47 = getelementptr inbounds [4 x double], [4 x double]* %20, i64 0, i64 0
%48 = getelementptr inbounds double, double* %47, i64 1
%49 = getelementptr inbounds [4 x double], [4 x double]* %19, i64 0, i64 0
%50 = getelementptr inbounds double, double* %49, i64 1
%51 = call double @orient2d(double* %46, double* %48, double* %50)
store double %51, double* %22
%52 = load double*, double** %16
store double %51, double* %52
%53 = getelementptr inbounds [4 x double], [4 x double]* %21, i64 0, i64 0
%54 = getelementptr inbounds double, double* %53, i64 2
%55 = getelementptr inbounds [4 x double], [4 x double]* %20, i64 0, i64 0
%56 = getelementptr inbounds double, double* %55, i64 2
%57 = getelementptr inbounds [4 x double], [4 x double]* %19, i64 0, i64 0
%58 = getelementptr inbounds double, double* %57, i64 2
%59 = call double @orient2d(double* %54, double* %56, double* %58)
store double %59, double* %23
%60 = load double*, double** %17
store double %59, double* %60
%61 = getelementptr inbounds [4 x double], [4 x double]* %21, i64 0, i64 0
%62 = getelementptr inbounds double, double* %61, i64 0
%63 = getelementptr inbounds [4 x double], [4 x double]* %20, i64 0, i64 0
%64 = getelementptr inbounds double, double* %63, i64 0
%65 = getelementptr inbounds [4 x double], [4 x double]* %19, i64 0, i64 0
%66 = getelementptr inbounds double, double* %65, i64 0
%67 = call double @orient2d(double* %62, double* %64, double* %66)
store double %67, double* %24
%68 = load double*, double** %18
store double %67, double* %68
%69 = load double, double* %22
%70 = load double, double* %22
%71 = load double, double* %23
%72 = load double, double* %23
%73 = fmul double %71, %72
%74 = call double @llvm.fmuladd.f64(double %69, double %70, double %73)
%75 = load double, double* %24
%76 = load double, double* %24
%77 = call double @llvm.fmuladd.f64(double %75, double %76, double %74)
ret double %77
}

LLVM IR (-O2):
define double @normvec(double %0, double %1, double %2, double %3, double %4, double %5, double* nocapture writeonly %6, double* nocapture writeonly %7, double* nocapture writeonly %8) {
%10 = alloca [4 x double]
%11 = alloca [4 x double]
%12 = alloca [4 x double]
%13 = bitcast [4 x double]* %10 to i8*
%14 = bitcast [4 x double]* %11 to i8*
%15 = bitcast [4 x double]* %12 to i8*
%16 = getelementptr inbounds [4 x double], [4 x double]* %10, i64 0, i64 0
store double %0, double* %16
%17 = getelementptr inbounds [4 x double], [4 x double]* %11, i64 0, i64 0
store double %3, double* %17
%18 = getelementptr inbounds [4 x double], [4 x double]* %12, i64 0, i64 0
%19 = getelementptr inbounds [4 x double], [4 x double]* %10, i64 0, i64 1
store double %1, double* %19
%20 = getelementptr inbounds [4 x double], [4 x double]* %11, i64 0, i64 1
store double %4, double* %20
%21 = getelementptr inbounds [4 x double], [4 x double]* %12, i64 0, i64 1
%22 = bitcast [4 x double]* %12 to <2 x double>*
store <2 x double> zeroinitializer, <2 x double>* %22
%23 = getelementptr inbounds [4 x double], [4 x double]* %10, i64 0, i64 2
store double %2, double* %23
%24 = getelementptr inbounds [4 x double], [4 x double]* %11, i64 0, i64 2
store double %5, double* %24
%25 = getelementptr inbounds [4 x double], [4 x double]* %12, i64 0, i64 2
%26 = getelementptr inbounds [4 x double], [4 x double]* %10, i64 0, i64 3
store double %0, double* %26
%27 = getelementptr inbounds [4 x double], [4 x double]* %11, i64 0, i64 3
store double %3, double* %27
%28 = bitcast double* %25 to <2 x double>*
store <2 x double> zeroinitializer, <2 x double>* %28
%29 = call double @orient2d(double* %21, double* %20, double* %19)
store double %29, double* %6
%30 = call double @orient2d(double* %25, double* %24, double* %23)
store double %30, double* %7
%31 = call double @orient2d(double* %18, double* %17, double* %16)
store double %31, double* %8
%32 = fmul double %30, %30
%33 = call double @llvm.fmuladd.f64(double %29, double %29, double %32)
%34 = call double @llvm.fmuladd.f64(double %31, double %31, double %33)
ret double %34
}