// File: /workspace/github_c_makefile_star2_O1/stetre[P]moongl/src/vertex_array.c
// Function: BindVertexBuffers
static int BindVertexBuffers(lua_State *L)
/*
 * bind_vertex_buffers(first, buffer1, offset1, stride1 [, buffer2, offset2, stride2, ...])
 * bind_vertex_buffers(array, first, buffer1, offset1, stride1 [, buffer2, offset2, stride2, ...])
 */
    {
    GLsizei named, count, i, arg;
    GLuint array, first;
    GLuint *buffers;
    GLintptr *offsets;
    GLsizei *strides;
    
    arg = 1;
    while(!lua_isnoneornil(L, arg))
        luaL_checkinteger(L, arg++);
    count = arg - 1;
    if(count < 4)
        return luaL_checkinteger(L, arg); /* raises an error */
    arg = 1;
    if(((count-2)%3) == 0)
        {
        named = 1;
        count = (count - 2)/3;
        array = luaL_checkinteger(L, arg++);
        }
    else if(((count-1)%3) == 0)
        {
        named = 0;
        count = (count - 1)/3;
        }
    else
        return luaL_error(L, NARGS_ERROR);
    first = lua_tointeger(L, arg++);
    buffers = (GLuint*)Malloc3(L, count*sizeof(GLuint),
                        (void**)&offsets, count*sizeof(GLintptr),
                        (void**)&strides, count*sizeof(GLsizei));
    for(i=0; i<count; i++)
        {
        buffers[i] = lua_tointeger(L, arg++);
        offsets[i] = lua_tointeger(L, arg++);
        strides[i] = lua_tointeger(L, arg++);
        }
    if(named)
        glVertexArrayVertexBuffers(array, first, count, buffers, offsets, strides);
    else
        glBindVertexBuffers(first, count, buffers, offsets, strides);
    Free(L, buffers);
    Free(L, offsets);
    Free(L, strides);
    CheckError(L);
    return 0;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
movl $0x1, %r14d
movl $0x1, %esi
callq 0x11860
testl %eax, %eax
jle 0x3d36c
movl $0x1, %esi
leal 0x1(%rsi), %r14d
movq %rbx, %rdi
callq 0x11af0
movq %rbx, %rdi
movl %r14d, %esi
callq 0x11860
movl %r14d, %esi
testl %eax, %eax
jg 0x3d34e
cmpl $0x4, %r14d
ja 0x3d382
movq %rbx, %rdi
movl %r14d, %esi
callq 0x11af0
jmp 0x3d537
leal -0x3(%r14), %ebp
movl $0xaaaaaaab, %eax       # imm = 0xAAAAAAAB
imulq %rbp, %rax
shrq $0x21, %rax
leal (%rax,%rax,2), %eax
movl %ebp, %ecx
subl %eax, %ecx
je 0x3d3cd
addl $-0x2, %r14d
imull $0xaaaaaaab, %r14d, %eax # imm = 0xAAAAAAAB
cmpl $0x55555556, %eax       # imm = 0x55555556
jb 0x3d3eb
leaq 0x21c9(%rip), %rsi      # 0x3f57e
movq %rbx, %rdi
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x11ae0
movl %ecx, 0x4(%rsp)
movq %rbx, %rdi
movl $0x1, %esi
callq 0x11af0
movq %rax, 0x20(%rsp)
movl $0x2, %r12d
jmp 0x3d3fd
movl %ecx, 0x4(%rsp)
movl $0x1, %r12d
movl %r14d, %ebp
movq %rax, 0x20(%rsp)
movl %ebp, %eax
movl $0xaaaaaaab, %r14d      # imm = 0xAAAAAAAB
imulq %rax, %r14
shrq $0x21, %r14
movq %rbx, %rdi
movl %r12d, %esi
xorl %edx, %edx
callq 0x11040
movq %rax, 0x28(%rsp)
leaq (,%r14,4), %rsi
movq %r14, 0x8(%rsp)
movq %r14, %rcx
shlq $0x3, %rcx
leaq 0x18(%rsp), %rdx
leaq 0x10(%rsp), %r8
movq %rbx, %rdi
movq %rsi, %r9
callq 0x119d0
movq %rax, 0x30(%rsp)
cmpl $0x3, %ebp
jb 0x3d4b9
movl 0x8(%rsp), %r15d
shlq $0x2, %r15
incl %r12d
xorl %r13d, %r13d
leal 0x1(%r12), %r14d
movq %rbx, %rdi
movl %r12d, %esi
xorl %edx, %edx
callq 0x11040
movq 0x30(%rsp), %rcx
movl %eax, (%rcx,%r13)
leal 0x2(%r12), %ebp
movq %rbx, %rdi
movl %r14d, %esi
xorl %edx, %edx
callq 0x11040
movq 0x18(%rsp), %rcx
movq %rax, (%rcx,%r13,2)
movq %rbx, %rdi
movl %ebp, %esi
xorl %edx, %edx
callq 0x11040
movq 0x10(%rsp), %rcx
movl %eax, (%rcx,%r13)
addq $0x4, %r13
addl $0x3, %r12d
cmpq %r13, %r15
jne 0x3d461
movq 0x30(%rsp), %r14
movq 0x18(%rsp), %r8
movq 0x10(%rsp), %r9
cmpl $0x0, 0x4(%rsp)
je 0x3d4ed
movq 0x190aa(%rip), %rax     # 0x56580
movq 0x28(%rsp), %rdi
movq 0x8(%rsp), %rsi
movq %r14, %rdx
movq %r8, %rcx
movq %r9, %r8
callq *(%rax)
jmp 0x3d508
movq 0x19914(%rip), %rax     # 0x56e08
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %r14, %rcx
callq *(%rax)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x11370
movq 0x18(%rsp), %rsi
movq %rbx, %rdi
callq 0x11370
movq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x11370
movq %rbx, %rdi
callq 0x11880
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq