// File: /workspace/github_cpp_makefile_star2_O3/rossy[P]crossc/SPIRV-Cross/spirv_glsl.cpp
// Function: spirv_cross::CompilerGLSL::type_to_packed_size(spirv_cross::SPIRType const&, spirv_cross::Bitset const&, spirv_cross::BufferPackingStandard)
uint32_t CompilerGLSL::type_to_packed_size(const SPIRType &type, const Bitset &flags, BufferPackingStandard packing)
{
	if (!type.array.empty())
	{
		return to_array_size_literal(type, uint32_t(type.array.size()) - 1) *
		       type_to_packed_array_stride(type, flags, packing);
	}

	uint32_t size = 0;

	if (type.basetype == SPIRType::Struct)
	{
		uint32_t pad_alignment = 1;

		for (uint32_t i = 0; i < type.member_types.size(); i++)
		{
			auto member_flags = ir.meta[type.self].members.at(i).decoration_flags;
			auto &member_type = get<SPIRType>(type.member_types[i]);

			uint32_t packed_alignment = type_to_packed_alignment(member_type, member_flags, packing);
			uint32_t alignment = max(packed_alignment, pad_alignment);

			// The next member following a struct member is aligned to the base alignment of the struct that came before.
			// GL 4.5 spec, 7.6.2.2.
			if (member_type.basetype == SPIRType::Struct)
				pad_alignment = packed_alignment;
			else
				pad_alignment = 1;

			size = (size + alignment - 1) & ~(alignment - 1);
			size += type_to_packed_size(member_type, member_flags, packing);
		}
	}
	else
	{
		const uint32_t base_alignment = type_to_packed_base_size(type, packing);

		if (type.columns == 1)
			size = type.vecsize * base_alignment;

		if (flags.get(DecorationColMajor) && type.columns > 1)
		{
			if (packing_is_vec4_padded(packing))
				size = type.columns * 4 * base_alignment;
			else if (type.vecsize == 3)
				size = type.columns * 4 * base_alignment;
			else
				size = type.columns * type.vecsize * base_alignment;
		}

		if (flags.get(DecorationRowMajor) && type.vecsize > 1)
		{
			if (packing_is_vec4_padded(packing))
				size = type.vecsize * 4 * base_alignment;
			else if (type.columns == 3)
				size = type.vecsize * 4 * base_alignment;
			else
				size = type.vecsize * type.columns * base_alignment;
		}
	}

	return size;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl %ecx, %r15d
movq %rdx, %r12
movq %rsi, %r14
movq %rdi, %rbx
movq 0x20(%rsi), %rax
movq 0x28(%rsi), %rdx
cmpq %rdx, %rax
je 0x29043
subq %rax, %rdx
shrq $0x2, %rdx
decl %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x292aa
movl %eax, %ebp
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
movl %r15d, %ecx
callq 0x28f48
movl %eax, %r13d
imull %ebp, %r13d
movl %r13d, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0xc, 0xc(%r14)
jne 0x291c7
movq 0x70(%r14), %rax
cmpq 0x68(%r14), %rax
je 0x2924b
movl %r15d, (%rsp)
movl $0x1, %r15d
xorl %ebp, %ebp
xorl %ecx, %ecx
movl $0x1, %r12d
movq %r14, 0x10(%rsp)
movq %rbx, 0x8(%rsp)
movq %rcx, 0x18(%rsp)
movl %r15d, 0x4(%rsp)
movl 0x8(%r14), %eax
movq 0x38(%rbx), %rcx
imulq $0x148, %rax, %rdx      # imm = 0x148
movq 0xd0(%rcx,%rdx), %rax
movq 0xd8(%rcx,%rdx), %rdx
subq %rax, %rdx
sarq $0x4, %rdx
movabsq $0x4ec4ec4ec4ec4ec5, %rcx # imm = 0x4EC4EC4EC4EC4EC5
imulq %rcx, %rdx
cmpq %rbp, %rdx
jbe 0x2927f
imulq $0xd0, %rbp, %rcx
leaq (%rax,%rcx), %rsi
addq $0x68, %rsi
movq -0x8(%rsi), %rax
movq %rax, 0x28(%rsp)
xorl %ecx, %ecx
movq %rcx, 0x30(%rsp)
movq 0x8(%rsi), %rax
movq %rax, 0x38(%rsp)
movq %rcx, 0x40(%rsp)
movq 0x18(%rsi), %rax
movq %rax, 0x48(%rsp)
movups 0x20(%rsi), %xmm0
leaq 0x30(%rsp), %rdi
movups %xmm0, 0x20(%rdi)
movq %rcx, 0x60(%rsp)
movq %rdi, 0x20(%rsp)
leaq 0x20(%rsp), %rdx
callq 0xd3c2
movq 0x68(%r14), %rax
movl (%rax,%rbp,4), %esi
movq %rbx, %rdi
callq 0xa3ea
movl (%rsp), %r15d
movq %rax, %r13
movq %rbx, %rdi
movq %rax, %rsi
leaq 0x28(%rsp), %rdx
movl %r15d, %ecx
callq 0x28c1a
movl %eax, %ebp
movl 0xc(%r13), %r14d
movq %rbx, %rdi
movq %r13, %rsi
leaq 0x28(%rsp), %rdx
movl %r15d, %ecx
callq 0x28fdc
movl 0x4(%rsp), %r15d
movl %eax, %r13d
cmpl $0xc, %r14d
movl $0x1, %r14d
cmovel %ebp, %r14d
cmpl %r12d, %ebp
cmoval %ebp, %r12d
movq 0x18(%rsp), %rax
addl %r12d, %eax
decl %eax
negl %r12d
andl %eax, %r12d
addl %r12d, %r13d
leaq 0x30(%rsp), %rdi
callq 0xd570
movl %r15d, %ebp
movq 0x10(%rsp), %rbx
movq 0x70(%rbx), %rax
subq 0x68(%rbx), %rax
sarq $0x2, %rax
incl %r15d
movl %r13d, %ecx
movl %r14d, %r12d
cmpq %rbp, %rax
movq %rbx, %r14
movq 0x8(%rsp), %rbx
ja 0x2907a
jmp 0x29031
movq %r14, %rsi
callq 0x28b4c
movl 0x14(%r14), %esi
movl 0x18(%r14), %edx
movl %esi, %ecx
imull %eax, %ecx
xorl %r13d, %r13d
cmpl $0x1, %edx
cmovel %ecx, %r13d
movq (%r12), %rdi
movl %edi, %r8d
shrb $0x5, %r8b
cmpl $0x2, %edx
setae %r9b
andb %r8b, %r9b
cmpb $0x1, %r9b
jne 0x2921c
cmpl $0x5, %r15d
ja 0x29253
movl $0x35, %r8d
btl %r15d, %r8d
jae 0x29253
imull %edx, %eax
shll $0x2, %eax
movl %eax, %r13d
shrb $0x4, %dil
cmpl $0x2, %esi
setae %al
testb %al, %dil
je 0x29031
cmpl $0x5, %r15d
ja 0x2926c
movl $0x35, %eax
btl %r15d, %eax
jae 0x2926c
shll $0x2, %ecx
movl %ecx, %r13d
jmp 0x29031
xorl %r13d, %r13d
jmp 0x29031
cmpl $0x3, %esi
jne 0x29276
testb $0x10, %dil
jne 0x2922f
imull %eax, %edx
shll $0x2, %edx
movl %edx, %r13d
jmp 0x29031
cmpl $0x3, %edx
je 0x29240
imull %edx, %ecx
jmp 0x29243
movl %ecx, %r13d
imull %edx, %r13d
jmp 0x2921c
leaq 0x8ae93(%rip), %rdi     # 0xb4119
movq %rbp, %rsi
xorl %eax, %eax
callq 0x63d0
jmp 0x29294
jmp 0x29294
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0xd570
movq %rbx, %rdi
callq 0x64a0
nop