// File: /workspace/github_cpp_makefile_star2_O3/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 $0x118, %rsp            # imm = 0x118
movl %edx, %ebp
movq %rsi, %rbx
movq %rdi, %r14
movq $0x0, 0x28(%rsp)
movslq 0x1d82d(%rip), %rax     # 0x2e698
movl 0x1d817(%rip), %ecx     # 0x2e688
decl %ecx
cmpl %ecx, %eax
jne 0x10eeb
movq 0x1d802(%rip), %rcx     # 0x2e680
movq (%rcx,%rax,8), %rdi
callq 0x7410
movslq 0x14(%r14), %rax
leaq 0x1(,%rax,4), %r12
movq %r12, %rdi
callq 0x7030
movq %rax, %r15
movq (%r14), %rcx
movq $-0x4, %r8
cmpl $0x0, 0x4(%rcx,%r8)
leaq 0x4(%r8), %r8
jne 0x10ea8
sarq $0x2, %r8
leaq 0x38(%rsp), %rdx
movq %r15, %rdi
movq %r12, %rsi
callq 0x13860
movq %r15, %rdi
callq 0x7660
movq 0x1d7a9(%rip), %rcx     # 0x2e680
movslq 0x1d7aa(%rip), %rdx     # 0x2e688
movq %rax, -0x8(%rcx,%rdx,8)
movq %r15, %rdi
callq 0x7490
movl 0x14(%r14), %r13d
movl 0x18(%r14), %r12d
leaq 0xf4(%rsp), %rax
leaq 0xf8(%rsp), %rdi
movq %rax, (%rdi)
leaq 0x17(%rsp), %rcx
movq %rcx, 0x8(%rdi)
movq $0x0, 0x10(%rdi)
xorl %ecx, %ecx
movl %ecx, 0x18(%rdi)
movl %ecx, (%rax)
movq %rbx, %rsi
callq 0xfd84
xorl %eax, %eax
cmpl $0x12, %ebp
setne %al
leal -0x1(%rax,%rax), %edx
leaq 0x38(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
callq 0x13ee6
movl 0x38(%rbx), %eax
movl %eax, 0x38(%r15)
movl 0x2c(%rbx), %eax
movl %eax, 0x2c(%r15)
movq %r14, 0xd8(%rsp)
movq (%r14), %rsi
movq %r15, %rdi
movl %r13d, (%rsp)
movl %r13d, %edx
movl %r12d, 0x4(%rsp)
movl %r12d, %ecx
callq 0x11859
xorl %r12d, %r12d
xorl %r15d, %r15d
movslq (%rsp), %rax
leaq 0x1(%rax), %r14
cmpl $-0x1, %eax
leaq 0x4(,%rax,4), %r13
movq %r13, 0x20(%rsp)
movq $-0x1, %rax
cmovlq %rax, %r13
callq 0x10bde
movl %eax, %edi
callq 0x10d6a
movl %eax, %ebp
cmpl $0x101fffff, %eax       # imm = 0x101FFFFF
jg 0x11055
leal -0x1(%rbp), %eax
cmpl $0x19, %eax
ja 0x111c2
leaq 0xf9b9(%rip), %rcx      # 0x20980
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpb $0x1, 0x1d729(%rip)     # 0x2e700
jne 0x10ff8
xorl %edi, %edi
movl $0x1, %esi
leaq 0x1d71d(%rip), %rdx     # 0x2e704
callq 0x7470
cmpl $-0x1, %eax
je 0x10ff8
movb $0x0, 0x1d708(%rip)     # 0x2e700
movl $0x13, %edi
callq 0x7320
callq 0x11b2f
movq %r13, %rdi
callq 0x7030
movq %rax, %rbp
movq 0x1d667(%rip), %rax     # 0x2e680
movslq 0x1d678(%rip), %rcx     # 0x2e698
movq (%rax,%rcx,8), %rcx
movq %rbp, %rdi
movq %r14, %rsi
leaq 0x28(%rsp), %rdx
callq 0x137ea
leaq 0x38(%rsp), %rdi
movq %rbp, %rsi
movl (%rsp), %edx
movl 0x4(%rsp), %ecx
callq 0x11859
movq %rbp, %rdi
callq 0x7490
jmp 0x10f9b
cmpl $0x4000003b, %ebp       # imm = 0x4000003B
jg 0x1109a
cmpl $0x10dfffff, %ebp       # imm = 0x10DFFFFF
jg 0x110d6
cmpl $0x107fffff, %ebp       # imm = 0x107FFFFF
jg 0x11107
cmpl $0x10200000, %ebp       # imm = 0x10200000
je 0x115a6
cmpl $0x10400000, %ebp       # imm = 0x10400000
je 0x115a6
cmpl $0x10600000, %ebp       # imm = 0x10600000
je 0x115a6
jmp 0x111cb
leal -0x4000003c(%rbp), %eax
cmpl $0x3d, %eax
ja 0x110b9
movabsq $0x2000054020000545, %rcx # imm = 0x2000054020000545
btq %rax, %rcx
jb 0x115a6
cmpl $0x50600000, %ebp       # imm = 0x50600000
je 0x115a6
cmpl $0x50800000, %ebp       # imm = 0x50800000
je 0x115a6
jmp 0x111cb
cmpl $0x305fffff, %ebp       # imm = 0x305FFFFF
jg 0x11130
cmpl $0x10e00000, %ebp       # imm = 0x10E00000
je 0x115a6
cmpl $0x11000000, %ebp       # imm = 0x11000000
je 0x115a6
cmpl $0x11200000, %ebp       # imm = 0x11200000
je 0x115a6
jmp 0x111cb
cmpl $0x10800000, %ebp       # imm = 0x10800000
je 0x115a6
cmpl $0x10a00000, %ebp       # imm = 0x10A00000
je 0x115a6
cmpl $0x10c00000, %ebp       # imm = 0x10C00000
je 0x115a6
jmp 0x111cb
cmpl $0x30600000, %ebp       # imm = 0x30600000
je 0x115a6
cmpl $0x30800000, %ebp       # imm = 0x30800000
je 0x115a6
cmpl $0x40000008, %ebp       # imm = 0x40000008
je 0x115a6
jmp 0x111cb
movq %r14, 0x18(%rsp)
cmpl $0x0, 0x90(%rsp)
jne 0x11180
cmpq $0x0, 0x1d4c3(%rip)     # 0x2e630
je 0x11180
movq 0x1d4c2(%rip), %rsi     # 0x2e638
leaq 0x38(%rsp), %rdi
callq 0x14116
movl 0x94(%rsp), %eax
movl %eax, %ecx
xorl $0x1, %ecx
movl %ebp, %edx
xorl $0x12, %edx
orl %ecx, %edx
je 0x111a7
movl %eax, %ecx
notl %ecx
xorl $0x13, %ebp
movb $0x1, %r14b
orl %ecx, %ebp
jne 0x11336
negl %eax
movl %eax, 0x94(%rsp)
leaq 0x38(%rsp), %rdi
callq 0x14178
movl %r15d, %r14d
jmp 0x11336
cmpl $0x7f, %ebp
je 0x115a6
cmpl $0x10ffff, %ebp         # imm = 0x10FFFF
movq %r14, 0x18(%rsp)
jg 0x112f1
cmpl $0x20, %ebp
jb 0x112f1
movl %ebp, %eax
addl $-0x7f, %eax
cmpl $0x21, %eax
jb 0x112f1
movq %rbx, 0x8(%rsp)
movslq 0x90(%rsp), %rbx
cmpq $-0x2, %rbx
leaq 0x8(,%rbx,4), %rdi
movq $-0x1, %rax
cmovlq %rax, %rdi
callq 0x7030
movq %rax, %rdi
testl %ebx, %ebx
je 0x11245
movq 0x80(%rsp), %rcx
xorl %edx, %edx
movq %rax, %rdi
movl (%rcx,%rdx,4), %esi
testl %esi, %esi
je 0x11245
movl %esi, (%rdi)
addq $0x4, %rdi
incq %rdx
cmpq %rdx, %rbx
jne 0x11230
xorl %ecx, %ecx
movl %ecx, (%rdi)
movl %ebp, (%rax,%rbx,4)
movl %ecx, 0x4(%rax,%rbx,4)
leaq 0x38(%rsp), %rdi
movq %rax, %rsi
movq %rax, %r14
callq 0x14116
movq %r14, %rdi
jmp 0x112e3
movq %rbx, 0x8(%rsp)
movslq 0x90(%rsp), %rbx
testq %rbx, %rbx
movq %r14, 0x18(%rsp)
jle 0x11312
leaq (,%rbx,4), %rdi
callq 0x7030
movq %rax, %rbp
movq %rax, %rdx
decl %ebx
movl %ebx, 0x90(%rsp)
movq 0x80(%rsp), %rax
movl $0x0, (%rax,%rbx,4)
je 0x112cd
shlq $0x2, %rbx
xorl %ecx, %ecx
movl (%rax,%rcx), %edx
testl %edx, %edx
je 0x112c7
movl %edx, (%rbp,%rcx)
addq $0x4, %rcx
cmpq %rcx, %rbx
jne 0x112b3
movq %rbp, %rdx
addq %rcx, %rdx
movl $0x0, (%rdx)
leaq 0x38(%rsp), %rdi
movq %rbp, %rsi
callq 0x14116
movq %rbp, %rdi
callq 0x7490
jmp 0x1132e
movq %r14, 0x18(%rsp)
jmp 0x1130d
movq 0x1ccd8(%rip), %r14     # 0x2dfd0
movq (%r14), %rsi
movl $0x7, %edi
callq 0x7440
movq (%r14), %rdi
callq 0x73f0
movl %r15d, %r14d
jmp 0x11336
movq 0x1ccb7(%rip), %rbx     # 0x2dfd0
movq (%rbx), %rsi
movl $0x7, %edi
callq 0x7440
movq (%rbx), %rdi
callq 0x73f0
movl %r15d, %r14d
movq 0x8(%rsp), %rbx
testq %r12, %r12
je 0x11343
movq %r12, %rdi
callq 0x7490
movq %r13, %rdi
callq 0x7030
movq %rax, %r12
movq 0x1d32b(%rip), %rax     # 0x2e680
movslq 0x1d33c(%rip), %rcx     # 0x2e698
movq (%rax,%rcx,8), %rcx
movq %r12, %rdi
movq 0x18(%rsp), %rsi
leaq 0x28(%rsp), %rdx
callq 0x137ea
movl 0x90(%rsp), %edx
testl %edx, %edx
jle 0x11514
movq %rbx, 0x8(%rsp)
movl 0x1d30b(%rip), %r13d    # 0x2e698
movl 0x28(%rsp), %ebp
movl 0x94(%rsp), %eax
testb $0x1, %r14b
movl $0x0, %ecx
cmovnel %eax, %ecx
addl 0x4(%rsp), %ecx
movq 0x20(%rsp), %r14
xorl %esi, %esi
cmpl %ebp, %ecx
setl %sil
xorl %edi, %edi
testl %ecx, %ecx
setns %dil
testl %eax, %eax
cmovgl %esi, %edi
cmpb $0x1, %dil
jne 0x1143a
movq 0x80(%rsp), %r8
movslq %edx, %r9
movslq %ecx, %rdi
movslq %eax, %r10
movslq %ebp, %rsi
leaq (%r12,%rdi,4), %r11
leaq (,%r10,4), %rbx
testl %edx, %edx
je 0x114ef
xorl %r14d, %r14d
movl (%r8,%r14,4), %r15d
testl %r15d, %r15d
je 0x114ed
cmpl (%r11,%r14,4), %r15d
jne 0x11413
incq %r14
cmpq %r14, %r9
jne 0x113f3
jmp 0x114ed
xorl %r14d, %r14d
addq %r10, %rdi
setns %r14b
xorl %r15d, %r15d
cmpq %rsi, %rdi
setl %r15b
testl %eax, %eax
cmovlel %r14d, %r15d
addq %rbx, %r11
testb %r15b, %r15b
movq 0x20(%rsp), %r14
jne 0x113e8
testl %eax, %eax
jle 0x11450
movl 0x1d244(%rip), %ecx     # 0x2e688
decl %ecx
cmpl %ecx, %r13d
jl 0x11459
jmp 0x1157f
testl %r13d, %r13d
jle 0x1157f
addl %eax, %r13d
movq 0x1d21d(%rip), %rax     # 0x2e680
movl %r13d, 0x34(%rsp)
movslq %r13d, %rbx
movq (%rax,%rbx,8), %rdi
callq 0x7180
movq %rax, %r15
leaq 0x1(%rax), %r13
movq %r12, %rdi
callq 0x7490
movq %r13, %rax
shrq $0x3e, %rax
leaq 0x4(,%r15,4), %rcx
negq %rax
movl $0x0, %edi
sbbq %rdi, %rdi
orq %rcx, %rdi
callq 0x7030
movq %rax, %r12
movq 0x1d1d1(%rip), %rax     # 0x2e680
movq (%rax,%rbx,8), %rcx
movq %r12, %rdi
movq %r13, %rsi
leaq 0x28(%rsp), %rdx
callq 0x137ea
movl 0x28(%rsp), %ebp
movl 0x90(%rsp), %edx
movl 0x94(%rsp), %eax
movl %ebp, %ecx
subl %edx, %ecx
testl %eax, %eax
movl $0x0, %esi
cmovgl %esi, %ecx
movl 0x34(%rsp), %r13d
jmp 0x113ad
movl %edi, %ecx
movl %r13d, 0x1d1a2(%rip)    # 0x2e698
leaq 0x4(,%rsi,4), %r14
incq %rsi
xorl %r15d, %r15d
movq %rsi, 0x18(%rsp)
movl %ecx, 0x4(%rsp)
movq 0x8(%rsp), %rbx
jmp 0x1151f
movl (%rsp), %ebp
movl %r14d, %r15d
movq 0x20(%rsp), %r14
movq %r12, %rdi
callq 0x7490
cmpl $-0x1, %ebp
movq $-0x1, %rax
cmovlq %rax, %r14
movq %r14, %rdi
callq 0x7030
movq %rax, %r12
movq 0x1d139(%rip), %rax     # 0x2e680
movslq 0x1d14a(%rip), %rcx     # 0x2e698
movq (%rax,%rcx,8), %rcx
movq %r12, %rdi
movq 0x18(%rsp), %rsi
leaq 0x28(%rsp), %rdx
callq 0x137ea
leaq 0x38(%rsp), %rdi
movq %r12, %rsi
movl %ebp, %edx
movl 0x4(%rsp), %ecx
callq 0x11859
movl %ebp, (%rsp)
jmp 0x10f78
movq 0x1ca4a(%rip), %rbx     # 0x2dfd0
movq (%rbx), %rsi
movl $0x7, %edi
callq 0x7440
movq (%rbx), %rdi
callq 0x73f0
xorl %r15d, %r15d
movl (%rsp), %ebp
jmp 0x1150d
movq %rbp, 0x20(%rsp)
movb $0x1, %r14b
movq %r12, %rbp
movq $0x0, 0x98(%rsp)
movl $0x4, %edi
callq 0x7030
xorl %ecx, %ecx
movl %ecx, (%rax)
movq %rax, 0xa0(%rsp)
movl %ecx, 0xc4(%rsp)
movl 0x24(%rbx), %eax
movl %eax, 0xb0(%rsp)
movq %rbx, %r12
movslq 0x1c(%rbx), %rbx
leal 0x1(%rbx), %eax
shlq $0x2, %rax
cmpq $-0x1, %rbx
movl %ebx, 0xb4(%rsp)
movq $-0x1, %r15
cmovgeq %rax, %r15
movq %r15, %rdi
callq 0x7030
movq %rax, %r13
movq %rax, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x7200
movq %r13, 0xe8(%rsp)
movq %r12, %r15
movslq 0x28(%r12), %rax
movq %r13, %rcx
cmpl %eax, %ebx
movq %rbp, %r12
movq 0x20(%rsp), %rbp
je 0x1165b
movq 0x8(%r15), %rdx
movq %r13, %rcx
movl (%rdx,%rax,4), %esi
testl %esi, %esi
je 0x1165b
movl %esi, (%rcx)
addq $0x4, %rcx
incq %rax
cmpq %rax, %rbx
jne 0x11646
movl $0x0, (%rcx)
movq $-0x1, %rax
cmpl $0x0, 0x4(%r13,%rax,4)
leaq 0x1(%rax), %rax
jne 0x11668
leaq 0xe0(%rsp), %rsi
movq %rax, (%rsi)
leaq 0x98(%rsp), %rdi
callq 0x142ba
movq %r15, %rbx
movq 0xd8(%rsp), %r15
xorl %eax, %eax
movl %eax, 0xb8(%rsp)
movl 0x24(%rbx), %ecx
movl %ecx, 0xbc(%rsp)
movl %eax, 0xc0(%rsp)
movl (%rsp), %eax
movl %eax, 0xc4(%rsp)
movl 0x50(%rsp), %eax
movl 0x68(%rsp), %ecx
movl %ecx, 0xc8(%rsp)
movl 0x34(%rbx), %ecx
movl %ecx, 0xcc(%rsp)
movl %eax, 0xd0(%rsp)
testq %r12, %r12
sete %al
xorb $0x1, %r14b
orb %al, %r14b
jne 0x1172c
movb $0x1, 0x1cfab(%rip)     # 0x2e69c
movq (%r15), %rax
movl 0x10(%r15), %ecx
incl %ecx
je 0x11717
movslq %ecx, %rcx
xorl %edx, %edx
movl (%r12,%rdx,4), %esi
testl %esi, %esi
je 0x11717
movl %esi, (%rax)
addq $0x4, %rax
incq %rdx
cmpq %rdx, %rcx
jne 0x11701
movl $0x0, (%rax)
movl (%rsp), %eax
movl %eax, 0x14(%r15)
movl 0x4(%rsp), %eax
movl %eax, 0x18(%r15)
testq %r12, %r12
je 0x11739
movq %r12, %rdi
callq 0x7490
movq (%r15), %rsi
movl 0x14(%r15), %edx
movl 0x18(%r15), %ecx
leaq 0x98(%rsp), %rdi
callq 0x11859
movl 0x14(%r15), %eax
movl %eax, 0x2c(%rbx)
movl 0xc8(%rsp), %eax
addl 0x20(%rbx), %eax
movl %eax, 0x30(%rbx)
leaq 0x78(%rsp), %rsi
leaq 0x1cebf(%rip), %rdi     # 0x2e630
callq 0x142ba
movq 0xe8(%rsp), %rdi
testq %rdi, %rdi
je 0x11788
callq 0x7490
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0x1179a
callq 0x7490
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x117ac
callq 0x7490
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x117bb
callq 0x7490
movl %ebp, %eax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
cmpl $0xc, %ebp
setne %al
negl %eax
orl $0xc, %eax
xorl %r14d, %r14d
movq %rax, 0x20(%rsp)
jmp 0x115ae
movq %rax, %rbx
movq %r14, %rdi
jmp 0x11842
jmp 0x1181b
jmp 0x11813
jmp 0x1181b
jmp 0x1181b
movq %rax, %rbx
movq %r15, %rdi
callq 0x7490
jmp 0x11851
jmp 0x1181b
jmp 0x1181b
movq %rax, %rbx
jmp 0x11835
jmp 0x1181b
jmp 0x1181b
movq %rax, %rbx
movq %rbp, %rdi
jmp 0x11842
movq %rax, %rbx
jmp 0x11847
movq %rax, %rbx
movq 0xe8(%rsp), %rdi
testq %rdi, %rdi
je 0x11835
callq 0x7490
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0x11847
callq 0x7490
leaq 0x38(%rsp), %rdi
callq 0x1433c
movq %rbx, %rdi
callq 0x7630