// File: /workspace/github_cpp_makefile_star2_O2/atsidaev[P]trx2x/DiskImage.cpp
// Function: TDiskImage::readTD0(int, bool)
void TDiskImage::readTD0(int hfile, bool readonly)
{
   long fsize = filelength(hfile);
   if(fsize < 0)
   {
      ShowError(ERR_GETLEN);
      return;
   }
   unsigned char *ptr = (unsigned char*)new char[fsize+256*20000];
   if(!ptr)
   {
      ShowError(ERR_NOMEM);
      return;
   }
   long rsize = read(hfile, ptr, fsize);

   TD0_MAIN_HEADER *td0hdr = (TD0_MAIN_HEADER*)ptr; 
   TD0_INFO_DATA *td0inf = (TD0_INFO_DATA*)(ptr+12);

   if(!rsize)
   {
      delete ptr;
      ShowError(ERR_CORRUPT);
      return;
   }
   if(rsize < 12)      // header
   {
      delete ptr;
      ShowError(ERR_CORRUPT);
      return;
   }

   if( (*(short*)ptr != WORD2('T','D'))&&(*(short*)ptr != WORD2('t','d')) )// non TD0
   {
      delete ptr;
      ShowError(ERR_FORMAT" TD0!");
      return;
   }
   if( TD0CRC(ptr,10) != td0hdr->CRC ) // CRC bad...
   {
      delete ptr;
      ShowError(ERR_FILECRC" TD0!");
      return;
   }
   if( (td0hdr->Ver > 21)||(td0hdr->Ver < 10) )           // 1.0 <= version <= 2.1...
   {
      delete ptr;
      ShowError(ERR_FILEVER" TD0!");
      return;
   }
   if( td0hdr->DataDOS != 0 )           // if DOS allocated sectors only...
   {
      delete ptr;
      ShowError(ERR_TD0DOSALLOC);
      return;
   }
   if(!unpack_td0(ptr, rsize))
   {
      delete ptr;
      ShowError(ERR_FORMAT" TD0!");
      return;
   }

// loading unpacked TD0...

   int tdOFF = 12;
   if(ptr[7] & 0x80) tdOFF += sizeof(TD0_INFO_DATA) + td0inf->strLen;

   TD0_TRACK_HEADER *tdtrk;
   TD0_SECT_HEADER *tdsect;

   MaxTrack = 0;
   MaxSide = 0;

   for(; tdOFF < rsize ;)
   {
      tdtrk = (TD0_TRACK_HEADER*)(ptr+tdOFF);
      tdOFF += sizeof(TD0_TRACK_HEADER);

      if(tdOFF >= rsize) break;
      if( tdtrk->SectorCount == 0xFF ) break;   // EOF marker


      unsigned trk = tdtrk->Track;
      unsigned side = tdtrk->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;         
      }


      unsigned SecCount = tdtrk->SectorCount;

      unsigned int tmpOFF = tdOFF;

// Вычисляем необходимое число байт под данные:
      unsigned int trkdatalen = 0;
      unsigned int SL;
      for(unsigned int ilsec=0; ilsec < SecCount; ilsec++)
      {
         tdsect = (TD0_SECT_HEADER*)(ptr+tmpOFF); 
         tmpOFF += sizeof(TD0_SECT_HEADER)+tdsect->DataLength;

         trkdatalen += 2+6;     // for marks:   0xA1, 0xFE, 6bytes
         trkdatalen += 4;       // for data header/crc: 0xA1, 0xFB, ...,2bytes
//         SL = unsigned(tdsect->ADRM[3]);
//         if(!SL) SL = 128;
//         else SL = 128 << SL;
         SL = tdsect->DataLength-1;
         trkdatalen += SL;
      }

// проверка на возможность формата...
      if(trkdatalen + SecCount*(3+2) > 6250)    // 3x4E & 2x00 per sec checking
      {
         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;
      unsigned int ptrcrc;
      unsigned int r;
      unsigned short vgcrc;
      for(unsigned sec=0; sec < SecCount; sec++)
      {
         tdsect = (TD0_SECT_HEADER*)(ptr+tdOFF); 
         tdOFF += sizeof(TD0_SECT_HEADER)+1;

         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] = tdsect->ADRM[0]; // cyl
         FTracksPtr[trk][side][1][tptr++] = 0x00;
         FTracksPtr[trk][side][0][tptr] = tdsect->ADRM[1]; // head 
         FTracksPtr[trk][side][1][tptr++] = 0x00;
         FTracksPtr[trk][side][0][tptr] = tdsect->ADRM[2]; // secN
         FTracksPtr[trk][side][1][tptr++] = 0x00;
         FTracksPtr[trk][side][0][tptr] = tdsect->ADRM[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;
         }

         if(tdsect->DataLength-1) // 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;
            }

            FTracksPtr[trk][side][0][tptr] = 0xFB;   // Метка "Данные"
            FTracksPtr[trk][side][1][tptr++] = 0x00;

//            SL = unsigned(tdsect->ADRM[3]);
//            if(!SL) SL = 128;
//            else SL = 128 << SL;
            SL = tdsect->DataLength-1;

            for(r=0; r < SL; r++)        // сектор SL байт
            {
               FTracksPtr[trk][side][0][tptr] = ptr[tdOFF+r];
               FTracksPtr[trk][side][1][tptr++] = 0x00;
            }
            tdOFF += SL;

            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 < 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;
      }

      if(unsigned(MaxTrack) < trk) MaxTrack = trk;
      if(unsigned(MaxSide) < side) MaxSide = side;
   }

   delete ptr;
   ReadOnly = readonly;
   FType = DIT_TD0;
   DiskPresent = true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movl %edx, %ebx
movl %esi, %r15d
movq %rdi, %rbp
movl %esi, %edi
callq 0x6db6
testq %rax, %rax
js 0x4dff
movq %rax, %r12
movq %rax, %rdi
addq $0x4e2000, %rdi         # imm = 0x4E2000
callq 0x1030
movq %rax, %r14
movl %r15d, %edi
movq %rax, %rsi
movq %r12, %rdx
callq 0x11a0
movq %rax, 0x50(%rsp)
testq %rax, %rax
je 0x4e08
movq %r14, 0x18(%rsp)
cmpq $0xb, %rax
jg 0x4e30
pushq $0x1
popq %rsi
movq 0x18(%rsp), %rdi
jmp 0x4e0e
leaq 0x2552(%rip), %rsi      # 0x7358
jmp 0x4e1a
pushq $0x1
popq %rsi
movq %r14, %rdi
callq 0x1140
leaq 0x255c(%rip), %rsi      # 0x7376
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x201c
movq 0x18(%rsp), %rdi
movzwl (%rdi), %eax
cmpl $0x4454, %eax           # imm = 0x4454
je 0x4e46
cmpl $0x6474, %eax           # imm = 0x6474
jne 0x4e84
pushq $0xa
popq %rsi
callq 0x6484
movq 0x18(%rsp), %rdi
cmpw 0xa(%rdi), %ax
jne 0x4e73
movb 0x4(%rdi), %al
addb $-0x16, %al
cmpb $-0xd, %al
ja 0x4e95
pushq $0x1
popq %rsi
callq 0x1140
leaq 0x28aa(%rip), %rsi      # 0x771b
jmp 0x4e1a
pushq $0x1
popq %rsi
callq 0x1140
leaq 0x2880(%rip), %rsi      # 0x7702
jmp 0x4e1a
pushq $0x1
popq %rsi
callq 0x1140
leaq 0x2852(%rip), %rsi      # 0x76e5
jmp 0x4e1a
cmpb $0x0, 0x8(%rdi)
je 0x4eaf
pushq $0x1
popq %rsi
callq 0x1140
leaq 0x2890(%rip), %rsi      # 0x773a
jmp 0x4e1a
leaq 0x50(%rsp), %rsi
movq %rdi, %r14
callq 0x64b5
testb %al, %al
je 0x4ed4
cmpb $0x0, 0x7(%r14)
movq %r14, %r10
movl %ebx, 0x30(%rsp)
js 0x4edc
pushq $0xc
popq %r11
jmp 0x4ee5
pushq $0x1
popq %rsi
movq %r14, %rdi
jmp 0x4e87
movzwl 0xe(%r10), %r11d
addl $0x16, %r11d
andw $0x0, 0x145007(%rbp)
movq 0x50(%rsp), %rcx
leaq 0x40000(%rbp), %rax
movq %rax, 0x60(%rsp)
leaq 0x40008(%rbp), %rax
movq %rax, 0x58(%rsp)
xorl %r12d, %r12d
movq %rbp, 0x40(%rsp)
movq %rcx, 0x38(%rsp)
movslq %r11d, %rbx
cmpq %rbx, %rcx
jle 0x54c7
addl $0x4, %r11d
movslq %r11d, %rax
cmpq %rax, %rcx
jle 0x54c7
cmpb $-0x1, (%r10,%rbx)
je 0x54c7
movzbl 0x1(%r10,%rbx), %r14d
movzbl 0x2(%r10,%rbx), %r15d
movl %r14d, %eax
shll $0xa, %eax
addq %rbp, %rax
movl $0x186a, (%rax,%r15,4)  # imm = 0x186A
movl $0x1c6a, %edi           # imm = 0x1C6A
movl %r11d, 0x14(%rsp)
callq 0x1030
movl %r14d, 0x34(%rsp)
shll $0xc, %r14d
addq 0x60(%rsp), %r14
movq %r15, 0x68(%rsp)
shll $0x4, %r15d
leaq (%r14,%r15), %rbp
movq %rax, (%r15,%r14)
movl $0x1c6a, %edi           # imm = 0x1C6A
callq 0x1030
movl 0x14(%rsp), %r11d
movq %rax, 0x8(%r15,%r14)
xorl %eax, %eax
cmpq $0x186a, %rax           # imm = 0x186A
je 0x4fbc
movq (%rbp), %rcx
movb %r12b, (%rcx,%rax)
movq 0x8(%rbp), %rcx
movb %r12b, (%rcx,%rax)
incq %rax
jmp 0x4f9f
movq 0x18(%rsp), %r10
movzbl (%r10,%rbx), %r8d
xorl %esi, %esi
movl %r8d, %eax
movl %r11d, %ecx
subl $0x1, %eax
jb 0x4fe7
movl %ecx, %edx
movzwl 0x6(%r10,%rdx), %edx
addl %edx, %ecx
addl $0x8, %ecx
addl %edx, %esi
addl $0xb, %esi
jmp 0x4fce
leal (%r8,%r8,4), %eax
addl %eax, %esi
cmpl $0x186b, %esi           # imm = 0x186B
movq %rsi, 0x48(%rsp)
jae 0x5023
cmpl $0x1866, %esi           # imm = 0x1866
jne 0x50c4
leal (%r8,%r8), %ecx
xorl %eax, %eax
pushq $0x1
popq %rdx
movl %edx, 0x10(%rsp)
movl %edx, 0xc(%rsp)
movl %edx, 0x8(%rsp)
movl %edx, %r13d
jmp 0x519f
movq %r10, %rdi
pushq $0x1
popq %rsi
callq 0x1140
movq 0x58(%rsp), %rbx
movq 0x40(%rsp), %rbp
movq %rbp, %r14
xorl %r15d, %r15d
cmpq $0x100, %r15            # imm = 0x100
je 0x509f
xorl %r13d, %r13d
cmpq $0x400, %r13            # imm = 0x400
je 0x508c
andl $0x0, (%r14,%r13)
movq -0x8(%rbx,%r13,4), %rdi
testq %rdi, %rdi
je 0x506a
pushq $0x1
popq %rsi
callq 0x1140
andq $0x0, -0x8(%rbx,%r13,4)
movq (%rbx,%r13,4), %rdi
testq %rdi, %rdi
je 0x5081
pushq $0x1
popq %rsi
callq 0x1140
andq $0x0, (%rbx,%r13,4)
addq $0x4, %r13
jmp 0x504a
incq %r15
addq $0x400, %r14            # imm = 0x400
addq $0x1000, %rbx           # imm = 0x1000
jmp 0x503e
leaq 0x242f(%rip), %rsi      # 0x74d5
callq 0x201c
movq 0x18(%rsp), %r10
movq 0x38(%rsp), %rcx
movq 0x48(%rsp), %rsi
movl 0x14(%rsp), %r11d
jmp 0x54b9
movl $0x1866, %eax           # imm = 0x1866
subl %esi, %eax
leal (%r8,%r8), %ecx
pushq $0x1
popq %rdx
movl %edx, 0x10(%rsp)
movl %edx, 0xc(%rsp)
movl %edx, %r9d
movl %edx, %r13d
movl %r13d, %edx
cmpl %ecx, %eax
setae %sil
cmpl $0xc, %r13d
setb %dil
andb %sil, %dil
movl $0x0, %esi
cmovnel %ecx, %esi
subl %esi, %eax
movzbl %dil, %r13d
addl %edx, %r13d
cmpl %r8d, %eax
jb 0x519a
movl 0x10(%rsp), %esi
cmpl $0xa, %esi
movl $0x0, %edx
cmovbl %r8d, %edx
adcl $0x0, %esi
movl %esi, 0x10(%rsp)
subl %edx, %eax
cmpl %r8d, %eax
jb 0x519a
movl 0xc(%rsp), %esi
cmpl $0x16, %esi
movl $0x0, %edx
cmovbl %r8d, %edx
adcl $0x0, %esi
movl %esi, 0xc(%rsp)
subl %edx, %eax
cmpl %r8d, %eax
jb 0x519a
cmpl $0x3c, %r9d
movl $0x0, %edx
cmovbl %r8d, %edx
adcl $0x0, %r9d
subl %edx, %eax
cmpl %r8d, %eax
jb 0x519a
cmpl $0xc, %r13d
setb %dl
cmpl $0xa, 0x10(%rsp)
setb %sil
cmpl $0x16, 0xc(%rsp)
setb %dil
orb %sil, %dil
cmpl $0x3c, %r9d
setb %sil
orb %dil, %sil
orb %dl, %sil
cmpb $0x1, %sil
jne 0x519a
testl %eax, %eax
jne 0x50e0
movl %r9d, 0x8(%rsp)
leal 0xa(%rcx), %esi
xorl %edx, %edx
xorl %r15d, %r15d
cmpl %esi, %eax
movl $0x0, %esi
cmoval %r8d, %esi
seta %r15b
subl %esi, %eax
addl $0x9, %ecx
cmpl %eax, %ecx
adcl $0x1, %r15d
xorl %eax, %eax
movq %r8, 0x70(%rsp)
movl %r13d, 0x24(%rsp)
cmpl %r8d, %eax
je 0x5465
movl %eax, 0x14(%rsp)
movslq %r11d, %r8
leal 0x7(%rdx), %ebx
leal 0xa(%rdx), %r14d
movl 0x10(%rsp), %eax
subl $0x1, %eax
jb 0x5208
movq (%rbp), %rcx
movl %edx, %esi
movb $0x4e, (%rcx,%rsi)
movq 0x8(%rbp), %rcx
incl %edx
movb $0x0, (%rcx,%rsi)
incl %ebx
incl %r14d
jmp 0x51e8
xorl %ecx, %ecx
leal (%rdx,%rcx), %eax
cmpl %ecx, %r13d
je 0x522d
movq (%rbp), %rsi
movl %eax, %eax
movb %r12b, (%rsi,%rax)
movq 0x8(%rbp), %rsi
movb %r12b, (%rsi,%rax)
incl %ecx
incl %ebx
incl %r14d
jmp 0x520a
pushq $-0x5
popq %rdx
leal -0x7(%rbx), %ecx
leal (%r15,%rdx), %edi
movq (%rbp), %rsi
cmpl $-0x5, %edi
je 0x5256
movb $-0x5f, (%rsi,%rcx)
movq 0x8(%rbp), %rsi
movb $-0x1, (%rsi,%rcx)
incl %ebx
decq %rdx
incl %r14d
jmp 0x5230
movb $-0x2, (%rsi,%rcx)
movq 0x8(%rbp), %rsi
xorl %r13d, %r13d
movb %r13b, (%rsi,%rcx)
movb (%r10,%r8), %cl
movq (%rbp), %rsi
leal -0x6(%rbx), %edi
movb %cl, (%rsi,%rdi)
movq 0x8(%rbp), %rcx
leal -0x5(%rbx), %esi
movb %r13b, (%rcx,%rdi)
movb 0x1(%r10,%r8), %cl
movq (%rbp), %rdi
movb %cl, (%rdi,%rsi)
movq 0x8(%rbp), %rcx
leal -0x4(%rbx), %edi
movb %r13b, (%rcx,%rsi)
movb 0x2(%r10,%r8), %cl
movq (%rbp), %rsi
movb %cl, (%rsi,%rdi)
movq 0x8(%rbp), %rcx
leal -0x3(%rbx), %esi
movb %r13b, (%rcx,%rdi)
movq %r8, 0x28(%rsp)
movb 0x3(%r10,%r8), %cl
movq (%rbp), %rdi
movb %cl, (%rdi,%rsi)
movq 0x8(%rbp), %rcx
leal -0x2(%rbx), %edi
movq %rdi, 0x80(%rsp)
movb %r13b, (%rcx,%rsi)
movq (%rbp), %rcx
movq %rcx, 0x78(%rsp)
movl %eax, %esi
addq %rcx, %rsi
negq %rdx
callq 0x1a98
movq 0x80(%rsp), %rsi
movq 0x78(%rsp), %rcx
movb %ah, (%rcx,%rsi)
movq 0x8(%rbp), %rcx
leal -0x1(%rbx), %edx
movb %r13b, (%rcx,%rsi)
movq (%rbp), %rcx
movb %al, (%rcx,%rdx)
movq 0x8(%rbp), %rax
movb %r13b, (%rax,%rdx)
movl 0xc(%rsp), %edx
leal (%rbx,%r13), %ecx
cmpl %r13d, %edx
je 0x5337
movq (%rbp), %rax
movl %ecx, %ecx
movb $0x4e, (%rax,%rcx)
movq 0x8(%rbp), %rax
movb $0x0, (%rax,%rcx)
incl %r13d
incl %r14d
jmp 0x5314
movl 0x24(%rsp), %r13d
movl %r13d, %eax
movq 0x18(%rsp), %r10
movq 0x28(%rsp), %r9
movl %ecx, %esi
subl $0x1, %eax
jb 0x5367
movq (%rbp), %rdx
movb %r12b, (%rdx,%rsi)
movq 0x8(%rbp), %rdx
incl %ecx
movb %r12b, (%rdx,%rsi)
incl %r14d
jmp 0x5349
leal 0x9(%r9), %r11d
cmpw $0x1, 0x6(%r10,%r9)
jne 0x537c
movl %ecx, %r14d
jmp 0x5433
xorl %edx, %edx
pushq $0x1
popq %rax
leal (%rcx,%rdx), %edi
movq (%rbp), %r8
cmpl %edx, %r15d
je 0x53a4
movb $-0x5f, (%r8,%rdi)
movq 0x8(%rbp), %r8
movb $-0x1, (%r8,%rdi)
incl %edx
incl %r14d
incl %eax
jmp 0x5381
movb $-0x5, (%r8,%rdi)
movq 0x8(%rbp), %rcx
movb $0x0, (%rcx,%rdi)
movzwl 0x6(%r10,%r9), %r13d
decl %r13d
movl %r11d, %ecx
movq %r13, %rdx
leal -0x2(%r14), %ebx
subq $0x1, %rdx
jb 0x53ed
movl %ecx, %edi
movb (%r10,%rdi), %dil
movq (%rbp), %r8
movl %ebx, %r9d
movb %dil, (%r8,%r9)
movq 0x8(%rbp), %rdi
movb $0x0, (%rdi,%r9)
incl %ecx
incl %r14d
incl %eax
jmp 0x53c0
addl %r11d, %r13d
movq (%rbp), %rcx
movq %rcx, 0x28(%rsp)
addq %rcx, %rsi
movl %eax, %edx
callq 0x1a98
movq 0x18(%rsp), %r10
movq 0x28(%rsp), %rcx
movb %ah, (%rcx,%rbx)
movq 0x8(%rbp), %rcx
leal -0x1(%r14), %edx
movb %r12b, (%rcx,%rbx)
movq (%rbp), %rcx
movb %al, (%rcx,%rdx)
movq 0x8(%rbp), %rax
movb %r12b, (%rax,%rdx)
movl %r13d, %r11d
movl 0x24(%rsp), %r13d
movl 0x8(%rsp), %eax
movl %r14d, %edx
movq 0x70(%rsp), %r8
subl $0x1, %eax
jb 0x545a
movq (%rbp), %rcx
movl %edx, %esi
movb $0x4e, (%rcx,%rsi)
movq 0x8(%rbp), %rcx
incl %edx
movb $0x0, (%rcx,%rsi)
jmp 0x543f
movl 0x14(%rsp), %eax
incl %eax
jmp 0x51cd
movq 0x48(%rsp), %rsi
movq 0x68(%rsp), %rdi
cmpl $0x186a, %edx           # imm = 0x186A
jge 0x548d
movq (%rbp), %rax
movl %edx, %ecx
movb $0x4e, (%rax,%rcx)
movq 0x8(%rbp), %rax
incl %edx
movb $0x0, (%rax,%rcx)
jmp 0x546f
movq 0x40(%rsp), %rbp
movl 0x34(%rsp), %eax
cmpb %al, 0x145007(%rbp)
jae 0x54a4
movb %al, 0x145007(%rbp)
cmpb %dil, 0x145008(%rbp)
movq 0x38(%rsp), %rcx
jae 0x54b9
movb %dil, 0x145008(%rbp)
cmpl $0x186b, %esi           # imm = 0x186B
jb 0x4f17
jmp 0x54ed
pushq $0x1
popq %rsi
movq %r10, %rdi
callq 0x1140
movl 0x30(%rsp), %eax
movb %al, 0x145005(%rbp)
movl $0x4, 0x141000(%rbp)
movb $0x1, 0x145006(%rbp)
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop