// File: /workspace/github_c_makefile_star2_O3/mincebert[P]maketzx/maketzx.c
// Function: RawRead
void RawRead(void)
{
   dword bytes;
   blocks++;
   raw=1;
//   header.type=0x0e;
   pilotlength=0;
   PushFilePointers();
   tonesearch=1;
   pilot.freq=BeepSearch(48);
   if (!pilot.freq) return;
   tonesearch=0;
   syncx.freq=2450;
   SetTimings();
   PopFilePointers();
   lseek(inpfile.handle,filepos,SEEK_SET);
   inpfile.bufpoint=0;
   do {
	PilotSearch(256);
	if (!blocktype) return;
	SyncSearch();
	if (!blocktype) return;
      }
   while (!SyncLoadOK);
   if (!SyncLoadOK && lastpulse) syncx.freq=samprate/(2*lastpulse); SetTimings();
   PushFilePointers();
   printf("Analysing pulses...            \xd");
   SearchDataFrequencies();
   if (!bit0.freq || !bit1.freq) return;
   PopFilePointers();
   lseek(inpfile.handle,filepos,SEEK_SET);
   inpfile.bufpoint=0;
   mspause=0;
   bytes=DataRead(bit0.samples,bit1.samples,0);
   if (blocktype) mspause+=(FindPause()/samprate)*1000;
   if (fabs(pilot.freq-810)<60)
      {
	double ratio=(808/pilot.freq);
	pilot.freq=808; pilotlength/=ratio; mspause/=ratio;
	bit0.freq*=ratio; bit1.freq*=ratio;
      }
   if (fabs(bit1.freq-1022)<=60)
      {
	bit0.freq=2*(bit1.freq=1022);
	raw=0;
      }
   else {
	  header.type=0x0e;
	  if (fabs(bit1.freq-1225)<=70) { bit0.freq=2*(bit1.freq=1225); }
	  else if (soft || fabs(bit1.freq-1300)<=50) { bit0.freq=2*(bit1.freq=1300); }
	     //else if (abs(bit1.freq-1400)<50) { bit0.freq=2*(bit1.freq=1400); SetTimings(); }
	       else if (slocktype || (!alk && fabs(bit1.freq-1480)<55)) { bit0.freq=2*(bit1.freq=1500); }
		    else if (alk || (!slocktype && fabs(bit1.freq-1550)<15)) { bit0.freq=2*(bit1.freq=1550); }
	}
   SetTimings();
   if (bytes==19)
      {
	byte count;
	dword savefilepos=filepos;
	ResetTempFile();
	if (GetData(&tempfile)==0)
	   {
	     header.type=GetData(&tempfile);
	     for (count=0; count<10; count++)
		 {
		   header.name[count]=GetData(&tempfile);
		   if (header.name[count]<' ') header.name[count]='*';
		 }
	     header.name[10]=0;
	     header.length=(byte)(GetData(&tempfile));
	     header.length+=(word)(256*GetData(&tempfile));
	     header.start=(byte)(GetData(&tempfile));
	     header.start+=(word)(256*GetData(&tempfile));
	     expectedlength=(header.length)+2;
	     if (header.type==0) nxtloadpos=header.start=23755;
	     else nxtloadpos=header.start;
	   }
	filepos=savefilepos;
      }
   else {
	  if (header.type>3) header.start=0;
	  if (header.type!=0xe) header.type=0xf;
	}

   PrintBlockInfo(header.start,bytes);
   if (pilot.freq==808 && syncx.freq==2450 && bit0.freq==2044 && bit1.freq==1022) WriteTZXNormalBlock(bytes);
   else WriteTZXTurboBlock(pilotlength,8,bytes);
   raw=0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
incl 0x7d25(%rip)            # 0xf228
movb $0x1, %bl
movb %bl, 0x7cab(%rip)       # 0xf1b6
movq $0x0, 0x146ca(%rip) # 0x1bbe0
callq 0x1659
movb %bl, 0x7cdf(%rip)       # 0xf200
movl $0x30, %edi
callq 0x33d9
movl %eax, %ecx
cvtsi2sd %rcx, %xmm0
movsd %xmm0, 0x141fe(%rip)    # 0x1b738
testl %eax, %eax
je 0x7a27
movb $0x0, 0x7cb7(%rip)      # 0xf200
movabsq $0x40a3240000000000, %r14 # imm = 0x40A3240000000000
movq %r14, 0x141fe(%rip)     # 0x1b758
callq 0x240d
callq 0x16fa
movzbl 0x7d15(%rip), %edi      # 0xf280
movq 0x7c76(%rip), %rsi      # 0xf1e8
xorl %edx, %edx
callq 0x10d0
movl $0x0, 0x7dfd(%rip)      # 0xf380
movl $0x100, %edi            # imm = 0x100
callq 0x2ba3
cmpb $0x0, 0x1412d(%rip)     # 0x1b6c1
je 0x7a27
callq 0x2edd
cmpb $0x0, 0x1411b(%rip)     # 0x1b6c1
je 0x7a27
cmpb $0x0, 0x14207(%rip)     # 0x1b7ba
je 0x7583
callq 0x240d
callq 0x1659
leaq 0x44a0(%rip), %rdi      # 0xba66
xorl %eax, %eax
callq 0x10b0
callq 0x7aa9
movsd 0x1419e(%rip), %xmm1    # 0x1b778
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm1
jne 0x75ea
jnp 0x7a27
movsd 0x141a6(%rip), %xmm1    # 0x1b798
ucomisd %xmm0, %xmm1
jne 0x75fe
jnp 0x7a27
callq 0x16fa
movzbl 0x7c76(%rip), %edi      # 0xf280
movq 0x7bd7(%rip), %rsi      # 0xf1e8
xorl %edx, %edx
callq 0x10d0
movl $0x0, 0x7d5e(%rip)      # 0xf380
movq $0x0, 0x7bf3(%rip) # 0xf220
movsd 0x14153(%rip), %xmm0    # 0x1b788
movsd 0x1416b(%rip), %xmm1    # 0x1b7a8
xorl %edi, %edi
callq 0x38de
movq %rax, %rbx
cmpb $0x0, 0x14073(%rip)     # 0x1b6c1
je 0x76a0
callq 0x43aa
testq %rax, %rax
js 0x7664
xorps %xmm0, %xmm0
cvtsi2ss %rax, %xmm0
jmp 0x767c
movq %rax, %rcx
shrq %rcx
andl $0x1, %eax
orq %rcx, %rax
xorps %xmm0, %xmm0
cvtsi2ss %rax, %xmm0
addss %xmm0, %xmm0
divss 0x7b6c(%rip), %xmm0     # 0xf1f0
mulss 0x3d58(%rip), %xmm0     # 0xb3e4
cvtss2sd %xmm0, %xmm0
addsd 0x7b88(%rip), %xmm0     # 0xf220
movsd %xmm0, 0x7b80(%rip)     # 0xf220
movsd 0x14090(%rip), %xmm3    # 0x1b738
movsd 0x3c98(%rip), %xmm0     # 0xb348
addsd %xmm3, %xmm0
andpd 0x3d44(%rip), %xmm0     # 0xb400
movsd 0x3c8c(%rip), %xmm1     # 0xb350
ucomisd %xmm0, %xmm1
movsd 0x140c8(%rip), %xmm0    # 0x1b798
jbe 0x7774
movsd 0x3bca(%rip), %xmm2     # 0xb2a8
divsd %xmm3, %xmm2
movabsq $0x4089400000000000, %rax # imm = 0x4089400000000000
movsd 0x144ec(%rip), %xmm3    # 0x1bbe0
unpcklps 0x3d15(%rip), %xmm3     # xmm3 = xmm3[0],mem[0],xmm3[1],mem[1]
subpd 0x3d1d(%rip), %xmm3     # 0xb420
movq %rax, 0x1402e(%rip)     # 0x1b738
movapd %xmm3, %xmm4
unpckhpd %xmm3, %xmm4            # xmm4 = xmm4[1],xmm3[1]
addsd %xmm3, %xmm4
divsd %xmm2, %xmm4
cvttsd2si %xmm4, %rax
movq %rax, %rcx
subsd 0x3bde(%rip), %xmm4     # 0xb308
cvttsd2si %xmm4, %rdx
sarq $0x3f, %rcx
andq %rcx, %rdx
orq %rax, %rdx
movq %rdx, 0x144a0(%rip)     # 0x1bbe0
movsd 0x7ad8(%rip), %xmm3     # 0xf220
divsd %xmm2, %xmm3
movsd %xmm3, 0x7acc(%rip)     # 0xf220
movsd 0x1401c(%rip), %xmm3    # 0x1b778
mulsd %xmm2, %xmm3
movsd %xmm3, 0x14010(%rip)    # 0x1b778
mulsd %xmm2, %xmm0
movsd %xmm0, 0x14024(%rip)    # 0x1b798
movsd 0x3bdc(%rip), %xmm2     # 0xb358
addsd %xmm0, %xmm2
andpd 0x3c78(%rip), %xmm2     # 0xb400
ucomisd %xmm2, %xmm1
jae 0x7818
movsd 0x3bc6(%rip), %xmm1     # 0xb360
addsd %xmm0, %xmm1
andpd 0x3c5a(%rip), %xmm1     # 0xb400
movb $0xe, 0x14443(%rip)     # 0x1bbf0
movsd 0x3bb3(%rip), %xmm2     # 0xb368
ucomisd %xmm1, %xmm2
jae 0x7843
cmpb $0x0, 0x79ec(%rip)      # 0xf1b2
jne 0x785d
movsd 0x3b9c(%rip), %xmm1     # 0xb370
addsd %xmm0, %xmm1
andpd 0x3c20(%rip), %xmm1     # 0xb400
movsd 0x3b00(%rip), %xmm2     # 0xb2e8
ucomisd %xmm1, %xmm2
jae 0x785d
cmpb $0x0, 0x79bf(%rip)      # 0xf1b4
je 0x7a36
movabsq $0x4097700000000000, %rax # imm = 0x4097700000000000
movq %rax, 0x13f8c(%rip)     # 0x1b798
movabsq $0x40a7700000000000, %rax # imm = 0x40A7700000000000
jmp 0x7878
movabsq $0x408ff00000000000, %rax # imm = 0x408FF00000000000
movq %rax, 0x13f6f(%rip)     # 0x1b798
movabsq $0x409ff00000000000, %rax # imm = 0x409FF00000000000
movq %rax, 0x13f3e(%rip)     # 0x1b778
movb $0x0, 0x7975(%rip)      # 0xf1b6
jmp 0x787f
movabsq $0x4093240000000000, %rax # imm = 0x4093240000000000
movq %rax, 0x13f44(%rip)     # 0x1b798
movq %r14, 0x13f1d(%rip)     # 0x1b778
jmp 0x787f
movabsq $0x4094500000000000, %rax # imm = 0x4094500000000000
movq %rax, 0x13f2a(%rip)     # 0x1b798
movabsq $0x40a4500000000000, %rax # imm = 0x40A4500000000000
movq %rax, 0x13ef9(%rip)     # 0x1b778
callq 0x240d
cmpq $0x13, %rbx
jne 0x7986
movq 0x7953(%rip), %r15      # 0xf1e8
callq 0x161e
leaq 0xfc17(%rip), %rdi      # 0x174b8
callq 0x1d8c
testb %al, %al
jne 0x797d
leaq 0xfc03(%rip), %r14      # 0x174b8
movq %r14, %rdi
callq 0x1d8c
movb %al, 0x1432d(%rip)      # 0x1bbf0
movl $0x1, %r12d
leaq 0x14320(%rip), %r13     # 0x1bbf0
movl $0x2a, %ebp
movq %r14, %rdi
callq 0x1d8c
cmpb $0x20, %al
movzbl %al, %eax
cmovll %ebp, %eax
movb %al, (%r12,%r13)
incq %r12
cmpq $0xb, %r12
jne 0x78d5
movb $0x0, 0x14302(%rip)     # 0x1bbfb
leaq 0xfbb8(%rip), %r14      # 0x174b8
movq %r14, %rdi
callq 0x1d8c
movzbl %al, %eax
movl %eax, 0x142eb(%rip)     # 0x1bbfc
movq %r14, %rdi
callq 0x1d8c
movzbl %al, %eax
shll $0x8, %eax
addl %eax, 0x142d7(%rip)     # 0x1bbfc
movq %r14, %rdi
callq 0x1d8c
movzbl %al, %eax
movl %eax, 0x142ca(%rip)     # 0x1bc00
movq %r14, %rdi
callq 0x1d8c
movzbl %al, %eax
shll $0x8, %eax
addl 0x142b6(%rip), %eax     # 0x1bc00
movl %eax, 0x142b0(%rip)     # 0x1bc00
movl 0x142a6(%rip), %ecx     # 0x1bbfc
addl $0x2, %ecx
movl %ecx, 0x78b5(%rip)      # 0xf214
cmpb $0x0, 0x1428a(%rip)     # 0x1bbf0
jne 0x7977
movl $0x5ccb, 0x1428e(%rip)  # imm = 0x5CCB
movl $0x5ccb, %eax           # imm = 0x5CCB
movl %eax, 0x7893(%rip)      # 0xf210
movq %r15, 0x7864(%rip)      # 0xf1e8
jmp 0x79a5
movb 0x14264(%rip), %al      # 0x1bbf0
cmpb $0x4, %al
jb 0x799e
movl $0x0, 0x14266(%rip)     # 0x1bc00
cmpb $0xe, %al
je 0x79a5
movb $0xf, 0x1424b(%rip)     # 0x1bbf0
movl 0x14255(%rip), %edi     # 0x1bc00
movq %rbx, %rsi
callq 0x4d24
movsd 0x13d7d(%rip), %xmm0    # 0x1b738
ucomisd 0x38e5(%rip), %xmm0     # 0xb2a8
jne 0x7a0c
jp 0x7a0c
movsd 0x13d89(%rip), %xmm0    # 0x1b758
ucomisd 0x39c1(%rip), %xmm0     # 0xb398
jne 0x7a0c
jp 0x7a0c
movsd 0x13d95(%rip), %xmm0    # 0x1b778
ucomisd 0x39b5(%rip), %xmm0     # 0xb3a0
jne 0x7a0c
jp 0x7a0c
movsd 0x13da1(%rip), %xmm0    # 0x1b798
ucomisd 0x39a9(%rip), %xmm0     # 0xb3a8
jne 0x7a0c
jp 0x7a0c
movl %ebx, %edi
callq 0x7e7b
jmp 0x7a20
movq 0x141cd(%rip), %rdi     # 0x1bbe0
movl $0x8, %esi
movq %rbx, %rdx
callq 0x56ac
movb $0x0, 0x778f(%rip)      # 0xf1b6
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpb $0x0, 0x7774(%rip)      # 0xf1b1
je 0x7a5f
movabsq $0x4098380000000000, %rax # imm = 0x4098380000000000
movq %rax, 0x13d48(%rip)     # 0x1b798
movabsq $0x40a8380000000000, %rax # imm = 0x40A8380000000000
jmp 0x7878
movsd 0x3911(%rip), %xmm1     # 0xb378
addsd %xmm0, %xmm1
andpd 0x398d(%rip), %xmm1     # 0xb400
movsd 0x3905(%rip), %xmm2     # 0xb380
ucomisd %xmm1, %xmm2
ja 0x77fb
addsd 0x38fb(%rip), %xmm0     # 0xb388
andpd 0x396b(%rip), %xmm0     # 0xb400
movsd 0x38f3(%rip), %xmm1     # 0xb390
ucomisd %xmm0, %xmm1
jbe 0x787f
jmp 0x7a3f