// File: rowdyroad[P]dtmfdecoder/./DTMFDecoder.h
// Function: DTMFDecoder<short>::goertzelFunction(unsigned long, std::vector<double, std::allocator<double>> const&)
double goertzelFunction(size_t frequency, const std::vector<double>& samples)
      {
          size_t scalingFactor = samples.size() / 2;
          double k = 0.5 + (((double)samples.size() * frequency) / sampleRate_),
                 omega = (2.0 * M_PI * k) / samples.size(),
                 sine = sin(omega),
                 cosine =cos(omega),
                 coeff = 2.0 * cosine,
                 q0 = 0,
                 q1 = 0,
                 q2 = 0;

          for (auto sample : samples) {
              q0 = coeff * q1 - q2 + sample;
              q2 = q1;
              q1 = q0;
          }
          double real = (q1 - q2 * cosine) / scalingFactor;
          double imag = (q2 * sine) / scalingFactor;
          return sqrtf(real*real + imag*imag);
      }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0x18(%rbp), %rdi
callq 0x5660
shrq %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rdi
callq 0x5660
movq %rax, %rcx
movq -0xc8(%rbp), %rax
movq %rcx, %xmm0
movaps 0x94f(%rip), %xmm3      # 0x9060
movaps %xmm3, -0xc0(%rbp)
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
movapd 0x94c(%rip), %xmm2      # 0x9070
movaps %xmm2, -0xb0(%rbp)
subpd %xmm2, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movq -0x10(%rbp), %xmm1
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
subpd %xmm2, %xmm1
movaps %xmm1, %xmm4
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm4, %xmm1
mulsd %xmm1, %xmm0
movq 0x50(%rax), %xmm1
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd 0x8d6(%rip), %xmm1      # 0x9050
addsd %xmm1, %xmm0
movsd %xmm0, -0x28(%rbp)
movsd -0x28(%rbp), %xmm0
movsd 0x890(%rip), %xmm1      # 0x9020
mulsd %xmm1, %xmm0
movsd %xmm0, -0x98(%rbp)
movq -0x18(%rbp), %rdi
callq 0x5660
movaps -0xc0(%rbp), %xmm3
movaps -0xb0(%rbp), %xmm2
movsd -0x98(%rbp), %xmm0
movq %rax, %xmm1
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
movsd -0x30(%rbp), %xmm0
callq 0x2050
movsd %xmm0, -0x38(%rbp)
movsd -0x30(%rbp), %xmm0
callq 0x22e0
movsd %xmm0, -0x40(%rbp)
movsd 0x846(%rip), %xmm0      # 0x9048
mulsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x50(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x58(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x60(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rdi
callq 0x8980
movq %rax, -0x70(%rbp)
movq -0x68(%rbp), %rdi
callq 0x89b0
movq %rax, -0x78(%rbp)
leaq -0x70(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x89e0
testb $0x1, %al
jne 0x8859
jmp 0x88c2
leaq -0x70(%rbp), %rdi
callq 0x8a20
movsd (%rax), %xmm0
movsd %xmm0, -0x80(%rbp)
movsd -0x48(%rbp), %xmm0
movsd -0x58(%rbp), %xmm2
movsd -0x60(%rbp), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
addsd -0x80(%rbp), %xmm0
movsd %xmm0, -0x50(%rbp)
movsd -0x58(%rbp), %xmm0
movsd %xmm0, -0x60(%rbp)
movsd -0x50(%rbp), %xmm0
movsd %xmm0, -0x58(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x8a40
jmp 0x8846
movsd -0x58(%rbp), %xmm0
movsd -0x60(%rbp), %xmm1
movsd -0x40(%rbp), %xmm2
mulsd %xmm2, %xmm1
subsd %xmm1, %xmm0
movq -0x20(%rbp), %xmm1
movaps 0x77b(%rip), %xmm3      # 0x9060
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
movapd 0x77f(%rip), %xmm2      # 0x9070
subpd %xmm2, %xmm1
movaps %xmm1, %xmm4
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm4, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x88(%rbp)
movsd -0x60(%rbp), %xmm0
movsd -0x38(%rbp), %xmm1
mulsd %xmm1, %xmm0
movq -0x20(%rbp), %xmm1
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x90(%rbp)
movsd -0x88(%rbp), %xmm0
movsd -0x88(%rbp), %xmm2
movsd -0x90(%rbp), %xmm1
mulsd -0x90(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
callq 0x22d0
cvtss2sd %xmm0, %xmm0
addq $0xd0, %rsp
popq %rbp
retq
nopl (%rax)