// File: andrakis[P]alisp/contrib/linenoise-ng/src/linenoise.cpp
// Function: InputBuffer::completeLine(PromptBase&)
int InputBuffer::completeLine(PromptBase& pi) {
  linenoiseCompletions lc;
  char32_t c = 0;

  // completionCallback() expects a parsable entity, so find the previous break
  // character and
  // extract a copy to parse.  we also handle the case where tab is hit while
  // not at end-of-line.
  int startIndex = pos;
  while (--startIndex >= 0) {
    if (strchr(breakChars, buf32[startIndex])) {
      break;
    }
  }
  ++startIndex;
  int itemLength = pos - startIndex;
  Utf32String unicodeCopy(&buf32[startIndex], itemLength);
  Utf8String parseItem(unicodeCopy);

  // get a list of completions
  completionCallback(parseItem.get(), &lc);

  // if no completions, we are done
  if (lc.completionStrings.size() == 0) {
    beep();
    freeCompletions(&lc);
    return 0;
  }

  // at least one completion
  int longestCommonPrefix = 0;
  int displayLength = 0;
  if (lc.completionStrings.size() == 1) {
    longestCommonPrefix = static_cast<int>(lc.completionStrings[0].length());
  } else {
    bool keepGoing = true;
    while (keepGoing) {
      for (size_t j = 0; j < lc.completionStrings.size() - 1; ++j) {
        char32_t c1 = lc.completionStrings[j][longestCommonPrefix];
        char32_t c2 = lc.completionStrings[j + 1][longestCommonPrefix];
        if ((0 == c1) || (0 == c2) || (c1 != c2)) {
          keepGoing = false;
          break;
        }
      }
      if (keepGoing) {
        ++longestCommonPrefix;
      }
    }
  }
  if (lc.completionStrings.size() != 1) {  // beep if ambiguous
    beep();
  }

  // if we can extend the item, extend it and return to main loop
  if (longestCommonPrefix > itemLength) {
    displayLength = len + longestCommonPrefix - itemLength;
    if (displayLength > buflen) {
      longestCommonPrefix -= displayLength - buflen;  // don't overflow buffer
      displayLength = buflen;                         // truncate the insertion
      beep();                                         // and make a noise
    }
    Utf32String displayText(displayLength + 1);
    memcpy(displayText.get(), buf32, sizeof(char32_t) * startIndex);
    memcpy(&displayText[startIndex], &lc.completionStrings[0][0],
           sizeof(char32_t) * longestCommonPrefix);
    int tailIndex = startIndex + longestCommonPrefix;
    memcpy(&displayText[tailIndex], &buf32[pos],
           sizeof(char32_t) * (displayLength - tailIndex + 1));
    copyString32(buf32, displayText.get(), displayLength);
    pos = startIndex + longestCommonPrefix;
    len = displayLength;
    refreshLine(pi);
    return 0;
  }

  // we can't complete any further, wait for second tab
  do {
    c = linenoiseReadChar();
    c = cleanupCtrl(c);
  } while (c == static_cast<char32_t>(-1));

  // if any character other than tab, pass it to the main loop
  if (c != ctrlChar('I')) {
    freeCompletions(&lc);
    return c;
  }

  // we got a second tab, maybe show list of possible completions
  bool showCompletions = true;
  bool onNewLine = false;
  if (lc.completionStrings.size() > completionCountCutoff) {
    int savePos =
        pos;  // move cursor to EOL to avoid overwriting the command line
    pos = len;
    refreshLine(pi);
    pos = savePos;
    printf("\nDisplay all %u possibilities? (y or n)",
           static_cast<unsigned int>(lc.completionStrings.size()));
    fflush(stdout);
    onNewLine = true;
    while (c != 'y' && c != 'Y' && c != 'n' && c != 'N' && c != ctrlChar('C')) {
      do {
        c = linenoiseReadChar();
        c = cleanupCtrl(c);
      } while (c == static_cast<char32_t>(-1));
    }
    switch (c) {
      case 'n':
      case 'N':
        showCompletions = false;
        freeCompletions(&lc);
        break;
      case ctrlChar('C'):
        showCompletions = false;
        freeCompletions(&lc);
        if (write(1, "^C", 2) == -1) return -1;  // Display the ^C we got
        c = 0;
        break;
    }
  }

  // if showing the list, do it the way readline does it
  bool stopList = false;
  if (showCompletions) {
    int longestCompletion = 0;
    for (size_t j = 0; j < lc.completionStrings.size(); ++j) {
      itemLength = static_cast<int>(lc.completionStrings[j].length());
      if (itemLength > longestCompletion) {
        longestCompletion = itemLength;
      }
    }
    longestCompletion += 2;
    int columnCount = pi.promptScreenColumns / longestCompletion;
    if (columnCount < 1) {
      columnCount = 1;
    }
    if (!onNewLine) {  // skip this if we showed "Display all %d possibilities?"
      int savePos =
          pos;  // move cursor to EOL to avoid overwriting the command line
      pos = len;
      refreshLine(pi);
      pos = savePos;
    }
    size_t pauseRow = getScreenRows() - 1;
    size_t rowCount =
        (lc.completionStrings.size() + columnCount - 1) / columnCount;
    for (size_t row = 0; row < rowCount; ++row) {
      if (row == pauseRow) {
        printf("\n--More--");
        fflush(stdout);
        c = 0;
        bool doBeep = false;
        while (c != ' ' && c != '\r' && c != '\n' && c != 'y' && c != 'Y' &&
               c != 'n' && c != 'N' && c != 'q' && c != 'Q' &&
               c != ctrlChar('C')) {
          if (doBeep) {
            beep();
          }
          doBeep = true;
          do {
            c = linenoiseReadChar();
            c = cleanupCtrl(c);
          } while (c == static_cast<char32_t>(-1));
        }
        switch (c) {
          case ' ':
          case 'y':
          case 'Y':
            printf("\r        \r");
            pauseRow += getScreenRows() - 1;
            break;
          case '\r':
          case '\n':
            printf("\r        \r");
            ++pauseRow;
            break;
          case 'n':
          case 'N':
          case 'q':
          case 'Q':
            printf("\r        \r");
            stopList = true;
            break;
          case ctrlChar('C'):
            if (write(1, "^C", 2) == -1) return -1;  // Display the ^C we got
            stopList = true;
            break;
        }
      } else {
        printf("\n");
      }
      if (stopList) {
        break;
      }
      for (int column = 0; column < columnCount; ++column) {
        size_t index = (column * rowCount) + row;
        if (index < lc.completionStrings.size()) {
          itemLength = static_cast<int>(lc.completionStrings[index].length());
          fflush(stdout);
          if (write32(1, lc.completionStrings[index].get(), itemLength) == -1)
            return -1;
          if (((column + 1) * rowCount) + row < lc.completionStrings.size()) {
            for (int k = itemLength; k < longestCompletion; ++k) {
              printf(" ");
            }
          }
        }
      }
    }
    fflush(stdout);
    freeCompletions(&lc);
  }

  // display the prompt on a new line, then redisplay the input buffer
  if (!stopList || c == ctrlChar('C')) {
    if (write(1, "\n", 1) == -1) return 0;
  }
  if (!pi.write()) return 0;
#ifndef _WIN32
  // we have to generate our own newline on line wrap on Linux
  if (pi.promptIndentation == 0 && pi.promptExtraLines > 0)
    if (write(1, "\n", 1) == -1) return 0;
#endif
  pi.promptCursorRowOffset = pi.promptExtraLines;
  refreshLine(pi);
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1f0, %rsp            # imm = 0x1F0
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xf8(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x23c70
movq -0xf8(%rbp), %rax
movl $0x0, -0x34(%rbp)
movl 0x18(%rax), %eax
movl %eax, -0x38(%rbp)
movl -0x38(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x38(%rbp)
cmpl $0x0, %eax
jl 0x1dab0
movq -0xf8(%rbp), %rax
movq (%rax), %rax
movslq -0x38(%rbp), %rcx
movl (%rax,%rcx,4), %esi
leaq 0x1f1df(%rip), %rdi     # 0x3cc80
callq 0x81b0
cmpq $0x0, %rax
je 0x1daae
jmp 0x1dab0
jmp 0x1da7b
movq -0xf8(%rbp), %rax
movl -0x38(%rbp), %ecx
incl %ecx
movl %ecx, -0x38(%rbp)
movl 0x18(%rax), %ecx
movl -0x38(%rbp), %edx
subl %edx, %ecx
movl %ecx, -0x3c(%rbp)
movq (%rax), %rax
movslq -0x38(%rbp), %rcx
leaq (%rax,%rcx,4), %rsi
movl -0x3c(%rbp), %edx
leaq -0x50(%rbp), %rdi
callq 0x23c90
jmp 0x1dae3
leaq -0x68(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x23d20
jmp 0x1daf2
movq 0x39fa7(%rip), %rax     # 0x57aa0
movq %rax, -0x108(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x23d90
movq %rax, -0x100(%rbp)
jmp 0x1db12
movq -0x108(%rbp), %rax
movq -0x100(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq *%rax
jmp 0x1db28
leaq -0x30(%rbp), %rdi
callq 0x23db0
cmpq $0x0, %rax
jne 0x1db8f
callq 0x1e810
jmp 0x1db3e
leaq -0x30(%rbp), %rdi
callq 0x1e840
jmp 0x1db49
movl $0x0, -0x4(%rbp)
movl $0x1, -0x6c(%rbp)
jmp 0x1e7b7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x1e7f0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x1e7e7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x1e7de
movl $0x0, -0x70(%rbp)
movl $0x0, -0x74(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x23db0
cmpq $0x1, %rax
jne 0x1dbd9
xorl %eax, %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
callq 0x23dd0
movq %rax, %rdi
callq 0x23df0
movq %rax, -0x110(%rbp)
jmp 0x1dbca
movq -0x110(%rbp), %rax
movl %eax, -0x70(%rbp)
jmp 0x1dcd0
movb $0x1, -0x75(%rbp)
testb $0x1, -0x75(%rbp)
je 0x1dcce
movq $0x0, -0x80(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0x118(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x23db0
movq %rax, %rcx
movq -0x118(%rbp), %rax
subq $0x1, %rcx
cmpq %rcx, %rax
jae 0x1dcba
movq -0x80(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0x23dd0
movq %rax, %rdi
movslq -0x70(%rbp), %rsi
callq 0x23e10
movq %rax, -0x120(%rbp)
jmp 0x1dc3c
movq -0x120(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x84(%rbp)
movq -0x80(%rbp), %rsi
incq %rsi
leaq -0x30(%rbp), %rdi
callq 0x23dd0
movq %rax, %rdi
movslq -0x70(%rbp), %rsi
callq 0x23e10
movq %rax, -0x128(%rbp)
jmp 0x1dc70
movq -0x128(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x88(%rbp)
xorl %eax, %eax
cmpl -0x84(%rbp), %eax
je 0x1dca1
xorl %eax, %eax
cmpl -0x88(%rbp), %eax
je 0x1dca1
movl -0x84(%rbp), %eax
cmpl -0x88(%rbp), %eax
je 0x1dca7
movb $0x0, -0x75(%rbp)
jmp 0x1dcba
jmp 0x1dca9
movq -0x80(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x80(%rbp)
jmp 0x1dbef
testb $0x1, -0x75(%rbp)
je 0x1dcc9
movl -0x70(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x70(%rbp)
jmp 0x1dbdd
jmp 0x1dcd0
leaq -0x30(%rbp), %rdi
callq 0x23db0
cmpq $0x1, %rax
je 0x1dce8
callq 0x1e810
jmp 0x1dce6
jmp 0x1dce8
movl -0x70(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jle 0x1ded6
movq -0xf8(%rbp), %rcx
movl 0x14(%rcx), %eax
addl -0x70(%rbp), %eax
subl -0x3c(%rbp), %eax
movl %eax, -0x74(%rbp)
movl -0x74(%rbp), %eax
cmpl 0x10(%rcx), %eax
jle 0x1dd35
movq -0xf8(%rbp), %rax
movl -0x74(%rbp), %esi
movl 0x10(%rax), %edx
movl -0x70(%rbp), %ecx
subl %esi, %edx
addl %edx, %ecx
movl %ecx, -0x70(%rbp)
movl 0x10(%rax), %eax
movl %eax, -0x74(%rbp)
callq 0x1e810
jmp 0x1dd33
jmp 0x1dd35
movl -0x74(%rbp), %esi
incl %esi
leaq -0x98(%rbp), %rdi
callq 0x23e40
jmp 0x1dd48
leaq -0x98(%rbp), %rdi
callq 0x23ec0
movq %rax, -0x130(%rbp)
jmp 0x1dd5d
movq -0x130(%rbp), %rdi
movq -0xf8(%rbp), %rax
movq (%rax), %rsi
movslq -0x38(%rbp), %rdx
shlq $0x2, %rdx
callq 0x8360
movslq -0x38(%rbp), %rsi
leaq -0x98(%rbp), %rdi
callq 0x23e10
movq %rax, -0x138(%rbp)
jmp 0x1dd94
xorl %eax, %eax
movl %eax, %esi
movq %rsi, -0x148(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x23dd0
movq -0x148(%rbp), %rsi
movq %rax, %rdi
callq 0x23e10
movq %rax, -0x140(%rbp)
jmp 0x1ddc0
movq -0x140(%rbp), %rsi
movq -0x138(%rbp), %rdi
movslq -0x70(%rbp), %rdx
shlq $0x2, %rdx
callq 0x8360
movl -0x38(%rbp), %eax
movl -0x70(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x9c(%rbp)
movslq -0x9c(%rbp), %rsi
leaq -0x98(%rbp), %rdi
callq 0x23e10
movq %rax, -0x150(%rbp)
jmp 0x1de05
movq -0xf8(%rbp), %rcx
movq -0x150(%rbp), %rdi
movq (%rcx), %rax
movslq 0x18(%rcx), %rcx
leaq (%rax,%rcx,4), %rsi
movl -0x74(%rbp), %eax
movl -0x9c(%rbp), %ecx
subl %ecx, %eax
cltq
leaq 0x4(,%rax,4), %rdx
callq 0x8360
movq -0xf8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x160(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x23ec0
movq %rax, -0x158(%rbp)
jmp 0x1de5e
movq -0x158(%rbp), %rsi
movq -0x160(%rbp), %rdi
movslq -0x74(%rbp), %rdx
callq 0x1e860
jmp 0x1de77
movq -0xf8(%rbp), %rdi
movl -0x38(%rbp), %eax
movl -0x70(%rbp), %ecx
addl %ecx, %eax
movl %eax, 0x18(%rdi)
movl -0x74(%rbp), %eax
movl %eax, 0x14(%rdi)
movq -0x18(%rbp), %rsi
callq 0x1d280
jmp 0x1de9a
movl $0x0, -0x4(%rbp)
movl $0x1, -0x6c(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x23b50
jmp 0x1e7b7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x23b50
jmp 0x1e7de
jmp 0x1ded8
callq 0x1e8d0
movl %eax, -0x164(%rbp)
jmp 0x1dee5
movl -0x164(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %edi
callq 0x1eac0
movl %eax, -0x168(%rbp)
jmp 0x1defe
movl -0x168(%rbp), %eax
movl %eax, -0x34(%rbp)
cmpl $-0x1, -0x34(%rbp)
je 0x1ded8
cmpl $0x9, -0x34(%rbp)
je 0x1df30
leaq -0x30(%rbp), %rdi
callq 0x1e840
jmp 0x1df1e
movl -0x34(%rbp), %eax
movl %eax, -0x4(%rbp)
movl $0x1, -0x6c(%rbp)
jmp 0x1e7b7
movb $0x1, -0x9d(%rbp)
movb $0x0, -0x9e(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x23db0
cmpq $0x64, %rax
jbe 0x1e0da
movq -0xf8(%rbp), %rdi
movl 0x18(%rdi), %eax
movl %eax, -0xa4(%rbp)
movl 0x14(%rdi), %eax
movl %eax, 0x18(%rdi)
movq -0x18(%rbp), %rsi
callq 0x1d280
jmp 0x1df72
movq -0xf8(%rbp), %rax
movl -0xa4(%rbp), %ecx
movl %ecx, 0x18(%rax)
leaq -0x30(%rbp), %rdi
callq 0x23db0
movl %eax, %esi
leaq 0x1ea65(%rip), %rdi     # 0x3c9f9
xorl %eax, %eax
callq 0x8080
jmp 0x1df9d
movq 0x38fdc(%rip), %rax     # 0x56f80
movq (%rax), %rdi
callq 0x84f0
jmp 0x1dfae
movb $0x1, -0x9e(%rbp)
xorl %eax, %eax
cmpl $0x79, -0x34(%rbp)
movb %al, -0x169(%rbp)
je 0x1dffa
xorl %eax, %eax
cmpl $0x59, -0x34(%rbp)
movb %al, -0x169(%rbp)
je 0x1dffa
xorl %eax, %eax
cmpl $0x6e, -0x34(%rbp)
movb %al, -0x169(%rbp)
je 0x1dffa
xorl %eax, %eax
cmpl $0x4e, -0x34(%rbp)
movb %al, -0x169(%rbp)
je 0x1dffa
cmpl $0x3, -0x34(%rbp)
setne %al
movb %al, -0x169(%rbp)
movb -0x169(%rbp), %al
testb $0x1, %al
jne 0x1e006
jmp 0x1e042
jmp 0x1e008
callq 0x1e8d0
movl %eax, -0x170(%rbp)
jmp 0x1e015
movl -0x170(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %edi
callq 0x1eac0
movl %eax, -0x174(%rbp)
jmp 0x1e02e
movl -0x174(%rbp), %eax
movl %eax, -0x34(%rbp)
cmpl $-0x1, -0x34(%rbp)
je 0x1e008
jmp 0x1dfb5
movl -0x34(%rbp), %eax
movl %eax, -0x178(%rbp)
subl $0x3, %eax
je 0x1e080
jmp 0x1e052
movl -0x178(%rbp), %eax
subl $0x4e, %eax
je 0x1e06c
jmp 0x1e05f
movl -0x178(%rbp), %eax
subl $0x6e, %eax
jne 0x1e0d8
jmp 0x1e06c
movb $0x0, -0x9d(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x1e840
jmp 0x1e07e
jmp 0x1e0d8
movb $0x0, -0x9d(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x1e840
jmp 0x1e092
leaq 0x1e988(%rip), %rsi     # 0x3ca21
movl $0x1, %edi
movl $0x2, %edx
callq 0x8190
movq %rax, -0x180(%rbp)
jmp 0x1e0b1
movq -0x180(%rbp), %rax
cmpq $-0x1, %rax
jne 0x1e0d1
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0x6c(%rbp)
jmp 0x1e7b7
movl $0x0, -0x34(%rbp)
jmp 0x1e0da
movb $0x0, -0xa5(%rbp)
testb $0x1, -0x9d(%rbp)
je 0x1e6be
movl $0x0, -0xac(%rbp)
movq $0x0, -0xb8(%rbp)
movq -0xb8(%rbp), %rax
movq %rax, -0x188(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x23db0
movq %rax, %rcx
movq -0x188(%rbp), %rax
cmpq %rcx, %rax
jae 0x1e17e
movq -0xb8(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0x23dd0
movq %rax, %rdi
callq 0x23df0
movq %rax, -0x190(%rbp)
jmp 0x1e14a
movq -0x190(%rbp), %rax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0xac(%rbp), %eax
jle 0x1e168
movl -0x3c(%rbp), %eax
movl %eax, -0xac(%rbp)
jmp 0x1e16a
movq -0xb8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xb8(%rbp)
jmp 0x1e103
movl -0xac(%rbp), %eax
addl $0x2, %eax
movl %eax, -0xac(%rbp)
movq -0x18(%rbp), %rax
movl 0x34(%rax), %eax
cltd
idivl -0xac(%rbp)
movl %eax, -0xbc(%rbp)
cmpl $0x1, -0xbc(%rbp)
jge 0x1e1b4
movl $0x1, -0xbc(%rbp)
testb $0x1, -0x9e(%rbp)
jne 0x1e1ee
movq -0xf8(%rbp), %rdi
movl 0x18(%rdi), %eax
movl %eax, -0xc0(%rbp)
movl 0x14(%rdi), %eax
movl %eax, 0x18(%rdi)
movq -0x18(%rbp), %rsi
callq 0x1d280
jmp 0x1e1de
movq -0xf8(%rbp), %rax
movl -0xc0(%rbp), %ecx
movl %ecx, 0x18(%rax)
callq 0x1eb40
movl %eax, -0x194(%rbp)
jmp 0x1e1fb
movl -0x194(%rbp), %eax
subl $0x1, %eax
cltq
movq %rax, -0xc8(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x23db0
movslq -0xbc(%rbp), %rcx
addq %rcx, %rax
subq $0x1, %rax
movslq -0xbc(%rbp), %rcx
xorl %edx, %edx
divq %rcx
movq %rax, -0xd0(%rbp)
movq $0x0, -0xd8(%rbp)
movq -0xd8(%rbp), %rax
cmpq -0xd0(%rbp), %rax
jae 0x1e6a0
movq -0xd8(%rbp), %rax
cmpq -0xc8(%rbp), %rax
jne 0x1e4e0
leaq 0x1e7b3(%rip), %rdi     # 0x3ca24
xorl %eax, %eax
callq 0x8080
jmp 0x1e27a
movq 0x38cff(%rip), %rax     # 0x56f80
movq (%rax), %rdi
callq 0x84f0
jmp 0x1e28b
movl $0x0, -0x34(%rbp)
movb $0x0, -0xd9(%rbp)
xorl %eax, %eax
cmpl $0x20, -0x34(%rbp)
movb %al, -0x195(%rbp)
je 0x1e324
xorl %eax, %eax
cmpl $0xd, -0x34(%rbp)
movb %al, -0x195(%rbp)
je 0x1e324
xorl %eax, %eax
cmpl $0xa, -0x34(%rbp)
movb %al, -0x195(%rbp)
je 0x1e324
xorl %eax, %eax
cmpl $0x79, -0x34(%rbp)
movb %al, -0x195(%rbp)
je 0x1e324
xorl %eax, %eax
cmpl $0x59, -0x34(%rbp)
movb %al, -0x195(%rbp)
je 0x1e324
xorl %eax, %eax
cmpl $0x6e, -0x34(%rbp)
movb %al, -0x195(%rbp)
je 0x1e324
xorl %eax, %eax
cmpl $0x4e, -0x34(%rbp)
movb %al, -0x195(%rbp)
je 0x1e324
xorl %eax, %eax
cmpl $0x71, -0x34(%rbp)
movb %al, -0x195(%rbp)
je 0x1e324
xorl %eax, %eax
cmpl $0x51, -0x34(%rbp)
movb %al, -0x195(%rbp)
je 0x1e324
cmpl $0x3, -0x34(%rbp)
setne %al
movb %al, -0x195(%rbp)
movb -0x195(%rbp), %al
testb $0x1, %al
jne 0x1e330
jmp 0x1e383
testb $0x1, -0xd9(%rbp)
je 0x1e342
callq 0x1e810
jmp 0x1e340
jmp 0x1e342
movb $0x1, -0xd9(%rbp)
callq 0x1e8d0
movl %eax, -0x19c(%rbp)
jmp 0x1e356
movl -0x19c(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %edi
callq 0x1eac0
movl %eax, -0x1a0(%rbp)
jmp 0x1e36f
movl -0x1a0(%rbp), %eax
movl %eax, -0x34(%rbp)
cmpl $-0x1, -0x34(%rbp)
je 0x1e349
jmp 0x1e299
movl -0x34(%rbp), %eax
movl %eax, -0x1a4(%rbp)
subl $0x3, %eax
je 0x1e498
jmp 0x1e397
movl -0x1a4(%rbp), %eax
subl $0xa, %eax
je 0x1e45b
jmp 0x1e3a8
movl -0x1a4(%rbp), %eax
subl $0xd, %eax
je 0x1e45b
jmp 0x1e3b9
movl -0x1a4(%rbp), %eax
subl $0x20, %eax
je 0x1e420
jmp 0x1e3c6
movl -0x1a4(%rbp), %eax
subl $0x4e, %eax
je 0x1e47f
jmp 0x1e3d7
movl -0x1a4(%rbp), %eax
subl $0x51, %eax
je 0x1e47f
jmp 0x1e3e8
movl -0x1a4(%rbp), %eax
subl $0x59, %eax
je 0x1e420
jmp 0x1e3f5
movl -0x1a4(%rbp), %eax
subl $0x6e, %eax
je 0x1e47f
jmp 0x1e402
movl -0x1a4(%rbp), %eax
subl $0x71, %eax
je 0x1e47f
jmp 0x1e40f
movl -0x1a4(%rbp), %eax
subl $0x79, %eax
jne 0x1e4de
jmp 0x1e420
leaq 0x1e607(%rip), %rdi     # 0x3ca2e
xorl %eax, %eax
callq 0x8080
jmp 0x1e430
callq 0x1eb40
movl %eax, -0x1a8(%rbp)
jmp 0x1e43d
movl -0x1a8(%rbp), %eax
subl $0x1, %eax
cltq
addq -0xc8(%rbp), %rax
movq %rax, -0xc8(%rbp)
jmp 0x1e4de
leaq 0x1e5cc(%rip), %rdi     # 0x3ca2e
xorl %eax, %eax
callq 0x8080
jmp 0x1e46b
movq -0xc8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xc8(%rbp)
jmp 0x1e4de
leaq 0x1e5a8(%rip), %rdi     # 0x3ca2e
xorl %eax, %eax
callq 0x8080
jmp 0x1e48f
movb $0x1, -0xa5(%rbp)
jmp 0x1e4de
leaq 0x1e582(%rip), %rsi     # 0x3ca21
movl $0x1, %edi
movl $0x2, %edx
callq 0x8190
movq %rax, -0x1b0(%rbp)
jmp 0x1e4b7
movq -0x1b0(%rbp), %rax
cmpq $-0x1, %rax
jne 0x1e4d7
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0x6c(%rbp)
jmp 0x1e7b7
movb $0x1, -0xa5(%rbp)
jmp 0x1e4f2
leaq 0x1e745(%rip), %rdi     # 0x3cc2c
xorl %eax, %eax
callq 0x8080
jmp 0x1e4f0
jmp 0x1e4f2
testb $0x1, -0xa5(%rbp)
je 0x1e500
jmp 0x1e6a0
movl $0x0, -0xe0(%rbp)
movl -0xe0(%rbp), %eax
cmpl -0xbc(%rbp), %eax
jge 0x1e687
movslq -0xe0(%rbp), %rax
imulq -0xd0(%rbp), %rax
addq -0xd8(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq -0xe8(%rbp), %rax
movq %rax, -0x1b8(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x23db0
movq %rax, %rcx
movq -0x1b8(%rbp), %rax
cmpq %rcx, %rax
jae 0x1e671
movq -0xe8(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0x23dd0
movq %rax, %rdi
callq 0x23df0
movq %rax, -0x1c0(%rbp)
jmp 0x1e584
movq -0x1c0(%rbp), %rax
movl %eax, -0x3c(%rbp)
movq 0x389eb(%rip), %rax     # 0x56f80
movq (%rax), %rdi
callq 0x84f0
jmp 0x1e59f
movq -0xe8(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0x23dd0
movq %rax, %rdi
callq 0x23ec0
movq %rax, -0x1c8(%rbp)
jmp 0x1e5c0
movq -0x1c8(%rbp), %rsi
movl -0x3c(%rbp), %edx
movl $0x1, %edi
callq 0x1d8e0
movl %eax, -0x1cc(%rbp)
jmp 0x1e5dc
movl -0x1cc(%rbp), %eax
cmpl $-0x1, %eax
jne 0x1e5fa
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0x6c(%rbp)
jmp 0x1e7b7
movl -0xe0(%rbp), %eax
addl $0x1, %eax
cltq
imulq -0xd0(%rbp), %rax
addq -0xd8(%rbp), %rax
movq %rax, -0x1d8(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x23db0
movq %rax, %rcx
movq -0x1d8(%rbp), %rax
cmpq %rcx, %rax
jae 0x1e66f
movl -0x3c(%rbp), %eax
movl %eax, -0xec(%rbp)
movl -0xec(%rbp), %eax
cmpl -0xac(%rbp), %eax
jge 0x1e66d
leaq 0x1e5a8(%rip), %rdi     # 0x3cbf9
xorl %eax, %eax
callq 0x8080
jmp 0x1e65a
jmp 0x1e65c
movl -0xec(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xec(%rbp)
jmp 0x1e63c
jmp 0x1e66f
jmp 0x1e671
jmp 0x1e673
movl -0xe0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xe0(%rbp)
jmp 0x1e50a
jmp 0x1e689
movq -0xd8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xd8(%rbp)
jmp 0x1e242
movq 0x388d9(%rip), %rax     # 0x56f80
movq (%rax), %rdi
callq 0x84f0
jmp 0x1e6b1
leaq -0x30(%rbp), %rdi
callq 0x1e840
jmp 0x1e6bc
jmp 0x1e6be
testb $0x1, -0xa5(%rbp)
je 0x1e6cd
cmpl $0x3, -0x34(%rbp)
jne 0x1e70e
leaq 0x1e558(%rip), %rsi     # 0x3cc2c
movl $0x1, %edi
movl $0x1, %edx
callq 0x8190
movq %rax, -0x1e0(%rbp)
jmp 0x1e6ec
movq -0x1e0(%rbp), %rax
cmpq $-0x1, %rax
jne 0x1e70c
movl $0x0, -0x4(%rbp)
movl $0x1, -0x6c(%rbp)
jmp 0x1e7b7
jmp 0x1e70e
movq -0x18(%rbp), %rdi
callq 0x23ee0
movb %al, -0x1e1(%rbp)
jmp 0x1e71f
movb -0x1e1(%rbp), %al
testb $0x1, %al
jne 0x1e73b
jmp 0x1e72b
movl $0x0, -0x4(%rbp)
movl $0x1, -0x6c(%rbp)
jmp 0x1e7b7
movq -0x18(%rbp), %rax
cmpl $0x0, 0x24(%rax)
jne 0x1e78d
movq -0x18(%rbp), %rax
cmpl $0x0, 0x20(%rax)
jle 0x1e78d
leaq 0x1e4d6(%rip), %rsi     # 0x3cc2c
movl $0x1, %edi
movl $0x1, %edx
callq 0x8190
movq %rax, -0x1f0(%rbp)
jmp 0x1e76e
movq -0x1f0(%rbp), %rax
cmpq $-0x1, %rax
jne 0x1e78b
movl $0x0, -0x4(%rbp)
movl $0x1, -0x6c(%rbp)
jmp 0x1e7b7
jmp 0x1e78d
movq -0xf8(%rbp), %rdi
movq -0x18(%rbp), %rax
movl 0x20(%rax), %ecx
movl %ecx, 0x30(%rax)
movq -0x18(%rbp), %rsi
callq 0x1d280
jmp 0x1e7a9
movl $0x0, -0x4(%rbp)
movl $0x1, -0x6c(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x23f30
leaq -0x50(%rbp), %rdi
callq 0x23b50
leaq -0x30(%rbp), %rdi
callq 0x23f60
movl -0x4(%rbp), %eax
addq $0x1f0, %rsp            # imm = 0x1F0
popq %rbp
retq
leaq -0x68(%rbp), %rdi
callq 0x23f30
leaq -0x50(%rbp), %rdi
callq 0x23b50
leaq -0x30(%rbp), %rdi
callq 0x23f60
movq -0x58(%rbp), %rdi
callq 0x87b0
nopw %cs:(%rax,%rax)