// File: /workspace/github_cpp_makefile_star2_O1/rossy[P]crossc/SPIRV-Cross/spirv_hlsl.cpp
// Function: spirv_cross::CompilerHLSL::emit_buffer_block(spirv_cross::SPIRVariable const&)
void CompilerHLSL::emit_buffer_block(const SPIRVariable &var)
{
	auto &type = get<SPIRType>(var.basetype);

	bool is_uav = var.storage == StorageClassStorageBuffer || has_decoration(type.self, DecorationBufferBlock);

	if (is_uav)
	{
		Bitset flags = ir.get_buffer_block_flags(var);
		bool is_readonly = flags.get(DecorationNonWritable);
		bool is_coherent = flags.get(DecorationCoherent);
		add_resource_name(var.self);
		statement(is_coherent ? "globallycoherent " : "", is_readonly ? "ByteAddressBuffer " : "RWByteAddressBuffer ",
		          to_name(var.self), type_to_array_glsl(type), to_resource_binding(var), ";");
	}
	else
	{
		if (type.array.empty())
		{
			if (buffer_is_packing_standard(type, BufferPackingHLSLCbufferPackOffset))
				set_decoration(type.self, DecorationCPacked);
			else
				SPIRV_CROSS_THROW("cbuffer cannot be expressed with either HLSL packing layout or packoffset.");

			// Flatten the top-level struct so we can use packoffset,
			// this restriction is similar to GLSL where layout(offset) is not possible on sub-structs.
			flattened_structs.insert(var.self);

			// Prefer the block name if possible.
			auto buffer_name = to_name(type.self, false);
			if (ir.meta[type.self].decoration.alias.empty() || resource_names.find(buffer_name) != end(resource_names))
				buffer_name = get_block_fallback_name(var.self);
			add_variable(resource_names, buffer_name);

			// If for some reason buffer_name is an illegal name, make a final fallback to a workaround name.
			// This cannot conflict with anything else, so we're safe now.
			if (buffer_name.empty())
				buffer_name = join("_", get<SPIRType>(var.basetype).self, "_", var.self);

			resource_names.insert(buffer_name);

			// Save for post-reflection later.
			declared_block_names[var.self] = buffer_name;

			type.member_name_cache.clear();
			add_resource_name(var.self);
			statement("cbuffer ", buffer_name, to_resource_binding(var));
			begin_scope();

			uint32_t i = 0;
			for (auto &member : type.member_types)
			{
				add_member_name(type, i);
				auto backup_name = get_member_name(type.self, i);
				auto member_name = to_member_name(type, i);
				set_member_name(type.self, i, sanitize_underscores(join(to_name(var.self), "_", member_name)));
				emit_struct_member(type, member, i, "");
				set_member_name(type.self, i, backup_name);
				i++;
			}

			end_scope_decl();
			statement("");
		}
		else
		{
			if (hlsl_options.shader_model < 51)
				SPIRV_CROSS_THROW(
				    "Need ConstantBuffer<T> to use arrays of UBOs, but this is only supported in SM 5.1.");

			// ConstantBuffer<T> does not support packoffset, so it is unuseable unless everything aligns as we expect.
			if (!buffer_is_packing_standard(type, BufferPackingHLSLCbuffer))
				SPIRV_CROSS_THROW("HLSL ConstantBuffer<T> cannot be expressed with normal HLSL packing rules.");

			add_resource_name(type.self);
			add_resource_name(var.self);

			emit_struct(get<SPIRType>(type.self));
			statement("ConstantBuffer<", to_name(type.self), "> ", to_name(var.self), type_to_array_glsl(type),
			          to_resource_binding(var), ";");
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movq %rsi, %r12
movq %rdi, %rbx
movl 0xc(%rsi), %esi
callq 0xa426
movq %rax, %r14
cmpl $0xc, 0x10(%r12)
je 0x6833d
movl 0x8(%r14), %esi
movq %rbx, %rdi
movl $0x3, %edx
callq 0x1299a
testb %al, %al
je 0x68479
leaq 0x8(%rbx), %rsi
leaq 0x70(%rsp), %r15
movq %r15, %rdi
movq %r12, %rdx
callq 0x24ca0
movq (%r15), %r15
movl 0x8(%r12), %esi
movq %rbx, %rdi
callq 0x287ea
btl $0x17, %r15d
leaq 0x4d542(%rip), %rax     # 0xb58af
leaq 0x565e9(%rip), %rcx     # 0xbe95d
cmovaeq %rax, %rcx
btl $0x18, %r15d
leaq 0x565eb(%rip), %rax     # 0xbe96f
leaq 0x565e6(%rip), %rdx     # 0xbe971
cmovaeq %rax, %rdx
movq %rcx, 0xd0(%rsp)
movq %rdx, 0xb0(%rsp)
movl 0x8(%r12), %edx
movq (%rbx), %rax
movq %rsp, %rdi
movq %rbx, %rsi
movl $0x1, %ecx
callq *0x38(%rax)
leaq 0x50(%rsp), %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x2bb66
leaq 0x20(%rsp), %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x68da2
subq $0x8, %rsp
leaq 0x57709(%rip), %rax     # 0xbfae9
leaq 0xd8(%rsp), %rsi
leaq 0xb8(%rsp), %rdx
leaq 0x8(%rsp), %rcx
leaq 0x58(%rsp), %r8
leaq 0x28(%rsp), %r9
movq %rbx, %rdi
pushq %rax
callq 0x796ea
addq $0x10, %rsp
leaq 0x30(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x68427
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x6260
leaq 0x60(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x68442
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x6260
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6845d
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x6260
leaq 0x78(%rsp), %rdi
callq 0xd5b0
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x20(%r14), %rax
cmpq 0x28(%r14), %rax
je 0x685bf
cmpl $0x32, 0x788(%rbx)
jbe 0x689d1
movq %rbx, %rdi
movq %r14, %rsi
movl $0x4, %edx
xorl %ecx, %ecx
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
callq 0x29938
testb %al, %al
je 0x68a3d
movl 0x8(%r14), %esi
movq %rbx, %rdi
callq 0x287ea
movl 0x8(%r12), %esi
movq %rbx, %rdi
callq 0x287ea
movl 0x8(%r14), %esi
movq %rbx, %rdi
callq 0xa426
movq %rbx, %rdi
movq %rax, %rsi
callq 0x285ee
movl 0x8(%r14), %edx
movq (%rbx), %rax
leaq 0x70(%rsp), %rdi
movq %rbx, %rsi
movl $0x1, %ecx
callq *0x38(%rax)
movl 0x8(%r12), %edx
movq (%rbx), %rax
movq %rsp, %rdi
movq %rbx, %rsi
movl $0x1, %ecx
callq *0x38(%rax)
leaq 0x50(%rsp), %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x2bb66
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x68da2
leaq 0x575ae(%rip), %rax     # 0xbfae9
leaq 0x564ea(%rip), %rsi     # 0xbea2c
leaq 0x4cc9c(%rip), %rcx     # 0xb51e5
leaq 0x70(%rsp), %rdx
movq %rsp, %r8
leaq 0x50(%rsp), %r9
movq %rbx, %rdi
pushq %rax
pushq %r14
callq 0x799b4
addq $0x10, %rsp
leaq 0x30(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x68580
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x6260
leaq 0x60(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6859b
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x6260
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x689a7
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x689a7
movq %rbx, %rdi
movq %r14, %rsi
movl $0x5, %edx
xorl %ecx, %ecx
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
callq 0x29938
testb %al, %al
je 0x68aa6
movl 0x8(%r14), %esi
movq %rbx, %rdi
movl $0xa, %edx
xorl %ecx, %ecx
callq 0x14ea4
leaq 0x6b0(%rbx), %rdi
leaq 0x8(%r12), %rsi
leaq 0x70(%rsp), %rdx
movq %rdi, (%rdx)
movq %rsi, 0x40(%rsp)
callq 0x1fc02
movl 0x8(%r14), %edx
movq (%rbx), %rax
leaq 0x70(%rsp), %rdi
movq %rbx, %rsi
xorl %ecx, %ecx
callq *0x38(%rax)
movl 0x8(%r14), %eax
movq 0x38(%rbx), %rcx
imulq $0x148, %rax, %rax      # imm = 0x148
cmpq $0x0, 0x8(%rcx,%rax)
je 0x68651
leaq 0x488(%rbx), %rdi
leaq 0x70(%rsp), %rsi
callq 0x20e88
testq %rax, %rax
je 0x6868c
movq 0x40(%rsp), %rax
movl (%rax), %edx
movq (%rbx), %rax
movq %rsp, %rdi
movq %rbx, %rsi
callq *0x20(%rax)
leaq 0x70(%rsp), %rdi
movq %rsp, %rsi
callq 0x6170
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6868c
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x6260
leaq 0x488(%rbx), %r15
leaq 0x70(%rsp), %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2b9f6
cmpq $0x0, 0x78(%rsp)
movq %r14, 0x48(%rsp)
jne 0x6870b
movl 0xc(%r12), %esi
movq %rbx, %rdi
callq 0xa426
addq $0x8, %rax
leaq 0x568e7(%rip), %rcx     # 0xbefaf
movq %rsp, %rdi
movq %rcx, %rsi
movq %rax, %rdx
movq 0x40(%rsp), %r8
callq 0x5234c
leaq 0x70(%rsp), %rdi
movq %rsp, %r13
movq %r13, %rsi
callq 0x6310
movq (%r13), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x68706
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0x48(%rsp), %r14
movq %rsp, %rdx
movq %r15, (%rdx)
leaq 0x70(%rsp), %rsi
movq %r15, %rdi
callq 0x20fa0
leaq 0x3d8(%rbx), %rdi
movq 0x40(%rsp), %rsi
callq 0x5b5a2
leaq 0x70(%rsp), %rsi
movq %rax, %rdi
callq 0x6170
movq %r14, %rdi
addq $0xa0, %rdi
callq 0xd978
movq 0x40(%rsp), %rax
movl (%rax), %esi
movq %rbx, %rdi
callq 0x287ea
movq %rsp, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x68da2
leaq 0x56215(%rip), %rsi     # 0xbe984
leaq 0x70(%rsp), %rdx
movq %rsp, %rcx
movq %rbx, %rdi
callq 0x79862
leaq 0x10(%rsp), %r12
movq -0x10(%r12), %rdi
cmpq %r12, %rdi
je 0x6879b
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x6260
movq %rbx, %rdi
callq 0x28804
movq 0x68(%r14), %r15
movq 0x70(%r14), %rax
movq %rax, 0xf0(%rsp)
cmpq %rax, %r15
je 0x68990
xorl %ebp, %ebp
movq %rbx, %rdi
movq %r14, %rsi
movl %ebp, %edx
callq 0x2881c
movl 0x8(%r14), %esi
movq %rbx, %rdi
movl %ebp, %edx
callq 0x14cea
movq %r12, (%rsp)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
movq %rsp, %rdi
callq 0xe480
leaq 0x50(%rsp), %rdi
movq %rbx, %rsi
movq 0x48(%rsp), %r14
movq %r14, %rdx
movl %ebp, %ecx
callq 0x2c69c
movl 0x8(%r14), %r12d
movq 0x40(%rsp), %rax
movl (%rax), %edx
movq (%rbx), %rax
leaq 0xb0(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
movl $0x1, %ecx
callq *0x38(%rax)
leaq 0xd0(%rsp), %r13
movq %r13, %rdi
movq %r14, %rsi
leaq 0x56770(%rip), %rdx     # 0xbefaf
leaq 0x50(%rsp), %rcx
callq 0x52708
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movq %r13, %rsi
callq 0x26038
movq %rbx, %rdi
movl %r12d, %esi
movl %ebp, %edx
movq %r14, %rcx
callq 0x14ce0
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x68885
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0xd0(%rsp), %rdi
leaq 0xe0(%rsp), %rax
cmpq %rax, %rdi
je 0x688aa
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0xb0(%rsp), %rdi
leaq 0xc0(%rsp), %rax
cmpq %rax, %rdi
je 0x688cf
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x6260
movl (%r15), %r12d
leaq 0x30(%rsp), %rax
movq %rax, 0x20(%rsp)
leaq 0x20(%rsp), %r14
movq %r14, %rdi
leaq 0x4cfc4(%rip), %rdx     # 0xb58af
movq %rdx, %rsi
callq 0x7c64
movq (%rbx), %rax
movq %rbx, %rdi
movq 0x48(%rsp), %rsi
movl %r12d, %edx
movl %ebp, %ecx
movq %r14, %r8
xorl %r9d, %r9d
callq *0xa8(%rax)
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
leaq 0x10(%rsp), %r12
je 0x68930
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0x48(%rsp), %rax
movl 0x8(%rax), %esi
movq %rbx, %rdi
movl %ebp, %edx
movq %rsp, %rcx
callq 0x14ce0
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x68961
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x6260
movq (%rsp), %rdi
cmpq %r12, %rdi
movq 0x48(%rsp), %r14
je 0x6897c
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x6260
addq $0x4, %r15
incl %ebp
cmpq 0xf0(%rsp), %r15
jne 0x687be
movq %rbx, %rdi
callq 0x2889c
leaq 0x4cf10(%rip), %rsi     # 0xb58af
movq %rbx, %rdi
callq 0xa700
leaq 0x80(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x68467
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x68467
movl $0x10, %edi
callq 0x6140
movq %rax, %r14
leaq 0x80(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x55f9c(%rip), %rsi     # 0xbe98d
leaq 0x55fe8(%rip), %rdx     # 0xbe9e0
leaq 0x70(%rsp), %rdi
callq 0x7c64
movb $0x1, %bpl
leaq 0x70(%rsp), %rsi
movq %r14, %rdi
callq 0x6320
leaq 0x9437f(%rip), %rax     # 0xfcd98
addq $0x10, %rax
movq %rax, (%r14)
xorl %ebp, %ebp
leaq 0x94357(%rip), %rsi     # 0xfcd80
movq 0x955a8(%rip), %rdx     # 0xfdfd8
movq %r14, %rdi
callq 0x6470
jmp 0x68b0d
movl $0x10, %edi
callq 0x6140
movq %rax, %r14
leaq 0x80(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x55f84(%rip), %rsi     # 0xbe9e1
leaq 0x55fc7(%rip), %rdx     # 0xbea2b
leaq 0x70(%rsp), %rdi
callq 0x7c64
movb $0x1, %bpl
leaq 0x70(%rsp), %rsi
movq %r14, %rdi
callq 0x6320
leaq 0x94313(%rip), %rax     # 0xfcd98
addq $0x10, %rax
movq %rax, (%r14)
xorl %ebp, %ebp
leaq 0x942eb(%rip), %rsi     # 0xfcd80
movq 0x9553c(%rip), %rdx     # 0xfdfd8
movq %r14, %rdi
callq 0x6470
jmp 0x68b0d
movl $0x10, %edi
callq 0x6140
movq %rax, %r14
leaq 0x80(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x55f84(%rip), %rsi     # 0xbea4a
leaq 0x55fc7(%rip), %rdx     # 0xbea94
leaq 0x70(%rsp), %rdi
callq 0x7c64
movb $0x1, %bpl
leaq 0x70(%rsp), %rsi
movq %r14, %rdi
callq 0x6320
leaq 0x942aa(%rip), %rax     # 0xfcd98
addq $0x10, %rax
movq %rax, (%r14)
xorl %ebp, %ebp
leaq 0x94282(%rip), %rsi     # 0xfcd80
movq 0x954d3(%rip), %rdx     # 0xfdfd8
movq %r14, %rdi
callq 0x6470
movq %rax, %rbx
movq 0x70(%rsp), %rdi
cmpq %r15, %rdi
je 0x68b32
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x68b32
movq %rax, %rbx
movb $0x1, %bpl
testb %bpl, %bpl
je 0x68d99
jmp 0x68baf
jmp 0x68d75
jmp 0x68d75
jmp 0x68c03
jmp 0x68d75
movq %rax, %rbx
movq 0x70(%rsp), %rdi
cmpq %r15, %rdi
je 0x68b76
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x68b76
movq %rax, %rbx
movb $0x1, %bpl
testb %bpl, %bpl
je 0x68d99
jmp 0x68baf
movq %rax, %rbx
movq 0x70(%rsp), %rdi
cmpq %r15, %rdi
je 0x68ba6
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x68ba6
movq %rax, %rbx
movb $0x1, %bpl
testb %bpl, %bpl
je 0x68d99
movq %r14, %rdi
callq 0x6200
jmp 0x68d99
jmp 0x68c03
jmp 0x68d75
movq %rax, %rbx
leaq 0x30(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x68be6
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x68be6
movq %rax, %rbx
leaq 0x60(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x68c06
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x68c06
movq %rax, %rbx
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
jmp 0x68d61
jmp 0x68d75
jmp 0x68d75
jmp 0x68d75
movq %rax, %rbx
leaq 0x30(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x68c46
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x68c46
movq %rax, %rbx
leaq 0x60(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x68c66
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x68c66
movq %rax, %rbx
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x68c88
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x68c88
jmp 0x68c85
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0xd5b0
jmp 0x68d99
jmp 0x68d75
movq %rax, %rbx
jmp 0x68d58
jmp 0x68d39
movq %rax, %rbx
jmp 0x68cf7
movq %rax, %rbx
jmp 0x68cd2
movq %rax, %rbx
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x68cd2
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0xd0(%rsp), %rdi
leaq 0xe0(%rsp), %rax
cmpq %rax, %rdi
je 0x68cf7
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0xb0(%rsp), %rdi
leaq 0xc0(%rsp), %rax
cmpq %rax, %rdi
je 0x68d3c
movq 0xc0(%rsp), %rsi
jmp 0x68d2f
jmp 0x68d39
movq %rax, %rbx
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x68d3c
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x68d3c
movq %rax, %rbx
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x68d58
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x6260
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x68d78
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x68d78
movq %rax, %rbx
leaq 0x80(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x68d99
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x6260
movq %rbx, %rdi
callq 0x64a0
nop