// File: /workspace/github_c_makefile_star2_O1/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
pushq %rax
movq %rsi, %r12
movl %edi, %ebx
movl $0x1, %r15d
cmpl $0x2, %edi
jl 0x165a
movl $0x1, %r15d
movslq %r15d, %rax
movq (%r12,%rax,8), %rsi
cmpb $0x2d, (%rsi)
jne 0x165a
movb 0x2(%rsi), %r13b
testb %r13b, %r13b
je 0x15e3
leaq 0x2(%rsi), %rdi
jmp 0x15e8
movq 0x8(%r12,%rax,8), %rdi
movzbl 0x1(%rsi), %eax
cmpl $0x65, %eax
jle 0x1605
cmpl $0x66, %eax
jne 0x161c
callq 0x1090
movsd %xmm0, 0x5b5d(%rip)     # 0x7160
jmp 0x1617
cmpl $0x61, %eax
jne 0x162e
callq 0x1090
movsd %xmm0, 0x5b41(%rip)     # 0x7158
movb $0x1, %r14b
jmp 0x163f
cmpl $0x68, %eax
je 0x1b50
cmpl $0x76, %eax
je 0x1b2f
xorl %r14d, %r14d
leaq 0x2a68(%rip), %rdi      # 0x40a0
xorl %eax, %eax
callq 0x1c44
testb %r13b, %r13b
sete %al
andb %r14b, %al
movzbl %al, %eax
addl %eax, %r15d
incl %r15d
cmpl %ebx, %r15d
jl 0x15c4
subl %r15d, %ebx
jne 0x166b
movq 0x5972(%rip), %rax      # 0x6fd8
movq (%rax), %rbx
jmp 0x168f
cmpl $0x2, %ebx
je 0x169b
cmpl $0x1, %ebx
jne 0x1c25
movslq %r15d, %rax
movq (%r12,%rax,8), %rdi
leaq 0x2bbe(%rip), %rsi      # 0x4245
callq 0x1cde
movq %rax, %rbx
movq 0x593a(%rip), %rax      # 0x6fd0
movq (%rax), %r14
jmp 0x16c5
movslq %r15d, %r14
movq (%r12,%r14,8), %rdi
leaq 0x2b9c(%rip), %rsi      # 0x4245
callq 0x1cde
movq %rax, %rbx
movq 0x8(%r12,%r14,8), %rdi
leaq 0x294c(%rip), %rsi      # 0x4009
callq 0x1cde
movq %rax, %r14
callq 0x1f5b
movq %rax, %r15
movq %rbx, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x2368
cmpl $0x1, (%r15)
je 0x16f2
movq (%r12), %rsi
leaq 0x2956(%rip), %rdi      # 0x4041
xorl %eax, %eax
callq 0x1c44
leaq 0x2967(%rip), %rdx      # 0x4060
movq %r14, %rdi
movq %r15, %rsi
xorl %ecx, %ecx
callq 0x2db9
cmpl $0x0, 0x5a43(%rip)      # 0x7150
jle 0x1b0e
leaq 0x196b(%rip), %rcx      # 0x3085
leaq 0x5a6f(%rip), %r13      # 0x7190
xorl %r9d, %r9d
movl %r9d, -0x2c(%rbp)
cmpl $-0x1, 0x5a25(%rip)     # 0x7154
jne 0x1762
movl $0xa, 0x5a15(%rip)      # 0x7150
xorl %r12d, %r12d
movl 0x8(%r15), %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2854
leaq 0x1931(%rip), %rcx      # 0x3085
movl %eax, (%r12,%r13)
addq $0x4, %r12
cmpq $0x28, %r12
jne 0x173e
movl 0x59ec(%rip), %eax      # 0x7154
leal 0x1(%rax), %edx
movl %edx, 0x59e3(%rip)      # 0x7154
movslq %edx, %rdx
imulq $0x30c30c31, %rdx, %rsi # imm = 0x30C30C31
movq %rsi, %rdx
shrq $0x3f, %rdx
sarq $0x22, %rsi
addl %edx, %esi
leal (%rsi,%rsi,4), %edx
leal (%rsi,%rdx,4), %edx
negl %edx
addl %edx, %eax
incl %eax
cltq
movl (%r13,%rax,4), %r12d
movl 0x8(%r15), %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2854
movl 0x59a4(%rip), %ecx      # 0x7154
leal 0xa(%rcx), %edx
movslq %edx, %rdx
imulq $0x30c30c31, %rdx, %rdx # imm = 0x30C30C31
movq %rdx, %rsi
shrq $0x3f, %rsi
sarq $0x22, %rdx
addl %esi, %edx
leal (%rdx,%rdx,4), %esi
leal (%rdx,%rsi,4), %edx
negl %edx
addl %edx, %ecx
addl $0xa, %ecx
movslq %ecx, %rcx
movl %eax, (%r13,%rcx,4)
movq %rbx, %rdi
callq 0x1170
testl %eax, %eax
je 0x17f1
decl 0x595f(%rip)            # 0x7150
movl -0x2c(%rbp), %edi
testl %edi, %edi
sets %al
testl %r12d, %r12d
setg %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x194a
negl %edi
movl 0x5942(%rip), %eax      # 0x7154
cmpl %edi, %r12d
jle 0x19c5
leal 0x14(%rax), %ecx
movslq %ecx, %rcx
imulq $0x30c30c31, %rcx, %rdx # imm = 0x30C30C31
movq %rdx, %rsi
shrq $0x3f, %rsi
sarq $0x22, %rdx
addl %esi, %edx
leal (%rdx,%rdx,4), %esi
leal (%rdx,%rsi,4), %edx
subl %edx, %ecx
movslq %ecx, %rcx
movl $0x0, (%r13,%rcx,4)
cvtsi2sd %edi, %xmm1
movsd 0x590b(%rip), %xmm0     # 0x7160
mulsd %xmm0, %xmm1
cvttsd2si %xmm1, %ecx
testl %ecx, %ecx
movl $0x86186187, %r12d      # imm = 0x86186187
je 0x18e0
leal 0x13(%rax), %edx
leal -0x2(%rax), %esi
movl $0x1, %edi
movl %ecx, %r8d
testl %esi, %esi
js 0x18e0
movl %edx, %r9d
imulq %r12, %r9
shrq $0x20, %r9
movl %edx, %r10d
subl %r9d, %r10d
shrl %r10d
addl %r9d, %r10d
shrl $0x4, %r10d
leal (%r10,%r10,4), %r9d
leal (%r10,%r9,4), %r9d
movl %edx, %r10d
subl %r9d, %r10d
movl %r10d, %r9d
movl (%r13,%r9,4), %r10d
testl %r10d, %r10d
je 0x18e0
leal (%r10,%r8), %r11d
cmpl $0x1, %r11d
adcl %r8d, %r10d
movl %r10d, (%r13,%r9,4)
cmpl $0x8, %edi
ja 0x18e0
xorps %xmm1, %xmm1
cvtsi2sd %r8d, %xmm1
mulsd %xmm0, %xmm1
cvttsd2si %xmm1, %r8d
incl %edi
decl %edx
decl %esi
testl %r8d, %r8d
jne 0x1875
xorl %r9d, %r9d
testl %ecx, %ecx
je 0x1953
movl $0x1, %edx
leal (%rax,%rdx), %esi
decl %esi
movslq %esi, %rsi
imulq $0x30c30c31, %rsi, %rdi # imm = 0x30C30C31
movq %rdi, %r8
shrq $0x3f, %r8
sarq $0x22, %rdi
addl %r8d, %edi
leal (%rdi,%rdi,4), %r8d
leal (%rdi,%r8,4), %edi
subl %edi, %esi
movslq %esi, %rsi
movl (%r13,%rsi,4), %edi
testl %edi, %edi
je 0x1953
leal (%rdi,%rcx), %r8d
cmpl $0x1, %r8d
adcl %ecx, %edi
movl %edi, (%r13,%rsi,4)
cmpl $0x8, %edx
ja 0x1953
incl %edx
xorps %xmm1, %xmm1
cvtsi2sd %ecx, %xmm1
mulsd %xmm0, %xmm1
cvttsd2si %xmm1, %ecx
testl %ecx, %ecx
jne 0x18ec
jmp 0x1953
movl %r12d, %r9d
movl $0x86186187, %r12d      # imm = 0x86186187
movl 0x57fb(%rip), %eax      # 0x7154
cmpl $0xa, %eax
jl 0x19ac
addl $-0xa, %eax
movq %rax, %rcx
imulq %r12, %rcx
shrq $0x20, %rcx
movl %eax, %edx
subl %ecx, %edx
shrl %edx
addl %ecx, %edx
shrl $0x4, %edx
leal (%rdx,%rdx,4), %ecx
leal (%rdx,%rcx,4), %ecx
subl %ecx, %eax
xorps %xmm0, %xmm0
cvtsi2sdl (%r13,%rax,4), %xmm0
mulsd 0x57c7(%rip), %xmm0     # 0x7158
cvttsd2si %xmm0, %edx
movq %r14, %rdi
leaq 0x29ee(%rip), %rsi      # 0x438d
xorl %eax, %eax
movl %r9d, %r12d
callq 0x1150
movl %r12d, %r9d
cmpl $0x0, 0x579d(%rip)      # 0x7150
leaq 0x16cb(%rip), %rcx      # 0x3085
jg 0x1724
jmp 0x1b0e
movslq %eax, %rcx
imulq $0x30c30c31, %rcx, %rdx # imm = 0x30C30C31
movq %rdx, %rsi
shrq $0x3f, %rsi
sarq $0x22, %rdx
addl %esi, %edx
leal (%rdx,%rdx,4), %esi
leal (%rdx,%rsi,4), %edx
subl %edx, %ecx
movslq %ecx, %rcx
movl $0x0, (%r13,%rcx,4)
cvtsi2sd %r12d, %xmm1
movsd 0x5763(%rip), %xmm0     # 0x7160
mulsd %xmm0, %xmm1
cvttsd2si %xmm1, %ecx
xorl %r9d, %r9d
testl %ecx, %ecx
je 0x194d
leal 0x14(%rax), %edx
leal -0x1(%rax), %esi
movl $0x1, %edi
movl %ecx, %r8d
movl $0x86186187, %r12d      # imm = 0x86186187
testl %esi, %esi
js 0x1a91
movl %edx, %r9d
imulq %r12, %r9
shrq $0x20, %r9
movl %edx, %r10d
subl %r9d, %r10d
shrl %r10d
addl %r9d, %r10d
shrl $0x4, %r10d
leal (%r10,%r10,4), %r9d
leal (%r10,%r9,4), %r9d
movl %edx, %r10d
subl %r9d, %r10d
movl %r10d, %r9d
movl (%r13,%r9,4), %r10d
testl %r10d, %r10d
je 0x1a91
subl %r8d, %r10d
movl $0xffffffff, %r11d      # imm = 0xFFFFFFFF
cmovel %r11d, %r10d
movl %r10d, (%r13,%r9,4)
cmpl $0x8, %edi
ja 0x1a91
xorps %xmm1, %xmm1
cvtsi2sd %r8d, %xmm1
mulsd %xmm0, %xmm1
cvttsd2si %xmm1, %r8d
incl %edi
decl %edx
decl %esi
testl %r8d, %r8d
jne 0x1a24
testl %ecx, %ecx
je 0x1b06
movl $0x1, %edx
xorl %r9d, %r9d
leal (%rax,%rdx), %esi
movslq %esi, %rsi
imulq $0x30c30c31, %rsi, %rdi # imm = 0x30C30C31
movq %rdi, %r8
shrq $0x3f, %r8
sarq $0x22, %rdi
addl %r8d, %edi
leal (%rdi,%rdi,4), %r8d
leal (%rdi,%r8,4), %edi
subl %edi, %esi
movslq %esi, %rsi
movl (%r13,%rsi,4), %edi
testl %edi, %edi
je 0x1953
subl %ecx, %edi
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
cmovel %r8d, %edi
movl %edi, (%r13,%rsi,4)
cmpl $0x8, %edx
ja 0x1953
incl %edx
xorps %xmm1, %xmm1
cvtsi2sd %ecx, %xmm1
mulsd %xmm0, %xmm1
cvttsd2si %xmm1, %ecx
testl %ecx, %ecx
jne 0x1a9d
jmp 0x1953
xorl %r9d, %r9d
jmp 0x1953
movq %rbx, %rdi
callq 0x10a0
movq %r14, %rdi
callq 0x10a0
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x560a(%rip), %rsi      # 0x7140
movq 0x560b(%rip), %rdx      # 0x7148
leaq 0x252d(%rip), %rdi      # 0x4071
xorl %eax, %eax
callq 0x10c0
jmp 0x1c1e
leaq 0x2563(%rip), %rdi      # 0x40ba
callq 0x1080
leaq 0x255d(%rip), %rdi      # 0x40c0
callq 0x1080
leaq 0x2583(%rip), %rdi      # 0x40f2
callq 0x1080
leaq 0x25a8(%rip), %rdi      # 0x4123
callq 0x1080
movl $0xa, %edi
callq 0x1050
leaq 0x25a2(%rip), %rdi      # 0x4133
callq 0x1080
leaq 0x25a4(%rip), %rdi      # 0x4141
callq 0x1080
leaq 0x25c1(%rip), %rdi      # 0x416a
callq 0x1080
movsd 0x55a2(%rip), %xmm0     # 0x7158
leaq 0x24c3(%rip), %rdi      # 0x4080
movb $0x1, %al
callq 0x10c0
movl $0xa, %edi
callq 0x1050
leaq 0x25c8(%rip), %rdi      # 0x419d
callq 0x1080
leaq 0x25e2(%rip), %rdi      # 0x41c3
callq 0x1080
leaq 0x2604(%rip), %rdi      # 0x41f1
callq 0x1080
movl $0xa, %edi
callq 0x1050
leaq 0x2613(%rip), %rdi      # 0x4216
callq 0x1080
movl $0xa, %edi
callq 0x1050
leaq 0x262e(%rip), %rdi      # 0x4247
callq 0x1080
xorl %edi, %edi
callq 0x1210
movq (%r12), %rsi
leaq 0x23db(%rip), %rdi      # 0x400b
xorl %eax, %eax
callq 0x10c0
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1210
nopl (%rax)