// File: /workspace/github_c_makefile_star2_O1/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 0x4fd58(%rip), %rbx     # 0x67f18
testb $0x2, (%rbx)
je 0x181cd
movq %r15, %rdi
callq 0x1322c
movq %r15, %rdi
callq 0x3c8b2
movq %r15, %rdi
callq 0x3e060
movq %r15, %rdi
callq 0x3da98
movq %r15, %rdi
callq 0x3ce41
testl %eax, %eax
je 0x181f9
movq %r15, %rdi
callq 0x3c8b2
movq %r15, %rdi
callq 0x3e060
movq %r15, %rdi
callq 0x3dc61
leaq 0x49370(%rip), %r14     # 0x61580
testb $0x4, (%r14)
je 0x1821e
movq %r15, %rdi
callq 0x2a7f4
movq %r15, %rdi
callq 0x3e060
testb $0x4, (%rbx)
je 0x18233
movq %r15, %rdi
callq 0x1322c
testb $0x8, (%r14)
jne 0x18248
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r15, 0x8(%rsp)
movq %r15, %rdi
callq 0x3f370
movl $0x0, 0x4fb15(%rip)     # 0x67d74
movq 0x18(%r15), %rax
movq %rax, (%rsp)
testq %rax, %rax
je 0x18330
movq (%rsp), %rdx
movzwl (%rdx), %eax
testb %al, %al
jle 0x18322
xorl %r13d, %r13d
movq %rdx, 0x10(%rsp)
movq 0x18(%rdx,%r13,8), %rbp
movzwl %ax, %eax
cmpl $0x100, %eax            # imm = 0x100
jb 0x1829b
testq %rbp, %rbp
je 0x1830b
movq 0x28(%rbp), %r15
testq %r15, %r15
je 0x1830b
movq %r15, %rbx
movzwl (%rbx), %eax
testb %al, %al
jle 0x18302
xorl %r12d, %r12d
movq 0x18(%rbx,%r12,8), %r14
movzwl %ax, %eax
cmpl $0x100, %eax            # imm = 0x100
jb 0x182c5
testq %r14, %r14
je 0x182f4
cmpq $0x0, 0x8(%r14)
je 0x182f4
movq %r14, %rdi
callq 0x24d8a
orl %eax, 0x4fa9a(%rip)     # 0x67d74
movq 0x8(%r14), %rax
testq %rax, %rax
je 0x182f4
cmpq %rbp, %rax
jne 0x18428
movq %r14, %rdi
callq 0x3148c
incq %r12
movl (%rbx), %eax
movsbq %al, %rcx
cmpq %rcx, %r12
jl 0x182b1
movq 0x10(%rbx), %rbx
cmpq %r15, %rbx
jne 0x182a7
incq %r13
movq 0x10(%rsp), %rdx
movl (%rdx), %eax
movsbq %al, %rcx
cmpq %rcx, %r13
jl 0x18287
movq 0x10(%rdx), %rdx
cmpq (%rsp), %rdx
jne 0x18274
testb $0x4, 0x4fa3d(%rip)     # 0x67d74
movq 0x8(%rsp), %r15
je 0x18346
movq %r15, %rdi
callq 0x3c8b2
movq %r15, %rdi
callq 0x315ce
movq %r15, %rdi
callq 0x3f370
cmpl $0x0, 0x4fa17(%rip)     # 0x67d74
jne 0x18255
movq %r15, %rdi
callq 0x3d395
testb $0x4, 0x4fa02(%rip)     # 0x67d74
je 0x18384
movq %r15, %rdi
callq 0x3c8b2
movq %r15, %rdi
callq 0x3dc61
cmpl $0x0, 0x4f9e9(%rip)     # 0x67d74
jne 0x1824d
movq %r15, %rdi
callq 0x3ca27
movq 0x10(%r15), %rax
testq %rax, %rax
je 0x183ea
movq %rax, %rcx
movzwl (%rcx), %esi
testb %sil, %sil
jle 0x183e1
xorl %edx, %edx
movq 0x18(%rcx,%rdx,8), %rdi
movzwl %si, %esi
cmpl $0x100, %esi            # imm = 0x100
jb 0x183c4
testq %rdi, %rdi
je 0x183d3
movq 0x18(%rdi), %rsi
movq $0x0, 0xd8(%rsi)
incq %rdx
movl (%rcx), %esi
movsbq %sil, %rdi
cmpq %rdi, %rdx
jl 0x183af
movq 0x10(%rcx), %rcx
cmpq %rax, %rcx
jne 0x183a5
movq %r15, %rdi
callq 0x3e71c
movq %r15, %rdi
callq 0x3bece
testl %eax, %eax
je 0x18447
movq %r15, %rdi
callq 0x3e6b0
testb $0x4, 0x4f967(%rip)     # 0x67d74
je 0x1824d
movq %r15, %rdi
callq 0x3c8b2
movq %r15, %rdi
callq 0x3dc61
jmp 0x1824d
leaq 0x2aab1(%rip), %rdi     # 0x42ee0
leaq 0x2aab9(%rip), %rsi     # 0x42eef
leaq 0x2aabd(%rip), %rcx     # 0x42efa
movl $0x2d, %edx
callq 0xe120
leaq 0x4f95a(%rip), %rax     # 0x67da8
cmpl $0x0, (%rax)
je 0x18239
movq %r15, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3ed26
nopl (%rax)