// File: /workspace/github_c_makefile_star2_O3/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 0x168a
movl $0x1, %r15d
movslq %r15d, %rax
movq (%r12,%rax,8), %rsi
cmpb $0x2d, (%rsi)
jne 0x168a
movb 0x2(%rsi), %r13b
testb %r13b, %r13b
je 0x1613
leaq 0x2(%rsi), %rdi
jmp 0x1618
movq 0x8(%r12,%rax,8), %rdi
movzbl 0x1(%rsi), %eax
cmpl $0x65, %eax
jle 0x1635
cmpl $0x66, %eax
jne 0x164c
callq 0x1090
movsd %xmm0, 0x5b2d(%rip)     # 0x7160
jmp 0x1647
cmpl $0x61, %eax
jne 0x165e
callq 0x1090
movsd %xmm0, 0x5b11(%rip)     # 0x7158
movb $0x1, %r14b
jmp 0x166f
cmpl $0x68, %eax
je 0x1b62
cmpl $0x76, %eax
je 0x1b41
xorl %r14d, %r14d
leaq 0x2a38(%rip), %rdi      # 0x40a0
xorl %eax, %eax
callq 0x1c54
testb %r13b, %r13b
sete %al
andb %r14b, %al
movzbl %al, %eax
addl %eax, %r15d
incl %r15d
cmpl %ebx, %r15d
jl 0x15f4
subl %r15d, %ebx
jne 0x169b
movq 0x5942(%rip), %rax      # 0x6fd8
movq (%rax), %rbx
jmp 0x16bf
cmpl $0x2, %ebx
je 0x16cb
cmpl $0x1, %ebx
jne 0x1c37
movslq %r15d, %rax
movq (%r12,%rax,8), %rdi
leaq 0x2b8e(%rip), %rsi      # 0x4245
callq 0x1cee
movq %rax, %rbx
movq 0x590a(%rip), %rax      # 0x6fd0
movq (%rax), %r14
jmp 0x16f5
movslq %r15d, %r14
movq (%r12,%r14,8), %rdi
leaq 0x2b6c(%rip), %rsi      # 0x4245
callq 0x1cee
movq %rax, %rbx
movq 0x8(%r12,%r14,8), %rdi
leaq 0x291c(%rip), %rsi      # 0x4009
callq 0x1cee
movq %rax, %r14
callq 0x1f5f
movq %rax, %r15
movq %rbx, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x2385
cmpl $0x1, (%r15)
je 0x1722
movq (%r12), %rsi
leaq 0x2926(%rip), %rdi      # 0x4041
xorl %eax, %eax
callq 0x1c54
leaq 0x2937(%rip), %rdx      # 0x4060
movq %r14, %rdi
movq %r15, %rsi
xorl %ecx, %ecx
callq 0x2e20
cmpl $0x0, 0x5a13(%rip)      # 0x7150
jle 0x1b20
movl 0x5a0b(%rip), %eax      # 0x7154
leaq 0x199b(%rip), %rcx      # 0x30eb
leaq 0x5a39(%rip), %r13      # 0x7190
xorl %esi, %esi
movl %esi, -0x2c(%rbp)
cmpl $-0x1, %eax
jne 0x1798
movl $0xa, 0x59e5(%rip)      # 0x7150
xorl %r12d, %r12d
movl 0x8(%r15), %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2888
leaq 0x1967(%rip), %rcx      # 0x30eb
movl %eax, (%r12,%r13)
addq $0x4, %r12
cmpq $0x28, %r12
jne 0x176e
movl 0x59bc(%rip), %eax      # 0x7154
incl %eax
movl %eax, 0x59b4(%rip)      # 0x7154
cltq
imulq $0x30c30c31, %rax, %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
subl %edx, %eax
cltq
movl (%r13,%rax,4), %r12d
movl 0x8(%r15), %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2888
movl 0x597a(%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 0x181b
decl 0x5935(%rip)            # 0x7150
movl -0x2c(%rbp), %edi
testl %edi, %edi
sets %al
testl %r12d, %r12d
setg %cl
testb %cl, %al
movl $0xffffffff, %r11d      # imm = 0xFFFFFFFF
je 0x1981
negl %edi
movl 0x5915(%rip), %eax      # 0x7154
cmpl %edi, %r12d
jbe 0x1995
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 0x58de(%rip), %xmm0     # 0x7160
mulsd %xmm0, %xmm1
cvttsd2si %xmm1, %ecx
xorl %esi, %esi
testl %ecx, %ecx
je 0x198a
leal 0x13(%rax), %edx
leal -0x2(%rax), %esi
movl $0x1, %edi
movl %ecx, %r8d
movl $0x86186187, %r12d      # imm = 0x86186187
testl %esi, %esi
js 0x1913
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 0x1913
leal (%r10,%r8), %r11d
cmpl $0x1, %r11d
adcl %r8d, %r10d
movl %r10d, (%r13,%r9,4)
cmpl $0x8, %edi
ja 0x1913
xorps %xmm1, %xmm1
cvtsi2sd %r8d, %xmm1
mulsd %xmm0, %xmm1
cvttsd2si %xmm1, %r8d
incl %edi
decl %edx
decl %esi
testl %r8d, %r8d
jne 0x18a8
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 0x1ab1
leal (%rdi,%rcx), %r8d
cmpl $0x1, %r8d
adcl %ecx, %edi
movl %edi, (%r13,%rsi,4)
cmpl $0x8, %edx
ja 0x1ab1
incl %edx
xorps %xmm1, %xmm1
cvtsi2sd %ecx, %xmm1
mulsd %xmm0, %xmm1
cvttsd2si %xmm1, %ecx
testl %ecx, %ecx
jne 0x1918
jmp 0x1ab1
movl 0x57cd(%rip), %eax      # 0x7154
movl %r12d, %esi
movl $0x86186187, %r12d      # imm = 0x86186187
jmp 0x1ab3
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 0x5793(%rip), %xmm0     # 0x7160
mulsd %xmm0, %xmm1
cvttsd2si %xmm1, %ecx
xorl %esi, %esi
testl %ecx, %ecx
je 0x198a
leal 0x14(%rax), %edx
leal -0x1(%rax), %esi
movl $0x1, %edi
movl %ecx, %r8d
movl $0x86186187, %r12d      # imm = 0x86186187
testl %esi, %esi
js 0x1a56
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 0x1a56
subl %r8d, %r10d
cmovel %r11d, %r10d
movl %r10d, (%r13,%r9,4)
cmpl $0x8, %edi
ja 0x1a56
xorps %xmm1, %xmm1
cvtsi2sd %r8d, %xmm1
mulsd %xmm0, %xmm1
cvttsd2si %xmm1, %r8d
incl %edi
decl %edx
decl %esi
testl %r8d, %r8d
jne 0x19ef
movl $0x1, %edx
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 0x1ab1
subl %ecx, %edi
cmovel %r11d, %edi
movl %edi, (%r13,%rsi,4)
cmpl $0x8, %edx
ja 0x1ab1
incl %edx
xorps %xmm1, %xmm1
cvtsi2sd %ecx, %xmm1
mulsd %xmm0, %xmm1
cvttsd2si %xmm1, %ecx
testl %ecx, %ecx
jne 0x1a5b
xorl %esi, %esi
cmpl $0xa, %eax
jl 0x1b0c
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 0x566d(%rip), %xmm0     # 0x7158
cvttsd2si %xmm0, %edx
movl %esi, %r12d
movq %r14, %rdi
leaq 0x2891(%rip), %rsi      # 0x438d
xorl %eax, %eax
callq 0x1150
movl %r12d, %esi
movl 0x5648(%rip), %eax      # 0x7154
leaq 0x15d8(%rip), %rcx      # 0x30eb
cmpl $0x0, 0x5636(%rip)      # 0x7150
jg 0x1759
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 0x55f8(%rip), %rsi      # 0x7140
movq 0x55f9(%rip), %rdx      # 0x7148
leaq 0x251b(%rip), %rdi      # 0x4071
xorl %eax, %eax
callq 0x10c0
jmp 0x1c30
leaq 0x2551(%rip), %rdi      # 0x40ba
callq 0x1080
leaq 0x254b(%rip), %rdi      # 0x40c0
callq 0x1080
leaq 0x2571(%rip), %rdi      # 0x40f2
callq 0x1080
leaq 0x2596(%rip), %rdi      # 0x4123
callq 0x1080
movl $0xa, %edi
callq 0x1050
leaq 0x2590(%rip), %rdi      # 0x4133
callq 0x1080
leaq 0x2592(%rip), %rdi      # 0x4141
callq 0x1080
leaq 0x25af(%rip), %rdi      # 0x416a
callq 0x1080
movsd 0x5590(%rip), %xmm0     # 0x7158
leaq 0x24b1(%rip), %rdi      # 0x4080
movb $0x1, %al
callq 0x10c0
movl $0xa, %edi
callq 0x1050
leaq 0x25b6(%rip), %rdi      # 0x419d
callq 0x1080
leaq 0x25d0(%rip), %rdi      # 0x41c3
callq 0x1080
leaq 0x25f2(%rip), %rdi      # 0x41f1
callq 0x1080
movl $0xa, %edi
callq 0x1050
leaq 0x2601(%rip), %rdi      # 0x4216
callq 0x1080
movl $0xa, %edi
callq 0x1050
leaq 0x261c(%rip), %rdi      # 0x4247
callq 0x1080
xorl %edi, %edi
callq 0x1210
movq (%r12), %rsi
leaq 0x23c9(%rip), %rdi      # 0x400b
xorl %eax, %eax
callq 0x10c0
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1210
nop