// File: /workspace/github_c_makefile_star2_O1/qpfiffer[P]38-Moths/src/greshunkel.c
// Function: include_line
static line
_include_line(const greshunkel_ctext *ctext, const line *current_line, const struct compiled_regex *all_regex) {
	line interpolated_line = {0};
	const line *operating_line = current_line;
	assert(operating_line->data != NULL);

	match_t match[2] = {0};
	while (regexec_2_0_beta(&all_regex->c_include_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);

		/* 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);


		/* Open the file here. */
		/* TODO: Make this actually the whole size of the file, not just a random buffer. */
		char template_file[2048] = {0};
		size_t template_file_siz = 0;
		FILE *include_file = fopen(just_match_str, "r");
		if (!include_file) {
			/* If we couldn't open the file, blow up with an assertion. */
			printf("Could not open SCREAM file for reading.\n");
			printf("Line: %s\n", operating_line->data);
			assert(1 == 0);
		}

		template_file_siz = fread(template_file, 1, sizeof(template_file), include_file);
		fclose(include_file);
		template_file[template_file_siz] = '\0';

		line rendered_piece = {0};
		rendered_piece.data = gshkl_render(ctext, template_file, template_file_siz, &rendered_piece.size);

		free(interpolated_line.data);
		interpolated_line.size = rendered_piece.size;
		interpolated_line.data = rendered_piece.data;
		operating_line = &interpolated_line;

		/* Set the next regex check after this one. */
		memset(match, 0, sizeof(match));
	}

	return *operating_line;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x878, %rsp            # imm = 0x878
movq %rdi, -0x68(%rbp)
xorl %eax, %eax
movq %rax, -0x38(%rbp)
movq %rax, -0x30(%rbp)
cmpq %rax, 0x8(%rsi)
je 0x434c
movq %rdx, %rbx
movq %rsi, %r14
leaq 0x8(%rsi), %r13
xorps %xmm0, %xmm0
leaq -0xa0(%rbp), %rcx
movaps %xmm0, 0x20(%rcx)
movaps %xmm0, 0x10(%rcx)
movaps %xmm0, (%rcx)
addq $0x140, %rbx            # imm = 0x140
movq -0x30(%rbp), %r12
movq -0x38(%rbp), %r15
movq (%r13), %rsi
movl $0x2, %edx
movq %rbx, %rdi
callq 0x3b54
testl %eax, %eax
jne 0x42bb
movq %r12, -0x50(%rbp)
movq %r13, -0x48(%rbp)
movq %r15, -0x40(%rbp)
leaq -0x30(%rbp), %rax
movq (%rax), %r13
leaq -0x8a0(%rbp), %r12
cmpl $-0x1, -0x88(%rbp)
je 0x4321
cmpl $-0x1, -0x84(%rbp)
je 0x4321
movq %rbx, %r15
movq %rsp, %rbx
movq -0x80(%rbp), %rdx
movq -0x78(%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
movl $0x800, %edx            # imm = 0x800
movq %r12, %rdi
xorl %esi, %esi
callq 0x1120
movq %r14, %rdi
leaq 0xe8b(%rip), %rsi       # 0x5081
callq 0x11f0
testq %rax, %rax
je 0x42d5
movq %rax, %r14
movl $0x1, %esi
movl $0x800, %edx            # imm = 0x800
movq %r12, %rdi
movq %rax, %rcx
callq 0x1080
movq %rax, %r13
movq %r14, %rdi
callq 0x10a0
movb $0x0, -0x8a0(%rbp,%r13)
xorps %xmm0, %xmm0
movaps %xmm0, -0x60(%rbp)
movq -0x68(%rbp), %rdi
movq %r12, %rsi
movq %r13, %rdx
leaq -0x60(%rbp), %rcx
callq 0x24d1
movq %rax, -0x58(%rbp)
movq -0x50(%rbp), %rdi
callq 0x1030
movq -0x60(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x58(%rbp), %r13
xorps %xmm0, %xmm0
movaps %xmm0, -0xa0(%rbp)
movaps %xmm0, -0x90(%rbp)
movaps %xmm0, -0x80(%rbp)
movq %rbx, %rsp
movl $0x2, %edx
movq %r15, %rbx
movq %r15, %rdi
movq %r13, %rsi
leaq -0xa0(%rbp), %rcx
callq 0x3b54
leaq -0x30(%rbp), %rcx
movq %rcx, -0x48(%rbp)
movq %r13, -0x50(%rbp)
testl %eax, %eax
je 0x4197
leaq -0x30(%rbp), %rax
movq %r13, (%rax)
movq %rax, %r13
leaq -0x38(%rbp), %r14
movq -0x40(%rbp), %r15
movq %r15, -0x38(%rbp)
movq (%r14), %rax
movq (%r13), %rdx
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r13, -0x30(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x38(%rbp)
leaq 0x2a0b(%rip), %rdi      # 0x6cf3
callq 0x1070
movq -0x48(%rbp), %rax
movq (%rax), %rsi
leaq 0x23ee(%rip), %rdi      # 0x66e9
xorl %eax, %eax
callq 0x10e0
leaq 0x243d(%rip), %rdi      # 0x6746
leaq 0x1f2e(%rip), %rsi      # 0x623e
leaq 0x2833(%rip), %rcx      # 0x6b4a
movl $0x209, %edx            # imm = 0x209
callq 0x1110
movq %r13, -0x30(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x38(%rbp)
leaq 0x270a(%rip), %rdi      # 0x6a3e
leaq 0x1f03(%rip), %rsi      # 0x623e
leaq 0x2808(%rip), %rcx      # 0x6b4a
movl $0x1f8, %edx            # imm = 0x1F8
callq 0x1110
leaq 0x2672(%rip), %rdi      # 0x69c5
leaq 0x1ee4(%rip), %rsi      # 0x623e
leaq 0x27e9(%rip), %rcx      # 0x6b4a
movl $0x1f3, %edx            # imm = 0x1F3
callq 0x1110