#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 determinant2x2(double, double, double, double);
double determinant3x3(double, double, double, double, double, double, double,
                      double, double);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
double *new_doubarray(int);
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ stderr;
double *invert3x3(double a11, double a12, double a13, double a21, double a22,
                  double a23, double a31, double a32, double a33) {
  double deta;
  double *invmatx = NULL;
  deta = determinant3x3(a11, a12, a13, a21, a22, a23, a31, a32, a33);
  if (deta == 0.0) {
    fprintf(stderr, "ERROR: invert3x3.  Input matrix is singular.\n");
    return NULL;
  }
  printf("invert3x3: determinant = %g\n", deta);
  if (!(invmatx = new_doubarray(9))) {
    fprintf(stderr, "ERROR: invert3x3\n");
    return NULL;
  }
  invmatx[0] = determinant2x2(a22, a23, a32, a33) / deta;
  invmatx[1] = determinant2x2(a13, a12, a33, a32) / deta;
  invmatx[2] = determinant2x2(a12, a13, a22, a23) / deta;
  invmatx[3] = determinant2x2(a23, a21, a33, a31) / deta;
  invmatx[4] = determinant2x2(a11, a13, a31, a33) / deta;
  invmatx[5] = determinant2x2(a13, a11, a23, a21) / deta;
  invmatx[6] = determinant2x2(a21, a22, a31, a32) / deta;
  invmatx[7] = determinant2x2(a12, a11, a32, a31) / deta;
  invmatx[8] = determinant2x2(a11, a12, a21, a22) / deta;
  return invmatx;
}


x86 assembly (clang, -O0):
<invert3x3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  0x10(%rbp),%xmm8
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
movsd  %xmm4,-0x30(%rbp)
movsd  %xmm5,-0x38(%rbp)
movsd  %xmm6,-0x40(%rbp)
movsd  %xmm7,-0x48(%rbp)
movq   $0x0,-0x58(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm3
movsd  -0x30(%rbp),%xmm4
movsd  -0x38(%rbp),%xmm5
movsd  -0x40(%rbp),%xmm6
movsd  -0x48(%rbp),%xmm7
movsd  0x10(%rbp),%xmm8
movsd  %xmm8,(%rsp)
call   1050 <determinant3x3@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1206 <invert3x3+0xb6>
jp     1206 <invert3x3+0xb6>
mov    0x2df5(%rip),%rax
mov    (%rax),%edi
lea    0xe0c(%rip),%rsi
call   1040 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    13b7 <invert3x3+0x267>
movsd  -0x50(%rbp),%xmm0
lea    0xe1c(%rip),%rdi
call   1030 <printf@plt>
mov    $0x9,%edi
call   1070 <new_doubarray@plt>
mov    %rax,-0x58(%rbp)
cmp    $0x0,%rax
jne    1251 <invert3x3+0x101>
mov    0x2daa(%rip),%rax
mov    (%rax),%edi
lea    0xe0c(%rip),%rsi
call   1040 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    13b7 <invert3x3+0x267>
movsd  -0x30(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm2
movsd  0x10(%rbp),%xmm3
call   1060 <determinant2x2@plt>
divsd  -0x50(%rbp),%xmm0
mov    -0x58(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  0x10(%rbp),%xmm2
movsd  -0x48(%rbp),%xmm3
call   1060 <determinant2x2@plt>
divsd  -0x50(%rbp),%xmm0
mov    -0x58(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm3
call   1060 <determinant2x2@plt>
divsd  -0x50(%rbp),%xmm0
mov    -0x58(%rbp),%rax
movsd  %xmm0,0x10(%rax)
movsd  -0x38(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  0x10(%rbp),%xmm2
movsd  -0x40(%rbp),%xmm3
call   1060 <determinant2x2@plt>
divsd  -0x50(%rbp),%xmm0
mov    -0x58(%rbp),%rax
movsd  %xmm0,0x18(%rax)
movsd  -0x10(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm2
movsd  0x10(%rbp),%xmm3
call   1060 <determinant2x2@plt>
divsd  -0x50(%rbp),%xmm0
mov    -0x58(%rbp),%rax
movsd  %xmm0,0x20(%rax)
movsd  -0x20(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm3
call   1060 <determinant2x2@plt>
divsd  -0x50(%rbp),%xmm0
mov    -0x58(%rbp),%rax
movsd  %xmm0,0x28(%rax)
movsd  -0x28(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm2
movsd  -0x48(%rbp),%xmm3
call   1060 <determinant2x2@plt>
divsd  -0x50(%rbp),%xmm0
mov    -0x58(%rbp),%rax
movsd  %xmm0,0x30(%rax)
movsd  -0x18(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm2
movsd  -0x40(%rbp),%xmm3
call   1060 <determinant2x2@plt>
divsd  -0x50(%rbp),%xmm0
mov    -0x58(%rbp),%rax
movsd  %xmm0,0x38(%rax)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm3
call   1060 <determinant2x2@plt>
divsd  -0x50(%rbp),%xmm0
mov    -0x58(%rbp),%rax
movsd  %xmm0,0x40(%rax)
mov    -0x58(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<invert3x3>:
push   %rbx
sub    $0x50,%rsp
movsd  0x60(%rsp),%xmm8
movsd  %xmm8,(%rsp)
movsd  %xmm0,0x30(%rsp)
movsd  %xmm1,0x38(%rsp)
movsd  %xmm2,0x10(%rsp)
movsd  %xmm3,0x40(%rsp)
movsd  %xmm4,0x48(%rsp)
movsd  %xmm5,0x18(%rsp)
movsd  %xmm6,0x28(%rsp)
movsd  %xmm7,0x20(%rsp)
call   1050 <determinant3x3@plt>
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11bf <invert3x3+0x6f>
jp     11bf <invert3x3+0x6f>
mov    0x2e36(%rip),%rax
mov    (%rax),%edi
lea    0xe4d(%rip),%rsi
call   1040 <fprintf@plt>
xor    %ebx,%ebx
jmp    134e <invert3x3+0x1fe>
lea    0xe68(%rip),%rdi
movsd  %xmm0,0x8(%rsp)
call   1030 <printf@plt>
mov    $0x9,%edi
call   1070 <new_doubarray@plt>
test   %rax,%rax
je     1357 <invert3x3+0x207>
mov    %rax,%rbx
movsd  0x48(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
movsd  0x20(%rsp),%xmm2
movsd  0x60(%rsp),%xmm3
call   1060 <determinant2x2@plt>
divsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%rbx)
movsd  0x10(%rsp),%xmm0
movsd  0x38(%rsp),%xmm1
movsd  0x60(%rsp),%xmm2
movsd  0x20(%rsp),%xmm3
call   1060 <determinant2x2@plt>
divsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rbx)
movsd  0x38(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  0x48(%rsp),%xmm2
movsd  0x18(%rsp),%xmm3
call   1060 <determinant2x2@plt>
divsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x10(%rbx)
movsd  0x18(%rsp),%xmm0
movsd  0x40(%rsp),%xmm1
movsd  0x60(%rsp),%xmm2
movsd  0x28(%rsp),%xmm3
call   1060 <determinant2x2@plt>
divsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x18(%rbx)
movsd  0x30(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  0x28(%rsp),%xmm2
movsd  0x60(%rsp),%xmm3
call   1060 <determinant2x2@plt>
divsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x20(%rbx)
movsd  0x10(%rsp),%xmm0
movsd  0x30(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
movsd  0x40(%rsp),%xmm3
call   1060 <determinant2x2@plt>
divsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x28(%rbx)
movsd  0x40(%rsp),%xmm0
movsd  0x48(%rsp),%xmm1
movsd  0x28(%rsp),%xmm2
movsd  0x20(%rsp),%xmm3
call   1060 <determinant2x2@plt>
divsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x30(%rbx)
movsd  0x38(%rsp),%xmm0
movsd  0x30(%rsp),%xmm1
movsd  0x20(%rsp),%xmm2
movsd  0x28(%rsp),%xmm3
call   1060 <determinant2x2@plt>
divsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x38(%rbx)
movsd  0x30(%rsp),%xmm0
movsd  0x38(%rsp),%xmm1
movsd  0x40(%rsp),%xmm2
movsd  0x48(%rsp),%xmm3
call   1060 <determinant2x2@plt>
divsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x40(%rbx)
mov    %rbx,%rax
add    $0x50,%rsp
pop    %rbx
ret
mov    0x2c82(%rip),%rax
mov    (%rax),%edi
lea    0xce4(%rip),%rsi
jmp    11b3 <invert3x3+0x63>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [46 x i8] c"ERROR: invert3x3. Input matrix is singular.\0A\00"
@.str.1 = [29 x i8] c"invert3x3: determinant = %g\0A\00"
@.str.2 = [18 x i8] c"ERROR: invert3x3\0A\00"
define double* @invert3x3(double %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7, double %8) {
%10 = alloca double*
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca double*
store double %0, double* %11
store double %1, double* %12
store double %2, double* %13
store double %3, double* %14
store double %4, double* %15
store double %5, double* %16
store double %6, double* %17
store double %7, double* %18
store double %8, double* %19
store double* null, double** %21
%22 = load double, double* %11
%23 = load double, double* %12
%24 = load double, double* %13
%25 = load double, double* %14
%26 = load double, double* %15
%27 = load double, double* %16
%28 = load double, double* %17
%29 = load double, double* %18
%30 = load double, double* %19
%31 = call double @determinant3x3(double %22, double %23, double %24, double %25, double %26, double %27, double %28, double %29, double %30)
store double %31, double* %20
%32 = load double, double* %20
%33 = fcmp oeq double %32, 0.000000e+00
br i1 %33, label %34, label %37
34: ; preds = %9
%35 = load i32, i32* @stderr
%36 = call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
store double* null, double** %10
br label %128
37: ; preds = %9
%38 = load double, double* %20
%39 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), double %38)
%40 = call double* @new_doubarray(i32 9)
store double* %40, double** %21
%41 = icmp ne double* %40, null
br i1 %41, label %45, label %42
42: ; preds = %37
%43 = load i32, i32* @stderr
%44 = call i32 @fprintf(i32 %43, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
store double* null, double** %10
br label %128
45: ; preds = %37
%46 = load double, double* %15
%47 = load double, double* %16
%48 = load double, double* %18
%49 = load double, double* %19
%50 = call double @determinant2x2(double %46, double %47, double %48, double %49)
%51 = load double, double* %20
%52 = fdiv double %50, %51
%53 = load double*, double** %21
%54 = getelementptr inbounds double, double* %53, i64 0
store double %52, double* %54
%55 = load double, double* %13
%56 = load double, double* %12
%57 = load double, double* %19
%58 = load double, double* %18
%59 = call double @determinant2x2(double %55, double %56, double %57, double %58)
%60 = load double, double* %20
%61 = fdiv double %59, %60
%62 = load double*, double** %21
%63 = getelementptr inbounds double, double* %62, i64 1
store double %61, double* %63
%64 = load double, double* %12
%65 = load double, double* %13
%66 = load double, double* %15
%67 = load double, double* %16
%68 = call double @determinant2x2(double %64, double %65, double %66, double %67)
%69 = load double, double* %20
%70 = fdiv double %68, %69
%71 = load double*, double** %21
%72 = getelementptr inbounds double, double* %71, i64 2
store double %70, double* %72
%73 = load double, double* %16
%74 = load double, double* %14
%75 = load double, double* %19
%76 = load double, double* %17
%77 = call double @determinant2x2(double %73, double %74, double %75, double %76)
%78 = load double, double* %20
%79 = fdiv double %77, %78
%80 = load double*, double** %21
%81 = getelementptr inbounds double, double* %80, i64 3
store double %79, double* %81
%82 = load double, double* %11
%83 = load double, double* %13
%84 = load double, double* %17
%85 = load double, double* %19
%86 = call double @determinant2x2(double %82, double %83, double %84, double %85)
%87 = load double, double* %20
%88 = fdiv double %86, %87
%89 = load double*, double** %21
%90 = getelementptr inbounds double, double* %89, i64 4
store double %88, double* %90
%91 = load double, double* %13
%92 = load double, double* %11
%93 = load double, double* %16
%94 = load double, double* %14
%95 = call double @determinant2x2(double %91, double %92, double %93, double %94)
%96 = load double, double* %20
%97 = fdiv double %95, %96
%98 = load double*, double** %21
%99 = getelementptr inbounds double, double* %98, i64 5
store double %97, double* %99
%100 = load double, double* %14
%101 = load double, double* %15
%102 = load double, double* %17
%103 = load double, double* %18
%104 = call double @determinant2x2(double %100, double %101, double %102, double %103)
%105 = load double, double* %20
%106 = fdiv double %104, %105
%107 = load double*, double** %21
%108 = getelementptr inbounds double, double* %107, i64 6
store double %106, double* %108
%109 = load double, double* %12
%110 = load double, double* %11
%111 = load double, double* %18
%112 = load double, double* %17
%113 = call double @determinant2x2(double %109, double %110, double %111, double %112)
%114 = load double, double* %20
%115 = fdiv double %113, %114
%116 = load double*, double** %21
%117 = getelementptr inbounds double, double* %116, i64 7
store double %115, double* %117
%118 = load double, double* %11
%119 = load double, double* %12
%120 = load double, double* %14
%121 = load double, double* %15
%122 = call double @determinant2x2(double %118, double %119, double %120, double %121)
%123 = load double, double* %20
%124 = fdiv double %122, %123
%125 = load double*, double** %21
%126 = getelementptr inbounds double, double* %125, i64 8
store double %124, double* %126
%127 = load double*, double** %21
store double* %127, double** %10
br label %128
128: ; preds = %45, %42, %34
%129 = load double*, double** %10
ret double* %129
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [46 x i8] c"ERROR: invert3x3. Input matrix is singular.\0A\00"
@.str.1 = [29 x i8] c"invert3x3: determinant = %g\0A\00"
@.str.2 = [18 x i8] c"ERROR: invert3x3\0A\00"
define double* @invert3x3(double %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7, double %8) {
%10 = tail call double @determinant3x3(double %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7, double %8)
%11 = fcmp oeq double %10, 0.000000e+00
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = load i32, i32* @stderr
%14 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
br label %49
15: ; preds = %9
%16 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), double %10)
%17 = tail call double* @new_doubarray(i32 9)
%18 = icmp eq double* %17, null
br i1 %18, label %19, label %22
19: ; preds = %15
%20 = load i32, i32* @stderr
%21 = tail call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
br label %49
22: ; preds = %15
%23 = tail call double @determinant2x2(double %4, double %5, double %7, double %8)
%24 = fdiv double %23, %10
store double %24, double* %17
%25 = tail call double @determinant2x2(double %2, double %1, double %8, double %7)
%26 = fdiv double %25, %10
%27 = getelementptr inbounds double, double* %17, i64 1
store double %26, double* %27
%28 = tail call double @determinant2x2(double %1, double %2, double %4, double %5)
%29 = fdiv double %28, %10
%30 = getelementptr inbounds double, double* %17, i64 2
store double %29, double* %30
%31 = tail call double @determinant2x2(double %5, double %3, double %8, double %6)
%32 = fdiv double %31, %10
%33 = getelementptr inbounds double, double* %17, i64 3
store double %32, double* %33
%34 = tail call double @determinant2x2(double %0, double %2, double %6, double %8)
%35 = fdiv double %34, %10
%36 = getelementptr inbounds double, double* %17, i64 4
store double %35, double* %36
%37 = tail call double @determinant2x2(double %2, double %0, double %5, double %3)
%38 = fdiv double %37, %10
%39 = getelementptr inbounds double, double* %17, i64 5
store double %38, double* %39
%40 = tail call double @determinant2x2(double %3, double %4, double %6, double %7)
%41 = fdiv double %40, %10
%42 = getelementptr inbounds double, double* %17, i64 6
store double %41, double* %42
%43 = tail call double @determinant2x2(double %1, double %0, double %7, double %6)
%44 = fdiv double %43, %10
%45 = getelementptr inbounds double, double* %17, i64 7
store double %44, double* %45
%46 = tail call double @determinant2x2(double %0, double %1, double %3, double %4)
%47 = fdiv double %46, %10
%48 = getelementptr inbounds double, double* %17, i64 8
store double %47, double* %48
br label %49
49: ; preds = %22, %19, %12
%50 = phi double* [ null, %12 ], [ %17, %22 ], [ null, %19 ]
ret double* %50
}