// File: stetre[P]moonvulkan/src/pipeline.c
// Function: GetPipelineExecutableProperties
static int GetPipelineExecutableProperties(lua_State *L)
    {
    ud_t *ud;
    int err;
    VkResult ec;
    uint32_t count, remaining, tot, i;
    VkPipelineInfoKHR* info=NULL;
    VkPipelineExecutablePropertiesKHR* properties = NULL; //[N]
    VkPipeline pipeline = checkpipeline(L, 1, &ud);
    CheckDevicePfn(L, ud, GetPipelineExecutablePropertiesKHR);
#define CLEANUP do {                                                    \
    zfreeVkPipelineInfoKHR(L, info, 1);                                 \
    zfreearrayVkPipelineExecutablePropertiesKHR(L, properties, N, 1);   \
} while(0)
    if(lua_istable(L, 2))
        {
        info = zcheckVkPipelineInfoKHR(L, 2, &err);
        if(err) { CLEANUP; return argerror(L, 2); }
        }
    else
        {
        info = znewVkPipelineInfoKHR(L, &err);
        if(err) { CLEANUP; return lua_error(L); }
        }
    info->pipeline = pipeline;
    properties = znewchainarrayVkPipelineExecutablePropertiesKHR(L, N, &err);
    if(err) { CLEANUP; lua_error(L); }
    ec = ud->ddt->GetPipelineExecutablePropertiesKHR(ud->device, info, &remaining, NULL);
    if(ec) { CLEANUP; CheckError(L, ec); }
    lua_newtable(L);
    if(remaining==0) { CLEANUP; return 1; }
    tot = 0;
    do {
        if(remaining > N)
            { count = N; remaining -= N; }
        else
            { count = remaining; remaining = 0; }
        ec = ud->ddt->GetPipelineExecutablePropertiesKHR(ud->device, info, &count, properties);
        if(ec && ec != VK_INCOMPLETE) { CLEANUP; CheckError(L, ec); }
        for(i = 0; i < count; i++)
            {
            zpushVkPipelineExecutablePropertiesKHR(L, &properties[i]);
            lua_rawseti(L, -2, ++tot);
            }
        } while (remaining > 0);
    CLEANUP;
#undef CLEANUP
    return 1;
    }

// Assembly:
subq $0x58, %rsp
movq %rdi, 0x48(%rsp)
movq $0x0, 0x20(%rsp)
movq $0x0, 0x18(%rsp)
movq 0x48(%rsp), %rdi
movl $0x1, %esi
leaq 0x40(%rsp), %rdx
leaq 0x71792(%rip), %rcx     # 0xcf923
callq 0x1a640
movq %rax, 0x10(%rsp)
movq 0x40(%rsp), %rax
movq 0x50(%rax), %rax
cmpq $0x0, 0x658(%rax)
jne 0x5e1ca
movq 0x48(%rsp), %rdi
leaq 0x84a67(%rip), %rsi     # 0xe2c21
movb $0x0, %al
callq 0x19ce0
movl %eax, 0x54(%rsp)
jmp 0x5e5b6
jmp 0x5e1cc
movq 0x48(%rsp), %rdi
movl $0x2, %esi
callq 0x1a240
cmpl $0x5, %eax
jne 0x5e273
movq 0x48(%rsp), %rdi
movl $0x2, %esi
leaq 0x3c(%rsp), %rdx
callq 0x18e50
movq %rax, 0x20(%rsp)
cmpl $0x0, 0x3c(%rsp)
je 0x5e271
jmp 0x5e206
movq 0x48(%rsp), %rdi
movq 0x20(%rsp), %rsi
movl $0x1, %edx
callq 0x19210
movq 0x48(%rsp), %rdi
movq 0x18(%rsp), %rsi
movl $0x218, %edx            # imm = 0x218
movl $0x20, %ecx
movl $0x1, %r8d
callq 0x198d0
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 0x5e5b6
jmp 0x5e2e2
movq 0x48(%rsp), %rdi
movl $0x3b9ee4c9, %esi       # imm = 0x3B9EE4C9
movl $0x18, %edx
leaq 0x3c(%rsp), %rcx
callq 0x19ee0
movq %rax, 0x20(%rsp)
cmpl $0x0, 0x3c(%rsp)
je 0x5e2e0
jmp 0x5e29a
movq 0x48(%rsp), %rdi
movq 0x20(%rsp), %rsi
movl $0x1, %edx
callq 0x19210
movq 0x48(%rsp), %rdi
movq 0x18(%rsp), %rsi
movl $0x218, %edx            # imm = 0x218
movl $0x20, %ecx
movl $0x1, %r8d
callq 0x198d0
movq 0x48(%rsp), %rdi
callq 0x19ad0
movl %eax, 0x54(%rsp)
jmp 0x5e5b6
jmp 0x5e2e2
movq 0x10(%rsp), %rcx
movq 0x20(%rsp), %rax
movq %rcx, 0x10(%rax)
movq 0x48(%rsp), %rdi
movl $0x20, %esi
leaq 0x3c(%rsp), %rdx
callq 0x18490
movq %rax, 0x18(%rsp)
cmpl $0x0, 0x3c(%rsp)
je 0x5e34f
jmp 0x5e312
movq 0x48(%rsp), %rdi
movq 0x20(%rsp), %rsi
movl $0x1, %edx
callq 0x19210
movq 0x48(%rsp), %rdi
movq 0x18(%rsp), %rsi
movl $0x218, %edx            # imm = 0x218
movl $0x20, %ecx
movl $0x1, %r8d
callq 0x198d0
movq 0x48(%rsp), %rdi
callq 0x19ad0
movq 0x40(%rsp), %rax
movq 0x50(%rax), %rax
movq 0x658(%rax), %rax
movq 0x40(%rsp), %rcx
movq 0x20(%rcx), %rdi
movq 0x20(%rsp), %rsi
leaq 0x30(%rsp), %rdx
xorl %ecx, %ecx
callq *%rax
movl %eax, 0x38(%rsp)
cmpl $0x0, 0x38(%rsp)
je 0x5e3e6
jmp 0x5e383
movq 0x48(%rsp), %rdi
movq 0x20(%rsp), %rsi
movl $0x1, %edx
callq 0x19210
movq 0x48(%rsp), %rdi
movq 0x18(%rsp), %rsi
movl $0x218, %edx            # imm = 0x218
movl $0x20, %ecx
movl $0x1, %r8d
callq 0x198d0
jmp 0x5e3b8
cmpl $0x0, 0x38(%rsp)
je 0x5e3e2
movq 0x48(%rsp), %rdi
movl 0x38(%rsp), %edx
xorl %esi, %esi
callq 0x18a00
movq 0x48(%rsp), %rdi
callq 0x19ad0
movl %eax, 0x54(%rsp)
jmp 0x5e5b6
jmp 0x5e3e4
jmp 0x5e3e6
movq 0x48(%rsp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x18830
cmpl $0x0, 0x30(%rsp)
jne 0x5e43d
jmp 0x5e3fd
movq 0x48(%rsp), %rdi
movq 0x20(%rsp), %rsi
movl $0x1, %edx
callq 0x19210
movq 0x48(%rsp), %rdi
movq 0x18(%rsp), %rsi
movl $0x218, %edx            # imm = 0x218
movl $0x20, %ecx
movl $0x1, %r8d
callq 0x198d0
movl $0x1, 0x54(%rsp)
jmp 0x5e5b6
movl $0x0, 0x2c(%rsp)
cmpl $0x20, 0x30(%rsp)
jbe 0x5e461
movl $0x20, 0x34(%rsp)
movl 0x30(%rsp), %eax
subl $0x20, %eax
movl %eax, 0x30(%rsp)
jmp 0x5e471
movl 0x30(%rsp), %eax
movl %eax, 0x34(%rsp)
movl $0x0, 0x30(%rsp)
movq 0x40(%rsp), %rax
movq 0x50(%rax), %rax
movq 0x658(%rax), %rax
movq 0x40(%rsp), %rcx
movq 0x20(%rcx), %rdi
movq 0x20(%rsp), %rsi
movq 0x18(%rsp), %rcx
leaq 0x34(%rsp), %rdx
callq *%rax
movl %eax, 0x38(%rsp)
cmpl $0x0, 0x38(%rsp)
je 0x5e512
cmpl $0x5, 0x38(%rsp)
je 0x5e512
jmp 0x5e4af
movq 0x48(%rsp), %rdi
movq 0x20(%rsp), %rsi
movl $0x1, %edx
callq 0x19210
movq 0x48(%rsp), %rdi
movq 0x18(%rsp), %rsi
movl $0x218, %edx            # imm = 0x218
movl $0x20, %ecx
movl $0x1, %r8d
callq 0x198d0
jmp 0x5e4e4
cmpl $0x0, 0x38(%rsp)
je 0x5e50e
movq 0x48(%rsp), %rdi
movl 0x38(%rsp), %edx
xorl %esi, %esi
callq 0x18a00
movq 0x48(%rsp), %rdi
callq 0x19ad0
movl %eax, 0x54(%rsp)
jmp 0x5e5b6
jmp 0x5e510
jmp 0x5e512
movl $0x0, 0x28(%rsp)
movl 0x28(%rsp), %eax
cmpl 0x34(%rsp), %eax
jae 0x5e56c
movq 0x48(%rsp), %rdi
movq 0x18(%rsp), %rsi
movl 0x28(%rsp), %eax
imulq $0x218, %rax, %rax      # imm = 0x218
addq %rax, %rsi
callq 0x183a0
movq 0x48(%rsp), %rdi
movl 0x2c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2c(%rsp)
movl %eax, %eax
movl %eax, %edx
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x191e0
movl 0x28(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x28(%rsp)
jmp 0x5e51a
jmp 0x5e56e
cmpl $0x0, 0x30(%rsp)
ja 0x5e445
jmp 0x5e57b
movq 0x48(%rsp), %rdi
movq 0x20(%rsp), %rsi
movl $0x1, %edx
callq 0x19210
movq 0x48(%rsp), %rdi
movq 0x18(%rsp), %rsi
movl $0x218, %edx            # imm = 0x218
movl $0x20, %ecx
movl $0x1, %r8d
callq 0x198d0
movl $0x1, 0x54(%rsp)
movl 0x54(%rsp), %eax
addq $0x58, %rsp
retq
nop