// File: /workspace/github_c_makefile_star2_O3/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, 0xc5e6(%rip)      # 0xf108
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, 0xa5d5(%rip)      # 0xd108
xorl %r13d, %r13d
movq %r13, 0xa5d3(%rip)      # 0xd110
movabsq $-0x4010000000000000, %rax # imm = 0xBFF0000000000000
movq %rax, 0xa5ca(%rip)      # 0xd118
movq %r13, 0xa5cb(%rip)      # 0xd120
movsd 0xc5cb(%rip), %xmm0     # 0xf128
mulsd 0x14a3(%rip), %xmm0     # 0x4008
cmpb $0x1, 0xc5dc(%rip)      # 0xf148
jne 0x2ba0
callq 0x34c7
movsd %xmm0, 0x858d(%rip)     # 0xb108
movsd %xmm1, 0x858d(%rip)     # 0xb110
xorpd 0x14e5(%rip), %xmm1     # 0x4070
movsd %xmm0, 0x8585(%rip)     # 0xb118
movlpd %xmm1, 0x8585(%rip)     # 0xb120
jmp 0x2d0b
leaq 0xa561(%rip), %rdi      # 0xd108
leaq 0x2060(%rsp), %rbx
movl $0x2, %esi
movq %rbx, %rdx
movapd %xmm0, 0x10(%rsp)
callq 0x2efb
movapd 0x14a6(%rip), %xmm0     # 0x4070
xorpd 0x10(%rsp), %xmm0
movsd 0xc578(%rip), %xmm1     # 0xf150
addsd %xmm1, %xmm1
divsd %xmm1, %xmm0
callq 0x1170
movsd %xmm0, 0x28(%rsp)
movsd 0x142d(%rip), %xmm2     # 0x4020
leaq 0x850e(%rip), %r14      # 0xb108
leaq 0x50(%rsp), %r15
movapd 0x10(%rsp), %xmm3
xorpd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
movapd %xmm2, 0x30(%rsp)
movapd %xmm3, 0x40(%rsp)
movapd %xmm3, %xmm0
callq 0x34c7
movsd 0x28(%rsp), %xmm2
mulsd %xmm2, %xmm0
mulsd %xmm2, %xmm1
movsd %xmm0, 0x84ce(%rip)     # 0xb108
movsd %xmm1, 0x84ce(%rip)     # 0xb110
xorpd 0x1426(%rip), %xmm1     # 0x4070
movsd %xmm0, 0x84c6(%rip)     # 0xb118
movlpd %xmm1, 0x84c6(%rip)     # 0xb120
movl 0xc4a8(%rip), %esi      # 0xf108
movq %r14, %rdi
movq %r15, %rdx
callq 0x2efb
movl 0xc49b(%rip), %ebp      # 0xf10c
movl 0xc490(%rip), %r12d     # 0xf108
movapd 0x10(%rsp), %xmm0
callq 0x34c7
movq %rbx, %rdi
movl %ebp, %esi
movq %r15, %rdx
movl %r12d, %ecx
callq 0x3280
movapd 0x40(%rsp), %xmm2
divsd %xmm0, %xmm1
ucomisd 0x13bb(%rip), %xmm1     # 0x4060
ja 0x2cad
movsd %xmm2, 0x8(%rsp)
xorpd %xmm0, %xmm0
cmpltsd %xmm1, %xmm0
andpd %xmm0, %xmm2
andnpd 0x30(%rsp), %xmm0
orpd %xmm2, %xmm0
andpd 0x13b4(%rip), %xmm1     # 0x4080
movsd 0x8(%rsp), %xmm3
addsd %xmm0, %xmm3
mulsd 0x133a(%rip), %xmm3     # 0x4018
cmpl $0x30, %r13d
ja 0x2cfd
incl %r13d
movsd 0x1369(%rip), %xmm2     # 0x4058
ucomisd %xmm1, %xmm2
movapd %xmm0, %xmm2
jbe 0x2c0f
movsd 0x1353(%rip), %xmm0     # 0x4058
ucomisd %xmm1, %xmm0
jbe 0x2d1d
addq $0x4078, %rsp           # imm = 0x4078
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x127f
jmp 0x2d0b