// File: /workspace/github_c_makefile_star2_O1/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, 0x3c6b(%rip)     # 0x6150
je 0x2511
movl %r14d, 0x3c62(%rip)     # 0x6150
decl %r14d
movsd 0xc57(%rip), %xmm0      # 0x3150
movl %r14d, %edi
callq 0x1050
addsd 0xc4f(%rip), %xmm0      # 0x3158
movsd %xmm0, 0x3c57(%rip)     # 0x6168
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), %rax
movsbq (%r15), %rcx
testb $0x20, 0x1(%rax,%rcx,2)
je 0x2567
leaq 0x7(%rsp), %r15
movl $0x1, %edx
movl %ebp, %edi
movq %r15, %rsi
callq 0x1110
incl (%rbx)
movq (%r14), %rax
movsbq 0x7(%rsp), %rcx
testb $0x20, 0x1(%rax,%rcx,2)
jne 0x2546
movl %ebp, 0xc(%rsp)
movq %rbx, %r15
xorl %r12d, %r12d
movl $0x1, %ebp
xorl %ebx, %ebx
xorl %r13d, %r13d
movl $0x0, 0x8(%rsp)
movq (%r14), %rcx
movsbq 0x7(%rsp), %rax
testb $0x8, 0x1(%rcx,%rax,2)
jne 0x25c0
testl %ebp, %ebp
setne %cl
cmpb $0x2d, %al
sete %dl
testb %dl, %cl
jne 0x25c0
testl %ebx, %ebx
sete %cl
cmpb $0x2e, %al
sete %dl
testb %dl, %cl
jne 0x25c0
cmpl $0x0, 0x8(%rsp)
jne 0x2632
movl %eax, %ecx
andb $-0x21, %cl
cmpb $0x45, %cl
jne 0x2632
cmpb $0x2e, %al
movl $0x1, %ecx
cmovel %ecx, %ebx
cmovel %ecx, %r13d
movl %eax, %ecx
andb $-0x21, %cl
xorl %ebp, %ebp
cmpb $0x45, %cl
jne 0x25f2
movl $0x1, %ebp
movl $0x1, %ebx
movl $0x1, %r13d
movl $0x1, 0x8(%rsp)
movb %al, 0x10(%rsp,%r12)
cmpq $0x1fe, %r12            # imm = 0x1FE
jb 0x2614
movl 0x3b42(%rip), %esi      # 0x6148
leaq 0xda0(%rip), %rdi       # 0x33ad
xorl %eax, %eax
callq 0x16e0
incl (%r15)
movl $0x1, %edx
movl 0xc(%rsp), %edi
leaq 0x7(%rsp), %rsi
callq 0x1110
incq %r12
jmp 0x2583
movl %r12d, %eax
movb $0x0, 0x10(%rsp,%rax)
movzwl 0x10(%rsp), %eax
cmpl $0x2d, %eax
je 0x2652
cmpl $0x2e, %eax
jne 0x2666
leaq 0xdbb(%rip), %rdi       # 0x340b
jmp 0x2659
leaq 0xd84(%rip), %rdi       # 0x33dd
movl 0x3ae9(%rip), %esi      # 0x6148
xorl %eax, %eax
callq 0x16e0
leaq 0x10(%rsp), %rdi
testl %r13d, %r13d
je 0x2683
callq 0x1080
mulsd 0x3aeb(%rip), %xmm0     # 0x6168
cvttsd2si %xmm0, %eax
jmp 0x2688
callq 0x11f0
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq