// File: /workspace/github_c_makefile_star2_O0/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
subq $0x8d0, %rsp            # imm = 0x8D0
movq %rdi, -0x18(%rbp)
movq %rsi, -0x20(%rbp)
movq %rdx, -0x28(%rbp)
leaq -0x38(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x1110
movq -0x20(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x523c
jmp 0x525b
leaq 0x37ea(%rip), %rdi      # 0x8a2d
leaq 0x2fe3(%rip), %rsi      # 0x822d
movl $0x1f3, %edx            # imm = 0x1F3
leaq 0x39f1(%rip), %rcx      # 0x8c47
callq 0x1100
leaq -0x70(%rbp), %rdi
xorl %esi, %esi
movl $0x30, %edx
callq 0x1110
movq -0x28(%rbp), %rdi
addq $0x140, %rdi            # imm = 0x140
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rsi
leaq -0x70(%rbp), %rcx
movl $0x2, %edx
callq 0x4610
cmpl $0x0, %eax
jne 0x546d
movq -0x58(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x78(%rbp)
cmpl $-0x1, -0x88(%rbp)
je 0x52c4
cmpl $-0x1, -0x84(%rbp)
je 0x52c4
jmp 0x52e3
leaq 0x37db(%rip), %rdi      # 0x8aa6
leaq 0x2f5b(%rip), %rsi      # 0x822d
movl $0x1f8, %edx            # imm = 0x1F8
leaq 0x3969(%rip), %rcx      # 0x8c47
callq 0x1100
movq -0x80(%rbp), %rcx
movq %rcx, %rax
incq %rax
movq %rsp, %rdx
movq %rdx, -0x90(%rbp)
addq $0x10, %rcx
andq $-0x10, %rcx
movq %rsp, %rdi
subq %rcx, %rdi
movq %rdi, -0x8c8(%rbp)
movq %rdi, %rsp
movq %rax, -0x98(%rbp)
movq -0x80(%rbp), %rax
movb $0x0, (%rdi,%rax)
movq -0x78(%rbp), %rsi
movq -0x80(%rbp), %rdx
callq 0x1050
leaq -0x8a0(%rbp), %rdi
xorl %esi, %esi
movl $0x800, %edx            # imm = 0x800
callq 0x1110
movq -0x8c8(%rbp), %rdi
movq $0x0, -0x8a8(%rbp)
leaq 0x1d2a(%rip), %rsi      # 0x7081
callq 0x11e0
movq %rax, -0x8b0(%rbp)
cmpq $0x0, -0x8b0(%rbp)
jne 0x53b0
leaq 0x392d(%rip), %rdi      # 0x8ca1
movb $0x0, %al
callq 0x10d0
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rsi
leaq 0x33c7(%rip), %rdi      # 0x8751
movb $0x0, %al
callq 0x10d0
leaq 0x3416(%rip), %rdi      # 0x87ae
leaq 0x2e8e(%rip), %rsi      # 0x822d
movl $0x209, %edx            # imm = 0x209
leaq 0x389c(%rip), %rcx      # 0x8c47
callq 0x1100
leaq -0x8a0(%rbp), %rdi
movq -0x8b0(%rbp), %rcx
movl $0x1, %esi
movl $0x800, %edx            # imm = 0x800
callq 0x1070
movq %rax, -0x8a8(%rbp)
movq -0x8b0(%rbp), %rdi
callq 0x1090
movq -0x8a8(%rbp), %rax
movb $0x0, -0x8a0(%rbp,%rax)
leaq -0x8c0(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x1110
movq -0x18(%rbp), %rdi
leaq -0x8a0(%rbp), %rsi
movq -0x8a8(%rbp), %rdx
leaq -0x8c0(%rbp), %rcx
callq 0x2a60
movq %rax, -0x8b8(%rbp)
movq -0x30(%rbp), %rdi
callq 0x1030
movq -0x8c0(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x8b8(%rbp), %rax
movq %rax, -0x30(%rbp)
leaq -0x38(%rbp), %rax
movq %rax, -0x40(%rbp)
leaq -0x70(%rbp), %rdi
xorl %esi, %esi
movl $0x30, %edx
callq 0x1110
movq -0x90(%rbp), %rax
movq %rax, %rsp
jmp 0x526b
movq -0x40(%rbp), %rax
movups (%rax), %xmm0
movaps %xmm0, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq -0x8(%rbp), %rdx
movq %rbp, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)