// File: /workspace/github_cpp_makefile_star2_O3/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 %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq 0x8(%rdi), %r15
movq 0x8(%rsi), %r12
subq (%rsi), %r12
cmpl %r12d, 0x20(%r15)
jae 0xabc1
movl %r12d, 0x20(%r15)
movq 0x18(%r15), %rdi
movl %r12d, %esi
callq 0x7530
testl %eax, %eax
je 0xaba2
leaq 0x18(%rbx), %rdi
movq 0x20(%rbx), %rdx
leaq 0x2bf3(%rip), %rcx      # 0xd73f
movl $0x40, %r8d
xorl %esi, %esi
callq 0x7710
leaq 0x58(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x18(%rbx), %rsi
movq 0x20(%rbx), %rdx
addq %rsi, %rdx
leaq 0x48(%rsp), %r14
movq %r14, %rdi
callq 0x7130
movq %rbx, %rdi
movl $0x8, %esi
movq %r14, %rdx
callq 0x7200
movq 0x48(%rsp), %rdi
cmpq %r15, %rdi
je 0xad71
movq 0x58(%rsp), %rsi
jmp 0xad69
movq 0x28(%r15), %rdi
callq 0x7500
movl 0x20(%r15), %edi
callq 0x75e0
movq %rax, 0x28(%r15)
testq %rax, %rax
je 0xad0d
xorps %xmm0, %xmm0
movups %xmm0, 0xc(%rsp)
movaps %xmm0, (%rsp)
movb 0xc(%r15), %al
movb %al, 0xd(%rsp)
movw $0xfdfe, 0xe(%rsp)      # imm = 0xFDFE
movb $-0x3, 0x3(%rsp)
testl %r12d, %r12d
je 0xac10
movl %r12d, %eax
xorl %esi, %esi
movq (%r14), %rcx
movq 0x8(%r14), %rdx
subq %rcx, %rdx
cmpq %rsi, %rdx
jbe 0xad80
movb (%rcx,%rsi), %cl
movq 0x28(%r15), %rdx
movb %cl, (%rdx,%rsi)
incq %rsi
cmpq %rsi, %rax
jne 0xabeb
movq 0x18(%r15), %rdi
movq 0x28(%r15), %rsi
movl %r12d, %edx
movq %rsp, %rcx
callq 0x71e0
cmpl %r12d, %eax
jge 0xac96
leaq 0x18(%rbx), %rdi
movq 0x20(%rbx), %rdx
leaq 0x2b49(%rip), %rcx      # 0xd780
movl $0x2e, %r8d
xorl %esi, %esi
callq 0x7710
leaq 0x98(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x18(%rbx), %rsi
movq 0x20(%rbx), %rdx
addq %rsi, %rdx
leaq 0x88(%rsp), %r14
movq %r14, %rdi
callq 0x7130
movq %rbx, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x7200
movq 0x88(%rsp), %rdi
cmpq %r15, %rdi
je 0xad71
movq 0x98(%rsp), %rsi
jmp 0xad69
movq (%r15), %rdi
movq %rsp, %rsi
callq 0x74f0
testl %eax, %eax
js 0xacb2
movq (%r15), %rdi
callq 0x78c0
jmp 0xad71
leaq 0x18(%rbx), %rdi
movq 0x20(%rbx), %rdx
leaq 0x2aee(%rip), %rcx      # 0xd7af
movl $0x3d, %r8d
xorl %esi, %esi
callq 0x7710
leaq 0x78(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x18(%rbx), %rsi
movq 0x20(%rbx), %rdx
addq %rsi, %rdx
leaq 0x68(%rsp), %r14
movq %r14, %rdi
callq 0x7130
movq %rbx, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x7200
movq 0x68(%rsp), %rdi
cmpq %r15, %rdi
je 0xad71
movq 0x78(%rsp), %rsi
jmp 0xad69
leaq 0x18(%rbx), %rdi
movq 0x20(%rbx), %rdx
leaq 0x2822(%rip), %rcx      # 0xd53e
movl $0x3a, %r8d
xorl %esi, %esi
callq 0x7710
leaq 0x38(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x18(%rbx), %rsi
movq 0x20(%rbx), %rdx
addq %rsi, %rdx
leaq 0x28(%rsp), %r14
movq %r14, %rdi
callq 0x7130
movq %rbx, %rdi
movl $0x5, %esi
movq %r14, %rdx
callq 0x7200
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0xad71
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x7420
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x2c69(%rip), %rdi      # 0xd9f0
xorl %eax, %eax
callq 0x76d0
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0xaddb
movq 0x38(%rsp), %rsi
jmp 0xadd3
movq %rax, %rbx
movq 0x68(%rsp), %rdi
jmp 0xadb7
movq %rax, %rbx
movq 0x88(%rsp), %rdi
cmpq %r15, %rdi
je 0xaddb
movq (%r15), %rsi
jmp 0xadd3
movq %rax, %rbx
movq 0x48(%rsp), %rdi
cmpq %r15, %rdi
je 0xaddb
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x7420
movq %rbx, %rdi
callq 0x78b0