#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*/ inv_matrix_det_incd(double *, double *, int *, int, int);
double inv_matrix_detd(double *p, int *n) {
  double d[10][10], sum = 0;
  int i, j, m;
  m = *n;
  if (*n == 2)
    return (*p * *(p + 11) - *(p + 1) * *(p + 10));
  for (i = 0, j = 0; j < m; j++) {
    *n = m;
    inv_matrix_det_incd(p, &d[0][0], n, i, j);
    sum = sum + *(p + 10 * i + j) * ((int)(i + j) & 1 ? -1 : 1) *
                    inv_matrix_detd(&d[0][0], n);
  }
  return (sum);
}


x86 assembly (clang, -O0):
<inv_matrix_detd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x370,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x348(%rbp)
ff
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x354(%rbp)
mov    -0x18(%rbp),%rax
cmpl   $0x2,(%rax)
jne    11a3 <inv_matrix_detd+0x83>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x58(%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x10(%rbp),%rax
mulsd  0x50(%rax),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12aa <inv_matrix_detd+0x18a>
movl   $0x0,-0x34c(%rbp)
movl   $0x0,-0x350(%rbp)
mov    -0x350(%rbp),%eax
cmp    -0x354(%rbp),%eax
jge    129d <inv_matrix_detd+0x17d>
mov    -0x354(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rdi
lea    -0x340(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x34c(%rbp),%ecx
mov    -0x350(%rbp),%r8d
call   1040 <inv_matrix_det_incd@plt>
movsd  -0x348(%rbp),%xmm0
ff
movsd  %xmm0,-0x368(%rbp)
ff
mov    -0x10(%rbp),%rax
imul   $0xa,-0x34c(%rbp),%ecx
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
movslq -0x350(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x34c(%rbp),%edx
add    -0x350(%rbp),%edx
and    $0x1,%edx
mov    $0x1,%eax
mov    $0xffffffff,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x360(%rbp)
ff
lea    -0x340(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <inv_matrix_detd@plt>
movsd  -0x368(%rbp),%xmm1
ff
movaps %xmm0,%xmm2
movsd  -0x360(%rbp),%xmm0
ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x348(%rbp)
ff
mov    -0x350(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x350(%rbp)
jmp    11b7 <inv_matrix_detd+0x97>
movsd  -0x348(%rbp),%xmm0
ff
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x370,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inv_matrix_detd>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x330,%rsp
mov    %rdi,%r14
mov    (%rsi),%r13d
cmp    $0x2,%r13
jne    115c <inv_matrix_detd+0x3c>
movsd  0x50(%r14),%xmm1
mulsd  0x8(%r14),%xmm1
movsd  (%r14),%xmm0
mulsd  0x58(%r14),%xmm0
subsd  %xmm1,%xmm0
jmp    11dd <inv_matrix_detd+0xbd>
test   %r13d,%r13d
jle    11d9 <inv_matrix_detd+0xb9>
mov    %rsi,%r15
xorpd  %xmm0,%xmm0
xor    %ebx,%ebx
lea    0x10(%rsp),%r12
nop
movsd  %xmm0,(%rsp)
mov    %r13d,(%r15)
mov    %r14,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
xor    %ecx,%ecx
mov    %ebx,%r8d
call   1040 <inv_matrix_det_incd@plt>
mov    %ebx,%eax
and    $0x1,%eax
neg    %eax
sbb    %eax,%eax
or     $0x1,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  (%r14,%rbx,8),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %r12,%rdi
mov    %r15,%rsi
call   1030 <inv_matrix_detd@plt>
mulsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  (%rsp),%xmm0
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1170 <inv_matrix_detd+0x50>
jmp    11dd <inv_matrix_detd+0xbd>
xorpd  %xmm0,%xmm0
add    $0x330,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define double @inv_matrix_detd(double* %0, i32* %1) {
%3 = alloca double
%4 = alloca double*
%5 = alloca i32*
%6 = alloca [10 x [10 x double]]
%7 = alloca double
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store double* %0, double** %4
store i32* %1, i32** %5
store double 0.000000e+00, double* %7
%11 = load i32*, i32** %5
%12 = load i32, i32* %11
store i32 %12, i32* %10
%13 = load i32*, i32** %5
%14 = load i32, i32* %13
%15 = icmp eq i32 %14, 2
br i1 %15, label %16, label %31
16: ; preds = %2
%17 = load double*, double** %4
%18 = load double, double* %17
%19 = load double*, double** %4
%20 = getelementptr inbounds double, double* %19, i64 11
%21 = load double, double* %20
%22 = load double*, double** %4
%23 = getelementptr inbounds double, double* %22, i64 1
%24 = load double, double* %23
%25 = load double*, double** %4
%26 = getelementptr inbounds double, double* %25, i64 10
%27 = load double, double* %26
%28 = fmul double %24, %27
%29 = fneg double %28
%30 = call double @llvm.fmuladd.f64(double %18, double %21, double %29)
store double %30, double* %3
br label %75
31: ; preds = %2
store i32 0, i32* %8
store i32 0, i32* %9
br label %32
32: ; preds = %70, %31
%33 = load i32, i32* %9
%34 = load i32, i32* %10
%35 = icmp slt i32 %33, %34
br i1 %35, label %36, label %73
36: ; preds = %32
%37 = load i32, i32* %10
%38 = load i32*, i32** %5
store i32 %37, i32* %38
%39 = load double*, double** %4
%40 = getelementptr inbounds [10 x [10 x double]], [10 x [10 x double]]* %6, i64 0, i64 0
%41 = getelementptr inbounds [10 x double], [10 x double]* %40, i64 0, i64 0
%42 = load i32*, i32** %5
%43 = load i32, i32* %8
%44 = load i32, i32* %9
%45 = call i32 @inv_matrix_det_incd(double* %39, double* %41, i32* %42, i32 %43, i32 %44)
%46 = load double, double* %7
%47 = load double*, double** %4
%48 = load i32, i32* %8
%49 = mul nsw i32 10, %48
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds double, double* %47, i64 %50
%52 = load i32, i32* %9
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds double, double* %51, i64 %53
%55 = load double, double* %54
%56 = load i32, i32* %8
%57 = load i32, i32* %9
%58 = add nsw i32 %56, %57
%59 = and i32 %58, 1
%60 = icmp ne i32 %59, 0
%61 = zext i1 %60 to i64
%62 = select i1 %60, i32 -1, i32 1
%63 = sitofp i32 %62 to double
%64 = fmul double %55, %63
%65 = getelementptr inbounds [10 x [10 x double]], [10 x [10 x double]]* %6, i64 0, i64 0
%66 = getelementptr inbounds [10 x double], [10 x double]* %65, i64 0, i64 0
%67 = load i32*, i32** %5
%68 = call double @inv_matrix_detd(double* %66, i32* %67)
%69 = call double @llvm.fmuladd.f64(double %64, double %68, double %46)
store double %69, double* %7
br label %70
70: ; preds = %36
%71 = load i32, i32* %9
%72 = add nsw i32 %71, 1
store i32 %72, i32* %9
br label %32
73: ; preds = %32
%74 = load double, double* %7
store double %74, double* %3
br label %75
75: ; preds = %73, %16
%76 = load double, double* %3
ret double %76
}

LLVM IR (-O2):
define double @inv_matrix_detd(double* %0, i32* %1) {
%3 = alloca [10 x [10 x double]]
%4 = bitcast [10 x [10 x double]]* %3 to i8*
%5 = load i32, i32* %1
%6 = icmp eq i32 %5, 2
br i1 %6, label %12, label %7
7: ; preds = %2
%8 = icmp sgt i32 %5, 0
br i1 %8, label %9, label %39
9: ; preds = %7
%10 = getelementptr inbounds [10 x [10 x double]], [10 x [10 x double]]* %3, i64 0, i64 0, i64 0
%11 = zext i32 %5 to i64
br label %23
12: ; preds = %2
%13 = load double, double* %0
%14 = getelementptr inbounds double, double* %0, i64 11
%15 = load double, double* %14
%16 = getelementptr inbounds double, double* %0, i64 1
%17 = load double, double* %16
%18 = getelementptr inbounds double, double* %0, i64 10
%19 = load double, double* %18
%20 = fneg double %17
%21 = fmul double %19, %20
%22 = tail call double @llvm.fmuladd.f64(double %13, double %15, double %21)
br label %39
23: ; preds = %9, %23
%24 = phi i64 [ 0, %9 ], [ %37, %23 ]
%25 = phi double [ 0.000000e+00, %9 ], [ %36, %23 ]
store i32 %5, i32* %1
%26 = trunc i64 %24 to i32
%27 = call i32 @inv_matrix_det_incd(double* %0, double* %10, i32* %1, i32 0, i32 %26)
%28 = getelementptr inbounds double, double* %0, i64 %24
%29 = load double, double* %28
%30 = and i32 %26, 1
%31 = icmp eq i32 %30, 0
%32 = select i1 %31, i32 1, i32 -1
%33 = sitofp i32 %32 to double
%34 = fmul double %29, %33
%35 = call double @inv_matrix_detd(double* %10, i32* %1)
%36 = call double @llvm.fmuladd.f64(double %34, double %35, double %25)
%37 = add nuw nsw i64 %24, 1
%38 = icmp eq i64 %37, %11
br i1 %38, label %39, label %23
39: ; preds = %23, %7, %12
%40 = phi double [ %22, %12 ], [ 0.000000e+00, %7 ], [ %36, %23 ]
ret double %40
}