// File: stetre[P]moonvulkan/src/physical_device.c
// Function: GetPhysicalDeviceFragmentShadingRates
static int GetPhysicalDeviceFragmentShadingRates(lua_State *L)
    {
    int err;
    VkResult ec;
    uint32_t i, count = 0;
    ud_t *ud;
    VkPhysicalDeviceFragmentShadingRateKHR *rates = NULL;
    VkPhysicalDevice physical_device = checkphysical_device(L, 1, &ud);
    CheckInstancePfn(L, ud, GetPhysicalDeviceFragmentShadingRatesKHR);
    ec = ud->idt->GetPhysicalDeviceFragmentShadingRatesKHR(physical_device, &count, NULL);
    if(ec) { CheckError(L, ec); return 0; }
    lua_newtable(L);
    if(count == 0) return 1;
#define CLEANUP zfreearrayVkPhysicalDeviceFragmentShadingRateKHR(L, rates, count, 1)
    rates = znewchainarrayVkPhysicalDeviceFragmentShadingRateKHR(L, count, &err);
    if(err) { CLEANUP; return lua_error(L); }
    ec = ud->idt->GetPhysicalDeviceFragmentShadingRatesKHR(physical_device, &count, rates);
    if(ec) { CLEANUP; CheckError(L, ec); return 0; }
    for(i=0; i<count; i++)
        {
        zpushVkPhysicalDeviceFragmentShadingRateKHR(L, &rates[i]);
        lua_rawseti(L, -2, i+1);
        }
    CLEANUP;
#undef CLEANUP
    return 1;
    }

// Assembly:
subq $0x38, %rsp
movq %rdi, 0x28(%rsp)
movl $0x0, 0x18(%rsp)
movq $0x0, 0x8(%rsp)
movq 0x28(%rsp), %rdi
movl $0x1, %esi
leaq 0x10(%rsp), %rdx
leaq 0x746fc(%rip), %rcx     # 0xd0eac
callq 0x1a640
movq %rax, (%rsp)
movq 0x10(%rsp), %rax
movq 0x48(%rax), %rax
cmpq $0x0, 0x1e8(%rax)
jne 0x5c7e8
movq 0x28(%rsp), %rdi
leaq 0x86246(%rip), %rsi     # 0xe2a1e
movb $0x0, %al
callq 0x19ce0
movl %eax, 0x34(%rsp)
jmp 0x5c9b9
jmp 0x5c7ea
movq 0x10(%rsp), %rax
movq 0x48(%rax), %rax
movq 0x1e8(%rax), %rax
movq (%rsp), %rdi
leaq 0x18(%rsp), %rsi
xorl %ecx, %ecx
movl %ecx, %edx
callq *%rax
movl %eax, 0x20(%rsp)
cmpl $0x0, 0x20(%rsp)
je 0x5c84f
jmp 0x5c816
cmpl $0x0, 0x20(%rsp)
je 0x5c840
movq 0x28(%rsp), %rdi
movl 0x20(%rsp), %edx
xorl %esi, %esi
callq 0x18a00
movq 0x28(%rsp), %rdi
callq 0x19ad0
movl %eax, 0x34(%rsp)
jmp 0x5c9b9
jmp 0x5c842
movl $0x0, 0x34(%rsp)
jmp 0x5c9b9
movq 0x28(%rsp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x18830
cmpl $0x0, 0x18(%rsp)
jne 0x5c871
movl $0x1, 0x34(%rsp)
jmp 0x5c9b9
movq 0x28(%rsp), %rdi
movl 0x18(%rsp), %esi
leaq 0x24(%rsp), %rdx
callq 0x18420
movq %rax, 0x8(%rsp)
cmpl $0x0, 0x24(%rsp)
je 0x5c8c1
movq 0x28(%rsp), %rdi
movq 0x8(%rsp), %rsi
movl 0x18(%rsp), %ecx
movl $0x20, %edx
movl $0x1, %r8d
callq 0x198d0
movq 0x28(%rsp), %rdi
callq 0x19ad0
movl %eax, 0x34(%rsp)
jmp 0x5c9b9
movq 0x10(%rsp), %rax
movq 0x48(%rax), %rax
movq 0x1e8(%rax), %rax
movq (%rsp), %rdi
movq 0x8(%rsp), %rdx
leaq 0x18(%rsp), %rsi
callq *%rax
movl %eax, 0x20(%rsp)
cmpl $0x0, 0x20(%rsp)
je 0x5c940
movq 0x28(%rsp), %rdi
movq 0x8(%rsp), %rsi
movl 0x18(%rsp), %ecx
movl $0x20, %edx
movl $0x1, %r8d
callq 0x198d0
cmpl $0x0, 0x20(%rsp)
je 0x5c934
movq 0x28(%rsp), %rdi
movl 0x20(%rsp), %edx
xorl %esi, %esi
callq 0x18a00
movq 0x28(%rsp), %rdi
callq 0x19ad0
movl %eax, 0x34(%rsp)
jmp 0x5c9b9
jmp 0x5c936
movl $0x0, 0x34(%rsp)
jmp 0x5c9b9
movl $0x0, 0x1c(%rsp)
movl 0x1c(%rsp), %eax
cmpl 0x18(%rsp), %eax
jae 0x5c993
movq 0x28(%rsp), %rdi
movq 0x8(%rsp), %rsi
movl 0x1c(%rsp), %eax
shlq $0x5, %rax
addq %rax, %rsi
callq 0x195b0
movq 0x28(%rsp), %rdi
movl 0x1c(%rsp), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %edx
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x191e0
movl 0x1c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1c(%rsp)
jmp 0x5c948
movq 0x28(%rsp), %rdi
movq 0x8(%rsp), %rsi
movl 0x18(%rsp), %ecx
movl $0x20, %edx
movl $0x1, %r8d
callq 0x198d0
movl $0x1, 0x34(%rsp)
movl 0x34(%rsp), %eax
addq $0x38, %rsp
retq
nopw %cs:(%rax,%rax)