// File: tobias93[P]piano/rtmidi_build/RtMidi.cpp
// Function: MidiInAlsa::initialize(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
void MidiInAlsa :: initialize( const std::string& clientName )
{
  // Set up the ALSA sequencer client.
  snd_seq_t *seq;
  int result = snd_seq_open(&seq, "default", SND_SEQ_OPEN_DUPLEX, SND_SEQ_NONBLOCK);
  if ( result < 0 ) {
    errorString_ = "MidiInAlsa::initialize: error creating ALSA sequencer client object.";
    error( RtMidiError::DRIVER_ERROR, errorString_ );
    return;
  }

  // Set client name.
  snd_seq_set_client_name( seq, clientName.c_str() );

  // Save our api-specific connection information.
  AlsaMidiData *data = (AlsaMidiData *) new AlsaMidiData;
  data->seq = seq;
  data->portNum = -1;
  data->vport = -1;
  data->subscription = 0;
  data->dummy_thread_id = pthread_self();
  data->thread = data->dummy_thread_id;
  data->trigger_fds[0] = -1;
  data->trigger_fds[1] = -1;
  apiData_ = (void *) data;
  inputData_.apiData = (void *) data;

   if ( pipe(data->trigger_fds) == -1 ) {
    errorString_ = "MidiInAlsa::initialize: error creating pipe objects.";
    error( RtMidiError::DRIVER_ERROR, errorString_ );
    return;
  }

  // Create the input queue
#ifndef AVOID_TIMESTAMPING
  data->queue_id = snd_seq_alloc_named_queue(seq, "RtMidi Queue");
  // Set arbitrary tempo (mm=100) and resolution (240)
  snd_seq_queue_tempo_t *qtempo;
  snd_seq_queue_tempo_alloca(&qtempo);
  snd_seq_queue_tempo_set_tempo(qtempo, 600000);
  snd_seq_queue_tempo_set_ppq(qtempo, 240);
  snd_seq_set_queue_tempo(data->seq, data->queue_id, qtempo);
  snd_seq_drain_output(data->seq);
#endif
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x88(%rbp)
leaq -0x18(%rbp), %rdi
leaq 0x949c(%rip), %rsi      # 0x19225
movl $0x3, %edx
movl $0x1, %ecx
callq 0xd3c0
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jge 0xfe18
movq -0x88(%rbp), %rdi
addq $0x18, %rdi
movq %rdi, -0x98(%rbp)
leaq 0x9473(%rip), %rsi      # 0x1922d
callq 0xdfb0
movq -0x98(%rbp), %rsi
leaq -0x40(%rbp), %rdi
movq %rdi, -0x90(%rbp)
callq 0xd3d0
movq -0x88(%rbp), %rdi
movq -0x90(%rbp), %rdx
movl $0x8, %esi
callq 0xd5f0
jmp 0xfdf0
leaq -0x40(%rbp), %rdi
callq 0xd600
jmp 0xffe5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x40(%rbp), %rdi
callq 0xd600
jmp 0xffea
movq -0x18(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0x10(%rbp), %rdi
callq 0xd3b0
movq -0xa0(%rbp), %rdi
movq %rax, %rsi
callq 0xdbb0
movl $0x58, %edi
callq 0xda40
movq %rax, -0x58(%rbp)
movq -0x18(%rbp), %rcx
movq -0x58(%rbp), %rax
movq %rcx, (%rax)
movq -0x58(%rbp), %rax
movl $0xffffffff, 0x8(%rax)  # imm = 0xFFFFFFFF
movq -0x58(%rbp), %rax
movl $0xffffffff, 0xc(%rax)  # imm = 0xFFFFFFFF
movq -0x58(%rbp), %rax
movq $0x0, 0x10(%rax)
callq 0xd8d0
movq %rax, %rdx
movq -0x88(%rbp), %rax
movq -0x58(%rbp), %rcx
movq %rdx, 0x38(%rcx)
movq -0x58(%rbp), %rcx
movq 0x38(%rcx), %rdx
movq -0x58(%rbp), %rcx
movq %rdx, 0x30(%rcx)
movq -0x58(%rbp), %rcx
movl $0xffffffff, 0x4c(%rcx) # imm = 0xFFFFFFFF
movq -0x58(%rbp), %rcx
movl $0xffffffff, 0x50(%rcx) # imm = 0xFFFFFFFF
movq -0x58(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0x58(%rbp), %rcx
movq %rcx, 0x90(%rax)
movq -0x58(%rbp), %rdi
addq $0x4c, %rdi
callq 0xdfd0
cmpl $-0x1, %eax
jne 0xff4f
movq -0x88(%rbp), %rdi
addq $0x18, %rdi
movq %rdi, -0xb0(%rbp)
leaq 0x9381(%rip), %rsi      # 0x19272
callq 0xdfb0
movq -0xb0(%rbp), %rsi
leaq -0x78(%rbp), %rdi
movq %rdi, -0xa8(%rbp)
callq 0xd3d0
movq -0x88(%rbp), %rdi
movq -0xa8(%rbp), %rdx
movl $0x8, %esi
callq 0xd5f0
jmp 0xff27
leaq -0x78(%rbp), %rdi
callq 0xd600
jmp 0xffe5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x78(%rbp), %rdi
callq 0xd600
jmp 0xffea
movq -0x18(%rbp), %rdi
leaq 0x934d(%rip), %rsi      # 0x192a7
callq 0xde40
movl %eax, %ecx
movq -0x58(%rbp), %rax
movl %ecx, 0x48(%rax)
callq 0xd690
movq %rax, %rcx
addq $0xf, %rcx
andq $-0x10, %rcx
movq %rsp, %rax
subq %rcx, %rax
movq %rax, %rsp
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0xb8(%rbp)
callq 0xd690
movq -0xb8(%rbp), %rdi
movq %rax, %rdx
xorl %esi, %esi
callq 0xd530
movq -0x80(%rbp), %rdi
movl $0x927c0, %esi          # imm = 0x927C0
callq 0xda10
movq -0x80(%rbp), %rdi
movl $0xf0, %esi
callq 0xe0e0
movq -0x58(%rbp), %rax
movq (%rax), %rdi
movq -0x58(%rbp), %rax
movl 0x48(%rax), %esi
movq -0x80(%rbp), %rdx
callq 0xe680
movq -0x58(%rbp), %rax
movq (%rax), %rdi
callq 0xe5b0
movq %rbp, %rsp
popq %rbp
retq
movq -0x48(%rbp), %rdi
callq 0xe590
nopw %cs:(%rax,%rax)