// File: /workspace/github_c_makefile_star2_O1/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 $0xf8, %rsp
movq %rdi, -0x88(%rbp)
xorl %eax, %eax
movq %rax, -0x40(%rbp)
movq %rax, -0x38(%rbp)
cmpq %rax, 0x8(%rsi)
je 0x47f6
movq %rdx, %rbx
movq %rsi, %r14
leaq 0xc0(%rdx), %r12
movq -0x38(%rbp), %r13
movq 0x8(%rsi), %rsi
leaq -0x120(%rbp), %rcx
movl $0x3, %edx
movq %r12, %rdi
callq 0x3b54
testl %eax, %eax
je 0x43d0
leaq 0x8(%r14), %r15
jmp 0x45b4
movq %rbx, -0x50(%rbp)
leaq 0x8(%r14), %rcx
movq %r12, -0x90(%rbp)
movq %rcx, %r15
movq %r13, -0x80(%rbp)
movq %r14, -0x30(%rbp)
movslq -0x120(%rbp), %rbx
movq -0x110(%rbp), %rdi
leaq 0x27fe(%rip), %rsi      # 0x6bfd
callq 0x1200
testq %rax, %rax
je 0x477a
movq %rax, %r12
movq %rsp, -0x78(%rbp)
movq %r15, -0x70(%rbp)
movq (%r15), %r15
movq -0x100(%rbp), %rdx
movq -0xf8(%rbp), %rsi
movq -0xe0(%rbp), %r13
movq %rsp, %r14
leaq 0x10(%rdx), %rax
andq $-0x10, %rax
subq %rax, %r14
movq %r14, %rsp
movb $0x0, (%rdx,%r14)
movq %r14, %rdi
callq 0x1050
movq -0x88(%rbp), %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x3c01
testq %rax, %rax
je 0x4799
movq %rax, %r14
negq %r15
leaq (%r12,%r15), %rax
addq $0x4, %rax
movq %rax, -0x48(%rbp)
subq %r13, %r12
movq %r13, %rdi
movq %r12, %rsi
callq 0x1150
movq %rax, -0x68(%rbp)
movq %rax, %rdi
callq *0x20(%r14)
movq %rax, -0x98(%rbp)
movq %rax, %rdi
callq 0x10c0
movq %rax, %r12
movq -0x30(%rbp), %rax
movq (%rax), %r15
movslq -0x48(%rbp), %rax
movq %rax, -0x58(%rbp)
subq %rax, %r15
leaq (%r12,%rbx), %rax
movq %rax, -0x48(%rbp)
leaq (%r15,%rax), %rsi
incq %rsi
movl $0x1, %edi
callq 0x1160
movq %r14, -0x60(%rbp)
movq %rax, %r14
movq -0x70(%rbp), %rax
movq (%rax), %r13
movq %r14, %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x1190
movq %r14, -0x30(%rbp)
addq %r14, %rbx
movq -0x98(%rbp), %r14
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x1190
addq %r12, %rbx
addq -0x58(%rbp), %r13
movq %rbx, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x1190
movq -0x60(%rbp), %rax
movq 0x28(%rax), %rax
testq %rax, %rax
je 0x452f
movq %r14, %rdi
callq *%rax
movq -0x48(%rbp), %rbx
addq %r15, %rbx
movq -0x68(%rbp), %rdi
callq 0x1030
movq -0x80(%rbp), %rdi
callq 0x1030
movq %rbx, -0x40(%rbp)
movq -0x30(%rbp), %r13
movq %r13, -0x38(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x120(%rbp)
movaps %xmm0, -0x110(%rbp)
movaps %xmm0, -0x100(%rbp)
movaps %xmm0, -0xf0(%rbp)
movq $0x0, -0xe0(%rbp)
movq -0x78(%rbp), %rsp
movl $0x3, %edx
movq -0x90(%rbp), %rdi
movq %r13, %rsi
leaq -0x120(%rbp), %rcx
callq 0x3b54
leaq -0x40(%rbp), %r14
leaq -0x38(%rbp), %r15
movq %r15, %rcx
testl %eax, %eax
je 0x43df
movq -0x50(%rbp), %rbx
addq $0x100, %rbx            # imm = 0x100
movq -0x38(%rbp), %r12
movq (%r15), %rsi
leaq -0xd0(%rbp), %rcx
movl $0x2, %edx
movq %rbx, %rdi
callq 0x3b54
testl %eax, %eax
jne 0x4765
movq %rbx, -0x50(%rbp)
movq %r12, -0x80(%rbp)
movq %r14, -0x30(%rbp)
movslq -0xd0(%rbp), %rbx
movq -0xc0(%rbp), %rdi
leaq 0x25fe(%rip), %rsi      # 0x6bfd
callq 0x1200
testq %rax, %rax
je 0x47b8
movq %rax, %r14
movq %rsp, -0x78(%rbp)
movq %r15, -0x70(%rbp)
movq (%r15), %r15
movq -0xb0(%rbp), %rdx
movq -0xa8(%rbp), %rsi
movq %rsp, %r12
leaq 0x10(%rdx), %rax
andq $-0x10, %rax
subq %rax, %r12
movq %r12, %rsp
movb $0x0, (%rdx,%r12)
movq %r12, %rdi
callq 0x1050
movq -0x88(%rbp), %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x3c01
testq %rax, %rax
je 0x47d7
negq %r15
addq %r15, %r14
addq $0x4, %r14
xorl %edi, %edi
movq %rax, -0x48(%rbp)
callq *0x20(%rax)
movq %rax, -0x58(%rbp)
movq %rax, %rdi
callq 0x10c0
movq %rax, %r12
movq -0x30(%rbp), %rax
movq (%rax), %r15
movslq %r14d, %rax
movq %rax, -0x60(%rbp)
subq %rax, %r15
leaq (%r12,%rbx), %rax
movq %rax, -0x68(%rbp)
leaq (%r15,%rax), %rsi
incq %rsi
movl $0x1, %edi
callq 0x1160
movq %rax, %r13
movq -0x70(%rbp), %rax
movq (%rax), %r14
movq %r13, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x1190
movq %r13, -0x30(%rbp)
addq %r13, %rbx
movq -0x58(%rbp), %r13
movq %rbx, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x1190
addq %r12, %rbx
addq -0x60(%rbp), %r14
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x1190
movq -0x48(%rbp), %rax
movq 0x28(%rax), %rax
testq %rax, %rax
je 0x4705
movq %r13, %rdi
callq *%rax
movq -0x68(%rbp), %rbx
addq %r15, %rbx
movq -0x80(%rbp), %rdi
callq 0x1030
movq %rbx, -0x40(%rbp)
movq -0x30(%rbp), %r12
movq %r12, -0x38(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0xd0(%rbp)
movaps %xmm0, -0xc0(%rbp)
movaps %xmm0, -0xb0(%rbp)
movq -0x78(%rbp), %rsp
movl $0x2, %edx
movq -0x50(%rbp), %rdi
movq %r12, %rsi
leaq -0xd0(%rbp), %rcx
callq 0x3b54
leaq -0x38(%rbp), %r15
leaq -0x40(%rbp), %r14
testl %eax, %eax
je 0x45e2
movq (%r14), %rax
movq (%r15), %rdx
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2481(%rip), %rdi      # 0x6c02
leaq 0x1ab6(%rip), %rsi      # 0x623e
leaq 0x2415(%rip), %rcx      # 0x6ba4
movl $0x154, %edx            # imm = 0x154
callq 0x1110
leaq 0x247d(%rip), %rdi      # 0x6c1d
leaq 0x1a97(%rip), %rsi      # 0x623e
leaq 0x23f6(%rip), %rcx      # 0x6ba4
movl $0x16f, %edx            # imm = 0x16F
callq 0x1110
leaq 0x2443(%rip), %rdi      # 0x6c02
leaq 0x1a78(%rip), %rsi      # 0x623e
leaq 0x23d7(%rip), %rcx      # 0x6ba4
movl $0x186, %edx            # imm = 0x186
callq 0x1110
leaq 0x243f(%rip), %rdi      # 0x6c1d
leaq 0x1a59(%rip), %rsi      # 0x623e
leaq 0x23b8(%rip), %rcx      # 0x6ba4
movl $0x197, %edx            # imm = 0x197
callq 0x1110
leaq 0x21c8(%rip), %rdi      # 0x69c5
leaq 0x1a3a(%rip), %rsi      # 0x623e
leaq 0x2399(%rip), %rcx      # 0x6ba4
movl $0x148, %edx            # imm = 0x148
callq 0x1110
nopl (%rax)