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

    int i,j,channels;
    char *inFile;
    FILE *in,*out;
    RRA *track;

    argIndex = processOptions(argc,argv);

    if (argc-argIndex == 0)
        {
        in = stdin;
        out = stdout;
        inFile = "stdin";
        }
    else if (argc-argIndex == 1)
        {
        in = OpenFile(argv[argIndex],"r");
        out = stdout;
        inFile = argv[argIndex];
        }
    else if (argc-argIndex == 2)
        {
        in = OpenFile(argv[argIndex],"r");
        out = OpenFile(argv[argIndex+1],"w");
        inFile = argv[argIndex];
        }
    else
        {
        printf("usage: rramono [-aNN.N] [-dNN.N] [-l] [-r] "
            "[<input wave> [<output wave>]]\n");
        exit(-1);
        }

    track = newRRAHeader();
    readRRAHeader(in,track,0);

    if (track->channels == 1)
        {
        fprintf(stderr, "%s is already a mono track\n", inFile);
        Channel = -1;
        }

    if (Channel >= track->channels)
        Fatal("mono: bad channel: %d\n",Channel);

    channels = track->channels;
    trackChannel = track->channels;
    track->channels = 1;
    setAttributeRRA(track,"channels","1");

    writeRRAHeader(out,track,"modifiedBy: mono",0);

    for (i = 0; !feof(in); ++i)
        {
        int total = 0;
        for (j = 0; j < channels; ++j)
            {

            int amp =
                readRRAAmplitude(in,out,track->bitsPerSample,commentHandler);

            if (j == Channel || Channel == -1)
                total += amp;
            }
        fprintf(out,"%d\n",(int)(total * AmpFactor));
        }

    if (i != track->samples)
        fprintf(stderr,"WARNING: %d samples found, %d expected\n",
            i,track->samples);

    fclose(in);
    fclose(out);

    return 0;

    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x1, -0x14(%rbp)
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
callq 0x1680
movl %eax, -0x14(%rbp)
movl -0x8(%rbp), %eax
subl -0x14(%rbp), %eax
cmpl $0x0, %eax
jne 0x1403
movq 0x6bfa(%rip), %rax      # 0x7fd8
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movq 0x6be4(%rip), %rax      # 0x7fd0
movq (%rax), %rax
movq %rax, -0x38(%rbp)
leaq 0x3c6a(%rip), %rax      # 0x5064
movq %rax, -0x28(%rbp)
jmp 0x14c0
movl -0x8(%rbp), %eax
subl -0x14(%rbp), %eax
cmpl $0x1, %eax
jne 0x144a
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x42f3(%rip), %rsi      # 0x5714
callq 0x1b40
movq %rax, -0x30(%rbp)
movq 0x6b9f(%rip), %rax      # 0x7fd0
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x28(%rbp)
jmp 0x14be
movl -0x8(%rbp), %eax
subl -0x14(%rbp), %eax
cmpl $0x2, %eax
jne 0x14a4
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x42ac(%rip), %rsi      # 0x5714
callq 0x1b40
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x3be1(%rip), %rsi      # 0x506a
callq 0x1b40
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x28(%rbp)
jmp 0x14bc
leaq 0x3bc1(%rip), %rdi      # 0x506c
movb $0x0, %al
callq 0x1090
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x11e0
jmp 0x14be
jmp 0x14c0
callq 0x2020
movq %rax, -0x40(%rbp)
movq -0x30(%rbp), %rdi
movq -0x40(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x2520
movq -0x40(%rbp), %rax
cmpl $0x1, (%rax)
jne 0x1509
movq 0x6b0e(%rip), %rax      # 0x7ff8
movq (%rax), %rdi
movq -0x28(%rbp), %rdx
leaq 0x3bbf(%rip), %rsi      # 0x50b7
movb $0x0, %al
callq 0x1110
movl $0xffffffff, 0x6c27(%rip) # imm = 0xFFFFFFFF
movl 0x6c21(%rip), %eax      # 0x8130
movq -0x40(%rbp), %rcx
cmpl (%rcx), %eax
jl 0x152b
movl 0x6c13(%rip), %esi      # 0x8130
leaq 0x3baf(%rip), %rdi      # 0x50d3
movb $0x0, %al
callq 0x19f0
movq -0x40(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x20(%rbp)
movq -0x40(%rbp), %rax
movl (%rax), %eax
movl %eax, 0x6bf4(%rip)      # 0x8134
movq -0x40(%rbp), %rax
movl $0x1, (%rax)
movq -0x40(%rbp), %rdi
leaq 0x3b95(%rip), %rsi      # 0x50ea
leaq 0x3b03(%rip), %rdx      # 0x505f
callq 0x2bd0
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
leaq 0x3b83(%rip), %rdx      # 0x50f3
xorl %eax, %eax
movl %eax, %ecx
callq 0x34c0
movl $0x0, -0x18(%rbp)
movq -0x30(%rbp), %rdi
callq 0x1130
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x159a
jmp 0x1629
movl $0x0, -0x44(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x15f8
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x40(%rbp), %rax
movl 0x8(%rax), %edx
leaq 0x2da(%rip), %rcx       # 0x18a0
callq 0x2c50
movl %eax, -0x48(%rbp)
movl -0x1c(%rbp), %eax
cmpl 0x6b59(%rip), %eax      # 0x8130
je 0x15e2
cmpl $-0x1, 0x6b50(%rip)     # 0x8130
jne 0x15eb
movl -0x48(%rbp), %eax
addl -0x44(%rbp), %eax
movl %eax, -0x44(%rbp)
jmp 0x15ed
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x15a8
movq -0x38(%rbp), %rdi
cvtsi2sdl -0x44(%rbp), %xmm0
mulsd 0x6b2f(%rip), %xmm0     # 0x8138
cvttsd2si %xmm0, %edx
leaq 0x3da1(%rip), %rsi      # 0x53b5
movb $0x0, %al
callq 0x1110
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x1580
movl -0x18(%rbp), %eax
movq -0x40(%rbp), %rcx
cmpl 0xc(%rcx), %eax
je 0x1657
movq 0x69bc(%rip), %rax      # 0x7ff8
movq (%rax), %rdi
movl -0x18(%rbp), %edx
movq -0x40(%rbp), %rax
movl 0xc(%rax), %ecx
leaq 0x3ab4(%rip), %rsi      # 0x5104
movb $0x0, %al
callq 0x1110
movq -0x30(%rbp), %rdi
callq 0x1070
movq -0x38(%rbp), %rdi
callq 0x1070
xorl %eax, %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)