// File: /workspace/github_c_makefile_star2_O2/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 $0x88, %rsp
movq %r9, 0x10(%rsp)
movq %r8, %r12
movl %ecx, %r15d
movq %rdx, %rbx
movq %rsi, %r13
movq %rdi, 0x8(%rsp)
callq 0xec15
movslq %eax, %r14
callq 0xec15
movslq %eax, %rbp
shlq $0x8, %rbp
addq %r14, %rbp
addl $0x2, (%r12)
movl %r15d, 0x4(%rsp)
testl %r15d, %r15d
je 0xcbfe
callq 0xec15
movslq %eax, %r14
shlq $0x10, %r14
callq 0xec15
cltq
shlq $0x18, %rax
addq %r14, %rax
addq %rax, %rbp
addl $0x2, (%r12)
callq 0xec15
movl %eax, %r14d
callq 0xec15
movl %eax, %r15d
shll $0x8, %r15d
addl %r14d, %r15d
addl $0x2, (%r12)
movq 0x10(%rsp), %rax
testq %rax, %rax
movq %r13, %r14
je 0xcc2a
movq %rbp, (%rax)
cmpq $0x1, %rbp
setne %al
testl %r15d, %r15d
setne %r13b
orb %al, %r13b
cmpb $0x1, %r13b
movb %r13b, 0x3(%rsp)
jne 0xcd12
leaq 0xf56f(%rip), %rdi      # 0x1c1c0
leaq 0x603f(%rip), %rsi      # 0x12c97
movq %rbp, %rdx
xorl %eax, %eax
callq 0x91b0
leaq 0xf657(%rip), %rdi      # 0x1c2c0
leaq 0xf550(%rip), %rsi      # 0x1c1c0
callq 0x91a0
imulq %rbp, %r14
testl %r15d, %r15d
je 0xcd12
movq 0x8(%rsp), %rax
leal 0x1(%rax), %ebp
movl $0x200, %eax            # imm = 0x200
movq %rax, 0x10(%rsp)
movl %r15d, %r13d
subl $0x1, %r13d
jb 0xd01d
cmpl $0x2, 0x8(%rsp)
jne 0xccae
movl $0x1, (%rbx)
movl %ebp, %edi
movq %r14, %rsi
movq %rbx, %rdx
movl 0x4(%rsp), %ecx
movq %r12, %r8
xorl %r9d, %r9d
callq 0xcb8f
movq 0x10(%rsp), %rcx
cmpl %ecx, %eax
cmovbl %eax, %ecx
movq %rcx, 0x10(%rsp)
cmpl $0x1, %r15d
movl %r13d, %r15d
je 0xcc94
leaq 0xf5dc(%rip), %r15      # 0x1c2c0
movq %r15, %rdi
callq 0x90b0
movw $0x2c, %cx
movw %cx, (%rax,%r15)
leaq 0xf6c4(%rip), %r15      # 0x1c3c0
movq %r15, %rdi
callq 0x90b0
movw $0x2c, %cx
movw %cx, (%rax,%r15)
movl %r13d, %r15d
jmp 0xcc94
callq 0xec15
movl (%r12), %ecx
addl %eax, %ecx
incl %ecx
movl %ecx, (%r12)
leaq 0xf46e(%rip), %rbp      # 0x1c198
leaq 0xf48f(%rip), %r12      # 0x1c1c0
movq %rax, 0x10(%rsp)
movl %eax, 0x4(%rsp)
xorl %r13d, %r13d
movq %r14, 0x18(%rsp)
cmpl $0x0, 0x4(%rsp)
je 0xd01d
callq 0xece6
addl $-0x7f, %eax
cmpl $-0x60, %eax
jbe 0xcd80
addq %r14, (%rbp)
xorl %edi, %edi
callq 0xc74e
cmpl $0x0, (%rbx)
sete %cl
je 0xcd7b
cmpl $0x3, %eax
je 0xcd76
testl %eax, %eax
jne 0xcd7b
incl %r13d
jmp 0xcd4d
incl %r13d
jmp 0xcd86
cmpl $0x0, (%rbx)
sete %cl
testb %cl, %cl
jne 0xcdcb
leaq 0xbd77(%rip), %rax      # 0x18b08
cmpl (%rax), %r13d
jb 0xcdcb
callq 0xec06
movb $0x27, 0xf41e(%rip)     # 0x1c1c0
movl %r13d, %ebp
negl %ebp
pushq $0x1
popq %rax
movl %eax, %r15d
leal (%r15,%rbp), %eax
movl %r15d, %r14d
cmpl $0x1, %eax
je 0xce7a
callq 0xec15
incl %r15d
movb %al, (%r14,%r12)
jmp 0xcdad
movl %r13d, %eax
imulq %r14, %rax
subq %rax, (%rbp)
callq 0xec06
xorl %edi, %edi
callq 0xc74e
cmpl $0x2, %eax
jne 0xcec9
cmpl $0x1, 0x8(%rsp)
je 0xcdf8
movl $0x1, (%rbx)
leaq 0xf319(%rip), %rax      # 0x1c118
movq (%rax), %rax
xorl %r8d, %r8d
cmpl $0x3, 0x18(%rax)
sete %r8b
leaq 0xf390(%rip), %rax      # 0x1c1a4
movl (%rax), %ecx
incl %r8d
leaq 0x30(%rsp), %rdi
pushq $0x2
popq %rsi
xorl %edx, %edx
xorl %r9d, %r9d
pushq $0x14
leaq 0x28(%rsp), %rax
pushq %rax
callq 0xfad9
popq %rcx
popq %rdx
movl %eax, %r15d
cltq
imulq %r14, %rax
addq %rax, (%rbp)
leaq 0xf11f(%rip), %rax      # 0x1bf68
cmpl $0x3, (%rax)
jne 0xce70
leaq 0xf46b(%rip), %rdi      # 0x1c2c0
leaq 0x30(%rsp), %rsi
callq 0x91a0
leaq 0xf55a(%rip), %rdi      # 0x1c3c0
leaq 0x30(%rsp), %rsi
callq 0x91a0
callq 0xed09
jmp 0xcff7
incl %r15d
movb $0x27, (%r14,%r12)
movb $0x0, (%r15,%r12)
cmpl $0x1, 0x8(%rsp)
je 0xce94
movl $0x1, (%rbx)
leaq 0xf425(%rip), %rdi      # 0x1c2c0
movq %r12, %rsi
callq 0x91a0
leaq 0xf516(%rip), %rdi      # 0x1c3c0
movq %r12, %rsi
callq 0x91a0
movl %r13d, %r15d
xorl %r13d, %r13d
movq 0x18(%rsp), %r14
leaq 0xf2d4(%rip), %rbp      # 0x1c198
jmp 0xcff7
movl 0x4(%rsp), %edx
movl %edx, %eax
andl $-0x5, %eax
movl %edx, %ecx
andl $-0x3, %ecx
cmpl $0x2, %eax
movl %edx, %r15d
pushq $0x1
popq %rax
cmovnel %eax, %r15d
cmpl $0x4, %edx
cmovel %edx, %r15d
cmpl $0x8, %ecx
cmovel %edx, %r15d
leaq 0xf3c7(%rip), %r14      # 0x1c2c0
movq %r14, %rdi
callq 0x90b0
movw $0x30, (%rax,%r14)
cmpl $0x1, 0x8(%rsp)
jne 0xcf25
leaq 0xf4aa(%rip), %r14      # 0x1c3c0
movq %r14, %rdi
callq 0x90b0
movw $0x30, (%rax,%r14)
movl %r15d, %r13d
xorl %r14d, %r14d
cmpq %r14, %r13
je 0xcf3f
callq 0xec15
movb %al, 0x26(%rsp,%r14)
incq %r14
jmp 0xcf2b
movq %r13, %rax
movq %r13, %rbp
movq 0x18(%rsp), %r14
subq $0x1, %rbp
jb 0xcfb4
movzbl 0x25(%rsp,%rax), %edx
cmpl $0x1, 0x8(%rsp)
jne 0xcf85
movq %r12, %rdi
leaq 0x6935(%rip), %rsi      # 0x1389b
xorl %eax, %eax
callq 0x91b0
leaq 0xf34c(%rip), %rdi      # 0x1c2c0
movq %r12, %rsi
callq 0x91a0
leaq 0xf43d(%rip), %rdi      # 0x1c3c0
jmp 0xcfa7
testl %edx, %edx
je 0xcf8f
movl $0x1, (%rbx)
movq %r12, %rdi
leaq 0x6902(%rip), %rsi      # 0x1389b
xorl %eax, %eax
callq 0x91b0
leaq 0xf319(%rip), %rdi      # 0x1c2c0
movq %r12, %rsi
callq 0x91a0
movq %rbp, %rax
jmp 0xcf4a
leaq 0xf305(%rip), %rbp      # 0x1c2c0
movq %rbp, %rdi
callq 0x90b0
movw $0x68, (%rax,%rbp)
cmpl $0x1, 0x8(%rsp)
jne 0xcfe5
leaq 0xf3e9(%rip), %rbp      # 0x1c3c0
movq %rbp, %rdi
callq 0x90b0
movw $0x68, (%rax,%rbp)
imulq %r14, %r13
leaq 0xf1a8(%rip), %rbp      # 0x1c198
addq %r13, (%rbp)
movl %r15d, %r13d
subl %r15d, 0x4(%rsp)
je 0xcd42
leaq 0xf2b7(%rip), %r15      # 0x1c2c0
movq %r15, %rdi
callq 0x90b0
movw $0x2c, (%rax,%r15)
jmp 0xcd42
cmpb $0x0, 0x3(%rsp)
je 0xd039
leaq 0xf295(%rip), %rbx      # 0x1c2c0
movq %rbx, %rdi
callq 0x90b0
movw $0x29, (%rax,%rbx)
movq 0x10(%rsp), %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq