Question: Every `x` blocks the mining reward is halved. Will the reward be halved forever such that we never quite reach 21 million bitcoins, or will we reach 21 million bitcoins at some point and will the reward cease to exist altogether?

Extra points for pointing to the relevant code!

Answer: 
Neither. The reward eventually ceases, but not at 21 million Bitcoins.

Here's the code (edited for clarity and brevity):

```
int halvings = nHeight / 210000;
CAmount nSubsidy = 50 * COIN; // COIN is one Bitcoin
// Subsidy is cut in half every 210,000 blocks which will occur approximately every 4 years.
return nSubsidy >> halvings;

```

[(Source.)](https://github.com/bitcoin/bitcoin/blob/a0625b8085aa379ac5f7bdca6f2cbf3cbb4a5d0a/src/main.cpp#L1093)

Note that it cuts the reward in half using the bit-shift operator, which means that eventually it won't be able to reduce the block reward by exactly half. So how many Bitcoins does it end up making in total?

20,999,999.9769 BTC, or 2,310,000 satoshis short of 21 million. (If you want to be a lot of fun at parties, bring this up whenever someone says that the maximum number of Bitcoins is 21 million.)

Then there are the various Bitcoins that aren't spendable due to various quirks of the Bitcoin protocol, like the [genesis block coinbase](https://bitcoin.stackexchange.com/questions/10009/why-can-t-the-genesis-block-coinbase-be-spent), or the [duplicated coinbase](https://web.archive.org/web/20150511232412/http://blockexplorer.com/block/00000000000743f190a18c5577a3c2d2a1f610ae9601ac046a38084ccb7cd721). [Edit: Or the many other instances of unspendable Bitcoins that Pieter mentions in his answer.]
20997107.88801356 once you remove the 2709.42507135 BTC “burn addresses” i.e. the bitcoin addresses with almost assuredly no earthly known private keys and therefore unspent lost forever. There are ~400 burn addresses with a total balance of 2759.42507135 as of Dec 2017 (2709.42507135 excluding the genesis block). Last year the burn addresses balance grew by [8.97 BTC](https://bitcoinwhoswho.com/blog/2017/12/30/8-97-bitcoins-burned-in-2017/)