// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%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)
movl $0x0, -0x20(%rbp)
movl $0x0, -0x1c(%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 0x17802
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 0x175e4
movq -0x30(%rbp), %rax
leaq 0x79ae(%rip), %rcx      # 0x1ef5c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x0, -0x4(%rbp)
jmp 0x1781f
movl $0x1, -0x20(%rbp)
jmp 0x175e4
cmpl $0x3, -0x1c(%rbp)
jge 0x175d9
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x20(%rbp)
jmp 0x175e4
jmp 0x175e4
cmpl $0x0, -0x20(%rbp)
je 0x17623
movq -0x10(%rbp), %rdi
callq 0xb160
cmpl $0x0, %eax
jle 0x175fd
jmp 0x1756d
movq -0x10(%rbp), %rdi
movl $0x1, %edx
movl %edx, %esi
callq 0xaeb0
cmpl $0x0, %eax
jne 0x1761e
movl $0x0, -0x4(%rbp)
jmp 0x1781f
jmp 0x1756d
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq %rsi, %rdx
addq $0xd0, %rdx
callq 0xa630
movl %eax, %ecx
movq %rcx, -0x38(%rbp)
subl $0x6, %eax
ja 0x17689
movq -0x38(%rbp), %rax
leaq 0x7928(%rip), %rcx      # 0x1ef78
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x0, -0x4(%rbp)
jmp 0x1781f
jmp 0x17689
movl $0x3, -0x1c(%rbp)
jmp 0x17689
movl $0x2, -0x1c(%rbp)
jmp 0x17689
movl $0x1, -0x1c(%rbp)
jmp 0x17689
movl $0x0, -0x1c(%rbp)
movq -0x10(%rbp), %rdi
callq 0xb160
cmpl $0x0, %eax
jle 0x1769c
jmp 0x1756d
cmpl $0x0, -0x1c(%rbp)
je 0x177d0
cmpl $0x3, -0x1c(%rbp)
jge 0x176ec
movq -0x10(%rbp), %rdi
movl $0x3, %esi
callq 0x18090
cmpl $0x0, %eax
je 0x176ec
movl $0x0, -0x1c(%rbp)
movq -0x10(%rbp), %rdi
movl $0x1, %edx
movl %edx, %esi
callq 0xaeb0
cmpl $0x0, %eax
jne 0x176e7
movl $0x0, -0x4(%rbp)
jmp 0x1781f
jmp 0x1756d
cmpl $0x2, -0x1c(%rbp)
jne 0x17732
movq -0x10(%rbp), %rdi
movl $0x40, %esi
callq 0x18090
cmpl $0x0, %eax
jne 0x17732
movl $0x0, -0x1c(%rbp)
movq -0x10(%rbp), %rdi
movl $0x1, %edx
movl %edx, %esi
callq 0xaeb0
cmpl $0x0, %eax
jne 0x1772d
movl $0x0, -0x4(%rbp)
jmp 0x1781f
jmp 0x1756d
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x10(%rbp), %rcx
movslq 0x8(%rcx), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movq -0x10(%rbp), %rcx
movslq 0x40(%rcx), %rcx
movzwl (%rax,%rcx,2), %esi
callq 0x18260
movw %ax, -0x22(%rbp)
movzwl -0x22(%rbp), %eax
movq -0x10(%rbp), %rcx
movq 0x38(%rcx), %rcx
movq -0x10(%rbp), %rdx
movslq 0x40(%rdx), %rdx
movzwl (%rcx,%rdx,2), %ecx
cmpl %ecx, %eax
je 0x177ae
movq -0x10(%rbp), %rax
movl $0x1, 0x94(%rax)
movq -0x10(%rbp), %rdi
movl $0x1, %edx
movzwl -0x22(%rbp), %esi
callq 0x182d0
cmpl $0x0, %eax
jne 0x177ac
movl $0x0, -0x4(%rbp)
jmp 0x1781f
jmp 0x177ce
movq -0x10(%rbp), %rdi
movl $0x1, %edx
movl %edx, %esi
callq 0xaeb0
cmpl $0x0, %eax
jne 0x177cc
movl $0x0, -0x4(%rbp)
jmp 0x1781f
jmp 0x177ce
jmp 0x177f0
movq -0x10(%rbp), %rdi
movl $0x1, %edx
movl %edx, %esi
callq 0xaeb0
cmpl $0x0, %eax
jne 0x177ee
movl $0x0, -0x4(%rbp)
jmp 0x1781f
jmp 0x177f0
cmpl $0x1, -0x1c(%rbp)
jne 0x177fd
movl $0x0, -0x1c(%rbp)
jmp 0x1756d
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
nopl (%rax,%rax)