// File: /workspace/github_c_makefile_star2_O2/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 $0x228, %rsp            # imm = 0x228
movq %rcx, %r14
movl %edx, %ebp
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x20(%rsp), %rdi
movl $0x200, %edx            # imm = 0x200
xorl %esi, %esi
callq 0x10d0
cmpl %ebp, 0x40c3(%rip)      # 0x614c
je 0x20b2
movl %ebp, 0x40bb(%rip)      # 0x614c
decl %ebp
movsd 0x10b5(%rip), %xmm0     # 0x3150
movl %ebp, %edi
callq 0x1050
addsd 0x10ae(%rip), %xmm0     # 0x3158
movsd %xmm0, 0x40ae(%rip)     # 0x6160
movq %rbx, %rdi
callq 0x1160
testl %eax, %eax
je 0x20c6
pushq $-0x1
popq %rax
jmp 0x21fe
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x1f35
movq %rbx, 0x10(%rsp)
movq %rbx, %rdi
callq 0x10e0
movl %eax, %ebp
pushq $0x1
popq %r14
callq 0x1240
movq %rax, 0x18(%rsp)
xorl %r15d, %r15d
movl %r14d, %ebx
xorl %r13d, %r13d
xorl %r12d, %r12d
movl $0x0, 0xc(%rsp)
movq 0x18(%rsp), %rax
movq (%rax), %rax
movslq %ebp, %rcx
testb $0x8, 0x1(%rax,%rcx,2)
jne 0x2141
testl %ebx, %ebx
setne %al
cmpl $0x2d, %ebp
sete %cl
testb %al, %cl
jne 0x2141
movl %ebp, %eax
xorl $0x2e, %eax
orl %r13d, %eax
je 0x2141
movl %ebp, %eax
andl $-0x21, %eax
cmpl $0x45, %eax
jne 0x219c
cmpl $0x0, 0xc(%rsp)
jne 0x219c
cmpl $0x2e, %ebp
cmovel %r14d, %r13d
cmovel %r14d, %r12d
movl %ebp, %eax
andl $-0x21, %eax
xorl %ebx, %ebx
cmpl $0x45, %eax
jne 0x2166
movl %r14d, %ebx
movl %r14d, %r13d
movl %r14d, %r12d
movl %r14d, 0xc(%rsp)
movb %bpl, 0x20(%rsp,%r15)
cmpq $0x1fe, %r15            # imm = 0x1FE
jb 0x2188
movl 0x3fce(%rip), %esi      # 0x6148
leaq 0x122c(%rip), %rdi      # 0x33ad
xorl %eax, %eax
callq 0x1490
movq 0x10(%rsp), %rdi
callq 0x10e0
movl %eax, %ebp
incq %r15
jmp 0x2105
movl %r15d, %eax
movb $0x0, 0x20(%rsp,%rax)
movl %ebp, %edi
movq 0x10(%rsp), %rsi
callq 0x1190
movzwl 0x20(%rsp), %eax
cmpl $0x2d, %eax
je 0x21c8
cmpl $0x2e, %eax
jne 0x21dc
leaq 0x1245(%rip), %rdi      # 0x340b
jmp 0x21cf
leaq 0x120e(%rip), %rdi      # 0x33dd
movl 0x3f73(%rip), %esi      # 0x6148
xorl %eax, %eax
callq 0x1490
leaq 0x20(%rsp), %rdi
testl %r12d, %r12d
je 0x21f9
callq 0x1080
mulsd 0x3f6d(%rip), %xmm0     # 0x6160
cvttsd2si %xmm0, %eax
jmp 0x21fe
callq 0x11f0
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq