Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- inline static int foo(int a) {
- return 2*a;
- }
- int a(int x) {
- return foo(x)+1;
- }
- int b(int x, int (*fptr)(int)) {
- return fptr(x)+1;
- }
- int test1(int n) {
- return a(n);
- }
- int test2(int n) {
- return b(n,foo);
- }
- /*
- g++ -O3 -Os:
- (...)
- .globl __Z5test1i
- .def __Z5test1i; .scl 2; .type 32; .endef
- __Z5test1i:
- pushl %ebp
- movl %esp, %ebp
- movl 8(%ebp), %eax
- leal 1(%eax,%eax), %eax
- leave
- ret
- .globl __Z5test2i
- .def __Z5test2i; .scl 2; .type 32; .endef
- __Z5test2i:
- pushl %ebp
- movl %esp, %ebp
- movl 8(%ebp), %eax
- leal 1(%eax,%eax), %eax
- leave
- ret
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement