// File: rossy[P]crossc/SPIRV-Cross/spirv_hlsl.cpp
// Function: spirv_cross::CompilerHLSL::emit_load(spirv_cross::Instruction const&)
void CompilerHLSL::emit_load(const Instruction &instruction)
{
	auto ops = stream(instruction);

	auto *chain = maybe_get<SPIRAccessChain>(ops[2]);
	if (chain)
	{
		uint32_t result_type = ops[0];
		uint32_t id = ops[1];
		uint32_t ptr = ops[2];

		auto load_expr = read_access_chain(*chain);

		bool forward = should_forward(ptr) && forced_temporaries.find(id) == end(forced_temporaries);

		// Do not forward complex load sequences like matrices, structs and arrays.
		auto &type = get<SPIRType>(result_type);
		if (type.columns > 1 || !type.array.empty() || type.basetype == SPIRType::Struct)
			forward = false;

		auto &e = emit_op(result_type, id, load_expr, forward, true);
		e.need_transpose = false;
		register_read(id, ptr, forward);
	}
	else
		CompilerGLSL::emit_instruction(instruction);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x90(%rbp)
movq -0x10(%rbp), %rsi
callq 0x2e560
movq -0x90(%rbp), %rdi
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movl 0x8(%rax), %esi
callq 0x2e7f0
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0xcac31
movq -0x90(%rbp), %rsi
movq -0x18(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x24(%rbp)
movq -0x18(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x28(%rbp)
movq -0x18(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x2c(%rbp)
movq -0x20(%rbp), %rdx
leaq -0x50(%rbp), %rdi
callq 0xc9da0
movq -0x90(%rbp), %rdi
movl -0x2c(%rbp), %esi
callq 0x78810
movb %al, -0x91(%rbp)
jmp 0xcaad5
movb -0x91(%rbp), %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x92(%rbp)
jne 0xcaaea
jmp 0xcab4f
movq -0x90(%rbp), %rdi
addq $0x228, %rdi            # imm = 0x228
leaq -0x28(%rbp), %rsi
callq 0x2ff00
movq %rax, -0xa0(%rbp)
jmp 0xcab0a
movq -0x90(%rbp), %rdi
movq -0xa0(%rbp), %rax
movq %rax, -0x70(%rbp)
addq $0x228, %rdi            # imm = 0x228
callq 0x2ff30
movq %rax, -0xa8(%rbp)
jmp 0xcab31
movq -0xa8(%rbp), %rax
movq %rax, -0x78(%rbp)
leaq -0x70(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x2eb30
movb %al, -0x92(%rbp)
movq -0x90(%rbp), %rdi
movb -0x92(%rbp), %al
andb $0x1, %al
movb %al, -0x51(%rbp)
movl -0x24(%rbp), %esi
callq 0xea90
movq %rax, -0xb0(%rbp)
jmp 0xcab72
movq -0xb0(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
cmpl $0x1, 0x18(%rax)
ja 0xcaba4
movq -0x80(%rbp), %rdi
addq $0x20, %rdi
callq 0x8690
testb $0x1, %al
jne 0xcab9a
jmp 0xcaba4
movq -0x80(%rbp), %rax
cmpl $0xc, 0xc(%rax)
jne 0xcabc4
movb $0x0, -0x51(%rbp)
jmp 0xcabc4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x7708
jmp 0xcac4a
movq -0x90(%rbp), %rdi
movl -0x24(%rbp), %esi
movl -0x28(%rbp), %edx
movzbl -0x51(%rbp), %r8d
andl $0x1, %r8d
leaq -0x50(%rbp), %rcx
movl $0x1, %r9d
callq 0x784f0
movq %rax, -0xb8(%rbp)
jmp 0xcabf2
movq -0x90(%rbp), %rdi
movq -0xb8(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
movb $0x0, 0x39(%rax)
movl -0x28(%rbp), %esi
movl -0x2c(%rbp), %edx
movzbl -0x51(%rbp), %ecx
andl $0x1, %ecx
callq 0x1fb20
jmp 0xcac26
leaq -0x50(%rbp), %rdi
callq 0x7708
jmp 0xcac41
movq -0x90(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x89270
addq $0xc0, %rsp
popq %rbp
retq
movq -0x60(%rbp), %rdi
callq 0x7640
nopw %cs:(%rax,%rax)