// File: 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
movq %rsp, %rbp
subq $0x170, %rsp            # imm = 0x170
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x2940
cmpl $0x2, -0x8(%rbp)
jle 0x242a
callq 0x23a0
jmp 0x2417
jmp 0x242a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x2914
movl $0x10, %edi
callq 0x2110
movq %rax, -0xe8(%rbp)
jmp 0x243d
movb $0x1, -0x72(%rbp)
leaq -0x71(%rbp), %rdi
movq %rdi, -0xf0(%rbp)
callq 0x2220
movq -0xf0(%rbp), %rdx
leaq 0x1bf1(%rip), %rsi      # 0x4050
leaq -0x70(%rbp), %rdi
callq 0x2960
jmp 0x246a
movq -0xe8(%rbp), %rdi
xorl %esi, %esi
leaq -0x70(%rbp), %rdx
movl $0x64, %ecx
callq 0x20a0
jmp 0x2483
movq -0xe8(%rbp), %rax
movb $0x0, -0x72(%rbp)
movq %rax, -0x18(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x2070
leaq -0x71(%rbp), %rdi
callq 0x2150
jmp 0x252f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x24fe
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x24da
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x2070
leaq -0x71(%rbp), %rdi
callq 0x2150
testb $0x1, -0x72(%rbp)
jne 0x24eb
jmp 0x24fc
movq -0xe8(%rbp), %rdi
movl $0x10, %esi
callq 0x2120
jmp 0x24fe
movl -0x4c(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x2914
movq -0x48(%rbp), %rdi
callq 0x2050
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
movl $0x1, %edi
callq 0x2190
movl $0x0, -0x84(%rbp)
movq -0x18(%rbp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movl %eax, -0xf4(%rbp)
jmp 0x254e
movl -0xf4(%rbp), %eax
movl %eax, -0x88(%rbp)
cmpl $0x2, -0x8(%rbp)
jne 0x2573
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x21e0
movl %eax, -0x84(%rbp)
movl -0x84(%rbp), %eax
cmpl -0x88(%rbp), %eax
jb 0x25bd
movq -0x18(%rbp), %rax
movq %rax, -0x100(%rbp)
cmpq $0x0, %rax
je 0x259f
movq -0x100(%rbp), %rdi
movq (%rdi), %rax
callq *0x40(%rax)
movq 0x3a32(%rip), %rdi      # 0x5fd8
leaq 0x1ab7(%rip), %rsi      # 0x4064
callq 0x2100
jmp 0x25b4
callq 0x23a0
jmp 0x25bb
jmp 0x25bd
movq -0x18(%rbp), %rax
movq %rax, -0x118(%rbp)
movl -0x84(%rbp), %eax
movl %eax, -0x10c(%rbp)
leaq -0xa9(%rbp), %rdi
movq %rdi, -0x108(%rbp)
callq 0x2220
movq -0x108(%rbp), %rdx
leaq 0x1a88(%rip), %rsi      # 0x407d
leaq -0xa8(%rbp), %rdi
callq 0x2960
jmp 0x2603
movl -0x10c(%rbp), %esi
movq -0x118(%rbp), %rdi
movq (%rdi), %rax
movq (%rax), %rax
leaq -0xa8(%rbp), %rdx
callq *%rax
jmp 0x2621
leaq -0xa8(%rbp), %rdi
callq 0x2070
leaq -0xa9(%rbp), %rdi
callq 0x2150
jmp 0x26c5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x2664
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x2070
leaq -0xa9(%rbp), %rdi
callq 0x2150
movl -0x4c(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x2914
movq -0x48(%rbp), %rdi
callq 0x2050
movq %rax, -0xb8(%rbp)
movq -0xb8(%rbp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
callq *%rax
movl $0x2, -0xbc(%rbp)
callq 0x21f0
jmp 0x26b1
movl -0xbc(%rbp), %eax
subl $0x2, %eax
je 0x28d0
jmp 0x28ff
movq -0x18(%rbp), %rdi
xorl %ecx, %ecx
movl %ecx, %esi
movl %ecx, %edx
callq 0x2a10
jmp 0x26d6
movb $0x0, 0x3a75(%rip)      # 0x6152
leaq 0x24c(%rip), %rsi       # 0x2930
movl $0x2, %edi
callq 0x2180
movq 0x38e3(%rip), %rdi      # 0x5fd8
leaq 0x198e(%rip), %rsi      # 0x408a
callq 0x2100
movq %rax, -0x120(%rbp)
jmp 0x270a
movq -0x18(%rbp), %rsi
movq (%rsi), %rax
movq 0x18(%rax), %rax
leaq -0xe0(%rbp), %rdi
xorl %edx, %edx
callq *%rax
jmp 0x2722
movq -0x120(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x20f0
movq %rax, -0x128(%rbp)
jmp 0x273e
movq -0x128(%rbp), %rdi
leaq 0x1956(%rip), %rsi      # 0x40a2
callq 0x2100
jmp 0x2753
leaq -0xe0(%rbp), %rdi
callq 0x2070
movb 0x39ed(%rip), %al       # 0x6152
xorb $-0x1, %al
testb $0x1, %al
jne 0x2770
jmp 0x28ce
movq -0x18(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x2a70
movsd %xmm0, -0x130(%rbp)
jmp 0x2787
movsd -0x130(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x2aa0
movl %eax, -0x34(%rbp)
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x34(%rbp), %eax
jge 0x286a
movq 0x381e(%rip), %rdi      # 0x5fd8
leaq 0x18f9(%rip), %rsi      # 0x40ba
callq 0x2100
movq %rax, -0x138(%rbp)
jmp 0x27cf
movq -0x138(%rbp), %rdi
movl -0x38(%rbp), %esi
callq 0x2200
movq %rax, -0x140(%rbp)
jmp 0x27e7
movq -0x140(%rbp), %rdi
leaq 0x18d3(%rip), %rsi      # 0x40c8
callq 0x2100
movq %rax, -0x148(%rbp)
jmp 0x2803
movslq -0x38(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0x2ac0
movq -0x148(%rbp), %rdi
movzbl (%rax), %esi
callq 0x2200
movq %rax, -0x150(%rbp)
jmp 0x2828
movq -0x150(%rbp), %rdi
leaq 0x188a(%rip), %rsi      # 0x40c0
callq 0x2100
jmp 0x283d
jmp 0x283f
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x27a7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x2070
jmp 0x2914
cmpl $0x0, -0x34(%rbp)
jle 0x28bd
movq 0x3761(%rip), %rdi      # 0x5fd8
leaq 0x1845(%rip), %rsi      # 0x40c3
callq 0x2100
movq %rax, -0x158(%rbp)
jmp 0x288c
movq -0x158(%rbp), %rdi
movsd -0x40(%rbp), %xmm0
callq 0x2240
movq %rax, -0x160(%rbp)
jmp 0x28a6
movq -0x160(%rbp), %rdi
movq 0x3714(%rip), %rsi      # 0x5fc8
callq 0x2130
jmp 0x28bb
jmp 0x28bd
movl $0x2710, %edi           # imm = 0x2710
callq 0x21b0
jmp 0x28c9
jmp 0x275f
jmp 0x28d0
movq -0x18(%rbp), %rax
movq %rax, -0x168(%rbp)
cmpq $0x0, %rax
je 0x28ee
movq -0x168(%rbp), %rdi
movq (%rdi), %rax
callq *0x40(%rax)
movl $0x0, -0x4(%rbp)
movl $0x1, -0xbc(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x2ae0
movl -0x4(%rbp), %eax
addq $0x170, %rsp            # imm = 0x170
popq %rbp
retq
leaq -0x30(%rbp), %rdi
callq 0x2ae0
movq -0x48(%rbp), %rdi
callq 0x2210
nopw %cs:(%rax,%rax)