// File: /workspace/github_cpp_makefile_star2_O3/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 $0xb8, %rsp
testq %rdi, %rdi
je 0x2c90
movq %rdi, %rbx
movq (%rdi), %rax
movq -0x8(%rax), %rax
movq 0x8(%rax), %rdi
movq 0x2796(%rip), %rax      # 0x4fb8
movq 0x8(%rax), %rsi
cmpq %rsi, %rdi
je 0x285b
cmpb $0x2a, (%rdi)
je 0x2839
callq 0x2170
testl %eax, %eax
je 0x285b
movq 0x2790(%rip), %rdi      # 0x4fd0
leaq 0x87e(%rip), %rsi       # 0x30c5
movl $0x35, %edx
callq 0x2140
movl $0x0, 0x14(%rsp)
jmp 0x2879
movq 0x276e(%rip), %rdi      # 0x4fd0
leaq 0x827(%rip), %rsi       # 0x3090
movl $0x34, %edx
callq 0x2140
movb $0x1, %al
movl %eax, 0x14(%rsp)
leaq 0x68(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0x274c(%rip), %rdi      # 0x4fe0
movq (%rdi), %rax
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x20f0
movsbl %al, %edx
movq 0x2731(%rip), %rdi      # 0x4fe0
leaq 0x58(%rsp), %rsi
callq 0x2230
leaq 0x83b(%rip), %rsi       # 0x30fb
leaq 0x58(%rsp), %rdi
callq 0x2050
testl %eax, %eax
je 0x299d
leaq 0x48(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movl $0x0, 0x10(%rsp)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x10(%rax)
movl %eax, %r14d
testl %eax, %eax
setne 0xf(%rsp)
je 0x2a01
cmpl $0x1, %r14d
jne 0x2a63
movq 0x26b8(%rip), %rdi      # 0x4fd0
leaq 0x81a(%rip), %rsi       # 0x3139
movl $0x9, %edx
callq 0x2140
movq (%rbx), %rax
leaq 0x18(%rsp), %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq *0x18(%rax)
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
movq 0x2686(%rip), %rdi      # 0x4fd0
callq 0x2140
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x20f0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2090
leaq 0x28(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2bc2
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x2120
jmp 0x2bc2
leaq 0xa8(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x74d(%rip), %rsi       # 0x30fd
leaq 0x74c(%rip), %rdx       # 0x3103
leaq 0x98(%rsp), %rdi
callq 0x2d3a
movq (%rbx), %rax
leaq 0x98(%rsp), %rsi
movq %rbx, %rdi
callq *0x8(%rax)
movq 0x98(%rsp), %rdi
movb $0x1, 0xf(%rsp)
cmpq %r14, %rdi
je 0x29f7
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x2120
leaq 0x68(%rsp), %rbx
jmp 0x2c63
leaq 0x6fc(%rip), %rax       # 0x3104
leaq 0x70f(%rip), %rsi       # 0x311e
movl 0x14(%rsp), %ecx
testb %cl, %cl
cmovneq %rax, %rsi
movzbl %cl, %eax
movl $0x1a, %edx
subq %rax, %rdx
movq 0x25a5(%rip), %rbx      # 0x4fd0
movq %rbx, %rdi
callq 0x2140
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x20f0
movsbl %al, %esi
movq 0x257f(%rip), %rdi      # 0x4fd0
callq 0x2030
movq %rax, %rdi
callq 0x2090
jmp 0x2c42
movl $0x0, 0x10(%rsp)
xorl %r15d, %r15d
leaq 0x18(%rsp), %r12
movq 0x2556(%rip), %rbp      # 0x4fd0
movq (%rbx), %rax
movq %r12, %rdi
movq %rbx, %rsi
movl %r15d, %edx
callq *0x18(%rax)
leaq 0x38(%rsp), %rdi
movq %r12, %rsi
callq 0x2160
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x2ab2
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x2120
cmpb $0x0, 0x14(%rsp)
je 0x2b18
movl $0xe, %edx
movq %rbp, %rdi
leaq 0x67b(%rip), %rsi       # 0x3143
callq 0x2140
movq %rbp, %rdi
movq %r15, %rsi
callq 0x2080
movq %rax, %r13
movl $0x2, %edx
movq %rax, %rdi
leaq 0x68d(%rip), %rsi       # 0x3177
callq 0x2140
movq 0x38(%rsp), %rsi
movq 0x40(%rsp), %rdx
movq %r13, %rdi
callq 0x2140
movb $0xa, 0x18(%rsp)
movl $0x1, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x2140
jmp 0x2b75
movl $0xf, %edx
movq %rbp, %rdi
leaq 0x62b(%rip), %rsi       # 0x3152
callq 0x2140
movq %rbp, %rdi
movq %r15, %rsi
callq 0x2080
movq %rax, %r13
movl $0x2, %edx
movq %rax, %rdi
leaq 0x62e(%rip), %rsi       # 0x3177
callq 0x2140
movq 0x38(%rsp), %rsi
movq 0x40(%rsp), %rdx
movq %r13, %rdi
callq 0x2140
movb $0xa, 0x18(%rsp)
movl $0x1, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x2140
incq %r15
movl %r15d, 0x10(%rsp)
cmpl %r14d, %r15d
jb 0x2a7a
movq 0x2443(%rip), %r15      # 0x4fd0
leaq 0x5ce(%rip), %r12       # 0x3162
movq 0x2445(%rip), %r13      # 0x4fe0
leaq 0x10(%rsp), %rbp
movl $0x17, %edx
movq %r15, %rdi
movq %r12, %rsi
callq 0x2140
movq %r13, %rdi
movq %rbp, %rsi
callq 0x2200
cmpl %r14d, 0x10(%rsp)
jae 0x2ba0
movq 0x2407(%rip), %rdi      # 0x4fd0
movq (%rdi), %rax
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x20f0
movsbl %al, %esi
movq 0x23ec(%rip), %rdi      # 0x4fd0
callq 0x2030
movq %rax, %rdi
callq 0x2090
movl 0x10(%rsp), %ebp
leaq 0x88(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x4f5(%rip), %rsi       # 0x30fd
leaq 0x4f4(%rip), %rdx       # 0x3103
leaq 0x78(%rsp), %rdi
callq 0x2d3a
movq (%rbx), %rax
leaq 0x78(%rsp), %rdx
movq %rbx, %rdi
movl %ebp, %esi
callq *(%rax)
movq 0x78(%rsp), %rdi
cmpq %r14, %rdi
je 0x2c42
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x2120
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
leaq 0x68(%rsp), %rbx
je 0x2c63
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x2120
movq 0x58(%rsp), %rdi
cmpq %rbx, %rdi
je 0x2c7a
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x2120
movb 0xf(%rsp), %al
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2130
jmp 0x2cf7
movq %rax, %rbx
movq 0x98(%rsp), %rdi
cmpq %r14, %rdi
je 0x2d16
movq 0xa8(%rsp), %rsi
jmp 0x2d0e
jmp 0x2cec
movq %rax, %rbx
movq 0x78(%rsp), %rdi
cmpq %r14, %rdi
je 0x2cfa
movq 0x88(%rsp), %rsi
jmp 0x2ce2
jmp 0x2cf7
movq %rax, %rbx
leaq 0x28(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2cfa
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x2120
jmp 0x2cfa
movq %rax, %rbx
jmp 0x2d16
jmp 0x2cf7
jmp 0x2cf7
jmp 0x2cf7
movq %rax, %rbx
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x2d16
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x2120
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x2d32
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x2120
movq %rbx, %rdi
callq 0x2210