// File: /workspace/github_cpp_makefile_star2_O1/stetre[P]moonvulkan/src/layers.c
// Function: EnumerateDeviceLayerProperties
static int EnumerateDeviceLayerProperties(lua_State *L) /* DEPRECATED */
    {
    int err;
    uint32_t count, remaining, tot, i;
    VkResult ec;
    ud_t *ud;
    VkLayerProperties* properties;//[N];
    VkPhysicalDevice physical_device = checkphysical_device(L, 1, &ud);
    int byname = optboolean(L, 2, 0);

#define CLEANUP zfreearrayVkLayerProperties(L, properties, N, 1) 
    properties = znewarrayVkLayerProperties(L, N, &err);
    if(err) { CLEANUP; lua_error(L); }
    lua_newtable(L);
    ec = ud->idt->EnumerateDeviceLayerProperties(physical_device, &remaining, NULL);
    if(ec) { CLEANUP; CheckError(L, ec); }
    if(remaining==0) { CLEANUP; return 1; }

    tot = 0;
    do {
        if(remaining > N)
            { count = N; remaining -= N; }
        else
            { count = remaining; remaining = 0; }

        ec = ud->idt->EnumerateDeviceLayerProperties(physical_device, &count, properties);
        if(ec && ec!=VK_INCOMPLETE) { CLEANUP; CheckError(L, ec); }
    
        if(byname)
            {
            for(i = 0; i < count; i++)
                {
                lua_pushstring(L, properties[i].layerName);
                zpushVkLayerProperties(L, &properties[i]);
                lua_rawset(L, -3);
                }
            }
        else
            {
            for(i = 0; i < count; i++)
                {
                zpushVkLayerProperties(L, &properties[i]);
                lua_rawseti(L, -2, ++tot);
                }
            }
    } while (remaining > 0);

    CLEANUP;
#undef CLEANUP
    return 1;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
leaq 0x4a991(%rip), %rcx     # 0x90ef4
leaq 0x10(%rsp), %rdx
movl $0x1, %esi
callq 0x1a520
movq %rax, %r15
movq %rbx, %rdi
movl $0x2, %esi
xorl %edx, %edx
callq 0x197e0
movl %eax, %ebp
leaq 0x24(%rsp), %r12
movl $0x208, %edx            # imm = 0x208
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0x20, %ecx
movq %r12, %r8
callq 0x19840
movq %rax, %r14
cmpl $0x0, (%r12)
je 0x465d5
movl $0x208, %edx            # imm = 0x208
movq %rbx, %rdi
movq %r14, %rsi
movl $0x20, %ecx
movl $0x1, %r8d
xorl %r9d, %r9d
callq 0x18d40
movq %rbx, %rdi
callq 0x199e0
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x187e0
movq 0x10(%rsp), %rax
movq 0x48(%rax), %rax
leaq 0x4(%rsp), %rsi
movq %r15, %rdi
xorl %edx, %edx
callq *0x10(%rax)
testl %eax, %eax
je 0x46638
movl %eax, %r12d
movl $0x208, %edx            # imm = 0x208
movq %rbx, %rdi
movq %r14, %rsi
movl $0x20, %ecx
movl $0x1, %r8d
xorl %r9d, %r9d
callq 0x18d40
movq %rbx, %rdi
xorl %esi, %esi
movl %r12d, %edx
callq 0x18990
movq %rbx, %rdi
callq 0x199e0
movl %eax, %ebp
jmp 0x46763
cmpl $0x0, 0x4(%rsp)
je 0x46740
movq $0x0, 0x8(%rsp)
movq %r15, 0x18(%rsp)
movl 0x4(%rsp), %eax
cmpl $0x21, %eax
jb 0x46666
movl $0x20, (%rsp)
addl $-0x20, %eax
jmp 0x4666b
movl %eax, (%rsp)
xorl %eax, %eax
movl %eax, 0x4(%rsp)
movq 0x10(%rsp), %rax
movq 0x48(%rax), %rax
movq %r15, %rdi
movq %rsp, %rsi
movq %r14, %rdx
callq *0x10(%rax)
testl %eax, %eax
je 0x46694
movl %eax, %r13d
cmpl $0x5, %eax
jne 0x46774
movl (%rsp), %eax
testl %ebp, %ebp
je 0x466e0
testl %eax, %eax
je 0x46735
movq %r14, %r13
xorl %r12d, %r12d
movq %rbx, %rdi
movq %r13, %rsi
callq 0x1a300
movq %rbx, %rdi
movq %r13, %rsi
callq 0x18df0
movq %rbx, %rdi
movl $0xfffffffd, %esi       # imm = 0xFFFFFFFD
callq 0x18810
incq %r12
movl (%rsp), %eax
addq $0x208, %r13            # imm = 0x208
cmpq %rax, %r12
jb 0x466a9
jmp 0x46735
testl %eax, %eax
je 0x46735
movl %ebp, %r15d
movl 0x8(%rsp), %r12d
movq %r14, %r13
xorl %ebp, %ebp
movq %rbx, %rdi
movq %r13, %rsi
callq 0x18df0
leal (%r12,%rbp), %edx
incl %edx
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x19140
incq %rbp
movl (%rsp), %eax
addq $0x208, %r13            # imm = 0x208
cmpq %rax, %rbp
jb 0x466f1
movq 0x8(%rsp), %rax
addl %ebp, %eax
movq %rax, 0x8(%rsp)
movl %r15d, %ebp
movq 0x18(%rsp), %r15
cmpl $0x0, 0x4(%rsp)
jne 0x46651
movl $0x1, %ebp
movl $0x208, %edx            # imm = 0x208
movq %rbx, %rdi
movq %r14, %rsi
movl $0x20, %ecx
movl $0x1, %r8d
xorl %r9d, %r9d
callq 0x18d40
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x208, %edx            # imm = 0x208
movq %rbx, %rdi
movq %r14, %rsi
movl $0x20, %ecx
movl $0x1, %r8d
xorl %r9d, %r9d
callq 0x18d40
movq %rbx, %rdi
xorl %esi, %esi
movl %r13d, %edx
jmp 0x46624
nop