// File: /workspace/github_c_makefile_star2_O1/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, %r14d
leaq 0xf8cc(%rip), %rax      # 0x1d190
movl (%rax), %eax
leaq 0xf82b(%rip), %rcx      # 0x1d0f8
movl %eax, (%rcx)
leaq 0xf8c2(%rip), %rax      # 0x1d198
movq (%rax), %rax
movq %rax, 0x8(%rcx)
leaq 0xf804(%rip), %r13      # 0x1d0e8
movq (%r13), %rax
leaq 0xf6e9(%rip), %rbp      # 0x1cfd8
xorl %r15d, %r15d
cmpq (%rbp), %rax
je 0xd95b
movl %r14d, %r15d
leaq 0xf7ee(%rip), %r12      # 0x1d0f0
leaq 0xf7ef(%rip), %rbx      # 0x1d0f8
movq (%r12), %rsi
movq %rbx, %rdi
callq 0xba88
testl %eax, %eax
jne 0xd941
movq (%r13), %rdi
movl $0x1, %r14d
movl $0x1, %esi
callq 0x127da
movq %rax, (%r13)
movq 0x20(%rax), %rcx
movq %rcx, (%r12)
cmpq (%rbp), %rax
jne 0xd909
jmp 0xd944
movl %eax, %r14d
cmpl $0x2, %r14d
movl %r15d, %r14d
movl $0x0, %r15d
jne 0xd95b
movq (%r12), %rax
movl 0x4(%rax), %r15d
testl %r15d, %r15d
leaq 0xf833(%rip), %r13      # 0x1d198
jne 0xda10
callq 0xf442
cmpl $-0x1, %eax
je 0xd9d5
movl %r14d, %ebp
movl $0x1, %r14d
xorl %ecx, %ecx
movl %ecx, %ebx
cmpl $0xc, %eax
jg 0xd992
testl %eax, %eax
je 0xd9a7
cmpl $0xa, %eax
je 0xd9a4
jmp 0xd99c
cmpl $0xd, %eax
je 0xd9a4
cmpl $0x1b, %eax
je 0xd9a4
addl $-0x7f, %eax
cmpl $-0x5f, %eax
jb 0xd9ca
xorl %r14d, %r14d
incq (%r13)
xorl %edi, %edi
callq 0xcca8
cmpl $0x3, %eax
je 0xd9bb
testl %eax, %eax
jne 0xd9c8
callq 0xf442
leal 0x1(%rbx), %ecx
cmpl $-0x1, %eax
jne 0xd980
incl %ebx
testl %r14d, %r14d
setne %al
movl %ebp, %r14d
jmp 0xd9d9
xorl %ebx, %ebx
movb $0x1, %al
testl %r14d, %r14d
jne 0xd9e7
leaq 0xc123(%rip), %rcx      # 0x19b08
jmp 0xd9ee
leaq 0xc116(%rip), %rcx      # 0x19b04
cmpl $0x2, %ebx
setge %dl
cmpl (%rcx), %ebx
jge 0xdc11
andb %dl, %al
jne 0xdc11
callq 0xf35d
movslq %ebx, %rax
subq %rax, (%r13)
testl %r15d, %r15d
sete %al
testl %r14d, %r14d
setne %cl
cmpl $0x1, %r15d
je 0xda28
xorl %ebx, %ebx
andb %al, %cl
je 0xda5c
callq 0xf442
movzbl %al, %edi
leaq 0xf779(%rip), %rax      # 0x1d1b0
movl $0x1, (%rax)
leaq (%rdi,%rdi,2), %rax
leaq 0xc118(%rip), %rcx      # 0x19b60
movq 0x10(%rcx,%rax,8), %rsi
movl 0x8(%rcx,%rax,8), %edx
callq *(%rcx,%rax,8)
movl %eax, %ebx
testl %eax, %eax
cmovel %eax, %r15d
testl %ebx, %ebx
je 0xdbb7
leaq 0x10b6d(%rip), %rax     # 0x1e5d8
movq (%rax), %rax
leaq 0x10b5b(%rip), %rcx     # 0x1e5d0
subq (%rcx), %rax
movslq %ebx, %rcx
movq %rcx, 0x8(%rsp)
cmpq %rcx, %rax
je 0xda91
leaq 0x623d(%rip), %rdi      # 0x13cc9
callq 0x12808
cmpb $0x0, 0xfa28(%rip)      # 0x1d4c0
jne 0xdd30
movq (%r13), %rax
leaq 0x38(%rsp), %rdi
movq %rax, (%rdi)
leaq 0xf4bf(%rip), %rax      # 0x1cf70
movq (%rax), %rsi
leaq 0x3ed9(%rip), %rdx      # 0x11994
xorl %ecx, %ecx
callq 0x1275f
movq %rax, %r14
movq (%r13), %rax
addq 0x8(%rsp), %rax
movq %rax, 0x28(%rsp)
leaq 0xf48e(%rip), %rax      # 0x1cf68
cmpl $0x3, (%rax)
jne 0xdcf3
leaq 0xf49e(%rip), %rax      # 0x1cf88
movq (%rax), %rsi
leaq 0x29c4(%rip), %r15      # 0x104b8
leaq 0x28(%rsp), %rbp
leaq 0x10(%rsp), %rcx
movq %rbp, %rdi
movq %r15, %rdx
callq 0x1275f
movq %rax, %r12
leaq 0xf465(%rip), %rax      # 0x1cf78
movq (%rax), %rsi
movq %rbp, %rdi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0x1275f
movq %rax, 0x20(%rsp)
leaq 0xf451(%rip), %rax      # 0x1cf80
movq (%rax), %rsi
movq %rbp, %rdi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0x1275f
movq %rax, %r15
testq %r12, %r12
je 0xdb79
leaq 0x61a7(%rip), %rbp      # 0x13cf5
movq %r12, %rax
movq (%r12), %rcx
cmpq (%rax), %rcx
jne 0xdb79
movq %rbp, %rdi
callq 0xca0a
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rcx
movq 0x20(%rcx), %rax
movq %rcx, 0x10(%rsp)
testq %rax, %rax
jne 0xdb51
testq %r15, %r15
je 0xdcb9
leaq 0x6179(%rip), %rdi      # 0x13d02
leaq 0x657c(%rip), %rcx      # 0x1410c
movq %rcx, %rsi
movq %rcx, %rdx
callq 0xcad8
movq 0x8(%r15), %r12
testq %r12, %r12
je 0xdcb9
movq %r12, %rdi
callq 0xdde2
movq 0x30(%r12), %r12
jmp 0xdb9f
callq 0xf96e
callq 0xf35d
leaq 0xf4c8(%rip), %r14      # 0x1d090
movq (%r14), %rax
testq %rax, %rax
je 0xdbe4
movl 0x38(%rax), %edi
cmpl $0x3, %edi
jl 0xdbe4
testl %r15d, %r15d
cmovnel %r15d, %edi
movl %edi, 0x38(%rax)
jmp 0xdbf0
testl %r15d, %r15d
movl $0x3, %edi
cmovnel %r15d, %edi
callq 0xf62a
movl %eax, %ebx
movl %eax, %edi
callq 0xce87
movq $0x0, (%r14)
movslq %ebx, %rax
addq %rax, (%r13)
jmp 0xddd1
leaq 0xf478(%rip), %r14      # 0x1d090
movq (%r14), %rax
testq %rax, %rax
je 0xdc64
movl 0x38(%rax), %edi
cmpl $0x3, %edi
jl 0xdc64
callq 0xf62a
movl %eax, %ebp
cmpl %eax, %ebx
jge 0xdc3d
movq (%r14), %rax
movl $0x3, 0x38(%rax)
movl %ebp, %edi
callq 0xce87
callq 0xf35d
movslq %ebx, %rax
movslq %ebp, %rcx
subq %rax, %rcx
addq %rcx, (%r13)
movq $0x0, (%r14)
movl %ebp, %ebx
jmp 0xddd1
testq %rax, %rax
je 0xdca1
leaq 0xf2f8(%rip), %rcx      # 0x1cf68
cmpl $0x3, (%rcx)
jne 0xdca1
cmpl $0x2, 0x38(%rax)
jne 0xdc93
leaq 0x5978(%rip), %rdi      # 0x135fa
callq 0xca9b
leaq 0x5ff6(%rip), %rdi      # 0x13c84
callq 0xc9d9
movq (%r14), %rax
cmpl $0x1, 0x38(%rax)
jne 0xdca1
callq 0xca3f
movl %ebx, %edi
callq 0xf0e0
callq 0xf35d
movq $0x0, (%r14)
jmp 0xddd1
movq 0x20(%rsp), %r15
testq %r15, %r15
je 0xdcf3
leaq 0x6052(%rip), %rdi      # 0x13d1c
leaq 0x643b(%rip), %rcx      # 0x1410c
movq %rcx, %rsi
movq %rcx, %rdx
callq 0xcad8
movq 0x8(%r15), %r15
testq %r15, %r15
je 0xdcf3
movq %r15, %rdi
callq 0xdde2
movq 0x30(%r15), %r15
jmp 0xdce0
testq %r14, %r14
je 0xdd17
movl 0x8(%r14), %edx
movq (%r13), %rcx
leaq 0xf7b9(%rip), %rdi      # 0x1d4c0
leaq 0x602b(%rip), %rsi      # 0x13d39
xorl %eax, %eax
callq 0x91b0
jmp 0xdd30
movq (%r13), %rdx
leaq 0xf79e(%rip), %rdi      # 0x1d4c0
leaq 0x601e(%rip), %rsi      # 0x13d47
xorl %eax, %eax
callq 0x91b0
leaq 0x6b64(%rip), %r14      # 0x1489b
leaq 0x1d(%rsp), %r15
leaq 0xf77d(%rip), %r12      # 0x1d4c0
movl %ebx, %ebp
callq 0xf36c
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 0xdd45
leaq 0xf440(%rip), %rax      # 0x1d1b0
cmpl $0x0, (%rax)
je 0xdda5
leaq 0xf1ec(%rip), %rax      # 0x1cf68
cmpl $0x3, (%rax)
jne 0xdd9e
leaq 0xf178(%rip), %rax      # 0x1cf00
cmpl $0x0, (%rax)
je 0xdd99
leaq 0xf72c(%rip), %rdi      # 0x1d4c0
callq 0xca0a
callq 0xca3f
movb $0x0, 0xf71b(%rip)      # 0x1d4c0
movq 0x8(%rsp), %rax
addq %rax, (%r13)
leaq 0xf2db(%rip), %rax      # 0x1d090
movq (%rax), %rcx
testq %rcx, %rcx
je 0xddd1
cmpl $0x2, 0x38(%rcx)
je 0xddca
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