#include <assert.h>
#include <stdbool.h>
#include <stdint.h>

static void encode_le16(uint16_t x, uint8_t *b)
{
	b[0] = x & 0xff;
	b[1] = x >> 8;
}

static uint16_t decode_le16(uint8_t *b)
{
	return b[0] | (b[1] << 8);
}

bool decode_encode_le16_ok(uint16_t x)
{
	uint8_t b[2];

	encode_le16(x, b);
	return decode_le16(b) == x;
}

int main(void)
{
	uint32_t x;

	for (x = 0; x <= UINT16_MAX; ++x)
		assert(decode_encode_le16_ok(x));

	return 0;
}