// File: rossy[P]crossc/SPIRV-Cross/spirv_glsl.cpp
// Function: spirv_cross::CompilerGLSL::emit_interface_block(spirv_cross::SPIRVariable const&)
void CompilerGLSL::emit_interface_block(const SPIRVariable &var)
{
	auto &type = get<SPIRType>(var.basetype);

	// Either make it plain in/out or in/out blocks depending on what shader is doing ...
	bool block = ir.meta[type.self].decoration.decoration_flags.get(DecorationBlock);
	const char *qual = to_storage_qualifiers_glsl(var);

	if (block)
	{
		// ESSL earlier than 310 and GLSL earlier than 150 did not support
		// I/O variables which are struct types.
		// To support this, flatten the struct into separate varyings instead.
		if ((options.es && options.version < 310) || (!options.es && options.version < 150))
		{
			// I/O blocks on ES require version 310 with Android Extension Pack extensions, or core version 320.
			// On desktop, I/O blocks were introduced with geometry shaders in GL 3.2 (GLSL 150).
			emit_flattened_io_block(var, qual);
		}
		else
		{
			if (options.es && options.version < 320)
			{
				// Geometry and tessellation extensions imply this extension.
				if (!has_extension("GL_EXT_geometry_shader") && !has_extension("GL_EXT_tessellation_shader"))
					require_extension_internal("GL_EXT_shader_io_blocks");
			}

			// Block names should never alias.
			auto block_name = to_name(type.self, false);

			// The namespace for I/O blocks is separate from other variables in GLSL.
			auto &block_namespace = type.storage == StorageClassInput ? block_input_names : block_output_names;

			// Shaders never use the block by interface name, so we don't
			// have to track this other than updating name caches.
			if (block_name.empty() || block_namespace.find(block_name) != end(block_namespace))
				block_name = get_fallback_name(type.self);
			else
				block_namespace.insert(block_name);

			// If for some reason buffer_name is an illegal name, make a final fallback to a workaround name.
			// This cannot conflict with anything else, so we're safe now.
			if (block_name.empty())
				block_name = join("_", get<SPIRType>(var.basetype).self, "_", var.self);

			// Instance names cannot alias block names.
			resource_names.insert(block_name);

			statement(layout_for_variable(var), qual, block_name);
			begin_scope();

			type.member_name_cache.clear();

			uint32_t i = 0;
			for (auto &member : type.member_types)
			{
				add_member_name(type, i);
				emit_struct_member(type, member, i);
				i++;
			}

			add_resource_name(var.self);
			end_scope_decl(join(to_name(var.self), type_to_array_glsl(type)));
			statement("");
		}
	}
	else
	{
		// ESSL earlier than 310 and GLSL earlier than 150 did not support
		// I/O variables which are struct types.
		// To support this, flatten the struct into separate varyings instead.
		if (type.basetype == SPIRType::Struct &&
		    ((options.es && options.version < 310) || (!options.es && options.version < 150)))
		{
			emit_flattened_io_block(var, qual);
		}
		else
		{
			add_resource_name(var.self);
			statement(layout_for_variable(var), variable_decl(var), ";");
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2f0, %rsp            # imm = 0x2F0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x260(%rbp)
movq -0x10(%rbp), %rax
movl 0xc(%rax), %esi
callq 0xea90
movq -0x260(%rbp), %rdi
movq %rax, -0x18(%rbp)
addq $0x8, %rdi
addq $0x30, %rdi
movq -0x18(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, %esi
callq 0xead0
movq %rax, %rdi
addq $0x60, %rdi
movl $0x2, %esi
callq 0xef50
movq -0x260(%rbp), %rdi
andb $0x1, %al
movb %al, -0x19(%rbp)
movq -0x10(%rbp), %rsi
movq (%rdi), %rax
callq *0x130(%rax)
movq %rax, -0x28(%rbp)
testb $0x1, -0x19(%rbp)
je 0x62bac
movq -0x260(%rbp), %rax
testb $0x1, 0x43c(%rax)
je 0x62396
movq -0x260(%rbp), %rax
cmpl $0x136, 0x438(%rax)     # imm = 0x136
jb 0x623b9
movq -0x260(%rbp), %rax
testb $0x1, 0x43c(%rax)
jne 0x623d2
movq -0x260(%rbp), %rax
cmpl $0x96, 0x438(%rax)
jae 0x623d2
movq -0x260(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0x61bb0
jmp 0x62ba7
movq -0x260(%rbp), %rax
testb $0x1, 0x43c(%rax)
je 0x6262f
movq -0x260(%rbp), %rax
cmpl $0x140, 0x438(%rax)     # imm = 0x140
jae 0x6262f
leaq -0x49(%rbp), %rdi
movq %rdi, -0x268(%rbp)
callq 0x7650
movq -0x268(%rbp), %rdx
movb $0x0, -0x82(%rbp)
movb $0x0, -0x83(%rbp)
leaq 0xde6ce(%rip), %rsi     # 0x140af7
leaq -0x48(%rbp), %rdi
callq 0x7520
jmp 0x62434
movq -0x260(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x62ce0
movb %al, -0x269(%rbp)
jmp 0x6244c
movb -0x269(%rbp), %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x26a(%rbp)
jne 0x624c1
jmp 0x62461
leaq -0x81(%rbp), %rdi
movq %rdi, -0x278(%rbp)
callq 0x7650
movq -0x278(%rbp), %rdx
movb $0x1, -0x82(%rbp)
leaq 0xde6b0(%rip), %rsi     # 0x140b39
leaq -0x80(%rbp), %rdi
callq 0x7520
jmp 0x62494
movq -0x260(%rbp), %rdi
movb $0x1, -0x83(%rbp)
leaq -0x80(%rbp), %rsi
callq 0x62ce0
movb %al, -0x279(%rbp)
jmp 0x624b3
movb -0x279(%rbp), %al
xorb $-0x1, %al
movb %al, -0x26a(%rbp)
movb -0x26a(%rbp), %al
movb %al, -0x27a(%rbp)
testb $0x1, -0x83(%rbp)
jne 0x624d8
jmp 0x624e1
leaq -0x80(%rbp), %rdi
callq 0x7708
testb $0x1, -0x82(%rbp)
jne 0x624ec
jmp 0x624f8
leaq -0x81(%rbp), %rdi
callq 0x73d0
leaq -0x48(%rbp), %rdi
callq 0x7708
leaq -0x49(%rbp), %rdi
callq 0x73d0
movb -0x27a(%rbp), %al
testb $0x1, %al
jne 0x62519
jmp 0x6262d
leaq -0xa9(%rbp), %rdi
movq %rdi, -0x288(%rbp)
callq 0x7650
movq -0x288(%rbp), %rdx
leaq 0xdf0d8(%rip), %rsi     # 0x141612
leaq -0xa8(%rbp), %rdi
callq 0x7520
jmp 0x62548
movq -0x260(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x589d0
jmp 0x6255d
leaq -0xa8(%rbp), %rdi
callq 0x7708
leaq -0xa9(%rbp), %rdi
callq 0x73d0
jmp 0x6262d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x625e8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x625df
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x625c6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
testb $0x1, -0x83(%rbp)
jne 0x625bb
jmp 0x625c4
leaq -0x80(%rbp), %rdi
callq 0x7708
jmp 0x625c6
testb $0x1, -0x82(%rbp)
jne 0x625d1
jmp 0x625dd
leaq -0x81(%rbp), %rdi
callq 0x73d0
jmp 0x625df
leaq -0x48(%rbp), %rdi
callq 0x7708
leaq -0x49(%rbp), %rdi
callq 0x73d0
jmp 0x62cd4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x6261c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x7708
leaq -0xa9(%rbp), %rdi
callq 0x73d0
jmp 0x62cd4
jmp 0x6262f
movq -0x260(%rbp), %rsi
movq -0x18(%rbp), %rax
movl 0x8(%rax), %edx
movq (%rsi), %rax
leaq -0xd0(%rbp), %rdi
xorl %ecx, %ecx
callq *0x38(%rax)
movq -0x18(%rbp), %rax
cmpl $0x1, 0x64(%rax)
jne 0x6266c
movq -0x260(%rbp), %rax
addq $0x4c0, %rax            # imm = 0x4C0
movq %rax, -0x290(%rbp)
jmp 0x62680
movq -0x260(%rbp), %rax
addq $0x4f8, %rax            # imm = 0x4F8
movq %rax, -0x290(%rbp)
movq -0x290(%rbp), %rax
movq %rax, -0xd8(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x75f0
movb %al, %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, -0x291(%rbp)
jne 0x6270f
movq -0xd8(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x2f720
movq %rax, -0x2a0(%rbp)
jmp 0x626c5
movq -0x2a0(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq -0xd8(%rbp), %rdi
callq 0x2f750
movq %rax, -0x2a8(%rbp)
jmp 0x626e8
movq -0x2a8(%rbp), %rax
movq %rax, -0xe8(%rbp)
leaq -0xe0(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x2f970
movb %al, -0x291(%rbp)
movb -0x291(%rbp), %al
testb $0x1, %al
jne 0x6271b
jmp 0x6278c
movq -0x260(%rbp), %rsi
movq -0x18(%rbp), %rax
movl 0x8(%rax), %edx
movq (%rsi), %rax
movq 0x18(%rax), %rax
leaq -0x108(%rbp), %rdi
callq *%rax
jmp 0x6273b
leaq -0xd0(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0x7050
jmp 0x62750
leaq -0x108(%rbp), %rdi
callq 0x7708
jmp 0x627c8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x62b96
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x108(%rbp), %rdi
callq 0x7708
jmp 0x62b96
movq -0xd8(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x2f780
movb %dl, -0x2b1(%rbp)
movq %rax, -0x2b0(%rbp)
jmp 0x627ae
movb -0x2b1(%rbp), %al
movq -0x2b0(%rbp), %rcx
movq %rcx, -0x118(%rbp)
movb %al, -0x110(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x75f0
testb $0x1, %al
jne 0x627da
jmp 0x62840
movq -0x260(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0xc(%rax), %esi
callq 0xea90
movq %rax, -0x2c0(%rbp)
jmp 0x627f6
movq -0x2c0(%rbp), %rdx
addq $0x8, %rdx
movq -0x10(%rbp), %r8
addq $0x8, %r8
leaq 0xe5d0e(%rip), %rcx     # 0x14851e
leaq -0x138(%rbp), %rdi
movq %rcx, %rsi
callq 0x9fb20
jmp 0x62821
leaq -0xd0(%rbp), %rdi
leaq -0x138(%rbp), %rsi
callq 0x7430
leaq -0x138(%rbp), %rdi
callq 0x7708
movq -0x260(%rbp), %rdi
addq $0x488, %rdi            # imm = 0x488
leaq -0xd0(%rbp), %rsi
callq 0x2f780
movb %dl, -0x2c9(%rbp)
movq %rax, -0x2c8(%rbp)
jmp 0x62869
movq -0x260(%rbp), %rsi
movb -0x2c9(%rbp), %al
movq -0x2c8(%rbp), %rcx
movq %rcx, -0x148(%rbp)
movb %al, -0x140(%rbp)
movq -0x10(%rbp), %rdx
leaq -0x168(%rbp), %rdi
callq 0x5e4c0
jmp 0x6289c
movq -0x260(%rbp), %rdi
leaq -0x168(%rbp), %rsi
leaq -0x28(%rbp), %rdx
leaq -0xd0(%rbp), %rcx
callq 0x9fff0
jmp 0x628bc
leaq -0x168(%rbp), %rdi
callq 0x7708
movq -0x260(%rbp), %rdi
callq 0x5c200
jmp 0x628d6
movq -0x18(%rbp), %rdi
addq $0xa0, %rdi
callq 0x9e1e0
movl $0x0, -0x16c(%rbp)
movq -0x18(%rbp), %rax
addq $0x68, %rax
movq %rax, -0x178(%rbp)
movq -0x178(%rbp), %rdi
callq 0x86d0
movq %rax, -0x180(%rbp)
movq -0x178(%rbp), %rdi
callq 0x8700
movq %rax, -0x188(%rbp)
leaq -0x180(%rbp), %rdi
leaq -0x188(%rbp), %rsi
callq 0x8730
testb $0x1, %al
jne 0x62941
jmp 0x62a7f
leaq -0x180(%rbp), %rdi
callq 0x8770
movq -0x260(%rbp), %rdi
movq %rax, -0x190(%rbp)
movq -0x18(%rbp), %rsi
movl -0x16c(%rbp), %edx
callq 0x5c240
jmp 0x6296c
movq -0x18(%rbp), %rax
movq %rax, -0x2e8(%rbp)
movq -0x190(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x2e0(%rbp)
movl -0x16c(%rbp), %eax
movl %eax, -0x2dc(%rbp)
leaq -0x1b1(%rbp), %rdi
movq %rdi, -0x2d8(%rbp)
callq 0x7650
movq -0x2d8(%rbp), %rdx
leaq 0xdbeeb(%rip), %rsi     # 0x13e89e
leaq -0x1b0(%rbp), %rdi
callq 0x7520
jmp 0x629c1
movl -0x2dc(%rbp), %ecx
movl -0x2e0(%rbp), %edx
movq -0x2e8(%rbp), %rsi
movq -0x260(%rbp), %rdi
movq (%rdi), %rax
movq 0xa8(%rax), %rax
leaq -0x1b0(%rbp), %r8
xorl %r9d, %r9d
callq *%rax
jmp 0x629f3
leaq -0x1b0(%rbp), %rdi
callq 0x7708
leaq -0x1b1(%rbp), %rdi
callq 0x73d0
movl -0x16c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x16c(%rbp)
leaq -0x180(%rbp), %rdi
callq 0x8790
jmp 0x62925
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x168(%rbp), %rdi
callq 0x7708
jmp 0x62b96
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x62a6e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x1b0(%rbp), %rdi
callq 0x7708
leaq -0x1b1(%rbp), %rdi
callq 0x73d0
jmp 0x62b96
movq -0x260(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x8(%rax), %esi
callq 0x5c1d0
jmp 0x62a94
movq -0x260(%rbp), %rsi
movq -0x10(%rbp), %rax
movl 0x8(%rax), %edx
movq (%rsi), %rax
movq 0x38(%rax), %rax
leaq -0x1f8(%rbp), %rdi
movl $0x1, %ecx
callq *%rax
jmp 0x62ab9
movq -0x260(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq -0x218(%rbp), %rdi
callq 0x61340
jmp 0x62ad2
leaq -0x1d8(%rbp), %rdi
leaq -0x1f8(%rbp), %rsi
leaq -0x218(%rbp), %rdx
callq 0xa0120
jmp 0x62aee
movq -0x260(%rbp), %rdi
leaq -0x1d8(%rbp), %rsi
callq 0x61240
jmp 0x62b03
leaq -0x1d8(%rbp), %rdi
callq 0x7708
leaq -0x218(%rbp), %rdi
callq 0x7708
leaq -0x1f8(%rbp), %rdi
callq 0x7708
movq -0x260(%rbp), %rdi
leaq 0xdbd69(%rip), %rsi     # 0x13e89e
callq 0xedf0
jmp 0x62b3c
leaq -0xd0(%rbp), %rdi
callq 0x7708
jmp 0x62ba7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x62b8a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x62b7e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x1d8(%rbp), %rdi
callq 0x7708
leaq -0x218(%rbp), %rdi
callq 0x7708
leaq -0x1f8(%rbp), %rdi
callq 0x7708
leaq -0xd0(%rbp), %rdi
callq 0x7708
jmp 0x62cd4
jmp 0x62ccb
movq -0x18(%rbp), %rax
cmpl $0xc, 0xc(%rax)
jne 0x62c15
movq -0x260(%rbp), %rax
testb $0x1, 0x43c(%rax)
je 0x62bd9
movq -0x260(%rbp), %rax
cmpl $0x136, 0x438(%rax)     # imm = 0x136
jb 0x62bfc
movq -0x260(%rbp), %rax
testb $0x1, 0x43c(%rax)
jne 0x62c15
movq -0x260(%rbp), %rax
cmpl $0x96, 0x438(%rax)
jae 0x62c15
movq -0x260(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0x61bb0
jmp 0x62cc9
movq -0x260(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x8(%rax), %esi
callq 0x5c1d0
movq -0x260(%rbp), %rsi
movq -0x10(%rbp), %rdx
leaq -0x238(%rbp), %rdi
callq 0x5e4c0
movq -0x260(%rbp), %rsi
movq -0x10(%rbp), %rdx
leaq -0x258(%rbp), %rdi
callq 0x62d60
jmp 0x62c58
movq -0x260(%rbp), %rdi
leaq 0xe6440(%rip), %rcx     # 0x1490a6
leaq -0x238(%rbp), %rsi
leaq -0x258(%rbp), %rdx
callq 0xa01d0
jmp 0x62c7b
leaq -0x258(%rbp), %rdi
callq 0x7708
leaq -0x238(%rbp), %rdi
callq 0x7708
jmp 0x62cc9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x62cbb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x258(%rbp), %rdi
callq 0x7708
leaq -0x238(%rbp), %rdi
callq 0x7708
jmp 0x62cd4
jmp 0x62ccb
addq $0x2f0, %rsp            # imm = 0x2F0
popq %rbp
retq
movq -0x58(%rbp), %rdi
callq 0x7640
nopl (%rax)