// File: /workspace/github_c_makefile_star2_O2/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
pushq $0x28
popq %rdi
callq 0x4da7
testl %eax, %eax
je 0xa889
leaq 0x4(%rsp), %rdi
callq 0x9f8b
pushq $0x1
popq %rbx
testl %eax, %eax
je 0xa809
movl %ebx, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
pushq $0x29
popq %r14
movl %r14d, %edi
callq 0x4da7
xorl %ebp, %ebp
testl %eax, %eax
je 0xa862
pushq $0x2c
popq %rdi
callq 0x4da7
testl %eax, %eax
je 0xa951
leaq 0xc(%rsp), %rdi
callq 0x9f8b
testl %eax, %eax
jne 0xa7fe
testl %ebp, %ebp
je 0xa844
xorl %eax, %eax
callq 0x960c
shll $0xa, %r14d
movl 0x4(%rsp), %eax
shll $0x5, %eax
orl %r14d, %eax
orl 0xc(%rsp), %eax
movswl %ax, %edi
callq 0x9d8c
xorl %ebx, %ebx
jmp 0xa7fe
leaq 0x126c7(%rip), %rax     # 0x1cf30
cmpl $0x2b, (%rax)
jne 0xa889
callq 0x4d44
movl 0x4(%rsp), %r14d
leal -0xe(%r14), %eax
movl %eax, 0x4(%rsp)
leal -0x10(%r14), %eax
cmpl $-0x3, %eax
ja 0xa8a0
leaq 0x1702(%rip), %rsi      # 0xbf92
pushq $0x12
popq %rdi
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
jmp 0x96cc
callq 0x4d82
leaq 0x4(%rsp), %rdi
callq 0x9f8b
testl %eax, %eax
je 0xa8fb
callq 0x4d94
leaq 0x8(%rsp), %rdi
callq 0x929a
cmpl $0x11, %eax
je 0xa903
xorl %ebp, %ebp
cmpl $0x2, %eax
jne 0xa8d9
movl $0x4, 0x8(%rsp)
pushq $0x1
popq %rbp
leaq 0x132d0(%rip), %rax     # 0x1dbb0
cmpl $0x0, (%rax)
movl 0x8(%rsp), %eax
je 0xa90b
testl %eax, %eax
je 0xa91a
cmpl $0x20, %eax
jbe 0xa931
leaq 0x2307(%rip), %rsi      # 0xcc00
jmp 0xa916
addl $0x2c, %r14d
xorl %ebp, %ebp
jmp 0xa941
pushq $0x1
popq %rbx
jmp 0xa7fe
testb $0x3, %al
je 0xa967
leaq 0x22bf(%rip), %rsi      # 0xcbd5
pushq $0x2b
jmp 0xa95a
movl %r14d, 0x4(%rsp)
leaq 0x22ba(%rip), %rdi      # 0xcbe0
callq 0x9cd8
pushq $0x29
popq %r14
jmp 0xa941
xorl %ecx, %ecx
cmpl $0x20, %eax
cmovnel %eax, %ecx
movl %ecx, 0x4(%rsp)
addl $0x1d, %r14d
pushq $0x29
popq %rdi
callq 0x4da7
testl %eax, %eax
jne 0xa81b
leaq 0x163a(%rip), %rsi      # 0xbf92
pushq $0x12
popq %rdi
callq 0x96cc
movl %eax, %ebx
jmp 0xa7fe
sarl $0x2, %eax
movl %eax, 0x8(%rsp)
jmp 0xa8e9