// File: /workspace/github_c_makefile_star2_O2/Encryptr[P]O-plus-plus/opp/opp.c
// Function: opp_init_module
void opp_init_module(const char* fname, struct Opp_Options* opts)
{
	Opp_Stats stats = {0};
	struct Opp_Scan scan = {0};

	opp_init_file(fname, &scan);

	START_CLOCK();
	struct Opp_Parser* parser = opp_parser_init(&scan);
	opp_parser_begin(parser);
	END_CLOCK();
	GET_TIME(S_PARSER);

	START_CLOCK();
	struct Opp_Analize* ctx = opp_init_analize(parser, opts);
	analize_tree(ctx);
	END_CLOCK();
	GET_TIME(S_ANALIZE);

	START_CLOCK();
	struct Opp_Context* context = opp_init_compile(parser, opts);
	opp_compile(context);
	END_CLOCK();
	GET_TIME(S_COMPILER);

	START_CLOCK();
	context->oppir = init_oppir();
	oppir_get_opcodes(context->oppir, &context->ir);
	oppir_eval(context->oppir);
	OppIO io = { .file = fopen("out.o", "wb") };
	oppir_emit_obj(context->oppir, &io);
	END_CLOCK();
	GET_TIME(S_IR);
	fclose(io.file);


	if (opts->run_output) 
		system("gcc ./stdlib/testing.o out.o");

	if (opts->debug)
		opp_debug_info(&stats, context);

	oppir_free(context->oppir);
	opp_free_compiler(context);
	opp_free_analize(ctx);
	opp_free_parser(parser);
	opp_free_lex(&scan, false);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rsi, %r12
xorpd %xmm0, %xmm0
leaq 0x50(%rsp), %rbx
movapd %xmm0, 0x40(%rbx)
movapd %xmm0, 0x30(%rbx)
movapd %xmm0, 0x20(%rbx)
movapd %xmm0, 0x10(%rbx)
movapd %xmm0, (%rbx)
movq %rbx, %rsi
callq 0x132c
callq 0x1090
movq %rax, 0x18(%rsp)
movq %rbx, %rdi
callq 0x7b90
movq %rax, %rbx
movq %rax, %rdi
callq 0x7eee
callq 0x1090
movq %rax, 0x10(%rsp)
callq 0x1090
movq %rax, 0x8(%rsp)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x1bcc
movq %rax, 0x28(%rsp)
movq %rax, %rdi
callq 0x1c34
callq 0x1090
movq %rax, %r13
callq 0x1090
movq %rax, (%rsp)
movq %rbx, 0x30(%rsp)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x3690
movq %rax, %r15
movq %rax, %rdi
callq 0x388f
callq 0x1090
movq %rax, %r14
callq 0x1090
movq %rax, 0x20(%rsp)
xorl %eax, %eax
callq 0x5278
movq %rax, 0x60(%r15)
leaq 0x48(%r15), %rsi
movq %rax, %rdi
callq 0x548d
movq 0x60(%r15), %rdi
callq 0x5497
leaq 0x38(%rsp), %rbx
andq $0x0, (%rbx)
leaq 0x8b26(%rip), %rdi      # 0xa05b
leaq 0x8b05(%rip), %rsi      # 0xa041
callq 0x11e0
movq %rax, 0x8(%rbx)
andq $0x0, 0x10(%rbx)
movq 0x60(%r15), %rdi
movq %rbx, %rsi
callq 0x6400
callq 0x1090
movq %rax, %rbp
movq 0x8(%rbx), %rdi
callq 0x10a0
cmpb $0x1, 0x1(%r12)
jne 0x157b
leaq 0x8ace(%rip), %rdi      # 0xa044
callq 0x10d0
cmpb $0x1, 0x5(%r12)
jne 0x16e0
movq 0x10(%rsp), %rax
subq 0x18(%rsp), %rax
subq 0x8(%rsp), %r13
subq (%rsp), %r14
cvtsi2sd %rax, %xmm1
subq 0x20(%rsp), %rbp
movsd 0x8a5c(%rip), %xmm0     # 0xa008
cvtsi2sd %r13, %xmm4
cvtsi2sd %r14, %xmm3
cvtsi2sd %rbp, %xmm2
divsd %xmm0, %xmm1
movsd %xmm1, 0x18(%rsp)
divsd %xmm0, %xmm4
movsd %xmm4, (%rsp)
divsd %xmm0, %xmm3
movsd %xmm3, 0x8(%rsp)
divsd %xmm0, %xmm2
movsd %xmm2, 0x10(%rsp)
leaq 0x8abc(%rip), %rdi      # 0xa0a5
leaq 0x8ada(%rip), %r12      # 0xa0ca
leaq 0x8c96(%rip), %r13      # 0xa28d
movq %r12, %rsi
movq %r13, %rdx
xorl %eax, %eax
callq 0x10e0
movq (%r15), %rax
movq (%rax), %rax
movq 0x10(%rax), %rsi
leaq 0x8abb(%rip), %rdi      # 0xa0d0
xorl %eax, %eax
callq 0x10e0
movq (%r15), %rax
movq (%rax), %rax
movq 0x20(%rax), %rsi
leaq 0x8aad(%rip), %rdi      # 0xa0da
xorl %eax, %eax
callq 0x10e0
leaq 0x8beb(%rip), %rdi      # 0xa226
callq 0x1060
leaq 0x8a9e(%rip), %rdi      # 0xa0e5
movsd 0x18(%rsp), %xmm0
movb $0x1, %al
callq 0x10e0
leaq 0x8a9c(%rip), %rdi      # 0xa0f7
movsd (%rsp), %xmm0
movb $0x1, %al
callq 0x10e0
leaq 0x8a9b(%rip), %rdi      # 0xa109
movsd 0x8(%rsp), %xmm0
movb $0x1, %al
callq 0x10e0
leaq 0x8a99(%rip), %rdi      # 0xa11b
movsd 0x10(%rsp), %xmm0
movb $0x1, %al
callq 0x10e0
movsd (%rsp), %xmm0
addsd 0x18(%rsp), %xmm0
addsd 0x8(%rsp), %xmm0
addsd 0x10(%rsp), %xmm0
leaq 0x8a80(%rip), %rdi      # 0xa12d
movb $0x1, %al
callq 0x10e0
leaq 0x8b77(%rip), %rdi      # 0xa232
callq 0x1060
leaq 0x8b78(%rip), %rdi      # 0xa23f
callq 0x1060
leaq 0x8a66(%rip), %rdi      # 0xa139
movq %r12, %rsi
movq %r13, %rdx
xorl %eax, %eax
callq 0x10e0
movq 0x60(%r15), %rdi
callq 0x53c3
movq %r15, %rdi
callq 0x370f
movq 0x28(%rsp), %rdi
callq 0x1c2f
movq 0x30(%rsp), %rdi
callq 0x7cca
leaq 0x50(%rsp), %rdi
xorl %esi, %esi
callq 0x93db
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq