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

    FILE *in,*out;
    RRA *h;

    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: %s -fN [<input rra file> [<output rra file>]]\n",
            argv[0]);
        exit(-1);
        }

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

    if (h->channels != 1)
        Fatal("%s requires a mono audio file\n",argv[0]);

    writeRRAHeader(out,h,"modifiedBy: zero",0);

    int curr = 0;
    int prev;
    int i = 0;
    while (Remaining > 0)
        {
        prev = curr;
        curr = readAmplitude(in,out,h);
        if (prev < 0 && curr > 0)
            {
            //fprintf(stderr,"crossing up at %d\n",i);
            if (abs(prev) < curr)
                adjustPrevious(-prev);
            else
                adjustCurrent(curr);
            curr = 0;
            }
        writeAmplitude(out,h);
        ++i;
        }

    fclose(in);
    fclose(out);

    return 0;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %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 0x1500
movl %eax, -0x14(%rbp)
movl -0x8(%rbp), %eax
subl -0x14(%rbp), %eax
cmpl $0x0, %eax
jne 0x1368
movq 0x6c8a(%rip), %rax      # 0x7fd8
movq (%rax), %rax
movq %rax, -0x20(%rbp)
movq 0x6c74(%rip), %rax      # 0x7fd0
movq (%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0x140c
movl -0x8(%rbp), %eax
subl -0x14(%rbp), %eax
cmpl $0x1, %eax
jne 0x139f
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x43aa(%rip), %rsi      # 0x5730
callq 0x1ee0
movq %rax, -0x20(%rbp)
movq 0x6c3a(%rip), %rax      # 0x7fd0
movq (%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0x140a
movl -0x8(%rbp), %eax
subl -0x14(%rbp), %eax
cmpl $0x2, %eax
jne 0x13e9
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x4373(%rip), %rsi      # 0x5730
callq 0x1ee0
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x3c83(%rip), %rsi      # 0x5061
callq 0x1ee0
movq %rax, -0x28(%rbp)
jmp 0x1408
movq -0x10(%rbp), %rax
movq (%rax), %rsi
leaq 0x3c6c(%rip), %rdi      # 0x5063
movb $0x0, %al
callq 0x1090
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x11d0
jmp 0x140a
jmp 0x140c
callq 0x23c0
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rdi
movq -0x30(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x28c0
movq -0x30(%rbp), %rax
cmpl $0x1, (%rax)
je 0x1444
movq -0x10(%rbp), %rax
movq (%rax), %rsi
leaq 0x3c5c(%rip), %rdi      # 0x5099
movb $0x0, %al
callq 0x1d90
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
leaq 0x3c65(%rip), %rdx      # 0x50b8
xorl %eax, %eax
movl %eax, %ecx
callq 0x3860
movl $0x0, -0x34(%rbp)
movl $0x0, -0x3c(%rbp)
cmpl $0x0, 0x6cb7(%rip)      # 0x8128
jle 0x14db
movl -0x34(%rbp), %eax
movl %eax, -0x38(%rbp)
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0x1780
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x38(%rbp)
jge 0x14c3
cmpl $0x0, -0x34(%rbp)
jle 0x14c3
movl -0x38(%rbp), %eax
movl %eax, %ecx
negl %ecx
cmovnsl %ecx, %eax
cmpl -0x34(%rbp), %eax
jge 0x14b4
xorl %edi, %edi
subl -0x38(%rbp), %edi
callq 0x1880
jmp 0x14bc
movl -0x34(%rbp), %edi
callq 0x1ae0
movl $0x0, -0x34(%rbp)
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x1d20
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x146a
movq -0x20(%rbp), %rdi
callq 0x1070
movq -0x28(%rbp), %rdi
callq 0x1070
xorl %eax, %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)