// File: /workspace/github_c_makefile_star2_O3/sisshiki1969[P]monocc/src/parse.c
// Function: parse_prim_expr
Node *parse_prim_expr() {
  Token *cur_token = token;
  if (at_eof()) {
    error_at_token(token, "Unexpected EOF.");
  }
  if (peek(TK_NUM)) {
    Token *t = consume();
    Node *node = new_node_num(t->num_val, cur_token);
    node->type = t->num_ty;
    return node;
  }
  if (peek(TK_STR)) {
    Token *tok = consume();
    Token *t = tok;
    while (peek(TK_STR)) {
      t->next = consume();
      t = t->next;
    }
    t->next = NULL;
    Node *node = new_node_str(tok);

    return node;
  }
  if (consume_if(TK_OP_PAREN)) {
    Node *node = parse_expr();
    expect(TK_CL_PAREN);
    return node;
  }
  if (consume_if(TK_IDENT)) {
    LVar *lvar = find_lvar(cur_token);
    if (lvar) return new_node_lvar(lvar, cur_token);
    Global *gvar = find_gvar(cur_token);
    if (gvar) return new_node_gvar(gvar, cur_token);
    TagName *tag = find_tag(cur_token);
    if (tag && is_enum_el(tag->type)) {
      return new_node_num(tag->type->offset, cur_token);
    }
    if (peek(TK_OP_PAREN)) {
      if (find_func(cur_token)) return new_node_ident(cur_token);
    }
    error_at_token(cur_token, "Identifier is not defined.");
  }
  if (consume_if(TK_MACRO)) {
    if (strncmp(cur_token->str, "__LINE__", 8) == 0) {
      int line_no = get_line(cur_token->str, source_text);
      return new_node_num(line_no, cur_token);
    }
  }
  if (is_type_specifier(token))
    error_at_token(token, "Can not use declaration here.");
  error_at_token(token, "parse_prim_expr(): Unexpected token.");
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
leaq 0xcce0(%rip), %r12      # 0x13228
movq (%r12), %rbx
movl (%rbx), %eax
movq %rbx, %r14
cmpl $0x41, %eax
jne 0x656e
leaq 0x6ea4(%rip), %rsi      # 0xd401
movq %rbx, %rdi
xorl %eax, %eax
callq 0x52cd
movq (%r12), %r14
movl (%r14), %eax
cmpl $0x1, %eax
jg 0x65c0
testl %eax, %eax
je 0x6606
cmpl $0x1, %eax
jne 0x673c
movq 0x8(%r14), %rax
movq %rax, (%r12)
movq 0x10(%r14), %r12
movl $0x1, %edi
movl $0x68, %esi
callq 0x10d0
movq %rax, %r15
movl $0x1, (%rax)
movq %r12, 0x20(%rax)
movq %rbx, 0x50(%rax)
xorl %eax, %eax
callq 0xac48
movq 0x18(%r14), %rax
jmp 0x66b1
cmpl $0x2, %eax
je 0x663c
cmpl $0x1d, %eax
jne 0x673c
movq 0x8(%r14), %rax
movq %rax, (%r12)
callq 0x76ae
movq %rax, %r15
movq (%r12), %rdi
cmpl $0x1e, (%rdi)
je 0x65f9
leaq 0x6e78(%rip), %rsi      # 0xd466
xorl %eax, %eax
callq 0x52cd
movq (%r12), %rdi
movq 0x8(%rdi), %rax
movq %rax, (%r12)
jmp 0x67ab
movq 0x8(%r14), %r15
movq %r15, (%r12)
movq %rbx, %rdi
callq 0x627e
testq %rax, %rax
je 0x6681
movq %rax, %r14
movl $0x1, %edi
movl $0x68, %esi
callq 0x10d0
movq %rax, %r15
movl $0x18, (%rax)
movq %r14, 0x30(%rax)
jmp 0x66a9
movq 0x8(%r14), %rax
movq %rax, (%r12)
cmpl $0x2, (%rax)
movq %r14, %rcx
jne 0x6666
movq %r14, %rdx
movq %rax, %rcx
movq 0x8(%rax), %rax
movq %rcx, 0x8(%rdx)
cmpl $0x2, (%rax)
movq %rcx, %rdx
je 0x664f
movq %rax, (%r12)
movq $0x0, 0x8(%rcx)
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x58a3
movq %rbx, %rdi
callq 0x6364
testq %rax, %rax
je 0x66ba
movq %rax, %r14
movl $0x1, %edi
movl $0x68, %esi
callq 0x10d0
movq %rax, %r15
movl $0x19, (%rax)
movq %rbx, 0x50(%rax)
movq 0x10(%r14), %rax
movq %rax, 0x58(%r15)
jmp 0x67ab
movq %rbx, %rdi
callq 0x647f
testq %rax, %rax
je 0x66f6
movq %rax, %r14
movq 0x10(%rax), %rdi
callq 0xad97
testb %al, %al
je 0x66f2
movq 0x10(%r14), %rax
movslq 0x28(%rax), %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x5864
movq (%r12), %r15
cmpl $0x1d, (%r15)
jne 0x6724
movq %rbx, %rdi
callq 0x63ef
testq %rax, %rax
je 0x6724
movl $0x1, %edi
movl $0x68, %esi
callq 0x10d0
movq %rax, %r15
movq %rbx, 0x50(%rax)
jmp 0x67ab
leaq 0x6ce6(%rip), %rsi      # 0xd411
movq %rbx, %rdi
xorl %eax, %eax
callq 0x52cd
movq (%r12), %r14
movl (%r14), %eax
cmpl $0x42, %eax
jne 0x6768
movq 0x8(%r14), %r14
movq %r14, (%r12)
movq 0x20(%rbx), %r15
leaq 0x6cd8(%rip), %rsi      # 0xd42c
movl $0x8, %edx
movq %r15, %rdi
callq 0x1050
testl %eax, %eax
je 0x67ba
movl (%r14), %eax
leal -0x34(%rax), %ecx
cmpl $0x8, %ecx
jb 0x6785
addl $-0x3d, %eax
cmpl $0x2, %eax
jb 0x6785
movq %r14, %rdi
callq 0x6217
testq %rax, %rax
je 0x679a
leaq 0x6ca9(%rip), %rsi      # 0xd435
movq %r14, %rdi
xorl %eax, %eax
callq 0x52cd
movq (%r12), %r14
leaq 0x6cb2(%rip), %rsi      # 0xd453
movq %r14, %rdi
xorl %eax, %eax
callq 0x52cd
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0xca4f(%rip), %rax      # 0x13210
movq (%rax), %rsi
movq %r15, %rdi
callq 0x502c
movslq %eax, %r14
movl $0x1, %edi
movl $0x68, %esi
callq 0x10d0
movq %rax, %r15
movl $0x1, (%rax)
movq %r14, 0x20(%rax)
movq %rbx, 0x50(%rax)
xorl %eax, %eax
callq 0xac48
jmp 0x66b1