// File: rossy[P]crossc/SPIRV-Cross/spirv_hlsl.cpp
// Function: spirv_cross::CompilerHLSL::compile[abi:cxx11]()
string CompilerHLSL::compile()
{
	// Do not deal with ES-isms like precision, older extensions and such.
	options.es = false;
	options.version = 450;
	options.vulkan_semantics = true;
	backend.float_literal_suffix = true;
	backend.double_literal_suffix = false;
	backend.half_literal_suffix = nullptr;
	backend.long_long_literal_suffix = true;
	backend.uint32_t_literal_suffix = true;
	backend.basic_int_type = "int";
	backend.basic_uint_type = "uint";
	backend.swizzle_is_function = false;
	backend.shared_is_implied = true;
	backend.flexible_member_array_supported = false;
	backend.explicit_struct_type = false;
	backend.use_initializer_list = true;
	backend.use_constructor_splatting = false;
	backend.boolean_mix_support = false;
	backend.can_swizzle_scalar = true;
	backend.can_declare_struct_inline = false;
	backend.can_declare_arrays_inline = false;
	backend.can_return_array = false;

	build_function_control_flow_graphs_and_analyze();
	update_active_builtins();
	analyze_image_and_sampler_usage();

	// Subpass input needs SV_Position.
	if (need_subpass_input)
		active_input_builtins.set(BuiltInFragCoord);

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

		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());
		emit_hlsl_entry_point();

		pass_count++;
	} while (force_recompile);

	// Entry point in HLSL 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), %rdi
movq %rdi, -0xa8(%rbp)
movb $0x0, 0x43c(%rdi)
movl $0x1c2, 0x438(%rdi)     # imm = 0x1C2
movb $0x1, 0x43e(%rdi)
movb $0x1, 0x600(%rdi)
movb $0x0, 0x601(%rdi)
movq $0x0, 0x618(%rdi)
movb $0x1, 0x603(%rdi)
movb $0x1, 0x602(%rdi)
leaq 0x6dd2e(%rip), %rax     # 0x141833
movq %rax, 0x608(%rdi)
leaq 0x795cf(%rip), %rax     # 0x14d0e2
movq %rax, 0x610(%rdi)
movb $0x0, 0x620(%rdi)
movb $0x1, 0x621(%rdi)
movb $0x0, 0x622(%rdi)
movb $0x0, 0x623(%rdi)
movb $0x1, 0x624(%rdi)
movb $0x0, 0x629(%rdi)
movb $0x0, 0x62a(%rdi)
movb $0x1, 0x62c(%rdi)
movb $0x0, 0x626(%rdi)
movb $0x0, 0x627(%rdi)
movb $0x0, 0x62e(%rdi)
callq 0x2b500
movq -0xa8(%rbp), %rdi
callq 0x2b100
movq -0xa8(%rbp), %rdi
callq 0x2b230
movq -0xa8(%rbp), %rax
testb $0x1, 0x398(%rax)
je 0xd3bac
movq -0xa8(%rbp), %rdi
addq $0x2d0, %rdi            # imm = 0x2D0
movl $0xf, %esi
callq 0x300d0
movl $0x0, -0x14(%rbp)
cmpl $0x3, -0x14(%rbp)
jb 0xd3c75
movb $0x1, -0x4d(%rbp)
movl $0x10, %edi
callq 0x71a0
movq %rax, -0xc8(%rbp)
leaq -0x39(%rbp), %rdi
movq %rdi, -0xc0(%rbp)
callq 0x7650
movq -0xc0(%rbp), %rdx
leaq 0x6a7df(%rip), %rsi     # 0x13e3cf
leaq -0x38(%rbp), %rdi
callq 0x7520
jmp 0xd3bfb
movq -0xc8(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x9c50
jmp 0xd3c0d
movq -0xc8(%rbp), %rdi
movb $0x0, -0x4d(%rbp)
leaq 0xda1b9(%rip), %rsi     # 0x1addd8
leaq -0xc9f96(%rip), %rdx    # 0x9c90
callq 0x7610
jmp 0xd3e1f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0xd3c53
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x7708
leaq -0x39(%rbp), %rdi
callq 0x73d0
testb $0x1, -0x4d(%rbp)
jne 0xd3c64
jmp 0xd3c70
movq -0xc8(%rbp), %rdi
callq 0x72c0
jmp 0xd3e16
movq -0xa8(%rbp), %rdi
callq 0x578d0
movl $0x178, %edi            # imm = 0x178
callq 0x7360
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xd0(%rbp)
callq 0x74f0
jmp 0xd3c9f
movq -0xd0(%rbp), %rsi
leaq -0x58(%rbp), %rdi
movq %rdi, -0xe8(%rbp)
callq 0x10620
movq -0xe8(%rbp), %rsi
movq -0xa8(%rbp), %rdi
addq $0x420, %rdi            # imm = 0x420
callq 0x10650
movq -0xe8(%rbp), %rdi
callq 0x10680
movq -0xa8(%rbp), %rdi
movq (%rdi), %rax
movq 0x78(%rax), %rax
callq *%rax
movq -0xa8(%rbp), %rdi
callq 0xbf5c0
movq -0xa8(%rbp), %rdi
movl 0x108(%rdi), %esi
callq 0x106d0
movq %rax, -0xe0(%rbp)
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, -0xd8(%rbp)
callq 0x10710
movq -0xa8(%rbp), %rdi
movq -0xe0(%rbp), %rsi
movq -0xd8(%rbp), %rdx
callq 0x59ba0
jmp 0xd3d59
leaq -0xa0(%rbp), %rdi
callq 0xf250
movq -0xa8(%rbp), %rdi
callq 0xc4860
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
movq -0xa8(%rbp), %rax
testb $0x1, 0x1d0(%rax)
jne 0xd3bb3
movq -0xa8(%rbp), %rdi
callq 0x25150
movq %rax, %rdi
addq $0x8, %rdi
leaq 0x7429c(%rip), %rsi     # 0x148044
callq 0x7510
movq -0xa8(%rbp), %rdi
addq $0x420, %rdi            # imm = 0x420
callq 0x10740
movq -0xb8(%rbp), %rdi
movq %rax, %rsi
callq 0x7380
movq -0xb0(%rbp), %rax
addq $0xf0, %rsp
popq %rbp
retq
movq -0xd0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
movl $0x178, %esi            # imm = 0x178
callq 0x7370
jmp 0xd3e16
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0xf250
movq -0x48(%rbp), %rdi
callq 0x7640
nop