// File: 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:
subq $0x68, %rsp
movq %rdi, 0x58(%rsp)
movq $0x0, 0x28(%rsp)
movq 0x58(%rsp), %rdi
movl $0x1, %esi
leaq 0x40(%rsp), %rdx
leaq 0xa7e23(%rip), %rcx     # 0xcf03b
callq 0x1a640
movq %rax, 0x20(%rsp)
movq $0x0, 0x18(%rsp)
movq 0x58(%rsp), %rdi
movl $0x2, %esi
callq 0x1a240
cmpl $0x5, %eax
jne 0x272c8
movq 0x58(%rsp), %rdi
movl $0x3, %esi
callq 0x19260
movq %rax, 0x18(%rsp)
movq 0x58(%rsp), %rdi
movl $0x2, %esi
leaq 0x54(%rsp), %rdx
callq 0x19390
movq %rax, 0x28(%rsp)
cmpl $0x0, 0x54(%rsp)
je 0x272c3
movq 0x58(%rsp), %rdi
movq 0x28(%rsp), %rsi
movl $0x1, %edx
callq 0x19210
movq 0x58(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x58(%rsp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %eax, %eax
movl %eax, %edx
callq 0x186d0
movq 0x8(%rsp), %rdi
movq %rax, %rdx
movl $0x2, %esi
callq 0x18460
movl %eax, 0x64(%rsp)
jmp 0x2750b
jmp 0x273ce
movq 0x58(%rsp), %rdi
movl $0x2, %esi
callq 0x19010
movl %eax, 0x14(%rsp)
movq 0x58(%rsp), %rdi
movl $0x3, %esi
callq 0x19190
movl %eax, 0x10(%rsp)
movq 0x58(%rsp), %rdi
movl $0x21, %esi
movl $0x28, %edx
leaq 0x54(%rsp), %rcx
callq 0x19ee0
movq %rax, 0x28(%rsp)
cmpl $0x0, 0x54(%rsp)
je 0x2733a
movq 0x58(%rsp), %rdi
movq 0x28(%rsp), %rsi
movl $0x1, %edx
callq 0x19210
movq 0x58(%rsp), %rdi
callq 0x19ad0
movl %eax, 0x64(%rsp)
jmp 0x2750b
movl 0x14(%rsp), %ecx
movq 0x28(%rsp), %rax
movl %ecx, 0x10(%rax)
movl 0x10(%rsp), %ecx
movq 0x28(%rsp), %rax
movl %ecx, 0x14(%rax)
movq 0x58(%rsp), %rdi
movq 0x28(%rsp), %rdx
addq $0x18, %rdx
movl $0x4, %esi
leaq 0x54(%rsp), %rcx
callq 0x180d0
movq %rax, %rcx
movq 0x28(%rsp), %rax
movq %rcx, 0x20(%rax)
cmpl $0x0, 0x54(%rsp)
je 0x273cc
movq 0x58(%rsp), %rdi
movq 0x28(%rsp), %rsi
movl $0x1, %edx
callq 0x19210
movq 0x58(%rsp), %rax
movq %rax, (%rsp)
movq 0x58(%rsp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %eax, %eax
movl %eax, %edx
callq 0x186d0
movq (%rsp), %rdi
movq %rax, %rdx
movl $0x4, %esi
callq 0x18460
movl %eax, 0x64(%rsp)
jmp 0x2750b
jmp 0x273ce
movq 0x40(%rsp), %rax
movq 0x50(%rax), %rax
movq 0x1c8(%rax), %rax
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rsi
movq 0x18(%rsp), %rdx
leaq 0x30(%rsp), %rcx
callq *%rax
movl %eax, 0x3c(%rsp)
movq 0x28(%rsp), %rax
movl 0x10(%rax), %eax
andl $0x1, %eax
movl %eax, 0x50(%rsp)
movq 0x58(%rsp), %rdi
movq 0x28(%rsp), %rsi
movl $0x1, %edx
callq 0x19210
cmpl $0x0, 0x3c(%rsp)
je 0x27445
movq 0x58(%rsp), %rdi
movl 0x3c(%rsp), %edx
xorl %esi, %esi
callq 0x18a00
movq 0x58(%rsp), %rdi
callq 0x19ad0
movl %eax, 0x64(%rsp)
jmp 0x2750b
jmp 0x27447
jmp 0x27449
movq 0xd5b48(%rip), %rax     # 0xfcf98
cmpl $0x0, (%rax)
je 0x27468
movq 0x30(%rsp), %rsi
leaq 0xa96d4(%rip), %rdi     # 0xd0b35
movb $0x0, %al
callq 0x189d0
jmp 0x2746a
movq 0x58(%rsp), %rdi
movq 0x30(%rsp), %rsi
leaq 0xa965a(%rip), %rdx     # 0xd0ad5
xorl %ecx, %ecx
callq 0x18350
movq %rax, 0x48(%rsp)
movq 0x40(%rsp), %rcx
movq 0x48(%rsp), %rax
movq %rcx, 0x10(%rax)
movq 0x20(%rsp), %rcx
movq 0x48(%rsp), %rax
movq %rcx, 0x20(%rax)
movq 0x40(%rsp), %rax
movq 0x18(%rax), %rcx
movq 0x48(%rsp), %rax
movq %rcx, 0x18(%rax)
movq 0x18(%rsp), %rcx
movq 0x48(%rsp), %rax
movq %rcx, 0x40(%rax)
movq 0x48(%rsp), %rax
leaq 0x141(%rip), %rcx       # 0x27610
movq %rcx, 0x8(%rax)
movq 0x40(%rsp), %rax
movq 0x50(%rax), %rcx
movq 0x48(%rsp), %rax
movq %rcx, 0x50(%rax)
cmpl $0x0, 0x50(%rsp)
je 0x27503
jmp 0x274ee
movq 0x48(%rsp), %rax
movl 0x28(%rax), %ecx
orl $0x8, %ecx
movq 0x48(%rsp), %rax
movl %ecx, 0x28(%rax)
jmp 0x27503
movl $0x1, 0x64(%rsp)
movl 0x64(%rsp), %eax
addq $0x68, %rsp
retq
nopw %cs:(%rax,%rax)