// File: /workspace/github_c_makefile_star2_O2/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 0xd4f1(%rip), %rax      # 0x145f0
cmpl $0x1, (%rax)
jne 0x7113
leaq 0x524e(%rip), %rsi      # 0xc359
pushq $0x12
popq %rdi
jmp 0x96cc
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
leaq 0xd4e0(%rip), %r14      # 0x14608
cmpl $0x0, 0x28(%r14)
jne 0x713e
leaq 0x4e5c(%rip), %rsi      # 0xbf92
pushq $0x12
popq %rdi
callq 0x96cc
pushq $0x72
popq %rdi
pushq $0x52
popq %rsi
callq 0x4dd8
testl %eax, %eax
je 0x7167
leaq 0xc(%rsp), %rdi
callq 0x8a58
cmpl $0x11, %eax
je 0x71c9
movl 0xc(%rsp), %eax
cmpl $0x20, %eax
jl 0x7185
jmp 0x71c9
leaq 0x5202(%rip), %rsi      # 0xc370
leaq 0xc(%rsp), %rdi
callq 0x9309
testl %eax, %eax
je 0x7181
pushq $0x1
popq %rax
jmp 0x71d8
movl 0xc(%rsp), %eax
cmpl $0x20, %eax
setb %cl
cmpl $0x63, %eax
sete %al
orb %cl, %al
jne 0x71a4
leaq 0x4df6(%rip), %rsi      # 0xbf92
pushq $0x2c
popq %rdi
callq 0x96cc
movq 0x88(%r14), %rbx
movl 0x4(%rbx), %eax
cmpl $0x1, %eax
je 0x71e7
cmpl $0x40, %eax
jne 0x71c9
cmpl $-0x1, 0x14(%rbx)
je 0x71e7
leaq 0x4dcd(%rip), %rsi      # 0xbf92
pushq $0x2d
jmp 0x71d2
leaq 0x4dc2(%rip), %rsi      # 0xbf92
pushq $0x12
popq %rdi
callq 0x96cc
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 0x721e
movl $0xfffffffe, %ecx       # imm = 0xFFFFFFFE
leal (%rax,%rcx), %edx
cmpb $0x2e, (%rbx,%rdx)
jne 0x721e
addl %ecx, %eax
incl %eax
cmpb $0x61, (%rbx,%rax)
leal 0x20(%r15), %eax
cmovnel %r15d, %eax
movl %eax, %r15d
pushq $0x21
popq %rdi
callq 0x4da7
leal -0x63(%r15), %edx
testl $0xffffffdf, %edx       # imm = 0xFFFFFFDF
sete %cl
testl %eax, %eax
setne %sil
andb %cl, %sil
cmpb $0x1, %sil
jne 0x724b
leaq 0x512b(%rip), %rsi      # 0xc374
jmp 0x71d0
cmpl $0x63, %r15d
je 0x725a
cmpl $0x83, %r15d
jne 0x72b0
leaq 0xd393(%rip), %rcx      # 0x145f4
movslq (%rcx), %rcx
imulq $0x808, %rcx, %rdi      # imm = 0x808
leaq 0xbe9e(%rip), %rsi      # 0x13110
movl 0x800(%rdi,%rsi), %r8d
leal 0x20(%r8), %r9d
cmpl $0x83, %r15d
cmovnel %r8d, %r9d
movslq %r9d, %r15
movq %r15, %r8
shlq $0x5, %r8
addq %rdi, %rsi
addq %r8, %rsi
cmpq %rdx, %r15
jl 0x7391
cmpl $0x0, (%rsi)
je 0x72bc
decq %r15
addq $-0x20, %rsi
jmp 0x7299
leaq 0xd33d(%rip), %rcx      # 0x145f4
movslq (%rcx), %rcx
jmp 0x72d0
movl %r15d, %edx
andl $0x1f, %edx
movl %edx, 0xc(%rsp)
cmpq $-0x1, %r15
je 0x7391
imulq $0x808, %rcx, %rsi      # imm = 0x808
leaq 0xbe32(%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 0x7343
addq %r15, %rsi
movslq 0x8(%rsi), %rax
imulq $0x204, %rax, %rax      # imm = 0x204
leaq 0xd4d0(%rip), %rcx      # 0x147e0
leaq (%rcx,%rax), %rdx
addq $0x4, %rdx
movl 0x4(%rsi), %ecx
leaq 0x509c(%rip), %rsi      # 0xc3be
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x31b0
movq %rbx, %rdi
callq 0x9cd8
leaq 0xd2b4(%rip), %rax      # 0x145f4
movslq (%rax), %rcx
imulq $0x808, %rcx, %rax      # imm = 0x808
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 0x71d8
leaq 0x5010(%rip), %rsi      # 0xc3a8
jmp 0x71d0