// File: /workspace/github_c_makefile_star2_O1/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 $0xa8, %rsp
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
movq %rdi, -0x38(%rbp)
movq %rcx, -0x30(%rbp)
callq 0x3cf8
movq %rax, -0x60(%rbp)
movq %rdx, -0x58(%rbp)
testq %rdx, %rdx
je 0x3b35
leaq -0xc0(%rbp), %rcx
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rcx)
movaps %xmm0, 0x10(%rcx)
movaps %xmm0, (%rcx)
movq -0x48(%rbp), %r12
movq -0x58(%rbp), %rsi
movl $0x2, %edx
movq -0x30(%rbp), %rdi
callq 0x3b54
testl %eax, %eax
je 0x3899
leaq -0x60(%rbp), %rbx
jmp 0x3a2d
leaq -0x60(%rbp), %r15
cmpl $-0x1, -0xa8(%rbp)
je 0x3af7
cmpl $-0x1, -0xa4(%rbp)
je 0x3af7
movq %rsp, -0x40(%rbp)
movq -0xa0(%rbp), %rdx
movq -0x98(%rbp), %rsi
movq %rsp, %rbx
leaq 0x10(%rdx), %rax
andq $-0x10, %rax
subq %rax, %rbx
movq %rbx, %rsp
movb $0x0, (%rdx,%rbx)
movq %rbx, %rdi
callq 0x1050
movq -0x38(%rbp), %rdi
movq %rbx, %rsi
movl $0x1, %edx
callq 0x3c01
testq %rax, %rax
je 0x3aba
movq %rax, %r14
movq %r12, -0x88(%rbp)
cmpl $0x1, 0x20(%rax)
jne 0x39a2
addq $0x28, %r14
movslq -0xc0(%rbp), %r13
movslq -0xbc(%rbp), %rbx
movq %rbx, -0x80(%rbp)
movq %r14, %rdi
callq 0x10c0
movq %rax, -0x70(%rbp)
movq (%r15), %rcx
subq %rbx, %rcx
movq %rcx, -0x78(%rbp)
leaq (%rax,%r13), %rbx
movq %r13, -0x68(%rbp)
leaq (%rcx,%rbx), %rsi
incq %rsi
addq %rcx, %rbx
movl $0x1, %edi
callq 0x1160
movq %rax, %r12
movq 0x8(%r15), %r15
movq %rax, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x1190
movq %r12, %r13
addq -0x68(%rbp), %r13
movq %r13, %rdi
movq %r14, %rsi
movq -0x70(%rbp), %r14
movq %r14, %rdx
callq 0x1190
addq %r14, %r13
addq -0x80(%rbp), %r15
movq %r13, %rdi
movq %r15, %rsi
movq -0x78(%rbp), %rdx
callq 0x1190
jmp 0x39d6
leaq 0x3283(%rip), %rdi      # 0x6c2c
callq 0x1070
movq 0x8(%r15), %rsi
leaq 0x2d30(%rip), %rdi      # 0x66e9
xorl %eax, %eax
callq 0x10e0
cmpl $0x1, 0x20(%r14)
movl $0x0, %ebx
movl $0x0, %r12d
jne 0x3b16
movq -0x88(%rbp), %rdi
callq 0x1030
movq %rbx, -0x50(%rbp)
movq %r12, -0x48(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0xc0(%rbp)
movaps %xmm0, -0xb0(%rbp)
movaps %xmm0, -0xa0(%rbp)
movq -0x40(%rbp), %rsp
movl $0x2, %edx
movq -0x30(%rbp), %rdi
movq %r12, %rsi
leaq -0xc0(%rbp), %rcx
callq 0x3b54
leaq -0x50(%rbp), %rbx
movq %rbx, %r15
testl %eax, %eax
je 0x389d
movq -0x38(%rbp), %rdi
movq %rbx, %rsi
movq -0x30(%rbp), %rdx
callq 0x410a
movq %rax, -0xd0(%rbp)
movq %rdx, -0xc8(%rbp)
movq -0x48(%rbp), %r15
cmpq %r15, %rdx
sete %al
testq %r15, %r15
sete %cl
orb %al, %cl
jne 0x3a68
movq 0x8(%rbx), %rdi
callq 0x1030
movq %rbx, -0x40(%rbp)
testq %r15, %r15
sete %r12b
leaq -0xd0(%rbp), %rsi
movq -0x38(%rbp), %rdi
movq -0x30(%rbp), %rdx
callq 0x436b
movq %rax, %rbx
movq %rdx, %r14
cmpq %r15, %rdx
sete %al
orb %r12b, %al
jne 0x3aa5
movq -0x40(%rbp), %rax
movq 0x8(%rax), %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 0x316b(%rip), %rdi      # 0x6c2c
callq 0x1070
movq 0x8(%r15), %rsi
leaq 0x2c18(%rip), %rdi      # 0x66e9
xorl %eax, %eax
callq 0x10e0
leaq 0x2c14(%rip), %rdi      # 0x66f3
leaq 0x2758(%rip), %rsi      # 0x623e
leaq 0x2ef5(%rip), %rcx      # 0x69e2
movl $0x23a, %edx            # imm = 0x23A
callq 0x1110
leaq 0x2f40(%rip), %rdi      # 0x6a3e
leaq 0x2739(%rip), %rsi      # 0x623e
leaq 0x2ed6(%rip), %rcx      # 0x69e2
movl $0x22c, %edx            # imm = 0x22C
callq 0x1110
leaq 0x2ff6(%rip), %rdi      # 0x6b13
leaq 0x271a(%rip), %rsi      # 0x623e
leaq 0x2eb7(%rip), %rcx      # 0x69e2
movl $0x23b, %edx            # imm = 0x23B
callq 0x1110
leaq 0x2e89(%rip), %rdi      # 0x69c5
leaq 0x26fb(%rip), %rsi      # 0x623e
leaq 0x2e98(%rip), %rcx      # 0x69e2
movl $0x227, %edx            # imm = 0x227
callq 0x1110