// File: /workspace/github_c_makefile_star2_O1/msteveb[P]autosetup/./jimsh0.c
// Function: JimAioOpenCommand
static int JimAioOpenCommand(Jim_Interp *interp, int argc,
        Jim_Obj *const *argv)
{
    int openflags;
    const char *filename;
    int fd = -1;
    int n = 0;
    int flags = 0;

    if (argc > 2 && Jim_CompareStringImmediate(interp, argv[2], "-noclose")) {
        flags = AIO_KEEPOPEN;
        n++;
    }
    if (argc < 2 || argc > 3 + n) {
        Jim_WrongNumArgs(interp, 1, argv, "filename ?-noclose? ?mode?");
        return JIM_ERR;
    }

    filename = Jim_String(argv[1]);

#ifdef jim_ext_tclcompat
    {


        if (*filename == '|') {
            Jim_Obj *evalObj[3];
            int i = 0;

            evalObj[i++] = Jim_NewStringObj(interp, "::popen", -1);
            evalObj[i++] = Jim_NewStringObj(interp, filename + 1, -1);
            if (argc == 3 + n) {
                evalObj[i++] = argv[2 + n];
            }

            return Jim_EvalObjVector(interp, i, evalObj);
        }
    }
#endif
    if (argc == 3 + n) {
        openflags = parse_open_mode(interp, argv[1], argv[2 + n]);
        if (openflags == -1) {
            return JIM_ERR;
        }
    }
    else {
        openflags = O_RDONLY;
    }
    fd = open(filename, openflags, 0666);
    if (fd < 0) {
        JimAioSetError(interp, argv[1]);
        return JIM_ERR;
    }

    return JimMakeChannel(interp, fd, argv[1], "aio.handle%ld", 0, flags) ? JIM_OK : JIM_ERR;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, %r14
movl %esi, %r13d
movq %rdi, %rbx
xorl %eax, %eax
cmpl $0x3, %esi
jl 0x6cec
movq 0x10(%r14), %rsi
leaq 0x258a0(%rip), %rdx     # 0x2c584
movq %rbx, %rdi
callq 0x73d6
cmpl $0x2, %r13d
jl 0x6cfb
leal 0x3(%rax), %r15d
cmpl %r13d, %r15d
jge 0x6d2a
leaq 0x2588b(%rip), %rcx     # 0x2c58d
movl $0x1, %r15d
movq %rbx, %rdi
movl $0x1, %esi
movq %r14, %rdx
callq 0x7454
movl %r15d, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, -0x30(%rbp)
movq 0x8(%r14), %r12
cmpq $0x0, (%r12)
jne 0x6d44
movq 0x8(%r12), %rax
movq %r12, %rdi
callq *0x18(%rax)
movq (%r12), %r12
cmpb $0x7c, (%r12)
jne 0x6db0
leaq 0x25852(%rip), %rsi     # 0x2c5a8
movq %rbx, %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x7516
movq %rax, -0x50(%rbp)
incq %r12
movq %rbx, %rdi
movq %r12, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x7516
movq %rax, -0x48(%rbp)
movl $0x2, %esi
cmpl %r13d, %r15d
movq -0x30(%rbp), %rax
jne 0x6d9c
movl %eax, %eax
movq 0x10(%r14,%rax,8), %rax
movq %rax, -0x40(%rbp)
movl $0x3, %esi
leaq -0x50(%rbp), %rdx
movq %rbx, %rdi
callq 0x10562
movl %eax, %r15d
jmp 0x6d18
xorl %esi, %esi
cmpl %r13d, %r15d
movq -0x30(%rbp), %r15
jne 0x6f4f
movq %r12, -0x58(%rbp)
movq 0x8(%r14), %rdx
movl %r15d, %eax
movq 0x10(%r14,%rax,8), %r13
cmpq $0x0, (%r13)
jne 0x6de6
movq 0x8(%r13), %rax
movq %rdx, %r15
movq %r13, %rdi
callq *0x18(%rax)
movq %r15, %rdx
movq (%r13), %r12
movzbl (%r12), %ecx
cmpl $0x60, %ecx
jle 0x6e1b
cmpl $0x61, %ecx
je 0x6eaa
xorl %eax, %eax
cmpl $0x72, %ecx
je 0x6eaf
cmpl $0x77, %ecx
jne 0x6f06
movl $0x241, %eax            # imm = 0x241
jmp 0x6eaf
cmpl $0x52, %ecx
je 0x6e29
cmpl $0x57, %ecx
jne 0x6f06
movq %rbx, %rdi
movq %r13, %rsi
callq 0xe338
cmpl $0x0, 0x20(%r13)
jle 0x6f3b
xorl %r15d, %r15d
xorl %r12d, %r12d
movq %rbx, %rdi
movq %r13, %rsi
movl %r12d, %edx
callq 0xe871
movq %rbx, %rdi
movq %rax, %rsi
leaq 0x2fde0(%rip), %rdx     # 0x36c40
leaq -0x50(%rbp), %rcx
leaq 0x257a7(%rip), %r8      # 0x2c612
movl $0x1, %r9d
callq 0x7e97
testl %eax, %eax
jne 0x6e89
movslq -0x50(%rbp), %rcx
leaq 0x218eb(%rip), %rdx     # 0x28770
orl (%rdx,%rcx,4), %r15d
testl %eax, %eax
jne 0x6f33
incl %r12d
movq %rbx, %rdi
movq %r13, %rsi
callq 0xe338
cmpl 0x20(%r13), %r12d
jl 0x6e45
jmp 0x6f3e
movl $0x441, %eax            # imm = 0x441
leaq 0x1(%r12), %rcx
xorl %edx, %edx
cmpb $0x62, 0x1(%r12)
leaq 0x2(%r12), %rsi
sete %dl
cmoveq %rsi, %rcx
xorl %esi, %esi
cmpb $0x74, 0x1(%rdx,%r12)
sete %sil
leaq (%rcx,%rsi), %rdx
movl %eax, %edi
andl $0x640, %edi            # imm = 0x640
orl $0x2, %edi
xorl %r8d, %r8d
cmpb $0x2b, (%rcx,%rsi)
sete %r8b
cmovnel %eax, %edi
movl %edi, %r15d
orl $0x80, %r15d
cmpb $0x78, (%r8,%rdx)
cmovnel %edi, %r15d
jmp 0x6f3e
cmpq $0x0, (%rdx)
jne 0x6f1c
movq 0x8(%rdx), %rax
movq %rdx, %r15
movq %rdx, %rdi
callq *0x18(%rax)
movq %r15, %rdx
movq (%rdx), %rdx
leaq 0x25698(%rip), %rsi     # 0x2c5be
movq %rbx, %rdi
movq %r12, %rcx
xorl %eax, %eax
callq 0x692d
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
jmp 0x6f3e
xorl %r15d, %r15d
cmpl $-0x1, %r15d
movl %r15d, %esi
movq -0x30(%rbp), %r15
movq -0x58(%rbp), %r12
je 0x6f94
movq %r12, %rdi
movl $0x1b6, %edx            # imm = 0x1B6
xorl %eax, %eax
callq 0x63d0
movq 0x8(%r14), %rdx
testl %eax, %eax
js 0x6f89
leaq 0x25643(%rip), %rcx     # 0x2c5b0
movq %rbx, %rdi
movl %eax, %esi
movl %r15d, %r8d
callq 0x70b7
xorl %r15d, %r15d
testq %rax, %rax
sete %r15b
jmp 0x6d18
movq %rbx, %rdi
movq %rdx, %rsi
callq 0x14d8d
movl $0x1, %r15d
jmp 0x6d18