Advertisement
Guest User

Untitled

a guest
Jan 20th, 2011
316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. inline static int foo(int a) {
  2.     return 2*a;
  3. }
  4.    
  5.  
  6. int a(int x) {
  7.     return foo(x)+1;
  8. }
  9.  
  10. int b(int x, int (*fptr)(int)) {
  11.     return fptr(x)+1;
  12. }
  13.  
  14. int test1(int n) {
  15.     return a(n);
  16. }
  17. int test2(int n) {
  18.     return b(n,foo);
  19. }
  20.  
  21. /*
  22. g++ -O3 -Os:
  23.  
  24. (...)
  25.  
  26. .globl __Z5test1i
  27.         .def    __Z5test1i;     .scl    2;      .type   32;     .endef
  28. __Z5test1i:
  29.         pushl   %ebp
  30.         movl    %esp, %ebp
  31.         movl    8(%ebp), %eax
  32.         leal    1(%eax,%eax), %eax
  33.         leave
  34.         ret
  35. .globl __Z5test2i
  36.         .def    __Z5test2i;     .scl    2;      .type   32;     .endef
  37. __Z5test2i:
  38.         pushl   %ebp
  39.         movl    %esp, %ebp
  40.         movl    8(%ebp), %eax
  41.         leal    1(%eax,%eax), %eax
  42.         leave
  43.         ret
  44. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement