// File: stetre[P]moonvulkan/src/descriptor_set.c
// Function: FreeDescriptorSets
static int FreeDescriptorSets(lua_State *L)
    {
    ud_t **ud;
    int err, free_allowed;
    VkResult ec;
    uint32_t i, count;
    VkDescriptorPool descriptor_pool;
    VkDescriptorSet *descriptor_set = checkdescriptor_setlist(L, 1, &count, &err, &ud);
    if(err) return argerrorc(L, 1, err);
    free_allowed = IsFreeDescriptorSetAllowed(ud[1]->parent_ud);
#define CLEANUP do {  Free(L, descriptor_set); Free(L, ud); } while(0)
    /* check that they all are from the same pool */
    for(i = 1; i < count; i++)
        {
        if(ud[i]->parent_ud != ud[0]->parent_ud)
            { CLEANUP; return argerrorc(L, 1, ERR_POOL); }
        }

    descriptor_pool = (VkDescriptorPool)ud[0]->parent_ud->handle;
    for(i = 0; i < count; i++)
        {
        freeuserdata(L, ud[i]);
        TRACE_DELETE(descriptor_set[i], "descriptor_set");
        }

    if(!free_allowed)
        { CLEANUP; return argerrorc(L, 1, ERR_POOL); }

    ec = ud[0]->ddt->FreeDescriptorSets(ud[0]->device, descriptor_pool, count, descriptor_set);
    CLEANUP;
    CheckError(L, ec);
    return 0;
#undef CLEANUP
    }

// Assembly:
subq $0x58, %rsp
movq %rdi, 0x48(%rsp)
movq 0x48(%rsp), %rdi
movl $0x1, %esi
leaq 0x2c(%rsp), %rdx
leaq 0x3c(%rsp), %rcx
leaq 0x40(%rsp), %r8
leaq 0xa7c29(%rip), %r9      # 0xcf952
callq 0x191f0
movq %rax, 0x18(%rsp)
cmpl $0x0, 0x3c(%rsp)
je 0x27d68
movq 0x48(%rsp), %rax
movq %rax, 0x10(%rsp)
movl 0x3c(%rsp), %edi
callq 0x19a60
movq 0x10(%rsp), %rdi
movq %rax, %rdx
movl $0x1, %esi
callq 0x18460
movl %eax, 0x54(%rsp)
jmp 0x27f6d
movq 0x40(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rax
movl 0x28(%rax), %eax
andl $0x8, %eax
cmpl $0x8, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x38(%rsp)
movl $0x1, 0x30(%rsp)
movl 0x30(%rsp), %eax
cmpl 0x2c(%rsp), %eax
jae 0x27e20
movq 0x40(%rsp), %rax
movl 0x30(%rsp), %ecx
movq (%rax,%rcx,8), %rax
movq 0x10(%rax), %rax
movq 0x40(%rsp), %rcx
movq (%rcx), %rcx
cmpq 0x10(%rcx), %rax
je 0x27e0e
jmp 0x27dc1
movq 0x48(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0x18300
movq 0x48(%rsp), %rdi
movq 0x40(%rsp), %rsi
callq 0x18300
movq 0x48(%rsp), %rax
movq %rax, 0x8(%rsp)
movl $0xfffffff8, %edi       # imm = 0xFFFFFFF8
callq 0x19a60
movq 0x8(%rsp), %rdi
movq %rax, %rdx
movl $0x1, %esi
callq 0x18460
movl %eax, 0x54(%rsp)
jmp 0x27f6d
jmp 0x27e10
movl 0x30(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x30(%rsp)
jmp 0x27d92
movq 0x40(%rsp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movq (%rax), %rax
movq %rax, 0x20(%rsp)
movl $0x0, 0x30(%rsp)
movl 0x30(%rsp), %eax
cmpl 0x2c(%rsp), %eax
jae 0x27e95
movq 0x48(%rsp), %rdi
movq 0x40(%rsp), %rax
movl 0x30(%rsp), %ecx
movq (%rax,%rcx,8), %rsi
callq 0x18dc0
movq 0xd5134(%rip), %rax     # 0xfcf98
cmpl $0x0, (%rax)
je 0x27e84
movq 0x18(%rsp), %rax
movl 0x30(%rsp), %ecx
movq (%rax,%rcx,8), %rsi
leaq 0xa8d80(%rip), %rdi     # 0xd0bfd
movb $0x0, %al
callq 0x189d0
jmp 0x27e86
jmp 0x27e88
movl 0x30(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x30(%rsp)
jmp 0x27e3c
cmpl $0x0, 0x38(%rsp)
jne 0x27ee9
jmp 0x27e9e
movq 0x48(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0x18300
movq 0x48(%rsp), %rdi
movq 0x40(%rsp), %rsi
callq 0x18300
movq 0x48(%rsp), %rax
movq %rax, (%rsp)
movl $0xfffffff8, %edi       # imm = 0xFFFFFFF8
callq 0x19a60
movq (%rsp), %rdi
movq %rax, %rdx
movl $0x1, %esi
callq 0x18460
movl %eax, 0x54(%rsp)
jmp 0x27f6d
movq 0x40(%rsp), %rax
movq (%rax), %rax
movq 0x50(%rax), %rax
movq 0x1e8(%rax), %rax
movq 0x40(%rsp), %rcx
movq (%rcx), %rcx
movq 0x20(%rcx), %rdi
movq 0x20(%rsp), %rsi
movl 0x2c(%rsp), %edx
movq 0x18(%rsp), %rcx
callq *%rax
movl %eax, 0x34(%rsp)
movq 0x48(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0x18300
movq 0x48(%rsp), %rdi
movq 0x40(%rsp), %rsi
callq 0x18300
jmp 0x27f3c
cmpl $0x0, 0x34(%rsp)
je 0x27f63
movq 0x48(%rsp), %rdi
movl 0x34(%rsp), %edx
xorl %esi, %esi
callq 0x18a00
movq 0x48(%rsp), %rdi
callq 0x19ad0
movl %eax, 0x54(%rsp)
jmp 0x27f6d
jmp 0x27f65
movl $0x0, 0x54(%rsp)
movl 0x54(%rsp), %eax
addq $0x58, %rsp
retq
nopw %cs:(%rax,%rax)