// File: /workspace/github_c_makefile_star2_O3/pipde[P]deos-songlib/lib/rra.c
// Function: readRRAAmplitude
int
readRRAAmplitude(FILE *in,FILE *out,int bps,void (*handler)(FILE *, FILE *))
    {
    int ch;
    char s[512] = "";
    int count;
    int first;
    int decimal;
    int floater;
    int exponent;
    static int storedBPS = -1;
    static double storedMax;

    if (storedBPS != bps)
        {
        storedBPS = bps;
        storedMax = pow(2,bps - 1) - 1;
        }

    if (feof(in)) return -1;

    first = 1;
    decimal = 0;
    floater = 0;
    exponent = 0;

    skipWhiteSpace(in,out,handler);

    count = 0;
    ch = fgetc(in);
    while (isdigit(ch) || (first && ch == '-') || (!decimal && ch == '.')
        || (!exponent && (ch == 'E' || ch == 'e')))
        {
        first = 0;
        if (ch == '.')
            {
            decimal = 1;
            floater = 1;
            }
        if (ch == 'E' || ch == 'e')
            {
            decimal = 1;
            floater = 1;
            exponent = 1;
            first = 1;
            }
        s[count++] = ch;
        if (count >= sizeof(s) - 1)
            Fatal("RRA FORMAT ERROR, line %d: number is too large\n",
                LineNumber);
        ch = fgetc(in);
        }

    s[count] = '\0';

    ungetc(ch, in);

    //printf("number is %s\n", s);

    if (strcmp(s,"-") == 0)
        Fatal("RRA FORMAT ERROR, line %d: lonely dash found\n", LineNumber);
    else if (strcmp(s,".") == 0)
        Fatal("RRA FORMAT ERROR, line %d: lonely dot found\n", LineNumber);

    if (floater)
        {
        //printf("!floater is %s (a fraction of 2^%d)\n",s,bps); 
        //printf("!%d\n", (int) (atof(s) * storedMax));
        return (int) (atof(s) * storedMax);
        }
    else
        return atoi(s);
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x218, %rsp            # imm = 0x218
movq %rcx, %r14
movl %edx, %ebp
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x10(%rsp), %rdi
movl $0x200, %edx            # imm = 0x200
xorl %esi, %esi
callq 0x10d0
cmpl %ebp, 0x4dd9(%rip)      # 0x714c
je 0x239c
movl %ebp, 0x4dd1(%rip)      # 0x714c
decl %ebp
movsd 0x1dcb(%rip), %xmm0     # 0x4150
movl %ebp, %edi
callq 0x1050
addsd 0x1dc4(%rip), %xmm0     # 0x4158
movsd %xmm0, 0x4dc4(%rip)     # 0x7160
movq %rbx, %rdi
callq 0x1160
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %ecx, %ecx
jne 0x2508
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x2210
movq %rbx, 0x8(%rsp)
movq %rbx, %rdi
callq 0x10e0
movl %eax, %ebp
callq 0x1240
movq %rax, %r14
xorl %r15d, %r15d
movl $0x1, %r13d
xorl %ebx, %ebx
xorl %r12d, %r12d
movl $0x0, 0x4(%rsp)
movq (%r14), %rax
movslq %ebp, %rcx
testb $0x8, 0x1(%rax,%rcx,2)
jne 0x2428
testl %r13d, %r13d
setne %al
cmpl $0x2d, %ebp
sete %cl
testb %al, %cl
jne 0x2414
movl %ebp, %eax
xorl $0x2e, %eax
orl %ebx, %eax
jne 0x2446
cmpl $0x2e, %ebp
movl $0x1, %eax
cmovel %eax, %ebx
cmovel %eax, %r12d
xorl %r13d, %r13d
jmp 0x2470
movl %ebp, %eax
andl $-0x21, %eax
cmpl $0x2e, %ebp
movl $0x1, %ecx
cmovel %ecx, %ebx
cmovel %ecx, %r12d
xorl %r13d, %r13d
cmpl $0x45, %eax
je 0x2457
jmp 0x2470
movl %ebp, %eax
andl $-0x21, %eax
cmpl $0x45, %eax
jne 0x24a6
cmpl $0x0, 0x4(%rsp)
jne 0x24a6
movl $0x1, %r13d
movl $0x1, %ebx
movl $0x1, %r12d
movl $0x1, 0x4(%rsp)
movb %bpl, 0x10(%rsp,%r15)
cmpq $0x1fe, %r15            # imm = 0x1FE
jb 0x2492
movl 0x4cc4(%rip), %esi      # 0x7148
leaq 0x1f22(%rip), %rdi      # 0x43ad
xorl %eax, %eax
callq 0x170c
movq 0x8(%rsp), %rdi
callq 0x10e0
movl %eax, %ebp
incq %r15
jmp 0x23ee
movl %r15d, %eax
movb $0x0, 0x10(%rsp,%rax)
movl %ebp, %edi
movq 0x8(%rsp), %rsi
callq 0x1190
movzwl 0x10(%rsp), %eax
cmpl $0x2d, %eax
je 0x24d2
cmpl $0x2e, %eax
jne 0x24e6
leaq 0x1f3b(%rip), %rdi      # 0x440b
jmp 0x24d9
leaq 0x1f04(%rip), %rdi      # 0x43dd
movl 0x4c69(%rip), %esi      # 0x7148
xorl %eax, %eax
callq 0x170c
leaq 0x10(%rsp), %rdi
testl %r12d, %r12d
je 0x2503
callq 0x1080
mulsd 0x4c63(%rip), %xmm0     # 0x7160
cvttsd2si %xmm0, %eax
jmp 0x2508
callq 0x11f0
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq