// File: /workspace/github_c_makefile_star2_O1/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 0x11160
movl %eax, %ebp
movq %rbx, %rdi
movl $0x2d, %esi
movl $0x2, %edx
callq 0x11160
movl %eax, %r14d
movl $0x3, %r13d
movq %rbx, %rdi
movl $0x3, %esi
callq 0x11860
testl %eax, %eax
jle 0x1405b
movl $0x3, %esi
leal 0x1(%rsi), %r13d
movq %rbx, %rdi
callq 0x11af0
movq %rbx, %rdi
movl %r13d, %esi
callq 0x11860
movl %r13d, %esi
testl %eax, %eax
jg 0x1403d
cmpl $0x5, %r13d
jb 0x14185
leal -0x3(%r13), %eax
cltq
imulq $0x55555556, %rax, %r15 # imm = 0x55555556
movq %r15, %rax
shrq $0x3f, %rax
shrq $0x20, %r15
addl %eax, %r15d
leal (%r15,%r15,2), %eax
negl %eax
addl %r13d, %eax
addl $-0x3, %eax
testl %eax, %eax
jne 0x14185
movl %r14d, 0x10(%rsp)
movl %ebp, 0x14(%rsp)
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 $0x6, %r13d
jl 0x14128
cmpl $0x2, %r15d
movl $0x1, %ebp
cmovgel %r15d, %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), %rcx
movl %eax, (%rcx,%r14,4)
incq %r14
addl $0x3, %r13d
cmpq %r14, %rbp
jne 0x140de
movq 0x42631(%rip), %rax     # 0x56760
movq 0x8(%rsp), %rsi
movq (%rsp), %r9
movl 0x14(%rsp), %edi
movl 0x10(%rsp), %edx
movq %r12, %rcx
movl %r15d, %r8d
callq *(%rax)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x11370
movq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x11370
movq (%rsp), %rsi
movq %rbx, %rdi
callq 0x11370
movq %rbx, %rdi
callq 0x11880
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2b3f2(%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