// File: /workspace/github_c_makefile_star2_O3/Nico01[P]obj2asm/odisasm.c
// Function: disp16
int disp16( byte, text, class )
    uchar   byte;
    char            *text;
    int             class;
{
    dword   offset;
    dword   dest;
    int             dummy;
#if 0
    int             bad_size;
#endif
    char            line[60];
    char            *short_text;
    PUB_T           *pub_rec;
    int             data_size;

    byte = byte;               /* Prevent unused variable warnings */
    class=class;              /* Prevent unused variable warnings */

    data_size = addr_bytes;

    if ( over_seg != -1 )               /* No segment overide allowed */
        return( 0 );

    switch( data_check( 1 ) ) {
    case BAD:
         return( 0 );
    case LABEL:
         return( 0 );
    case FIXUP:
         if ( fix_rec->word_sized && fix_rec->extended == addr_large
                                  && fix_rec->relate == 0 ) {
             get_fix( line, 1, FALSE, size_bytes, NEAR, TRUE, &dummy, CS );
             adjust_assumes();
             instr_opcode( text );
             instr_operand( line );
             return( 1 + data_size );
         } else {
             return( 0 );
         }
    case NORMAL:
         if ( check_getv( &offset, addr_large ) ) {
             return( 0 );
         }
         /* note: the next if actually checks for 1 byte too far in
         ** the negative direction. but this is ok, because it would be
         ** replaced by a short jmp
         */
         if ( offset < 0x80 || offset >= 0xFFFFFF7FL ) {
#if 0
             bad_size = TRUE;
#endif
             short_text = "near ptr ";
         } else {
             short_text = "";
#if 0
             bad_size = FALSE;
#endif
         }

         dest = inst_offset + offset + addr_bytes + 1;
         pub_rec = check_public( 1, segment, dest, 'L' );

         if ( pub_rec ) {
             offset = dest - pub_rec->offset;
             if ( offset > 0L ) {
                 if ( addr_large ) {
                     sprintf( line, "%s%s + 0%08lXh", short_text,
                              pub_rec->name, offset );
                 } else {
                     sprintf( line, "%s%s + 0%04lXh", short_text,
                              pub_rec->name, offset );
                 }
             } else {
                 sprintf( line, "%s%s", short_text, pub_rec->name );
             }
         } else {
             if ( compatibility == 2 ) {
                 if ( addr_large ) {
                     sprintf( line, "%s .0%08lXh", short_text, offset );
                 } else {
                     sprintf( line, "%s .0%04lXh", short_text, offset );
                 }
             } else {
                 if ( addr_large ) {
                     sprintf( line, "%s[%s:0%08lXh]", short_text,
                              cseg_name, offset );
                 } else {
                     sprintf( line, "%s[%s:0%04lXh]", short_text,
                              cseg_name, offset );
                 }
             }
         }

         instr_opcode( text );
         instr_operand( line );
#if 0
         if ( bad_size ) {
             if ( pass == 3 ) {
                 out_comment( "Large jump translated into short" );
             }
             instr_opcode( "nop" );
             if ( pass == 3 ) {
                 out_comment( "Nop inserted to retain proper length" );
             }
         }
#endif
         return( 1 + data_size );
    }
    return(0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
xorl %ebp, %ebp
cmpl $-0x1, 0xf506(%rip)     # 0x19a88
je 0xa595
movl %ebp, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rsi, %rbx
movl 0xf4f1(%rip), %r13d     # 0x19a90
movl $0x1, %edi
callq 0xcd14
testl %eax, %eax
je 0xa60c
cmpl $0x2, %eax
jne 0xa584
leaq 0x12b5f(%rip), %rax     # 0x1d118
movq (%rax), %rax
cmpl $0x0, 0x3c(%rax)
je 0xa584
movl 0x38(%rax), %ecx
cmpl 0x128bd(%rip), %ecx     # 0x1ce88
jne 0xa584
cmpl $0x0, 0x14(%rax)
jne 0xa584
movl 0xf4b3(%rip), %ecx      # 0x19a8c
leaq 0x8(%rsp), %rax
leaq 0x10(%rsp), %rdi
movl $0x1, %esi
xorl %edx, %edx
movl $0x1, %r8d
movl $0x1, %r9d
pushq $0x12
pushq %rax
callq 0x1027f
addq $0x10, %rsp
callq 0xf955
jmp 0xa74f
cmpl $0x0, 0x12875(%rip)     # 0x1ce88
je 0xa621
leaq 0x8(%rsp), %rdi
callq 0x971c
jmp 0xa62b
leaq 0x8(%rsp), %rdi
callq 0x96e5
testl %eax, %eax
jne 0xa584
movq 0x8(%rsp), %r15
movabsq $-0xffffff7f, %rax      # imm = 0xFFFFFFFF00000081
leaq (%r15,%rax), %rcx
subq $-0x80, %rax
cmpq %rax, %rcx
leaq 0x8caa(%rip), %rax      # 0x132fe
leaq 0x9ab1(%rip), %r14      # 0x1410c
cmovbq %rax, %r14
leaq 0x12b32(%rip), %rax     # 0x1d198
movslq 0xf423(%rip), %rcx      # 0x19a90
movq (%rax), %rax
addq %r15, %rax
leaq (%rcx,%rax), %r12
incq %r12
leaq 0x12b0f(%rip), %rax     # 0x1d190
movl (%rax), %esi
movl $0x1, %edi
movq %r12, %rdx
movl $0x4c, %ecx
callq 0xfafa
testq %rax, %rax
je 0xa6b8
subq 0x8(%rax), %r12
jne 0xa6d7
addq $0x10, %rax
leaq 0x9da0(%rip), %rsi      # 0x1444b
leaq 0x10(%rsp), %rdi
movq %r14, %rdx
movq %rax, %rcx
jmp 0xa72d
leaq 0x12839(%rip), %rax     # 0x1cef8
cmpl $0x2, (%rax)
movl 0x127c0(%rip), %eax     # 0x1ce88
jne 0xa6ed
testl %eax, %eax
je 0xa71b
leaq 0x8c42(%rip), %rsi      # 0x13317
jmp 0xa722
addq $0x10, %rax
cmpl $0x0, 0x127a6(%rip)     # 0x1ce88
je 0xa704
leaq 0x8c1d(%rip), %rsi      # 0x13308
jmp 0xa70b
leaq 0x12ab4(%rip), %rcx     # 0x1d1a8
movq (%rcx), %rcx
testl %eax, %eax
je 0xa736
leaq 0x8c2d(%rip), %rsi      # 0x1332f
jmp 0xa73d
leaq 0x8bc9(%rip), %rsi      # 0x132d4
leaq 0x10(%rsp), %rdi
movq %r14, %rdx
movq %rax, %rcx
movq %r12, %r8
jmp 0xa748
leaq 0x8c01(%rip), %rsi      # 0x13323
leaq 0x10(%rsp), %rdi
movq %r14, %rdx
movq %r15, %rcx
xorl %eax, %eax
callq 0x91b0
jmp 0xa74f
leaq 0x8bb2(%rip), %rsi      # 0x132ef
leaq 0x10(%rsp), %rdi
movq %r14, %rdx
movq %r15, %r8
xorl %eax, %eax
callq 0x91b0
movq %rbx, %rdi
callq 0x97c1
leaq 0x1280a(%rip), %rax     # 0x1cf68
cmpl $0x3, (%rax)
jne 0xa76d
leaq 0x10(%rsp), %rdi
callq 0xca45
incl %r13d
movl %r13d, %ebp
jmp 0xa584