// File: 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:
subq $0x78, %rsp
movq %rdi, 0x68(%rsp)
movq 0x68(%rsp), %rdi
movl $0x1, %esi
leaq 0x50(%rsp), %rdx
leaq 0xaa28a(%rip), %rcx     # 0xd06c9
callq 0x1a640
movq %rax, 0x28(%rsp)
movq 0x68(%rsp), %rdi
movl $0x4, %esi
callq 0x19260
movq %rax, 0x20(%rsp)
movq 0x50(%rsp), %rax
movq 0x48(%rax), %rax
cmpq $0x0, 0x188(%rax)
jne 0x2648c
movq 0x68(%rsp), %rdi
leaq 0xaa48c(%rip), %rsi     # 0xd0908
movb $0x0, %al
callq 0x19ce0
movl %eax, 0x74(%rsp)
jmp 0x2671f
jmp 0x2648e
movq 0x68(%rsp), %rdi
movl $0x3, %esi
callq 0x1a240
cmpl $0x6, %eax
je 0x264d1
movq 0x68(%rsp), %rax
movq %rax, 0x18(%rsp)
movl $0xfffffffe, %edi       # imm = 0xFFFFFFFE
callq 0x19a60
movq 0x18(%rsp), %rdi
movq %rax, %rdx
movl $0x3, %esi
callq 0x18460
movl %eax, 0x74(%rsp)
jmp 0x2671f
movq 0x68(%rsp), %rdi
movl $0x2, %esi
leaq 0x64(%rsp), %rdx
callq 0x18b40
movq %rax, 0x30(%rsp)
cmpl $0x0, 0x64(%rsp)
je 0x2653d
movq 0x68(%rsp), %rdi
movq 0x30(%rsp), %rsi
movl $0x1, %edx
callq 0x19210
movq 0x68(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x68(%rsp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %eax, %eax
movl %eax, %edx
callq 0x186d0
movq 0x10(%rsp), %rdi
movq %rax, %rdx
movl $0x2, %esi
callq 0x18460
movl %eax, 0x74(%rsp)
jmp 0x2671f
movq 0x30(%rsp), %rax
leaq 0x887(%rip), %rcx       # 0x26dd0
movq %rcx, 0x20(%rax)
movq 0x68(%rsp), %rdi
movl $0x8, %esi
callq 0x18050
movq %rax, 0x48(%rsp)
cmpq $0x0, 0x48(%rsp)
jne 0x265a9
movq 0x68(%rsp), %rdi
movq 0x30(%rsp), %rsi
movl $0x1, %edx
callq 0x19210
movq 0x68(%rsp), %rax
movq %rax, 0x8(%rsp)
movl $0xfffffffa, %edi       # imm = 0xFFFFFFFA
callq 0x19a60
movq 0x8(%rsp), %rdi
movq %rax, %rsi
movb $0x0, %al
callq 0x19ce0
movl %eax, 0x74(%rsp)
jmp 0x2671f
movq 0x48(%rsp), %rcx
movq 0x30(%rsp), %rax
movq %rcx, 0x28(%rax)
movq 0x50(%rsp), %rax
movq 0x48(%rax), %rax
movq 0x188(%rax), %rax
movq 0x28(%rsp), %rdi
movq 0x30(%rsp), %rsi
movq 0x20(%rsp), %rdx
leaq 0x38(%rsp), %rcx
callq *%rax
movl %eax, 0x44(%rsp)
movq 0x68(%rsp), %rdi
movq 0x30(%rsp), %rsi
movl $0x1, %edx
callq 0x19210
cmpl $0x0, 0x44(%rsp)
je 0x26644
movq 0x68(%rsp), %rdi
movq 0x48(%rsp), %rsi
callq 0x18300
cmpl $0x0, 0x44(%rsp)
je 0x26635
movq 0x68(%rsp), %rdi
movl 0x44(%rsp), %edx
xorl %esi, %esi
callq 0x18a00
movq 0x68(%rsp), %rdi
callq 0x19ad0
movl %eax, 0x74(%rsp)
jmp 0x2671f
jmp 0x26637
movl $0x0, 0x74(%rsp)
jmp 0x2671f
movq 0x68(%rsp), %rdi
movl $0x3, %esi
callq 0x18f40
movq 0x68(%rsp), %rdi
movl $0xfff0b9d8, %esi       # imm = 0xFFF0B9D8
callq 0x18800
movl %eax, 0x60(%rsp)
movq 0xd692b(%rip), %rax     # 0xfcf98
cmpl $0x0, (%rax)
je 0x26685
movq 0x38(%rsp), %rsi
leaq 0xaa2bc(%rip), %rdi     # 0xd093a
movb $0x0, %al
callq 0x189d0
jmp 0x26687
movq 0x68(%rsp), %rdi
movq 0x38(%rsp), %rsi
leaq 0xaa169(%rip), %rdx     # 0xd0801
xorl %ecx, %ecx
callq 0x18350
movq %rax, 0x58(%rsp)
movl 0x60(%rsp), %ecx
movq 0x58(%rsp), %rax
movl %ecx, 0x2c(%rax)
movq 0x48(%rsp), %rcx
movq 0x58(%rsp), %rax
movq %rcx, 0x58(%rax)
movq 0x58(%rsp), %rcx
movq 0x48(%rsp), %rax
movq %rcx, (%rax)
movq 0x50(%rsp), %rcx
movq 0x58(%rsp), %rax
movq %rcx, 0x10(%rax)
movq 0x28(%rsp), %rcx
movq 0x58(%rsp), %rax
movq %rcx, 0x18(%rax)
movq 0x20(%rsp), %rcx
movq 0x58(%rsp), %rax
movq %rcx, 0x40(%rax)
movq 0x58(%rsp), %rax
leaq 0x80f(%rip), %rcx       # 0x26f10
movq %rcx, 0x8(%rax)
movq 0x50(%rsp), %rax
movq 0x48(%rax), %rcx
movq 0x58(%rsp), %rax
movq %rcx, 0x48(%rax)
movl $0x1, 0x74(%rsp)
movl 0x74(%rsp), %eax
addq $0x78, %rsp
retq
nopl (%rax,%rax)