// File: /workspace/github_c_makefile_star2_O2/Nico01[P]obj2asm/oprocess.c
// Function: enumerated
void enumerated(DAT_T *data_rec, DAT_T *next_rec, int inst_proc)
{
    int             length;
    int             result;
    dword   prev_offset;
    int             addition;
    int             dcheck;

    /*
    ** Process enumerated data within this record
    */
    length = data_rec->length;
    fseek( o_file, data_rec->file_pos+record_overused, L_SET );
    length = buff_init( length-record_overused );
    addition = 0;
    if ( next_rec ) {
        fseek( o_file, next_rec->file_pos, L_SET );
        addition = 0x10;      /* Longest instruction can be 0x10 bytes long */
        if ( addition > next_rec->length ) {
            addition = next_rec->length;
        }
        length += buff_add( addition );
    }
    while ( length > addition ) {
#ifdef DEBUG
        printf( "DIS-ASSEMBLY processing enumerated %08lX %04X %04X %04X %04X\n", 
                    data_rec, data_rec->offset, data_rec->length, length, 
                    inst_offset );
#endif
        if ( length < 0 ) {
            fmt_error( "Dis-assembly Record Over-run" );
        }

        prev_offset = inst_offset;

        dcheck = data_check( 0 );

        switch ( dcheck ) {
            case BAD:       result = proc_normal( inst_proc );      break;
            case LABEL:     result = proc_label();                  break;
            case FIXUP:     result = proc_fixup();                  break;
            case NORMAL:    result = proc_normal( inst_proc );      break;
        }

        length -= result;

        if ( (dword)result != inst_offset - prev_offset ) {
#ifdef DEBUG
            printf("Instruction Length was %ld, delta IP = %ld\n",
                                   (long)result, inst_offset - prev_offset );
#endif
            fmt_error("Dis-assembly Instruction Size Error");
        }

        if ( data_rec->offset + data_rec->length - length + addition 
                                                        != inst_offset ) {
            fmt_error("Dis-assembly Instruction Mis-alignment");
        }

        if ( buff_end - buff_cur != length ) {
#ifdef DEBUG
            printf("Buffer remaining: %04d Length remaining: %04d\n", 
                                            buff_end - buff_cur, length );
#endif
            fmt_error("Dis-assembly Internal Instruction Processing" );
        }
    }
    record_overused = addition - length;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, 0x4(%rsp)
movq %rsi, %r12
movq %rdi, %r14
movl 0x18(%rdi), %r15d
leaq 0xe40f(%rip), %rbx      # 0x1bf58
movq (%rbx), %rdi
movslq 0xea4d(%rip), %rsi      # 0x1c5a0
addq 0x10(%r14), %rsi
xorl %ebp, %ebp
xorl %edx, %edx
callq 0x9160
subl 0xea39(%rip), %r15d     # 0x1c5a0
movl %r15d, %edi
callq 0xec3f
movl %eax, %r15d
testq %r12, %r12
je 0xdb9e
movq (%rbx), %rdi
movq 0x10(%r12), %rsi
xorl %edx, %edx
callq 0x9160
movl 0x18(%r12), %eax
cmpl $0x10, %eax
pushq $0x10
popq %rbp
cmovll %eax, %ebp
movl %ebp, %edi
callq 0xec95
addl %eax, %r15d
leaq 0xe5f3(%rip), %r13      # 0x1c198
movl %ebp, %eax
subl %r15d, %eax
jge 0xdc6f
testl %r15d, %r15d
jns 0xdbc1
leaq 0x51ae(%rip), %rdi      # 0x12d6a
callq 0x11eec
movq (%r13), %rbx
xorl %edi, %edi
callq 0xc74e
movl %eax, %eax
leaq 0x5087(%rip), %rcx      # 0x12c5c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl 0x4(%rsp), %edi
callq 0xd2ac
jmp 0xdbf8
callq 0xd050
xorl %r12d, %r12d
jmp 0xdbfb
callq 0xd19f
movl %eax, %r12d
movslq %r12d, %rcx
movq (%r13), %rax
movq %rax, %rdx
subq %rbx, %rdx
cmpq %rcx, %rdx
je 0xdc1d
leaq 0x5173(%rip), %rdi      # 0x12d87
callq 0x11eec
movq (%r13), %rax
subl %r12d, %r15d
movl %ebp, %ecx
subl %r15d, %ecx
addl 0x4(%r14), %ecx
addl 0x18(%r14), %ecx
cmpq %rcx, %rax
je 0xdc3e
leaq 0x5172(%rip), %rdi      # 0x12dab
callq 0x11eec
leaq 0xf99b(%rip), %rax      # 0x1d5e0
movq (%rax), %rax
leaq 0xf989(%rip), %rcx      # 0x1d5d8
subq (%rcx), %rax
movslq %r15d, %rcx
cmpq %rcx, %rax
je 0xdba5
leaq 0x516d(%rip), %rdi      # 0x12dd2
callq 0x11eec
jmp 0xdba5
movl %eax, 0xe92b(%rip)      # 0x1c5a0
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq