// File: /workspace/github_cpp_makefile_star2_O1/stetre[P]moonvulkan/src/debug_report_callback.c
// Function: Create
static int Create(lua_State *L)
    {
    ud_info_t *ud_info;
    ud_t *ud, *instance_ud;
    VkResult ec;
    VkDebugReportCallbackEXT debug_report_callback;
    VkDebugReportCallbackCreateInfoEXT info;
    int ref;
    VkInstance instance = checkinstance(L, 1, &instance_ud);
    const VkAllocationCallbacks *allocator = optallocator(L, 4);
    CheckInstancePfn(L, instance_ud, CreateDebugReportCallbackEXT);
    if(!lua_isfunction(L, 3)) return argerrorc(L, 3, ERR_TYPE);

    info.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT;
    info.pNext = NULL;
    info.flags = checkflags(L, 2);
    info.pfnCallback = (PFN_vkDebugReportCallbackEXT)Callback;

    ud_info = (ud_info_t*)MallocNoErr(L, sizeof(ud_info_t));
    if(!ud_info) return errmemory(L);
    info.pUserData = ud_info;
    ec = instance_ud->idt->CreateDebugReportCallbackEXT(instance, &info, allocator, 
                            &debug_report_callback);
    if(ec)
        {
        Free(L, ud_info);
        CheckError(L, ec);
        return 0;
        }
    lua_pushvalue(L, 3);
    ref = luaL_ref(L, LUA_REGISTRYINDEX);
    TRACE_CREATE(debug_report_callback, "debug_report_callback");
    ud = newuserdata_nondispatchable(L, debug_report_callback, DEBUG_REPORT_CALLBACK_MT);
    ud->ref1 = ref;
    ud->info = ud_info;
    ud_info->ud = ud;
    ud->ref1 = ref;
    ud->parent_ud = instance_ud;
    ud->instance = instance;
    ud->allocator = allocator;
    ud->destructor = freedebug_report_callback;
    ud->idt = instance_ud->idt;
    return 1;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x40, %rsp
movq %rdi, %rbx
leaq 0x6e41c(%rip), %rcx     # 0x90711
leaq 0x10(%rsp), %r12
movl $0x1, %esi
movq %r12, %rdx
callq 0x1a520
movq %rax, %r14
movq %rbx, %rdi
movl $0x4, %esi
callq 0x191c0
movq %rax, %r15
movq (%r12), %rax
movq 0x48(%rax), %rax
cmpq $0x0, 0xd0(%rax)
je 0x223d3
movq %rbx, %rdi
movl $0x3, %esi
callq 0x1a130
cmpl $0x6, %eax
jne 0x223df
movl $0x3b9af4f8, 0x18(%rsp) # imm = 0x3B9AF4F8
movq $0x0, 0x20(%rsp)
movq %rbx, %rdi
movl $0x2, %esi
callq 0x18f70
movl %eax, 0x28(%rsp)
leaq 0x446(%rip), %rax       # 0x227b5
movq %rax, 0x30(%rsp)
movl $0x8, %esi
movq %rbx, %rdi
callq 0x18050
testq %rax, %rax
je 0x223fb
movq %rax, %r12
leaq 0x18(%rsp), %rsi
movq %rax, 0x20(%rsi)
movq 0x10(%rsp), %rax
movq 0x48(%rax), %rax
leaq 0x8(%rsp), %rcx
movq %r14, %rdi
movq %r15, %rdx
callq *0xd0(%rax)
testl %eax, %eax
je 0x2241f
movl %eax, %ebp
movq %rbx, %rdi
movq %r12, %rsi
callq 0x182e0
movq %rbx, %rdi
xorl %esi, %esi
movl %ebp, %edx
callq 0x18990
movq %rbx, %rdi
callq 0x199e0
jmp 0x22412
leaq 0x6e34b(%rip), %rsi     # 0x90725
movq %rbx, %rdi
jmp 0x2240b
movl $0xfffffffe, %edi       # imm = 0xFFFFFFFE
callq 0x19970
movq %rbx, %rdi
movl $0x3, %esi
movq %rax, %rdx
callq 0x18420
jmp 0x22412
movl $0xfffffffa, %edi       # imm = 0xFFFFFFFA
callq 0x19970
movq %rbx, %rdi
movq %rax, %rsi
xorl %eax, %eax
callq 0x19be0
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
movl $0x3, %esi
callq 0x18ea0
movq %rbx, %rdi
movl $0xfff0b9d8, %esi       # imm = 0xFFF0B9D8
callq 0x187b0
movl %eax, %ebp
movq 0xa0b86(%rip), %rax     # 0xc2fc8
cmpl $0x0, (%rax)
je 0x2245a
movq 0x8(%rsp), %rsi
leaq 0x6e304(%rip), %rdi     # 0x90757
xorl %eax, %eax
callq 0x18970
movq 0x8(%rsp), %rsi
leaq 0x6e201(%rip), %rdx     # 0x90667
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x18330
movl %ebp, 0x2c(%rax)
movq %r12, 0x58(%rax)
movq %rax, (%r12)
movl %ebp, 0x2c(%rax)
movq 0x10(%rsp), %rcx
movq %rcx, 0x10(%rax)
movq %r14, 0x18(%rax)
movq %r15, 0x40(%rax)
leaq 0x454(%rip), %rdx       # 0x228ea
movq %rdx, 0x8(%rax)
movq 0x48(%rcx), %rcx
movq %rcx, 0x48(%rax)
movl $0x1, %eax
jmp 0x22412