// File: /workspace/github_c_makefile_star2_O3/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 0x5721
testb %al, %al
je 0x4f59
callq 0x4467
movq %rax, %r14
movl (%rax), %ebp
testb $0x1, %bpl
jne 0x4fa6
cmpl $0x2, 0x4e4b(%rip)      # 0x9d80
jne 0x5086
movq %r14, %rsi
addq $0x4, %rsi
movl 0x7168(%rip), %edx      # 0xc0b0
leaq 0x4bd1(%rip), %rdi      # 0x9b20
callq 0x4353
jmp 0x5086
callq 0x21b0
movq (%rax), %rax
movl 0x7149(%rip), %ebp      # 0xc0b0
movslq %ebp, %rsi
leaq 0x70df(%rip), %r15      # 0xc050
movsbq (%rsi,%r15), %rcx
testb $0x8, 0x1(%rax,%rcx,2)
jne 0x4fe5
movzbl %cl, %eax
cmpl $0x3c, %eax
jg 0x50a4
cmpl $0x28, %eax
je 0x50f9
cmpl $0x2e, %eax
jne 0x50e6
movl 0x7113(%rip), %ebp      # 0xc0b4
jmp 0x5187
movl %ebp, %eax
notl %eax
testb $0x43, %al
setne %cl
testb $-0x7d, %al
setne %dl
testb %dl, %cl
jne 0x5036
movl 0xc(%r14), %eax
cmpq $0x7, %rax
ja 0x51fe
leaq 0x10e3(%rip), %rcx      # 0x60b0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0xa, 0x7160(%rip)      # 0xc140
jmp 0x51c6
movl 0x7151(%rip), %edx      # 0xc13c
xorl %r12d, %r12d
cmpl %edx, %ebp
jge 0x5256
movl 0x7144(%rip), %ecx      # 0xc140
addq %rsi, %r15
xorl %r12d, %r12d
movl %ebp, %r14d
movsbq (%r15), %rsi
testb $0x8, 0x1(%rax,%rsi,2)
je 0x519c
addl $-0x30, %esi
cmpl %ecx, %esi
jge 0x5232
imull %ecx, %r12d
addl %esi, %r12d
incl %r14d
incq %r15
cmpl %r14d, %edx
jne 0x5005
jmp 0x5256
testl $0x101, %eax            # imm = 0x101
jne 0x5086
cmpl $0x2, 0x4d3c(%rip)      # 0x9d80
jne 0x5062
movq %r14, %rsi
addq $0x4, %rsi
movl 0x705d(%rip), %edx      # 0xc0b0
leaq 0x4ad6(%rip), %rdi      # 0x9b30
callq 0x4353
movl (%r14), %ebp
movl $0x1, %edi
callq 0x3911
movl %ebp, (%rbx)
movb $0x0, 0x4(%rbx)
movq $0x0, 0xc(%rbx)
movl $0x0, 0x14(%rbx)
jmp 0x5276
movl $0x1, %edi
callq 0x3911
movq 0x10(%r14), %rax
movq %rax, 0x10(%rbx)
movups (%r14), %xmm0
movups %xmm0, (%rbx)
jmp 0x5276
cmpl $0x3d, %eax
je 0x513b
cmpl $0x5b, %eax
jne 0x50e6
movl $0x1, %edi
callq 0x3911
callq 0x3a39
movl %eax, %ebp
movslq 0x6fe6(%rip), %rsi      # 0xc0b0
cmpb $0x5d, (%rsi,%r15)
je 0x5187
leaq 0x49b4(%rip), %rdi      # 0x9a90
callq 0x4b12
jmp 0x5191
leaq 0x49a3(%rip), %rdi      # 0x9a90
movl %ebp, %esi
callq 0x4b12
jmp 0x5185
movl $0x1, %edi
callq 0x3911
callq 0x3a39
movl %eax, %ebp
movslq 0x6f9f(%rip), %rax      # 0xc0b0
cmpb $0x29, (%rax,%r15)
jne 0x5122
movl $0x1, %edi
callq 0x3911
movl %ebp, %edi
callq 0x5286
movl $0x1, (%rbx)
movb $0x0, 0x4(%rbx)
movl %eax, 0xc(%rbx)
jmp 0x526e
leaq 0x49ae(%rip), %rdi      # 0x9af0
movl %ebp, %esi
callq 0x4b12
movslq 0x6f68(%rip), %rax      # 0xc0b8
addq %rax, %r15
movl $0x601, %ecx            # imm = 0x601
movzbl (%r15), %edx
cmpl $0xa, %edx
ja 0x5166
btl %edx, %ecx
jb 0x5173
incl %eax
movl %eax, 0x6f4a(%rip)      # 0xc0b8
incq %r15
jmp 0x5158
movl %eax, 0x6f37(%rip)      # 0xc0b0
movl %eax, 0x6fbd(%rip)      # 0xc13c
movl %eax, 0x6fbf(%rip)      # 0xc144
xorl %ebp, %ebp
movl $0x1, %edi
callq 0x3911
movl $0x1, (%rbx)
jmp 0x5229
leaq 0x9(%rsp), %r14
movq %r14, %rdi
movl %ebp, %esi
callq 0x430e
leaq 0x490e(%rip), %rdi      # 0x9ac0
movq %r14, %rsi
movl %ebp, %edx
jmp 0x524e
movl $0x8, 0x6f7a(%rip)      # 0xc140
movl $0x43, %r14d
jmp 0x521a
movl $0x1, %r14d
movl $0x1, %edi
callq 0x3911
callq 0x4d33
jmp 0x51fa
movl $0x1, %r14d
movl $0x1, %edi
callq 0x3911
callq 0x4e1c
movl %eax, %ebp
jmp 0x521c
movq %r14, %rsi
addq $0x4, %rsi
movl 0x6ea5(%rip), %edx      # 0xc0b0
leaq 0x493e(%rip), %rdi      # 0x9b50
callq 0x4353
movl (%r14), %r14d
xorl %ebp, %ebp
movl $0x1, %edi
callq 0x3911
movl %r14d, (%rbx)
movb $0x0, 0x4(%rbx)
movl %ebp, 0xc(%rbx)
jmp 0x526e
leaq 0x2(%rsp), %r15
movq %r15, %rdi
movl %ebp, %esi
callq 0x430e
leaq 0x4888(%rip), %rdi      # 0x9ad0
movq %r15, %rsi
movl %r14d, %edx
callq 0x4353
xorl %r12d, %r12d
movl $0x1, %edi
callq 0x3911
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