// File: /workspace/github_c_makefile_star2_O3/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 0x1625
movq %rsi, %r15
callq 0x1d7f
movq %rax, %r14
movq %r15, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x21a5
testq %r14, %r14
je 0x162e
cmpl $0x2, (%r14)
jne 0x1658
leaq 0x2a20(%rip), %rdi      # 0x4043
jmp 0x1635
leaq 0x29dd(%rip), %rdi      # 0x4009
jmp 0x1635
leaq 0x29ec(%rip), %rdi      # 0x4021
movq %rbx, %rsi
xorl %eax, %eax
callq 0x10c0
movl $0x1, 0x5b2f(%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 0x177c
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 0x26a8
testl %r12d, %r12d
je 0x16f3
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 0x2bde(%rip), %rsi      # 0x42bd
movl %eax, %edx
xorl %eax, %eax
callq 0x1150
movl $0x1, %r12d
movl %r14d, %ebx
jmp 0x175c
movl 0x5a5f(%rip), %ecx      # 0x7158
cmpl %ecx, %eax
setl %dl
negl %ecx
cmpl %ecx, %eax
setg %al
xorl %r12d, %r12d
testb %al, %dl
je 0x1716
movb $0x1, %al
movq %rax, -0x38(%rbp)
xorl %ebx, %ebx
jmp 0x175c
leal 0x1(%r14), %ebx
cmpl $0x1d, %r14d
jl 0x1756
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 0x2937(%rip), %rdx      # 0x407e
xorl %ecx, %ecx
callq 0x2c40
movl $0x1, %r12d
jmp 0x175c
movb $0x1, %al
movq %rax, -0x38(%rbp)
incl %r13d
movq %r15, %rdi
callq 0x1170
movl %ebx, %r14d
testl %eax, %eax
je 0x1687
cmpb $0x0, -0x38(%rbp)
movq -0x50(%rbp), %rbx
je 0x17b6
leaq 0x2910(%rip), %rdi      # 0x4093
movq %rbx, %rsi
xorl %eax, %eax
callq 0x10c0
movl $0x1, 0x59e1(%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 0x290b(%rip), %rdi      # 0x40c8
movq %rbx, %rsi
xorl %eax, %eax
callq 0x10c0
jmp 0x1797