// File: /workspace/github_c_makefile_star2_O1/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: allocateBtreePage
static int allocateBtreePage(
  BtShared *pBt,         /* The btree */
  MemPage **ppPage,      /* Store pointer to the allocated page here */
  Pgno *pPgno,           /* Store the page number here */
  Pgno nearby,           /* Search for a page near this one */
  u8 eMode               /* BTALLOC_EXACT, BTALLOC_LT, or BTALLOC_ANY */
){
  MemPage *pPage1;
  int rc;
  u32 n;     /* Number of pages on the freelist */
  u32 k;     /* Number of leaves on the trunk of the freelist */
  MemPage *pTrunk = 0;
  MemPage *pPrevTrunk = 0;
  Pgno mxPage;     /* Total size of the database file */

  assert( sqlite3_mutex_held(pBt->mutex) );
  assert( eMode==BTALLOC_ANY || (nearby>0 && IfNotOmitAV(pBt->autoVacuum)) );
  pPage1 = pBt->pPage1;
  mxPage = btreePagecount(pBt);
  n = get4byte(&pPage1->aData[36]);
  testcase( n==mxPage-1 );
  if( n>=mxPage ){
    return SQLITE_CORRUPT_BKPT;
  }
  if( n>0 ){
    /* There are pages on the freelist.  Reuse one of those pages. */
    Pgno iTrunk;
    u8 searchList = 0; /* If the free-list must be searched for 'nearby' */
    
    /* If eMode==BTALLOC_EXACT and a query of the pointer-map
    ** shows that the page 'nearby' is somewhere on the free-list, then
    ** the entire-list will be searched for that page.
    */
#ifndef SQLITE_OMIT_AUTOVACUUM
    if( eMode==BTALLOC_EXACT ){
      if( nearby<=mxPage ){
        u8 eType;
        assert( nearby>0 );
        assert( pBt->autoVacuum );
        rc = ptrmapGet(pBt, nearby, &eType, 0);
        if( rc ) return rc;
        if( eType==PTRMAP_FREEPAGE ){
          searchList = 1;
        }
      }
    }else if( eMode==BTALLOC_LE ){
      searchList = 1;
    }
#endif

    /* Decrement the free-list count by 1. Set iTrunk to the index of the
    ** first free-list trunk page. iPrevTrunk is initially 1.
    */
    rc = sqlite3PagerWrite(pPage1->pDbPage);
    if( rc ) return rc;
    put4byte(&pPage1->aData[36], n-1);

    /* The code within this loop is run only once if the 'searchList' variable
    ** is not true. Otherwise, it runs once for each trunk-page on the
    ** free-list until the page 'nearby' is located (eMode==BTALLOC_EXACT)
    ** or until a page less than 'nearby' is located (eMode==BTALLOC_LT)
    */
    do {
      pPrevTrunk = pTrunk;
      if( pPrevTrunk ){
        iTrunk = get4byte(&pPrevTrunk->aData[0]);
      }else{
        iTrunk = get4byte(&pPage1->aData[32]);
      }
      testcase( iTrunk==mxPage );
      if( iTrunk>mxPage ){
        rc = SQLITE_CORRUPT_BKPT;
      }else{
        rc = btreeGetPage(pBt, iTrunk, &pTrunk, 0);
      }
      if( rc ){
        pTrunk = 0;
        goto end_allocate_page;
      }
      assert( pTrunk!=0 );
      assert( pTrunk->aData!=0 );

      k = get4byte(&pTrunk->aData[4]); /* # of leaves on this trunk page */
      if( k==0 && !searchList ){
        /* The trunk has no leaves and the list is not being searched. 
        ** So extract the trunk page itself and use it as the newly 
        ** allocated page */
        assert( pPrevTrunk==0 );
        rc = sqlite3PagerWrite(pTrunk->pDbPage);
        if( rc ){
          goto end_allocate_page;
        }
        *pPgno = iTrunk;
        memcpy(&pPage1->aData[32], &pTrunk->aData[0], 4);
        *ppPage = pTrunk;
        pTrunk = 0;
        TRACE(("ALLOCATE: %d trunk - %d free pages left\n", *pPgno, n-1));
      }else if( k>(u32)(pBt->usableSize/4 - 2) ){
        /* Value of k is out of range.  Database corruption */
        rc = SQLITE_CORRUPT_BKPT;
        goto end_allocate_page;
#ifndef SQLITE_OMIT_AUTOVACUUM
      }else if( searchList 
            && (nearby==iTrunk || (iTrunk<nearby && eMode==BTALLOC_LE)) 
      ){
        /* The list is being searched and this trunk page is the page
        ** to allocate, regardless of whether it has leaves.
        */
        *pPgno = iTrunk;
        *ppPage = pTrunk;
        searchList = 0;
        rc = sqlite3PagerWrite(pTrunk->pDbPage);
        if( rc ){
          goto end_allocate_page;
        }
        if( k==0 ){
          if( !pPrevTrunk ){
            memcpy(&pPage1->aData[32], &pTrunk->aData[0], 4);
          }else{
            rc = sqlite3PagerWrite(pPrevTrunk->pDbPage);
            if( rc!=SQLITE_OK ){
              goto end_allocate_page;
            }
            memcpy(&pPrevTrunk->aData[0], &pTrunk->aData[0], 4);
          }
        }else{
          /* The trunk page is required by the caller but it contains 
          ** pointers to free-list leaves. The first leaf becomes a trunk
          ** page in this case.
          */
          MemPage *pNewTrunk;
          Pgno iNewTrunk = get4byte(&pTrunk->aData[8]);
          if( iNewTrunk>mxPage ){ 
            rc = SQLITE_CORRUPT_BKPT;
            goto end_allocate_page;
          }
          testcase( iNewTrunk==mxPage );
          rc = btreeGetPage(pBt, iNewTrunk, &pNewTrunk, 0);
          if( rc!=SQLITE_OK ){
            goto end_allocate_page;
          }
          rc = sqlite3PagerWrite(pNewTrunk->pDbPage);
          if( rc!=SQLITE_OK ){
            releasePage(pNewTrunk);
            goto end_allocate_page;
          }
          memcpy(&pNewTrunk->aData[0], &pTrunk->aData[0], 4);
          put4byte(&pNewTrunk->aData[4], k-1);
          memcpy(&pNewTrunk->aData[8], &pTrunk->aData[12], (k-1)*4);
          releasePage(pNewTrunk);
          if( !pPrevTrunk ){
            assert( sqlite3PagerIswriteable(pPage1->pDbPage) );
            put4byte(&pPage1->aData[32], iNewTrunk);
          }else{
            rc = sqlite3PagerWrite(pPrevTrunk->pDbPage);
            if( rc ){
              goto end_allocate_page;
            }
            put4byte(&pPrevTrunk->aData[0], iNewTrunk);
          }
        }
        pTrunk = 0;
        TRACE(("ALLOCATE: %d trunk - %d free pages left\n", *pPgno, n-1));
#endif
      }else if( k>0 ){
        /* Extract a leaf from the trunk */
        u32 closest;
        Pgno iPage;
        unsigned char *aData = pTrunk->aData;
        if( nearby>0 ){
          u32 i;
          closest = 0;
          if( eMode==BTALLOC_LE ){
            for(i=0; i<k; i++){
              iPage = get4byte(&aData[8+i*4]);
              if( iPage<=nearby ){
                closest = i;
                break;
              }
            }
          }else{
            int dist;
            dist = sqlite3AbsInt32(get4byte(&aData[8]) - nearby);
            for(i=1; i<k; i++){
              int d2 = sqlite3AbsInt32(get4byte(&aData[8+i*4]) - nearby);
              if( d2<dist ){
                closest = i;
                dist = d2;
              }
            }
          }
        }else{
          closest = 0;
        }

        iPage = get4byte(&aData[8+closest*4]);
        testcase( iPage==mxPage );
        if( iPage>mxPage ){
          rc = SQLITE_CORRUPT_BKPT;
          goto end_allocate_page;
        }
        testcase( iPage==mxPage );
        if( !searchList 
         || (iPage==nearby || (iPage<nearby && eMode==BTALLOC_LE)) 
        ){
          int noContent;
          *pPgno = iPage;
          TRACE(("ALLOCATE: %d was leaf %d of %d on trunk %d"
                 ": %d more free pages\n",
                 *pPgno, closest+1, k, pTrunk->pgno, n-1));
          rc = sqlite3PagerWrite(pTrunk->pDbPage);
          if( rc ) goto end_allocate_page;
          if( closest<k-1 ){
            memcpy(&aData[8+closest*4], &aData[4+k*4], 4);
          }
          put4byte(&aData[4], k-1);
          noContent = !btreeGetHasContent(pBt, *pPgno) ? PAGER_GET_NOCONTENT : 0;
          rc = btreeGetPage(pBt, *pPgno, ppPage, noContent);
          if( rc==SQLITE_OK ){
            rc = sqlite3PagerWrite((*ppPage)->pDbPage);
            if( rc!=SQLITE_OK ){
              releasePage(*ppPage);
            }
          }
          searchList = 0;
        }
      }
      releasePage(pPrevTrunk);
      pPrevTrunk = 0;
    }while( searchList );
  }else{
    /* There are no pages on the freelist, so append a new page to the
    ** database image.
    **
    ** Normally, new pages allocated by this block can be requested from the
    ** pager layer with the 'no-content' flag set. This prevents the pager
    ** from trying to read the pages content from disk. However, if the
    ** current transaction has already run one or more incremental-vacuum
    ** steps, then the page we are about to allocate may contain content
    ** that is required in the event of a rollback. In this case, do
    ** not set the no-content flag. This causes the pager to load and journal
    ** the current page content before overwriting it.
    **
    ** Note that the pager will not actually attempt to load or journal 
    ** content for any page that really does lie past the end of the database
    ** file on disk. So the effects of disabling the no-content optimization
    ** here are confined to those pages that lie between the end of the
    ** database image and the end of the database file.
    */
    int bNoContent = (0==IfNotOmitAV(pBt->bDoTruncate)) ? PAGER_GET_NOCONTENT : 0;

    rc = sqlite3PagerWrite(pBt->pPage1->pDbPage);
    if( rc ) return rc;
    pBt->nPage++;
    if( pBt->nPage==PENDING_BYTE_PAGE(pBt) ) pBt->nPage++;

#ifndef SQLITE_OMIT_AUTOVACUUM
    if( pBt->autoVacuum && PTRMAP_ISPAGE(pBt, pBt->nPage) ){
      /* If *pPgno refers to a pointer-map page, allocate two new pages
      ** at the end of the file instead of one. The first allocated page
      ** becomes a new pointer-map page, the second is used by the caller.
      */
      MemPage *pPg = 0;
      TRACE(("ALLOCATE: %d from end of file (pointer-map page)\n", pBt->nPage));
      assert( pBt->nPage!=PENDING_BYTE_PAGE(pBt) );
      rc = btreeGetPage(pBt, pBt->nPage, &pPg, bNoContent);
      if( rc==SQLITE_OK ){
        rc = sqlite3PagerWrite(pPg->pDbPage);
        releasePage(pPg);
      }
      if( rc ) return rc;
      pBt->nPage++;
      if( pBt->nPage==PENDING_BYTE_PAGE(pBt) ){ pBt->nPage++; }
    }
#endif
    put4byte(28 + (u8*)pBt->pPage1->aData, pBt->nPage);
    *pPgno = pBt->nPage;

    assert( *pPgno!=PENDING_BYTE_PAGE(pBt) );
    rc = btreeGetPage(pBt, *pPgno, ppPage, bNoContent);
    if( rc ) return rc;
    rc = sqlite3PagerWrite((*ppPage)->pDbPage);
    if( rc!=SQLITE_OK ){
      releasePage(*ppPage);
    }
    TRACE(("ALLOCATE: %d from end of file\n", *pPgno));
  }

  assert( *pPgno!=PENDING_BYTE_PAGE(pBt) );

end_allocate_page:
  releasePage(pTrunk);
  releasePage(pPrevTrunk);
  if( rc==SQLITE_OK ){
    if( sqlite3PagerPageRefcount((*ppPage)->pDbPage)>1 ){
      releasePage(*ppPage);
      return SQLITE_CORRUPT_BKPT;
    }
    (*ppPage)->isInit = 0;
  }else{
    *ppPage = 0;
  }
  assert( rc!=SQLITE_OK || sqlite3PagerIswriteable((*ppPage)->pDbPage) );
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdx, -0x58(%rbp)
movq $0x0, -0x50(%rbp)
movq 0x18(%rdi), %r14
movl 0x3c(%rdi), %edx
movq 0x50(%r14), %rax
movl 0x24(%rax), %r15d
bswapl %r15d
movl %edx, -0x44(%rbp)
cmpl %edx, %r15d
jae 0x21eb5
movq %rsi, %r12
movq %rdi, %r13
testl %r15d, %r15d
je 0x21ede
cmpb $0x2, %r8b
movq %r12, -0x78(%rbp)
movl %r8d, -0x88(%rbp)
movl %ecx, -0x84(%rbp)
je 0x21fbf
movzbl %r8b, %eax
cmpl $0x1, %eax
jne 0x21eae
cmpl %ecx, -0x44(%rbp)
jae 0x2259f
xorl %ebx, %ebx
jmp 0x21fc1
leaq 0x57958(%rip), %rsi     # 0x79814
leaq 0x57676(%rip), %rcx     # 0x79539
movl $0xb, %ebx
movl $0xb, %edi
movl $0xd52e, %edx           # imm = 0xD52E
xorl %eax, %eax
callq 0xb8cc
jmp 0x2271f
xorl %ebx, %ebx
cmpb $0x0, 0x23(%r13)
sete %r15b
movq 0x68(%r14), %rdi
callq 0xdebf
testl %eax, %eax
jne 0x2261c
movl 0x3c(%r13), %esi
leal 0x1(%rsi), %eax
movl %eax, 0x3c(%r13)
movl 0x72935(%rip), %eax     # 0x94840
xorl %edx, %edx
divl 0x30(%r13)
movl %eax, %ecx
cmpl %eax, %esi
jne 0x21f1e
addl $0x2, %esi
movl %esi, 0x3c(%r13)
movb %r15b, %bl
cmpb $0x0, 0x21(%r13)
je 0x225f0
movl 0x3c(%r13), %esi
xorl %eax, %eax
cmpl $0x2, %esi
jb 0x21f68
movl 0x34(%r13), %eax
movl $0xcccccccd, %r8d       # imm = 0xCCCCCCCD
imulq %rax, %r8
shrq $0x22, %r8
incl %r8d
leal -0x2(%rsi), %edi
movl %edi, %eax
xorl %edx, %edx
divl %r8d
subl %edx, %edi
leal 0x1(%rdi), %eax
xorl %edx, %edx
cmpl %ecx, %eax
sete %dl
leal (%rdi,%rdx), %eax
addl $0x2, %eax
cmpl %esi, %eax
jne 0x225f0
leaq -0x80(%rbp), %rdx
movq $0x0, (%rdx)
movq %r13, %rdi
movl %ebx, %ecx
callq 0x2035c
testl %eax, %eax
jne 0x21faa
movq -0x80(%rbp), %r14
movq 0x68(%r14), %rdi
callq 0xdebf
movl %eax, %r15d
testq %r14, %r14
je 0x21fa7
movq 0x68(%r14), %rdi
callq 0xdcd4
movl %r15d, %eax
testl %eax, %eax
je 0x22730
xorl %ebx, %ebx
movl %eax, %r15d
movl %eax, %r14d
jmp 0x22624
movb $0x1, %bl
movq %r14, %r12
movq 0x68(%r14), %rdi
callq 0xdebf
testl %eax, %eax
je 0x21fe3
movl %eax, %r14d
movl $0x1, %edx
xorl %r15d, %r15d
movl %eax, %ebx
jmp 0x226a6
movq %r12, -0x70(%rbp)
movq 0x50(%r12), %rax
decl %r15d
bswapl %r15d
movl %r15d, 0x24(%rax)
movq %r13, -0x30(%rbp)
movq -0x50(%rbp), %rsi
testq %rsi, %rsi
je 0x22025
movq 0x50(%rsi), %rax
movzbl (%rax), %ecx
shll $0x18, %ecx
movzbl 0x1(%rax), %edx
shll $0x10, %edx
orl %ecx, %edx
movzbl 0x2(%rax), %ecx
shll $0x8, %ecx
orl %edx, %ecx
addq $0x3, %rax
jmp 0x2204a
movq -0x70(%rbp), %rax
movq 0x50(%rax), %rax
movzbl 0x20(%rax), %ecx
shll $0x18, %ecx
movzbl 0x21(%rax), %edx
shll $0x10, %edx
orl %ecx, %edx
movzbl 0x22(%rax), %ecx
shll $0x8, %ecx
orl %edx, %ecx
addq $0x23, %rax
movzbl (%rax), %r12d
orl %ecx, %r12d
cmpl -0x44(%rbp), %r12d
movq %rsi, -0x40(%rbp)
jbe 0x22082
movl $0xb, %r14d
movl $0xb, %edi
leaq 0x577a7(%rip), %rsi     # 0x79814
movl $0xd55f, %edx           # imm = 0xD55F
leaq 0x574c0(%rip), %rcx     # 0x79539
xorl %eax, %eax
callq 0xb8cc
jmp 0x22096
movq %r13, %rdi
movl %r12d, %esi
leaq -0x50(%rbp), %rdx
xorl %ecx, %ecx
callq 0x2035c
movl %eax, %r14d
testl %r14d, %r14d
jne 0x225d9
movq -0x50(%rbp), %r14
movq 0x50(%r14), %r15
movl 0x4(%r15), %r13d
bswapl %r13d
testb %bl, %bl
jne 0x22101
testl %r13d, %r13d
jne 0x22101
movq 0x68(%r14), %rdi
callq 0xdebf
testl %eax, %eax
movq -0x40(%rbp), %r15
jne 0x2269b
movq -0x58(%rbp), %rax
movl %r12d, (%rax)
movq -0x70(%rbp), %rax
movq 0x50(%rax), %rax
movq 0x50(%r14), %rcx
movl (%rcx), %ecx
movl %ecx, 0x20(%rax)
movq -0x78(%rbp), %rax
movq %r14, (%rax)
movq $0x0, -0x50(%rbp)
xorl %ebx, %ebx
xorl %r14d, %r14d
movq -0x30(%rbp), %r13
jmp 0x223d7
movq -0x30(%rbp), %rax
movl 0x34(%rax), %eax
shrl $0x2, %eax
addl $-0x2, %eax
cmpl %eax, %r13d
ja 0x22668
testb %bl, %bl
movl -0x88(%rbp), %r9d
movl -0x84(%rbp), %r10d
je 0x2213c
cmpb $0x2, %r9b
sete %al
cmpl %r10d, %r12d
setb %cl
je 0x22190
andb %cl, %al
jne 0x22190
testl %r13d, %r13d
je 0x2222f
xorl %r12d, %r12d
testl %r10d, %r10d
je 0x22310
cmpb $0x2, %r9b
movl $0x7fffffff, %r11d      # imm = 0x7FFFFFFF
jne 0x2223f
movl %r13d, %eax
movl $0x8, %ecx
xorl %edx, %edx
movl %ecx, %esi
andl $-0x4, %esi
movl (%r15,%rsi), %esi
bswapl %esi
cmpl %r10d, %esi
jbe 0x2230d
incq %rdx
addq $0x4, %rcx
cmpq %rdx, %rax
jne 0x2216b
jmp 0x22310
movq -0x58(%rbp), %rax
movl %r12d, (%rax)
movq -0x78(%rbp), %rax
movq %r14, (%rax)
movq %r14, %r12
movq 0x68(%r14), %rdi
callq 0xdebf
movl $0x4, %edx
testl %eax, %eax
movl -0x34(%rbp), %ebx
movq -0x40(%rbp), %r15
jne 0x2275e
testl %r13d, %r13d
je 0x222a6
movq 0x50(%r12), %rax
movzbl 0x8(%rax), %edi
movl %edi, %ecx
shll $0x18, %ecx
movzbl 0x9(%rax), %r8d
movl %r8d, %edx
shll $0x10, %edx
orl %ecx, %edx
movzbl 0xa(%rax), %ecx
movl %ecx, %esi
shll $0x8, %esi
orl %edx, %esi
movzbl 0xb(%rax), %r15d
orl %r15d, %esi
cmpl -0x44(%rbp), %esi
jbe 0x222cd
xorl %ebx, %ebx
movl $0xb, %r14d
movl $0xb, %edi
leaq 0x57602(%rip), %rsi     # 0x79814
movl $0xd59d, %edx           # imm = 0xD59D
leaq 0x5731b(%rip), %rcx     # 0x79539
xorl %eax, %eax
callq 0xb8cc
movl $0x4, %edx
jmp 0x222f8
xorl %r14d, %r14d
movq -0x30(%rbp), %r13
movq -0x40(%rbp), %r15
jmp 0x223d7
cmpl $0x1, %r13d
je 0x22310
movl 0x8(%r15), %ecx
bswapl %ecx
subl %r10d, %ecx
movl %ecx, %eax
negl %eax
cmovol %r11d, %eax
testl %ecx, %ecx
cmovnsl %ecx, %eax
movl %r13d, %ecx
xorl %r12d, %r12d
movl $0x1, %edx
movl $0xc, %esi
movl %esi, %edi
andl $-0x4, %edi
movl (%r15,%rdi), %edi
bswapl %edi
subl %r10d, %edi
movl %edi, %r8d
negl %r8d
cmovol %r11d, %r8d
testl %edi, %edi
cmovnsl %edi, %r8d
cmpl %eax, %r8d
cmovll %edx, %r12d
cmovll %r8d, %eax
incq %rdx
addq $0x4, %rsi
cmpq %rdx, %rcx
jne 0x2226f
jmp 0x22310
testq %r15, %r15
je 0x223b1
movq 0x68(%r15), %rdi
callq 0xdebf
testl %eax, %eax
movq -0x30(%rbp), %r13
jne 0x22766
movq 0x50(%r15), %rax
jmp 0x223c1
movl %ecx, -0x5c(%rbp)
movl %r8d, -0x60(%rbp)
movl %edi, -0x68(%rbp)
xorl %ebx, %ebx
movq -0x30(%rbp), %rdi
leaq -0x80(%rbp), %rdx
xorl %ecx, %ecx
callq 0x2035c
movl $0x4, %edx
testl %eax, %eax
je 0x2244e
movl %eax, %r14d
movq -0x30(%rbp), %r13
movq -0x40(%rbp), %r15
testb %bl, %bl
jne 0x223cd
jmp 0x226a3
movl %edx, %r12d
leal 0x8(,%r12,4), %esi
movl (%r15,%rsi), %eax
bswapl %eax
cmpl -0x44(%rbp), %eax
jbe 0x22352
xorl %r12d, %r12d
movl $0xb, %r14d
movl $0xb, %edi
leaq 0x574dc(%rip), %rsi     # 0x79814
movl $0xd5de, %edx           # imm = 0xD5DE
leaq 0x571f5(%rip), %rcx     # 0x79539
xorl %eax, %eax
callq 0xb8cc
movl $0x4, %edx
jmp 0x2239f
cmpb $0x2, %r9b
setne %cl
cmpl %r10d, %eax
setae %dl
je 0x2237d
orb %dl, %cl
je 0x2237d
testb %bl, %bl
je 0x2237d
xorl %edx, %edx
movb $0x1, %bl
xorl %r14d, %r14d
movq -0x30(%rbp), %r13
movq -0x40(%rbp), %r15
movb $0x1, %r12b
jmp 0x223a7
movq %rsi, -0x68(%rbp)
movq -0x58(%rbp), %rcx
movl %eax, (%rcx)
movq 0x68(%r14), %rdi
callq 0xdebf
testl %eax, %eax
je 0x223f4
movl %eax, %r14d
movl $0x4, %edx
xorl %r12d, %r12d
movq -0x30(%rbp), %r13
movq -0x40(%rbp), %r15
testb %r12b, %r12b
jne 0x223d7
jmp 0x226a3
movq -0x70(%rbp), %rax
movq 0x50(%rax), %rax
addq $0x20, %rax
movq -0x30(%rbp), %r13
movq 0x50(%r12), %rcx
movl (%rcx), %ecx
movl %ecx, (%rax)
xorl %r14d, %r14d
movq $0x0, -0x50(%rbp)
xorl %ebx, %ebx
testq %r15, %r15
je 0x223e5
movq 0x68(%r15), %rdi
callq 0xdcd4
testb %bl, %bl
movb $0x1, %bl
jne 0x21ffa
jmp 0x225e6
leal -0x1(%r13), %eax
cmpl %eax, %r12d
jae 0x22411
leal 0x4(,%r13,4), %ecx
movl (%r15,%rcx), %ecx
movq -0x68(%rbp), %rdx
movl %ecx, (%r15,%rdx)
bswapl %eax
movl %eax, 0x4(%r15)
movq -0x58(%rbp), %rax
movl (%rax), %r14d
movq -0x30(%rbp), %r13
movq 0x58(%r13), %rdi
testq %rdi, %rdi
movq -0x78(%rbp), %rbx
movb $0x1, %r12b
je 0x22484
xorl %ecx, %ecx
cmpl %r14d, (%rdi)
movq -0x40(%rbp), %r15
jb 0x2248d
movl %r14d, %esi
callq 0x1b2c2
xorl %ecx, %ecx
testl %eax, %eax
sete %cl
jmp 0x2248d
movq -0x80(%rbp), %rbx
movq 0x68(%rbx), %rdi
callq 0xdebf
testl %eax, %eax
je 0x224d5
movl %eax, %r14d
testq %rbx, %rbx
movq -0x40(%rbp), %r15
je 0x22474
movq 0x68(%rbx), %rdi
callq 0xdcd4
xorl %ebx, %ebx
movq -0x30(%rbp), %r13
movl $0x4, %edx
jmp 0x22300
movl $0x1, %ecx
movq -0x40(%rbp), %r15
movq %r13, %rdi
movl %r14d, %esi
movq %rbx, %rdx
callq 0x2035c
testl %eax, %eax
je 0x224ab
movl %eax, %r14d
xorl %ebx, %ebx
xorl %edx, %edx
jmp 0x223a7
movq (%rbx), %rax
movq 0x68(%rax), %rdi
callq 0xdebf
testl %eax, %eax
je 0x22546
movl %eax, %r14d
movq (%rbx), %rax
testq %rax, %rax
je 0x224a2
movq 0x68(%rax), %rdi
callq 0xdcd4
jmp 0x224a2
movq 0x50(%rbx), %rax
movq 0x50(%r12), %rcx
movl (%rcx), %ecx
movl %ecx, (%rax)
movq 0x50(%rbx), %rax
leal -0x1(%r13), %ecx
bswapl %ecx
movl %ecx, 0x4(%rax)
movq 0x50(%rbx), %rdi
addq $0x8, %rdi
movq 0x50(%r12), %rsi
addq $0xc, %rsi
leal -0x4(,%r13,4), %edx
callq 0x82f0
testq %rbx, %rbx
je 0x2251b
movq 0x68(%rbx), %rdi
callq 0xdcd4
movq -0x40(%rbp), %r12
testq %r12, %r12
movq -0x30(%rbp), %r13
je 0x22552
movq 0x68(%r12), %rdi
callq 0xdebf
xorl %r14d, %r14d
testl %eax, %eax
je 0x22579
xorl %ebx, %ebx
movl %eax, %r14d
movq %r12, %r15
jmp 0x2247a
xorl %ebx, %ebx
xorl %edx, %edx
xorl %r14d, %r14d
jmp 0x223a7
movq -0x70(%rbp), %rax
movq 0x50(%rax), %rax
movl -0x68(%rbp), %ecx
movb %cl, 0x20(%rax)
movl -0x60(%rbp), %ecx
movb %cl, 0x21(%rax)
movl -0x5c(%rbp), %ecx
movb %cl, 0x22(%rax)
movb %r15b, 0x23(%rax)
xorl %edx, %edx
movb $0x1, %bl
xorl %r14d, %r14d
jmp 0x22597
movq 0x50(%r12), %rax
movl -0x68(%rbp), %ecx
movb %cl, (%rax)
movl -0x60(%rbp), %ecx
movb %cl, 0x1(%rax)
movl -0x5c(%rbp), %ecx
movb %cl, 0x2(%rax)
movb %r15b, 0x3(%rax)
movb $0x1, %bl
xorl %edx, %edx
movq %r12, %r15
jmp 0x22300
movl %ecx, %esi
leaq -0x80(%rbp), %r12
movq %r13, %rdi
movq %r12, %rdx
xorl %ecx, %ecx
callq 0x21d4e
testl %eax, %eax
sete %bl
cmpb $0x2, (%r12)
sete %cl
movl $0x1, %edx
testl %eax, %eax
je 0x2265e
movl %eax, %r14d
movl %eax, %ebx
xorl %r15d, %r15d
jmp 0x226a6
movq $0x0, -0x50(%rbp)
jmp 0x2268d
xorl %edx, %edx
xorl %r15d, %r15d
jmp 0x226a3
movq 0x18(%r13), %rax
movq 0x50(%rax), %rax
movl 0x3c(%r13), %ecx
bswapl %ecx
movl %ecx, 0x1c(%rax)
movl 0x3c(%r13), %esi
movq -0x58(%rbp), %rax
movl %esi, (%rax)
movq %r13, %rdi
movq %r12, %rdx
movl %ebx, %ecx
callq 0x2035c
testl %eax, %eax
je 0x22634
movl %eax, %r14d
xorl %ebx, %ebx
movl %eax, %r15d
testb %bl, %bl
movl %r15d, %ebx
je 0x2271f
xorl %r15d, %r15d
jmp 0x226af
movq (%r12), %rax
movq 0x68(%rax), %rdi
callq 0xdebf
movl %eax, %r14d
movb $0x1, %bl
testl %eax, %eax
je 0x22624
movq (%r12), %rax
testq %rax, %rax
je 0x22624
movq 0x68(%rax), %rdi
callq 0xdcd4
jmp 0x22624
movl %eax, -0x34(%rbp)
andb %cl, %bl
jmp 0x21fc1
leaq 0x571a5(%rip), %rsi     # 0x79814
leaq 0x56ec3(%rip), %rcx     # 0x79539
movl $0xb, %r14d
movl $0xb, %edi
movl $0xd57b, %edx           # imm = 0xD57B
xorl %eax, %eax
callq 0xb8cc
movl $0x4, %edx
movl -0x34(%rbp), %ebx
movq -0x40(%rbp), %r15
jmp 0x226a6
movl %eax, %r14d
movl $0x4, %edx
movl -0x34(%rbp), %ebx
testb $0x3, %dl
movq -0x78(%rbp), %r12
jne 0x2271f
movq -0x50(%rbp), %rax
testq %rax, %rax
je 0x226c1
movq 0x68(%rax), %rdi
callq 0xdcd4
testq %r15, %r15
je 0x226cf
movq 0x68(%r15), %rdi
callq 0xdcd4
testl %r14d, %r14d
je 0x226de
movq $0x0, (%r12)
jmp 0x2271c
movq (%r12), %rax
movq 0x68(%rax), %rdi
cmpw $0x2, 0x2e(%rdi)
jl 0x22719
testq %rax, %rax
je 0x226f7
callq 0xdcd4
leaq 0x57116(%rip), %rsi     # 0x79814
leaq 0x56e34(%rip), %rcx     # 0x79539
movl $0xb, %ebx
movl $0xb, %edi
movl $0xd640, %edx           # imm = 0xD640
jmp 0x21ed2
movb $0x0, (%rax)
movl %r14d, %ebx
movl %ebx, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %eax, %r15d
movl 0x3c(%r13), %ecx
leal 0x1(%rcx), %eax
movl %eax, 0x3c(%r13)
movl 0x720fc(%rip), %eax     # 0x94840
xorl %edx, %edx
divl 0x30(%r13)
cmpl %eax, %ecx
jne 0x225f0
addl $0x2, %ecx
movl %ecx, 0x3c(%r13)
jmp 0x225f0
movl %eax, %r14d
jmp 0x226a6
movl %eax, %r14d
movl $0x4, %edx
jmp 0x226a6