// File: rossy[P]crossc/SPIRV-Cross/spirv_hlsl.cpp
// Function: spirv_cross::CompilerHLSL::emit_struct_member(spirv_cross::SPIRType const&, unsigned int, unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, unsigned int)
void CompilerHLSL::emit_struct_member(const SPIRType &type, uint32_t member_type_id, uint32_t index,
                                      const string &qualifier, uint32_t base_offset)
{
	auto &membertype = get<SPIRType>(member_type_id);

	Bitset memberflags;
	auto &memb = ir.meta[type.self].members;
	if (index < memb.size())
		memberflags = memb[index].decoration_flags;

	string qualifiers;
	bool is_block = ir.meta[type.self].decoration.decoration_flags.get(DecorationBlock) ||
	                ir.meta[type.self].decoration.decoration_flags.get(DecorationBufferBlock);

	if (is_block)
		qualifiers = to_interpolation_qualifiers(memberflags);

	string packing_offset;
	bool is_push_constant = type.storage == StorageClassPushConstant;

	if ((has_decoration(type.self, DecorationCPacked) || is_push_constant) &&
	    has_member_decoration(type.self, index, DecorationOffset))
	{
		uint32_t offset = memb[index].offset - base_offset;
		if (offset & 3)
			SPIRV_CROSS_THROW("Cannot pack on tighter bounds than 4 bytes in HLSL.");

		static const char *packing_swizzle[] = { "", ".y", ".z", ".w" };
		packing_offset = join(" : packoffset(c", offset / 16, packing_swizzle[(offset & 15) >> 2], ")");
	}

	statement(layout_for_member(type, index), qualifiers, qualifier,
	          variable_decl(membertype, to_member_name(type, index)), packing_offset, ";");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1f0, %rsp            # imm = 0x1F0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
movl %r9d, -0x24(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x1b8(%rbp)
movl -0x14(%rbp), %esi
callq 0xea90
movq %rax, -0x30(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x10710
movq -0x1b8(%rbp), %rdi
addq $0x8, %rdi
addq $0x30, %rdi
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, %esi
callq 0xead0
addq $0xd0, %rax
movq %rax, -0x78(%rbp)
movl -0x18(%rbp), %eax
movq %rax, -0x1b0(%rbp)
movq -0x78(%rbp), %rdi
callq 0x2eca0
movq %rax, %rcx
movq -0x1b0(%rbp), %rax
cmpq %rcx, %rax
jae 0xc2110
movq -0x78(%rbp), %rdi
movl -0x18(%rbp), %eax
movl %eax, %esi
callq 0x2fa30
movq %rax, %rsi
addq $0x60, %rsi
leaq -0x70(%rbp), %rdi
callq 0x38560
jmp 0xc20fa
jmp 0xc2110
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0xc2592
leaq -0xa8(%rbp), %rdi
callq 0x7530
movq -0x1b8(%rbp), %rdi
addq $0x38, %rdi
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, %esi
callq 0xead0
movq %rax, %rdi
addq $0x60, %rdi
movl $0x2, %esi
callq 0xef50
movb %al, -0x1b9(%rbp)
jmp 0xc214e
movb -0x1b9(%rbp), %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, -0x1ba(%rbp)
jne 0xc21a3
jmp 0xc2163
movq -0x1b8(%rbp), %rdi
addq $0x38, %rdi
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, %esi
callq 0xead0
movq %rax, %rdi
addq $0x60, %rdi
movl $0x3, %esi
callq 0xef50
movb %al, -0x1bb(%rbp)
jmp 0xc2195
movb -0x1bb(%rbp), %al
movb %al, -0x1ba(%rbp)
jmp 0xc21a3
movb -0x1ba(%rbp), %al
andb $0x1, %al
movb %al, -0xa9(%rbp)
testb $0x1, -0xa9(%rbp)
je 0xc220f
movq -0x1b8(%rbp), %rsi
movq (%rsi), %rax
movq 0x140(%rax), %rax
leaq -0xd0(%rbp), %rdi
leaq -0x70(%rbp), %rdx
callq *%rax
jmp 0xc21da
leaq -0xa8(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x7430
leaq -0xd0(%rbp), %rdi
callq 0x7708
jmp 0xc220f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0xc2586
leaq -0xf0(%rbp), %rdi
callq 0x7530
movq -0x1b8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x64(%rax), %eax
subl $0x9, %eax
sete -0xf1(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %esi
movl $0xa, %edx
callq 0x1f560
movb %al, -0x1bc(%rbp)
jmp 0xc224c
movb -0x1bc(%rbp), %al
testb $0x1, %al
jne 0xc2265
jmp 0xc2258
testb $0x1, -0xf1(%rbp)
je 0xc2417
movq -0x1b8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x8(%rax), %esi
movl -0x18(%rbp), %edx
movl $0x23, %ecx
callq 0x21f90
movb %al, -0x1bd(%rbp)
jmp 0xc2288
movb -0x1bd(%rbp), %al
testb $0x1, %al
jne 0xc2297
jmp 0xc2417
movq -0x78(%rbp), %rdi
movl -0x18(%rbp), %eax
movl %eax, %esi
callq 0x2fa30
movl 0xb4(%rax), %eax
subl -0x24(%rbp), %eax
movl %eax, -0xf8(%rbp)
movl -0xf8(%rbp), %eax
andl $0x3, %eax
cmpl $0x0, %eax
je 0xc23b0
movb $0x1, -0x11a(%rbp)
movl $0x10, %edi
callq 0x71a0
movq %rax, -0x1d0(%rbp)
leaq -0x119(%rbp), %rdi
movq %rdi, -0x1c8(%rbp)
callq 0x7650
movq -0x1c8(%rbp), %rdx
leaq 0x85b89(%rip), %rsi     # 0x147e88
leaq -0x118(%rbp), %rdi
callq 0x7520
jmp 0xc230d
movq -0x1d0(%rbp), %rdi
leaq -0x118(%rbp), %rsi
callq 0x9c50
jmp 0xc2322
movq -0x1d0(%rbp), %rdi
movb $0x0, -0x11a(%rbp)
leaq 0xebaa1(%rip), %rsi     # 0x1addd8
leaq -0xb86ae(%rip), %rdx    # 0x9c90
callq 0x7610
jmp 0xc25a4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0xc257a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0xc2388
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x118(%rbp), %rdi
callq 0x7708
leaq -0x119(%rbp), %rdi
callq 0x73d0
testb $0x1, -0x11a(%rbp)
jne 0xc239f
jmp 0xc23ab
movq -0x1d0(%rbp), %rdi
callq 0x72c0
jmp 0xc257a
movl -0xf8(%rbp), %eax
shrl $0x4, %eax
movl %eax, -0x144(%rbp)
movl -0xf8(%rbp), %eax
andl $0xc, %eax
movl %eax, %ecx
leaq 0xed17f(%rip), %rax     # 0x1af550
leaq (%rax,%rcx,2), %rcx
leaq 0x85ae0(%rip), %rsi     # 0x147ebc
leaq 0x82b16(%rip), %r8      # 0x144ef9
leaq -0x140(%rbp), %rdi
leaq -0x144(%rbp), %rdx
callq 0xdad50
jmp 0xc23f8
leaq -0xf0(%rbp), %rdi
leaq -0x140(%rbp), %rsi
callq 0x7430
leaq -0x140(%rbp), %rdi
callq 0x7708
movq -0x1b8(%rbp), %rsi
movq -0x10(%rbp), %rdx
movl -0x18(%rbp), %ecx
movq (%rsi), %rax
movq 0x138(%rax), %rax
leaq -0x168(%rbp), %rdi
callq *%rax
jmp 0xc243a
movq -0x1b8(%rbp), %rsi
movq -0x20(%rbp), %rax
movq %rax, -0x1e0(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x1d8(%rbp)
movq -0x10(%rbp), %rdx
movl -0x18(%rbp), %ecx
leaq -0x1a8(%rbp), %rdi
callq 0x62230
jmp 0xc246c
movq -0x1d8(%rbp), %rdx
movq -0x1b8(%rbp), %rsi
movq (%rsi), %rax
movq 0xc8(%rax), %rax
leaq -0x188(%rbp), %rdi
leaq -0x1a8(%rbp), %rcx
xorl %r8d, %r8d
callq *%rax
jmp 0xc2499
movq -0x1e0(%rbp), %rcx
movq -0x1b8(%rbp), %rdi
leaq 0x86bf8(%rip), %rdx     # 0x1490a6
movq %rsp, %rax
movq %rdx, (%rax)
leaq -0x168(%rbp), %rsi
leaq -0xa8(%rbp), %rdx
leaq -0x188(%rbp), %r8
leaq -0xf0(%rbp), %r9
callq 0xdae10
jmp 0xc24d7
leaq -0x188(%rbp), %rdi
callq 0x7708
leaq -0x1a8(%rbp), %rdi
callq 0x7708
leaq -0x168(%rbp), %rdi
callq 0x7708
leaq -0xf0(%rbp), %rdi
callq 0x7708
leaq -0xa8(%rbp), %rdi
callq 0x7708
leaq -0x70(%rbp), %rdi
callq 0xf250
addq $0x1f0, %rsp            # imm = 0x1F0
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0xc256e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0xc2562
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x188(%rbp), %rdi
callq 0x7708
leaq -0x1a8(%rbp), %rdi
callq 0x7708
leaq -0x168(%rbp), %rdi
callq 0x7708
leaq -0xf0(%rbp), %rdi
callq 0x7708
leaq -0xa8(%rbp), %rdi
callq 0x7708
leaq -0x70(%rbp), %rdi
callq 0xf250
movq -0x80(%rbp), %rdi
callq 0x7640
nopw %cs:(%rax,%rax)