// File: /workspace/github_c_makefile_star2_O1/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 0xcc98(%rip), %r12      # 0x13228
movq (%r12), %rbx
cmpl $0x41, (%rbx)
jne 0x65aa
leaq 0x6e25(%rip), %rsi      # 0xd3c5
movq %rbx, %rdi
xorl %eax, %eax
callq 0x52f9
movq (%r12), %r15
movl (%r15), %eax
cmpl $0x1, %eax
jg 0x6607
testl %eax, %eax
je 0x664d
cmpl $0x1, %eax
jne 0x670a
movq 0x8(%r15), %rax
movq %rax, (%r12)
movq 0x10(%r15), %r12
movl $0x1, %edi
movl $0x68, %esi
callq 0x10d0
movq %rax, %r14
movl $0x1, (%rax)
movq %r12, 0x20(%rax)
movq %rbx, 0x50(%rax)
xorl %eax, %eax
callq 0xad70
movq %rax, 0x58(%r14)
movq 0x18(%r15), %rax
jmp 0x67bb
cmpl $0x2, %eax
je 0x6683
cmpl $0x1d, %eax
jne 0x670a
movq 0x8(%r15), %rax
movq %rax, (%r12)
callq 0x77a4
movq %rax, %r14
movq (%r12), %rdi
cmpl $0x1e, (%rdi)
je 0x663c
leaq 0x6df5(%rip), %rsi      # 0xd42a
xorl %eax, %eax
callq 0x52f9
movq (%r12), %rax
movq 0x8(%rax), %rax
movq %rax, (%r12)
jmp 0x67bf
movq 0x8(%r15), %rax
movq %rax, (%r12)
movq %rbx, %rdi
callq 0x62ca
testq %rax, %rax
je 0x66c8
movq %rax, %r15
movl $0x1, %edi
movl $0x68, %esi
callq 0x10d0
movq %rax, %r14
movl $0x18, (%rax)
movq %r15, 0x30(%rax)
jmp 0x66f4
movq 0x8(%r15), %rax
movq %rax, (%r12)
cmpl $0x2, (%rax)
movq %r15, %rcx
jne 0x66ad
movq %r15, %rdx
movq %rax, %rcx
movq 0x8(%rax), %rax
movq %rcx, 0x8(%rdx)
cmpl $0x2, (%rax)
movq %rcx, %rdx
je 0x6696
movq %rax, (%r12)
movq $0x0, 0x8(%rcx)
movq %r15, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x58eb
movq %rbx, %rdi
callq 0x63ba
testq %rax, %rax
je 0x67ce
movq %rax, %r15
movl $0x1, %edi
movl $0x68, %esi
callq 0x10d0
movq %rax, %r14
movl $0x19, (%rax)
movq %rbx, 0x50(%rax)
movq 0x10(%r15), %rax
movq %rax, 0x58(%r14)
xorl %eax, %eax
testb %al, %al
je 0x67bf
movq (%r12), %rax
cmpl $0x42, (%rax)
jne 0x6737
movq 0x8(%rax), %rax
movq %rax, (%r12)
movq 0x20(%rbx), %r15
leaq 0x6cca(%rip), %rsi      # 0xd3f0
movl $0x8, %edx
movq %r15, %rdi
callq 0x1050
testl %eax, %eax
je 0x677f
movq (%r12), %rbx
movl (%rbx), %eax
leal -0x34(%rax), %ecx
cmpl $0x8, %ecx
jb 0x675a
addl $-0x3d, %eax
cmpl $0x2, %eax
jb 0x675a
movq %rbx, %rdi
callq 0x626a
testq %rax, %rax
je 0x676b
leaq 0x6c98(%rip), %rsi      # 0xd3f9
movq %rbx, %rdi
xorl %eax, %eax
callq 0x52f9
movq (%r12), %rdi
leaq 0x6ca1(%rip), %rsi      # 0xd417
xorl %eax, %eax
callq 0x52f9
jmp 0x67bf
leaq 0xca8a(%rip), %rax      # 0x13210
movq (%rax), %rsi
movq %r15, %rdi
callq 0x5050
movslq %eax, %r15
movl $0x1, %edi
movl $0x68, %esi
callq 0x10d0
movq %rax, %r14
movl $0x1, (%rax)
movq %r15, 0x20(%rax)
movq %rbx, 0x50(%rax)
xorl %eax, %eax
callq 0xad70
movq %rax, 0x58(%r14)
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq %rbx, %rdi
callq 0x64c9
testq %rax, %rax
je 0x6803
movq %rax, %r14
movq 0x10(%rax), %rdi
callq 0xaec3
testb %al, %al
je 0x6803
movq 0x10(%r14), %rax
movslq 0x28(%rax), %rdi
movq %rbx, %rsi
callq 0x58ac
movq %rax, %r14
jmp 0x6700
movq (%r12), %rax
cmpl $0x1d, (%rax)
jne 0x683a
movq %rbx, %rdi
callq 0x643f
testq %rax, %rax
je 0x683a
movl $0x1, %edi
movl $0x68, %esi
callq 0x10d0
movq %rax, %r14
movl $0x0, (%rax)
movq %rbx, 0x50(%rax)
jmp 0x6700
leaq 0x6b94(%rip), %rsi      # 0xd3d5
movq %rbx, %rdi
xorl %eax, %eax
callq 0x52f9
movb $0x1, %al
jmp 0x6702