// File: /workspace/github_c_makefile_star2_O3/Ihsoh[P]ilang/compiler/preprocessor/preprocessor.c
// Function: pp_process
void pp_process(
	const char *file,
	const char *include_paths,
	const char *source,
	int len,
	Map *defs,
	FILE *out,
	ResizableString *result
) {
	assert(file);
	assert(include_paths);
	assert(source);
	assert(defs);
	assert(out != NULL || result != NULL);

	ResizableString rstr_comment_removed;
	rstr_init(&rstr_comment_removed);
	pp_comment_process(
		&rstr_comment_removed,
		file,
		source,
		len
	);

	ResizableString rstr_line_concated;
	rstr_init(&rstr_line_concated);
	pp_line_concat_process(
		&rstr_line_concated,
		file,
		RSTR_CSTR(&rstr_comment_removed),
		RSTR_LEN(&rstr_comment_removed)
	);

	rstr_free(&rstr_comment_removed);
	
	ParserContext *psrctx = pp_parser_new_context(
		file,
		RSTR_CSTR(&rstr_line_concated),
		RSTR_LEN(&rstr_line_concated)
	);
	pp_parser_parse(psrctx);

	PPGeneratorContext *genctx = pp_gen_new_context(
		psrctx, include_paths, NULL, NULL, out, result
	);

	MapEntryIterator iter;
	map_iter_init(defs, &iter);
	MapEntry *entry = NULL;
	while ((entry = map_iter_next(defs, &iter)) != NULL) {
		pp_gen_define(genctx, entry->key, entry->value);
	}

	pp_gen_generate(genctx);
	pp_gen_free_context(genctx);

	pp_parser_free_context(psrctx);

	rstr_free(&rstr_line_concated);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
testq %rdi, %rdi
je 0x2caea
testq %rsi, %rsi
je 0x2cb09
movq %rdx, %r14
testq %rdx, %rdx
je 0x2cb28
movq %r8, %rbx
testq %r8, %r8
je 0x2cb47
movq %rsi, -0x38(%rbp)
movq %r9, %rax
orq 0x10(%rbp), %rax
movq %r9, -0x30(%rbp)
je 0x2cb66
movl %ecx, %r13d
movq %rdi, %r12
leaq -0x60(%rbp), %r15
movq %r15, %rdi
callq 0xe274
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %rdx
movl %r13d, %ecx
callq 0x24324
leaq -0x50(%rbp), %r14
movq %r14, %rdi
callq 0xe274
movq 0x8(%r15), %rdx
testq %rdx, %rdx
leaq 0x1d61(%rip), %r13      # 0x2e792
cmoveq %r13, %rdx
movl 0x4(%r15), %ecx
movq %r14, %rdi
movq %r12, %rsi
callq 0x2b8b0
movq %r15, %rdi
callq 0xe772
movq 0x8(%r14), %rsi
testq %rsi, %rsi
cmoveq %r13, %rsi
movl 0x4(%r14), %edx
movq %r12, %rdi
callq 0x2b928
movq %rax, %r12
movq %rax, %rdi
callq 0x2ba02
movq %r12, %rdi
movq -0x38(%rbp), %rsi
xorl %edx, %edx
xorl %ecx, %ecx
movq -0x30(%rbp), %r8
movq 0x10(%rbp), %r9
callq 0x280af
movq %rax, %r14
leaq -0x40(%rbp), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0xc898
movq %rbx, %rdi
movq %r15, %rsi
callq 0xc8ec
testq %rax, %rax
je 0x2caba
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
movq %r14, %rdi
callq 0x2838b
jmp 0x2ca98
movq %r14, %rdi
callq 0x28004
movq %r14, %rdi
callq 0x28300
movq %r12, %rdi
callq 0x2b9bf
leaq -0x50(%rbp), %rdi
callq 0xe772
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xf18(%rip), %rdi       # 0x2da09
leaq 0xa0f5(%rip), %rsi      # 0x36bed
leaq 0xa113(%rip), %rcx      # 0x36c12
movl $0x17, %edx
callq 0xa0b0
leaq 0x8f18(%rip), %rdi      # 0x35a28
leaq 0xa0d6(%rip), %rsi      # 0x36bed
leaq 0xa0f4(%rip), %rcx      # 0x36c12
movl $0x18, %edx
callq 0xa0b0
leaq 0xa07(%rip), %rdi       # 0x2d536
leaq 0xa0b7(%rip), %rsi      # 0x36bed
leaq 0xa0d5(%rip), %rcx      # 0x36c12
movl $0x19, %edx
callq 0xa0b0
leaq 0xa125(%rip), %rdi      # 0x36c73
leaq 0xa098(%rip), %rsi      # 0x36bed
leaq 0xa0b6(%rip), %rcx      # 0x36c12
movl $0x1a, %edx
callq 0xa0b0
leaq 0x8ec9(%rip), %rdi      # 0x35a36
leaq 0xa079(%rip), %rsi      # 0x36bed
leaq 0xa097(%rip), %rcx      # 0x36c12
movl $0x1b, %edx
callq 0xa0b0