// File: /workspace/github_c_makefile_star2_O3/Nico01[P]obj2asm/rec_segdef.c
// Function: segdef
void segdef()
{
    NAME_T          search;
    NAME_T          *segment;
    NAME_T          *class;
    NAME_T          *overlay;
    char            operands[80];
    uchar           acbp;
    int             align;
    int             combine;
    int             big;
    int             page;
    int             frame;
    int             ltl;
    uchar           offset;
    int             max_len;
    int             grp_off;
    word            length;
    int             name_idx;
    int             code;

    acbp = get_byte();

    align   = (acbp & 0xE0) >> 5;
    combine = (acbp & 0x1C) >> 2;
    big     = (acbp & 0x02) >> 1;
    page    = (acbp & 0x01);

    if ( align == 0 ) {
        frame  = get_word();
        offset = get_byte();
    }

    if ( align == 6 ) {
        ltl = get_byte();
        max_len = get_word();
        grp_off = get_word();
    }

    length = get_word();                    /* Length of segment */

#ifdef DEBUG
printf("Length of segment = %04X\n",length );
#endif

    operands[0] = '\0';                     /* No operands yet */

    get_index( &search.index );
    segment = (NAME_T *)find( (char *)&search, name_tree, TC name_compare, NULL );
    if ( segment == NULL ) fmt_error( "Undefined segment name" );
    name_idx = search.index;

    get_index( &search.index );
    class = (NAME_T *)find( (char *)&search, name_tree, TC name_compare, NULL );
    if ( class == NULL ) fmt_error( "Undefined class name" );

    get_index( &search.index );
    overlay = (NAME_T *)find( (char *)&search, name_tree, TC name_compare, NULL );
    if ( overlay == NULL ) fmt_error( "Undefined overlay name" );

    if ( compatibility == 0 ) {
        if ( !processor_type_comment_occurred ) {
            out_line( "", ".386p", "", "Enable USE32/USE16 usage" );
            out_line( "", ".387", "", "Enable floating point also" );
            out_newline();
            processor_type_comment_occurred = TRUE;
            processor_mode = 386;
        }

        /* page will now be 0 only for 16-bit segments */
        /* before 32-bit segments                      */

        if ( strlen(class->name) ) {
            if ( processor_mode == 386 ) {
                sprintf( operands, "%s %s %s '%s'", al_text[align],
                        cb_text[combine], use_text[page], class->name );
            } else {
                sprintf( operands, "%s %s '%s'", al_text[align],
                            cb_text[combine], class->name );
            }
        } else {
            if ( processor_mode == 386 ) {
                sprintf( operands, "%s %s %s", al_text[align],
                            cb_text[combine], use_text[page] );
            } else {
                sprintf( operands, "%s %s", al_text[align],
                                              cb_text[combine] );
            }
        }
    } else {
        if ( strlen(class->name) ) {
            sprintf( operands, "%s %s '%s'", al_text[align], 
                                            cb_text[combine], class->name );
        } else {
            sprintf( operands, "%s %s", al_text[align], cb_text[combine] );
        }
    }

    if ( compatibility == 2 ) {
        /*
        ** No pre-output segment listing for RASM86 files
        */
    } else {
        out_line( segment->name, "SEGMENT", operands, "" );
        out_line( segment->name, "ENDS", "", "" );
        out_newline();
    }

    code = FALSE;
    upstr( operands, segment->name );
    if ( strstr(operands,"CODE") ) {
        code = TRUE;
    }
    if ( strstr(operands, "DRIVER") ) {
        code = TRUE;
    }

    upstr( operands, class->name );
    if ( strstr(operands,"CODE") ) {
        code = TRUE;
    }
    if ( strstr(operands,"TEXT") ) {
        code = TRUE;
    }

    seg_insert( name_idx, class, length, page, code );
    big     = big;
    frame = frame;
    offset = offset;
    ltl = ltl;
    max_len = max_len;
    grp_off = grp_off;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
callq 0xf4b4
movzbl %al, %r13d
movl %r13d, %ebp
shrl $0x5, %ebp
cmpb $0x1f, %r13b
ja 0x11e0f
callq 0xf4e8
callq 0xf4b4
cmpl $0x6, %ebp
jne 0x11e23
callq 0xf4b4
callq 0xf4e8
callq 0xf4e8
callq 0xf4e8
movw %ax, 0x6(%rsp)
movb $0x0, 0x10(%rsp)
leaq 0x68(%rsp), %r14
movq %r14, %rdi
callq 0xf599
leaq 0xb14a(%rip), %rbx      # 0x1cf90
movq (%rbx), %rsi
leaq -0x348(%rip), %rdx      # 0x11b08
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x1280f
movq %rax, %r12
testq %rax, %rax
jne 0x11e6e
leaq 0x16dc(%rip), %rdi      # 0x13545
callq 0x128bc
leaq 0x68(%rsp), %r15
movl (%r15), %eax
movl %eax, 0xc(%rsp)
movq %r15, %rdi
callq 0xf599
movq (%rbx), %rsi
leaq -0x384(%rip), %rdx      # 0x11b08
movq %r15, %rdi
xorl %ecx, %ecx
callq 0x1280f
movq %rax, %r15
testq %rax, %rax
jne 0x11eaa
leaq 0x2cc6(%rip), %rdi      # 0x14b6b
callq 0x128bc
movl %r13d, %ebx
shrl $0x2, %ebx
movl %r13d, %r14d
leaq 0x68(%rsp), %r13
movq %r13, %rdi
callq 0xf599
leaq 0xb0c9(%rip), %rax      # 0x1cf90
movq (%rax), %rsi
leaq -0x3c9(%rip), %rdx      # 0x11b08
movq %r13, %rdi
xorl %ecx, %ecx
callq 0x1280f
testq %rax, %rax
jne 0x11eec
leaq 0x2c99(%rip), %rdi      # 0x14b80
callq 0x128bc
andl $0x7, %ebx
andl $0x1, %r14d
leaq 0xaffe(%rip), %rax      # 0x1cef8
cmpl $0x0, (%rax)
movl %r14d, 0x8(%rsp)
je 0x11f3e
cmpb $0x0, 0x4(%r15)
movl %ebp, %eax
leaq 0xaede(%rip), %rcx      # 0x1cdf0
movq (%rcx,%rax,8), %rdx
movl %ebx, %eax
leaq 0xaf11(%rip), %rcx      # 0x1ce30
movq (%rcx,%rax,8), %rcx
je 0x1201e
leaq 0x4(%r15), %r8
leaq 0x2c9a(%rip), %rsi      # 0x14bce
leaq 0x10(%rsp), %rdi
jmp 0x12042
movl %r14d, %r13d
leaq 0xafa8(%rip), %r14      # 0x1cef0
cmpl $0x0, (%r14)
jne 0x11fa5
leaq 0x2667(%rip), %rsi      # 0x145bc
leaq 0x21b0(%rip), %r13      # 0x1410c
leaq 0x2c34(%rip), %rcx      # 0x14b97
movq %r13, %rdi
movq %r13, %rdx
callq 0xcb44
leaq 0x264d(%rip), %rsi      # 0x145c2
leaq 0x2c34(%rip), %rcx      # 0x14bb0
movq %r13, %rdi
movq %r13, %rdx
movl 0x8(%rsp), %r13d
callq 0xcb44
callq 0xcad9
movl $0x1, (%r14)
leaq 0xaf45(%rip), %rax      # 0x1cee4
movl $0x182, (%rax)          # imm = 0x182
cmpb $0x0, 0x4(%r15)
leaq 0xaf33(%rip), %rax      # 0x1cee4
movl (%rax), %eax
movl %ebp, %ecx
leaq 0xae34(%rip), %rdx      # 0x1cdf0
movq (%rdx,%rcx,8), %rdx
movl %ebx, %ecx
leaq 0xae67(%rip), %rsi      # 0x1ce30
movq (%rsi,%rcx,8), %rcx
je 0x11ffd
leaq 0x4(%r15), %r9
cmpl $0x182, %eax            # imm = 0x182
jne 0x12033
movl %r13d, %eax
leaq 0xae8c(%rip), %rsi      # 0x1ce70
movq (%rsi,%rax,8), %r8
leaq 0x2bdc(%rip), %rsi      # 0x14bcb
leaq 0x10(%rsp), %rdi
xorl %eax, %eax
callq 0x91b0
jmp 0x12049
cmpl $0x182, %eax            # imm = 0x182
jne 0x1201e
movl %r13d, %eax
leaq 0xae62(%rip), %rsi      # 0x1ce70
movq (%rsi,%rax,8), %r8
leaq 0x2bc0(%rip), %rsi      # 0x14bd9
jmp 0x11f34
leaq 0x2bb7(%rip), %rsi      # 0x14bdc
leaq 0x10(%rsp), %rdi
xorl %eax, %eax
callq 0x91b0
jmp 0x12049
leaq 0x2b94(%rip), %rsi      # 0x14bce
leaq 0x10(%rsp), %rdi
movq %r9, %r8
xorl %eax, %eax
callq 0x91b0
leaq 0xaea8(%rip), %rax      # 0x1cef8
cmpl $0x2, (%rax)
je 0x12092
leaq 0x4(%r12), %r13
leaq 0x1dc2(%rip), %rsi      # 0x13e23
leaq 0x20a4(%rip), %rbp      # 0x1410c
leaq 0x10(%rsp), %rdx
movq %r13, %rdi
movq %rbp, %rcx
callq 0xcb44
leaq 0x1dc7(%rip), %rsi      # 0x13e46
movq %r13, %rdi
movq %rbp, %rdx
movq %rbp, %rcx
callq 0xcb44
callq 0xcad9
movb 0x4(%r12), %bl
leaq 0x10(%rsp), %r13
movq %r13, %rcx
testb %bl, %bl
je 0x120cb
callq 0x9030
addq $0x5, %r12
leaq 0x10(%rsp), %rcx
movq (%rax), %rdx
movsbq %bl, %rsi
movb (%rdx,%rsi,4), %dl
movb %dl, (%rcx)
incq %rcx
movb (%r12), %bl
incq %r12
testb %bl, %bl
jne 0x120b1
movb $0x0, (%rcx)
leaq 0x14a5(%rip), %rsi      # 0x1357a
movq %r13, %rdi
callq 0x91e0
movq %rax, %r12
leaq 0x2afb(%rip), %rsi      # 0x14be2
movq %r13, %rdi
callq 0x91e0
movq %rax, %rbp
movb 0x4(%r15), %bl
testb %bl, %bl
je 0x12125
callq 0x9030
movq %r15, %rcx
addq $0x5, %rcx
leaq 0x10(%rsp), %r13
movq (%rax), %rdx
movsbq %bl, %rsi
movb (%rdx,%rsi,4), %dl
movb %dl, (%r13)
incq %r13
movb (%rcx), %bl
incq %rcx
testb %bl, %bl
jne 0x1210b
movb $0x0, (%r13)
leaq 0x1449(%rip), %rsi      # 0x1357a
leaq 0x10(%rsp), %r13
movq %r13, %rdi
callq 0x91e0
movq %rax, %r14
leaq 0x2aa1(%rip), %rsi      # 0x14be9
movq %r13, %rdi
callq 0x91e0
movq %r14, %xmm0
movq %rax, %xmm1
punpcklqdq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0]
movq %r12, %xmm0
movq %rbp, %xmm2
punpcklqdq %xmm0, %xmm2    # xmm2 = xmm2[0],xmm0[0]
por %xmm1, %xmm2
pxor %xmm0, %xmm0
pcmpeqd %xmm2, %xmm0
movmskps %xmm0, %eax
xorl %r8d, %r8d
xorl $0xf, %eax
setne %r8b
movzwl 0x6(%rsp), %edx
movl 0xc(%rsp), %edi
movq %r15, %rsi
movl 0x8(%rsp), %ecx
callq 0x11d42
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq