// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: sqlite3WalFrames
SQLITE_PRIVATE int sqlite3WalFrames(
  Wal *pWal,                      /* Wal handle to write to */
  int szPage,                     /* Database page-size in bytes */
  PgHdr *pList,                   /* List of dirty pages to write */
  Pgno nTruncate,                 /* Database size after this commit */
  int isCommit,                   /* True if this is a commit */
  int sync_flags                  /* Flags to pass to OsSync() (or 0) */
){
  int rc;                         /* Used to catch return codes */
  u32 iFrame;                     /* Next frame address */
  PgHdr *p;                       /* Iterator to run through pList with. */
  PgHdr *pLast = 0;               /* Last frame in list */
  int nExtra = 0;                 /* Number of extra copies of last page */
  int szFrame;                    /* The size of a single frame */
  i64 iOffset;                    /* Next byte to write in WAL file */
  WalWriter w;                    /* The writer */
  u32 iFirst = 0;                 /* First frame that may be overwritten */
  WalIndexHdr *pLive;             /* Pointer to shared header */

  assert( pList );
  assert( pWal->writeLock );

  /* If this frame set completes a transaction, then nTruncate>0.  If
  ** nTruncate==0 then this frame set does not complete the transaction. */
  assert( (isCommit!=0)==(nTruncate!=0) );

#if defined(SQLITE_TEST) && defined(SQLITE_DEBUG)
  { int cnt; for(cnt=0, p=pList; p; p=p->pDirty, cnt++){}
    WALTRACE(("WAL%p: frame write begin. %d frames. mxFrame=%d. %s\n",
              pWal, cnt, pWal->hdr.mxFrame, isCommit ? "Commit" : "Spill"));
  }
#endif

  pLive = (WalIndexHdr*)walIndexHdr(pWal);
  if( memcmp(&pWal->hdr, (void *)pLive, sizeof(WalIndexHdr))!=0 ){
    iFirst = pLive->mxFrame+1;
  }

  /* See if it is possible to write these frames into the start of the
  ** log file, instead of appending to it at pWal->hdr.mxFrame.
  */
  if( SQLITE_OK!=(rc = walRestartLog(pWal)) ){
    return rc;
  }

  /* If this is the first frame written into the log, write the WAL
  ** header to the start of the WAL file. See comments at the top of
  ** this source file for a description of the WAL header format.
  */
  iFrame = pWal->hdr.mxFrame;
  if( iFrame==0 ){
    u8 aWalHdr[WAL_HDRSIZE];      /* Buffer to assemble wal-header in */
    u32 aCksum[2];                /* Checksum for wal-header */

    sqlite3Put4byte(&aWalHdr[0], (WAL_MAGIC | SQLITE_BIGENDIAN));
    sqlite3Put4byte(&aWalHdr[4], WAL_MAX_VERSION);
    sqlite3Put4byte(&aWalHdr[8], szPage);
    sqlite3Put4byte(&aWalHdr[12], pWal->nCkpt);
    if( pWal->nCkpt==0 ) sqlite3_randomness(8, pWal->hdr.aSalt);
    memcpy(&aWalHdr[16], pWal->hdr.aSalt, 8);
    walChecksumBytes(1, aWalHdr, WAL_HDRSIZE-2*4, 0, aCksum);
    sqlite3Put4byte(&aWalHdr[24], aCksum[0]);
    sqlite3Put4byte(&aWalHdr[28], aCksum[1]);

    pWal->szPage = szPage;
    pWal->hdr.bigEndCksum = SQLITE_BIGENDIAN;
    pWal->hdr.aFrameCksum[0] = aCksum[0];
    pWal->hdr.aFrameCksum[1] = aCksum[1];
    pWal->truncateOnCommit = 1;

    rc = sqlite3OsWrite(pWal->pWalFd, aWalHdr, sizeof(aWalHdr), 0);
    WALTRACE(("WAL%p: wal-header write %s\n", pWal, rc ? "failed" : "ok"));
    if( rc!=SQLITE_OK ){
      return rc;
    }

    /* Sync the header (unless SQLITE_IOCAP_SEQUENTIAL is true or unless
    ** all syncing is turned off by PRAGMA synchronous=OFF).  Otherwise
    ** an out-of-order write following a WAL restart could result in
    ** database corruption.  See the ticket:
    **
    **     https://sqlite.org/src/info/ff5be73dee
    */
    if( pWal->syncHeader ){
      rc = sqlite3OsSync(pWal->pWalFd, CKPT_SYNC_FLAGS(sync_flags));
      if( rc ) return rc;
    }
  }
  assert( (int)pWal->szPage==szPage );

  /* Setup information needed to write frames into the WAL */
  w.pWal = pWal;
  w.pFd = pWal->pWalFd;
  w.iSyncPoint = 0;
  w.syncFlags = sync_flags;
  w.szPage = szPage;
  iOffset = walFrameOffset(iFrame+1, szPage);
  szFrame = szPage + WAL_FRAME_HDRSIZE;

  /* Write all frames into the log file exactly once */
  for(p=pList; p; p=p->pDirty){
    int nDbSize;   /* 0 normally.  Positive == commit flag */

    /* Check if this page has already been written into the wal file by
    ** the current transaction. If so, overwrite the existing frame and
    ** set Wal.writeLock to WAL_WRITELOCK_RECKSUM - indicating that
    ** checksums must be recomputed when the transaction is committed.  */
    if( iFirst && (p->pDirty || isCommit==0) ){
      u32 iWrite = 0;
      VVA_ONLY(rc =) sqlite3WalFindFrame(pWal, p->pgno, &iWrite);
      assert( rc==SQLITE_OK || iWrite==0 );
      if( iWrite>=iFirst ){
        i64 iOff = walFrameOffset(iWrite, szPage) + WAL_FRAME_HDRSIZE;
        void *pData;
        if( pWal->iReCksum==0 || iWrite<pWal->iReCksum ){
          pWal->iReCksum = iWrite;
        }
        pData = p->pData;
        rc = sqlite3OsWrite(pWal->pWalFd, pData, szPage, iOff);
        if( rc ) return rc;
        p->flags &= ~PGHDR_WAL_APPEND;
        continue;
      }
    }

    iFrame++;
    assert( iOffset==walFrameOffset(iFrame, szPage) );
    nDbSize = (isCommit && p->pDirty==0) ? nTruncate : 0;
    rc = walWriteOneFrame(&w, p, nDbSize, iOffset);
    if( rc ) return rc;
    pLast = p;
    iOffset += szFrame;
    p->flags |= PGHDR_WAL_APPEND;
  }

  /* Recalculate checksums within the wal file if required. */
  if( isCommit && pWal->iReCksum ){
    rc = walRewriteChecksums(pWal, iFrame);
    if( rc ) return rc;
  }

  /* If this is the end of a transaction, then we might need to pad
  ** the transaction and/or sync the WAL file.
  **
  ** Padding and syncing only occur if this set of frames complete a
  ** transaction and if PRAGMA synchronous=FULL.  If synchronous==NORMAL
  ** or synchronous==OFF, then no padding or syncing are needed.
  **
  ** If SQLITE_IOCAP_POWERSAFE_OVERWRITE is defined, then padding is not
  ** needed and only the sync is done.  If padding is needed, then the
  ** final frame is repeated (with its commit mark) until the next sector
  ** boundary is crossed.  Only the part of the WAL prior to the last
  ** sector boundary is synced; the part of the last frame that extends
  ** past the sector boundary is written after the sync.
  */
  if( isCommit && WAL_SYNC_FLAGS(sync_flags)!=0 ){
    int bSync = 1;
    if( pWal->padToSectorBoundary ){
      int sectorSize = sqlite3SectorSize(pWal->pWalFd);
      w.iSyncPoint = ((iOffset+sectorSize-1)/sectorSize)*sectorSize;
      bSync = (w.iSyncPoint==iOffset);
      testcase( bSync );
      while( iOffset<w.iSyncPoint ){
        rc = walWriteOneFrame(&w, pLast, nTruncate, iOffset);
        if( rc ) return rc;
        iOffset += szFrame;
        nExtra++;
        assert( pLast!=0 );
      }
    }
    if( bSync ){
      assert( rc==SQLITE_OK );
      rc = sqlite3OsSync(w.pFd, WAL_SYNC_FLAGS(sync_flags));
    }
  }

  /* If this frame set completes the first transaction in the WAL and
  ** if PRAGMA journal_size_limit is set, then truncate the WAL to the
  ** journal size limit, if possible.
  */
  if( isCommit && pWal->truncateOnCommit && pWal->mxWalSize>=0 ){
    i64 sz = pWal->mxWalSize;
    if( walFrameOffset(iFrame+nExtra+1, szPage)>pWal->mxWalSize ){
      sz = walFrameOffset(iFrame+nExtra+1, szPage);
    }
    walLimitSize(pWal, sz);
    pWal->truncateOnCommit = 0;
  }

  /* Append data to the wal-index. It is not necessary to lock the
  ** wal-index to do this as the SQLITE_SHM_WRITE lock held on the wal-index
  ** guarantees that there are no other writers, and no data that may
  ** be in use by existing readers is being overwritten.
  */
  iFrame = pWal->hdr.mxFrame;
  for(p=pList; p && rc==SQLITE_OK; p=p->pDirty){
    if( (p->flags & PGHDR_WAL_APPEND)==0 ) continue;
    iFrame++;
    rc = walIndexAppend(pWal, iFrame, p->pgno);
  }
  assert( pLast!=0 || nExtra==0 );
  while( rc==SQLITE_OK && nExtra>0 ){
    iFrame++;
    nExtra--;
    rc = walIndexAppend(pWal, iFrame, pLast->pgno);
  }

  if( rc==SQLITE_OK ){
    /* Update the private copy of the header. */
    pWal->hdr.szPage = (u16)((szPage&0xff00) | (szPage>>16));
    testcase( szPage<=32768 );
    testcase( szPage>=65536 );
    pWal->hdr.mxFrame = iFrame;
    if( isCommit ){
      pWal->hdr.iChange++;
      pWal->hdr.nPage = nTruncate;
    }
    /* If this is a commit, update the wal-index header too. */
    if( isCommit ){
      walIndexWriteHdr(pWal);
      pWal->iCallback = iFrame;
    }
  }

  WALTRACE(("WAL%p: frame write %s\n", pWal, rc ? "failed" : "ok"));
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movl %r8d, -0x28(%rbp)
movl %r9d, -0x2c(%rbp)
movq $0x0, -0x48(%rbp)
movl $0x0, -0x4c(%rbp)
movl $0x0, -0x7c(%rbp)
movq -0x10(%rbp), %rdi
callq 0x3ddcf0
movq %rax, -0x88(%rbp)
movq -0x10(%rbp), %rdi
addq $0x48, %rdi
movq -0x88(%rbp), %rsi
movl $0x30, %edx
callq 0x192c0
cmpl $0x0, %eax
je 0x3dd625
movq -0x88(%rbp), %rax
movl 0x10(%rax), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
movq -0x10(%rbp), %rdi
callq 0x3ddd10
movl %eax, %ecx
movl %ecx, -0x30(%rbp)
xorl %eax, %eax
cmpl %ecx, %eax
je 0x3dd644
movl -0x30(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x3ddcaa
movq -0x10(%rbp), %rax
movl 0x58(%rax), %eax
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jne 0x3dd7c7
leaq -0xb0(%rbp), %rdi
movl $0x377f0682, %esi       # imm = 0x377F0682
callq 0x3dd200
leaq -0xb0(%rbp), %rdi
addq $0x4, %rdi
movl $0x2de218, %esi         # imm = 0x2DE218
callq 0x3dd200
leaq -0xb0(%rbp), %rdi
addq $0x8, %rdi
movl -0x14(%rbp), %esi
callq 0x3dd200
leaq -0xb0(%rbp), %rdi
addq $0xc, %rdi
movq -0x10(%rbp), %rax
movl 0x88(%rax), %esi
callq 0x3dd200
movq -0x10(%rbp), %rax
cmpl $0x0, 0x88(%rax)
jne 0x3dd6ce
movq -0x10(%rbp), %rsi
addq $0x48, %rsi
addq $0x20, %rsi
movl $0x8, %edi
callq 0x3c3b60
movq -0x10(%rbp), %rax
movq 0x68(%rax), %rax
movq %rax, -0xa0(%rbp)
leaq -0xb0(%rbp), %rsi
leaq -0xb8(%rbp), %r8
movl $0x1, %edi
movl $0x18, %edx
xorl %eax, %eax
movl %eax, %ecx
callq 0x3dde00
leaq -0xb0(%rbp), %rdi
addq $0x18, %rdi
movl -0xb8(%rbp), %esi
callq 0x3dd200
leaq -0xb0(%rbp), %rdi
addq $0x1c, %rdi
movl -0xb4(%rbp), %esi
callq 0x3dd200
movl -0x14(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x38(%rax)
movq -0x10(%rbp), %rax
movb $0x0, 0x55(%rax)
movl -0xb8(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x60(%rax)
movl -0xb4(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x64(%rax)
movq -0x10(%rbp), %rax
movb $0x1, 0x43(%rax)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
leaq -0xb0(%rbp), %rsi
movl $0x20, %edx
xorl %eax, %eax
movl %eax, %ecx
callq 0x3c6930
movl %eax, -0x30(%rbp)
cmpl $0x0, -0x30(%rbp)
je 0x3dd78f
movl -0x30(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x3ddcaa
movq -0x10(%rbp), %rax
cmpb $0x0, 0x44(%rax)
je 0x3dd7c5
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
movl -0x2c(%rbp), %esi
sarl $0x2, %esi
andl $0x3, %esi
callq 0x3ddf70
movl %eax, -0x30(%rbp)
cmpl $0x0, -0x30(%rbp)
je 0x3dd7c3
movl -0x30(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x3ddcaa
jmp 0x3dd7c5
jmp 0x3dd7c7
movq -0x10(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x70(%rbp)
movq $0x0, -0x68(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, -0x60(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x5c(%rbp)
movl -0x34(%rbp), %eax
addl $0x1, %eax
subl $0x1, %eax
movl %eax, %eax
movl -0x14(%rbp), %ecx
addl $0x18, %ecx
movslq %ecx, %rcx
imulq %rcx, %rax
addq $0x20, %rax
movq %rax, -0x58(%rbp)
movl -0x14(%rbp), %eax
addl $0x18, %eax
movl %eax, -0x50(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x3dd9b8
cmpl $0x0, -0x7c(%rbp)
je 0x3dd91e
movq -0x40(%rbp), %rax
cmpq $0x0, 0x20(%rax)
jne 0x3dd84a
cmpl $0x0, -0x28(%rbp)
jne 0x3dd91e
movl $0x0, -0xc0(%rbp)
movq -0x10(%rbp), %rdi
movq -0x40(%rbp), %rax
movl 0x30(%rax), %esi
leaq -0xc0(%rbp), %rdx
callq 0x3ddfb0
movl -0xc0(%rbp), %eax
cmpl -0x7c(%rbp), %eax
jb 0x3dd91c
movl -0xc0(%rbp), %eax
subl $0x1, %eax
movl %eax, %eax
movl -0x14(%rbp), %ecx
addl $0x18, %ecx
movslq %ecx, %rcx
imulq %rcx, %rax
addq $0x20, %rax
addq $0x18, %rax
movq %rax, -0xc8(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x7c(%rax)
je 0x3dd8ba
movl -0xc0(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x7c(%rcx), %eax
jae 0x3dd8c7
movl -0xc0(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x7c(%rax)
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0xd0(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0xd0(%rbp), %rsi
movl -0x14(%rbp), %edx
movq -0xc8(%rbp), %rcx
callq 0x3c6930
movl %eax, -0x30(%rbp)
cmpl $0x0, -0x30(%rbp)
je 0x3dd908
movl -0x30(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x3ddcaa
movq -0x40(%rbp), %rax
movzwl 0x34(%rax), %ecx
andl $-0x41, %ecx
movw %cx, 0x34(%rax)
jmp 0x3dd9a7
jmp 0x3dd91e
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x28(%rbp)
je 0x3dd943
movq -0x40(%rbp), %rax
cmpq $0x0, 0x20(%rax)
jne 0x3dd943
movl -0x24(%rbp), %eax
movl %eax, -0xe4(%rbp)
jmp 0x3dd94d
xorl %eax, %eax
movl %eax, -0xe4(%rbp)
jmp 0x3dd94d
movl -0xe4(%rbp), %eax
movl %eax, -0xbc(%rbp)
movq -0x40(%rbp), %rsi
movl -0xbc(%rbp), %edx
movq -0x58(%rbp), %rcx
leaq -0x78(%rbp), %rdi
callq 0x3de120
movl %eax, -0x30(%rbp)
cmpl $0x0, -0x30(%rbp)
je 0x3dd984
movl -0x30(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x3ddcaa
movq -0x40(%rbp), %rax
movq %rax, -0x48(%rbp)
movslq -0x50(%rbp), %rax
addq -0x58(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x40(%rbp), %rax
movzwl 0x34(%rax), %ecx
orl $0x40, %ecx
movw %cx, 0x34(%rax)
movq -0x40(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x40(%rbp)
jmp 0x3dd820
cmpl $0x0, -0x28(%rbp)
je 0x3dd9ea
movq -0x10(%rbp), %rax
cmpl $0x0, 0x7c(%rax)
je 0x3dd9ea
movq -0x10(%rbp), %rdi
movl -0x34(%rbp), %esi
callq 0x3de1c0
movl %eax, -0x30(%rbp)
cmpl $0x0, -0x30(%rbp)
je 0x3dd9e8
movl -0x30(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x3ddcaa
jmp 0x3dd9ea
cmpl $0x0, -0x28(%rbp)
je 0x3ddad9
movl -0x2c(%rbp), %eax
andl $0x3, %eax
cmpl $0x0, %eax
je 0x3ddad9
movl $0x1, -0xd4(%rbp)
movq -0x10(%rbp), %rax
cmpb $0x0, 0x45(%rax)
je 0x3ddabc
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x3dbf00
movl %eax, -0xd8(%rbp)
movq -0x58(%rbp), %rax
movslq -0xd8(%rbp), %rcx
addq %rcx, %rax
subq $0x1, %rax
movslq -0xd8(%rbp), %rcx
cqto
idivq %rcx
movslq -0xd8(%rbp), %rcx
imulq %rcx, %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
cmpq -0x58(%rbp), %rax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0xd4(%rbp)
movq -0x58(%rbp), %rax
cmpq -0x68(%rbp), %rax
jge 0x3ddaba
movq -0x48(%rbp), %rsi
movl -0x24(%rbp), %edx
movq -0x58(%rbp), %rcx
leaq -0x78(%rbp), %rdi
callq 0x3de120
movl %eax, -0x30(%rbp)
cmpl $0x0, -0x30(%rbp)
je 0x3ddaa3
movl -0x30(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x3ddcaa
movslq -0x50(%rbp), %rax
addq -0x58(%rbp), %rax
movq %rax, -0x58(%rbp)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x3dda71
jmp 0x3ddabc
cmpl $0x0, -0xd4(%rbp)
je 0x3ddad7
movq -0x70(%rbp), %rdi
movl -0x2c(%rbp), %esi
andl $0x3, %esi
callq 0x3ddf70
movl %eax, -0x30(%rbp)
jmp 0x3ddad9
cmpl $0x0, -0x28(%rbp)
je 0x3ddb75
movq -0x10(%rbp), %rax
movzbl 0x43(%rax), %eax
cmpl $0x0, %eax
je 0x3ddb75
movq -0x10(%rbp), %rax
cmpq $0x0, 0x20(%rax)
jl 0x3ddb75
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0xe0(%rbp)
movl -0x34(%rbp), %eax
addl -0x4c(%rbp), %eax
addl $0x1, %eax
subl $0x1, %eax
movl %eax, %eax
movl -0x14(%rbp), %ecx
addl $0x18, %ecx
movslq %ecx, %rcx
imulq %rcx, %rax
addq $0x20, %rax
movq -0x10(%rbp), %rcx
cmpq 0x20(%rcx), %rax
jle 0x3ddb5d
movl -0x34(%rbp), %eax
addl -0x4c(%rbp), %eax
addl $0x1, %eax
subl $0x1, %eax
movl %eax, %eax
movl -0x14(%rbp), %ecx
addl $0x18, %ecx
movslq %ecx, %rcx
imulq %rcx, %rax
addq $0x20, %rax
movq %rax, -0xe0(%rbp)
movq -0x10(%rbp), %rdi
movq -0xe0(%rbp), %rsi
callq 0x3de380
movq -0x10(%rbp), %rax
movb $0x0, 0x43(%rax)
movq -0x10(%rbp), %rax
movl 0x58(%rax), %eax
movl %eax, -0x34(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x40(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x40(%rbp)
movb %al, -0xe5(%rbp)
je 0x3ddba3
cmpl $0x0, -0x30(%rbp)
sete %al
movb %al, -0xe5(%rbp)
movb -0xe5(%rbp), %al
testb $0x1, %al
jne 0x3ddbaf
jmp 0x3ddbee
movq -0x40(%rbp), %rax
movzwl 0x34(%rax), %eax
andl $0x40, %eax
cmpl $0x0, %eax
jne 0x3ddbc1
jmp 0x3ddbe0
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movq -0x10(%rbp), %rdi
movl -0x34(%rbp), %esi
movq -0x40(%rbp), %rax
movl 0x30(%rax), %edx
callq 0x3de400
movl %eax, -0x30(%rbp)
movq -0x40(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x40(%rbp)
jmp 0x3ddb87
jmp 0x3ddbf0
xorl %eax, %eax
cmpl $0x0, -0x30(%rbp)
movb %al, -0xe6(%rbp)
jne 0x3ddc0b
cmpl $0x0, -0x4c(%rbp)
setg %al
movb %al, -0xe6(%rbp)
movb -0xe6(%rbp), %al
testb $0x1, %al
jne 0x3ddc17
jmp 0x3ddc41
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movl -0x4c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x4c(%rbp)
movq -0x10(%rbp), %rdi
movl -0x34(%rbp), %esi
movq -0x48(%rbp), %rax
movl 0x30(%rax), %edx
callq 0x3de400
movl %eax, -0x30(%rbp)
jmp 0x3ddbf0
cmpl $0x0, -0x30(%rbp)
jne 0x3ddca4
movl -0x14(%rbp), %eax
andl $0xff00, %eax           # imm = 0xFF00
movl -0x14(%rbp), %ecx
sarl $0x10, %ecx
orl %ecx, %eax
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0x56(%rax)
movl -0x34(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x58(%rax)
cmpl $0x0, -0x28(%rbp)
je 0x3ddc89
movq -0x10(%rbp), %rax
movl 0x50(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x50(%rax)
movl -0x24(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x5c(%rax)
cmpl $0x0, -0x28(%rbp)
je 0x3ddca2
movq -0x10(%rbp), %rdi
callq 0x3de520
movl -0x34(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x18(%rax)
jmp 0x3ddca4
movl -0x30(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xf0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)