#include <iostream>
#include <cstdint>
using namespace std;

int32_t encode(int32_t a, int32_t b, int32_t c, int32_t d) {
	return (a << 12) + (b << 8) + (c << 4) + d;
}

void decode(int32_t value, int32_t *result) {
	const int32_t mask = 0xf;
	result[0] = (value >> 12) & mask; // a
	result[1] = (value >> 8) & mask; // b
	result[2] = (value >> 4) & mask; // c
	result[3] = value & mask; // d
}

int main() {
	int32_t result[] = {0, 0, 0, 0};
	
	int32_t encoded = encode(6, 4, 2, 9);
	decode(encoded, result);
	
	cout << "a: " << result[0] << endl
		<< "b: " << result[1] << endl
		<< "c: " << result[2] << endl
		<< "d: " << result[3] << endl;
	
	return 0;
}