// File: /workspace/github_c_makefile_star2_O2/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 $0x228, %rsp            # imm = 0x228
movq %rdx, 0x18(%rsp)
movl %esi, %r14d
movl %edi, 0x10(%rsp)
leaq 0x20(%rsp), %rdi
movl $0x200, %edx            # imm = 0x200
xorl %esi, %esi
callq 0x10d0
cmpl %r14d, 0x3f0b(%rip)     # 0x6150
je 0x2271
movl %r14d, 0x3f02(%rip)     # 0x6150
decl %r14d
movsd 0xef7(%rip), %xmm0      # 0x3150
movl %r14d, %edi
callq 0x1050
addsd 0xeef(%rip), %xmm0      # 0x3158
movsd %xmm0, 0x3ef7(%rip)     # 0x6168
movq 0x18(%rsp), %rax
movl $0x1, (%rax)
leaq 0xf(%rsp), %r15
pushq $0x1
popq %r12
movl 0x10(%rsp), %edi
movq %r15, %rsi
movq %r12, %rdx
callq 0x1110
callq 0x1240
movq %rax, %r14
movq (%r14), %rcx
movsbq 0xf(%rsp), %rax
movzwl (%rcx,%rax,2), %ecx
btl $0xd, %ecx
jae 0x22c7
movl 0x10(%rsp), %edi
movq %r15, %rsi
movq %r12, %rdx
callq 0x1110
movq 0x18(%rsp), %rax
incl (%rax)
jmp 0x229c
pushq $0x1
popq %rbp
xorl %r13d, %r13d
movl %ebp, %ebx
xorl %r12d, %r12d
xorl %r15d, %r15d
movl $0x0, 0x14(%rsp)
btl $0xb, %ecx
jb 0x2311
testl %ebx, %ebx
setne %cl
cmpb $0x2d, %al
sete %dl
testb %dl, %cl
jne 0x2311
testl %r12d, %r12d
sete %cl
cmpb $0x2e, %al
sete %dl
testb %dl, %cl
jne 0x2311
cmpl $0x0, 0x14(%rsp)
jne 0x2382
movl %eax, %ecx
andb $-0x21, %cl
cmpb $0x45, %cl
jne 0x2382
cmpb $0x2e, %al
cmovel %ebp, %r12d
cmovel %ebp, %r15d
movl %eax, %ecx
andb $-0x21, %cl
xorl %ebx, %ebx
cmpb $0x45, %cl
jne 0x2333
movl %ebp, %ebx
movl %ebp, %r12d
movl %ebp, %r15d
movl %ebp, 0x14(%rsp)
movb %al, 0x20(%rsp,%r13)
cmpq $0x1fe, %r13            # imm = 0x1FE
jb 0x2355
movl 0x3e01(%rip), %esi      # 0x6148
leaq 0x105f(%rip), %rdi      # 0x33ad
xorl %eax, %eax
callq 0x1490
movq 0x18(%rsp), %rax
incl (%rax)
movl 0x10(%rsp), %edi
leaq 0xf(%rsp), %rsi
pushq $0x1
popq %rdx
callq 0x1110
movq (%r14), %rcx
movsbq 0xf(%rsp), %rax
movzwl (%rcx,%rax,2), %ecx
incq %r13
jmp 0x22dd
movl %r13d, %eax
movb $0x0, 0x20(%rsp,%rax)
movzwl 0x20(%rsp), %eax
cmpl $0x2d, %eax
je 0x23a2
cmpl $0x2e, %eax
jne 0x23b6
leaq 0x106b(%rip), %rdi      # 0x340b
jmp 0x23a9
leaq 0x1034(%rip), %rdi      # 0x33dd
movl 0x3d99(%rip), %esi      # 0x6148
xorl %eax, %eax
callq 0x1490
leaq 0x20(%rsp), %rdi
testl %r15d, %r15d
je 0x23d3
callq 0x1080
mulsd 0x3d9b(%rip), %xmm0     # 0x6168
cvttsd2si %xmm0, %eax
jmp 0x23d8
callq 0x11f0
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq