// File: /workspace/github_c_makefile_star2_O3/Nico01[P]obj2asm/odisasm.c
// Function: do_mod_rm
int do_mod_rm( line, mod, r_m, type, size_needed, ref_mode )
    char            *line;
    uchar   mod;
    uchar   r_m;
    int             type;
    int             size_needed;
    int             ref_mode;
{
    int             size_known;
    int             sib_offset;
    char            sib_text[50];
    char            temp2[50];
    int             result;
    
    size_known = FALSE;

    strcpy( sib_text, "" );
    sib_offset = 0;

    if ( addr_large ) {
        if ( r_m == 4 && mod != 3 ) {
            /* Get result and new r_m */
            sib_offset = do_sib( sib_text, &r_m );
            if ( sib_offset == -1 ) {
                return( -1 );
            }
        }
    }
    switch( mod ) {
        case 0: result = mod0( ref_mode, sib_offset, sib_text, temp2,
                                            r_m, type, &size_known );
                break;
        case 1: result = mod1( ref_mode, sib_offset, sib_text, temp2, r_m );
                size_known = TRUE;
                break;
        case 2: result = mod2( ref_mode, sib_offset, sib_text, temp2,
                                            r_m, type, &size_known );
                break;
        case 3: result = mod3( ref_mode, temp2, r_m, type, &size_known );
                size_needed = FALSE;
                break;
    }

    if ( result != -1 ) {
        if ( compatibility == 2 ) {
            if ( over_seg != -1 ) {         /* Any previous segment overide? */
                strcat( line, sregsc[over_seg] );
                strcat( line, " " );
            }
            if ( !size_known || size_needed ) {
                strcat( line, type_to_text(type) );
            }
        } else {
            /*
            ** If the size is already known, then we don't need 'xxxx' ptr text
            */
            if ( !size_known || size_needed ) {
                strcat( line, type_to_text(type) );
            }
            if ( over_seg != -1 ) {         /* Any previous segment overide? */
                strcat( line, sregsc[over_seg] );
            }
        }
        strcat( line, temp2 );
    }
    return( result );
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x88, %rsp
movl %r8d, %ebp
movl %ecx, %r14d
movl %esi, %r15d
movq %rdi, %rbx
movb %dl, 0xb(%rsp)
movl $0x0, 0xc(%rsp)
movb $0x0, 0x50(%rsp)
xorl %esi, %esi
cmpl $0x0, 0x11ef7(%rip)     # 0x1ce88
je 0xafbe
cmpb $0x4, %dl
setne %al
cmpb $0x3, %r15b
sete %cl
orb %al, %cl
jne 0xafbe
leaq 0x50(%rsp), %rdi
leaq 0xb(%rsp), %rsi
callq 0xaec7
movl %eax, %esi
cmpl $-0x1, %eax
je 0xb068
cmpb $0x3, %r15b
ja 0xb073
movzbl %r15b, %eax
leaq 0x8061(%rip), %rcx      # 0x13034
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movzbl 0xb(%rsp), %r8d
leaq 0xc(%rsp), %rax
movq %rax, (%rsp)
leaq 0x50(%rsp), %rdx
leaq 0x10(%rsp), %rcx
movl %r14d, %r9d
callq 0xa799
jmp 0xb020
movzbl 0xb(%rsp), %r8d
leaq 0xc(%rsp), %rax
movq %rax, (%rsp)
leaq 0x50(%rsp), %rdx
leaq 0x10(%rsp), %rcx
movl %r14d, %r9d
callq 0xabef
movl %eax, %r15d
jmp 0xb062
movzbl 0xb(%rsp), %eax
leal -0x3(%r14), %ecx
cmpl $0x2, %ecx
ja 0xb075
movl %ecx, %ecx
leaq 0xdd8c(%rip), %rdx      # 0x18dc8
movq (%rdx,%rcx,8), %rcx
jmp 0xb07c
movzbl 0xb(%rsp), %r8d
leaq 0x50(%rsp), %rdx
leaq 0x10(%rsp), %rcx
callq 0xaac2
movl %eax, %r15d
movl $0x1, 0xc(%rsp)
cmpl $-0x1, %r15d
jne 0xb097
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
jmp 0xb134
jmp 0xb097
leaq 0xe154(%rip), %rcx      # 0x191d0
movq (%rcx,%rax,8), %rsi
leaq 0x10(%rsp), %rdi
callq 0x9070
movl $0x1, 0xc(%rsp)
xorl %r15d, %r15d
xorl %ebp, %ebp
leaq 0x11e5a(%rip), %rax     # 0x1cef8
cmpl $0x2, (%rax)
jne 0xb0e9
movslq 0xe9de(%rip), %rax      # 0x19a88
cmpq $-0x1, %rax
je 0xb0d1
leaq 0xe189(%rip), %rcx      # 0x19240
movq (%rcx,%rax,8), %rsi
movq %rbx, %rdi
callq 0x91a0
movq %rbx, %rdi
callq 0x90b0
movw $0x20, (%rbx,%rax)
testl %ebp, %ebp
jne 0xb0dc
cmpl $0x0, 0xc(%rsp)
jne 0xb127
movl %r14d, %edi
callq 0xf67d
movq %rax, %rsi
jmp 0xb11f
testl %ebp, %ebp
jne 0xb0f4
cmpl $0x0, 0xc(%rsp)
jne 0xb107
movl %r14d, %edi
callq 0xf67d
movq %rbx, %rdi
movq %rax, %rsi
callq 0x91a0
movslq 0xe97a(%rip), %rax      # 0x19a88
cmpq $-0x1, %rax
je 0xb127
leaq 0xe125(%rip), %rcx      # 0x19240
movq (%rcx,%rax,8), %rsi
movq %rbx, %rdi
callq 0x91a0
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x91a0
movl %r15d, %eax
addq $0x88, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq