// File: /workspace/github_c_makefile_star2_O1/pipde[P]deos-songlib/utils/repitch/repitch.c
// Function: main
int
main(int argc,char **argv)
    {
    int freqCount;
    double twelfthRoot;
    skip = 10;
    twelfthRoot = pow(2.0, (1.0/12.0));

    double baseFreq = 8.859;    // number of samples for Eb 8 at 44,100 sample rate
    for (freqCount = 0; freqCount < 100; freqCount++)
    {
        double target = baseFreq * pow(twelfthRoot,freqCount);
        int samples = (int)target;
        targetFreqs[freqCount] = samples;
    }

    int argIndex = 1;

    FILE *in,*out;
    RRA *r, *r2;

    argIndex = processOptions(argc,argv);

    if (argc-argIndex == 0)
        {
        in = stdin;
        out = stdout;
        }
    else if (argc-argIndex == 1)
        {
        in = OpenFile(argv[argIndex],"r");
        out = stdout;
        }
    else if (argc-argIndex == 2)
        {
        in = OpenFile(argv[argIndex],"r");
        out = OpenFile(argv[argIndex+1],"w");
        }
    else
        {
        printf("usage: filter [<input rra file> [<output wave file>]]\n");
        exit(-1);
        }

    r2 = readRRA(in,0);
    fclose(in);

    if (argc-argIndex == 0)
        {
        in = stdin;
        }
    else if (argc-argIndex == 1)
        {
        in = OpenFile(argv[argIndex],"r");
        }
    else if (argc-argIndex == 2)
        {
        in = OpenFile(argv[argIndex],"r");
        }
    else
        {
        exit(-1);
        }

    r = newRRAHeader();
    readRRAHeader(in, r, 0);
    
    if (r->channels != 1)
        Fatal("rrarepitch only works on mono audio files\n");

    processData(in,out,r, r2);

    fclose(in);
    fclose(out);

    return 0;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2ef8, %rsp           # imm = 0x2EF8
movq %rsi, %r15
movl %edi, %r13d
movl $0xa, 0x5bb0(%rip)      # 0x7180
movl %edi, %r14d
leaq 0x5bb6(%rip), %rbx      # 0x7190
xorl %r12d, %r12d
xorps %xmm1, %xmm1
cvtsi2sd %r12d, %xmm1
movsd 0x2a1b(%rip), %xmm0     # 0x4008
callq 0x1090
mulsd 0x2a16(%rip), %xmm0     # 0x4010
cvttsd2si %xmm0, %eax
movl %eax, (%rbx)
incq %r12
addq $0x4, %rbx
cmpq $0x64, %r12
jne 0x15dd
movl $0x1, %r12d
cmpl $0x2, %r13d
jl 0x16a2
movl $0x1, %r12d
leaq 0x2b02(%rip), %rbx      # 0x412c
movq (%r15,%r12,8), %rsi
cmpb $0x2d, (%rsi)
jne 0x16a2
cmpb $0x0, 0x2(%rsi)
je 0x163f
leaq 0x2(%rsi), %rdi
jmp 0x1644
movq 0x8(%r15,%r12,8), %rdi
movzbl 0x1(%rsi), %eax
cmpl $0x6f, %eax
je 0x1662
cmpl $0x76, %eax
je 0x1a93
movq %rbx, %rdi
xorl %eax, %eax
callq 0x1acc
jmp 0x1697
callq 0x1080
cvttsd2si %xmm0, %eax
movl %eax, 0x5caf(%rip)      # 0x7320
movl $0x7, %edi
subl %eax, %edi
movsd 0x2998(%rip), %xmm0     # 0x4018
callq 0x1050
mulsd 0x2993(%rip), %xmm0     # 0x4020
cvttsd2si %xmm0, %eax
movl %eax, 0x5ae9(%rip)      # 0x7180
incq %r12
cmpq %r12, %r14
jne 0x162a
movl %r14d, %r12d
movl %r13d, %eax
subl %r12d, %eax
movl %r13d, -0x38(%rbp)
movl %eax, -0x30(%rbp)
jne 0x16bd
movq 0x5920(%rip), %rax      # 0x6fd8
movq (%rax), %r13
jmp 0x16e1
cmpl $0x2, %eax
je 0x16ed
cmpl $0x1, %eax
jne 0x1ab6
movslq %r12d, %rax
movq (%r15,%rax,8), %rdi
leaq 0x2f24(%rip), %rsi      # 0x45fd
callq 0x1b66
movq %rax, %r13
movq 0x58e8(%rip), %rax      # 0x6fd0
movq (%rax), %rbx
jmp 0x1717
movslq %r12d, %rbx
movq (%r15,%rbx,8), %rdi
leaq 0x2f02(%rip), %rsi      # 0x45fd
callq 0x1b66
movq %rax, %r13
movq 0x8(%r15,%rbx,8), %rdi
leaq 0x2945(%rip), %rsi      # 0x4054
callq 0x1b66
movq %rax, %rbx
movq %r13, %rdi
xorl %esi, %esi
callq 0x20d2
movq %rax, %r14
movq %r13, %rdi
callq 0x10a0
cmpl %r12d, -0x38(%rbp)
jne 0x173e
movq 0x589f(%rip), %rax      # 0x6fd8
movq (%rax), %r15
jmp 0x1765
movl -0x30(%rbp), %eax
cmpl $0x2, %eax
je 0x174f
cmpl $0x1, %eax
jne 0x1ac2
movslq %r12d, %rax
movq (%r15,%rax,8), %rdi
leaq 0x2ea0(%rip), %rsi      # 0x45fd
callq 0x1b66
movq %rax, %r15
callq 0x1de3
movq %rax, %r12
movq %r15, -0x30(%rbp)
movq %r15, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x21f0
cmpl $0x1, (%r12)
je 0x1793
leaq 0x28ca(%rip), %rdi      # 0x4056
xorl %eax, %eax
callq 0x1acc
cmpl $0x0, 0xc(%r12)
jle 0x17e6
movq $-0xc350, %r15          # imm = 0xFFFF3CB0
leaq 0x1764(%rip), %r13      # 0x2f0d
movl 0x8(%r12), %edx
movq -0x30(%rbp), %rdi
movq %rbx, %rsi
movq %r13, %rcx
callq 0x26dc
cmpq $0xbb7, %r15            # imm = 0xBB7
ja 0x17ce
movl %eax, -0x2f20(%rbp,%r15,4)
movslq 0xc(%r12), %rax
leaq 0x1(%r15), %rcx
addq $0xc351, %r15           # imm = 0xC351
cmpq %rax, %r15
movq %rcx, %r15
jl 0x17a9
movslq 0x5993(%rip), %rax      # 0x7180
xorl %r15d, %r15d
movl $0x989680, %r13d        # imm = 0x989680
movl $0x0, %r12d
cmpq $0xb53, %rax            # imm = 0xB53
jg 0x186a
movl %eax, %ecx
leaq -0x2f20(,%rax,4), %rdx
addq %rbp, %rdx
xorl %r12d, %r12d
movq %rax, %rsi
movl $0x0, %edi
testl %eax, %eax
jle 0x1846
xorl %r8d, %r8d
xorl %edi, %edi
movl -0x2f20(%rbp,%r8,4), %r9d
subl (%rdx,%r8,4), %r9d
movl %r9d, %r10d
negl %r10d
cmovsl %r9d, %r10d
addl %r10d, %edi
incq %r8
cmpq %r8, %rcx
jne 0x1825
movl %r13d, %r8d
negl %r8d
cmovsl %r13d, %r8d
cmpl %r8d, %edi
cmovbl %esi, %r12d
cmovbl %edi, %r13d
incq %rsi
addq $0x4, %rdx
cmpl $0xb54, %esi            # imm = 0xB54
jne 0x1817
movl $0x1f4, %eax            # imm = 0x1F4
leaq 0x591a(%rip), %rcx      # 0x7190
xorl %edx, %edx
movl (%rdx,%rcx), %esi
movl %r12d, %edi
subl %esi, %edi
movl %edi, %r8d
negl %r8d
cmovsl %edi, %r8d
cmpl %eax, %r8d
cmovlel %esi, %r15d
cmovll %r8d, %eax
addq $0x4, %rdx
cmpq $0x190, %rdx            # imm = 0x190
jne 0x1878
leaq 0x27d8(%rip), %rdi      # 0x4081
movl %r12d, %esi
xorl %eax, %eax
callq 0x10c0
movl $0xac44, %eax           # imm = 0xAC44
xorl %edx, %edx
idivl %r12d
leaq 0x27d6(%rip), %rdi      # 0x409a
movl %eax, %esi
xorl %eax, %eax
callq 0x10c0
leaq 0x27e1(%rip), %rdi      # 0x40b5
movl %r13d, %esi
xorl %eax, %eax
callq 0x10c0
cvtsi2sd %r12d, %xmm0
cvtsi2sd %r15d, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x5864(%rip)     # 0x7158
leaq 0x27cd(%rip), %rdi      # 0x40c8
movb $0x1, %al
callq 0x10c0
leaq 0x27ca(%rip), %rdx      # 0x40d3
movq %rbx, %rdi
movq %r14, %rsi
xorl %ecx, %ecx
callq 0x2c41
movl 0xc(%r14), %eax
testl %eax, %eax
movq -0x30(%rbp), %r15
jle 0x1a50
leaq 0x2970(%rip), %r12      # 0x429d
xorpd %xmm2, %xmm2
ucomisd 0x270f(%rip), %xmm2     # 0x4048
jb 0x1a74
movq 0x18(%r14), %rcx
movq (%rcx), %rcx
cvttsd2si %xmm2, %edx
decl %eax
cmpl %edx, %eax
movsd %xmm2, -0x38(%rbp)
jle 0x19f9
leal 0x1(%rdx), %esi
xorl %edi, %edi
testl %edx, %edx
setg %dil
movl %edx, %r8d
subl %edi, %r8d
leal 0x2(%rdx), %edi
cmpl %eax, %esi
cmovgel %esi, %edi
xorps %xmm1, %xmm1
cvtsi2sd %edx, %xmm1
movapd %xmm2, %xmm0
movslq %edx, %rax
xorps %xmm2, %xmm2
cvtsi2sdl (%rcx,%rax,4), %xmm2
subsd %xmm1, %xmm0
movslq %r8d, %rax
xorps %xmm1, %xmm1
cvtsi2sdl (%rcx,%rax,4), %xmm1
movapd %xmm2, %xmm4
movsd 0x2685(%rip), %xmm5     # 0x4028
mulsd %xmm5, %xmm4
subsd %xmm1, %xmm4
movslq %esi, %rax
xorps %xmm3, %xmm3
cvtsi2sdl (%rcx,%rax,4), %xmm3
movapd %xmm3, %xmm1
mulsd %xmm5, %xmm1
addsd %xmm4, %xmm1
movslq %edi, %rax
xorps %xmm4, %xmm4
cvtsi2sdl (%rcx,%rax,4), %xmm4
subsd %xmm4, %xmm1
mulsd 0x2657(%rip), %xmm1     # 0x4030
movsd 0x2657(%rip), %xmm4     # 0x4038
ucomisd %xmm0, %xmm4
jbe 0x1a05
subsd %xmm2, %xmm1
addsd %xmm1, %xmm1
mulsd %xmm0, %xmm1
addsd %xmm2, %xmm1
jmp 0x1a1d
cltq
xorps %xmm1, %xmm1
cvtsi2sdl (%rcx,%rax,4), %xmm1
jmp 0x1a1d
subsd %xmm1, %xmm3
addsd %xmm3, %xmm3
addsd 0x262b(%rip), %xmm0     # 0x4040
mulsd %xmm3, %xmm0
addsd %xmm0, %xmm1
cvttsd2si %xmm1, %edx
movq %rbx, %rdi
movq %r12, %rsi
xorl %eax, %eax
callq 0x1160
movsd -0x38(%rbp), %xmm2
addsd 0x571d(%rip), %xmm2     # 0x7158
movl 0xc(%r14), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
ucomisd %xmm2, %xmm0
ja 0x1931
movq %r15, %rdi
callq 0x10a0
movq %rbx, %rdi
callq 0x10a0
xorl %eax, %eax
addq $0x2ef8, %rsp           # imm = 0x2EF8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x266f(%rip), %rdi      # 0x40ea
leaq 0x266f(%rip), %rsi      # 0x40f1
leaq 0x2672(%rip), %rcx      # 0x40fb
movl $0xc3, %edx
callq 0x10e0
movq 0x56ae(%rip), %rsi      # 0x7148
movq 0x56af(%rip), %rdx      # 0x7150
leaq 0x2675(%rip), %rdi      # 0x411d
xorl %eax, %eax
callq 0x10c0
xorl %edi, %edi
callq 0x1220
leaq 0x2689(%rip), %rdi      # 0x4146
callq 0x1070
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1220