// File: /workspace/github_c_makefile_star2_O2/mrkite[P]regs/docmaker/parser.cc
// Function: Parser::parseRef(Ref*, File*)
bool Parser::parseRef(Ref *ref, File *f) {
  ref->pointer = 0;
  ref->array = -1;

  Token token;
  while ((token = f->token()).type == SYMBOL && token.asSym == '^') {
    ref->pointer++;
  }
  if (token.type != VAR) {
    error(f, "Expected a type or a pointer.\n");
    return false;
  }
  ref->symbol = find(token);
  token = f->token();
  if (token.type == SYMBOL && token.asSym == '[') {
    ref->array = 0;  // empty bracket
    token = f->token();
    if (token.type == NUMBER) {
      ref->array = token.asNum;
      token = f->token();
    }
    if (!token.expect(']')) {
      return false;
    }
  } else {
    f->reset();
  }
  token = f->token();
  if (token.type == SYMBOL && token.asSym == '|') {
    token = f->token();
    if (token.type != VAR) {
      error(f, "Expected a register\n");
      return false;
    } else {
      ref->reg = token.asStr;
    }
  } else {
    f->reset();
  }
  return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rdx, %rbx
movq %rsi, %r14
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
movq %rax, 0x8(%rsi)
leaq 0x20(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movq %rdi, (%rsp)
xorl %ecx, %ecx
movb %cl, (%rax)
movb %cl, 0x10(%rax)
andl $0x0, 0x14(%rax)
leaq 0x48(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %cl, (%rax)
leaq 0x60(%rsp), %r13
leaq 0x8(%rsp), %rbp
movq %r13, %rdi
movq %rbx, %rsi
callq 0x54d6
movq %rbp, %rdi
movq %r13, %rsi
callq 0x3e8e
movl (%rax), %r12d
movb 0x30(%rsp), %r15b
movq %r13, %rdi
callq 0x3d0a
cmpl $0x3, %r12d
jne 0x3a36
cmpb $0x5e, %r15b
jne 0x3a36
incl 0x8(%r14)
jmp 0x39fe
cmpl $0x7, 0x8(%rsp)
jne 0x3b0f
leaq 0x8(%rsp), %rsi
movq (%rsp), %rdi
callq 0x2a12
movq %rax, (%r14)
leaq 0x60(%rsp), %rdi
movq %rbx, %rsi
callq 0x54d6
leaq 0x8(%rsp), %r12
leaq 0x60(%rsp), %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0x3e8e
movq %r13, %rdi
callq 0x3d0a
cmpl $0x3, (%r12)
jne 0x3b27
cmpb $0x5b, 0x30(%rsp)
jne 0x3b27
andl $0x0, 0xc(%r14)
leaq 0x60(%rsp), %rdi
movq %rbx, %rsi
callq 0x54d6
leaq 0x8(%rsp), %r12
leaq 0x60(%rsp), %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0x3e8e
movq %r13, %rdi
callq 0x3d0a
cmpl $0x2, (%r12)
jne 0x3af7
movl 0x34(%rsp), %eax
movl %eax, 0xc(%r14)
leaq 0x60(%rsp), %rdi
movq %rbx, %rsi
callq 0x54d6
leaq 0x8(%rsp), %rdi
leaq 0x60(%rsp), %r12
movq %r12, %rsi
callq 0x3e8e
movq %r12, %rdi
callq 0x3d0a
leaq 0x8(%rsp), %rdi
pushq $0x5d
popq %rsi
callq 0x5716
testb %al, %al
jne 0x3b2f
xorl %ebp, %ebp
jmp 0x3bb9
leaq 0x3627(%rip), %rdx      # 0x713d
xorl %ebp, %ebp
movq %rbx, %rsi
xorl %eax, %eax
callq 0x2fbe
jmp 0x3bb9
movq %rbx, %rdi
callq 0x570e
leaq 0x60(%rsp), %rdi
movq %rbx, %rsi
callq 0x54d6
leaq 0x8(%rsp), %r12
leaq 0x60(%rsp), %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0x3e8e
movq %r13, %rdi
callq 0x3d0a
cmpl $0x3, (%r12)
jne 0x3bae
cmpb $0x7c, 0x30(%rsp)
jne 0x3bae
leaq 0x60(%rsp), %rdi
movq %rbx, %rsi
callq 0x54d6
leaq 0x8(%rsp), %r12
leaq 0x60(%rsp), %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0x3e8e
movq %r13, %rdi
callq 0x3d0a
cmpl $0x7, (%r12)
jne 0x3bd7
addq $0x10, %r14
movb $0x1, %bpl
movq %r14, %rdi
leaq 0x10(%rsp), %rsi
callq 0x2130
jmp 0x3bb9
movb $0x1, %bpl
movq %rbx, %rdi
callq 0x570e
leaq 0x8(%rsp), %rdi
callq 0x3d0a
movl %ebp, %eax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x357e(%rip), %rdx      # 0x715c
jmp 0x3b16
jmp 0x3bef
jmp 0x3bef
jmp 0x3bef
jmp 0x3bef
jmp 0x3bef
jmp 0x3bef
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x3d0a
movq %rbx, %rdi
callq 0x23a0