// File: /workspace/github_cpp_makefile_star2_O3/andrakis[P]alisp/contrib/linenoise-ng/src/linenoise.cpp
// Function: linenoisePreloadBuffer
void linenoisePreloadBuffer(const char* preloadText) {
  if (!preloadText) {
    return;
  }
  int bufferSize = static_cast<int>(strlen(preloadText) + 1);
  unique_ptr<char[]> tempBuffer(new char[bufferSize]);
  strncpy(&tempBuffer[0], preloadText, bufferSize);

  // remove characters that won't display correctly
  char* pIn = &tempBuffer[0];
  char* pOut = pIn;
  bool controlsStripped = false;
  bool whitespaceSeen = false;
  while (*pIn) {
    unsigned char c =
        *pIn++;       // we need unsigned so chars 0x80 and above are allowed
    if ('\r' == c) {  // silently skip CR
      continue;
    }
    if ('\n' == c || '\t' == c) {  // note newline or tab
      whitespaceSeen = true;
      continue;
    }
    if (isControlChar(
            c)) {  // remove other control characters, flag for message
      controlsStripped = true;
      *pOut++ = ' ';
      continue;
    }
    if (whitespaceSeen) {  // convert whitespace to a single space
      *pOut++ = ' ';
      whitespaceSeen = false;
    }
    *pOut++ = c;
  }
  *pOut = 0;
  int processedLength = static_cast<int>(pOut - tempBuffer.get());
  bool lineTruncated = false;
  if (processedLength > (LINENOISE_MAX_LINE - 1)) {
    lineTruncated = true;
    tempBuffer[LINENOISE_MAX_LINE - 1] = 0;
  }
  preloadedBufferContents = tempBuffer.get();
  if (controlsStripped) {
    preloadErrorMessage +=
        " [Edited line: control characters were converted to spaces]\n";
  }
  if (lineTruncated) {
    preloadErrorMessage += " [Edited line: the line length was reduced from ";
    char buf[128];
    snprintf(buf, sizeof(buf), "%d to %d]\n", processedLength,
             (LINENOISE_MAX_LINE - 1));
    preloadErrorMessage += buf;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x80, %rsp
testq %rdi, %rdi
je 0x130fd
movq %rdi, %r14
callq 0x7180
incl %eax
movslq %eax, %r15
movq %r15, %rdi
callq 0x7030
movq %rax, %rbx
movq %rax, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x71c0
movb (%rbx), %dl
testb %dl, %dl
je 0x1304a
movq %rbx, %rax
incq %rax
xorl %ecx, %ecx
xorl %ebp, %ebp
movq %rbx, %r14
cmpb $0xd, %dl
je 0x1303f
leal -0x9(%rdx), %esi
cmpb $0x2, %sil
jae 0x1300f
movb $0x1, %cl
jmp 0x1303f
cmpb $0x20, %dl
jb 0x13035
movzbl %dl, %esi
addl $-0x7f, %esi
cmpl $0x20, %esi
jbe 0x13035
testb $0x1, %cl
je 0x1302b
movb $0x20, (%r14)
incq %r14
movb %dl, (%r14)
incq %r14
xorl %ecx, %ecx
jmp 0x1303f
movb $0x20, (%r14)
incq %r14
movb $0x1, %bpl
movb (%rax), %dl
incq %rax
testb %dl, %dl
jne 0x12ffd
jmp 0x1304f
xorl %ebp, %ebp
movq %rbx, %r14
movb $0x0, (%r14)
subl %ebx, %r14d
cmpl $0x1000, %r14d          # imm = 0x1000
jl 0x13066
movb $0x0, 0xfff(%rbx)
movq 0x1b643(%rip), %r15     # 0x2e6b0
leaq 0x1b634(%rip), %r12     # 0x2e6a8
movq %rbx, %rdi
callq 0x7180
movq %r12, %rdi
xorl %esi, %esi
movq %r15, %rdx
movq %rbx, %rcx
movq %rax, %r8
callq 0x7550
testb $0x1, %bpl
je 0x130a8
leaq 0x1b62c(%rip), %rdi     # 0x2e6c8
leaq 0xdae6(%rip), %rsi      # 0x20b89
callq 0x7680
cmpl $0x1000, %r14d          # imm = 0x1000
jl 0x130f5
leaq 0x1b610(%rip), %rdi     # 0x2e6c8
leaq 0xdb07(%rip), %rsi      # 0x20bc6
callq 0x7680
leaq 0xdb2c(%rip), %rdx      # 0x20bf7
movq %rsp, %r15
movl $0x80, %esi
movq %r15, %rdi
movl %r14d, %ecx
movl $0xfff, %r8d            # imm = 0xFFF
xorl %eax, %eax
callq 0x75a0
leaq 0x1b5db(%rip), %rdi     # 0x2e6c8
movq %r15, %rsi
callq 0x7680
movq %rbx, %rdi
callq 0x7490
addq $0x80, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1310f
movq %rax, %r14
movq %rbx, %rdi
callq 0x7490
movq %r14, %rdi
callq 0x7630