// File: /workspace/github_c_makefile_star2_O2/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 0xeecd(%rip), %rax      # 0x1c190
movl (%rax), %eax
leaq 0xee2c(%rip), %rbx      # 0x1c0f8
movl %eax, (%rbx)
leaq 0xeec3(%rip), %r13      # 0x1c198
movq (%r13), %rax
movq %rax, 0x8(%rbx)
leaq 0xee04(%rip), %r15      # 0x1c0e8
leaq 0xeced(%rip), %r12      # 0x1bfd8
leaq 0xedfe(%rip), %r14      # 0x1c0f0
movq (%r15), %rax
cmpq (%r12), %rax
je 0xd327
movq (%r14), %rsi
movq %rbx, %rdi
callq 0xb5f4
testl %eax, %eax
jne 0xd311
callq 0xc6a0
jmp 0xd2f2
cmpl $0x2, %eax
jne 0xd327
movq (%r14), %rax
movl 0x4(%rax), %ebx
testl %ebx, %ebx
je 0xd327
xorl %eax, %eax
jmp 0xd44e
pushq $0x1
popq %rbx
movl %ebx, %r14d
callq 0xece6
testl %eax, %eax
je 0xd355
cmpl $0xa, %eax
je 0xd352
cmpl $0xd, %eax
je 0xd352
cmpl $0x1b, %eax
je 0xd352
cmpl $-0x1, %eax
je 0xd36d
addl $-0x7f, %eax
cmpl $-0x5f, %eax
jb 0xd36d
xorl %r14d, %r14d
incq (%r13)
xorl %edi, %edi
callq 0xc74e
cmpl $0x3, %eax
je 0xd369
testl %eax, %eax
jne 0xd36f
incl %ebx
jmp 0xd32d
decl %ebx
testl %ebp, %ebp
jne 0xd37c
leaq 0xb78e(%rip), %rax      # 0x18b08
jmp 0xd383
leaq 0xb781(%rip), %rax      # 0x18b04
movslq %ebx, %r15
cmpl (%rax), %ebx
jge 0xd39e
testl %r14d, %r14d
sete %al
cmpl $0x2, %ebx
setl %cl
orb %al, %cl
jne 0xd441
leaq 0xeceb(%rip), %r14      # 0x1c090
movq (%r14), %rax
testq %rax, %rax
je 0xd3eb
movl 0x38(%rax), %edi
cmpl $0x3, %edi
jl 0xd3eb
callq 0xeeda
movl %eax, %ebp
cmpl %eax, %ebx
jge 0xd3ca
movq (%r14), %rax
movl $0x3, 0x38(%rax)
movl %ebp, %edi
callq 0xc8d0
callq 0xec06
movslq %ebp, %rax
subq %r15, %rax
addq %rax, (%r13)
andq $0x0, (%r14)
movl %ebp, %ebx
jmp 0xd756
testq %rax, %rax
je 0xd42c
leaq 0xeb71(%rip), %rcx      # 0x1bf68
cmpl $0x3, (%rcx)
jne 0xd42c
movl 0x38(%rax), %eax
cmpl $0x2, %eax
jne 0xd422
leaq 0x51ef(%rip), %rdi      # 0x125fa
callq 0xc554
leaq 0x586d(%rip), %rdi      # 0x12c84
callq 0xc4c6
movq (%r14), %rax
movl 0x38(%rax), %eax
cmpl $0x1, %eax
jne 0xd42c
callq 0xc522
movl %ebx, %edi
callq 0xe9c4
callq 0xec06
andq $0x0, (%r14)
jmp 0xd756
callq 0xec06
subq %r15, (%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 0xd5b1
callq 0xece6
movzbl %al, %edi
leaq 0xed3c(%rip), %rax      # 0x1c1b0
movl $0x1, (%rax)
imulq $0x18, %rdi, %rax
leaq 0xb6db(%rip), %rcx      # 0x18b60
movq 0x10(%rcx,%rax), %rsi
movl 0x8(%rcx,%rax), %edx
callq *(%rcx,%rax)
testl %eax, %eax
je 0xd5af
movl %eax, %ebx
leaq 0x10136(%rip), %rax     # 0x1d5d8
movq (%rax), %rax
leaq 0x10124(%rip), %rcx     # 0x1d5d0
subq (%rcx), %rax
movslq %ebx, %rcx
movq %rcx, 0x8(%rsp)
cmpq %rcx, %rax
je 0xd4c8
leaq 0x5806(%rip), %rdi      # 0x12cc9
callq 0x11eec
cmpb $0x0, 0xeff1(%rip)      # 0x1c4c0
jne 0xd6b5
movq (%r13), %rax
leaq 0x38(%rsp), %rdi
movq %rax, (%rdi)
leaq 0xea88(%rip), %rax      # 0x1bf70
movq (%rax), %rsi
leaq 0x3d16(%rip), %rdx      # 0x11208
xorl %ecx, %ecx
callq 0x11e3b
movq %rax, %r14
movq (%r13), %rax
addq 0x8(%rsp), %rax
movq %rax, 0x28(%rsp)
leaq 0xea57(%rip), %rax      # 0x1bf68
cmpl $0x3, (%rax)
jne 0xd678
movq %r14, 0x20(%rsp)
leaq 0xea62(%rip), %rax      # 0x1bf88
movq (%rax), %rsi
leaq 0x285c(%rip), %r12      # 0xfd8c
leaq 0x28(%rsp), %rbp
leaq 0x10(%rsp), %rcx
movq %rbp, %rdi
movq %r12, %rdx
callq 0x11e3b
movq %rax, %r14
leaq 0xea29(%rip), %rax      # 0x1bf78
movq (%rax), %rsi
movq %rbp, %rdi
movq %r12, %rdx
xorl %ecx, %ecx
callq 0x11e3b
movq %rax, %r15
leaq 0xea17(%rip), %rax      # 0x1bf80
movq (%rax), %rsi
movq %rbp, %rdi
movq %r12, %rdx
xorl %ecx, %ecx
callq 0x11e3b
movq %rax, %r12
leaq 0x5772(%rip), %rbp      # 0x12cf5
movq %r14, %rax
testq %rax, %rax
je 0xd602
movq (%r14), %rcx
cmpq (%rax), %rcx
jne 0xd602
movq %rbp, %rdi
callq 0xc4ef
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rcx
movq 0x20(%rcx), %rax
movq %rcx, 0x10(%rsp)
jmp 0xd586
xorl %ebx, %ebx
callq 0xf218
callq 0xec06
leaq 0xeace(%rip), %r14      # 0x1c090
movq (%r14), %rax
testq %rax, %rax
je 0xd5dc
movl 0x38(%rax), %edi
cmpl $0x3, %edi
jl 0xd5dc
testl %ebx, %ebx
cmovnel %ebx, %edi
movl %edi, 0x38(%rax)
jmp 0xd5e4
testl %ebx, %ebx
pushq $0x3
popq %rdi
cmovnel %ebx, %edi
callq 0xeeda
movl %eax, %ebx
movl %eax, %edi
callq 0xc8d0
andq $0x0, (%r14)
movslq %ebx, %rax
addq %rax, (%r13)
jmp 0xd756
testq %r12, %r12
movq 0x20(%rsp), %r14
je 0xd640
leaq 0x56ef(%rip), %rdi      # 0x12d02
leaq 0x5af2(%rip), %rcx      # 0x1310c
movq %rcx, %rsi
movq %rcx, %rdx
callq 0xc585
addq $0x8, %r12
movq (%r12), %r12
testq %r12, %r12
je 0xd640
movq %r12, %rdi
callq 0xd767
addq $0x30, %r12
jmp 0xd629
testq %r15, %r15
je 0xd678
leaq 0x56d0(%rip), %rdi      # 0x12d1c
leaq 0x5ab9(%rip), %rcx      # 0x1310c
movq %rcx, %rsi
movq %rcx, %rdx
callq 0xc585
addq $0x8, %r15
movq (%r15), %r15
testq %r15, %r15
je 0xd678
movq %r15, %rdi
callq 0xd767
addq $0x30, %r15
jmp 0xd662
testq %r14, %r14
je 0xd69c
movl 0x8(%r14), %edx
movq (%r13), %rcx
leaq 0xee34(%rip), %rdi      # 0x1c4c0
leaq 0x56a6(%rip), %rsi      # 0x12d39
xorl %eax, %eax
callq 0x91b0
jmp 0xd6b5
movq (%r13), %rdx
leaq 0xee19(%rip), %rdi      # 0x1c4c0
leaq 0x5699(%rip), %rsi      # 0x12d47
xorl %eax, %eax
callq 0x91b0
leaq 0x61df(%rip), %r14      # 0x1389b
leaq 0x1d(%rsp), %r15
leaq 0xedf8(%rip), %r12      # 0x1c4c0
movl %ebx, %ebp
subl $0x1, %ebp
jb 0xd6f1
callq 0xec15
movzbl %al, %edx
movq %r15, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x91b0
movq %r12, %rdi
movq %r15, %rsi
callq 0x91a0
jmp 0xd6ca
leaq 0xeab8(%rip), %rax      # 0x1c1b0
cmpl $0x0, (%rax)
je 0xd72d
leaq 0xe864(%rip), %rax      # 0x1bf68
cmpl $0x3, (%rax)
jne 0xd726
leaq 0xe7f0(%rip), %rax      # 0x1bf00
cmpl $0x0, (%rax)
je 0xd721
leaq 0xeda4(%rip), %rdi      # 0x1c4c0
callq 0xc4ef
callq 0xc522
movb $0x0, 0xed93(%rip)      # 0x1c4c0
movq 0x8(%rsp), %rax
addq %rax, (%r13)
leaq 0xe953(%rip), %rax      # 0x1c090
movq (%rax), %rcx
testq %rcx, %rcx
je 0xd756
cmpl $0x2, 0x38(%rcx)
je 0xd752
movl $0x1, 0x38(%rcx)
andq $0x0, (%rax)
movl %ebx, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq