// File: /workspace/github_c_makefile_star2_O0/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
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 0x2ab10
movl %eax, -0x54(%rbp)
movq -0x30(%rbp), %rax
movq 0x50(%rax), %rdi
addq $0x24, %rdi
callq 0x20a50
movl %eax, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x54(%rbp), %eax
jb 0x2cf66
movl $0xd52e, %edi           # imm = 0xD52E
callq 0x24410
movl %eax, -0x4(%rbp)
jmp 0x2d7bb
cmpl $0x0, -0x38(%rbp)
jbe 0x2d57d
movb $0x0, -0x59(%rbp)
movzbl -0x25(%rbp), %eax
cmpl $0x1, %eax
jne 0x2cfbe
movl -0x24(%rbp), %eax
cmpl -0x54(%rbp), %eax
ja 0x2cfbc
movq -0x10(%rbp), %rdi
movl -0x24(%rbp), %esi
leaq -0x5a(%rbp), %rdx
xorl %eax, %eax
movl %eax, %ecx
callq 0x2cdf0
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x2cfad
movl -0x34(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x2d7bb
movzbl -0x5a(%rbp), %eax
cmpl $0x2, %eax
jne 0x2cfba
movb $0x1, -0x59(%rbp)
jmp 0x2cfbc
jmp 0x2cfcd
movzbl -0x25(%rbp), %eax
cmpl $0x2, %eax
jne 0x2cfcb
movb $0x1, -0x59(%rbp)
jmp 0x2cfcd
movq -0x30(%rbp), %rax
movq 0x68(%rax), %rdi
callq 0xef80
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x2cfee
movl -0x34(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x2d7bb
movq -0x30(%rbp), %rax
movq 0x50(%rax), %rdi
addq $0x24, %rdi
movl -0x38(%rbp), %esi
subl $0x1, %esi
callq 0x22060
movq -0x48(%rbp), %rax
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
je 0x2d026
movq -0x50(%rbp), %rax
movq 0x50(%rax), %rdi
callq 0x20a50
movl %eax, -0x58(%rbp)
jmp 0x2d03a
movq -0x30(%rbp), %rax
movq 0x50(%rax), %rdi
addq $0x20, %rdi
callq 0x20a50
movl %eax, -0x58(%rbp)
movl -0x58(%rbp), %eax
cmpl -0x54(%rbp), %eax
jbe 0x2d051
movl $0xd55f, %edi           # imm = 0xD55F
callq 0x24410
movl %eax, -0x34(%rbp)
jmp 0x2d066
movq -0x10(%rbp), %rdi
movl -0x58(%rbp), %esi
leaq -0x48(%rbp), %rdx
xorl %ecx, %ecx
callq 0x29ed0
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x2d079
movq $0x0, -0x48(%rbp)
jmp 0x2d756
movq -0x48(%rbp), %rax
movq 0x50(%rax), %rdi
addq $0x4, %rdi
callq 0x20a50
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
jne 0x2d0ea
cmpb $0x0, -0x59(%rbp)
jne 0x2d0ea
movq -0x48(%rbp), %rax
movq 0x68(%rax), %rdi
callq 0xef80
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x2d0b4
jmp 0x2d756
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 0x2d55d
movl -0x3c(%rbp), %eax
movq -0x10(%rbp), %rcx
movl 0x34(%rcx), %ecx
shrl $0x2, %ecx
subl $0x2, %ecx
cmpl %ecx, %eax
jbe 0x2d110
movl $0xd57b, %edi           # imm = 0xD57B
callq 0x24410
movl %eax, -0x34(%rbp)
jmp 0x2d756
movzbl -0x59(%rbp), %eax
cmpl $0x0, %eax
je 0x2d2f0
movl -0x24(%rbp), %eax
cmpl -0x58(%rbp), %eax
je 0x2d13e
movl -0x58(%rbp), %eax
cmpl -0x24(%rbp), %eax
jae 0x2d2f0
movzbl -0x25(%rbp), %eax
cmpl $0x2, %eax
jne 0x2d2f0
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 0x68(%rax), %rdi
callq 0xef80
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x2d171
jmp 0x2d756
cmpl $0x0, -0x3c(%rbp)
jne 0x2d1c9
cmpq $0x0, -0x50(%rbp)
jne 0x2d195
movq -0x30(%rbp), %rax
movq 0x50(%rax), %rax
movq -0x48(%rbp), %rcx
movq 0x50(%rcx), %rcx
movl (%rcx), %ecx
movl %ecx, 0x20(%rax)
jmp 0x2d1c4
movq -0x50(%rbp), %rax
movq 0x68(%rax), %rdi
callq 0xef80
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x2d1b0
jmp 0x2d756
movq -0x50(%rbp), %rax
movq 0x50(%rax), %rax
movq -0x48(%rbp), %rcx
movq 0x50(%rcx), %rcx
movl (%rcx), %ecx
movl %ecx, (%rax)
jmp 0x2d2e3
movq -0x48(%rbp), %rax
movq 0x50(%rax), %rdi
addq $0x8, %rdi
callq 0x20a50
movl %eax, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
cmpl -0x54(%rbp), %eax
jbe 0x2d1f7
movl $0xd59d, %edi           # imm = 0xD59D
callq 0x24410
movl %eax, -0x34(%rbp)
jmp 0x2d756
movq -0x10(%rbp), %rdi
movl -0x6c(%rbp), %esi
leaq -0x68(%rbp), %rdx
xorl %ecx, %ecx
callq 0x29ed0
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x2d217
jmp 0x2d756
movq -0x68(%rbp), %rax
movq 0x68(%rax), %rdi
callq 0xef80
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x2d23b
movq -0x68(%rbp), %rdi
callq 0x29fd0
jmp 0x2d756
movq -0x68(%rbp), %rax
movq 0x50(%rax), %rax
movq -0x48(%rbp), %rcx
movq 0x50(%rcx), %rcx
movl (%rcx), %ecx
movl %ecx, (%rax)
movq -0x68(%rbp), %rax
movq 0x50(%rax), %rdi
addq $0x4, %rdi
movl -0x3c(%rbp), %esi
subl $0x1, %esi
callq 0x22060
movq -0x68(%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 0x82f0
movq -0x68(%rbp), %rdi
callq 0x29fd0
cmpq $0x0, -0x50(%rbp)
jne 0x2d2b6
movq -0x30(%rbp), %rax
movq 0x50(%rax), %rdi
addq $0x20, %rdi
movl -0x6c(%rbp), %esi
callq 0x22060
jmp 0x2d2e1
movq -0x50(%rbp), %rax
movq 0x68(%rax), %rdi
callq 0xef80
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x2d2d1
jmp 0x2d756
movq -0x50(%rbp), %rax
movq 0x50(%rax), %rdi
movl -0x6c(%rbp), %esi
callq 0x22060
jmp 0x2d2e3
movq $0x0, -0x48(%rbp)
jmp 0x2d559
cmpl $0x0, -0x3c(%rbp)
jbe 0x2d557
movq -0x48(%rbp), %rax
movq 0x50(%rax), %rax
movq %rax, -0x80(%rbp)
cmpl $0x0, -0x24(%rbp)
jbe 0x2d413
movl $0x0, -0x70(%rbp)
movzbl -0x25(%rbp), %eax
cmpl $0x2, %eax
jne 0x2d37d
movl $0x0, -0x84(%rbp)
movl -0x84(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jae 0x2d378
movq -0x80(%rbp), %rdi
movl -0x84(%rbp), %eax
shll $0x2, %eax
addl $0x8, %eax
movl %eax, %eax
addq %rax, %rdi
callq 0x20a50
movl %eax, -0x74(%rbp)
movl -0x74(%rbp), %eax
cmpl -0x24(%rbp), %eax
ja 0x2d365
movl -0x84(%rbp), %eax
movl %eax, -0x70(%rbp)
jmp 0x2d378
jmp 0x2d367
movl -0x84(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x84(%rbp)
jmp 0x2d32a
jmp 0x2d411
movq -0x80(%rbp), %rdi
addq $0x8, %rdi
callq 0x20a50
movl %eax, %edi
subl -0x24(%rbp), %edi
callq 0x2d960
movl %eax, -0x88(%rbp)
movl $0x1, -0x84(%rbp)
movl -0x84(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jae 0x2d40f
movq -0x80(%rbp), %rdi
movl -0x84(%rbp), %eax
shll $0x2, %eax
addl $0x8, %eax
movl %eax, %eax
addq %rax, %rdi
callq 0x20a50
movl %eax, %edi
subl -0x24(%rbp), %edi
callq 0x2d960
movl %eax, -0x8c(%rbp)
movl -0x8c(%rbp), %eax
cmpl -0x88(%rbp), %eax
jge 0x2d3fc
movl -0x84(%rbp), %eax
movl %eax, -0x70(%rbp)
movl -0x8c(%rbp), %eax
movl %eax, -0x88(%rbp)
jmp 0x2d3fe
movl -0x84(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x84(%rbp)
jmp 0x2d3a4
jmp 0x2d411
jmp 0x2d41a
movl $0x0, -0x70(%rbp)
movq -0x80(%rbp), %rdi
movl -0x70(%rbp), %eax
shll $0x2, %eax
addl $0x8, %eax
movl %eax, %eax
addq %rax, %rdi
callq 0x20a50
movl %eax, -0x74(%rbp)
movl -0x74(%rbp), %eax
cmpl -0x54(%rbp), %eax
jbe 0x2d44e
movl $0xd5de, %edi           # imm = 0xD5DE
callq 0x24410
movl %eax, -0x34(%rbp)
jmp 0x2d756
cmpb $0x0, -0x59(%rbp)
je 0x2d475
movl -0x74(%rbp), %eax
cmpl -0x24(%rbp), %eax
je 0x2d475
movl -0x74(%rbp), %eax
cmpl -0x24(%rbp), %eax
jae 0x2d555
movzbl -0x25(%rbp), %eax
cmpl $0x2, %eax
jne 0x2d555
movl -0x74(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movq -0x48(%rbp), %rax
movq 0x68(%rax), %rdi
callq 0xef80
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x2d499
jmp 0x2d756
movl -0x70(%rbp), %eax
movl -0x3c(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jae 0x2d4ca
movq -0x80(%rbp), %rax
movl -0x70(%rbp), %ecx
shll $0x2, %ecx
addl $0x8, %ecx
movl %ecx, %ecx
movq -0x80(%rbp), %rdx
movl -0x3c(%rbp), %esi
shll $0x2, %esi
addl $0x4, %esi
movl %esi, %esi
movl (%rdx,%rsi), %edx
movl %edx, (%rax,%rcx)
movq -0x80(%rbp), %rdi
addq $0x4, %rdi
movl -0x3c(%rbp), %esi
subl $0x1, %esi
callq 0x22060
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movl (%rax), %esi
callq 0x2d9a0
cmpl $0x0, %eax
setne %dl
xorb $-0x1, %dl
xorl %eax, %eax
movl $0x1, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, -0x90(%rbp)
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movl (%rax), %esi
movq -0x18(%rbp), %rdx
movl -0x90(%rbp), %ecx
callq 0x29ed0
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jne 0x2d551
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq 0x68(%rax), %rdi
callq 0xef80
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x2d54f
movq -0x18(%rbp), %rax
movq (%rax), %rdi
callq 0x29fd0
jmp 0x2d551
movb $0x0, -0x59(%rbp)
jmp 0x2d557
jmp 0x2d559
jmp 0x2d55b
jmp 0x2d55d
movq -0x50(%rbp), %rdi
callq 0x29fd0
movq $0x0, -0x50(%rbp)
cmpb $0x0, -0x59(%rbp)
jne 0x2d005
jmp 0x2d754
movq -0x10(%rbp), %rax
movzbl 0x23(%rax), %edx
xorl %eax, %eax
movl $0x1, %ecx
cmpl %edx, %eax
cmovel %ecx, %eax
movl %eax, -0x94(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x68(%rax), %rdi
callq 0xef80
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x2d5bc
movl -0x34(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x2d7bb
movq -0x10(%rbp), %rax
movl 0x3c(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x3c(%rax)
movq -0x10(%rbp), %rax
movl 0x3c(%rax), %eax
movl %eax, -0xa4(%rbp)
movl 0xa32f4(%rip), %eax     # 0xd08d0
movq -0x10(%rbp), %rcx
xorl %edx, %edx
divl 0x30(%rcx)
movl %eax, %ecx
movl -0xa4(%rbp), %eax
addl $0x1, %ecx
cmpl %ecx, %eax
jne 0x2d601
movq -0x10(%rbp), %rax
movl 0x3c(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x3c(%rax)
movq -0x10(%rbp), %rax
movzbl 0x21(%rax), %eax
cmpl $0x0, %eax
je 0x2d6d7
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x3c(%rax), %esi
callq 0x2b950
movq -0x10(%rbp), %rcx
cmpl 0x3c(%rcx), %eax
jne 0x2d6d7
movq $0x0, -0xa0(%rbp)
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x3c(%rax), %esi
movl -0x94(%rbp), %ecx
leaq -0xa0(%rbp), %rdx
callq 0x29ed0
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jne 0x2d67f
movq -0xa0(%rbp), %rax
movq 0x68(%rax), %rdi
callq 0xef80
movl %eax, -0x34(%rbp)
movq -0xa0(%rbp), %rdi
callq 0x29fd0
cmpl $0x0, -0x34(%rbp)
je 0x2d690
movl -0x34(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x2d7bb
movq -0x10(%rbp), %rax
movl 0x3c(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x3c(%rax)
movq -0x10(%rbp), %rax
movl 0x3c(%rax), %eax
movl %eax, -0xa8(%rbp)
movl 0xa3220(%rip), %eax     # 0xd08d0
movq -0x10(%rbp), %rcx
xorl %edx, %edx
divl 0x30(%rcx)
movl %eax, %ecx
movl -0xa8(%rbp), %eax
addl $0x1, %ecx
cmpl %ecx, %eax
jne 0x2d6d5
movq -0x10(%rbp), %rax
movl 0x3c(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x3c(%rax)
jmp 0x2d6d7
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x50(%rax), %rdi
addq $0x1c, %rdi
movq -0x10(%rbp), %rax
movl 0x3c(%rax), %esi
callq 0x22060
movq -0x10(%rbp), %rax
movl 0x3c(%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 -0x94(%rbp), %ecx
callq 0x29ed0
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x2d72d
movl -0x34(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x2d7bb
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq 0x68(%rax), %rdi
callq 0xef80
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x2d752
movq -0x18(%rbp), %rax
movq (%rax), %rdi
callq 0x29fd0
jmp 0x2d754
jmp 0x2d756
movq -0x48(%rbp), %rdi
callq 0x29fd0
movq -0x50(%rbp), %rdi
callq 0x29fd0
cmpl $0x0, -0x34(%rbp)
jne 0x2d7aa
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq 0x68(%rax), %rdi
callq 0x24a40
cmpl $0x1, %eax
jle 0x2d79e
movq -0x18(%rbp), %rax
movq (%rax), %rdi
callq 0x29fd0
movl $0xd640, %edi           # imm = 0xD640
callq 0x24410
movl %eax, -0x4(%rbp)
jmp 0x2d7bb
movq -0x18(%rbp), %rax
movq (%rax), %rax
movb $0x0, (%rax)
jmp 0x2d7b5
movq -0x18(%rbp), %rax
movq $0x0, (%rax)
movl -0x34(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xb0, %rsp
popq %rbp
retq
nopw (%rax,%rax)