// File: /workspace/github_c_makefile_star2_O0/MikeGray-APH[P]LibLouisAPH/source/languages/generic-backward.c
// Function: add_soft_terminators
static int add_soft_terminators(struct translate *translate)
{
	const struct table *table;
	int numeric_in, numeric_passage_in, nocontract_in;

	numeric_in =
	numeric_passage_in =
	nocontract_in = 0;

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

	translate->input_crs =
	translate->output_len = 0;
	while(translate->input_crs < translate->input_len)
	{
		switch(translate_get_mode_indicator(translate, table, &table->numeric))
		{
		case FAIL:  return 0;

		case BEGIN:

			numeric_passage_in = 1;

			if(!nocontract_in)
			{
				nocontract_in = 1;

				/*   don't start if there is no end   */
				if(table->nocontract.begin_len && table->nocontract.end_len)
				if(!generic_insert_marked(translate, table->nocontract.begin, table->nocontract.begin_len, table->marker_soft))
					return 0;
			}

			/*   copy indicator now so it doesn't turn off numeric mode later   */
			if(translate_copy_marked_indicators(translate) < 0)
				return 0;

			continue;

		case END:

			numeric_passage_in = 0;

			if(translate_copy_marked_indicators(translate) < 0)
				return 0;

			nocontract_in = 0;

			if(table->nocontract.end_len)
			if(!generic_insert_marked(translate, table->nocontract.end, table->nocontract.end_len, table->marker_soft))
				return 0;

			continue;

		case WORD:

			numeric_in = 1;

			if(!nocontract_in)
			{
				nocontract_in = 1;

				/*   don't start a word if there is no terminator   */
				if(table->nocontract.word_len && table->nocontract.term_len)
				if(!generic_insert_marked(translate, table->nocontract.word, table->nocontract.word_len, table->marker_soft))
					return 0;
			}

			/*   copy indicator now so it doesn't turn off numeric mode later   */
			if(translate_copy_marked_indicators(translate) < 0)
				return 0;

			continue;

		case TERM:  numeric_in = 0;  break;

		/*   numeric space   */
		case SYMBOL:
		case NONE:  break;
		}

		if(numeric_passage_in)
		{
			if(!translate_copy_to_output(translate, 1, 1))
				return 0;
			continue;
		}

		/*   assume that valid digit chars are free of indicators and modifiers   */
		if(translate_on_indicator_or_modifier_marker(translate))
		{
			if(numeric_in)
			{
				numeric_in = 0;
				CHANGE_MARK

				/*   put end before marked indicator   */
				if(table->numeric.end_len)
				if(!generic_insert_marked(translate, table->numeric.end, table->numeric.end_len, table->marker_soft))
					return 0;
			}
			if(translate_copy_marked_indicators_or_modifiers(translate) < 0)
				return 0;

			continue;
		}

		if(numeric_in)
		{
			if(translate_has_attributes(translate, (CHAR_SPACE | CHAR_SEQUENCE_DELIMITER)))
			{
				numeric_in = 0;
				CHANGE_MARK

				if(table->numeric.end_len)
				if(!generic_insert_marked(translate, table->numeric.end, table->numeric.end_len, table->marker_soft))
					return 0;

				nocontract_in = 0;
				if(table->nocontract.term_len)
				{
					/*   put terminator after delimiter (because of dashes)   */
					if(!translate_copy_to_output(translate, 1, 1))
						return 0;

					if(!generic_insert_marked(translate, table->nocontract.term, table->nocontract.term_len, table->marker_soft))
						return 0;

					continue;
				}
			}
			else if(!translate_has_attributes(translate, CHAR_NUMERIC_UCHAR | CHAR_NUMERIC_CONT))
			{
				numeric_in = 0;
				CHANGE_MARK

				if(table->numeric.end_len)
				if(!generic_insert_marked(translate, table->numeric.end, table->numeric.end_len, table->marker_soft))
					return 0;
			}
		}
		else if(nocontract_in)
		{
			if(translate_has_attributes(translate, (CHAR_SPACE | CHAR_SEQUENCE_DELIMITER)))
			{
				nocontract_in = 0;
				if(table->nocontract.term_len)
				{
					/*   put terminator after delimiter (because of dashes)   */
					if(!translate_copy_to_output(translate, 1, 1))
						return 0;

					if(!generic_insert_marked(translate, table->nocontract.term, table->nocontract.term_len, table->marker_soft))
						return 0;

					continue;
				}
			}
		}

		if(!translate_copy_to_output(translate, 1, 1))
			return 0;
	}

	/*   this may not be necessary, here for consistency   */
	if(numeric_in)
	{
		if(table->numeric.end_len)
		if(!generic_insert_marked(translate, table->numeric.end, table->numeric.end_len, table->marker_soft))
			return 0;

		if(table->nocontract.term_len)
		if(!generic_insert_marked(translate, table->nocontract.term, table->nocontract.term_len, table->marker_soft))
			return 0;
	}
	else if(nocontract_in)
	if(table->nocontract.term_len)
	if(!generic_insert_marked(translate, table->nocontract.term, table->nocontract.term_len, table->marker_soft))
		return 0;

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

	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movl $0x0, -0x24(%rbp)
movl $0x0, -0x20(%rbp)
movl $0x0, -0x1c(%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, -0x18(%rbp)
movq -0x10(%rbp), %rax
movl 0xc(%rax), %ecx
subl $0x1, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x8(%rax)
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 0x17285
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq %rsi, %rdx
addq $0x150, %rdx            # imm = 0x150
callq 0xa630
movl %eax, %ecx
movq %rcx, -0x30(%rbp)
subl $0x6, %eax
ja 0x16f88
movq -0x30(%rbp), %rax
leaq 0x8167(%rip), %rcx      # 0x1ef40
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x0, -0x4(%rbp)
jmp 0x17393
movl $0x1, -0x20(%rbp)
cmpl $0x0, -0x24(%rbp)
jne 0x16e5b
movl $0x1, -0x24(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, 0xa4(%rax)
je 0x16e59
movq -0x18(%rbp), %rax
cmpl $0x0, 0xa8(%rax)
je 0x16e59
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x50, %rsi
addq $0xc, %rsi
movq -0x18(%rbp), %rax
movl 0xa4(%rax), %edx
movq -0x18(%rbp), %rax
movzwl 0x1f2(%rax), %ecx
callq 0x102a0
cmpl $0x0, %eax
jne 0x16e57
movl $0x0, -0x4(%rbp)
jmp 0x17393
jmp 0x16e59
jmp 0x16e5b
movq -0x10(%rbp), %rdi
callq 0xb160
cmpl $0x0, %eax
jge 0x16e75
movl $0x0, -0x4(%rbp)
jmp 0x17393
jmp 0x16d94
movl $0x0, -0x20(%rbp)
movq -0x10(%rbp), %rdi
callq 0xb160
cmpl $0x0, %eax
jge 0x16e9b
movl $0x0, -0x4(%rbp)
jmp 0x17393
movl $0x0, -0x24(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, 0xa8(%rax)
je 0x16eec
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x50, %rsi
addq $0x1a, %rsi
movq -0x18(%rbp), %rax
movl 0xa8(%rax), %edx
movq -0x18(%rbp), %rax
movzwl 0x1f2(%rax), %ecx
callq 0x102a0
cmpl $0x0, %eax
jne 0x16eea
movl $0x0, -0x4(%rbp)
jmp 0x17393
jmp 0x16eec
jmp 0x16d94
movl $0x1, -0x1c(%rbp)
cmpl $0x0, -0x24(%rbp)
jne 0x16f5e
movl $0x1, -0x24(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, 0xac(%rax)
je 0x16f5c
movq -0x18(%rbp), %rax
cmpl $0x0, 0xb0(%rax)
je 0x16f5c
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x50, %rsi
addq $0x28, %rsi
movq -0x18(%rbp), %rax
movl 0xac(%rax), %edx
movq -0x18(%rbp), %rax
movzwl 0x1f2(%rax), %ecx
callq 0x102a0
cmpl $0x0, %eax
jne 0x16f5a
movl $0x0, -0x4(%rbp)
jmp 0x17393
jmp 0x16f5c
jmp 0x16f5e
movq -0x10(%rbp), %rdi
callq 0xb160
cmpl $0x0, %eax
jge 0x16f78
movl $0x0, -0x4(%rbp)
jmp 0x17393
jmp 0x16d94
movl $0x0, -0x1c(%rbp)
jmp 0x16f88
jmp 0x16f88
cmpl $0x0, -0x20(%rbp)
je 0x16fb4
movq -0x10(%rbp), %rdi
movl $0x1, %edx
movl %edx, %esi
callq 0xaeb0
cmpl $0x0, %eax
jne 0x16faf
movl $0x0, -0x4(%rbp)
jmp 0x17393
jmp 0x16d94
movq -0x10(%rbp), %rdi
callq 0x18060
cmpl $0x0, %eax
je 0x1704f
cmpl $0x0, -0x1c(%rbp)
je 0x17030
movl $0x0, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movl $0x1, 0x94(%rax)
movq -0x18(%rbp), %rax
cmpl $0x0, 0x1a8(%rax)
je 0x1702e
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x150, %rsi            # imm = 0x150
addq $0x1a, %rsi
movq -0x18(%rbp), %rax
movl 0x1a8(%rax), %edx
movq -0x18(%rbp), %rax
movzwl 0x1f2(%rax), %ecx
callq 0x102a0
cmpl $0x0, %eax
jne 0x1702c
movl $0x0, -0x4(%rbp)
jmp 0x17393
jmp 0x1702e
jmp 0x17030
movq -0x10(%rbp), %rdi
callq 0xb250
cmpl $0x0, %eax
jge 0x1704a
movl $0x0, -0x4(%rbp)
jmp 0x17393
jmp 0x16d94
cmpl $0x0, -0x1c(%rbp)
je 0x171c7
movq -0x10(%rbp), %rdi
movl $0x3, %esi
callq 0x18090
cmpl $0x0, %eax
je 0x17149
movl $0x0, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movl $0x1, 0x94(%rax)
movq -0x18(%rbp), %rax
cmpl $0x0, 0x1a8(%rax)
je 0x170d2
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x150, %rsi            # imm = 0x150
addq $0x1a, %rsi
movq -0x18(%rbp), %rax
movl 0x1a8(%rax), %edx
movq -0x18(%rbp), %rax
movzwl 0x1f2(%rax), %ecx
callq 0x102a0
cmpl $0x0, %eax
jne 0x170d0
movl $0x0, -0x4(%rbp)
jmp 0x17393
jmp 0x170d2
movl $0x0, -0x24(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, 0xb0(%rax)
je 0x17147
movq -0x10(%rbp), %rdi
movl $0x1, %edx
movl %edx, %esi
callq 0xaeb0
cmpl $0x0, %eax
jne 0x17107
movl $0x0, -0x4(%rbp)
jmp 0x17393
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x50, %rsi
addq $0x36, %rsi
movq -0x18(%rbp), %rax
movl 0xb0(%rax), %edx
movq -0x18(%rbp), %rax
movzwl 0x1f2(%rax), %ecx
callq 0x102a0
cmpl $0x0, %eax
jne 0x17142
movl $0x0, -0x4(%rbp)
jmp 0x17393
jmp 0x16d94
jmp 0x171c2
movq -0x10(%rbp), %rdi
movl $0x3000, %esi           # imm = 0x3000
callq 0x18090
cmpl $0x0, %eax
jne 0x171c0
movl $0x0, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movl $0x1, 0x94(%rax)
movq -0x18(%rbp), %rax
cmpl $0x0, 0x1a8(%rax)
je 0x171be
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x150, %rsi            # imm = 0x150
addq $0x1a, %rsi
movq -0x18(%rbp), %rax
movl 0x1a8(%rax), %edx
movq -0x18(%rbp), %rax
movzwl 0x1f2(%rax), %ecx
callq 0x102a0
cmpl $0x0, %eax
jne 0x171bc
movl $0x0, -0x4(%rbp)
jmp 0x17393
jmp 0x171be
jmp 0x171c0
jmp 0x171c2
jmp 0x1725f
cmpl $0x0, -0x24(%rbp)
je 0x1725d
movq -0x10(%rbp), %rdi
movl $0x3, %esi
callq 0x18090
cmpl $0x0, %eax
je 0x1725b
movl $0x0, -0x24(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, 0xb0(%rax)
je 0x17259
movq -0x10(%rbp), %rdi
movl $0x1, %edx
movl %edx, %esi
callq 0xaeb0
cmpl $0x0, %eax
jne 0x17219
movl $0x0, -0x4(%rbp)
jmp 0x17393
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x50, %rsi
addq $0x36, %rsi
movq -0x18(%rbp), %rax
movl 0xb0(%rax), %edx
movq -0x18(%rbp), %rax
movzwl 0x1f2(%rax), %ecx
callq 0x102a0
cmpl $0x0, %eax
jne 0x17254
movl $0x0, -0x4(%rbp)
jmp 0x17393
jmp 0x16d94
jmp 0x1725b
jmp 0x1725d
jmp 0x1725f
movq -0x10(%rbp), %rdi
movl $0x1, %edx
movl %edx, %esi
callq 0xaeb0
cmpl $0x0, %eax
jne 0x17280
movl $0x0, -0x4(%rbp)
jmp 0x17393
jmp 0x16d94
cmpl $0x0, -0x1c(%rbp)
je 0x17325
movq -0x18(%rbp), %rax
cmpl $0x0, 0x1a8(%rax)
je 0x172dc
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x150, %rsi            # imm = 0x150
addq $0x1a, %rsi
movq -0x18(%rbp), %rax
movl 0x1a8(%rax), %edx
movq -0x18(%rbp), %rax
movzwl 0x1f2(%rax), %ecx
callq 0x102a0
cmpl $0x0, %eax
jne 0x172da
movl $0x0, -0x4(%rbp)
jmp 0x17393
jmp 0x172dc
movq -0x18(%rbp), %rax
cmpl $0x0, 0xb0(%rax)
je 0x17323
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x50, %rsi
addq $0x36, %rsi
movq -0x18(%rbp), %rax
movl 0xb0(%rax), %edx
movq -0x18(%rbp), %rax
movzwl 0x1f2(%rax), %ecx
callq 0x102a0
cmpl $0x0, %eax
jne 0x17321
movl $0x0, -0x4(%rbp)
jmp 0x17393
jmp 0x17323
jmp 0x17376
cmpl $0x0, -0x24(%rbp)
je 0x17374
movq -0x18(%rbp), %rax
cmpl $0x0, 0xb0(%rax)
je 0x17372
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x50, %rsi
addq $0x36, %rsi
movq -0x18(%rbp), %rax
movl 0xb0(%rax), %edx
movq -0x18(%rbp), %rax
movzwl 0x1f2(%rax), %ecx
callq 0x102a0
cmpl $0x0, %eax
jne 0x17370
movl $0x0, -0x4(%rbp)
jmp 0x17393
jmp 0x17372
jmp 0x17374
jmp 0x17376
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 $0x30, %rsp
popq %rbp
retq
nopl (%rax)