// File: /workspace/github_cpp_makefile_star2_O1/SpiritLooper[P]RDV_OBJRender/matrix.cpp
// Function: Matrix::inverse()
Matrix Matrix::inverse() {
    assert(rows==cols);
    // augmenting the square matrix with the identity matrix of the same dimensions a => [ai]
    Matrix result(rows, cols*2);
    for(int i=0; i<rows; i++)
        for(int j=0; j<cols; j++)
            result[i][j] = m[i][j];
    for(int i=0; i<rows; i++)
        result[i][i+cols] = 1;
    // first pass
    for (int i=0; i<rows-1; i++) {
        // normalize the first row
        for(int j=result.cols-1; j>=0; j--)
            result[i][j] /= result[i][i];
        for (int k=i+1; k<rows; k++) {
            float coeff = result[k][i];
            for (int j=0; j<result.cols; j++) {
                result[k][j] -= result[i][j]*coeff;
            }
        }
    }
    // normalize the last row
    for(int j=result.cols-1; j>=rows-1; j--)
        result[rows-1][j] /= result[rows-1][rows-1];
    // second pass
    for (int i=rows-1; i>0; i--) {
        for (int k=i-1; k>=0; k--) {
            float coeff = result[k][i];
            for (int j=0; j<result.cols; j++) {
                result[k][j] -= result[i][j]*coeff;
            }
        }
    }
    // cut the identity matrix back
    Matrix truncate(rows, cols);
    for(int i=0; i<rows; i++)
        for(int j=0; j<cols; j++)
            truncate[i][j] = result[i][j+cols];
    return truncate;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %r13
movl 0x18(%rsi), %esi
movl 0x1c(%r13), %edx
cmpl %edx, %esi
jne 0x2c24
movq %rdi, %rbx
addl %edx, %edx
leaq 0x10(%rsp), %rdi
callq 0x25ec
movl 0x18(%r13), %esi
movl %esi, %eax
testl %esi, %esi
jle 0x293a
movl 0x1c(%r13), %ecx
xorl %edx, %edx
testl %ecx, %ecx
jle 0x2932
leaq (,%rdx,8), %rdi
leaq (%rdi,%rdi,2), %rdi
movq (%r13), %r8
addq %rdi, %r8
addq 0x10(%rsp), %rdi
xorl %r9d, %r9d
movslq 0x28(%rsp), %r10
cmpq %r10, %rdx
jge 0x2c05
movq (%r8), %r10
movss (%r10,%r9,4), %xmm0
movq (%rdi), %r10
movss %xmm0, (%r10,%r9,4)
incq %r9
cmpq %r9, %rcx
jne 0x290a
incq %rdx
cmpq %rax, %rdx
jne 0x28eb
testl %esi, %esi
jle 0x2975
movq 0x10(%rsp), %rcx
movslq 0x1c(%r13), %rdx
shlq $0x2, %rdx
xorl %edi, %edi
movslq 0x28(%rsp), %r8
cmpq %r8, %rdi
jge 0x2c05
movq (%rcx), %r8
addq %rdx, %r8
movl $0x3f800000, (%r8,%rdi,4) # imm = 0x3F800000
incq %rdi
addq $0x18, %rcx
cmpq %rdi, %rax
jne 0x294d
leal -0x1(%rsi), %ecx
movl %ecx, 0xc(%rsp)
movq %rsi, 0x30(%rsp)
cmpl $0x2, %esi
jl 0x2a79
movl 0x2c(%rsp), %edx
movl 0xc(%rsp), %edi
leaq 0x1(%rdx), %rsi
movl $0x1, %r9d
xorl %r10d, %r10d
leaq (%r10,%r10,2), %r12
testl %edx, %edx
jle 0x29e5
leaq (,%r12,8), %rcx
addq 0x10(%rsp), %rcx
movq %rsi, %r11
movslq 0x28(%rsp), %r14
cmpq %r14, %r10
jge 0x2c05
movq (%rcx), %r14
movss -0x8(%r14,%r11,4), %xmm0
divss (%r14,%r10,4), %xmm0
movss %xmm0, -0x8(%r14,%r11,4)
decq %r11
cmpq $0x1, %r11
jg 0x29b7
movq %r13, %r8
leaq 0x1(%r10), %r11
movq 0x10(%rsp), %r15
leaq (%r15,%r12,8), %r12
movq %r9, %r13
movslq 0x28(%rsp), %rcx
cmpq %rcx, %r13
jge 0x2c05
testl %edx, %edx
jle 0x2a5f
leaq (,%r13,2), %rcx
addq %r13, %rcx
movq (%r15,%rcx,8), %rbp
movss (%rbp,%r10,4), %xmm0
xorl %ecx, %ecx
movslq 0x28(%rsp), %r14
cmpq %r14, %r10
jge 0x2c05
cmpq %r14, %r13
jge 0x2c05
movq (%r12), %r14
movss (%rbp,%rcx,4), %xmm1
movss (%r14,%rcx,4), %xmm2
mulss %xmm0, %xmm2
subss %xmm2, %xmm1
movss %xmm1, (%rbp,%rcx,4)
incq %rcx
cmpq %rcx, %rdx
jne 0x2a22
incq %r13
cmpq %rax, %r13
jne 0x29f8
incq %r9
movq %r11, %r10
cmpq %rdi, %r11
movq %r8, %r13
jne 0x299f
movslq 0x2c(%rsp), %rdx
movq 0x30(%rsp), %rsi
cmpl %esi, %edx
jl 0x2ad4
testl %esi, %esi
jle 0x2c05
movl 0xc(%rsp), %r8d
movl %r8d, %ecx
leaq (%rcx,%rcx,2), %rdi
shlq $0x3, %rdi
addq 0x10(%rsp), %rdi
movslq %r8d, %rcx
leaq 0x1(%rdx), %r8
cmpl %esi, 0x28(%rsp)
jl 0x2c05
movq (%rdi), %r9
movss -0x8(%r9,%r8,4), %xmm0
divss (%r9,%rcx,4), %xmm0
movss %xmm0, -0x8(%r9,%r8,4)
decq %r8
cmpq %rax, %r8
jg 0x2aab
cmpl $0x2, %esi
jl 0x2b70
movl 0xc(%rsp), %eax
movl %edx, %ecx
movq 0x10(%rsp), %rdi
leaq (%rax,%rax,2), %r8
leaq (%rdi,%r8,8), %r8
movq %rax, %r9
movq %r9, %r10
cmpl %r10d, 0x28(%rsp)
jl 0x2c05
leaq -0x1(%r10), %r9
testl %edx, %edx
jle 0x2b59
movl %r9d, %r11d
leaq (%r11,%r11,2), %r11
movq (%rdi,%r11,8), %r11
movss (%r11,%rax,4), %xmm0
xorl %r15d, %r15d
movslq 0x28(%rsp), %r12
cmpq %r12, %rax
jge 0x2c05
cmpl %r10d, %r12d
jl 0x2c05
movq (%r8), %r14
movss (%r11,%r15,4), %xmm1
movss (%r14,%r15,4), %xmm2
mulss %xmm0, %xmm2
subss %xmm2, %xmm1
movss %xmm1, (%r11,%r15,4)
incq %r15
cmpq %r15, %rcx
jne 0x2b1d
cmpl $0x1, %r10d
jg 0x2af3
leaq -0x1(%rax), %rdi
cmpq $0x1, %rax
movq %rdi, %rax
jg 0x2ae3
movl 0x1c(%r13), %edx
movq %rbx, %rdi
callq 0x25ec
movslq 0x18(%r13), %rax
testq %rax, %rax
jle 0x2be9
movl 0x1c(%r13), %ecx
movq %rcx, %rdx
shlq $0x2, %rdx
xorl %esi, %esi
testl %ecx, %ecx
jle 0x2be1
leaq (,%rsi,8), %rdi
leaq (%rdi,%rdi,2), %rdi
movq 0x10(%rsp), %r8
addq %rdi, %r8
addq (%rbx), %rdi
xorl %r9d, %r9d
movslq 0x28(%rsp), %r10
cmpq %r10, %rsi
jge 0x2c05
movslq 0x18(%rbx), %r10
cmpq %r10, %rsi
jge 0x2c05
movq (%r8), %r10
addq %rdx, %r10
movss (%r9,%r10), %xmm0
movq (%rdi), %r10
movss %xmm0, (%r10,%r9)
addq $0x4, %r9
cmpq %r9, %rdx
jne 0x2bb0
incq %rsi
cmpq %rax, %rsi
jne 0x2b92
leaq 0x10(%rsp), %rdi
callq 0x2e46
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x43fc(%rip), %rdi      # 0x7008
leaq 0x4404(%rip), %rsi      # 0x7017
leaq 0x4408(%rip), %rcx      # 0x7022
movl $0x18, %edx
callq 0x2110
leaq 0x4461(%rip), %rdi      # 0x708c
leaq 0x43e5(%rip), %rsi      # 0x7017
leaq 0x445e(%rip), %rcx      # 0x7097
movl $0x33, %edx
callq 0x2110
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x2e46
movq %rbx, %rdi
callq 0x22d0