// File: /workspace/github_c_makefile_star2_O2/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 0x2b41e
testq %rsi, %rsi
je 0x2b437
movq %rdx, %r14
testq %rdx, %rdx
je 0x2b450
movq %r8, %rbx
testq %r8, %r8
je 0x2b469
movq %rsi, -0x38(%rbp)
movq %r9, %rax
orq 0x10(%rbp), %rax
movq %r9, -0x30(%rbp)
je 0x2b482
movl %ecx, %r12d
movq %rdi, %r13
leaq -0x60(%rbp), %r15
movq %r15, %rdi
callq 0xde1c
movq %r15, %rdi
movq %r13, %rsi
movq %r14, %rdx
movl %r12d, %ecx
callq 0x231b0
leaq -0x50(%rbp), %r14
movq %r14, %rdi
callq 0xde1c
movq 0x8(%r15), %rdx
testq %rdx, %rdx
leaq 0x242d(%rip), %r12      # 0x2d792
cmoveq %r12, %rdx
movl 0x4(%r15), %ecx
movq %r14, %rdi
movq %r13, %rsi
callq 0x2a251
movq %r15, %rdi
callq 0xe2b9
movq 0x8(%r14), %rsi
testq %rsi, %rsi
cmoveq %r12, %rsi
movl 0x4(%r14), %edx
movq %r13, %rdi
callq 0x2a2bc
movq %rax, %r13
movq %rax, %rdi
callq 0x2a393
movq %r13, %rdi
movq -0x38(%rbp), %rsi
xorl %edx, %edx
xorl %ecx, %ecx
movq -0x30(%rbp), %r8
movq 0x10(%rbp), %r9
callq 0x26c4b
movq %rax, %r14
leaq -0x40(%rbp), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0xc585
movq %rbx, %rdi
movq %r15, %rsi
callq 0xc5d9
testq %rax, %rax
je 0x2b3ee
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
movq %r14, %rdi
callq 0x26f11
jmp 0x2b3cc
movq %r14, %rdi
callq 0x26ba0
movq %r14, %rdi
callq 0x26e92
movq %r13, %rdi
callq 0x2a350
leaq -0x50(%rbp), %rdi
callq 0xe2b9
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x15e4(%rip), %rdi      # 0x2ca09
leaq 0xa851(%rip), %rsi      # 0x35c7d
leaq 0xa86f(%rip), %rcx      # 0x35ca2
pushq $0x17
jmp 0x2b499
leaq 0x967a(%rip), %rdi      # 0x34ab8
leaq 0xa838(%rip), %rsi      # 0x35c7d
leaq 0xa856(%rip), %rcx      # 0x35ca2
pushq $0x18
jmp 0x2b499
leaq 0x10df(%rip), %rdi      # 0x2c536
leaq 0xa81f(%rip), %rsi      # 0x35c7d
leaq 0xa83d(%rip), %rcx      # 0x35ca2
pushq $0x19
jmp 0x2b499
leaq 0xa893(%rip), %rdi      # 0x35d03
leaq 0xa806(%rip), %rsi      # 0x35c7d
leaq 0xa824(%rip), %rcx      # 0x35ca2
pushq $0x1a
jmp 0x2b499
leaq 0x963d(%rip), %rdi      # 0x34ac6
leaq 0xa7ed(%rip), %rsi      # 0x35c7d
leaq 0xa80b(%rip), %rcx      # 0x35ca2
pushq $0x1b
popq %rdx
callq 0xa0b0