// File: /workspace/github_c_makefile_star2_O3/MikeGray-APH[P]LibLouisAPH/source/languages/generic-backward.c
// Function: convert_indicators_capital
static int convert_indicators_capital(struct translate *translate)
{
	const struct table *table;
	int capital_in, numeric_in;
	unichar upper;

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

	capital_in =
	numeric_in = 0;

	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:
		case WORD:  numeric_in = 1;  break;

		case END:
		case TERM:

			if(capital_in < 3)
				capital_in = 0;
			numeric_in = 0;
			break;

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

		if(numeric_in)
		{
			if(translate_copy_marked_indicators(translate) > 0)
				continue;
			if(!translate_copy_to_output(translate, 1, 1))
				return 0;
			continue;
		}

		switch(translate_get_mode_indicator(translate, table, &table->capital))
		{
		case FAIL:  return 0;
		case NONE:  break;

		case BEGIN:   capital_in = 3;  break;
		case WORD:    capital_in = 2;  break;
		case SYMBOL:  capital_in = 1;  break;

		case END:
		case TERM:  capital_in = 0;  break;
		}


		if(translate_copy_marked_indicators(translate) > 0)
			continue;

		if(capital_in)
		{
			if(capital_in < 3 && translate_has_attributes(translate, (CHAR_SPACE | CHAR_SEQUENCE_DELIMITER)))
			{
				capital_in = 0;
				if(!translate_copy_to_output(translate, 1, 1))
					return 0;
				continue;
			}

			if(capital_in == 2 && !translate_has_attributes(translate, CHAR_LETTER))
			{
				capital_in = 0;
				if(!translate_copy_to_output(translate, 1, 1))
					return 0;
				continue;
			}

			upper = generic_lower_to_upper(translate->tables[translate->table_crs], translate->input[translate->input_crs]);
			if(upper != translate->input[translate->input_crs])
			{
				CHANGE_MARK
				if(!translate_insert_dot_for_chars(translate, upper, 1))
					return 0;
			}
			else if(!translate_copy_to_output(translate, 1, 1))
				return 0;
		}
		else if(!translate_copy_to_output(translate, 1, 1))
			return 0;

		if(capital_in == 1)
			capital_in = 0;
	}

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

	return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movq (%rdi), %rax
movslq 0xc(%rdi), %rcx
movq -0x8(%rax,%rcx,8), %r14
decq %rcx
movl %ecx, 0x8(%rdi)
xorl %eax, %eax
movl %eax, 0x68(%rdi)
movl %eax, 0x40(%rdi)
cmpl %eax, 0x44(%rdi)
jle 0xf05a
leaq 0x150(%r14), %r15
leaq 0xd0(%r14), %rax
movq %rax, 0x10(%rsp)
leaq 0x4f29(%rip), %r13      # 0x13d80
xorl %r12d, %r12d
movb $0x1, %bpl
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x6f4b
cmpl $0x5, %eax
ja 0xee7c
movl %eax, %eax
movslq (%r13,%rax,4), %rax
addq %r13, %rax
jmpq *%rax
testb $0x1, %bpl
jne 0xeec4
movq %rbx, %rdi
callq 0x76d5
testl %eax, %eax
jg 0xeea8
movq %rbx, %rdi
movl $0x1, %esi
movl $0x1, %edx
callq 0x7467
testl %eax, %eax
je 0xf068
movl 0x40(%rbx), %eax
xorl %ebp, %ebp
cmpl 0x44(%rbx), %eax
jl 0xee5d
jmp 0xf05a
cmpl $0x3, %r12d
movl $0x0, %eax
cmovll %eax, %r12d
movq %rbx, %rdi
movq %r14, %rsi
movq 0x10(%rsp), %rdx
callq 0x6f4b
cmpl $0x6, %eax
ja 0xef16
movl %eax, %eax
leaq 0x4eb6(%rip), %rcx      # 0x13d98
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rbx, %rdi
callq 0x76d5
testl %eax, %eax
jg 0xefb5
jmp 0xef9b
movl $0x1, %r12d
jmp 0xef16
movl $0x3, %r12d
jmp 0xef16
movl $0x2, %r12d
movq %rbx, %rdi
callq 0x76d5
testl %eax, %eax
jg 0xefb8
testl %r12d, %r12d
je 0xef9b
movl 0x40(%rbx), %eax
cmpl $0x2, %r12d
jg 0xefcc
testl %eax, %eax
js 0xef67
cmpl %eax, 0x44(%rbx)
jle 0xef64
movslq 0x8(%rbx), %rcx
movq (%rbx), %rdx
movq 0x38(%rbx), %rsi
movq (%rdx,%rcx,8), %rdi
movzwl (%rsi,%rax,2), %esi
callq 0x1ef5
testq %rax, %rax
je 0xef64
testb $0x3, 0x24(%rax)
jne 0xef9b
movl 0x40(%rbx), %eax
cmpl $0x2, %r12d
jne 0xefcc
testl %eax, %eax
js 0xef9b
cmpl %eax, 0x44(%rbx)
jle 0xef9b
movslq 0x8(%rbx), %rcx
movq (%rbx), %rdx
movq 0x38(%rbx), %rsi
movq (%rdx,%rcx,8), %rdi
movl %eax, %eax
movzwl (%rsi,%rax,2), %esi
callq 0x1ef5
testq %rax, %rax
je 0xef9b
testb $0x40, 0x24(%rax)
jne 0xefc9
movq %rbx, %rdi
movl $0x1, %esi
movl $0x1, %edx
callq 0x7467
testl %eax, %eax
je 0xf068
xorl %r12d, %r12d
movl 0x40(%rbx), %eax
cmpl 0x44(%rbx), %eax
jl 0xee5a
jmp 0xf05a
movl 0x40(%rbx), %eax
movslq 0x8(%rbx), %rcx
movq (%rbx), %rdx
movq 0x38(%rbx), %rsi
movq (%rdx,%rcx,8), %rdi
cltq
movzwl (%rsi,%rax,2), %ebp
movzwl %bp, %esi
callq 0x1ef5
testq %rax, %rax
je 0xeffc
testb $0x1, 0x25(%rax)
je 0xeffc
movq 0x8(%rax), %rax
movzwl 0x20(%rax), %ebp
movq 0x38(%rbx), %rax
movslq 0x40(%rbx), %rcx
cmpw (%rax,%rcx,2), %bp
jne 0xf01e
movq %rbx, %rdi
movl $0x1, %esi
movl $0x1, %edx
callq 0x7467
jmp 0xf044
movl $0x1, 0x94(%rbx)
movw %bp, 0xe(%rsp)
movq %rbx, %rdi
leaq 0xe(%rsp), %rsi
movl $0x1, %edx
movl $0x1, %ecx
callq 0x72f8
testl %eax, %eax
je 0xf068
cmpl $0x1, %r12d
movl $0x0, %eax
cmovel %eax, %r12d
jmp 0xefb8
movq 0x60(%rbx), %rax
movslq 0x68(%rbx), %rcx
movw $0x0, (%rax,%rcx,2)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq