// File: /workspace/github_c_makefile_star2_O0/gplessis[P]dotdeb-redis/deps/linenoise/linenoise.c
// Function: completeLine
static int completeLine(struct linenoiseState *ls) {
    linenoiseCompletions lc = { 0, NULL };
    int nread, nwritten;
    char c = 0;

    completionCallback(ls->buf,&lc);
    if (lc.len == 0) {
        linenoiseBeep();
    } else {
        size_t stop = 0, i = 0;

        while(!stop) {
            /* Show completion or original buffer */
            if (i < lc.len) {
                struct linenoiseState saved = *ls;

                ls->len = ls->pos = strlen(lc.cvec[i]);
                ls->buf = lc.cvec[i];
                refreshLine(ls);
                ls->len = saved.len;
                ls->pos = saved.pos;
                ls->buf = saved.buf;
            } else {
                refreshLine(ls);
            }

            nread = read(ls->ifd,&c,1);
            if (nread <= 0) {
                freeCompletions(&lc);
                return -1;
            }

            switch(c) {
                case 9: /* tab */
                    i = (i+1) % (lc.len+1);
                    if (i == lc.len) linenoiseBeep();
                    break;
                case 27: /* escape */
                    /* Re-show original buffer */
                    if (i < lc.len) refreshLine(ls);
                    stop = 1;
                    break;
                default:
                    /* Update buffer and return */
                    if (i < lc.len) {
                        nwritten = snprintf(ls->buf,ls->buflen,"%s",lc.cvec[i]);
                        ls->len = ls->pos = nwritten;
                    }
                    stop = 1;
                    break;
            }
        }
    }

    freeCompletions(&lc);
    return c; /* Return last read character */
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x10(%rbp)
leaq -0x20(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x10250
movb $0x0, -0x29(%rbp)
movq 0x7d2f6(%rip), %rax     # 0xa1630
movq -0x10(%rbp), %rcx
movq 0x8(%rcx), %rdi
leaq -0x20(%rbp), %rsi
callq *%rax
cmpq $0x0, -0x20(%rbp)
jne 0x24359
callq 0x24600
jmp 0x244ff
movq $0x0, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
cmpq $0x0, -0x38(%rbp)
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x2437c
jmp 0x244fd
movq -0x40(%rbp), %rax
cmpq -0x20(%rbp), %rax
jae 0x24405
movq -0x10(%rbp), %rsi
leaq -0x98(%rbp), %rdi
movl $0x58, %edx
callq 0x103b0
movq -0x18(%rbp), %rax
movq -0x40(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x101a0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x10(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x18(%rbp), %rax
movq -0x40(%rbp), %rcx
movq (%rax,%rcx,8), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rdi
callq 0x22760
movq -0x60(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x70(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x90(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
jmp 0x2440e
movq -0x10(%rbp), %rdi
callq 0x22760
movq -0x10(%rbp), %rax
movl (%rax), %edi
leaq -0x29(%rbp), %rsi
movl $0x1, %edx
callq 0x102b0
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jg 0x24440
leaq -0x20(%rbp), %rdi
callq 0x24630
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2450f
movsbl -0x29(%rbp), %eax
movl %eax, -0x9c(%rbp)
subl $0x9, %eax
je 0x2445e
jmp 0x24451
movl -0x9c(%rbp), %eax
subl $0x1b, %eax
je 0x24488
jmp 0x244a5
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq -0x20(%rbp), %rcx
addq $0x1, %rcx
xorl %edx, %edx
divq %rcx
movq %rdx, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x20(%rbp), %rax
jne 0x24486
callq 0x24600
jmp 0x244f8
movq -0x40(%rbp), %rax
cmpq -0x20(%rbp), %rax
jae 0x2449b
movq -0x10(%rbp), %rdi
callq 0x22760
movq $0x1, -0x38(%rbp)
jmp 0x244f8
movq -0x40(%rbp), %rax
cmpq -0x20(%rbp), %rax
jae 0x244f0
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x18(%rbp), %rax
movq -0x40(%rbp), %rcx
movq (%rax,%rcx,8), %rcx
leaq 0x62b60(%rip), %rdx     # 0x87032
movb $0x0, %al
callq 0x101e0
movl %eax, -0x28(%rbp)
movslq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x10(%rbp), %rax
movq %rcx, 0x38(%rax)
movq $0x1, -0x38(%rbp)
jmp 0x24369
jmp 0x244ff
leaq -0x20(%rbp), %rdi
callq 0x24630
movsbl -0x29(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xa0, %rsp
popq %rbp
retq
nopl (%rax,%rax)