// File: /workspace/github_cpp_makefile_star2_O1/Ahhgust[P]STRaitRazor/trie.cpp
// Function: Trie::makeTrieFromConfig(std::vector<Config, std::allocator<Config>>*, unsigned int, unsigned char, unsigned char)
void
Trie::makeTrieFromConfig(vector<Config> *c, unsigned numStrs, unsigned char distance, unsigned char motifDistance) {
  unsigned i, nf, nr, memNeeded=0;

  if (distance >2) {
    cerr << "Sorry, the max anchor distance supported with trie-search is 2; " << distance   << " is too big!" << endl;
    exit(EXIT_FAILURE);
  } else if (motifDistance > 1) {
    cerr << "Sorry, the max motif distance supported with trie-search is 1; " << motifDistance   << " is too big!" << endl;
    exit(EXIT_FAILURE);
  }

  // make a table of IUPAC codes
  char IUPAC[255][2];
  memset(IUPAC, 0, 255+255);
  IUPAC[ (int)'R'][0] = 'A';
  IUPAC[ (int)'R'][1] = 'G';

  IUPAC[ (int)'Y'][0] = 'C';
  IUPAC[ (int)'Y'][1] = 'T';

  IUPAC[ (int)'S'][0] = 'G';
  IUPAC[ (int)'S'][1] = 'C';

  IUPAC[ (int)'W'][0] = 'A';
  IUPAC[ (int)'W'][1] = 'T';

  IUPAC[ (int)'K'][0] = 'G';
  IUPAC[ (int)'K'][1] = 'T';

  IUPAC[ (int)'M'][0] = 'A';
  IUPAC[ (int)'M'][1] = 'C';

  // compute an (upper-bound) on the number of nodes in the trie
  for (i=0; i < numStrs; ++i) {
    // math for the memory needed for a hamming distance of 1:
    // N = length of string + 1 (ie, including \0)
    // entering that string requires at most N nodes.
    // entering all the 1-base substitutions on that string requires
    // 3*N for all the substitutions on the 0th positoin
    // 3*(N-1) for all of the substutitions on the 1st position (previous position 0 is already in the trie)
    // 3*(N-2) for all of the subs on the second position (previous 2 positions are in the trie) 
    // ...
    // 3 
    // which is equal to:
    // N + 3N + (3(N)(N-1))/2
    //memNeeded += (2*c[i].forwardLength + 2) + (3* (c[i].reverseLength+2)* (c[i].reverseLength+3))/2;
    //memNeeded += (2*c[i].reverseLength + 2) + (3* (c[i].forwardLength+2)* (c[i].forwardLength+3))/2;

    // we have the forwardFlank twice (8N) (+ and - strand)
    // and again for the reverse flank
    nf = (8*((*c)[i].forwardLength+1)) + 3* ((*c)[i].forwardLength)*((*c)[i].forwardLength-1);
    nr = (8*((*c)[i].reverseLength+1)) + 3* ((*c)[i].reverseLength)*((*c)[i].reverseLength-1);


    const char *s = (*c)[i].forwardFlank.c_str();
    unsigned nfAmbig=0;
    for (unsigned j = 0; j < (*c)[i].forwardLength; ++j, ++s) { // adjust the memory for IUPAC codes (double the memory for each IUPAC code)
      if ( IUPAC[(int)*s][0] != 0) {
        nf = nf + nf;
        ++nfAmbig;
      }
    }

    if (nfAmbig > 1) {
      cerr << endl << "At most 1 ambiguity code is supported per anchor." << endl 
           << "Problem with locus: " << (*c)[i].locusName << " Anchor " << (*c)[i].forwardFlank << endl << endl;
      exit(EXIT_FAILURE);
    }

    s = (*c)[i].reverseFlank.c_str();
    unsigned nrAmbig=0;
    for (unsigned j = 0; j < (*c)[i].reverseLength; ++j, ++s) { // adjust the memory for IUPAC codes (double the memory for each IUPAC code)
      if ( IUPAC[(int)*s][0] != 0) {
        nr = nr + nr;
        ++nrAmbig;
      }
    }



    if (nrAmbig > 1) {
      cerr << endl << "At most 1 ambiguity code is supported per anchor." << endl <<
        "Problem with locus: " << (*c)[i].locusName << " Anchor " << (*c)[i].reverseFlank << endl << endl;
      exit(EXIT_FAILURE);
    }
    
    if (distance == 0) {
      memNeeded += ((*c)[i].forwardLength+1)*(2*(nfAmbig+1)) + ((*c)[i].reverseLength+1)*(2*(nrAmbig+1));
    } else if (distance == 1) {
      memNeeded += nf + nr;
    } else if (distance == 2) {
      // got lazy with this one; wolfram alpha was used to simplify the sum:
      // sum i=1 to N (i)(i-1)
      // which is the (worst-case) memory needed to add a word of length N and all 2-permutations of it
      memNeeded += (nfAmbig*nfAmbig+1)*6*((*c)[i].forwardLength)*((*c)[i].forwardLength+1)*((*c)[i].forwardLength+2);
      memNeeded += (nrAmbig*nrAmbig+1)*6*((*c)[i].reverseLength)*((*c)[i].reverseLength+1)*((*c)[i].reverseLength-1);
    }

    memNeeded += ((*c)[i].motifLength+1) *2; // the motifs are also added
    if (motifDistance == 1) {
      memNeeded += (8*((*c)[i].motifLength+1)) + 3* ((*c)[i].motifLength)*((*c)[i].motifLength-1);
    }
  }

  initMem(memNeeded);

  for (i=0; i < numStrs; ++i) {

    int numAmbig=0;
    string s =  (*c)[i].forwardFlank;
    for (unsigned j= 0; j < (*c)[i].forwardLength; ++j) {
      if ( IUPAC[(int)s.at(j)][0] != 0) {

        int iupac = (int)s.at(j);

        s[j] = IUPAC[ iupac ][0]; // overwrite the ambiguity code with the first form, then add to trie
        addPermutations(s, (*c)[i].forwardLength, i, (unsigned char) FORWARDFLANK,
                        (unsigned char) FORWARDFLANK_RC, distance);
        
        
        s[j] = IUPAC[ iupac ][1]; // overwrite the ambiguity code with the second form, then add to trie
        addPermutations(s, (*c)[i].forwardLength, i, (unsigned char) FORWARDFLANK,
                        (unsigned char) FORWARDFLANK_RC, distance);
        
        ++numAmbig;
        break;
      }
    }
    
    if (numAmbig==0) {

      addPermutations((*c)[i].forwardFlank, (*c)[i].forwardLength, i, (unsigned char) FORWARDFLANK,
                      (unsigned char) FORWARDFLANK_RC, distance);
    }
    numAmbig=0;
    s =  (*c)[i].reverseFlank;
    for (unsigned j= 0; j < (*c)[i].reverseLength; ++j) {
      if ( IUPAC[(int)s.at(j)][0] != 0) {

        int iupac = (int)s.at(j);

        s[j] = IUPAC[ iupac ][0]; // overwrite the ambiguity code with the first form, then add to trie
        addPermutations(s, (*c)[i].reverseLength, i, (unsigned char) REVERSEFLANK, 
                        (unsigned char) REVERSEFLANK_RC, distance);
        
        s[j] = IUPAC[ iupac ][1]; // overwrite the ambiguity code with the second form, then add to trie
        addPermutations(s, (*c)[i].reverseLength, i, (unsigned char) REVERSEFLANK, 
                        (unsigned char) REVERSEFLANK_RC, distance);
        
        ++numAmbig;
        break;
      }
    }


    // and the reverse flank (and its RC)
    if (numAmbig==0)
      addPermutations((*c)[i].reverseFlank, (*c)[i].reverseLength, i, (unsigned char) REVERSEFLANK, 
                      (unsigned char) REVERSEFLANK_RC, distance);
    
    if (motifDistance==0) {
    // add the motif (no degeneracy in this)
      addWord((*c)[i].strMotif.c_str(), (*c)[i].motifLength, i, MOTIF);
      addWordRC((*c)[i].strMotif.c_str(), (*c)[i].motifLength, i, MOTIF_RC);
    } else {
      addPermutations((*c)[i].strMotif, (*c)[i].motifLength, i, (unsigned char) MOTIF, (unsigned char) MOTIF_RC, motifDistance);
    }
  } 
  
  //  cerr << memNeeded << " bytes asked for ; Mem unused: " << memNeeded - (mem-root) << endl;

  if (mem-root > (int) memNeeded) {
    cerr << "Error with the maths. Email the author (August) to fix this!" << endl;
    exit(1);
  }
  
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x348, %rsp            # imm = 0x348
movl %edx, 0x48(%rsp)
movq %rdi, 0x10(%rsp)
movl %ecx, 0x24(%rsp)
cmpb $0x3, %cl
jae 0xa9a6
movl %r8d, %r14d
movzbl %r14b, %eax
movl %eax, 0x4c(%rsp)
cmpb $0x2, %r14b
jae 0xa9c3
movq %rsi, %rbx
leaq 0x140(%rsp), %r13
xorl %r12d, %r12d
movl $0x1fe, %edx            # imm = 0x1FE
movq %r13, %rdi
xorl %esi, %esi
callq 0x3180
movl $0x43474741, 0xa4(%r13) # imm = 0x43474741
movw $0x5443, 0xb2(%r13)     # imm = 0x5443
movw $0x5441, 0xae(%r13)     # imm = 0x5441
movw $0x5447, 0x96(%r13)     # imm = 0x5447
movw $0x4341, 0x9a(%r13)     # imm = 0x4341
movl 0x48(%rsp), %ecx
movl %ecx, %eax
movq %rax, 0x58(%rsp)
movzbl 0x24(%rsp), %eax
movl %eax, 0xc(%rsp)
testl %ecx, %ecx
je 0xa350
movq (%rbx), %rbp
xorl %edx, %edx
xorl %r12d, %r12d
imulq $0xb8, %rdx, %rax
leaq (%rax,%rbp), %rcx
movq %rax, 0x50(%rsp)
movl 0xa0(%rbp,%rax), %edi
leal (%rdi,%rdi,2), %r8d
addl $0x5, %r8d
imull %edi, %r8d
addl $0x8, %r8d
testq %rdi, %rdi
movq %rcx, 0x18(%rsp)
je 0xa214
movq 0x40(%rcx), %r10
xorl %r11d, %r11d
xorl %r9d, %r9d
movsbq (%r10,%r11), %r15
xorl %ecx, %ecx
cmpb $0x0, 0x140(%rsp,%r15,2)
setne %cl
shll %cl, %r8d
addl %ecx, %r9d
incq %r11
cmpl %r11d, %edi
jne 0xa1f1
jmp 0xa217
xorl %r9d, %r9d
cmpl $0x1, %r9d
ja 0xa8c4
movq %r12, %rsi
movl %r14d, %eax
movq %rbp, %r13
movq 0x50(%rsp), %rcx
movl 0xa4(%rbp,%rcx), %r10d
leal (%r10,%r10,2), %r15d
addl $0x5, %r15d
imull %r10d, %r15d
addl $0x8, %r15d
testq %r10, %r10
je 0xa27f
movq 0x18(%rsp), %rcx
movq 0x60(%rcx), %rbp
xorl %r12d, %r12d
xorl %r11d, %r11d
movsbq (%rbp,%r12), %r14
xorl %ecx, %ecx
cmpb $0x0, 0x140(%rsp,%r14,2)
setne %cl
shll %cl, %r15d
addl %ecx, %r11d
incq %r12
cmpl %r12d, %r10d
jne 0xa25b
jmp 0xa282
xorl %r11d, %r11d
cmpl $0x1, %r11d
ja 0xa925
cmpb $0x1, 0x24(%rsp)
movl %eax, %r14d
movq %r13, %rbp
je 0xa2c5
cmpl $0x0, 0xc(%rsp)
jne 0xa2cd
incl %edi
leal 0x2(,%r9,2), %r8d
imull %edi, %r8d
incl %r10d
leal 0x2(,%r11,2), %ecx
imull %r10d, %ecx
addl %esi, %r8d
addl %ecx, %r8d
jmp 0xa319
addl %esi, %r8d
addl %r15d, %r8d
jmp 0xa319
leal -0x1(%r10), %ecx
imull %r9d, %r9d
leal (%r9,%r9,2), %r8d
leal 0x6(,%r8,2), %r8d
leal 0x1(%rdi), %r9d
imull %edi, %r9d
addl $0x2, %edi
imull %r9d, %edi
imull %r8d, %edi
addl %esi, %edi
imull %r11d, %r11d
leal (%r11,%r11,2), %r8d
leal 0x6(,%r8,2), %r9d
leal 0x1(%r10), %r8d
imull %r10d, %r8d
imull %ecx, %r8d
imull %r9d, %r8d
addl %edi, %r8d
movq 0x18(%rsp), %rax
movl 0xa8(%rax), %ecx
leal (%r8,%rcx,2), %r12d
addl $0x2, %r12d
cmpb $0x1, %r14b
jne 0xa342
leal (%rcx,%rcx,2), %esi
addl $0x5, %esi
imull %ecx, %esi
addl %esi, %r12d
addl $0x8, %r12d
incq %rdx
cmpq 0x58(%rsp), %rdx
jne 0xa1b6
movl %r12d, %eax
shlq $0x4, %rax
movq %r12, %r15
leaq (%rax,%rax,2), %r12
movq %r12, %rdi
callq 0x3030
movq %rax, %r13
movq 0x10(%rsp), %rax
movq %r13, 0x8(%rax)
movq %r15, 0x18(%rsp)
testl %r15d, %r15d
je 0xa389
movq %r13, %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0x3180
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
movl %ecx, 0x10(%rax)
movq %r13, (%rax)
cmpl $0x0, 0x48(%rsp)
je 0xa864
xorl %r12d, %r12d
movq (%rbx), %rax
imulq $0xb8, %r12, %r13
leaq 0x38(%rsp), %rcx
movq %rcx, 0x28(%rsp)
movq 0x40(%rax,%r13), %rsi
movq 0x48(%rax,%r13), %rdx
addq %rsi, %rdx
leaq 0x28(%rsp), %rdi
callq 0x9204
movq (%rbx), %rax
movl 0xa0(%rax,%r13), %eax
testq %rax, %rax
je 0xa412
movq 0x28(%rsp), %rcx
movq 0x30(%rsp), %rdx
xorl %r15d, %r15d
cmpq %r15, %rdx
jbe 0xa8a2
movsbq (%rcx,%r15), %rbp
movb 0x140(%rsp,%rbp,2), %sil
testb %sil, %sil
jne 0xa484
incq %r15
cmpl %r15d, %eax
jne 0xa3ef
movq (%rbx), %rax
leaq 0x110(%rsp), %rcx
movq %rcx, 0x100(%rsp)
movq 0x40(%rax,%r13), %rsi
movq 0x48(%rax,%r13), %rdx
addq %rsi, %rdx
leaq 0x100(%rsp), %rdi
callq 0x9204
movq (%rbx), %rax
movl 0xa0(%rax,%r13), %edx
movl 0xc(%rsp), %eax
movl %eax, (%rsp)
movq 0x10(%rsp), %rdi
leaq 0x100(%rsp), %rsi
movl %r12d, %ecx
xorl %r8d, %r8d
movl $0x1, %r9d
callq 0x9e1c
movq 0x100(%rsp), %rdi
leaq 0x110(%rsp), %rcx
jmp 0xa581
movb %sil, (%rcx,%r15)
leaq 0xb0(%rsp), %rax
movq %rax, 0xa0(%rsp)
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
addq %rsi, %rdx
leaq 0xa0(%rsp), %rdi
callq 0x9204
movq (%rbx), %rax
movl 0xa0(%rax,%r13), %edx
movl 0xc(%rsp), %eax
movl %eax, (%rsp)
movq 0x10(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
movl %r12d, %ecx
xorl %r8d, %r8d
movl $0x1, %r9d
callq 0x9e1c
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0xa507
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x32d0
movb 0x141(%rsp,%rbp,2), %al
movq 0x28(%rsp), %rcx
movb %al, (%rcx,%r15)
leaq 0x130(%rsp), %rax
movq %rax, 0x120(%rsp)
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
addq %rsi, %rdx
leaq 0x120(%rsp), %rdi
callq 0x9204
movq (%rbx), %rax
movl 0xa0(%rax,%r13), %edx
movl 0xc(%rsp), %eax
movl %eax, (%rsp)
movq 0x10(%rsp), %rdi
leaq 0x120(%rsp), %rsi
movl %r12d, %ecx
xorl %r8d, %r8d
movl $0x1, %r9d
callq 0x9e1c
movq 0x120(%rsp), %rdi
leaq 0x130(%rsp), %rcx
movq %rcx, %rax
cmpq %rcx, %rdi
je 0xa594
movq (%rax), %rsi
incq %rsi
callq 0x32d0
movq (%rbx), %rax
leaq (%rax,%r13), %rsi
addq $0x60, %rsi
leaq 0x28(%rsp), %rdi
callq 0x3170
movq (%rbx), %rax
movl 0xa4(%rax,%r13), %eax
testq %rax, %rax
je 0xa5e9
movq 0x28(%rsp), %rcx
movq 0x30(%rsp), %rdx
xorl %r15d, %r15d
cmpq %r15, %rdx
jbe 0xa8b3
movsbq (%rcx,%r15), %rbp
movb 0x140(%rsp,%rbp,2), %sil
testb %sil, %sil
jne 0xa65e
incq %r15
cmpl %r15d, %eax
jne 0xa5c6
movq (%rbx), %rax
leaq 0xd0(%rsp), %rcx
movq %rcx, 0xc0(%rsp)
movq 0x60(%rax,%r13), %rsi
movq 0x68(%rax,%r13), %rdx
addq %rsi, %rdx
leaq 0xc0(%rsp), %rdi
callq 0x9204
movq (%rbx), %rax
movl 0xa4(%rax,%r13), %edx
movl 0xc(%rsp), %eax
movl %eax, (%rsp)
movq 0x10(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
movl %r12d, %ecx
movl $0x3, %r8d
movl $0x2, %r9d
callq 0x9e1c
movq 0xc0(%rsp), %rdi
leaq 0xd0(%rsp), %rcx
jmp 0xa761
movb %sil, (%rcx,%r15)
leaq 0x90(%rsp), %rax
movq %rax, 0x80(%rsp)
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
addq %rsi, %rdx
leaq 0x80(%rsp), %rdi
callq 0x9204
movq (%rbx), %rax
movl 0xa4(%rax,%r13), %edx
movl 0xc(%rsp), %eax
movl %eax, (%rsp)
movq 0x10(%rsp), %rdi
leaq 0x80(%rsp), %rsi
movl %r12d, %ecx
movl $0x3, %r8d
movl $0x2, %r9d
callq 0x9e1c
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0xa6e4
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x32d0
movb 0x141(%rsp,%rbp,2), %al
movq 0x28(%rsp), %rcx
movb %al, (%rcx,%r15)
leaq 0xf0(%rsp), %rax
movq %rax, 0xe0(%rsp)
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
addq %rsi, %rdx
leaq 0xe0(%rsp), %rdi
callq 0x9204
movq (%rbx), %rax
movl 0xa4(%rax,%r13), %edx
movl 0xc(%rsp), %eax
movl %eax, (%rsp)
movq 0x10(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
movl %r12d, %ecx
movl $0x3, %r8d
movl $0x2, %r9d
callq 0x9e1c
movq 0xe0(%rsp), %rdi
leaq 0xf0(%rsp), %rcx
movq %rcx, %rax
cmpq %rcx, %rdi
je 0xa774
movq (%rax), %rsi
incq %rsi
callq 0x32d0
movq (%rbx), %rax
testb %r14b, %r14b
je 0xa7f1
leaq 0x70(%rsp), %rcx
movq %rcx, 0x60(%rsp)
movq 0x80(%rax,%r13), %rsi
movq 0x88(%rax,%r13), %rdx
addq %rsi, %rdx
leaq 0x60(%rsp), %rdi
callq 0x9204
movq (%rbx), %rax
movl 0xa8(%rax,%r13), %edx
movl 0x4c(%rsp), %eax
movl %eax, (%rsp)
movq 0x10(%rsp), %rdi
leaq 0x60(%rsp), %rsi
movl %r12d, %ecx
movl $0x4, %r8d
movl $0x5, %r9d
callq 0x9e1c
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0xa83a
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x32d0
jmp 0xa83a
movq 0x80(%rax,%r13), %rsi
movl 0xa8(%rax,%r13), %edx
movq 0x10(%rsp), %rdi
movl %r12d, %ecx
movl $0x4, %r8d
callq 0x9a98
movq (%rbx), %rax
movq 0x80(%rax,%r13), %rsi
movl 0xa8(%rax,%r13), %edx
movq 0x10(%rsp), %rdi
movl %r12d, %ecx
movl $0x5, %r8d
callq 0x9c18
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0xa856
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x32d0
incq %r12
cmpq 0x58(%rsp), %r12
jne 0xa3a7
movq 0x10(%rsp), %rcx
movq 0x8(%rcx), %rax
subq (%rcx), %rax
sarq $0x4, %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %rcx
movslq 0x18(%rsp), %rax
cmpq %rax, %rcx
jg 0xa9ee
addq $0x348, %rsp            # imm = 0x348
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1790(%rip), %rdi      # 0xc039
movq %r15, %rsi
xorl %eax, %eax
callq 0x33d0
leaq 0x177f(%rip), %rdi      # 0xc039
movq %r15, %rsi
xorl %eax, %eax
callq 0x33d0
movq 0x4725(%rip), %rdi      # 0xeff0
callq 0x3140
leaq 0x168b(%rip), %rsi      # 0xbf62
movq %rax, %rdi
callq 0x32a0
movq %rax, %rdi
callq 0x3140
leaq 0x16a6(%rip), %rsi      # 0xbf94
movq %rax, %rdi
callq 0x32a0
movq (%rbx), %rsi
movq 0x50(%rsp), %r14
addq %r14, %rsi
movq %rax, %rdi
callq 0x3270
leaq 0x1699(%rip), %rsi      # 0xbfa9
movq %rax, %rdi
callq 0x32a0
movq (%rbx), %rcx
leaq (%rcx,%r14), %rsi
addq $0x40, %rsi
jmp 0xa984
movq 0x46c4(%rip), %rdi      # 0xeff0
callq 0x3140
leaq 0x162a(%rip), %rsi      # 0xbf62
movq %rax, %rdi
callq 0x32a0
movq %rax, %rdi
callq 0x3140
leaq 0x1645(%rip), %rsi      # 0xbf94
movq %rax, %rdi
callq 0x32a0
movq (%rbx), %rsi
movq 0x50(%rsp), %r14
addq %r14, %rsi
movq %rax, %rdi
callq 0x3270
leaq 0x1638(%rip), %rsi      # 0xbfa9
movq %rax, %rdi
callq 0x32a0
movq (%rbx), %rcx
leaq (%rcx,%r14), %rsi
addq $0x60, %rsi
movq %rax, %rdi
callq 0x3270
movq %rax, %rdi
callq 0x3140
movq %rax, %rdi
callq 0x3140
movl $0x1, %edi
callq 0x3340
movq 0x4643(%rip), %rdi      # 0xeff0
leaq 0x1520(%rip), %rsi      # 0xbed4
callq 0x32a0
movzbl 0x24(%rsp), %esi
movq %rax, %rdi
jmp 0xa9dd
movq 0x4626(%rip), %rdi      # 0xeff0
leaq 0x1551(%rip), %rsi      # 0xbf22
callq 0x32a0
movq %rax, %rdi
movl 0x4c(%rsp), %esi
callq 0x33e0
leaq 0x152c(%rip), %rsi      # 0xbf15
movq %rax, %rdi
jmp 0xa9fc
movq 0x45fb(%rip), %rdi      # 0xeff0
leaq 0x15b6(%rip), %rsi      # 0xbfb2
callq 0x32a0
jmp 0xa994
movq %rax, %rbx
movq 0x120(%rsp), %rdi
leaq 0x130(%rsp), %rax
cmpq %rax, %rdi
je 0xab10
movq 0x130(%rsp), %rsi
jmp 0xaaff
movq %rax, %rbx
movq 0xe0(%rsp), %rdi
leaq 0xf0(%rsp), %rax
cmpq %rax, %rdi
je 0xab10
movq 0xf0(%rsp), %rsi
jmp 0xaaff
movq %rax, %rbx
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0xab10
movq 0xb0(%rsp), %rsi
jmp 0xaaff
movq %rax, %rbx
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0xab10
movq 0x90(%rsp), %rsi
jmp 0xaaff
movq %rax, %rbx
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0xab10
movq 0x70(%rsp), %rsi
jmp 0xaaff
jmp 0xab0d
jmp 0xab0d
movq %rax, %rbx
movq 0xc0(%rsp), %rdi
leaq 0xd0(%rsp), %rax
cmpq %rax, %rdi
je 0xab10
movq 0xd0(%rsp), %rsi
jmp 0xaaff
movq %rax, %rbx
movq 0x100(%rsp), %rdi
leaq 0x110(%rsp), %rax
cmpq %rax, %rdi
je 0xab10
movq 0x110(%rsp), %rsi
incq %rsi
callq 0x32d0
jmp 0xab10
jmp 0xab0d
jmp 0xab0d
movq %rax, %rbx
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0xab2c
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x32d0
movq %rbx, %rdi
callq 0x3480