// File: /workspace/github_c_makefile_star2_O0/pipde[P]deos-songlib/utils/distort2/distort2.c
// Function: main
int
main(int argc,char **argv)
    {
    int argIndex = 1;

    int old;
    FILE *in,*out;
    RRA *r;

    level = 20000;
    sign = 0;
    direction = 0;
    delaySize = 1;
    argIndex = processOptions(argc,argv);

    if (argc-argIndex == 0)
        {
        in = stdin;
        out = stdout;
        }
    else if (argc-argIndex == 1)
        {
        in = OpenFile(argv[argIndex],"r");
        out = stdout;
        }
    else if (argc-argIndex == 2)
        {
        in = OpenFile(argv[argIndex],"r");
        out = OpenFile(argv[argIndex+1],"w");
        }
    else
        {
        printf("usage: filter [<input rra file> [<output wave file>]]\n");
        exit(-1);
        }

    r = newRRAHeader();
    readRRAHeader(in, r, 0);
    
    if (r->channels != 1)
        Fatal("distorter only works on mono audio files\n");

    factor = ((int)pow(2,r->bitsPerSample - 1)/level) / 3;
    if (level >= 20000) {
        factor = 1;
    }

    /* compute new number of samples, saving the old number */
    old = r->samples;
    r->samples = (int) (r->samples / step);

    writeRRAHeader(out,r,"modifiedBy: rraDistorter",0);

    /* restore the old number */
    r->samples = old;

    processData(in,out,r);

    fclose(in);
    fclose(out);

    return 0;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x1, -0x14(%rbp)
movl $0x4e20, 0x6e15(%rip)   # imm = 0x4E20
movl $0x0, 0x6e0f(%rip)      # 0x8150
movl $0x0, 0x6e09(%rip)      # 0x8154
movl $0x1, 0x6e03(%rip)      # 0x8158
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
callq 0x1520
movl %eax, -0x14(%rbp)
movl -0x8(%rbp), %eax
subl -0x14(%rbp), %eax
cmpl $0x0, %eax
jne 0x1390
movq 0x6c62(%rip), %rax      # 0x7fd8
movq (%rax), %rax
movq %rax, -0x20(%rbp)
movq 0x6c4c(%rip), %rax      # 0x7fd0
movq (%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0x142d
movl -0x8(%rbp), %eax
subl -0x14(%rbp), %eax
cmpl $0x1, %eax
jne 0x13c7
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x3cbb(%rip), %rsi      # 0x5069
callq 0x1ac0
movq %rax, -0x20(%rbp)
movq 0x6c12(%rip), %rax      # 0x7fd0
movq (%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0x142b
movl -0x8(%rbp), %eax
subl -0x14(%rbp), %eax
cmpl $0x2, %eax
jne 0x1411
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x3c84(%rip), %rsi      # 0x5069
callq 0x1ac0
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x3c6a(%rip), %rsi      # 0x5070
callq 0x1ac0
movq %rax, -0x28(%rbp)
jmp 0x1429
leaq 0x3c5a(%rip), %rdi      # 0x5072
movb $0x0, %al
callq 0x1090
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x11d0
jmp 0x142b
jmp 0x142d
callq 0x1fa0
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rdi
movq -0x30(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x24a0
movq -0x30(%rbp), %rax
cmpl $0x1, (%rax)
je 0x145e
leaq 0x3c52(%rip), %rdi      # 0x50a9
movb $0x0, %al
callq 0x1970
movq -0x30(%rbp), %rax
movl 0x8(%rax), %eax
subl $0x1, %eax
cvtsi2sd %eax, %xmm1
movsd 0x3b94(%rip), %xmm0     # 0x5008
callq 0x1060
cvttsd2si %xmm0, %eax
cltd
idivl 0x6cc8(%rip)            # 0x814c
movl $0x3, %ecx
cltd
idivl %ecx
movl %eax, 0x6cca(%rip)      # 0x815c
cmpl $0x4e20, 0x6cb0(%rip)   # imm = 0x4E20
jl 0x14a8
movl $0x1, 0x6cb4(%rip)      # 0x815c
movq -0x30(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x18(%rbp)
movq -0x30(%rbp), %rax
cvtsi2sdl 0xc(%rax), %xmm0
divsd 0x6c65(%rip), %xmm0     # 0x8128
cvttsd2si %xmm0, %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
leaq 0x3bf6(%rip), %rdx      # 0x50d3
xorl %eax, %eax
movl %eax, %ecx
callq 0x3440
movl -0x18(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0x16b0
movq -0x20(%rbp), %rdi
callq 0x1070
movq -0x28(%rbp), %rdi
callq 0x1070
xorl %eax, %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)