// File: /workspace/github_c_makefile_star2_O1/Nico01[P]obj2asm/rec_fixupp.c
// Function: decode_fixup
int decode_fixup( relate, size, form, offset, extension )
    int             relate;                 /* mode 0=self rel, 1=segment rel */
    int             size;                   /* zero */
    int             form;                   /* LOC value [0-4] */
    int             offset;                 /* offset of data item */
    int             extension;
{
    int             length;
    int             fix;
    int             thread;
    int             a_mode;                 /* Mode of Frame   */
    int             a_index;                /* Index of Frame  */
    int             b_mode;                 /* Mode of Target  */
    int             b_index;                /* Index of Target */
    int             fbit;
    int             tbit;
    int             pbit;
    dword   displacement;
    int             extended;

    extended = FALSE;

    fix = get_byte();

    length = 1;
    fbit   = ( fix & 0x80 ) >> 7;   /* F-bit field */
    a_mode = ( fix & 0x70 ) >> 4;   /* frame index */
    if ( fbit == 1 ) {
        /* Reference a previously loaded thread fixup for location */
        thread = ( a_mode & 0x03 );
        a_index = threads[1][thread].index; /* mode is a thread # */
        a_mode  = threads[1][thread].mode;
    } else {
        /* otherwise, frame is explicitly specified */
        if ( a_mode < 4 ) {                 /* mode is not a thread # */
            length += get_index( &a_index );
        }
    }
    tbit   = ( fix & 0x08 ) >> 3;       /* T-bit field */
    thread = ( fix & 0x07 );
    pbit   = ( thread & 0x04 ) >> 2;    /* P-bit field */
    b_mode = ( thread & 0x03 );         /* Target mode */
    if ( tbit == 1 ) {
        b_index = threads[0][b_mode].index; /* mode is a thread # */
        b_mode  = threads[0][b_mode].mode & 0x03;
    } else {
        length += get_index( &b_index );    /* mode is not a thread # */
    }

    if ( size != 0 && extension ) { /* size is always 0 for 16bit MS langs */
        extended = TRUE;
    }

    if ( pbit == 0 ) {
        displacement = (dword)get_int();
        length += 2;
        if ( extended ) {
            displacement += (dword)get_byte() << 16;
            displacement += (dword)get_byte() << 24;
            length += 2;
        }
    } else {
        displacement = 0L;
    }

    if ( a_mode == 5 ) {    /* don't process this type of fixupp */
        a_mode = b_mode;
        a_index = b_index;
    }

    fix_insert( offset, relate, form, displacement, a_mode, a_index,
                                                b_mode, b_index, extended );
    return( length );
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %r8d, 0x8(%rsp)
movl %ecx, 0x10(%rsp)
movl %edx, 0x14(%rsp)
movl %esi, %ebp
movl %edi, 0xc(%rsp)
callq 0xf478
movl %eax, %ebx
movzbl %al, %r13d
movl %r13d, %r15d
shrl $0x4, %r15d
testb %r13b, %r13b
js 0x112c7
andl $0x7, %r15d
movl $0x1, %r12d
cmpl $0x3, %r15d
ja 0x112e9
leaq 0x4(%rsp), %rdi
callq 0xf55d
movswl %ax, %r12d
incl %r12d
jmp 0x112e9
andl $0x3, %r15d
leaq 0xbbce(%rip), %rax      # 0x1cea0
movl 0x24(%rax,%r15,8), %ecx
movl 0x20(%rax,%r15,8), %eax
movl %ecx, 0x4(%rsp)
movl $0x1, %r12d
movl %eax, %r15d
movl %r13d, %r14d
andl $0x3, %r14d
testb $0x8, %r13b
jne 0x11304
movq %rsp, %rdi
callq 0xf55d
cwtl
addl %eax, %r12d
jmp 0x1131d
movl %r14d, %eax
leaq 0xbb92(%rip), %rcx      # 0x1cea0
movl (%rcx,%rax,8), %r14d
movl 0x4(%rcx,%rax,8), %eax
movl %eax, (%rsp)
andl $0x3, %r14d
testl %ebp, %ebp
setne %al
cmpl $0x0, 0x8(%rsp)
setne %bpl
andb %al, %bpl
testb $0x4, %bl
jne 0x11365
callq 0xf494
movswq %ax, %rbx
testb %bpl, %bpl
je 0x11369
callq 0xf478
movzbl %al, %r13d
shll $0x10, %r13d
addq %rbx, %r13
callq 0xf478
movzbl %al, %ebx
shll $0x18, %ebx
addq %r13, %rbx
addl $0x4, %r12d
jmp 0x1136d
xorl %ebx, %ebx
jmp 0x1136d
addl $0x2, %r12d
cmpl $0x5, %r15d
jne 0x1137d
movl (%rsp), %eax
movl %eax, 0x4(%rsp)
movl %r14d, %r15d
movzbl %bpl, %eax
movl 0x4(%rsp), %r9d
movl (%rsp), %r10d
subq $0x8, %rsp
movl 0x18(%rsp), %edi
movl 0x14(%rsp), %esi
movl 0x1c(%rsp), %edx
movq %rbx, %rcx
movl %r15d, %r8d
pushq %rax
pushq %r10
pushq %r14
callq 0x111ab
addq $0x20, %rsp
movl %r12d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq