// File: /workspace/github_cpp_makefile_star2_O2/tobias93[P]piano/rtmidi_build/RtMidi.cpp
// Function: MidiInAlsa::openVirtualPort(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void MidiInAlsa :: openVirtualPort( std::string portName )
{
  AlsaMidiData *data = static_cast<AlsaMidiData *> (apiData_);
  if ( data->vport < 0 ) {
    snd_seq_port_info_t *pinfo;
    snd_seq_port_info_alloca( &pinfo );
    snd_seq_port_info_set_capability( pinfo,
				      SND_SEQ_PORT_CAP_WRITE |
				      SND_SEQ_PORT_CAP_SUBS_WRITE );
    snd_seq_port_info_set_type( pinfo,
				SND_SEQ_PORT_TYPE_MIDI_GENERIC |
				SND_SEQ_PORT_TYPE_APPLICATION );
    snd_seq_port_info_set_midi_channels(pinfo, 16);
#ifndef AVOID_TIMESTAMPING
    snd_seq_port_info_set_timestamping(pinfo, 1);
    snd_seq_port_info_set_timestamp_real(pinfo, 1);    
    snd_seq_port_info_set_timestamp_queue(pinfo, data->queue_id);
#endif
    snd_seq_port_info_set_name(pinfo, portName.c_str());
    data->vport = snd_seq_create_port(data->seq, pinfo);

    if ( data->vport < 0 ) {
      errorString_ = "MidiInAlsa::openVirtualPort: ALSA error creating virtual port.";
      error( RtMidiError::DRIVER_ERROR, errorString_ );
      return;
    }
    data->vport = snd_seq_port_info_get_port(pinfo);
  }

  if ( inputData_.doInput == false ) {
    // Wait for old thread to stop, if still running
    if ( !pthread_equal(data->thread, data->dummy_thread_id) )
      pthread_join( data->thread, NULL );

    // Start the input queue
#ifndef AVOID_TIMESTAMPING
    snd_seq_start_queue( data->seq, data->queue_id, NULL );
    snd_seq_drain_output( data->seq );
#endif
    // Start our MIDI input thread.
    pthread_attr_t attr;
    pthread_attr_init(&attr);
    pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
    pthread_attr_setschedpolicy(&attr, SCHED_OTHER);

    inputData_.doInput = true;
    int err = pthread_create(&data->thread, &attr, alsaMidiHandler, &inputData_);
    pthread_attr_destroy(&attr);
    if ( err ) {
      if ( data->subscription ) {
        snd_seq_unsubscribe_port( data->seq, data->subscription );
        snd_seq_port_subscribe_free( data->subscription );
        data->subscription = 0;
      }
      inputData_.doInput = false;
      errorString_ = "MidiInAlsa::openPort: error starting MIDI input thread!";
      error( RtMidiError::THREAD_ERROR, errorString_ );
      return;
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdi, %rbx
movq 0x8(%rdi), %r13
cmpl $0x0, 0xc(%r13)
jns 0x95e6
movq %rsi, %r15
callq 0x7890
movq %rsp, %r14
addq $0xf, %rax
andq $-0x10, %rax
subq %rax, %r14
movq %r14, %rsp
callq 0x7890
movq %r14, %rdi
xorl %esi, %esi
movq %rax, %rdx
callq 0x71f0
pushq $0x42
popq %rsi
movq %r14, %rdi
callq 0x78f0
movq %r14, %rdi
movl $0x100002, %esi         # imm = 0x100002
callq 0x7210
pushq $0x10
popq %rsi
movq %r14, %rdi
callq 0x7190
pushq $0x1
popq %r12
movq %r14, %rdi
movl %r12d, %esi
callq 0x77c0
movq %r14, %rdi
movl %r12d, %esi
callq 0x7830
movl 0x48(%r13), %esi
movq %r14, %rdi
callq 0x7a70
movq (%r15), %rsi
movq %r14, %rdi
callq 0x7b10
movq (%r13), %rdi
movq %r14, %rsi
callq 0x70e0
movl %eax, 0xc(%r13)
testl %eax, %eax
js 0x96e7
movq %r14, %rdi
callq 0x7900
movl %eax, 0xc(%r13)
cmpb $0x0, 0x89(%rbx)
jne 0x9720
leaq 0x50(%rbx), %r14
leaq 0x30(%r13), %r15
movq 0x30(%r13), %r12
movq 0x38(%r13), %rsi
movq %r12, %rdi
callq 0x79d0
testl %eax, %eax
jne 0x9619
movq %r12, %rdi
xorl %esi, %esi
callq 0x73e0
movq (%r13), %rdi
movl 0x48(%r13), %esi
pushq $0x1e
popq %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x7500
movq (%r13), %rdi
callq 0x7a20
leaq -0xa0(%rbp), %r12
movq %r12, %rdi
callq 0x75e0
movq %r12, %rdi
xorl %esi, %esi
callq 0x7640
movq %r12, %rdi
xorl %esi, %esi
callq 0x7740
movb $0x1, 0x89(%rbx)
leaq -0x554(%rip), %rdx      # 0x9114
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %rcx
callq 0x7a80
movl %eax, %r14d
movq %r12, %rdi
callq 0x7910
testl %r14d, %r14d
je 0x9720
movq 0x10(%r13), %rsi
testq %rsi, %rsi
je 0x96aa
movq (%r13), %rdi
callq 0x79e0
movq 0x10(%r13), %rdi
callq 0x77e0
andq $0x0, 0x10(%r13)
movb $0x0, 0x89(%rbx)
leaq 0x18(%rbx), %r14
leaq 0x2d94(%rip), %rsi      # 0xc450
movq %r14, %rdi
callq 0x7af0
leaq -0x48(%rbp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x7720
pushq $0xa
popq %rsi
movq %rbx, %rdi
movq %r15, %rdx
callq 0x7240
leaq -0x48(%rbp), %rdi
jmp 0x971b
leaq 0x18(%rbx), %r14
leaq 0x2d96(%rip), %rsi      # 0xc488
movq %r14, %rdi
callq 0x7af0
leaq -0x68(%rbp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x7720
pushq $0x8
popq %rsi
movq %rbx, %rdi
movq %r15, %rdx
callq 0x7240
leaq -0x68(%rbp), %rdi
callq 0x7180
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x68(%rbp), %rdi
jmp 0x973f
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x7180
movq %rbx, %rdi
callq 0x7a10