// File: /workspace/github_c_makefile_star2_O0/theovosse[P]llgen/llgen.c
// Function: determineEmptyRule
static Boolean determineEmptyRule(Node rule) {
	Boolean empty = true, firstPrinted;
	NodeList* rules, emptyRule;

	if (rule == NULL || rule->empty) {
		return true;
	}
	for (Node ptr = rule; ptr != NULL; ptr = ptr->next) {
		switch (ptr->nodeType) {
			case single: /* Only if identifier produces empty, not if string; ignore code and output */
				if (!((ptr->element.name->nameType == identifier && ptr->element.name->empty) ||
					  ptr->element.name->nameType == output ||
					  ptr->element.name->nameType == code)) {
					empty = false;
				}
				break;
			case option: /* Bien sure */
				break;
			case sequence: /* Only if subpart is empty */
				if (!determineEmptyRule(ptr->element.sub)) {
					empty = false;
				}
				break;
			case chain: /* Only if first part of chain is empty, second doesn't matter */
				if (!determineEmptyRule(ptr->element.sub->element.sub)) {
					empty = false;
				}
				break;
			case alternative: /* Only if one of the alternatives is empty */
				firstPrinted = false;
				rules = &ptr->element.alternatives;
				emptyRule = NULL;
				if (!ptr->element.alternatives->empty) {
					while (*rules != NULL) {
						if (determineEmptyRule((*rules)->first)) {
							if (emptyRule != NULL) {
								if (!firstPrinted) {
									if (emptyRule->first != NULL) {
										fprintf(stderr, "%s:%d:error: more than one empty alternative\n",
												inputFileName, emptyRule->first->lineNr);
									} else {
										fprintf(stderr, "%s:%d:error: more than one empty alternative following this line\n",
												inputFileName, ptr->lineNr);
									}
									firstPrinted = true;
								}
								if ((*rules)->first != NULL) {
									fprintf(stderr, "%s:%d:error: and here\n",
											inputFileName, (*rules)->first->lineNr);
								} else {
									fprintf(stderr, "%s:%d:error: and following this line\n",
											inputFileName, ptr->lineNr);
								}
								notLLError = true;
								rules = &(*rules)->rest;
							} else {
								// Take this out of the list and move it to the end
								emptyRule = *rules;
								*rules = emptyRule->rest;
								emptyRule->rest = NULL;
							}
						} else {
							rules = &(*rules)->rest;
						}
					}
					if (emptyRule != NULL) {
						// Reorder such that emptyRule goes to the end.
						*rules = emptyRule;
						ptr->element.alternatives->empty = true;
					} else {
						empty = false;
					}
				}
				break;
			case breakToken:
			case errorMessage:
				break;
			// default:
			// 	fprintf(stderr, "determineEmptyRule: unknown nodetype %d\n", ptr->nodeType);
			// 	return empty;
		}
	}
	rule->empty = empty;
	return empty;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movw $0xffff, -0x12(%rbp)    # imm = 0xFFFF
cmpq $0x0, -0x10(%rbp)
je 0x58e6
movq -0x10(%rbp), %rax
movswl 0x22(%rax), %eax
cmpl $0x0, %eax
je 0x58f1
movw $0xffff, -0x2(%rbp)     # imm = 0xFFFF
jmp 0x5b8d
movq -0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x5b79
movq -0x30(%rbp), %rax
movl 0x4(%rax), %eax
movq %rax, -0x38(%rbp)
subq $0x6, %rax
ja 0x5b66
movq -0x38(%rbp), %rax
leaq 0x13734(%rip), %rcx     # 0x19058
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
cmpl $0x0, 0x38(%rax)
jne 0x594c
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movswl 0x30(%rax), %eax
cmpl $0x0, %eax
jne 0x596e
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
cmpl $0x2, 0x38(%rax)
je 0x596e
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
cmpl $0x3, 0x38(%rax)
je 0x596e
movw $0x0, -0x12(%rbp)
jmp 0x5b66
jmp 0x5b66
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x58c0
cmpw $0x0, %ax
jne 0x5991
movw $0x0, -0x12(%rbp)
jmp 0x5b66
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x18(%rax), %rdi
callq 0x58c0
cmpw $0x0, %ax
jne 0x59b3
movw $0x0, -0x12(%rbp)
jmp 0x5b66
movw $0x0, -0x14(%rbp)
movq -0x30(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
cmpw $0x0, 0x10(%rax)
jne 0x5b62
jmp 0x59e7
movq -0x20(%rbp), %rax
cmpq $0x0, (%rax)
je 0x5b38
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq (%rax), %rdi
callq 0x58c0
cmpw $0x0, %ax
je 0x5b24
cmpq $0x0, -0x28(%rbp)
je 0x5afc
cmpw $0x0, -0x14(%rbp)
jne 0x5a81
movq -0x28(%rbp), %rax
cmpq $0x0, (%rax)
je 0x5a55
movq 0x1a5c7(%rip), %rax     # 0x1fff8
movq (%rax), %rdi
movq 0x1a73d(%rip), %rdx     # 0x20178
movq -0x28(%rbp), %rax
movq (%rax), %rax
movswl (%rax), %ecx
leaq 0x138e8(%rip), %rsi     # 0x19334
movb $0x0, %al
callq 0x3140
jmp 0x5a7b
movq 0x1a59c(%rip), %rax     # 0x1fff8
movq (%rax), %rdi
movq 0x1a712(%rip), %rdx     # 0x20178
movq -0x30(%rbp), %rax
movswl (%rax), %ecx
leaq 0x138ee(%rip), %rsi     # 0x19362
movb $0x0, %al
callq 0x3140
movw $0xffff, -0x14(%rbp)    # imm = 0xFFFF
movq -0x20(%rbp), %rax
movq (%rax), %rax
cmpq $0x0, (%rax)
je 0x5abc
movq 0x1a563(%rip), %rax     # 0x1fff8
movq (%rax), %rdi
movq 0x1a6d9(%rip), %rdx     # 0x20178
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq (%rax), %rax
movswl (%rax), %ecx
leaq 0x138f1(%rip), %rsi     # 0x193a4
movb $0x0, %al
callq 0x3140
jmp 0x5ae2
movq 0x1a535(%rip), %rax     # 0x1fff8
movq (%rax), %rdi
movq 0x1a6ab(%rip), %rdx     # 0x20178
movq -0x30(%rbp), %rax
movswl (%rax), %ecx
leaq 0x138e0(%rip), %rsi     # 0x193bb
movb $0x0, %al
callq 0x3140
movw $0xffff, 0x1b297(%rip)  # imm = 0xFFFF
movq -0x20(%rbp), %rax
movq (%rax), %rax
addq $0x8, %rax
movq %rax, -0x20(%rbp)
jmp 0x5b22
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
movq $0x0, 0x8(%rax)
jmp 0x5b33
movq -0x20(%rbp), %rax
movq (%rax), %rax
addq $0x8, %rax
movq %rax, -0x20(%rbp)
jmp 0x59e7
cmpq $0x0, -0x28(%rbp)
je 0x5b5a
movq -0x28(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movw $0xffff, 0x10(%rax)     # imm = 0xFFFF
jmp 0x5b60
movw $0x0, -0x12(%rbp)
jmp 0x5b62
jmp 0x5b66
jmp 0x5b66
jmp 0x5b68
movq -0x30(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x30(%rbp)
jmp 0x58f9
movw -0x12(%rbp), %cx
movq -0x10(%rbp), %rax
movw %cx, 0x22(%rax)
movw -0x12(%rbp), %ax
movw %ax, -0x2(%rbp)
movw -0x2(%rbp), %ax
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)