// File: /workspace/github_c_makefile_star2_O1/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 %rbp
pushq %rbx
subq $0x18, %rsp
leaq 0x14(%rsp), %rdi
callq 0xac2c
movl $0x1, %ebx
testl %eax, %eax
je 0xb930
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %rbp
retq
movl $0x2c, %edi
callq 0x4fa3
testl %eax, %eax
je 0xb9a4
movl $0x28, %edi
callq 0x4fa3
testl %eax, %eax
je 0xb9a4
leaq 0xc(%rsp), %rdi
callq 0xac2c
testl %eax, %eax
jne 0xb927
movl $0x29, %edi
callq 0x4fa3
movl $0x2f, %ebp
testl %eax, %eax
je 0xb9bb
shll $0xa, %ebp
movl 0xc(%rsp), %eax
shll $0x5, %eax
orl %ebp, %eax
orl 0x14(%rsp), %eax
movswl %ax, %edi
shrl $0xa, %eax
andl $0x3f, %eax
movl %eax, 0x8794(%rip)      # 0x14120
leaq 0x8a1d(%rip), %rax      # 0x143b0
movl (%rax), %eax
movl %eax, 0x8789(%rip)      # 0x14124
callq 0x35ae
xorl %ebx, %ebx
jmp 0xb927
leaq 0x225f(%rip), %rsi      # 0xdc0a
movl $0x12, %edi
addq $0x18, %rsp
popq %rbx
popq %rbp
jmp 0xa2c8
leaq 0x1156e(%rip), %rax     # 0x1cf30
cmpl $0x2b, (%rax)
jne 0xb9e1
callq 0x4f15
movl 0xc(%rsp), %ebx
leal -0x10(%rbx), %eax
cmpl $-0x3, %eax
ja 0xb9ea
leaq 0x224e(%rip), %rsi      # 0xdc2d
jmp 0xb9ab
leaq 0x2237(%rip), %rsi      # 0xdc1f
jmp 0xb9ab
callq 0x4f53
leaq 0xc(%rsp), %rdi
callq 0xac2c
testl %eax, %eax
je 0xba42
leal 0x23(%rbx), %ebp
callq 0x4f65
leaq 0x10(%rsp), %rdi
callq 0x9e70
cmpl $0x11, %eax
je 0xba49
cmpl $0x2, %eax
jne 0xba20
xorl %eax, %eax
callq 0xa204
leaq 0x12189(%rip), %rax     # 0x1dbb0
cmpl $0x0, (%rax)
je 0xba50
movl 0x10(%rsp), %eax
testl %eax, %eax
je 0xba6f
cmpl $0x21, %eax
jb 0xba88
leaq 0x21c0(%rip), %rsi      # 0xdc00
jmp 0xba5f
addl $0x2e, %ebx
movl %ebx, %ebp
jmp 0xba9e
movl $0x1, %ebx
jmp 0xba6b
movl 0x10(%rsp), %eax
testb $0x3, %al
je 0xbac8
leaq 0x2176(%rip), %rsi      # 0xdbd5
movl $0x2b, %edi
callq 0xa2c8
movl %eax, %ebx
xorl %eax, %eax
jmp 0xba96
movl %ebx, 0xc(%rsp)
leaq 0x21c8(%rip), %rdi      # 0xdc42
callq 0xa900
movb $0x1, %al
movl $0x2f, %ebp
jmp 0xba96
xorl %ecx, %ecx
cmpl $0x20, %eax
cmovnel %eax, %ecx
movl %ecx, 0xc(%rsp)
movb $0x1, %al
testb %al, %al
je 0xb927
movl $0x29, %edi
callq 0x4fa3
testl %eax, %eax
jne 0xb96d
leaq 0x14db(%rip), %rsi      # 0xcf92
movl $0x12, %edi
callq 0xa2c8
movl %eax, %ebx
jmp 0xb927
sarl $0x2, %eax
movl %eax, 0x10(%rsp)
jmp 0xba2c