// File: /workspace/github_c_makefile_star2_O0/simh[P]simtools/crossassemblers/macro1/macro1.c
// Function: lookup
SYM_T *lookup( char *name, int type )
{
    int ix;				/* Insertion index */
    int lx;				/* Left index */
    int rx;				/* Right index */
    SYM_T *best;			/* best match */
    SYM_T *sym;

    /* YIKES!  Search dummies (and "R") before anything else!! */
    if (curmacro && curmacro->defn) {
	struct macdef *mdp = curmacro->defn;
	int i;

	for (i = 0, sym = mdp->args; i <= mdp->nargs; i++, sym++)
	    if (strcmp(name, sym->name) == 0)
		return sym;
    }

    lx = 0;
    rx = symbol_top - 1;
    best = NULL;
    while (lx <= rx) {
	int mx = (lx + rx) / 2;		/* Find center of search area. */
	int compare;

	sym = symtab + mx;

	compare = strcmp(name, sym->name);
	if (compare < 0)
	    rx = mx - 1;
	else if (compare > 0)
	    lx = mx + 1;
	else {				/* match */
	    if (overbar && !M_DEFINED(sym->type) && pass == 2) {
		sym->type = DEFINED;
		sym->val = vars_addr++;
		nvars++;
	    }
	    return sym;			/* return exact match */
	} /* match */

	/* save best non-exact match; MACRO returns last defined n-x match! */
	if ((M_PSEUDO(sym->type)||M_EPSEUDO(sym->type)||M_MACRO(sym->type)) &&
	    strncmp(name, sym->name, 3) == 0)
	    best = sym;
    } /* while */

    /* return best match (pseudo or macro) if any for lookups (not defns) */
    if (best && type == UNDEFINED)
	return best;

    /* Must put symbol in table if index is negative. */
    ix = lx;				/* insertion point */
    if( symbol_top + 1 >= SYMBOL_TABLE_SIZE ) {
	errorSymbol( &symbol_table_full, name, lexstart );
	exit( 1 );
    }

    for( rx = symbol_top; rx >= ix; rx-- )
	symtab[rx + 1] = symtab[rx];

    symbol_top++;

    /* Enter the symbol as UNDEFINED with a value of zero. */
    sym = symtab + ix;
    strcpy( sym->name, name );
    sym->type = UNDEFINED;
    sym->val  = 0;
    sym->xref_count = 0;
    if( xref && pass == 2 && sym->xref_index >= 0)
	xreftab[sym->xref_index] = 0;

    if (overbar)
	nvars++;

    return sym;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
cmpq $0x0, 0x9859(%rip)      # 0xe0c0
je 0x48e2
movq 0x9850(%rip), %rax      # 0xe0c0
cmpq $0x0, 0x70(%rax)
je 0x48e2
movq 0x9842(%rip), %rax      # 0xe0c0
movq 0x70(%rax), %rax
movq %rax, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
movq -0x38(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x30(%rbp)
movl -0x3c(%rbp), %eax
movq -0x38(%rbp), %rcx
cmpl (%rcx), %eax
jg 0x48e0
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
addq $0x4, %rsi
callq 0x20f0
cmpl $0x0, %eax
jne 0x48c7
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x4b76
jmp 0x48c9
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
movq -0x30(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x30(%rbp)
jmp 0x4899
jmp 0x48e2
movl $0x0, -0x1c(%rbp)
movl 0x7461(%rip), %eax      # 0xbd50
subl $0x1, %eax
movl %eax, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x20(%rbp), %eax
jg 0x4a20
movl -0x1c(%rbp), %eax
addl -0x20(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, -0x40(%rbp)
movq 0x7427(%rip), %rax      # 0xbd48
movslq -0x40(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
addq $0x4, %rsi
callq 0x20f0
movl %eax, -0x44(%rbp)
cmpl $0x0, -0x44(%rbp)
jge 0x4955
movl -0x40(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x49c6
cmpl $0x0, -0x44(%rbp)
jle 0x4966
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x49c4
cmpl $0x0, 0xaa4b(%rip)      # 0xf3b8
je 0x49b7
movq -0x30(%rbp), %rax
movl (%rax), %eax
andl $0x1, %eax
cmpl $0x1, %eax
je 0x49b7
cmpl $0x2, 0x73fc(%rip)      # 0xbd80
jne 0x49b7
movq -0x30(%rbp), %rax
movl $0x1, (%rax)
movl 0xaa26(%rip), %ecx      # 0xf3bc
movl %ecx, %eax
addl $0x1, %eax
movl %eax, 0xaa1b(%rip)      # 0xf3bc
movq -0x30(%rbp), %rax
movl %ecx, 0xc(%rax)
movl 0x97a2(%rip), %eax      # 0xe150
addl $0x1, %eax
movl %eax, 0x9799(%rip)      # 0xe150
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x4b76
jmp 0x49c6
movq -0x30(%rbp), %rax
movl (%rax), %eax
andl $0x43, %eax
cmpl $0x43, %eax
je 0x49f8
movq -0x30(%rbp), %rax
movl (%rax), %eax
andl $0x83, %eax
cmpl $0x83, %eax
je 0x49f8
movq -0x30(%rbp), %rax
movl (%rax), %eax
andl $0x101, %eax            # imm = 0x101
cmpl $0x101, %eax            # imm = 0x101
jne 0x4a1b
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
addq $0x4, %rsi
movl $0x3, %edx
callq 0x2060
cmpl $0x0, %eax
jne 0x4a1b
movq -0x30(%rbp), %rax
movq %rax, -0x28(%rbp)
jmp 0x48fd
cmpq $0x0, -0x28(%rbp)
je 0x4a3a
cmpl $0x0, -0x14(%rbp)
jne 0x4a3a
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x4b76
movl -0x1c(%rbp), %eax
movl %eax, -0x18(%rbp)
movl 0x730a(%rip), %eax      # 0xbd50
addl $0x1, %eax
cmpl $0x2000, %eax           # imm = 0x2000
jl 0x4a70
movq -0x10(%rbp), %rsi
movl 0x9656(%rip), %edx      # 0xe0b0
leaq 0x718f(%rip), %rdi      # 0xbbf0
callq 0x4c10
movl $0x1, %edi
callq 0x2190
movl 0x72da(%rip), %eax      # 0xbd50
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x18(%rbp), %eax
jl 0x4acb
movq 0x72c0(%rip), %rax      # 0xbd48
movl -0x20(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x72a9(%rip), %rcx      # 0xbd48
movslq -0x20(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rax)
movq 0x10(%rcx), %rcx
movq %rcx, 0x10(%rax)
movl -0x20(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x4a79
movl 0x727f(%rip), %eax      # 0xbd50
addl $0x1, %eax
movl %eax, 0x7276(%rip)      # 0xbd50
movq 0x7267(%rip), %rax      # 0xbd48
movslq -0x18(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
addq $0x4, %rdi
movq -0x10(%rbp), %rsi
callq 0x2070
movq -0x30(%rbp), %rax
movl $0x0, (%rax)
movq -0x30(%rbp), %rax
movl $0x0, 0xc(%rax)
movq -0x30(%rbp), %rax
movl $0x0, 0x14(%rax)
movzbl 0x7241(%rip), %eax      # 0xbd69
cmpl $0x0, %eax
je 0x4b56
cmpl $0x2, 0x724c(%rip)      # 0xbd80
jne 0x4b56
movq -0x30(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jl 0x4b56
movq 0x7371(%rip), %rax      # 0xbeb8
movq -0x30(%rbp), %rcx
movslq 0x10(%rcx), %rcx
movl $0x0, (%rax,%rcx,4)
cmpl $0x0, 0xa85b(%rip)      # 0xf3b8
je 0x4b6e
movl 0x95eb(%rip), %eax      # 0xe150
addl $0x1, %eax
movl %eax, 0x95e2(%rip)      # 0xe150
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq