// File: /workspace/github_c_makefile_star2_O1/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
movb $0x0, 0x20(%rsp)
cmpb $0x6, %r12b
sete %al
cmpl $0x0, 0x126ca(%rip)     # 0x1ce88
setne %cl
sete %dl
andb %al, %dl
cmpb $0x5, %r12b
sete %al
andb %cl, %al
orb %dl, %al
cmpb $0x1, %al
jne 0xa82f
movl %r9d, %ebp
movl 0xf2aa(%rip), %eax      # 0x19a88
leal 0x11(%rax), %ecx
cmpl $-0x1, %eax
movl $0x14, %r13d
cmovnel %ecx, %r13d
leal 0x2(%rbx), %edi
callq 0xcca8
cmpl $0x3, %eax
ja 0xa82f
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
movl %eax, %eax
leaq 0x881a(%rip), %rcx      # 0x13024
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpl $0x0, 0x1266a(%rip)     # 0x1ce84
je 0xa927
leaq 0x8(%rsp), %rdi
callq 0x971c
jmp 0xa931
cmpl $0x0, 0x12652(%rip)     # 0x1ce88
leaq 0xeaf3(%rip), %rax      # 0x19330
leaq 0xeb2c(%rip), %rcx      # 0x19370
cmoveq %rax, %rcx
movzbl %r12b, %eax
movq (%rcx,%rax,8), %rsi
movq %r14, %rdi
callq 0x9070
cmpb $0x0, (%r15)
je 0xa878
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)
movq 0x90(%rsp), %rax
movl $0x1, (%rax)
movl %ebx, %r12d
movl %r12d, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x12867(%rip), %rax     # 0x1d118
movq (%rax), %rax
cmpl $0x0, 0x3c(%rax)
je 0xa898
movl 0x38(%rax), %eax
cmpl 0x125c5(%rip), %eax     # 0x1ce88
jne 0xa898
movl 0xf1c1(%rip), %ecx      # 0x19a8c
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
movl %ebp, %r8d
movl $0x1, %r9d
pushq %r13
pushq 0x98(%rsp)
callq 0x10207
addq $0x10, %rsp
cmpb $0x0, (%r15)
je 0xa91c
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 0xf16e(%rip), %ebx      # 0x19a90
jmp 0xa895
leaq 0x8(%rsp), %rdi
callq 0x96e5
testl %eax, %eax
jne 0xa898
leaq 0x125bc(%rip), %rax     # 0x1cefc
cmpl $0x0, (%rax)
je 0xa95d
movq 0x8(%rsp), %rdx
xorl %edi, %edi
xorl %esi, %esi
movl $0x53, %ecx
callq 0xfad5
movq %rax, %r12
jmp 0xa960
xorl %r12d, %r12d
testq %r12, %r12
je 0xa9ca
movq 0x8(%r12), %rax
subq %rax, 0x8(%rsp)
movq 0x48(%r12), %rsi
testq %rsi, %rsi
je 0xa988
leaq 0x20(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0xfdd9
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0xaa03
movl 0xf0f4(%rip), %edx      # 0x19a8c
leaq 0x10(%rsp), %r15
movq %r15, %rsi
callq 0xcb08
addq $0x10, %r12
leaq 0x898e(%rip), %rsi      # 0x1333e
leaq 0x20(%rsp), %rcx
movq %r14, %rdi
movq %r12, %rdx
movq %r15, %r8
xorl %eax, %eax
callq 0x91b0
jmp 0xaa79
movq 0x8(%rsp), %rdi
movl 0xf0b7(%rip), %edx      # 0x19a8c
leaq 0x10(%rsp), %rsi
callq 0xcb08
leaq 0x12512(%rip), %rax     # 0x1cef8
cmpl $0x2, (%rax)
jne 0xaa22
leaq 0x88b7(%rip), %rsi      # 0x132a9
leaq 0x10(%rsp), %rdx
movq %r14, %rdi
xorl %eax, %eax
callq 0x91b0
jmp 0xaa79
addq $0x10, %r12
leaq 0x9a3d(%rip), %rsi      # 0x1444b
leaq 0x20(%rsp), %rcx
movq %r14, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x91b0
jmp 0xaa79
cmpl $-0x1, 0xf05f(%rip)     # 0x19a88
leaq 0x8918(%rip), %rax      # 0x13348
leaq 0x8914(%rip), %rsi      # 0x1334b
cmoveq %rax, %rsi
leaq 0x10(%rsp), %rdx
movq %r14, %rdi
xorl %eax, %eax
callq 0x91b0
cmpb $0x0, (%r15)
je 0xaa6a
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)
addl 0xf011(%rip), %ebx      # 0x19a90
movq 0x90(%rsp), %rax
movl $0x0, (%rax)
jmp 0xa895