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

  // Minimal command-line check.
  if ( argc != 2 ) usage();
  nBytes = (unsigned int) atoi( argv[1] );

  // RtMidiOut and RtMidiIn constructors
  try {
    midiout = new RtMidiOut();
    midiin = new RtMidiIn();
  }
  catch ( RtMidiError &error ) {
    error.printMessage();
    goto cleanup;
  }

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

  try {
    if ( chooseMidiPort( midiin ) == false ) goto cleanup;
    if ( chooseMidiPort( midiout ) == false ) goto cleanup;
  }
  catch ( RtMidiError &error ) {
    error.printMessage();
    goto cleanup;
  }

  midiin->setCallback( &mycallback );

  message.push_back( 0xF6 );
  midiout->sendMessage( &message );
  SLEEP( 500 ); // pause a little

  // Create a long sysex message of numbered bytes and send it out ... twice.
  for ( int n=0; n<2; n++ ) {
    message.clear();
    message.push_back( 240 );
    for ( i=0; i<nBytes; i++ )
      message.push_back( i % 128 );
    message.push_back( 247 );
    midiout->sendMessage( &message );

    SLEEP( 500 ); // pause a little
  }

  // Clean up
 cleanup:
  delete midiout;
  delete midiin;

  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x4070
cmpl $0x2, -0x8(%rbp)
je 0x35e2
callq 0x3480
jmp 0x35cf
jmp 0x35e2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x3a2f
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x32b0
movl %eax, -0x40(%rbp)
movl $0x10, %edi
callq 0x3180
movq %rax, -0xd0(%rbp)
jmp 0x3605
movb $0x1, -0x72(%rbp)
leaq -0x71(%rbp), %rdi
movq %rdi, -0xd8(%rbp)
callq 0x3300
movq -0xd8(%rbp), %rdx
leaq 0x2a40(%rip), %rsi      # 0x6067
leaq -0x70(%rbp), %rdi
callq 0x4090
jmp 0x3632
movq -0xd0(%rbp), %rdi
xorl %esi, %esi
leaq -0x70(%rbp), %rdx
callq 0x3160
jmp 0x3646
movq -0xd0(%rbp), %rax
movb $0x0, -0x72(%rbp)
movq %rax, -0x18(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x30d0
leaq -0x71(%rbp), %rdi
callq 0x31c0
movl $0x10, %edi
callq 0x3180
movq %rax, -0xe0(%rbp)
jmp 0x367a
movb $0x1, -0x9a(%rbp)
leaq -0x99(%rbp), %rdi
movq %rdi, -0xe8(%rbp)
callq 0x3300
movq -0xe8(%rbp), %rdx
leaq 0x29da(%rip), %rsi      # 0x607c
leaq -0x98(%rbp), %rdi
callq 0x4090
jmp 0x36b0
movq -0xe0(%rbp), %rdi
xorl %esi, %esi
leaq -0x98(%rbp), %rdx
movl $0x64, %ecx
callq 0x3100
jmp 0x36cc
movq -0xe0(%rbp), %rax
movb $0x0, -0x9a(%rbp)
movq %rax, -0x20(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x30d0
leaq -0x99(%rbp), %rdi
callq 0x31c0
jmp 0x37f8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x37a3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x372f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x30d0
leaq -0x71(%rbp), %rdi
callq 0x31c0
testb $0x1, -0x72(%rbp)
jne 0x3740
jmp 0x3751
movq -0xd0(%rbp), %rdi
movl $0x10, %esi
callq 0x3190
jmp 0x37a3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x3779
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x30d0
leaq -0x99(%rbp), %rdi
callq 0x31c0
testb $0x1, -0x9a(%rbp)
jne 0x3790
jmp 0x37a1
movq -0xe0(%rbp), %rdi
movl $0x10, %esi
callq 0x3190
jmp 0x37a3
movl -0x4c(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x3a2f
movq -0x48(%rbp), %rdi
callq 0x30a0
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
callq *%rax
movl $0x2, -0xac(%rbp)
callq 0x32d0
jmp 0x37e4
movl -0xac(%rbp), %eax
subl $0x2, %eax
je 0x39cd
jmp 0x3a1a
movq -0x20(%rbp), %rdi
xorl %esi, %esi
movl $0x1, %ecx
movl %ecx, %edx
callq 0x4140
jmp 0x380c
movq -0x20(%rbp), %rdi
callq 0x3a50
movb %al, -0xe9(%rbp)
jmp 0x381d
movb -0xe9(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x387f
jmp 0x39cd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x3a2f
movq -0x48(%rbp), %rdi
callq 0x30a0
movq %rax, -0xb8(%rbp)
movq -0xb8(%rbp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
callq *%rax
movl $0x2, -0xac(%rbp)
callq 0x32d0
jmp 0x38a7
movq -0x18(%rbp), %rdi
callq 0x3a50
movb %al, -0xea(%rbp)
jmp 0x3890
movb -0xea(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x38a5
jmp 0x39cd
jmp 0x38bb
movl -0xac(%rbp), %eax
subl $0x2, %eax
je 0x39cd
jmp 0x3a1a
movq -0x20(%rbp), %rdi
leaq -0x406(%rip), %rsi      # 0x34c0
xorl %eax, %eax
movl %eax, %edx
callq 0x41a0
jmp 0x38d1
movb $-0xa, -0xb9(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0xb9(%rbp), %rsi
callq 0x41d0
jmp 0x38ea
movq -0x18(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x4200
jmp 0x38f9
movl $0x7a120, %edi          # imm = 0x7A120
callq 0x3270
jmp 0x3905
movl $0x0, -0xc0(%rbp)
cmpl $0x2, -0xc0(%rbp)
jge 0x39cb
leaq -0x38(%rbp), %rdi
movq %rdi, -0xf8(%rbp)
callq 0x4230
movq -0xf8(%rbp), %rdi
movb $-0x10, -0xc1(%rbp)
leaq -0xc1(%rbp), %rsi
callq 0x41d0
jmp 0x3948
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x40(%rbp), %eax
jae 0x3981
movb -0x3c(%rbp), %al
andb $0x7f, %al
movb %al, -0xc2(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0xc2(%rbp), %rsi
callq 0x41d0
jmp 0x3974
jmp 0x3976
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x394f
movb $-0x9, -0xc3(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0xc3(%rbp), %rsi
callq 0x41d0
jmp 0x399a
movq -0x18(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x4200
jmp 0x39a9
movl $0x7a120, %edi          # imm = 0x7A120
callq 0x3270
jmp 0x39b5
jmp 0x39b7
movl -0xc0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc0(%rbp)
jmp 0x390f
jmp 0x39cd
movq -0x18(%rbp), %rax
movq %rax, -0x100(%rbp)
cmpq $0x0, %rax
je 0x39eb
movq -0x100(%rbp), %rdi
movq (%rdi), %rax
callq *0x40(%rax)
movq -0x20(%rbp), %rax
movq %rax, -0x108(%rbp)
cmpq $0x0, %rax
je 0x3a09
movq -0x108(%rbp), %rdi
movq (%rdi), %rax
callq *0x40(%rax)
movl $0x0, -0x4(%rbp)
movl $0x1, -0xac(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x4250
movl -0x4(%rbp), %eax
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
leaq -0x38(%rbp), %rdi
callq 0x4250
movq -0x48(%rbp), %rdi
callq 0x32f0
nopw %cs:(%rax,%rax)