// File: /workspace/github_c_makefile_star2_O2/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
andl $0x0, 0x5e04(%rip)      # 0x7168
movl %edi, %r14d
andl $0x0, 0x5dfe(%rip)      # 0x716c
movl $0x4e20, 0x5dec(%rip)   # imm = 0x4E20
pushq $0x1
popq %rax
movl %eax, 0x5def(%rip)      # 0x7170
movslq %edi, %r12
cmpl $0x2, %r12d
cmovgel %edi, %eax
movl %eax, -0x2c(%rbp)
pushq $0x1
popq %r15
leaq 0x2c87(%rip), %r13      # 0x4020
cmpq %r12, %r15
jge 0x1430
movq (%rbx,%r15,8), %rsi
cmpb $0x2d, (%rsi)
jne 0x1435
cmpb $0x0, 0x2(%rsi)
je 0x13bb
leaq 0x2(%rsi), %rdi
jmp 0x13c0
movq 0x8(%rbx,%r15,8), %rdi
movsbl 0x1(%rsi), %eax
addl $-0x66, %eax
rorl %eax
cmpl $0x8, %eax
ja 0x141a
movslq (%r13,%rax,4), %rax
addq %r13, %rax
jmpq *%rax
callq 0x1080
cvttsd2si %xmm0, %eax
movl %eax, 0x5d89(%rip)      # 0x7170
jmp 0x1428
callq 0x1080
mulsd 0x2c1a(%rip), %xmm0     # 0x4010
cvttsd2si %xmm0, %eax
movl %eax, 0x5d64(%rip)      # 0x7164
jmp 0x1428
movl $0x2, 0x5d5c(%rip)      # 0x7168
jmp 0x1428
movl $0x1, 0x5d50(%rip)      # 0x7168
jmp 0x1428
leaq 0x2c83(%rip), %rdi      # 0x40a4
xorl %eax, %eax
callq 0x1720
incq %r15
jmp 0x1399
movl -0x2c(%rbp), %eax
jmp 0x1438
movl %r15d, %eax
subl %eax, %r14d
jne 0x1449
movq 0x5b94(%rip), %rax      # 0x6fd8
movq (%rax), %r14
jmp 0x146e
cmpl $0x2, %r14d
je 0x147a
cmpl $0x1, %r14d
jne 0x1573
cltq
movq (%rbx,%rax,8), %rdi
leaq 0x2be3(%rip), %rsi      # 0x4049
callq 0x1850
movq %rax, %r14
movq 0x5b5b(%rip), %rax      # 0x6fd0
movq (%rax), %rbx
jmp 0x14a4
movslq %eax, %r15
movq (%rbx,%r15,8), %rdi
leaq 0x2bc1(%rip), %rsi      # 0x4049
callq 0x1850
movq %rax, %r14
movq 0x8(%rbx,%r15,8), %rdi
leaq 0x2bb4(%rip), %rsi      # 0x4050
callq 0x1850
movq %rax, %rbx
callq 0x1aac
movq %rax, %r15
movq %r14, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x1e11
cmpl $0x1, (%r15)
je 0x14cd
leaq 0x2b8c(%rip), %rdi      # 0x4052
xorl %eax, %eax
callq 0x1720
movl 0x8(%r15), %edi
decl %edi
movsd 0x2b2d(%rip), %xmm0     # 0x4008
callq 0x1050
cvttsd2si %xmm0, %eax
movl 0x5c7a(%rip), %ecx      # 0x7164
cltd
idivl %ecx
pushq $0x3
popq %rsi
cltd
idivl %esi
cmpl $0x4e20, %ecx           # imm = 0x4E20
pushq $0x1
popq %rcx
cmovgel %ecx, %eax
movl %eax, 0x5c6f(%rip)      # 0x7174
movl 0xc(%r15), %r12d
leaq 0x2b6c(%rip), %rdx      # 0x407c
movq %rbx, %rdi
movq %r15, %rsi
xorl %ecx, %ecx
callq 0x2820
movl %r12d, 0xc(%r15)
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x1587
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 0x5be1(%rip), %rsi      # 0x7138
movq 0x5be2(%rip), %rdx      # 0x7140
leaq 0x2b30(%rip), %rdi      # 0x4095
xorl %eax, %eax
callq 0x10b0
xorl %edi, %edi
callq 0x1200
leaq 0x2b44(%rip), %rdi      # 0x40be
callq 0x1070
pushq $-0x1
popq %rdi
callq 0x1200