// File: /workspace/github_c_makefile_star2_O2/msteveb[P]autosetup/./jimsh0.c
// Function: aio_cmd_read
static int aio_cmd_read(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
    AioFile *af = Jim_CmdPrivData(interp);
    int nonewline = 0;
    jim_wide neededLen = -1;
    static const char * const options[] = { "-pending", "-nonewline", NULL };
    enum { OPT_PENDING, OPT_NONEWLINE };
    int option;
    int nb;
    Jim_Obj *objPtr;

    if (argc) {
        if (*Jim_String(argv[0]) == '-') {
            if (Jim_GetEnum(interp, argv[0], options, &option, NULL, JIM_ERRMSG) != JIM_OK) {
                return JIM_ERR;
            }
            switch (option) {
                case OPT_PENDING:

                    break;
                case OPT_NONEWLINE:
                    nonewline++;
                    break;
            }
        }
        else {
            if (Jim_GetWide(interp, argv[0], &neededLen) != JIM_OK)
                return JIM_ERR;
            if (neededLen < 0) {
                Jim_SetResultString(interp, "invalid parameter: negative len", -1);
                return JIM_ERR;
            }
        }
        argc--;
        argv++;
    }
    if (argc) {
        return -1;
    }


    nb = aio_start_nonblocking(af);

    if (aio_read_len(interp, af, nb ? AIO_NONBLOCK : 0, neededLen) != JIM_OK) {
        aio_set_nonblocking(af, nb);
        return JIM_ERR;
    }
    objPtr = aio_read_consume(interp, af, neededLen);

    aio_set_nonblocking(af, nb);

    if (objPtr) {
        if (nonewline) {
            int len;
            const char *s = Jim_GetString(objPtr, &len);

            if (len > 0 && s[len - 1] == '\n') {
                objPtr->length--;
                objPtr->bytes[objPtr->length] = '\0';
            }
        }
        Jim_SetResult(interp, objPtr);
    }
    else {
        Jim_SetEmptyResult(interp);
    }
    return JIM_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movq 0x1b8(%rdi), %r14
orq $-0x1, -0x38(%rbp)
pushq $0x1
popq %r13
testl %esi, %esi
je 0x12203
movq %rdx, %r12
movl %esi, %r15d
movq (%rdx), %rdi
callq 0x7340
cmpb $0x2d, (%rax)
movq (%r12), %rsi
jne 0x1220b
leaq 0x1fa08(%rip), %rdx     # 0x31be0
leaq -0x30(%rbp), %rcx
pushq $0x1
popq %r12
movq %rbx, %rdi
xorl %r8d, %r8d
movl %r12d, %r9d
callq 0x7b44
testl %eax, %eax
jne 0x12307
cmpl $0x1, -0x30(%rbp)
setne %al
pushq $-0x1
popq %r12
jmp 0x12232
movb $0x1, %al
pushq $-0x1
popq %r12
jmp 0x1223c
leaq -0x38(%rbp), %rdx
movq %rbx, %rdi
callq 0xc979
testl %eax, %eax
je 0x12223
movl %r13d, %r12d
jmp 0x12307
movq -0x38(%rbp), %r12
movb $0x1, %al
testq %r12, %r12
js 0x12319
cmpl $0x1, %r15d
jne 0x122d7
movb %al, -0x29(%rbp)
movl %r13d, %r15d
movq %r14, %rdi
callq 0x12d64
movl %eax, %r13d
xorl %edx, %edx
testl %eax, %eax
setne %dl
shll $0x4, %edx
movq %rbx, %rdi
movq %r14, %rsi
movl %r12d, %ecx
callq 0x12d8b
testl %eax, %eax
je 0x1227c
movq %r14, %rdi
movl %r13d, %esi
callq 0x12e9b
movl %r15d, %r12d
jmp 0x12307
movq %rbx, %rdi
movq %r14, %rsi
movl %r12d, %edx
callq 0x12ef6
movq %rax, %r15
movq %r14, %rdi
movl %r13d, %esi
callq 0x12e9b
testq %r15, %r15
je 0x122dd
cmpb $0x0, -0x29(%rbp)
jne 0x122e4
leaq -0x3c(%rbp), %r14
movq %r15, %rdi
movq %r14, %rsi
callq 0x7fc7
movslq (%r14), %rcx
testq %rcx, %rcx
jle 0x122e4
cmpb $0xa, -0x1(%rax,%rcx)
jne 0x122e4
movslq 0x14(%r15), %rax
leaq -0x1(%rax), %rcx
movl %ecx, 0x14(%r15)
movq (%r15), %rcx
movb $0x0, -0x1(%rcx,%rax)
jmp 0x122e4
pushq $-0x1
popq %r12
jmp 0x12307
movq 0x128(%rbx), %r15
incl 0x10(%r15)
movq (%rbx), %rsi
movl 0x10(%rsi), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0x10(%rsi)
cmpl $0x1, %eax
jg 0x12301
movq %rbx, %rdi
callq 0x73bf
movq %r15, (%rbx)
xorl %r12d, %r12d
movl %r12d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x151c6(%rip), %rsi     # 0x274e6
pushq $-0x1
popq %rdx
movq %rbx, %rdi
callq 0x7363
movq %rax, %r14
incl 0x10(%rax)
movq (%rbx), %rsi
movl 0x10(%rsi), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0x10(%rsi)
cmpl $0x1, %eax
jg 0x1234a
movq %rbx, %rdi
callq 0x73bf
movq %r14, (%rbx)
jmp 0x1221b