Pied Piper's Compression Code From HBO's Silicon Valley, Compiled

The third season of HBO's Silicon Valley is now under way and if you caught the first episode, you would have noticed a snippet of Pied Piper's valuable compression code towards the end of the show. Turns out this code actually compiles, though the output isn't what you might expect.

Or perhaps it is.

Obviously, Mike Judge doesn't hold the key to a compression algorithm that tosses the laws of information entropy out the window. So, what's the next best thing? Well, that would be a joke.

You can see the code snippet from the show, in written form, over on Wikicoding. For those with sore clicking fingers, here it is replicated:


typedef unsigned long u64;

/* Start here */
typedef void enc_cfg_t;
typedef int enc_cfg2_t;
typedef __int128_t dcf_t;

enc_cfg_t _ctx_iface(dcf_t s, enc_cfg2_t i){
	int c = (((s & ((dcf_t)0x1FULL <> i * 5) + 65);
	printf("%c", c); }
	enc_cfg2_t main() {
	for (int i=0; i<17; i++){
		_ctx_iface(0x79481E6BBCC01223 + ((dcf_t)0x1222DC <0; c >>= 1)
		d += c & 1;
	// O(m) lol no thanks

	//1000 wrap into loop
	c = c - ((c >> 1) & ~0UL/3);
	c = (c & ~0UL/5) + ((c >> 2) & ~0UL/5);
	c = (c & 0UL/0x21) + ((c >> 4) & 0UL/0x11);
	c = (c & ~0UL/0x101) + ((c >> 8) & ~0UL/0x101);
	c = (c & ~0UL/0x10001)+((c>>16)&~0UL/0x10001);
	c = (c & ~0UL/0x100000001)+((c>>32)&~0UL/0x100000001);

	//TODO throw away intermediates... but could be useful later (see seander)
	return c;

//TODO transform + multiply spectra + transform back. faster? lossy?

u64 * ConvolutedMagic(u64 *x, u64 y, u64 *z, u64 n, u64 n_y) {
	//z is array of offsets in BITS
	//y is left-aligned of length n_y
	//TODO function is ridic fragile. e.g. if len z > len x/y...

	u64 * a = malloc(sizeof(u64)*n);
	u64 b,o_64,o_bit;

	for (int i=0; i> 6;
		o_bit= z[i] - ((z[i]>>6) << 6);
		b = *(x+o_64) < 0) {
			b += x[o_64+1] >> (64-o_bit);
		b = (b >> (64-n_y))<> (64-n_y))<<(64-n_y); //not necessary, just in case
		a[i] = HammingCtr(b,y);

	return a;

int main() {
	//test hamconv
	u64 x[] = {1,2,3,4,5,6,7,8};
	u64 y = 15;
	u64 z[] = {0,64,64*2,64*3,64*4,64*5,64*6,64*7};

	u64 n_samples = sizeof(z)/sizeof(u64);
	u64 *out = ConvolutedMagic(x,y,z,n_samples,64);

	for (int i=0; i<n_samples;i++) {

	return 0;

What language is that? It's good old C and if you reckon it should compile, well, it does. Does it produce the mystical and highly vaunted middle-out compression from the show? No.

For those without a C compiler at the ready, you can do it online. As for the output, it's a simple one-liner:


Dream on indeed.

[Wikicoding, via Reddit]


    The line 69 void Main() is commented out by the characters on line 68 and 83.

    The actual main function is poorly indented, so appears as part of the function enc_cfg_t _ctx_iface(), but that function is terminated by the } parenthesis a the end of line 13. The main function is on the next line using the user defined type for int as enc_cfg2_t to help disguise it.
    Then the code is really just translating bits to ascii through the _ctx_iface function to print out the phrase. The rest is just for disguise.

    Someone knows too much about bad programming techniques to produce this!

    It is a cool little easter egg but i do find it a mystery why directors put so much effort into details that would go over the heads of 99% of the audience.

      It's the little details that make the big picture. Kudos for playing to your target audience.

      My guess would be that when people discover the easter egg the show gets free publicity. Maybe they even leak it to a few groups.

      Something like this they might have also figured certain members of their audience were definitely going to test the code and this seems like something a friend could have chucked together for them in 5 minutes.

      I've been watching the show since day 1. But see ZERO about it in mainstream media. This is the first I've seen of it. So it has worked as far as I am concerned.

    because that 1% was always going to check it so it has to make sense or they will be called out and if it's going to be logical code, why not make it an easter egg.

    Is the dick-to-floor ratio correct? You need to account for elbows.

Join the discussion!