// File: /workspace/github_c_makefile_star2_O3/Nico01[P]obj2asm/odisasm.c
// Function: mod2
int mod2( ref_mode, sib_offset, sib_text, text, r_m, type, size_known )
    int             ref_mode;
    int             sib_offset;
    char            *sib_text;
    char            *text;
    uchar   r_m;
    int             type;
    int             *size_known;
{
    dword   offset;
    int             result;
    char            temp[50];
    char            *sign;
    int             ref_seg;

    if ( r_m == 2 || r_m == 3 ) {
        ref_seg = SS;               /* SS relative addressing modes */
    } else {
        ref_seg = DS;
    }
    if ( over_seg != -1 ) {
        ref_seg = 17+over_seg;
    }

    switch( data_check(2+sib_offset) ) {
        case BAD:
            result = -1;
            break;
        case LABEL:
            result = -1;
            break;
        case FIXUP:
            if ( fix_rec->word_sized && fix_rec->extended == addr_large ) {
                get_fix( temp, 0, FALSE, addr_bytes,
                                            type, TRUE, size_known, ref_seg );
                if ( compatibility == 2 ) {
                    strcpy( text, temp );
                    strcat( text, addr_mode[r_m] );
                } else {
                    if ( addr_large ) {
                        strcpy( text, addr_386m[r_m] );
                    } else {
                        strcpy( text, addr_mode[r_m] );
                    }
                    if ( strlen(sib_text) ) {
                        strcat( text, "+" );
                        strcat( text, sib_text );
                    }
                    strcat( text, "+" );
                    strcat( text, temp );
                }
                strcat( text, "]" );
                result = addr_bytes+sib_offset;
            } else {
                result = -1;
            }
            break;
        case NORMAL:
            if ( check_getv( &offset, addr_large ) ) {
                result = -1;
            } else {
                if ( offset == 0x00000000L ) { 
                    return( -1 );       /* Assembler should have optimized */
                }
                if ( addr_large ) {
                    strcpy( text, addr_386m[r_m] );
                } else {
                    strcpy( text, addr_mode[r_m] );
                }
                if ( strlen(sib_text) ) {
                    strcat( text, "+" );
                    strcat( text, sib_text );
                }
                if ( offset > 0x80000000L ) {
                    offset = -offset;
                    sign = "-";
                } else {
                    sign = "+";
                }
                out_hexize( offset, temp, addr_bytes );
                if ( compatibility == 2 ) {
                    strcat( text, "]" );
                    strcat( text, sign );
                    strcat( text, temp );
                } else {
                    strcat( text, sign );
                    strcat( text, temp );
                    strcat( text, "]" );
                }
                result = addr_bytes+sib_offset;
                *size_known = TRUE;
            }
            break;
    }
    return( result );
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %r9d, %r13d
movl %r8d, %ebp
movq %rcx, %r14
movq %rdx, (%rsp)
movl %esi, %ebx
movl %ebp, %eax
andb $-0x2, %al
xorl %ecx, %ecx
cmpb $0x2, %al
setne %cl
addl $0x13, %ecx
movl 0xee68(%rip), %eax      # 0x19a88
leal 0x11(%rax), %r15d
cmpl $-0x1, %eax
cmovel %ecx, %r15d
leal 0x2(%rbx), %edi
callq 0xcd14
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
testl %eax, %eax
je 0xaccb
cmpl $0x2, %eax
jne 0xae7a
leaq 0x124c7(%rip), %rax     # 0x1d118
movq (%rax), %rax
cmpl $0x0, 0x3c(%rax)
je 0xae7a
movl 0x38(%rax), %eax
cmpl 0x12221(%rip), %eax     # 0x1ce88
jne 0xae7a
movl 0xee1d(%rip), %ecx      # 0x19a90
leaq 0x10(%rsp), %r12
movq %r12, %rdi
xorl %esi, %esi
xorl %edx, %edx
movl %r13d, %r8d
movl $0x1, %r9d
pushq %r15
pushq 0x88(%rsp)
callq 0x1027f
addq $0x10, %rsp
leaq 0x12257(%rip), %rax     # 0x1cef8
cmpl $0x2, (%rax)
jne 0xadfb
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0x9070
movzbl %bpl, %eax
leaq 0xe66e(%rip), %rcx      # 0x19330
movq (%rcx,%rax,8), %r12
jmp 0xae57
cmpl $0x0, 0x121b6(%rip)     # 0x1ce88
je 0xace0
leaq 0x8(%rsp), %rdi
callq 0x971c
jmp 0xacea
leaq 0x8(%rsp), %rdi
callq 0x96e5
testl %eax, %eax
setne %al
movq 0x8(%rsp), %r13
testq %r13, %r13
sete %cl
orb %al, %cl
jne 0xae7a
cmpl $0x0, 0x1217f(%rip)     # 0x1ce88
leaq 0xe620(%rip), %rax      # 0x19330
leaq 0xe659(%rip), %rcx      # 0x19370
cmoveq %rax, %rcx
movzbl %bpl, %eax
movq (%rcx,%rax,8), %rsi
movq %r14, %rdi
callq 0x9070
movq (%rsp), %r15
cmpb $0x0, (%r15)
je 0xad4f
movq %r14, %rdi
callq 0x90b0
movw $0x2b, (%r14,%rax)
movq %r14, %rdi
movq %r15, %rsi
callq 0x91a0
movq %r13, %rdi
negq %rdi
movl $0x80000000, %eax       # imm = 0x80000000
cmpq %rax, %r13
cmovbeq %r13, %rdi
leaq 0x85e9(%rip), %rax      # 0x13351
leaq 0x85e0(%rip), %r15      # 0x1334f
cmovaq %rax, %r15
movl 0xed17(%rip), %edx      # 0x19a90
leaq 0x10(%rsp), %rsi
callq 0xcb74
leaq 0x1216e(%rip), %rax     # 0x1cef8
movl (%rax), %ebp
movq %r14, %rdi
callq 0x90b0
cmpl $0x2, %ebp
jne 0xadc0
movw $0x5d, (%r14,%rax)
movq %r14, %rdi
callq 0x90b0
movzwl (%r15), %ecx
movw %cx, (%r14,%rax)
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0x91a0
jmp 0xade5
movzwl (%r15), %ecx
movw %cx, (%r14,%rax)
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0x91a0
movq %r14, %rdi
callq 0x90b0
movw $0x5d, (%r14,%rax)
addl 0xeca5(%rip), %ebx      # 0x19a90
movq 0x80(%rsp), %rax
movl $0x1, (%rax)
jmp 0xae77
cmpl $0x0, 0x12086(%rip)     # 0x1ce88
leaq 0xe527(%rip), %rax      # 0x19330
leaq 0xe560(%rip), %rcx      # 0x19370
cmoveq %rax, %rcx
movzbl %bpl, %eax
movq (%rcx,%rax,8), %rsi
movq %r14, %rdi
callq 0x9070
movq (%rsp), %r15
cmpb $0x0, (%r15)
je 0xae48
movq %r14, %rdi
callq 0x90b0
movw $0x2b, (%r14,%rax)
movq %r14, %rdi
movq %r15, %rsi
callq 0x91a0
movq %r14, %rdi
callq 0x90b0
movw $0x2b, (%r14,%rax)
movq %r14, %rdi
movq %r12, %rsi
callq 0x91a0
movq %r14, %rdi
callq 0x90b0
movw $0x5d, (%r14,%rax)
addl 0xec19(%rip), %ebx      # 0x19a90
movl %ebx, %r12d
movl %r12d, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq