// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xe0, %rsp
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movl $0x200, -0x50(%rbp)     # imm = 0x200
callq 0x11910
cltq
movq %rax, -0x38(%rbp)
callq 0x11910
cltq
shlq $0x8, %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
movl (%rax), %ecx
addl $0x2, %ecx
movl %ecx, (%rax)
cmpl $0x0, -0x1c(%rbp)
je 0xebb8
callq 0x11910
cltq
shlq $0x10, %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
callq 0x11910
cltq
shlq $0x18, %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
movl (%rax), %ecx
addl $0x2, %ecx
movl %ecx, (%rax)
callq 0x11910
movl %eax, -0x3c(%rbp)
callq 0x11910
shll $0x8, %eax
addl -0x3c(%rbp), %eax
movl %eax, -0x3c(%rbp)
movq -0x28(%rbp), %rax
movl (%rax), %ecx
addl $0x2, %ecx
movl %ecx, (%rax)
cmpq $0x0, -0x30(%rbp)
je 0xebeb
movq -0x38(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
cmpq $0x1, -0x38(%rbp)
jne 0xebf8
cmpl $0x0, -0x3c(%rbp)
je 0xec24
movq -0x38(%rbp), %rdx
leaq 0x1178d(%rip), %rdi     # 0x20390
leaq 0x912b(%rip), %rsi      # 0x17d35
movb $0x0, %al
callq 0x9190
leaq 0x11878(%rip), %rdi     # 0x20490
leaq 0x11771(%rip), %rsi     # 0x20390
callq 0x9180
movq -0x38(%rbp), %rax
imulq -0x10(%rbp), %rax
movq %rax, -0x10(%rbp)
cmpl $0x0, -0x3c(%rbp)
je 0xecc3
movl -0x3c(%rbp), %eax
movl %eax, -0x40(%rbp)
cmpl $0x0, -0x40(%rbp)
je 0xecbe
cmpl $0x2, -0x4(%rbp)
jne 0xec57
movq -0x18(%rbp), %rax
movl $0x1, (%rax)
movl -0x4(%rbp), %edi
addl $0x1, %edi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movl -0x1c(%rbp), %ecx
movq -0x28(%rbp), %r8
xorl %eax, %eax
movl %eax, %r9d
callq 0xeb30
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
cmpl -0x50(%rbp), %eax
jae 0xec87
movl -0x4c(%rbp), %eax
movl %eax, -0x50(%rbp)
movl -0x40(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x40(%rbp)
cmpl $0x0, -0x40(%rbp)
je 0xecbc
leaq 0x117f3(%rip), %rdi     # 0x20490
leaq 0x93e9(%rip), %rsi      # 0x1808d
callq 0x9180
leaq 0x118e0(%rip), %rdi     # 0x20590
leaq 0x93d6(%rip), %rsi      # 0x1808d
callq 0x9180
jmp 0xec41
jmp 0xf14f
callq 0x11910
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
movl %eax, -0x50(%rbp)
movl -0x44(%rbp), %ecx
addl $0x1, %ecx
movq -0x28(%rbp), %rax
addl (%rax), %ecx
movl %ecx, (%rax)
movl $0x0, -0x4c(%rbp)
cmpl $0x0, -0x44(%rbp)
je 0xf14d
jmp 0xecf2
callq 0x11a60
movl %eax, -0x48(%rbp)
cmpl $-0x1, -0x48(%rbp)
jne 0xed05
jmp 0xed8d
cmpl $0x20, -0x48(%rbp)
jl 0xed11
cmpl $0x7e, -0x48(%rbp)
jle 0xed13
jmp 0xed8d
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
movq -0x10(%rbp), %rcx
leaq 0x11641(%rip), %rax     # 0x20368
addq (%rax), %rcx
leaq 0x11637(%rip), %rax     # 0x20368
movq %rcx, (%rax)
xorl %edi, %edi
callq 0xe580
movl %eax, -0xc4(%rbp)
movq -0x18(%rbp), %rcx
xorl %eax, %eax
cmpl $0x0, (%rcx)
movb %al, -0xc9(%rbp)
je 0xed7f
movb $0x1, %al
cmpl $0x0, -0xc4(%rbp)
movb %al, -0xca(%rbp)
je 0xed73
cmpl $0x3, -0xc4(%rbp)
sete %al
movb %al, -0xca(%rbp)
movb -0xca(%rbp), %al
movb %al, -0xc9(%rbp)
movb -0xc9(%rbp), %al
testb $0x1, %al
jne 0xecf2
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0xee78
movl -0x4c(%rbp), %eax
leaq 0xde94(%rip), %rcx      # 0x1cc38
cmpl (%rcx), %eax
jb 0xee78
callq 0x118f0
movl -0x4c(%rbp), %ecx
movl -0x44(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x44(%rbp)
movb $0x27, 0x115cd(%rip)    # 0x20390
movl $0x1, -0xc0(%rbp)
cmpl $0x0, -0x4c(%rbp)
je 0xee0a
callq 0x11910
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %eax
movb %al, %dl
movl -0xc0(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0xc0(%rbp)
movl %eax, %eax
movl %eax, %ecx
leaq 0x11594(%rip), %rax     # 0x20390
movb %dl, (%rax,%rcx)
movl -0x4c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0xedcd
movl -0xc0(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0xc0(%rbp)
movl %eax, %eax
movl %eax, %ecx
leaq 0x1156a(%rip), %rax     # 0x20390
movb $0x27, (%rax,%rcx)
movl -0xc0(%rbp), %eax
movl %eax, %ecx
leaq 0x11557(%rip), %rax     # 0x20390
movb $0x0, (%rax,%rcx)
cmpl $0x1, -0x4(%rbp)
je 0xee4d
movq -0x18(%rbp), %rax
movl $0x1, (%rax)
leaq 0x1163c(%rip), %rdi     # 0x20490
leaq 0x11535(%rip), %rsi     # 0x20390
callq 0x9180
leaq 0x11729(%rip), %rdi     # 0x20590
leaq 0x11522(%rip), %rsi     # 0x20390
callq 0x9180
jmp 0xf12f
movl -0x4c(%rbp), %eax
imulq -0x10(%rbp), %rax
leaq 0x114e1(%rip), %rcx     # 0x20368
movq (%rcx), %rcx
subq %rax, %rcx
leaq 0x114d4(%rip), %rax     # 0x20368
movq %rcx, (%rax)
callq 0x118f0
xorl %edi, %edi
callq 0xe580
cmpl $0x2, %eax
jne 0xefa8
cmpl $0x1, -0x4(%rbp)
je 0xeebc
movq -0x18(%rbp), %rax
movl $0x1, (%rax)
leaq 0x11425(%rip), %rax     # 0x202e8
movq (%rax), %rax
cmpl $0x3, 0x18(%rax)
jne 0xef08
leaq -0xb0(%rbp), %rdi
leaq 0x1149a(%rip), %rax     # 0x20374
movl (%rax), %ecx
movl $0x2, %r8d
xorl %r9d, %r9d
leaq -0xc8(%rbp), %rax
movl %r8d, %esi
movl %r9d, %edx
movq %rax, (%rsp)
movl $0x14, 0x8(%rsp)
callq 0x13210
movl %eax, -0x54(%rbp)
jmp 0xef44
leaq -0xb0(%rbp), %rdi
leaq 0x1145e(%rip), %rax     # 0x20374
movl (%rax), %ecx
movl $0x2, %esi
xorl %r9d, %r9d
movl $0x1, %r8d
leaq -0xc8(%rbp), %rax
movl %r9d, %edx
movq %rax, (%rsp)
movl $0x14, 0x8(%rsp)
callq 0x13210
movl %eax, -0x54(%rbp)
movslq -0x54(%rbp), %rcx
imulq -0x10(%rbp), %rcx
leaq 0x11414(%rip), %rax     # 0x20368
addq (%rax), %rcx
leaq 0x1140a(%rip), %rax     # 0x20368
movq %rcx, (%rax)
movl -0x54(%rbp), %ecx
movl -0x44(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x44(%rbp)
leaq 0x111c5(%rip), %rax     # 0x20138
cmpl $0x3, (%rax)
jne 0xef9e
leaq -0xb0(%rbp), %rsi
leaq 0x1150a(%rip), %rdi     # 0x20490
callq 0x9180
leaq -0xb0(%rbp), %rsi
leaq 0x115f7(%rip), %rdi     # 0x20590
callq 0x9180
callq 0x11ab0
jmp 0xf12d
movl -0x44(%rbp), %eax
movl %eax, -0x4c(%rbp)
cmpl $0x2, -0x4c(%rbp)
je 0xefd3
cmpl $0x4, -0x4c(%rbp)
je 0xefd3
cmpl $0x6, -0x4c(%rbp)
je 0xefd3
cmpl $0x8, -0x4c(%rbp)
je 0xefd3
cmpl $0xa, -0x4c(%rbp)
je 0xefd3
movl $0x1, -0x4c(%rbp)
leaq 0x114b6(%rip), %rdi     # 0x20490
leaq 0x816a(%rip), %rsi      # 0x1714b
callq 0x9180
cmpl $0x1, -0x4(%rbp)
jne 0xefff
leaq 0x1159d(%rip), %rdi     # 0x20590
leaq 0x8151(%rip), %rsi      # 0x1714b
callq 0x9180
movl $0x0, -0xc0(%rbp)
movl -0xc0(%rbp), %eax
cmpl -0x4c(%rbp), %eax
jae 0xf039
callq 0x11910
movb %al, %cl
movl -0xc0(%rbp), %eax
movb %cl, -0xba(%rbp,%rax)
movl -0xc0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc0(%rbp)
jmp 0xf009
movl -0x4c(%rbp), %eax
movl %eax, -0xc0(%rbp)
cmpl $0x0, -0xc0(%rbp)
je 0xf0d7
movl -0xc0(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0xc0(%rbp)
cmpl $0x1, -0x4(%rbp)
je 0xf083
movl -0xc0(%rbp), %eax
movzbl -0xba(%rbp,%rax), %eax
cmpl $0x0, %eax
je 0xf081
movq -0x18(%rbp), %rax
movl $0x1, (%rax)
jmp 0xf083
movl -0xc0(%rbp), %eax
movzbl -0xba(%rbp,%rax), %edx
leaq 0x112f8(%rip), %rdi     # 0x20390
leaq 0x9820(%rip), %rsi      # 0x188bf
movb $0x0, %al
callq 0x9190
leaq 0x113e3(%rip), %rdi     # 0x20490
leaq 0x112dc(%rip), %rsi     # 0x20390
callq 0x9180
cmpl $0x1, -0x4(%rbp)
jne 0xf0d2
leaq 0x114ca(%rip), %rdi     # 0x20590
leaq 0x112c3(%rip), %rsi     # 0x20390
callq 0x9180
jmp 0xf042
leaq 0x113b2(%rip), %rdi     # 0x20490
leaq 0x8f9f(%rip), %rsi      # 0x18084
callq 0x9180
cmpl $0x1, -0x4(%rbp)
jne 0xf103
leaq 0x11499(%rip), %rdi     # 0x20590
leaq 0x8f86(%rip), %rsi      # 0x18084
callq 0x9180
movl -0x4c(%rbp), %ecx
movl -0x44(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x44(%rbp)
movq -0x10(%rbp), %rcx
movl -0x4c(%rbp), %eax
imulq %rax, %rcx
leaq 0x11248(%rip), %rax     # 0x20368
addq (%rax), %rcx
leaq 0x1123e(%rip), %rax     # 0x20368
movq %rcx, (%rax)
jmp 0xf12f
cmpl $0x0, -0x44(%rbp)
je 0xf148
leaq 0x11354(%rip), %rdi     # 0x20490
leaq 0x8f4a(%rip), %rsi      # 0x1808d
callq 0x9180
jmp 0xece6
jmp 0xf14f
cmpq $0x1, -0x38(%rbp)
jne 0xf15c
cmpl $0x0, -0x3c(%rbp)
je 0xf16f
leaq 0x1132d(%rip), %rdi     # 0x20490
leaq 0x8d54(%rip), %rsi      # 0x17ebe
callq 0x9180
movl -0x50(%rbp), %eax
addq $0xe0, %rsp
popq %rbp
retq
nopl (%rax,%rax)