// File: stetre[P]moonvulkan/src/pipeline_cache.c
// Function: Create
static int Create(lua_State *L)
    {
    int err;
    ud_t *ud, *device_ud;
    VkResult ec;
    VkPipelineCache pipeline_cache;
    VkPipelineCacheCreateInfo* info;
    VkDevice device = checkdevice(L, 1, &device_ud);
    const VkAllocationCallbacks *allocator = NULL;
#define CLEANUP zfreeVkPipelineCacheCreateInfo(L, info, 1)
    if(lua_istable(L, 2))
        {
        allocator = optallocator(L, 3);
        info = zcheckVkPipelineCacheCreateInfo(L, 2, &err);
        if(err) { CLEANUP; return argerror(L, 2); }
        lua_getfield(L, 2, "initial_data");
        info->pInitialData = (void*)luaL_optlstring(L, -1, NULL, &info->initialDataSize);
        }
    else
        {
        info = znewVkPipelineCacheCreateInfo(L, &err);
        if(err) { CLEANUP; return lua_error(L); }
        info->flags = optflags(L, 2, 0);
        info->pInitialData = (void*)luaL_optlstring(L, 3, NULL, &info->initialDataSize);
        }
    ec = device_ud->ddt->CreatePipelineCache(device, info, allocator, &pipeline_cache);
    CLEANUP;
    CheckError(L, ec);
#undef CLEANUP
    TRACE_CREATE(pipeline_cache, "pipeline_cache");
    ud = newuserdata_nondispatchable(L, pipeline_cache, PIPELINE_CACHE_MT);
    ud->parent_ud = device_ud;
    ud->device = device;
    ud->instance = device_ud->instance;
    ud->allocator = allocator;
    ud->destructor = freepipeline_cache;
    ud->ddt = device_ud->ddt;
    return 1;
    }

// Assembly:
subq $0x58, %rsp
movq %rdi, 0x48(%rsp)
movq 0x48(%rsp), %rdi
movl $0x1, %esi
leaq 0x30(%rsp), %rdx
leaq 0x6ff9c(%rip), %rcx     # 0xcf03b
callq 0x1a640
movq %rax, 0x10(%rsp)
movq $0x0, 0x8(%rsp)
movq 0x48(%rsp), %rdi
movl $0x2, %esi
callq 0x1a240
cmpl $0x5, %eax
jne 0x5f18b
movq 0x48(%rsp), %rdi
movl $0x3, %esi
callq 0x19260
movq %rax, 0x8(%rsp)
movq 0x48(%rsp), %rdi
movl $0x2, %esi
leaq 0x44(%rsp), %rdx
callq 0x18110
movq %rax, 0x18(%rsp)
cmpl $0x0, 0x44(%rsp)
je 0x5f148
movq 0x48(%rsp), %rdi
movq 0x18(%rsp), %rsi
movl $0x1, %edx
callq 0x19210
movq 0x48(%rsp), %rax
movq %rax, (%rsp)
movq 0x48(%rsp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %eax, %eax
movl %eax, %edx
callq 0x186d0
movq (%rsp), %rdi
movq %rax, %rdx
movl $0x2, %esi
callq 0x18460
movl %eax, 0x54(%rsp)
jmp 0x5f32c
movq 0x48(%rsp), %rdi
movl $0x2, %esi
leaq 0x83bd8(%rip), %rdx     # 0xe2d31
callq 0x1a5a0
movq 0x48(%rsp), %rdi
movq 0x18(%rsp), %rcx
addq $0x18, %rcx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %eax, %eax
movl %eax, %edx
callq 0x18900
movq %rax, %rcx
movq 0x18(%rsp), %rax
movq %rcx, 0x20(%rax)
jmp 0x5f21c
movq 0x48(%rsp), %rdi
movl $0x11, %esi
movl $0x28, %edx
leaq 0x44(%rsp), %rcx
callq 0x19ee0
movq %rax, 0x18(%rsp)
cmpl $0x0, 0x44(%rsp)
je 0x5f1d7
movq 0x48(%rsp), %rdi
movq 0x18(%rsp), %rsi
movl $0x1, %edx
callq 0x19210
movq 0x48(%rsp), %rdi
callq 0x19ad0
movl %eax, 0x54(%rsp)
jmp 0x5f32c
movq 0x48(%rsp), %rdi
movl $0x2, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x19370
movl %eax, %ecx
movq 0x18(%rsp), %rax
movl %ecx, 0x10(%rax)
movq 0x48(%rsp), %rdi
movq 0x18(%rsp), %rcx
addq $0x18, %rcx
movl $0x3, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x18900
movq %rax, %rcx
movq 0x18(%rsp), %rax
movq %rcx, 0x20(%rax)
movq 0x30(%rsp), %rax
movq 0x50(%rax), %rax
movq 0x160(%rax), %rax
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq 0x8(%rsp), %rdx
leaq 0x20(%rsp), %rcx
callq *%rax
movl %eax, 0x2c(%rsp)
movq 0x48(%rsp), %rdi
movq 0x18(%rsp), %rsi
movl $0x1, %edx
callq 0x19210
cmpl $0x0, 0x2c(%rsp)
je 0x5f284
movq 0x48(%rsp), %rdi
movl 0x2c(%rsp), %edx
xorl %esi, %esi
callq 0x18a00
movq 0x48(%rsp), %rdi
callq 0x19ad0
movl %eax, 0x54(%rsp)
jmp 0x5f32c
jmp 0x5f286
jmp 0x5f288
movq 0x9dd09(%rip), %rax     # 0xfcf98
cmpl $0x0, (%rax)
je 0x5f2a7
movq 0x20(%rsp), %rsi
leaq 0x83a9e(%rip), %rdi     # 0xe2d3e
movb $0x0, %al
callq 0x189d0
jmp 0x5f2a9
movq 0x48(%rsp), %rdi
movq 0x20(%rsp), %rsi
leaq 0x71c7a(%rip), %rdx     # 0xd0f34
xorl %ecx, %ecx
callq 0x18350
movq %rax, 0x38(%rsp)
movq 0x30(%rsp), %rcx
movq 0x38(%rsp), %rax
movq %rcx, 0x10(%rax)
movq 0x10(%rsp), %rcx
movq 0x38(%rsp), %rax
movq %rcx, 0x20(%rax)
movq 0x30(%rsp), %rax
movq 0x18(%rax), %rcx
movq 0x38(%rsp), %rax
movq %rcx, 0x18(%rax)
movq 0x8(%rsp), %rcx
movq 0x38(%rsp), %rax
movq %rcx, 0x40(%rax)
movq 0x38(%rsp), %rax
leaq 0x2f2(%rip), %rcx       # 0x5f600
movq %rcx, 0x8(%rax)
movq 0x30(%rsp), %rax
movq 0x50(%rax), %rcx
movq 0x38(%rsp), %rax
movq %rcx, 0x50(%rax)
movl $0x1, 0x54(%rsp)
movl 0x54(%rsp), %eax
addq $0x58, %rsp
retq
nopw %cs:(%rax,%rax)