// File: tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Quaternion.cpp
// Function: gaps::R3Quaternion::Matrix() const
const R4Matrix R3Quaternion::
Matrix(void) const
{
    // Return rotation matrix
    RNScalar a = v[0];
    RNScalar b = v[1];
    RNScalar c = v[2];
    RNScalar d = v[3];
    R4Matrix m = R4identity_matrix;
    m[0][0] = a*a + b*b - c*c - d*d;
    m[0][1] = 2*b*c - 2*a*d;
    m[0][2] = 2*b*d + 2*a*c;
    m[1][0] = 2*b*c + 2*a*d;
    m[1][1] = a*a - b*b + c*c - d*d;
    m[1][2] = 2*c*d - 2*a*b;
    m[2][0] = 2*b*d - 2*a*c;
    m[2][1] = 2*c*d + 2*a*b;
    m[2][2] = a*a - b*b - c*c + d*d;
    return m;
}

// Assembly:
subq $0x88, %rsp
movq %rdi, 0x40(%rsp)
movq %rdi, %rax
movq %rax, 0x50(%rsp)
movq %rdi, 0x80(%rsp)
movq %rsi, 0x78(%rsp)
movq 0x78(%rsp), %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x70(%rsp)
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x68(%rsp)
movsd 0x10(%rax), %xmm0
movsd %xmm0, 0x60(%rsp)
movsd 0x18(%rax), %xmm0
movsd %xmm0, 0x58(%rsp)
leaq 0x1282e8(%rip), %rsi    # 0x178c30
callq 0x51b60
movq 0x40(%rsp), %rdi
movsd 0x70(%rsp), %xmm0
movsd 0x70(%rsp), %xmm2
movsd 0x68(%rsp), %xmm1
mulsd 0x68(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd 0x60(%rsp), %xmm1
movsd 0x60(%rsp), %xmm2
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movsd 0x58(%rsp), %xmm0
movsd 0x58(%rsp), %xmm2
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rsp)
xorl %esi, %esi
callq 0x51ad0
movsd (%rsp), %xmm0
movq 0x40(%rsp), %rdi
movsd %xmm0, (%rax)
movsd 0xe2816(%rip), %xmm0    # 0x133200
mulsd 0x68(%rsp), %xmm0
movsd 0x60(%rsp), %xmm2
movsd 0xe2802(%rip), %xmm1    # 0x133200
mulsd 0x70(%rsp), %xmm1
mulsd 0x58(%rsp), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x8(%rsp)
xorl %esi, %esi
callq 0x51ad0
movsd 0x8(%rsp), %xmm0
movq 0x40(%rsp), %rdi
movsd %xmm0, 0x8(%rax)
movsd 0xe27b2(%rip), %xmm0    # 0x133200
mulsd 0x68(%rsp), %xmm0
movsd 0x58(%rsp), %xmm2
movsd 0xe279e(%rip), %xmm1    # 0x133200
mulsd 0x70(%rsp), %xmm1
mulsd 0x60(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rsp)
xorl %esi, %esi
callq 0x51ad0
movsd 0x10(%rsp), %xmm0
movq 0x40(%rsp), %rdi
movsd %xmm0, 0x10(%rax)
movsd 0xe2765(%rip), %xmm0    # 0x133200
mulsd 0x68(%rsp), %xmm0
movsd 0x60(%rsp), %xmm2
movsd 0xe2751(%rip), %xmm1    # 0x133200
mulsd 0x70(%rsp), %xmm1
mulsd 0x58(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x18(%rsp)
movl $0x1, %esi
callq 0x51ad0
movsd 0x18(%rsp), %xmm0
movq 0x40(%rsp), %rdi
movsd %xmm0, (%rax)
movsd 0x70(%rsp), %xmm0
movsd 0x70(%rsp), %xmm2
movsd 0x68(%rsp), %xmm1
mulsd 0x68(%rsp), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd 0x60(%rsp), %xmm1
movsd 0x60(%rsp), %xmm2
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movsd 0x58(%rsp), %xmm0
movsd 0x58(%rsp), %xmm2
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x20(%rsp)
movl $0x1, %esi
callq 0x51ad0
movsd 0x20(%rsp), %xmm0
movq 0x40(%rsp), %rdi
movsd %xmm0, 0x8(%rax)
movsd 0xe2680(%rip), %xmm0    # 0x133200
mulsd 0x60(%rsp), %xmm0
movsd 0x58(%rsp), %xmm2
movsd 0xe266c(%rip), %xmm1    # 0x133200
mulsd 0x70(%rsp), %xmm1
mulsd 0x68(%rsp), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x28(%rsp)
movl $0x1, %esi
callq 0x51ad0
movsd 0x28(%rsp), %xmm0
movq 0x40(%rsp), %rdi
movsd %xmm0, 0x10(%rax)
movsd 0xe2619(%rip), %xmm0    # 0x133200
mulsd 0x68(%rsp), %xmm0
movsd 0x58(%rsp), %xmm2
movsd 0xe2605(%rip), %xmm1    # 0x133200
mulsd 0x70(%rsp), %xmm1
mulsd 0x60(%rsp), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x30(%rsp)
movl $0x2, %esi
callq 0x51ad0
movsd 0x30(%rsp), %xmm0
movq 0x40(%rsp), %rdi
movsd %xmm0, (%rax)
movsd 0xe25b3(%rip), %xmm0    # 0x133200
mulsd 0x60(%rsp), %xmm0
movsd 0x58(%rsp), %xmm2
movsd 0xe259f(%rip), %xmm1    # 0x133200
mulsd 0x70(%rsp), %xmm1
mulsd 0x68(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x38(%rsp)
movl $0x2, %esi
callq 0x51ad0
movsd 0x38(%rsp), %xmm0
movq 0x40(%rsp), %rdi
movsd %xmm0, 0x8(%rax)
movsd 0x70(%rsp), %xmm0
movsd 0x70(%rsp), %xmm2
movsd 0x68(%rsp), %xmm1
mulsd 0x68(%rsp), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd 0x60(%rsp), %xmm1
movsd 0x60(%rsp), %xmm2
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movsd 0x58(%rsp), %xmm0
movsd 0x58(%rsp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x48(%rsp)
movl $0x2, %esi
callq 0x51ad0
movsd 0x48(%rsp), %xmm0
movq %rax, %rcx
movq 0x50(%rsp), %rax
movsd %xmm0, 0x10(%rcx)
addq $0x88, %rsp
retq
nopw %cs:(%rax,%rax)