// File: /workspace/github_c_makefile_star2_O2/Nico01[P]obj2asm/odisasm.c
// Function: mod0
int mod0( 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;
    PUB_T           *pub_rec;
    STRUC_T         *pub_struct;
    int             ref_seg;
    char            this_member[NAMESIZE+1+1];  /* 1 for ., 1 for \0 */
    char            temp[16];

    this_member[0] = '\0';

    if ( (r_m == 6 && !addr_large) || (r_m == 5 && addr_large) ) {
        if ( over_seg != -1 ) {
            ref_seg = 17+over_seg;
        } else {
            ref_seg = DS;
        }
        switch( data_check( 2+sib_offset ) ) {
            case BAD:
                result = -1;
                return( result );
            case LABEL:
                result = -1;
                return( result );
            case FIXUP:
                if ( fix_rec->word_sized && fix_rec->extended == addr_large ) {
                    get_fix( text, 0, FALSE, size_bytes, 
                                            type, TRUE, size_known, ref_seg );
                    if ( strlen(sib_text) ) {
                        strcat( text, "[" );
                        strcat( text, sib_text );
                        strcat( text, "]" );
                    }
                    result = addr_bytes+sib_offset;
                } else {
                    result = -1;
                }
                return( result );
            case NORMAL:
                if ( check_getv( &offset, size_large ) ) {
                    result = -1;
                    return( result );
                }
                if ( add_labels ) {
                    pub_rec = check_public( 0, 0, offset, 'S' );
                } else {
                    pub_rec = NULL;
                }
                if ( pub_rec ) {
                    offset -= pub_rec->offset;
                    pub_struct = pub_rec->structure;
                    if ( pub_struct ) {
                        find_member( this_member, pub_struct, &offset );
                    }
                    if ( offset != 0 ) {
                        out_hexize( offset, temp, size_bytes );
                        sprintf( text, "%s%s + %s",
                                 pub_rec->name, this_member, temp );
                    } else {
                        sprintf( text, "%s%s", pub_rec->name, this_member );
                    }
                } else {
                    out_hexize( offset, temp, size_bytes );
                    if ( compatibility == 2 ) {
                        sprintf( text, " .%s", temp );
                    } else {
                        if ( over_seg == -1 ) {
                            sprintf( text, "ds:[%s", temp );
                        } else {
                            sprintf( text, "[%s", temp );
                        }
                        if ( strlen( sib_text ) ) {
                            strcat( text, "+" );
                            strcat( text, sib_text );
                        }
                        strcat( text, "]" );
                    }
                }
                result = addr_bytes+sib_offset;
                *size_known = FALSE;
                return( result );
        }
    }
    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, "]" );
    result = sib_offset;
    *size_known = TRUE;
    return( result );
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %r8d, %r12d
movq %rcx, %r14
movq %rdx, %r15
movl %esi, %ebx
movq 0x90(%rsp), %r13
movb $0x0, 0x20(%rsp)
cmpb $0x6, %r12b
sete %cl
movl 0x11b0b(%rip), %eax     # 0x1be88
testl %eax, %eax
setne %dl
sete %sil
andb %cl, %sil
cmpb $0x5, %r12b
sete %cl
andb %dl, %cl
orb %sil, %cl
cmpb $0x1, %cl
jne 0xa523
movl %r9d, %ebp
movl 0xe6e1(%rip), %eax      # 0x18a88
leal 0x11(%rax), %ecx
cmpl $-0x1, %eax
pushq $0x14
popq %r13
cmovnel %ecx, %r13d
leal 0x2(%rbx), %edi
callq 0xc74e
cmpl $0x3, %eax
ja 0xa515
pushq $-0x1
popq %r12
movl %eax, %eax
leaq 0x7c51(%rip), %rcx      # 0x12024
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl 0x11aa2(%rip), %esi     # 0x1be84
leaq 0x8(%rsp), %rdi
callq 0x9461
testl %eax, %eax
jne 0xa581
leaq 0x11b01(%rip), %rax     # 0x1befc
cmpl $0x0, (%rax)
movq 0x8(%rsp), %rbp
je 0xa593
pushq $0x53
popq %rcx
xorl %edi, %edi
xorl %esi, %esi
movq %rbp, %rdx
callq 0xf360
testq %rax, %rax
je 0xa593
movq %rax, %r12
subq 0x8(%rax), %rbp
movq %rbp, 0x8(%rsp)
movq 0x48(%rax), %rsi
testq %rsi, %rsi
movq 0x90(%rsp), %r13
je 0xa453
leaq 0x20(%rsp), %rdi
leaq 0x8(%rsp), %r15
movq %r15, %rdx
callq 0xf662
movq (%r15), %rbp
testq %rbp, %rbp
je 0xa62b
movl 0xe62a(%rip), %edx      # 0x18a8c
leaq 0x10(%rsp), %r15
movq %rbp, %rdi
movq %r15, %rsi
callq 0xc5b5
addq $0x10, %r12
leaq 0x7ec1(%rip), %rsi      # 0x1233e
leaq 0x20(%rsp), %rcx
movq %r14, %rdi
movq %r12, %rdx
movq %r15, %r8
xorl %eax, %eax
callq 0x91b0
jmp 0xa648
leaq 0x11c7a(%rip), %rax     # 0x1c118
movq (%rax), %rax
cmpl $0x0, 0x3c(%rax)
je 0xa581
movl 0x38(%rax), %eax
cmpl 0x119d4(%rip), %eax     # 0x1be88
jne 0xa581
movl 0xe5cc(%rip), %ecx      # 0x18a8c
pushq $0x1
popq %r9
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
movl %ebp, %r8d
pushq %r13
pushq 0x98(%rsp)
callq 0xfad9
popq %rcx
popq %rdx
cmpb $0x0, (%r15)
je 0xa50d
movq %r14, %rdi
callq 0x90b0
movw $0x5b, (%r14,%rax)
movq %r14, %rdi
movq %r15, %rsi
callq 0x91a0
movq %r14, %rdi
callq 0x90b0
movw $0x5d, (%r14,%rax)
addl 0xe57d(%rip), %ebx      # 0x18a90
jmp 0xa57e
movl 0x1196d(%rip), %eax     # 0x1be88
movq 0x90(%rsp), %r13
testl %eax, %eax
leaq 0xde04(%rip), %rax      # 0x18330
leaq 0xde3d(%rip), %rcx      # 0x18370
cmoveq %rax, %rcx
movzbl %r12b, %eax
movq (%rcx,%rax,8), %rsi
movq %r14, %rdi
callq 0x9070
cmpb $0x0, (%r15)
je 0xa567
movq %r14, %rdi
callq 0x90b0
movw $0x2b, (%r14,%rax)
movq %r14, %rdi
movq %r15, %rsi
callq 0x91a0
movq %r14, %rdi
callq 0x90b0
movw $0x5d, (%r14,%rax)
movl $0x1, (%r13)
movl %ebx, %r12d
movl %r12d, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0xe4f3(%rip), %edx      # 0x18a8c
leaq 0x10(%rsp), %rsi
movq %rbp, %rdi
callq 0xc5b5
leaq 0x1194b(%rip), %rax     # 0x1bef8
cmpl $0x2, (%rax)
movq 0x90(%rsp), %r13
jne 0xa5d2
leaq 0x7ce8(%rip), %rsi      # 0x122a9
leaq 0x10(%rsp), %rdx
movq %r14, %rdi
xorl %eax, %eax
callq 0x91b0
jmp 0xa648
cmpl $-0x1, 0xe4af(%rip)     # 0x18a88
leaq 0x7d68(%rip), %rax      # 0x12348
leaq 0x7d64(%rip), %rsi      # 0x1234b
cmoveq %rax, %rsi
leaq 0x10(%rsp), %rdx
movq %r14, %rdi
xorl %eax, %eax
callq 0x91b0
cmpb $0x0, (%r15)
je 0xa61a
movq %r14, %rdi
callq 0x90b0
movw $0x2b, (%r14,%rax)
movq %r14, %rdi
movq %r15, %rsi
callq 0x91a0
movq %r14, %rdi
callq 0x90b0
movw $0x5d, (%r14,%rax)
jmp 0xa648
addq $0x10, %r12
leaq 0x8e15(%rip), %rsi      # 0x1344b
leaq 0x20(%rsp), %rcx
movq %r14, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x91b0
addl 0xe442(%rip), %ebx      # 0x18a90
andl $0x0, (%r13)
jmp 0xa57e