OK the first schema:
It's a little confusing because of an added Midi Thru function on the Out DIN. This is not the norm. a Thru should be a 3rd DIN socket using pins 2, 4 and 5. Wired this way, you would need a special cable that separated the two midi loops. Atari STs were wired this way, and it was a bad idea back then too.
Starting from the left:
The two inverter gates connected to pin 3 form a buffer of the TTL Midi coming from the Midi In DIN. Pin 1 is the Current source for this loop.
The other two inverters gates and resister connected to pin 5, are buffering the TTL from the header, most times not needed but if the controller has very low output drive levels, the gates would provide higher drive. In this circuit the current source is connected thru a resister on pin 4. The reason for the two resisters on pins 4 and 5, is to limit current if either pin get connect to power or shorted to GND. The total resistance is selected for the loop current but using two Rs adds protection to each pin going to the outside world.
The use of two gates is to have a non-inverting buffer. This kind of shows what I had talked about before, when the gate outputs a 1, the pin is at Vcc, there would be a high on both sides of the LED in the opto at the far end, so no current flows. When the gate outputs a 0, the pin is at GND. Now the current flows from the source, out the cable on pin 4, across the LED, back on the cable pin 5 and to GND. This is Push-Pull active output.
On pin 2 GND is connected, this is just for shielding in the cable as it's never connected to the system GND on the other end. Even though there is a cable connecting two devices they are electrically isolated, this is to avoid GND loops that cause hum in audio.
The Midi In DIN:
DIN Pin 4 is the current source from the distant Midi Out. It flows thru the R and to the anode of the opto's LED. The LED's cathode connects to pin 5, the return path. The diode between DIN 4 and 5 is there for reverse voltage protection.
The other half of the opto is made up of a Light dependent gate and a transistor pair. When light hits the gate, it conducts and applies a bias voltage to the first Trans. This bias turns the junction on and current flows from it's collector to the emitter. This emitter voltage turns on the second Trans causing it's collector, the Rx line pin6, to be pulled to GND.
When these Trans are Off the Rx line is pulled to Vcc by R4.
R3 is there to improve switching by draining off the emitter voltage quickly.
The second Trans is 'open Collector' meaning it's collector is not directly connected to Vcc in the chip. The last schema shows the opto powered by 5V but the OC Rx line is pulled up to 3.3V. This would be needed with a controller that is not 5V tolerant.
The second schema:
This is wrong because there is only a single R for the Midi Out loop. As stated above, this may work but if there is a short on pin 5 it could kill the Tx pin of the controller. Also there is no Rev Polarity diode on the opto, so it's more prone to being destroyed.
Most of these circuits are based on Transistor Transistor Logic, and are current dependent. They may work at a lower voltage than they are rated for but would be switching slower and /or drawing higher current and over stressing the junctions. Meaning a shorter life.
As you've seen there are lots of different designs out there, some good, some bad. Stick with the tried and tested ones, where it's been used by many people. The design on the Teensey Midi page for example has been tested by alot of builders, it's a well tested and safe bet. I use the 6n138 design used by the MIDIbox community because it's well tested also and by sticking to a 'favorite' design it allows me to keep the standard parts on hand.
Anyways, have fun,
Yogi