// File: rossy[P]crossc/SPIRV-Cross/spirv_glsl.cpp
// Function: spirv_cross::CompilerGLSL::emit_struct(spirv_cross::SPIRType&)
void CompilerGLSL::emit_struct(SPIRType &type)
{
	// Struct types can be stamped out multiple times
	// with just different offsets, matrix layouts, etc ...
	// Type-punning with these types is legal, which complicates things
	// when we are storing struct and array types in an SSBO for example.
	// If the type master is packed however, we can no longer assume that the struct declaration will be redundant.
	if (type.type_alias != 0 && !has_decoration(type.type_alias, DecorationCPacked))
		return;

	add_resource_name(type.self);
	auto name = type_to_glsl(type);

	statement(!backend.explicit_struct_type ? "struct " : "", name);
	begin_scope();

	type.member_name_cache.clear();

	uint32_t i = 0;
	bool emitted = false;
	for (auto &member : type.member_types)
	{
		add_member_name(type, i);
		emit_struct_member(type, member, i);
		i++;
		emitted = true;
	}

	// Don't declare empty structs in GLSL, this is not allowed.
	if (type_is_empty(type) && !backend.supports_empty_struct)
	{
		statement("int empty_struct_member;");
		emitted = true;
	}

	end_scope_decl();

	if (emitted)
		statement("");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x98(%rax)
je 0x5bf4f
movq -0xa0(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x98(%rax), %esi
movl $0xa, %edx
callq 0x1f560
testb $0x1, %al
jne 0x5bf4f
jmp 0x5c1b3
movq -0xa0(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x8(%rax), %esi
callq 0x5c1d0
movq -0xa0(%rbp), %rsi
movq -0x10(%rbp), %rdx
movq (%rsi), %rax
movq 0x98(%rax), %rax
leaq -0x30(%rbp), %rdi
movq %rdi, -0xa8(%rbp)
xorl %ecx, %ecx
callq *%rax
movq -0xa0(%rbp), %rdi
movq -0xa8(%rbp), %rdx
movb 0x623(%rdi), %sil
leaq 0xe28fc(%rip), %rcx     # 0x13e89e
leaq 0xe4f92(%rip), %rax     # 0x140f3b
testb $0x1, %sil
cmovneq %rcx, %rax
movq %rax, -0x38(%rbp)
leaq -0x38(%rbp), %rsi
callq 0x9f4f0
jmp 0x5bfc0
movq -0xa0(%rbp), %rdi
callq 0x5c200
jmp 0x5bfce
movq -0x10(%rbp), %rdi
addq $0xa0, %rdi
callq 0x9e1e0
movl $0x0, -0x48(%rbp)
movb $0x0, -0x49(%rbp)
movq -0x10(%rbp), %rax
addq $0x68, %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rdi
callq 0x86d0
movq %rax, -0x60(%rbp)
movq -0x58(%rbp), %rdi
callq 0x8700
movq %rax, -0x68(%rbp)
leaq -0x60(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x8730
testb $0x1, %al
jne 0x5c025
jmp 0x5c140
leaq -0x60(%rbp), %rdi
callq 0x8770
movq -0xa0(%rbp), %rdi
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rsi
movl -0x48(%rbp), %edx
callq 0x5c240
jmp 0x5c047
movq -0x10(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0x70(%rbp), %rax
movl (%rax), %eax
movl %eax, -0xb8(%rbp)
movl -0x48(%rbp), %eax
movl %eax, -0xb4(%rbp)
leaq -0x91(%rbp), %rdi
movq %rdi, -0xb0(%rbp)
callq 0x7650
movq -0xb0(%rbp), %rdx
leaq 0xe2816(%rip), %rsi     # 0x13e89e
leaq -0x90(%rbp), %rdi
callq 0x7520
jmp 0x5c096
movl -0xb4(%rbp), %ecx
movl -0xb8(%rbp), %edx
movq -0xc0(%rbp), %rsi
movq -0xa0(%rbp), %rdi
movq (%rdi), %rax
movq 0xa8(%rax), %rax
leaq -0x90(%rbp), %r8
xorl %r9d, %r9d
callq *%rax
jmp 0x5c0c8
leaq -0x90(%rbp), %rdi
callq 0x7708
leaq -0x91(%rbp), %rdi
callq 0x73d0
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
movb $0x1, -0x49(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x8790
jmp 0x5c00f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x5c1bc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x5c132
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x7708
leaq -0x91(%rbp), %rdi
callq 0x73d0
jmp 0x5c1bc
movq -0xa0(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x5bec0
testb $0x1, %al
jne 0x5c156
jmp 0x5c17f
movq -0xa0(%rbp), %rax
testb $0x1, 0x631(%rax)
jne 0x5c17f
movq -0xa0(%rbp), %rdi
leaq 0xe4dcf(%rip), %rsi     # 0x140f43
callq 0x9f030
jmp 0x5c17b
movb $0x1, -0x49(%rbp)
movq -0xa0(%rbp), %rdi
callq 0x5c350
jmp 0x5c18d
testb $0x1, -0x49(%rbp)
je 0x5c1aa
movq -0xa0(%rbp), %rdi
leaq 0xe26fd(%rip), %rsi     # 0x13e89e
callq 0xedf0
jmp 0x5c1a8
jmp 0x5c1aa
leaq -0x30(%rbp), %rdi
callq 0x7708
addq $0xc0, %rsp
popq %rbp
retq
leaq -0x30(%rbp), %rdi
callq 0x7708
movq -0x40(%rbp), %rdi
callq 0x7640
nop