#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*/ det(double **, int);
double fabs(int /*<<< orphan*/);
int /*<<< orphan*/ free_matrix2(double **);
int /*<<< orphan*/ inv(double **, double **, int);
int /*<<< orphan*/ matrix_vec_mult(double *, double **, double *, int, int);
int /*<<< orphan*/ mult(double *, double *, int, int);
double **new_matrix2(int, int);
int /*<<< orphan*/ reorder_rows(double **, double **, int *, int, int);
void cross4d(double w[4], double x[4], double y[4], double z[4]) {
  double **V = new_matrix2(4, 3);
  int i;
  for (i = 0; i < 4; ++i) {
    V[i][0] = x[i];
    V[i][1] = y[1];
    V[i][2] = z[i];
  }
  double **W = new_matrix2(3, 3);
  int indices[4][3] = {{2, 3, 4}, {1, 3, 4}, {1, 2, 4}, {1, 2, 3}};
  int cut_axis = 0;
  double dmax = 0;
  for (i = 0; i < 4; ++i) {
    reorder_rows(W, V, indices[i], 3, 3);
    double tmp = fabs(det(W, 3));
    if (dmax < tmp) {
      dmax = tmp;
      cut_axis = i;
    }
  }
  double *c0 = V[cut_axis];
  int uncut_axis[3];
  for (i = 0; i < cut_axis; ++i) {
    uncut_axis[i] = i;
    w[i] = 0;
  }
  for (i = cut_axis + 1; i < 4; ++i) {
    uncut_axis[i - 1] = i;
    w[i] = 0;
  }
  w[cut_axis] = 1;
  reorder_rows(W, V, uncut_axis, 3, 3);
  inv(W, W, 3);
  mult(c0, c0, -1, 3);
  double tmp[3];
  matrix_vec_mult(tmp, W, c0, 3, 3);
  for (i = 0; i < 3; ++i) {
    w[uncut_axis[i]] = tmp[i];
  }
  free_matrix2(V);
  free_matrix2(W);
}


x86 assembly (clang, -O0):
<cross4d>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    $0x4,%edi
mov    $0x3,%esi
call   1090 <new_matrix2@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x4,-0x2c(%rbp)
jge    1232 <cross4d+0xa2>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsd  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsd  %xmm0,0x10(%rax)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11c5 <cross4d+0x35>
mov    $0x3,%esi
mov    %esi,%edi
call   1090 <new_matrix2@plt>
mov    %rax,-0x38(%rbp)
lea    -0x70(%rbp),%rdi
lea    0xdc3(%rip),%rsi
mov    $0x30,%edx
call   1040 <memcpy@plt>
movl   $0x0,-0x74(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x80(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x4,-0x2c(%rbp)
jge    12f6 <cross4d+0x166>
mov    -0x38(%rbp),%rdi
mov    -0x28(%rbp),%rsi
movslq -0x2c(%rbp),%rax
lea    -0x70(%rbp),%rdx
imul   $0xc,%rax,%rax
add    %rax,%rdx
mov    $0x3,%r8d
mov    %r8d,%ecx
call   1080 <reorder_rows@plt>
mov    -0x38(%rbp),%rdi
mov    $0x3,%esi
call   10a0 <det@plt>
mov    %eax,%edi
call   1030 <fabs@plt>
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x80(%rbp),%xmm1
movsd  -0x88(%rbp),%xmm0
ff
ucomisd %xmm1,%xmm0
jbe    12e3 <cross4d+0x153>
movsd  -0x88(%rbp),%xmm0
ff
movsd  %xmm0,-0x80(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x74(%rbp)
jmp    12e8 <cross4d+0x158>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    126d <cross4d+0xdd>
mov    -0x28(%rbp),%rax
movslq -0x74(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x90(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x74(%rbp),%eax
jge    1348 <cross4d+0x1b8>
mov    -0x2c(%rbp),%ecx
movslq -0x2c(%rbp),%rax
mov    %ecx,-0x9c(%rbp,%rax,4)
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1310 <cross4d+0x180>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
cmpl   $0x4,-0x2c(%rbp)
jge    138b <cross4d+0x1fb>
mov    -0x2c(%rbp),%ecx
mov    -0x2c(%rbp),%eax
sub    $0x1,%eax
cltq
mov    %ecx,-0x9c(%rbp,%rax,4)
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1351 <cross4d+0x1c1>
mov    -0x8(%rbp),%rax
movslq -0x74(%rbp),%rcx
movsd  0xc65(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x38(%rbp),%rdi
mov    -0x28(%rbp),%rsi
lea    -0x9c(%rbp),%rdx
mov    $0x3,%r8d
mov    %r8d,%ecx
call   1080 <reorder_rows@plt>
mov    -0x38(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    $0x3,%edx
call   1070 <inv@plt>
mov    -0x90(%rbp),%rdi
mov    -0x90(%rbp),%rsi
mov    $0xffffffff,%edx
mov    $0x3,%ecx
call   1060 <mult@plt>
lea    -0xc0(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x90(%rbp),%rdx
mov    $0x3,%r8d
mov    %r8d,%ecx
call   10b0 <matrix_vec_mult@plt>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x3,-0x2c(%rbp)
jge    144d <cross4d+0x2bd>
movslq -0x2c(%rbp),%rax
movsd  -0xc0(%rbp,%rax,8),%xmm0
ff ff
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movslq -0x9c(%rbp,%rcx,4),%rcx
ff
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1413 <cross4d+0x283>
mov    -0x28(%rbp),%rdi
call   1050 <free_matrix2@plt>
mov    -0x38(%rbp),%rdi
call   1050 <free_matrix2@plt>
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cross4d>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %rcx,%r12
mov    %rdx,%r13
mov    %rsi,%rbx
mov    %rdi,%r14
mov    $0x4,%edi
mov    $0x3,%esi
call   1090 <new_matrix2@plt>
mov    %rax,%r15
movsd  (%rbx),%xmm0
mov    (%rax),%rax
movsd  %xmm0,(%rax)
movsd  0x8(%r13),%xmm0
movsd  %xmm0,0x8(%rax)
movsd  (%r12),%xmm0
movsd  %xmm0,0x10(%rax)
movsd  0x8(%rbx),%xmm0
mov    0x8(%r15),%rax
movsd  %xmm0,(%rax)
movsd  0x8(%r13),%xmm0
movsd  %xmm0,0x8(%rax)
movsd  0x8(%r12),%xmm0
movsd  %xmm0,0x10(%rax)
movsd  0x10(%rbx),%xmm0
mov    0x10(%r15),%rax
movsd  %xmm0,(%rax)
movsd  0x8(%r13),%xmm0
movsd  %xmm0,0x8(%rax)
movsd  0x10(%r12),%xmm0
movsd  %xmm0,0x10(%rax)
movsd  0x18(%rbx),%xmm0
mov    0x18(%r15),%rax
movsd  %xmm0,(%rax)
movsd  0x8(%r13),%xmm0
movsd  %xmm0,0x8(%rax)
movsd  0x18(%r12),%xmm0
movsd  %xmm0,0x10(%rax)
mov    $0x3,%edi
mov    $0x3,%esi
call   1090 <new_matrix2@plt>
mov    %rax,%r13
movaps 0xdbe(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xda2(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movapd 0xd85(%rip),%xmm0
movapd %xmm0,0x40(%rsp)
lea    0x40(%rsp),%rdx
mov    %r13,%rdi
mov    %r15,%rsi
mov    $0x3,%ecx
mov    $0x3,%r8d
call   1080 <reorder_rows@plt>
mov    %r13,%rdi
mov    $0x3,%esi
call   10a0 <det@plt>
mov    %eax,%edi
call   1040 <fabs@plt>
xorpd  %xmm1,%xmm1
maxsd  %xmm1,%xmm0
movsd  %xmm0,(%rsp)
lea    0x4c(%rsp),%rdx
mov    %r13,%rdi
mov    %r15,%rsi
mov    $0x3,%ecx
mov    $0x3,%r8d
call   1080 <reorder_rows@plt>
mov    %r13,%rdi
mov    $0x3,%esi
call   10a0 <det@plt>
mov    %eax,%edi
call   1040 <fabs@plt>
xor    %ebx,%ebx
movsd  (%rsp),%xmm1
ucomisd %xmm1,%xmm0
seta   %bl
maxsd  %xmm1,%xmm0
movsd  %xmm0,(%rsp)
lea    0x58(%rsp),%rdx
mov    %r13,%rdi
mov    %r15,%rsi
mov    $0x3,%ecx
mov    $0x3,%r8d
call   1080 <reorder_rows@plt>
mov    %r13,%rdi
mov    $0x3,%esi
call   10a0 <det@plt>
mov    %eax,%edi
call   1040 <fabs@plt>
movsd  (%rsp),%xmm1
ucomisd %xmm1,%xmm0
maxsd  %xmm1,%xmm0
movsd  %xmm0,(%rsp)
mov    $0x2,%ebp
cmovbe %ebx,%ebp
lea    0x64(%rsp),%rdx
mov    %r13,%rdi
mov    %r15,%rsi
mov    $0x3,%ecx
mov    $0x3,%r8d
call   1080 <reorder_rows@plt>
mov    %r13,%rdi
mov    $0x3,%esi
call   10a0 <det@plt>
mov    %eax,%edi
call   1040 <fabs@plt>
ucomisd (%rsp),%xmm0
mov    $0x3,%eax
cmova  %eax,%ebp
mov    (%r15,%rbp,8),%r12
test   %ebp,%ebp
je     13cf <cross4d+0x23f>
lea    0x0(,%rbp,8),%edx
mov    %r14,%rdi
xor    %esi,%esi
movsd  %xmm0,0x18(%rsp)
call   1030 <memset@plt>
movsd  0x18(%rsp),%xmm0
movl   $0x0,0xc(%rsp)
cmp    $0x1,%ebp
je     13cf <cross4d+0x23f>
movl   $0x1,0x10(%rsp)
cmp    $0x2,%ebp
je     13cf <cross4d+0x23f>
movl   $0x2,0x14(%rsp)
ucomisd (%rsp),%xmm0
ja     1411 <cross4d+0x281>
lea    (%r14,%rbp,8),%rdi
add    $0x8,%rdi
mov    $0x2,%eax
sub    %ebp,%eax
lea    0x8(,%rax,8),%rdx
xor    %esi,%esi
call   1030 <memset@plt>
mov    %rbp,%rax
nopw   0x0(%rax,%rax,1)
lea    0x1(%rax),%rcx
mov    %ecx,0xc(%rsp,%rax,4)
mov    %rcx,%rax
cmp    $0x3,%rcx
jne    1400 <cross4d+0x270>
movabs $0x3ff0000000000000,%rax
mov    %rax,(%r14,%rbp,8)
lea    0xc(%rsp),%rdx
mov    %r13,%rdi
mov    %r15,%rsi
mov    $0x3,%ecx
mov    $0x3,%r8d
call   1080 <reorder_rows@plt>
mov    %r13,%rdi
mov    %r13,%rsi
mov    $0x3,%edx
call   1070 <inv@plt>
mov    %r12,%rdi
mov    %r12,%rsi
mov    $0xffffffff,%edx
mov    $0x3,%ecx
call   1060 <mult@plt>
lea    0x20(%rsp),%rdi
mov    %r13,%rsi
mov    %r12,%rdx
mov    $0x3,%ecx
mov    $0x3,%r8d
call   10b0 <matrix_vec_mult@plt>
movsd  0x20(%rsp),%xmm0
movslq 0xc(%rsp),%rax
movsd  %xmm0,(%r14,%rax,8)
movsd  0x28(%rsp),%xmm0
movslq 0x10(%rsp),%rax
movsd  %xmm0,(%r14,%rax,8)
movsd  0x30(%rsp),%xmm0
movslq 0x14(%rsp),%rax
movsd  %xmm0,(%r14,%rax,8)
mov    %r15,%rdi
call   1050 <free_matrix2@plt>
mov    %r13,%rdi
call   1050 <free_matrix2@plt>
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.cross4d.indices = [4 x [3 x i32]] [[3 x i32] [i32 2, i32 3, i32 4], [3 x i32] [i32 1, i32 3, i32 4], [3 x i32] [i32 1, i32 2, i32 4], [3 x i32] [i32 1, i32 2, i32 3]]
define void @cross4d(double* %0, double* %1, double* %2, double* %3) {
%5 = alloca double*
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca double**
%10 = alloca i32
%11 = alloca double**
%12 = alloca [4 x [3 x i32]]
%13 = alloca i32
%14 = alloca double
%15 = alloca double
%16 = alloca double*
%17 = alloca [3 x i32]
%18 = alloca [3 x double]
store double* %0, double** %5
store double* %1, double** %6
store double* %2, double** %7
store double* %3, double** %8
%19 = call double** @new_matrix2(i32 4, i32 3)
store double** %19, double*** %9
store i32 0, i32* %10
br label %20
20: ; preds = %55, %4
%21 = load i32, i32* %10
%22 = icmp slt i32 %21, 4
br i1 %22, label %23, label %58
23: ; preds = %20
%24 = load double*, double** %6
%25 = load i32, i32* %10
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds double, double* %24, i64 %26
%28 = load double, double* %27
%29 = load double**, double*** %9
%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 = getelementptr inbounds double, double* %33, i64 0
store double %28, double* %34
%35 = load double*, double** %7
%36 = getelementptr inbounds double, double* %35, i64 1
%37 = load double, double* %36
%38 = load double**, double*** %9
%39 = load i32, i32* %10
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds double*, double** %38, i64 %40
%42 = load double*, double** %41
%43 = getelementptr inbounds double, double* %42, i64 1
store double %37, double* %43
%44 = load double*, double** %8
%45 = load i32, i32* %10
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds double, double* %44, i64 %46
%48 = load double, double* %47
%49 = load double**, double*** %9
%50 = load i32, i32* %10
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds double*, double** %49, i64 %51
%53 = load double*, double** %52
%54 = getelementptr inbounds double, double* %53, i64 2
store double %48, double* %54
br label %55
55: ; preds = %23
%56 = load i32, i32* %10
%57 = add nsw i32 %56, 1
store i32 %57, i32* %10
br label %20
58: ; preds = %20
%59 = call double** @new_matrix2(i32 3, i32 3)
store double** %59, double*** %11
%60 = bitcast [4 x [3 x i32]]* %12 to i8*
store i32 0, i32* %13
store double 0.000000e+00, double* %14
store i32 0, i32* %10
br label %61
61: ; preds = %82, %58
%62 = load i32, i32* %10
%63 = icmp slt i32 %62, 4
br i1 %63, label %64, label %85
64: ; preds = %61
%65 = load double**, double*** %11
%66 = load double**, double*** %9
%67 = load i32, i32* %10
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [4 x [3 x i32]], [4 x [3 x i32]]* %12, i64 0, i64 %68
%70 = getelementptr inbounds [3 x i32], [3 x i32]* %69, i64 0, i64 0
%71 = call i32 @reorder_rows(double** %65, double** %66, i32* %70, i32 3, i32 3)
%72 = load double**, double*** %11
%73 = call i32 @det(double** %72, i32 3)
%74 = call double @fabs(i32 %73)
store double %74, double* %15
%75 = load double, double* %14
%76 = load double, double* %15
%77 = fcmp olt double %75, %76
br i1 %77, label %78, label %81
78: ; preds = %64
%79 = load double, double* %15
store double %79, double* %14
%80 = load i32, i32* %10
store i32 %80, i32* %13
br label %81
81: ; preds = %78, %64
br label %82
82: ; preds = %81
%83 = load i32, i32* %10
%84 = add nsw i32 %83, 1
store i32 %84, i32* %10
br label %61
85: ; preds = %61
%86 = load double**, double*** %9
%87 = load i32, i32* %13
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds double*, double** %86, i64 %88
%90 = load double*, double** %89
store double* %90, double** %16
store i32 0, i32* %10
br label %91
91: ; preds = %104, %85
%92 = load i32, i32* %10
%93 = load i32, i32* %13
%94 = icmp slt i32 %92, %93
br i1 %94, label %95, label %107
95: ; preds = %91
%96 = load i32, i32* %10
%97 = load i32, i32* %10
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds [3 x i32], [3 x i32]* %17, i64 0, i64 %98
store i32 %96, i32* %99
%100 = load double*, double** %5
%101 = load i32, i32* %10
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds double, double* %100, i64 %102
store double 0.000000e+00, double* %103
br label %104
104: ; preds = %95
%105 = load i32, i32* %10
%106 = add nsw i32 %105, 1
store i32 %106, i32* %10
br label %91
107: ; preds = %91
%108 = load i32, i32* %13
%109 = add nsw i32 %108, 1
store i32 %109, i32* %10
br label %110
110: ; preds = %123, %107
%111 = load i32, i32* %10
%112 = icmp slt i32 %111, 4
br i1 %112, label %113, label %126
113: ; preds = %110
%114 = load i32, i32* %10
%115 = load i32, i32* %10
%116 = sub nsw i32 %115, 1
%117 = sext i32 %116 to i64
%118 = getelementptr inbounds [3 x i32], [3 x i32]* %17, i64 0, i64 %117
store i32 %114, i32* %118
%119 = load double*, double** %5
%120 = load i32, i32* %10
%121 = sext i32 %120 to i64
%122 = getelementptr inbounds double, double* %119, i64 %121
store double 0.000000e+00, double* %122
br label %123
123: ; preds = %113
%124 = load i32, i32* %10
%125 = add nsw i32 %124, 1
store i32 %125, i32* %10
br label %110
126: ; preds = %110
%127 = load double*, double** %5
%128 = load i32, i32* %13
%129 = sext i32 %128 to i64
%130 = getelementptr inbounds double, double* %127, i64 %129
store double 1.000000e+00, double* %130
%131 = load double**, double*** %11
%132 = load double**, double*** %9
%133 = getelementptr inbounds [3 x i32], [3 x i32]* %17, i64 0, i64 0
%134 = call i32 @reorder_rows(double** %131, double** %132, i32* %133, i32 3, i32 3)
%135 = load double**, double*** %11
%136 = load double**, double*** %11
%137 = call i32 @inv(double** %135, double** %136, i32 3)
%138 = load double*, double** %16
%139 = load double*, double** %16
%140 = call i32 @mult(double* %138, double* %139, i32 -1, i32 3)
%141 = getelementptr inbounds [3 x double], [3 x double]* %18, i64 0, i64 0
%142 = load double**, double*** %11
%143 = load double*, double** %16
%144 = call i32 @matrix_vec_mult(double* %141, double** %142, double* %143, i32 3, i32 3)
store i32 0, i32* %10
br label %145
145: ; preds = %160, %126
%146 = load i32, i32* %10
%147 = icmp slt i32 %146, 3
br i1 %147, label %148, label %163
148: ; preds = %145
%149 = load i32, i32* %10
%150 = sext i32 %149 to i64
%151 = getelementptr inbounds [3 x double], [3 x double]* %18, i64 0, i64 %150
%152 = load double, double* %151
%153 = load double*, double** %5
%154 = load i32, i32* %10
%155 = sext i32 %154 to i64
%156 = getelementptr inbounds [3 x i32], [3 x i32]* %17, i64 0, i64 %155
%157 = load i32, i32* %156
%158 = sext i32 %157 to i64
%159 = getelementptr inbounds double, double* %153, i64 %158
store double %152, double* %159
br label %160
160: ; preds = %148
%161 = load i32, i32* %10
%162 = add nsw i32 %161, 1
store i32 %162, i32* %10
br label %145
163: ; preds = %145
%164 = load double**, double*** %9
%165 = call i32 @free_matrix2(double** %164)
%166 = load double**, double*** %11
%167 = call i32 @free_matrix2(double** %166)
ret void
}

LLVM IR (-O2):
@__const.cross4d.indices = [4 x [3 x i32]] [[3 x i32] [i32 2, i32 3, i32 4], [3 x i32] [i32 1, i32 3, i32 4], [3 x i32] [i32 1, i32 2, i32 4], [3 x i32] [i32 1, i32 2, i32 3]]
define void @cross4d(double* nocapture writeonly %0, double* nocapture %1, double* nocapture %2, double* nocapture %3) {
%5 = alloca [4 x [3 x i32]]
%6 = alloca [3 x i32]
%7 = alloca [3 x double]
%8 = tail call double** @new_matrix2(i32 4, i32 3)
%9 = getelementptr inbounds double, double* %2, i64 1
%10 = load double, double* %1
%11 = load double*, double** %8
store double %10, double* %11
%12 = load double, double* %9
%13 = getelementptr inbounds double, double* %11, i64 1
store double %12, double* %13
%14 = load double, double* %3
%15 = getelementptr inbounds double, double* %11, i64 2
store double %14, double* %15
%16 = getelementptr inbounds double, double* %1, i64 1
%17 = load double, double* %16
%18 = getelementptr inbounds double*, double** %8, i64 1
%19 = load double*, double** %18
store double %17, double* %19
%20 = load double, double* %9
%21 = getelementptr inbounds double, double* %19, i64 1
store double %20, double* %21
%22 = getelementptr inbounds double, double* %3, i64 1
%23 = load double, double* %22
%24 = getelementptr inbounds double, double* %19, i64 2
store double %23, double* %24
%25 = getelementptr inbounds double, double* %1, i64 2
%26 = load double, double* %25
%27 = getelementptr inbounds double*, double** %8, i64 2
%28 = load double*, double** %27
store double %26, double* %28
%29 = load double, double* %9
%30 = getelementptr inbounds double, double* %28, i64 1
store double %29, double* %30
%31 = getelementptr inbounds double, double* %3, i64 2
%32 = load double, double* %31
%33 = getelementptr inbounds double, double* %28, i64 2
store double %32, double* %33
%34 = getelementptr inbounds double, double* %1, i64 3
%35 = load double, double* %34
%36 = getelementptr inbounds double*, double** %8, i64 3
%37 = load double*, double** %36
store double %35, double* %37
%38 = load double, double* %9
%39 = getelementptr inbounds double, double* %37, i64 1
store double %38, double* %39
%40 = getelementptr inbounds double, double* %3, i64 3
%41 = load double, double* %40
%42 = getelementptr inbounds double, double* %37, i64 2
store double %41, double* %42
%43 = tail call double** @new_matrix2(i32 3, i32 3)
%44 = bitcast [4 x [3 x i32]]* %5 to i8*
%45 = getelementptr inbounds [4 x [3 x i32]], [4 x [3 x i32]]* %5, i64 0, i64 0, i64 0
%46 = call i32 @reorder_rows(double** %43, double** %8, i32* %45, i32 3, i32 3)
%47 = call i32 @det(double** %43, i32 3)
%48 = call double @fabs(i32 %47)
%49 = fcmp ogt double %48, 0.000000e+00
%50 = select i1 %49, double %48, double 0.000000e+00
%51 = getelementptr inbounds [4 x [3 x i32]], [4 x [3 x i32]]* %5, i64 0, i64 1, i64 0
%52 = call i32 @reorder_rows(double** %43, double** %8, i32* %51, i32 3, i32 3)
%53 = call i32 @det(double** %43, i32 3)
%54 = call double @fabs(i32 %53)
%55 = fcmp olt double %50, %54
%56 = select i1 %55, double %54, double %50
%57 = zext i1 %55 to i32
%58 = getelementptr inbounds [4 x [3 x i32]], [4 x [3 x i32]]* %5, i64 0, i64 2, i64 0
%59 = call i32 @reorder_rows(double** %43, double** %8, i32* %58, i32 3, i32 3)
%60 = call i32 @det(double** %43, i32 3)
%61 = call double @fabs(i32 %60)
%62 = fcmp olt double %56, %61
%63 = select i1 %62, double %61, double %56
%64 = select i1 %62, i32 2, i32 %57
%65 = getelementptr inbounds [4 x [3 x i32]], [4 x [3 x i32]]* %5, i64 0, i64 3, i64 0
%66 = call i32 @reorder_rows(double** %43, double** %8, i32* %65, i32 3, i32 3)
%67 = call i32 @det(double** %43, i32 3)
%68 = call double @fabs(i32 %67)
%69 = fcmp olt double %63, %68
%70 = select i1 %69, i32 3, i32 %64
%71 = zext i32 %70 to i64
%72 = getelementptr inbounds double*, double** %8, i64 %71
%73 = load double*, double** %72
%74 = bitcast [3 x i32]* %6 to i8*
%75 = icmp eq i32 %70, 0
br i1 %75, label %82, label %76
76: ; preds = %4
%77 = bitcast double* %0 to i8*
%78 = shl nuw nsw i32 %70, 3
%79 = zext i32 %78 to i64
%80 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 0
store i32 0, i32* %80
%81 = icmp eq i32 %70, 1
br i1 %81, label %82, label %92
82: ; preds = %76, %92, %95, %4
br i1 %69, label %103, label %83
83: ; preds = %82
%84 = zext i32 %70 to i64
%85 = add nuw nsw i64 %84, 1
%86 = getelementptr double, double* %0, i64 %85
%87 = bitcast double* %86 to i8*
%88 = sub nsw i32 2, %70
%89 = zext i32 %88 to i64
%90 = shl nuw nsw i64 %89, 3
%91 = add nuw nsw i64 %90, 8
br label %97
92: ; preds = %76
%93 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 1
store i32 1, i32* %93
%94 = icmp eq i32 %70, 2
br i1 %94, label %82, label %95
95: ; preds = %92
%96 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 2
store i32 2, i32* %96
br label %82
97: ; preds = %83, %97
%98 = phi i64 [ %84, %83 ], [ %99, %97 ]
%99 = add nuw nsw i64 %98, 1
%100 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 %98
%101 = trunc i64 %99 to i32
store i32 %101, i32* %100
%102 = icmp eq i64 %99, 3
br i1 %102, label %103, label %97
103: ; preds = %97, %82
%104 = getelementptr inbounds double, double* %0, i64 %71
store double 1.000000e+00, double* %104
%105 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 0
%106 = call i32 @reorder_rows(double** %43, double** %8, i32* %105, i32 3, i32 3)
%107 = call i32 @inv(double** %43, double** %43, i32 3)
%108 = call i32 @mult(double* %73, double* %73, i32 -1, i32 3)
%109 = bitcast [3 x double]* %7 to i8*
%110 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 0
%111 = call i32 @matrix_vec_mult(double* %110, double** %43, double* %73, i32 3, i32 3)
%112 = load double, double* %110
%113 = load i32, i32* %105
%114 = sext i32 %113 to i64
%115 = getelementptr inbounds double, double* %0, i64 %114
store double %112, double* %115
%116 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 1
%117 = load double, double* %116
%118 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 1
%119 = load i32, i32* %118
%120 = sext i32 %119 to i64
%121 = getelementptr inbounds double, double* %0, i64 %120
store double %117, double* %121
%122 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 2
%123 = load double, double* %122
%124 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 2
%125 = load i32, i32* %124
%126 = sext i32 %125 to i64
%127 = getelementptr inbounds double, double* %0, i64 %126
store double %123, double* %127
%128 = call i32 @free_matrix2(double** %8)
%129 = call i32 @free_matrix2(double** %43)
ret void
}