// File: /workspace/github_c_makefile_star2_O3/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 0x3bdd
movq %rax, -0x60(%rbp)
movq %rdx, -0x58(%rbp)
testq %rdx, %rdx
je 0x3a56
movq %rdx, %rsi
leaq -0x90(%rbp), %rcx
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rcx)
movaps %xmm0, 0x10(%rcx)
movaps %xmm0, (%rcx)
movl $0x2, %edx
movq %rbx, %rdi
callq 0x3a75
testl %eax, %eax
je 0x384e
leaq -0x60(%rbp), %r13
movq -0x48(%rbp), %r12
jmp 0x395c
leaq -0x60(%rbp), %r15
xorl %r12d, %r12d
cmpl $-0x1, -0x78(%rbp)
je 0x3a18
cmpl $-0x1, -0x74(%rbp)
je 0x3a18
movq %rbx, %r13
movq %rsp, %rbx
movq -0x70(%rbp), %rdx
movq -0x68(%rbp), %rsi
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 -0x30(%rbp), %rdi
movq %r14, %rsi
movl $0x1, %edx
callq 0x3b22
testq %rax, %rax
je 0x39db
movq %rax, %r14
cmpl $0x1, 0x20(%rax)
jne 0x38d9
addq $0x28, %r14
movl -0x90(%rbp), %esi
movl -0x8c(%rbp), %edx
leaq -0x40(%rbp), %rdi
movq %r14, %rcx
movq %r15, %r8
callq 0x3f5c
jmp 0x3902
leaq 0x334c(%rip), %rdi      # 0x6c2c
callq 0x1070
movq 0x8(%r15), %rsi
leaq 0x2df9(%rip), %rdi      # 0x66e9
xorl %eax, %eax
callq 0x10e0
cmpl $0x1, 0x20(%r14)
jne 0x3a37
movq %r12, %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, -0x90(%rbp)
movaps %xmm0, -0x80(%rbp)
movaps %xmm0, -0x70(%rbp)
movq %rbx, %rsp
movl $0x2, %edx
movq %r13, %rbx
movq %r13, %rdi
movq %r12, %rsi
leaq -0x90(%rbp), %rcx
callq 0x3a75
leaq -0x50(%rbp), %r13
movq %r13, %r15
testl %eax, %eax
je 0x3855
movq -0x30(%rbp), %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x4002
movq %rax, -0xa0(%rbp)
movq %rdx, -0x98(%rbp)
cmpq %r12, %rdx
sete %al
testq %r12, %r12
sete %cl
orb %al, %cl
jne 0x3992
movq 0x8(%r13), %rdi
callq 0x1030
testq %r12, %r12
sete %r15b
leaq -0xa0(%rbp), %rsi
movq -0x30(%rbp), %rdi
movq %rbx, %rdx
callq 0x4207
movq %rax, %rbx
movq %rdx, %r14
cmpq %r12, %rdx
sete %al
orb %r15b, %al
jne 0x39c6
movq 0x8(%r13), %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 0x324a(%rip), %rdi      # 0x6c2c
callq 0x1070
movq 0x8(%r15), %rsi
leaq 0x2cf7(%rip), %rdi      # 0x66e9
xorl %eax, %eax
callq 0x10e0
leaq 0x2cf3(%rip), %rdi      # 0x66f3
leaq 0x2837(%rip), %rsi      # 0x623e
leaq 0x2fd4(%rip), %rcx      # 0x69e2
movl $0x23a, %edx            # imm = 0x23A
callq 0x1110
leaq 0x301f(%rip), %rdi      # 0x6a3e
leaq 0x2818(%rip), %rsi      # 0x623e
leaq 0x2fb5(%rip), %rcx      # 0x69e2
movl $0x22c, %edx            # imm = 0x22C
callq 0x1110
leaq 0x30d5(%rip), %rdi      # 0x6b13
leaq 0x27f9(%rip), %rsi      # 0x623e
leaq 0x2f96(%rip), %rcx      # 0x69e2
movl $0x23b, %edx            # imm = 0x23B
callq 0x1110
leaq 0x2f68(%rip), %rdi      # 0x69c5
leaq 0x27da(%rip), %rsi      # 0x623e
leaq 0x2f77(%rip), %rcx      # 0x69e2
movl $0x227, %edx            # imm = 0x227
callq 0x1110