// File: rossy[P]crossc/SPIRV-Cross/spirv_hlsl.cpp
// Function: spirv_cross::CompilerHLSL::image_type_hlsl_legacy[abi:cxx11](spirv_cross::SPIRType const&, unsigned int)
string CompilerHLSL::image_type_hlsl_legacy(const SPIRType &type, uint32_t id)
{
	auto &imagetype = get<SPIRType>(type.image.type);
	string res;

	switch (imagetype.basetype)
	{
	case SPIRType::Int:
		res = "i";
		break;
	case SPIRType::UInt:
		res = "u";
		break;
	default:
		break;
	}

	if (type.basetype == SPIRType::Image && type.image.dim == DimSubpassData)
		return res + "subpassInput" + (type.image.ms ? "MS" : "");

	// If we're emulating subpassInput with samplers, force sampler2D
	// so we don't have to specify format.
	if (type.basetype == SPIRType::Image && type.image.dim != DimSubpassData)
	{
		// Sampler buffers are always declared as samplerBuffer even though they might be separate images in the SPIR-V.
		if (type.image.dim == DimBuffer && type.image.sampled == 1)
			res += "sampler";
		else
			res += type.image.sampled == 2 ? "image" : "texture";
	}
	else
		res += "sampler";

	switch (type.image.dim)
	{
	case Dim1D:
		res += "1D";
		break;
	case Dim2D:
		res += "2D";
		break;
	case Dim3D:
		res += "3D";
		break;
	case DimCube:
		res += "CUBE";
		break;

	case DimBuffer:
		res += "Buffer";
		break;

	case DimSubpassData:
		res += "2D";
		break;
	default:
		SPIRV_CROSS_THROW("Only 1D, 2D, 3D, Buffer, InputTarget and Cube textures supported.");
	}

	if (type.image.ms)
		res += "MS";
	if (type.image.arrayed)
		res += "Array";
	if (image_is_comparison(type, id))
		res += "Shadow";

	return res;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0xc0(%rbp)
movq %rdi, %rax
movq %rax, -0xb8(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0xb0(%rbp)
movq -0x18(%rbp), %rax
movl 0x80(%rax), %esi
callq 0xea90
movq %rax, -0x28(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x7530
movq -0x28(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0xa8(%rbp)
subl $0x4, %eax
je 0xbbd43
jmp 0xbbd36
movl -0xa8(%rbp), %eax
subl $0x5, %eax
je 0xbbd68
jmp 0xbbd7c
leaq 0x85391(%rip), %rsi     # 0x1410db
leaq -0x48(%rbp), %rdi
callq 0x7510
jmp 0xbbd55
jmp 0xbbd7e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0xbc0cf
leaq 0x883de(%rip), %rsi     # 0x14414d
leaq -0x48(%rbp), %rdi
callq 0x7510
jmp 0xbbd7a
jmp 0xbbd7e
jmp 0xbbd7e
movq -0x18(%rbp), %rax
cmpl $0xd, 0xc(%rax)
jne 0xbbe0f
movq -0x18(%rbp), %rax
cmpl $0x6, 0x84(%rax)
jne 0xbbe0f
leaq 0x88e9c(%rip), %rdx     # 0x144c3c
leaq -0x78(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x2f8c0
jmp 0xbbdaf
movq -0xc0(%rbp), %rdi
movq -0x18(%rbp), %rax
movb 0x8a(%rax), %cl
leaq 0x8602b(%rip), %rax     # 0x141df2
leaq 0x82ad0(%rip), %rdx     # 0x13e89e
testb $0x1, %cl
cmovneq %rax, %rdx
leaq -0x78(%rbp), %rsi
callq 0x11910
jmp 0xbbde0
leaq -0x78(%rbp), %rdi
callq 0x7708
movl $0x1, -0x7c(%rbp)
jmp 0xbc0b6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x7708
jmp 0xbc0cf
movq -0x18(%rbp), %rax
cmpl $0xd, 0xc(%rax)
jne 0xbbe82
movq -0x18(%rbp), %rax
cmpl $0x6, 0x84(%rax)
je 0xbbe82
movq -0x18(%rbp), %rax
cmpl $0x5, 0x84(%rax)
jne 0xbbe54
movq -0x18(%rbp), %rax
cmpl $0x1, 0x8c(%rax)
jne 0xbbe54
leaq 0x8c1e0(%rip), %rsi     # 0x148027
leaq -0x48(%rbp), %rdi
callq 0x7340
jmp 0xbbe52
jmp 0xbbe80
movq -0x18(%rbp), %rax
movl 0x8c(%rax), %eax
subl $0x2, %eax
leaq 0x88de1(%rip), %rax     # 0x144c49
leaq 0x90d95(%rip), %rsi     # 0x14cc04
cmoveq %rax, %rsi
leaq -0x48(%rbp), %rdi
callq 0x7340
jmp 0xbbe7e
jmp 0xbbe80
jmp 0xbbe96
leaq 0x8c19e(%rip), %rsi     # 0x148027
leaq -0x48(%rbp), %rdi
callq 0x7340
jmp 0xbbe94
jmp 0xbbe96
movq -0x18(%rbp), %rax
movl 0x84(%rax), %eax
movq %rax, -0xc8(%rbp)
subq $0x6, %rax
ja 0xbbf52
movq -0xc8(%rbp), %rax
leaq 0x8963d(%rip), %rcx     # 0x1454fc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x85ef3(%rip), %rsi     # 0x141dc2
leaq -0x48(%rbp), %rdi
callq 0x7340
jmp 0xbbeda
jmp 0xbc022
leaq 0x85ef3(%rip), %rsi     # 0x141dd9
leaq -0x48(%rbp), %rdi
callq 0x7340
jmp 0xbbef1
jmp 0xbc022
leaq 0x85f1b(%rip), %rsi     # 0x141e18
leaq -0x48(%rbp), %rdi
callq 0x7340
jmp 0xbbf08
jmp 0xbc022
leaq 0x8c4c3(%rip), %rsi     # 0x1483d7
leaq -0x48(%rbp), %rdi
callq 0x7340
jmp 0xbbf1f
jmp 0xbc022
leaq 0x85ef6(%rip), %rsi     # 0x141e21
leaq -0x48(%rbp), %rdi
callq 0x7340
jmp 0xbbf36
jmp 0xbc022
leaq 0x85e97(%rip), %rsi     # 0x141dd9
leaq -0x48(%rbp), %rdi
callq 0x7340
jmp 0xbbf4d
jmp 0xbc022
movb $0x1, -0xa2(%rbp)
movl $0x10, %edi
callq 0x71a0
movq %rax, -0xd8(%rbp)
leaq -0xa1(%rbp), %rdi
movq %rdi, -0xd0(%rbp)
callq 0x7650
movq -0xd0(%rbp), %rdx
leaq 0x88cf7(%rip), %rsi     # 0x144c82
leaq -0xa0(%rbp), %rdi
callq 0x7520
jmp 0xbbf99
movq -0xd8(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x9c50
jmp 0xbbfae
movq -0xd8(%rbp), %rdi
movb $0x0, -0xa2(%rbp)
leaq 0xf1e15(%rip), %rsi     # 0x1addd8
leaq -0xb233a(%rip), %rdx    # 0x9c90
callq 0x7610
jmp 0xbc0e1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0xbbffa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x7708
leaq -0xa1(%rbp), %rdi
callq 0x73d0
testb $0x1, -0xa2(%rbp)
jne 0xbc011
jmp 0xbc01d
movq -0xd8(%rbp), %rdi
callq 0x72c0
jmp 0xbc0cf
movq -0x18(%rbp), %rax
testb $0x1, 0x8a(%rax)
je 0xbc043
leaq 0x85dbc(%rip), %rsi     # 0x141df2
leaq -0x48(%rbp), %rdi
callq 0x7340
jmp 0xbc041
jmp 0xbc043
movq -0x18(%rbp), %rax
testb $0x1, 0x89(%rax)
je 0xbc064
leaq 0x85d76(%rip), %rsi     # 0x141dcd
leaq -0x48(%rbp), %rdi
callq 0x7340
jmp 0xbc062
jmp 0xbc064
movq -0xb0(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
callq 0x2c890
movb %al, -0xd9(%rbp)
jmp 0xbc07f
movb -0xd9(%rbp), %al
testb $0x1, %al
jne 0xbc08b
jmp 0xbc09f
leaq 0x85f21(%rip), %rsi     # 0x141fb3
leaq -0x48(%rbp), %rdi
callq 0x7340
jmp 0xbc09d
jmp 0xbc09f
movq -0xc0(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x7210
movl $0x1, -0x7c(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x7708
movq -0xb8(%rbp), %rax
addq $0xe0, %rsp
popq %rbp
retq
leaq -0x48(%rbp), %rdi
callq 0x7708
movq -0x50(%rbp), %rdi
callq 0x7640
nopw %cs:(%rax,%rax)