// File: /workspace/github_cpp_makefile_star2_O2/tobias93[P]piano/rtmidi_build/RtMidi.cpp
// Function: MidiOutAlsa::sendMessage(std::vector<unsigned char, std::allocator<unsigned char>>*)
void MidiOutAlsa :: sendMessage( std::vector<unsigned char> *message )
{
  int result;
  AlsaMidiData *data = static_cast<AlsaMidiData *> (apiData_);
  unsigned int nBytes = message->size();
  if ( nBytes > data->bufferSize ) {
    data->bufferSize = nBytes;
    result = snd_midi_event_resize_buffer ( data->coder, nBytes);
    if ( result != 0 ) {
      errorString_ = "MidiOutAlsa::sendMessage: ALSA error resizing MIDI event buffer.";
      error( RtMidiError::DRIVER_ERROR, errorString_ );
      return;
    }
    free (data->buffer);
    data->buffer = (unsigned char *) malloc( data->bufferSize );
    if ( data->buffer == NULL ) {
    errorString_ = "MidiOutAlsa::initialize: error allocating buffer memory!\n\n";
    error( RtMidiError::MEMORY_ERROR, errorString_ );
    return;
    }
  }

  snd_seq_event_t ev;
  snd_seq_ev_clear(&ev);
  snd_seq_ev_set_source(&ev, data->vport);
  snd_seq_ev_set_subs(&ev);
  snd_seq_ev_set_direct(&ev);
  for ( unsigned int i=0; i<nBytes; ++i ) data->buffer[i] = message->at(i);
  result = snd_midi_event_encode( data->coder, data->buffer, (long)nBytes, &ev );
  if ( result < (int)nBytes ) {
    errorString_ = "MidiOutAlsa::sendMessage: event parsing error!";
    error( RtMidiError::WARNING, errorString_ );
    return;
  }

  // Send the event.
  result = snd_seq_event_output(data->seq, &ev);
  if ( result < 0 ) {
    errorString_ = "MidiOutAlsa::sendMessage: error sending MIDI message to port.";
    error( RtMidiError::WARNING, errorString_ );
    return;
  }
  snd_seq_drain_output(data->seq);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq 0x8(%rdi), %r12
movq 0x8(%rsi), %r13
subq (%rsi), %r13
cmpl %r13d, 0x20(%r12)
jae 0xa12e
movl %r13d, 0x20(%r12)
movq 0x18(%r12), %rdi
movl %r13d, %esi
callq 0x75d0
testl %eax, %eax
je 0xa10c
leaq 0x18(%rbx), %r14
leaq 0x2673(%rip), %rsi      # 0xc74f
movq %r14, %rdi
callq 0x7af0
leaq 0x48(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x7720
pushq $0x8
popq %rsi
movq %rbx, %rdi
movq %r15, %rdx
callq 0x7240
leaq 0x48(%rsp), %rdi
jmp 0xa257
movq 0x28(%r12), %rdi
callq 0x75a0
movl 0x20(%r12), %edi
callq 0x76a0
movq %rax, 0x28(%r12)
testq %rax, %rax
je 0xa221
xorps %xmm0, %xmm0
movups %xmm0, 0xc(%rsp)
movaps %xmm0, (%rsp)
movb 0xc(%r12), %al
movb %al, 0xd(%rsp)
movw $0xfdfe, 0xe(%rsp)      # imm = 0xFDFE
movb $-0x3, 0x3(%rsp)
movl %r13d, %ebp
xorl %r15d, %r15d
cmpq %r15, %rbp
je 0xa175
movq %r14, %rdi
movq %r15, %rsi
callq 0x7280
movb (%rax), %al
movq 0x28(%r12), %rcx
movb %al, (%rcx,%r15)
incq %r15
jmp 0xa155
movq 0x18(%r12), %rdi
movq 0x28(%r12), %rsi
movl %r13d, %edx
movq %rsp, %rcx
callq 0x7200
cmpl %r13d, %eax
jge 0xa1cf
leaq 0x18(%rbx), %r15
leaq 0x25f6(%rip), %rsi      # 0xc790
movq %r15, %rdi
callq 0x7af0
leaq 0x88(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x7720
movq %rbx, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x7240
leaq 0x88(%rsp), %rdi
jmp 0xa257
movq (%r12), %rdi
movq %rsp, %rsi
callq 0x7590
testl %eax, %eax
js 0xa1ea
movq (%r12), %rdi
callq 0x7a20
jmp 0xa25c
leaq 0x18(%rbx), %r15
leaq 0x25ca(%rip), %rsi      # 0xc7bf
movq %r15, %rdi
callq 0x7af0
leaq 0x68(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x7720
movq %rbx, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x7240
leaq 0x68(%rsp), %rdi
jmp 0xa257
leaq 0x18(%rbx), %r14
leaq 0x2322(%rip), %rsi      # 0xc54e
movq %r14, %rdi
callq 0x7af0
leaq 0x28(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x7720
pushq $0x5
popq %rsi
movq %rbx, %rdi
movq %r15, %rdx
callq 0x7240
leaq 0x28(%rsp), %rdi
callq 0x7180
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
jmp 0xa28a
jmp 0xa27a
movq %rax, %rbx
movq %r14, %rdi
jmp 0xa28a
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x7180
movq %rbx, %rdi
callq 0x7a10
nop