// File: /workspace/github_cpp_makefile_star2_O2/rossy[P]crossc/SPIRV-Cross/spirv_hlsl.cpp
// Function: spirv_cross::CompilerHLSL::write_access_chain(spirv_cross::SPIRAccessChain const&, unsigned int)
void CompilerHLSL::write_access_chain(const SPIRAccessChain &chain, uint32_t value)
{
	auto &type = get<SPIRType>(chain.basetype);

	SPIRType target_type;
	target_type.basetype = SPIRType::UInt;
	target_type.vecsize = type.vecsize;
	target_type.columns = type.columns;

	if (type.basetype == SPIRType::Struct)
		SPIRV_CROSS_THROW("Writing structs to RWByteAddressBuffer not yet supported.");
	if (type.width != 32)
		SPIRV_CROSS_THROW("Writing types other than 32-bit to RWByteAddressBuffer not yet supported.");
	if (!type.array.empty())
		SPIRV_CROSS_THROW("Reading arrays from ByteAddressBuffer not yet supported.");

	if (type.columns == 1 && !chain.row_major_matrix)
	{
		const char *store_op = nullptr;
		switch (type.vecsize)
		{
		case 1:
			store_op = "Store";
			break;
		case 2:
			store_op = "Store2";
			break;
		case 3:
			store_op = "Store3";
			break;
		case 4:
			store_op = "Store4";
			break;
		default:
			SPIRV_CROSS_THROW("Unknown vector size.");
		}

		auto store_expr = to_expression(value);
		auto bitcast_op = bitcast_glsl_op(target_type, type);
		if (!bitcast_op.empty())
			store_expr = join(bitcast_op, "(", store_expr, ")");
		statement(chain.base, ".", store_op, "(", chain.dynamic_index, chain.static_index, ", ", store_expr, ");");
	}
	else if (type.columns == 1)
	{
		// Strided store.
		for (uint32_t r = 0; r < type.vecsize; r++)
		{
			auto store_expr = to_enclosed_expression(value);
			if (type.vecsize > 1)
			{
				store_expr += ".";
				store_expr += index_to_swizzle(r);
			}
			remove_duplicate_swizzle(store_expr);

			auto bitcast_op = bitcast_glsl_op(target_type, type);
			if (!bitcast_op.empty())
				store_expr = join(bitcast_op, "(", store_expr, ")");
			statement(chain.base, ".Store(", chain.dynamic_index, chain.static_index + chain.matrix_stride * r, ", ",
			          store_expr, ");");
		}
	}
	else if (!chain.row_major_matrix)
	{
		const char *store_op = nullptr;
		switch (type.vecsize)
		{
		case 1:
			store_op = "Store";
			break;
		case 2:
			store_op = "Store2";
			break;
		case 3:
			store_op = "Store3";
			break;
		case 4:
			store_op = "Store4";
			break;
		default:
			SPIRV_CROSS_THROW("Unknown vector size.");
		}

		for (uint32_t c = 0; c < type.columns; c++)
		{
			auto store_expr = join(to_enclosed_expression(value), "[", c, "]");
			auto bitcast_op = bitcast_glsl_op(target_type, type);
			if (!bitcast_op.empty())
				store_expr = join(bitcast_op, "(", store_expr, ")");
			statement(chain.base, ".", store_op, "(", chain.dynamic_index, chain.static_index + c * chain.matrix_stride,
			          ", ", store_expr, ");");
		}
	}
	else
	{
		for (uint32_t r = 0; r < type.vecsize; r++)
		{
			for (uint32_t c = 0; c < type.columns; c++)
			{
				auto store_expr = join(to_enclosed_expression(value), "[", c, "].", index_to_swizzle(r));
				remove_duplicate_swizzle(store_expr);
				auto bitcast_op = bitcast_glsl_op(target_type, type);
				if (!bitcast_op.empty())
					store_expr = join(bitcast_op, "(", store_expr, ")");
				statement(chain.base, ".Store(", chain.dynamic_index,
				          chain.static_index + c * (type.width / 8) + r * chain.matrix_stride, ", ", store_expr, ");");
			}
		}
	}

	register_write(chain.self);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x168, %rsp            # imm = 0x168
movl %edx, 0x18(%rsp)
movq %rdi, %rbx
movq %rsi, 0x10(%rsp)
movl 0xc(%rsi), %esi
callq 0x90a4
leaq 0x160(%rsp), %rdx
andl $0x0, -0xc8(%rdx)
leaq 0x8e461(%rip), %rcx     # 0xe73f0
addq $0x10, %rcx
movq %rcx, -0xd0(%rdx)
andl $0x0, -0xc0(%rdx)
andq $0x0, -0x88(%rdx)
andl $0x0, -0x80(%rdx)
andq $0x0, -0x78(%rdx)
movq %rax, %r15
movb $0x0, -0x70(%rdx)
xorps %xmm0, %xmm0
movups %xmm0, -0xb0(%rdx)
movups %xmm0, -0xa0(%rdx)
andl $0x0, -0x90(%rdx)
movl $0x8, -0x6c(%rdx)
andq $0x0, -0x58(%rdx)
movups %xmm0, -0x68(%rdx)
andq $0x0, -0x38(%rdx)
movq %rdx, -0x30(%rdx)
movq $0x1, -0x28(%rdx)
movups %xmm0, -0x20(%rdx)
movl $0x3f800000, -0x10(%rdx) # imm = 0x3F800000
movups %xmm0, -0x8(%rdx)
movl $0x5, -0xc4(%rdx)
movl 0x14(%rax), %ecx
movl %ecx, -0xbc(%rdx)
movl 0x18(%rax), %eax
movl %eax, -0xb8(%rdx)
cmpl $0xc, 0xc(%r15)
je 0x59585
cmpl $0x20, 0x10(%r15)
jne 0x595d3
movq 0x20(%r15), %rdx
cmpq 0x28(%r15), %rdx
jne 0x59621
movq 0x10(%rsp), %rdx
movb 0x64(%rdx), %dl
cmpl $0x1, %eax
jne 0x5917c
testb %dl, %dl
je 0x592de
movq 0x10(%rsp), %rax
leaq 0x18(%rax), %rdx
movq %rdx, 0x40(%rsp)
addq $0x38, %rax
movq %rax, 0x68(%rsp)
xorl %ebp, %ebp
leaq 0x20(%rsp), %r13
leaq 0x48(%rsp), %r14
leaq 0x70(%rsp), %r12
cmpl %ecx, %ebp
jae 0x5942c
movq %r13, %rdi
movq %rbx, %rsi
movl 0x18(%rsp), %edx
callq 0x2beca
cmpl $0x2, 0x14(%r15)
jb 0x590c4
movq %r13, %rdi
leaq 0x3c77f(%rip), %rsi     # 0x95829
callq 0x64d0
movq %rbx, %rdi
movl %ebp, %esi
callq 0x2ab62
movq %r13, %rdi
movq %rax, %rsi
callq 0x64d0
movq %rbx, %rdi
movq %r13, %rsi
callq 0x2abf8
movq (%rbx), %rax
movq %r14, %rdi
movq %rbx, %rsi
leaq 0x90(%rsp), %rdx
movq %r15, %rcx
callq *0x168(%rax)
cmpq $0x0, 0x50(%rsp)
je 0x59120
movq %r12, %rdi
movq %r14, %rsi
leaq 0x44b2b(%rip), %rdx     # 0x9dc29
movq %r13, %rcx
leaq 0x3c8ed(%rip), %r8      # 0x959f5
callq 0x62e67
movq %r13, %rdi
movq %r12, %rsi
callq 0x6320
movq %r12, %rdi
callq 0x6548
movq 0x10(%rsp), %rcx
movl 0x60(%rcx), %eax
imull %ebp, %eax
addl 0x58(%rcx), %eax
movl %eax, 0x70(%rsp)
movq %rbx, %rdi
movq 0x40(%rsp), %rsi
leaq 0x402b2(%rip), %rdx     # 0x993f3
movq 0x68(%rsp), %rcx
movq %r12, %r8
leaq 0x3bf3b(%rip), %r9      # 0x9508b
leaq 0x40929(%rip), %rax     # 0x99a80
pushq %rax
pushq %r13
callq 0x63028
popq %rax
popq %rcx
movq %r14, %rdi
callq 0x6548
movq %r13, %rdi
callq 0x6548
incl %ebp
movl 0x14(%r15), %ecx
jmp 0x59082
testb %dl, %dl
je 0x59302
movq 0x10(%rsp), %rdx
leaq 0x18(%rdx), %rsi
movq %rsi, 0x40(%rsp)
addq $0x38, %rdx
movq %rdx, 0x68(%rsp)
xorl %ebp, %ebp
leaq 0x48(%rsp), %r14
leaq 0x20(%rsp), %r12
leaq 0x70(%rsp), %r13
cmpl %ecx, %ebp
jae 0x5942c
xorl %ecx, %ecx
movl %ecx, 0x8(%rsp)
cmpl %eax, %ecx
jae 0x592d3
movq %r14, %rdi
movq %rbx, %rsi
movl 0x18(%rsp), %edx
callq 0x2beca
movq %rbx, %rdi
movl %ebp, %esi
callq 0x2ab62
movq %rax, 0x70(%rsp)
movq %r12, %rdi
movq %r14, %rsi
leaq 0x44ab7(%rip), %rdx     # 0x9dca4
leaq 0x8(%rsp), %rcx
leaq 0x3b320(%rip), %r8      # 0x94519
movq %r13, %r9
callq 0x63287
movq %r14, %rdi
callq 0x6548
movq %rbx, %rdi
movq %r12, %rsi
callq 0x2abf8
movq (%rbx), %rax
movq %r14, %rdi
movq %rbx, %rsi
leaq 0x90(%rsp), %rdx
movq %r15, %rcx
callq *0x168(%rax)
cmpq $0x0, 0x50(%rsp)
je 0x59265
movq %r13, %rdi
movq %r14, %rsi
leaq 0x449e6(%rip), %rdx     # 0x9dc29
movq %r12, %rcx
leaq 0x3c7a8(%rip), %r8      # 0x959f5
callq 0x62e67
movq %r12, %rdi
movq %r13, %rsi
callq 0x6320
movq %r13, %rdi
callq 0x6548
movl 0x10(%r15), %eax
shrl $0x3, %eax
imull 0x8(%rsp), %eax
movq 0x10(%rsp), %rcx
addl 0x58(%rcx), %eax
movl 0x60(%rcx), %ecx
imull %ebp, %ecx
addl %eax, %ecx
movl %ecx, 0x70(%rsp)
movq %rbx, %rdi
movq 0x40(%rsp), %rsi
leaq 0x4015f(%rip), %rdx     # 0x993f3
movq 0x68(%rsp), %rcx
movq %r13, %r8
leaq 0x3bde8(%rip), %r9      # 0x9508b
leaq 0x407d6(%rip), %rax     # 0x99a80
pushq %rax
pushq %r12
callq 0x63028
popq %rax
popq %rcx
movq %r14, %rdi
callq 0x6548
movq %r12, %rdi
callq 0x6548
movl 0x8(%rsp), %ecx
incl %ecx
movl 0x18(%r15), %eax
jmp 0x591b6
incl %ebp
movl 0x14(%r15), %ecx
jmp 0x591ac
decl %ecx
cmpl $0x3, %ecx
ja 0x5966f
leaq 0x3cf38(%rip), %rax     # 0x96228
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
leaq 0x39139(%rip), %rax     # 0x92439
jmp 0x5935a
decl %ecx
cmpl $0x3, %ecx
ja 0x596ba
leaq 0x3cf04(%rip), %rdx     # 0x96218
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
leaq 0x39115(%rip), %rcx     # 0x92439
jmp 0x59462
leaq 0x400b5(%rip), %rax     # 0x993e5
jmp 0x5935a
leaq 0x400ac(%rip), %rcx     # 0x993e5
jmp 0x59462
leaq 0x400a7(%rip), %rax     # 0x993ec
jmp 0x5935a
leaq 0x4009e(%rip), %rcx     # 0x993ec
jmp 0x59462
leaq 0x40084(%rip), %rax     # 0x993de
movq %rax, 0x8(%rsp)
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
movl 0x18(%rsp), %edx
callq 0x2b9f0
movq (%rbx), %rax
leaq 0x48(%rsp), %rdi
leaq 0x90(%rsp), %rdx
movq %rbx, %rsi
movq %r15, %rcx
callq *0x168(%rax)
cmpq $0x0, 0x50(%rsp)
je 0x593d3
leaq 0x4488b(%rip), %rdx     # 0x9dc29
leaq 0x3c650(%rip), %r8      # 0x959f5
leaq 0x70(%rsp), %rdi
leaq 0x48(%rsp), %rsi
leaq 0x20(%rsp), %rcx
callq 0x62e67
leaq 0x20(%rsp), %rdi
leaq 0x70(%rsp), %r15
movq %r15, %rsi
callq 0x6320
movq %r15, %rdi
callq 0x6548
movq 0x10(%rsp), %rax
leaq 0x18(%rax), %rsi
leaq 0x38(%rax), %r9
addq $0x58, %rax
leaq 0x40695(%rip), %r10     # 0x99a80
leaq 0x3bc99(%rip), %r11     # 0x9508b
leaq 0x3c430(%rip), %rdx     # 0x95829
leaq 0x44829(%rip), %r8      # 0x9dc29
leaq 0x8(%rsp), %rcx
movq %rbx, %rdi
pushq %r10
pushq %r14
pushq %r11
pushq %rax
callq 0x62ee4
addq $0x20, %rsp
leaq 0x48(%rsp), %rdi
callq 0x6548
leaq 0x20(%rsp), %rdi
callq 0x6548
movq 0x10(%rsp), %rax
movl 0x8(%rax), %esi
movq %rbx, %rdi
callq 0x107cc
leaq 0x90(%rsp), %rdi
callq 0x17a3e
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3ff7c(%rip), %rcx     # 0x993de
movq %rcx, 0x8(%rsp)
movq 0x10(%rsp), %rcx
leaq 0x18(%rcx), %rdx
movq %rdx, 0x40(%rsp)
leaq 0x38(%rcx), %r12
xorl %ecx, %ecx
leaq 0x48(%rsp), %r13
leaq 0x20(%rsp), %rbp
leaq 0x70(%rsp), %r14
movl %ecx, 0x1c(%rsp)
cmpl %eax, %ecx
jae 0x5942c
movq %r13, %rdi
movq %rbx, %rsi
movl 0x18(%rsp), %edx
callq 0x2beca
movq %rbp, %rdi
movq %r13, %rsi
leaq 0x447f6(%rip), %rdx     # 0x9dca4
leaq 0x1c(%rsp), %rcx
leaq 0x3f614(%rip), %r8      # 0x98ace
callq 0x428fa
movq %r13, %rdi
callq 0x6548
movq (%rbx), %rax
movq %r13, %rdi
movq %rbx, %rsi
leaq 0x90(%rsp), %rdx
movq %r15, %rcx
callq *0x168(%rax)
cmpq $0x0, 0x50(%rsp)
je 0x59518
movq %r14, %rdi
movq %r13, %rsi
leaq 0x44733(%rip), %rdx     # 0x9dc29
movq %rbp, %rcx
leaq 0x3c4f5(%rip), %r8      # 0x959f5
callq 0x62e67
movq %rbp, %rdi
movq %r14, %rsi
callq 0x6320
movq %r14, %rdi
callq 0x6548
movq 0x10(%rsp), %rcx
movl 0x60(%rcx), %eax
imull 0x1c(%rsp), %eax
addl 0x58(%rcx), %eax
movl %eax, 0x70(%rsp)
movq %rbx, %rdi
movq 0x40(%rsp), %rsi
leaq 0x3c2ee(%rip), %rdx     # 0x95829
leaq 0x8(%rsp), %rcx
leaq 0x446e2(%rip), %r8      # 0x9dc29
movq %r12, %r9
leaq 0x4052f(%rip), %rax     # 0x99a80
pushq %rax
pushq %rbp
leaq 0x3bb31(%rip), %rax     # 0x9508b
pushq %rax
pushq %r14
callq 0x63144
addq $0x20, %rsp
movq %r13, %rdi
callq 0x6548
movq %rbp, %rdi
callq 0x6548
movl 0x1c(%rsp), %ecx
incl %ecx
movl 0x18(%r15), %eax
jmp 0x5948a
pushq $0x10
popq %rdi
callq 0x6140
movq %rax, %r14
leaq 0x3fdc3(%rip), %rsi     # 0x9935a
leaq 0x20(%rsp), %rdi
leaq 0x48(%rsp), %rdx
callq 0x6100
movb $0x1, %bpl
leaq 0x20(%rsp), %rsi
movq %r14, %rdi
callq 0x6f6e
xorl %ebp, %ebp
leaq 0x8d801(%rip), %rsi     # 0xe6dc0
movq 0x8ea1a(%rip), %rdx     # 0xe7fe0
movq %r14, %rdi
callq 0x6490
jmp 0x59703
pushq $0x10
popq %rdi
callq 0x6140
movq %rax, %r14
leaq 0x3fdaf(%rip), %rsi     # 0x99394
leaq 0x20(%rsp), %rdi
leaq 0x48(%rsp), %rdx
callq 0x6100
movb $0x1, %bpl
leaq 0x20(%rsp), %rsi
movq %r14, %rdi
callq 0x6f6e
xorl %ebp, %ebp
leaq 0x8d7b3(%rip), %rsi     # 0xe6dc0
movq 0x8e9cc(%rip), %rdx     # 0xe7fe0
movq %r14, %rdi
callq 0x6490
jmp 0x59703
pushq $0x10
popq %rdi
callq 0x6140
movq %rax, %r14
leaq 0x3fcc0(%rip), %rsi     # 0x992f3
leaq 0x20(%rsp), %rdi
leaq 0x48(%rsp), %rdx
callq 0x6100
movb $0x1, %bpl
leaq 0x20(%rsp), %rsi
movq %r14, %rdi
callq 0x6f6e
xorl %ebp, %ebp
leaq 0x8d765(%rip), %rsi     # 0xe6dc0
movq 0x8e97e(%rip), %rdx     # 0xe7fe0
movq %r14, %rdi
callq 0x6490
jmp 0x59703
pushq $0x10
popq %rdi
callq 0x6140
movq %rax, %r14
leaq 0x3fcbd(%rip), %rsi     # 0x9933e
leaq 0x20(%rsp), %rdi
leaq 0x48(%rsp), %rdx
callq 0x6100
movb $0x1, %bpl
leaq 0x20(%rsp), %rsi
movq %r14, %rdi
callq 0x6f6e
xorl %ebp, %ebp
leaq 0x8d717(%rip), %rsi     # 0xe6dc0
movq 0x8e930(%rip), %rdx     # 0xe7fe0
movq %r14, %rdi
callq 0x6490
jmp 0x59703
pushq $0x10
popq %rdi
callq 0x6140
movq %rax, %r14
leaq 0x3fc72(%rip), %rsi     # 0x9933e
leaq 0x20(%rsp), %rdi
leaq 0x48(%rsp), %rdx
callq 0x6100
movb $0x1, %bpl
leaq 0x20(%rsp), %rsi
movq %r14, %rdi
callq 0x6f6e
xorl %ebp, %ebp
leaq 0x8d6cc(%rip), %rsi     # 0xe6dc0
movq 0x8e8e5(%rip), %rdx     # 0xe7fe0
movq %r14, %rdi
callq 0x6490
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x6548
testb %bpl, %bpl
je 0x597f1
jmp 0x59792
jmp 0x59776
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x6548
testb %bpl, %bpl
je 0x597f1
jmp 0x59792
jmp 0x59776
jmp 0x597cb
jmp 0x597cb
jmp 0x597da
jmp 0x597c6
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x6548
testb %bpl, %bpl
je 0x597f1
jmp 0x59792
jmp 0x59776
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x6548
testb %bpl, %bpl
je 0x597f1
jmp 0x59792
movq %rax, %rbx
jmp 0x59792
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x6548
testb %bpl, %bpl
jne 0x59792
jmp 0x597f1
movq %rax, %rbx
movq %r14, %rdi
callq 0x6200
jmp 0x597f1
jmp 0x597c6
jmp 0x597cb
jmp 0x597ac
jmp 0x597cb
jmp 0x597c6
jmp 0x597da
jmp 0x597c6
jmp 0x597e4
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x6548
jmp 0x597be
movq %rax, %rbx
jmp 0x597dd
jmp 0x597da
jmp 0x597cb
jmp 0x597da
movq %rax, %rbx
jmp 0x597f1
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x6548
jmp 0x597dd
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
jmp 0x597ec
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x6548
leaq 0x90(%rsp), %rdi
callq 0x17a3e
movq %rbx, %rdi
callq 0x64b0