// File: stetre[P]moonvulkan/src/flags.c
// Function: checkimageusageflags
static VkFlags checkimageusageflags(lua_State *L, int arg)
    {
    const char *s;
    VkFlags flags = 0;

    while(lua_isstring(L, arg))
        {
        s = lua_tostring(L, arg++);
#define CASE(CODE,str) if((strcmp(s, str)==0)) do { flags |= CODE; goto done; } while(0)
        CASE(VK_IMAGE_USAGE_TRANSFER_SRC_BIT, "transfer src");
        CASE(VK_IMAGE_USAGE_TRANSFER_DST_BIT, "transfer dst");
        CASE(VK_IMAGE_USAGE_SAMPLED_BIT, "sampled");
        CASE(VK_IMAGE_USAGE_STORAGE_BIT, "storage");
        CASE(VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, "color attachment");
        CASE(VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, "depth stencil attachment");
        CASE(VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, "transient attachment");
        CASE(VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT, "input attachment");
        CASE(VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT, "fragment density map");
#undef CASE
        return (VkFlags)luaL_argerror(L, --arg, badvalue(L,s));
        done: ;
        }

    return flags;
    }

// Assembly:
subq $0x38, %rsp
movq %rdi, 0x28(%rsp)
movl %esi, 0x24(%rsp)
movl $0x0, 0x14(%rsp)
movq 0x28(%rsp), %rdi
movl 0x24(%rsp), %esi
callq 0x1a7a0
cmpl $0x0, %eax
je 0x4cc2f
movq 0x28(%rsp), %rdi
movl 0x24(%rsp), %esi
movl %esi, %eax
addl $0x1, %eax
movl %eax, 0x24(%rsp)
xorl %eax, %eax
movl %eax, %edx
callq 0x186d0
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rdi
leaq 0x916b4(%rip), %rsi     # 0xde13c
callq 0x190a0
cmpl $0x0, %eax
jne 0x4caa4
jmp 0x4ca94
movl 0x14(%rsp), %eax
orl $0x1, %eax
movl %eax, 0x14(%rsp)
jmp 0x4cc2a
movq 0x18(%rsp), %rdi
leaq 0x91699(%rip), %rsi     # 0xde149
callq 0x190a0
cmpl $0x0, %eax
jne 0x4cacc
jmp 0x4cabc
movl 0x14(%rsp), %eax
orl $0x2, %eax
movl %eax, 0x14(%rsp)
jmp 0x4cc2a
movq 0x18(%rsp), %rdi
leaq 0x91c2b(%rip), %rsi     # 0xde703
callq 0x190a0
cmpl $0x0, %eax
jne 0x4caf4
jmp 0x4cae4
movl 0x14(%rsp), %eax
orl $0x4, %eax
movl %eax, 0x14(%rsp)
jmp 0x4cc2a
movq 0x18(%rsp), %rdi
leaq 0x9171f(%rip), %rsi     # 0xde21f
callq 0x190a0
cmpl $0x0, %eax
jne 0x4cb1c
jmp 0x4cb0c
movl 0x14(%rsp), %eax
orl $0x8, %eax
movl %eax, 0x14(%rsp)
jmp 0x4cc2a
movq 0x18(%rsp), %rdi
leaq 0x91be3(%rip), %rsi     # 0xde70b
callq 0x190a0
cmpl $0x0, %eax
jne 0x4cb44
jmp 0x4cb34
movl 0x14(%rsp), %eax
orl $0x10, %eax
movl %eax, 0x14(%rsp)
jmp 0x4cc2a
movq 0x18(%rsp), %rdi
leaq 0x91bcc(%rip), %rsi     # 0xde71c
callq 0x190a0
cmpl $0x0, %eax
jne 0x4cb6c
jmp 0x4cb5c
movl 0x14(%rsp), %eax
orl $0x20, %eax
movl %eax, 0x14(%rsp)
jmp 0x4cc2a
movq 0x18(%rsp), %rdi
leaq 0x91bbd(%rip), %rsi     # 0xde735
callq 0x190a0
cmpl $0x0, %eax
jne 0x4cb94
jmp 0x4cb84
movl 0x14(%rsp), %eax
orl $0x40, %eax
movl %eax, 0x14(%rsp)
jmp 0x4cc2a
movq 0x18(%rsp), %rdi
leaq 0x8a320(%rip), %rsi     # 0xd6ec0
callq 0x190a0
cmpl $0x0, %eax
jne 0x4cbbb
jmp 0x4cbac
movl 0x14(%rsp), %eax
orl $0x80, %eax
movl %eax, 0x14(%rsp)
jmp 0x4cc2a
movq 0x18(%rsp), %rdi
leaq 0x91b83(%rip), %rsi     # 0xde74a
callq 0x190a0
cmpl $0x0, %eax
jne 0x4cbe2
jmp 0x4cbd3
movl 0x14(%rsp), %eax
orl $0x200, %eax            # imm = 0x200
movl %eax, 0x14(%rsp)
jmp 0x4cc2a
movq 0x28(%rsp), %rax
movq %rax, 0x8(%rsp)
movl 0x24(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x10(%rsp)
movl %eax, 0x24(%rsp)
movq 0x28(%rsp), %rdi
movq 0x18(%rsp), %rdx
leaq 0x84dc4(%rip), %rsi     # 0xd19d0
movb $0x0, %al
callq 0x18f50
movq 0x8(%rsp), %rdi
movl 0x10(%rsp), %esi
movq %rax, %rdx
callq 0x18460
movl %eax, 0x34(%rsp)
jmp 0x4cc37
jmp 0x4ca45
movl 0x14(%rsp), %eax
movl %eax, 0x34(%rsp)
movl 0x34(%rsp), %eax
addq $0x38, %rsp
retq