// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x70, %rsp
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movl %edx, -0xc(%rbp)
movl %ecx, -0x10(%rbp)
movl %r8d, -0x14(%rbp)
movl $0x0, -0x4c(%rbp)
callq 0x11ad0
movzbl %al, %eax
movl %eax, -0x1c(%rbp)
movl $0x1, -0x18(%rbp)
movl -0x1c(%rbp), %eax
andl $0x80, %eax
sarl $0x7, %eax
movl %eax, -0x34(%rbp)
movl -0x1c(%rbp), %eax
andl $0x70, %eax
sarl $0x4, %eax
movl %eax, -0x24(%rbp)
cmpl $0x1, -0x34(%rbp)
jne 0x14cc0
movl -0x24(%rbp), %eax
andl $0x3, %eax
movl %eax, -0x20(%rbp)
movslq -0x20(%rbp), %rcx
leaq 0xb3cb(%rip), %rax      # 0x20070
movl 0x24(%rax,%rcx,8), %eax
movl %eax, -0x28(%rbp)
movslq -0x20(%rbp), %rcx
leaq 0xb3b9(%rip), %rax      # 0x20070
movl 0x20(%rax,%rcx,8), %eax
movl %eax, -0x24(%rbp)
jmp 0x14cd8
cmpl $0x4, -0x24(%rbp)
jge 0x14cd6
leaq -0x28(%rbp), %rdi
callq 0x11c80
cwtl
addl -0x18(%rbp), %eax
movl %eax, -0x18(%rbp)
jmp 0x14cd8
movl -0x1c(%rbp), %eax
andl $0x8, %eax
sarl $0x3, %eax
movl %eax, -0x38(%rbp)
movl -0x1c(%rbp), %eax
andl $0x7, %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
andl $0x4, %eax
sarl $0x2, %eax
movl %eax, -0x3c(%rbp)
movl -0x20(%rbp), %eax
andl $0x3, %eax
movl %eax, -0x2c(%rbp)
cmpl $0x1, -0x38(%rbp)
jne 0x14d30
movslq -0x2c(%rbp), %rcx
leaq 0xb35d(%rip), %rax      # 0x20070
movl 0x4(%rax,%rcx,8), %eax
movl %eax, -0x30(%rbp)
movslq -0x2c(%rbp), %rcx
leaq 0xb34b(%rip), %rax      # 0x20070
movl (%rax,%rcx,8), %eax
andl $0x3, %eax
movl %eax, -0x2c(%rbp)
jmp 0x14d40
leaq -0x30(%rbp), %rdi
callq 0x11c80
cwtl
addl -0x18(%rbp), %eax
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x8(%rbp)
je 0x14d53
cmpl $0x0, -0x14(%rbp)
je 0x14d53
movl $0x1, -0x4c(%rbp)
cmpl $0x0, -0x3c(%rbp)
jne 0x14da8
callq 0x11b20
movswq %ax, %rax
movq %rax, -0x48(%rbp)
movl -0x18(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x4c(%rbp)
je 0x14da6
callq 0x11ad0
movzbl %al, %eax
shlq $0x10, %rax
addq -0x48(%rbp), %rax
movq %rax, -0x48(%rbp)
callq 0x11ad0
movzbl %al, %eax
shlq $0x18, %rax
addq -0x48(%rbp), %rax
movq %rax, -0x48(%rbp)
movl -0x18(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x18(%rbp)
jmp 0x14db0
movq $0x0, -0x48(%rbp)
cmpl $0x5, -0x24(%rbp)
jne 0x14dc2
movl -0x2c(%rbp), %eax
movl %eax, -0x24(%rbp)
movl -0x30(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0x10(%rbp), %edi
movl -0x4(%rbp), %esi
movl -0xc(%rbp), %edx
movq -0x48(%rbp), %rcx
movl -0x24(%rbp), %r8d
movl -0x28(%rbp), %r9d
movl -0x2c(%rbp), %r11d
movl -0x30(%rbp), %r10d
movl -0x4c(%rbp), %eax
movl %r11d, (%rsp)
movl %r10d, 0x8(%rsp)
movl %eax, 0x10(%rsp)
callq 0x14b40
movl -0x18(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)