// File: adamnovak[P]rlcsa/docarray.cpp
// Function: CSA::DocArray::readRules(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, bool)
void
DocArray::readRules(const std::string& name_prefix, bool print)
{
  std::vector<pair_type> occurrences; // (block_id, rule_id)
  std::vector<usint> docs;
  SuccinctVector::Encoder rb_encoder(RULE_BLOCK_SIZE);
  SuccinctVector::Encoder rb_encoder_rle(RULE_BLOCK_SIZE);
  usint files = 0, current_rule = this->getNumberOfDocuments();
  usint total_rules = 0, total_occs = 0, total_size = 0, total_runs = 0;


  // Parse the individual files containing rules / bicliques.
  while(true)
  {
    std::ostringstream fn;
    fn << name_prefix << "-biclique-it-" << files << ".txt";
    std::ifstream input(fn.str().c_str(), std::ios_base::binary);
    if(!input) { break; }

    std::vector<std::string> rows;
    readRows(input, rows, true);
    input.close();

    bool invalid_blocks = false, nonoccurring_rules = false, invalid_docs = false, empty_rules = false;
    usint curr_rules = 0, curr_occs = 0, curr_size = 0, curr_runs = 0;
    for(std::vector<std::string>::iterator siter = rows.begin(); siter != rows.end(); ++siter)
    {
      std::vector<usint> before, after;
      parseLine(*siter, before, '-', after);

      // Block ids.
      bool occurs = false;
      for(std::vector<usint>::iterator iter = before.begin(); iter != before.end(); ++iter)
      {
        if(this->nodeIsBlock(*iter))
        {
          occurrences.push_back(pair_type(this->nodeToBlock(*iter), current_rule));
          curr_occs++; occurs = true;
        }
        else { invalid_blocks = true; }
      }
      if(!occurs) { nonoccurring_rules = true; }
      curr_rules++; current_rule++;

      // Document ids.
      rb_encoder.addBit(total_size + curr_size);
      rb_encoder_rle.addBit(docs.size());
      occurs = false;
      usint prev_doc = WORD_MAX - 1, run_length = 0;
      for(std::vector<usint>::iterator iter = after.begin(); iter != after.end(); ++iter)
      {
        if(this->nodeIsDoc(*iter))
        {
          usint doc_id = this->nodeToDoc(*iter);
          if(doc_id == prev_doc + 1) { run_length++; prev_doc++; }
          else
          {
            if(run_length > 0) { docs.push_back(run_length); }
            docs.push_back(doc_id); run_length = 1; curr_runs++;
            prev_doc = doc_id;
          }
          curr_size++; occurs = true;
        }
        else { invalid_docs = true; }
      }
      if(!occurs)
      {
        docs.push_back(this->getNumberOfDocuments());
        curr_size++; curr_runs++; empty_rules = true;
      }
      else { docs.push_back(run_length); }
    }

    if(print)
    {
      std::cout << "File " << files << ": "
        << curr_rules << " rules, "
        << curr_occs << " occurrences, "
        << curr_size << " document ids in "
        << curr_runs << " runs" << std::endl;
      if(invalid_blocks)     { std::cout << "There were invalid block ids." << std::endl; }
      if(nonoccurring_rules) { std::cout << "There were non-occurring rules." << std::endl; }
      if(invalid_docs)       { std::cout << "There were invalid document ids." << std::endl; }
      if(empty_rules)        { std::cout << "There were empty rules." << std::endl; }
      std::cout << std::endl;
    }
    files++;
    total_rules += curr_rules; total_occs += curr_occs; total_size += curr_size; total_runs += curr_runs;
  }


  // Parse the singleton file and the remaining part of the graph.
  usint total_singletons = 0, temp = 0;

  std::ostringstream ffn;
  ffn << name_prefix << "-it-" << (files - 1);
  std::string remainder_name = ffn.str();
  temp = parseSingletonFile(remainder_name, *this, occurrences, print);
  if(temp > 0) { total_singletons += temp; files++; }

  std::string singleton_name = name_prefix + ".singletons";
  temp = parseSingletonFile(singleton_name, *this, occurrences, print);
  if(temp > 0) { total_singletons += temp; files++; }


  // Build the structures.
  if(total_size < docs.size())
  {
    this->uses_rle = false;
    this->rule_borders = new SuccinctVector(rb_encoder, total_size);
    WriteBuffer rbuf(total_size, length(this->getNumberOfDocuments()));
    bool need_run_length = false; usint prev = 0;
    for(std::vector<usint>::iterator iter = docs.begin(); iter != docs.end(); ++iter)
    {
      if(!need_run_length)
      {
        prev = *iter;
        rbuf.writeItem(*iter);
        need_run_length = (*iter != this->getNumberOfDocuments());
      }
      else
      {
        for(usint i = 1; i < *iter; i++) { rbuf.writeItem(prev + i); }
        need_run_length = false;
      }
    }
    this->rules = rbuf.getReadBuffer();
  }
  else
  {
    this->uses_rle = true;
    this->rule_borders = new SuccinctVector(rb_encoder_rle, docs.size());
    WriteBuffer rbuf(docs.size(), length(this->getNumberOfDocuments()));
    for(std::vector<usint>::iterator iter = docs.begin(); iter != docs.end(); ++iter)
    {
      rbuf.writeItem(*iter);
    }
    this->rules = rbuf.getReadBuffer();
  }

  parallelSort(occurrences.begin(), occurrences.end());
  usint real_occs = occurrences.size();
  for(usint i = 0, looking_for = 0; i < occurrences.size(); i++)
  {
    while(looking_for < occurrences[i].first) { real_occs++; looking_for++; }
    looking_for = occurrences[i].first + 1;
  }
  real_occs += this->getNumberOfNodes() - 1 - occurrences.rbegin()->first;

  SuccinctVector::Encoder bb_encoder(BLOCK_BLOCK_SIZE);
  WriteBuffer bbuf(real_occs, length(this->maxInteger()));
  usint pos = 0;
  for(usint i = 0, looking_for = 0; i < occurrences.size(); i++)
  {
    while(looking_for < occurrences[i].first)
    {
      bb_encoder.addBit(pos);
      bbuf.writeItem(this->maxInteger()); pos++;
      looking_for++;
    }
    if(i == 0 || occurrences[i].first != occurrences[i - 1].first)
    {
      bb_encoder.addBit(pos);
      looking_for++;
    }
    bbuf.writeItem(occurrences[i].second); pos++;
  }
  for(usint i = occurrences.rbegin()->first + 1; i < this->getNumberOfNodes(); i++)
  {
    bb_encoder.addBit(pos);
    bbuf.writeItem(this->maxInteger()); pos++;
  }
  this->block_borders = new SuccinctVector(bb_encoder, real_occs);
  this->blocks = bbuf.getReadBuffer();

  if(print)
  {
    std::cout << files << " files: "
      << total_rules << " rules, "
      << total_occs << " occurrences, "
      << total_size << " document ids in "
      << total_runs << " runs, "
      << total_singletons << " singletons, "
      << (real_occs - total_occs - total_singletons) << " complete blocks" << std::endl;
    if(this->usesRLE()) { std::cout << "Using run-length encoded rules." << std::endl; }
    std::cout << std::endl;
  }
  this->has_grammar = true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb20, %rsp            # imm = 0xB20
movb %dl, %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
andb $0x1, %al
movb %al, -0x11(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x8d0(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x17910
leaq -0x48(%rbp), %rdi
callq 0x10bc0
leaq -0xb8(%rbp), %rdi
movl $0x20, %esi
movl $0x100000, %edx         # imm = 0x100000
callq 0x2cf20
jmp 0x2142f
leaq -0x138(%rbp), %rdi
movl $0x20, %esi
movl $0x100000, %edx         # imm = 0x100000
callq 0x2cf20
jmp 0x21447
movq -0x8d0(%rbp), %rdi
movl $0x0, -0x13c(%rbp)
callq 0x237c0
movl %eax, -0x8d4(%rbp)
jmp 0x21465
movl -0x8d4(%rbp), %eax
movl %eax, -0x140(%rbp)
movl $0x0, -0x144(%rbp)
movl $0x0, -0x148(%rbp)
movl $0x0, -0x14c(%rbp)
movl $0x0, -0x150(%rbp)
jmp 0x2149b
leaq -0x2c8(%rbp), %rdi
callq 0x3430
jmp 0x214a9
movq -0x10(%rbp), %rsi
leaq -0x2c8(%rbp), %rdi
callq 0x3290
movq %rax, -0x8e0(%rbp)
jmp 0x214c2
movq -0x8e0(%rbp), %rdi
leaq 0x13527(%rip), %rsi     # 0x349f7
callq 0x32c0
movq %rax, -0x8e8(%rbp)
jmp 0x214de
movq -0x8e8(%rbp), %rdi
movl -0x13c(%rbp), %esi
callq 0x3420
movq %rax, -0x8f0(%rbp)
jmp 0x214f9
movq -0x8f0(%rbp), %rdi
leaq 0x134fe(%rip), %rsi     # 0x34a05
callq 0x32c0
jmp 0x2150e
leaq -0x4f0(%rbp), %rdi
leaq -0x2c8(%rbp), %rsi
callq 0x3300
jmp 0x21523
leaq -0x4f0(%rbp), %rdi
callq 0x3130
movq %rax, %rsi
leaq -0x4d0(%rbp), %rdi
movl $0x4, %edx
callq 0x35a0
jmp 0x21545
leaq -0x4f0(%rbp), %rdi
callq 0x3638
movq -0x4d0(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x4d0(%rbp,%rax), %rdi
callq 0x3160
movb %al, -0x8f1(%rbp)
jmp 0x21571
movb -0x8f1(%rbp), %al
testb $0x1, %al
jne 0x21580
jmp 0x21625
movl $0x3, -0x4f4(%rbp)
jmp 0x21dba
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
jmp 0x22b83
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
jmp 0x22b77
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
jmp 0x22b6b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
jmp 0x21dfd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
leaq -0x4f0(%rbp), %rdi
callq 0x3638
jmp 0x21dfd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
jmp 0x21df1
leaq -0x510(%rbp), %rdi
movq %rdi, -0x900(%rbp)
callq 0x23820
movq -0x900(%rbp), %rsi
leaq -0x4d0(%rbp), %rdi
movl $0x1, %edx
callq 0x2f270
jmp 0x21652
leaq -0x4d0(%rbp), %rdi
callq 0x30b0
jmp 0x21660
movb $0x0, -0x511(%rbp)
movb $0x0, -0x512(%rbp)
movb $0x0, -0x513(%rbp)
movb $0x0, -0x514(%rbp)
movl $0x0, -0x518(%rbp)
movl $0x0, -0x51c(%rbp)
movl $0x0, -0x520(%rbp)
movl $0x0, -0x524(%rbp)
leaq -0x510(%rbp), %rdi
callq 0x23840
movq %rax, -0x530(%rbp)
leaq -0x510(%rbp), %rdi
callq 0x238b0
movq %rax, -0x538(%rbp)
leaq -0x530(%rbp), %rdi
leaq -0x538(%rbp), %rsi
callq 0x23870
testb $0x1, %al
jne 0x216e6
jmp 0x21af8
leaq -0x550(%rbp), %rdi
movq %rdi, -0x910(%rbp)
callq 0x10bc0
leaq -0x568(%rbp), %rdi
movq %rdi, -0x908(%rbp)
callq 0x10bc0
leaq -0x530(%rbp), %rdi
callq 0x238e0
movq -0x910(%rbp), %rsi
movq -0x908(%rbp), %rcx
movq %rax, %rdi
movl $0x2d, %edx
callq 0x20d20
jmp 0x21735
movb $0x0, -0x569(%rbp)
leaq -0x550(%rbp), %rdi
callq 0x7870
movq %rax, -0x578(%rbp)
leaq -0x550(%rbp), %rdi
callq 0x78e0
movq %rax, -0x580(%rbp)
leaq -0x578(%rbp), %rdi
leaq -0x580(%rbp), %rsi
callq 0x78a0
testb $0x1, %al
jne 0x2177e
jmp 0x21883
leaq -0x578(%rbp), %rdi
callq 0x7910
movq -0x8d0(%rbp), %rdi
movl (%rax), %esi
callq 0x23900
movb %al, -0x911(%rbp)
jmp 0x217a0
movb -0x911(%rbp), %al
testb $0x1, %al
jne 0x217af
jmp 0x21869
leaq -0x578(%rbp), %rdi
callq 0x7910
movq -0x8d0(%rbp), %rdi
movl (%rax), %esi
callq 0x23970
movl %eax, -0x918(%rbp)
jmp 0x217d1
movl -0x918(%rbp), %eax
movl %eax, -0x58c(%rbp)
leaq -0x588(%rbp), %rdi
leaq -0x58c(%rbp), %rsi
leaq -0x140(%rbp), %rdx
callq 0x11340
jmp 0x217f9
leaq -0x30(%rbp), %rdi
leaq -0x588(%rbp), %rsi
callq 0x17930
jmp 0x2180b
movl -0x51c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x51c(%rbp)
movb $0x1, -0x569(%rbp)
jmp 0x21870
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
jmp 0x21de5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
leaq -0x568(%rbp), %rdi
callq 0x1c250
leaq -0x550(%rbp), %rdi
callq 0x1c250
jmp 0x21de5
movb $0x1, -0x511(%rbp)
jmp 0x21872
leaq -0x578(%rbp), %rdi
callq 0x7930
jmp 0x2174f
testb $0x1, -0x569(%rbp)
jne 0x21893
movb $0x1, -0x512(%rbp)
movl -0x518(%rbp), %eax
incl %eax
movl %eax, -0x518(%rbp)
movl -0x140(%rbp), %eax
incl %eax
movl %eax, -0x140(%rbp)
movl -0x14c(%rbp), %esi
movl -0x520(%rbp), %eax
addl %eax, %esi
leaq -0xb8(%rbp), %rdi
callq 0x2d0b0
jmp 0x218cb
leaq -0x48(%rbp), %rdi
callq 0x7810
movl %eax, %esi
leaq -0x138(%rbp), %rdi
callq 0x2d0b0
jmp 0x218e4
movb $0x0, -0x569(%rbp)
movl $0xfffffffe, -0x590(%rbp) # imm = 0xFFFFFFFE
movl $0x0, -0x594(%rbp)
leaq -0x568(%rbp), %rdi
callq 0x7870
movq %rax, -0x5a0(%rbp)
leaq -0x568(%rbp), %rdi
callq 0x78e0
movq %rax, -0x5a8(%rbp)
leaq -0x5a0(%rbp), %rdi
leaq -0x5a8(%rbp), %rsi
callq 0x78a0
testb $0x1, %al
jne 0x21941
jmp 0x21a59
leaq -0x5a0(%rbp), %rdi
callq 0x7910
movq -0x8d0(%rbp), %rdi
movl (%rax), %esi
callq 0x239a0
movb %al, -0x919(%rbp)
jmp 0x21963
movb -0x919(%rbp), %al
testb $0x1, %al
jne 0x21972
jmp 0x21a3f
leaq -0x5a0(%rbp), %rdi
callq 0x7910
movq -0x8d0(%rbp), %rdi
movl (%rax), %esi
callq 0x239f0
movl %eax, -0x920(%rbp)
jmp 0x21994
movl -0x920(%rbp), %eax
movl %eax, -0x5ac(%rbp)
movl -0x5ac(%rbp), %eax
movl -0x590(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jne 0x219d3
movl -0x594(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x594(%rbp)
movl -0x590(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x590(%rbp)
jmp 0x21a27
cmpl $0x0, -0x594(%rbp)
jbe 0x219f0
leaq -0x48(%rbp), %rdi
leaq -0x594(%rbp), %rsi
callq 0x10cc0
jmp 0x219ee
jmp 0x219f0
leaq -0x48(%rbp), %rdi
leaq -0x5ac(%rbp), %rsi
callq 0x10cc0
jmp 0x21a02
movl $0x1, -0x594(%rbp)
movl -0x524(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x524(%rbp)
movl -0x5ac(%rbp), %eax
movl %eax, -0x590(%rbp)
movl -0x520(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x520(%rbp)
movb $0x1, -0x569(%rbp)
jmp 0x21a46
movb $0x1, -0x513(%rbp)
jmp 0x21a48
leaq -0x5a0(%rbp), %rdi
callq 0x7930
jmp 0x21912
testb $0x1, -0x569(%rbp)
jne 0x21abb
movq -0x8d0(%rbp), %rdi
callq 0x237c0
movl %eax, -0x924(%rbp)
jmp 0x21a76
movl -0x924(%rbp), %eax
movl %eax, -0x5b0(%rbp)
leaq -0x48(%rbp), %rdi
leaq -0x5b0(%rbp), %rsi
callq 0x1bf60
jmp 0x21a94
movl -0x520(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x520(%rbp)
movl -0x524(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x524(%rbp)
movb $0x1, -0x514(%rbp)
jmp 0x21acf
leaq -0x48(%rbp), %rdi
leaq -0x594(%rbp), %rsi
callq 0x10cc0
jmp 0x21acd
jmp 0x21acf
leaq -0x568(%rbp), %rdi
callq 0x1c250
leaq -0x550(%rbp), %rdi
callq 0x1c250
leaq -0x530(%rbp), %rdi
callq 0x23a10
jmp 0x216b7
testb $0x1, -0x11(%rbp)
je 0x21d4d
movq 0x244c7(%rip), %rdi     # 0x45fd0
leaq 0x12efa(%rip), %rsi     # 0x34a0a
callq 0x32c0
movq %rax, -0x930(%rbp)
jmp 0x21b1e
movq -0x930(%rbp), %rdi
movl -0x13c(%rbp), %esi
callq 0x3420
movq %rax, -0x938(%rbp)
jmp 0x21b39
movq -0x938(%rbp), %rdi
leaq 0x126d4(%rip), %rsi     # 0x3421b
callq 0x32c0
movq %rax, -0x940(%rbp)
jmp 0x21b55
movq -0x940(%rbp), %rdi
movl -0x518(%rbp), %esi
callq 0x3420
movq %rax, -0x948(%rbp)
jmp 0x21b70
movq -0x948(%rbp), %rdi
leaq 0x12e92(%rip), %rsi     # 0x34a10
callq 0x32c0
movq %rax, -0x950(%rbp)
jmp 0x21b8c
movq -0x950(%rbp), %rdi
movl -0x51c(%rbp), %esi
callq 0x3420
movq %rax, -0x958(%rbp)
jmp 0x21ba7
movq -0x958(%rbp), %rdi
leaq 0x12e64(%rip), %rsi     # 0x34a19
callq 0x32c0
movq %rax, -0x960(%rbp)
jmp 0x21bc3
movq -0x960(%rbp), %rdi
movl -0x520(%rbp), %esi
callq 0x3420
movq %rax, -0x968(%rbp)
jmp 0x21bde
movq -0x968(%rbp), %rdi
leaq 0x12e3c(%rip), %rsi     # 0x34a28
callq 0x32c0
movq %rax, -0x970(%rbp)
jmp 0x21bfa
movq -0x970(%rbp), %rdi
movl -0x524(%rbp), %esi
callq 0x3420
movq %rax, -0x978(%rbp)
jmp 0x21c15
movq -0x978(%rbp), %rdi
leaq 0x12e17(%rip), %rsi     # 0x34a3a
callq 0x32c0
movq %rax, -0x980(%rbp)
jmp 0x21c31
movq -0x980(%rbp), %rdi
movq 0x24371(%rip), %rsi     # 0x45fb0
callq 0x3330
jmp 0x21c46
testb $0x1, -0x511(%rbp)
je 0x21c82
movq 0x2437a(%rip), %rdi     # 0x45fd0
leaq 0x12d5b(%rip), %rsi     # 0x349b8
callq 0x32c0
movq %rax, -0x988(%rbp)
jmp 0x21c6b
movq -0x988(%rbp), %rdi
movq 0x24337(%rip), %rsi     # 0x45fb0
callq 0x3330
jmp 0x21c80
jmp 0x21c82
testb $0x1, -0x512(%rbp)
je 0x21cbe
movq 0x2433e(%rip), %rdi     # 0x45fd0
leaq 0x12da7(%rip), %rsi     # 0x34a40
callq 0x32c0
movq %rax, -0x990(%rbp)
jmp 0x21ca7
movq -0x990(%rbp), %rdi
movq 0x242fb(%rip), %rsi     # 0x45fb0
callq 0x3330
jmp 0x21cbc
jmp 0x21cbe
testb $0x1, -0x513(%rbp)
je 0x21cfa
movq 0x24302(%rip), %rdi     # 0x45fd0
leaq 0x12d01(%rip), %rsi     # 0x349d6
callq 0x32c0
movq %rax, -0x998(%rbp)
jmp 0x21ce3
movq -0x998(%rbp), %rdi
movq 0x242bf(%rip), %rsi     # 0x45fb0
callq 0x3330
jmp 0x21cf8
jmp 0x21cfa
testb $0x1, -0x514(%rbp)
je 0x21d36
movq 0x242c6(%rip), %rdi     # 0x45fd0
leaq 0x12d4f(%rip), %rsi     # 0x34a60
callq 0x32c0
movq %rax, -0x9a0(%rbp)
jmp 0x21d1f
movq -0x9a0(%rbp), %rdi
movq 0x24283(%rip), %rsi     # 0x45fb0
callq 0x3330
jmp 0x21d34
jmp 0x21d36
movq 0x24293(%rip), %rdi     # 0x45fd0
movq 0x2426c(%rip), %rsi     # 0x45fb0
callq 0x3330
jmp 0x21d4b
jmp 0x21d4d
movl -0x13c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x13c(%rbp)
movl -0x518(%rbp), %eax
addl -0x144(%rbp), %eax
movl %eax, -0x144(%rbp)
movl -0x51c(%rbp), %eax
addl -0x148(%rbp), %eax
movl %eax, -0x148(%rbp)
movl -0x520(%rbp), %eax
addl -0x14c(%rbp), %eax
movl %eax, -0x14c(%rbp)
movl -0x524(%rbp), %eax
addl -0x150(%rbp), %eax
movl %eax, -0x150(%rbp)
leaq -0x510(%rbp), %rdi
callq 0x23a30
movl $0x0, -0x4f4(%rbp)
leaq -0x4d0(%rbp), %rdi
callq 0x30e0
leaq -0x2c8(%rbp), %rdi
callq 0x30d0
movl -0x4f4(%rbp), %eax
testl %eax, %eax
je 0x21de0
jmp 0x21dde
jmp 0x21e0e
jmp 0x21499
leaq -0x510(%rbp), %rdi
callq 0x23a30
leaq -0x4d0(%rbp), %rdi
callq 0x30e0
leaq -0x2c8(%rbp), %rdi
callq 0x30d0
jmp 0x22b6b
movl $0x0, -0x5b4(%rbp)
movl $0x0, -0x5b8(%rbp)
leaq -0x730(%rbp), %rdi
callq 0x3430
jmp 0x21e30
movq -0x10(%rbp), %rsi
leaq -0x730(%rbp), %rdi
callq 0x3290
movq %rax, -0x9a8(%rbp)
jmp 0x21e49
movq -0x9a8(%rbp), %rdi
leaq 0x12ba9(%rip), %rsi     # 0x34a00
callq 0x32c0
movq %rax, -0x9b0(%rbp)
jmp 0x21e65
movq -0x9b0(%rbp), %rdi
movl -0x13c(%rbp), %esi
decl %esi
callq 0x3420
jmp 0x21e7b
leaq -0x750(%rbp), %rdi
leaq -0x730(%rbp), %rsi
callq 0x3300
jmp 0x21e90
movq -0x8d0(%rbp), %rsi
movzbl -0x11(%rbp), %ecx
andl $0x1, %ecx
leaq -0x750(%rbp), %rdi
leaq -0x30(%rbp), %rdx
callq 0x20e50
movl %eax, -0x9b4(%rbp)
jmp 0x21eb6
movl -0x9b4(%rbp), %eax
movl %eax, -0x5b8(%rbp)
cmpl $0x0, -0x5b8(%rbp)
jbe 0x21f1c
movl -0x5b8(%rbp), %eax
addl -0x5b4(%rbp), %eax
movl %eax, -0x5b4(%rbp)
movl -0x13c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x13c(%rbp)
jmp 0x21f1c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
jmp 0x22b5f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
jmp 0x22b53
movq -0x10(%rbp), %rsi
leaq 0x12379(%rip), %rdx     # 0x342a0
leaq -0x770(%rbp), %rdi
callq 0x7770
jmp 0x21f35
movq -0x8d0(%rbp), %rsi
movzbl -0x11(%rbp), %ecx
andl $0x1, %ecx
leaq -0x770(%rbp), %rdi
leaq -0x30(%rbp), %rdx
callq 0x20e50
movl %eax, -0x9b8(%rbp)
jmp 0x21f5b
movl -0x9b8(%rbp), %eax
movl %eax, -0x5b8(%rbp)
cmpl $0x0, -0x5b8(%rbp)
jbe 0x21faa
movl -0x5b8(%rbp), %eax
addl -0x5b4(%rbp), %eax
movl %eax, -0x5b4(%rbp)
movl -0x13c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x13c(%rbp)
jmp 0x21faa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
jmp 0x22b47
movl -0x14c(%rbp), %eax
movq %rax, -0x9c0(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x7810
movq %rax, %rcx
movq -0x9c0(%rbp), %rax
cmpq %rcx, %rax
jae 0x22236
movq -0x8d0(%rbp), %rax
movb $0x0, 0x4a(%rax)
movl $0x48, %edi
callq 0x32e0
movq %rax, -0x9c8(%rbp)
jmp 0x21ff1
movq -0x9c8(%rbp), %rdi
movl -0x14c(%rbp), %edx
leaq -0xb8(%rbp), %rsi
callq 0x2c4f0
jmp 0x2200c
movq -0x8d0(%rbp), %rdi
movq -0x9c8(%rbp), %rax
movq %rax, 0x28(%rdi)
movl -0x14c(%rbp), %eax
movl %eax, -0x9d0(%rbp)
callq 0x237c0
movl %eax, -0x9cc(%rbp)
jmp 0x22037
movl -0x9cc(%rbp), %edi
callq 0x178e0
movl %eax, -0x9d4(%rbp)
jmp 0x2204a
movl -0x9d4(%rbp), %edx
movl -0x9d0(%rbp), %esi
leaq -0x798(%rbp), %rdi
callq 0x28e30
jmp 0x22064
movb $0x0, -0x799(%rbp)
movl $0x0, -0x7a0(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x7870
movq %rax, -0x7a8(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x78e0
movq %rax, -0x7b0(%rbp)
leaq -0x7a8(%rbp), %rdi
leaq -0x7b0(%rbp), %rsi
callq 0x78a0
testb $0x1, %al
jne 0x220b1
jmp 0x221fe
testb $0x1, -0x799(%rbp)
jne 0x22186
leaq -0x7a8(%rbp), %rdi
movq %rdi, -0x9e0(%rbp)
callq 0x7910
movq -0x9e0(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0x7a0(%rbp)
callq 0x7910
movl (%rax), %esi
leaq -0x798(%rbp), %rdi
callq 0x179c0
jmp 0x220f5
leaq -0x7a8(%rbp), %rdi
callq 0x7910
movq -0x8d0(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0x9e8(%rbp)
callq 0x237c0
movl %eax, -0x9e4(%rbp)
jmp 0x2211d
movl -0x9e8(%rbp), %eax
movl -0x9e4(%rbp), %ecx
cmpl %ecx, %eax
setne %al
andb $0x1, %al
movb %al, -0x799(%rbp)
jmp 0x221eb
movq -0x9c8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
movl $0x48, %esi
callq 0x32f0
jmp 0x22b47
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
leaq -0x798(%rbp), %rdi
callq 0x28f70
jmp 0x22b47
movl $0x1, -0x7b4(%rbp)
movl -0x7b4(%rbp), %eax
movl %eax, -0x9ec(%rbp)
leaq -0x7a8(%rbp), %rdi
callq 0x7910
movq %rax, %rcx
movl -0x9ec(%rbp), %eax
cmpl (%rcx), %eax
jae 0x221e4
movl -0x7a0(%rbp), %esi
movl -0x7b4(%rbp), %eax
addl %eax, %esi
leaq -0x798(%rbp), %rdi
callq 0x179c0
jmp 0x221d1
jmp 0x221d3
movl -0x7b4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7b4(%rbp)
jmp 0x22190
movb $0x0, -0x799(%rbp)
jmp 0x221ed
leaq -0x7a8(%rbp), %rdi
callq 0x7930
jmp 0x22085
leaq -0x798(%rbp), %rdi
callq 0x28fb0
movq %rax, -0x9f8(%rbp)
jmp 0x22213
movq -0x8d0(%rbp), %rax
movq -0x9f8(%rbp), %rcx
movq %rcx, 0x30(%rax)
leaq -0x798(%rbp), %rdi
callq 0x28f70
jmp 0x223b9
movq -0x8d0(%rbp), %rax
movb $0x1, 0x4a(%rax)
movl $0x48, %edi
callq 0x32e0
movq %rax, -0xa00(%rbp)
jmp 0x22254
leaq -0x48(%rbp), %rdi
callq 0x7810
movq -0xa00(%rbp), %rdi
movl %eax, %edx
leaq -0x138(%rbp), %rsi
callq 0x2c4f0
jmp 0x22274
movq -0x8d0(%rbp), %rax
movq -0xa00(%rbp), %rcx
movq %rcx, 0x28(%rax)
leaq -0x48(%rbp), %rdi
callq 0x7810
movq -0x8d0(%rbp), %rdi
movl %eax, -0xa08(%rbp)
callq 0x237c0
movl %eax, -0xa04(%rbp)
jmp 0x222a9
movl -0xa04(%rbp), %edi
callq 0x178e0
movl %eax, -0xa0c(%rbp)
jmp 0x222bc
movl -0xa0c(%rbp), %edx
movl -0xa08(%rbp), %esi
leaq -0x7e0(%rbp), %rdi
callq 0x28e30
jmp 0x222d6
leaq -0x48(%rbp), %rdi
callq 0x7870
movq %rax, -0x7e8(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x78e0
movq %rax, -0x7f0(%rbp)
leaq -0x7e8(%rbp), %rdi
leaq -0x7f0(%rbp), %rsi
callq 0x78a0
testb $0x1, %al
jne 0x2230f
jmp 0x22386
leaq -0x7e8(%rbp), %rdi
callq 0x7910
movl (%rax), %esi
leaq -0x7e0(%rbp), %rdi
callq 0x179c0
jmp 0x2232b
jmp 0x2232d
leaq -0x7e8(%rbp), %rdi
callq 0x7930
jmp 0x222e6
movq -0xa00(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
movl $0x48, %esi
callq 0x32f0
jmp 0x22b47
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
leaq -0x7e0(%rbp), %rdi
callq 0x28f70
jmp 0x22b47
leaq -0x7e0(%rbp), %rdi
callq 0x28fb0
movq %rax, -0xa18(%rbp)
jmp 0x2239b
movq -0x8d0(%rbp), %rax
movq -0xa18(%rbp), %rcx
movq %rcx, 0x30(%rax)
leaq -0x7e0(%rbp), %rdi
callq 0x28f70
leaq -0x30(%rbp), %rdi
movq %rdi, -0xa20(%rbp)
callq 0x10ae0
movq -0xa20(%rbp), %rdi
movq %rax, -0x7f8(%rbp)
callq 0x10b50
movq %rax, -0x800(%rbp)
movq -0x7f8(%rbp), %rdi
movq -0x800(%rbp), %rsi
callq 0x17960
jmp 0x223f8
leaq -0x30(%rbp), %rdi
callq 0x18330
movl %eax, -0x804(%rbp)
movl $0x0, -0x808(%rbp)
movl $0x0, -0x80c(%rbp)
movl -0x808(%rbp), %eax
movq %rax, -0xa28(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x18330
movq %rax, %rcx
movq -0xa28(%rbp), %rax
cmpq %rcx, %rax
jae 0x224bc
jmp 0x22442
movl -0x80c(%rbp), %eax
movl %eax, -0xa2c(%rbp)
movl -0x808(%rbp), %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
callq 0x179a0
movq %rax, %rcx
movl -0xa2c(%rbp), %eax
cmpl (%rcx), %eax
jae 0x2248c
movl -0x804(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x804(%rbp)
movl -0x80c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x80c(%rbp)
jmp 0x22442
movl -0x808(%rbp), %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
callq 0x179a0
movl (%rax), %eax
addl $0x1, %eax
movl %eax, -0x80c(%rbp)
movl -0x808(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x808(%rbp)
jmp 0x2241b
movq -0x8d0(%rbp), %rdi
callq 0x7970
movl %eax, -0xa30(%rbp)
jmp 0x224d0
movl -0xa30(%rbp), %eax
decl %eax
movl %eax, -0xa44(%rbp)
leaq -0x818(%rbp), %rdi
movq %rdi, -0xa40(%rbp)
leaq -0x30(%rbp), %rsi
callq 0x23a90
movq -0xa40(%rbp), %rdi
callq 0x23ae0
movq %rax, -0xa38(%rbp)
jmp 0x2250a
movl -0xa44(%rbp), %ecx
movq -0xa38(%rbp), %rax
movl (%rax), %eax
subl %eax, %ecx
movl -0x804(%rbp), %eax
addl %ecx, %eax
movl %eax, -0x804(%rbp)
leaq -0x888(%rbp), %rdi
movl $0x20, %esi
movl $0x100000, %edx         # imm = 0x100000
callq 0x2cf20
jmp 0x22541
movq -0x8d0(%rbp), %rdi
movl -0x804(%rbp), %eax
movl %eax, -0xa4c(%rbp)
callq 0x237e0
movl %eax, -0xa48(%rbp)
jmp 0x22561
movl -0xa48(%rbp), %edi
callq 0x178e0
movl %eax, -0xa50(%rbp)
jmp 0x22574
movl -0xa50(%rbp), %edx
movl -0xa4c(%rbp), %esi
leaq -0x8b0(%rbp), %rdi
callq 0x28e30
jmp 0x2258e
movl $0x0, -0x8b4(%rbp)
movl $0x0, -0x8b8(%rbp)
movl $0x0, -0x8bc(%rbp)
movl -0x8b8(%rbp), %eax
movq %rax, -0xa58(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x18330
movq %rax, %rcx
movq -0xa58(%rbp), %rax
cmpq %rcx, %rax
jae 0x2273f
jmp 0x225d7
movl -0x8bc(%rbp), %eax
movl %eax, -0xa5c(%rbp)
movl -0x8b8(%rbp), %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
callq 0x179a0
movq %rax, %rcx
movl -0xa5c(%rbp), %eax
cmpl (%rcx), %eax
jae 0x22692
movl -0x8b4(%rbp), %esi
leaq -0x888(%rbp), %rdi
callq 0x2d0b0
jmp 0x22619
movq -0x8d0(%rbp), %rdi
callq 0x237e0
movl %eax, -0xa60(%rbp)
jmp 0x2262d
movl -0xa60(%rbp), %esi
leaq -0x8b0(%rbp), %rdi
callq 0x179c0
jmp 0x22641
movl -0x8b4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8b4(%rbp)
movl -0x8bc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8bc(%rbp)
jmp 0x225d7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
jmp 0x22b3b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
jmp 0x22b2f
cmpl $0x0, -0x8b8(%rbp)
je 0x226d7
movl -0x8b8(%rbp), %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
callq 0x179a0
movl (%rax), %eax
movl %eax, -0xa64(%rbp)
movl -0x8b8(%rbp), %eax
subl $0x1, %eax
movl %eax, %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
callq 0x179a0
movq %rax, %rcx
movl -0xa64(%rbp), %eax
cmpl (%rcx), %eax
je 0x226fa
movl -0x8b4(%rbp), %esi
leaq -0x888(%rbp), %rdi
callq 0x2d0b0
jmp 0x226eb
movl -0x8bc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8bc(%rbp)
movl -0x8b8(%rbp), %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
callq 0x179a0
movl 0x4(%rax), %esi
leaq -0x8b0(%rbp), %rdi
callq 0x179c0
jmp 0x2271c
movl -0x8b4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8b4(%rbp)
movl -0x8b8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8b8(%rbp)
jmp 0x225ac
leaq -0x8c8(%rbp), %rdi
movq %rdi, -0xa78(%rbp)
leaq -0x30(%rbp), %rsi
callq 0x23a90
movq -0xa78(%rbp), %rdi
callq 0x23ae0
movq %rax, -0xa70(%rbp)
jmp 0x2276b
movq -0xa70(%rbp), %rax
movl (%rax), %eax
addl $0x1, %eax
movl %eax, -0x8c0(%rbp)
movq -0x8d0(%rbp), %rdi
movl -0x8c0(%rbp), %eax
movl %eax, -0xa80(%rbp)
callq 0x7970
movl %eax, -0xa7c(%rbp)
jmp 0x2279d
movl -0xa80(%rbp), %eax
movl -0xa7c(%rbp), %ecx
cmpl %ecx, %eax
jae 0x2280c
movl -0x8b4(%rbp), %esi
leaq -0x888(%rbp), %rdi
callq 0x2d0b0
jmp 0x227c1
movq -0x8d0(%rbp), %rdi
callq 0x237e0
movl %eax, -0xa84(%rbp)
jmp 0x227d5
movl -0xa84(%rbp), %esi
leaq -0x8b0(%rbp), %rdi
callq 0x179c0
jmp 0x227e9
movl -0x8b4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8b4(%rbp)
movl -0x8c0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8c0(%rbp)
jmp 0x2277d
movl $0x48, %edi
callq 0x32e0
movq %rax, -0xa90(%rbp)
jmp 0x2281f
movq -0xa90(%rbp), %rdi
movl -0x804(%rbp), %edx
leaq -0x888(%rbp), %rsi
callq 0x2c4f0
jmp 0x2283a
movq -0x8d0(%rbp), %rax
movq -0xa90(%rbp), %rcx
movq %rcx, 0x38(%rax)
leaq -0x8b0(%rbp), %rdi
callq 0x28fb0
movq %rax, -0xa98(%rbp)
jmp 0x22861
movq -0x8d0(%rbp), %rax
movq -0xa98(%rbp), %rcx
movq %rcx, 0x40(%rax)
testb $0x1, -0x11(%rbp)
je 0x22ab5
movl -0x13c(%rbp), %esi
movq 0x23746(%rip), %rdi     # 0x45fd0
callq 0x3420
movq %rax, -0xaa0(%rbp)
jmp 0x22898
movq -0xaa0(%rbp), %rdi
leaq 0x121d2(%rip), %rsi     # 0x34a78
callq 0x32c0
movq %rax, -0xaa8(%rbp)
jmp 0x228b4
movq -0xaa8(%rbp), %rdi
movl -0x144(%rbp), %esi
callq 0x3420
movq %rax, -0xab0(%rbp)
jmp 0x228cf
movq -0xab0(%rbp), %rdi
leaq 0x12133(%rip), %rsi     # 0x34a10
callq 0x32c0
movq %rax, -0xab8(%rbp)
jmp 0x228eb
movq -0xab8(%rbp), %rdi
movl -0x148(%rbp), %esi
callq 0x3420
movq %rax, -0xac0(%rbp)
jmp 0x22906
movq -0xac0(%rbp), %rdi
leaq 0x12105(%rip), %rsi     # 0x34a19
callq 0x32c0
movq %rax, -0xac8(%rbp)
jmp 0x22922
movq -0xac8(%rbp), %rdi
movl -0x14c(%rbp), %esi
callq 0x3420
movq %rax, -0xad0(%rbp)
jmp 0x2293d
movq -0xad0(%rbp), %rdi
leaq 0x120dd(%rip), %rsi     # 0x34a28
callq 0x32c0
movq %rax, -0xad8(%rbp)
jmp 0x22959
movq -0xad8(%rbp), %rdi
movl -0x150(%rbp), %esi
callq 0x3420
movq %rax, -0xae0(%rbp)
jmp 0x22974
movq -0xae0(%rbp), %rdi
leaq 0x120ff(%rip), %rsi     # 0x34a81
callq 0x32c0
movq %rax, -0xae8(%rbp)
jmp 0x22990
movq -0xae8(%rbp), %rdi
movl -0x5b4(%rbp), %esi
callq 0x3420
movq %rax, -0xaf0(%rbp)
jmp 0x229ab
movq -0xaf0(%rbp), %rdi
leaq 0x120d0(%rip), %rsi     # 0x34a89
callq 0x32c0
movq %rax, -0xaf8(%rbp)
jmp 0x229c7
movq -0xaf8(%rbp), %rdi
movl -0x804(%rbp), %esi
movl -0x148(%rbp), %eax
subl %eax, %esi
movl -0x5b4(%rbp), %eax
subl %eax, %esi
callq 0x3420
movq %rax, -0xb00(%rbp)
jmp 0x229f2
movq -0xb00(%rbp), %rdi
leaq 0x12097(%rip), %rsi     # 0x34a97
callq 0x32c0
movq %rax, -0xb08(%rbp)
jmp 0x22a0e
movq -0xb08(%rbp), %rdi
movq 0x23594(%rip), %rsi     # 0x45fb0
callq 0x3330
jmp 0x22a23
movq -0x8d0(%rbp), %rdi
callq 0x23b20
movb %al, -0xb09(%rbp)
jmp 0x22a37
movb -0xb09(%rbp), %al
testb $0x1, %al
jne 0x22a43
jmp 0x22a9e
movq 0x23586(%rip), %rdi     # 0x45fd0
leaq 0x12057(%rip), %rsi     # 0x34aa8
callq 0x32c0
movq %rax, -0xb18(%rbp)
jmp 0x22a5f
movq -0xb18(%rbp), %rdi
movq 0x23543(%rip), %rsi     # 0x45fb0
callq 0x3330
jmp 0x22a74
jmp 0x22a9e
movq -0xa90(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
movl $0x48, %esi
callq 0x32f0
jmp 0x22b2f
movq 0x2352b(%rip), %rdi     # 0x45fd0
movq 0x23504(%rip), %rsi     # 0x45fb0
callq 0x3330
jmp 0x22ab3
jmp 0x22ab5
movq -0x8d0(%rbp), %rax
movb $0x1, 0x49(%rax)
leaq -0x8b0(%rbp), %rdi
callq 0x28f70
leaq -0x888(%rbp), %rdi
callq 0x2cf50
leaq -0x770(%rbp), %rdi
callq 0x3638
leaq -0x750(%rbp), %rdi
callq 0x3638
leaq -0x730(%rbp), %rdi
callq 0x30d0
leaq -0x138(%rbp), %rdi
callq 0x2cf50
leaq -0xb8(%rbp), %rdi
callq 0x2cf50
leaq -0x48(%rbp), %rdi
callq 0x1c250
leaq -0x30(%rbp), %rdi
callq 0x17a00
addq $0xb20, %rsp            # imm = 0xB20
popq %rbp
retq
leaq -0x8b0(%rbp), %rdi
callq 0x28f70
leaq -0x888(%rbp), %rdi
callq 0x2cf50
leaq -0x770(%rbp), %rdi
callq 0x3638
leaq -0x750(%rbp), %rdi
callq 0x3638
leaq -0x730(%rbp), %rdi
callq 0x30d0
leaq -0x138(%rbp), %rdi
callq 0x2cf50
leaq -0xb8(%rbp), %rdi
callq 0x2cf50
leaq -0x48(%rbp), %rdi
callq 0x1c250
leaq -0x30(%rbp), %rdi
callq 0x17a00
movq -0xc0(%rbp), %rdi
callq 0x3570
nopw %cs:(%rax,%rax)