text:
namespace SurgSim
{
namespace Math
{

class TriangleCapsuleContactCalculationTest : public ::testing::Test
{
protected:
	typedef std::tuple<std::string,	// String to describe the scenario.
		MockTriangle,	// The triangle.
		MockCapsule,	// The capsule.
		bool,		// Flag to indicate if the two shapes are expected to be found intersecting.
		bool,		// Flag to indicate if expected contact info is available to check against.
		Vector3d,	// Expected penetration point in the triangle.
		Vector3d>	// Expected penetration point in the capsule.
		TriangleCapsuleTestCase;

	SurgSim::Math::RigidTransform3d buildRigidTransform(double angle, double axisX, double axisY, double axisZ,
		double translationX, double translationY, double translationZ)
	{
		using SurgSim::Math::makeRigidTransform;
		using SurgSim::Math::makeRotationQuaternion;
		return makeRigidTransform(makeRotationQuaternion(angle, Vector3d(axisX, axisY, axisZ).normalized()),
									Vector3d(translationX, translationY, translationZ));
	}

	void SetUp() override
	{
		m_transforms.push_back(buildRigidTransform(0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0));
		m_transforms.push_back(buildRigidTransform(1.234, 17.04, 2.047, 3.052, 23.34, 42.45, 83.68));
		m_transforms.push_back(buildRigidTransform(-5.34, 41.03, -2.52, -3.84, -3.45, 66.47, 29.34));
		m_transforms.push_back(buildRigidTransform(0.246, -9.42, -4.86, 2.469, 37.68, -34.6, -17.1));
		m_transforms.push_back(buildRigidTransform(-0.85, 3.344, 8.329, -97.4, 9.465, 0.275, -95.9));
	}

	void checkEqual(const Vector3d& v1, const Vector3d& v2)
	{
		if (v1.isZero(Geometry::DistanceEpsilon))
		{
			EXPECT_TRUE(v2.isZero(Geometry::DistanceEpsilon));
		}
		else
		{
			EXPECT_TRUE(v1.isApprox(v2, Geometry::DistanceEpsilon));
		}
	}

	void testTriangleCapsuleContactCalculation(const TriangleCapsuleTestCase& data)
	{
		MockTriangle t = std::get<1>(data);
		MockCapsule c = std::get<2>(data);
		bool contactExpected = std::get<3>(data);
		bool checkForPenetrationPoints = std::get<4>(data);
		Vector3d expectedTPoint = std::get<5>(data);
		Vector3d expectedCPoint = std::get<6>(data);

		double expectedPenetrationDepth = (expectedCPoint - expectedTPoint).norm();
		double penetrationDepth;
		Vector3d tPoint, cPoint, normal, cPointAxis;
		bool contactFound = false;
		std::string traceMessage[12] = {"Triangle vs Capsule",
			"Triangle (vertices shifted once) vs Capsule",
			"Triangle (vertices shifted twice) vs Capsule",
			"Triangle vs Capsule (vertices interchanged)",
			"Triangle (vertices shifted once) vs Capsule (vertices interchanged)",
			"Triangle (vertices shifted twice) vs Capsule (vertices interchanged)",
			"Reversed Triangle vs Capsule",
			"Reversed Triangle (vertices shifted once) vs Capsule",
			"Reversed Triangle (vertices shifted twice) vs Capsule",
			"Reversed Triangle vs Capsule (vertices interchanged)",
			"Reversed Triangle (vertices shifted once) vs Capsule (vertices interchanged)",
			"Reversed Triangle (vertices shifted twice) vs Capsule (vertices interchanged)"
		};
		for (int count = 0; count < 12; ++count)
		{
			SCOPED_TRACE(std::get<0>(data) + ": " + traceMessage[count]);

			switch (count)
			{
			case 0:
				EXPECT_NO_THROW(
					contactFound = calculateContactTriangleCapsule(t.v0, t.v1, t.v2, t.n, c.v0, c.v1, c.r,
					&penetrationDepth, &tPoint, &cPoint, &normal, &cPointAxis));
				break;
			case 1:
				EXPECT_NO_THROW(
					contactFound = calculateContactTriangleCapsule(t.v1, t.v2, t.v0, t.n, c.v0, c.v1, c.r,
					&penetrationDepth, &tPoint, &cPoint, &normal, &cPointAxis));
				break;
			case 2:
				EXPECT_NO_THROW(
					contactFound = calculateContactTriangleCapsule(t.v2, t.v0, t.v1, t.n, c.v0, c.v1, c.r,
					&penetrationDepth, &tPoint, &cPoint, &normal, &cPointAxis));
				break;
			case 3:
				EXPECT_NO_THROW(
					contactFound = calculateContactTriangleCapsule(t.v0, t.v1, t.v2, t.n, c.v1, c.v0, c.r,
					&penetrationDepth, &tPoint, &cPoint, &normal, &cPointAxis));
				break;
			case 4:
				EXPECT_NO_THROW(
					contactFound = calculateContactTriangleCapsule(t.v1, t.v2, t.v0, t.n, c.v1, c.v0, c.r,
					&penetrationDepth, &tPoint, &cPoint, &normal, &cPointAxis));
				break;
			case 5:
				EXPECT_NO_THROW(
					contactFound = calculateContactTriangleCapsule(t.v2, t.v0, t.v1, t.n, c.v1, c.v0, c.r,
					&penetrationDepth, &tPoint, &cPoint, &normal, &cPointAxis));
				break;
			case 6:
				EXPECT_NO_THROW(
					contactFound = calculateContactTriangleCapsule(t.v2, t.v1, t.v0, c.v0, c.v1, c.r,
					&penetrationDepth, &tPoint, &cPoint, &normal, &cPointAxis));
				break;
			case 7:
				EXPECT_NO_THROW(
					contactFound = calculateContactTriangleCapsule(t.v1, t.v0, t.v2, c.v0, c.v1, c.r,
					&penetrationDepth, &tPoint, &cPoint, &normal, &cPointAxis));
				break;
			case 8:
				EXPECT_NO_THROW(
					contactFound = calculateContactTriangleCapsule(t.v0, t.v2, t.v1, c.v0, c.v1, c.r,
					&penetrationDepth, &tPoint, &cPoint, &normal, &cPointAxis));
				break;
			case 9:
				EXPECT_NO_THROW(
					contactFound = calculateContactTriangleCapsule(t.v2, t.v1, t.v0, c.v1, c.v0, c.r,
					&penetrationDepth, &tPoint, &cPoint, &normal, &cPointAxis));
				break;
			case 10:
				EXPECT_NO_THROW(
					contactFound = calculateContactTriangleCapsule(t.v1, t.v0, t.v2, c.v1, c.v0, c.r,
					&penetrationDepth, &tPoint, &cPoint, &normal, &cPointAxis));
				break;
			case 11:
				EXPECT_NO_THROW(
					contactFound = calculateContactTriangleCapsule(t.v0, t.v2, t.v1, c.v1, c.v0, c.r,
					&penetrationDepth, &tPoint, &cPoint, &normal, &cPointAxis));
				break;
			}

			EXPECT_EQ(contactExpected, contactFound);
			if (contactFound)
			{
				if (checkForPenetrationPoints && count < 6)
				{
					EXPECT_NEAR(expectedPenetrationDepth, penetrationDepth, Geometry::DistanceEpsilon);
					checkEqual(expectedTPoint, tPoint);
					checkEqual(expectedCPoint, cPoint);
				}

				// Check that tPoint is on the plane of t.
				double tSignedDistance = std::abs(tPoint.dot(t.n) - t.v0.dot(t.n));
				EXPECT_NEAR(tSignedDistance, 0.0, Geometry::DistanceEpsilon);

				// Check that cPoint is on the surface of c.
				Vector3d result;
				double cDistance = SurgSim::Math::distancePointSegment(cPoint, c.v0, c.v1, &result) - c.r;
				EXPECT_LE(std::abs(cDistance), Geometry::DistanceEpsilon);

				// Check that tPoint is inside t.
				EXPECT_TRUE(SurgSim::Math::isPointInsideTriangle(tPoint, t.v0, t.v1, t.v2));

				// Check if the penetration depth when applied as correction, separates the shapes.
				// First move the shapes apart by just short of the penetration depth, to make sure
				// the shapes are still colliding.
				{
					Vector3d tP, cP;
					Vector3d correction = normal * (0.5 * penetrationDepth - Geometry::DistanceEpsilon);
					MockTriangle correctedT(t);
					correctedT.translate(correction);
					MockCapsule correctedC(c);
					correctedC.translate(-correction);
					auto correctedDistance = distanceSegmentTriangle(correctedC.v0, correctedC.v1, correctedT.v0,
						correctedT.v1, correctedT.v2, correctedT.n, &cP, &tP) - c.r;
					EXPECT_TRUE(correctedDistance >= -4.0 * Geometry::DistanceEpsilon)
						<< "correctedDistance = " << correctedDistance;
					EXPECT_TRUE(correctedDistance <= Geometry::DistanceEpsilon)
						<< "correctedDistance = " << correctedDistance;
				}
				// Now move the shapes apart by just a little farther than the penetration depth, to establish
				// that the shapes are not colliding.
				{
					Vector3d tP, cP;
					Vector3d correction = normal * (0.5 * penetrationDepth + Geometry::DistanceEpsilon);
					MockTriangle correctedT(t);
					correctedT.translate(correction);
					MockCapsule correctedC(c);
					correctedC.translate(-correction);
					auto correctedDistance = distanceSegmentTriangle(correctedC.v0, correctedC.v1, correctedT.v0,
						correctedT.v1, correctedT.v2, correctedT.n, &cP, &tP) - c.r;
					EXPECT_TRUE(correctedDistance <= 4.0 * Geometry::DistanceEpsilon)
						<< "correctedDistance = " << correctedDistance;
					EXPECT_TRUE(correctedDistance >= -Geometry::DistanceEpsilon)
						<< "correctedDistance = " << correctedDistance;
				}
			}
		}
	}

	void testTriangleCapsuleContactCalculation(std::string scenario, Vector3d cv0, Vector3d cv1, bool contactFound,
		bool checkPenetrationPoints = false, Vector3d pointOnTriangle = Vector3d::Zero(),
		Vector3d pointOnCapsule = Vector3d::Zero())
	{
		MockTriangle t(Vector3d(5, -5, 0), Vector3d(0, 5, 0), Vector3d(-5, -5, 0));
		MockCapsule c(MockCapsule(cv0, cv1, 0.5));

		for (const auto& transform : m_transforms)
		{
			MockTriangle transformedT(t);
			transformedT.transform(transform);
			MockCapsule transformedC(c);
			transformedC.transform(transform);
			testTriangleCapsuleContactCalculation(TriangleCapsuleTestCase(scenario, transformedT, transformedC,
				contactFound, checkPenetrationPoints, (transform * pointOnTriangle).eval(),
				(transform * pointOnCapsule).eval()));
		}
	}

private:
	// List of random transformations.
	std::vector<SurgSim::Math::RigidTransform3d> m_transforms;
};

TEST_F(TriangleCapsuleContactCalculationTest, TestCase1)
{
	testTriangleCapsuleContactCalculation("(Perpendicular) Capsule far away from triangle",
		Vector3d(0.0, 0.0, 10.0), Vector3d(0.0, 0.0, 5.0), false);
}

TEST_F(TriangleCapsuleContactCalculationTest, TestCase2)
{
	testTriangleCapsuleContactCalculation("(Perpendicular) Capsule far away from triangle",
		Vector3d(0.0, 0.0, 10.0), Vector3d(0.0, 0.0, 5.0), false);
}

TEST_F(TriangleCapsuleContactCalculationTest, TestCase3)
{
	testTriangleCapsuleContactCalculation("(Perpendicular) Capsule just away triangle",
		Vector3d(0.0, 0.0, 10.0), Vector3d(0.0, 0.0, 0.500001), false);
}

TEST_F(TriangleCapsuleContactCalculationTest, TestCase4)
{
	testTriangleCapsuleContactCalculation("(Perpendicular) Capsule just touching triangle",
		Vector3d(0.0, 0.0, 10.0), Vector3d(0.0, 0.0, 0.49999), true, true, Vector3d::Zero(), Vector3d(0, 0, -0.00001));
}

TEST_F(TriangleCapsuleContactCalculationTest, TestCase5)
{
	testTriangleCapsuleContactCalculation("(Perpendicular) Capsule axis just away from triangle",
		Vector3d(0.0, 0.0, 10.0), Vector3d(0.0, 0.0, 0.0001), true, true, Vector3d::Zero(), Vector3d(0, 0, -0.4999));
}

TEST_F(TriangleCapsuleContactCalculationTest, TestCase6)
{
	testTriangleCapsuleContactCalculation("(Perpendicular) Capsule axis just touching triangle",
		Vector3d(0.0, 0.0, 10.0), Vector3d(0.0, 0.0, -0.0001), true, true, Vector3d::Zero(), Vector3d(0, 0, -0.5001));
}

TEST_F(TriangleCapsuleContactCalculationTest, TestCase7)
{
	testTriangleCapsuleContactCalculation("(Angled) Capsule far away from triangle",
		Vector3d(1.0, 1.0, 10.0), Vector3d(0.0, 0.0, 5.0), false);
}

TEST_F(TriangleCapsuleContactCalculationTest, TestCase8)
{
	testTriangleCapsuleContactCalculation("(Angled) Capsule just away triangle",
		Vector3d(1.0, 1.0, 10.0), Vector3d(0.0, 0.0, 0.500001), false);
}

TEST_F(TriangleCapsuleContactCalculationTest, TestCase9)
{
	testTriangleCapsuleContactCalculation("(Angled) Capsule just touching triangle",
		Vector3d(1.0, 1.0, 10.0), Vector3d(0.0, 0.0, 0.49999), true, true, Vector3d::Zero(), Vector3d(0, 0, -0.00001));
}

TEST_F(TriangleCapsuleContactCalculationTest, TestCase10)
{
	testTriangleCapsuleContactCalculation("(Angled) Capsule axis just away from triangle",
		Vector3d(1.0, 1.0, 10.0), Vector3d(0.0, 0.0, 0.0001), true, true, Vector3d::Zero(), Vector3d(0, 0, -0.4999));
}

TEST_F(TriangleCapsuleContactCalculationTest, TestCase11)
{
	testTriangleCapsuleContactCalculation("(Angled) Capsule axis just touching triangle",
		Vector3d(1.0, 1.0, 10.0), Vector3d(0.0, 0.0, -0.0001), true, true, Vector3d::Zero(), Vector3d(0, 0, -0.5001));
}

TEST_F(TriangleCapsuleContactCalculationTest, TestCase12)
{
	testTriangleCapsuleContactCalculation("Capsule axis through triangle",
		Vector3d(0.0, 6.0, 1.0), Vector3d(0.0, -6.0, -1.0), true, false);
}

TEST_F(TriangleCapsuleContactCalculationTest, TestCase13)
{
	testTriangleCapsuleContactCalculation("(Angled, near edge 1) Capsule far away from triangle",
		Vector3d(4.0, 0.0, 5.0), Vector3d(2.4, 0.0, 2.0), false);
}

TEST_F(TriangleCapsuleContactCalculationTest, TestCase14)
{
	testTriangleCapsuleContactCalculation("(Angled, near edge 1) Capsule just away triangle",
		Vector3d(4.0, 0.0, 5.0), Vector3d(2.4, 0.0, 0.500001), false);
}

TEST_F(TriangleCapsuleContactCalculationTest, TestCase15)
{
	testTriangleCapsuleContactCalculation("(Angled, near edge 1) Capsule just touching triangle",
		Vector3d(4.0, 0.0, 5.0), Vector3d(2.4, 0.0, 0.49999), true,
		true, Vector3d(2.4, 0.0, 0.0), Vector3d(2.4, 0.0,-0.00001));
}

TEST_F(TriangleCapsuleContactCalculationTest, TestCase16)
{
	testTriangleCapsuleContactCalculation("(Angled, near edge 1) Capsule axis just away from triangle",
		Vector3d(4.0, 0.0, 5.0), Vector3d(2.4, 0.0, 0.0001), true,
		true, Vector3d(2.4, 0.0, 0.0), Vector3d(2.4, 0.0, -0.4999));
}

TEST_F(TriangleCapsuleContactCalculationTest, TestCase17)
{
	testTriangleCapsuleContactCalculation("(Angled, near edge 1) Capsule axis just touching triangle",
		Vector3d(4.0, 0.0, 5.0), Vector3d(2.4, 0.0, -0.0001), true,
		true, Vector3d(2.4, 0.0, 0.0), Vector3d(2.4, 0.0, -0.5001));
}

TEST_F(TriangleCapsuleContactCalculationTest, TestCase18)
{
	testTriangleCapsuleContactCalculation("(Angled, near edge 1) Capsule axis inside triangle",
		Vector3d(4.0, 0.0, 5.0), Vector3d(2.4, 0.0, -0.5), true);
}

TEST_F(TriangleCapsuleContactCalculationTest, TestCase19)
{
	testTriangleCapsuleContactCalculation("(Angled, near edge 2) Capsule far away from triangle",
		Vector3d(-4.0, 0.0, 5.0), Vector3d(-2.4, 0.0, 2.0), false);
}

TEST_F(TriangleCapsuleContactCalculationTest, TestCase20)
{
	testTriangleCapsuleContactCalculation("(Angled, near edge 2) Capsule just away triangle",
		Vector3d(-4.0, 0.0, 5.0), Vector3d(-2.4, 0.0, 0.500001), false);
}

TEST_F(TriangleCapsuleContactCalculationTest, TestCase21)
{
	testTriangleCapsuleContactCalculation("(Angled, near edge 2) Capsule just touching triangle",
		Vector3d(-4.0, 0.0, 5.0), Vector3d(-2.4, 0.0, 0.49999), true,
		true, Vector3d(-2.4, 0.0, 0.0), Vector3d(-2.4, 0.0, -0.00001));
}

TEST_F(TriangleCapsuleContactCalculationTest, TestCase22)
{
	testTriangleCapsuleContactCalculation("(Angled, near edge 2) Capsule axis just away from triangle",
		Vector3d(-4.0, 0.0, 5.0), Vector3d(-2.4, 0.0, 0.0001), true,
		true, Vector3d(-2.4, 0.0, 0.0), Vector3d(-2.4, 0.0, -0.4999));
}

TEST_F(TriangleCapsuleContactCalculationTest, TestCase23)
{
	testTriangleCapsuleContactCalculation("(Angled, near edge 2) Capsule axis just touching triangle",
		Vector3d(-4.0, 0.0, 5.0), Vector3d(-2.4, 0.0, -0.0001), true,
		true, Vector3d(-2.4, 0.0, 0.0), Vector3d(-2.4, 0.0, -0.5001));
}

TEST_F(TriangleCapsuleContactCalculationTest, TestCase24)
{
	testTriangleCapsuleContactCalculation("(Angled, near edge 2) Capsule axis inside triangle",
		Vector3d(-4.0, 0.0, 5.0), Vector3d(-2.4, 0.0, -0.5), true);
}

TEST_F(TriangleCapsuleContactCalculationTest, TestCase25)
{
	testTriangleCapsuleContactCalculation("(Angled, near edge 3) Capsule far away from triangle",
		Vector3d(0.0, -6.0, 5.0), Vector3d(0.0, -4.8, 2.0), false);
}

TEST_F(TriangleCapsuleContactCalculationTest, TestCase26)
{
	testTriangleCapsuleContactCalculation("(Angled, near edge 3) Capsule just away triangle",
		Vector3d(0.0, -6.0, 5.0), Vector3d(0.0, -4.8, 0.500001), false);
}

TEST_F(TriangleCapsuleContactCalculationTest, TestCase27)
{
	testTriangleCapsuleContactCalculation("(Angled, near edge 3) Capsule just touching triangle",
		Vector3d(0.0, -6.0, 5.0), Vector3d(0.0, -4.8, 0.49999), true,
		true, Vector3d(0,-4.8,0), Vector3d(0,-4.8,-0.00001));
}

TEST_F(TriangleCapsuleContactCalculationTest, TestCase28)
{
	testTriangleCapsuleContactCalculation("(Angled, near edge 3) Capsule axis just away from triangle",
		Vector3d(0.0, -6.0, 5.0), Vector3d(0.0, -4.8, 0.0001), true,
		true, Vector3d(0.0, -4.8, 0.0), Vector3d(0.0, -4.8, -0.4999));
}

TEST_F(TriangleCapsuleContactCalculationTest, TestCase29)
{
	testTriangleCapsuleContactCalculation("(Angled, near edge 3) Capsule axis just touching triangle",
		Vector3d(0.0, -6.0, 5.0), Vector3d(0.0, -4.8, -0.0001), true,
		true, Vector3d(0.0 ,-4.8, 0.0), Vector3d(0.0, -4.8, -0.5001));
}

TEST_F(TriangleCapsuleContactCalculationTest, TestCase30)
{
	testTriangleCapsuleContactCalculation("(Angled, near edge 3) Capsule axis inside triangle",
		Vector3d(0.0, -6.0, 5.0), Vector3d(0.0, -4.8, -0.5), true);
}

TEST_F(TriangleCapsuleContactCalculationTest, TestCase31)
{
	testTriangleCapsuleContactCalculation("(Angled, at center) Capsule axis inside triangle",
		Vector3d(0.0, 0.0, -0.01), Vector3d(0.0, -0.1, 3.0), true);
}

TEST_F(TriangleCapsuleContactCalculationTest, TestCase32)
{
	MockTriangle t(Vector3d(0.0085640543450962274, -0.17216352338611343, 0.032793871473806267),
		Vector3d(0.17462358883922274, -0.16815838417660384, 0.13533384863957792),
		Vector3d(0.16119856859908893, -0.21686057517329485, 0.072690609592390418));
	MockCapsule c(Vector3d(0.18735007841383616, -0.28690200129741239, 0.11717293620266563),
		Vector3d(0.10383485572751404, -0.17364876935318688, 0.046339120022104330), 1e-5);

	testTriangleCapsuleContactCalculation(
		TriangleCapsuleTestCase("Failing test 1", t, c, true, false, Vector3d(), Vector3d()));
}

TEST_F(TriangleCapsuleContactCalculationTest, TestCase33)
{
	MockTriangle t(Vector3d(5, -5, 0), Vector3d(0, 5, 0), Vector3d(-5, -5, 0));
	MockCapsule c(Vector3d(0, -4, -1), Vector3d(0, -5 + 1e-9, 0), 1e-9);

	testTriangleCapsuleContactCalculation(
		TriangleCapsuleTestCase("Failing test 2", t, c, true, false, Vector3d(), Vector3d()));
}

TEST_F(TriangleCapsuleContactCalculationTest, TestCase34)
{
	MockTriangle t(Vector3d(0005.55605,0087.7003,-0047.2398), Vector3d(0000.110703,0113.919,-0039.387),
		Vector3d(-0005.57197,0087.8735,-0047.1883));
	MockCapsule c(Vector3d(0,0115.5,-0045.), Vector3d(0,0110.,-0040.), 0000.1);

	testTriangleCapsuleContactCalculation(
		TriangleCapsuleTestCase("Failing test 3", t, c, true, false, Vector3d(), Vector3d()));
}

TEST_F(TriangleCapsuleContactCalculationTest, TestCase35)
{
	MockTriangle t(Vector3d(0.013092,0.108735,-0.0290345), Vector3d(0.0077754,0.135282,-0.0222713),
		Vector3d(0.00196512,0.108977,-0.0290394));
	MockCapsule c(Vector3d(0.00207912,0.109781,-0.0298305), Vector3d(0.00309017,0.109511,-0.0247458), 0.0001);

	testTriangleCapsuleContactCalculation(
		TriangleCapsuleTestCase("Failing test 4", t, c, true, false, Vector3d(), Vector3d()));
}

TEST_F(TriangleCapsuleContactCalculationTest, TestCase36)
{
	auto penetration = Geometry::DistanceEpsilon * 0.5;
	auto cv0 = Vector3d(0.0, 0.0, penetration);
	auto cv1 = Vector3d(0.01, 0.01, -1.0);
	Vector3d trianglePoint = { cv1.x(), cv1.y(), 0.0 };
	Vector3d capsulePoint = { cv1.x(), cv1.y(), cv1.z() - 0.5 };
	testTriangleCapsuleContactCalculation(
		"Failing test 5 (Angled capsule axis penetrating triangle, less than DistanceEpsilon on positive side)",
		cv0, cv1, true, true, trianglePoint, capsulePoint);
}

TEST_F(TriangleCapsuleContactCalculationTest, TestCase37)
{
	auto offset = Geometry::DistanceEpsilon * 0.5;
	auto cv0 = Vector3d(0.0, 0.0, offset);
	auto cv1 = Vector3d(0.01, 0.01, offset * 0.1);
	Vector3d trianglePoint = { cv1.x(), cv1.y(), 0.0 };
	Vector3d capsulePoint = { cv1.x(), cv1.y(), cv1.z() - 0.5 };
	testTriangleCapsuleContactCalculation(
		"Failing test 6 (Angled capsule axis, both points less than DistanceEpsilon from face in positive direction)",
		cv0, cv1, true, true, trianglePoint, capsulePoint);
}

TEST_F(TriangleCapsuleContactCalculationTest, TestCase38)
{
	auto tv0 = Vector3d(97.391948688286129, 41.587250765721723, 6.4762957459524273);
	auto tv1 = Vector3d(97.391945808859896, 41.587187360783867, 6.476308949921625);
	auto tv2 = Vector3d(97.391932515918165, 41.587204342013217, 6.4762963528486324);
	auto cv0 = Vector3d(97.391955981452543, 41.587241454620784, 6.4762810073613636);
	auto cv1 = Vector3d(97.391937572450138, 41.58725489458393, 6.4763193175101549);

	MockTriangle tri(tv0, tv1, tv2);
	MockCapsule c(cv0, cv1, 0.0001);
	testTriangleCapsuleContactCalculation(
		TriangleCapsuleTestCase("Failing test 7 (Capsule axis passes within epsilon of one edge)",
			tri, c, true, false, Vector3d(), Vector3d()));
}

TEST_F(TriangleCapsuleContactCalculationTest, TestCase39)
{
	auto offset = Geometry::DistanceEpsilon * 0.5;
	auto cv0 = Vector3d(0.0, 0.0, -offset);
	auto cv1 = Vector3d(-6.0, 0.0, -1.0);
	Vector3d trianglePoint = { -2.52048079801, -0.040961596024, 0.0 };
	Vector3d capsulePoint = { -2.52048079801, -0.040961596024, -0.925273150684 };
	testTriangleCapsuleContactCalculation(
		"Failing test 8 (cvTop touching underside of triangle, cvBottom projects outside of triangle)",
		cv0, cv1, true, true, trianglePoint, capsulePoint);
}

TEST_F(TriangleCapsuleContactCalculationTest, TestCase40)
{
	auto offset = Geometry::DistanceEpsilon * 0.5;
	auto cv0 = Vector3d(0.0, 0.0, -offset);
	auto cv1 = Vector3d(0.0, 10.0, -1.0);
	Vector3d trianglePoint = { 0.0, 5.0, 0.0 };
	Vector3d capsulePoint = { 0.0, 5.0, -1.00249378108 };
	testTriangleCapsuleContactCalculation(
		"cvTop touching underside of triangle, cvBottom projects outside of triangle at corner",
		cv0, cv1, true, true, trianglePoint, capsulePoint);
}

TEST_F(TriangleCapsuleContactCalculationTest, TestCase41)
{
	auto offset = Geometry::DistanceEpsilon * 0.5;
	auto cv0 = Vector3d(1.0, 0.0, -offset);
	auto cv1 = Vector3d(1.0, 10.0, -1.0);
	Vector3d trianglePoint = { 0.9024099927097938, 3.195180014580413, 0.0 };
	Vector3d capsulePoint = { 0.9024099927097938, 3.195180014580413, -0.81234753833176 };
	testTriangleCapsuleContactCalculation(
		"cvTop touching underside of triangle near corner, cvBottom projects outside nearby edge but would cross another edge",
		cv0, cv1, true, true, trianglePoint, capsulePoint);
}

TEST_F(TriangleCapsuleContactCalculationTest, TestCase42)
{
	auto offset = Geometry::DistanceEpsilon * 0.5;
	auto cv0 = Vector3d(0.0, 4.0, -offset);
	auto cv1 = Vector3d(0.0, 5.2, -1.0);
	Vector3d trianglePoint = { 0.0, 5.0, 0.0 };
	Vector3d capsulePoint = { 0.0, 5.0, -1.4582575695 };
	testTriangleCapsuleContactCalculation(
		"cvTop touching underside of triangle, cvBottom is outside one of the corners and is the axis penetration point",
		cv0, cv1, true, true, trianglePoint, capsulePoint);
}

TEST_F(TriangleCapsuleContactCalculationTest, TestCase43)
{
	auto offset = Geometry::DistanceEpsilon * 0.5;
	auto cv0 = Vector3d(0.0, 4.0, -offset);
	auto cv1 = Vector3d(0.0, 5.2, -1.0);
	Vector3d trianglePoint = { 0.0, 5.0, 0.0 };
	Vector3d capsulePoint = { 0.0, 5.0, -1.4582575695 };
	testTriangleCapsuleContactCalculation(
		"cvTop touching underside of triangle, cvBottom is outside one of the corners and is the axis penetration point",
		cv0, cv1, true, true, trianglePoint, capsulePoint);
}

TEST_F(TriangleCapsuleContactCalculationTest, TestCase44)
{
	auto offset = Geometry::DistanceEpsilon * 0.5;
	auto cv0 = Vector3d(0.0, 0.0, -offset);
	auto cv1 = Vector3d(0.0, -5.2, -1.0);
	Vector3d trianglePoint = { 0.0, -5.0, 0.0 };
	Vector3d capsulePoint = { 0.0, -5.0, -1.47070008827};
	testTriangleCapsuleContactCalculation(
		"cvTop touching underside of triangle, cvBottom is slightly more than radius from an edge, the intersection of the cylinder with the plane is not angled",
		cv0, cv1, true, true, trianglePoint, capsulePoint);
}

TEST_F(TriangleCapsuleContactCalculationTest, TestCase45)
{
	auto tv0 = Vector3d(-645.19016174767671, -948.40360069058988, 557.13683782102282);
	auto tv1 = Vector3d(-645.19079664488879, -948.40351561976593, 557.1371785126388);
	auto tv2 = Vector3d(-645.19085390115458, -948.40351914770122, 557.13641794930516);
	auto cv0 = Vector3d(-645.19062914255881, -948.40354467068505, 557.13662574653279);
	auto cv1 = Vector3d(-645.19007499326176, -948.4033066658659, 557.13640896655102);
	MockTriangle tri(tv0, tv1, tv2);
	MockCapsule c(cv0, cv1, 0.0001);
	testTriangleCapsuleContactCalculation(
		TriangleCapsuleTestCase("axis touches triangle, bottom is not in triangle",
			tri, c, true, false, Vector3d(), Vector3d()));
}

TEST_F(TriangleCapsuleContactCalculationTest, TestCase46)
{
	auto tv0 = Vector3d(2.426500005027252, -59.28773167314293, -79.62747904307153);
	auto tv1 = Vector3d(2.427152773252143, -59.28749935293187, -79.62723787298583);
	auto tv2 = Vector3d(2.426744702798851, -59.28790033650574, -79.62779546198951);
	auto cv0 = Vector3d(2.426759423757323, -59.28817822384058, -79.62776566361566);
	auto cv1 = Vector3d(2.426787192879603, -59.28777390068916, -79.62760270556898);
	MockTriangle tri(tv0, tv1, tv2);
	MockCapsule c(cv0, cv1, 0.0001);
	testTriangleCapsuleContactCalculation(
		TriangleCapsuleTestCase("axis touching triangle, bottom is outside of triangle on two sides, the penetration point is under a vertex on the cylinder",
			tri, c, true, false, Vector3d(), Vector3d()));
}

TEST_F(TriangleCapsuleContactCalculationTest, TestCase47)
{
	auto tv0 = Vector3d(-0.0001463164258976192, -0.0002230732815911322, 0.0004572077078934273);
	auto tv1 = Vector3d(-4.340778882491997e-05, 0.0003900046473060158, -0.000112293059937122);
	auto tv2 = Vector3d(-5.698797769697528e-05, 0.0001870145299064479, 0.0001506273581337782);
	auto cv0 = Vector3d(-0.0001421079719436742, 0.0001280347667781626, 0.0003048158910791373);
	auto cv1 = Vector3d(0.0002648019331809418, 0.0004165889038605414, -0.0004404029045147011);
	MockTriangle tri(tv0, tv1, tv2);
	MockCapsule c(cv0, cv1, 0.0001);
	testTriangleCapsuleContactCalculation(
		TriangleCapsuleTestCase("axis touching triangle, bottom is outside of triangle on two sides, the penetration point is under a vertex (sometimes on bottom, sometimes on cylinder)",
			tri, c, true, false, Vector3d(), Vector3d()));
}

TEST_F(TriangleCapsuleContactCalculationTest, TestCase48)
{
	auto tv0 = Vector3d(-1, 0, 0);
	auto tv1 = Vector3d(1, 0, 0);
	auto tv2 = Vector3d(1, -1, 0);
	auto cv0 = Vector3d(0, -0.1, 0);
	auto cv1 = Vector3d(0, 1, 0);
	MockTriangle tri(tv0, tv1, tv2);
	MockCapsule c(cv0, cv1, 0.001);
	testTriangleCapsuleContactCalculation(
		TriangleCapsuleTestCase("axis coplanar with triangle, one endpoint in triangle",
			tri, c, true, false, Vector3d(), Vector3d()));
}

TEST_F(TriangleCapsuleContactCalculationTest, TestCase49)
{
	auto tv0 = Vector3d(-1, 0, 0);
	auto tv1 = Vector3d(1, 0, 0);
	auto tv2 = Vector3d(1, -1, 0);
	auto cv0 = Vector3d(0, 0, 0);
	auto cv1 = Vector3d(0, 1, 0);
	MockTriangle tri(tv0, tv1, tv2);
	MockCapsule c(cv0, cv1, 0.001);
	testTriangleCapsuleContactCalculation(
		TriangleCapsuleTestCase("axis coplanar with triangle, one endpoint on triangle edge",
			tri, c, true, false, Vector3d(), Vector3d()));
}

TEST_F(TriangleCapsuleContactCalculationTest, FileTest)
{
	auto tv0 = Vector3d(-0.0001463164258976192, -0.0002230732815911322, 0.0004572077078934273);
	auto tv1 = Vector3d(-4.340778882491997e-05, 0.0003900046473060158, -0.000112293059937122);
	auto tv2 = Vector3d(-5.698797769697528e-05, 0.0001870145299064479, 0.0001506273581337782);
	auto cv0 = Vector3d(-0.0001421079719436742, 0.0001280347667781626, 0.0003048158910791373);
	auto cv1 = Vector3d(0.0002648019331809418, 0.0004165889038605414, -0.0004404029045147011);
	auto tn = tv0.cross(tv1).normalized();
	double cr = 0.1234;

	TriangleCapsuleContactCalculation::TriangleCapsuleContactCalculation<double, 0>
		calc(tv0, tv1, tv2, tn, cv0, cv1, cr);

	calc.toFile("test.bin");

	TriangleCapsuleContactCalculation::TriangleCapsuleContactCalculation<double, 0>
		other(Vector3d(), Vector3d(), Vector3d(), Vector3d(), Vector3d(), Vector3d(), 0.0);

	other.fromFile("test.bin");

	EXPECT_EQ(calc.m_tv0, other.m_tv0);
	EXPECT_EQ(calc.m_tv1, other.m_tv1);
	EXPECT_EQ(calc.m_tv2, other.m_tv2);
	EXPECT_EQ(calc.m_cvTop, other.m_cvTop);
	EXPECT_EQ(calc.m_cvBottom, other.m_cvBottom);
	EXPECT_EQ(calc.m_cr, other.m_cr);
}

TEST_F(TriangleCapsuleContactCalculationTest, TestFromFile)
{
	SurgSim::Framework::ApplicationData data("config.txt");
	std::string fileName = "TriangleCapsuleContactException.bin";
	std::string path = data.findFile(fileName);
	ASSERT_TRUE(!path.empty()) << "Can not locate file " << fileName;

	TriangleCapsuleContactCalculation::TriangleCapsuleContactCalculation<double, 0>
		test(Vector3d(), Vector3d(), Vector3d(), Vector3d(), Vector3d(), Vector3d(), 0.0);
	test.fromFile(path);

	MockTriangle tri(test.m_tv0, test.m_tv1, test.m_tv2, test.m_tn);
	MockCapsule c(test.m_cvTop, test.m_cvBottom, test.m_cr);
	testTriangleCapsuleContactCalculation(
		TriangleCapsuleTestCase("TestFromFile", tri, c, true, false, Vector3d(), Vector3d()));
}

}
}


text:
;Intel® 64 and IA-32 Architectures Software Developer's Manual. Vol 1 (2015-01)
;5.1 GENERAL-PURPOSE INSTRUCTIONS
;5.1.1         Data Transfer Instructions
mov|cmove|cmovz|cmovne|cmovnz|cmova|cmovnbe|cmovae|cmovnb|cmovb|cmovnae
cmovbe|cmovna|cmovg|cmovnle|cmovge|cmovnl|cmovl|cmovnge|cmovle|cmovng
cmovc|cmovnc|cmovo|cmovno|cmovs|cmovns|cmovp|cmovpe|cmovnp|cmovpo
xchg|bswap|xadd|cmpxchg|cmpxchg8b
push|pop|pusha|pushad|popa|popad
cwd|cdq|cbw|cwde
movsx|movzx
;5.1.2         Binary Arithmetic Instructions
adcx|adox|add|adc|sub|sbb|imul|mul|idiv|div|inc|dec|neg|cmp|
;5.1.3         Decimal Arithmetic Instructions
daa|das|aaa|aas|aam|aad
;5.1.4 Logical Instructions
and|or|xor|not
;5.1.5         Shift and Rotate Instructions
sar|shr|sal|shl|shrd|shld|ror|rol|rcr|rcl
;5.1.6         Bit and Byte Instructions
bt|bts|btr|btc|bsf|bsr
sete|setz|setne|setnz|seta|setnbe|setae|setnb|setnc|setb|setnae|setc
setbe|setna|setg|setnle|setge|setnl|setl|setnge|setle|setng
sets|setns|seto|setno|setpe|setp|setpo|setnp
test|crc32|popcnt
;5.1.7         Control Transfer Instructions
jmp|je|jz|jne|jnz|ja|jnbe|jae|jnb|jb|jnae|jbe|jna|jg|jnle|jge|jnl|jl|jnge|jle|jng
jc|jnc|jo|jno|js|jns|jpo|jnp|jpe|jp|jcxz|jecxz
loop|loopz|loope|loopnz|loopne
call|ret|iret|int|into|bound|enter|leave
;5.1.8 String Instructions
movs|movsb|movs|movsw|movs|movsd
cmps|cmpsb|cmps|cmpsw|cmps|cmpsd
scas|scasb|scas|scasw|scas|scasd
lods|lodsb|lods|lodsw|lods|lodsd
stos|stosb|stos|stosw|stos|stosd
rep|repe|repz|repne|repnz
;5.1.9 I/O Instructions
in|out|ins|insb|ins|insw|ins|insd|outs|outsb|outs|outsw|outs|outsd
;5.1.10      Enter and Leave Instructions
enter|leave
;5.1.11      Flag Control (EFLAG) Instructions
stc|clc|cmc|cld|std|lahf|sahf|pushf|pushfd|popf|popfd|sti|cli
;5.1.12      Segment Register Instructions
lds|les|lfs|lgs|lss
;5.1.13 Miscellaneous Instructions
lea|nop|ud2|xlat|xlatb|cpuid|movbe|prefetchw|prefetchwt1
;5.1.14      Random Number Generator Instructions
rdrand|rdseed
;5.1.15 BMI1, BMI2
andn|bextr|blsi|blsmsk|blsr|bzhi|lzcnt|mulx|pdep|pext|rorx|sarx|shlx|shrx|tzcnt

;5.2         X87 FPU INSTRUCTIONS
;5.2.1         x87 FPU Data Transfer Instructions
fld|fst|fstp|fild|fist|fistp|fbld|fbstp|fxch
fcmove|fcmovne|fcmovb|fcmovbe|fcmovnb|fcmovnbe|fcmovu|fcmovnu
;5.2.2         x87 FPU Basic Arithmetic Instructions
fadd|faddp|fiadd|fsub|fsubp|fisub|fsubr|fsubrp|fisubr
fmul|fmulp|fimul|fdiv|fdivp|fidiv|fdivr|fdivrp|fidivr
fprem|fprem1|fabs|fchs|frndint|fscale|fsqrt|fxtract
;5.2.3         x87 FPU Comparison Instructions
fcom|fcomp|fcompp|fucom|fucomp|fucompp|ficom|ficomp|fcomi|fucomi|fcomip|fucomip|ftst|fxam
;5.2.4         x87 FPU Transcendental Instructions
fsin|fcos|fsincos|fptan|fpatan|f2xm1|fyl2x|fyl2xp1
;5.2.5         x87 FPU Load Constants Instructions
fld1|fldz|fldpi|fldl2e|fldln2|fldl2t|fldlg2
;5.2.6         x87 FPU Control Instructions
fincstp|fdecstp|ffree|finit|fninit|fclex|fnclex|fstcw|fnstcw
fldcw|fstenv|fnstenv|fldenv|fsave|fnsave|frstor|fstsw|fnstsw
wait|fwait|fnop

;5.3         X87 FPU AND SIMD STATE MANAGEMENT INSTRUCTIONS
fxsave|fxrstor

;5.4 MMX™ INSTRUCTIONS
;5.4.1         MMX Data Transfer Instructions
movd|movq
;5.4.2 MMX Conversion Instructions
packsswb|packssdw|packuswb|punpckhbw|punpckhwd|punpckhdq|punpcklbw|punpcklwd|punpckldq
;5.4.3         MMX Packed Arithmetic Instructions
paddb|paddw|paddd|paddsb|paddsw|paddusb|paddusw
psubb|psubw|psubd|psubsb|psubsw|psubusb|psubusw
pmulhw|pmullw|pmaddwd
;5.4.4         MMX Comparison Instructions
pcmpeqb|pcmpeqw|pcmpeqd|pcmpgtb|pcmpgtw|pcmpgtd
;5.4.5         MMX Logical Instructions
pand|pandn|por|pxor
;5.4.6         MMX Shift and Rotate Instructions
psllw|pslld|psllq|psrlw|psrld|psrlq|psraw|psrad
;5.4.7         MMX State Management Instructions
emms

;5.5 SSE INSTRUCTIONS
;5.5.1         SSE SIMD Single-Precision Floating-Point Instructions
;5.5.1.1        SSE Data Transfer Instructions
movaps|movups|movhps|movhlps|movlps|movlhps|movmskps|movss
;5.5.1.2        SSE Packed Arithmetic Instructions
addps|addss|subps|subss|mulss|mulps|divps|divss
rcpps|rcpss|sqrtps|sqrtss|rsqrtps|rsqrtss
maxps|maxss|minps|minss
;5.5.1.3        SSE Comparison Instructions
cmpps|cmpss|comiss|ucomiss
;5.5.1.4        SSE Logical Instructions
andps|andnps|orps|xorps
;5.5.1.5        SSE Shuffle and Unpack Instructions
shufps|unpckhps|unpcklps
;5.5.1.6        SSE Conversion Instructions
cvtpi2ps|cvtsi2ss|cvtps2pi|cvttps2pi|cvtss2si|cvttss2si
;5.5.2         SSE MXCSR State Management Instructions
ldmxcsr|stmxcsr
;5.5.3         SSE 64-Bit SIMD Integer Instructions
pavgb|pavgw|pextrw|pinsrw|pmaxub|pmaxsw|pminub|pminsw|pmovmskb|pmulhuw|psadbw|pshufw
;5.5.4         SSE Cacheability Control, Prefetch, and Instruction Ordering Instructions
maskmovq|movntps|sfence
prefetchnta|prefetcht0|prefetcht1|prefetcht2|prefetchw|prefetchwt1

;5.6 SSE2 INSTRUCTIONS
;5.6.1         SSE2 Packed and Scalar Double-Precision Floating-Point Instructions
;5.6.1.1        SSE2 Data Movement Instructions
movapd|movupd|movhpd|movlpd|movmskpd|movsd
;5.6.1.2        SSE2 Packed Arithmetic Instructions
addpd|addsd|subpd|subsd|mulpd|mulsd|divpd|divsd|sqrtpd|sqrtsd|maxpd|maxsd|minpd|minsd
;5.6.1.3        SSE2 Logical Instructions
andpd|andnpd|orpd|xorpd
;5.6.1.4        SSE2 Compare Instructions
cmppd|cmpsd|comisd|ucomisd
;5.6.1.5        SSE2 Shuffle and Unpack Instructions
shufpd|unpckhpd|unpcklpd
;5.6.1.6        SSE2 Conversion Instructions
cvtpd2pi|cvttpd2pi|cvtpi2pd|cvtpd2dq|cvttpd2dq|cvtdq2pd|cvtps2pd|cvtpd2ps|cvtss2sd|cvtsd2ss|cvtsd2si|cvttsd2si|cvtsi2sd
;5.6.2         SSE2 Packed Single-Precision Floating-Point Instructions
cvtdq2ps|cvtps2dq|cvttps2dq
;5.6.3         SSE2 128-Bit SIMD Integer Instructions
movdqa|movdqu|movq2dq|movdq2q|pmuludq|paddq|psubq|pshuflw|pshufhw|pshufd|pslldq|psrldq|punpckhqdq|punpcklqdq
;5.6.4         SSE2 Cacheability Control and Ordering Instructions
clflush|lfence|mfence|pause|maskmovdqu|movntpd|movntdq|movnti

;5.7 SSE3 INSTRUCTIONS
;5.7.1         SSE3 x87-FP Integer Conversion Instruction
fisttp
;5.7.2         SSE3 Specialized 128-bit Unaligned Data Load Instruction
lddqu
;5.7.3         SSE3 SIMD Floating-Point Packed ADD/SUB Instructions
addsubps|addsubpd
;5.7.4         SSE3 SIMD Floating-Point Horizontal ADD/SUB Instructions
haddps|hsubps|haddpd|hsubpd
;5.7.5         SSE3 SIMD Floating-Point LOAD/MOVE/DUPLICATE Instructions
movshdup|movsldup|movddup
;5.7.6         SSE3 Agent Synchronization Instructions
monitor|mwait

;5.8 SUPPLEMENTAL STREAMING SIMD EXTENSIONS 3 (SSSE3) INSTRUCTIONS
;5.8.1 Horizontal Addition/Subtraction
phaddw|phaddsw|phaddd|phsubw|phsubsw|phsubd
;5.8.2         Packed Absolute Values
pabsb|pabsw|pabsd
;5.8.3         Multiply and Add Packed Signed and Unsigned Bytes
pmaddubsw
;5.8.4         Packed Multiply High with Round and Scale
pmulhrsw
;5.8.5         Packed Shuffle Bytes
pshufb
;5.8.6 Packed Sign
psignb|psignw|psignd
;5.8.7         Packed Align Right
palignr

;5.9 SSE4 INSTRUCTIONS

;5.10 SSE4.1 INSTRUCTIONS
;5.10.1      Dword Multiply Instructions
pmulld|pmuldq
;5.10.2      Floating-Point Dot Product Instructions
dppd|dpps
;5.10.3      Streaming Load Hint Instruction
movntdqa
;5.10.4      Packed Blending Instructions
blendpd|blendps|blendvpd|blendvps|pblendvb|pblendw
;5.10.5      Packed Integer MIN/MAX Instructions
pminuw|pminud|pminsb|pminsd|pmaxuw|pmaxud|pmaxsb|pmaxsd
;5.10.6      Floating-Point Round Instructions with Selectable Rounding Mode
roundps|roundpd|roundss|roundsd
;5.10.7      Insertion and Extractions from XMM Registers
extractps|insertps|pinsrb|pinsrd|pinsrq|pextrb|pextrw|pextrd|pextrq
;5.10.8      Packed Integer Format Conversions
pmovsxbw|pmovzxbw|pmovsxbd|pmovzxbd|pmovsxwd|pmovzxwd|pmovsxbq|pmovzxbq|pmovsxwq|pmovzxwq|pmovsxdq|pmovzxdq
;5.10.9      Improved Sums of Absolute Differences (SAD) for 4-Byte Blocks
mpsadbw
;5.10.10 Horizontal Search
phminposuw
;5.10.11 Packed Test
ptest
;5.10.12    Packed Qword Equality Comparisons
pcmpeqq
;5.10.13    Dword Packing With Unsigned Saturation
packusdw

;5.11       SSE4.2 INSTRUCTION SET
;5.11.1      String and Text Processing Instructions
pcmpestri|pcmpestrm|pcmpistri|pcmpistrm
;5.11.2 Packed Comparison SIMD integer Instruction
pcmpgtq

;5.12       AESNI AND PCLMULQDQ
aesdec|aesdeclast|aesenc|aesenclast|aesimc|aeskeygenassist|pclmulqdq

;5.13       INTEL® ADVANCED VECTOR EXTENSIONS (INTEL® AVX)
;Table 14-2.  Promoted 256-Bit and 128-bit Arithmetic AVX Instructions
sqrtps, sqrtpd, rsqrtps, rcpps
addps, addpd, subps, subpd
mulps, mulpd, divps, divpd
cvtps2pd, cvtpd2ps
cvtdq2ps, cvtps2dq
cvttps2dq, cvttpd2dq
cvtpd2dq, cvtdq2pd
minps, minpd, maxps, maxpd
haddpd, haddps, hsubpd, hsubps
cmpps, cmppd
addsubpd, addsubps, dpps
roundpd, roundps
;Table 14-3.  Promoted 256-bit and 128-bit Data Movement AVX Instructions
movaps, movapd, movdqa
movups, movupd, movdqu
movmskps, movmskpd
lddqu, movntps, movntpd, movntdq, movntdqa
movshdup, movsldup, movddup
;Table 14-3.  Promoted 256-bit and 128-bit Data Movement AVX Instructions
unpckhpd, unpckhps, unpcklpd
blendps, blendpd
shufpd, shufps, unpcklps
blendvps, blendvpd
ptest, movmskpd, movmskps
xorps, xorpd, orps, orpd
andnpd, andnps, andpd, andps
;Table 14-4.  256-bit AVX Instruction Enhancement
vbroadcastf128|vbroadcastsd|vbroadcastss|vextractf128|vinsertf128|vmaskmovps|vmaskmovpd|vmaskmovps|vmaskmovpd
vpermilpd|vpermilpd|vpermilps|vpermilps|vperm2f128|vtestps|vtestpd|vzeroall|vzeroupper
;Table 14-5.  Promotion of Legacy SIMD ISA to 128-bit Arithmetic AVX instruction
cvtpi2ps, cvtpi2pd, cvtpd2pi
cvttps2pi, cvttpd2pi, cvtps2pi
cvtsi2ss, cvtsi2sd, cvtsd2si
cvttss2si, cvttsd2si, cvtss2si
comisd, rsqrtss, rcpss
ucomiss, ucomisd, comiss
addss, addsd, subss, subsd
mulss, mulsd, divss, divsd
sqrtss, sqrtsd
cvtss2sd, cvtsd2ss
minss, minsd, maxss, maxsd
pand, pandn, por, pxor
pcmpgtb, pcmpgtw, pcmpgtd
pmaddwd, pmaddubsw
pavgb, pavgw, pmuludq
pcmpeqb, pcmpeqw, pcmpeqd
pmullw, pmulhuw, pmulhw
psubsw, paddsw, psadbw
paddusb, paddusw, paddsb
psubusb, psubusw, psubsb
pminub, pminsw
pmaxub, pmaxsw
paddb, paddw, paddd, paddq
psubb, psubw, psubd, psubq
psllw, pslld, psllq, psraw
psrlw, psrld, psrlq, psrad
phsubw, phsubd, phsubsw
phaddw, phaddd, phaddsw
pmulhrsw
psignb, psignw, psignd
pabsb, pabsw, pabsd
dppd
phminposuw, mpsadbw
pmaxsb, pmaxsd, pmaxud
pminsb, pminsd, pminud
pmaxuw, pminuw
pmovsxbw, pmovzxbw, pmovsxbd, pmovzxbd, pmovsxwd, pmovzxwd, pmovsxbq, pmovzxbq, pmovsxwq, pmovzxwq, pmovsxdq, pmovzxdq
pmuldq, pmulld
roundsd, roundss
popcnt
pcmpgtq
crc32
pcmpestri, pcmpestrm
pcmpistri, pcmpistrm
pclmulqdq
aesdec, aesdeclast
aesenc, aesenclast
aesimc, aeskeygenassist
;Table 14-6.  128-bit AVX Instruction Enhancement
vbroadcastss|vmaskmovps|vmaskmovpd|vmaskmovps|vmaskmovpd|vpermilpd|vpermilpd|vpermilps|vpermilps|vtestps|vtestpd
;Table 14-7.  Promotion of Legacy SIMD ISA to 128-bit Non-Arithmetic AVX instruction
movq2dq, movdq2q
ldmxcsr, stmxcsr
movss, movsd, cmpss, cmpsd
movhps, movhpd
movhps, movhpd
movlhps, movhlps
movq, movd
packuswb, packssdw, packsswb
punpckhbw, punpckhwd
punpcklbw, punpcklwd
punpckhdq, punpckldq
punpcklqdq, punpckhqdq
pshufhw, pshuflw, pshufd
pmovmskb, maskmovdqu
pand, pandn, por, pxor
pinsrw, pextrw
palignr, pshufb
extractps, insertps
packusdw, pcmpeqq
pblendvb, pblendw
pextrw, pextrb, pextrd, pextrq
pinsrb, pinsrd, pinsrq

;5.14 16-BIT FLOATING-POINT CONVERSION
vcvtph2ps|vcvtps2ph

;5.15 FUSED-MULTIPLY-ADD (FMA)
;Table 14-15.  FMA Instructions
vfmadd132pd|vfmadd213pd|vfmadd231pd
vfmadd132ps|vfmadd213ps|vfmadd231ps
vfmadd132sd|vfmadd213sd|vfmadd231sd
vfmadd132ss|vfmadd213ss|vfmadd231ss
vfmaddsub132pd|vfmaddsub213pd|vfmaddsub231pd
vfmaddsub132ps|vfmaddsub213ps|vfmaddsub231ps
vfmsubadd132pd|vfmsubadd213pd|vfmsubadd231pd
vfmsubadd132ps|vfmsubadd213ps|vfmsubadd231ps
vfmsub132pd|vfmsub213pd|vfmsub231pd
vfmsub132ps|vfmsub213ps|vfmsub231ps
vfmsub132sd|vfmsub213sd|vfmsub231sd
vfmsub132ss|vfmsub213ss|vfmsub231ss
vfnmadd132pd|vfnmadd213pd|vfnmadd231pd
vfnmadd132ps|vfnmadd213ps|vfnmadd231ps
vfnmadd132sd|vfnmadd213sd|vfnmadd231sd
vfnmadd132ss|vfnmadd213ss|vfnmadd231ss
vfnmsub132pd|vfnmsub213pd|vfnmsub231pd
vfnmsub132ps|vfnmsub213ps|vfnmsub231ps
vfnmsub132sd|vfnmsub213sd|vfnmsub231sd
vfnmsub132ss|vfnmsub213ss|vfnmsub231ss

;5.16       INTEL® ADVANCED VECTOR EXTENSIONS 2 (INTEL® AVX2)
;Table 14-18.  Promoted Vector Integer SIMD Instructions in AVX2
punpcklbw|punpcklwd|punpckldq|packsswb|pcmpgtb|pcmpgtw|pcmpgtd|packuswb
punpckhbw|punpckhwd|punpckhdq|packssdw|punpcklqdq|punpckhqdq|movd|movq|movdqa|movdqu
pshufd|pshufhw|pshuflw|pcmpeqb|pcmpeqw|pcmpeqd|movdqa|movdqu|pinsrw|pextrw
psrlw|psrld|psrlq|paddq|pmullw|pmovmskb|psubusb|psubusw|pminub|pand|paddusb|paddusw
pmaxub|pandn|pavgb|psraw|psrad|pavgw|pmulhuw|pmulhw|movntdq|psubsb|psubsw|pminsw
por|paddsb|paddsw|pmaxsw|pxor|lddqu|psllw|pslld|psllq|pmuludq|pmaddwd
psadbw|psubb|psubw|psubd|psubq|paddb|paddw|paddd|phaddw|phaddsw|phaddd
phsubw|phsubsw|phsubd|pmaddubsw|palignr|pshufb|pmulhrsw|psignb|psignw|psignd
pabsb|pabsw|pabsd|movntdqa|mpsadbw|packusdw|pblendvb|pblendw|pcmpeqq
pextrd|pextrq|pextrb|pextrw|phminposuw|pinsrb|pinsrd|pinsrq
pmaxsb|pmaxsd|pmaxud|pmaxuw|pminsb|pminsd|pminud|pminuw
pmovsxbw|pmovzxbw|pmovsxbd|pmovzxbd|pmovsxwd|pmovzxwd|pmovsxbq|pmovzxbq|pmovsxwq|pmovzxwq|pmovsxdq|pmovzxdq
pmuldq|pmulld|ptest|pcmpgtq|pcmpestri|pcmpestrm|pcmpistri|pcmpistrm
aesdec|aesdeclast|aesenc|aesenclast|aesimc|aeskeygenassist|pclmulqdq
;Table 14-19.   VEX-Only SIMD Instructions in AVX and AVX2
vbroadcasti128|vbroadcastf128
vbroadcastsd|vbroadcastsd
vbroadcastss|vbroadcastss
vextracti128|vextractf128
vinserti128|vinsertf128
vpmaskmovd|vmaskmovps
vpmaskmovq|vmaskmovpd
vpermilpd|vpermilps
vperm2i128|vperm2f128
vpermd|vpermps|vpermq|vpermpd
vtestpd|vtestps
vpblendd|vpsllvd|vpsllvq|vpsravd|vpsrlvd|vpsrlvq
vgatherdpd|vgatherdqpd|vgatherdps|vgatherdqps|vpgatherdd|vpgatherqd|vpgatherdq|vpgatherqq
;Table 14-20.  New Primitive in AVX2 Instructions
vpermd|vpermpd|vpermps|vpermq
vpsllvd|vpsllvq|vpsllvd|vpsllvq
vpsravd|vpsrlvd|vpsrlvq|vpsrlvd|vpsrlvq
vgatherdd|vgatherqd|vgatherdd|vgatherqd|vgatherdpd|vgatherqpd|vgatherdpd|vgatherqpd
vgatherdps|vgatherqps|vgatherdps|vgatherqps|vgatherdq|vgatherqq|vgatherdq|vgatherqq

;5.17       INTEL® TRANSACTIONAL SYNCHRONIZATION EXTENSIONS (TSX)
xabort|xacquire|xrelease|xbegin|xend|xtest

;5.18 SYSTEM INSTRUCTIONS
clac|stac|lgdt|sgdt|lldt|sldt|ltr|str|lidt|sidt|mov|lmsw|smsw
clts|arpl|lar|lsl|verr|verw|mov|invd|wbinvd|invlpg|invpcid
lock
hlt|rsm|rdmsr|wrmsr|rdpmc|rdtsc|rdtscp|sysenter|sysexit
xsave|xsaveopt|xrstor|xgetbv|xsetbv|rdfsbase|rdgsbase|wrfsbase|wrgsbase

;5.19 64-BIT MODE INSTRUCTIONS
cdqe|cmpsq|cmpxchg16b|lodsq|movsq|movzx|stosq|swapgs|syscall|sysret

;5.20 VIRTUAL-MACHINE EXTENSIONS
vmptrld|vmptrst|vmclear|vmread|vmwrite|vmlaunch|vmresume|vmxoff|vmxon|invept|invvpid|vmcall|vmfunc

;5.21 SAFER MODE EXTENSIONS
getsec
[capabilities|enteraccs|exitac|senter|sexit|parameters|smctrl|wakeup]

;====================================================================
;Intel® 64 and IA-32 Architectures Software Developer's Manual. Vol 2 (2015-01)
aaa|aad|aam|aas|adc|adcx|add|addpd|addps|addsd|addss|addsubpd|addsubps|adox
aesdec|aesdeclast|aesenc|aesenclast|aesimc|aeskeygenassist
and|andn|andpd|andps|andnpd|andnps|arpl

blendpd|bextr|blendps|blendvpd|blendvps|blsi|blsmsk|blsr|bound|bsf|bsr|bswap|bt|btc|btr|bts|bzhi

call|cbw|cwde|cdqe|clac|clc|cld|clflush|cli|clts|cmc
cmova|cmovae|cmovb|cmovbe|cmovc|cmove|cmovg|cmovge|cmovl|cmovle
cmovna|cmovnae|cmovnb|cmovnbe|cmovnc|cmovne|cmovng|cmovnge|cmovnl|cmovnle
cmovno|cmovnp|cmovns|cmovnz|cmovo|cmovp|cmovpe|cmovpo|cmovs|cmovz
cmp|cmppd|cmpps|cmps|cmpsb|cmpsw|cmpsd|cmpsq|cmpsd|cmpss|cmpxchg|cmpxchg8b|cmpxchg16b|comisd|comiss|cpuid|crc32
cvtdq2pd|cvtdq2ps|cvtpd2dq|cvtpd2pi|cvtpd2ps|cvtpi2pd|cvtpi2ps|cvtps2dq|cvtps2pd|cvtps2pi|cvtsd2si|cvtsd2ss
cvtsi2sd|cvtsi2ss|cvtss2sd|cvtss2si|cvttpd2dq|cvttpd2pi|cvttps2dq|cvttps2pi|cvttsd2si|cvttss2si|cwd|cdq|cqo

daa|das|dec|div|divpd|divps|divsd|divss|dppd|dpps

emms|enter|extractps

f2xm1|fabs|fadd|faddp|fiadd|fbld|fbstp|fchs|fclex|fnclex
fcmovb|fcmove|fcmovbe|fcmovu|fcmovnb|fcmovne|fcmovnbe|fcmovnu
fcom|fcomp|fcompp|fcomi|fcomip|fucomi|fucomip|fcos|fdecstp|fdiv|fdivp|fidiv|fdivr|fdivrp|fidivr|ffree
ficom|ficomp|fild|fincstp|finit|fninit|fist|fistp|fisttp|fld|fld1|fldl2t|fldl2e|fldpi|fldlg2|fldln2|fldz|fldcw|fldenv
fmul|fmulp|fimul|fnop|fpatan|fprem|fprem1|fptan|frndint|frstor|fsave|fnsave|fscale|fsin|fsincos|fsqrt|fst|fstp
fstcw|fnstcw|fstenv|fnstenv|fstsw|fnstsw|fsub|fsubp|fisub|fsubr|fsubrp|fisubr|ftst|fucom|fucomp|fucompp|fxam|fxch
fxrstor|fxrstor64|fxsave|fxsave64|fxtract|fyl2x|fyl2xp1

haddpd|haddps|hlt|hsubpd|hsubps

idiv|imul|in|inc|ins|insb|insw|insd|insertps|int n|into|int 3|invd|invlpg|invpcid|iret|iretd|iretq

ja|jae|jb|jbe|jc|jcxz|jecxz|jrcxz|je|jg|jge|jl|jle|jna|jnae|jnb|jnbe|jnc|jne|jng|jnge|jnl|jnle|jno|jnp|jns|jnz|jo|jp|jpe|jpo|js|jz
jmp

lahf|lar|lddqu|ldmxcsr|lds|les|lfs|lgs|lss|lea|leave|lfence|lgdt|lidt|lldt|lmsw|lock|lods|lodsb|lodsw|lodsd|lodsq
loop|loope|loopne
lsl|ltr|lzcnt

maskmovdqu|maskmovq|maxpd|maxps|maxsd|maxss|mfence|minpd|minps|minsd|minss|monitor
mov|movapd|movaps|movbe|movd|movq|movddup|movdqa|movdqu|movdq2q|movhlps|movhpd|movhps|movlhps|movlpd|movlps
movmskpd|movmskps|movntdqa|movntdq|movnti|movntpd|movntps|movntq|movq2dq|movs|movsb|movsw|movsd|movsq
movshdup|movsldup|movss|movsx|movsxd|movupd|movups|movzx|mpsadbw|mul|mulpd|mulps|mulsd|mulss|mulx|mwait

neg|nop|not

or|orpd|orps|out|outs|outsb|outsw|outsd

pabsb|pabsw|pabsd|packsswb|packssdw|packusdw|packuswb|paddb|paddw|paddd|paddq|paddsb|paddsw|paddusb|paddusw
palignr|pand|pandn|pause|pavgb|pavgw|pblendvb|pblendw|pclmulqdq
pcmpeqb|pcmpeqw|pcmpeqd|pcmpeqq|pcmpestri|pcmpestrm|pcmpgtb|pcmpgtw|pcmpgtd|pcmpgtq|pcmpistri|pcmpistrm
pdep|pext|pextrb|pextrd|pextrq|pextrw|phaddw|phaddd|phaddsw|phminposuw|phsubw|phsubd|phsubsw|pinsrb|pinsrd|pinsrq|pinsrw
pmaddubsw|pmaddwd|pmaxsb|pmaxsd|pmaxsw|pmaxub|pmaxud|pmaxuw|pminsb|pminsd|pminsw|pminub|pminud|pminuw|pmovmskb
pmovsxbw|pmovsxbd|pmovsxbq|pmovsxwd|pmovsxwq|pmovsxdq
pmovzxbw|pmovzxbd|pmovzxbq|pmovzxwd|pmovzxwq|pmovzxdq
pmuldq|pmulhrsw|pmulhuw|pmulhw|pmulld|pmullw|pmuludq|pop|popa|popad|popcnt|popf|popfd|popfq|por
prefetcht0|prefetcht1|prefetcht2|prefetchnta|prefetchw|prefetchwt1
psadbw|pshufb|pshufd|pshufhw|pshuflw|pshufw|psignb|psignw|psignd
pslldq|psllw|pslld|psllq|psraw|psrad|psrldq|psrlw|psrld|psrlq
psubb|psubw|psubd|psubq|psubsb|psubsw|psubusb|psubusw|ptest
punpckhbw|punpckhwd|punpckhdq|punpckhqdq|punpcklbw|punpcklwd|punpckldq|punpcklqdq
push|pusha|pushad|pushf|pushfd|pushfq|pxor

rcl|rcr|rol|ror|rcpps|rcpss|rdfsbase|rdgsbase|rdmsr|rdpkru|rdpmc|rdrand|rdseed|rdtsc|rdtscp
rep|repe|repz|repne|repnz|ret|rorx|roundpd|roundps|roundsd|roundss|rsm|rsqrtps|rsqrtss

sahf|sal|sar|shl|shr|sarx|shlx|shrx|sbb|scas|scasb|scasw|scasd|scasq
seta|setae|setb|setbe|setc|sete|setg|setge|setl|setle|seto|setp|setpe|setpo|sets|setz
setna|setnae|setnb|setnbe|setnc|setne|setng|setnge|setnl|setnle|setno|setnp|setns|setnz
sfence|sgdt|shld|shrd|shufpd|shufps|sidt|sldt|smsw|sqrtpd|sqrtps|sqrtsd|sqrtss
stac|stc|std|sti|stmxcsr|stos|stosb|stosw|stosd|stosq|str|sub|subpd|subps|subsd|subss|swapgs|syscall|sysenter|sysexit|sysret

test|tzcnt

ucomisd|ucomiss|ud2|unpckhpd|unpckhps|unpcklpd|unpcklps

vbroadcastss|vbroadcastsd|vbroadcastf128
vcvtph2ps|vcvtps2ph|verr|verw
vextractf128|vextracti128|vfmadd132pd|vfmadd213pd|vfmadd231pd|vfmadd132ps|vfmadd213ps|vfmadd231ps|vfmadd132sd|vfmadd213sd|vfmadd231sd|vfmadd132ss|vfmadd213ss|vfmadd231ss
vfmaddsub132pd|vfmaddsub213pd|vfmaddsub231pd|vfmaddsub132ps|vfmaddsub213ps|vfmaddsub231ps
vfmsubadd132pd|vfmsubadd213pd|vfmsubadd231pd|vfmsubadd132ps|vfmsubadd213ps|vfmsubadd231ps
vfmsub132pd|vfmsub213pd|vfmsub231pd|vfmsub132ps|vfmsub213ps|vfmsub231ps|vfmsub132sd|vfmsub213sd|vfmsub231sd|vfmsub132ss|vfmsub213ss|vfmsub231ss
vfnmadd132pd|vfnmadd213pd|vfnmadd231pd|vfnmadd132ps|vfnmadd213ps|vfnmadd231ps|vfnmadd132sd|vfnmadd213sd|vfnmadd231sd|vfnmadd132ss|vfnmadd213ss|vfnmadd231ss
vfnmsub132pd|vfnmsub213pd|vfnmsub231pd|vfnmsub132ps|vfnmsub213ps|vfnmsub231ps|vfnmsub132sd|vfnmsub213sd|vfnmsub231sd|vfnmsub132ss|vfnmsub213ss|vfnmsub231ss
vgatherdpd|vgatherqpd|vgatherdps|vgatherqps|vpgatherdd|vpgatherqd|vpgatherdq|vpgatherqq
vinsertf128|vinserti128|vmaskmovps|vmaskmovpd|vpblendd
vpbroadcastb|vpbroadcastw|vpbroadcastd|vpbroadcastq|vbroadcasti128
vpermd|vpermpd|vpermps|vpermq|vperm2i128|vpermilpd|vpermilps|vperm2f128|vpmaskmovd|vpmaskmovq
vpsllvd|vpsllvq|vpsravd|vpsrlvd|vpsrlvq|vtestpd|vtestps|vzeroall|vzeroupper

wait|fwait|wbinvd|wrfsbase|wrgsbase|wrmsr|wrpkru

xacquire|xrelease|xabort|xadd|xbegin|xchg|xend|xgetbv|xlat|xlatb|xor|xorpd|xorps
xrstor|xrstor64|xrstors|xrstors64|xsave|xsave64|xsavec|xsavec64|xsaveopt|xsaveopt64|xsaves|xsaves64|xsetbv|xtest

getsec[capabilities]|getsec[enteraccs]|getsec[exitac]|getsec[senter]|getsec[sexit]|getsec[parameters]|getsec[smctrl]|getsec[wakeup]|

;====================================================================
;Intel® Architecture Instruction Set Extensions Programming Reference (2014-10)
;6 OPMASK
;6.1 MASK INSTRUCTIONS
kaddw|kaddb|kaddq|kaddd
kandw|kandb|kandq|kandd
kandnw|kandnb|kandnq|kandnd
kmovw|kmovb|kmovq|kmovd
kunpckbw|kunpckwd|kunpckdq
knotw|knotb|knotq|knotd
korw|korb|korq|kord
kortestw|kortestb|kortestq|kortestd
kshiftlw|kshiftlb|kshiftlq|kshiftld
kshiftrw|kshiftrb|kshiftrq|kshiftrd
kxnorw|kxnorb|kxnorq|kxnord
ktestw|ktestb|ktestq|ktestd
kxorw|kxorb|kxorq|kxord

;7 ADDITIONAL 512-BIT INSTRUCTION EXTENSIONS
;7.2 INSTRUCTION SET REFERENCE
vexp2pd|vexp2ps
vrcp28pd|vrcp28sd|vrcp28ps|vrcp28ss
vrsqrt28pd|vrsqrt28sd|vrsqrt28ps|vrsqrt28ss
vgatherpf0dps|vgatherpf0qps|vgatherpf0dpd|vgatherpf0qpd
vgatherpf1dps|vgatherpf1qps|vgatherpf1dpd|vgatherpf1qpd
vscatterpf0dps|vscatterpf0qps|vscatterpf0dpd|vscatterpf0qpd
vscatterpf1dps|vscatterpf1qps|vscatterpf1dpd|vscatterpf1qpd

;8 INTEL® SHA EXTENSIONS
;8.3         SHA EXTENSIONS REFERENCE
sha1rnds4|sha1nexte|sha1msg1|sha1msg2
sha256rnds2|sha256msg1|sha256msg2

;9 INTEL® MEMORY PROTECTION EXTENSIONS
;9.4         INTEL MPX INSTRUCTION REFERENCE
bndmk|bndcl|bndcu|bndcn|bndmov|bndldx|bndstx

;10 ADDITIONAL NEW INSTRUCTIONS
prefetchwt1

;11 MEMORY INSTRUCTIONS
;11.4 INSTRUCTION SET REFERENCE
clflushopt|clwb|pcommit

;====================================================================
;AMD64 Architecture Programmer's Manual Volume 2: System Programming (2011-12)
;6         System-Management Instructions
arpl|clgi|cli|clts|hlt|int3|invd|invlpg|invlpga
iret|iret|iretw|iretd|iretq
lar|lgdt|lidt|lldt|lmsw|lsl|ltr|monitor|mwait|rdfsbase|rdgsbase|rdmsr|rdpmc|rdtsc|rdtscp|rsm|sgdt|sidt|skinit|sldt
smsw|sti|stgi|str|swapgs|syscall|sysenter|sysexit|sysret|ud2|verr|verw|vmload|vmmcall|vmrun|vmsave|wbinvd|wrfsbase|wrgsbase|wrmsr
;7         Memory System
;7.5.2  Write Combining
movntsd|movntss
;7.6.3  Cache and Memory Management Instructions
prefetch|prefetchw

;====================================================================
;AMD64 Architecture Programmer's Manual Volume 3: General-Purpose and System Instructions (2015-06)
;3 General-Purpose Instruction Reference
aaa|aad|aam|aas|adc|add|and|andn
bextr|blcfill|blci|blcic|blcmsk|blcs|blsfill|blsi|blsic|blsmsk|blsr|bound|bsf|bsr|bswap|bt|btc|btr|bts|bzhi
call|cbw|cwde|cdqe|cwd|cdq|cqo|clc|cld|clflush|cmc
cmovo|cmovno|cmovb|cmovc|cmovnae|cmovnb|cmovnc|cmovae|cmovz|cmove|cmovnz|cmovne|cmovbe|cmovna|cmovnbe
cmova|cmovs|cmovns|cmovp|cmovpe|cmovnp|cmovpo|cmovl|cmovnge|cmovnl|cmovge|cmovle|cmovng|cmovnle|cmovg
cmp|cmps|cmpsb|cmpsw|cmpsd|cmpsq|cmpxchg|cmpxchg8b|cmpxchg16b|cpuid|crc32
daa|das|dec|div
enter
idiv|imul|in|inc|ins|insb|insw|insd|int|into
jo|jno|jb|jc|jnae|jnb|jnc|jae|jz|je|jnz|jne|jbe|jna|jnbe|ja|js|jns|jp|jpe|jnp|jpo|jl|jnge|jnl|jge|jle|jng|jnle|jg|jcxz|jecxz|jrcxz|jmp
lahf|lds|les|lfs|lgs|lss|lea|leave|lfence|llwpcb|lods|lodsb|lodsw|lodsd|lodsq|loop|loope|loopne|loopnz|loopz|lwpins|lwpval|lzcnt
mfence|mov|movbe|movd|movmskpd|movmskps|movnti|movs|movsb|movsw|movsd|movsq|movsx|movsxd|movzx|mul|mulx
neg|nop|not
or|out|outs|outsb|outsw|outsd
pause|pdep|pext|pop|popa|popad|popcnt|popf|popfd|popfq|prefetch|prefetchw|prefetchnta|prefetcht0|prefetcht1|prefetcht2|push|pusha|pushad|pushf|pushfd|pushfq
rcl|rcr|rdfsbase|rdgsbase|rdrand|ret|rol|ror|rorx
sahf|sal|shl|sar|sarx|sbb|scas|scasb|scasw|scasd|scasq
seto|setno|setb|setc|setnae|setnb|setnc|setae|setz|sete|setnz|setne|setbe|setna|setnbe|seta|sets|setns|setp|setpe|setnp|setpo|setl|setnge|setnl|setge|setle|setng|setnle|setg
sfence|shl|shld|shlx|shr|shrd|shrx|slwpcb|stc|std|stos|stosb|stosw|stosd|stosq|sub
t1mskc|test|tzcnt|tzmsk
wrfsbase|wrgsbase
xadd|xchg|xlat|xlatb|xor

;4 System Instruction Reference
arpl|clgi|cli|clts|hlt|int 3|invd|invlpg|invlpga|iret|iretd|iretq|lar|lgdt|lidt|lldt|lmsw|lsl|ltr
monitor|monitorx|mov crn|mov drn|mwait|mwaitx|rdmsr|rdpmc|rdtsc|rdtscp|rsm
sgdt|sidt|skinit|sldt|smsw|sti|stgi|str|swapgs|syscall|sysenter|sysexit|sysret
ud2|verr|verw|vmload|vmmcall|vmrun|vmsave|wbinvd|wrmsr

; Zen Architecture
clzero

;====================================================================
;AMD64 Architecture Programmer's Manual Volume 4: 128-Bit and 256-Bit Media Instructions (2013-05)
addpd|vaddpd|addps|vaddps|addsd|vaddsd|addss|vaddss|addsubpd|vaddsubpd|addsubps|vaddsubps
aesdec|vaesdec|aesdeclast|vaesdeclast|aesenc|vaesenc|aesenclast|vaesenclast|aesimc|vaesimc
aeskeygenassist|vaeskeygenassist|andnpd|vandnpd|andnps|vandnps|andpd|vandpd|andps|vandps

blendpd|vblendpd|blendps|vblendps|blendvpd|vblendvpd|blendvps|vblendvps

cmppd|vcmppd|cmpps|vcmpps|cmpsd|vcmpsd|cmpss|vcmpss|comisd|vcomisd|comiss|vcomiss
cvtdq2pd|vcvtdq2pd|cvtdq2ps|vcvtdq2ps|cvtpd2dq|vcvtpd2dq|cvtpd2ps|vcvtpd2ps|cvtps2dq|vcvtps2dq
cvtps2pd|vcvtps2pd|cvtsd2si|vcvtsd2si|cvtsd2ss|vcvtsd2ss|cvtsi2sd|vcvtsi2sd|cvtsi2ss|vcvtsi2ss
cvtss2sd|vcvtss2sd|cvtss2si|vcvtss2si|cvttpd2dq|vcvttpd2dq|cvttps2dq|vcvttps2dq|cvttsd2si|vcvttsd2si|cvttss2si|vcvttss2si

divpd|vdivpd|divps|vdivps|divsd|vdivsd|divss|vdivss|dppd|vdppd|dpps|vdpps

extractps|vextractps|extrq

haddpd|vhaddpd|haddps|vhaddps|hsubpd|vhsubpd|hsubps|vhsubps

insertps|vinsertps|insertq

lddqu|vlddqu|ldmxcsr|vldmxcsr

maskmovdqu|vmaskmovdqu|maxpd|vmaxpd|maxps|vmaxps|maxsd|vmaxsd|maxss|vmaxss|minpd|vminpd|minps|vminps|minsd|vminsd|minss|vminss
movapd|vmovapd|movaps|vmovaps|movd|vmovd|movddup|vmovddup|movdqa|vmovdqa|movdqu|vmovdqu|movhlps|vmovhlps
movhpd|vmovhpd|movhps|vmovhps|movlhps|vmovlhps|movlpd|vmovlpd|movlps|vmovlps|movmskpd|vmovmskpd|movmskps|vmovmskps
movntdq|vmovntdq|movntdqa|vmovntdqa|movntpd|vmovntpd|movntps|vmovntps|movntsd|movntss|movq|vmovq|movsd|vmovsd
movshdup|vmovshdup|movsldup|vmovsldup|movss|vmovss|movupd|vmovupd|movups|vmovups|mpsadbw|vmpsadbw
mulpd|vmulpd|mulps|vmulps|mulsd|vmulsd|mulss|vmulss

orpd|vorpd|orps|vorps

pabsb|vpabsb|pabsd|vpabsd|pabsw|vpabsw|packssdw|vpackssdw|packsswb|vpacksswb|packusdw|vpackusdw|packuswb|vpackuswb
paddb|vpaddb|paddd|vpaddd|paddq|vpaddq|paddsb|vpaddsb|paddsw|vpaddsw|paddusb|vpaddusb|paddusw|vpaddusw|paddw|vpaddw
palignr|vpalignr|pand|vpand|pandn|vpandn|pavgb|vpavgb|pavgw|vpavgw
pblendvb|vpblendvb|pblendw|vpblendw|pclmulqdq|vpclmulqdq
pcmpeqb|vpcmpeqb|pcmpeqd|vpcmpeqd|pcmpeqq|vpcmpeqq|pcmpeqw|vpcmpeqw|pcmpestri|vpcmpestri|pcmpestrm|vpcmpestrm
pcmpgtb|vpcmpgtb|pcmpgtd|vpcmpgtd|pcmpgtq|vpcmpgtq|pcmpgtw|vpcmpgtw|pcmpistri|vpcmpistri|pcmpistrm|vpcmpistrm
pextrb|vpextrb|pextrd|vpextrd|pextrq|vpextrq|pextrw|vpextrw|phaddd|vphaddd|phaddsw|vphaddsw|phaddw|vphaddw
phminposuw|vphminposuw|phsubd|vphsubd|phsubsw|vphsubsw|phsubw|vphsubw|pinsrb|vpinsrb|pinsrd|vpinsrd|pinsrq|vpinsrq|pinsrw|vpinsrw
pmaddubsw|vpmaddubsw|pmaddwd|vpmaddwd|pmaxsb|vpmaxsb|pmaxsd|vpmaxsd|pmaxsw|vpmaxsw|pmaxub|vpmaxub|pmaxud|vpmaxud|pmaxuw|vpmaxuw
pminsb|vpminsb|pminsd|vpminsd|pminsw|vpminsw|pminub|vpminub|pminud|vpminud|pminuw|vpminuw|pmovmskb|vpmovmskb
pmovsxbd|vpmovsxbd|pmovsxbq|vpmovsxbq|pmovsxbw|vpmovsxbw|pmovsxdq|vpmovsxdq|pmovsxwd|vpmovsxwd|pmovsxwq|vpmovsxwq
pmovzxbd|vpmovzxbd|pmovzxbq|vpmovzxbq|pmovzxbw|vpmovzxbw|pmovzxdq|vpmovzxdq|pmovzxwd|vpmovzxwd|pmovzxwq|vpmovzxwq
pmuldq|vpmuldq|pmulhrsw|vpmulhrsw|pmulhuw|vpmulhuw|pmulhw|vpmulhw|pmulld|vpmulld|pmullw|vpmullw|pmuludq|vpmuludq
por|vpor|psadbw|vpsadbw|pshufb|vpshufb|pshufd|vpshufd|pshufhw|vpshufhw|pshuflw|vpshuflw|psignb|vpsignb|psignd|vpsignd|psignw|vpsignw
pslld|vpslld|pslldq|vpslldq|psllq|vpsllq|psllw|vpsllw|psrad|vpsrad|psraw|vpsraw|psrld|vpsrld|psrldq|vpsrldq|psrlq|vpsrlq|psrlw|vpsrlw
psubb|vpsubb|psubd|vpsubd|psubq|vpsubq|psubsb|vpsubsb|psubsw|vpsubsw|psubusb|vpsubusb|psubusw|vpsubusw|psubw|vpsubw|ptest|vptest
punpckhbw|vpunpckhbw|punpckhdq|vpunpckhdq|punpckhqdq|vpunpckhqdq|punpckhwd|vpunpckhwd
punpcklbw|vpunpcklbw|punpckldq|vpunpckldq|punpcklqdq|vpunpcklqdq|punpcklwd|vpunpcklwd|pxor|vpxor

rcpps|vrcpps|rcpss|vrcpss|roundpd|vroundpd|roundps|vroundps|roundsd|vroundsd|roundss|vroundss|rsqrtps|vrsqrtps|rsqrtss|vrsqrtss

shufpd|vshufpd|shufps|vshufps|sqrtpd|vsqrtpd|sqrtps|vsqrtps|sqrtsd|vsqrtsd|sqrtss|vsqrtss|stmxcsr|vstmxcsr|subpd|vsubpd|subps|vsubps|subsd|vsubsd|subss|vsubss

ucomisd|vucomisd|ucomiss|vucomiss|unpckhpd|vunpckhpd|unpckhps|vunpckhps|unpcklpd|vunpcklpd|unpcklps|vunpcklps

vbroadcastf128|vbroadcastsd|vbroadcastss|vcvtph2ps|vcvtps2ph|vextractf128
vfmaddpd|vfmadd132pd|vfmadd213pd|vfmadd231pd|vfmaddps|vfmadd132ps|vfmadd213ps|vfmadd231ps
vfmaddsd|vfmadd132sd|vfmadd213sd|vfmadd231sd|vfmaddss|vfmadd132ss|vfmadd213ss|vfmadd231ss
vfmaddsubpd|vfmaddsub132pd|vfmaddsub213pd|vfmaddsub231pd|vfmaddsubps|vfmaddsub132ps|vfmaddsub213ps|vfmaddsub231ps
vfmsubaddpd|vfmsubadd132pd|vfmsubadd213pd|vfmsubadd231pd|vfmsubaddps|vfmsubadd132ps|vfmsubadd213ps|vfmsubadd231ps
vfmsubpd|vfmsub132pd|vfmsub213pd|vfmsub231pd|vfmsubps|vfmsub132ps|vfmsub213ps|vfmsub231ps
vfmsubsd|vfmsub132sd|vfmsub213sd|vfmsub231sd|vfmsubss|vfmsub132ss|vfmsub213ss|vfmsub231ss
vfnmaddpd|vfnmadd132pd|vfnmadd213pd|vfnmadd231pd|vfnmaddps|vfnmadd132ps|vfnmadd213ps|vfnmadd231ps
vfnmaddsd|vfnmadd132sd|vfnmadd213sd|vfnmadd231sd|vfnmaddss|vfnmadd132ss|vfnmadd213ss|vfnmadd231ss
vfnmsubpd|vfnmsub132pd|vfnmsub213pd|vfnmsub231pd|vfnmsubps|vfnmsub132ps|vfnmsub213ps|vfnmsub231ps
vfnmsubsd|vfnmsub132sd|vfnmsub213sd|vfnmsub231sd|vfnmsubss|vfnmsub132ss|vfnmsub213ss|vfnmsub231ss
vfrczpd|vfrczps|vfrczsd|vfrczss|vinsertf128|vmaskmovpd|vmaskmovps
vpcmov|vpcomb|vpcomd|vpcomq|vpcomub|vpcomud|vpcomuq|vpcomuw|vpcomw
vperm2f128|vpermil2pd|vpermil2ps|vpermilpd|vpermilps
vphaddbd|vphaddbq|vphaddbw|vphadddq|vphaddubd|vphaddubq|vphaddubw|vphaddudq|vphadduwd|vphadduwq|vphaddwd|vphaddwq
vphsubbw|vphsubdq|vphsubwd|vpmacsdd|vpmacsdqh|vpmacsdql|vpmacssdd|vpmacssdqh|vpmacssdql|vpmacsswd|vpmacssww|vpmacswd|vpmacsww
vpmadcsswd|vpmadcswd|vpperm|vprotb|vprotd|vprotq|vprotw|vpshab|vpshad|vpshaq|vpshaw|vpshlb|vpshld|vpshlq|vpshlw
vtestpd|vtestps|vzeroall|vzeroupper

xgetbv|xorpd|vxorpd|xorps|vxorps|xrstor|xsave|xsaveopt|xsetbv

;AMD64 Architecture Programmer's Manual Volume 5: 64-Bit Media and x87 Floating-Point Instructions (2013-05)
;1 64-Bit Media Instruction Reference
cvtpd2pi|cvtpi2pd|cvtpi2ps|cvtps2pi|cvttpd2pi|cvttps2pi
emms|femms
frstor|fsave|fnsave|fxrstor|fxsave
maskmovq|movd|movdq2q|movntq|movq|movq2dq
packssdw|packsswb|packuswb

paddb|paddd|paddq|paddsb|paddsw|paddusb|paddusw|paddw|pand|pandn|pavgb|pavgusb|pavgw
pcmpeqb|pcmpeqd|pcmpeqw|pcmpgtb|pcmpgtd|pcmpgtw
pextrw
pf2id|pf2iw|pfacc|pfadd|pfcmpeq|pfcmpge|pfcmpgt|pfmax|pfmin|pfmul|pfnacc|pfpnacc|pfrcp|pfrcpit1|pfrcpit2|pfrsqit1|pfrsqrt|pfsub|pfsubr
pi2fd|pi2fw|pinsrw|pmaddwd|pmaxsw|pmaxub|pminsw|pminub|pmovmskb|pmulhrw|pmulhuw|pmulhw|pmullw|pmuludq|por|psadbw|pshufw
pslld|psllq|psllw|psrad|psraw|psrld|psrlq|psrlw|psubb|psubd|psubq|psubsb|psubsw|psubusb|psubusw|psubw|pswapd
punpckhbw|punpckhdq|punpckhwd|punpcklbw|punpckldq|punpcklwd|pxor

;2 x87 Floating-Point Instruction Reference
f2xm1|fabs|fadd|faddp|fiadd|fbld|fbstp|fchs|fclex|fnclex
fcmovb|fcmovbe|fcmove|fcmovnb|fcmovnbe|fcmovne|fcmovnu|fcmovu
fcom|fcomp|fcompp|fcomi|fcomip|fcos|fdecstp|fdiv|fdivp|fidiv|fdivr|fdivrp|fidivr|ffree|ficom|ficomp|fild|fincstp|finit|fninit
fist|fistp|fisttp|fld|fld1|fldcw|fldenv|fldl2e|fldl2t|fldlg2|fldln2|fldpi|fldz|fmul|fmulp|fimul|fnop|fpatan|fprem|fprem1|fptan
frndint|frstor|fsave|fnsave|fscale|fsin|fsincos|fsqrt|fst|fstp|fstcw|fnstcw|fstenv|fnstenv|fstsw|fnstsw
fsub|fsubp|fisub|fsubr|fsubrp|fisubr|ftst|fucom|fucomp|fucompp|fucomi|fucomip|fwait|wait|fxam|fxch|fxrstor|fxsave|fxtract|fyl2x|fyl2xp1

;====================================================================
;legacy
retn|retf

;undocumented
icebp
int1
smi
int03			; Instead of INT3
ud1			; No documented mnemonic for this one

sqrtps xmm0,[ebx+10]	; SSE opcode
paddsiw mm0,[ebx+10]	; Cyrix opcode with the same byte seq.

;====================================================================
;old samples
label:	vaddpd xmm10, [rax+r15*4]
		vaddps ymm1, ymm2, yword [rax]
lock	add st0, mm1

.text
		db 'test\0'

redpajama_set_name: RedPajamaGithub


text:
package org.apache.giraph.worker;

import org.apache.giraph.conf.ImmutableClassesGiraphConfiguration;
import org.apache.giraph.edge.Edge;
import org.apache.giraph.graph.VertexEdgeCount;
import org.apache.giraph.io.EdgeInputFormat;
import org.apache.giraph.io.EdgeReader;
import org.apache.giraph.io.filters.EdgeInputFilter;
import org.apache.giraph.utils.LoggerUtils;
import org.apache.giraph.utils.MemoryUtils;
import org.apache.giraph.zk.ZooKeeperExt;
import org.apache.hadoop.io.Writable;
import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.mapreduce.InputSplit;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;

import com.yammer.metrics.core.Counter;
import com.yammer.metrics.core.Meter;

import java.io.IOException;

/**
 * Load as many edge input splits as possible.
 * Every thread will has its own instance of WorkerClientRequestProcessor
 * to send requests.
 *
 * @param <I> Vertex id
 * @param <V> Vertex value
 * @param <E> Edge value
 */
public class EdgeInputSplitsCallable<I extends WritableComparable,
    V extends Writable, E extends Writable>
    extends InputSplitsCallable<I, V, E> {
  /** How often to update metrics and print info */
  public static final int EDGES_UPDATE_PERIOD = 1000000;
  /** How often to update filtered metrics */
  public static final int EDGES_FILTERED_UPDATE_PERIOD = 10000;

  /** Class logger */
  private static final Logger LOG = Logger.getLogger(
      EdgeInputSplitsCallable.class);

  /** Aggregator handler */
  private final WorkerThreadAggregatorUsage aggregatorUsage;
  /** Edge input format */
  private final EdgeInputFormat<I, E> edgeInputFormat;
  /** Input split max edges (-1 denotes all) */
  private final long inputSplitMaxEdges;

  /** Filter to use */
  private final EdgeInputFilter<I, E> edgeInputFilter;

  // Metrics
  /** edges loaded meter across all readers */
  private final Meter totalEdgesMeter;
  /** edges filtered out by user */
  private final Counter totalEdgesFiltered;

  /**
   * Constructor.
   *
   * @param edgeInputFormat Edge input format
   * @param context Context
   * @param configuration Configuration
   * @param bspServiceWorker service worker
   * @param splitsHandler Handler for input splits
   * @param zooKeeperExt Handle to ZooKeeperExt
   */
  public EdgeInputSplitsCallable(
      EdgeInputFormat<I, E> edgeInputFormat,
      Mapper<?, ?, ?, ?>.Context context,
      ImmutableClassesGiraphConfiguration<I, V, E> configuration,
      BspServiceWorker<I, V, E> bspServiceWorker,
      InputSplitsHandler splitsHandler,
      ZooKeeperExt zooKeeperExt)  {
    super(context, configuration, bspServiceWorker, splitsHandler,
        zooKeeperExt);
    this.edgeInputFormat = edgeInputFormat;

    inputSplitMaxEdges = configuration.getInputSplitMaxEdges();
    // Initialize aggregator usage.
    this.aggregatorUsage = bspServiceWorker.getAggregatorHandler()
      .newThreadAggregatorUsage();
    edgeInputFilter = configuration.getEdgeInputFilter();

    // Initialize Metrics
    totalEdgesMeter = getTotalEdgesLoadedMeter();
    totalEdgesFiltered = getTotalEdgesFilteredCounter();
  }

  @Override
  public EdgeInputFormat<I, E> getInputFormat() {
    return edgeInputFormat;
  }

  /**
   * Read edges from input split.  If testing, the user may request a
   * maximum number of edges to be read from an input split.
   *
   * @param inputSplit Input split to process with edge reader
   * @return Edges loaded from this input split
   * @throws IOException
   * @throws InterruptedException
   */
  @Override
  protected VertexEdgeCount readInputSplit(
      InputSplit inputSplit) throws IOException,
      InterruptedException {
    EdgeReader<I, E> edgeReader =
        edgeInputFormat.createEdgeReader(inputSplit, context);
    edgeReader.setConf(
        (ImmutableClassesGiraphConfiguration<I, Writable, E>)
            configuration);

    edgeReader.initialize(inputSplit, context);
    // Set aggregator usage to edge reader
    edgeReader.setWorkerAggregatorUse(aggregatorUsage);

    long inputSplitEdgesLoaded = 0;
    long inputSplitEdgesFiltered = 0;

    while (edgeReader.nextEdge()) {
      I sourceId = edgeReader.getCurrentSourceId();
      Edge<I, E> readerEdge = edgeReader.getCurrentEdge();
      if (sourceId == null) {
        throw new IllegalArgumentException(
            "readInputSplit: Edge reader returned an edge " +
                "without a source vertex id!  - " + readerEdge);
      }
      if (readerEdge.getTargetVertexId() == null) {
        throw new IllegalArgumentException(
            "readInputSplit: Edge reader returned an edge " +
                "without a target vertex id!  - " + readerEdge);
      }
      if (readerEdge.getValue() == null) {
        throw new IllegalArgumentException(
            "readInputSplit: Edge reader returned an edge " +
                "without a value!  - " + readerEdge);
      }

      ++inputSplitEdgesLoaded;

      if (edgeInputFilter.dropEdge(sourceId, readerEdge)) {
        ++inputSplitEdgesFiltered;
        if (inputSplitEdgesFiltered % EDGES_FILTERED_UPDATE_PERIOD == 0) {
          totalEdgesFiltered.inc(inputSplitEdgesFiltered);
          inputSplitEdgesFiltered = 0;
        }
        continue;
      }

      workerClientRequestProcessor.sendEdgeRequest(sourceId, readerEdge);
      context.progress(); // do this before potential data transfer

      // Update status every EDGES_UPDATE_PERIOD edges
      if (inputSplitEdgesLoaded % EDGES_UPDATE_PERIOD == 0) {
        totalEdgesMeter.mark(EDGES_UPDATE_PERIOD);
        LoggerUtils.setStatusAndLog(context, LOG, Level.INFO,
            "readEdgeInputSplit: Loaded " +
                totalEdgesMeter.count() + " edges at " +
                totalEdgesMeter.meanRate() + " edges/sec " +
                MemoryUtils.getRuntimeMemoryStats());
      }

      // For sampling, or to limit outlier input splits, the number of
      // records per input split can be limited
      if (inputSplitMaxEdges > 0 &&
          inputSplitEdgesLoaded >= inputSplitMaxEdges) {
        if (LOG.isInfoEnabled()) {
          LOG.info("readInputSplit: Leaving the input " +
              "split early, reached maximum edges " +
              inputSplitEdgesLoaded);
        }
        break;
      }
    }
    edgeReader.close();

    totalEdgesFiltered.inc(inputSplitEdgesFiltered);
    totalEdgesMeter.mark(inputSplitEdgesLoaded % EDGES_UPDATE_PERIOD);

    return new VertexEdgeCount(0, inputSplitEdgesLoaded);
  }
}


text:
angular.module('app').service('Msg', function ($rootScope, $location, DS) {
  'use strict';

  var socket = io.connect($location.protocol() + '://' + $location.host() + ':' + $location.port(), { path: '/api/socket.io' });

  socket.on('create', function (data) {
    if (data.ownerId && $rootScope.loggedInUser && $rootScope.loggedInUser.id === data.ownerId) {
      DS.find(data.resource, data.id);
    }
    $rootScope.$broadcast('create', data.resource, data.id, data.ownerId);
  });
  socket.on('update', function (data) {
    if (data.id === 'all' && data.seriesId) {
      angular.forEach(DS.filter(data.resource, { seriesId: data.seriesId }), function (instance) {
        DS.refresh(data.resource, instance.id);
      });
    } else {
      DS.refresh(data.resource, data.id);
    }
    $rootScope.$broadcast('update', data.resource, data.id, data.ownerId);
  });
  socket.on('destroy', function (data) {
    if (data.id === 'all' && data.lessonId) {
      DS.ejectAll(data.resource, { lessonId: data.lessonId });
    } else {
      DS.eject(data.resource, data.id);
    }
    $rootScope.$broadcast('destroy', data.resource, data.id, data.ownerId);
  });

  return {};
}).run(function (Msg) {
});


text:
package com.gongshw.chisu.service.service.model;

import java.util.Date;

/**
 * @author gongshiwei
 */
public class ServiceStatus {
    private Date time;
    private String version;

    public Date getTime() {
        return time;
    }

    public void setTime(Date time) {
        this.time = time;
    }

    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }
}


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
     "http://www.w3.org/TR/html4/transitional.dtd">

  <meta HTTP-EQUIV=CONTENT-TYPE CONTENT="text/html; charset=utf-8">
  <title>Slide 40</title>


text:
package org.jboss.pnc.rest.restmodel;

import com.fasterxml.jackson.databind.ObjectMapper;

import org.jboss.pnc.common.json.JsonOutputConverterMapper;
import org.jboss.pnc.spi.repositorymanager.ArtifactRepository;

import javax.xml.bind.annotation.XmlRootElement;

import java.io.IOException;

@XmlRootElement(name = "artifactRepository")
public class ArtifactRepositoryRest implements ArtifactRepository {

    private String id;

    private String name;

    private String url;

    private Boolean releases;

    private Boolean snapshots;

    public ArtifactRepositoryRest() {}

    public ArtifactRepositoryRest(String serialized) throws IOException {
        ObjectMapper mapper = new ObjectMapper(); //TODO replace with JsonOutputConverterMapper
        ArtifactRepositoryRest artifactRepositoryRestFromJson = mapper.readValue(serialized, ArtifactRepositoryRest.class);
        ArtifactRepository artifactRepository = artifactRepositoryRestFromJson.toArtifactRepository();

        init(artifactRepository);
    }

    public ArtifactRepositoryRest(ArtifactRepository artifactRepository) {
        init(artifactRepository);
    }

    private void init(ArtifactRepository buildExecutionConfiguration) {
        id = buildExecutionConfiguration.getId();
        name = buildExecutionConfiguration.getName();
        url = buildExecutionConfiguration.getUrl();
        releases = buildExecutionConfiguration.getReleases();
        snapshots = buildExecutionConfiguration.getSnapshots();
    }

    public ArtifactRepository toArtifactRepository() {
        return ArtifactRepository.build(
                id,
                name,
                url,
                releases,
                snapshots
        );
    }

    @Override
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @Override
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    @Override
    public Boolean getReleases() {
        return releases;
    }

    public void setReleases(Boolean releases) {
        this.releases = releases;
    }

    @Override
    public Boolean getSnapshots() {
        return snapshots;
    }

    public void setSnapshots(Boolean snapshots) {
        this.snapshots = snapshots;
    }

    @Override
    public String toString() {
        return JsonOutputConverterMapper.apply(this);
    }

}


text:
package org.apache.spark.sql.catalyst.util

import scala.reflect.ClassTag

import org.apache.spark.sql.catalyst.InternalRow
import org.apache.spark.sql.catalyst.expressions.{SpecializedGetters, UnsafeArrayData}
import org.apache.spark.sql.types._
import org.apache.spark.unsafe.Platform
import org.apache.spark.unsafe.array.ByteArrayMethods

object ArrayData {
  def toArrayData(input: Any): ArrayData = input match {
    case a: Array[Boolean] => UnsafeArrayData.fromPrimitiveArray(a)
    case a: Array[Byte] => UnsafeArrayData.fromPrimitiveArray(a)
    case a: Array[Short] => UnsafeArrayData.fromPrimitiveArray(a)
    case a: Array[Int] => UnsafeArrayData.fromPrimitiveArray(a)
    case a: Array[Long] => UnsafeArrayData.fromPrimitiveArray(a)
    case a: Array[Float] => UnsafeArrayData.fromPrimitiveArray(a)
    case a: Array[Double] => UnsafeArrayData.fromPrimitiveArray(a)
    case other => new GenericArrayData(other)
  }

  /**
   * Allocate [[UnsafeArrayData]] or [[GenericArrayData]] based on given parameters.
   *
   * @param elementSize a size of an element in bytes. If less than zero, the type of an element is
   *                    non-primitive type
   * @param numElements the number of elements the array should contain
   * @param additionalErrorMessage string to include in the error message
   */
  def allocateArrayData(
      elementSize: Int,
      numElements: Long,
      additionalErrorMessage: String): ArrayData = {
    if (elementSize >= 0 && !UnsafeArrayData.shouldUseGenericArrayData(elementSize, numElements)) {
      UnsafeArrayData.createFreshArray(numElements.toInt, elementSize)
    } else if (numElements <= ByteArrayMethods.MAX_ROUNDED_ARRAY_LENGTH.toLong) {
      new GenericArrayData(new Array[Any](numElements.toInt))
    } else {
      throw new RuntimeException(s"Cannot create array with $numElements " +
        "elements of data due to exceeding the limit " +
        s"${ByteArrayMethods.MAX_ROUNDED_ARRAY_LENGTH} elements for ArrayData. " +
        additionalErrorMessage)
    }
  }
}

abstract class ArrayData extends SpecializedGetters with Serializable {
  def numElements(): Int

  def copy(): ArrayData

  def array: Array[Any]

  def toSeq[T](dataType: DataType): IndexedSeq[T] =
    new ArrayDataIndexedSeq[T](this, dataType)

  def setNullAt(i: Int): Unit

  def update(i: Int, value: Any): Unit

  // default implementation (slow)
  def setBoolean(i: Int, value: Boolean): Unit = update(i, value)
  def setByte(i: Int, value: Byte): Unit = update(i, value)
  def setShort(i: Int, value: Short): Unit = update(i, value)
  def setInt(i: Int, value: Int): Unit = update(i, value)
  def setLong(i: Int, value: Long): Unit = update(i, value)
  def setFloat(i: Int, value: Float): Unit = update(i, value)
  def setDouble(i: Int, value: Double): Unit = update(i, value)

  def toBooleanArray(): Array[Boolean] = {
    val size = numElements()
    val values = new Array[Boolean](size)
    var i = 0
    while (i < size) {
      values(i) = getBoolean(i)
      i += 1
    }
    values
  }

  def toByteArray(): Array[Byte] = {
    val size = numElements()
    val values = new Array[Byte](size)
    var i = 0
    while (i < size) {
      values(i) = getByte(i)
      i += 1
    }
    values
  }

  def toShortArray(): Array[Short] = {
    val size = numElements()
    val values = new Array[Short](size)
    var i = 0
    while (i < size) {
      values(i) = getShort(i)
      i += 1
    }
    values
  }

  def toIntArray(): Array[Int] = {
    val size = numElements()
    val values = new Array[Int](size)
    var i = 0
    while (i < size) {
      values(i) = getInt(i)
      i += 1
    }
    values
  }

  def toLongArray(): Array[Long] = {
    val size = numElements()
    val values = new Array[Long](size)
    var i = 0
    while (i < size) {
      values(i) = getLong(i)
      i += 1
    }
    values
  }

  def toFloatArray(): Array[Float] = {
    val size = numElements()
    val values = new Array[Float](size)
    var i = 0
    while (i < size) {
      values(i) = getFloat(i)
      i += 1
    }
    values
  }

  def toDoubleArray(): Array[Double] = {
    val size = numElements()
    val values = new Array[Double](size)
    var i = 0
    while (i < size) {
      values(i) = getDouble(i)
      i += 1
    }
    values
  }

  def toObjectArray(elementType: DataType): Array[AnyRef] =
    toArray[AnyRef](elementType: DataType)

  def toArray[T: ClassTag](elementType: DataType): Array[T] = {
    val size = numElements()
    val accessor = InternalRow.getAccessor(elementType)
    val values = new Array[T](size)
    var i = 0
    while (i < size) {
      if (isNullAt(i)) {
        values(i) = null.asInstanceOf[T]
      } else {
        values(i) = accessor(this, i).asInstanceOf[T]
      }
      i += 1
    }
    values
  }

  def foreach(elementType: DataType, f: (Int, Any) => Unit): Unit = {
    val size = numElements()
    val accessor = InternalRow.getAccessor(elementType)
    var i = 0
    while (i < size) {
      if (isNullAt(i)) {
        f(i, null)
      } else {
        f(i, accessor(this, i))
      }
      i += 1
    }
  }
}

/**
 * Implements an `IndexedSeq` interface for `ArrayData`. Notice that if the original `ArrayData`
 * is a primitive array and contains null elements, it is better to ask for `IndexedSeq[Any]`,
 * instead of `IndexedSeq[Int]`, in order to keep the null elements.
 */
class ArrayDataIndexedSeq[T](arrayData: ArrayData, dataType: DataType) extends IndexedSeq[T] {

  private val accessor: (SpecializedGetters, Int) => Any = InternalRow.getAccessor(dataType)

  override def apply(idx: Int): T =
    if (0 <= idx && idx < arrayData.numElements()) {
      if (arrayData.isNullAt(idx)) {
        null.asInstanceOf[T]
      } else {
        accessor(arrayData, idx).asInstanceOf[T]
      }
    } else {
      throw new IndexOutOfBoundsException(
        s"Index $idx must be between 0 and the length of the ArrayData.")
    }

  override def length: Int = arrayData.numElements()
}


text:
module CodeRay
module Scanners

  # Scanner for YAML.
  #
  # Based on the YAML scanner from Syntax by Jamis Buck.
  class YAML < Scanner

    register_for :yaml
    file_extension 'yml'

    KINDS_NOT_LOC = :all

  protected

    def scan_tokens encoder, options

      state = :initial
      key_indent = string_indent = 0

      until eos?

        key_indent = nil if bol?

        if match = scan(/ +[\t ]*/)
          encoder.text_token match, :space

        elsif match = scan(/\n+/)
          encoder.text_token match, :space
          state = :initial if match.index(?\n)

        elsif match = scan(/#.*/)
          encoder.text_token match, :comment

        elsif bol? and case
          when match = scan(/---|\.\.\./)
            encoder.begin_group :head
            encoder.text_token match, :head
            encoder.end_group :head
            next
          when match = scan(/%.*/)
            encoder.text_token match, :doctype
            next
          end

        elsif state == :value and case
          when !check(/(?:"[^"]*")(?=: |:$)/) && match = scan(/"/)
            encoder.begin_group :string
            encoder.text_token match, :delimiter
            encoder.text_token match, :content if match = scan(/ [^"\\]* (?: \\. [^"\\]* )* /mx)
            encoder.text_token match, :delimiter if match = scan(/"/)
            encoder.end_group :string
            next
          when match = scan(/[|>][-+]?/)
            encoder.begin_group :string
            encoder.text_token match, :delimiter
            string_indent = key_indent || column(pos - match.size) - 1
            encoder.text_token matched, :content if scan(/(?:\n+ {#{string_indent + 1}}.*)+/)
            encoder.end_group :string
            next
          when match = scan(/(?![!"*&]).+?(?=$|\s+#)/)
            encoder.begin_group :string
            encoder.text_token match, :content
            string_indent = key_indent || column(pos - match.size) - 1
            encoder.text_token matched, :content if scan(/(?:\n+ {#{string_indent + 1}}.*)+/)
            encoder.end_group :string
            next
          end

        elsif case
          when match = scan(/[-:](?= |$)/)
            state = :value if state == :colon && (match == ':' || match == '-')
            state = :value if state == :initial && match == '-'
            encoder.text_token match, :operator
            next
          when match = scan(/[,{}\[\]]/)
            encoder.text_token match, :operator
            next
          when state == :initial && match = scan(/[-\w.()\/ ]*\S(?= *:(?: |$))/)
            encoder.text_token match, :key
            key_indent = column(pos - match.size) - 1
            state = :colon
            next
          when match = scan(/(?:"[^"\n]*"|'[^'\n]*')(?= *:(?: |$))/)
            encoder.begin_group :key
            encoder.text_token match[0,1], :delimiter
            encoder.text_token match[1..-2], :content
            encoder.text_token match[-1,1], :delimiter
            encoder.end_group :key
            key_indent = column(pos - match.size) - 1
            state = :colon
            next
          when match = scan(/(![\w\/]+)(:([\w:]+))?/)
            encoder.text_token self[1], :type
            if self[2]
              encoder.text_token ':', :operator
              encoder.text_token self[3], :class
            end
            next
          when match = scan(/&\S+/)
            encoder.text_token match, :variable
            next
          when match = scan(/\*\w+/)
            encoder.text_token match, :global_variable
            next
          when match = scan(/<</)
            encoder.text_token match, :class_variable
            next
          when match = scan(/\d\d:\d\d:\d\d/)
            encoder.text_token match, :octal
            next
          when match = scan(/\d\d\d\d-\d\d-\d\d\s\d\d:\d\d:\d\d(\.\d+)? [-+]\d\d:\d\d/)
            encoder.text_token match, :octal
            next
          when match = scan(/:\w+/)
            encoder.text_token match, :symbol
            next
          when match = scan(/[^:\s]+(:(?! |$)[^:\s]*)* .*/)
            encoder.text_token match, :error
            next
          when match = scan(/[^:\s]+(:(?! |$)[^:\s]*)*/)
            encoder.text_token match, :error
            next
          end

        else
          raise if eos?
          encoder.text_token getch, :error

        end

      end

      encoder
    end

  end

end
end


text:
mvn -Dmaven.test.skip=true clean compile package
# Use regular later: mvn clean compile package


text:
> **ATTENTION:** This repository is archived and therefore readonly.

# swiftmailer-validator
swiftmailer validator to be used in symfony

## usage

`validation.yml` file

````
AppBundle\Entity\SomeEntity:
    properties:
        mail:
            - NotBlank: ~
            - Email: ~
            - Artack\Component\Validator\Constraint\SwiftmailerEmail: ~
````