For an example, let's say that in_buf = 0x1000 0000. At 0x1000 0000, we have stored the data, the next 16 bits being "0110 0000 0011 0010". bit_buf = 0000 0000 0001 0110 and bits = 8 (since we have 8 bits still loaded in bit_buf).
Now, we want to load the next 16 bits into bit_buf. The first step is to get the next 16 bits from in_buf, which is accomplished by *(unsigned short *)is->in_buf (since in_buf is a pointer, we need to use * to get the actual data from it, and since we only want 16 bits we cast it to unsigned short.)
Loaded data: 0110 0000 0011 0010
The next step it to make sure we are only loading 16 bits and not losing any data. Right now there is 8 bits still loaded into bit_buf, so if we just set bit_buf to what we just loaded, we will lose those 8 bits. So what we do is shift our newly loaded data left by however many bits are still in bit_buf so we aren't overwriting anything but we aren't getting out of order.
Loaded data is now: 0011 0010 0000 0000
Next, we will use the OR operator to set our data without losing the old data. OR takes 2 binary numbers and combines them so that any bits that = 1 in either numbers = 1 in the new number, and any bits that = 0 in both numbers = 0 in the new number.
bit_buf: 0000 0000 0001 0110
New data: 0011 0010 0000 0000
After OR: 0011 0010 0001 0110
And there you have it. bit_buf is now loaded with the next 16 bits.