simplified:
nonce is part of data.
data leads to hash1 in call to runhash1.
hash1 leads to hash in call to runhash2. (runhash1 and runhash2 are the same method: runhash)
potential valid block if hash[7] is zero.
runhash1(hash1, data, midstate);
runhash2(hash, hash1, sha256_init_state);
how would you like to optimize this ?