#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*/ crossProduct(double *, double *, double *);
double scalarProduct(double *, double *);
int /*<<< orphan*/ vertexSub(double *, double *, double *);
double volumeOfTetrahedron(double *a, double *b, double *c, double *d) {
  double a_d[3], b_d[3], c_d[3], cross[3];
  vertexSub(a, d, a_d);
  vertexSub(b, d, b_d);
  vertexSub(c, d, c_d);
  crossProduct(b_d, c_d, cross);
  double v = scalarProduct(a_d, cross) / (double)6;
  return (v >= 0) ? v : -v;
}


x86 assembly (clang, -O0):
<volumeOfTetrahedron>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
lea    -0x40(%rbp),%rdx
call   1050 <vertexSub@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
lea    -0x60(%rbp),%rdx
call   1050 <vertexSub@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
lea    -0x80(%rbp),%rdx
call   1050 <vertexSub@plt>
lea    -0x60(%rbp),%rdi
lea    -0x80(%rbp),%rsi
lea    -0xa0(%rbp),%rdx
call   1030 <crossProduct@plt>
lea    -0x40(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
call   1040 <scalarProduct@plt>
movsd  0xe56(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
movsd  -0xa8(%rbp),%xmm0
ff
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11e0 <volumeOfTetrahedron+0xb0>
movsd  -0xa8(%rbp),%xmm0
ff
movsd  %xmm0,-0xb0(%rbp)
ff
jmp    1207 <volumeOfTetrahedron+0xd7>
movsd  -0xa8(%rbp),%xmm0
ff
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  -0xb0(%rbp),%xmm0
ff
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<volumeOfTetrahedron>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x80,%rsp
mov    %rcx,%rbx
mov    %rdx,%r14
mov    %rsi,%r15
lea    0x60(%rsp),%r12
mov    %rcx,%rsi
mov    %r12,%rdx
call   1050 <vertexSub@plt>
lea    0x40(%rsp),%r13
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
call   1050 <vertexSub@plt>
lea    0x20(%rsp),%r15
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1050 <vertexSub@plt>
mov    %rsp,%rbx
mov    %r13,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1030 <crossProduct@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1040 <scalarProduct@plt>
divsd  0xe5d(%rip),%xmm0
movapd 0xe65(%rip),%xmm1
xorpd  %xmm0,%xmm1
xorpd  %xmm2,%xmm2
cmplesd %xmm0,%xmm2
andpd  %xmm2,%xmm0
andnpd %xmm1,%xmm2
orpd   %xmm2,%xmm0
add    $0x80,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define double @volumeOfTetrahedron(double* %0, double* %1, double* %2, double* %3) {
%5 = alloca double*
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca [3 x double]
%10 = alloca [3 x double]
%11 = alloca [3 x double]
%12 = alloca [3 x double]
%13 = alloca double
store double* %0, double** %5
store double* %1, double** %6
store double* %2, double** %7
store double* %3, double** %8
%14 = load double*, double** %5
%15 = load double*, double** %8
%16 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0, i64 0
%17 = call i32 @vertexSub(double* %14, double* %15, double* %16)
%18 = load double*, double** %6
%19 = load double*, double** %8
%20 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 0
%21 = call i32 @vertexSub(double* %18, double* %19, double* %20)
%22 = load double*, double** %7
%23 = load double*, double** %8
%24 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 0
%25 = call i32 @vertexSub(double* %22, double* %23, double* %24)
%26 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 0
%27 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 0
%28 = getelementptr inbounds [3 x double], [3 x double]* %12, i64 0, i64 0
%29 = call i32 @crossProduct(double* %26, double* %27, double* %28)
%30 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0, i64 0
%31 = getelementptr inbounds [3 x double], [3 x double]* %12, i64 0, i64 0
%32 = call double @scalarProduct(double* %30, double* %31)
%33 = fdiv double %32, 6.000000e+00
store double %33, double* %13
%34 = load double, double* %13
%35 = fcmp oge double %34, 0.000000e+00
br i1 %35, label %36, label %38
36: ; preds = %4
%37 = load double, double* %13
br label %41
38: ; preds = %4
%39 = load double, double* %13
%40 = fneg double %39
br label %41
41: ; preds = %38, %36
%42 = phi double [ %37, %36 ], [ %40, %38 ]
ret double %42
}

LLVM IR (-O2):
define double @volumeOfTetrahedron(double* %0, double* %1, double* %2, double* %3) {
%5 = alloca [3 x double]
%6 = alloca [3 x double]
%7 = alloca [3 x double]
%8 = alloca [3 x double]
%9 = bitcast [3 x double]* %5 to i8*
%10 = bitcast [3 x double]* %6 to i8*
%11 = bitcast [3 x double]* %7 to i8*
%12 = bitcast [3 x double]* %8 to i8*
%13 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 0
%14 = call i32 @vertexSub(double* %0, double* %3, double* %13)
%15 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 0
%16 = call i32 @vertexSub(double* %1, double* %3, double* %15)
%17 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 0
%18 = call i32 @vertexSub(double* %2, double* %3, double* %17)
%19 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 0
%20 = call i32 @crossProduct(double* %15, double* %17, double* %19)
%21 = call double @scalarProduct(double* %13, double* %19)
%22 = fdiv double %21, 6.000000e+00
%23 = fcmp oge double %22, 0.000000e+00
%24 = fneg double %22
%25 = select i1 %23, double %22, double %24
ret double %25
}