// File: stetre[P]moonvulkan/src/device.c
// Function: Create
static int Create(lua_State *L)
    {
    int err;
    ud_t *ud, *physdev_ud;
    VkResult ec;
    VkDevice device;
    VkDeviceCreateInfo* info;
    VkPhysicalDevice physical_device = checkphysical_device(L, 1, &physdev_ud);
    const VkAllocationCallbacks *allocator = optallocator(L, 3);
#define CLEANUP zfreeVkDeviceCreateInfo(L, info, 1)
    info = zcheckVkDeviceCreateInfo(L, 2, &err, physdev_ud);
    if(err) { CLEANUP; return argerror(L, 2); }
    ec = physdev_ud->idt->CreateDevice(physical_device, info, allocator, &device);
    if(ec) { CLEANUP; CheckError(L, ec); return 0; }
    TRACE_CREATE(device, "device");
    ud = newuserdata_dispatchable(L, device, DEVICE_MT);
    ud->parent_ud = UD(physical_device)->parent_ud; /* instance ud */
    ud->instance = UD(physical_device)->instance;
    ud->allocator = allocator;
    ud->destructor = freedevice;
    ud->ddt = getproc_device(L, device, info);
    CLEANUP;
#undef CLEANUP
    return 1;
    }

// Assembly:
subq $0x58, %rsp
movq %rdi, 0x48(%rsp)
movq 0x48(%rsp), %rdi
movl $0x1, %esi
leaq 0x30(%rsp), %rdx
leaq 0xa7c1d(%rip), %rcx     # 0xd0eac
callq 0x1a640
movq %rax, 0x10(%rsp)
movq 0x48(%rsp), %rdi
movl $0x3, %esi
callq 0x19260
movq %rax, 0x8(%rsp)
movq 0x48(%rsp), %rdi
movq 0x30(%rsp), %rcx
movl $0x2, %esi
leaq 0x44(%rsp), %rdx
callq 0x1a480
movq %rax, 0x18(%rsp)
cmpl $0x0, 0x44(%rsp)
je 0x2931c
movq 0x48(%rsp), %rdi
movq 0x18(%rsp), %rsi
movl $0x1, %edx
callq 0x19210
movq 0x48(%rsp), %rax
movq %rax, (%rsp)
movq 0x48(%rsp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %eax, %eax
movl %eax, %edx
callq 0x186d0
movq (%rsp), %rdi
movq %rax, %rdx
movl $0x2, %esi
callq 0x18460
movl %eax, 0x54(%rsp)
jmp 0x29462
movq 0x30(%rsp), %rax
movq 0x48(%rax), %rax
movq 0x50(%rax), %rax
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq 0x8(%rsp), %rdx
leaq 0x20(%rsp), %rcx
callq *%rax
movl %eax, 0x2c(%rsp)
cmpl $0x0, 0x2c(%rsp)
je 0x29397
movq 0x48(%rsp), %rdi
movq 0x18(%rsp), %rsi
movl $0x1, %edx
callq 0x19210
cmpl $0x0, 0x2c(%rsp)
je 0x29388
movq 0x48(%rsp), %rdi
movl 0x2c(%rsp), %edx
xorl %esi, %esi
callq 0x18a00
movq 0x48(%rsp), %rdi
callq 0x19ad0
movl %eax, 0x54(%rsp)
jmp 0x29462
jmp 0x2938a
movl $0x0, 0x54(%rsp)
jmp 0x29462
jmp 0x29399
movq 0xd3bf8(%rip), %rax     # 0xfcf98
cmpl $0x0, (%rax)
je 0x293b8
movq 0x20(%rsp), %rsi
leaq 0xa7b16(%rip), %rdi     # 0xd0ec7
movb $0x0, %al
callq 0x189d0
jmp 0x293ba
movq 0x48(%rsp), %rdi
movq 0x20(%rsp), %rsi
leaq 0xa5c70(%rip), %rdx     # 0xcf03b
movl $0x1, %ecx
callq 0x18350
movq %rax, 0x38(%rsp)
movq 0x10(%rsp), %rdi
callq 0x19fd0
movq 0x10(%rax), %rcx
movq 0x38(%rsp), %rax
movq %rcx, 0x10(%rax)
movq 0x10(%rsp), %rdi
callq 0x19fd0
movq 0x18(%rax), %rcx
movq 0x38(%rsp), %rax
movq %rcx, 0x18(%rax)
movq 0x8(%rsp), %rcx
movq 0x38(%rsp), %rax
movq %rcx, 0x40(%rax)
movq 0x38(%rsp), %rax
leaq 0x94e(%rip), %rcx       # 0x29d70
movq %rcx, 0x8(%rax)
movq 0x48(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq 0x18(%rsp), %rdx
callq 0x18ce0
movq %rax, %rcx
movq 0x38(%rsp), %rax
movq %rcx, 0x50(%rax)
movq 0x48(%rsp), %rdi
movq 0x18(%rsp), %rsi
movl $0x1, %edx
callq 0x19210
movl $0x1, 0x54(%rsp)
movl 0x54(%rsp), %eax
addq $0x58, %rsp
retq
nopl (%rax,%rax)