// File: stetre[P]moonvulkan/src/pipeline.c
// Function: CreateCompute
static int CreateCompute(lua_State *L)
    {
    int err;
    uint32_t count, i;
    VkResult ec;
    VkPipeline *pipeline;

    VkDevice device = checkdevice(L, 1, NULL);
    VkPipelineCache cache = testpipeline_cache(L, 2, NULL);
    const VkAllocationCallbacks *allocator = optallocator(L, 4);
#define CLEANUP zfreearrayVkComputePipelineCreateInfo(L, info, count, 1)
    VkComputePipelineCreateInfo *info = zcheckarrayVkComputePipelineCreateInfo(L, 3, &count, &err);
    if(err) { CLEANUP; return argerror(L, 3); }

    pipeline = (VkPipeline*)MallocNoErr(L, count*sizeof(VkPipeline));
    if(!pipeline) { CLEANUP; return errmemory(L); }

    ec = UD(device)->ddt->CreateComputePipelines(device, cache, count, info, allocator, pipeline);
    CLEANUP;
#undef CLEANUP

    if(ec)
        {
        Free(L, pipeline);
        CheckError(L, ec);
        }
    lua_newtable(L);
    for(i = 0; i < count; i++)
        {
        newpipeline(L, pipeline[i], device, allocator);
        lua_rawseti(L, -2, i+1);
        }
    Free(L, pipeline);
    return 1;
    }

// Assembly:
subq $0x58, %rsp
movq %rdi, 0x48(%rsp)
movq 0x48(%rsp), %rdi
movl $0x1, %esi
xorl %eax, %eax
movl %eax, %edx
leaq 0x7112d(%rip), %rcx     # 0xcf03b
callq 0x1a640
movq %rax, 0x28(%rsp)
movq 0x48(%rsp), %rdi
movl $0x2, %esi
xorl %eax, %eax
movl %eax, %edx
leaq 0x73007(%rip), %rcx     # 0xd0f34
callq 0x1a5f0
movq %rax, 0x20(%rsp)
movq 0x48(%rsp), %rdi
movl $0x4, %esi
callq 0x19260
movq %rax, 0x18(%rsp)
movq 0x48(%rsp), %rdi
movl $0x3, %esi
leaq 0x40(%rsp), %rdx
leaq 0x44(%rsp), %rcx
callq 0x196a0
movq %rax, 0x10(%rsp)
cmpl $0x0, 0x44(%rsp)
je 0x5dfc6
movq 0x48(%rsp), %rdi
movq 0x10(%rsp), %rsi
movl 0x40(%rsp), %ecx
movl $0x60, %edx
movl $0x1, %r8d
callq 0x198d0
movq 0x48(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x48(%rsp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %eax, %eax
movl %eax, %edx
callq 0x186d0
movq 0x8(%rsp), %rdi
movq %rax, %rdx
movl $0x3, %esi
callq 0x18460
movl %eax, 0x54(%rsp)
jmp 0x5e148
movq 0x48(%rsp), %rdi
movl 0x40(%rsp), %eax
movl %eax, %esi
shlq $0x3, %rsi
callq 0x18050
movq %rax, 0x30(%rsp)
cmpq $0x0, 0x30(%rsp)
jne 0x5e02f
movq 0x48(%rsp), %rdi
movq 0x10(%rsp), %rsi
movl 0x40(%rsp), %ecx
movl $0x60, %edx
movl $0x1, %r8d
callq 0x198d0
movq 0x48(%rsp), %rax
movq %rax, (%rsp)
movl $0xfffffffa, %edi       # imm = 0xFFFFFFFA
callq 0x19a60
movq (%rsp), %rdi
movq %rax, %rsi
movb $0x0, %al
callq 0x19ce0
movl %eax, 0x54(%rsp)
jmp 0x5e148
movq 0x28(%rsp), %rdi
callq 0x19fd0
movq 0x50(%rax), %rax
movq 0x188(%rax), %rax
movq 0x28(%rsp), %rdi
movq 0x20(%rsp), %rsi
movl 0x40(%rsp), %edx
movq 0x10(%rsp), %rcx
movq 0x18(%rsp), %r8
movq 0x30(%rsp), %r9
callq *%rax
movl %eax, 0x38(%rsp)
movq 0x48(%rsp), %rdi
movq 0x10(%rsp), %rsi
movl 0x40(%rsp), %ecx
movl $0x60, %edx
movl $0x1, %r8d
callq 0x198d0
cmpl $0x0, 0x38(%rsp)
je 0x5e0c9
movq 0x48(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0x18300
cmpl $0x0, 0x38(%rsp)
je 0x5e0c5
movq 0x48(%rsp), %rdi
movl 0x38(%rsp), %edx
xorl %esi, %esi
callq 0x18a00
movq 0x48(%rsp), %rdi
callq 0x19ad0
movl %eax, 0x54(%rsp)
jmp 0x5e148
jmp 0x5e0c7
jmp 0x5e0c9
movq 0x48(%rsp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x18830
movl $0x0, 0x3c(%rsp)
movl 0x3c(%rsp), %eax
cmpl 0x40(%rsp), %eax
jae 0x5e131
movq 0x48(%rsp), %rdi
movq 0x30(%rsp), %rax
movl 0x3c(%rsp), %ecx
movq (%rax,%rcx,8), %rsi
movq 0x28(%rsp), %rdx
movq 0x18(%rsp), %rcx
callq 0x5ecc0
movq 0x48(%rsp), %rdi
movl 0x3c(%rsp), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %edx
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x191e0
movl 0x3c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x3c(%rsp)
jmp 0x5e0df
movq 0x48(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0x18300
movl $0x1, 0x54(%rsp)
movl 0x54(%rsp), %eax
addq $0x58, %rsp
retq
nopw %cs:(%rax,%rax)