// File: /workspace/github_c_makefile_star2_O3/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 0x11850
testl %eax, %eax
jle 0x3d496
movl $0xfffffffe, %r14d      # imm = 0xFFFFFFFE
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
leal 0x3(%r14), %esi
leal 0x4(%r14), %ebp
movq %rbx, %rdi
callq 0x11af0
movq %rbx, %rdi
movl %ebp, %esi
callq 0x11850
incl %r14d
incl %r15d
testl %eax, %eax
jg 0x3d465
leal 0x2(%r14), %eax
cmpl $0x3, %eax
ja 0x3d4a6
addl $0x3, %r14d
movq %rbx, %rdi
movl %r14d, %esi
callq 0x11af0
jmp 0x3d64c
movl %r14d, %ecx
movl $0xaaaaaaab, %eax       # imm = 0xAAAAAAAB
imulq %rax, %rcx
shrq $0x21, %rcx
leal (%rcx,%rcx,2), %ecx
negl %ecx
leal (%r14,%rcx), %edx
addl $-0x2, %edx
cmpl $-0x2, %edx
jne 0x3d4e5
movl %edx, 0x4(%rsp)
movq %rbx, %rdi
movl $0x1, %esi
callq 0x11af0
movq %rax, 0x20(%rsp)
movl $0x2, %r13d
jmp 0x3d513
movl %r15d, %ecx
imulq %rax, %rcx
shrq $0x21, %rcx
leal (%rcx,%rcx,2), %eax
notl %eax
addl %r14d, %eax
cmpl $-0x2, %eax
jne 0x3d65b
movl %edx, 0x4(%rsp)
incl %r14d
movl $0x1, %r13d
movq %rax, 0x20(%rsp)
movl %r14d, %eax
movl $0xaaaaaaab, %r12d      # imm = 0xAAAAAAAB
imulq %rax, %r12
shrq $0x21, %r12
movq %rbx, %rdi
movl %r13d, %esi
xorl %edx, %edx
callq 0x11040
movq %rax, 0x28(%rsp)
leaq (,%r12,4), %r15
movq %r12, 0x30(%rsp)
leaq (,%r12,8), %rcx
leaq 0x10(%rsp), %rdx
leaq 0x8(%rsp), %r8
movq %rbx, %rdi
movq %r15, %rsi
movq %r15, %r9
callq 0x119d0
movq %rax, %r12
cmpl $0x3, %r14d
jb 0x3d5d3
incl %r13d
xorl %ebp, %ebp
leal 0x1(%r13), %eax
movl %eax, 0x1c(%rsp)
movq %rbx, %rdi
movl %r13d, %esi
xorl %edx, %edx
callq 0x11040
movl %eax, (%r12,%rbp)
movq %r15, %r14
movq %r12, %r15
leal 0x2(%r13), %r12d
movq %rbx, %rdi
movl 0x1c(%rsp), %esi
xorl %edx, %edx
callq 0x11040
movq 0x10(%rsp), %rcx
movq %rax, (%rcx,%rbp,2)
movq %rbx, %rdi
movl %r12d, %esi
movq %r15, %r12
movq %r14, %r15
xorl %edx, %edx
callq 0x11040
movq 0x8(%rsp), %rcx
movl %eax, (%rcx,%rbp)
addq $0x4, %rbp
addl $0x3, %r13d
cmpq %rbp, %r14
jne 0x3d571
movq 0x10(%rsp), %r8
movq 0x8(%rsp), %r9
cmpl $-0x2, 0x4(%rsp)
jne 0x3d601
movq 0x1981d(%rip), %rax     # 0x56e08
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
movq %r12, %rcx
callq *(%rax)
jmp 0x3d61d
movq 0x18f78(%rip), %rax     # 0x56580
movq 0x28(%rsp), %rdi
movq 0x30(%rsp), %rsi
movq %r12, %rdx
movq %r8, %rcx
movq %r9, %r8
callq *(%rax)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x11360
movq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x11360
movq 0x8(%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 0x1f1c(%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