// File: /workspace/github_c_makefile_star2_O1/42Bastian[P]lyxass/pseudo.c
// Function: p_reg
int p_reg(int d)
{
  int32_t l;
  int i,o;
  int allowRedefine;

  if ( sourceMode == LYNX ) {
    return Error(SYNTAX_ERR,"REG only in RISC modes");
  }

  if ( ! Current.Label.len ) Error(SYNTAX_ERR,"");

  if ( TestAtomOR('r','R') ){
    if ( getdec32( &l ) == EXPR_ERR ) return Error(SYNTAX_ERR,"");
    if ( l > 31 ) return Error(SYNTAX_ERR,"");
  } else {
    if ( NeedConst( &l, "REG") ) return 1;
  }

  if ( (l < 0 || l > 31) && l != 99 ) Error(REG_ERR,"");

  if ( (Current.LabelPtr->type == REGISTER ) &&
       (Current.LabelPtr->file != -1) ) return Error(REG1_ERR,"");

  if ( Current.LabelPtr->type != NORMAL &&
       Current.LabelPtr->type != REGISTER ) return Error(SYNTAX_ERR,"");

  o = l;
  i = (int)strlen(Current.LabelPtr->name);
  if ( i > 2 &&
       Current.LabelPtr->name[i-2] == '.' &&
       Current.LabelPtr->name[i-1] == 'a'){
    o += 32;
  }
  allowRedefine = TestAtom('!');
  if ( (o == 99 || o == (99+32)) && allowRedefine ){
    return Error(SYNTAX_ERR,
                 "'!' not allowed with automatic register allocation.");
  }
  if ( o == 99 || o == (99+32) ){
    int end = o-99;
    i = risc[jaguar_mode].regAllocStart;
    if ( o == 99+32 ){
      i+=32;
    }
    o = -1;
    for( ; i >= end; --i){
      if ( risc[jaguar_mode].regs[i].flag == 0 ){
        o = i;
        l = o & 31;
        break;
      }
    }
    if ( o == -1 ){
      return Error(SYNTAX_ERR,"No more free register");
    }
  }

  if ( risc[jaguar_mode].regs[o].flag && allowRedefine == 0 ) {
    char help[256];
    sprintf(help,"Register already defined: %s:%5d",
            file_list[risc[jaguar_mode].regs[o].file].name,
            risc[jaguar_mode].regs[o].line);

    Warning(help);
  }

  risc[jaguar_mode].regs[o].flag = 1;
  risc[jaguar_mode].regs[o].file = Current.File;
  risc[jaguar_mode].regs[o].line = Current.Line;
  risc[jaguar_mode].regs[o].label = Current.LabelPtr;
  ++risc[jaguar_mode].regs[o].refCount;
  Current.LabelPtr->file = Current.File;
  Current.LabelPtr->type = REGISTER;
  Current.LabelPtr->value = l;
  // Current.varModifier++;
  // printf("(%s)%d\n",Current.LabelPtr->name,Current.LabelPtr->value);
  return 0;
}

// Assembly:
leaq 0xcc22(%rip), %rax      # 0x145f0
cmpl $0x1, (%rax)
jne 0x79e4
leaq 0x597f(%rip), %rsi      # 0xd359
movl $0x12, %edi
jmp 0xa2c8
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x110, %rsp            # imm = 0x110
leaq 0xcc0d(%rip), %r14      # 0x14608
cmpl $0x0, 0x28(%r14)
jne 0x7a13
leaq 0x5589(%rip), %rsi      # 0xcf92
movl $0x12, %edi
callq 0xa2c8
movl $0x72, %edi
movl $0x52, %esi
callq 0x5083
testl %eax, %eax
je 0x7a45
leaq 0xc(%rsp), %rdi
callq 0x94fc
cmpl $0x11, %eax
je 0x7b25
cmpl $0x20, 0xc(%rsp)
jl 0x7a65
jmp 0x7b25
leaq 0x5924(%rip), %rsi      # 0xd370
leaq 0xc(%rsp), %rdi
callq 0x9ee6
movl %eax, %ecx
movl $0x1, %eax
testl %ecx, %ecx
jne 0x7b36
movl 0xc(%rsp), %eax
cmpl $0x20, %eax
setb %cl
cmpl $0x63, %eax
sete %al
orb %cl, %al
jne 0x7a8a
leaq 0x5512(%rip), %rsi      # 0xcf92
movl $0x2c, %edi
callq 0xa2c8
movq 0x88(%r14), %rbx
movl 0x4(%rbx), %eax
cmpl $0x1, %eax
je 0x7ac0
cmpl $0x40, %eax
jne 0x7b25
cmpl $-0x1, 0x14(%rbx)
je 0x7ab6
leaq 0x54e3(%rip), %rsi      # 0xcf92
movl $0x2d, %edi
jmp 0x7b31
cmpl $0x1, %eax
je 0x7ac0
cmpl $0x40, %eax
jne 0x7b25
movl 0xc(%rsp), %r15d
addq $0x38, %rbx
movq %rbx, %rdi
callq 0x30b0
cmpl $0x3, %eax
jl 0x7af7
movl $0xfffffffe, %ecx       # imm = 0xFFFFFFFE
leal (%rax,%rcx), %edx
cmpb $0x2e, (%rbx,%rdx)
jne 0x7af7
addl %ecx, %eax
incl %eax
cmpb $0x61, (%rbx,%rax)
leal 0x20(%r15), %eax
cmovnel %r15d, %eax
movl %eax, %r15d
movl $0x21, %edi
callq 0x4fa3
movl %eax, %ebx
leal -0x63(%r15), %ecx
testl $0xffffffdf, %ecx       # imm = 0xFFFFFFDF
sete %al
testl %ebx, %ebx
setne %dl
andb %al, %dl
cmpb $0x1, %dl
jne 0x7b47
leaq 0x5851(%rip), %rsi      # 0xd374
jmp 0x7b2c
leaq 0x5466(%rip), %rsi      # 0xcf92
movl $0x12, %edi
callq 0xa2c8
addq $0x110, %rsp            # imm = 0x110
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
cmpl $0x83, %r15d
je 0x7b5a
cmpl $0x63, %r15d
jne 0x7bee
leaq 0xca93(%rip), %rax      # 0x145f4
movslq (%rax), %rax
movq %rax, %rdx
shlq $0xb, %rdx
leaq (%rdx,%rax,8), %rsi
leaq 0xb59a(%rip), %rax      # 0x13110
movl 0x800(%rax,%rsi), %edx
cmpl $0x83, %r15d
leal 0x20(%rdx), %edi
movl %edi, %r15d
cmovnel %edx, %r15d
cmpl %ecx, %r15d
jl 0x7bbb
movslq %r15d, %rdi
movslq %ecx, %rcx
leaq 0x1(%rdi), %rdx
shlq $0x5, %rdi
addq %rsi, %rax
addq %rdi, %rax
cmpl $0x0, (%rax)
je 0x7bc3
decl %r15d
decq %rdx
addq $-0x20, %rax
cmpq %rcx, %rdx
jg 0x7ba7
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
jmp 0x7bcd
movl %r15d, %eax
andl $0x1f, %eax
movl %eax, 0xc(%rsp)
cmpl $-0x1, %r15d
jne 0x7be4
leaq 0x57ce(%rip), %rsi      # 0xd3a8
movl $0x12, %edi
callq 0xa2c8
cmpl $-0x1, %r15d
je 0x7b36
leaq 0xc9ff(%rip), %r13      # 0x145f4
movslq (%r13), %rax
movq %rax, %rcx
shlq $0xb, %rcx
leaq (%rcx,%rax,8), %rax
leaq 0xb505(%rip), %r12      # 0x13110
addq %r12, %rax
movslq %r15d, %r15
shlq $0x5, %r15
cmpl $0x0, (%r15,%rax)
setne %cl
testl %ebx, %ebx
sete %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x7c6a
addq %r15, %rax
movslq 0x8(%rax), %rcx
movq %rcx, %rdx
shlq $0x9, %rdx
leaq (%rdx,%rcx,4), %rcx
leaq 0xcb9e(%rip), %rdx      # 0x147e0
addq %rcx, %rdx
addq $0x4, %rdx
movl 0x4(%rax), %ecx
leaq 0x576b(%rip), %rsi      # 0xd3be
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x31b0
movq %rbx, %rdi
callq 0xa900
movslq (%r13), %rax
movq %rax, %rcx
shlq $0xb, %rcx
leaq (%rcx,%rax,8), %rax
addq %rax, %r12
movl $0x1, (%r15,%r12)
movl 0x4(%r14), %eax
movl %eax, 0x8(%r15,%r12)
movl (%r14), %ecx
movl %ecx, 0x4(%r15,%r12)
movq 0x88(%r14), %rcx
movq %rcx, 0x10(%r15,%r12)
incl 0x18(%r15,%r12)
movl %eax, 0x14(%rcx)
movl $0x40, 0x4(%rcx)
movslq 0xc(%rsp), %rax
movq %rax, 0x8(%rcx)
xorl %eax, %eax
jmp 0x7b36