// File: /workspace/github_c_makefile_star2_O2/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, %r12d
movl $0xa, 0x5df0(%rip)      # 0x7180
leaq 0x5df9(%rip), %rbx      # 0x7190
xorl %r14d, %r14d
cmpq $0x64, %r14
je 0x13c9
cvtsi2sd %r14d, %xmm1
movsd 0x2c5b(%rip), %xmm0     # 0x4008
callq 0x1090
mulsd 0x2c56(%rip), %xmm0     # 0x4010
cvttsd2si %xmm0, %eax
movl %eax, (%rbx)
incq %r14
addq $0x4, %rbx
jmp 0x139a
movslq %r12d, %r14
cmpl $0x2, %r14d
pushq $0x1
popq %rax
movl %r12d, -0x30(%rbp)
cmovgel %r12d, %eax
movl %eax, -0x38(%rbp)
pushq $0x1
popq %r12
pushq $0x7
popq %r13
leaq 0x2d3f(%rip), %rbx      # 0x412c
cmpq %r14, %r12
jge 0x1462
movq (%r15,%r12,8), %rsi
cmpb $0x2d, (%rsi)
jne 0x1467
cmpb $0x0, 0x2(%rsi)
je 0x1407
leaq 0x2(%rsi), %rdi
jmp 0x140c
movq 0x8(%r15,%r12,8), %rdi
movzbl 0x1(%rsi), %eax
cmpl $0x6f, %eax
je 0x142a
cmpl $0x76, %eax
je 0x182b
movq %rbx, %rdi
xorl %eax, %eax
callq 0x1864
jmp 0x145d
callq 0x1080
cvttsd2si %xmm0, %eax
movl %eax, 0x5ee7(%rip)      # 0x7320
movl %r13d, %edi
subl %eax, %edi
movsd 0x2bf2(%rip), %xmm0     # 0x4038
callq 0x1050
mulsd 0x2bed(%rip), %xmm0     # 0x4040
cvttsd2si %xmm0, %eax
movl %eax, 0x5d23(%rip)      # 0x7180
incq %r12
jmp 0x13ed
movl -0x38(%rbp), %eax
jmp 0x146a
movl %r12d, %eax
movl -0x30(%rbp), %r12d
movslq %eax, %rbx
subl %eax, %r12d
movl %eax, -0x38(%rbp)
movq %rbx, -0x40(%rbp)
jne 0x1489
movq 0x5b54(%rip), %rax      # 0x6fd8
movq (%rax), %r13
jmp 0x14ac
cmpl $0x2, %r12d
je 0x14b8
cmpl $0x1, %r12d
jne 0x184e
movq (%r15,%rbx,8), %rdi
leaq 0x3156(%rip), %rsi      # 0x45fa
callq 0x1994
movq %rax, %r13
movq 0x5b1d(%rip), %rax      # 0x6fd0
movq (%rax), %rbx
jmp 0x14df
movq (%r15,%rbx,8), %rdi
leaq 0x3137(%rip), %rsi      # 0x45fa
callq 0x1994
movq %rax, %r13
movq 0x8(%r15,%rbx,8), %rdi
leaq 0x2b7d(%rip), %rsi      # 0x4054
callq 0x1994
movq %rax, %rbx
movq %r13, %rdi
xorl %esi, %esi
callq 0x1e61
movq %rax, %r14
movq %r13, %rdi
callq 0x10a0
movl -0x38(%rbp), %eax
cmpl %eax, -0x30(%rbp)
jne 0x1508
movq 0x5ad5(%rip), %rax      # 0x6fd8
movq (%rax), %r15
jmp 0x152f
cmpl $0x2, %r12d
je 0x1518
cmpl $0x1, %r12d
jne 0x185a
movq -0x40(%rbp), %rax
movq (%r15,%rax,8), %rdi
leaq 0x30d3(%rip), %rsi      # 0x45fa
callq 0x1994
movq %rax, %r15
callq 0x1bf0
movq %rax, %r12
movq %r15, -0x30(%rbp)
movq %r15, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x1f55
cmpl $0x1, (%r12)
je 0x155d
leaq 0x2b00(%rip), %rdi      # 0x4056
xorl %eax, %eax
callq 0x1864
xorl %r15d, %r15d
leaq 0x168a(%rip), %r13      # 0x2bf1
movslq 0xc(%r12), %rax
cmpq %rax, %r15
jge 0x15a9
movl 0x8(%r12), %edx
movq -0x30(%rbp), %rdi
movq %rbx, %rsi
movq %r13, %rcx
callq 0x242a
leaq -0xc350(%r15), %rcx
cmpq $0xbb7, %rcx            # imm = 0xBB7
ja 0x159d
movl %eax, -0x33c60(%rbp,%r15,4)
addq $0xc351, %rcx           # imm = 0xC351
movq %rcx, %r15
jmp 0x1567
movslq 0x5bd0(%rip), %rax      # 0x7180
xorl %r12d, %r12d
testl %eax, %eax
movl $0x0, %ecx
cmovgl %eax, %ecx
leaq -0x2f20(,%rax,4), %rdx
addq %rbp, %rdx
movl $0x989680, %r13d        # imm = 0x989680
cmpq $0xb53, %rax            # imm = 0xB53
jg 0x1619
xorl %edi, %edi
xorl %esi, %esi
cmpq %rdi, %rcx
je 0x15fd
movl -0x2f20(%rbp,%rdi,4), %r8d
subl (%rdx,%rdi,4), %r8d
movl %r8d, %r9d
negl %r9d
cmovsl %r8d, %r9d
addl %r9d, %esi
incq %rdi
jmp 0x15da
movl %r13d, %edi
negl %edi
cmovsl %r13d, %edi
cmpl %edi, %esi
cmovbl %eax, %r12d
cmovbl %esi, %r13d
incq %rax
addq $0x4, %rdx
jmp 0x15ce
movl $0x1f4, %eax            # imm = 0x1F4
xorl %ecx, %ecx
leaq 0x5b69(%rip), %rdx      # 0x7190
xorl %r15d, %r15d
cmpq $0x190, %rcx            # imm = 0x190
je 0x1656
movl (%rcx,%rdx), %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, %rcx
jmp 0x162a
leaq 0x2a24(%rip), %rdi      # 0x4081
movl %r12d, %esi
xorl %eax, %eax
callq 0x10c0
movl $0xac44, %eax           # imm = 0xAC44
xorl %edx, %edx
idivl %r12d
leaq 0x2a22(%rip), %rdi      # 0x409a
movl %eax, %esi
xorl %eax, %eax
callq 0x10c0
leaq 0x2a2d(%rip), %rdi      # 0x40b5
movl %r13d, %esi
xorl %eax, %eax
callq 0x10c0
cvtsi2sd %r12d, %xmm0
cvtsi2sd %r15d, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x5ab0(%rip)     # 0x7158
leaq 0x2a19(%rip), %rdi      # 0x40c8
movb $0x1, %al
callq 0x10c0
leaq 0x2a16(%rip), %rdx      # 0x40d3
movq %rbx, %rdi
movq %r14, %rsi
xorl %ecx, %ecx
callq 0x2964
leaq 0x2bcc(%rip), %r12      # 0x429d
xorpd %xmm2, %xmm2
movq -0x30(%rbp), %r15
movslq 0xc(%r14), %rdx
cvtsi2sd %edx, %xmm0
ucomisd %xmm2, %xmm0
jbe 0x17e8
ucomisd 0x2955(%rip), %xmm2     # 0x4048
jb 0x180c
movq 0x18(%r14), %rax
movq (%rax), %rax
cvttsd2si %xmm2, %ecx
leal -0x1(%rdx), %esi
cmpl %ecx, %esi
movsd %xmm2, -0x38(%rbp)
jle 0x17a5
leal 0x1(%rcx), %edx
xorl %edi, %edi
testl %ecx, %ecx
setg %dil
movl %ecx, %r8d
subl %edi, %r8d
leal 0x2(%rcx), %edi
cmpl %esi, %edx
cmovgel %edx, %edi
cvtsi2sd %ecx, %xmm1
movapd %xmm2, %xmm0
movslq %ecx, %rcx
cvtsi2sdl (%rax,%rcx,4), %xmm2
subsd %xmm1, %xmm0
movslq %r8d, %rcx
cvtsi2sdl (%rax,%rcx,4), %xmm1
movapd %xmm2, %xmm4
movsd 0x28c3(%rip), %xmm5     # 0x4018
mulsd %xmm5, %xmm4
subsd %xmm1, %xmm4
movslq %edx, %rcx
cvtsi2sdl (%rax,%rcx,4), %xmm3
movapd %xmm3, %xmm1
mulsd %xmm5, %xmm1
addsd %xmm4, %xmm1
movslq %edi, %rcx
cvtsi2sdl (%rax,%rcx,4), %xmm4
subsd %xmm4, %xmm1
mulsd 0x289b(%rip), %xmm1     # 0x4020
movsd 0x289b(%rip), %xmm4     # 0x4028
ucomisd %xmm0, %xmm4
jbe 0x17ad
subsd %xmm2, %xmm1
addsd %xmm1, %xmm1
mulsd %xmm0, %xmm1
addsd %xmm2, %xmm1
jmp 0x17c5
cvtsi2sdl -0x4(%rax,%rdx,4), %xmm1
jmp 0x17c5
subsd %xmm1, %xmm3
addsd %xmm3, %xmm3
addsd 0x2873(%rip), %xmm0     # 0x4030
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 0x5975(%rip), %xmm2     # 0x7158
jmp 0x16d9
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 0x28d7(%rip), %rdi      # 0x40ea
leaq 0x28d7(%rip), %rsi      # 0x40f1
leaq 0x28da(%rip), %rcx      # 0x40fb
movl $0xc3, %edx
callq 0x10e0
movq 0x5916(%rip), %rsi      # 0x7148
movq 0x5917(%rip), %rdx      # 0x7150
leaq 0x28dd(%rip), %rdi      # 0x411d
xorl %eax, %eax
callq 0x10c0
xorl %edi, %edi
callq 0x1220
leaq 0x28f1(%rip), %rdi      # 0x4146
callq 0x1070
pushq $-0x1
popq %rdi
callq 0x1220
nop