// File: /workspace/github_c_makefile_star2_O3/ukontainer[P]sqlite-bench/sqlite3.c
// Function: wherePathSolver
static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){
  int mxChoice;             /* Maximum number of simultaneous paths tracked */
  int nLoop;                /* Number of terms in the join */
  Parse *pParse;            /* Parsing context */
  sqlite3 *db;              /* The database connection */
  int iLoop;                /* Loop counter over the terms of the join */
  int ii, jj;               /* Loop counters */
  int mxI = 0;              /* Index of next entry to replace */
  int nOrderBy;             /* Number of ORDER BY clause terms */
  LogEst mxCost = 0;        /* Maximum cost of a set of paths */
  LogEst mxUnsorted = 0;    /* Maximum unsorted cost of a set of path */
  int nTo, nFrom;           /* Number of valid entries in aTo[] and aFrom[] */
  WherePath *aFrom;         /* All nFrom paths at the previous level */
  WherePath *aTo;           /* The nTo best paths at the current level */
  WherePath *pFrom;         /* An element of aFrom[] that we are working on */
  WherePath *pTo;           /* An element of aTo[] that we are working on */
  WhereLoop *pWLoop;        /* One of the WhereLoop objects */
  WhereLoop **pX;           /* Used to divy up the pSpace memory */
  LogEst *aSortCost = 0;    /* Sorting and partial sorting costs */
  char *pSpace;             /* Temporary memory used by this routine */
  int nSpace;               /* Bytes of space allocated at pSpace */

  pParse = pWInfo->pParse;
  db = pParse->db;
  nLoop = pWInfo->nLevel;
  /* TUNING: For simple queries, only the best path is tracked.
  ** For 2-way joins, the 5 best paths are followed.
  ** For joins of 3 or more tables, track the 10 best paths */
  mxChoice = (nLoop<=1) ? 1 : (nLoop==2 ? 5 : 10);
  assert( nLoop<=pWInfo->pTabList->nSrc );
  WHERETRACE(0x002, ("---- begin solver.  (nRowEst=%d)\n", nRowEst));

  /* If nRowEst is zero and there is an ORDER BY clause, ignore it. In this
  ** case the purpose of this call is to estimate the number of rows returned
  ** by the overall query. Once this estimate has been obtained, the caller
  ** will invoke this function a second time, passing the estimate as the
  ** nRowEst parameter.  */
  if( pWInfo->pOrderBy==0 || nRowEst==0 ){
    nOrderBy = 0;
  }else{
    nOrderBy = pWInfo->pOrderBy->nExpr;
  }

  /* Allocate and initialize space for aTo, aFrom and aSortCost[] */
  nSpace = (sizeof(WherePath)+sizeof(WhereLoop*)*nLoop)*mxChoice*2;
  nSpace += sizeof(LogEst) * nOrderBy;
  pSpace = sqlite3DbMallocRawNN(db, nSpace);
  if( pSpace==0 ) return SQLITE_NOMEM_BKPT;
  aTo = (WherePath*)pSpace;
  aFrom = aTo+mxChoice;
  memset(aFrom, 0, sizeof(aFrom[0]));
  pX = (WhereLoop**)(aFrom+mxChoice);
  for(ii=mxChoice*2, pFrom=aTo; ii>0; ii--, pFrom++, pX += nLoop){
    pFrom->aLoop = pX;
  }
  if( nOrderBy ){
    /* If there is an ORDER BY clause and it is not being ignored, set up
    ** space for the aSortCost[] array. Each element of the aSortCost array
    ** is either zero - meaning it has not yet been initialized - or the
    ** cost of sorting nRowEst rows of data where the first X terms of
    ** the ORDER BY clause are already in order, where X is the array 
    ** index.  */
    aSortCost = (LogEst*)pX;
    memset(aSortCost, 0, sizeof(LogEst) * nOrderBy);
  }
  assert( aSortCost==0 || &pSpace[nSpace]==(char*)&aSortCost[nOrderBy] );
  assert( aSortCost!=0 || &pSpace[nSpace]==(char*)pX );

  /* Seed the search with a single WherePath containing zero WhereLoops.
  **
  ** TUNING: Do not let the number of iterations go above 28.  If the cost
  ** of computing an automatic index is not paid back within the first 28
  ** rows, then do not use the automatic index. */
  aFrom[0].nRow = MIN(pParse->nQueryLoop, 48);  assert( 48==sqlite3LogEst(28) );
  nFrom = 1;
  assert( aFrom[0].isOrdered==0 );
  if( nOrderBy ){
    /* If nLoop is zero, then there are no FROM terms in the query. Since
    ** in this case the query may return a maximum of one row, the results
    ** are already in the requested order. Set isOrdered to nOrderBy to
    ** indicate this. Or, if nLoop is greater than zero, set isOrdered to
    ** -1, indicating that the result set may or may not be ordered, 
    ** depending on the loops added to the current plan.  */
    aFrom[0].isOrdered = nLoop>0 ? -1 : nOrderBy;
  }

  /* Compute successively longer WherePaths using the previous generation
  ** of WherePaths as the basis for the next.  Keep track of the mxChoice
  ** best paths at each generation */
  for(iLoop=0; iLoop<nLoop; iLoop++){
    nTo = 0;
    for(ii=0, pFrom=aFrom; ii<nFrom; ii++, pFrom++){
      for(pWLoop=pWInfo->pLoops; pWLoop; pWLoop=pWLoop->pNextLoop){
        LogEst nOut;                      /* Rows visited by (pFrom+pWLoop) */
        LogEst rCost;                     /* Cost of path (pFrom+pWLoop) */
        LogEst rUnsorted;                 /* Unsorted cost of (pFrom+pWLoop) */
        i8 isOrdered = pFrom->isOrdered;  /* isOrdered for (pFrom+pWLoop) */
        Bitmask maskNew;                  /* Mask of src visited by (..) */
        Bitmask revMask = 0;              /* Mask of rev-order loops for (..) */

        if( (pWLoop->prereq & ~pFrom->maskLoop)!=0 ) continue;
        if( (pWLoop->maskSelf & pFrom->maskLoop)!=0 ) continue;
        if( (pWLoop->wsFlags & WHERE_AUTO_INDEX)!=0 && pFrom->nRow<3 ){
          /* Do not use an automatic index if the this loop is expected
          ** to run less than 1.25 times.  It is tempting to also exclude
          ** automatic index usage on an outer loop, but sometimes an automatic
          ** index is useful in the outer loop of a correlated subquery. */
          assert( 10==sqlite3LogEst(2) );
          continue;
        }

        /* At this point, pWLoop is a candidate to be the next loop. 
        ** Compute its cost */
        rUnsorted = sqlite3LogEstAdd(pWLoop->rSetup,pWLoop->rRun + pFrom->nRow);
        rUnsorted = sqlite3LogEstAdd(rUnsorted, pFrom->rUnsorted);
        nOut = pFrom->nRow + pWLoop->nOut;
        maskNew = pFrom->maskLoop | pWLoop->maskSelf;
        if( isOrdered<0 ){
          isOrdered = wherePathSatisfiesOrderBy(pWInfo,
                       pWInfo->pOrderBy, pFrom, pWInfo->wctrlFlags,
                       iLoop, pWLoop, &revMask);
        }else{
          revMask = pFrom->revLoop;
        }
        if( isOrdered>=0 && isOrdered<nOrderBy ){
          if( aSortCost[isOrdered]==0 ){
            aSortCost[isOrdered] = whereSortingCost(
                pWInfo, nRowEst, nOrderBy, isOrdered
            );
          }
          /* TUNING:  Add a small extra penalty (5) to sorting as an
          ** extra encouragment to the query planner to select a plan
          ** where the rows emerge in the correct order without any sorting
          ** required. */
          rCost = sqlite3LogEstAdd(rUnsorted, aSortCost[isOrdered]) + 5;

          WHERETRACE(0x002,
              ("---- sort cost=%-3d (%d/%d) increases cost %3d to %-3d\n",
               aSortCost[isOrdered], (nOrderBy-isOrdered), nOrderBy, 
               rUnsorted, rCost));
        }else{
          rCost = rUnsorted;
          rUnsorted -= 2;  /* TUNING:  Slight bias in favor of no-sort plans */
        }

        /* Check to see if pWLoop should be added to the set of
        ** mxChoice best-so-far paths.
        **
        ** First look for an existing path among best-so-far paths
        ** that covers the same set of loops and has the same isOrdered
        ** setting as the current path candidate.
        **
        ** The term "((pTo->isOrdered^isOrdered)&0x80)==0" is equivalent
        ** to (pTo->isOrdered==(-1))==(isOrdered==(-1))" for the range
        ** of legal values for isOrdered, -1..64.
        */
        for(jj=0, pTo=aTo; jj<nTo; jj++, pTo++){
          if( pTo->maskLoop==maskNew
           && ((pTo->isOrdered^isOrdered)&0x80)==0
          ){
            testcase( jj==nTo-1 );
            break;
          }
        }
        if( jj>=nTo ){
          /* None of the existing best-so-far paths match the candidate. */
          if( nTo>=mxChoice
           && (rCost>mxCost || (rCost==mxCost && rUnsorted>=mxUnsorted))
          ){
            /* The current candidate is no better than any of the mxChoice
            ** paths currently in the best-so-far buffer.  So discard
            ** this candidate as not viable. */
#ifdef WHERETRACE_ENABLED /* 0x4 */
            if( sqlite3WhereTrace&0x4 ){
              sqlite3DebugPrintf("Skip   %s cost=%-3d,%3d,%3d order=%c\n",
                  wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsorted,
                  isOrdered>=0 ? isOrdered+'0' : '?');
            }
#endif
            continue;
          }
          /* If we reach this points it means that the new candidate path
          ** needs to be added to the set of best-so-far paths. */
          if( nTo<mxChoice ){
            /* Increase the size of the aTo set by one */
            jj = nTo++;
          }else{
            /* New path replaces the prior worst to keep count below mxChoice */
            jj = mxI;
          }
          pTo = &aTo[jj];
#ifdef WHERETRACE_ENABLED /* 0x4 */
          if( sqlite3WhereTrace&0x4 ){
            sqlite3DebugPrintf("New    %s cost=%-3d,%3d,%3d order=%c\n",
                wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsorted,
                isOrdered>=0 ? isOrdered+'0' : '?');
          }
#endif
        }else{
          /* Control reaches here if best-so-far path pTo=aTo[jj] covers the
          ** same set of loops and has the same isOrdered setting as the
          ** candidate path.  Check to see if the candidate should replace
          ** pTo or if the candidate should be skipped.
          ** 
          ** The conditional is an expanded vector comparison equivalent to:
          **   (pTo->rCost,pTo->nRow,pTo->rUnsorted) <= (rCost,nOut,rUnsorted)
          */
          if( pTo->rCost<rCost 
           || (pTo->rCost==rCost
               && (pTo->nRow<nOut
                   || (pTo->nRow==nOut && pTo->rUnsorted<=rUnsorted)
                  )
              )
          ){
#ifdef WHERETRACE_ENABLED /* 0x4 */
            if( sqlite3WhereTrace&0x4 ){
              sqlite3DebugPrintf(
                  "Skip   %s cost=%-3d,%3d,%3d order=%c",
                  wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsorted,
                  isOrdered>=0 ? isOrdered+'0' : '?');
              sqlite3DebugPrintf("   vs %s cost=%-3d,%3d,%3d order=%c\n",
                  wherePathName(pTo, iLoop+1, 0), pTo->rCost, pTo->nRow,
                  pTo->rUnsorted, pTo->isOrdered>=0 ? pTo->isOrdered+'0' : '?');
            }
#endif
            /* Discard the candidate path from further consideration */
            testcase( pTo->rCost==rCost );
            continue;
          }
          testcase( pTo->rCost==rCost+1 );
          /* Control reaches here if the candidate path is better than the
          ** pTo path.  Replace pTo with the candidate. */
#ifdef WHERETRACE_ENABLED /* 0x4 */
          if( sqlite3WhereTrace&0x4 ){
            sqlite3DebugPrintf(
                "Update %s cost=%-3d,%3d,%3d order=%c",
                wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsorted,
                isOrdered>=0 ? isOrdered+'0' : '?');
            sqlite3DebugPrintf("  was %s cost=%-3d,%3d,%3d order=%c\n",
                wherePathName(pTo, iLoop+1, 0), pTo->rCost, pTo->nRow,
                pTo->rUnsorted, pTo->isOrdered>=0 ? pTo->isOrdered+'0' : '?');
          }
#endif
        }
        /* pWLoop is a winner.  Add it to the set of best so far */
        pTo->maskLoop = pFrom->maskLoop | pWLoop->maskSelf;
        pTo->revLoop = revMask;
        pTo->nRow = nOut;
        pTo->rCost = rCost;
        pTo->rUnsorted = rUnsorted;
        pTo->isOrdered = isOrdered;
        memcpy(pTo->aLoop, pFrom->aLoop, sizeof(WhereLoop*)*iLoop);
        pTo->aLoop[iLoop] = pWLoop;
        if( nTo>=mxChoice ){
          mxI = 0;
          mxCost = aTo[0].rCost;
          mxUnsorted = aTo[0].nRow;
          for(jj=1, pTo=&aTo[1]; jj<mxChoice; jj++, pTo++){
            if( pTo->rCost>mxCost 
             || (pTo->rCost==mxCost && pTo->rUnsorted>mxUnsorted) 
            ){
              mxCost = pTo->rCost;
              mxUnsorted = pTo->rUnsorted;
              mxI = jj;
            }
          }
        }
      }
    }

#ifdef WHERETRACE_ENABLED  /* >=2 */
    if( sqlite3WhereTrace & 0x02 ){
      sqlite3DebugPrintf("---- after round %d ----\n", iLoop);
      for(ii=0, pTo=aTo; ii<nTo; ii++, pTo++){
        sqlite3DebugPrintf(" %s cost=%-3d nrow=%-3d order=%c",
           wherePathName(pTo, iLoop+1, 0), pTo->rCost, pTo->nRow,
           pTo->isOrdered>=0 ? (pTo->isOrdered+'0') : '?');
        if( pTo->isOrdered>0 ){
          sqlite3DebugPrintf(" rev=0x%llx\n", pTo->revLoop);
        }else{
          sqlite3DebugPrintf("\n");
        }
      }
    }
#endif

    /* Swap the roles of aFrom and aTo for the next generation */
    pFrom = aTo;
    aTo = aFrom;
    aFrom = pFrom;
    nFrom = nTo;
  }

  if( nFrom==0 ){
    sqlite3ErrorMsg(pParse, "no query solution");
    sqlite3DbFreeNN(db, pSpace);
    return SQLITE_ERROR;
  }
  
  /* Find the lowest cost path.  pFrom will be left pointing to that path */
  pFrom = aFrom;
  for(ii=1; ii<nFrom; ii++){
    if( pFrom->rCost>aFrom[ii].rCost ) pFrom = &aFrom[ii];
  }
  assert( pWInfo->nLevel==nLoop );
  /* Load the lowest cost path into pWInfo */
  for(iLoop=0; iLoop<nLoop; iLoop++){
    WhereLevel *pLevel = pWInfo->a + iLoop;
    pLevel->pWLoop = pWLoop = pFrom->aLoop[iLoop];
    pLevel->iFrom = pWLoop->iTab;
    pLevel->iTabCur = pWInfo->pTabList->a[pLevel->iFrom].iCursor;
  }
  if( (pWInfo->wctrlFlags & WHERE_WANT_DISTINCT)!=0
   && (pWInfo->wctrlFlags & WHERE_DISTINCTBY)==0
   && pWInfo->eDistinct==WHERE_DISTINCT_NOOP
   && nRowEst
  ){
    Bitmask notUsed;
    int rc = wherePathSatisfiesOrderBy(pWInfo, pWInfo->pResultSet, pFrom,
                 WHERE_DISTINCTBY, nLoop-1, pFrom->aLoop[nLoop-1], &notUsed);
    if( rc==pWInfo->pResultSet->nExpr ){
      pWInfo->eDistinct = WHERE_DISTINCT_ORDERED;
    }
  }
  pWInfo->bOrderedInnerLoop = 0;
  if( pWInfo->pOrderBy ){
    if( pWInfo->wctrlFlags & WHERE_DISTINCTBY ){
      if( pFrom->isOrdered==pWInfo->pOrderBy->nExpr ){
        pWInfo->eDistinct = WHERE_DISTINCT_ORDERED;
      }
    }else{
      pWInfo->nOBSat = pFrom->isOrdered;
      pWInfo->revMask = pFrom->revLoop;
      if( pWInfo->nOBSat<=0 ){
        pWInfo->nOBSat = 0;
        if( nLoop>0 ){
          u32 wsFlags = pFrom->aLoop[nLoop-1]->wsFlags;
          if( (wsFlags & WHERE_ONEROW)==0 
           && (wsFlags&(WHERE_IPK|WHERE_COLUMN_IN))!=(WHERE_IPK|WHERE_COLUMN_IN)
          ){
            Bitmask m = 0;
            int rc = wherePathSatisfiesOrderBy(pWInfo, pWInfo->pOrderBy, pFrom,
                      WHERE_ORDERBY_LIMIT, nLoop-1, pFrom->aLoop[nLoop-1], &m);
            testcase( wsFlags & WHERE_IPK );
            testcase( wsFlags & WHERE_COLUMN_IN );
            if( rc==pWInfo->pOrderBy->nExpr ){
              pWInfo->bOrderedInnerLoop = 1;
              pWInfo->revMask = m;
            }
          }
        }
      }
    }
    if( (pWInfo->wctrlFlags & WHERE_SORTBYGROUP)
        && pWInfo->nOBSat==pWInfo->pOrderBy->nExpr && nLoop>0
    ){
      Bitmask revMask = 0;
      int nOrder = wherePathSatisfiesOrderBy(pWInfo, pWInfo->pOrderBy, 
          pFrom, 0, nLoop-1, pFrom->aLoop[nLoop-1], &revMask
      );
      assert( pWInfo->sorted==0 );
      if( nOrder==pWInfo->pOrderBy->nExpr ){
        pWInfo->sorted = 1;
        pWInfo->revMask = revMask;
      }
    }
  }


  pWInfo->nRowOut = pFrom->nRow;

  /* Free temporary memory and return success */
  sqlite3DbFreeNN(db, pSpace);
  return SQLITE_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rdi, %r13
movq (%rdi), %rcx
movq 0x10(%rdi), %rax
movq %rcx, 0x70(%rsp)
movq (%rcx), %rdi
movzbl 0x42(%r13), %r12d
xorl %ecx, %ecx
cmpl $0x2, %r12d
setne %cl
leal 0x5(%rcx,%rcx,4), %ecx
movl $0x1, %r14d
cmovael %ecx, %r14d
testq %rax, %rax
sete %cl
movq %rsi, 0x48(%rsp)
testw %si, %si
sete %dl
xorl %ebp, %ebp
orb %cl, %dl
jne 0x462347
movl (%rax), %ebp
leal 0x20(,%r12,8), %eax
leal (%r14,%r14), %ebx
imull %ebx, %eax
movslq %ebp, %r15
addq %r15, %r15
addl %r15d, %eax
movslq %eax, %rsi
movq %rdi, 0x40(%rsp)
callq 0x415fb1
testq %rax, %rax
je 0x462410
movl %ebp, 0x28(%rsp)
movl %r14d, %edi
shll $0x5, %edi
leaq (%rax,%rdi), %rcx
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rax,%rdi)
movups %xmm0, (%rax,%rdi)
movq %rcx, %rbp
addq %rcx, %rdi
incl %ebx
movq %rax, %rcx
leal (,%r12,8), %eax
movq %rcx, 0xa0(%rsp)
addq $0x18, %rcx
movq %r14, %rsi
movq %rdi, (%rcx)
decl %ebx
addq %rax, %rdi
addq $0x20, %rcx
cmpl $0x1, %ebx
ja 0x4623b1
movl 0x28(%rsp), %r14d
testl %r14d, %r14d
movq %rsi, 0x68(%rsp)
je 0x462422
xorl %ebx, %ebx
movq %rdi, 0x50(%rsp)
xorl %esi, %esi
movq %r15, %rdx
callq 0x4010b8
movq 0x68(%rsp), %rsi
movq 0x70(%rsp), %rax
movl 0xb4(%rax), %ecx
cmpl $0x30, %ecx
movl $0x30, %eax
cmovbl %ecx, %eax
movq %r12, %rcx
negq %rcx
sbbl %ebx, %ebx
orb %r14b, %bl
movq %rbp, %rdx
movb %bl, 0x16(%rbp)
jmp 0x462444
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x70(%rsp), %rax
movl 0xb4(%rax), %ecx
cmpl $0x30, %ecx
movl $0x30, %eax
cmovbl %ecx, %eax
movq $0x0, 0x50(%rsp)
movq %rbp, %rdx
movq 0x40(%rsp), %rdi
movw %ax, 0x10(%rdx)
testq %r12, %r12
je 0x46294f
cmpl $0x3, %esi
movl $0x2, %edi
cmovael %esi, %edi
movq 0x48(%rsp), %rax
addl $-0x32, %eax
movl %eax, 0x90(%rsp)
movl $0x1, %r10d
movq $0x0, 0x58(%rsp)
movl $0x0, 0x10(%rsp)
xorl %r9d, %r9d
xorl %r8d, %r8d
movq 0xa0(%rsp), %rax
movq %r13, 0x60(%rsp)
movq %r12, 0xa8(%rsp)
movl %edi, 0x94(%rsp)
testl %r10d, %r10d
movq %rax, 0x30(%rsp)
jg 0x4624bb
xorl %r11d, %r11d
jmp 0x46287d
movl %r10d, 0x9c(%rsp)
movq 0x58(%rsp), %rcx
leaq (,%rcx,8), %rsi
movq %rsi, 0xc0(%rsp)
addq $0x34, %rax
movq %rax, 0xb8(%rsp)
movl $0x0, 0x3c(%rsp)
movzwl %cx, %eax
movl %eax, 0x98(%rsp)
xorl %r11d, %r11d
movq %rdx, %r12
movq %rdx, 0x18(%rsp)
movq 0x50(%r13), %r13
testq %r13, %r13
je 0x46285d
movb 0x16(%r12), %r15b
movq $0x0, 0x20(%rsp)
movq (%r12), %rbp
movq %rbp, %rax
notq %rax
testq %rax, (%r13)
jne 0x462830
movq 0x8(%r13), %rbx
testq %rbp, %rbx
jne 0x462830
testb $0x40, 0x29(%r13)
movzwl 0x10(%r12), %r14d
je 0x462555
cmpw $0x3, %r14w
jl 0x462830
movl %r11d, 0x2c(%rsp)
movq %r9, 0x78(%rsp)
movq %r8, 0x80(%rsp)
movswl 0x12(%r13), %edi
movzwl 0x14(%r13), %eax
addw %r14w, %ax
movswl %ax, %esi
callq 0x4618c3
movswl 0x14(%r12), %esi
movswl %ax, %edi
callq 0x4618c3
movl %eax, %edi
addw 0x16(%r13), %r14w
testb %r15b, %r15b
js 0x4625a3
movq 0x8(%r12), %rax
movq %rax, 0x20(%rsp)
jmp 0x4625d5
movl %edi, %r15d
movq 0x60(%rsp), %rdi
movq 0x10(%rdi), %rsi
movzwl 0x40(%rdi), %ecx
leaq 0x20(%rsp), %rax
movq %rax, (%rsp)
movq %r12, %rdx
movl 0x98(%rsp), %r8d
movq %r13, %r9
callq 0x46a957
movl %r15d, %edi
movl %eax, %r15d
movl 0x2c(%rsp), %r11d
movsbl %r15b, %eax
testb %al, %al
sets %dl
movl 0x28(%rsp), %ecx
subl %eax, %ecx
setle %al
orb %dl, %al
movq 0x68(%rsp), %rsi
movq 0x80(%rsp), %r8
movq 0x78(%rsp), %r9
jne 0x462663
movzbl %r15b, %edx
movq 0x50(%rsp), %rax
movzwl (%rax,%rdx,2), %eax
testw %ax, %ax
jne 0x4626a1
movq %rdx, 0xb0(%rsp)
movl %edi, 0x14(%rsp)
imull $0x64, %ecx, %eax
cltd
idivl 0x28(%rsp)
movslq %eax, %rdi
callq 0x4309c4
movl %eax, %esi
movq 0x60(%rsp), %rax
testb $0x40, 0x41(%rax)
movq 0x48(%rsp), %rax
je 0x462659
movq 0x60(%rsp), %rax
movl 0x28(%rax), %eax
movq 0x48(%rsp), %rcx
cmpw %cx, %ax
cmovgel %ecx, %eax
cmpw $0xb, %ax
jge 0x46266a
xorl %eax, %eax
jmp 0x462683
movl %edi, %eax
addl $-0x2, %edi
jmp 0x4626d9
movzwl %ax, %edi
movl %esi, 0x8c(%rsp)
callq 0x4309c4
movl 0x8c(%rsp), %esi
addl $-0x21, %eax
movq 0x50(%rsp), %rcx
movl 0x14(%rsp), %edi
movq 0xb0(%rsp), %rdx
addl 0x90(%rsp), %eax
addl %esi, %eax
movw %ax, (%rcx,%rdx,2)
movw %r14w, 0x14(%rsp)
movl %edi, %r14d
movswl %r14w, %edi
movswl %ax, %esi
callq 0x4618c3
movl %r14d, %edi
movzwl 0x14(%rsp), %r14d
addl $0x5, %eax
movq 0x68(%rsp), %rsi
movq 0x80(%rsp), %r8
movq 0x78(%rsp), %r9
movl 0x2c(%rsp), %r11d
testl %r11d, %r11d
jle 0x462703
orq %rbp, %rbx
movl %r11d, %ecx
movq 0x30(%rsp), %rbp
cmpq %rbx, (%rbp)
jne 0x4626fb
movb 0x16(%rbp), %dl
xorb %r15b, %dl
jns 0x462825
addq $0x20, %rbp
decl %ecx
jne 0x4626e9
movl %r11d, %ecx
cmpl %esi, %r11d
jge 0x462792
xorl %edx, %edx
cmpl %esi, %r11d
setl %dl
addl %edx, %r11d
movslq %ecx, %rbp
shlq $0x5, %rbp
addq 0x30(%rsp), %rbp
movq 0x8(%r13), %rcx
orq (%r12), %rcx
movq %rcx, (%rbp)
movq 0x20(%rsp), %rcx
movq %rcx, 0x8(%rbp)
movw %r14w, 0x10(%rbp)
movw %ax, 0x12(%rbp)
movw %di, 0x14(%rbp)
movb %r15b, 0x16(%rbp)
movq 0x18(%rbp), %rdi
movq 0x18(%r12), %rsi
movq 0xc0(%rsp), %rdx
movl %r11d, %ebx
callq 0x401048
movl %ebx, %r11d
movq 0x18(%rbp), %rax
movq 0x58(%rsp), %rcx
movq %r13, (%rax,%rcx,8)
cmpl 0x68(%rsp), %ebx
jge 0x4627b5
movq 0x18(%rsp), %rdx
movq 0x80(%rsp), %r8
movq 0x78(%rsp), %r9
jmp 0x462830
cmpw %r9w, %ax
jg 0x46282b
movl 0x10(%rsp), %ecx
jne 0x46270f
movl 0x10(%rsp), %ecx
cmpw %r8w, %di
jge 0x46282b
jmp 0x46270f
movl $0x0, 0x10(%rsp)
movq 0x30(%rsp), %rax
movzwl 0x10(%rax), %r8d
movzwl 0x12(%rax), %r9d
cmpb $0x2, 0xa8(%rsp)
movl 0x94(%rsp), %edi
jb 0x46282b
movl $0x0, 0x10(%rsp)
movl $0x1, %eax
movq 0xb8(%rsp), %rcx
movzwl -0x2(%rcx), %edx
cmpw %r9w, %dx
jle 0x462809
movzwl (%rcx), %r8d
movl %edx, %r9d
movl %eax, 0x10(%rsp)
jmp 0x462819
jne 0x462819
movzwl (%rcx), %esi
cmpw %r8w, %si
jle 0x462819
movl %esi, %r8d
jmp 0x462800
incl %eax
addq $0x20, %rcx
cmpl %eax, %edi
jne 0x4627f2
jmp 0x46282b
cmpw %ax, 0x12(%rbp)
jge 0x462839
movq 0x18(%rsp), %rdx
movq 0x40(%r13), %r13
jmp 0x462505
jne 0x462726
cmpw %r14w, 0x10(%rbp)
movq 0x18(%rsp), %rdx
jl 0x462830
jne 0x462726
cmpw %di, 0x14(%rbp)
jg 0x462726
jmp 0x46282b
movl 0x3c(%rsp), %eax
incl %eax
addq $0x20, %r12
movl %eax, 0x3c(%rsp)
cmpl 0x9c(%rsp), %eax
movq 0x60(%rsp), %r13
jne 0x462501
movq 0x58(%rsp), %rsi
incq %rsi
movq %rdx, %rax
movq 0x30(%rsp), %rdx
movl %r11d, %r10d
movq 0xa8(%rsp), %r12
movq %rsi, 0x58(%rsp)
cmpq %r12, %rsi
jne 0x4624a9
testl %r11d, %r11d
je 0x4628e3
cmpl $0x2, %r11d
movq 0x40(%rsp), %rdi
jl 0x462900
movl %r11d, %eax
movq 0x30(%rsp), %rsi
leaq 0x20(%rsi), %rcx
decq %rax
movzwl 0x12(%rsi), %edx
movq %rcx, %r9
cmpw 0x12(%rcx), %dx
jg 0x4628d5
movq %rsi, %r9
addq $0x20, %rcx
movq %r9, %rsi
decq %rax
jne 0x4628c5
jmp 0x462905
leaq 0xf0ad5(%rip), %rsi     # 0x5533bf
movq 0x70(%rsp), %rdi
xorl %eax, %eax
callq 0x40e48a
movq 0x40(%rsp), %rdi
jmp 0x462a68
movq 0x30(%rsp), %r9
testq %r12, %r12
je 0x46294c
movq 0x18(%r9), %rax
movq 0x8(%r13), %rcx
addq $0x8, %rcx
movl %r12d, %edx
leaq 0x3e0(%r13), %rsi
xorl %r10d, %r10d
movq (%rax,%r10,8), %r8
movq %r8, (%rsi)
movzbl 0x10(%r8), %r8d
movb %r8b, -0x1c(%rsi)
imulq $0x70, %r8, %r8
movl 0x40(%rcx,%r8), %r8d
movl %r8d, -0x44(%rsi)
incq %r10
addq $0x58, %rsi
cmpq %r10, %rdx
jne 0x462923
movq %r9, %rdx
movzwl 0x40(%r13), %eax
andl $0x180, %eax            # imm = 0x180
cmpl $0x100, %eax            # imm = 0x100
jne 0x4629b7
cmpw $0x0, 0x48(%rsp)
je 0x4629b7
cmpb $0x0, 0x47(%r13)
jne 0x4629b7
movq %rdi, %r14
movq 0x18(%r13), %rsi
leaq -0x1(%r12), %rax
movq 0x18(%rdx), %rcx
movq -0x8(%rcx,%r12,8), %r9
leaq 0x20(%rsp), %rcx
movq %rcx, (%rsp)
movzwl %ax, %r8d
movq %r13, %rdi
movq %rdx, %rbx
movl $0x80, %ecx
callq 0x46a957
movsbl %al, %eax
movq 0x18(%r13), %rcx
cmpl %eax, (%rcx)
jne 0x4629b1
movb $0x2, 0x47(%r13)
movq %rbx, %rdx
movq %r14, %rdi
movb $0x0, 0x48(%r13)
movq 0x10(%r13), %rsi
testq %rsi, %rsi
je 0x462a5f
movzwl 0x40(%r13), %eax
movb 0x16(%rdx), %cl
testb %al, %al
js 0x4629f1
movb %cl, 0x43(%r13)
movq %rdx, %rbx
movq 0x8(%rdx), %rdx
movq %rdx, 0x58(%r13)
testb %cl, %cl
jle 0x462a86
movq %rbx, %rdx
jmp 0x4629fd
movsbl %cl, %ecx
cmpl %ecx, (%rsi)
jne 0x4629fd
movb $0x2, 0x47(%r13)
btl $0x9, %eax
jae 0x462a5f
testq %r12, %r12
je 0x462a5f
movsbl 0x43(%r13), %eax
cmpl %eax, (%rsi)
jne 0x462a5f
movq %rdi, %r14
leaq 0x20(%rsp), %rax
movq $0x0, (%rax)
decl %r12d
movq 0x18(%rdx), %rcx
movq (%rcx,%r12,8), %r9
movq %rax, (%rsp)
movzwl %r12w, %r8d
movq %r13, %rdi
movq %rdx, %rbx
xorl %ecx, %ecx
callq 0x46a957
movsbl %al, %eax
movq 0x10(%r13), %rcx
cmpl %eax, (%rcx)
jne 0x462a59
movb $0x1, 0x44(%r13)
movq 0x20(%rsp), %rax
movq %rax, 0x58(%r13)
movq %rbx, %rdx
movq %r14, %rdi
movzwl 0x10(%rdx), %eax
movw %ax, 0x60(%r13)
movq 0xa0(%rsp), %rsi
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x415f0a
movb $0x0, 0x43(%r13)
testq %r12, %r12
je 0x4629ec
movq %rbx, %rdx
movq 0x18(%rbx), %r8
leal -0x1(%r12), %ecx
movq (%r8,%rcx,8), %r9
movl 0x28(%r9), %r8d
movl %r8d, %r10d
shrl $0xc, %r10d
andl $0x1, %r10d
notl %r8d
testl $0x104, %r8d            # imm = 0x104
sete %r8b
orb %r10b, %r8b
jne 0x4629fd
movq %rdi, %r14
leaq 0x20(%rsp), %rax
movq $0x0, (%rax)
movq %rax, (%rsp)
movzwl %cx, %r8d
movq %r13, %rdi
movl $0x800, %ecx            # imm = 0x800
callq 0x46a957
movsbl %al, %eax
movq 0x10(%r13), %rsi
cmpl %eax, (%rsi)
jne 0x462b07
movb $0x1, 0x48(%r13)
movq 0x20(%rsp), %rax
movq %rax, 0x58(%r13)
movzwl 0x40(%r13), %eax
movq %rbx, %rdx
movq %r14, %rdi
jmp 0x4629fd