// File: /workspace/github_c_makefile_star2_O1/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, 0x8(%rsp)
movl %esi, %ebx
movl %ebp, %eax
andb $-0x2, %al
xorl %ecx, %ecx
cmpb $0x2, %al
setne %cl
addl $0x13, %ecx
movl 0xee97(%rip), %eax      # 0x19a88
leal 0x11(%rax), %r15d
cmpl $-0x1, %eax
cmovel %ecx, %r15d
leal 0x2(%rbx), %edi
callq 0xcca8
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
testl %eax, %eax
je 0xac9c
cmpl $0x2, %eax
jne 0xae49
leaq 0x124f6(%rip), %rax     # 0x1d118
movq (%rax), %rax
cmpl $0x0, 0x3c(%rax)
je 0xae49
movl 0x38(%rax), %eax
cmpl 0x12250(%rip), %eax     # 0x1ce88
jne 0xae49
movl 0xee4c(%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 0x10207
addq $0x10, %rsp
leaq 0x12286(%rip), %rax     # 0x1cef8
cmpl $0x2, (%rax)
jne 0xadc9
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0x9070
movzbl %bpl, %eax
leaq 0xe69d(%rip), %rcx      # 0x19330
movq (%rcx,%rax,8), %r12
jmp 0xae26
cmpl $0x0, 0x121e5(%rip)     # 0x1ce88
je 0xacaf
movq %rsp, %rdi
callq 0x971c
jmp 0xacb7
movq %rsp, %rdi
callq 0x96e5
testl %eax, %eax
setne %al
movq (%rsp), %r13
testq %r13, %r13
sete %cl
orb %al, %cl
jne 0xae49
cmpl $0x0, 0x121b3(%rip)     # 0x1ce88
leaq 0xe654(%rip), %rax      # 0x19330
leaq 0xe68d(%rip), %rcx      # 0x19370
cmoveq %rax, %rcx
movzbl %bpl, %eax
movq (%rcx,%rax,8), %rsi
movq %r14, %rdi
callq 0x9070
movq 0x8(%rsp), %r15
cmpb $0x0, (%r15)
je 0xad1c
movq %r14, %rdi
callq 0x90b0
movw $0x2b, (%r14,%rax)
movq %r14, %rdi
movq %r15, %rsi
callq 0x91a0
movl $0x80000001, %eax       # imm = 0x80000001
cmpq %rax, %r13
jb 0xad36
negq %r13
movq %r13, (%rsp)
leaq 0x861d(%rip), %r15      # 0x13351
jmp 0xad3d
leaq 0x8612(%rip), %r15      # 0x1334f
movq (%rsp), %rdi
movl 0xed49(%rip), %edx      # 0x19a90
leaq 0x10(%rsp), %rsi
callq 0xcb08
leaq 0x121a0(%rip), %rax     # 0x1cef8
movl (%rax), %ebp
movq %r14, %rdi
callq 0x90b0
cmpl $0x2, %ebp
jne 0xad8e
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 0xadb3
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 0xecd7(%rip), %ebx      # 0x19a90
movq 0x80(%rsp), %rax
movl $0x1, (%rax)
jmp 0xae46
cmpl $0x0, 0x120b8(%rip)     # 0x1ce88
leaq 0xe559(%rip), %rax      # 0x19330
leaq 0xe592(%rip), %rcx      # 0x19370
cmoveq %rax, %rcx
movzbl %bpl, %eax
movq (%rcx,%rax,8), %rsi
movq %r14, %rdi
callq 0x9070
movq 0x8(%rsp), %r15
cmpb $0x0, (%r15)
je 0xae17
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 0xec4a(%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