// File: /workspace/github_c_makefile_star2_O0/Nico01[P]obj2asm/oextra.c
// Function: load_extra
void load_extra( exename, filename )
    char            *exename;
    char            *filename;
{
    FILE            *e_file;
    char            temp_name[50];
    char            e_line[LINE_SIZE+1];
    int             line_num;
    char            *pc;
    char            *semicolon;
    char            *equal;
    char            *colon;
    char            seg_text[NAMESIZE+1];
    char            lab_text[NAMESIZE+1];
    int             segment_type;
    dword   disp;
    int             count;

#ifdef DEBUG
    printf("Loading from extra file %s\n", filename );
#endif

    strcpy( temp_name, filename );
    if ( strchr(temp_name,'.') == NULL ) {  /* Append ".add" if not extension */
        strcat( temp_name, ".add" );        /* is supplied                    */
    }
    e_file = fopen( temp_name, "r" );
    if ( e_file == NULL ) {
        fprintf( stderr, "%s: Cannot open %s\n", exename, temp_name );
        exit(6);
    }

    line_num = 1;

    /*
    ** Process lines of format:
    **
    **  SEG segname CODE/DATA                 Pick segment type
    **  labname = segname : offset            Create label
    **  segname : offset : DB/DW/DD/DF/DQ/DT  Control dis-assembly
    */

    while ( fgets(e_line,LINE_SIZE,e_file) != NULL ) {
        semicolon = strchr( e_line, ';' );
        if ( semicolon ) {
            *semicolon = '\0';
        }
        pc = ignore_whitespace( e_line );
#ifdef DEBUG
fprintf(stderr, "%s", pc );
#endif
        if ( strnicmp(pc,"SEG ",4) == 0 ) {
            pc = ignore_whitespace( pc+4 );
            pc = get_text( seg_text, pc );
            pc = ignore_whitespace( pc );
            segment_type = 0;
            if ( strnicmp(pc,"CODE",4) == 0 ) {
                pc += 4;
                segment_type = 1;
            }
            if ( strnicmp(pc,"DATA",4) == 0 ) {
                pc += 4;
                segment_type = 2;
            }
            if ( segment_type == 0 ) {
                fprintf( stderr,
                  "%s: Syntax error on line %d of %s (should be CODE/DATA).\n",
                  exename, line_num, temp_name );
                exit(7);
            }
            seg_rec = find_seg_by_name( seg_text );
            if ( !seg_rec ) {
                fprintf( stderr,
            "%s: Syntax error on line %d of %s (segment '%s' not found)\n",
                    exename, line_num, temp_name, seg_text );
                exit(7);
            }
            if ( segment_type == 1 ) {
                seg_rec->code = TRUE;
            } else {
                seg_rec->code = FALSE;
            }
        }
        equal = strchr(pc, '=' );
        if ( equal ) {
            pc = get_text(lab_text, pc );
            pc = ignore_whitespace(pc);
            if ( strnicmp(pc,"=",1) != 0 ) {
                fprintf( stderr,
            "%s: Syntax error on line %d of %s (expecting '=' after label)\n",
                    exename, line_num, temp_name );
                exit(7);
            }
            pc=ignore_whitespace(pc+1);
            colon=strchr(pc,':');
            if ( colon == NULL ) {
                fprintf( stderr,
            "%s: Syntax error on line %d of %s (expecting ':')\n",
                    exename, line_num, temp_name );
                exit(7);
            }
            pc = get_text( seg_text, pc );
            pc = ignore_whitespace( colon+1 );
            pc = get_num( pc, &disp );
            seg_rec = find_seg_by_name( seg_text );
            if ( !seg_rec ) {
                fprintf( stderr,
            "%s: Syntax error on line %d of %s (segment '%s' not found)\n",
                    exename, line_num, temp_name, seg_text );
                exit(7);
            }
            pub_insert( seg_rec->index, disp, lab_text, LOCAL, FALSE );
        }
        colon = strchr(pc,':');
        if ( colon ) {
            pc = get_text( seg_text, pc );
            seg_rec = find_seg_by_name( seg_text );
            if ( !seg_rec ) {
                fprintf( stderr,
            "%s: Syntax error on line %d of %s (segment '%s' not found)\n",
                    exename, line_num, temp_name, seg_text );
                exit(7);
            }
            pc = ignore_whitespace( pc );
            if ( strnicmp(pc,":",1) != 0 ) {
                fprintf( stderr,
            "%s: Syntax error on line %d of %s (expecting ':' seperator)\n",
                    exename, line_num, temp_name );
                exit(7);
            }
            pc = get_num( pc+1, &disp );
            pc = ignore_whitespace( pc );
            if ( strnicmp(pc,":",1) != 0 ) {
                fprintf( stderr,
            "%s: Syntax error on line %d of %s (expecting ':' seperator)\n",
                    exename, line_num, temp_name );
                exit(7);
            }
            pc = ignore_whitespace( pc+1 );
            pc = get_text( lab_text, pc );  /* Is really data type text */
            count = 0;
            while ( count < hint_nwords ) {
                if ( stricmp(lab_text,hint_words[count].text) == 0 ) {
                    break;
                }
                count++;
            }
            if ( count == hint_nwords ) {
                fprintf( stderr,
            "%s: Syntax error on line %d of %s (expecting DB/DW/DD/DF/DQ/DT)\n",
                    exename, line_num, temp_name );
                exit(7);
            }
            hint_insert(seg_rec->index,disp,hint_words[count].type,1);
        }
        pc = ignore_whitespace( pc );
        if ( strlen(pc) != 0 ) {
                fprintf( stderr,
       "%s: Syntax error on line %d of %s (too many characters on line '%s')\n",
                    exename, line_num, temp_name, pc );
                exit(7);
        }
        line_num++;
    }

#ifdef DEBUG
fprintf(stderr, "\n", e_line );
#endif

    fclose( e_file );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x160, %rsp            # imm = 0x160
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x50(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x9060
leaq -0x50(%rbp), %rdi
movl $0x2e, %esi
callq 0x90b0
cmpq $0x0, %rax
jne 0xcf64
leaq -0x50(%rbp), %rdi
leaq 0xa5a4(%rip), %rsi      # 0x17503
callq 0x9180
leaq -0x50(%rbp), %rdi
leaq 0xba51(%rip), %rsi      # 0x189c0
callq 0x9160
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0xcfa9
movq 0xf072(%rip), %rax      # 0x1bff8
movq (%rax), %rdi
movq -0x8(%rbp), %rdx
leaq -0x50(%rbp), %rcx
leaq 0xa570(%rip), %rsi      # 0x17508
movb $0x0, %al
callq 0x9120
movl $0x6, %edi
callq 0x91a0
movl $0x1, -0xb4(%rbp)
leaq -0xb0(%rbp), %rdi
movq -0x18(%rbp), %rdx
movl $0x50, %esi
callq 0x90e0
cmpq $0x0, %rax
je 0xd670
leaq -0xb0(%rbp), %rdi
movl $0x3b, %esi
callq 0x90b0
movq %rax, -0xc8(%rbp)
cmpq $0x0, -0xc8(%rbp)
je 0xcffe
movq -0xc8(%rbp), %rax
movb $0x0, (%rax)
leaq -0xb0(%rbp), %rdi
callq 0xcc50
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rdi
leaq 0xa4fd(%rip), %rsi      # 0x1751c
movl $0x4, %edx
callq 0x9130
cmpl $0x0, %eax
jne 0xd1b7
movq -0xc0(%rbp), %rdi
addq $0x4, %rdi
callq 0xcc50
movq %rax, -0xc0(%rbp)
leaq -0x110(%rbp), %rdi
movq -0xc0(%rbp), %rsi
callq 0xccb0
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rdi
callq 0xcc50
movq %rax, -0xc0(%rbp)
movl $0x0, -0x144(%rbp)
movq -0xc0(%rbp), %rdi
leaq 0xa493(%rip), %rsi      # 0x17521
movl $0x4, %edx
callq 0x9130
cmpl $0x0, %eax
jne 0xd0b9
movq -0xc0(%rbp), %rax
addq $0x4, %rax
movq %rax, -0xc0(%rbp)
movl $0x1, -0x144(%rbp)
movq -0xc0(%rbp), %rdi
leaq 0xa45f(%rip), %rsi      # 0x17526
movl $0x4, %edx
callq 0x9130
cmpl $0x0, %eax
jne 0xd0f2
movq -0xc0(%rbp), %rax
addq $0x4, %rax
movq %rax, -0xc0(%rbp)
movl $0x2, -0x144(%rbp)
cmpl $0x0, -0x144(%rbp)
jne 0xd12b
movq 0xeef6(%rip), %rax      # 0x1bff8
movq (%rax), %rdi
movq -0x8(%rbp), %rdx
movl -0xb4(%rbp), %ecx
leaq -0x50(%rbp), %r8
leaq 0xa411(%rip), %rsi      # 0x1752b
movb $0x0, %al
callq 0x9120
movl $0x7, %edi
callq 0x91a0
leaq -0x110(%rbp), %rdi
callq 0xcb80
movq %rax, %rcx
leaq 0x1307f(%rip), %rax     # 0x201c0
movq %rcx, (%rax)
leaq 0x13075(%rip), %rax     # 0x201c0
cmpq $0x0, (%rax)
jne 0xd188
movq 0xeea0(%rip), %rax      # 0x1bff8
movq (%rax), %rdi
movq -0x8(%rbp), %rdx
movl -0xb4(%rbp), %ecx
leaq -0x50(%rbp), %r8
leaq -0x110(%rbp), %r9
leaq 0xa3ee(%rip), %rsi      # 0x17565
movb $0x0, %al
callq 0x9120
movl $0x7, %edi
callq 0x91a0
cmpl $0x1, -0x144(%rbp)
jne 0xd1a4
leaq 0x13028(%rip), %rax     # 0x201c0
movq (%rax), %rax
movl $0x1, 0x14(%rax)
jmp 0xd1b5
leaq 0x13015(%rip), %rax     # 0x201c0
movq (%rax), %rax
movl $0x0, 0x14(%rax)
jmp 0xd1b7
movq -0xc0(%rbp), %rdi
movl $0x3d, %esi
callq 0x90b0
movq %rax, -0xd0(%rbp)
cmpq $0x0, -0xd0(%rbp)
je 0xd38d
leaq -0x140(%rbp), %rdi
movq -0xc0(%rbp), %rsi
callq 0xccb0
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rdi
callq 0xcc50
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rdi
leaq 0xa389(%rip), %rsi      # 0x175a1
movl $0x1, %edx
callq 0x9130
cmpl $0x0, %eax
je 0xd257
movq 0xedca(%rip), %rax      # 0x1bff8
movq (%rax), %rdi
movq -0x8(%rbp), %rdx
movl -0xb4(%rbp), %ecx
leaq -0x50(%rbp), %r8
leaq 0xa35d(%rip), %rsi      # 0x175a3
movb $0x0, %al
callq 0x9120
movl $0x7, %edi
callq 0x91a0
movq -0xc0(%rbp), %rdi
addq $0x1, %rdi
callq 0xcc50
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rdi
movl $0x3a, %esi
callq 0x90b0
movq %rax, -0xd8(%rbp)
cmpq $0x0, -0xd8(%rbp)
jne 0xd2c0
movq 0xed61(%rip), %rax      # 0x1bff8
movq (%rax), %rdi
movq -0x8(%rbp), %rdx
movl -0xb4(%rbp), %ecx
leaq -0x50(%rbp), %r8
leaq 0xa333(%rip), %rsi      # 0x175e2
movb $0x0, %al
callq 0x9120
movl $0x7, %edi
callq 0x91a0
leaq -0x110(%rbp), %rdi
movq -0xc0(%rbp), %rsi
callq 0xccb0
movq %rax, -0xc0(%rbp)
movq -0xd8(%rbp), %rdi
addq $0x1, %rdi
callq 0xcc50
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rdi
leaq -0x150(%rbp), %rsi
callq 0xcd80
movq %rax, -0xc0(%rbp)
leaq -0x110(%rbp), %rdi
callq 0xcb80
movq %rax, %rcx
leaq 0x12e9f(%rip), %rax     # 0x201c0
movq %rcx, (%rax)
leaq 0x12e95(%rip), %rax     # 0x201c0
cmpq $0x0, (%rax)
jne 0xd368
movq 0xecc0(%rip), %rax      # 0x1bff8
movq (%rax), %rdi
movq -0x8(%rbp), %rdx
movl -0xb4(%rbp), %ecx
leaq -0x50(%rbp), %r8
leaq -0x110(%rbp), %r9
leaq 0xa20e(%rip), %rsi      # 0x17565
movb $0x0, %al
callq 0x9120
movl $0x7, %edi
callq 0x91a0
leaq 0x12e51(%rip), %rax     # 0x201c0
movq (%rax), %rax
movl (%rax), %edi
movq -0x150(%rbp), %rsi
leaq -0x140(%rbp), %rdx
xorl %r8d, %r8d
movl %r8d, %ecx
callq 0x15a90
movq -0xc0(%rbp), %rdi
movl $0x3a, %esi
callq 0x90b0
movq %rax, -0xd8(%rbp)
cmpq $0x0, -0xd8(%rbp)
je 0xd600
leaq -0x110(%rbp), %rdi
movq -0xc0(%rbp), %rsi
callq 0xccb0
movq %rax, -0xc0(%rbp)
leaq -0x110(%rbp), %rdi
callq 0xcb80
movq %rax, %rcx
leaq 0x12ddd(%rip), %rax     # 0x201c0
movq %rcx, (%rax)
leaq 0x12dd3(%rip), %rax     # 0x201c0
cmpq $0x0, (%rax)
jne 0xd42a
movq 0xebfe(%rip), %rax      # 0x1bff8
movq (%rax), %rdi
movq -0x8(%rbp), %rdx
movl -0xb4(%rbp), %ecx
leaq -0x50(%rbp), %r8
leaq -0x110(%rbp), %r9
leaq 0xa14c(%rip), %rsi      # 0x17565
movb $0x0, %al
callq 0x9120
movl $0x7, %edi
callq 0x91a0
movq -0xc0(%rbp), %rdi
callq 0xcc50
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rdi
leaq 0xb193(%rip), %rsi      # 0x185de
movl $0x1, %edx
callq 0x9130
cmpl $0x0, %eax
je 0xd48a
movq 0xeb97(%rip), %rax      # 0x1bff8
movq (%rax), %rdi
movq -0x8(%rbp), %rdx
movl -0xb4(%rbp), %ecx
leaq -0x50(%rbp), %r8
leaq 0xa19c(%rip), %rsi      # 0x17615
movb $0x0, %al
callq 0x9120
movl $0x7, %edi
callq 0x91a0
movq -0xc0(%rbp), %rdi
addq $0x1, %rdi
leaq -0x150(%rbp), %rsi
callq 0xcd80
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rdi
callq 0xcc50
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rdi
leaq 0xb115(%rip), %rsi      # 0x185de
movl $0x1, %edx
callq 0x9130
cmpl $0x0, %eax
je 0xd508
movq 0xeb19(%rip), %rax      # 0x1bff8
movq (%rax), %rdi
movq -0x8(%rbp), %rdx
movl -0xb4(%rbp), %ecx
leaq -0x50(%rbp), %r8
leaq 0xa11e(%rip), %rsi      # 0x17615
movb $0x0, %al
callq 0x9120
movl $0x7, %edi
callq 0x91a0
movq -0xc0(%rbp), %rdi
addq $0x1, %rdi
callq 0xcc50
movq %rax, -0xc0(%rbp)
leaq -0x140(%rbp), %rdi
movq -0xc0(%rbp), %rsi
callq 0xccb0
movq %rax, -0xc0(%rbp)
movl $0x0, -0x154(%rbp)
movl -0x154(%rbp), %eax
cmpl 0xf6e1(%rip), %eax      # 0x1cc30
jge 0xd58d
leaq -0x140(%rbp), %rdi
movslq -0x154(%rbp), %rcx
leaq 0xf66a(%rip), %rax      # 0x1cbd0
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rsi
callq 0x9040
cmpl $0x0, %eax
jne 0xd57c
jmp 0xd58d
movl -0x154(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x154(%rbp)
jmp 0xd543
movl -0x154(%rbp), %eax
cmpl 0xf697(%rip), %eax      # 0x1cc30
jne 0xd5cb
movq 0xea56(%rip), %rax      # 0x1bff8
movq (%rax), %rdi
movq -0x8(%rbp), %rdx
movl -0xb4(%rbp), %ecx
leaq -0x50(%rbp), %r8
leaq 0xa098(%rip), %rsi      # 0x17652
movb $0x0, %al
callq 0x9120
movl $0x7, %edi
callq 0x91a0
leaq 0x12bee(%rip), %rax     # 0x201c0
movq (%rax), %rax
movl (%rax), %edi
movq -0x150(%rbp), %rsi
movslq -0x154(%rbp), %rcx
leaq 0xf5e4(%rip), %rax      # 0x1cbd0
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x8(%rax), %edx
movl $0x1, %ecx
callq 0xcb10
movq -0xc0(%rbp), %rdi
callq 0xcc50
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rdi
callq 0x90a0
cmpq $0x0, %rax
je 0xd65c
movq 0xe9cc(%rip), %rax      # 0x1bff8
movq (%rax), %rdi
movq -0x8(%rbp), %rdx
movl -0xb4(%rbp), %ecx
leaq -0x50(%rbp), %r8
movq -0xc0(%rbp), %r9
leaq 0xa048(%rip), %rsi      # 0x17693
movb $0x0, %al
callq 0x9120
movl $0x7, %edi
callq 0x91a0
movl -0xb4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb4(%rbp)
jmp 0xcfb3
movq -0x18(%rbp), %rdi
callq 0x9090
addq $0x160, %rsp            # imm = 0x160
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)