// File: /workspace/github_c_makefile_star2_O1/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 0x4fa3
testl %eax, %eax
je 0xb75d
leaq 0x4(%rsp), %rdi
callq 0xac2c
movl %eax, %ecx
movl $0x1, %eax
testl %ecx, %ecx
je 0xb6b5
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
movl $0x29, %ebx
movl $0x29, %edi
callq 0x4fa3
xorl %ebp, %ebp
testl %eax, %eax
je 0xb736
movl $0x2c, %edi
callq 0x4fa3
testl %eax, %eax
je 0xb848
leaq 0xc(%rsp), %rdi
callq 0xac2c
movl %eax, %ecx
movl $0x1, %eax
testl %ecx, %ecx
jne 0xb6ac
testl %ebp, %ebp
je 0xb6fc
xorl %eax, %eax
callq 0xa204
shll $0xa, %ebx
movl 0x4(%rsp), %eax
shll $0x5, %eax
orl %ebx, %eax
orl 0xc(%rsp), %eax
movswl %ax, %edi
shrl $0xa, %eax
andl $0x3f, %eax
movl %eax, 0x8a05(%rip)      # 0x14120
leaq 0x8c8e(%rip), %rax      # 0x143b0
movl (%rax), %eax
movl %eax, 0x89fa(%rip)      # 0x14124
callq 0x35ae
xorl %eax, %eax
jmp 0xb6ac
leaq 0x117f3(%rip), %rax     # 0x1cf30
cmpl $0x2b, (%rax)
jne 0xb75d
callq 0x4f15
movl 0x4(%rsp), %r14d
leal -0xe(%r14), %eax
movl %eax, 0x4(%rsp)
leal -0x10(%r14), %eax
cmpl $-0x3, %eax
ja 0xb776
leaq 0x182e(%rip), %rsi      # 0xcf92
movl $0x12, %edi
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
jmp 0xa2c8
leal 0x2c(%r14), %ebx
callq 0x4f53
leaq 0x4(%rsp), %rdi
callq 0xac2c
testl %eax, %eax
je 0xb7d7
callq 0x4f65
leaq 0x8(%rsp), %rdi
callq 0x9e70
xorl %ebp, %ebp
cmpl $0x11, %eax
je 0xb7db
cmpl $0x2, %eax
jne 0xb7b5
movl $0x4, 0x8(%rsp)
movl $0x1, %ebp
leaq 0x123f4(%rip), %rax     # 0x1dbb0
cmpl $0x0, (%rax)
je 0xb7e2
movl 0x8(%rsp), %eax
testl %eax, %eax
je 0xb7ff
cmpl $0x21, %eax
jb 0xb819
leaq 0x242b(%rip), %rsi      # 0xdc00
jmp 0xb7f1
xorl %ebp, %ebp
jmp 0xb836
movl $0x1, %eax
jmp 0xb7fb
movl 0x8(%rsp), %eax
testb $0x3, %al
je 0xb85e
leaq 0x23e4(%rip), %rsi      # 0xdbd5
movl $0x2b, %edi
callq 0xa2c8
xorl %ecx, %ecx
jmp 0xb82e
movl %r14d, 0x4(%rsp)
leaq 0x23d5(%rip), %rdi      # 0xdbe0
callq 0xa900
movb $0x1, %cl
movl $0x29, %ebx
jmp 0xb82e
xorl %ecx, %ecx
cmpl $0x20, %eax
cmovnel %eax, %ecx
movl %ecx, 0x4(%rsp)
addl $0x1d, %r14d
movb $0x1, %cl
movl %r14d, %ebx
testb %cl, %cl
je 0xb6ac
movl $0x29, %edi
callq 0x4fa3
testl %eax, %eax
jne 0xb6ca
leaq 0x1743(%rip), %rsi      # 0xcf92
movl $0x12, %edi
callq 0xa2c8
jmp 0xb6ac
sarl $0x2, %eax
movl %eax, 0x8(%rsp)
jmp 0xb7c1