// File: rossy[P]crossc/SPIRV-Cross/spirv_msl.cpp
// Function: spirv_cross::CompilerMSL::get_declared_struct_member_size(spirv_cross::SPIRType const&, unsigned int) const
size_t CompilerMSL::get_declared_struct_member_size(const SPIRType &struct_type, uint32_t index) const
{
	auto &type = get<SPIRType>(struct_type.member_types[index]);

	switch (type.basetype)
	{
	case SPIRType::Unknown:
	case SPIRType::Void:
	case SPIRType::AtomicCounter:
	case SPIRType::Image:
	case SPIRType::SampledImage:
	case SPIRType::Sampler:
		SPIRV_CROSS_THROW("Querying size of opaque object.");

	default:
	{
		// For arrays, we can use ArrayStride to get an easy check.
		// Runtime arrays will have zero size so force to min of one.
		if (!type.array.empty())
		{
			bool array_size_literal = type.array_size_literal.back();
			uint32_t array_size =
			    array_size_literal ? type.array.back() : get<SPIRConstant>(type.array.back()).scalar();
			return type_struct_member_array_stride(struct_type, index) * max(array_size, 1u);
		}

		if (type.basetype == SPIRType::Struct)
			return get_declared_struct_size(type);

		uint32_t component_size = type.width / 8;
		uint32_t vecsize = type.vecsize;
		uint32_t columns = type.columns;

		// An unpacked 3-element vector or matrix column is the same memory size as a 4-element.
		if (vecsize == 3 && !has_member_decoration(struct_type.self, index, DecorationCPacked))
			vecsize = 4;

		return component_size * vecsize * columns;
	}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x18(%rbp), %rdi
addq $0x68, %rdi
movl -0x1c(%rbp), %eax
movl %eax, %esi
callq 0x8570
movq -0x80(%rbp), %rdi
movl (%rax), %esi
callq 0x2e6b0
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x78(%rbp)
subl $0x2, %eax
jb 0x10d98b
jmp 0x10d970
movl -0x78(%rbp), %eax
subl $0x8, %eax
je 0x10d98b
jmp 0x10d97a
movl -0x78(%rbp), %eax
addl $-0xd, %eax
subl $0x2, %eax
ja 0x10da43
jmp 0x10d98b
movb $0x1, -0x5d(%rbp)
movl $0x10, %edi
callq 0x71a0
movq %rax, -0x90(%rbp)
leaq -0x49(%rbp), %rdi
movq %rdi, -0x88(%rbp)
callq 0x7650
movq -0x88(%rbp), %rdx
leaq 0x40105(%rip), %rsi     # 0x14dac3
leaq -0x48(%rbp), %rdi
callq 0x7520
jmp 0x10d9c9
movq -0x90(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x9c50
jmp 0x10d9db
movq -0x90(%rbp), %rdi
movb $0x0, -0x5d(%rbp)
leaq 0xa03eb(%rip), %rsi     # 0x1addd8
leaq -0x103d64(%rip), %rdx   # 0x9c90
callq 0x7610
jmp 0x10db86
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x10da21
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x7708
leaq -0x49(%rbp), %rdi
callq 0x73d0
testb $0x1, -0x5d(%rbp)
jne 0x10da32
jmp 0x10da3e
movq -0x90(%rbp), %rdi
callq 0x72c0
jmp 0x10db7d
movq -0x28(%rbp), %rdi
addq $0x20, %rdi
callq 0x8690
testb $0x1, %al
jne 0x10daf8
movq -0x28(%rbp), %rdi
addq $0x38, %rdi
callq 0x2fe70
andb $0x1, %al
movb %al, -0x5e(%rbp)
testb $0x1, -0x5e(%rbp)
je 0x10da87
movq -0x28(%rbp), %rdi
addq $0x20, %rdi
callq 0x2fe30
movl (%rax), %eax
movl %eax, -0x94(%rbp)
jmp 0x10dab1
movq -0x28(%rbp), %rdi
addq $0x20, %rdi
callq 0x2fe30
movq -0x80(%rbp), %rdi
movl (%rax), %esi
callq 0x2e950
movq %rax, %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x2f560
movl %eax, -0x94(%rbp)
movq -0x80(%rbp), %rdi
movl -0x94(%rbp), %eax
movl %eax, -0x64(%rbp)
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
callq 0x24170
movl %eax, -0x98(%rbp)
movl $0x1, -0x68(%rbp)
leaq -0x64(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x9f7e0
movq %rax, %rcx
movl -0x98(%rbp), %eax
imull (%rcx), %eax
movl %eax, %eax
movq %rax, -0x8(%rbp)
jmp 0x10db70
movq -0x28(%rbp), %rax
cmpl $0xc, 0xc(%rax)
jne 0x10db15
movq -0x80(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x243b0
movq %rax, -0x8(%rbp)
jmp 0x10db70
movq -0x28(%rbp), %rax
movl 0x10(%rax), %eax
shrl $0x3, %eax
movl %eax, -0x6c(%rbp)
movq -0x28(%rbp), %rax
movl 0x14(%rax), %eax
movl %eax, -0x70(%rbp)
movq -0x28(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, -0x74(%rbp)
cmpl $0x3, -0x70(%rbp)
jne 0x10db5f
movq -0x80(%rbp), %rdi
movq -0x18(%rbp), %rax
movl 0x8(%rax), %esi
movl -0x1c(%rbp), %edx
movl $0xa, %ecx
callq 0x21f90
testb $0x1, %al
jne 0x10db5f
movl $0x4, -0x70(%rbp)
movl -0x6c(%rbp), %eax
imull -0x70(%rbp), %eax
imull -0x74(%rbp), %eax
movl %eax, %eax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xa0, %rsp
popq %rbp
retq
movq -0x58(%rbp), %rdi
callq 0x7640
nopw %cs:(%rax,%rax)