#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 calculate_volume_factor_2d(double **);
double calculate_volume_factor_3d(double **);
int sqrt(int);
int /*<<< orphan*/ test_double(int, double, double const, char *);
void test_volume_factors(void) {
  double a[3][3] = {
      {0.28165, 0.28165, 0}, {0.28165, 0, 0.28165}, {0, 0.28165, 0.28165}};
  double vf_3d = calculate_volume_factor_3d(a);
  double vf_2d = calculate_volume_factor_2d(a);
  const double tol = 1E-8;
  test_double(1 / sqrt(2), vf_3d, tol, "VF_3D");
  test_double(sqrt(3) / 2, vf_2d, tol, "VF_2D");
}


x86 assembly (clang, -O0):
<test_volume_factors>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x48,%edx
call   1040 <memset@plt>
movsd  0xe98(%rip),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xe8b(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xe7e(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe71(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe64(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe57(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
lea    -0x50(%rbp),%rdi
call   1030 <calculate_volume_factor_3d@plt>
movsd  %xmm0,-0x58(%rbp)
lea    -0x50(%rbp),%rdi
call   1050 <calculate_volume_factor_2d@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  0xe26(%rip),%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    $0x2,%edi
call   1070 <sqrt@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cltd
idiv   %ecx
mov    %eax,%edi
movsd  -0x58(%rbp),%xmm0
movsd  0xdfe(%rip),%xmm1
lea    0xe07(%rip),%rsi
call   1060 <test_double@plt>
mov    $0x3,%edi
call   1070 <sqrt@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
movsd  -0x60(%rbp),%xmm0
movsd  0xdd1(%rip),%xmm1
lea    0xde0(%rip),%rsi
call   1060 <test_double@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_volume_factors>:
push   %rbx
sub    $0x60,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x40(%rsp)
movaps 0xea2(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movabs $0x3fd2068db8bac711,%rax
06 d2 3f
mov    %rax,0x28(%rsp)
mov    %rax,0x38(%rsp)
movups %xmm0,0x48(%rsp)
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <calculate_volume_factor_3d@plt>
movsd  %xmm0,(%rsp)
mov    %rbx,%rdi
call   1040 <calculate_volume_factor_2d@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0x2,%edi
call   1060 <sqrt@plt>
lea    0x1(%rax),%ecx
xor    %edi,%edi
cmp    $0x3,%ecx
cmovb  %eax,%edi
lea    0xe60(%rip),%rsi
movsd  0xe50(%rip),%xmm1
movsd  (%rsp),%xmm0
call   1050 <test_double@plt>
mov    $0x3,%edi
call   1060 <sqrt@plt>
mov    %eax,%edi
shr    $0x1f,%edi
add    %eax,%edi
sar    %edi
lea    0xe3a(%rip),%rsi
movsd  0x8(%rsp),%xmm0
movsd  0xe1e(%rip),%xmm1
call   1050 <test_double@plt>
add    $0x60,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"VF_3D\00"
@.str.1 = [6 x i8] c"VF_2D\00"
define void @test_volume_factors() {
%1 = alloca [3 x [3 x double]]
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = bitcast [3 x [3 x double]]* %1 to i8*
%6 = bitcast i8* %5 to [3 x [3 x double]]*
%7 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %6, i32 0, i32 0
%8 = getelementptr inbounds [3 x double], [3 x double]* %7, i32 0, i32 0
store double 2.816500e-01, double* %8
%9 = getelementptr inbounds [3 x double], [3 x double]* %7, i32 0, i32 1
store double 2.816500e-01, double* %9
%10 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %6, i32 0, i32 1
%11 = getelementptr inbounds [3 x double], [3 x double]* %10, i32 0, i32 0
store double 2.816500e-01, double* %11
%12 = getelementptr inbounds [3 x double], [3 x double]* %10, i32 0, i32 2
store double 2.816500e-01, double* %12
%13 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %6, i32 0, i32 2
%14 = getelementptr inbounds [3 x double], [3 x double]* %13, i32 0, i32 1
store double 2.816500e-01, double* %14
%15 = getelementptr inbounds [3 x double], [3 x double]* %13, i32 0, i32 2
store double 2.816500e-01, double* %15
%16 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %1, i64 0, i64 0
%17 = bitcast [3 x double]* %16 to double**
%18 = call double @calculate_volume_factor_3d(double** %17)
store double %18, double* %2
%19 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %1, i64 0, i64 0
%20 = bitcast [3 x double]* %19 to double**
%21 = call double @calculate_volume_factor_2d(double** %20)
store double %21, double* %3
store double 1.000000e-08, double* %4
%22 = call i32 @sqrt(i32 2)
%23 = sdiv i32 1, %22
%24 = load double, double* %2
%25 = call i32 @test_double(i32 %23, double %24, double 1.000000e-08, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%26 = call i32 @sqrt(i32 3)
%27 = sdiv i32 %26, 2
%28 = load double, double* %3
%29 = call i32 @test_double(i32 %27, double %28, double 1.000000e-08, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"VF_3D\00"
@.str.1 = [6 x i8] c"VF_2D\00"
define void @test_volume_factors() {
%1 = alloca [3 x [3 x double]]
%2 = bitcast [3 x [3 x double]]* %1 to i8*
%3 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %1, i64 0, i64 0, i64 2
%4 = bitcast double* %3 to i8*
%5 = bitcast [3 x [3 x double]]* %1 to <2 x double>*
store <2 x double> <double 2.816500e-01, double 2.816500e-01>, <2 x double>* %5
%6 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %1, i64 0, i64 1, i64 0
store double 2.816500e-01, double* %6
%7 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %1, i64 0, i64 1, i64 2
store double 2.816500e-01, double* %7
%8 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %1, i64 0, i64 2, i64 1
%9 = bitcast double* %8 to <2 x double>*
store <2 x double> <double 2.816500e-01, double 2.816500e-01>, <2 x double>* %9
%10 = bitcast [3 x [3 x double]]* %1 to double**
%11 = call double @calculate_volume_factor_3d(double** %10)
%12 = call double @calculate_volume_factor_2d(double** %10)
%13 = call i32 @sqrt(i32 2)
%14 = add i32 %13, 1
%15 = icmp ult i32 %14, 3
%16 = select i1 %15, i32 %13, i32 0
%17 = call i32 @test_double(i32 %16, double %11, double 1.000000e-08, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%18 = call i32 @sqrt(i32 3)
%19 = sdiv i32 %18, 2
%20 = call i32 @test_double(i32 %19, double %12, double 1.000000e-08, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
ret void
}