// File: /workspace/github_c_makefile_star2_O2/42Bastian[P]lyxass/jaguar.c
// Function: store_reg
int store_reg(int op )
{
  int reg1,reg2, save_reg2;

  if ( GetRegister( &reg1 ) ) return 1;

  if ( !TestAtom(',') || !TestAtom('(') ) {
    return Error(SYNTAX_ERR,"Expecting ',' or '('");
  }

  if ( GetRegister( &reg2 ) ) return 1;

  if ( TestAtom(')') ){
    op = 47;
  } else {
    if ( atom != '+' ) return Error(SYNTAX_ERR,"Expecting '+'");
    GetAtom();
    op = 60;

    if ( reg2 != 14 && reg2 != 15 ) {
      return Error(SYNTAX_ERR,"Expecting r14 or r15");
    }

    op += (reg2 - 14);

    save_reg2 = reg2;

    SavePosition();

    if ( GetRegister( &reg2 ) ){
      int32_t l;
      int err;

      op -= 11;

      RestorePosition();

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

      if ( err == EXPR_UNSOLVED ) saveCurrentLine();

      if ( !mac_mode ){
        if ( (l & 3) ) return Error(IMM_ERR,"x % 4 != 0");
        l >>= 2;
      }
      if ( l == 0 ){
        op = 47;
        reg2 = save_reg2;
        Warning("Offest 0 using STORE w/o index");
      } else {
        if ( l < 0 || l > 32 ) return Error(IMM_ERR,"4<=x<=128");
        reg2 = l == 32 ? 0 : l;
      }
    }
    if ( !TestAtom(')')) return Error(SYNTAX_ERR,"");
  }
  op = ( op << 10 ) | ( reg2 << 5 ) | reg1;

  writeOp( op );

  return 0;
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
leaq 0xc(%rsp), %rdi
callq 0x9f8b
pushq $0x1
popq %rbx
testl %eax, %eax
je 0xaa10
movl %ebx, %eax
addq $0x10, %rsp
popq %rbx
retq
pushq $0x2c
popq %rdi
callq 0x4da7
testl %eax, %eax
je 0xaa61
pushq $0x28
popq %rdi
callq 0x4da7
testl %eax, %eax
je 0xaa61
leaq 0x4(%rsp), %rdi
callq 0x9f8b
testl %eax, %eax
jne 0xaa08
pushq $0x29
popq %rdi
callq 0x4da7
testl %eax, %eax
je 0xaa75
pushq $0x2f
popq %rbx
shll $0xa, %ebx
movl 0x4(%rsp), %eax
shll $0x5, %eax
orl %ebx, %eax
orl 0xc(%rsp), %eax
movswl %ax, %edi
callq 0x9d8c
xorl %ebx, %ebx
jmp 0xaa08
leaq 0x21a2(%rip), %rsi      # 0xcc0a
pushq $0x12
popq %rdi
addq $0x10, %rsp
popq %rbx
jmp 0x96cc
leaq 0x124b4(%rip), %rax     # 0x1cf30
cmpl $0x2b, (%rax)
jne 0xaa9b
callq 0x4d44
movl 0x4(%rsp), %ebx
leal -0x10(%rbx), %eax
cmpl $-0x3, %eax
ja 0xaaa4
leaq 0x2194(%rip), %rsi      # 0xcc2d
jmp 0xaa68
leaq 0x217d(%rip), %rsi      # 0xcc1f
jmp 0xaa68
callq 0x4d82
leaq 0x4(%rsp), %rdi
callq 0x9f8b
testl %eax, %eax
je 0xaaf9
callq 0x4d94
leaq 0x8(%rsp), %rdi
callq 0x929a
cmpl $0x11, %eax
je 0xaafe
cmpl $0x2, %eax
jne 0xaad7
xorl %eax, %eax
callq 0x960c
leaq 0x130d2(%rip), %rax     # 0x1dbb0
cmpl $0x0, (%rax)
movl 0x8(%rsp), %eax
je 0xab06
testl %eax, %eax
je 0xab15
cmpl $0x20, %eax
jbe 0xab2a
leaq 0x2109(%rip), %rsi      # 0xcc00
jmp 0xab11
addl $0x2e, %ebx
jmp 0xab39
pushq $0x1
popq %rbx
jmp 0xaa08
testb $0x3, %al
je 0xab5f
leaq 0x20c4(%rip), %rsi      # 0xcbd5
pushq $0x2b
jmp 0xab52
movl %ebx, 0x4(%rsp)
leaq 0x2122(%rip), %rdi      # 0xcc42
callq 0x9cd8
pushq $0x2f
popq %rbx
jmp 0xab39
addl $0x23, %ebx
xorl %ecx, %ecx
cmpl $0x20, %eax
cmovnel %eax, %ecx
movl %ecx, 0x4(%rsp)
pushq $0x29
popq %rdi
callq 0x4da7
testl %eax, %eax
jne 0xaa45
leaq 0x1442(%rip), %rsi      # 0xbf92
pushq $0x12
popq %rdi
callq 0x96cc
movl %eax, %ebx
jmp 0xaa08
sarl $0x2, %eax
movl %eax, 0x8(%rsp)
jmp 0xaae7