// File: stetre[P]moonvulkan/src/cmd.c
// Function: CmdBindVertexBuffers
static int CmdBindVertexBuffers(lua_State *L)
    {
    int err;
    uint32_t count, count1;
    VkBuffer *buffers = NULL;
    VkDeviceSize *offsets = NULL;
    VkDeviceSize *sizes = NULL;
    VkDeviceSize *strides = NULL;
    ud_t *ud;
    VkCommandBuffer cb = checkcommand_buffer(L, 1, &ud);
    uint32_t first = luaL_checkinteger(L, 2);
#define CLEANUP do {                    \
        if(buffers) Free(L, buffers);   \
        if(offsets) Free(L, offsets);   \
        if(sizes) Free(L, sizes);       \
        if(strides) Free(L, strides);   \
} while(0)

    buffers = checkbufferlist(L, 3, &count, &err);
    if(err) { CLEANUP; return argerrorc(L, 3, err); }
    
    offsets = checkdevicesizelist(L, 4, &count1, &err);
    if(err) { CLEANUP; return argerrorc(L, 4, err); }
    if(count1 != count) { CLEANUP; return argerrorc(L, 4, ERR_LENGTH); }

    if(lua_isnoneornil(L, 5) && lua_isnoneornil(L, 6))
        ud->ddt->CmdBindVertexBuffers(cb, first, count, buffers, offsets);
    else
        {
        if(!TestDevicePfn(L, ud, CmdBindVertexBuffers2EXT))
            {
            CLEANUP;
            CheckDevicePfn(L, ud, CmdBindVertexBuffers2EXT); // to raise an error
            return 0;
            }
        else
            {
            sizes = checkdevicesizelist(L, 5, &count1, &err);
            if(err < 0) { CLEANUP; return argerrorc(L, 5, err); }
            if((count1 != 0) && (count1 != count)) { CLEANUP; return argerrorc(L, 5, ERR_LENGTH); }
            strides = checkdevicesizelist(L, 6, &count1, &err);
            if(err < 0) { CLEANUP; return argerrorc(L, 6, err); }
            if((count1 != 0) && (count1 != count)) { CLEANUP; return argerrorc(L, 6, ERR_LENGTH); }
            ud->ddt->CmdBindVertexBuffers2EXT(cb, first, count, buffers, offsets, sizes, strides);
            }
        }
    CLEANUP;
#undef CLEANUP
    return 0;
    }

// Assembly:
subq $0x98, %rsp
movq %rdi, 0x88(%rsp)
movq $0x0, 0x70(%rsp)
movq $0x0, 0x68(%rsp)
movq $0x0, 0x60(%rsp)
movq $0x0, 0x58(%rsp)
movq 0x88(%rsp), %rdi
movl $0x1, %esi
leaq 0x50(%rsp), %rdx
leaq 0xb3cdd(%rip), %rcx     # 0xcf909
callq 0x1a640
movq %rax, 0x48(%rsp)
movq 0x88(%rsp), %rdi
movl $0x2, %esi
callq 0x19190
movl %eax, 0x44(%rsp)
movq 0x88(%rsp), %rdi
movl $0x3, %esi
leaq 0x80(%rsp), %rdx
leaq 0x84(%rsp), %rcx
leaq 0xb3390(%rip), %r8      # 0xcf000
callq 0x19ae0
movq %rax, 0x70(%rsp)
cmpl $0x0, 0x84(%rsp)
je 0x1bd2b
jmp 0x1bc8a
cmpq $0x0, 0x70(%rsp)
je 0x1bca4
movq 0x88(%rsp), %rdi
movq 0x70(%rsp), %rsi
callq 0x18300
cmpq $0x0, 0x68(%rsp)
je 0x1bcbe
movq 0x88(%rsp), %rdi
movq 0x68(%rsp), %rsi
callq 0x18300
cmpq $0x0, 0x60(%rsp)
je 0x1bcd8
movq 0x88(%rsp), %rdi
movq 0x60(%rsp), %rsi
callq 0x18300
cmpq $0x0, 0x58(%rsp)
je 0x1bcf2
movq 0x88(%rsp), %rdi
movq 0x58(%rsp), %rsi
callq 0x18300
jmp 0x1bcf4
movq 0x88(%rsp), %rax
movq %rax, 0x38(%rsp)
movl 0x84(%rsp), %edi
callq 0x19a60
movq 0x38(%rsp), %rdi
movq %rax, %rdx
movl $0x3, %esi
callq 0x18460
movl %eax, 0x94(%rsp)
jmp 0x1c3b4
movq 0x88(%rsp), %rdi
movl $0x4, %esi
leaq 0x7c(%rsp), %rdx
leaq 0x84(%rsp), %rcx
callq 0x19fb0
movq %rax, 0x68(%rsp)
cmpl $0x0, 0x84(%rsp)
je 0x1be00
jmp 0x1bd5f
cmpq $0x0, 0x70(%rsp)
je 0x1bd79
movq 0x88(%rsp), %rdi
movq 0x70(%rsp), %rsi
callq 0x18300
cmpq $0x0, 0x68(%rsp)
je 0x1bd93
movq 0x88(%rsp), %rdi
movq 0x68(%rsp), %rsi
callq 0x18300
cmpq $0x0, 0x60(%rsp)
je 0x1bdad
movq 0x88(%rsp), %rdi
movq 0x60(%rsp), %rsi
callq 0x18300
cmpq $0x0, 0x58(%rsp)
je 0x1bdc7
movq 0x88(%rsp), %rdi
movq 0x58(%rsp), %rsi
callq 0x18300
jmp 0x1bdc9
movq 0x88(%rsp), %rax
movq %rax, 0x30(%rsp)
movl 0x84(%rsp), %edi
callq 0x19a60
movq 0x30(%rsp), %rdi
movq %rax, %rdx
movl $0x4, %esi
callq 0x18460
movl %eax, 0x94(%rsp)
jmp 0x1c3b4
movl 0x7c(%rsp), %eax
cmpl 0x80(%rsp), %eax
je 0x1beb2
jmp 0x1be13
cmpq $0x0, 0x70(%rsp)
je 0x1be2d
movq 0x88(%rsp), %rdi
movq 0x70(%rsp), %rsi
callq 0x18300
cmpq $0x0, 0x68(%rsp)
je 0x1be47
movq 0x88(%rsp), %rdi
movq 0x68(%rsp), %rsi
callq 0x18300
cmpq $0x0, 0x60(%rsp)
je 0x1be61
movq 0x88(%rsp), %rdi
movq 0x60(%rsp), %rsi
callq 0x18300
cmpq $0x0, 0x58(%rsp)
je 0x1be7b
movq 0x88(%rsp), %rdi
movq 0x58(%rsp), %rsi
callq 0x18300
jmp 0x1be7d
movq 0x88(%rsp), %rax
movq %rax, 0x28(%rsp)
movl $0xfffffff9, %edi       # imm = 0xFFFFFFF9
callq 0x19a60
movq 0x28(%rsp), %rdi
movq %rax, %rdx
movl $0x4, %esi
callq 0x18460
movl %eax, 0x94(%rsp)
jmp 0x1c3b4
movq 0x88(%rsp), %rdi
movl $0x5, %esi
callq 0x1a240
cmpl $0x0, %eax
jg 0x1bf11
movq 0x88(%rsp), %rdi
movl $0x6, %esi
callq 0x1a240
cmpl $0x0, %eax
jg 0x1bf11
movq 0x50(%rsp), %rax
movq 0x50(%rax), %rax
movq 0x330(%rax), %rax
movq 0x48(%rsp), %rdi
movl 0x44(%rsp), %esi
movl 0x80(%rsp), %edx
movq 0x70(%rsp), %rcx
movq 0x68(%rsp), %r8
callq *%rax
jmp 0x1c33d
movq 0x50(%rsp), %rax
movq 0x50(%rax), %rax
cmpq $0x0, 0x7b8(%rax)
jne 0x1bfdd
jmp 0x1bf2a
cmpq $0x0, 0x70(%rsp)
je 0x1bf44
movq 0x88(%rsp), %rdi
movq 0x70(%rsp), %rsi
callq 0x18300
cmpq $0x0, 0x68(%rsp)
je 0x1bf5e
movq 0x88(%rsp), %rdi
movq 0x68(%rsp), %rsi
callq 0x18300
cmpq $0x0, 0x60(%rsp)
je 0x1bf78
movq 0x88(%rsp), %rdi
movq 0x60(%rsp), %rsi
callq 0x18300
cmpq $0x0, 0x58(%rsp)
je 0x1bf92
movq 0x88(%rsp), %rdi
movq 0x58(%rsp), %rsi
callq 0x18300
jmp 0x1bf94
jmp 0x1bf96
movq 0x50(%rsp), %rax
movq 0x50(%rax), %rax
cmpq $0x0, 0x7b8(%rax)
jne 0x1bfcb
movq 0x88(%rsp), %rdi
leaq 0xb39b4(%rip), %rsi     # 0xcf96c
movb $0x0, %al
callq 0x19ce0
movl %eax, 0x94(%rsp)
jmp 0x1c3b4
jmp 0x1bfcd
movl $0x0, 0x94(%rsp)
jmp 0x1c3b4
movq 0x88(%rsp), %rdi
movl $0x5, %esi
leaq 0x7c(%rsp), %rdx
leaq 0x84(%rsp), %rcx
callq 0x19fb0
movq %rax, 0x60(%rsp)
cmpl $0x0, 0x84(%rsp)
jge 0x1c0b2
jmp 0x1c011
cmpq $0x0, 0x70(%rsp)
je 0x1c02b
movq 0x88(%rsp), %rdi
movq 0x70(%rsp), %rsi
callq 0x18300
cmpq $0x0, 0x68(%rsp)
je 0x1c045
movq 0x88(%rsp), %rdi
movq 0x68(%rsp), %rsi
callq 0x18300
cmpq $0x0, 0x60(%rsp)
je 0x1c05f
movq 0x88(%rsp), %rdi
movq 0x60(%rsp), %rsi
callq 0x18300
cmpq $0x0, 0x58(%rsp)
je 0x1c079
movq 0x88(%rsp), %rdi
movq 0x58(%rsp), %rsi
callq 0x18300
jmp 0x1c07b
movq 0x88(%rsp), %rax
movq %rax, 0x20(%rsp)
movl 0x84(%rsp), %edi
callq 0x19a60
movq 0x20(%rsp), %rdi
movq %rax, %rdx
movl $0x5, %esi
callq 0x18460
movl %eax, 0x94(%rsp)
jmp 0x1c3b4
cmpl $0x0, 0x7c(%rsp)
je 0x1c16f
movl 0x7c(%rsp), %eax
cmpl 0x80(%rsp), %eax
je 0x1c16f
jmp 0x1c0d0
cmpq $0x0, 0x70(%rsp)
je 0x1c0ea
movq 0x88(%rsp), %rdi
movq 0x70(%rsp), %rsi
callq 0x18300
cmpq $0x0, 0x68(%rsp)
je 0x1c104
movq 0x88(%rsp), %rdi
movq 0x68(%rsp), %rsi
callq 0x18300
cmpq $0x0, 0x60(%rsp)
je 0x1c11e
movq 0x88(%rsp), %rdi
movq 0x60(%rsp), %rsi
callq 0x18300
cmpq $0x0, 0x58(%rsp)
je 0x1c138
movq 0x88(%rsp), %rdi
movq 0x58(%rsp), %rsi
callq 0x18300
jmp 0x1c13a
movq 0x88(%rsp), %rax
movq %rax, 0x18(%rsp)
movl $0xfffffff9, %edi       # imm = 0xFFFFFFF9
callq 0x19a60
movq 0x18(%rsp), %rdi
movq %rax, %rdx
movl $0x5, %esi
callq 0x18460
movl %eax, 0x94(%rsp)
jmp 0x1c3b4
movq 0x88(%rsp), %rdi
movl $0x6, %esi
leaq 0x7c(%rsp), %rdx
leaq 0x84(%rsp), %rcx
callq 0x19fb0
movq %rax, 0x58(%rsp)
cmpl $0x0, 0x84(%rsp)
jge 0x1c244
jmp 0x1c1a3
cmpq $0x0, 0x70(%rsp)
je 0x1c1bd
movq 0x88(%rsp), %rdi
movq 0x70(%rsp), %rsi
callq 0x18300
cmpq $0x0, 0x68(%rsp)
je 0x1c1d7
movq 0x88(%rsp), %rdi
movq 0x68(%rsp), %rsi
callq 0x18300
cmpq $0x0, 0x60(%rsp)
je 0x1c1f1
movq 0x88(%rsp), %rdi
movq 0x60(%rsp), %rsi
callq 0x18300
cmpq $0x0, 0x58(%rsp)
je 0x1c20b
movq 0x88(%rsp), %rdi
movq 0x58(%rsp), %rsi
callq 0x18300
jmp 0x1c20d
movq 0x88(%rsp), %rax
movq %rax, 0x10(%rsp)
movl 0x84(%rsp), %edi
callq 0x19a60
movq 0x10(%rsp), %rdi
movq %rax, %rdx
movl $0x6, %esi
callq 0x18460
movl %eax, 0x94(%rsp)
jmp 0x1c3b4
cmpl $0x0, 0x7c(%rsp)
je 0x1c301
movl 0x7c(%rsp), %eax
cmpl 0x80(%rsp), %eax
je 0x1c301
jmp 0x1c262
cmpq $0x0, 0x70(%rsp)
je 0x1c27c
movq 0x88(%rsp), %rdi
movq 0x70(%rsp), %rsi
callq 0x18300
cmpq $0x0, 0x68(%rsp)
je 0x1c296
movq 0x88(%rsp), %rdi
movq 0x68(%rsp), %rsi
callq 0x18300
cmpq $0x0, 0x60(%rsp)
je 0x1c2b0
movq 0x88(%rsp), %rdi
movq 0x60(%rsp), %rsi
callq 0x18300
cmpq $0x0, 0x58(%rsp)
je 0x1c2ca
movq 0x88(%rsp), %rdi
movq 0x58(%rsp), %rsi
callq 0x18300
jmp 0x1c2cc
movq 0x88(%rsp), %rax
movq %rax, 0x8(%rsp)
movl $0xfffffff9, %edi       # imm = 0xFFFFFFF9
callq 0x19a60
movq 0x8(%rsp), %rdi
movq %rax, %rdx
movl $0x6, %esi
callq 0x18460
movl %eax, 0x94(%rsp)
jmp 0x1c3b4
movq 0x50(%rsp), %rax
movq 0x50(%rax), %rax
movq 0x7b8(%rax), %rax
movq 0x48(%rsp), %rdi
movl 0x44(%rsp), %esi
movl 0x80(%rsp), %edx
movq 0x70(%rsp), %rcx
movq 0x68(%rsp), %r8
movq 0x60(%rsp), %r9
movq 0x58(%rsp), %r10
movq %r10, (%rsp)
callq *%rax
jmp 0x1c33d
jmp 0x1c33f
cmpq $0x0, 0x70(%rsp)
je 0x1c359
movq 0x88(%rsp), %rdi
movq 0x70(%rsp), %rsi
callq 0x18300
cmpq $0x0, 0x68(%rsp)
je 0x1c373
movq 0x88(%rsp), %rdi
movq 0x68(%rsp), %rsi
callq 0x18300
cmpq $0x0, 0x60(%rsp)
je 0x1c38d
movq 0x88(%rsp), %rdi
movq 0x60(%rsp), %rsi
callq 0x18300
cmpq $0x0, 0x58(%rsp)
je 0x1c3a7
movq 0x88(%rsp), %rdi
movq 0x58(%rsp), %rsi
callq 0x18300
jmp 0x1c3a9
movl $0x0, 0x94(%rsp)
movl 0x94(%rsp), %eax
addq $0x98, %rsp
retq
nopw %cs:(%rax,%rax)