// File: /workspace/github_cpp_makefile_star2_O3/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 0x7443
setne %al
jmp 0x757f
movl %esi, %ebp
movq %rdi, %rbx
movl $0x0, (%rax,%r15,4)
movq (%rdi), %rdi
callq 0x7870
movq %rax, %r14
movl 0xc(%rax), %eax
cmpl $0x3, %eax
je 0x74c8
cmpl $0x2, %eax
je 0x7491
cmpl $0x1, %eax
jne 0x7528
movl 0x18(%r14), %esi
movq %rbx, %rdi
callq 0x741e
testb %al, %al
je 0x7528
movq %r14, %rax
addq $0x18, %rax
jmp 0x751c
movl 0x2c(%r14), %esi
movq %rbx, %rdi
callq 0x741e
testb %al, %al
je 0x74af
movl 0x2c(%r14), %edx
movq %rbx, %rdi
movl %ebp, %esi
callq 0x758e
movl 0x30(%r14), %esi
movq %rbx, %rdi
callq 0x741e
testb %al, %al
je 0x7528
movq %r14, %rax
addq $0x30, %rax
jmp 0x751c
movq 0x98(%r14), %r12
movq 0xa0(%r14), %r13
cmpq %r13, %r12
je 0x7501
movl 0x4(%r12), %esi
movq %rbx, %rdi
callq 0x741e
testb %al, %al
je 0x74fb
movl 0x4(%r12), %edx
movq %rbx, %rdi
movl %ebp, %esi
callq 0x758e
addq $0x8, %r12
jmp 0x74d6
movl 0x34(%r14), %esi
testl %esi, %esi
je 0x7528
movq %rbx, %rdi
callq 0x741e
testb %al, %al
je 0x7528
movq %r14, %rax
addq $0x34, %rax
movl (%rax), %edx
movq %rbx, %rdi
movl %ebp, %esi
callq 0x758e
cmpl $0x1, 0x10(%r14)
jne 0x753d
movl 0x1c(%r14), %edx
movq %rbx, %rdi
movl %ebp, %esi
callq 0x758e
movl 0x88(%rbx), %eax
incl %eax
movl %eax, 0x88(%rbx)
movq 0x58(%rbx), %rcx
movl %eax, (%rcx,%r15,4)
movq 0x78(%rbx), %rsi
cmpq 0x80(%rbx), %rsi
je 0x756c
movl %ebp, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x78(%rbx)
jmp 0x757d
addq $0x70, %rbx
leaq 0x4(%rsp), %rdx
movq %rbx, %rdi
callq 0x797e
movb $0x1, %al
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq