// File: /workspace/github_c_makefile_star2_O0/qpfiffer[P]38-Moths/src/greshunkel.c
// Function: filter_line
static line
_filter_line(const greshunkel_ctext *ctext, const line *current_line, const struct compiled_regex *all_regex) {
	line interpolated_line = {0};
	line new_line_to_add = {0};
	const line *operating_line = current_line;
	assert(operating_line->data != NULL);

	/* Now we match template filters: */
	match_t filter_matches[3];
	while (regexec_2_0_beta(&all_regex->c_filter_regex, operating_line->data, 3, filter_matches) == 0) {
		match_t whole_match = filter_matches[0];
		const char *start_of_first_XxX = strstr(whole_match.start, " XxX");
		const char *end_of_first_XxX = start_of_first_XxX + strlen(" XxX");
		const size_t full_diff = end_of_first_XxX - whole_match.start;

		whole_match.rm_eo = (whole_match.start + full_diff) - operating_line->data;
		whole_match.len = full_diff;
		assert(start_of_first_XxX != NULL);

		const match_t function_name = filter_matches[1];
		const match_t argument = filter_matches[2];

		const greshunkel_filter *filter;
		char just_match_str[function_name.len + 1];
		just_match_str[function_name.len] = '\0';
		strncpy(just_match_str, function_name.start, function_name.len);

		if ((filter = find_needle(ctext, just_match_str, 0))) {

			const size_t new_len = start_of_first_XxX - argument.start;

			/* Render the argument out so we can pass it to the filter function. */
			char *rendered_argument = strndup(argument.start, new_len);

			/* Pass it to the filter function. */
			char *filter_result = filter->filter_func(rendered_argument);

			vishnu(&new_line_to_add, whole_match, filter_result, operating_line);

			if (filter->clean_up != NULL)
				filter->clean_up(filter_result);

			free(rendered_argument);
		}
		assert(filter != NULL);

		free(interpolated_line.data);
		interpolated_line.size = new_line_to_add.size;
		interpolated_line.data = new_line_to_add.data;
		new_line_to_add.size = 0;
		new_line_to_add.data = NULL;
		operating_line = &interpolated_line;

		/* Set the next regex check after this one. */
		memset(filter_matches, 0, sizeof(filter_matches));
	}

	/* No arguments matching. */
	match_t filter_matches_no_args[2];
	while (regexec_2_0_beta(&all_regex->c_filter_no_args_regex, operating_line->data, 2, filter_matches_no_args) == 0) {
		match_t whole_match = filter_matches_no_args[0];
		const char *start_of_first_XxX = strstr(whole_match.start, " XxX");
		const char *end_of_first_XxX = start_of_first_XxX + strlen(" XxX");
		const size_t full_diff = end_of_first_XxX - whole_match.start;

		whole_match.rm_eo = (whole_match.start + full_diff) - operating_line->data;
		whole_match.len = full_diff;
		assert(start_of_first_XxX != NULL);

		const match_t function_name = filter_matches_no_args[1];

		const greshunkel_filter *filter;
		char just_match_str[function_name.len + 1];
		just_match_str[function_name.len] = '\0';
		strncpy(just_match_str, function_name.start, function_name.len);

		if ((filter = find_needle(ctext, just_match_str, 0))) {
			char *filter_result = filter->filter_func(NULL);

			vishnu(&new_line_to_add, whole_match, filter_result, operating_line);

			if (filter->clean_up != NULL)
				filter->clean_up(filter_result);
		}
		assert(filter != NULL);

		free(interpolated_line.data);
		interpolated_line.size = new_line_to_add.size;
		interpolated_line.data = new_line_to_add.data;
		new_line_to_add.size = 0;
		new_line_to_add.data = NULL;
		operating_line = &interpolated_line;

		memset(filter_matches_no_args, 0, sizeof(filter_matches_no_args));
	}

	return *operating_line;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1f0, %rsp            # imm = 0x1F0
movq %rdi, -0x18(%rbp)
movq %rsi, -0x20(%rbp)
movq %rdx, -0x28(%rbp)
leaq -0x38(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x1110
leaq -0x48(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x1110
movq -0x20(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x54dc
jmp 0x54fb
leaq 0x354a(%rip), %rdi      # 0x8a2d
leaq 0x2d43(%rip), %rsi      # 0x822d
movl $0x148, %edx            # imm = 0x148
leaq 0x37d4(%rip), %rcx      # 0x8cca
callq 0x1100
jmp 0x54fd
movq -0x28(%rbp), %rdi
addq $0xc0, %rdi
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rsi
leaq -0xa0(%rbp), %rcx
movl $0x3, %edx
callq 0x4610
cmpl $0x0, %eax
jne 0x57cb
movq -0xa0(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0x98(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0x90(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rdi
leaq 0x37c1(%rip), %rsi      # 0x8d23
callq 0x11f0
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rax
addq $0x4, %rax
movq %rax, -0xc8(%rbp)
movq -0xc8(%rbp), %rax
movq -0xa8(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0xd0(%rbp)
movq -0xa8(%rbp), %rax
addq -0xd0(%rbp), %rax
movq -0x50(%rbp), %rcx
movq 0x8(%rcx), %rcx
subq %rcx, %rax
movl %eax, -0xb4(%rbp)
movq -0xd0(%rbp), %rax
movq %rax, -0xb0(%rbp)
cmpq $0x0, -0xc0(%rbp)
je 0x55d1
jmp 0x55f0
leaq 0x3750(%rip), %rdi      # 0x8d28
leaq 0x2c4e(%rip), %rsi      # 0x822d
movl $0x154, %edx            # imm = 0x154
leaq 0x36df(%rip), %rcx      # 0x8cca
callq 0x1100
movq -0x78(%rbp), %rax
movq %rax, -0xe0(%rbp)
movups -0x88(%rbp), %xmm0
movaps %xmm0, -0xf0(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x100(%rbp)
movaps -0x70(%rbp), %xmm0
movaps %xmm0, -0x110(%rbp)
movq -0xe8(%rbp), %rcx
movq %rcx, %rax
incq %rax
movq %rsp, %rdx
movq %rdx, -0x120(%rbp)
addq $0x10, %rcx
andq $-0x10, %rcx
movq %rsp, %rdi
subq %rcx, %rdi
movq %rdi, -0x1e8(%rbp)
movq %rdi, %rsp
movq %rax, -0x128(%rbp)
movq -0xe8(%rbp), %rax
movb $0x0, (%rdi,%rax)
movq -0xe0(%rbp), %rsi
movq -0xe8(%rbp), %rdx
callq 0x1050
movq -0x1e8(%rbp), %rsi
movq -0x18(%rbp), %rdi
xorl %edx, %edx
callq 0x4740
movq %rax, -0x118(%rbp)
cmpq $0x0, %rax
je 0x574d
movq -0xc0(%rbp), %rax
movq -0x100(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x130(%rbp)
movq -0x100(%rbp), %rdi
movq -0x130(%rbp), %rsi
callq 0x1140
movq %rax, -0x138(%rbp)
movq -0x118(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x138(%rbp), %rdi
callq *%rax
movq %rax, -0x140(%rbp)
movq -0x140(%rbp), %rsi
movq -0x50(%rbp), %rdx
leaq -0x48(%rbp), %rdi
leaq -0xb8(%rbp), %rax
subq $0x20, %rsp
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x5110
addq $0x20, %rsp
movq -0x118(%rbp), %rax
cmpq $0x0, 0x28(%rax)
je 0x5741
movq -0x118(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x140(%rbp), %rdi
callq *%rax
movq -0x138(%rbp), %rdi
callq 0x1030
cmpq $0x0, -0x118(%rbp)
je 0x5759
jmp 0x5778
leaq 0x35e3(%rip), %rdi      # 0x8d43
leaq 0x2ac6(%rip), %rsi      # 0x822d
movl $0x16f, %edx            # imm = 0x16F
leaq 0x3557(%rip), %rcx      # 0x8cca
callq 0x1100
movq -0x30(%rbp), %rdi
callq 0x1030
movq -0x48(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x30(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0x40(%rbp)
leaq -0x38(%rbp), %rax
movq %rax, -0x50(%rbp)
leaq -0xa0(%rbp), %rdi
xorl %esi, %esi
movl $0x48, %edx
callq 0x1110
movq -0x120(%rbp), %rax
movq %rax, %rsp
jmp 0x54fd
jmp 0x57cd
movq -0x28(%rbp), %rdi
addq $0x100, %rdi            # imm = 0x100
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rsi
leaq -0x170(%rbp), %rcx
movl $0x2, %edx
callq 0x4610
cmpl $0x0, %eax
jne 0x5a42
movq -0x170(%rbp), %rax
movq %rax, -0x188(%rbp)
movq -0x168(%rbp), %rax
movq %rax, -0x180(%rbp)
movq -0x160(%rbp), %rax
movq %rax, -0x178(%rbp)
movq -0x178(%rbp), %rdi
leaq 0x34f1(%rip), %rsi      # 0x8d23
callq 0x11f0
movq %rax, -0x190(%rbp)
movq -0x190(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x198(%rbp)
movq -0x198(%rbp), %rax
movq -0x178(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x1a0(%rbp)
movq -0x178(%rbp), %rax
addq -0x1a0(%rbp), %rax
movq -0x50(%rbp), %rcx
movq 0x8(%rcx), %rcx
subq %rcx, %rax
movl %eax, -0x184(%rbp)
movq -0x1a0(%rbp), %rax
movq %rax, -0x180(%rbp)
cmpq $0x0, -0x190(%rbp)
je 0x58a1
jmp 0x58c0
leaq 0x3480(%rip), %rdi      # 0x8d28
leaq 0x297e(%rip), %rsi      # 0x822d
movl $0x186, %edx            # imm = 0x186
leaq 0x340f(%rip), %rcx      # 0x8cca
callq 0x1100
movq -0x148(%rbp), %rax
movq %rax, -0x1b0(%rbp)
movups -0x158(%rbp), %xmm0
movaps %xmm0, -0x1c0(%rbp)
movq -0x1b8(%rbp), %rcx
movq %rcx, %rax
incq %rax
movq %rsp, %rdx
movq %rdx, -0x1d0(%rbp)
addq $0x10, %rcx
andq $-0x10, %rcx
movq %rsp, %rdi
subq %rcx, %rdi
movq %rdi, -0x1f0(%rbp)
movq %rdi, %rsp
movq %rax, -0x1d8(%rbp)
movq -0x1b8(%rbp), %rax
movb $0x0, (%rdi,%rax)
movq -0x1b0(%rbp), %rsi
movq -0x1b8(%rbp), %rdx
callq 0x1050
movq -0x1f0(%rbp), %rsi
movq -0x18(%rbp), %rdi
xorl %edx, %edx
callq 0x4740
movq %rax, -0x1c8(%rbp)
cmpq $0x0, %rax
je 0x59c4
movq -0x1c8(%rbp), %rax
xorl %ecx, %ecx
movl %ecx, %edi
callq *0x20(%rax)
movq %rax, -0x1e0(%rbp)
movq -0x1e0(%rbp), %rsi
movq -0x50(%rbp), %rdx
leaq -0x48(%rbp), %rdi
leaq -0x188(%rbp), %rax
subq $0x20, %rsp
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x5110
addq $0x20, %rsp
movq -0x1c8(%rbp), %rax
cmpq $0x0, 0x28(%rax)
je 0x59c2
movq -0x1c8(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x1e0(%rbp), %rdi
callq *%rax
jmp 0x59c4
cmpq $0x0, -0x1c8(%rbp)
je 0x59d0
jmp 0x59ef
leaq 0x336c(%rip), %rdi      # 0x8d43
leaq 0x284f(%rip), %rsi      # 0x822d
movl $0x197, %edx            # imm = 0x197
leaq 0x32e0(%rip), %rcx      # 0x8cca
callq 0x1100
movq -0x30(%rbp), %rdi
callq 0x1030
movq -0x48(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x30(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0x40(%rbp)
leaq -0x38(%rbp), %rax
movq %rax, -0x50(%rbp)
leaq -0x170(%rbp), %rdi
xorl %esi, %esi
movl $0x30, %edx
callq 0x1110
movq -0x1d0(%rbp), %rax
movq %rax, %rsp
jmp 0x57cd
movq -0x50(%rbp), %rax
movups (%rax), %xmm0
movaps %xmm0, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq -0x8(%rbp), %rdx
movq %rbp, %rsp
popq %rbp
retq
nopw (%rax,%rax)