// File: /workspace/github_c_makefile_star2_O1/pipde[P]deos-songlib/utils/rra/rrastrip.c
// Function: rraStrip
void rraStrip( char* file, FILE *in, FILE *out ){
        int startFound = 0;
        int i;
        int seriesCount = 0;
        int ramped = 0;
        int rampCount = 0;
        int rampInc = 1/WINDOW_SIZE;
        RRA *track;
        if( in == NULL ){
                printf("Unable to open file %s\n", file);
                badFile = 1;
                return;
        }
        track = newRRAHeader();
        readRRAHeader( in, track, 0 );
        if( track == NULL ){
                printf("%s is not a well formed RRA file\n",file);
                badFile = 1;
                return;
        }
        if( track->channels == 2 ){
                printf("%s is a stereo RRA file, please split with rramono first.\n", file);
                badFile = 1;
                return;
        }
        for( i = 0; !feof( in ); i++){
                int amp = readRRAAmplitude(in,out,track->bitsPerSample,0);
                if( !startFound ){
                        if( amp >= AMP_MIN || amp <= ( -1 * AMP_MIN ) ){
                                seriesCount++;
                                if(seriesCount >= WINDOW_SIZE ){
                                        startFound = 1;
                                        i -= WINDOW_SIZE;
                                        track->samples = track->samples - (i + 1);
                                        writeRRAHeader( out, track, "modifiedBy: rrastrip", 0 );
                                }
                        }else{
                                
                                seriesCount = 0;
                        }
                }else{
                        if( !ramped ){
                                amp = amp * (rampCount * rampInc);
                                rampCount++;
                                if( rampCount >= WINDOW_SIZE ){
                                        ramped = 1;
                                }
                        }
                        fprintf( out, "%d\n", amp );
                }
        }
        if( !startFound ){
                printf("Found no usable amplitudes in %s. Leaving unaltered.", file );
                badFile = 1;
        }else{
                printf("%s stripped sucessfully.\n", file );
        }

        fclose( in );
        fclose( out );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, -0x40(%rbp)
movq %rdi, %rbx
testq %rsi, %rsi
je 0x15f5
movq %rsi, %r15
callq 0x1d5b
movq %rax, %r14
movq %r15, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x2168
testq %r14, %r14
je 0x15fe
cmpl $0x2, (%r14)
jne 0x1628
leaq 0x2a50(%rip), %rdi      # 0x4043
jmp 0x1605
leaq 0x2a0d(%rip), %rdi      # 0x4009
jmp 0x1605
leaq 0x2a1c(%rip), %rdi      # 0x4021
movq %rbx, %rsi
xorl %eax, %eax
callq 0x10c0
movl $0x1, 0x5b5f(%rip)      # 0x7178
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r15, %rdi
callq 0x1170
testl %eax, %eax
jne 0x174c
movq %r14, -0x48(%rbp)
movq %rbx, -0x50(%rbp)
xorl %r12d, %r12d
xorl %r13d, %r13d
movl $0x0, -0x30(%rbp)
movl $0x0, -0x2c(%rbp)
xorl %r14d, %r14d
movq -0x48(%rbp), %rax
movl 0x8(%rax), %edx
movq %r15, %rdi
movq -0x40(%rbp), %rbx
movq %rbx, %rsi
xorl %ecx, %ecx
callq 0x2654
testl %r12d, %r12d
je 0x16c3
movl -0x30(%rbp), %edi
cmpl $0x1d, %edi
setge %cl
xorl %edx, %edx
movl -0x2c(%rbp), %esi
testl %esi, %esi
sete %dl
cmovel %esi, %eax
setne %sil
orb %cl, %sil
movzbl %sil, %ecx
movl %ecx, -0x2c(%rbp)
addl %edx, %edi
movl %edi, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq %rbx, %rdi
leaq 0x2c0e(%rip), %rsi      # 0x42bd
movl %eax, %edx
xorl %eax, %eax
callq 0x1150
movl $0x1, %r12d
movl %r14d, %ebx
jmp 0x172c
movl 0x5a8f(%rip), %ecx      # 0x7158
cmpl %ecx, %eax
setl %dl
negl %ecx
cmpl %ecx, %eax
setg %al
xorl %r12d, %r12d
testb %al, %dl
je 0x16e6
movb $0x1, %al
movq %rax, -0x38(%rbp)
xorl %ebx, %ebx
jmp 0x172c
leal 0x1(%r14), %ebx
cmpl $0x1d, %r14d
jl 0x1726
movq -0x48(%rbp), %rsi
movl 0xc(%rsi), %eax
subl %r13d, %eax
addl $-0x1e, %r13d
addl $0x1d, %eax
movl %eax, 0xc(%rsi)
movq $0x0, -0x38(%rbp)
movq -0x40(%rbp), %rdi
leaq 0x2967(%rip), %rdx      # 0x407e
xorl %ecx, %ecx
callq 0x2bb9
movl $0x1, %r12d
jmp 0x172c
movb $0x1, %al
movq %rax, -0x38(%rbp)
incl %r13d
movq %r15, %rdi
callq 0x1170
movl %ebx, %r14d
testl %eax, %eax
je 0x1657
cmpb $0x0, -0x38(%rbp)
movq -0x50(%rbp), %rbx
je 0x1786
leaq 0x2940(%rip), %rdi      # 0x4093
movq %rbx, %rsi
xorl %eax, %eax
callq 0x10c0
movl $0x1, 0x5a11(%rip)      # 0x7178
movq %r15, %rdi
callq 0x1090
movq -0x40(%rbp), %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1090
leaq 0x293b(%rip), %rdi      # 0x40c8
movq %rbx, %rsi
xorl %eax, %eax
callq 0x10c0
jmp 0x1767