// File: atsidaev[P]trx2x/DiskImage.cpp
// Function: TDiskImage::readFDI(int, bool)
void TDiskImage::readFDI(int hfile, bool readonly)
{
   long fsize = filelength(hfile);
   if(fsize < 0)
   {
      ShowError(ERR_GETLEN);
      return;
   }

   unsigned char *ptr = (unsigned char*)new char[fsize+1024*2048];
   if(!ptr)
   {
      ShowError(ERR_NOMEM);
      return;
   }

   unsigned long rsize = read(hfile, ptr, fsize);
   if(rsize < 14)
   {
      delete ptr;
      ShowError(ERR_CORRUPT);
      return;
   }

   if(memcmp(ptr, "FDI", 3) != 0) 
   {
      delete ptr;
      ShowError(ERR_FORMAT" FDI!");
      return;
   }

// ==========================================
// ********** Analyse FDI header ************...
// ------------------------------------------
   unsigned short *fdihead = (unsigned short*)(ptr+4);
   unsigned int fdiCylCount  = fdihead[0];      // +4
   unsigned int fdiSideCount = fdihead[1];      // +6
//   unsigned int fdiOFFtext   = fdihead[2];      // +8
   unsigned int fdiOFFdata   = fdihead[3];      // +A
   unsigned int fdiSIZEext   = fdihead[4];      // +C

   if((fdiCylCount > 256)||(fdiCylCount == 0))
   {
      delete ptr;
      ShowError(ERR_MANYCYLS);
      return;
   }
   if((fdiSideCount > 256)||(fdiSideCount == 0))
   {
      delete ptr;
      ShowError(ERR_MANYSIDS);
      return;
   }

   MaxTrack = (unsigned char)(fdiCylCount-1);
   MaxSide = (unsigned char)(fdiSideCount-1);

   if(rsize < 0x0E + fdiSIZEext + (unsigned(MaxTrack) + 1) * (unsigned(MaxSide) + 1) * 7 )
   {
      delete ptr;
      ShowError(ERR_CORRUPT);
      return;
   }


   struct FDISECINFO
   {
      unsigned char ADAM[5];
      unsigned int SectorOffset;        // относит DataOffset
   };
   struct FDITRACKHDR
   {
      unsigned int DataOffset;          // относит начала файла
      unsigned int SectorCount;
      FDISECINFO SectorsInfo[256];
   };

   FDITRACKHDR *tracksinfo = new FDITRACKHDR[(unsigned(MaxTrack)+1)*(unsigned(MaxSide)+1)];

   unsigned int fdiOFF = 0x0E + fdiSIZEext;

   unsigned int trk, side;
// Анализ области заголовков треков...
   for(trk=0; trk <= unsigned(MaxTrack); trk++)
      for(side=0; side <= unsigned(MaxSide); side++)
      {
         if(rsize < fdiOFF )
         {
            delete[] tracksinfo;
            delete ptr;
            ShowError(ERR_CORRUPT);
            return;
         }

         tracksinfo[trk*(MaxSide+1)+side].DataOffset = *((uint32_t*)(ptr+fdiOFF));
         fdiOFF+=4;

         if(rsize < fdiOFFdata+tracksinfo[trk*(MaxSide+1)+side].DataOffset )
         {
            delete[] tracksinfo;
            delete ptr;
            ShowError(ERR_CORRUPT);
            return;
         }

         fdiOFF+=2;      // "Всегда содержит 0 (резерв для модернизации)"

         tracksinfo[trk*(MaxSide+1)+side].SectorCount = unsigned(ptr[fdiOFF++]);

         for(unsigned isec=0; isec < tracksinfo[trk*(MaxSide+1)+side].SectorCount; isec++)
         {
            memcpy(tracksinfo[trk*(MaxSide+1)+side].SectorsInfo[isec].ADAM, ptr+fdiOFF,5);
            fdiOFF+=5;
            tracksinfo[trk*(MaxSide+1)+side].SectorsInfo[isec].SectorOffset = unsigned(*((unsigned short*)(ptr+fdiOFF)));
            fdiOFF+=2;

            if(rsize < fdiOFFdata+tracksinfo[trk*(MaxSide+1)+side].DataOffset+tracksinfo[trk*(MaxSide+1)+side].SectorsInfo[isec].SectorOffset )
            {
               delete[] tracksinfo;
               delete ptr;
               ShowError(ERR_CORRUPT);
               return;
            }
         }
      }

// форматирование нового диска и размещение FDI секторов...
   unsigned int ptrcrc;
   unsigned int r;
   unsigned short vgcrc;
   unsigned int trkdatalen;
   unsigned SecCount;
   unsigned SL;

   for(trk=0; trk <= unsigned(MaxTrack); trk++)
      for(side=0; side <= unsigned(MaxSide); side++)
      {
         FTrackLength[trk][side] = 6250;

// make unformatted track...
         FTracksPtr[trk][side][0] = (unsigned char*)new char[FTrackLength[trk][side]+1024];      // trk img
         FTracksPtr[trk][side][1] = (unsigned char*)new char[FTrackLength[trk][side]+1024];      // clk img
         for(unsigned ij=0; ij < 6250; ij++)   
         {
            FTracksPtr[trk][side][0][ij] = 0x00;
            FTracksPtr[trk][side][1][ij] = 0x00;         
         }

         SecCount = tracksinfo[trk*(MaxSide+1)+side].SectorCount;

// Вычисляем необходимое число байт под данные:
         trkdatalen = 0;
         for(unsigned int ilsec=0; ilsec < SecCount; ilsec++)
         {
            trkdatalen += 2+6;     // for marks:   0xA1, 0xFE, 6bytes
            SL = unsigned(tracksinfo[trk*(MaxSide+1)+side].SectorsInfo[ilsec].ADAM[3]);
            if(!SL) SL = 128;
            else SL = 128 << SL;

            if(tracksinfo[trk*(MaxSide+1)+side].SectorsInfo[ilsec].ADAM[4] & 0x40)
               SL = 0;          // заголовок без массива данных
            else
               trkdatalen += 4;       // for data header/crc: 0xA1, 0xFB, ...,2bytes

            trkdatalen += SL;
         }

         if(trkdatalen + SecCount*(3+2) > 6250)    // 3x4E & 2x00 per sec checking
         {
            delete[] tracksinfo;
            delete ptr;
            for(int t=0; t < 256; t++)
               for(int s=0; s < 256; s++)
               {
                  FTrackLength[t][s] = 0;
                  if(FTracksPtr[t][s][0]) delete FTracksPtr[t][s][0];
                  FTracksPtr[t][s][0] = NULL;
                  if(FTracksPtr[t][s][1]) delete FTracksPtr[t][s][1];
                  FTracksPtr[t][s][1] = NULL;
               }
            ShowError(ERR_IMPOSSIBLE);
            return;
         }

         unsigned int FreeSpace = 6250 - (trkdatalen + SecCount*(3+2));

         unsigned int SynchroPulseLen = 1; // 1 уже учтен в trkdatalen...
         unsigned int FirstSpaceLen = 1;
         unsigned int SecondSpaceLen = 1;
         unsigned int ThirdSpaceLen = 1;
         unsigned int SynchroSpaceLen = 1;
         FreeSpace -= FirstSpaceLen+SecondSpaceLen+ThirdSpaceLen+SynchroSpaceLen;

// Распределяем длины пробелов и синхропромежутка:
         while(FreeSpace > 0)
         {
            if(FreeSpace>=(SecCount*2)) 
               if(SynchroSpaceLen < 12) {SynchroSpaceLen++; FreeSpace-=SecCount*2;} // Synchro for ADM & DATA
            if(FreeSpace < SecCount) break;

            if(FirstSpaceLen < 10) {FirstSpaceLen++; FreeSpace-=SecCount;}
            if(FreeSpace < SecCount) break;
            if(SecondSpaceLen < 22) {SecondSpaceLen++; FreeSpace-=SecCount;}
            if(FreeSpace < SecCount) break;
            if(ThirdSpaceLen < 60) {ThirdSpaceLen++; FreeSpace-=SecCount;}
            if(FreeSpace < SecCount) break;

            if((SynchroSpaceLen>=12)&&(FirstSpaceLen>=10)&&(SecondSpaceLen>=22)&&(ThirdSpaceLen>=60)) break;
         };
// по возможности делаем три синхроимпульса...
         if(FreeSpace > (SecCount*2)+10) { SynchroPulseLen++; FreeSpace-=SecCount; }
         if(FreeSpace > (SecCount*2)+9) SynchroPulseLen++; 

// Форматируем дорожку...

         unsigned int tptr=0;
         for(unsigned sec=0; sec < SecCount; sec++)
         {
            for(r=0; r < FirstSpaceLen; r++)        // Первый пробел
            {
               FTracksPtr[trk][side][0][tptr] = 0x4E;
               FTracksPtr[trk][side][1][tptr++] = 0x00;
            }
            for(r=0; r < SynchroSpaceLen; r++)        // Синхропромежуток
            {
               FTracksPtr[trk][side][0][tptr] = 0x00;
               FTracksPtr[trk][side][1][tptr++] = 0x00;
            }
            ptrcrc = tptr;
            for(r=0; r < SynchroPulseLen; r++)        // Синхроимпульс
            {
               FTracksPtr[trk][side][0][tptr] = 0xA1;
               FTracksPtr[trk][side][1][tptr++] = 0xFF;
            }
            FTracksPtr[trk][side][0][tptr] = 0xFE;   // Метка "Адрес"
            FTracksPtr[trk][side][1][tptr++] = 0x00;

            FTracksPtr[trk][side][0][tptr] = tracksinfo[trk*(MaxSide+1)+side].SectorsInfo[sec].ADAM[0]; // cyl
            FTracksPtr[trk][side][1][tptr++] = 0x00;
            FTracksPtr[trk][side][0][tptr] = tracksinfo[trk*(MaxSide+1)+side].SectorsInfo[sec].ADAM[1]; // head 
            FTracksPtr[trk][side][1][tptr++] = 0x00;
            FTracksPtr[trk][side][0][tptr] = tracksinfo[trk*(MaxSide+1)+side].SectorsInfo[sec].ADAM[2]; // secN
            FTracksPtr[trk][side][1][tptr++] = 0x00;
            FTracksPtr[trk][side][0][tptr] = tracksinfo[trk*(MaxSide+1)+side].SectorsInfo[sec].ADAM[3]; // len code
            FTracksPtr[trk][side][1][tptr++] = 0x00;

            vgcrc = MakeVGCRC(FTracksPtr[trk][side][0]+ptrcrc, tptr-ptrcrc);
            FTracksPtr[trk][side][0][tptr] = (unsigned char)(vgcrc>>8); // VG93 CRC
            FTracksPtr[trk][side][1][tptr++] = 0x00;
            FTracksPtr[trk][side][0][tptr] = (unsigned char)(vgcrc&0xFF);
            FTracksPtr[trk][side][1][tptr++] = 0x00;

            for(r=0; r < SecondSpaceLen; r++)        // Второй пробел
            {
               FTracksPtr[trk][side][0][tptr] = 0x4E;
               FTracksPtr[trk][side][1][tptr++] = 0x00;
            }
            for(r=0; r < SynchroSpaceLen; r++)        // Синхропромежуток
            {
               FTracksPtr[trk][side][0][tptr] = 0x00;
               FTracksPtr[trk][side][1][tptr++] = 0x00;
            }

            unsigned char fdiSectorFlags = tracksinfo[trk*(MaxSide+1)+side].SectorsInfo[sec].ADAM[4];

// !!!!!!!!!
// !WARNING! this feature of FDI format is NOT FULL DOCUMENTED!!!
// !!!!!!!!!
//
//  Flags::bit6 - Возможно, 1 в данном разряде
//                будет обозначать адресный маркер без области данных.
//

            if(!(fdiSectorFlags & 0x40)) // oh-oh, data area not present... ;-) 
            {
               ptrcrc = tptr;
               for(r=0; r < SynchroPulseLen; r++)        // Синхроимпульс
               {
                  FTracksPtr[trk][side][0][tptr] = 0xA1;
                  FTracksPtr[trk][side][1][tptr++] = 0xFF;
               }
   
               if(fdiSectorFlags & 0x80)
                  FTracksPtr[trk][side][0][tptr] = 0xF8;   // Метка "Удаленные данные"
               else
                  FTracksPtr[trk][side][0][tptr] = 0xFB;   // Метка "Данные"
               FTracksPtr[trk][side][1][tptr++] = 0x00;
   
   
               SL = unsigned(tracksinfo[trk*(MaxSide+1)+side].SectorsInfo[sec].ADAM[3]);
               if(!SL) SL = 128;
               else SL = 128 << SL;
   
               unsigned int secDATAOFF = fdiOFFdata + tracksinfo[trk*(MaxSide+1)+side].DataOffset + tracksinfo[trk*(MaxSide+1)+side].SectorsInfo[sec].SectorOffset;
   
               for(r=0; r < SL; r++)        // сектор SL байт
               {
                  FTracksPtr[trk][side][0][tptr] = ptr[secDATAOFF+r];
                  FTracksPtr[trk][side][1][tptr++] = 0x00;
               }
   
               vgcrc = MakeVGCRC(FTracksPtr[trk][side][0]+ptrcrc, tptr-ptrcrc);
   
   
               if(fdiSectorFlags & 0x3F)        // CRC correct?
               {
                  FTracksPtr[trk][side][0][tptr] = (unsigned char)(vgcrc>>8); // VG93 CRC
                  FTracksPtr[trk][side][1][tptr++] = 0x00;
                  FTracksPtr[trk][side][0][tptr] = (unsigned char)(vgcrc&0xFF);
                  FTracksPtr[trk][side][1][tptr++] = 0x00;
               }
               else     // oh-oh, high technology... CRC bad... ;-)
               {
                  FTracksPtr[trk][side][0][tptr] = (unsigned char)(vgcrc>>8)^0xFF; // emulation bad CRC... ;)
                  FTracksPtr[trk][side][1][tptr++] = 0x00;
                  FTracksPtr[trk][side][0][tptr] = (unsigned char)(vgcrc&0xFF)^0xFF;  // --//-- ;)
                  FTracksPtr[trk][side][1][tptr++] = 0x00;
               }
            }


            for(r=0; r < ThirdSpaceLen; r++)        // Третий пробел
            {
               FTracksPtr[trk][side][0][tptr] = 0x4E;
               FTracksPtr[trk][side][1][tptr++] = 0x00;
            }
         }
         for(int eoftrk=tptr; eoftrk < 6250; eoftrk++) 
         {
            FTracksPtr[trk][side][0][tptr] = 0x4E;
            FTracksPtr[trk][side][1][tptr++] = 0x00;
         }
      }

   delete[] tracksinfo;
   delete ptr;
   ReadOnly = readonly;
   FType = DIT_FDI;
   DiskPresent = true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
movb %dl, %al
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
andb $0x1, %al
movb %al, -0xd(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xb8(%rbp)
movl -0xc(%rbp), %edi
callq 0xd6a0
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jge 0x662f
movq -0xb8(%rbp), %rdi
leaq 0x7d19(%rip), %rsi      # 0xe33e
callq 0x2c30
jmp 0x8004
movq -0x18(%rbp), %rdi
addq $0x200000, %rdi         # imm = 0x200000
callq 0x1030
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x6662
movq -0xb8(%rbp), %rdi
leaq 0x7d04(%rip), %rsi      # 0xe35c
callq 0x2c30
jmp 0x8004
movl -0xc(%rbp), %edi
movq -0x20(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x11a0
movq %rax, -0x28(%rbp)
cmpq $0xe, -0x28(%rbp)
jae 0x66b7
movq -0x20(%rbp), %rax
movq %rax, -0xc0(%rbp)
cmpq $0x0, %rax
je 0x669f
movq -0xc0(%rbp), %rdi
movl $0x1, %esi
callq 0x1130
movq -0xb8(%rbp), %rdi
leaq 0x7cc1(%rip), %rsi      # 0xe36e
callq 0x2c30
jmp 0x8004
movq -0x20(%rbp), %rdi
leaq 0x7b05(%rip), %rsi      # 0xe1c7
movl $0x3, %edx
callq 0x1070
cmpl $0x0, %eax
je 0x670b
movq -0x20(%rbp), %rax
movq %rax, -0xc8(%rbp)
cmpq $0x0, %rax
je 0x66f3
movq -0xc8(%rbp), %rdi
movl $0x1, %esi
callq 0x1130
movq -0xb8(%rbp), %rdi
leaq 0x7d4a(%rip), %rsi      # 0xe44b
callq 0x2c30
jmp 0x8004
movq -0x20(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movzwl (%rax), %eax
movl %eax, -0x34(%rbp)
movq -0x30(%rbp), %rax
movzwl 0x2(%rax), %eax
movl %eax, -0x38(%rbp)
movq -0x30(%rbp), %rax
movzwl 0x6(%rax), %eax
movl %eax, -0x3c(%rbp)
movq -0x30(%rbp), %rax
movzwl 0x8(%rax), %eax
movl %eax, -0x40(%rbp)
cmpl $0x100, -0x34(%rbp)     # imm = 0x100
ja 0x6751
cmpl $0x0, -0x34(%rbp)
jne 0x678b
movq -0x20(%rbp), %rax
movq %rax, -0xd0(%rbp)
cmpq $0x0, %rax
je 0x6773
movq -0xd0(%rbp), %rdi
movl $0x1, %esi
callq 0x1130
movq -0xb8(%rbp), %rdi
leaq 0x7ce7(%rip), %rsi      # 0xe468
callq 0x2c30
jmp 0x8004
cmpl $0x100, -0x38(%rbp)     # imm = 0x100
ja 0x679a
cmpl $0x0, -0x38(%rbp)
jne 0x67d4
movq -0x20(%rbp), %rax
movq %rax, -0xd8(%rbp)
cmpq $0x0, %rax
je 0x67bc
movq -0xd8(%rbp), %rdi
movl $0x1, %esi
callq 0x1130
movq -0xb8(%rbp), %rdi
leaq 0x7cd2(%rip), %rsi      # 0xe49c
callq 0x2c30
jmp 0x8004
movq -0xb8(%rbp), %rsi
movl -0x34(%rbp), %eax
subl $0x1, %eax
movb %al, 0x145007(%rsi)
movl -0x38(%rbp), %eax
subl $0x1, %eax
movb %al, 0x145008(%rsi)
movq -0x28(%rbp), %rax
movl -0x40(%rbp), %ecx
addl $0xe, %ecx
movzbl 0x145007(%rsi), %edx
addl $0x1, %edx
movzbl 0x145008(%rsi), %esi
addl $0x1, %esi
imull %esi, %edx
imull $0x7, %edx, %edx
addl %edx, %ecx
movl %ecx, %ecx
cmpq %rcx, %rax
jae 0x685a
movq -0x20(%rbp), %rax
movq %rax, -0xe0(%rbp)
cmpq $0x0, %rax
je 0x6842
movq -0xe0(%rbp), %rdi
movl $0x1, %esi
callq 0x1130
movq -0xb8(%rbp), %rdi
leaq 0x7b1e(%rip), %rsi      # 0xe36e
callq 0x2c30
jmp 0x8004
movq -0xb8(%rbp), %rcx
movzbl 0x145007(%rcx), %eax
addl $0x1, %eax
movzbl 0x145008(%rcx), %ecx
addl $0x1, %ecx
imull %ecx, %eax
movl %eax, %eax
movl $0xc08, %ecx            # imm = 0xC08
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x1030
movq %rax, -0x48(%rbp)
movl -0x40(%rbp), %eax
addl $0xe, %eax
movl %eax, -0x4c(%rbp)
movl $0x0, -0x50(%rbp)
movq -0xb8(%rbp), %rcx
movl -0x50(%rbp), %eax
movzbl 0x145007(%rcx), %ecx
cmpl %ecx, %eax
ja 0x6c29
movl $0x0, -0x54(%rbp)
movq -0xb8(%rbp), %rcx
movl -0x54(%rbp), %eax
movzbl 0x145008(%rcx), %ecx
cmpl %ecx, %eax
ja 0x6c19
movq -0x28(%rbp), %rax
movl -0x4c(%rbp), %ecx
cmpq %rcx, %rax
jae 0x694b
movq -0x48(%rbp), %rax
movq %rax, -0xe8(%rbp)
cmpq $0x0, %rax
je 0x6911
movq -0xe8(%rbp), %rdi
callq 0x1160
movq -0x20(%rbp), %rax
movq %rax, -0xf0(%rbp)
cmpq $0x0, %rax
je 0x6933
movq -0xf0(%rbp), %rdi
movl $0x1, %esi
callq 0x1130
movq -0xb8(%rbp), %rdi
leaq 0x7a2d(%rip), %rsi      # 0xe36e
callq 0x2c30
jmp 0x8004
movq -0xb8(%rbp), %rdi
movq -0x20(%rbp), %rax
movl -0x4c(%rbp), %ecx
movl (%rax,%rcx), %ecx
movq -0x48(%rbp), %rax
movl -0x50(%rbp), %edx
movzbl 0x145008(%rdi), %esi
addl $0x1, %esi
imull %esi, %edx
addl -0x54(%rbp), %edx
movl %edx, %edx
imulq $0xc08, %rdx, %rdx      # imm = 0xC08
addq %rdx, %rax
movl %ecx, (%rax)
movl -0x4c(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x4c(%rbp)
movq -0x28(%rbp), %rax
movl -0x3c(%rbp), %ecx
movq -0x48(%rbp), %rdx
movl -0x50(%rbp), %esi
movzbl 0x145008(%rdi), %edi
addl $0x1, %edi
imull %edi, %esi
addl -0x54(%rbp), %esi
movl %esi, %esi
imulq $0xc08, %rsi, %rsi      # imm = 0xC08
addq %rsi, %rdx
addl (%rdx), %ecx
movl %ecx, %ecx
cmpq %rcx, %rax
jae 0x6a14
movq -0x48(%rbp), %rax
movq %rax, -0xf8(%rbp)
cmpq $0x0, %rax
je 0x69da
movq -0xf8(%rbp), %rdi
callq 0x1160
movq -0x20(%rbp), %rax
movq %rax, -0x100(%rbp)
cmpq $0x0, %rax
je 0x69fc
movq -0x100(%rbp), %rdi
movl $0x1, %esi
callq 0x1130
movq -0xb8(%rbp), %rdi
leaq 0x7964(%rip), %rsi      # 0xe36e
callq 0x2c30
jmp 0x8004
movq -0xb8(%rbp), %rsi
movl -0x4c(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x4c(%rbp)
movq -0x20(%rbp), %rax
movl -0x4c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x4c(%rbp)
movl %ecx, %ecx
movzbl (%rax,%rcx), %ecx
movq -0x48(%rbp), %rax
movl -0x50(%rbp), %edx
movzbl 0x145008(%rsi), %esi
addl $0x1, %esi
imull %esi, %edx
addl -0x54(%rbp), %edx
movl %edx, %edx
imulq $0xc08, %rdx, %rdx      # imm = 0xC08
addq %rdx, %rax
movl %ecx, 0x4(%rax)
movl $0x0, -0x58(%rbp)
movq -0xb8(%rbp), %rsi
movl -0x58(%rbp), %eax
movq -0x48(%rbp), %rcx
movl -0x50(%rbp), %edx
movzbl 0x145008(%rsi), %esi
addl $0x1, %esi
imull %esi, %edx
addl -0x54(%rbp), %edx
movl %edx, %edx
imulq $0xc08, %rdx, %rdx      # imm = 0xC08
addq %rdx, %rcx
cmpl 0x4(%rcx), %eax
jae 0x6c09
movq -0xb8(%rbp), %rdi
movq -0x48(%rbp), %rax
movl -0x50(%rbp), %ecx
movzbl 0x145008(%rdi), %edx
addl $0x1, %edx
imull %edx, %ecx
addl -0x54(%rbp), %ecx
movl %ecx, %ecx
imulq $0xc08, %rcx, %rcx      # imm = 0xC08
addq %rcx, %rax
addq $0x8, %rax
movl -0x58(%rbp), %ecx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq -0x20(%rbp), %rcx
movl -0x4c(%rbp), %edx
movl (%rcx,%rdx), %esi
movl %esi, (%rax)
movb 0x4(%rcx,%rdx), %cl
movb %cl, 0x4(%rax)
movl -0x4c(%rbp), %eax
addl $0x5, %eax
movl %eax, -0x4c(%rbp)
movq -0x20(%rbp), %rax
movl -0x4c(%rbp), %ecx
movzwl (%rax,%rcx), %ecx
movq -0x48(%rbp), %rax
movl -0x50(%rbp), %edx
movzbl 0x145008(%rdi), %esi
addl $0x1, %esi
imull %esi, %edx
addl -0x54(%rbp), %edx
movl %edx, %edx
imulq $0xc08, %rdx, %rdx      # imm = 0xC08
addq %rdx, %rax
addq $0x8, %rax
movl -0x58(%rbp), %edx
imulq $0xc, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x8(%rax)
movl -0x4c(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x4c(%rbp)
movq -0x28(%rbp), %rax
movl -0x3c(%rbp), %ecx
movq -0x48(%rbp), %rdx
movl -0x50(%rbp), %esi
movzbl 0x145008(%rdi), %r8d
addl $0x1, %r8d
imull %r8d, %esi
addl -0x54(%rbp), %esi
movl %esi, %esi
imulq $0xc08, %rsi, %rsi      # imm = 0xC08
addq %rsi, %rdx
addl (%rdx), %ecx
movq -0x48(%rbp), %rdx
movl -0x50(%rbp), %esi
movzbl 0x145008(%rdi), %edi
addl $0x1, %edi
imull %edi, %esi
addl -0x54(%rbp), %esi
movl %esi, %esi
imulq $0xc08, %rsi, %rsi      # imm = 0xC08
addq %rsi, %rdx
addq $0x8, %rdx
movl -0x58(%rbp), %esi
imulq $0xc, %rsi, %rsi
addq %rsi, %rdx
addl 0x8(%rdx), %ecx
movl %ecx, %ecx
cmpq %rcx, %rax
jae 0x6bf9
movq -0x48(%rbp), %rax
movq %rax, -0x108(%rbp)
cmpq $0x0, %rax
je 0x6bbf
movq -0x108(%rbp), %rdi
callq 0x1160
movq -0x20(%rbp), %rax
movq %rax, -0x110(%rbp)
cmpq $0x0, %rax
je 0x6be1
movq -0x110(%rbp), %rdi
movl $0x1, %esi
callq 0x1130
movq -0xb8(%rbp), %rdi
leaq 0x777f(%rip), %rsi      # 0xe36e
callq 0x2c30
jmp 0x8004
jmp 0x6bfb
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x6a66
jmp 0x6c0b
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x68cf
jmp 0x6c1b
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x68af
movl $0x0, -0x50(%rbp)
movq -0xb8(%rbp), %rcx
movl -0x50(%rbp), %eax
movzbl 0x145007(%rcx), %ecx
cmpl %ecx, %eax
ja 0x7fa1
movl $0x0, -0x54(%rbp)
movq -0xb8(%rbp), %rcx
movl -0x54(%rbp), %eax
movzbl 0x145008(%rcx), %ecx
cmpl %ecx, %eax
ja 0x7f91
movq -0xb8(%rbp), %rax
movl -0x50(%rbp), %ecx
movl %ecx, %edx
shlq $0xa, %rdx
movq %rax, %rcx
addq %rdx, %rcx
movl -0x54(%rbp), %edx
movl $0x186a, (%rcx,%rdx,4)  # imm = 0x186A
movl -0x50(%rbp), %ecx
shlq $0xa, %rcx
addq %rcx, %rax
movl -0x54(%rbp), %ecx
movl (%rax,%rcx,4), %eax
addl $0x400, %eax            # imm = 0x400
movl %eax, %eax
movl %eax, %edi
callq 0x1030
movq %rax, %rdx
movq -0xb8(%rbp), %rax
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x50(%rbp), %esi
shlq $0xc, %rsi
addq %rsi, %rcx
movl -0x54(%rbp), %esi
shlq $0x4, %rsi
addq %rsi, %rcx
movq %rdx, (%rcx)
movl -0x50(%rbp), %ecx
shlq $0xa, %rcx
addq %rcx, %rax
movl -0x54(%rbp), %ecx
movl (%rax,%rcx,4), %eax
addl $0x400, %eax            # imm = 0x400
movl %eax, %eax
movl %eax, %edi
callq 0x1030
movq %rax, %rcx
movq -0xb8(%rbp), %rax
addq $0x40000, %rax          # imm = 0x40000
movl -0x50(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rax
movl -0x54(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
movl $0x0, -0x74(%rbp)
cmpl $0x186a, -0x74(%rbp)    # imm = 0x186A
jae 0x6d87
movq -0xb8(%rbp), %rax
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x50(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x54(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movl -0x74(%rbp), %edx
movb $0x0, (%rcx,%rdx)
addq $0x40000, %rax          # imm = 0x40000
movl -0x50(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x54(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x74(%rbp), %ecx
movb $0x0, (%rax,%rcx)
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x6d1f
movq -0xb8(%rbp), %rdx
movq -0x48(%rbp), %rax
movl -0x50(%rbp), %ecx
movzbl 0x145008(%rdx), %edx
addl $0x1, %edx
imull %edx, %ecx
addl -0x54(%rbp), %ecx
movl %ecx, %ecx
imulq $0xc08, %rcx, %rcx      # imm = 0xC08
addq %rcx, %rax
movl 0x4(%rax), %eax
movl %eax, -0x6c(%rbp)
movl $0x0, -0x68(%rbp)
movl $0x0, -0x78(%rbp)
movl -0x78(%rbp), %eax
cmpl -0x6c(%rbp), %eax
jae 0x6ea2
movq -0xb8(%rbp), %rdx
movl -0x68(%rbp), %eax
addl $0x8, %eax
movl %eax, -0x68(%rbp)
movq -0x48(%rbp), %rax
movl -0x50(%rbp), %ecx
movzbl 0x145008(%rdx), %edx
addl $0x1, %edx
imull %edx, %ecx
addl -0x54(%rbp), %ecx
movl %ecx, %ecx
imulq $0xc08, %rcx, %rcx      # imm = 0xC08
addq %rcx, %rax
addq $0x8, %rax
movl -0x78(%rbp), %ecx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movzbl 0x3(%rax), %eax
movl %eax, -0x70(%rbp)
cmpl $0x0, -0x70(%rbp)
jne 0x6e28
movl $0x80, -0x70(%rbp)
jmp 0x6e35
movl -0x70(%rbp), %ecx
movl $0x80, %eax
shll %cl, %eax
movl %eax, -0x70(%rbp)
movq -0xb8(%rbp), %rdx
movq -0x48(%rbp), %rax
movl -0x50(%rbp), %ecx
movzbl 0x145008(%rdx), %edx
addl $0x1, %edx
imull %edx, %ecx
addl -0x54(%rbp), %ecx
movl %ecx, %ecx
imulq $0xc08, %rcx, %rcx      # imm = 0xC08
addq %rcx, %rax
addq $0x8, %rax
movl -0x78(%rbp), %ecx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movzbl 0x4(%rax), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0x6e82
movl $0x0, -0x70(%rbp)
jmp 0x6e8b
movl -0x68(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x68(%rbp)
movl -0x70(%rbp), %eax
addl -0x68(%rbp), %eax
movl %eax, -0x68(%rbp)
movl -0x78(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x78(%rbp)
jmp 0x6dc5
movl -0x68(%rbp), %eax
imull $0x5, -0x6c(%rbp), %ecx
addl %ecx, %eax
cmpl $0x186a, %eax           # imm = 0x186A
jbe 0x709e
movq -0x48(%rbp), %rax
movq %rax, -0x118(%rbp)
cmpq $0x0, %rax
je 0x6ed3
movq -0x118(%rbp), %rdi
callq 0x1160
movq -0x20(%rbp), %rax
movq %rax, -0x120(%rbp)
cmpq $0x0, %rax
je 0x6ef5
movq -0x120(%rbp), %rdi
movl $0x1, %esi
callq 0x1130
movl $0x0, -0x7c(%rbp)
cmpl $0x100, -0x7c(%rbp)     # imm = 0x100
jge 0x7086
movl $0x0, -0x80(%rbp)
cmpl $0x100, -0x80(%rbp)     # imm = 0x100
jge 0x7076
movq -0xb8(%rbp), %rax
movslq -0x7c(%rbp), %rdx
shlq $0xa, %rdx
movq %rax, %rcx
addq %rdx, %rcx
movslq -0x80(%rbp), %rdx
movl $0x0, (%rcx,%rdx,4)
addq $0x40000, %rax          # imm = 0x40000
movslq -0x7c(%rbp), %rcx
shlq $0xc, %rcx
addq %rcx, %rax
movslq -0x80(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
cmpq $0x0, (%rax)
je 0x6fa5
movq -0xb8(%rbp), %rax
addq $0x40000, %rax          # imm = 0x40000
movslq -0x7c(%rbp), %rcx
shlq $0xc, %rcx
addq %rcx, %rax
movslq -0x80(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq %rax, -0x128(%rbp)
cmpq $0x0, %rax
je 0x6fa3
movq -0x128(%rbp), %rdi
movl $0x1, %esi
callq 0x1130
jmp 0x6fa5
movq -0xb8(%rbp), %rax
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movslq -0x7c(%rbp), %rdx
shlq $0xc, %rdx
addq %rdx, %rcx
movslq -0x80(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movq $0x0, (%rcx)
addq $0x40000, %rax          # imm = 0x40000
movslq -0x7c(%rbp), %rcx
shlq $0xc, %rcx
addq %rcx, %rax
movslq -0x80(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
cmpq $0x0, 0x8(%rax)
je 0x703d
movq -0xb8(%rbp), %rax
addq $0x40000, %rax          # imm = 0x40000
movslq -0x7c(%rbp), %rcx
shlq $0xc, %rcx
addq %rcx, %rax
movslq -0x80(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq %rax, -0x130(%rbp)
cmpq $0x0, %rax
je 0x703b
movq -0x130(%rbp), %rdi
movl $0x1, %esi
callq 0x1130
jmp 0x703d
movq -0xb8(%rbp), %rax
addq $0x40000, %rax          # imm = 0x40000
movslq -0x7c(%rbp), %rcx
shlq $0xc, %rcx
addq %rcx, %rax
movslq -0x80(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq $0x0, 0x8(%rax)
movl -0x80(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x80(%rbp)
jmp 0x6f10
jmp 0x7078
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0x6efc
movq -0xb8(%rbp), %rdi
leaq 0x7439(%rip), %rsi      # 0xe4cd
callq 0x2c30
jmp 0x8004
movl -0x68(%rbp), %ecx
imull $0x5, -0x6c(%rbp), %eax
addl %eax, %ecx
movl $0x186a, %eax           # imm = 0x186A
subl %ecx, %eax
movl %eax, -0x84(%rbp)
movl $0x1, -0x88(%rbp)
movl $0x1, -0x8c(%rbp)
movl $0x1, -0x90(%rbp)
movl $0x1, -0x94(%rbp)
movl $0x1, -0x98(%rbp)
movl -0x8c(%rbp), %ecx
addl -0x90(%rbp), %ecx
addl -0x94(%rbp), %ecx
addl -0x98(%rbp), %ecx
movl -0x84(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x84(%rbp)
cmpl $0x0, -0x84(%rbp)
jbe 0x7235
movl -0x84(%rbp), %eax
movl -0x6c(%rbp), %ecx
shll %ecx
cmpl %ecx, %eax
jb 0x7155
cmpl $0xc, -0x98(%rbp)
jae 0x7153
movl -0x98(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x98(%rbp)
movl -0x6c(%rbp), %ecx
shll %ecx
movl -0x84(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x84(%rbp)
jmp 0x7155
movl -0x84(%rbp), %eax
cmpl -0x6c(%rbp), %eax
jae 0x7165
jmp 0x7235
cmpl $0xa, -0x8c(%rbp)
jae 0x718e
movl -0x8c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8c(%rbp)
movl -0x6c(%rbp), %ecx
movl -0x84(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x84(%rbp)
movl -0x84(%rbp), %eax
cmpl -0x6c(%rbp), %eax
jae 0x719e
jmp 0x7235
cmpl $0x16, -0x90(%rbp)
jae 0x71c7
movl -0x90(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x90(%rbp)
movl -0x6c(%rbp), %ecx
movl -0x84(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x84(%rbp)
movl -0x84(%rbp), %eax
cmpl -0x6c(%rbp), %eax
jae 0x71d4
jmp 0x7235
cmpl $0x3c, -0x94(%rbp)
jae 0x71fd
movl -0x94(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x94(%rbp)
movl -0x6c(%rbp), %ecx
movl -0x84(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x84(%rbp)
movl -0x84(%rbp), %eax
cmpl -0x6c(%rbp), %eax
jae 0x720a
jmp 0x7235
cmpl $0xc, -0x98(%rbp)
jb 0x7230
cmpl $0xa, -0x8c(%rbp)
jb 0x7230
cmpl $0x16, -0x90(%rbp)
jb 0x7230
cmpl $0x3c, -0x94(%rbp)
jb 0x7230
jmp 0x7235
jmp 0x710c
movl -0x84(%rbp), %eax
movl -0x6c(%rbp), %ecx
shll %ecx
addl $0xa, %ecx
cmpl %ecx, %eax
jbe 0x7267
movl -0x88(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x88(%rbp)
movl -0x6c(%rbp), %ecx
movl -0x84(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x84(%rbp)
movl -0x84(%rbp), %eax
movl -0x6c(%rbp), %ecx
shll %ecx
addl $0x9, %ecx
cmpl %ecx, %eax
jbe 0x7288
movl -0x88(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x88(%rbp)
movl $0x0, -0x9c(%rbp)
movl $0x0, -0xa0(%rbp)
movl -0xa0(%rbp), %eax
cmpl -0x6c(%rbp), %eax
jae 0x7eee
movl $0x0, -0x60(%rbp)
movl -0x60(%rbp), %eax
cmpl -0x8c(%rbp), %eax
jae 0x732f
movq -0xb8(%rbp), %rax
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x50(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x54(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movl -0x9c(%rbp), %edx
movb $0x4e, (%rcx,%rdx)
addq $0x40000, %rax          # imm = 0x40000
movl -0x50(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x54(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x9c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x9c(%rbp)
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x72b2
movl $0x0, -0x60(%rbp)
movl -0x60(%rbp), %eax
cmpl -0x98(%rbp), %eax
jae 0x73b3
movq -0xb8(%rbp), %rax
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x50(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x54(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movl -0x9c(%rbp), %edx
movb $0x0, (%rcx,%rdx)
addq $0x40000, %rax          # imm = 0x40000
movl -0x50(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x54(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x9c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x9c(%rbp)
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x7336
movl -0x9c(%rbp), %eax
movl %eax, -0x5c(%rbp)
movl $0x0, -0x60(%rbp)
movl -0x60(%rbp), %eax
cmpl -0x88(%rbp), %eax
jae 0x7440
movq -0xb8(%rbp), %rax
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x50(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x54(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movl -0x9c(%rbp), %edx
movb $-0x5f, (%rcx,%rdx)
addq $0x40000, %rax          # imm = 0x40000
movl -0x50(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x54(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x9c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x9c(%rbp)
movl %ecx, %ecx
movb $-0x1, (%rax,%rcx)
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x73c3
movq -0xb8(%rbp), %rdi
movq %rdi, %rax
addq $0x40000, %rax          # imm = 0x40000
movl -0x50(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x54(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl -0x9c(%rbp), %ecx
movb $-0x2, (%rax,%rcx)
movq %rdi, %rax
addq $0x40000, %rax          # imm = 0x40000
movl -0x50(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x54(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x9c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x9c(%rbp)
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movq -0x48(%rbp), %rax
movl -0x50(%rbp), %ecx
movzbl 0x145008(%rdi), %edx
addl $0x1, %edx
imull %edx, %ecx
addl -0x54(%rbp), %ecx
movl %ecx, %ecx
imulq $0xc08, %rcx, %rcx      # imm = 0xC08
addq %rcx, %rax
addq $0x8, %rax
movl -0xa0(%rbp), %ecx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movb (%rax), %dl
movq %rdi, %rax
addq $0x40000, %rax          # imm = 0x40000
movl -0x50(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x54(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl -0x9c(%rbp), %ecx
movb %dl, (%rax,%rcx)
movq %rdi, %rax
addq $0x40000, %rax          # imm = 0x40000
movl -0x50(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x54(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x9c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x9c(%rbp)
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movq -0x48(%rbp), %rax
movl -0x50(%rbp), %ecx
movzbl 0x145008(%rdi), %edx
addl $0x1, %edx
imull %edx, %ecx
addl -0x54(%rbp), %ecx
movl %ecx, %ecx
imulq $0xc08, %rcx, %rcx      # imm = 0xC08
addq %rcx, %rax
addq $0x8, %rax
movl -0xa0(%rbp), %ecx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movb 0x1(%rax), %dl
movq %rdi, %rax
addq $0x40000, %rax          # imm = 0x40000
movl -0x50(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x54(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl -0x9c(%rbp), %ecx
movb %dl, (%rax,%rcx)
movq %rdi, %rax
addq $0x40000, %rax          # imm = 0x40000
movl -0x50(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x54(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x9c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x9c(%rbp)
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movq -0x48(%rbp), %rax
movl -0x50(%rbp), %ecx
movzbl 0x145008(%rdi), %edx
addl $0x1, %edx
imull %edx, %ecx
addl -0x54(%rbp), %ecx
movl %ecx, %ecx
imulq $0xc08, %rcx, %rcx      # imm = 0xC08
addq %rcx, %rax
addq $0x8, %rax
movl -0xa0(%rbp), %ecx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movb 0x2(%rax), %dl
movq %rdi, %rax
addq $0x40000, %rax          # imm = 0x40000
movl -0x50(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x54(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl -0x9c(%rbp), %ecx
movb %dl, (%rax,%rcx)
movq %rdi, %rax
addq $0x40000, %rax          # imm = 0x40000
movl -0x50(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x54(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x9c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x9c(%rbp)
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movq -0x48(%rbp), %rax
movl -0x50(%rbp), %ecx
movzbl 0x145008(%rdi), %edx
addl $0x1, %edx
imull %edx, %ecx
addl -0x54(%rbp), %ecx
movl %ecx, %ecx
imulq $0xc08, %rcx, %rcx      # imm = 0xC08
addq %rcx, %rax
addq $0x8, %rax
movl -0xa0(%rbp), %ecx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movb 0x3(%rax), %dl
movq %rdi, %rax
addq $0x40000, %rax          # imm = 0x40000
movl -0x50(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x54(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl -0x9c(%rbp), %ecx
movb %dl, (%rax,%rcx)
movq %rdi, %rax
addq $0x40000, %rax          # imm = 0x40000
movl -0x50(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x54(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x9c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x9c(%rbp)
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movq %rdi, %rax
addq $0x40000, %rax          # imm = 0x40000
movl -0x50(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x54(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rsi
movl -0x5c(%rbp), %eax
addq %rax, %rsi
movl -0x9c(%rbp), %eax
subl -0x5c(%rbp), %eax
movl %eax, %eax
movl %eax, %edx
callq 0x1fa0
movw %ax, %cx
movq -0xb8(%rbp), %rax
movw %cx, -0x62(%rbp)
movzwl -0x62(%rbp), %ecx
sarl $0x8, %ecx
movb %cl, %sil
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x50(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x54(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movl -0x9c(%rbp), %edx
movb %sil, (%rcx,%rdx)
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x50(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x54(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq 0x8(%rcx), %rcx
movl -0x9c(%rbp), %edx
movl %edx, %esi
addl $0x1, %esi
movl %esi, -0x9c(%rbp)
movl %edx, %edx
movb $0x0, (%rcx,%rdx)
movzwl -0x62(%rbp), %ecx
andl $0xff, %ecx
movb %cl, %sil
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x50(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x54(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movl -0x9c(%rbp), %edx
movb %sil, (%rcx,%rdx)
addq $0x40000, %rax          # imm = 0x40000
movl -0x50(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x54(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x9c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x9c(%rbp)
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movl $0x0, -0x60(%rbp)
movl -0x60(%rbp), %eax
cmpl -0x90(%rbp), %eax
jae 0x78ad
movq -0xb8(%rbp), %rax
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x50(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x54(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movl -0x9c(%rbp), %edx
movb $0x4e, (%rcx,%rdx)
addq $0x40000, %rax          # imm = 0x40000
movl -0x50(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x54(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x9c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x9c(%rbp)
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x7830
movl $0x0, -0x60(%rbp)
movl -0x60(%rbp), %eax
cmpl -0x98(%rbp), %eax
jae 0x7931
movq -0xb8(%rbp), %rax
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x50(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x54(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movl -0x9c(%rbp), %edx
movb $0x0, (%rcx,%rdx)
addq $0x40000, %rax          # imm = 0x40000
movl -0x50(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x54(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x9c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x9c(%rbp)
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x78b4
movq -0xb8(%rbp), %rdx
movq -0x48(%rbp), %rax
movl -0x50(%rbp), %ecx
movzbl 0x145008(%rdx), %edx
addl $0x1, %edx
imull %edx, %ecx
addl -0x54(%rbp), %ecx
movl %ecx, %ecx
imulq $0xc08, %rcx, %rcx      # imm = 0xC08
addq %rcx, %rax
addq $0x8, %rax
movl -0xa0(%rbp), %ecx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movb 0x4(%rax), %al
movb %al, -0xa1(%rbp)
movzbl -0xa1(%rbp), %eax
andl $0x40, %eax
cmpl $0x0, %eax
jne 0x7e54
movl -0x9c(%rbp), %eax
movl %eax, -0x5c(%rbp)
movl $0x0, -0x60(%rbp)
movl -0x60(%rbp), %eax
cmpl -0x88(%rbp), %eax
jae 0x7a15
movq -0xb8(%rbp), %rax
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x50(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x54(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movl -0x9c(%rbp), %edx
movb $-0x5f, (%rcx,%rdx)
addq $0x40000, %rax          # imm = 0x40000
movl -0x50(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x54(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x9c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x9c(%rbp)
movl %ecx, %ecx
movb $-0x1, (%rax,%rcx)
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x7998
movzbl -0xa1(%rbp), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x7a56
movq -0xb8(%rbp), %rax
addq $0x40000, %rax          # imm = 0x40000
movl -0x50(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x54(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl -0x9c(%rbp), %ecx
movb $-0x8, (%rax,%rcx)
jmp 0x7a84
movq -0xb8(%rbp), %rax
addq $0x40000, %rax          # imm = 0x40000
movl -0x50(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x54(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl -0x9c(%rbp), %ecx
movb $-0x5, (%rax,%rcx)
movq -0xb8(%rbp), %rdx
movq %rdx, %rax
addq $0x40000, %rax          # imm = 0x40000
movl -0x50(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x54(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x9c(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x9c(%rbp)
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movq -0x48(%rbp), %rax
movl -0x50(%rbp), %ecx
movzbl 0x145008(%rdx), %edx
addl $0x1, %edx
imull %edx, %ecx
addl -0x54(%rbp), %ecx
movl %ecx, %ecx
imulq $0xc08, %rcx, %rcx      # imm = 0xC08
addq %rcx, %rax
addq $0x8, %rax
movl -0xa0(%rbp), %ecx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movzbl 0x3(%rax), %eax
movl %eax, -0x70(%rbp)
cmpl $0x0, -0x70(%rbp)
jne 0x7b0d
movl $0x80, -0x70(%rbp)
jmp 0x7b1a
movl -0x70(%rbp), %ecx
movl $0x80, %eax
shll %cl, %eax
movl %eax, -0x70(%rbp)
movq -0xb8(%rbp), %rsi
movl -0x3c(%rbp), %eax
movq -0x48(%rbp), %rcx
movl -0x50(%rbp), %edx
movzbl 0x145008(%rsi), %edi
addl $0x1, %edi
imull %edi, %edx
addl -0x54(%rbp), %edx
movl %edx, %edx
imulq $0xc08, %rdx, %rdx      # imm = 0xC08
addq %rdx, %rcx
addl (%rcx), %eax
movq -0x48(%rbp), %rcx
movl -0x50(%rbp), %edx
movzbl 0x145008(%rsi), %esi
addl $0x1, %esi
imull %esi, %edx
addl -0x54(%rbp), %edx
movl %edx, %edx
imulq $0xc08, %rdx, %rdx      # imm = 0xC08
addq %rdx, %rcx
addq $0x8, %rcx
movl -0xa0(%rbp), %edx
imulq $0xc, %rdx, %rdx
addq %rdx, %rcx
addl 0x8(%rcx), %eax
movl %eax, -0xa8(%rbp)
movl $0x0, -0x60(%rbp)
movl -0x60(%rbp), %eax
cmpl -0x70(%rbp), %eax
jae 0x7c21
movq -0xb8(%rbp), %rax
movq -0x20(%rbp), %rcx
movl -0xa8(%rbp), %edx
addl -0x60(%rbp), %edx
movl %edx, %edx
movb (%rcx,%rdx), %sil
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x50(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x54(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movl -0x9c(%rbp), %edx
movb %sil, (%rcx,%rdx)
addq $0x40000, %rax          # imm = 0x40000
movl -0x50(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x54(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x9c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x9c(%rbp)
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x7b8d
movq -0xb8(%rbp), %rdi
movq %rdi, %rax
addq $0x40000, %rax          # imm = 0x40000
movl -0x50(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x54(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rsi
movl -0x5c(%rbp), %eax
addq %rax, %rsi
movl -0x9c(%rbp), %eax
subl -0x5c(%rbp), %eax
movl %eax, %eax
movl %eax, %edx
callq 0x1fa0
movw %ax, -0x62(%rbp)
movzbl -0xa1(%rbp), %eax
andl $0x3f, %eax
cmpl $0x0, %eax
je 0x7d5e
movq -0xb8(%rbp), %rax
movzwl -0x62(%rbp), %ecx
sarl $0x8, %ecx
movb %cl, %sil
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x50(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x54(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movl -0x9c(%rbp), %edx
movb %sil, (%rcx,%rdx)
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x50(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x54(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq 0x8(%rcx), %rcx
movl -0x9c(%rbp), %edx
movl %edx, %esi
addl $0x1, %esi
movl %esi, -0x9c(%rbp)
movl %edx, %edx
movb $0x0, (%rcx,%rdx)
movzwl -0x62(%rbp), %ecx
andl $0xff, %ecx
movb %cl, %sil
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x50(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x54(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movl -0x9c(%rbp), %edx
movb %sil, (%rcx,%rdx)
addq $0x40000, %rax          # imm = 0x40000
movl -0x50(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x54(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x9c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x9c(%rbp)
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
jmp 0x7e52
movq -0xb8(%rbp), %rax
movzwl -0x62(%rbp), %ecx
sarl $0x8, %ecx
movzbl %cl, %ecx
xorl $0xff, %ecx
movb %cl, %sil
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x50(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x54(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movl -0x9c(%rbp), %edx
movb %sil, (%rcx,%rdx)
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x50(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x54(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq 0x8(%rcx), %rcx
movl -0x9c(%rbp), %edx
movl %edx, %esi
addl $0x1, %esi
movl %esi, -0x9c(%rbp)
movl %edx, %edx
movb $0x0, (%rcx,%rdx)
movzwl -0x62(%rbp), %ecx
andl $0xff, %ecx
movzbl %cl, %ecx
xorl $0xff, %ecx
movb %cl, %sil
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x50(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x54(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movl -0x9c(%rbp), %edx
movb %sil, (%rcx,%rdx)
addq $0x40000, %rax          # imm = 0x40000
movl -0x50(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x54(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x9c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x9c(%rbp)
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
jmp 0x7e54
movl $0x0, -0x60(%rbp)
movl -0x60(%rbp), %eax
cmpl -0x94(%rbp), %eax
jae 0x7ed8
movq -0xb8(%rbp), %rax
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x50(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x54(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movl -0x9c(%rbp), %edx
movb $0x4e, (%rcx,%rdx)
addq $0x40000, %rax          # imm = 0x40000
movl -0x50(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x54(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x9c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x9c(%rbp)
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x7e5b
jmp 0x7eda
movl -0xa0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa0(%rbp)
jmp 0x729c
movl -0x9c(%rbp), %eax
movl %eax, -0xac(%rbp)
cmpl $0x186a, -0xac(%rbp)    # imm = 0x186A
jge 0x7f81
movq -0xb8(%rbp), %rax
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x50(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x54(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movl -0x9c(%rbp), %edx
movb $0x4e, (%rcx,%rdx)
addq $0x40000, %rax          # imm = 0x40000
movl -0x50(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x54(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x9c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x9c(%rbp)
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movl -0xac(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xac(%rbp)
jmp 0x7efa
jmp 0x7f83
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x6c50
jmp 0x7f93
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x6c30
movq -0x48(%rbp), %rax
movq %rax, -0x138(%rbp)
cmpq $0x0, %rax
je 0x7fbe
movq -0x138(%rbp), %rdi
callq 0x1160
movq -0x20(%rbp), %rax
movq %rax, -0x140(%rbp)
cmpq $0x0, %rax
je 0x7fe0
movq -0x140(%rbp), %rdi
movl $0x1, %esi
callq 0x1130
movq -0xb8(%rbp), %rax
movb -0xd(%rbp), %cl
andb $0x1, %cl
movb %cl, 0x145005(%rax)
movl $0x3, 0x141000(%rax)
movb $0x1, 0x145006(%rax)
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
nopl (%rax)