// File: /workspace/github_c_makefile_star2_O0/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
subq $0x30, %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 0x2640
movl %eax, -0x14(%rbp)
movl -0x8(%rbp), %eax
subl -0x14(%rbp), %eax
cmpl $0x0, %eax
jne 0x2434
movq 0xfbca(%rip), %rax      # 0x11fd8
movq (%rax), %rax
movq %rax, -0x20(%rbp)
leaq 0xae55(%rip), %rdi      # 0xd271
callq 0x28e0
movq 0xfba8(%rip), %rax      # 0x11fd0
movq (%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0x2585
movl -0x8(%rbp), %eax
subl -0x14(%rbp), %eax
cmpl $0x1, %eax
jne 0x2471
movq 0xfb92(%rip), %rax      # 0x11fd8
movq (%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x28e0
movq 0xfb6b(%rip), %rax      # 0x11fd0
movq (%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0x2583
movl -0x8(%rbp), %eax
subl -0x14(%rbp), %eax
cmpl $0x2, %eax
jne 0x24c1
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0xbb37(%rip), %rsi      # 0xdfc6
callq 0x97c0
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
callq 0x28e0
movq 0xfb1b(%rip), %rax      # 0x11fd0
movq (%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0x2581
movl -0x8(%rbp), %eax
subl -0x14(%rbp), %eax
cmpl $0x3, %eax
jne 0x2521
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0xbae7(%rip), %rsi      # 0xdfc6
callq 0x97c0
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
callq 0x28e0
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
leaq 0xad61(%rip), %rsi      # 0xd277
callq 0x97c0
movq %rax, -0x28(%rbp)
jmp 0x257f
movq -0x10(%rbp), %rax
movq (%rax), %rsi
leaq 0xad4a(%rip), %rdi      # 0xd279
movb $0x0, %al
callq 0x20d0
movq -0x10(%rbp), %rax
movq (%rax), %rsi
leaq 0xad40(%rip), %rdi      # 0xd284
movb $0x0, %al
callq 0x20d0
movq -0x10(%rbp), %rax
movq (%rax), %rsi
leaq 0xad49(%rip), %rdi      # 0xd2a2
movb $0x0, %al
callq 0x20d0
movq -0x10(%rbp), %rax
movq (%rax), %rsi
leaq 0xad63(%rip), %rdi      # 0xd2d1
movb $0x0, %al
callq 0x20d0
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x2280
jmp 0x2581
jmp 0x2583
jmp 0x2585
callq 0x9ca0
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rdi
movq -0x30(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0xa1a0
movq -0x30(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, 0x10604(%rip)     # 0x12bb0
movq -0x30(%rbp), %rax
cmpl $0x1, (%rax)
je 0x25ca
movq -0x10(%rbp), %rax
movq (%rax), %rsi
leaq 0xad4f(%rip), %rdi      # 0xd312
movb $0x0, %al
callq 0x9670
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
leaq 0xad58(%rip), %rdx      # 0xd331
xorl %eax, %eax
movl %eax, %ecx
callq 0xb140
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0x2b40
movq -0x20(%rbp), %rdi
callq 0x20a0
movq -0x28(%rbp), %rdi
callq 0x20a0
movq 0xf9ec(%rip), %rax      # 0x11ff8
movq (%rax), %rdi
movl 0x1059f(%rip), %edx     # 0x12bb4
cvtsi2sdl 0x10597(%rip), %xmm0 # 0x12bb4
movq -0x30(%rbp), %rax
cvtsi2sdl 0x4(%rax), %xmm1
divsd %xmm1, %xmm0
leaq 0xad14(%rip), %rsi      # 0xd345
movb $0x1, %al
callq 0x21a0
xorl %eax, %eax
addq $0x30, %rsp
popq %rbp
retq