// File: /workspace/github_c_makefile_star2_O1/skeeto[P]flappy/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 */
  LogEst rCost;             /* Cost of a path */
  LogEst nOut;              /* Number of outputs */
  LogEst mxCost = 0;        /* Maximum cost of a set of paths */
  LogEst mxOut = 0;         /* Maximum nOut value on the set of paths */
  LogEst rSortCost;         /* Cost to do a sort */
  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 */
  char *pSpace;             /* Temporary memory used by this routine */

  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\n"));

  /* Allocate and initialize space for aTo and aFrom */
  ii = (sizeof(WherePath)+sizeof(WhereLoop*)*nLoop)*mxChoice*2;
  pSpace = sqlite3DbMallocRaw(db, ii);
  if( pSpace==0 ) return SQLITE_NOMEM;
  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;
  }

  /* Seed the search with a single WherePath containing zero WhereLoops.
  **
  ** TUNING: Do not let the number of iterations go above 25.  If the cost
  ** of computing an automatic index is not paid back within the first 25
  ** rows, then do not use the automatic index. */
  aFrom[0].nRow = MIN(pParse->nQueryLoop, 46);  assert( 46==sqlite3LogEst(25) );
  nFrom = 1;

  /* Precompute the cost of sorting the final result set, if the caller
  ** to sqlite3WhereBegin() was concerned about sorting */
  rSortCost = 0;
  if( pWInfo->pOrderBy==0 || nRowEst==0 ){
    aFrom[0].isOrderedValid = 1;
  }else{
    /* TUNING: Estimated cost of sorting is 48*N*log2(N) where N is the
    ** number of output rows. The 48 is the expected size of a row to sort. 
    ** FIXME:  compute a better estimate of the 48 multiplier based on the
    ** result set expressions. */
    rSortCost = nRowEst + estLog(nRowEst);
    WHERETRACE(0x002,("---- sort cost=%-3d\n", rSortCost));
  }

  /* 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){
        Bitmask maskNew;
        Bitmask revMask = 0;
        u8 isOrderedValid = pFrom->isOrderedValid;
        u8 isOrdered = pFrom->isOrdered;
        if( (pWLoop->prereq & ~pFrom->maskLoop)!=0 ) continue;
        if( (pWLoop->maskSelf & pFrom->maskLoop)!=0 ) continue;
        /* At this point, pWLoop is a candidate to be the next loop. 
        ** Compute its cost */
        rCost = sqlite3LogEstAdd(pWLoop->rSetup,pWLoop->rRun + pFrom->nRow);
        rCost = sqlite3LogEstAdd(rCost, pFrom->rCost);
        nOut = pFrom->nRow + pWLoop->nOut;
        maskNew = pFrom->maskLoop | pWLoop->maskSelf;
        if( !isOrderedValid ){
          switch( wherePathSatisfiesOrderBy(pWInfo,
                       pWInfo->pOrderBy, pFrom, pWInfo->wctrlFlags,
                       iLoop, pWLoop, &revMask) ){
            case 1:  /* Yes.  pFrom+pWLoop does satisfy the ORDER BY clause */
              isOrdered = 1;
              isOrderedValid = 1;
              break;
            case 0:  /* No.  pFrom+pWLoop will require a separate sort */
              isOrdered = 0;
              isOrderedValid = 1;
              rCost = sqlite3LogEstAdd(rCost, rSortCost);
              break;
            default: /* Cannot tell yet.  Try again on the next iteration */
              break;
          }
        }else{
          revMask = pFrom->revLoop;
        }
        /* Check to see if pWLoop should be added to the mxChoice best so far */
        for(jj=0, pTo=aTo; jj<nTo; jj++, pTo++){
          if( pTo->maskLoop==maskNew
           && pTo->isOrderedValid==isOrderedValid
           && ((pTo->rCost<=rCost && pTo->nRow<=nOut) ||
                (pTo->rCost>=rCost && pTo->nRow>=nOut))
          ){
            testcase( jj==nTo-1 );
            break;
          }
        }
        if( jj>=nTo ){
          if( nTo>=mxChoice && rCost>=mxCost ){
#ifdef WHERETRACE_ENABLED /* 0x4 */
            if( sqlite3WhereTrace&0x4 ){
              sqlite3DebugPrintf("Skip   %s cost=%-3d,%3d order=%c\n",
                  wherePathName(pFrom, iLoop, pWLoop), rCost, nOut,
                  isOrderedValid ? (isOrdered ? 'Y' : 'N') : '?');
            }
#endif
            continue;
          }
          /* Add a new Path to the aTo[] set */
          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 order=%c\n",
                wherePathName(pFrom, iLoop, pWLoop), rCost, nOut,
                isOrderedValid ? (isOrdered ? 'Y' : 'N') : '?');
          }
#endif
        }else{
          if( pTo->rCost<=rCost && pTo->nRow<=nOut ){
#ifdef WHERETRACE_ENABLED /* 0x4 */
            if( sqlite3WhereTrace&0x4 ){
              sqlite3DebugPrintf(
                  "Skip   %s cost=%-3d,%3d order=%c",
                  wherePathName(pFrom, iLoop, pWLoop), rCost, nOut,
                  isOrderedValid ? (isOrdered ? 'Y' : 'N') : '?');
              sqlite3DebugPrintf("   vs %s cost=%-3d,%d order=%c\n",
                  wherePathName(pTo, iLoop+1, 0), pTo->rCost, pTo->nRow,
                  pTo->isOrderedValid ? (pTo->isOrdered ? 'Y' : 'N') : '?');
            }
#endif
            testcase( pTo->rCost==rCost );
            continue;
          }
          testcase( pTo->rCost==rCost+1 );
          /* A new and better score for a previously created equivalent path */
#ifdef WHERETRACE_ENABLED /* 0x4 */
          if( sqlite3WhereTrace&0x4 ){
            sqlite3DebugPrintf(
                "Update %s cost=%-3d,%3d order=%c",
                wherePathName(pFrom, iLoop, pWLoop), rCost, nOut,
                isOrderedValid ? (isOrdered ? 'Y' : 'N') : '?');
            sqlite3DebugPrintf("  was %s cost=%-3d,%3d order=%c\n",
                wherePathName(pTo, iLoop+1, 0), pTo->rCost, pTo->nRow,
                pTo->isOrderedValid ? (pTo->isOrdered ? 'Y' : 'N') : '?');
          }
#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->isOrderedValid = isOrderedValid;
        pTo->isOrdered = isOrdered;
        memcpy(pTo->aLoop, pFrom->aLoop, sizeof(WhereLoop*)*iLoop);
        pTo->aLoop[iLoop] = pWLoop;
        if( nTo>=mxChoice ){
          mxI = 0;
          mxCost = aTo[0].rCost;
          mxOut = aTo[0].nRow;
          for(jj=1, pTo=&aTo[1]; jj<mxChoice; jj++, pTo++){
            if( pTo->rCost>mxCost || (pTo->rCost==mxCost && pTo->nRow>mxOut) ){
              mxCost = pTo->rCost;
              mxOut = pTo->nRow;
              mxI = jj;
            }
          }
        }
      }
    }

#ifdef WHERETRACE_ENABLED  /* >=2 */
    if( sqlite3WhereTrace>=2 ){
      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->isOrderedValid ? (pTo->isOrdered ? 'Y' : 'N') : '?');
        if( pTo->isOrderedValid && pTo->isOrdered ){
          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");
    sqlite3DbFree(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==1 ) pWInfo->eDistinct = WHERE_DISTINCT_ORDERED;
  }
  if( pFrom->isOrdered ){
    if( pWInfo->wctrlFlags & WHERE_DISTINCTBY ){
      pWInfo->eDistinct = WHERE_DISTINCT_ORDERED;
    }else{
      pWInfo->bOBSat = 1;
      pWInfo->revMask = pFrom->revLoop;
    }
  }
  pWInfo->nRowOut = pFrom->nRow;

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movl %esi, %ebp
movq %rdi, %rbx
movq (%rdi), %rcx
movzbl 0x38(%rdi), %r12d
xorl %eax, %eax
cmpl $0x2, %r12d
setne %al
cmpl $0x1, %r12d
leal 0x5(%rax,%rax,4), %r13d
cmovel %r12d, %r13d
movq %rcx, 0x88(%rsp)
movq (%rcx), %r14
leal 0x20(,%r12,8), %esi
imull %r13d, %esi
addl %esi, %esi
movq %r14, %rdi
callq 0x11af4
testq %rax, %rax
je 0x599c9
movq %rax, %r15
movl %r13d, %eax
shll $0x5, %eax
leaq (%r15,%rax), %rdi
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%r15,%rax)
movups %xmm0, (%r15,%rax)
addq %rdi, %rax
leal 0x1(,%r13,2), %ecx
leal (,%r12,8), %edx
movq %r15, %rsi
addq $0x18, %rsi
movq %r13, %r8
movq %rax, (%rsi)
decl %ecx
addq %rdx, %rax
addq $0x20, %rsi
cmpl $0x1, %ecx
jg 0x59966
movq 0x88(%rsp), %rax
movl 0x1f8(%rax), %eax
cmpl $0x2e, %eax
movl $0x2e, %ecx
cmovbl %eax, %ecx
movw %cx, 0x10(%rdi)
testw %bp, %bp
movq %r8, 0x10(%rsp)
je 0x599db
cmpq $0x0, 0x10(%rbx)
je 0x599db
movq %rdi, %r13
movswq %bp, %rdi
callq 0x3530e
movq 0x10(%rsp), %r8
movq %r13, %rdi
leal -0x21(%rax), %edx
xorl %ecx, %ecx
cmpw $0x22, %ax
cmovgel %edx, %ecx
addl %ebp, %ecx
jmp 0x599e1
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb $0x1, 0x15(%rdi)
xorl %ecx, %ecx
movl %ebp, 0x2c(%rsp)
movq %r14, 0x60(%rsp)
movq %rbx, 0x48(%rsp)
movq %r12, 0x38(%rsp)
testq %r12, %r12
movq %r15, 0x58(%rsp)
je 0x59d9f
cmpl $0x3, %r8d
movl $0x2, %r9d
cmovael %r8d, %r9d
movq $0x0, 0x40(%rsp)
movswl %cx, %eax
movl %eax, 0x74(%rsp)
movl $0x1, %r8d
movq %rdi, %rsi
xorl %r10d, %r10d
xorl %r11d, %r11d
movl %r9d, 0x78(%rsp)
movq %r15, %rdi
testl %r8d, %r8d
movq %rsi, 0x90(%rsp)
jg 0x59a4b
xorl %ebp, %ebp
jmp 0x59d77
movq 0x40(%rsp), %rax
leaq (,%rax,8), %rcx
movq %rcx, 0xa0(%rsp)
leaq 0x30(%rdi), %rcx
movq %rcx, 0x98(%rsp)
xorl %ecx, %ecx
movzwl %ax, %eax
movl %eax, 0x80(%rsp)
movq %rsi, %r13
xorl %ebp, %ebp
movq %rdi, 0x18(%rsp)
movl %r8d, 0x7c(%rsp)
movl %ecx, 0x84(%rsp)
movq 0x48(%rsp), %rax
movq 0x20(%rax), %r15
testq %r15, %r15
je 0x59d5c
movq %r13, 0x68(%rsp)
movq $0x0, 0x50(%rsp)
movq (%r13), %rbx
movq %rbx, %rax
notq %rax
testq %rax, (%r15)
jne 0x59d02
movq 0x8(%r15), %r12
testq %rbx, %r12
jne 0x59d02
movl %ebp, 0x34(%rsp)
movl %r11d, 0xc(%rsp)
movq %r10, 0x20(%rsp)
movb 0x15(%r13), %r14b
movb 0x14(%r13), %al
movl %eax, 0x30(%rsp)
movswl 0x12(%r15), %edi
movzwl 0x10(%r13), %ebp
movzwl 0x14(%r15), %eax
addw %bp, %ax
movswl %ax, %esi
callq 0x5d44e
movswl 0x12(%r13), %esi
movswl %ax, %edi
callq 0x5d44e
movl %ebp, %r9d
movq %r13, %rdx
movl %eax, %r13d
addw 0x16(%r15), %r9w
testb %r14b, %r14b
je 0x59b45
movq 0x8(%rdx), %rax
movq %rax, 0x50(%rsp)
movq 0x18(%rsp), %rdi
movq 0x10(%rsp), %r8
movq 0x20(%rsp), %r10
movl 0x34(%rsp), %ebp
movl 0x30(%rsp), %r11d
jmp 0x59bb5
movw %r9w, 0xa(%rsp)
movq 0x48(%rsp), %rdi
movq 0x10(%rdi), %rsi
movzwl 0x32(%rdi), %ecx
leaq 0x50(%rsp), %rax
movq %rax, (%rsp)
movl 0x80(%rsp), %r8d
movq %r15, %r9
callq 0x5dbc7
testl %eax, %eax
movl 0x34(%rsp), %ebp
je 0x59b8a
cmpl $0x1, %eax
jne 0x59d11
movb $0x1, %r14b
movb $0x1, %r11b
jmp 0x59ba0
movswl %r13w, %edi
movl 0x74(%rsp), %esi
callq 0x5d44e
movl %eax, %r13d
movb $0x1, %r14b
xorl %r11d, %r11d
movq 0x18(%rsp), %rdi
movq 0x10(%rsp), %r8
movq 0x20(%rsp), %r10
movzwl 0xa(%rsp), %r9d
testl %ebp, %ebp
setg %al
jle 0x59c11
orq %rbx, %r12
movl %ebp, %ecx
negl %ecx
movl $0x1, %edx
movq %rdi, %rbx
cmpq %r12, (%rbx)
jne 0x59bfc
cmpb %r14b, 0x15(%rbx)
jne 0x59bfc
movzwl 0x12(%rbx), %esi
cmpw %r13w, %si
jg 0x59beb
cmpw %r9w, 0x10(%rbx)
jle 0x59d2e
cmpw %r13w, %si
jl 0x59bfc
cmpw %r9w, 0x10(%rbx)
jge 0x59d2e
addq $0x20, %rbx
cmpl %ebp, %edx
setl %al
leal (%rcx,%rdx), %esi
incl %esi
incl %edx
cmpl $0x1, %esi
jne 0x59bcb
cmpl %r8d, %ebp
jl 0x59c2b
cmpw %r10w, %r13w
jl 0x59c2b
movl 0xc(%rsp), %r11d
movq 0x68(%rsp), %r13
jmp 0x59d02
xorl %eax, %eax
cmpl %r8d, %ebp
setl %al
movl 0xc(%rsp), %ecx
cmovll %ebp, %ecx
addl %eax, %ebp
movslq %ecx, %rbx
shlq $0x5, %rbx
addq %rdi, %rbx
movq %r8, %r12
movq 0x8(%r15), %rax
movq 0x68(%rsp), %rcx
orq (%rcx), %rax
movq %rax, (%rbx)
movq 0x50(%rsp), %rax
movq %rax, 0x8(%rbx)
movw %r9w, 0x10(%rbx)
movw %r13w, 0x12(%rbx)
movq %rcx, %r13
movb %r14b, 0x15(%rbx)
movb %r11b, 0x14(%rbx)
movq 0x18(%rbx), %rdi
movq 0x18(%rcx), %rsi
movq 0xa0(%rsp), %rdx
callq 0x7230
movq 0x18(%rbx), %rax
movq 0x40(%rsp), %rcx
movq %r15, (%rax,%rcx,8)
cmpl %r12d, %ebp
jge 0x59cae
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %r10
movl 0xc(%rsp), %r11d
jmp 0x59d02
xorl %r11d, %r11d
movq 0x18(%rsp), %rdi
movzwl 0x12(%rdi), %r10d
cmpl $0x1, 0x38(%rsp)
movl 0x78(%rsp), %r9d
je 0x59d02
movzwl 0x10(%rdi), %eax
xorl %r11d, %r11d
movl $0x1, %ecx
movq 0x98(%rsp), %rdx
movzwl 0x2(%rdx), %esi
cmpw %r10w, %si
jle 0x59cf0
movzwl (%rdx), %eax
movl %ecx, %r11d
movl %esi, %r10d
jmp 0x59cf7
jne 0x59cf7
cmpw %ax, (%rdx)
jg 0x59ce5
incl %ecx
addq $0x20, %rdx
cmpl %ecx, %r9d
jne 0x59cdb
movq 0x38(%r15), %r15
testq %r15, %r15
jne 0x59aa5
jmp 0x59d5c
xorl %r14d, %r14d
movq 0x18(%rsp), %rdi
movq 0x10(%rsp), %r8
movq 0x20(%rsp), %r10
movzwl 0xa(%rsp), %r9d
jmp 0x59b3e
testb $0x1, %al
je 0x59c11
cmpw %r13w, 0x12(%rbx)
jle 0x59d47
movq 0x10(%rsp), %r12
jmp 0x59c49
cmpw %r9w, 0x10(%rbx)
movq 0x10(%rsp), %r12
jle 0x59c1c
jmp 0x59c49
movl 0x84(%rsp), %ecx
incl %ecx
addq $0x20, %r13
movl 0x7c(%rsp), %r8d
cmpl %r8d, %ecx
jne 0x59a87
movq 0x40(%rsp), %rdx
incq %rdx
movq 0x90(%rsp), %r15
movq %rdi, %rsi
movl %ebp, %r8d
movq %rdx, 0x40(%rsp)
cmpq 0x38(%rsp), %rdx
jne 0x59a34
jmp 0x59da4
movl $0x1, %ebp
testl %ebp, %ebp
je 0x59ded
cmpl $0x2, %ebp
jl 0x59e12
movl %ebp, %eax
leaq 0x20(%rdi), %rcx
decq %rax
movq 0x48(%rsp), %rbx
movq 0x60(%rsp), %r14
movq 0x58(%rsp), %r12
movq 0x38(%rsp), %r10
movl 0x2c(%rsp), %r9d
movzwl 0x12(%rdi), %edx
movq %rcx, %r15
cmpw 0x12(%rcx), %dx
jg 0x59ddf
movq %rdi, %r15
addq $0x20, %rcx
movq %r15, %rdi
decq %rax
jne 0x59dcf
jmp 0x59e2e
leaq 0x18c2c(%rip), %rsi     # 0x72a20
movq 0x88(%rsp), %rdi
xorl %eax, %eax
callq 0x11c1f
movq 0x60(%rsp), %r14
movq 0x58(%rsp), %r12
jmp 0x59eef
movq %rdi, %r15
movq 0x48(%rsp), %rbx
movq 0x60(%rsp), %r14
movq 0x58(%rsp), %r12
movq 0x38(%rsp), %r10
movl 0x2c(%rsp), %r9d
testq %r10, %r10
je 0x59e74
movq 0x18(%r15), %rax
movq 0x8(%rbx), %rcx
addq $0x8, %rcx
movl %r10d, %edx
leaq 0x380(%rbx), %rsi
xorl %edi, %edi
movq (%rax,%rdi,8), %r8
movq %r8, (%rsi)
movzbl 0x10(%r8), %r8d
movb %r8b, -0x1c(%rsi)
imulq $0x68, %r8, %r8
movl 0x3c(%rcx,%r8), %r8d
movl %r8d, -0x3c(%rsi)
incq %rdi
addq $0x50, %rsi
cmpq %rdi, %rdx
jne 0x59e4b
movzwl 0x32(%rbx), %eax
andl $0x600, %eax            # imm = 0x600
cmpl $0x400, %eax            # imm = 0x400
jne 0x59ec7
testw %r9w, %r9w
je 0x59ec7
cmpb $0x0, 0x37(%rbx)
jne 0x59ec7
movq 0x18(%rbx), %rsi
movq 0x18(%r15), %rax
movq -0x8(%rax,%r10,8), %r9
leaq -0x1(%r10), %rax
leaq 0x50(%rsp), %rcx
movq %rcx, (%rsp)
movzwl %ax, %r8d
movq %rbx, %rdi
movq %r15, %rdx
movl $0x200, %ecx            # imm = 0x200
callq 0x5dbc7
cmpl $0x1, %eax
jne 0x59ec7
movb $0x2, 0x37(%rbx)
cmpb $0x0, 0x14(%r15)
je 0x59ee6
testb $0x2, 0x33(%rbx)
jne 0x59ee2
movb $0x1, 0x34(%rbx)
movq 0x8(%r15), %rax
movq %rax, 0x28(%rbx)
jmp 0x59ee6
movb $0x2, 0x37(%rbx)
movzwl 0x10(%r15), %eax
movw %ax, 0x30(%rbx)
movq %r14, %rdi
movq %r12, %rsi
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x9b58