// File: stetre[P]moonvulkan/src/device.c
// Function: freedevice
static int freedevice(lua_State *L, ud_t *ud)
    {
    VkDevice device = (VkDevice)(uintptr_t)ud->handle;
    const VkAllocationCallbacks *allocator = ud->allocator;
    PFN_vkDeviceWaitIdle DeviceWaitIdle = NULL;
    PFN_vkDestroyDevice DestroyDevice = NULL;
    if(ud->ddt)
        {
        DeviceWaitIdle = ud->ddt->DeviceWaitIdle;
        DestroyDevice = ud->ddt->DestroyDevice;
        }
    freechildren(L, SAMPLER_YCBCR_CONVERSION_MT, ud);
    freechildren(L, VALIDATION_CACHE_MT, ud);
    freechildren(L, DESCRIPTOR_UPDATE_TEMPLATE_MT, ud);
    freechildren(L, SWAPCHAIN_MT, ud);
    freechildren(L, COMMAND_POOL_MT, ud);
    freechildren(L, PIPELINE_CACHE_MT, ud);
    freechildren(L, PIPELINE_MT, ud);
    freechildren(L, SAMPLER_MT, ud);
    freechildren(L, SEMAPHORE_MT, ud);
    freechildren(L, FENCE_MT, ud);
    freechildren(L, DEVICE_MEMORY_MT, ud);
    freechildren(L, BUFFER_MT, ud);
    freechildren(L, IMAGE_MT, ud);
    freechildren(L, EVENT_MT, ud);
    freechildren(L, SHADER_MODULE_MT, ud);
    freechildren(L, FRAMEBUFFER_MT, ud);
    freechildren(L, RENDER_PASS_MT, ud);
    freechildren(L, PIPELINE_LAYOUT_MT, ud);
    freechildren(L, DESCRIPTOR_SET_LAYOUT_MT, ud);
    freechildren(L, DESCRIPTOR_POOL_MT, ud);
    freechildren(L, QUERY_POOL_MT, ud);
    freechildren(L, QUEUE_MT, ud);
    if(ud->ddt) Free(L, ud->ddt);
    if(!freeuserdata(L, ud))
        return 0; /* double call */
    TRACE_DELETE(device, "device");
    if(DeviceWaitIdle) DeviceWaitIdle(device);
    if(DestroyDevice) DestroyDevice(device, allocator);
    return 0;
    }

// Assembly:
subq $0x38, %rsp
movq %rdi, 0x28(%rsp)
movq %rsi, 0x20(%rsp)
movq 0x20(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x18(%rsp)
movq 0x20(%rsp), %rax
movq 0x40(%rax), %rax
movq %rax, 0x10(%rsp)
movq $0x0, 0x8(%rsp)
movq $0x0, (%rsp)
movq 0x20(%rsp), %rax
cmpq $0x0, 0x50(%rax)
je 0x29dd8
movq 0x20(%rsp), %rax
movq 0x50(%rax), %rax
movq 0x20(%rax), %rax
movq %rax, 0x8(%rsp)
movq 0x20(%rsp), %rax
movq 0x50(%rax), %rax
movq (%rax), %rax
movq %rax, (%rsp)
movq 0x28(%rsp), %rdi
movq 0x20(%rsp), %rdx
leaq 0xa70f6(%rip), %rsi     # 0xd0edf
callq 0x18fa0
movq 0x28(%rsp), %rdi
movq 0x20(%rsp), %rdx
leaq 0xa7104(%rip), %rsi     # 0xd0f03
callq 0x18fa0
movq 0x28(%rsp), %rdi
movq 0x20(%rsp), %rdx
leaq 0xa5cc0(%rip), %rsi     # 0xcfad5
callq 0x18fa0
movq 0x28(%rsp), %rdi
movq 0x20(%rsp), %rdx
leaq 0xa70f4(%rip), %rsi     # 0xd0f1f
callq 0x18fa0
movq 0x28(%rsp), %rdi
movq 0x20(%rsp), %rdx
leaq 0xa64b7(%rip), %rsi     # 0xd02f8
callq 0x18fa0
movq 0x28(%rsp), %rdi
movq 0x20(%rsp), %rdx
leaq 0xa70dd(%rip), %rsi     # 0xd0f34
callq 0x18fa0
movq 0x28(%rsp), %rdi
movq 0x20(%rsp), %rdx
leaq 0xa5ab6(%rip), %rsi     # 0xcf923
callq 0x18fa0
movq 0x28(%rsp), %rdi
movq 0x20(%rsp), %rdx
leaq 0xa6773(%rip), %rsi     # 0xd05f6
callq 0x18fa0
movq 0x28(%rsp), %rdi
movq 0x20(%rsp), %rdx
leaq 0xa70b5(%rip), %rsi     # 0xd0f4e
callq 0x18fa0
movq 0x28(%rsp), %rdi
movq 0x20(%rsp), %rdx
leaq 0xa70b4(%rip), %rsi     # 0xd0f63
callq 0x18fa0
movq 0x28(%rsp), %rdi
movq 0x20(%rsp), %rdx
leaq 0xa70af(%rip), %rsi     # 0xd0f74
callq 0x18fa0
movq 0x28(%rsp), %rdi
movq 0x20(%rsp), %rdx
leaq 0xa5125(%rip), %rsi     # 0xcf000
callq 0x18fa0
movq 0x28(%rsp), %rdi
movq 0x20(%rsp), %rdx
leaq 0xa5aa9(%rip), %rsi     # 0xcf99a
callq 0x18fa0
movq 0x28(%rsp), %rdi
movq 0x20(%rsp), %rdx
leaq 0xa5aa4(%rip), %rsi     # 0xcf9ab
callq 0x18fa0
movq 0x28(%rsp), %rdi
movq 0x20(%rsp), %rdx
leaq 0xa7070(%rip), %rsi     # 0xd0f8d
callq 0x18fa0
movq 0x28(%rsp), %rdi
movq 0x20(%rsp), %rdx
leaq 0xa7073(%rip), %rsi     # 0xd0fa6
callq 0x18fa0
movq 0x28(%rsp), %rdi
movq 0x20(%rsp), %rdx
leaq 0xa7074(%rip), %rsi     # 0xd0fbd
callq 0x18fa0
movq 0x28(%rsp), %rdi
movq 0x20(%rsp), %rdx
leaq 0xa59d8(%rip), %rsi     # 0xcf937
callq 0x18fa0
movq 0x28(%rsp), %rdi
movq 0x20(%rsp), %rdx
leaq 0xa6c47(%rip), %rsi     # 0xd0bbc
callq 0x18fa0
movq 0x28(%rsp), %rdi
movq 0x20(%rsp), %rdx
leaq 0xa6b4a(%rip), %rsi     # 0xd0ad5
callq 0x18fa0
movq 0x28(%rsp), %rdi
movq 0x20(%rsp), %rdx
leaq 0xa5a6e(%rip), %rsi     # 0xcfa0f
callq 0x18fa0
movq 0x28(%rsp), %rdi
movq 0x20(%rsp), %rdx
leaq 0xa69e9(%rip), %rsi     # 0xd09a0
callq 0x18fa0
movq 0x20(%rsp), %rax
cmpq $0x0, 0x50(%rax)
je 0x29fdb
movq 0x28(%rsp), %rdi
movq 0x20(%rsp), %rax
movq 0x50(%rax), %rsi
callq 0x18300
movq 0x28(%rsp), %rdi
movq 0x20(%rsp), %rsi
callq 0x18dc0
cmpl $0x0, %eax
jne 0x29ff9
movl $0x0, 0x34(%rsp)
jmp 0x2a04f
jmp 0x29ffb
movq 0xd2f96(%rip), %rax     # 0xfcf98
cmpl $0x0, (%rax)
je 0x2a01a
movq 0x18(%rsp), %rsi
leaq 0xa6fc1(%rip), %rdi     # 0xd0fd4
movb $0x0, %al
callq 0x189d0
jmp 0x2a01c
cmpq $0x0, 0x8(%rsp)
je 0x2a030
movq 0x8(%rsp), %rax
movq 0x18(%rsp), %rdi
callq *%rax
cmpq $0x0, (%rsp)
je 0x2a047
movq (%rsp), %rax
movq 0x18(%rsp), %rdi
movq 0x10(%rsp), %rsi
callq *%rax
movl $0x0, 0x34(%rsp)
movl 0x34(%rsp), %eax
addq $0x38, %rsp
retq
nopl (%rax,%rax)