When embedding assembly code into a C/C++ program, you can avoid clobbering registers by saving them with a push instruction (or specify clobber list of compiler supports it).
If you are including assembly inline and want to avoid the overhead of pushing and popping clobbered registers, is there a way of letting gcc choose registers for you (e.g. ones it knows have no useful info in them).
Yes. You can specify that you want a particular variable (input or output) to be stored in a register, but you don’t have to specify a register. See this document for a detailed explanation. Essentially, the inline assembly looks like this: