// File: /workspace/github_c_makefile_star2_O0/stetre[P]moonglmath/src/quat.c
// Function: quat_Mat
static int quat_Mat(lua_State *L, size_t n)
/* returns the rotation matrix corresponding to the quaternion */
    {
#define w q[0]
#define x q[1]
#define y q[2]
#define z q[3]
    quat_t q; 
    mat_t m;
    double s, wx, wy, wz, xx, yy, zz, xy, xz, yz;
    checkquat(L, 1, q);
    mat_clear(m);
    s = w*w + x*x + y*y +z*z;
    if(s == 0)
        {
        m[0][0] = m[1][1] = m[2][2] = m[3][3] = 1;
        return pushmat(L, m, 4, 4, n, n);
        }
    s = 2 / s;  
    wx = s*w*x;
    wy = s*w*y;
    wz = s*w*z;
    xx = s*x*x;
    yy = s*y*y;
    zz = s*z*z;
    xy = s*x*y;
    xz = s*x*z;
    yz = s*y*z;
    
    m[0][0] = 1 - yy - zz;
    m[1][1] = 1 - xx - zz;
    m[2][2] = 1 - xx - yy;
    m[3][3] = 1;
    m[0][1] = xy - wz;
    m[1][0] = xy + wz;
    m[0][2] = xz + wy;
    m[2][0] = xz - wy;
    m[1][2] = yz - wx;
    m[2][1] = yz + wx;
    return pushmat(L, m, 4, 4, n, n);
#undef w
#undef x
#undef y
#undef z
    }

// Assembly:
subq $0x108, %rsp            # imm = 0x108
movq %rdi, 0xf8(%rsp)
movq %rsi, 0xf0(%rsp)
movq 0xf8(%rsp), %rdi
leaq 0xd0(%rsp), %rdx
movl $0x1, %esi
callq 0x8260
leaq 0x50(%rsp), %rdi
xorl %esi, %esi
movl $0x80, %edx
callq 0x8530
movsd 0xd0(%rsp), %xmm0
movsd 0xd0(%rsp), %xmm2
movsd 0xd8(%rsp), %xmm1
mulsd 0xd8(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd 0xe0(%rsp), %xmm1
movsd 0xe0(%rsp), %xmm2
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movsd 0xe8(%rsp), %xmm0
movsd 0xe8(%rsp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x48(%rsp)
movsd 0x48(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x1b02d
jp 0x1b02d
movsd 0x80ff(%rip), %xmm0     # 0x230c0
movsd %xmm0, 0xc8(%rsp)
movsd 0x80ee(%rip), %xmm0     # 0x230c0
movsd %xmm0, 0xa0(%rsp)
movsd 0x80dd(%rip), %xmm0     # 0x230c0
movsd %xmm0, 0x78(%rsp)
movsd 0x80cf(%rip), %xmm0     # 0x230c0
movsd %xmm0, 0x50(%rsp)
movq 0xf8(%rsp), %rdi
leaq 0x50(%rsp), %rsi
movq 0xf0(%rsp), %r8
movq 0xf0(%rsp), %r9
movl $0x4, %ecx
movq %rcx, %rdx
callq 0x8500
movl %eax, 0x104(%rsp)
jmp 0x1b254
movsd 0x86cb(%rip), %xmm0     # 0x23700
divsd 0x48(%rsp), %xmm0
movsd %xmm0, 0x48(%rsp)
movsd 0x48(%rsp), %xmm0
mulsd 0xd0(%rsp), %xmm0
mulsd 0xd8(%rsp), %xmm0
movsd %xmm0, 0x40(%rsp)
movsd 0x48(%rsp), %xmm0
mulsd 0xd0(%rsp), %xmm0
mulsd 0xe0(%rsp), %xmm0
movsd %xmm0, 0x38(%rsp)
movsd 0x48(%rsp), %xmm0
mulsd 0xd0(%rsp), %xmm0
mulsd 0xe8(%rsp), %xmm0
movsd %xmm0, 0x30(%rsp)
movsd 0x48(%rsp), %xmm0
mulsd 0xd8(%rsp), %xmm0
mulsd 0xd8(%rsp), %xmm0
movsd %xmm0, 0x28(%rsp)
movsd 0x48(%rsp), %xmm0
mulsd 0xe0(%rsp), %xmm0
mulsd 0xe0(%rsp), %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0x48(%rsp), %xmm0
mulsd 0xe8(%rsp), %xmm0
mulsd 0xe8(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x48(%rsp), %xmm0
mulsd 0xd8(%rsp), %xmm0
mulsd 0xe0(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x48(%rsp), %xmm0
mulsd 0xd8(%rsp), %xmm0
mulsd 0xe8(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x48(%rsp), %xmm0
mulsd 0xe0(%rsp), %xmm0
mulsd 0xe8(%rsp), %xmm0
movsd %xmm0, (%rsp)
movsd 0x7f6a(%rip), %xmm0     # 0x230c0
subsd 0x20(%rsp), %xmm0
subsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x50(%rsp)
movsd 0x7f50(%rip), %xmm0     # 0x230c0
subsd 0x28(%rsp), %xmm0
subsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x78(%rsp)
movsd 0x7f36(%rip), %xmm0     # 0x230c0
subsd 0x28(%rsp), %xmm0
subsd 0x20(%rsp), %xmm0
movsd %xmm0, 0xa0(%rsp)
movsd 0x7f19(%rip), %xmm0     # 0x230c0
movsd %xmm0, 0xc8(%rsp)
movsd 0x10(%rsp), %xmm0
subsd 0x30(%rsp), %xmm0
movsd %xmm0, 0x58(%rsp)
movsd 0x10(%rsp), %xmm0
addsd 0x30(%rsp), %xmm0
movsd %xmm0, 0x70(%rsp)
movsd 0x8(%rsp), %xmm0
addsd 0x38(%rsp), %xmm0
movsd %xmm0, 0x60(%rsp)
movsd 0x8(%rsp), %xmm0
subsd 0x38(%rsp), %xmm0
movsd %xmm0, 0x90(%rsp)
movsd (%rsp), %xmm0
subsd 0x40(%rsp), %xmm0
movsd %xmm0, 0x80(%rsp)
movsd (%rsp), %xmm0
addsd 0x40(%rsp), %xmm0
movsd %xmm0, 0x98(%rsp)
movq 0xf8(%rsp), %rdi
leaq 0x50(%rsp), %rsi
movq 0xf0(%rsp), %r8
movq 0xf0(%rsp), %r9
movl $0x4, %ecx
movq %rcx, %rdx
callq 0x8500
movl %eax, 0x104(%rsp)
movl 0x104(%rsp), %eax
addq $0x108, %rsp            # imm = 0x108
retq
nopw %cs:(%rax,%rax)