/* ARGSUSED */ static void output_trans2_findfirst(int flags, uchar_t *data, char *xtra, int xsz) { int length; char filename[256]; char infolevel[100]; if (flags & F_SUM) { length = snprintf(xtra, xsz, " Findfirst"); xtra += length; xsz -= length; data += 12; (void) unicode2ascii(filename, 256, data, 512); snprintf(xtra, xsz, " File=%s", filename); } if (flags & F_DTAIL) { show_line("FunctionName = Findfirst"); show_printf("SearchAttributes = 0x%.4x", get2(data)); data += 2; show_printf("FindCount = 0x%.4x", get2(data)); data += 2; show_printf("FindFlags = 0x%.4x", get2(data)); data += 2; get_info_level(infolevel, sizeof (infolevel), get2(data)); show_printf("InfoLevel = %s", infolevel); data += 6; (void) unicode2ascii(filename, 256, data, 512); show_printf("FileName = %s", filename); } }
char *fmt_inst(uchar *pc) { uchar *args = pc; struct _opcode *ip = &optable[*pc++]; static char buf[80]; const char *p; char *s = buf; if (ip->i_name == NULL) { strcpy(buf, "UNKNOWN"); return buf; } s += sprintf(s, "%s", ip->i_name); for (p = ip->i_patt; *p != '\0'; p++) { switch (*p) { case '1': case 'K': s += sprintf(s, " %d", get1(pc)); pc++; break; case '2': case 'L': s += sprintf(s, " %d", get2(pc)); pc += 2; break; case 'R': s += sprintf(s, " %d", get2(pc)+(args-imem)); pc += 2; break; case 'S': s += sprintf(s, " %d", get1(pc)+(args-imem)); pc += 1; break; case 'N': s += sprintf(s, " %d", ip->i_arg); break; default: s += sprintf(s, " ?%c?", *p); } } return buf; }
int main() { int n,m,num2,num3,num5,num7,num9; int table[4][4]={6,2,4,8,1,3,9,7,1,7,9,3,1,9,1,9}; while(scanf("%d%d",&n,&m)!=EOF) { num2=get2(n)-get2(n-m); num5=get5(n)-get5(n-m); num3=getx(n,3)-getx(n-m,3); num7=getx(n,7)-getx(n-m,7); num9=getx(n,9)-getx(n-m,9); if(num2<num5) { printf("5\n"); continue; } int result=1; if(num2!=num5) { result*=table[0][(num2-num5)%4]; } result*=table[1][num3%4]; result*=table[2][num7%4]; result*=table[3][num9&1]; printf("%d\n",result%10); } return 0; }
static int findCDir(Biobuf *bin) { int64_t ecoff; int32_t off; int entries, zclen; ecoff = Bseek(bin, -ZECHeadSize, 2); if(ecoff < 0) sysfatal("can't seek to header"); if(get4(bin) != ZECHeader) sysfatal("bad magic number on directory"); get2(bin); get2(bin); get2(bin); entries = get2(bin); get4(bin); off = get4(bin); zclen = get2(bin); while(zclen-- > 0) get1(bin); if(Bseek(bin, off, 0) != off) sysfatal("can't seek to contents"); return entries; }
static void gethms(int i) { //hms field[i] char *c = field[i]; gpst.hr = get2(c); gpst.mn = get2(&c[2]); gpst.sc = get2(&c[4]); if (c[6] && c[6] == '.') gpst.scth = get3(&c[7]); }
V7_PRIVATE struct v7_val *find(struct v7 *v7, const struct v7_val *key) { struct v7_val *v, *f; if (!EXECUTING(v7->flags)) return NULL; for (f = v7->ctx; f != NULL; f = f->next) { if ((v = get2(f, key)) != NULL) return v; } if (v7->cf && (v = get2(v7->cf->v.func.var_obj, key)) != NULL) return v; return NULL; }
void gettoken(void) { strcpy(token,pending); get2(); if (!strcmp("/",token) && !strcmp("*",pending)) { d("comment:",token,pending); while (strcmp("*",token) || strcmp("/",pending)) { strcpy(token,pending); get2(); d(" ",token,""); } strcpy(token,pending); get2(); strcpy(token,pending); get2(); } d("gettoken returning",token,pending); }
// variable = identifier { '.' identifier | '[' expression ']' } static enum v7_err parse_variable(struct v7 *v7) { struct v7_val **v = NULL, key = str_to_val(v7->tok, v7->tok_len); struct v7_val *ns = find(v7, &key), ro_prop; if (!v7->no_exec) { TRY(v7_make_and_push(v7, V7_UNDEF)); v = v7_top(v7); } while (*v7->cursor == '.' || *v7->cursor == '[') { int ch = *v7->cursor; TRY(match(v7, ch)); CHECK(v7->no_exec || ns != NULL, V7_SYNTAX_ERROR); v7->cur_obj = ns; if (ch == '.') { TRY(parse_identifier(v7)); if (!v7->no_exec) { key = str_to_val(v7->tok, v7->tok_len); ns = get2(ns, &key); if (ns != NULL && ns->type == V7_RO_PROP) { ns->v.prop_func(v7->cur_obj, &ro_prop); ns = &ro_prop; } } } else { TRY(parse_expression(v7)); TRY(match(v7, ']')); if (!v7->no_exec) { ns = get2(ns, v7_top(v7)[-1]); if (ns != NULL && ns->type == V7_RO_PROP) { ns->v.prop_func(v7->cur_obj, &ro_prop); ns = &ro_prop; } TRY(inc_stack(v7, -1)); } } } if (v != NULL && ns != NULL) { free_val(v7, v[-1]); v[-1] = ns; v[-1]->ref_count++; } return V7_OK; }
void init(void) { int i; d("init","",""); get2(); gettoken(); for (i = 0; i < MAXTAB; i++) keytab[i][0] = '\0'; }
int main(){ int i,a,b,t; char s[5]; for(i=0;i<30000;i++)h1[i]=i+1; while(scanf("%d %s",&a,s)!=EOF){ while(l2>0&&m[h2[0]]<a){ t=get2(); m[t]=0; add1(t); } if(s[0]=='+'){ t=get1(); printf("%d\n",t); m[t]=a+599; add2(t); }else{ scanf("%d",&b); if(m[b]==0)printf("-\n"); else{ printf("+\n"); m[b]=a+599; adj2(b); } } } return 0; }
static void getll(int f) { int l, d; char *c; c = field[f++]; l = get2(c); c += 2; d = (getndp(c, 5) + 1) / 6; c = field[f++]; l *= 1000000; l += d; if (*c != 'N') l = -l; // if (l != gpst.llat) // chg = 1; gpst.llat = l; c = field[f++]; l = get3(c); c += 3; d = (getndp(c, 5) + 1) / 6; c = field[f]; l *= 1000000; l += d; if (*c != 'E') l = -l; // if (l != gpst.llon) // chg = 1; gpst.llon = l; }
void cmdsrc(int c, Map *map) { u32int w; long locval, locmsk; ADDR savdot; ushort sh; char buf[512]; int ret; if (c == 'L') dotinc = 4; else dotinc = 2; savdot=dot; expr(1); locval=expv; if (expr(0)) locmsk=expv; else locmsk = ~0; if (c == 'L') while ((ret = get4(map, dot, &w)) > 0 && (w&locmsk) != locval) dot = inkdot(dotinc); else while ((ret = get2(map, dot, &sh)) > 0 && (sh&locmsk) != locval) dot = inkdot(dotinc); if (ret < 0) { dot=savdot; error("%r"); } symoff(buf, 512, dot, CANY); dprint(buf); }
/* * find the start of the central directory * returns the number of entries in the directory, * or -1 if there was an error */ static int findCDir(Biobuf *bin, char *file) { int64_t ecoff; int32_t off, size, m; int entries, zclen, dn, ds, de; ecoff = Bseek(bin, -ZECHeadSize, 2); if(ecoff < 0){ fprint(2, "unzip: can't seek to contents of %s\n", file); longjmp(seekjmp, 1); return -1; } if(setjmp(zjmp)) return -1; if((m=get4(bin)) != ZECHeader){ fprint(2, "unzip: bad magic number for table of contents of %s: %#.8lx\n", file, m); longjmp(seekjmp, 1); return -1; } dn = get2(bin); ds = get2(bin); de = get2(bin); entries = get2(bin); size = get4(bin); off = get4(bin); zclen = get2(bin); while(zclen-- > 0) get1(bin); if(verbose > 1){ print("table starts at %ld for %ld bytes\n", off, size); if(ecoff - size != off) print("\ttable should start at %lld-%ld=%lld\n", ecoff, size, ecoff-size); if(dn || ds || de != entries) print("\tcurrent disk=%d start disk=%d table entries on this disk=%d\n", dn, ds, de); } if(Bseek(bin, off, 0) != off){ fprint(2, "unzip: can't seek to start of contents of %s\n", file); longjmp(seekjmp, 1); return -1; } return entries; }
void ChaCha_Policy<R>::CipherSetKey(const NameValuePairs ¶ms, const byte *key, size_t length) { CRYPTOPP_UNUSED(params); CRYPTOPP_ASSERT(length == 16 || length == 32); // "expand 16-byte k" or "expand 32-byte k" m_state[0] = 0x61707865; m_state[1] = (length == 16) ? 0x3120646e : 0x3320646e; m_state[2] = (length == 16) ? 0x79622d36 : 0x79622d32; m_state[3] = 0x6b206574; GetBlock<word32, LittleEndian> get1(key); get1(m_state[4])(m_state[5])(m_state[6])(m_state[7]); GetBlock<word32, LittleEndian> get2(key + ((length == 32) ? 16 : 0)); get2(m_state[8])(m_state[9])(m_state[10])(m_state[11]); }
void crop_circle (Array<complex<T> > &in) { int64_t size = in.dimensions(0); int64_t r2 = size * size / 4; for(int64_t j=0; j<size; j++) { int64_t y = j - size/2; for(int64_t i=0; i<size; i++) { int64_t x = i - size/2; if (x*x + y*y > r2) { get2(in, i, j) = get2(in, i, j) = 0.0; } } } }
static int get3(char *c) { int i = 0; if (*c) i = (*c++ - '0') * 100; i += get2(c); return i; }
void dump(void) { int i, k; for (k = 0; k < nprocs; k++) { proc p = proctab[k]; value *cp = p->p_addr; uchar *pc, *limit; if (cp[CP_PRIM].z != interp) continue; pc = cp[CP_CODE].x; limit = pc + cp[CP_SIZE].i; printf("Procedure %s:\n", proctab[k]->p_name); while (pc < limit) { int op = *pc; uchar *pc1 = pc + optable[op].i_len; printf("%6d: %-30s", pc-imem, fmt_inst(pc)); while (pc < pc1) printf(" %d", *pc++); printf("\n"); if (op == K_JCASE_1) { int n = pc[-1]; for (i = 0; i < n; i++) { printf("%6d: CASEL %-22d %d %d\n", pc-imem, get2(pc)+(pc-imem), pc[0], pc[1]); pc += 2; } } #ifdef SPECIALS if (op == K_CASEJUMP_1) { int n = pc[-1]; for (i = 0; i < n; i++) { printf("%6d: CASEV %d %d\n", pc-imem, get2(pc), get2(pc+2)+(pc-imem)); pc += 4; } } #endif } } }
/* ARGSUSED */ static void output_trans2_setfile(int flags, uchar_t *data, char *xtra, int xsz) { int length; if (flags & F_SUM) { length = snprintf(xtra, xsz, " SetFileInfo"); xtra += length; xsz -= length; snprintf(xtra, xsz, " FileID=0x%x", get2(data)); } if (flags & F_DTAIL) { show_line("FunctionName = SetFileInfo"); show_printf("FileID = 0x%.4x", get2(data)); data += 2; show_printf("InfoLevel = 0x%.4x", get2(data)); } }
static int t_reverse (lua_State *L) { int u = aux_getn(L, 1); int l = 1; while (l < u) { get2(L, l, u); set2(L, l, u); ++l; --u; } return 0; }
static struct v7_val *find(struct v7 *v7, struct v7_val *key) { struct v7_val *v; int i; if (v7->no_exec) return NULL; // Search for the name, traversing scopes up to the top level scope for (i = v7->current_scope; i >= 0; i--) { if ((v = get2(&v7->scopes[i], key)) != NULL) return v; } return NULL; }
static int decode(ulong pc, Instr *i) { ushort w; get2(pc, &w); i->w = w; i->addr = pc; i->op = thumbclass(w); return 1; }
void _degrid2_thread(int *num_threads, int *cur_thread, Array<complex<T> > &data, Array<T> &coords, Array<complex<T> > &out, Array<T> &kernel_table) { int imin, imax, jmin, jmax, i, j; int width = data.dimensions(0); // assume isotropic dims int width_div2 = width / 2; uint64_t p; T x, y, ix, jy; T kernelRadius = DEFAULT_RADIUS_FOV_PRODUCT / width; T kernelRadius_sqr = kernelRadius * kernelRadius; T width_inv = 1.0 / width; T dist_multiplier = (kernel_table.dimensions(0) - 1)/kernelRadius_sqr; /* split threads up by even chunks of data_out memory */ unsigned long numSections = out.size() / *num_threads; unsigned long p_start = *cur_thread * numSections; unsigned long p_end = (*cur_thread+1) * numSections; /* loop over output data points */ for (p=p_start; p<p_end; p++) { complex<T> d = 0.; /* get the coordinates of the datapoint to grid * these vary between -.5 -- +.5 */ x = coords.get1v(p, 0); y = coords.get1v(p, 1); /* set the boundaries of final dataset for gridding this point */ ix = x * width + width_div2; set_minmax(ix, &imin, &imax, width, (T) DEFAULT_RADIUS_FOV_PRODUCT); jy = y * width + width_div2; set_minmax(jy, &jmin, &jmax, width, (T) DEFAULT_RADIUS_FOV_PRODUCT); /* Convolve the kernel at the coordinate location to get a * non-cartesian sample */ for (j=jmin; j<=jmax; ++j) { jy = (j - width_div2) * width_inv; for (i=imin; i<=imax; ++i) { ix = (i - width_div2) * width_inv; T dist_sqr = dist2(ix - x, jy - y); if (dist_sqr < kernelRadius_sqr) { T ker = get1(kernel_table, (int) rint(dist_sqr * dist_multiplier)); d += get2(data, i, j) * ker; // convolution sum } } } get1(out, p) = d; // store the sum for this coordinate point } }
bool Decimate::getNextFrame(uint32_t *fn,ADMImage *data) { switch(configuration.mode) { case 0: return get0(fn,data);break; case 1: return get1(fn,data);break; case 2: return get2(fn,data);break; case 3: return get3(fn,data);break; default: ADM_assert(0); } return false; }
void ChaCha_Policy::CipherSetKey(const NameValuePairs ¶ms, const byte *key, size_t length) { CRYPTOPP_UNUSED(params); CRYPTOPP_ASSERT(length == 16 || length == 32); m_rounds = params.GetIntValueWithDefault(Name::Rounds(), 20); if (!(m_rounds == 8 || m_rounds == 12 || m_rounds == 20)) throw InvalidRounds(ChaCha::StaticAlgorithmName(), m_rounds); // "expand 16-byte k" or "expand 32-byte k" m_state[0] = 0x61707865; m_state[1] = (length == 16) ? 0x3120646e : 0x3320646e; m_state[2] = (length == 16) ? 0x79622d36 : 0x79622d32; m_state[3] = 0x6b206574; GetBlock<word32, LittleEndian> get1(key); get1(m_state[4])(m_state[5])(m_state[6])(m_state[7]); GetBlock<word32, LittleEndian> get2(key + ((length == 32) ? 16 : 0)); get2(m_state[8])(m_state[9])(m_state[10])(m_state[11]); }
static int header(Biobuf *bin, ZipHead *zh) { uint32_t v; int flen, xlen; v = get4(bin); if(v != ZHeader){ if(v == ZCHeader) return 0; error("bad magic number %lx at %lld", v, Boffset(bin)-4); } zh->extvers = get1(bin); zh->extos = get1(bin); zh->flags = get2(bin); zh->meth = get2(bin); zh->modtime = get2(bin); zh->moddate = get2(bin); zh->crc = get4(bin); zh->csize = get4(bin); zh->uncsize = get4(bin); flen = get2(bin); xlen = get2(bin); zh->file = getname(bin, flen); while(xlen-- > 0) get1(bin); return 1; }
static int header(Biobuf *bin, ZipHead *zh) { uint32_t v; int flen, xlen; v = get4(bin); if(v != ZHeader){ if(v == ZCHeader) return 0; sysfatal("bad magic on local header"); } zh->extvers = get1(bin); zh->extos = get1(bin); zh->flags = get2(bin); zh->meth = get2(bin); zh->modtime = get2(bin); zh->moddate = get2(bin); zh->crc = get4(bin); zh->csize = get4(bin); zh->uncsize = get4(bin); flen = get2(bin); xlen = get2(bin); zh->file = getname(bin, flen); while(xlen-- > 0) get1(bin); return 1; }
static int cheader(Biobuf *bin, ZipHead *zh) { ulong v; int flen, xlen, fclen; v = get4(bin); if(v != ZCHeader){ if(v == ZECHeader) return 0; error("bad magic number %lux", v); } zh->madevers = get1(bin); zh->madeos = get1(bin); zh->extvers = get1(bin); zh->extos = get1(bin); zh->flags = get2(bin); zh->meth = get2(bin); zh->modtime = get2(bin); zh->moddate = get2(bin); zh->crc = get4(bin); zh->csize = get4(bin); zh->uncsize = get4(bin); flen = get2(bin); xlen = get2(bin); fclen = get2(bin); get2(bin); /* disk number start */ zh->iattr = get2(bin); zh->eattr = get4(bin); zh->off = get4(bin); zh->file = getname(bin, flen); while(xlen-- > 0) get1(bin); while(fclen-- > 0) get1(bin); return 1; }
static int decode(Map *map, uvlong pc, Instr *i) { ushort w; if(get2(map, pc, &w) < 0) { werrstr("can't read instruction: %r"); return -1; } i->w = w; i->addr = pc; i->op = thumbclass(w); i->map = map; return 1; }
static int cheader(Biobuf *bin, ZipHead *zh) { uint32_t v; int flen, xlen, fclen; v = get4(bin); if(v != ZCHeader){ if(v == ZECHeader) return 0; sysfatal("bad magic number in file"); } zh->madevers = get1(bin); zh->madeos = get1(bin); zh->extvers = get1(bin); zh->extos = get1(bin); zh->flags = get2(bin); zh->meth = get2(bin); zh->modtime = get2(bin); zh->moddate = get2(bin); zh->crc = get4(bin); zh->csize = get4(bin); zh->uncsize = get4(bin); flen = get2(bin); xlen = get2(bin); fclen = get2(bin); get2(bin); /* disk number start */ zh->iattr = get2(bin); /* 1 == is-text-file */ zh->eattr = get4(bin); /* 1 == readonly-file */ zh->off = get4(bin); zh->file = getname(bin, flen); while(xlen-- > 0) get1(bin); while(fclen-- > 0) get1(bin); return 1; }
/* * Function: grain_keystream * * Synopsis * Generates a new bit and updates the internal state of the cipher. */ u8 grain_keystream(ECRYPT_ctx* ctx) { u32 x0 = get3(S), x1 = get25(S), x2 = get46(S), x3 = get64(S), x4 = get63(B); u32 Z = get1(B) ^ get2(B) ^ get4(B) ^ get10(B) ^ get31(B) ^ get43(B) ^ get56(B) ^ h(x0,x1,x2,x3,x4); u32 S80 = get62(S) ^ get51(S) ^ get38(S) ^ get23(S) ^ get13(S) ^ get0(S); #if !defined(COMBINE_TERMS) u32 B80 =(get0(S)) ^ (get62(B)) ^ (get60(B)) ^ (get52(B)) ^ (get45(B)) ^ (get37(B)) ^ (get33(B)) ^ (get28(B)) ^ (get21(B))^ (get14(B)) ^ (get9(B)) ^ (get0(B)) ^ (get63(B)&get60(B)) ^ (get37(B)&get33(B)) ^ (get15(B)&get9(B))^ (get60(B)&get52(B)&get45(B)) ^ (get33(B)&get28(B)&get21(B)) ^ (get63(B)&get45(B)&get28(B)&get9(B))^ (get60(B)&get52(B)&get37(B)&get33(B)) ^ (get63(B)&get60(B)&get21(B)&get15(B))^ (get63(B)&get60(B)&get52(B)&get45(B)&get37(B)) ^ (get33(B)&get28(B)&get21(B)&get15(B)&get9(B))^ (get52(B)&get45(B)&get37(B)&get33(B)&get28(B)&get21(B)); #else u32 B33_28_21 = (get33(B)&get28(B)&get21(B)); /* 3 */ u32 B52_45_37 = (get52(B)&get45(B)&get37(B)); /* 2 */ u32 B52_37_33 = (get52(B)&get37(B)&get33(B)); /* 2 */ u32 B60_52_45 = (get60(B)&get52(B)&get45(B)); /* 2 */ u32 B63_60 = (get63(B)&get60(B)); /* 3 */ u32 B37_33 = (get37(B)&get33(B)); /* 3 */ u32 B45_28 = (get45(B)&get28(B)); /* 2 */ u32 B15_9 = (get15(B)&get9(B)); /* 2 */ u32 B21_15 = (get21(B)&get15(B)); /* 2 */ u32 B80 =(get0(S)) ^ (get62(B)) ^ (get60(B)) ^ (get52(B)) ^ (get45(B)) ^ (get37(B)) ^ (get33(B)) ^ (get28(B)) ^ (get21(B))^ (get14(B)) ^ (get9(B)) ^ (get0(B)) ^ (B63_60) ^ (B37_33) ^ (B15_9)^ (B60_52_45) ^ (B33_28_21) ^ (get63(B)&B45_28&get9(B))^ (get60(B)&B52_37_33) ^ (B63_60&B21_15)^ (B63_60&B52_45_37) ^ (B33_28_21&B15_9)^ (B52_45_37&B33_28_21); #endif SHIFT_FSR(S); SHIFT_FSR(B); set79(S,S80); set79(B,B80); return Z&1; }