// File: /workspace/github_cpp_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r15
movq %rdi, %r12
movq 0x50(%rsi), %rax
testq %rax, %rax
je 0x2482c
movq (%rax), %r13
movq 0x20(%rax), %rbp
jmp 0x24831
xorl %ebp, %ebp
xorl %r13d, %r13d
movq (%r15), %rbx
movq 0x40(%r15), %r14
leaq 0x5a6e8(%rip), %rsi     # 0x7ef27
movq %r12, %rdi
movq %r15, %rdx
callq 0x18ee0
leaq 0x5a6fa(%rip), %rsi     # 0x7ef4b
movq %r12, %rdi
movq %r15, %rdx
callq 0x18ee0
leaq 0x59272(%rip), %rsi     # 0x7dad5
movq %r12, %rdi
movq %r15, %rdx
callq 0x18ee0
leaq 0x5a6f2(%rip), %rsi     # 0x7ef67
movq %r12, %rdi
movq %r15, %rdx
callq 0x18ee0
leaq 0x59a71(%rip), %rsi     # 0x7e2f8
movq %r12, %rdi
movq %r15, %rdx
callq 0x18ee0
leaq 0x5a6e3(%rip), %rsi     # 0x7ef7c
movq %r12, %rdi
movq %r15, %rdx
callq 0x18ee0
leaq 0x59078(%rip), %rsi     # 0x7d923
movq %r12, %rdi
movq %r15, %rdx
callq 0x18ee0
leaq 0x59d81(%rip), %rsi     # 0x7e63e
movq %r12, %rdi
movq %r15, %rdx
callq 0x18ee0
leaq 0x5a6c7(%rip), %rsi     # 0x7ef96
movq %r12, %rdi
movq %r15, %rdx
callq 0x18ee0
leaq 0x5a6ca(%rip), %rsi     # 0x7efab
movq %r12, %rdi
movq %r15, %rdx
callq 0x18ee0
leaq 0x5a6c9(%rip), %rsi     # 0x7efbc
movq %r12, %rdi
movq %r15, %rdx
callq 0x18ee0
leaq 0x586fb(%rip), %rsi     # 0x7d000
movq %r12, %rdi
movq %r15, %rdx
callq 0x18ee0
leaq 0x59083(%rip), %rsi     # 0x7d99a
movq %r12, %rdi
movq %r15, %rdx
callq 0x18ee0
leaq 0x59082(%rip), %rsi     # 0x7d9ab
movq %r12, %rdi
movq %r15, %rdx
callq 0x18ee0
leaq 0x5a69a(%rip), %rsi     # 0x7efd5
movq %r12, %rdi
movq %r15, %rdx
callq 0x18ee0
leaq 0x5a6a1(%rip), %rsi     # 0x7efee
movq %r12, %rdi
movq %r15, %rdx
callq 0x18ee0
leaq 0x5a6a6(%rip), %rsi     # 0x7f005
movq %r12, %rdi
movq %r15, %rdx
callq 0x18ee0
leaq 0x58fc6(%rip), %rsi     # 0x7d937
movq %r12, %rdi
movq %r15, %rdx
callq 0x18ee0
leaq 0x5a281(%rip), %rsi     # 0x7ec04
movq %r12, %rdi
movq %r15, %rdx
callq 0x18ee0
leaq 0x5a188(%rip), %rsi     # 0x7eb1d
movq %r12, %rdi
movq %r15, %rdx
callq 0x18ee0
leaq 0x59068(%rip), %rsi     # 0x7da0f
movq %r12, %rdi
movq %r15, %rdx
callq 0x18ee0
leaq 0x5a02f(%rip), %rsi     # 0x7e9e8
movq %r12, %rdi
movq %r15, %rdx
callq 0x18ee0
movq 0x50(%r15), %rsi
testq %rsi, %rsi
je 0x249d5
movq %r12, %rdi
callq 0x182e0
movq %r12, %rdi
movq %r15, %rsi
callq 0x18d20
testl %eax, %eax
je 0x24a19
movq 0x965ad(%rip), %rax     # 0xbaf98
cmpl $0x0, (%rax)
je 0x24a01
leaq 0x5a625(%rip), %rdi     # 0x7f01c
movq %rbx, %rsi
xorl %eax, %eax
callq 0x18960
testq %rbp, %rbp
je 0x24a0b
movq %rbx, %rdi
callq *%rbp
testq %r13, %r13
je 0x24a19
movq %rbx, %rdi
movq %r14, %rsi
callq *%r13
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop