// File: tomfunkhouser[P]gaps/pkgs/R2Shapes/R3Matrix.cpp
// Function: gaps::R3Matrix::Invert()
void R3Matrix::
Invert(void)
{
    // Compute determinant
    RNScalar det = Determinant();
    if (RNIsZero(det, 1E-8)) {
        RNWarning("Unable to invert matrix with zero determinant");
        return;
    }

    // Copy values
    RNScalar m00 = m[0][0]; RNScalar m01 = m[0][1]; RNScalar m02 = m[0][2];
    RNScalar m10 = m[1][0]; RNScalar m11 = m[1][1]; RNScalar m12 = m[1][2];
    RNScalar m20 = m[2][0]; RNScalar m21 = m[2][1]; RNScalar m22 = m[2][2];

    // Compute inverse matrix
    m[0][0] = R3MatrixDet2(m11, m12, m21, m22)/det;
    m[0][1] = R3MatrixDet2(m02, m01, m22, m21)/det;
    m[0][2] = R3MatrixDet2(m01, m02, m11, m12)/det;
    m[1][0] = R3MatrixDet2(m12, m10, m22, m20)/det;
    m[1][1] = R3MatrixDet2(m00, m02, m20, m22)/det;
    m[1][2] = R3MatrixDet2(m02, m00, m12, m10)/det;
    m[2][0] = R3MatrixDet2(m10, m11, m20, m21)/det;
    m[2][1] = R3MatrixDet2(m01, m00, m21, m20)/det;
    m[2][2] = R3MatrixDet2(m00, m01, m10, m11)/det;
}

// Assembly:
subq $0x68, %rsp
movq %rdi, 0x60(%rsp)
movq 0x60(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0xbfc20
movsd %xmm0, 0x58(%rsp)
movsd 0x58(%rsp), %xmm0
movsd 0x73f7c(%rip), %xmm1    # 0x133dd8
callq 0x36b80
cmpl $0x0, %eax
je 0xbfe79
leaq 0x73f73(%rip), %rdi     # 0x133de0
movb $0x0, %al
callq 0xd5010
jmp 0xc0074
movq 0x8(%rsp), %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x50(%rsp)
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x48(%rsp)
movsd 0x10(%rax), %xmm0
movsd %xmm0, 0x40(%rsp)
movsd 0x18(%rax), %xmm0
movsd %xmm0, 0x38(%rsp)
movsd 0x20(%rax), %xmm0
movsd %xmm0, 0x30(%rsp)
movsd 0x28(%rax), %xmm0
movsd %xmm0, 0x28(%rsp)
movsd 0x30(%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0x38(%rax), %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x40(%rax), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x30(%rsp), %xmm0
movsd 0x28(%rsp), %xmm1
movsd 0x18(%rsp), %xmm2
movsd 0x10(%rsp), %xmm3
callq 0xc00f0
movq 0x8(%rsp), %rax
divsd 0x58(%rsp), %xmm0
movsd %xmm0, (%rax)
movsd 0x40(%rsp), %xmm0
movsd 0x48(%rsp), %xmm1
movsd 0x10(%rsp), %xmm2
movsd 0x18(%rsp), %xmm3
callq 0xc00f0
movq 0x8(%rsp), %rax
divsd 0x58(%rsp), %xmm0
movsd %xmm0, 0x8(%rax)
movsd 0x48(%rsp), %xmm0
movsd 0x40(%rsp), %xmm1
movsd 0x30(%rsp), %xmm2
movsd 0x28(%rsp), %xmm3
callq 0xc00f0
movq 0x8(%rsp), %rax
divsd 0x58(%rsp), %xmm0
movsd %xmm0, 0x10(%rax)
movsd 0x28(%rsp), %xmm0
movsd 0x38(%rsp), %xmm1
movsd 0x10(%rsp), %xmm2
movsd 0x20(%rsp), %xmm3
callq 0xc00f0
movq 0x8(%rsp), %rax
divsd 0x58(%rsp), %xmm0
movsd %xmm0, 0x18(%rax)
movsd 0x50(%rsp), %xmm0
movsd 0x40(%rsp), %xmm1
movsd 0x20(%rsp), %xmm2
movsd 0x10(%rsp), %xmm3
callq 0xc00f0
movq 0x8(%rsp), %rax
divsd 0x58(%rsp), %xmm0
movsd %xmm0, 0x20(%rax)
movsd 0x40(%rsp), %xmm0
movsd 0x50(%rsp), %xmm1
movsd 0x28(%rsp), %xmm2
movsd 0x38(%rsp), %xmm3
callq 0xc00f0
movq 0x8(%rsp), %rax
divsd 0x58(%rsp), %xmm0
movsd %xmm0, 0x28(%rax)
movsd 0x38(%rsp), %xmm0
movsd 0x30(%rsp), %xmm1
movsd 0x20(%rsp), %xmm2
movsd 0x18(%rsp), %xmm3
callq 0xc00f0
movq 0x8(%rsp), %rax
divsd 0x58(%rsp), %xmm0
movsd %xmm0, 0x30(%rax)
movsd 0x48(%rsp), %xmm0
movsd 0x50(%rsp), %xmm1
movsd 0x18(%rsp), %xmm2
movsd 0x20(%rsp), %xmm3
callq 0xc00f0
movq 0x8(%rsp), %rax
divsd 0x58(%rsp), %xmm0
movsd %xmm0, 0x38(%rax)
movsd 0x50(%rsp), %xmm0
movsd 0x48(%rsp), %xmm1
movsd 0x38(%rsp), %xmm2
movsd 0x30(%rsp), %xmm3
callq 0xc00f0
movq 0x8(%rsp), %rax
divsd 0x58(%rsp), %xmm0
movsd %xmm0, 0x40(%rax)
addq $0x68, %rsp
retq
nopl (%rax)