// File: /workspace/github_c_makefile_star2_O0/MaoKo[P]FGFX/fgfp/src/cfg_production.c
// Function: unreachable_production
int
unreachable_production(cfg_t const* cfg) {
	if (!cfg)
		{ return (ERROR); }
	if (EMPTY_VECTOR(cfg->non_terminal))
		{ return (DONE); }

	bitset_t* nter_seen = new_bitset();
	vector_t* stack_prod = NULL;

	symbol_t* crt_symbol = AT_VECTOR(cfg->non_terminal, cfg->goal);
	ADD_BITSET(nter_seen, GET_INDEX(crt_symbol));

	stack_prod = stack_production_lhs(cfg, crt_symbol);
	while (!EMPTY_VECTOR(stack_prod)) {
		production_t* crt_prod = (production_t*)BACK_VECTOR(stack_prod);
		POP_BACK_VECTOR(stack_prod);

		list_rhs_t* list = crt_prod->rhs_element;
		while (list) {
			crt_symbol = list->symbol_rhs;
			if (IS_NON_TERMINAL(crt_symbol) && !IS_PRESENT(nter_seen,
												GET_INDEX(crt_symbol))) {
				ADD_BITSET(nter_seen, GET_INDEX(crt_symbol));
				move_vector(stack_prod, stack_production_lhs(cfg, crt_symbol));
			}
			list = list->next;
		}
	}
	
	int unreach = DONE;
	for (int i = SIZE_VECTOR(cfg->non_terminal) - 1; i >= 0; --i) {
		if (!IS_PRESENT(nter_seen, (size_t)i)) {
            symbol_t* crt_symbol = (symbol_t*)AT_VECTOR(cfg->non_terminal, i);
			unreach = ERROR;
            if (crt_symbol->name) {
			    warnf(0, "The nonterminal %s is unreachable.",
                                                        crt_symbol->name);
            }
            else {
                warnf(0, "A nonterminal created by a %s element is unreachable",
                        ((crt_symbol->spec_kind == OPT) ? "optional" : "list"));
            }
			erase_vector(cfg->non_terminal, i);
			shift_index(cfg, i);
		}
	} 

	del_bitset(nter_seen);
	del_vector(stack_prod);

	return (unreach);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x71bf
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x74fd
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
cmpq $0x0, 0x10(%rax)
jne 0x71da
movl $0x0, -0x4(%rbp)
jmp 0x74fd
callq 0x1290
movq %rax, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x28(%rcx), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rcx
movl 0x4(%rcx), %ecx
cmpq %rcx, %rax
jb 0x722b
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rax
movq (%rax), %rsi
callq 0x1420
jmp 0x7259
movq -0x28(%rbp), %rax
movq (%rax), %rcx
andq $0x3f, %rcx
movl $0x1, %edx
shlq %cl, %rdx
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x28(%rbp), %rcx
movq (%rcx), %rcx
shrq $0x6, %rcx
orq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x70d0
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
cmpq $0x0, 0x10(%rax)
setne %al
xorb $-0x1, %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x7283
jmp 0x73c9
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq -0x20(%rbp), %rcx
movq 0x10(%rcx), %rcx
subq $0x1, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rsi
subq $0x1, %rsi
callq 0x21a0
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x73c4
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpl $0x27, 0x8(%rax)
jne 0x73b4
cmpq $0x0, -0x18(%rbp)
je 0x72fe
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rcx
movl 0x4(%rcx), %ecx
cmpq %rcx, %rax
jb 0x730a
xorl %eax, %eax
testb $0x1, %al
jne 0x73b4
jmp 0x7340
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x28(%rbp), %rcx
movq (%rcx), %rcx
shrq $0x6, %rcx
movq (%rax,%rcx,8), %rax
movq -0x28(%rbp), %rcx
movq (%rcx), %rcx
andq $0x3f, %rcx
movl $0x1, %edx
shlq %cl, %rdx
movq %rdx, %rcx
andq %rcx, %rax
cmpq $0x0, %rax
jne 0x73b4
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rcx
movl 0x4(%rcx), %ecx
cmpq %rcx, %rax
jb 0x7365
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rax
movq (%rax), %rsi
callq 0x1420
jmp 0x7393
movq -0x28(%rbp), %rax
movq (%rax), %rcx
andq $0x3f, %rcx
movl $0x1, %edx
shlq %cl, %rdx
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x28(%rbp), %rcx
movq (%rcx), %rcx
shrq $0x6, %rcx
orq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
movq -0x20(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x70d0
movq -0x50(%rbp), %rdi
movq %rax, %rsi
callq 0x24e0
movq -0x38(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x38(%rbp)
jmp 0x72bf
jmp 0x726a
movl $0x0, -0x3c(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rax
subq $0x1, %rax
movl %eax, -0x40(%rbp)
cmpl $0x0, -0x40(%rbp)
jl 0x74e5
cmpq $0x0, -0x18(%rbp)
je 0x7404
movslq -0x40(%rbp), %rax
movq -0x18(%rbp), %rcx
movl 0x4(%rcx), %ecx
cmpq %rcx, %rax
jb 0x7410
xorl %eax, %eax
testb $0x1, %al
jne 0x74d5
jmp 0x7444
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x40(%rbp), %rcx
shrq $0x6, %rcx
movq (%rax,%rcx,8), %rax
movslq -0x40(%rbp), %rcx
andq $0x3f, %rcx
movl $0x1, %edx
shlq %cl, %rdx
movq %rdx, %rcx
andq %rcx, %rax
cmpq $0x0, %rax
jne 0x74d5
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movslq -0x40(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x48(%rbp)
movl $0xffffffff, -0x3c(%rbp) # imm = 0xFFFFFFFF
movq -0x48(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x7489
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rdx
xorl %eax, %eax
movl %eax, %edi
leaq 0x5677(%rip), %rsi      # 0xcaf7
movb $0x0, %al
callq 0x43c0
jmp 0x74b7
movq -0x48(%rbp), %rax
movl 0x38(%rax), %ecx
leaq 0x56c1(%rip), %rdx      # 0xcb58
leaq 0x56b1(%rip), %rax      # 0xcb4f
cmpl $0x0, %ecx
cmoveq %rax, %rdx
xorl %eax, %eax
movl %eax, %edi
leaq 0x566a(%rip), %rsi      # 0xcb1a
movb $0x0, %al
callq 0x43c0
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movslq -0x40(%rbp), %rsi
callq 0x21a0
movq -0x10(%rbp), %rdi
movslq -0x40(%rbp), %rsi
callq 0x7510
jmp 0x74d7
movl -0x40(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x73e3
movq -0x18(%rbp), %rdi
callq 0x1300
movq -0x20(%rbp), %rdi
callq 0x1ff0
movl -0x3c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)