// File: /workspace/github_c_makefile_star2_O1/waywardgeek[P]sonic/main.c
// Function: main
int main(int argc, char** argv) {
  char* inFileName;
  char* outFileName;
  float speed = 1.0f;
  float pitch = 1.0f;
  float rate = 1.0f;
  float volume = 1.0f;
  int outputSampleRate = 0;  /* Means use the input file sample rate. */
  int emulateChordPitch = 0;
  int quality = 0;
  int xArg = 1;
  int computeSpectrogram = 0;
  int numRows = 0, numCols = 0;

  while (xArg < argc && *(argv[xArg]) == '-') {
    if (!strcmp(argv[xArg], "-c")) {
      emulateChordPitch = 1;
      printf("Scaling pitch linearly.\n");
    } else if (!strcmp(argv[xArg], "-o")) {
      xArg++;
      if (xArg < argc) {
        outputSampleRate = atoi(argv[xArg]);
        printf("Setting output sample rate to %d\n", outputSampleRate);
      }
    } else if (!strcmp(argv[xArg], "-p")) {
      xArg++;
      if (xArg < argc) {
        pitch = atof(argv[xArg]);
        printf("Setting pitch to %0.2fX\n", pitch);
      }
    } else if (!strcmp(argv[xArg], "-q")) {
      quality = 1;
      printf("Disabling speed-up heuristics\n");
    } else if (!strcmp(argv[xArg], "-r")) {
      xArg++;
      if (xArg < argc) {
        rate = atof(argv[xArg]);
        if (rate == 0.0f) {
          usage();
        }
        printf("Setting rate to %0.2fX\n", rate);
      }
    } else if (!strcmp(argv[xArg], "-s")) {
      xArg++;
      if (xArg < argc) {
        speed = atof(argv[xArg]);
        printf("Setting speed to %0.2fX\n", speed);
      }
#ifdef SONIC_SPECTROGRAM
    } else if (!strcmp(argv[xArg], "-S")) {
      xArg++;
      if (xArg < argc) {
        numCols = atof(argv[xArg]);
      }
      xArg++;
      if (xArg < argc) {
        numRows = atof(argv[xArg]);
        computeSpectrogram = 1;
        printf("Computing spectrogram %d wide and %d tall\n", numCols, numRows);
      }
#endif  /* SONIC_SPECTROGRAM */
    } else if (!strcmp(argv[xArg], "-v")) {
      xArg++;
      if (xArg < argc) {
        volume = atof(argv[xArg]);
        printf("Setting volume to %0.2f\n", volume);
      }
    }
    xArg++;
  }
  if (argc - xArg != 2) {
    usage();
  }
  inFileName = argv[xArg];
  outFileName = argv[xArg + 1];
  runSonic(inFileName, outFileName, speed, pitch, rate, volume,
           outputSampleRate, emulateChordPitch, quality,
           computeSpectrogram, numRows, numCols);
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2038, %rsp           # imm = 0x2038
movq %rsi, %r14
movl %edi, %r15d
movl $0x1, %r13d
cmpl $0x2, %edi
jl 0x1665
movss 0x2baa(%rip), %xmm0     # 0x4004
movss %xmm0, 0x1c(%rsp)
movss %xmm0, 0x18(%rsp)
movss %xmm0, 0x14(%rsp)
movss %xmm0, 0x10(%rsp)
movl $0x0, 0x20(%rsp)
xorl %ebp, %ebp
xorl %r12d, %r12d
movslq %r13d, %rax
movq (%r14,%rax,8), %rbx
cmpb $0x2d, (%rbx)
jne 0x1692
movq %rbx, %rdi
leaq 0x2b73(%rip), %rsi      # 0x400c
callq 0x10c0
testl %eax, %eax
je 0x1562
movq %rbx, %rdi
leaq 0x2b5f(%rip), %rsi      # 0x400f
callq 0x10c0
testl %eax, %eax
je 0x1578
movq %rbx, %rdi
leaq 0x2b6d(%rip), %rsi      # 0x4034
callq 0x10c0
testl %eax, %eax
je 0x15a8
movq %rbx, %rdi
leaq 0x2b72(%rip), %rsi      # 0x4050
callq 0x10c0
testl %eax, %eax
je 0x15d7
movq %rbx, %rdi
leaq 0x2b5e(%rip), %rsi      # 0x4053
callq 0x10c0
testl %eax, %eax
je 0x15ed
movq %rbx, %rdi
leaq 0x2b62(%rip), %rsi      # 0x406e
callq 0x10c0
testl %eax, %eax
je 0x1627
movq %rbx, %rdi
leaq 0x2b67(%rip), %rsi      # 0x408a
callq 0x10c0
testl %eax, %eax
jne 0x1657
incl %r13d
cmpl %r15d, %r13d
jge 0x1657
movslq %r13d, %rax
movq (%r14,%rax,8), %rdi
callq 0x1060
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x10(%rsp)
cvtss2sd %xmm0, %xmm0
leaq 0x2b30(%rip), %rdi      # 0x408d
jmp 0x1650
leaq 0x2e10(%rip), %rdi      # 0x4379
callq 0x1040
movl $0x1, %ebp
jmp 0x1657
incl %r13d
cmpl %r15d, %r13d
jge 0x1657
movslq %r13d, %rax
movq (%r14,%rax,8), %rdi
callq 0x1130
movl %eax, %r12d
leaq 0x2a78(%rip), %rdi      # 0x4012
movl %eax, %esi
xorl %eax, %eax
callq 0x1090
jmp 0x1657
incl %r13d
cmpl %r15d, %r13d
jge 0x1657
movslq %r13d, %rax
movq (%r14,%rax,8), %rdi
callq 0x1060
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x1c(%rsp)
cvtss2sd %xmm0, %xmm0
leaq 0x2a62(%rip), %rdi      # 0x4037
jmp 0x1650
leaq 0x2db3(%rip), %rdi      # 0x4391
callq 0x1040
movl $0x1, 0x20(%rsp)
jmp 0x1657
incl %r13d
cmpl %r15d, %r13d
jge 0x1657
movslq %r13d, %rax
movq (%r14,%rax,8), %rdi
callq 0x1060
cvtsd2ss %xmm0, %xmm0
ucomiss 0x29fc(%rip), %xmm0     # 0x4008
jne 0x1614
jnp 0x180e
movss %xmm0, 0x18(%rsp)
cvtss2sd %xmm0, %xmm0
leaq 0x2a31(%rip), %rdi      # 0x4056
jmp 0x1650
incl %r13d
cmpl %r15d, %r13d
jge 0x1657
movslq %r13d, %rax
movq (%r14,%rax,8), %rdi
callq 0x1060
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x14(%rsp)
cvtss2sd %xmm0, %xmm0
leaq 0x2a21(%rip), %rdi      # 0x4071
movb $0x1, %al
callq 0x1090
incl %r13d
cmpl %r15d, %r13d
jl 0x147f
jmp 0x1692
xorl %r12d, %r12d
movss 0x2994(%rip), %xmm0     # 0x4004
xorl %ebp, %ebp
movl $0x0, 0x20(%rsp)
movss %xmm0, 0x18(%rsp)
movss %xmm0, 0x1c(%rsp)
movss %xmm0, 0x10(%rsp)
movss %xmm0, 0x14(%rsp)
subl %r13d, %r15d
cmpl $0x2, %r15d
jne 0x17f4
movslq %r13d, %rax
movq (%r14,%rax,8), %r13
movq 0x8(%r14,%rax,8), %r15
leaq 0x24(%rsp), %rsi
leaq 0xc(%rsp), %rdx
movq %r13, %rdi
callq 0x2de0
movq %rax, 0x28(%rsp)
testl %r12d, %r12d
je 0x16cc
movl %r12d, 0x24(%rsp)
cmpq $0x0, 0x28(%rsp)
je 0x17f9
movl 0x24(%rsp), %esi
movl 0xc(%rsp), %edx
movq %r15, %rdi
callq 0x30c6
testq %rax, %rax
je 0x1801
movq %rax, %r14
movl 0x24(%rsp), %edi
movl 0xc(%rsp), %esi
callq 0x194d
movq %rax, %r15
movq %rax, %rdi
movss 0x14(%rsp), %xmm0
callq 0x1824
movq %r15, %rdi
movss 0x1c(%rsp), %xmm0
callq 0x1855
movq %r15, %rdi
movss 0x18(%rsp), %xmm0
callq 0x1886
movq %r15, %rdi
movss 0x10(%rsp), %xmm0
callq 0x18d2
movq %r15, %rdi
movl %ebp, %esi
callq 0x18bc
movq %r15, %rdi
movl 0x20(%rsp), %esi
callq 0x18c1
leaq 0x1030(%rsp), %r12
leaq 0x30(%rsp), %r13
movl $0x800, %eax            # imm = 0x800
xorl %edx, %edx
idivl 0xc(%rsp)
movq 0x28(%rsp), %rdi
movq %r12, %rsi
movl %eax, %edx
callq 0x33cb
movl %eax, %ebp
movq %r15, %rdi
testl %eax, %eax
je 0x178e
movq %r12, %rsi
movl %ebp, %edx
callq 0x1e2e
jmp 0x1793
callq 0x1d2e
movl $0x800, %eax            # imm = 0x800
xorl %edx, %edx
idivl 0xc(%rsp)
movq %r15, %rdi
movq %r13, %rsi
movl %eax, %edx
callq 0x1c3b
movl %eax, %ebx
testl %eax, %eax
jle 0x17be
movq %r14, %rdi
movq %r13, %rsi
movl %ebx, %edx
callq 0x3449
testl %ebx, %ebx
jg 0x1793
testl %ebp, %ebp
jg 0x175f
movq %r15, %rdi
callq 0x18fd
movq 0x28(%rsp), %rdi
callq 0x32e9
movq %r14, %rdi
callq 0x32e9
xorl %eax, %eax
addq $0x2038, %rsp           # imm = 0x2038
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x1191
movq %r13, %rdi
callq 0x11de
movq 0x28(%rsp), %rdi
movq %r15, %rsi
callq 0x11b2
callq 0x1170
nop