// File: /workspace/github_c_makefile_star2_O0/AK6DN[P]dec-utilities-for-pdp/palbart/palbart.c
// Function: evalFltg
FLTG_T *evalFltg()
{
  int      current_state;
  int      current_col;
  WORD16   exponent;
  FLTG_T  *fltg;
  WORD32   input_value;
  BOOL     negate;
  BOOL     negate_exponent;
  int      next_state;
  int      right_digits;

  /* This uses a lexical analyzer to parse the floating point format.         */
  static BYTE state_table[][10] =
  {
    /*  0   1   2   3   4   5   6  Oolumn index                               */
    /*  +   -   d   .   E  sp   p      State  Comment                         */
     {  2,  1,  3,  4, 10, 10, 10  },  /*  0  Initial state.                  */
     { 11, 11,  3,  4, 11, 11, 11  },  /*  1  -                               */
     { 11, 11,  3,  4, 11, 11, 11  },  /*  2  +                               */
     { 10, 10, 10,  4,  6, 10, 10  },  /*  3  # (+-ddd)                       */
     { 11, 11,  5, 11, 11, 10, 10  },  /*  4  . (+-ddd.)                      */
     { 11, 11, 11, 11,  6, 10, 11  },  /*  5  # (+-ddd.ddd)                   */
     {  8,  7,  9, 11, 11, 11, 11  },  /*  6  E (+-ddd.dddE)                  */
     { 11, 11,  9, 11, 11, 11, 11  },  /*  7  - (+-ddd.dddE-                  */
     { 11, 11,  9, 11, 11, 11, 11  },  /*  8  + (+-ddd.dddE+                  */
     { 11, 11, 11, 11, 11, 10, 11  }   /*  9  # (+-ddd.dddE+-dd               */
                                       /* 10  Completion state                */
                                       /* 11  Error state.                    */
  };

  delimiter = line[lexterm];
  fltg = &fltg_ac;
  fltg->exponent = 0;
  fltg->mantissa = 0;
  input_value = 0;
  negate = FALSE;
  negate_exponent = FALSE;
  next_state = 0;
  exponent = 0;
  right_digits = 0;
  current_state = 0;

  while( TRUE )
  {
    /* Classify character.  This is the column index.                         */
    switch( line[lexstart] )
    {
    case '+':
      current_col = 0;
      break;

    case '-':
      current_col = 1;
      break;

    case '.':
      current_col = 3;
      break;

    case 'E':  case 'e':
      current_col = 4;
      break;

    default:
      if( isdigit( line[lexstart] ))
      {
        current_col = 2;
      }
      else if( isdone( line[lexstart] ))
      {
        current_col = 5;
      }
      else
      {
        current_col = 6;
      }
      break;
    }

    next_state = state_table[current_state][current_col];

    switch( next_state )
    {
    case 1:                             /*  -                                 */
      negate = TRUE;
    case 2:                             /*  +                                 */
      delimiter = line[lexterm];        /* Move past the + or - character.    */
      nextLexBlank();
      break;

    case 3:                             /* Number  (+-ddd)                    */
      input_value = evalDubl( 0 );      /* Integer part of the number.        */
      nextLexeme();                     /* Move past previous lexeme.         */
      break;

    case 4:
      delimiter = line[lexterm];
      nextLexBlank();                   /* Move past the . character.         */
      break;

    case 5:                             /* .  (+-ddd.ddd)                     */
                                        /* Fractional part of the number.     */
      input_value = evalDubl( input_value );
      right_digits = lexterm - lexstart;/* Digit count to right of decimal.   */
      nextLexeme();                     /* Move past previous lexeme.         */
      break;

    case 6:                             /* E  (+-ddd.dddE)                    */
      delimiter = line[lexterm];        /* Move past the E.                   */
      nextLexBlank();
      break;

    case 7:                             /* -  (+-ddd.dddE-)                   */
      negate_exponent = TRUE;
    case 8:                             /* +  (+-ddd.dddE+)                   */
      delimiter = line[lexterm];        /* Move past the + or - character.    */
      nextLexBlank();
      break;

    case 9:                             /* #  (+-ddd.dddE+-dd)                */
      exponent = (int)evalDubl( 0 );    /* Exponent of floating point number. */
      if( negate_exponent ) { exponent = - exponent; }
      nextLexeme();                     /* Move past previous lexeme.         */
      break;

    case 10:                            /* Floating number parsed, convert    */
                                        /* the number.                        */
      /* Get the exponent for the number as input.                            */
      exponent -= right_digits;

      /* Remove trailing zeros and adjust the exponent accordingly.           */
      while(( input_value % 10 ) == 0 )
      {
        input_value /= 10;
        exponent++;
      }

      /* Convert the number to floating point.  The number is calculated with */
      /* a 27 bit mantissa to improve precision.  The extra 3 bits are        */
      /* discarded after the result has been calculated.                      */
      fltg->exponent = 26;
      fltg->mantissa = input_value << 3;
      normalizeFltg( fltg );


      while( exponent != 0 )
      {
        if( exponent < 0 )
        {
          /* Decimal point is to the left. */
          fltg->mantissa /= 10;
          normalizeFltg( fltg );
          exponent++;
        }
        else if( exponent > 0 )
        {
          /* Decimal point is to the right. */
          fltg->mantissa *= 10;
          normalizeFltg( fltg );
          exponent--;
        }
      }

      /* Discard the extra precsion used for calculating the number.          */
      fltg->mantissa >>= 3;
      fltg->exponent -= 3;
      if( negate )
      {
        fltg->mantissa = (- fltg->mantissa ) & 077777777L;
      }
      return( fltg );

    case 11:                            /* Error in format.                   */
      /* Not a properly constructued floating point number.                   */
      return( fltg );
    default:
      break;
    }
    /* Set state for next pass through the loop.                              */
    current_state = next_state;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movslq 0x7ebd(%rip), %rcx      # 0xf87c
leaq 0x7e2a(%rip), %rax      # 0xf7f0
movb (%rax,%rcx), %al
movb %al, 0x7eb1(%rip)       # 0xf880
leaq 0x7ec2(%rip), %rax      # 0xf898
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movw $0x0, (%rax)
movq -0x20(%rbp), %rax
movq $0x0, 0x8(%rax)
movq $0x0, -0x28(%rbp)
movb $0x0, -0x29(%rbp)
movb $0x0, -0x2a(%rbp)
movl $0x0, -0x30(%rbp)
movw $0x0, -0x12(%rbp)
movl $0x0, -0x34(%rbp)
movl $0x0, -0xc(%rbp)
movslq 0x7e53(%rip), %rax      # 0xf874
leaq 0x7dc8(%rip), %rcx      # 0xf7f0
movsbl (%rax,%rcx), %eax
movl %eax, -0x38(%rbp)
subl $0x2b, %eax
je 0x7a5e
jmp 0x7a36
movl -0x38(%rbp), %eax
subl $0x2d, %eax
je 0x7a6a
jmp 0x7a40
movl -0x38(%rbp), %eax
subl $0x2e, %eax
je 0x7a76
jmp 0x7a4a
movl -0x38(%rbp), %eax
subl $0x45, %eax
je 0x7a82
jmp 0x7a54
movl -0x38(%rbp), %eax
subl $0x65, %eax
je 0x7a82
jmp 0x7a8e
movl $0x0, -0x10(%rbp)
jmp 0x7b32
movl $0x1, -0x10(%rbp)
jmp 0x7b32
movl $0x3, -0x10(%rbp)
jmp 0x7b32
movl $0x4, -0x10(%rbp)
jmp 0x7b32
callq 0x21b0
movq (%rax), %rax
movslq 0x7dd7(%rip), %rdx      # 0xf874
leaq 0x7d4c(%rip), %rcx      # 0xf7f0
movsbl (%rcx,%rdx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0x7ac2
movl $0x2, -0x10(%rbp)
jmp 0x7b30
movslq 0x7dab(%rip), %rcx      # 0xf874
leaq 0x7d20(%rip), %rax      # 0xf7f0
movsbl (%rax,%rcx), %eax
cmpl $0x2f, %eax
je 0x7b1e
movslq 0x7d94(%rip), %rcx      # 0xf874
leaq 0x7d09(%rip), %rax      # 0xf7f0
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
je 0x7b1e
movslq 0x7d7d(%rip), %rcx      # 0xf874
leaq 0x7cf2(%rip), %rax      # 0xf7f0
movsbl (%rax,%rcx), %eax
cmpl $0xa, %eax
je 0x7b1e
movslq 0x7d66(%rip), %rcx      # 0xf874
leaq 0x7cdb(%rip), %rax      # 0xf7f0
movsbl (%rax,%rcx), %eax
cmpl $0x3b, %eax
jne 0x7b27
movl $0x5, -0x10(%rbp)
jmp 0x7b2e
movl $0x6, -0x10(%rbp)
jmp 0x7b30
jmp 0x7b32
movslq -0xc(%rbp), %rax
leaq (%rax,%rax,4), %rcx
leaq 0x57cf(%rip), %rax      # 0xd310
leaq (%rax,%rcx,2), %rcx
movslq -0x10(%rbp), %rax
movzbl (%rax,%rcx), %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x40(%rbp)
subl $0xa, %eax
ja 0x7d96
movq -0x40(%rbp), %rax
leaq 0x1755(%rip), %rcx      # 0x92c4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movb $0x1, -0x29(%rbp)
movslq 0x7cf9(%rip), %rcx      # 0xf87c
leaq 0x7c66(%rip), %rax      # 0xf7f0
movb (%rax,%rcx), %al
movb %al, 0x7ced(%rip)       # 0xf880
callq 0x51a0
jmp 0x7d98
xorl %eax, %eax
movl %eax, %edi
callq 0x7470
movq %rax, -0x28(%rbp)
callq 0x4330
jmp 0x7d98
movslq 0x7cc1(%rip), %rcx      # 0xf87c
leaq 0x7c2e(%rip), %rax      # 0xf7f0
movb (%rax,%rcx), %al
movb %al, 0x7cb5(%rip)       # 0xf880
callq 0x51a0
jmp 0x7d98
movq -0x28(%rbp), %rdi
callq 0x7470
movq %rax, -0x28(%rbp)
movl 0x7c94(%rip), %eax      # 0xf87c
subl 0x7c86(%rip), %eax      # 0xf874
movl %eax, -0x34(%rbp)
callq 0x4330
jmp 0x7d98
movslq 0x7c7a(%rip), %rcx      # 0xf87c
leaq 0x7be7(%rip), %rax      # 0xf7f0
movb (%rax,%rcx), %al
movb %al, 0x7c6e(%rip)       # 0xf880
callq 0x51a0
jmp 0x7d98
movb $0x1, -0x2a(%rbp)
movslq 0x7c55(%rip), %rcx      # 0xf87c
leaq 0x7bc2(%rip), %rax      # 0xf7f0
movb (%rax,%rcx), %al
movb %al, 0x7c49(%rip)       # 0xf880
callq 0x51a0
jmp 0x7d98
xorl %eax, %eax
movl %eax, %edi
callq 0x7470
movw %ax, -0x12(%rbp)
cmpb $0x0, -0x2a(%rbp)
je 0x7c60
movswl -0x12(%rbp), %ecx
xorl %eax, %eax
subl %ecx, %eax
movw %ax, -0x12(%rbp)
callq 0x4330
jmp 0x7d98
movl -0x34(%rbp), %ecx
movswl -0x12(%rbp), %eax
subl %ecx, %eax
movw %ax, -0x12(%rbp)
movq -0x28(%rbp), %rax
movl $0xa, %ecx
cqto
idivq %rcx
cmpq $0x0, %rdx
jne 0x7cab
movq -0x28(%rbp), %rax
movl $0xa, %ecx
cqto
idivq %rcx
movq %rax, -0x28(%rbp)
movw -0x12(%rbp), %ax
addw $0x1, %ax
movw %ax, -0x12(%rbp)
jmp 0x7c77
movq -0x20(%rbp), %rax
movw $0x1a, (%rax)
movq -0x28(%rbp), %rcx
shlq $0x3, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rdi
callq 0x7db0
movswl -0x12(%rbp), %eax
cmpl $0x0, %eax
je 0x7d46
movswl -0x12(%rbp), %eax
cmpl $0x0, %eax
jge 0x7d17
movq -0x20(%rbp), %rax
movq %rax, -0x48(%rbp)
movq 0x8(%rax), %rax
movl $0xa, %ecx
cqto
idivq %rcx
movq %rax, %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rdi
callq 0x7db0
movw -0x12(%rbp), %ax
addw $0x1, %ax
movw %ax, -0x12(%rbp)
jmp 0x7d44
movswl -0x12(%rbp), %eax
cmpl $0x0, %eax
jle 0x7d42
movq -0x20(%rbp), %rax
imulq $0xa, 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rdi
callq 0x7db0
movw -0x12(%rbp), %ax
addw $-0x1, %ax
movw %ax, -0x12(%rbp)
jmp 0x7d44
jmp 0x7ccd
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rcx
sarq $0x3, %rcx
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rax
movswl (%rax), %ecx
subl $0x3, %ecx
movw %cx, (%rax)
cmpb $0x0, -0x29(%rbp)
je 0x7d82
movq -0x20(%rbp), %rax
xorl %ecx, %ecx
subq 0x8(%rax), %rcx
andq $0xffffff, %rcx         # imm = 0xFFFFFF
movq -0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x7da3
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x7da3
jmp 0x7d98
movl -0x30(%rbp), %eax
movl %eax, -0xc(%rbp)
jmp 0x7a1a
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)