// File: /workspace/github_c_makefile_star2_O3/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 0xcc96(%rip), %rax      # 0x145f0
cmpl $0x1, (%rax)
jne 0x7970
leaq 0x5a5c(%rip), %rsi      # 0xd3c2
movl $0x12, %edi
jmp 0xa1d8
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
leaq 0xcc83(%rip), %r14      # 0x14608
cmpl $0x0, 0x28(%r14)
jne 0x799d
leaq 0x55ff(%rip), %rsi      # 0xcf92
movl $0x12, %edi
callq 0xa1d8
movl $0x72, %edi
movl $0x52, %esi
callq 0x504d
testl %eax, %eax
je 0x79ca
leaq 0xc(%rsp), %rdi
callq 0x9480
cmpl $0x11, %eax
je 0x7a33
movl 0xc(%rsp), %eax
cmpl $0x20, %eax
jl 0x79ea
jmp 0x7a33
leaq 0x5a08(%rip), %rsi      # 0xd3d9
leaq 0xc(%rsp), %rdi
callq 0x9de2
movl %eax, %ecx
movl $0x1, %eax
testl %ecx, %ecx
jne 0x7a44
movl 0xc(%rsp), %eax
cmpl $0x20, %eax
setb %cl
cmpl $0x63, %eax
sete %al
orb %cl, %al
jne 0x7a0b
leaq 0x5591(%rip), %rsi      # 0xcf92
movl $0x2c, %edi
callq 0xa1d8
movq 0x88(%r14), %rbx
movl 0x4(%rbx), %eax
cmpl $0x1, %eax
je 0x7a53
cmpl $0x40, %eax
jne 0x7a33
cmpl $-0x1, 0x14(%rbx)
je 0x7a53
leaq 0x5566(%rip), %rsi      # 0xcf92
movl $0x2d, %edi
jmp 0x7a3f
leaq 0x5558(%rip), %rsi      # 0xcf92
movl $0x12, %edi
callq 0xa1d8
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movl 0xc(%rsp), %r15d
addq $0x38, %rbx
movq %rbx, %rdi
callq 0x30b0
cmpl $0x3, %eax
jl 0x7a8a
movl $0xfffffffe, %ecx       # imm = 0xFFFFFFFE
leal (%rax,%rcx), %edx
cmpb $0x2e, (%rbx,%rdx)
jne 0x7a8a
addl %ecx, %eax
incl %eax
cmpb $0x61, (%rbx,%rax)
leal 0x20(%r15), %eax
cmovnel %r15d, %eax
movl %eax, %r15d
movl $0x21, %edi
callq 0x4fa8
leal -0x63(%r15), %esi
testl $0xffffffdf, %esi       # imm = 0xFFFFFFDF
sete %cl
testl %eax, %eax
setne %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x7ab6
leaq 0x5929(%rip), %rsi      # 0xd3dd
jmp 0x7a3a
cmpl $0x63, %r15d
je 0x7ac5
cmpl $0x83, %r15d
jne 0x7b23
leaq 0xcb28(%rip), %rcx      # 0x145f4
movslq (%rcx), %rcx
movq %rcx, %rdx
shlq $0xb, %rdx
leaq (%rdx,%rcx,8), %rdi
leaq 0xb62f(%rip), %rdx      # 0x13110
movl 0x800(%rdx,%rdi), %r9d
leal 0x20(%r9), %r8d
cmpl $0x83, %r15d
cmovnel %r9d, %r8d
cmpl %esi, %r8d
jl 0x7b40
movl %r8d, %r8d
movl %esi, %esi
leaq 0x1(%r8), %r15
shlq $0x5, %r8
addq %rdi, %rdx
addq %r8, %rdx
cmpl $0x0, (%rdx)
je 0x7b2f
decq %r15
addq $-0x20, %rdx
cmpq %rsi, %r15
jg 0x7b10
jmp 0x7b40
leaq 0xcaca(%rip), %rcx      # 0x145f4
movslq (%rcx), %rcx
jmp 0x7b4c
leaq -0x1(%r15), %rdx
andl $0x1f, %edx
movl %edx, 0xc(%rsp)
subq $0x1, %r15
jae 0x7b4c
leaq 0x58ca(%rip), %rsi      # 0xd411
jmp 0x7a3a
movq %rcx, %rdx
shlq $0xb, %rdx
leaq (%rdx,%rcx,8), %rsi
leaq 0xb5b2(%rip), %r12      # 0x13110
addq %r12, %rsi
movslq %r15d, %r15
shlq $0x5, %r15
cmpl $0x0, (%r15,%rsi)
setne %dl
testl %eax, %eax
sete %al
andb %dl, %al
cmpb $0x1, %al
jne 0x7bc7
addq %r15, %rsi
movslq 0x8(%rsi), %rax
movq %rax, %rcx
shlq $0x9, %rcx
leaq (%rcx,%rax,4), %rax
leaq 0xcc4c(%rip), %rcx      # 0x147e0
leaq (%rcx,%rax), %rdx
addq $0x4, %rdx
movl 0x4(%rsi), %ecx
leaq 0x5881(%rip), %rsi      # 0xd427
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x31b0
movq %rbx, %rdi
callq 0xa81b
leaq 0xca30(%rip), %rax      # 0x145f4
movslq (%rax), %rcx
movq %rcx, %rax
shlq $0xb, %rax
leaq (%rax,%rcx,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 0x7a44