// File: rossy[P]crossc/SPIRV-Cross/spirv_glsl.cpp
// Function: spirv_cross::CompilerGLSL::flattened_access_chain_struct[abi:cxx11](unsigned int, unsigned int const*, unsigned int, spirv_cross::SPIRType const&, unsigned int)
std::string CompilerGLSL::flattened_access_chain_struct(uint32_t base, const uint32_t *indices, uint32_t count,
                                                        const SPIRType &target_type, uint32_t offset)
{
	std::string expr;

	expr += type_to_glsl_constructor(target_type);
	expr += "(";

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

		const SPIRType &member_type = get<SPIRType>(target_type.member_types[i]);
		uint32_t member_offset = type_struct_member_offset(target_type, i);

		// The access chain terminates at the struct, so we need to find matrix strides and row-major information
		// ahead of time.
		bool need_transpose = false;
		uint32_t matrix_stride = 0;
		if (member_type.columns > 1)
		{
			need_transpose = combined_decoration_for_member(target_type, i).get(DecorationRowMajor);
			matrix_stride = type_struct_member_matrix_stride(target_type, i);
		}

		auto tmp = flattened_access_chain(base, indices, count, member_type, offset + member_offset, matrix_stride,
		                                  need_transpose);

		// Cannot forward transpositions, so resolve them here.
		if (need_transpose)
			expr += convert_row_major_matrix(tmp, member_type, false);
		else
			expr += tmp;
	}

	expr += ")";

	return expr;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x170, %rsp            # imm = 0x170
movq %rdi, -0x138(%rbp)
movq %rdi, %rax
movq %rax, -0x130(%rbp)
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movq %r9, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x128(%rbp)
movb $0x0, -0x31(%rbp)
callq 0x7530
movq -0x128(%rbp), %rsi
movq -0x30(%rbp), %rdx
leaq -0x58(%rbp), %rdi
callq 0x72bf0
jmp 0x87810
movq -0x138(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x7470
jmp 0x87822
leaq -0x58(%rbp), %rdi
callq 0x7708
movq -0x138(%rbp), %rdi
leaq 0xc5af4(%rip), %rsi     # 0x14d32d
callq 0x7340
jmp 0x87840
movl $0x0, -0x68(%rbp)
movl -0x68(%rbp), %eax
movl %eax, -0x13c(%rbp)
movq -0x30(%rbp), %rdi
addq $0x68, %rdi
callq 0x8650
movq %rax, %rcx
movl -0x13c(%rbp), %eax
cmpl %ecx, %eax
jae 0x87af5
cmpl $0x0, -0x68(%rbp)
je 0x878b6
movq -0x138(%rbp), %rdi
leaq 0xbcd0d(%rip), %rsi     # 0x14458f
callq 0x7340
jmp 0x87889
jmp 0x878b6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x87b30
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x7708
jmp 0x87b30
movq -0x30(%rbp), %rdi
addq $0x68, %rdi
movl -0x68(%rbp), %eax
movl %eax, %esi
callq 0x8570
movq -0x128(%rbp), %rdi
movl (%rax), %esi
callq 0xea90
movq %rax, -0x148(%rbp)
jmp 0x878df
movq -0x128(%rbp), %rdi
movq -0x148(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x30(%rbp), %rsi
movl -0x68(%rbp), %edx
callq 0x24050
movl %eax, -0x14c(%rbp)
jmp 0x87905
movl -0x14c(%rbp), %eax
movl %eax, -0x74(%rbp)
movb $0x0, -0x75(%rbp)
movl $0x0, -0x7c(%rbp)
movq -0x70(%rbp), %rax
cmpl $0x1, 0x18(%rax)
jbe 0x879b6
movq -0x128(%rbp), %rsi
movq -0x30(%rbp), %rdx
movl -0x68(%rbp), %ecx
leaq -0xc0(%rbp), %rdi
callq 0x2c660
jmp 0x87943
leaq -0xc0(%rbp), %rdi
movl $0x4, %esi
callq 0xef50
movb %al, -0x14d(%rbp)
jmp 0x8795c
movb -0x14d(%rbp), %al
andb $0x1, %al
movb %al, -0x75(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0xf250
movq -0x128(%rbp), %rdi
movq -0x30(%rbp), %rsi
movl -0x68(%rbp), %edx
callq 0x24290
movl %eax, -0x154(%rbp)
jmp 0x8798e
movl -0x154(%rbp), %eax
movl %eax, -0x7c(%rbp)
jmp 0x879b6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0xf250
jmp 0x87b30
movq -0x128(%rbp), %rsi
movl -0x14(%rbp), %edx
movq -0x20(%rbp), %rcx
movl -0x24(%rbp), %r8d
movq -0x70(%rbp), %r9
movl 0x10(%rbp), %edi
movl -0x74(%rbp), %eax
addl %eax, %edi
movl -0x7c(%rbp), %r10d
movzbl -0x75(%rbp), %r11d
andl $0x1, %r11d
movq %rsp, %rax
movl %r11d, 0x10(%rax)
movl %r10d, 0x8(%rax)
movl %edi, (%rax)
leaq -0xe0(%rbp), %rdi
callq 0x87100
jmp 0x879fc
testb $0x1, -0x75(%rbp)
je 0x87ab6
leaq -0x120(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x7170
jmp 0x87a1b
movq -0x128(%rbp), %rsi
movq -0x70(%rbp), %rcx
movq (%rsi), %rax
movq 0x118(%rax), %rax
leaq -0x100(%rbp), %rdi
leaq -0x120(%rbp), %rdx
xorl %r8d, %r8d
callq *%rax
jmp 0x87a45
movq -0x138(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0x7470
jmp 0x87a5a
leaq -0x100(%rbp), %rdi
callq 0x7708
leaq -0x120(%rbp), %rdi
callq 0x7708
jmp 0x87acd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x87ae7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x87aa8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x100(%rbp), %rdi
callq 0x7708
leaq -0x120(%rbp), %rdi
callq 0x7708
jmp 0x87ae7
movq -0x138(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x7470
jmp 0x87acb
jmp 0x87acd
leaq -0xe0(%rbp), %rdi
callq 0x7708
movl -0x68(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x68(%rbp)
jmp 0x87847
leaq -0xe0(%rbp), %rdi
callq 0x7708
jmp 0x87b30
movq -0x138(%rbp), %rdi
leaq 0xbd3f6(%rip), %rsi     # 0x144ef9
callq 0x7340
jmp 0x87b0a
movb $0x1, -0x31(%rbp)
testb $0x1, -0x31(%rbp)
jne 0x87b20
movq -0x138(%rbp), %rdi
callq 0x7708
movq -0x130(%rbp), %rax
addq $0x170, %rsp            # imm = 0x170
popq %rbp
retq
movq -0x138(%rbp), %rdi
callq 0x7708
movq -0x60(%rbp), %rdi
callq 0x7640
nopw %cs:(%rax,%rax)