// File: /workspace/github_c_makefile_star2_O3/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
pushq %rax
movq %rdi, %rbx
movq 0x1b8(%rdi), %r14
testl %esi, %esi
je 0x138bd
movq %rdx, %r12
movl %esi, %r15d
movq (%rdx), %r13
movq (%r13), %rax
testq %rax, %rax
jne 0x13877
movq 0x8(%r13), %rax
movq %r13, %rdi
callq *0x18(%rax)
movq (%r13), %rax
cmpb $0x2d, (%rax)
movq (%r12), %r12
jne 0x138c8
leaq 0x22359(%rip), %rdx     # 0x35be0
leaq -0x30(%rbp), %rcx
movl $0x1, %r13d
movq %rbx, %rdi
movq %r12, %rsi
xorl %r8d, %r8d
movl $0x1, %r9d
callq 0x7eac
testl %eax, %eax
jne 0x139df
cmpl $0x1, -0x30(%rbp)
setne %al
movq $-0x1, %r12
jmp 0x13904
movq $-0x1, %r12
movb $0x1, %al
jmp 0x13914
leaq 0x21a21(%rip), %rax     # 0x352f0
cmpq %rax, 0x8(%r12)
je 0x138f4
movl $0x1, %r13d
movq %rbx, %rdi
movq %r12, %rsi
movl $0x1, %edx
callq 0xd6c3
testl %eax, %eax
jne 0x139df
movq 0x18(%r12), %r12
movb $0x1, %al
testq %r12, %r12
js 0x139f1
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
cmpl $0x1, %r15d
jne 0x139df
movb %al, -0x29(%rbp)
movl 0xc(%r14), %r13d
cmpq $0x0, 0x10(%r14)
je 0x1392f
movq %r14, %rdi
movl $0x1, %esi
callq 0x147c8
shrl $0x4, %r13d
andl $0x1, %r13d
movl %r13d, %edx
shll $0x4, %edx
movq %rbx, %rdi
movq %r14, %rsi
movl %r12d, %ecx
callq 0x14696
testl %eax, %eax
je 0x13962
movq %r14, %rdi
movl %r13d, %esi
callq 0x147c8
movl $0x1, %r13d
jmp 0x139df
movq %rbx, %rdi
movq %r14, %rsi
movl %r12d, %edx
callq 0x14827
movq %rax, %r15
movq %r14, %rdi
movl %r13d, %esi
callq 0x147c8
testq %r15, %r15
je 0x13a2c
cmpb $0x0, -0x29(%rbp)
jne 0x139bc
movq (%r15), %rax
testq %rax, %rax
jne 0x139a2
movq 0x8(%r15), %rax
movq %r15, %rdi
callq *0x18(%rax)
movq (%r15), %rax
movslq 0x14(%r15), %rcx
testq %rcx, %rcx
jle 0x139bc
cmpb $0xa, -0x1(%rax,%rcx)
jne 0x139bc
decl %ecx
movl %ecx, 0x14(%r15)
movb $0x0, (%rax,%rcx)
incl 0x10(%r15)
movq (%rbx), %rsi
movl 0x10(%rsi), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0x10(%rsi)
cmpl $0x2, %eax
jge 0x139d9
movq %rbx, %rdi
callq 0x758c
movq %r15, (%rbx)
xorl %r13d, %r13d
movl %r13d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x17a9e(%rip), %rsi     # 0x2b496
movq %rbx, %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x7508
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 0x13a24
movq %rbx, %rdi
callq 0x758c
movq %r14, (%rbx)
jmp 0x1395a
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
jle 0x139d1
jmp 0x139d9