// File: /workspace/github_cpp_makefile_star2_O2/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 $0x28, %rsp
movq %rdi, %rbx
leaq 0x5a440(%rip), %rcx     # 0x7d03b
pushq $0x1
popq %rsi
leaq 0x18(%rsp), %rdx
callq 0x1a500
movq %rax, %r14
pushq $0x2
popq %rsi
movq %rbx, %rdi
callq 0x1a110
cmpl $0x5, %eax
jne 0x22c6c
pushq $0x3
popq %rsi
movq %rbx, %rdi
callq 0x191a0
movq %rax, %r15
pushq $0x2
popq %rsi
leaq 0xc(%rsp), %r13
movq %rbx, %rdi
movq %r13, %rdx
callq 0x192b0
movq %rax, %r12
cmpl $0x0, (%r13)
je 0x22d17
pushq $0x1
popq %rdx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x19150
pushq $-0x1
popq %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x18680
pushq $0x2
jmp 0x22d06
pushq $0x2
popq %rsi
movq %rbx, %rdi
callq 0x18f50
movq %rax, %r15
pushq $0x3
popq %rsi
movq %rbx, %rdi
callq 0x190d0
movq %rax, %r13
pushq $0x21
popq %rsi
pushq $0x28
popq %rdx
leaq 0xc(%rsp), %rbp
movq %rbx, %rdi
movq %rbp, %rcx
callq 0x19dc0
movq %rax, %r12
cmpl $0x0, (%rbp)
je 0x22cba
pushq $0x1
popq %rdx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x19150
jmp 0x22d66
movl %r15d, 0x10(%r12)
movl %r13d, 0x14(%r12)
movq %r12, %rdx
addq $0x18, %rdx
pushq $0x4
popq %rsi
leaq 0xc(%rsp), %r15
movq %rbx, %rdi
movq %r15, %rcx
callq 0x180d0
movq %rax, 0x20(%r12)
cmpl $0x0, (%r15)
je 0x22d14
pushq $0x1
popq %rdx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x19150
pushq $-0x1
popq %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x18680
pushq $0x4
popq %rsi
movq %rbx, %rdi
movq %rax, %rdx
callq 0x18420
jmp 0x22d6e
xorl %r15d, %r15d
movq %r15, 0x20(%rsp)
movq 0x18(%rsp), %rax
movq 0x50(%rax), %rax
leaq 0x10(%rsp), %rcx
movq %r14, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq *0x1c8(%rax)
movl %eax, %r13d
movq %r14, %r15
movl 0x10(%r12), %r14d
pushq $0x1
popq %rbp
movq %rbx, %rdi
movq %r12, %rsi
movl %ebp, %edx
callq 0x19150
testl %r13d, %r13d
je 0x22d81
movq %rbx, %rdi
xorl %esi, %esi
movl %r13d, %edx
callq 0x18980
movq %rbx, %rdi
callq 0x199c0
movl %eax, %ebp
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x20(%rsp), %r12
movq 0x9820b(%rip), %rax     # 0xbaf98
cmpl $0x0, (%rax)
je 0x22da5
movq 0x10(%rsp), %rsi
leaq 0x5bddf(%rip), %rdi     # 0x7eb7d
xorl %eax, %eax
callq 0x18960
movq 0x10(%rsp), %rsi
leaq 0x5bd6c(%rip), %rdx     # 0x7eb1d
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x18330
movq 0x18(%rsp), %rcx
movq %rcx, 0x10(%rax)
movq %r15, 0x20(%rax)
movq 0x18(%rcx), %rdx
movq %rdx, 0x18(%rax)
movq %r12, 0x40(%rax)
leaq 0xca(%rip), %rdx        # 0x22ea5
movq %rdx, 0x8(%rax)
movq 0x50(%rcx), %rcx
movq %rcx, 0x50(%rax)
testb $0x1, %r14b
je 0x22d70
orb $0x8, 0x28(%rax)
jmp 0x22d70