// File: /workspace/github_c_makefile_star2_O1/simh[P]simtools/crossassemblers/macro1/macro1.c
// Function: eval2
SYM_T eval2()
{
  WORD32  digit;
  WORD32  from;
  SYM_T  *sym;
  WORD32  val;
  SYM_T   sym_eval;

  sym_eval.type = DEFINED;
  sym_eval.name[0] = '\0';
  sym_eval.val = sym_eval.xref_index = sym_eval.xref_count = 0;

  val = 0;

  if( isLexSymbol()) {
    sym = evalSymbol();
    if(!M_DEFINED( sym->type )) {
      if( pass == 2 )
        errorSymbol( &undefined_symbol, sym->name, lexstart );
      next(1);
      return( *sym );
    }
    else if( M_PSEUDO(sym->type) || M_EPSEUDO(sym->type)) {
      switch (sym->val) {
      case DECIMAL:
        radix = 10;
	sym_eval.type = PSEUDO;
	sym_eval.val = 0;		/* has zero as a value! */
	break;
      case OCTAL:
        radix = 8;
	sym_eval.type = PSEUDO;
	sym_eval.val = 0;		/* has zero as a value */
	break;
      case FLEX:
	next(1);			/* skip keyword */
	sym_eval.val = flex();
	break;
      case CHAR:
	next(1);			/* skip keyword */
	sym_eval.val = getChar();
	break;
      default:
        errorSymbol( &value_required, sym->name, lexstart );
        sym_eval.type = sym->type;
	sym_eval.val = 0;
	break;
      }
      next(1);
      return( sym_eval );
    }
    else if( M_MACRO( sym->type ))
    {
      if( pass == 2 )
      {
        errorSymbol( &misplaced_symbol, sym->name, lexstart );
      }
      sym_eval.type = sym->type;
      sym_eval.val = 0;
      next(1);
      return( sym_eval );
    }
    else
    {
      next(1);
      return( *sym );
    }
  } /* symbol */
  else if( isdigit( line[lexstart] )) {
    from = lexstart;
    val = 0;
    while( from < lexterm ) {
	if( isdigit( line[from] )) {
	    digit = line[from++] - '0';
	    if( digit >= radix ) {
		errorLexeme( &number_not_radix, from - 1 );
		val = 0;
		break;
	    }
	    val = val * radix + digit;
	}
	else {
	    errorLexeme( &not_a_number, lexstart );
	    val = 0;
	    break;
	}
    }
    next(1);
    sym_eval.val = val;
    return( sym_eval );
  } /* digit */
  else {
    switch( line[lexstart] ) {
    case '.':				/* Value of Current Location Counter */
	val = clc;
	next(1);
	break;
    case '(':				/* Generate literal */
	next(1);			/* Skip paren */
	val = getExprs();		/* recurse */
	if( line[lexstart] == ')' )
	    next(1);			/* Skip end paren */
	sym_eval.val = literal(val);
	return sym_eval;
    case '[':				/* parens!! */
	next(1);
	sym_eval.val = getExprs();	/* mutual recursion */
	if( line[lexstart] == ']' )
	    next(1);			/* Skip close bracket */
	else
	    errorMessage( &illegal_character, lexstart );
	return sym_eval;
    default:
	switch( line[lexstart] ) {
	case '=':
	    errorMessage( &illegal_equals, lexstart );
	    moveToEndOfLine();
	    break;
	default:
	    errorMessage( &illegal_character, lexstart );
	    break;
	} /* error switch */
	val = 0;				/* On error, set value to zero. */
	next(1);				/* Go past illegal character. */
    } /* switch on first char */
  } /* not symbol or number */
  sym_eval.val = val;
  return( sym_eval );
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
callq 0x56bd
testb %al, %al
je 0x4efc
callq 0x4407
movq %rax, %r14
movl (%rax), %eax
testb $0x1, %al
jne 0x4f49
cmpl $0x2, 0x4ea8(%rip)      # 0x9d80
jne 0x5027
movq %r14, %rsi
addq $0x4, %rsi
movl 0x71c5(%rip), %edx      # 0xc0b0
leaq 0x4c2e(%rip), %rdi      # 0x9b20
callq 0x42f3
jmp 0x5027
callq 0x21b0
movq (%rax), %rax
movl 0x71a6(%rip), %ebp      # 0xc0b0
movslq %ebp, %rsi
leaq 0x713c(%rip), %r15      # 0xc050
movsbq (%rsi,%r15), %rcx
testb $0x8, 0x1(%rax,%rcx,2)
jne 0x4f86
movzbl %cl, %eax
cmpl $0x3c, %eax
jg 0x5045
cmpl $0x28, %eax
je 0x509a
cmpl $0x2e, %eax
jne 0x5087
movl 0x7170(%rip), %ebp      # 0xc0b4
jmp 0x5128
notl %eax
testb $0x43, %al
setne %cl
testb $-0x7d, %al
setne %dl
testb %dl, %cl
jne 0x4fd7
movl 0xc(%r14), %eax
cmpq $0x7, %rax
ja 0x519f
leaq 0x1142(%rip), %rcx      # 0x60b0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0xa, 0x71bf(%rip)      # 0xc140
jmp 0x5167
movl 0x71b0(%rip), %edx      # 0xc13c
xorl %r12d, %r12d
cmpl %edx, %ebp
jge 0x51f7
movl 0x71a3(%rip), %ecx      # 0xc140
addq %rsi, %r15
xorl %r12d, %r12d
movl %ebp, %r14d
movsbq (%r15), %rsi
testb $0x8, 0x1(%rax,%rsi,2)
je 0x513d
addl $-0x30, %esi
cmpl %ecx, %esi
jge 0x51d3
imull %ecx, %r12d
addl %esi, %r12d
incl %r14d
incq %r15
cmpl %r14d, %edx
jne 0x4fa6
jmp 0x51f7
testl $0x101, %eax            # imm = 0x101
jne 0x5027
cmpl $0x2, 0x4d9b(%rip)      # 0x9d80
jne 0x5000
movq %r14, %rsi
addq $0x4, %rsi
movl 0x70bc(%rip), %edx      # 0xc0b0
leaq 0x4b35(%rip), %rdi      # 0x9b30
callq 0x42f3
movl (%r14), %ebp
movl $0x1, %edi
callq 0x384a
movl %ebp, (%rbx)
movb $0x0, 0x4(%rbx)
movq $0x0, 0xc(%rbx)
movl $0x0, 0x14(%rbx)
jmp 0x5217
movl $0x1, %edi
callq 0x384a
movq 0x10(%r14), %rax
movq %rax, 0x10(%rbx)
movups (%r14), %xmm0
movups %xmm0, (%rbx)
jmp 0x5217
cmpl $0x3d, %eax
je 0x50dc
cmpl $0x5b, %eax
jne 0x5087
movl $0x1, %edi
callq 0x384a
callq 0x398a
movl %eax, %ebp
movslq 0x7045(%rip), %rsi      # 0xc0b0
cmpb $0x5d, (%rsi,%r15)
je 0x5128
leaq 0x4a13(%rip), %rdi      # 0x9a90
callq 0x4ab6
jmp 0x5132
leaq 0x4a02(%rip), %rdi      # 0x9a90
movl %ebp, %esi
callq 0x4ab6
jmp 0x5126
movl $0x1, %edi
callq 0x384a
callq 0x398a
movl %eax, %ebp
movslq 0x6ffe(%rip), %rax      # 0xc0b0
cmpb $0x29, (%rax,%r15)
jne 0x50c3
movl $0x1, %edi
callq 0x384a
movl %ebp, %edi
callq 0x5227
movl $0x1, (%rbx)
movb $0x0, 0x4(%rbx)
movl %eax, 0xc(%rbx)
jmp 0x520f
leaq 0x4a0d(%rip), %rdi      # 0x9af0
movl %ebp, %esi
callq 0x4ab6
movslq 0x6fc7(%rip), %rax      # 0xc0b8
addq %rax, %r15
movl $0x601, %ecx            # imm = 0x601
movzbl (%r15), %edx
cmpl $0xa, %edx
ja 0x5107
btl %edx, %ecx
jb 0x5114
incl %eax
movl %eax, 0x6fa9(%rip)      # 0xc0b8
incq %r15
jmp 0x50f9
movl %eax, 0x6f96(%rip)      # 0xc0b0
movl %eax, 0x701c(%rip)      # 0xc13c
movl %eax, 0x701e(%rip)      # 0xc144
xorl %ebp, %ebp
movl $0x1, %edi
callq 0x384a
movl $0x1, (%rbx)
jmp 0x51ca
leaq 0x9(%rsp), %r14
movq %r14, %rdi
movl %ebp, %esi
callq 0x42ae
leaq 0x496d(%rip), %rdi      # 0x9ac0
movq %r14, %rsi
movl %ebp, %edx
jmp 0x51ef
movl $0x8, 0x6fd9(%rip)      # 0xc140
movl $0x43, %r14d
jmp 0x51bb
movl $0x1, %r14d
movl $0x1, %edi
callq 0x384a
callq 0x4cc9
jmp 0x519b
movl $0x1, %r14d
movl $0x1, %edi
callq 0x384a
callq 0x4dbd
movl %eax, %ebp
jmp 0x51bd
movq %r14, %rsi
addq $0x4, %rsi
movl 0x6f04(%rip), %edx      # 0xc0b0
leaq 0x499d(%rip), %rdi      # 0x9b50
callq 0x42f3
movl (%r14), %r14d
xorl %ebp, %ebp
movl $0x1, %edi
callq 0x384a
movl %r14d, (%rbx)
movb $0x0, 0x4(%rbx)
movl %ebp, 0xc(%rbx)
jmp 0x520f
leaq 0x2(%rsp), %r15
movq %r15, %rdi
movl %ebp, %esi
callq 0x42ae
leaq 0x48e7(%rip), %rdi      # 0x9ad0
movq %r15, %rsi
movl %r14d, %edx
callq 0x42f3
xorl %r12d, %r12d
movl $0x1, %edi
callq 0x384a
movl $0x1, (%rbx)
movb $0x0, 0x4(%rbx)
movl %r12d, 0xc(%rbx)
movq $0x0, 0x10(%rbx)
movq %rbx, %rax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq