// File: tobias93[P]piano/rtmidi_build/tests/sysextest.cpp
// Function: chooseMidiPort(RtMidi*)
bool chooseMidiPort( RtMidi *rtmidi )
{
  bool isInput = false;
  if ( typeid( *rtmidi ) == typeid( RtMidiIn ) )
    isInput = true;

  if ( isInput )
    std::cout << "\nWould you like to open a virtual input port? [y/N] ";
  else
    std::cout << "\nWould you like to open a virtual output port? [y/N] ";

  std::string keyHit;
  std::getline( std::cin, keyHit );
  if ( keyHit == "y" ) {
    rtmidi->openVirtualPort();
    return true;
  }

  std::string portName;
  unsigned int i = 0, nPorts = rtmidi->getPortCount();
  if ( nPorts == 0 ) {
    if ( isInput )
      std::cout << "No input ports available!" << std::endl;
    else
      std::cout << "No output ports available!" << std::endl;
    return false;
  }

  if ( nPorts == 1 ) {
    std::cout << "\nOpening " << rtmidi->getPortName() << std::endl;
  }
  else {
    for ( i=0; i<nPorts; i++ ) {
      portName = rtmidi->getPortName(i);
      if ( isInput )
        std::cout << "  Input port #" << i << ": " << portName << '\n';
      else
        std::cout << "  Output port #" << i << ": " << portName << '\n';
    }

    do {
      std::cout << "\nChoose a port number: ";
      std::cin >> i;
    } while ( i >= nPorts );
  }

  std::cout << std::endl;
  rtmidi->openPort( i );

  return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1b0, %rsp            # imm = 0x1B0
movq %rdi, -0x10(%rbp)
movb $0x0, -0x11(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x108(%rbp)
cmpq $0x0, %rax
jne 0x3a79
callq 0x31e0
movq -0x108(%rbp), %rax
movq (%rax), %rax
movq -0x8(%rax), %rdi
movq 0x5522(%rip), %rsi      # 0x8fb0
callq 0x42b0
testb $0x1, %al
jne 0x3a99
jmp 0x3a9d
movb $0x1, -0x11(%rbp)
testb $0x1, -0x11(%rbp)
je 0x3ab8
movq 0x5526(%rip), %rdi      # 0x8fd0
leaq 0x25df(%rip), %rsi      # 0x6090
callq 0x3170
jmp 0x3acb
movq 0x5511(%rip), %rdi      # 0x8fd0
leaq 0x25ff(%rip), %rsi      # 0x60c5
callq 0x3170
leaq -0x38(%rbp), %rdi
movq %rdi, -0x110(%rbp)
callq 0x3250
movq -0x110(%rbp), %rsi
movq 0x54f7(%rip), %rdi      # 0x8fe0
callq 0x3050
jmp 0x3af0
leaq 0x2604(%rip), %rsi      # 0x60fb
leaq -0x38(%rbp), %rdi
callq 0x4320
movb %al, -0x111(%rbp)
jmp 0x3b08
movb -0x111(%rbp), %al
testb $0x1, %al
jne 0x3b17
jmp 0x3bc5
movq -0x10(%rbp), %rax
movq %rax, -0x128(%rbp)
leaq -0x69(%rbp), %rdi
movq %rdi, -0x120(%rbp)
callq 0x3300
movq -0x120(%rbp), %rdx
leaq 0x25bd(%rip), %rsi      # 0x60fd
leaq -0x68(%rbp), %rdi
callq 0x4090
jmp 0x3b4b
movq -0x128(%rbp), %rdi
movq (%rdi), %rax
movq 0x8(%rax), %rax
leaq -0x68(%rbp), %rsi
callq *%rax
jmp 0x3b61
leaq -0x68(%rbp), %rdi
callq 0x30d0
leaq -0x69(%rbp), %rdi
callq 0x31c0
movb $0x1, -0x1(%rbp)
movl $0x1, -0x70(%rbp)
jmp 0x3fe4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x3ffb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x3bb7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x30d0
leaq -0x69(%rbp), %rdi
callq 0x31c0
jmp 0x3ffb
leaq -0x90(%rbp), %rdi
callq 0x3250
movl $0x0, -0x94(%rbp)
movq -0x10(%rbp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movl %eax, -0x12c(%rbp)
jmp 0x3bf0
movl -0x12c(%rbp), %eax
movl %eax, -0x98(%rbp)
cmpl $0x0, -0x98(%rbp)
jne 0x3c96
testb $0x1, -0x11(%rbp)
je 0x3c53
movq 0x53ba(%rip), %rdi      # 0x8fd0
leaq 0x24e7(%rip), %rsi      # 0x6104
callq 0x3170
movq %rax, -0x138(%rbp)
jmp 0x3c2b
movq -0x138(%rbp), %rdi
movq 0x5387(%rip), %rsi      # 0x8fc0
callq 0x31a0
jmp 0x3c40
jmp 0x3c86
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x3fd6
movq 0x5376(%rip), %rdi      # 0x8fd0
leaq 0x24bd(%rip), %rsi      # 0x611e
callq 0x3170
movq %rax, -0x140(%rbp)
jmp 0x3c6f
movq -0x140(%rbp), %rdi
movq 0x5343(%rip), %rsi      # 0x8fc0
callq 0x31a0
jmp 0x3c84
jmp 0x3c86
movb $0x0, -0x1(%rbp)
movl $0x1, -0x70(%rbp)
jmp 0x3fc8
cmpl $0x1, -0x98(%rbp)
jne 0x3d36
movq 0x5326(%rip), %rdi      # 0x8fd0
leaq 0x2488(%rip), %rsi      # 0x6139
callq 0x3170
movq %rax, -0x148(%rbp)
jmp 0x3cbf
movq -0x10(%rbp), %rsi
movq (%rsi), %rax
movq 0x18(%rax), %rax
leaq -0xb8(%rbp), %rdi
xorl %edx, %edx
callq *%rax
jmp 0x3cd7
movq -0x148(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x3150
movq %rax, -0x150(%rbp)
jmp 0x3cf3
movq -0x150(%rbp), %rdi
movq 0x52bf(%rip), %rsi      # 0x8fc0
callq 0x31a0
jmp 0x3d08
leaq -0xb8(%rbp), %rdi
callq 0x30d0
jmp 0x3ef6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x30d0
jmp 0x3fd6
movl $0x0, -0x94(%rbp)
movl -0x94(%rbp), %eax
cmpl -0x98(%rbp), %eax
jae 0x3eb8
movq -0x10(%rbp), %rsi
movl -0x94(%rbp), %edx
movq (%rsi), %rax
movq 0x18(%rax), %rax
leaq -0xd8(%rbp), %rdi
callq *%rax
jmp 0x3d6e
leaq -0x90(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x3220
leaq -0xd8(%rbp), %rdi
callq 0x30d0
testb $0x1, -0x11(%rbp)
je 0x3e1e
movq 0x5232(%rip), %rdi      # 0x8fd0
leaq 0x239e(%rip), %rsi      # 0x6143
callq 0x3170
movq %rax, -0x158(%rbp)
jmp 0x3db3
movq -0x158(%rbp), %rdi
movl -0x94(%rbp), %esi
callq 0x3240
movq %rax, -0x160(%rbp)
jmp 0x3dce
movq -0x160(%rbp), %rdi
leaq 0x239b(%rip), %rsi      # 0x6177
callq 0x3170
movq %rax, -0x168(%rbp)
jmp 0x3dea
movq -0x168(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x3150
movq %rax, -0x170(%rbp)
jmp 0x3e06
movq -0x170(%rbp), %rdi
movl $0xa, %esi
callq 0x3200
jmp 0x3e19
jmp 0x3ea2
movq 0x51ab(%rip), %rdi      # 0x8fd0
leaq 0x2326(%rip), %rsi      # 0x6152
callq 0x3170
movq %rax, -0x178(%rbp)
jmp 0x3e3a
movq -0x178(%rbp), %rdi
movl -0x94(%rbp), %esi
callq 0x3240
movq %rax, -0x180(%rbp)
jmp 0x3e55
movq -0x180(%rbp), %rdi
leaq 0x2314(%rip), %rsi      # 0x6177
callq 0x3170
movq %rax, -0x188(%rbp)
jmp 0x3e71
movq -0x188(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x3150
movq %rax, -0x190(%rbp)
jmp 0x3e8d
movq -0x190(%rbp), %rdi
movl $0xa, %esi
callq 0x3200
jmp 0x3ea0
jmp 0x3ea2
jmp 0x3ea4
movl -0x94(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x94(%rbp)
jmp 0x3d40
jmp 0x3eba
movq 0x510f(%rip), %rdi      # 0x8fd0
leaq 0x229a(%rip), %rsi      # 0x6162
callq 0x3170
jmp 0x3ecf
movq 0x510a(%rip), %rdi      # 0x8fe0
leaq -0x94(%rbp), %rsi
callq 0x3030
jmp 0x3ee4
jmp 0x3ee6
movl -0x94(%rbp), %eax
cmpl -0x98(%rbp), %eax
jae 0x3eba
jmp 0x3ef6
movq 0x50d3(%rip), %rdi      # 0x8fd0
movq 0x50bc(%rip), %rsi      # 0x8fc0
callq 0x31a0
jmp 0x3f0b
movq -0x10(%rbp), %rax
movq %rax, -0x1a8(%rbp)
movl -0x94(%rbp), %eax
movl %eax, -0x19c(%rbp)
leaq -0xf9(%rbp), %rdi
movq %rdi, -0x198(%rbp)
callq 0x3300
movq -0x198(%rbp), %rdx
leaq 0x21ba(%rip), %rsi      # 0x60fd
leaq -0xf8(%rbp), %rdi
callq 0x4090
jmp 0x3f51
movl -0x19c(%rbp), %esi
movq -0x1a8(%rbp), %rdi
movq (%rdi), %rax
movq (%rax), %rax
leaq -0xf8(%rbp), %rdx
callq *%rax
jmp 0x3f6f
leaq -0xf8(%rbp), %rdi
callq 0x30d0
leaq -0xf9(%rbp), %rdi
callq 0x31c0
movb $0x1, -0x1(%rbp)
movl $0x1, -0x70(%rbp)
jmp 0x3fc8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x3fba
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x30d0
leaq -0xf9(%rbp), %rdi
callq 0x31c0
jmp 0x3fd6
leaq -0x90(%rbp), %rdi
callq 0x30d0
jmp 0x3fe4
leaq -0x90(%rbp), %rdi
callq 0x30d0
jmp 0x3ffb
leaq -0x38(%rbp), %rdi
callq 0x30d0
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x1b0, %rsp            # imm = 0x1B0
popq %rbp
retq
leaq -0x38(%rbp), %rdi
callq 0x30d0
movq -0x40(%rbp), %rdi
callq 0x32f0
nopl (%rax)