// File: /workspace/github_c_makefile_star2_O0/Mithreindeir[P]ewcc/src/frontend/cdecl.c
// Function: parse_dir_declarator
int parse_dir_declarator(struct parser *p, struct declaration *decl)
{
	/*Identifier */
	struct token *t;
	if ((t = match(p, t_ident))) {
		if (decl->ident)
			syntax_error(p,
				     "Too many identifiers in declaration");
		int len = strlen(t->tok);
		decl->ident = malloc(len + 1);
		memcpy(decl->ident, t->tok, len);
		decl->ident[len] = 0;
	} else if (match(p, t_lparen) && parse_declarator(p, decl)) {
		if (!match(p, t_rparen))
			syntax_error(p,
				     "Missing right parentheses in declarator");
	} else {
		return 0;
	}
	while ((t = match(p, t_lbrack)) || (t = match(p, t_lparen))) {
		if (t->type == t_lbrack) {
			struct expr *cexpr;
			if (!(cexpr=parse_expr(p)))
				syntax_error(p, "Missing constant expression in array decl");
			if (cexpr->type != node_cnum)
				syntax_error(p, "Only constant value cexprs implemented right now");
			if (!match(p, t_rbrack))
				syntax_error(p,
					     "Missing right bracket in array declaration");
			struct type *arr;
			decl->type =
			    types_merge(decl->type, (arr=type_init(type_array)));
			arr->info.elem = CNUM(cexpr);
			node_free(cexpr);
		} else if (t->type == t_lparen) {
			/*Declaration list */
			int paramc = 0;
			char **paramv = NULL;
			struct type **paramt = NULL;
			struct declaration *d;
			while ((d = parse_param(p))) {
				paramc++;
				if (paramc == 1) {
					paramv = malloc(sizeof(char *));
					paramt =
					    malloc(sizeof(struct type *));
				} else {
					paramv =
					    realloc(paramv,
						    sizeof(char *) *
						    paramc);
					paramt =
					    realloc(paramt,
						    sizeof(struct type *) *
						    paramc);
				}
				paramv[paramc - 1] = d->ident;
				paramt[paramc - 1] = d->type;
				free(d);
				if (!match(p, t_comma))
					break;
			}
			if (!match(p, t_rparen))
				syntax_error(p,
					     "Missing right parentheses in function ptr declaration");
			struct type *fcn;
			decl->type =
			    types_merge(decl->type,
					(fcn = type_init(type_fcn)));
			fcn->info.fcn.paramc = paramc;
			fcn->info.fcn.paramv = paramv;
			fcn->info.fcn.paramt = paramt;
		}
	}
	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rdi
movl $0xc, %esi
callq 0xaab0
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
je 0x7f64
movq -0x18(%rbp), %rax
cmpq $0x0, (%rax)
je 0x7f15
movq -0x10(%rbp), %rdi
leaq 0x45e8(%rip), %rsi      # 0xc4f8
callq 0xabb0
movq -0x20(%rbp), %rax
movq (%rax), %rdi
callq 0x2050
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rdi
callq 0x20e0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movq -0x20(%rbp), %rax
movq (%rax), %rsi
movslq -0x24(%rbp), %rdx
callq 0x20d0
movq -0x18(%rbp), %rax
movq (%rax), %rax
movslq -0x24(%rbp), %rcx
movb $0x0, (%rax,%rcx)
jmp 0x7fbe
movq -0x10(%rbp), %rdi
movl $0x14, %esi
callq 0xaab0
cmpq $0x0, %rax
je 0x7fb0
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x8240
cmpl $0x0, %eax
je 0x7fb0
movq -0x10(%rbp), %rdi
movl $0x15, %esi
callq 0xaab0
cmpq $0x0, %rax
jne 0x7fae
movq -0x10(%rbp), %rdi
leaq 0x4573(%rip), %rsi      # 0xc51c
callq 0xabb0
jmp 0x7fbc
movl $0x0, -0x4(%rbp)
jmp 0x8234
jmp 0x7fbe
jmp 0x7fc0
movq -0x10(%rbp), %rdi
movl $0x16, %esi
callq 0xaab0
movq %rax, %rcx
movq %rcx, -0x20(%rbp)
movb $0x1, %al
cmpq $0x0, %rcx
movb %al, -0x61(%rbp)
jne 0x7ffc
movq -0x10(%rbp), %rdi
movl $0x14, %esi
callq 0xaab0
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
setne %al
movb %al, -0x61(%rbp)
movb -0x61(%rbp), %al
testb $0x1, %al
jne 0x8008
jmp 0x822d
movq -0x20(%rbp), %rax
cmpl $0x16, 0x14(%rax)
jne 0x80c8
movq -0x10(%rbp), %rdi
callq 0x9860
movq %rax, -0x30(%rbp)
cmpq $0x0, %rax
jne 0x8039
movq -0x10(%rbp), %rdi
leaq 0x4510(%rip), %rsi      # 0xc544
callq 0xabb0
movq -0x30(%rbp), %rax
cmpl $0x4, (%rax)
je 0x8052
movq -0x10(%rbp), %rdi
leaq 0x4521(%rip), %rsi      # 0xc56e
callq 0xabb0
movq -0x10(%rbp), %rdi
movl $0x17, %esi
callq 0xaab0
cmpq $0x0, %rax
jne 0x8076
movq -0x10(%rbp), %rdi
leaq 0x452e(%rip), %rsi      # 0xc59f
callq 0xabb0
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x70(%rbp)
movl $0x2, %edi
callq 0xb0a0
movq -0x70(%rbp), %rdi
movq %rax, %rsi
movq %rsi, -0x38(%rbp)
callq 0xb0e0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movl %eax, %ecx
movq -0x38(%rbp), %rax
movl %ecx, (%rax)
movq -0x30(%rbp), %rdi
callq 0x7660
jmp 0x8228
movq -0x20(%rbp), %rax
cmpl $0x14, 0x14(%rax)
jne 0x8226
movl $0x0, -0x3c(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
movq -0x10(%rbp), %rdi
callq 0x82e0
movq %rax, -0x58(%rbp)
cmpq $0x0, %rax
je 0x81b0
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
cmpl $0x1, -0x3c(%rbp)
jne 0x8131
movl $0x8, %edi
callq 0x20e0
movq %rax, -0x48(%rbp)
movl $0x8, %edi
callq 0x20e0
movq %rax, -0x50(%rbp)
jmp 0x815b
movq -0x48(%rbp), %rdi
movslq -0x3c(%rbp), %rsi
shlq $0x3, %rsi
callq 0x20f0
movq %rax, -0x48(%rbp)
movq -0x50(%rbp), %rdi
movslq -0x3c(%rbp), %rsi
shlq $0x3, %rsi
callq 0x20f0
movq %rax, -0x50(%rbp)
movq -0x58(%rbp), %rax
movq (%rax), %rdx
movq -0x48(%rbp), %rax
movl -0x3c(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x58(%rbp), %rax
movq 0x8(%rax), %rdx
movq -0x50(%rbp), %rax
movl -0x3c(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x58(%rbp), %rdi
callq 0x2030
movq -0x10(%rbp), %rdi
movl $0x29, %esi
callq 0xaab0
cmpq $0x0, %rax
jne 0x81ab
jmp 0x81b0
jmp 0x80ed
movq -0x10(%rbp), %rdi
movl $0x15, %esi
callq 0xaab0
cmpq $0x0, %rax
jne 0x81d4
movq -0x10(%rbp), %rdi
leaq 0x43fb(%rip), %rsi      # 0xc5ca
callq 0xabb0
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x78(%rbp)
movl $0x3, %edi
callq 0xb0a0
movq -0x78(%rbp), %rdi
movq %rax, %rsi
movq %rsi, -0x60(%rbp)
callq 0xb0e0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movl -0x3c(%rbp), %ecx
movq -0x60(%rbp), %rax
movl %ecx, (%rax)
movq -0x48(%rbp), %rcx
movq -0x60(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x50(%rbp), %rcx
movq -0x60(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0x8228
jmp 0x7fc0
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq