// File: /workspace/github_c_makefile_star2_O2/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 %r14
pushq %rbx
movq %rdi, %rbx
callq 0x50c2
testb %al, %al
je 0x49eb
callq 0x3fb4
movq %rax, %r14
movl (%rax), %ebp
testb $0x1, %bpl
jne 0x4a3f
cmpl $0x2, 0x53b9(%rip)      # 0x9d80
jne 0x4b01
movq %r14, %rsi
addq $0x4, %rsi
movl 0x76d6(%rip), %edx      # 0xc0b0
leaq 0x513f(%rip), %rdi      # 0x9b20
callq 0x3ea0
jmp 0x4b01
callq 0x21b0
movq (%rax), %rcx
movslq 0x76b6(%rip), %rsi      # 0xc0b0
leaq 0x764f(%rip), %r14      # 0xc050
movsbq (%rsi,%r14), %rax
testb $0x8, 0x1(%rcx,%rax,2)
jne 0x4a7e
movzbl %al, %eax
cmpl $0x28, %eax
je 0x4b77
cmpl $0x5b, %eax
je 0x4b39
cmpl $0x3d, %eax
je 0x4b64
cmpl $0x2e, %eax
jne 0x4bb5
movl 0x767a(%rip), %ebp      # 0xc0b4
jmp 0x4bc3
movl %ebp, %eax
notl %eax
testb $0x43, %al
setne %cl
testb $-0x7d, %al
setne %dl
testb %dl, %cl
jne 0x4aba
movl 0xc(%r14), %eax
cmpq $0x7, %rax
ja 0x4c0e
leaq 0x164a(%rip), %rcx      # 0x60b0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0xa, 0x76c7(%rip)      # 0xc140
jmp 0x4be4
movslq 0x76b7(%rip), %rdx      # 0xc13c
movl 0x76b5(%rip), %edi      # 0xc140
xorl %ebp, %ebp
movq %rsi, %rax
cmpq %rdx, %rax
jge 0x4bc3
movsbq (%rax,%r14), %r8
testb $0x8, 0x1(%rcx,%r8,2)
je 0x4b1d
addl $-0x30, %r8d
cmpl %edi, %r8d
jge 0x4b26
incq %rax
imull %edi, %ebp
addl %r8d, %ebp
jmp 0x4a90
testw $0x101, %ax             # imm = 0x101
jne 0x4b01
cmpl $0x2, 0x52b9(%rip)      # 0x9d80
jne 0x4ae5
movq %r14, %rsi
addq $0x4, %rsi
movl 0x75da(%rip), %edx      # 0xc0b0
leaq 0x5053(%rip), %rdi      # 0x9b30
callq 0x3ea0
movl (%r14), %ebp
pushq $0x1
popq %rdi
callq 0x3575
movl %ebp, (%rbx)
movb $0x0, 0x4(%rbx)
andq $0x0, 0xc(%rbx)
andl $0x0, 0x14(%rbx)
jmp 0x4c44
pushq $0x1
popq %rdi
callq 0x3575
movq 0x10(%r14), %rax
movq %rax, 0x10(%rbx)
movups (%r14), %xmm0
movups %xmm0, (%rbx)
jmp 0x4c44
leaq 0x4f9c(%rip), %rdi      # 0x9ac0
jmp 0x4b2f
leaq 0x4fa3(%rip), %rdi      # 0x9ad0
movl %eax, %esi
callq 0x3f76
jmp 0x4bc1
pushq $0x1
popq %rdi
callq 0x3575
callq 0x369a
movl %eax, %ebp
movslq 0x7561(%rip), %rsi      # 0xc0b0
cmpb $0x5d, (%rsi,%r14)
je 0x4bc3
leaq 0x4f33(%rip), %rdi      # 0x9a90
callq 0x45ba
jmp 0x4bcb
leaq 0x4f85(%rip), %rdi      # 0x9af0
callq 0x45ba
callq 0x4689
jmp 0x4bc1
pushq $0x1
popq %rdi
callq 0x3575
callq 0x369a
movl %eax, %ebp
movslq 0x7523(%rip), %rax      # 0xc0b0
cmpb $0x29, (%rax,%r14)
jne 0x4b9c
pushq $0x1
popq %rdi
callq 0x3575
movl %ebp, %edi
callq 0x4c4c
movl $0x1, (%rbx)
movb $0x0, 0x4(%rbx)
movl %eax, 0xc(%rbx)
jmp 0x4c3f
leaq 0x4ed4(%rip), %rdi      # 0x9a90
callq 0x45ba
xorl %ebp, %ebp
pushq $0x1
popq %rdi
callq 0x3575
movl $0x1, (%rbx)
movb $0x0, 0x4(%rbx)
movl %ebp, 0xc(%rbx)
jmp 0x4c3f
movl $0x8, 0x755c(%rip)      # 0xc140
pushq $0x43
popq %rbp
jmp 0x4c2a
pushq $0x1
popq %rbp
movl %ebp, %edi
callq 0x3575
callq 0x47ca
jmp 0x4c09
pushq $0x1
popq %rbp
movl %ebp, %edi
callq 0x3575
callq 0x48b8
movl %eax, %r14d
jmp 0x4c2d
movq %r14, %rsi
addq $0x4, %rsi
movl 0x7495(%rip), %edx      # 0xc0b0
leaq 0x4f2e(%rip), %rdi      # 0x9b50
callq 0x3ea0
movl (%r14), %ebp
xorl %r14d, %r14d
pushq $0x1
popq %rdi
callq 0x3575
movl %ebp, (%rbx)
movb $0x0, 0x4(%rbx)
movl %r14d, 0xc(%rbx)
andq $0x0, 0x10(%rbx)
movq %rbx, %rax
popq %rbx
popq %r14
popq %rbp
retq