// File: stetre[P]moonvulkan/src/cmd.c
// Function: CmdCopyBuffer
static int CmdCopyBuffer(lua_State *L)
    {
    int err;
    uint32_t count;
    ud_t *ud;
    VkCommandBuffer cb = checkcommand_buffer(L, 1, &ud);
    if(ud->ddt->CmdCopyBuffer2KHR && lua_type(L, 2)==LUA_TTABLE)
        {
        VkCopyBufferInfo2KHR *info = zcheckVkCopyBufferInfo2KHR(L, 2, &err);
#define CLEANUP zfreeVkCopyBufferInfo2KHR(L, info, 1)
        if(err) { CLEANUP; return argerror(L, 2); }
        ud->ddt->CmdCopyBuffer2KHR(cb, info);
        CLEANUP;
#undef CLEANUP
        }
    else
        {
        VkBuffer srcBuffer = checkbuffer(L, 2, NULL);
        VkBuffer dstBuffer = checkbuffer(L, 3, NULL);
#define CLEANUP zfreearrayVkBufferCopy(L, regions, count, 1)
        VkBufferCopy* regions = zcheckarrayVkBufferCopy(L, 4, &count, &err);
        if(err) { CLEANUP; return argerror(L, 4); }
        ud->ddt->CmdCopyBuffer(cb, srcBuffer, dstBuffer, count, regions);
        CLEANUP;
#undef CLEANUP
        }
    return 0;
    }

// Assembly:
subq $0x58, %rsp
movq %rdi, 0x48(%rsp)
movq 0x48(%rsp), %rdi
movl $0x1, %esi
leaq 0x38(%rsp), %rdx
leaq 0xb310a(%rip), %rcx     # 0xcf909
callq 0x1a640
movq %rax, 0x30(%rsp)
movq 0x38(%rsp), %rax
movq 0x50(%rax), %rax
cmpq $0x0, 0x6a0(%rax)
je 0x1c8d9
movq 0x48(%rsp), %rdi
movl $0x2, %esi
callq 0x1a240
cmpl $0x5, %eax
jne 0x1c8d9
movq 0x48(%rsp), %rdi
movl $0x2, %esi
leaq 0x44(%rsp), %rdx
callq 0x1a160
movq %rax, 0x28(%rsp)
cmpl $0x0, 0x44(%rsp)
je 0x1c8a4
movq 0x48(%rsp), %rdi
movq 0x28(%rsp), %rsi
movl $0x1, %edx
callq 0x19210
movq 0x48(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x48(%rsp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %eax, %eax
movl %eax, %edx
callq 0x186d0
movq 0x8(%rsp), %rdi
movq %rax, %rdx
movl $0x2, %esi
callq 0x18460
movl %eax, 0x54(%rsp)
jmp 0x1c9e7
movq 0x38(%rsp), %rax
movq 0x50(%rax), %rax
movq 0x6a0(%rax), %rax
movq 0x30(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq *%rax
movq 0x48(%rsp), %rdi
movq 0x28(%rsp), %rsi
movl $0x1, %edx
callq 0x19210
jmp 0x1c9df
movq 0x48(%rsp), %rdi
movl $0x2, %esi
xorl %eax, %eax
movl %eax, %edx
leaq 0xb2712(%rip), %rcx     # 0xcf000
callq 0x1a640
movq %rax, 0x20(%rsp)
movq 0x48(%rsp), %rdi
movl $0x3, %esi
xorl %eax, %eax
movl %eax, %edx
leaq 0xb26f3(%rip), %rcx     # 0xcf000
callq 0x1a640
movq %rax, 0x18(%rsp)
movq 0x48(%rsp), %rdi
movl $0x4, %esi
leaq 0x40(%rsp), %rdx
leaq 0x44(%rsp), %rcx
callq 0x1a320
movq %rax, 0x10(%rsp)
cmpl $0x0, 0x44(%rsp)
je 0x1c992
movq 0x48(%rsp), %rdi
movq 0x10(%rsp), %rsi
movl 0x40(%rsp), %ecx
movl $0x18, %edx
movl $0x1, %r8d
xorl %eax, %eax
movl %eax, %r9d
callq 0x18dd0
movq 0x48(%rsp), %rax
movq %rax, (%rsp)
movq 0x48(%rsp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %eax, %eax
movl %eax, %edx
callq 0x186d0
movq (%rsp), %rdi
movq %rax, %rdx
movl $0x4, %esi
callq 0x18460
movl %eax, 0x54(%rsp)
jmp 0x1c9e7
movq 0x38(%rsp), %rax
movq 0x50(%rax), %rax
movq 0x368(%rax), %rax
movq 0x30(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq 0x18(%rsp), %rdx
movl 0x40(%rsp), %ecx
movq 0x10(%rsp), %r8
callq *%rax
movq 0x48(%rsp), %rdi
movq 0x10(%rsp), %rsi
movl 0x40(%rsp), %ecx
movl $0x18, %edx
movl $0x1, %r8d
xorl %eax, %eax
movl %eax, %r9d
callq 0x18dd0
movl $0x0, 0x54(%rsp)
movl 0x54(%rsp), %eax
addq $0x58, %rsp
retq