// File: /workspace/github_cpp_makefile_star2_O2/rossy[P]crossc/SPIRV-Cross/spirv_cross.cpp
// Function: spirv_cross::Compiler::build_function_control_flow_graphs_and_analyze()
void Compiler::build_function_control_flow_graphs_and_analyze()
{
	CFGBuilder handler(*this);
	handler.function_cfgs[ir.default_entry_point].reset(new CFG(*this, get<SPIRFunction>(ir.default_entry_point)));
	traverse_all_reachable_opcodes(get<SPIRFunction>(ir.default_entry_point), handler);
	function_cfgs = move(handler.function_cfgs);

	for (auto &f : function_cfgs)
	{
		auto &func = get<SPIRFunction>(f.first);
		AnalyzeVariableScopeAccessHandler scope_handler(*this, func);
		analyze_variable_scope(func, scope_handler);
		find_function_local_luts(func, scope_handler);

		// Check if we can actually use the loop variables we found in analyze_variable_scope.
		// To use multiple initializers, we need the same type and qualifiers.
		for (auto block : func.blocks)
		{
			auto &b = get<SPIRBlock>(block);
			if (b.loop_variables.size() < 2)
				continue;

			auto &flags = get_decoration_bitset(b.loop_variables.front());
			uint32_t type = get<SPIRVariable>(b.loop_variables.front()).basetype;
			bool invalid_initializers = false;
			for (auto loop_variable : b.loop_variables)
			{
				if (flags != get_decoration_bitset(loop_variable) ||
				    type != get<SPIRVariable>(b.loop_variables.front()).basetype)
				{
					invalid_initializers = true;
					break;
				}
			}

			if (invalid_initializers)
			{
				for (auto loop_variable : b.loop_variables)
					get<SPIRVariable>(loop_variable).loop_variable = false;
				b.loop_variables.clear();
			}
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1a8, %rsp            # imm = 0x1A8
movq %rdi, %rbx
leaq 0x28(%rsp), %rdi
movq %rbx, %rsi
callq 0x16546
leaq 0x38(%rsp), %r14
leaq 0x108(%rbx), %rsi
movq %r14, %rdi
callq 0x1ec1a
movq %rax, %r15
movl $0x90, %edi
callq 0x6270
movq %rax, %r12
movl 0x108(%rbx), %esi
movq %rbx, %rdi
callq 0xa048
movq %r12, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x661c
movq %r15, %rdi
movq %r12, %rsi
callq 0x1ef0a
movl 0x108(%rbx), %esi
movq %rbx, %rdi
callq 0xa048
leaq 0x28(%rsp), %rdx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x1157c
leaq 0x3a0(%rbx), %rdi
movq %r14, %rsi
callq 0x1ad7e
leaq 0x3b0(%rbx), %rax
leaq 0x8(%rbx), %rcx
movq %rcx, 0x8(%rsp)
movq (%rax), %rax
testq %rax, %rax
je 0x164e6
movq %rax, 0x10(%rsp)
movl 0x8(%rax), %esi
movq %rbx, %rdi
callq 0xa048
movq %rax, %r12
leaq 0x70(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x14ac4
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x15502
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x15300
movq 0x68(%r12), %r14
movq 0x70(%r12), %rax
movq %rax, 0x18(%rsp)
cmpq 0x18(%rsp), %r14
je 0x164d2
movl (%r14), %esi
movq %rbx, %rdi
callq 0x6bf0
movq %rax, %r12
movq %r14, 0x20(%rsp)
movq 0xd0(%rax), %rax
movq 0xd8(%r12), %rcx
subq %rax, %rcx
cmpq $0x5, %rcx
jb 0x164c4
movl (%rax), %esi
movq 0x8(%rsp), %rdi
callq 0x1fd16
movq %rax, %r13
movq 0xd0(%r12), %rax
movl (%rax), %esi
movq %rbx, %rdi
callq 0x9c0e
movl 0xc(%rax), %ebp
movq 0xd0(%r12), %r15
movq 0xd8(%r12), %r14
cmpq %r14, %r15
je 0x164c4
movl (%r15), %esi
movq 0x8(%rsp), %rdi
callq 0x1fd16
movq %r13, %rdi
movq %rax, %rsi
callq 0x17ca0
testb %al, %al
jne 0x16480
movq 0xd0(%r12), %rax
movl (%rax), %esi
movq %rbx, %rdi
callq 0x9c0e
addq $0x4, %r15
cmpl 0xc(%rax), %ebp
je 0x16444
movq 0xd0(%r12), %r14
movq 0xd8(%r12), %r15
cmpq %r15, %r14
je 0x164aa
movl (%r14), %esi
movq %rbx, %rdi
callq 0x9c0e
movb $0x0, 0x64(%rax)
addq $0x4, %r14
jmp 0x16490
movq 0xd0(%r12), %rax
cmpq %rax, 0xd8(%r12)
je 0x164c4
movq %rax, 0xd8(%r12)
movq 0x20(%rsp), %r14
addq $0x4, %r14
jmp 0x163d6
leaq 0x70(%rsp), %rdi
callq 0x17caa
movq 0x10(%rsp), %rax
jmp 0x16379
leaq 0x28(%rsp), %rdi
callq 0x17cf6
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movl $0x90, %esi
movq %r12, %rdi
callq 0x6280
jmp 0x16534
jmp 0x16518
jmp 0x16518
movq %rax, %rbx
jmp 0x16534
jmp 0x16527
jmp 0x16527
jmp 0x16527
jmp 0x16527
jmp 0x16527
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x17caa
leaq 0x28(%rsp), %rdi
callq 0x17cf6
movq %rbx, %rdi
callq 0x64b0