#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 */
struct mat44 {
  int dummy;
};

/* Variables and functions */
float mat44_at(struct mat44 *, int, int);
float mat44_determinant(struct mat44 *a) {
  float det = 0;
  for (int x = 0; x < 4; x++) {
    {
      float s = 1;
      for (int i = 0; i < 4; i++) {
        s *= mat44_at(a, (i + x) & 3, i);
      }
      det += s;
    }
    {
      float t = 1;
      for (int i = 0; i < 4; i++) {
        t *= mat44_at(a, (-i + x) & 3, i);
      }
      det -= t;
    }
  }
  return det;
}


x86 assembly (clang, -O0):
<mat44_determinant>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x4,-0x10(%rbp)
jge    11fd <mat44_determinant+0xed>
movss  0xec3(%rip),%xmm0
movss  %xmm0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x4,-0x18(%rbp)
jge    1180 <mat44_determinant+0x70>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%esi
add    -0x10(%rbp),%esi
and    $0x3,%esi
mov    -0x18(%rbp),%edx
call   1030 <mat44_at@plt>
mulss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1149 <mat44_determinant+0x39>
movss  -0x14(%rbp),%xmm0
addss  -0xc(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  0xe69(%rip),%xmm0
movss  %xmm0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x4,-0x20(%rbp)
jge    11dc <mat44_determinant+0xcc>
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
sub    -0x20(%rbp),%esi
add    -0x10(%rbp),%esi
and    $0x3,%esi
mov    -0x20(%rbp),%edx
call   1030 <mat44_at@plt>
mulss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11a3 <mat44_determinant+0x93>
movss  -0x1c(%rbp),%xmm1
movss  -0xc(%rbp),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    112b <mat44_determinant+0x1b>
movss  -0xc(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mat44_determinant>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r15
xorps  %xmm0,%xmm0
movss  %xmm0,0x4(%rsp)
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %ebp,%esi
xor    %edx,%edx
call   1030 <mat44_at@plt>
movss  %xmm0,(%rsp)
lea    0x1(%rbp),%r13d
mov    %r13d,%r14d
and    $0x3,%r14d
mov    %r15,%rdi
mov    %r14d,%esi
mov    $0x1,%edx
call   1030 <mat44_at@plt>
mulss  (%rsp),%xmm0
movss  %xmm0,(%rsp)
lea    0x2(%rbp),%r12d
and    $0x3,%r12d
mov    %r15,%rdi
mov    %r12d,%esi
mov    $0x2,%edx
call   1030 <mat44_at@plt>
mulss  (%rsp),%xmm0
movss  %xmm0,(%rsp)
lea    -0x1(%rbp),%ebx
and    $0x3,%ebx
mov    %r15,%rdi
mov    %ebx,%esi
mov    $0x3,%edx
call   1030 <mat44_at@plt>
mulss  (%rsp),%xmm0
movss  0x4(%rsp),%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,0x4(%rsp)
mov    %r15,%rdi
mov    %ebp,%esi
xor    %edx,%edx
call   1030 <mat44_at@plt>
movss  %xmm0,(%rsp)
mov    %r15,%rdi
mov    %ebx,%esi
mov    $0x1,%edx
call   1030 <mat44_at@plt>
mulss  (%rsp),%xmm0
movss  %xmm0,(%rsp)
mov    %r15,%rdi
mov    %r12d,%esi
mov    $0x2,%edx
call   1030 <mat44_at@plt>
mulss  (%rsp),%xmm0
movss  %xmm0,(%rsp)
mov    %r15,%rdi
mov    %r14d,%esi
mov    $0x3,%edx
call   1030 <mat44_at@plt>
mulss  (%rsp),%xmm0
movss  0x4(%rsp),%xmm1
subss  %xmm0,%xmm1
movss  %xmm1,0x4(%rsp)
mov    %r13d,%ebp
cmp    $0x4,%r13d
jne    1130 <mat44_determinant+0x20>
movss  0x4(%rsp),%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.mat44 = type { i32 }
define float @mat44_determinant(%struct.mat44* %0) {
%2 = alloca %struct.mat44*
%3 = alloca float
%4 = alloca i32
%5 = alloca float
%6 = alloca i32
%7 = alloca float
%8 = alloca i32
store %struct.mat44* %0, %struct.mat44** %2
store float 0.000000e+00, float* %3
store i32 0, i32* %4
br label %9
9: ; preds = %54, %1
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 4
br i1 %11, label %12, label %57
12: ; preds = %9
store float 1.000000e+00, float* %5
store i32 0, i32* %6
br label %13
13: ; preds = %26, %12
%14 = load i32, i32* %6
%15 = icmp slt i32 %14, 4
br i1 %15, label %16, label %29
16: ; preds = %13
%17 = load %struct.mat44*, %struct.mat44** %2
%18 = load i32, i32* %6
%19 = load i32, i32* %4
%20 = add nsw i32 %18, %19
%21 = and i32 %20, 3
%22 = load i32, i32* %6
%23 = call float @mat44_at(%struct.mat44* %17, i32 %21, i32 %22)
%24 = load float, float* %5
%25 = fmul float %24, %23
store float %25, float* %5
br label %26
26: ; preds = %16
%27 = load i32, i32* %6
%28 = add nsw i32 %27, 1
store i32 %28, i32* %6
br label %13
29: ; preds = %13
%30 = load float, float* %5
%31 = load float, float* %3
%32 = fadd float %31, %30
store float %32, float* %3
store float 1.000000e+00, float* %7
store i32 0, i32* %8
br label %33
33: ; preds = %47, %29
%34 = load i32, i32* %8
%35 = icmp slt i32 %34, 4
br i1 %35, label %36, label %50
36: ; preds = %33
%37 = load %struct.mat44*, %struct.mat44** %2
%38 = load i32, i32* %8
%39 = sub nsw i32 0, %38
%40 = load i32, i32* %4
%41 = add nsw i32 %39, %40
%42 = and i32 %41, 3
%43 = load i32, i32* %8
%44 = call float @mat44_at(%struct.mat44* %37, i32 %42, i32 %43)
%45 = load float, float* %7
%46 = fmul float %45, %44
store float %46, float* %7
br label %47
47: ; preds = %36
%48 = load i32, i32* %8
%49 = add nsw i32 %48, 1
store i32 %49, i32* %8
br label %33
50: ; preds = %33
%51 = load float, float* %7
%52 = load float, float* %3
%53 = fsub float %52, %51
store float %53, float* %3
br label %54
54: ; preds = %50
%55 = load i32, i32* %4
%56 = add nsw i32 %55, 1
store i32 %56, i32* %4
br label %9
57: ; preds = %9
%58 = load float, float* %3
ret float %58
}

LLVM IR (-O2):
%struct.mat44 = type { i32 }
define float @mat44_determinant(%struct.mat44* %0) {
br label %2
2: ; preds = %1, %2
%3 = phi i32 [ 0, %1 ], [ %6, %2 ]
%4 = phi float [ 0.000000e+00, %1 ], [ %32, %2 ]
%5 = tail call float @mat44_at(%struct.mat44* %0, i32 %3, i32 0)
%6 = add nuw nsw i32 %3, 1
%7 = and i32 %6, 3
%8 = tail call float @mat44_at(%struct.mat44* %0, i32 %7, i32 1)
%9 = fmul float %5, %8
%10 = add nuw nsw i32 %3, 2
%11 = and i32 %10, 3
%12 = tail call float @mat44_at(%struct.mat44* %0, i32 %11, i32 2)
%13 = fmul float %9, %12
%14 = add nuw nsw i32 %3, 3
%15 = and i32 %14, 3
%16 = tail call float @mat44_at(%struct.mat44* %0, i32 %15, i32 3)
%17 = fmul float %13, %16
%18 = tail call float @mat44_at(%struct.mat44* %0, i32 %3, i32 0)
%19 = add nuw i32 %3, 3
%20 = and i32 %19, 3
%21 = tail call float @mat44_at(%struct.mat44* %0, i32 %20, i32 1)
%22 = fmul float %18, %21
%23 = add nuw i32 %3, 2
%24 = and i32 %23, 3
%25 = tail call float @mat44_at(%struct.mat44* %0, i32 %24, i32 2)
%26 = fmul float %22, %25
%27 = add nuw i32 %3, 1
%28 = and i32 %27, 3
%29 = tail call float @mat44_at(%struct.mat44* %0, i32 %28, i32 3)
%30 = fmul float %26, %29
%31 = fadd float %4, %17
%32 = fsub float %31, %30
%33 = icmp eq i32 %6, 4
br i1 %33, label %34, label %2
34: ; preds = %2
ret float %32
}