// File: /workspace/github_cpp_makefile_star2_O1/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 0x69334
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 0xa426
movq %rax, %r15
movl (%rbx), %ecx
movl 0x4(%rbx), %r8d
movq %r14, %rdi
movq %rax, %rsi
movl $0x5, %edx
callq 0x29938
testb %al, %al
je 0x69354
movq %rbx, %rbp
movl 0x8(%r15), %esi
movq %r14, %rdi
movl $0xa, %edx
xorl %ecx, %ecx
callq 0x14ea4
movq 0x88(%rsp), %rdi
movq %rdi, 0x8(%rsp)
movq 0x70(%rsp), %r13
movq %r13, %rsi
movq %r12, %rdx
callq 0x1fc02
movq %r15, %rdi
addq $0xa0, %rdi
callq 0xd978
movl (%r13), %esi
movq %r14, %rdi
callq 0x287ea
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 0x694da
movq %r14, %rdi
leaq 0x55a54(%rip), %rsi     # 0xbea95
movq %r12, %rdx
movq %r13, %rcx
callq 0x79af0
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x69068
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x69084
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6260
imulq $0x148, %rbx, %rax      # imm = 0x148
addq %rax, %r15
addq $0xd0, %r15
movq %r14, %rdi
callq 0x28804
movq (%r15), %rax
cmpq %rax, 0x8(%r15)
movq 0x78(%rsp), %rbx
leaq 0x8(%rsp), %r12
je 0x69300
xorl %ebp, %ebp
xorl %r13d, %r13d
movq %r15, 0x98(%rsp)
imulq $0xd0, %rbp, %rcx
movl 0xb4(%rax,%rcx), %eax
cmpl %eax, (%rbx)
ja 0x692d9
cmpl 0x4(%rbx), %eax
jae 0x692d9
movq 0x28(%rsp), %r15
movq 0x68(%r15), %rbx
movq %r14, %rdi
movq %r15, %rsi
movl %r13d, %edx
callq 0x2881c
movl 0x8(%r15), %esi
movq %r14, %rdi
movl %ebp, %edx
callq 0x14cea
leaq 0x18(%rsp), %rcx
movq %rcx, 0x8(%rsp)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0xe480
leaq 0x50(%rsp), %rdi
movq %r14, %rsi
movq %r15, %rdx
movl %ebp, %ecx
callq 0x2c69c
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 0x55e35(%rip), %rdx     # 0xbefaf
leaq 0x50(%rsp), %rcx
callq 0x52708
leaq 0x30(%rsp), %r13
movq %r13, %rdi
movq %r15, %rsi
callq 0x26038
movq %rbx, %rdi
movl %r12d, %esi
movl %r14d, %edx
movq %r13, %rcx
callq 0x14ce0
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x691c1
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0xc8(%rsp), %rdi
leaq 0xd8(%rsp), %rax
cmpq %rax, %rdi
movl %r14d, %r13d
je 0x691e9
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
movq %rbx, %r14
je 0x69211
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 0x4c679(%rip), %rdx     # 0xb58af
movq %rdx, %rsi
callq 0x7c64
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 0x6927b
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 0x14ce0
movq 0x98(%rsp), %r15
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x692ba
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x692d6
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6260
incl %r13d
incl %ebp
movq (%r15), %rax
movq 0x8(%r15), %rcx
subq %rax, %rcx
sarq $0x4, %rcx
movabsq $0x4ec4ec4ec4ec4ec5, %rdx # imm = 0x4EC4EC4EC4EC4EC5
imulq %rdx, %rcx
cmpq %rbp, %rcx
ja 0x690c1
movq %r14, %rdi
callq 0x2889c
addq $0x10, %rbx
cmpq 0x90(%rsp), %rbx
movq 0x80(%rsp), %rsi
jne 0x68f7a
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 0x556c7(%rip), %rsi     # 0xbea3c
leaq 0x55718(%rip), %rdx     # 0xbea94
callq 0x7c64
movb $0x1, %bpl
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x6320
leaq 0x93a00(%rip), %rax     # 0xfcd98
addq $0x10, %rax
movq %rax, (%r14)
xorl %ebp, %ebp
leaq 0x939d8(%rip), %rsi     # 0xfcd80
movq 0x94c29(%rip), %rdx     # 0xfdfd8
movq %r14, %rdi
callq 0x6470
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x693de
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x693de
movq %rax, %rbx
movb $0x1, %bpl
testb %bpl, %bpl
je 0x694d1
movq %r14, %rdi
callq 0x6200
jmp 0x694d1
jmp 0x6943e
jmp 0x69496
movq %rax, %rbx
jmp 0x6946b
movq %rax, %rbx
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x69499
movq 0x40(%rsp), %rsi
jmp 0x69488
movq %rax, %rbx
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x69446
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x69446
movq %rax, %rbx
jmp 0x694b5
movq %rax, %rbx
movq 0xc8(%rsp), %rdi
leaq 0xd8(%rsp), %rax
cmpq %rax, %rdi
je 0x6946b
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x69499
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x69499
jmp 0x69496
jmp 0x69496
movq %rax, %rbx
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x694b5
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x694d1
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6260
movq %rbx, %rdi
callq 0x64a0
nop