// File: /workspace/github_cpp_makefile_star2_O2/rossy[P]crossc/SPIRV-Cross/spirv_cfg.cpp
// Function: spirv_cross::CFG::post_order_visit(unsigned int)
bool CFG::post_order_visit(uint32_t block_id)
{
	// If we have already branched to this block (back edge), stop recursion.
	// If our branches are back-edges, we do not record them.
	// We have to record crossing edges however.
	if (visit_order[block_id] >= 0)
		return !is_back_edge(block_id);

	// Block back-edges from recursively revisiting ourselves.
	visit_order[block_id] = 0;

	// First visit our branch targets.
	auto &block = compiler.get<SPIRBlock>(block_id);
	switch (block.terminator)
	{
	case SPIRBlock::Direct:
		if (post_order_visit(block.next_block))
			add_branch(block_id, block.next_block);
		break;

	case SPIRBlock::Select:
		if (post_order_visit(block.true_block))
			add_branch(block_id, block.true_block);
		if (post_order_visit(block.false_block))
			add_branch(block_id, block.false_block);
		break;

	case SPIRBlock::MultiSelect:
		for (auto &target : block.cases)
		{
			if (post_order_visit(target.block))
				add_branch(block_id, target.block);
		}
		if (block.default_block && post_order_visit(block.default_block))
			add_branch(block_id, block.default_block);
		break;

	default:
		break;
	}

	// If this is a loop header, add an implied branch to the merge target.
	// This is needed to avoid annoying cases with do { ... } while(false) loops often generated by inliners.
	// To the CFG, this is linear control flow, but we risk picking the do/while scope as our dominating block.
	// This makes sure that if we are accessing a variable outside the do/while, we choose the loop header as dominator.
	if (block.merge == SPIRBlock::MergeLoop)
		add_branch(block_id, block.merge_block);

	// Then visit ourselves. Start counting at one, to let 0 be a magic value for testing back vs. crossing edges.
	visit_order[block_id] = ++visit_count;
	post_order.push_back(block_id);
	return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, 0x4(%rsp)
movl %esi, %r15d
movq 0x58(%rdi), %rax
cmpl $0x0, (%rax,%r15,4)
js 0x6887
setne %al
jmp 0x69a7
movl %esi, %ebp
movq %rdi, %rbx
andl $0x0, (%rax,%r15,4)
movq (%rdi), %rdi
callq 0x6bf0
movq %rax, %r14
movl 0xc(%rax), %eax
cmpl $0x3, %eax
je 0x6909
cmpl $0x2, %eax
je 0x68d2
cmpl $0x1, %eax
jne 0x6969
movl 0x18(%r14), %esi
movq %rbx, %rdi
callq 0x6862
testb %al, %al
je 0x6969
movq %r14, %rax
addq $0x18, %rax
jmp 0x695d
movl 0x2c(%r14), %esi
movq %rbx, %rdi
callq 0x6862
testb %al, %al
je 0x68f0
movl 0x2c(%r14), %edx
movq %rbx, %rdi
movl %ebp, %esi
callq 0x69b6
movl 0x30(%r14), %esi
movq %rbx, %rdi
callq 0x6862
testb %al, %al
je 0x6969
movq %r14, %rax
addq $0x30, %rax
jmp 0x695d
movq 0x98(%r14), %r12
movq 0xa0(%r14), %r13
cmpq %r13, %r12
je 0x6942
movl 0x4(%r12), %esi
movq %rbx, %rdi
callq 0x6862
testb %al, %al
je 0x693c
movl 0x4(%r12), %edx
movq %rbx, %rdi
movl %ebp, %esi
callq 0x69b6
addq $0x8, %r12
jmp 0x6917
movl 0x34(%r14), %esi
testl %esi, %esi
je 0x6969
movq %rbx, %rdi
callq 0x6862
testb %al, %al
je 0x6969
movq %r14, %rax
addq $0x34, %rax
movl (%rax), %edx
movq %rbx, %rdi
movl %ebp, %esi
callq 0x69b6
cmpl $0x1, 0x10(%r14)
jne 0x697e
movl 0x1c(%r14), %edx
movq %rbx, %rdi
movl %ebp, %esi
callq 0x69b6
movl 0x88(%rbx), %eax
incl %eax
movl %eax, 0x88(%rbx)
movq 0x58(%rbx), %rcx
movl %eax, (%rcx,%r15,4)
addq $0x70, %rbx
leaq 0x4(%rsp), %rsi
movq %rbx, %rdi
callq 0x6c06
movb $0x1, %al
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq