// File: /workspace/github_c_makefile_star2_O1/hsjoihs[P]c-compiler/parse_type.c
// Function: parse_dcl_postfixes
static void parse_dcl_postfixes(const struct Token **ptr_tokvec,
                                struct Vector /*<struct TypeNode>*/ *ptr_vec)
{
	const struct Token *tokvec = *ptr_tokvec;

	struct Vector vec = *ptr_vec;

	// The parser must handle cases like `int test()[3];` (which tries to define
	// an array of functions) or `int test()()` (which tries to define a
	// function returning a function). While these declarations are semantically
	// forbidden, they are syntactically legal.
	while (1) {
		if (tokvec[0].kind == LEFT_BRACKET) {
			++tokvec;
			expect_and_consume(&tokvec, LIT_DEC_INTEGER,
			                   "an integer while parsing a declaration");
			int length = tokvec[-1].int_value;
			expect_and_consume(&tokvec, RIGHT_BRACKET,
			                   "closing ] while parsing a declaration");

			struct TypeNode a;
			a.type_category = ARRAY;
			a.array_length = length;
			struct TypeNode *ptr = calloc(1, sizeof(struct TypeNode));
			*ptr = a;
			push_vector(&vec, ptr);
			continue;
		} else if (tokvec[0].kind == LEFT_PAREN &&
		           (can_start_a_type(&tokvec[1]) ||
		            tokvec[1].kind == RIGHT_PAREN)) {
			++tokvec;
			parse_parameter_type_list(&tokvec, &vec);
			expect_and_consume(&tokvec, RIGHT_PAREN,
			                   "closing ) while parsing functional type");
			continue;
		} else {
			break;
		}
	}

	*ptr_tokvec = tokvec;
	*ptr_vec = vec;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rdi, -0x68(%rbp)
movq (%rdi), %rax
leaq -0x38(%rbp), %r15
movq %rax, (%r15)
movq %rsi, -0x70(%rbp)
movups (%rsi), %xmm0
leaq -0x50(%rbp), %r12
movaps %xmm0, (%r12)
leaq -0xa8(%rbp), %r13
leaq -0x30(%rbp), %rbx
movq -0x38(%rbp), %rax
movl (%rax), %ecx
cmpl $0x6, %ecx
je 0xa053
cmpl $0x36, %ecx
jne 0xa215
addq $0x20, %rax
movq %rax, -0x38(%rbp)
movq %r15, %rdi
movl $0x4, %esi
leaq 0x667d(%rip), %rdx      # 0x10689
callq 0x94af
movq -0x38(%rbp), %rax
movl -0x1c(%rax), %r14d
movq %r15, %rdi
movl $0x37, %esi
leaq 0x6688(%rip), %rdx      # 0x106b0
callq 0x94af
movl $0x1, %edi
movl $0x50, %esi
callq 0x10d0
movl $0x2, (%rax)
movl %r14d, 0x10(%rax)
movq %r12, %rdi
movq %rax, %rsi
callq 0x5ba7
jmp 0x9fe1
movl 0x20(%rax), %edi
leal -0x35(%rdi), %ecx
cmpl $0x16, %ecx
setb %dl
movl $0x21c229, %esi         # imm = 0x21C229
shrl %cl, %esi
cmpl $0x7, %edi
je 0xa074
andb %sil, %dl
je 0xa215
leaq 0x20(%rax), %rcx
movq %rcx, -0x38(%rbp)
xorl %edi, %edi
cmpl $0x6, (%rax)
sete %dil
xorl %eax, %eax
callq 0x243c
movq -0x38(%rbp), %rdi
movq %rdi, -0x30(%rbp)
movaps -0x50(%rbp), %xmm0
movaps %xmm0, -0x60(%rbp)
movl (%rdi), %ecx
leal -0x35(%rcx), %eax
cmpl $0x15, %eax
ja 0xa1b9
movl $0x21c029, %edx         # imm = 0x21C029
btl %eax, %edx
jae 0xa171
movl $0x3, -0xc0(%rbp)
movl $0x1, -0x98(%rbp)
callq 0x5af4
movq %rax, -0xa8(%rbp)
movq %rdx, -0xa0(%rbp)
movq %rbx, %rdi
callq 0x96c4
movq %r13, %rdi
movq %rax, %rsi
callq 0x5ba7
movq -0x30(%rbp), %rax
cmpl $0xa, (%rax)
jne 0xa11b
leaq 0x20(%rax), %rcx
movq %rcx, -0x30(%rbp)
cmpl $0x48, 0x20(%rax)
jne 0xa0df
movl $0x2, -0x98(%rbp)
addq $0x40, %rax
movq %rax, -0x30(%rbp)
movl $0x1, %edi
movl $0x50, %esi
callq 0x10d0
movl $0xa, %ecx
movq %rax, %rdi
leaq -0xc0(%rbp), %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq -0x60(%rbp), %rdi
movq %rax, %rsi
callq 0x5ba7
movq -0x30(%rbp), %rax
movq %rax, -0x38(%rbp)
movaps -0x60(%rbp), %xmm0
movaps %xmm0, -0x50(%rbp)
movq %r15, %rdi
movl $0x7, %esi
leaq 0x656f(%rip), %rdx      # 0x106d6
callq 0x94af
jmp 0x9fe1
cmpl $0x9, %eax
jne 0xa1b9
cmpl $0x7, 0x20(%rdi)
jne 0xa1f6
addq $0x20, %rdi
movq %rdi, -0x30(%rbp)
callq 0x5af4
movq %rax, %r14
movq %rdx, %r12
movl $0x1, %edi
movl $0x50, %esi
callq 0x10d0
movl $0x3, (%rax)
movq %r14, 0x18(%rax)
movq %r12, 0x20(%rax)
leaq -0x50(%rbp), %r12
movl $0x1, 0x28(%rax)
jmp 0xa13c
cmpl $0x7, %ecx
jne 0xa209
callq 0x5af4
movq %rax, %r12
movq %rdx, %r14
movl $0x1, %edi
movl $0x50, %esi
callq 0x10d0
movl $0x3, (%rax)
movq %r12, 0x18(%rax)
leaq -0x50(%rbp), %r12
movq %r14, 0x20(%rax)
movl $0x0, 0x28(%rax)
jmp 0xa13c
cmpl $0x15, %eax
ja 0xa209
movl $0x21c229, %ecx         # imm = 0x21C229
btl %eax, %ecx
jb 0xa0b8
leaq 0x64ee(%rip), %rsi      # 0x106fe
callq 0x93c4
movq -0x68(%rbp), %rcx
movq %rax, (%rcx)
movaps -0x50(%rbp), %xmm0
movq -0x70(%rbp), %rax
movups %xmm0, (%rax)
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq