// File: /workspace/github_cpp_makefile_star2_O2/stetre[P]moonvulkan/src/debug_utils_messenger.c
// Function: Create
static int Create(lua_State *L)
    {
    int err, ref;
    ud_t *ud, *instance_ud;
    ud_info_t *ud_info;
    VkResult ec;
    VkDebugUtilsMessengerEXT debug_utils_messenger;
    VkDebugUtilsMessengerCreateInfoEXT* info;
    VkInstance instance = checkinstance(L, 1, &instance_ud);
    const VkAllocationCallbacks *allocator = optallocator(L, 4);
    CheckInstancePfn(L, instance_ud, CreateDebugUtilsMessengerEXT);
    if(!lua_isfunction(L, 3)) return argerrorc(L, 3, ERR_TYPE);
#define CLEANUP zfreeVkDebugUtilsMessengerCreateInfoEXT(L, info, 1)
    info = zcheckVkDebugUtilsMessengerCreateInfoEXT(L, 2, &err);
    if(err) { CLEANUP; return argerror(L, 2); }
    info->pfnUserCallback = /*(PFN_vkDebugUtilsMessengerEXT)*/Callback;
    ud_info = (ud_info_t*)MallocNoErr(L, sizeof(ud_info_t));
    if(!ud_info) { CLEANUP; return errmemory(L); }
    info->pUserData = ud_info;
    ec = instance_ud->idt->CreateDebugUtilsMessengerEXT(instance,info,allocator,&debug_utils_messenger);
    CLEANUP;
#undef CLEANUP
    if(ec)
        {
        Free(L, ud_info);
        CheckError(L, ec);
        return 0;
        }
    lua_pushvalue(L, 3);
    ref = luaL_ref(L, LUA_REGISTRYINDEX);
    TRACE_CREATE(debug_utils_messenger, "debug_utils_messenger");
    ud = newuserdata_nondispatchable(L, debug_utils_messenger, DEBUG_UTILS_MESSENGER_MT);
    ud->ref1 = ref;
    ud->info = ud_info;
    ud_info->ud = ud;
    ud->parent_ud = instance_ud;
    ud->instance = instance;
    ud->allocator = allocator;
    ud->destructor = freedebug_utils_messenger;
    ud->idt = instance_ud->idt;
    return 1;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
leaq 0x5c472(%rip), %rcx     # 0x7e711
pushq $0x1
popq %rsi
leaq 0x18(%rsp), %r12
movq %r12, %rdx
callq 0x1a500
movq %rax, %r14
pushq $0x4
popq %rsi
movq %rbx, %rdi
callq 0x191a0
movq %rax, %r15
movq (%r12), %rax
movq 0x48(%rax), %rax
cmpq $0x0, 0x188(%rax)
je 0x2231e
pushq $0x3
popq %rsi
movq %rbx, %rdi
callq 0x1a110
cmpl $0x6, %eax
jne 0x22331
pushq $0x2
popq %rsi
leaq 0x24(%rsp), %r12
movq %rbx, %rdi
movq %r12, %rdx
callq 0x18ab0
movq %rax, %r13
cmpl $0x0, (%r12)
je 0x2235a
pushq $0x1
popq %rdx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x19150
pushq $-0x1
popq %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x18680
pushq $0x2
jmp 0x2233b
leaq 0x5c62b(%rip), %rsi     # 0x7e950
movq %rbx, %rdi
xorl %eax, %eax
callq 0x19bc0
jmp 0x22347
pushq $-0x2
popq %rdi
callq 0x19950
pushq $0x3
popq %rsi
movq %rbx, %rdi
movq %rax, %rdx
callq 0x18420
movl %eax, %ebp
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x5d8(%rip), %rax       # 0x22939
movq %rax, 0x20(%r13)
pushq $0x8
popq %rsi
movq %rbx, %rdi
callq 0x18050
testq %rax, %rax
je 0x223da
movq %rax, 0x28(%r13)
movq %rax, 0x8(%rsp)
movq 0x18(%rsp), %rax
movq 0x48(%rax), %rax
leaq 0x10(%rsp), %rcx
movq %r14, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq *0x188(%rax)
movl %eax, %r12d
pushq $0x1
popq %rbp
movq %rbx, %rdi
movq %r13, %rsi
movl %ebp, %edx
callq 0x19150
testl %r12d, %r12d
je 0x223fb
movq %rbx, %rdi
movq 0x8(%rsp), %rsi
callq 0x182e0
movq %rbx, %rdi
xorl %esi, %esi
movl %r12d, %edx
callq 0x18980
movq %rbx, %rdi
callq 0x199c0
jmp 0x22347
pushq $0x1
popq %rdx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x19150
pushq $-0x6
popq %rdi
callq 0x19950
movq %rbx, %rdi
movq %rax, %rsi
jmp 0x22328
movq 0x8(%rsp), %r12
pushq $0x3
popq %rsi
movq %rbx, %rdi
callq 0x18e80
movq %rbx, %rdi
movl $0xfff0b9d8, %esi       # imm = 0xFFF0B9D8
callq 0x187a0
movl %eax, %r13d
movq 0x98b76(%rip), %rax     # 0xbaf98
cmpl $0x0, (%rax)
je 0x2243a
movq 0x10(%rsp), %rsi
leaq 0x5c54f(%rip), %rdi     # 0x7e982
xorl %eax, %eax
callq 0x18960
movq 0x10(%rsp), %rsi
leaq 0x5c403(%rip), %rdx     # 0x7e849
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x18330
movl %r13d, 0x2c(%rax)
movq %r12, 0x58(%rax)
movq %rax, (%r12)
movq 0x18(%rsp), %rcx
movq %rcx, 0x10(%rax)
movq %r14, 0x18(%rax)
movq %r15, 0x40(%rax)
leaq 0x5a4(%rip), %rdx       # 0x22a18
movq %rdx, 0x8(%rax)
movq 0x48(%rcx), %rcx
movq %rcx, 0x48(%rax)
jmp 0x22349