// File: /workspace/github_cpp_makefile_star2_O3/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, %r13d
leal -0x8(%r13), %eax
cmpl $-0x6, %eax
jbe 0x4922
movq %rsi, %r14
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x4b92
movq (%rbx), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
testl %eax, %eax
je 0x4927
movq 0x8(%r14), %rdi
callq 0x4330
movl %eax, %ebp
movq 0x10(%r14), %rdi
callq 0x4330
movl %eax, %r15d
xorl %eax, %eax
cmpl $0x4, %r13d
movl %r15d, 0x18(%rsp)
jb 0x4716
movq 0x18(%r14), %rdi
callq 0x4330
movl %eax, %ebx
cmpl $0x4, %r13d
jne 0x4720
xorl %r15d, %r15d
xorl %r12d, %r12d
jmp 0x4752
xorl %r15d, %r15d
xorl %ebx, %ebx
xorl %r12d, %r12d
jmp 0x4754
movq 0x20(%r14), %rdi
callq 0x4330
movl %eax, %r12d
cmpl $0x6, %r13d
jb 0x474f
movq 0x28(%r14), %rdi
callq 0x4330
movl %eax, %r15d
cmpl $0x6, %r13d
je 0x4752
movq 0x30(%r14), %rdi
callq 0x4330
jmp 0x4754
xorl %r15d, %r15d
xorl %eax, %eax
movq 0x8(%rsp), %rdi
movb $0x1, 0x1a0(%rdi)
movl $0x200, 0x14(%rsp)      # imm = 0x200
movl %ebx, 0x28(%rsp)
movl %ebp, 0x2c(%rsp)
movl %r15d, 0x30(%rsp)
movl %r12d, 0x1c(%rsp)
movl %ebp, 0x20(%rsp)
movl %eax, 0x24(%rsp)
testl %ebx, %ebx
jne 0x4790
movq (%rdi), %rax
callq *0x28(%rax)
movl %eax, 0x28(%rsp)
testl %r12d, %r12d
jne 0x47a4
movq 0x8(%rsp), %rdi
movq (%rdi), %rax
callq *0x30(%rax)
movl %eax, 0x1c(%rsp)
xorl %eax, %eax
leaq 0x50(%rsp), %r15
movq %rax, -0x18(%r15)
movq %r15, -0x10(%r15)
movq %rax, -0x8(%r15)
movb $0x0, (%r15)
leaq 0x14(%rsp), %r9
imull (%r9), %ebp
movl $0x0, 0x10(%r15)
addl %ebp, %ebp
leaq 0x34(%rsp), %r10
movl %ebp, (%r10)
leaq 0x38(%rsp), %r11
leaq -0x1be(%rip), %rbx      # 0x4624
leaq 0x8(%rsp), %rdi
leaq 0x1c(%rsp), %rsi
leaq 0x28(%rsp), %rdx
movl $0x2, %ecx
movl 0x18(%rsp), %r8d
pushq %rax
pushq %r11
pushq %r10
pushq %rbx
callq 0x4d26
addq $0x20, %rsp
movq 0x87b7(%rip), %rdi      # 0xcfc8
leaq 0x49b6(%rip), %rsi      # 0x91ce
movl $0x12, %edx
callq 0x4230
movq 0x8(%rsp), %rdi
callq 0x54e4
movq 0x8795(%rip), %rdi      # 0xcfc8
movq %rax, %rsi
callq 0x41e0
movq %rax, %rbx
leaq 0x499c(%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 0x873d(%rip), %rdi      # 0xcfc8
leaq 0x4957(%rip), %rsi      # 0x91e9
movl $0x34, %edx
callq 0x4230
movl 0x14(%rsp), %esi
movq 0x8721(%rip), %rdi      # 0xcfc8
callq 0x4150
leaq 0x496b(%rip), %rsi      # 0x921e
movl $0x3, %edx
movq %rax, %rdi
callq 0x4230
movq 0x8711(%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 0x48f0
movq (%rdi), %rax
callq *0x38(%rax)
movq 0x40(%rsp), %rdi
cmpq %r15, %rdi
je 0x4907
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x4220
leaq 0x8(%rsp), %rdi
callq 0x4d16
xorl %eax, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x45ac
movq 0x869a(%rip), %rdi      # 0xcfc8
leaq 0x487f(%rip), %rsi      # 0x91b4
callq 0x4200
movl $0x1, %edi
callq 0x4270
jmp 0x49da
jmp 0x49da
jmp 0x49da
movq %rax, %rbx
jmp 0x4a7b
jmp 0x49e2
movq %rax, %rbx
cmpl $0x2, %edx
jne 0x4a64
movq %rbx, %rdi
callq 0x40a0
movq %rax, %rbx
leaq 0x7(%rsp), %rsi
movb $0xa, (%rsi)
movq 0x8642(%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 0x493a
movq %rax, %rbx
callq 0x4390
jmp 0x4a64
movq %rax, %rdi
callq 0x4a8d
movq %rax, %rbx
cmpl $0x2, %edx
jne 0x4a64
movq %rbx, %rdi
callq 0x40a0
movq %rax, %rbx
leaq 0x7(%rsp), %rsi
movb $0xa, (%rsi)
movq 0x85c4(%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 0x48dc
jmp 0x4a61
movq %rax, %rbx
callq 0x4390
jmp 0x4a64
jmp 0x49da
movq %rax, %rbx
movq 0x40(%rsp), %rdi
cmpq %r15, %rdi
je 0x4a7b
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x4220
leaq 0x8(%rsp), %rdi
callq 0x4d16
movq %rbx, %rdi
callq 0x43c0