// File: /workspace/github_c_makefile_star2_O1/Nico01[P]obj2asm/outarget.c
// Function: get_seg
void get_seg( result, fixup, ref_mode, data, seg_reg )
    char    *result;
    FIX_T   *fixup;
    int     ref_mode;
    void    *data;
    int     seg_reg;
{
    char    *this_name;
    int     form;
    int     mode;
    int     index;
    int     ref_seg;
    EXT_T   *ext_rec;
    PUB_T   *pub_rec;

    form  = fixup->form;
    mode  = fixup->a_mode;
    index = fixup->a_index;

    strcpy( result, "" );

    if ( mode == TARGET || mode == NONE ) {
        return;
    }

    /*
    ** Check for Externals with implied or lacking segment
    **  This means that the fixup tells that the external was defined in
    **  that segment (for implied, SI:EI). Or that the external was defined
    **  outside any segment (for lacking, EI:EI).
    */
    if ( fixup->b_mode == EXTERNAL ) {
        ext_rec = data;
        if ( mode == EXTERNAL ) {
            /* Must be EI:EI */
            ext_rec->used = -1;         /* Remove from any segments! */
            return;
        }
        if ( mode == SEGMENT ) {
            ext_rec->pos_abs = FALSE;
            if ( ref_mode != 0 ) {
                /* Must be Segment:EI */
                if ( pass == 1 && ext_rec->used == 0 ) {
                    sex_insert( index, ext_rec );
                    ext_rec->used = index;
                }
                if ( ext_rec->used == index ) {
                    return;
                }
            }
        }
    } else {
        if ( fixup->b_mode == SEGMENT ) {
            pub_rec = data;
            if ( ref_mode == 2 && (ref_mode == 1 && form == POINTER) ) {
                if ( pub_rec->seg_idx == index ) {
                    return;
                }
            }
        }
    }

    /*
    ** On first important fixup, assign the "ASSIGN xx:" values
    */
    if ( ref_mode == 0 || (ref_mode == 1 && form != POINTER) ) {
        ref_seg = seg_reg - ES;                 /* Convert to 0,1,2,3,etc */
        seg_rec->new_mode [ref_seg] = mode;
        seg_rec->new_index[ref_seg] = index;
        if ( mode == SEGMENT ) {
            if ( fixup->b_mode == EXTERNAL && ext_rec->used == index ) {
                return;
            }
        }
        if ( mode == SEGMENT || mode == GROUP ) {
            if ( fixup->b_mode == SEGMENT || fixup->b_mode == EXTERNAL ) {
                return;
            }
        }
        /*
        ** Frame on a code reference is always taken from the assume?
        */
    }

    if ( form == BASE ) {
        if ( fixup->b_mode == mode && fixup->b_index == index ) {
            return;
        }
    }

    this_name = mode_name( mode, index );
    if ( this_name ) {
        sprintf( result, "%s:", this_name );
        return;
    } else {
        return;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edx, %r12d
movl 0x18(%rsi), %edx
movl 0x1c(%rsi), %r14d
movl 0x20(%rsi), %ebp
movb $0x0, (%rdi)
leal -0x5(%r14), %eax
cmpl $0x2, %eax
jae 0xf9cb
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %r8d, %r13d
movq %rsi, %r15
movq %rdi, %rbx
cmpl $0x2, 0x24(%rsi)
jne 0xfa30
testl %r14d, %r14d
je 0xf9ee
cmpl $0x2, %r14d
jne 0xfa30
movl $0xffffffff, 0x48(%rcx) # imm = 0xFFFFFFFF
jmp 0xf9bc
movl $0x0, 0x30(%rcx)
testl %r12d, %r12d
je 0xfa4c
leaq 0xd567(%rip), %rax      # 0x1cf68
cmpl $0x1, (%rax)
jne 0xfa2b
cmpl $0x0, 0x48(%rcx)
jne 0xfa2b
movl %ebp, %edi
movq %rcx, %rsi
movl %edx, 0xc(%rsp)
movq %rcx, 0x10(%rsp)
callq 0xf5d0
movq 0x10(%rsp), %rcx
movl 0xc(%rsp), %edx
movl %ebp, 0x48(%rcx)
cmpl %ebp, 0x48(%rcx)
je 0xf9bc
testl %r12d, %r12d
je 0xfa4c
cmpl $0x1, %r12d
sete %al
cmpl $0x3, %edx
setne %sil
andb %al, %sil
cmpb $0x1, %sil
jne 0xfa8b
leaq 0xd59d(%rip), %rax      # 0x1cff0
movq (%rax), %rax
movslq %r13d, %rsi
movl %r14d, -0x28(%rax,%rsi,4)
movl %ebp, -0x10(%rax,%rsi,4)
testl %r14d, %r14d
jne 0xfa77
cmpl $0x2, 0x24(%r15)
jne 0xfa77
cmpl %ebp, 0x48(%rcx)
je 0xf9bc
cmpl $0x1, %r14d
ja 0xfa8b
testl $0xfffffffd, 0x24(%r15) # imm = 0xFFFFFFFD
je 0xf9bc
cmpl $0x2, %edx
jne 0xfaa0
cmpl %r14d, 0x24(%r15)
jne 0xfaa0
cmpl %ebp, 0x28(%r15)
je 0xf9bc
movl %r14d, %edi
movl %ebp, %esi
callq 0xf85b
testq %rax, %rax
je 0xf9bc
leaq 0x4208(%rip), %rsi      # 0x13cc2
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x91b0