// File: 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
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x48(%rbp)
cmpl $0x1, -0xc(%rbp)
jne 0xf080
movq -0x48(%rbp), %rax
movl 0x1f8(%rax), %edx
movq %rax, %rcx
addq $0x1a8, %rcx            # imm = 0x1A8
addq $0xe8, %rcx
movslq -0xc(%rbp), %rsi
imulq $0x50, %rsi, %rsi
addq %rsi, %rcx
movl %edx, 0x4(%rcx)
movl 0x1f0(%rax), %edx
movq %rax, %rcx
addq $0x1a8, %rcx            # imm = 0x1A8
addq $0xe8, %rcx
movslq -0xc(%rbp), %rsi
imulq $0x50, %rsi, %rsi
addq %rsi, %rcx
movl %edx, 0x8(%rcx)
movq 0x228(%rax), %rdx
movq %rax, %rcx
addq $0x1a8, %rcx            # imm = 0x1A8
addq $0xe8, %rcx
movslq -0xc(%rbp), %rsi
imulq $0x50, %rsi, %rsi
addq %rsi, %rcx
movq %rdx, 0x10(%rcx)
movq 0x218(%rax), %rcx
addq $0x1a8, %rax            # imm = 0x1A8
addq $0xe8, %rax
movslq -0xc(%rbp), %rdx
imulq $0x50, %rdx, %rdx
addq %rdx, %rax
movq %rcx, 0x18(%rax)
jmp 0xf117
movq -0x48(%rbp), %rax
movl 0x1ec(%rax), %edx
movq %rax, %rcx
addq $0x1a8, %rcx            # imm = 0x1A8
addq $0xe8, %rcx
movslq -0xc(%rbp), %rsi
imulq $0x50, %rsi, %rsi
addq %rsi, %rcx
movl %edx, 0x4(%rcx)
movl 0x1f4(%rax), %edx
movq %rax, %rcx
addq $0x1a8, %rcx            # imm = 0x1A8
addq $0xe8, %rcx
movslq -0xc(%rbp), %rsi
imulq $0x50, %rsi, %rsi
addq %rsi, %rcx
movl %edx, 0x8(%rcx)
movq 0x218(%rax), %rdx
movq %rax, %rcx
addq $0x1a8, %rcx            # imm = 0x1A8
addq $0xe8, %rcx
movslq -0xc(%rbp), %rsi
imulq $0x50, %rsi, %rsi
addq %rsi, %rcx
movq %rdx, 0x10(%rcx)
movq 0x220(%rax), %rcx
addq $0x1a8, %rax            # imm = 0x1A8
addq $0xe8, %rax
movslq -0xc(%rbp), %rdx
imulq $0x50, %rdx, %rdx
addq %rdx, %rax
movq %rcx, 0x18(%rax)
movq -0x48(%rbp), %rcx
movq %rcx, %rax
addq $0x1a8, %rax            # imm = 0x1A8
addq $0xe8, %rax
movslq -0xc(%rbp), %rdx
imulq $0x50, %rdx, %rdx
addq %rdx, %rax
movl 0x4(%rax), %eax
addq $0x1a8, %rcx            # imm = 0x1A8
addq $0xe8, %rcx
movslq -0xc(%rbp), %rdx
imulq $0x50, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x8(%rcx), %eax
jge 0xf194
movq -0x48(%rbp), %rax
movq %rax, %rcx
addq $0x1a8, %rcx            # imm = 0x1A8
addq $0xe8, %rcx
movslq -0xc(%rbp), %rdx
imulq $0x50, %rdx, %rdx
addq %rdx, %rcx
movl 0x4(%rcx), %ecx
addq $0x1a8, %rax            # imm = 0x1A8
addq $0xe8, %rax
movslq -0xc(%rbp), %rdx
imulq $0x50, %rdx, %rdx
addq %rdx, %rax
movl %ecx, (%rax)
jmp 0xf1d0
movq -0x48(%rbp), %rax
movq %rax, %rcx
addq $0x1a8, %rcx            # imm = 0x1A8
addq $0xe8, %rcx
movslq -0xc(%rbp), %rdx
imulq $0x50, %rdx, %rdx
addq %rdx, %rcx
movl 0x8(%rcx), %ecx
addq $0x1a8, %rax            # imm = 0x1A8
addq $0xe8, %rax
movslq -0xc(%rbp), %rdx
imulq $0x50, %rdx, %rdx
addq %rdx, %rax
movl %ecx, (%rax)
movq -0x48(%rbp), %rcx
movslq -0xc(%rbp), %rax
movb 0x1db(%rcx,%rax), %al
andb $0x1, %al
movzbl %al, %eax
movb 0x1da(%rcx), %cl
andb $0x1, %cl
movzbl %cl, %ecx
cmpl %ecx, %eax
je 0xf3bd
cmpl $0x0, -0xc(%rbp)
jne 0xf210
movq -0x48(%rbp), %rax
movslq -0xc(%rbp), %rcx
testb $0x1, 0x1db(%rax,%rcx)
jne 0xf22b
cmpl $0x1, -0xc(%rbp)
jne 0xf2f3
movq -0x48(%rbp), %rax
testb $0x1, 0x1da(%rax)
je 0xf2f3
movl $0x0, -0x14(%rbp)
movq -0x48(%rbp), %rcx
movl -0x14(%rbp), %eax
addq $0x1a8, %rcx            # imm = 0x1A8
addq $0xe8, %rcx
movslq -0xc(%rbp), %rdx
imulq $0x50, %rdx, %rdx
addq %rdx, %rcx
cmpl (%rcx), %eax
jge 0xf2ee
movq -0x48(%rbp), %rcx
movq %rcx, %rdi
addq $0x1a8, %rdi            # imm = 0x1A8
addq $0xe8, %rdi
movslq -0xc(%rbp), %rax
imulq $0x50, %rax, %rax
addq %rax, %rdi
addq $0x20, %rdi
movl -0x14(%rbp), %eax
imull 0x1e4(%rcx), %eax
movl %eax, -0x18(%rbp)
leaq -0x18(%rbp), %rsi
callq 0xff20
movq -0x48(%rbp), %rdi
addq $0x1a8, %rdi            # imm = 0x1A8
addq $0xe8, %rdi
movslq -0xc(%rbp), %rax
imulq $0x50, %rax, %rax
addq %rax, %rdi
addq $0x38, %rdi
leaq -0x14(%rbp), %rsi
callq 0xff50
movq -0x48(%rbp), %rax
addq $0x1a8, %rax            # imm = 0x1A8
addq $0xe8, %rax
movslq -0xc(%rbp), %rcx
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movl $0x1, 0x4(%rax)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0xf232
jmp 0xf3b8
movl $0x0, -0x1c(%rbp)
movq -0x48(%rbp), %rcx
movl -0x1c(%rbp), %eax
addq $0x1a8, %rcx            # imm = 0x1A8
addq $0xe8, %rcx
movslq -0xc(%rbp), %rdx
imulq $0x50, %rdx, %rdx
addq %rdx, %rcx
cmpl (%rcx), %eax
jge 0xf3b6
movq -0x48(%rbp), %rdi
addq $0x1a8, %rdi            # imm = 0x1A8
addq $0xe8, %rdi
movslq -0xc(%rbp), %rax
imulq $0x50, %rax, %rax
addq %rax, %rdi
addq $0x20, %rdi
leaq -0x1c(%rbp), %rsi
callq 0xff50
movq -0x48(%rbp), %rcx
movq %rcx, %rdi
addq $0x1a8, %rdi            # imm = 0x1A8
addq $0xe8, %rdi
movslq -0xc(%rbp), %rax
imulq $0x50, %rax, %rax
addq %rax, %rdi
addq $0x38, %rdi
movl -0x1c(%rbp), %eax
imull 0x1e4(%rcx), %eax
movl %eax, -0x20(%rbp)
leaq -0x20(%rbp), %rsi
callq 0xff20
movq -0x48(%rbp), %rax
addq $0x1a8, %rax            # imm = 0x1A8
addq $0xe8, %rax
movslq -0xc(%rbp), %rcx
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movl $0x1, 0x8(%rax)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xf2fa
jmp 0xf3b8
jmp 0xf55a
movq -0x48(%rbp), %rax
testb $0x1, 0x1da(%rax)
je 0xf460
movl $0x0, -0x24(%rbp)
movq -0x48(%rbp), %rcx
movl -0x24(%rbp), %eax
addq $0x1a8, %rcx            # imm = 0x1A8
addq $0xe8, %rcx
movslq -0xc(%rbp), %rdx
imulq $0x50, %rdx, %rdx
addq %rdx, %rcx
cmpl (%rcx), %eax
jge 0xf45b
movq -0x48(%rbp), %rdi
addq $0x1a8, %rdi            # imm = 0x1A8
addq $0xe8, %rdi
movslq -0xc(%rbp), %rax
imulq $0x50, %rax, %rax
addq %rax, %rdi
addq $0x20, %rdi
leaq -0x24(%rbp), %rsi
callq 0xff50
movq -0x48(%rbp), %rdi
addq $0x1a8, %rdi            # imm = 0x1A8
addq $0xe8, %rdi
movslq -0xc(%rbp), %rax
imulq $0x50, %rax, %rax
addq %rax, %rdi
addq $0x38, %rdi
leaq -0x24(%rbp), %rsi
callq 0xff50
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xf3d5
jmp 0xf558
movl $0x0, -0x28(%rbp)
movq -0x48(%rbp), %rcx
movl -0x28(%rbp), %eax
addq $0x1a8, %rcx            # imm = 0x1A8
addq $0xe8, %rcx
movslq -0xc(%rbp), %rdx
imulq $0x50, %rdx, %rdx
addq %rdx, %rcx
cmpl (%rcx), %eax
jge 0xf556
movq -0x48(%rbp), %rcx
movq %rcx, %rdi
addq $0x1a8, %rdi            # imm = 0x1A8
addq $0xe8, %rdi
movslq -0xc(%rbp), %rax
imulq $0x50, %rax, %rax
addq %rax, %rdi
addq $0x20, %rdi
movl -0x28(%rbp), %eax
imull 0x1e4(%rcx), %eax
movl %eax, -0x2c(%rbp)
leaq -0x2c(%rbp), %rsi
callq 0xff20
movq -0x48(%rbp), %rcx
movq %rcx, %rdi
addq $0x1a8, %rdi            # imm = 0x1A8
addq $0xe8, %rdi
movslq -0xc(%rbp), %rax
imulq $0x50, %rax, %rax
addq %rax, %rdi
addq $0x38, %rdi
movl -0x28(%rbp), %eax
imull 0x1e4(%rcx), %eax
movl %eax, -0x30(%rbp)
leaq -0x30(%rbp), %rsi
callq 0xff20
movq -0x48(%rbp), %rax
movq %rax, %rcx
addq $0x1a8, %rcx            # imm = 0x1A8
addq $0xe8, %rcx
movslq -0xc(%rbp), %rdx
imulq $0x50, %rdx, %rdx
addq %rdx, %rcx
movl $0x1, 0x4(%rcx)
addq $0x1a8, %rax            # imm = 0x1A8
addq $0xe8, %rax
movslq -0xc(%rbp), %rcx
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movl $0x1, 0x8(%rax)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0xf467
jmp 0xf558
jmp 0xf55a
cmpl $0x0, -0x10(%rbp)
jbe 0xf759
movq -0x48(%rbp), %rax
movslq -0xc(%rbp), %rcx
testb $0x1, 0x1db(%rax,%rcx)
je 0xf663
cmpl $0x0, -0xc(%rbp)
jne 0xf5ef
movl $0x0, -0x34(%rbp)
movq -0x48(%rbp), %rcx
movl -0x34(%rbp), %eax
addq $0x1a8, %rcx            # imm = 0x1A8
addq $0xe8, %rcx
movslq -0xc(%rbp), %rdx
imulq $0x50, %rdx, %rdx
addq %rdx, %rcx
cmpl (%rcx), %eax
jge 0xf5ed
movq -0x48(%rbp), %rdi
movl -0x10(%rbp), %eax
movl %eax, -0x4c(%rbp)
addq $0x1a8, %rdi            # imm = 0x1A8
addq $0xe8, %rdi
movslq -0xc(%rbp), %rax
imulq $0x50, %rax, %rax
addq %rax, %rdi
addq $0x38, %rdi
movslq -0x34(%rbp), %rsi
callq 0xffc0
movl -0x4c(%rbp), %ecx
addl (%rax), %ecx
movl %ecx, (%rax)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0xf587
jmp 0xf65e
movl $0x0, -0x38(%rbp)
movq -0x48(%rbp), %rcx
movl -0x38(%rbp), %eax
addq $0x1a8, %rcx            # imm = 0x1A8
addq $0xe8, %rcx
movslq -0xc(%rbp), %rdx
imulq $0x50, %rdx, %rdx
addq %rdx, %rcx
cmpl (%rcx), %eax
jge 0xf65c
movq -0x48(%rbp), %rdi
movl -0x10(%rbp), %eax
movl %eax, -0x50(%rbp)
addq $0x1a8, %rdi            # imm = 0x1A8
addq $0xe8, %rdi
movslq -0xc(%rbp), %rax
imulq $0x50, %rax, %rax
addq %rax, %rdi
addq $0x20, %rdi
movslq -0x38(%rbp), %rsi
callq 0xffc0
movl -0x50(%rbp), %ecx
addl (%rax), %ecx
movl %ecx, (%rax)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0xf5f6
jmp 0xf65e
jmp 0xf757
cmpl $0x0, -0xc(%rbp)
jne 0xf6df
movl $0x0, -0x3c(%rbp)
movq -0x48(%rbp), %rcx
movl -0x3c(%rbp), %eax
addq $0x1a8, %rcx            # imm = 0x1A8
addq $0xe8, %rcx
movslq -0xc(%rbp), %rdx
imulq $0x50, %rdx, %rdx
addq %rdx, %rcx
cmpl (%rcx), %eax
jge 0xf6dd
movq -0x48(%rbp), %rdi
movl -0x10(%rbp), %eax
imull 0x1e4(%rdi), %eax
movl %eax, -0x54(%rbp)
addq $0x1a8, %rdi            # imm = 0x1A8
addq $0xe8, %rdi
movslq -0xc(%rbp), %rax
imulq $0x50, %rax, %rax
addq %rax, %rdi
addq $0x38, %rdi
movslq -0x3c(%rbp), %rsi
callq 0xffc0
movl -0x54(%rbp), %ecx
addl (%rax), %ecx
movl %ecx, (%rax)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0xf670
jmp 0xf755
movl $0x0, -0x40(%rbp)
movq -0x48(%rbp), %rcx
movl -0x40(%rbp), %eax
addq $0x1a8, %rcx            # imm = 0x1A8
addq $0xe8, %rcx
movslq -0xc(%rbp), %rdx
imulq $0x50, %rdx, %rdx
addq %rdx, %rcx
cmpl (%rcx), %eax
jge 0xf753
movq -0x48(%rbp), %rdi
movl -0x10(%rbp), %eax
imull 0x1e4(%rdi), %eax
movl %eax, -0x58(%rbp)
addq $0x1a8, %rdi            # imm = 0x1A8
addq $0xe8, %rdi
movslq -0xc(%rbp), %rax
imulq $0x50, %rax, %rax
addq %rax, %rdi
addq $0x20, %rdi
movslq -0x40(%rbp), %rsi
callq 0xffc0
movl -0x58(%rbp), %ecx
addl (%rax), %ecx
movl %ecx, (%rax)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0xf6e6
jmp 0xf755
jmp 0xf757
jmp 0xf759
addq $0x60, %rsp
popq %rbp
retq
nop