// File: /workspace/github_c_makefile_star2_O2/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 %rdi, %rbx
testq %rsi, %rsi
je 0x13b4
movq %rdx, %r13
movq %rsi, %r14
callq 0x1b40
movq %rax, %r15
movq %r14, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x1ea5
testq %r15, %r15
je 0x13bd
cmpl $0x2, (%r15)
jne 0x13e7
leaq 0x2c91(%rip), %rdi      # 0x4043
jmp 0x13c4
leaq 0x2c4e(%rip), %rdi      # 0x4009
jmp 0x13c4
leaq 0x2c5d(%rip), %rdi      # 0x4021
movq %rbx, %rsi
xorl %eax, %eax
callq 0x10c0
movl $0x1, 0x5da0(%rip)      # 0x7178
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r15, -0x48(%rbp)
movq %r14, -0x38(%rbp)
movq %rbx, -0x40(%rbp)
xorl %r12d, %r12d
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
xorl %ebx, %ebx
xorl %r15d, %r15d
movq %r13, -0x50(%rbp)
movq -0x38(%rbp), %r14
movq %r14, %rdi
callq 0x1170
testl %eax, %eax
jne 0x14dc
movq -0x48(%rbp), %rax
movl 0x8(%rax), %edx
movq %r14, %rdi
movq %r13, %rsi
xorl %ecx, %ecx
callq 0x237a
testl %r15d, %r15d
je 0x147f
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 %r13, %rdi
leaq 0x2e50(%rip), %rsi      # 0x42bd
movl %eax, %edx
xorl %eax, %eax
callq 0x1150
movl %r12d, %r13d
pushq $0x1
popq %r15
jmp 0x14ce
movl 0x5cd3(%rip), %ecx      # 0x7158
cmpl %ecx, %eax
setl %dl
negl %ecx
cmpl %ecx, %eax
setg %al
xorl %r15d, %r15d
testb %al, %dl
je 0x149d
xorl %r13d, %r13d
jmp 0x14ce
leal 0x1(%r12), %r13d
cmpl $0x1d, %r12d
jl 0x14ce
movq -0x48(%rbp), %rsi
movl 0xc(%rsi), %eax
subl %ebx, %eax
addl $-0x1e, %ebx
addl $0x1d, %eax
movl %eax, 0xc(%rsi)
movq -0x50(%rbp), %rdi
leaq 0x2bb9(%rip), %rdx      # 0x407e
xorl %ecx, %ecx
callq 0x28b4
jmp 0x1479
incl %ebx
movl %r13d, %r12d
movq -0x50(%rbp), %r13
jmp 0x1411
testl %r15d, %r15d
je 0x14f5
leaq 0x2be0(%rip), %rdi      # 0x40c8
movq -0x40(%rbp), %rsi
xorl %eax, %eax
callq 0x10c0
jmp 0x1511
leaq 0x2b97(%rip), %rdi      # 0x4093
movq -0x40(%rbp), %rsi
xorl %eax, %eax
callq 0x10c0
movl $0x1, 0x5c67(%rip)      # 0x7178
movq -0x38(%rbp), %rdi
callq 0x1090
movq %r13, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1090