// File: /workspace/github_c_makefile_star2_O0/mincebert[P]maketzx/maketzx.c
// Function: SearchDataFrequencies
void SearchDataFrequencies(void)
{
  dword dwpulse,count,pulsecount=0;
//  double tolerance=2; //((125-(samprate/282.22))/samprate)*1000;
  double pmax=0,pmin=0,totmin=0,totmax=0,startmax,startmin,min,max;
  byte pulse;
  wmincount=wmaxcount=0;
/*  do {
       dwpulse=FindEdge2();
       if (!blocktype) break;
       if (dwpulse<samprate/808 && dwpulse)
	  {
	    pulse=dwpulse;
	    PutData(&tempfile,pulse,1);
	    pulsecount++;
	  }
     }
  while (dwpulse<pilot.samples && dwpulse);
  ResetTempFile();
  for (count=0; count<2; count++) GetData(&tempfile); */
//  FindEdge2();
//  FindEdge2();
//  for (count=0; count<2; count++)
//      {
	pmax=pmin=FindEdge2(); //GetData(&tempfile);
	if (pmax*2-pilot.samples+.5>-3)
	   {
	     startmin=totmin=pmin=pmax*.7;
	     pmax--;
	     startmax=totmax=pmax;
	     wmincount++;
	     wmaxcount++;
	   }
	else {
	       startmax=totmax=pmax=pmin*1.8;
	       pmin++;
	       startmin=totmin=pmin;
	       wmaxcount++;
	       wmincount++;
	     }
/*  wmaxcount=wmincount=0;
  if (pulsecount<10) { bit0.freq=bit1.freq=0; return; }
  for (count=0; count<pulsecount-5; count++) */
	do {
	     pulse=FindEdge2(); //GetData(&tempfile);
	     pulsecount++;
	     if (pulse)
		{
		  if (fabs(pulse-pmax)<2) { wmaxcount++; totmax+=pulse; }
		  else if (fabs(pulse-pmin)<2) { wmincount++; totmin+=pulse; }
		  //if (pulse==pmax || (pulse>pmax && pulse<=pmax*1.5 && abs(pmin*2-pulse)<2)) { wmaxcount++; totmax+=pulse; }// && pulse<=pmax*1.5) wmaxcount++;
		  //else if (pulse>pmax && pulse<=pmax*1.5) wmaxcount=1;
		       //else if (pulse==pmin || (pulse<pmin && pulse>=pmin*.5 && abs(pmax/2-pulse)<2)) { wmincount++; totmin+=pulse; }//&& pulse>=pmin*.5) wmincount++;
			    //else if (pulse<pmin && pulse>=pmin*.5) wmincount=1;
		  pmax=(pulse*(pulse>pmax && (pulse<=pmin*2.5 || pulse<=pmax*1.5)))+(pmax*(pulse<=pmax));
		  pmin=(pulse*(pulse<pmin && (pulse>=pmax/3 || pulse>=pmin*.5)))+(pmin*(pulse>=pmin));
//                diff=abs(pmax-2*pmin);
		}
	   }
	while (pulsecount<21 && pulse<pmax*1.5 && pulse>pmin*.5);
//      totmin+=pmin;
//      totmax+=pmax;
//      }
//  if (wmaxcount>wmincount && wmincount<wmaxcount/2 || wmincount<15) pmin+=.25;
//  if (wmaxcount<wmincount && wmaxcount<wmincount/2 || wmaxcount<15) pmax-=.75;
//  pmax+=((pmin*2+pmax)/3-middle/pulsecount);
//  pmin=(3*pmin+6*pmax)/15; pmax=2*pmin;  // pmax++; pmin++;
//  pmax+=1.2-abs(diff); pmin+=.4-abs(diff/2);
//  ratio=(double)max(wmaxcount,wmincount)/min(wmaxcount,wmincount);
/*  if (pmax-start*2>pmin/2) { totmax+=start; totmin-=start; wmincount--; }
  else { totmax-=start; wmaxcount--; } */
  min=totmin/wmincount; max=totmax/wmaxcount;
  if (fabs(pmin*2-pmax)>pmin/2) { pmin=min; pmax=max; }
  else {
	 if ((wmincount==1 && wmaxcount>1) || fabs(pmin-startmin)<.01) pmin=max/2;
	    else if ((wmaxcount==1 && wmincount>1) || fabs(pmax-startmax)<0.1) pmax=min*2;
	 pmin=(pmin+pmax)/3; pmax=2*pmin;
       }
//  pmax+=(pmax*(2*ratio/3)/100);
//  pmin-=(pmin*(ratio/3)/100);
/*  pmin=(pmin+pmax)/3; pmax=pmin*2; //pmin=diff/4; pmax-=diff/2;*/
  if (pmin && pmax) bit0.freq=(samprate/pmin); bit1.freq=(samprate/pmax); SetTimings();
  ResetTempFile();
}

// Assembly:
subq $0x78, %rsp
movq $0x0, 0x60(%rsp)
movq $0x0, 0x58(%rsp)
movq $0x0, 0x50(%rsp)
movq $0x0, 0x48(%rsp)
movq $0x0, 0x40(%rsp)
movl $0x0, 0x159d9(%rip)     # 0x1fbb4
movl $0x0, 0x159cb(%rip)     # 0x1fbb0
callq 0x3150
movq %rax, %xmm0
movaps 0x597a(%rip), %xmm1     # 0xfb70
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x597e(%rip), %xmm1     # 0xfb80
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd %xmm0, 0x50(%rsp)
movsd %xmm0, 0x58(%rsp)
movsd 0x58(%rsp), %xmm0
movsd 0x154fd(%rip), %xmm1    # 0x1f728
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
addsd %xmm0, %xmm0
addsd %xmm1, %xmm0
movsd 0x57de(%rip), %xmm1     # 0xfa30
addsd %xmm1, %xmm0
movsd 0x58aa(%rip), %xmm1     # 0xfb08
ucomisd %xmm1, %xmm0
jbe 0xa2ca
movsd 0x58b4(%rip), %xmm0     # 0xfb20
mulsd 0x58(%rsp), %xmm0
movsd %xmm0, 0x50(%rsp)
movsd %xmm0, 0x48(%rsp)
movsd %xmm0, 0x30(%rsp)
movsd 0x588c(%rip), %xmm0     # 0xfb18
addsd 0x58(%rsp), %xmm0
movsd %xmm0, 0x58(%rsp)
movsd 0x58(%rsp), %xmm0
movsd %xmm0, 0x40(%rsp)
movsd %xmm0, 0x38(%rsp)
movl 0x15900(%rip), %eax     # 0x1fbb0
addl $0x1, %eax
movl %eax, 0x158f7(%rip)     # 0x1fbb0
movl 0x158f5(%rip), %eax     # 0x1fbb4
addl $0x1, %eax
movl %eax, 0x158ec(%rip)     # 0x1fbb4
jmp 0xa32e
movsd 0x583e(%rip), %xmm0     # 0xfb10
mulsd 0x50(%rsp), %xmm0
movsd %xmm0, 0x58(%rsp)
movsd %xmm0, 0x40(%rsp)
movsd %xmm0, 0x38(%rsp)
movsd 0x56fe(%rip), %xmm0     # 0xf9f0
addsd 0x50(%rsp), %xmm0
movsd %xmm0, 0x50(%rsp)
movsd 0x50(%rsp), %xmm0
movsd %xmm0, 0x48(%rsp)
movsd %xmm0, 0x30(%rsp)
movl 0x1589e(%rip), %eax     # 0x1fbb4
addl $0x1, %eax
movl %eax, 0x15895(%rip)     # 0x1fbb4
movl 0x1588b(%rip), %eax     # 0x1fbb0
addl $0x1, %eax
movl %eax, 0x15882(%rip)     # 0x1fbb0
jmp 0xa330
callq 0x3150
movb %al, 0x1f(%rsp)
movq 0x60(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x60(%rsp)
cmpb $0x0, 0x1f(%rsp)
je 0xa55c
movzbl 0x1f(%rsp), %eax
cvtsi2sd %eax, %xmm1
subsd 0x58(%rsp), %xmm1
movaps 0x57f8(%rip), %xmm0     # 0xfb60
pand %xmm0, %xmm1
movsd 0x5694(%rip), %xmm0     # 0xfa08
ucomisd %xmm1, %xmm0
jbe 0xa3a0
movl 0x15834(%rip), %eax     # 0x1fbb4
addl $0x1, %eax
movl %eax, 0x1582b(%rip)     # 0x1fbb4
movzbl 0x1f(%rsp), %eax
cvtsi2sd %eax, %xmm0
addsd 0x40(%rsp), %xmm0
movsd %xmm0, 0x40(%rsp)
jmp 0xa3ee
movzbl 0x1f(%rsp), %eax
cvtsi2sd %eax, %xmm1
subsd 0x50(%rsp), %xmm1
movaps 0x57aa(%rip), %xmm0     # 0xfb60
pand %xmm0, %xmm1
movsd 0x5646(%rip), %xmm0     # 0xfa08
ucomisd %xmm1, %xmm0
jbe 0xa3ec
movl 0x157e2(%rip), %eax     # 0x1fbb0
addl $0x1, %eax
movl %eax, 0x157d9(%rip)     # 0x1fbb0
movzbl 0x1f(%rsp), %eax
cvtsi2sd %eax, %xmm0
addsd 0x48(%rsp), %xmm0
movsd %xmm0, 0x48(%rsp)
jmp 0xa3ee
movzbl 0x1f(%rsp), %eax
movl %eax, 0x18(%rsp)
movzbl 0x1f(%rsp), %eax
cvtsi2sd %eax, %xmm0
xorl %eax, %eax
ucomisd 0x58(%rsp), %xmm0
movb %al, 0x1e(%rsp)
jbe 0xa45b
movzbl 0x1f(%rsp), %eax
cvtsi2sd %eax, %xmm1
movsd 0x5709(%rip), %xmm0     # 0xfb28
mulsd 0x50(%rsp), %xmm0
movb $0x1, %al
ucomisd %xmm1, %xmm0
movb %al, 0x17(%rsp)
jae 0xa453
movzbl 0x1f(%rsp), %eax
cvtsi2sd %eax, %xmm1
movsd 0x56ee(%rip), %xmm0     # 0xfb30
mulsd 0x58(%rsp), %xmm0
ucomisd %xmm1, %xmm0
setae %al
movb %al, 0x17(%rsp)
movb 0x17(%rsp), %al
movb %al, 0x1e(%rsp)
movl 0x18(%rsp), %eax
movb 0x1e(%rsp), %cl
andb $0x1, %cl
movzbl %cl, %ecx
imull %ecx, %eax
cvtsi2sd %eax, %xmm1
movsd 0x58(%rsp), %xmm0
movzbl 0x1f(%rsp), %eax
cvtsi2sd %eax, %xmm3
movsd 0x58(%rsp), %xmm2
ucomisd %xmm3, %xmm2
setae %al
andb $0x1, %al
movzbl %al, %eax
cvtsi2sd %eax, %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x58(%rsp)
movzbl 0x1f(%rsp), %eax
movl %eax, 0x10(%rsp)
movzbl 0x1f(%rsp), %eax
cvtsi2sd %eax, %xmm1
movsd 0x50(%rsp), %xmm0
xorl %eax, %eax
ucomisd %xmm1, %xmm0
movb %al, 0x16(%rsp)
jbe 0xa518
movzbl 0x1f(%rsp), %eax
cvtsi2sd %eax, %xmm0
movsd 0x58(%rsp), %xmm1
movsd 0x54ea(%rip), %xmm2     # 0xf9c8
divsd %xmm2, %xmm1
movb $0x1, %al
ucomisd %xmm1, %xmm0
movb %al, 0xf(%rsp)
jae 0xa510
movzbl 0x1f(%rsp), %eax
cvtsi2sd %eax, %xmm0
movsd 0x5531(%rip), %xmm1     # 0xfa30
mulsd 0x50(%rsp), %xmm1
ucomisd %xmm1, %xmm0
setae %al
movb %al, 0xf(%rsp)
movb 0xf(%rsp), %al
movb %al, 0x16(%rsp)
movl 0x10(%rsp), %eax
movb 0x16(%rsp), %cl
andb $0x1, %cl
movzbl %cl, %ecx
imull %ecx, %eax
cvtsi2sd %eax, %xmm1
movsd 0x50(%rsp), %xmm0
movzbl 0x1f(%rsp), %eax
cvtsi2sd %eax, %xmm2
ucomisd 0x50(%rsp), %xmm2
setae %al
andb $0x1, %al
movzbl %al, %eax
cvtsi2sd %eax, %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x50(%rsp)
jmp 0xa55e
xorl %eax, %eax
cmpq $0x15, 0x60(%rsp)
movb %al, 0xe(%rsp)
jae 0xa5b1
movzbl 0x1f(%rsp), %eax
cvtsi2sd %eax, %xmm1
movsd 0x55b3(%rip), %xmm0     # 0xfb30
mulsd 0x58(%rsp), %xmm0
xorl %eax, %eax
ucomisd %xmm1, %xmm0
movb %al, 0xe(%rsp)
jbe 0xa5b1
movzbl 0x1f(%rsp), %eax
cvtsi2sd %eax, %xmm0
movsd 0x5490(%rip), %xmm1     # 0xfa30
mulsd 0x50(%rsp), %xmm1
ucomisd %xmm1, %xmm0
seta %al
movb %al, 0xe(%rsp)
movb 0xe(%rsp), %al
testb $0x1, %al
jne 0xa330
movsd 0x48(%rsp), %xmm0
movl 0x155e7(%rip), %eax     # 0x1fbb0
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x28(%rsp)
movsd 0x40(%rsp), %xmm0
movl 0x155d0(%rip), %eax     # 0x1fbb4
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0x50(%rsp), %xmm0
movsd 0x58(%rsp), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
addsd %xmm0, %xmm0
addsd %xmm1, %xmm0
movaps 0x553b(%rip), %xmm1     # 0xfb60
pand %xmm1, %xmm0
movsd 0x50(%rsp), %xmm1
movsd 0x53d1(%rip), %xmm2     # 0xfa08
divsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jbe 0xa65e
movsd 0x28(%rsp), %xmm0
movsd %xmm0, 0x50(%rsp)
movsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x58(%rsp)
jmp 0xa72e
cmpl $0x1, 0x1554b(%rip)     # 0x1fbb0
jne 0xa670
cmpl $0x1, 0x15546(%rip)     # 0x1fbb4
ja 0xa695
movsd 0x50(%rsp), %xmm1
subsd 0x30(%rsp), %xmm1
movaps 0x54dd(%rip), %xmm0     # 0xfb60
pand %xmm0, %xmm1
movsd 0x54a9(%rip), %xmm0     # 0xfb38
ucomisd %xmm1, %xmm0
jbe 0xa6af
movsd 0x20(%rsp), %xmm0
movsd 0x5365(%rip), %xmm1     # 0xfa08
divsd %xmm1, %xmm0
movsd %xmm0, 0x50(%rsp)
jmp 0xa6fc
cmpl $0x1, 0x154fe(%rip)     # 0x1fbb4
jne 0xa6c1
cmpl $0x1, 0x154f1(%rip)     # 0x1fbb0
ja 0xa6e6
movsd 0x58(%rsp), %xmm1
subsd 0x38(%rsp), %xmm1
movaps 0x548c(%rip), %xmm0     # 0xfb60
pand %xmm0, %xmm1
movsd 0x5318(%rip), %xmm0     # 0xf9f8
ucomisd %xmm1, %xmm0
jbe 0xa6fa
movsd 0x531a(%rip), %xmm0     # 0xfa08
mulsd 0x28(%rsp), %xmm0
movsd %xmm0, 0x58(%rsp)
jmp 0xa6fc
movsd 0x50(%rsp), %xmm0
addsd 0x58(%rsp), %xmm0
movsd 0x52b8(%rip), %xmm1     # 0xf9c8
divsd %xmm1, %xmm0
movsd %xmm0, 0x50(%rsp)
movsd 0x52e6(%rip), %xmm0     # 0xfa08
mulsd 0x50(%rsp), %xmm0
movsd %xmm0, 0x58(%rsp)
movsd 0x50(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xa741
jp 0xa741
jmp 0xa76e
movsd 0x58(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xa754
jp 0xa754
jmp 0xa76e
movss 0x8a74(%rip), %xmm0     # 0x131d0
cvtss2sd %xmm0, %xmm0
divsd 0x50(%rsp), %xmm0
movsd %xmm0, 0x14fea(%rip)    # 0x1f758
movss 0x8a5a(%rip), %xmm0     # 0x131d0
cvtss2sd %xmm0, %xmm0
divsd 0x58(%rsp), %xmm0
movsd %xmm0, 0x14ff0(%rip)    # 0x1f778
callq 0x2d90
callq 0x18a0
addq $0x78, %rsp
retq
nopw (%rax,%rax)