// File: stetre[P]moonvulkan/src/pipeline.c
// Function: GetPipelineExecutableStatistics
static int GetPipelineExecutableStatistics(lua_State *L)
    {
    ud_t *ud;
    int err;
    VkResult ec;
    uint32_t count, remaining, tot, i;
    VkPipelineExecutableInfoKHR* info=NULL;
    VkPipelineExecutableStatisticKHR* statistics = NULL; //[N]
    VkPipeline pipeline = checkpipeline(L, 1, &ud);
    CheckDevicePfn(L, ud, GetPipelineExecutableStatisticsKHR);
#define CLEANUP do {                                                    \
    zfreeVkPipelineExecutableInfoKHR(L, info, 1);                       \
    zfreearrayVkPipelineExecutableStatisticKHR(L, statistics, N, 1);    \
} while(0)
    info = zcheckVkPipelineExecutableInfoKHR(L, 2, &err);
    info->pipeline = pipeline;
    statistics = znewchainarrayVkPipelineExecutableStatisticKHR(L, N, &err);
    if(err) { CLEANUP; lua_error(L); }
    ec = ud->ddt->GetPipelineExecutableStatisticsKHR(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->GetPipelineExecutableStatisticsKHR(ud->device, info, &count, statistics);
        if(ec && ec != VK_INCOMPLETE) { CLEANUP; CheckError(L, ec); }
        for(i = 0; i < count; i++)
            {
            zpushVkPipelineExecutableStatisticKHR(L, &statistics[i]);
            lua_rawseti(L, -2, ++tot);
            }
        } while (remaining > 0);
    CLEANUP;
#undef CLEANUP
    return 1;
    }

// Assembly:
subq $0x48, %rsp
movq %rdi, 0x38(%rsp)
movq $0x0, 0x10(%rsp)
movq $0x0, 0x8(%rsp)
movq 0x38(%rsp), %rdi
movl $0x1, %esi
leaq 0x30(%rsp), %rdx
leaq 0x71332(%rip), %rcx     # 0xcf923
callq 0x1a640
movq %rax, (%rsp)
movq 0x30(%rsp), %rax
movq 0x50(%rax), %rax
cmpq $0x0, 0x660(%rax)
jne 0x5e629
movq 0x38(%rsp), %rdi
leaq 0x84640(%rip), %rsi     # 0xe2c59
movb $0x0, %al
callq 0x19ce0
movl %eax, 0x44(%rsp)
jmp 0x5e917
jmp 0x5e62b
movq 0x38(%rsp), %rdi
movl $0x2, %esi
leaq 0x2c(%rsp), %rdx
callq 0x1a430
movq %rax, 0x10(%rsp)
movq (%rsp), %rcx
movq 0x10(%rsp), %rax
movq %rcx, 0x10(%rax)
movq 0x38(%rsp), %rdi
movl $0x20, %esi
leaq 0x2c(%rsp), %rdx
callq 0x19dd0
movq %rax, 0x8(%rsp)
cmpl $0x0, 0x2c(%rsp)
je 0x5e6b0
jmp 0x5e673
movq 0x38(%rsp), %rdi
movq 0x10(%rsp), %rsi
movl $0x1, %edx
callq 0x19210
movq 0x38(%rsp), %rdi
movq 0x8(%rsp), %rsi
movl $0x220, %edx            # imm = 0x220
movl $0x20, %ecx
movl $0x1, %r8d
callq 0x198d0
movq 0x38(%rsp), %rdi
callq 0x19ad0
movq 0x30(%rsp), %rax
movq 0x50(%rax), %rax
movq 0x660(%rax), %rax
movq 0x30(%rsp), %rcx
movq 0x20(%rcx), %rdi
movq 0x10(%rsp), %rsi
leaq 0x20(%rsp), %rdx
xorl %ecx, %ecx
callq *%rax
movl %eax, 0x28(%rsp)
cmpl $0x0, 0x28(%rsp)
je 0x5e747
jmp 0x5e6e4
movq 0x38(%rsp), %rdi
movq 0x10(%rsp), %rsi
movl $0x1, %edx
callq 0x19210
movq 0x38(%rsp), %rdi
movq 0x8(%rsp), %rsi
movl $0x220, %edx            # imm = 0x220
movl $0x20, %ecx
movl $0x1, %r8d
callq 0x198d0
jmp 0x5e719
cmpl $0x0, 0x28(%rsp)
je 0x5e743
movq 0x38(%rsp), %rdi
movl 0x28(%rsp), %edx
xorl %esi, %esi
callq 0x18a00
movq 0x38(%rsp), %rdi
callq 0x19ad0
movl %eax, 0x44(%rsp)
jmp 0x5e917
jmp 0x5e745
jmp 0x5e747
movq 0x38(%rsp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x18830
cmpl $0x0, 0x20(%rsp)
jne 0x5e79e
jmp 0x5e75e
movq 0x38(%rsp), %rdi
movq 0x10(%rsp), %rsi
movl $0x1, %edx
callq 0x19210
movq 0x38(%rsp), %rdi
movq 0x8(%rsp), %rsi
movl $0x220, %edx            # imm = 0x220
movl $0x20, %ecx
movl $0x1, %r8d
callq 0x198d0
movl $0x1, 0x44(%rsp)
jmp 0x5e917
movl $0x0, 0x1c(%rsp)
cmpl $0x20, 0x20(%rsp)
jbe 0x5e7c2
movl $0x20, 0x24(%rsp)
movl 0x20(%rsp), %eax
subl $0x20, %eax
movl %eax, 0x20(%rsp)
jmp 0x5e7d2
movl 0x20(%rsp), %eax
movl %eax, 0x24(%rsp)
movl $0x0, 0x20(%rsp)
movq 0x30(%rsp), %rax
movq 0x50(%rax), %rax
movq 0x660(%rax), %rax
movq 0x30(%rsp), %rcx
movq 0x20(%rcx), %rdi
movq 0x10(%rsp), %rsi
movq 0x8(%rsp), %rcx
leaq 0x24(%rsp), %rdx
callq *%rax
movl %eax, 0x28(%rsp)
cmpl $0x0, 0x28(%rsp)
je 0x5e873
cmpl $0x5, 0x28(%rsp)
je 0x5e873
jmp 0x5e810
movq 0x38(%rsp), %rdi
movq 0x10(%rsp), %rsi
movl $0x1, %edx
callq 0x19210
movq 0x38(%rsp), %rdi
movq 0x8(%rsp), %rsi
movl $0x220, %edx            # imm = 0x220
movl $0x20, %ecx
movl $0x1, %r8d
callq 0x198d0
jmp 0x5e845
cmpl $0x0, 0x28(%rsp)
je 0x5e86f
movq 0x38(%rsp), %rdi
movl 0x28(%rsp), %edx
xorl %esi, %esi
callq 0x18a00
movq 0x38(%rsp), %rdi
callq 0x19ad0
movl %eax, 0x44(%rsp)
jmp 0x5e917
jmp 0x5e871
jmp 0x5e873
movl $0x0, 0x18(%rsp)
movl 0x18(%rsp), %eax
cmpl 0x24(%rsp), %eax
jae 0x5e8cd
movq 0x38(%rsp), %rdi
movq 0x8(%rsp), %rsi
movl 0x18(%rsp), %eax
imulq $0x220, %rax, %rax      # imm = 0x220
addq %rax, %rsi
callq 0x1a1c0
movq 0x38(%rsp), %rdi
movl 0x1c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1c(%rsp)
movl %eax, %eax
movl %eax, %edx
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x191e0
movl 0x18(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x18(%rsp)
jmp 0x5e87b
jmp 0x5e8cf
cmpl $0x0, 0x20(%rsp)
ja 0x5e7a6
jmp 0x5e8dc
movq 0x38(%rsp), %rdi
movq 0x10(%rsp), %rsi
movl $0x1, %edx
callq 0x19210
movq 0x38(%rsp), %rdi
movq 0x8(%rsp), %rsi
movl $0x220, %edx            # imm = 0x220
movl $0x20, %ecx
movl $0x1, %r8d
callq 0x198d0
movl $0x1, 0x44(%rsp)
movl 0x44(%rsp), %eax
addq $0x48, %rsp
retq