// File: /workspace/github_c_makefile_star2_O0/msteveb[P]autosetup/./jimsh0.c
// Function: parse_open_mode
static int parse_open_mode(Jim_Interp *interp, Jim_Obj *filenameObj, Jim_Obj *modeObj)
{

    int flags;
    const char *mode = Jim_String(modeObj);
    if (*mode == 'R' || *mode == 'W') {
        return parse_posix_open_mode(interp, modeObj);
    }
    if (*mode == 'r') {
        flags = O_RDONLY;
    }
    else if (*mode == 'w') {
        flags = O_WRONLY | O_CREAT | O_TRUNC;
    }
    else if (*mode == 'a') {
        flags = O_WRONLY | O_CREAT | O_APPEND;
    }
    else {
        Jim_SetResultFormatted(interp, "%s: invalid open mode '%s'", Jim_String(filenameObj), mode);
        return -1;
    }
    mode++;

    if (*mode == 'b') {
#ifdef O_BINARY
        flags |= O_BINARY;
#endif
        mode++;
    }

    if (*mode == 't') {
#ifdef O_TEXT
        flags |= O_TEXT;
#endif
        mode++;
    }

    if (*mode == '+') {
        mode++;

        flags &= ~(O_RDONLY | O_WRONLY);
        flags |= O_RDWR;
    }

    if (*mode == 'x') {
        mode++;
#ifdef O_EXCL
        flags |= O_EXCL;
#endif
    }

    if (*mode == 'F') {
        mode++;
#ifdef O_LARGEFILE
        flags |= O_LARGEFILE;
#endif
    }

    if (*mode == 'e') {

        mode++;
    }
    return flags;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x20(%rbp), %rdi
callq 0x7960
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x52, %eax
je 0x18ba9
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x57, %eax
jne 0x18bbe
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x18d20
movl %eax, -0x4(%rbp)
jmp 0x18d08
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x72, %eax
jne 0x18bd3
movl $0x0, -0x24(%rbp)
jmp 0x18c37
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x77, %eax
jne 0x18be8
movl $0x241, -0x24(%rbp)     # imm = 0x241
jmp 0x18c35
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x61, %eax
jne 0x18bfd
movl $0x441, -0x24(%rbp)     # imm = 0x441
jmp 0x18c33
movq -0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rdi
callq 0x7960
movq -0x38(%rbp), %rdi
movq %rax, %rdx
movq -0x30(%rbp), %rcx
leaq 0x22ca1(%rip), %rsi     # 0x3b8c1
movb $0x0, %al
callq 0x6b40
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x18d08
jmp 0x18c35
jmp 0x18c37
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x62, %eax
jne 0x18c5b
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x74, %eax
jne 0x18c7c
movl -0x24(%rbp), %eax
orl $0x0, %eax
movl %eax, -0x24(%rbp)
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2b, %eax
jne 0x18ca6
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
movl -0x24(%rbp), %eax
andl $-0x2, %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
orl $0x2, %eax
movl %eax, -0x24(%rbp)
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x78, %eax
jne 0x18cc9
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
movl -0x24(%rbp), %eax
orl $0x80, %eax
movl %eax, -0x24(%rbp)
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x46, %eax
jne 0x18cea
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
movl -0x24(%rbp), %eax
orl $0x0, %eax
movl %eax, -0x24(%rbp)
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x65, %eax
jne 0x18d02
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)