Callgrind is a profiling tool that can be used via the Valgrind framework and its report can be displayed/inspected with the KCachegrind profile data visualization tool.
sudo apt-get install valgrind kcachegrind graphviz
Not necessarily required but useful to have the debugging information in the binary so if it's possible compile with the -g option.
gcc -g -o program program.c
valgrind --tool=callgrind <program> [program-options]
# or even
valgrind --tool=callgrind --dump-instr=yes --simulate-cache=yes --collect-jumps=yes <program> [program-options]
NOTE: This way the program runs much slower...
kcachegrind &