// File: /workspace/github_c_makefile_star2_O1/mincebert[P]maketzx/maketzx.c
// Function: DataRead
dword DataRead(double bit0,double bit1,word explen)
{
  byte value,count,lastval,tolerance,maxpulse;/*=bit1+bit0-tolerance;*/
  word pulse;
  dword amount=0;
  double middle;
  if (spdchk) { bit0*=ecf; bit1*=ecf; }
  middle=(double)(bit1+bit0)/2;
//  if (bit0-bit1+2*tolerance) { bit1++; tolerance++; }
/*  if (maxpulse>pilot.samples)*/
  maxpulse=bit1+(pilot.samples-bit1)/2+1;
  tolerance=(bit1-bit0)/2;
  if (maxpulse>(byte)bit1+(byte)bit0) maxpulse=bit1+bit0-tolerance;
  if (!subblocks && !slocktype || raw) checksum=0;
  for (count=0; count<8; count++) faultybits[count]=0;
  probend=0;
  EndBlock=0;
  DataLoadOK=0;
  printf("Reading data...            \x0d");
  if (!explen)
     {
       do {
	    PushFilePointers();
	    value=0;
	    for (count=0; count<8; count++)
		{
//                byte good=1;
		  pulse=0;
		  if (EndBlock) break;

/*                do {
		       pulse+=FindEdge1();
		       if (currpulse<2) good=0;
		       else good=1;
		     }
		  while (!good && blocktype);
		  do {
		       pulse+=FindEdge1();
		       if (currpulse<2) good=0;
		       else good=1;
		     }
		  while (!good && blocktype); */

//                do pulse+=FindEdge2();
//                while (pulse<bit0-tolerance && blocktype);

		     do {
			  pulse=FindEdge2();
//                        if (pulse<bit0-tolerance && pulse-diff>0 && abs(diff)<5)
//                        pulse-=diff;
			}
		     while (pulse<bit0-tolerance && blocktype);


		  if (((pulse-(int)(middle+.5))<2 && (pulse-2*currpulse)>2) || pulse>maxpulse)
		     {
		       if (currpulse+lastpulse>maxpulse)
			  {
			    if (!count)
			       {
				 mspause+=(pulse/samprate)*1000;
				 EndBlock=1;
				 break;
			       }
			    if (count==7)
			       {
				 mspause+=((pulse-(2*lastpulse))/samprate)*1000;
				 pulse=2*lastpulse;
				 EndBlock=1;
			       }
			    else if ((slocktype>1 && slocktype<5) && blocks>blockskip+1)
				    {
				      PopFilePointers();
				      //RecoverFilePointers();
				      lseek(inpfile.handle,filepos,SEEK_SET);
				      inpfile.bufpoint=0;
				      EndBlock=1; break;
				    }
				 else { EndBlock=1; break; }
			  }
			else {
			       if (loggen) fprintf(logfile,"?- Ambiguous pulse found: %u samples,",pulse);
			       pulse=((currpulse+lastpulse)/2+pulse-middle+(lastpulse<currpulse))*2;
			       if (loggen) {
					     fprintf(logfile," changed to %u (%d)\n",pulse,pulse>middle);
					     fprintf(logfile,"   Position: block %ld, byte %lu, bit %ld, sample %lu\n\n",(dword)blocks,(dword)amount,(dword)7-count,(dword)totalread-pulse);
					   }
			       faultybits[7-count]++;
			      }
		     }

	       /*         if (pulse>bit1+tolerance || pulse>pilot.samples)
		     {
		       if (count==7) {
				       mspause+=((pulse-(2*lastpulse))/samprate)*1000;
				       pulse=2*lastpulse;
				       EndBlock=1;
				     }
		       else if ((slocktype>1 && slocktype<5) && blocks>blockskip+1)
			       {
				 PopFilePointers();
				 lseek(inpfile.handle,filepos,SEEK_SET);
				 inpfile.bufpoint=0;
				 EndBlock=1; break;
			       }
			    else { EndBlock=1; break; }
		     } */
		  if (!blocktype && !count)
		     {
		       if ((alk && blocks>2) || (!checksum && amount)) DataLoadOK=1;
		       return amount;
		     }
		  if (pulse>=bit0-tolerance && pulse<=middle) value<<=1;
		  else if (pulse>middle && pulse<=maxpulse) { value<<=1; value|=0x1; }
		}
	    if (count==8)
	       {
		 amount++;
		 if (amount==1) flag=value;
		 chksum=lastval=value;
		 lastval=value;
		 checksum^=value;
		 if (!checksum) probend=amount;
		 PutData(&tempfile,value,1);
	       }
	    RemoveFilePointers();
	  }
       while (!EndBlock);
//       RecoverFilePointers();
       if ((!checksum && amount) || ((alk || (blocks>blockskip && blockskip && !raw)) || (slocktype>1 && slocktype<5 && blocks>blockskip+1 && blockskip)))
	  {
	    byte bitpoint;
	    byte fbits=0;
	    DataLoadOK=1;
	    if (loggen)
	       {
		 fprintf(logfile,"!- Block %d",blocks);
		 if (subblocks) fprintf(logfile," -> Sub-block %d",subblocks);
		 if (alk)
		    {
		      if (blocks<blockskip) fprintf(logfile," loaded OK\n");
		      else fprintf(logfile," is Alkatraz and cannot be checked\n");
		    }
		 else fprintf(logfile," loaded OK\n");
	       }
	    for (bitpoint=0; bitpoint<8; bitpoint++)
		{
		  if (faultybits[bitpoint]>1) { fbits++; }
		}
	    if (fbits)
	       {
		 if (loggen)
		    {
		      fprintf(logfile,"\n!- WARNING!!! Several ambiguous pulses were found loading bit");
		      if (fbits>1) fprintf(logfile,"s");
		      fprintf(logfile," ");
		    }
		 for (bitpoint=0; bitpoint<8; bitpoint++)
		     if (faultybits[bitpoint]>1)
			   {
			     if (loggen) fprintf(logfile,"%d",bitpoint);
			     fbits--;
			     if (loggen)
				{
				  if (fbits) fprintf(logfile,",");
				  else fprintf(logfile,".\n");
				}
			   }
		 if (loggen)
		    {
		      fprintf(logfile,"   It's strictly recommended that you check that block by loading it on a real\n");
		      fprintf(logfile,"   ZX Spectrum (better solution) or an emulator.\n\n");
		    }
	       }
	  }
       else if (probend && amount-probend<=2)
	    { amount=probend; checksum=0; DataLoadOK=1; }
	    else {
		   char bitpoint;
		   word meanbits[8]={ 0,0,0,0,0,0,0,0 };
		   byte bit,fbits=0;
		   byte dchecksum=checksum;
		   DataLoadOK=0;
		   if (loggen) fprintf(logfile,"X- Bad checksum in block %d (calculated=%d (#%2X), loaded=%d (#%2X))\n",blocks,dchecksum^lastval,dchecksum^lastval,lastval,lastval);
		   for (bitpoint=7; bitpoint>=0; bitpoint--)
		       {
			 if (faultybits[bitpoint])
			    {
			      //bit=pow(2,bitpoint)
			      bit=(int)(1<<bitpoint);
			      if (dchecksum>bit-1)
				 {
				   meanbits[bitpoint]++;
				   fbits++;
				   dchecksum^=bit*(faultybits[bitpoint]==1);
				 }
			    }
			 if (!dchecksum) break;
		       }
		   if (loggen)
		      {
			if (!fbits) fprintf(logfile,"   No ambiguous bits in that block...try resampling and cross your fingers!!!\n");
			else {
			       fprintf(logfile,"   Ambiguous pulses were found in the block ");
			       if (!dchecksum) fprintf(logfile,"and some of them seemed\n   to be determinant:\n");
			       else fprintf(logfile," but none of them was determinant\n   Please try resampling...\n\n");
			     }
		      }
		 }
       if (!mspause && !subblocks) mspause=(pulse/samprate)*1000;
       if (loggen) fprintf(logfile,"\n+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n\n");
     }
  else {
	 mspause=0;
	 for (amount=0; amount<explen; amount++)
	     {
//             byte good=1;
	       value=0;
	       for (count=0; count<8; count++)
		   {

		     pulse=0;
/*                   do {
			  pulse+=FindEdge1();
			  if (currpulse<2) good=0;
			  else good=1;
			}
		     while (!good && blocktype);
		     do {
			  pulse+=FindEdge1();
			  if (currpulse<2) good=0;
			  else good=1;
			}
		     while (!good && blocktype); */


		     do {
			  pulse=FindEdge2();
//                        if ((currpulse<2 || lastpulse<2) && abs(currpulse-lastpulse)>4)
//                           do pulse+=FindEdge1();
//                           while (currpulse<2);
			}
		     while (pulse<bit0-tolerance && blocktype);

		     if (!blocktype && !count)
			{
			  if (!checksum) DataLoadOK=1;
			  return amount;
			}
		     if (pulse>=bit0-tolerance && pulse<=middle) value<<=1;
		     else if (pulse>middle && pulse<=maxpulse) { value<<=1; value|=0x1; }
			  else { strcpy(errstring,"Pulse too long"); Error(8); }
		   }
	       if (soft && blocks>blockskip) checksum^=MirrorByte(value);
	       else checksum^=value;
	       if (amount==1) flag=value;
	       if (amount==explen-1)
	       chksum=value;
	       if (amount==0x11d2)
	       amount=amount+1-1;
	       PutData(&tempfile,value,1);
	     }
	 if (!checksum || ((slocktype || zeta) && blocks>blockskip && !SpeedEndBlock) ||
	      (soft)) DataLoadOK=1;
	 expectedlength=0;
       }
  return amount;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %edi, %r14d
cmpb $0x0, 0xb7d8(%rip)      # 0xf1b9
je 0x39f3
movsd 0xb70d(%rip), %xmm2     # 0xf0f8
mulsd %xmm2, %xmm0
mulsd %xmm2, %xmm1
movapd %xmm1, %xmm4
addsd %xmm0, %xmm4
movsd 0x78cd(%rip), %xmm3     # 0xb2d0
movsd 0x17d3d(%rip), %xmm2    # 0x1b748
subsd %xmm1, %xmm2
mulsd %xmm3, %xmm2
addsd %xmm1, %xmm2
addsd 0x7899(%rip), %xmm2     # 0xb2b8
cvttsd2si %xmm2, %eax
cvttsd2si %xmm1, %ecx
subsd %xmm0, %xmm1
mulsd %xmm3, %xmm1
cvttsd2si %xmm1, %edx
movl $0xff, %esi
movl %eax, %edi
andl %esi, %edi
andl %esi, %ecx
movsd %xmm0, 0x20(%rsp)
cvttsd2si %xmm0, %r8d
andl %esi, %r8d
addl %ecx, %r8d
andl %esi, %edx
cmpl %edi, %r8d
xorps %xmm0, %xmm0
cvtsi2sd %edx, %xmm0
movapd %xmm4, %xmm1
movsd %xmm0, 0x10(%rsp)
subsd %xmm0, %xmm1
cvttsd2si %xmm1, %ebx
cmovael %eax, %ebx
cmpl $0x0, 0xb7d1(%rip)      # 0xf248
sete %al
cmpb $0x0, 0xb733(%rip)      # 0xf1b4
sete %cl
testb %cl, %al
jne 0x3a91
cmpb $0x0, 0xb727(%rip)      # 0xf1b6
je 0x3a98
movb $0x0, 0x18150(%rip)     # 0x1bbe8
mulsd %xmm3, %xmm4
movsd %xmm4, 0x18(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0xb7c2(%rip)     # 0xf270
movapd %xmm0, 0xb7aa(%rip)     # 0xf260
movq $0x0, 0xb757(%rip) # 0xf218
xorl %eax, %eax
movb %al, 0x17cef(%rip)      # 0x1b7b8
movb %al, 0x1811a(%rip)      # 0x1bbe9
leaq 0x7bb0(%rip), %rdi      # 0xb686
xorl %eax, %eax
callq 0x10b0
movsd 0x18(%rsp), %xmm1
movzbl %bl, %r12d
movsd 0x20(%rsp), %xmm0
subsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x20(%rsp)
testl %r14d, %r14d
je 0x3c64
movq $0x0, 0xb713(%rip) # 0xf220
movl %r14d, %ebp
decl %r14d
xorl %ebx, %ebx
movq %rbp, %r15
xorl %r13d, %r13d
xorl %ebp, %ebp
callq 0x2648
movsd 0x20(%rsp), %xmm1
movl %eax, %ecx
xorps %xmm0, %xmm0
cvtsi2sd %rcx, %xmm0
ucomisd %xmm0, %xmm1
movb 0x17b85(%rip), %cl      # 0x1b6c1
jbe 0x3b42
testb %cl, %cl
jne 0x3b1d
orb %r13b, %cl
je 0x3c4c
ucomisd %xmm1, %xmm0
movsd 0x18(%rsp), %xmm1
jb 0x3b62
ucomisd %xmm0, %xmm1
jb 0x3b62
addb %bpl, %bpl
jmp 0x3b7b
ucomisd %xmm1, %xmm0
jbe 0x4446
cmpl %r12d, %eax
ja 0x4446
addb %bpl, %bpl
incb %bpl
incb %r13b
cmpb $0x8, %r13b
jne 0x3b1d
cmpb $0x0, 0xb627(%rip)      # 0xf1b2
movl %ebp, %eax
je 0x3bb6
movl 0xb693(%rip), %ecx      # 0xf228
movl %ebp, %eax
cmpl 0xb68f(%rip), %ecx      # 0xf22c
jbe 0x3bb6
movb $0x8, %cl
xorl %eax, %eax
movl %ebp, %edx
shrb %al
movl %edx, %esi
andb $-0x80, %sil
orb %sil, %al
addb %dl, %dl
decb %cl
jne 0x3ba5
xorb %al, 0x1802c(%rip)      # 0x1bbe8
cmpq $0x1, %rbx
jne 0x3bc9
movb %bpl, 0x18021(%rip)     # 0x1bbea
cmpq %r14, %rbx
jne 0x3bd5
movb %bpl, 0x18016(%rip)     # 0x1bbeb
movzbl %bpl, %esi
leaq 0x138d8(%rip), %rdi     # 0x174b8
movl $0x1, %edx
callq 0x1e21
incq %rbx
movq %r15, %rbp
cmpq %r15, %rbx
jne 0x3b15
cmpb $0x0, 0x17fe8(%rip)     # 0x1bbe8
je 0x3c36
movb 0xb5ad(%rip), %al       # 0xf1b5
orb 0xb5a6(%rip), %al       # 0xf1b4
je 0x3c2d
movl 0xb612(%rip), %eax      # 0xf228
cmpl 0xb610(%rip), %eax      # 0xf22c
seta %al
cmpb $0x0, 0x17fc6(%rip)     # 0x1bbec
sete %cl
testb %cl, %al
jne 0x3c36
cmpb $0x0, 0xb57e(%rip)      # 0xf1b2
je 0x3c3d
movb $0x1, 0x17fac(%rip)     # 0x1bbe9
movl $0x0, 0xb5cd(%rip)      # 0xf214
jmp 0x40e6
cmpb $0x0, 0x17f95(%rip)     # 0x1bbe8
jne 0x3c5c
movb $0x1, 0x17f8d(%rip)     # 0x1bbe9
movq %rbx, %rbp
jmp 0x40e6
movsd 0x7664(%rip), %xmm0     # 0xb2d0
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %r13d
leaq 0xb5e4(%rip), %r15      # 0xf260
xorl %ebp, %ebp
movl %r13d, 0x2c(%rsp)
callq 0x165a
xorl %ebx, %ebx
movq $0x0, 0x10(%rsp)
cmpb $0x0, 0x17b1e(%rip)     # 0x1b7b8
jne 0x3f06
callq 0x2648
movsd 0x20(%rsp), %xmm1
movq %rax, %r14
movl %r14d, %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
ucomisd %xmm0, %xmm1
jbe 0x3cc8
cmpb $0x0, 0x179fb(%rip)     # 0x1b6c1
jne 0x3ca0
movl %r14d, %ecx
subl %r13d, %ecx
cmpl $0x1, %ecx
ja 0x3cfa
movl %r14d, %ecx
movq 0x179fb(%rip), %rdx     # 0x1b6d8
addq %rdx, %rdx
subq %rdx, %rcx
cmpq $0x2, %rcx
movsd 0x18(%rsp), %xmm3
ja 0x3d09
cmpl %r12d, %r14d
jbe 0x3eab
jmp 0x3d09
cmpl %r12d, %r14d
movsd 0x18(%rsp), %xmm3
jbe 0x3eab
movq 0x179c0(%rip), %rcx     # 0x1b6d0
movq 0x179c1(%rip), %rdx     # 0x1b6d8
addq %rcx, %rdx
cmpq %r12, %rdx
jbe 0x3d45
cmpb $0x7, %bl
jne 0x3f0b
movl %r14d, %eax
leaq (%rcx,%rcx), %rdx
subq %rdx, %rax
js 0x3e63
xorps %xmm0, %xmm0
cvtsi2ss %rax, %xmm0
jmp 0x3e7b
cmpb $0x0, 0xb46c(%rip)      # 0xf1b8
je 0x3d6c
movq 0x1375b(%rip), %rdi     # 0x174b0
leaq 0x7947(%rip), %rsi      # 0xb6a3
movl %r14d, %edx
xorl %eax, %eax
callq 0x1120
movsd 0x18(%rsp), %xmm3
movq 0x17965(%rip), %rax     # 0x1b6d8
movq 0x17956(%rip), %rcx     # 0x1b6d0
leaq (%rcx,%rax), %rdx
shrq %rdx
movl %r14d, %esi
addq %rdx, %rsi
movq %rsi, %xmm0
punpckldq 0x767c(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x7684(%rip), %xmm0     # 0xb420
movsd 0x7514(%rip), %xmm1     # 0xb2b8
cmpq %rax, %rcx
jb 0x3dad
xorpd %xmm1, %xmm1
movapd %xmm0, %xmm2
unpckhpd %xmm0, %xmm2            # xmm2 = xmm2[1],xmm0[1]
addsd %xmm0, %xmm2
subsd %xmm3, %xmm2
addsd %xmm1, %xmm2
addsd %xmm2, %xmm2
cvttsd2si %xmm2, %r14
cmpb $0x0, 0xb3e7(%rip)      # 0xf1b8
je 0x3e48
movq 0x136d6(%rip), %rdi     # 0x174b0
movq %r12, %r13
movq %r15, %r12
movq %rbp, %r15
movl %r14d, %ebp
xorps %xmm0, %xmm0
cvtsi2sd %rbp, %xmm0
xorl %ecx, %ecx
ucomisd %xmm3, %xmm0
seta %cl
leaq 0x78cb(%rip), %rsi      # 0xb6c9
movl %r14d, %edx
xorl %eax, %eax
callq 0x1120
movq 0x136a1(%rip), %rdi     # 0x174b0
movl 0xb413(%rip), %edx      # 0xf228
movl $0x7, %r8d
subq %rbx, %r8
movq 0xb3ab(%rip), %r9       # 0xf1d0
subq %rbp, %r9
movq %r15, %rbp
movq %r12, %r15
movq %r13, %r12
leaq 0x78a6(%rip), %rsi      # 0xb6de
movq %rbp, %rcx
xorl %eax, %eax
callq 0x1120
movsd 0x18(%rsp), %xmm3
movl $0x7, %eax
subl %ebx, %eax
shll $0x2, %eax
incl (%rax,%r15)
movsd 0x20(%rsp), %xmm1
movl 0x2c(%rsp), %r13d
jmp 0x3eab
movq %rax, %rdx
shrq %rdx
andl $0x1, %eax
orq %rdx, %rax
xorps %xmm0, %xmm0
cvtsi2ss %rax, %xmm0
addss %xmm0, %xmm0
divss 0xb36d(%rip), %xmm0     # 0xf1f0
mulss 0x7559(%rip), %xmm0     # 0xb3e4
cvtss2sd %xmm0, %xmm0
addsd 0xb389(%rip), %xmm0     # 0xf220
movsd %xmm0, 0xb381(%rip)     # 0xf220
addl %ecx, %ecx
movb $0x1, 0x17910(%rip)     # 0x1b7b8
movl %ecx, %r14d
movb 0x17810(%rip), %al      # 0x1b6c1
orb %bl, %al
je 0x40b6
movl %r14d, %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
ucomisd %xmm1, %xmm0
jb 0x3ed9
ucomisd %xmm0, %xmm3
jb 0x3ed9
movq 0x10(%rsp), %rax
addb %al, %al
jmp 0x3eed
ucomisd %xmm3, %xmm0
jbe 0x3ef2
cmpl %r12d, %r14d
ja 0x3ef2
movq 0x10(%rsp), %rax
addb %al, %al
incb %al
movq %rax, 0x10(%rsp)
incq %rbx
cmpq $0x8, %rbx
jne 0x3c93
movb $0x8, %bl
jmp 0x3f87
xorl %r14d, %r14d
jmp 0x3f87
movzbl %bl, %ecx
testl %ecx, %ecx
jne 0x3f40
xorps %xmm0, %xmm0
cvtsi2ss %rax, %xmm0
divss 0xb2ce(%rip), %xmm0     # 0xf1f0
mulss 0x74ba(%rip), %xmm0     # 0xb3e4
cvtss2sd %xmm0, %xmm0
addsd 0xb2ea(%rip), %xmm0     # 0xf220
movsd %xmm0, 0xb2e2(%rip)     # 0xf220
jmp 0x3f80
movb 0xb26e(%rip), %al       # 0xf1b4
addb $-0x2, %al
cmpb $0x2, %al
ja 0x3f80
movl 0xb2da(%rip), %eax      # 0xf22c
incl %eax
cmpl %eax, 0xb2ce(%rip)      # 0xf228
jbe 0x3f80
callq 0x16fb
movzbl 0xb318(%rip), %edi      # 0xf280
movq 0xb279(%rip), %rsi      # 0xf1e8
xorl %edx, %edx
callq 0x10d0
movl $0x0, 0xb400(%rip)      # 0xf380
movb $0x1, 0x17831(%rip)     # 0x1b7b8
cmpb $0x8, %bl
jne 0x3fd8
testq %rbp, %rbp
movq 0x10(%rsp), %rbx
jne 0x3f9c
movb %bl, 0x17c4e(%rip)      # 0x1bbea
incq %rbp
movb %bl, 0x17c46(%rip)      # 0x1bbeb
movb 0x17c3d(%rip), %al      # 0x1bbe8
movl %eax, %ecx
xorb %bl, %cl
movb %cl, 0x17c33(%rip)      # 0x1bbe8
cmpb %bl, %al
jne 0x3fc0
movq %rbp, 0xb258(%rip)      # 0xf218
movzbl %bl, %esi
leaq 0x134ee(%rip), %rdi     # 0x174b8
movl $0x1, %edx
callq 0x1e21
movb %bl, 0xf(%rsp)
callq 0x178c
cmpb $0x0, 0x177d4(%rip)     # 0x1b7b8
je 0x3c83
movb 0x17bf8(%rip), %bl      # 0x1bbe8
testb %bl, %bl
sete %al
testq %rbp, %rbp
setne %cl
testb %cl, %al
jne 0x4031
cmpb $0x0, 0xb1ab(%rip)      # 0xf1b1
jne 0x4031
movl 0xb21a(%rip), %edx      # 0xf228
movl 0xb218(%rip), %eax      # 0xf22c
cmpl %eax, %edx
jbe 0x40f8
testl %eax, %eax
je 0x40f8
cmpb $0x0, 0xb18b(%rip)      # 0xf1b6
jne 0x40f8
movb $0x1, 0x17bb1(%rip)     # 0x1bbe9
cmpb $0x0, 0xb179(%rip)      # 0xf1b8
je 0x4175
movq 0x13464(%rip), %rdi     # 0x174b0
movl 0xb1d6(%rip), %edx      # 0xf228
leaq 0x76bd(%rip), %rsi      # 0xb716
xorl %eax, %eax
callq 0x1120
movl 0xb1e2(%rip), %edx      # 0xf248
testl %edx, %edx
je 0x407f
movq 0x1343f(%rip), %rdi     # 0x174b0
leaq 0x76aa(%rip), %rsi      # 0xb722
xorl %eax, %eax
callq 0x1120
cmpb $0x0, 0xb12b(%rip)      # 0xf1b1
je 0x4158
movl 0xb196(%rip), %eax      # 0xf228
movq 0x13417(%rip), %rcx     # 0x174b0
cmpl 0xb18d(%rip), %eax      # 0xf22c
jb 0x415f
leaq 0x7693(%rip), %rdi      # 0xb73f
movl $0x23, %esi
jmp 0x416b
cmpb $0x0, 0xb0f4(%rip)      # 0xf1b1
je 0x40c8
cmpl $0x2, 0xb162(%rip)      # 0xf228
ja 0x40df
cmpb $0x0, 0x17b19(%rip)     # 0x1bbe8
sete %al
testq %rbp, %rbp
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x40e6
movb $0x1, 0x17b03(%rip)     # 0x1bbe9
movq %rbp, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb 0xb0b6(%rip), %cl       # 0xf1b4
addb $-0x2, %cl
cmpb $0x2, %cl
ja 0x411a
testl %eax, %eax
sete %cl
incl %eax
cmpl %eax, %edx
setbe %al
orb %cl, %al
je 0x4031
movq 0xb0f7(%rip), %rax      # 0xf218
testq %rax, %rax
setne %cl
movq %rbp, %rsi
subq %rax, %rsi
cmpq $0x3, %rsi
setb %sil
andb %cl, %sil
cmpb $0x1, %sil
jne 0x4349
movb $0x0, 0x17a9f(%rip)     # 0x1bbe8
movb $0x1, 0x17a99(%rip)     # 0x1bbe9
movq %rax, %rbp
jmp 0x42d6
movq 0x13351(%rip), %rcx     # 0x174b0
leaq 0x75cd(%rip), %rdi      # 0xb733
movl $0xb, %esi
movl $0x1, %edx
callq 0x1180
xorpd %xmm0, %xmm0
xorl %eax, %eax
movdqa 0x72ad(%rip), %xmm1     # 0xb430
movdqa 0x72b5(%rip), %xmm2     # 0xb440
movdqa (%rax,%r15), %xmm3
pxor %xmm1, %xmm3
pcmpgtd %xmm2, %xmm3
packssdw %xmm3, %xmm3
packsswb %xmm3, %xmm3
psubb %xmm3, %xmm0
addq $0x10, %rax
cmpq $0x20, %rax
jne 0x418b
pxor %xmm1, %xmm1
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
psadbw %xmm1, %xmm0
movd %xmm0, %ebx
testb %bl, %bl
je 0x42d6
cmpb $0x0, 0xafea(%rip)      # 0xf1b8
je 0x4214
movq 0x132d9(%rip), %rcx     # 0x174b0
leaq 0x7585(%rip), %rdi      # 0xb763
movl $0x3e, %esi
movl $0x1, %edx
callq 0x1180
cmpb $0x1, %bl
je 0x4203
movq 0x132b7(%rip), %rsi     # 0x174b0
movl $0x73, %edi
callq 0x1100
movq 0x132a6(%rip), %rsi     # 0x174b0
movl $0x20, %edi
callq 0x1100
movq %r15, %rax
leaq 0x7501(%rip), %r12      # 0xb71f
xorl %r13d, %r13d
movq %rax, %r15
cmpl $0x2, (%rax)
jb 0x4283
cmpb $0x0, 0xaf88(%rip)      # 0xf1b8
je 0x4246
movq 0x13277(%rip), %rdi     # 0x174b0
movq %r12, %rsi
movl %r13d, %edx
xorl %eax, %eax
callq 0x1120
decb %bl
cmpb $0x0, 0xaf69(%rip)      # 0xf1b8
je 0x4283
movq 0x13258(%rip), %rcx     # 0x174b0
testb %bl, %bl
je 0x426b
movl $0x2c, %edi
movq %rcx, %rsi
callq 0x1100
jmp 0x4283
movl $0x2, %esi
movl $0x1, %edx
leaq 0x7947(%rip), %rdi      # 0xbbc3
callq 0x1180
xorl %ebx, %ebx
incq %r13
movq %r15, %rax
addq $0x4, %rax
cmpq $0x8, %r13
jne 0x4221
cmpb $0x0, 0xaf1e(%rip)      # 0xf1b8
je 0x42d6
movq 0x1320d(%rip), %rcx     # 0x174b0
leaq 0x74f8(%rip), %rdi      # 0xb7a2
movl $0x4f, %esi
movl $0x1, %edx
callq 0x1180
movq 0x131f0(%rip), %rcx     # 0x174b0
leaq 0x752b(%rip), %rdi      # 0xb7f2
movl $0x32, %esi
movl $0x1, %edx
callq 0x1180
movsd 0xaf42(%rip), %xmm0     # 0xf220
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x431a
jp 0x431a
cmpl $0x0, 0xaf57(%rip)      # 0xf248
jne 0x431a
movl %r14d, %eax
xorps %xmm0, %xmm0
cvtsi2ss %rax, %xmm0
divss 0xaeea(%rip), %xmm0     # 0xf1f0
mulss 0x70d6(%rip), %xmm0     # 0xb3e4
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0xaf06(%rip)     # 0xf220
cmpb $0x0, 0xae97(%rip)      # 0xf1b8
je 0x40e6
movq 0x13182(%rip), %rcx     # 0x174b0
leaq 0x7621(%rip), %rdi      # 0xb956
movl $0x52, %esi
movl $0x1, %edx
callq 0x1180
jmp 0x40e6
xorpd %xmm0, %xmm0
movapd %xmm0, 0x40(%rsp)
movapd %xmm0, 0x30(%rsp)
movb $0x0, 0x17889(%rip)     # 0x1bbe9
cmpb $0x0, 0xae51(%rip)      # 0xf1b8
je 0x4393
movq 0x13140(%rip), %rdi     # 0x174b0
movzbl 0xf(%rsp), %r9d
movl %ebx, %eax
xorb %r9b, %al
movzbl %al, %ecx
movl %r9d, (%rsp)
leaq 0x749c(%rip), %rsi      # 0xb825
movl %ecx, %r8d
xorl %eax, %eax
callq 0x1120
movl $0x7, %ecx
xorl %edx, %edx
xorl %eax, %eax
movl (%r15,%rcx,4), %edi
testl %edi, %edi
je 0x43c9
movl $0x1, %esi
shll %cl, %esi
movzbl %bl, %r8d
movzbl %sil, %r9d
cmpl %r8d, %r9d
ja 0x43c9
incl 0x30(%rsp,%rcx,4)
incb %al
cmpl $0x1, %edi
cmovnel %edx, %esi
xorb %bl, %sil
movl %esi, %ebx
subq $0x1, %rcx
setb %sil
testb %bl, %bl
je 0x43da
testb %sil, %sil
je 0x439c
cmpb $0x0, 0xadd7(%rip)      # 0xf1b8
je 0x42d6
movq 0x130c2(%rip), %rcx     # 0x174b0
testb %al, %al
je 0x4424
leaq 0x74c1(%rip), %rdi      # 0xb8ba
movl $0x2c, %esi
movl $0x1, %edx
callq 0x1180
movq 0x130a1(%rip), %rcx     # 0x174b0
testb %bl, %bl
je 0x4435
leaq 0x74fc(%rip), %rdi      # 0xb916
movl $0x3f, %esi
jmp 0x42cc
leaq 0x7440(%rip), %rdi      # 0xb86b
movl $0x4e, %esi
jmp 0x42cc
leaq 0x74ab(%rip), %rdi      # 0xb8e7
movl $0x2e, %esi
jmp 0x42cc
movabsq $0x676e6f6c206f6f, %rax # imm = 0x676E6F6C206F6F
movq %rax, 0x17290(%rip)     # 0x1b6e7
movabsq $0x6f742065736c7550, %rax # imm = 0x6F742065736C7550
movq %rax, 0x17278(%rip)     # 0x1b6e0
movl $0x8, %edi
callq 0x140c