// File: /workspace/github_cpp_makefile_star2_O1/stetre[P]moonvulkan/src/device.c
// Function: GetCalibratedTimestamps
static int GetCalibratedTimestamps(lua_State *L)
    {
    ud_t *ud;
    int err;
    VkResult ec;
    uint32_t i, count;
    VkCalibratedTimestampInfoEXT *infos = NULL;
    uint64_t* timestamps = NULL;
    uint64_t* maxdeviations = NULL;
    VkDevice device = checkdevice(L, 1, &ud);
    CheckDevicePfn(L, ud, GetCalibratedTimestampsEXT);

#define CLEANUP do {                                                        \
    if(infos) zfreearrayVkCalibratedTimestampInfoEXT(L, infos, count, 1);   \
    if(timestamps) Free(L, timestamps);                                     \
    if(maxdeviations) Free(L, maxdeviations);                               \
} while(0)
    infos = zcheckarrayVkCalibratedTimestampInfoEXT(L, 2, &count, &err);
    if(err) { CLEANUP; return argerror(L, 2); }
    timestamps = (uint64_t*)MallocNoErr(L, sizeof(uint64_t)*count);
    if(!timestamps) { CLEANUP; return errmemory(L); }
    maxdeviations = (uint64_t*)MallocNoErr(L, sizeof(uint64_t)*count);
    if(!maxdeviations) { CLEANUP; return errmemory(L); }

    ec = ud->ddt->GetCalibratedTimestampsEXT(device, count, infos, timestamps, maxdeviations);
    if(ec) { CLEANUP; CheckError(L, ec); return 0; }

    lua_newtable(L);
    lua_newtable(L);
    for(i=0; i<count; i++)
        {
        lua_pushinteger(L, timestamps[i]);
        lua_rawseti(L, -3, i+1);
        lua_pushinteger(L, maxdeviations[i]);
        lua_rawseti(L, -2, i+1);
        }
    CLEANUP;
#undef CLEANUP
    return 2;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
leaq 0x6a20a(%rip), %rcx     # 0x8f03b
leaq 0x8(%rsp), %r14
movl $0x1, %esi
movq %r14, %rdx
callq 0x1a520
movq %rax, %r13
movq (%r14), %rax
movq 0x50(%rax), %rax
cmpq $0x0, 0x5a0(%rax)
je 0x24ebd
leaq 0x4(%rsp), %rdx
leaq 0x14(%rsp), %r15
movq %rbx, %rdi
movl $0x2, %esi
movq %r15, %rcx
callq 0x19ae0
movq %rax, %r14
cmpl $0x0, (%r15)
je 0x24ecc
testq %r14, %r14
je 0x24e99
movl 0x4(%rsp), %ecx
movl $0x18, %edx
movq %rbx, %rdi
movq %r14, %rsi
movl $0x1, %r8d
callq 0x19800
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %edx, %edx
callq 0x18690
movq %rbx, %rdi
movl $0x2, %esi
movq %rax, %rdx
callq 0x18420
jmp 0x24fda
leaq 0x6c186(%rip), %rsi     # 0x9104a
movq %rbx, %rdi
jmp 0x24fd3
movl 0x4(%rsp), %esi
shlq $0x3, %rsi
movq %rbx, %rdi
callq 0x18050
testq %rax, %rax
je 0x24f78
movq %rax, %r15
movl 0x4(%rsp), %esi
shlq $0x3, %rsi
movq %rbx, %rdi
callq 0x18050
testq %rax, %rax
je 0x24f99
movq %rax, %r12
movq 0x8(%rsp), %rax
movq 0x50(%rax), %rax
movl 0x4(%rsp), %esi
movq %r13, %rdi
movq %r14, %rdx
movq %r15, %rcx
movq %r12, %r8
callq *0x5a0(%rax)
testl %eax, %eax
je 0x24fe9
movl %eax, %ebp
testq %r14, %r14
je 0x24f4c
movl 0x4(%rsp), %ecx
movl $0x18, %edx
movq %rbx, %rdi
movq %r14, %rsi
movl $0x1, %r8d
callq 0x19800
movq %rbx, %rdi
movq %r15, %rsi
callq 0x182e0
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 0x24fda
testq %r14, %r14
je 0x24fc3
movl 0x4(%rsp), %ecx
movl $0x18, %edx
movq %rbx, %rdi
movq %r14, %rsi
movl $0x1, %r8d
callq 0x19800
jmp 0x24fc3
testq %r14, %r14
je 0x24fb8
movl 0x4(%rsp), %ecx
movl $0x18, %edx
movq %rbx, %rdi
movq %r14, %rsi
movl $0x1, %r8d
callq 0x19800
movq %rbx, %rdi
movq %r15, %rsi
callq 0x182e0
movl $0xfffffffa, %edi       # imm = 0xFFFFFFFA
callq 0x19970
movq %rbx, %rdi
movq %rax, %rsi
xorl %eax, %eax
callq 0x19be0
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x187e0
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x187e0
movl 0x4(%rsp), %ecx
testl %ecx, %ecx
je 0x25053
xorl %ebp, %ebp
movq (%r15,%rbp,8), %rsi
movq %rbx, %rdi
callq 0x18b60
leaq 0x1(%rbp), %r13
movq %rbx, %rdi
movl $0xfffffffd, %esi       # imm = 0xFFFFFFFD
movq %r13, %rdx
callq 0x19140
movq (%r12,%rbp,8), %rsi
movq %rbx, %rdi
callq 0x18b60
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
movq %r13, %rdx
callq 0x19140
movl 0x4(%rsp), %ecx
movq %r13, %rbp
cmpq %rcx, %r13
jb 0x2500b
testq %r14, %r14
je 0x2506e
movl $0x18, %edx
movq %rbx, %rdi
movq %r14, %rsi
movl $0x1, %r8d
callq 0x19800
movq %rbx, %rdi
movq %r15, %rsi
callq 0x182e0
movq %rbx, %rdi
movq %r12, %rsi
callq 0x182e0
movl $0x2, %eax
jmp 0x24fda