// File: /workspace/github_c_makefile_star2_O2/mincebert[P]maketzx/maketzx.c
// Function: FindEdge2
dword FindEdge2(void)
{
  byte good=0;
  dword hp1=0,hp2=0,total=0;

  if (FindingPause)
     {
       hp1=FindEdge1();
       if (!blocktype)
          {
            if (!FindingPause && hp1>(int)(samprate/500))
	       {
	         mspause=(hp1/samprate)*1000;
	         hp2=hp1=0;
	         EndBlock=1;
	         return hp2;
	       }
            else return hp1;
          }
       hp2=FindEdge1();
       if (!FindingPause && hp2>(int)(samprate/500))
	  {
	    mspause=((hp2-hp1)/samprate)*1000;
	    hp2=hp1;
	    EndBlock=1;
	  }
     }
  else {
	 do {
	      hp1+=FindEdge1();
	      //
	      if (!blocktype)
	         {
	           if (!FindingPause && hp1>(int)(samprate/500))
		      {
		        mspause=(hp1/samprate)*1000;
		        hp2=hp1=0;
		        EndBlock=1;
		        return hp2;
		      }
	           else return hp1;
	         }
	      //
	      if (currpulse<2 && bit0.samples>3)
		 {
		   PushFilePointers();
		   FindEdge1();
		   if (currpulse<2) { RemoveFilePointers(); good=0; }
		   else {
			  PopFilePointers();
			  lseek(inpfile.handle,filepos,SEEK_SET);
			  inpfile.bufpoint=0;
			  good=1;
			}
		 }
	      else good=1;
	    }
	 while (!good && blocktype);
	 do {
	      hp2+=FindEdge1();
	      //
	      if (!FindingPause && hp2>(int)(samprate/500))
		 {
		   mspause=((hp2-hp1)/samprate)*1000;
		   hp2=hp1;
		   EndBlock=1;
		 }
	      //
	      if (currpulse<2 && bit0.samples>3)
		 {
		   PushFilePointers();
		   FindEdge1();
		   if (currpulse<2) { RemoveFilePointers(); good=0; }
		   else {
			  PopFilePointers();
			  lseek(inpfile.handle,filepos,SEEK_SET);
			  inpfile.bufpoint=0;
			  good=1;
			}
		 }
	      else good=1;
	    }
	  while (!good && blocktype);

       }
  total=(hp1+hp2);
  return total;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
cmpb $0x0, 0xcc12(%rip)      # 0xf1aa
je 0x25f9
callq 0x2429
movq %rax, %rbx
cmpb $0x0, 0x19108(%rip)     # 0x1b6b1
je 0x265a
callq 0x2429
movq %rax, %r14
cmpb $0x0, 0xcbec(%rip)      # 0xf1aa
jne 0x27e0
movss 0xcc14(%rip), %xmm0     # 0xf1e0
movaps %xmm0, %xmm1
divss 0x7e09(%rip), %xmm1     # 0xa3e0
cvttss2si %xmm1, %eax
cltq
cmpq %rax, %r14
jbe 0x27e0
subq %rbx, %r14
js 0x27a8
cvtsi2ss %r14, %xmm1
jmp 0x27be
xorl %ebx, %ebx
movq %rbx, %r14
callq 0x2429
movq %rax, %rbx
addq %r14, %rbx
cmpb $0x0, 0x190a1(%rip)     # 0x1b6b1
je 0x265a
cmpq $0x1, 0x190ae(%rip)     # 0x1b6c8
ja 0x26bd
movsd 0x19150(%rip), %xmm0    # 0x1b778
ucomisd 0x7c58(%rip), %xmm0     # 0xa288
jbe 0x26bd
callq 0x1618
callq 0x2429
cmpq $0x2, 0x19080(%rip)     # 0x1b6c8
jae 0x269c
callq 0x1748
cmpb $0x0, 0x1905b(%rip)     # 0x1b6b1
jne 0x25fb
jmp 0x26bd
cmpb $0x0, 0xcb49(%rip)      # 0xf1aa
jne 0x27e3
movss 0xcb71(%rip), %xmm0     # 0xf1e0
movaps %xmm0, %xmm1
divss 0x7d66(%rip), %xmm1     # 0xa3e0
cvttss2si %xmm1, %eax
cltq
cmpq %rax, %rbx
jbe 0x27e3
testq %rbx, %rbx
js 0x27ec
cvtsi2ss %rbx, %xmm1
jmp 0x2801
callq 0x16b7
movzbl 0xcbc8(%rip), %edi      # 0xf270
movq 0xcb29(%rip), %rsi      # 0xf1d8
xorl %edx, %edx
callq 0x10d0
andl $0x0, 0xccb3(%rip)      # 0xf370
xorl %r14d, %r14d
movq %r14, %r15
callq 0x2429
movq %rax, %r14
addq %r15, %r14
cmpb $0x0, 0xcad5(%rip)      # 0xf1aa
jne 0x2739
movss 0xcb01(%rip), %xmm0     # 0xf1e0
movaps %xmm0, %xmm1
divss 0x7cf6(%rip), %xmm1     # 0xa3e0
cvttss2si %xmm1, %eax
cltq
cmpq %rax, %r14
jbe 0x2739
subq %rbx, %r14
js 0x2701
cvtsi2ss %r14, %xmm1
jmp 0x2717
movq %r14, %rax
shrq %rax
andl $0x1, %r14d
orq %rax, %r14
cvtsi2ss %r14, %xmm1
addss %xmm1, %xmm1
divss %xmm0, %xmm1
mulss 0x7cc1(%rip), %xmm1     # 0xa3e4
cvtss2sd %xmm1, %xmm0
movsd %xmm0, 0xcae1(%rip)     # 0xf210
movb $0x1, 0x19072(%rip)     # 0x1b7a8
movq %rbx, %r14
cmpq $0x1, 0x18f87(%rip)     # 0x1b6c8
ja 0x27e0
movsd 0x19029(%rip), %xmm0    # 0x1b778
ucomisd 0x7b31(%rip), %xmm0     # 0xa288
jbe 0x27e0
callq 0x1618
callq 0x2429
cmpq $0x2, 0x18f59(%rip)     # 0x1b6c8
jae 0x2785
callq 0x1748
cmpb $0x0, 0x18f34(%rip)     # 0x1b6b1
jne 0x26c0
jmp 0x27e0
callq 0x16b7
movzbl 0xcadf(%rip), %edi      # 0xf270
movq 0xca40(%rip), %rsi      # 0xf1d8
xorl %edx, %edx
callq 0x10d0
andl $0x0, 0xcbca(%rip)      # 0xf370
jmp 0x27e0
movq %r14, %rax
shrq %rax
andl $0x1, %r14d
orq %rax, %r14
cvtsi2ss %r14, %xmm1
addss %xmm1, %xmm1
divss %xmm0, %xmm1
mulss 0x7c1a(%rip), %xmm1     # 0xa3e4
cvtss2sd %xmm1, %xmm0
movsd %xmm0, 0xca3a(%rip)     # 0xf210
movb $0x1, 0x18fcb(%rip)     # 0x1b7a8
movq %rbx, %r14
addq %r14, %rbx
movq %rbx, %rax
popq %rbx
popq %r14
popq %r15
retq
movq %rbx, %rax
shrq %rax
andl $0x1, %ebx
orq %rax, %rbx
cvtsi2ss %rbx, %xmm1
addss %xmm1, %xmm1
divss %xmm0, %xmm1
mulss 0x7bd7(%rip), %xmm1     # 0xa3e4
cvtss2sd %xmm1, %xmm0
movsd %xmm0, 0xc9f7(%rip)     # 0xf210
movb $0x1, 0x18f88(%rip)     # 0x1b7a8
xorl %ebx, %ebx
jmp 0x27e3