// File: /workspace/github_c_makefile_star2_O0/voithos[P]awl/src/linenoise.c
// Function: refreshMultiLine
static void refreshMultiLine(struct linenoiseState *l) {
    char seq[64];
    int plen = strlen(l->prompt);
    int rows = (plen+l->len+l->cols-1)/l->cols; /* rows used by current buf. */
    int rpos = (plen+l->oldpos+l->cols)/l->cols; /* cursor relative row. */
    int rpos2; /* rpos after refresh. */
    int old_rows = l->maxrows;
    int fd = l->ofd, j;
    struct abuf ab;

    /* Update maxrows if needed. */
    if (rows > (int)l->maxrows) l->maxrows = rows;

    /* First step: clear all the lines used before. To do so start by
     * going to the last row. */
    abInit(&ab);
    if (old_rows-rpos > 0) {
        lndebug("go down %d", old_rows-rpos);
        snprintf(seq,64,"\x1b[%dB", old_rows-rpos);
        abAppend(&ab,seq,strlen(seq));
    }

    /* Now for every row clear it, go up. */
    for (j = 0; j < old_rows-1; j++) {
        lndebug("clear+up");
        snprintf(seq,64,"\x1b[0G\x1b[0K\x1b[1A");
        abAppend(&ab,seq,strlen(seq));
    }

    /* Clean the top line. */
    lndebug("clear");
    snprintf(seq,64,"\x1b[0G\x1b[0K");
    abAppend(&ab,seq,strlen(seq));

    /* Write the prompt and the current buffer content */
    abAppend(&ab,l->prompt,strlen(l->prompt));
    abAppend(&ab,l->buf,l->len);

    /* If we are at the very end of the screen with our prompt, we need to
     * emit a newline and move the prompt to the first column. */
    if (l->pos &&
        l->pos == l->len &&
        (l->pos+plen) % l->cols == 0)
    {
        lndebug("<newline>");
        abAppend(&ab,"\n",1);
        snprintf(seq,64,"\x1b[0G");
        abAppend(&ab,seq,strlen(seq));
        rows++;
        if (rows > (int)l->maxrows) l->maxrows = rows;
    }

    /* Move cursor to right position. */
    rpos2 = (plen+l->pos+l->cols)/l->cols; /* current cursor relative row. */
    lndebug("rpos2 %d", rpos2);

    /* Go up till we reach the expected positon. */
    if (rows-rpos2 > 0) {
        lndebug("go-up %d", rows-rpos2);
        snprintf(seq,64,"\x1b[%dA", rows-rpos2);
        abAppend(&ab,seq,strlen(seq));
    }

    /* Set column. */
    lndebug("set col %d", 1+((plen+(int)l->pos) % (int)l->cols));
    snprintf(seq,64,"\x1b[%dG", 1+((plen+(int)l->pos) % (int)l->cols));
    abAppend(&ab,seq,strlen(seq));

    lndebug("\n");
    l->oldpos = l->pos;

    if (write(fd,ab.b,ab.len) == -1) {} /* Can't recover from write error. */
    abFree(&ab);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x20f0
movl %eax, -0x54(%rbp)
movslq -0x54(%rbp), %rax
movq -0x8(%rbp), %rcx
addq 0x38(%rcx), %rax
movq -0x8(%rbp), %rcx
addq 0x40(%rcx), %rax
subq $0x1, %rax
movq -0x8(%rbp), %rcx
xorl %edx, %edx
divq 0x40(%rcx)
movl %eax, -0x58(%rbp)
movslq -0x54(%rbp), %rax
movq -0x8(%rbp), %rcx
addq 0x30(%rcx), %rax
movq -0x8(%rbp), %rcx
addq 0x40(%rcx), %rax
movq -0x8(%rbp), %rcx
xorl %edx, %edx
divq 0x40(%rcx)
movl %eax, -0x5c(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movl %eax, -0x64(%rbp)
movq -0x8(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x68(%rbp)
movl -0x58(%rbp), %eax
movq -0x8(%rbp), %rcx
movq 0x48(%rcx), %rcx
cmpl %ecx, %eax
jle 0x9365
movslq -0x58(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x48(%rax)
leaq -0x80(%rbp), %rdi
callq 0x9860
movl -0x64(%rbp), %eax
subl -0x5c(%rbp), %eax
cmpl $0x0, %eax
jle 0x93bc
leaq -0x50(%rbp), %rdi
movl -0x64(%rbp), %ecx
subl -0x5c(%rbp), %ecx
movl $0x40, %esi
leaq 0x11649(%rip), %rdx     # 0x1a9d8
movb $0x0, %al
callq 0x2120
leaq -0x50(%rbp), %rax
movq %rax, -0x88(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x20f0
movq -0x88(%rbp), %rsi
movl %eax, %edx
leaq -0x80(%rbp), %rdi
callq 0x9880
movl $0x0, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
movl -0x64(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x9418
leaq -0x50(%rbp), %rdi
movl $0x40, %esi
leaq 0x115fe(%rip), %rdx     # 0x1a9de
movb $0x0, %al
callq 0x2120
leaq -0x50(%rbp), %rax
movq %rax, -0x90(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x20f0
movq -0x90(%rbp), %rsi
movl %eax, %edx
leaq -0x80(%rbp), %rdi
callq 0x9880
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x93c3
leaq -0x50(%rbp), %rdi
movl $0x40, %esi
leaq 0x115c3(%rip), %rdx     # 0x1a9eb
movb $0x0, %al
callq 0x2120
leaq -0x50(%rbp), %rax
movq %rax, -0xa0(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x20f0
movq -0xa0(%rbp), %rsi
movl %eax, %edx
leaq -0x80(%rbp), %rdi
callq 0x9880
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x98(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x20f0
movq -0x98(%rbp), %rsi
movl %eax, %edx
leaq -0x80(%rbp), %rdi
callq 0x9880
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movl %eax, %edx
leaq -0x80(%rbp), %rdi
callq 0x9880
movq -0x8(%rbp), %rax
cmpq $0x0, 0x28(%rax)
je 0x955a
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x8(%rbp), %rcx
cmpq 0x38(%rcx), %rax
jne 0x955a
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x54(%rbp), %rcx
addq %rcx, %rax
movq -0x8(%rbp), %rcx
xorl %edx, %edx
divq 0x40(%rcx)
cmpq $0x0, %rdx
jne 0x955a
leaq -0x80(%rbp), %rdi
leaq 0x12448(%rip), %rsi     # 0x1b935
movl $0x1, %edx
callq 0x9880
leaq -0x50(%rbp), %rdi
movl $0x40, %esi
leaq 0x114ca(%rip), %rdx     # 0x1a9d1
movb $0x0, %al
callq 0x2120
leaq -0x50(%rbp), %rax
movq %rax, -0xa8(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x20f0
movq -0xa8(%rbp), %rsi
movl %eax, %edx
leaq -0x80(%rbp), %rdi
callq 0x9880
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
movl -0x58(%rbp), %eax
movq -0x8(%rbp), %rcx
movq 0x48(%rcx), %rcx
cmpl %ecx, %eax
jle 0x9558
movslq -0x58(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x48(%rax)
jmp 0x955a
movslq -0x54(%rbp), %rax
movq -0x8(%rbp), %rcx
addq 0x28(%rcx), %rax
movq -0x8(%rbp), %rcx
addq 0x40(%rcx), %rax
movq -0x8(%rbp), %rcx
xorl %edx, %edx
divq 0x40(%rcx)
movl %eax, -0x60(%rbp)
movl -0x58(%rbp), %eax
subl -0x60(%rbp), %eax
cmpl $0x0, %eax
jle 0x95c9
leaq -0x50(%rbp), %rdi
movl -0x58(%rbp), %ecx
subl -0x60(%rbp), %ecx
movl $0x40, %esi
leaq 0x11458(%rip), %rdx     # 0x1a9f4
movb $0x0, %al
callq 0x2120
leaq -0x50(%rbp), %rax
movq %rax, -0xb0(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x20f0
movq -0xb0(%rbp), %rsi
movl %eax, %edx
leaq -0x80(%rbp), %rdi
callq 0x9880
leaq -0x50(%rbp), %rdi
movl -0x54(%rbp), %eax
movq -0x8(%rbp), %rcx
movq 0x28(%rcx), %rcx
addl %ecx, %eax
movq -0x8(%rbp), %rcx
movq 0x40(%rcx), %rcx
cltd
idivl %ecx
movl %edx, %ecx
addl $0x1, %ecx
movl $0x40, %esi
leaq 0x11404(%rip), %rdx     # 0x1a9fa
movb $0x0, %al
callq 0x2120
leaq -0x50(%rbp), %rax
movq %rax, -0xb8(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x20f0
movq -0xb8(%rbp), %rsi
movl %eax, %edx
leaq -0x80(%rbp), %rdi
callq 0x9880
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x30(%rax)
movl -0x68(%rbp), %edi
movq -0x80(%rbp), %rsi
movslq -0x78(%rbp), %rdx
callq 0x20c0
cmpq $-0x1, %rax
jne 0x964b
jmp 0x964b
leaq -0x80(%rbp), %rdi
callq 0x9900
addq $0xc0, %rsp
popq %rbp
retq
nopl (%rax)