// File: /workspace/github_c_makefile_star2_O2/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 %r12
pushq %rbx
subq $0x90, %rsp
movl %r8d, %r14d
movl %ecx, %ebp
movl %esi, %r15d
movq %rdi, %rbx
movb %dl, 0xb(%rsp)
andl $0x0, 0xc(%rsp)
movb $0x0, 0x50(%rsp)
xorl %esi, %esi
cmpl $0x0, 0x11372(%rip)     # 0x1be88
pushq $-0x1
popq %r12
je 0xab47
cmpb $0x4, %dl
setne %al
cmpb $0x3, %r15b
sete %cl
orb %al, %cl
jne 0xab47
leaq 0x50(%rsp), %rdi
leaq 0xb(%rsp), %rsi
callq 0xaa4d
movl %eax, %esi
cmpl $-0x1, %eax
je 0xac97
cmpb $0x3, %r15b
ja 0xabf7
movzbl %r15b, %eax
leaq 0x74d8(%rip), %rcx      # 0x12034
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 %ebp, %r9d
callq 0xa34a
jmp 0xaba9
movzbl 0xb(%rsp), %r8d
leaq 0xc(%rsp), %rax
movq %rax, (%rsp)
leaq 0x50(%rsp), %rdx
leaq 0x10(%rsp), %rcx
movl %ebp, %r9d
callq 0xa788
movl %eax, %r15d
jmp 0xabec
movzbl 0xb(%rsp), %edx
leaq 0x10(%rsp), %rsi
leaq 0xc(%rsp), %r8
movl %ebp, %ecx
callq 0xaa12
xorl %r15d, %r15d
xorl %r14d, %r14d
jmp 0xabf7
movzbl 0xb(%rsp), %r8d
leaq 0x50(%rsp), %rdx
leaq 0x10(%rsp), %rcx
callq 0xa658
movl %eax, %r15d
movl $0x1, 0xc(%rsp)
cmpl $-0x1, %r15d
jne 0xabf7
jmp 0xac97
leaq 0x112fa(%rip), %rax     # 0x1bef8
cmpl $0x2, (%rax)
jne 0xac49
movslq 0xde7e(%rip), %rax      # 0x18a88
cmpq $-0x1, %rax
je 0xac31
leaq 0xd629(%rip), %rcx      # 0x18240
movq (%rcx,%rax,8), %rsi
movq %rbx, %rdi
callq 0x91a0
movq %rbx, %rdi
callq 0x90b0
movw $0x20, (%rbx,%rax)
testl %r14d, %r14d
jne 0xac3d
cmpl $0x0, 0xc(%rsp)
jne 0xac87
movl %ebp, %edi
callq 0xeef1
movq %rax, %rsi
jmp 0xac7f
testl %r14d, %r14d
jne 0xac55
cmpl $0x0, 0xc(%rsp)
jne 0xac67
movl %ebp, %edi
callq 0xeef1
movq %rbx, %rdi
movq %rax, %rsi
callq 0x91a0
movslq 0xde1a(%rip), %rax      # 0x18a88
cmpq $-0x1, %rax
je 0xac87
leaq 0xd5c5(%rip), %rcx      # 0x18240
movq (%rcx,%rax,8), %rsi
movq %rbx, %rdi
callq 0x91a0
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x91a0
movl %r15d, %r12d
movl %r12d, %eax
addq $0x90, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq