// File: /workspace/github_c_makefile_star2_O0/janet-lang[P]janet/src/core/io.c
// Function: checkflags
static int32_t checkflags(const uint8_t *str) {
    int32_t flags = 0;
    int32_t i;
    int32_t len = janet_string_length(str);
    if (!len || len > 10)
        janet_panic("file mode must have a length between 1 and 10");
    switch (*str) {
        default:
            janet_panicf("invalid flag %c, expected w, a, or r", *str);
            break;
        case 'w':
            flags |= JANET_FILE_WRITE;
            janet_sandbox_assert(JANET_SANDBOX_FS_WRITE);
            break;
        case 'a':
            flags |= JANET_FILE_APPEND;
            janet_sandbox_assert(JANET_SANDBOX_FS);
            break;
        case 'r':
            flags |= JANET_FILE_READ;
            janet_sandbox_assert(JANET_SANDBOX_FS_READ);
            break;
    }
    for (i = 1; i < len; i++) {
        switch (str[i]) {
            default:
                janet_panicf("invalid flag %c, expected +, b, or n", str[i]);
                break;
            case '+':
                if (flags & JANET_FILE_UPDATE) return -1;
                janet_sandbox_assert(JANET_SANDBOX_FS_WRITE);
                flags |= JANET_FILE_UPDATE;
                break;
            case 'b':
                if (flags & JANET_FILE_BINARY) return -1;
                flags |= JANET_FILE_BINARY;
                break;
            case 'n':
                if (flags & JANET_FILE_NONIL) return -1;
                flags |= JANET_FILE_NONIL;
                break;
        }
    }
    return flags;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
movq -0x10(%rbp), %rax
movl -0x8(%rax), %eax
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x3e419
cmpl $0xa, -0x1c(%rbp)
jle 0x3e425
leaq 0x4e229(%rip), %rdi     # 0x8c649
callq 0x1ad60
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
movl %eax, -0x20(%rbp)
subl $0x61, %eax
je 0x3e474
jmp 0x3e436
movl -0x20(%rbp), %eax
subl $0x72, %eax
je 0x3e489
jmp 0x3e440
movl -0x20(%rbp), %eax
subl $0x77, %eax
je 0x3e45f
jmp 0x3e44a
movq -0x10(%rbp), %rax
movzbl (%rax), %esi
leaq 0x4e21f(%rip), %rdi     # 0x8c677
movb $0x0, %al
callq 0x1ac40
movl -0x14(%rbp), %eax
orl $0x1, %eax
movl %eax, -0x14(%rbp)
movl $0x20, %edi
callq 0x7ab10
jmp 0x3e49c
movl -0x14(%rbp), %eax
orl $0x4, %eax
movl %eax, -0x14(%rbp)
movl $0x460, %edi            # imm = 0x460
callq 0x7ab10
jmp 0x3e49c
movl -0x14(%rbp), %eax
orl $0x2, %eax
movl %eax, -0x14(%rbp)
movl $0x40, %edi
callq 0x7ab10
movl $0x1, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x3e56c
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movl %eax, -0x24(%rbp)
subl $0x2b, %eax
je 0x3e4f3
jmp 0x3e4c5
movl -0x24(%rbp), %eax
subl $0x62, %eax
je 0x3e51c
jmp 0x3e4cf
movl -0x24(%rbp), %eax
subl $0x6e, %eax
je 0x3e53b
jmp 0x3e4d9
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
movzbl (%rax,%rcx), %esi
leaq 0x4e1b0(%rip), %rdi     # 0x8c69c
movb $0x0, %al
callq 0x1ac40
movl -0x14(%rbp), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x3e507
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x3e572
movl $0x20, %edi
callq 0x7ab10
movl -0x14(%rbp), %eax
orl $0x8, %eax
movl %eax, -0x14(%rbp)
jmp 0x3e55c
movl -0x14(%rbp), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0x3e530
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x3e572
movl -0x14(%rbp), %eax
orl $0x40, %eax
movl %eax, -0x14(%rbp)
jmp 0x3e55c
movl -0x14(%rbp), %eax
andl $0x200, %eax            # imm = 0x200
cmpl $0x0, %eax
je 0x3e551
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x3e572
movl -0x14(%rbp), %eax
orl $0x200, %eax            # imm = 0x200
movl %eax, -0x14(%rbp)
jmp 0x3e55e
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x3e4a3
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)