#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 */
int /*<<< orphan*/ cross3(double *, double *, double *);
int /*<<< orphan*/ hypot3_sqr(double, double, double);
double sqrt(int /*<<< orphan*/);
double triangle3_area(const double v0[3], const double v1[3],
                      const double v2[3]) {
  double u[3], w[3], uxw[3];
  int i;
  for (i = 0; i < 3; ++i) {
    u[i] = v1[i] - v0[i];
    w[i] = v2[i] - v0[i];
  }
  cross3(u, w, uxw);
  return 0.5 * sqrt(hypot3_sqr(uxw[0], uxw[1], uxw[2]));
}


x86 assembly (clang, -O0):
<triangle3_area>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x74(%rbp)
cmpl   $0x3,-0x74(%rbp)
jge    11ae <triangle3_area+0x7e>
mov    -0x10(%rbp),%rax
movslq -0x74(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x74(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
movslq -0x74(%rbp),%rax
movsd  %xmm0,-0x30(%rbp,%rax,8)
mov    -0x18(%rbp),%rax
movslq -0x74(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x74(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
movslq -0x74(%rbp),%rax
movsd  %xmm0,-0x50(%rbp,%rax,8)
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    114e <triangle3_area+0x1e>
lea    -0x30(%rbp),%rdi
lea    -0x50(%rbp),%rsi
lea    -0x70(%rbp),%rdx
call   1030 <cross3@plt>
movsd  -0x70(%rbp),%xmm0
movsd  -0x68(%rbp),%xmm1
movsd  -0x60(%rbp),%xmm2
call   1040 <hypot3_sqr@plt>
mov    %eax,%edi
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  0xe1b(%rip),%xmm0
mulsd  %xmm1,%xmm0
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<triangle3_area>:
sub    $0x58,%rsp
movupd (%rdi),%xmm0
movupd (%rsi),%xmm1
subpd  %xmm0,%xmm1
movapd %xmm1,0x40(%rsp)
movupd (%rdx),%xmm1
subpd  %xmm0,%xmm1
movapd %xmm1,0x20(%rsp)
movsd  0x10(%rsi),%xmm0
movsd  0x10(%rdi),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,0x50(%rsp)
movsd  0x10(%rdx),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,0x30(%rsp)
lea    0x40(%rsp),%rdi
lea    0x20(%rsp),%rsi
mov    %rsp,%rdx
call   1030 <cross3@plt>
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
call   1040 <hypot3_sqr@plt>
mov    %eax,%edi
call   1050 <sqrt@plt>
mulsd  0xe52(%rip),%xmm0
add    $0x58,%rsp
ret

LLVM IR (-O0):
define double @triangle3_area(double* %0, double* %1, double* %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca double*
%7 = alloca [3 x double]
%8 = alloca [3 x double]
%9 = alloca [3 x double]
%10 = alloca i32
store double* %0, double** %4
store double* %1, double** %5
store double* %2, double** %6
store i32 0, i32* %10
br label %11
11: ; preds = %43, %3
%12 = load i32, i32* %10
%13 = icmp slt i32 %12, 3
br i1 %13, label %14, label %46
14: ; preds = %11
%15 = load double*, double** %5
%16 = load i32, i32* %10
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds double, double* %15, i64 %17
%19 = load double, double* %18
%20 = load double*, double** %4
%21 = load i32, i32* %10
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds double, double* %20, i64 %22
%24 = load double, double* %23
%25 = fsub double %19, %24
%26 = load i32, i32* %10
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 %27
store double %25, double* %28
%29 = load double*, double** %6
%30 = load i32, i32* %10
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds double, double* %29, i64 %31
%33 = load double, double* %32
%34 = load double*, double** %4
%35 = load i32, i32* %10
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds double, double* %34, i64 %36
%38 = load double, double* %37
%39 = fsub double %33, %38
%40 = load i32, i32* %10
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 %41
store double %39, double* %42
br label %43
43: ; preds = %14
%44 = load i32, i32* %10
%45 = add nsw i32 %44, 1
store i32 %45, i32* %10
br label %11
46: ; preds = %11
%47 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 0
%48 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 0
%49 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0, i64 0
%50 = call i32 @cross3(double* %47, double* %48, double* %49)
%51 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0, i64 0
%52 = load double, double* %51
%53 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0, i64 1
%54 = load double, double* %53
%55 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0, i64 2
%56 = load double, double* %55
%57 = call i32 @hypot3_sqr(double %52, double %54, double %56)
%58 = call double @sqrt(i32 %57)
%59 = fmul double 5.000000e-01, %58
ret double %59
}

LLVM IR (-O2):
define double @triangle3_area(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* %0 to <2 x double>*
%12 = load <2 x double>, <2 x double>* %11
%13 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 0
%14 = bitcast double* %1 to <2 x double>*
%15 = load <2 x double>, <2 x double>* %14
%16 = fsub <2 x double> %15, %12
%17 = bitcast [3 x double]* %4 to <2 x double>*
store <2 x double> %16, <2 x double>* %17
%18 = bitcast double* %2 to <2 x double>*
%19 = load <2 x double>, <2 x double>* %18
%20 = fsub <2 x double> %19, %12
%21 = bitcast [3 x double]* %5 to <2 x double>*
store <2 x double> %20, <2 x double>* %21
%22 = getelementptr inbounds double, double* %1, i64 2
%23 = load double, double* %22
%24 = getelementptr inbounds double, double* %0, i64 2
%25 = load double, double* %24
%26 = fsub double %23, %25
%27 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 2
store double %26, double* %27
%28 = getelementptr inbounds double, double* %2, i64 2
%29 = load double, double* %28
%30 = fsub double %29, %25
%31 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 2
store double %30, double* %31
%32 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 0
%33 = call i32 @cross3(double* %10, double* %13, double* %32)
%34 = load double, double* %32
%35 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 1
%36 = load double, double* %35
%37 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 2
%38 = load double, double* %37
%39 = call i32 @hypot3_sqr(double %34, double %36, double %38)
%40 = call double @sqrt(i32 %39)
%41 = fmul double %40, 5.000000e-01
ret double %41
}