// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x2c0, %rsp            # imm = 0x2C0
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x2a0(%rbp)
movq -0x18(%rbp), %rax
movl $0x0, 0x8(%rax)
movq -0x18(%rbp), %rax
movl $0xffffffff, 0xc(%rax)  # imm = 0xFFFFFFFF
leaq -0x78(%rbp), %rdi
callq 0x6860
movq -0x20(%rbp), %rsi
leaq -0xd0(%rbp), %rdi
callq 0xc500
jmp 0x6373
leaq -0x78(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x6c90
movq %rax, %rcx
xorl %eax, %eax
cmpl $0x3, (%rcx)
movb %al, -0x2a1(%rbp)
jne 0x63a3
movsbl -0x50(%rbp), %eax
cmpl $0x5e, %eax
sete %al
movb %al, -0x2a1(%rbp)
movb -0x2a1(%rbp), %al
movb %al, -0x2a2(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x68a0
movb -0x2a2(%rbp), %al
testb $0x1, %al
jne 0x63c7
jmp 0x63f6
movq -0x18(%rbp), %rax
movl 0x8(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x8(%rax)
jmp 0x6361
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd8(%rbp)
movl %eax, -0xdc(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x68a0
jmp 0x6636
cmpl $0x7, -0x78(%rbp)
je 0x642a
movq -0x2a0(%rbp), %rdi
movq -0x20(%rbp), %rsi
leaq 0xad2f(%rip), %rdx      # 0x1113d
xorl %eax, %eax
callq 0x52f0
jmp 0x6417
movb $0x0, -0x1(%rbp)
movl $0x1, -0xe0(%rbp)
jmp 0x661f
movq -0x2a0(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x4800
movq %rax, -0x2b0(%rbp)
jmp 0x6443
movq -0x2b0(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rsi
leaq -0x138(%rbp), %rdi
callq 0xc500
jmp 0x6463
leaq -0x78(%rbp), %rdi
leaq -0x138(%rbp), %rsi
callq 0x6c90
leaq -0x138(%rbp), %rdi
callq 0x68a0
cmpl $0x3, -0x78(%rbp)
jne 0x6544
movsbl -0x50(%rbp), %eax
cmpl $0x5b, %eax
jne 0x6544
movq -0x18(%rbp), %rax
movl $0x0, 0xc(%rax)
movq -0x20(%rbp), %rsi
leaq -0x190(%rbp), %rdi
callq 0xc500
jmp 0x64b3
leaq -0x78(%rbp), %rdi
leaq -0x190(%rbp), %rsi
callq 0x6c90
leaq -0x190(%rbp), %rdi
callq 0x68a0
cmpl $0x2, -0x78(%rbp)
jne 0x650d
movl -0x4c(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x20(%rbp), %rsi
leaq -0x1e8(%rbp), %rdi
callq 0xc500
jmp 0x64f1
leaq -0x78(%rbp), %rdi
leaq -0x1e8(%rbp), %rsi
callq 0x6c90
leaq -0x1e8(%rbp), %rdi
callq 0x68a0
leaq -0x78(%rbp), %rdi
movl $0x5d, %esi
callq 0xc990
movb %al, -0x2b1(%rbp)
jmp 0x6523
movb -0x2b1(%rbp), %al
testb $0x1, %al
jne 0x6542
jmp 0x652f
movb $0x0, -0x1(%rbp)
movl $0x1, -0xe0(%rbp)
jmp 0x661f
jmp 0x6551
movq -0x20(%rbp), %rdi
callq 0xc970
jmp 0x654f
jmp 0x6551
movq -0x20(%rbp), %rsi
leaq -0x240(%rbp), %rdi
callq 0xc500
jmp 0x6563
leaq -0x78(%rbp), %rdi
leaq -0x240(%rbp), %rsi
callq 0x6c90
leaq -0x240(%rbp), %rdi
callq 0x68a0
cmpl $0x3, -0x78(%rbp)
jne 0x6604
movsbl -0x50(%rbp), %eax
cmpl $0x7c, %eax
jne 0x6604
movq -0x20(%rbp), %rsi
leaq -0x298(%rbp), %rdi
callq 0xc500
jmp 0x65a0
leaq -0x78(%rbp), %rdi
leaq -0x298(%rbp), %rsi
callq 0x6c90
leaq -0x298(%rbp), %rdi
callq 0x68a0
cmpl $0x7, -0x78(%rbp)
je 0x65ed
movq -0x2a0(%rbp), %rdi
movq -0x20(%rbp), %rsi
leaq 0xab88(%rip), %rdx      # 0x1115c
xorl %eax, %eax
callq 0x52f0
jmp 0x65dd
movb $0x0, -0x1(%rbp)
movl $0x1, -0xe0(%rbp)
jmp 0x661f
leaq -0x70(%rbp), %rsi
movq -0x18(%rbp), %rdi
addq $0x10, %rdi
callq 0x3050
jmp 0x6600
jmp 0x6602
jmp 0x6611
movq -0x20(%rbp), %rdi
callq 0xc970
jmp 0x660f
jmp 0x6611
movb $0x1, -0x1(%rbp)
movl $0x1, -0xe0(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x68a0
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x2c0, %rsp            # imm = 0x2C0
popq %rbp
retq
movq -0xd8(%rbp), %rdi
callq 0x3490
nopw %cs:(%rax,%rax)