// File: rossy[P]crossc/SPIRV-Cross/spirv_hlsl.cpp
// Function: spirv_cross::CompilerHLSL::type_to_glsl[abi:cxx11](spirv_cross::SPIRType const&, unsigned int)
string CompilerHLSL::type_to_glsl(const SPIRType &type, uint32_t id)
{
	// Ignore the pointer type since GLSL doesn't have pointers.

	switch (type.basetype)
	{
	case SPIRType::Struct:
		// Need OpName lookup here to get a "sensible" name for a struct.
		if (backend.explicit_struct_type)
			return join("struct ", to_name(type.self));
		else
			return to_name(type.self);

	case SPIRType::Image:
	case SPIRType::SampledImage:
		return image_type_hlsl(type, id);

	case SPIRType::Sampler:
		return comparison_ids.count(id) ? "SamplerComparisonState" : "SamplerState";

	case SPIRType::Void:
		return "void";

	default:
		break;
	}

	if (type.vecsize == 1 && type.columns == 1) // Scalar builtin
	{
		switch (type.basetype)
		{
		case SPIRType::Boolean:
			return "bool";
		case SPIRType::Int:
			return backend.basic_int_type;
		case SPIRType::UInt:
			return backend.basic_uint_type;
		case SPIRType::AtomicCounter:
			return "atomic_uint";
		case SPIRType::Half:
			return "min16float";
		case SPIRType::Float:
			return "float";
		case SPIRType::Double:
			return "double";
		case SPIRType::Int64:
			return "int64_t";
		case SPIRType::UInt64:
			return "uint64_t";
		default:
			return "???";
		}
	}
	else if (type.vecsize > 1 && type.columns == 1) // Vector builtin
	{
		switch (type.basetype)
		{
		case SPIRType::Boolean:
			return join("bool", type.vecsize);
		case SPIRType::Int:
			return join("int", type.vecsize);
		case SPIRType::UInt:
			return join("uint", type.vecsize);
		case SPIRType::Half:
			return join("min16float", type.vecsize);
		case SPIRType::Float:
			return join("float", type.vecsize);
		case SPIRType::Double:
			return join("double", type.vecsize);
		case SPIRType::Int64:
			return join("i64vec", type.vecsize);
		case SPIRType::UInt64:
			return join("u64vec", type.vecsize);
		default:
			return "???";
		}
	}
	else
	{
		switch (type.basetype)
		{
		case SPIRType::Boolean:
			return join("bool", type.columns, "x", type.vecsize);
		case SPIRType::Int:
			return join("int", type.columns, "x", type.vecsize);
		case SPIRType::UInt:
			return join("uint", type.columns, "x", type.vecsize);
		case SPIRType::Half:
			return join("min16float", type.columns, "x", type.vecsize);
		case SPIRType::Float:
			return join("float", type.columns, "x", type.vecsize);
		case SPIRType::Double:
			return join("double", type.columns, "x", type.vecsize);
		// Matrix types not supported for int64/uint64.
		default:
			return "???";
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x130, %rsp            # imm = 0x130
movq %rdi, -0x80(%rbp)
movq %rdi, %rax
movq %rax, -0x78(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x18(%rbp), %rax
movl 0xc(%rax), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x68(%rbp)
subl $0xe, %eax
ja 0xbc335
movq -0x68(%rbp), %rax
leaq 0x89368(%rip), %rcx     # 0x145518
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x70(%rbp), %rax
testb $0x1, 0x623(%rax)
je 0xbc22b
movq -0x70(%rbp), %rsi
movq -0x18(%rbp), %rax
movl 0x8(%rax), %edx
movq (%rsi), %rax
movq 0x38(%rax), %rax
leaq -0x40(%rbp), %rdi
movq %rdi, -0x88(%rbp)
movl $0x1, %ecx
callq *%rax
movq -0x80(%rbp), %rdi
movq -0x88(%rbp), %rdx
leaq 0x84d3f(%rip), %rsi     # 0x140f3b
callq 0xa75e0
jmp 0xbc203
leaq -0x40(%rbp), %rdi
callq 0x7708
jmp 0xbc9dc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x7708
jmp 0xbc9e9
movq -0x70(%rbp), %rsi
movq -0x80(%rbp), %rdi
movq -0x18(%rbp), %rax
movl 0x8(%rax), %edx
movq (%rsi), %rax
movl $0x1, %ecx
callq *0x38(%rax)
jmp 0xbc9dc
movq -0x70(%rbp), %rsi
movq -0x80(%rbp), %rdi
movq -0x18(%rbp), %rdx
movl -0x1c(%rbp), %ecx
callq 0xbc0f0
jmp 0xbc9dc
movq -0x70(%rbp), %rdi
addq $0x360, %rdi            # imm = 0x360
leaq -0x1c(%rbp), %rsi
callq 0x13520
testq %rax, %rax
leaq 0x89cfe(%rip), %rcx     # 0x145f7f
leaq 0x89d0e(%rip), %rax     # 0x145f96
cmovneq %rcx, %rax
movq %rax, -0x98(%rbp)
leaq -0x4d(%rbp), %rdi
movq %rdi, -0x90(%rbp)
callq 0x7650
movq -0x80(%rbp), %rdi
movq -0x98(%rbp), %rsi
movq -0x90(%rbp), %rdx
callq 0x7520
jmp 0xbc2bc
leaq -0x4d(%rbp), %rdi
callq 0x73d0
jmp 0xbc9dc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x4d(%rbp), %rdi
callq 0x73d0
jmp 0xbc9e9
leaq -0x4e(%rbp), %rdi
movq %rdi, -0xa0(%rbp)
callq 0x7650
movq -0x80(%rbp), %rdi
movq -0xa0(%rbp), %rdx
leaq 0x85ecf(%rip), %rsi     # 0x1421d5
callq 0x7520
jmp 0xbc30d
leaq -0x4e(%rbp), %rdi
callq 0x73d0
jmp 0xbc9dc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x4e(%rbp), %rdi
callq 0x73d0
jmp 0xbc9e9
jmp 0xbc337
movq -0x18(%rbp), %rax
cmpl $0x1, 0x14(%rax)
jne 0xbc6d4
movq -0x18(%rbp), %rax
cmpl $0x1, 0x18(%rax)
jne 0xbc6d4
movq -0x18(%rbp), %rax
movl 0xc(%rax), %eax
addl $-0x2, %eax
movl %eax, %ecx
movq %rcx, -0xa8(%rbp)
subl $0x9, %eax
ja 0xbc683
movq -0xa8(%rbp), %rax
leaq 0x89227(%rip), %rcx     # 0x1455a4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq -0x4f(%rbp), %rdi
movq %rdi, -0xb0(%rbp)
callq 0x7650
movq -0x80(%rbp), %rdi
movq -0xb0(%rbp), %rdx
leaq 0x858e6(%rip), %rsi     # 0x141c8e
callq 0x7520
jmp 0xbc3af
leaq -0x4f(%rbp), %rdi
callq 0x73d0
jmp 0xbc9dc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x4f(%rbp), %rdi
callq 0x73d0
jmp 0xbc9e9
movq -0x70(%rbp), %rax
movq 0x608(%rax), %rax
movq %rax, -0xc0(%rbp)
leaq -0x50(%rbp), %rdi
movq %rdi, -0xb8(%rbp)
callq 0x7650
movq -0x80(%rbp), %rdi
movq -0xc0(%rbp), %rsi
movq -0xb8(%rbp), %rdx
callq 0x7520
jmp 0xbc412
leaq -0x50(%rbp), %rdi
callq 0x73d0
jmp 0xbc9dc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x73d0
jmp 0xbc9e9
movq -0x70(%rbp), %rax
movq 0x610(%rax), %rax
movq %rax, -0xd0(%rbp)
leaq -0x51(%rbp), %rdi
movq %rdi, -0xc8(%rbp)
callq 0x7650
movq -0x80(%rbp), %rdi
movq -0xd0(%rbp), %rsi
movq -0xc8(%rbp), %rdx
callq 0x7520
jmp 0xbc475
leaq -0x51(%rbp), %rdi
callq 0x73d0
jmp 0xbc9dc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x51(%rbp), %rdi
callq 0x73d0
jmp 0xbc9e9
leaq -0x52(%rbp), %rdi
movq %rdi, -0xd8(%rbp)
callq 0x7650
movq -0x80(%rbp), %rdi
movq -0xd8(%rbp), %rdx
leaq 0x857b9(%rip), %rsi     # 0x141c78
callq 0x7520
jmp 0xbc4c6
leaq -0x52(%rbp), %rdi
callq 0x73d0
jmp 0xbc9dc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x52(%rbp), %rdi
callq 0x73d0
jmp 0xbc9e9
leaq -0x53(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
callq 0x7650
movq -0x80(%rbp), %rdi
movq -0xe0(%rbp), %rdx
leaq 0x89a93(%rip), %rsi     # 0x145fa3
callq 0x7520
jmp 0xbc517
leaq -0x53(%rbp), %rdi
callq 0x73d0
jmp 0xbc9dc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x53(%rbp), %rdi
callq 0x73d0
jmp 0xbc9e9
leaq -0x54(%rbp), %rdi
movq %rdi, -0xe8(%rbp)
callq 0x7650
movq -0x80(%rbp), %rdi
movq -0xe8(%rbp), %rdx
leaq 0x90b88(%rip), %rsi     # 0x14d0e9
callq 0x7520
jmp 0xbc568
leaq -0x54(%rbp), %rdi
callq 0x73d0
jmp 0xbc9dc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x54(%rbp), %rdi
callq 0x73d0
jmp 0xbc9e9
leaq -0x55(%rbp), %rdi
movq %rdi, -0xf0(%rbp)
callq 0x7650
movq -0x80(%rbp), %rdi
movq -0xf0(%rbp), %rdx
leaq 0x8c02f(%rip), %rsi     # 0x1485e1
callq 0x7520
jmp 0xbc5b9
leaq -0x55(%rbp), %rdi
callq 0x73d0
jmp 0xbc9dc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x55(%rbp), %rdi
callq 0x73d0
jmp 0xbc9e9
leaq -0x56(%rbp), %rdi
movq %rdi, -0xf8(%rbp)
callq 0x7650
movq -0x80(%rbp), %rdi
movq -0xf8(%rbp), %rdx
leaq 0x8877d(%rip), %rsi     # 0x144d80
callq 0x7520
jmp 0xbc60a
leaq -0x56(%rbp), %rdi
callq 0x73d0
jmp 0xbc9dc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x56(%rbp), %rdi
callq 0x73d0
jmp 0xbc9e9
leaq -0x57(%rbp), %rdi
movq %rdi, -0x100(%rbp)
callq 0x7650
movq -0x80(%rbp), %rdi
movq -0x100(%rbp), %rdx
leaq 0x8872b(%rip), %rsi     # 0x144d7f
callq 0x7520
jmp 0xbc65b
leaq -0x57(%rbp), %rdi
callq 0x73d0
jmp 0xbc9dc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x57(%rbp), %rdi
callq 0x73d0
jmp 0xbc9e9
leaq -0x58(%rbp), %rdi
movq %rdi, -0x108(%rbp)
callq 0x7650
movq -0x80(%rbp), %rdi
movq -0x108(%rbp), %rdx
leaq 0x886e3(%rip), %rsi     # 0x144d88
callq 0x7520
jmp 0xbc6ac
leaq -0x58(%rbp), %rdi
callq 0x73d0
jmp 0xbc9dc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x73d0
jmp 0xbc9e9
movq -0x18(%rbp), %rax
cmpl $0x1, 0x14(%rax)
jbe 0xbc85c
movq -0x18(%rbp), %rax
cmpl $0x1, 0x18(%rax)
jne 0xbc85c
movq -0x18(%rbp), %rax
movl 0xc(%rax), %eax
addl $-0x2, %eax
movl %eax, %ecx
movq %rcx, -0x110(%rbp)
subl $0x9, %eax
ja 0xbc80b
movq -0x110(%rbp), %rax
leaq 0x88e62(%rip), %rcx     # 0x14557c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x80(%rbp), %rdi
movq -0x18(%rbp), %rdx
addq $0x14, %rdx
leaq 0x85558(%rip), %rsi     # 0x141c8e
callq 0xa7690
jmp 0xbc9dc
movq -0x80(%rbp), %rdi
movq -0x18(%rbp), %rdx
addq $0x14, %rdx
leaq 0x850e0(%rip), %rsi     # 0x141833
callq 0xa77f0
jmp 0xbc9dc
movq -0x80(%rbp), %rdi
movq -0x18(%rbp), %rdx
addq $0x14, %rdx
leaq 0x90972(%rip), %rsi     # 0x14d0e2
callq 0xa7690
jmp 0xbc9dc
movq -0x80(%rbp), %rdi
movq -0x18(%rbp), %rdx
addq $0x14, %rdx
leaq 0x89816(%rip), %rsi     # 0x145fa3
callq 0xd7140
jmp 0xbc9dc
movq -0x80(%rbp), %rdi
movq -0x18(%rbp), %rdx
addq $0x14, %rdx
leaq 0x9093f(%rip), %rsi     # 0x14d0e9
callq 0xd71f0
jmp 0xbc9dc
movq -0x80(%rbp), %rdi
movq -0x18(%rbp), %rdx
addq $0x14, %rdx
leaq 0x8be1a(%rip), %rsi     # 0x1485e1
callq 0xa7740
jmp 0xbc9dc
movq -0x80(%rbp), %rdi
movq -0x18(%rbp), %rdx
addq $0x14, %rdx
leaq 0x885c3(%rip), %rsi     # 0x144da7
callq 0xa7740
jmp 0xbc9dc
movq -0x80(%rbp), %rdi
movq -0x18(%rbp), %rdx
addq $0x14, %rdx
leaq 0x885ad(%rip), %rsi     # 0x144dae
callq 0xa7740
jmp 0xbc9dc
leaq -0x59(%rbp), %rdi
movq %rdi, -0x118(%rbp)
callq 0x7650
movq -0x80(%rbp), %rdi
movq -0x118(%rbp), %rdx
leaq 0x8855b(%rip), %rsi     # 0x144d88
callq 0x7520
jmp 0xbc834
leaq -0x59(%rbp), %rdi
callq 0x73d0
jmp 0xbc9dc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x59(%rbp), %rdi
callq 0x73d0
jmp 0xbc9e9
movq -0x18(%rbp), %rax
movl 0xc(%rax), %eax
addl $-0x2, %eax
movl %eax, %ecx
movq %rcx, -0x120(%rbp)
subl $0x9, %eax
ja 0xbc991
movq -0x120(%rbp), %rax
leaq 0x88cce(%rip), %rcx     # 0x145554
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x80(%rbp), %rdi
movq -0x18(%rbp), %rdx
addq $0x18, %rdx
movq -0x18(%rbp), %r8
addq $0x14, %r8
leaq 0x853e4(%rip), %rsi     # 0x141c8e
leaq 0x879b0(%rip), %rcx     # 0x144261
callq 0xa78a0
jmp 0xbc9dc
movq -0x80(%rbp), %rdi
movq -0x18(%rbp), %rdx
addq $0x18, %rdx
movq -0x18(%rbp), %r8
addq $0x14, %r8
leaq 0x84f5d(%rip), %rsi     # 0x141833
leaq 0x87984(%rip), %rcx     # 0x144261
callq 0xa7a20
jmp 0xbc9dc
movq -0x80(%rbp), %rdi
movq -0x18(%rbp), %rdx
addq $0x18, %rdx
movq -0x18(%rbp), %r8
addq $0x14, %r8
leaq 0x907e0(%rip), %rsi     # 0x14d0e2
leaq 0x87958(%rip), %rcx     # 0x144261
callq 0xa78a0
jmp 0xbc9dc
movq -0x80(%rbp), %rdi
movq -0x18(%rbp), %rdx
addq $0x18, %rdx
movq -0x18(%rbp), %r8
addq $0x14, %r8
leaq 0x89675(%rip), %rsi     # 0x145fa3
leaq 0x8792c(%rip), %rcx     # 0x144261
callq 0xd72a0
jmp 0xbc9dc
movq -0x80(%rbp), %rdi
movq -0x18(%rbp), %rdx
addq $0x18, %rdx
movq -0x18(%rbp), %r8
addq $0x14, %r8
leaq 0x9078f(%rip), %rsi     # 0x14d0e9
leaq 0x87900(%rip), %rcx     # 0x144261
callq 0xd7360
jmp 0xbc9dc
movq -0x80(%rbp), %rdi
movq -0x18(%rbp), %rdx
addq $0x18, %rdx
movq -0x18(%rbp), %r8
addq $0x14, %r8
leaq 0x8bc5e(%rip), %rsi     # 0x1485e1
leaq 0x878d7(%rip), %rcx     # 0x144261
callq 0xa7960
jmp 0xbc9dc
leaq -0x5a(%rbp), %rdi
movq %rdi, -0x128(%rbp)
callq 0x7650
movq -0x80(%rbp), %rdi
movq -0x128(%rbp), %rdx
leaq 0x883d5(%rip), %rsi     # 0x144d88
callq 0x7520
jmp 0xbc9ba
leaq -0x5a(%rbp), %rdi
callq 0x73d0
jmp 0xbc9dc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x5a(%rbp), %rdi
callq 0x73d0
jmp 0xbc9e9
movq -0x78(%rbp), %rax
addq $0x130, %rsp            # imm = 0x130
popq %rbp
retq
movq -0x48(%rbp), %rdi
callq 0x7640
nopw %cs:(%rax,%rax)