// File: /workspace/github_cpp_makefile_star2_O1/rowdyroad[P]dtmfdecoder/example.cpp
// Function: main
int main (int argc, char *argv[])
{
  if (argc < 2) {
    std::cout << "Usage: " << argv[0] << " something.wav" << std::endl;
    return 1;
  }

  WAVHeader header;

  FILE * fp = loadWaveFile(argv[1], header);

  size_t timestamp = 0;
  size_t read_length = 0;

  std::vector<int16_t> frames(400);

  TextHandler handler;
  DTMFDecoder<> decoder(&handler);
  std::cout << "Detecting begin..." << std::endl;
  while (read_length < header.subchunk2Size) {
    int chunk_length = fread(frames.data(), sizeof(int16_t), frames.size(), fp);

    if (chunk_length <= 0) {
      break;
    }
    read_length += chunk_length * sizeof(int16_t);
    decoder.decode(frames, chunk_length);
  }

  fclose(fp);
  std::cout << "Detecting complete!" << std::endl;
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x158, %rsp            # imm = 0x158
movq %rsi, %r14
cmpl $0x1, %edi
jg 0x24ee
movq 0x3b29(%rip), %rbx      # 0x5fd8
leaq 0x1be2(%rip), %rsi      # 0x4098
movl $0x7, %edx
movq %rbx, %rdi
callq 0x21b0
movq (%r14), %r14
testq %r14, %r14
je 0x2763
movq %r14, %rdi
callq 0x2090
movq 0x3afa(%rip), %rdi      # 0x5fd8
movq %r14, %rsi
movq %rax, %rdx
callq 0x21b0
jmp 0x277a
movl $0x46464952, 0x28(%rsp) # imm = 0x46464952
movabsq $0x20746d6645564157, %rax # imm = 0x20746D6645564157
movq %rax, 0x38(%rsp)
movq $0x10, 0x40(%rsp)
movw $0x1, 0x48(%rsp)
movl $0x61746164, 0x64(%rsp) # imm = 0x61746164
movq $0x0, 0x68(%rsp)
movq 0x8(%r14), %rsi
leaq 0x70(%rsp), %rdi
movq %rsp, %rdx
callq 0x2826
leaq 0x70(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x242c
movq %rax, %rbx
leaq 0x80(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x256a
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x2190
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
movl $0x320, %edi            # imm = 0x320
callq 0x2180
movq %rax, (%rsp)
movq %rax, 0x8(%rsp)
movq %rax, %r14
addq $0x320, %r14            # imm = 0x320
movq %r14, 0x10(%rsp)
movl $0x320, %edx            # imm = 0x320
movq %rax, %rdi
xorl %esi, %esi
callq 0x20d0
movq %r14, 0x8(%rsp)
leaq 0x37c1(%rip), %rax      # 0x5d78
leaq 0x20(%rsp), %rsi
movq %rax, (%rsi)
leaq 0x70(%rsp), %rdi
movsd 0x1a3c(%rip), %xmm0     # 0x4008
movl $0x1f40, %edx           # imm = 0x1F40
movl $0x32, %ecx
movl $0xa, %r8d
callq 0x2864
movq 0x39f0(%rip), %r14      # 0x5fd8
leaq 0x1ac0(%rip), %rsi      # 0x40af
movl $0x12, %edx
movq %r14, %rdi
callq 0x21b0
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq 0x39be(%rip), %rdi      # 0x5fd8
callq 0x2030
movq %rax, %rdi
callq 0x20f0
movq 0x68(%rsp), %rbp
xorl %r14d, %r14d
movq %rsp, %r15
cmpq %rbp, %r14
jae 0x267e
movq (%rsp), %rdi
movq 0x8(%rsp), %rdx
subq %rdi, %rdx
sarq %rdx
movl $0x2, %esi
movq %rbx, %rcx
callq 0x21f0
movq %rax, %r12
testl %r12d, %r12d
jle 0x2679
movl %r12d, %r13d
andl $0x7fffffff, %r13d      # imm = 0x7FFFFFFF
leaq 0x70(%rsp), %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x2a4e
leaq (%r14,%r13,2), %r14
testl %r12d, %r12d
jg 0x2632
movq %rbx, %rdi
callq 0x2170
movq 0x394b(%rip), %rbx      # 0x5fd8
leaq 0x1a2e(%rip), %rsi      # 0x40c2
movl $0x13, %edx
movq %rbx, %rdi
callq 0x21b0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq 0x3919(%rip), %rdi      # 0x5fd8
callq 0x2030
movq %rax, %rdi
callq 0x20f0
leaq 0x128(%rsp), %rbx
movq %rbx, %rdi
callq 0x2ed4
movq -0x18(%rbx), %rdi
testq %rdi, %rdi
je 0x26f5
movq 0x120(%rsp), %rsi
subq %rdi, %rsi
callq 0x2190
movq 0xf8(%rsp), %rdi
testq %rdi, %rdi
je 0x2712
movq 0x108(%rsp), %rsi
subq %rdi, %rsi
callq 0x2190
movq 0x90(%rsp), %rdi
testq %rdi, %rdi
je 0x272f
movq 0xa0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2190
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
je 0x2749
movq 0x88(%rsp), %rsi
subq %rdi, %rsi
callq 0x2190
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x275f
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x2190
xorl %eax, %eax
jmp 0x27ba
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x2230
leaq 0x191f(%rip), %rsi      # 0x40a0
movl $0xe, %edx
movq %rbx, %rdi
callq 0x21b0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20f0
movl $0x1, %eax
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x2808
jmp 0x27f4
movq %rax, %rbx
leaq 0x80(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x281e
movq 0x80(%rsp), %rsi
incq %rsi
jmp 0x2819
movq %rax, %rbx
jmp 0x281e
jmp 0x27fb
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x2cd4
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x281e
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x2190
movq %rbx, %rdi
callq 0x2240