// File: /workspace/github_c_makefile_star2_O0/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
subq $0xf0, %rsp
movq %rsi, -0x20(%rbp)
movq %rdx, -0x18(%rbp)
movq %rdi, -0x28(%rbp)
movq %rcx, -0x30(%rbp)
leaq -0x40(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x1110
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x1110
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rcx
movq -0x20(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x4c60
movq %rax, -0x60(%rbp)
movq %rdx, -0x58(%rbp)
leaq -0x60(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x42ad
jmp 0x42cc
leaq 0x4779(%rip), %rdi      # 0x8a2d
leaq 0x3f72(%rip), %rsi      # 0x822d
movl $0x227, %edx            # imm = 0x227
leaq 0x4783(%rip), %rcx      # 0x8a4a
callq 0x1100
leaq -0xa0(%rbp), %rdi
xorl %esi, %esi
movl $0x30, %edx
callq 0x1110
movq -0x30(%rbp), %rdi
movq -0x68(%rbp), %rax
movq 0x8(%rax), %rsi
leaq -0xa0(%rbp), %rcx
movl $0x2, %edx
callq 0x4610
cmpl $0x0, %eax
jne 0x44f3
movq -0x88(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0x78(%rbp), %rax
movq %rax, -0xa8(%rbp)
cmpl $-0x1, -0xb8(%rbp)
je 0x433d
cmpl $-0x1, -0xb4(%rbp)
je 0x433d
jmp 0x435c
leaq 0x4762(%rip), %rdi      # 0x8aa6
leaq 0x3ee2(%rip), %rsi      # 0x822d
movl $0x22c, %edx            # imm = 0x22C
leaq 0x46f3(%rip), %rcx      # 0x8a4a
callq 0x1100
movq -0xb0(%rbp), %rcx
movq %rcx, %rax
incq %rax
movq %rsp, %rdx
movq %rdx, -0xc8(%rbp)
addq $0x10, %rcx
andq $-0x10, %rcx
movq %rsp, %rdi
subq %rcx, %rdi
movq %rdi, -0xe8(%rbp)
movq %rdi, %rsp
movq %rax, -0xd0(%rbp)
movq -0xb0(%rbp), %rax
movb $0x0, (%rdi,%rax)
movq -0xa8(%rbp), %rsi
movq -0xb0(%rbp), %rdx
callq 0x1050
movq -0xe8(%rbp), %rsi
movq -0x28(%rbp), %rdi
movl $0x1, %edx
callq 0x4740
movq %rax, -0xc0(%rbp)
cmpq $0x0, %rax
je 0x4421
movq -0xc0(%rbp), %rax
cmpl $0x1, 0x20(%rax)
jne 0x4421
leaq -0xa0(%rbp), %rax
movq -0xc0(%rbp), %rsi
addq $0x28, %rsi
movq -0x68(%rbp), %rdx
leaq -0x50(%rbp), %rdi
subq $0x20, %rsp
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x5110
addq $0x20, %rsp
jmp 0x44a0
leaq 0x42f4(%rip), %rdi      # 0x871c
movb $0x0, %al
callq 0x10d0
movq -0x68(%rbp), %rax
movq 0x8(%rax), %rsi
leaq 0x4313(%rip), %rdi      # 0x8751
movb $0x0, %al
callq 0x10d0
cmpq $0x0, -0xc0(%rbp)
je 0x4451
jmp 0x4470
leaq 0x4303(%rip), %rdi      # 0x875b
leaq 0x3dce(%rip), %rsi      # 0x822d
movl $0x23a, %edx            # imm = 0x23A
leaq 0x45df(%rip), %rcx      # 0x8a4a
callq 0x1100
movq -0xc0(%rbp), %rax
cmpl $0x1, 0x20(%rax)
jne 0x447f
jmp 0x449e
leaq 0x46f5(%rip), %rdi      # 0x8b7b
leaq 0x3da0(%rip), %rsi      # 0x822d
movl $0x23b, %edx            # imm = 0x23B
leaq 0x45b1(%rip), %rcx      # 0x8a4a
callq 0x1100
jmp 0x44a0
movq -0x38(%rbp), %rdi
callq 0x1030
movq -0x50(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x38(%rbp)
movq $0x0, -0x50(%rbp)
movq $0x0, -0x48(%rbp)
leaq -0x40(%rbp), %rax
movq %rax, -0x68(%rbp)
leaq -0xa0(%rbp), %rdi
xorl %esi, %esi
movl $0x30, %edx
callq 0x1110
movq -0xc8(%rbp), %rax
movq %rax, %rsp
jmp 0x42df
movq -0x28(%rbp), %rdi
movq -0x68(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0x5200
movq %rax, -0xe0(%rbp)
movq %rdx, -0xd8(%rbp)
movq -0xd8(%rbp), %rax
cmpq -0x38(%rbp), %rax
je 0x4533
cmpq $0x0, -0x38(%rbp)
je 0x4533
movq -0x68(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x1030
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rdx
leaq -0xe0(%rbp), %rsi
callq 0x5490
movq %rax, -0x10(%rbp)
movq %rdx, -0x8(%rbp)
movq -0x8(%rbp), %rax
cmpq -0x38(%rbp), %rax
je 0x456d
cmpq $0x0, -0x38(%rbp)
je 0x456d
movq -0x68(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x1030
movq -0x10(%rbp), %rax
movq -0x8(%rbp), %rdx
movq %rbp, %rsp
popq %rbp
retq
nopw (%rax,%rax)