// File: /workspace/github_c_makefile_star2_O2/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 %rdx, %rbx
movq %rsi, %r14
movq %rdi, -0x48(%rbp)
movl 0x5bc8(%rip), %eax      # 0x7170
movq %rsp, %rsi
leaq 0xf(,%rax,4), %rax
andq $-0x10, %rax
subq %rax, %rsi
movq %rsi, %rsp
xorl %r15d, %r15d
xorl %eax, %eax
movq %rsi, -0x38(%rbp)
cmpl 0xc(%rbx), %eax
jge 0x16e4
movl %eax, -0x2c(%rbp)
movslq %r15d, %r13
leaq (%rsi,%r13,4), %rax
movq %rax, -0x40(%rbp)
xorl %r12d, %r12d
leaq (%r12,%r13), %r15
cmpl (%rbx), %r12d
jge 0x16d6
movl 0x8(%rbx), %edx
movq -0x48(%rbp), %rdi
movq %r14, %rsi
leaq 0x14af(%rip), %rcx      # 0x2aad
callq 0x22e6
movslq 0x5b66(%rip), %rcx      # 0x7170
cmpq %rcx, %r15
jge 0x161f
movq -0x40(%rbp), %rcx
movl %eax, (%rcx,%r12,4)
movl 0x5b47(%rip), %ecx      # 0x7164
jmp 0x165a
movl 0x5b3b(%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 0x5b25(%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, 0x5b08(%rip)      # 0x7160
movl %esi, %eax
movl %eax, %edx
negl %edx
cmovsl %eax, %edx
movl 0x5b01(%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 0x16b4
movl %ecx, %edx
negl %edx
cmpl %edx, %eax
jle 0x16b6
cvtsi2sd %ecx, %xmm0
cvtsi2sd %eax, %xmm1
divsd %xmm0, %xmm1
movapd %xmm1, %xmm2
mulsd %xmm1, %xmm2
mulsd %xmm1, %xmm2
divsd 0x2972(%rip), %xmm2     # 0x4018
addsd %xmm1, %xmm2
mulsd %xmm0, %xmm2
cvttsd2si %xmm2, %edx
jmp 0x16b6
movl %ecx, %edx
imull 0x5ab7(%rip), %edx      # 0x7174
movq %r14, %rdi
leaq 0x2b5e(%rip), %rsi      # 0x4225
xorl %eax, %eax
callq 0x1140
incq %r12
jmp 0x15e0
movl -0x2c(%rbp), %eax
incl %eax
movq -0x38(%rbp), %rsi
jmp 0x15c6
movl 0x5a76(%rip), %eax      # 0x7160
xorl %ecx, %ecx
movslq %eax, %rdx
movl (%rsi,%rdx,4), %edx
imull %edx, %edx
cmpl $0x65, %edx
jb 0x1710
cmpl $0x14, %eax
cmovgel %ecx, %eax
cltq
andl $0x0, (%rsi,%rax,4)
incl %eax
movl %eax, 0x5a52(%rip)      # 0x7160
jmp 0x16ec
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop