// File: /workspace/github_c_makefile_star2_O1/randyrossi[P]fisher-modem/mkfilter/src/mkfilter.C
// Function: compute_bpres()
static void compute_bpres() { /* compute Z-plane pole & zero positions for
                                 bandpass resonator */
  zplane.numpoles = zplane.numzeros = 2;
  zplane.zeros[0] = 1.0;
  zplane.zeros[1] = -1.0;
  double theta = TWOPI * raw_alpha1; /* where we want the peak to be */
  if (infq) {                        /* oscillator */
    complex zp = expj(theta);
    zplane.poles[0] = zp;
    zplane.poles[1] = cconj(zp);
  } else { /* must iterate to find exact pole positions */
    complex topcoeffs[MAXPZ + 1];
    expand(zplane.zeros, zplane.numzeros, topcoeffs);
    double r = exp(-theta / (2.0 * qfactor));
    double thm = theta, th1 = 0.0, th2 = PI;
    bool cvg = false;
    for (int i = 0; i < 50 && !cvg; i++) {
      complex zp = r * expj(thm);
      zplane.poles[0] = zp;
      zplane.poles[1] = cconj(zp);
      complex botcoeffs[MAXPZ + 1];
      expand(zplane.poles, zplane.numpoles, botcoeffs);
      complex g = evaluate(topcoeffs, zplane.numzeros, botcoeffs,
                           zplane.numpoles, expj(theta));
      double phi = g.im / g.re; /* approx to atan2 */
      if (phi > 0.0)
        th2 = thm;
      else
        th1 = thm;
      if (fabs(phi) < EPS)
        cvg = true;
      thm = 0.5 * (th1 + th2);
    }
    unless(cvg) fprintf(stderr, "mkfilter: warning: failed to converge\n");
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x4078, %rsp           # imm = 0x4078
movabsq $0x200000002, %rax      # imm = 0x200000002
movq %rax, 0xc610(%rip)      # 0xf108
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, 0xa5ff(%rip)      # 0xd108
xorl %r13d, %r13d
movq %r13, 0xa5fd(%rip)      # 0xd110
movabsq $-0x4010000000000000, %rax # imm = 0xBFF0000000000000
movq %rax, 0xa5f4(%rip)      # 0xd118
movq %r13, 0xa5f5(%rip)      # 0xd120
movsd 0xc5f5(%rip), %xmm0     # 0xf128
mulsd 0x14cd(%rip), %xmm0     # 0x4008
cmpb $0x1, 0xc606(%rip)      # 0xf148
jne 0x2b76
callq 0x34b3
movsd %xmm0, 0x85b7(%rip)     # 0xb108
movsd %xmm1, 0x85b7(%rip)     # 0xb110
xorpd 0x150f(%rip), %xmm1     # 0x4070
movsd %xmm0, 0x85af(%rip)     # 0xb118
movlpd %xmm1, 0x85af(%rip)     # 0xb120
jmp 0x2ce9
leaq 0xa58b(%rip), %rdi      # 0xd108
leaq 0x50(%rsp), %rdx
movl $0x2, %esi
movapd %xmm0, 0x10(%rsp)
callq 0x2ed9
movapd 0x14d6(%rip), %xmm0     # 0x4070
xorpd 0x10(%rsp), %xmm0
movsd 0xc5a8(%rip), %xmm1     # 0xf150
addsd %xmm1, %xmm1
divsd %xmm1, %xmm0
callq 0x1170
movsd %xmm0, 0x28(%rsp)
movsd 0x145d(%rip), %xmm2     # 0x4020
leaq 0x2060(%rsp), %r15
movl $0x1, %ebx
movapd 0x10(%rsp), %xmm1
xorpd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
xorl %r14d, %r14d
movapd %xmm2, 0x30(%rsp)
movapd %xmm1, 0x40(%rsp)
movapd %xmm1, %xmm0
callq 0x34b3
movsd 0x28(%rsp), %xmm2
mulsd %xmm2, %xmm0
mulsd %xmm2, %xmm1
movsd %xmm0, 0x84fa(%rip)     # 0xb108
movsd %xmm1, 0x84fa(%rip)     # 0xb110
xorpd 0x1452(%rip), %xmm1     # 0x4070
movsd %xmm0, 0x84f2(%rip)     # 0xb118
movlpd %xmm1, 0x84f2(%rip)     # 0xb120
movl 0xc4d4(%rip), %esi      # 0xf108
leaq 0x84cd(%rip), %rdi      # 0xb108
movq %r15, %rdx
callq 0x2ed9
movl 0xc4c3(%rip), %ebp      # 0xf10c
movl 0xc4b8(%rip), %r12d     # 0xf108
movapd 0x10(%rsp), %xmm0
callq 0x34b3
leaq 0x50(%rsp), %rdi
movl %ebp, %esi
movq %r15, %rdx
movl %r12d, %ecx
callq 0x325c
movapd 0x40(%rsp), %xmm2
divsd %xmm0, %xmm1
ucomisd 0x13e1(%rip), %xmm1     # 0x4060
ja 0x2c87
movsd %xmm2, 0x8(%rsp)
xorpd %xmm0, %xmm0
cmpltsd %xmm1, %xmm0
andpd %xmm0, %xmm2
andnpd 0x30(%rsp), %xmm0
orpd %xmm2, %xmm0
andpd 0x13da(%rip), %xmm1     # 0x4080
movsd 0x13aa(%rip), %xmm2     # 0x4058
ucomisd %xmm1, %xmm2
movzbl %r14b, %r14d
cmoval %ebx, %r14d
movsd 0x8(%rsp), %xmm1
addsd %xmm0, %xmm1
mulsd 0x134c(%rip), %xmm1     # 0x4018
cmpl $0x30, %r13d
ja 0x2ce3
incl %r13d
movapd %xmm0, %xmm2
testb $0x1, %r14b
je 0x2be3
testb $0x1, %r14b
je 0x2cfb
addq $0x4078, %rsp           # imm = 0x4078
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x127f
jmp 0x2ce9