// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x240, %rsp            # imm = 0x240
movl %edi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
leaq -0x220(%rbp), %rdi
xorl %esi, %esi
movl $0x200, %edx            # imm = 0x200
callq 0x10b0
movl 0x4642(%rip), %eax      # 0x7130
cmpl -0xc(%rbp), %eax
je 0x2b27
movl -0xc(%rbp), %eax
movl %eax, 0x4634(%rip)      # 0x7130
movl -0xc(%rbp), %eax
subl $0x1, %eax
cvtsi2sd %eax, %xmm1
movsd 0x162a(%rip), %xmm0     # 0x4138
callq 0x1060
movsd 0x156d(%rip), %xmm1     # 0x4088
subsd %xmm1, %xmm0
movsd %xmm0, 0x4621(%rip)     # 0x7148
movl $0x1, -0x228(%rbp)
movl $0x0, -0x22c(%rbp)
movl $0x0, -0x230(%rbp)
movl $0x0, -0x234(%rbp)
movq -0x18(%rbp), %rax
movl $0x1, (%rax)
movl -0x8(%rbp), %edi
leaq -0x19(%rbp), %rsi
movl $0x1, %edx
callq 0x10e0
callq 0x1200
movq (%rax), %rax
movsbl -0x19(%rbp), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
je 0x2ba5
movl -0x8(%rbp), %edi
leaq -0x19(%rbp), %rsi
movl $0x1, %edx
callq 0x10e0
movq -0x18(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
jmp 0x2b6a
movl $0x0, -0x224(%rbp)
callq 0x1200
movq (%rax), %rax
movsbl -0x19(%rbp), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %ecx
andl $0x800, %ecx            # imm = 0x800
movb $0x1, %al
cmpl $0x0, %ecx
movb %al, -0x235(%rbp)
jne 0x2c53
cmpl $0x0, -0x228(%rbp)
je 0x2bef
movsbl -0x19(%rbp), %ecx
movb $0x1, %al
cmpl $0x2d, %ecx
movb %al, -0x235(%rbp)
je 0x2c53
cmpl $0x0, -0x22c(%rbp)
jne 0x2c09
movsbl -0x19(%rbp), %ecx
movb $0x1, %al
cmpl $0x2e, %ecx
movb %al, -0x235(%rbp)
je 0x2c53
xorl %eax, %eax
cmpl $0x0, -0x234(%rbp)
movb %al, -0x236(%rbp)
jne 0x2c47
movsbl -0x19(%rbp), %ecx
movb $0x1, %al
cmpl $0x45, %ecx
movb %al, -0x237(%rbp)
je 0x2c3b
movsbl -0x19(%rbp), %eax
cmpl $0x65, %eax
sete %al
movb %al, -0x237(%rbp)
movb -0x237(%rbp), %al
movb %al, -0x236(%rbp)
movb -0x236(%rbp), %al
movb %al, -0x235(%rbp)
movb -0x235(%rbp), %al
testb $0x1, %al
jne 0x2c62
jmp 0x2d24
movl $0x0, -0x228(%rbp)
movsbl -0x19(%rbp), %eax
cmpl $0x2e, %eax
jne 0x2c89
movl $0x1, -0x22c(%rbp)
movl $0x1, -0x230(%rbp)
movsbl -0x19(%rbp), %eax
cmpl $0x45, %eax
je 0x2c9b
movsbl -0x19(%rbp), %eax
cmpl $0x65, %eax
jne 0x2cc3
movl $0x1, -0x22c(%rbp)
movl $0x1, -0x230(%rbp)
movl $0x1, -0x234(%rbp)
movl $0x1, -0x228(%rbp)
movb -0x19(%rbp), %cl
movl -0x224(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x224(%rbp)
cltq
movb %cl, -0x220(%rbp,%rax)
movslq -0x224(%rbp), %rax
cmpq $0x1ff, %rax            # imm = 0x1FF
jb 0x2d03
movl 0x4433(%rip), %esi      # 0x7128
leaq 0x1681(%rip), %rdi      # 0x437d
movb $0x0, %al
callq 0x1580
movq -0x18(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movl -0x8(%rbp), %edi
leaq -0x19(%rbp), %rsi
movl $0x1, %edx
callq 0x10e0
jmp 0x2baf
movslq -0x224(%rbp), %rax
movb $0x0, -0x220(%rbp,%rax)
leaq -0x220(%rbp), %rdi
leaq 0x166c(%rip), %rsi      # 0x43ad
callq 0x10f0
cmpl $0x0, %eax
jne 0x2d61
movl 0x43d7(%rip), %esi      # 0x7128
leaq 0x1657(%rip), %rdi      # 0x43af
movb $0x0, %al
callq 0x1580
jmp 0x2d8f
leaq -0x220(%rbp), %rdi
leaq 0x166e(%rip), %rsi      # 0x43dd
callq 0x10f0
cmpl $0x0, %eax
jne 0x2d8d
movl 0x43a9(%rip), %esi      # 0x7128
leaq 0x1659(%rip), %rdi      # 0x43df
movb $0x0, %al
callq 0x1580
jmp 0x2d8f
cmpl $0x0, -0x230(%rbp)
je 0x2db5
leaq -0x220(%rbp), %rdi
callq 0x1050
mulsd 0x439c(%rip), %xmm0     # 0x7148
cvttsd2si %xmm0, %eax
movl %eax, -0x4(%rbp)
jmp 0x2dc4
leaq -0x220(%rbp), %rdi
callq 0x11c0
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x240, %rsp            # imm = 0x240
popq %rbp
retq