// File: /workspace/github_c_makefile_star2_O3/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 0x9787
xorl %ebx, %ebx
testl %eax, %eax
jne 0xb8fe
movq 0x8(%rsp), %r14
movl %r14d, %edx
shrb $0x6, %dl
movl %r14d, %eax
andb $0x7, %al
shlb $0x3, %bpl
andb $0x38, %bpl
movl %r14d, %r15d
shrb $0x3, %r15b
andb $0x7, %r15b
orb %bpl, %r15b
cmpb $0x3, %dl
jne 0xb7bf
movzbl %r15b, %edx
movzbl %al, %ecx
leaq 0x10(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0xb910
movl $0x2, %ebx
jmp 0xb868
movl %r15d, %ecx
andb $0x3d, %cl
movl $0x8, %esi
movl $0x8, %edi
cmpb $0x3c, %cl
je 0xb7e9
movl %ebp, %edi
shrb $0x4, %dil
movzbl %dil, %edi
leaq 0x7b7f(%rip), %r8       # 0x13364
movl (%r8,%rdi,4), %edi
cmpb $0x1d, %cl
cmovel %esi, %edi
cmpb $0x2f, %r15b
movl $0x4, %esi
cmovnel %edi, %esi
cmpb $0x3d, %cl
movl $0x5, %ecx
cmovnel %esi, %ecx
cmpb $0xc, %r15b
setb %sil
cmpb $0x10, %bpl
setae %dil
orb %sil, %dil
leal -0x2f(%r15), %esi
cmpb $-0x3, %sil
setb %sil
andb %dil, %sil
movzbl %sil, %r8d
leaq 0x50(%rsp), %rdi
movb $0x0, (%rdi)
movzbl %dl, %esi
movzbl %al, %edx
callq 0xaf5e
cmpl $-0x1, %eax
je 0xb8fe
movl %eax, %ebp
movzbl %r15b, %eax
leaq 0xfb0b(%rip), %rcx      # 0x1b360
movq (%rcx,%rax,8), %rsi
leaq 0x10(%rsp), %rdi
callq 0x9070
addl $0x2, %ebp
movl %ebp, %ebx
movb 0x10(%rsp), %al
testb %al, %al
je 0xb894
cmpb $0x6e, 0x11(%rsp)
jne 0xb8c4
testb $0x1, 0x11616(%rip)     # 0x1ce94
je 0xb8c4
movb %al, 0x11606(%rip)      # 0x1ce8c
leaq 0x12(%rsp), %rsi
leaq 0x115fb(%rip), %rdi     # 0x1ce8d
jmp 0xb8d0
movzbl %r15b, %edx
andl $0x7, %r14d
leaq 0xd86d(%rip), %rax      # 0x19110
movq 0x40(%rax,%r14,8), %rcx
leaq 0x7aa4(%rip), %rsi      # 0x13353
leaq 0x50(%rsp), %rdi
xorl %eax, %eax
callq 0x91b0
leaq 0x7a9b(%rip), %rdi      # 0x1335d
jmp 0xb8dc
leaq 0x115c1(%rip), %rdi     # 0x1ce8c
leaq 0x10(%rsp), %rsi
callq 0x9070
leaq 0x115b0(%rip), %rdi     # 0x1ce8c
callq 0x97c1
leaq 0x11680(%rip), %rax     # 0x1cf68
cmpl $0x3, (%rax)
jne 0xb8f7
leaq 0x50(%rsp), %rdi
callq 0xca45
movb $0x0, 0x11596(%rip)     # 0x1ce94
movl %ebx, %eax
addq $0x88, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nop