// File: /workspace/github_c_makefile_star2_O2/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, 0xe93c(%rip)     # 0x18a88
je 0xa15f
movl %ebp, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rsi, %rbx
movl 0xe927(%rip), %r13d     # 0x18a90
pushq $0x1
popq %rdi
callq 0xc74e
testl %eax, %eax
je 0xa1ca
cmpl $0x2, %eax
jne 0xa14e
leaq 0x11f97(%rip), %rax     # 0x1c118
movq (%rax), %rax
cmpl $0x0, 0x3c(%rax)
je 0xa14e
movl 0x38(%rax), %ecx
cmpl 0x11cf5(%rip), %ecx     # 0x1be88
jne 0xa14e
cmpl $0x0, 0x14(%rax)
jne 0xa14e
movl 0xe8eb(%rip), %ecx      # 0x18a8c
leaq 0x8(%rsp), %rax
leaq 0x10(%rsp), %rdi
pushq $0x1
popq %rsi
xorl %edx, %edx
movl %esi, %r8d
movl %esi, %r9d
pushq $0x12
pushq %rax
callq 0xfad9
popq %rcx
popq %rdx
callq 0xf1c1
jmp 0xa2fa
movl 0x11cb8(%rip), %esi     # 0x1be88
leaq 0x8(%rsp), %rdi
callq 0x9461
testl %eax, %eax
jne 0xa14e
movq 0x8(%rsp), %r15
movabsq $-0xffffff7f, %rax      # imm = 0xFFFFFFFF00000081
leaq (%r15,%rax), %rcx
subq $-0x80, %rax
cmpq %rax, %rcx
leaq 0x80fb(%rip), %rax      # 0x122fe
leaq 0x8f02(%rip), %r14      # 0x1310c
cmovbq %rax, %r14
leaq 0x11f83(%rip), %rax     # 0x1c198
movslq 0xe874(%rip), %rcx      # 0x18a90
movq (%rax), %rax
addq %r15, %rax
leaq (%rcx,%rax), %r12
incq %r12
leaq 0x11f60(%rip), %rax     # 0x1c190
movl (%rax), %esi
pushq $0x1
popq %rdi
pushq $0x4c
popq %rcx
movq %r12, %rdx
callq 0xf360
testq %rax, %rax
je 0xa263
subq 0x8(%rax), %r12
jne 0xa282
addq $0x10, %rax
leaq 0x91f5(%rip), %rsi      # 0x1344b
leaq 0x10(%rsp), %rdi
movq %r14, %rdx
movq %rax, %rcx
jmp 0xa2d8
leaq 0x11c8e(%rip), %rax     # 0x1bef8
cmpl $0x2, (%rax)
movl 0x11c15(%rip), %eax     # 0x1be88
jne 0xa298
testl %eax, %eax
je 0xa2c6
leaq 0x8097(%rip), %rsi      # 0x12317
jmp 0xa2cd
addq $0x10, %rax
cmpl $0x0, 0x11bfb(%rip)     # 0x1be88
je 0xa2af
leaq 0x8072(%rip), %rsi      # 0x12308
jmp 0xa2b6
leaq 0x11f09(%rip), %rcx     # 0x1c1a8
movq (%rcx), %rcx
testl %eax, %eax
je 0xa2e1
leaq 0x8082(%rip), %rsi      # 0x1232f
jmp 0xa2e8
leaq 0x801e(%rip), %rsi      # 0x122d4
leaq 0x10(%rsp), %rdi
movq %r14, %rdx
movq %rax, %rcx
movq %r12, %r8
jmp 0xa2f3
leaq 0x8056(%rip), %rsi      # 0x12323
leaq 0x10(%rsp), %rdi
movq %r14, %rdx
movq %r15, %rcx
xorl %eax, %eax
callq 0x91b0
jmp 0xa2fa
leaq 0x8007(%rip), %rsi      # 0x122ef
leaq 0x10(%rsp), %rdi
movq %r14, %rdx
movq %r15, %r8
xorl %eax, %eax
callq 0x91b0
movq %rbx, %rdi
callq 0x9491
leaq 0x10(%rsp), %rdi
callq 0x94b3
incl %r13d
movl %r13d, %ebp
jmp 0xa14e