// File: /workspace/github_cpp_makefile_star2_O3/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 0x68c80(%rip), %rcx     # 0x8c03b
leaq 0x10(%rsp), %rdx
movl $0x1, %esi
callq 0x1a4e0
movq %rax, %r14
movq %rbx, %rdi
movl $0x2, %esi
callq 0x1a0f0
movq %rbx, %rdi
cmpl $0x5, %eax
jne 0x2343e
movl $0x3, %esi
callq 0x191b0
movq %rax, %r15
leaq 0x4(%rsp), %r13
movq %rbx, %rdi
movl $0x2, %esi
movq %r13, %rdx
callq 0x192b0
movq %rax, %r12
cmpl $0x0, (%r13)
je 0x234f8
movq %rbx, %rdi
movq %r12, %rsi
movl $0x1, %edx
callq 0x19160
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %edx, %edx
callq 0x18680
movq %rbx, %rdi
movl $0x2, %esi
jmp 0x234eb
movl $0x2, %esi
callq 0x18f60
movq %rax, %r15
movq %rbx, %rdi
movl $0x3, %esi
callq 0x190e0
movq %rax, %r13
leaq 0x4(%rsp), %rbp
movl $0x28, %edx
movq %rbx, %rdi
movl $0x21, %esi
movq %rbp, %rcx
callq 0x19da0
movq %rax, %r12
cmpl $0x0, (%rbp)
je 0x23493
movq %rbx, %rdi
movq %r12, %rsi
movl $0x1, %edx
callq 0x19160
jmp 0x2353c
movl %r15d, 0x10(%r12)
movl %r13d, 0x14(%r12)
movq %r12, %rdx
addq $0x18, %rdx
leaq 0x4(%rsp), %r15
movq %rbx, %rdi
movl $0x4, %esi
movq %r15, %rcx
callq 0x180d0
movq %rax, 0x20(%r12)
cmpl $0x0, (%r15)
je 0x234f5
movq %rbx, %rdi
movq %r12, %rsi
movl $0x1, %edx
callq 0x19160
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %edx, %edx
callq 0x18680
movq %rbx, %rdi
movl $0x4, %esi
movq %rax, %rdx
callq 0x18410
jmp 0x23544
xorl %r15d, %r15d
movq 0x10(%rsp), %rax
movq 0x50(%rax), %rax
leaq 0x8(%rsp), %rcx
movq %r14, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq *0x1c8(%rax)
movl %eax, %ebp
movl 0x10(%r12), %r13d
movq %rbx, %rdi
movq %r12, %rsi
movl $0x1, %edx
callq 0x19160
testl %ebp, %ebp
je 0x23553
movq %rbx, %rdi
xorl %esi, %esi
movl %ebp, %edx
callq 0x18980
movq %rbx, %rdi
callq 0x199a0
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x9ca6e(%rip), %rax     # 0xbffc8
cmpl $0x0, (%rax)
je 0x23572
movq 0x8(%rsp), %rsi
leaq 0x6a612(%rip), %rdi     # 0x8db7d
xorl %eax, %eax
callq 0x18960
movq 0x8(%rsp), %rsi
leaq 0x6a59f(%rip), %rdx     # 0x8db1d
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x18320
movq %rax, %rcx
movq 0x10(%rsp), %rax
movq %rax, 0x10(%rcx)
movq %r14, 0x20(%rcx)
movq 0x18(%rax), %rdx
movq %rdx, 0x18(%rcx)
movq %r15, 0x40(%rcx)
leaq 0xd5(%rip), %rdx        # 0x23680
movq %rdx, 0x8(%rcx)
movq 0x50(%rax), %rax
movq %rax, 0x50(%rcx)
movl $0x1, %eax
testb $0x1, %r13b
je 0x23544
orb $0x8, 0x28(%rcx)
jmp 0x23544