// File: /workspace/github_c_makefile_star2_O1/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 0xed6d(%rip), %rbx      # 0x1cf58
movq (%rbx), %rdi
movslq 0xf3ab(%rip), %rsi      # 0x1d5a0
addq 0x10(%r14), %rsi
xorl %ebp, %ebp
xorl %edx, %edx
callq 0x9160
subl 0xf397(%rip), %r15d     # 0x1d5a0
movl %r15d, %edi
callq 0xf398
movl %eax, %r15d
testq %r12, %r12
je 0xe242
movq (%rbx), %rdi
movq 0x10(%r12), %rsi
xorl %edx, %edx
callq 0x9160
movl 0x18(%r12), %eax
cmpl $0x10, %eax
movl $0x10, %ebp
cmovll %eax, %ebp
movl %ebp, %edi
callq 0xf3f0
addl %eax, %r15d
cmpl %ebp, %r15d
jle 0xe30b
leaq 0xef46(%rip), %r13      # 0x1d198
testl %r15d, %r15d
jns 0xe263
leaq 0x5b0c(%rip), %rdi      # 0x13d6a
callq 0x12808
movq (%r13), %rbx
xorl %edi, %edi
callq 0xcca8
movl %eax, %eax
leaq 0x59e5(%rip), %rcx      # 0x13c5c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl 0x4(%rsp), %edi
callq 0xd8ac
jmp 0xe29a
callq 0xd63e
xorl %r12d, %r12d
jmp 0xe29d
callq 0xd7a9
movl %eax, %r12d
movslq %r12d, %rax
movq (%r13), %rcx
subq %rbx, %rcx
cmpq %rax, %rcx
je 0xe2b8
leaq 0x5ad4(%rip), %rdi      # 0x13d87
callq 0x12808
subl %r12d, %r15d
movl %ebp, %eax
subl %r15d, %eax
addl 0x4(%r14), %eax
addl 0x18(%r14), %eax
cmpq %rax, (%r13)
je 0xe2da
leaq 0x5ad6(%rip), %rdi      # 0x13dab
callq 0x12808
leaq 0x102ff(%rip), %rax     # 0x1e5e0
movq (%rax), %rax
leaq 0x102ed(%rip), %rcx     # 0x1e5d8
subq (%rcx), %rax
movslq %r15d, %rcx
cmpq %rcx, %rax
je 0xe302
leaq 0x5ad5(%rip), %rdi      # 0x13dd2
callq 0x12808
cmpl %r15d, %ebp
jl 0xe252
subl %r15d, %ebp
movl %ebp, 0xf28c(%rip)      # 0x1d5a0
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq