// File: /workspace/github_c_makefile_star2_O2/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
pushq $0x1
popq %r15
xorl %r12d, %r12d
pushq $-0x1
popq %rbp
pushq $-0x2
popq %r14
movq %rbx, %rdi
movl %r15d, %esi
callq 0x11850
testl %eax, %eax
jle 0x39faa
leal 0x1(%r15), %r13d
movq %rbx, %rdi
movl %r15d, %esi
callq 0x11af0
decl %r12d
incl %ebp
incl %r14d
movl %r13d, %r15d
jmp 0x39f7f
cmpl $0x4, %r15d
ja 0x39fc0
movq %rbx, %rdi
movl %r15d, %esi
callq 0x11af0
jmp 0x3a14c
pushq $-0x2
popq %rdi
pushq $0x3
popq %rsi
movl %r14d, %eax
xorl %edx, %edx
divl %esi
leal (%rax,%rax,2), %eax
movl %edi, %ecx
subl %eax, %ecx
cmpl %r12d, %ecx
jne 0x3a000
movl %ecx, 0x4(%rsp)
subl %r12d, %edi
movl %esi, %ebp
pushq $0x1
popq %rsi
movl %edi, %r14d
movq %rbx, %rdi
callq 0x11af0
movl %r14d, %ecx
movl %ebp, %esi
movq %rax, 0x20(%rsp)
pushq $0x2
popq %r15
jmp 0x3a026
movl %ebp, %eax
xorl %edx, %edx
divl %esi
leal (%rax,%rax,2), %eax
notl %eax
cmpl %r12d, %eax
jne 0x3a15b
movl %ecx, 0x4(%rsp)
movl %r12d, %ecx
notl %ecx
pushq $0x1
popq %r15
movq %rax, 0x20(%rsp)
xorl %r13d, %r13d
movl %ecx, %eax
xorl %edx, %edx
divl %esi
movl %eax, %ebp
movq %rbx, %rdi
movl %r15d, %esi
xorl %edx, %edx
callq 0x11040
movq %rax, 0x28(%rsp)
leaq (,%rbp,4), %r14
movq %rbp, 0x30(%rsp)
shlq $0x3, %rbp
leaq 0x18(%rsp), %rdx
leaq 0x10(%rsp), %r8
movq %rbx, %rdi
movq %r14, %rsi
movq %rbp, %rcx
movq %r14, %r9
callq 0x119d0
movq %rax, 0x8(%rsp)
addl $0x3, %r15d
cmpq %r13, %r14
je 0x3a0c9
leal -0x2(%r15), %esi
leal -0x1(%r15), %ebp
movq %rbx, %rdi
xorl %edx, %edx
callq 0x11040
movq 0x8(%rsp), %rcx
movl %eax, (%rcx,%r13)
movq %rbx, %rdi
movl %ebp, %esi
xorl %edx, %edx
callq 0x11040
movq 0x18(%rsp), %rcx
movq %rax, (%rcx,%r13,2)
movq %rbx, %rdi
movl %r15d, %esi
xorl %edx, %edx
callq 0x11040
movq 0x10(%rsp), %rcx
movl %eax, (%rcx,%r13)
addq $0x4, %r13
jmp 0x3a074
movq 0x18(%rsp), %r8
movq 0x10(%rsp), %r9
cmpl %r12d, 0x4(%rsp)
jne 0x3a0fc
movq 0x1bd27(%rip), %rax     # 0x55e08
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
movq 0x8(%rsp), %r14
movq %r14, %rcx
callq *(%rax)
jmp 0x3a11d
movq 0x1b47d(%rip), %rax     # 0x55580
movq 0x28(%rsp), %rdi
movq 0x30(%rsp), %rsi
movq 0x8(%rsp), %r14
movq %r14, %rdx
movq %r8, %rcx
movq %r9, %r8
callq *(%rax)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x11360
movq 0x18(%rsp), %rsi
movq %rbx, %rdi
callq 0x11360
movq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x11360
movq %rbx, %rdi
callq 0x11870
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x141c(%rip), %rsi      # 0x3b57e
movq %rbx, %rdi
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x11ae0