// File: /workspace/github_c_makefile_star2_O3/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 0x8738
movq %rax, %r13
movq %rax, (%rbx)
xorl %eax, %eax
callq 0x8738
movq %rax, %r12
movq %rbx, (%rsp)
movq %rax, 0x8(%rbx)
movq (%r15), %rdi
movslq (%r14), %rsi
movq (%rdi,%rsi,8), %rbp
movl (%rbp), %ebx
callq 0x59c5
testb %al, %al
jne 0x5390
andl $-0x9, %ebx
cmpl $0x4, %ebx
jne 0x53c3
cmpl $0x1f, (%rbp)
je 0x53c3
movq %r15, %rdi
movq %r14, %rsi
callq 0x54a9
testq %rax, %rax
je 0x546f
movq %r13, %rdi
movq %rax, %rsi
callq 0x876b
movslq (%r14), %rsi
movq (%r15), %rdi
movq (%rdi,%rsi,8), %rax
movl (%rax), %ebx
jmp 0x537f
movq (%r15), %rcx
movslq (%r14), %rax
movq (%rcx,%rax,8), %rcx
cmpl $0x1f, (%rcx)
je 0x5464
leaq 0x52c3(%rip), %r13      # 0xa6a0
leaq 0x52df(%rip), %rbx      # 0xa6c3
movl $0x1, %edi
movl $0x10, %esi
callq 0x10c0
movq %rax, %rbp
movq %r15, %rdi
movq %r14, %rsi
callq 0x5523
movq %rax, (%rbp)
testq %rax, %rax
je 0x547d
movq (%r15), %rcx
movslq (%r14), %rax
movq (%rcx,%rax,8), %rcx
cmpl $0x1e, (%rcx)
jne 0x5432
incl %eax
movl %eax, (%r14)
movq %r15, %rdi
movq %r14, %rsi
callq 0x7553
movq %rax, 0x8(%rbp)
testq %rax, %rax
je 0x547a
movq %r12, %rdi
movq %rbp, %rsi
callq 0x876b
movq (%r15), %rcx
movl (%r14), %eax
movslq %eax, %rdx
movq (%rcx,%rdx,8), %rsi
movl (%rsi), %esi
cmpl $0x30, %esi
jne 0x545f
leaq 0x1(%rdx), %rax
movl %eax, (%r14)
movq 0x8(%rcx,%rdx,8), %rcx
movl (%rcx), %esi
cmpl $0x1f, %esi
jne 0x53e4
incl %eax
movl %eax, (%r14)
movq (%rsp), %rbx
jmp 0x5497
leaq 0x4a3d(%rip), %rdi      # 0x9eb3
xorl %ebx, %ebx
jmp 0x5490
movq %rbx, %r13
xorl %ebx, %ebx
movq %r13, %rdi
xorl %eax, %eax
callq 0x86ac
leaq 0x51e8(%rip), %rdi      # 0xa678
xorl %eax, %eax
callq 0x86ac
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq