// File: /workspace/github_c_makefile_star2_O3/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 0x126bc(%rip), %eax     # 0x1ce88
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 0xa8db
movl %r9d, %ebp
movl 0xf292(%rip), %eax      # 0x19a88
leal 0x11(%rax), %ecx
cmpl $-0x1, %eax
movl $0x14, %r13d
cmovnel %ecx, %r13d
leal 0x2(%rbx), %edi
callq 0xcd14
cmpl $0x3, %eax
ja 0xa8cd
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
movl %eax, %eax
leaq 0x87fe(%rip), %rcx      # 0x13024
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpl $0x0, 0x1264e(%rip)     # 0x1ce84
je 0xa94b
leaq 0x8(%rsp), %rdi
callq 0x971c
jmp 0xa955
leaq 0x128c6(%rip), %rax     # 0x1d118
movq (%rax), %rax
cmpl $0x0, 0x3c(%rax)
je 0xa939
movl 0x38(%rax), %eax
cmpl 0x12620(%rip), %eax     # 0x1ce88
jne 0xa939
movl 0xf218(%rip), %ecx      # 0x19a8c
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
movl %ebp, %r8d
movl $0x1, %r9d
pushq %r13
pushq 0x98(%rsp)
callq 0x1027f
addq $0x10, %rsp
cmpb $0x0, (%r15)
je 0xa8c5
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 0xf1c5(%rip), %ebx      # 0x19a90
jmp 0xa936
movl 0x125b5(%rip), %eax     # 0x1ce88
movq 0x90(%rsp), %r13
testl %eax, %eax
leaq 0xea4c(%rip), %rax      # 0x19330
leaq 0xea85(%rip), %rcx      # 0x19370
cmoveq %rax, %rcx
movzbl %r12b, %eax
movq (%rcx,%rax,8), %rsi
movq %r14, %rdi
callq 0x9070
cmpb $0x0, (%r15)
je 0xa91f
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
leaq 0x8(%rsp), %rdi
callq 0x96e5
testl %eax, %eax
jne 0xa939
leaq 0x1259c(%rip), %rax     # 0x1cefc
cmpl $0x0, (%rax)
movq 0x8(%rsp), %rbp
je 0xa9fa
xorl %edi, %edi
xorl %esi, %esi
movq %rbp, %rdx
movl $0x53, %ecx
callq 0xfafa
testq %rax, %rax
je 0xa9fa
movq %rax, %r12
subq 0x8(%rax), %rbp
movq %rbp, 0x8(%rsp)
movq 0x48(%rax), %rsi
testq %rsi, %rsi
movq 0x90(%rsp), %r13
je 0xa9b6
leaq 0x20(%rsp), %rdi
leaq 0x8(%rsp), %r15
movq %r15, %rdx
callq 0xfdfe
movq (%r15), %rbp
testq %rbp, %rbp
je 0xaa92
movl 0xf0c7(%rip), %edx      # 0x19a8c
leaq 0x10(%rsp), %r15
movq %rbp, %rdi
movq %r15, %rsi
callq 0xcb74
addq $0x10, %r12
leaq 0x895e(%rip), %rsi      # 0x1333e
leaq 0x20(%rsp), %rcx
movq %r14, %rdi
movq %r12, %rdx
movq %r15, %r8
xorl %eax, %eax
callq 0x91b0
jmp 0xaaaf
movl 0xf08c(%rip), %edx      # 0x19a8c
leaq 0x10(%rsp), %rsi
movq %rbp, %rdi
callq 0xcb74
leaq 0x124e4(%rip), %rax     # 0x1cef8
cmpl $0x2, (%rax)
movq 0x90(%rsp), %r13
jne 0xaa39
leaq 0x8881(%rip), %rsi      # 0x132a9
leaq 0x10(%rsp), %rdx
movq %r14, %rdi
xorl %eax, %eax
callq 0x91b0
jmp 0xaaaf
cmpl $-0x1, 0xf048(%rip)     # 0x19a88
leaq 0x8901(%rip), %rax      # 0x13348
leaq 0x88fd(%rip), %rsi      # 0x1334b
cmoveq %rax, %rsi
leaq 0x10(%rsp), %rdx
movq %r14, %rdi
xorl %eax, %eax
callq 0x91b0
cmpb $0x0, (%r15)
je 0xaa81
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 0xaaaf
addq $0x10, %r12
leaq 0x99ae(%rip), %rsi      # 0x1444b
leaq 0x20(%rsp), %rcx
movq %r14, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x91b0
addl 0xefdb(%rip), %ebx      # 0x19a90
movl $0x0, (%r13)
jmp 0xa936