// File: /workspace/github_c_makefile_star2_O2/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 0x846e(%rip)            # 0xf218
movb $0x1, %bl
movb %bl, 0x83f4(%rip)       # 0xf1a6
andq $0x0, 0x14e16(%rip)     # 0x1bbd0
callq 0x1618
movb %bl, 0x842b(%rip)       # 0xf1f0
pushq $0x30
popq %rdi
callq 0x3287
movl %eax, %ecx
cvtsi2sd %rcx, %xmm0
movsd %xmm0, 0x1494c(%rip)    # 0x1b728
testl %eax, %eax
je 0x72b6
movb $0x0, 0x8405(%rip)      # 0xf1f0
movabsq $0x40a3240000000000, %r14 # imm = 0x40A3240000000000
movq %r14, 0x1494c(%rip)     # 0x1b748
callq 0x2397
callq 0x16b7
movzbl 0x8463(%rip), %edi      # 0xf270
movq 0x83c4(%rip), %rsi      # 0xf1d8
xorl %edx, %edx
callq 0x10d0
andl $0x0, 0x854e(%rip)      # 0xf370
movl $0x100, %edi            # imm = 0x100
callq 0x2a7c
cmpb $0x0, 0x1487e(%rip)     # 0x1b6b1
je 0x72b6
callq 0x2dad
cmpb $0x0, 0x1486c(%rip)     # 0x1b6b1
je 0x72b6
cmpb $0x0, 0x14958(%rip)     # 0x1b7aa
je 0x6e22
callq 0x2397
callq 0x1618
leaq 0x3ba1(%rip), %rdi      # 0xaa06
xorl %eax, %eax
callq 0x10b0
callq 0x7338
movsd 0x148ef(%rip), %xmm1    # 0x1b768
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm1
jne 0x6e89
jnp 0x72b6
movsd 0x148f7(%rip), %xmm1    # 0x1b788
ucomisd %xmm0, %xmm1
jne 0x6e9d
jnp 0x72b6
callq 0x16b7
movzbl 0x83c7(%rip), %edi      # 0xf270
movq 0x8328(%rip), %rsi      # 0xf1d8
xorl %edx, %edx
callq 0x10d0
andl $0x0, 0x84b2(%rip)      # 0xf370
andq $0x0, 0x834a(%rip)      # 0xf210
movsd 0x148aa(%rip), %xmm0    # 0x1b778
movsd 0x148c2(%rip), %xmm1    # 0x1b798
xorl %edi, %edi
callq 0x374a
movq %rax, %rbx
cmpb $0x0, 0x147ca(%rip)     # 0x1b6b1
je 0x6f33
callq 0x4167
testq %rax, %rax
js 0x6efa
cvtsi2ss %rax, %xmm0
jmp 0x6f0f
movq %rax, %rcx
shrq %rcx
andl $0x1, %eax
orq %rcx, %rax
cvtsi2ss %rax, %xmm0
addss %xmm0, %xmm0
divss 0x82c9(%rip), %xmm0     # 0xf1e0
mulss 0x34c5(%rip), %xmm0     # 0xa3e4
cvtss2sd %xmm0, %xmm0
addsd 0x82e5(%rip), %xmm0     # 0xf210
movsd %xmm0, 0x82dd(%rip)     # 0xf210
movsd 0x147ed(%rip), %xmm3    # 0x1b728
movsd 0x3405(%rip), %xmm0     # 0xa348
addsd %xmm3, %xmm0
andpd 0x34b1(%rip), %xmm0     # 0xa400
movsd 0x33f9(%rip), %xmm1     # 0xa350
ucomisd %xmm0, %xmm1
movsd 0x14825(%rip), %xmm0    # 0x1b788
jbe 0x7007
movsd 0x3337(%rip), %xmm2     # 0xa2a8
divsd %xmm3, %xmm2
movabsq $0x4089400000000000, %rax # imm = 0x4089400000000000
movsd 0x14c49(%rip), %xmm3    # 0x1bbd0
unpcklps 0x3482(%rip), %xmm3     # xmm3 = xmm3[0],mem[0],xmm3[1],mem[1]
subpd 0x348a(%rip), %xmm3     # 0xa420
movq %rax, 0x1478b(%rip)     # 0x1b728
movapd %xmm3, %xmm4
unpckhpd %xmm3, %xmm4            # xmm4 = xmm4[1],xmm3[1]
addsd %xmm3, %xmm4
divsd %xmm2, %xmm4
cvttsd2si %xmm4, %rax
movq %rax, %rcx
subsd 0x334b(%rip), %xmm4     # 0xa308
cvttsd2si %xmm4, %rdx
sarq $0x3f, %rcx
andq %rcx, %rdx
orq %rax, %rdx
movq %rdx, 0x14bfd(%rip)     # 0x1bbd0
movsd 0x8235(%rip), %xmm3     # 0xf210
divsd %xmm2, %xmm3
movsd %xmm3, 0x8229(%rip)     # 0xf210
movsd 0x14779(%rip), %xmm3    # 0x1b768
mulsd %xmm2, %xmm3
movsd %xmm3, 0x1476d(%rip)    # 0x1b768
mulsd %xmm2, %xmm0
movsd %xmm0, 0x14781(%rip)    # 0x1b788
movsd 0x3349(%rip), %xmm2     # 0xa358
addsd %xmm0, %xmm2
andpd 0x33e5(%rip), %xmm2     # 0xa400
ucomisd %xmm2, %xmm1
jae 0x70ab
movsd 0x3333(%rip), %xmm1     # 0xa360
addsd %xmm0, %xmm1
andpd 0x33c7(%rip), %xmm1     # 0xa400
movb $0xe, 0x14ba0(%rip)     # 0x1bbe0
movsd 0x3320(%rip), %xmm2     # 0xa368
ucomisd %xmm1, %xmm2
jae 0x70d6
cmpb $0x0, 0x8149(%rip)      # 0xf1a2
jne 0x70f0
movsd 0x3309(%rip), %xmm1     # 0xa370
addsd %xmm0, %xmm1
andpd 0x338d(%rip), %xmm1     # 0xa400
movsd 0x326d(%rip), %xmm2     # 0xa2e8
ucomisd %xmm1, %xmm2
jae 0x70f0
cmpb $0x0, 0x811c(%rip)      # 0xf1a4
je 0x72c5
movabsq $0x4097700000000000, %rax # imm = 0x4097700000000000
movq %rax, 0x146e9(%rip)     # 0x1b788
movabsq $0x40a7700000000000, %rax # imm = 0x40A7700000000000
jmp 0x710b
movabsq $0x408ff00000000000, %rax # imm = 0x408FF00000000000
movq %rax, 0x146cc(%rip)     # 0x1b788
movabsq $0x409ff00000000000, %rax # imm = 0x409FF00000000000
movq %rax, 0x1469b(%rip)     # 0x1b768
movb $0x0, 0x80d2(%rip)      # 0xf1a6
jmp 0x7112
movabsq $0x4093240000000000, %rax # imm = 0x4093240000000000
movq %rax, 0x146a1(%rip)     # 0x1b788
movq %r14, 0x1467a(%rip)     # 0x1b768
jmp 0x7112
movabsq $0x4094500000000000, %rax # imm = 0x4094500000000000
movq %rax, 0x14687(%rip)     # 0x1b788
movabsq $0x40a4500000000000, %rax # imm = 0x40A4500000000000
movq %rax, 0x14656(%rip)     # 0x1b768
callq 0x2397
cmpq $0x13, %rbx
jne 0x717f
movq 0x80b4(%rip), %r15      # 0xf1d8
callq 0x15e9
leaq 0x10378(%rip), %rdi     # 0x174a8
callq 0x1d32
testb %al, %al
jne 0x722f
leaq 0x10364(%rip), %r14     # 0x174a8
movq %r14, %rdi
callq 0x1d32
movb %al, 0x14a8e(%rip)      # 0x1bbe0
pushq $0x1
popq %r12
leaq 0x14a83(%rip), %r13     # 0x1bbe0
pushq $0x2a
popq %rbp
cmpq $0xb, %r12
je 0x71a4
movq %r14, %rdi
callq 0x1d32
cmpb $0x20, %al
movzbl %al, %eax
cmovll %ebp, %eax
movb %al, (%r12,%r13)
incq %r12
jmp 0x7160
movb 0x14a5b(%rip), %al      # 0x1bbe0
cmpb $0x4, %al
jb 0x7198
andl $0x0, 0x14a60(%rip)     # 0x1bbf0
cmpb $0xe, %al
je 0x7236
movb $0xf, 0x14a41(%rip)     # 0x1bbe0
jmp 0x7236
movb $0x0, 0x14a40(%rip)     # 0x1bbeb
leaq 0x102f6(%rip), %r14     # 0x174a8
movq %r14, %rdi
callq 0x1d32
movzbl %al, %eax
movl %eax, 0x14a29(%rip)     # 0x1bbec
movq %r14, %rdi
callq 0x1d32
movzbl %al, %eax
shll $0x8, %eax
addl %eax, 0x14a15(%rip)     # 0x1bbec
movq %r14, %rdi
callq 0x1d32
movzbl %al, %eax
movl %eax, 0x14a08(%rip)     # 0x1bbf0
movq %r14, %rdi
callq 0x1d32
movzbl %al, %eax
shll $0x8, %eax
addl 0x149f4(%rip), %eax     # 0x1bbf0
movl %eax, 0x149ee(%rip)     # 0x1bbf0
movl 0x149e4(%rip), %ecx     # 0x1bbec
addl $0x2, %ecx
movl %ecx, 0x7ff3(%rip)      # 0xf204
cmpb $0x0, 0x149c8(%rip)     # 0x1bbe0
jne 0x7229
movl $0x5ccb, 0x149cc(%rip)  # imm = 0x5CCB
movl $0x5ccb, %eax           # imm = 0x5CCB
movl %eax, 0x7fd1(%rip)      # 0xf200
movq %r15, 0x7fa2(%rip)      # 0xf1d8
movl 0x149b4(%rip), %edi     # 0x1bbf0
movq %rbx, %rsi
callq 0x4a02
movsd 0x144dc(%rip), %xmm0    # 0x1b728
ucomisd 0x3054(%rip), %xmm0     # 0xa2a8
jne 0x729d
jp 0x729d
movsd 0x144e8(%rip), %xmm0    # 0x1b748
ucomisd 0x3130(%rip), %xmm0     # 0xa398
jne 0x729d
jp 0x729d
movsd 0x144f4(%rip), %xmm0    # 0x1b768
ucomisd 0x3124(%rip), %xmm0     # 0xa3a0
jne 0x729d
jp 0x729d
movsd 0x14500(%rip), %xmm0    # 0x1b788
ucomisd 0x3118(%rip), %xmm0     # 0xa3a8
jne 0x729d
jp 0x729d
movl %ebx, %edi
callq 0x76f2
jmp 0x72af
movq 0x1492c(%rip), %rdi     # 0x1bbd0
pushq $0x8
popq %rsi
movq %rbx, %rdx
callq 0x5303
movb $0x0, 0x7ef0(%rip)      # 0xf1a6
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpb $0x0, 0x7ed5(%rip)      # 0xf1a1
je 0x72ee
movabsq $0x4098380000000000, %rax # imm = 0x4098380000000000
movq %rax, 0x144a9(%rip)     # 0x1b788
movabsq $0x40a8380000000000, %rax # imm = 0x40A8380000000000
jmp 0x710b
movsd 0x3082(%rip), %xmm1     # 0xa378
addsd %xmm0, %xmm1
andpd 0x30fe(%rip), %xmm1     # 0xa400
movsd 0x3076(%rip), %xmm2     # 0xa380
ucomisd %xmm1, %xmm2
ja 0x708e
addsd 0x306c(%rip), %xmm0     # 0xa388
andpd 0x30dc(%rip), %xmm0     # 0xa400
movsd 0x3064(%rip), %xmm1     # 0xa390
ucomisd %xmm0, %xmm1
jbe 0x7112
jmp 0x72ce