entry sum_35() { new_env(1, 0); ildc(0); load(); null(); oequal(); jz(label2); ildc(0); ret(); jmp(label3); label2: ildc(0); load(); call(get_element_29); ildc(0); load(); ildc(1); getfield(); call(sum_35); iadd(); ret(); label3: null(); ret(); }
int main() { static char buf[256]; int i, c; for (i = 1, iset(pow26[0],"1"), iset(pow26_sums[0],"1"); i < 23; i++) { imuls(pow26[i], pow26[i - 1], 26); iadd(pow26_sums[i], pow26_sums[i - 1], pow26[i]); } for (;;) { for (i = 0; (c = getchar()) != EOF && c != '\n';) if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) buf[i++] = c; buf[i] = '\0'; if (c == EOF) break; if (i == 0) continue; if (buf[0] >= '0' && buf[0] <= '9') giveword(buf); else givenum(buf, i); } return 0; }
ulong machnextaddr(Ureg *ur) { Instr i; i = machinstr(ur->pc); switch(instrtype(i)) { case IADD: return iadd(ur,i); case IBRANCH: return ibranch(ur,i); case ILDM: return ildm(ur,i); case ILDR: return ildr(ur,i); case IMOV: return imov(ur,i); case IADC: case IAND: case IBIC: case IEOR: case ILDRT: case IMRS: case IMVN: case IORR: case IRSB: case IRSC: case ISBC: case ISUB: // XXX - Tad: unimplemented // // any of these instructions could possibly have the // PC as Rd. Eventually, these should all be // checked just like the others. default: return ur->pc+4; } return 0; }
int main(int argc, const char *argv[]) { int i; int *mem = malloc(1100000); capture_stdio(); for (i = 0;; ++i) { int32_t t0[2], t1[2]; char *msg; int n; gp_get_usertime(t0); switch (i) { case 0: iadd(0, n = 10000000, &msg); break; case 1: imul(1, n = 1000000, &msg); break; case 2: idiv(1, n = 1000000, &msg); break; case 3: fadd(3.14, n = 10000000, &msg); break; case 4: fmul(1.0000001, n = 10000000, &msg); break; case 5: fdiv(1.0000001, n = 1000000, &msg); break; case 6: fconv(12345, n = 10000000, &msg); break; case 7: mfast(mem, n = 10000000, &msg); break; case 8: mslow(mem, n = 1000000, &msg); break; default: free(mem); exit(0); } gp_get_usertime(t1); fprintf(stdout, "Time for %9d %s = %g ms\n", n, msg, (t1[0] - t0[0]) * 1000.0 + (t1[1] - t0[1]) / 1000000.0); fflush(stdout); } }
static void givenum(const char *s, int len) { static limb_t x[NLIMBS]; int i; iset(x, "0"); for (i = 0; i < len; i++) { if (i >= 1) imuls(x, x, 26); if (s[i] >= 'a' && s[i] <= 'z') iadds(x, s[i] - 'a'); else iadds(x, s[i] - 'A'); } iadd(x, x, pow26_sums[len - 1]); printf("%-22s", s); iprint(x); }
entry length_34() { new_env(1, 0); ildc(0); load(); null(); oequal(); jz(label0); ildc(0); ret(); jmp(label1); label0: ildc(1); ildc(0); load(); ildc(1); getfield(); call(length_34); iadd(); ret(); label1: null(); ret(); }
entry main_40() { new_env(0, 3); ildc(1); newobj(2); ildc(0); call(List_28); store(); pop(); ildc(0); ildc(1); store(); pop(); label6: ildc(0); load(); ildc(6); ilt(); jz(label7); ildc(1); ildc(1); load(); ildc(0); load(); call(push_front_30); store(); pop(); label8: ildc(0); dup(); load(); swap(); dup(); load(); ildc(1); iadd(); store(); pop(); pop(); jmp(label6); label7: ildc(1); load(); call(print_36); pop(); ildc(6); call(print_13); pop(); ildc(1); load(); call(length_34); call(println_15); pop(); ildc(9); call(print_13); pop(); ildc(1); load(); call(sum_35); call(println_15); pop(); ildc(2); newobj(2); ildc(1); load(); call(get_element_29); call(List_28); store(); pop(); ildc(1); ildc(1); load(); call(pop_front_33); store(); pop(); label9: ildc(1); load(); null(); onotequal(); jz(label10); ildc(2); ildc(2); load(); ildc(1); load(); call(get_element_29); call(push_front_30); store(); pop(); ildc(1); ildc(1); load(); call(pop_front_33); store(); pop(); jmp(label9); label10: ildc(2); load(); call(print_36); pop(); ildc(11); call(print_13); pop(); ildc(2); load(); call(length_34); call(println_15); pop(); ildc(14); call(print_13); pop(); ildc(2); load(); call(sum_35); call(println_15); pop(); null(); ret(); }