// File: /workspace/github_cpp_makefile_star2_O2/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, %rbx
movl 0xc(%rsi), %esi
callq 0x90a4
movq %rax, %r14
leaq 0x8(%rbx), %rsi
leaq 0xc8(%rsp), %rdi
movq %r15, %rdx
callq 0x1fb0a
cmpl $0xc, 0x10(%r15)
jne 0x24f79
movl 0x8(%r14), %edx
jmp 0x24fad
movl 0x8(%r14), %edx
movq 0x38(%rbx), %rax
imulq $0x148, %rdx, %rcx      # imm = 0x148
testb $0x8, 0x60(%rax,%rcx)
jne 0x24fad
leaq 0x6a8f1(%rip), %r13     # 0x8f887
movl $0x0, 0xc(%rsp)
movq %r13, 0x40(%rsp)
movq %r13, %rbp
movq %r13, 0x38(%rsp)
jmp 0x25007
movl 0xc8(%rsp), %eax
btl $0x17, %eax
leaq 0x6a8c8(%rip), %rcx     # 0x8f887
leaq 0x73937(%rip), %rsi     # 0x988fd
cmovaeq %rcx, %rsi
movq %rsi, 0x38(%rsp)
btl $0x13, %eax
leaq 0x6cfff(%rip), %rsi     # 0x91fd9
cmovaeq %rcx, %rsi
movq %rsi, 0x40(%rsp)
btl $0x19, %eax
leaq 0x6cff5(%rip), %rbp     # 0x91fe3
cmovaeq %rcx, %rbp
btl $0x18, %eax
leaq 0x6cff1(%rip), %r13     # 0x91fee
cmovaeq %rcx, %r13
movb $0x1, %al
movl %eax, 0xc(%rsp)
movq (%rbx), %rax
leaq 0x48(%rsp), %rdi
movq %rbx, %rsi
xorl %ecx, %ecx
callq *0x38(%rax)
leaq 0x530(%rbx), %r12
leaq 0x568(%rbx), %rax
cmpb $0x0, 0xc(%rsp)
cmovneq %rax, %r12
movl 0x8(%r14), %eax
movq 0x38(%rbx), %rcx
imulq $0x148, %rax, %rax      # imm = 0x148
cmpq $0x0, 0x8(%rcx,%rax)
je 0x25057
leaq 0x48(%rsp), %rsi
movq %r12, %rdi
callq 0x1be34
testq %rax, %rax
je 0x25082
movl 0x8(%r15), %edx
movq (%rbx), %rax
leaq 0x18(%rsp), %rdi
movq %rbx, %rsi
callq *0x20(%rax)
leaq 0x48(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x6170
leaq 0x18(%rsp), %rdi
callq 0x6548
leaq 0x48(%rsp), %rdx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x25356
cmpq $0x0, 0x50(%rsp)
movq %rbx, 0x10(%rsp)
jne 0x250ef
movq %rbx, %rdi
movq %r14, %rbx
movl 0xc(%r15), %esi
callq 0x90a4
addq $0x8, %rax
leaq 0x8(%r15), %r8
leaq 0x73e8a(%rip), %rcx     # 0x98f47
leaq 0x18(%rsp), %rdi
movq %rcx, %rsi
movq %rax, %rdx
callq 0x41e67
leaq 0x48(%rsp), %rdi
leaq 0x18(%rsp), %r14
movq %r14, %rsi
callq 0x6320
movq %r14, %rdi
callq 0x6548
movq %rbx, %r14
movq 0x10(%rsp), %rbx
leaq 0x488(%rbx), %rdi
leaq 0x48(%rsp), %rsi
callq 0x1bf20
leaq 0x3d8(%rbx), %rdi
leaq 0x8(%r15), %rsi
movq %rsi, 0x68(%rsp)
callq 0x48908
leaq 0x48(%rsp), %r12
movq %rax, %rdi
movq %r12, %rsi
callq 0x6170
leaq 0x18(%rsp), %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x23d8a
leaq 0x70(%rsp), %rdx
movq 0x38(%rsp), %rax
movq %rax, (%rdx)
leaq 0x90(%rsp), %rcx
movq 0x40(%rsp), %rax
movq %rax, (%rcx)
leaq 0xc0(%rsp), %r8
movq %rbp, (%r8)
leaq 0xb8(%rsp), %r9
movq %r13, (%r9)
leaq 0x737ae(%rip), %rax     # 0x9891d
leaq 0x6ce82(%rip), %rsi     # 0x91ff8
cmpb $0x0, 0xc(%rsp)
cmovneq %rax, %rsi
leaq 0xb0(%rsp), %rax
movq %rsi, (%rax)
leaq 0x18(%rsp), %rsi
movq %rbx, %rdi
pushq %r12
pushq %rax
callq 0x41ee4
popq %rax
popq %rcx
leaq 0x18(%rsp), %rdi
callq 0x6548
movq %rbx, %rdi
callq 0x22d28
movq %r14, %rdi
addq $0xa0, %rdi
callq 0xb854
movq 0x68(%r14), %r15
movq 0x70(%r14), %r12
xorl %ebp, %ebp
leaq 0x18(%rsp), %r13
cmpq %r12, %r15
je 0x2522c
movq %rbx, %rdi
movq %r14, %rbx
movq %r14, %rsi
movl %ebp, %edx
callq 0x22d40
movl (%r15), %r14d
movq %r13, %rdi
leaq 0x6a699(%rip), %rsi     # 0x8f887
leaq 0x70(%rsp), %rdx
callq 0x6100
movq 0x10(%rsp), %rdi
movq (%rdi), %rax
movq %rbx, %rsi
movl %r14d, %edx
movl %ebp, %ecx
movq %r13, %r8
xorl %r9d, %r9d
callq *0xa8(%rax)
movq %r13, %rdi
callq 0x6548
incl %ebp
addq $0x4, %r15
movq %rbx, %r14
movq 0x10(%rsp), %rbx
jmp 0x251cc
movq 0x68(%rsp), %r15
movl (%r15), %esi
movq %rbx, %rdi
callq 0x22d1a
movl (%r15), %edx
movq (%rbx), %rax
leaq 0x70(%rsp), %rdi
pushq $0x1
popq %rcx
movq %rbx, %rsi
callq *0x38(%rax)
leaq 0x90(%rsp), %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x2547c
leaq 0x18(%rsp), %rdi
leaq 0x70(%rsp), %rsi
leaq 0x90(%rsp), %rdx
callq 0x1743e
leaq 0x18(%rsp), %rsi
movq %rbx, %rdi
callq 0x253d4
leaq 0x18(%rsp), %rdi
callq 0x6548
leaq 0x90(%rsp), %rdi
callq 0x6548
leaq 0x70(%rsp), %rdi
callq 0x6548
leaq 0x6a5d8(%rip), %rsi     # 0x8f887
movq %rbx, %rdi
callq 0x928e
leaq 0x48(%rsp), %rdi
callq 0x6548
leaq 0xd0(%rsp), %rdi
callq 0xb51c
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x25324
jmp 0x25324
jmp 0x25329
jmp 0x25324
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x6548
jmp 0x252fa
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x6548
jmp 0x2530c
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
jmp 0x25331
jmp 0x25324
jmp 0x25329
jmp 0x25324
movq %rax, %rbx
jmp 0x25340
jmp 0x25324
jmp 0x25324
jmp 0x25324
movq %rax, %rbx
jmp 0x25336
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x6548
leaq 0x48(%rsp), %rdi
callq 0x6548
leaq 0xd0(%rsp), %rdi
callq 0xb51c
movq %rbx, %rdi
callq 0x64b0
nop