// File: /workspace/github_c_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r12
movl %edi, %ebx
pushq $0x1
popq %r15
movslq %r15d, %r14
cmpl %r15d, %ebx
jle 0x1408
movq (%r12,%r14,8), %rsi
cmpb $0x2d, (%rsi)
jne 0x1408
movb 0x2(%rsi), %r13b
testb %r13b, %r13b
je 0x139a
leaq 0x2(%rsi), %rdi
jmp 0x139f
movq 0x8(%r12,%r14,8), %rdi
movzbl 0x1(%rsi), %eax
cmpl $0x61, %eax
je 0x13d2
cmpl $0x66, %eax
je 0x13e1
cmpl $0x68, %eax
je 0x17c4
cmpl $0x76, %eax
je 0x188b
xorl %r14d, %r14d
leaq 0x2cd7(%rip), %rdi      # 0x40a0
xorl %eax, %eax
callq 0x18c8
jmp 0x13f1
callq 0x1090
movsd %xmm0, 0x5d79(%rip)     # 0x7158
jmp 0x13ee
callq 0x1090
movsd %xmm0, 0x5d72(%rip)     # 0x7160
movb $0x1, %r14b
testb %r13b, %r13b
sete %al
andb %r14b, %al
movzbl %al, %eax
addl %eax, %r15d
incl %r15d
jmp 0x1376
subl %r15d, %ebx
jne 0x1419
movq 0x5bc4(%rip), %rax      # 0x6fd8
movq (%rax), %rbx
jmp 0x143a
cmpl $0x2, %ebx
je 0x1446
cmpl $0x1, %ebx
jne 0x18ae
movq (%r12,%r14,8), %rdi
leaq 0x2e13(%rip), %rsi      # 0x4245
callq 0x19f8
movq %rax, %rbx
movq 0x5b8f(%rip), %rax      # 0x6fd0
movq (%rax), %rax
jmp 0x146a
movq (%r12,%r14,8), %rdi
leaq 0x2df4(%rip), %rsi      # 0x4245
callq 0x19f8
movq %rax, %rbx
movq 0x8(%r12,%r14,8), %rdi
leaq 0x2ba4(%rip), %rsi      # 0x4009
callq 0x19f8
movq %rax, -0x30(%rbp)
callq 0x1c54
movq %rax, %r15
movq %rbx, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x1fb9
cmpl $0x1, (%r15)
je 0x149b
movq (%r12), %rsi
leaq 0x2bad(%rip), %rdi      # 0x4041
xorl %eax, %eax
callq 0x18c8
leaq 0x2bbe(%rip), %rdx      # 0x4060
movq -0x30(%rbp), %rdi
movq %r15, %rsi
xorl %ecx, %ecx
callq 0x29c8
leaq 0x5cd9(%rip), %r13      # 0x7190
pushq $0x15
popq %r14
xorl %r12d, %r12d
movq %rbx, -0x40(%rbp)
movq %r15, -0x38(%rbp)
cmpl $0x0, 0x5c83(%rip)      # 0x7150
jle 0x17a2
movl 0x5c7b(%rip), %eax      # 0x7154
cmpl $-0x1, %eax
jne 0x151c
movl $0xa, 0x5c68(%rip)      # 0x7150
xorl %r14d, %r14d
cmpq $0x28, %r14
je 0x1512
movl 0x8(%r15), %edx
movq %rbx, %rdi
movq -0x30(%rbp), %rsi
leaq 0x1752(%rip), %rcx      # 0x2c55
callq 0x248e
movl %eax, (%r14,%r13)
addq $0x4, %r14
jmp 0x14eb
movl 0x5c3c(%rip), %eax      # 0x7154
pushq $0x15
popq %r14
incl %eax
movl %eax, 0x5c30(%rip)      # 0x7154
cltd
idivl %r14d
movslq %edx, %rax
movq %r15, %rcx
movl (%r13,%rax,4), %r15d
movl 0x8(%rcx), %edx
movq %rbx, %rdi
movq -0x30(%rbp), %rsi
leaq 0x1711(%rip), %rcx      # 0x2c55
callq 0x248e
movl %eax, %ecx
movl 0x5c03(%rip), %eax      # 0x7154
addl $0xa, %eax
cltd
idivl %r14d
movslq %edx, %rax
movl %ecx, (%r13,%rax,4)
movq %rbx, %rdi
callq 0x1170
testl %eax, %eax
je 0x1572
decl 0x5bde(%rip)            # 0x7150
testl %r12d, %r12d
sets %al
testl %r15d, %r15d
setg %cl
testb %cl, %al
je 0x1629
negl %r12d
movl 0x5bc5(%rip), %ecx      # 0x7154
cmpl %r12d, %r15d
jbe 0x167b
leal 0x14(%rcx), %eax
cltd
pushq $0x15
popq %r14
idivl %r14d
movslq %edx, %rax
andl $0x0, (%r13,%rax,4)
cvtsi2sd %r12d, %xmm1
movsd 0x5ba7(%rip), %xmm0     # 0x7160
mulsd %xmm0, %xmm1
leal 0x13(%rcx), %esi
leal -0x2(%rcx), %edi
pushq $0x1
popq %r8
movapd %xmm1, %xmm2
movq -0x40(%rbp), %rbx
movq -0x38(%rbp), %r15
movl %esi, %eax
xorl %edx, %edx
divl %r14d
cvttsd2si %xmm2, %eax
testl %eax, %eax
je 0x1703
cmpl $0x9, %r8d
ja 0x1703
testl %edi, %edi
js 0x1703
movl %edx, %edx
movl (%r13,%rdx,4), %r9d
testl %r9d, %r9d
je 0x1703
leal (%r9,%rax), %r10d
cmpl $0x1, %r10d
adcl %eax, %r9d
movl %r9d, (%r13,%rdx,4)
cvtsi2sd %eax, %xmm2
incl %r8d
mulsd %xmm0, %xmm2
decl %esi
decl %edi
jmp 0x15d3
movl 0x5b25(%rip), %ecx      # 0x7154
movl %r15d, %r12d
pushq $0x15
popq %r14
movq -0x40(%rbp), %rbx
movq -0x38(%rbp), %r15
cmpl $0xa, %ecx
jl 0x14c6
addl $-0xa, %ecx
movl %ecx, %eax
xorl %edx, %edx
divl %r14d
cvtsi2sdl (%r13,%rdx,4), %xmm0
mulsd 0x5af8(%rip), %xmm0     # 0x7158
cvttsd2si %xmm0, %edx
movq -0x30(%rbp), %rdi
leaq 0x2d1e(%rip), %rsi      # 0x438d
xorl %eax, %eax
callq 0x1150
jmp 0x14c6
movl %ecx, %eax
cltd
pushq $0x15
popq %r14
idivl %r14d
movslq %edx, %rax
andl $0x0, (%r13,%rax,4)
cvtsi2sd %r15d, %xmm1
movsd 0x5ac5(%rip), %xmm0     # 0x7160
mulsd %xmm0, %xmm1
leal 0x14(%rcx), %esi
leal -0x1(%rcx), %edi
pushq $0x1
popq %r8
movapd %xmm1, %xmm2
pushq $-0x1
popq %r10
movq -0x40(%rbp), %rbx
movq -0x38(%rbp), %r15
movl %esi, %eax
xorl %edx, %edx
divl %r14d
cvttsd2si %xmm2, %eax
testl %eax, %eax
je 0x1757
cmpl $0xa, %r8d
jae 0x1757
testl %edi, %edi
js 0x1757
movl %edx, %edx
movl (%r13,%rdx,4), %r9d
testl %r9d, %r9d
je 0x1757
subl %eax, %r9d
cmovel %r10d, %r9d
movl %r9d, (%r13,%rdx,4)
cvtsi2sd %eax, %xmm2
incl %r8d
mulsd %xmm0, %xmm2
decl %esi
decl %edi
jmp 0x16b9
movl %ecx, %esi
pushq $0x1
popq %rdi
cvttsd2si %xmm1, %r8d
xorl %r12d, %r12d
testl %r8d, %r8d
je 0x163e
cmpl $0x9, %edi
ja 0x163e
movl %esi, %eax
cltd
idivl %r14d
movslq %edx, %rax
movl (%r13,%rax,4), %edx
testl %edx, %edx
je 0x163e
leal (%rdx,%r8), %r9d
cmpl $0x1, %r9d
adcl %r8d, %edx
movl %edx, (%r13,%rax,4)
incl %edi
cvtsi2sd %r8d, %xmm1
mulsd %xmm0, %xmm1
incl %esi
jmp 0x1708
pushq $0x1
popq %rax
movl %eax, %esi
cvttsd2si %xmm1, %edi
xorl %r12d, %r12d
testl %edi, %edi
je 0x163e
cmpl $0x9, %esi
ja 0x163e
leal (%rcx,%rsi), %eax
cltd
idivl %r14d
movslq %edx, %rax
movl (%r13,%rax,4), %edx
testl %edx, %edx
je 0x163e
subl %edi, %edx
cmovel %r10d, %edx
movl %edx, (%r13,%rax,4)
incl %esi
cvtsi2sd %edi, %xmm1
mulsd %xmm0, %xmm1
jmp 0x175c
movq %rbx, %rdi
callq 0x10a0
movq -0x30(%rbp), %rdi
callq 0x10a0
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x28ef(%rip), %rdi      # 0x40ba
callq 0x1080
leaq 0x28e9(%rip), %rdi      # 0x40c0
callq 0x1080
leaq 0x290f(%rip), %rdi      # 0x40f2
callq 0x1080
leaq 0x2934(%rip), %rdi      # 0x4123
callq 0x1080
pushq $0xa
popq %rbx
movl %ebx, %edi
callq 0x1050
leaq 0x292e(%rip), %rdi      # 0x4133
callq 0x1080
leaq 0x2930(%rip), %rdi      # 0x4141
callq 0x1080
leaq 0x294d(%rip), %rdi      # 0x416a
callq 0x1080
movsd 0x592e(%rip), %xmm0     # 0x7158
leaq 0x284f(%rip), %rdi      # 0x4080
movb $0x1, %al
callq 0x10c0
movl %ebx, %edi
callq 0x1050
leaq 0x2957(%rip), %rdi      # 0x419d
callq 0x1080
leaq 0x2971(%rip), %rdi      # 0x41c3
callq 0x1080
leaq 0x2993(%rip), %rdi      # 0x41f1
callq 0x1080
movl %ebx, %edi
callq 0x1050
leaq 0x29a5(%rip), %rdi      # 0x4216
callq 0x1080
movl %ebx, %edi
callq 0x1050
leaq 0x29c3(%rip), %rdi      # 0x4247
callq 0x1080
jmp 0x18a7
movq 0x58ae(%rip), %rsi      # 0x7140
movq 0x58af(%rip), %rdx      # 0x7148
leaq 0x27d1(%rip), %rdi      # 0x4071
xorl %eax, %eax
callq 0x10c0
xorl %edi, %edi
callq 0x1210
movq (%r12), %rsi
leaq 0x2752(%rip), %rdi      # 0x400b
xorl %eax, %eax
callq 0x10c0
pushq $-0x1
popq %rdi
callq 0x1210