// File: /workspace/github_cpp_makefile_star2_O1/stetre[P]moonvulkan/src/shader_module.c
// Function: Create
static int Create(lua_State *L)
    {
    int err;
    ud_t *ud, *device_ud;
    VkResult ec;
    VkShaderModule shader_module;
    VkShaderModuleCreateInfo* info;
    size_t size;
    const char *code;
    VkDevice device = checkdevice(L, 1, &device_ud);
    const VkAllocationCallbacks *allocator = NULL;
#define CLEANUP zfreeVkShaderModuleCreateInfo(L, info, 1)
    if(lua_istable(L, 2))
        {
        allocator = optallocator(L, 3);
        info = zcheckVkShaderModuleCreateInfo(L, 2, &err);
        if(err) { CLEANUP; return argerror(L, 2); }
        lua_getfield(L, 2, "code");
        code = luaL_optlstring(L, -1, NULL, &size);
        }
    else
        {
        VkFlags flags = checkflags(L, 2);
        info = znewVkShaderModuleCreateInfo(L, &err);
        if(err) { CLEANUP; return lua_error(L); }
        info->flags = flags;
        code = luaL_optlstring(L, 3, NULL, &size);
        }

    if(!code || (size == 0))
        return luaL_error(L, "missing shader code");
    info->codeSize = size;
    info->pCode = (uint32_t*)code;
    ec = device_ud->ddt->CreateShaderModule(device, info, allocator, &shader_module);
    CLEANUP;
    CheckError(L, ec);
#undef CLEANUP
    TRACE_CREATE(shader_module, "shader_module");
    ud = newuserdata_nondispatchable(L, shader_module, SHADER_MODULE_MT);
    ud->parent_ud = device_ud;
    ud->device = device;
    ud->instance = device_ud->instance;
    ud->allocator = allocator;
    ud->destructor = freeshader_module;
    ud->ddt = device_ud->ddt;
    return 1;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
leaq 0x4303c(%rip), %rcx     # 0x8f03b
leaq 0x20(%rsp), %rdx
movl $0x1, %esi
callq 0x1a520
movq %rax, %r14
movq %rbx, %rdi
movl $0x2, %esi
callq 0x1a130
movq %rbx, %rdi
cmpl $0x5, %eax
jne 0x4c08a
movl $0x3, %esi
callq 0x191c0
movq %rax, %r12
leaq 0xc(%rsp), %r13
movq %rbx, %rdi
movl $0x2, %esi
movq %r13, %rdx
callq 0x18570
movq %rax, %r15
cmpl $0x0, (%r13)
je 0x4c0d8
movq %rbx, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x19170
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %edx, %edx
callq 0x18690
movq %rbx, %rdi
movl $0x2, %esi
movq %rax, %rdx
callq 0x18420
jmp 0x4c1a2
movl $0x2, %esi
callq 0x18f70
movq %rax, %r12
leaq 0xc(%rsp), %r13
movl $0x28, %edx
movq %rbx, %rdi
movl $0x10, %esi
movq %r13, %rcx
callq 0x19de0
movq %rax, %r15
movl (%r13), %ebp
testl %ebp, %ebp
je 0x4c102
movq %rbx, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x19170
movq %rbx, %rdi
callq 0x199e0
movl %eax, %ecx
jmp 0x4c11a
leaq 0x571b8(%rip), %rdx     # 0xa3297
movq %rbx, %rdi
movl $0x2, %esi
callq 0x1a480
leaq 0x10(%rsp), %rcx
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %edx, %edx
callq 0x188b0
jmp 0x4c125
movl %r12d, 0x10(%r15)
leaq 0x10(%rsp), %rcx
movq %rbx, %rdi
movl $0x3, %esi
xorl %edx, %edx
callq 0x188b0
testl %ebp, %ebp
jne 0x4c1a4
xorl %r12d, %r12d
testq %rax, %rax
sete %dl
movq 0x10(%rsp), %rcx
testq %rcx, %rcx
sete %sil
orb %dl, %sil
cmpb $0x1, %sil
jne 0x4c153
leaq 0x57141(%rip), %rsi     # 0xa3288
movq %rbx, %rdi
xorl %eax, %eax
callq 0x19be0
jmp 0x4c1a2
movq %rcx, 0x18(%r15)
movq %rax, 0x20(%r15)
movq 0x20(%rsp), %rax
movq 0x50(%rax), %rax
leaq 0x18(%rsp), %rcx
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq *0x150(%rax)
movl %eax, %ebp
movq %rbx, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x19170
testl %ebp, %ebp
je 0x4c1b5
movq %rbx, %rdi
xorl %esi, %esi
movl %ebp, %edx
callq 0x18990
movq %rbx, %rdi
callq 0x199e0
movl %eax, %ecx
movl %ecx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x76e0c(%rip), %rax     # 0xc2fc8
cmpl $0x0, (%rax)
je 0x4c1d4
movq 0x18(%rsp), %rsi
leaq 0x570cf(%rip), %rdi     # 0xa329c
xorl %eax, %eax
callq 0x18970
movq 0x18(%rsp), %rsi
leaq 0x44df5(%rip), %rdx     # 0x90fd5
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x18330
movq 0x20(%rsp), %rcx
movq %rcx, 0x10(%rax)
movq %r14, 0x20(%rax)
movq 0x18(%rcx), %rdx
movq %rdx, 0x18(%rax)
movq %r12, 0x40(%rax)
leaq 0x42(%rip), %rdx        # 0x4c24c
movq %rdx, 0x8(%rax)
movq 0x50(%rcx), %rcx
movq %rcx, 0x50(%rax)
movl $0x1, %ecx
jmp 0x4c1a4