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

    int i,count,prev,curr;
    double freq;
    FILE *in,*out;
    char *source = 0;
    RRA *h;
    static int skip;

    argIndex = processOptions(argc,argv);

    if (argc-argIndex == 0)
        {
        in = stdin;
        out = stdout;
        }
    else if (argc-argIndex == 1)
        {
        source = argv[argIndex];
        in = OpenFile(source,"r");
        out = stdout;
        }
    else if (argc-argIndex == 2)
        {
        source = argv[argIndex];
        in = OpenFile(source,"r");
        out = OpenFile(argv[argIndex+1],"w");
        }
    else
        {
        printf("usage: %s [<input 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]);

    /* skip over the first part */

    skip = initialOffset * h->sampleRate;
    printf("skip is %d\n",skip);
    for (i = 0; i < skip; ++i)
        (void) readRRAAmplitude(in,out,h->bitsPerSample,outputComment);

    /* find first upward zero */

    prev = readRRAAmplitude(in,out,h->bitsPerSample,outputComment);
    curr = readRRAAmplitude(in,out,h->bitsPerSample,outputComment);

    while (prev >= 0 || curr != 0)
        {
        prev = curr;
        curr = readRRAAmplitude(in,out,h->bitsPerSample,outputComment);
        }

    count = 0;
    while (count < 2000)
        {
        prev = readRRAAmplitude(in,out,h->bitsPerSample,outputComment);
        curr = readRRAAmplitude(in,out,h->bitsPerSample,outputComment);
        count += 2;

        /* find next upward zero */
    
        while (prev >= 0 || curr != 0)
            {
            prev = curr;
            curr = readRRAAmplitude(in,out,h->bitsPerSample,outputComment);
            ++count;
            }

        freq = h->sampleRate / (double) count;
        printf("possible wavelength/frequency/note: %d/%f/%s\n",
            count,freq,closestNote(freq));
        }

    fclose(in);
    fclose(out);

    return 0;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x1, -0x14(%rbp)
movq $0x0, -0x48(%rbp)
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
callq 0x2740
movl %eax, -0x14(%rbp)
movl -0x8(%rbp), %eax
subl -0x14(%rbp), %eax
cmpl $0x0, %eax
jne 0x2450
movq 0x6ba2(%rip), %rax      # 0x8fd8
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movq 0x6b8c(%rip), %rax      # 0x8fd0
movq (%rax), %rax
movq %rax, -0x40(%rbp)
jmp 0x2504
movl -0x8(%rbp), %eax
subl -0x14(%rbp), %eax
cmpl $0x1, %eax
jne 0x248f
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
leaq 0x4380(%rip), %rsi      # 0x67f6
callq 0x2a50
movq %rax, -0x38(%rbp)
movq 0x6b4a(%rip), %rax      # 0x8fd0
movq (%rax), %rax
movq %rax, -0x40(%rbp)
jmp 0x2502
movl -0x8(%rbp), %eax
subl -0x14(%rbp), %eax
cmpl $0x2, %eax
jne 0x24e1
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
leaq 0x4341(%rip), %rsi      # 0x67f6
callq 0x2a50
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x3d0a(%rip), %rsi      # 0x61e0
callq 0x2a50
movq %rax, -0x40(%rbp)
jmp 0x2500
movq -0x10(%rbp), %rax
movq (%rax), %rsi
leaq 0x3cf3(%rip), %rdi      # 0x61e2
movb $0x0, %al
callq 0x2090
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x21d0
jmp 0x2502
jmp 0x2504
callq 0x2f30
movq %rax, -0x50(%rbp)
movq -0x38(%rbp), %rdi
movq -0x50(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x3430
movq -0x50(%rbp), %rax
cmpl $0x1, (%rax)
je 0x253c
movq -0x10(%rbp), %rax
movq (%rax), %rsi
leaq 0x3ccb(%rip), %rdi      # 0x6200
movb $0x0, %al
callq 0x2900
movsd 0x736c(%rip), %xmm0     # 0x98b0
movq -0x50(%rbp), %rax
cvtsi2sdl 0x4(%rax), %xmm1
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x7371(%rip)      # 0x98cc
movl 0x736b(%rip), %esi      # 0x98cc
leaq 0x3cb7(%rip), %rdi      # 0x621f
movb $0x0, %al
callq 0x2090
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl 0x734d(%rip), %eax      # 0x98cc
jge 0x25a7
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x50(%rbp), %rax
movl 0x8(%rax), %edx
leaq 0x2279(%rip), %rcx      # 0x4810
callq 0x3b60
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x2576
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x50(%rbp), %rax
movl 0x8(%rax), %edx
leaq 0x2253(%rip), %rcx      # 0x4810
callq 0x3b60
movl %eax, -0x20(%rbp)
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x50(%rbp), %rax
movl 0x8(%rax), %edx
leaq 0x2235(%rip), %rcx      # 0x4810
callq 0x3b60
movl %eax, -0x24(%rbp)
movb $0x1, %al
cmpl $0x0, -0x20(%rbp)
movb %al, -0x51(%rbp)
jge 0x25f8
cmpl $0x0, -0x24(%rbp)
setne %al
movb %al, -0x51(%rbp)
movb -0x51(%rbp), %al
testb $0x1, %al
jne 0x2601
jmp 0x2627
movl -0x24(%rbp), %eax
movl %eax, -0x20(%rbp)
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x50(%rbp), %rax
movl 0x8(%rax), %edx
leaq 0x21f3(%rip), %rcx      # 0x4810
callq 0x3b60
movl %eax, -0x24(%rbp)
jmp 0x25e3
movl $0x0, -0x1c(%rbp)
cmpl $0x7d0, -0x1c(%rbp)     # imm = 0x7D0
jge 0x271c
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x50(%rbp), %rax
movl 0x8(%rax), %edx
leaq 0x21bf(%rip), %rcx      # 0x4810
callq 0x3b60
movl %eax, -0x20(%rbp)
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x50(%rbp), %rax
movl 0x8(%rax), %edx
leaq 0x21a1(%rip), %rcx      # 0x4810
callq 0x3b60
movl %eax, -0x24(%rbp)
movl -0x1c(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x1c(%rbp)
movb $0x1, %al
cmpl $0x0, -0x20(%rbp)
movb %al, -0x52(%rbp)
jge 0x2695
cmpl $0x0, -0x24(%rbp)
setne %al
movb %al, -0x52(%rbp)
movb -0x52(%rbp), %al
testb $0x1, %al
jne 0x269e
jmp 0x26cd
movl -0x24(%rbp), %eax
movl %eax, -0x20(%rbp)
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x50(%rbp), %rax
movl 0x8(%rax), %edx
leaq 0x2156(%rip), %rcx      # 0x4810
callq 0x3b60
movl %eax, -0x24(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x2680
movq -0x50(%rbp), %rax
cvtsi2sdl 0x4(%rax), %xmm0
cvtsi2sdl -0x1c(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x64(%rbp)
movsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x60(%rbp)
movsd -0x30(%rbp), %xmm0
callq 0x2310
movl -0x64(%rbp), %esi
movsd -0x60(%rbp), %xmm0
movq %rax, %rdx
leaq 0x3b1b(%rip), %rdi      # 0x622b
movb $0x1, %al
callq 0x2090
jmp 0x262e
movq -0x38(%rbp), %rdi
callq 0x2070
movq -0x40(%rbp), %rdi
callq 0x2070
xorl %eax, %eax
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)