>p0008a "src:inline: DB(0x68); DD(\"hello\\n\"); DB(0xe8); DD_R(printf - 4); DB(0x58); DB(0xc3);"
>p0008a "src:inline: PUSH_I(\"hello\\n\"); CALL_I(printf); POP_R(EAX); RET();"
#define c a+b
#define b 2
#define a 1
printf("%d\n", c);printf("%d\n", c);
#define c a+b
#define b 2
#define a 1 8.0KB : printf("hello, world\n"); のみの.exeファイル
23.5KB : p0008a.c で pp のみ(Mode=0)
28.0KB : p0008a.c で pp+cc (Mode=1)
30.0KB : p0008a.c で pp+cc+cjit (Mode=2)
35.5KB : p0008a.c で pp+cc+cjit+clang (Mode=3)
37.5KB : p0008a.c で pp+cc+cjit+clang+calc+graphic (Mode=4)a_static char *a_memmem0(const char *t, intptr_t tn, const char *p, intptr_t pn)
{
if (pn <= 0) return (char *) t;
if (tn < pn) return NULL;
intptr_t i = pn - 1;
const char *t1 = t + tn - pn, c0 = p[0];
for (t--;;) {
nxt:
t = memchr(t + 1, c0, t1 - t);
if (t == NULL) return NULL;
if (t[i] == p[i]) {
for (i = 1; i < pn; i++) {
if (t[i] != p[i]) goto nxt;
}
return (char *) t;
}
}
}
a_static char *a_memmem(const char *t, intptr_t tn, const char *p, intptr_t pn)
{
if (pn <= 0) return (char *) t;
if (tn < pn) return NULL;
intptr_t i = pn - 1;
const char *t1 = t + tn - pn, *t16 = t1 - 16, c0 = p[0];
for (t--;;) {
nxt:
t++;
for (;;) {
if (t <= t16) {
if (t[0] == c0) goto t0;
if (t[1] == c0) goto t1;
if (t[2] == c0) goto t2;
if (t[3] == c0) goto t3;
if (t[4] == c0) goto t4;
if (t[5] == c0) goto t5;
if (t[6] == c0) goto t6;
if (t[7] == c0) goto t7;
if (t[8] == c0) goto t8;
if (t[9] == c0) goto t9;
if (t[10] == c0) goto t10;
if (t[11] == c0) goto t11;
if (t[12] == c0) goto t12;
if (t[13] == c0) goto t13;
if (t[14] == c0) goto t14;
if (t[15] == c0) goto t15;
t += 16;
continue;
}
if (t > t1) return NULL;
if (t[0] == c0) goto t0;
t++;
}
t15: t++;
t14: t++;
t13: t++;
t12: t += 12; goto t0;
t11: t++;
t10: t++;
t9: t++;
t8: t += 8; goto t0;
t7: t++;
t6: t++;
t5: t++;
t4: t += 4; goto t0;
t3: t++;
t2: t++;
t1: t++;
t0:
if (t[i] == p[i]) {
for (i = 1; i < pn; i++) {
if (t[i] != p[i]) goto nxt;
}
return (char *) t;
}
}
}
#include <acl4v1.c>
#include "t0003a.c" // ここにa_memmem()があります.
int main(void)
{
char *s = malloc(900 * 1024 * 1024); // 900MB.
int i, j = 0;
for (i = 0; i <= 100000000; i++) // とりあえず1億.
j += sprintf(s + j, "%d ", i);
printf("j=%d\n", j);
clock_t t0, t1, t2;
t0 = clock();
int rs = (int) strstr(s, " 100000000");
t1 = clock();
int rm = (int) a_memmem(s, j, " 100000000", 10);
t2 = clock();
printf("strstr=%x\n", rs);
printf("a_memmem=%x\n", rm);
printf("t1-t0=%d t2-t1=%d\n", t1-t0, t2-t1);
return 0;
}
t1-t0=321 t2-t1=292 t1-t0=272 t2-t1=272 t1-t0=278 t2-t1=273
#include <acl4v1.c>
#include "t0003a.c"
int main(void)
{
char *s = malloc(140 * 1024 * 1024); // 140MB.
int i, j = 0;
for (i = 0; i <= 10000000; i++) // とりあえず100万.
j += sprintf(s + j, "count=%d ", i);
printf("j=%d\n", j);
clock_t t0, t1, t2;
t0 = clock();
int rs = (int) strstr(s, "count=10000000");
t1 = clock();
int rm = (int) a_memmem(s, j, "count=10000000", 14);
t2 = clock();
printf("strstr=%x\n", rs);
printf("a_memmem=%x\n", rm);
printf("t1-t0=%d t2-t1=%d\n", t1 - t0, t2 - t1);
return 0;
}
t1-t0=101 t2-t1=46 t1-t0=96 t2-t1=45 t1-t0=97 t2-t1=42
| 8+8=16型 | 8 | 64 | 512 | 4096 |
| 10+6=16型 | 6 | 60 | 600 | 6000 |
| 7+9=16型 | 9 | 63 | 441 | 3087 |
| 6+10=16型 | 10 | 60 | 360 | 2160 |
| 5+11=16型 | 11 | 55 | 275 | 1375 |
| 4+12=16型 | 12 | 48 | 192 | 768 |
| コメント | お名前 | NameLink | |