// File: /workspace/github_c_makefile_star2_O0/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
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x138f
movq -0x8(%rbp), %rsi
leaq 0x3c90(%rip), %rdi      # 0x5009
movb $0x0, %al
callq 0x10a0
movl $0x1, 0x6dce(%rip)      # 0x8158
jmp 0x154c
callq 0x1ff0
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x24f0
cmpq $0x0, -0x38(%rbp)
jne 0x13d1
movq -0x8(%rbp), %rsi
leaq 0x3c66(%rip), %rdi      # 0x5021
movb $0x0, %al
callq 0x10a0
movl $0x1, 0x6d8c(%rip)      # 0x8158
jmp 0x154c
movq -0x38(%rbp), %rax
cmpl $0x2, (%rax)
jne 0x13fb
movq -0x8(%rbp), %rsi
leaq 0x3c5e(%rip), %rdi      # 0x5043
movb $0x0, %al
callq 0x10a0
movl $0x1, 0x6d62(%rip)      # 0x8158
jmp 0x154c
movl $0x0, -0x20(%rbp)
movq -0x10(%rbp), %rdi
callq 0x1140
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x141c
jmp 0x1504
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x38(%rbp), %rax
movl 0x8(%rax), %edx
xorl %eax, %eax
movl %eax, %ecx
callq 0x2c20
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jne 0x14b1
movl -0x3c(%rbp), %eax
cmpl 0x6cf2(%rip), %eax      # 0x8138
jge 0x1459
movl -0x3c(%rbp), %eax
imull $0xffffffff, 0x6ce3(%rip), %ecx # imm = 0xFFFFFFFF
cmpl %ecx, %eax
jg 0x14a8
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
cmpl $0x1e, -0x24(%rbp)
jl 0x14a6
movl $0x1, -0x1c(%rbp)
movl -0x20(%rbp), %eax
subl $0x1e, %eax
movl %eax, -0x20(%rbp)
movq -0x38(%rbp), %rax
movl 0xc(%rax), %ecx
movl -0x20(%rbp), %eax
addl $0x1, %eax
subl %eax, %ecx
movq -0x38(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x18(%rbp), %rdi
movq -0x38(%rbp), %rsi
leaq 0x3be1(%rip), %rdx      # 0x507e
xorl %eax, %eax
movl %eax, %ecx
callq 0x3490
jmp 0x14af
movl $0x0, -0x24(%rbp)
jmp 0x14f4
cmpl $0x0, -0x28(%rbp)
jne 0x14df
movl -0x3c(%rbp), %eax
movl -0x2c(%rbp), %ecx
imull -0x30(%rbp), %ecx
imull %ecx, %eax
movl %eax, -0x3c(%rbp)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
cmpl $0x1e, -0x2c(%rbp)
jl 0x14dd
movl $0x1, -0x28(%rbp)
jmp 0x14df
movq -0x18(%rbp), %rdi
movl -0x3c(%rbp), %edx
leaq 0x3da8(%rip), %rsi      # 0x5295
movb $0x0, %al
callq 0x1120
jmp 0x14f6
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x1402
cmpl $0x0, -0x1c(%rbp)
jne 0x1528
movq -0x8(%rbp), %rsi
leaq 0x3b7e(%rip), %rdi      # 0x5093
movb $0x0, %al
callq 0x10a0
movl $0x1, 0x6c32(%rip)      # 0x8158
jmp 0x153a
movq -0x8(%rbp), %rsi
leaq 0x3b95(%rip), %rdi      # 0x50c8
movb $0x0, %al
callq 0x10a0
movq -0x10(%rbp), %rdi
callq 0x1070
movq -0x18(%rbp), %rdi
callq 0x1070
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)