// File: /workspace/github_c_makefile_star2_O2/sisshiki1969[P]monocc/src/parse.c
// Function: parse_postfix_expr
Node *parse_postfix_expr() {
  Node *node = parse_prim_expr();
  while (true) {
    Token *op_token = token;
    if (consume_if(TK_OP_PAREN)) {
      /*
      if (node->kind != ND_IDENT)
        error_at_node(node, "Currently, callee must be an identifier.");*/
      Function *fn = find_func(node->token);
      if (!fn) error_at_node(node, "Undefined identifier.");
      node->type = fn->type->ptr_to;
      Vector *vec = vec_new();
      Token *op_token = token;
      MemberInfo *param = fn->type->params;
      while (!peek(TK_CL_PAREN)) {
        if (!param && !fn->type->variadic)
          error_at_token(token, "Too many arguments in func call.");
        Node *arg = parse_assign_expr();
        if (is_array(type(arg)))
          arg = new_node_expr(ND_ADDR, arg, NULL, arg->token);
        if (param && !is_compatible_type(param->type, type(arg))) {
          error_types(param->type, type(arg));
          error_at_node(arg, "The type of an argument is mismatch %s",
                        "with func parameter.");
        }
        if (param) {
          Type *ty_from = type(arg);
          Type *ty_to = param->type;
          arg = new_node_cast(arg, ty_to, arg->token);
        }

        vec_push(vec, arg);
        if (param) param = param->next;
        if (!consume_if(TK_COMMA)) break;
      }
      if (param) error_at_token(token, "Too few arguments in func call.");
      expect(TK_CL_PAREN);
      node = new_node_call(node, vec, node->token);
    } else if (consume_if(TK_OP_BRACKET)) {
      // ary[index] -> *(ary + index * sizeof(ary))
      if (!is_array(type(node)) && !is_ptr(type(node)))
        error_at_node(node, "Subscripted value is neither array nor pointer.");
      Node *offset = parse_expr();
      node = pointer_add(node, offset, token);
      /*int size = sizeof_type(type(node)->ptr_to);
      offset =
          new_node_binary(ND_MUL, offset, new_node_num(size, token), token);
      node = new_node_binary(ND_ADD, node, offset, token);*/
      node = new_node_expr(ND_DEREF, node, NULL, token);
      expect(TK_CL_BRACKET);
    } else if (consume_if(TK_INC)) {
      Node *rhs =
          new_node_binary(ND_ADD, node, new_node_num(1, op_token), op_token);
      node = new_node_expr(ND_ASSIGN, node, rhs, op_token);
      node = new_node_binary(ND_SUB, node, new_node_num(1, op_token), op_token);
    } else if (consume_if(TK_DEC)) {
      Node *rhs =
          new_node_binary(ND_SUB, node, new_node_num(1, op_token), op_token);
      node = new_node_expr(ND_ASSIGN, node, rhs, op_token);
      node = new_node_binary(ND_ADD, node, new_node_num(1, op_token), op_token);
    } else if (consume_if(TK_DOT)) {
      if (!is_struct(type(node)))
        error_at_node(
            node,
            "Request for member 'a' in something not a structure or union.");
      node = new_node_member(node, consume_ident());
    } else if (consume_if(TK_ARROW)) {
      if (!is_ptr(type(node)) || !is_struct(type(node)->ptr_to))
        error_at_node(node, "Invalid type argument of '->'.");
      node = new_node_binary(ND_DEREF, node, NULL, op_token);
      node = new_node_member(node, consume_ident());
    } else
      return node;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
callq 0x5d65
movq %rax, %r15
leaq 0xb1f9(%rip), %r14      # 0x11228
pushq $0x1
popq %r12
pushq $0x4
popq %rbp
pushq $0x15
popq %r13
movq (%r14), %rbx
movl (%rbx), %eax
leal -0x1d(%rax), %ecx
cmpl $0x9, %ecx
ja 0x60ce
leaq 0x517e(%rip), %rdx      # 0xb1d0
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
movq 0x8(%rbx), %rax
movq %rax, (%r14)
movq %r15, %rdi
callq 0x9610
movq %rax, %rdi
callq 0x919f
testb %al, %al
jne 0x609b
movq %r15, %rdi
callq 0x9610
movq %rax, %rdi
callq 0x9198
testb %al, %al
jne 0x609b
movq %r15, %rdi
leaq 0x545f(%rip), %rsi      # 0xb4f3
xorl %eax, %eax
callq 0x4a9e
callq 0x6ac5
movq (%r14), %rdx
movq %r15, %rdi
movq %rax, %rsi
callq 0x5f79
movq (%r14), %rcx
pushq $0x17
popq %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x54df
movq %rax, %r15
pushq $0x22
popq %rdi
callq 0x5a46
jmp 0x603a
cmpl $0x12, %eax
je 0x61cb
cmpl $0x13, %eax
jne 0x639f
movq 0x8(%rbx), %rax
movq %rax, (%r14)
movq %r12, %rdi
movq %rbx, %rsi
callq 0x5200
pushq $0x5
popq %rdi
movq %r15, %rsi
movq %rax, %rdx
movq %rbx, %rcx
callq 0x5422
movl %r13d, %edi
movq %r15, %rsi
movq %rax, %rdx
movq %rbx, %rcx
callq 0x54df
movq %rax, %r14
movq %r12, %rdi
movq %rbx, %rsi
callq 0x5200
movl %ebp, %edi
jmp 0x620f
movq 0x8(%rbx), %rax
movq %rax, (%r14)
movq %r15, %rdi
callq 0x9610
movq %rax, %rdi
callq 0x91ad
testb %al, %al
jne 0x6155
movq %r15, %rdi
leaq 0x53d5(%rip), %rsi      # 0xb523
xorl %eax, %eax
callq 0x4a9e
callq 0x5a19
movq %r15, %rdi
jmp 0x61bb
movq 0x8(%rbx), %rax
movq %rax, (%r14)
movq %r15, %rdi
callq 0x9610
movq %rax, %rdi
callq 0x9198
testb %al, %al
je 0x618f
movq %r15, %rdi
callq 0x9610
movq 0x8(%rax), %rdi
callq 0x91ad
testb %al, %al
jne 0x61a0
movq %r15, %rdi
leaq 0x53c8(%rip), %rsi      # 0xb561
xorl %eax, %eax
callq 0x4a9e
pushq $0x17
popq %rdi
movq %r15, %rsi
xorl %edx, %edx
movq %rbx, %rcx
callq 0x5422
movq %rax, %rbx
callq 0x5a19
movq %rbx, %rdi
movq %rax, %rsi
callq 0x5515
movq %rax, %r15
jmp 0x603a
movq 0x8(%rbx), %rax
movq %rax, (%r14)
movq %r12, %rdi
movq %rbx, %rsi
callq 0x5200
movl %ebp, %edi
movq %r15, %rsi
movq %rax, %rdx
movq %rbx, %rcx
callq 0x5422
movl %r13d, %edi
movq %r15, %rsi
movq %rax, %rdx
movq %rbx, %rcx
callq 0x54df
movq %rax, %r14
movq %r12, %rdi
movq %rbx, %rsi
callq 0x5200
pushq $0x5
popq %rdi
movq %r14, %rsi
leaq 0xb00f(%rip), %r14      # 0x11228
movq %rax, %rdx
movq %rbx, %rcx
callq 0x5422
movq %rax, %r15
jmp 0x603a
movq 0x8(%rbx), %rax
movq %rax, (%r14)
movq 0x50(%r15), %rdi
callq 0x5c59
movq %rax, %rbx
testq %rax, %rax
jne 0x6255
movq %r15, %rdi
leaq 0x5212(%rip), %rsi      # 0xb460
xorl %eax, %eax
callq 0x4a9e
movq 0x10(%rbx), %rax
movq 0x8(%rax), %rax
movq %rax, 0x58(%r15)
xorl %eax, %eax
callq 0x34c8
movq %rax, %r12
movq 0x10(%rbx), %rax
movq 0x18(%rax), %r13
movq (%r14), %rdi
cmpl $0x1e, (%rdi)
je 0x636d
testq %r13, %r13
jne 0x629c
movq 0x10(%rbx), %rax
cmpb $0x0, 0x38(%rax)
jne 0x629c
leaq 0x51e1(%rip), %rsi      # 0xb476
xorl %eax, %eax
callq 0x48b3
callq 0x6ac5
movq %rax, %rbp
movq %rax, %rdi
callq 0x9610
movq %rax, %rdi
callq 0x919f
testb %al, %al
je 0x62cc
movq 0x50(%rbp), %rcx
pushq $0x16
popq %rdi
movq %rbp, %rsi
xorl %edx, %edx
callq 0x54df
movq %rax, %rbp
testq %r13, %r13
je 0x634b
movq 0x10(%r13), %r14
movq %rbp, %rdi
callq 0x9610
movq %r14, %rdi
movq %rax, %rsi
callq 0x94a5
testb %al, %al
jne 0x631b
movq 0x10(%r13), %r14
movq %rbp, %rdi
callq 0x9610
movq %r14, %rdi
movq %rax, %rsi
callq 0x98a4
movq %rbp, %rdi
leaq 0x518a(%rip), %rsi      # 0xb497
leaq 0x51aa(%rip), %rdx      # 0xb4be
xorl %eax, %eax
callq 0x4a9e
movq %rbp, %rdi
callq 0x9610
movq 0x10(%r13), %rsi
movq 0x50(%rbp), %rdx
movq %rbp, %rdi
callq 0x565c
movq %r12, %rdi
movq %rax, %rsi
callq 0x34f6
movq (%r13), %r13
leaq 0xaedf(%rip), %r14      # 0x11228
jmp 0x6359
movq %r12, %rdi
movq %rbp, %rsi
callq 0x34f6
xorl %r13d, %r13d
movq (%r14), %rdi
cmpl $0x23, (%rdi)
jne 0x636d
movq 0x8(%rdi), %rdi
movq %rdi, (%r14)
jmp 0x6276
testq %r13, %r13
je 0x6380
leaq 0x515a(%rip), %rsi      # 0xb4d3
xorl %eax, %eax
callq 0x48b3
pushq $0x1e
popq %rdi
callq 0x5a46
movq 0x50(%r15), %rdx
movq %r15, %rdi
movq %r12, %rsi
callq 0x5681
movq %rax, %r15
jmp 0x602f
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq