// File: /workspace/github_c_makefile_star2_O0/pipde[P]deos-songlib/utils/distort2/distort2.c
// Function: processData
static void
processData(FILE *in,FILE *out, RRA *r)
{
    int i,j;
    int count = 0;
    int delayLine[delaySize];
    for (i=0; i < r->samples; ++i) {
        for (j=0; j < r->channels; ++j)
        {
            int amp = readRRAAmplitude(in, out, r->bitsPerSample, outputComment);

            int temp = amp;
            if (count < delaySize)
            {
                delayLine[count] = temp;
            }
            else
            {
               if (loc >= delaySize)
               {
                    loc = 0;
               }
               temp += delayLine[loc];
               if (temp >= level) {
                    temp = level;
               }
               else if (temp <= -level) {
                    temp = -level;
               }     
               delayLine[loc] = temp;
               loc++;
            }
            count++;
            if (sign == 1) {
                if (temp < 0)
                    temp = -temp;
                }
            if (sign == 2) {
                if (temp > 0)
                    temp = -temp;
                }
            
            if (temp >= level) {
                temp = level;
            }
            else if (temp <= -level) {
                temp = -level;
            }
            else
            {
                // these calculations make the transitions into and out of
                // the clipping levels smoother
                double fLevel = (double) level;
                double fTemp = (double) temp;
                double dec = fTemp/fLevel;
                double newDec = dec - ((dec*dec*dec)/3.0);
                double newAmp = newDec * level;
                temp =(int) newAmp;
            }
            fprintf(out, "%d\n", temp * factor);
        }
    }
    while (delayLine[loc] * delayLine[loc] > 100)
    {
        if (loc >= 20)
        {
            loc = 0;
        }
        int a;
        a = delayLine[loc];
        delayLine[loc] = (2/3)*a;
        loc++;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl $0x0, -0x24(%rbp)
movl 0x6a84(%rip), %eax      # 0x8158
movq %rsp, %rcx
movq %rcx, -0x30(%rbp)
leaq 0xf(,%rax,4), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x78(%rbp)
movq %rcx, %rsp
movq %rax, -0x38(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jge 0x18fb
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x18eb
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rax
movl 0x8(%rax), %edx
leaq 0x2145(%rip), %rcx      # 0x3880
callq 0x2bd0
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movl %eax, -0x40(%rbp)
movl -0x24(%rbp), %eax
cmpl 0x6a06(%rip), %eax      # 0x8158
jge 0x1764
movq -0x78(%rbp), %rax
movl -0x40(%rbp), %edx
movslq -0x24(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x17e2
movl 0x69de(%rip), %eax      # 0x8148
cmpl 0x69e8(%rip), %eax      # 0x8158
jl 0x177c
movl $0x0, 0x69cc(%rip)      # 0x8148
movq -0x78(%rbp), %rax
movslq 0x69c1(%rip), %rcx      # 0x8148
movl (%rax,%rcx,4), %eax
addl -0x40(%rbp), %eax
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl 0x69b3(%rip), %eax      # 0x814c
jl 0x17a6
movl 0x69ab(%rip), %eax      # 0x814c
movl %eax, -0x40(%rbp)
jmp 0x17c2
movl -0x40(%rbp), %eax
xorl %ecx, %ecx
subl 0x699b(%rip), %ecx      # 0x814c
cmpl %ecx, %eax
jg 0x17c0
xorl %eax, %eax
subl 0x698f(%rip), %eax      # 0x814c
movl %eax, -0x40(%rbp)
jmp 0x17c2
movq -0x78(%rbp), %rax
movl -0x40(%rbp), %edx
movslq 0x6978(%rip), %rcx      # 0x8148
movl %edx, (%rax,%rcx,4)
movl 0x696f(%rip), %eax      # 0x8148
addl $0x1, %eax
movl %eax, 0x6966(%rip)      # 0x8148
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
cmpl $0x1, 0x695e(%rip)      # 0x8150
jne 0x1804
cmpl $0x0, -0x40(%rbp)
jge 0x1802
xorl %eax, %eax
subl -0x40(%rbp), %eax
movl %eax, -0x40(%rbp)
jmp 0x1804
cmpl $0x2, 0x6945(%rip)      # 0x8150
jne 0x181d
cmpl $0x0, -0x40(%rbp)
jle 0x181b
xorl %eax, %eax
subl -0x40(%rbp), %eax
movl %eax, -0x40(%rbp)
jmp 0x181d
movl -0x40(%rbp), %eax
cmpl 0x6926(%rip), %eax      # 0x814c
jl 0x1836
movl 0x691e(%rip), %eax      # 0x814c
movl %eax, -0x40(%rbp)
jmp 0x18c1
movl -0x40(%rbp), %eax
xorl %ecx, %ecx
subl 0x690b(%rip), %ecx      # 0x814c
cmpl %ecx, %eax
jg 0x1852
xorl %eax, %eax
subl 0x68ff(%rip), %eax      # 0x814c
movl %eax, -0x40(%rbp)
jmp 0x18bf
cvtsi2sdl 0x68f2(%rip), %xmm0 # 0x814c
movsd %xmm0, -0x48(%rbp)
cvtsi2sdl -0x40(%rbp), %xmm0
movsd %xmm0, -0x50(%rbp)
movsd -0x50(%rbp), %xmm0
divsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x58(%rbp)
movsd -0x58(%rbp), %xmm0
movsd -0x58(%rbp), %xmm1
mulsd -0x58(%rbp), %xmm1
mulsd -0x58(%rbp), %xmm1
movsd 0x3784(%rip), %xmm2     # 0x5018
divsd %xmm2, %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, -0x60(%rbp)
movsd -0x60(%rbp), %xmm0
cvtsi2sdl 0x689e(%rip), %xmm1 # 0x814c
mulsd %xmm1, %xmm0
movsd %xmm0, -0x68(%rbp)
cvttsd2si -0x68(%rbp), %eax
movl %eax, -0x40(%rbp)
jmp 0x18c1
movq -0x10(%rbp), %rdi
movl -0x40(%rbp), %edx
imull 0x688d(%rip), %edx      # 0x815c
leaq 0x393f(%rip), %rsi      # 0x5215
movb $0x0, %al
callq 0x1110
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x1716
jmp 0x18ed
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x16ff
jmp 0x18fd
movq -0x78(%rbp), %rcx
movslq 0x6840(%rip), %rax      # 0x8148
movl (%rcx,%rax,4), %eax
movslq 0x6836(%rip), %rdx      # 0x8148
imull (%rcx,%rdx,4), %eax
cmpl $0x64, %eax
jle 0x195e
cmpl $0x14, 0x6826(%rip)     # 0x8148
jl 0x192e
movl $0x0, 0x681a(%rip)      # 0x8148
movq -0x78(%rbp), %rax
movslq 0x680f(%rip), %rcx      # 0x8148
movl (%rax,%rcx,4), %ecx
movl %ecx, -0x6c(%rbp)
imull $0x0, -0x6c(%rbp), %edx
movslq 0x67fe(%rip), %rcx      # 0x8148
movl %edx, (%rax,%rcx,4)
movl 0x67f5(%rip), %eax      # 0x8148
addl $0x1, %eax
movl %eax, 0x67ec(%rip)      # 0x8148
jmp 0x18fd
movq -0x30(%rbp), %rax
movq %rax, %rsp
movq %rbp, %rsp
popq %rbp
retq
nopw (%rax,%rax)