// File: /workspace/github_cpp_makefile_star2_O3/rossy[P]crossc/SPIRV-Cross/spirv_hlsl.cpp
// Function: spirv_cross::CompilerHLSL::emit_push_constant_block(spirv_cross::SPIRVariable const&)
void CompilerHLSL::emit_push_constant_block(const SPIRVariable &var)
{
	if (root_constants_layout.empty())
	{
		emit_buffer_block(var);
	}
	else
	{
		for (const auto &layout : root_constants_layout)
		{
			auto &type = get<SPIRType>(var.basetype);

			if (buffer_is_packing_standard(type, BufferPackingHLSLCbufferPackOffset, layout.start, layout.end))
				set_decoration(type.self, DecorationCPacked);
			else
				SPIRV_CROSS_THROW(
				    "root constant cbuffer cannot be expressed with either HLSL packing layout or packoffset.");

			flattened_structs.insert(var.self);
			type.member_name_cache.clear();
			add_resource_name(var.self);
			auto &memb = ir.meta[type.self].members;

			statement("cbuffer SPIRV_CROSS_RootConstant_", to_name(var.self),
			          to_resource_register('b', layout.binding, layout.space));
			begin_scope();

			// Index of the next field in the generated root constant constant buffer
			auto constant_index = 0u;

			// Iterate over all member of the push constant and check which of the fields
			// fit into the given root constant layout.
			for (auto i = 0u; i < memb.size(); i++)
			{
				const auto offset = memb[i].offset;
				if (layout.start <= offset && offset < layout.end)
				{
					const auto &member = type.member_types[i];

					add_member_name(type, constant_index);
					auto backup_name = get_member_name(type.self, i);
					auto member_name = to_member_name(type, i);
					set_member_name(type.self, constant_index,
					                sanitize_underscores(join(to_name(var.self), "_", member_name)));
					emit_struct_member(type, member, i, "", layout.start);
					set_member_name(type.self, constant_index, backup_name);

					constant_index++;
				}
			}

			end_scope_decl();
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movq %rdi, %r14
movq 0x7d0(%rdi), %rbx
movq 0x7d8(%rdi), %rax
movq %rax, 0x90(%rsp)
cmpq %rax, %rbx
je 0x68a55
leaq 0x6b0(%r14), %rax
movq %rax, 0x88(%rsp)
leaq 0x8(%rsi), %rax
movq %rax, 0x70(%rsp)
leaq 0x8(%rsp), %r12
movq %rsi, 0x80(%rsp)
movl 0xc(%rsi), %esi
movq %r14, %rdi
callq 0xa3ea
movq %rax, %r15
movl (%rbx), %ecx
movl 0x4(%rbx), %r8d
movq %r14, %rdi
movq %rax, %rsi
movl $0x5, %edx
callq 0x29318
testb %al, %al
je 0x68a75
movq %rbx, %rbp
movl 0x8(%r15), %esi
movq %r14, %rdi
movl $0xa, %edx
xorl %ecx, %ecx
callq 0x14d16
movq 0x88(%rsp), %rdi
movq %rdi, 0x8(%rsp)
movq 0x70(%rsp), %r13
movq %r13, %rsi
movq %r12, %rdx
callq 0x1f510
movq %r15, %rdi
addq $0xa0, %rdi
callq 0xd940
movl (%r13), %esi
movq %r14, %rdi
callq 0x281be
movq %r15, 0x28(%rsp)
movl 0x8(%r15), %ebx
movq 0x38(%r14), %r15
movl (%r13), %edx
movq (%r14), %rax
movq %r12, %rdi
movq %r14, %rsi
movl $0x1, %ecx
callq *0x38(%rax)
movl 0x8(%rbp), %ecx
movq %rbp, 0x78(%rsp)
movl 0xc(%rbp), %r8d
leaq 0x50(%rsp), %r13
movq %r13, %rdi
movq %r14, %rsi
movl $0x62, %edx
callq 0x68bf6
movq %r14, %rdi
leaq 0x55342(%rip), %rsi     # 0xbda9d
movq %r12, %rdx
movq %r13, %rcx
callq 0x78fe4
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x68782
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x6879e
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6260
imulq $0x148, %rbx, %rax      # imm = 0x148
leaq (%r15,%rax), %rbx
addq $0xd0, %rbx
movq %r14, %rdi
callq 0x281d8
movq (%rbx), %rax
movq %rbx, 0x98(%rsp)
movq 0x8(%rbx), %rcx
cmpq %rax, %rcx
movq 0x78(%rsp), %rbx
leaq 0x8(%rsp), %r12
je 0x68a21
xorl %ebp, %ebp
xorl %r13d, %r13d
imulq $0xd0, %rbp, %rdx
movl 0xb4(%rax,%rdx), %edx
cmpl %edx, (%rbx)
ja 0x689fe
cmpl 0x4(%rbx), %edx
jae 0x689fe
movq 0x28(%rsp), %r15
movq 0x68(%r15), %rbx
movq %r14, %rdi
movq %r15, %rsi
movl %r13d, %edx
callq 0x281f0
movl 0x8(%r15), %esi
movq %r14, %rdi
movl %ebp, %edx
callq 0x14b5c
leaq 0x18(%rsp), %rcx
movq %rcx, 0x8(%rsp)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0xe456
leaq 0x50(%rsp), %rdi
movq %r14, %rsi
movq %r15, %rdx
movl %ebp, %ecx
callq 0x2c088
movq %rbx, 0xa0(%rsp)
movq %r14, %rsi
movl %r13d, %r14d
movl 0x8(%r15), %r12d
movq 0x70(%rsp), %rax
movl (%rax), %edx
movq (%rsi), %rax
leaq 0xa8(%rsp), %r13
movq %r13, %rdi
movq %rsi, %rbx
movl $0x1, %ecx
callq *0x38(%rax)
leaq 0xc8(%rsp), %r15
movq %r15, %rdi
movq %r13, %rsi
leaq 0x5571f(%rip), %rdx     # 0xbdfb7
leaq 0x50(%rsp), %rcx
callq 0x51f10
leaq 0x30(%rsp), %r13
movq %r13, %rdi
movq %r15, %rsi
callq 0x25974
movq %rbx, %rdi
movl %r12d, %esi
movl %r14d, %edx
movq %r13, %rcx
callq 0x14b52
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x688df
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0xc8(%rsp), %rdi
leaq 0xd8(%rsp), %rax
cmpq %rax, %rdi
movl %r14d, %r13d
je 0x68907
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
movq %rbx, %r14
je 0x6892f
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0xa0(%rsp), %rax
movl (%rax,%rbp,4), %r12d
leaq 0x40(%rsp), %rax
movq %rax, 0x30(%rsp)
leaq 0x30(%rsp), %r15
movq %r15, %rdi
leaq 0x4bf5b(%rip), %rdx     # 0xb48af
movq %rdx, %rsi
callq 0x7be0
movq 0x78(%rsp), %rbx
movl (%rbx), %r9d
movq (%r14), %rax
movq %r14, %rdi
movq 0x28(%rsp), %rsi
movl %r12d, %edx
movl %ebp, %ecx
movq %r15, %r8
callq *0xa8(%rax)
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x68999
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0x28(%rsp), %rax
movl 0x8(%rax), %esi
movq %r14, %rdi
movl %r13d, %edx
leaq 0x8(%rsp), %r12
movq %r12, %rcx
callq 0x14b52
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x689d0
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x689ec
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6260
incl %r13d
movq 0x98(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
incl %ebp
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x4, %rdx
movabsq $0x4ec4ec4ec4ec4ec5, %rsi # imm = 0x4EC4EC4EC4EC4EC5
imulq %rsi, %rdx
cmpq %rbp, %rdx
ja 0x687df
movq %r14, %rdi
callq 0x28270
addq $0x10, %rbx
cmpq 0x90(%rsp), %rbx
movq 0x80(%rsp), %rsi
jne 0x68694
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%r14), %rax
movq 0xe8(%rax), %rax
movq %r14, %rdi
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmpq *%rax
movl $0x10, %edi
callq 0x6140
movq %rax, %r14
leaq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
movq %rax, (%rdi)
leaq 0x54fae(%rip), %rsi     # 0xbda44
leaq 0x54fff(%rip), %rdx     # 0xbda9c
callq 0x7be0
movb $0x1, %bpl
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x6320
leaq 0x9330f(%rip), %rax     # 0xfbdc8
addq $0x10, %rax
movq %rax, (%r14)
xorl %ebp, %ebp
leaq 0x932e7(%rip), %rsi     # 0xfbdb0
movq 0x94508(%rip), %rdx     # 0xfcfd8
movq %r14, %rdi
callq 0x6470
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x68af7
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6260
testb %bpl, %bpl
jne 0x68b04
jmp 0x68bee
movq %rax, %rbx
movq %r14, %rdi
callq 0x6200
jmp 0x68bee
jmp 0x68b5b
jmp 0x68bb3
movq %rax, %rbx
jmp 0x68b88
movq %rax, %rbx
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x68bb6
movq 0x40(%rsp), %rsi
jmp 0x68ba5
movq %rax, %rbx
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x68b63
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x68b63
movq %rax, %rbx
jmp 0x68bd2
movq %rax, %rbx
movq 0xc8(%rsp), %rdi
leaq 0xd8(%rsp), %rax
cmpq %rax, %rdi
je 0x68b88
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x68bb6
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x68bb6
jmp 0x68bb3
jmp 0x68bb3
movq %rax, %rbx
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x68bd2
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x68bee
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6260
movq %rbx, %rdi
callq 0x64a0