#include <iostream>
#include <ctime>
#include <cstdint>
using std::cout;
using std::endl;

std::uint32_t rand_value;

std::uint32_t lcg()
{
	const auto a = 22695477u;
	const auto c = 1u;

	rand_value = a * rand_value + c;
	return rand_value;
}

enum func_method {log_or, mult};

template <typename test_type, func_method method>
void test_func()
{
	const unsigned long end = 800'000'000;
	unsigned int sum = 0;

	auto clock_begin = std::clock();
	if (method == func_method::log_or)
		for (unsigned long i = 0; i < end; ++i)
		{
			test_type a = lcg();
			test_type b = lcg();
			if (a == 0 || b == 0)
				++sum;
		}
	else if (method == func_method::mult)
		for (unsigned long i = 0; i < end; ++i)
		{
			test_type a = lcg();
			test_type b = lcg();
			if (a * b == 0)
				++sum;
		}
	else
		cout << "Invalid method" << endl;
	auto clock_end = std::clock();

	cout << "sum:  " << sum << endl;
	cout << "time: " << double(clock_end - clock_begin) / CLOCKS_PER_SEC << endl;
}

int main()
{
	typedef double test_type;
	
	rand_value = 1;
	test_func<test_type, func_method::mult>();
	rand_value = 1;
	test_func<test_type, func_method::log_or>();

	return 0;
}