// File: atsidaev[P]trx2x/DiskImage.cpp
// Function: TDiskImage::readSCL(int, bool)
void TDiskImage::readSCL(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 < 9+4)      // header
   {
      delete ptr;
      ShowError(ERR_CORRUPT);
      return;
   }
   if(memcmp(ptr, "SINCLAIR", 8) != 0) 
   {
      delete ptr;
      ShowError(ERR_FORMAT" SCL!");
      return;
   }

   unsigned int FileCount = ptr[8];
   if(rsize < 9+4+FileCount*14)
   {
      delete ptr;
      ShowError(ERR_CORRUPT);
      return;
   }

   TRDOS_DIR_ELEMENT *fileinfo[256];

   unsigned short FilesTotalSecs = 0;

// checking for corrupt + SCL-CRC + FileDIRS parse
   uint32_t SCLCRC = 0;
   uint32_t sclOFF = 0;
   unsigned int i, j;
   for(i=0; i < 9; i++) SCLCRC += unsigned(ptr[sclOFF++]);

   for(i=0; i < FileCount; i++)
   {
      fileinfo[i] = (TRDOS_DIR_ELEMENT*)(ptr+sclOFF);
      for(j=0; j < 14; j++) SCLCRC += unsigned(ptr[sclOFF++]);
   }
   for(i=0; i < FileCount; i++)
   {
      unsigned SL = unsigned(fileinfo[i]->SecLen)*256;
      FilesTotalSecs += fileinfo[i]->SecLen;
      if(rsize < sclOFF+4+SL)
      {
         delete ptr;
         ShowError(ERR_CORRUPT);
         return;
      }
      for(j=0; j < SL; j++) SCLCRC += unsigned(ptr[sclOFF++]);
   }

   if( *((uint32_t*)(ptr+sclOFF)) != SCLCRC )
      ShowError(ERR_FILECRC" SCL!");


   if(FilesTotalSecs < 2544) FilesTotalSecs = 2544;
   else
   {
      int cyls = ((16+FilesTotalSecs) / (16*2)) + ( ((16+FilesTotalSecs) % (16*2))?  1:0);
      FilesTotalSecs = (cyls * 16*2)-16;
   }

   formatTRDOS((FilesTotalSecs+16)/(16*2), 2);
   ReadOnly = true;
   FType = DIT_SCL;
   DiskPresent = true;

   sclOFF = 9+14*FileCount;

   bool BOOTADD=true;

   unsigned char SEC=0, TRK=1;
   unsigned short FreeSEC = 2544;
   unsigned char _FileCount = 0;
   unsigned char _DelFileCount = 0;

   TRDOS_DIR_ELEMENT trdosde;
   VGFIND_SECTOR vgfs;
   char sbuf[512];

   for(i=0; i < FileCount; i++)
   {
      if(TRK >= (MaxTrack+1)*(MaxSide+1)) break;      // disk full ?

      memcpy(sbuf, fileinfo[i]->FileName, 9);
      if(sbuf[0] == 0x01) _DelFileCount++;
      _FileCount++; 
      make_uppercase(sbuf);
      if(!memcmp(sbuf, "BOOT    B", 9)) BOOTADD = false;

      memcpy(&trdosde, fileinfo[i], 14);

      trdosde.FirstSec = SEC;
      trdosde.FirstTrk = TRK;

      unsigned int dirsec = ((i*16)/256)+1;
      if(FindSector(0, 0, dirsec, &vgfs))         // DIR ELEMENT write
      {
         memcpy(vgfs.SectorPointer + ((i*16)%256), &trdosde, 16);
         ApplySectorCRC(vgfs);
      }

      for(j=0; j < unsigned(trdosde.SecLen); j++)
      {
         if(FindSector(TRK/2, TRK%2, SEC+1, &vgfs))       // SECTOR write
         {
            memcpy(vgfs.SectorPointer, ptr+sclOFF, 256);
            ApplySectorCRC(vgfs);
         }
         sclOFF+=256;
         SEC++;
         FreeSEC--;
         if(SEC > 15) { SEC=0; TRK++; }

         if(TRK >= (MaxTrack+1)*(MaxSide+1)) break;      // disk full ?
      }
   }
   if(!AddBOOT) BOOTADD = false;

   if(BOOTADD&&(unsigned(_FileCount)+unsigned(_DelFileCount) < 127))
   {
      unsigned int dirsec = ((_FileCount*16)/256)+1;
      if(FindSector(0, 0, dirsec, &vgfs))         // DIR ELEMENT write
      {
         memcpy(vgfs.SectorPointer + ((i*16)%256), sbootdir, 16);
         ApplySectorCRC(vgfs);
      }
      _FileCount++;

      memcpy(&trdosde, sbootdir, 16);

      unsigned char _bSEC=trdosde.FirstSec+1;
      unsigned int _bOFF=0;

      for(j=0; j < unsigned(trdosde.SecLen); j++)
      {
         if(FindSector(0, 0, _bSEC++, &vgfs))       // SECTOR write
         {
            memcpy(vgfs.SectorPointer, sbootimage+_bOFF, 256);
            ApplySectorCRC(vgfs);
         }
         _bOFF+=256;
         if(_bSEC > 16) break;
      }
   }

   if(FindSector(0, 0, 9, &vgfs))         // update disk info
   {
      vgfs.SectorPointer[0xE1] = SEC;
      vgfs.SectorPointer[0xE2] = TRK;
      vgfs.SectorPointer[0xE4] = _FileCount;
      vgfs.SectorPointer[0xF4] = _DelFileCount;
      *((unsigned short*)(vgfs.SectorPointer+0xE5)) = FreeSEC;
      ApplySectorCRC(vgfs);
   }

   delete ptr;
   ReadOnly = readonly;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd30, %rsp            # imm = 0xD30
movb %dl, %al
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
andb $0x1, %al
movb %al, -0xd(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xc98(%rbp)
movl -0xc(%rbp), %edi
callq 0xd6a0
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jge 0x59ff
movq -0xc98(%rbp), %rdi
leaq 0x8949(%rip), %rsi      # 0xe33e
callq 0x2c30
jmp 0x65c8
movq -0x18(%rbp), %rdi
addq $0x200000, %rdi         # imm = 0x200000
callq 0x1030
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x5a32
movq -0xc98(%rbp), %rdi
leaq 0x8934(%rip), %rsi      # 0xe35c
callq 0x2c30
jmp 0x65c8
movl -0xc(%rbp), %edi
movq -0x20(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x11a0
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x5a87
movq -0x20(%rbp), %rax
movq %rax, -0xca0(%rbp)
cmpq $0x0, %rax
je 0x5a6f
movq -0xca0(%rbp), %rdi
movl $0x1, %esi
callq 0x1130
movq -0xc98(%rbp), %rdi
leaq 0x88f1(%rip), %rsi      # 0xe36e
callq 0x2c30
jmp 0x65c8
cmpq $0xd, -0x28(%rbp)
jae 0x5ac8
movq -0x20(%rbp), %rax
movq %rax, -0xca8(%rbp)
cmpq $0x0, %rax
je 0x5ab0
movq -0xca8(%rbp), %rdi
movl $0x1, %esi
callq 0x1130
movq -0xc98(%rbp), %rdi
leaq 0x88b0(%rip), %rsi      # 0xe36e
callq 0x2c30
jmp 0x65c8
movq -0x20(%rbp), %rax
movq (%rax), %rax
movabsq $0x5249414c434e4953, %rcx # imm = 0x5249414C434E4953
subq %rcx, %rax
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
je 0x5b21
movq -0x20(%rbp), %rax
movq %rax, -0xcb0(%rbp)
cmpq $0x0, %rax
je 0x5b09
movq -0xcb0(%rbp), %rdi
movl $0x1, %esi
callq 0x1130
movq -0xc98(%rbp), %rdi
leaq 0x8a0f(%rip), %rsi      # 0xe526
callq 0x2c30
jmp 0x65c8
movq -0x20(%rbp), %rax
movzbl 0x8(%rax), %eax
movl %eax, -0x2c(%rbp)
movq -0x28(%rbp), %rax
imull $0xe, -0x2c(%rbp), %ecx
addl $0xd, %ecx
movl %ecx, %ecx
cmpq %rcx, %rax
jae 0x5b78
movq -0x20(%rbp), %rax
movq %rax, -0xcb8(%rbp)
cmpq $0x0, %rax
je 0x5b60
movq -0xcb8(%rbp), %rdi
movl $0x1, %esi
callq 0x1130
movq -0xc98(%rbp), %rdi
leaq 0x8800(%rip), %rsi      # 0xe36e
callq 0x2c30
jmp 0x65c8
movw $0x0, -0x832(%rbp)
movl $0x0, -0x838(%rbp)
movl $0x0, -0x83c(%rbp)
movl $0x0, -0x840(%rbp)
cmpl $0x9, -0x840(%rbp)
jae 0x5be0
movq -0x20(%rbp), %rax
movl -0x83c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x83c(%rbp)
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
addl -0x838(%rbp), %eax
movl %eax, -0x838(%rbp)
movl -0x840(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x840(%rbp)
jmp 0x5b9f
movl $0x0, -0x840(%rbp)
movl -0x840(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jae 0x5c71
movq -0x20(%rbp), %rcx
movl -0x83c(%rbp), %eax
addq %rax, %rcx
movl -0x840(%rbp), %eax
movq %rcx, -0x830(%rbp,%rax,8)
movl $0x0, -0x844(%rbp)
cmpl $0xe, -0x844(%rbp)
jae 0x5c5b
movq -0x20(%rbp), %rax
movl -0x83c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x83c(%rbp)
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
addl -0x838(%rbp), %eax
movl %eax, -0x838(%rbp)
movl -0x844(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x844(%rbp)
jmp 0x5c1a
jmp 0x5c5d
movl -0x840(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x840(%rbp)
jmp 0x5bea
movl $0x0, -0x840(%rbp)
movl -0x840(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jae 0x5d81
movl -0x840(%rbp), %eax
movq -0x830(%rbp,%rax,8), %rax
movzbl 0xd(%rax), %eax
shll $0x8, %eax
movl %eax, -0x848(%rbp)
movl -0x840(%rbp), %eax
movq -0x830(%rbp,%rax,8), %rax
movzbl 0xd(%rax), %ecx
movzwl -0x832(%rbp), %eax
addl %ecx, %eax
movw %ax, -0x832(%rbp)
movq -0x28(%rbp), %rax
movl -0x83c(%rbp), %ecx
addl $0x4, %ecx
addl -0x848(%rbp), %ecx
movl %ecx, %ecx
cmpq %rcx, %rax
jae 0x5d1b
movq -0x20(%rbp), %rax
movq %rax, -0xcc0(%rbp)
cmpq $0x0, %rax
je 0x5d03
movq -0xcc0(%rbp), %rdi
movl $0x1, %esi
callq 0x1130
movq -0xc98(%rbp), %rdi
leaq 0x865d(%rip), %rsi      # 0xe36e
callq 0x2c30
jmp 0x65c8
movl $0x0, -0x844(%rbp)
movl -0x844(%rbp), %eax
cmpl -0x848(%rbp), %eax
jae 0x5d6b
movq -0x20(%rbp), %rax
movl -0x83c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x83c(%rbp)
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
addl -0x838(%rbp), %eax
movl %eax, -0x838(%rbp)
movl -0x844(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x844(%rbp)
jmp 0x5d25
jmp 0x5d6d
movl -0x840(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x840(%rbp)
jmp 0x5c7b
movq -0x20(%rbp), %rax
movl -0x83c(%rbp), %ecx
movl (%rax,%rcx), %eax
cmpl -0x838(%rbp), %eax
je 0x5da9
movq -0xc98(%rbp), %rdi
leaq 0x879f(%rip), %rsi      # 0xe543
callq 0x2c30
movzwl -0x832(%rbp), %eax
cmpl $0x9f0, %eax            # imm = 0x9F0
jge 0x5dc2
movw $0x9f0, -0x832(%rbp)    # imm = 0x9F0
jmp 0x5e1e
movzwl -0x832(%rbp), %eax
addl $0x10, %eax
movl $0x20, %ecx
cltd
idivl %ecx
movl %eax, -0xcc4(%rbp)
movzwl -0x832(%rbp), %eax
addl $0x10, %eax
movl $0x20, %ecx
cltd
idivl %ecx
movl -0xcc4(%rbp), %eax
movl %edx, %esi
xorl %ecx, %ecx
movl $0x1, %edx
cmpl $0x0, %esi
cmovnel %edx, %ecx
addl %ecx, %eax
movl %eax, -0x84c(%rbp)
movl -0x84c(%rbp), %eax
shll $0x4, %eax
shll %eax
subl $0x10, %eax
movw %ax, -0x832(%rbp)
movq -0xc98(%rbp), %rdi
movzwl -0x832(%rbp), %eax
addl $0x10, %eax
movl $0x20, %ecx
cltd
idivl %ecx
movl %eax, %esi
movl $0x2, %edx
callq 0xbae0
movq -0xc98(%rbp), %rax
movb $0x1, 0x145005(%rax)
movl $0x2, 0x141000(%rax)
movb $0x1, 0x145006(%rax)
imull $0xe, -0x2c(%rbp), %eax
addl $0x9, %eax
movl %eax, -0x83c(%rbp)
movb $0x1, -0x84d(%rbp)
movb $0x0, -0x84e(%rbp)
movb $0x1, -0x84f(%rbp)
movw $0x9f0, -0x852(%rbp)    # imm = 0x9F0
movb $0x0, -0x853(%rbp)
movb $0x0, -0x854(%rbp)
movl $0x0, -0x840(%rbp)
movl -0x840(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jae 0x6227
movq -0xc98(%rbp), %rdx
movzbl -0x84f(%rbp), %eax
movzbl 0x145007(%rdx), %ecx
addl $0x1, %ecx
movzbl 0x145008(%rdx), %edx
addl $0x1, %edx
imull %edx, %ecx
cmpl %ecx, %eax
jl 0x5ee2
jmp 0x6227
movl -0x840(%rbp), %eax
movq -0x830(%rbp,%rax,8), %rax
movq (%rax), %rcx
movq %rcx, -0xac0(%rbp)
movb 0x8(%rax), %al
movb %al, -0xab8(%rbp)
movsbl -0xac0(%rbp), %eax
cmpl $0x1, %eax
jne 0x5f1d
movb -0x854(%rbp), %al
addb $0x1, %al
movb %al, -0x854(%rbp)
movb -0x853(%rbp), %al
addb $0x1, %al
movb %al, -0x853(%rbp)
leaq -0xac0(%rbp), %rdi
callq 0x1ad0
leaq -0xac0(%rbp), %rdi
leaq 0x8617(%rip), %rsi      # 0xe55c
movl $0x9, %edx
callq 0x1070
cmpl $0x0, %eax
jne 0x5f5b
movb $0x0, -0x84d(%rbp)
movq -0xc98(%rbp), %rdi
movl -0x840(%rbp), %eax
movq -0x830(%rbp,%rax,8), %rax
movq (%rax), %rcx
movq %rcx, -0x864(%rbp)
movl 0x8(%rax), %ecx
movl %ecx, -0x85c(%rbp)
movw 0xc(%rax), %ax
movw %ax, -0x858(%rbp)
movb -0x84e(%rbp), %al
movb %al, -0x856(%rbp)
movb -0x84f(%rbp), %al
movb %al, -0x855(%rbp)
movl -0x840(%rbp), %eax
shll $0x4, %eax
shrl $0x8, %eax
addl $0x1, %eax
movl %eax, -0xac4(%rbp)
movl -0xac4(%rbp), %eax
xorl %r9d, %r9d
leaq -0x8c0(%rbp), %r8
movl %r9d, %esi
movl %r9d, %edx
movzbl %al, %ecx
callq 0x25d0
testb $0x1, %al
jne 0x5fe2
jmp 0x6079
movq -0x888(%rbp), %rax
movl -0x840(%rbp), %ecx
shll $0x4, %ecx
andl $0xff, %ecx
movl %ecx, %ecx
movq -0x864(%rbp), %rdx
movq %rdx, (%rax,%rcx)
movq -0x85c(%rbp), %rdx
movq %rdx, 0x8(%rax,%rcx)
leaq -0xb20(%rbp), %rdi
leaq -0x8c0(%rbp), %rsi
movl $0x58, %edx
callq 0x10c0
movq -0xc98(%rbp), %rdi
movq -0xad0(%rbp), %rcx
movq %rsp, %rax
movq %rcx, 0x50(%rax)
movups -0xae0(%rbp), %xmm0
movups %xmm0, 0x40(%rax)
movups -0xb20(%rbp), %xmm0
movups -0xb10(%rbp), %xmm1
movups -0xb00(%rbp), %xmm2
movups -0xaf0(%rbp), %xmm3
movups %xmm3, 0x30(%rax)
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0x2040
movl $0x0, -0x844(%rbp)
movl -0x844(%rbp), %eax
movzbl -0x857(%rbp), %ecx
cmpl %ecx, %eax
jae 0x6211
movq -0xc98(%rbp), %rdi
movzbl -0x84f(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movb %al, -0xcc5(%rbp)
movzbl -0x84f(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %edx, %eax
movb -0xcc5(%rbp), %dl
movb %al, %cl
movzbl -0x84e(%rbp), %eax
addl $0x1, %eax
leaq -0x8c0(%rbp), %r8
xorl %r9d, %r9d
movzbl %dl, %esi
movzbl %cl, %edx
movzbl %al, %ecx
callq 0x25d0
testb $0x1, %al
jne 0x60f8
jmp 0x617e
movq -0x888(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl -0x83c(%rbp), %eax
addq %rax, %rsi
movl $0x100, %edx            # imm = 0x100
callq 0x10c0
leaq -0xb78(%rbp), %rdi
leaq -0x8c0(%rbp), %rsi
movl $0x58, %edx
callq 0x10c0
movq -0xc98(%rbp), %rdi
movq -0xb28(%rbp), %rcx
movq %rsp, %rax
movq %rcx, 0x50(%rax)
movups -0xb38(%rbp), %xmm0
movups %xmm0, 0x40(%rax)
movups -0xb78(%rbp), %xmm0
movups -0xb68(%rbp), %xmm1
movups -0xb58(%rbp), %xmm2
movups -0xb48(%rbp), %xmm3
movups %xmm3, 0x30(%rax)
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0x2040
movl -0x83c(%rbp), %eax
addl $0x100, %eax            # imm = 0x100
movl %eax, -0x83c(%rbp)
movb -0x84e(%rbp), %al
addb $0x1, %al
movb %al, -0x84e(%rbp)
movw -0x852(%rbp), %ax
addw $-0x1, %ax
movw %ax, -0x852(%rbp)
movzbl -0x84e(%rbp), %eax
cmpl $0xf, %eax
jle 0x61d0
movb $0x0, -0x84e(%rbp)
movb -0x84f(%rbp), %al
addb $0x1, %al
movb %al, -0x84f(%rbp)
movq -0xc98(%rbp), %rdx
movzbl -0x84f(%rbp), %eax
movzbl 0x145007(%rdx), %ecx
addl $0x1, %ecx
movzbl 0x145008(%rdx), %edx
addl $0x1, %edx
imull %edx, %ecx
cmpl %ecx, %eax
jl 0x61fb
jmp 0x6211
jmp 0x61fd
movl -0x844(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x844(%rbp)
jmp 0x6083
jmp 0x6213
movl -0x840(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x840(%rbp)
jmp 0x5ea5
movq -0xc98(%rbp), %rax
testb $0x1, 0x145009(%rax)
jne 0x623e
movb $0x0, -0x84d(%rbp)
testb $0x1, -0x84d(%rbp)
je 0x64a0
movzbl -0x853(%rbp), %eax
movzbl -0x854(%rbp), %ecx
addl %ecx, %eax
cmpl $0x7f, %eax
jae 0x64a0
movq -0xc98(%rbp), %rdi
movzbl -0x853(%rbp), %eax
shll $0x4, %eax
movl $0x100, %ecx            # imm = 0x100
cltd
idivl %ecx
addl $0x1, %eax
movl %eax, -0xb7c(%rbp)
movl -0xb7c(%rbp), %eax
xorl %r9d, %r9d
leaq -0x8c0(%rbp), %r8
movl %r9d, %esi
movl %r9d, %edx
movzbl %al, %ecx
callq 0x25d0
testb $0x1, %al
jne 0x62ad
jmp 0x6344
movq -0x888(%rbp), %rax
movl -0x840(%rbp), %ecx
shll $0x4, %ecx
andl $0xff, %ecx
movl %ecx, %ecx
movq 0xaef4(%rip), %rdx      # 0x111c0
movq %rdx, (%rax,%rcx)
movq 0xaef1(%rip), %rdx      # 0x111c8
movq %rdx, 0x8(%rax,%rcx)
leaq -0xbd8(%rbp), %rdi
leaq -0x8c0(%rbp), %rsi
movl $0x58, %edx
callq 0x10c0
movq -0xc98(%rbp), %rdi
movq -0xb88(%rbp), %rcx
movq %rsp, %rax
movq %rcx, 0x50(%rax)
movups -0xb98(%rbp), %xmm0
movups %xmm0, 0x40(%rax)
movups -0xbd8(%rbp), %xmm0
movups -0xbc8(%rbp), %xmm1
movups -0xbb8(%rbp), %xmm2
movups -0xba8(%rbp), %xmm3
movups %xmm3, 0x30(%rax)
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0x2040
movb -0x853(%rbp), %al
addb $0x1, %al
movb %al, -0x853(%rbp)
movq 0xae67(%rip), %rax      # 0x111c0
movq %rax, -0x864(%rbp)
movq 0xae61(%rip), %rax      # 0x111c8
movq %rax, -0x85c(%rbp)
movzbl -0x856(%rbp), %eax
addl $0x1, %eax
movb %al, -0xbd9(%rbp)
movl $0x0, -0xbe0(%rbp)
movl $0x0, -0x844(%rbp)
movl -0x844(%rbp), %eax
movzbl -0x857(%rbp), %ecx
cmpl %ecx, %eax
jae 0x649e
movq -0xc98(%rbp), %rdi
movb -0xbd9(%rbp), %al
movb %al, %cl
addb $0x1, %cl
movb %cl, -0xbd9(%rbp)
xorl %r9d, %r9d
leaq -0x8c0(%rbp), %r8
movl %r9d, %esi
movl %r9d, %edx
movzbl %al, %ecx
callq 0x25d0
testb $0x1, %al
jne 0x63e0
jmp 0x6469
movq -0x888(%rbp), %rdi
movl -0xbe0(%rbp), %eax
leaq 0xb1ed(%rip), %rsi      # 0x115e1
addq %rax, %rsi
movl $0x100, %edx            # imm = 0x100
callq 0x10c0
leaq -0xc38(%rbp), %rdi
leaq -0x8c0(%rbp), %rsi
movl $0x58, %edx
callq 0x10c0
movq -0xc98(%rbp), %rdi
movq -0xbe8(%rbp), %rcx
movq %rsp, %rax
movq %rcx, 0x50(%rax)
movups -0xbf8(%rbp), %xmm0
movups %xmm0, 0x40(%rax)
movups -0xc38(%rbp), %xmm0
movups -0xc28(%rbp), %xmm1
movups -0xc18(%rbp), %xmm2
movups -0xc08(%rbp), %xmm3
movups %xmm3, 0x30(%rax)
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0x2040
movl -0xbe0(%rbp), %eax
addl $0x100, %eax            # imm = 0x100
movl %eax, -0xbe0(%rbp)
movzbl -0xbd9(%rbp), %eax
cmpl $0x10, %eax
jle 0x6488
jmp 0x649e
jmp 0x648a
movl -0x844(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x844(%rbp)
jmp 0x6392
jmp 0x64a0
movq -0xc98(%rbp), %rdi
xorl %r9d, %r9d
movl $0x9, %ecx
leaq -0x8c0(%rbp), %r8
movl %r9d, %esi
movl %r9d, %edx
callq 0x25d0
testb $0x1, %al
jne 0x64ca
jmp 0x6593
movb -0x84e(%rbp), %cl
movq -0x888(%rbp), %rax
movb %cl, 0xe1(%rax)
movb -0x84f(%rbp), %cl
movq -0x888(%rbp), %rax
movb %cl, 0xe2(%rax)
movb -0x853(%rbp), %cl
movq -0x888(%rbp), %rax
movb %cl, 0xe4(%rax)
movb -0x854(%rbp), %cl
movq -0x888(%rbp), %rax
movb %cl, 0xf4(%rax)
movw -0x852(%rbp), %cx
movq -0x888(%rbp), %rax
movw %cx, 0xe5(%rax)
leaq -0xc90(%rbp), %rdi
leaq -0x8c0(%rbp), %rsi
movl $0x58, %edx
callq 0x10c0
movq -0xc98(%rbp), %rdi
movq -0xc40(%rbp), %rcx
movq %rsp, %rax
movq %rcx, 0x50(%rax)
movups -0xc50(%rbp), %xmm0
movups %xmm0, 0x40(%rax)
movups -0xc90(%rbp), %xmm0
movups -0xc80(%rbp), %xmm1
movups -0xc70(%rbp), %xmm2
movups -0xc60(%rbp), %xmm3
movups %xmm3, 0x30(%rax)
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0x2040
movq -0x20(%rbp), %rax
movq %rax, -0xcd0(%rbp)
cmpq $0x0, %rax
je 0x65b5
movq -0xcd0(%rbp), %rdi
movl $0x1, %esi
callq 0x1130
movq -0xc98(%rbp), %rax
movb -0xd(%rbp), %cl
andb $0x1, %cl
movb %cl, 0x145005(%rax)
addq $0xd30, %rsp            # imm = 0xD30
popq %rbp
retq
nopw %cs:(%rax,%rax)