The response FAILED open or read happens when the file specified in the md5 checksum file (md5sum.tmp in your case) does not exist.

For example.

 [user@localhost tmp]$ cd /tmp/testfolder
 [user@localhost testfolder]$ touch dog
 [user@localhost testfolder]$ md5sum dog > /tmp/md5sum.tmp
 [user@localhost testfolder]$ md5sum -c /tmp/md5sum.tmp
 dog: OK
 [user@localhost testfolder]$ cd ..
 [user@localhost tmp]$ md5sum -c /tmp/md5sum.tmp
 md5sum: dog: No such file or directory
 dog: FAILED open or read
 md5sum: WARNING: 1 listed file could not be read

Note that I believe the md5sum program does not look at the standard input when passed the -c option. It simply looks at the checksums in the file specified by the -c option. If they exist and the filename matches, than it compares it and all is happy.

While there is probably a better way, storing the result of two separate md5sums in a variable and then comparing them with an if statement is probably the approach I would take.