// File: rossy[P]crossc/SPIRV-Cross/spirv_cpp.cpp
// Function: spirv_cross::CompilerCPP::compile[abi:cxx11]()
string CompilerCPP::compile()
{
	// Force a classic "C" locale, reverts when function returns
	ClassicLocale classic_locale;

	// Do not deal with ES-isms like precision, older extensions and such.
	options.es = false;
	options.version = 450;
	backend.float_literal_suffix = true;
	backend.double_literal_suffix = false;
	backend.long_long_literal_suffix = true;
	backend.uint32_t_literal_suffix = true;
	backend.basic_int_type = "int32_t";
	backend.basic_uint_type = "uint32_t";
	backend.swizzle_is_function = true;
	backend.shared_is_implied = true;
	backend.flexible_member_array_supported = false;
	backend.explicit_struct_type = true;
	backend.use_initializer_list = true;

	build_function_control_flow_graphs_and_analyze();
	update_active_builtins();

	uint32_t pass_count = 0;
	do
	{
		if (pass_count >= 3)
			SPIRV_CROSS_THROW("Over 3 compilation loops detected. Must be a bug!");

		resource_registrations.clear();
		reset();

		// Move constructor for this type is broken on GCC 4.9 ...
		buffer = unique_ptr<ostringstream>(new ostringstream());

		emit_header();
		emit_resources();

		emit_function(get<SPIRFunction>(ir.default_entry_point), Bitset());

		pass_count++;
	} while (force_recompile);

	// Match opening scope of emit_header().
	end_scope_decl();
	// namespace
	end_scope();

	// Emit C entry points
	emit_c_linkage();

	// Entry point in CPP is always main() for the time being.
	get_entry_point().name = "main";

	return buffer->str();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0xb8(%rbp)
movq %rdi, %rax
movq %rax, -0xb0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xa8(%rbp)
leaq -0x18(%rbp), %rdi
callq 0x105a0
movq -0xa8(%rbp), %rdi
movb $0x0, 0x43c(%rdi)
movl $0x1c2, 0x438(%rdi)     # imm = 0x1C2
movb $0x1, 0x600(%rdi)
movb $0x0, 0x601(%rdi)
movb $0x1, 0x603(%rdi)
movb $0x1, 0x602(%rdi)
leaq 0x130bb4(%rip), %rax    # 0x13e3c7
movq %rax, 0x608(%rdi)
leaq 0x130ba5(%rip), %rax    # 0x13e3c6
movq %rax, 0x610(%rdi)
movb $0x1, 0x620(%rdi)
movb $0x1, 0x621(%rdi)
movb $0x0, 0x622(%rdi)
movb $0x1, 0x623(%rdi)
movb $0x1, 0x624(%rdi)
callq 0x2b500
jmp 0xd852
movq -0xa8(%rbp), %rdi
callq 0x2b100
jmp 0xd860
movl $0x0, -0x28(%rbp)
cmpl $0x3, -0x28(%rbp)
jb 0xd93a
movb $0x1, -0x4a(%rbp)
movl $0x10, %edi
callq 0x71a0
movq %rax, -0xc8(%rbp)
leaq -0x49(%rbp), %rdi
movq %rdi, -0xc0(%rbp)
callq 0x7650
movq -0xc0(%rbp), %rdx
leaq 0x130b2b(%rip), %rsi    # 0x13e3cf
leaq -0x48(%rbp), %rdi
callq 0x7520
jmp 0xd8af
movq -0xc8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x9c50
jmp 0xd8c1
movq -0xc8(%rbp), %rdi
movb $0x0, -0x4a(%rbp)
leaq 0x1a0505(%rip), %rsi    # 0x1addd8
leaq -0x3c4a(%rip), %rdx     # 0x9c90
callq 0x7610
jmp 0xdb43
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0xdb31
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0xd918
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x7708
leaq -0x49(%rbp), %rdi
callq 0x73d0
testb $0x1, -0x4a(%rbp)
jne 0xd929
jmp 0xd935
movq -0xc8(%rbp), %rdi
callq 0x72c0
jmp 0xdb31
movq -0xa8(%rbp), %rdi
addq $0x788, %rdi            # imm = 0x788
callq 0x10340
movq -0xa8(%rbp), %rdi
callq 0x578d0
jmp 0xd95b
movl $0x178, %edi            # imm = 0x178
callq 0x7360
movq %rax, -0xd0(%rbp)
jmp 0xd96e
movq -0xd0(%rbp), %rdi
callq 0x74f0
jmp 0xd97c
movq -0xd0(%rbp), %rsi
leaq -0x58(%rbp), %rdi
movq %rdi, -0xd8(%rbp)
callq 0x10620
movq -0xd8(%rbp), %rsi
movq -0xa8(%rbp), %rdi
addq $0x420, %rdi            # imm = 0x420
callq 0x10650
movq -0xd8(%rbp), %rdi
callq 0x10680
movq -0xa8(%rbp), %rdi
movq (%rdi), %rax
movq 0x78(%rax), %rax
callq *%rax
jmp 0xd9cb
movq -0xa8(%rbp), %rdi
callq 0xcde0
jmp 0xd9d9
movq -0xa8(%rbp), %rdi
movl 0x108(%rdi), %esi
callq 0x106d0
movq %rax, -0xe0(%rbp)
jmp 0xd9f4
xorps %xmm0, %xmm0
movaps %xmm0, -0x70(%rbp)
movaps %xmm0, -0x80(%rbp)
movaps %xmm0, -0x90(%rbp)
movaps %xmm0, -0xa0(%rbp)
leaq -0xa0(%rbp), %rdi
movq %rdi, -0xe8(%rbp)
callq 0x10710
movq -0xa8(%rbp), %rdi
movq -0xe0(%rbp), %rsi
movq -0xe8(%rbp), %rdx
callq 0x59ba0
jmp 0xda3c
leaq -0xa0(%rbp), %rdi
callq 0xf250
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
movq -0xa8(%rbp), %rax
testb $0x1, 0x1d0(%rax)
jne 0xd867
movq -0xa8(%rbp), %rdi
callq 0x5c350
jmp 0xda73
movq -0xa8(%rbp), %rdi
callq 0x876c0
jmp 0xda81
movq -0xa8(%rbp), %rdi
callq 0xdb50
jmp 0xda8f
movq -0xa8(%rbp), %rdi
callq 0x25150
movq %rax, -0xf0(%rbp)
jmp 0xdaa4
movq -0xf0(%rbp), %rdi
addq $0x8, %rdi
leaq 0x13a58e(%rip), %rsi    # 0x148044
callq 0x7510
jmp 0xdabd
movq -0xa8(%rbp), %rdi
addq $0x420, %rdi            # imm = 0x420
callq 0x10740
movq -0xb8(%rbp), %rdi
movq %rax, %rsi
callq 0x7380
jmp 0xdae1
leaq -0x18(%rbp), %rdi
callq 0x10760
movq -0xb0(%rbp), %rax
addq $0xf0, %rsp
popq %rbp
retq
movq -0xd0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
movl $0x178, %esi            # imm = 0x178
callq 0x7370
jmp 0xdb31
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0xf250
leaq -0x18(%rbp), %rdi
callq 0x10760
movq -0x20(%rbp), %rdi
callq 0x7640
nopw %cs:(%rax,%rax)