// File: andrakis[P]alisp/contrib/linenoise-ng/src/linenoise.cpp
// Function: PromptInfo::PromptInfo(char const*, int)
PromptInfo(const char* textPtr, int columns) {
    promptExtraLines = 0;
    promptLastLinePosition = 0;
    promptPreviousLen = 0;
    promptScreenColumns = columns;
    Utf32String tempUnicode(textPtr);

    // strip control characters from the prompt -- we do allow newline
    char32_t* pIn = tempUnicode.get();
    char32_t* pOut = pIn;

    int len = 0;
    int x = 0;

    bool const strip = (isatty(1) == 0);

    while (*pIn) {
      char32_t c = *pIn;
      if ('\n' == c || !isControlChar(c)) {
        *pOut = c;
        ++pOut;
        ++pIn;
        ++len;
        if ('\n' == c || ++x >= promptScreenColumns) {
          x = 0;
          ++promptExtraLines;
          promptLastLinePosition = len;
        }
      } else if (c == '\x1b') {
        if (strip) {
          // jump over control chars
          ++pIn;
          if (*pIn == '[') {
            ++pIn;
            while (*pIn && ((*pIn == ';') || ((*pIn >= '0' && *pIn <= '9')))) {
              ++pIn;
            }
            if (*pIn == 'm') {
              ++pIn;
            }
          }
        } else {
          // copy control chars
          *pOut = *pIn;
          ++pOut;
          ++pIn;
          if (*pIn == '[') {
            *pOut = *pIn;
            ++pOut;
            ++pIn;
            while (*pIn && ((*pIn == ';') || ((*pIn >= '0' && *pIn <= '9')))) {
              *pOut = *pIn;
              ++pOut;
              ++pIn;
            }
            if (*pIn == 'm') {
              *pOut = *pIn;
              ++pOut;
              ++pIn;
            }
          }
        }
      } else {
        ++pIn;
      }
    }
    *pOut = 0;
    promptChars = len;
    promptBytes = static_cast<int>(pOut - tempUnicode.get());
    promptText = tempUnicode;

    promptIndentation = len - promptLastLinePosition;
    promptCursorRowOffset = promptExtraLines;
  }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x60(%rbp)
callq 0x245d0
movq -0x60(%rbp), %rax
movl $0x0, 0x20(%rax)
movl $0x0, 0x28(%rax)
movl $0x0, 0x38(%rax)
movl -0x14(%rbp), %ecx
movl %ecx, 0x34(%rax)
movq -0x10(%rbp), %rsi
leaq -0x28(%rbp), %rdi
callq 0x23ab0
jmp 0x24b61
leaq -0x28(%rbp), %rdi
callq 0x23ec0
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x48(%rbp)
movl $0x0, -0x4c(%rbp)
movl $0x0, -0x50(%rbp)
movl $0x1, %edi
callq 0x87a0
cmpl $0x0, %eax
sete %al
andb $0x1, %al
movb %al, -0x51(%rbp)
movq -0x40(%rbp), %rax
cmpl $0x0, (%rax)
je 0x24df5
movq -0x40(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x58(%rbp)
movl $0xa, %eax
cmpl -0x58(%rbp), %eax
je 0x24bc5
movl -0x58(%rbp), %edi
callq 0x20020
testb $0x1, %al
jne 0x24c3d
movl -0x58(%rbp), %ecx
movq -0x48(%rbp), %rax
movl %ecx, (%rax)
movq -0x48(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x40(%rbp)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
movl $0xa, %eax
cmpl -0x58(%rbp), %eax
je 0x24c0b
movq -0x60(%rbp), %rcx
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
cmpl 0x34(%rcx), %eax
jl 0x24c38
movq -0x60(%rbp), %rax
movl $0x0, -0x50(%rbp)
movl 0x20(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x20(%rax)
movl -0x4c(%rbp), %ecx
movl %ecx, 0x28(%rax)
jmp 0x24c38
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x24e78
jmp 0x24df0
cmpl $0x1b, -0x58(%rbp)
jne 0x24de2
testb $0x1, -0x51(%rbp)
je 0x24ce8
movq -0x40(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpl $0x5b, (%rax)
jne 0x24ce3
movq -0x40(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rcx
xorl %eax, %eax
cmpl $0x0, (%rcx)
movb %al, -0x61(%rbp)
je 0x24cb5
movq -0x40(%rbp), %rcx
movb $0x1, %al
cmpl $0x3b, (%rcx)
movb %al, -0x62(%rbp)
je 0x24caf
movq -0x40(%rbp), %rcx
xorl %eax, %eax
cmpl $0x30, (%rcx)
movb %al, -0x63(%rbp)
jb 0x24ca9
movq -0x40(%rbp), %rax
cmpl $0x39, (%rax)
setbe %al
movb %al, -0x63(%rbp)
movb -0x63(%rbp), %al
movb %al, -0x62(%rbp)
movb -0x62(%rbp), %al
movb %al, -0x61(%rbp)
movb -0x61(%rbp), %al
testb $0x1, %al
jne 0x24cbe
jmp 0x24ccc
movq -0x40(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x40(%rbp)
jmp 0x24c72
movq -0x40(%rbp), %rax
cmpl $0x6d, (%rax)
jne 0x24ce1
movq -0x40(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x40(%rbp)
jmp 0x24ce3
jmp 0x24de0
movq -0x40(%rbp), %rax
movl (%rax), %ecx
movq -0x48(%rbp), %rax
movl %ecx, (%rax)
movq -0x48(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpl $0x5b, (%rax)
jne 0x24dde
movq -0x40(%rbp), %rax
movl (%rax), %ecx
movq -0x48(%rbp), %rax
movl %ecx, (%rax)
movq -0x48(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rcx
xorl %eax, %eax
cmpl $0x0, (%rcx)
movb %al, -0x64(%rbp)
je 0x24d80
movq -0x40(%rbp), %rcx
movb $0x1, %al
cmpl $0x3b, (%rcx)
movb %al, -0x65(%rbp)
je 0x24d7a
movq -0x40(%rbp), %rcx
xorl %eax, %eax
cmpl $0x30, (%rcx)
movb %al, -0x66(%rbp)
jb 0x24d74
movq -0x40(%rbp), %rax
cmpl $0x39, (%rax)
setbe %al
movb %al, -0x66(%rbp)
movb -0x66(%rbp), %al
movb %al, -0x65(%rbp)
movb -0x65(%rbp), %al
movb %al, -0x64(%rbp)
movb -0x64(%rbp), %al
testb $0x1, %al
jne 0x24d89
jmp 0x24daf
movq -0x40(%rbp), %rax
movl (%rax), %ecx
movq -0x48(%rbp), %rax
movl %ecx, (%rax)
movq -0x48(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x40(%rbp)
jmp 0x24d3d
movq -0x40(%rbp), %rax
cmpl $0x6d, (%rax)
jne 0x24ddc
movq -0x40(%rbp), %rax
movl (%rax), %ecx
movq -0x48(%rbp), %rax
movl %ecx, (%rax)
movq -0x48(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x40(%rbp)
jmp 0x24dde
jmp 0x24de0
jmp 0x24dee
movq -0x40(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x40(%rbp)
jmp 0x24df0
jmp 0x24b99
movq -0x60(%rbp), %rax
movq -0x48(%rbp), %rcx
movl $0x0, (%rcx)
movl -0x4c(%rbp), %ecx
movl %ecx, 0x18(%rax)
movq -0x48(%rbp), %rax
movq %rax, -0x70(%rbp)
leaq -0x28(%rbp), %rdi
movq %rdi, -0x78(%rbp)
callq 0x23ec0
movq -0x60(%rbp), %rdi
movq -0x78(%rbp), %rsi
movq %rax, %rcx
movq -0x70(%rbp), %rax
subq %rcx, %rax
shrq $0x2, %rax
movl %eax, 0x1c(%rdi)
callq 0x24640
jmp 0x24e3e
movq -0x60(%rbp), %rax
movl -0x4c(%rbp), %ecx
subl 0x28(%rax), %ecx
movl %ecx, 0x24(%rax)
movl 0x20(%rax), %ecx
movl %ecx, 0x30(%rax)
leaq -0x28(%rbp), %rdi
callq 0x23b50
addq $0x80, %rsp
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x23b50
movq -0x60(%rbp), %rdi
callq 0x24700
movq -0x30(%rbp), %rdi
callq 0x87b0
nopw (%rax,%rax)