// File: /workspace/github_cpp_makefile_star2_O1/atsidaev[P]trx2x/DiskImage.cpp
// Function: TDiskImage::readFDD(int, bool)
void TDiskImage::readFDD(int hfile, bool readonly)
{

   long fsize = filelength(hfile);
   if(fsize < 0 )
   {
      ShowError(ERR_GETLEN);
      return;
   }

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

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

   FDD_MAIN_HEADER *fdd_hdr = (FDD_MAIN_HEADER*)ptr;

   int MaxC = fdd_hdr->MaxTracks;
   int MaxH = fdd_hdr->MaxHeads;

   if( MaxH > 2 )
   {
      delete ptr;
      ShowError(ERR_MANYSIDS);
      return;
   }


   MaxH = (MaxH - 1)&0xFF;
   MaxC = (MaxC - 1)&0xFF;


   MaxTrack = MaxC;
   MaxSide = MaxH;


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

   FDD_TRACK_HEADER *trackinfo;

   unsigned int trk, side;

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

         if( (fdd_hdr->DataOffset[trk*(MaxSide+1)+side]+2) > int(rsize) )
         {
            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_CORRUPT);
            return;
         }

         trackinfo = (FDD_TRACK_HEADER *) (ptr + fdd_hdr->DataOffset[trk*(MaxSide+1)+side]);

         SecCount = trackinfo->SectNum;

         if( ( 2+SecCount*8 + fdd_hdr->DataOffset[trk*(MaxSide+1)+side]) > rsize )
         {
            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_CORRUPT);
            return;
         }
         else if(trackinfo->sect[SecCount-1].SectPos > int(rsize))
         {
            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_CORRUPT);
            return;
         }



// Вычисляем необходимое число байт под данные:
         trkdatalen = 0;
         for(unsigned int ilsec=0; ilsec < SecCount; ilsec++)
         {
            trkdatalen += 2+6;     // for marks:   0xA1, 0xFE, 6bytes
            SL = unsigned(trackinfo->sect[ilsec].size);
            if(!SL) SL = 128;
            else SL = 128 << SL;

            trkdatalen += 4;       // for data header/crc: 0xA1, 0xFB, ...,2bytes

            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;
         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] = trackinfo->sect[sec].trk;  // cyl
            FTracksPtr[trk][side][1][tptr++] = 0x00;
            FTracksPtr[trk][side][0][tptr] = trackinfo->sect[sec].side; // head 
            FTracksPtr[trk][side][1][tptr++] = 0x00;
            FTracksPtr[trk][side][0][tptr] = trackinfo->sect[sec].sect; // secN
            FTracksPtr[trk][side][1][tptr++] = 0x00;
            FTracksPtr[trk][side][0][tptr] = trackinfo->sect[sec].size; // 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;
            }


// DATA AM
            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( trackinfo->sect[sec].size );
            if(!SL) SL = 128;
            else SL = 128 << SL;

            unsigned int secDATAOFF = trackinfo->sect[sec].SectPos;

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


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

   delete ptr;
   ReadOnly = readonly;
   FType = DIT_FDD;
   DiskPresent = true;

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movl %edx, 0x18(%rsp)
movl %esi, %r15d
movq %rdi, %r13
movl %esi, %edi
xorl %esi, %esi
movl $0x1, %edx
callq 0x1210
movq %rax, %r14
movl %r15d, %edi
xorl %esi, %esi
movl $0x2, %edx
callq 0x1210
movq %rax, %r12
movl %r15d, %edi
movq %r14, %rsi
xorl %edx, %edx
callq 0x1210
testq %r12, %r12
js 0x6231
movq %r12, %rdi
addq $0x8000, %rdi           # imm = 0x8000
callq 0x1030
movq %rax, %rbx
movl %r15d, %edi
movq %rax, %rsi
movq %r12, %rdx
callq 0x11b0
cmpq $0x1023, %rax           # imm = 0x1023
ja 0x623a
movl $0x1, %esi
movq %rbx, %rdi
callq 0x1150
leaq 0x2147(%rip), %rsi      # 0x8376
jmp 0x6256
leaq 0x2120(%rip), %rsi      # 0x8358
jmp 0x6256
movb 0x1f(%rbx), %dl
cmpb $0x3, %dl
jb 0x6269
movl $0x1, %esi
movq %rbx, %rdi
callq 0x1150
leaq 0x224e(%rip), %rsi      # 0x84a4
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x23fa
movq %rax, 0x58(%rsp)
movb 0x1e(%rbx), %cl
decb %dl
decb %cl
movb %cl, 0x145007(%r13)
movb %dl, 0x145008(%r13)
leaq 0x40000(%r13), %rax
movq %rbx, 0x8(%rsp)
leaq 0x5(%rbx), %rcx
movq %rcx, 0x40(%rsp)
xorl %r12d, %r12d
xorl %r14d, %r14d
movq %r13, 0x48(%rsp)
movq %rax, 0x38(%rsp)
movq %r14, %rcx
shlq $0xa, %rcx
addq %r13, %rcx
movq %rcx, 0x68(%rsp)
movq %r14, %rcx
shlq $0xc, %rcx
addq %rax, %rcx
movq %rcx, 0x60(%rsp)
xorl %ebx, %ebx
movq %r14, 0x50(%rsp)
movq 0x68(%rsp), %rax
movl $0x186a, (%rax,%rbx,4)  # imm = 0x186A
movl $0x1c6a, %edi           # imm = 0x1C6A
callq 0x1030
movq %rbx, 0x28(%rsp)
shlq $0x4, %rbx
movq 0x60(%rsp), %rbp
leaq (%rbx,%rbp), %r15
movq %rax, (%rbx,%rbp)
movl $0x1c6a, %edi           # imm = 0x1C6A
callq 0x1030
movq %rax, 0x8(%rbx,%rbp)
xorl %eax, %eax
movq (%r15), %rcx
movb %r12b, (%rcx,%rax)
movq 0x8(%r15), %rcx
movb %r12b, (%rcx,%rax)
incq %rax
cmpq $0x186a, %rax           # imm = 0x186A
jne 0x630a
movzbl 0x145008(%r13), %eax
incq %rax
imulq %r14, %rax
addq 0x28(%rsp), %rax
movq 0x8(%rsp), %rdi
movl 0x24(%rdi,%rax,4), %edx
leal 0x2(%rdx), %eax
movq 0x58(%rsp), %rcx
cmpl %ecx, %eax
ja 0x6881
movzbl 0x1(%rdi,%rdx), %ebp
leal (%rdx,%rbp,8), %eax
addl $0x2, %eax
cmpq %rax, %rcx
jb 0x6904
leaq (%rdi,%rdx), %rsi
leal -0x1(%rbp), %eax
movq %rsi, 0x10(%rsp)
cmpl %ecx, 0x6(%rsi,%rax,8)
ja 0x6987
testq %rbp, %rbp
je 0x63a2
addq 0x40(%rsp), %rdx
xorl %edi, %edi
xorl %esi, %esi
movb (%rdx,%rdi,8), %cl
movl $0x80, %eax
shll %cl, %eax
addl %eax, %esi
addl $0xc, %esi
incq %rdi
cmpq %rdi, %rbp
jne 0x6389
jmp 0x63a4
xorl %esi, %esi
leal (%rbp,%rbp,4), %eax
addl %esi, %eax
cmpl $0x186a, %eax           # imm = 0x186A
ja 0x6a0f
movl $0x1, %r9d
xorl %r13d, %r13d
movl $0x0, %ecx
movl $0x1, %ebx
movl $0x1, %r10d
movl $0x1, %r8d
cmpl $0x1866, %eax           # imm = 0x1866
jne 0x6768
testq %rbp, %rbp
je 0x6718
movl %r10d, %edx
addq $0x2, 0x10(%rsp)
leal 0xa(,%rbp,2), %eax
xorl %r14d, %r14d
xorl %r10d, %r10d
cmpl %eax, %ecx
seta %r10b
movl $0x0, %eax
cmoval %ebp, %eax
subl %eax, %ecx
leal 0x9(,%rbp,2), %eax
cmpl %ecx, %eax
adcl $0x0, %r10d
cmpl $0x1, %r9d
adcl $0x0, %r9d
movl %r9d, 0x24(%rsp)
leal 0x1(%r10), %eax
cmpl $0x1, %r8d
adcl $0x0, %r8d
cmpl $0x1, %eax
adcl $0x1, %r10d
leal 0x5(%r10), %r11d
cmpl $0x1, %ebx
adcl $0x0, %ebx
movl %ebx, 0x20(%rsp)
cmpl $0x1, %edx
adcl $0x0, %edx
movl %edx, 0x1c(%rsp)
movl %ebp, %eax
movq %rax, 0x70(%rsp)
xorl %r13d, %r13d
leal 0x9(%r13), %eax
leal 0xd(%r13), %edi
movl 0x24(%rsp), %edx
movl %eax, %ecx
movl %edi, %esi
movq (%r15), %rax
movl %r13d, %edi
movb $0x4e, (%rax,%rdi)
movq 0x8(%r15), %rax
incl %r13d
movb $0x0, (%rax,%rdi)
leal 0x1(%rcx), %eax
leal 0x1(%rsi), %edi
decl %edx
jne 0x6469
xorl %edi, %edi
movl %ecx, %ebp
movl %esi, %edx
leal (%rdi,%r13), %eax
movq (%r15), %rcx
movb %r12b, (%rcx,%rax)
movq 0x8(%r15), %rcx
movb %r12b, (%rcx,%rax)
incl %edi
leal 0x1(%rbp), %ecx
leal 0x1(%rdx), %esi
cmpl %edi, %r8d
jne 0x648e
addl %edi, %r13d
xorl %esi, %esi
movl %edx, %ecx
leal -0x7(%rbp), %eax
movq (%r15), %rdx
movb $-0x5f, (%rdx,%rax)
movq 0x8(%r15), %rdx
movb $-0x1, (%rdx,%rax)
incl %esi
incl %ebp
leal 0x1(%rcx), %edx
cmpl %esi, %r10d
jne 0x64b7
movq (%r15), %rax
leal -0x7(%rbp), %edx
movb $-0x2, (%rax,%rdx)
movq 0x8(%r15), %rax
leal -0x6(%rbp), %edi
movb %r12b, (%rax,%rdx)
movq 0x10(%rsp), %r9
movb (%r9,%r14,8), %al
movq (%r15), %rdx
movb %al, (%rdx,%rdi)
movq 0x8(%r15), %rax
leal -0x5(%rbp), %edx
movb %r12b, (%rax,%rdi)
movb 0x1(%r9,%r14,8), %al
movq (%r15), %rdi
movb %al, (%rdi,%rdx)
movq 0x8(%r15), %rax
leal -0x4(%rbp), %edi
movb %r12b, (%rax,%rdx)
movb 0x2(%r9,%r14,8), %al
movq (%r15), %rdx
movb %al, (%rdx,%rdi)
movq 0x8(%r15), %rax
leal -0x3(%rbp), %edx
movb %r12b, (%rax,%rdi)
movq %r14, 0x30(%rsp)
movb 0x3(%r9,%r14,8), %al
movq (%r15), %rdi
movb %al, (%rdi,%rdx)
movq 0x8(%r15), %rax
movb %r12b, (%rax,%rdx)
movq (%r15), %rdi
movw $0xffff, %dx            # imm = 0xFFFF
cmpl $-0x5, %esi
je 0x6593
movl %r13d, %esi
addq %rdi, %rsi
movw $0xffff, %dx            # imm = 0xFFFF
xorl %r13d, %r13d
movzbl (%rsi,%r13), %eax
shll $0x8, %eax
xorl %eax, %edx
movl $0x8, %ebx
leal (%rdx,%rdx), %r14d
movl %r14d, %eax
xorl $0x1021, %eax           # imm = 0x1021
testw %dx, %dx
cmovnsl %r14d, %eax
movl %eax, %edx
decl %ebx
jne 0x6572
incq %r13
cmpq %r11, %r13
jne 0x6563
leal -0x2(%rbp), %eax
movl %eax, %eax
movb %dh, (%rdi,%rax)
movq 0x8(%r15), %rsi
leal -0x1(%rbp), %edi
movb %r12b, (%rsi,%rax)
movq (%r15), %rax
movb %dl, (%rax,%rdi)
movq 0x8(%r15), %rax
movb %r12b, (%rax,%rdi)
movl 0x20(%rsp), %esi
movl %ecx, %edx
movq (%r15), %rax
movl %ebp, %ecx
movb $0x4e, (%rax,%rcx)
movq 0x8(%r15), %rax
incl %ebp
movb $0x0, (%rax,%rcx)
leal 0x1(%rdx), %ecx
decl %esi
jne 0x65b8
movl %r8d, %ecx
movq 0x30(%rsp), %r9
movl %edx, %esi
movq (%r15), %rax
movl %ebp, %edx
movb %r12b, (%rax,%rdx)
movq 0x8(%r15), %rax
incl %ebp
movb %r12b, (%rax,%rdx)
leal 0x1(%rsi), %edx
decl %ecx
jne 0x65dc
movl %r10d, %eax
movl %esi, %edi
leal -0x1(%rdi), %ecx
movq (%r15), %rdx
movb $-0x5f, (%rdx,%rcx)
movq 0x8(%r15), %rdx
movb $-0x1, (%rdx,%rcx)
leal 0x1(%rdi), %esi
decl %eax
jne 0x65fb
movq (%r15), %rax
leal -0x1(%rsi), %r13d
movb $-0x5, (%rax,%r13)
movq 0x8(%r15), %rax
movb $0x0, (%rax,%r13)
movq 0x10(%rsp), %rax
movzbl 0x3(%rax,%r9,8), %ecx
cmpl $0x18, %ecx
ja 0x667a
movl $0x80, %edx
shll %cl, %edx
movq 0x10(%rsp), %rax
movl 0x4(%rax,%r9,8), %ecx
cmpl $0x1, %edx
adcl $0x0, %edx
movq 0x8(%rsp), %r9
incl %edi
movl %ecx, %eax
movb (%r9,%rax), %al
movq (%r15), %rsi
movb %al, (%rsi,%rdi)
movq 0x8(%r15), %rax
movb $0x0, (%rax,%rdi)
incl %ecx
decq %rdx
jne 0x6657
leal 0x1(%rdi), %esi
movl %edi, %r13d
movq (%r15), %rcx
movw $0xffff, %dx            # imm = 0xFFFF
movl %esi, %edi
subl %ebp, %edi
je 0x66c5
movl %ebp, %ebp
addq %rcx, %rbp
movw $0xffff, %dx            # imm = 0xFFFF
xorl %ebx, %ebx
movzbl (%rbp,%rbx), %eax
shll $0x8, %eax
xorl %eax, %edx
movl $0x8, %eax
leal (%rdx,%rdx), %r9d
movl %r9d, %r14d
xorl $0x1021, %r14d          # imm = 0x1021
testw %dx, %dx
cmovnsl %r9d, %r14d
movl %r14d, %edx
decl %eax
jne 0x66a1
incq %rbx
cmpq %rdi, %rbx
jb 0x6692
movl %esi, %eax
movb %dh, (%rcx,%rax)
movq 0x8(%r15), %rcx
leal 0x2(%r13), %esi
movb %r12b, (%rcx,%rax)
movq (%r15), %rax
movb %dl, (%rax,%rsi)
movq 0x8(%r15), %rax
addl $0x3, %r13d
movb %r12b, (%rax,%rsi)
movl 0x1c(%rsp), %eax
movq (%r15), %rcx
movl %r13d, %edx
movb $0x4e, (%rcx,%rdx)
movq 0x8(%r15), %rcx
incl %r13d
movb $0x0, (%rcx,%rdx)
decl %eax
jne 0x66ec
movq 0x30(%rsp), %r14
incq %r14
cmpq 0x70(%rsp), %r14
jne 0x645d
cmpl $0x1869, %r13d          # imm = 0x1869
jg 0x673f
movq (%r15), %rax
movl %r13d, %ecx
movb $0x4e, (%rax,%rcx)
movq 0x8(%r15), %rax
incl %r13d
movb $0x0, (%rax,%rcx)
cmpl $0x186a, %r13d          # imm = 0x186A
jne 0x6721
movq 0x28(%rsp), %rdx
leaq 0x1(%rdx), %rbx
movq 0x48(%rsp), %r13
movzbl 0x145008(%r13), %ecx
cmpq %rcx, %rdx
movq 0x50(%rsp), %r14
jb 0x62cd
jmp 0x6828
movl $0x1866, %ecx           # imm = 0x1866
subl %eax, %ecx
leal (,%rbp,2), %edi
movl %r8d, %eax
cmpl %edi, %ecx
setae %dl
cmpl $0xc, %r8d
setb %sil
andb %dl, %sil
movl $0x0, %edx
cmovnel %edi, %edx
subl %edx, %ecx
movzbl %sil, %r8d
addl %eax, %r8d
cmpl %ebp, %ecx
jb 0x63df
cmpl $0xa, %r9d
movl $0x0, %eax
cmovbl %ebp, %eax
adcl $0x0, %r9d
subl %eax, %ecx
cmpl %ebp, %ecx
jb 0x63df
cmpl $0x16, %ebx
movl $0x0, %eax
cmovbl %ebp, %eax
adcl $0x0, %ebx
subl %eax, %ecx
cmpl %ebp, %ecx
jb 0x63df
cmpl $0x3c, %r10d
movl $0x0, %eax
cmovbl %ebp, %eax
adcl $0x0, %r10d
subl %eax, %ecx
cmpl %ebp, %ecx
jb 0x63df
cmpl $0xc, %r8d
setb %al
cmpl $0xa, %r9d
setb %dl
cmpl $0x16, %ebx
setb %sil
orb %dl, %sil
cmpl $0x3c, %r10d
setb %dl
orb %sil, %dl
orb %al, %dl
cmpb $0x1, %dl
jne 0x63df
testl %ecx, %ecx
jne 0x6776
jmp 0x63df
leaq 0x1(%r14), %rax
movzbl 0x145007(%r13), %ecx
cmpq %rcx, %r14
movq %rax, %r14
movq 0x38(%rsp), %rax
jb 0x62a8
movl $0x1, %esi
movq 0x8(%rsp), %rdi
callq 0x1150
movl 0x18(%rsp), %eax
movb %al, 0x145005(%r13)
movl $0x7, 0x141000(%r13)
movb $0x1, 0x145006(%r13)
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x1, %esi
callq 0x1150
leaq 0x40008(%r13), %r14
xorl %r15d, %r15d
xorl %ebx, %ebx
movl $0x0, (%r13,%rbx)
movq -0x8(%r14,%rbx,4), %rdi
testq %rdi, %rdi
je 0x68b4
movl $0x1, %esi
callq 0x1150
movq $0x0, -0x8(%r14,%rbx,4)
movq (%r14,%rbx,4), %rdi
testq %rdi, %rdi
je 0x68d0
movl $0x1, %esi
callq 0x1150
movq $0x0, (%r14,%rbx,4)
addq $0x4, %rbx
cmpq $0x400, %rbx            # imm = 0x400
jne 0x6897
incq %r15
addq $0x400, %r13            # imm = 0x400
addq $0x1000, %r14           # imm = 0x1000
cmpq $0x100, %r15            # imm = 0x100
jne 0x6895
jmp 0x6228
movl $0x1, %esi
callq 0x1150
leaq 0x40008(%r13), %r14
xorl %r15d, %r15d
xorl %ebx, %ebx
movl $0x0, (%r13,%rbx)
movq -0x8(%r14,%rbx,4), %rdi
testq %rdi, %rdi
je 0x6937
movl $0x1, %esi
callq 0x1150
movq $0x0, -0x8(%r14,%rbx,4)
movq (%r14,%rbx,4), %rdi
testq %rdi, %rdi
je 0x6953
movl $0x1, %esi
callq 0x1150
movq $0x0, (%r14,%rbx,4)
addq $0x4, %rbx
cmpq $0x400, %rbx            # imm = 0x400
jne 0x691a
incq %r15
addq $0x400, %r13            # imm = 0x400
addq $0x1000, %r14           # imm = 0x1000
cmpq $0x100, %r15            # imm = 0x100
jne 0x6918
jmp 0x6228
movl $0x1, %esi
movq 0x8(%rsp), %rdi
callq 0x1150
leaq 0x40008(%r13), %r14
xorl %r15d, %r15d
xorl %ebx, %ebx
movl $0x0, (%r13,%rbx)
movq -0x8(%r14,%rbx,4), %rdi
testq %rdi, %rdi
je 0x69bf
movl $0x1, %esi
callq 0x1150
movq $0x0, -0x8(%r14,%rbx,4)
movq (%r14,%rbx,4), %rdi
testq %rdi, %rdi
je 0x69db
movl $0x1, %esi
callq 0x1150
movq $0x0, (%r14,%rbx,4)
addq $0x4, %rbx
cmpq $0x400, %rbx            # imm = 0x400
jne 0x69a2
incq %r15
addq $0x400, %r13            # imm = 0x400
addq $0x1000, %r14           # imm = 0x1000
cmpq $0x100, %r15            # imm = 0x100
jne 0x69a0
jmp 0x6228
movl $0x1, %esi
movq 0x8(%rsp), %rdi
callq 0x1150
leaq 0x40008(%r13), %r14
xorl %r15d, %r15d
xorl %ebx, %ebx
movl $0x0, (%r13,%rbx)
movq -0x8(%r14,%rbx,4), %rdi
testq %rdi, %rdi
je 0x6a47
movl $0x1, %esi
callq 0x1150
movq $0x0, -0x8(%r14,%rbx,4)
movq (%r14,%rbx,4), %rdi
testq %rdi, %rdi
je 0x6a63
movl $0x1, %esi
callq 0x1150
movq $0x0, (%r14,%rbx,4)
addq $0x4, %rbx
cmpq $0x400, %rbx            # imm = 0x400
jne 0x6a2a
incq %r15
addq $0x400, %r13            # imm = 0x400
addq $0x1000, %r14           # imm = 0x1000
cmpq $0x100, %r15            # imm = 0x100
jne 0x6a28
leaq 0x1a3c(%rip), %rsi      # 0x84d5
jmp 0x6256