// File: /workspace/github_c_makefile_star2_O1/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 0x7c44(%rip)            # 0xf228
movb $0x1, %bl
movb %bl, 0x7bca(%rip)       # 0xf1b6
movq $0x0, 0x145e9(%rip) # 0x1bbe0
callq 0x165a
movb %bl, 0x7bfe(%rip)       # 0xf200
movl $0x30, %edi
callq 0x345d
movl %eax, %ecx
cvtsi2sd %rcx, %xmm0
movsd %xmm0, 0x1411d(%rip)    # 0x1b738
testl %eax, %eax
je 0x7b0c
movb $0x0, 0x7bd6(%rip)      # 0xf200
movabsq $0x40a3240000000000, %r14 # imm = 0x40A3240000000000
movq %r14, 0x1411d(%rip)     # 0x1b758
callq 0x2424
callq 0x16fb
movzbl 0x7c34(%rip), %edi      # 0xf280
movq 0x7b95(%rip), %rsi      # 0xf1e8
xorl %edx, %edx
callq 0x10d0
movl $0x0, 0x7d1c(%rip)      # 0xf380
movl $0x100, %edi            # imm = 0x100
callq 0x2bfc
cmpb $0x0, 0x1404c(%rip)     # 0x1b6c1
je 0x7b0c
callq 0x2f5c
cmpb $0x0, 0x1403a(%rip)     # 0x1b6c1
je 0x7b0c
cmpb $0x0, 0x14126(%rip)     # 0x1b7ba
je 0x7664
callq 0x2424
callq 0x165a
leaq 0x43bf(%rip), %rdi      # 0xba66
xorl %eax, %eax
callq 0x10b0
callq 0x7b93
movsd 0x140bd(%rip), %xmm1    # 0x1b778
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm1
jne 0x76cb
jnp 0x7b0c
movsd 0x140c5(%rip), %xmm1    # 0x1b798
ucomisd %xmm0, %xmm1
jne 0x76df
jnp 0x7b0c
callq 0x16fb
movzbl 0x7b95(%rip), %edi      # 0xf280
movq 0x7af6(%rip), %rsi      # 0xf1e8
xorl %edx, %edx
callq 0x10d0
movl $0x0, 0x7c7d(%rip)      # 0xf380
movq $0x0, 0x7b12(%rip) # 0xf220
movsd 0x14072(%rip), %xmm0    # 0x1b788
movsd 0x1408a(%rip), %xmm1    # 0x1b7a8
xorl %edi, %edi
callq 0x39c9
movq %rax, %rbx
cmpb $0x0, 0x13f92(%rip)     # 0x1b6c1
je 0x7781
callq 0x4488
testq %rax, %rax
js 0x7745
xorps %xmm0, %xmm0
cvtsi2ss %rax, %xmm0
jmp 0x775d
movq %rax, %rcx
shrq %rcx
andl $0x1, %eax
orq %rcx, %rax
xorps %xmm0, %xmm0
cvtsi2ss %rax, %xmm0
addss %xmm0, %xmm0
divss 0x7a8b(%rip), %xmm0     # 0xf1f0
mulss 0x3c77(%rip), %xmm0     # 0xb3e4
cvtss2sd %xmm0, %xmm0
addsd 0x7aa7(%rip), %xmm0     # 0xf220
movsd %xmm0, 0x7a9f(%rip)     # 0xf220
movsd 0x13faf(%rip), %xmm2    # 0x1b738
movsd 0x3bb7(%rip), %xmm0     # 0xb348
addsd %xmm2, %xmm0
andpd 0x3c63(%rip), %xmm0     # 0xb400
movsd 0x3bab(%rip), %xmm1     # 0xb350
ucomisd %xmm0, %xmm1
jbe 0x7851
movsd 0x3af1(%rip), %xmm0     # 0xb2a8
divsd %xmm2, %xmm0
movabsq $0x4089400000000000, %rax # imm = 0x4089400000000000
movq %rax, 0x13f6c(%rip)     # 0x1b738
movsd 0x1440c(%rip), %xmm2    # 0x1bbe0
unpcklps 0x3c35(%rip), %xmm2     # xmm2 = xmm2[0],mem[0],xmm2[1],mem[1]
subpd 0x3c3d(%rip), %xmm2     # 0xb420
movapd %xmm2, %xmm3
unpckhpd %xmm2, %xmm3            # xmm3 = xmm3[1],xmm2[1]
addsd %xmm2, %xmm3
divsd %xmm0, %xmm3
cvttsd2si %xmm3, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
subsd 0x3b01(%rip), %xmm3     # 0xb308
cvttsd2si %xmm3, %rdx
andq %rcx, %rdx
orq %rax, %rdx
movq %rdx, 0x143c7(%rip)     # 0x1bbe0
movsd 0x79ff(%rip), %xmm2     # 0xf220
divsd %xmm0, %xmm2
movsd %xmm2, 0x79f3(%rip)     # 0xf220
movsd 0x13f43(%rip), %xmm2    # 0x1b778
mulsd %xmm0, %xmm2
movsd %xmm2, 0x13f37(%rip)    # 0x1b778
mulsd 0x13f4f(%rip), %xmm0    # 0x1b798
movsd %xmm0, 0x13f47(%rip)    # 0x1b798
movsd 0x13f3f(%rip), %xmm0    # 0x1b798
movsd 0x3af7(%rip), %xmm2     # 0xb358
addsd %xmm0, %xmm2
andpd 0x3b93(%rip), %xmm2     # 0xb400
ucomisd %xmm2, %xmm1
jae 0x78fd
movsd 0x3ae1(%rip), %xmm1     # 0xb360
addsd %xmm0, %xmm1
andpd 0x3b75(%rip), %xmm1     # 0xb400
movb $0xe, 0x1435e(%rip)     # 0x1bbf0
movsd 0x3ace(%rip), %xmm2     # 0xb368
ucomisd %xmm1, %xmm2
jae 0x7928
cmpb $0x0, 0x7907(%rip)      # 0xf1b2
jne 0x7942
movsd 0x3ab7(%rip), %xmm1     # 0xb370
addsd %xmm0, %xmm1
andpd 0x3b3b(%rip), %xmm1     # 0xb400
movsd 0x3a1b(%rip), %xmm2     # 0xb2e8
ucomisd %xmm1, %xmm2
jae 0x7942
cmpb $0x0, 0x78da(%rip)      # 0xf1b4
je 0x7b1b
movabsq $0x4097700000000000, %rax # imm = 0x4097700000000000
movq %rax, 0x13ea7(%rip)     # 0x1b798
movabsq $0x40a7700000000000, %rax # imm = 0x40A7700000000000
jmp 0x795d
movabsq $0x408ff00000000000, %rax # imm = 0x408FF00000000000
movq %rax, 0x13e8a(%rip)     # 0x1b798
movabsq $0x409ff00000000000, %rax # imm = 0x409FF00000000000
movq %rax, 0x13e59(%rip)     # 0x1b778
movb $0x0, 0x7890(%rip)      # 0xf1b6
jmp 0x7964
movabsq $0x4093240000000000, %rax # imm = 0x4093240000000000
movq %rax, 0x13e5f(%rip)     # 0x1b798
movq %r14, 0x13e38(%rip)     # 0x1b778
jmp 0x7964
movabsq $0x4094500000000000, %rax # imm = 0x4094500000000000
movq %rax, 0x13e45(%rip)     # 0x1b798
movabsq $0x40a4500000000000, %rax # imm = 0x40A4500000000000
movq %rax, 0x13e14(%rip)     # 0x1b778
callq 0x2424
cmpq $0x13, %rbx
jne 0x7a6b
movq 0x786e(%rip), %r15      # 0xf1e8
callq 0x161f
leaq 0xfb32(%rip), %rdi      # 0x174b8
callq 0x1db5
testb %al, %al
jne 0x7a62
leaq 0xfb1e(%rip), %r14      # 0x174b8
movq %r14, %rdi
callq 0x1db5
movb %al, 0x14248(%rip)      # 0x1bbf0
movl $0x1, %r12d
leaq 0x1423b(%rip), %r13     # 0x1bbf0
movl $0x2a, %ebp
movq %r14, %rdi
callq 0x1db5
cmpb $0x20, %al
movzbl %al, %eax
cmovll %ebp, %eax
movb %al, (%r12,%r13)
incq %r12
cmpq $0xb, %r12
jne 0x79ba
movb $0x0, 0x1421d(%rip)     # 0x1bbfb
leaq 0xfad3(%rip), %r14      # 0x174b8
movq %r14, %rdi
callq 0x1db5
movzbl %al, %eax
movl %eax, 0x14206(%rip)     # 0x1bbfc
movq %r14, %rdi
callq 0x1db5
movzbl %al, %eax
shll $0x8, %eax
addl %eax, 0x141f2(%rip)     # 0x1bbfc
movq %r14, %rdi
callq 0x1db5
movzbl %al, %eax
movl %eax, 0x141e5(%rip)     # 0x1bc00
movq %r14, %rdi
callq 0x1db5
movzbl %al, %eax
shll $0x8, %eax
addl 0x141d1(%rip), %eax     # 0x1bc00
movl %eax, 0x141cb(%rip)     # 0x1bc00
movl 0x141c1(%rip), %ecx     # 0x1bbfc
addl $0x2, %ecx
movl %ecx, 0x77d0(%rip)      # 0xf214
cmpb $0x0, 0x141a5(%rip)     # 0x1bbf0
jne 0x7a5c
movl $0x5ccb, 0x141a9(%rip)  # imm = 0x5CCB
movl $0x5ccb, %eax           # imm = 0x5CCB
movl %eax, 0x77ae(%rip)      # 0xf210
movq %r15, 0x777f(%rip)      # 0xf1e8
jmp 0x7a8a
movb 0x1417f(%rip), %al      # 0x1bbf0
cmpb $0x4, %al
jb 0x7a7f
movl $0x0, 0x14181(%rip)     # 0x1bc00
cmpb $0xe, %al
je 0x7a8a
movb $0xf, 0x14166(%rip)     # 0x1bbf0
movl 0x14170(%rip), %edi     # 0x1bc00
movq %rbx, %rsi
callq 0x4e25
movsd 0x13c98(%rip), %xmm0    # 0x1b738
ucomisd 0x3800(%rip), %xmm0     # 0xb2a8
jne 0x7af1
jp 0x7af1
movsd 0x13ca4(%rip), %xmm0    # 0x1b758
ucomisd 0x38dc(%rip), %xmm0     # 0xb398
jne 0x7af1
jp 0x7af1
movsd 0x13cb0(%rip), %xmm0    # 0x1b778
ucomisd 0x38d0(%rip), %xmm0     # 0xb3a0
jne 0x7af1
jp 0x7af1
movsd 0x13cbc(%rip), %xmm0    # 0x1b798
ucomisd 0x38c4(%rip), %xmm0     # 0xb3a8
jne 0x7af1
jp 0x7af1
movl %ebx, %edi
callq 0x7f57
jmp 0x7b05
movq 0x140e8(%rip), %rdi     # 0x1bbe0
movl $0x8, %esi
movq %rbx, %rdx
callq 0x5778
movb $0x0, 0x76aa(%rip)      # 0xf1b6
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb 0x7690(%rip), %al       # 0xf1b1
testb %al, %al
je 0x7b45
movabsq $0x4098380000000000, %rax # imm = 0x4098380000000000
movq %rax, 0x13c62(%rip)     # 0x1b798
movabsq $0x40a8380000000000, %rax # imm = 0x40A8380000000000
jmp 0x795d
movsd 0x382b(%rip), %xmm1     # 0xb378
addsd %xmm0, %xmm1
andpd 0x38a7(%rip), %xmm1     # 0xb400
movsd 0x381f(%rip), %xmm2     # 0xb380
ucomisd %xmm1, %xmm2
ja 0x78e0
testb %al, %al
jne 0x7b25
addsd 0x3811(%rip), %xmm0     # 0xb388
andpd 0x3881(%rip), %xmm0     # 0xb400
movsd 0x3809(%rip), %xmm1     # 0xb390
ucomisd %xmm0, %xmm1
jbe 0x7964
jmp 0x7b25