// File: 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
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rdi
callq 0xe2c0
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x20(%rcx), %eax
jbe 0x128a8
movl -0x24(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x20(%rax)
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rdi
movl -0x24(%rbp), %eax
movl %eax, %esi
callq 0xdd80
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0x127fe
movq -0xe0(%rbp), %rdi
addq $0x18, %rdi
movq %rdi, -0xf0(%rbp)
leaq 0x6fa7(%rip), %rsi      # 0x19747
callq 0xdfb0
movq -0xf0(%rbp), %rsi
leaq -0x48(%rbp), %rdi
movq %rdi, -0xe8(%rbp)
callq 0xd3d0
movq -0xe0(%rbp), %rdi
movq -0xe8(%rbp), %rdx
movl $0x8, %esi
callq 0xd5f0
jmp 0x127d6
leaq -0x48(%rbp), %rdi
callq 0xd600
jmp 0x12a6f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x48(%rbp), %rdi
callq 0xd600
jmp 0x12a78
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rdi
callq 0xdd40
movq -0x20(%rbp), %rax
movl 0x20(%rax), %eax
movl %eax, %edi
callq 0xdf10
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x20(%rbp), %rax
cmpq $0x0, 0x28(%rax)
jne 0x128a6
movq -0xe0(%rbp), %rdi
addq $0x18, %rdi
movq %rdi, -0x100(%rbp)
leaq 0x6cfe(%rip), %rsi      # 0x19546
callq 0xdfb0
movq -0x100(%rbp), %rsi
leaq -0x78(%rbp), %rdi
movq %rdi, -0xf8(%rbp)
callq 0xd3d0
movq -0xe0(%rbp), %rdi
movq -0xf8(%rbp), %rdx
movl $0x5, %esi
callq 0xd5f0
jmp 0x1287e
leaq -0x78(%rbp), %rdi
callq 0xd600
jmp 0x12a6f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x78(%rbp), %rdi
callq 0xd600
jmp 0x12a78
jmp 0x128a8
leaq -0x94(%rbp), %rdi
xorl %esi, %esi
movl $0x1c, %edx
callq 0xd530
movq -0x20(%rbp), %rax
movl 0xc(%rax), %eax
movb %al, -0x87(%rbp)
movb $-0x2, -0x86(%rbp)
movb $-0x3, -0x85(%rbp)
movb $-0x3, -0x91(%rbp)
movl $0x0, -0x98(%rbp)
movl -0x98(%rbp), %eax
cmpl -0x24(%rbp), %eax
jae 0x12927
movq -0x10(%rbp), %rdi
movl -0x98(%rbp), %eax
movl %eax, %esi
callq 0xd650
movb (%rax), %dl
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rax
movl -0x98(%rbp), %ecx
movb %dl, (%rax,%rcx)
movl -0x98(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x98(%rbp)
jmp 0x128e7
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rsi
movl -0x24(%rbp), %eax
movl %eax, %edx
leaq -0x94(%rbp), %rcx
callq 0xd540
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x129d0
movq -0xe0(%rbp), %rdi
addq $0x18, %rdi
movq %rdi, -0x110(%rbp)
leaq 0x6e1c(%rip), %rsi      # 0x19788
callq 0xdfb0
movq -0x110(%rbp), %rsi
leaq -0xb8(%rbp), %rdi
movq %rdi, -0x108(%rbp)
callq 0xd3d0
movq -0xe0(%rbp), %rdi
movq -0x108(%rbp), %rdx
xorl %esi, %esi
callq 0xd5f0
jmp 0x129a2
leaq -0xb8(%rbp), %rdi
callq 0xd600
jmp 0x12a6f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0xd600
jmp 0x12a78
movq -0x20(%rbp), %rax
movq (%rax), %rdi
leaq -0x94(%rbp), %rsi
callq 0xdd30
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
jge 0x12a63
movq -0xe0(%rbp), %rdi
addq $0x18, %rdi
movq %rdi, -0x120(%rbp)
leaq 0x6db2(%rip), %rsi      # 0x197b7
callq 0xdfb0
movq -0x120(%rbp), %rsi
leaq -0xd8(%rbp), %rdi
movq %rdi, -0x118(%rbp)
callq 0xd3d0
movq -0xe0(%rbp), %rdi
movq -0x118(%rbp), %rdx
xorl %esi, %esi
callq 0xd5f0
jmp 0x12a3b
leaq -0xd8(%rbp), %rdi
callq 0xd600
jmp 0x12a6f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0xd600
jmp 0x12a78
movq -0x20(%rbp), %rax
movq (%rax), %rdi
callq 0xe5b0
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
movq -0x50(%rbp), %rdi
callq 0xe590
nopw %cs:(%rax,%rax)
nopl (%rax,%rax)