Skip to content

Instantly share code, notes, and snippets.

@ranha
Created March 27, 2012 04:14
Show Gist options
  • Save ranha/2212478 to your computer and use it in GitHub Desktop.
Save ranha/2212478 to your computer and use it in GitHub Desktop.
azu
/Users/ranha/c_misc/souwa% gcc --version
i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
/Users/ranha/c_misc/souwa% gcc -Wall -Wextra nyan.c
/Users/ranha/c_misc/souwa% ./a.out
1 + 2 + 3 + 4 + 5
15
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
int f();
int main();
int f(void)
{
srand(182551180);
if((((uint64_t)main) + 13) ==
*(((uint64_t*)__builtin_frame_address(0)) + ((5-1) * 6) + 1)){
puts("5");
return 5;
}
for(;;) {
if((((uint64_t)main) + 13) ==
*(((uint64_t*)__builtin_frame_address(0)) + ((rand() % 5) * 6) + 1)){
printf("%d + ",(rand() % 5) + 1);
return ((rand()%5) + 1) + f();/* a + bはaが先にcallされるとする */
}
else {
(void)(rand()%5);
(void)(rand()%5);
}
}
}
int main()
{
printf("%d\n",f());
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment