// File: /workspace/github_c_makefile_star2_O3/Nico01[P]obj2asm/oprocess.c
// Function: proc_normal
int proc_normal(int inst_proc)
{
    int      data_size;
    int      data;
    int      inst_length;
    int      zeros;
    int      string_limit;
    int      dcheck;
    char     temp[3];
    int      this_size;
    int      data_type;
    int      direct;
    LINE_T   Line, *pLine;
    SCOPE_T  Scope, *pEndScope, *pArgScope, *pLocScope, *pScope;
    NODE_T  *pNode;
    LOCAL_VAR *pVar;

    data_type = UNKNOWN;
    /*
    ** Step 0, determine if there is a hint record at this position
    */
    hint_search.seg_idx    = segment;
    hint_search.offset     = inst_offset;
    direct = RIGHT;
    while ( hint_node != hint_tree
            && (direct = hint_compare( &hint_search, hint_rec )) == LEFT ) {
        hint_advance();
        direct = RIGHT;
    }
    if ( direct == EQUAL ) {
        data_type = hint_rec->hint_type;
    }

    if ( data_type == UNKNOWN ) {       /* Default, search for string */
        /*
        ** Step 1, Is it a string?
        */
        data_size = 0;
        zeros = TRUE;
        do {
            data = buff_getc();
            if ( data == EOF ) {
                break;
            }
            if ( data != 0 && data != 0x0A && data != 0x0D && data != 0x1B
                  && (data < ' ' || data > '~') ) {
                break;
            }
            if ( data != 0 ) {
                zeros = FALSE;
            }
            data_size++;
            inst_offset++;
            dcheck = data_check( 0 );
        } while ( dcheck == NORMAL || dcheck == BAD );

        if ( inst_proc ) {
            string_limit = code_string;
        } else {
            string_limit = data_string;
        }
        if ( data_size >= string_limit || (zeros && data_size > 1) ) {
            if ( last_pub_rec && last_pub_rec->type > FAR ) {
                this_size = type_to_size(last_pub_rec->type);
                if ( data_size < this_size ) {
                    last_pub_rec->type = BYTE_PTR;
                }
                data_byte( this_size );
                buff_reseek();
                inst_offset -= data_size;
                inst_offset += this_size;
                last_pub_rec = NULL;
                return( this_size );
            } else {
                /*
                ** Either near, far, or unknown
                */
                if ( last_pub_rec && pass == 3 ) {
                    if ( last_pub_rec->type == FAR ) {
                        out_directive("=");
                        out_operand("$");
                    }
                    if ( last_pub_rec->type == NEAR ) {
                        out_endline();
                    }
                }
                empty_string( data_size );
                buff_reseek();
                last_pub_rec = NULL;
                return( data_size );
            }
        }
        buff_reseek();
        inst_offset -= data_size;
    }

    if ( data_type == NEAR || (inst_proc && data_type == UNKNOWN) ) {
        data = (uchar)buff_getc();
#ifdef DEBUG
        printf("Disassembly instruction lookup [%02X]\n", data );
#endif
        hex_finish = TRUE;

        inst_length = (*instr[data].rtn)
                        ((uchar)data,
                        instr[data].text,
                        instr[data].special );
        if ( inst_length == 0 ) {       /* Wrong, it wasn't an instruction */
            data_type = UNKNOWN;
        }
    } else {
        inst_length = 0;
    }

    if ( inst_length ) {
        /*
        ** Check for instruction routine returning the proper number
        ** of bytes eaten from buffer.
        */
        if ( buff_cur - buff_beg != inst_length ) {
#ifdef DEBUG
            printf("PN: Buffer remaining: %04d Length remaining: %04d\n",
                                        buff_cur - buff_beg, inst_length );
#endif
            fmt_error("Disassembly Internal Instruction Processing" );
        }

        /*
        ** Yes, instruction, throw away buffer
        */
        if ( !*hex_comment ) {
            Line.hex_offset = inst_offset;
            pLine = find(&Line, line_tree, TC linnum_compare, NULL);
            Scope.hex_offset = inst_offset+inst_length;
            if (pass==3) {
              pScope = pEndScope = find(&Scope, end_scope_tree, TC scope_compare, &pNode);
              pArgScope = find(&Scope, arg_scope_tree, TC scope_compare, NULL);
              pLocScope = find(&Scope, loc_scope_tree, TC scope_compare, NULL);
              while (pScope && pEndScope->hex_offset == pScope->hex_offset) {
                out_comment("End of scope");
                pScope = pNode->ptr[LEFT]->data;
                pNode = pNode->ptr[LEFT];
              }
              if (pLocScope) {
                out_line("; Start of scope (locals)","","","");
                pVar = pLocScope->head;
                while (pVar) {
                  out_var(pVar);
                  pVar = pVar->next;
                }
              }
              if (pArgScope) {
                out_line("; Start of scope (arguments)","","","");
                pVar = pArgScope->head;
                while (pVar) {
                  out_var(pVar);
                  pVar = pVar->next;
                }
              }
            }
            if (pLine)
              sprintf(hex_comment, "[%05d] %04X: ", pLine->line_number, inst_offset);
            else
              sprintf(hex_comment, "        %04X: ", inst_offset );
        }
        this_size = inst_length;
        while ( this_size-- ) {
            sprintf( temp, "%02X", (uchar)buff_regetc() );
            strcat( hex_comment, temp );
        }
        if ( hex_finish ) {
            if ( pass == 3 ) {
                if ( hex_output ) {
                    out_comment( hex_comment );
                }
                out_endline();
            }
            *hex_comment = 0;
        }
        inst_offset += inst_length;
        if ( last_pub_rec ) {
            if ( last_pub_rec->type != FAR ) {
                last_pub_rec->type = NEAR;
            }
            last_pub_rec = NULL;
        }
        return( inst_length );
    }

    /*
    ** Ingore any assumes that might have been pending
    */
    abort_assumes();

    /*
    ** Nope, not instruction.  Leave byte
    */
    buff_reseek();      /* Back to start, instruction */
                        /* look may have moved ptr    */
    if ( last_pub_rec && last_pub_rec->type > FAR ) {
        if ( last_pub_rec->type == UNKNOWN ) {
            last_pub_rec->type = BYTE_PTR;      /* Default if not known */
        }
        if ( data_type == UNKNOWN ) {           /* Default if no hint */
            data_type = last_pub_rec->type;
        }
        last_pub_rec->type = data_type;         /* Assign actual type */
    } else {
        if ( data_type == UNKNOWN ) {
            data_type = BYTE_PTR;
        }
    }
    data_size = type_to_size( data_type );
    data_byte( data_size );
    last_pub_rec = NULL;
    inst_offset += data_size;
    return( data_size );
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %edi, %ebp
leaq 0xf873(%rip), %rax      # 0x1d190
movl (%rax), %eax
leaq 0xf7d2(%rip), %rcx      # 0x1d0f8
movl %eax, (%rcx)
leaq 0xf869(%rip), %r13      # 0x1d198
movq (%r13), %rax
movq %rax, 0x8(%rcx)
leaq 0xf7aa(%rip), %r14      # 0x1d0e8
movq (%r14), %rax
leaq 0xf690(%rip), %r12      # 0x1cfd8
cmpq (%r12), %rax
je 0xd9a0
leaq 0xf79b(%rip), %r15      # 0x1d0f0
movq (%r15), %rsi
leaq 0xf799(%rip), %rbx      # 0x1d0f8
movq %rbx, %rdi
callq 0xbafc
testl %eax, %eax
jne 0xd98a
movq (%r14), %rdi
movl $0x1, %esi
callq 0x1288c
movq %rax, (%r14)
movq 0x20(%rax), %rsi
movq %rsi, (%r15)
cmpq (%r12), %rax
jne 0xd95f
jmp 0xd9a0
cmpl $0x2, %eax
jne 0xd9a0
movq (%r15), %rax
movl 0x4(%rax), %ebx
testl %ebx, %ebx
je 0xd9a0
xorl %eax, %eax
jmp 0xda87
movl $0x1, %ebx
movl $0x1, %r14d
callq 0xf47e
cmpl $0xc, %eax
jg 0xd9c5
testl %eax, %eax
je 0xd9da
cmpl $0xa, %eax
je 0xd9d7
cmpl $-0x1, %eax
jne 0xd9cf
jmp 0xd9f2
cmpl $0xd, %eax
je 0xd9d7
cmpl $0x1b, %eax
je 0xd9d7
addl $-0x7f, %eax
cmpl $-0x5f, %eax
jb 0xd9f2
xorl %r14d, %r14d
incq (%r13)
xorl %edi, %edi
callq 0xcd14
cmpl $0x3, %eax
je 0xd9ee
testl %eax, %eax
jne 0xd9f4
incl %ebx
jmp 0xd9ab
decl %ebx
testl %ebp, %ebp
jne 0xda01
leaq 0xc109(%rip), %rax      # 0x19b08
jmp 0xda08
leaq 0xc0fc(%rip), %rax      # 0x19b04
cmpl (%rax), %ebx
jge 0xda1c
testl %r14d, %r14d
sete %al
cmpl $0x2, %ebx
setl %cl
orb %al, %cl
jne 0xda77
leaq 0xf66d(%rip), %r14      # 0x1d090
movq (%r14), %rax
testq %rax, %rax
je 0xdc5e
movl 0x38(%rax), %edi
cmpl $0x3, %edi
jl 0xdc25
callq 0xf666
movl %eax, %ebp
cmpl %eax, %ebx
jge 0xda50
movq (%r14), %rax
movl $0x3, 0x38(%rax)
movl %ebp, %edi
callq 0xcee6
callq 0xf398
movslq %ebx, %rax
movslq %ebp, %rcx
subq %rax, %rcx
addq %rcx, (%r13)
movq $0x0, (%r14)
movl %ebp, %ebx
jmp 0xdde6
callq 0xf398
movslq %ebx, %rax
subq %rax, (%r13)
xorl %ebx, %ebx
movb $0x1, %al
cmpl $0x1, %ebx
setne %cl
testl %ebp, %ebp
sete %dl
xorb $0x1, %al
orb %dl, %al
testb %al, %cl
jne 0xdc78
callq 0xf47e
movzbl %al, %edi
leaq 0xf703(%rip), %rax      # 0x1d1b0
movl $0x1, (%rax)
leaq (%rdi,%rdi,2), %rax
leaq 0xc0a2(%rip), %rcx      # 0x19b60
movq 0x10(%rcx,%rax,8), %rsi
movl 0x8(%rcx,%rax,8), %edx
callq *(%rcx,%rax,8)
testl %eax, %eax
je 0xdc76
movl %eax, %ebx
leaq 0x10afd(%rip), %rax     # 0x1e5d8
movq (%rax), %rax
leaq 0x10aeb(%rip), %rcx     # 0x1e5d0
subq (%rcx), %rax
movslq %ebx, %r12
cmpq %r12, %rax
je 0xdafc
leaq 0x61d2(%rip), %rdi      # 0x13cc9
callq 0x128bc
cmpb $0x0, 0xf9bd(%rip)      # 0x1d4c0
movq %r12, 0x20(%rsp)
jne 0xdd45
movq (%r13), %rax
leaq 0x38(%rsp), %rdi
movq %rax, (%rdi)
leaq 0xf44f(%rip), %rax      # 0x1cf70
movq (%rax), %rsi
leaq 0x3ef5(%rip), %rdx      # 0x11a20
xorl %ecx, %ecx
callq 0x1280f
movq %rax, %r14
movq (%r13), %rax
addq %r12, %rax
movq %rax, 0x28(%rsp)
leaq 0xf420(%rip), %rax      # 0x1cf68
cmpl $0x3, (%rax)
jne 0xdd08
leaq 0xf430(%rip), %rax      # 0x1cf88
movq (%rax), %rsi
leaq 0x29d2(%rip), %r15      # 0x10534
leaq 0x28(%rsp), %rbp
leaq 0x8(%rsp), %rcx
movq %rbp, %rdi
movq %r15, %rdx
callq 0x1280f
movq %rax, %r12
leaq 0xf3f7(%rip), %rax      # 0x1cf78
movq (%rax), %rsi
movq %rbp, %rdi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0x1280f
movq %rax, 0x18(%rsp)
leaq 0xf3e3(%rip), %rax      # 0x1cf80
movq (%rax), %rsi
movq %rbp, %rdi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0x1280f
movq %rax, %r15
testq %r12, %r12
je 0xdbe7
leaq 0x6139(%rip), %rbp      # 0x13cf5
movq %r12, %rax
movq (%r12), %rcx
cmpq (%rax), %rcx
jne 0xdbe7
movq %rbp, %rdi
callq 0xca76
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rcx
movq 0x20(%rcx), %rax
movq %rcx, 0x8(%rsp)
testq %rax, %rax
jne 0xdbbf
testq %r15, %r15
je 0xdcce
leaq 0x610b(%rip), %rdi      # 0x13d02
leaq 0x650e(%rip), %rcx      # 0x1410c
movq %rcx, %rsi
movq %rcx, %rdx
callq 0xcb44
movq 0x8(%r15), %r12
testq %r12, %r12
je 0xdcce
movq %r12, %rdi
callq 0xddf7
movq 0x30(%r12), %r12
jmp 0xdc0d
leaq 0xf33c(%rip), %rax      # 0x1cf68
cmpl $0x3, (%rax)
jne 0xdc5e
cmpl $0x2, %edi
jne 0xdc54
leaq 0x59bd(%rip), %rdi      # 0x135fa
callq 0xcb07
leaq 0x603b(%rip), %rdi      # 0x13c84
callq 0xca45
movq (%r14), %rax
movl 0x38(%rax), %edi
cmpl $0x1, %edi
jne 0xdc5e
callq 0xcaab
movl %ebx, %edi
callq 0xf11c
callq 0xf398
movq $0x0, (%r14)
jmp 0xdde6
xorl %ebx, %ebx
callq 0xf9aa
callq 0xf398
leaq 0xf407(%rip), %r14      # 0x1d090
movq (%r14), %rax
testq %rax, %rax
je 0xdca3
movl 0x38(%rax), %edi
cmpl $0x3, %edi
jl 0xdca3
testl %ebx, %ebx
cmovnel %ebx, %edi
movl %edi, 0x38(%rax)
jmp 0xdcad
testl %ebx, %ebx
movl $0x3, %edi
cmovnel %ebx, %edi
callq 0xf666
movl %eax, %ebx
movl %eax, %edi
callq 0xcee6
movq $0x0, (%r14)
movslq %ebx, %rax
addq %rax, (%r13)
jmp 0xdde6
movq 0x18(%rsp), %r15
testq %r15, %r15
je 0xdd08
leaq 0x603d(%rip), %rdi      # 0x13d1c
leaq 0x6426(%rip), %rcx      # 0x1410c
movq %rcx, %rsi
movq %rcx, %rdx
callq 0xcb44
movq 0x8(%r15), %r15
testq %r15, %r15
je 0xdd08
movq %r15, %rdi
callq 0xddf7
movq 0x30(%r15), %r15
jmp 0xdcf5
testq %r14, %r14
je 0xdd2c
movl 0x8(%r14), %edx
movq (%r13), %rcx
leaq 0xf7a4(%rip), %rdi      # 0x1d4c0
leaq 0x6016(%rip), %rsi      # 0x13d39
xorl %eax, %eax
callq 0x91b0
jmp 0xdd45
movq (%r13), %rdx
leaq 0xf789(%rip), %rdi      # 0x1d4c0
leaq 0x6009(%rip), %rsi      # 0x13d47
xorl %eax, %eax
callq 0x91b0
leaq 0x6b4f(%rip), %r14      # 0x1489b
leaq 0x15(%rsp), %r15
leaq 0xf768(%rip), %r12      # 0x1d4c0
movl %ebx, %ebp
callq 0xf3a7
movzbl %al, %edx
movq %r15, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x91b0
movq %r12, %rdi
movq %r15, %rsi
callq 0x91a0
decl %ebp
jne 0xdd5a
leaq 0xf42b(%rip), %rax      # 0x1d1b0
cmpl $0x0, (%rax)
movq 0x20(%rsp), %r14
je 0xddbf
leaq 0xf1d2(%rip), %rax      # 0x1cf68
cmpl $0x3, (%rax)
jne 0xddb8
leaq 0xf15e(%rip), %rax      # 0x1cf00
cmpl $0x0, (%rax)
je 0xddb3
leaq 0xf712(%rip), %rdi      # 0x1d4c0
callq 0xca76
callq 0xcaab
movb $0x0, 0xf701(%rip)      # 0x1d4c0
addq %r14, (%r13)
leaq 0xf2c6(%rip), %rax      # 0x1d090
movq (%rax), %rcx
testq %rcx, %rcx
je 0xdde6
cmpl $0x2, 0x38(%rcx)
je 0xdddf
movl $0x1, 0x38(%rcx)
movq $0x0, (%rax)
movl %ebx, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq