// File: /workspace/github_c_makefile_star2_O0/waywardgeek[P]sonic/main_lite.c
// Function: runSonic
static void runSonic(char* inFileName, char* outFileName, float speed, float volume) {
  waveFile inFile, outFile = NULL;
  short inBuffer[SONIC_INPUT_SAMPLES], outBuffer[SONIC_INPUT_SAMPLES];
  int samplesRead, samplesWritten, sampleRate, numChannels;

  inFile = openInputWaveFile(inFileName, &sampleRate, &numChannels);
  if (numChannels != 1) {
    fprintf(stderr, "sonic_lite only processes mono wave files.  This file has %d channels.\n",
        numChannels);
    exit(1);
  }
  if (sampleRate != SONIC_SAMPLE_RATE) {
    fprintf(stderr,
        "sonic_lite only processes wave files with a sample rate of %d Hz.  This file uses %d\n",
        SONIC_SAMPLE_RATE, sampleRate);
    exit(1);
  }
  if (inFile == NULL) {
    fprintf(stderr, "Unable to read wave file %s\n", inFileName);
    exit(1);
  }
  outFile = openOutputWaveFile(outFileName, sampleRate, 1);
  if (outFile == NULL) {
    closeWaveFile(inFile);
    fprintf(stderr, "Unable to open wave file %s for writing\n", outFileName);
    exit(1);
  }
  sonicInit();
  sonicSetSpeed(speed);
  sonicSetVolume(volume);
  do {
    samplesRead = readFromWaveFile(inFile, inBuffer, SONIC_INPUT_SAMPLES);
    if (samplesRead == 0) {
      sonicFlushStream();
    } else {
      sonicWriteShortToStream(inBuffer, samplesRead);
    }
    do {
      samplesWritten = sonicReadShortFromStream(outBuffer, SONIC_INPUT_SAMPLES);
      if (samplesWritten > 0) {
        writeToWaveFile(outFile, outBuffer, samplesWritten);
      }
    } while (samplesWritten > 0);
  } while (samplesRead > 0);
  closeWaveFile(inFile);
  closeWaveFile(outFile);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x180, %rsp            # imm = 0x180
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movss %xmm0, -0x14(%rbp)
movss %xmm1, -0x18(%rbp)
movq $0x0, -0x28(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x17c(%rbp), %rsi
leaq -0x180(%rbp), %rdx
callq 0x1d30
movq %rax, -0x20(%rbp)
cmpl $0x1, -0x180(%rbp)
je 0x2af1
movq 0x2528(%rip), %rax      # 0x4ff8
movq (%rax), %rdi
movl -0x180(%rbp), %edx
leaq 0x7f7(%rip), %rsi       # 0x32d7
movb $0x0, %al
callq 0x10c0
movl $0x1, %edi
callq 0x1110
cmpl $0x1f40, -0x17c(%rbp)   # imm = 0x1F40
je 0x2b2a
movq 0x24f4(%rip), %rax      # 0x4ff8
movq (%rax), %rdi
movl -0x17c(%rbp), %ecx
leaq 0x80b(%rip), %rsi       # 0x331f
movl $0x1f40, %edx           # imm = 0x1F40
movb $0x0, %al
callq 0x10c0
movl $0x1, %edi
callq 0x1110
cmpq $0x0, -0x20(%rbp)
jne 0x2b57
movq 0x24c0(%rip), %rax      # 0x4ff8
movq (%rax), %rdi
movq -0x8(%rbp), %rdx
leaq 0x82f(%rip), %rsi       # 0x3375
movb $0x0, %al
callq 0x10c0
movl $0x1, %edi
callq 0x1110
movq -0x10(%rbp), %rdi
movl -0x17c(%rbp), %esi
movl $0x1, %edx
callq 0x2020
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x2ba5
movq -0x20(%rbp), %rdi
callq 0x21d0
movq 0x2472(%rip), %rax      # 0x4ff8
movq (%rax), %rdi
movq -0x10(%rbp), %rdx
leaq 0x4c3(%rip), %rsi       # 0x3057
movb $0x0, %al
callq 0x10c0
movl $0x1, %edi
callq 0x1110
callq 0x1270
movss -0x14(%rbp), %xmm0
callq 0x1230
movss -0x18(%rbp), %xmm0
callq 0x1250
movq -0x20(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
movl $0x50, %edx
callq 0x2360
movl %eax, -0x174(%rbp)
cmpl $0x0, -0x174(%rbp)
jne 0x2be9
callq 0x1380
jmp 0x2bfb
leaq -0xd0(%rbp), %rdi
movl -0x174(%rbp), %esi
callq 0x1440
jmp 0x2bfd
leaq -0x170(%rbp), %rdi
movl $0x50, %esi
callq 0x12d0
movl %eax, -0x178(%rbp)
cmpl $0x0, -0x178(%rbp)
jle 0x2c33
movq -0x28(%rbp), %rdi
leaq -0x170(%rbp), %rsi
movl -0x178(%rbp), %edx
callq 0x24b0
jmp 0x2c35
cmpl $0x0, -0x178(%rbp)
jg 0x2bfd
jmp 0x2c40
cmpl $0x0, -0x174(%rbp)
jg 0x2bbe
movq -0x20(%rbp), %rdi
callq 0x21d0
movq -0x28(%rbp), %rdi
callq 0x21d0
addq $0x180, %rsp            # imm = 0x180
popq %rbp
retq