// File: /workspace/github_cpp_makefile_star2_O2/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, %rbx
movq 0x7d0(%rdi), %rbp
movq 0x7d8(%rdi), %rax
movq %rax, 0x38(%rsp)
cmpq %rax, %rbp
je 0x55182
leaq 0x6b0(%rbx), %rax
movq %rax, 0x30(%rsp)
leaq 0x8(%rsi), %rax
movq %rax, 0x8(%rsp)
movq %rsi, 0x28(%rsp)
movq %rbx, 0x20(%rsp)
cmpq 0x38(%rsp), %rbp
je 0x55170
movl 0xc(%rsi), %esi
movq %rbx, %rdi
callq 0x90a4
movq %rbx, %r14
movq %rax, %rbx
movl (%rbp), %ecx
movl 0x4(%rbp), %r8d
movq %r14, %rdi
movq %rax, %rsi
pushq $0x5
popq %rdx
callq 0x23b1a
testb %al, %al
je 0x551a2
movl 0x8(%rbx), %esi
movq %r14, %rdi
pushq $0xa
popq %rdx
xorl %ecx, %ecx
callq 0x1206e
movq 0x30(%rsp), %rdi
movq 0x8(%rsp), %r13
movq %r13, %rsi
callq 0x1af30
movq %rbx, %rdi
addq $0xa0, %rdi
callq 0xb854
movl (%r13), %esi
movq %r14, %rdi
callq 0x22d1a
movq %rbx, 0x10(%rsp)
movl 0x8(%rbx), %r15d
movq 0x38(%r14), %r12
movl (%r13), %edx
movq (%r14), %rax
leaq 0x48(%rsp), %r13
movq %r13, %rdi
movq %r14, %rsi
pushq $0x1
popq %rcx
callq *0x38(%rax)
movl 0x8(%rbp), %ecx
movq %rbp, 0x18(%rsp)
movl 0xc(%rbp), %r8d
leaq 0x68(%rsp), %rbp
movq %rbp, %rdi
movq %r14, %rsi
pushq $0x62
popq %rdx
callq 0x5527c
movq %r14, %rbx
movq %r14, %rdi
leaq 0x43abd(%rip), %rsi     # 0x98a2d
movq %r13, %rdx
movq %rbp, %rcx
callq 0x61930
movq %r13, %r14
imulq $0x148, %r15, %rax      # imm = 0x148
leaq (%r12,%rax), %r13
addq $0xd0, %r13
movq %rbp, %rdi
callq 0x6548
movq %r14, %rdi
callq 0x6548
movq %rbx, %rdi
callq 0x22d28
xorl %r12d, %r12d
xorl %r15d, %r15d
movq 0x18(%rsp), %r14
movq 0x10(%rsp), %rbp
movq %r13, 0x40(%rsp)
movl %r15d, %r15d
movq (%r13), %rcx
movq 0x8(%r13), %rax
subq %rcx, %rax
cqto
movl $0xd0, %esi
idivq %rsi
cmpq %r15, %rax
jbe 0x55157
imulq $0xd0, %r15, %rax
movl 0xb4(%rcx,%rax), %eax
cmpl %eax, (%r14)
ja 0x5514f
cmpl 0x4(%r14), %eax
jae 0x5514f
movq 0x68(%rbp), %r14
movq %rbx, %rdi
movq %rbp, %rsi
movl %r12d, %edx
callq 0x22d40
movl 0x8(%rbp), %esi
movq %rbx, %rdi
movl %r15d, %edx
callq 0x11ee2
leaq 0x48(%rsp), %rdi
movq %rax, %rsi
callq 0x63c0
leaq 0x68(%rsp), %rdi
movq %rbx, %rsi
movq %rbp, %rdx
movl %r15d, %ecx
callq 0x25cca
movl %r12d, 0x4(%rsp)
movl 0x8(%rbp), %r13d
movq 0x8(%rsp), %rax
movl (%rax), %edx
movq (%rbx), %rax
leaq 0x88(%rsp), %rbp
movq %rbx, %rsi
movq %rbp, %rbx
movq %rbp, %rdi
pushq $0x1
popq %rcx
callq *0x38(%rax)
leaq 0xc8(%rsp), %rbp
movq %rbp, %rdi
movq %rbx, %rsi
leaq 0x43ec9(%rip), %rdx     # 0x98f47
leaq 0x68(%rsp), %rcx
callq 0x42137
leaq 0xa8(%rsp), %rbx
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x20bb0
movq 0x20(%rsp), %rdi
movl %r13d, %esi
movl 0x4(%rsp), %edx
movq %rbx, %rcx
callq 0x11ed8
movq %rbx, %rdi
callq 0x6548
movq %rbp, %rdi
callq 0x6548
leaq 0x88(%rsp), %rdi
callq 0x6548
movq %rbx, %r12
movl (%r14,%r15,4), %r13d
movq %rbx, %rdi
leaq 0x3a7aa(%rip), %rsi     # 0x8f887
movq %rbp, %rdx
callq 0x6100
movq 0x18(%rsp), %rax
movq %rax, %r14
movl (%rax), %r9d
movq 0x20(%rsp), %rbx
movq (%rbx), %rax
movq %rbx, %rdi
movq 0x10(%rsp), %rbp
movq %rbp, %rsi
movl %r13d, %edx
movl %r15d, %ecx
movq %r12, %r8
callq *0xa8(%rax)
movq %r12, %rdi
callq 0x6548
movl 0x8(%rbp), %esi
movq %rbx, %rdi
movl 0x4(%rsp), %r12d
movl %r12d, %edx
leaq 0x48(%rsp), %r13
movq %r13, %rcx
callq 0x11ed8
incl %r12d
leaq 0x68(%rsp), %rdi
callq 0x6548
movq %r13, %rdi
callq 0x6548
movq 0x40(%rsp), %r13
incl %r15d
jmp 0x54fbd
movq %rbx, %rdi
callq 0x22dba
movq %r14, %rbp
addq $0x10, %rbp
movq 0x28(%rsp), %rsi
jmp 0x54ea9
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%rbx), %rax
movq 0xe8(%rax), %rax
movq %rbx, %rdi
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmpq *%rax
pushq $0x10
popq %rdi
callq 0x6140
movq %rax, %r14
leaq 0x43820(%rip), %rsi     # 0x989d4
leaq 0x48(%rsp), %rdi
leaq 0x68(%rsp), %rdx
callq 0x6100
movb $0x1, %bpl
leaq 0x48(%rsp), %rsi
movq %r14, %rdi
callq 0x6f6e
xorl %ebp, %ebp
leaq 0x91be4(%rip), %rsi     # 0xe6dc0
movq 0x92dfd(%rip), %rdx     # 0xe7fe0
movq %r14, %rdi
callq 0x6490
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x6548
testb %bpl, %bpl
jne 0x55202
jmp 0x5526e
movq %rax, %rbx
movq %r14, %rdi
callq 0x6200
jmp 0x5526e
jmp 0x55276
jmp 0x55219
movq %rax, %rbx
jmp 0x5524d
jmp 0x55219
jmp 0x55219
movq %rax, %rbx
jmp 0x5525a
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
jmp 0x55255
movq %rax, %rbx
jmp 0x55240
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
callq 0x6548
leaq 0xc8(%rsp), %rdi
callq 0x6548
leaq 0x88(%rsp), %rdi
callq 0x6548
leaq 0x68(%rsp), %rdi
callq 0x6548
leaq 0x48(%rsp), %rdi
callq 0x6548
movq %rbx, %rdi
callq 0x64b0
movq %rax, %rbx
jmp 0x55264
nop