// File: /workspace/github_c_makefile_star2_O0/mincebert[P]maketzx/maketzx.c
// Function: PilotSearch
dword PilotSearch(word pulses)
{
  byte tolerance=pilot.samples-samprate/(pilot.freq+200-(pilot.freq/100*correction));
  word count;
  dword skipped1=0,skipped2=0,hpulse,pulse;
  wmaxcount=wmincount=wmax=wmin=0;
  PilotLinkingOK=0;
  if (spdchk && pilot.freq==808)
     do {
	  word pfreq;
	  CheckingSpeed=1;
	  PushFilePointers();
	  pfreq=BeepSearch(16);
	  if (!pfreq && !blocktype)
	     {
	       PopFilePointers();
	       lseek(inpfile.handle,filepos,SEEK_SET);
	       inpfile.bufpoint=0;
	       ecf=1; break;
	     }
	  PopFilePointers();
	  lseek(inpfile.handle,filepos,SEEK_SET);
	  inpfile.bufpoint=0;
	  ecf=(double)808/pfreq;
	  if (fabs(ecf)<.10) ecf=1;
	  CheckingSpeed=0;
	}
     while (fabs(ecf-1)>.20);
  if (!FindingPause && !ClickSearch) printf("Searching pilot...     \x0d");
  if (spdchk) pilot.samples*=ecf;
  do {
       do {
	    hpulse=FindEdge1();
	    if (!blocktype) return skipped1+skipped2+hpulse;
	    skipped1+=hpulse;
	  }
       while (hpulse<(pilot.samples/2)-tolerance || hpulse>(pilot.samples/2)+tolerance);
       skipped2=0;
       PushFilePointers();
       for (count=0; count<pulses; count++)
	   {
	     skipped2+=(pulse=FindEdge2());
	     if ((pulse<pilot.samples-(2*tolerance) || pulse>pilot.samples+(2*tolerance)) && !tonesearch)
		{ RemoveFilePointers(); break; }
/*           if (tapespeedcheck)
		{
		  if (pulse==wmax-(wmax-wmin)/2 && wmax!=0) wmaxcount++;
		  else if (pulse==wmin+(wmax-wmin)/2 && wmin!=0) wmincount++;
		  if (pulse<wmin) wmincount=1;
		  else if (pulse>wmax) wmaxcount=1;
		  if (wmax==0) wmax=pulse;
		  else wmax=(pulse*(pulse>wmax))+(wmax*(pulse<=wmax));
		  if (wmin==0) wmin=pulse;
		  else wmin=(pulse*(pulse<wmin))+(wmin*(pulse>=wmin));
		} */
	   }
       if (count==pulses) PilotLinkingOK=1;
       else { skipped1+=skipped2; skipped2=0; }
     }
  while (count!=pulses);
  if (!FindingPause) pilotlength+=skipped2+hpulse;
  if (!FindingPause && !ClickSearch) printf("Loading pilot...       \x0d");
  if (FindingPause)
     {
       PopFilePointers();
       lseek(inpfile.handle,filepos,SEEK_SET);
       inpfile.bufpoint=0;
       RemoveFilePointers();
       PushFilePointers();
     }
  else RemoveFilePointers();
  return skipped1-hpulse;
}

// Assembly:
subq $0x48, %rsp
movl %edi, 0x3c(%rsp)
movsd 0x1bd38(%rip), %xmm0    # 0x1f728
movss 0xf7d8(%rip), %xmm1     # 0x131d0
cvtss2sd %xmm1, %xmm1
movsd 0x1bd14(%rip), %xmm3    # 0x1f718
movsd 0xbfcc(%rip), %xmm4     # 0xf9d8
movaps %xmm3, %xmm2
addsd %xmm4, %xmm2
movsd 0xbfc5(%rip), %xmm4     # 0xf9e0
divsd %xmm4, %xmm3
movsd 0xf7b1(%rip), %xmm4     # 0x131d8
mulsd %xmm4, %xmm3
addsd %xmm3, %xmm2
divsd %xmm2, %xmm1
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movb %al, 0x3b(%rsp)
movq $0x0, 0x28(%rsp)
movq $0x0, 0x20(%rsp)
movq $0x0, 0x1c144(%rip) # 0x1fba0
movq $0x0, 0x1c141(%rip) # 0x1fba8
movl $0x0, 0x1c13f(%rip)     # 0x1fbb0
movl $0x0, 0x1c139(%rip)     # 0x1fbb4
movb $0x0, 0x1c136(%rip)     # 0x1fbb8
movzbl 0xf710(%rip), %eax      # 0x13199
cmpl $0x0, %eax
je 0x3bc3
movsd 0x1bc7e(%rip), %xmm0    # 0x1f718
movsd 0xbf46(%rip), %xmm1     # 0xf9e8
ucomisd %xmm1, %xmm0
jne 0x3bc3
jp 0x3bc3
jmp 0x3ab4
movb $0x1, 0xf6e1(%rip)      # 0x1319c
callq 0x18e0
movl $0x10, %edi
callq 0x4680
movl %eax, 0xc(%rsp)
cmpl $0x0, 0xc(%rsp)
jne 0x3b17
cmpb $0x0, 0x1bbc5(%rip)     # 0x1f6a1
jne 0x3b17
callq 0x1a10
movzbl 0xf776(%rip), %edi      # 0x13260
movq 0xf6d7(%rip), %rsi      # 0x131c8
xorl %edx, %edx
callq 0x10b0
movl $0x0, 0xf85e(%rip)      # 0x13360
movsd 0xbee6(%rip), %xmm0     # 0xf9f0
movsd %xmm0, 0xf5c6(%rip)     # 0x130d8
jmp 0x3bc1
callq 0x1a10
movzbl 0xf73d(%rip), %edi      # 0x13260
movq 0xf69e(%rip), %rsi      # 0x131c8
xorl %edx, %edx
callq 0x10b0
movl $0x0, 0xf825(%rip)      # 0x13360
movl 0xc(%rsp), %eax
cvtsi2sd %rax, %xmm1
movsd 0xbe9c(%rip), %xmm0     # 0xf9e8
divsd %xmm1, %xmm0
movsd %xmm0, 0xf580(%rip)     # 0x130d8
movsd 0xf578(%rip), %xmm1     # 0x130d8
movaps 0xbff9(%rip), %xmm0     # 0xfb60
pand %xmm0, %xmm1
movsd 0xbe85(%rip), %xmm0     # 0xf9f8
ucomisd %xmm1, %xmm0
jbe 0x3b89
movsd 0xbe6f(%rip), %xmm0     # 0xf9f0
movsd %xmm0, 0xf54f(%rip)     # 0x130d8
movb $0x0, 0xf60c(%rip)      # 0x1319c
movsd 0xf540(%rip), %xmm0     # 0x130d8
movsd 0xbe50(%rip), %xmm1     # 0xf9f0
subsd %xmm1, %xmm0
movaps 0xbfb5(%rip), %xmm1     # 0xfb60
pand %xmm1, %xmm0
movsd 0xbe49(%rip), %xmm1     # 0xfa00
ucomisd %xmm1, %xmm0
ja 0x3ab4
jmp 0x3bc3
cmpb $0x0, 0xf5d0(%rip)      # 0x1319a
jne 0x3be3
cmpb $0x0, 0xf5c8(%rip)      # 0x1319b
jne 0x3be3
leaq 0xc5f0(%rip), %rdi      # 0x101cc
movb $0x0, %al
callq 0x1090
cmpb $0x0, 0xf5af(%rip)      # 0x13199
je 0x3c04
movsd 0xf4e4(%rip), %xmm0     # 0x130d8
mulsd 0x1bb2c(%rip), %xmm0    # 0x1f728
movsd %xmm0, 0x1bb24(%rip)    # 0x1f728
jmp 0x3c06
jmp 0x3c08
callq 0x2e80
movq %rax, 0x18(%rsp)
cmpb $0x0, 0x1ba88(%rip)     # 0x1f6a1
jne 0x3c34
movq 0x28(%rsp), %rax
addq 0x20(%rsp), %rax
addq 0x18(%rsp), %rax
movq %rax, 0x40(%rsp)
jmp 0x3eab
movq 0x18(%rsp), %rax
addq 0x28(%rsp), %rax
movq %rax, 0x28(%rsp)
movaps 0xbf26(%rip), %xmm0     # 0xfb70
movq 0x18(%rsp), %xmm1
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
movapd 0xbf24(%rip), %xmm0     # 0xfb80
subpd %xmm0, %xmm1
movaps %xmm1, %xmm0
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm0, %xmm1
movsd 0x1bab5(%rip), %xmm0    # 0x1f728
movsd 0xbd8d(%rip), %xmm2     # 0xfa08
divsd %xmm2, %xmm0
movzbl 0x3b(%rsp), %eax
cvtsi2sd %eax, %xmm2
subsd %xmm2, %xmm0
movb $0x1, %al
ucomisd %xmm1, %xmm0
movb %al, 0xb(%rsp)
ja 0x3cec
movaps 0xbed1(%rip), %xmm1     # 0xfb70
movq 0x18(%rsp), %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0xbecf(%rip), %xmm1     # 0xfb80
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd 0x1ba60(%rip), %xmm1    # 0x1f728
movsd 0xbd38(%rip), %xmm2     # 0xfa08
divsd %xmm2, %xmm1
movzbl 0x3b(%rsp), %eax
cvtsi2sd %eax, %xmm2
addsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
seta %al
movb %al, 0xb(%rsp)
movb 0xb(%rsp), %al
testb $0x1, %al
jne 0x3c08
movq $0x0, 0x20(%rsp)
callq 0x18e0
movl $0x0, 0x34(%rsp)
movl 0x34(%rsp), %eax
cmpl 0x3c(%rsp), %eax
jae 0x3de2
callq 0x3150
movq %rax, %rcx
movq %rcx, 0x10(%rsp)
movq 0x20(%rsp), %rax
addq %rcx, %rax
movq %rax, 0x20(%rsp)
movaps 0xbe33(%rip), %xmm0     # 0xfb70
movq 0x10(%rsp), %xmm1
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
movapd 0xbe31(%rip), %xmm0     # 0xfb80
subpd %xmm0, %xmm1
movaps %xmm1, %xmm0
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm0, %xmm1
movsd 0x1b9c2(%rip), %xmm0    # 0x1f728
movzbl 0x3b(%rsp), %eax
shll %eax
cvtsi2sd %eax, %xmm2
subsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
ja 0x3dc0
movaps 0xbdee(%rip), %xmm1     # 0xfb70
movq 0x10(%rsp), %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0xbdec(%rip), %xmm1     # 0xfb80
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd 0x1b97d(%rip), %xmm1    # 0x1f728
movzbl 0x3b(%rsp), %eax
shll %eax
cvtsi2sd %eax, %xmm2
addsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x3dd0
cmpb $0x0, 0xf419(%rip)      # 0x131e0
jne 0x3dd0
callq 0x1b30
jmp 0x3de2
jmp 0x3dd2
movl 0x34(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x34(%rsp)
jmp 0x3d0e
movl 0x34(%rsp), %eax
cmpl 0x3c(%rsp), %eax
jne 0x3df5
movb $0x1, 0x1bdc5(%rip)     # 0x1fbb8
jmp 0x3e0d
movq 0x20(%rsp), %rax
addq 0x28(%rsp), %rax
movq %rax, 0x28(%rsp)
movq $0x0, 0x20(%rsp)
jmp 0x3e0f
movl 0x34(%rsp), %eax
cmpl 0x3c(%rsp), %eax
jne 0x3c06
cmpb $0x0, 0xf376(%rip)      # 0x1319a
jne 0x3e3e
movq 0x20(%rsp), %rax
addq 0x18(%rsp), %rax
addq 0x1bd89(%rip), %rax     # 0x1fbc0
movq %rax, 0x1bd82(%rip)     # 0x1fbc0
cmpb $0x0, 0xf355(%rip)      # 0x1319a
jne 0x3e5e
cmpb $0x0, 0xf34d(%rip)      # 0x1319b
jne 0x3e5e
leaq 0xc38e(%rip), %rdi      # 0x101e5
movb $0x0, %al
callq 0x1090
cmpb $0x0, 0xf335(%rip)      # 0x1319a
je 0x3e97
callq 0x1a10
movzbl 0xf3ed(%rip), %edi      # 0x13260
movq 0xf34e(%rip), %rsi      # 0x131c8
xorl %edx, %edx
callq 0x10b0
movl $0x0, 0xf4d5(%rip)      # 0x13360
callq 0x1b30
callq 0x18e0
jmp 0x3e9c
callq 0x1b30
movq 0x28(%rsp), %rax
subq 0x18(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rax
addq $0x48, %rsp
retq
nopw %cs:(%rax,%rax)