// File: /workspace/github_c_makefile_star2_O2/qpfiffer[P]38-Moths/src/greshunkel.c
// Function: interpolate_line
static line
_interpolate_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};

	/* Do context variables first: */
	const line _operating_line = _interpolate_line_subcontext(ctext, current_line, all_regex);
	const line *operating_line = &_operating_line;
	assert(operating_line->data != NULL);

	match_t match[2] = {0};
	while (regexec_2_0_beta(&all_regex->c_var_regex, operating_line->data, 2, match) == 0) {
		const match_t inner_match = match[1];
		assert(inner_match.rm_so != -1 && inner_match.rm_eo != -1);

		const greshunkel_tuple *tuple;
		/* Copy the string here so we only get the match, not everything after it. */
		char just_match_str[inner_match.len + 1];
		just_match_str[inner_match.len] = '\0';
		strncpy(just_match_str, inner_match.start, inner_match.len);

		if ((tuple = find_needle(ctext, just_match_str, 1)) && tuple->type == GSHKL_STR) {
			vishnu(&new_line_to_add, match[0], tuple->value.str, operating_line);
		} else {
			/* Blow up if we had a variable that wasn't in the context. */
			printf("Did not match a variable that needed to be matched.\n");
			printf("Line: %s\n", operating_line->data);
			assert(tuple != NULL);
			assert(tuple->type == GSHKL_STR);
		}

		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(match, 0, sizeof(match));
	}

	/* SCREAM includes */
	line included_line = _include_line(ctext, operating_line, all_regex);
	if (included_line.data != interpolated_line.data && interpolated_line.data != NULL)
		free(operating_line->data);

	line filtered_line = _filter_line(ctext, &included_line, all_regex);
	if (filtered_line.data != interpolated_line.data && interpolated_line.data != NULL)
		free(operating_line->data);

	return filtered_line;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rcx, %rbx
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
movaps %xmm0, -0x40(%rbp)
movq %rdi, -0x30(%rbp)
callq 0x37bd
movq %rax, -0xa0(%rbp)
movq %rdx, -0x98(%rbp)
testq %rdx, %rdx
je 0x352b
movq %rdx, %rsi
leaq -0x80(%rbp), %rax
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rax)
movaps %xmm0, 0x10(%rax)
movaps %xmm0, (%rax)
leaq -0xa0(%rbp), %r15
xorl %r13d, %r13d
movq %rbx, %rdi
pushq $0x2
popq %rdx
leaq -0x80(%rbp), %rcx
callq 0x354a
testl %eax, %eax
jne 0x342d
cmpl $-0x1, -0x68(%rbp)
je 0x34ed
cmpl $-0x1, -0x64(%rbp)
je 0x34ed
movq %rsp, %r14
movq -0x60(%rbp), %rdx
movq -0x58(%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 -0x30(%rbp), %rdi
movq %r12, %rsi
pushq $0x1
popq %rdx
callq 0x35f0
testq %rax, %rax
je 0x34b0
movq %rax, %r12
cmpl $0x1, 0x20(%rax)
jne 0x33c9
addq $0x28, %r12
subq $0x20, %rsp
movq -0x70(%rbp), %rax
movq %rax, 0x10(%rsp)
movaps -0x80(%rbp), %xmm0
movups %xmm0, (%rsp)
leaq -0x40(%rbp), %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x3b20
addq $0x20, %rsp
jmp 0x33f3
leaq 0x385c(%rip), %rdi      # 0x6c2c
callq 0x1070
movq 0x8(%r15), %rsi
leaq 0x3309(%rip), %rdi      # 0x66e9
xorl %eax, %eax
callq 0x10e0
cmpl $0x1, 0x20(%r12)
jne 0x350c
movq %r13, %rdi
callq 0x1030
movq -0x40(%rbp), %rax
movq -0x38(%rbp), %rsi
movq %rax, -0x50(%rbp)
movq %rsi, -0x48(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x40(%rbp)
movaps %xmm0, -0x80(%rbp)
movaps %xmm0, -0x70(%rbp)
movaps %xmm0, -0x60(%rbp)
movq %r14, %rsp
movq %rsi, %r13
leaq -0x50(%rbp), %r15
jmp 0x3326
movq -0x30(%rbp), %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x3bc6
movq %rax, -0x90(%rbp)
movq %rdx, -0x88(%rbp)
movq -0x48(%rbp), %r12
cmpq %r12, %rdx
sete %al
testq %r12, %r12
sete %cl
orb %al, %cl
jne 0x3467
movq 0x8(%r15), %rdi
callq 0x1030
testq %r12, %r12
sete %r13b
leaq -0x90(%rbp), %rsi
movq -0x30(%rbp), %rdi
movq %rbx, %rdx
callq 0x3de1
movq %rax, %rbx
movq %rdx, %r14
cmpq %r12, %rdx
sete %al
orb %r13b, %al
jne 0x349b
movq 0x8(%r15), %rdi
callq 0x1030
movq %rbx, %rax
movq %r14, %rdx
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3775(%rip), %rdi      # 0x6c2c
callq 0x1070
movq 0x8(%r15), %rsi
leaq 0x3222(%rip), %rdi      # 0x66e9
xorl %eax, %eax
callq 0x10e0
leaq 0x321e(%rip), %rdi      # 0x66f3
leaq 0x2d62(%rip), %rsi      # 0x623e
leaq 0x34ff(%rip), %rcx      # 0x69e2
movl $0x23a, %edx            # imm = 0x23A
callq 0x1110
leaq 0x354a(%rip), %rdi      # 0x6a3e
leaq 0x2d43(%rip), %rsi      # 0x623e
leaq 0x34e0(%rip), %rcx      # 0x69e2
movl $0x22c, %edx            # imm = 0x22C
callq 0x1110
leaq 0x3600(%rip), %rdi      # 0x6b13
leaq 0x2d24(%rip), %rsi      # 0x623e
leaq 0x34c1(%rip), %rcx      # 0x69e2
movl $0x23b, %edx            # imm = 0x23B
callq 0x1110
leaq 0x3493(%rip), %rdi      # 0x69c5
leaq 0x2d05(%rip), %rsi      # 0x623e
leaq 0x34a2(%rip), %rcx      # 0x69e2
movl $0x227, %edx            # imm = 0x227
callq 0x1110