// File: /workspace/github_c_makefile_star2_O3/pipde[P]deos-songlib/lib/rra.c
// Function: readRRAAmplitudeFD
int
readRRAAmplitudeFD(int in,int bps,int *size)
    {
    char 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;
        }

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

    //skip white space
    *size = 1;
    read(in,&ch,1);
    while (isspace(ch))
        {
        read(in,&ch,1);
        ++*size;
        }

    //printf("first char is %c\n",ch);
    
    count = 0;
    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);
        ++*size;
        read(in,&ch,1);
        }

    s[count] = '\0';

    //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 %rdx, %rbx
movl %esi, %r14d
movl %edi, %ebp
leaq 0x10(%rsp), %rdi
movl $0x200, %edx            # imm = 0x200
xorl %esi, %esi
callq 0x10d0
cmpl %r14d, 0x4c05(%rip)     # 0x7150
je 0x2577
movl %r14d, 0x4bfc(%rip)     # 0x7150
decl %r14d
movsd 0x1bf1(%rip), %xmm0     # 0x4150
movl %r14d, %edi
callq 0x1050
addsd 0x1be9(%rip), %xmm0     # 0x4158
movsd %xmm0, 0x4bf1(%rip)     # 0x7168
movl $0x1, (%rbx)
leaq 0x7(%rsp), %r15
movl $0x1, %edx
movl %ebp, %edi
movq %r15, %rsi
callq 0x1110
callq 0x1240
movq %rax, %r14
movq (%rax), %rcx
movsbq (%r15), %rax
testb $0x20, 0x1(%rcx,%rax,2)
je 0x25cd
leaq 0x7(%rsp), %r15
movl $0x1, %edx
movl %ebp, %edi
movq %r15, %rsi
callq 0x1110
incl (%rbx)
movq (%r14), %rcx
movsbq 0x7(%rsp), %rax
testb $0x20, 0x1(%rcx,%rax,2)
jne 0x25ac
movq %r14, %r15
movl %ebp, 0xc(%rsp)
movq %rbx, %r14
xorl %r12d, %r12d
movl $0x1, %ebp
xorl %ebx, %ebx
xorl %r13d, %r13d
movl $0x0, 0x8(%rsp)
movsbq %al, %rdx
testb $0x8, 0x1(%rcx,%rdx,2)
jne 0x2625
testl %ebp, %ebp
setne %cl
cmpb $0x2d, %al
sete %dl
testb %dl, %cl
jne 0x2613
testl %ebx, %ebx
sete %cl
cmpb $0x2e, %al
sete %dl
testb %dl, %cl
je 0x2641
cmpb $0x2e, %al
movl $0x1, %ecx
cmovel %ecx, %ebx
cmovel %ecx, %r13d
xorl %ebp, %ebp
jmp 0x266a
movl %eax, %ecx
andb $-0x21, %cl
cmpb $0x2e, %al
movl $0x1, %edx
cmovel %edx, %ebx
cmovel %edx, %r13d
xorl %ebp, %ebp
cmpb $0x45, %cl
je 0x2652
jmp 0x266a
cmpl $0x0, 0x8(%rsp)
jne 0x26b1
movl %eax, %ecx
andb $-0x21, %cl
cmpb $0x45, %cl
jne 0x26b1
movl $0x1, %ebp
movl $0x1, %ebx
movl $0x1, %r13d
movl $0x1, 0x8(%rsp)
movb %al, 0x10(%rsp,%r12)
cmpq $0x1fe, %r12            # imm = 0x1FE
jb 0x268c
movl 0x4aca(%rip), %esi      # 0x7148
leaq 0x1d28(%rip), %rdi      # 0x43ad
xorl %eax, %eax
callq 0x170c
incl (%r14)
movl $0x1, %edx
movl 0xc(%rsp), %edi
leaq 0x7(%rsp), %rsi
callq 0x1110
movq (%r15), %rcx
movb 0x7(%rsp), %al
incq %r12
jmp 0x25ec
movl %r12d, %eax
movb $0x0, 0x10(%rsp,%rax)
movzwl 0x10(%rsp), %eax
cmpl $0x2d, %eax
je 0x26d1
cmpl $0x2e, %eax
jne 0x26e5
leaq 0x1d3c(%rip), %rdi      # 0x440b
jmp 0x26d8
leaq 0x1d05(%rip), %rdi      # 0x43dd
movl 0x4a6a(%rip), %esi      # 0x7148
xorl %eax, %eax
callq 0x170c
leaq 0x10(%rsp), %rdi
testl %r13d, %r13d
je 0x2702
callq 0x1080
mulsd 0x4a6c(%rip), %xmm0     # 0x7168
cvttsd2si %xmm0, %eax
jmp 0x2707
callq 0x11f0
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq