What is the grammatical name of"had a stray dog not given them away" and it's function?

subordinate clause

it's equivalent to
if a stray dog had not given them away

The phrase "had a stray dog not given them away" is a conditional clause. Specifically, it is a type of conditional clause known as a "third conditional" or "past unreal conditional." The function of this conditional clause is to express a hypothetical situation in the past and its potential outcome. In this case, it suggests that if a stray dog had not given them away in the past, something else would have happened.