// File: /workspace/github_c_makefile_star2_O1/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, %r14
movl %edi, %ebx
movl $0x1, %r12d
cmpl $0x2, %edi
jl 0x4012
movl $0x1, %r12d
movslq %r12d, %rax
movq (%r14,%rax,8), %rsi
cmpb $0x2d, (%rsi)
jne 0x4012
movb 0x2(%rsi), %r13b
testb %r13b, %r13b
je 0x3f76
leaq 0x2(%rsi), %rdi
jmp 0x3f7b
movq 0x8(%r14,%rax,8), %rdi
movzbl 0x1(%rsi), %eax
cmpl $0x6f, %eax
jg 0x3f9b
cmpl $0x62, %eax
je 0x3fb2
cmpl $0x63, %eax
jne 0x3fec
callq 0x32b0
movl %eax, 0xb9af(%rip)      # 0xf948
jmp 0x3fcc
cmpl $0x70, %eax
je 0x3fc1
cmpl $0x77, %eax
jne 0x3ff6
callq 0x32b0
movl %eax, 0xb990(%rip)      # 0xf940
jmp 0x3fcc
callq 0x30b0
movsd %xmm0, 0xb991(%rip)     # 0xf950
jmp 0x3fcc
callq 0x32b0
movl %eax, 0xb978(%rip)      # 0xf944
movb $0x1, %r15b
testb %r13b, %r13b
sete %al
andb %r15b, %al
movzbl %al, %eax
addl %eax, %r12d
incl %r12d
cmpl %ebx, %r12d
jl 0x3f57
jmp 0x4012
cmpl $0x68, %eax
jne 0x3fff
jmp 0x4333
cmpl $0x76, %eax
je 0x4406
xorl %r15d, %r15d
leaq 0x6527(%rip), %rdi      # 0xa530
xorl %eax, %eax
callq 0x84ec
jmp 0x3fcf
subl %r12d, %ebx
jne 0x402a
movq 0xafba(%rip), %rax      # 0xefd8
movq (%rax), %rbx
leaq 0x65c7(%rip), %rdi      # 0xa5ef
jmp 0x406f
cmpl $0x3, %ebx
je 0x42fa
cmpl $0x2, %ebx
je 0x4054
cmpl $0x1, %ebx
jne 0x4429
movq 0xaf90(%rip), %rax      # 0xefd8
movq (%rax), %rbx
movslq %r12d, %rax
movq (%r14,%rax,8), %rdi
jmp 0x406f
movslq %r12d, %r15
movq (%r14,%r15,8), %rdi
leaq 0x6681(%rip), %rsi      # 0xa6e3
callq 0x8586
movq %rax, %rbx
movq 0x8(%r14,%r15,8), %rdi
callq 0x4477
movq 0xaf55(%rip), %rax      # 0xefd0
movq (%rax), %r12
callq 0x8803
movq %rax, %r13
movq %rbx, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x8c10
movl 0x4(%r13), %eax
movl %eax, 0xbb43(%rip)      # 0xfbe0
cmpl $0x1, (%r13)
je 0x40b5
movq (%r14), %rsi
leaq 0x620e(%rip), %rdi      # 0xa2bc
xorl %eax, %eax
callq 0x84ec
leaq 0x621f(%rip), %rdx      # 0xa2db
movq %r12, %rdi
movq %r13, %rsi
xorl %ecx, %ecx
callq 0x9661
movslq 0xb870(%rip), %rdi      # 0xf940
shlq $0x2, %rdi
callq 0x3240
movq %rax, 0xd328(%rip)      # 0x11408
testq %rax, %rax
jne 0x40f3
leaq 0x6269(%rip), %rdi      # 0xa355
xorl %eax, %eax
callq 0x84ec
movq %r13, %rax
addq $0x4, %rax
movq %rax, -0x38(%rbp)
movb $0x0, 0xd30b(%rip)      # 0x11410
movq 0xaeec(%rip), %r15      # 0xeff8
leaq 0x581a(%rip), %r14      # 0x992d
movq %r13, -0x48(%rbp)
movq %r12, -0x40(%rbp)
movq %rbx, -0x50(%rbp)
movq (%r15), %rdi
movl 0xd2d8(%rip), %edx      # 0x11400
leal 0x1(%rdx), %eax
movl %eax, 0xd2cf(%rip)      # 0x11400
leaq 0x6235(%rip), %rsi      # 0xa36d
xorl %eax, %eax
callq 0x31e0
movl 0x8(%r13), %edx
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rcx
callq 0x90fc
movl %eax, %r14d
movzbl 0xd2b4(%rip), %r15d     # 0x11410
movl 0xb7de(%rip), %eax      # 0xf940
movl $0x0, %ecx
cmpl %r15d, %eax
jle 0x41cc
movl $0x1, %r12d
leaq 0x57b4(%rip), %r13      # 0x992d
movq %rbx, %rdi
callq 0x3200
testl %eax, %eax
movq 0xd27e(%rip), %rax      # 0x11408
movl $0x0, %ecx
cmovnel %ecx, %r14d
cmovnel %ecx, %r12d
movl %r14d, (%rax,%r15,4)
movq -0x48(%rbp), %rax
movl 0x8(%rax), %edx
movq %rbx, %rdi
movq -0x40(%rbp), %rsi
movq %r13, %rcx
callq 0x90fc
movl %eax, %r14d
incq %r15
movl 0xb783(%rip), %eax      # 0xf940
cmpl %r15d, %eax
jg 0x4179
testl %r12d, %r12d
sete %cl
movq -0x40(%rbp), %r12
movl %ecx, %ebx
addl %eax, 0xba10(%rip)      # 0xfbe4
xorps %xmm0, %xmm0
cvtsi2sdl 0xba01(%rip), %xmm0 # 0xfbe0
movapd %xmm0, %xmm1
mulsd 0x5e1d(%rip), %xmm1     # 0xa008
divsd 0xd205(%rip), %xmm1     # 0x113f8
cvttsd2si %xmm1, %edx
mulsd 0x5e11(%rip), %xmm0     # 0xa010
divsd 0xd1e9(%rip), %xmm0     # 0x113f0
cvttsd2si %xmm0, %r14d
movq 0xade5(%rip), %r15      # 0xeff8
movq (%r15), %rdi
leaq 0x6170(%rip), %rsi      # 0xa38d
movl %edx, %r13d
xorl %eax, %eax
callq 0x31e0
movq (%r15), %rdi
leaq 0x6178(%rip), %rsi      # 0xa3a9
movl %r14d, %edx
xorl %eax, %eax
callq 0x31e0
cmpl $0x0, 0xb702(%rip)      # 0xf944
movl $0x0, %esi
jle 0x425b
movl %r14d, %edi
movl %r13d, %esi
leaq -0x2c(%rbp), %rdx
callq 0x3507
movl -0x2c(%rbp), %esi
cmpl $0x18, %esi
jg 0x426f
callq 0x38c5
movsd 0x5dab(%rip), %xmm0     # 0xa018
jmp 0x4281
movq -0x38(%rbp), %rdi
leaq -0x58(%rbp), %rdx
callq 0x37a0
movsd -0x58(%rbp), %xmm0
leaq 0x56a5(%rip), %r14      # 0x992d
movq %r12, %rdi
callq 0x3340
testb %bl, %bl
movq -0x50(%rbp), %rbx
movq -0x48(%rbp), %r13
je 0x411f
movq 0xd161(%rip), %rdi      # 0x11408
callq 0x3040
movq %rbx, %rdi
callq 0x30d0
movq %r12, %rdi
callq 0x30d0
movl 0xb922(%rip), %edx      # 0xfbe4
xorps %xmm0, %xmm0
cvtsi2sd %edx, %xmm0
movq (%r15), %rdi
movq -0x38(%rbp), %rax
xorps %xmm1, %xmm1
cvtsi2sdl (%rax), %xmm1
divsd %xmm1, %xmm0
leaq 0x600d(%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 %r12d, %r15
movq (%r14,%r15,8), %rdi
leaq 0x63db(%rip), %rsi      # 0xa6e3
callq 0x8586
movq %rax, %rbx
movq 0x8(%r14,%r15,8), %rdi
callq 0x4477
movq 0x10(%r14,%r15,8), %rdi
leaq 0x5efb(%rip), %rsi      # 0xa221
callq 0x8586
movq %rax, %r12
jmp 0x407e
leaq 0x6210(%rip), %rdi      # 0xa54a
callq 0x30a0
leaq 0x6213(%rip), %rdi      # 0xa559
callq 0x30a0
leaq 0x6231(%rip), %rdi      # 0xa583
callq 0x30a0
leaq 0x6236(%rip), %rdi      # 0xa594
callq 0x30a0
leaq 0x6247(%rip), %rdi      # 0xa5b1
callq 0x30a0
leaq 0x627f(%rip), %rdi      # 0xa5f5
callq 0x30a0
movsd 0xb5cd(%rip), %xmm0     # 0xf950
leaq 0x6174(%rip), %rdi      # 0xa4fe
movb $0x1, %al
callq 0x3100
leaq 0x62a0(%rip), %rdi      # 0xa638
callq 0x30a0
movl 0xb5a5(%rip), %esi      # 0xf948
leaq 0x616e(%rip), %rbx      # 0xa518
movq %rbx, %rdi
xorl %eax, %eax
callq 0x3100
leaq 0x62a4(%rip), %rdi      # 0xa65f
callq 0x30a0
movl 0xb57e(%rip), %esi      # 0xf944
movq %rbx, %rdi
xorl %eax, %eax
callq 0x3100
leaq 0x62c8(%rip), %rdi      # 0xa69f
callq 0x30a0
movl 0xb55e(%rip), %esi      # 0xf940
movq %rbx, %rdi
xorl %eax, %eax
callq 0x3100
leaq 0x62ce(%rip), %rdi      # 0xa6c1
callq 0x30a0
leaq 0x62e6(%rip), %rdi      # 0xa6e5
callq 0x30a0
jmp 0x4422
movq 0xada3(%rip), %rsi      # 0xf1b0
movq 0xada4(%rip), %rdx      # 0xf1b8
leaq 0x60d4(%rip), %rdi      # 0xa4ef
xorl %eax, %eax
callq 0x3100
xorl %edi, %edi
callq 0x32d0
movq (%r14), %rsi
leaq 0x5df0(%rip), %rdi      # 0xa223
xorl %eax, %eax
callq 0x3100
movq (%r14), %rsi
leaq 0x5dea(%rip), %rdi      # 0xa22e
xorl %eax, %eax
callq 0x3100
movq (%r14), %rsi
leaq 0x5df7(%rip), %rdi      # 0xa24c
xorl %eax, %eax
callq 0x3100
movq (%r14), %rsi
leaq 0x5e15(%rip), %rdi      # 0xa27b
xorl %eax, %eax
callq 0x3100
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x32d0