// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
movl $0x4, %edi
callq 0x7030
xorl %r15d, %r15d
movl %r15d, (%rax)
movq %rax, 0x8(%rbx)
movl %r15d, 0x20(%rbx)
movq $0x0, 0x28(%rbx)
movl %r15d, 0x38(%rbx)
movl %ebp, 0x34(%rbx)
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x13dc0
movq 0x10(%rsp), %r14
movl $0x1, %edi
callq 0x7620
movl 0x20(%rbx), %ecx
movl 0x34(%rbx), %edx
movq %r14, %r9
xorl %esi, %esi
movq %r9, %rdi
movq %r14, %r8
movl (%r14), %r9d
cmpl $0xa, %r9d
je 0x1475f
testl %r9d, %r9d
je 0x14784
cmpl $0x20, %r9d
setb %r10b
leal -0x7f(%r9), %r11d
cmpl $0x21, %r11d
setb %r11b
orb %r10b, %r11b
je 0x146ba
cmpl $0x1b, %r9d
jne 0x146dd
testl %eax, %eax
je 0x146ec
movl $0x1b, (%rdi)
leaq 0x4(%rdi), %r9
leaq 0x4(%r8), %r14
cmpl $0x5b, 0x4(%r8)
jne 0x1462e
movl $0x5b, 0x4(%rdi)
addq $0x8, %rdi
addq $0x8, %r8
movq %r8, %r14
movq %rdi, %r9
movl (%r14), %edi
cmpl $0x3b, %edi
je 0x146ad
testl %edi, %edi
je 0x1462e
leal -0x30(%rdi), %r8d
cmpl $0x9, %r8d
ja 0x14723
movl %edi, (%r9)
addq $0x4, %r9
addq $0x4, %r14
jmp 0x14697
movl %r9d, (%rdi)
addq $0x4, %rdi
addq $0x4, %r8
incl %r15d
incl %esi
movq %r8, %r14
movq %rdi, %r9
cmpl %edx, %esi
jl 0x1462e
jmp 0x14770
addq $0x4, %r8
movq %r8, %r14
movq %rdi, %r9
jmp 0x1462e
leaq 0x4(%r8), %r14
cmpl $0x5b, 0x4(%r8)
movq %rdi, %r9
jne 0x1462e
addq $0x8, %r8
movq %r8, %r14
movl (%r14), %r8d
cmpl $0x3b, %r8d
je 0x1471d
testl %r8d, %r8d
je 0x14740
leal -0x30(%r8), %r9d
cmpl $0x9, %r9d
ja 0x14745
addq $0x4, %r14
jmp 0x14705
cmpl $0x6d, %edi
jne 0x1462e
movl $0x6d, (%r9)
addq $0x4, %r9
addq $0x4, %r14
jmp 0x1462e
xorl %r9d, %r9d
jmp 0x14754
xorl %r9d, %r9d
cmpl $0x6d, %r8d
sete %r9b
shll $0x2, %r9d
addq %r9, %r14
movq %rdi, %r9
jmp 0x1462e
movl $0xa, (%rdi)
addq $0x4, %rdi
addq $0x4, %r8
incl %r15d
incl %ecx
movl %ecx, 0x20(%rbx)
movl %r15d, 0x28(%rbx)
movq %r8, %r14
movq %rdi, %r9
jmp 0x1462c
movl $0x0, (%rdi)
movl %r15d, 0x18(%rbx)
leaq 0x8(%rsp), %rsi
subq 0x8(%rsi), %rdi
shrq $0x2, %rdi
movl %edi, 0x1c(%rbx)
movq %rbx, %rdi
callq 0x142ba
subl 0x28(%rbx), %r15d
movl %r15d, 0x24(%rbx)
movl 0x20(%rbx), %eax
movl %eax, 0x30(%rbx)
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x147c3
callq 0x7490
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x147e5
callq 0x7490
jmp 0x147e5
movq %rax, %r14
movq 0x8(%rbx), %rdi
testq %rdi, %rdi
je 0x147f3
callq 0x7490
movq %r14, %rdi
callq 0x7630
nop