// File: /workspace/github_c_makefile_star2_O3/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: flattenSubquery
static int flattenSubquery(
  Parse *pParse,       /* Parsing context */
  Select *p,           /* The parent or outer SELECT statement */
  int iFrom,           /* Index in p->pSrc->a[] of the inner subquery */
  int isAgg,           /* True if outer SELECT uses aggregate functions */
  int subqueryIsAgg    /* True if the subquery uses aggregate functions */
){
  const char *zSavedAuthContext = pParse->zAuthContext;
  Select *pParent;
  Select *pSub;       /* The inner query or "subquery" */
  Select *pSub1;      /* Pointer to the rightmost select in sub-query */
  SrcList *pSrc;      /* The FROM clause of the outer query */
  SrcList *pSubSrc;   /* The FROM clause of the subquery */
  ExprList *pList;    /* The result set of the outer query */
  int iParent;        /* VDBE cursor number of the pSub result set temp table */
  int i;              /* Loop counter */
  Expr *pWhere;                    /* The WHERE clause */
  struct SrcList_item *pSubitem;   /* The subquery */
  sqlite3 *db = pParse->db;

  /* Check to see if flattening is permitted.  Return 0 if not.
  */
  assert( p!=0 );
  assert( p->pPrior==0 );  /* Unable to flatten compound queries */
  if( OptimizationDisabled(db, SQLITE_QueryFlattener) ) return 0;
  pSrc = p->pSrc;
  assert( pSrc && iFrom>=0 && iFrom<pSrc->nSrc );
  pSubitem = &pSrc->a[iFrom];
  iParent = pSubitem->iCursor;
  pSub = pSubitem->pSelect;
  assert( pSub!=0 );
  if( isAgg && subqueryIsAgg ) return 0;                 /* Restriction (1)  */
  if( subqueryIsAgg && pSrc->nSrc>1 ) return 0;          /* Restriction (2)  */
  pSubSrc = pSub->pSrc;
  assert( pSubSrc );
  /* Prior to version 3.1.2, when LIMIT and OFFSET had to be simple constants,
  ** not arbitrary expresssions, we allowed some combining of LIMIT and OFFSET
  ** because they could be computed at compile-time.  But when LIMIT and OFFSET
  ** became arbitrary expressions, we were forced to add restrictions (13)
  ** and (14). */
  if( pSub->pLimit && p->pLimit ) return 0;              /* Restriction (13) */
  if( pSub->pOffset ) return 0;                          /* Restriction (14) */
  if( p->pRightmost && pSub->pLimit ){
    return 0;                                            /* Restriction (15) */
  }
  if( pSubSrc->nSrc==0 ) return 0;                       /* Restriction (7)  */
  if( pSub->selFlags & SF_Distinct ) return 0;           /* Restriction (5)  */
  if( pSub->pLimit && (pSrc->nSrc>1 || isAgg) ){
     return 0;         /* Restrictions (8)(9) */
  }
  if( (p->selFlags & SF_Distinct)!=0 && subqueryIsAgg ){
     return 0;         /* Restriction (6)  */
  }
  if( p->pOrderBy && pSub->pOrderBy ){
     return 0;                                           /* Restriction (11) */
  }
  if( isAgg && pSub->pOrderBy ) return 0;                /* Restriction (16) */
  if( pSub->pLimit && p->pWhere ) return 0;              /* Restriction (19) */
  if( pSub->pLimit && (p->selFlags & SF_Distinct)!=0 ){
     return 0;         /* Restriction (21) */
  }

  /* OBSOLETE COMMENT 1:
  ** Restriction 3:  If the subquery is a join, make sure the subquery is 
  ** not used as the right operand of an outer join.  Examples of why this
  ** is not allowed:
  **
  **         t1 LEFT OUTER JOIN (t2 JOIN t3)
  **
  ** If we flatten the above, we would get
  **
  **         (t1 LEFT OUTER JOIN t2) JOIN t3
  **
  ** which is not at all the same thing.
  **
  ** OBSOLETE COMMENT 2:
  ** Restriction 12:  If the subquery is the right operand of a left outer
  ** join, make sure the subquery has no WHERE clause.
  ** An examples of why this is not allowed:
  **
  **         t1 LEFT OUTER JOIN (SELECT * FROM t2 WHERE t2.x>0)
  **
  ** If we flatten the above, we would get
  **
  **         (t1 LEFT OUTER JOIN t2) WHERE t2.x>0
  **
  ** But the t2.x>0 test will always fail on a NULL row of t2, which
  ** effectively converts the OUTER JOIN into an INNER JOIN.
  **
  ** THIS OVERRIDES OBSOLETE COMMENTS 1 AND 2 ABOVE:
  ** Ticket #3300 shows that flattening the right term of a LEFT JOIN
  ** is fraught with danger.  Best to avoid the whole thing.  If the
  ** subquery is the right term of a LEFT JOIN, then do not flatten.
  */
  if( (pSubitem->jointype & JT_OUTER)!=0 ){
    return 0;
  }

  /* Restriction 17: If the sub-query is a compound SELECT, then it must
  ** use only the UNION ALL operator. And none of the simple select queries
  ** that make up the compound SELECT are allowed to be aggregate or distinct
  ** queries.
  */
  if( pSub->pPrior ){
    if( pSub->pOrderBy ){
      return 0;  /* Restriction 20 */
    }
    if( isAgg || (p->selFlags & SF_Distinct)!=0 || pSrc->nSrc!=1 ){
      return 0;
    }
    for(pSub1=pSub; pSub1; pSub1=pSub1->pPrior){
      testcase( (pSub1->selFlags & (SF_Distinct|SF_Aggregate))==SF_Distinct );
      testcase( (pSub1->selFlags & (SF_Distinct|SF_Aggregate))==SF_Aggregate );
      assert( pSub->pSrc!=0 );
      if( (pSub1->selFlags & (SF_Distinct|SF_Aggregate))!=0
       || (pSub1->pPrior && pSub1->op!=TK_ALL) 
       || pSub1->pSrc->nSrc<1
       || pSub->pEList->nExpr!=pSub1->pEList->nExpr
      ){
        return 0;
      }
      testcase( pSub1->pSrc->nSrc>1 );
    }

    /* Restriction 18. */
    if( p->pOrderBy ){
      int ii;
      for(ii=0; ii<p->pOrderBy->nExpr; ii++){
        if( p->pOrderBy->a[ii].iOrderByCol==0 ) return 0;
      }
    }
  }

  /***** If we reach this point, flattening is permitted. *****/

  /* Authorize the subquery */
  pParse->zAuthContext = pSubitem->zName;
  TESTONLY(i =) sqlite3AuthCheck(pParse, SQLITE_SELECT, 0, 0, 0);
  testcase( i==SQLITE_DENY );
  pParse->zAuthContext = zSavedAuthContext;

  /* If the sub-query is a compound SELECT statement, then (by restrictions
  ** 17 and 18 above) it must be a UNION ALL and the parent query must 
  ** be of the form:
  **
  **     SELECT <expr-list> FROM (<sub-query>) <where-clause> 
  **
  ** followed by any ORDER BY, LIMIT and/or OFFSET clauses. This block
  ** creates N-1 copies of the parent query without any ORDER BY, LIMIT or 
  ** OFFSET clauses and joins them to the left-hand-side of the original
  ** using UNION ALL operators. In this case N is the number of simple
  ** select statements in the compound sub-query.
  **
  ** Example:
  **
  **     SELECT a+1 FROM (
  **        SELECT x FROM tab
  **        UNION ALL
  **        SELECT y FROM tab
  **        UNION ALL
  **        SELECT abs(z*2) FROM tab2
  **     ) WHERE a!=5 ORDER BY 1
  **
  ** Transformed into:
  **
  **     SELECT x+1 FROM tab WHERE x+1!=5
  **     UNION ALL
  **     SELECT y+1 FROM tab WHERE y+1!=5
  **     UNION ALL
  **     SELECT abs(z*2)+1 FROM tab2 WHERE abs(z*2)+1!=5
  **     ORDER BY 1
  **
  ** We call this the "compound-subquery flattening".
  */
  for(pSub=pSub->pPrior; pSub; pSub=pSub->pPrior){
    Select *pNew;
    ExprList *pOrderBy = p->pOrderBy;
    Expr *pLimit = p->pLimit;
    Expr *pOffset = p->pOffset;
    Select *pPrior = p->pPrior;
    p->pOrderBy = 0;
    p->pSrc = 0;
    p->pPrior = 0;
    p->pLimit = 0;
    p->pOffset = 0;
    pNew = sqlite3SelectDup(db, p, 0);
    p->pOffset = pOffset;
    p->pLimit = pLimit;
    p->pOrderBy = pOrderBy;
    p->pSrc = pSrc;
    p->op = TK_ALL;
    p->pRightmost = 0;
    if( pNew==0 ){
      pNew = pPrior;
    }else{
      pNew->pPrior = pPrior;
      pNew->pRightmost = 0;
    }
    p->pPrior = pNew;
    if( db->mallocFailed ) return 1;
  }

  /* Begin flattening the iFrom-th entry of the FROM clause 
  ** in the outer query.
  */
  pSub = pSub1 = pSubitem->pSelect;

  /* Delete the transient table structure associated with the
  ** subquery
  */
  sqlite3DbFree(db, pSubitem->zDatabase);
  sqlite3DbFree(db, pSubitem->zName);
  sqlite3DbFree(db, pSubitem->zAlias);
  pSubitem->zDatabase = 0;
  pSubitem->zName = 0;
  pSubitem->zAlias = 0;
  pSubitem->pSelect = 0;

  /* Defer deleting the Table object associated with the
  ** subquery until code generation is
  ** complete, since there may still exist Expr.pTab entries that
  ** refer to the subquery even after flattening.  Ticket #3346.
  **
  ** pSubitem->pTab is always non-NULL by test restrictions and tests above.
  */
  if( ALWAYS(pSubitem->pTab!=0) ){
    Table *pTabToDel = pSubitem->pTab;
    if( pTabToDel->nRef==1 ){
      Parse *pToplevel = sqlite3ParseToplevel(pParse);
      pTabToDel->pNextZombie = pToplevel->pZombieTab;
      pToplevel->pZombieTab = pTabToDel;
    }else{
      pTabToDel->nRef--;
    }
    pSubitem->pTab = 0;
  }

  /* The following loop runs once for each term in a compound-subquery
  ** flattening (as described above).  If we are doing a different kind
  ** of flattening - a flattening other than a compound-subquery flattening -
  ** then this loop only runs once.
  **
  ** This loop moves all of the FROM elements of the subquery into the
  ** the FROM clause of the outer query.  Before doing this, remember
  ** the cursor number for the original outer query FROM element in
  ** iParent.  The iParent cursor will never be used.  Subsequent code
  ** will scan expressions looking for iParent references and replace
  ** those references with expressions that resolve to the subquery FROM
  ** elements we are now copying in.
  */
  for(pParent=p; pParent; pParent=pParent->pPrior, pSub=pSub->pPrior){
    int nSubSrc;
    u8 jointype = 0;
    pSubSrc = pSub->pSrc;     /* FROM clause of subquery */
    nSubSrc = pSubSrc->nSrc;  /* Number of terms in subquery FROM clause */
    pSrc = pParent->pSrc;     /* FROM clause of the outer query */

    if( pSrc ){
      assert( pParent==p );  /* First time through the loop */
      jointype = pSubitem->jointype;
    }else{
      assert( pParent!=p );  /* 2nd and subsequent times through the loop */
      pSrc = pParent->pSrc = sqlite3SrcListAppend(db, 0, 0, 0);
      if( pSrc==0 ){
        assert( db->mallocFailed );
        break;
      }
    }

    /* The subquery uses a single slot of the FROM clause of the outer
    ** query.  If the subquery has more than one element in its FROM clause,
    ** then expand the outer query to make space for it to hold all elements
    ** of the subquery.
    **
    ** Example:
    **
    **    SELECT * FROM tabA, (SELECT * FROM sub1, sub2), tabB;
    **
    ** The outer query has 3 slots in its FROM clause.  One slot of the
    ** outer query (the middle slot) is used by the subquery.  The next
    ** block of code will expand the out query to 4 slots.  The middle
    ** slot is expanded to two slots in order to make space for the
    ** two elements in the FROM clause of the subquery.
    */
    if( nSubSrc>1 ){
      pParent->pSrc = pSrc = sqlite3SrcListEnlarge(db, pSrc, nSubSrc-1,iFrom+1);
      if( db->mallocFailed ){
        break;
      }
    }

    /* Transfer the FROM clause terms from the subquery into the
    ** outer query.
    */
    for(i=0; i<nSubSrc; i++){
      sqlite3IdListDelete(db, pSrc->a[i+iFrom].pUsing);
      pSrc->a[i+iFrom] = pSubSrc->a[i];
      memset(&pSubSrc->a[i], 0, sizeof(pSubSrc->a[i]));
    }
    pSrc->a[iFrom].jointype = jointype;
  
    /* Now begin substituting subquery result set expressions for 
    ** references to the iParent in the outer query.
    ** 
    ** Example:
    **
    **   SELECT a+5, b*10 FROM (SELECT x*3 AS a, y+10 AS b FROM t1) WHERE a>b;
    **   \                     \_____________ subquery __________/          /
    **    \_____________________ outer query ______________________________/
    **
    ** We look at every expression in the outer query and every place we see
    ** "a" we substitute "x*3" and every place we see "b" we substitute "y+10".
    */
    pList = pParent->pEList;
    for(i=0; i<pList->nExpr; i++){
      if( pList->a[i].zName==0 ){
        char *zName = sqlite3DbStrDup(db, pList->a[i].zSpan);
        sqlite3Dequote(zName);
        pList->a[i].zName = zName;
      }
    }
    substExprList(db, pParent->pEList, iParent, pSub->pEList);
    if( isAgg ){
      substExprList(db, pParent->pGroupBy, iParent, pSub->pEList);
      pParent->pHaving = substExpr(db, pParent->pHaving, iParent, pSub->pEList);
    }
    if( pSub->pOrderBy ){
      assert( pParent->pOrderBy==0 );
      pParent->pOrderBy = pSub->pOrderBy;
      pSub->pOrderBy = 0;
    }else if( pParent->pOrderBy ){
      substExprList(db, pParent->pOrderBy, iParent, pSub->pEList);
    }
    if( pSub->pWhere ){
      pWhere = sqlite3ExprDup(db, pSub->pWhere, 0);
    }else{
      pWhere = 0;
    }
    if( subqueryIsAgg ){
      assert( pParent->pHaving==0 );
      pParent->pHaving = pParent->pWhere;
      pParent->pWhere = pWhere;
      pParent->pHaving = substExpr(db, pParent->pHaving, iParent, pSub->pEList);
      pParent->pHaving = sqlite3ExprAnd(db, pParent->pHaving, 
                                  sqlite3ExprDup(db, pSub->pHaving, 0));
      assert( pParent->pGroupBy==0 );
      pParent->pGroupBy = sqlite3ExprListDup(db, pSub->pGroupBy, 0);
    }else{
      pParent->pWhere = substExpr(db, pParent->pWhere, iParent, pSub->pEList);
      pParent->pWhere = sqlite3ExprAnd(db, pParent->pWhere, pWhere);
    }
  
    /* The flattened query is distinct if either the inner or the
    ** outer query is distinct. 
    */
    pParent->selFlags |= pSub->selFlags & SF_Distinct;
  
    /*
    ** SELECT ... FROM (SELECT ... LIMIT a OFFSET b) LIMIT x OFFSET y;
    **
    ** One is tempted to try to add a and b to combine the limits.  But this
    ** does not work if either limit is negative.
    */
    if( pSub->pLimit ){
      pParent->pLimit = pSub->pLimit;
      pSub->pLimit = 0;
    }
  }

  /* Finially, delete what is left of the subquery and return
  ** success.
  */
  sqlite3SelectDelete(db, pSub1);

  return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq (%rdi), %r12
xorl %eax, %eax
testb $0x1, 0x4c(%r12)
jne 0x50708
movl %r8d, %ebx
movq %rdi, %r15
testl %ecx, %ecx
setne %r8b
testl %ebx, %ebx
setne %dil
testb %dil, %r8b
jne 0x50708
movq 0x248(%r15), %r10
movq 0x28(%rsi), %r13
movslq %edx, %rdi
imulq $0x68, %rdi, %r11
movl 0x44(%r13,%r11), %r9d
movq 0x30(%r13,%r11), %r14
testl %ebx, %ebx
je 0x500c9
cmpb $0x1, (%r13)
ja 0x50708
movq 0x28(%r14), %rdi
movq 0x68(%r14), %r8
testq %r8, %r8
je 0x500e1
cmpq $0x0, 0x68(%rsi)
jne 0x50708
cmpq $0x0, 0x70(%r14)
jne 0x50708
testq %r8, %r8
je 0x500fc
cmpq $0x0, 0x60(%rsi)
jne 0x50708
cmpb $0x0, (%rdi)
je 0x50708
testb $0x1, 0xa(%r14)
jne 0x50708
testq %r8, %r8
je 0x50128
testl %ecx, %ecx
jne 0x50708
cmpb $0x1, (%r13)
ja 0x50708
movq %r10, -0x40(%rbp)
testl %ebx, %ebx
setne %dil
movzwl 0xa(%rsi), %r10d
testb %r10b, %dil
jne 0x50708
movl %r9d, -0x34(%rbp)
movq 0x48(%rsi), %r9
testq %r9, %r9
je 0x50158
cmpq $0x0, 0x48(%r14)
jne 0x50708
testl %ecx, %ecx
je 0x50167
cmpq $0x0, 0x48(%r14)
jne 0x50708
testq %r8, %r8
je 0x50181
testb $0x1, %r10b
jne 0x50708
cmpq $0x0, 0x30(%rsi)
jne 0x50708
leaq (%r11,%r13), %rdi
addq $0x8, %rdi
movq %rdi, -0x60(%rbp)
testb $0x20, 0x38(%rdi)
jne 0x50708
movq %rsi, -0x30(%rbp)
cmpq $0x0, 0x50(%r14)
movl %ecx, -0x84(%rbp)
movq %r11, -0x50(%rbp)
je 0x50256
testl %ecx, %ecx
jne 0x50708
andl $0x1, %r10d
jne 0x50708
cmpq $0x0, 0x48(%r14)
jne 0x50708
cmpb $0x1, (%r13)
jne 0x50708
movl %edx, %r10d
movq %r14, %rdx
testq %rdx, %rdx
je 0x50222
testb $0x5, 0xa(%rdx)
jne 0x50708
movq 0x50(%rdx), %rsi
testq %rsi, %rsi
je 0x50200
cmpb $0x71, 0x8(%rdx)
jne 0x50708
movq 0x28(%rdx), %rdi
cmpb $0x0, (%rdi)
je 0x50708
movq (%r14), %rdi
movl (%rdi), %edi
movq (%rdx), %r8
movq %rsi, %rdx
cmpl (%r8), %edi
je 0x501de
jmp 0x50708
testq %r9, %r9
movl %r10d, %edx
je 0x50256
movslq (%r9), %rdi
testq %rdi, %rdi
jle 0x50256
movq 0x8(%r9), %rcx
shlq $0x5, %rdi
xorl %eax, %eax
xorl %esi, %esi
cmpw $0x0, 0x1a(%rcx,%rsi)
je 0x50708
addq $0x20, %rsi
cmpq %rsi, %rdi
movl %r10d, %edx
jne 0x5023e
movl %edx, -0x44(%rbp)
movq -0x60(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x248(%r15)
movq %r15, %rdi
movl $0x15, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x460eb
movq -0x40(%rbp), %rax
movq %rax, 0x248(%r15)
movq 0x50(%r14), %r14
testq %r14, %r14
movq -0x30(%rbp), %rsi
je 0x5034f
leaq 0x48(%rsi), %rax
movq %rax, -0x80(%rbp)
leaq 0x68(%rsi), %rax
movq %rax, -0x70(%rbp)
movq 0x48(%rsi), %rax
movq %rax, -0x68(%rbp)
movq 0x50(%rsi), %rax
movq %rax, -0x40(%rbp)
movq 0x68(%rsi), %rax
movq %rax, -0x78(%rbp)
movq 0x70(%rsi), %rax
movq %rax, -0x58(%rbp)
xorl %eax, %eax
movq %rax, 0x28(%rsi)
movq -0x80(%rbp), %rax
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq -0x70(%rbp), %rax
movups %xmm0, (%rax)
movq %r12, %rdi
xorl %edx, %edx
callq 0x48744
movq -0x30(%rbp), %rsi
movq -0x58(%rbp), %rcx
movq %rcx, 0x70(%rsi)
movq -0x78(%rbp), %rcx
movq %rcx, 0x68(%rsi)
movq -0x68(%rbp), %rcx
movq %rcx, 0x48(%rsi)
movq %r13, 0x28(%rsi)
movb $0x71, 0x8(%rsi)
xorl %ecx, %ecx
movq %rcx, 0x60(%rsi)
testq %rax, %rax
je 0x5032a
movq -0x40(%rbp), %rcx
movq %rcx, 0x50(%rax)
movq $0x0, 0x60(%rax)
jmp 0x5032e
movq -0x40(%rbp), %rax
movq %rax, 0x50(%rsi)
cmpb $0x0, 0x50(%r12)
jne 0x50703
movq %rax, -0x40(%rbp)
movq 0x50(%r14), %r14
testq %r14, %r14
jne 0x502c8
movq -0x60(%rbp), %r14
movq 0x8(%r14), %rsi
movq 0x28(%r14), %rax
movq %rax, -0x58(%rbp)
movq %r12, %rdi
callq 0x9ca4
movq 0x10(%r14), %rsi
movq %r12, %rdi
callq 0x9ca4
movq 0x18(%r14), %rsi
movq %r12, %rdi
callq 0x9ca4
xorl %eax, %eax
movq %rax, 0x28(%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%r14)
movq %rax, 0x18(%r14)
movq 0x20(%r14), %rax
testq %rax, %rax
je 0x503d8
movzwl 0x44(%rax), %ecx
cmpw $0x1, %cx
jne 0x503c6
movq 0x1d8(%r15), %rcx
testq %rcx, %rcx
cmoveq %r15, %rcx
movq 0x288(%rcx), %rdx
movq %rdx, 0x70(%rax)
movq %rax, 0x288(%rcx)
jmp 0x503cc
decl %ecx
movw %cx, 0x44(%rax)
movq -0x60(%rbp), %rax
movq $0x0, 0x20(%rax)
movq -0x30(%rbp), %rsi
testq %rsi, %rsi
movl -0x44(%rbp), %ecx
movq -0x50(%rbp), %rdi
movl -0x34(%rbp), %edx
je 0x506f7
incl %ecx
movq -0x58(%rbp), %r13
movl %ecx, -0x44(%rbp)
movq 0x28(%r13), %r14
movzbl (%r14), %r15d
movq 0x28(%rsi), %r8
testq %r8, %r8
movq %rsi, -0x30(%rbp)
je 0x5041a
movq -0x60(%rbp), %rax
movb 0x38(%rax), %al
movq %rax, -0x68(%rbp)
jmp 0x5044e
movq $0x0, -0x68(%rbp)
movq %r12, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x3dc99
movl -0x34(%rbp), %edx
movq -0x50(%rbp), %rdi
movq -0x30(%rbp), %rsi
movl -0x44(%rbp), %ecx
movq %rax, 0x28(%rsi)
testq %rax, %rax
je 0x506f7
movq %rax, %r8
cmpb $0x2, %r15b
movq %r13, -0x70(%rbp)
jb 0x50483
leal -0x1(%r15), %edx
movq %r12, %rdi
movq %r8, %rsi
callq 0x560ab
movq -0x50(%rbp), %rdi
movq %rax, %r8
movq -0x30(%rbp), %rax
movq %r8, 0x28(%rax)
cmpb $0x0, 0x50(%r12)
je 0x5048c
jmp 0x506f7
testl %r15d, %r15d
je 0x50515
movl %r15d, %r13d
movq %r8, -0x78(%rbp)
leaq (%r8,%rdi), %rax
movq %rax, -0x80(%rbp)
movl $0x8, %r15d
movq -0x80(%rbp), %rax
leaq (%rax,%r15), %rcx
movq %rcx, -0x40(%rbp)
movq 0x48(%rax,%r15), %rsi
movq %r12, %rdi
callq 0x349e3
leaq (%r14,%r15), %rsi
movl $0xd, %ecx
movq -0x40(%rbp), %rdi
rep  movsq (%rsi), %es:(%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x50(%r14,%r15)
movups %xmm0, 0x40(%r14,%r15)
movups %xmm0, 0x30(%r14,%r15)
movups %xmm0, 0x20(%r14,%r15)
movups %xmm0, 0x10(%r14,%r15)
movups %xmm0, (%r14,%r15)
movq $0x0, 0x60(%r14,%r15)
addq $0x68, %r15
decq %r13
jne 0x504a1
movq -0x30(%rbp), %rsi
movq -0x50(%rbp), %rdi
movl -0x34(%rbp), %edx
movq -0x70(%rbp), %r13
movq -0x78(%rbp), %r8
movq -0x68(%rbp), %rax
movb %al, 0x40(%r8,%rdi)
movq (%rsi), %r8
movl (%r8), %eax
testl %eax, %eax
jle 0x50584
movq 0x8(%r8), %rcx
movl $0x8, %r14d
xorl %r13d, %r13d
movq %r8, -0x40(%rbp)
cmpq $0x0, (%rcx,%r14)
jne 0x5056e
movq 0x8(%rcx,%r14), %rsi
movq %r12, %rdi
callq 0x101fc
movq %rax, %r15
movq %rax, %rdi
callq 0x461c6
movq -0x40(%rbp), %r8
movl -0x34(%rbp), %edx
movq -0x30(%rbp), %rsi
movq 0x8(%r8), %rcx
movq %r15, (%rcx,%r14)
movl (%r8), %eax
incq %r13
movslq %eax, %rdi
addq $0x20, %r14
cmpq %rdi, %r13
jl 0x50539
movq (%rsi), %r8
movq -0x70(%rbp), %r13
movq (%r13), %rcx
movq %r12, %rdi
movq %r8, %rsi
movl %edx, %r14d
callq 0x561dd
cmpl $0x0, -0x84(%rbp)
movq -0x30(%rbp), %rcx
je 0x505d5
movq 0x38(%rcx), %rsi
movq (%r13), %rcx
movq %r12, %rdi
movl %r14d, %edx
callq 0x561dd
movq -0x30(%rbp), %rax
movq 0x40(%rax), %rsi
movq (%r13), %rcx
movq %r12, %rdi
movl %r14d, %edx
callq 0x5624f
movq -0x30(%rbp), %rcx
movq %rax, 0x40(%rcx)
movq 0x48(%r13), %rax
testq %rax, %rax
je 0x505ec
movq %rax, 0x48(%rcx)
movq $0x0, 0x48(%r13)
jmp 0x50608
movq 0x48(%rcx), %rsi
testq %rsi, %rsi
je 0x50608
movq (%r13), %rcx
movq %r12, %rdi
movl -0x34(%rbp), %edx
callq 0x561dd
movq -0x30(%rbp), %rcx
movq 0x30(%r13), %rsi
testq %rsi, %rsi
je 0x50626
movq %r12, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x4848c
movq -0x30(%rbp), %rcx
movq %rax, %r15
jmp 0x50629
xorl %r15d, %r15d
movl -0x34(%rbp), %edx
movq 0x30(%rcx), %rsi
testl %ebx, %ebx
je 0x50691
movq %rsi, 0x40(%rcx)
movq %r15, 0x30(%rcx)
movq (%r13), %rcx
movq %r12, %rdi
callq 0x5624f
movq %rax, %r15
movq -0x30(%rbp), %rax
movq %r15, 0x40(%rax)
movq 0x40(%r13), %rsi
movq %r12, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x4848c
movq %r12, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x4a8e5
movq -0x30(%rbp), %rcx
movq %rax, 0x40(%rcx)
movq 0x38(%r13), %rsi
movq %r12, %rdi
xorl %edx, %edx
callq 0x4887b
movq -0x30(%rbp), %rsi
movq %rax, 0x38(%rsi)
jmp 0x506bb
movq (%r13), %rcx
movq %r12, %rdi
callq 0x5624f
movq -0x30(%rbp), %rcx
movq %rax, 0x30(%rcx)
movq %r12, %rdi
movq %rax, %rsi
movq %r15, %rdx
callq 0x4a8e5
movq -0x30(%rbp), %rsi
movq %rax, 0x30(%rsi)
movzwl 0xa(%r13), %eax
andl $0x1, %eax
orw %ax, 0xa(%rsi)
movq 0x68(%r13), %rax
testq %rax, %rax
movl -0x44(%rbp), %ecx
movq -0x50(%rbp), %rdi
je 0x506e3
movq %rax, 0x68(%rsi)
movq $0x0, 0x68(%r13)
movq 0x50(%rsi), %rsi
movq 0x50(%r13), %r13
testq %rsi, %rsi
movl -0x34(%rbp), %edx
jne 0x503f8
movq %r12, %rdi
movq -0x58(%rbp), %rsi
callq 0x34827
movl $0x1, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq