Advertisement
imk0tter

Untitled

May 5th, 2014
443
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define PREVIOUS_FRAME(x) (*(int *)(x + ((int *)__builtin_frame_address(1) - (int *)__builtin_frame_address(0))))
  2. void f(int x)
  3. {
  4.     if (x > 0)
  5.     {  
  6.         x = -x;
  7.         printf("1\n");
  8.         f(-2);
  9.     }
  10.     else
  11.     {
  12.         if (PREVIOUS_FRAME(&x) <= x)
  13.         {
  14.             printf("%i\n", -x);
  15.             if (PREVIOUS_FRAME(&x) != x)
  16.                 f(PREVIOUS_FRAME(&x));
  17.         }
  18.         else
  19.         {
  20.             printf("%i\n", -(PREVIOUS_FRAME(&x) - 1));
  21.             if (x != PREVIOUS_FRAME(&x) - 1)
  22.                 f(PREVIOUS_FRAME(&x) - 2);
  23.         }
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement