// File: /workspace/github_c_makefile_star2_O1/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, 0x5bba(%rip)   # imm = 0x4E20
xorl %eax, %eax
movl %eax, 0x5bb6(%rip)      # 0x7168
movl %eax, 0x5bb4(%rip)      # 0x716c
movl $0x1, 0x5bae(%rip)      # 0x7170
movl $0x1, %r12d
cmpl $0x2, %edi
jl 0x1675
movl %r14d, %r13d
movl $0x1, %r12d
leaq 0x2a3f(%rip), %r15      # 0x4020
movq (%rbx,%r12,8), %rsi
cmpb $0x2d, (%rsi)
jne 0x1675
cmpb $0x0, 0x2(%rsi)
je 0x15fa
leaq 0x2(%rsi), %rdi
jmp 0x15ff
movq 0x8(%rbx,%r12,8), %rdi
movsbl 0x1(%rsi), %eax
addl $-0x66, %eax
rorl %eax
cmpl $0x8, %eax
ja 0x1658
movslq (%r15,%rax,4), %rax
addq %r15, %rax
jmpq *%rax
callq 0x1080
cvttsd2si %xmm0, %eax
movl %eax, 0x5b4b(%rip)      # 0x7170
jmp 0x1666
callq 0x1080
mulsd 0x29d4(%rip), %xmm0     # 0x4008
cvttsd2si %xmm0, %eax
movl %eax, 0x5b26(%rip)      # 0x7164
jmp 0x1666
movl $0x2, 0x5b1e(%rip)      # 0x7168
jmp 0x1666
movl $0x1, 0x5b12(%rip)      # 0x7168
jmp 0x1666
leaq 0x2a45(%rip), %rdi      # 0x40a4
xorl %eax, %eax
callq 0x199c
incq %r12
cmpq %r12, %r13
jne 0x15e1
movl %r13d, %r12d
subl %r12d, %r14d
jne 0x1686
movq 0x5957(%rip), %rax      # 0x6fd8
movq (%rax), %r14
jmp 0x16ac
cmpl $0x2, %r14d
je 0x16b8
cmpl $0x1, %r14d
jne 0x17c3
movslq %r12d, %rax
movq (%rbx,%rax,8), %rdi
leaq 0x29a5(%rip), %rsi      # 0x4049
callq 0x1a36
movq %rax, %r14
movq 0x591d(%rip), %rax      # 0x6fd0
movq (%rax), %rbx
jmp 0x16e2
movslq %r12d, %r15
movq (%rbx,%r15,8), %rdi
leaq 0x2983(%rip), %rsi      # 0x4049
callq 0x1a36
movq %rax, %r14
movq 0x8(%rbx,%r15,8), %rdi
leaq 0x2976(%rip), %rsi      # 0x4050
callq 0x1a36
movq %rax, %rbx
callq 0x1cb3
movq %rax, %r15
movq %r14, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x20c0
cmpl $0x1, (%r15)
je 0x170b
leaq 0x294e(%rip), %rdi      # 0x4052
xorl %eax, %eax
callq 0x199c
movl 0x8(%r15), %edi
decl %edi
movsd 0x28f7(%rip), %xmm0     # 0x4010
callq 0x1050
cvttsd2si %xmm0, %eax
movl 0x5a3c(%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, 0x5a1f(%rip)      # 0x7174
movl 0xc(%r15), %r12d
leaq 0x291c(%rip), %rdx      # 0x407c
movq %rbx, %rdi
movq %r15, %rsi
xorl %ecx, %ecx
callq 0x2b11
movl %r12d, 0xc(%r15)
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x17d9
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
movq 0x5991(%rip), %rsi      # 0x7138
movq 0x5992(%rip), %rdx      # 0x7140
leaq 0x28e0(%rip), %rdi      # 0x4095
xorl %eax, %eax
callq 0x10b0
xorl %edi, %edi
callq 0x1200
leaq 0x28f4(%rip), %rdi      # 0x40be
callq 0x1070
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1200