// File: /workspace/github_c_makefile_star2_O1/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
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
testl %esi, %esi
je 0x13cf9
movq %rdx, %r13
movl %esi, %r15d
movq (%rdx), %r12
cmpq $0x0, (%r12)
jne 0x13caf
movq 0x8(%r12), %rax
movq %r12, %rdi
callq *0x18(%rax)
movq (%r12), %rax
cmpb $0x2d, (%rax)
movq (%r13), %r12
jne 0x13cff
leaq 0x22f1d(%rip), %rdx     # 0x36be0
leaq -0x30(%rbp), %rcx
movl $0x1, %r13d
movq %rbx, %rdi
movq %r12, %rsi
xorl %r8d, %r8d
movl $0x1, %r9d
callq 0x7e97
testl %eax, %eax
jne 0x13e68
cmpl $0x1, -0x30(%rbp)
setne %cl
movq $-0x1, %r12
jmp 0x13d4c
movb $0x1, %cl
movb $0x1, %al
jmp 0x13d53
leaq 0x225da(%rip), %rax     # 0x362e0
cmpq %rax, 0x8(%r12)
je 0x13d2c
movq %rbx, %rdi
movq %r12, %rsi
movl $0x1, %edx
callq 0xd6d7
testl %eax, %eax
je 0x13d2c
movq $-0x1, %r12
xorl %eax, %eax
jmp 0x13d33
movq 0x18(%r12), %r12
movb $0x1, %al
movl $0x1, %r13d
testb %al, %al
je 0x13e68
movb $0x1, %cl
testq %r12, %r12
js 0x13e32
cmpl $0x1, %r15d
sete %al
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
testb %al, %al
je 0x13e68
movb %cl, -0x29(%rbp)
movl 0xc(%r14), %r13d
cmpq $0x0, 0x10(%r14)
je 0x13d7c
movq %r14, %rdi
movl $0x1, %esi
callq 0x14c5d
shrl $0x4, %r13d
andl $0x1, %r13d
movl %r13d, %edx
shll $0x4, %edx
movq %rbx, %rdi
movq %r14, %rsi
movl %r12d, %ecx
callq 0x14ad8
testl %eax, %eax
je 0x13db2
movq %r14, %rdi
movl %r13d, %esi
callq 0x14c5d
movl $0x1, %r13d
jmp 0x13e68
movq %rbx, %rdi
movq %r14, %rsi
movl %r12d, %edx
callq 0x14cbc
movq %rax, %r15
movq %r14, %rdi
movl %r13d, %esi
callq 0x14c5d
testq %r15, %r15
je 0x13e7a
cmpb $0x0, -0x29(%rbp)
jne 0x13e0d
cmpq $0x0, (%r15)
jne 0x13ded
movq 0x8(%r15), %rax
movq %r15, %rdi
callq *0x18(%rax)
movslq 0x14(%r15), %rax
testq %rax, %rax
jle 0x13e0d
movq (%r15), %rcx
cmpb $0xa, -0x1(%rcx,%rax)
jne 0x13e0d
leaq -0x1(%rax), %rdx
movl %edx, 0x14(%r15)
movb $0x0, -0x1(%rcx,%rax)
incl 0x10(%r15)
movq (%rbx), %rsi
movl 0x10(%rsi), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0x10(%rsi)
cmpl $0x2, %eax
jge 0x13e2a
movq %rbx, %rdi
callq 0x759a
movq %r15, (%rbx)
xorl %r13d, %r13d
jmp 0x13e68
leaq 0x186b8(%rip), %rsi     # 0x2c4f1
movq %rbx, %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x7516
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 0x13e65
movq %rbx, %rdi
callq 0x759a
movq %r14, (%rbx)
movl %r13d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
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 0x13e22
jmp 0x13e2a