// File: /workspace/github_c_makefile_star2_O0/chgzm[P]minic/parser.c
// Function: create_primary_expr_node
static PrimaryExprNode* create_primary_expr_node(const Vector* vec, int* index) {
    PrimaryExprNode* primary_expr_node = calloc(1, sizeof(PrimaryExprNode));

    const Token* token = vec->elements[*index];
    switch (token->type) {
    case TK_IDENT: {
        primary_expr_node->identifier = strdup(token->str);
        ++(*index);
        break;
    }
    case TK_NUM:
    case TK_BYTE:
    case TK_STR: {
        primary_expr_node->constant_node = create_constant_node(vec, index);
        if (primary_expr_node->constant_node == NULL) {
            error("Failed to create constant node.\n");
            return NULL;
        }
        break;
    }
    case TK_LPAREN: {
        ++(*index);
        primary_expr_node->expr_node = create_expr_node(vec, index);
        if (primary_expr_node->expr_node == NULL) {
            error("Failed to create expression-node.\n");
            return NULL;
        }

        Token* rparen_token = vec->elements[*index];
        if (rparen_token->type != TK_RPAREN) {
            error("Invalid token[%d]=\"%s\".\n", *index, decode_token_type(rparen_token->type));
            return NULL;
        }
        ++(*index);

        break;
    }
    default: {
        error("Invalid token[%d]=\"%s\".\n", *index, decode_token_type(token->type));
        return NULL;
    }
    }

    return primary_expr_node;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl $0x1, %edi
movl $0x28, %esi
callq 0x10b0
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x34(%rbp)
subl $0x3, %eax
jb 0xa748
jmp 0xa709
movl -0x34(%rbp), %eax
subl $0x3, %eax
je 0xa720
jmp 0xa713
movl -0x34(%rbp), %eax
subl $0x21, %eax
je 0xa789
jmp 0xa830
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x1170
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x18(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
jmp 0xa862
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xaaf0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
cmpq $0x0, (%rax)
jne 0xa784
leaq 0x5dac(%rip), %rdi      # 0x1051c
movb $0x0, %al
callq 0xe4e0
movq $0x0, -0x8(%rbp)
jmp 0xa86a
jmp 0xa862
movq -0x18(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x91a0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0xa7d2
leaq 0x5d7f(%rip), %rdi      # 0x1053d
movb $0x0, %al
callq 0xe4e0
movq $0x0, -0x8(%rbp)
jmp 0xa86a
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x22, (%rax)
je 0xa823
movq -0x18(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x38(%rbp)
movq -0x30(%rbp), %rax
movl (%rax), %edi
callq 0xe050
movl -0x38(%rbp), %esi
movq %rax, %rdx
leaq 0x571e(%rip), %rdi      # 0xff30
movb $0x0, %al
callq 0xe4e0
movq $0x0, -0x8(%rbp)
jmp 0xa86a
movq -0x18(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
jmp 0xa862
movq -0x18(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x3c(%rbp)
movq -0x28(%rbp), %rax
movl (%rax), %edi
callq 0xe050
movl -0x3c(%rbp), %esi
movq %rax, %rdx
leaq 0x56df(%rip), %rdi      # 0xff30
movb $0x0, %al
callq 0xe4e0
movq $0x0, -0x8(%rbp)
jmp 0xa86a
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)