#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 fabs(double);
double sqrt(double);
int /*<<< orphan*/ vector_product(double const *, double const *, double *);
double calculate_volume_factor_3d(const double a[3][3]) {
  double a12[3];
  vector_product(a[0], a[1], a12);
  double volume = 0;
  double l[3];
  l[0] = l[1] = l[2] = 0;
  for (int i = 0; i < 3; ++i) {
    volume += a12[i] * a[2][i];
    l[0] += a[0][i] * a[0][i];
    l[1] += a[1][i] * a[1][i];
    l[2] += a[2][i] * a[2][i];
  }
  return fabs(volume) / sqrt(l[0] * l[1] * l[2]);
}


x86 assembly (clang, -O0):
<calculate_volume_factor_3d>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rsi
add    $0x18,%rsi
lea    -0x20(%rbp),%rdx
call   1030 <vector_product@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
cmpl   $0x3,-0x44(%rbp)
jge    1232 <calculate_volume_factor_3d+0x112>
movslq -0x44(%rbp),%rax
movsd  -0x20(%rbp,%rax,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  0x30(%rax,%rcx,8),%xmm2
movsd  -0x28(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x40(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  0x18(%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  0x18(%rax,%rcx,8),%xmm2
movsd  -0x38(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  0x30(%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  0x30(%rax,%rcx,8),%xmm2
movsd  -0x30(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1168 <calculate_volume_factor_3d+0x48>
movsd  -0x28(%rbp),%xmm0
movaps 0xdc2(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x40(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
divsd  %xmm1,%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calculate_volume_factor_3d>:
push   %rbx
sub    $0x30,%rsp
mov    %rdi,%rbx
lea    0x18(%rdi),%rsi
mov    %rsp,%rdx
call   1030 <vector_product@plt>
movsd  0x30(%rbx),%xmm3
movsd  (%rsp),%xmm4
mulsd  %xmm3,%xmm4
xorpd  %xmm1,%xmm1
addsd  %xmm1,%xmm4
movsd  0x18(%rbx),%xmm5
movsd  0x20(%rbx),%xmm0
movsd  0x28(%rbx),%xmm2
movhpd (%rbx),%xmm5
mulpd  %xmm5,%xmm5
xorpd  %xmm6,%xmm6
addpd  %xmm5,%xmm6
mulsd  %xmm3,%xmm3
addsd  %xmm1,%xmm3
movsd  0x38(%rbx),%xmm5
movsd  0x8(%rsp),%xmm7
mulsd  %xmm5,%xmm7
addsd  %xmm4,%xmm7
movhpd 0x8(%rbx),%xmm0
mulpd  %xmm0,%xmm0
addpd  %xmm6,%xmm0
mulsd  %xmm5,%xmm5
addsd  %xmm3,%xmm5
movsd  0x40(%rbx),%xmm3
movsd  0x10(%rsp),%xmm4
mulsd  %xmm3,%xmm4
movhpd 0x10(%rbx),%xmm2
addsd  %xmm7,%xmm4
mulpd  %xmm2,%xmm2
addpd  %xmm0,%xmm2
mulsd  %xmm3,%xmm3
addsd  %xmm5,%xmm3
andpd  0xe37(%rip),%xmm4
movapd %xmm2,%xmm0
unpckhpd %xmm2,%xmm0
mulsd  %xmm2,%xmm0
mulsd  %xmm3,%xmm0
ucomisd %xmm1,%xmm0
jb     11e5 <calculate_volume_factor_3d+0xc5>
sqrtsd %xmm0,%xmm0
jmp    11f6 <calculate_volume_factor_3d+0xd6>
movapd %xmm4,0x20(%rsp)
call   1040 <sqrt@plt>
movapd 0x20(%rsp),%xmm4
divsd  %xmm0,%xmm4
movapd %xmm4,%xmm0
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @calculate_volume_factor_3d([3 x double]* %0) {
%2 = alloca [3 x double]*
%3 = alloca [3 x double]
%4 = alloca double
%5 = alloca [3 x double]
%6 = alloca i32
store [3 x double]* %0, [3 x double]** %2
%7 = load [3 x double]*, [3 x double]** %2
%8 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0
%9 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 0
%10 = load [3 x double]*, [3 x double]** %2
%11 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 1
%12 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 0
%13 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 0
%14 = call i32 @vector_product(double* %9, double* %12, double* %13)
store double 0.000000e+00, double* %4
%15 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 2
store double 0.000000e+00, double* %15
%16 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 1
store double 0.000000e+00, double* %16
%17 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 0
store double 0.000000e+00, double* %17
store i32 0, i32* %6
br label %18
18: ; preds = %79, %1
%19 = load i32, i32* %6
%20 = icmp slt i32 %19, 3
br i1 %20, label %21, label %82
21: ; preds = %18
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 %23
%25 = load double, double* %24
%26 = load [3 x double]*, [3 x double]** %2
%27 = getelementptr inbounds [3 x double], [3 x double]* %26, i64 2
%28 = load i32, i32* %6
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [3 x double], [3 x double]* %27, i64 0, i64 %29
%31 = load double, double* %30
%32 = load double, double* %4
%33 = call double @llvm.fmuladd.f64(double %25, double %31, double %32)
store double %33, double* %4
%34 = load [3 x double]*, [3 x double]** %2
%35 = getelementptr inbounds [3 x double], [3 x double]* %34, i64 0
%36 = load i32, i32* %6
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [3 x double], [3 x double]* %35, i64 0, i64 %37
%39 = load double, double* %38
%40 = load [3 x double]*, [3 x double]** %2
%41 = getelementptr inbounds [3 x double], [3 x double]* %40, i64 0
%42 = load i32, i32* %6
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [3 x double], [3 x double]* %41, i64 0, i64 %43
%45 = load double, double* %44
%46 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 0
%47 = load double, double* %46
%48 = call double @llvm.fmuladd.f64(double %39, double %45, double %47)
store double %48, double* %46
%49 = load [3 x double]*, [3 x double]** %2
%50 = getelementptr inbounds [3 x double], [3 x double]* %49, i64 1
%51 = load i32, i32* %6
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [3 x double], [3 x double]* %50, i64 0, i64 %52
%54 = load double, double* %53
%55 = load [3 x double]*, [3 x double]** %2
%56 = getelementptr inbounds [3 x double], [3 x double]* %55, i64 1
%57 = load i32, i32* %6
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [3 x double], [3 x double]* %56, i64 0, i64 %58
%60 = load double, double* %59
%61 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 1
%62 = load double, double* %61
%63 = call double @llvm.fmuladd.f64(double %54, double %60, double %62)
store double %63, double* %61
%64 = load [3 x double]*, [3 x double]** %2
%65 = getelementptr inbounds [3 x double], [3 x double]* %64, i64 2
%66 = load i32, i32* %6
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds [3 x double], [3 x double]* %65, i64 0, i64 %67
%69 = load double, double* %68
%70 = load [3 x double]*, [3 x double]** %2
%71 = getelementptr inbounds [3 x double], [3 x double]* %70, i64 2
%72 = load i32, i32* %6
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds [3 x double], [3 x double]* %71, i64 0, i64 %73
%75 = load double, double* %74
%76 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 2
%77 = load double, double* %76
%78 = call double @llvm.fmuladd.f64(double %69, double %75, double %77)
store double %78, double* %76
br label %79
79: ; preds = %21
%80 = load i32, i32* %6
%81 = add nsw i32 %80, 1
store i32 %81, i32* %6
br label %18
82: ; preds = %18
%83 = load double, double* %4
%84 = call double @llvm.fabs.f64(double %83)
%85 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 0
%86 = load double, double* %85
%87 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 1
%88 = load double, double* %87
%89 = fmul double %86, %88
%90 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 2
%91 = load double, double* %90
%92 = fmul double %89, %91
%93 = call double @sqrt(double %92)
%94 = fdiv double %84, %93
ret double %94
}

LLVM IR (-O2):
define double @calculate_volume_factor_3d([3 x double]* %0) {
%2 = alloca [3 x double]
%3 = bitcast [3 x double]* %2 to i8*
%4 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 0, i64 0
%5 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 1, i64 0
%6 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 0
%7 = call i32 @vector_product(double* %4, double* %5, double* %6)
%8 = load double, double* %6
%9 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 2, i64 0
%10 = load double, double* %9
%11 = call double @llvm.fmuladd.f64(double %8, double %10, double 0.000000e+00)
%12 = load double, double* %4
%13 = load double, double* %5
%14 = insertelement <2 x double> poison, double %13, i64 0
%15 = insertelement <2 x double> %14, double %12, i64 1
%16 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %15, <2 x double> %15, <2 x double> zeroinitializer)
%17 = call double @llvm.fmuladd.f64(double %10, double %10, double 0.000000e+00)
%18 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 1
%19 = load double, double* %18
%20 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 2, i64 1
%21 = load double, double* %20
%22 = call double @llvm.fmuladd.f64(double %19, double %21, double %11)
%23 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 0, i64 1
%24 = load double, double* %23
%25 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 1, i64 1
%26 = load double, double* %25
%27 = insertelement <2 x double> poison, double %26, i64 0
%28 = insertelement <2 x double> %27, double %24, i64 1
%29 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %28, <2 x double> %28, <2 x double> %16)
%30 = call double @llvm.fmuladd.f64(double %21, double %21, double %17)
%31 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 2
%32 = load double, double* %31
%33 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 2, i64 2
%34 = load double, double* %33
%35 = call double @llvm.fmuladd.f64(double %32, double %34, double %22)
%36 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 0, i64 2
%37 = load double, double* %36
%38 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 1, i64 2
%39 = load double, double* %38
%40 = insertelement <2 x double> poison, double %39, i64 0
%41 = insertelement <2 x double> %40, double %37, i64 1
%42 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %41, <2 x double> %41, <2 x double> %29)
%43 = call double @llvm.fmuladd.f64(double %34, double %34, double %30)
%44 = call double @llvm.fabs.f64(double %35)
%45 = shufflevector <2 x double> %42, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%46 = fmul <2 x double> %42, %45
%47 = extractelement <2 x double> %46, i64 0
%48 = fmul double %43, %47
%49 = call double @sqrt(double %48)
%50 = fdiv double %44, %49
ret double %50
}