// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %rbx
subq $0x48, %rsp
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x3a8f(%rip), %rsi      # 0xc22d
leaq -0x20(%rbp), %rdi
pushq $0x3
popq %rdx
pushq $0x1
popq %rcx
callq 0x7160
testl %eax, %eax
js 0x887b
movq -0x20(%rbp), %rdi
movq (%r14), %rsi
callq 0x74e0
pushq $0x58
popq %rdi
callq 0x7480
movq %rax, %r14
movq -0x20(%rbp), %rax
movq %rax, (%r14)
orq $-0x1, 0x8(%r14)
andq $0x0, 0x10(%r14)
callq 0x73c0
movq %rax, 0x38(%r14)
movq %rax, 0x30(%r14)
orq $-0x1, 0x4c(%r14)
leaq 0x4c(%r14), %rdi
movq %r14, 0x8(%rbx)
movq %r14, 0x90(%rbx)
callq 0x7700
cmpl $-0x1, %eax
je 0x88b1
movq -0x20(%rbp), %rdi
leaq 0x3a98(%rip), %rsi      # 0xc2af
callq 0x7620
movl %eax, 0x48(%r14)
callq 0x72a0
movq %rsp, %rbx
addq $0xf, %rax
andq $-0x10, %rax
subq %rax, %rbx
movq %rbx, %rsp
callq 0x72a0
movq %rbx, %rdi
xorl %esi, %esi
movq %rax, %rdx
callq 0x71f0
movq %rbx, %rdi
movl $0x927c0, %esi          # imm = 0x927C0
callq 0x7460
movq %rbx, %rdi
movl $0xf0, %esi
callq 0x7790
movq (%r14), %rdi
movl 0x48(%r14), %esi
movq %rbx, %rdx
callq 0x7aa0
movq (%r14), %rdi
callq 0x7a20
jmp 0x88ea
leaq 0x18(%rbx), %r15
leaq 0x39af(%rip), %rsi      # 0xc235
movq %r15, %rdi
callq 0x7af0
leaq -0x60(%rbp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x7720
pushq $0x8
popq %rsi
movq %rbx, %rdi
movq %r14, %rdx
callq 0x7240
leaq -0x60(%rbp), %rdi
jmp 0x88e5
leaq 0x18(%rbx), %r15
leaq 0x39be(%rip), %rsi      # 0xc27a
movq %r15, %rdi
callq 0x7af0
leaq -0x40(%rbp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x7720
pushq $0x8
popq %rsi
movq %rbx, %rdi
movq %r14, %rdx
callq 0x7240
leaq -0x40(%rbp), %rdi
callq 0x7180
leaq -0x18(%rbp), %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
jmp 0x88f7
movq %rax, %rbx
movq %r14, %rdi
callq 0x7180
movq %rbx, %rdi
callq 0x7a10