// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xb0, %rsp
movb %r8b, %al
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movb %al, -0x25(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
callq 0x3e7da0
movl %eax, -0x54(%rbp)
movq -0x30(%rbp), %rax
movq 0x50(%rax), %rdi
addq $0x24, %rdi
callq 0x3db720
movl %eax, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x54(%rbp), %eax
jb 0x3e9c36
movl $0x11313, %edi          # imm = 0x11313
callq 0x3dff80
movl %eax, -0x4(%rbp)
jmp 0x3ea480
cmpl $0x0, -0x38(%rbp)
jbe 0x3ea287
movb $0x0, -0x59(%rbp)
movl $0x0, -0x60(%rbp)
movzbl -0x25(%rbp), %eax
cmpl $0x1, %eax
jne 0x3e9c95
movl -0x24(%rbp), %eax
cmpl -0x54(%rbp), %eax
ja 0x3e9c93
movq -0x10(%rbp), %rdi
movl -0x24(%rbp), %esi
leaq -0x61(%rbp), %rdx
xorl %eax, %eax
movl %eax, %ecx
callq 0x3e9a70
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x3e9c84
movl -0x34(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x3ea480
movzbl -0x61(%rbp), %eax
cmpl $0x2, %eax
jne 0x3e9c91
movb $0x1, -0x59(%rbp)
jmp 0x3e9c93
jmp 0x3e9ca4
movzbl -0x25(%rbp), %eax
cmpl $0x2, %eax
jne 0x3e9ca2
movb $0x1, -0x59(%rbp)
jmp 0x3e9ca4
movq -0x30(%rbp), %rax
movq 0x70(%rax), %rdi
callq 0x3c6610
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x3e9cc5
movl -0x34(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x3ea480
movq -0x30(%rbp), %rax
movq 0x50(%rax), %rdi
addq $0x24, %rdi
movl -0x38(%rbp), %esi
subl $0x1, %esi
callq 0x3dd200
movq -0x48(%rbp), %rax
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
je 0x3e9cfd
movq -0x50(%rbp), %rax
movq 0x50(%rax), %rdi
callq 0x3db720
movl %eax, -0x58(%rbp)
jmp 0x3e9d11
movq -0x30(%rbp), %rax
movq 0x50(%rax), %rdi
addq $0x20, %rdi
callq 0x3db720
movl %eax, -0x58(%rbp)
movl -0x58(%rbp), %eax
cmpl -0x54(%rbp), %eax
ja 0x3e9d29
movl -0x60(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x60(%rbp)
cmpl -0x38(%rbp), %eax
jbe 0x3e9d38
movl $0x1134b, %edi          # imm = 0x1134B
callq 0x3dff80
movl %eax, -0x34(%rbp)
jmp 0x3e9d4d
movq -0x10(%rbp), %rdi
movl -0x58(%rbp), %esi
leaq -0x48(%rbp), %rdx
xorl %ecx, %ecx
callq 0x3ea630
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x3e9d60
movq $0x0, -0x48(%rbp)
jmp 0x3ea468
movq -0x48(%rbp), %rax
movq 0x50(%rax), %rdi
addq $0x4, %rdi
callq 0x3db720
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
jne 0x3e9dd1
cmpb $0x0, -0x59(%rbp)
jne 0x3e9dd1
movq -0x48(%rbp), %rax
movq 0x70(%rax), %rdi
callq 0x3c6610
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x3e9d9b
jmp 0x3ea468
movl -0x58(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movq -0x30(%rbp), %rax
movq 0x50(%rax), %rax
movq -0x48(%rbp), %rcx
movq 0x50(%rcx), %rcx
movl (%rcx), %ecx
movl %ecx, 0x20(%rax)
movq -0x48(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq $0x0, -0x48(%rbp)
jmp 0x3ea267
movl -0x3c(%rbp), %eax
movq -0x10(%rbp), %rcx
movl 0x38(%rcx), %ecx
shrl $0x2, %ecx
subl $0x2, %ecx
cmpl %ecx, %eax
jbe 0x3e9df7
movl $0x11368, %edi          # imm = 0x11368
callq 0x3dff80
movl %eax, -0x34(%rbp)
jmp 0x3ea468
movzbl -0x59(%rbp), %eax
cmpl $0x0, %eax
je 0x3e9fd7
movl -0x24(%rbp), %eax
cmpl -0x58(%rbp), %eax
je 0x3e9e25
movl -0x58(%rbp), %eax
cmpl -0x24(%rbp), %eax
jae 0x3e9fd7
movzbl -0x25(%rbp), %eax
cmpl $0x2, %eax
jne 0x3e9fd7
movl -0x58(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movq -0x48(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movb $0x0, -0x59(%rbp)
movq -0x48(%rbp), %rax
movq 0x70(%rax), %rdi
callq 0x3c6610
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x3e9e58
jmp 0x3ea468
cmpl $0x0, -0x3c(%rbp)
jne 0x3e9eb0
cmpq $0x0, -0x50(%rbp)
jne 0x3e9e7c
movq -0x30(%rbp), %rax
movq 0x50(%rax), %rax
movq -0x48(%rbp), %rcx
movq 0x50(%rcx), %rcx
movl (%rcx), %ecx
movl %ecx, 0x20(%rax)
jmp 0x3e9eab
movq -0x50(%rbp), %rax
movq 0x70(%rax), %rdi
callq 0x3c6610
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x3e9e97
jmp 0x3ea468
movq -0x50(%rbp), %rax
movq 0x50(%rax), %rax
movq -0x48(%rbp), %rcx
movq 0x50(%rcx), %rcx
movl (%rcx), %ecx
movl %ecx, (%rax)
jmp 0x3e9fca
movq -0x48(%rbp), %rax
movq 0x50(%rax), %rdi
addq $0x8, %rdi
callq 0x3db720
movl %eax, -0x74(%rbp)
movl -0x74(%rbp), %eax
cmpl -0x54(%rbp), %eax
jbe 0x3e9ede
movl $0x1138a, %edi          # imm = 0x1138A
callq 0x3dff80
movl %eax, -0x34(%rbp)
jmp 0x3ea468
movq -0x10(%rbp), %rdi
movl -0x74(%rbp), %esi
leaq -0x70(%rbp), %rdx
xorl %ecx, %ecx
callq 0x3ea630
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x3e9efe
jmp 0x3ea468
movq -0x70(%rbp), %rax
movq 0x70(%rax), %rdi
callq 0x3c6610
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x3e9f22
movq -0x70(%rbp), %rdi
callq 0x3e9b70
jmp 0x3ea468
movq -0x70(%rbp), %rax
movq 0x50(%rax), %rax
movq -0x48(%rbp), %rcx
movq 0x50(%rcx), %rcx
movl (%rcx), %ecx
movl %ecx, (%rax)
movq -0x70(%rbp), %rax
movq 0x50(%rax), %rdi
addq $0x4, %rdi
movl -0x3c(%rbp), %esi
subl $0x1, %esi
callq 0x3dd200
movq -0x70(%rbp), %rax
movq 0x50(%rax), %rdi
addq $0x8, %rdi
movq -0x48(%rbp), %rax
movq 0x50(%rax), %rsi
addq $0xc, %rsi
movl -0x3c(%rbp), %eax
subl $0x1, %eax
shll $0x2, %eax
movl %eax, %eax
movl %eax, %edx
callq 0x19610
movq -0x70(%rbp), %rdi
callq 0x3e9b70
cmpq $0x0, -0x50(%rbp)
jne 0x3e9f9d
movq -0x30(%rbp), %rax
movq 0x50(%rax), %rdi
addq $0x20, %rdi
movl -0x74(%rbp), %esi
callq 0x3dd200
jmp 0x3e9fc8
movq -0x50(%rbp), %rax
movq 0x70(%rax), %rdi
callq 0x3c6610
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x3e9fb8
jmp 0x3ea468
movq -0x50(%rbp), %rax
movq 0x50(%rax), %rdi
movl -0x74(%rbp), %esi
callq 0x3dd200
jmp 0x3e9fca
movq $0x0, -0x48(%rbp)
jmp 0x3ea263
cmpl $0x0, -0x3c(%rbp)
jbe 0x3ea261
movq -0x48(%rbp), %rax
movq 0x50(%rax), %rax
movq %rax, -0x88(%rbp)
cmpl $0x0, -0x24(%rbp)
jbe 0x3ea106
movl $0x0, -0x78(%rbp)
movzbl -0x25(%rbp), %eax
cmpl $0x2, %eax
jne 0x3ea06a
movl $0x0, -0x8c(%rbp)
movl -0x8c(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jae 0x3ea065
movq -0x88(%rbp), %rdi
movl -0x8c(%rbp), %eax
shll $0x2, %eax
addl $0x8, %eax
movl %eax, %eax
addq %rax, %rdi
callq 0x3db720
movl %eax, -0x7c(%rbp)
movl -0x7c(%rbp), %eax
cmpl -0x24(%rbp), %eax
ja 0x3ea052
movl -0x8c(%rbp), %eax
movl %eax, -0x78(%rbp)
jmp 0x3ea065
jmp 0x3ea054
movl -0x8c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8c(%rbp)
jmp 0x3ea014
jmp 0x3ea104
movq -0x88(%rbp), %rdi
addq $0x8, %rdi
callq 0x3db720
movl %eax, %edi
subl -0x24(%rbp), %edi
callq 0x3ea6d0
movl %eax, -0x90(%rbp)
movl $0x1, -0x8c(%rbp)
movl -0x8c(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jae 0x3ea102
movq -0x88(%rbp), %rdi
movl -0x8c(%rbp), %eax
shll $0x2, %eax
addl $0x8, %eax
movl %eax, %eax
addq %rax, %rdi
callq 0x3db720
movl %eax, %edi
subl -0x24(%rbp), %edi
callq 0x3ea6d0
movl %eax, -0x94(%rbp)
movl -0x94(%rbp), %eax
cmpl -0x90(%rbp), %eax
jge 0x3ea0ef
movl -0x8c(%rbp), %eax
movl %eax, -0x78(%rbp)
movl -0x94(%rbp), %eax
movl %eax, -0x90(%rbp)
jmp 0x3ea0f1
movl -0x8c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8c(%rbp)
jmp 0x3ea094
jmp 0x3ea104
jmp 0x3ea10d
movl $0x0, -0x78(%rbp)
movq -0x88(%rbp), %rdi
movl -0x78(%rbp), %eax
shll $0x2, %eax
addl $0x8, %eax
movl %eax, %eax
addq %rax, %rdi
callq 0x3db720
movl %eax, -0x7c(%rbp)
movl -0x7c(%rbp), %eax
cmpl -0x54(%rbp), %eax
jbe 0x3ea144
movl $0x113cb, %edi          # imm = 0x113CB
callq 0x3dff80
movl %eax, -0x34(%rbp)
jmp 0x3ea468
cmpb $0x0, -0x59(%rbp)
je 0x3ea16b
movl -0x7c(%rbp), %eax
cmpl -0x24(%rbp), %eax
je 0x3ea16b
movl -0x7c(%rbp), %eax
cmpl -0x24(%rbp), %eax
jae 0x3ea25f
movzbl -0x25(%rbp), %eax
cmpl $0x2, %eax
jne 0x3ea25f
movl -0x7c(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movq -0x48(%rbp), %rax
movq 0x70(%rax), %rdi
callq 0x3c6610
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x3ea18f
jmp 0x3ea468
movl -0x78(%rbp), %eax
movl -0x3c(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jae 0x3ea1c6
movq -0x88(%rbp), %rax
movl -0x78(%rbp), %ecx
shll $0x2, %ecx
addl $0x8, %ecx
movl %ecx, %ecx
movq -0x88(%rbp), %rdx
movl -0x3c(%rbp), %esi
shll $0x2, %esi
addl $0x4, %esi
movl %esi, %esi
movl (%rdx,%rsi), %edx
movl %edx, (%rax,%rcx)
movq -0x88(%rbp), %rdi
addq $0x4, %rdi
movl -0x3c(%rbp), %esi
subl $0x1, %esi
callq 0x3dd200
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movl (%rax), %esi
callq 0x3ea710
cmpl $0x0, %eax
setne %dl
xorb $-0x1, %dl
xorl %eax, %eax
movl $0x1, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, -0x98(%rbp)
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movl (%rax), %esi
movq -0x18(%rbp), %rdx
movl -0x98(%rbp), %ecx
callq 0x3ea630
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jne 0x3ea25b
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq 0x70(%rax), %rdi
callq 0x3c6610
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x3ea259
movq -0x18(%rbp), %rax
movq (%rax), %rdi
callq 0x3e9b70
movq -0x18(%rbp), %rax
movq $0x0, (%rax)
jmp 0x3ea25b
movb $0x0, -0x59(%rbp)
jmp 0x3ea261
jmp 0x3ea263
jmp 0x3ea265
jmp 0x3ea267
movq -0x50(%rbp), %rdi
callq 0x3e9b70
movq $0x0, -0x50(%rbp)
cmpb $0x0, -0x59(%rbp)
jne 0x3e9cdc
jmp 0x3ea466
movq -0x10(%rbp), %rax
movzbl 0x23(%rax), %edx
xorl %eax, %eax
movl $0x1, %ecx
cmpl %edx, %eax
cmovel %ecx, %eax
movl %eax, -0x9c(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x70(%rax), %rdi
callq 0x3c6610
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x3ea2c6
movl -0x34(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x3ea480
movq -0x10(%rbp), %rax
movl 0x40(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x40(%rax)
movq -0x10(%rbp), %rax
movl 0x40(%rax), %eax
movl %eax, -0xac(%rbp)
movl 0x2559ca(%rip), %eax    # 0x63fcb0
movq -0x10(%rbp), %rcx
xorl %edx, %edx
divl 0x34(%rcx)
movl %eax, %ecx
movl -0xac(%rbp), %eax
addl $0x1, %ecx
cmpl %ecx, %eax
jne 0x3ea30b
movq -0x10(%rbp), %rax
movl 0x40(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x40(%rax)
movq -0x10(%rbp), %rax
movzbl 0x21(%rax), %eax
cmpl $0x0, %eax
je 0x3ea3e1
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x40(%rax), %esi
callq 0x3e8c00
movq -0x10(%rbp), %rcx
cmpl 0x40(%rcx), %eax
jne 0x3ea3e1
movq $0x0, -0xa8(%rbp)
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x40(%rax), %esi
movl -0x9c(%rbp), %ecx
leaq -0xa8(%rbp), %rdx
callq 0x3ea630
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jne 0x3ea389
movq -0xa8(%rbp), %rax
movq 0x70(%rax), %rdi
callq 0x3c6610
movl %eax, -0x34(%rbp)
movq -0xa8(%rbp), %rdi
callq 0x3e9b70
cmpl $0x0, -0x34(%rbp)
je 0x3ea39a
movl -0x34(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x3ea480
movq -0x10(%rbp), %rax
movl 0x40(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x40(%rax)
movq -0x10(%rbp), %rax
movl 0x40(%rax), %eax
movl %eax, -0xb0(%rbp)
movl 0x2558f6(%rip), %eax    # 0x63fcb0
movq -0x10(%rbp), %rcx
xorl %edx, %edx
divl 0x34(%rcx)
movl %eax, %ecx
movl -0xb0(%rbp), %eax
addl $0x1, %ecx
cmpl %ecx, %eax
jne 0x3ea3df
movq -0x10(%rbp), %rax
movl 0x40(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x40(%rax)
jmp 0x3ea3e1
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x50(%rax), %rdi
addq $0x1c, %rdi
movq -0x10(%rbp), %rax
movl 0x40(%rax), %esi
callq 0x3dd200
movq -0x10(%rbp), %rax
movl 0x40(%rax), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movl (%rax), %esi
movq -0x18(%rbp), %rdx
movl -0x9c(%rbp), %ecx
callq 0x3ea630
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x3ea434
movl -0x34(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x3ea480
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq 0x70(%rax), %rdi
callq 0x3c6610
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x3ea464
movq -0x18(%rbp), %rax
movq (%rax), %rdi
callq 0x3e9b70
movq -0x18(%rbp), %rax
movq $0x0, (%rax)
jmp 0x3ea466
jmp 0x3ea468
movq -0x48(%rbp), %rdi
callq 0x3e9b70
movq -0x50(%rbp), %rdi
callq 0x3e9b70
movl -0x34(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xb0, %rsp
popq %rbp
retq
nopl (%rax)