// File: /workspace/github_cpp_makefile_star2_O1/rossy[P]crossc/SPIRV-Cross/spirv_msl.cpp
// Function: spirv_cross::CompilerMSL::align_struct(spirv_cross::SPIRType&)
void CompilerMSL::align_struct(SPIRType &ib_type)
{
	uint32_t &ib_type_id = ib_type.self;

	// Sort the members of the interface structure by their offset.
	// They should already be sorted per SPIR-V spec anyway.
	MemberSorter member_sorter(ib_type, ir.meta[ib_type_id], MemberSorter::Offset);
	member_sorter.sort();

	uint32_t curr_offset;
	uint32_t mbr_cnt = uint32_t(ib_type.member_types.size());

	// Test the alignment of each member, and if a member should be closer to the previous
	// member than the default spacing expects, it is likely that the previous member is in
	// a packed format. If so, and the previous member is packable, pack it.
	// For example...this applies to any 3-element vector that is followed by a scalar.
	curr_offset = 0;
	for (uint32_t mbr_idx = 0; mbr_idx < mbr_cnt; mbr_idx++)
	{
		if (is_member_packable(ib_type, mbr_idx))
			set_member_decoration(ib_type_id, mbr_idx, DecorationCPacked);

		// Align current offset to the current member's default alignment.
		size_t align_mask = get_declared_struct_member_alignment(ib_type, mbr_idx) - 1;
		curr_offset = uint32_t((curr_offset + align_mask) & ~align_mask);

		// Fetch the member offset as declared in the SPIRV.
		uint32_t mbr_offset = get_member_decoration(ib_type_id, mbr_idx, DecorationOffset);
		if (mbr_offset > curr_offset)
		{
			// Since MSL and SPIR-V have slightly different struct member alignment and
			// size rules, we'll pad to standard C-packing rules. If the member is farther
			// away than C-packing, expects, add an inert padding member before the the member.
			MSLStructMemberKey key = get_struct_member_key(ib_type_id, mbr_idx);
			struct_member_padding[key] = mbr_offset - curr_offset;
		}

		// Increment the current offset to be positioned immediately after the current member.
		curr_offset = mbr_offset + uint32_t(get_declared_struct_member_size(ib_type, mbr_idx));
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movl 0x8(%rsi), %eax
imulq $0x148, %rax, %rdx      # imm = 0x148
addq 0x38(%rdi), %rdx
leaq 0x20(%rsp), %r15
movq %r15, %rdi
movl $0x2, %ecx
callq 0xa1806
movq %r15, %rdi
callq 0x8fd72
movq 0x70(%rbx), %rax
subq 0x68(%rbx), %rax
shrq $0x2, %rax
testl %eax, %eax
je 0x900d6
leaq 0x848(%r14), %rcx
movq %rcx, 0x8(%rsp)
movl %eax, %eax
movq %rax, 0x10(%rsp)
xorl %r12d, %r12d
xorl %ebp, %ebp
movq %r14, %rdi
movq %rbx, %rsi
movl %r12d, %edx
callq 0x900e6
testb %al, %al
je 0x9005e
movl 0x8(%rbx), %esi
movq %r14, %rdi
movl %r12d, %edx
movl $0xa, %ecx
xorl %r8d, %r8d
callq 0x14cd6
movq %r14, %rdi
movq %rbx, %rsi
movl %r12d, %edx
callq 0x90254
movq %rax, %r13
addl %ebp, %eax
decl %eax
negl %r13d
andl %eax, %r13d
movl 0x8(%rbx), %esi
movq %r14, %rdi
movl %r12d, %edx
movl $0x23, %ecx
callq 0x14e6c
movl %eax, %ebp
movl %eax, %r15d
subl %r13d, %r15d
jbe 0x900b7
movl 0x8(%rbx), %eax
shlq $0x20, %rax
addq %r12, %rax
movq %rax, 0x18(%rsp)
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0xaa576
movl %r15d, (%rax)
movq (%r14), %rax
movq %r14, %rdi
movq %rbx, %rsi
movl %r12d, %edx
callq *0x30(%rax)
addl %eax, %ebp
incq %r12
cmpq %r12, 0x10(%rsp)
jne 0x90036
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop