// File: /workspace/github_c_makefile_star2_O2/Nico01[P]obj2asm/odisasm.c
// Function: esc
int esc( byte, text, class )
    uchar   byte;
    char            *text;
    int             class;
{
    int             size;
    int             dir;
    int             type;
    dword   mod_reg;
    uchar   mod;
    uchar   r_m;
    uchar   lll;        /* Described as LLL in 80386 Prog Ref Man. */
    uchar   ttt;        /* Described as TTT in 80386 Prog Ref Man. */
    uchar   esc_byte;
    uchar   mf;
    int             additional;
    int             size_needed;
    char            line[50];
    char            temp[50];
    int             ref_mode;

    text = text;               /* Prevent unused variable warnings */
    class=class;              /* Prevent unused variable warnings */

    size = (byte & 0x01);
    dir  = (byte & 0x02) >> 1;
    ref_mode = 0;

    if ( get_checkc( &mod_reg ) ) {
        return( 0 );
    }
    mod = (uchar)(((int)mod_reg & 0xC0) >> 6);
    lll = (uchar)(((int)mod_reg & 0x38) >> 3);
    r_m = (uchar)(((int)mod_reg & 0x07) >> 0);

    ttt = (uchar)(byte & 0x07);
    esc_byte = (uchar)(ttt << 3) + lll;

    if ( mod == 0x03 ) {
        esc_special( temp, line, esc_byte, r_m );
        additional = 0;
    } else {
        mf = (uchar)((esc_byte & 0x30) >> 4);

        size_needed = TRUE;

        switch( mf ) {
            case 0:     type = DWORD_PTR;   break;
            case 1:     type = DWORD_PTR;   break;
            case 2:     type = QWORD_PTR;   break;
            case 3:     type = WORD_PTR;    break;
        }

        /*
        ** There are always exceptions to the rule (Thank you, Intel)
        */
        if (    esc_byte == 0x1D || esc_byte == 0x1F 
             || esc_byte == 0x3C || esc_byte == 0x3E ) {
            type = TBYTE_PTR;
        }
        if ( esc_byte == 0x2F ) {
            type = WORD_PTR;
        }
        if ( esc_byte == 0x3D || esc_byte == 0x3F ) {
            type = DWORD_PTR;
        }

        if (    (esc_byte >= 0x0C && esc_byte <= 0x0F)
             || (esc_byte >= 0x2C && esc_byte <= 0x2E) ) {
            size_needed = FALSE;
        }
        sprintf( line, "" );
        additional = do_mod_rm( line, mod, r_m, type, size_needed, ref_mode );
        if ( additional == -1 ) {           /* Error in 'do_mod_rm' */
            return( 0 );
        }
        strcpy( temp, esc_inst[esc_byte] );
    }
    if ( strlen( temp ) ) {
        if ( temp[1] == 'n' && fp_wait ) {
            fp_opcode[0] = temp[0];             /* Remove the 'n' */
            strcpy( &fp_opcode[1], &temp[2] );
        } else {
            strcpy( fp_opcode, temp );
        }
        instr_opcode( fp_opcode );
        instr_operand( line );
    } else {
        sprintf( line, "0%02Xh,%s", esc_byte, regs[1][r_m] );
        instr_opcode( "esc" );
        instr_operand( line );
    }

    fp_wait = FALSE;                /* Reset always */
    dir = dir;
    size = size;
    return( 2+additional );
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x88, %rsp
movl %edi, %ebp
leaq 0x8(%rsp), %rdi
callq 0x946e
xorl %ebx, %ebx
testl %eax, %eax
jne 0xb3f6
movq 0x8(%rsp), %r15
movl %r15d, %edx
shrb $0x6, %dl
movl %r15d, %eax
andb $0x7, %al
shlb $0x3, %bpl
andb $0x38, %bpl
movl %r15d, %esi
shrb $0x3, %sil
andb $0x7, %sil
orb %bpl, %sil
movzbl %sil, %r14d
cmpb $0x3, %dl
jne 0xb2c8
movzbl %al, %ecx
leaq 0x10(%rsp), %rdi
leaq 0x50(%rsp), %rsi
movl %r14d, %edx
callq 0xb408
pushq $0x2
popq %rbx
jmp 0xb367
movl %esi, %ecx
andb $0x3d, %cl
pushq $0x8
popq %rdi
movl %edi, %r8d
cmpb $0x3c, %cl
je 0xb2ee
movl %ebp, %r8d
shrb $0x4, %r8b
movzbl %r8b, %r8d
leaq 0x707a(%rip), %r9       # 0x12364
movl (%r9,%r8,4), %r8d
cmpb $0x1d, %cl
cmovel %edi, %r8d
cmpb $0x2f, %sil
pushq $0x4
popq %rdi
cmovnel %r8d, %edi
cmpb $0x3d, %cl
pushq $0x5
popq %rcx
cmovnel %edi, %ecx
cmpb $0xc, %sil
setb %dil
cmpb $0x10, %bpl
setae %r8b
orb %dil, %r8b
addb $-0x2f, %sil
cmpb $-0x3, %sil
setb %sil
andb %r8b, %sil
movzbl %sil, %r8d
leaq 0x50(%rsp), %rdi
movb $0x0, (%rdi)
movzbl %dl, %esi
movzbl %al, %edx
callq 0xaae5
cmpl $-0x1, %eax
je 0xb3f6
movl %eax, %ebp
leaq 0xf00c(%rip), %rax      # 0x1a360
movq (%rax,%r14,8), %rsi
leaq 0x10(%rsp), %rdi
callq 0x9070
addl $0x2, %ebp
movl %ebp, %ebx
movb 0x10(%rsp), %al
testb %al, %al
je 0xb39a
cmpb $0x6e, 0x11(%rsp)
jne 0xb3c9
testb $0x1, 0x10b17(%rip)     # 0x1be94
je 0xb3c9
movb %al, 0x10b07(%rip)      # 0x1be8c
leaq 0x10b00(%rip), %r14     # 0x1be8c
leaq 0x12(%rsp), %rsi
leaq 0x10af5(%rip), %rdi     # 0x1be8d
jmp 0xb3d8
andl $0x7, %r15d
leaq 0xcd6b(%rip), %rax      # 0x18110
movq 0x40(%rax,%r15,8), %rcx
leaq 0x6fa2(%rip), %rsi      # 0x12353
leaq 0x50(%rsp), %rdi
movl %r14d, %edx
xorl %eax, %eax
callq 0x91b0
leaq 0x6f96(%rip), %r14      # 0x1235d
jmp 0xb3dd
leaq 0x10abc(%rip), %r14     # 0x1be8c
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0x9070
movq %r14, %rdi
callq 0x9491
leaq 0x50(%rsp), %rdi
callq 0x94b3
movb $0x0, 0x10a9e(%rip)     # 0x1be94
movl %ebx, %eax
addq $0x88, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nop