// File: /workspace/github_cpp_makefile_star2_O1/rossy[P]crossc/SPIRV-Cross/spirv_hlsl.cpp
// Function: spirv_cross::CompilerHLSL::emit_hlsl_entry_point()
void CompilerHLSL::emit_hlsl_entry_point()
{
	vector<string> arguments;

	if (require_input)
		arguments.push_back("SPIRV_Cross_Input stage_input");

	// Add I/O blocks as separate arguments with appropriate storage qualifier.
	for (auto &id : ir.ids)
	{
		if (id.get_type() == TypeVariable)
		{
			auto &var = id.get<SPIRVariable>();
			auto &type = get<SPIRType>(var.basetype);
			bool block = ir.meta[type.self].decoration.decoration_flags.get(DecorationBlock);

			if (var.storage != StorageClassInput && var.storage != StorageClassOutput)
				continue;

			if (block && !is_builtin_variable(var) && interface_variable_exists_in_entry_point(var.self))
			{
				if (var.storage == StorageClassInput)
				{
					arguments.push_back(join("in ", variable_decl(type, join("stage_input", to_name(var.self)))));
				}
				else if (var.storage == StorageClassOutput)
				{
					arguments.push_back(join("out ", variable_decl(type, join("stage_output", to_name(var.self)))));
				}
			}
		}
	}

	auto &execution = get_entry_point();

	switch (execution.model)
	{
	case ExecutionModelGLCompute:
	{
		SpecializationConstant wg_x, wg_y, wg_z;
		get_work_group_size_specialization_constants(wg_x, wg_y, wg_z);

		uint32_t x = execution.workgroup_size.x;
		uint32_t y = execution.workgroup_size.y;
		uint32_t z = execution.workgroup_size.z;

		if (wg_x.id)
			x = get<SPIRConstant>(wg_x.id).scalar();
		if (wg_y.id)
			y = get<SPIRConstant>(wg_y.id).scalar();
		if (wg_z.id)
			z = get<SPIRConstant>(wg_z.id).scalar();

		statement("[numthreads(", x, ", ", y, ", ", z, ")]");
		break;
	}
	case ExecutionModelFragment:
		if (execution.flags.get(ExecutionModeEarlyFragmentTests))
			statement("[earlydepthstencil]");
		break;
	default:
		break;
	}

	statement(require_output ? "SPIRV_Cross_Output " : "void ", "main(", merge(arguments), ")");
	begin_scope();
	bool legacy = hlsl_options.shader_model <= 30;

	// Copy builtins from entry point arguments to globals.
	active_input_builtins.for_each_bit([&](uint32_t i) {
		auto builtin = builtin_to_glsl(static_cast<BuiltIn>(i), StorageClassInput);
		switch (static_cast<BuiltIn>(i))
		{
		case BuiltInFragCoord:
			// VPOS in D3D9 is sampled at integer locations, apply half-pixel offset to be consistent.
			// TODO: Do we need an option here? Any reason why a D3D9 shader would be used
			// on a D3D10+ system with a different rasterization config?
			if (legacy)
				statement(builtin, " = stage_input.", builtin, " + float4(0.5f, 0.5f, 0.0f, 0.0f);");
			else
				statement(builtin, " = stage_input.", builtin, ";");
			break;

		case BuiltInVertexId:
		case BuiltInVertexIndex:
		case BuiltInInstanceId:
		case BuiltInInstanceIndex:
			// D3D semantics are uint, but shader wants int.
			statement(builtin, " = int(stage_input.", builtin, ");");
			break;

		case BuiltInNumWorkgroups:
		case BuiltInPointCoord:
		case BuiltInSubgroupSize:
		case BuiltInSubgroupLocalInvocationId:
			break;

		case BuiltInSubgroupEqMask:
			// Emulate these ...
			// No 64-bit in HLSL, so have to do it in 32-bit and unroll.
			statement("gl_SubgroupEqMask = 1u << (WaveGetLaneIndex() - uint4(0, 32, 64, 96));");
			statement("if (WaveGetLaneIndex() >= 32) gl_SubgroupEqMask.x = 0;");
			statement("if (WaveGetLaneIndex() >= 64 || WaveGetLaneIndex() < 32) gl_SubgroupEqMask.y = 0;");
			statement("if (WaveGetLaneIndex() >= 96 || WaveGetLaneIndex() < 64) gl_SubgroupEqMask.z = 0;");
			statement("if (WaveGetLaneIndex() < 96) gl_SubgroupEqMask.w = 0;");
			break;

		case BuiltInSubgroupGeMask:
			// Emulate these ...
			// No 64-bit in HLSL, so have to do it in 32-bit and unroll.
			statement("gl_SubgroupGeMask = ~((1u << (WaveGetLaneIndex() - uint4(0, 32, 64, 96))) - 1u);");
			statement("if (WaveGetLaneIndex() >= 32) gl_SubgroupGeMask.x = 0u;");
			statement("if (WaveGetLaneIndex() >= 64) gl_SubgroupGeMask.y = 0u;");
			statement("if (WaveGetLaneIndex() >= 96) gl_SubgroupGeMask.z = 0u;");
			statement("if (WaveGetLaneIndex() < 32) gl_SubgroupGeMask.y = ~0u;");
			statement("if (WaveGetLaneIndex() < 64) gl_SubgroupGeMask.z = ~0u;");
			statement("if (WaveGetLaneIndex() < 96) gl_SubgroupGeMask.w = ~0u;");
			break;

		case BuiltInSubgroupGtMask:
			// Emulate these ...
			// No 64-bit in HLSL, so have to do it in 32-bit and unroll.
			statement("uint gt_lane_index = WaveGetLaneIndex() + 1;");
			statement("gl_SubgroupGtMask = ~((1u << (gt_lane_index - uint4(0, 32, 64, 96))) - 1u);");
			statement("if (gt_lane_index >= 32) gl_SubgroupGtMask.x = 0u;");
			statement("if (gt_lane_index >= 64) gl_SubgroupGtMask.y = 0u;");
			statement("if (gt_lane_index >= 96) gl_SubgroupGtMask.z = 0u;");
			statement("if (gt_lane_index >= 128) gl_SubgroupGtMask.w = 0u;");
			statement("if (gt_lane_index < 32) gl_SubgroupGtMask.y = ~0u;");
			statement("if (gt_lane_index < 64) gl_SubgroupGtMask.z = ~0u;");
			statement("if (gt_lane_index < 96) gl_SubgroupGtMask.w = ~0u;");
			break;

		case BuiltInSubgroupLeMask:
			// Emulate these ...
			// No 64-bit in HLSL, so have to do it in 32-bit and unroll.
			statement("uint le_lane_index = WaveGetLaneIndex() + 1;");
			statement("gl_SubgroupLeMask = (1u << (le_lane_index - uint4(0, 32, 64, 96))) - 1u;");
			statement("if (le_lane_index >= 32) gl_SubgroupLeMask.x = ~0u;");
			statement("if (le_lane_index >= 64) gl_SubgroupLeMask.y = ~0u;");
			statement("if (le_lane_index >= 96) gl_SubgroupLeMask.z = ~0u;");
			statement("if (le_lane_index >= 128) gl_SubgroupLeMask.w = ~0u;");
			statement("if (le_lane_index < 32) gl_SubgroupLeMask.y = 0u;");
			statement("if (le_lane_index < 64) gl_SubgroupLeMask.z = 0u;");
			statement("if (le_lane_index < 96) gl_SubgroupLeMask.w = 0u;");
			break;

		case BuiltInSubgroupLtMask:
			// Emulate these ...
			// No 64-bit in HLSL, so have to do it in 32-bit and unroll.
			statement("gl_SubgroupLtMask = (1u << (WaveGetLaneIndex() - uint4(0, 32, 64, 96))) - 1u;");
			statement("if (WaveGetLaneIndex() >= 32) gl_SubgroupLtMask.x = ~0u;");
			statement("if (WaveGetLaneIndex() >= 64) gl_SubgroupLtMask.y = ~0u;");
			statement("if (WaveGetLaneIndex() >= 96) gl_SubgroupLtMask.z = ~0u;");
			statement("if (WaveGetLaneIndex() < 32) gl_SubgroupLtMask.y = 0u;");
			statement("if (WaveGetLaneIndex() < 64) gl_SubgroupLtMask.z = 0u;");
			statement("if (WaveGetLaneIndex() < 96) gl_SubgroupLtMask.w = 0u;");
			break;

		case BuiltInClipDistance:
			for (uint32_t clip = 0; clip < clip_distance_count; clip++)
				statement("gl_ClipDistance[", clip, "] = stage_input.gl_ClipDistance", clip / 4, ".", "xyzw"[clip & 3],
				          ";");
			break;

		case BuiltInCullDistance:
			for (uint32_t cull = 0; cull < cull_distance_count; cull++)
				statement("gl_CullDistance[", cull, "] = stage_input.gl_CullDistance", cull / 4, ".", "xyzw"[cull & 3],
				          ";");
			break;

		default:
			statement(builtin, " = stage_input.", builtin, ";");
			break;
		}
	});

	// Copy from stage input struct to globals.
	for (auto &id : ir.ids)
	{
		if (id.get_type() == TypeVariable)
		{
			auto &var = id.get<SPIRVariable>();
			auto &type = get<SPIRType>(var.basetype);
			bool block = ir.meta[type.self].decoration.decoration_flags.get(DecorationBlock);

			if (var.storage != StorageClassInput)
				continue;

			bool need_matrix_unroll = var.storage == StorageClassInput && execution.model == ExecutionModelVertex;

			if (!block && !var.remapped_variable && type.pointer && !is_builtin_variable(var) &&
			    interface_variable_exists_in_entry_point(var.self))
			{
				auto name = to_name(var.self);
				auto &mtype = get<SPIRType>(var.basetype);
				if (need_matrix_unroll && mtype.columns > 1)
				{
					// Unroll matrices.
					for (uint32_t col = 0; col < mtype.columns; col++)
						statement(name, "[", col, "] = stage_input.", name, "_", col, ";");
				}
				else
				{
					statement(name, " = stage_input.", name, ";");
				}
			}

			// I/O blocks don't use the common stage input/output struct, but separate outputs.
			if (block && !is_builtin_variable(var) && interface_variable_exists_in_entry_point(var.self))
			{
				auto name = to_name(var.self);
				statement(name, " = stage_input", name, ";");
			}
		}
	}

	// Run the shader.
	if (execution.model == ExecutionModelVertex)
		statement("vert_main();");
	else if (execution.model == ExecutionModelFragment)
		statement("frag_main();");
	else if (execution.model == ExecutionModelGLCompute)
		statement("comp_main();");
	else
		SPIRV_CROSS_THROW("Unsupported shader stage.");

	// Copy block outputs.
	for (auto &id : ir.ids)
	{
		if (id.get_type() == TypeVariable)
		{
			auto &var = id.get<SPIRVariable>();
			auto &type = get<SPIRType>(var.basetype);
			bool block = ir.meta[type.self].decoration.decoration_flags.get(DecorationBlock);

			if (var.storage != StorageClassOutput)
				continue;

			// I/O blocks don't use the common stage input/output struct, but separate outputs.
			if (block && !is_builtin_variable(var) && interface_variable_exists_in_entry_point(var.self))
			{
				auto name = to_name(var.self);
				statement("stage_output", name, " = ", name, ";");
			}
		}
	}

	// Copy stage outputs.
	if (require_output)
	{
		statement("SPIRV_Cross_Output stage_output;");

		// Copy builtins from globals to return struct.
		active_output_builtins.for_each_bit([&](uint32_t i) {
			// PointSize doesn't exist in HLSL.
			if (i == BuiltInPointSize)
				return;

			switch (static_cast<BuiltIn>(i))
			{
			case BuiltInClipDistance:
				for (uint32_t clip = 0; clip < clip_distance_count; clip++)
					statement("stage_output.gl_ClipDistance", clip / 4, ".", "xyzw"[clip & 3], " = gl_ClipDistance[",
					          clip, "];");
				break;

			case BuiltInCullDistance:
				for (uint32_t cull = 0; cull < cull_distance_count; cull++)
					statement("stage_output.gl_CullDistance", cull / 4, ".", "xyzw"[cull & 3], " = gl_CullDistance[",
					          cull, "];");
				break;

			default:
			{
				auto builtin_expr = builtin_to_glsl(static_cast<BuiltIn>(i), StorageClassOutput);
				statement("stage_output.", builtin_expr, " = ", builtin_expr, ";");
				break;
			}
			}
		});

		for (auto &id : ir.ids)
		{
			if (id.get_type() == TypeVariable)
			{
				auto &var = id.get<SPIRVariable>();
				auto &type = get<SPIRType>(var.basetype);
				bool block = ir.meta[type.self].decoration.decoration_flags.get(DecorationBlock);

				if (var.storage != StorageClassOutput)
					continue;

				if (!block && var.storage != StorageClassFunction && !var.remapped_variable && type.pointer &&
				    !is_builtin_variable(var) && interface_variable_exists_in_entry_point(var.self))
				{
					auto name = to_name(var.self);

					if (legacy && execution.model == ExecutionModelFragment)
					{
						string output_filler;
						for (uint32_t size = type.vecsize; size < 4; ++size)
							output_filler += ", 0.0";

						statement("stage_output.", name, " = float4(", name, output_filler, ");");
					}
					else
					{
						statement("stage_output.", name, " = ", name, ";");
					}
				}
			}
		}

		statement("return stage_output;");
	}

	end_scope();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rdi, %rbx
xorps %xmm0, %xmm0
movaps %xmm0, 0x90(%rsp)
movq $0x0, 0xa0(%rsp)
cmpb $0x1, 0x7a9(%rdi)
jne 0x69ec1
movq %rsp, %rdi
leaq 0x10(%rsp), %rax
movq %rax, (%rdi)
leaq 0x54c80(%rip), %rsi     # 0xbeb0a
leaq 0x54c96(%rip), %rdx     # 0xbeb27
callq 0x7c64
leaq 0x90(%rsp), %rdi
movq %rsp, %rsi
callq 0xebe6
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x69ec1
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0x20(%rbx), %r14
movq 0x28(%rbx), %rbp
cmpq %rbp, %r14
je 0x6a0bf
cmpl $0x2, 0x8(%r14)
jne 0x6a0b6
movq %r14, %rdi
callq 0xb2e2
movq %rax, %r13
movl 0xc(%rax), %esi
movq %rbx, %rdi
callq 0xa426
movq %rax, %r15
movl 0x10(%r13), %eax
orl $0x2, %eax
cmpl $0x3, %eax
jne 0x6a0b6
movq 0x38(%rbx), %rax
movl 0x8(%r15), %ecx
imulq $0x148, %rcx, %rcx      # imm = 0x148
testb $0x4, 0x60(%rax,%rcx)
je 0x6a0b6
movq %rbx, %rdi
movq %r13, %rsi
callq 0x133a2
testb %al, %al
jne 0x6a0b6
movl 0x8(%r13), %esi
movq %rbx, %rdi
callq 0x13f62
testb %al, %al
je 0x6a0b6
movl 0x10(%r13), %eax
cmpl $0x3, %eax
je 0x69fce
cmpl $0x1, %eax
jne 0x6a0b6
movl 0x8(%r13), %edx
movq (%rbx), %rax
leaq 0x70(%rsp), %r13
movq %r13, %rdi
movq %rbx, %rsi
movl $0x1, %ecx
callq *0x38(%rax)
leaq 0x50(%rsp), %r12
movq %r12, %rdi
leaq 0x54bf8(%rip), %rsi     # 0xbeb7a
movq %r13, %rdx
callq 0x55d47
movq (%rbx), %rax
leaq 0x20(%rsp), %r13
movq %r13, %rdi
movq %rbx, %rsi
movq %r15, %rdx
movq %r12, %rcx
xorl %r8d, %r8d
callq *0xc8(%rax)
movq %rsp, %r15
movq %r15, %rdi
leaq 0x4e103(%rip), %rsi     # 0xb80b7
movq %r13, %rdx
callq 0x58997
leaq 0x90(%rsp), %rdi
movq %r15, %rsi
callq 0xebe6
jmp 0x6a041
movl 0x8(%r13), %edx
movq (%rbx), %rax
leaq 0x70(%rsp), %r13
movq %r13, %rdi
movq %rbx, %rsi
movl $0x1, %ecx
callq *0x38(%rax)
leaq 0x50(%rsp), %r12
movq %r12, %rdi
leaq 0x4b23f(%rip), %rsi     # 0xb5236
movq %r13, %rdx
callq 0x79db1
movq (%rbx), %rax
leaq 0x20(%rsp), %r13
movq %r13, %rdi
movq %rbx, %rsi
movq %r15, %rdx
movq %r12, %rcx
xorl %r8d, %r8d
callq *0xc8(%rax)
movq %rsp, %r15
movq %r15, %rdi
leaq 0x515aa(%rip), %rsi     # 0xbb5d3
movq %r13, %rdx
callq 0x79d25
leaq 0x90(%rsp), %rdi
movq %r15, %rsi
callq 0xebe6
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x6a05c
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x6a078
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x6a094
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x6a0b6
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x6260
addq $0x10, %r14
jmp 0x69ec9
movq %rbx, %rdi
callq 0x16254
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rax
movl 0xb8(%rax), %eax
cmpl $0x4, %eax
je 0x6a19d
cmpl $0x5, %eax
jne 0x6a1b7
movq %rsp, %rsi
leaq 0x20(%rsp), %rdx
leaq 0x50(%rsp), %rcx
movq %rbx, %rdi
callq 0x162fc
movq 0x40(%rsp), %rcx
movl 0xa0(%rcx), %eax
movl %eax, 0x70(%rsp)
movl 0xa4(%rcx), %eax
movl %eax, 0x4c(%rsp)
movl 0xa8(%rcx), %eax
movl %eax, 0x48(%rsp)
movl (%rsp), %esi
testl %esi, %esi
je 0x6a137
movq %rbx, %rdi
callq 0x1c66e
movl 0x10(%rax), %eax
movl %eax, 0x70(%rsp)
movl 0x20(%rsp), %esi
testl %esi, %esi
je 0x6a14e
movq %rbx, %rdi
callq 0x1c66e
movl 0x10(%rax), %eax
movl %eax, 0x4c(%rsp)
movl 0x50(%rsp), %esi
testl %esi, %esi
je 0x6a165
movq %rbx, %rdi
callq 0x1c66e
movl 0x10(%rax), %eax
movl %eax, 0x48(%rsp)
leaq 0x549c9(%rip), %rax     # 0xbeb35
leaq 0x48(%rsp), %r10
leaq 0x549b0(%rip), %rsi     # 0xbeb28
leaq 0x50f3c(%rip), %rcx     # 0xbb0bb
leaq 0x70(%rsp), %rdx
leaq 0x4c(%rsp), %r8
movq %rbx, %rdi
movq %rcx, %r9
pushq %rax
pushq %r10
callq 0x79e3e
addq $0x10, %rsp
jmp 0x6a1b7
movq 0x40(%rsp), %rax
testb $0x2, 0x61(%rax)
je 0x6a1b7
leaq 0x54989(%rip), %rsi     # 0xbeb38
movq %rbx, %rdi
callq 0xc486
leaq 0x5498e(%rip), %rax     # 0xbeb4c
leaq 0x548fb(%rip), %rcx     # 0xbeac0
cmpb $0x0, 0x7a8(%rbx)
cmovneq %rax, %rcx
movq %rcx, 0x20(%rsp)
leaq 0x10(%rsp), %rax
movq %rax, (%rsp)
movq $0x0, 0x8(%rsp)
movb $0x0, 0x10(%rsp)
movq 0x90(%rsp), %r12
movq 0x98(%rsp), %r13
cmpq %r13, %r12
je 0x6a241
movq %rsp, %r14
leaq 0x50eb0(%rip), %r15     # 0xbb0bb
movq (%r12), %rsi
movq 0x8(%r12), %rdx
movq %r14, %rdi
callq 0x60b0
movq 0x98(%rsp), %rax
addq $-0x20, %rax
cmpq %rax, %r12
je 0x6a238
movq %r14, %rdi
movq %r15, %rsi
callq 0x64e0
addq $0x20, %r12
cmpq %r13, %r12
jne 0x6a20b
leaq 0x54918(%rip), %rdx     # 0xbeb60
leaq 0x517d6(%rip), %r8      # 0xbba25
leaq 0x20(%rsp), %rsi
movq %rsp, %rcx
movq %rbx, %rdi
callq 0x79f7a
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x6a27a
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x6260
movq %rbx, %rdi
callq 0x28804
cmpl $0x1f, 0x788(%rbx)
leaq 0x50(%rsp), %rax
setb (%rax)
leaq 0x20(%rsp), %r15
movq %rbx, (%r15)
movq %rax, 0x8(%r15)
xorl %r14d, %r14d
movq 0x2d0(%rbx), %rax
btq %r14, %rax
jae 0x6a2b8
movq %r15, %rdi
movl %r14d, %esi
callq 0x75598
incq %r14
cmpq $0x40, %r14
jne 0x6a2a0
movq 0x2f0(%rbx), %rsi
testq %rsi, %rsi
je 0x6a3a0
xorps %xmm0, %xmm0
movq %rsp, %rdi
movaps %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
callq 0x7d4ee
movq 0x2e8(%rbx), %r12
testq %r12, %r12
je 0x6a327
movq %rsp, %r14
leaq 0x8(%r12), %rdx
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x6a316
movl (%rdx), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rsp)
jmp 0x6a31e
movq %r14, %rdi
callq 0x7a00
movq (%r12), %r12
testq %r12, %r12
jne 0x6a2f6
movq (%rsp), %r14
movq 0x8(%rsp), %r12
cmpq %r12, %r14
je 0x6a362
movq %r12, %rax
subq %r14, %rax
sarq $0x2, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r14, %rdi
movq %r12, %rsi
callq 0x21b53
movq %r14, %rdi
movq %r12, %rsi
callq 0x21c36
movq (%rsp), %r12
movq 0x8(%rsp), %r13
cmpq %r13, %r12
je 0x6a38a
leaq 0x20(%rsp), %r14
movl (%r12), %esi
movq %r14, %rdi
callq 0x75598
addq $0x4, %r12
cmpq %r13, %r12
jne 0x6a375
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x6a3a0
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x6260
movq 0x20(%rbx), %r12
movq 0x28(%rbx), %rbp
cmpq %rbp, %r12
je 0x6a56c
cmpl $0x2, 0x8(%r12)
jne 0x6a545
movq %r12, %rdi
callq 0xb2e2
movq %rax, %r14
movl 0xc(%rax), %esi
movq %rbx, %rdi
callq 0xa426
cmpl $0x1, 0x10(%r14)
jne 0x6a545
movq 0x38(%rbx), %rcx
movl 0x8(%rax), %edx
imulq $0x148, %rdx, %rdx      # imm = 0x148
testb $0x4, 0x60(%rcx,%rdx)
jne 0x6a4d7
cmpb $0x0, 0x5b(%r14)
jne 0x6a545
cmpb $0x1, 0x60(%rax)
jne 0x6a545
movq 0x40(%rsp), %rax
movl 0xb8(%rax), %r13d
movq %rbx, %rdi
movq %r14, %rsi
callq 0x133a2
testb %al, %al
jne 0x6a545
movl 0x8(%r14), %esi
movq %rbx, %rdi
callq 0x13f62
testb %al, %al
je 0x6a545
movl 0x8(%r14), %edx
movq (%rbx), %rax
movq %rsp, %rdi
movq %rbx, %rsi
movl $0x1, %ecx
callq *0x38(%rax)
movl 0xc(%r14), %esi
movq %rbx, %rdi
callq 0xa426
testl %r13d, %r13d
jne 0x6a54e
movq %rax, %r14
cmpl $0x2, 0x18(%rax)
jb 0x6a54e
movl $0x0, 0x20(%rsp)
cmpl $0x0, 0x18(%r14)
movq %rsp, %r13
je 0x6a52a
subq $0x8, %rsp
movq %rbx, %rdi
movq %r13, %rsi
leaq 0x5987f(%rip), %rdx     # 0xc3d1c
movq %r15, %rcx
leaq 0x546bf(%rip), %r8      # 0xbeb66
movq %r13, %r9
leaq 0x55638(%rip), %rax     # 0xbfae9
pushq %rax
pushq %r15
leaq 0x54af4(%rip), %rax     # 0xbefaf
pushq %rax
callq 0x7a092
addq $0x20, %rsp
movl 0x20(%rsp), %eax
incl %eax
movl %eax, 0x20(%rsp)
cmpl 0x18(%r14), %eax
jb 0x6a48c
jmp 0x6a52a
movq %rbx, %rdi
movq %r14, %rsi
callq 0x133a2
testb %al, %al
jne 0x6a545
movl 0x8(%r14), %esi
movq %rbx, %rdi
callq 0x13f62
testb %al, %al
je 0x6a545
movl 0x8(%r14), %edx
movq (%rbx), %rax
movq %rsp, %r14
movq %r14, %rdi
movq %rbx, %rsi
movl $0x1, %ecx
callq *0x38(%rax)
movq %rbx, %rdi
movq %r14, %rsi
leaq 0x5465c(%rip), %rdx     # 0xbeb77
movq %r14, %rcx
leaq 0x555c4(%rip), %r8      # 0xbfae9
callq 0x7a38c
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x6a545
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x6260
addq $0x10, %r12
jmp 0x6a3a8
movq %rbx, %rdi
movq %rsp, %rcx
movq %rcx, %rsi
leaq 0x54609(%rip), %rdx     # 0xbeb67
leaq 0x55584(%rip), %r8      # 0xbfae9
callq 0x7a206
jmp 0x6a52a
movq 0x40(%rsp), %rax
movl 0xb8(%rax), %eax
testl %eax, %eax
je 0x6a59b
cmpl $0x4, %eax
je 0x6a592
cmpl $0x5, %eax
jne 0x6a987
leaq 0x54610(%rip), %rsi     # 0xbeba0
jmp 0x6a5a2
leaq 0x545fa(%rip), %rsi     # 0xbeb93
jmp 0x6a5a2
leaq 0x545e4(%rip), %rsi     # 0xbeb86
movq %rbx, %rdi
callq 0x7a512
movq 0x20(%rbx), %r15
movq 0x28(%rbx), %rbp
cmpq %rbp, %r15
je 0x6a684
movq %rsp, %r12
leaq 0x55524(%rip), %r14     # 0xbfae9
cmpl $0x2, 0x8(%r15)
jne 0x6a677
movq %r15, %rdi
callq 0xb2e2
movq %rax, %r13
movl 0xc(%rax), %esi
movq %rbx, %rdi
callq 0xa426
cmpl $0x3, 0x10(%r13)
jne 0x6a677
movl 0x8(%rax), %eax
movq 0x38(%rbx), %rcx
imulq $0x148, %rax, %rax      # imm = 0x148
movq 0x60(%rcx,%rax), %rax
andl $0x4, %eax
je 0x6a677
movq %rbx, %rdi
movq %r13, %rsi
callq 0x133a2
testb %al, %al
jne 0x6a677
movl 0x8(%r13), %esi
movq %rbx, %rdi
callq 0x13f62
testb %al, %al
je 0x6a677
movl 0x8(%r13), %edx
movq (%rbx), %rax
movq %r12, %rdi
movq %rbx, %rsi
movl $0x1, %ecx
callq *0x38(%rax)
movq %rbx, %rdi
leaq 0x4abef(%rip), %rsi     # 0xb5236
movq %r12, %rdx
leaq 0x55401(%rip), %rcx     # 0xbfa52
movq %r12, %r8
movq %r14, %r9
callq 0x7a618
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x6a677
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x6260
addq $0x10, %r15
cmpq %rbp, %r15
jne 0x6a5c5
cmpb $0x0, 0x7a8(%rbx)
je 0x6a960
leaq 0x5452f(%rip), %rsi     # 0xbebc7
movq %rbx, %rdi
callq 0x513e0
leaq 0x20(%rsp), %r14
movq %rbx, (%r14)
xorl %r15d, %r15d
movq 0x310(%rbx), %rax
btq %r15, %rax
jae 0x6a6c3
movq %r14, %rdi
movl %r15d, %esi
callq 0x75a40
incq %r15
cmpq $0x40, %r15
jne 0x6a6ab
movq 0x330(%rbx), %rsi
testq %rsi, %rsi
je 0x6a7a8
xorps %xmm0, %xmm0
movq %rsp, %rdi
movaps %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
callq 0x7d4ee
movq 0x328(%rbx), %r15
testq %r15, %r15
je 0x6a730
movq %rsp, %r14
leaq 0x8(%r15), %rdx
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x6a720
movl (%rdx), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rsp)
jmp 0x6a728
movq %r14, %rdi
callq 0x7a00
movq (%r15), %r15
testq %r15, %r15
jne 0x6a701
movq (%rsp), %r14
movq 0x8(%rsp), %r15
cmpq %r15, %r14
je 0x6a76b
movq %r15, %rax
subq %r14, %rax
sarq $0x2, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r14, %rdi
movq %r15, %rsi
callq 0x21b53
movq %r14, %rdi
movq %r15, %rsi
callq 0x21c36
movq (%rsp), %r15
movq 0x8(%rsp), %r12
cmpq %r12, %r15
je 0x6a792
leaq 0x20(%rsp), %r14
movl (%r15), %esi
movq %r14, %rdi
callq 0x75a40
addq $0x4, %r15
cmpq %r12, %r15
jne 0x6a77e
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x6a7a8
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x6260
movq 0x20(%rbx), %r15
movq 0x28(%rbx), %r13
cmpq %r13, %r15
je 0x6a951
leaq 0x20(%rsp), %rbp
cmpl $0x2, 0x8(%r15)
jne 0x6a944
movq %r15, %rdi
callq 0xb2e2
movq %rax, %r12
movl 0xc(%rax), %esi
movq %rbx, %rdi
callq 0xa426
cmpl $0x3, 0x10(%r12)
jne 0x6a944
movq %rax, %r14
movl 0x8(%rax), %eax
movq 0x38(%rbx), %rcx
imulq $0x148, %rax, %rax      # imm = 0x148
movq 0x60(%rcx,%rax), %rax
andl $0x4, %eax
jne 0x6a944
cmpb $0x0, 0x5b(%r12)
jne 0x6a944
cmpb $0x1, 0x60(%r14)
jne 0x6a944
movq %rbx, %rdi
movq %r12, %rsi
callq 0x133a2
testb %al, %al
jne 0x6a944
movl 0x8(%r12), %esi
movq %rbx, %rdi
callq 0x13f62
testb %al, %al
je 0x6a944
movl 0x8(%r12), %edx
movq (%rbx), %rax
movq %rsp, %r12
movq %r12, %rdi
movq %rbx, %rsi
movl $0x1, %ecx
callq *0x38(%rax)
cmpb $0x1, 0x50(%rsp)
jne 0x6a906
movq 0x40(%rsp), %rax
cmpl $0x4, 0xb8(%rax)
jne 0x6a906
leaq 0x30(%rsp), %rax
movq %rax, 0x20(%rsp)
movq $0x0, 0x28(%rsp)
movb $0x0, 0x30(%rsp)
movl 0x14(%r14), %r14d
cmpl $0x3, %r14d
ja 0x6a8b9
addl $-0x4, %r14d
movq %rbp, %rdi
leaq 0x54339(%rip), %rsi     # 0xbebe8
callq 0x64e0
incl %r14d
jne 0x6a8a5
subq $0x8, %rsp
movq %rbx, %rdi
leaq 0x54327(%rip), %rsi     # 0xbebee
movq %r12, %rdx
leaq 0x5432b(%rip), %rcx     # 0xbebfc
movq %r12, %r8
movq %rbp, %r9
leaq 0x5520a(%rip), %rax     # 0xbfae8
pushq %rax
callq 0x7a7d0
addq $0x10, %rsp
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x6a929
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x6a929
movq %rbx, %rdi
leaq 0x542de(%rip), %rsi     # 0xbebee
movq %r12, %rdx
leaq 0x55138(%rip), %rcx     # 0xbfa52
movq %r12, %r8
leaq 0x551c5(%rip), %r9      # 0xbfae9
callq 0x7a9a8
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x6a944
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x6260
addq $0x10, %r15
cmpq %r13, %r15
jne 0x6a7be
leaq 0x542af(%rip), %rsi     # 0xbec07
movq %rbx, %rdi
callq 0xcef8
movq %rbx, %rdi
callq 0x4358a
leaq 0x90(%rsp), %rdi
callq 0xda64
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x10, %edi
callq 0x6140
movq %rax, %r14
movq %rsp, %rdi
leaq 0x10(%rsp), %rax
movq %rax, (%rdi)
leaq 0x54207(%rip), %rsi     # 0xbebad
leaq 0x54219(%rip), %rdx     # 0xbebc6
callq 0x7c64
movb $0x1, %bpl
movq %rsp, %rsi
movq %r14, %rdi
callq 0x6320
leaq 0x923d1(%rip), %rax     # 0xfcd98
addq $0x10, %rax
movq %rax, (%r14)
xorl %ebp, %ebp
leaq 0x923a9(%rip), %rsi     # 0xfcd80
movq 0x935fa(%rip), %rdx     # 0xfdfd8
movq %r14, %rdi
callq 0x6470
jmp 0x6aae3
jmp 0x6ab47
jmp 0x6ab42
jmp 0x6ab42
movq %rax, %rbx
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x6aa20
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x6aa20
movq %rax, %rbx
movb $0x1, %bpl
testb %bpl, %bpl
je 0x6ab65
movq %r14, %rdi
callq 0x6200
jmp 0x6ab65
jmp 0x6aa43
jmp 0x6aa63
jmp 0x6aa84
jmp 0x6aaa5
jmp 0x6ab42
movq %rax, %rbx
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x6aa66
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x6aa66
movq %rax, %rbx
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x6aa87
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x6aa87
movq %rax, %rbx
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x6aaa8
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x6aaa8
movq %rax, %rbx
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x6ab65
movq 0x80(%rsp), %rsi
jmp 0x6ab5d
jmp 0x6ab42
jmp 0x6ab47
jmp 0x6ab42
jmp 0x6ab47
jmp 0x6ab42
jmp 0x6ab47
jmp 0x6ab47
jmp 0x6ab42
jmp 0x6ab2c
jmp 0x6ab42
jmp 0x6ab42
jmp 0x6ab47
movq %rax, %rbx
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x6ab4a
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x6ab4a
jmp 0x6ab47
jmp 0x6ab42
jmp 0x6ab2c
jmp 0x6ab42
jmp 0x6ab2c
jmp 0x6ab42
jmp 0x6ab42
jmp 0x6ab2c
jmp 0x6ab42
jmp 0x6ab42
jmp 0x6ab42
jmp 0x6ab2c
jmp 0x6ab42
jmp 0x6ab42
jmp 0x6ab42
jmp 0x6ab42
jmp 0x6ab42
jmp 0x6ab42
jmp 0x6ab42
jmp 0x6ab42
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x6ab65
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
jmp 0x6ab60
movq %rax, %rbx
jmp 0x6ab65
movq %rax, %rbx
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x6ab65
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x6260
leaq 0x90(%rsp), %rdi
callq 0xda64
movq %rbx, %rdi
callq 0x64a0