// File: /workspace/github_cpp_makefile_star2_O1/andrakis[P]alisp/contrib/linenoise-ng/src/linenoise.cpp
// Function: InputBuffer::incrementalHistorySearch(PromptBase&, int)
int InputBuffer::incrementalHistorySearch(PromptBase& pi, int startChar) {
  size_t bufferSize;
  size_t ucharCount = 0;

  // if not already recalling, add the current line to the history list so we
  // don't have to
  // special case it
  if (historyIndex == historyLen - 1) {
    free(history[historyLen - 1]);
    bufferSize = sizeof(char32_t) * len + 1;
    unique_ptr<char[]> tempBuffer(new char[bufferSize]);
    copyString32to8(tempBuffer.get(), bufferSize, buf32);
    history[historyLen - 1] = strdup8(tempBuffer.get());
  }
  int historyLineLength = len;
  int historyLinePosition = pos;
  char32_t emptyBuffer[1];
  char emptyWidths[1];
  InputBuffer empty(emptyBuffer, emptyWidths, 1);
  empty.refreshLine(pi);  // erase the old input first
  DynamicPrompt dp(pi, (startChar == ctrlChar('R')) ? -1 : 1);

  dp.promptPreviousLen = pi.promptPreviousLen;
  dp.promptPreviousInputLen = pi.promptPreviousInputLen;
  dynamicRefresh(dp, buf32, historyLineLength,
                 historyLinePosition);  // draw user's text with our prompt

  // loop until we get an exit character
  int c = 0;
  bool keepLooping = true;
  bool useSearchedLine = true;
  bool searchAgain = false;
  char32_t* activeHistoryLine = 0;
  while (keepLooping) {
    c = linenoiseReadChar();
    c = cleanupCtrl(c);  // convert CTRL + <char> into normal ctrl

    switch (c) {
      // these characters keep the selected text but do not execute it
      case ctrlChar('A'):  // ctrl-A, move cursor to start of line
      case HOME_KEY:
      case ctrlChar('B'):  // ctrl-B, move cursor left by one character
      case LEFT_ARROW_KEY:
      case META + 'b':  // meta-B, move cursor left by one word
      case META + 'B':
      case CTRL + LEFT_ARROW_KEY:
      case META + LEFT_ARROW_KEY:  // Emacs allows Meta, bash & readline don't
      case ctrlChar('D'):
      case META + 'd':  // meta-D, kill word to right of cursor
      case META + 'D':
      case ctrlChar('E'):  // ctrl-E, move cursor to end of line
      case END_KEY:
      case ctrlChar('F'):  // ctrl-F, move cursor right by one character
      case RIGHT_ARROW_KEY:
      case META + 'f':  // meta-F, move cursor right by one word
      case META + 'F':
      case CTRL + RIGHT_ARROW_KEY:
      case META + RIGHT_ARROW_KEY:  // Emacs allows Meta, bash & readline don't
      case META + ctrlChar('H'):
      case ctrlChar('J'):
      case ctrlChar('K'):  // ctrl-K, kill from cursor to end of line
      case ctrlChar('M'):
      case ctrlChar('N'):  // ctrl-N, recall next line in history
      case ctrlChar('P'):  // ctrl-P, recall previous line in history
      case DOWN_ARROW_KEY:
      case UP_ARROW_KEY:
      case ctrlChar('T'):  // ctrl-T, transpose characters
      case ctrlChar(
          'U'):  // ctrl-U, kill all characters to the left of the cursor
      case ctrlChar('W'):
      case META + 'y':  // meta-Y, "yank-pop", rotate popped text
      case META + 'Y':
      case 127:
      case DELETE_KEY:
      case META + '<':  // start of history
      case PAGE_UP_KEY:
      case META + '>':  // end of history
      case PAGE_DOWN_KEY:
        keepLooping = false;
        break;

      // these characters revert the input line to its previous state
      case ctrlChar('C'):  // ctrl-C, abort this line
      case ctrlChar('G'):
      case ctrlChar('L'):  // ctrl-L, clear screen and redisplay line
        keepLooping = false;
        useSearchedLine = false;
        if (c != ctrlChar('L')) {
          c = -1;  // ctrl-C and ctrl-G just abort the search and do nothing
                   // else
        }
        break;

      // these characters stay in search mode and update the display
      case ctrlChar('S'):
      case ctrlChar('R'):
        if (dp.searchTextLen ==
            0) {  // if no current search text, recall previous text
          if (previousSearchText.length()) {
            dp.updateSearchText(previousSearchText.get());
          }
        }
        if ((dp.direction == 1 && c == ctrlChar('R')) ||
            (dp.direction == -1 && c == ctrlChar('S'))) {
          dp.direction = 0 - dp.direction;  // reverse direction
          dp.updateSearchPrompt();          // change the prompt
        } else {
          searchAgain = true;  // same direction, search again
        }
        break;

// job control is its own thing
#ifndef _WIN32
      case ctrlChar('Z'):  // ctrl-Z, job control
        disableRawMode();  // Returning to Linux (whatever) shell, leave raw
                           // mode
        raise(SIGSTOP);    // Break out in mid-line
        enableRawMode();   // Back from Linux shell, re-enter raw mode
        {
          bufferSize = historyLineLength + 1;
          unique_ptr<char32_t[]> tempUnicode(new char32_t[bufferSize]);
          copyString8to32(tempUnicode.get(), bufferSize, ucharCount,
                          history[historyIndex]);
          dynamicRefresh(dp, tempUnicode.get(), historyLineLength,
                         historyLinePosition);
        }
        continue;
        break;
#endif

      // these characters update the search string, and hence the selected input
      // line
      case ctrlChar('H'):  // backspace/ctrl-H, delete char to left of cursor
        if (dp.searchTextLen > 0) {
          unique_ptr<char32_t[]> tempUnicode(new char32_t[dp.searchTextLen]);
          --dp.searchTextLen;
          dp.searchText[dp.searchTextLen] = 0;
          copyString32(tempUnicode.get(), dp.searchText.get(),
                       dp.searchTextLen);
          dp.updateSearchText(tempUnicode.get());
        } else {
          beep();
        }
        break;

      case ctrlChar('Y'):  // ctrl-Y, yank killed text
        break;

      default:
        if (!isControlChar(c) && c <= 0x0010FFFF) {  // not an action character
          unique_ptr<char32_t[]> tempUnicode(
              new char32_t[dp.searchTextLen + 2]);
          copyString32(tempUnicode.get(), dp.searchText.get(),
                       dp.searchTextLen);
          tempUnicode[dp.searchTextLen] = c;
          tempUnicode[dp.searchTextLen + 1] = 0;
          dp.updateSearchText(tempUnicode.get());
        } else {
          beep();
        }
    }  // switch

    // if we are staying in search mode, search now
    if (keepLooping) {
      bufferSize = historyLineLength + 1;
      if (activeHistoryLine) {
        delete[] activeHistoryLine;
        activeHistoryLine = nullptr;
      }
      activeHistoryLine = new char32_t[bufferSize];
      copyString8to32(activeHistoryLine, bufferSize, ucharCount,
                      history[historyIndex]);
      if (dp.searchTextLen > 0) {
        bool found = false;
        int historySearchIndex = historyIndex;
        int lineLength = static_cast<int>(ucharCount);
        int lineSearchPos = historyLinePosition;
        if (searchAgain) {
          lineSearchPos += dp.direction;
        }
        searchAgain = false;
        while (true) {
          while ((dp.direction > 0) ? (lineSearchPos < lineLength)
                                    : (lineSearchPos >= 0)) {
            if (strncmp32(dp.searchText.get(),
                          &activeHistoryLine[lineSearchPos],
                          dp.searchTextLen) == 0) {
              found = true;
              break;
            }
            lineSearchPos += dp.direction;
          }
          if (found) {
            historyIndex = historySearchIndex;
            historyLineLength = lineLength;
            historyLinePosition = lineSearchPos;
            break;
          } else if ((dp.direction > 0) ? (historySearchIndex < historyLen - 1)
                                        : (historySearchIndex > 0)) {
            historySearchIndex += dp.direction;
            bufferSize = strlen8(history[historySearchIndex]) + 1;
            delete[] activeHistoryLine;
            activeHistoryLine = nullptr;
            activeHistoryLine = new char32_t[bufferSize];
            copyString8to32(activeHistoryLine, bufferSize, ucharCount,
                            history[historySearchIndex]);
            lineLength = static_cast<int>(ucharCount);
            lineSearchPos =
                (dp.direction > 0) ? 0 : (lineLength - dp.searchTextLen);
          } else {
            beep();
            break;
          }
        };  // while
      }
      if (activeHistoryLine) {
        delete[] activeHistoryLine;
        activeHistoryLine = nullptr;
      }
      bufferSize = historyLineLength + 1;
      activeHistoryLine = new char32_t[bufferSize];
      copyString8to32(activeHistoryLine, bufferSize, ucharCount,
                      history[historyIndex]);
      dynamicRefresh(dp, activeHistoryLine, historyLineLength,
                     historyLinePosition);  // draw user's text with our prompt
    }
  }  // while

  // leaving history search, restore previous prompt, maybe make searched line
  // current
  PromptBase pb;
  pb.promptChars = pi.promptIndentation;
  pb.promptBytes = pi.promptBytes;
  Utf32String tempUnicode(pb.promptBytes + 1);

  copyString32(tempUnicode.get(), &pi.promptText[pi.promptLastLinePosition],
               pb.promptBytes - pi.promptLastLinePosition);
  tempUnicode.initFromBuffer();
  pb.promptText = tempUnicode;
  pb.promptExtraLines = 0;
  pb.promptIndentation = pi.promptIndentation;
  pb.promptLastLinePosition = 0;
  pb.promptPreviousInputLen = historyLineLength;
  pb.promptCursorRowOffset = dp.promptCursorRowOffset;
  pb.promptScreenColumns = pi.promptScreenColumns;
  pb.promptPreviousLen = dp.promptChars;
  if (useSearchedLine && activeHistoryLine) {
    historyRecallMostRecent = true;
    copyString32(buf32, activeHistoryLine, buflen + 1);
    len = historyLineLength;
    pos = historyLinePosition;
  }
  if (activeHistoryLine) {
    delete[] activeHistoryLine;
    activeHistoryLine = nullptr;
  }
  dynamicRefresh(pb, buf32, len,
                 pos);  // redraw the original prompt with current input
  pi.promptPreviousInputLen = len;
  pi.promptCursorRowOffset = pi.promptExtraLines + pb.promptCursorRowOffset;
  previousSearchText =
      dp.searchText;  // save search text for possible reuse on ctrl-R ctrl-R
  return c;           // pass a character or -1 back to main loop
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
movl %edx, %ebx
movq %rsi, %r12
movq %rdi, %r13
movq $0x0, 0x20(%rsp)
movslq 0x1e727(%rip), %rax     # 0x2f968
leal -0x1(%rax), %ecx
cmpl %ecx, 0x1e72e(%rip)     # 0x2f978
jne 0x112cb
movq 0x1e70d(%rip), %rcx     # 0x2f960
movq -0x8(%rcx,%rax,8), %rdi
callq 0x7400
movslq 0x14(%r13), %rax
leaq 0x1(,%rax,4), %r15
movq %r15, %rdi
callq 0x7030
movq %rax, %r14
movq (%r13), %rcx
movq $0x0, 0x40(%rsp)
movq $-0x4, %r8
cmpl $0x0, 0x4(%rcx,%r8)
leaq 0x4(%r8), %r8
jne 0x11288
sarq $0x2, %r8
leaq 0x40(%rsp), %rdx
movq %r14, %rdi
movq %r15, %rsi
callq 0x13dfb
movq %r14, %rdi
callq 0x7650
movq 0x1e6a9(%rip), %rcx     # 0x2f960
movslq 0x1e6aa(%rip), %rdx     # 0x2f968
movq %rax, -0x8(%rcx,%rdx,8)
movq %r14, %rdi
callq 0x7480
movl 0x14(%r13), %r15d
movl 0x18(%r13), %r14d
leaq 0x104(%rsp), %rax
leaq 0x108(%rsp), %rdi
movq %rax, (%rdi)
leaq 0x1f(%rsp), %rcx
movq %rcx, 0x8(%rdi)
movq $0x0, 0x10(%rdi)
xorl %ecx, %ecx
movl %ecx, 0x18(%rdi)
movl %ecx, (%rax)
movq %r12, %rsi
callq 0x1012c
xorl %eax, %eax
cmpl $0x12, %ebx
setne %al
leal -0x1(%rax,%rax), %edx
leaq 0x40(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x143fc
movl 0x38(%r12), %eax
movl %eax, 0x38(%rbx)
movq %r12, 0xf0(%rsp)
movl 0x2c(%r12), %eax
movl %eax, 0x2c(%rbx)
movq %r13, 0xe8(%rsp)
movq (%r13), %rsi
movq %rbx, %rdi
movl %r15d, %edx
movl %r14d, %ecx
callq 0x11cac
movb $0x1, %al
movl %eax, 0x10(%rsp)
xorl %ebx, %ebx
movl $0x0, 0x14(%rsp)
movb $0x1, %al
movl %eax, 0x2c(%rsp)
movslq %r15d, %rax
leaq 0x1(%rax), %r13
cmpl $-0x1, %eax
leaq 0x4(,%rax,4), %rbp
movq $-0x1, %rax
cmovlq %rax, %rbp
callq 0x10fc5
movl %eax, %edi
callq 0x1114a
cmpl $0x101fffff, %eax       # imm = 0x101FFFFF
movq %rax, 0x8(%rsp)
jg 0x1144d
decl %eax
cmpl $0x19, %eax
ja 0x11882
leaq 0x105eb(%rip), %rcx     # 0x219a0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpb $0x1, 0x1e61b(%rip)     # 0x2f9e0
jne 0x113e6
xorl %edi, %edi
movl $0x1, %esi
leaq 0x1e60f(%rip), %rdx     # 0x2f9e4
callq 0x7460
cmpl $-0x1, %eax
je 0x113e6
movb $0x0, 0x1e5fa(%rip)     # 0x2f9e0
movl $0x13, %edi
callq 0x7310
callq 0x11f82
movq %rbp, %rdi
callq 0x7030
movq %rax, %r12
movq 0x1e559(%rip), %rax     # 0x2f960
movslq 0x1e56a(%rip), %rcx     # 0x2f978
movq (%rax,%rcx,8), %rcx
movq %r12, %rdi
movq %r13, %rsi
leaq 0x20(%rsp), %rdx
callq 0x13d85
leaq 0x40(%rsp), %rdi
movq %r12, %rsi
movl %r15d, %edx
movl %r14d, %ecx
callq 0x11cac
movq %r12, %rdi
callq 0x7480
testb $0x1, 0x10(%rsp)
jne 0x11387
jmp 0x11a09
cmpl $0x4000003b, %eax       # imm = 0x4000003B
jg 0x1148a
cmpl $0x10dfffff, %eax       # imm = 0x10DFFFFF
jg 0x11748
cmpl $0x107fffff, %eax       # imm = 0x107FFFFF
jg 0x1177b
cmpl $0x10200000, %eax       # imm = 0x10200000
je 0x114ac
cmpl $0x10400000, 0x8(%rsp)  # imm = 0x10400000
je 0x114ac
cmpl $0x10600000, 0x8(%rsp)  # imm = 0x10600000
je 0x114ac
jmp 0x1188d
addl $0xbfffffc4, %eax       # imm = 0xBFFFFFC4
cmpl $0x3d, %eax
ja 0x117fc
movabsq $0x2000054020000545, %rcx # imm = 0x2000054020000545
btq %rax, %rcx
jae 0x117fc
movl $0x0, 0x10(%rsp)
testb $0x1, 0x10(%rsp)
je 0x11738
testq %rbx, %rbx
je 0x114cc
movq %rbx, %rdi
callq 0x7480
leal 0x1(%r15), %eax
movslq %eax, %r13
leaq (,%r13,4), %rdi
cmpl $-0x1, %r15d
movq $-0x1, %rax
cmovlq %rax, %rdi
callq 0x7030
movq %rax, %rbx
movq 0x1e467(%rip), %rax     # 0x2f960
movslq 0x1e478(%rip), %rcx     # 0x2f978
movq (%rax,%rcx,8), %rcx
movq %rbx, %rdi
movq %r13, %rsi
leaq 0x20(%rsp), %rdx
callq 0x13d85
cmpl $0x0, 0x98(%rsp)
jle 0x116d6
movl %r14d, 0x18(%rsp)
movq %r15, 0xf8(%rsp)
xorl %r14d, %r14d
movl $0x0, %eax
testb $0x1, 0x14(%rsp)
je 0x11545
movl 0x9c(%rsp), %eax
movl 0x1e42c(%rip), %r15d    # 0x2f978
movl 0x20(%rsp), %ecx
addl 0x18(%rsp), %eax
movslq 0x9c(%rsp), %rdx
xorl %esi, %esi
cmpl %ecx, %eax
setl %sil
xorl %edi, %edi
testl %eax, %eax
setns %dil
testq %rdx, %rdx
cmovgl %esi, %edi
cmpb $0x1, %dil
jne 0x115de
movq 0x88(%rsp), %rsi
movslq 0x98(%rsp), %rdi
cltq
movslq %ecx, %r8
leaq (%rbx,%rax,4), %r9
leaq (,%rdx,4), %r10
testl %edi, %edi
je 0x115db
xorl %r11d, %r11d
movl (%rsi,%r11,4), %ebp
testl %ebp, %ebp
je 0x115db
cmpl (%r9,%r11,4), %ebp
jne 0x115b8
incq %r11
cmpq %r11, %rdi
jne 0x115a0
jmp 0x115db
xorl %r11d, %r11d
addq %rdx, %rax
setns %r11b
xorl %ebp, %ebp
cmpq %r8, %rax
setl %bpl
testl %edx, %edx
cmovlel %r11d, %ebp
addq %r10, %r9
testb %bpl, %bpl
jne 0x11599
jmp 0x115de
movb $0x1, %r14b
testb $0x1, %r14b
jne 0x1168e
testl %edx, %edx
jle 0x115fe
movl 0x1e376(%rip), %eax     # 0x2f968
decl %eax
cmpl %eax, %r15d
jl 0x11607
jmp 0x116a5
testl %r15d, %r15d
jle 0x116a5
addl %edx, %r15d
movq 0x1e34f(%rip), %rax     # 0x2f960
movslq %r15d, %r12
movq (%rax,%r12,8), %rdi
callq 0x7180
movq %rax, %rbp
leaq 0x1(%rax), %r13
movq %rbx, %rdi
callq 0x7480
movq %r13, %rax
shrq $0x3e, %rax
leaq 0x4(,%rbp,4), %rcx
negq %rax
movl $0x0, %edi
sbbq %rdi, %rdi
orq %rcx, %rdi
callq 0x7030
movq %rax, %rbx
movq 0x1e308(%rip), %rax     # 0x2f960
movq (%rax,%r12,8), %rcx
movq %rbx, %rdi
movq %r13, %rsi
leaq 0x20(%rsp), %rdx
callq 0x13d85
movl 0x20(%rsp), %ecx
movl %ecx, %eax
subl 0x98(%rsp), %eax
cmpl $0x0, 0x9c(%rsp)
movl $0x0, %edx
cmovgl %edx, %eax
jmp 0x11554
movl %r15d, 0x1e2e3(%rip)    # 0x2f978
movl $0x0, 0x14(%rsp)
movl %ecx, %r15d
movl %eax, %r14d
jmp 0x116d6
movq 0x1d924(%rip), %r14     # 0x2efd0
movq (%r14), %rsi
movl $0x7, %edi
callq 0x7430
movq (%r14), %rdi
callq 0x73e0
movl $0x0, 0x14(%rsp)
movq 0xf8(%rsp), %r15
movl 0x18(%rsp), %r14d
movq %rbx, %rdi
callq 0x7480
movslq %r15d, %r13
cmpl $-0x1, %r13d
leaq 0x4(,%r13,4), %rdi
movq $-0x1, %rax
cmovlq %rax, %rdi
callq 0x7030
movq %rax, %rbx
incq %r13
movq 0x1e256(%rip), %rax     # 0x2f960
movslq 0x1e267(%rip), %rcx     # 0x2f978
movq (%rax,%rcx,8), %rcx
movq %rbx, %rdi
movq %r13, %rsi
leaq 0x20(%rsp), %rdx
callq 0x13d85
leaq 0x40(%rsp), %rdi
movq %rbx, %rsi
movl %r15d, %edx
movl %r14d, %ecx
callq 0x11cac
testb $0x1, 0x10(%rsp)
jne 0x1136a
jmp 0x11a13
cmpl $0x305fffff, %eax       # imm = 0x305FFFFF
jg 0x117a7
cmpl $0x10e00000, %eax       # imm = 0x10E00000
je 0x114ac
cmpl $0x11000000, 0x8(%rsp)  # imm = 0x11000000
je 0x114ac
cmpl $0x11200000, 0x8(%rsp)  # imm = 0x11200000
je 0x114ac
jmp 0x1188d
cmpl $0x10800000, %eax       # imm = 0x10800000
je 0x114ac
cmpl $0x10a00000, 0x8(%rsp)  # imm = 0x10A00000
je 0x114ac
cmpl $0x10c00000, 0x8(%rsp)  # imm = 0x10C00000
je 0x114ac
jmp 0x1188d
cmpl $0x30600000, %eax       # imm = 0x30600000
je 0x114ac
cmpl $0x30800000, 0x8(%rsp)  # imm = 0x30800000
je 0x114ac
cmpl $0x40000008, 0x8(%rsp)  # imm = 0x40000008
je 0x114ac
jmp 0x1188d
xorl %eax, %eax
cmpl $0xc, 0x8(%rsp)
setne %al
negl %eax
orl $0xc, %eax
movl $0x0, 0x10(%rsp)
movq %rax, 0x8(%rsp)
movl $0x0, 0x2c(%rsp)
jmp 0x114b4
cmpl $0x50600000, 0x8(%rsp)  # imm = 0x50600000
je 0x114ac
cmpl $0x50800000, 0x8(%rsp)  # imm = 0x50800000
je 0x114ac
jmp 0x1188d
cmpl $0x0, 0x98(%rsp)
jne 0x1183f
cmpq $0x0, 0x1e0e4(%rip)     # 0x2f910
je 0x1183f
movq 0x1e0e3(%rip), %rsi     # 0x2f918
leaq 0x40(%rsp), %rdi
callq 0x1462e
movl 0x9c(%rsp), %eax
movl %eax, %ecx
xorl $0x1, %ecx
movq 0x8(%rsp), %rsi
movl %esi, %edx
xorl $0x12, %edx
orl %ecx, %edx
je 0x1186a
movl %eax, %ecx
notl %ecx
movl %esi, %edx
xorl $0x13, %edx
orl %ecx, %edx
jne 0x119d0
negl %eax
movl %eax, 0x9c(%rsp)
leaq 0x40(%rsp), %rdi
callq 0x14690
jmp 0x114b4
cmpl $0x7f, 0x8(%rsp)
je 0x114ac
movq 0x8(%rsp), %rax
cmpl $0x10ffff, %eax         # imm = 0x10FFFF
jg 0x119ad
cmpl $0x20, %eax
jb 0x119ad
addl $-0x7f, %eax
cmpl $0x21, %eax
jb 0x119ad
movl %r14d, %ebp
movslq 0x98(%rsp), %r14
cmpq $-0x2, %r14
leaq 0x8(,%r14,4), %rdi
movq $-0x1, %rax
cmovlq %rax, %rdi
callq 0x7030
movq %rax, %r13
testl %r14d, %r14d
je 0x11903
movq 0x88(%rsp), %rcx
xorl %edx, %edx
movq %r13, %rax
movl (%rcx,%rdx,4), %esi
testl %esi, %esi
je 0x11903
movl %esi, (%rax)
addq $0x4, %rax
incq %rdx
cmpq %rdx, %r14
jne 0x118ee
xorl %ecx, %ecx
movl %ecx, (%rax)
movq 0x8(%rsp), %rax
movl %eax, (%r13,%r14,4)
movl %ecx, 0x4(%r13,%r14,4)
leaq 0x40(%rsp), %rdi
movq %r13, %rsi
callq 0x1462e
movq %r13, %rdi
callq 0x7480
jmp 0x11a01
movl %r14d, %ebp
movslq 0x98(%rsp), %r14
testq %r14, %r14
jle 0x119db
leaq (,%r14,4), %rdi
callq 0x7030
movq %rax, %r12
movl %r14d, %ecx
decl %ecx
movl %ecx, 0x98(%rsp)
movq 0x88(%rsp), %rcx
movl $0x0, -0x4(%rcx,%r14,4)
je 0x11990
decq %r14
xorl %edx, %edx
movq %r12, %rax
movl (%rcx,%rdx,4), %esi
testl %esi, %esi
je 0x11990
movl %esi, (%rax)
addq $0x4, %rax
incq %rdx
cmpq %rdx, %r14
jne 0x1197b
movl $0x0, (%rax)
leaq 0x40(%rsp), %rdi
movq %r12, %rsi
callq 0x1462e
movq %r12, %rdi
callq 0x7480
jmp 0x119f7
movq 0x1d61c(%rip), %r12     # 0x2efd0
movq (%r12), %rsi
movl $0x7, %edi
callq 0x7430
movq (%r12), %rdi
callq 0x73e0
jmp 0x114b4
movb $0x1, %al
movl %eax, 0x14(%rsp)
jmp 0x114b4
movq 0x1d5ee(%rip), %r14     # 0x2efd0
movq (%r14), %rsi
movl $0x7, %edi
callq 0x7430
movq (%r14), %rdi
callq 0x73e0
movl $0x8, %eax
movq %rax, 0x8(%rsp)
movl %ebp, %r14d
jmp 0x114b4
movl $0x1a, %eax
movq %rax, 0x8(%rsp)
movl %r14d, 0x18(%rsp)
movq %r15, %rbp
xorps %xmm0, %xmm0
movaps %xmm0, 0xa0(%rsp)
movl $0x4, %edi
callq 0x7030
xorl %ecx, %ecx
movl %ecx, (%rax)
movq %rax, 0xa8(%rsp)
movl %ecx, 0xcc(%rsp)
movq 0xf0(%rsp), %r12
movl 0x24(%r12), %eax
movl %eax, 0xb8(%rsp)
movslq 0x1c(%r12), %r15
cmpq $-0x1, %r15
movl %r15d, 0xbc(%rsp)
leaq 0x4(,%r15,4), %rax
movq $-0x1, %r13
cmovgeq %rax, %r13
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movq %r13, %rdi
callq 0x7030
movq %rax, %r14
movq %rax, %rdi
xorl %esi, %esi
movq %r13, %rdx
callq 0x7200
movq %r14, 0x38(%rsp)
movslq 0x28(%r12), %rax
movq %r14, %rcx
cmpl %eax, %r15d
movq 0xe8(%rsp), %r13
je 0x11ad2
movq 0x8(%r12), %rdx
movq %r14, %rcx
movl (%rdx,%rax,4), %esi
testl %esi, %esi
je 0x11ad2
movl %esi, (%rcx)
addq $0x4, %rcx
incq %rax
cmpq %rax, %r15
jne 0x11abd
movl $0x0, (%rcx)
movq $-0x1, %rax
cmpl $0x0, 0x4(%r14,%rax,4)
leaq 0x1(%rax), %rax
jne 0x11adf
leaq 0x30(%rsp), %rsi
movq %rax, (%rsi)
leaq 0xa0(%rsp), %rdi
callq 0x147da
xorl %eax, %eax
movl %eax, 0xc0(%rsp)
movl 0x24(%r12), %ecx
movl %ecx, 0xc4(%rsp)
movl %eax, 0xc8(%rsp)
movl %ebp, 0xcc(%rsp)
movl 0x58(%rsp), %eax
movl 0x70(%rsp), %ecx
movl %ecx, 0xd0(%rsp)
movl 0x34(%r12), %ecx
movl %ecx, 0xd4(%rsp)
movl %eax, 0xd8(%rsp)
testb $0x1, 0x2c(%rsp)
movl 0x18(%rsp), %edi
je 0x11b90
testq %rbx, %rbx
je 0x11b90
movb $0x1, 0x1de20(%rip)     # 0x2f97c
movq (%r13), %rax
movl 0x10(%r13), %ecx
incl %ecx
je 0x11b82
movslq %ecx, %rcx
xorl %edx, %edx
movl (%rbx,%rdx,4), %esi
testl %esi, %esi
je 0x11b82
movl %esi, (%rax)
addq $0x4, %rax
incq %rdx
cmpq %rdx, %rcx
jne 0x11b6d
movl $0x0, (%rax)
movl %ebp, 0x14(%r13)
movl %edi, 0x18(%r13)
testq %rbx, %rbx
je 0x11b9d
movq %rbx, %rdi
callq 0x7480
movq (%r13), %rsi
movl 0x14(%r13), %edx
movl 0x18(%r13), %ecx
leaq 0xa0(%rsp), %rdi
callq 0x11cac
movl 0x14(%r13), %eax
movl %eax, 0x2c(%r12)
movl 0xd0(%rsp), %eax
addl 0x20(%r12), %eax
movl %eax, 0x30(%r12)
leaq 0x80(%rsp), %rsi
leaq 0x1dd31(%rip), %rdi     # 0x2f910
callq 0x147da
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x11bf3
callq 0x7480
movq 0xa8(%rsp), %rdi
testq %rdi, %rdi
movq 0x8(%rsp), %rbx
je 0x11c0a
callq 0x7480
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0x11c1c
callq 0x7480
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x11c2b
callq 0x7480
movl %ebx, %eax
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq %r13, %rdi
jmp 0x11c8c
jmp 0x11c97
jmp 0x11c86
jmp 0x11c97
movq %rax, %rbx
movq %r14, %rdi
callq 0x7480
jmp 0x11ca4
movq %rax, %rbx
jmp 0x11c75
jmp 0x11c97
jmp 0x11c97
movq %rax, %rbx
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x11c75
callq 0x7480
movq 0xa8(%rsp), %rdi
testq %rdi, %rdi
jne 0x11c8c
jmp 0x11c9a
jmp 0x11c97
movq %rax, %rbx
movq %r12, %rdi
callq 0x7480
jmp 0x11c9a
jmp 0x11c97
jmp 0x11c97
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x1485c
movq %rbx, %rdi
callq 0x7620