// File: /workspace/github_c_makefile_star2_O1/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 0x5979(%rip), %eax      # 0x7170
movq %rsp, %rsi
leaq 0xf(,%rax,4), %rax
andq $-0x10, %rax
subq %rax, %rsi
movq %rsi, %rsp
cmpl $0x0, 0xc(%rdx)
jle 0x1954
movq %rdx, %rbx
xorl %eax, %eax
xorl %ecx, %ecx
movq %rsi, -0x38(%rbp)
cmpl $0x0, (%rbx)
jle 0x1949
movl %eax, -0x30(%rbp)
movl %ecx, -0x2c(%rbp)
movslq %ecx, %r12
leaq (%rsi,%r12,4), %rax
movq %rax, -0x40(%rbp)
xorl %r13d, %r13d
leaq (%r12,%r13), %r15
movl 0x8(%rbx), %edx
movq -0x48(%rbp), %rdi
movq %r14, %rsi
leaq 0x158a(%rip), %rcx      # 0x2ddd
callq 0x25ac
movslq 0x5911(%rip), %rcx      # 0x7170
cmpq %rcx, %r15
jge 0x186e
movq -0x40(%rbp), %rcx
movl %eax, (%rcx,%r13,4)
jmp 0x18b0
cmpl %ecx, 0x58ec(%rip)      # 0x7160
jl 0x1880
movl $0x0, 0x58e0(%rip)      # 0x7160
movslq 0x58d9(%rip), %rcx      # 0x7160
movq -0x38(%rbp), %rdi
addl (%rdi,%rcx,4), %eax
movl 0x58d0(%rip), %edx      # 0x7164
movl %edx, %esi
negl %esi
cmpl %esi, %eax
cmovgl %eax, %esi
cmpl %edx, %eax
cmovgel %edx, %esi
movl %esi, (%rdi,%rcx,4)
leal 0x1(%rcx), %eax
movl %eax, 0x58b2(%rip)      # 0x7160
movl %esi, %eax
movl 0x58b2(%rip), %ecx      # 0x7168
movl %eax, %edx
negl %edx
cmovsl %eax, %edx
cmpl $0x1, %ecx
cmovnel %eax, %edx
movl %edx, %eax
negl %eax
cmovnsl %edx, %eax
cmpl $0x2, %ecx
cmovnel %edx, %eax
movl 0x588e(%rip), %ecx      # 0x7164
cmpl %ecx, %eax
jge 0x1916
movl %ecx, %edx
negl %edx
cmpl %edx, %eax
jle 0x1918
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 0x2710(%rip), %xmm2     # 0x4018
addsd %xmm1, %xmm2
mulsd %xmm0, %xmm2
cvttsd2si %xmm2, %edx
jmp 0x1918
movl %ecx, %edx
imull 0x5855(%rip), %edx      # 0x7174
movq %r14, %rdi
leaq 0x28fc(%rip), %rsi      # 0x4225
xorl %eax, %eax
callq 0x1140
incq %r13
cmpl (%rbx), %r13d
jl 0x183e
movl -0x2c(%rbp), %ecx
addl %r13d, %ecx
movq -0x38(%rbp), %rsi
movl -0x30(%rbp), %eax
incl %eax
cmpl 0xc(%rbx), %eax
jl 0x1821
movslq 0x5805(%rip), %rax      # 0x7160
movl (%rsi,%rax,4), %ecx
imull %ecx, %ecx
cmpl $0x65, %ecx
jb 0x198d
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 0x1968
movl %eax, 0x57d3(%rip)      # 0x7160
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq