// File: /workspace/github_c_makefile_star2_O3/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 $0x128, %rsp            # imm = 0x128
movq %rdi, 0x8(%rsp)
leaq 0x20(%rsp), %rbx
movq %rbx, %rdi
callq 0x9070
movq %rbx, %rdi
movl $0x2e, %esi
callq 0x90c0
testq %rax, %rax
jne 0xbd95
leaq 0x20(%rsp), %rdi
callq 0x90b0
movl $0x6464612e, 0x20(%rsp,%rax) # imm = 0x6464612E
movb $0x0, 0x24(%rsp,%rax)
leaq 0x8bfc(%rip), %rsi      # 0x14998
leaq 0x20(%rsp), %rdi
callq 0x9180
testq %rax, %rax
je 0xc3c3
movq %rax, %r14
leaq 0xd0(%rsp), %r15
movq %r15, %rdi
movl $0x50, %esi
movq %rax, %rdx
callq 0x9100
testq %rax, %rax
je 0xc2d1
movl $0x1, %ebx
movabsq $0x100000600, %rbp      # imm = 0x100000600
movabsq $0x2400000100000601, %r12 # imm = 0x2400000100000601
movq %r14, 0x98(%rsp)
movq %r15, %rdi
movl $0x3b, %esi
callq 0x90c0
testq %rax, %rax
je 0xbe09
movb $0x0, (%rax)
leaq 0xd5(%rsp), %r13
movzbl (%r15), %eax
cmpq $0x20, %rax
ja 0xbe29
btq %rax, %rbp
jae 0xbe29
incq %r15
incq %r13
jmp 0xbe11
movl $0x4, %edx
movq %r15, %rdi
leaq 0x773d(%rip), %rsi      # 0x13575
callq 0x9150
testl %eax, %eax
jne 0xbf4a
addq $0x4, %r15
movzbl (%r15), %eax
cmpq $0x20, %rax
ja 0xbe61
btq %rax, %rbp
jae 0xbe61
incq %r15
incq %r13
jmp 0xbe49
xorl %ecx, %ecx
cmpb $0x3d, %al
ja 0xbe70
movzbl %al, %edx
btq %rdx, %r12
jb 0xbe89
movb %al, 0x60(%rsp,%rcx)
cmpl $0x27, %ecx
je 0xc2c4
movb (%r13), %al
incq %rcx
incq %r13
jmp 0xbe63
addq %rcx, %r15
leaq (%rsp,%rcx), %rax
addq $0x60, %rax
movq %r15, %r13
movb $0x0, (%rax)
movzbl (%r13), %eax
cmpq $0x20, %rax
ja 0xbeb0
btq %rax, %rbp
jae 0xbeb0
incq %r13
jmp 0xbe9a
movl %ebx, 0x14(%rsp)
movl $0x4, %edx
movq %r13, %rdi
leaq 0x76b7(%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 %bl
movl $0x4, %edx
movq %r13, %rdi
leaq 0x768f(%rip), %rsi      # 0x1357f
callq 0x9150
movl %eax, %r12d
testl %eax, %eax
setne %al
cmovneq %r13, %r15
andb %bl, %al
cmpb $0x1, %al
je 0xc39f
leaq 0x60(%rsp), %rdi
callq 0xbb70
leaq 0x110d4(%rip), %rcx     # 0x1cff0
movq %rax, (%rcx)
testq %rax, %rax
movl 0x14(%rsp), %ebx
je 0xc342
testl %r12d, %r12d
setne %cl
testl %r14d, %r14d
sete %dl
andb %cl, %dl
movzbl %dl, %ecx
movl %ecx, 0x14(%rax)
movabsq $0x2400000100000601, %r12 # imm = 0x2400000100000601
movq %r15, %rdi
movl $0x3d, %esi
callq 0x90c0
testq %rax, %rax
je 0xc087
xorl %eax, %eax
movzbl (%r15,%rax), %ecx
cmpq $0x3d, %rcx
ja 0xbf73
btq %rcx, %r12
jb 0xbf82
movb %cl, 0xa0(%rsp,%rax)
incq %rax
cmpl $0x28, %eax
jne 0xbf62
addq %rax, %r15
addq %rsp, %rax
addq $0xa0, %rax
movb $0x0, (%rax)
leaq 0x1(%r15), %r13
leaq 0x2(%r15), %r14
movzbl (%r15), %eax
cmpq $0x20, %rax
ja 0xbfb4
btq %rax, %rbp
jae 0xbfb4
incq %r15
incq %r13
incq %r14
jmp 0xbf99
movl $0x1, %edx
movq %r15, %rdi
leaq 0x7637(%rip), %rsi      # 0x135fa
callq 0x9150
testl %eax, %eax
jne 0xc38c
movzbl (%r13), %r15d
cmpq $0x20, %r15
ja 0xbfe9
btq %r15, %rbp
jae 0xbfe9
incq %r13
incq %r14
jmp 0xbfd0
movq %r13, %rdi
movl $0x3a, %esi
callq 0x90c0
testq %rax, %rax
je 0xc379
movl $0x27, %edx
leaq 0x60(%rsp), %rcx
cmpb $0x3d, %r15b
ja 0xc019
movzbl %r15b, %esi
btq %rsi, %r12
jb 0xc02c
movb %r15b, (%rcx)
incq %rcx
subl $0x1, %edx
jb 0xc02c
movb (%r14), %r15b
incq %r14
jmp 0xc009
movb $0x0, (%rcx)
incq %rax
movzbl (%rax), %ecx
cmpq $0x20, %rcx
ja 0xc041
btq %rcx, %rbp
jb 0xc02f
movq %rax, %rdi
leaq 0x18(%rsp), %rsi
callq 0xbc6f
movq %rax, %r15
leaq 0x60(%rsp), %rdi
callq 0xbb70
leaq 0x10f8e(%rip), %rcx     # 0x1cff0
movq %rax, (%rcx)
testq %rax, %rax
je 0xc342
movl (%rax), %edi
movq 0x18(%rsp), %rsi
leaq 0xa0(%rsp), %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x11c13
movq %r15, %rdi
movl $0x3a, %esi
callq 0x90c0
testq %rax, %rax
je 0xc273
xorl %eax, %eax
movzbl (%r15,%rax), %ecx
cmpq $0x3d, %rcx
ja 0xc0b0
btq %rcx, %r12
jb 0xc0bc
movb %cl, 0x60(%rsp,%rax)
incq %rax
cmpl $0x28, %eax
jne 0xc09f
addq %rax, %r15
addq %rsp, %rax
addq $0x60, %rax
movb $0x0, (%rax)
leaq 0x60(%rsp), %rdi
callq 0xbb70
leaq 0x10f16(%rip), %rcx     # 0x1cff0
movq %rax, (%rcx)
testq %rax, %rax
je 0xc342
movzbl (%r15), %eax
cmpq $0x20, %rax
ja 0xc0fb
btq %rax, %rbp
jae 0xc0fb
incq %r15
jmp 0xc0e6
movl $0x1, %edx
movq %r15, %rdi
leaq 0x84b0(%rip), %rsi      # 0x145ba
callq 0x9150
testl %eax, %eax
jne 0xc366
incq %r15
movq %r15, %rdi
leaq 0x18(%rsp), %rsi
callq 0xbc6f
leaq 0x1(%rax), %r14
movq %rax, %r15
addq $0x2, %r15
movzbl (%rax), %ecx
cmpq $0x20, %rcx
ja 0xc14c
btq %rcx, %rbp
jae 0xc14c
incq %rax
incq %r14
incq %r15
jmp 0xc132
movl $0x1, %edx
movq %rax, %rdi
leaq 0x845f(%rip), %rsi      # 0x145ba
callq 0x9150
testl %eax, %eax
jne 0xc366
movzbl (%r14), %eax
cmpq $0x20, %rax
ja 0xc180
btq %rax, %rbp
jae 0xc180
incq %r14
incq %r15
jmp 0xc168
xorl %ecx, %ecx
cmpb $0x3d, %al
ja 0xc18f
movzbl %al, %edx
btq %rdx, %r12
jb 0xc1aa
movb %al, 0xa0(%rsp,%rcx)
cmpl $0x27, %ecx
je 0xc2b5
movb (%r15), %al
incq %rcx
incq %r15
jmp 0xc182
addq %rcx, %r14
leaq (%rsp,%rcx), %rax
addq $0xa0, %rax
movq %r14, %r15
movb $0x0, (%rax)
movslq 0xd93c(%rip), %r14      # 0x19b00
testq %r14, %r14
jle 0xc1f9
leaq 0xd8d0(%rip), %r13      # 0x19aa0
xorl %r12d, %r12d
movq (%r13), %rsi
leaq 0xa0(%rsp), %rdi
callq 0x9050
testl %eax, %eax
je 0xc1fc
incq %r12
addq $0x10, %r13
cmpq %r12, %r14
jne 0xc1d3
jmp 0xc314
xorl %r12d, %r12d
cmpl %r14d, %r12d
je 0xc314
leaq 0x10de4(%rip), %rax     # 0x1cff0
movq (%rax), %rax
movl %ebx, %r13d
movl (%rax), %ebx
movq 0x18(%rsp), %r14
movl %r12d, %eax
shlq $0x4, %rax
leaq 0xd879(%rip), %rcx      # 0x19aa0
movl 0x8(%rax,%rcx), %r12d
movl $0x18, %edi
callq 0x128e2
movl %ebx, (%rax)
movl %r13d, %ebx
movq %r14, 0x8(%rax)
movl %r12d, 0x4(%rax)
movq $0x1, 0x10(%rax)
leaq 0x10d86(%rip), %rcx     # 0x1cfd8
movq (%rcx), %rsi
movq %rax, %rdi
leaq -0x763(%rip), %rdx      # 0xbafc
callq 0x125e8
movabsq $0x2400000100000601, %r12 # imm = 0x2400000100000601
jmp 0xc273
incq %r15
movzbl (%r15), %eax
leal -0x9(%rax), %ecx
cmpl $0x2, %ecx
jb 0xc270
cmpl $0x20, %eax
je 0xc270
testl %eax, %eax
jne 0xc2eb
incl %ebx
leaq 0xd0(%rsp), %r15
movq %r15, %rdi
movl $0x50, %esi
movq 0x98(%rsp), %r14
movq %r14, %rdx
callq 0x9100
testq %rax, %rax
jne 0xbdf4
jmp 0xc2d1
leaq (%rsp,%rcx), %rax
addq $0xa1, %rax
jmp 0xc1ba
leaq (%rsp,%rcx), %rax
addq $0x61, %rax
jmp 0xbe97
movq %r14, %rdi
callq 0x90a0
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xcd06(%rip), %rax      # 0x18ff8
movq (%rax), %rdi
leaq 0x73f0(%rip), %rsi      # 0x136ec
leaq 0x20(%rsp), %r8
movq 0x8(%rsp), %rdx
movl %ebx, %ecx
movq %r15, %r9
xorl %eax, %eax
callq 0x9140
jmp 0xc338
movq 0xccdd(%rip), %rax      # 0x18ff8
movq (%rax), %rdi
leaq 0x7386(%rip), %rsi      # 0x136ab
leaq 0x20(%rsp), %r8
movq 0x8(%rsp), %rdx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x9140
movl $0x7, %edi
callq 0x91c0
movq 0xccaf(%rip), %rax      # 0x18ff8
movq (%rax), %rdi
leaq 0x726b(%rip), %rsi      # 0x135be
leaq 0x20(%rsp), %r8
leaq 0x60(%rsp), %r9
movq 0x8(%rsp), %rdx
movl %ebx, %ecx
jmp 0xc30b
movq 0xcc8b(%rip), %rax      # 0x18ff8
movq (%rax), %rdi
leaq 0x72f7(%rip), %rsi      # 0x1366e
jmp 0xc325
movq 0xcc78(%rip), %rax      # 0x18ff8
movq (%rax), %rdi
leaq 0x72b1(%rip), %rsi      # 0x1363b
jmp 0xc325
movq 0xcc65(%rip), %rax      # 0x18ff8
movq (%rax), %rdi
leaq 0x725f(%rip), %rsi      # 0x135fc
jmp 0xc325
movq 0xcc52(%rip), %rax      # 0x18ff8
movq (%rax), %rdi
leaq 0x71d4(%rip), %rsi      # 0x13584
leaq 0x20(%rsp), %r8
movq 0x8(%rsp), %rdx
movl 0x14(%rsp), %ecx
jmp 0xc331
leaq 0x20(%rsp), %rsi
movq 0x8(%rsp), %rdi
callq 0x9210
nop