// File: /workspace/github_c_makefile_star2_O2/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 0x4ad28(%rip), %rbx     # 0x60f18
testb $0x2, (%rbx)
je 0x161fd
movq %r15, %rdi
callq 0x128dd
movq %r15, %rdi
callq 0x34fa1
movq %r15, %rdi
callq 0x36514
movq %r15, %rdi
callq 0x35fb4
movq %r15, %rdi
callq 0x354c1
testl %eax, %eax
je 0x16229
movq %r15, %rdi
callq 0x34fa1
movq %r15, %rdi
callq 0x36514
movq %r15, %rdi
callq 0x36162
leaq 0x44340(%rip), %r14     # 0x5a580
testb $0x4, (%r14)
je 0x1624e
movq %r15, %rdi
callq 0x25bdc
movq %r15, %rdi
callq 0x36514
testb $0x4, (%rbx)
je 0x16263
movq %r15, %rdi
callq 0x128dd
testb $0x8, (%r14)
jne 0x16278
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r15, (%rsp)
movq %r15, %rdi
callq 0x376dc
andl $0x0, 0x4aae9(%rip)     # 0x60d74
movq 0x18(%r15), %rax
testq %rax, %rax
je 0x16362
movq %rax, %rdx
movq %rax, 0x8(%rsp)
xorl %r13d, %r13d
movq %rdx, 0x10(%rsp)
movl (%rdx), %eax
movsbq %al, %rcx
cmpq %rcx, %r13
jge 0x1633b
movq 0x18(%rdx,%r13,8), %rbp
cmpw $0x100, %ax             # imm = 0x100
jb 0x162c7
testq %rbp, %rbp
je 0x1632e
movq 0x28(%rbp), %r15
testq %r15, %r15
je 0x1632e
movq %r15, %rbx
xorl %r12d, %r12d
movl (%rbx), %eax
movsbq %al, %rcx
cmpq %rcx, %r12
jge 0x16325
movq 0x18(%rbx,%r12,8), %r14
cmpw $0x100, %ax             # imm = 0x100
jb 0x162f1
testq %r14, %r14
je 0x16320
cmpq $0x0, 0x8(%r14)
je 0x16320
movq %r14, %rdi
callq 0x21ff5
orl %eax, 0x4aa6e(%rip)     # 0x60d74
movq 0x8(%r14), %rax
testq %rax, %rax
je 0x16320
cmpq %rbp, %rax
jne 0x16429
movq %r14, %rdi
callq 0x2be18
incq %r12
jmp 0x162d6
movq 0x10(%rbx), %rbx
cmpq %r15, %rbx
jne 0x162d3
incq %r13
movq 0x10(%rsp), %rdx
jmp 0x162a8
movq 0x10(%rdx), %rdx
movq 0x8(%rsp), %rax
cmpq %rax, %rdx
jne 0x162a0
testb $0x4, 0x4aa20(%rip)     # 0x60d74
movq (%rsp), %r15
je 0x16362
movq %r15, %rdi
callq 0x34fa1
movq %r15, %rdi
callq 0x2bf57
movq %r15, %rdi
callq 0x376dc
cmpl $0x0, 0x4a9fb(%rip)     # 0x60d74
jne 0x16284
movq %r15, %rdi
callq 0x3595d
movl 0x4a9e7(%rip), %eax     # 0x60d74
testb $0x4, %al
je 0x1639f
movq %r15, %rdi
callq 0x1646c
movl 0x4a9d5(%rip), %eax     # 0x60d74
testl %eax, %eax
jne 0x1627c
movq %r15, %rdi
callq 0x35106
movq 0x10(%r15), %rax
testq %rax, %rax
je 0x163f3
movq %rax, %rcx
xorl %edx, %edx
movl (%rcx), %esi
movsbq %sil, %rdi
cmpq %rdi, %rdx
jge 0x163ea
movq 0x18(%rcx,%rdx,8), %rdi
cmpw $0x100, %si             # imm = 0x100
jb 0x163d9
testq %rdi, %rdi
je 0x163e5
movq 0x18(%rdi), %rsi
andq $0x0, 0xd8(%rsi)
incq %rdx
jmp 0x163bd
movq 0x10(%rcx), %rcx
cmpq %rax, %rcx
jne 0x163bb
movq %r15, %rdi
callq 0x36ba1
movq %r15, %rdi
callq 0x34681
testl %eax, %eax
je 0x16446
movq %r15, %rdi
callq 0x36b3f
testb $0x4, 0x4a95e(%rip)     # 0x60d74
je 0x1627c
movq %r15, %rdi
callq 0x1646c
jmp 0x1627c
leaq 0x24ae0(%rip), %rdi     # 0x3af10
leaq 0x24ae8(%rip), %rsi     # 0x3af1f
leaq 0x24aec(%rip), %rcx     # 0x3af2a
pushq $0x2d
popq %rdx
callq 0xe120
leaq 0x4a95b(%rip), %rax     # 0x60da8
cmpl $0x0, (%rax)
je 0x16269
movq %r15, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3722e