// File: /workspace/github_cpp_makefile_star2_O1/tobias93[P]piano/rtaudio/tests/duplex.cpp
// Function: main
int main( int argc, char *argv[] )
{
  unsigned int channels, fs, bufferBytes, oDevice = 0, iDevice = 0, iOffset = 0, oOffset = 0;

  // Minimal command-line checking
  if (argc < 3 || argc > 7 ) usage();

  RtAudio adac;
  if ( adac.getDeviceCount() < 1 ) {
    std::cout << "\nNo audio devices found!\n";
    exit( 1 );
  }

  channels = (unsigned int) atoi(argv[1]);
  fs = (unsigned int) atoi(argv[2]);
  if ( argc > 3 )
    iDevice = (unsigned int) atoi(argv[3]);
  if ( argc > 4 )
    oDevice = (unsigned int) atoi(argv[4]);
  if ( argc > 5 )
    iOffset = (unsigned int) atoi(argv[5]);
  if ( argc > 6 )
    oOffset = (unsigned int) atoi(argv[6]);

  // Let RtAudio print messages to stderr.
  adac.showWarnings( true );

  // Set the same number of channels for both input and output.
  unsigned int bufferFrames = 512;
  RtAudio::StreamParameters iParams, oParams;
  iParams.deviceId = iDevice;
  iParams.nChannels = channels;
  iParams.firstChannel = iOffset;
  oParams.deviceId = oDevice;
  oParams.nChannels = channels;
  oParams.firstChannel = oOffset;

  if ( iDevice == 0 )
    iParams.deviceId = adac.getDefaultInputDevice();
  if ( oDevice == 0 )
    oParams.deviceId = adac.getDefaultOutputDevice();

  RtAudio::StreamOptions options;
  //options.flags |= RTAUDIO_NONINTERLEAVED;

  bufferBytes = bufferFrames * channels * sizeof( MY_TYPE );
  try {
    adac.openStream( &oParams, &iParams, FORMAT, fs, &bufferFrames, &inout, (void *)&bufferBytes, &options );
  }
  catch ( RtAudioError& e ) {
    std::cout << '\n' << e.getMessage() << '\n' << std::endl;
    exit( 1 );
  }

  // Test RtAudio functionality for reporting latency.
  std::cout << "\nStream latency = " << adac.getStreamLatency() << " frames" << std::endl;

  try {
    adac.startStream();

    char input;
    std::cout << "\nRunning ... press <enter> to quit (buffer frames = " << bufferFrames << ").\n";
    std::cin.get(input);

    // Stop the stream.
    adac.stopStream();
  }
  catch ( RtAudioError& e ) {
    std::cout << '\n' << e.getMessage() << '\n' << std::endl;
    goto cleanup;
  }

 cleanup:
  if ( adac.isStreamOpen() ) adac.closeStream();

  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl %edi, %r15d
leal -0x8(%r15), %eax
cmpl $-0x6, %eax
jbe 0x4931
movq %rsi, %r14
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x4ba0
movq (%rbx), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
testl %eax, %eax
je 0x4936
movq 0x8(%r14), %rdi
callq 0x4330
movl %eax, %ebp
movq 0x10(%r14), %rdi
callq 0x4330
movl %eax, 0x20(%rsp)
xorl %ebx, %ebx
movl $0x0, %r13d
cmpl $0x4, %r15d
jl 0x470b
movq 0x18(%r14), %rdi
callq 0x4330
movl %eax, %r13d
cmpl $0x5, %r15d
jl 0x471c
movq 0x20(%r14), %rdi
callq 0x4330
movl %eax, %ebx
movl %ebx, 0x24(%rsp)
xorl %ebx, %ebx
movl $0x0, %r12d
cmpl $0x6, %r15d
jl 0x473a
movq 0x28(%r14), %rdi
callq 0x4330
movl %eax, %r12d
cmpl $0x7, %r15d
jl 0x474b
movq 0x30(%r14), %rdi
callq 0x4330
movl %eax, %ebx
movq 0x8(%rsp), %rdi
movb $0x1, 0x1a0(%rdi)
movl $0x200, 0x10(%rsp)      # imm = 0x200
movq $0x0, 0x14(%rsp)
movl $0x0, 0x1c(%rsp)
movl %r13d, 0x14(%rsp)
movl %ebp, 0x18(%rsp)
movl %r12d, 0x1c(%rsp)
movl 0x24(%rsp), %r14d
movl %r14d, 0x28(%rsp)
movl %ebp, 0x2c(%rsp)
movl %ebx, 0x30(%rsp)
testl %r13d, %r13d
jne 0x479f
movq (%rdi), %rax
callq *0x28(%rax)
movl %eax, 0x14(%rsp)
testl %r14d, %r14d
jne 0x47b3
movq 0x8(%rsp), %rdi
movq (%rdi), %rax
callq *0x30(%rax)
movl %eax, 0x28(%rsp)
xorl %eax, %eax
leaq 0x50(%rsp), %r15
movq %rax, -0x18(%r15)
movq %r15, -0x10(%r15)
movq %rax, -0x8(%r15)
movb $0x0, (%r15)
leaq 0x10(%rsp), %r9
imull (%r9), %ebp
movl $0x0, 0x10(%r15)
addl %ebp, %ebp
leaq 0x34(%rsp), %r10
movl %ebp, (%r10)
leaq 0x38(%rsp), %r11
leaq -0x1cd(%rip), %rbx      # 0x4624
leaq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %rsi
leaq 0x14(%rsp), %rdx
movl $0x2, %ecx
movl 0x20(%rsp), %r8d
pushq %rax
pushq %r11
pushq %r10
pushq %rbx
callq 0x4d34
addq $0x20, %rsp
movq 0x87a8(%rip), %rdi      # 0xcfc8
leaq 0x49a7(%rip), %rsi      # 0x91ce
movl $0x12, %edx
callq 0x4230
movq 0x8(%rsp), %rdi
callq 0x54ca
movq 0x8786(%rip), %rdi      # 0xcfc8
movq %rax, %rsi
callq 0x41e0
movq %rax, %rbx
leaq 0x498d(%rip), %rsi      # 0x91e1
movl $0x7, %edx
movq %rax, %rdi
callq 0x4230
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x41f0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x4160
movq 0x8(%rsp), %rdi
movq (%rdi), %rax
callq *0x40(%rax)
movq 0x872e(%rip), %rdi      # 0xcfc8
leaq 0x4948(%rip), %rsi      # 0x91e9
movl $0x34, %edx
callq 0x4230
movl 0x10(%rsp), %esi
movq 0x8712(%rip), %rdi      # 0xcfc8
callq 0x4150
leaq 0x495c(%rip), %rsi      # 0x921e
movl $0x3, %edx
movq %rax, %rdi
callq 0x4230
movq 0x8702(%rip), %rdi      # 0xcfd8
leaq 0x7(%rsp), %rsi
callq 0x42b0
movq 0x8(%rsp), %rdi
movq (%rdi), %rax
callq *0x48(%rax)
movq 0x8(%rsp), %rdi
cmpl $-0x32, 0x1bc(%rdi)
je 0x48ff
movq (%rdi), %rax
callq *0x38(%rax)
movq 0x40(%rsp), %rdi
cmpq %r15, %rdi
je 0x4916
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x4220
leaq 0x8(%rsp), %rdi
callq 0x4d24
xorl %eax, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x45ac
movq 0x868b(%rip), %rdi      # 0xcfc8
leaq 0x4870(%rip), %rsi      # 0x91b4
callq 0x4200
movl $0x1, %edi
callq 0x4270
jmp 0x49e9
jmp 0x49e9
jmp 0x49e9
movq %rax, %rbx
jmp 0x4a8a
jmp 0x49f1
movq %rax, %rbx
cmpl $0x2, %edx
jne 0x4a73
movq %rbx, %rdi
callq 0x40a0
movq %rax, %rbx
leaq 0x7(%rsp), %rsi
movb $0xa, (%rsi)
movq 0x8633(%rip), %rdi      # 0xcfc8
movl $0x1, %edx
callq 0x4230
movq %rax, %r14
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x28(%rax)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq %r14, %rdi
callq 0x4230
leaq 0x7(%rsp), %rsi
movb $0xa, (%rsi)
movl $0x1, %edx
movq %rax, %rdi
callq 0x4230
movq %rax, %rdi
callq 0x40d0
jmp 0x4949
movq %rax, %rbx
callq 0x4390
jmp 0x4a73
movq %rax, %rdi
callq 0x4a9c
movq %rax, %rbx
cmpl $0x2, %edx
jne 0x4a73
movq %rbx, %rdi
callq 0x40a0
movq %rax, %rbx
leaq 0x7(%rsp), %rsi
movb $0xa, (%rsi)
movq 0x85b5(%rip), %rdi      # 0xcfc8
movl $0x1, %edx
callq 0x4230
movq %rax, %r14
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x28(%rax)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq %r14, %rdi
callq 0x4230
leaq 0x7(%rsp), %rsi
movb $0xa, (%rsi)
movl $0x1, %edx
movq %rax, %rdi
callq 0x4230
movq %rax, %rdi
callq 0x40d0
callq 0x4390
jmp 0x48eb
jmp 0x4a70
movq %rax, %rbx
callq 0x4390
jmp 0x4a73
jmp 0x49e9
movq %rax, %rbx
movq 0x40(%rsp), %rdi
cmpq %r15, %rdi
je 0x4a8a
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x4220
leaq 0x8(%rsp), %rdi
callq 0x4d24
movq %rbx, %rdi
callq 0x43c0