// File: /workspace/github_c_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r14
movq %rdi, -0x48(%rbp)
movl 0x5943(%rip), %eax      # 0x7170
movq %rsp, %rsi
leaq 0xf(,%rax,4), %rax
andq $-0x10, %rax
subq %rax, %rsi
movq %rsi, %rsp
movl 0xc(%rdx), %ecx
testl %ecx, %ecx
jle 0x1989
movq %rdx, %rbx
movl (%rdx), %eax
xorl %edx, %edx
xorl %edi, %edi
movq %rsi, -0x38(%rbp)
testl %eax, %eax
jle 0x197f
movl %edx, -0x30(%rbp)
movl %edi, -0x2c(%rbp)
movslq %edi, %r15
leaq (%rsi,%r15,4), %rax
movq %rax, -0x40(%rbp)
xorl %r13d, %r13d
leaq (%r15,%r13), %r12
movl 0x8(%rbx), %edx
movq -0x48(%rbp), %rdi
movq %r14, %rsi
leaq 0x15e0(%rip), %rcx      # 0x2e6b
callq 0x2608
movslq 0x58d9(%rip), %rcx      # 0x7170
cmpq %rcx, %r12
jge 0x18ac
movq -0x40(%rbp), %rcx
movl %eax, (%rcx,%r13,4)
movl 0x58ba(%rip), %ecx      # 0x7164
jmp 0x18e7
movl 0x58ae(%rip), %edx      # 0x7160
cmpl %ecx, %edx
movl $0x0, %ecx
cmovgel %ecx, %edx
movslq %edx, %rdx
movq -0x38(%rbp), %rdi
addl (%rdi,%rdx,4), %eax
movl 0x5898(%rip), %ecx      # 0x7164
movl %ecx, %esi
negl %esi
cmpl %esi, %eax
cmovgl %eax, %esi
cmpl %ecx, %eax
cmovgel %ecx, %esi
movl %esi, (%rdi,%rdx,4)
incl %edx
movl %edx, 0x587b(%rip)      # 0x7160
movl %esi, %eax
movl %eax, %edx
negl %edx
cmovsl %eax, %edx
movl 0x5874(%rip), %esi      # 0x7168
cmpl $0x1, %esi
cmovnel %eax, %edx
movl %edx, %eax
negl %eax
cmovnsl %edx, %eax
cmpl $0x2, %esi
cmovnel %edx, %eax
cmpl %ecx, %eax
jge 0x1947
movl %ecx, %edx
negl %edx
cmpl %edx, %eax
jle 0x1949
xorps %xmm0, %xmm0
cvtsi2sd %ecx, %xmm0
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
divsd %xmm0, %xmm1
movapd %xmm1, %xmm2
mulsd %xmm1, %xmm2
mulsd %xmm1, %xmm2
divsd 0x26df(%rip), %xmm2     # 0x4018
addsd %xmm1, %xmm2
mulsd %xmm0, %xmm2
cvttsd2si %xmm2, %edx
jmp 0x1949
movl %ecx, %edx
imull 0x5824(%rip), %edx      # 0x7174
movq %r14, %rdi
leaq 0x28cb(%rip), %rsi      # 0x4225
xorl %eax, %eax
callq 0x1140
movl (%rbx), %eax
incq %r13
cmpl %eax, %r13d
jl 0x1876
movl -0x2c(%rbp), %edi
addl %r13d, %edi
movl 0xc(%rbx), %ecx
movq -0x38(%rbp), %rsi
movl -0x30(%rbp), %edx
incl %edx
cmpl %ecx, %edx
jl 0x185a
movslq 0x57d0(%rip), %rax      # 0x7160
movl (%rsi,%rax,4), %ecx
imull %ecx, %ecx
cmpl $0x65, %ecx
jb 0x19c2
xorl %ecx, %ecx
cmpl $0x14, %eax
cmovgel %ecx, %eax
movslq %eax, %rdx
movl $0x0, (%rsi,%rdx,4)
leal 0x1(%rdx), %eax
movl 0x4(%rsi,%rdx,4), %edx
imull %edx, %edx
cmpl $0x64, %edx
ja 0x199d
movl %eax, 0x579e(%rip)      # 0x7160
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)