// File: /workspace/github_c_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rdi, 0x8(%rsp)
leaq 0x50(%rsp), %rbx
movq %rbx, %rdi
callq 0x9070
movq %rbx, %rdi
movl $0x2e, %esi
callq 0x90c0
testq %rax, %rax
jne 0xbd39
leaq 0x50(%rsp), %rdi
callq 0x90b0
movl $0x6464612e, 0x50(%rsp,%rax) # imm = 0x6464612E
movb $0x0, 0x54(%rsp,%rax)
leaq 0x8c58(%rip), %rsi      # 0x14998
leaq 0x50(%rsp), %rdi
callq 0x9180
testq %rax, %rax
je 0xc333
movq %rax, %r14
leaq 0xc0(%rsp), %r15
movq %r15, %rdi
movl $0x50, %esi
movq %rax, %rdx
callq 0x9100
testq %rax, %rax
je 0xc218
movl $0x1, %ebp
movabsq $0x100000600, %rbx      # imm = 0x100000600
movabsq $0x2400000100000601, %r12 # imm = 0x2400000100000601
movq %r14, 0x88(%rsp)
movq %r15, %rdi
movl $0x3b, %esi
callq 0x90c0
testq %rax, %rax
je 0xbdad
movb $0x0, (%rax)
movzbl (%r15), %eax
cmpq $0x20, %rax
ja 0xbdc2
btq %rax, %rbx
jae 0xbdc2
incq %r15
jmp 0xbdad
movl $0x4, %edx
movq %r15, %rdi
leaq 0x77a4(%rip), %rsi      # 0x13575
callq 0x9150
testl %eax, %eax
movl %ebp, 0x14(%rsp)
jne 0xbed8
addq $0x4, %r15
movzbl (%r15), %eax
cmpq $0x20, %rax
ja 0xbdfb
btq %rax, %rbx
jae 0xbdfb
incq %r15
jmp 0xbde6
xorl %eax, %eax
movzbl (%r15,%rax), %ecx
cmpq $0x3d, %rcx
ja 0xbe0e
btq %rcx, %r12
jb 0xbe1a
movb %cl, 0x20(%rsp,%rax)
incq %rax
cmpl $0x28, %eax
jne 0xbdfd
addq %rax, %r15
addq %rsp, %rax
addq $0x20, %rax
movq %r15, %r13
movb $0x0, (%rax)
movzbl (%r13), %eax
cmpq $0x20, %rax
ja 0xbe40
btq %rax, %rbx
jae 0xbe40
incq %r13
jmp 0xbe2a
movl $0x4, %edx
movq %r13, %rdi
leaq 0x772b(%rip), %rsi      # 0x1357a
callq 0x9150
movl %eax, %r14d
leaq 0x4(%r13), %rax
leaq 0x8(%r13), %r15
testl %r14d, %r14d
cmoveq %rax, %r13
cmovneq %rax, %r15
setne %bpl
movl $0x4, %edx
movq %r13, %rdi
leaq 0x7702(%rip), %rsi      # 0x1357f
callq 0x9150
movl %eax, %r12d
testl %eax, %eax
setne %al
cmovneq %r13, %r15
andb %bpl, %al
cmpb $0x1, %al
je 0xc2df
leaq 0x20(%rsp), %rdi
callq 0xbafc
leaq 0x11146(%rip), %rcx     # 0x1cff0
movq %rax, (%rcx)
testq %rax, %rax
je 0xc30a
testl %r12d, %r12d
setne %cl
testl %r14d, %r14d
sete %dl
andb %cl, %dl
movzbl %dl, %ecx
movl %ecx, 0x14(%rax)
movl 0x14(%rsp), %ebp
movabsq $0x2400000100000601, %r12 # imm = 0x2400000100000601
movq %r15, %rdi
movl $0x3d, %esi
callq 0x90c0
testq %rax, %rax
je 0xc005
xorl %eax, %eax
movzbl (%r15,%rax), %ecx
cmpq $0x3d, %rcx
ja 0xbf01
btq %rcx, %r12
jb 0xbf10
movb %cl, 0x90(%rsp,%rax)
incq %rax
cmpl $0x28, %eax
jne 0xbef0
addq %rax, %r15
addq %rsp, %rax
addq $0x90, %rax
movb $0x0, (%rax)
leaq 0x1(%r15), %r13
movzbl (%r15), %eax
cmpq $0x20, %rax
ja 0xbf3b
btq %rax, %rbx
jae 0xbf3b
incq %r15
incq %r13
jmp 0xbf23
movl $0x1, %edx
movq %r15, %rdi
leaq 0x76b0(%rip), %rsi      # 0x135fa
callq 0x9150
testl %eax, %eax
jne 0xc2ad
movzbl (%r13), %eax
cmpq $0x20, %rax
ja 0xbf6d
btq %rax, %rbx
jae 0xbf6d
incq %r13
jmp 0xbf57
movq %r13, %rdi
movl $0x3a, %esi
callq 0x90c0
testq %rax, %rax
je 0xc29a
xorl %ecx, %ecx
movzbl (%r13,%rcx), %edx
cmpq $0x3d, %rdx
ja 0xbf97
btq %rdx, %r12
jb 0xbfa3
movb %dl, 0x20(%rsp,%rcx)
incq %rcx
cmpl $0x28, %ecx
jne 0xbf85
addq %rsp, %rcx
addq $0x20, %rcx
movb $0x0, (%rcx)
incq %rax
movzbl (%rax), %ecx
cmpq $0x20, %rcx
ja 0xbfbf
btq %rcx, %rbx
jb 0xbfad
movq %rax, %rdi
leaq 0x18(%rsp), %rsi
callq 0xbbfb
movq %rax, %r15
leaq 0x20(%rsp), %rdi
callq 0xbafc
leaq 0x11010(%rip), %rcx     # 0x1cff0
movq %rax, (%rcx)
testq %rax, %rax
je 0xc263
movl (%rax), %edi
movq 0x18(%rsp), %rsi
leaq 0x90(%rsp), %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x11b87
movq %r15, %rdi
movl $0x3a, %esi
callq 0x90c0
testq %rax, %rax
je 0xc1d8
xorl %eax, %eax
movzbl (%r15,%rax), %ecx
cmpq $0x3d, %rcx
ja 0xc02e
btq %rcx, %r12
jb 0xc03a
movb %cl, 0x20(%rsp,%rax)
incq %rax
cmpl $0x28, %eax
jne 0xc01d
addq %rax, %r15
addq %rsp, %rax
addq $0x20, %rax
movb $0x0, (%rax)
leaq 0x20(%rsp), %rdi
callq 0xbafc
leaq 0x10f98(%rip), %rcx     # 0x1cff0
movq %rax, (%rcx)
testq %rax, %rax
je 0xc263
movzbl (%r15), %eax
cmpq $0x20, %rax
ja 0xc079
btq %rax, %rbx
jae 0xc079
incq %r15
jmp 0xc064
movl $0x1, %edx
movq %r15, %rdi
leaq 0x8532(%rip), %rsi      # 0x145ba
callq 0x9150
testl %eax, %eax
jne 0xc287
incq %r15
movq %r15, %rdi
leaq 0x18(%rsp), %rsi
callq 0xbbfb
movq %rax, %r15
incq %r15
movzbl (%rax), %ecx
cmpq $0x20, %rcx
ja 0xc0bf
btq %rcx, %rbx
jae 0xc0bf
incq %rax
jmp 0xc0a8
movl $0x1, %edx
movq %rax, %rdi
leaq 0x84ec(%rip), %rsi      # 0x145ba
callq 0x9150
testl %eax, %eax
jne 0xc287
movzbl (%r15), %eax
cmpq $0x20, %rax
ja 0xc0f0
btq %rax, %rbx
jae 0xc0f0
incq %r15
jmp 0xc0db
xorl %eax, %eax
movzbl (%r15,%rax), %ecx
cmpq $0x3d, %rcx
ja 0xc103
btq %rcx, %r12
jb 0xc112
movb %cl, 0x90(%rsp,%rax)
incq %rax
cmpl $0x28, %eax
jne 0xc0f2
addq %rax, %r15
addq %rsp, %rax
addq $0x90, %rax
movb $0x0, (%rax)
movl 0xd9d8(%rip), %r14d     # 0x19b00
testl %r14d, %r14d
leaq 0x90(%rsp), %rbp
jle 0xc160
leaq 0xd964(%rip), %r13      # 0x19aa0
xorl %r12d, %r12d
movq (%r13), %rsi
movq %rbp, %rdi
callq 0x9050
testl %eax, %eax
je 0xc163
incq %r12
addq $0x10, %r13
cmpq %r12, %r14
jne 0xc13f
movl %r14d, %r12d
jmp 0xc163
xorl %r12d, %r12d
cmpl %r14d, %r12d
je 0xc2cc
leaq 0x10e7d(%rip), %rax     # 0x1cff0
movq (%rax), %rax
movl (%rax), %ebp
movq 0x18(%rsp), %r14
movl %r12d, %eax
shlq $0x4, %rax
leaq 0xd915(%rip), %rcx      # 0x19aa0
movl 0x8(%rax,%rcx), %r12d
movl $0x18, %edi
callq 0x1282e
movl %ebp, (%rax)
movq %r14, 0x8(%rax)
movl %r12d, 0x4(%rax)
movq $0x1, 0x10(%rax)
leaq 0x10e25(%rip), %rcx     # 0x1cfd8
movq (%rcx), %rsi
movq %rax, %rdi
leaq -0x738(%rip), %rdx      # 0xba88
callq 0x12538
movl 0x14(%rsp), %ebp
movabsq $0x2400000100000601, %r12 # imm = 0x2400000100000601
jmp 0xc1d8
incq %r15
movzbl (%r15), %eax
leal -0x9(%rax), %ecx
cmpl $0x2, %ecx
jb 0xc1d5
cmpl $0x20, %eax
je 0xc1d5
testl %eax, %eax
jne 0xc232
incl %ebp
leaq 0xc0(%rsp), %r15
movq %r15, %rdi
movl $0x50, %esi
movq 0x88(%rsp), %r14
movq %r14, %rdx
callq 0x9100
testq %rax, %rax
jne 0xbd98
movq %r14, %rdi
callq 0x90a0
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xcdbf(%rip), %rax      # 0x18ff8
movq (%rax), %rdi
leaq 0x74a9(%rip), %rsi      # 0x136ec
leaq 0x50(%rsp), %r8
movq 0x8(%rsp), %rdx
movl %ebp, %ecx
movq %r15, %r9
xorl %eax, %eax
callq 0x9140
movl $0x7, %edi
callq 0x91c0
movq 0xcd8e(%rip), %rax      # 0x18ff8
movq (%rax), %rdi
leaq 0x734a(%rip), %rsi      # 0x135be
leaq 0x50(%rsp), %r8
leaq 0x20(%rsp), %r9
movq 0x8(%rsp), %rdx
movl %ebp, %ecx
jmp 0xc252
movq 0xcd6a(%rip), %rax      # 0x18ff8
movq (%rax), %rdi
leaq 0x73d6(%rip), %rsi      # 0x1366e
jmp 0xc2be
movq 0xcd57(%rip), %rax      # 0x18ff8
movq (%rax), %rdi
leaq 0x7390(%rip), %rsi      # 0x1363b
jmp 0xc2be
movq 0xcd44(%rip), %rax      # 0x18ff8
movq (%rax), %rdi
leaq 0x733e(%rip), %rsi      # 0x135fc
leaq 0x50(%rsp), %r8
movq 0x8(%rsp), %rdx
movl %ebp, %ecx
jmp 0xc2fe
movq 0xcd25(%rip), %rax      # 0x18ff8
movq (%rax), %rdi
leaq 0x73ce(%rip), %rsi      # 0x136ab
jmp 0xc2f0
movq 0xcd12(%rip), %rax      # 0x18ff8
movq (%rax), %rdi
leaq 0x7294(%rip), %rsi      # 0x13584
leaq 0x50(%rsp), %r8
movq 0x8(%rsp), %rdx
movl 0x14(%rsp), %ecx
xorl %eax, %eax
callq 0x9140
jmp 0xc259
movq 0xcce7(%rip), %rax      # 0x18ff8
movq (%rax), %rdi
leaq 0x72a3(%rip), %rsi      # 0x135be
leaq 0x50(%rsp), %r8
leaq 0x20(%rsp), %r9
movq 0x8(%rsp), %rdx
movl 0x14(%rsp), %ecx
jmp 0xc252
leaq 0x50(%rsp), %rsi
movq 0x8(%rsp), %rdi
callq 0x9210
nop