// File: /workspace/github_c_makefile_star2_O3/stetre[P]moongl/src/draw.c
// Function: MultiDrawElementsBaseVertex
static int MultiDrawElementsBaseVertex(lua_State *L)
/* multi_draw_elements_base_vertex
 *  (mode, type, count1, indices1, basevertex1, [, count2, indices2, basevertex2, ...]) 
 */
    {
    GLsizei *count, drawcount, i, arg;
    GLintptr *indices;
    GLint *basevertex;
    GLenum mode = checkdrawmode(L, 1);
    GLenum type = checkdrawtype(L, 2);
    arg = 3;
    while(!lua_isnoneornil(L, arg))
        luaL_checkinteger(L, arg++);
    drawcount = arg - 3;
    if(((arg<5) || (drawcount%3) != 0))
        return luaL_error(L, NARGS_ERROR);
    drawcount /= 3;
    indices = (GLintptr*)Malloc3(L, drawcount*sizeof(GLintptr), 
                    (void**)&count, drawcount*sizeof(GLsizei),
                    (void**)&basevertex, drawcount*sizeof(GLint));
    arg = 3;
    for(i=0; i<drawcount; i++)
        {
        indices[i] = lua_tointeger(L, arg++);
        count[i] = lua_tointeger(L, arg++);
        basevertex[i] = lua_tointeger(L, arg++);
        }
    glMultiDrawElementsBaseVertex(mode, count, type, (const void* const*)indices, drawcount,basevertex);
    Free(L, indices); 
    Free(L, count);
    Free(L, basevertex);
    CheckError(L);
    return 0;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movl $0x2c, %esi
movl $0x1, %edx
callq 0x11150
movl %eax, %r13d
movq %rbx, %rdi
movl $0x2d, %esi
movl $0x2, %edx
callq 0x11150
movl %eax, 0x14(%rsp)
movq %rbx, %rdi
movl $0x3, %esi
callq 0x11850
testl %eax, %eax
jle 0x1423c
xorl %r12d, %r12d
leal 0x3(%r12), %esi
leal 0x4(%r12), %r15d
movq %rbx, %rdi
callq 0x11af0
movq %rbx, %rdi
movl %r15d, %esi
callq 0x11850
incl %r12d
testl %eax, %eax
jg 0x14136
leal 0x2(%r12), %ebp
cmpl $0x4, %ebp
jb 0x1423c
movl %r12d, %r14d
movl $0xaaaaaaab, %eax       # imm = 0xAAAAAAAB
imulq %r14, %rax
shrq $0x21, %rax
leal (%rax,%rax,2), %eax
cmpl %r12d, %eax
jne 0x1423c
movl %r13d, 0x10(%rsp)
movslq %r12d, %rax
imulq $0x55555556, %rax, %r15 # imm = 0x55555556
movq %r15, %rax
shrq $0x3f, %rax
shrq $0x20, %r15
addl %eax, %r15d
movslq %r15d, %rcx
leaq (,%rcx,8), %rsi
shlq $0x2, %rcx
leaq 0x8(%rsp), %rdx
movq %rsp, %r8
movq %rbx, %rdi
movq %rcx, %r9
callq 0x119d0
movq %rax, %r12
cmpl $0x4, %ebp
jbe 0x1425b
movl $0xaaaaaaab, %eax       # imm = 0xAAAAAAAB
imulq %r14, %rax
shrq $0x21, %rax
cmpl $0x2, %eax
movl $0x1, %ebp
cmovgel %eax, %ebp
movl $0x3, %r13d
xorl %r14d, %r14d
movq %rbx, %rdi
movl %r13d, %esi
xorl %edx, %edx
callq 0x11040
movq %rax, (%r12,%r14,8)
leal 0x1(%r13), %esi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x11040
movq 0x8(%rsp), %rcx
movl %eax, (%rcx,%r14,4)
leal 0x2(%r13), %esi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x11040
movq (%rsp), %r9
movl %eax, (%r9,%r14,4)
incq %r14
addl $0x3, %r13d
cmpq %r14, %rbp
jne 0x141f0
jmp 0x1425f
leaq 0x2b33b(%rip), %rsi     # 0x3f57e
movq %rbx, %rdi
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x11ae0
movq (%rsp), %r9
movq 0x424fa(%rip), %rax     # 0x56760
movq 0x8(%rsp), %rsi
movl 0x10(%rsp), %edi
movl 0x14(%rsp), %edx
movq %r12, %rcx
movl %r15d, %r8d
callq *(%rax)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x11360
movq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x11360
movq (%rsp), %rsi
movq %rbx, %rdi
callq 0x11360
movq %rbx, %rdi
callq 0x11870
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq