// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xe0, %rsp
callq 0x11ad0
movb %al, -0xa1(%rbp)
movzbl -0xa1(%rbp), %eax
andl $0xe0, %eax
sarl $0x5, %eax
movl %eax, -0xa8(%rbp)
movzbl -0xa1(%rbp), %eax
andl $0x1c, %eax
sarl $0x2, %eax
movl %eax, -0xac(%rbp)
movzbl -0xa1(%rbp), %eax
andl $0x2, %eax
sarl %eax
movl %eax, -0xb0(%rbp)
movzbl -0xa1(%rbp), %eax
andl $0x1, %eax
movl %eax, -0xb4(%rbp)
cmpl $0x0, -0xa8(%rbp)
jne 0x15de2
callq 0x11b50
movzwl %ax, %eax
movl %eax, -0xb8(%rbp)
callq 0x11ad0
movb %al, -0xbd(%rbp)
cmpl $0x6, -0xa8(%rbp)
jne 0x15e15
callq 0x11ad0
movzbl %al, %eax
movl %eax, -0xbc(%rbp)
callq 0x11b50
movzwl %ax, %eax
movl %eax, -0xc4(%rbp)
callq 0x11b50
movzwl %ax, %eax
movl %eax, -0xc8(%rbp)
callq 0x11b50
movzwl %ax, %eax
movl %eax, -0xcc(%rbp)
movb $0x0, -0xa0(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x11c80
leaq 0xa326(%rip), %rax      # 0x20160
movq (%rax), %rsi
leaq -0x30(%rbp), %rdi
leaq -0x5c8(%rip), %rdx      # 0x15880
xorl %eax, %eax
movl %eax, %ecx
callq 0x16c50
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x15e68
leaq 0x1689(%rip), %rdi      # 0x174ec
callq 0x16e00
movl -0x30(%rbp), %eax
movl %eax, -0xd0(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x11c80
leaq 0xa2df(%rip), %rax      # 0x20160
movq (%rax), %rsi
leaq -0x30(%rbp), %rdi
leaq -0x60f(%rip), %rdx      # 0x15880
xorl %eax, %eax
movl %eax, %ecx
callq 0x16c50
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x15eaf
leaq 0x2cdb(%rip), %rdi      # 0x18b85
callq 0x16e00
leaq -0x30(%rbp), %rdi
callq 0x11c80
leaq 0xa2a1(%rip), %rax      # 0x20160
movq (%rax), %rsi
leaq -0x30(%rbp), %rdi
leaq -0x64d(%rip), %rdx      # 0x15880
xorl %eax, %eax
movl %eax, %ecx
callq 0x16c50
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x15eed
leaq 0x2cb2(%rip), %rdi      # 0x18b9a
callq 0x16e00
leaq 0xa1d4(%rip), %rax      # 0x200c8
cmpl $0x0, (%rax)
jne 0x160bf
leaq 0xa1bc(%rip), %rax      # 0x200c0
cmpl $0x0, (%rax)
jne 0x15f62
leaq 0x22b0(%rip), %rdx      # 0x181c0
leaq 0x26c9(%rip), %rsi      # 0x185e0
leaq 0x2c93(%rip), %rcx      # 0x18bb1
movq %rdx, %rdi
callq 0xe2d0
leaq 0x2293(%rip), %rdx      # 0x181c0
leaq 0x26b2(%rip), %rsi      # 0x185e6
leaq 0x2c8f(%rip), %rcx      # 0x18bca
movq %rdx, %rdi
callq 0xe2d0
callq 0xe280
leaq 0xa171(%rip), %rax      # 0x200c0
movl $0x1, (%rax)
leaq 0xa158(%rip), %rax      # 0x200b4
movl $0x182, (%rax)          # imm = 0x182
movq -0x40(%rbp), %rdi
addq $0x4, %rdi
callq 0x90a0
cmpq $0x0, %rax
je 0x16023
leaq 0xa134(%rip), %rax      # 0x200b4
cmpl $0x182, (%rax)          # imm = 0x182
jne 0x15fdd
leaq -0xa0(%rbp), %rdi
movslq -0xa8(%rbp), %rcx
leaq 0xa023(%rip), %rax      # 0x1ffc0
movq (%rax,%rcx,8), %rdx
movslq -0xac(%rbp), %rcx
leaq 0xa051(%rip), %rax      # 0x20000
movq (%rax,%rcx,8), %rcx
movslq -0xb4(%rbp), %rsi
leaq 0xa07f(%rip), %rax      # 0x20040
movq (%rax,%rsi,8), %r8
movq -0x40(%rbp), %r9
addq $0x4, %r9
leaq 0x2c11(%rip), %rsi      # 0x18be5
movb $0x0, %al
callq 0x9190
jmp 0x1601e
leaq -0xa0(%rbp), %rdi
movslq -0xa8(%rbp), %rcx
leaq 0x9fce(%rip), %rax      # 0x1ffc0
movq (%rax,%rcx,8), %rdx
movslq -0xac(%rbp), %rcx
leaq 0x9ffc(%rip), %rax      # 0x20000
movq (%rax,%rcx,8), %rcx
movq -0x40(%rbp), %r8
addq $0x4, %r8
leaq 0x2bd1(%rip), %rsi      # 0x18be8
movb $0x0, %al
callq 0x9190
jmp 0x160ba
leaq 0xa08a(%rip), %rax      # 0x200b4
cmpl $0x182, (%rax)          # imm = 0x182
jne 0x1607f
leaq -0xa0(%rbp), %rdi
movslq -0xa8(%rbp), %rcx
leaq 0x9f79(%rip), %rax      # 0x1ffc0
movq (%rax,%rcx,8), %rdx
movslq -0xac(%rbp), %rcx
leaq 0x9fa7(%rip), %rax      # 0x20000
movq (%rax,%rcx,8), %rcx
movslq -0xb4(%rbp), %rsi
leaq 0x9fd5(%rip), %rax      # 0x20040
movq (%rax,%rsi,8), %r8
leaq 0x2b7d(%rip), %rsi      # 0x18bf3
movb $0x0, %al
callq 0x9190
jmp 0x160b8
leaq -0xa0(%rbp), %rdi
movslq -0xa8(%rbp), %rcx
leaq 0x9f2c(%rip), %rax      # 0x1ffc0
movq (%rax,%rcx,8), %rdx
movslq -0xac(%rbp), %rcx
leaq 0x9f5a(%rip), %rax      # 0x20000
movq (%rax,%rcx,8), %rcx
leaq 0x2b45(%rip), %rsi      # 0x18bf6
movb $0x0, %al
callq 0x9190
jmp 0x160ba
jmp 0x16150
movq -0x40(%rbp), %rdi
addq $0x4, %rdi
callq 0x90a0
cmpq $0x0, %rax
je 0x16115
leaq -0xa0(%rbp), %rdi
movslq -0xa8(%rbp), %rcx
leaq 0x9ed9(%rip), %rax      # 0x1ffc0
movq (%rax,%rcx,8), %rdx
movslq -0xac(%rbp), %rcx
leaq 0x9f07(%rip), %rax      # 0x20000
movq (%rax,%rcx,8), %rcx
movq -0x40(%rbp), %r8
addq $0x4, %r8
leaq 0x2adc(%rip), %rsi      # 0x18be8
movb $0x0, %al
callq 0x9190
jmp 0x1614e
leaq -0xa0(%rbp), %rdi
movslq -0xa8(%rbp), %rcx
leaq 0x9e96(%rip), %rax      # 0x1ffc0
movq (%rax,%rcx,8), %rdx
movslq -0xac(%rbp), %rcx
leaq 0x9ec4(%rip), %rax      # 0x20000
movq (%rax,%rcx,8), %rcx
leaq 0x2aaf(%rip), %rsi      # 0x18bf6
movb $0x0, %al
callq 0x9190
jmp 0x16150
leaq 0x9f71(%rip), %rax      # 0x200c8
cmpl $0x2, (%rax)
jne 0x1615e
jmp 0x161a3
movq -0x38(%rbp), %rdi
addq $0x4, %rdi
leaq -0xa0(%rbp), %rdx
leaq 0x1d51(%rip), %rsi      # 0x17ec5
leaq 0x2045(%rip), %rcx      # 0x181c0
callq 0xe2d0
movq -0x38(%rbp), %rdi
addq $0x4, %rdi
leaq 0x1d59(%rip), %rsi      # 0x17ee8
leaq 0x202a(%rip), %rcx      # 0x181c0
movq %rcx, %rdx
callq 0xe2d0
callq 0xe280
movl $0x0, -0xd4(%rbp)
leaq -0xa0(%rbp), %rdi
movq -0x38(%rbp), %rsi
addq $0x4, %rsi
callq 0x15d00
leaq -0xa0(%rbp), %rdi
leaq 0x1352(%rip), %rsi      # 0x17521
callq 0x91b0
cmpq $0x0, %rax
je 0x161e4
movl $0x1, -0xd4(%rbp)
leaq -0xa0(%rbp), %rdi
leaq 0x2a0a(%rip), %rsi      # 0x18bfc
callq 0x91b0
cmpq $0x0, %rax
je 0x16207
movl $0x1, -0xd4(%rbp)
leaq -0xa0(%rbp), %rdi
movq -0x40(%rbp), %rsi
addq $0x4, %rsi
callq 0x15d00
leaq -0xa0(%rbp), %rdi
leaq 0x12f8(%rip), %rsi      # 0x17521
callq 0x91b0
cmpq $0x0, %rax
je 0x1623e
movl $0x1, -0xd4(%rbp)
leaq -0xa0(%rbp), %rdi
leaq 0x29b7(%rip), %rsi      # 0x18c03
callq 0x91b0
cmpq $0x0, %rax
je 0x16261
movl $0x1, -0xd4(%rbp)
movl -0xd0(%rbp), %edi
movq -0x40(%rbp), %rsi
movl -0xcc(%rbp), %edx
movl -0xb4(%rbp), %ecx
movl -0xd4(%rbp), %r8d
callq 0x15c60
movl -0xb0(%rbp), %eax
movl %eax, -0xb0(%rbp)
movl -0xb8(%rbp), %eax
movl %eax, -0xb8(%rbp)
movb -0xbd(%rbp), %al
movb %al, -0xbd(%rbp)
movl -0xbc(%rbp), %eax
movl %eax, -0xbc(%rbp)
movl -0xc4(%rbp), %eax
movl %eax, -0xc4(%rbp)
movl -0xc8(%rbp), %eax
movl %eax, -0xc8(%rbp)
addq $0xe0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nop