// File: stetre[P]moonvulkan/src/flags.c
// Function: checkshaderstageflags
static VkFlags checkshaderstageflags(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_SHADER_STAGE_VERTEX_BIT, "vertex");
    CASE(VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, "tessellation control");
    CASE(VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, "tessellation evaluation");
    CASE(VK_SHADER_STAGE_GEOMETRY_BIT, "geometry");
    CASE(VK_SHADER_STAGE_FRAGMENT_BIT, "fragment");
    CASE(VK_SHADER_STAGE_COMPUTE_BIT, "compute");
    CASE(VK_SHADER_STAGE_RAYGEN_BIT, "raygen");
    CASE(VK_SHADER_STAGE_ANY_HIT_BIT, "any hit");
    CASE(VK_SHADER_STAGE_CLOSEST_HIT_BIT, "closest hit");
    CASE(VK_SHADER_STAGE_MISS_BIT, "miss");
    CASE(VK_SHADER_STAGE_INTERSECTION_BIT, "intersection");
    CASE(VK_SHADER_STAGE_CALLABLE_BIT, "callable");
    // These are not individual bits:
    CASE(VK_SHADER_STAGE_ALL_GRAPHICS, "all graphics");
    CASE(VK_SHADER_STAGE_ALL, "all");
#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 0x48e61
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 0x905ab(%rip), %rsi     # 0xd9193
callq 0x190a0
cmpl $0x0, %eax
jne 0x48c04
jmp 0x48bf4
movl 0x14(%rsp), %eax
orl $0x1, %eax
movl %eax, 0x14(%rsp)
jmp 0x48e5c
movq 0x18(%rsp), %rdi
leaq 0x95301(%rip), %rsi     # 0xddf11
callq 0x190a0
cmpl $0x0, %eax
jne 0x48c2c
jmp 0x48c1c
movl 0x14(%rsp), %eax
orl $0x2, %eax
movl %eax, 0x14(%rsp)
jmp 0x48e5c
movq 0x18(%rsp), %rdi
leaq 0x952ee(%rip), %rsi     # 0xddf26
callq 0x190a0
cmpl $0x0, %eax
jne 0x48c54
jmp 0x48c44
movl 0x14(%rsp), %eax
orl $0x4, %eax
movl %eax, 0x14(%rsp)
jmp 0x48e5c
movq 0x18(%rsp), %rdi
leaq 0x952de(%rip), %rsi     # 0xddf3e
callq 0x190a0
cmpl $0x0, %eax
jne 0x48c7c
jmp 0x48c6c
movl 0x14(%rsp), %eax
orl $0x8, %eax
movl %eax, 0x14(%rsp)
jmp 0x48e5c
movq 0x18(%rsp), %rdi
leaq 0x952bf(%rip), %rsi     # 0xddf47
callq 0x190a0
cmpl $0x0, %eax
jne 0x48ca4
jmp 0x48c94
movl 0x14(%rsp), %eax
orl $0x10, %eax
movl %eax, 0x14(%rsp)
jmp 0x48e5c
movq 0x18(%rsp), %rdi
leaq 0x8e3a3(%rip), %rsi     # 0xd7053
callq 0x190a0
cmpl $0x0, %eax
jne 0x48ccc
jmp 0x48cbc
movl 0x14(%rsp), %eax
orl $0x20, %eax
movl %eax, 0x14(%rsp)
jmp 0x48e5c
movq 0x18(%rsp), %rdi
leaq 0x95278(%rip), %rsi     # 0xddf50
callq 0x190a0
cmpl $0x0, %eax
jne 0x48cf6
jmp 0x48ce4
movl 0x14(%rsp), %eax
orl $0x100, %eax            # imm = 0x100
movl %eax, 0x14(%rsp)
jmp 0x48e5c
movq 0x18(%rsp), %rdi
leaq 0x90812(%rip), %rsi     # 0xd9514
callq 0x190a0
cmpl $0x0, %eax
jne 0x48d20
jmp 0x48d0e
movl 0x14(%rsp), %eax
orl $0x200, %eax            # imm = 0x200
movl %eax, 0x14(%rsp)
jmp 0x48e5c
movq 0x18(%rsp), %rdi
leaq 0x907bc(%rip), %rsi     # 0xd94e8
callq 0x190a0
cmpl $0x0, %eax
jne 0x48d4a
jmp 0x48d38
movl 0x14(%rsp), %eax
orl $0x400, %eax            # imm = 0x400
movl %eax, 0x14(%rsp)
jmp 0x48e5c
movq 0x18(%rsp), %rdi
leaq 0x95201(%rip), %rsi     # 0xddf57
callq 0x190a0
cmpl $0x0, %eax
jne 0x48d74
jmp 0x48d62
movl 0x14(%rsp), %eax
orl $0x800, %eax            # imm = 0x800
movl %eax, 0x14(%rsp)
jmp 0x48e5c
movq 0x18(%rsp), %rdi
leaq 0x907b8(%rip), %rsi     # 0xd9538
callq 0x190a0
cmpl $0x0, %eax
jne 0x48d9e
jmp 0x48d8c
movl 0x14(%rsp), %eax
orl $0x1000, %eax           # imm = 0x1000
movl %eax, 0x14(%rsp)
jmp 0x48e5c
movq 0x18(%rsp), %rdi
leaq 0x951b2(%rip), %rsi     # 0xddf5c
callq 0x190a0
cmpl $0x0, %eax
jne 0x48dc8
jmp 0x48db6
movl 0x14(%rsp), %eax
orl $0x2000, %eax           # imm = 0x2000
movl %eax, 0x14(%rsp)
jmp 0x48e5c
movq 0x18(%rsp), %rdi
leaq 0x95191(%rip), %rsi     # 0xddf65
callq 0x190a0
cmpl $0x0, %eax
jne 0x48ded
jmp 0x48de0
movl 0x14(%rsp), %eax
orl $0x1f, %eax
movl %eax, 0x14(%rsp)
jmp 0x48e5c
movq 0x18(%rsp), %rdi
leaq 0x8ed76(%rip), %rsi     # 0xd7b6f
callq 0x190a0
cmpl $0x0, %eax
jne 0x48e14
jmp 0x48e05
movl 0x14(%rsp), %eax
orl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, 0x14(%rsp)
jmp 0x48e5c
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 0x88b92(%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 0x48e69
jmp 0x48ba5
movl 0x14(%rsp), %eax
movl %eax, 0x34(%rsp)
movl 0x34(%rsp), %eax
addq $0x38, %rsp
retq
nopw %cs:(%rax,%rax)