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

    FILE *in,*out;
    RRA *h;

    argIndex = processOptions(argc,argv);

    if (argc-argIndex == 0)
        {
        in = stdin;
        readLegalNotes("notes");
        out = stdout;
        }
    else if (argc-argIndex == 1)
        {
        in = stdin;
        readLegalNotes(argv[argIndex]);
        out = stdout;
        }
    else if (argc-argIndex == 2)
        {
        in = OpenFile(argv[argIndex],"r");
        readLegalNotes(argv[argIndex+1]);
        out = stdout;
        }
    else if (argc-argIndex == 3)
        {
        in = OpenFile(argv[argIndex],"r");
        readLegalNotes(argv[argIndex+1]);
        out = OpenFile(argv[argIndex+2],"w");
        }
    else
        {
        printf("usage: %s\n",argv[0]);
        printf("       %s <legal notes file>\n",argv[0]);
        printf("       %s <input rra file> <legal notes file>\n",argv[0]);
        printf("       %s <input rra file> <legal notes file> <output rra file>\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]);

    //printf("%f,%f\n",pow(2,h->bitsPerSample-1)-1,pow(Factor,thresholdDb));

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

    processData(in,out,h);

    fclose(in);
    fclose(out);

    fprintf(stderr,"Extra samples: %d (%f seconds)\n",
        ExtraSamples,ExtraSamples / (double) h->sampleRate);

    return 0;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %r12
movl %edi, %ebx
movl $0x1, %r15d
cmpl $0x2, %edi
jl 0x3dc2
movl $0x1, %r15d
movslq %r15d, %rax
movq (%r12,%rax,8), %rsi
cmpb $0x2d, (%rsi)
jne 0x3dc2
movb 0x2(%rsi), %r13b
testb %r13b, %r13b
je 0x3d26
leaq 0x2(%rsi), %rdi
jmp 0x3d2b
movq 0x8(%r12,%rax,8), %rdi
movzbl 0x1(%rsi), %eax
cmpl $0x6f, %eax
jg 0x3d4b
cmpl $0x62, %eax
je 0x3d62
cmpl $0x63, %eax
jne 0x3d9c
callq 0x32b0
movl %eax, 0xbbff(%rip)      # 0xf948
jmp 0x3d7c
cmpl $0x70, %eax
je 0x3d71
cmpl $0x77, %eax
jne 0x3da6
callq 0x32b0
movl %eax, 0xbbe0(%rip)      # 0xf940
jmp 0x3d7c
callq 0x30b0
movsd %xmm0, 0xbbe1(%rip)     # 0xf950
jmp 0x3d7c
callq 0x32b0
movl %eax, 0xbbc8(%rip)      # 0xf944
movb $0x1, %r14b
testb %r13b, %r13b
sete %al
andb %r14b, %al
movzbl %al, %eax
addl %eax, %r15d
incl %r15d
cmpl %ebx, %r15d
jl 0x3d07
jmp 0x3dc2
cmpl $0x68, %eax
jne 0x3daf
jmp 0x4278
cmpl $0x76, %eax
je 0x434b
xorl %r14d, %r14d
leaq 0x6777(%rip), %rdi      # 0xa530
xorl %eax, %eax
callq 0x858c
jmp 0x3d7f
subl %r15d, %ebx
jne 0x3dda
movq 0xb20a(%rip), %rax      # 0xefd8
movq (%rax), %rbx
leaq 0x6817(%rip), %rdi      # 0xa5ef
jmp 0x3e1f
cmpl $0x3, %ebx
je 0x423f
cmpl $0x2, %ebx
je 0x3e04
cmpl $0x1, %ebx
jne 0x436e
movq 0xb1e0(%rip), %rax      # 0xefd8
movq (%rax), %rbx
movslq %r15d, %rax
movq (%r12,%rax,8), %rdi
jmp 0x3e1f
movslq %r15d, %r14
movq (%r12,%r14,8), %rdi
leaq 0x68d1(%rip), %rsi      # 0xa6e3
callq 0x8626
movq %rax, %rbx
movq 0x8(%r12,%r14,8), %rdi
callq 0x43c0
movq 0xb1a5(%rip), %rax      # 0xefd0
movq (%rax), %r13
callq 0x8897
movq %rax, %r15
movq %rbx, %r14
movq %rbx, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x8cbd
movl 0x4(%r15), %eax
movl %eax, 0xbd90(%rip)      # 0xfbe0
movq %r15, %rbx
cmpl $0x1, (%r15)
je 0x3e6b
movq (%r12), %rsi
leaq 0x6458(%rip), %rdi      # 0xa2bc
xorl %eax, %eax
callq 0x858c
leaq 0x6469(%rip), %rdx      # 0xa2db
movq %r13, %rdi
movq %rbx, %r12
movq %rbx, %rsi
xorl %ecx, %ecx
callq 0x9758
movslq 0xbab7(%rip), %rdi      # 0xf940
shlq $0x2, %rdi
callq 0x3240
movq %rax, 0xd56f(%rip)      # 0x11408
testq %rax, %rax
jne 0x3eac
leaq 0x64b0(%rip), %rdi      # 0xa355
xorl %eax, %eax
callq 0x858c
movq %r12, %rax
addq $0x4, %rax
movq %rax, -0x40(%rbp)
movb $0x0, 0xd552(%rip)      # 0x11410
movq 0xb133(%rip), %r15      # 0xeff8
leaq 0x5b57(%rip), %rax      # 0x9a23
movq %r14, %rbx
movq %r13, %r14
movq %rax, %r13
movq %r14, -0x50(%rbp)
movq %r12, -0x48(%rbp)
movq %rbx, -0x58(%rbp)
movq (%r15), %rdi
movl 0xd516(%rip), %edx      # 0x11400
leal 0x1(%rdx), %eax
movl %eax, 0xd50d(%rip)      # 0x11400
movl $0x0, -0x2c(%rbp)
leaq 0x646c(%rip), %rsi      # 0xa36d
xorl %eax, %eax
callq 0x31e0
movl 0x8(%r12), %edx
movq %rbx, %rdi
movq %r14, %rsi
movq %r13, %rcx
callq 0x91c0
movl %eax, %r13d
movzbl 0xd4ea(%rip), %r15d     # 0x11410
movl 0xba14(%rip), %eax      # 0xf940
cmpl %r15d, %eax
jle 0x3f98
movl $0x1, %r12d
leaq 0x5ae5(%rip), %r14      # 0x9a23
movq %rbx, %rdi
callq 0x3200
testl %eax, %eax
movq 0xd4b9(%rip), %rax      # 0x11408
movl $0x0, %ecx
cmovnel %ecx, %r13d
cmovnel %ecx, %r12d
movl %r13d, (%rax,%r15,4)
movq -0x48(%rbp), %rax
movl 0x8(%rax), %edx
movq %rbx, %rdi
movq -0x50(%rbp), %rsi
movq %r14, %rcx
callq 0x91c0
movl %eax, %r13d
incq %r15
movl 0xb9be(%rip), %eax      # 0xf940
cmpl %r15d, %eax
jg 0x3f3e
testl %r12d, %r12d
sete %cl
movl %ecx, -0x2c(%rbp)
movq -0x48(%rbp), %r12
movq -0x50(%rbp), %r14
movq %r12, %rbx
addl %eax, 0xbc43(%rip)      # 0xfbe4
xorps %xmm0, %xmm0
cvtsi2sdl 0xbc34(%rip), %xmm0 # 0xfbe0
movapd %xmm0, %xmm1
mulsd 0x6050(%rip), %xmm1     # 0xa008
divsd 0xd438(%rip), %xmm1     # 0x113f8
cvttsd2si %xmm1, %edx
mulsd 0x6044(%rip), %xmm0     # 0xa010
divsd 0xd41c(%rip), %xmm0     # 0x113f0
cvttsd2si %xmm0, %r13d
movq 0xb018(%rip), %r15      # 0xeff8
movq (%r15), %rdi
leaq 0x63a3(%rip), %rsi      # 0xa38d
movl %edx, %r12d
xorl %eax, %eax
callq 0x31e0
movq (%r15), %rdi
leaq 0x63ab(%rip), %rsi      # 0xa3a9
movl %r13d, %edx
xorl %eax, %eax
callq 0x31e0
cmpl $0x0, 0xb935(%rip)      # 0xf944
jle 0x4028
movq -0x40(%rbp), %rdi
movl %r13d, %esi
movl %r12d, %edx
leaq -0x60(%rbp), %rcx
callq 0x3340
testb $0x1, %al
je 0x4037
callq 0x36df
movsd 0x5fe3(%rip), %xmm1     # 0xa018
jmp 0x403c
movsd -0x60(%rbp), %xmm1
movsd 0xd3d4(%rip), %xmm0     # 0x11418
ucomisd 0x5fdc(%rip), %xmm0     # 0xa028
leaq 0x59d0(%rip), %r13      # 0x9a23
movq %rbx, %r12
jne 0x4066
jp 0x4066
movsd %xmm1, 0xd3b6(%rip)     # 0x11418
movapd %xmm1, %xmm0
movq (%r15), %rdi
leaq 0x63dd(%rip), %rsi      # 0xa44d
movsd %xmm1, -0x38(%rbp)
movb $0x2, %al
callq 0x31e0
movsd 0xd39c(%rip), %xmm0     # 0x11420
movl 0xb8b6(%rip), %esi      # 0xf940
leal -0x1(%rsi), %eax
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
ucomisd %xmm0, %xmm1
movq -0x58(%rbp), %rbx
jbe 0x417a
xorl %r13d, %r13d
movq 0xd35c(%rip), %rdi      # 0x11408
callq 0x7077
movq %r14, %rdi
leaq 0x6305(%rip), %rsi      # 0xa3c0
movl %eax, %edx
xorl %eax, %eax
callq 0x31e0
decl 0xbb1a(%rip)            # 0xfbe4
movsd 0xd346(%rip), %xmm1     # 0x11418
movsd 0xd346(%rip), %xmm0     # 0x11420
addsd %xmm1, %xmm0
movsd %xmm0, 0xd33a(%rip)     # 0x11420
movsd -0x38(%rbp), %xmm2
ucomisd %xmm1, %xmm2
jbe 0x4109
mulsd 0x5f27(%rip), %xmm1     # 0xa020
movsd %xmm1, 0xd317(%rip)     # 0x11418
ucomisd %xmm2, %xmm1
jae 0x411f
jmp 0x4132
divsd 0x5f0f(%rip), %xmm1     # 0xa020
movsd %xmm1, 0xd2ff(%rip)     # 0x11418
ucomisd %xmm1, %xmm2
jb 0x4132
movsd %xmm2, 0xd2f1(%rip)     # 0x11418
testl %r13d, %r13d
movl $0x1, %r13d
je 0x414e
movl 0xb808(%rip), %esi      # 0xf940
leal -0x1(%rsi), %eax
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
ucomisd %xmm0, %xmm1
ja 0x40a5
jmp 0x416e
movq (%r15), %rdi
leaq 0x6319(%rip), %rsi      # 0xa471
movsd -0x38(%rbp), %xmm0
movb $0x1, %al
callq 0x31e0
movsd 0xd2b4(%rip), %xmm0     # 0x11420
jmp 0x4132
testl %r13d, %r13d
leaq 0x58ab(%rip), %r13      # 0x9a23
jne 0x41b7
movq (%r15), %rdi
leaq 0x6308(%rip), %rsi      # 0xa48c
movsd -0x38(%rbp), %xmm0
movb $0x1, %al
callq 0x31e0
movq (%r15), %rdi
movsd 0xd27d(%rip), %xmm0     # 0x11418
leaq 0x6309(%rip), %rsi      # 0xa4ab
movb $0x1, %al
callq 0x31e0
movsd 0xd26f(%rip), %xmm0     # 0x11420
movl 0xb789(%rip), %esi      # 0xf940
cvttpd2dq %xmm0, %xmm1
cvtdq2pd %xmm1, %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, 0xd255(%rip)     # 0x11420
movq 0xd236(%rip), %rdi      # 0x11408
movslq %esi, %rax
movl -0x4(%rdi,%rax,4), %eax
movl %eax, (%rdi)
movb $0x1, 0xd22e(%rip)      # 0x11410
cmpb $0x0, -0x2c(%rbp)
je 0x3ee1
callq 0x3040
movq %rbx, %rdi
callq 0x30d0
movq %r14, %rdi
callq 0x30d0
movl 0xb9dd(%rip), %edx      # 0xfbe4
xorps %xmm0, %xmm0
cvtsi2sd %edx, %xmm0
movq (%r15), %rdi
movq -0x40(%rbp), %rax
xorps %xmm1, %xmm1
cvtsi2sdl (%rax), %xmm1
divsd %xmm1, %xmm0
leaq 0x60c8(%rip), %rsi      # 0xa2ef
movb $0x1, %al
callq 0x31e0
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movslq %r15d, %r14
movq (%r12,%r14,8), %rdi
leaq 0x6496(%rip), %rsi      # 0xa6e3
callq 0x8626
movq %rax, %rbx
movq 0x8(%r12,%r14,8), %rdi
callq 0x43c0
movq 0x10(%r12,%r14,8), %rdi
leaq 0x5fb6(%rip), %rsi      # 0xa221
callq 0x8626
movq %rax, %r13
jmp 0x3e2e
leaq 0x62cb(%rip), %rdi      # 0xa54a
callq 0x30a0
leaq 0x62ce(%rip), %rdi      # 0xa559
callq 0x30a0
leaq 0x62ec(%rip), %rdi      # 0xa583
callq 0x30a0
leaq 0x62f1(%rip), %rdi      # 0xa594
callq 0x30a0
leaq 0x6302(%rip), %rdi      # 0xa5b1
callq 0x30a0
leaq 0x633a(%rip), %rdi      # 0xa5f5
callq 0x30a0
movsd 0xb688(%rip), %xmm0     # 0xf950
leaq 0x622f(%rip), %rdi      # 0xa4fe
movb $0x1, %al
callq 0x3100
leaq 0x635b(%rip), %rdi      # 0xa638
callq 0x30a0
movl 0xb660(%rip), %esi      # 0xf948
leaq 0x6229(%rip), %rbx      # 0xa518
movq %rbx, %rdi
xorl %eax, %eax
callq 0x3100
leaq 0x635f(%rip), %rdi      # 0xa65f
callq 0x30a0
movl 0xb639(%rip), %esi      # 0xf944
movq %rbx, %rdi
xorl %eax, %eax
callq 0x3100
leaq 0x6383(%rip), %rdi      # 0xa69f
callq 0x30a0
movl 0xb619(%rip), %esi      # 0xf940
movq %rbx, %rdi
xorl %eax, %eax
callq 0x3100
leaq 0x6389(%rip), %rdi      # 0xa6c1
callq 0x30a0
leaq 0x63a1(%rip), %rdi      # 0xa6e5
callq 0x30a0
jmp 0x4367
movq 0xae5e(%rip), %rsi      # 0xf1b0
movq 0xae5f(%rip), %rdx      # 0xf1b8
leaq 0x618f(%rip), %rdi      # 0xa4ef
xorl %eax, %eax
callq 0x3100
xorl %edi, %edi
callq 0x32d0
movq (%r12), %rsi
leaq 0x5eaa(%rip), %rdi      # 0xa223
xorl %eax, %eax
callq 0x3100
movq (%r12), %rsi
leaq 0x5ea3(%rip), %rdi      # 0xa22e
xorl %eax, %eax
callq 0x3100
movq (%r12), %rsi
leaq 0x5eaf(%rip), %rdi      # 0xa24c
xorl %eax, %eax
callq 0x3100
movq (%r12), %rsi
leaq 0x5ecc(%rip), %rdi      # 0xa27b
xorl %eax, %eax
callq 0x3100
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x32d0