If you are using linux, then you can use linux perf instead of gprof, as described here:
http://code.google.com/p/jrfonseca/wiki/Gprof2Dot#linux_perf
Typing perf report
and selecting a function will allow you to get line-by-line information about where the CPU time is spent inside the function.