// File: /workspace/github_c_makefile_star2_O0/simh[P]simtools/crossassemblers/macro11/macros.c
// Function: read_body
void read_body(
    STACK *stack,
    BUFFER *gb,
    char *name,
    int called)
{
    int             nest;

    /* Read the stream in until the end marker is hit */

    /* Note: "called" says that this body is being pulled from a macro
       library, and so under no circumstance should it be listed. */

    nest = 1;
    for (;;) {
        SYMBOL         *op;
        char           *nextline;
        char           *cp;

        nextline = stack_gets(stack);  /* Now read the line */
        if (nextline == NULL) {        /* End of file. */
            report(stack->top, "Macro body of '%s' not closed\n", name);
            break;
        }

        if (!called && (list_level - 1 + list_md) > 0) {
            list_flush();
            list_source(stack->top, nextline);
        }

        op = get_op(nextline, &cp);

        if (op == NULL) {              /* Not a pseudo-op */
            buffer_append_line(gb, nextline);
            continue;
        }
        if (op->section->type == SECTION_PSEUDO) {
            if (op->value == P_MACRO || op->value == P_REPT || op->value == P_IRP || op->value == P_IRPC) {
                nest++;
            }

            if (op->value == P_ENDM || op->value == P_ENDR) {
                nest--;
                /* If there's a name on the .ENDM, then
                 * check if the name matches the one on .MACRO.
                 * See page 7-3.
                 * Since we don't keep a stack of nested
                 * .MACRO names, just check for the outer one.
                 */
                if (nest == 0 && name && op->value == P_ENDM) {
                    cp = skipwhite(cp);
                    if (!EOL(*cp)) {
                        char           *label = get_symbol(cp, &cp, NULL);

                        if (label) {
                            if (strcmp(label, name) != 0) {
                                report(stack->top, ".ENDM '%s' does not match .MACRO '%s'\n", label, name);
                            }
                            free(label);
                        }
                    }
                }
            }

            if (nest == 0)
                return;                /* All done. */
        }

        buffer_append_line(gb, nextline);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl $0x1, -0x20(%rbp)
movq -0x8(%rbp), %rdi
callq 0x13280
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0xab60
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rdx
leaq 0xaa21(%rip), %rsi      # 0x15575
movb $0x0, %al
callq 0xa890
jmp 0xacea
cmpl $0x0, -0x1c(%rbp)
jne 0xab95
leaq 0xef03(%rip), %rax      # 0x19a70
movl (%rax), %eax
subl $0x1, %eax
leaq 0xeeeb(%rip), %rcx      # 0x19a64
addl (%rcx), %eax
cmpl $0x0, %eax
jle 0xab95
callq 0xa5d0
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movq -0x30(%rbp), %rsi
callq 0xa4a0
movq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0xbe30
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0xabbf
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x12d50
jmp 0xab2e
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rax
cmpl $0x4, 0x8(%rax)
jne 0xacd8
movq -0x28(%rbp), %rax
cmpl $0x32, 0x8(%rax)
je 0xabf9
movq -0x28(%rbp), %rax
cmpl $0x2c, 0x8(%rax)
je 0xabf9
movq -0x28(%rbp), %rax
cmpl $0x19, 0x8(%rax)
je 0xabf9
movq -0x28(%rbp), %rax
cmpl $0x1a, 0x8(%rax)
jne 0xac02
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
movq -0x28(%rbp), %rax
cmpl $0xb, 0x8(%rax)
je 0xac1a
movq -0x28(%rbp), %rax
cmpl $0xc, 0x8(%rax)
jne 0xacce
movl -0x20(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jne 0xaccc
cmpq $0x0, -0x18(%rbp)
je 0xaccc
movq -0x28(%rbp), %rax
cmpl $0xb, 0x8(%rax)
jne 0xaccc
movq -0x38(%rbp), %rdi
callq 0xb9e0
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpb $0x0, (%rax)
je 0xacca
movq -0x38(%rbp), %rax
movsbl (%rax), %eax
cmpl $0xa, %eax
je 0xacca
movq -0x38(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x3b, %eax
je 0xacca
movq -0x38(%rbp), %rdi
leaq -0x38(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0xbf60
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0xacc8
movq -0x40(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x21b0
cmpl $0x0, %eax
je 0xacbf
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movq -0x40(%rbp), %rdx
movq -0x18(%rbp), %rcx
leaq 0xa8dc(%rip), %rsi      # 0x15594
movb $0x0, %al
callq 0xa890
movq -0x40(%rbp), %rdi
callq 0x2040
jmp 0xacca
jmp 0xaccc
jmp 0xacce
cmpl $0x0, -0x20(%rbp)
jne 0xacd6
jmp 0xacea
jmp 0xacd8
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x12d50
jmp 0xab2e
addq $0x40, %rsp
popq %rbp
retq