It seems that you have a dead PCIe slot on your board. Since it's relatively new you should RMA it.
Why do you need the 2nd PCIe slot? You only have one GPU, so you should always be using the 1st slot because that's the one that uses all the 16x PCIe lanes. The 2nd slot is using only 8x lanes. You could also try updating the BIOS if you haven't done that already. Your CPU is fairly new and that board is old and it needs a BIOS update in order to properly support the kaby lake CPUs.
Also the bent pins have nothing to do with that. The CPU is connected only with the 1st PCIe 16x slot. The motherboard uses special switches that transfer 8 of those lanes to the 2nd slot. If one of those switches is bad/damaged or a bad capacitor could...