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

	// Block names should never alias.
	auto buffer_name = to_name(type.self, false);
	size_t buffer_size = (get_declared_struct_size(type) + 15) / 16;

	SPIRType::BaseType basic_type;
	if (get_common_basic_type(type, basic_type))
	{
		SPIRType tmp;
		tmp.basetype = basic_type;
		tmp.vecsize = 4;
		if (basic_type != SPIRType::Float && basic_type != SPIRType::Int && basic_type != SPIRType::UInt)
			SPIRV_CROSS_THROW("Basic types in a flattened UBO must be float, int or uint.");

		auto flags = ir.get_buffer_block_flags(var);
		statement("uniform ", flags_to_precision_qualifiers_glsl(tmp, flags), type_to_glsl(tmp), " ", buffer_name, "[",
		          buffer_size, "];");
	}
	else
		SPIRV_CROSS_THROW("All basic types in a flattened block must be the same.");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x240, %rsp            # imm = 0x240
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x1f0(%rbp)
movq -0x10(%rbp), %rax
movl 0xc(%rax), %esi
callq 0xea90
movq -0x1f0(%rbp), %rsi
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movl 0x8(%rax), %edx
movq (%rsi), %rax
movq 0x38(%rax), %rax
leaq -0x38(%rbp), %rdi
xorl %ecx, %ecx
callq *%rax
movq -0x1f0(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x243b0
movq %rax, -0x1e8(%rbp)
jmp 0x60244
movq -0x1f0(%rbp), %rdi
movq -0x1e8(%rbp), %rax
addq $0xf, %rax
shrq $0x4, %rax
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rsi
leaq -0x50(%rbp), %rdx
callq 0x2a730
movb %al, -0x1f1(%rbp)
jmp 0x60273
movb -0x1f1(%rbp), %al
testb $0x1, %al
jne 0x60282
jmp 0x604db
leaq -0x128(%rbp), %rdi
callq 0x31440
movl -0x50(%rbp), %eax
movl %eax, -0x11c(%rbp)
movl $0x4, -0x114(%rbp)
cmpl $0xa, -0x50(%rbp)
je 0x603a0
cmpl $0x4, -0x50(%rbp)
je 0x603a0
cmpl $0x5, -0x50(%rbp)
je 0x603a0
movb $0x1, -0x14a(%rbp)
movl $0x10, %edi
callq 0x71a0
movq %rax, -0x208(%rbp)
leaq -0x149(%rbp), %rdi
movq %rdi, -0x200(%rbp)
callq 0x7650
movq -0x200(%rbp), %rdx
leaq 0xe120d(%rip), %rsi     # 0x141505
leaq -0x148(%rbp), %rdi
callq 0x7520
jmp 0x60306
movq -0x208(%rbp), %rdi
leaq -0x148(%rbp), %rsi
callq 0x9c50
jmp 0x6031b
movq -0x208(%rbp), %rdi
movb $0x0, -0x14a(%rbp)
leaq 0x14daa8(%rip), %rsi    # 0x1addd8
leaq -0x566a7(%rip), %rdx    # 0x9c90
callq 0x7610
jmp 0x605c9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x605b7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x60378
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x148(%rbp), %rdi
callq 0x7708
leaq -0x149(%rbp), %rdi
callq 0x73d0
testb $0x1, -0x14a(%rbp)
jne 0x6038f
jmp 0x6039b
movq -0x208(%rbp), %rdi
callq 0x72c0
jmp 0x604ca
movq -0x1f0(%rbp), %rsi
addq $0x8, %rsi
movq -0x10(%rbp), %rdx
leaq -0x190(%rbp), %rdi
callq 0x54c20
jmp 0x603bd
movq -0x1f0(%rbp), %rdi
leaq -0x128(%rbp), %rsi
leaq -0x190(%rbp), %rdx
callq 0x61830
movq %rax, -0x210(%rbp)
jmp 0x603e0
movq -0x1f0(%rbp), %rsi
movq -0x210(%rbp), %rax
movq %rax, -0x198(%rbp)
movq (%rsi), %rax
movq 0x98(%rax), %rax
leaq -0x1b8(%rbp), %rdi
leaq -0x128(%rbp), %rdx
xorl %ecx, %ecx
callq *%rax
jmp 0x60413
movq -0x1f0(%rbp), %rdi
leaq 0xe6c28(%rip), %rcx     # 0x147049
movq %rsp, %rax
movq %rcx, 0x10(%rax)
leaq -0x40(%rbp), %rcx
movq %rcx, 0x8(%rax)
leaq 0xecf71(%rip), %rcx     # 0x14d3a8
movq %rcx, (%rax)
leaq 0xe10bb(%rip), %rsi     # 0x1414fc
leaq 0xde455(%rip), %r8      # 0x13e89d
leaq -0x198(%rbp), %rdx
leaq -0x1b8(%rbp), %rcx
leaq -0x38(%rbp), %r9
callq 0x9fd90
jmp 0x60461
leaq -0x1b8(%rbp), %rdi
callq 0x7708
leaq -0x190(%rbp), %rdi
callq 0xf250
leaq -0x128(%rbp), %rdi
callq 0x314e0
jmp 0x605a5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x604ca
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x604be
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x1b8(%rbp), %rdi
callq 0x7708
leaq -0x190(%rbp), %rdi
callq 0xf250
leaq -0x128(%rbp), %rdi
callq 0x314e0
jmp 0x605b7
movb $0x1, -0x1da(%rbp)
movl $0x10, %edi
callq 0x71a0
movq %rax, -0x220(%rbp)
leaq -0x1d9(%rbp), %rdi
movq %rdi, -0x218(%rbp)
callq 0x7650
movq -0x218(%rbp), %rdx
leaq 0xe102c(%rip), %rsi     # 0x141540
leaq -0x1d8(%rbp), %rdi
callq 0x7520
jmp 0x60522
movq -0x220(%rbp), %rdi
leaq -0x1d8(%rbp), %rsi
callq 0x9c50
jmp 0x60537
movq -0x220(%rbp), %rdi
movb $0x0, -0x1da(%rbp)
leaq 0x14d88c(%rip), %rsi    # 0x1addd8
leaq -0x568c3(%rip), %rdx    # 0x9c90
callq 0x7610
jmp 0x605c9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x60580
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x1d8(%rbp), %rdi
callq 0x7708
leaq -0x1d9(%rbp), %rdi
callq 0x73d0
testb $0x1, -0x1da(%rbp)
jne 0x60597
jmp 0x605a3
movq -0x220(%rbp), %rdi
callq 0x72c0
jmp 0x605b7
leaq -0x38(%rbp), %rdi
callq 0x7708
addq $0x240, %rsp            # imm = 0x240
popq %rbp
retq
leaq -0x38(%rbp), %rdi
callq 0x7708
movq -0x48(%rbp), %rdi
callq 0x7640
nopl (%rax)