// File: /workspace/github_cpp_makefile_star2_O2/rossy[P]crossc/SPIRV-Cross/spirv_glsl.cpp
// Function: spirv_cross::CompilerGLSL::flattened_access_chain_vector[abi:cxx11](unsigned int, unsigned int const*, unsigned int, spirv_cross::SPIRType const&, unsigned int, unsigned int, bool)
std::string CompilerGLSL::flattened_access_chain_vector(uint32_t base, const uint32_t *indices, uint32_t count,
                                                        const SPIRType &target_type, uint32_t offset,
                                                        uint32_t matrix_stride, bool need_transpose)
{
	auto result = flattened_access_chain_offset(expression_type(base), indices, count, offset, 16);

	auto buffer_name = to_name(expression_type(base).self);

	if (need_transpose)
	{
		std::string expr;

		if (target_type.vecsize > 1)
		{
			expr += type_to_glsl_constructor(target_type);
			expr += "(";
		}

		for (uint32_t i = 0; i < target_type.vecsize; ++i)
		{
			if (i != 0)
				expr += ", ";

			uint32_t component_offset = result.second + i * matrix_stride;

			assert(component_offset % (target_type.width / 8) == 0);
			uint32_t index = component_offset / (target_type.width / 8);

			expr += buffer_name;
			expr += "[";
			expr += result.first; // this is a series of N1 * k1 + N2 * k2 + ... that is either empty or ends with a +
			expr += convert_to_string(index / 4);
			expr += "]";

			expr += vector_swizzle(1, index % 4);
		}

		if (target_type.vecsize > 1)
		{
			expr += ")";
		}

		return expr;
	}
	else
	{
		assert(result.second % (target_type.width / 8) == 0);
		uint32_t index = result.second / (target_type.width / 8);

		std::string expr;

		expr += buffer_name;
		expr += "[";
		expr += result.first; // this is a series of N1 * k1 + N2 * k2 + ... that is either empty or ends with a +
		expr += convert_to_string(index / 4);
		expr += "]";

		expr += vector_swizzle(target_type.vecsize, index % 4);

		return expr;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %r9, %r14
movl %r8d, %ebp
movq %rcx, %r12
movl %edx, %r13d
movq %rsi, %r15
movq %rdi, %rbx
movq %rsi, %rdi
movl %edx, %esi
callq 0x104b0
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rsp)
movl $0x10, (%rsp)
leaq 0x40(%rsp), %rdi
movq %r15, %rsi
movq %rax, %rdx
movq %r12, %rcx
movl %ebp, %r8d
movl 0xc0(%rsp), %r9d
callq 0x35a84
movq %r15, %rdi
movl %r13d, %esi
callq 0x104b0
movl 0x8(%rax), %edx
movq (%r15), %rax
leaq 0x68(%rsp), %rdi
pushq $0x1
popq %rcx
movq %r15, %rsi
callq *0x38(%rax)
cmpb $0x0, 0xd0(%rsp)
je 0x36b52
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
andq $0x0, 0x8(%rbx)
movb $0x0, 0x10(%rbx)
cmpl $0x2, 0x14(%r14)
jb 0x36a86
leaq 0x20(%rsp), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x2c226
leaq 0x20(%rsp), %rsi
movq %rbx, %rdi
callq 0x64f0
leaq 0x20(%rsp), %rdi
callq 0x6548
leaq 0x671ab(%rip), %rsi     # 0x9dc29
movq %rbx, %rdi
callq 0x64d0
xorl %r15d, %r15d
leaq 0x20(%rsp), %rbp
xorl %r12d, %r12d
movl 0x14(%r14), %eax
cmpl %eax, %r12d
jae 0x36bf4
testl %r12d, %r12d
je 0x36ab2
movq %rbx, %rdi
leaq 0x5e5de(%rip), %rsi     # 0x9508b
callq 0x64d0
movl 0x60(%rsp), %eax
addl %r15d, %eax
movl 0x10(%r14), %ecx
shrl $0x3, %ecx
xorl %edx, %edx
divl %ecx
testl %edx, %edx
jne 0x36c31
movl %eax, %r13d
movq %rbx, %rdi
leaq 0x68(%rsp), %rsi
callq 0x64f0
movq %rbx, %rdi
leaq 0x671be(%rip), %rsi     # 0x9dca4
callq 0x64d0
movq %rbx, %rdi
leaq 0x40(%rsp), %rsi
callq 0x64f0
movl %r13d, %esi
shrl $0x2, %esi
movq %rbp, %rdi
callq 0x1c182
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x64f0
movq %rbp, %rdi
callq 0x6548
movq %rbx, %rdi
leaq 0x61fab(%rip), %rsi     # 0x98ace
callq 0x64d0
andl $0x3, %r13d
pushq $0x1
popq %rdi
movl %r13d, %esi
callq 0x36cba
movq %rbx, %rdi
movq %rax, %rsi
callq 0x64d0
incl %r12d
addl 0xc8(%rsp), %r15d
jmp 0x36a91
movl 0x60(%rsp), %eax
movl 0x10(%r14), %ecx
shrl $0x3, %ecx
xorl %edx, %edx
divl %ecx
testl %edx, %edx
jne 0x36c50
movl %eax, %ebp
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
andq $0x0, 0x8(%rbx)
movb $0x0, 0x10(%rbx)
leaq 0x68(%rsp), %rsi
movq %rbx, %rdi
callq 0x64f0
leaq 0x67115(%rip), %rsi     # 0x9dca4
movq %rbx, %rdi
callq 0x64d0
leaq 0x40(%rsp), %rsi
movq %rbx, %rdi
callq 0x64f0
movl %ebp, %esi
shrl $0x2, %esi
leaq 0x20(%rsp), %rdi
callq 0x1c182
leaq 0x20(%rsp), %rsi
movq %rbx, %rdi
callq 0x64f0
leaq 0x20(%rsp), %rdi
callq 0x6548
leaq 0x61efd(%rip), %rsi     # 0x98ace
movq %rbx, %rdi
callq 0x64d0
movl 0x14(%r14), %edi
andl $0x3, %ebp
movl %ebp, %esi
callq 0x36cba
movq %rbx, %rdi
movq %rax, %rsi
callq 0x64d0
jmp 0x36c08
cmpl $0x1, %eax
jbe 0x36c08
leaq 0x5edf5(%rip), %rsi     # 0x959f5
movq %rbx, %rdi
callq 0x64d0
leaq 0x68(%rsp), %rdi
callq 0x6548
leaq 0x40(%rsp), %rdi
callq 0x6548
movq %rbx, %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x5daaa(%rip), %rdi     # 0x946e2
leaq 0x5b0e9(%rip), %rsi     # 0x91d28
leaq 0x5dacc(%rip), %rcx     # 0x94712
movl $0x1619, %edx           # imm = 0x1619
callq 0x61c0
leaq 0x5db52(%rip), %rdi     # 0x947a9
leaq 0x5b0ca(%rip), %rsi     # 0x91d28
leaq 0x5daad(%rip), %rcx     # 0x94712
movl $0x162e, %edx           # imm = 0x162E
callq 0x61c0
jmp 0x36c84
jmp 0x36c93
jmp 0x36c93
jmp 0x36c84
jmp 0x36c93
movq %rax, %r14
jmp 0x36ca8
jmp 0x36c93
jmp 0x36c93
jmp 0x36c93
movq %rax, %r14
leaq 0x20(%rsp), %rdi
callq 0x6548
jmp 0x36c96
movq %rax, %r14
movq %rbx, %rdi
callq 0x6548
leaq 0x68(%rsp), %rdi
callq 0x6548
leaq 0x40(%rsp), %rdi
callq 0x6548
movq %r14, %rdi
callq 0x64b0