// File: /workspace/github_cpp_makefile_star2_O2/tobias93[P]piano/rtaudio/RtAudio.cpp
// Function: RtApi::setConvertInfo(RtApi::StreamMode, unsigned int)
void RtApi :: setConvertInfo( StreamMode mode, unsigned int firstChannel )
{
  if ( mode == INPUT ) { // convert device to user buffer
    stream_.convertInfo[mode].inJump = stream_.nDeviceChannels[1];
    stream_.convertInfo[mode].outJump = stream_.nUserChannels[1];
    stream_.convertInfo[mode].inFormat = stream_.deviceFormat[1];
    stream_.convertInfo[mode].outFormat = stream_.userFormat;
  }
  else { // convert user to device buffer
    stream_.convertInfo[mode].inJump = stream_.nUserChannels[0];
    stream_.convertInfo[mode].outJump = stream_.nDeviceChannels[0];
    stream_.convertInfo[mode].inFormat = stream_.userFormat;
    stream_.convertInfo[mode].outFormat = stream_.deviceFormat[0];
  }

  if ( stream_.convertInfo[mode].inJump < stream_.convertInfo[mode].outJump )
    stream_.convertInfo[mode].channels = stream_.convertInfo[mode].inJump;
  else
    stream_.convertInfo[mode].channels = stream_.convertInfo[mode].outJump;

  // Set up the interleave/deinterleave offsets.
  if ( stream_.deviceInterleaved[mode] != stream_.userInterleaved ) {
    if ( ( mode == OUTPUT && stream_.deviceInterleaved[mode] ) ||
         ( mode == INPUT && stream_.userInterleaved ) ) {
      for ( int k=0; k<stream_.convertInfo[mode].channels; k++ ) {
        stream_.convertInfo[mode].inOffset.push_back( k * stream_.bufferSize );
        stream_.convertInfo[mode].outOffset.push_back( k );
        stream_.convertInfo[mode].inJump = 1;
      }
    }
    else {
      for ( int k=0; k<stream_.convertInfo[mode].channels; k++ ) {
        stream_.convertInfo[mode].inOffset.push_back( k );
        stream_.convertInfo[mode].outOffset.push_back( k * stream_.bufferSize );
        stream_.convertInfo[mode].outJump = 1;
      }
    }
  }
  else { // no (de)interleaving
    if ( stream_.userInterleaved ) {
      for ( int k=0; k<stream_.convertInfo[mode].channels; k++ ) {
        stream_.convertInfo[mode].inOffset.push_back( k );
        stream_.convertInfo[mode].outOffset.push_back( k );
      }
    }
    else {
      for ( int k=0; k<stream_.convertInfo[mode].channels; k++ ) {
        stream_.convertInfo[mode].inOffset.push_back( k * stream_.bufferSize );
        stream_.convertInfo[mode].outOffset.push_back( k * stream_.bufferSize );
        stream_.convertInfo[mode].inJump = 1;
        stream_.convertInfo[mode].outJump = 1;
      }
    }
  }

  // Add channel offset.
  if ( firstChannel > 0 ) {
    if ( stream_.deviceInterleaved[mode] ) {
      if ( mode == OUTPUT ) {
        for ( int k=0; k<stream_.convertInfo[mode].channels; k++ )
          stream_.convertInfo[mode].outOffset[k] += firstChannel;
      }
      else {
        for ( int k=0; k<stream_.convertInfo[mode].channels; k++ )
          stream_.convertInfo[mode].inOffset[k] += firstChannel;
      }
    }
    else {
      if ( mode == OUTPUT ) {
        for ( int k=0; k<stream_.convertInfo[mode].channels; k++ )
          stream_.convertInfo[mode].outOffset[k] += ( firstChannel * stream_.bufferSize );
      }
      else {
        for ( int k=0; k<stream_.convertInfo[mode].channels; k++ )
          stream_.convertInfo[mode].inOffset[k] += ( firstChannel  * stream_.bufferSize );
      }
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %esi, %ebp
movq %rdi, %r14
cmpl $0x1, %esi
jne 0x7476
movl 0x1f0(%r14), %eax
movl 0x1f8(%r14), %ecx
movl %ecx, 0x2e4(%r14)
movl %eax, 0x2e8(%r14)
movq 0x228(%r14), %rsi
movq %rsi, 0x2f0(%r14)
movq 0x218(%r14), %rsi
movq %rsi, 0x2f8(%r14)
pushq $0x1
popq %r8
jmp 0x74ac
movl 0x1ec(%r14), %ecx
movslq %ebp, %r8
imulq $0x50, %r8, %rsi
movl %ecx, 0x294(%r14,%rsi)
movl 0x1f4(%r14), %eax
movl %eax, 0x298(%r14,%rsi)
movups 0x218(%r14), %xmm0
movups %xmm0, 0x2a0(%r14,%rsi)
imulq $0x50, %r8, %rsi
leaq (%r14,%rsi), %rbx
addq $0x290, %rbx            # imm = 0x290
cmpl %eax, %ecx
cmovll %ecx, %eax
movl %eax, (%rbx)
movb 0x1db(%r14,%r8), %dil
movb 0x1da(%r14), %cl
cmpb %cl, %dil
movl %edx, 0xc(%rsp)
movl %ebp, 0x8(%rsp)
movq %r8, 0x10(%rsp)
jne 0x7523
leaq 0x38(%rbx), %r15
leaq 0x20(%rbx), %r12
testb %dil, %dil
je 0x7581
xorl %ecx, %ecx
movq %rsp, %r13
movl %ecx, (%rsp)
cmpl %eax, %ecx
jge 0x762d
movq %r12, %rdi
movq %r13, %rsi
callq 0x794c
movq %r15, %rdi
movq %r13, %rsi
callq 0x794c
movl (%rsp), %ecx
incl %ecx
movl (%rbx), %eax
jmp 0x74f9
testl %ebp, %ebp
sete %sil
testb %dil, %sil
je 0x75d2
leaq 0x20(%rbx), %r15
leaq 0x38(%rbx), %r12
xorl %ecx, %ecx
leaq 0x4(%rsp), %r13
movq %rsp, %rbp
movl %ecx, (%rsp)
cmpl %eax, %ecx
jge 0x762d
imull 0x1e4(%r14), %ecx
movl %ecx, 0x4(%rsp)
movq %r15, %rdi
movq %r13, %rsi
callq 0x7e38
movq %r12, %rdi
movq %rbp, %rsi
callq 0x794c
movl $0x1, 0x4(%rbx)
movl (%rsp), %ecx
incl %ecx
movl (%rbx), %eax
jmp 0x7544
xorl %ebp, %ebp
movq %rsp, %r13
cmpl %eax, %ebp
jge 0x762d
movl 0x1e4(%r14), %eax
imull %ebp, %eax
movl %eax, (%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x7e38
movl 0x1e4(%r14), %eax
imull %ebp, %eax
movl %eax, (%rsp)
movq %r15, %rdi
movq %r13, %rsi
callq 0x7e38
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x4(%rbx)
incl %ebp
movl (%rbx), %eax
jmp 0x7586
cmpl $0x1, %ebp
jne 0x75df
testb %cl, %cl
jne 0x7532
leaq 0x20(%rbx), %r15
leaq 0x38(%rbx), %r12
xorl %ecx, %ecx
movq %rsp, %r13
leaq 0x4(%rsp), %rbp
movl %ecx, (%rsp)
cmpl %eax, %ecx
jge 0x762d
movq %r15, %rdi
movq %r13, %rsi
callq 0x794c
movl 0x1e4(%r14), %eax
imull (%rsp), %eax
movl %eax, 0x4(%rsp)
movq %r12, %rdi
movq %rbp, %rsi
callq 0x7e38
movl $0x1, 0x8(%rbx)
movl (%rsp), %ecx
incl %ecx
movl (%rbx), %eax
jmp 0x75f1
movl 0xc(%rsp), %esi
testl %esi, %esi
je 0x76c7
movq 0x10(%rsp), %rcx
cmpb $0x1, 0x1db(%r14,%rcx)
jne 0x7667
cmpl $0x0, 0x8(%rsp)
je 0x768f
xorl %ecx, %ecx
cltq
cmpq %rax, %rcx
jge 0x76c7
movq 0x20(%rbx), %rax
addl %esi, (%rax,%rcx,4)
incq %rcx
movl (%rbx), %eax
jmp 0x7652
cmpl $0x0, 0x8(%rsp)
je 0x76a6
xorl %ecx, %ecx
cltq
cmpq %rax, %rcx
jge 0x76c7
movl 0x1e4(%r14), %eax
imull %esi, %eax
movq 0x20(%rbx), %rdx
addl %eax, (%rdx,%rcx,4)
incq %rcx
movl (%rbx), %eax
jmp 0x7670
xorl %ecx, %ecx
cltq
cmpq %rax, %rcx
jge 0x76c7
movq 0x38(%rbx), %rax
addl %esi, (%rax,%rcx,4)
incq %rcx
movl (%rbx), %eax
jmp 0x7691
xorl %ecx, %ecx
cltq
cmpq %rax, %rcx
jge 0x76c7
movl 0x1e4(%r14), %eax
imull %esi, %eax
movq 0x38(%rbx), %rdx
addl %eax, (%rdx,%rcx,4)
incq %rcx
movl (%rbx), %eax
jmp 0x76a8
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq