// File: /workspace/github_c_makefile_star2_O1/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, 0x3e29(%rip)      # 0x614c
je 0x234c
movl %ebp, 0x3e21(%rip)      # 0x614c
decl %ebp
movsd 0xe1b(%rip), %xmm0      # 0x3150
movl %ebp, %edi
callq 0x1050
addsd 0xe14(%rip), %xmm0      # 0x3158
movsd %xmm0, 0x3e14(%rip)     # 0x6160
movq %rbx, %rdi
callq 0x1160
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %ecx, %ecx
jne 0x24a2
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x21c0
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 0x23d5
testl %r13d, %r13d
setne %al
cmpl $0x2d, %ebp
sete %cl
testb %al, %cl
jne 0x23d5
movl %ebp, %eax
xorl $0x2e, %eax
orl %ebx, %eax
je 0x23d5
movl %ebp, %eax
andl $-0x21, %eax
cmpl $0x45, %eax
jne 0x2440
cmpl $0x0, 0x4(%rsp)
jne 0x2440
cmpl $0x2e, %ebp
movl $0x1, %eax
cmovel %eax, %ebx
cmovel %eax, %r12d
movl %ebp, %eax
andl $-0x21, %eax
xorl %r13d, %r13d
cmpl $0x45, %eax
jne 0x240a
movl $0x1, %r13d
movl $0x1, %ebx
movl $0x1, %r12d
movl $0x1, 0x4(%rsp)
movb %bpl, 0x10(%rsp,%r15)
cmpq $0x1fe, %r15            # imm = 0x1FE
jb 0x242c
movl 0x3d2a(%rip), %esi      # 0x6148
leaq 0xf88(%rip), %rdi       # 0x33ad
xorl %eax, %eax
callq 0x16e0
movq 0x8(%rsp), %rdi
callq 0x10e0
movl %eax, %ebp
incq %r15
jmp 0x239e
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 0x246c
cmpl $0x2e, %eax
jne 0x2480
leaq 0xfa1(%rip), %rdi       # 0x340b
jmp 0x2473
leaq 0xf6a(%rip), %rdi       # 0x33dd
movl 0x3ccf(%rip), %esi      # 0x6148
xorl %eax, %eax
callq 0x16e0
leaq 0x10(%rsp), %rdi
testl %r12d, %r12d
je 0x249d
callq 0x1080
mulsd 0x3cc9(%rip), %xmm0     # 0x6160
cvttsd2si %xmm0, %eax
jmp 0x24a2
callq 0x11f0
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq