// File: atsidaev[P]trx2x/DiskImage.cpp
// Function: TDiskImage::formatTRDOS(unsigned int, unsigned int)
void TDiskImage::formatTRDOS(unsigned int Tcount, unsigned int Scount)
{
   MaxTrack = Tcount-1;
   MaxSide = Scount-1;

   unsigned short TotalSecs = Tcount*Scount * 16 - 16;

// форматирование нового диска под TR-DOS (16 x 256bytes sector per track)...
   unsigned int ptrcrc;
   unsigned int r;
   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 tptr=0;
         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] = 0x00;
               FTracksPtr[trk][side][1][tptr++] = 0x00;
            }
            if( (trk==0)&&(side==0)&&(sec==8) )      // make TR-DOS id
            {
               int ssec = tptr-256;
               FTracksPtr[trk][side][0][ssec+0xE1] = 0x00; // first free SECT
               FTracksPtr[trk][side][0][ssec+0xE2] = 0x01; // first free TRACK
               FTracksPtr[trk][side][0][ssec+0xE3] = 0x16; // 80trk DS
               FTracksPtr[trk][side][0][ssec+0xE4] = 0x00; // file count
               *(unsigned short*)(FTracksPtr[trk][side][0]+ssec+0xE5) 
                                                   = TotalSecs; // free SECS count
               FTracksPtr[trk][side][0][ssec+0xE7] = 0x10; // TR-DOS id
               FTracksPtr[trk][side][0][ssec+0xF4] = 0x00; // deleted file count

               memcpy(FTracksPtr[trk][side][0]+ssec+0xF5, 
                  STR_CREATEDISKNAME"               ",8); // disk name
               FTracksPtr[trk][side][0][ssec+0xFD] = 0x00; // zero
               FTracksPtr[trk][side][0][ssec+0xFE] = 0x00; // zero
               FTracksPtr[trk][side][0][ssec+0xFF] = 0x00; // zero
            }

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x40(%rbp)
movl -0xc(%rbp), %ecx
subl $0x1, %ecx
movb %cl, 0x145007(%rax)
movl -0x10(%rbp), %ecx
subl $0x1, %ecx
movb %cl, 0x145008(%rax)
movl -0xc(%rbp), %eax
imull -0x10(%rbp), %eax
shll $0x4, %eax
subl $0x10, %eax
movw %ax, -0x12(%rbp)
movl $0x0, -0x24(%rbp)
movq -0x40(%rbp), %rcx
movl -0x24(%rbp), %eax
movzbl 0x145007(%rcx), %ecx
cmpl %ecx, %eax
ja 0xc6ec
movl $0x0, -0x28(%rbp)
movq -0x40(%rbp), %rcx
movl -0x28(%rbp), %eax
movzbl 0x145008(%rcx), %ecx
cmpl %ecx, %eax
ja 0xc6dc
movq -0x40(%rbp), %rax
movl -0x24(%rbp), %ecx
movl %ecx, %edx
shlq $0xa, %rdx
movq %rax, %rcx
addq %rdx, %rcx
movl -0x28(%rbp), %edx
movl $0x186a, (%rcx,%rdx,4)  # imm = 0x186A
movl -0x24(%rbp), %ecx
shlq $0xa, %rcx
addq %rcx, %rax
movl -0x28(%rbp), %ecx
movl (%rax,%rcx,4), %eax
addl $0x400, %eax            # imm = 0x400
movl %eax, %eax
movl %eax, %edi
callq 0x1030
movq %rax, %rdx
movq -0x40(%rbp), %rax
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x24(%rbp), %esi
shlq $0xc, %rsi
addq %rsi, %rcx
movl -0x28(%rbp), %esi
shlq $0x4, %rsi
addq %rsi, %rcx
movq %rdx, (%rcx)
movl -0x24(%rbp), %ecx
shlq $0xa, %rcx
addq %rcx, %rax
movl -0x28(%rbp), %ecx
movl (%rax,%rcx,4), %eax
addl $0x400, %eax            # imm = 0x400
movl %eax, %eax
movl %eax, %edi
callq 0x1030
movq %rax, %rcx
movq -0x40(%rbp), %rax
addq $0x40000, %rax          # imm = 0x40000
movl -0x24(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rax
movl -0x28(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
cmpl $0x10, -0x30(%rbp)
jge 0xc657
movl $0x0, -0x1c(%rbp)
cmpl $0xa, -0x1c(%rbp)
jae 0xbc8e
movq -0x40(%rbp), %rax
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x24(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x28(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movl -0x2c(%rbp), %edx
movb $0x4e, (%rcx,%rdx)
addq $0x40000, %rax          # imm = 0x40000
movl -0x24(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x28(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x2c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x2c(%rbp)
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xbc22
movl $0x0, -0x1c(%rbp)
cmpl $0xc, -0x1c(%rbp)
jae 0xbd01
movq -0x40(%rbp), %rax
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x24(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x28(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movl -0x2c(%rbp), %edx
movb $0x0, (%rcx,%rdx)
addq $0x40000, %rax          # imm = 0x40000
movl -0x24(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x28(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x2c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x2c(%rbp)
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xbc95
movl -0x2c(%rbp), %eax
movl %eax, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
cmpl $0x3, -0x1c(%rbp)
jae 0xbd7a
movq -0x40(%rbp), %rax
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x24(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x28(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movl -0x2c(%rbp), %edx
movb $-0x5f, (%rcx,%rdx)
addq $0x40000, %rax          # imm = 0x40000
movl -0x24(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x28(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x2c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x2c(%rbp)
movl %ecx, %ecx
movb $-0x1, (%rax,%rcx)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xbd0e
movq -0x40(%rbp), %rdi
movq %rdi, %rax
addq $0x40000, %rax          # imm = 0x40000
movl -0x24(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x28(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl -0x2c(%rbp), %ecx
movb $-0x2, (%rax,%rcx)
movq %rdi, %rax
addq $0x40000, %rax          # imm = 0x40000
movl -0x24(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x28(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x2c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x2c(%rbp)
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movl -0x24(%rbp), %eax
movb %al, %dl
movq %rdi, %rax
addq $0x40000, %rax          # imm = 0x40000
movl -0x24(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x28(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl -0x2c(%rbp), %ecx
movb %dl, (%rax,%rcx)
movq %rdi, %rax
addq $0x40000, %rax          # imm = 0x40000
movl -0x24(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x28(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x2c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x2c(%rbp)
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movq %rdi, %rax
addq $0x40000, %rax          # imm = 0x40000
movl -0x24(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x28(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl -0x2c(%rbp), %ecx
movb $0x0, (%rax,%rcx)
movq %rdi, %rax
addq $0x40000, %rax          # imm = 0x40000
movl -0x24(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x28(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x2c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x2c(%rbp)
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movb %al, %dl
movq %rdi, %rax
addq $0x40000, %rax          # imm = 0x40000
movl -0x24(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x28(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl -0x2c(%rbp), %ecx
movb %dl, (%rax,%rcx)
movq %rdi, %rax
addq $0x40000, %rax          # imm = 0x40000
movl -0x24(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x28(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x2c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x2c(%rbp)
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movq %rdi, %rax
addq $0x40000, %rax          # imm = 0x40000
movl -0x24(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x28(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl -0x2c(%rbp), %ecx
movb $0x1, (%rax,%rcx)
movq %rdi, %rax
addq $0x40000, %rax          # imm = 0x40000
movl -0x24(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x28(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x2c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x2c(%rbp)
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movq %rdi, %rax
addq $0x40000, %rax          # imm = 0x40000
movl -0x24(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x28(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rsi
movl -0x18(%rbp), %eax
addq %rax, %rsi
movl -0x2c(%rbp), %eax
subl -0x18(%rbp), %eax
movl %eax, %eax
movl %eax, %edx
callq 0x1fa0
movw %ax, %cx
movq -0x40(%rbp), %rax
movw %cx, -0x1e(%rbp)
movzwl -0x1e(%rbp), %ecx
sarl $0x8, %ecx
movb %cl, %sil
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x24(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x28(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movl -0x2c(%rbp), %edx
movb %sil, (%rcx,%rdx)
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x24(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x28(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq 0x8(%rcx), %rcx
movl -0x2c(%rbp), %edx
movl %edx, %esi
addl $0x1, %esi
movl %esi, -0x2c(%rbp)
movl %edx, %edx
movb $0x0, (%rcx,%rdx)
movzwl -0x1e(%rbp), %ecx
andl $0xff, %ecx
movb %cl, %sil
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x24(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x28(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movl -0x2c(%rbp), %edx
movb %sil, (%rcx,%rdx)
addq $0x40000, %rax          # imm = 0x40000
movl -0x24(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x28(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x2c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x2c(%rbp)
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movl $0x0, -0x1c(%rbp)
cmpl $0x16, -0x1c(%rbp)
jae 0xc0c2
movq -0x40(%rbp), %rax
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x24(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x28(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movl -0x2c(%rbp), %edx
movb $0x4e, (%rcx,%rdx)
addq $0x40000, %rax          # imm = 0x40000
movl -0x24(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x28(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x2c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x2c(%rbp)
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xc056
movl $0x0, -0x1c(%rbp)
cmpl $0xc, -0x1c(%rbp)
jae 0xc135
movq -0x40(%rbp), %rax
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x24(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x28(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movl -0x2c(%rbp), %edx
movb $0x0, (%rcx,%rdx)
addq $0x40000, %rax          # imm = 0x40000
movl -0x24(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x28(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x2c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x2c(%rbp)
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xc0c9
movl -0x2c(%rbp), %eax
movl %eax, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
cmpl $0x3, -0x1c(%rbp)
jae 0xc1ae
movq -0x40(%rbp), %rax
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x24(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x28(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movl -0x2c(%rbp), %edx
movb $-0x5f, (%rcx,%rdx)
addq $0x40000, %rax          # imm = 0x40000
movl -0x24(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x28(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x2c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x2c(%rbp)
movl %ecx, %ecx
movb $-0x1, (%rax,%rcx)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xc142
movq -0x40(%rbp), %rax
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x24(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x28(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movl -0x2c(%rbp), %edx
movb $-0x5, (%rcx,%rdx)
addq $0x40000, %rax          # imm = 0x40000
movl -0x24(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x28(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x2c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x2c(%rbp)
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movl $0x0, -0x1c(%rbp)
cmpl $0x100, -0x1c(%rbp)     # imm = 0x100
jae 0xc27f
movq -0x40(%rbp), %rax
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x24(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x28(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movl -0x2c(%rbp), %edx
movb $0x0, (%rcx,%rdx)
addq $0x40000, %rax          # imm = 0x40000
movl -0x24(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x28(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x2c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x2c(%rbp)
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xc210
cmpl $0x0, -0x24(%rbp)
jne 0xc4c7
cmpl $0x0, -0x28(%rbp)
jne 0xc4c7
cmpl $0x8, -0x30(%rbp)
jne 0xc4c7
movq -0x40(%rbp), %rax
movl -0x2c(%rbp), %ecx
subl $0x100, %ecx            # imm = 0x100
movl %ecx, -0x34(%rbp)
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x24(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x28(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movl -0x34(%rbp), %edx
addl $0xe1, %edx
movslq %edx, %rdx
movb $0x0, (%rcx,%rdx)
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x24(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x28(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movl -0x34(%rbp), %edx
addl $0xe2, %edx
movslq %edx, %rdx
movb $0x1, (%rcx,%rdx)
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x24(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x28(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movl -0x34(%rbp), %edx
addl $0xe3, %edx
movslq %edx, %rdx
movb $0x16, (%rcx,%rdx)
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x24(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x28(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movl -0x34(%rbp), %edx
addl $0xe4, %edx
movslq %edx, %rdx
movb $0x0, (%rcx,%rdx)
movw -0x12(%rbp), %si
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x24(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x28(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movslq -0x34(%rbp), %rdx
movw %si, 0xe5(%rcx,%rdx)
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x24(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x28(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movl -0x34(%rbp), %edx
addl $0xe7, %edx
movslq %edx, %rdx
movb $0x10, (%rcx,%rdx)
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x24(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x28(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movl -0x34(%rbp), %edx
addl $0xf4, %edx
movslq %edx, %rdx
movb $0x0, (%rcx,%rdx)
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x24(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x28(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movslq -0x34(%rbp), %rdx
movq 0x1ef4(%rip), %rsi      # 0xe324
movq %rsi, 0xf5(%rcx,%rdx)
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x24(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x28(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movl -0x34(%rbp), %edx
addl $0xfd, %edx
movslq %edx, %rdx
movb $0x0, (%rcx,%rdx)
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x24(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x28(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movl -0x34(%rbp), %edx
addl $0xfe, %edx
movslq %edx, %rdx
movb $0x0, (%rcx,%rdx)
addq $0x40000, %rax          # imm = 0x40000
movl -0x24(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x28(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl -0x34(%rbp), %ecx
addl $0xff, %ecx
movslq %ecx, %rcx
movb $0x0, (%rax,%rcx)
movq -0x40(%rbp), %rdi
movq %rdi, %rax
addq $0x40000, %rax          # imm = 0x40000
movl -0x24(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x28(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rsi
movl -0x18(%rbp), %eax
addq %rax, %rsi
movl -0x2c(%rbp), %eax
subl -0x18(%rbp), %eax
movl %eax, %eax
movl %eax, %edx
callq 0x1fa0
movw %ax, %cx
movq -0x40(%rbp), %rax
movw %cx, -0x1e(%rbp)
movzwl -0x1e(%rbp), %ecx
sarl $0x8, %ecx
movb %cl, %sil
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x24(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x28(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movl -0x2c(%rbp), %edx
movb %sil, (%rcx,%rdx)
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x24(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x28(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq 0x8(%rcx), %rcx
movl -0x2c(%rbp), %edx
movl %edx, %esi
addl $0x1, %esi
movl %esi, -0x2c(%rbp)
movl %edx, %edx
movb $0x0, (%rcx,%rdx)
movzwl -0x1e(%rbp), %ecx
andl $0xff, %ecx
movb %cl, %sil
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x24(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x28(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movl -0x2c(%rbp), %edx
movb %sil, (%rcx,%rdx)
addq $0x40000, %rax          # imm = 0x40000
movl -0x24(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x28(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x2c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x2c(%rbp)
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movl $0x0, -0x1c(%rbp)
cmpl $0x3c, -0x1c(%rbp)
jae 0xc647
movq -0x40(%rbp), %rax
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x24(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x28(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movl -0x2c(%rbp), %edx
movb $0x4e, (%rcx,%rdx)
addq $0x40000, %rax          # imm = 0x40000
movl -0x24(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x28(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x2c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x2c(%rbp)
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xc5db
jmp 0xc649
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0xbc11
movl -0x2c(%rbp), %eax
movl %eax, -0x38(%rbp)
cmpl $0x186a, -0x38(%rbp)    # imm = 0x186A
jge 0xc6cc
movq -0x40(%rbp), %rax
movq %rax, %rcx
addq $0x40000, %rcx          # imm = 0x40000
movl -0x24(%rbp), %edx
shlq $0xc, %rdx
addq %rdx, %rcx
movl -0x28(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
movl -0x2c(%rbp), %edx
movb $0x4e, (%rcx,%rdx)
addq $0x40000, %rax          # imm = 0x40000
movl -0x24(%rbp), %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x28(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x2c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x2c(%rbp)
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0xc65d
jmp 0xc6ce
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0xbb47
jmp 0xc6de
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xbb2a
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)