// File: /workspace/github_c_makefile_star2_O3/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 0xed50(%rip), %rbx      # 0x1cf58
movq (%rbx), %rdi
movslq 0xf38e(%rip), %rsi      # 0x1d5a0
addq 0x10(%r14), %rsi
xorl %ebp, %ebp
xorl %edx, %edx
callq 0x9160
subl 0xf37a(%rip), %r15d     # 0x1d5a0
movl %r15d, %edi
callq 0xf3d3
movl %eax, %r15d
testq %r12, %r12
je 0xe25f
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 0xf42b
addl %eax, %r15d
movl %ebp, %ebx
subl %r15d, %ebx
jge 0xe332
leaq 0xef27(%rip), %r13      # 0x1d198
testl %r15d, %r15d
jns 0xe282
leaq 0x5aed(%rip), %rdi      # 0x13d6a
callq 0x128bc
movq (%r13), %rbx
xorl %edi, %edi
callq 0xcd14
movl %eax, %eax
leaq 0x59c6(%rip), %rcx      # 0x13c5c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl 0x4(%rsp), %edi
callq 0xd906
jmp 0xe2b9
callq 0xd687
xorl %r12d, %r12d
jmp 0xe2bc
callq 0xd7f2
movl %eax, %r12d
movslq %r12d, %rcx
movq (%r13), %rax
movq %rax, %rdx
subq %rbx, %rdx
cmpq %rcx, %rdx
je 0xe2de
leaq 0x5ab2(%rip), %rdi      # 0x13d87
callq 0x128bc
movq (%r13), %rax
subl %r12d, %r15d
movl %ebp, %ebx
subl %r15d, %ebx
movl 0x4(%r14), %ecx
addl %ebx, %ecx
addl 0x18(%r14), %ecx
cmpq %rcx, %rax
je 0xe301
leaq 0x5aaf(%rip), %rdi      # 0x13dab
callq 0x128bc
leaq 0x102d8(%rip), %rax     # 0x1e5e0
movq (%rax), %rax
leaq 0x102c6(%rip), %rcx     # 0x1e5d8
subq (%rcx), %rax
movslq %r15d, %rcx
cmpq %rcx, %rax
je 0xe329
leaq 0x5aae(%rip), %rdi      # 0x13dd2
callq 0x128bc
cmpl %r15d, %ebp
jl 0xe271
movl %ebx, 0xf268(%rip)      # 0x1d5a0
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq