// File: /workspace/github_c_makefile_star2_O3/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
subq $0x18, %rsp
movslq %edi, %rax
leaq 0x69f0(%rip), %rcx      # 0xa050
movq (%rcx,%rax,8), %r12
xorl %eax, %eax
testq %r12, %r12
je 0x38fd
cmpb $0x0, 0x1fc(%r12)
je 0x38fd
leaq 0x1fc(%r12), %rax
movq %rax, 0x10(%rsp)
leaq 0x89be(%rip), %r13      # 0xc050
movslq 0x8a17(%rip), %rbx      # 0xc0b0
movzbl (%rbx,%r13), %eax
cmpl $0x20, %eax
je 0x36a8
cmpl $0xc, %eax
jne 0x36b1
xorl %edi, %edi
callq 0x3911
jmp 0x3692
movl $0x1, %edi
movl $0x80, %esi
callq 0x20e0
testq %rax, %rax
je 0x390c
movq %rax, 0x8(%rsp)
movq %r12, 0x70(%rax)
movl 0x89dc(%rip), %eax      # 0xc0b4
movl %eax, 0x10(%r12)
leaq 0x70(%r12), %r15
movq $-0x2, %rbp
movl $0x2, %r14d
movslq %ebx, %rax
movzbl (%rax,%r13), %eax
cmpq $0x2f, %rax
ja 0x3711
movabsq $0x800000000401, %rcx   # imm = 0x800000000401
btq %rax, %rcx
jb 0x37b8
cmpb $0x9, %al
je 0x37b8
leaq 0x3(%rbp), %rbx
cmpq $0x14, %rbx
ja 0x37b8
xorl %edi, %edi
callq 0x3911
movslq 0x897b(%rip), %rax      # 0xc0b0
movzbl (%rax,%r13), %eax
cmpq $0x2f, %rax
ja 0x3756
cmpq $0x2c, %rax
je 0x3778
movabsq $0x800000000601, %rcx   # imm = 0x800000000601
btq %rax, %rcx
jb 0x37b8
movslq 0x8953(%rip), %rax      # 0xc0b0
movzbl (%rax,%r13), %eax
cmpq $0x2f, %rax
ja 0x3791
movabsq $0x100001000, %rcx      # imm = 0x100001000
btq %rax, %rcx
jae 0x3781
xorl %edi, %edi
callq 0x3911
jmp 0x3756
movabsq $0x800000000601, %rcx   # imm = 0x800000000601
btq %rax, %rcx
jb 0x37b8
callq 0x3a39
movslq (%r12), %rcx
cmpq %rcx, %rbx
jg 0x37a3
movl %eax, -0x48(%r15)
movl 0x8907(%rip), %ebx      # 0xc0b0
addq $0x18, %r15
incq %rbp
incq %r14
jmp 0x36ef
leal 0x3(%rbp), %ecx
movl (%r12), %eax
cmpl %ecx, %eax
jl 0x38c0
incl %eax
movq %rax, %rcx
subq %r14, %rcx
movq %rcx, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
subq %rbp, %rax
andq $-0x4, %rax
xorl %ecx, %ecx
movdqa 0x28e6(%rip), %xmm1     # 0x60d0
movdqa 0x28ee(%rip), %xmm2     # 0x60e0
movdqa 0x28f6(%rip), %xmm3     # 0x60f0
pxor %xmm3, %xmm0
pcmpeqd %xmm4, %xmm4
movq %rcx, %xmm5
pshufd $0x44, %xmm5, %xmm5     # xmm5 = xmm5[0,1,0,1]
movdqa %xmm5, %xmm6
por %xmm2, %xmm6
pxor %xmm3, %xmm6
movdqa %xmm6, %xmm7
pcmpgtd %xmm0, %xmm7
pcmpeqd %xmm0, %xmm6
pshufd $0xf5, %xmm6, %xmm8     # xmm8 = xmm6[1,1,3,3]
pand %xmm7, %xmm8
pshufd $0xf5, %xmm7, %xmm6     # xmm6 = xmm7[1,1,3,3]
por %xmm8, %xmm6
movd %xmm6, %edx
notl %edx
testb $0x1, %dl
je 0x384c
movl $0x0, -0x48(%r15)
pxor %xmm4, %xmm6
pextrw $0x4, %xmm6, %edx
testb $0x1, %dl
je 0x3862
movl $0x0, -0x30(%r15)
por %xmm1, %xmm5
pxor %xmm3, %xmm5
movdqa %xmm5, %xmm6
pcmpgtd %xmm0, %xmm6
pcmpeqd %xmm0, %xmm5
pshufd $0xf5, %xmm5, %xmm7     # xmm7 = xmm5[1,1,3,3]
pand %xmm6, %xmm7
pshufd $0xf5, %xmm6, %xmm5     # xmm5 = xmm6[1,1,3,3]
por %xmm7, %xmm5
pxor %xmm4, %xmm5
pextrw $0x0, %xmm5, %edx
testb $0x1, %dl
je 0x389e
movl $0x0, -0x18(%r15)
pextrw $0x4, %xmm5, %edx
testb $0x1, %dl
je 0x38af
movl $0x0, (%r15)
addq $0x4, %rcx
addq $0x60, %r15
cmpq %rcx, %rax
jne 0x3802
leaq 0x8789(%rip), %rsi      # 0xc050
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x2070
movl 0x87de(%rip), %eax      # 0xc0b8
movl %eax, 0x60(%rbx)
movq 0x10(%rsp), %rax
movq %rax, 0x68(%rbx)
movq 0x87d3(%rip), %rax      # 0xc0c0
movq %rax, 0x78(%rbx)
movq %rbx, 0x87c8(%rip)      # 0xc0c0
movl $0x1, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x237b