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

	Bitset flags = ir.get_buffer_block_flags(var);
	bool ssbo = var.storage == StorageClassStorageBuffer ||
	            ir.meta[type.self].decoration.decoration_flags.get(DecorationBufferBlock);
	bool is_restrict = ssbo && flags.get(DecorationRestrict);
	bool is_writeonly = ssbo && flags.get(DecorationNonReadable);
	bool is_readonly = ssbo && flags.get(DecorationNonWritable);
	bool is_coherent = ssbo && flags.get(DecorationCoherent);

	// Block names should never alias, but from HLSL input they kind of can because block types are reused for UAVs ...
	auto buffer_name = to_name(type.self, false);

	auto &block_namespace = ssbo ? block_ssbo_names : block_ubo_names;

	// Shaders never use the block by interface name, so we don't
	// have to track this other than updating name caches.
	if (ir.meta[type.self].decoration.alias.empty() || block_namespace.find(buffer_name) != end(block_namespace))
		buffer_name = get_block_fallback_name(var.self);

	// Make sure we get something unique.
	add_variable(block_namespace, 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);

	// Instance names cannot alias block names.
	resource_names.insert(buffer_name);

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

	statement(layout_for_variable(var), is_coherent ? "coherent " : "", is_restrict ? "restrict " : "",
	          is_writeonly ? "writeonly " : "", is_readonly ? "readonly " : "", ssbo ? "buffer " : "uniform ",
	          buffer_name);

	begin_scope();

	type.member_name_cache.clear();

	uint32_t i = 0;
	for (auto &member : type.member_types)
	{
		add_member_name(type, i);
		emit_struct_member(type, member, i);
		i++;
	}

	add_resource_name(var.self);
	end_scope_decl(to_name(var.self) + type_to_array_glsl(type));
	statement("");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %rsi, %r15
movq %rdi, %r14
movl 0xc(%rsi), %esi
callq 0xa3ea
movq %rax, %rbx
leaq 0x8(%r14), %rsi
leaq 0xc8(%rsp), %rdi
movq %r15, %rdx
callq 0x2460e
cmpl $0xc, 0x10(%r15)
jne 0x2ae52
movl 0x8(%rbx), %edx
jmp 0x2ae85
movl 0x8(%rbx), %edx
movq 0x38(%r14), %rax
imulq $0x148, %rdx, %rcx      # imm = 0x148
testb $0x8, 0x60(%rax,%rcx)
jne 0x2ae85
leaq 0x89a41(%rip), %r13     # 0xb48af
movl $0x0, 0x28(%rsp)
movq %r13, 0x30(%rsp)
movq %r13, %rbp
movq %r13, 0x40(%rsp)
jmp 0x2aedf
movl 0xc8(%rsp), %eax
btl $0x17, %eax
leaq 0x89a18(%rip), %rcx     # 0xb48af
leaq 0x92acf(%rip), %rsi     # 0xbd96d
cmovaeq %rcx, %rsi
movq %rsi, 0x40(%rsp)
btl $0x13, %eax
leaq 0x8c147(%rip), %rsi     # 0xb6ff9
cmovaeq %rcx, %rsi
movq %rsi, 0x30(%rsp)
btl $0x19, %eax
leaq 0x8c13d(%rip), %rbp     # 0xb7003
cmovaeq %rcx, %rbp
btl $0x18, %eax
leaq 0x8c139(%rip), %r13     # 0xb700e
cmovaeq %rcx, %r13
movb $0x1, %al
movl %eax, 0x28(%rsp)
movq (%r14), %rax
leaq 0x48(%rsp), %rdi
movq %r14, %rsi
xorl %ecx, %ecx
callq *0x38(%rax)
leaq 0x530(%r14), %r12
leaq 0x568(%r14), %rax
cmpb $0x0, 0x28(%rsp)
cmovneq %rax, %r12
movl 0x8(%rbx), %eax
movq 0x38(%r14), %rcx
imulq $0x148, %rax, %rax      # imm = 0x148
cmpq $0x0, 0x8(%rcx,%rax)
je 0x2af2e
leaq 0x48(%rsp), %rsi
movq %r12, %rdi
callq 0x20790
testq %rax, %rax
je 0x2af6a
movl 0x8(%r15), %edx
movq (%r14), %rax
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
callq *0x20(%rax)
leaq 0x48(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x6170
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2af6a
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6260
movq %rbx, 0x38(%rsp)
leaq 0x48(%rsp), %rdx
movq %r14, %rdi
movq %r12, %rsi
callq 0x2b3ee
cmpq $0x0, 0x50(%rsp)
jne 0x2afdf
movl 0xc(%r15), %esi
movq %r14, %rdi
callq 0xa3ea
addq $0x8, %rax
leaq 0x8(%r15), %r8
leaq 0x93015(%rip), %rcx     # 0xbdfb7
leaq 0x8(%rsp), %rdi
movq %rcx, %rsi
movq %rax, %rdx
callq 0x51b54
leaq 0x48(%rsp), %rdi
leaq 0x8(%rsp), %r12
movq %r12, %rsi
callq 0x6310
movq (%r12), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x2afdf
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6260
leaq 0x488(%r14), %rbx
leaq 0x8(%rsp), %rdx
movq %rbx, (%rdx)
leaq 0x48(%rsp), %rsi
movq %rbx, %rdi
callq 0x208a8
leaq 0x3d8(%r14), %rdi
leaq 0x8(%r15), %rsi
movq %rsi, 0xa8(%rsp)
callq 0x5ada8
leaq 0x48(%rsp), %r12
movq %rax, %rdi
movq %r12, %rsi
callq 0x6170
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x295fe
leaq 0x88(%rsp), %rdx
movq 0x40(%rsp), %rax
movq %rax, (%rdx)
leaq 0x68(%rsp), %rcx
movq 0x30(%rsp), %rax
movq %rax, (%rcx)
leaq 0xc0(%rsp), %r8
movq %rbp, (%r8)
leaq 0xb8(%rsp), %r9
movq %r13, (%r9)
leaq 0x92920(%rip), %rax     # 0xbd98d
leaq 0x8bfa4(%rip), %rsi     # 0xb7018
cmpb $0x0, 0x28(%rsp)
cmovneq %rax, %rsi
leaq 0xb0(%rsp), %rax
movq %rsi, (%rax)
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
pushq %r12
pushq %rax
callq 0x51bf2
addq $0x10, %rsp
leaq 0x18(%rsp), %r13
movq -0x10(%r13), %rdi
cmpq %r13, %rdi
je 0x2b0b7
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6260
leaq 0x8fb19(%rip), %rsi     # 0xbabd7
movq %r14, %rdi
callq 0x59e02
movq %rbx, 0x30(%rsp)
movq %r14, %rbx
incl 0x638(%r14)
movq 0x38(%rsp), %r15
movq %r15, %rdi
addq $0xa0, %rdi
callq 0xd940
movq 0x68(%r15), %r14
movq 0x70(%r15), %rax
movq %rax, 0x28(%rsp)
cmpq %rax, %r14
je 0x2b171
xorl %ebp, %ebp
leaq 0x8(%rsp), %r12
movq %r13, %r15
movq %rbx, %rdi
movq 0x38(%rsp), %rsi
movl %ebp, %edx
callq 0x281f0
movl (%r14), %r13d
movq %r15, 0x8(%rsp)
movq %r12, %rdi
leaq 0x89789(%rip), %rdx     # 0xb48af
movq %rdx, %rsi
callq 0x7be0
movq %rbx, %rdi
movq (%rbx), %rax
movq 0x38(%rsp), %rsi
movl %r13d, %edx
movl %ebp, %ecx
movq %r12, %r8
xorl %r9d, %r9d
callq *0xa8(%rax)
movq 0x8(%rsp), %rdi
movq %r15, %r13
cmpq %r15, %rdi
je 0x2b164
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6260
incl %ebp
addq $0x4, %r14
cmpq 0x28(%rsp), %r14
jne 0x2b102
movq 0xa8(%rsp), %r14
movl (%r14), %eax
imulq $0x148, %rax, %rdx      # imm = 0x148
addq 0x38(%rbx), %rdx
movq %rbx, %rdi
movq 0x30(%rsp), %rsi
callq 0x2b3ee
movl (%r14), %edx
movq (%rbx), %rax
leaq 0x88(%rsp), %rdi
movq %rbx, %rsi
movl $0x1, %ecx
callq *0x38(%rax)
leaq 0x68(%rsp), %rdi
movq %rbx, %rsi
movq 0x38(%rsp), %rdx
callq 0x2b55a
leaq 0x98(%rsp), %r14
movq -0x10(%r14), %rcx
movq -0x8(%r14), %r8
movq 0x70(%rsp), %rdx
leaq (%rdx,%r8), %rax
movl $0xf, %edi
cmpq %r14, %rcx
je 0x2b1ea
movq 0x98(%rsp), %rdi
movq 0x68(%rsp), %rsi
cmpq %rdi, %rax
jbe 0x2b20d
leaq 0x78(%rsp), %r9
movl $0xf, %edi
cmpq %r9, %rsi
je 0x2b208
movq 0x78(%rsp), %rdi
cmpq %rdi, %rax
jbe 0x2b21c
leaq 0x88(%rsp), %rdi
callq 0x60b0
jmp 0x2b22a
leaq 0x68(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x62c0
movq %r13, 0x8(%rsp)
movq (%rax), %rdx
leaq 0x10(%rax), %rcx
cmpq %rcx, %rdx
je 0x2b24a
movq %rdx, 0x8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
jmp 0x2b252
movups (%rcx), %xmm0
movups %xmm0, (%r13)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, 0x10(%rsp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x2b486
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x2b293
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6260
leaq 0x78(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2b2ae
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0x88(%rsp), %rdi
cmpq %r14, %rdi
je 0x2b2cb
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x6260
leaq 0x895dd(%rip), %rsi     # 0xb48af
movq %rbx, %rdi
callq 0xa6c4
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2b2f5
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x6260
leaq 0xd0(%rsp), %rdi
callq 0xd570
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2b39e
jmp 0x2b39e
jmp 0x2b37e
jmp 0x2b39e
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x2b341
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x2b341
movq %rax, %rbx
leaq 0x78(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2b361
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x2b361
movq %rax, %rbx
leaq 0x98(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2b3a1
movq 0x98(%rsp), %rsi
jmp 0x2b3e3
jmp 0x2b39e
movq %rax, %rbx
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x2b3de
jmp 0x2b3a1
jmp 0x2b39e
movq %rax, %rbx
jmp 0x2b3bc
jmp 0x2b39e
jmp 0x2b39e
jmp 0x2b39e
movq %rax, %rbx
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2b3bc
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x6260
leaq 0xd0(%rsp), %rdi
callq 0xd570
movq %rbx, %rdi
callq 0x64a0
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x2b3a1
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x2b3a1
nop