// File: /workspace/github_c_makefile_star2_O0/MikeGray-APH[P]LibLouisAPH/source/languages/generic-common.c
// Function: generic_process
int generic_process(struct translate *translate, const enum table_hash_type hash_type, const enum rule_direction direction)
{
	const struct table *table;
	const struct rule *rule;
	enum mode_type nocontract_state;

	/*   only copy indicators from last table in tables   */
	table = translate->tables[translate->table_cnt - 1];

	/*   reset tracked cursor   */
	translate->cursor_set = 0;

	nocontract_state = NONE;

	translate->input_crs =
	translate->output_len = 0;
	while(translate->input_crs < translate->input_len)
	{
		/*   just copy when notrans is set   */
		if(translate->input_mask[translate->input_crs] & MASK_NO_TRANSLATION)
		{
			if(!translate_copy_to_output(translate, 1, 1))
				return 0;
			continue;
		}

		/*   nocontract word stops on space   */
		if(nocontract_state == WORD)
		if(table_get_character_attributes(table, translate->input[translate->input_crs]) & CHAR_SPACE)
			nocontract_state = NONE;

		/*   nocontract   */
		switch(translate_get_mode_indicator(translate, table, &table->nocontract))
		{
		case FAIL:   return 0;
		case NONE:                              break;
		case BEGIN:  nocontract_state = BEGIN;  break;
		case WORD:   nocontract_state = WORD;   break;
		case END:
		case TERM:   nocontract_state = NONE;   break;

		case SYMBOL:

			/*   it is possible for symbol to be inside WORD or PASSAGE   */
			if(nocontract_state == NONE)
				nocontract_state = SYMBOL;
			break;
		}

		if(translate_copy_marked_indicators(translate) > 0)
			continue;

		/*   find rule   */
		rule = generic_match_rule(translate, hash_type, direction, nocontract_state == NONE);
		if(!rule)
		{
			if(!translate_copy_to_output(translate, 1, 1))
				return 0;
		}
		else
		{
			CHANGE_MARK
			if(!generic_apply_rule(translate, rule, direction))
				return 0;
		}

		/*   reset nocontract symbol   */
		if(nocontract_state == SYMBOL)
			nocontract_state = NONE;
	}

#ifdef DEBUG
	translate->output[translate->output_len] = 0;
#endif

	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x10(%rbp), %rcx
movl 0xc(%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movl $0x0, 0x8c(%rax)
movl $0x1, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movl $0x0, 0x68(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x40(%rax)
movq -0x10(%rbp), %rax
movl 0x40(%rax), %eax
movq -0x10(%rbp), %rcx
cmpl 0x44(%rcx), %eax
jge 0x10b04
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x10(%rbp), %rcx
movslq 0x40(%rcx), %rcx
movsbl (%rax,%rcx), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x109cc
movq -0x10(%rbp), %rdi
movl $0x1, %edx
movl %edx, %esi
callq 0xaeb0
cmpl $0x0, %eax
jne 0x109ca
movl $0x0, -0x4(%rbp)
jmp 0x10b21
jmp 0x10979
cmpl $0x4, -0x2c(%rbp)
jne 0x10a00
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movq -0x10(%rbp), %rcx
movslq 0x40(%rcx), %rcx
movzwl (%rax,%rcx,2), %esi
callq 0x10b30
andl $0x1, %eax
cmpl $0x0, %eax
je 0x109fe
movl $0x1, -0x2c(%rbp)
jmp 0x10a00
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq %rsi, %rdx
addq $0x50, %rdx
callq 0xa630
movl %eax, %ecx
movq %rcx, -0x38(%rbp)
subl $0x6, %eax
ja 0x10a6b
movq -0x38(%rbp), %rax
leaq 0xe412(%rip), %rcx      # 0x1ee3c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x0, -0x4(%rbp)
jmp 0x10b21
jmp 0x10a6b
movl $0x2, -0x2c(%rbp)
jmp 0x10a6b
movl $0x4, -0x2c(%rbp)
jmp 0x10a6b
movl $0x1, -0x2c(%rbp)
jmp 0x10a6b
cmpl $0x1, -0x2c(%rbp)
jne 0x10a69
movl $0x6, -0x2c(%rbp)
jmp 0x10a6b
movq -0x10(%rbp), %rdi
callq 0xb160
cmpl $0x0, %eax
jle 0x10a7e
jmp 0x10979
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
movl -0x18(%rbp), %edx
cmpl $0x1, -0x2c(%rbp)
sete %al
andb $0x1, %al
movzbl %al, %ecx
callq 0x10b80
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x10ac4
movq -0x10(%rbp), %rdi
movl $0x1, %edx
movl %edx, %esi
callq 0xaeb0
cmpl $0x0, %eax
jne 0x10ac2
movl $0x0, -0x4(%rbp)
jmp 0x10b21
jmp 0x10af2
movq -0x10(%rbp), %rax
movl $0x1, 0x94(%rax)
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
movl -0x18(%rbp), %edx
callq 0x10ca0
cmpl $0x0, %eax
jne 0x10af0
movl $0x0, -0x4(%rbp)
jmp 0x10b21
jmp 0x10af2
cmpl $0x6, -0x2c(%rbp)
jne 0x10aff
movl $0x1, -0x2c(%rbp)
jmp 0x10979
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rax
movq -0x10(%rbp), %rcx
movslq 0x68(%rcx), %rcx
movw $0x0, (%rax,%rcx,2)
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)