// File: /workspace/github_c_makefile_star2_O2/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 $0x58, %rsp
movq %rsi, %r15
movl %edi, %ebx
pushq $0x1
popq %r12
movslq %r12d, %r14
cmpl %r12d, %ebx
jle 0x34ee
movq (%r15,%r14,8), %rsi
cmpb $0x2d, (%rsi)
jne 0x34ee
movb 0x2(%rsi), %r13b
testb %r13b, %r13b
je 0x345e
leaq 0x2(%rsi), %rdi
jmp 0x3463
movq 0x8(%r15,%r14,8), %rdi
movzbl 0x1(%rsi), %eax
cmpl $0x62, %eax
je 0x34ad
cmpl $0x63, %eax
je 0x34c9
cmpl $0x70, %eax
je 0x34bc
cmpl $0x77, %eax
je 0x34a0
cmpl $0x68, %eax
je 0x3c7b
cmpl $0x76, %eax
je 0x3d4e
xorl %r14d, %r14d
leaq 0x7099(%rip), %rdi      # 0xa530
xorl %eax, %eax
callq 0x7b30
jmp 0x34d7
callq 0x32a0
movl %eax, 0xc485(%rip)      # 0xf930
jmp 0x34d4
callq 0x30b0
movsd %xmm0, 0xc486(%rip)     # 0xf940
jmp 0x34d4
callq 0x32a0
movl %eax, 0xc46d(%rip)      # 0xf934
jmp 0x34d4
callq 0x32a0
movl %eax, 0xc464(%rip)      # 0xf938
movb $0x1, %r14b
testb %r13b, %r13b
sete %al
andb %r14b, %al
movzbl %al, %eax
addl %eax, %r12d
incl %r12d
jmp 0x3436
subl %r12d, %ebx
jne 0x3506
movq 0xbade(%rip), %rax      # 0xefd8
movq (%rax), %rbx
leaq 0x70eb(%rip), %rdi      # 0xa5ef
jmp 0x3574
cmpl $0x3, %ebx
je 0x3529
cmpl $0x2, %ebx
je 0x355c
cmpl $0x1, %ebx
jne 0x3d71
movq 0xbab8(%rip), %rax      # 0xefd8
movq (%rax), %rbx
movq (%r15,%r14,8), %rdi
jmp 0x3574
movq (%r15,%r14,8), %rdi
leaq 0x71af(%rip), %rsi      # 0xa6e3
callq 0x7c60
movq %rax, %rbx
movq 0x8(%r15,%r14,8), %rdi
callq 0x3dbd
movq 0x10(%r15,%r14,8), %rdi
leaq 0x6ccf(%rip), %rsi      # 0xa221
callq 0x7c60
movq %rax, %r12
jmp 0x3583
movq (%r15,%r14,8), %rdi
leaq 0x717c(%rip), %rsi      # 0xa6e3
callq 0x7c60
movq %rax, %rbx
movq 0x8(%r15,%r14,8), %rdi
callq 0x3dbd
movq 0xba50(%rip), %rax      # 0xefd0
movq (%rax), %r12
callq 0x7ebc
movq %rax, %r13
movq %rbx, -0x50(%rbp)
movq %rbx, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x8221
movl 0x4(%r13), %eax
movl %eax, 0xc62a(%rip)      # 0xfbd0
cmpl $0x1, (%r13)
je 0x35be
movq (%r15), %rsi
leaq 0x6d05(%rip), %rdi      # 0xa2bc
xorl %eax, %eax
callq 0x7b30
leaq 0x6d16(%rip), %rdx      # 0xa2db
movq %r12, %rdi
movq %r13, %rsi
xorl %ecx, %ecx
callq 0x8c30
movslq 0xc357(%rip), %rdi      # 0xf930
shlq $0x2, %rdi
callq 0x3230
movq %rax, 0xde0f(%rip)      # 0x113f8
testq %rax, %rax
jne 0x35fc
leaq 0x6d60(%rip), %rdi      # 0xa355
xorl %eax, %eax
callq 0x7b30
movb $0x0, 0xddfd(%rip)      # 0x11400
pushq $0x1
popq %rax
movq -0x50(%rbp), %r15
movq %r12, -0x78(%rbp)
movq %r13, -0x70(%rbp)
testl %eax, %eax
je 0x3c22
movq 0xb9d7(%rip), %rax      # 0xeff8
movq (%rax), %rdi
movl 0xddc6(%rip), %edx      # 0x113f0
leal 0x1(%rdx), %eax
movl %eax, 0xddbd(%rip)      # 0x113f0
leaq 0x6d33(%rip), %rsi      # 0xa36d
xorl %eax, %eax
callq 0x31e0
movl 0x8(%r13), %edx
movq %r15, %rdi
movq %r12, %rsi
leaq 0x586b(%rip), %rcx      # 0x8ebd
callq 0x86f6
movl %eax, %ebx
movzbl 0xdd9f(%rip), %r14d     # 0x11400
pushq $0x1
popq %rax
movl %eax, -0x38(%rbp)
movslq 0xc2c2(%rip), %rax      # 0xf930
cmpq %rax, %r14
jge 0x36b6
movq %r15, %rdi
callq 0x3200
testl %eax, %eax
movq 0xdd74(%rip), %rax      # 0x113f8
movl $0x0, %ecx
cmovnel %ecx, %ebx
movl -0x38(%rbp), %edx
cmovnel %ecx, %edx
movl %edx, -0x38(%rbp)
movl %ebx, (%rax,%r14,4)
movl 0x8(%r13), %edx
movq %r15, %rdi
movq %r12, %rsi
leaq 0x5813(%rip), %rcx      # 0x8ebd
callq 0x86f6
movl %eax, %ebx
incq %r14
jmp 0x3667
addl %eax, 0xc518(%rip)      # 0xfbd4
cvtsi2sdl 0xc50c(%rip), %xmm0 # 0xfbd0
movapd %xmm0, %xmm1
mulsd 0x6938(%rip), %xmm1     # 0xa008
divsd 0xdd10(%rip), %xmm1     # 0x113e8
cvttsd2si %xmm1, %edx
mulsd 0x692c(%rip), %xmm0     # 0xa010
divsd 0xdcf4(%rip), %xmm0     # 0x113e0
cvttsd2si %xmm0, %r14d
movq 0xb900(%rip), %rbx      # 0xeff8
movq (%rbx), %rdi
movl $0x0, -0x34(%rbp)
leaq 0x6c84(%rip), %rsi      # 0xa38d
movl %edx, -0x40(%rbp)
xorl %eax, %eax
callq 0x31e0
movq (%rbx), %rdi
leaq 0x6c8c(%rip), %rsi      # 0xa3a9
movl %r14d, -0x3c(%rbp)
movl %r14d, %edx
xorl %eax, %eax
callq 0x31e0
movsd 0x68e5(%rip), %xmm0     # 0xa018
movsd %xmm0, -0x48(%rbp)
movl $0x0, -0x30(%rbp)
xorl %edx, %edx
cmpl 0xc1ed(%rip), %edx      # 0xf934
leaq 0x6c72(%rip), %r14      # 0xa3c0
pushq $0xc
popq %r11
leaq 0xd487(%rip), %rbx      # 0x10be0
jge 0x3976
movq 0xb892(%rip), %rax      # 0xeff8
movq (%rax), %rdi
leaq 0x6c54(%rip), %rsi      # 0xa3c4
movl %edx, -0x54(%rbp)
xorl %eax, %eax
callq 0x31e0
movslq 0xc1af(%rip), %rax      # 0xf930
movq 0xdc70(%rip), %rcx      # 0x113f8
movslq -0x30(%rbp), %rdx
leal 0x1(%rdx), %r12d
cmpl %r12d, %eax
cmovgl %eax, %r12d
movl %edx, %r13d
negl %r13d
leaq 0x1(%rdx), %rsi
cmpq %rax, %rsi
jge 0x37bd
cmpl $0x0, (%rcx,%rdx,4)
jns 0x37b2
cmpl $0x0, (%rcx,%rsi,4)
jns 0x37ba
decl %r13d
movq %rsi, %rdx
jmp 0x379d
movl %esi, %r12d
movq 0xb834(%rip), %rax      # 0xeff8
movq (%rax), %rdi
leaq 0x6c02(%rip), %rsi      # 0xa3d0
movl %r12d, %edx
xorl %eax, %eax
callq 0x31e0
movslq %r12d, %r10
movl %r12d, -0x30(%rbp)
movl 0xc153(%rip), %edx      # 0xf938
movq 0xdc0c(%rip), %rax      # 0x113f8
movl -0x40(%rbp), %r8d
movl -0x3c(%rbp), %r9d
movslq 0xc135(%rip), %rcx      # 0xf930
movslq %edx, %rdx
subq %rdx, %rcx
movslq %r12d, %rdx
leal 0x1(%rdx), %r12d
cmpl %r12d, %ecx
cmovgl %ecx, %r12d
leal (%rdx,%r13), %ebx
incq %rdx
cmpq %rcx, %rdx
jge 0x383e
movl -0x4(%rax,%rdx,4), %esi
movl %esi, %edi
negl %edi
cmovsl %esi, %edi
cmpl %r15d, %edi
cmovgl %edi, %r15d
testl %esi, %esi
jns 0x3837
cmpl $0x0, (%rax,%rdx,4)
jns 0x383b
incl %ebx
jmp 0x3813
movl %edx, %r12d
movl %r15d, %edx
movslq %r12d, %r14
movl (%rax,%r14,4), %esi
movl %esi, %r15d
negl %r15d
cmovsl %esi, %r15d
cmpl %edx, %r15d
cmovlel %edx, %r15d
cmpl %ecx, %r14d
je 0x3964
cmpl %r9d, %ebx
jg 0x3964
cmpl %r8d, %ebx
jl 0x3801
cmpl $0x12c, %r15d           # imm = 0x12C
jb 0x3801
movq 0xb778(%rip), %rax      # 0xeff8
movq (%rax), %rdi
leaq 0x6b69(%rip), %rsi      # 0xa3f3
movl %r14d, %edx
xorl %eax, %eax
movq %r10, -0x60(%rbp)
callq 0x31e0
movq 0xb759(%rip), %rax      # 0xeff8
movq (%rax), %rdi
leaq 0x6b6b(%rip), %rsi      # 0xa414
movl %r15d, %edx
xorl %eax, %eax
callq 0x31e0
movq -0x60(%rbp), %r10
movl 0xc07b(%rip), %edx      # 0xf938
movq 0xdb34(%rip), %rax      # 0x113f8
testl %edx, %edx
movl $0x0, %ecx
cmovgl %edx, %ecx
leaq (%rax,%r10,4), %rsi
leaq (%rax,%r14,4), %rdi
xorpd %xmm1, %xmm1
xorl %r8d, %r8d
cmpq %r8, %rcx
je 0x38fc
movl (%rsi,%r8,4), %r9d
subl (%rdi,%r8,4), %r9d
cvtsi2sd %r9d, %xmm0
mulsd %xmm0, %xmm0
addsd %xmm0, %xmm1
incq %r8
jmp 0x38dd
xorpd %xmm0, %xmm0
ucomisd -0x48(%rbp), %xmm0
cvtsi2sd %edx, %xmm0
divsd %xmm0, %xmm1
movl -0x40(%rbp), %r8d
movl -0x3c(%rbp), %r9d
ja 0x3926
movsd -0x48(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x37f4
movq 0xb6cb(%rip), %rax      # 0xeff8
movq (%rax), %rdi
leaq 0x6af2(%rip), %rsi      # 0xa429
movl %ebx, %edx
movapd %xmm1, %xmm0
movsd %xmm1, -0x68(%rbp)
movsd -0x48(%rbp), %xmm1
movb $0x2, %al
callq 0x31e0
movq -0x60(%rbp), %r10
movl %ebx, -0x34(%rbp)
movsd -0x68(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
jmp 0x37df
movl -0x54(%rbp), %edx
incl %edx
movq -0x78(%rbp), %r12
movq -0x70(%rbp), %r13
jmp 0x3741
movl -0x34(%rbp), %ecx
cmpl $0x18, %ecx
jg 0x39ab
movq 0xb673(%rip), %rax      # 0xeff8
movq (%rax), %rcx
leaq 0x69ea(%rip), %rdi      # 0xa379
pushq $0x13
popq %rsi
pushq $0x1
popq %rdx
callq 0x32d0
movsd 0x667e(%rip), %xmm1     # 0xa020
movq -0x50(%rbp), %r15
jmp 0x3a95
movl 0x4(%r13), %eax
cltd
idivl %ecx
cvtsi2sd %eax, %xmm0
mulsd 0xbf82(%rip), %xmm0     # 0xf940
movslq 0xc213(%rip), %rdi      # 0xfbd8
xorpd %xmm4, %xmm4
xorl %esi, %esi
pushq $0x1
popq %rcx
movq -0x50(%rbp), %r15
leaq 0xb7d7(%rip), %r10      # 0xf1b0
cmpq $0x6c, %rcx
je 0x3a50
xorl %r8d, %r8d
movl %ecx, %eax
xorl %edx, %edx
divl %r11d
movq %rbx, %rax
xorl %r9d, %r9d
testl %r9d, %r9d
jne 0x3a0b
cmpq %rdi, %r8
jge 0x3a0b
xorl %r9d, %r9d
cmpl (%rax), %edx
sete %r9b
incq %r8
addq $0x4, %rax
jmp 0x39ef
testl %r9d, %r9d
je 0x3a4b
movsd (%r10,%rcx,8), %xmm1
subsd %xmm0, %xmm1
andpd 0x661e(%rip), %xmm1     # 0xa040
movapd %xmm4, %xmm2
xorpd %xmm3, %xmm3
cmpeqpd %xmm3, %xmm2
movapd %xmm1, %xmm3
cmpltpd %xmm4, %xmm3
orpd %xmm2, %xmm3
movd %xmm3, %eax
testb $0x1, %al
cmovnel %ecx, %esi
je 0x3a4b
movapd %xmm1, %xmm4
incq %rcx
jmp 0x39d9
movq 0xb5a1(%rip), %rax      # 0xeff8
movq (%rax), %rdi
movslq %esi, %rbx
movsd (%r10,%rbx,8), %xmm1
leaq 0xbaa6(%rip), %rax      # 0xf510
movq (%rax,%rbx,8), %rcx
leaq 0x6a4c(%rip), %rsi      # 0xa4c1
movl -0x34(%rbp), %edx
movb $0x2, %al
movsd %xmm0, -0x30(%rbp)
callq 0x31e0
leaq 0xb725(%rip), %rax      # 0xf1b0
movsd (%rax,%rbx,8), %xmm1
divsd -0x30(%rbp), %xmm1
movsd 0xd96b(%rip), %xmm0     # 0x11408
ucomisd 0x658b(%rip), %xmm0     # 0xa030
jne 0x3ab5
jp 0x3ab5
movsd %xmm1, 0xd957(%rip)     # 0x11408
movapd %xmm1, %xmm0
movq 0xb53c(%rip), %rax      # 0xeff8
movq (%rax), %rdi
leaq 0x6987(%rip), %rsi      # 0xa44d
movb $0x2, %al
movsd %xmm1, -0x30(%rbp)
callq 0x31e0
movb $0x1, %bl
movsd 0xd934(%rip), %xmm0     # 0x11410
movl 0xbe4e(%rip), %esi      # 0xf930
leal -0x1(%rsi), %eax
cvtsi2sd %eax, %xmm1
ucomisd %xmm0, %xmm1
jbe 0x3ba6
movq 0xd8fe(%rip), %rdi      # 0x113f8
callq 0x67d0
movq %r12, %rdi
movq %r14, %rsi
movl %eax, %edx
xorl %eax, %eax
callq 0x31e0
decl 0xc0c0(%rip)            # 0xfbd4
movsd 0xd8ec(%rip), %xmm1     # 0x11408
movsd 0xd8ec(%rip), %xmm0     # 0x11410
addsd %xmm1, %xmm0
movsd %xmm0, 0xd8e0(%rip)     # 0x11410
movsd -0x30(%rbp), %xmm2
ucomisd %xmm1, %xmm2
jbe 0x3b53
mulsd 0x64e5(%rip), %xmm1     # 0xa028
movsd %xmm1, 0xd8bd(%rip)     # 0x11408
ucomisd %xmm2, %xmm1
jb 0x3adc
jmp 0x3b6d
divsd 0x64cd(%rip), %xmm1     # 0xa028
movsd %xmm1, 0xd8a5(%rip)     # 0x11408
ucomisd %xmm1, %xmm2
jb 0x3adc
movsd %xmm2, 0xd893(%rip)     # 0x11408
testb $0x1, %bl
movl $0x0, %ebx
je 0x3adc
movq 0xb46e(%rip), %rax      # 0xeff8
movq (%rax), %rdi
leaq 0x68dd(%rip), %rsi      # 0xa471
movapd %xmm2, %xmm0
movb $0x1, %al
callq 0x31e0
xorl %ebx, %ebx
jmp 0x3ad4
testb $0x1, %bl
je 0x3bef
movq 0xb446(%rip), %rbx      # 0xeff8
movq (%rbx), %rdi
leaq 0x68d0(%rip), %rsi      # 0xa48c
movsd -0x30(%rbp), %xmm0
movb $0x1, %al
callq 0x31e0
movq (%rbx), %rdi
movsd 0xd835(%rip), %xmm0     # 0x11408
leaq 0x68d1(%rip), %rsi      # 0xa4ab
movb $0x1, %al
callq 0x31e0
movsd 0xd827(%rip), %xmm0     # 0x11410
movl 0xbd41(%rip), %esi      # 0xf930
cvttpd2dq %xmm0, %xmm1
cvtdq2pd %xmm1, %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, 0xd80d(%rip)     # 0x11410
movq 0xd7ee(%rip), %rax      # 0x113f8
movslq %esi, %rcx
movl -0x4(%rax,%rcx,4), %ecx
movl %ecx, (%rax)
movb $0x1, 0xd7e6(%rip)      # 0x11400
movl -0x38(%rbp), %eax
jmp 0x3612
movq 0xd7cf(%rip), %rdi      # 0x113f8
callq 0x3040
movq %r15, %rdi
callq 0x30d0
movq %r12, %rdi
callq 0x30d0
movl 0xbf90(%rip), %edx      # 0xfbd4
cvtsi2sd %edx, %xmm0
movq 0xb3a9(%rip), %rax      # 0xeff8
movq (%rax), %rdi
cvtsi2sdl 0x4(%r13), %xmm1
divsd %xmm1, %xmm0
leaq 0x668c(%rip), %rsi      # 0xa2ef
movb $0x1, %al
callq 0x31e0
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x68c8(%rip), %rdi      # 0xa54a
callq 0x30a0
leaq 0x68cb(%rip), %rdi      # 0xa559
callq 0x30a0
leaq 0x68e9(%rip), %rdi      # 0xa583
callq 0x30a0
leaq 0x68ee(%rip), %rdi      # 0xa594
callq 0x30a0
leaq 0x68ff(%rip), %rdi      # 0xa5b1
callq 0x30a0
leaq 0x6937(%rip), %rdi      # 0xa5f5
callq 0x30a0
movsd 0xbc75(%rip), %xmm0     # 0xf940
leaq 0x682c(%rip), %rdi      # 0xa4fe
movb $0x1, %al
callq 0x3100
leaq 0x6958(%rip), %rdi      # 0xa638
callq 0x30a0
movl 0xbc4d(%rip), %esi      # 0xf938
leaq 0x6826(%rip), %rbx      # 0xa518
movq %rbx, %rdi
xorl %eax, %eax
callq 0x3100
leaq 0x695c(%rip), %rdi      # 0xa65f
callq 0x30a0
movl 0xbc26(%rip), %esi      # 0xf934
movq %rbx, %rdi
xorl %eax, %eax
callq 0x3100
leaq 0x6980(%rip), %rdi      # 0xa69f
callq 0x30a0
movl 0xbc06(%rip), %esi      # 0xf930
movq %rbx, %rdi
xorl %eax, %eax
callq 0x3100
leaq 0x6986(%rip), %rdi      # 0xa6c1
callq 0x30a0
leaq 0x699e(%rip), %rdi      # 0xa6e5
callq 0x30a0
jmp 0x3d6a
movq 0xb44b(%rip), %rsi      # 0xf1a0
movq 0xb44c(%rip), %rdx      # 0xf1a8
leaq 0x678c(%rip), %rdi      # 0xa4ef
xorl %eax, %eax
callq 0x3100
xorl %edi, %edi
callq 0x32c0
movq (%r15), %rsi
leaq 0x64a8(%rip), %rdi      # 0xa223
xorl %eax, %eax
callq 0x3100
movq (%r15), %rsi
leaq 0x64a2(%rip), %rdi      # 0xa22e
xorl %eax, %eax
callq 0x3100
movq (%r15), %rsi
leaq 0x64af(%rip), %rdi      # 0xa24c
xorl %eax, %eax
callq 0x3100
movq (%r15), %rsi
leaq 0x64cd(%rip), %rdi      # 0xa27b
xorl %eax, %eax
callq 0x3100
pushq $-0x1
popq %rdi
callq 0x32c0