// File: tobias93[P]piano/rtmidi_build/tests/midiclock.cpp
// Function: bool choosePort<RtMidiIn>(RtMidiIn*, char const*)
bool choosePort( RT *rtmidi, const char *dir )
{
  std::string portName;
  unsigned int i = 0, nPorts = rtmidi->getPortCount();
  if ( nPorts == 0 ) {
    std::cout << "No " << dir << " 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);
      std::cout << "  " << dir << " port #" << i << ": " << portName << '\n';
    }

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

  std::cout << "\n";
  rtmidi->openPort( i );

  return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x130, %rsp            # imm = 0x130
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x3230
movl $0x0, -0x3c(%rbp)
movq -0x10(%rbp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movl %eax, -0xb8(%rbp)
jmp 0x4138
movl -0xb8(%rbp), %eax
movl %eax, -0x40(%rbp)
cmpl $0x0, -0x40(%rbp)
jne 0x41d2
movq 0x4e7e(%rip), %rdi      # 0x8fd0
leaq 0x2094(%rip), %rsi      # 0x61ed
callq 0x3150
movq %rax, -0xc0(%rbp)
jmp 0x4167
movq -0xc0(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x3150
movq %rax, -0xc8(%rbp)
jmp 0x4180
movq -0xc8(%rbp), %rdi
leaq 0x2063(%rip), %rsi      # 0x61f1
callq 0x3150
movq %rax, -0xd0(%rbp)
jmp 0x419c
movq -0xd0(%rbp), %rdi
movq 0x4e16(%rip), %rsi      # 0x8fc0
callq 0x3180
jmp 0x41b1
movb $0x0, -0x1(%rbp)
movl $0x1, -0x50(%rbp)
jmp 0x4477
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x448e
cmpl $0x1, -0x40(%rbp)
jne 0x4263
movq 0x4ded(%rip), %rdi      # 0x8fd0
leaq 0x2019(%rip), %rsi      # 0x6203
callq 0x3150
movq %rax, -0xd8(%rbp)
jmp 0x41f8
movq -0x10(%rbp), %rsi
movq (%rsi), %rax
movq 0x18(%rax), %rax
leaq -0x70(%rbp), %rdi
xorl %edx, %edx
callq *%rax
jmp 0x420d
movq -0xd8(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x3130
movq %rax, -0xe0(%rbp)
jmp 0x4226
movq -0xe0(%rbp), %rdi
movq 0x4d8c(%rip), %rsi      # 0x8fc0
callq 0x3180
jmp 0x423b
leaq -0x70(%rbp), %rdi
callq 0x30b0
jmp 0x43a8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x30b0
jmp 0x448e
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x40(%rbp), %eax
jae 0x4373
movq -0x10(%rbp), %rsi
movl -0x3c(%rbp), %edx
movq (%rsi), %rax
movq 0x18(%rax), %rax
leaq -0x90(%rbp), %rdi
callq *%rax
jmp 0x428f
leaq -0x38(%rbp), %rdi
leaq -0x90(%rbp), %rsi
movq %rsi, -0xf0(%rbp)
callq 0x31f0
movq -0xf0(%rbp), %rdi
callq 0x30b0
movq 0x4d17(%rip), %rdi      # 0x8fd0
leaq 0x1f4d(%rip), %rsi      # 0x620d
callq 0x3150
movq %rax, -0xe8(%rbp)
jmp 0x42ce
movq -0xe8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x3150
movq %rax, -0xf8(%rbp)
jmp 0x42e7
movq -0xf8(%rbp), %rdi
leaq 0x1f1b(%rip), %rsi      # 0x6210
callq 0x3150
movq %rax, -0x100(%rbp)
jmp 0x4303
movq -0x100(%rbp), %rdi
movl -0x3c(%rbp), %esi
callq 0x3210
movq %rax, -0x108(%rbp)
jmp 0x431b
movq -0x108(%rbp), %rdi
leaq 0x1f04(%rip), %rsi      # 0x622d
callq 0x3150
movq %rax, -0x110(%rbp)
jmp 0x4337
movq -0x110(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x3130
movq %rax, -0x118(%rbp)
jmp 0x4350
movq -0x118(%rbp), %rdi
movl $0xa, %esi
callq 0x31d0
jmp 0x4363
jmp 0x4365
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x426a
jmp 0x4375
movq 0x4c54(%rip), %rdi      # 0x8fd0
leaq 0x1e95(%rip), %rsi      # 0x6218
callq 0x3150
jmp 0x438a
movq 0x4c4f(%rip), %rdi      # 0x8fe0
leaq -0x3c(%rbp), %rsi
callq 0x3030
jmp 0x439c
jmp 0x439e
movl -0x3c(%rbp), %eax
cmpl -0x40(%rbp), %eax
jae 0x4375
jmp 0x43a8
movq 0x4c21(%rip), %rdi      # 0x8fd0
leaq 0x1cf6(%rip), %rsi      # 0x60ac
callq 0x3150
jmp 0x43bd
movq -0x10(%rbp), %rax
movq %rax, -0x130(%rbp)
movl -0x3c(%rbp), %eax
movl %eax, -0x124(%rbp)
leaq -0xb1(%rbp), %rdi
movq %rdi, -0x120(%rbp)
callq 0x32b0
movq -0x120(%rbp), %rdx
leaq 0x1e3e(%rip), %rsi      # 0x6230
leaq -0xb0(%rbp), %rdi
callq 0x3ec0
jmp 0x4400
movl -0x124(%rbp), %esi
movq -0x130(%rbp), %rdi
movq (%rdi), %rax
movq (%rax), %rax
leaq -0xb0(%rbp), %rdx
callq *%rax
jmp 0x441e
leaq -0xb0(%rbp), %rdi
callq 0x30b0
leaq -0xb1(%rbp), %rdi
callq 0x31a0
movb $0x1, -0x1(%rbp)
movl $0x1, -0x50(%rbp)
jmp 0x4477
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x4469
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x30b0
leaq -0xb1(%rbp), %rdi
callq 0x31a0
jmp 0x448e
leaq -0x38(%rbp), %rdi
callq 0x30b0
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x130, %rsp            # imm = 0x130
popq %rbp
retq
leaq -0x38(%rbp), %rdi
callq 0x30b0
movq -0x48(%rbp), %rdi
callq 0x32a0