// File: /workspace/github_c_makefile_star2_O0/msteveb[P]autosetup/./jimsh0.c
// Function: aio_cmd_copy
static int aio_cmd_copy(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
    AioFile *af = Jim_CmdPrivData(interp);
    jim_wide count = 0;
    jim_wide maxlen = JIM_WIDE_MAX;
    int ok = 1;
    Jim_Obj *objv[4];

    if (argc == 2) {
        if (Jim_GetWide(interp, argv[1], &maxlen) != JIM_OK) {
            return JIM_ERR;
        }
    }

    objv[0] = argv[0];
    objv[1] = Jim_NewStringObj(interp, "flush", -1);
    if (Jim_EvalObjVector(interp, 2, objv) != JIM_OK) {
        Jim_SetResultFormatted(interp, "Not a filehandle: \"%#s\"", argv[0]);
        return JIM_ERR;
    }


    objv[0] = argv[0];
    objv[1] = Jim_NewStringObj(interp, "puts", -1);
    objv[2] = Jim_NewStringObj(interp, "-nonewline", -1);
    Jim_IncrRefCount(objv[1]);
    Jim_IncrRefCount(objv[2]);

    while (count < maxlen) {
        jim_wide len = maxlen - count;
        if (len > af->rbuf_len) {
            len = af->rbuf_len;
        }
        if (aio_read_len(interp, af, 0, len) != JIM_OK) {
            ok = 0;
            break;
        }
        objv[3] = aio_read_consume(interp, af, len);
        count += Jim_Length(objv[3]);
        if (Jim_EvalObjVector(interp, 4, objv) != JIM_OK) {
            ok = 0;
            break;
        }
        if (aio_eof(af)) {
            break;
        }
        if (count >= 16384 && af->rbuf_len < 65536) {

            af->rbuf_len = 65536;
            af->rbuf = Jim_Realloc(af->rbuf, af->rbuf_len);
        }
    }

    Jim_DecrRefCount(interp, objv[1]);
    Jim_DecrRefCount(interp, objv[2]);

    if (!ok) {
        return JIM_ERR;
    }

    Jim_SetResultInt(interp, count);

    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)
movabsq $0x7fffffffffffffff, %rax # imm = 0x7FFFFFFFFFFFFFFF
movq %rax, -0x38(%rbp)
movl $0x1, -0x3c(%rbp)
cmpl $0x2, -0x14(%rbp)
jne 0x174fd
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rsi
leaq -0x38(%rbp), %rdx
callq 0xf640
cmpl $0x0, %eax
je 0x174fb
movl $0x1, -0x4(%rbp)
jmp 0x17759
jmp 0x174fd
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x24240(%rip), %rsi     # 0x3b753
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x7990
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x60(%rbp), %rdx
movl $0x2, %esi
callq 0x12aa0
cmpl $0x0, %eax
je 0x1755d
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movq (%rax), %rdx
leaq 0x235d2(%rip), %rsi     # 0x3ab1c
movb $0x0, %al
callq 0x6b40
movl $0x1, -0x4(%rbp)
jmp 0x17759
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x241c3(%rip), %rsi     # 0x3b736
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x7990
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x2521f(%rip), %rsi     # 0x3c7ab
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x7990
movq %rax, -0x50(%rbp)
movq -0x58(%rbp), %rax
movl 0x10(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x10(%rax)
movq -0x50(%rbp), %rax
movl 0x10(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x10(%rax)
movq -0x30(%rbp), %rax
cmpq -0x38(%rbp), %rax
jge 0x176b5
movq -0x38(%rbp), %rax
subq -0x30(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
movq -0x28(%rbp), %rcx
cmpq 0x48(%rcx), %rax
jbe 0x175e8
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x68(%rbp), %rax
movl %eax, %ecx
xorl %edx, %edx
callq 0x18510
cmpl $0x0, %eax
je 0x1760e
movl $0x0, -0x3c(%rbp)
jmp 0x176b5
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x68(%rbp), %rax
movl %eax, %edx
callq 0x18770
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
callq 0xc700
cltq
addq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x60(%rbp), %rdx
movl $0x4, %esi
callq 0x12aa0
cmpl $0x0, %eax
je 0x17658
movl $0x0, -0x3c(%rbp)
jmp 0x176b5
movq -0x28(%rbp), %rdi
callq 0x18820
cmpl $0x0, %eax
je 0x17668
jmp 0x176b5
cmpq $0x4000, -0x30(%rbp)    # imm = 0x4000
jl 0x176b0
movq -0x28(%rbp), %rax
cmpq $0x10000, 0x48(%rax)    # imm = 0x10000
jae 0x176b0
movq -0x28(%rbp), %rax
movq $0x10000, 0x48(%rax)    # imm = 0x10000
movq 0x30bfd(%rip), %rax     # 0x48290
movq -0x28(%rbp), %rcx
movq 0x40(%rcx), %rdi
movq -0x28(%rbp), %rcx
movq 0x48(%rcx), %rsi
callq *%rax
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x40(%rax)
jmp 0x175b4
movq -0x58(%rbp), %rcx
movl 0x10(%rcx), %eax
addl $-0x1, %eax
movl %eax, 0x10(%rcx)
cmpl $0x0, %eax
jg 0x176d4
movq -0x10(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0x7a10
movq -0x50(%rbp), %rcx
movl 0x10(%rcx), %eax
addl $-0x1, %eax
movl %eax, 0x10(%rcx)
cmpl $0x0, %eax
jg 0x176f3
movq -0x10(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x7a10
cmpl $0x0, -0x3c(%rbp)
jne 0x17702
movl $0x1, -0x4(%rbp)
jmp 0x17759
jmp 0x17704
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x8d60
movq %rax, -0x70(%rbp)
movq -0x70(%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 0x17747
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
callq 0x7a10
movq -0x70(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)