// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
testq %rdi, %rdi
je 0x29f9
movq %rdi, %rbx
movq (%rdi), %rax
movq -0x8(%rax), %rdi
movq 0x2839(%rip), %rsi      # 0x4fb8
callq 0x2ab8
movl %eax, %ebp
leaq 0x903(%rip), %rax       # 0x3090
leaq 0x931(%rip), %rsi       # 0x30c5
testb %bpl, %bpl
cmovneq %rax, %rsi
movq 0x282e(%rip), %rdi      # 0x4fd0
callq 0x2140
leaq 0x58(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0x2821(%rip), %rdi      # 0x4fe0
leaq 0x48(%rsp), %rsi
callq 0x2030
leaq 0x92b(%rip), %rsi       # 0x30fb
leaq 0x48(%rsp), %rdi
callq 0x2ae0
testb %al, %al
je 0x281c
leaq 0x918(%rip), %rsi       # 0x30fd
leaq 0x88(%rsp), %rdi
leaq 0x28(%rsp), %rdx
callq 0x2a72
movq (%rbx), %rax
leaq 0x88(%rsp), %rsi
movq %rbx, %rdi
callq *0x8(%rax)
leaq 0x88(%rsp), %rdi
callq 0x20a0
movb $0x1, %bl
jmp 0x29db
leaq 0x38(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
andl $0x0, 0x4(%rsp)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x10(%rax)
movl %eax, %r14d
testl %eax, %eax
setne 0x3(%rsp)
je 0x2897
cmpl $0x1, %r14d
jne 0x28c5
movq 0x277c(%rip), %rdi      # 0x4fd0
leaq 0x8de(%rip), %rsi       # 0x3139
callq 0x2140
movq %rax, %r14
movq (%rbx), %rax
leaq 0x8(%rsp), %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq *0x18(%rax)
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x2120
movq %rax, %rdi
callq 0x20b0
leaq 0x8(%rsp), %rdi
callq 0x20a0
jmp 0x298e
leaq 0x866(%rip), %rax       # 0x3104
leaq 0x879(%rip), %rsi       # 0x311e
testb %bpl, %bpl
cmovneq %rax, %rsi
movq 0x271d(%rip), %rdi      # 0x4fd0
callq 0x2140
movq %rax, %rdi
callq 0x20b0
jmp 0x29cd
leaq 0x877(%rip), %rax       # 0x3143
leaq 0x87f(%rip), %r15       # 0x3152
testb %bpl, %bpl
cmovneq %rax, %r15
xorl %r12d, %r12d
leaq 0x8(%rsp), %r13
leaq 0x28(%rsp), %rbp
movl %r12d, 0x4(%rsp)
cmpl %r14d, %r12d
jae 0x2957
movq (%rbx), %rax
movq %r13, %rdi
movq %rbx, %rsi
movl %r12d, %edx
callq *0x18(%rax)
movq %rbp, %rdi
movq %r13, %rsi
callq 0x21a0
movq %r13, %rdi
callq 0x20a0
movq 0x26b6(%rip), %rdi      # 0x4fd0
movq %r15, %rsi
callq 0x2140
movq %rax, %rdi
movq %r12, %rsi
callq 0x20d0
movq %rax, %rdi
leaq 0x840(%rip), %rsi       # 0x3177
callq 0x2140
movq %rax, %rdi
movq %rbp, %rsi
callq 0x2120
movq %rax, %rdi
pushq $0xa
popq %rsi
callq 0x2180
incq %r12
jmp 0x28e7
movq 0x2672(%rip), %r15      # 0x4fd0
leaq 0x7fd(%rip), %r12       # 0x3162
movq 0x2674(%rip), %r13      # 0x4fe0
leaq 0x4(%rsp), %rbp
movq %r15, %rdi
movq %r12, %rsi
callq 0x2140
movq %r13, %rdi
movq %rbp, %rsi
callq 0x2240
cmpl %r14d, 0x4(%rsp)
jae 0x2971
movq 0x263b(%rip), %rdi      # 0x4fd0
callq 0x20b0
movl 0x4(%rsp), %ebp
leaq 0x758(%rip), %rsi       # 0x30fd
leaq 0x68(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0x2a72
movq (%rbx), %rax
leaq 0x68(%rsp), %rdx
movq %rbx, %rdi
movl %ebp, %esi
callq *(%rax)
leaq 0x68(%rsp), %rdi
callq 0x20a0
leaq 0x28(%rsp), %rdi
callq 0x20a0
movb 0x3(%rsp), %bl
leaq 0x48(%rsp), %rdi
callq 0x20a0
movl %ebx, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2170
jmp 0x2a35
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
jmp 0x2a14
jmp 0x2a35
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x20a0
jmp 0x2a38
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
jmp 0x2a3d
jmp 0x2a2a
movq %rax, %rbx
jmp 0x2a42
jmp 0x2a35
jmp 0x2a35
jmp 0x2a35
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x20a0
leaq 0x48(%rsp), %rdi
callq 0x20a0
movq %rbx, %rdi
callq 0x2250