// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/external/sqlite-3.33.0/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);
  /* EVIDENCE-OF: R-05119-02637 The 4-byte big-endian integer at offset 36
  ** stores stores the total number of pages on the freelist. */
  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' */
    u32 nSearch = 0;   /* Count of the number of search attempts */

    /* 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 ){
        /* EVIDENCE-OF: R-01506-11053 The first integer on a freelist trunk page
        ** is the page number of the next freelist trunk page in the list or
        ** zero if this is the last freelist trunk page. */
        iTrunk = get4byte(&pPrevTrunk->aData[0]);
      }else{
        /* EVIDENCE-OF: R-59841-13798 The 4-byte big-endian integer at offset 32
        ** stores the page number of the first page of the freelist, or zero if
        ** the freelist is empty. */
        iTrunk = get4byte(&pPage1->aData[32]);
      }
      testcase( iTrunk==mxPage );
      if( iTrunk>mxPage || nSearch++ > n ){
        rc = SQLITE_CORRUPT_PGNO(pPrevTrunk ? pPrevTrunk->pgno : 1);
      }else{
        rc = btreeGetUnusedPage(pBt, iTrunk, &pTrunk, 0);
      }
      if( rc ){
        pTrunk = 0;
        goto end_allocate_page;
      }
      assert( pTrunk!=0 );
      assert( pTrunk->aData!=0 );
      /* EVIDENCE-OF: R-13523-04394 The second integer on a freelist trunk page
      ** is the number of leaf page pointers to follow. */
      k = get4byte(&pTrunk->aData[4]);
      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_PGNO(iTrunk);
        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_PGNO(iTrunk);
            goto end_allocate_page;
          }
          testcase( iNewTrunk==mxPage );
          rc = btreeGetUnusedPage(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_PGNO(iTrunk);
          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 = btreeGetUnusedPage(pBt, *pPgno, ppPage, noContent);
          if( rc==SQLITE_OK ){
            rc = sqlite3PagerWrite((*ppPage)->pDbPage);
            if( rc!=SQLITE_OK ){
              releasePage(*ppPage);
              *ppPage = 0;
            }
          }
          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 = btreeGetUnusedPage(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 = btreeGetUnusedPage(pBt, *pPgno, ppPage, bNoContent);
    if( rc ) return rc;
    rc = sqlite3PagerWrite((*ppPage)->pDbPage);
    if( rc!=SQLITE_OK ){
      releasePage(*ppPage);
      *ppPage = 0;
    }
    TRACE(("ALLOCATE: %d from end of file\n", *pPgno));
  }

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

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdx, 0x38(%rsp)
movq %rsi, %r15
movq $0x0, 0x20(%rsp)
movq 0x18(%rdi), %r14
movl 0x40(%rdi), %edx
movq 0x50(%r14), %rax
movl 0x24(%rax), %esi
bswapl %esi
movl %edx, 0x14(%rsp)
cmpl %edx, %esi
jae 0x298489
movq %rdi, %r12
testl %esi, %esi
je 0x2984ba
movl %r8d, %ebx
cmpb $0x2, %bl
movl %ecx, 0x6c(%rsp)
movq %rsi, 0x70(%rsp)
je 0x2985a6
movzbl %bl, %eax
cmpl $0x1, %eax
jne 0x29847c
cmpl %ecx, 0x14(%rsp)
jae 0x298bc6
movq %r12, 0x18(%rsp)
xorl %r13d, %r13d
jmp 0x2985ae
leaq 0x146e8f(%rip), %rsi    # 0x3df31f
leaq 0x146f99(%rip), %rdx    # 0x3df430
leaq 0x146ce7(%rip), %r8     # 0x3df185
movl $0xb, %r13d
movl $0xb, %edi
movl $0x11313, %ecx          # imm = 0x11313
xorl %eax, %eax
callq 0x27e637
jmp 0x298d23
xorl %ebx, %ebx
cmpb $0x0, 0x23(%r12)
movq %r14, %rax
sete %r14b
movq 0x70(%rax), %rdi
callq 0x280e3a
testl %eax, %eax
jne 0x298c5a
movl 0x40(%r12), %esi
leal 0x1(%rsi), %eax
movl %eax, 0x40(%r12)
movl 0x22e5d3(%rip), %eax    # 0x4c6ac0
xorl %edx, %edx
divl 0x34(%r12)
movl %eax, %ecx
cmpl %eax, %esi
jne 0x298502
addl $0x2, %esi
movl %esi, 0x40(%r12)
movb %r14b, %bl
cmpb $0x0, 0x21(%r12)
je 0x298c2a
movl 0x40(%r12), %esi
xorl %eax, %eax
cmpl $0x2, %esi
jb 0x29854f
movl 0x38(%r12), %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 0x298c2a
leaq 0x50(%rsp), %rdx
movq $0x0, (%rdx)
movq %r12, %rdi
movl %ebx, %ecx
callq 0x299077
movl %eax, %r13d
testl %eax, %eax
jne 0x298593
movq 0x50(%rsp), %r14
movq 0x70(%r14), %rdi
callq 0x280e3a
movl %eax, %r13d
testq %r14, %r14
je 0x298593
movq 0x70(%r14), %rdi
callq 0x2949b7
testl %r13d, %r13d
je 0x298d35
xorl %ebx, %ebx
movl %r13d, %ebp
jmp 0x298c61
movq %r12, 0x18(%rsp)
movb $0x1, %r13b
movq 0x70(%r14), %rdi
callq 0x280e3a
testl %eax, %eax
je 0x2985ce
movl %eax, %ebp
movl $0x1, %r15d
xorl %r14d, %r14d
movl %eax, %r13d
jmp 0x298cf9
movl %ebx, 0x2c(%rsp)
movq %r15, 0x58(%rsp)
movq %r14, 0x30(%rsp)
movq 0x50(%r14), %rax
movq 0x70(%rsp), %rcx
decl %ecx
bswapl %ecx
movl %ecx, 0x24(%rax)
movq $0x0, 0x60(%rsp)
movq 0x20(%rsp), %r14
testq %r14, %r14
je 0x298621
movq 0x50(%r14), %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 0x298647
movq 0x30(%rsp), %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), %r15d
orl %ecx, %r15d
cmpl 0x14(%rsp), %r15d
ja 0x29866a
movq 0x60(%rsp), %rax
leal 0x1(%rax), %ebx
cmpl 0x70(%rsp), %eax
jbe 0x298697
movl %ebx, %eax
movq %rax, 0x60(%rsp)
movl $0xb, %ebp
movl $0xb, %edi
leaq 0x146ca4(%rip), %rsi    # 0x3df31f
leaq 0x146dae(%rip), %rdx    # 0x3df430
movl $0x1134b, %ecx          # imm = 0x1134B
leaq 0x146af7(%rip), %r8     # 0x3df185
xorl %eax, %eax
callq 0x27e637
jmp 0x2986b4
movq 0x18(%rsp), %rdi
movl %r15d, %esi
leaq 0x20(%rsp), %rdx
xorl %ecx, %ecx
callq 0x299077
movl %eax, %ebp
movl %ebx, %eax
movq %rax, 0x60(%rsp)
testl %ebp, %ebp
jne 0x298c09
movq %r14, 0x8(%rsp)
movq 0x20(%rsp), %r14
movq 0x50(%r14), %r12
movl 0x4(%r12), %ebx
bswapl %ebx
testb %r13b, %r13b
jne 0x29871e
testl %ebx, %ebx
jne 0x29871e
movq 0x70(%r14), %rdi
callq 0x280e3a
testl %eax, %eax
jne 0x298ce7
movq 0x38(%rsp), %rax
movl %r15d, (%rax)
movq 0x30(%rsp), %rax
movq 0x50(%rax), %rax
movq 0x50(%r14), %rcx
movl (%rcx), %ecx
movl %ecx, 0x20(%rax)
movq 0x58(%rsp), %rax
movq %r14, (%rax)
movq $0x0, 0x20(%rsp)
xorl %r13d, %r13d
jmp 0x2987a1
movq 0x18(%rsp), %rax
movl 0x38(%rax), %eax
shrl $0x2, %eax
addl $-0x2, %eax
cmpl %eax, %ebx
ja 0x298cba
testb %r13b, %r13b
movl 0x6c(%rsp), %r9d
je 0x298752
cmpb $0x2, 0x2c(%rsp)
sete %al
cmpl %r9d, %r15d
setb %cl
je 0x2987ad
andb %cl, %al
jne 0x2987ad
testl %ebx, %ebx
je 0x2987a1
xorl %r15d, %r15d
testl %r9d, %r9d
je 0x29892b
cmpb $0x2, 0x2c(%rsp)
movl $0x7fffffff, %r10d      # imm = 0x7FFFFFFF
jne 0x298851
movl %ebx, %eax
movl $0x8, %ecx
xorl %edx, %edx
movl %ecx, %esi
andl $-0x4, %esi
movl (%r12,%rsi), %esi
bswapl %esi
cmpl %r9d, %esi
jbe 0x298928
incq %rdx
addq $0x4, %rcx
cmpq %rdx, %rax
jne 0x29877c
jmp 0x29892b
xorl %ebp, %ebp
movq 0x8(%rsp), %r14
jmp 0x2989f7
movq 0x38(%rsp), %rax
movl %r15d, (%rax)
movq 0x58(%rsp), %rax
movq %r14, (%rax)
movq 0x70(%r14), %rdi
callq 0x280e3a
movl $0x4, %r15d
testl %eax, %eax
movl 0x4(%rsp), %r13d
jne 0x298d64
testl %ebx, %ebx
je 0x2988b7
movq 0x50(%r14), %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), %r13d
orl %r13d, %esi
cmpl 0x14(%rsp), %esi
jbe 0x2988df
xorl %r12d, %r12d
movl $0xb, %ebp
movl $0xb, %edi
leaq 0x146af3(%rip), %rsi    # 0x3df31f
leaq 0x146bfd(%rip), %rdx    # 0x3df430
movl $0x1138a, %ecx          # imm = 0x1138A
leaq 0x146946(%rip), %r8     # 0x3df185
xorl %eax, %eax
callq 0x27e637
movl $0x4, %r15d
jmp 0x298910
cmpl $0x1, %ebx
je 0x29892b
movl 0x8(%r12), %ecx
bswapl %ecx
subl %r9d, %ecx
movl %ecx, %eax
negl %eax
cmovol %r10d, %eax
testl %ecx, %ecx
cmovnsl %ecx, %eax
movl %ebx, %ecx
xorl %r15d, %r15d
movl $0x1, %edx
movl $0xc, %esi
movl %esi, %edi
andl $-0x4, %edi
movl (%r12,%rdi), %edi
bswapl %edi
subl %r9d, %edi
movl %edi, %r8d
negl %r8d
cmovol %r10d, %r8d
testl %edi, %edi
cmovnsl %edi, %r8d
cmpl %eax, %r8d
cmovll %edx, %r15d
cmovll %r8d, %eax
incq %rdx
addq $0x4, %rsi
cmpq %rdx, %rcx
jne 0x298880
jmp 0x29892b
movq 0x8(%rsp), %rbx
testq %rbx, %rbx
je 0x2989cf
movq 0x70(%rbx), %rdi
callq 0x280e3a
testl %eax, %eax
jne 0x298d68
movq 0x50(%rbx), %rax
jmp 0x2989dc
movl %ecx, 0x40(%rsp)
movl %r8d, 0x44(%rsp)
movl %edi, 0x48(%rsp)
xorl %r12d, %r12d
movq 0x18(%rsp), %rdi
leaq 0x50(%rsp), %rdx
xorl %ecx, %ecx
callq 0x299077
movl $0x4, %r15d
testl %eax, %eax
je 0x298a69
movl %eax, %ebp
movl 0x4(%rsp), %r13d
movq 0x8(%rsp), %r14
testb %r12b, %r12b
jne 0x2989eb
jmp 0x298cf9
movl %edx, %r15d
leal 0x8(,%r15,4), %esi
movl (%r12,%rsi), %eax
bswapl %eax
cmpl 0x14(%rsp), %eax
jbe 0x298974
xorl %ebx, %ebx
movl $0xb, %ebp
movl $0xb, %edi
leaq 0x1469cd(%rip), %rsi    # 0x3df31f
leaq 0x146ad7(%rip), %rdx    # 0x3df430
movl $0x113cb, %ecx          # imm = 0x113CB
leaq 0x146820(%rip), %r8     # 0x3df185
xorl %eax, %eax
callq 0x27e637
movl $0x4, %r15d
jmp 0x2989c1
cmpb $0x2, 0x2c(%rsp)
setne %cl
cmpl %r9d, %eax
setae %dl
je 0x29899e
orb %dl, %cl
je 0x29899e
testb %r13b, %r13b
je 0x29899e
xorl %r15d, %r15d
movb $0x1, %r13b
xorl %ebp, %ebp
movq 0x8(%rsp), %r14
movb $0x1, %bl
jmp 0x2989c6
movq %rsi, 0x48(%rsp)
movq 0x38(%rsp), %rcx
movl %eax, (%rcx)
movq 0x70(%r14), %rdi
callq 0x280e3a
testl %eax, %eax
je 0x298a16
movl %eax, %ebp
movl $0x4, %r15d
xorl %ebx, %ebx
movq 0x8(%rsp), %r14
testb %bl, %bl
jne 0x2989f7
jmp 0x298c20
movq 0x30(%rsp), %rax
movq 0x50(%rax), %rax
addq $0x20, %rax
movq 0x50(%r14), %rcx
movl (%rcx), %ecx
movl %ecx, (%rax)
xorl %ebp, %ebp
movq 0x8(%rsp), %r14
movq $0x0, 0x20(%rsp)
xorl %r13d, %r13d
testq %r14, %r14
je 0x298a05
movq 0x70(%r14), %rdi
callq 0x2949b7
testb %r13b, %r13b
movb $0x1, %r13b
jne 0x2985f5
jmp 0x298c1a
leal -0x1(%rbx), %eax
cmpl %eax, %r15d
jae 0x298a32
leal 0x4(,%rbx,4), %ecx
movl (%r12,%rcx), %ecx
movq 0x48(%rsp), %rdx
movl %ecx, (%r12,%rdx)
bswapl %eax
movl %eax, 0x4(%r12)
movq 0x38(%rsp), %rax
movl (%rax), %ebp
movq 0x18(%rsp), %r14
movq 0x60(%r14), %rdi
testq %rdi, %rdi
movq 0x58(%rsp), %rbx
je 0x298a9a
xorl %ecx, %ecx
cmpl %ebp, (%rdi)
jb 0x298a9f
movl %ebp, %esi
callq 0x290715
xorl %ecx, %ecx
testl %eax, %eax
sete %cl
jmp 0x298a9f
movq 0x50(%rsp), %r12
movq 0x70(%r12), %rdi
callq 0x280e3a
testl %eax, %eax
je 0x298afb
movl %eax, %ebp
testq %r12, %r12
movl 0x4(%rsp), %r13d
je 0x298a92
movq 0x70(%r12), %rdi
callq 0x2949b7
xorl %r12d, %r12d
jmp 0x298915
movl $0x1, %ecx
movq %r14, %rdi
movl %ebp, %esi
movq %rbx, %rdx
callq 0x299077
testl %eax, %eax
je 0x298abd
movl %eax, %ebp
xorl %r13d, %r13d
xorl %r15d, %r15d
jmp 0x298995
movq (%rbx), %rax
movq 0x70(%rax), %rdi
callq 0x280e3a
testl %eax, %eax
movq 0x8(%rsp), %r14
je 0x298b61
movl %eax, %ebp
movq (%rbx), %rax
testq %rax, %rax
je 0x298ae9
movq 0x70(%rax), %rdi
callq 0x2949b7
movq $0x0, (%rbx)
xorl %r13d, %r13d
xorl %r15d, %r15d
jmp 0x29899a
movq 0x50(%r12), %rax
movq 0x50(%r14), %rcx
movl (%rcx), %ecx
movl %ecx, (%rax)
movq 0x50(%r12), %rax
leal -0x1(%rbx), %ecx
bswapl %ecx
movl %ecx, 0x4(%rax)
movq 0x50(%r12), %rdi
addq $0x8, %rdi
movq 0x50(%r14), %rsi
addq $0xc, %rsi
leal -0x4(,%rbx,4), %edx
callq 0x17660
testq %r12, %r12
je 0x298b41
movq 0x70(%r12), %rdi
callq 0x2949b7
movq 0x8(%rsp), %r14
testq %r14, %r14
je 0x298b6e
movq 0x70(%r14), %rdi
callq 0x280e3a
xorl %ebp, %ebp
testl %eax, %eax
je 0x298b9a
xorl %r12d, %r12d
movl %eax, %ebp
jmp 0x298bbc
xorl %r13d, %r13d
xorl %r15d, %r15d
xorl %ebp, %ebp
jmp 0x29899a
movq 0x30(%rsp), %rax
movq 0x50(%rax), %rax
movl 0x48(%rsp), %ecx
movb %cl, 0x20(%rax)
movl 0x44(%rsp), %ecx
movb %cl, 0x21(%rax)
movl 0x40(%rsp), %ecx
movb %cl, 0x22(%rax)
movb %r13b, 0x23(%rax)
xorl %r15d, %r15d
movb $0x1, %r12b
xorl %ebp, %ebp
jmp 0x298bbc
movq 0x50(%r14), %rax
movl 0x48(%rsp), %ecx
movb %cl, (%rax)
movl 0x44(%rsp), %ecx
movb %cl, 0x1(%rax)
movl 0x40(%rsp), %ecx
movb %cl, 0x2(%rax)
movb %r13b, 0x3(%rax)
movb $0x1, %r12b
xorl %r15d, %r15d
movl 0x4(%rsp), %r13d
jmp 0x29891a
movl %ecx, %esi
movq %r14, 0x30(%rsp)
movl %ebx, %ebp
movq %r15, %rbx
xorl %r14d, %r14d
leaq 0x50(%rsp), %r15
movq %r12, %rdi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0x298318
testl %eax, %eax
sete %r13b
cmpb $0x2, (%r15)
sete %cl
movl $0x1, %r15d
testl %eax, %eax
je 0x298c9f
movl %eax, %ebp
jmp 0x2985c6
movq $0x0, 0x20(%rsp)
movl $0x4, %r15d
jmp 0x298c20
xorl %r15d, %r15d
xorl %r14d, %r14d
movl 0x4(%rsp), %r13d
jmp 0x298cf9
movq 0x18(%r12), %rax
movq 0x50(%rax), %rax
movl 0x40(%r12), %ecx
bswapl %ecx
movl %ecx, 0x1c(%rax)
movl 0x40(%r12), %esi
movq 0x38(%rsp), %rax
movl %esi, (%rax)
movq %r12, %rdi
movq %r15, %rdx
movl %ebx, %ecx
callq 0x299077
testl %eax, %eax
je 0x298c71
movl %eax, %ebp
xorl %ebx, %ebx
movl %eax, %r13d
testb %bl, %bl
je 0x298d23
xorl %r14d, %r14d
jmp 0x298cff
movq (%r15), %rax
movq 0x70(%rax), %rdi
callq 0x280e3a
movl %eax, %ebp
movb $0x1, %bl
testl %eax, %eax
je 0x298c61
movq (%r15), %rax
testq %rax, %rax
je 0x298c96
movq 0x70(%rax), %rdi
callq 0x2949b7
movq $0x0, (%r15)
jmp 0x298c61
movq %r12, 0x18(%rsp)
movl %eax, 0x4(%rsp)
andb %cl, %r13b
movq %rbx, %r15
movl %ebp, %ebx
movq 0x30(%rsp), %r14
jmp 0x2985ae
leaq 0x14665e(%rip), %rsi    # 0x3df31f
leaq 0x146768(%rip), %rdx    # 0x3df430
leaq 0x1464b6(%rip), %r8     # 0x3df185
movl $0xb, %ebp
movl $0xb, %edi
movl $0x11368, %ecx          # imm = 0x11368
xorl %eax, %eax
callq 0x27e637
jmp 0x298ce9
movl %eax, %ebp
movl $0x4, %r15d
movl 0x4(%rsp), %r13d
movq 0x8(%rsp), %r14
testb $0x3, %r15b
jne 0x298d23
movq 0x20(%rsp), %rax
testq %rax, %rax
je 0x298d12
movq 0x70(%rax), %rdi
callq 0x2949b7
testq %r14, %r14
je 0x298d20
movq 0x70(%r14), %rdi
callq 0x2949b7
movl %ebp, %r13d
movl %r13d, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x40(%r12), %ecx
leal 0x1(%rcx), %eax
movl %eax, 0x40(%r12)
movl 0x22dd78(%rip), %eax    # 0x4c6ac0
xorl %edx, %edx
divl 0x34(%r12)
cmpl %eax, %ecx
jne 0x298c2a
addl $0x2, %ecx
movl %ecx, 0x40(%r12)
jmp 0x298c2a
movl %eax, %ebp
jmp 0x298cf4
movl %eax, %ebp
movq %rbx, %r14
jmp 0x298cf9