// File: /workspace/github_c_makefile_star2_O0/AK6DN[P]dec-utilities-for-pdp/palbart/palbart.c
// Function: fixMRIInstruction
WORD16 fixMRIInstruction(WORD16 instruction, WORD16 value)
{
        /* Now have the address part of the MRI instruction.                  */
        if( value < 00200 )
        {
          instruction |= value;        /* Page zero MRI.                             */
        }
        else if( (( fieldlc + reloc ) & 07600 ) <= value
             && value <= ((( fieldlc + reloc ) & 07600) | 0177 ))
        {
          instruction |= ( PAGE_BIT | (value & ADDRESS_FIELD )); /* Current page MRI */
        }
        else
        {
          if(( instruction & INDIRECT_BIT ) == INDIRECT_BIT )
          {
            /* Already indirect, can't generate                               */
            errorSymbol( &illegal_indirect, NULL, lexstartprev );
          }
          else
          {
            if( literals_ok )
            {
              /* Now fix off page reference.                                  */
              /* Search current page literal pool for needed instruction.           */
              /* Set Indirect Current Page                                    */
              instruction |= ( 00600 | insertLiteral( cp, value, GET_PAGE_INDEX(clc) ));
              indirect_generated = TRUE;
              if (pass == 2)
              {
                links++;
              }
            }
            else
            {
              errorSymbol( &illegal_reference, NULL, lexstartprev );
              instruction |= ( value & 0177 );
            }
          }
        }
   return instruction;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movw %si, %ax
movw %di, %cx
movw %cx, -0x2(%rbp)
movw %ax, -0x4(%rbp)
movswl -0x4(%rbp), %eax
cmpl $0x80, %eax
jge 0x67f4
movswl -0x4(%rbp), %ecx
movswl -0x2(%rbp), %eax
orl %ecx, %eax
movw %ax, -0x2(%rbp)
jmp 0x6906
movswl 0x8fc9(%rip), %eax      # 0xf7c4
movswl 0x8fc4(%rip), %ecx      # 0xf7c6
addl %ecx, %eax
andl $0xf80, %eax            # imm = 0xF80
movswl -0x4(%rbp), %ecx
cmpl %ecx, %eax
jg 0x684e
movswl -0x4(%rbp), %eax
movswl 0x8fa8(%rip), %ecx      # 0xf7c4
movswl 0x8fa3(%rip), %edx      # 0xf7c6
addl %edx, %ecx
andl $0xf80, %ecx            # imm = 0xF80
orl $0x7f, %ecx
cmpl %ecx, %eax
jg 0x684e
movswl -0x4(%rbp), %ecx
andl $0x7f, %ecx
orl $0x80, %ecx
movswl -0x2(%rbp), %eax
orl %ecx, %eax
movw %ax, -0x2(%rbp)
jmp 0x6904
movswl -0x2(%rbp), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x100, %eax            # imm = 0x100
jne 0x6879
movl 0x9020(%rip), %edx      # 0xf884
leaq 0x692d(%rip), %rdi      # 0xd198
xorl %eax, %eax
movl %eax, %esi
callq 0x5030
jmp 0x6902
cmpb $0x0, 0x6b2a(%rip)      # 0xd3aa
je 0x68d9
movw -0x4(%rbp), %ax
movswl 0x8f33(%rip), %edx      # 0xf7c0
andl $0xf80, %edx            # imm = 0xF80
sarl $0x7, %edx
leaq 0x6e23(%rip), %rdi      # 0xd6c0
movswl %ax, %esi
callq 0x6910
movswl %ax, %ecx
orl $0x180, %ecx            # imm = 0x180
movswl -0x2(%rbp), %eax
orl %ecx, %eax
movw %ax, -0x2(%rbp)
movb $0x1, 0x8fc9(%rip)      # 0xf888
cmpl $0x2, 0x6b8a(%rip)      # 0xd450
jne 0x68d7
movl 0x6cea(%rip), %eax      # 0xd5b8
addl $0x1, %eax
movl %eax, 0x6ce1(%rip)      # 0xd5b8
jmp 0x6900
movl 0x8fa5(%rip), %edx      # 0xf884
leaq 0x68c2(%rip), %rdi      # 0xd1a8
xorl %eax, %eax
movl %eax, %esi
callq 0x5030
movswl -0x4(%rbp), %ecx
andl $0x7f, %ecx
movswl -0x2(%rbp), %eax
orl %ecx, %eax
movw %ax, -0x2(%rbp)
jmp 0x6902
jmp 0x6904
jmp 0x6906
movw -0x2(%rbp), %ax
addq $0x10, %rsp
popq %rbp
retq