// File: /workspace/github_c_makefile_star2_O0/pipde[P]deos-songlib/utils/mixer/fastmixer.c
// Function: main
int
main(int argc,char **argv)
    {
    int argIndex;
    int i,j,k;
    int maxSize = 0,clips = 0;
    int inRRACount;
    int maxChannels,maxSamples,maxSkip;
    RRA *r,*rraheaders[MAX_RRAS];
    FILE *out,*rrafiles[MAX_RRAS];

    // should have at least one inputs 

    argIndex = processOptions(argc,argv);

    inRRACount = argc - argIndex;

    if (inRRACount < 1)
        {
        puts("fastmixer in.rra [more rra files ...]");
        exit(-1);
        }

    out = stdout;

    /* read in rras, keeping track of the highest sampleCount */

    maxSkip = maxChannels = maxSamples = 0;

    for (i = 0; i < inRRACount; ++i)
        {
        if (i >= MAX_RRAS)
            {
            printf(" skipping (too many input files)\n");
            continue;
            }

        if (strcmp(argv[argIndex + i],"-") == 0)
            rrafiles[i] = stdin;
        else
            rrafiles[i] = OpenFile(argv[argIndex + i],"r");

        rraheaders[i] = newRRAHeader();
        readRRAHeader(rrafiles[i],rraheaders[i],0);

        if (maxSamples < rraheaders[i]->samples)
            maxSamples = rraheaders[i]->samples;
        if (maxChannels < rraheaders[i]->channels)
            maxChannels = rraheaders[i]->channels;
        if (maxSkip < rraheaders[i]->skip)
            maxSkip = rraheaders[i]->skip;
        if (maxSize < pow(2,rraheaders[i]->bitsPerSample - 1))
            maxSize = pow(2,rraheaders[i]->bitsPerSample - 1);
            maxSkip = rraheaders[i]->skip;
        }
    if (skip != 0) maxSkip = skip;

    r = newRRAHeader();
    r->sampleRate = rraheaders[0]->sampleRate;
    r->bitsPerSample = rraheaders[0]->bitsPerSample;
    r->channels = maxChannels;
    r->samples = maxSamples - maxSkip;

    writeRRAHeader(out,r,"createdBy: fmix",0);

    for (i = 0; i < maxSamples; ++i)
        {
        for (j = 0; j < maxChannels; ++j)
            {
            int total = 0;
            for (k = 0; k < inRRACount; ++k)
                {
                if (i < rraheaders[k]->samples && j < rraheaders[k]->channels)
                    {
                    //total += readRRAAmplitude 
                                        //( rrafiles[k], rraheaders[k]->bitsPerSample, 0);
                    total += readRRAAmplitude(rrafiles[k],out,rraheaders[k]->bitsPerSample,outputComment);
                    }
                }
            if (i >= maxSkip)
                {
                int x = total * attenuation;
                fprintf(out,"%d\n",x);
                if (x > maxSize)
                    {
                    ++clips;
                    }
                }
            }
        }

    for (i = 0; i < inRRACount; ++i)
        fclose(rrafiles[i]);

    fprintf(stderr,"%s clip: %d\n",argv[0],clips);
    return 0;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1a0, %rsp            # imm = 0x1A0
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x0, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
callq 0x2800
movl %eax, -0x14(%rbp)
movl -0x8(%rbp), %eax
subl -0x14(%rbp), %eax
movl %eax, -0x2c(%rbp)
cmpl $0x1, -0x2c(%rbp)
jge 0x242b
leaq 0x9c93(%rip), %rdi      # 0xc0af
callq 0x2070
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x2280
movq 0xdb9e(%rip), %rax      # 0xffd0
movq (%rax), %rax
movq %rax, -0xe8(%rbp)
movl $0x0, -0x34(%rbp)
movl $0x0, -0x30(%rbp)
movl $0x0, -0x38(%rbp)
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x2610
cmpl $0x14, -0x18(%rbp)
jl 0x247d
leaq 0x9c64(%rip), %rdi      # 0xc0d5
movb $0x0, %al
callq 0x20d0
jmp 0x2602
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
addl -0x18(%rbp), %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x9c62(%rip), %rsi      # 0xc0f7
callq 0x2180
cmpl $0x0, %eax
jne 0x24b7
movq 0xdb32(%rip), %rax      # 0xffd8
movq (%rax), %rcx
movslq -0x18(%rbp), %rax
movq %rcx, -0x190(%rbp,%rax,8)
jmp 0x24e3
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
addl -0x18(%rbp), %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x9bd9(%rip), %rsi      # 0xc0a8
callq 0x8ce0
movq %rax, %rcx
movslq -0x18(%rbp), %rax
movq %rcx, -0x190(%rbp,%rax,8)
callq 0x91c0
movq %rax, %rcx
movslq -0x18(%rbp), %rax
movq %rcx, -0xe0(%rbp,%rax,8)
movslq -0x18(%rbp), %rax
movq -0x190(%rbp,%rax,8), %rdi
movslq -0x18(%rbp), %rax
movq -0xe0(%rbp,%rax,8), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x96c0
movl -0x34(%rbp), %eax
movslq -0x18(%rbp), %rcx
movq -0xe0(%rbp,%rcx,8), %rcx
cmpl 0xc(%rcx), %eax
jge 0x253e
movslq -0x18(%rbp), %rax
movq -0xe0(%rbp,%rax,8), %rax
movl 0xc(%rax), %eax
movl %eax, -0x34(%rbp)
movl -0x30(%rbp), %eax
movslq -0x18(%rbp), %rcx
movq -0xe0(%rbp,%rcx,8), %rcx
cmpl (%rcx), %eax
jge 0x2562
movslq -0x18(%rbp), %rax
movq -0xe0(%rbp,%rax,8), %rax
movl (%rax), %eax
movl %eax, -0x30(%rbp)
movl -0x38(%rbp), %eax
movslq -0x18(%rbp), %rcx
movq -0xe0(%rbp,%rcx,8), %rcx
cmpl 0x10(%rcx), %eax
jge 0x2588
movslq -0x18(%rbp), %rax
movq -0xe0(%rbp,%rax,8), %rax
movl 0x10(%rax), %eax
movl %eax, -0x38(%rbp)
cvtsi2sdl -0x24(%rbp), %xmm0
movsd %xmm0, -0x1a0(%rbp)
movslq -0x18(%rbp), %rax
movq -0xe0(%rbp,%rax,8), %rax
movl 0x8(%rax), %eax
subl $0x1, %eax
cvtsi2sd %eax, %xmm1
movsd 0x9a55(%rip), %xmm0     # 0xc008
callq 0x2090
movsd -0x1a0(%rbp), %xmm1
ucomisd %xmm1, %xmm0
jbe 0x25f0
movslq -0x18(%rbp), %rax
movq -0xe0(%rbp,%rax,8), %rax
movl 0x8(%rax), %eax
subl $0x1, %eax
cvtsi2sd %eax, %xmm1
movsd 0x9a24(%rip), %xmm0     # 0xc008
callq 0x2090
cvttsd2si %xmm0, %eax
movl %eax, -0x24(%rbp)
movslq -0x18(%rbp), %rax
movq -0xe0(%rbp,%rax,8), %rax
movl 0x10(%rax), %eax
movl %eax, -0x38(%rbp)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x2458
cmpl $0x0, 0xddfd(%rip)      # 0x10414
je 0x2622
movl 0xddf5(%rip), %eax      # 0x10414
movl %eax, -0x38(%rbp)
callq 0x91c0
movq %rax, -0x40(%rbp)
movq -0xe0(%rbp), %rax
movl 0x4(%rax), %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0xe0(%rbp), %rax
movl 0x8(%rax), %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x8(%rax)
movl -0x30(%rbp), %ecx
movq -0x40(%rbp), %rax
movl %ecx, (%rax)
movl -0x34(%rbp), %ecx
subl -0x38(%rbp), %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0xe8(%rbp), %rdi
movq -0x40(%rbp), %rsi
leaq 0x9a84(%rip), %rdx      # 0xc0f9
xorl %eax, %eax
movl %eax, %ecx
callq 0xa660
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x34(%rbp), %eax
jge 0x279e
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x30(%rbp), %eax
jge 0x278e
movl $0x0, -0x194(%rbp)
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x272b
movl -0x18(%rbp), %eax
movslq -0x20(%rbp), %rcx
movq -0xe0(%rbp,%rcx,8), %rcx
cmpl 0xc(%rcx), %eax
jge 0x271e
movl -0x1c(%rbp), %eax
movslq -0x20(%rbp), %rcx
movq -0xe0(%rbp,%rcx,8), %rcx
cmpl (%rcx), %eax
jge 0x271e
movslq -0x20(%rbp), %rax
movq -0x190(%rbp,%rax,8), %rdi
movq -0xe8(%rbp), %rsi
movslq -0x20(%rbp), %rax
movq -0xe0(%rbp,%rax,8), %rax
movl 0x8(%rax), %edx
leaq 0x8393(%rip), %rcx      # 0xaaa0
callq 0x9df0
addl -0x194(%rbp), %eax
movl %eax, -0x194(%rbp)
jmp 0x2720
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x26b5
movl -0x18(%rbp), %eax
cmpl -0x38(%rbp), %eax
jl 0x277e
cvtsi2sdl -0x194(%rbp), %xmm0
mulsd 0xda4d(%rip), %xmm0     # 0x10190
cvttsd2si %xmm0, %eax
movl %eax, -0x198(%rbp)
movq -0xe8(%rbp), %rdi
movl -0x198(%rbp), %edx
leaq 0x9efc(%rip), %rsi      # 0xc65d
movb $0x0, %al
callq 0x21a0
movl -0x198(%rbp), %eax
cmpl -0x24(%rbp), %eax
jle 0x277c
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x277e
jmp 0x2780
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x2698
jmp 0x2790
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x2685
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x27c9
movslq -0x18(%rbp), %rax
movq -0x190(%rbp,%rax,8), %rdi
callq 0x20a0
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x27a5
movq 0xd828(%rip), %rax      # 0xfff8
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rdx
movl -0x28(%rbp), %ecx
leaq 0x9925(%rip), %rsi      # 0xc109
movb $0x0, %al
callq 0x21a0
xorl %eax, %eax
addq $0x1a0, %rsp            # imm = 0x1A0
popq %rbp
retq
nopw %cs:(%rax,%rax)