// File: tobias93[P]piano/rtaudio/RtAudio.cpp
// Function: RtApiPulse::probeDeviceOpen(unsigned int, RtApi::StreamMode, unsigned int, unsigned int, unsigned int, unsigned long, unsigned int*, RtAudio::StreamOptions*)
bool RtApiPulse::probeDeviceOpen( unsigned int device, StreamMode mode,
                                  unsigned int channels, unsigned int firstChannel,
                                  unsigned int sampleRate, RtAudioFormat format,
                                  unsigned int *bufferSize, RtAudio::StreamOptions *options )
{
  PulseAudioHandle *pah = 0;
  unsigned long bufferBytes = 0;
  pa_sample_spec ss;

  if ( device != 0 ) return false;
  if ( mode != INPUT && mode != OUTPUT ) return false;
  if ( channels != 1 && channels != 2 ) {
    errorText_ = "RtApiPulse::probeDeviceOpen: unsupported number of channels.";
    return false;
  }
  ss.channels = channels;

  if ( firstChannel != 0 ) return false;

  bool sr_found = false;
  for ( const unsigned int *sr = SUPPORTED_SAMPLERATES; *sr; ++sr ) {
    if ( sampleRate == *sr ) {
      sr_found = true;
      stream_.sampleRate = sampleRate;
      ss.rate = sampleRate;
      break;
    }
  }
  if ( !sr_found ) {
    errorText_ = "RtApiPulse::probeDeviceOpen: unsupported sample rate.";
    return false;
  }

  bool sf_found = 0;
  for ( const rtaudio_pa_format_mapping_t *sf = supported_sampleformats;
        sf->rtaudio_format && sf->pa_format != PA_SAMPLE_INVALID; ++sf ) {
    if ( format == sf->rtaudio_format ) {
      sf_found = true;
      stream_.userFormat = sf->rtaudio_format;
      stream_.deviceFormat[mode] = stream_.userFormat;
      ss.format = sf->pa_format;
      break;
    }
  }
  if ( !sf_found ) { // Use internal data format conversion.
    stream_.userFormat = format;
    stream_.deviceFormat[mode] = RTAUDIO_FLOAT32;
    ss.format = PA_SAMPLE_FLOAT32LE;
  }

  // Set other stream parameters.
  if ( options && options->flags & RTAUDIO_NONINTERLEAVED ) stream_.userInterleaved = false;
  else stream_.userInterleaved = true;
  stream_.deviceInterleaved[mode] = true;
  stream_.nBuffers = 1;
  stream_.doByteSwap[mode] = false;
  stream_.nUserChannels[mode] = channels;
  stream_.nDeviceChannels[mode] = channels + firstChannel;
  stream_.channelOffset[mode] = 0;
  std::string streamName = "RtAudio";

  // Set flags for buffer conversion.
  stream_.doConvertBuffer[mode] = false;
  if ( stream_.userFormat != stream_.deviceFormat[mode] )
    stream_.doConvertBuffer[mode] = true;
  if ( stream_.nUserChannels[mode] < stream_.nDeviceChannels[mode] )
    stream_.doConvertBuffer[mode] = true;

  // Allocate necessary internal buffers.
  bufferBytes = stream_.nUserChannels[mode] * *bufferSize * formatBytes( stream_.userFormat );
  stream_.userBuffer[mode] = (char *) calloc( bufferBytes, 1 );
  if ( stream_.userBuffer[mode] == NULL ) {
    errorText_ = "RtApiPulse::probeDeviceOpen: error allocating user buffer memory.";
    goto error;
  }
  stream_.bufferSize = *bufferSize;

  if ( stream_.doConvertBuffer[mode] ) {

    bool makeBuffer = true;
    bufferBytes = stream_.nDeviceChannels[mode] * formatBytes( stream_.deviceFormat[mode] );
    if ( mode == INPUT ) {
      if ( stream_.mode == OUTPUT && stream_.deviceBuffer ) {
        unsigned long bytesOut = stream_.nDeviceChannels[0] * formatBytes( stream_.deviceFormat[0] );
        if ( bufferBytes <= bytesOut ) makeBuffer = false;
      }
    }

    if ( makeBuffer ) {
      bufferBytes *= *bufferSize;
      if ( stream_.deviceBuffer ) free( stream_.deviceBuffer );
      stream_.deviceBuffer = (char *) calloc( bufferBytes, 1 );
      if ( stream_.deviceBuffer == NULL ) {
        errorText_ = "RtApiPulse::probeDeviceOpen: error allocating device buffer memory.";
        goto error;
      }
    }
  }

  stream_.device[mode] = device;

  // Setup the buffer conversion information structure.
  if ( stream_.doConvertBuffer[mode] ) setConvertInfo( mode, firstChannel );

  if ( !stream_.apiHandle ) {
    PulseAudioHandle *pah = new PulseAudioHandle;
    if ( !pah ) {
      errorText_ = "RtApiPulse::probeDeviceOpen: error allocating memory for handle.";
      goto error;
    }

    stream_.apiHandle = pah;
    if ( pthread_cond_init( &pah->runnable_cv, NULL ) != 0 ) {
      errorText_ = "RtApiPulse::probeDeviceOpen: error creating condition variable.";
      goto error;
    }
  }
  pah = static_cast<PulseAudioHandle *>( stream_.apiHandle );

  int error;
  if ( options && !options->streamName.empty() ) streamName = options->streamName;
  switch ( mode ) {
  case INPUT:
    pa_buffer_attr buffer_attr;
    buffer_attr.fragsize = bufferBytes;
    buffer_attr.maxlength = -1;

    pah->s_rec = pa_simple_new( NULL, streamName.c_str(), PA_STREAM_RECORD, NULL, "Record", &ss, NULL, &buffer_attr, &error );
    if ( !pah->s_rec ) {
      errorText_ = "RtApiPulse::probeDeviceOpen: error connecting input to PulseAudio server.";
      goto error;
    }
    break;
  case OUTPUT:
    pah->s_play = pa_simple_new( NULL, streamName.c_str(), PA_STREAM_PLAYBACK, NULL, "Playback", &ss, NULL, NULL, &error );
    if ( !pah->s_play ) {
      errorText_ = "RtApiPulse::probeDeviceOpen: error connecting output to PulseAudio server.";
      goto error;
    }
    break;
  default:
    goto error;
  }

  if ( stream_.mode == UNINITIALIZED )
    stream_.mode = mode;
  else if ( stream_.mode == mode )
    goto error;
  else
    stream_.mode = DUPLEX;

  if ( !stream_.callbackInfo.isRunning ) {
    stream_.callbackInfo.object = this;
    stream_.callbackInfo.isRunning = true;
    if ( pthread_create( &pah->thread, NULL, pulseaudio_callback, (void *)&stream_.callbackInfo) != 0 ) {
      errorText_ = "RtApiPulse::probeDeviceOpen: error creating thread.";
      goto error;
    }
  }

  stream_.state = STREAM_STOPPED;
  return true;
 
 error:
  if ( pah && stream_.callbackInfo.isRunning ) {
    pthread_cond_destroy( &pah->runnable_cv );
    delete pah;
    stream_.apiHandle = 0;
  }

  for ( int i=0; i<2; i++ ) {
    if ( stream_.userBuffer[i] ) {
      free( stream_.userBuffer[i] );
      stream_.userBuffer[i] = 0;
    }
  }

  if ( stream_.deviceBuffer ) {
    free( stream_.deviceBuffer );
    stream_.deviceBuffer = 0;
  }

  return FAILURE;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movl %r9d, -0x24(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0xe5c6
movb $0x0, -0x1(%rbp)
jmp 0xef99
cmpl $0x1, -0x18(%rbp)
je 0xe5db
cmpl $0x0, -0x18(%rbp)
je 0xe5db
movb $0x0, -0x1(%rbp)
jmp 0xef99
cmpl $0x1, -0x1c(%rbp)
je 0xe60a
cmpl $0x2, -0x1c(%rbp)
je 0xe60a
movq -0xd0(%rbp), %rdi
addq $0x180, %rdi            # imm = 0x180
leaq 0x538b(%rip), %rsi      # 0x13987
callq 0x8330
movb $0x0, -0x1(%rbp)
jmp 0xef99
movl -0x1c(%rbp), %eax
movb %al, -0x3c(%rbp)
cmpl $0x0, -0x20(%rbp)
je 0xe61f
movb $0x0, -0x1(%rbp)
jmp 0xef99
movb $0x0, -0x45(%rbp)
leaq 0x4df6(%rip), %rax      # 0x13420
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
cmpl $0x0, (%rax)
je 0xe66e
movl -0x24(%rbp), %eax
movq -0x50(%rbp), %rcx
cmpl (%rcx), %eax
jne 0xe65e
movq -0xd0(%rbp), %rax
movb $0x1, -0x45(%rbp)
movl -0x24(%rbp), %ecx
movl %ecx, 0x1e0(%rax)
movl -0x24(%rbp), %eax
movl %eax, -0x40(%rbp)
jmp 0xe66e
jmp 0xe660
movq -0x50(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x50(%rbp)
jmp 0xe62e
testb $0x1, -0x45(%rbp)
jne 0xe697
movq -0xd0(%rbp), %rdi
addq $0x180, %rdi            # imm = 0x180
leaq 0x533b(%rip), %rsi      # 0x139c4
callq 0x8330
movb $0x0, -0x1(%rbp)
jmp 0xef99
movb $0x0, -0x51(%rbp)
leaq 0x4d9e(%rip), %rax      # 0x13440
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rcx
xorl %eax, %eax
cmpq $0x0, (%rcx)
movb %al, -0xd1(%rbp)
je 0xe6c9
movq -0x60(%rbp), %rax
cmpl $-0x1, 0x8(%rax)
setne %al
movb %al, -0xd1(%rbp)
movb -0xd1(%rbp), %al
testb $0x1, %al
jne 0xe6d5
jmp 0xe72d
movq 0x10(%rbp), %rax
movq -0x60(%rbp), %rcx
cmpq (%rcx), %rax
jne 0xe71a
movq -0xd0(%rbp), %rax
movb $0x1, -0x51(%rbp)
movq -0x60(%rbp), %rcx
movq (%rcx), %rcx
movq %rcx, 0x218(%rax)
movq 0x218(%rax), %rdx
movslq -0x18(%rbp), %rcx
movq %rdx, 0x220(%rax,%rcx,8)
movq -0x60(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x44(%rbp)
jmp 0xe72d
jmp 0xe71c
movq -0x60(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x60(%rbp)
jmp 0xe6a6
testb $0x1, -0x51(%rbp)
jne 0xe75c
movq -0xd0(%rbp), %rax
movq 0x10(%rbp), %rcx
movq %rcx, 0x218(%rax)
movslq -0x18(%rbp), %rcx
movq $0x10, 0x220(%rax,%rcx,8)
movl $0x5, -0x44(%rbp)
cmpq $0x0, 0x20(%rbp)
je 0xe781
movq 0x20(%rbp), %rax
movl (%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0xe781
movq -0xd0(%rbp), %rax
movb $0x0, 0x1da(%rax)
jmp 0xe78f
movq -0xd0(%rbp), %rax
movb $0x1, 0x1da(%rax)
movq -0xd0(%rbp), %rax
movslq -0x18(%rbp), %rcx
movb $0x1, 0x1db(%rax,%rcx)
movl $0x1, 0x1e8(%rax)
movslq -0x18(%rbp), %rcx
movb $0x0, 0x1dd(%rax,%rcx)
movl -0x1c(%rbp), %edx
movslq -0x18(%rbp), %rcx
movl %edx, 0x1ec(%rax,%rcx,4)
movl -0x1c(%rbp), %edx
movl -0x20(%rbp), %ecx
addl %ecx, %edx
movslq -0x18(%rbp), %rcx
movl %edx, 0x1f4(%rax,%rcx,4)
movslq -0x18(%rbp), %rcx
movl $0x0, 0x1fc(%rax,%rcx,4)
leaq -0x81(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
callq 0x8480
movq -0xe0(%rbp), %rdx
leaq 0x51f1(%rip), %rsi      # 0x139fa
leaq -0x80(%rbp), %rdi
callq 0xf9e0
jmp 0xe814
leaq -0x81(%rbp), %rdi
callq 0x8270
movq -0xd0(%rbp), %rcx
movslq -0x18(%rbp), %rax
movb $0x0, 0x1d8(%rcx,%rax)
movq 0x218(%rcx), %rax
movslq -0x18(%rbp), %rdx
cmpq 0x220(%rcx,%rdx,8), %rax
je 0xe880
movq -0xd0(%rbp), %rax
movslq -0x18(%rbp), %rcx
movb $0x1, 0x1d8(%rax,%rcx)
jmp 0xe880
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0x81(%rbp), %rdi
callq 0x8270
jmp 0xefa7
movq -0xd0(%rbp), %rcx
movslq -0x18(%rbp), %rax
movl 0x1ec(%rcx,%rax,4), %eax
movslq -0x18(%rbp), %rdx
cmpl 0x1f4(%rcx,%rdx,4), %eax
jae 0xe8b2
movq -0xd0(%rbp), %rax
movslq -0x18(%rbp), %rcx
movb $0x1, 0x1d8(%rax,%rcx)
movq -0xd0(%rbp), %rdi
movslq -0x18(%rbp), %rax
movl 0x1ec(%rdi,%rax,4), %eax
movq 0x18(%rbp), %rcx
movl (%rcx), %ecx
imull %ecx, %eax
movl %eax, -0xe8(%rbp)
movq 0x218(%rdi), %rsi
callq 0xa3d0
movl %eax, -0xe4(%rbp)
jmp 0xe8e7
movl -0xe4(%rbp), %ecx
movl -0xe8(%rbp), %eax
imull %ecx, %eax
movl %eax, %eax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
movl $0x1, %esi
callq 0x8150
movq %rax, %rdx
movq -0xd0(%rbp), %rax
movslq -0x18(%rbp), %rcx
movq %rdx, 0x1c0(%rax,%rcx,8)
movslq -0x18(%rbp), %rcx
cmpq $0x0, 0x1c0(%rax,%rcx,8)
jne 0xe967
movq -0xd0(%rbp), %rdi
addq $0x180, %rdi            # imm = 0x180
leaq 0x50be(%rip), %rsi      # 0x13a02
callq 0x8330
jmp 0xe94b
jmp 0xee73
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0xef8e
movq -0xd0(%rbp), %rax
movq 0x18(%rbp), %rcx
movl (%rcx), %ecx
movl %ecx, 0x1e4(%rax)
movslq -0x18(%rbp), %rcx
testb $0x1, 0x1d8(%rax,%rcx)
je 0xeadd
movq -0xd0(%rbp), %rdi
movb $0x1, -0x95(%rbp)
movslq -0x18(%rbp), %rax
movl 0x1f4(%rdi,%rax,4), %ecx
movl %ecx, -0xf0(%rbp)
movq 0x220(%rdi,%rax,8), %rsi
callq 0xa3d0
movl %eax, -0xec(%rbp)
jmp 0xe9c0
movl -0xec(%rbp), %ecx
movl -0xf0(%rbp), %eax
imull %ecx, %eax
movl %eax, %eax
movq %rax, -0x38(%rbp)
cmpl $0x1, -0x18(%rbp)
jne 0xea53
movq -0xd0(%rbp), %rax
cmpl $0x0, 0x1b8(%rax)
jne 0xea51
movq -0xd0(%rbp), %rax
cmpq $0x0, 0x1d0(%rax)
je 0xea51
movq -0xd0(%rbp), %rdi
movl 0x1f4(%rdi), %eax
movl %eax, -0xf8(%rbp)
movq 0x220(%rdi), %rsi
callq 0xa3d0
movl %eax, -0xf4(%rbp)
jmp 0xea23
movl -0xf4(%rbp), %ecx
movl -0xf8(%rbp), %eax
imull %ecx, %eax
movl %eax, %eax
movq %rax, -0xa0(%rbp)
movq -0x38(%rbp), %rax
cmpq -0xa0(%rbp), %rax
ja 0xea4f
movb $0x0, -0x95(%rbp)
jmp 0xea51
jmp 0xea53
testb $0x1, -0x95(%rbp)
je 0xeadb
movq -0xd0(%rbp), %rax
movq 0x18(%rbp), %rcx
movl (%rcx), %ecx
imulq -0x38(%rbp), %rcx
movq %rcx, -0x38(%rbp)
cmpq $0x0, 0x1d0(%rax)
je 0xea8f
movq -0xd0(%rbp), %rax
movq 0x1d0(%rax), %rdi
callq 0x82d0
movq -0x38(%rbp), %rdi
movl $0x1, %esi
callq 0x8150
movq %rax, %rcx
movq -0xd0(%rbp), %rax
movq %rcx, 0x1d0(%rax)
cmpq $0x0, 0x1d0(%rax)
jne 0xead9
movq -0xd0(%rbp), %rdi
addq $0x180, %rdi            # imm = 0x180
leaq 0x4f77(%rip), %rsi      # 0x13a44
callq 0x8330
jmp 0xead4
jmp 0xee73
jmp 0xeadb
jmp 0xeadd
movq -0xd0(%rbp), %rax
movl -0x14(%rbp), %edx
movslq -0x18(%rbp), %rcx
movl %edx, 0x1a8(%rax,%rcx,4)
movslq -0x18(%rbp), %rcx
testb $0x1, 0x1d8(%rax,%rcx)
je 0xeb16
movq -0xd0(%rbp), %rdi
movl -0x18(%rbp), %esi
movl -0x20(%rbp), %edx
callq 0xefc0
jmp 0xeb14
jmp 0xeb16
movq -0xd0(%rbp), %rax
cmpq $0x0, 0x1b0(%rax)
jne 0xebfe
movl $0x50, %edi
callq 0x8220
movq %rax, -0x100(%rbp)
jmp 0xeb3e
movq -0x100(%rbp), %rdi
callq 0xfed0
jmp 0xeb4c
movq -0x100(%rbp), %rax
movq %rax, -0xa8(%rbp)
cmpq $0x0, -0xa8(%rbp)
jne 0xebad
movq -0xd0(%rbp), %rdi
addq $0x180, %rdi            # imm = 0x180
leaq 0x4f0f(%rip), %rsi      # 0x13a88
callq 0x8330
jmp 0xeb80
jmp 0xee73
movq -0x100(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
movl $0x50, %esi
callq 0x8230
jmp 0xef8e
movq -0xd0(%rbp), %rax
movq -0xa8(%rbp), %rcx
movq %rcx, 0x1b0(%rax)
movq -0xa8(%rbp), %rdi
addq $0x18, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x82e0
cmpl $0x0, %eax
je 0xebfc
movq -0xd0(%rbp), %rdi
addq $0x180, %rdi            # imm = 0x180
leaq 0x4ed9(%rip), %rsi      # 0x13ac9
callq 0x8330
jmp 0xebf7
jmp 0xee73
jmp 0xebfe
movq -0xd0(%rbp), %rax
movq 0x1b0(%rax), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, 0x20(%rbp)
je 0xec3d
movq 0x20(%rbp), %rdi
addq $0x8, %rdi
callq 0x8430
testb $0x1, %al
jne 0xec3d
movq 0x20(%rbp), %rsi
addq $0x8, %rsi
leaq -0x80(%rbp), %rdi
callq 0x8040
jmp 0xec3b
jmp 0xec3d
movl -0x18(%rbp), %eax
movl %eax, -0x104(%rbp)
testl %eax, %eax
je 0xed05
jmp 0xec50
movl -0x104(%rbp), %eax
subl $0x1, %eax
jne 0xed8e
jmp 0xec61
movl -0x38(%rbp), %eax
movl %eax, -0xb0(%rbp)
movl $0xffffffff, -0xc0(%rbp) # imm = 0xFFFFFFFF
leaq -0x80(%rbp), %rdi
callq 0x80d0
movq %rax, %rsi
movq %rsp, %rax
leaq -0xac(%rbp), %rcx
movq %rcx, 0x10(%rax)
leaq -0xc0(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq $0x0, (%rax)
leaq 0x4e62(%rip), %r8       # 0x13b09
xorl %eax, %eax
movl %eax, %ecx
movl $0x2, %edx
leaq -0x44(%rbp), %r9
movq %rcx, %rdi
callq 0x8200
movq %rax, -0x110(%rbp)
jmp 0xecc5
movq -0x110(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x30(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0xed00
movq -0xd0(%rbp), %rdi
addq $0x180, %rdi            # imm = 0x180
leaq 0x4e1c(%rip), %rsi      # 0x13b10
callq 0x8330
jmp 0xecfb
jmp 0xee73
jmp 0xed93
leaq -0x80(%rbp), %rdi
callq 0x80d0
movq %rax, %rsi
movq %rsp, %rax
leaq -0xac(%rbp), %rcx
movq %rcx, 0x10(%rax)
movq $0x0, 0x8(%rax)
movq $0x0, (%rax)
leaq 0x4e25(%rip), %r8       # 0x13b5a
xorl %eax, %eax
movl %eax, %ecx
movl $0x1, %edx
leaq -0x44(%rbp), %r9
movq %rcx, %rdi
callq 0x8200
movq %rax, -0x118(%rbp)
jmp 0xed53
movq -0x118(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
movq -0x30(%rbp), %rax
cmpq $0x0, (%rax)
jne 0xed8c
movq -0xd0(%rbp), %rdi
addq $0x180, %rdi            # imm = 0x180
leaq 0x4de3(%rip), %rsi      # 0x13b63
callq 0x8330
jmp 0xed87
jmp 0xee73
jmp 0xed93
jmp 0xee73
movq -0xd0(%rbp), %rax
cmpl $-0x4b, 0x1b8(%rax)
jne 0xedb5
movq -0xd0(%rbp), %rax
movl -0x18(%rbp), %ecx
movl %ecx, 0x1b8(%rax)
jmp 0xeddf
movq -0xd0(%rbp), %rax
movl 0x1b8(%rax), %eax
cmpl -0x18(%rbp), %eax
jne 0xedcc
jmp 0xee73
movq -0xd0(%rbp), %rax
movl $0x2, 0x1b8(%rax)
jmp 0xeddf
movq -0xd0(%rbp), %rax
testb $0x1, 0x288(%rax)
jne 0xee4f
movq -0xd0(%rbp), %rcx
movq %rcx, 0x258(%rcx)
movb $0x1, 0x288(%rcx)
movq -0x30(%rbp), %rdi
addq $0x10, %rdi
addq $0x1a8, %rcx            # imm = 0x1A8
addq $0xb0, %rcx
xorl %eax, %eax
movl %eax, %esi
leaq 0x93b(%rip), %rdx       # 0xf760
callq 0x84a0
cmpl $0x0, %eax
je 0xee4d
movq -0xd0(%rbp), %rdi
addq $0x180, %rdi            # imm = 0x180
leaq 0x4d6a(%rip), %rsi      # 0x13bae
callq 0x8330
jmp 0xee4b
jmp 0xee73
jmp 0xee4f
movq -0xd0(%rbp), %rax
movl $0x0, 0x1bc(%rax)
movb $0x1, -0x1(%rbp)
movl $0x1, -0xc4(%rbp)
jmp 0xef83
cmpq $0x0, -0x30(%rbp)
je 0xeecb
movq -0xd0(%rbp), %rax
testb $0x1, 0x288(%rax)
je 0xeecb
movq -0x30(%rbp), %rdi
addq $0x18, %rdi
callq 0x84c0
movq -0x30(%rbp), %rax
movq %rax, -0x120(%rbp)
cmpq $0x0, %rax
je 0xeeb9
movq -0x120(%rbp), %rdi
movl $0x50, %esi
callq 0x8230
movq -0xd0(%rbp), %rax
movq $0x0, 0x1b0(%rax)
movl $0x0, -0xc8(%rbp)
cmpl $0x2, -0xc8(%rbp)
jge 0xef3f
movq -0xd0(%rbp), %rax
movslq -0xc8(%rbp), %rcx
cmpq $0x0, 0x1c0(%rax,%rcx,8)
je 0xef2c
movq -0xd0(%rbp), %rax
movslq -0xc8(%rbp), %rcx
movq 0x1c0(%rax,%rcx,8), %rdi
callq 0x82d0
movq -0xd0(%rbp), %rax
movslq -0xc8(%rbp), %rcx
movq $0x0, 0x1c0(%rax,%rcx,8)
jmp 0xef2e
movl -0xc8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc8(%rbp)
jmp 0xeed5
movq -0xd0(%rbp), %rax
cmpq $0x0, 0x1d0(%rax)
je 0xef75
movq -0xd0(%rbp), %rax
movq 0x1d0(%rax), %rdi
callq 0x82d0
movq -0xd0(%rbp), %rax
movq $0x0, 0x1d0(%rax)
movb $0x0, -0x1(%rbp)
movl $0x1, -0xc4(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x8140
jmp 0xef99
leaq -0x80(%rbp), %rdi
callq 0x8140
jmp 0xefa7
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
movq -0x90(%rbp), %rdi
callq 0x8460
nopw %cs:(%rax,%rax)