// File: /workspace/github_c_makefile_star2_O1/stetre[P]moonglmath/src/mat.c
// Function: moonglmath_testmat
int testmat(lua_State *L, int arg, mat_t m, size_t *nr, size_t *nc)
    {
    int row;
    size_t i, j, nr_, nc_;
    if(!testmetatable(L, arg, MAT_MT))
        return 0;

    lua_getfield(L, arg, "rows");   
    nr_ = luaL_checkinteger(L, -1);
    lua_pop(L, 1);
    lua_getfield(L, arg, "columns");    
    nc_ = luaL_checkinteger(L, -1);
    lua_pop(L, 1);
    checkmatsize(L, nr_, nc_);

    if(nr) *nr = nr_;
    if(nc) *nc = nc_;
    if(m)
        {
        for(i=0; i < nr_; i++)
            {
            if(lua_geti(L, arg, i+1) != LUA_TTABLE)
                return luaL_error(L, "malformed matrix");
            row = lua_gettop(L);
            for(j=0; j < nc_; j++)
                {
                lua_geti(L, row, j+1);
                m[i][j] = luaL_checknumber(L, -1);
                lua_pop(L, 1);
                }
            lua_pop(L, 1);
            }
        }
    return 1;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r8, %r12
movq %rcx, %r13
movq %rdx, %r14
movl %esi, %r15d
movq %rdi, %rbx
leaq 0x9a45(%rip), %rdx      # 0x17395
callq 0x8170
testl %eax, %eax
je 0xd9f1
movq %r12, 0x20(%rsp)
leaq 0x9c57(%rip), %rdx      # 0x175c0
movq %rbx, %rdi
movl %r15d, %esi
callq 0x8da0
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x86e0
movq %rax, %r12
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x80c0
leaq 0x9c2d(%rip), %rdx      # 0x175c5
movq %rbx, %rdi
movl %r15d, %esi
callq 0x8da0
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x86e0
movq %rax, %rbp
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x80c0
movq %r12, 0x10(%rsp)
leaq -0x5(%r12), %rax
cmpq $-0x4, %rax
setb %al
movq %rbp, 0x8(%rsp)
leaq -0x5(%rbp), %rcx
cmpq $-0x4, %rcx
setb %cl
orb %al, %cl
je 0xd9f8
leaq 0x9be1(%rip), %rsi      # 0x175cd
jmp 0xdaf5
xorl %eax, %eax
jmp 0xdadf
testq %r13, %r13
je 0xda06
movq 0x10(%rsp), %rax
movq %rax, (%r13)
movq 0x20(%rsp), %rcx
testq %rcx, %rcx
je 0xda18
movq 0x8(%rsp), %rax
movq %rax, (%rcx)
testq %r14, %r14
setne %al
cmpq $0x0, 0x10(%rsp)
setne %cl
andb %al, %cl
movl $0x1, %eax
cmpb $0x1, %cl
jne 0xdadf
movq 0x8(%rsp), %rbp
negq %rbp
xorl %r13d, %r13d
movl %r15d, 0x1c(%rsp)
incq %r13
movq %rbx, %rdi
movl %r15d, %esi
movq %r13, %rdx
callq 0x8d30
cmpl $0x5, %eax
jne 0xdaee
movq %rbx, %rdi
callq 0x8060
cmpq $0x0, 0x8(%rsp)
je 0xdab9
movl %eax, %r15d
movl $0x1, %r12d
movq %rbx, %rdi
movl %r15d, %esi
movq %r12, %rdx
callq 0x8d30
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x8320
movsd %xmm0, -0x8(%r14,%r12,8)
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x80c0
leaq (%r12,%rbp), %rax
incq %rax
incq %r12
cmpq $0x1, %rax
jne 0xda7a
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x80c0
addq $0x20, %r14
cmpq 0x10(%rsp), %r13
movl 0x1c(%rsp), %r15d
jne 0xda47
movl $0x1, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x9aec(%rip), %rsi      # 0x175e1
movq %rbx, %rdi
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x8a80