// File: /workspace/github_cpp_makefile_star2_O2/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, %r14
movl 0x18(%rsi), %esi
cmpl 0x1c(%r14), %esi
jne 0x2a77
movq %rdi, %rbx
leal (%rsi,%rsi), %edx
leaq 0x10(%rsp), %r15
movq %r15, %rdi
callq 0x24dc
xorl %r12d, %r12d
movslq 0x18(%r14), %rsi
cmpq %rsi, %r12
jge 0x27e9
imulq $0x18, %r12, %r13
xorl %ebp, %ebp
movslq 0x1c(%r14), %rax
cmpq %rax, %rbp
jge 0x27e4
movq (%r14), %rax
movq (%rax,%r13), %rax
movss (%rax,%rbp,4), %xmm0
movss %xmm0, 0x8(%rsp)
movq %r15, %rdi
movl %r12d, %esi
callq 0x25d2
movq (%rax), %rax
movss 0x8(%rsp), %xmm0
movss %xmm0, (%rax,%rbp,4)
incq %rbp
jmp 0x27ab
incq %r12
jmp 0x279c
xorl %r15d, %r15d
leaq 0x10(%rsp), %r12
cmpl %esi, %r15d
jge 0x281b
movq %r12, %rdi
movl %r15d, %esi
callq 0x25d2
movslq 0x1c(%r14), %rcx
addq %r15, %rcx
movq (%rax), %rax
movl $0x3f800000, (%rax,%rcx,4) # imm = 0x3F800000
movl 0x18(%r14), %esi
incq %r15
jmp 0x27f1
xorl %r12d, %r12d
leaq 0x10(%rsp), %r15
leal -0x1(%rsi), %eax
cltq
movslq 0x2c(%rsp), %r13
cmpq %rax, %r12
jge 0x290f
movl %r13d, %r13d
testl %r13d, %r13d
jle 0x2883
leaq -0x1(%r13), %rbp
movq %r15, %rdi
movl %r12d, %esi
callq 0x25d2
movq (%rax), %rax
movss (%rax,%r12,4), %xmm0
movss %xmm0, 0x8(%rsp)
movq %r15, %rdi
movl %r12d, %esi
callq 0x25d2
movq (%rax), %rax
movss -0x4(%rax,%r13,4), %xmm0
divss 0x8(%rsp), %xmm0
movss %xmm0, -0x4(%rax,%r13,4)
movq %rbp, %r13
jmp 0x2839
leaq 0x1(%r12), %rax
movq %rax, 0x30(%rsp)
movl %eax, %ebp
movl 0x18(%r14), %esi
cmpl %esi, %ebp
jge 0x2905
movq %r15, %rdi
movl %ebp, %esi
callq 0x25d2
movq (%rax), %rax
movss (%rax,%r12,4), %xmm0
movss %xmm0, 0xc(%rsp)
xorl %r13d, %r13d
movslq 0x2c(%rsp), %rax
cmpq %rax, %r13
jge 0x2901
movq %r15, %rdi
movl %r12d, %esi
callq 0x25d2
movq (%rax), %rax
movss (%rax,%r13,4), %xmm0
mulss 0xc(%rsp), %xmm0
movss %xmm0, 0x8(%rsp)
movq %r15, %rdi
movl %ebp, %esi
callq 0x25d2
movq (%rax), %rax
movss (%rax,%r13,4), %xmm0
subss 0x8(%rsp), %xmm0
movss %xmm0, (%rax,%r13,4)
incq %r13
jmp 0x28b3
incl %ebp
jmp 0x288f
movq 0x30(%rsp), %r12
jmp 0x2823
leaq 0x10(%rsp), %r15
movslq %esi, %rax
decl %esi
cmpq %rax, %r13
jl 0x2968
leaq -0x1(%r13), %r12
movq %r15, %rdi
callq 0x25d2
movslq 0x18(%r14), %rsi
movq (%rax), %rax
movss -0x4(%rax,%rsi,4), %xmm0
movss %xmm0, 0x8(%rsp)
decq %rsi
movq %r15, %rdi
callq 0x25d2
movq (%rax), %rax
movss -0x4(%rax,%r13,4), %xmm0
divss 0x8(%rsp), %xmm0
movss %xmm0, -0x4(%rax,%r13,4)
movl 0x18(%r14), %esi
movq %r12, %r13
jmp 0x2914
movl %esi, %r15d
leaq 0x10(%rsp), %r12
movl %r15d, %ebp
testl %r15d, %r15d
jle 0x29ed
testl %ebp, %ebp
jle 0x29e8
decl %ebp
movq %r12, %rdi
movl %ebp, %esi
callq 0x25d2
movq (%rax), %rax
movss (%rax,%r15,4), %xmm0
movss %xmm0, 0xc(%rsp)
xorl %r13d, %r13d
movslq 0x2c(%rsp), %rax
cmpq %rax, %r13
jge 0x2978
movq %r12, %rdi
movl %r15d, %esi
callq 0x25d2
movq (%rax), %rax
movss (%rax,%r13,4), %xmm0
mulss 0xc(%rsp), %xmm0
movss %xmm0, 0x8(%rsp)
movq %r12, %rdi
movl %ebp, %esi
callq 0x25d2
movq (%rax), %rax
movss (%rax,%r13,4), %xmm0
subss 0x8(%rsp), %xmm0
movss %xmm0, (%rax,%r13,4)
incq %r13
jmp 0x299a
decq %r15
jmp 0x2970
movl 0x18(%r14), %esi
movl 0x1c(%r14), %edx
movq %rbx, %rdi
callq 0x24dc
xorl %r15d, %r15d
leaq 0x10(%rsp), %r12
cmpl 0x18(%r14), %r15d
jge 0x2a5b
xorl %r13d, %r13d
movslq 0x1c(%r14), %rax
cmpq %rax, %r13
jge 0x2a56
movq %r12, %rdi
movl %r15d, %esi
callq 0x25d2
movslq 0x1c(%r14), %rcx
addq %r13, %rcx
movq (%rax), %rax
movss (%rax,%rcx,4), %xmm0
movss %xmm0, 0x8(%rsp)
movq %rbx, %rdi
movl %r15d, %esi
callq 0x25d2
movq (%rax), %rax
movss 0x8(%rsp), %xmm0
movss %xmm0, (%rax,%r13,4)
incq %r13
jmp 0x2a0e
incl %r15d
jmp 0x2a05
leaq 0x10(%rsp), %rdi
callq 0x2be2
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x460e(%rip), %rdi      # 0x708c
leaq 0x4592(%rip), %rsi      # 0x7017
leaq 0x460b(%rip), %rcx      # 0x7097
pushq $0x33
popq %rdx
callq 0x2120
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x2be2
movq %rbx, %rdi
callq 0x22b0