// File: /workspace/github_c_makefile_star2_O1/chgzm[P]minic/parser.c
// Function: create_declaration_node
static DeclarationNode* create_declaration_node(const Vector* vec, int* index) {
    DeclarationNode* declaration_node = malloc(sizeof(DeclarationNode));

    declaration_node->decl_specifier_nodes  = create_vector();
    declaration_node->init_declarator_nodes = create_vector();

    const Token* token = vec->elements[*index];
    while (is_declaration_specifier(vec, *index) && token->type != TK_SEMICOL) {
        DeclSpecifierNode* decl_specifier_node = create_decl_specifier_node(vec, index);
        if (decl_specifier_node == NULL) {
            error("Failed to create declaration-specifier node.\n");
            return NULL;
        }

        vector_push_back(declaration_node->decl_specifier_nodes, decl_specifier_node);
    }

    token = vec->elements[*index];
    while (token->type != TK_SEMICOL) {
        InitDeclaratorNode* init_declarator_node = create_init_declarator_node(vec, index);
        if (init_declarator_node == NULL) {
            error("Failed to create init-declarator node.\n");
            return NULL;
        }

        vector_push_back(declaration_node->init_declarator_nodes, init_declarator_node);

        token = vec->elements[*index];
        if (token->type == TK_COMMA) {
            ++(*index);
            token = vec->elements[*index];
        } 
    }
    ++(*index);

    return declaration_node;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %r15
movl $0x10, %edi
callq 0x1100
movq %rax, %rbx
xorl %eax, %eax
callq 0x8b08
movq %rax, %r13
movq %rax, (%rbx)
xorl %eax, %eax
callq 0x8b08
movq %rax, %r12
movq %rbx, (%rsp)
movq %rax, 0x8(%rbx)
movq (%r15), %rax
movslq (%r14), %rcx
movq (%rax,%rcx,8), %rbp
movslq (%r14), %rsi
movq (%r15), %rax
movq (%rax,%rsi,8), %rax
movl (%rax), %ebx
movq %r15, %rdi
callq 0x5ac1
testb %al, %al
jne 0x541c
andl $-0x9, %ebx
cmpl $0x4, %ebx
jne 0x545a
cmpl $0x1f, (%rbp)
je 0x545a
movq %r15, %rdi
movq %r14, %rsi
callq 0x5537
movq %rax, %rbx
testq %rax, %rax
je 0x5442
movq %r13, %rdi
movq %rbx, %rsi
callq 0x8b3b
jmp 0x5450
leaq 0x5a6a(%rip), %rdi      # 0xaeb3
xorl %eax, %eax
callq 0x8a7c
testq %rbx, %rbx
jne 0x53fc
jmp 0x551d
movq (%r15), %rax
movslq (%r14), %rcx
movq (%rax,%rcx,8), %r13
leaq 0x626e(%rip), %rbx      # 0xb6d9
cmpl $0x1f, (%r13)
je 0x5521
movl $0x1, %edi
movl $0x10, %esi
callq 0x10c0
movq %rax, %rbp
movq %r15, %rdi
movq %r14, %rsi
callq 0x55b4
movq %rax, (%rbp)
movq %rbx, %rdi
testq %rax, %rax
je 0x54ce
movq (%r15), %rcx
movslq (%r14), %rax
movq (%rcx,%rax,8), %rcx
cmpl $0x1e, (%rcx)
jne 0x54d7
incl %eax
movl %eax, (%r14)
movq %r15, %rdi
movq %r14, %rsi
callq 0x78f5
movq %rax, 0x8(%rbp)
leaq 0x6233(%rip), %rdi      # 0xb6fc
testq %rax, %rax
jne 0x54d7
xorl %eax, %eax
callq 0x8a7c
xorl %ebp, %ebp
testq %rbp, %rbp
je 0x5506
movq %r12, %rdi
movq %rbp, %rsi
callq 0x8b3b
movq (%r15), %rax
movslq (%r14), %rcx
movq (%rax,%rcx,8), %r13
cmpl $0x30, (%r13)
jne 0x5514
leaq 0x1(%rcx), %rdx
movl %edx, (%r14)
movq 0x8(%rax,%rcx,8), %r13
jmp 0x5514
leaq 0x61a4(%rip), %rdi      # 0xb6b1
xorl %eax, %eax
callq 0x8a7c
testq %rbp, %rbp
jne 0x546b
xorl %eax, %eax
jmp 0x5528
incl (%r14)
movq (%rsp), %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq