// File: /workspace/github_c_makefile_star2_O0/Edilbert[P]BS9/bs9.c
// Function: ParseRealData
char *ParseRealData(char *p, int ldq)
{

   int v;
   int i,mansize;
   int Sign,Exponent;
   double d;

   mansize = 3; // default mantissa size

   p = SkipSpace(p);
   memset(Operand,0,sizeof(Operand));

   if (*p == '$')
   {
      ++p;
      for (i=0 ; i <= mansize ; ++i, p+=2)
      {
          v = Hex2Byte(p);
          if (v < 0) break;
          Operand[i] = v;
      }
   }
   else
   {
      if (!StrNCaseCmp(p,"cosd(",5))
      {
         d = strtod(p+5,NULL);
         d = cos(M_PI * d / 180.0);
      }
      else d = strtod(p,NULL);
      if (d != 0)
      {
         Sign = 0;
         if (d < 0)
         {
            Sign = 0x80;
            d = -d;
         }
         d = frexp(d,&Exponent);
         Exponent += 0x80;
         if (Exponent < 1 || Exponent > 255)
         {
            ErrorMsg("Exponent %d out of range\n",Exponent);
            ++ErrNum;
            return p+strlen(p);;
         }
         Operand[0] = Exponent;
         d *= 256;
         v = d;
         Operand[1] = (v & 127) | Sign;
         d -= v;

         for (i=2 ; i < 6 ; ++i)
         {
            d *= 256;
            Operand[i] = v = d;
            d -= v;
         }
      }
   }

   // Round

   if (Operand[mansize+1] & 0x80) // rounding bit set
   {
      for (i=mansize ; i > 1 ; --i)
      {
         if (++Operand[i]) break; // no carry
      }
      if (i == 1) // carry was propagated
      {
         if (Operand[1] == 0x7f) // highest positive value
         {
            ++Operand[0];        // Increment exponent
              Operand[1] = 0;
         }
         else if (Operand[1] == 0xff)
         {
            ++Operand[0];        // Increment exponent
              Operand[1] = 0x80;
         }
         else ++Operand[1];
      }
   }

   if (!ldq)
   {
      if (!Pass)
      {
         for (i=0 ; i < mansize+1 ; ++i) PutByte(pc+i,Operand[i]);
         if (ListOn)
         {
            PrintPC();
            fprintf(lf," %2.2x %2.2x%2.2x%2.2x  ",
               Operand[0],Operand[1],Operand[2],Operand[3]);
            fprintf(lf," %s\n",Line);
         }
      }
      pc += mansize+1;
   }
   return p + strlen(p);;
}

// Assembly:
subq $0x48, %rsp
movq %rdi, 0x38(%rsp)
movl %esi, 0x34(%rsp)
movl $0x3, 0x28(%rsp)
movq 0x38(%rsp), %rdi
callq 0x2830
movq %rax, 0x38(%rsp)
leaq 0x82e75(%rip), %rdi     # 0x88050
xorl %esi, %esi
movl $0x100, %edx            # imm = 0x100
callq 0x2160
movq 0x38(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x24, %eax
jne 0x5260
movq 0x38(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x38(%rsp)
movl $0x0, 0x2c(%rsp)
movl 0x2c(%rsp), %eax
cmpl 0x28(%rsp), %eax
jg 0x525b
movq 0x38(%rsp), %rdi
callq 0x5150
movl %eax, 0x30(%rsp)
cmpl $0x0, 0x30(%rsp)
jge 0x522b
jmp 0x525b
movl 0x30(%rsp), %eax
movb %al, %dl
movslq 0x2c(%rsp), %rcx
leaq 0x82e13(%rip), %rax     # 0x88050
movb %dl, (%rax,%rcx)
movl 0x2c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2c(%rsp)
movq 0x38(%rsp), %rax
addq $0x2, %rax
movq %rax, 0x38(%rsp)
jmp 0x520a
jmp 0x5454
movq 0x38(%rsp), %rdi
leaq 0xb0fa(%rip), %rsi      # 0x10366
movl $0x5, %edx
callq 0x2d70
cmpl $0x0, %eax
jne 0x52ba
movq 0x38(%rsp), %rdi
addq $0x5, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x20c0
movsd %xmm0, 0x18(%rsp)
movsd 0xad75(%rip), %xmm0     # 0x10010
mulsd 0x18(%rsp), %xmm0
movsd 0xad5f(%rip), %xmm1     # 0x10008
divsd %xmm1, %xmm0
callq 0x2170
movsd %xmm0, 0x18(%rsp)
jmp 0x52ce
movq 0x38(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x20c0
movsd %xmm0, 0x18(%rsp)
movsd 0x18(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x52e4
jp 0x52e4
jmp 0x5452
movl $0x0, 0x24(%rsp)
xorps %xmm0, %xmm0
ucomisd 0x18(%rsp), %xmm0
jbe 0x5322
movl $0x80, 0x24(%rsp)
movsd 0x18(%rsp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x18(%rsp), %xmm0
leaq 0x20(%rsp), %rdi
callq 0x21a0
movsd %xmm0, 0x18(%rsp)
movl 0x20(%rsp), %eax
addl $0x80, %eax
movl %eax, 0x20(%rsp)
cmpl $0x1, 0x20(%rsp)
jl 0x5356
cmpl $0xff, 0x20(%rsp)
jle 0x53a0
movl 0x20(%rsp), %esi
leaq 0xb00b(%rip), %rdi      # 0x1036c
movb $0x0, %al
callq 0x3150
movl 0x2369e(%rip), %eax     # 0x28a0c
addl $0x1, %eax
movl %eax, 0x23695(%rip)     # 0x28a0c
movq 0x38(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x38(%rsp), %rdi
callq 0x20f0
movq %rax, %rcx
movq 0x10(%rsp), %rax
addq %rcx, %rax
movq %rax, 0x40(%rsp)
jmp 0x560a
movl 0x20(%rsp), %eax
movb %al, 0x82ca6(%rip)      # 0x88050
movsd 0xac66(%rip), %xmm0     # 0x10018
mulsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
cvttsd2si 0x18(%rsp), %eax
movl %eax, 0x30(%rsp)
movl 0x30(%rsp), %eax
andl $0x7f, %eax
orl 0x24(%rsp), %eax
movb %al, 0x82c78(%rip)      # 0x88051
cvtsi2sdl 0x30(%rsp), %xmm1
movsd 0x18(%rsp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, 0x18(%rsp)
movl $0x2, 0x2c(%rsp)
cmpl $0x6, 0x2c(%rsp)
jge 0x5450
movsd 0xac12(%rip), %xmm0     # 0x10018
mulsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
cvttsd2si 0x18(%rsp), %eax
movl %eax, 0x30(%rsp)
movb %al, %dl
movslq 0x2c(%rsp), %rcx
leaq 0x82c26(%rip), %rax     # 0x88050
movb %dl, (%rax,%rcx)
cvtsi2sdl 0x30(%rsp), %xmm1
movsd 0x18(%rsp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, 0x18(%rsp)
movl 0x2c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2c(%rsp)
jmp 0x53f7
jmp 0x5452
jmp 0x5454
movl 0x28(%rsp), %eax
addl $0x1, %eax
movslq %eax, %rcx
leaq 0x82beb(%rip), %rax     # 0x88050
movzbl (%rax,%rcx), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x5519
movl 0x28(%rsp), %eax
movl %eax, 0x2c(%rsp)
cmpl $0x1, 0x2c(%rsp)
jle 0x54b6
movslq 0x2c(%rsp), %rdx
leaq 0x82bbe(%rip), %rax     # 0x88050
movb (%rax,%rdx), %al
addb $0x1, %al
leaq 0x82bb2(%rip), %rcx     # 0x88050
movb %al, (%rcx,%rdx)
cmpb $0x0, %al
je 0x54a7
jmp 0x54b6
jmp 0x54a9
movl 0x2c(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x2c(%rsp)
jmp 0x547f
cmpl $0x1, 0x2c(%rsp)
jne 0x5517
movzbl 0x82b8d(%rip), %eax     # 0x88051
cmpl $0x7f, %eax
jne 0x54e0
movb 0x82b81(%rip), %al      # 0x88050
addb $0x1, %al
movb %al, 0x82b79(%rip)      # 0x88050
movb $0x0, 0x82b73(%rip)     # 0x88051
jmp 0x5515
movzbl 0x82b6a(%rip), %eax     # 0x88051
cmpl $0xff, %eax
jne 0x5505
movb 0x82b5c(%rip), %al      # 0x88050
addb $0x1, %al
movb %al, 0x82b54(%rip)      # 0x88050
movb $-0x80, 0x82b4e(%rip)   # 0x88051
jmp 0x5513
movb 0x82b46(%rip), %al      # 0x88051
addb $0x1, %al
movb %al, 0x82b3e(%rip)      # 0x88051
jmp 0x5515
jmp 0x5517
jmp 0x5519
cmpl $0x0, 0x34(%rsp)
jne 0x55e6
cmpl $0x0, 0x234cd(%rip)     # 0x289f8
jne 0x55d3
movl $0x0, 0x2c(%rsp)
movl 0x2c(%rsp), %eax
movl 0x28(%rsp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jge 0x5574
movl 0x121c6(%rip), %edi     # 0x17714
addl 0x2c(%rsp), %edi
movslq 0x2c(%rsp), %rcx
leaq 0x82af2(%rip), %rax     # 0x88050
movzbl (%rax,%rcx), %esi
callq 0x23f0
movl 0x2c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2c(%rsp)
jmp 0x5539
cmpl $0x0, 0xfc1d(%rip)      # 0x15198
je 0x55d1
callq 0x3350
movq 0x2345f(%rip), %rdi     # 0x289e8
movzbl 0x82ac0(%rip), %edx     # 0x88050
movzbl 0x82aba(%rip), %ecx     # 0x88051
movzbl 0x82ab3(%rip), %r8d     # 0x88052
movzbl 0x82aac(%rip), %r9d     # 0x88053
leaq 0xadd8(%rip), %rsi      # 0x10386
movb $0x0, %al
callq 0x21e0
movq 0x2342c(%rip), %rdi     # 0x289e8
leaq 0xabc8(%rip), %rsi      # 0x1018b
leaq 0x228b6(%rip), %rdx     # 0x27e80
movb $0x0, %al
callq 0x21e0
jmp 0x55d3
movl 0x28(%rsp), %eax
addl $0x1, %eax
addl 0x12134(%rip), %eax     # 0x17714
movl %eax, 0x1212e(%rip)     # 0x17714
movq 0x38(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x38(%rsp), %rdi
callq 0x20f0
movq %rax, %rcx
movq 0x8(%rsp), %rax
addq %rcx, %rax
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rax
addq $0x48, %rsp
retq
nopw %cs:(%rax,%rax)