// File: stetre[P]moonvulkan/src/cmd.c
// Function: CmdResolveImage
static int CmdResolveImage(lua_State *L)
    {
    int err;
    uint32_t count;
    ud_t *ud;
    VkCommandBuffer cb = checkcommand_buffer(L, 1, &ud);
    if(ud->ddt->CmdResolveImage2KHR && lua_type(L, 2)==LUA_TTABLE)
        {
        VkResolveImageInfo2KHR *info = zcheckVkResolveImageInfo2KHR(L, 2, &err);
#define CLEANUP zfreeVkResolveImageInfo2KHR(L, info, 1)
        if(err) { CLEANUP; return argerror(L, 2); }
        ud->ddt->CmdResolveImage2KHR(cb, info);
        CLEANUP;
#undef CLEANUP
        }
    else
        {
        VkImage srcImage = checkimage(L, 2, NULL);
        VkImageLayout srcImageLayout = checkimagelayout(L, 3);
        VkImage dstImage = checkimage(L, 4, NULL);
        VkImageLayout dstImageLayout = checkimagelayout(L, 5);
#define CLEANUP zfreearrayVkImageResolve(L, regions, count, 1)
        VkImageResolve* regions = zcheckarrayVkImageResolve(L, 6, &count, &err);
        if(err) { CLEANUP; return argerror(L, 6); }
        ud->ddt->CmdResolveImage(cb, srcImage, srcImageLayout, dstImage, dstImageLayout, count, regions);
        CLEANUP;
#undef CLEANUP
        }
    return 0;
    }

// Assembly:
subq $0x78, %rsp
movq %rdi, 0x68(%rsp)
movq 0x68(%rsp), %rdi
movl $0x1, %esi
leaq 0x58(%rsp), %rdx
leaq 0xb1e4a(%rip), %rcx     # 0xcf909
callq 0x1a640
movq %rax, 0x50(%rsp)
movq 0x58(%rsp), %rax
movq 0x50(%rax), %rax
cmpq $0x0, 0x6c8(%rax)
je 0x1db99
movq 0x68(%rsp), %rdi
movl $0x2, %esi
callq 0x1a240
cmpl $0x5, %eax
jne 0x1db99
movq 0x68(%rsp), %rdi
movl $0x2, %esi
leaq 0x64(%rsp), %rdx
callq 0x193c0
movq %rax, 0x48(%rsp)
cmpl $0x0, 0x64(%rsp)
je 0x1db64
movq 0x68(%rsp), %rdi
movq 0x48(%rsp), %rsi
movl $0x1, %edx
callq 0x19210
movq 0x68(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x68(%rsp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %eax, %eax
movl %eax, %edx
callq 0x186d0
movq 0x18(%rsp), %rdi
movq %rax, %rdx
movl $0x2, %esi
callq 0x18460
movl %eax, 0x74(%rsp)
jmp 0x1dce7
movq 0x58(%rsp), %rax
movq 0x50(%rax), %rax
movq 0x6c8(%rax), %rax
movq 0x50(%rsp), %rdi
movq 0x48(%rsp), %rsi
callq *%rax
movq 0x68(%rsp), %rdi
movq 0x48(%rsp), %rsi
movl $0x1, %edx
callq 0x19210
jmp 0x1dcdf
movq 0x68(%rsp), %rdi
movl $0x2, %esi
xorl %eax, %eax
movl %eax, %edx
leaq 0xb1dec(%rip), %rcx     # 0xcf99a
callq 0x1a640
movq %rax, 0x40(%rsp)
movq 0x68(%rsp), %rdi
movl $0xa, %esi
movl $0x3, %edx
callq 0x19d20
movl %eax, 0x3c(%rsp)
movq 0x68(%rsp), %rdi
movl $0x4, %esi
xorl %eax, %eax
movl %eax, %edx
leaq 0xb1db5(%rip), %rcx     # 0xcf99a
callq 0x1a640
movq %rax, 0x30(%rsp)
movq 0x68(%rsp), %rdi
movl $0xa, %esi
movl $0x5, %edx
callq 0x19d20
movl %eax, 0x2c(%rsp)
movq 0x68(%rsp), %rdi
movl $0x6, %esi
leaq 0x60(%rsp), %rdx
leaq 0x64(%rsp), %rcx
callq 0x18c30
movq %rax, 0x20(%rsp)
cmpl $0x0, 0x64(%rsp)
je 0x1dc84
movq 0x68(%rsp), %rdi
movq 0x20(%rsp), %rsi
movl 0x60(%rsp), %ecx
movl $0x44, %edx
movl $0x1, %r8d
xorl %eax, %eax
movl %eax, %r9d
callq 0x18dd0
movq 0x68(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x68(%rsp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %eax, %eax
movl %eax, %edx
callq 0x186d0
movq 0x10(%rsp), %rdi
movq %rax, %rdx
movl $0x6, %esi
callq 0x18460
movl %eax, 0x74(%rsp)
jmp 0x1dce7
movq 0x58(%rsp), %rax
movq 0x50(%rax), %rax
movq 0x3b8(%rax), %rax
movq 0x50(%rsp), %rdi
movq 0x40(%rsp), %rsi
movl 0x3c(%rsp), %edx
movq 0x30(%rsp), %rcx
movl 0x2c(%rsp), %r8d
movl 0x60(%rsp), %r9d
movq 0x20(%rsp), %r10
movq %r10, (%rsp)
callq *%rax
movq 0x68(%rsp), %rdi
movq 0x20(%rsp), %rsi
movl 0x60(%rsp), %ecx
movl $0x44, %edx
movl $0x1, %r8d
xorl %eax, %eax
movl %eax, %r9d
callq 0x18dd0
movl $0x0, 0x74(%rsp)
movl 0x74(%rsp), %eax
addq $0x78, %rsp
retq