// File: /workspace/github_cpp_makefile_star2_O2/rossy[P]crossc/SPIRV-Cross/spirv_glsl.cpp
// Function: spirv_cross::CompilerGLSL::layout_for_member[abi:cxx11](spirv_cross::SPIRType const&, unsigned int)
string CompilerGLSL::layout_for_member(const SPIRType &type, uint32_t index)
{
	if (is_legacy())
		return "";

	bool is_block = ir.meta[type.self].decoration.decoration_flags.get(DecorationBlock) ||
	                ir.meta[type.self].decoration.decoration_flags.get(DecorationBufferBlock);
	if (!is_block)
		return "";

	auto &memb = ir.meta[type.self].members;
	if (index >= memb.size())
		return "";
	auto &dec = memb[index];

	vector<string> attr;

	// We can only apply layouts on members in block interfaces.
	// This is a bit problematic because in SPIR-V decorations are applied on the struct types directly.
	// This is not supported on GLSL, so we have to make the assumption that if a struct within our buffer block struct
	// has a decoration, it was originally caused by a top-level layout() qualifier in GLSL.
	//
	// We would like to go from (SPIR-V style):
	//
	// struct Foo { layout(row_major) mat4 matrix; };
	// buffer UBO { Foo foo; };
	//
	// to
	//
	// struct Foo { mat4 matrix; }; // GLSL doesn't support any layout shenanigans in raw struct declarations.
	// buffer UBO { layout(row_major) Foo foo; }; // Apply the layout on top-level.
	auto flags = combined_decoration_for_member(type, index);

	if (flags.get(DecorationRowMajor))
		attr.push_back("row_major");
	// We don't emit any global layouts, so column_major is default.
	//if (flags & (1ull << DecorationColMajor))
	//    attr.push_back("column_major");

	if (dec.decoration_flags.get(DecorationLocation) && can_use_io_location(type.storage, true))
		attr.push_back(join("location = ", dec.location));

	// Can only declare component if we can declare location.
	if (dec.decoration_flags.get(DecorationComponent) && can_use_io_location(type.storage, true))
	{
		if (!options.es)
		{
			if (options.version < 440 && options.version >= 140)
				require_extension_internal("GL_ARB_enhanced_layouts");
			else if (options.version < 140)
				SPIRV_CROSS_THROW("Component decoration is not supported in targets below GLSL 1.40.");
			attr.push_back(join("component = ", dec.component));
		}
		else
			SPIRV_CROSS_THROW("Component decoration is not supported in ES targets.");
	}

	// DecorationCPacked is set by layout_for_variable earlier to mark that we need to emit offset qualifiers.
	// This is only done selectively in GLSL as needed.
	if (has_decoration(type.self, DecorationCPacked) && dec.decoration_flags.get(DecorationOffset))
		attr.push_back(join("offset = ", dec.offset));

	if (attr.empty())
		return "";

	string res = "layout(";
	res += merge(attr);
	res += ") ";
	return res;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movl %ecx, %ebp
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x41b9c
testb %al, %al
jne 0x230d2
movl 0x8(%r12), %ecx
movq 0x38(%r15), %rax
imulq $0x148, %rcx, %rcx      # imm = 0x148
testb $0xc, 0x60(%rax,%rcx)
je 0x230d2
addq %rcx, %rax
movl %ebp, %r13d
movq 0xd0(%rax), %r14
movq 0xd8(%rax), %rax
subq %r14, %rax
movl $0xd0, %ecx
cqto
idivq %rcx
cmpq %r13, %rax
jbe 0x230d2
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
andq $0x0, 0x40(%rsp)
leaq 0x48(%rsp), %rdi
movq %r15, %rsi
movq %r12, %rdx
movl %ebp, %ecx
callq 0x16ba6
testb $0x10, 0x48(%rsp)
je 0x23007
leaq 0x6eac7(%rip), %rsi     # 0x91aa6
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x6100
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0xcc8c
leaq 0x10(%rsp), %rdi
callq 0x6548
imulq $0xd0, %r13, %rax
addq %rax, %r14
testb $0x40, 0x63(%r14)
je 0x2305d
movl 0x64(%r12), %esi
pushq $0x1
popq %rdx
movq %r15, %rdi
callq 0x23326
testb %al, %al
je 0x2305d
leaq 0xa4(%r14), %rdx
leaq 0x6ea76(%rip), %rsi     # 0x91ab0
leaq 0x10(%rsp), %rdi
callq 0x416ac
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0xcc8c
leaq 0x10(%rsp), %rdi
callq 0x6548
testb $-0x80, 0x63(%r14)
je 0x23137
movl 0x64(%r12), %esi
pushq $0x1
popq %rdx
movq %r15, %rdi
callq 0x23326
testb %al, %al
je 0x23137
cmpb $0x0, 0x43c(%r15)
jne 0x2320a
movl 0x438(%r15), %eax
leal -0x8c(%rax), %ecx
cmpl $0x12b, %ecx            # imm = 0x12B
ja 0x230fb
leaq 0x6ea12(%rip), %rsi     # 0x91abc
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x6100
leaq 0x10(%rsp), %rsi
movq %r15, %rdi
callq 0x21390
leaq 0x10(%rsp), %rdi
callq 0x6548
jmp 0x23106
leaq 0x6c7ae(%rip), %rsi     # 0x8f887
leaq 0x48(%rsp), %rdx
movq %rbx, %rdi
callq 0x6100
movq %rbx, %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x8b, %eax
jbe 0x23255
leaq 0xa8(%r14), %rdx
leaq 0x6ea02(%rip), %rsi     # 0x91b16
leaq 0x10(%rsp), %rdi
callq 0x41bc9
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0xcc8c
leaq 0x10(%rsp), %rdi
callq 0x6548
movl 0x8(%r12), %esi
pushq $0xa
popq %rdx
movq %r15, %rdi
callq 0x103d2
testb %al, %al
je 0x23186
testb $0x8, 0x64(%r14)
je 0x23186
addq $0xb4, %r14
leaq 0x6e9f8(%rip), %rsi     # 0x91b58
leaq 0x10(%rsp), %rdi
movq %r14, %rdx
callq 0x41c33
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0xcc8c
leaq 0x10(%rsp), %rdi
callq 0x6548
movq 0x30(%rsp), %rax
cmpq 0x38(%rsp), %rax
je 0x231dd
leaq 0x6e889(%rip), %rsi     # 0x91a22
leaq 0x10(%rsp), %rdx
movq %rbx, %rdi
callq 0x6100
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x41980
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x64f0
leaq 0x10(%rsp), %rdi
callq 0x6548
leaq 0x72bfa(%rip), %rsi     # 0x95dcd
movq %rbx, %rdi
callq 0x64d0
jmp 0x231f1
leaq 0x6c6a3(%rip), %rsi     # 0x8f887
leaq 0x10(%rsp), %rdx
movq %rbx, %rdi
callq 0x6100
leaq 0x50(%rsp), %rdi
callq 0xb51c
leaq 0x30(%rsp), %rdi
callq 0xb98a
jmp 0x230e6
pushq $0x10
popq %rdi
callq 0x6140
movq %rax, %rbx
leaq 0x6e907(%rip), %rsi     # 0x91b23
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x6100
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x6f6e
xorl %ebp, %ebp
leaq 0xc3b7c(%rip), %rsi     # 0xe6dc0
movq 0xc4d95(%rip), %rdx     # 0xe7fe0
movq %rbx, %rdi
callq 0x6490
jmp 0x2329e
pushq $0x10
popq %rdi
callq 0x6140
movq %rax, %rbx
leaq 0x6e86d(%rip), %rsi     # 0x91ad4
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x6100
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x6f6e
xorl %ebp, %ebp
leaq 0xc3b31(%rip), %rsi     # 0xe6dc0
movq 0xc4d4a(%rip), %rdx     # 0xe7fe0
movq %rbx, %rdi
callq 0x6490
jmp 0x232a6
jmp 0x232ba
jmp 0x232d5
jmp 0x23306
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x6548
testb %bpl, %bpl
jne 0x232bd
jmp 0x23309
movq %rax, %r14
movq %rbx, %rdi
callq 0x6200
jmp 0x23309
jmp 0x232d5
jmp 0x232d5
jmp 0x23306
jmp 0x23306
jmp 0x232d5
jmp 0x23306
jmp 0x23306
movq %rax, %r14
leaq 0x10(%rsp), %rdi
jmp 0x232f8
jmp 0x23306
jmp 0x232f2
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x6548
jmp 0x232f5
movq %rax, %r14
movq %rbx, %rdi
callq 0x6548
jmp 0x23309
jmp 0x23306
movq %rax, %r14
jmp 0x23313
movq %rax, %r14
leaq 0x50(%rsp), %rdi
callq 0xb51c
leaq 0x30(%rsp), %rdi
callq 0xb98a
movq %r14, %rdi
callq 0x64b0
nop