// File: /workspace/github_c_makefile_star2_O3/42Bastian[P]lyxass/jaguar.c
// Function: GetRegister
int GetRegister(int *reg)
{
  label_t regL;
  label_t *regL2;
  int32_t solved;
  char *p;

  *reg = -1;

  KillSpace();

  if ( (atom == 'r' || atom == 'R') && isdigit(next_atom) ){
    int32_t l;
    GetAtom();
    if ( getdec32(&l) == EXPR_ERR ) return Error(REG_ERR,"");
    if ( l > 31 ) return Error(REG_ERR,"");
    *reg = (int)l;
    return 0;
  }

  p = srcLinePtr - 1;

  if ( GetLabel(&regL) ) return 1;

  if ( (regL2 = FindLabel(&regL, &solved)) == NULL ){
#if 0 /* allow pass 2 resolving */
    return -1;
#else
    return Error(REG_ERR,"");
#endif
  }

  if (regL2->type != REGISTER ) return -1;

  if (regL2->value == -1 ) return Error(REG_ERR,"");

  if ( regL2->len > 2 ){
    *p++ = 'r';
    *p++ = (char)(regL2->value / 10 + '0');
    *p++ = (char)(regL2->value % 10 + '0');
    *p++ = atom;
    memmove(p,srcLinePtr,strlen(srcLinePtr)+1);
  } else {
    memmove(p+4,srcLinePtr,strlen(srcLinePtr)+1);
    *p++ = 'r';
    *p++ = (char)(regL2->value / 10 + '0');
    *p++ = (char)(regL2->value % 10 + '0');
    *p++ = atom;
  }
  srcLinePtr = p;
  next_atom = *p;

  *reg = (int)regL2->value;

  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdi, %rbx
movl $0xffffffff, (%rdi)     # imm = 0xFFFFFFFF
xorl %eax, %eax
callq 0x4ff7
leaq 0x123c8(%rip), %r12     # 0x1cf30
movl (%r12), %eax
andl $-0x21, %eax
cmpl $0x52, %eax
jne 0xab91
callq 0x31e0
movq (%rax), %rax
leaq 0x123b5(%rip), %rcx     # 0x1cf38
movslq (%rcx), %rcx
testb $0x8, 0x1(%rax,%rcx,2)
jne 0xac6e
leaq 0x12388(%rip), %rbp     # 0x1cf20
movq (%rbp), %r14
leaq 0x18(%rsp), %rdi
callq 0x52f1
movl %eax, %ecx
movl $0x1, %eax
testl %ecx, %ecx
jne 0xad3e
leaq 0x18(%rsp), %rdi
leaq 0x14(%rsp), %rsi
callq 0x60dc
testq %rax, %rax
je 0xac8f
movq %rax, %r15
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl $0x40, 0x4(%r15)
jne 0xad3e
cmpq $-0x1, 0x8(%r15)
je 0xac8f
cmpl $0x3, (%r15)
jl 0xaca5
movb $0x72, -0x1(%r14)
movabsq $0x6666666666666667, %rcx # imm = 0x6666666666666667
movq %rcx, %rax
imulq 0x8(%r15)
movq %rdx, %rax
shrq $0x3f, %rax
shrl $0x2, %edx
addl %eax, %edx
addb $0x30, %dl
movb %dl, (%r14)
movq 0x8(%r15), %rsi
movq %rsi, %rax
imulq %rcx
movq %rdx, %rax
shrq $0x3f, %rax
shrl $0x2, %edx
addl %eax, %edx
addl %edx, %edx
leal (%rdx,%rdx,4), %eax
subl %eax, %esi
addb $0x30, %sil
movb %sil, 0x1(%r14)
movb (%r12), %al
movb %al, 0x2(%r14)
addq $0x3, %r14
movq (%rbp), %r12
movq %r12, %rdi
callq 0x30b0
leaq 0x1(%rax), %rdx
movq %r14, %rdi
movq %r12, %rsi
callq 0x3180
jmp 0xad25
callq 0x4f1a
leaq 0x18(%rsp), %rdi
callq 0x9480
cmpl $0x11, %eax
je 0xac8f
movl 0x18(%rsp), %eax
cmpl $0x20, %eax
jl 0xad3a
leaq 0x22fc(%rip), %rsi      # 0xcf92
movl $0x2c, %edi
callq 0xa1d8
jmp 0xad3e
leaq 0x3(%r14), %rax
movq %rax, 0x8(%rsp)
movq (%rbp), %r13
movq %r13, %rdi
callq 0x30b0
leaq 0x1(%rax), %rdx
movq 0x8(%rsp), %rdi
movq %r13, %rsi
callq 0x3180
movb $0x72, -0x1(%r14)
movabsq $0x6666666666666667, %rcx # imm = 0x6666666666666667
movq %rcx, %rax
imulq 0x8(%r15)
movq %rdx, %rax
shrq $0x3f, %rax
shrl $0x2, %edx
addl %eax, %edx
addb $0x30, %dl
movb %dl, (%r14)
movq 0x8(%r15), %rsi
movq %rsi, %rax
imulq %rcx
movq %rdx, %rax
shrq $0x3f, %rax
shrl $0x2, %edx
addl %eax, %edx
addl %edx, %edx
leal (%rdx,%rdx,4), %eax
subl %eax, %esi
addb $0x30, %sil
movb %sil, 0x1(%r14)
movb (%r12), %al
movb %al, 0x2(%r14)
movq 0x8(%rsp), %r14
movq %r14, (%rbp)
movsbl (%r14), %eax
leaq 0x12204(%rip), %rcx     # 0x1cf38
movl %eax, (%rcx)
movl 0x8(%r15), %eax
movl %eax, (%rbx)
xorl %eax, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq