Galaxy S5 Freezes Constantly
As a method of starting to debug this, Linux keeps a log for the kernel. I'm not sure if /proc/last_kmsg is there or not, but you want the kernel log.

I'd start by replacing the stock recovery with TWRP. Whether or not you want to Flash to a different rom. TWRP has a file browser. It should let you save the kernel's log either way. You want to pay attention to two files:


/var/log/boot.msg (useful in the state after the failed boot)
/var/log/syslog (useful in the state after the crash, and the state after the boot)


You'll want to thoroughly examine these files and paste the contents up here. It's possible the problem is hardware though. I'd flash CM13 (because it's all around better), and see if that fixes it. If problems persist on a fresh CM13, you know you've got a hardware issue.