How to conditionally replace a pattern?

Hi,

How to replace only the function calls with a new name and skip the function definition and declarations. consider the following code.
There are 2 functions defined here returnint and returnvoid.
I need to replace returnint with giveint and returnvoid with givevoid only in the function calls.

1  static int returnint(int num1);
2  static void returnvoid(int num1);
3  void main()
4  {
5     int num1;
6     num1=returnint(3);
7     returnvoid(2);
8     returnvoid(5);
9   }
10  static int returnint(int num1)
11  {
12       returnvoid(5);
13       return 12;
14   }
15   static void returnvoid(int num1)
16   {
17        return;
18   }

function calls are present in line numbers 6,7,8 and 12. so in all these lines, the existing function is to be replaced with the new names given.
funcion declarations and definitions present at lines 1,2,10 and 15 are to be skipped and the original function names are to be retained.
sample output:

1  static int returnint(int num1);
2  static void returnvoid(int num1);
3  void main()
4  {
5     int num1;
6     num1=giveint(3);
7     givevoid(2);
8     givevoid(5);
9   }
10  static int returnint(int num1)
11  {
12       givevoid(5);
13       return 12;
14   }
15   static void returnvoid(int num1)
16   {
17        return;
18   }

Thanks,
Srini

 
$ nawk '!/static.*return/{if($0!~/return[\; ]/)sub("return","get");print}/static.*return/' test.txt
static int returnint(int num1);
static void returnvoid(int num1);
void main()
{
int num1;
num1=getint(3);
getvoid(2);
getvoid(5);
}
static int returnint(int num1)
{
  getvoid(5);
  return 12;
}
static void returnvoid(int num1)
{
   return;
}

There is one logic i can think of. both the function definition and declaration have the return types(int or void or long) in them along with the function name.
So can we form an array of all such possible return types and when the returntype present in the array is there along with function, it is skipped else it is changed with the new name into the same file?
i could not arrive at any code for this logic. :frowning:

---------- Post updated at 04:44 PM ---------- Previous update was at 04:38 PM ----------

@itkamaraj : Thanks for the reply.
But it is NOT the convention that the function name has to start with returnABC etc, it can be anything like validateABC or getTheValOfABC etc. Also static is optional in both function definition and declaration. Can u please help by checking my previous comment (using the array of return types one).

Thanks,
Srini