// File: /workspace/github_c_makefile_star2_O3/42Bastian[P]lyxass/jaguar.c
// Function: load_reg
int load_reg(int op )
{
  int reg1,reg2,save_reg1;
  int save = 0;

  if ( !TestAtom('(') ) return Error(SYNTAX_ERR,"");

  if ( GetRegister( &reg1 ) ) return 1;

  if ( TestAtom(')') ){
    op = 41;
  } else {
    if ( atom != '+' ) return Error(SYNTAX_ERR,"");
    GetAtom();
    op = 58;
    save_reg1 = reg1;
    reg1 -= 14;
    if ( reg1  < 0 || reg1 > 1 ) return Error(SYNTAX_ERR,"");
    op += reg1;

    SavePosition();

    if ( GetRegister( &reg1 ) ){
      int32_t l;
      int err;
      RestorePosition();

      if ( (err = Expression( &l )) == EXPR_ERR ) return 1;

      if ( err == EXPR_UNSOLVED ){
        save = 1;
        l = 4;
      }

      if ( !mac_mode ){
        if ( (l & 3) ) return Error(IMM_ERR,"x % 4 != 0");
        l >>= 2;
      }
      if ( l == 0 ){
        op = 41;
        reg1 = save_reg1;
        Warning("Index 0, using non-indexed LOAD");
      } else {
        if ( l < 0 || l > 32 ) return Error(IMM_ERR,"4<=x<=128");
        reg1 = l == 32 ? 0 : l;
        op -= 15;
      }
    }
    if ( !TestAtom(')') ) return Error(SYNTAX_ERR,"");
  }

  if ( !TestAtom(',') ) return Error(SYNTAX_ERR,"");

  if ( GetRegister( &reg2 ) ) return 1;

  if ( save ) saveCurrentLine();

  op = ( op << 10 ) | ( reg1 << 5 ) | reg2;

  writeOp( op );

  return 0;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movl $0x28, %edi
callq 0x4fa8
testl %eax, %eax
je 0xb672
leaq 0x4(%rsp), %rdi
callq 0xab43
movl $0x1, %ebx
testl %eax, %eax
je 0xb5ce
movl %ebx, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
movl $0x29, %r14d
movl $0x29, %edi
callq 0x4fa8
xorl %ebp, %ebp
testl %eax, %eax
je 0xb64b
movl $0x2c, %edi
callq 0x4fa8
testl %eax, %eax
je 0xb747
leaq 0xc(%rsp), %rdi
callq 0xab43
testl %eax, %eax
jne 0xb5c3
testl %ebp, %ebp
je 0xb60f
xorl %eax, %eax
callq 0xa118
shll $0xa, %r14d
movl 0x4(%rsp), %eax
shll $0x5, %eax
orl %r14d, %eax
orl 0xc(%rsp), %eax
movswl %ax, %edi
shrl $0xa, %eax
andl $0x3f, %eax
movl %eax, 0x8af0(%rip)      # 0x14120
leaq 0x8d79(%rip), %rax      # 0x143b0
movl (%rax), %eax
movl %eax, 0x8ae5(%rip)      # 0x14124
callq 0x35cf
xorl %ebx, %ebx
jmp 0xb5c3
leaq 0x118de(%rip), %rax     # 0x1cf30
cmpl $0x2b, (%rax)
jne 0xb672
callq 0x4f1a
movl 0x4(%rsp), %r14d
leal -0xe(%r14), %eax
movl %eax, 0x4(%rsp)
leal -0x10(%r14), %eax
cmpl $-0x3, %eax
ja 0xb68b
leaq 0x1919(%rip), %rsi      # 0xcf92
movl $0x12, %edi
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
jmp 0xa1d8
callq 0x4f58
leaq 0x4(%rsp), %rdi
callq 0xab43
testl %eax, %eax
je 0xb6e8
callq 0x4f6a
leaq 0x8(%rsp), %rdi
callq 0x9d6c
cmpl $0x11, %eax
je 0xb6f0
xorl %ebp, %ebp
cmpl $0x2, %eax
jne 0xb6c6
movl $0x4, 0x8(%rsp)
movl $0x1, %ebp
leaq 0x124e3(%rip), %rax     # 0x1dbb0
cmpl $0x0, (%rax)
movl 0x8(%rsp), %eax
je 0xb6fa
testl %eax, %eax
je 0xb70c
cmpl $0x20, %eax
jbe 0xb725
leaq 0x2582(%rip), %rsi      # 0xdc68
jmp 0xb705
addl $0x2c, %r14d
xorl %ebp, %ebp
jmp 0xb735
movl $0x1, %ebx
jmp 0xb5c3
testb $0x3, %al
je 0xb75f
leaq 0x2538(%rip), %rsi      # 0xdc3d
movl $0x2b, %edi
jmp 0xb753
movl %r14d, 0x4(%rsp)
leaq 0x2530(%rip), %rdi      # 0xdc48
callq 0xa81b
movl $0x29, %r14d
jmp 0xb735
xorl %ecx, %ecx
cmpl $0x20, %eax
cmovnel %eax, %ecx
movl %ecx, 0x4(%rsp)
addl $0x1d, %r14d
movl $0x29, %edi
callq 0x4fa8
testl %eax, %eax
jne 0xb5e4
leaq 0x1844(%rip), %rsi      # 0xcf92
movl $0x12, %edi
callq 0xa1d8
movl %eax, %ebx
jmp 0xb5c3
sarl $0x2, %eax
movl %eax, 0x8(%rsp)
jmp 0xb6d6