// File: /workspace/github_cpp_makefile_star2_O1/stetre[P]moonvulkan/src/descriptor_pool.c
// Function: Create
static int Create(lua_State *L)
    {
    int err, free_allowed;
    ud_t *ud, *device_ud;
    VkResult ec;
    VkDescriptorPool descriptor_pool;
    VkDescriptorPoolCreateInfo* info = NULL;
    VkDevice device = checkdevice(L, 1, &device_ud);
    const VkAllocationCallbacks *allocator = NULL;
#define CLEANUP zfreeVkDescriptorPoolCreateInfo(L, info, 1)
    if(lua_istable(L, 2))
        {
        allocator = optallocator(L, 3);
        info = zcheckVkDescriptorPoolCreateInfo(L, 2, &err);
        if(err) { CLEANUP; return argerror(L, 2); }
        }
    else
        {
        VkFlags flags = checkflags(L, 2);
        uint32_t maxSets = luaL_checkinteger(L, 3);
        info = znewVkDescriptorPoolCreateInfo(L, &err);
        if(err) { CLEANUP; return lua_error(L); }
        info->flags = flags;
        info->maxSets = maxSets;
        info->pPoolSizes = zcheckarrayVkDescriptorPoolSize(L, 4, &info->poolSizeCount, &err);
        if(err) { CLEANUP; return argerror(L, 4); }
        }
    ec = device_ud->ddt->CreateDescriptorPool(device, info, allocator, &descriptor_pool);
    free_allowed = info->flags & VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT;
    CLEANUP;
    CheckError(L, ec);
#undef CLEANUP
    TRACE_CREATE(descriptor_pool, "descriptor_pool");
    ud = newuserdata_nondispatchable(L, descriptor_pool, DESCRIPTOR_POOL_MT);
    ud->parent_ud = device_ud;
    ud->device = device;
    ud->instance = device_ud->instance;
    ud->allocator = allocator;
    ud->destructor = freedescriptor_pool;
    ud->ddt = device_ud->ddt;
    if(free_allowed) /* Rfr. Vulkan Spec '13.2.3. Allocation of Descriptor Sets' */
        MarkFreeDescriptorSetAllowed(ud);
    return 1;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
leaq 0x6bbc4(%rip), %rcx     # 0x8f03b
leaq 0x10(%rsp), %rdx
movl $0x1, %esi
callq 0x1a520
movq %rax, %r14
movq %rbx, %rdi
movl $0x2, %esi
callq 0x1a130
movq %rbx, %rdi
cmpl $0x5, %eax
jne 0x23502
movl $0x3, %esi
callq 0x191c0
movq %rax, %r12
leaq 0x4(%rsp), %r13
movq %rbx, %rdi
movl $0x2, %esi
movq %r13, %rdx
callq 0x192d0
movq %rax, %r15
cmpl $0x0, (%r13)
je 0x235d1
movq %rbx, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x19170
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %edx, %edx
callq 0x18690
movq %rbx, %rdi
movl $0x2, %esi
movq %rax, %rdx
callq 0x18420
jmp 0x23691
movl $0x2, %esi
callq 0x18f70
movq %rax, %r12
movq %rbx, %rdi
movl $0x3, %esi
callq 0x190f0
movq %rax, %r13
leaq 0x4(%rsp), %rbp
movl $0x28, %edx
movq %rbx, %rdi
movl $0x21, %esi
movq %rbp, %rcx
callq 0x19de0
movq %rax, %r15
cmpl $0x0, (%rbp)
je 0x2355f
movq %rbx, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x19170
movq %rbx, %rdi
callq 0x199e0
xorl %r12d, %r12d
jmp 0x235c5
movl %r12d, 0x10(%r15)
movl %r13d, 0x14(%r15)
movq %r15, %rdx
addq $0x18, %rdx
leaq 0x4(%rsp), %r12
movq %rbx, %rdi
movl $0x4, %esi
movq %r12, %rcx
callq 0x180d0
movq %rax, 0x20(%r15)
cmpl $0x0, (%r12)
je 0x235c2
movq %rbx, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x19170
xorl %r12d, %r12d
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %edx, %edx
callq 0x18690
movq %rbx, %rdi
movl $0x4, %esi
movq %rax, %rdx
callq 0x18420
jmp 0x235c5
movb $0x1, %r12b
testb %r12b, %r12b
je 0x23691
xorl %r12d, %r12d
movq 0x10(%rsp), %rax
movq 0x50(%rax), %rax
leaq 0x8(%rsp), %rcx
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq *0x1c8(%rax)
movl %eax, %ebp
movl 0x10(%r15), %r13d
movq %rbx, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x19170
testl %ebp, %ebp
je 0x2361e
movq %rbx, %rdi
xorl %esi, %esi
movl %ebp, %edx
callq 0x18990
movq %rbx, %rdi
callq 0x199e0
jmp 0x23691
movq 0x9f9a3(%rip), %rax     # 0xc2fc8
cmpl $0x0, (%rax)
je 0x2363d
movq 0x8(%rsp), %rsi
leaq 0x6d547(%rip), %rdi     # 0x90b7d
xorl %eax, %eax
callq 0x18970
movq 0x8(%rsp), %rsi
leaq 0x6d4d4(%rip), %rdx     # 0x90b1d
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x18330
movq %rax, %rcx
movq 0x10(%rsp), %rax
movq %rax, 0x10(%rcx)
movq %r14, 0x20(%rcx)
movq 0x18(%rax), %rdx
movq %rdx, 0x18(%rcx)
movq %r12, 0x40(%rcx)
leaq 0xdf(%rip), %rdx        # 0x23755
movq %rdx, 0x8(%rcx)
movq 0x50(%rax), %rax
movq %rax, 0x50(%rcx)
movl $0x1, %eax
testb $0x1, %r13b
je 0x23691
orb $0x8, 0x28(%rcx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq