// File: /workspace/github_cpp_makefile_star2_O3/sangwoojun[P]rv32emulator/./linenoise.hpp
// Function: linenoise::refreshSingleLine(linenoise::linenoiseState*)
inline void refreshSingleLine(struct linenoiseState *l) {
    char seq[64];
    int pcolwid = unicodeColumnPos(l->prompt.c_str(), static_cast<int>(l->prompt.length()));
    int fd = l->ofd;
    char *buf = l->buf;
    int len = l->len;
    int pos = l->pos;
    std::string ab;

    while((pcolwid+unicodeColumnPos(buf, pos)) >= l->cols) {
        int glen = unicodeGraphemeLen(buf, len, 0);
        buf += glen;
        len -= glen;
        pos -= glen;
    }
    while (pcolwid+unicodeColumnPos(buf, len) > l->cols) {
        len -= unicodePrevGraphemeLen(buf, len);
    }

    /* Cursor to left edge */
    snprintf(seq,64,"\r");
    ab += seq;
    /* Write the prompt and the current buffer content */
    ab += l->prompt;
    ab.append(buf, len);
    /* Erase to right */
    snprintf(seq,64,"\x1b[0K");
    ab += seq;
    /* Move cursor to original position. */
    snprintf(seq,64,"\r\x1b[%dC", (int)(unicodeColumnPos(buf, pos)+pcolwid));
    ab += seq;
    if (write(fd,ab.c_str(), static_cast<int>(ab.length())) == -1) {} /* Can't recover from write error. */
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdi, %rbx
movq 0x18(%rdi), %rdi
movl 0x20(%rbx), %esi
callq 0x6f77
movl %eax, -0x2c(%rbp)
movl 0x4(%rbx), %eax
movl %eax, -0x30(%rbp)
movq 0x8(%rbx), %r15
movl 0x40(%rbx), %r13d
movl 0x38(%rbx), %r12d
leaq -0x40(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x1550(%rip), %r14      # 0x8180
movq %r15, %rdi
movl %r12d, %esi
callq 0x6f77
addl -0x2c(%rbp), %eax
cmpl 0x44(%rbx), %eax
jl 0x6e86
testl %r13d, %r13d
je 0x6d60
movb (%r15), %cl
movl $0x1, %eax
testb %cl, %cl
jns 0x6c71
movl $0x2, %eax
cmpb $-0x20, %cl
jb 0x6c71
cmpb $-0x10, %cl
movl $0x4, %eax
sbbl $0x0, %eax
cmpl %r13d, %eax
jge 0x6d62
movslq %eax, %rsi
movzbl (%r15,%rsi), %edx
testb %dl, %dl
js 0x6c90
movl $0x1, %ecx
jmp 0x6d42
addq %r15, %rsi
cmpb $-0x10, %dl
movl $0x4, %ecx
sbbl $0x0, %ecx
cmpb $-0x20, %dl
movl $0x2, %edi
cmovbl %edi, %ecx
movl %edx, %edi
andl $-0x20, %edi
cmpl $0xc0, %edi
jne 0x6cd2
andl $0x1f, %edx
shll $0x6, %edx
movl $0x1, %r8d
movq %rdx, %rdi
movzbl (%rsi,%r8), %edx
andl $0x3f, %edx
orq %rdi, %rdx
jmp 0x6d42
movl %edx, %edi
andl $-0x10, %edi
cmpl $0xe0, %edi
jne 0x6cfe
cmpb $-0x20, %dl
jb 0x6d3b
andl $0xf, %edx
shll $0xc, %edx
movzbl 0x1(%rsi), %edi
andl $0x3f, %edi
shll $0x6, %edi
orl %edx, %edi
movl $0x2, %r8d
jmp 0x6cc5
movl %edx, %edi
andl $-0x8, %edi
cmpl $0xf0, %edi
jne 0x6d40
cmpl $0x4, %ecx
jb 0x6d40
andl $0x7, %edx
shll $0x12, %edx
movzbl 0x1(%rsi), %r8d
andl $0x3f, %r8d
shll $0xc, %r8d
orl %edx, %r8d
movzbl 0x2(%rsi), %edi
andl $0x3f, %edi
shll $0x6, %edi
orl %r8d, %edi
movl $0x3, %r8d
jmp 0x6cc5
movl $0x2, %ecx
xorl %edx, %edx
xorl %esi, %esi
cmpq %rdx, (%rsi,%r14)
je 0x6d59
addq $0x8, %rsi
cmpq $0x30f8, %rsi           # imm = 0x30F8
jne 0x6d44
jmp 0x6d62
addl %ecx, %eax
jmp 0x6c71
xorl %eax, %eax
cltq
addq %rax, %r15
subl %eax, %r13d
subl %eax, %r12d
jmp 0x6c30
movl %r13d, %eax
testl %r13d, %r13d
jle 0x6e7c
movl %eax, %esi
movl %eax, %ecx
decq %rcx
testl %eax, %eax
jle 0x6d9d
movl %ecx, %edx
movb (%r15,%rdx), %dl
andb $-0x40, %dl
decl %eax
decq %rcx
negb %dl
jo 0x6d85
jmp 0x6da2
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
subl %eax, %esi
jne 0x6dad
xorl %edi, %edi
jmp 0x6e5b
movslq %eax, %rcx
addq %r15, %rcx
movzbl (%rcx), %edx
movl %edx, %edi
testb %dl, %dl
jns 0x6e5b
movl %edx, %edi
andl $-0x20, %edi
cmpl $0xc0, %edi
jne 0x6de8
movl $0x0, %edi
cmpl $0x2, %esi
jl 0x6e5b
andl $0x1f, %edx
shll $0x6, %edx
movl $0x1, %esi
jmp 0x6e52
movl %edx, %edi
andl $-0x10, %edi
cmpl $0xe0, %edi
jne 0x6e18
movl $0x0, %edi
cmpl $0x3, %esi
jl 0x6e5b
andl $0xf, %edx
shll $0xc, %edx
movzbl 0x1(%rcx), %esi
andl $0x3f, %esi
shll $0x6, %esi
orl %esi, %edx
movl $0x2, %esi
jmp 0x6e52
cmpl $0x4, %esi
jl 0x6da6
movl %edx, %esi
andl $-0x8, %esi
movl $0x0, %edi
cmpl $0xf0, %esi
jne 0x6e5b
andl $0x7, %edx
shll $0x12, %edx
movzbl 0x1(%rcx), %esi
andl $0x3f, %esi
shll $0xc, %esi
orl %edx, %esi
movzbl 0x2(%rcx), %edx
andl $0x3f, %edx
shll $0x6, %edx
orl %esi, %edx
movl $0x3, %esi
movzbl (%rcx,%rsi), %edi
andl $0x3f, %edi
orl %edx, %edi
movl %edi, %ecx
xorl %edx, %edx
cmpq %rcx, (%rdx,%r14)
je 0x6e74
addq $0x8, %rdx
cmpq $0x30f8, %rdx           # imm = 0x30F8
jne 0x6e5f
jmp 0x6e80
testl %eax, %eax
jg 0x6d7e
xorl %eax, %eax
jmp 0x6e83
subl %r13d, %eax
addl %eax, %r13d
movq %r15, %rdi
movl %r13d, %esi
callq 0x6f77
addl -0x2c(%rbp), %eax
cmpl 0x44(%rbx), %eax
jg 0x6d72
leaq -0x90(%rbp), %rsi
movw $0xd, (%rsi)
leaq -0x50(%rbp), %rdi
callq 0x23a0
movq 0x18(%rbx), %rsi
movq 0x20(%rbx), %rdx
leaq -0x50(%rbp), %rdi
callq 0x2090
movslq %r13d, %rdx
leaq -0x50(%rbp), %rdi
movq %r15, %rsi
callq 0x2050
leaq -0x90(%rbp), %rsi
movb $0x0, 0x4(%rsi)
movl $0x4b305b1b, (%rsi)     # imm = 0x4B305B1B
leaq -0x50(%rbp), %rdi
callq 0x23a0
movq %r15, %rdi
movl %r12d, %esi
callq 0x6f77
addl -0x2c(%rbp), %eax
leaq 0x4ad1(%rip), %rdx      # 0xb9d2
leaq -0x90(%rbp), %rbx
movl $0x40, %esi
movq %rbx, %rdi
movl %eax, %ecx
xorl %eax, %eax
callq 0x2340
leaq -0x50(%rbp), %rdi
movq %rbx, %rsi
callq 0x23a0
movq -0x50(%rbp), %rsi
movslq -0x48(%rbp), %rdx
movl -0x30(%rbp), %edi
callq 0x20a0
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x6f47
callq 0x2180
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6f5a
jmp 0x6f5a
movq %rax, %rbx
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x6f6f
callq 0x2180
movq %rbx, %rdi
callq 0x2370