// File: /workspace/github_c_makefile_star2_O2/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, 0xca0d(%rip)      # 0xf0f8
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, 0xa9fc(%rip)      # 0xd0f8
andq $0x0, 0xa9fc(%rip)      # 0xd100
movabsq $-0x4010000000000000, %rax # imm = 0xBFF0000000000000
movq %rax, 0xa9f3(%rip)      # 0xd108
andq $0x0, 0xa9f3(%rip)      # 0xd110
movsd 0xc9fb(%rip), %xmm0     # 0xf120
mulsd 0x18db(%rip), %xmm0     # 0x4008
cmpb $0x1, 0xca0c(%rip)      # 0xf140
jne 0x2768
callq 0x3181
movsd %xmm0, 0x89b5(%rip)     # 0xb0f8
movsd %xmm1, 0x89b5(%rip)     # 0xb100
xorpd 0x191d(%rip), %xmm1     # 0x4070
movsd %xmm0, 0x89ad(%rip)     # 0xb108
movlpd %xmm1, 0x89ad(%rip)     # 0xb110
jmp 0x28d2
leaq 0xa989(%rip), %rdi      # 0xd0f8
pushq $0x2
popq %rsi
leaq 0x2060(%rsp), %rbx
movq %rbx, %rdx
movapd %xmm0, 0x10(%rsp)
callq 0x2bcd
movapd 0x18e0(%rip), %xmm0     # 0x4070
xorpd 0x10(%rsp), %xmm0
movsd 0xc9aa(%rip), %xmm1     # 0xf148
addsd %xmm1, %xmm1
divsd %xmm1, %xmm0
callq 0x1160
movsd %xmm0, 0x28(%rsp)
movapd 0x10(%rsp), %xmm0
movsd 0x1861(%rip), %xmm4     # 0x4020
xorl %r13d, %r13d
leaq 0x892f(%rip), %r14      # 0xb0f8
leaq 0x50(%rsp), %r15
xorl %eax, %eax
xorpd %xmm1, %xmm1
movsd %xmm1, 0x8(%rsp)
cmpl $0x31, %r13d
ja 0x28ce
testb $0x1, %al
jne 0x28ce
movapd %xmm4, 0x30(%rsp)
movapd %xmm0, 0x40(%rsp)
callq 0x3181
movsd 0x28(%rsp), %xmm2
mulsd %xmm2, %xmm0
mulsd %xmm2, %xmm1
movsd %xmm0, 0x88e5(%rip)     # 0xb0f8
movsd %xmm1, 0x88e5(%rip)     # 0xb100
xorpd 0x184d(%rip), %xmm1     # 0x4070
movsd %xmm0, 0x88dd(%rip)     # 0xb108
movlpd %xmm1, 0x88dd(%rip)     # 0xb110
movl 0xc8bf(%rip), %esi      # 0xf0f8
movq %r14, %rdi
movq %r15, %rdx
callq 0x2bcd
movl 0xc8b2(%rip), %ebp      # 0xf0fc
movl 0xc8a7(%rip), %r12d     # 0xf0f8
movapd 0x10(%rsp), %xmm0
callq 0x3181
movq %rbx, %rdi
movl %ebp, %esi
movq %r15, %rdx
movl %r12d, %ecx
callq 0x2f74
movapd 0x40(%rsp), %xmm3
divsd %xmm0, %xmm1
ucomisd 0x17da(%rip), %xmm1     # 0x4058
ja 0x2886
movsd %xmm3, 0x8(%rsp)
xorpd %xmm4, %xmm4
cmpltsd %xmm1, %xmm4
andpd %xmm4, %xmm3
andnpd 0x30(%rsp), %xmm4
andpd 0x17df(%rip), %xmm1     # 0x4080
movsd 0x17a7(%rip), %xmm2     # 0x4050
ucomisd %xmm1, %xmm2
orpd %xmm3, %xmm4
seta %al
movapd %xmm4, %xmm0
addsd 0x8(%rsp), %xmm0
mulsd 0x1752(%rip), %xmm0     # 0x4018
incl %r13d
jmp 0x27da
testb $0x1, %al
je 0x28e4
addq $0x4078, %rsp           # imm = 0x4078
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x46f5(%rip), %rax      # 0x6fe0
movq (%rax), %rcx
leaq 0x1f0a(%rip), %rdi      # 0x47ff
pushq $0x26
popq %rsi
pushq $0x1
popq %rdx
callq 0x1190
jmp 0x28d2