// File: /workspace/github_c_makefile_star2_O3/Nico01[P]obj2asm/oprocess.c
// Function: proc_idb
int proc_idb( depth, mult, dup_only, extended, length_used, repeat_cnt )
    int             depth;
    dword   mult;
    int             *dup_only;
    int             extended;
    word    *length_used;
    dword   *repeat_cnt;
{
    dword   repeat;
    word    num_blocks;
    word    blocks;
    word    length;
    int             data;
    word    data_size;
    word    result;
    int             fix_size;
    char            operand[80];
    uchar   rev_buff[10];
    word    out_count;
    int             dcheck;
    int             dummy;

    result = 512;

    repeat = (dword)buff_regetc();
    repeat += (dword)buff_regetc() << 8;
    *length_used += 2;

    if ( extended ) {
        repeat += (dword)buff_regetc() << 16;
        repeat += (dword)buff_regetc() << 24;
        *length_used += 2;
    }
    num_blocks = buff_regetc();
    num_blocks += buff_regetc() << 8;
    *length_used += 2;

    if ( repeat_cnt ) {             /* Return repeat count if needed */
        *repeat_cnt = repeat;
    }

    if ( repeat != 1 || num_blocks != 0 ) {
        sprintf( idb_buff, "%ld dup(", repeat );
        strcat( dup_buff, idb_buff );
    }

    mult *= repeat;

    if ( num_blocks ) {
        blocks = num_blocks;
        while ( blocks ) {
            if ( depth == 2 ) {
                *dup_only = TRUE;
            }
            data_size = proc_idb( depth+1, mult, dup_only, extended,
                                                       length_used, NULL );
            if ( data_size < result ) {
                result = data_size;
            }
            --blocks;
            if ( blocks != 0 ) {
                strcat( dup_buff, "," );
                strcat( struc_buff, "," );
            }
        }
    } else {
        length = buff_regetc();
        result = length;
        *length_used += length + 1;         /* one extra for the length byte */
        data_size = 0;
        while ( length ) {
            do {
                data = buff_getc();
                if ( data == EOF ) {
                    break;
                }
                if ( data < ' ' || data > '~' ) {
                    break;
                }
                data_size++;
                inst_offset += mult;
                dcheck = data_check( 0 );
            } while ( *dup_only && (dcheck == NORMAL || dcheck == BAD) );
            if ( *dup_only && data_size >= data_string ) {
                buff_reseek();
                length -= data_size;
                idb_buff[0] = '\'';
                out_count = 1;
                while ( data_size ) {
                    data = buff_regetc();
                    idb_buff[out_count++] = (char)data;
                    --data_size;
                }
                idb_buff[out_count++] = '\'';
                idb_buff[out_count] = '\0';
                if ( depth != 1 ) {
                    *dup_only = TRUE;
                }
                strcat( dup_buff, idb_buff );
                strcat( struc_buff, idb_buff );
            } else {
                /*
                ** Was it a fixup?
                */
                inst_offset -= data_size * mult;
                buff_reseek();      /* Back to start, string look */
                                    /* may have moved ptr         */
                if ( data_check( 0 ) == FIXUP ) {
                    if ( depth != 1 ) {
                        *dup_only = TRUE;
                    }
                    if ( fix_rec->form == POINTER ) {
                        fix_size = get_fix( operand, 2, FALSE, segment_bytes,
                                                    FAR, FALSE, &dummy, DS );
                    } else {
                        fix_size = get_fix( operand, 2, FALSE, segment_bytes,
                                                    NEAR, FALSE, &dummy, DS );
                    }
                    inst_offset += fix_size * mult;
                    length -= fix_size;
                    if ( pass == 3 ) {
                        strcat( dup_buff, operand );
                        strcat( struc_buff, operand );
                    }
                    buff_empty();
                } else {
                    /*
                    ** Nope, not a string.  Leave one or multiple bytes
                    */
                    data_size = length;
                    if ( data_size != 2 && data_size != 4 && data_size != 6
                                        && data_size != 8 && data_size != 10 ) {
                        data_size = 1;
                    }
                    strcat( dup_buff, "0" );
                    if ( depth == 1 ) {
                        strcat( struc_buff, "0" );
                    }
                    out_count = 0;
                    while ( out_count < data_size ) {
                        rev_buff[ out_count ] = (uchar)buff_regetc();
                        out_count++;
                    }
                    out_count = data_size;
                    while ( out_count ) {
                        --out_count;
                        if ( depth != 1 ) {
                            if ( rev_buff[out_count] != 0 ) {
                                *dup_only = TRUE;
                            }
                        }
                        sprintf( idb_buff, "%02X", rev_buff[out_count] );
                        strcat( dup_buff, idb_buff );
                        if ( depth == 1 ) {
                            strcat( struc_buff, idb_buff );
                        }
                    }
                    strcat( dup_buff, "h" );
                    if ( depth == 1 ) {
                        strcat( struc_buff, "h" );
                    }

                    length -= data_size;
                    inst_offset += mult * data_size;
                }
            }
            if ( length ) {
                strcat( dup_buff, "," );
            }
        }
    }

    if ( repeat != 1 || num_blocks != 0 ) {
        strcat( dup_buff, ")" );
    }

    return( result );
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %r9, 0x8(%rsp)
movq %r8, %rbp
movl %ecx, %r13d
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, 0x10(%rsp)
callq 0xf3a7
movslq %eax, %r14
callq 0xf3a7
movslq %eax, %r12
shlq $0x8, %r12
addq %r14, %r12
addl $0x2, (%rbp)
movl %r13d, 0x18(%rsp)
testl %r13d, %r13d
je 0xd20b
callq 0xf3a7
movslq %eax, %r14
shlq $0x10, %r14
callq 0xf3a7
cltq
shlq $0x18, %rax
addq %r14, %rax
addq %rax, %r12
addl $0x2, (%rbp)
callq 0xf3a7
movl %eax, %r14d
callq 0xf3a7
shll $0x8, %eax
movq %r14, 0x38(%rsp)
addl %eax, %r14d
addl $0x2, (%rbp)
movq 0x8(%rsp), %rcx
testq %rcx, %rcx
je 0xd234
movq %r12, (%rcx)
cmpq $0x1, %r12
setne %cl
testl %r14d, %r14d
setne %r13b
orb %cl, %r13b
cmpb $0x1, %r13b
jne 0xd32e
movq %rax, 0x30(%rsp)
movq %rbp, 0x28(%rsp)
leaq 0xff60(%rip), %rbp      # 0x1d1c0
leaq 0x6a30(%rip), %rsi      # 0x13c97
movq %rbp, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x91b0
leaq 0x10045(%rip), %rdi     # 0x1d2c0
movq %rbp, %rsi
callq 0x91a0
imulq %r12, %r15
testl %r14d, %r14d
je 0xd329
movb %r13b, 0x7(%rsp)
movq %r15, 0x8(%rsp)
movq 0x10(%rsp), %rax
incl %eax
movl %eax, 0x24(%rsp)
movq 0x38(%rsp), %rax
movq 0x30(%rsp), %rcx
leal (%rax,%rcx), %r14d
decl %r14d
movl $0x200, %ebp            # imm = 0x200
movw $0x2c, %r15w
leaq 0x100f9(%rip), %r13     # 0x1d3c0
cmpl $0x2, 0x10(%rsp)
jne 0xd2d4
movl $0x1, (%rbx)
movl 0x24(%rsp), %edi
movq 0x8(%rsp), %rsi
movq %rbx, %rdx
movl 0x18(%rsp), %ecx
movq 0x28(%rsp), %r8
xorl %r9d, %r9d
callq 0xd19e
cmpl %ebp, %eax
cmovbl %eax, %ebp
subl $0x1, %r14d
jb 0xd31f
leaq 0xffbd(%rip), %r12      # 0x1d2c0
movq %r12, %rdi
callq 0x90b0
movw %r15w, (%rax,%r12)
movq %r13, %rdi
callq 0x90b0
movw %r15w, (%rax,%r13)
jmp 0xd2c7
movb 0x7(%rsp), %r13b
jmp 0xd659
movq 0x28(%rsp), %rbp
callq 0xf3a7
movl (%rbp), %ecx
addl %eax, %ecx
incl %ecx
movl %ecx, (%rbp)
testl %eax, %eax
je 0xd657
movb %r13b, 0x7(%rsp)
leaq 0xfe47(%rip), %r12      # 0x1d198
leaq 0xfe68(%rip), %r13      # 0x1d1c0
xorl %ebp, %ebp
movq %rax, 0x18(%rsp)
movl %eax, %r14d
movq %r15, 0x8(%rsp)
callq 0xf47e
addl $-0x7f, %eax
cmpl $-0x5f, %eax
jb 0xd3a3
incl %ebp
movl %ebp, %ecx
movl %ecx, %ebp
addq %r15, (%r12)
xorl %edi, %edi
callq 0xcd14
cmpl $0x0, (%rbx)
je 0xd3a3
cmpl $0x3, %eax
je 0xd393
testl %eax, %eax
jne 0xd3a3
callq 0xf47e
addl $-0x7f, %eax
leal 0x1(%rbp), %ecx
cmpl $-0x60, %eax
ja 0xd378
cmpl $0x0, (%rbx)
je 0xd3ec
leaq 0xc759(%rip), %rax      # 0x19b08
cmpl (%rax), %ebp
jb 0xd3ec
callq 0xf398
movb $0x27, 0xfe01(%rip)     # 0x1d1c0
testl %ebp, %ebp
je 0xd591
movl %ebp, %r15d
xorl %r12d, %r12d
callq 0xf3a7
movb %al, 0x1(%r12,%r13)
incq %r12
cmpl %r12d, %r15d
jne 0xd3cd
leal 0x1(%rbp), %eax
movq 0x8(%rsp), %r15
jmp 0xd596
movl %ebp, %eax
imulq %r15, %rax
subq %rax, (%r12)
callq 0xf398
xorl %edi, %edi
callq 0xcd14
cmpl $0x2, %eax
jne 0xd4a4
cmpl $0x1, 0x10(%rsp)
je 0xd418
movl $0x1, (%rbx)
leaq 0xfcf9(%rip), %rax      # 0x1d118
movq (%rax), %rax
xorl %r8d, %r8d
cmpl $0x3, 0x18(%rax)
sete %r8b
leaq 0xfd70(%rip), %rax      # 0x1d1a4
movl (%rax), %ecx
incl %r8d
leaq 0x50(%rsp), %rdi
movl $0x2, %esi
xorl %edx, %edx
xorl %r9d, %r9d
pushq $0x14
leaq 0x48(%rsp), %rax
pushq %rax
callq 0x1027f
addq $0x10, %rsp
movl %eax, %r12d
cltq
imulq %r15, %rax
leaq 0xfd2f(%rip), %rcx      # 0x1d198
addq %rax, (%rcx)
leaq 0xfaf5(%rip), %rax      # 0x1cf68
cmpl $0x3, (%rax)
jne 0xd49a
leaq 0xfe41(%rip), %rdi      # 0x1d2c0
leaq 0x50(%rsp), %rsi
callq 0x91a0
leaq 0xff30(%rip), %rdi      # 0x1d3c0
leaq 0x50(%rsp), %rsi
callq 0x91a0
callq 0xf4a3
jmp 0xd624
movl %r14d, %eax
andl $-0x5, %eax
movl %r14d, %ecx
andl $-0x3, %ecx
cmpl $0x2, %eax
movl %r14d, %r12d
movl $0x1, %eax
cmovnel %eax, %r12d
cmpl $0x4, %r14d
cmovel %r14d, %r12d
cmpl $0x8, %ecx
cmovel %r14d, %r12d
leaq 0xfdeb(%rip), %r15      # 0x1d2c0
movq %r15, %rdi
callq 0x90b0
movw $0x30, (%rax,%r15)
cmpl $0x1, 0x10(%rsp)
jne 0xd501
leaq 0xfece(%rip), %r15      # 0x1d3c0
movq %r15, %rdi
callq 0x90b0
movw $0x30, (%rax,%r15)
movl %r12d, %r15d
xorl %ebp, %ebp
callq 0xf3a7
movb %al, 0x46(%rsp,%rbp)
incq %rbp
cmpq %rbp, %r15
jne 0xd506
leal -0x1(%r12), %ebp
movl %ebp, %eax
movzbl 0x46(%rsp,%rax), %edx
cmpl $0x1, 0x10(%rsp)
jne 0xd55f
movq %r13, %rdi
leaq 0x7367(%rip), %rsi      # 0x1489b
xorl %eax, %eax
callq 0x91b0
leaq 0xfd7e(%rip), %rdi      # 0x1d2c0
movq %r13, %rsi
callq 0x91a0
leaq 0xfe6f(%rip), %rdi      # 0x1d3c0
movq %r13, %rsi
callq 0x91a0
testl %ebp, %ebp
jne 0xd58d
jmp 0xd5d7
testl %edx, %edx
je 0xd569
movl $0x1, (%rbx)
movq %r13, %rdi
leaq 0x7328(%rip), %rsi      # 0x1489b
xorl %eax, %eax
callq 0x91b0
leaq 0xfd3f(%rip), %rdi      # 0x1d2c0
movq %r13, %rsi
callq 0x91a0
testl %ebp, %ebp
je 0xd5f5
decl %ebp
jmp 0xd51c
movl $0x1, %eax
leal 0x1(%rax), %ecx
movl %eax, %eax
movb $0x27, (%rax,%r13)
movb $0x0, (%rcx,%r13)
cmpl $0x1, 0x10(%rsp)
je 0xd5b2
movl $0x1, (%rbx)
leaq 0xfd07(%rip), %rdi      # 0x1d2c0
movq %r13, %rsi
callq 0x91a0
leaq 0xfdf8(%rip), %rdi      # 0x1d3c0
movq %r13, %rsi
callq 0x91a0
movl %ebp, %r12d
xorl %ebp, %ebp
jmp 0xd624
leaq 0xfce2(%rip), %rbp      # 0x1d2c0
movq %rbp, %rdi
callq 0x90b0
movw $0x68, (%rax,%rbp)
leaq 0xfdcd(%rip), %rbp      # 0x1d3c0
jmp 0xd5fc
leaq 0xfcc4(%rip), %rbp      # 0x1d2c0
movq %rbp, %rdi
callq 0x90b0
movw $0x68, (%rbp,%rax)
movq 0x8(%rsp), %rax
imulq %rax, %r15
leaq 0xfb7d(%rip), %rcx      # 0x1d198
addq %r15, (%rcx)
movq %rax, %r15
movl %r12d, %ebp
subl %r12d, %r14d
je 0xd64b
leaq 0xfc90(%rip), %r12      # 0x1d2c0
movq %r12, %rdi
callq 0x90b0
movw $0x2c, (%rax,%r12)
leaq 0xfb52(%rip), %r12      # 0x1d198
jmp 0xd367
movb 0x7(%rsp), %r13b
movq 0x18(%rsp), %rbp
jmp 0xd659
xorl %ebp, %ebp
testb %r13b, %r13b
je 0xd673
leaq 0xfc5b(%rip), %rbx      # 0x1d2c0
movq %rbx, %rdi
callq 0x90b0
movw $0x29, (%rax,%rbx)
movl %ebp, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq