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

    int old;
    FILE *in,*out;
    RRA *r;

    level = 20000;
    sign = 0;
    direction = 0;
    delaySize = 1;
    argIndex = processOptions(argc,argv);

    if (argc-argIndex == 0)
        {
        in = stdin;
        out = stdout;
        }
    else if (argc-argIndex == 1)
        {
        in = OpenFile(argv[argIndex],"r");
        out = stdout;
        }
    else if (argc-argIndex == 2)
        {
        in = OpenFile(argv[argIndex],"r");
        out = OpenFile(argv[argIndex+1],"w");
        }
    else
        {
        printf("usage: filter [<input rra file> [<output wave file>]]\n");
        exit(-1);
        }

    r = newRRAHeader();
    readRRAHeader(in, r, 0);
    
    if (r->channels != 1)
        Fatal("distorter only works on mono audio files\n");

    factor = ((int)pow(2,r->bitsPerSample - 1)/level) / 3;
    if (level >= 20000) {
        factor = 1;
    }

    /* compute new number of samples, saving the old number */
    old = r->samples;
    r->samples = (int) (r->samples / step);

    writeRRAHeader(out,r,"modifiedBy: rraDistorter",0);

    /* restore the old number */
    r->samples = old;

    processData(in,out,r);

    fclose(in);
    fclose(out);

    return 0;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movl %edi, %r14d
movl $0x4e20, 0x5b8a(%rip)   # imm = 0x4E20
xorl %eax, %eax
movl %eax, 0x5b86(%rip)      # 0x7168
movl %eax, 0x5b84(%rip)      # 0x716c
movl $0x1, 0x5b7e(%rip)      # 0x7170
movl $0x1, %r12d
cmpl $0x2, %edi
jl 0x16a4
movl %r14d, %r13d
movl $0x1, %r12d
leaq 0x2a0f(%rip), %r15      # 0x4020
movq (%rbx,%r12,8), %rsi
cmpb $0x2d, (%rsi)
jne 0x16a4
cmpb $0x0, 0x2(%rsi)
je 0x162a
leaq 0x2(%rsi), %rdi
jmp 0x162f
movq 0x8(%rbx,%r12,8), %rdi
movsbl 0x1(%rsi), %eax
addl $-0x66, %eax
rorl %eax
cmpl $0x8, %eax
ja 0x1688
movslq (%r15,%rax,4), %rax
addq %r15, %rax
jmpq *%rax
callq 0x1080
cvttsd2si %xmm0, %eax
movl %eax, 0x5b1b(%rip)      # 0x7170
jmp 0x1696
callq 0x1080
mulsd 0x29a4(%rip), %xmm0     # 0x4008
cvttsd2si %xmm0, %eax
movl %eax, 0x5af6(%rip)      # 0x7164
jmp 0x1696
movl $0x2, 0x5aee(%rip)      # 0x7168
jmp 0x1696
movl $0x1, 0x5ae2(%rip)      # 0x7168
jmp 0x1696
leaq 0x2a15(%rip), %rdi      # 0x40a4
xorl %eax, %eax
callq 0x19d4
incq %r12
cmpq %r12, %r13
jne 0x1611
jmp 0x16a9
subl %r12d, %r14d
jne 0x16b5
movq 0x5928(%rip), %rax      # 0x6fd8
movq (%rax), %r14
jmp 0x16df
cmpl $0x2, %r14d
je 0x17a7
cmpl $0x1, %r14d
jne 0x17f9
movslq %r12d, %rax
movq (%rbx,%rax,8), %rdi
leaq 0x2972(%rip), %rsi      # 0x4049
callq 0x1a6e
movq %rax, %r14
movq 0x58ea(%rip), %rax      # 0x6fd0
movq (%rax), %rbx
callq 0x1cdf
movq %rax, %r15
movq %r14, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x2105
cmpl $0x1, (%r15)
je 0x1712
leaq 0x2947(%rip), %rdi      # 0x4052
xorl %eax, %eax
callq 0x19d4
movl 0x8(%r15), %edi
decl %edi
movsd 0x28f0(%rip), %xmm0     # 0x4010
callq 0x1050
cvttsd2si %xmm0, %eax
movl 0x5a35(%rip), %ecx      # 0x7164
cltd
idivl %ecx
cltq
imulq $0x55555556, %rax, %rax # imm = 0x55555556
movq %rax, %rdx
shrq $0x3f, %rdx
shrq $0x20, %rax
addl %edx, %eax
cmpl $0x4e20, %ecx           # imm = 0x4E20
movl $0x1, %ecx
cmovll %eax, %ecx
movl %ecx, 0x5a18(%rip)      # 0x7174
movl 0xc(%r15), %r12d
leaq 0x2915(%rip), %rdx      # 0x407c
movq %rbx, %rdi
movq %r15, %rsi
xorl %ecx, %ecx
callq 0x2ba0
movl %r12d, 0xc(%r15)
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x180f
movq %r14, %rdi
callq 0x1090
movq %rbx, %rdi
callq 0x1090
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movslq %r12d, %r15
movq (%rbx,%r15,8), %rdi
leaq 0x2894(%rip), %rsi      # 0x4049
callq 0x1a6e
movq %rax, %r14
movq 0x8(%rbx,%r15,8), %rdi
leaq 0x2887(%rip), %rsi      # 0x4050
callq 0x1a6e
movq %rax, %rbx
jmp 0x16e9
movq 0x595b(%rip), %rsi      # 0x7138
movq 0x595c(%rip), %rdx      # 0x7140
leaq 0x28aa(%rip), %rdi      # 0x4095
xorl %eax, %eax
callq 0x10b0
xorl %edi, %edi
callq 0x1200
leaq 0x28be(%rip), %rdi      # 0x40be
callq 0x1070
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1200