double gen_determinant(A, n)
double **A;
int n;
{
  double det;
  int i;
  if (n == 1)
    return (A[1][1]);
  det = 0.0;
  for (i = 1; i <= n; i++)
    det += A[1][i] * cofactor(A, 1, i, n);
  return (det);
}


x86 assembly (clang, -O0):
<gen_determinant>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jne    1140 <gen_determinant+0x30>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11ba <gen_determinant+0xaa>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     11b0 <gen_determinant+0xa0>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x24(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    $0x1,%esi
mov    $0x0,%al
call   1030 <cofactor@plt>
movsd  -0x30(%rbp),%xmm0
cvtsi2sd %eax,%xmm2
movsd  -0x20(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    114f <gen_determinant+0x3f>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gen_determinant>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r15
cmp    $0x1,%esi
jne    112e <gen_determinant+0x1e>
mov    0x8(%r15),%rax
movsd  0x8(%rax),%xmm0
jmp    119a <gen_determinant+0x8a>
jl     1197 <gen_determinant+0x87>
mov    %esi,%r14d
lea    0x1(%r14),%r12d
xorps  %xmm0,%xmm0
mov    $0x1,%ebx
nop
movsd  %xmm0,0x8(%rsp)
mov    0x8(%r15),%rax
movsd  (%rax,%rbx,8),%xmm0
movsd  %xmm0,0x10(%rsp)
mov    %r15,%rdi
mov    $0x1,%esi
mov    %ebx,%edx
mov    %r14d,%ecx
xor    %eax,%eax
call   1030 <cofactor@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1140 <gen_determinant+0x30>
jmp    119a <gen_determinant+0x8a>
xorps  %xmm0,%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define double @gen_determinant(double** %0, i32 %1) {
%3 = alloca double
%4 = alloca double**
%5 = alloca i32
%6 = alloca double
%7 = alloca i32
store double** %0, double*** %4
store i32 %1, i32* %5
%8 = load i32, i32* %5
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %16
10: ; preds = %2
%11 = load double**, double*** %4
%12 = getelementptr inbounds double*, double** %11, i64 1
%13 = load double*, double** %12
%14 = getelementptr inbounds double, double* %13, i64 1
%15 = load double, double* %14
store double %15, double* %3
br label %41
16: ; preds = %2
store double 0.000000e+00, double* %6
store i32 1, i32* %7
br label %17
17: ; preds = %36, %16
%18 = load i32, i32* %7
%19 = load i32, i32* %5
%20 = icmp sle i32 %18, %19
br i1 %20, label %21, label %39
21: ; preds = %17
%22 = load double**, double*** %4
%23 = getelementptr inbounds double*, double** %22, i64 1
%24 = load double*, double** %23
%25 = load i32, i32* %7
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds double, double* %24, i64 %26
%28 = load double, double* %27
%29 = load double**, double*** %4
%30 = load i32, i32* %7
%31 = load i32, i32* %5
%32 = call i32 (double**, i32, i32, i32, ...) bitcast (i32 (...)* @cofactor to i32 (double**, i32, i32, i32, ...)*)(double** %29, i32 1, i32 %30, i32 %31)
%33 = sitofp i32 %32 to double
%34 = load double, double* %6
%35 = call double @llvm.fmuladd.f64(double %28, double %33, double %34)
store double %35, double* %6
br label %36
36: ; preds = %21
%37 = load i32, i32* %7
%38 = add nsw i32 %37, 1
store i32 %38, i32* %7
br label %17
39: ; preds = %17
%40 = load double, double* %6
store double %40, double* %3
br label %41
41: ; preds = %39, %10
%42 = load double, double* %3
ret double %42
}

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