// File: /workspace/github_c_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rsi, %r13
movq %rdi, -0x70(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
movaps %xmm0, -0x40(%rbp)
movq 0x8(%rsi), %rsi
testq %rsi, %rsi
je 0x4594
movq %rdx, %r15
leaq 0x8(%r13), %rbx
leaq 0xc0(%rdx), %r14
leaq -0x100(%rbp), %rcx
movl $0x3, %edx
movq %r14, %rdi
callq 0x3a75
testl %eax, %eax
je 0x426b
movq (%rbx), %r12
xorl %r14d, %r14d
jmp 0x43c7
movq %r15, -0x58(%rbp)
movq (%rbx), %r12
xorl %ecx, %ecx
movq %r14, -0x78(%rbp)
movq %rcx, -0x60(%rbp)
movq %r13, -0x30(%rbp)
movl -0x100(%rbp), %eax
movl %eax, -0x64(%rbp)
movq -0xf0(%rbp), %rdi
leaq 0x2966(%rip), %rsi      # 0x6bfd
callq 0x1200
testq %rax, %rax
je 0x4518
movq %rax, %r13
movq %rsp, -0x80(%rbp)
movq -0xe0(%rbp), %rdx
movq -0xd8(%rbp), %rsi
movq -0xc0(%rbp), %rbx
movq %rsp, %r15
leaq 0x10(%rdx), %rax
andq $-0x10, %rax
subq %rax, %r15
movq %r15, %rsp
movb $0x0, (%rdx,%r15)
movq %r15, %rdi
callq 0x1050
movq -0x70(%rbp), %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x3b22
testq %rax, %rax
je 0x4537
movq %rax, %r15
movl %r13d, %r14d
subl %r12d, %r14d
addl $0x4, %r14d
subq %rbx, %r13
movq %rbx, %rdi
movq %r13, %rsi
callq 0x1150
movq %rax, %rbx
movq %rax, %rdi
callq *0x20(%r15)
movq %rax, %r12
leaq -0x40(%rbp), %rdi
movl -0x64(%rbp), %esi
movl %r14d, %edx
movq %rax, %rcx
movq -0x30(%rbp), %r8
callq 0x3f5c
movq 0x28(%r15), %rax
testq %rax, %rax
je 0x4342
movq %r12, %rdi
callq *%rax
movq %rbx, %rdi
callq 0x1030
movq -0x60(%rbp), %rdi
callq 0x1030
movq -0x40(%rbp), %rax
movq -0x38(%rbp), %r12
movq %rax, -0x50(%rbp)
movq %r12, -0x48(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x40(%rbp)
movaps %xmm0, -0x100(%rbp)
movaps %xmm0, -0xf0(%rbp)
movaps %xmm0, -0xe0(%rbp)
movaps %xmm0, -0xd0(%rbp)
movq $0x0, -0xc0(%rbp)
movq -0x80(%rbp), %rsp
movl $0x3, %edx
movq -0x78(%rbp), %rdi
movq %r12, %rsi
leaq -0x100(%rbp), %rcx
callq 0x3a75
leaq -0x50(%rbp), %r13
movq %r12, %rcx
testl %eax, %eax
je 0x4278
movq %r12, %r14
leaq -0x48(%rbp), %rbx
movq -0x58(%rbp), %r15
addq $0x100, %r15            # imm = 0x100
leaq -0xb0(%rbp), %rcx
movl $0x2, %edx
movq %r15, %rdi
movq %r12, %rsi
callq 0x3a75
testl %eax, %eax
je 0x43f5
movq (%r13), %r14
movq (%rbx), %rbx
jmp 0x4503
movq %r14, -0x30(%rbp)
movq (%rbx), %rbx
movq %r15, -0x58(%rbp)
movl -0xb0(%rbp), %r14d
movq -0xa0(%rbp), %rdi
leaq 0x27e8(%rip), %rsi      # 0x6bfd
callq 0x1200
testq %rax, %rax
je 0x4556
movq %rax, %r12
movq %rsp, -0x60(%rbp)
movq -0x90(%rbp), %rdx
movq -0x88(%rbp), %rsi
movq %rsp, %r15
leaq 0x10(%rdx), %rax
andq $-0x10, %rax
subq %rax, %r15
movq %r15, %rsp
movb $0x0, (%rdx,%r15)
movq %r15, %rdi
callq 0x1050
movq -0x70(%rbp), %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x3b22
testq %rax, %rax
je 0x4575
movq %rax, %r15
subl %ebx, %r12d
addl $0x4, %r12d
xorl %edi, %edi
callq *0x20(%rax)
movq %rax, %rbx
leaq -0x40(%rbp), %rdi
movl %r14d, %esi
movl %r12d, %edx
movq %rax, %rcx
movq %r13, %r8
callq 0x3f5c
movq 0x28(%r15), %rax
testq %rax, %rax
je 0x44a2
movq %rbx, %rdi
callq *%rax
movq -0x30(%rbp), %rdi
callq 0x1030
movq -0x40(%rbp), %r14
movq -0x38(%rbp), %rbx
movq %r14, -0x50(%rbp)
movq %rbx, -0x48(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x40(%rbp)
movaps %xmm0, -0xb0(%rbp)
movaps %xmm0, -0xa0(%rbp)
movaps %xmm0, -0x90(%rbp)
movq -0x60(%rbp), %rsp
movl $0x2, %edx
movq -0x58(%rbp), %rdi
movq %rbx, %rsi
leaq -0xb0(%rbp), %rcx
callq 0x3a75
leaq -0x50(%rbp), %r13
movq %rbx, -0x30(%rbp)
testl %eax, %eax
je 0x4400
movq %r14, %rax
movq %rbx, %rdx
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x26e3(%rip), %rdi      # 0x6c02
leaq 0x1d18(%rip), %rsi      # 0x623e
leaq 0x2677(%rip), %rcx      # 0x6ba4
movl $0x154, %edx            # imm = 0x154
callq 0x1110
leaq 0x26df(%rip), %rdi      # 0x6c1d
leaq 0x1cf9(%rip), %rsi      # 0x623e
leaq 0x2658(%rip), %rcx      # 0x6ba4
movl $0x16f, %edx            # imm = 0x16F
callq 0x1110
leaq 0x26a5(%rip), %rdi      # 0x6c02
leaq 0x1cda(%rip), %rsi      # 0x623e
leaq 0x2639(%rip), %rcx      # 0x6ba4
movl $0x186, %edx            # imm = 0x186
callq 0x1110
leaq 0x26a1(%rip), %rdi      # 0x6c1d
leaq 0x1cbb(%rip), %rsi      # 0x623e
leaq 0x261a(%rip), %rcx      # 0x6ba4
movl $0x197, %edx            # imm = 0x197
callq 0x1110
leaq 0x242a(%rip), %rdi      # 0x69c5
leaq 0x1c9c(%rip), %rsi      # 0x623e
leaq 0x25fb(%rip), %rcx      # 0x6ba4
movl $0x148, %edx            # imm = 0x148
callq 0x1110
nop