// File: /workspace/github_c_makefile_star2_O2/simh[P]simtools/crossassemblers/macro1/macro1.c
// Function: invokeMacro
int
invokeMacro(int index)
{
    struct macinv *mip;
    struct macdef *mdp;
    int jx;

    mdp = mac_defs[index];
    if (mdp == NULL || mdp->body[0] == '\0')
	return 0;

    /* Find arguments. */
    while (ISBLANK(line[lexstart]))
	next(0);

    mip = calloc(1, sizeof(struct macinv));
    if (!mip) {
	fprintf(stderr, "could not allocate memory for macro invocation\n");
	exit(1);
    }
    mip->defn = mdp;

    /* evaluate args, saving values in SYM_T entries in defn.
     * (cannot have recursive macros)
     */
    mdp->args[0].val = clc;		/* r is location at start */
    for( jx = 1; !ISDONE(line[lexstart]) && jx <= MAC_MAX_ARGS; ) {
	WORD32 val;

	next(0);
	if (ISDONE(line[lexstart]))
	    break;

	if (line[lexstart] == ',')
	    next(0);

	while( ISBLANK( line[lexstart] ))
	    next(0);

	if (ISDONE(line[lexstart]))
	    break;

	val = getExprs();

	/* ignore excess values silently? */
	if (jx <= mdp->nargs)
	    mdp->args[jx].val = val;
	jx++;
    } /* end for */

    /* XXX complain if too few actuals? -- nah */
    while (jx <= mdp->nargs)
	mdp->args[jx++].val = 0;

    strcpy(mip->mac_line, line);	/* save line */
    mip->mac_cc = cc;			/* save position in line */
    mip->mac_ptr = mdp->body;
    mip->prev = curmacro;		/* push the old entry */
    curmacro = mip;			/* step up to the plate! */
    return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movslq %edi, %rax
leaq 0x6c9c(%rip), %rcx      # 0xa050
movq (%rcx,%rax,8), %r12
xorl %eax, %eax
testq %r12, %r12
je 0x3542
cmpb $0x0, 0x1fc(%r12)
je 0x3542
leaq 0x1fc(%r12), %rax
movq %rax, (%rsp)
leaq 0x8c6b(%rip), %r13      # 0xc050
movslq 0x8cc4(%rip), %r15      # 0xc0b0
movzbl (%r15,%r13), %eax
cmpl $0x20, %eax
je 0x33fb
cmpl $0xc, %eax
jne 0x3404
xorl %edi, %edi
callq 0x3575
jmp 0x33e5
pushq $0x1
popq %r14
movl $0x80, %esi
movq %r14, %rdi
callq 0x20e0
testq %rax, %rax
je 0x3551
movq %rax, %rbx
movq %r12, 0x70(%rax)
movl 0x8c89(%rip), %eax      # 0xc0b4
movl %eax, 0x10(%r12)
leaq 0x28(%r12), %rbp
movslq %r15d, %rax
movzbl (%rax,%r13), %eax
cmpq $0x2f, %rax
movabsq $0x100001000, %r15      # imm = 0x100001000
ja 0x3461
movabsq $0x800000000401, %rcx   # imm = 0x800000000401
btq %rax, %rcx
jb 0x34f7
cmpb $0x9, %al
je 0x34f7
cmpq $0x14, %r14
ja 0x34f7
xorl %edi, %edi
callq 0x3575
movslq 0x8c2f(%rip), %rax      # 0xc0b0
movzbl (%rax,%r13), %eax
cmpq $0x2f, %rax
ja 0x34a2
cmpq $0x2c, %rax
je 0x34ba
movabsq $0x800000000601, %rcx   # imm = 0x800000000601
btq %rax, %rcx
jb 0x34f7
movslq 0x8c07(%rip), %rax      # 0xc0b0
movzbl (%rax,%r13), %eax
cmpq $0x2f, %rax
ja 0x34d3
btq %rax, %r15
jae 0x34c3
xorl %edi, %edi
callq 0x3575
jmp 0x34a2
movabsq $0x800000000601, %rcx   # imm = 0x800000000601
btq %rax, %rcx
jb 0x34f7
callq 0x369a
movslq (%r12), %rcx
cmpq %rcx, %r14
jg 0x34e4
movl %eax, (%rbp)
incq %r14
movl 0x8bc2(%rip), %r15d     # 0xc0b0
addq $0x18, %rbp
jmp 0x3435
movslq (%r12), %rax
cmpq %rax, %r14
jg 0x350d
incq %r14
andl $0x0, (%rbp)
addq $0x18, %rbp
jmp 0x34fb
leaq 0x8b3c(%rip), %rsi      # 0xc050
movq %rbx, %rdi
callq 0x2070
movl 0x8b96(%rip), %eax      # 0xc0b8
movl %eax, 0x60(%rbx)
movq (%rsp), %rax
movq %rax, 0x68(%rbx)
movq 0x8b8c(%rip), %rax      # 0xc0c0
movq %rax, 0x78(%rbx)
movq %rbx, 0x8b81(%rip)      # 0xc0c0
pushq $0x1
popq %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x5aa0(%rip), %rax      # 0x8ff8
movq (%rax), %rcx
leaq 0x3143(%rip), %rdi      # 0x66a5
pushq $0x2f
popq %rsi
pushq $0x1
popq %rdx
callq 0x2180
pushq $0x1
popq %rdi
callq 0x2170