// File: /workspace/github_c_makefile_star2_O0/simh[P]simtools/crossassemblers/macro11/rept_irpc.c
// Function: expand_irp
STREAM         *expand_irp(
    STACK *stack,
    char *cp)
{
    char           *label,
                   *items;
    BUFFER         *gb;
    int             levelmod = 0;
    IRP_STREAM     *str;

    label = get_symbol(cp, &cp, NULL);
    if (!label) {
        report(stack->top, "Illegal .IRP syntax\n");
        return NULL;
    }

    cp = skipdelim(cp);

    items = getstring(cp, &cp);
    if (!items) {
        report(stack->top, "Illegal .IRP syntax\n");
        free(label);
        return NULL;
    }

    gb = new_buffer();

    levelmod = 0;
    if (!list_md) {
        list_level--;
        levelmod++;
    }

    read_body(stack, gb, NULL, FALSE);

    list_level += levelmod;

    str = memcheck(malloc(sizeof(IRP_STREAM))); {
        char           *name = memcheck(malloc(strlen(stack->top->name) + 32));

        sprintf(name, "%s:%d->.IRP", stack->top->name, stack->top->line);
        buffer_stream_construct(&str->bstr, NULL, name);
        free(name);
    }

    str->bstr.stream.vtbl = &irp_stream_vtbl;

    str->body = gb;
    str->items = items;
    str->offset = 0;
    str->label = label;
    str->savecond = last_cond;

    return &str->bstr.stream;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl $0x0, -0x34(%rbp)
movq -0x18(%rbp), %rdi
leaq -0x18(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0xbf60
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0xd965
movq -0x10(%rbp), %rax
movq (%rax), %rdi
leaq 0x7dfb(%rip), %rsi      # 0x1574c
movb $0x0, %al
callq 0xa890
movq $0x0, -0x8(%rbp)
jmp 0xdaeb
movq -0x18(%rbp), %rdi
callq 0xba30
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0xbad0
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0xd9b5
movq -0x10(%rbp), %rax
movq (%rax), %rdi
leaq 0x7db4(%rip), %rsi      # 0x1574c
movb $0x0, %al
callq 0xa890
movq -0x20(%rbp), %rdi
callq 0x2040
movq $0x0, -0x8(%rbp)
jmp 0xdaeb
callq 0x12af0
movq %rax, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
leaq 0xc098(%rip), %rax      # 0x19a64
cmpl $0x0, (%rax)
jne 0xd9ef
leaq 0xc098(%rip), %rax      # 0x19a70
movl (%rax), %ecx
addl $-0x1, %ecx
leaq 0xc08c(%rip), %rax      # 0x19a70
movl %ecx, (%rax)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
xorl %ecx, %ecx
callq 0xab10
movl -0x34(%rbp), %ecx
leaq 0xc064(%rip), %rax      # 0x19a70
addl (%rax), %ecx
leaq 0xc05b(%rip), %rax      # 0x19a70
movl %ecx, (%rax)
movl $0x58, %edi
callq 0x2220
movq %rax, %rdi
callq 0x136a0
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rdi
callq 0x20c0
movq %rax, %rdi
addq $0x20, %rdi
callq 0x2220
movq %rax, %rdi
callq 0x136a0
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rdx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl 0x10(%rax), %ecx
leaq 0x7cec(%rip), %rsi      # 0x15761
movb $0x0, %al
callq 0x22a0
movq -0x40(%rbp), %rdi
movq -0x48(%rbp), %rdx
xorl %eax, %eax
movl %eax, %esi
callq 0x12f90
movq -0x48(%rbp), %rdi
callq 0x2040
movq -0x40(%rbp), %rax
leaq 0xc007(%rip), %rcx      # 0x19aa8
movq %rcx, (%rax)
movq -0x30(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x48(%rax)
movq -0x28(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x40(%rbp), %rax
movl $0x0, 0x40(%rax)
movq -0x20(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x30(%rax)
leaq 0xd9f6(%rip), %rax      # 0x1b4d0
movl (%rax), %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x50(%rax)
movq -0x40(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)