#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 */
typedef size_t n;

/* Variables and functions */
int /*<<< orphan*/ free(double *);
double *myMinor(void *, double *, int, int, int /*<<< orphan*/, int);
double pow(double, int);
double det(void *space, double *m, int n) {
  double sum = 0, *t = NULL;
  int j;
  if (n == 1) {
    return m[(0) * (n) + (0)];
  }
  for (j = 0; j < n; j++) {
    t = myMinor(space, m, n, n, 0, j);
    sum += pow(-1.0, (j + 2)) * m[(0) * (n) + (j)] * det(space, t, n - 1);
  }
  free(t);
  return sum;
}


x86 assembly (clang, -O0):
<det>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
cmpl   $0x1,-0x1c(%rbp)
jne    118a <det+0x4a>
mov    -0x18(%rbp),%rax
imul   $0x0,-0x1c(%rbp),%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1234 <det+0xf4>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1221 <det+0xe1>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    -0x34(%rbp),%r9d
xor    %r8d,%r8d
call   1060 <myMinor@plt>
mov    %rax,-0x30(%rbp)
mov    -0x34(%rbp),%edi
add    $0x2,%edi
movsd  0xe37(%rip),%xmm0
call   1040 <pow@plt>
mov    -0x18(%rbp),%rax
imul   $0x0,-0x1c(%rbp),%ecx
add    -0x34(%rbp),%ecx
movslq %ecx,%rcx
mulsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x1c(%rbp),%edx
sub    $0x1,%edx
call   1050 <det@plt>
movaps %xmm0,%xmm2
movsd  -0x40(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1191 <det+0x51>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<det>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r15
cmp    $0x1,%edx
jne    1160 <det+0x20>
movsd  (%r15),%xmm0
jmp    120a <det+0xca>
jl     11f1 <det+0xb1>
mov    %edx,%r14d
mov    %rdi,%r12
mov    %edx,%r13d
add    $0xffffffff,%r14d
xorps  %xmm0,%xmm0
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
movsd  %xmm0,0x8(%rsp)
mov    %r12,%rdi
mov    %r15,%rsi
mov    %r13d,%edx
mov    %r13d,%ecx
xor    %r8d,%r8d
mov    %ebp,%r9d
call   1060 <myMinor@plt>
mov    %rax,%rbx
lea    0x2(%rbp),%edi
movsd  0xe55(%rip),%xmm0
call   1040 <pow@plt>
mulsd  (%r15,%rbp,8),%xmm0
movsd  %xmm0,0x10(%rsp)
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
call   1050 <det@plt>
mulsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
add    $0x1,%rbp
cmp    %rbp,%r13
jne    1180 <det+0x40>
jmp    11fc <det+0xbc>
xorps  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %ebx,%ebx
mov    %rbx,%rdi
call   1030 <free@plt>
movsd  0x8(%rsp),%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @det(i8* %0, double* %1, i32 %2) {
%4 = alloca double
%5 = alloca i8*
%6 = alloca double*
%7 = alloca i32
%8 = alloca double
%9 = alloca double*
%10 = alloca i32
store i8* %0, i8** %5
store double* %1, double** %6
store i32 %2, i32* %7
store double 0.000000e+00, double* %8
store double* null, double** %9
%11 = load i32, i32* %7
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %21
13: ; preds = %3
%14 = load double*, double** %6
%15 = load i32, i32* %7
%16 = mul nsw i32 0, %15
%17 = add nsw i32 %16, 0
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds double, double* %14, i64 %18
%20 = load double, double* %19
store double %20, double* %4
br label %59
21: ; preds = %3
store i32 0, i32* %10
br label %22
22: ; preds = %52, %21
%23 = load i32, i32* %10
%24 = load i32, i32* %7
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %55
26: ; preds = %22
%27 = load i8*, i8** %5
%28 = load double*, double** %6
%29 = load i32, i32* %7
%30 = load i32, i32* %7
%31 = load i32, i32* %10
%32 = call double* @myMinor(i8* %27, double* %28, i32 %29, i32 %30, i32 0, i32 %31)
store double* %32, double** %9
%33 = load i32, i32* %10
%34 = add nsw i32 %33, 2
%35 = call double @pow(double -1.000000e+00, i32 %34)
%36 = load double*, double** %6
%37 = load i32, i32* %7
%38 = mul nsw i32 0, %37
%39 = load i32, i32* %10
%40 = add nsw i32 %38, %39
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds double, double* %36, i64 %41
%43 = load double, double* %42
%44 = fmul double %35, %43
%45 = load i8*, i8** %5
%46 = load double*, double** %9
%47 = load i32, i32* %7
%48 = sub nsw i32 %47, 1
%49 = call double @det(i8* %45, double* %46, i32 %48)
%50 = load double, double* %8
%51 = call double @llvm.fmuladd.f64(double %44, double %49, double %50)
store double %51, double* %8
br label %52
52: ; preds = %26
%53 = load i32, i32* %10
%54 = add nsw i32 %53, 1
store i32 %54, i32* %10
br label %22
55: ; preds = %22
%56 = load double*, double** %9
%57 = call i32 @free(double* %56)
%58 = load double, double* %8
store double %58, double* %4
br label %59
59: ; preds = %55, %13
%60 = load double, double* %4
ret double %60
}

LLVM IR (-O2):
define double @det(i8* %0, double* %1, i32 %2) {
%4 = icmp eq i32 %2, 1
br i1 %4, label %10, label %5
5: ; preds = %3
%6 = icmp sgt i32 %2, 0
br i1 %6, label %7, label %27
7: ; preds = %5
%8 = add nsw i32 %2, -1
%9 = zext i32 %2 to i64
br label %12
10: ; preds = %3
%11 = load double, double* %1
br label %31
12: ; preds = %7, %12
%13 = phi i64 [ 0, %7 ], [ %25, %12 ]
%14 = phi double [ 0.000000e+00, %7 ], [ %24, %12 ]
%15 = trunc i64 %13 to i32
%16 = tail call double* @myMinor(i8* %0, double* %1, i32 %2, i32 %2, i32 0, i32 %15)
%17 = trunc i64 %13 to i32
%18 = add i32 %17, 2
%19 = tail call double @pow(double -1.000000e+00, i32 %18)
%20 = getelementptr inbounds double, double* %1, i64 %13
%21 = load double, double* %20
%22 = fmul double %19, %21
%23 = tail call double @det(i8* %0, double* %16, i32 %8)
%24 = tail call double @llvm.fmuladd.f64(double %22, double %23, double %14)
%25 = add nuw nsw i64 %13, 1
%26 = icmp eq i64 %25, %9
br i1 %26, label %27, label %12
27: ; preds = %12, %5
%28 = phi double [ 0.000000e+00, %5 ], [ %24, %12 ]
%29 = phi double* [ null, %5 ], [ %16, %12 ]
%30 = tail call i32 @free(double* %29)
br label %31
31: ; preds = %27, %10
%32 = phi double [ %11, %10 ], [ %28, %27 ]
ret double %32
}