// File: /workspace/github_c_makefile_star2_O0/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
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movl $0xffffffff, -0x34(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
cmpl $0x2, -0x14(%rbp)
jle 0x712b
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rsi
leaq 0x34776(%rip), %rdx     # 0x3b887
callq 0x77a0
cmpl $0x0, %eax
je 0x712b
movl $0x1, -0x3c(%rbp)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
cmpl $0x2, -0x14(%rbp)
jl 0x713e
movl -0x14(%rbp), %eax
movl -0x38(%rbp), %ecx
addl $0x3, %ecx
cmpl %ecx, %eax
jle 0x7163
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rdx
movl $0x1, %esi
leaq 0x3473e(%rip), %rcx     # 0x3b890
callq 0x7880
movl $0x1, -0x4(%rbp)
jmp 0x72de
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x7960
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x7c, %eax
jne 0x7228
movl $0x0, -0x64(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x34715(%rip), %rsi     # 0x3b8ab
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x7990
movq %rax, %rcx
movl -0x64(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x64(%rbp)
cltq
movq %rcx, -0x60(%rbp,%rax,8)
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
addq $0x1, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x7990
movq %rax, %rcx
movl -0x64(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x64(%rbp)
cltq
movq %rcx, -0x60(%rbp,%rax,8)
movl -0x14(%rbp), %eax
movl -0x38(%rbp), %ecx
addl $0x3, %ecx
cmpl %ecx, %eax
jne 0x7210
movq -0x20(%rbp), %rax
movl -0x38(%rbp), %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rcx
movl -0x64(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x64(%rbp)
cltq
movq %rcx, -0x60(%rbp,%rax,8)
movq -0x10(%rbp), %rdi
movl -0x64(%rbp), %esi
leaq -0x60(%rbp), %rdx
callq 0x12aa0
movl %eax, -0x4(%rbp)
jmp 0x72de
movl -0x14(%rbp), %eax
movl -0x38(%rbp), %ecx
addl $0x3, %ecx
cmpl %ecx, %eax
jne 0x726b
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x20(%rbp), %rax
movl -0x38(%rbp), %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdx
callq 0x18b70
movl %eax, -0x24(%rbp)
cmpl $-0x1, -0x24(%rbp)
jne 0x7269
movl $0x1, -0x4(%rbp)
jmp 0x72de
jmp 0x7272
movl $0x0, -0x24(%rbp)
movq -0x30(%rbp), %rdi
movl -0x24(%rbp), %esi
movl $0x1b6, %edx            # imm = 0x1B6
movb $0x0, %al
callq 0x63e0
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jge 0x72a8
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x188a0
movl $0x1, -0x4(%rbp)
jmp 0x72de
movq -0x10(%rbp), %rdi
movl -0x34(%rbp), %esi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdx
movl -0x3c(%rbp), %r9d
leaq 0x345f1(%rip), %rcx     # 0x3b8b3
xorl %r8d, %r8d
callq 0x7350
movq %rax, %rdx
movl $0x1, %eax
xorl %ecx, %ecx
cmpq $0x0, %rdx
cmovnel %ecx, %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopw (%rax,%rax)