// File: /workspace/github_c_makefile_star2_O0/waywardgeek[P]sonic/main_experimental.c
// Function: runSonic
static void runSonic(char* inFileName, char* outFileName, float speed) {
  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_experimental only processes mono wave files.  This file has %d channels.\n",
        numChannels);
    exit(1);
  }
  if (inFile == NULL) {
    fprintf(stderr, "Unable to read wave file %s\n", inFileName);
    exit(1);
  }
  printf("Sample rate %d\n", sampleRate);
  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(speed, sampleRate);
  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);
      }
  /* temp */
  counter++;
    } 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)
movq $0x0, -0x28(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x17c(%rbp), %rsi
leaq -0x180(%rbp), %rdx
callq 0x1f40
movq %rax, -0x20(%rbp)
cmpl $0x1, -0x180(%rbp)
je 0x2c8c
movq 0x238d(%rip), %rax      # 0x4ff8
movq (%rax), %rdi
movl -0x180(%rbp), %edx
leaq 0x623(%rip), %rsi       # 0x329e
movb $0x0, %al
callq 0x10d0
movl $0x1, %edi
callq 0x1120
cmpq $0x0, -0x20(%rbp)
jne 0x2cb9
movq 0x235e(%rip), %rax      # 0x4ff8
movq (%rax), %rdi
movq -0x8(%rbp), %rdx
leaq 0x646(%rip), %rsi       # 0x32ee
movb $0x0, %al
callq 0x10d0
movl $0x1, %edi
callq 0x1120
movl -0x17c(%rbp), %esi
leaq 0x645(%rip), %rdi       # 0x330b
movb $0x0, %al
callq 0x1080
movq -0x10(%rbp), %rdi
movl -0x17c(%rbp), %esi
movl $0x1, %edx
callq 0x2230
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x2d1b
movq -0x20(%rbp), %rdi
callq 0x23e0
movq 0x22fc(%rip), %rax      # 0x4ff8
movq (%rax), %rdi
movq -0x10(%rbp), %rdx
leaq 0x35d(%rip), %rsi       # 0x3067
movb $0x0, %al
callq 0x10d0
movl $0x1, %edi
callq 0x1120
movss -0x14(%rbp), %xmm0
movl -0x17c(%rbp), %edi
callq 0x1270
movq -0x20(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
movl $0x50, %edx
callq 0x2570
movl %eax, -0x174(%rbp)
cmpl $0x0, -0x174(%rbp)
jne 0x2d56
callq 0x13f0
jmp 0x2d68
leaq -0xd0(%rbp), %rdi
movl -0x174(%rbp), %esi
callq 0x14d0
jmp 0x2d6a
leaq -0x170(%rbp), %rdi
movl $0x50, %esi
callq 0x1340
movl %eax, -0x178(%rbp)
cmpl $0x0, -0x178(%rbp)
jle 0x2da0
movq -0x28(%rbp), %rdi
leaq -0x170(%rbp), %rsi
movl -0x178(%rbp), %edx
callq 0x26c0
movl 0x5bb0b6(%rip), %eax    # 0x5bde5c
addl $0x1, %eax
movl %eax, 0x5bb0ad(%rip)    # 0x5bde5c
cmpl $0x0, -0x178(%rbp)
jg 0x2d6a
jmp 0x2dba
cmpl $0x0, -0x174(%rbp)
jg 0x2d2b
movq -0x20(%rbp), %rdi
callq 0x23e0
movq -0x28(%rbp), %rdi
callq 0x23e0
addq $0x180, %rsp            # imm = 0x180
popq %rbp
retq