Return values from a purely assembly language standpoint don't really need memory allocated unless they are being stored in another variable. Integral return values in C/C++ are stored in EAX and floating point return values are stored in ST(0). If there is no further need for these variables a simple cmp instruction can be executed and then flow can branch based on the results. No memory allocation is required for this type of code.
Since function returns int the result of the function will be stored in EAX by the compiler. The result of function() could be placed into a temporary variable which would need memory or it could also be placed in another register in preparation for the eventual cmp that will be executed. I suspect that most compilers can optimize this type of code if the result of function() is never used again meaning that no memory needs to be allocated to both store and examine the return value of function(). It really depends on the state of the program at the time and what registers are being used for which purposes. Compilers are extremely smart, though, so I suspect that if the result of function() is not needed later in the code...any good compiler would optimize this out to a simple register comparison.