// File: /workspace/github_cpp_makefile_star2_O2/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
pushq $0x2
popq %rcx
movq %r15, %rdi
callq 0x7db24
movq %r15, %rdi
callq 0x7393e
movq 0x70(%rbx), %rax
subq 0x68(%rbx), %rax
shrq $0x2, %rax
leaq 0x848(%r14), %rcx
movq %rcx, 0x8(%rsp)
movl %eax, %eax
movq %rax, 0x10(%rsp)
xorl %r12d, %r12d
xorl %ebp, %ebp
cmpq %r12, 0x10(%rsp)
je 0x73b71
movq %r14, %rdi
movq %rbx, %rsi
movl %r12d, %edx
callq 0x73b80
testb %al, %al
je 0x73b01
movl 0x8(%rbx), %esi
movq %r14, %rdi
movl %r12d, %edx
pushq $0xa
popq %rcx
xorl %r8d, %r8d
callq 0x11ece
movq %r14, %rdi
movq %rbx, %rsi
movl %r12d, %edx
callq 0x73cde
movq %rax, %r15
addl %ebp, %eax
decl %eax
negl %r15d
andl %eax, %r15d
movl 0x8(%rbx), %esi
movq %r14, %rdi
movl %r12d, %edx
pushq $0x23
popq %rcx
callq 0x12036
movl %eax, %ebp
movl %eax, %r13d
subl %r15d, %r13d
jbe 0x73b58
movl 0x8(%rbx), %eax
shlq $0x20, %rax
addq %r12, %rax
movq %rax, 0x18(%rsp)
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x85208
movl %r13d, (%rax)
movq (%r14), %rax
movq %r14, %rdi
movq %rbx, %rsi
movl %r12d, %edx
callq *0x30(%rax)
addl %eax, %ebp
incq %r12
jmp 0x73ad0
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq