// File: /workspace/github_cpp_makefile_star2_O1/rossy[P]crossc/SPIRV-Cross/spirv_cross.cpp
// Function: spirv_cross::Compiler::BufferAccessHandler::handle(spv::Op, unsigned int const*, unsigned int)
bool Compiler::BufferAccessHandler::handle(Op opcode, const uint32_t *args, uint32_t length)
{
	if (opcode != OpAccessChain && opcode != OpInBoundsAccessChain)
		return true;

	// Invalid SPIR-V.
	if (length < 4)
		return false;

	if (args[2] != id)
		return true;

	// Don't bother traversing the entire access chain tree yet.
	// If we access a struct member, assume we access the entire member.
	uint32_t index = compiler.get<SPIRConstant>(args[3]).scalar();

	// Seen this index already.
	if (seen.find(index) != end(seen))
		return true;
	seen.insert(index);

	auto &type = compiler.expression_type(id);
	uint32_t offset = compiler.type_struct_member_offset(type, index);

	size_t range;
	// If we have another member in the struct, deduce the range by looking at the next member.
	// This is okay since structs in SPIR-V can have padding, but Offset decoration must be
	// monotonically increasing.
	// Of course, this doesn't take into account if the SPIR-V for some reason decided to add
	// very large amounts of padding, but that's not really a big deal.
	if (index + 1 < type.member_types.size())
	{
		range = compiler.type_struct_member_offset(type, index + 1) - offset;
	}
	else
	{
		// No padding, so just deduce it from the size of the member directly.
		range = compiler.get_declared_struct_member_size(type, index);
	}

	ranges.push_back({ index, offset, range });
	return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x20, %rsp
addl $-0x43, %esi
movb $0x1, %bl
cmpl $-0x2, %esi
jb 0x15ee3
cmpl $0x4, %ecx
jae 0x15d9a
xorl %ebx, %ebx
jmp 0x15ee3
movq %rdi, %r14
movl 0x8(%rdx), %eax
cmpl 0x18(%rdi), %eax
jne 0x15ee3
movq 0x8(%r14), %rdi
movl 0xc(%rdx), %esi
callq 0x1bb22
movl 0x10(%rax), %ecx
movl %ecx, 0x4(%rsp)
movq 0x20(%r14), %rdi
movq 0x28(%r14), %r8
xorl %r10d, %r10d
movq %rcx, %rax
xorl %edx, %edx
divq %r8
movq (%rdi,%rdx,8), %rax
testq %rax, %rax
je 0x15e15
movq (%rax), %r9
movq %rax, %r10
cmpl 0x8(%r9), %ecx
je 0x15e15
movq %rdx, %rsi
movq %r9, %r11
movq (%r9), %r9
testq %r9, %r9
je 0x15e12
movl 0x8(%r9), %edi
movq %rdi, %rax
xorl %edx, %edx
divq %r8
movl $0x0, %r10d
cmpq %rsi, %rdx
jne 0x15e15
movq %r11, %r10
cmpl %edi, %ecx
jne 0x15de7
jmp 0x15e15
xorl %r10d, %r10d
testq %r10, %r10
je 0x15e24
cmpq $0x0, (%r10)
jne 0x15ee3
leaq 0x20(%r14), %rdi
leaq 0x8(%rsp), %rdx
movq %rdi, (%rdx)
leaq 0x4(%rsp), %r12
movq %r12, %rsi
callq 0x1fc02
movq 0x8(%r14), %r15
movl 0x18(%r14), %esi
movq %r15, %rdi
callq 0x13116
movq %r15, %rdi
movl %eax, %esi
callq 0x1b9de
movq %rax, %r15
movq 0x8(%r14), %rdi
movl (%r12), %edx
movq %rax, %rsi
callq 0x155fe
movl %eax, %ebp
movl (%r12), %edx
movq 0x70(%r15), %rcx
subq 0x68(%r15), %rcx
leal 0x1(%rdx), %eax
sarq $0x2, %rcx
movq 0x8(%r14), %rdi
cmpq %rax, %rcx
jbe 0x15e96
movq %r15, %rsi
movl %eax, %edx
callq 0x155fe
subl %ebp, %eax
jmp 0x15e9f
movq (%rdi), %rax
movq %r15, %rsi
callq *0x30(%rax)
movq 0x10(%r14), %rdi
movl 0x4(%rsp), %ecx
movl %ecx, 0x8(%rsp)
movl %ebp, %ecx
movq %rcx, 0x10(%rsp)
movq %rax, 0x18(%rsp)
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x15ed9
movq 0x18(%rsp), %rax
movq %rax, 0x10(%rsi)
movups 0x8(%rsp), %xmm0
movups %xmm0, (%rsi)
addq $0x18, 0x8(%rdi)
jmp 0x15ee3
leaq 0x8(%rsp), %rdx
callq 0x217e8
movl %ebx, %eax
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq