// File: /workspace/github_cpp_makefile_star2_O2/tobias93[P]piano/rtmidi_build/tests/qmidiin.cpp
// Function: main
int main( int argc, char *argv[] )
{
  RtMidiIn *midiin = 0;
  std::vector<unsigned char> message;
  int nBytes, i;
  double stamp;

  // Minimal command-line check.
  if ( argc > 2 ) usage();

  // RtMidiIn constructor
  try {
    midiin = new RtMidiIn();
  }
  catch ( RtMidiError &error ) {
    error.printMessage();
    exit( EXIT_FAILURE );
  }

  // Check available ports vs. specified.
  unsigned int port = 0;
  unsigned int nPorts = midiin->getPortCount();
  if ( argc == 2 ) port = (unsigned int) atoi( argv[1] );
  if ( port >= nPorts ) {
    delete midiin;
    std::cout << "Invalid port specifier!\n";
    usage();
  }

  try {
    midiin->openPort( port );
  }
  catch ( RtMidiError &error ) {
    error.printMessage();
    goto cleanup;
  }

  // Don't ignore sysex, timing, or active sensing messages.
  midiin->ignoreTypes( false, false, false );

  // Install an interrupt handler function.
  done = false;
  (void) signal(SIGINT, finish);

  // Periodically check input queue.
  std::cout << "Reading MIDI from port " << midiin->getPortName() << " ... quit with Ctrl-C.\n";
  while ( !done ) {
    stamp = midiin->getMessage( &message );
    nBytes = message.size();
    for ( i=0; i<nBytes; i++ )
      std::cout << "Byte " << i << " = " << (int)message[i] << ", ";
    if ( nBytes > 0 )
      std::cout << "stamp = " << stamp << std::endl;

    // Sleep for 10 milliseconds.
    SLEEP( 10 );
  }

  // Clean up
 cleanup:
  delete midiin;

  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
andq $0x0, 0x20(%rsp)
cmpl $0x3, %edi
jge 0x251d
movq %rsi, %r14
movl %edi, %ebp
pushq $0x10
popq %rdi
callq 0x20f0
movq %rax, %rbx
leaq 0xd08(%rip), %rsi       # 0x3050
leaq 0x78(%rsp), %rdi
leaq 0x38(%rsp), %rdx
callq 0x2628
leaq 0x78(%rsp), %rdx
pushq $0x64
popq %rcx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x2090
leaq 0x78(%rsp), %rdi
callq 0x2060
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x10(%rax)
movl %eax, %r12d
xorl %r15d, %r15d
cmpl $0x2, %ebp
jne 0x2393
movq 0x8(%r14), %rdi
callq 0x2150
movl %eax, %r15d
cmpl %r12d, %r15d
jae 0x2522
leaq 0xcda(%rip), %rsi       # 0x307d
leaq 0x58(%rsp), %rdi
leaq 0x38(%rsp), %rdx
movq %rbx, 0x8(%rsp)
callq 0x2628
movq (%rbx), %rax
leaq 0x58(%rsp), %rdx
movq %rbx, %rdi
movl %r15d, %esi
callq *(%rax)
leaq 0x58(%rsp), %rdi
callq 0x2060
movq 0x8(%rbx), %rdi
movq (%rdi), %rax
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq *0x48(%rax)
movb $0x0, 0x2d12(%rip)      # 0x50fa
leaq 0x230(%rip), %rsi       # 0x261f
pushq $0x2
popq %rdi
callq 0x2110
movq 0x2bda(%rip), %rdi      # 0x4fd8
leaq 0xc85(%rip), %rsi       # 0x308a
callq 0x20e0
movq %rax, %r14
movq (%rbx), %rax
leaq 0x38(%rsp), %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq *0x18(%rax)
leaq 0x38(%rsp), %rsi
movq %r14, %rdi
callq 0x20d0
leaq 0xc71(%rip), %rsi       # 0x30a2
movq %rax, %rdi
callq 0x20e0
leaq 0x38(%rsp), %rdi
callq 0x2060
movq 0x2b8e(%rip), %r15      # 0x4fd8
leaq 0xc69(%rip), %r13       # 0x30ba
leaq 0xc70(%rip), %rbp       # 0x30c8
leaq 0xc61(%rip), %r12       # 0x30c0
cmpb $0x0, 0x2c94(%rip)      # 0x50fa
jne 0x2580
movq 0x8(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x2664
movsd %xmm0, 0x30(%rsp)
movl 0x18(%rsp), %eax
subl 0x10(%rsp), %eax
testl %eax, %eax
movl $0x0, %ebx
movl %eax, 0x4(%rsp)
cmovgl %eax, %ebx
xorl %r14d, %r14d
cmpq %r14, %rbx
je 0x24e2
movq %r15, %rdi
movq %r13, %rsi
callq 0x20e0
movq %rax, %rdi
movl %r14d, %esi
callq 0x2180
movq %rax, %rdi
movq %rbp, %rsi
callq 0x20e0
movq 0x10(%rsp), %rcx
movzbl (%rcx,%r14), %esi
movq %rax, %rdi
callq 0x2180
movq %rax, %rdi
movq %r12, %rsi
callq 0x20e0
incq %r14
jmp 0x249a
cmpl $0x0, 0x4(%rsp)
jle 0x250e
movq %r15, %rdi
leaq 0xbd0(%rip), %rsi       # 0x30c3
callq 0x20e0
movq %rax, %rdi
movsd 0x30(%rsp), %xmm0
callq 0x2160
movq %rax, %rdi
callq 0x2070
movl $0x2710, %edi           # imm = 0x2710
callq 0x2130
jmp 0x245f
callq 0x22dc
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x40(%rax)
movq 0x2aa6(%rip), %rdi      # 0x4fd8
leaq 0xb2b(%rip), %rsi       # 0x3064
callq 0x20e0
callq 0x22dc
jmp 0x260a
movq %rdx, %r15
movq %rax, %r14
leaq 0x58(%rsp), %rdi
callq 0x2060
jmp 0x2560
movq %rdx, %r15
movq %rax, %r14
cmpl $0x1, %r15d
jne 0x260d
movq %r14, %rdi
callq 0x2040
movq (%rax), %rcx
movq %rax, %rdi
callq *0x18(%rcx)
callq 0x2170
movq 0x8(%rsp), %rdi
movq (%rdi), %rax
callq *0x40(%rax)
leaq 0x10(%rsp), %rdi
callq 0x2678
xorl %eax, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x260a
movq %rdx, %r15
movq %rax, %r14
leaq 0x78(%rsp), %rdi
callq 0x2060
jmp 0x25c3
movq %rdx, %r15
movq %rax, %r14
pushq $0x10
popq %rsi
movq %rbx, %rdi
callq 0x2100
jmp 0x25d6
movq %rdx, %r15
movq %rax, %r14
cmpl $0x1, %r15d
jne 0x260d
movq %r14, %rdi
callq 0x2040
movq (%rax), %rcx
movq %rax, %rdi
callq *0x18(%rcx)
pushq $0x1
popq %rdi
callq 0x2120
jmp 0x260a
movq %rax, %r14
leaq 0x38(%rsp), %rdi
callq 0x2060
jmp 0x260d
jmp 0x260a
jmp 0x260a
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x2678
movq %r14, %rdi
callq 0x2190