// File: /workspace/github_c_makefile_star2_O0/pipde[P]deos-songlib/utils/fixpitch/fixpitch.c
// Function: main
int
main(int argc,char **argv)
    {
    int argIndex = 1;

    FILE *in,*out,*nfp;
    RRA *h;

    argIndex = processOptions(argc,argv);

    if (argc-argIndex == 1)
        {
        nfp = OpenFile(argv[argIndex],"r");
        in = stdin;
        out = stdout;
        }
    else if (argc-argIndex == 2)
        {
        nfp = OpenFile(argv[argIndex],"r");
        in = OpenFile(argv[argIndex+1],"r");
        out = stdout;
        }
    else if (argc-argIndex == 3)
        {
        nfp = OpenFile(argv[argIndex],"r");
        in = OpenFile(argv[argIndex+1],"r");
        out = OpenFile(argv[argIndex+2],"w");
        }
    else
        {
        printf("usage: %s\n [-h] NOTES_FILE [INPUT_RRA [OUTPUT_RRA]\n",argv[0]);
        exit(-1);
        }

    h = newRRAHeader();
    
    readRRAHeader(in,h,0);

    SampleRate = h->sampleRate;

    if (h->channels != 1)
        Fatal("%s requires a mono audio file\n",argv[0]);

    writeRRAHeader(out,h,"modifiedBy: correct",0);

    if (Report) ReportFP = OpenFile("changes.rpt","w");

    readLegalNotes(nfp);

    LongestCycle = SampleRate / 100 * OctavesAllowed;
    ShortestCycle = SampleRate / 1000;

    MinFactor = 1 / (1 + (ST - 1) * Reach * Bias);
    MaxFactor = 1 + (ST - 1) * Reach * Bias;

    WindowSize = (CycleCount + 1) * LongestCycle;

    if (AbsoluteThreshold == 0)
        AbsoluteThreshold = (int) (pow(2,h->bitsPerSample - 1) / 200);
    if (RelativeThreshold == 0.0)
        RelativeThreshold = 0.20;

    //printf("MinFactor is %f\n",MinFactor);
    //printf("MaxFactor is %f\n",MaxFactor);
    //printf("AbsoluteThreshold is %d\n",AbsoluteThreshold);
    //getchar();

    if ((Window = malloc(sizeof(int) * WindowSize)) == 0)
        Fatal("correct: out of memory\n");

    processData(in,out,h);

    fclose(out);
    fclose(in);
    fclose(nfp);

    if (Report)
        {
        fprintf(ReportFP,"%d samples read\n",SamplesRead);
        fprintf(ReportFP,"%d samples written\n",SamplesWritten);
        fprintf(ReportFP,"%.2f%% samples repitched\n",
            100.0 * SamplesRepitched / (double) SamplesRead);
        fprintf(ReportFP,"%d samples (%.3f seconds) %s\n",
            SampleDelta,SampleDelta / (double) SampleRate,
            SampleDelta < 0? "long" : "short");
        fclose(ReportFP);
        assert(SamplesStored == 0);
        }

    return 0;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x1, -0x14(%rbp)
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
callq 0x2780
movl %eax, -0x14(%rbp)
movl -0x8(%rbp), %eax
subl -0x14(%rbp), %eax
cmpl $0x1, %eax
jne 0x23a4
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x5c14(%rip), %rsi      # 0x7f8e
callq 0x3c80
movq %rax, -0x30(%rbp)
movq 0x7c4e(%rip), %rax      # 0x9fd8
movq (%rax), %rax
movq %rax, -0x20(%rbp)
movq 0x7c38(%rip), %rax      # 0x9fd0
movq (%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0x248d
movl -0x8(%rbp), %eax
subl -0x14(%rbp), %eax
cmpl $0x2, %eax
jne 0x23ff
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x5bcc(%rip), %rsi      # 0x7f8e
callq 0x3c80
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x5bab(%rip), %rsi      # 0x7f8e
callq 0x3c80
movq %rax, -0x20(%rbp)
movq 0x7bdd(%rip), %rax      # 0x9fd0
movq (%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0x248b
movl -0x8(%rbp), %eax
subl -0x14(%rbp), %eax
cmpl $0x3, %eax
jne 0x246a
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x5b71(%rip), %rsi      # 0x7f8e
callq 0x3c80
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x5b50(%rip), %rsi      # 0x7f8e
callq 0x3c80
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x4e6e(%rip), %rsi      # 0x72cd
callq 0x3c80
movq %rax, -0x28(%rbp)
jmp 0x2489
movq -0x10(%rbp), %rax
movq (%rax), %rsi
leaq 0x4e57(%rip), %rdi      # 0x72cf
movb $0x0, %al
callq 0x20a0
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x21f0
jmp 0x248b
jmp 0x248d
callq 0x4160
movq %rax, -0x38(%rbp)
movq -0x20(%rbp), %rdi
movq -0x38(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x4660
movq -0x38(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, 0x845c(%rip)      # 0xa910
movq -0x38(%rbp), %rax
cmpl $0x1, (%rax)
je 0x24d2
movq -0x10(%rbp), %rax
movq (%rax), %rsi
leaq 0x4e38(%rip), %rdi      # 0x7303
movb $0x0, %al
callq 0x3b30
movq -0x28(%rbp), %rdi
movq -0x38(%rbp), %rsi
leaq 0x4e41(%rip), %rdx      # 0x7322
xorl %eax, %eax
movl %eax, %ecx
callq 0x5600
cmpl $0x0, 0x8423(%rip)      # 0xa914
je 0x250d
leaq 0x4e3c(%rip), %rdi      # 0x7336
leaq 0x4dcc(%rip), %rsi      # 0x72cd
callq 0x3c80
movq %rax, 0x840b(%rip)      # 0xa918
movq -0x30(%rbp), %rdi
callq 0x2ac0
movl 0x83f4(%rip), %eax      # 0xa910
movl $0x64, %ecx
cltd
idivl %ecx
imull 0x8395(%rip), %eax      # 0xa8c0
movl %eax, 0x83ef(%rip)      # 0xa920
movl 0x83d9(%rip), %eax      # 0xa910
movl $0x3e8, %ecx            # imm = 0x3E8
cltd
idivl %ecx
movl %eax, 0x83df(%rip)      # 0xa924
movsd 0x4ac3(%rip), %xmm1     # 0x7010
mulsd 0x8373(%rip), %xmm1     # 0xa8c8
movsd 0x8373(%rip), %xmm0     # 0xa8d0
mulsd %xmm0, %xmm1
movsd 0x4a9f(%rip), %xmm0     # 0x7008
addsd %xmm0, %xmm1
movsd 0x4a93(%rip), %xmm0     # 0x7008
divsd %xmm1, %xmm0
movsd %xmm0, 0x83a7(%rip)     # 0xa928
movsd 0x4a87(%rip), %xmm0     # 0x7010
mulsd 0x8337(%rip), %xmm0     # 0xa8c8
movsd 0x8337(%rip), %xmm1     # 0xa8d0
mulsd %xmm1, %xmm0
movsd 0x4a63(%rip), %xmm1     # 0x7008
addsd %xmm1, %xmm0
movsd %xmm0, 0x837f(%rip)     # 0xa930
movl 0x8321(%rip), %eax      # 0xa8d8
addl $0x1, %eax
imull 0x835f(%rip), %eax      # 0xa920
movl %eax, 0x8371(%rip)      # 0xa938
cmpl $0x0, 0x836e(%rip)      # 0xa93c
jne 0x2601
movq -0x38(%rbp), %rax
movl 0x8(%rax), %eax
subl $0x1, %eax
cvtsi2sd %eax, %xmm1
movsd 0x4a3a(%rip), %xmm0     # 0x7020
callq 0x2070
movsd 0x4a25(%rip), %xmm1     # 0x7018
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x833b(%rip)      # 0xa93c
movsd 0x8337(%rip), %xmm0     # 0xa940
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x2624
jp 0x2624
movsd 0x4a0c(%rip), %xmm0     # 0x7028
movsd %xmm0, 0x831c(%rip)     # 0xa940
movslq 0x830d(%rip), %rdi      # 0xa938
shlq $0x2, %rdi
callq 0x2170
movq %rax, 0x830d(%rip)      # 0xa948
cmpq $0x0, %rax
jne 0x264f
leaq 0x4cfa(%rip), %rdi      # 0x7342
movb $0x0, %al
callq 0x3b30
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq 0x2c10
movq -0x28(%rbp), %rdi
callq 0x2080
movq -0x20(%rbp), %rdi
callq 0x2080
movq -0x30(%rbp), %rdi
callq 0x2080
cmpl $0x0, 0x8292(%rip)      # 0xa914
je 0x2775
movq 0x8289(%rip), %rdi      # 0xa918
movl 0x82bb(%rip), %edx      # 0xa950
leaq 0x4cbe(%rip), %rsi      # 0x735a
movb $0x0, %al
callq 0x2130
movq 0x826e(%rip), %rdi      # 0xa918
movl 0x82a4(%rip), %edx      # 0xa954
leaq 0x4cb4(%rip), %rsi      # 0x736b
movb $0x0, %al
callq 0x2130
movq 0x8253(%rip), %rdi      # 0xa918
cvtsi2sdl 0x828b(%rip), %xmm1 # 0xa958
movsd 0x495b(%rip), %xmm0     # 0x7030
mulsd %xmm1, %xmm0
cvtsi2sdl 0x826f(%rip), %xmm1 # 0xa950
divsd %xmm1, %xmm0
leaq 0x4c93(%rip), %rsi      # 0x737f
movb $0x1, %al
callq 0x2130
movq 0x821e(%rip), %rdi      # 0xa918
movl 0x825c(%rip), %edx      # 0xa95c
cvtsi2sdl 0x8254(%rip), %xmm0 # 0xa95c
cvtsi2sdl 0x8200(%rip), %xmm1 # 0xa910
divsd %xmm1, %xmm0
movl 0x8242(%rip), %esi      # 0xa95c
leaq 0x4c9b(%rip), %rcx      # 0x73bc
leaq 0x4c8f(%rip), %rax      # 0x73b7
cmpl $0x0, %esi
cmovlq %rax, %rcx
leaq 0x4c63(%rip), %rsi      # 0x7399
movb $0x1, %al
callq 0x2130
movq 0x81d4(%rip), %rdi      # 0xa918
callq 0x2080
cmpl $0x0, 0x8210(%rip)      # 0xa960
jne 0x2754
jmp 0x2773
leaq 0x4c67(%rip), %rdi      # 0x73c2
leaq 0x4c73(%rip), %rsi      # 0x73d5
movl $0x11a, %edx            # imm = 0x11A
leaq 0x4c72(%rip), %rcx      # 0x73e0
callq 0x20c0
jmp 0x2775
xorl %eax, %eax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)