// File: /workspace/github_c_makefile_star2_O0/simh[P]simtools/crossassemblers/macro11/assemble_aux.c
// Function: mode_extension
void mode_extension(
    TEXT_RLD *tr,
    ADDR_MODE *mode,
    STREAM *str)
{
    EX_TREE        *value = mode->offset;
    SYMBOL         *sym;
    unsigned        offset;

    /* Also frees the mode. */

    if (value == NULL) {
        free_addr_mode(mode);
        return;
    }

    if (value->type == EX_LIT) {
        if (mode->rel)                 /* PC-relative? */
            store_displaced_word(str, tr, 2, value->data.lit);
        else
            store_word(str, tr, 2, value->data.lit);    /* Just a
                                                           known
                                                           value. */
    } else if (express_sym_offset(value, &sym, &offset)) {
        if ((sym->flags & (SYMBOLFLAG_GLOBAL | SYMBOLFLAG_DEFINITION)) == SYMBOLFLAG_GLOBAL) {
            /* Reference to a global symbol. */
            /* Global symbol plus offset */
            if (mode->rel)
                store_global_displaced_offset_word(str, tr, 2, offset, sym->label);
            else
                store_global_offset_word(str, tr, 2, offset, sym->label);
        } else {
            /* Relative to non-external symbol. */
            if (current_pc->section == sym->section) {
                /* In the same section */
                if (mode->rel) {
                    /* I can compute this myself. */
                    store_word(str, tr, 2, sym->value + offset - DOT - 2);
                } else
                    store_internal_word(str, tr, 2, sym->value + offset);
            } else {
                /* In a different section */
                if (mode->rel)
                    store_psect_displaced_offset_word(str, tr, 2, sym->value + offset, sym->section->label);
                else
                    store_psect_offset_word(str, tr, 2, sym->value + offset, sym->section->label);
            }
        }
    } else {
        /* Complex relocation */

        if (mode->rel)
            store_complex_displaced(str, tr, 2, mode->offset);
        else
            store_complex(str, tr, 2, mode->offset);
    }

    free_addr_mode(mode);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x7fc5
movq -0x10(%rbp), %rdi
callq 0x78e0
jmp 0x819e
movq -0x20(%rbp), %rax
cmpl $0x1, (%rax)
jne 0x8011
movq -0x10(%rbp), %rax
cmpl $0x0, 0x4(%rax)
je 0x7ff3
movq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rsi
movq -0x20(%rbp), %rax
movl 0x10(%rax), %ecx
movl $0x2, %edx
callq 0x81b0
jmp 0x800c
movq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rsi
movq -0x20(%rbp), %rax
movl 0x10(%rax), %ecx
movl $0x2, %edx
callq 0x77e0
jmp 0x8195
movq -0x20(%rbp), %rdi
leaq -0x28(%rbp), %rsi
leaq -0x2c(%rbp), %rdx
callq 0x7b20
cmpl $0x0, %eax
je 0x8151
movq -0x28(%rbp), %rax
movl 0x10(%rax), %eax
andl $0xa, %eax
cmpl $0x2, %eax
jne 0x8083
movq -0x10(%rbp), %rax
cmpl $0x0, 0x4(%rax)
je 0x8062
movq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rsi
movl -0x2c(%rbp), %ecx
movq -0x28(%rbp), %rax
movq (%rax), %r8
movl $0x2, %edx
callq 0x8220
jmp 0x807e
movq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rsi
movl -0x2c(%rbp), %ecx
movq -0x28(%rbp), %rax
movq (%rax), %r8
movl $0x2, %edx
callq 0x8290
jmp 0x814f
leaq 0x135de(%rip), %rax     # 0x1b668
movq (%rax), %rax
movq 0x18(%rax), %rax
movq -0x28(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jne 0x80f1
movq -0x10(%rbp), %rax
cmpl $0x0, 0x4(%rax)
je 0x80d3
movq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rsi
movq -0x28(%rbp), %rax
movl 0x8(%rax), %ecx
addl -0x2c(%rbp), %ecx
leaq 0x135aa(%rip), %rax     # 0x1b668
movq (%rax), %rax
subl 0x8(%rax), %ecx
subl $0x2, %ecx
movl $0x2, %edx
callq 0x77e0
jmp 0x80ef
movq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rsi
movq -0x28(%rbp), %rax
movl 0x8(%rax), %ecx
addl -0x2c(%rbp), %ecx
movl $0x2, %edx
callq 0x8300
jmp 0x814d
movq -0x10(%rbp), %rax
cmpl $0x0, 0x4(%rax)
je 0x8124
movq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rsi
movq -0x28(%rbp), %rax
movl 0x8(%rax), %ecx
addl -0x2c(%rbp), %ecx
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rax
movq (%rax), %r8
movl $0x2, %edx
callq 0x8370
jmp 0x814b
movq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rsi
movq -0x28(%rbp), %rax
movl 0x8(%rax), %ecx
addl -0x2c(%rbp), %ecx
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rax
movq (%rax), %r8
movl $0x2, %edx
callq 0x83e0
jmp 0x814d
jmp 0x814f
jmp 0x8193
movq -0x10(%rbp), %rax
cmpl $0x0, 0x4(%rax)
je 0x8177
movq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rsi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rcx
movl $0x2, %edx
callq 0x8450
jmp 0x8191
movq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rsi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rcx
movl $0x2, %edx
callq 0x8520
jmp 0x8193
jmp 0x8195
movq -0x10(%rbp), %rdi
callq 0x78e0
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)