// File: /workspace/github_cpp_makefile_star2_O2/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 $0x88, %rsp
movl %edx, 0x1c(%rsp)
movl %esi, %r15d
movq %rdi, %r13
movl %esi, %edi
callq 0x6db6
testq %rax, %rax
js 0x5566
movq %rax, %r12
movq %rax, %rdi
addq $0x8000, %rdi           # imm = 0x8000
callq 0x1030
movq %rax, %rbx
movl %r15d, %edi
movq %rax, %rsi
movq %r12, %rdx
callq 0x11a0
cmpq $0x1023, %rax           # imm = 0x1023
ja 0x556f
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x1140
leaq 0x1e12(%rip), %rsi      # 0x7376
jmp 0x558b
leaq 0x1deb(%rip), %rsi      # 0x7358
jmp 0x558b
movq %rax, %r14
movb 0x1f(%rbx), %al
cmpb $0x3, %al
jb 0x55a1
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x1140
leaq 0x1f19(%rip), %rsi      # 0x74a4
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x201c
movb 0x1e(%rbx), %cl
decb %al
decb %cl
movb %cl, 0x145007(%r13)
movb %al, 0x145008(%r13)
leaq 0x40000(%r13), %rdx
movq %rdx, 0x48(%rsp)
movq %rbx, 0x8(%rsp)
leaq 0x5(%rbx), %rdx
movq %rdx, 0x60(%rsp)
xorl %r12d, %r12d
xorl %edx, %edx
movq %r13, 0x58(%rsp)
movq %r14, 0x50(%rsp)
movzbl %cl, %ecx
cmpq %rcx, %rdx
ja 0x5ce4
movq %rdx, %rcx
shlq $0xa, %rcx
addq %r13, %rcx
movq %rcx, 0x70(%rsp)
movq %rdx, 0x28(%rsp)
shlq $0xc, %rdx
addq 0x48(%rsp), %rdx
movq %rdx, 0x68(%rsp)
xorl %ebx, %ebx
movzbl %al, %ecx
cmpq %rcx, %rbx
ja 0x5ace
movq 0x70(%rsp), %rax
movl $0x186a, (%rax,%rbx,4)  # imm = 0x186A
movl $0x1c6a, %edi           # imm = 0x1C6A
callq 0x1030
movq %rbx, 0x30(%rsp)
shlq $0x4, %rbx
movq 0x68(%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
cmpq $0x186a, %rax           # imm = 0x186A
je 0x5674
movq (%r15), %rcx
movb %r12b, (%rcx,%rax)
movq 0x8(%r15), %rcx
movb %r12b, (%rcx,%rax)
incq %rax
jmp 0x5658
movzbl 0x145008(%r13), %eax
incq %rax
imulq 0x28(%rsp), %rax
addq 0x30(%rsp), %rax
movq 0x8(%rsp), %rdi
movl 0x24(%rdi,%rax,4), %edx
leal 0x2(%rdx), %ecx
cmpl %r14d, %ecx
ja 0x5ae2
movzbl 0x1(%rdi,%rdx), %eax
leal (%rcx,%rax,8), %ecx
cmpq %rcx, %r14
jb 0x5b5e
leaq (%rdi,%rdx), %r9
leal -0x1(%rax), %ecx
cmpl %r14d, 0x6(%r9,%rcx,8)
ja 0x5bda
addq $0x2, %r9
movl %eax, %r10d
addq 0x60(%rsp), %rdx
xorl %edi, %edi
xorl %esi, %esi
cmpq %rdi, %r10
je 0x56ee
movb (%rdx,%rdi,8), %cl
movl $0x80, %r8d
shll %cl, %r8d
addl %r8d, %esi
addl $0xc, %esi
incq %rdi
jmp 0x56d2
leal (%rax,%rax,4), %ecx
addl %ecx, %esi
cmpl $0x186a, %esi           # imm = 0x186A
ja 0x5c5b
cmpl $0x1866, %esi           # imm = 0x1866
jne 0x59ee
leal (%rax,%rax), %edx
xorl %ecx, %ecx
pushq $0x1
popq %rsi
movl %esi, 0x4(%rsp)
movl %esi, (%rsp)
movl %esi, %r11d
movl %esi, %r13d
leal 0xa(%rdx), %esi
xorl %r8d, %r8d
xorl %r14d, %r14d
cmpl %esi, %ecx
cmovbel %r8d, %eax
seta %r14b
subl %eax, %ecx
addl $0x9, %edx
cmpl %ecx, %edx
adcl $0x1, %r14d
xorl %eax, %eax
movq %r9, 0x38(%rsp)
movq %r10, 0x78(%rsp)
movl %r11d, 0x24(%rsp)
movl %r13d, 0x20(%rsp)
cmpq %r10, %r8
je 0x59b4
leal 0x7(%rax), %ebx
leal 0xa(%rax), %ebp
movl 0x4(%rsp), %ecx
subl $0x1, %ecx
jb 0x5785
movq (%r15), %rdx
movl %eax, %esi
movb $0x4e, (%rdx,%rsi)
movq 0x8(%r15), %rdx
incl %eax
movb $0x0, (%rdx,%rsi)
incl %ebx
incl %ebp
jmp 0x5767
xorl %edx, %edx
leal (%rax,%rdx), %ecx
cmpl %edx, %r13d
je 0x57a8
movq (%r15), %rsi
movl %ecx, %ecx
movb %r12b, (%rsi,%rcx)
movq 0x8(%r15), %rsi
movb %r12b, (%rsi,%rcx)
incl %edx
incl %ebx
incl %ebp
jmp 0x5787
pushq $-0x5
popq %rdx
leal (%r14,%rdx), %edi
leal -0x7(%rbx), %eax
movq (%r15), %rsi
cmpl $-0x5, %edi
je 0x57cf
movb $-0x5f, (%rsi,%rax)
movq 0x8(%r15), %rsi
movb $-0x1, (%rsi,%rax)
decq %rdx
incl %ebx
incl %ebp
jmp 0x57ab
movb $-0x2, (%rsi,%rax)
movq 0x8(%r15), %rsi
xorl %r13d, %r13d
movb %r13b, (%rsi,%rax)
movb (%r9,%r8,8), %al
movq (%r15), %rsi
leal -0x6(%rbx), %edi
movb %al, (%rsi,%rdi)
movq 0x8(%r15), %rax
leal -0x5(%rbx), %esi
movb %r13b, (%rax,%rdi)
movb 0x1(%r9,%r8,8), %al
movq (%r15), %rdi
movb %al, (%rdi,%rsi)
movq 0x8(%r15), %rax
leal -0x4(%rbx), %edi
movb %r13b, (%rax,%rsi)
movb 0x2(%r9,%r8,8), %al
movq (%r15), %rsi
movb %al, (%rsi,%rdi)
movq 0x8(%r15), %rax
leal -0x3(%rbx), %esi
movb %r13b, (%rax,%rdi)
movq %r8, 0x40(%rsp)
movb 0x3(%r9,%r8,8), %al
movq (%r15), %rdi
movb %al, (%rdi,%rsi)
movq 0x8(%r15), %rax
leal -0x2(%rbx), %edi
movq %rdi, 0x10(%rsp)
movb %r13b, (%rax,%rsi)
movq (%r15), %rax
movq %rax, 0x80(%rsp)
movl %ecx, %esi
addq %rax, %rsi
negq %rdx
callq 0x1a98
movq 0x10(%rsp), %rsi
movq 0x80(%rsp), %rcx
movb %ah, (%rcx,%rsi)
movq 0x8(%r15), %rcx
leal -0x1(%rbx), %edx
movb %r13b, (%rcx,%rsi)
movq (%r15), %rcx
movb %al, (%rcx,%rdx)
movq 0x8(%r15), %rax
movb %r13b, (%rax,%rdx)
movl (%rsp), %edx
leal (%rbx,%r13), %eax
cmpl %r13d, %edx
je 0x58a7
movq (%r15), %rcx
movl %eax, %eax
movb $0x4e, (%rcx,%rax)
movq 0x8(%r15), %rcx
movb $0x0, (%rcx,%rax)
incl %r13d
incl %ebp
jmp 0x5886
movl 0x20(%rsp), %r13d
movl %r13d, %ecx
movq 0x8(%rsp), %r10
movq 0x38(%rsp), %r9
movl %eax, %esi
subl $0x1, %ecx
jb 0x58d5
movq (%r15), %rdx
movb %r12b, (%rdx,%rsi)
movq 0x8(%r15), %rdx
incl %eax
movb %r12b, (%rdx,%rsi)
incl %ebp
jmp 0x58b9
xorl %ecx, %ecx
pushq $0x1
popq %rdx
leal (%rax,%rcx), %edi
movq (%r15), %r8
cmpl %ecx, %r14d
je 0x58fc
movb $-0x5f, (%r8,%rdi)
movq 0x8(%r15), %r8
movb $-0x1, (%r8,%rdi)
incl %ecx
incl %ebp
incq %rdx
jmp 0x58da
movb $-0x5, (%r8,%rdi)
movq 0x8(%r15), %rax
movb $0x0, (%rax,%rdi)
movq 0x40(%rsp), %rdi
movb 0x3(%r9,%rdi,8), %cl
movl $0x80, %eax
shll %cl, %eax
movl 0x4(%r9,%rdi,8), %ecx
leal -0x2(%rbp), %ebx
subq $0x1, %rax
jb 0x594a
movl %ecx, %edi
movb (%r10,%rdi), %dil
movq (%r15), %r8
movl %ebx, %r9d
movb %dil, (%r8,%r9)
movq 0x8(%r15), %rdi
movb $0x0, (%rdi,%r9)
incl %ecx
incl %ebp
incq %rdx
jmp 0x591f
movq (%r15), %rax
movq %rax, 0x10(%rsp)
addq %rax, %rsi
callq 0x1a98
movq 0x10(%rsp), %rcx
movb %ah, (%rcx,%rbx)
movq 0x8(%r15), %rdx
leal -0x1(%rbp), %esi
xorl %ecx, %ecx
movb %cl, (%rdx,%rbx)
movq (%r15), %rdx
movb %al, (%rdx,%rsi)
movq 0x8(%r15), %rax
movb %cl, (%rax,%rsi)
movq 0x78(%rsp), %r10
movl 0x24(%rsp), %r11d
movq 0x40(%rsp), %r8
leal (%rcx,%rbp), %eax
cmpl %ecx, %r11d
je 0x59a7
movq (%r15), %rdx
movl %eax, %eax
movb $0x4e, (%rdx,%rax)
movq 0x8(%r15), %rdx
movb $0x0, (%rdx,%rax)
incl %ecx
jmp 0x598a
incq %r8
movq 0x38(%rsp), %r9
jmp 0x5754
movq 0x58(%rsp), %r13
movq 0x50(%rsp), %r14
cmpl $0x186a, %eax           # imm = 0x186A
jge 0x59da
movq (%r15), %rcx
movl %eax, %edx
movb $0x4e, (%rcx,%rdx)
movq 0x8(%r15), %rcx
incl %eax
movb $0x0, (%rcx,%rdx)
jmp 0x59be
movq 0x30(%rsp), %rbx
incq %rbx
movb 0x145008(%r13), %al
jmp 0x560f
movl $0x1866, %ecx           # imm = 0x1866
subl %esi, %ecx
leal (%rax,%rax), %edx
pushq $0x1
popq %rsi
movl %esi, 0x4(%rsp)
movl %esi, (%rsp)
movl %esi, %r11d
movl %esi, %r13d
movl %r13d, %esi
cmpl %edx, %ecx
setae %dil
cmpl $0xc, %r13d
setb %r8b
andb %dil, %r8b
movl $0x0, %edi
cmovnel %edx, %edi
subl %edi, %ecx
movzbl %r8b, %r13d
addl %esi, %r13d
cmpl %eax, %ecx
jb 0x5720
movl 0x4(%rsp), %edi
cmpl $0xa, %edi
movl $0x0, %esi
cmovbl %eax, %esi
adcl $0x0, %edi
movl %edi, 0x4(%rsp)
subl %esi, %ecx
cmpl %eax, %ecx
jb 0x5720
movl (%rsp), %edi
cmpl $0x16, %edi
movl $0x0, %esi
cmovbl %eax, %esi
adcl $0x0, %edi
movl %edi, (%rsp)
subl %esi, %ecx
cmpl %eax, %ecx
jb 0x5720
cmpl $0x3c, %r11d
movl $0x0, %esi
cmovbl %eax, %esi
adcl $0x0, %r11d
subl %esi, %ecx
cmpl %eax, %ecx
jb 0x5720
cmpl $0xc, %r13d
setb %sil
cmpl $0xa, 0x4(%rsp)
setb %dil
cmpl $0x16, (%rsp)
setb %r8b
orb %dil, %r8b
cmpl $0x3c, %r11d
setb %dil
orb %r8b, %dil
orb %sil, %dil
cmpb $0x1, %dil
jne 0x5720
testl %ecx, %ecx
jne 0x5a08
jmp 0x5720
movq 0x28(%rsp), %rdx
incq %rdx
movb 0x145007(%r13), %cl
jmp 0x55df
pushq $0x1
popq %r15
movq %r15, %rsi
callq 0x1140
leaq 0x40008(%r13), %rbx
xorl %r14d, %r14d
cmpq $0x100, %r14            # imm = 0x100
je 0x555d
xorl %r12d, %r12d
cmpq $0x400, %r12            # imm = 0x400
je 0x5b4b
andl $0x0, (%r13,%r12)
movq -0x8(%rbx,%r12,4), %rdi
testq %rdi, %rdi
je 0x5b29
movq %r15, %rsi
callq 0x1140
andq $0x0, -0x8(%rbx,%r12,4)
movq (%rbx,%r12,4), %rdi
testq %rdi, %rdi
je 0x5b40
movq %r15, %rsi
callq 0x1140
andq $0x0, (%rbx,%r12,4)
addq $0x4, %r12
jmp 0x5b08
incq %r14
addq $0x400, %r13            # imm = 0x400
addq $0x1000, %rbx           # imm = 0x1000
jmp 0x5af8
pushq $0x1
popq %r15
movq %r15, %rsi
callq 0x1140
leaq 0x40008(%r13), %rbx
xorl %r14d, %r14d
cmpq $0x100, %r14            # imm = 0x100
je 0x555d
xorl %r12d, %r12d
cmpq $0x400, %r12            # imm = 0x400
je 0x5bc7
andl $0x0, (%r13,%r12)
movq -0x8(%rbx,%r12,4), %rdi
testq %rdi, %rdi
je 0x5ba5
movq %r15, %rsi
callq 0x1140
andq $0x0, -0x8(%rbx,%r12,4)
movq (%rbx,%r12,4), %rdi
testq %rdi, %rdi
je 0x5bbc
movq %r15, %rsi
callq 0x1140
andq $0x0, (%rbx,%r12,4)
addq $0x4, %r12
jmp 0x5b84
incq %r14
addq $0x400, %r13            # imm = 0x400
addq $0x1000, %rbx           # imm = 0x1000
jmp 0x5b74
pushq $0x1
popq %r15
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x1140
leaq 0x40008(%r13), %rbx
xorl %r14d, %r14d
cmpq $0x100, %r14            # imm = 0x100
je 0x555d
xorl %r12d, %r12d
cmpq $0x400, %r12            # imm = 0x400
je 0x5c48
andl $0x0, (%r13,%r12)
movq -0x8(%rbx,%r12,4), %rdi
testq %rdi, %rdi
je 0x5c26
movq %r15, %rsi
callq 0x1140
andq $0x0, -0x8(%rbx,%r12,4)
movq (%rbx,%r12,4), %rdi
testq %rdi, %rdi
je 0x5c3d
movq %r15, %rsi
callq 0x1140
andq $0x0, (%rbx,%r12,4)
addq $0x4, %r12
jmp 0x5c05
incq %r14
addq $0x400, %r13            # imm = 0x400
addq $0x1000, %rbx           # imm = 0x1000
jmp 0x5bf5
pushq $0x1
popq %r15
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x1140
leaq 0x40008(%r13), %rbx
xorl %r14d, %r14d
cmpq $0x100, %r14            # imm = 0x100
je 0x5cd8
xorl %r12d, %r12d
cmpq $0x400, %r12            # imm = 0x400
je 0x5cc5
andl $0x0, (%r13,%r12)
movq -0x8(%rbx,%r12,4), %rdi
testq %rdi, %rdi
je 0x5ca3
movq %r15, %rsi
callq 0x1140
andq $0x0, -0x8(%rbx,%r12,4)
movq (%rbx,%r12,4), %rdi
testq %rdi, %rdi
je 0x5cba
movq %r15, %rsi
callq 0x1140
andq $0x0, (%rbx,%r12,4)
addq $0x4, %r12
jmp 0x5c82
incq %r14
addq $0x400, %r13            # imm = 0x400
addq $0x1000, %rbx           # imm = 0x1000
jmp 0x5c76
leaq 0x17f6(%rip), %rsi      # 0x74d5
jmp 0x558b
pushq $0x1
popq %rsi
movq 0x8(%rsp), %rdi
callq 0x1140
movl 0x1c(%rsp), %eax
movb %al, 0x145005(%r13)
movl $0x7, 0x141000(%r13)
movb $0x1, 0x145006(%r13)
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop