// File: atsidaev[P]trx2x/DiskImage.cpp
// Function: TDiskImage::readTRD(int, bool)
void TDiskImage::readTRD(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)
   {
      delete ptr;
      ShowError(ERR_CORRUPT);
      return;
   }

   if(rsize % (256*16*2))
   {
      delete ptr;
      ShowError(ERR_UNKFORMAT);
      return;
   }
   MaxSide = 1;
   MaxTrack = (rsize / (256*16*2)) - 1;


// форматирование нового диска под TR-DOS...

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

         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


         unsigned int r;
         unsigned int tptr=0;
         unsigned int ptrcrc;

         for(int sec=0; sec < 16; sec++)
         {
            for(r=0; r < 10; r++)        // Первый пробел
            {
               FTracksPtr[trk][side][0][tptr] = 0x4E;
               FTracksPtr[trk][side][1][tptr++] = 0x00;
            }
            for(r=0; r < 12; r++)        // Синхропромежуток
            {
               FTracksPtr[trk][side][0][tptr] = 0x00;
               FTracksPtr[trk][side][1][tptr++] = 0x00;
            }
            ptrcrc = tptr;
            for(r=0; r < 3; 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] = (unsigned char)trk; // cyl
            FTracksPtr[trk][side][1][tptr++] = 0x00;
            FTracksPtr[trk][side][0][tptr] = (unsigned char)0x00; // head (TR always 0)
            FTracksPtr[trk][side][1][tptr++] = 0x00;
            FTracksPtr[trk][side][0][tptr] = (unsigned char)(sec+1); // secN
            FTracksPtr[trk][side][1][tptr++] = 0x00;
            FTracksPtr[trk][side][0][tptr] = (unsigned char)0x01; // len=256b
            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 < 22; r++)        // Второй пробел
            {
               FTracksPtr[trk][side][0][tptr] = 0x4E;
               FTracksPtr[trk][side][1][tptr++] = 0x00;
            }
            for(r=0; r < 12; r++)        // Синхропромежуток
            {
               FTracksPtr[trk][side][0][tptr] = 0x00;
               FTracksPtr[trk][side][1][tptr++] = 0x00;
            }
            ptrcrc = tptr;
            for(r=0; r < 3; 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;

            for(r=0; r < 256; r++)        // сектор 256байт
            {
               FTracksPtr[trk][side][0][tptr] = ptr[(trk*2+side)*4096+sec*256+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 < 60; 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_TRD;
   DiskPresent = true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movb %dl, %al
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
andb $0x1, %al
movb %al, -0xd(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x50(%rbp)
movl -0xc(%rbp), %edi
callq 0xd6a0
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jge 0x4ee6
movq -0x50(%rbp), %rdi
leaq 0x9462(%rip), %rsi      # 0xe33e
callq 0x2c30
jmp 0x59a5
movq -0x18(%rbp), %rdi
addq $0x200000, %rdi         # imm = 0x200000
callq 0x1030
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x4f16
movq -0x50(%rbp), %rdi
leaq 0x9450(%rip), %rsi      # 0xe35c
callq 0x2c30
jmp 0x59a5
movl -0xc(%rbp), %edi
movq -0x20(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x11a0
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x4f62
movq -0x20(%rbp), %rax
movq %rax, -0x58(%rbp)
cmpq $0x0, %rax
je 0x4f4d
movq -0x58(%rbp), %rdi
movl $0x1, %esi
callq 0x1130
movq -0x50(%rbp), %rdi
leaq 0x9416(%rip), %rsi      # 0xe36e
callq 0x2c30
jmp 0x59a5
movq -0x28(%rbp), %rax
andq $0x1fff, %rax           # imm = 0x1FFF
cmpq $0x0, %rax
je 0x4fa3
movq -0x20(%rbp), %rax
movq %rax, -0x60(%rbp)
cmpq $0x0, %rax
je 0x4f8e
movq -0x60(%rbp), %rdi
movl $0x1, %esi
callq 0x1130
movq -0x50(%rbp), %rdi
leaq 0x9344(%rip), %rsi      # 0xe2dd
callq 0x2c30
jmp 0x59a5
movq -0x50(%rbp), %rax
movb $0x1, 0x145008(%rax)
movq -0x28(%rbp), %rcx
shrq $0xd, %rcx
subq $0x1, %rcx
movb %cl, 0x145007(%rax)
movl $0x0, -0x30(%rbp)
movq -0x50(%rbp), %rcx
movl -0x30(%rbp), %eax
movzbl 0x145007(%rcx), %ecx
cmpl %ecx, %eax
ja 0x5968
movl $0x0, -0x34(%rbp)
movq -0x50(%rbp), %rcx
movl -0x34(%rbp), %eax
movzbl 0x145008(%rcx), %ecx
cmpl %ecx, %eax
ja 0x5958
movq -0x50(%rbp), %rax
movl -0x30(%rbp), %ecx
movl %ecx, %edx
shlq $0xa, %rdx
movq %rax, %rcx
addq %rdx, %rcx
movl -0x34(%rbp), %edx
movl $0x186a, (%rcx,%rdx,4)  # imm = 0x186A
movl -0x30(%rbp), %ecx
shlq $0xa, %rcx
addq %rcx, %rax
movl -0x34(%rbp), %ecx
movl (%rax,%rcx,4), %eax
addl $0x400, %eax            # imm = 0x400
movl %eax, %eax
movl %eax, %edi
callq 0x1030
movq %rax, %rdx
movq -0x50(%rbp), %rax
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x30(%rbp), %esi
shlq $0xc, %rsi
addq %rsi, %rcx
movl -0x34(%rbp), %esi
shlq $0x4, %rsi
addq %rsi, %rcx
movq %rdx, (%rcx)
movl -0x30(%rbp), %ecx
shlq $0xa, %rcx
addq %rcx, %rax
movl -0x34(%rbp), %ecx
movl (%rax,%rcx,4), %eax
addl $0x400, %eax            # imm = 0x400
movl %eax, %eax
movl %eax, %edi
callq 0x1030
movq %rax, %rcx
movq -0x50(%rbp), %rax
addq $0x40000, %rax          # imm = 0x40000
movl -0x30(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rax
movl -0x34(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
movl $0x0, -0x3c(%rbp)
movl $0x0, -0x44(%rbp)
cmpl $0x10, -0x44(%rbp)
jge 0x58d3
movl $0x0, -0x38(%rbp)
cmpl $0xa, -0x38(%rbp)
jae 0x512b
movq -0x50(%rbp), %rax
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x30(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x34(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movl -0x3c(%rbp), %edx
movb $0x4e, (%rcx,%rdx)
addq $0x40000, %rax          # imm = 0x40000
movl -0x30(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x34(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x3c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x3c(%rbp)
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x50bf
movl $0x0, -0x38(%rbp)
cmpl $0xc, -0x38(%rbp)
jae 0x519e
movq -0x50(%rbp), %rax
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x30(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x34(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movl -0x3c(%rbp), %edx
movb $0x0, (%rcx,%rdx)
addq $0x40000, %rax          # imm = 0x40000
movl -0x30(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x34(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x3c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x3c(%rbp)
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x5132
movl -0x3c(%rbp), %eax
movl %eax, -0x40(%rbp)
movl $0x0, -0x38(%rbp)
cmpl $0x3, -0x38(%rbp)
jae 0x5217
movq -0x50(%rbp), %rax
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x30(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x34(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movl -0x3c(%rbp), %edx
movb $-0x5f, (%rcx,%rdx)
addq $0x40000, %rax          # imm = 0x40000
movl -0x30(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x34(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x3c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x3c(%rbp)
movl %ecx, %ecx
movb $-0x1, (%rax,%rcx)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x51ab
movq -0x50(%rbp), %rdi
movq %rdi, %rax
addq $0x40000, %rax          # imm = 0x40000
movl -0x30(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x34(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl -0x3c(%rbp), %ecx
movb $-0x2, (%rax,%rcx)
movq %rdi, %rax
addq $0x40000, %rax          # imm = 0x40000
movl -0x30(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x34(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x3c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x3c(%rbp)
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movl -0x30(%rbp), %eax
movb %al, %dl
movq %rdi, %rax
addq $0x40000, %rax          # imm = 0x40000
movl -0x30(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x34(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl -0x3c(%rbp), %ecx
movb %dl, (%rax,%rcx)
movq %rdi, %rax
addq $0x40000, %rax          # imm = 0x40000
movl -0x30(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x34(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x3c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x3c(%rbp)
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movq %rdi, %rax
addq $0x40000, %rax          # imm = 0x40000
movl -0x30(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x34(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl -0x3c(%rbp), %ecx
movb $0x0, (%rax,%rcx)
movq %rdi, %rax
addq $0x40000, %rax          # imm = 0x40000
movl -0x30(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x34(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x3c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x3c(%rbp)
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movb %al, %dl
movq %rdi, %rax
addq $0x40000, %rax          # imm = 0x40000
movl -0x30(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x34(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl -0x3c(%rbp), %ecx
movb %dl, (%rax,%rcx)
movq %rdi, %rax
addq $0x40000, %rax          # imm = 0x40000
movl -0x30(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x34(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x3c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x3c(%rbp)
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movq %rdi, %rax
addq $0x40000, %rax          # imm = 0x40000
movl -0x30(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x34(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl -0x3c(%rbp), %ecx
movb $0x1, (%rax,%rcx)
movq %rdi, %rax
addq $0x40000, %rax          # imm = 0x40000
movl -0x30(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x34(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x3c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x3c(%rbp)
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movq %rdi, %rax
addq $0x40000, %rax          # imm = 0x40000
movl -0x30(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x34(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rsi
movl -0x40(%rbp), %eax
addq %rax, %rsi
movl -0x3c(%rbp), %eax
subl -0x40(%rbp), %eax
movl %eax, %eax
movl %eax, %edx
callq 0x1fa0
movw %ax, %cx
movq -0x50(%rbp), %rax
movw %cx, -0x2a(%rbp)
movzwl -0x2a(%rbp), %ecx
sarl $0x8, %ecx
movb %cl, %sil
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x30(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x34(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movl -0x3c(%rbp), %edx
movb %sil, (%rcx,%rdx)
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x30(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x34(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq 0x8(%rcx), %rcx
movl -0x3c(%rbp), %edx
movl %edx, %esi
addl $0x1, %esi
movl %esi, -0x3c(%rbp)
movl %edx, %edx
movb $0x0, (%rcx,%rdx)
movzwl -0x2a(%rbp), %ecx
andl $0xff, %ecx
movb %cl, %sil
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x30(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x34(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movl -0x3c(%rbp), %edx
movb %sil, (%rcx,%rdx)
addq $0x40000, %rax          # imm = 0x40000
movl -0x30(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x34(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x3c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x3c(%rbp)
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movl $0x0, -0x38(%rbp)
cmpl $0x16, -0x38(%rbp)
jae 0x555f
movq -0x50(%rbp), %rax
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x30(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x34(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movl -0x3c(%rbp), %edx
movb $0x4e, (%rcx,%rdx)
addq $0x40000, %rax          # imm = 0x40000
movl -0x30(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x34(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x3c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x3c(%rbp)
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x54f3
movl $0x0, -0x38(%rbp)
cmpl $0xc, -0x38(%rbp)
jae 0x55d2
movq -0x50(%rbp), %rax
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x30(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x34(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movl -0x3c(%rbp), %edx
movb $0x0, (%rcx,%rdx)
addq $0x40000, %rax          # imm = 0x40000
movl -0x30(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x34(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x3c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x3c(%rbp)
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x5566
movl -0x3c(%rbp), %eax
movl %eax, -0x40(%rbp)
movl $0x0, -0x38(%rbp)
cmpl $0x3, -0x38(%rbp)
jae 0x564b
movq -0x50(%rbp), %rax
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x30(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x34(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movl -0x3c(%rbp), %edx
movb $-0x5f, (%rcx,%rdx)
addq $0x40000, %rax          # imm = 0x40000
movl -0x30(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x34(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x3c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x3c(%rbp)
movl %ecx, %ecx
movb $-0x1, (%rax,%rcx)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x55df
movq -0x50(%rbp), %rax
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x30(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x34(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movl -0x3c(%rbp), %edx
movb $-0x5, (%rcx,%rdx)
addq $0x40000, %rax          # imm = 0x40000
movl -0x30(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x34(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x3c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x3c(%rbp)
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movl $0x0, -0x38(%rbp)
cmpl $0x100, -0x38(%rbp)     # imm = 0x100
jae 0x5743
movq -0x50(%rbp), %rax
movq -0x20(%rbp), %rcx
movl -0x30(%rbp), %edx
shll %edx
addl -0x34(%rbp), %edx
shll $0xc, %edx
movl -0x44(%rbp), %esi
shll $0x8, %esi
addl %esi, %edx
addl -0x38(%rbp), %edx
movl %edx, %edx
movb (%rcx,%rdx), %sil
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x30(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x34(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movl -0x3c(%rbp), %edx
movb %sil, (%rcx,%rdx)
addq $0x40000, %rax          # imm = 0x40000
movl -0x30(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x34(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x3c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x3c(%rbp)
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x56ad
movq -0x50(%rbp), %rdi
movq %rdi, %rax
addq $0x40000, %rax          # imm = 0x40000
movl -0x30(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x34(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rsi
movl -0x40(%rbp), %eax
addq %rax, %rsi
movl -0x3c(%rbp), %eax
subl -0x40(%rbp), %eax
movl %eax, %eax
movl %eax, %edx
callq 0x1fa0
movw %ax, %cx
movq -0x50(%rbp), %rax
movw %cx, -0x2a(%rbp)
movzwl -0x2a(%rbp), %ecx
sarl $0x8, %ecx
movb %cl, %sil
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x30(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x34(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movl -0x3c(%rbp), %edx
movb %sil, (%rcx,%rdx)
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x30(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x34(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq 0x8(%rcx), %rcx
movl -0x3c(%rbp), %edx
movl %edx, %esi
addl $0x1, %esi
movl %esi, -0x3c(%rbp)
movl %edx, %edx
movb $0x0, (%rcx,%rdx)
movzwl -0x2a(%rbp), %ecx
andl $0xff, %ecx
movb %cl, %sil
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x30(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x34(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movl -0x3c(%rbp), %edx
movb %sil, (%rcx,%rdx)
addq $0x40000, %rax          # imm = 0x40000
movl -0x30(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x34(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x3c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x3c(%rbp)
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movl $0x0, -0x38(%rbp)
cmpl $0x3c, -0x38(%rbp)
jae 0x58c3
movq -0x50(%rbp), %rax
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x30(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x34(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movl -0x3c(%rbp), %edx
movb $0x4e, (%rcx,%rdx)
addq $0x40000, %rax          # imm = 0x40000
movl -0x30(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x34(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x3c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x3c(%rbp)
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x5857
jmp 0x58c5
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x50ae
movl -0x3c(%rbp), %eax
movl %eax, -0x48(%rbp)
cmpl $0x186a, -0x48(%rbp)    # imm = 0x186A
jge 0x5948
movq -0x50(%rbp), %rax
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x30(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x34(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movl -0x3c(%rbp), %edx
movb $0x4e, (%rcx,%rdx)
addq $0x40000, %rax          # imm = 0x40000
movl -0x30(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x34(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x3c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x3c(%rbp)
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x58d9
jmp 0x594a
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x4fe4
jmp 0x595a
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x4fc7
movq -0x20(%rbp), %rax
movq %rax, -0x68(%rbp)
cmpq $0x0, %rax
je 0x5984
movq -0x68(%rbp), %rdi
movl $0x1, %esi
callq 0x1130
movq -0x50(%rbp), %rax
movb -0xd(%rbp), %cl
andb $0x1, %cl
movb %cl, 0x145005(%rax)
movl $0x1, 0x141000(%rax)
movb $0x1, 0x145006(%rax)
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax,%rax)