// File: /workspace/github_c_makefile_star2_O0/msteveb[P]autosetup/./jimsh0.c
// Function: aio_cmd_gets
static int aio_cmd_gets(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
    AioFile *af = Jim_CmdPrivData(interp);
    Jim_Obj *objPtr = NULL;
    int len;
    int nb;
    unsigned flags = AIO_ONEREAD;
    char *nl = NULL;
    int offset = 0;

    errno = 0;


    nb = aio_start_nonblocking(af);
    if (nb) {
        flags |= AIO_NONBLOCK;
    }

    while (!aio_eof(af)) {
        if (af->readbuf) {
            const char *pt = Jim_GetString(af->readbuf, &len);
            nl = memchr(pt + offset, '\n', len - offset);
            if (nl) {

                objPtr = Jim_NewStringObj(interp, pt, nl - pt);

                aio_consume(af->readbuf, nl - pt + 1);
                break;
            }
            offset = len;
        }


        if (aio_read_len(interp, af, flags, -1) != JIM_OK) {
            break;
        }
    }

    aio_set_nonblocking(af, nb);

    if (!nl && aio_eof(af) && af->readbuf) {

        objPtr = af->readbuf;
        af->readbuf = NULL;
    }
    else if (!objPtr) {
        objPtr = Jim_NewStringObj(interp, NULL, 0);
    }

    if (argc) {
        if (Jim_SetVariable(interp, argv[0], objPtr) != JIM_OK) {
            Jim_FreeNewObj(interp, objPtr);
            return JIM_ERR;
        }

        len = Jim_Length(objPtr);

        if (!nl && len == 0) {

            len = -1;
        }
        Jim_SetResultInt(interp, len);
    }
    else {
        Jim_SetResult(interp, objPtr);
    }
    return JIM_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x1b8(%rax), %rax
movq %rax, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movl $0x20, -0x3c(%rbp)
movq $0x0, -0x48(%rbp)
movl $0x0, -0x4c(%rbp)
callq 0x6080
movl $0x0, (%rax)
movq -0x28(%rbp), %rdi
callq 0x184c0
movl %eax, -0x38(%rbp)
cmpl $0x0, -0x38(%rbp)
je 0x17866
movl -0x3c(%rbp), %eax
orl $0x10, %eax
movl %eax, -0x3c(%rbp)
jmp 0x17868
movq -0x28(%rbp), %rdi
callq 0x18820
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x17882
jmp 0x17934
movq -0x28(%rbp), %rax
cmpq $0x0, 0x30(%rax)
je 0x17913
movq -0x28(%rbp), %rax
movq 0x30(%rax), %rdi
leaq -0x34(%rbp), %rsi
callq 0x89b0
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rdi
movslq -0x4c(%rbp), %rax
addq %rax, %rdi
movl -0x34(%rbp), %eax
subl -0x4c(%rbp), %eax
movslq %eax, %rdx
movl $0xa, %esi
callq 0x62a0
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0x1790d
movq -0x10(%rbp), %rdi
movq -0x58(%rbp), %rsi
movq -0x48(%rbp), %rax
movq -0x58(%rbp), %rcx
subq %rcx, %rax
movl %eax, %edx
callq 0x7990
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rax
movq 0x30(%rax), %rdi
movq -0x48(%rbp), %rax
movq -0x58(%rbp), %rcx
subq %rcx, %rax
addq $0x1, %rax
movl %eax, %esi
callq 0x189c0
jmp 0x17934
movl -0x34(%rbp), %eax
movl %eax, -0x4c(%rbp)
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
movl -0x3c(%rbp), %edx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0x18510
cmpl $0x0, %eax
je 0x1792f
jmp 0x17934
jmp 0x17868
movq -0x28(%rbp), %rdi
movl -0x38(%rbp), %esi
callq 0x186d0
cmpq $0x0, -0x48(%rbp)
jne 0x1797a
movq -0x28(%rbp), %rdi
callq 0x18820
cmpl $0x0, %eax
je 0x1797a
movq -0x28(%rbp), %rax
cmpq $0x0, 0x30(%rax)
je 0x1797a
movq -0x28(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rax
movq $0x0, 0x30(%rax)
jmp 0x17996
cmpq $0x0, -0x30(%rbp)
jne 0x17994
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x7990
movq %rax, -0x30(%rbp)
jmp 0x17996
cmpl $0x0, -0x14(%rbp)
je 0x17a44
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movq (%rax), %rsi
movq -0x30(%rbp), %rdx
callq 0x8df0
cmpl $0x0, %eax
je 0x179d2
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x7a10
movl $0x1, -0x4(%rbp)
jmp 0x17a94
movq -0x30(%rbp), %rdi
callq 0xc700
movl %eax, -0x34(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x179f2
cmpl $0x0, -0x34(%rbp)
jne 0x179f2
movl $0xffffffff, -0x34(%rbp) # imm = 0xFFFFFFFF
jmp 0x179f4
movq -0x10(%rbp), %rdi
movslq -0x34(%rbp), %rsi
callq 0x8d60
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movl 0x10(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x10(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rcx
movl 0x10(%rcx), %eax
addl $-0x1, %eax
movl %eax, 0x10(%rcx)
cmpl $0x0, %eax
jg 0x17a37
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
callq 0x7a10
movq -0x60(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
jmp 0x17a8d
jmp 0x17a46
movq -0x30(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
movl 0x10(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x10(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rcx
movl 0x10(%rcx), %eax
addl $-0x1, %eax
movl %eax, 0x10(%rcx)
cmpl $0x0, %eax
jg 0x17a80
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
callq 0x7a10
movq -0x68(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
jmp 0x17a8d
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)