// File: /workspace/github_c_makefile_star2_O3/lucvoo[P]sparse-dev/optimize.c
// Function: optimize
void optimize(struct entrypoint *ep)
{
	if (fdump_ir & PASS_LINEARIZE)
		show_entry(ep);

	/*
	 * Do trivial flow simplification - branches to
	 * branches, kill dead basicblocks etc
	 */
	kill_unreachable_bbs(ep);
	ir_validate(ep);

	cfg_postorder(ep);
	if (simplify_cfg_early(ep))
		kill_unreachable_bbs(ep);
	ir_validate(ep);

	domtree_build(ep);

	/*
	 * Turn symbols into pseudos
	 */
	if (fpasses & PASS_MEM2REG)
		ssa_convert(ep);
	ir_validate(ep);
	if (fdump_ir & PASS_MEM2REG)
		show_entry(ep);

	if (!(fpasses & PASS_OPTIM))
		return;
repeat:
	/*
	 * Remove trivial instructions, and try to CSE
	 * the rest.
	 */
	do {
		simplify_memops(ep);
		do {
			repeat_phase = 0;
			clean_up_insns(ep);
			if (repeat_phase & REPEAT_CFG_CLEANUP)
				kill_unreachable_bbs(ep);

			cse_eliminate(ep);
			simplify_memops(ep);
		} while (repeat_phase);
		pack_basic_blocks(ep);
		if (repeat_phase & REPEAT_CFG_CLEANUP)
			cleanup_cfg(ep);
	} while (repeat_phase);

	vrfy_flow(ep);

	/* Cleanup */
	clear_symbol_pseudos(ep);

	/* And track pseudo register usage */
	track_pseudo_liveness(ep);

	/*
	 * Some flow optimizations can only effectively
	 * be done when we've done liveness analysis. But
	 * if they trigger, we need to start all over
	 * again
	 */
	if (simplify_flow(ep)) {
		clear_liveness(ep);
		if (repeat_phase & REPEAT_CFG_CLEANUP)
			cleanup_cfg(ep);
		goto repeat;
	}

	/* Finally, add deathnotes to pseudos now that we have them */
	if (dbg_dead)
		track_pseudo_death(ep);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %r15
leaq 0x4ed3c(%rip), %rbx     # 0x66f18
testb $0x2, (%rbx)
je 0x181e9
movq %r15, %rdi
callq 0x13290
movq %r15, %rdi
callq 0x3b9ad
movq %r15, %rdi
callq 0x3d0a0
movq %r15, %rdi
callq 0x3cad4
movq %r15, %rdi
callq 0x3bf6c
testl %eax, %eax
je 0x18215
movq %r15, %rdi
callq 0x3b9ad
movq %r15, %rdi
callq 0x3d0a0
movq %r15, %rdi
callq 0x3cca2
leaq 0x48354(%rip), %r14     # 0x60580
testb $0x4, (%r14)
je 0x1823a
movq %r15, %rdi
callq 0x2a348
movq %r15, %rdi
callq 0x3d0a0
testb $0x4, (%rbx)
je 0x1824f
movq %r15, %rdi
callq 0x13290
testb $0x8, (%r14)
jne 0x18264
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r15, (%rsp)
movq %r15, %rdi
callq 0x3e430
movl $0x0, 0x4eafa(%rip)     # 0x66d74
movq 0x18(%r15), %rax
testq %rax, %rax
je 0x18369
movq %rax, %rdx
movq %rax, 0x8(%rsp)
movzwl (%rdx), %eax
testb %al, %al
jle 0x18342
xorl %r13d, %r13d
movq %rdx, 0x10(%rsp)
movq 0x18(%rdx,%r13,8), %rbp
movzwl %ax, %ecx
cmpl $0x100, %ecx            # imm = 0x100
jb 0x182b7
testq %rbp, %rbp
je 0x1832f
movq 0x28(%rbp), %r15
testq %r15, %r15
je 0x1832f
movq %r15, %rbx
movzwl (%rbx), %eax
testb %al, %al
jle 0x1831e
xorl %r12d, %r12d
movq 0x18(%rbx,%r12,8), %r14
movzwl %ax, %eax
cmpl $0x100, %eax            # imm = 0x100
jb 0x182e1
testq %r14, %r14
je 0x18310
cmpq $0x0, 0x8(%r14)
je 0x18310
movq %r14, %rdi
callq 0x24cf6
orl %eax, 0x4ea7e(%rip)     # 0x66d74
movq 0x8(%r14), %rax
testq %rax, %rax
je 0x18310
cmpq %rbp, %rax
jne 0x18452
movq %r14, %rdi
callq 0x30d70
incq %r12
movl (%rbx), %eax
movsbq %al, %rcx
cmpq %rcx, %r12
jl 0x182cd
movq 0x10(%rbx), %rbx
cmpq %r15, %rbx
jne 0x182c3
movq 0x10(%rsp), %rdx
movzwl (%rdx), %eax
incq %r13
movzwl %ax, %ecx
movsbq %cl, %rcx
cmpq %rcx, %r13
jl 0x182a2
movq 0x10(%rdx), %rdx
movq 0x8(%rsp), %rax
cmpq %rax, %rdx
jne 0x1828f
testb $0x4, 0x4ea19(%rip)     # 0x66d74
movq (%rsp), %r15
je 0x18369
movq %r15, %rdi
callq 0x3b9ad
movq %r15, %rdi
callq 0x30eb2
movq %r15, %rdi
callq 0x3e430
cmpl $0x0, 0x4e9f4(%rip)     # 0x66d74
jne 0x18270
movq %r15, %rdi
callq 0x3c44f
movl 0x4e9e0(%rip), %eax     # 0x66d74
testb $0x4, %al
je 0x183ae
movq %r15, %rdi
callq 0x3b9ad
movq %r15, %rdi
callq 0x3cca2
movl 0x4e9c6(%rip), %eax     # 0x66d74
testl %eax, %eax
jne 0x18268
movq %r15, %rdi
callq 0x3bb3d
movq 0x10(%r15), %rax
testq %rax, %rax
je 0x18414
movq %rax, %rcx
movzwl (%rcx), %edx
testb %dl, %dl
jle 0x1840b
xorl %esi, %esi
movq 0x18(%rcx,%rsi,8), %rdi
movzwl %dx, %r8d
cmpl $0x100, %r8d            # imm = 0x100
jb 0x183ea
testq %rdi, %rdi
je 0x183fc
movq 0x18(%rdi), %rdx
movq $0x0, 0xd8(%rdx)
movzwl (%rcx), %edx
incq %rsi
movzwl %dx, %edi
movsbq %dil, %rdi
cmpq %rdi, %rsi
jl 0x183d3
movq 0x10(%rcx), %rcx
cmpq %rax, %rcx
jne 0x183ca
movq %r15, %rdi
callq 0x3d785
movq %r15, %rdi
callq 0x3afba
testl %eax, %eax
je 0x18471
movq %r15, %rdi
callq 0x3d714
testb $0x4, 0x4e93d(%rip)     # 0x66d74
je 0x18268
movq %r15, %rdi
callq 0x3b9ad
movq %r15, %rdi
callq 0x3cca2
jmp 0x18268
leaq 0x29a57(%rip), %rdi     # 0x41eb0
leaq 0x29a5f(%rip), %rsi     # 0x41ebf
leaq 0x29a63(%rip), %rcx     # 0x41eca
movl $0x2d, %edx
callq 0xe120
leaq 0x4e930(%rip), %rax     # 0x66da8
cmpl $0x0, (%rax)
je 0x18255
movq %r15, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3ddca
nop