file
stringlengths
18
26
data
stringlengths
3
1.04M
the_stack_data/107953437.c
/* Check inherited file descriptors for sanity at startup. NaCl version. Copyright (C) 2015-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ /* Nothing to do here. */ void __libc_check_standard_fds (void) { }
the_stack_data/62108.c
/* A simple program to test shellcode gcc -fno-stack-protector -z execstack tshell.c */ #include <stdio.h> #include <string.h> unsigned char code[]= \ "\xeb\x09\x5b\x80\x33\xaa\x74\x08\x43\xeb\xf8\xe8\xf2\xff\xff\xff\x9b\x6a\xfa\xc2" "\x85\x85\xd9\xc2\xc2\x85\xc8\xc3\xc4\x1a\xa1\x23\x49\x67\x2a\xaa"; main() { printf("Shellcode Length: %d\n", strlen(code)); int (*ret)() = (int(*)())code; ret(); }
the_stack_data/12638032.c
#ifndef TH_GENERIC_FILE #define TH_GENERIC_FILE "generic/THTensor.c" #else /**** access methods ****/ THStorage *THTensor_(storage)(const THTensor *self) { return self->storage; } ptrdiff_t THTensor_(storageOffset)(const THTensor *self) { return self->storageOffset; } int THTensor_(nDimension)(const THTensor *self) { return self->nDimension; } long THTensor_(size)(const THTensor *self, int dim) { THArgCheck((dim >= 0) && (dim < self->nDimension), 2, "dimension %d out of range of %dD tensor", dim+TH_INDEX_BASE, THTensor_(nDimension)(self)); return self->size[dim]; } long THTensor_(stride)(const THTensor *self, int dim) { THArgCheck((dim >= 0) && (dim < self->nDimension), 2, "dimension %d out of range of %dD tensor", dim+TH_INDEX_BASE, THTensor_(nDimension)(self)); return self->stride[dim]; } THLongStorage *THTensor_(newSizeOf)(THTensor *self) { THLongStorage *size = THLongStorage_newWithSize(self->nDimension); THLongStorage_rawCopy(size, self->size); return size; } THLongStorage *THTensor_(newStrideOf)(THTensor *self) { THLongStorage *stride = THLongStorage_newWithSize(self->nDimension); THLongStorage_rawCopy(stride, self->stride); return stride; } real *THTensor_(data)(const THTensor *self) { if(self->storage) return (self->storage->data+self->storageOffset); else return NULL; } void THTensor_(setFlag)(THTensor *self, const char flag) { self->flag |= flag; } void THTensor_(clearFlag)(THTensor *self, const char flag) { self->flag &= ~flag; } /**** creation methods ****/ static void THTensor_(rawInit)(THTensor *self); /* Empty init */ THTensor *THTensor_(new)(void) { THTensor *self = THAlloc(sizeof(THTensor)); THTensor_(rawInit)(self); return self; } /* Pointer-copy init */ THTensor *THTensor_(newWithTensor)(THTensor *tensor) { THTensor *self = THAlloc(sizeof(THTensor)); THTensor_(rawInit)(self); THTensor_(setStorageNd)(self, tensor->storage, tensor->storageOffset, tensor->nDimension, tensor->size, tensor->stride); return self; } /* Storage init */ THTensor *THTensor_(newWithStorage)(THStorage *storage, ptrdiff_t storageOffset, THLongStorage *size, THLongStorage *stride) { THTensor *self = THAlloc(sizeof(THTensor)); if(size && stride) THArgCheck(size->size == stride->size, 4, "inconsistent size"); THTensor_(rawInit)(self); #ifdef DEBUG THAssert((size ? size->size : (stride ? stride->size : 0)) <= INT_MAX); #endif THTensor_(setStorageNd)(self, storage, storageOffset, (size ? size->size : (stride ? stride->size : 0)), (size ? size->data : NULL), (stride ? stride->data : NULL)); return self; } THTensor *THTensor_(newWithStorage1d)(THStorage *storage, ptrdiff_t storageOffset, long size0, long stride0) { return THTensor_(newWithStorage4d)(storage, storageOffset, size0, stride0, -1, -1, -1, -1, -1, -1); } THTensor *THTensor_(newWithStorage2d)(THStorage *storage, ptrdiff_t storageOffset, long size0, long stride0, long size1, long stride1) { return THTensor_(newWithStorage4d)(storage, storageOffset, size0, stride0, size1, stride1, -1, -1, -1, -1); } THTensor *THTensor_(newWithStorage3d)(THStorage *storage, ptrdiff_t storageOffset, long size0, long stride0, long size1, long stride1, long size2, long stride2) { return THTensor_(newWithStorage4d)(storage, storageOffset, size0, stride0, size1, stride1, size2, stride2, -1, -1); } THTensor *THTensor_(newWithStorage4d)(THStorage *storage, ptrdiff_t storageOffset, long size0, long stride0, long size1, long stride1, long size2, long stride2, long size3, long stride3) { long size[4] = {size0, size1, size2, size3}; long stride[4] = {stride0, stride1, stride2, stride3}; THTensor *self = THAlloc(sizeof(THTensor)); THTensor_(rawInit)(self); THTensor_(setStorageNd)(self, storage, storageOffset, 4, size, stride); return self; } THTensor *THTensor_(newWithSize)(THLongStorage *size, THLongStorage *stride) { return THTensor_(newWithStorage)(NULL, 0, size, stride); } THTensor *THTensor_(newWithSize1d)(long size0) { return THTensor_(newWithSize4d)(size0, -1, -1, -1); } THTensor *THTensor_(newWithSize2d)(long size0, long size1) { return THTensor_(newWithSize4d)(size0, size1, -1, -1); } THTensor *THTensor_(newWithSize3d)(long size0, long size1, long size2) { return THTensor_(newWithSize4d)(size0, size1, size2, -1); } THTensor *THTensor_(newWithSize4d)(long size0, long size1, long size2, long size3) { long size[4] = {size0, size1, size2, size3}; THTensor *self = THAlloc(sizeof(THTensor)); THTensor_(rawInit)(self); THTensor_(resizeNd)(self, 4, size, NULL); return self; } THTensor *THTensor_(newClone)(THTensor *self) { THTensor *tensor = THTensor_(new)(); THTensor_(resizeAs)(tensor, self); THTensor_(copy)(tensor, self); return tensor; } THTensor *THTensor_(newContiguous)(THTensor *self) { if(!THTensor_(isContiguous)(self)) return THTensor_(newClone)(self); else { THTensor_(retain)(self); return self; } } THTensor *THTensor_(newSelect)(THTensor *tensor, int dimension_, long sliceIndex_) { THTensor *self = THTensor_(newWithTensor)(tensor); THTensor_(select)(self, NULL, dimension_, sliceIndex_); return self; } THTensor *THTensor_(newNarrow)(THTensor *tensor, int dimension_, long firstIndex_, long size_) { THTensor *self = THTensor_(newWithTensor)(tensor); THTensor_(narrow)(self, NULL, dimension_, firstIndex_, size_); return self; } THTensor *THTensor_(newTranspose)(THTensor *tensor, int dimension1_, int dimension2_) { THTensor *self = THTensor_(newWithTensor)(tensor); THTensor_(transpose)(self, NULL, dimension1_, dimension2_); return self; } THTensor *THTensor_(newUnfold)(THTensor *tensor, int dimension_, long size_, long step_) { THTensor *self = THTensor_(newWithTensor)(tensor); THTensor_(unfold)(self, NULL, dimension_, size_, step_); return self; } THTensor *THTensor_(newView)(THTensor *tensor, THLongStorage *size) { THArgCheck(THTensor_(isContiguous)(tensor), 1, "input is not contiguous"); ptrdiff_t numel = THTensor_(nElement)(tensor); THTensor *self = THTensor_(new)(); THLongStorage *inferred_size = THLongStorage_newInferSize(size, numel); THTensor_(setStorage)(self, tensor->storage, tensor->storageOffset, inferred_size, NULL); THLongStorage_free(inferred_size); return self; } /* Resize */ void THTensor_(resize)(THTensor *self, THLongStorage *size, THLongStorage *stride) { THArgCheck(size != NULL, 2, "invalid size"); if(stride) THArgCheck(stride->size == size->size, 3, "invalid stride"); #ifdef DEBUG THAssert(size->size <= INT_MAX); #endif THTensor_(resizeNd)(self, size->size, size->data, (stride ? stride->data : NULL)); } void THTensor_(resizeAs)(THTensor *self, THTensor *src) { if(!THTensor_(isSameSizeAs)(self, src)) THTensor_(resizeNd)(self, src->nDimension, src->size, NULL); } void THTensor_(resize1d)(THTensor *tensor, long size0) { THTensor_(resize4d)(tensor, size0, -1, -1, -1); } void THTensor_(resize2d)(THTensor *tensor, long size0, long size1) { THTensor_(resize4d)(tensor, size0, size1, -1, -1); } void THTensor_(resize3d)(THTensor *tensor, long size0, long size1, long size2) { THTensor_(resize4d)(tensor, size0, size1, size2, -1); } void THTensor_(resize4d)(THTensor *self, long size0, long size1, long size2, long size3) { long size[4] = {size0, size1, size2, size3}; THTensor_(resizeNd)(self, 4, size, NULL); } void THTensor_(resize5d)(THTensor *self, long size0, long size1, long size2, long size3, long size4) { long size[5] = {size0, size1, size2, size3, size4}; THTensor_(resizeNd)(self, 5, size, NULL); } THTensor* THTensor_(newExpand)(THTensor *tensor, THLongStorage *sizes) { THTensor *result = THTensor_(new)(); THTensor_(expand)(result, tensor, sizes); return result; } void THTensor_(expand)(THTensor *r, THTensor *tensor, THLongStorage *sizes) { THArgCheck(THTensor_(nDimension)(tensor) > 0, 0, "can't expand an empty tensor"); THArgCheck(THLongStorage_size(sizes) >= THTensor_(nDimension)(tensor), 1, "the number of sizes provided must be greater or equal to the " "number of dimensions in the tensor"); long *expandedSizes; long *expandedStrides; char error_buffer[1024]; int ret = THLongStorage_inferExpandGeometry(tensor->size, tensor->stride, THTensor_(nDimension)(tensor), sizes, &expandedSizes, &expandedStrides, error_buffer, 1024); if (ret != 0) { THError(error_buffer); return; } THTensor_(setStorageNd)(r, THTensor_(storage)(tensor), THTensor_(storageOffset)(tensor), THLongStorage_size(sizes), expandedSizes, expandedStrides); THFree(expandedSizes); THFree(expandedStrides); } void THTensor_(expandNd)(THTensor **rets, THTensor **ops, int count) { for (int i = 0; i < count; ++i) { THArgCheck(THTensor_(nDimension)(ops[i]) > 0, i, "can't expand empty tensor %d", i); } long *op_sizes[count]; long op_dims[count]; for (int i = 0; i < count; ++i) { op_sizes[i] = ops[i]->size; op_dims[i] = ops[i]->nDimension; } THLongStorage *sizes = THLongStorage_new(); char error_buffer[1024]; int ret = THLongStorage_inferSizeN(sizes, count, op_sizes, op_dims, error_buffer, 1024); if(ret != 0) { THLongStorage_free(sizes); THError(error_buffer); return; } for (int i = 0; i < count; ++i) { THTensor_(expand)(rets[i], ops[i], sizes); } THLongStorage_free(sizes); } void THTensor_(set)(THTensor *self, THTensor *src) { if(self != src) THTensor_(setStorageNd)(self, src->storage, src->storageOffset, src->nDimension, src->size, src->stride); } void THTensor_(setStorage)(THTensor *self, THStorage *storage_, ptrdiff_t storageOffset_, THLongStorage *size_, THLongStorage *stride_) { if(size_ && stride_) THArgCheck(size_->size == stride_->size, 5, "inconsistent size/stride sizes"); #ifdef DEBUG THAssert((size_ ? size_->size : (stride_ ? stride_->size : 0)) <= INT_MAX); #endif THTensor_(setStorageNd)(self, storage_, storageOffset_, (size_ ? size_->size : (stride_ ? stride_->size : 0)), (size_ ? size_->data : NULL), (stride_ ? stride_->data : NULL)); } void THTensor_(setStorage1d)(THTensor *self, THStorage *storage_, ptrdiff_t storageOffset_, long size0_, long stride0_) { THTensor_(setStorage4d)(self, storage_, storageOffset_, size0_, stride0_, -1, -1, -1, -1, -1, -1); } void THTensor_(setStorage2d)(THTensor *self, THStorage *storage_, ptrdiff_t storageOffset_, long size0_, long stride0_, long size1_, long stride1_) { THTensor_(setStorage4d)(self, storage_, storageOffset_, size0_, stride0_, size1_, stride1_, -1, -1, -1, -1); } void THTensor_(setStorage3d)(THTensor *self, THStorage *storage_, ptrdiff_t storageOffset_, long size0_, long stride0_, long size1_, long stride1_, long size2_, long stride2_) { THTensor_(setStorage4d)(self, storage_, storageOffset_, size0_, stride0_, size1_, stride1_, size2_, stride2_, -1, -1); } void THTensor_(setStorage4d)(THTensor *self, THStorage *storage_, ptrdiff_t storageOffset_, long size0_, long stride0_, long size1_, long stride1_, long size2_, long stride2_, long size3_, long stride3_) { long size[4] = {size0_, size1_, size2_, size3_}; long stride[4] = {stride0_, stride1_, stride2_, stride3_}; THTensor_(setStorageNd)(self, storage_, storageOffset_, 4, size, stride); } void THTensor_(narrow)(THTensor *self, THTensor *src, int dimension, long firstIndex, long size) { if(!src) src = self; THArgCheck( (dimension >= 0) && (dimension < src->nDimension), 2, "out of range"); THArgCheck( (firstIndex >= 0) && (firstIndex < src->size[dimension]), 3, "out of range"); THArgCheck( (size > 0) && (firstIndex <= src->size[dimension] - size), 4, "out of range"); THTensor_(set)(self, src); if(firstIndex > 0) self->storageOffset += firstIndex*self->stride[dimension]; self->size[dimension] = size; } void THTensor_(select)(THTensor *self, THTensor *src, int dimension, long sliceIndex) { int d; if(!src) src = self; THArgCheck(src->nDimension > 1, 1, "cannot select on a vector"); THArgCheck((dimension >= 0) && (dimension < src->nDimension), 2, "out of range"); THArgCheck((sliceIndex >= 0) && (sliceIndex < src->size[dimension]), 3, "out of range"); THTensor_(set)(self, src); THTensor_(narrow)(self, NULL, dimension, sliceIndex, 1); for(d = dimension; d < self->nDimension-1; d++) { self->size[d] = self->size[d+1]; self->stride[d] = self->stride[d+1]; } self->nDimension--; } void THTensor_(transpose)(THTensor *self, THTensor *src, int dimension1, int dimension2) { long z; if(!src) src = self; THArgCheck( (dimension1 >= 0) && (dimension1 < src->nDimension), 1, "out of range"); THArgCheck( (dimension2 >= 0) && (dimension2 < src->nDimension), 2, "out of range"); THTensor_(set)(self, src); if(dimension1 == dimension2) return; z = self->stride[dimension1]; self->stride[dimension1] = self->stride[dimension2]; self->stride[dimension2] = z; z = self->size[dimension1]; self->size[dimension1] = self->size[dimension2]; self->size[dimension2] = z; } void THTensor_(unfold)(THTensor *self, THTensor *src, int dimension, long size, long step) { long *newSize; long *newStride; int d; if(!src) src = self; THArgCheck( (src->nDimension > 0), 1, "cannot unfold an empty tensor"); THArgCheck((dimension >= 0) && (dimension < src->nDimension), 2, "out of range"); THArgCheck(size <= src->size[dimension], 3, "out of range"); THArgCheck(step > 0, 4, "invalid step"); THTensor_(set)(self, src); newSize = THAlloc(sizeof(long)*(self->nDimension+1)); newStride = THAlloc(sizeof(long)*(self->nDimension+1)); newSize[self->nDimension] = size; newStride[self->nDimension] = self->stride[dimension]; for(d = 0; d < self->nDimension; d++) { if(d == dimension) { newSize[d] = (self->size[d] - size) / step + 1; newStride[d] = step*self->stride[d]; } else { newSize[d] = self->size[d]; newStride[d] = self->stride[d]; } } THFree(self->size); THFree(self->stride); self->size = newSize; self->stride = newStride; self->nDimension++; } /* we have to handle the case where the result is a number */ void THTensor_(squeeze)(THTensor *self, THTensor *src) { int ndim = 0; int d; if(!src) src = self; THTensor_(set)(self, src); for(d = 0; d < src->nDimension; d++) { if(src->size[d] != 1) { if(d != ndim) { self->size[ndim] = src->size[d]; self->stride[ndim] = src->stride[d]; } ndim++; } } /* right now, we do not handle 0-dimension tensors */ if(ndim == 0 && src->nDimension > 0) { self->size[0] = 1; self->stride[0] = 1; ndim = 1; } self->nDimension = ndim; } void THTensor_(squeeze1d)(THTensor *self, THTensor *src, int dimension) { int d; if(!src) src = self; THArgCheck((dimension >= 0) && (dimension < src->nDimension), 2, "dimension out of range"); THTensor_(set)(self, src); if(src->size[dimension] == 1 && src->nDimension > 1) { for(d = dimension; d < self->nDimension-1; d++) { self->size[d] = self->size[d+1]; self->stride[d] = self->stride[d+1]; } self->nDimension--; } } void THTensor_(unsqueeze1d)(THTensor *self, THTensor *src, int dimension) { int d; if(!src) src = self; THArgCheck((dimension >= 0) && (dimension <= src->nDimension), 2, "dimension out of range"); THArgCheck(src->nDimension > 0, 2, "cannot unsqueeze empty tensor"); THTensor_(set)(self, src); self->size = (long*)THRealloc(self->size, sizeof(long)*(self->nDimension+1)); self->stride = (long*)THRealloc(self->stride, sizeof(long)*(self->nDimension+1)); self->nDimension++; for (d = self->nDimension-1; d > dimension; d--) { self->size[d] = self->size[d-1]; self->stride[d] = self->stride[d-1]; } if (dimension+1 < self->nDimension) { self->stride[dimension] = self->size[dimension+1] * self->stride[dimension+1]; } else { self->stride[dimension] = 1; } self->size[dimension] = 1; } int THTensor_(isTransposed)(const THTensor *self) { if (THTensor_(isContiguous)(self)) { return 0; } long max_stride = 1; long size_max_stride = 1; long z = 1; int d; for (d = 0; d < self->nDimension; ++d) { if (self->stride[d] == 0 && self->size[d] != 1) return 0; if (self->stride[d] > max_stride) { max_stride = self->stride[d]; size_max_stride = self->size[d]; } z *= self->size[d]; } if (z == max_stride * size_max_stride) { return 1; } return 0; } int THTensor_(isContiguous)(const THTensor *self) { long z = 1; int d; for(d = self->nDimension-1; d >= 0; d--) { if(self->size[d] != 1) { if(self->stride[d] == z) z *= self->size[d]; else return 0; } } return 1; } int THTensor_(isSize)(const THTensor *self, const THLongStorage *dims) { int d; if (self->nDimension != dims->size) return 0; for(d = 0; d < self->nDimension; ++d) { if(self->size[d] != dims->data[d]) return 0; } return 1; } int THTensor_(isSameSizeAs)(const THTensor *self, const THTensor* src) { int d; if (self->nDimension != src->nDimension) return 0; for(d = 0; d < self->nDimension; ++d) { if(self->size[d] != src->size[d]) return 0; } return 1; } int THTensor_(isSetTo)(const THTensor *self, const THTensor* src) { if (!self->storage) return 0; if (self->storage == src->storage && self->storageOffset == src->storageOffset && self->nDimension == src->nDimension) { int d; for (d = 0; d < self->nDimension; ++d) { if (self->size[d] != src->size[d] || self->stride[d] != src->stride[d]) return 0; } return 1; } return 0; } ptrdiff_t THTensor_(nElement)(const THTensor *self) { if(self->nDimension == 0) return 0; else { ptrdiff_t nElement = 1; int d; for(d = 0; d < self->nDimension; d++) nElement *= self->size[d]; return nElement; } } void THTensor_(retain)(THTensor *self) { if(self->flag & TH_TENSOR_REFCOUNTED) THAtomicIncrementRef(&self->refcount); } void THTensor_(free)(THTensor *self) { if(!self) return; if(self->flag & TH_TENSOR_REFCOUNTED) { if(THAtomicDecrementRef(&self->refcount)) { THFree(self->size); THFree(self->stride); if(self->storage) THStorage_(free)(self->storage); THFree(self); } } } void THTensor_(freeCopyTo)(THTensor *self, THTensor *dst) { if(self != dst) THTensor_(copy)(dst, self); THTensor_(free)(self); } /*******************************************************************************/ static void THTensor_(rawInit)(THTensor *self) { self->refcount = 1; self->storage = NULL; self->storageOffset = 0; self->size = NULL; self->stride = NULL; self->nDimension = 0; self->flag = TH_TENSOR_REFCOUNTED; } void THTensor_(setStorageNd)(THTensor *self, THStorage *storage, ptrdiff_t storageOffset, int nDimension, long *size, long *stride) { /* storage */ if(self->storage != storage) { if(self->storage) THStorage_(free)(self->storage); if(storage) { self->storage = storage; THStorage_(retain)(self->storage); } else self->storage = NULL; } /* storageOffset */ if(storageOffset < 0) THError("Tensor: invalid storage offset"); self->storageOffset = storageOffset; /* size and stride */ THTensor_(resizeNd)(self, nDimension, size, stride); } void THTensor_(resizeNd)(THTensor *self, int nDimension, long *size, long *stride) { int d; int nDimension_; ptrdiff_t totalSize; int hascorrectsize = 1; nDimension_ = 0; for(d = 0; d < nDimension; d++) { if(size[d] > 0) { nDimension_++; if((self->nDimension > d) && (size[d] != self->size[d])) hascorrectsize = 0; if((self->nDimension > d) && stride && (stride[d] >= 0) && (stride[d] != self->stride[d])) hascorrectsize = 0; } else break; } nDimension = nDimension_; if(nDimension != self->nDimension) hascorrectsize = 0; if(hascorrectsize) return; if(nDimension > 0) { if(nDimension != self->nDimension) { self->size = THRealloc(self->size, sizeof(long)*nDimension); self->stride = THRealloc(self->stride, sizeof(long)*nDimension); self->nDimension = nDimension; } totalSize = 1; for(d = self->nDimension-1; d >= 0; d--) { self->size[d] = size[d]; if(stride && (stride[d] >= 0) ) self->stride[d] = stride[d]; else { if(d == self->nDimension-1) self->stride[d] = 1; else self->stride[d] = self->size[d+1]*self->stride[d+1]; } totalSize += (self->size[d]-1)*self->stride[d]; } if(totalSize+self->storageOffset > 0) { if(!self->storage) self->storage = THStorage_(new)(); if(totalSize+self->storageOffset > self->storage->size) THStorage_(resize)(self->storage, totalSize+self->storageOffset); } } else self->nDimension = 0; } void THTensor_(set1d)(THTensor *tensor, long x0, real value) { THArgCheck(tensor->nDimension == 1, 1, "tensor must have one dimension"); THArgCheck( (x0 >= 0) && (x0 < tensor->size[0]), 2, "out of range"); THStorage_(set)(tensor->storage, tensor->storageOffset+x0*tensor->stride[0], value); } real THTensor_(get1d)(const THTensor *tensor, long x0) { THArgCheck(tensor->nDimension == 1, 1, "tensor must have one dimension"); THArgCheck( (x0 >= 0) && (x0 < tensor->size[0]), 2, "out of range"); return THStorage_(get)(tensor->storage, tensor->storageOffset+x0*tensor->stride[0]); } void THTensor_(set2d)(THTensor *tensor, long x0, long x1, real value) { THArgCheck(tensor->nDimension == 2, 1, "tensor must have two dimensions"); THArgCheck((x0 >= 0) && (x0 < tensor->size[0]) && (x1 >= 0) && (x1 < tensor->size[1]), 2, "out of range"); THStorage_(set)(tensor->storage, tensor->storageOffset+x0*tensor->stride[0]+x1*tensor->stride[1], value); } real THTensor_(get2d)(const THTensor *tensor, long x0, long x1) { THArgCheck(tensor->nDimension == 2, 1, "tensor must have two dimensions"); THArgCheck((x0 >= 0) && (x0 < tensor->size[0]) && (x1 >= 0) && (x1 < tensor->size[1]), 2, "out of range"); return THStorage_(get)(tensor->storage, tensor->storageOffset+x0*tensor->stride[0]+x1*tensor->stride[1]); } void THTensor_(set3d)(THTensor *tensor, long x0, long x1, long x2, real value) { THArgCheck(tensor->nDimension == 3, 1, "tensor must have three dimensions"); THArgCheck( (x0 >= 0) && (x0 < tensor->size[0]) && (x1 >= 0) && (x1 < tensor->size[1]) && (x2 >= 0) && (x2 < tensor->size[2]), 2, "out of range"); THStorage_(set)(tensor->storage, tensor->storageOffset+x0*tensor->stride[0]+x1*tensor->stride[1]+x2*tensor->stride[2], value); } real THTensor_(get3d)(const THTensor *tensor, long x0, long x1, long x2) { THArgCheck(tensor->nDimension == 3, 1, "tensor must have three dimensions"); THArgCheck( (x0 >= 0) && (x0 < tensor->size[0]) && (x1 >= 0) && (x1 < tensor->size[1]) && (x2 >= 0) && (x2 < tensor->size[2]), 2, "out of range"); return THStorage_(get)(tensor->storage, tensor->storageOffset+x0*tensor->stride[0]+x1*tensor->stride[1]+x2*tensor->stride[2]); } void THTensor_(set4d)(THTensor *tensor, long x0, long x1, long x2, long x3, real value) { THArgCheck(tensor->nDimension == 4, 1, "tensor must have four dimensions"); THArgCheck((x0 >= 0) && (x0 < tensor->size[0]) && (x1 >= 0) && (x1 < tensor->size[1]) && (x2 >= 0) && (x2 < tensor->size[2]) && (x3 >= 0) && (x3 < tensor->size[3]), 2, "out of range"); THStorage_(set)(tensor->storage, tensor->storageOffset+x0*tensor->stride[0]+x1*tensor->stride[1]+x2*tensor->stride[2]+x3*tensor->stride[3], value); } real THTensor_(get4d)(const THTensor *tensor, long x0, long x1, long x2, long x3) { THArgCheck(tensor->nDimension == 4, 1, "tensor must have four dimensions"); THArgCheck((x0 >= 0) && (x0 < tensor->size[0]) && (x1 >= 0) && (x1 < tensor->size[1]) && (x2 >= 0) && (x2 < tensor->size[2]) && (x3 >= 0) && (x3 < tensor->size[3]), 2, "out of range"); return THStorage_(get)(tensor->storage, tensor->storageOffset+x0*tensor->stride[0]+x1*tensor->stride[1]+x2*tensor->stride[2]+x3*tensor->stride[3]); } THDescBuff THTensor_(desc)(const THTensor *tensor) { const int L = TH_DESC_BUFF_LEN; THDescBuff buf; char *str = buf.str; int n = 0; #define _stringify(x) #x n += snprintf(str, L-n, "torch." _stringify(x) "Tensor of size "); #undef _stringify int i; for(i = 0; i < tensor->nDimension; i++) { if(n >= L) break; n += snprintf(str+n, L-n, "%ld", tensor->size[i]); if(i < tensor->nDimension-1) { n += snprintf(str+n, L-n, "x"); } } if(n >= L) { snprintf(str+L-4, 4, "..."); } return buf; } THDescBuff THTensor_(sizeDesc)(const THTensor *tensor) { THLongStorage *size = THTensor_(newSizeOf)((THTensor*)tensor); THDescBuff buf = THLongStorage_sizeDesc(size); THLongStorage_free(size); return buf; } #endif
the_stack_data/926858.c
#include <stdio.h> #include <assert.h> #include <limits.h> int mul3div4(int x) { int is_neg = x & INT_MIN; int x3 = (x << 1) + x; is_neg && (x3 += (1<<2)-1); return x3 >> 2; } int main() { assert(mul3div4(12) == 9); assert(mul3div4(10) == 7); assert(mul3div4(-10) == -7); assert(mul3div4(-12) == -9); }
the_stack_data/193893286.c
/* Copyright (C) 2000, 2001 Silicon Graphics, Inc. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of version 2.1 of the GNU Lesser General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Further, this software is distributed without any warranty that it is free of the rightful claim of any third person regarding infringement or the like. Any license provided herein, whether implied or otherwise, applies only to this software file. Patent licenses, if any, provided herein do not apply to combinations of this program with other software, or any other product whatsoever. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pky, Mountain View, CA 94043, or: http://www.sgi.com For further information regarding this notice, see: http://oss.sgi.com/projects/GenInfo/NoticeExplan */ #pragma ident "@(#) libu/clib/reada.c 92.1 07/01/99 13:42:20" long READA(fd, buf, nbyte, status, signo) long *fd, *buf, *nbyte, *status, *signo; { return((long)reada(*fd, (char *)buf, *nbyte, status, *signo)); }
the_stack_data/29825350.c
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> void display(char cr, int lines, int width); int main() { char c; int rows, cols; //while (1) //{ // scanf("%c %d %d", &c, &rows, &cols); // while (getchar() != '\n') continue; // display(c, rows, cols); // if (c == '\n') // break; // doesn't work well //} printf("Input one character and two integers:\n"); while ((c = getchar()) != '\n') { scanf("%d %d", &rows, &cols); while (getchar() != '\n') continue; display(c, rows, cols); printf("Input another character and two integers:\n"); printf("Press Enter to quit.\n"); } return 0; } void display(char cr, int lines, int width) { int r, c; for (r = 0; r < lines; r++) { for (c = 0; c < width; c++) { printf("%c", cr); } printf("\n"); } } //void display(char cr, int lines, int width) //{ // int row, col; // // for (row = 0; row < lines; ++row) // { // for (col = 0; col < width; ++col) // printf("%c", cr); // printf("\n"); // } //}
the_stack_data/2605.c
#include <stdio.h> #include <stdlib.h> #include <string.h> #define STU_NAME_MAX 31 typedef struct { int stuID; char* stuName; } EleType; typedef struct Node *PtrToNode; // Pointer to Node typedef PtrToNode List; // Header of Linked List struct Node { EleType ele; // Element of the node PtrToNode next; // Next node of the node }; // Function description์€ ๊ฐ ํ•จ์ˆ˜๋ฅผ ์ •์˜ํ•˜๋Š” ๋ถ€๋ถ„์— ์ž‘์„ฑ๋จ. // ํ•จ์ˆ˜ ์„ ์–ธ // Main Functions void Insert(EleType X, List L); void Delete(int id, List L); void Find(int id, List L); void PrintList(List L); // Other Functions List MakeEmpty(); List FindPreNode(int id, List L); void FreeNode(PtrToNode P); void DeleteList(List L); void PrintCurrentList(List L); FILE *output; void main() { FILE *input; char func_selected; int stuID_temp; char stuName_temp[STU_NAME_MAX]; EleType ele_temp; List L = MakeEmpty(); input = fopen("input.txt", "r"); output = fopen("output.txt", "w"); while(1) { fscanf(input, " %c", &func_selected); if(feof(input)) { // Break at the end of file. break; } switch(func_selected) { case 'i' : // Insert fscanf(input, "%d ", &ele_temp.stuID); // Read id. int i; for(i = 0; i < STU_NAME_MAX; i++) { // Read name to end of the line. int isEOF = fscanf(input, "%c", &stuName_temp[i]); // Read a character. if(stuName_temp[i] == '\r' || stuName_temp[i] == '\n' || isEOF == EOF) { // If it's CR or NL or EOF, (end of the line or end of file) stuName_temp[i] = '\0'; // Convert it to NULL, break; // And break. } } ele_temp.stuName = (char*)malloc(sizeof(char)*(strlen(stuName_temp)+1)); // +1 for NULL strcpy(ele_temp.stuName, stuName_temp); Insert(ele_temp, L); break; case 'd' : // Delete fscanf(input, "%d", &stuID_temp); Delete(stuID_temp, L); break; case 'f' : // Find fscanf(input, "%d", &stuID_temp); Find(stuID_temp, L); break; case 'p' : // Print PrintList(L); break; default : break; } } // Free DeleteList(L); // Close files fclose(input); fclose(output); } // ํ•จ์ˆ˜ ์ •์˜ // input์œผ๋กœ Element X์™€ Linked List์˜ Header์ธ L์„ ๋ฐ›์•„์„œ, // (Linked List๊ฐ€ student ID์— ๋”ฐ๋ผ ์ •๋ ฌ๋˜๋„๋ก ํ•˜๋Š”) Linked List ์•ˆ์˜ ์ ์ ˆํ•œ ์œ„์น˜์— Element X๋ฅผ ๊ฐ€์ง€๋Š” ๋…ธ๋“œ๋ฅผ ์‚ฝ์ž…ํ•˜๋Š” ํ•จ์ˆ˜. void Insert(EleType X, List L) { PtrToNode P = L, TmpNode; for (;; P = P->next) { if(P->next == NULL || X.stuID < P->next->ele.stuID) { TmpNode = (PtrToNode)malloc(sizeof(struct Node)); TmpNode->ele = X; TmpNode->next = P->next; P->next = TmpNode; fprintf(output, "Insertion Success : %d\n", TmpNode->ele.stuID); PrintCurrentList(L); break; } if(X.stuID == P->next->ele.stuID) { fprintf(output, "Insertion Failed. Id %d already exists.\n", X.stuID); break; } } } // input์œผ๋กœ Student ID์™€ Linked List์˜ Header์ธ L์„ ๋ฐ›์•„์„œ, // ์ฃผ์–ด์ง„ Linked List์— ํ•ด๋‹น id๋ฅผ ๊ฐ€์ง€๋Š” ๋…ธ๋“œ๊ฐ€ ์กด์žฌํ•  ๊ฒฝ์šฐ ์‚ญ์ œํ•˜๋Š” ํ•จ์ˆ˜. void Delete(int id, List L) { PtrToNode Pre = FindPreNode(id, L); // The previous node of the node that has given id. PtrToNode P = Pre->next; // The node that has given id. if(P != NULL) { Pre->next = P->next; FreeNode(P); fprintf(output, "Deletion Success : %d\n", id); PrintCurrentList(L); } else { fprintf(output, "Deletion Failed : Student ID %d is not in the list.\n", id); } } // input์œผ๋กœ Student ID์™€ Linked List์˜ Header์ธ L์„ ๋ฐ›์•„์„œ, // ์ฃผ์–ด์ง„ Linked List์— ํ•ด๋‹น id๋ฅผ ๊ฐ€์ง€๋Š” ๋…ธ๋“œ๊ฐ€ ์กด์žฌํ•˜๋Š”์ง€ ์ฐพ๊ณ , ์กด์žฌํ•  ๊ฒฝ์šฐ ํ•ด๋‹น ๋…ธ๋“œ๊ฐ€ ๊ฐ€์ง€๋Š” student ID์™€ Name์„ ์ถœ๋ ฅํ•˜๋Š” ํ•จ์ˆ˜. void Find(int id, List L) { PtrToNode P = FindPreNode(id, L)->next; // The node that has given id. if(P != NULL) { fprintf(output, "Find Success : %d %s\n", P->ele.stuID, P->ele.stuName); } else { fprintf(output, "Find %d Failed. There is no student ID\n", id); } } // input์œผ๋กœ Linked List์˜ Header์ธ L์„ ๋ฐ›์•„์„œ, // ํ•ด๋‹น Linked List์˜ ๊ฐ ๋…ธ๋“œ๋“ค(์ด ๊ฐ€์ง„ ์ •๋ณด)๋ฅผ ์ˆœ์„œ๋Œ€๋กœ ์ถœ๋ ฅํ•˜๋Š” ํ•จ์ˆ˜. void PrintList(List L) { PtrToNode P = L->next; fprintf(output, "-----LIST-----\n"); for(; P != NULL; P = P->next) { fprintf(output, "%d %s\n", P->ele.stuID, P->ele.stuName); } fprintf(output, "--------------\n"); } // Linked List๋ฅผ ๋งŒ๋“ค๊ธฐ ์œ„ํ•ด ์ด์˜ Header ์—ญํ• ์„ ํ•˜๋Š” Node(ํฌ์ธํ„ฐ)๋ฅผ ๋งŒ๋“ค๊ณ  ๋ฐ˜ํ™˜ํ•˜๋Š” ํ•จ์ˆ˜. List MakeEmpty() { List L = (List)malloc(sizeof(struct Node)); L->ele.stuID = -1; L->ele.stuName = ""; L->next = NULL; return L; } // Find ํ•จ์ˆ˜๋‚˜ Delete ํ•จ์ˆ˜ ๋“ฑ์—์„œ ํ™œ์šฉํ•˜๊ธฐ ์œ„ํ•ด, // input์œผ๋กœ Student ID์™€ Linked List์˜ Header์ธ L์„ ๋ฐ›์•„์„œ, // ์ฃผ์–ด์ง„ Linked List์— ํ•ด๋‹น id๋ฅผ ๊ฐ€์ง€๋Š” ๋…ธ๋“œ๊ฐ€ ์กด์žฌํ•˜๋Š”์ง€ ์ฐพ๊ณ , ์žˆ์„ ๊ฒฝ์šฐ ํ•ด๋‹น ๋…ธ๋“œ์˜ ์ „ ๋…ธ๋“œ, ์—†์„ ๊ฒฝ์šฐ ๋งˆ์ง€๋ง‰ ๋…ธ๋“œ๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋Š” ํ•จ์ˆ˜. // (Delete ํ•จ์ˆ˜์—์„œ๋Š” ์‚ญ์ œํ•  ๋…ธ๋“œ์˜ ์ „ ๋…ธ๋“œ์— ์ ‘๊ทผํ•  ํ•„์š”๊ฐ€ ์žˆ์–ด์„œ ์ „ ๋…ธ๋“œ๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋ฉฐ, // ํ•ด๋‹น ๋…ธ๋“œ๊ฐ€ ํ•„์š”ํ•  ๊ฒฝ์šฐ ์—ฌ๊ธฐ์„œ ๋ฐ˜ํ™˜ํ•œ ๊ฒƒ์˜ ๋‹ค์Œ ๋…ธ๋“œ์— ๋ฐ”๋กœ ์ ‘๊ทผํ•˜๋ฉด ๋˜๊ธฐ์— ๋”ฐ๋กœ ํ•ด๋‹น ๋…ธ๋“œ๋ฅผ ์ฐพ๋Š” ํ•จ์ˆ˜๋Š” ๋งŒ๋“ค์ง€ ์•Š์Œ, // ํ•ด๋‹น id๋ฅผ ๊ฐ€์ง€๋Š” ๋…ธ๋“œ๊ฐ€ ์—†์œผ๋ฉด, next๋กœ NULL์„ ๊ฐ€์ง€๋Š” ๋งˆ์ง€๋ง‰ ๋…ธ๋“œ๊ฐ€ ๋ฐ˜ํ™˜๋˜๋ฏ€๋กœ ํ•ด๋‹น id๋ฅผ ๊ฐ€์ง€๋Š” ๋…ธ๋“œ๊ฐ€ ์—†์Œ์„ ํŒ๋ณ„ํ•  ์ˆ˜ ์žˆ์Œ.) PtrToNode FindPreNode(int id, List L) { PtrToNode P = L; for(;; P = P->next) { if(P->next == NULL || P->next->ele.stuID == id) { return P; // Return previous node of the node that has given id, for Delete function. // If the node that has given id isn't in the list, return the last node of the list. } } } // input์œผ๋กœ ํ•œ ๊ฐœ ๋…ธ๋“œ(ํฌ์ธํ„ฐ)๋ฅผ ๋ฐ›์•„์„œ, // ๊ฐ Node๋ฅผ freeํ•  ๋•Œ ์•ˆ์˜ ๋ฌธ์ž์—ด๋„ freeํ•ด์ค˜์•ผ ํ•˜๊ธฐ์— ์ด๋ฅผ ๋™์‹œ์— ํ•˜๊ธฐ ์œ„ํ•œ ํ•จ์ˆ˜. void FreeNode(PtrToNode P) { free(P->ele.stuName); free(P); } // input์œผ๋กœ Linked List์˜ Header์ธ L์„ ๋ฐ›์•„์„œ, // ํ•ด๋‹น Linked List๋ฅผ ๋ชจ๋‘ ์‚ญ์ œํ•˜๋ฉฐ ๋™์ ํ• ๋‹น์„ ํ•ด์ œํ•˜๋Š” ํ•จ์ˆ˜. void DeleteList(List L) { PtrToNode P = L->next, TmpNode; while(P != NULL) { TmpNode = P->next; FreeNode(P); P = TmpNode; } free(L); } // input์œผ๋กœ Linked List์˜ Header์ธ L์„ ๋ฐ›์•„์„œ, // Insert ํ•จ์ˆ˜์™€ Delete ํ•จ์ˆ˜์—์„œ ํ•ด๋‹น Linked List์˜ ํ˜„์žฌ ์ƒํƒœ(๊ฐ ๋…ธ๋“œ๋“ค์ด ๊ฐ€์ง„ ์ •๋ณด)๋ฅผ ์ถœ๋ ฅํ•  ๋•Œ ์“ฐ๋Š” ํ•จ์ˆ˜. void PrintCurrentList(List L) { PtrToNode P = L->next; int i = (P != NULL); fprintf(output, "Current List > "); while(i) { fprintf(output, "%d %s", P->ele.stuID, P->ele.stuName); P = P->next; if(i = (P != NULL)) { fprintf(output, "-"); } } fprintf(output, "\n"); }
the_stack_data/17755.c
/* Copyright (c) 2017, Piotr Durlej * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #include <stdlib.h> div_t div(int num, int den) { div_t r; r.quot = num / den; r.rem = num % den; return r; }
the_stack_data/34511468.c
/** ****************************************************************************** * @file stm32l4xx_ll_lptim.c * @author MCD Application Team * @brief LPTIM LL module driver. ****************************************************************************** * @attention * * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics. * All rights reserved.</center></h2> * * This software component is licensed by ST under BSD 3-Clause license, * the "License"; You may not use this file except in compliance with the * License. You may obtain a copy of the License at: * opensource.org/licenses/BSD-3-Clause * ****************************************************************************** */ #if defined(USE_FULL_LL_DRIVER) /* Includes ------------------------------------------------------------------*/ #include "stm32l4xx_ll_lptim.h" #include "stm32l4xx_ll_bus.h" #include "stm32l4xx_ll_rcc.h" #ifdef USE_FULL_ASSERT #include "stm32_assert.h" #else #define assert_param(expr) ((void)0U) #endif /** @addtogroup STM32L4xx_LL_Driver * @{ */ #if defined (LPTIM1) || defined (LPTIM2) /** @addtogroup LPTIM_LL * @{ */ /* Private types -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private constants ---------------------------------------------------------*/ /* Private macros ------------------------------------------------------------*/ /** @addtogroup LPTIM_LL_Private_Macros * @{ */ #define IS_LL_LPTIM_CLOCK_SOURCE(__VALUE__) (((__VALUE__) == LL_LPTIM_CLK_SOURCE_INTERNAL) \ || ((__VALUE__) == LL_LPTIM_CLK_SOURCE_EXTERNAL)) #define IS_LL_LPTIM_CLOCK_PRESCALER(__VALUE__) (((__VALUE__) == LL_LPTIM_PRESCALER_DIV1) \ || ((__VALUE__) == LL_LPTIM_PRESCALER_DIV2) \ || ((__VALUE__) == LL_LPTIM_PRESCALER_DIV4) \ || ((__VALUE__) == LL_LPTIM_PRESCALER_DIV8) \ || ((__VALUE__) == LL_LPTIM_PRESCALER_DIV16) \ || ((__VALUE__) == LL_LPTIM_PRESCALER_DIV32) \ || ((__VALUE__) == LL_LPTIM_PRESCALER_DIV64) \ || ((__VALUE__) == LL_LPTIM_PRESCALER_DIV128)) #define IS_LL_LPTIM_WAVEFORM(__VALUE__) (((__VALUE__) == LL_LPTIM_OUTPUT_WAVEFORM_PWM) \ || ((__VALUE__) == LL_LPTIM_OUTPUT_WAVEFORM_SETONCE)) #define IS_LL_LPTIM_OUTPUT_POLARITY(__VALUE__) (((__VALUE__) == LL_LPTIM_OUTPUT_POLARITY_REGULAR) \ || ((__VALUE__) == LL_LPTIM_OUTPUT_POLARITY_INVERSE)) /** * @} */ /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /** @defgroup LPTIM_Private_Functions LPTIM Private Functions * @{ */ /** * @} */ /* Exported functions --------------------------------------------------------*/ /** @addtogroup LPTIM_LL_Exported_Functions * @{ */ /** @addtogroup LPTIM_LL_EF_Init * @{ */ /** * @brief Set LPTIMx registers to their reset values. * @param LPTIMx LP Timer instance * @retval An ErrorStatus enumeration value: * - SUCCESS: LPTIMx registers are de-initialized * - ERROR: invalid LPTIMx instance */ ErrorStatus LL_LPTIM_DeInit(LPTIM_TypeDef *LPTIMx) { ErrorStatus result = SUCCESS; /* Check the parameters */ assert_param(IS_LPTIM_INSTANCE(LPTIMx)); if (LPTIMx == LPTIM1) { LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_LPTIM1); LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_LPTIM1); } #if defined(LPTIM2) else if (LPTIMx == LPTIM2) { LL_APB1_GRP2_ForceReset(LL_APB1_GRP2_PERIPH_LPTIM2); LL_APB1_GRP2_ReleaseReset(LL_APB1_GRP2_PERIPH_LPTIM2); } #endif /* LPTIM2 */ else { result = ERROR; } return result; } /** * @brief Set each fields of the LPTIM_InitStruct structure to its default * value. * @param LPTIM_InitStruct pointer to a @ref LL_LPTIM_InitTypeDef structure * @retval None */ void LL_LPTIM_StructInit(LL_LPTIM_InitTypeDef *LPTIM_InitStruct) { /* Set the default configuration */ LPTIM_InitStruct->ClockSource = LL_LPTIM_CLK_SOURCE_INTERNAL; LPTIM_InitStruct->Prescaler = LL_LPTIM_PRESCALER_DIV1; LPTIM_InitStruct->Waveform = LL_LPTIM_OUTPUT_WAVEFORM_PWM; LPTIM_InitStruct->Polarity = LL_LPTIM_OUTPUT_POLARITY_REGULAR; } /** * @brief Configure the LPTIMx peripheral according to the specified parameters. * @note LL_LPTIM_Init can only be called when the LPTIM instance is disabled. * @note LPTIMx can be disabled using unitary function @ref LL_LPTIM_Disable(). * @param LPTIMx LP Timer Instance * @param LPTIM_InitStruct pointer to a @ref LL_LPTIM_InitTypeDef structure * @retval An ErrorStatus enumeration value: * - SUCCESS: LPTIMx instance has been initialized * - ERROR: LPTIMx instance hasn't been initialized */ ErrorStatus LL_LPTIM_Init(LPTIM_TypeDef *LPTIMx, LL_LPTIM_InitTypeDef *LPTIM_InitStruct) { ErrorStatus result = SUCCESS; /* Check the parameters */ assert_param(IS_LPTIM_INSTANCE(LPTIMx)); assert_param(IS_LL_LPTIM_CLOCK_SOURCE(LPTIM_InitStruct->ClockSource)); assert_param(IS_LL_LPTIM_CLOCK_PRESCALER(LPTIM_InitStruct->Prescaler)); assert_param(IS_LL_LPTIM_WAVEFORM(LPTIM_InitStruct->Waveform)); assert_param(IS_LL_LPTIM_OUTPUT_POLARITY(LPTIM_InitStruct->Polarity)); /* The LPTIMx_CFGR register must only be modified when the LPTIM is disabled (ENABLE bit is reset to 0). */ if (LL_LPTIM_IsEnabled(LPTIMx) == 1UL) { result = ERROR; } else { /* Set CKSEL bitfield according to ClockSource value */ /* Set PRESC bitfield according to Prescaler value */ /* Set WAVE bitfield according to Waveform value */ /* Set WAVEPOL bitfield according to Polarity value */ MODIFY_REG(LPTIMx->CFGR, (LPTIM_CFGR_CKSEL | LPTIM_CFGR_PRESC | LPTIM_CFGR_WAVE | LPTIM_CFGR_WAVPOL), LPTIM_InitStruct->ClockSource | \ LPTIM_InitStruct->Prescaler | \ LPTIM_InitStruct->Waveform | \ LPTIM_InitStruct->Polarity); } return result; } /** * @brief Disable the LPTIM instance * @rmtoll CR ENABLE LL_LPTIM_Disable * @param LPTIMx Low-Power Timer instance * @note The following sequence is required to solve LPTIM disable HW limitation. * Please check Errata Sheet ES0335 for more details under "MCU may remain * stuck in LPTIM interrupt when entering Stop mode" section. * @retval None */ void LL_LPTIM_Disable(LPTIM_TypeDef *LPTIMx) { LL_RCC_ClocksTypeDef rcc_clock; uint32_t tmpclksource = 0; uint32_t tmpIER; uint32_t tmpCFGR; uint32_t tmpCMP; uint32_t tmpARR; uint32_t tmpOR; #if defined(LPTIM_RCR_REP) uint32_t tmpRCR; #endif /* Check the parameters */ assert_param(IS_LPTIM_INSTANCE(LPTIMx)); __disable_irq(); /********** Save LPTIM Config *********/ /* Save LPTIM source clock */ switch ((uint32_t)LPTIMx) { case LPTIM1_BASE: tmpclksource = LL_RCC_GetLPTIMClockSource(LL_RCC_LPTIM1_CLKSOURCE); break; #if defined(LPTIM2) case LPTIM2_BASE: tmpclksource = LL_RCC_GetLPTIMClockSource(LL_RCC_LPTIM2_CLKSOURCE); break; #endif /* LPTIM2 */ default: break; } /* Save LPTIM configuration registers */ tmpIER = LPTIMx->IER; tmpCFGR = LPTIMx->CFGR; tmpCMP = LPTIMx->CMP; tmpARR = LPTIMx->ARR; tmpOR = LPTIMx->OR; #if defined(LPTIM_RCR_REP) tmpRCR = LPTIMx->RCR; #endif /************* Reset LPTIM ************/ (void)LL_LPTIM_DeInit(LPTIMx); /********* Restore LPTIM Config *******/ LL_RCC_GetSystemClocksFreq(&rcc_clock); #if defined(LPTIM_RCR_REP) if ((tmpCMP != 0UL) || (tmpARR != 0UL) || (tmpRCR != 0UL)) #else if ((tmpCMP != 0UL) || (tmpARR != 0UL)) #endif { /* Force LPTIM source kernel clock from APB */ switch ((uint32_t)LPTIMx) { case LPTIM1_BASE: LL_RCC_SetLPTIMClockSource(LL_RCC_LPTIM1_CLKSOURCE_PCLK1); break; #if defined(LPTIM2) case LPTIM2_BASE: LL_RCC_SetLPTIMClockSource(LL_RCC_LPTIM2_CLKSOURCE_PCLK1); break; #endif /* LPTIM2 */ default: break; } if (tmpCMP != 0UL) { /* Restore CMP and ARR registers (LPTIM should be enabled first) */ LPTIMx->CR |= LPTIM_CR_ENABLE; LPTIMx->CMP = tmpCMP; /* Polling on CMP write ok status after above restore operation */ do { rcc_clock.SYSCLK_Frequency--; /* Used for timeout */ } while (((LL_LPTIM_IsActiveFlag_CMPOK(LPTIMx) != 1UL)) && ((rcc_clock.SYSCLK_Frequency) > 0UL)); LL_LPTIM_ClearFlag_CMPOK(LPTIMx); } if (tmpARR != 0UL) { LPTIMx->CR |= LPTIM_CR_ENABLE; LPTIMx->ARR = tmpARR; LL_RCC_GetSystemClocksFreq(&rcc_clock); /* Polling on ARR write ok status after above restore operation */ do { rcc_clock.SYSCLK_Frequency--; /* Used for timeout */ } while (((LL_LPTIM_IsActiveFlag_ARROK(LPTIMx) != 1UL)) && ((rcc_clock.SYSCLK_Frequency) > 0UL)); LL_LPTIM_ClearFlag_ARROK(LPTIMx); } #if defined(LPTIM_RCR_REP) if (tmpRCR != 0UL) { LPTIMx->CR |= LPTIM_CR_ENABLE; LPTIMx->RCR = tmpRCR; LL_RCC_GetSystemClocksFreq(&rcc_clock); /* Polling on RCR write ok status after above restore operation */ do { rcc_clock.SYSCLK_Frequency--; /* Used for timeout */ } while (((LL_LPTIM_IsActiveFlag_REPOK(LPTIMx) != 1UL)) && ((rcc_clock.SYSCLK_Frequency) > 0UL)); LL_LPTIM_ClearFlag_REPOK(LPTIMx); } #endif /* Restore LPTIM source kernel clock */ LL_RCC_SetLPTIMClockSource(tmpclksource); } /* Restore configuration registers (LPTIM should be disabled first) */ LPTIMx->CR &= ~(LPTIM_CR_ENABLE); LPTIMx->IER = tmpIER; LPTIMx->CFGR = tmpCFGR; LPTIMx->OR = tmpOR; __enable_irq(); } /** * @} */ /** * @} */ /** * @} */ #endif /* LPTIM1 || LPTIM2 */ /** * @} */ #endif /* USE_FULL_LL_DRIVER */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
the_stack_data/30013.c
#include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <unistd.h> #include <sys/wait.h> #include <string.h> int main(){ pid_t pid; char *args[3], a[3]; int l, i; char *x; if ((pid = fork()) == 0) { // child process system ("echo CHILD executing LS:"); printf("\nI am Child, my ID %d, MY PARENT ID = %d",getpid(),getppid()); printf("\n"); execlp("ls", "ls", "-l", (char*)NULL); exit(0); } else if (pid > 0) { // parent process wait(NULL); system ("echo PARENT executing User Input Command:"); printf("\n\nI am Parent, my ID %d, I have child with ID: %d, My ParentID = %d", getpid(), pid, getppid()); printf ("\nEnter the command: "); scanf("%s", a); l = strlen(a); x = (char *)malloc(l + 1); strcpy(x, a); args[0] = x; printf ("\nEnter the argument for %s: ", args[0]); scanf("%s", a); l = strlen(a); x = (char *)malloc(l + 1); strcpy(x, a); args[1] = x; args[2] = NULL; execvp(args[0], args); exit(0); } else printf("Problem in child creation....\n"); return 0; }
the_stack_data/247019124.c
#include <stdio.h> int main() { int a[16],i,j,k,l,m; scanf("%d",&a[0]); while (a[0]!=-1) { i=0; m=0; while (a[i]!=0) scanf("%d",&a[++i]); for (j=0;j<i;j++) { l=a[j]*2; for (k=0;k<i;k++) { if (a[k]==l) { m++; break; } } } printf("%d\n",m); scanf("%d",&a[0]); } return 0; }
the_stack_data/32951051.c
/*===-- timeit.c - LLVM Test Suite Timing Tool ------------------*- C++ -*-===*\ |* *| |* Part of the LLVM Project, under the Apache License v2.0 with LLVM *| |* Exceptions. *| |* See https://llvm.org/LICENSE.txt for license information. *| |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *| |* *| \*===----------------------------------------------------------------------===*/ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <errno.h> #include <signal.h> #include <unistd.h> #include <sys/resource.h> #include <sys/time.h> #include <sys/wait.h> /* Enumeration for our exit status codes. */ enum ExitCode { /* \brief Indicates a failure monitoring the target. */ EXITCODE_MONITORING_FAILURE = 66, /* \brief Indicates a failure in exec() which usually means an invalid program * name. */ EXITCODE_EXEC_FAILURE = 67, EXITCODE_EXEC_NOENTRY = 127, EXITCODE_EXEC_NOPERMISSION = 126, /* \brief Indicates that we were unexpectedly signalled(). */ EXITCODE_SIGNALLED = 68, /* \brief Indicates the child was signalled. */ EXITCODE_CHILD_SIGNALLED = 69 }; /* \brief Record our own program name, for error messages. */ static const char *g_program_name = 0; /* \brief Record the child command name, for error messages. */ static const char *g_target_program = 0; /* \brief If given, report output in POSIX mode format. */ static int g_posix_mode = 0; /* \brief If non-zero, execute the program with a timeout of the given number * of seconds. */ static int g_timeout_in_seconds = 0; /* \brief If non-zero, the PID of the process being monitored. */ static pid_t g_monitored_pid = 0; /* \brief If non-zero, the path to attempt to chdir() to before executing the * target. */ static const char *g_target_exec_directory = 0; /* \brief If non-zero, the path to write the summary information to (exit status * and timing). */ static const char *g_summary_file = 0; /* \brief If non-zero, the path to redirect the target standard input to. */ static const char *g_target_redirect_input = 0; /* \brief If non-zero, the path to redirect the target stdout to. */ static const char *g_target_redirect_stdout = 0; /* \brief If non-zero, the path to redirect the target stderr to. */ static const char *g_target_redirect_stderr = 0; /* \brief If non-zero, append exit status at end of output file. */ static int g_append_exitstats = 0; /* @name Resource Limit Variables */ /* @{ */ /* \brief If non-sentinel, the CPU time limit to set for the target. */ static rlim_t g_target_cpu_limit = ~(rlim_t) 0; /* \brief If non-sentinel, the stack size limit to set for the target. */ static rlim_t g_target_stack_size_limit = ~(rlim_t) 0; /* \brief If non-sentinel, the data size limit to set for the target. */ static rlim_t g_target_data_size_limit = ~(rlim_t) 0; /* \brief If non-sentinel, the RSS size limit to set for the target. */ static rlim_t g_target_rss_size_limit = ~(rlim_t) 0; /* \brief If non-sentinel, the file size limit to set for the target. */ static rlim_t g_target_file_size_limit = ~(rlim_t) 0; /* \brief If non-sentinel, the core limit to set for the target. */ static rlim_t g_target_core_limit = ~(rlim_t) 0; /* \brief If non-sentinel, the file count limit to set for the target. */ static rlim_t g_target_file_count_limit = ~(rlim_t) 0; /* \brief If non-sentinel, the subprocess count limit to set for the target. */ static rlim_t g_target_subprocess_count_limit = ~(rlim_t) 0; /* @} */ static double sample_wall_time(void) { struct timeval t; gettimeofday(&t, NULL); return (double) t.tv_sec + t.tv_usec * 1.e-6; } static void terminate_handler(int signal) { /* If we are monitoring a process, kill its process group and assume we will * complete normally. */ if (g_monitored_pid) { fprintf(stderr, ("%s: error: received signal %d. " "killing monitored process(es): %s\n"), g_program_name, signal, g_target_program); /* Kill the process group of monitored_pid. */ kill(-g_monitored_pid, SIGKILL); return; } fprintf(stderr, "%s: error: received signal %d. exiting.\n", g_program_name, signal); /* Otherwise, we received a signal we should treat as for ourselves, and exit * quickly. */ _exit(EXITCODE_SIGNALLED); } static void timeout_handler(int signal) { (void)signal; fprintf(stderr, "%s: TIMING OUT PROCESS: %s\n", g_program_name, g_target_program); /* We should always be monitoring a process when we receive an alarm. Kill its * process group and assume we will terminate normally. */ kill(-g_monitored_pid, SIGKILL); } static int monitor_child_process(pid_t pid, double start_time) { double real_time, user_time, sys_time; struct rusage usage; int res, status; /* Record the PID we are monitoring, for use in the signal handlers. */ g_monitored_pid = pid; /* If we are running with a timeout, set up an alarm now. */ if (g_timeout_in_seconds) { sigset_t masked; sigemptyset(&masked); sigaddset(&masked, SIGALRM); alarm(g_timeout_in_seconds); } /* Wait for the process to terminate. */ do { res = waitpid(pid, &status, 0); } while (res < 0 && errno == EINTR); if (res < 0) { perror("waitpid"); return EXITCODE_MONITORING_FAILURE; } /* Record the real elapsed time as soon as we can. */ real_time = sample_wall_time() - start_time; /* Just in case, kill the child process group. */ kill(-pid, SIGKILL); /* Collect the other resource data on the children. */ if (getrusage(RUSAGE_CHILDREN, &usage) < 0) { perror("getrusage"); return EXITCODE_MONITORING_FAILURE; } user_time = (double) usage.ru_utime.tv_sec + usage.ru_utime.tv_usec/1000000.0; sys_time = (double) usage.ru_stime.tv_sec + usage.ru_stime.tv_usec/1000000.0; /* If the process was signalled, report a more interesting status. */ int exit_status; if (WIFSIGNALED(status)) { fprintf(stderr, "%s: error: child terminated by signal %d\n", g_program_name, WTERMSIG(status)); /* Propagate the signalled status to the caller. */ exit_status = 128 + WTERMSIG(status); } else if (WIFEXITED(status)) { exit_status = WEXITSTATUS(status); } else { /* This should never happen, but if it does assume some kind of failure. */ exit_status = EXITCODE_MONITORING_FAILURE; } // If we are not using a summary file, report the information as /usr/bin/time // would. if (!g_summary_file) { if (g_posix_mode) { fprintf(stderr, "real %12.4f\nuser %12.4f\nsys %12.4f\n", real_time, user_time, sys_time); } else { fprintf(stderr, "%12.4f real %12.4f user %12.4f sys\n", real_time, user_time, sys_time); } } else { /* Otherwise, write the summary data in a simple parsable format. */ FILE *fp = fopen(g_summary_file, "w"); if (!fp) { perror("fopen"); return EXITCODE_MONITORING_FAILURE; } fprintf(fp, "exit %d\n", exit_status); fprintf(fp, "%-10s %.4f\n", "real", real_time); fprintf(fp, "%-10s %.4f\n", "user", user_time); fprintf(fp, "%-10s %.4f\n", "sys", sys_time); fclose(fp); } if (g_append_exitstats && g_target_program) { FILE *fp_stdout = fopen(g_target_redirect_stdout, "a"); if (!fp_stdout) { perror("fopen"); return EXITCODE_MONITORING_FAILURE; } fprintf(fp_stdout, "exit %d\n", exit_status); fclose(fp_stdout); /* let timeit itself report success */ exit_status = 0; } return exit_status; } #define set_resource_limit(resource, value) \ set_resource_limit_actual(#resource, resource, value) static void set_resource_limit_actual(const char *resource_name, int resource, rlim_t value) { /* Get the current limit. */ struct rlimit current; getrlimit(resource, &current); /* Set the limits to as close as requested, assuming we are not super-user. */ struct rlimit requested; requested.rlim_cur = requested.rlim_max = \ (value < current.rlim_max) ? value : current.rlim_max; if (setrlimit(resource, &requested) < 0) { fprintf(stderr, "%s: warning: unable to set limit for %s (to {%lu, %lu})\n", g_program_name, resource_name, (unsigned long) requested.rlim_cur, (unsigned long) requested.rlim_max); } } static int streq(const char *a, const char *b) { return strcmp(a, b) == 0; } static int execute_target_process(char * const argv[]) { /* Create a new process group for pid, and the process tree it may spawn. We * do this, because later on we might want to kill pid _and_ all processes * spawned by it and its descendants. */ setpgid(0, 0); /* Redirect the standard input, if requested. */ if (g_target_redirect_input) { FILE *fp = fopen(g_target_redirect_input, "r"); if (!fp) { perror("fopen"); return EXITCODE_MONITORING_FAILURE; } int fd = fileno(fp); if (dup2(fd, 0) < 0) { perror("dup2"); return EXITCODE_MONITORING_FAILURE; } fclose(fp); } /* Redirect the standard output, if requested. */ FILE *fp_stdout = NULL; if (g_target_redirect_stdout) { fp_stdout = fopen(g_target_redirect_stdout, "w"); if (!fp_stdout) { perror("fopen"); return EXITCODE_MONITORING_FAILURE; } int fd = fileno(fp_stdout); if (dup2(fd, STDOUT_FILENO) < 0) { perror("dup2"); return EXITCODE_MONITORING_FAILURE; } } if (g_target_redirect_stderr) { FILE *fp_stderr = NULL; int fd; if (streq(g_target_redirect_stdout, g_target_redirect_stderr)) fd = fileno(fp_stdout); else { fp_stderr = fopen(g_target_redirect_stderr, "w"); if (!fp_stderr) { perror("fopen"); return EXITCODE_MONITORING_FAILURE; } fd = fileno(fp_stderr); } if (dup2(fd, STDERR_FILENO) < 0) { perror("dup2"); return EXITCODE_MONITORING_FAILURE; } if (fp_stderr != NULL) fclose(fp_stderr); } if (fp_stdout != NULL) fclose(fp_stdout); /* Honor any requested resource limits. */ if (g_target_cpu_limit != ~(rlim_t) 0) { set_resource_limit(RLIMIT_CPU, g_target_cpu_limit); } if (g_target_stack_size_limit != ~(rlim_t) 0) { set_resource_limit(RLIMIT_STACK, g_target_stack_size_limit); } if (g_target_data_size_limit != ~(rlim_t) 0) { set_resource_limit(RLIMIT_DATA, g_target_data_size_limit); } if (g_target_rss_size_limit != ~(rlim_t) 0) { set_resource_limit(RLIMIT_RSS, g_target_rss_size_limit); } if (g_target_file_size_limit != ~(rlim_t) 0) { set_resource_limit(RLIMIT_FSIZE, g_target_file_size_limit); } if (g_target_core_limit != ~(rlim_t) 0) { set_resource_limit(RLIMIT_CORE, g_target_core_limit); } if (g_target_file_count_limit != ~(rlim_t) 0) { set_resource_limit(RLIMIT_NOFILE, g_target_file_count_limit); } if (g_target_subprocess_count_limit != ~(rlim_t) 0) { set_resource_limit(RLIMIT_NPROC, g_target_subprocess_count_limit); } /* Honor the desired target execute directory. */ if (g_target_exec_directory) { if (chdir(g_target_exec_directory) < 0) { perror("chdir"); return EXITCODE_MONITORING_FAILURE; } } execvp(argv[0], argv); perror("execv"); if (errno == ENOENT) { return EXITCODE_EXEC_NOENTRY; } else if (errno == EACCES) { return EXITCODE_EXEC_NOPERMISSION; } return EXITCODE_EXEC_FAILURE; } static int execute(char * const argv[]) { double start_time; pid_t pid; /* Set up signal handlers so we can terminate the monitored process(es) on * SIGINT or SIGTERM. */ signal(SIGINT, terminate_handler); signal(SIGTERM, terminate_handler); /* Set up a signal handler to terminate the process on timeout. */ signal(SIGALRM, timeout_handler); start_time = sample_wall_time(); /* Fork the child process. */ pid = fork(); if (pid < 0) { perror("fork"); return EXITCODE_MONITORING_FAILURE; } /* If we are in the context of the child process, spawn it. */ if (pid == 0) { /* Setup and execute the target process. This never returns except on * failure. */ return execute_target_process(argv); } /* Otherwise, we are in the context of the monitoring process. */ return monitor_child_process(pid, start_time); } static void usage(int is_error) { #define WRAPPED "\n " fprintf(stderr, "usage: %s [options] command ... arguments ...\n", g_program_name); fprintf(stderr, "Options:\n"); fprintf(stderr, " %-20s %s", "-h, --help", "Show this help text.\n"); fprintf(stderr, " %-20s %s", "-p, --posix", "Report time in /usr/bin/time POSIX format.\n"); fprintf(stderr, " %-20s %s", "-t, --timeout <N>", "Execute the subprocess with a timeout of N seconds.\n"); fprintf(stderr, " %-20s %s", "-c, --chdir <PATH>", "Execute the subprocess in the given working directory.\n"); fprintf(stderr, " %-20s %s", "--summary <PATH>", "Write monitored process summary (exit code and time) to PATH.\n"); fprintf(stderr, " %-20s %s", "--redirect-output <PATH>", WRAPPED "Redirect stdout and stderr for the target to PATH.\n"); fprintf(stderr, " %-20s %s", "--redirect-stdout <PATH>", WRAPPED "Redirect stdout for the target to PATH.\n"); fprintf(stderr, " %-20s %s", "--redirect-stderr <PATH>", WRAPPED "Redirect stderr for the target to PATH.\n"); fprintf(stderr, " %-20s %s", "--redirect-input <PATH>", WRAPPED "Redirect stdin for the target to PATH.\n"); fprintf(stderr, " %-20s %s", "--limit-cpu <N>", WRAPPED "Limit the target to N seconds of CPU time.\n"); fprintf(stderr, " %-20s %s", "--limit-stack-size <N>", WRAPPED "Limit the target to N bytes of stack space.\n"); fprintf(stderr, " %-20s %s", "--limit-data-size <N>", WRAPPED "Limit the target to N bytes of data.\n"); fprintf(stderr, " %-20s %s", "--limit-rss-size <N>", WRAPPED "Limit the target to N bytes of resident memory.\n"); fprintf(stderr, " %-20s %s", "--limit-file-size <N>", WRAPPED "Limit the target to creating files no more than N bytes.\n"); fprintf(stderr, " %-20s %s", "--limit-core <N>", WRAPPED "Limit the size for which core files will be generated.\n"); fprintf(stderr, " %-20s %s", "--limit-file-count <N>", (WRAPPED "Limit the maximum number of open files the target can have.\n")); fprintf(stderr, " %-20s %s", "--limit-subprocess-count <N>", (WRAPPED "Limit the maximum number of simultaneous processes " "the target can use.\n")); _exit(is_error); } int main(int argc, char * const argv[]) { int i; g_program_name = argv[0]; for (i = 1; i != argc; ++i) { const char *arg = argv[i]; if (arg[0] != '-') break; if (streq(arg, "-h") || streq(arg, "--help")) { usage(/*is_error=*/0); } if (streq(arg, "-p") || streq(arg, "--posix")) { g_posix_mode = 1; continue; } if (streq(arg, "-t") || streq(arg, "--timeout")) { if (i + 1 == argc) { fprintf(stderr, "error: %s argument requires an option\n", arg); usage(/*is_error=*/1); } g_timeout_in_seconds = atoi(argv[++i]); continue; } if (streq(arg, "--summary")) { if (i + 1 == argc) { fprintf(stderr, "error: %s argument requires an option\n", arg); usage(/*is_error=*/1); } g_summary_file = argv[++i]; continue; } if (streq(arg, "--redirect-input")) { if (i + 1 == argc) { fprintf(stderr, "error: %s argument requires an option\n", arg); usage(/*is_error=*/1); } g_target_redirect_input = argv[++i]; continue; } if (streq(arg, "--redirect-output")) { if (i + 1 == argc) { fprintf(stderr, "error: %s argument requires an option\n", arg); usage(/*is_error=*/1); } g_target_redirect_stdout = argv[++i]; g_target_redirect_stderr = g_target_redirect_stdout; continue; } if (streq(arg, "--redirect-stdout")) { if (i + 1 == argc) { fprintf(stderr, "error: %s argument requires an option\n", arg); usage(/*is_error=*/1); } g_target_redirect_stdout = argv[++i]; continue; } if (streq(arg, "--redirect-stderr")) { if (i + 1 == argc) { fprintf(stderr, "error: %s argument requires an option\n", arg); usage(/*is_error=*/1); } g_target_redirect_stderr = argv[++i]; continue; } if (streq(arg, "--append-exitstatus")) { g_append_exitstats = 1; continue; } if (streq(arg, "-c") || streq(arg, "--chdir")) { if (i + 1 == argc) { fprintf(stderr, "error: %s argument requires an option\n", arg); usage(/*is_error=*/1); } g_target_exec_directory = argv[++i]; continue; } if (strncmp(arg, "--limit-", 8) == 0) { rlim_t value; if (i + 1 == argc) { fprintf(stderr, "error: %s argument requires an option\n", arg); usage(/*is_error=*/1); } value = atoi(argv[++i]); if (streq(arg, "--limit-cpu")) { g_target_cpu_limit = value; } else if (streq(arg, "--limit-stack-size")) { g_target_stack_size_limit = value; } else if (streq(arg, "--limit-data-size")) { g_target_data_size_limit = value; } else if (streq(arg, "--limit-rss-size")) { g_target_rss_size_limit = value; } else if (streq(arg, "--limit-file-size")) { g_target_file_size_limit = value; } else if (streq(arg, "--limit-core")) { g_target_core_limit = value; } else if (streq(arg, "--limit-file-count")) { g_target_file_count_limit = value; } else if (streq(arg, "--limit-subprocess-count")) { g_target_subprocess_count_limit = value; } else { fprintf(stderr, "error: invalid limit argument '%s'\n", arg); usage(/*is_error=*/1); } continue; } fprintf(stderr, "error: invalid argument '%s'\n", arg); usage(/*is_error=*/1); } if (i == argc) { fprintf(stderr, "error: no command (or arguments) was given\n"); usage(/*is_error=*/1); } g_target_program = argv[i]; return execute(&argv[i]); }
the_stack_data/271785.c
#include <omp.h> #include <sys/time.h> #include <stdio.h> void worker_timed(int delay_us) { struct timeval start, now; gettimeofday(&start, NULL); while(1) { gettimeofday(&now, NULL); if(((now.tv_sec - start.tv_sec)*1000000) + ((now.tv_usec - start.tv_usec)) >= delay_us) break; } } //TODO: get loadbalancing using with threadlocal //use an initial parallel region so initial setup is not counted int main( int argc, char** argv) { int i = 0; int num_tasks=500000; int delay = 40; int total_time; struct timeval start, end; if(argc > 1) num_tasks = atoi(argv[1]); if(argc > 2) delay = atoi(argv[2]); #pragma omp parallel { #pragma omp single { gettimeofday(&start, NULL); for(i = 0; i < num_tasks; i++) { #pragma omp task untied worker_timed(delay); } #pragma omp taskwait gettimeofday(&end, NULL); } } total_time = ((end.tv_sec - start.tv_sec)*1000) + ((end.tv_usec - start.tv_usec)/1000); printf("total time for %d tasks on %d cores, with a delay of %d, is %d ms\n", num_tasks, omp_get_num_procs(), delay, total_time); }
the_stack_data/517944.c
#include <stdio.h> #include <string.h> int main(){ char teste[255]; printf("Digite uma palavra: "); //Limpa o buffer setbuf(stdin, 0); //Lรช string fgets(teste, 255, stdin); printf("%s", teste); teste[strlen(teste) - 1] = '\0' ; return 0; }
the_stack_data/1161135.c
// Copyright 2020, Dimitra S. Kaitalidou, All rights reserved int solution(int A, int B, int K){ // Initialize variables int div_num = 0; int div_num1 = 0; int div_num2 = 0; // Find the number of the divisible numbers if(A == B) { if(A % K == 0) div_num = 1; else div_num = 0; } else { if(A % K == 0) { div_num1 = A/K; if(B % K == 0) div_num2 = B/K; else div_num2 = (B - B % K) / K; } else { div_num1 = (A + K - A % K) / K; if(B % K == 0) div_num2 = B/K; else div_num2 = (B - B % K) / K; } div_num = div_num2 - div_num1 + 1; } // Return result return div_num; }
the_stack_data/95450622.c
/******************************************************************************/ /* stkchk_var.c */ /* */ /* Copyright (c) 2017 Texas Instruments Incorporated */ /* http://www.ti.com/ */ /* */ /* Redistribution and use in source and binary forms, with or without */ /* modification, are permitted provided that the following conditions */ /* are met: */ /* */ /* Redistributions of source code must retain the above copyright */ /* notice, this list of conditions and the following disclaimer. */ /* */ /* Redistributions in binary form must reproduce the above copyright */ /* notice, this list of conditions and the following disclaimer in */ /* the documentation and/or other materials provided with the */ /* distribution. */ /* */ /* Neither the name of Texas Instruments Incorporated nor the names */ /* of its contributors may be used to endorse or promote products */ /* derived from this software without specific prior written */ /* permission. */ /* */ /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ /* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ /* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR */ /* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ /* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ /* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ /* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */ /* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY */ /* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE */ /* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* */ /******************************************************************************/ /******************************************************************************/ /* Variable used by the stkchk*.asm routines to remember if stack overflow */ /* diagnostics have already been issued. */ /******************************************************************************/ unsigned int _stkchk_called;
the_stack_data/125141801.c
#include <stdio.h> #include <stdlib.h> #include <math.h> typedef signed char digit; digit digits[100][50] = { { 3,7,1,0,7,2,8,7,5,3,3,9,0,2,1,0,2,7,9,8,7,9,7,9,9,8,2,2,0,8,3,7,5,9,0,2,4,6,5,1,0,1,3,5,7,4,0,2,5,0 }, { 4,6,3,7,6,9,3,7,6,7,7,4,9,0,0,0,9,7,1,2,6,4,8,1,2,4,8,9,6,9,7,0,0,7,8,0,5,0,4,1,7,0,1,8,2,6,0,5,3,8 }, { 7,4,3,2,4,9,8,6,1,9,9,5,2,4,7,4,1,0,5,9,4,7,4,2,3,3,3,0,9,5,1,3,0,5,8,1,2,3,7,2,6,6,1,7,3,0,9,6,2,9 }, { 9,1,9,4,2,2,1,3,3,6,3,5,7,4,1,6,1,5,7,2,5,2,2,4,3,0,5,6,3,3,0,1,8,1,1,0,7,2,4,0,6,1,5,4,9,0,8,2,5,0 }, { 2,3,0,6,7,5,8,8,2,0,7,5,3,9,3,4,6,1,7,1,1,7,1,9,8,0,3,1,0,4,2,1,0,4,7,5,1,3,7,7,8,0,6,3,2,4,6,6,7,6 }, { 8,9,2,6,1,6,7,0,6,9,6,6,2,3,6,3,3,8,2,0,1,3,6,3,7,8,4,1,8,3,8,3,6,8,4,1,7,8,7,3,4,3,6,1,7,2,6,7,5,7 }, { 2,8,1,1,2,8,7,9,8,1,2,8,4,9,9,7,9,4,0,8,0,6,5,4,8,1,9,3,1,5,9,2,6,2,1,6,9,1,2,7,5,8,8,9,8,3,2,7,3,8 }, { 4,4,2,7,4,2,2,8,9,1,7,4,3,2,5,2,0,3,2,1,9,2,3,5,8,9,4,2,2,8,7,6,7,9,6,4,8,7,6,7,0,2,7,2,1,8,9,3,1,8 }, { 4,7,4,5,1,4,4,5,7,3,6,0,0,1,3,0,6,4,3,9,0,9,1,1,6,7,2,1,6,8,5,6,8,4,4,5,8,8,7,1,1,6,0,3,1,5,3,2,7,6 }, { 7,0,3,8,6,4,8,6,1,0,5,8,4,3,0,2,5,4,3,9,9,3,9,6,1,9,8,2,8,9,1,7,5,9,3,6,6,5,6,8,6,7,5,7,9,3,4,9,5,1 }, { 6,2,1,7,6,4,5,7,1,4,1,8,5,6,5,6,0,6,2,9,5,0,2,1,5,7,2,2,3,1,9,6,5,8,6,7,5,5,0,7,9,3,2,4,1,9,3,3,3,1 }, { 6,4,9,0,6,3,5,2,4,6,2,7,4,1,9,0,4,9,2,9,1,0,1,4,3,2,4,4,5,8,1,3,8,2,2,6,6,3,3,4,7,9,4,4,7,5,8,1,7,8 }, { 9,2,5,7,5,8,6,7,7,1,8,3,3,7,2,1,7,6,6,1,9,6,3,7,5,1,5,9,0,5,7,9,2,3,9,7,2,8,2,4,5,5,9,8,8,3,8,4,0,7 }, { 5,8,2,0,3,5,6,5,3,2,5,3,5,9,3,9,9,0,0,8,4,0,2,6,3,3,5,6,8,9,4,8,8,3,0,1,8,9,4,5,8,6,2,8,2,2,7,8,2,8 }, { 8,0,1,8,1,1,9,9,3,8,4,8,2,6,2,8,2,0,1,4,2,7,8,1,9,4,1,3,9,9,4,0,5,6,7,5,8,7,1,5,1,1,7,0,0,9,4,3,9,0 }, { 3,5,3,9,8,6,6,4,3,7,2,8,2,7,1,1,2,6,5,3,8,2,9,9,8,7,2,4,0,7,8,4,4,7,3,0,5,3,1,9,0,1,0,4,2,9,3,5,8,6 }, { 8,6,5,1,5,5,0,6,0,0,6,2,9,5,8,6,4,8,6,1,5,3,2,0,7,5,2,7,3,3,7,1,9,5,9,1,9,1,4,2,0,5,1,7,2,5,5,8,2,9 }, { 7,1,6,9,3,8,8,8,7,0,7,7,1,5,4,6,6,4,9,9,1,1,5,5,9,3,4,8,7,6,0,3,5,3,2,9,2,1,7,1,4,9,7,0,0,5,6,9,3,8 }, { 5,4,3,7,0,0,7,0,5,7,6,8,2,6,6,8,4,6,2,4,6,2,1,4,9,5,6,5,0,0,7,6,4,7,1,7,8,7,2,9,4,4,3,8,3,7,7,6,0,4 }, { 5,3,2,8,2,6,5,4,1,0,8,7,5,6,8,2,8,4,4,3,1,9,1,1,9,0,6,3,4,6,9,4,0,3,7,8,5,5,2,1,7,7,7,9,2,9,5,1,4,5 }, { 3,6,1,2,3,2,7,2,5,2,5,0,0,0,2,9,6,0,7,1,0,7,5,0,8,2,5,6,3,8,1,5,6,5,6,7,1,0,8,8,5,2,5,8,3,5,0,7,2,1 }, { 4,5,8,7,6,5,7,6,1,7,2,4,1,0,9,7,6,4,4,7,3,3,9,1,1,0,6,0,7,2,1,8,2,6,5,2,3,6,8,7,7,2,2,3,6,3,6,0,4,5 }, { 1,7,4,2,3,7,0,6,9,0,5,8,5,1,8,6,0,6,6,0,4,4,8,2,0,7,6,2,1,2,0,9,8,1,3,2,8,7,8,6,0,7,3,3,9,6,9,4,1,2 }, { 8,1,1,4,2,6,6,0,4,1,8,0,8,6,8,3,0,6,1,9,3,2,8,4,6,0,8,1,1,1,9,1,0,6,1,5,5,6,9,4,0,5,1,2,6,8,9,6,9,2 }, { 5,1,9,3,4,3,2,5,4,5,1,7,2,8,3,8,8,6,4,1,9,1,8,0,4,7,0,4,9,2,9,3,2,1,5,0,5,8,6,4,2,5,6,3,0,4,9,4,8,3 }, { 6,2,4,6,7,2,2,1,6,4,8,4,3,5,0,7,6,2,0,1,7,2,7,9,1,8,0,3,9,9,4,4,6,9,3,0,0,4,7,3,2,9,5,6,3,4,0,6,9,1 }, { 1,5,7,3,2,4,4,4,3,8,6,9,0,8,1,2,5,7,9,4,5,1,4,0,8,9,0,5,7,7,0,6,2,2,9,4,2,9,1,9,7,1,0,7,9,2,8,2,0,9 }, { 5,5,0,3,7,6,8,7,5,2,5,6,7,8,7,7,3,0,9,1,8,6,2,5,4,0,7,4,4,9,6,9,8,4,4,5,0,8,3,3,0,3,9,3,6,8,2,1,2,6 }, { 1,8,3,3,6,3,8,4,8,2,5,3,3,0,1,5,4,6,8,6,1,9,6,1,2,4,3,4,8,7,6,7,6,8,1,2,9,7,5,3,4,3,7,5,9,4,6,5,1,5 }, { 8,0,3,8,6,2,8,7,5,9,2,8,7,8,4,9,0,2,0,1,5,2,1,6,8,5,5,5,4,8,2,8,7,1,7,2,0,1,2,1,9,2,5,7,7,6,6,9,5,4 }, { 7,8,1,8,2,8,3,3,7,5,7,9,9,3,1,0,3,6,1,4,7,4,0,3,5,6,8,5,6,4,4,9,0,9,5,5,2,7,0,9,7,8,6,4,7,9,7,5,8,1 }, { 1,6,7,2,6,3,2,0,1,0,0,4,3,6,8,9,7,8,4,2,5,5,3,5,3,9,9,2,0,9,3,1,8,3,7,4,4,1,4,9,7,8,0,6,8,6,0,9,8,4 }, { 4,8,4,0,3,0,9,8,1,2,9,0,7,7,7,9,1,7,9,9,0,8,8,2,1,8,7,9,5,3,2,7,3,6,4,4,7,5,6,7,5,5,9,0,8,4,8,0,3,0 }, { 8,7,0,8,6,9,8,7,5,5,1,3,9,2,7,1,1,8,5,4,5,1,7,0,7,8,5,4,4,1,6,1,8,5,2,4,2,4,3,2,0,6,9,3,1,5,0,3,3,2 }, { 5,9,9,5,9,4,0,6,8,9,5,7,5,6,5,3,6,7,8,2,1,0,7,0,7,4,9,2,6,9,6,6,5,3,7,6,7,6,3,2,6,2,3,5,4,4,7,2,1,0 }, { 6,9,7,9,3,9,5,0,6,7,9,6,5,2,6,9,4,7,4,2,5,9,7,7,0,9,7,3,9,1,6,6,6,9,3,7,6,3,0,4,2,6,3,3,9,8,7,0,8,5 }, { 4,1,0,5,2,6,8,4,7,0,8,2,9,9,0,8,5,2,1,1,3,9,9,4,2,7,3,6,5,7,3,4,1,1,6,1,8,2,7,6,0,3,1,5,0,0,1,2,7,1 }, { 6,5,3,7,8,6,0,7,3,6,1,5,0,1,0,8,0,8,5,7,0,0,9,1,4,9,9,3,9,5,1,2,5,5,7,0,2,8,1,9,8,7,4,6,0,0,4,3,7,5 }, { 3,5,8,2,9,0,3,5,3,1,7,4,3,4,7,1,7,3,2,6,9,3,2,1,2,3,5,7,8,1,5,4,9,8,2,6,2,9,7,4,2,5,5,2,7,3,7,3,0,7 }, { 9,4,9,5,3,7,5,9,7,6,5,1,0,5,3,0,5,9,4,6,9,6,6,0,6,7,6,8,3,1,5,6,5,7,4,3,7,7,1,6,7,4,0,1,8,7,5,2,7,5 }, { 8,8,9,0,2,8,0,2,5,7,1,7,3,3,2,2,9,6,1,9,1,7,6,6,6,8,7,1,3,8,1,9,9,3,1,8,1,1,0,4,8,7,7,0,1,9,0,2,7,1 }, { 2,5,2,6,7,6,8,0,2,7,6,0,7,8,0,0,3,0,1,3,6,7,8,6,8,0,9,9,2,5,2,5,4,6,3,4,0,1,0,6,1,6,3,2,8,6,6,5,2,6 }, { 3,6,2,7,0,2,1,8,5,4,0,4,9,7,7,0,5,5,8,5,6,2,9,9,4,6,5,8,0,6,3,6,2,3,7,9,9,3,1,4,0,7,4,6,2,5,5,9,6,2 }, { 2,4,0,7,4,4,8,6,9,0,8,2,3,1,1,7,4,9,7,7,7,9,2,3,6,5,4,6,6,2,5,7,2,4,6,9,2,3,3,2,2,8,1,0,9,1,7,1,4,1 }, { 9,1,4,3,0,2,8,8,1,9,7,1,0,3,2,8,8,5,9,7,8,0,6,6,6,9,7,6,0,8,9,2,9,3,8,6,3,8,2,8,5,0,2,5,3,3,3,4,0,3 }, { 3,4,4,1,3,0,6,5,5,7,8,0,1,6,1,2,7,8,1,5,9,2,1,8,1,5,0,0,5,5,6,1,8,6,8,8,3,6,4,6,8,4,2,0,0,9,0,4,7,0 }, { 2,3,0,5,3,0,8,1,1,7,2,8,1,6,4,3,0,4,8,7,6,2,3,7,9,1,9,6,9,8,4,2,4,8,7,2,5,5,0,3,6,6,3,8,7,8,4,5,8,3 }, { 1,1,4,8,7,6,9,6,9,3,2,1,5,4,9,0,2,8,1,0,4,2,4,0,2,0,1,3,8,3,3,5,1,2,4,4,6,2,1,8,1,4,4,1,7,7,3,4,7,0 }, { 6,3,7,8,3,2,9,9,4,9,0,6,3,6,2,5,9,6,6,6,4,9,8,5,8,7,6,1,8,2,2,1,2,2,5,2,2,5,5,1,2,4,8,6,7,6,4,5,3,3 }, { 6,7,7,2,0,1,8,6,9,7,1,6,9,8,5,4,4,3,1,2,4,1,9,5,7,2,4,0,9,9,1,3,9,5,9,0,0,8,9,5,2,3,1,0,0,5,8,8,2,2 }, { 9,5,5,4,8,2,5,5,3,0,0,2,6,3,5,2,0,7,8,1,5,3,2,2,9,6,7,9,6,2,4,9,4,8,1,6,4,1,9,5,3,8,6,8,2,1,8,7,7,4 }, { 7,6,0,8,5,3,2,7,1,3,2,2,8,5,7,2,3,1,1,0,4,2,4,8,0,3,4,5,6,1,2,4,8,6,7,6,9,7,0,6,4,5,0,7,9,9,5,2,3,6 }, { 3,7,7,7,4,2,4,2,5,3,5,4,1,1,2,9,1,6,8,4,2,7,6,8,6,5,5,3,8,9,2,6,2,0,5,0,2,4,9,1,0,3,2,6,5,7,2,9,6,7 }, { 2,3,7,0,1,9,1,3,2,7,5,7,2,5,6,7,5,2,8,5,6,5,3,2,4,8,2,5,8,2,6,5,4,6,3,0,9,2,2,0,7,0,5,8,5,9,6,5,2,2 }, { 2,9,7,9,8,8,6,0,2,7,2,2,5,8,3,3,1,9,1,3,1,2,6,3,7,5,1,4,7,3,4,1,9,9,4,8,8,9,5,3,4,7,6,5,7,4,5,5,0,1 }, { 1,8,4,9,5,7,0,1,4,5,4,8,7,9,2,8,8,9,8,4,8,5,6,8,2,7,7,2,6,0,7,7,7,1,3,7,2,1,4,0,3,7,9,8,8,7,9,7,1,5 }, { 3,8,2,9,8,2,0,3,7,8,3,0,3,1,4,7,3,5,2,7,7,2,1,5,8,0,3,4,8,1,4,4,5,1,3,4,9,1,3,7,3,2,2,6,6,5,1,3,8,1 }, { 3,4,8,2,9,5,4,3,8,2,9,1,9,9,9,1,8,1,8,0,2,7,8,9,1,6,5,2,2,4,3,1,0,2,7,3,9,2,2,5,1,1,2,2,8,6,9,5,3,9 }, { 4,0,9,5,7,9,5,3,0,6,6,4,0,5,2,3,2,6,3,2,5,3,8,0,4,4,1,0,0,0,5,9,6,5,4,9,3,9,1,5,9,8,7,9,5,9,3,6,3,5 }, { 2,9,7,4,6,1,5,2,1,8,5,5,0,2,3,7,1,3,0,7,6,4,2,2,5,5,1,2,1,1,8,3,6,9,3,8,0,3,5,8,0,3,8,8,5,8,4,9,0,3 }, { 4,1,6,9,8,1,1,6,2,2,2,0,7,2,9,7,7,1,8,6,1,5,8,2,3,6,6,7,8,4,2,4,6,8,9,1,5,7,9,9,3,5,3,2,9,6,1,9,2,2 }, { 6,2,4,6,7,9,5,7,1,9,4,4,0,1,2,6,9,0,4,3,8,7,7,1,0,7,2,7,5,0,4,8,1,0,2,3,9,0,8,9,5,5,2,3,5,9,7,4,5,7 }, { 2,3,1,8,9,7,0,6,7,7,2,5,4,7,9,1,5,0,6,1,5,0,5,5,0,4,9,5,3,9,2,2,9,7,9,5,3,0,9,0,1,1,2,9,9,6,7,5,1,9 }, { 8,6,1,8,8,0,8,8,2,2,5,8,7,5,3,1,4,5,2,9,5,8,4,0,9,9,2,5,1,2,0,3,8,2,9,0,0,9,4,0,7,7,7,0,7,7,5,6,7,2 }, { 1,1,3,0,6,7,3,9,7,0,8,3,0,4,7,2,4,4,8,3,8,1,6,5,3,3,8,7,3,5,0,2,3,4,0,8,4,5,6,4,7,0,5,8,0,7,7,3,0,8 }, { 8,2,9,5,9,1,7,4,7,6,7,1,4,0,3,6,3,1,9,8,0,0,8,1,8,7,1,2,9,0,1,1,8,7,5,4,9,1,3,1,0,5,4,7,1,2,6,5,8,1 }, { 9,7,6,2,3,3,3,1,0,4,4,8,1,8,3,8,6,2,6,9,5,1,5,4,5,6,3,3,4,9,2,6,3,6,6,5,7,2,8,9,7,5,6,3,4,0,0,5,0,0 }, { 4,2,8,4,6,2,8,0,1,8,3,5,1,7,0,7,0,5,2,7,8,3,1,8,3,9,4,2,5,8,8,2,1,4,5,5,2,1,2,2,7,2,5,1,2,5,0,3,2,7 }, { 5,5,1,2,1,6,0,3,5,4,6,9,8,1,2,0,0,5,8,1,7,6,2,1,6,5,2,1,2,8,2,7,6,5,2,7,5,1,6,9,1,2,9,6,8,9,7,7,8,9 }, { 3,2,2,3,8,1,9,5,7,3,4,3,2,9,3,3,9,9,4,6,4,3,7,5,0,1,9,0,7,8,3,6,9,4,5,7,6,5,8,8,3,3,5,2,3,9,9,8,8,6 }, { 7,5,5,0,6,1,6,4,9,6,5,1,8,4,7,7,5,1,8,0,7,3,8,1,6,8,8,3,7,8,6,1,0,9,1,5,2,7,3,5,7,9,2,9,7,0,1,3,3,7 }, { 6,2,1,7,7,8,4,2,7,5,2,1,9,2,6,2,3,4,0,1,9,4,2,3,9,9,6,3,9,1,6,8,0,4,4,9,8,3,9,9,3,1,7,3,3,1,2,7,3,1 }, { 3,2,9,2,4,1,8,5,7,0,7,1,4,7,3,4,9,5,6,6,9,1,6,6,7,4,6,8,7,6,3,4,6,6,0,9,1,5,0,3,5,9,1,4,6,7,7,5,0,4 }, { 9,9,5,1,8,6,7,1,4,3,0,2,3,5,2,1,9,6,2,8,8,9,4,8,9,0,1,0,2,4,2,3,3,2,5,1,1,6,9,1,3,6,1,9,6,2,6,6,2,2 }, { 7,3,2,6,7,4,6,0,8,0,0,5,9,1,5,4,7,4,7,1,8,3,0,7,9,8,3,9,2,8,6,8,5,3,5,2,0,6,9,4,6,9,4,4,5,4,0,7,2,4 }, { 7,6,8,4,1,8,2,2,5,2,4,6,7,4,4,1,7,1,6,1,5,1,4,0,3,6,4,2,7,9,8,2,2,7,3,3,4,8,0,5,5,5,5,6,2,1,4,8,1,8 }, { 9,7,1,4,2,6,1,7,9,1,0,3,4,2,5,9,8,6,4,7,2,0,4,5,1,6,8,9,3,9,8,9,4,2,2,1,7,9,8,2,6,0,8,8,0,7,6,8,5,2 }, { 8,7,7,8,3,6,4,6,1,8,2,7,9,9,3,4,6,3,1,3,7,6,7,7,5,4,3,0,7,8,0,9,3,6,3,3,3,3,0,1,8,9,8,2,6,4,2,0,9,0 }, { 1,0,8,4,8,8,0,2,5,2,1,6,7,4,6,7,0,8,8,3,2,1,5,1,2,0,1,8,5,8,8,3,5,4,3,2,2,3,8,1,2,8,7,6,9,5,2,7,8,6 }, { 7,1,3,2,9,6,1,2,4,7,4,7,8,2,4,6,4,5,3,8,6,3,6,9,9,3,0,0,9,0,4,9,3,1,0,3,6,3,6,1,9,7,6,3,8,7,8,0,3,9 }, { 6,2,1,8,4,0,7,3,5,7,2,3,9,9,7,9,4,2,2,3,4,0,6,2,3,5,3,9,3,8,0,8,3,3,9,6,5,1,3,2,7,4,0,8,0,1,1,1,1,6 }, { 6,6,6,2,7,8,9,1,9,8,1,4,8,8,0,8,7,7,9,7,9,4,1,8,7,6,8,7,6,1,4,4,2,3,0,0,3,0,9,8,4,4,9,0,8,5,1,4,1,1 }, { 6,0,6,6,1,8,2,6,2,9,3,6,8,2,8,3,6,7,6,4,7,4,4,7,7,9,2,3,9,1,8,0,3,3,5,1,1,0,9,8,9,0,6,9,7,9,0,7,1,4 }, { 8,5,7,8,6,9,4,4,0,8,9,5,5,2,9,9,0,6,5,3,6,4,0,4,4,7,4,2,5,5,7,6,0,8,3,6,5,9,9,7,6,6,4,5,7,9,5,0,9,6 }, { 6,6,0,2,4,3,9,6,4,0,9,9,0,5,3,8,9,6,0,7,1,2,0,1,9,8,2,1,9,9,7,6,0,4,7,5,9,9,4,9,0,1,9,7,2,3,0,2,9,7 }, { 6,4,9,1,3,9,8,2,6,8,0,0,3,2,9,7,3,1,5,6,0,3,7,1,2,0,0,4,1,3,7,7,9,0,3,7,8,5,5,6,6,0,8,5,0,8,9,2,5,2 }, { 1,6,7,3,0,9,3,9,3,1,9,8,7,2,7,5,0,2,7,5,4,6,8,9,0,6,9,0,3,7,0,7,5,3,9,4,1,3,0,4,2,6,5,2,3,1,5,0,1,1 }, { 9,4,8,0,9,3,7,7,2,4,5,0,4,8,7,9,5,1,5,0,9,5,4,1,0,0,9,2,1,6,4,5,8,6,3,7,5,4,7,1,0,5,9,8,4,3,6,7,9,1 }, { 7,8,6,3,9,1,6,7,0,2,1,1,8,7,4,9,2,4,3,1,9,9,5,7,0,0,6,4,1,9,1,7,9,6,9,7,7,7,5,9,9,0,2,8,3,0,0,6,9,9 }, { 1,5,3,6,8,7,1,3,7,1,1,9,3,6,6,1,4,9,5,2,8,1,1,3,0,5,8,7,6,3,8,0,2,7,8,4,1,0,7,5,4,4,4,9,7,3,3,0,7,8 }, { 4,0,7,8,9,9,2,3,1,1,5,5,3,5,5,6,2,5,6,1,1,4,2,3,2,2,4,2,3,2,5,5,0,3,3,6,8,5,4,4,2,4,8,8,9,1,7,3,5,3 }, { 4,4,8,8,9,9,1,1,5,0,1,4,4,0,6,4,8,0,2,0,3,6,9,0,6,8,0,6,3,9,6,0,6,7,2,3,2,2,1,9,3,2,0,4,1,4,9,5,3,5 }, { 4,1,5,0,3,1,2,8,8,8,0,3,3,9,5,3,6,0,5,3,2,9,9,3,4,0,3,6,8,0,0,6,9,7,7,7,1,0,6,5,0,5,6,6,6,3,1,9,5,4 }, { 8,1,2,3,4,8,8,0,6,7,3,2,1,0,1,4,6,7,3,9,0,5,8,5,6,8,5,5,7,9,3,4,5,8,1,4,0,3,6,2,7,8,2,2,7,0,3,2,8,0 }, { 8,2,6,1,6,5,7,0,7,7,3,9,4,8,3,2,7,5,9,2,2,3,2,8,4,5,9,4,1,7,0,6,5,2,5,0,9,4,5,1,2,3,2,5,2,3,0,6,0,8 }, { 2,2,9,1,8,8,0,2,0,5,8,7,7,7,3,1,9,7,1,9,8,3,9,4,5,0,1,8,0,8,8,8,0,7,2,4,2,9,6,6,1,9,8,0,8,1,1,1,9,7 }, { 7,7,1,5,8,5,4,2,5,0,2,0,1,6,5,4,5,0,9,0,4,1,3,2,4,5,8,0,9,7,8,6,8,8,2,7,7,8,9,4,8,7,2,1,8,5,9,6,1,7 }, { 7,2,1,0,7,8,3,8,4,3,5,0,6,9,1,8,6,1,5,5,4,3,5,6,6,2,8,8,4,0,6,2,2,5,7,4,7,3,6,9,2,2,8,4,5,0,9,5,1,6 }, { 2,0,8,4,9,6,0,3,9,8,0,1,3,4,0,0,1,7,2,3,9,3,0,6,7,1,6,6,6,8,2,3,5,5,5,2,4,5,2,5,2,8,0,4,6,0,9,7,2,2 }, { 5,3,5,0,3,5,3,4,2,2,6,4,7,2,5,2,4,2,5,0,8,7,4,0,5,4,0,7,5,5,9,1,7,8,9,7,8,1,2,6,4,3,3,0,3,3,1,6,9,0 } }; digit digitss[2][5] = { // 5746 { 8, 2, 3, 4, 8}, { 4, 5, 1, 2, 9} }; int main(int argc, char** argv) { printf("Calculating the first ten digits of the sum of the pre-given one-hundred 50-digit numbers.\n"); unsigned sum[100] = { 0u }; unsigned carry = 0u; unsigned digitcount = sizeof(digits) / sizeof(digits[0]); unsigned digitlen = sizeof(digits[0]) / sizeof(digits[0][0]); unsigned sumoffset = 100 - digitlen; unsigned sumlen = 0u; for (int i = 0; i < digitcount; i++) for (int j = digitlen - 1; j >= 0; j--) { digit res = sum[j + sumoffset] + digits[i][j]; sum[j + sumoffset] = res % 10u; digit carry = res / 10u; unsigned reps = 0u; for (int k = j + sumoffset - 1; k >= 0; k--) { if (carry == 0) break; digit res = sum[k] + carry; carry = res / 10u; sum[k] = res % 10u; reps++; } unsigned maxidx = digitlen - j + reps; if (sumlen < maxidx) sumlen = maxidx; } printf("Sum: "); for (unsigned i = 100 - sumlen; i < 100; i++) printf("%d", sum[i]); printf("\nResult: "); for (unsigned i = 0; i <= 10; i++) printf("%d", sum[100 - sumlen + i]); printf("\n"); }
the_stack_data/636121.c
#include <stdio.h> #include <stdlib.h> typedef struct BstNode{ int data; struct BstNode* left; struct BstNode* right; } BstNode; struct BstNode* root = NULL; struct BstNode* createNode(int num){ struct BstNode* temp = (struct BstNode *) malloc(sizeof(struct BstNode)); temp -> data = num; return temp; } struct BstNode* Insert(struct BstNode* base, int num){ // empty tree condition if (base == NULL) return createNode(num); else if(num < base -> data) base -> left = Insert(base->left, num); else if(num > base -> data) base -> right = Insert(base->right, num); return base; } void preorder_display(struct BstNode* ptr){ if (ptr != NULL){ printf("%5d", ptr -> data); preorder_display(ptr -> left); preorder_display(ptr -> right); } } void inorder_display(struct BstNode* ptr){ if(ptr != NULL){ inorder_display(ptr -> left); printf("%5d", ptr->data); inorder_display(ptr -> right); } } void postorder_display(struct BstNode* ptr){ if(ptr != NULL){ postorder_display(ptr -> left); postorder_display(ptr -> right); printf("%5d", ptr->data); } } void main(){ int ch, num; printf("########### MENU ###########\n\n"); for(;;){ printf("== Enter Option == \n"); printf("(option - 1) Insert\n"); printf("(option - 2) Display (in Pre-Order)\n"); printf("(option - 3) Display (in In-Order)\n"); printf("(option - 4) Display (in Post-Order)\n"); printf("(option - 5) Display Root\n"); printf("(option - 6) Exit\n"); printf("Enter Option : "); scanf("%d", &ch); switch(ch) { case 1: printf("Enter Number to Add to the Tree : "); scanf("%d", &num); root = Insert(root, num); break; case 2: printf("\nDisplaying in Pre-Order : "); preorder_display(root); break; case 3: printf("\nDisplaying in In-Order : "); inorder_display(root); break; case 4: printf("\nDisplaying in Post-Order : "); postorder_display(root); break; case 5: // printf("\nRoot is of Type : " + typeof(root) + "\n"); // printf("\nRoot : %d\n", root); printf("\nRoot value : %d\n", root->data); postorder_display(root); break; case 6: printf("\nExiting..."); break; default: printf("\n== Wrong Oprtion =="); break; } printf("\n\n"); } }
the_stack_data/329830.c
#include <stdio.h> #include <stdlib.h> int main() { //GCD of two numbers without division int a, b, n, m; printf ("Enter First Integer: "); scanf ("%d", &n); printf ("Enter Second Integer: "); scanf ("%d", &m); a = n; b = m; while (a != b) { if(a > b) { a = a - b; } if (b > a) { b = b - a; } } if (a == b) { printf ("GCD of %d and %d is = %d", n, m, a); } }
the_stack_data/386072.c
#include <stdio.h> #include <stdlib.h> #include <omp.h> main() { float *x,*y,*work1,*work2; float sum; int *index; int n,i; n=1000; x=(float*)malloc(n*sizeof(float)); y=(float*)malloc(n*sizeof(float)); work1=(float*)malloc(n*sizeof(float)); work2=(float*)malloc(n*sizeof(float)); index=(int*)malloc(n*sizeof(float)); srand((unsigned) n); for( i=0;i < n;i++) { // index[i]=(n-i)-1; index[i]=(rand() % (n/10)); x[i]=0.0; y[i]=0.0; work1[i]=i; work2[i]=i*i; } sum=0; #pragma omp parallel for shared(x,y,index,n,sum) for( i=0;i< n;i++) { #pragma omp atomic x[index[i]] += work1[i]; #pragma omp atomic sum+= work1[i]; y[i] += work2[i]; } for( i=0;i < n;i++) printf("%d %g %g\n",i,x[i],y[i]); printf("sum %g\n",sum); }
the_stack_data/92324704.c
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <limits.h> #include <sys/wait.h> #include <errno.h> #include <sys/stat.h> #include <fcntl.h> #include <ctype.h> #define MAX_INPUT_LEN 256 // Maximum input length + 2 (2 because of ending "\n" and \0) // We made a separate run-method since its used in both shell-scripting and normal shell-prompting. int run (char input[MAX_INPUT_LEN]) { char delims[] = " \t\n"; // Tokens split by space or tab character int pid; char *params[64]; char *command = strtok(input, delims); // Fetching the command from input printf("\033[0;33mCommand:\033[0m %s \t \033[0;33mParameters:\033[0m ", command); char *param = strtok(NULL, delims); // Fetching paramaters from input int i = 0; while(param != NULL) { // Iterating through paramaters if (!strcmp(param, "<") || !strcmp(param, ">")){ // End of parameters, break break; } printf("%s, ", param); params[i] = param; i++; param = strtok(NULL, delims); } printf("\n"); // Redirections char *in_file = NULL; char *out_file = NULL; int has_redirected_input = 0; int has_redirected_output = 0; if (param != NULL && strcmp(param, "<") == 0) {// Setting redirection variables for input has_redirected_input = 1; in_file = strtok(NULL, delims); param = strtok(NULL, delims); printf("\033[0;33mRedirection-file-input: \033[0m%s \n", in_file); } if (param != NULL && strcmp(param, ">") == 0) {// Setting redirection variables for output has_redirected_output = 1; out_file = strtok(NULL, delims); param = strtok(NULL, delims); printf("\033[0;33mRedirection-file-output: \033[0m%s \n", out_file); } if (param != NULL && strcmp(param, "<") == 0) {// Setting redirecting variables, not actually doing redirecting here if (has_redirected_input) { printf("Attempted to redirect input twice, exiting\n"); exit(1); } in_file = strtok(NULL, delims); param = strtok(NULL, delims); printf("\033[0;33mRedirection-file-input: \033[0m%s \n", in_file); } // TASK D - Internal Commands if (strcmp(command, "cd")==0 || strcmp(command, "CD")==0) { //internal command to change working directore if (chdir(params[0])!=0) { printf("Error CD-ing, %d\n", errno); } } else if (strcmp(command, "exit")==0 || strcmp(command, "EXIT")==0) { //internal command to exit shell printf("Exiting...\n"); exit(EXIT_SUCCESS); } //TASK B and C else { //external command -- creating child prosess for execution pid = fork(); //Creating child prosess if (pid > 0) //Parent process { wait(NULL); } else if (pid == 0) //Child process { char *argv[i + 2]; argv[0] = command; //first element of argv is always the command so that commandoes that dont have parameters work for (int c = 0; c < i; c++) { //making list argv out of parameters argv[c + 1] = params[c]; } argv[i + 1] = NULL; //last element must be NULL if (in_file != NULL) { //redirect if inputfile is given int input = open(in_file, O_RDONLY); //reading in_file with open if (input == -1) { //if return-value of open is -1 an error occured printf("Error: InputFile can not be read or doesn't exist\n"); exit(EXIT_FAILURE); } else { dup2(input, 0); //setting standard input to in_file (this is where the redirecting happens) close(input); //closing input-file } } if (out_file != NULL) { //redirect output if outputfile is given //printf("INNE HER\n"); int output = open(out_file, O_WRONLY | O_TRUNC | O_CREAT, S_IRUSR | S_IRGRP | S_IWGRP | S_IWUSR); // FLAGS FOUND HERE: http://www.cs.loyola.edu/~jglenn/702/S2005/Examples/dup2.html printf("ERROR: %d", errno); if (output == -1) { //if return-value of open is -1 an error occured printf("ERROR: Outfile cannot be opened - Showing Result in shell instead\n"); } else { dup2(output, 1); //setting standard output to out-file (this is where the redirecting happens) close(output); //closing output-file } } if (execvp(command, argv) < 0) { //executing command with given parameters (returns negative number if error has occured) printf("An error has occured. Error type: %d\n", errno); exit(EXIT_FAILURE); } } } } //main holds input in argv to support shell scripting from ubuntu int main(int argc, char *argv[]) { char *input = malloc(MAX_INPUT_LEN); if (input == NULL) { printf("No memory\n"); return 1; } char cwd[PATH_MAX]; if (argc > 1) { // Execute shell script FILE *stream; stream = fopen(argv[1], "r"); // Opening file with fopen, only for reading char *line = NULL; // Initializing line-variable size_t lenght = 0; ssize_t readline; if (stream == NULL) { printf("Error: shell script can not be read or doesn't exist\n"); exit(EXIT_FAILURE); } while ((readline = getline(&line, &lenght, stream)) != -1) {// Reading line for line from input-stream run(line); // Executing line with the shells run-method } free(line); // Deallocating memory fclose(stream); // Closing input-stream } else{ // Run shell as usual while(1) { getcwd(cwd, sizeof(cwd)); // Updating CWD printf("\033[1;31mwish:<%s>$ \033[0m", cwd); // Our shell prompt prints the current path of the shell in red. fgets(input, MAX_INPUT_LEN, stdin); // Fgets returns 0 on error TODO: error handling run(input); // Call the run-method with current input } } }
the_stack_data/148579039.c
#include "stdio.h" #include "unistd.h" #include "stdlib.h" #include "pthread.h" #include "semaphore.h" #define TRUE 1 #define NE 10 //numero de escritores #define NL 20 //numero de leitores pthread_mutex_t turno; pthread_mutex_t mutex; /* controla o acesso a 'rc' */ pthread_mutex_t db; /* controla o acesso a base de dados */ int rc = 0; /* nรบmero de processos lendo ou querendo ler */ void* reader(void *arg); void* writer(void *arg); void read_data_base(); void use_data_read(); void think_up_data(); void write_data_base(); int main() { pthread_mutex_init(&mutex, NULL); pthread_mutex_init(&db, NULL); pthread_mutex_init(&turno, NULL); pthread_t r[NL], w[NE]; int i; int *id; /* criando leitores */ for (i = 0; i < NL ; i++) { id = (int *) malloc(sizeof(int)); *id = i; pthread_create(&r[i], NULL, reader, (void *) (id)); } /* criando escritores */ for (i = 0; i< NE; i++) { id = (int *) malloc(sizeof(int)); *id = i; pthread_create(&w[i], NULL, writer, (void *) (id)); } pthread_join(r[0],NULL); return 0; } void* reader(void *arg) { int i = *((int *) arg); while(TRUE) { /* repere para sempre */ pthread_mutex_lock(&turno); pthread_mutex_lock(&mutex); /* obtรฉm acesso exclusivo ร  'rc' */ rc = rc + 1; /* um leitor a mais agora */ if (rc == 1) { /* se este for o primeiro leitor... */ pthread_mutex_lock(&db); } pthread_mutex_unlock(&mutex); /* libera o acesso exclusivo a 'rc' */ pthread_mutex_unlock(&turno); read_data_base(i); /* acesso aos dados */ pthread_mutex_lock(&mutex); /* obtรฉm acesso exclusivo a 'rc' */ rc = rc - 1; /* um leitor a menos agora */ if (rc == 0) { /* se este for o รบltimo leitor */ pthread_mutex_unlock(&db); } pthread_mutex_unlock(&mutex); /* libera o acesso exclusivo a 'rc' */ use_data_read(i); /* regiรฃo nรฃo crรญtica */ } pthread_exit(0); } void* writer(void *arg) { int i = *((int *) arg); while(TRUE) { /* repete para sempre */ think_up_data(i); /* regiรฃo nรฃo crรญtica */ pthread_mutex_lock(&turno); pthread_mutex_lock(&db); /* obtรฉm acesso exclusivo */ write_data_base(i); /* atualiza os dados */ pthread_mutex_unlock(&db); /* libera o acesso exclusivo */ pthread_mutex_unlock(&turno); } pthread_exit(0); } void read_data_base(int i) { printf("Leitor %d estรก lendo os dados! Nรบmero de leitores = %d \n", i,rc); sleep( rand() % 5); } void use_data_read(int i) { printf("Leitor %d estรก usando os dados lidos!\n", i); sleep(rand() % 5); } void think_up_data(int i) { printf("Escritor %d estรก pensando no que escrever!\n", i); sleep(rand() % 5); } void write_data_base(int i) { printf("Escritor %d estรก escrevendo os dados!\n", i); sleep( rand() % 5); }
the_stack_data/100140766.c
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/wait.h> #include <unistd.h> int main (int argc, char *argv[]) { char buffer[4096]; ssize_t nbytes; FILE *fp = fopen("/tmp/code.cbl", "w"); if (!fp) return 1; while ((nbytes = fread(buffer, sizeof(char), sizeof(buffer), stdin)) > 0) if (fwrite(buffer, sizeof(char), nbytes, fp) != nbytes) return 2; fclose(fp); pid_t pid = fork(); if (!pid) { execl("/usr/local/bin/cobc", "/usr/local/bin/cobc", "-FCx", "/tmp/code.cbl", "-o", "/tmp/code.c", NULL); perror("execl"); return 3; } int status; waitpid(pid, &status, 0); if (!WIFEXITED(status)) return 4; if (WEXITSTATUS(status)) return WEXITSTATUS(status); if (remove("/tmp/code.cbl")) { perror("remove"); return 5; } int ntcc = argc + 3; char **tcc = malloc(ntcc * sizeof(char*)); tcc[0] = "/usr/bin/tcc"; tcc[1] = "-lcob"; tcc[2] = "-run"; tcc[3] = "/tmp/code.c"; memcpy(&tcc[4], &argv[2], (argc - 2) * sizeof(char*)); tcc[ntcc - 1] = NULL; execv("/usr/bin/tcc", tcc); perror("execv"); return 6; }
the_stack_data/46895.c
/* * Copyright (c) 2016 Simon Schmidt * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #include <stdio.h> #include <unistd.h> #include <fcntl.h> typedef const char* string_t; char buffer[512]; static void blokcp(int* files,int nfiles){ int n,i; for(;;){ n = read(0,buffer,512); if(n<1)break; for(i=0;i<nfiles;++i) write(files[i],buffer,n); } } #define caseof(v,c) case v:c;break; int main(int argc,const string_t* argv){ int i=1,opt_a=0,opt_i=0,flags = O_WRONLY|O_CREAT|O_TRUNC; string_t opt; int dfiles[argc]; int nfiles=1; if(argc>1 && argv[1][0]=='-'){ opt = argv[1]+1; while(*opt) switch(*opt++){ caseof('a',opt_a=1) caseof('i',opt_i=1) } i=2; } if(opt_a) flags = O_WRONLY|O_CREAT|O_APPEND; if(opt_i) ; dfiles[0]=1; for(;i<argc;++i){ dfiles[nfiles++] = open(argv[i],flags,0644); } blokcp(dfiles,nfiles); return 0; }
the_stack_data/234517739.c
/* * Copyright (c) 2011 Apple, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ #include "strings.h" __attribute__((visibility("hidden"))) size_t _libkernel_strlcpy(char * restrict dst, const char * restrict src, size_t maxlen) { const size_t srclen = _libkernel_strlen(src); if (srclen < maxlen) { _libkernel_memmove(dst, src, srclen+1); } else if (maxlen != 0) { _libkernel_memmove(dst, src, maxlen-1); dst[maxlen-1] = '\0'; } return srclen; }
the_stack_data/721390.c
#include <stdio.h> #include <stdlib.h> char chr_legal[] = "abcdefghijklmnopqrstuvwxyz0123456789_-./"; int chr_idx[256] = {0}; char idx_chr[256] = {0}; #define FNAME 0 typedef struct trie_t *trie, trie_t; struct trie_t { trie next[sizeof(chr_legal)]; /* next letter; slot 0 is for file name */ int eow; }; trie trie_new() { return calloc(sizeof(trie_t), 1); } #define find_word(r, w) trie_trav(r, w, 1) /* tree traversal: returns node if end of word and matches string, optionally * create node if doesn't exist */ trie trie_trav(trie root, const char * str, int no_create) { int c; while (root) { if ((c = str[0]) == '\0') { if (!root->eow && no_create) return 0; break; } if (! (c = chr_idx[c]) ) { str++; continue; } if (!root->next[c]) { if (no_create) return 0; root->next[c] = trie_new(); } root = root->next[c]; str++; } return root; } /* complete traversal of whole tree, calling callback at each end of word node. * similar method can be used to free nodes, had we wanted to do that. */ int trie_all(trie root, char path[], int depth, int (*callback)(char *)) { int i; if (root->eow && !callback(path)) return 0; for (i = 1; i < sizeof(chr_legal); i++) { if (!root->next[i]) continue; path[depth] = idx_chr[i]; path[depth + 1] = '\0'; if (!trie_all(root->next[i], path, depth + 1, callback)) return 0; } return 1; } void add_index(trie root, const char *word, const char *fname) { trie x = trie_trav(root, word, 0); x->eow = 1; if (!x->next[FNAME]) x->next[FNAME] = trie_new(); x = trie_trav(x->next[FNAME], fname, 0); x->eow = 1; } int print_path(char *path) { printf(" %s", path); return 1; } /* pretend we parsed text files and got lower cased words: dealing * * with text file is a whole other animal and would make code too long */ const char *files[] = { "f1.txt", "source/f2.txt", "other_file" }; const char *text[][5] ={{ "it", "is", "what", "it", "is" }, { "what", "is", "it", 0 }, { "it", "is", "a", "banana", 0 }}; trie init_tables() { int i, j; trie root = trie_new(); for (i = 0; i < sizeof(chr_legal); i++) { chr_idx[(int)chr_legal[i]] = i + 1; idx_chr[i + 1] = chr_legal[i]; } /* Enable USE_ADVANCED_FILE_HANDLING to use advanced file handling. * You need to have files named like above files[], with words in them * like in text[][]. Case doesn't matter (told you it's advanced). */ #define USE_ADVANCED_FILE_HANDLING 0 #if USE_ADVANCED_FILE_HANDLING void read_file(const char * fname) { char cmd[1024]; char word[1024]; sprintf(cmd, "perl -p -e 'while(/(\\w+)/g) {print lc($1),\"\\n\"}' %s", fname); FILE *in = popen(cmd, "r"); while (!feof(in)) { fscanf(in, "%1000s", word); add_index(root, word, fname); } pclose(in); }; read_file("f1.txt"); read_file("source/f2.txt"); read_file("other_file"); #else for (i = 0; i < 3; i++) { for (j = 0; j < 5; j++) { if (!text[i][j]) break; add_index(root, text[i][j], files[i]); } } #endif /*USE_ADVANCED_FILE_HANDLING*/ return root; } void search_index(trie root, const char *word) { char path[1024]; printf("Search for \"%s\": ", word); trie found = find_word(root, word); if (!found) printf("not found\n"); else { trie_all(found->next[FNAME], path, 0, print_path); printf("\n"); } } int main() { trie root = init_tables(); search_index(root, "what"); search_index(root, "is"); search_index(root, "banana"); search_index(root, "boo"); return 0; }
the_stack_data/232956088.c
// RUN: %clang -target i386-unknown-unknown -faddress-sanitizer %s -S -emit-llvm -o - | FileCheck %s // RUN: %clang -O1 -target i386-unknown-unknown -faddress-sanitizer %s -S -emit-llvm -o - | FileCheck %s // RUN: %clang -O2 -target i386-unknown-unknown -faddress-sanitizer %s -S -emit-llvm -o - | FileCheck %s // RUN: %clang -O3 -target i386-unknown-unknown -faddress-sanitizer %s -S -emit-llvm -o - | FileCheck %s // RUN: %clang -target i386-unknown-unknown -fsanitize=address %s -S -emit-llvm -o - | FileCheck %s // Verify that -faddress-sanitizer invokes asan instrumentation. int foo(int *a) { return *a; } // CHECK: __asan_init
the_stack_data/101020.c
/* $OpenBSD: getoldopt.c,v 1.4 2000/01/22 20:24:51 deraadt Exp $ */ /* $NetBSD: getoldopt.c,v 1.3 1995/03/21 09:07:28 cgd Exp $ */ /* * Plug-compatible replacement for getopt() for parsing tar-like * arguments. If the first argument begins with "-", it uses getopt; * otherwise, it uses the old rules used by tar, dump, and ps. * * Written 25 August 1985 by John Gilmore (ihnp4!hoptoad!gnu) and placed * in the Pubic Domain for your edification and enjoyment. * * $FreeBSD: src/bin/pax/getoldopt.c,v 1.1.2.1 2001/08/01 05:03:11 obrien Exp $ * $DragonFly: src/bin/pax/getoldopt.c,v 1.3 2003/09/28 14:39:14 hmp Exp $ */ #include <stdio.h> #include <string.h> #include <unistd.h> int getoldopt(int argc, char **argv, char *optstring) { static char *key; /* Points to next keyletter */ static char use_getopt; /* !=0 if argv[1][0] was '-' */ char c; char *place; optarg = NULL; if (key == NULL) { /* First time */ if (argc < 2) return EOF; key = argv[1]; if (*key == '-') use_getopt++; else optind = 2; } if (use_getopt) return getopt(argc, argv, optstring); c = *key++; if (c == '\0') { key--; return EOF; } place = strchr(optstring, c); if (place == NULL || c == ':') { fprintf(stderr, "%s: unknown option %c\n", argv[0], c); return('?'); } place++; if (*place == ':') { if (optind < argc) { optarg = argv[optind]; optind++; } else { fprintf(stderr, "%s: %c argument missing\n", argv[0], c); return('?'); } } return(c); }
the_stack_data/107951964.c
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> #include <sys/stat.h> #include <sys/mman.h> #define error_en(msg) \ do { \ perror(msg); \ exit(EXIT_FAILURE); \ } while (0) #define SHM "/shm" #define SHM_SIZE 1024 int main(int argc, char *argv[]) { int fd = 0; int flags = O_RDONLY; int perms = S_IRUSR | S_IWUSR; void *addr = NULL; struct stat statbuf; fd = shm_open(SHM, flags, perms); if (fd == -1) error_en("Open shared memory failed"); if (fstat(fd, &statbuf) == -1) { perror("Get shared memory state failed"); goto exit_on_err; } addr = mmap(NULL, SHM_SIZE, PROT_READ, MAP_SHARED, fd, 0); if (addr == MAP_FAILED) { perror("Map shared memory failed"); goto exit_on_err; } if (write(STDOUT_FILENO, addr, statbuf.st_size) == -1) error_en("Write standard output failed"); printf("\n"); exit_on_err: if (close(fd) == -1) error_en("Close shared memory failed"); if (shm_unlink(SHM) == -1) error_en("Unlink shared memory failed"); return 0; }
the_stack_data/126766.c
#include <stdio.h> char lower(char c) { if (c >= 'A' && c <= 'Z') return c + ('a'-'A'); return c; } int main (int argc, char *argv[]) { char vowels[6] = { 'a', 'i', 'y', 'e', 'o', 'u' }; char consonants[20] = { 'b', 'k', 'x', 'z', 'n', 'h', 'd', 'c', 'w', 'g', 'p', 'v', 'j', 'q', 't', 's', 'r', 'l', 'm', 'f' }; int i, j; char ch; char str[101]; scanf("%c", &ch); while (!feof(stdin)) { i=0; while (ch != '\n') { if ((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z')) { for (j=0; j<6; j++) if (vowels[j] == lower(ch)) str[i] = vowels[(j+3)%6] - (vowels[j] - ch); for (j=0; j<20; j++) if (consonants[j] == lower(ch)) str[i] = consonants[(j+10)%20] - (consonants[j] - ch); } else str[i] = ch; i += 1; scanf("%c", &ch); } str[i] = '\0'; printf("%s\n", str); scanf("%c", &ch); } return 0; }
the_stack_data/129770.c
// Uses OpenMP for parallelization and enables vectorization through use // of GCC ivdep pragma // Based on the approach in Ulrich Drepper's What Every Programmer Should // Know About Memory: // https://people.freebsd.org/~lstewart/articles/cpumemory.pdf #include <errno.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/time.h> #include <unistd.h> #include <emmintrin.h> // Print message describing the error and die #define handle_error(msg) \ do { \ fprintf(stderr, "%s: %s (%s:%d)\n", (msg), strerror(errno), __FILE__, \ __LINE__); \ exit(EXIT_FAILURE); \ } while (0) // Convenience macro for indexing matrix #define IDX(N, r, c) ((N) * (r) + (c)) // Cache line size long g_linesize; // Used for tic() and toc() struct timeval g_t1, g_t2; // Simple timer function. tic() records the current time, and toc() returns // the elapsed time since the last tic() void tic() { gettimeofday(&g_t1, NULL); } // Return time since last invocation of tic() in milliseconds double toc() { double ret; gettimeofday(&g_t2, NULL); ret = (g_t2.tv_sec - g_t1.tv_sec) * 1000.0; ret += (g_t2.tv_usec - g_t1.tv_usec) / 1000.0; return ret; } // Generate random double in range [min, max] double rand_double(double min, double max) { return min + (max - min) * ((double)rand() / (double)RAND_MAX); } // Simple struct to hold a square matrix struct matrix { double *data; size_t N; }; void matrix_init(struct matrix *m, size_t N) { m->N = N; if ((m->data = malloc(N * N * sizeof(*m->data))) == NULL) { handle_error("malloc"); } } // Set every element of m to a random value in the range [-1,1] void matrix_randomize(struct matrix *m) { size_t N = m->N; for (size_t i = 0; i < N * N; ++i) { m->data[i] = rand_double(-1.0, 1.0); } } // Zero-out matrix m void matrix_zero(struct matrix *m) { size_t N = m->N; #pragma omp parallel for for (size_t i = 0; i < N * N; ++i) { m->data[i] = 0.0; } } // Naive implementation of matrix multiplication // Computes a*b and stores result in res // a, b, and res must all have the same dimension void matrix_mult_naive(struct matrix *a, struct matrix *b, struct matrix *res) { size_t N = a->N; matrix_zero(res); #pragma omp parallel for for (size_t i = 0; i < N; ++i) for (size_t j = 0; j < N; ++j) for (size_t k = 0; k < N; ++k) res->data[IDX(N, i, j)] += a->data[IDX(N, i, k)] * b->data[IDX(N, k, j)]; } // Cache-friendly implementation of matrix multiplication // Computes a*b and stores result in res // a, b, and res must all have the same dimension, and the dimension must // be a power of 2 void matrix_mult_fast(struct matrix *a, struct matrix *b, struct matrix *res) { size_t N = a->N; matrix_zero(res); size_t SM = 4 * g_linesize / sizeof(double); size_t i, j, k, i2, j2, k2; double *ra, *rb, *rres; #pragma omp parallel for for (i = 0; i < N; i += SM) { for (j = 0; j < N; j += SM) { for (k = 0; k < N; k += SM) { for (i2 = 0, rres = &res->data[IDX(N, i, j)], ra = &a->data[IDX(N, i, k)]; i2 < SM; ++i2, rres += N, ra += N) { for (k2 = 0, rb = &b->data[IDX(N, k, j)]; k2 < SM; ++k2, rb += N) { #pragma GCC ivdep for (j2 = 0; j2 < SM; ++j2) { rres[j2] += ra[k2] * rb[j2]; } } } } } } } // Return 1 if a == b, 0 otherwise int matrix_is_equal(struct matrix *a, struct matrix *b) { size_t N = a->N; if (b->N != N) { return 0; } for (size_t i = 0; i < N * N; ++i) { if (a->data[i] != b->data[i]) return 0; } return 1; } int main(int argc, char *argv[]) { if (argc != 2) { printf("Usage: %s dim\n", argv[0]); printf("DIM must be a power of 2\n"); exit(EXIT_FAILURE); } errno = 0; size_t N = strtoul(argv[1], NULL, 0); if (errno) { handle_error("atoul"); } if (N < 2 || (N & (N - 1))) { printf("DIM must be >= 2 and be a power of 2\n"); exit(EXIT_FAILURE); } printf("Matrix dimension N=%lu\n", N); //if ((g_linesize = sysconf(_SC_LEVEL1_DCACHE_LINESIZE)) == -1) { // handle_error("sysconf"); //} g_linesize = 64; printf("Cache line size: %ld\n", g_linesize); struct matrix a, b, res_naive, res_fast; printf("Preparing matrices ...\n"); tic(); matrix_init(&a, N); matrix_randomize(&a); matrix_init(&b, N); matrix_randomize(&b); matrix_init(&res_naive, N); matrix_init(&res_fast, N); printf("Done. %.3lf ms\n", toc()); printf("Performing naive multiplication ...\n"); tic(); matrix_mult_naive(&a, &b, &res_naive); printf("Done. %.3lf ms\n", toc()); printf("Performing fast multiplication ...\n"); tic(); matrix_mult_fast(&a, &b, &res_fast); printf("Done. %.3lf ms\n", toc()); printf("Verifying ...\n"); tic(); printf("%s", matrix_is_equal(&res_naive, &res_fast) ? "PASSED" : "FAILED"); printf(" %lf ms\n", toc()); return 0; }
the_stack_data/49883.c
#include <stdio.h> #include <stdbool.h> #include <stdlib.h> #include <sys/time.h> #define M 300 #define N 400 #define K 200 #define MAX_ITER 5 /* ะะฐะฟะธัะฐั‚ัŒ ะฟั€ะพะณั€ะฐะผะผัƒ ะฟะพ ะฟะตั€ะตะผะฝะพะถะตะฝะธัŽ ะผะฐั‚ั€ะธั†. ะ—ะฐะฟัƒัั‚ะธั‚ัŒ ะฟั€ะพะณั€ะฐะผะผัƒ ั ะฐะฒั‚ะพะผะฐั‚ะธั‡ะตัะบะธะผ ั€ะฐัะฟะฐั€ะฐะปะปะตะปะธะฒะฐะฝะธะตะผ ะธ ะฑะตะท ะฝะตะณะพ, ะพั†ะตะฝะธั‚ัŒ ั€ะฐะทะฝะธั†ัƒ */ int main(){ srand(0); float m1[M][N], m2[N][K], result[M][K]; float full_time = 0.; struct timeval start_s, end_s; for (int iter = 0; iter < MAX_ITER; iter++){ for (int i = 0; i < M; i++){ for (int j = 0; j < N; j++){ m1[i][j] = rand(); } } for (int i = 0; i < N; i++){ for (int j = 0; j < K; j++){ m2[i][j] = rand(); } } gettimeofday(&start_s, NULL); float sum = 0.; #pragma parallel for (int i = 0; i < M; i++){ for(int j = 0; j < K; j++){ sum = 0.; for(int k = 0; k < N; k++){ sum += m1[i][k] * m2[k][j]; } result[i][j] = sum; } } gettimeofday(&end_s, NULL); printf("%f\n", result[0][0]); full_time += ((end_s.tv_sec - start_s.tv_sec) * 1000000u + end_s.tv_usec - start_s.tv_usec) / 1.e6; } printf("time: %f sec\n", full_time / MAX_ITER); }
the_stack_data/125139319.c
#include <stdio.h> #define MAX 100 int main() { int n, aux, i, reverse, count, max; char line[MAX + 1]; scanf("%d", &n); count = max = reverse = 0; aux = n; while (aux--) { scanf("%s", line); if (!reverse) { for (i = 0; i < n; i++) { if (line[i] == 'o') { count++; } else if (line[i] == 'A') { count = 0; } if (count > max) { max = count; } } } else { for (i = n - 1; i >= 0; i--) { if (line[i] == 'o') { count++; } else if (line[i] == 'A') { count = 0; } if (count > max) { max = count; } } } reverse = !reverse; } printf("%d\n", max); return 0; }
the_stack_data/20149.c
/* Database "concert_singer" contains tables: concert singer singer_in_concert stadium */ #ifndef CONCERT_SINGER #define CONCERT_SINGER struct T_concert { double concert_id; char concert_name[15]; char theme[16]; char stadium_id[3]; // --> stadium.stadium_id char year[5]; }; struct T_singer { double singer_id; char name[13]; char country[14]; char song_name[10]; char song_release_year[5]; double age; char is_male[2]; }; struct T_singer_in_concert { double concert_id; // --> concert.concert_id char singer_id[2]; // --> singer.singer_id }; struct T_stadium { double stadium_id; char location[16]; char name[18]; double capacity; double highest; double lowest; double average; }; struct T_concert concert[] = { { 1, "Auditions", "Free choice", "1", "2014" }, { 2, "Super bootcamp", "Free choice 2", "2", "2014" }, { 3, "Home Visits", "Bleeding Love", "2", "2015" }, { 4, "Week 1", "Wide Awake", "10", "2014" }, { 5, "Week 1", "Happy Tonight", "9", "2015" }, { 6, "Week 2", "Party All Night", "7", "2015" } }; struct T_singer singer[] = { { 1, "Joe Sharp", "Netherlands", "You", "1992", 52, "F" }, { 2, "Timbaland", "United States", "Dangerous", "2008", 32, "T" }, { 3, "Justin Brown", "France", "Hey Oh", "2013", 29, "T" }, { 4, "Rose White", "France", "Sun", "2003", 41, "F" }, { 5, "John Nizinik", "France", "Gentleman", "2014", 43, "T" }, { 6, "Tribal King", "France", "Love", "2016", 25, "T" } }; struct T_singer_in_concert singer_in_concert[] = { { 1, "2" }, { 1, "3" }, { 1, "5" }, { 2, "3" }, { 2, "6" }, { 3, "5" }, { 4, "4" }, { 5, "6" }, { 5, "3" }, { 6, "2" } }; struct T_stadium stadium[] = { { 1, "Raith Rovers", "Stark's Park", 10104, 4812, 1294, 2106 }, { 2, "Ayr United", "Somerset Park", 11998, 2363, 1057, 1477 }, { 3, "East Fife", "Bayview Stadium", 2000, 1980, 533, 864 }, { 4, "Queen's Park", "Hampden Park", 52500, 1763, 466, 730 }, { 5, "Stirling Albion", "Forthbank Stadium", 3808, 1125, 404, 642 }, { 6, "Arbroath", "Gayfield Park", 4125, 921, 411, 638 }, { 7, "Alloa Athletic", "Recreation Park", 3100, 1057, 331, 637 }, { 9, "Peterhead", "Balmoor", 4000, 837, 400, 615 }, { 10, "Brechin City", "Glebe Park", 3960, 780, 315, 552 } }; #endif
the_stack_data/389064.c
/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as * applicable. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <stdio.h> /* generate a apr_table_t of 256 values, where certain characters are * marked "interesting"... for the uri parsing process. */ int main(int argc, char *argv[]) { int i; char *value; printf("/* this file is automatically generated by " "gen_uri_delims, do not edit */\n"); printf("static const unsigned char uri_delims[256] = {"); for (i = 0; i < 256; ++i) { if (i % 20 == 0) printf("\n "); switch (i) { case ':': value = "T_COLON"; break; case '/': value = "T_SLASH"; break; case '?': value = "T_QUESTION"; break; case '#': value = "T_HASH"; break; case '\0': value = "T_NUL"; break; default: value = "0"; break; } printf("%s%c", value, (i < 255) ? ',' : ' '); } printf("\n};\n"); return 0; }
the_stack_data/913317.c
#include <stdio.h> int main(int argc, char** argv, char **envp) { fprintf(stdout, "Environment variables:\n"); for(int i = 0; envp[i] != NULL; i++) { fprintf(stdout, "%s\n", envp[i]); } fprintf(stdout, "\nProgram arguments:\n"); for(int i = 0; i < argc ; i++) { fprintf(stdout, "argv[%d]: %s\n", i, argv[i]); } return 0; }
the_stack_data/696975.c
// Top-level routine for calling the Forth interpreter // Defines a few serial I/O interface functions and main() void putchar(char c) { if (c == '\n') tx('\r'); tx(c); } static int pending_char; int kbhit() { unsigned char byte; if (pending_char) { return 1; } if (dbgu_mayget(&byte)) { pending_char = byte+1; return 1; } return 0; } int getchar() { int retval; if (pending_char) { retval = pending_char-1; pending_char = 0; return retval; } return ((int)ukey()) & 0xff; } main() { void *up; init_io(); up = init_forth(); execute_word("run-tests", up); // Call the top-level application word reset(); }
the_stack_data/479365.c
#include <stdio.h> int sum(void); // ใƒ—ใƒญใƒˆใ‚ฟใ‚คใƒ—ๅฎฃ่จ€ int main(void) { sum(); // ้–ขๆ•ฐๅ‘ผใณๅ‡บใ— return 0; } int sum(void) { printf("%d\n",(1 +100) * 100 / 2); return 0; }
the_stack_data/206393989.c
// Remon Hasan #include <stdio.h> #include <math.h> #define G_ACCELERATION 9810.0 /* In mm/s^2 */ double findLandingPosition(double height, double horizonSpeed) { return horizonSpeed * sqrt(2 * height / G_ACCELERATION); } int main(void) { int numTests, poolLength, distance, height, horizonSpeed; double landingPos; scanf("%d", &numTests); while (numTests) { scanf("%d %d %d %d", &poolLength, &distance, &height, &horizonSpeed); landingPos = findLandingPosition(height, horizonSpeed); if (landingPos < distance - 500.0 || landingPos > distance + poolLength + 500.0) { printf("FLOOR\n"); } else { if (landingPos > distance + 500.0 && landingPos < distance + poolLength - 500.0) { printf("POOL\n"); } else { printf("EDGE\n"); } } numTests--; } return 0; }
the_stack_data/212644528.c
/* Copyright (C) 2001-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ #include <sys/statfs.h> #include <sys/statvfs.h> int statvfs64 (const char *file, struct statvfs64 *buf) { /* `struct statvfs64' is in fact identical to `struct statfs64' so we can simply call statfs64. */ return __statfs64 (file, (struct statfs64 *)buf); }
the_stack_data/28262071.c
#include <stdarg.h> extern void abort (void); long x, y; inline void __attribute__((always_inline)) f1i (va_list ap) { x = va_arg (ap, double); x += va_arg (ap, long); x += va_arg (ap, double); } void f1 (int i, ...) { va_list ap; va_start (ap, i); f1i (ap); va_end (ap); } inline void __attribute__((always_inline)) f2i (va_list ap) { y = va_arg (ap, int); y += va_arg (ap, long); y += va_arg (ap, double); f1i (ap); } void f2 (int i, ...) { va_list ap; va_start (ap, i); f2i (ap); va_end (ap); } long f3h (int i, long arg0, long arg1, long arg2, long arg3) { return i + arg0 + arg1 + arg2 + arg3; } long f3 (int i, ...) { long t, arg0, arg1, arg2, arg3; va_list ap; va_start (ap, i); switch (i) { case 0: t = f3h (i, 0, 0, 0, 0); break; case 1: arg0 = va_arg (ap, long); t = f3h (i, arg0, 0, 0, 0); break; case 2: arg0 = va_arg (ap, long); arg1 = va_arg (ap, long); t = f3h (i, arg0, arg1, 0, 0); break; case 3: arg0 = va_arg (ap, long); arg1 = va_arg (ap, long); arg2 = va_arg (ap, long); t = f3h (i, arg0, arg1, arg2, 0); break; case 4: arg0 = va_arg (ap, long); arg1 = va_arg (ap, long); arg2 = va_arg (ap, long); arg3 = va_arg (ap, long); t = f3h (i, arg0, arg1, arg2, arg3); break; default: abort (); } va_end (ap); return t; } void f4 (int i, ...) { va_list ap; va_start (ap, i); switch (i) { case 4: y = va_arg (ap, double); break; case 5: y = va_arg (ap, double); y += va_arg (ap, double); break; default: abort (); } f1i (ap); va_end (ap); } int main (void) { f1 (3, 16.0, 128L, 32.0); if (x != 176L) abort (); f2 (6, 5, 7L, 18.0, 19.0, 17L, 64.0); if (x != 100L || y != 30L) abort (); if (f3 (0) != 0) abort (); if (f3 (1, 18L) != 19L) abort (); if (f3 (2, 18L, 100L) != 120L) abort (); if (f3 (3, 18L, 100L, 300L) != 421L) abort (); if (f3 (4, 18L, 71L, 64L, 86L) != 243L) abort (); f4 (4, 6.0, 9.0, 16L, 18.0); if (x != 43L || y != 6L) abort (); f4 (5, 7.0, 21.0, 1.0, 17L, 126.0); if (x != 144L || y != 28L) abort (); return 0; }
the_stack_data/1227304.c
/* Exercise 1 - Calculations Write a C program to input marks of two subjects. Calculate and print the average of the two marks. */ #include <stdio.h> int main() { float mark[2]={0,0}; printf("ENTER THE MARK01 ::"); scanf("%f",&mark[0]); printf("ENTER THE MARK02 ::"); scanf("%f",&mark[1]); printf("\n\nAverage Of THE 2 marks IS::%.2f",(mark[0]+mark[1])/2); return 0; }
the_stack_data/98574046.c
#include <stdio.h> void scilab_rt_hist3d_i2d0d0s0d2_(int in00, int in01, int matrixin0[in00][in01], double scalarin0, double scalarin1, char* scalarin2, int in10, int in11, double matrixin1[in10][in11]) { int i; int j; int val0 = 0; double val1 = 0; for (i = 0; i < in00; ++i) { for (j = 0; j < in01; ++j) { val0 += matrixin0[i][j]; } } printf("%d", val0); printf("%f", scalarin0); printf("%f", scalarin1); printf("%s", scalarin2); for (i = 0; i < in10; ++i) { for (j = 0; j < in11; ++j) { val1 += matrixin1[i][j]; } } printf("%f", val1); }
the_stack_data/36075631.c
#include <stdio.h> int getint() { int x; scanf("%d", &x); return x; } int putint(int x) { printf("%d",x); } int putchar(int x); int f(int a[100], int x) { a[x] = x * x; return x; } int cp(int a[100], int b[100]) { int i; i = 0; while (i < 100) { b[i] = a[i]; i = i + 1; } } int s[100]; int main() { int a; a = getint(); a = a % 100; int i; i = 0; while (i < 100) if (i < a) i = f(s, i) + 1; else { s[i] = i; i = i + 1; } int s2[100]; cp(s, s2); i = 0; while (i < 100) { putint(s2[i]); putchar(10); i = i + 1; } return 0; }
the_stack_data/103264296.c
/* TODO: * * add UNDEFINED at end if not specified * convert POSITION -> FORWARD,POSITION * * * deal with lowercase in <Uhhhh> * * what about reorders that keep the same rule? * * remove "unused" collation elements? (probably doesn't save much) * * add_rule function ... returns index into rule table after possibly adding custom-indexed rule * but don't forget about multichar weights... replace with strings of indexes * */ #include <stddef.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdint.h> #include <stdarg.h> #include <limits.h> #include <ctype.h> #include <assert.h> #include <search.h> typedef struct { char *name; /* */ int num_weights; /* */ int ii_shift; /* */ int ti_shift; /* */ int ii_len; /* */ int ti_len; /* */ int max_weight; /* */ int num_col_base; /* */ int max_col_index; /* */ int undefined_idx; /* */ int range_low; /* */ int range_count; /* high - low */ int range_base_weight; /* */ int num_starters; /* */ int range_rule_offset; /* */ int wcs2colidt_offset; /* */ int index2weight_offset; /* */ int index2ruleidx_offset; /* */ int multistart_offset; /* */ } base_locale_t; #define BASE_LOCALE_LEN 20 static base_locale_t base_locale_array[BASE_LOCALE_LEN]; static size_t base_locale_len; typedef struct { char *name; /* */ int base_idx; /* */ int undefined_idx; /* */ int overrides_offset; /* */ int multistart_offset; /* */ } der_locale_t; #define DER_LOCALE_LEN 300 static der_locale_t der_locale_array[DER_LOCALE_LEN]; static size_t der_locale_len; #define OVERRIDE_LEN 50000 static uint16_t override_buffer[OVERRIDE_LEN]; static size_t override_len; #define MULTISTART_LEN 10000 static uint16_t multistart_buffer[MULTISTART_LEN]; static size_t multistart_len; #define WCS2COLIDT_LEN 200000 static uint16_t wcs2colidt_buffer[WCS2COLIDT_LEN]; static size_t wcs2colidt_len; #define INDEX2WEIGHT_LEN 200000 static uint16_t index2weight_buffer[INDEX2WEIGHT_LEN]; static size_t index2weight_len; static uint16_t index2ruleidx_buffer[INDEX2WEIGHT_LEN]; static size_t index2ruleidx_len; #define WEIGHTSTR_LEN 10000 static uint16_t weightstr_buffer[WEIGHTSTR_LEN]; static size_t weightstr_len; #define RULETABLE_LEN (1L<<16) static uint16_t ruletable_buffer[RULETABLE_LEN]; static size_t ruletable_len; #define RANGE (0x10000UL) typedef uint16_t tbl_item; static uint16_t u16_buf[10000]; static int u16_buf_len; static int u16_starter; typedef struct { uint16_t ii_len; uint16_t ti_len; uint16_t ut_len; unsigned char ii_shift; unsigned char ti_shift; tbl_item *ii; tbl_item *ti; tbl_item *ut; } table_data; static size_t newopt(tbl_item *ut, size_t usize, int shift, table_data *tbl); #define MAX_COLLATION_WEIGHTS 4 #define MAX_FNO 1 #define MAX_FILES (MAX_FNO + 1) static FILE *fstack[MAX_FILES]; static char *fname[MAX_FILES]; static int lineno[MAX_FILES]; static int fno = -1; static tbl_item wcs2index[RANGE]; static char linebuf[1024]; static char *pos; static char *pos_e = NULL; static char end_of_token = 0; /* slot to save */ #define IN_ORDER 0x01 #define IN_REORDER 0x02 #define IN_REORDER_SECTIONS 0x04 static int order_state; static int cur_num_weights; /* number of weights in current use */ static char cur_rule[MAX_COLLATION_WEIGHTS]; static int anonsection = 0; typedef struct ll_item_struct ll_item_t; struct ll_item_struct { ll_item_t *next; ll_item_t *prev; void *data; int data_type; int idx; }; static ll_item_t *reorder_section_ptr = NULL; static int superset; static int superset_order_start_cnt; /* only support one order for now */ static int superset_in_sync; static ll_item_t *comm_cur_ptr; static ll_item_t *comm_prev_ptr; enum { R_FORWARD = 0x01, R_POSITION = 0x02, R_BACKWARD = 0x04 /* must be largest in value */ }; typedef struct { size_t num_weights; char rule[MAX_COLLATION_WEIGHTS]; const char *colitem[MAX_COLLATION_WEIGHTS]; } weight_t; static void *root_weight = NULL; size_t unique_weights = 0; typedef struct { const char *symbol; weight_t *weight; } weighted_item_t; typedef struct { const char *symbol1; const char *symbol2; int length; weight_t *weight; } range_item_t; typedef struct { const char *name; ll_item_t *itm_list; /* weighted_item_t list .. circular!!! */ size_t num_items; size_t num_rules; char rules[MAX_COLLATION_WEIGHTS]; } section_t; static section_t *cur_section = NULL; typedef struct { const char *symbol; ll_item_t *node; } wi_index_t; typedef struct col_locale_struct col_locale_t; struct col_locale_struct { char *name; void *root_colitem; /* all base and derived, or just derived */ void *root_element; void *root_scripts; void *root_wi_index; void *root_wi_index_reordered; ll_item_t *section_list; col_locale_t *base_locale; /* null if this is a base */ void *root_derived_wi; ll_item_t *derived_list; void *root_starter_char; void *root_starter_all; ll_item_t *undefined_idx; }; typedef struct { const char *symbol; int idx; } col_index_t; static void *root_col_locale = NULL; typedef struct { const char *keyword; void (*handler)(void); } keyword_table_t; typedef struct { const char *string; const char *element; /* NULL if collating symbol */ } colitem_t; static col_locale_t *cur_base = NULL; static col_locale_t *cur_derived = NULL; static col_locale_t *cur_col = NULL; static void *root_sym = NULL; static size_t num_sym = 0; static size_t mem_sym = 0; static void error_msg(const char *fmt, ...) __attribute__ ((noreturn, format (printf, 1, 2))); static void *xmalloc(size_t n); static char *xsymdup(const char *s); /* only allocate once... store in a tree */ static void pushfile(char *filename); static void popfile(void); static void processfile(void); static int iscommentchar(int); static void eatwhitespace(void); static int next_line(void); static char *next_token(void); static void do_unrecognized(void); static col_locale_t *new_col_locale(char *name); static ll_item_t *new_ll_item(int data_type, void *data); static weight_t *register_weight(weight_t *w); static size_t ll_len(ll_item_t *l); static size_t ll_count(ll_item_t *l, int mask); static void add_wi_index(ll_item_t *l); static size_t tnumnodes(const void *root); static ll_item_t *find_wi_index(const char *sym, col_locale_t *cl); static void mark_reordered(const char *sym); static ll_item_t *find_wi_index_reordered(const char *sym); static ll_item_t *next_comm_ptr(void); static ll_item_t *init_comm_ptr(void); static ll_item_t *find_ll_last(ll_item_t *p); static void dump_weights(const char *name); static void finalize_base(void); static int is_ucode(const char *s); static int sym_cmp(const void *n1, const void *n2); static void do_starter_lists(col_locale_t *cl); static void dump_base_locale(int n); static void dump_der_locale(int n); static void dump_collate(FILE *fp); enum { DT_SECTION = 0x01, DT_WEIGHTED = 0x02, DT_REORDER = 0x04, /* a section to support reorder_after */ DT_COL_LOCALE = 0x08, DT_RANGE = 0x10, }; static section_t *new_section(const char *name) { section_t *p; char buf[128]; p = xmalloc(sizeof(section_t)); if (!name) { /* anonymous section */ name = buf; snprintf(buf, sizeof(buf), "anon%05d", anonsection); ++anonsection; } else if (*name != '<') { /* reorder */ name = buf; snprintf(buf, sizeof(buf), "%s %05d", cur_col->name, anonsection); ++anonsection; } #warning devel code /* fprintf(stderr, "section %s\n", name); */ p->name = xsymdup(name); p->itm_list = NULL; p->num_items = 0; p->num_rules = 0; memset(p->rules, 0, MAX_COLLATION_WEIGHTS); /* cur_num_weights = p->num_rules = 0; */ /* memset(p->rules, 0, MAX_COLLATION_WEIGHTS); */ /* memset(cur_rule, R_FORWARD, 4); */ #warning devel code if (*p->name == 'a') { cur_num_weights = p->num_rules = 4; memset(p->rules, R_FORWARD, 4); memset(cur_rule, R_FORWARD, 4); p->rules[3] |= R_POSITION; cur_rule[3] |= R_POSITION; } /* fprintf(stderr, "new section %s -- cur_num_weights = %d\n", p->name, cur_num_weights); */ return p; } static void do_order_start(void); static void do_order_end(void); static void do_reorder_after(void); static void do_reorder_end(void); static void do_reorder_sections_after(void); static void do_reorder_sections_end(void); static void do_copy(void); static void do_colsym(void); static void do_colele(void); static void do_script(void); static void do_range(void); static col_locale_t *new_col_locale(char *name); static int colitem_cmp(const void *n1, const void *n2); static int colelement_cmp(const void *n1, const void *n2); static void del_colitem(colitem_t *p); static colitem_t *new_colitem(char *item, char *def); static void add_colitem(char *item, char *def); static void add_script(const char *s); static unsigned int add_rule(weighted_item_t *wi); static unsigned int add_range_rule(range_item_t *ri); static const keyword_table_t keyword_table[] = { { "collating-symbol", do_colsym }, { "collating-element", do_colele }, { "script", do_script }, { "copy", do_copy }, { "order_start", do_order_start }, { "order_end", do_order_end }, { "order-end", do_order_end }, { "reorder-after", do_reorder_after }, { "reorder-end", do_reorder_end }, { "reorder-sections-after", do_reorder_sections_after }, { "reorder-sections-end", do_reorder_sections_end }, { "UCLIBC_RANGE", do_range }, { NULL, do_unrecognized } }; static void do_unrecognized(void) { #if 1 error_msg("warning: unrecognized: %s", pos); #else /* fprintf(stderr, "warning: unrecognized initial keyword \"%s\"\n", pos); */ fprintf(stderr, "warning: unrecognized: %s", pos); if (end_of_token) { fprintf(stderr, "%c%s", end_of_token, pos_e+1); } fprintf(stderr, "\n"); #endif } /* typedef struct { */ /* const char *symbol1; */ /* const char *symbol2; */ /* int length; */ /* weight_t *weight; */ /* } range_item_t; */ static void do_range(void) { range_item_t *ri; weight_t w; int i; char *s; char *s1; char *s2; const char **ci; ll_item_t *lli; assert(!superset); assert(order_state == IN_ORDER); s1 = next_token(); if (!s1) { error_msg("missing start of range"); } if (!is_ucode(s1)) { error_msg("start of range is not a ucode: %s", s1); } s1 = xsymdup(s1); s2 = next_token(); if (!s2) { error_msg("missing end of range"); } if (!is_ucode(s2)) { error_msg("end of range is not a ucode: %s", s2); } s2 = xsymdup(s2); ri = (range_item_t *) xmalloc(sizeof(range_item_t)); ri->symbol1 = s1; ri->symbol2 = s2; ri->length = strtoul(s2+2, NULL, 16) - strtoul(s1+2, NULL, 16); if (ri->length <= 0) { error_msg("illegal range length %d", ri->length); } s = next_token(); w.num_weights = cur_num_weights; for (i=0 ; i < cur_num_weights ; i++) { w.rule[i] = cur_rule[i]; } ci = w.colitem + (i-1); /* now i == cur_num_weights */ #define STR_DITTO "." while (s && *s && i) { --i; if (*s == ';') { ci[-i] = xsymdup(STR_DITTO); if (*++s) { continue; } } if (*s) { ci[-i] = xsymdup(s); } s = next_token(); if (s) { if (*s == ';') { ++s; } else if (i) { error_msg("missing seperator"); } } } if (s) { error_msg("too many weights: %d %d |%s| %d", cur_num_weights, i, s, (int)*s); } while (i) { /* missing weights are not an error */ --i; ci[-i] = xsymdup(STR_DITTO); } ri->weight = register_weight(&w); /* if ((i = is_ucode(t)) != 0) { */ /* assert(!t[i]); */ /* add_colitem(t, NULL); */ /* } */ lli = new_ll_item(DT_RANGE, ri); if (!cur_section->itm_list) { /* printf("creating new item list: %s\n", wi->symbol); */ cur_section->itm_list = lli; lli->prev = lli->next = lli; ++cur_section->num_items; } else { insque(lli, cur_section->itm_list->prev); /* printf("adding item to list: %d - %s\n", ll_len(cur_section->itm_list), wi->symbol); */ ++cur_section->num_items; } /* add_wi_index(lli); */ } static weighted_item_t *add_weight(char *t) { weighted_item_t *wi; weight_t w; int i; char *s; const char **ci; t = xsymdup(t); s = next_token(); w.num_weights = cur_num_weights; for (i=0 ; i < cur_num_weights ; i++) { w.rule[i] = cur_rule[i]; } ci = w.colitem + (i-1); /* now i == cur_num_weights */ while (s && *s && i) { --i; if (*s == ';') { ci[-i] = xsymdup(STR_DITTO); if (*++s) { continue; } } if (*s) { if (!strcmp(s,t)) { s = STR_DITTO; } ci[-i] = xsymdup(s); } s = next_token(); if (s) { if (*s == ';') { ++s; } else if (i) { error_msg("missing seperator"); } } } if (s) { error_msg("too many weights: %d %d |%s| %d", cur_num_weights, i, s, (int)*s); } while (i) { /* missing weights are not an error */ --i; ci[-i] = xsymdup(STR_DITTO); } wi = xmalloc(sizeof(weighted_item_t)); wi->symbol = t; wi->weight = register_weight(&w); if ((i = is_ucode(t)) != 0) { assert(!t[i]); add_colitem(t, NULL); } return wi; } static void add_superset_weight(char *t) { ll_item_t *lli; weighted_item_t *wi; if (!comm_cur_ptr || (strcmp(t, ((weighted_item_t *)(comm_cur_ptr->data))->symbol) != 0) ) { /* now out of sync */ if (superset_in_sync) { /* need a new section */ superset_in_sync = 0; cur_section = new_section("R"); cur_num_weights = cur_section->num_rules = ((section_t *)(cur_base->section_list->data))->num_rules; memcpy(cur_rule, ((section_t *)(cur_base->section_list->data))->rules, MAX_COLLATION_WEIGHTS); memcpy(cur_section->rules, ((section_t *)(cur_base->section_list->data))->rules, MAX_COLLATION_WEIGHTS); insque(new_ll_item(DT_REORDER, cur_section), find_ll_last(cur_col->section_list)); assert(comm_prev_ptr); lli = new_ll_item(DT_REORDER, cur_section); lli->prev = lli->next = lli; insque(lli, comm_prev_ptr); /* fprintf(stderr, " subsection -----------------------\n"); */ } /* fprintf(stderr, " %s %s\n", t, ((weighted_item_t *)(comm_cur_ptr->data))->symbol); */ wi = add_weight(t); lli = new_ll_item(DT_WEIGHTED, wi); mark_reordered(wi->symbol); /* printf("reorder: %s\n", t); */ if (!cur_section->itm_list) { cur_section->itm_list = lli; lli->prev = lli->next = lli; ++cur_section->num_items; } else { insque(lli, cur_section->itm_list->prev); ++cur_section->num_items; } add_wi_index(lli); } else { /* in sync */ superset_in_sync = 1; next_comm_ptr(); } } static void do_weight(char *t) { weighted_item_t *wi; ll_item_t *lli; if (superset) { add_superset_weight(t); return; } switch(order_state) { case 0: /* fprintf(stdout, "no-order weight: %s\n", t); */ /* break; */ case IN_ORDER: /* in a section */ /* fprintf(stdout, "weight: %s\n", t); */ wi = add_weight(t); lli = new_ll_item(DT_WEIGHTED, wi); if (!cur_section->itm_list) { /* fprintf(stdout, "creating new item list: %s %s %p\n", wi->symbol, cur_section->name, lli); */ cur_section->itm_list = lli; lli->prev = lli->next = lli; ++cur_section->num_items; } else { insque(lli, cur_section->itm_list->prev); /* fprintf(stdout, "adding item to list: %d - %s %p\n", ll_len(cur_section->itm_list), wi->symbol, lli); */ ++cur_section->num_items; } add_wi_index(lli); break; case IN_REORDER: /* std rule - but in a block with an insert-after pt */ wi = add_weight(t); lli = new_ll_item(DT_WEIGHTED, wi); mark_reordered(wi->symbol); /* fprintf(stdout, "reorder: %s %s %p\n", t, cur_section->name, lli); */ if (!cur_section->itm_list) { cur_section->itm_list = lli; lli->prev = lli->next = lli; ++cur_section->num_items; } else { insque(lli, cur_section->itm_list->prev); ++cur_section->num_items; } add_wi_index(lli); break; case IN_REORDER_SECTIONS: t = xsymdup(t); if (next_token() != NULL) { error_msg("trailing text in reorder section item: %s", pos); } lli = cur_col->section_list; do { if (lli->data_type & DT_SECTION) { if (!strcmp(((section_t *)(lli->data))->name, t)) { lli->data_type = DT_REORDER; lli = new_ll_item(DT_REORDER, (section_t *)(lli->data)); insque(lli, reorder_section_ptr); reorder_section_ptr = lli; return; } } lli = lli->next; } while (lli); error_msg("reorder_sections_after for non-base item currently not supported: %s", t); /* fprintf(stdout, "reorder_secitons: %s\n", t); */ break; default: error_msg("invalid order_state %d", order_state); } } static int col_locale_cmp(const void *n1, const void *n2) { return strcmp(((const col_locale_t *) n1)->name, ((const col_locale_t *) n2)->name); } static void processfile(void) { char *t; const keyword_table_t *k; order_state = 0; #warning devel code /* cur_num_weights = 0; */ /* cur_num_weights = 4; */ /* memset(cur_rule, R_FORWARD, 4); */ if (cur_col != cur_base) { cur_col->base_locale = cur_base; cur_col->undefined_idx = cur_base->undefined_idx; if (!cur_base->derived_list) { cur_base->derived_list = new_ll_item(DT_COL_LOCALE, cur_col); } else { insque(new_ll_item(DT_COL_LOCALE, cur_col), find_ll_last(cur_base->derived_list)); } } if (tfind(cur_col, &root_col_locale, col_locale_cmp)) { error_msg("attempt to read locale: %s", cur_col->name); } if (!tsearch(cur_col, &root_col_locale, col_locale_cmp)) { error_msg("OUT OF MEMORY!"); } if (superset) { superset_order_start_cnt = 0; superset_in_sync = 0; init_comm_ptr(); } while (next_line()) { /* printf("%5d:", lineno[fno]); */ /* while ((t = next_token()) != NULL) { */ /* printf(" |%s|", t); */ /* printf("\n"); */ /* } */ t = next_token(); assert(t); assert(t == pos); if ((*t == '<') || (!strcmp(t, "UNDEFINED"))) { do_weight(t); } else { for (k = keyword_table ; k->keyword ; k++) { if (!strcmp(k->keyword, t)) { break; } } k->handler(); } } if (cur_base == cur_col) { fprintf(stderr, "Base: %15s", cur_col->name); } else { #if 1 if (!cur_col->undefined_idx) { #if 0 if (superset) { if (superset_order_start_cnt == 1) { --superset_order_start_cnt; /* ugh.. hack this */ } } #endif /* This is an awful hack to get around the problem of unspecified UNDEFINED * definitions in the supported locales derived from iso14651_t1. */ if (!strcmp(cur_base->name, "iso14651_t1")) { fprintf(stderr, "Warning: adding UNDEFINED entry for %s\n", cur_col->name); strcpy(linebuf, "script <UNDEFINED_SECTION>\n"); pos_e = NULL; pos = linebuf; t = next_token(); assert(t); assert(t == pos); do_script(); strcpy(linebuf, "order_start <UNDEFINED_SECTION>;forward;backward;forward;forward,position\n"); pos_e = NULL; pos = linebuf; t = next_token(); assert(t); assert(t == pos); do_order_start(); strcpy(linebuf, "UNDEFINED IGNORE;IGNORE;IGNORE\n"); pos_e = NULL; pos = linebuf; t = next_token(); assert(t); assert(t == pos); do_weight(t); strcpy(linebuf, "order_end\n"); pos_e = NULL; pos = linebuf; t = next_token(); assert(t); assert(t == pos); do_order_end(); } else { error_msg("no definition of UNDEFINED for %s", cur_col->name); } } #endif fprintf(stderr, " Der: %15s", cur_col->name); } { ll_item_t *p = cur_col->section_list; fprintf(stderr, "%6u weights", tnumnodes(cur_col->root_wi_index)); if (cur_base) { fprintf(stderr, " %6u der %6u reor %6u starter - %u new stubs", tnumnodes(cur_base->root_derived_wi), tnumnodes(cur_base->root_wi_index_reordered), tnumnodes(cur_base->root_starter_char), ll_count(cur_col->section_list, DT_REORDER)); } fprintf(stderr, "\n"); #if 0 while (p) { assert(((section_t *)(p->data))->num_items == ll_len(((section_t *)(p->data))->itm_list)); if (!p->next && ((*((section_t *)(p->data))->name == 'a') && (((section_t *)(p->data))->num_items == 0)) ) { break; } if (!(p->data_type & DT_REORDER)) { if ((*((section_t *)(p->data))->name != 'a') || (((section_t *)(p->data))->num_items > 0) ) { fprintf(stderr, /* "\t%-15s %zu\n", */ "\t%-15s %6u\n", ((section_t *)(p->data))->name, ((section_t *)(p->data))->num_items); } } p = p->next; } #endif } } static void print_colnode(const void *ptr, VISIT order, int level) { const colitem_t *p = *(const colitem_t **) ptr; if (order == postorder || order == leaf) { printf("collating item = \"%s\"", p->string); if (p->element) { printf(" is %s", p->element); } printf("\n"); } } static void print_weight_node(const void *ptr, VISIT order, int level) { const weight_t *p = *(const weight_t **) ptr; int i; if (order == postorder || order == leaf) { printf("weight: (%d) ", p->num_weights); for (i = 0 ; i < p->num_weights ; i++) { if (p->rule[i] & R_FORWARD) { printf("F"); } if (p->rule[i] & R_BACKWARD) { printf("B"); } if (p->rule[i] & R_POSITION) { printf("P"); } printf(","); } for (i = 0 ; i < p->num_weights ; i++) { printf(" %s", p->colitem[i]); } printf("\n"); } } typedef struct { const char *der_name; int base_locale; } deps_t; enum { BASE_iso14651_t1, BASE_comm, BASE_cs_CZ, BASE_ar_SA, BASE_th_TH, BASE_ja_JP, BASE_ko_KR, BASE_MAX }; static const char *base_name[] = { "iso14651_t1", "comm", "cs_CZ", "ar_SA", "th_TH", "ja_JP", "ko_KR" }; static ll_item_t *locale_list[BASE_MAX]; static void init_locale_list(void) { int i; for (i=0 ; i < BASE_MAX ; i++) { locale_list[i] = (ll_item_t *) xmalloc(sizeof(ll_item_t)); locale_list[i]->prev = locale_list[i]->next = locale_list[i]; locale_list[i]->data = (void *) base_name[i]; } } deps_t deps[] = { { "af_ZA", BASE_iso14651_t1 }, { "am_ET", BASE_iso14651_t1 }, { "ar_AE", BASE_iso14651_t1 }, { "ar_BH", BASE_iso14651_t1 }, { "ar_DZ", BASE_iso14651_t1 }, { "ar_EG", BASE_iso14651_t1 }, { "ar_IN", BASE_iso14651_t1 }, { "ar_IQ", BASE_iso14651_t1 }, { "ar_JO", BASE_iso14651_t1 }, { "ar_KW", BASE_iso14651_t1 }, { "ar_LB", BASE_iso14651_t1 }, { "ar_LY", BASE_iso14651_t1 }, { "ar_MA", BASE_iso14651_t1 }, { "ar_OM", BASE_iso14651_t1 }, { "ar_QA", BASE_iso14651_t1 }, { "ar_SA", BASE_ar_SA }, { "ar_SD", BASE_iso14651_t1 }, { "ar_SY", BASE_iso14651_t1 }, { "ar_TN", BASE_iso14651_t1 }, { "ar_YE", BASE_iso14651_t1 }, { "az_AZ", BASE_iso14651_t1 }, { "be_BY", BASE_iso14651_t1 }, { "bg_BG", BASE_iso14651_t1 }, { "bn_BD", BASE_iso14651_t1 }, { "bn_IN", BASE_iso14651_t1 }, { "br_FR", BASE_iso14651_t1 }, { "bs_BA", BASE_iso14651_t1 }, { "ca_ES", BASE_comm }, { "cs_CZ", BASE_cs_CZ }, { "cy_GB", BASE_iso14651_t1 }, { "da_DK", BASE_comm }, { "de_AT", BASE_iso14651_t1 }, { "de_BE", BASE_iso14651_t1 }, { "de_CH", BASE_iso14651_t1 }, { "de_DE", BASE_iso14651_t1 }, { "de_LU", BASE_iso14651_t1 }, { "el_GR", BASE_iso14651_t1 }, { "en_AU", BASE_iso14651_t1 }, { "en_BW", BASE_iso14651_t1 }, { "en_CA", BASE_comm }, { "en_DK", BASE_iso14651_t1 }, { "en_GB", BASE_iso14651_t1 }, { "en_HK", BASE_iso14651_t1 }, { "en_IE", BASE_iso14651_t1 }, { "en_IN", BASE_iso14651_t1 }, { "en_NZ", BASE_iso14651_t1 }, { "en_PH", BASE_iso14651_t1 }, { "en_SG", BASE_iso14651_t1 }, { "en_US", BASE_iso14651_t1 }, { "en_ZA", BASE_iso14651_t1 }, { "en_ZW", BASE_iso14651_t1 }, { "eo_EO", BASE_iso14651_t1 }, { "es_AR", BASE_comm }, { "es_BO", BASE_comm }, { "es_CL", BASE_comm }, { "es_CO", BASE_comm }, { "es_CR", BASE_comm }, { "es_DO", BASE_comm }, { "es_EC", BASE_comm }, { "es_ES", BASE_comm }, { "es_GT", BASE_comm }, { "es_HN", BASE_comm }, { "es_MX", BASE_comm }, { "es_NI", BASE_comm }, { "es_PA", BASE_comm }, { "es_PE", BASE_comm }, { "es_PR", BASE_comm }, { "es_PY", BASE_comm }, { "es_SV", BASE_comm }, { "es_US", BASE_comm }, { "es_UY", BASE_comm }, { "es_VE", BASE_comm }, { "et_EE", BASE_comm }, { "eu_ES", BASE_iso14651_t1 }, { "fa_IR", BASE_iso14651_t1 }, { "fi_FI", BASE_comm }, { "fo_FO", BASE_comm }, { "fr_BE", BASE_iso14651_t1 }, { "fr_CA", BASE_comm }, { "fr_CH", BASE_iso14651_t1 }, { "fr_FR", BASE_iso14651_t1 }, { "fr_LU", BASE_iso14651_t1 }, { "ga_IE", BASE_iso14651_t1 }, { "gd_GB", BASE_iso14651_t1 }, { "gl_ES", BASE_comm }, { "gv_GB", BASE_iso14651_t1 }, { "he_IL", BASE_iso14651_t1 }, { "hi_IN", BASE_iso14651_t1 }, { "hr_HR", BASE_comm }, { "hu_HU", BASE_iso14651_t1 }, { "hy_AM", BASE_iso14651_t1 }, { "id_ID", BASE_iso14651_t1 }, { "is_IS", BASE_comm }, { "it_CH", BASE_iso14651_t1 }, { "it_IT", BASE_iso14651_t1 }, { "iw_IL", BASE_iso14651_t1 }, { "ja_JP", BASE_ja_JP }, { "ka_GE", BASE_iso14651_t1 }, { "kl_GL", BASE_comm }, { "ko_KR", BASE_ko_KR }, { "kw_GB", BASE_iso14651_t1 }, { "lt_LT", BASE_comm }, { "lv_LV", BASE_comm }, { "mi_NZ", BASE_iso14651_t1 }, { "mk_MK", BASE_iso14651_t1 }, { "mr_IN", BASE_iso14651_t1 }, { "ms_MY", BASE_iso14651_t1 }, { "mt_MT", BASE_iso14651_t1 }, { "nl_BE", BASE_iso14651_t1 }, { "nl_NL", BASE_iso14651_t1 }, { "nn_NO", BASE_iso14651_t1 }, { "no_NO", BASE_comm }, { "oc_FR", BASE_iso14651_t1 }, { "pl_PL", BASE_comm }, { "pt_BR", BASE_iso14651_t1 }, { "pt_PT", BASE_iso14651_t1 }, { "ro_RO", BASE_iso14651_t1 }, { "ru_RU", BASE_iso14651_t1 }, { "ru_UA", BASE_iso14651_t1 }, { "se_NO", BASE_iso14651_t1 }, { "sk_SK", BASE_cs_CZ }, { "sl_SI", BASE_comm }, { "sq_AL", BASE_iso14651_t1 }, { "sr_YU", BASE_iso14651_t1 }, { "sv_FI", BASE_comm }, { "sv_SE", BASE_iso14651_t1 }, { "ta_IN", BASE_iso14651_t1 }, { "te_IN", BASE_iso14651_t1 }, { "tg_TJ", BASE_iso14651_t1 }, { "th_TH", BASE_th_TH }, { "ti_ER", BASE_iso14651_t1 }, { "ti_ET", BASE_iso14651_t1 }, { "tl_PH", BASE_iso14651_t1 }, { "tr_TR", BASE_comm }, { "tt_RU", BASE_iso14651_t1 }, { "uk_UA", BASE_iso14651_t1 }, { "ur_PK", BASE_iso14651_t1 }, { "uz_UZ", BASE_iso14651_t1 }, { "vi_VN", BASE_iso14651_t1 }, { "wa_BE", BASE_iso14651_t1 }, { "yi_US", BASE_iso14651_t1 }, { "zh_CN", BASE_iso14651_t1 }, { "zh_HK", BASE_iso14651_t1 }, { "zh_SG", BASE_iso14651_t1 }, { "zh_TW", BASE_iso14651_t1 }, }; static int der_count[BASE_MAX]; static const char *new_args[500]; static int new_arg_count; static int dep_cmp(const void *s1, const void *s2) { return strcmp( (const char *) s1, ((const deps_t *) s2)->der_name); } static int old_main(int argc, char **argv); int main(int argc, char **argv) { const deps_t *p; ll_item_t *lli; int i; int total; if (argc < 2) { return EXIT_FAILURE; } init_locale_list(); while (--argc) { p = (const deps_t *) bsearch(*++argv, deps, sizeof(deps)/sizeof(deps[0]), sizeof(deps[0]), dep_cmp); if (!p) { if (!strcmp("C", *argv)) { printf("ignoring C locale\n"); continue; } else { printf("%s not found\n", *argv); return EXIT_FAILURE; } } i = p->base_locale; ++der_count[i]; if (!strcmp(base_name[i], *argv)) { /* same name as base, so skip after count incremented */ continue; } /* add it to the list. the main body will catch duplicates */ lli = (ll_item_t *) xmalloc(sizeof(ll_item_t)); lli->prev = lli->next = NULL; lli->data = (void *) *argv; insque(lli, locale_list[i]); } total = 0; for (i=0 ; i < BASE_MAX ; i++) { /* printf("der_count[%2d] = %3d\n", i, der_count[i]); */ total += der_count[i]; } /* printf("total = %d\n", total); */ new_args[new_arg_count++] = "dummyprogramname"; for (i=0 ; i < BASE_MAX ; i++) { if (!der_count[i]) { continue; } new_args[new_arg_count++] = (i == BASE_comm) ? "-c" : "-b"; lli = locale_list[i]; do { new_args[new_arg_count++] = (const char *) (lli->data); lli = lli->next; } while (lli != locale_list[i]); new_args[new_arg_count++] = "-f"; } /* for (i=0 ; i < new_arg_count ; i++) { */ /* printf("%3d: %s\n", i, new_args[i]); */ /* } */ return old_main(new_arg_count, (char **) new_args); } /* usage... prog -b basefile derived {derived} -s single {single} */ static int old_main(int argc, char **argv) { int next_is_base = 0; int next_is_subset = 0; superset = 0; while (--argc) { ++argv; if (**argv == '-') { if ((*argv)[1] == 'd') { dump_weights((*argv) + 2); } else if ((*argv)[1] == 'f') { /* dump all weight rules */ finalize_base(); } else if ((*argv)[1] == 'R') { /* dump all weight rules */ twalk(root_weight, print_weight_node); } else if (((*argv)[1] == 'c') && !(*argv)[2]) { /* new common subset */ cur_base = cur_derived = NULL; next_is_subset = 1; next_is_base = 1; superset = 0; } else if (((*argv)[1] == 'b') && !(*argv)[2]) { /* new base locale */ cur_base = cur_derived = NULL; next_is_subset = 0; next_is_base = 1; superset = 0; } else if (((*argv)[1] == 's') && !(*argv)[2]) { /* single locales follow */ cur_base = cur_derived = NULL; next_is_subset = 0; next_is_base = 2; superset = 0; } else { error_msg("unrecognized option %s", *argv); } continue; } /* new file */ new_col_locale(*argv); /* automaticly sets cur_col */ if (next_is_base) { cur_base = cur_col; } else { cur_derived = cur_col; } pushfile(*argv); /* fprintf(stderr, "processing file %s\n", *argv); */ processfile(); /* this does a popfile */ /* twalk(cur_col->root_colitem, print_colnode); */ if (next_is_base == 1) { next_is_base = 0; } if (next_is_subset) { next_is_subset = 0; superset = 1; } } fprintf(stderr, "success!\n"); fprintf(stderr, /* "num_sym=%zu mem_sym=%zu unique_weights=%zu\n", */ "num_sym=%u mem_sym=%u unique_weights=%u\n", num_sym, mem_sym, unique_weights); /* twalk(root_weight, print_weight_node); */ fprintf(stderr, "num base locales = %d num derived locales = %d\n", base_locale_len, der_locale_len); fprintf(stderr, "override_len = %d multistart_len = %d weightstr_len = %d\n" "wcs2colidt_len = %d index2weight_len = %d index2ruleidx_len = %d\n" "ruletable_len = %d\n" "total size is %d bytes or %d kB\n", override_len, multistart_len, weightstr_len, wcs2colidt_len, index2weight_len, index2ruleidx_len, ruletable_len, #warning mult by 2 for rule indecies (override_len + multistart_len + weightstr_len + wcs2colidt_len + index2weight_len + index2ruleidx_len + ruletable_len) * 2, (override_len + multistart_len + weightstr_len + wcs2colidt_len + index2weight_len + index2ruleidx_len + ruletable_len + 511) / 512); #if 0 { int i; for (i=0 ; i < base_locale_len ; i++) { dump_base_locale(i); } for (i=0 ; i < der_locale_len ; i++) { dump_der_locale(i); } } #endif { FILE *fp = fopen("locale_collate.h", "w"); if (!fp) { error_msg("couldn't open output file!"); } dump_collate(fp); if (ferror(fp) || fclose(fp)) { error_msg("write error or close error for output file!\n"); } } return EXIT_SUCCESS; } static void error_msg(const char *fmt, ...) { va_list arg; fprintf(stderr, "Error: "); if (fno >= 0) { fprintf(stderr, "file %s (%d): ", fname[fno], lineno[fno]); } va_start(arg, fmt); vfprintf(stderr, fmt, arg); va_end(arg); fprintf(stderr, "\n"); exit(EXIT_FAILURE); } static void pushfile(char *filename) { static char fbuf[PATH_MAX]; snprintf(fbuf, PATH_MAX, "collation/%s", filename); if (fno >= MAX_FNO) { error_msg("file stack size exceeded"); } if (!(fstack[++fno] = fopen(fbuf, "r"))) { --fno; /* oops */ error_msg("cannot open file %s", fbuf); } fname[fno] = xsymdup(filename); lineno[fno] = 0; } static void popfile(void) { if (fno < 0) { error_msg("pop on empty file stack"); } /* free(fname[fno]); */ fclose(fstack[fno]); --fno; } static void eatwhitespace(void) { while (isspace(*pos)) { ++pos; } } static int iscommentchar(int c) { return ((c == '#') || (c == '%')); } static int next_line(void) { size_t n; char *s = linebuf; assert(fno >= 0); pos_e = NULL; do { if (fgets(s, sizeof(linebuf), fstack[fno]) != NULL) { ++lineno[fno]; n = strlen(linebuf); if ((n == sizeof(linebuf) - 1) && (linebuf[n-1] != '\n')) { /* Either line is too long or last line is very long with * no trailing newline. But we'll always treat it as an * errro. */ error_msg("line too long?"); } --n; /* Be careful... last line doesn't need a newline. */ if (linebuf[n] == '\n') { linebuf[n--] = 0; /* trim trailing newline */ } pos = linebuf; eatwhitespace(); if (*pos && !iscommentchar(*pos)) { /* not empty or comment line */ return 1; /* got a line */ } } else { /* eof */ popfile(); } } while (fno >= 0); return 0; } static char *next_token(void) { char *p; #if 0 if (pos_e == NULL) { return NULL pos = pos_e; *pos = end_of_token; end_of_token = 0; } #else if (pos_e != NULL) { pos = pos_e; *pos = end_of_token; end_of_token = 0; } #endif eatwhitespace(); p = pos; if (!*p || iscommentchar(*p)) { /* end of line or start of comment */ pos = pos_e = NULL; *p = 0; /* treat comment as end of line */ /* fprintf(stdout, "returning NUL token |%s|\n", pos); */ return NULL; #if 1 } else if (*p == '<') { /* collating symbol, element, or value */ while (*++p) { if ((*p == '/') && p[1]) { ++p; continue; } if (*p == '>') { pos_e = ++p; end_of_token = *p; *p = 0; /* fprintf(stdout, "returning col token |%s|\n", pos); */ return pos; } } } else if (*p == '"') { /* collating element value? */ while (*++p) { if (*p == '"') { /* found the end of the quoted string */ pos_e = ++p; end_of_token = *p; *p = 0; /* fprintf(stdout, "returning quote token |%s|\n", pos); */ return pos; } } #endif } else { /* some kind of keyword */ while (*++p) { if (isspace(*p) || (*p == ';')) { break; } } pos_e = p; end_of_token = *p; *p = 0; /* fprintf(stdout, "returning key token |%s|\n", pos); */ return pos; } error_msg("illegal token |%s|", pos); } static void *xmalloc(size_t n) { void *p; if (!(p = malloc(n))) { error_msg("OUT OF MEMORY"); } return p; } static void do_copy(void) { char *s; char *e; if ((s = next_token()) != NULL) { e = strchr(s + 1, '"'); if ((*s == '"') && e && (*e == '"') && !e[1]) { if (next_token() != NULL) { error_msg("illegal trailing text: %s", pos); } *e = 0; ++s; if (cur_base && !strcmp(cur_base->name,s)) { /* fprintf(stderr, "skipping copy of base file %s\n", s); */ #warning need to update last in order and position or check return; } /* fprintf(stderr, "full copy of %s\n", s); */ pushfile(s); return; } } error_msg("illegal or missing arg for copy: %s", s); } static void do_colsym(void) { char *s; char *e; if ((s = next_token()) != NULL) { e = strrchr(s,'>'); if ((*s == '<') && e && (*e == '>') && !e[1]) { if (next_token() != NULL) { error_msg("illegal trailing text: %s", pos); } e[1] = 0; /* cleanup in case next_token stored something */ add_colitem(s,NULL); return; } } error_msg("illegal or missing arg for collating-symbol: %s", s); } static void do_colele(void) { char *s; char *e; char *s1; char *e1; int n; if ((s = next_token()) != NULL) { e = strrchr(s,'>'); if ((*s == '<') && e && (*e == '>') && !e[1]) { if (((s1 = next_token()) == NULL) || (strcmp(s1,"from") != 0) || ((s1 = next_token()) == NULL) || (*s1 != '\"') ) { error_msg("illegal format for collating-element spec"); } e1 = strchr(s1 + 1, '"'); if ((*s1 != '"') || !e1 || (*e1 != '"') || (e1[1] != 0)) { error_msg("illegal definition for collating-element: %s", s1); } if (next_token() != NULL) { error_msg("illegal trailing text: %s", pos); } e[1] = 0; /* cleanup in case next_token stored something */ e1[1] = 0; add_colitem(s,s1); ++s1; if (!(n = is_ucode(s1))) { error_msg("starting char must be a <U####> code: %s", s1); } assert(s1[n] == '<'); s1[n] = 0; s = xsymdup(s1); if (!(tsearch(s, &cur_base->root_starter_char, sym_cmp))) { error_msg("OUT OF MEMORY"); } return; } } error_msg("illegal or missing arg for collating-element: %s", s); } static ll_item_t *find_section_list_item(const char *name, col_locale_t *loc) { ll_item_t *p; if (!loc) { return NULL; } p = loc->section_list; while (p) { #warning devel code /* if (!((p->data_type == DT_SECTION) || (p->data_type == DT_REORDER))) { */ /* fprintf(stderr, "fsli = %d\n", p->data_type); */ /* } */ assert((p->data_type == DT_SECTION) || (p->data_type == DT_REORDER)); if (!strcmp(name, ((section_t *)(p->data))->name)) { break; } p = p->next; } return p; } static ll_item_t *find_ll_last(ll_item_t *p) { assert(p); while (p->next) { p = p->next; } return p; } static void do_script(void) { char *s; char *e; if ((s = next_token()) != NULL) { e = strrchr(s,'>'); if ((*s == '<') && e && (*e == '>') && !e[1]) { if (next_token() != NULL) { error_msg("illegal trailing text: %s", pos); } e[1] = 0; /* cleanup in case next_token stored something */ add_script(s); return; } } error_msg("illegal or missing arg for script: %s", s); } static col_locale_t *new_col_locale(char *name) { ll_item_t *lli; ll_item_t *lli2; cur_col = (col_locale_t *) xmalloc(sizeof(col_locale_t)); cur_col->name = name; cur_col->root_colitem = NULL; cur_col->root_element = NULL; cur_col->root_scripts = NULL; cur_col->base_locale = NULL; if (!superset) { /* start with an anonymous section */ cur_section = new_section(NULL); cur_col->section_list = new_ll_item(DT_SECTION, cur_section); } else { /* start with a reorder section */ cur_section = new_section("R"); cur_num_weights = cur_section->num_rules = ((section_t *)(cur_base->section_list->data))->num_rules; memcpy(cur_rule, ((section_t *)(cur_base->section_list->data))->rules, MAX_COLLATION_WEIGHTS); memcpy(cur_section->rules, ((section_t *)(cur_base->section_list->data))->rules, MAX_COLLATION_WEIGHTS); cur_col->section_list = new_ll_item(DT_REORDER, cur_section); assert(cur_base->section_list->next == NULL); /* currently only one section allowed */ lli = ((section_t *)(cur_base->section_list->data))->itm_list; assert(lli); lli2 = new_ll_item(DT_REORDER, cur_section); lli2->prev = lli2->next = lli2; insque(lli2, lli->prev); ((section_t *)(cur_base->section_list->data))->itm_list = lli2; } /* cur_col->section_list = NULL; */ /* add_script(((section_t *)(cur_col->section_list->data))->name); */ cur_col->root_wi_index = NULL; cur_col->root_wi_index_reordered = NULL; cur_col->root_derived_wi = NULL; cur_col->derived_list = NULL; cur_col->root_starter_char = NULL; cur_col->root_starter_all = NULL; cur_col->undefined_idx = NULL; return cur_col; } static int colitem_cmp(const void *n1, const void *n2) { return strcmp(((colitem_t *)n1)->string, ((colitem_t *)n2)->string); } static int colelement_cmp(const void *n1, const void *n2) { int r; r = strcmp(((colitem_t *)n1)->string, ((colitem_t *)n2)->string); if (!r) { if (((colitem_t *)n1)->element && ((colitem_t *)n2)->element) { r = strcmp(((colitem_t *)n1)->element, ((colitem_t *)n2)->element); } else if (((colitem_t *)n1)->element == ((colitem_t *)n2)->element) { r = 0; /* both null */ } else { r = (((colitem_t *)n1)->element == NULL) ? -1 : 1; } } return r; } static void del_colitem(colitem_t *p) { /* free((void *) p->element); */ /* free((void *) p->string); */ free(p); } static colitem_t *new_colitem(char *item, char *def) { colitem_t *p; p = xmalloc(sizeof(colitem_t)); p->string = xsymdup(item); p->element = (!def) ? def : xsymdup(def); return p; } static void add_colitem(char *item, char *def) { colitem_t *p; #if 0 printf("adding collation item %s", item); if (def) { printf(" with definition %s", def); } printf("\n"); #endif p = new_colitem(item, def); #warning devel code if (superset) { if (tfind(p, &cur_base->root_colitem, colitem_cmp)) { /* fprintf(stderr, "skipping superset duplicate collating item \"%s\"\n", p->string); */ del_colitem(p); return; /* } else { */ /* fprintf(stderr, "superset: new collating item \"%s\" = %s\n", p->string, p->element); */ } } if (cur_col == cur_derived) { if (!tfind(p, &cur_base->root_colitem, colitem_cmp)) { /* not in current but could be in base */ if (!tsearch(p, &cur_base->root_colitem, colitem_cmp)) { error_msg("OUT OF MEMORY!"); } } else if (!tfind(p, &cur_base->root_colitem, colelement_cmp)) { error_msg("collating element/symbol mismatch: item=%s def=%s", item, def); } } if (!tfind(p, &cur_col->root_colitem, colitem_cmp)) { /* not in current but could be in base */ if (!tsearch(p, &cur_col->root_colitem, colitem_cmp)) { error_msg("OUT OF MEMORY!"); } } else if (!tfind(p, &cur_col->root_colitem, colelement_cmp)) { error_msg("collating element/symbol mismatch"); } else { /* already there */ fprintf(stderr, "duplicate collating item \"%s\"\n", p->string); del_colitem(p); } } /* add a script (section) to the current locale */ static void add_script(const char *s) { ll_item_t *l; /* make sure it isn't in base if working with derived */ if (cur_base != cur_col) { if (find_section_list_item(s, cur_base)) { error_msg("attempt to add script %s for derived when already in base", s); } } if (find_section_list_item(s, cur_col)) { error_msg("attempt to readd script %s", s); } l = find_ll_last(cur_col->section_list); insque(new_ll_item(DT_SECTION, new_section(s)), l); } static const char str_forward[] = "forward"; static const char str_backward[] = "backward"; static const char str_position[] = "position"; static void do_order_start(void) { const char *s; char *e; ll_item_t *l; section_t *sect; int rule; if (order_state & ~IN_ORDER) { error_msg("order_start following reorder{_sections}_after"); } order_state |= IN_ORDER; if (superset) { if (++superset_order_start_cnt > 1) { error_msg("currently only a common order_start is supported in superset"); } return; } if (!(s = next_token())) { s = str_forward; /* if no args */ } if (*s == '<') { /* section (script) */ e = strrchr(s,'>'); if ((*s == '<') && e && (*e == '>') && !e[1]) { e[1] = 0; /* cleanup in case next_token stored something */ if (!(l = find_section_list_item(s, cur_col))) { error_msg("ref of undefined sections: %s", s); } sect = (section_t *)(l->data); if (sect->num_rules) { error_msg("sections already defined: %s", s); } } else { error_msg("illegal section ref: %s", s); } if (!(s = next_token())) { s = str_forward; /* if no args */ } else if (*s != ';') { error_msg("missing seperator!"); } } else { /* need an anonymous section */ if ((*cur_section->name != '<') && (cur_section->num_items == 0)) { /* already in an empty anonymous section */ sect = cur_section; /* fprintf(stdout, "using empty anon section %s\n", sect->name); */ } else { sect = new_section(NULL); l = find_ll_last(cur_col->section_list); insque(new_ll_item(DT_SECTION, sect), l); /* fprintf(stdout, "adding order section after section %s\n", ((section_t *)(l->data))->name); */ /* fprintf(stdout, " last section is %s\n", ((section_t *)(l->next->data))->name); */ } sect->num_rules = 0; /* setting this below so nix default */ } cur_section = sect; /* fprintf(stdout, "cur_section now %s\n", cur_section->name); */ #warning need to add section to weight list? /* now do rules */ do { rule = 0; if (*s == ';') { ++s; } while (*s) { if (!strncmp(str_forward, s, 7)) { rule |= R_FORWARD; s += 7; } else if (!strncmp(str_backward, s, 8)) { rule |= R_BACKWARD; s += 8; } else if (!strncmp(str_position, s, 8)) { rule |= R_POSITION; s += 8; } if (*s == ',') { ++s; continue; } if (!*s || (*s == ';')) { if (sect->num_rules >= MAX_COLLATION_WEIGHTS) { error_msg("more than %d weight rules!", MAX_COLLATION_WEIGHTS); } if (!rule) { error_msg("missing weight rule!"); } if ((rule & (R_FORWARD|R_BACKWARD|R_POSITION)) > R_BACKWARD) { error_msg("backward paired with forward and/or position!"); } sect->rules[sect->num_rules++] = rule; rule = 0; continue; } error_msg("illegal weight rule: %s", s); } } while ((s = next_token()) != NULL); cur_section = sect; /* fprintf(stderr, "setting cur_num_weights to %d for %s\n", sect->num_rules, sect->name); */ cur_num_weights = sect->num_rules; memcpy(cur_rule, sect->rules, MAX_COLLATION_WEIGHTS); } static void do_order_end(void) { if (!(order_state & IN_ORDER)) { error_msg("order_end with no matching order_start"); } order_state &= ~IN_ORDER; cur_section = new_section(NULL); } static void do_reorder_after(void) { char *t; ll_item_t *lli; const weight_t *w; int save_cur_num_weights; char save_cur_rule[MAX_COLLATION_WEIGHTS]; if (order_state & ~IN_REORDER) { error_msg("reorder_after following order_start or reorder_sections_after"); } order_state |= IN_REORDER; if (superset) { error_msg("currently reorder_after is not supported in supersets"); } #warning have to use rule for current section!!! if (!(t = next_token())) { error_msg("missing arg for reorder_after"); } t = xsymdup(t); if (next_token() != NULL) { error_msg("trailing text reorder_after: %s", pos); } if (cur_col == cur_base) { error_msg("sorry.. reorder_after in base locale is not currently supported"); } if (!(lli = find_wi_index(t, cur_base))) { error_msg("reorder_after for non-base item currently not supported: %s", t); } w = ((weighted_item_t *)(lli->data))->weight; save_cur_num_weights = cur_num_weights; memcpy(save_cur_rule, cur_rule, MAX_COLLATION_WEIGHTS); cur_section = new_section("R"); insque(new_ll_item(DT_REORDER, cur_section), lli); #if 0 { ll_item_t *l1; ll_item_t *l2; ll_item_t *l3; l1 = new_ll_item(DT_REORDER, cur_section); l2 = find_ll_last(cur_col->section_list); insque(l1, l2); l3 = find_ll_last(cur_col->section_list); fprintf(stderr, "reorder_after %p %p %p %s\n", l1, l2, l3, cur_section->name); } #else insque(new_ll_item(DT_REORDER, cur_section), find_ll_last(cur_col->section_list)); #endif cur_num_weights = cur_section->num_rules = save_cur_num_weights; memcpy(cur_rule, save_cur_rule, MAX_COLLATION_WEIGHTS); memcpy(cur_section->rules, save_cur_rule, MAX_COLLATION_WEIGHTS); #warning devel code /* fprintf(stderr, "reorder -- %s %d\n", ((weighted_item_t *)(lli->data))->symbol, w->num_weights); */ #warning hack to get around hu_HU reorder-after problem /* if (!w->num_weights) { */ /* } else { */ /* cur_num_weights = w->num_weights; */ /* memcpy(cur_rule, w->rule, MAX_COLLATION_WEIGHTS); */ /* } */ /* fprintf(stderr, "reorder_after succeeded for %s\n", t); */ } static void do_reorder_end(void) { if (!(order_state & IN_REORDER)) { error_msg("reorder_end with no matching reorder_after"); } order_state &= ~IN_REORDER; } static void do_reorder_sections_after(void) { const char *t; ll_item_t *lli; if (order_state & ~IN_REORDER_SECTIONS) { error_msg("reorder_sections_after following order_start or reorder_after"); } order_state |= IN_REORDER_SECTIONS; if (superset) { error_msg("currently reorder_sections_after is not supported in supersets"); } if (!(t = next_token())) { error_msg("missing arg for reorder_sections_after"); } t = xsymdup(t); if (next_token() != NULL) { error_msg("trailing text reorder_sections_after: %s", pos); } if (cur_col == cur_base) { error_msg("sorry.. reorder_sections_after in base locale is not currently supported"); } lli = cur_base->section_list; do { /* fprintf(stderr, "hmm -- |%s|%d|\n", ((section_t *)(lli->data))->name, lli->data_type); */ if (lli->data_type & DT_SECTION) { /* fprintf(stderr, "checking |%s|%s|\n", ((section_t *)(lli->data))->name, t); */ if (!strcmp(((section_t *)(lli->data))->name, t)) { reorder_section_ptr = lli; return; } } lli = lli->next; } while (lli); error_msg("reorder_sections_after for non-base item currently not supported: %s", t); } static void do_reorder_sections_end(void) { if (!(order_state & IN_REORDER_SECTIONS)) { error_msg("reorder_sections_end with no matching reorder_sections_after"); } order_state &= ~IN_REORDER_SECTIONS; reorder_section_ptr = NULL; } static ll_item_t *new_ll_item(int data_type, void *data) { ll_item_t *p; p = xmalloc(sizeof(ll_item_t)); p->next = p->prev = NULL; p->data_type = data_type; p->data = data; p->idx = INT_MIN; return p; } static int sym_cmp(const void *n1, const void *n2) { /* fprintf(stderr, "sym_cmp: |%s| |%s|\n", (const char *)n1, (const char *)n2); */ return strcmp((const char *) n1, (const char *) n2); } static char *xsymdup(const char *s) { void *p; if (!(p = tfind(s, &root_sym, sym_cmp))) { /* not a currently known symbol */ if (!(s = strdup(s)) || !(p = tsearch(s, &root_sym, sym_cmp))) { error_msg("OUT OF MEMORY!"); } ++num_sym; mem_sym += strlen(s) + 1; /* fprintf(stderr, "xsymdup: alloc |%s| %p |%s| %p\n", *(char **)p, p, s, s); */ /* } else { */ /* fprintf(stderr, "xsymdup: found |%s| %p\n", *(char **)p, p); */ } return *(char **) p; } static int weight_cmp(const void *n1, const void *n2) { const weight_t *w1 = (const weight_t *) n1; const weight_t *w2 = (const weight_t *) n2; int i, r; if (w1->num_weights != w2->num_weights) { return w1->num_weights - w2->num_weights; } for (i=0 ; i < w1->num_weights ; i++) { if (w1->rule[i] != w2->rule[i]) { return w1->rule[i] - w2->rule[i]; } if ((r = strcmp(w1->colitem[i], w2->colitem[i])) != 0) { return r; } } return 0; } static weight_t *register_weight(weight_t *w) { void *p; if (!(p = tfind(w, &root_weight, weight_cmp))) { /* new weight */ p = xmalloc(sizeof(weight_t)); memcpy(p, w, sizeof(weight_t)); if (!(p = tsearch(p, &root_weight, weight_cmp))) { error_msg("OUT OF MEMORY!"); } ++unique_weights; /* } else { */ /* fprintf(stderr, "rw: found\n"); */ } return *(weight_t **)p; } static size_t ll_len(ll_item_t *l) { size_t n = 0; ll_item_t *p = l; while (p) { ++n; p = p->next; if (p == l) { /* work for circular too */ break; } } return n; } static size_t ll_count(ll_item_t *l, int mask) { size_t n = 0; ll_item_t *p = l; while (p) { if (p->data_type & mask) { ++n; } p = p->next; if (p == l) { /* work for circular too */ break; } } return n; } static int wi_index_cmp(const void *n1, const void *n2) { const char *s1 = ((weighted_item_t *)(((ll_item_t *) n1)->data))->symbol; const char *s2 = ((weighted_item_t *)(((ll_item_t *) n2)->data))->symbol; return strcmp(s1, s2); } static void add_wi_index(ll_item_t *l) { assert(l->data_type == DT_WEIGHTED); if (!strcmp(((weighted_item_t *)(l->data))->symbol, "UNDEFINED")) { cur_col->undefined_idx = l; } if (!tfind(l, &cur_col->root_wi_index, wi_index_cmp)) { /* new wi_index */ if (!tsearch(l, &cur_col->root_wi_index, wi_index_cmp)) { error_msg("OUT OF MEMORY!"); } } if (cur_base != cur_col) { if (!tfind(l, &cur_base->root_wi_index, wi_index_cmp)) {/* not a base val */ /* printf("derived: %s\n", ((weighted_item_t *)(l->data))->symbol); */ if (!tfind(l, &cur_base->root_derived_wi, wi_index_cmp)) { /* new derived */ if (!tsearch(l, &cur_base->root_derived_wi, wi_index_cmp)) { error_msg("OUT OF MEMORY!"); } } } } } static int final_index; static int is_ucode(const char *s) { if ((s[0] == '<') && (s[1] == 'U') && isxdigit(s[2]) && isxdigit(s[3]) && isxdigit(s[4]) && isxdigit(s[5]) && (s[6] == '>') ) { return 7; } else { return 0; } } static void add_final_col_index(const char *s) { ENTRY e; e.key = (char *) s; e.data = (void *)(final_index); if (!hsearch(e, FIND)) { /* not in the table */ if (!hsearch(e, ENTER)) { error_msg("OUT OF MEMORY! (hsearch)"); } #if 0 { int n; void *v; colitem_t ci; colitem_t *p; const char *t; if (!strcmp(s, "UNDEFINED")) { printf("%6d: %s\n", final_index, s); } else { assert(*s == '<'); if ((n = is_ucode(s)) != 0) { assert(!s[n]); printf("%6d: %s\n", final_index, s); } else { ci.string = (char *) s; ci.element = NULL; /* don't care */ v = tfind(&ci, &cur_base->root_colitem, colitem_cmp); if (!v) { fprintf(stderr, "%s NOT DEFINED!!!\n", s); } else { p = *((colitem_t **) v); if (p->element != NULL) { t = p->element; assert(*t == '"'); ++t; n = is_ucode(t); assert(n); printf("%6d: %.*s | ", final_index, n, t); do { t += n; assert(*t); if (*t == '"') { assert(!t[1]); break; } n = is_ucode(t); assert(n); printf("%.*s", n, t); } while (1); printf(" collating-element %s\n", s); } else { printf("%6d: %s (collating-symbol)\n", final_index, s); } } } } } #endif ++final_index; } } static int final_index_val0(const char *s) { ENTRY *p; ENTRY e; e.key = (char *) s; if (!(p = hsearch(e, FIND))) { /* not in the table */ return 0; } return (int)(p->data); } static int final_index_val(const char *s) { ENTRY *p; ENTRY e; e.key = (char *) s; if (!(p = hsearch(e, FIND))) { /* not in the table */ error_msg("can't find final index: %s", s); } return (int)(p->data); } static size_t num_tree_nodes; static void count_nodes(const void *ptr, VISIT order, int level) { if ((order == postorder) || (order == leaf)) { ++num_tree_nodes; } } static size_t tnumnodes(const void *root) { num_tree_nodes = 0; twalk(root, count_nodes); return num_tree_nodes; } static ll_item_t *find_wi_index(const char *sym, col_locale_t *cl) { weighted_item_t w; ll_item_t l; void *p; w.symbol = sym; l.data = &w; l.data_type = DT_WEIGHTED; p = tfind(&l, &cl->root_wi_index, wi_index_cmp); if (p) { p = *(ll_item_t **)p; } return (ll_item_t *) p; } static void mark_reordered(const char *sym) { ll_item_t *lli; lli = find_wi_index(sym, cur_base); if (lli) { if (!tsearch(lli, &cur_base->root_wi_index_reordered, wi_index_cmp)) { error_msg("OUT OF MEMORY!"); } } } static ll_item_t *find_wi_index_reordered(const char *sym) { weighted_item_t w; ll_item_t l; void *p; w.symbol = sym; l.data = &w; l.data_type = DT_WEIGHTED; p = tfind(&l, &cur_base->root_wi_index_reordered, wi_index_cmp); if (p) { p = *(ll_item_t **)p; } return (ll_item_t *) p; } static ll_item_t *init_comm_ptr(void) { assert(cur_base); assert(cur_base->section_list); /* at the moment, only support one section in comm */ assert(cur_base->section_list->next == NULL); comm_cur_ptr = ((section_t *)(cur_base->section_list->data))->itm_list; while (comm_cur_ptr && (comm_cur_ptr->data_type & DT_REORDER)) { comm_cur_ptr = comm_cur_ptr->next; } #warning devel code /* { */ /* ll_item_t *p = comm_cur_ptr; */ /* fprintf(stderr, "init_comm_ptr\n"); */ /* while (p != comm_cur_ptr) { */ /* if (p->data_type & DT_WEIGHTED) { */ /* fprintf(stderr, "%s", ((weighted_item_t *)p)->symbol); */ /* } */ /* p = p->next; */ /* } */ /* } */ assert(comm_cur_ptr); /* fprintf(stderr, "init_comm_ptr -- %s %p %p %p %d\n", */ /* ((weighted_item_t *)(comm_cur_ptr->data))->symbol, */ /* comm_cur_ptr, comm_cur_ptr->prev, comm_cur_ptr->next, */ /* ll_len(comm_cur_ptr)); */ comm_prev_ptr = NULL; return comm_cur_ptr; } static ll_item_t *next_comm_ptr(void) { /* at the moment, only support one section in comm */ assert(cur_base->section_list->next == NULL); comm_prev_ptr = comm_cur_ptr; while (comm_cur_ptr && ((comm_cur_ptr = comm_cur_ptr->next) != NULL)) { if (!(comm_cur_ptr->data_type & DT_REORDER)) { break; } } return comm_cur_ptr; } static int dump_count; #if 0 static void dump_section(section_t *s, int mask, col_locale_t *der) { ll_item_t *lli; ll_item_t *lli0; weighted_item_t *w; weight_t *p; int i; lli0 = lli = s->itm_list; if (!lli0) { return; } do { if (!(lli->data_type & mask)) { lli = lli->next; continue; } if (lli->data_type & DT_WEIGHTED) { ++dump_count; w = (weighted_item_t *)(lli->data); p = w->weight; printf("%6d: %s (%d) ", dump_count, w->symbol, p->num_weights); for (i = 0 ; i < p->num_weights ; i++) { if (p->rule[i] & R_FORWARD) { printf("F"); } if (p->rule[i] & R_BACKWARD) { printf("B"); } if (p->rule[i] & R_POSITION) { printf("P"); } printf(","); } for (i = 0 ; i < p->num_weights ; i++) { printf(" %s", p->colitem[i]); } printf("\n"); } else if (lli->data_type & (DT_SECTION|DT_REORDER)) { if (lli->data_type == DT_REORDER) { assert(der); if (strncmp(((section_t *)(lli->data))->name, der->name, strlen(der->name))) { lli = lli->next; continue; } } if (lli->data_type & DT_SECTION) { printf("SECTION -----------------\n"); } else { printf("REORDER -----------------\n"); } dump_section((section_t *)(lli->data), mask, der); printf("DONE --------------------\n"); } lli = lli->next; } while (lli != lli0); } #else static int in_reorder_section = 0; static void dump_section(section_t *s, int mask, col_locale_t *der) { ll_item_t *lli; ll_item_t *lli0; weighted_item_t *w; weight_t *p; int i; lli0 = lli = s->itm_list; if (!lli0) { return; } do { if (!(lli->data_type & mask)) { lli = lli->next; continue; } if (lli->data_type & DT_WEIGHTED) { ++dump_count; w = (weighted_item_t *)(lli->data); p = w->weight; #if 1 if (in_reorder_section) { printf(" %p", w); } #else printf("%6d: %s (%d) ", dump_count, w->symbol, p->num_weights); for (i = 0 ; i < p->num_weights ; i++) { if (p->rule[i] & R_FORWARD) { printf("F"); } if (p->rule[i] & R_BACKWARD) { printf("B"); } if (p->rule[i] & R_POSITION) { printf("P"); } printf(","); } for (i = 0 ; i < p->num_weights ; i++) { printf(" %s", p->colitem[i]); } printf("\n"); #endif } else if (lli->data_type & (DT_SECTION|DT_REORDER)) { if (lli->data_type == DT_REORDER) { assert(der); if (strncmp(((section_t *)(lli->data))->name, der->name, strlen(der->name))) { lli = lli->next; continue; } } if (lli->data_type & DT_SECTION) { /* printf("SECTION -----------------\n"); */ assert(0); } else { /* printf("REORDER -----------------\n"); */ in_reorder_section = 1; } dump_section((section_t *)(lli->data), mask, der); /* printf("DONE --------------------\n"); */ printf("\n"); in_reorder_section = 0; } lli = lli->next; } while (lli != lli0); } #endif static void dump_weights(const char *name) { ll_item_t *lli; col_locale_t *base; col_locale_t *der; col_locale_t cl; void *p; assert(name); if (!*name) { /* use last */ base = cur_base; der = cur_derived; } else { cl.name = (char *) name; if (!(p = tfind(&cl, &root_col_locale, col_locale_cmp))) { error_msg("unknown locale: %s", name); } base = *((col_locale_t **) p); der = NULL; if (base->base_locale) { /* oops... really derived */ der = base; base = der->base_locale; } } dump_count = 0; if (base) { /* printf("BASE - %s\n", base->name); */ for (lli = base->section_list ; lli ; lli = lli->next) { /* printf("SECTION %s\n", ((section_t *)(lli->data))->name); */ dump_section((section_t *)(lli->data), ~0, der); } } assert(der != base); if (der) { /* printf("DERIVED - %s\n", der->name); */ for (lli = der->section_list ; lli ; lli = lli->next) { if (lli->data_type == DT_SECTION) { dump_section((section_t *)(lli->data), DT_WEIGHTED, der); } } } /* printf("DONE\n"); */ } static void print_starter_node(const void *ptr, VISIT order, int level) { if (order == postorder || order == leaf) { fprintf(stderr, " %s\n", *(const char **) ptr); } } static void finalize_base(void) { ll_item_t *s; ll_item_t *h; ll_item_t *lli; ll_item_t *h2; ll_item_t *l2; ll_item_t *cli; ll_item_t *rli = NULL; weighted_item_t *w; weight_t *p; int i, n, mr, r, mi; col_locale_t *cl; void *mm; int num_invariant = 0; int num_varying = 0; int max_weight; int index2weight_len_inc = 1; assert(cur_base); assert(base_locale_len+1 < BASE_LOCALE_LEN); base_locale_array[base_locale_len].name = cur_base->name; base_locale_array[base_locale_len].num_weights = 1; base_locale_array[base_locale_len].index2weight_offset = index2weight_len; base_locale_array[base_locale_len].index2ruleidx_offset = index2ruleidx_len; if (!strcmp(cur_base->name,"ja_JP") || !strcmp(cur_base->name,"ko_KR")) { #warning fix the index2weight check!! index2weight_len_inc = 0; } /* printf("%s -- index2weight_len = %d\n", cur_base->name, index2weight_len); */ if (!hcreate(30000)) { error_msg("OUT OF MEMORY!"); } /* first pass ... set the fixed indexes */ final_index = i = 1; mr = 0; for (s = cur_base->section_list ; s ; s = s->next) { #if 1 if (s->data_type & DT_REORDER) { /* a reordered section */ fprintf(stderr, "pass1: reordered section %s - xxx\n", ((section_t *)(s->data))->name); lli = ((section_t *)(s->data))->itm_list; r = 0; if (lli) { /* r = ll_len( ((section_t *)(lli->data))->itm_list ); */ r = ll_len(lli) + 1; } if (r > mr) { mr = r; } fprintf(stderr, "pass1: reordered section %s - %d\n", ((section_t *)(s->data))->name, r); continue; } #endif h = lli = ((section_t *)(s->data))->itm_list; if (!lli) { continue; } do { if (lli->data_type & DT_RANGE) { i += mr; mr = 0; #warning check ko_kR and 9 /* ++i; */ lli->idx = i; assert(!rli); rli = lli; fprintf(stderr, "range pre = %d after = ", i); i += ((range_item_t *)(lli->data))->length + 1; #warning check ko_kR and 9 /* ++i; */ fprintf(stderr, "%d\n", i); if (!index2weight_len_inc) { /* ko_KR hack */ final_index += ((range_item_t *)(lli->data))->length + 1; } /* add_final_col_index("RANGE"); */ } else if (lli->data_type & DT_WEIGHTED) { i += mr; mr = 0; w = (weighted_item_t *)(lli->data); if (find_wi_index_reordered(w->symbol)) { /* reordered symbol so skip on first pass */ ++num_varying; ++i; continue; } ++num_invariant; index2weight_buffer[index2weight_len] = lli->idx = i++; index2weight_len += index2weight_len_inc; add_final_col_index(w->symbol); } else { assert(lli->data_type & DT_REORDER); r = ll_len( ((section_t *)(lli->data))->itm_list ); #warning check ko_kR and 9 if (r > mr) { mr = r; } /* r = 0; */ } } while ((lli = lli->next) != h); } /* second pass ... set the reordered indexes */ mi = i + mr; mr = i = 0; for (s = cur_base->section_list ; s ; s = s->next) { h = lli = ((section_t *)(s->data))->itm_list; if (!lli) { continue; } do { if (lli->data_type & DT_RANGE) { i += mr; mr = 0; i = lli->idx + ((range_item_t *)(lli->data))->length + 1; #warning check } else if ((lli->data_type & DT_WEIGHTED) && !(s->data_type & DT_REORDER)) { i += mr; mr = 0; w = (weighted_item_t *)(lli->data); if (find_wi_index_reordered(w->symbol) /* reordered symbol skipped on first pass */ #if 0 || (s->data_type & DT_REORDER) /* or in a reordered section */ #endif ) { assert(!(s->data_type & DT_REORDER)); index2weight_buffer[index2weight_len] = lli->idx = ++i; index2weight_len += index2weight_len_inc; add_final_col_index(w->symbol); /* fprintf(stdout, "%11s: r %6d %6d %s\n", */ /* cur_base->name, lli->idx, final_index_val(w->symbol), w->symbol); */ continue; } i = lli->idx; /* fprintf(stdout, "%11s: w %6d %6d %s\n", */ /* cur_base->name, lli->idx, final_index_val(w->symbol), w->symbol); */ } else { /* fprintf(stderr, "section: %s %d %d\n", ((section_t *)(s->data))->name, */ /* s->data_type, lli->data_type); */ /* assert(!(s->data_type & DT_REORDER)); */ /* assert(lli->data_type & DT_REORDER); */ #if 1 if (s->data_type & DT_REORDER) { h2 = l2 = lli; if (!h2) { continue; } } else { assert(s->data_type & DT_SECTION); h2 = l2 = ((section_t *)(lli->data))->itm_list; if (!h2) { continue; } } #else h2 = l2 = ((section_t *)(lli->data))->itm_list; if (!h2) { continue; } #endif r = 0; do { assert(l2->data_type & DT_WEIGHTED); ++r; l2->idx = i + r; /* fprintf(stdout, "%s: R %6d %s\n", */ /* ((section_t *)(lli->data))->name, l2->idx, ((weighted_item_t *)(l2->data))->symbol); */ } while ((l2 = l2->next) != h2); if (r > mr) { mr = r; } } } while ((lli = lli->next) != h); } /* finally, walk through all derived locales and set non-reordered section items */ mr = mi; for (cli = cur_base->derived_list ; cli ; cli = cli->next) { cl = (col_locale_t *)(cli->data); /* fprintf(stderr, "pass3: %d %s\n", cli->data_type, cl->name); */ /* fprintf(stdout, "pass3: %d %s\n", cli->data_type, cl->name); */ assert(cli->data_type == DT_COL_LOCALE); i = mi; for (s = cl->section_list ; s ; s = s->next) { /* if (s->data_type & DT_REORDER) { */ /* continue; */ /* } */ h = lli = ((section_t *)(s->data))->itm_list; if (!lli) { continue; } do { assert(!(lli->data_type & DT_RANGE)); if (lli->data_type & DT_WEIGHTED) { /* fprintf(stderr, " %d %d %s\n", lli->data_type, lli->idx, ((weighted_item_t *)(lli->data))->symbol); */ add_final_col_index(((weighted_item_t *)(lli->data))->symbol); if (s->data_type & DT_REORDER) { continue; } assert(lli->idx == INT_MIN); lli->idx = ++i; /* fprintf(stdout, "%11s: S %6d %6d %s\n", */ /* cl->name, lli->idx, */ /* final_index_val(((weighted_item_t *)(lli->data))->symbol), */ /* ((weighted_item_t *)(lli->data))->symbol); */ } else { assert(0); assert(lli->data_type & DT_SECTION); h2 = l2 = ((section_t *)(lli->data))->itm_list; if (!h2) { continue; } do { assert(l2->data_type & DT_WEIGHTED); assert(l2->idx == INT_MIN); l2->idx = ++i; add_final_col_index(((weighted_item_t *)(l2->data))->symbol); } while ((l2 = l2->next) != h2); } } while ((lli = lli->next) != h); } if (i > mr) { mr = i; } } max_weight = mr; assert(num_varying == tnumnodes(cur_base->root_wi_index_reordered)); /* we can now initialize the wcs2index array */ { ENTRY *p; ENTRY e; char buf[8]; static const char xd[] = "0123456789ABCDEF"; int starter_index = final_index; int wcs2index_count = 0; strcpy(buf, "<U....>"); memset(wcs2index, 0, sizeof(wcs2index)); e.key = (char *) buf; for (i=1 ; i <= 0xffff ; i++) { buf[5] = xd[ i & 0xf ]; buf[4] = xd[ (i >> 4) & 0xf ]; buf[3] = xd[ (i >> 8) & 0xf ]; buf[2] = xd[ (i >> 12) & 0xf ]; if ((p = hsearch(e, FIND)) != NULL) { ++wcs2index_count; if ((tfind(buf, &cur_base->root_starter_char, sym_cmp)) != NULL) { wcs2index[i] = ++starter_index; /* fprintf(stderr, "wcs2index[ %#06x ] = %d (starter)\n", i, wcs2index[i]); */ } else { wcs2index[i] = (int)(p->data); /* fprintf(stderr, "wcs2index[ %#06x ] = %d\n", i, wcs2index[i]); */ } } else { if ((tfind(buf, &cur_base->root_starter_char, sym_cmp)) != NULL) { error_msg("marked starter but not in hash: %s", buf); } } } /* ---------------------------------------------------------------------- */ { int i, n; table_data table; size_t t, smallest; n = 0; smallest = SIZE_MAX; table.ii = NULL; for (i=0 ; i < 14 ; i++) { if ((RANGE >> i) < 4) { break; } t = newopt(wcs2index, RANGE, i, &table); if (smallest >= t) { n = i; smallest = t; /* } else { */ /* break; */ } } /* printf("smallest = %u for range %#x (%u)\n", smallest, RANGE, RANGE); */ assert(smallest != SIZE_MAX); if (smallest + wcs2colidt_len >= WCS2COLIDT_LEN) { error_msg("WCS2COLIDT_LEN too small"); } base_locale_array[base_locale_len].wcs2colidt_offset = wcs2colidt_len; table.ii = wcs2colidt_buffer + wcs2colidt_len; t = smallest; smallest = SIZE_MAX; smallest = newopt(wcs2index, RANGE, n, &table); assert(t == smallest); wcs2colidt_len += smallest; /* fprintf(stderr, "smallest = %d wcs2colidt_len = %d\n", smallest, wcs2colidt_len); */ #if 0 { unsigned int sc, n, i0, i1; unsigned int u = 0xe40; table_data *tbl = &table; #define __LOCALE_DATA_WCctype_TI_MASK ((1 << tbl->ti_shift)-1) #define __LOCALE_DATA_WCctype_TI_SHIFT (tbl->ti_shift) #define __LOCALE_DATA_WCctype_TI_LEN (tbl->ti_len) #define __LOCALE_DATA_WCctype_II_MASK ((1 << tbl->ii_shift)-1) #define __LOCALE_DATA_WCctype_II_SHIFT (tbl->ii_shift) #define __LOCALE_DATA_WCctype_II_LEN (tbl->ii_len) sc = u & __LOCALE_DATA_WCctype_TI_MASK; u >>= __LOCALE_DATA_WCctype_TI_SHIFT; n = u & __LOCALE_DATA_WCctype_II_MASK; u >>= __LOCALE_DATA_WCctype_II_SHIFT; i0 = tbl->ii[u]; fprintf(stderr, "i0 = %d\n", i0); i0 <<= __LOCALE_DATA_WCctype_II_SHIFT; i1 = tbl->ii[__LOCALE_DATA_WCctype_II_LEN + i0 + n]; /* i1 = tbl->ti[i0 + n]; */ fprintf(stderr, "i1 = %d\n", i1); i1 <<= __LOCALE_DATA_WCctype_TI_SHIFT; /* return *(uint16_t *)(&(tbl->ii[__LOCALE_DATA_WCctype_II_LEN + __LOCALE_DATA_WCctype_TI_LEN + i1 + sc])); */ fprintf(stderr, "i2 = %d\n", __LOCALE_DATA_WCctype_II_LEN + __LOCALE_DATA_WCctype_TI_LEN + i1 + sc); fprintf(stderr, "val = %d\n", tbl->ii[__LOCALE_DATA_WCctype_II_LEN + __LOCALE_DATA_WCctype_TI_LEN + i1 + sc]); /* return tbl->ut[i1 + sc]; */ } #endif base_locale_array[base_locale_len].ii_shift = table.ii_shift; base_locale_array[base_locale_len].ti_shift = table.ti_shift; base_locale_array[base_locale_len].ii_len = table.ii_len; base_locale_array[base_locale_len].ti_len = table.ti_len; } /* ---------------------------------------------------------------------- */ base_locale_array[base_locale_len].num_col_base = num_invariant + num_varying; base_locale_array[base_locale_len].max_col_index = final_index; base_locale_array[base_locale_len].max_weight = max_weight; fprintf(stderr, "%s: %6u invariant %6u varying %6u derived %6u total %6u max weight %6u wcs2\n", cur_base->name, num_invariant, num_varying, tnumnodes(cur_base->root_derived_wi), final_index, max_weight, wcs2index_count); } #if 1 /* ok, now we need to dump out the base and derived tables... */ /* don't forget to break up collating elements!!! */ /* fprintf(stdout, "**************************************************\n"); */ /* first pass ... set the invariants */ for (s = cur_base->section_list ; s ; s = s->next) { #if 1 if (s->data_type & DT_REORDER) { fprintf(stderr, "1: skipping reordered section %s\n", ((section_t *)(s->data))->name); continue; } #endif h = lli = ((section_t *)(s->data))->itm_list; if (!lli) { continue; } do { if (lli->data_type & DT_WEIGHTED) { w = (weighted_item_t *)(lli->data); if (find_wi_index_reordered(w->symbol)) { /* reordered symbol so skip on first pass */ continue; } if (index2weight_len_inc) { index2ruleidx_buffer[index2ruleidx_len++] = add_rule((weighted_item_t *)(lli->data)); } /* fprintf(stdout, "%11s: w %6d %6d %s\n", */ /* cur_base->name, lli->idx, final_index_val(w->symbol), w->symbol); */ } } while ((lli = lli->next) != h); } /* second pass ... set varying */ for (s = cur_base->section_list ; s ; s = s->next) { #if 1 if (s->data_type & DT_REORDER) { fprintf(stderr, "2: skipping reordered section %s\n", ((section_t *)(s->data))->name); continue; } #endif h = lli = ((section_t *)(s->data))->itm_list; if (!lli) { continue; } do { if (lli->data_type & DT_WEIGHTED) { w = (weighted_item_t *)(lli->data); if (find_wi_index_reordered(w->symbol)) { /* reordered symbol so skip on first pass */ if (index2weight_len_inc) { index2ruleidx_buffer[index2ruleidx_len++] = add_rule((weighted_item_t *)(lli->data)); } /* fprintf(stdout, "%11s: r %6d %6d %s\n", */ /* cur_base->name, lli->idx, final_index_val(w->symbol), w->symbol); */ continue; } } } while ((lli = lli->next) != h); } do_starter_lists(cur_base); /* fprintf(stderr,"updated final_index = %d\n", final_index); */ if (rli) { base_locale_array[base_locale_len].range_low = strtoul(((range_item_t *)(rli->data))->symbol1 + 2, NULL, 16); base_locale_array[base_locale_len].range_count = ((range_item_t *)(rli->data))->length; base_locale_array[base_locale_len].range_base_weight = rli->idx; base_locale_array[base_locale_len].range_rule_offset = add_range_rule((range_item_t *)(rli->data)); /* fprintf(stdout, "%11s: %6d %6d %s %s (%d)\n", */ /* "RANGE", rli->idx, -1, */ /* ((range_item_t *)(rli->data))->symbol1, */ /* ((range_item_t *)(rli->data))->symbol2, */ /* ((range_item_t *)(rli->data))->length); */ } /* fprintf(stdout,"\nDerived\n\n"); */ /* first, if base name is of the form ll_CC, add a derived locale for it */ if ((strlen(cur_base->name) == 5) && islower(cur_base->name[0]) && islower(cur_base->name[1]) && (cur_base->name[2] == '_') && isupper(cur_base->name[3]) && isupper(cur_base->name[4]) ) { fprintf(stderr, "adding special derived for %s\n", cur_base->name); /* fprintf(stderr,"updated final_index = %d\n", final_index); */ assert(der_locale_len+1 < DER_LOCALE_LEN); der_locale_array[der_locale_len].name = cur_base->name; der_locale_array[der_locale_len].base_idx = base_locale_len; u16_buf[0] = 1; u16_buf[1] = 0; u16_buf_len = 2; mm = NULL; if ((u16_buf_len > override_len) || !(mm = memmem(override_buffer, override_len*sizeof(override_buffer[0]), u16_buf, u16_buf_len*sizeof(u16_buf[0]))) ) { assert(override_len + u16_buf_len < OVERRIDE_LEN); memcpy(override_buffer + override_len, u16_buf, u16_buf_len*sizeof(u16_buf[0])); der_locale_array[der_locale_len].overrides_offset = override_len; override_len += u16_buf_len; /* printf("%s: override_len = %d u16_buf_len = %d\n", cl->name, override_len, u16_buf_len); */ } else if (!(u16_buf_len > override_len)) { assert(mm); der_locale_array[der_locale_len].overrides_offset = ((uint16_t *)(mm)) - override_buffer; /* printf("%s: memmem found a match with u16_buf_len = %d\n", cl->name, u16_buf_len); */ } der_locale_array[der_locale_len].multistart_offset = base_locale_array[base_locale_len].multistart_offset; der_locale_array[der_locale_len].undefined_idx = final_index_val0("UNDEFINED"); if (!der_locale_array[der_locale_len].undefined_idx) { error_msg("no UNDEFINED definition for %s", cur_base->name); } ++der_locale_len; } else { fprintf(stderr, "NOT adding special derived for %s\n", cur_base->name); } /* now all the derived... */ for (cli = cur_base->derived_list ; cli ; cli = cli->next) { cl = (col_locale_t *)(cli->data); assert(cli->data_type == DT_COL_LOCALE); assert(der_locale_len+1 < DER_LOCALE_LEN); der_locale_array[der_locale_len].name = cl->name; der_locale_array[der_locale_len].base_idx = base_locale_len; u16_buf_len = 0; for (i = 0 ; i < 2 ; i++) { if (i) { /* fprintf(stdout, " section --- (singles)\n"); */ u16_buf[u16_buf_len++] = 1; /* single */ } /* we do this in two passes... first all sequences, then all single reorders */ for (s = cl->section_list ; s ; s = s->next) { /* fprintf(stderr, "doing section %s\n", ((section_t *)(s->data))->name); */ h = lli = ((section_t *)(s->data))->itm_list; if (!lli) { /* fprintf(stdout, "EMPTY ITEM LIST IN SECTION %s\n", ((section_t *)(s->data))->name ); */ continue; } assert(u16_buf_len +4 < sizeof(u16_buf)/sizeof(u16_buf[0])); if ((!i && (ll_len(h) > 1) ) || (ll_len(h) == i)) { if (!i) { /* fprintf(stdout, " section ----------------- %d %d\n", i, ll_len(h)); */ u16_buf[u16_buf_len++] = ll_len(h); /* multi */ assert(lli->data_type & DT_WEIGHTED); #if 0 u16_buf[u16_buf_len++] = final_index_val(((weighted_item_t *)(lli->data))->symbol); /* start index */ #endif u16_buf[u16_buf_len++] = lli->idx; /* start weight */ } do { assert(lli->data_type & DT_WEIGHTED); if (lli->data_type & DT_WEIGHTED) { /* fprintf(stdout, "%11s: S %6d %6d %s\n", */ /* cl->name, lli->idx, */ /* final_index_val(((weighted_item_t *)(lli->data))->symbol), */ /* ((weighted_item_t *)(lli->data))->symbol); */ #if 0 if (i) { assert(u16_buf_len +4 < sizeof(u16_buf)/sizeof(u16_buf[0])); u16_buf[u16_buf_len++] = final_index_val(((weighted_item_t *)(lli->data))->symbol); assert(u16_buf[u16_buf_len-1]); u16_buf[u16_buf_len++] = lli->idx; /* weight */ } #else assert(u16_buf_len +4 < sizeof(u16_buf)/sizeof(u16_buf[0])); u16_buf[u16_buf_len++] = final_index_val(((weighted_item_t *)(lli->data))->symbol); assert(u16_buf[u16_buf_len-1]); if (i) { u16_buf[u16_buf_len++] = lli->idx; /* weight */ } #endif u16_buf[u16_buf_len++] = add_rule((weighted_item_t *)(lli->data)); } } while ((lli = lli->next) != h); } } } u16_buf[u16_buf_len++] = 0; mm = NULL; if ((u16_buf_len > override_len) || !(mm = memmem(override_buffer, override_len*sizeof(override_buffer[0]), u16_buf, u16_buf_len*sizeof(u16_buf[0]))) ) { assert(override_len + u16_buf_len < OVERRIDE_LEN); memcpy(override_buffer + override_len, u16_buf, u16_buf_len*sizeof(u16_buf[0])); der_locale_array[der_locale_len].overrides_offset = override_len; override_len += u16_buf_len; /* printf("%s: override_len = %d u16_buf_len = %d\n", cl->name, override_len, u16_buf_len); */ } else if (!(u16_buf_len > override_len)) { assert(mm); der_locale_array[der_locale_len].overrides_offset = ((uint16_t *)(mm)) - override_buffer; /* printf("%s: memmem found a match with u16_buf_len = %d\n", cl->name, u16_buf_len); */ } do_starter_lists(cl); der_locale_array[der_locale_len].undefined_idx = final_index_val0("UNDEFINED"); #if 0 assert(der_locale_array[der_locale_len].undefined_idx); if (!der_locale_array[der_locale_len].undefined_idx) { der_locale_array[der_locale_len].undefined_idx = base_locale_array[base_locale_len].undefined_idx; } #endif if (!der_locale_array[der_locale_len].undefined_idx) { error_msg("no UNDEFINED definition for %s", cl->name); } ++der_locale_len; } #endif #warning handle UNDEFINED idx specially? what if in only some of derived? /* base_locale_array[base_locale_len].undefined_idx = final_index_val0("UNDEFINED"); */ base_locale_array[base_locale_len].undefined_idx = 0; hdestroy(); ++base_locale_len; /* if (tnumnodes(cur_base->root_starter_char)) { */ /* fprintf(stderr, "starter nodes\n"); */ /* twalk(cur_base->root_starter_char, print_starter_node); */ /* } */ } static int starter_all_cmp(const void *n1, const void *n2) { const char *s1 = ((weighted_item_t *) n1)->symbol; const char *s2 = ((weighted_item_t *) n2)->symbol; colitem_t x; colitem_t *p; int n; /* sort by 1st char ... then inverse for string */ x.element = NULL; if (!is_ucode(s1)) { x.string = s1; p = tfind(&x, &cur_base->root_colitem, colitem_cmp); s1 = (*((colitem_t **) p))->element + 1; } if (!is_ucode(s2)) { x.string = s2; p = tfind(&x, &cur_base->root_colitem, colitem_cmp); s2 = (*((colitem_t **) p))->element + 1; } /* <U####>< */ /* 01234567 */ assert(is_ucode(s1)); assert(is_ucode(s2)); n = strncmp(s1+2, s2+2, 4); if (n) { return n; } s1 += 7; s2 += 7; return strcmp(s2, s1); } static void print_starter_all_node(const void *ptr, VISIT order, int level) { const weighted_item_t *w = *(const weighted_item_t **) ptr; colitem_t *ci; void *p; int n; colitem_t x; if (order == postorder || order == leaf) { #if 0 if ((n = is_ucode(w->symbol)) != 0) { printf(" %s\n", w->symbol); } else { x.string = w->symbol; x.element = NULL; p = tfind(&x, &cur_base->root_colitem, colitem_cmp); assert(p); ci = *((colitem_t **) p); printf("%s = %s\n", ci->element, w->symbol); } #else printf("%s|", w->symbol); /* if ((n = is_ucode(w->symbol)) != 0) { */ /* printf("\n"); */ /* } */ #endif } } static void process_starter_node(const void *ptr, VISIT order, int level) { const weighted_item_t *w = *(const weighted_item_t **) ptr; colitem_t *ci; void *p; int n; colitem_t x; const char *s; char buf[32]; /* store index of collation item followed by (unprefixed) nul-terminated string */ if (order == postorder || order == leaf) { if ((n = is_ucode(w->symbol)) != 0) { u16_buf[u16_buf_len++] = final_index_val(w->symbol); assert(u16_buf[u16_buf_len-1]); u16_buf[u16_buf_len++] = 0; if (++u16_starter < base_locale_array[base_locale_len].num_starters) { u16_buf[u16_starter] = u16_buf_len; } /* fprintf(stderr, "ucode - %d %d\n", u16_buf[u16_starter-1], u16_buf_len); */ } else { x.string = w->symbol; x.element = NULL; p = tfind(&x, &cur_base->root_colitem, colitem_cmp); assert(p); ci = *((colitem_t **) p); s = ci->element; u16_buf[u16_buf_len++] = final_index_val(w->symbol); assert(u16_buf[u16_buf_len-1]); assert(*s == '"'); n = is_ucode(++s); /* fprintf(stderr, "s is |%s| with len %d (%d)\n", s, strlen(s), n); */ assert(n); s += n; while (*s != '"') { n = is_ucode(s); assert(n); strncpy(buf, s, n+1); buf[n] = 0; /* fprintf(stderr, "buf is |%s| with len %d (%d)\n", buf, strlen(buf), n); */ u16_buf[u16_buf_len++] = final_index_val(buf); assert(u16_buf[u16_buf_len-1]); s += n; } u16_buf[u16_buf_len++] = 0; } } } static void **p_cl_root_starter_all; static void complete_starter_node(const void *ptr, VISIT order, int level) { weighted_item_t w; weighted_item_t *p; if (order == postorder || order == leaf) { w.symbol = *(const char **) ptr; w.weight = NULL; if (!tfind(&w, p_cl_root_starter_all, starter_all_cmp)) { p = xmalloc(sizeof(weighted_item_t)); p->symbol = w.symbol; p->weight = NULL; /* fprintf(stderr, "complete_starter_node: %s\n", *(const char **) ptr); */ if (!tsearch(p, p_cl_root_starter_all, starter_all_cmp)) { error_msg("OUT OF MEMORY"); } } } } static void do_starter_lists(col_locale_t *cl) { ll_item_t *s; ll_item_t *h; ll_item_t *lli; col_locale_t *c; colitem_t *ci; weighted_item_t *w; void *p; char buf[32]; int n; colitem_t x; void *mm; c = cl; if (c != cur_base) { c = cur_base; } /* printf("STARTERS %s --------------------\n", cl->name); */ LOOP: for (s = c->section_list ; s ; s = s->next) { h = lli = ((section_t *)(s->data))->itm_list; if (!lli) { continue; } do { if (lli->data_type & DT_WEIGHTED) { w = (weighted_item_t *)(lli->data); ci = NULL; if ((n = is_ucode(w->symbol)) != 0) { strcpy(buf, w->symbol); } else { /* fprintf(stdout, "looking for |%s|\n", w->symbol); */ x.string = w->symbol; x.element = NULL; p = tfind(&x, &cur_base->root_colitem, colitem_cmp); if (!p) { /* fprintf(stderr, "Whoa... processing starters for %s and couldn't find %s\n", */ /* cl->name, w->symbol); */ continue; } ci = *((colitem_t **) p); if (!ci->element) { /* just a collating symbol */ continue; } assert(ci->element[0] == '"'); n = is_ucode(ci->element + 1); assert(n); strncpy(buf, ci->element + 1, n); } if ((tfind(buf, &cur_base->root_starter_char, sym_cmp)) != NULL) { /* fprintf(stdout, "adding from %s: %s", c->name, w->symbol); */ /* if (ci) { */ /* fprintf(stdout, " = %s", ci->element); */ /* } */ /* fprintf(stdout, "\n"); */ if (!tsearch(w, &cl->root_starter_all, starter_all_cmp)) { error_msg("OUT OF MEMORY"); } } } } while ((lli = lli->next) != h); } if (c != cl) { c = cl; goto LOOP; } p_cl_root_starter_all = &cl->root_starter_all; twalk(cur_base->root_starter_char, complete_starter_node); if (cl == cur_base) { base_locale_array[base_locale_len].num_starters = tnumnodes(cur_base->root_starter_char); } #if 0 printf("\nNow walking tree...\n\n"); twalk(cl->root_starter_all, print_starter_all_node); printf("\n\n"); #endif u16_starter = 0; u16_buf[0] = u16_buf_len = base_locale_array[base_locale_len].num_starters; twalk(cl->root_starter_all, process_starter_node); /* fprintf(stderr, "s=%d n=%d\n", u16_starter, base_locale_array[base_locale_len].num_starters); */ assert(u16_starter == base_locale_array[base_locale_len].num_starters); #if 0 { int i; for (i=0 ; i < u16_buf_len ; i++) { fprintf(stderr, "starter %2d: %d - %#06x\n", i, u16_buf[i], u16_buf[i]); }} #endif mm = NULL; if (u16_buf_len) { /* assert(base_locale_array[base_locale_len].num_starters); */ if ((u16_buf_len > multistart_len) || !(mm = memmem(multistart_buffer, multistart_len*sizeof(multistart_buffer[0]), u16_buf, u16_buf_len*sizeof(u16_buf[0]))) ) { assert(multistart_len + u16_buf_len < MULTISTART_LEN); memcpy(multistart_buffer + multistart_len, u16_buf, u16_buf_len*sizeof(u16_buf[0])); if (cl == cur_base) { base_locale_array[base_locale_len].multistart_offset = multistart_len; } else { der_locale_array[der_locale_len].multistart_offset = multistart_len; } multistart_len += u16_buf_len; /* fprintf(stderr, "%s: multistart_len = %d u16_buf_len = %d\n", cl->name, multistart_len, u16_buf_len); */ } else if (!(u16_buf_len > multistart_len)) { assert(mm); if (cl == cur_base) { base_locale_array[base_locale_len].multistart_offset = ((uint16_t *)(mm)) - multistart_buffer; } else { der_locale_array[der_locale_len].multistart_offset = ((uint16_t *)(mm)) - multistart_buffer; } /* fprintf(stderr, "%s: memmem found a match with u16_buf_len = %d\n", cl->name, u16_buf_len); */ } } else { assert(!base_locale_array[base_locale_len].num_starters); } /* printf("u16_buf_len = %d\n", u16_buf_len); */ /* printf("STARTERS %s DONE ---------------\n", cl->name); */ } /* For sorting the blocks of unsigned chars. */ static size_t nu_val; int nu_memcmp(const void *a, const void *b) { return memcmp(*(unsigned char**)a, *(unsigned char**)b, nu_val * sizeof(tbl_item)); } size_t newopt(tbl_item *ut, size_t usize, int shift, table_data *tbl) { static int recurse = 0; tbl_item *ti[RANGE]; /* table index */ size_t numblocks; size_t blocksize; size_t uniq; size_t i, j; size_t smallest, t; tbl_item *ii_save; int uniqblock[1 << (8*sizeof(tbl_item) - 1)]; tbl_item uit[RANGE]; int shift2; if (shift > 15) { return SIZE_MAX; } ii_save = NULL; blocksize = 1 << shift; numblocks = usize >> shift; /* init table index */ for (i=j=0 ; i < numblocks ; i++) { ti[i] = ut + j; j += blocksize; } /* sort */ nu_val = blocksize; qsort(ti, numblocks, sizeof(unsigned char *), nu_memcmp); uniq = 1; uit[(ti[0]-ut)/blocksize] = 0; for (i=1 ; i < numblocks ; i++) { if (memcmp(ti[i-1], ti[i], blocksize*sizeof(tbl_item)) < 0) { if (++uniq > (1 << (8*sizeof(tbl_item) - 1))) { break; } uniqblock[uniq - 1] = i; } #if 1 else if (memcmp(ti[i-1], ti[i], blocksize*sizeof(tbl_item)) > 0) { printf("bad sort %i!\n", i); abort(); } #endif uit[(ti[i]-ut)/blocksize] = uniq - 1; } smallest = SIZE_MAX; shift2 = -1; if (uniq <= (1 << (8*sizeof(tbl_item) - 1))) { smallest = numblocks + uniq * blocksize; if (!recurse) { ++recurse; for (j=1 ; j < 14 ; j++) { if ((numblocks >> j) < 2) break; if (tbl) { ii_save = tbl->ii; tbl->ii = NULL; } if ((t = newopt(uit, numblocks, j, tbl)) < SIZE_MAX) { t += uniq * blocksize; } if (tbl) { tbl->ii = ii_save; } if (smallest >= t) { shift2 = j; smallest = t; /* if (!tbl->ii) { */ /* printf("ishift %u tshift %u size %u\n", */ /* shift2, shift, t); */ /* } */ /* } else { */ /* break; */ } } --recurse; } } else { return SIZE_MAX; } if (tbl->ii) { if (recurse) { tbl->ii_shift = shift; tbl->ii_len = numblocks; memcpy(tbl->ii, uit, numblocks*sizeof(tbl_item)); tbl->ti = tbl->ii + tbl->ii_len; tbl->ti_len = uniq * blocksize; for (i=0 ; i < uniq ; i++) { memcpy(tbl->ti + i * blocksize, ti[uniqblock[i]], blocksize*sizeof(tbl_item)); } } else { ++recurse; /* printf("setting ishift %u tshift %u\n", shift2, shift); */ newopt(uit, numblocks, shift2, tbl); --recurse; tbl->ti_shift = shift; tbl->ut_len = uniq * blocksize; tbl->ut = tbl->ti + tbl->ti_len; for (i=0 ; i < uniq ; i++) { memcpy(tbl->ut + i * blocksize, ti[uniqblock[i]], blocksize*sizeof(tbl_item)); } } } return smallest; } static const int rule2val[8] = { -1, (1 << 14), /* forward */ (2 << 14), /* position */ (3 << 14), /* forward,position */ 0, /* backward */ -1, -1, -1, }; static int final_index_val_x(const char *s, const char *sym) { int r; if (!(r = final_index_val0(s))) { if (!strcmp(s, "IGNORE")) { r = 0; } else if (!strcmp(s, "..") || !strcmp(sym, "RANGE")) { if (*sym == '.') { final_index_val(sym); /* make sure it's known */ } r = 0x3fff; } else if (!strcmp(s, ".")) { r = 0x3ffe; } else { error_msg("can't find final index: %s", s); } } return r; } /* store rule2val in 2 high bits and collation index in lower. * for sort strings, store (offset from base) + max colindex as index. */ static unsigned int add_rule(weighted_item_t *wi) { weight_t *w = wi->weight; int i, j, r, n; uint16_t rbuf[MAX_COLLATION_WEIGHTS]; uint16_t ws_buf[32]; void *mm; char buf[32]; const char *s; const char *e; for (i=0 ; i < MAX_COLLATION_WEIGHTS ; i++) { rbuf[i] = rule2val[R_FORWARD]; /* set a default to forward-ignore */ } if (base_locale_array[base_locale_len].num_weights < w->num_weights) { base_locale_array[base_locale_len].num_weights = w->num_weights; } for (i=0 ; i < w->num_weights ; i++) { assert(rule2val[(int)(w->rule[i])] >= 0); assert(w->colitem[i] && *w->colitem[i]); if (*w->colitem[i] == '"') { /* string... */ s = w->colitem[i] + 1; assert(*s == '<'); n = 0; do { e = s; do { if (*e == '/') { e += 2; continue; } } while (*e++ != '>'); assert(((size_t)(e-s) < sizeof(buf))); memcpy(buf, s, (size_t)(e-s)); buf[(size_t)(e-s)] = 0; r = final_index_val_x(buf, wi->symbol); assert(n + 1 < sizeof(ws_buf)/sizeof(ws_buf[0])); ws_buf[n++] = r | rule2val[(int)(w->rule[i])]; s = e; } while (*s != '"'); ws_buf[n++] = 0; /* terminator */ mm = memmem(weightstr_buffer, weightstr_len*sizeof(weightstr_buffer[0]), ws_buf, n*sizeof(ws_buf[0])); if (!mm) { assert(weightstr_len + n < WEIGHTSTR_LEN); memcpy(weightstr_buffer + weightstr_len, ws_buf, n*sizeof(ws_buf[0])); mm = weightstr_buffer + weightstr_len; weightstr_len += n; } r = (((uint16_t *)(mm)) - weightstr_buffer) + base_locale_array[base_locale_len].max_col_index + 2; assert(r < (1 << 14)); rbuf[i] = r | rule2val[(int)(w->rule[i])]; } else { /* item */ r = final_index_val_x(w->colitem[i], wi->symbol); rbuf[i] = r | rule2val[(int)(w->rule[i])]; } } for (i=0 ; i < ruletable_len ; i += MAX_COLLATION_WEIGHTS) { if (!memcmp(ruletable_buffer + i, rbuf, MAX_COLLATION_WEIGHTS*sizeof(ruletable_buffer[0]))) { return i/MAX_COLLATION_WEIGHTS; } } memcpy(ruletable_buffer + ruletable_len, rbuf, MAX_COLLATION_WEIGHTS*sizeof(ruletable_buffer[0])); ruletable_len += MAX_COLLATION_WEIGHTS; return (ruletable_len / MAX_COLLATION_WEIGHTS)-1; } static unsigned int add_range_rule(range_item_t *ri) { weight_t *w = ri->weight; int i, j, r, n; uint16_t rbuf[MAX_COLLATION_WEIGHTS]; uint16_t ws_buf[32]; void *mm; char buf[32]; const char *s; const char *e; for (i=0 ; i < MAX_COLLATION_WEIGHTS ; i++) { rbuf[i] = rule2val[R_FORWARD]; /* set a default to forward-ignore */ } if (base_locale_array[base_locale_len].num_weights < w->num_weights) { base_locale_array[base_locale_len].num_weights = w->num_weights; } for (i=0 ; i < w->num_weights ; i++) { assert(rule2val[(int)(w->rule[i])] >= 0); assert(w->colitem[i] && *w->colitem[i]); if (*w->colitem[i] == '"') { /* string... */ s = w->colitem[i] + 1; assert(*s == '<'); n = 0; do { e = s; do { if (*e == '/') { e += 2; continue; } } while (*e++ != '>'); assert(((size_t)(e-s) < sizeof(buf))); memcpy(buf, s, (size_t)(e-s)); buf[(size_t)(e-s)] = 0; r = final_index_val_x(buf, "RANGE"); assert(n + 1 < sizeof(ws_buf)/sizeof(ws_buf[0])); ws_buf[n++] = r | rule2val[(int)(w->rule[i])]; s = e; } while (*s != '"'); ws_buf[n++] = 0; /* terminator */ mm = memmem(weightstr_buffer, weightstr_len*sizeof(weightstr_buffer[0]), ws_buf, n*sizeof(ws_buf[0])); if (!mm) { assert(weightstr_len + n < WEIGHTSTR_LEN); memcpy(weightstr_buffer + weightstr_len, ws_buf, n*sizeof(ws_buf[0])); mm = weightstr_buffer + weightstr_len; weightstr_len += n; } r = (((uint16_t *)(mm)) - weightstr_buffer) + base_locale_array[base_locale_len].max_col_index + 2; assert(r < (1 << 14)); rbuf[i] = r | rule2val[(int)(w->rule[i])]; } else { /* item */ r = final_index_val_x(w->colitem[i], "RANGE"); rbuf[i] = r | rule2val[(int)(w->rule[i])]; } } for (i=0 ; i < ruletable_len ; i += MAX_COLLATION_WEIGHTS) { if (!memcmp(ruletable_buffer + i, rbuf, MAX_COLLATION_WEIGHTS*sizeof(ruletable_buffer[0]))) { return i/MAX_COLLATION_WEIGHTS; } } memcpy(ruletable_buffer + ruletable_len, rbuf, MAX_COLLATION_WEIGHTS*sizeof(ruletable_buffer[0])); ruletable_len += MAX_COLLATION_WEIGHTS; return (ruletable_len / MAX_COLLATION_WEIGHTS)-1; } #define DUMPn(X) fprintf(stderr, "%10d-%-.20s", base_locale_array[n]. X, #X); static void dump_base_locale(int n) { assert(n < base_locale_len); fprintf(stderr, "Base Locale: %s\n", base_locale_array[n].name); DUMPn(num_weights); DUMPn(ii_shift); DUMPn(ti_shift); DUMPn(ii_len); DUMPn(ti_len); DUMPn(max_weight); fprintf(stderr, "\n"); DUMPn(num_col_base); DUMPn(max_col_index); DUMPn(undefined_idx); DUMPn(range_low); DUMPn(range_count); fprintf(stderr, "\n"); DUMPn(range_base_weight); DUMPn(num_starters); fprintf(stderr, "\n"); DUMPn(range_rule_offset); DUMPn(wcs2colidt_offset); DUMPn(index2weight_offset); fprintf(stderr, "\n"); DUMPn(index2ruleidx_offset); DUMPn(multistart_offset); fprintf(stderr, "\n"); } #undef DUMPn #define DUMPn(X) fprintf(stderr, "%10d-%s", der_locale_array[n]. X, #X); static void dump_der_locale(int n) { assert(n < der_locale_len); fprintf(stderr, "Derived Locale: %s (%.12s)", der_locale_array[n].name, base_locale_array[der_locale_array[n].base_idx].name); DUMPn(base_idx); DUMPn(undefined_idx); DUMPn(overrides_offset); DUMPn(multistart_offset); fprintf(stderr, "\n"); } static unsigned long collate_pos; static void dump_u16_array(FILE *fp, uint16_t *u, int len, const char *name) { int i; fprintf(fp, "\t/* %8lu %s */\n", collate_pos, name); for (i=0 ; i < len ; i++) { if (!(i & 7)) { fprintf(fp, "\n\t"); } fprintf(fp," %#06x,", (unsigned int)(u[i])); } fprintf(fp,"\n"); collate_pos += len; } #define OUT_U16C(X,N) fprintf(fp,"\t%10d, /* %8lu %s */\n", X, collate_pos++, N); static void dump_collate(FILE *fp) { int n; fprintf(fp, "const uint16_t __locale_collate_tbl[] = {\n"); OUT_U16C(base_locale_len, "numbef of base locales"); OUT_U16C(der_locale_len, "number of derived locales"); OUT_U16C(MAX_COLLATION_WEIGHTS, "max collation weights"); OUT_U16C(index2weight_len, "number of index2{weight|ruleidx} elements"); OUT_U16C(weightstr_len, "number of weightstr elements"); OUT_U16C(multistart_len, "number of multistart elements"); OUT_U16C(override_len, "number of override elements"); OUT_U16C(ruletable_len, "number of ruletable elements"); #undef DUMPn #define DUMPn(X) fprintf(fp, "\t%10d, /* %8lu %s */\n", base_locale_array[n]. X, collate_pos++, #X); for (n=0 ; n < base_locale_len ; n++) { unsigned wcs2colidt_offset_low = base_locale_array[n].wcs2colidt_offset & 0xffffU; unsigned wcs2colidt_offset_hi = base_locale_array[n].wcs2colidt_offset >> 16; fprintf(fp, "\t/* Base Locale %2d: %s */\n", n, base_locale_array[n].name); DUMPn(num_weights); DUMPn(num_starters); DUMPn(ii_shift); DUMPn(ti_shift); DUMPn(ii_len); DUMPn(ti_len); DUMPn(max_weight); DUMPn(num_col_base); DUMPn(max_col_index); DUMPn(undefined_idx); DUMPn(range_low); DUMPn(range_count); DUMPn(range_base_weight); DUMPn(range_rule_offset); DUMPn(index2weight_offset); DUMPn(index2ruleidx_offset); DUMPn(multistart_offset); #undef DUMPn #define DUMPn(X) fprintf(fp, "\t%10d, /* %8lu %s */\n", X, collate_pos++, #X); DUMPn(wcs2colidt_offset_low); DUMPn(wcs2colidt_offset_hi); } #undef DUMPn fprintf(fp, "#define COL_IDX_C %5d\n", 0); #define DUMPn(X) fprintf(fp, "\t%10d, /* %8lu %s */\n", der_locale_array[n]. X, collate_pos++, #X); for (n=0 ; n < der_locale_len ; n++) { fprintf(fp, "#define COL_IDX_%s %5d\n", der_locale_array[n].name, n+1); fprintf(fp, "\t/* Derived Locale %4d: %s (%.12s) */\n", n, der_locale_array[n].name, base_locale_array[der_locale_array[n].base_idx].name); DUMPn(base_idx); DUMPn(undefined_idx); DUMPn(overrides_offset); DUMPn(multistart_offset); } #undef DUMPn fprintf(fp, "\n"); dump_u16_array(fp, index2weight_buffer, index2weight_len, "index2weight"); dump_u16_array(fp, index2ruleidx_buffer, index2ruleidx_len, "index2ruleidx"); dump_u16_array(fp, multistart_buffer, multistart_len, "multistart"); dump_u16_array(fp, override_buffer, override_len, "override"); dump_u16_array(fp, ruletable_buffer, ruletable_len, "ruletable"); dump_u16_array(fp, weightstr_buffer, weightstr_len, "weightstr"); dump_u16_array(fp, wcs2colidt_buffer, wcs2colidt_len, "wcs2colidt"); fprintf(fp,"}; /* %8lu */\n", collate_pos); fprintf(fp,"#define __lc_collate_data_LEN %d\n\n", collate_pos); }
the_stack_data/90847.c
//Classification: #default/n/DEC/CG/aS+dS/D(v)/lc/rp //Written by: Igor Eremeev //Reviewed by: Sergey Pomelov //Comment: #include <stdio.h> int func (int a) { printf ("%d", a); return 0; } int main(void) { int a = 10; int *p = &a; int i; for (i = 0; i < 10; i++) (*p)--; if (*p) { func (a); } return 0; }
the_stack_data/18743.c
void kernel_heat_3d(int tsteps, int n, double A[ 120 + 0][120 + 0][120 + 0], double B[ 120 + 0][120 + 0][120 + 0]) { int t, i, j, k; #pragma clang loop(i1, j1, k1) tile sizes(128, 8, 128) for (t = 1; t <= 500; t++) { #pragma clang loop id(i1) for (i = 1; i < n-1; i++) { #pragma clang loop id(j1) for (j = 1; j < n-1; j++) { #pragma clang loop id(k1) for (k = 1; k < n-1; k++) { B[i][j][k] = 0.125 * (A[i+1][j][k] - 2.0 * A[i][j][k] + A[i-1][j][k]) + 0.125 * (A[i][j+1][k] - 2.0 * A[i][j][k] + A[i][j-1][k]) + 0.125 * (A[i][j][k+1] - 2.0 * A[i][j][k] + A[i][j][k-1]) + A[i][j][k]; } } } #pragma clang loop(i2, j2, k2) tile sizes(128, 8, 128) #pragma clang loop id(i2) for (i = 1; i < n-1; i++) { #pragma clang loop id(j2) for (j = 1; j < n-1; j++) { #pragma clang loop id(k2) for (k = 1; k < n-1; k++) { A[i][j][k] = 0.125 * (B[i+1][j][k] - 2.0 * B[i][j][k] + B[i-1][j][k]) + 0.125 * (B[i][j+1][k] - 2.0 * B[i][j][k] + B[i][j-1][k]) + 0.125 * (B[i][j][k+1] - 2.0 * B[i][j][k] + B[i][j][k-1]) + B[i][j][k]; } } } } }
the_stack_data/1041598.c
/* $NetBSD: __mb_cur_max.c,v 1.2 2001/01/25 01:25:06 itojun Exp $ */ /*- * Copyright (c)1999 Citrus Project, * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include <sys/cdefs.h> #include <sys/types.h> #include <limits.h> size_t __mb_cur_max = 1; size_t __mb_len_max_runtime = MB_LEN_MAX;
the_stack_data/200143830.c
#include <arpa/inet.h> #include <linux/if_packet.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <sys/ioctl.h> #include <sys/socket.h> #include <net/if.h> #include <netinet/ether.h> #define MY_DEST_MAC0 0x12 #define MY_DEST_MAC1 0x34 #define MY_DEST_MAC2 0x56 #define MY_DEST_MAC3 0x78 #define MY_DEST_MAC4 0x9a #define MY_DEST_MAC5 0xbc #define DEFAULT_IF "enp0s31f6" #define BUF_SIZ 2048 char udp_packet[] = { 0x45, 0x00, 0x00, 0x24, 0x7d, 0x2f, 0x40, 0x00, 0x40, 0x11, 0xf3, 0xf2, 0xc0, 0xa8, 0x00, 0x01, 0xc0, 0xa8, 0x00, 0x02, 0x05, 0xfe, 0x05, 0xfe, 0x00, 0x10, 0xc9, 0xc8, 0x54, 0x43, 0x46, 0x32, 0x04, 0x00, 0x00, 0x00, }; char arp_packet[] = { 0x00, 0x01, 0x08, 0x00, 0x06, 0x04, 0x00, 0x01, 0x10, 0x65, 0x30, 0x70, // Make sure to put your own MAC address as sender MAC 0x3d, 0x6d, 0xc0, 0xa8, // and configure with the relevant IP address that you want 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xa8, 0x00, 0x01, }; int main(int argc, char *argv[]) { uint32_t broadcast = 0; uint16_t ether_type = ETH_P_IP; int sockfd; struct ifreq if_idx; struct ifreq if_mac; int tx_len = 0; char sendbuf[BUF_SIZ]; struct ether_header *eh = (struct ether_header *) sendbuf; struct iphdr *iph = (struct iphdr *) (sendbuf + sizeof(struct ether_header)); struct sockaddr_ll socket_address; char ifName[IFNAMSIZ]; /* Get interface name */ if (argc > 1) strcpy(ifName, argv[1]); else strcpy(ifName, DEFAULT_IF); /* Open RAW socket to send on */ if ((sockfd = socket(AF_PACKET, SOCK_RAW, IPPROTO_RAW)) == -1) { perror("socket"); } /* Get the index of the interface to send on */ memset(&if_idx, 0, sizeof(struct ifreq)); strncpy(if_idx.ifr_name, ifName, IFNAMSIZ-1); if (ioctl(sockfd, SIOCGIFINDEX, &if_idx) < 0) perror("SIOCGIFINDEX"); /* Get the MAC address of the interface to send on */ memset(&if_mac, 0, sizeof(struct ifreq)); strncpy(if_mac.ifr_name, ifName, IFNAMSIZ-1); if (ioctl(sockfd, SIOCGIFHWADDR, &if_mac) < 0) perror("SIOCGIFHWADDR"); /* Construct the Ethernet header */ memset(sendbuf, 0, BUF_SIZ); /* Ethernet header */ eh->ether_shost[0] = ((uint8_t *)&if_mac.ifr_hwaddr.sa_data)[0]; eh->ether_shost[1] = ((uint8_t *)&if_mac.ifr_hwaddr.sa_data)[1]; eh->ether_shost[2] = ((uint8_t *)&if_mac.ifr_hwaddr.sa_data)[2]; eh->ether_shost[3] = ((uint8_t *)&if_mac.ifr_hwaddr.sa_data)[3]; eh->ether_shost[4] = ((uint8_t *)&if_mac.ifr_hwaddr.sa_data)[4]; eh->ether_shost[5] = ((uint8_t *)&if_mac.ifr_hwaddr.sa_data)[5]; eh->ether_dhost[0] = broadcast ? 0xff : MY_DEST_MAC0; eh->ether_dhost[1] = broadcast ? 0xff : MY_DEST_MAC1; eh->ether_dhost[2] = broadcast ? 0xff : MY_DEST_MAC2; eh->ether_dhost[3] = broadcast ? 0xff : MY_DEST_MAC3; eh->ether_dhost[4] = broadcast ? 0xff : MY_DEST_MAC4; eh->ether_dhost[5] = broadcast ? 0xff : MY_DEST_MAC5; /* Ethertype field */ eh->ether_type = htons(ether_type); tx_len += sizeof(struct ether_header); /* Packet data */ char* packet_data = udp_packet; uint32_t packet_len = sizeof(arp_packet) / sizeof(char); for (size_t itt = 0; itt < packet_len; itt++) sendbuf[tx_len++] = packet_data[itt]; /* Index of the network device */ socket_address.sll_ifindex = if_idx.ifr_ifindex; /* Address length*/ socket_address.sll_halen = ETH_ALEN; /* Destination MAC */ socket_address.sll_addr[0] = MY_DEST_MAC0; socket_address.sll_addr[1] = MY_DEST_MAC1; socket_address.sll_addr[2] = MY_DEST_MAC2; socket_address.sll_addr[3] = MY_DEST_MAC3; socket_address.sll_addr[4] = MY_DEST_MAC4; socket_address.sll_addr[5] = MY_DEST_MAC5; /* Send packet */ for (size_t itt = 0; itt < 200000; itt++) if (sendto(sockfd, sendbuf, tx_len, 0, (struct sockaddr*)&socket_address, sizeof(struct sockaddr_ll)) < 0) printf("Send failed\n"); return 0; }
the_stack_data/555905.c
#include<stdio.h> #include<sys/socket.h> #include<stdlib.h> #include<netinet/in.h> #include<string.h> #include<fcntl.h> #include<errno.h> #include<unistd.h> #include<sys/types.h> #include<sys/stat.h> #include<arpa/inet.h> #define PORT 8000 #define N 100000 #define BUFFER_LIMIT 10000 // reads an integer from socket int readint(int sock){ int n; read(sock, (char *)&n, sizeof(n)); n = ntohl(n); return n; } // reads a string from socket void readstr(int sock, char* buffer){ int len = readint(sock); read(sock, buffer, len); buffer[len]='\0'; return; } // sends an integer to socket void sendint(int sock, int n){ n = htonl(n); send(sock, (char *)&n, sizeof(n), 0); } // sends a string to socket void sendstr(int sock, char* buffer){ sendint(sock,strlen(buffer)); send(sock,buffer,strlen(buffer),0); } void uploadFile(int sock, char filename[]){ char data[N]; int rd = open(filename,O_RDONLY); if(rd == -1) { perror("Error"); // sends a error code to download sendint(sock, 0); return; } else{ struct stat st; if (fstat(rd, &st) < 0){ perror("Error"); // sends a error code to download sendint(sock, 0); return; } if(! S_ISREG(st.st_mode)){ printf("Error: Not a regular file\n"); // sends a error code to download sendint(sock, 0); return; } // sends a success code to download sendint(sock, 1); } int size = lseek(rd,0,SEEK_END); // sends the size of file sendint(sock, size); // remaining characters int j = size; lseek(rd,0,SEEK_SET); printf("Uploading %d bytes\n",j); // Default socket buffer limit is 43689 for LINUX LOW-MEM SYSTEMS!! // Using 10,000 to overcome the issue!! // If still throws bus error/ seg fault, reduce it!! while(j>BUFFER_LIMIT){ // read data from file read(rd,data,BUFFER_LIMIT); data[BUFFER_LIMIT]='\0'; // send data only after ack from client if(!readint(sock)) return; // sendstr(sock, data); send(sock, data, BUFFER_LIMIT, 0); // check j-=BUFFER_LIMIT; } // read data from file read(rd,data,j); data[j]='\0'; // send data only after ack from client if(!readint(sock)) return; // sendstr(sock, data); send(sock, data, j, 0); // check j=0; if (close(rd) < 0) { perror("Error "); return; } } int main(int argc, char const *argv[]) { int server_fd, new_socket, valread; struct sockaddr_in address; int opt = 1; int addrlen = sizeof(address); char buffer[N] = {0}; // Creating socket file descriptor if ((server_fd = socket(AF_INET, SOCK_STREAM, 0)) == 0) // creates socket, SOCK_STREAM is for TCP. SOCK_DGRAM for UDP { perror("socket failed"); exit(EXIT_FAILURE); } // This is to lose the pesky "Address already in use" error message if (setsockopt(server_fd, SOL_SOCKET, SO_REUSEADDR, //| SO_REUSEPORT, &opt, sizeof(opt))) // SOL_SOCKET is the socket layer itself { perror("setsockopt"); exit(EXIT_FAILURE); } address.sin_family = AF_INET; // Address family. For IPv6, it's AF_INET6. 29 others exist like AF_UNIX etc. address.sin_addr.s_addr = INADDR_ANY; // Accept connections from any IP address - listens from aint interfaces. address.sin_port = htons( PORT ); // Server port to open. Htons converts to Big Endian - Left to Right. RTL is Little Endian // Forcefuinty attaching socket to the port 8080 if (bind(server_fd, (struct sockaddr *)&address, sizeof(address))<0) { perror("bind failed"); exit(EXIT_FAILURE); } // Port bind is done. You want to wait for incoming connections and handle them in some way. // The process is two step: first you listen(), then you accept() if (listen(server_fd, 3) < 0) // 3 is the maximum size of queue - connections you haven't accepted { perror("listen"); exit(EXIT_FAILURE); } // returns a brand new socket file descriptor to use for this single accepted connection. Once done, use send and recv if ((new_socket = accept(server_fd, (struct sockaddr *)&address, (socklen_t*)&addrlen))<0) { perror("accept"); exit(EXIT_FAILURE); } // gets the number of files at the very beginning int num_of_file = readint(new_socket); for(int i=0;i<num_of_file;i++){ char filename[N]; // read the file name readstr(new_socket,filename); printf("Uploading %s\n",filename); uploadFile(new_socket, filename); printf("\n"); } return 0; }
the_stack_data/156394496.c
#include <stdlib.h> #include <stdio.h> #include <sys/types.h> #include <unistd.h> #include <fcntl.h> #include <pthread.h> #include <sched.h> #include <time.h> #define IMG_HEIGHT (3000) #define IMG_WIDTH (4000) //#define IMG_HEIGHT (300) //#define IMG_WIDTH (400) #define NUM_ROW_THREADS (3) #define NUM_COL_THREADS (4) //#define NUM_ROW_THREADS (6) //#define NUM_COL_THREADS (8) //#define NUM_ROW_THREADS (12) //#define NUM_COL_THREADS (16) #define IMG_H_SLICE (IMG_HEIGHT/NUM_ROW_THREADS) #define IMG_W_SLICE (IMG_WIDTH/NUM_COL_THREADS) #define ITERATIONS (90) #define CREATE_ITERATIONS (1) #define FAST_IO typedef double FLOAT; pthread_t threads[NUM_ROW_THREADS*NUM_COL_THREADS]; typedef struct _threadArgs { int thread_idx; int i; int j; int h; int w; int iterations; } threadArgsType; threadArgsType threadarg[NUM_ROW_THREADS*NUM_COL_THREADS]; pthread_attr_t fifo_sched_attr; pthread_attr_t orig_sched_attr; struct sched_param fifo_param; typedef unsigned int UINT32; typedef unsigned long long int UINT64; typedef unsigned char UINT8; // PPM Edge Enhancement Code in row x column format UINT8 header[22]; UINT8 R[IMG_HEIGHT][IMG_WIDTH]; UINT8 G[IMG_HEIGHT][IMG_WIDTH]; UINT8 B[IMG_HEIGHT][IMG_WIDTH]; UINT8 convR[IMG_HEIGHT][IMG_WIDTH]; UINT8 convG[IMG_HEIGHT][IMG_WIDTH]; UINT8 convB[IMG_HEIGHT][IMG_WIDTH]; // PPM format array with RGB channels all packed together UINT8 RGB[IMG_HEIGHT*IMG_WIDTH*3]; #define K 4.0 #define F 8.0 //#define F 80.0 FLOAT PSF[9] = {-K/F, -K/F, -K/F, -K/F, K+1.0, -K/F, -K/F, -K/F, -K/F}; void *sharpen_thread(void *threadptr) { threadArgsType thargs=*((threadArgsType *)threadptr); int i=thargs.i; int j=thargs.j; int repeat=0; FLOAT temp=0; //printf("i=%d, j=%d, h=%d, w=%d, iter=%d\n", thargs.i, thargs.j, thargs.h, thargs.w, thargs.iterations); for(repeat=0; repeat < thargs.iterations; repeat++) { for(i=thargs.i; i<(thargs.i+thargs.h); i++) { for(j=thargs.j; j<(thargs.j+thargs.w); j++) { temp=0; temp += (PSF[0] * (FLOAT)R[(i-1)][j-1]); temp += (PSF[1] * (FLOAT)R[(i-1)][j]); temp += (PSF[2] * (FLOAT)R[(i-1)][j+1]); temp += (PSF[3] * (FLOAT)R[(i)][j-1]); temp += (PSF[4] * (FLOAT)R[(i)][j]); temp += (PSF[5] * (FLOAT)R[(i)][j+1]); temp += (PSF[6] * (FLOAT)R[(i+1)][j-1]); temp += (PSF[7] * (FLOAT)R[(i+1)][j]); temp += (PSF[8] * (FLOAT)R[(i+1)][j+1]); if(temp<0.0) temp=0.0; if(temp>255.0) temp=255.0; convR[i][j]=(UINT8)temp; temp=0; temp += (PSF[0] * (FLOAT)G[(i-1)][j-1]); temp += (PSF[1] * (FLOAT)G[(i-1)][j]); temp += (PSF[2] * (FLOAT)G[(i-1)][j+1]); temp += (PSF[3] * (FLOAT)G[(i)][j-1]); temp += (PSF[4] * (FLOAT)G[(i)][j]); temp += (PSF[5] * (FLOAT)G[(i)][j+1]); temp += (PSF[6] * (FLOAT)G[(i+1)][j-1]); temp += (PSF[7] * (FLOAT)G[(i+1)][j]); temp += (PSF[8] * (FLOAT)G[(i+1)][j+1]); if(temp<0.0) temp=0.0; if(temp>255.0) temp=255.0; convG[i][j]=(UINT8)temp; temp=0; temp += (PSF[0] * (FLOAT)B[(i-1)][j-1]); temp += (PSF[1] * (FLOAT)B[(i-1)][j]); temp += (PSF[2] * (FLOAT)B[(i-1)][j+1]); temp += (PSF[3] * (FLOAT)B[(i)][j-1]); temp += (PSF[4] * (FLOAT)B[(i)][j]); temp += (PSF[5] * (FLOAT)B[(i)][j+1]); temp += (PSF[6] * (FLOAT)B[(i+1)][j-1]); temp += (PSF[7] * (FLOAT)B[(i+1)][j]); temp += (PSF[8] * (FLOAT)B[(i+1)][j+1]); if(temp<0.0) temp=0.0; if(temp>255.0) temp=255.0; convB[i][j]=(UINT8)temp; } } //printf("thread-%d %d ", thargs.thread_idx, repeat); } pthread_exit((void **)0); } int main(int argc, char *argv[]) { int fdin, fdout, bytesRead=0, bytesWritten=0, bytesLeft, i, j, idx, jdx, pixel, readcnt, writecnt; UINT64 microsecs=0, millisecs=0; unsigned int thread_idx; FLOAT temp, fnow, fstart; int runs=0, rc; struct timespec now, start; clock_gettime(CLOCK_MONOTONIC, &start); fstart = (FLOAT)start.tv_sec + (FLOAT)start.tv_nsec / 1000000000.0; if(argc < 3) { printf("Usage: sharpen input_file.ppm output_file.ppm\n"); exit(-1); } else { if((fdin = open(argv[1], O_RDONLY, 0644)) < 0) { printf("Error opening %s\n", argv[1]); } //else // printf("File opened successfully\n"); if((fdout = open(argv[2], (O_RDWR | O_CREAT), 0666)) < 0) { printf("Error opening %s\n", argv[1]); } //else // printf("Output file=%s opened successfully\n", "sharpen.ppm"); } bytesLeft=21; //printf("Reading header\n"); do { //printf("bytesRead=%d, bytesLeft=%d\n", bytesRead, bytesLeft); bytesRead=read(fdin, (void *)header, bytesLeft); bytesLeft -= bytesRead; } while(bytesLeft > 0); header[21]='\0'; printf("header = %s\n", header); #ifdef FAST_IO clock_gettime(CLOCK_MONOTONIC, &now); fnow = (FLOAT)now.tv_sec + (FLOAT)now.tv_nsec / 1000000000.0; fstart = (FLOAT)now.tv_sec + (FLOAT)now.tv_nsec / 1000000000.0; printf("\nstart test input at %lf\n", fnow - fstart); bytesRead=0; bytesLeft=IMG_HEIGHT*IMG_WIDTH*3; readcnt=0; printf("START: read %d, bytesRead=%d, bytesLeft=%d\n", readcnt, bytesRead, bytesLeft); // Read in RGB data in large chunks, requesting all and reading residual do { bytesRead=read(fdin, (void *)&RGB[bytesRead], bytesLeft); bytesLeft -= bytesRead; readcnt++; printf("read %d, bytesRead=%d, bytesLeft=%d\n", readcnt, bytesRead, bytesLeft); } while((bytesLeft > 0) && (readcnt < 3)); printf("END: read %d, bytesRead=%d, bytesLeft=%d\n", readcnt, bytesRead, bytesLeft); // create in memory copy from input by channel for(i=0, pixel=0; i<IMG_HEIGHT; i++) { for(j=0; j<IMG_WIDTH; j++) { R[i][j]=RGB[pixel+0]; convR[i][j]=R[i][j]; G[i][j]=RGB[pixel+1]; convG[i][j]=G[i][j]; B[i][j]=RGB[pixel+2]; convB[i][j]=B[i][j]; pixel+=3; } } clock_gettime(CLOCK_MONOTONIC, &now); fnow = (FLOAT)now.tv_sec + (FLOAT)now.tv_nsec / 1000000000.0; printf("\ncompleted test input at %lf\n", fnow - fstart); #else // Read RGB data - very slow 1 byte at a time! for(i=0; i<IMG_HEIGHT; i++) { for(j=0; j<IMG_WIDTH; j++) { rc=read(fdin, (void *)&R[i][j], 1); convR[i][j]=R[i][j]; rc=read(fdin, (void *)&G[i][j], 1); convG[i][j]=G[i][j]; rc=read(fdin, (void *)&B[i][j], 1); convB[i][j]=B[i][j]; } } #endif printf("source file %s read\n", argv[1]); close(fdin); clock_gettime(CLOCK_MONOTONIC, &now); fnow = (FLOAT)now.tv_sec + (FLOAT)now.tv_nsec / 1000000000.0; fstart = (FLOAT)now.tv_sec + (FLOAT)now.tv_nsec / 1000000000.0; printf("\nstart test at %lf\n", fnow - fstart); for(runs=0; runs < CREATE_ITERATIONS; runs++) { for(thread_idx=0; thread_idx<(NUM_ROW_THREADS*NUM_COL_THREADS); thread_idx++) { // hard coded for 4 x 3 threads, could generalize to any 4:3 aspect ratio if(thread_idx == 0) {idx=1; jdx=1;} if(thread_idx == 1) {idx=1; jdx=(thread_idx*(IMG_W_SLICE-1));} if(thread_idx == 2) {idx=1; jdx=(thread_idx*(IMG_W_SLICE-1));} if(thread_idx == 3) {idx=1; jdx=(thread_idx*(IMG_W_SLICE-1));} if(thread_idx == 4) {idx=IMG_H_SLICE; jdx=(thread_idx*(IMG_W_SLICE-1));} if(thread_idx == 5) {idx=IMG_H_SLICE; jdx=(thread_idx*(IMG_W_SLICE-1));} if(thread_idx == 6) {idx=IMG_H_SLICE; jdx=(thread_idx*(IMG_W_SLICE-1));} if(thread_idx == 7) {idx=IMG_H_SLICE; jdx=(thread_idx*(IMG_W_SLICE-1));} if(thread_idx == 8) {idx=(2*(IMG_H_SLICE-1)); jdx=(thread_idx*(IMG_W_SLICE-1));} if(thread_idx == 9) {idx=(2*(IMG_H_SLICE-1)); jdx=(thread_idx*(IMG_W_SLICE-1));} if(thread_idx == 10) {idx=(2*(IMG_H_SLICE-1)); jdx=(thread_idx*(IMG_W_SLICE-1));} if(thread_idx == 11) {idx=(2*(IMG_H_SLICE-1)); jdx=(thread_idx*(IMG_W_SLICE-1));} //printf("idx=%d, jdx=%d\n", idx, jdx); threadarg[thread_idx].i=idx; threadarg[thread_idx].h=IMG_H_SLICE-1; threadarg[thread_idx].j=jdx; threadarg[thread_idx].w=IMG_W_SLICE-1; threadarg[thread_idx].iterations=ITERATIONS; //printf("create thread_idx=%d\n", thread_idx); pthread_create(&threads[thread_idx], (void *)0, sharpen_thread, (void *)&threadarg[thread_idx]); } for(thread_idx=0; thread_idx<(NUM_ROW_THREADS*NUM_COL_THREADS); thread_idx++) { printf("join thread_idx=%d\n", thread_idx); if((pthread_join(threads[thread_idx], (void **)0)) < 0) perror("pthread_join"); } printf("create run=%d ", runs); } clock_gettime(CLOCK_MONOTONIC, &now); fnow = (FLOAT)now.tv_sec + (FLOAT)now.tv_nsec / 1000000000.0; printf("\nCompleted test at %lf for %d creat-to-join and %lf FPS\n\n", fnow - fstart, runs, (fnow-fstart)/(FLOAT)ITERATIONS); printf("Starting output file %s write\n", argv[2]); rc=write(fdout, (void *)header, 21); #ifdef FAST_IO clock_gettime(CLOCK_MONOTONIC, &now); fnow = (FLOAT)now.tv_sec + (FLOAT)now.tv_nsec / 1000000000.0; fstart = (FLOAT)now.tv_sec + (FLOAT)now.tv_nsec / 1000000000.0; printf("\nstart test input at %lf\n", fnow - fstart); // create in memory copy from input by channel for(i=0, pixel=0; i<IMG_HEIGHT; i++) { for(j=0; j<IMG_WIDTH; j++) { RGB[pixel+0]=convR[i][j]; RGB[pixel+1]=convG[i][j]; RGB[pixel+2]=convB[i][j]; pixel+=3; } } bytesWritten=0; bytesLeft=IMG_HEIGHT*IMG_WIDTH*3; writecnt=0; printf("START: write %d, bytesWritten=%d, bytesLeft=%d\n", writecnt, bytesWritten, bytesLeft); // Write RGB data in large chunks, requesting all at once and writing residual do { bytesWritten=write(fdout, (void *)&RGB[bytesWritten], bytesLeft); bytesLeft -= bytesWritten; writecnt++; printf("write %d, bytesWritten=%d, bytesLeft=%d\n", writecnt, bytesWritten, bytesLeft); } while((bytesLeft > 0) && (writecnt < 3)); printf("END: write %d, bytesWritten=%d, bytesLeft=%d\n", writecnt, bytesWritten, bytesLeft); clock_gettime(CLOCK_MONOTONIC, &now); fnow = (FLOAT)now.tv_sec + (FLOAT)now.tv_nsec / 1000000000.0; printf("\ncompleted test input at %lf\n", fnow - fstart); #else // Write RGB data - very slow 1 byte at a time! for(i=0; i<IMG_HEIGHT; i++) { for(j=0; j<IMG_WIDTH; j+=1) { rc=write(fdout, (void *)&convR[i][j], 1); rc=write(fdout, (void *)&convG[i][j], 1); rc=write(fdout, (void *)&convB[i][j], 1); } } #endif printf("Output file %s written\n", argv[2]); close(fdout); }
the_stack_data/218893246.c
#include <stdio.h> #include <string.h> const int _ORIGIN_ = 0; const char _DELIM_ = ' '; const char _NEW_LINE_ = '\n'; const char _TAB_ = '\t'; int main( int argc, char *argv[] ) { char firstDelimFlag = 'F', lastDelimFlag = 'T', gramFile[100], tempChar; FILE *ipFile, *opFile; int delimCnt = 0, firstDelimPos, charRead; if( argc < 3 ) { printf( "Invalid no of arguments\n" ); printf( "Usage: ./fileSplitter <file to be splitted> <no of grams required>\n" ); return 1; } ipFile = fopen( argv[1], "r" ); if ( NULL == ipFile ) { perror( "Error opening file" ); return 1; } strcat( gramFile, argv[1] ); strcat( gramFile, argv[2] ); opFile = fopen( gramFile, "w" ); if ( NULL == ipFile ) { perror( "Error opening file" ); return 1; } const int gramLimit = atoi( argv[2] ); while ( !feof( ipFile ) ){ charRead = fgetc( ipFile ); if ( ( _DELIM_ == charRead ) || ( _NEW_LINE_ == charRead ) || ( _TAB_ == charRead ) ) { tempChar = fgetc( ipFile ); while ( ( tempChar == _NEW_LINE_ ) || ( tempChar == _DELIM_ ) || ( tempChar == _TAB_ ) ) { tempChar = fgetc( ipFile ); } if( EOF == tempChar ) break; fseek ( ipFile, ftell ( ipFile ) - 1, _ORIGIN_ ); if( ( _NEW_LINE_ == charRead ) || ( _TAB_ == charRead ) ) charRead = _DELIM_; if( _DELIM_ == charRead ) { if ( 'F' == firstDelimFlag ){ firstDelimPos = ftell( ipFile ); firstDelimFlag = 'T'; } ++delimCnt; if ( delimCnt == gramLimit ){ fseek( ipFile, firstDelimPos, _ORIGIN_ ); firstDelimFlag = 'F'; charRead = _NEW_LINE_; delimCnt = 0; } } } fputc( charRead, opFile ); } fclose(ipFile); fclose(opFile); return 0; }
the_stack_data/72052.c
/* * Copyright 2015 The SageTV Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <stdlib.h> #include <math.h> double trunctest(double x) { if (!finite (x)) return x; if (x < 0.0) return - floor (-x); else return floor (x); } float truncf(float f) { return (float) trunctest((double) f); }
the_stack_data/55714.c
/* * We are given 5 integer numbers. Write a program that finds all subsets of * these numbers whose sum is 0. Assume that repeating the same subset several * times is not a problem. Examples: numbers result 3 -2 1 1 8 -2 + 1 + 1 = 0 * 3 1 -7 35 22 no zero subset * 1 3 -4 -2 -1 1 + -1 = 0 1 + 3 + -4 = 0 3 + -2 + -1 = 0 * 1 1 1 -1 -1 1 + -1 = 0 1 + 1 + -1 + -1 = 0 1 + -1 + 1 + -1 = 0 โ€ฆ 0 0 0 0 0 0 + 0 + 0 + 0 + 0 = 0 Hint: you may check for zero each of the 32 subsets with 32 if statements. */ #include <stdio.h> int main() { int a, b, c, d, e; printf("a = "); scanf("%d", &a); printf("b = "); scanf("%d", &b); printf("c = "); scanf("%d", &c); printf("d = "); scanf("%d", &d); printf("e = "); scanf("%d", &e); int isZeroSubset = 0; // one number subset -> check sum = 0 if (a == 0) { isZeroSubset = 1; printf("%d\n", a); } if (b == 0) { isZeroSubset = 1; printf("%d\n", b); } if (c == 0) { isZeroSubset = 1; printf("%d\n", c); } if (d == 0) { isZeroSubset = 1; printf("%d\n", d); } if (e == 0) { isZeroSubset = 1; printf("%d\n", e); } // two numbers subsets -> check to sum = 0 if (a + b == 0) { isZeroSubset = 1; printf("%d + %d = %d\n", a, b, a + b); } if (a + c == 0) { isZeroSubset = 1; printf("%d + %d = %d\n", a, c, a + c); } if (a + d == 0) { isZeroSubset = 1; printf("%d + %d = %d\n", a, d, a + d); } if (a + e == 0) { isZeroSubset = 1; printf("%d + %d = %d\n", a, e, a + e); } if (b + c == 0) { isZeroSubset = 1; printf("%d + %d = %d\n", b, c, b + c); } if (b + d == 0) { isZeroSubset = 1; printf("%d + %d = %d\n", b, d, b + d); } if (b + e == 0) { isZeroSubset = 1; printf("%d + %d = %d\n", b, e, b + e); } if (c + d == 0) { isZeroSubset = 1; printf("%d + %d = %d\n", c, d, c + d); } if (c + e == 0) { isZeroSubset = 1; printf("%d + %d = %d\n", c, e, c + e); } if (d + e == 0) { isZeroSubset = 1; printf("%d + %d = %d\n", d, e, d + e); } // three numbers subsets -> check to sum = 0 if (a + b + c == 0) { isZeroSubset = 1; printf("%d + %d + %d = %d\n", a, b, c, a + b + c); } if (a + b + d == 0) { isZeroSubset = 1; printf("%d + %d + %d = %d\n", a, b, d, a + b + d); } if (a + b + e == 0) { isZeroSubset = 1; printf("%d + %d + %d = %d\n", a, b, e, a + b + e); } if (a + c + d == 0) { isZeroSubset = 1; printf("%d + %d + %d = %d\n", a, c, d, a + c + d); } if (a + c + e == 0) { isZeroSubset = 1; printf("%d + %d + %d = %d\n", a, c, e, a + c + e); } if (a + d + e == 0) { isZeroSubset = 1; printf("%d + %d + %d = %d\n", a, d, e, a + d + e); } if (b + c + d == 0) { isZeroSubset = 1; printf("%d + %d + %d = %d\n", b, c, d, b + c + d); } if (b + c + e == 0) { isZeroSubset = 1; printf("%d + %d + %d = %d\n", b, c, e, b + c + e); } if (b + d + e == 0) { isZeroSubset = 1; printf("%d + %d + %d = %d\n", b, d, e, b + d + e); } if (c + d + e == 0) { isZeroSubset = 1; printf("%d + %d + %d = %d\n", c, d, e, c + d + e); } // four numbers subsets -> check to sum = 0 if (a + b + c + d == 0) { isZeroSubset = 1; printf("%d + %d + %d + %d = %d\n", a, b, c, d, a + b + c + d); } if (a + b + c + e == 0) { isZeroSubset = 1; printf("%d + %d + %d + %d = %d\n", a, b, c, e, a + b + c + e); } if (a + b + d + e == 0) { isZeroSubset = 1; printf("%d + %d + %d + %d = %d\n", a, b, d, e, a + b + d + e); } if (b + c + d + e == 0) { isZeroSubset = 1; printf("%d + %d + %d + %d = %d\n", b, c, d, e, b + c + d + e); } if (c + a + d + e == 0) { isZeroSubset = 1; printf("%d + %d + %d + %d = %d\n", c, a, d, e, c + a + d + e); } // five numbers subsets -> check to sum = 0 if (a + b + c + d + e == 0) { isZeroSubset = 1; printf("%d + %d + %d + %d + %d = %d\n", a, b, c, d, e, a + b + c + d + e); } if(!isZeroSubset){ printf("no zero subset\n"); } return 0; }
the_stack_data/45449888.c
#include <stdio.h> #include <stdlib.h> #include <assert.h> #include <string.h> #define BASE_10 10 void ex_atoi() { int i = atoi("55"); assert(i == 55); i = atoi("abc"); // zero is not guaranteed by the standard! assert(i == 0); } void ex_strtol() { char *numstr = "12345EightyEight"; char *last; long result = strtol(numstr, &last, BASE_10); assert(result == 12345); assert(strcmp(last, "EightyEight") == 0); } int main(void) { ex_atoi(); ex_strtol(); return 0; }
the_stack_data/1104632.c
#include <stdio.h> #include <stdlib.h> #include <time.h> int main(void){ int palpite, correto; srand(time(NULL)); correto = rand() % 100; palpite = -1; while (palpite != correto) { printf("Adivinhe o numero: "); scanf("%d", &palpite); if (palpite > correto){ puts("Palpite alto!"); }else if (palpite < correto){ puts("Palpite foi baixo!"); } } puts("Voce acertou!"); return 0; }
the_stack_data/92514.c
#include <stdio.h> #define ALUNOS 10 #define DISCIPLINAS 5 #define DIM 80 long score_disciplina(int disciplina, int valores[ALUNOS][DISCIPLINAS]) { int i, score = 0; for (i = 0; i < ALUNOS; i++) score += valores[i][disciplina]; return score; } long score_aluno(int aluno, int valores[ALUNOS][DISCIPLINAS]) { int i, score = 0; for (i = 0; i < DISCIPLINAS; i++) score += valores[aluno][i]; return score; } int main() { int valores[ALUNOS][DISCIPLINAS], n_inputs = 0, i, aluno, disc, a, d, v, max_n = 0, max_score = -100; scanf("%d", &n_inputs); for (aluno = 0; aluno < ALUNOS; aluno++) { for (disc = 0; disc < DISCIPLINAS; disc++) { valores[aluno][disc] = 0; } } for (i = 0; i < n_inputs; i++) { scanf("%d", &a); scanf("%d", &d); scanf("%d", &v); valores[a][d] = v; } for (i = 0; i < DISCIPLINAS; i++) { if (score_disciplina(i, valores) > max_score) { max_score = score_disciplina(i, valores); max_n = i; } } printf("%d\n", max_n); max_score = -100; for (i = 0; i < ALUNOS; i++) { if (score_aluno(i, valores) > max_score) { max_score = score_aluno(i, valores); max_n = i; } } printf("%d\n", max_n); return 0; }
the_stack_data/12637024.c
#include <stdio.h> #include <stdlib.h> struct node { int val; struct node *prv, *nxt; }; struct node *current; struct node *create_node(int val) { struct node *n; n = (struct node *) malloc(sizeof(struct node *)); n->val = val; return n; } void move_node(int n) { for( int i=0; i<abs(n); i++ ) current = n < 0 ? current->prv : current->nxt; } void insert_node(int val) { struct node *n, *new; n = current; new = create_node(val); new->prv = current; new->nxt = current->nxt; new->nxt->prv = new; new->prv->nxt = new; current = new; } unsigned int pop() { struct node *n; int val; n = current; n->prv->nxt = n->nxt; n->nxt->prv = n->prv; val = n->val; current = n->nxt; free(n); return (unsigned int) val; } unsigned int run_game(int pl, int high) { unsigned int *scores, max = 0; int i, player; struct node *zero, *n, *m; scores = (unsigned int *) malloc(pl * sizeof(unsigned int)); for( i=0; i<pl; i++ ) scores[i] = 0; zero = create_node(0); zero->prv = zero; zero->nxt = zero; current = zero; for( i=0; i<high; i++ ) { player = i % pl; if( (i+1) % 23 == 0 ) { move_node(-7); scores[player] += (unsigned int) i + pop() + 1; } else { move_node(1); insert_node(i+1); } } for( i=0; i<pl; i++ ) if( max < scores[i] ) max = scores[i]; for( n = zero->nxt, m = zero->nxt->nxt; m != zero; n = m ) { m = n->nxt; free(n); } free(zero); return max; } int main(int argc, char *argv[]) { FILE *fd; int players, high_marble; if( !(fd = fopen(argc == 1 ? "09-input.txt" : argv[1], "r")) ) return printf("09-input: cannot open\n"), 1; fscanf(fd, "%d players; last marble is worth %d points", &players, &high_marble); printf("%u\n", run_game(players, high_marble)); printf("%u\n", run_game(players, high_marble*100)); }
the_stack_data/22011518.c
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> #include <string.h> int main(int argc, char* argv[]) { int fd; char c; if (argc != 4) { puts("Errore nel numero di parametri"); exit(1); } if ((fd = open(argv[1], O_RDWR)) < 0) { puts("Errore in apertura file"); exit(2); } if (strlen(argv[2]) != 1) { puts("Errore non carattere"); exit(3); } if (strlen(argv[3]) != 1) { puts("Errore non carattere"); exit(4); } while (read(fd, &c, 1)) { if (c == argv[2][0]) { lseek(fd, -1L, SEEK_CUR); write(fd, &argv[3][0], 1); } } return 0; }
the_stack_data/11075455.c
#include <stdio.h> #include <stdlib.h> #define LIMIT 1000000 int main(int argc, char const *argv[]) { unsigned int i, num, terms, max_terms = 0, max_number; for (i = 1; i <= LIMIT; ++i) { terms = 1; num = i; while (num != 1) { terms++; if (num % 2 == 1) { num = (num * 3) + 1; } else { num = num / 2; } } if (terms > max_terms) { max_terms = terms; max_number = i; } } printf("Number with maximum terms: %d, with %d terms.\n", max_number, max_terms); return 0; }
the_stack_data/225142757.c
# 1 "imf3.c" # 1 "imf3.c" 1 # 1 "<built-in>" 1 # 1 "<built-in>" 3 # 147 "<built-in>" 3 # 1 "<command line>" 1 # 1 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/common/technology/autopilot\\etc/autopilot_ssdm_op.h" 1 /* autopilot_ssdm_op.h*/ /* #- (c) Copyright 2011-2015 Xilinx, Inc. All rights reserved. #- #- This file contains confidential and proprietary information #- of Xilinx, Inc. and is protected under U.S. and #- international copyright and other intellectual property #- laws. #- #- DISCLAIMER #- This disclaimer is not a license and does not grant any #- rights to the materials distributed herewith. Except as #- otherwise provided in a valid license issued to you by #- Xilinx, and to the maximum extent permitted by applicable #- law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND #- WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES #- AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING #- BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON- #- INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and #- (2) Xilinx shall not be liable (whether in contract or tort, #- including negligence, or under any other theory of #- liability) for any loss or damage of any kind or nature #- related to, arising under or in connection with these #- materials, including for any direct, or any indirect, #- special, incidental, or consequential loss or damage #- (including loss of data, profits, goodwill, or any type of #- loss or damage suffered as a result of any action brought #- by a third party) even if such damage or loss was #- reasonably foreseeable or Xilinx had been advised of the #- possibility of the same. #- #- CRITICAL APPLICATIONS #- Xilinx products are not designed or intended to be fail- #- safe, or for use in any application requiring fail-safe #- performance, such as life-support or safety devices or #- systems, Class III medical devices, nuclear facilities, #- applications related to the deployment of airbags, or any #- other applications that could lead to death, personal #- injury, or severe property or environmental damage #- (individually and collectively, "Critical #- Applications"). Customer assumes the sole risk and #- liability of any use of Xilinx products in Critical #- Applications, subject only to applicable laws and #- regulations governing limitations on product liability. #- #- THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS #- PART OF THIS FILE AT ALL TIMES. #- ************************************************************************ * * $Id$ */ # 280 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/common/technology/autopilot\\etc/autopilot_ssdm_op.h" /*#define AP_SPEC_ATTR __attribute__ ((pure))*/ /****** SSDM Intrinsics: OPERATIONS ***/ // Interface operations //typedef unsigned int __attribute__ ((bitwidth(1))) _uint1_; void _ssdm_op_IfRead() __attribute__ ((nothrow)); void _ssdm_op_IfWrite() __attribute__ ((nothrow)); //_uint1_ _ssdm_op_IfNbRead() SSDM_OP_ATTR; //_uint1_ _ssdm_op_IfNbWrite() SSDM_OP_ATTR; //_uint1_ _ssdm_op_IfCanRead() SSDM_OP_ATTR; //_uint1_ _ssdm_op_IfCanWrite() SSDM_OP_ATTR; // Stream Intrinsics void _ssdm_StreamRead() __attribute__ ((nothrow)); void _ssdm_StreamWrite() __attribute__ ((nothrow)); //_uint1_ _ssdm_StreamNbRead() SSDM_OP_ATTR; //_uint1_ _ssdm_StreamNbWrite() SSDM_OP_ATTR; //_uint1_ _ssdm_StreamCanRead() SSDM_OP_ATTR; //_uint1_ _ssdm_StreamCanWrite() SSDM_OP_ATTR; // Misc void _ssdm_op_MemShiftRead() __attribute__ ((nothrow)); void _ssdm_op_Wait() __attribute__ ((nothrow)); void _ssdm_op_Poll() __attribute__ ((nothrow)); void _ssdm_op_Return() __attribute__ ((nothrow)); /* SSDM Intrinsics: SPECIFICATIONS */ void _ssdm_op_SpecSynModule() __attribute__ ((nothrow)); void _ssdm_op_SpecTopModule() __attribute__ ((nothrow)); void _ssdm_op_SpecProcessDecl() __attribute__ ((nothrow)); void _ssdm_op_SpecProcessDef() __attribute__ ((nothrow)); void _ssdm_op_SpecPort() __attribute__ ((nothrow)); void _ssdm_op_SpecConnection() __attribute__ ((nothrow)); void _ssdm_op_SpecChannel() __attribute__ ((nothrow)); void _ssdm_op_SpecSensitive() __attribute__ ((nothrow)); void _ssdm_op_SpecModuleInst() __attribute__ ((nothrow)); void _ssdm_op_SpecPortMap() __attribute__ ((nothrow)); void _ssdm_op_SpecReset() __attribute__ ((nothrow)); void _ssdm_op_SpecPlatform() __attribute__ ((nothrow)); void _ssdm_op_SpecClockDomain() __attribute__ ((nothrow)); void _ssdm_op_SpecPowerDomain() __attribute__ ((nothrow)); int _ssdm_op_SpecRegionBegin() __attribute__ ((nothrow)); int _ssdm_op_SpecRegionEnd() __attribute__ ((nothrow)); void _ssdm_op_SpecLoopName() __attribute__ ((nothrow)); void _ssdm_op_SpecLoopTripCount() __attribute__ ((nothrow)); int _ssdm_op_SpecStateBegin() __attribute__ ((nothrow)); int _ssdm_op_SpecStateEnd() __attribute__ ((nothrow)); void _ssdm_op_SpecInterface() __attribute__ ((nothrow)); void _ssdm_op_SpecPipeline() __attribute__ ((nothrow)); void _ssdm_op_SpecDataflowPipeline() __attribute__ ((nothrow)); void _ssdm_op_SpecLatency() __attribute__ ((nothrow)); void _ssdm_op_SpecParallel() __attribute__ ((nothrow)); void _ssdm_op_SpecProtocol() __attribute__ ((nothrow)); void _ssdm_op_SpecOccurrence() __attribute__ ((nothrow)); void _ssdm_op_SpecResource() __attribute__ ((nothrow)); void _ssdm_op_SpecResourceLimit() __attribute__ ((nothrow)); void _ssdm_op_SpecCHCore() __attribute__ ((nothrow)); void _ssdm_op_SpecFUCore() __attribute__ ((nothrow)); void _ssdm_op_SpecIFCore() __attribute__ ((nothrow)); void _ssdm_op_SpecIPCore() __attribute__ ((nothrow)); void _ssdm_op_SpecKeepValue() __attribute__ ((nothrow)); void _ssdm_op_SpecMemCore() __attribute__ ((nothrow)); void _ssdm_op_SpecExt() __attribute__ ((nothrow)); /*void* _ssdm_op_SpecProcess() SSDM_SPEC_ATTR; void* _ssdm_op_SpecEdge() SSDM_SPEC_ATTR; */ /* Presynthesis directive functions */ void _ssdm_SpecArrayDimSize() __attribute__ ((nothrow)); void _ssdm_RegionBegin() __attribute__ ((nothrow)); void _ssdm_RegionEnd() __attribute__ ((nothrow)); void _ssdm_Unroll() __attribute__ ((nothrow)); void _ssdm_UnrollRegion() __attribute__ ((nothrow)); void _ssdm_InlineAll() __attribute__ ((nothrow)); void _ssdm_InlineLoop() __attribute__ ((nothrow)); void _ssdm_Inline() __attribute__ ((nothrow)); void _ssdm_InlineSelf() __attribute__ ((nothrow)); void _ssdm_InlineRegion() __attribute__ ((nothrow)); void _ssdm_SpecArrayMap() __attribute__ ((nothrow)); void _ssdm_SpecArrayPartition() __attribute__ ((nothrow)); void _ssdm_SpecArrayReshape() __attribute__ ((nothrow)); void _ssdm_SpecStream() __attribute__ ((nothrow)); void _ssdm_SpecExpr() __attribute__ ((nothrow)); void _ssdm_SpecExprBalance() __attribute__ ((nothrow)); void _ssdm_SpecDependence() __attribute__ ((nothrow)); void _ssdm_SpecLoopMerge() __attribute__ ((nothrow)); void _ssdm_SpecLoopFlatten() __attribute__ ((nothrow)); void _ssdm_SpecLoopRewind() __attribute__ ((nothrow)); void _ssdm_SpecFuncInstantiation() __attribute__ ((nothrow)); void _ssdm_SpecFuncBuffer() __attribute__ ((nothrow)); void _ssdm_SpecFuncExtract() __attribute__ ((nothrow)); void _ssdm_SpecConstant() __attribute__ ((nothrow)); void _ssdm_DataPack() __attribute__ ((nothrow)); void _ssdm_SpecDataPack() __attribute__ ((nothrow)); void _ssdm_op_SpecBitsMap() __attribute__ ((nothrow)); void _ssdm_op_SpecLicense() __attribute__ ((nothrow)); /*#define _ssdm_op_WaitUntil(X) while (!(X)) _ssdm_op_Wait(1); #define _ssdm_op_Delayed(X) X */ # 7 "<command line>" 2 # 1 "<built-in>" 2 # 1 "imf3.c" 2 # 1 "./duc.h" 1 # 1 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/common/technology/autopilot\\ap_cint.h" 1 /* ap_cint.h */ /* #- (c) Copyright 2011-2015 Xilinx, Inc. All rights reserved. #- #- This file contains confidential and proprietary information #- of Xilinx, Inc. and is protected under U.S. and #- international copyright and other intellectual property #- laws. #- #- DISCLAIMER #- This disclaimer is not a license and does not grant any #- rights to the materials distributed herewith. Except as #- otherwise provided in a valid license issued to you by #- Xilinx, and to the maximum extent permitted by applicable #- law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND #- WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES #- AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING #- BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON- #- INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and #- (2) Xilinx shall not be liable (whether in contract or tort, #- including negligence, or under any other theory of #- liability) for any loss or damage of any kind or nature #- related to, arising under or in connection with these #- materials, including for any direct, or any indirect, #- special, incidental, or consequential loss or damage #- (including loss of data, profits, goodwill, or any type of #- loss or damage suffered as a result of any action brought #- by a third party) even if such damage or loss was #- reasonably foreseeable or Xilinx had been advised of the #- possibility of the same. #- #- CRITICAL APPLICATIONS #- Xilinx products are not designed or intended to be fail- #- safe, or for use in any application requiring fail-safe #- performance, such as life-support or safety devices or #- systems, Class III medical devices, nuclear facilities, #- applications related to the deployment of airbags, or any #- other applications that could lead to death, personal #- injury, or severe property or environmental damage #- (individually and collectively, "Critical #- Applications"). Customer assumes the sole risk and #- liability of any use of Xilinx products in Critical #- Applications, subject only to applicable laws and #- regulations governing limitations on product liability. #- #- THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS #- PART OF THIS FILE AT ALL TIMES. #- ************************************************************************ * * $Id$ */ # 62 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/common/technology/autopilot\\ap_cint.h" # 1 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\string.h" 1 3 /** * This file has no copyright assigned and is placed in the Public Domain. * This file is part of the w64 mingw-runtime package. * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ # 1 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\_mingw.h" 1 3 /** * This file has no copyright assigned and is placed in the Public Domain. * This file is part of the w64 mingw-runtime package. * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ # 1 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include/_mingw_mac.h" 1 3 /** * This file has no copyright assigned and is placed in the Public Domain. * This file is part of the w64 mingw-runtime package. * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ # 18 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include/_mingw_mac.h" 3 /* mingw.org's version macros: these make gcc to define MINGW32_SUPPORTS_MT_EH and to use the _CRT_MT global and the __mingwthr_key_dtor() function from the MinGW CRT in its private gthr-win32.h header. */ /* MS does not prefix symbols by underscores for 64-bit. */ /* As we have to support older gcc version, which are using underscores as symbol prefix for x64, we have to check here for the user label prefix defined by gcc. */ # 62 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include/_mingw_mac.h" 3 /* Use alias for msvcr80 export of get/set_output_format. */ /* Set VC specific compiler target macros. */ # 10 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\_mingw.h" 2 3 /* C/C++ specific language defines. */ # 32 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\_mingw.h" 3 /* Note the extern. This is needed to work around GCC's limitations in handling dllimport attribute. */ # 147 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\_mingw.h" 3 /* Attribute `nonnull' was valid as of gcc 3.3. We don't use GCC's variadiac macro facility, because variadic macros cause syntax errors with --traditional-cpp. */ # 225 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\_mingw.h" 3 /* High byte is the major version, low byte is the minor. */ # 247 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\_mingw.h" 3 /*typedef int __int128 __attribute__ ((__mode__ (TI)));*/ # 277 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\_mingw.h" 3 # 1 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\vadefs.h" 1 3 /** * This file has no copyright assigned and is placed in the Public Domain. * This file is part of the w64 mingw-runtime package. * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ # 1 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\_mingw.h" 1 3 /** * This file has no copyright assigned and is placed in the Public Domain. * This file is part of the w64 mingw-runtime package. * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ # 674 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\_mingw.h" 3 # 1 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include/sdks/_mingw_directx.h" 1 3 # 674 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\_mingw.h" 2 3 # 1 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include/sdks/_mingw_ddk.h" 1 3 # 675 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\_mingw.h" 2 3 # 13 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\vadefs.h" 2 3 #pragma pack(push,_CRT_PACKING) typedef __builtin_va_list __gnuc_va_list; typedef __gnuc_va_list va_list; # 46 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\vadefs.h" 3 /* Use GCC builtins */ # 102 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\vadefs.h" 3 #pragma pack(pop) # 277 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\_mingw.h" 2 3 #pragma pack(push,_CRT_PACKING) # 316 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\_mingw.h" 3 /* We have to define _DLL for gcc based mingw version. This define is set by VC, when DLL-based runtime is used. So, gcc based runtime just have DLL-base runtime, therefore this define has to be set. As our headers are possibly used by windows compiler having a static C-runtime, we make this definition gnu compiler specific here. */ # 370 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\_mingw.h" 3 __extension__ typedef unsigned long long size_t; # 380 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\_mingw.h" 3 __extension__ typedef long long ssize_t; # 392 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\_mingw.h" 3 __extension__ typedef long long intptr_t; # 405 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\_mingw.h" 3 __extension__ typedef unsigned long long uintptr_t; # 418 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\_mingw.h" 3 __extension__ typedef long long ptrdiff_t; # 428 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\_mingw.h" 3 typedef unsigned short wchar_t; typedef unsigned short wint_t; typedef unsigned short wctype_t; # 456 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\_mingw.h" 3 typedef int errno_t; typedef long __time32_t; __extension__ typedef long long __time64_t; typedef __time64_t time_t; # 518 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\_mingw.h" 3 /* _dowildcard is an int that controls the globbing of the command line. * The MinGW32 (mingw.org) runtime calls it _CRT_glob, so we are adding * a compatibility definition here: you can use either of _CRT_glob or * _dowildcard . * If _dowildcard is non-zero, the command line will be globbed: *.* * will be expanded to be all files in the startup directory. * In the mingw-w64 library a _dowildcard variable is defined as being * 0, therefore command line globbing is DISABLED by default. To turn it * on and to leave wildcard command line processing MS's globbing code, * include a line in one of your source modules defining _dowildcard and * setting it to -1, like so: * int _dowildcard = -1; */ # 605 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\_mingw.h" 3 /* MSVC-isms: */ struct threadlocaleinfostruct; struct threadmbcinfostruct; typedef struct threadlocaleinfostruct *pthreadlocinfo; typedef struct threadmbcinfostruct *pthreadmbcinfo; struct __lc_time_data; typedef struct localeinfo_struct { pthreadlocinfo locinfo; pthreadmbcinfo mbcinfo; } _locale_tstruct,*_locale_t; typedef struct tagLC_ID { unsigned short wLanguage; unsigned short wCountry; unsigned short wCodePage; } LC_ID,*LPLC_ID; typedef struct threadlocaleinfostruct { int refcount; unsigned int lc_codepage; unsigned int lc_collate_cp; unsigned long lc_handle[6]; LC_ID lc_id[6]; struct { char *locale; wchar_t *wlocale; int *refcount; int *wrefcount; } lc_category[6]; int lc_clike; int mb_cur_max; int *lconv_intl_refcount; int *lconv_num_refcount; int *lconv_mon_refcount; struct lconv *lconv; int *ctype1_refcount; unsigned short *ctype1; const unsigned short *pctype; const unsigned char *pclmap; const unsigned char *pcumap; struct __lc_time_data *lc_time_curr; } threadlocinfo; /* mingw-w64 specific functions: */ const char *__mingw_get_crt_info (void); #pragma pack(pop) # 9 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\string.h" 2 3 # 36 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\string.h" 3 __attribute__ ((__dllimport__)) void * _memccpy(void *_Dst,const void *_Src,int _Val,size_t _MaxCount); void * memchr(const void *_Buf ,int _Val,size_t _MaxCount); __attribute__ ((__dllimport__)) int _memicmp(const void *_Buf1,const void *_Buf2,size_t _Size); __attribute__ ((__dllimport__)) int _memicmp_l(const void *_Buf1,const void *_Buf2,size_t _Size,_locale_t _Locale); int memcmp(const void *_Buf1,const void *_Buf2,size_t _Size); void * memcpy(void * __restrict__ _Dst,const void * __restrict__ _Src,size_t _Size) ; void * memset(void *_Dst,int _Val,size_t _Size); void * memccpy(void *_Dst,const void *_Src,int _Val,size_t _Size) ; int memicmp(const void *_Buf1,const void *_Buf2,size_t _Size) ; char * _strset(char *_Str,int _Val) ; char * _strset_l(char *_Str,int _Val,_locale_t _Locale) ; char * strcpy(char * __restrict__ _Dest,const char * __restrict__ _Source); char * strcat(char * __restrict__ _Dest,const char * __restrict__ _Source); int strcmp(const char *_Str1,const char *_Str2); size_t strlen(const char *_Str); size_t strnlen(const char *_Str,size_t _MaxCount); void * memmove(void *_Dst,const void *_Src,size_t _Size) ; __attribute__ ((__dllimport__)) char * _strdup(const char *_Src); char * strchr(const char *_Str,int _Val); __attribute__ ((__dllimport__)) int _stricmp(const char *_Str1,const char *_Str2); __attribute__ ((__dllimport__)) int _strcmpi(const char *_Str1,const char *_Str2); __attribute__ ((__dllimport__)) int _stricmp_l(const char *_Str1,const char *_Str2,_locale_t _Locale); int strcoll(const char *_Str1,const char *_Str2); __attribute__ ((__dllimport__)) int _strcoll_l(const char *_Str1,const char *_Str2,_locale_t _Locale); __attribute__ ((__dllimport__)) int _stricoll(const char *_Str1,const char *_Str2); __attribute__ ((__dllimport__)) int _stricoll_l(const char *_Str1,const char *_Str2,_locale_t _Locale); __attribute__ ((__dllimport__)) int _strncoll (const char *_Str1,const char *_Str2,size_t _MaxCount); __attribute__ ((__dllimport__)) int _strncoll_l(const char *_Str1,const char *_Str2,size_t _MaxCount,_locale_t _Locale); __attribute__ ((__dllimport__)) int _strnicoll (const char *_Str1,const char *_Str2,size_t _MaxCount); __attribute__ ((__dllimport__)) int _strnicoll_l(const char *_Str1,const char *_Str2,size_t _MaxCount,_locale_t _Locale); size_t strcspn(const char *_Str,const char *_Control); __attribute__ ((__dllimport__)) char * _strerror(const char *_ErrMsg) ; char * strerror(int) ; __attribute__ ((__dllimport__)) char * _strlwr(char *_String) ; char *strlwr_l(char *_String,_locale_t _Locale) ; char * strncat(char * __restrict__ _Dest,const char * __restrict__ _Source,size_t _Count) ; int strncmp(const char *_Str1,const char *_Str2,size_t _MaxCount); __attribute__ ((__dllimport__)) int _strnicmp(const char *_Str1,const char *_Str2,size_t _MaxCount); __attribute__ ((__dllimport__)) int _strnicmp_l(const char *_Str1,const char *_Str2,size_t _MaxCount,_locale_t _Locale); char *strncpy(char * __restrict__ _Dest,const char * __restrict__ _Source,size_t _Count) ; __attribute__ ((__dllimport__)) char * _strnset(char *_Str,int _Val,size_t _MaxCount) ; __attribute__ ((__dllimport__)) char * _strnset_l(char *str,int c,size_t count,_locale_t _Locale) ; char * strpbrk(const char *_Str,const char *_Control); char * strrchr(const char *_Str,int _Ch); __attribute__ ((__dllimport__)) char * _strrev(char *_Str); size_t strspn(const char *_Str,const char *_Control); char * strstr(const char *_Str,const char *_SubStr); char * strtok(char * __restrict__ _Str,const char * __restrict__ _Delim) ; __attribute__ ((__dllimport__)) char * _strupr(char *_String) ; __attribute__ ((__dllimport__)) char *_strupr_l(char *_String,_locale_t _Locale) ; size_t strxfrm(char * __restrict__ _Dst,const char * __restrict__ _Src,size_t _MaxCount); __attribute__ ((__dllimport__)) size_t _strxfrm_l(char * __restrict__ _Dst,const char * __restrict__ _Src,size_t _MaxCount,_locale_t _Locale); char * strdup(const char *_Src) ; int strcmpi(const char *_Str1,const char *_Str2) ; int stricmp(const char *_Str1,const char *_Str2) ; char * strlwr(char *_Str) ; int strnicmp(const char *_Str1,const char *_Str,size_t _MaxCount) ; int strncasecmp (const char *, const char *, size_t); int strcasecmp (const char *, const char *); char * strnset(char *_Str,int _Val,size_t _MaxCount) ; char * strrev(char *_Str) ; char * strset(char *_Str,int _Val) ; char * strupr(char *_Str) ; __attribute__ ((__dllimport__)) wchar_t * _wcsdup(const wchar_t *_Str); wchar_t * wcscat(wchar_t * __restrict__ _Dest,const wchar_t * __restrict__ _Source) ; wchar_t * wcschr(const wchar_t *_Str,wchar_t _Ch); int wcscmp(const wchar_t *_Str1,const wchar_t *_Str2); wchar_t * wcscpy(wchar_t * __restrict__ _Dest,const wchar_t * __restrict__ _Source) ; size_t wcscspn(const wchar_t *_Str,const wchar_t *_Control); size_t wcslen(const wchar_t *_Str); size_t wcsnlen(const wchar_t *_Src,size_t _MaxCount); wchar_t *wcsncat(wchar_t * __restrict__ _Dest,const wchar_t * __restrict__ _Source,size_t _Count) ; int wcsncmp(const wchar_t *_Str1,const wchar_t *_Str2,size_t _MaxCount); wchar_t *wcsncpy(wchar_t * __restrict__ _Dest,const wchar_t * __restrict__ _Source,size_t _Count) ; wchar_t * _wcsncpy_l(wchar_t * __restrict__ _Dest,const wchar_t * __restrict__ _Source,size_t _Count,_locale_t _Locale) ; wchar_t * wcspbrk(const wchar_t *_Str,const wchar_t *_Control); wchar_t * wcsrchr(const wchar_t *_Str,wchar_t _Ch); size_t wcsspn(const wchar_t *_Str,const wchar_t *_Control); wchar_t * wcsstr(const wchar_t *_Str,const wchar_t *_SubStr); wchar_t * wcstok(wchar_t * __restrict__ _Str,const wchar_t * __restrict__ _Delim) ; __attribute__ ((__dllimport__)) wchar_t * _wcserror(int _ErrNum) ; __attribute__ ((__dllimport__)) wchar_t * __wcserror(const wchar_t *_Str) ; __attribute__ ((__dllimport__)) int _wcsicmp(const wchar_t *_Str1,const wchar_t *_Str2); __attribute__ ((__dllimport__)) int _wcsicmp_l(const wchar_t *_Str1,const wchar_t *_Str2,_locale_t _Locale); __attribute__ ((__dllimport__)) int _wcsnicmp(const wchar_t *_Str1,const wchar_t *_Str2,size_t _MaxCount); __attribute__ ((__dllimport__)) int _wcsnicmp_l(const wchar_t *_Str1,const wchar_t *_Str2,size_t _MaxCount,_locale_t _Locale); __attribute__ ((__dllimport__)) wchar_t * _wcsnset(wchar_t *_Str,wchar_t _Val,size_t _MaxCount) ; __attribute__ ((__dllimport__)) wchar_t * _wcsrev(wchar_t *_Str); __attribute__ ((__dllimport__)) wchar_t * _wcsset(wchar_t *_Str,wchar_t _Val) ; __attribute__ ((__dllimport__)) wchar_t * _wcslwr(wchar_t *_String) ; __attribute__ ((__dllimport__)) wchar_t *_wcslwr_l(wchar_t *_String,_locale_t _Locale) ; __attribute__ ((__dllimport__)) wchar_t * _wcsupr(wchar_t *_String) ; __attribute__ ((__dllimport__)) wchar_t *_wcsupr_l(wchar_t *_String,_locale_t _Locale) ; size_t wcsxfrm(wchar_t * __restrict__ _Dst,const wchar_t * __restrict__ _Src,size_t _MaxCount); __attribute__ ((__dllimport__)) size_t _wcsxfrm_l(wchar_t * __restrict__ _Dst,const wchar_t * __restrict__ _Src,size_t _MaxCount,_locale_t _Locale); int wcscoll(const wchar_t *_Str1,const wchar_t *_Str2); __attribute__ ((__dllimport__)) int _wcscoll_l(const wchar_t *_Str1,const wchar_t *_Str2,_locale_t _Locale); __attribute__ ((__dllimport__)) int _wcsicoll(const wchar_t *_Str1,const wchar_t *_Str2); __attribute__ ((__dllimport__)) int _wcsicoll_l(const wchar_t *_Str1,const wchar_t *_Str2,_locale_t _Locale); __attribute__ ((__dllimport__)) int _wcsncoll(const wchar_t *_Str1,const wchar_t *_Str2,size_t _MaxCount); __attribute__ ((__dllimport__)) int _wcsncoll_l(const wchar_t *_Str1,const wchar_t *_Str2,size_t _MaxCount,_locale_t _Locale); __attribute__ ((__dllimport__)) int _wcsnicoll(const wchar_t *_Str1,const wchar_t *_Str2,size_t _MaxCount); __attribute__ ((__dllimport__)) int _wcsnicoll_l(const wchar_t *_Str1,const wchar_t *_Str2,size_t _MaxCount,_locale_t _Locale); wchar_t * wcsdup(const wchar_t *_Str) ; int wcsicmp(const wchar_t *_Str1,const wchar_t *_Str2) ; int wcsnicmp(const wchar_t *_Str1,const wchar_t *_Str2,size_t _MaxCount) ; wchar_t * wcsnset(wchar_t *_Str,wchar_t _Val,size_t _MaxCount) ; wchar_t * wcsrev(wchar_t *_Str) ; wchar_t * wcsset(wchar_t *_Str,wchar_t _Val) ; wchar_t * wcslwr(wchar_t *_Str) ; wchar_t * wcsupr(wchar_t *_Str) ; int wcsicoll(const wchar_t *_Str1,const wchar_t *_Str2) ; # 1 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\sec_api/string_s.h" 1 3 /** * This file has no copyright assigned and is placed in the Public Domain. * This file is part of the w64 mingw-runtime package. * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ # 1 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\string.h" 1 3 /** * This file has no copyright assigned and is placed in the Public Domain. * This file is part of the w64 mingw-runtime package. * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ # 9 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\sec_api/string_s.h" 2 3 # 175 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\string.h" 2 3 # 63 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/common/technology/autopilot\\ap_cint.h" 2 # 1 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\stdio.h" 1 3 /** * This file has no copyright assigned and is placed in the Public Domain. * This file is part of the w64 mingw-runtime package. * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ # 1 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\_mingw.h" 1 3 /** * This file has no copyright assigned and is placed in the Public Domain. * This file is part of the w64 mingw-runtime package. * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ # 9 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\stdio.h" 2 3 # 1 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\_mingw_print_push.h" 1 3 /** * This file has no copyright assigned and is placed in the Public Domain. * This file is part of the w64 mingw-runtime package. * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ /* Undefine __mingw_<printf> macros. */ # 11 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\stdio.h" 2 3 #pragma pack(push,_CRT_PACKING) # 26 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\stdio.h" 3 struct _iobuf { char *_ptr; int _cnt; char *_base; int _flag; int _file; int _charbuf; int _bufsiz; char *_tmpfname; }; typedef struct _iobuf FILE; # 84 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\stdio.h" 3 typedef long _off_t; typedef long off_t; __extension__ typedef long long _off64_t; __extension__ typedef long long off64_t; __attribute__ ((__dllimport__)) FILE * __iob_func(void); # 120 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\stdio.h" 3 __extension__ typedef long long fpos_t; # 157 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\stdio.h" 3 __attribute__ ((__dllimport__)) int _filbuf(FILE *_File); __attribute__ ((__dllimport__)) int _flsbuf(int _Ch,FILE *_File); __attribute__ ((__dllimport__)) FILE * _fsopen(const char *_Filename,const char *_Mode,int _ShFlag); void clearerr(FILE *_File); int fclose(FILE *_File); __attribute__ ((__dllimport__)) int _fcloseall(void); __attribute__ ((__dllimport__)) FILE * _fdopen(int _FileHandle,const char *_Mode); int feof(FILE *_File); int ferror(FILE *_File); int fflush(FILE *_File); int fgetc(FILE *_File); __attribute__ ((__dllimport__)) int _fgetchar(void); int fgetpos(FILE * __restrict__ _File ,fpos_t * __restrict__ _Pos); char * fgets(char * __restrict__ _Buf,int _MaxCount,FILE * __restrict__ _File); __attribute__ ((__dllimport__)) int _fileno(FILE *_File); __attribute__ ((__dllimport__)) char * _tempnam(const char *_DirName,const char *_FilePrefix); __attribute__ ((__dllimport__)) int _flushall(void); FILE * fopen(const char * __restrict__ _Filename,const char * __restrict__ _Mode) ; FILE *fopen64(const char * __restrict__ filename,const char * __restrict__ mode); int fprintf(FILE * __restrict__ _File,const char * __restrict__ _Format,...); int fputc(int _Ch,FILE *_File); __attribute__ ((__dllimport__)) int _fputchar(int _Ch); int fputs(const char * __restrict__ _Str,FILE * __restrict__ _File); size_t fread(void * __restrict__ _DstBuf,size_t _ElementSize,size_t _Count,FILE * __restrict__ _File); FILE * freopen(const char * __restrict__ _Filename,const char * __restrict__ _Mode,FILE * __restrict__ _File) ; int fscanf(FILE * __restrict__ _File,const char * __restrict__ _Format,...) ; int _fscanf_l(FILE * __restrict__ _File,const char * __restrict__ _Format,_locale_t locale,...) ; int fsetpos(FILE *_File,const fpos_t *_Pos); int fseek(FILE *_File,long _Offset,int _Origin); int fseeko64(FILE* stream, _off64_t offset, int whence); long ftell(FILE *_File); _off64_t ftello64(FILE * stream); __extension__ int _fseeki64(FILE *_File,long long _Offset,int _Origin); __extension__ long long _ftelli64(FILE *_File); size_t fwrite(const void * __restrict__ _Str,size_t _Size,size_t _Count,FILE * __restrict__ _File); int getc(FILE *_File); int getchar(void); __attribute__ ((__dllimport__)) int _getmaxstdio(void); char * gets(char *_Buffer) ; int _getw(FILE *_File); void perror(const char *_ErrMsg); __attribute__ ((__dllimport__)) int _pclose(FILE *_File); __attribute__ ((__dllimport__)) FILE * _popen(const char *_Command,const char *_Mode); int printf(const char * __restrict__ _Format,...); int putc(int _Ch,FILE *_File); int putchar(int _Ch); int puts(const char *_Str); __attribute__ ((__dllimport__)) int _putw(int _Word,FILE *_File); int remove(const char *_Filename); int rename(const char *_OldFilename,const char *_NewFilename); __attribute__ ((__dllimport__)) int _unlink(const char *_Filename); int unlink(const char *_Filename) ; void rewind(FILE *_File); __attribute__ ((__dllimport__)) int _rmtmp(void); int scanf(const char * __restrict__ _Format,...) ; int _scanf_l(const char * __restrict__ format,_locale_t locale,... ) ; void setbuf(FILE * __restrict__ _File,char * __restrict__ _Buffer) ; __attribute__ ((__dllimport__)) int _setmaxstdio(int _Max); __attribute__ ((__dllimport__)) unsigned int _set_output_format(unsigned int _Format); __attribute__ ((__dllimport__)) unsigned int _get_output_format(void); unsigned int __mingw_set_output_format(unsigned int _Format); unsigned int __mingw_get_output_format(void); int setvbuf(FILE * __restrict__ _File,char * __restrict__ _Buf,int _Mode,size_t _Size); __attribute__ ((__dllimport__)) int _scprintf(const char * __restrict__ _Format,...); int sscanf(const char * __restrict__ _Src,const char * __restrict__ _Format,...) ; int _sscanf_l(const char * __restrict__ buffer,const char * __restrict__ format,_locale_t locale,...) ; __attribute__ ((__dllimport__)) int _snscanf(const char * __restrict__ _Src,size_t _MaxCount,const char * __restrict__ _Format,...) ; __attribute__ ((__dllimport__)) int _snscanf_l(const char * __restrict__ input,size_t length,const char * __restrict__ format,_locale_t locale,...) ; FILE * tmpfile(void) ; char * tmpnam(char *_Buffer); int ungetc(int _Ch,FILE *_File); int vfprintf(FILE * __restrict__ _File,const char * __restrict__ _Format,va_list _ArgList); int vprintf(const char * __restrict__ _Format,va_list _ArgList); /* Make sure macros are not defined. */ extern __attribute__((__format__ (gnu_printf, 3, 0))) __attribute__ ((__nonnull__ (3))) int __mingw_vsnprintf(char * __restrict__ _DstBuf,size_t _MaxCount,const char * __restrict__ _Format, va_list _ArgList); extern __attribute__((__format__ (gnu_printf, 3, 4))) __attribute__ ((__nonnull__ (3))) int __mingw_snprintf(char * __restrict__ s, size_t n, const char * __restrict__ format, ...); extern __attribute__((__format__ (gnu_printf, 1, 2))) __attribute__ ((__nonnull__ (1))) int __mingw_printf(const char * __restrict__ , ... ) __attribute__ ((__nothrow__)); extern __attribute__((__format__ (gnu_printf, 1, 0))) __attribute__ ((__nonnull__ (1))) int __mingw_vprintf (const char * __restrict__ , va_list) __attribute__ ((__nothrow__)); extern __attribute__((__format__ (gnu_printf, 2, 3))) __attribute__ ((__nonnull__ (2))) int __mingw_fprintf (FILE * __restrict__ , const char * __restrict__ , ...) __attribute__ ((__nothrow__)); extern __attribute__((__format__ (gnu_printf, 2, 0))) __attribute__ ((__nonnull__ (2))) int __mingw_vfprintf (FILE * __restrict__ , const char * __restrict__ , va_list) __attribute__ ((__nothrow__)); extern __attribute__((__format__ (gnu_printf, 2, 3))) __attribute__ ((__nonnull__ (2))) int __mingw_sprintf (char * __restrict__ , const char * __restrict__ , ...) __attribute__ ((__nothrow__)); extern __attribute__((__format__ (gnu_printf, 2, 0))) __attribute__ ((__nonnull__ (2))) int __mingw_vsprintf (char * __restrict__ , const char * __restrict__ , va_list) __attribute__ ((__nothrow__)); __attribute__ ((__dllimport__)) int _snprintf(char * __restrict__ _Dest,size_t _Count,const char * __restrict__ _Format,...) ; __attribute__ ((__dllimport__)) int _snprintf_l(char * __restrict__ buffer,size_t count,const char * __restrict__ format,_locale_t locale,...) ; __attribute__ ((__dllimport__)) int _vsnprintf(char * __restrict__ _Dest,size_t _Count,const char * __restrict__ _Format,va_list _Args) ; __attribute__ ((__dllimport__)) int _vsnprintf_l(char * __restrict__ buffer,size_t count,const char * __restrict__ format,_locale_t locale,va_list argptr) ; int sprintf(char * __restrict__ _Dest,const char * __restrict__ _Format,...) ; int _sprintf_l(char * __restrict__ buffer,const char * __restrict__ format,_locale_t locale,...) ; int vsprintf(char * __restrict__ _Dest,const char * __restrict__ _Format,va_list _Args) ; /* this is here to deal with software defining * vsnprintf as _vsnprintf, eg. libxml2. */ int vsnprintf(char * __restrict__ _DstBuf,size_t _MaxCount,const char * __restrict__ _Format,va_list _ArgList) ; int snprintf(char * __restrict__ s, size_t n, const char * __restrict__ format, ...); # 312 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\stdio.h" 3 int vscanf(const char * __restrict__ Format, va_list argp); int vfscanf (FILE * __restrict__ fp, const char * __restrict__ Format,va_list argp); int vsscanf (const char * __restrict__ _Str,const char * __restrict__ Format,va_list argp); __attribute__ ((__dllimport__)) int _vscprintf(const char * __restrict__ _Format,va_list _ArgList); __attribute__ ((__dllimport__)) int _set_printf_count_output(int _Value); __attribute__ ((__dllimport__)) int _get_printf_count_output(void); # 330 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\stdio.h" 3 __attribute__ ((__dllimport__)) FILE * _wfsopen(const wchar_t *_Filename,const wchar_t *_Mode,int _ShFlag); wint_t fgetwc(FILE *_File); __attribute__ ((__dllimport__)) wint_t _fgetwchar(void); wint_t fputwc(wchar_t _Ch,FILE *_File); __attribute__ ((__dllimport__)) wint_t _fputwchar(wchar_t _Ch); wint_t getwc(FILE *_File); wint_t getwchar(void); wint_t putwc(wchar_t _Ch,FILE *_File); wint_t putwchar(wchar_t _Ch); wint_t ungetwc(wint_t _Ch,FILE *_File); wchar_t * fgetws(wchar_t * __restrict__ _Dst,int _SizeInWords,FILE * __restrict__ _File); int fputws(const wchar_t * __restrict__ _Str,FILE * __restrict__ _File); __attribute__ ((__dllimport__)) wchar_t * _getws(wchar_t *_String) ; __attribute__ ((__dllimport__)) int _putws(const wchar_t *_Str); int fwprintf(FILE * __restrict__ _File,const wchar_t * __restrict__ _Format,...); int wprintf(const wchar_t * __restrict__ _Format,...); __attribute__ ((__dllimport__)) int _scwprintf(const wchar_t * __restrict__ _Format,...); int vfwprintf(FILE * __restrict__ _File,const wchar_t * __restrict__ _Format,va_list _ArgList); int vwprintf(const wchar_t * __restrict__ _Format,va_list _ArgList); __attribute__ ((__dllimport__)) int swprintf(wchar_t * __restrict__ , const wchar_t * __restrict__ , ...) ; __attribute__ ((__dllimport__)) int _swprintf_l(wchar_t * __restrict__ buffer,size_t count,const wchar_t * __restrict__ format,_locale_t locale,... ) ; __attribute__ ((__dllimport__)) int vswprintf(wchar_t * __restrict__ , const wchar_t * __restrict__ ,va_list) ; __attribute__ ((__dllimport__)) int _swprintf_c(wchar_t * __restrict__ _DstBuf,size_t _SizeInWords,const wchar_t * __restrict__ _Format,...); __attribute__ ((__dllimport__)) int _vswprintf_c(wchar_t * __restrict__ _DstBuf,size_t _SizeInWords,const wchar_t * __restrict__ _Format,va_list _ArgList); __attribute__ ((__dllimport__)) int _snwprintf(wchar_t * __restrict__ _Dest,size_t _Count,const wchar_t * __restrict__ _Format,...) ; __attribute__ ((__dllimport__)) int _vsnwprintf(wchar_t * __restrict__ _Dest,size_t _Count,const wchar_t * __restrict__ _Format,va_list _Args) ; int snwprintf (wchar_t * __restrict__ s, size_t n, const wchar_t * __restrict__ format, ...); int vsnwprintf (wchar_t * __restrict__ , size_t, const wchar_t * __restrict__ , va_list); # 373 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\stdio.h" 3 int vwscanf (const wchar_t * __restrict__ , va_list); int vfwscanf (FILE * __restrict__ ,const wchar_t * __restrict__ ,va_list); int vswscanf (const wchar_t * __restrict__ ,const wchar_t * __restrict__ ,va_list); __attribute__ ((__dllimport__)) int _fwprintf_p(FILE * __restrict__ _File,const wchar_t * __restrict__ _Format,...); __attribute__ ((__dllimport__)) int _wprintf_p(const wchar_t * __restrict__ _Format,...); __attribute__ ((__dllimport__)) int _vfwprintf_p(FILE * __restrict__ _File,const wchar_t * __restrict__ _Format,va_list _ArgList); __attribute__ ((__dllimport__)) int _vwprintf_p(const wchar_t * __restrict__ _Format,va_list _ArgList); __attribute__ ((__dllimport__)) int _swprintf_p(wchar_t * __restrict__ _DstBuf,size_t _MaxCount,const wchar_t * __restrict__ _Format,...); __attribute__ ((__dllimport__)) int _vswprintf_p(wchar_t * __restrict__ _DstBuf,size_t _MaxCount,const wchar_t * __restrict__ _Format,va_list _ArgList); __attribute__ ((__dllimport__)) int _scwprintf_p(const wchar_t * __restrict__ _Format,...); __attribute__ ((__dllimport__)) int _vscwprintf_p(const wchar_t * __restrict__ _Format,va_list _ArgList); __attribute__ ((__dllimport__)) int _wprintf_l(const wchar_t * __restrict__ _Format,_locale_t _Locale,...); __attribute__ ((__dllimport__)) int _wprintf_p_l(const wchar_t * __restrict__ _Format,_locale_t _Locale,...); __attribute__ ((__dllimport__)) int _vwprintf_l(const wchar_t * __restrict__ _Format,_locale_t _Locale,va_list _ArgList); __attribute__ ((__dllimport__)) int _vwprintf_p_l(const wchar_t * __restrict__ _Format,_locale_t _Locale,va_list _ArgList); __attribute__ ((__dllimport__)) int _fwprintf_l(FILE * __restrict__ _File,const wchar_t * __restrict__ _Format,_locale_t _Locale,...); __attribute__ ((__dllimport__)) int _fwprintf_p_l(FILE * __restrict__ _File,const wchar_t * __restrict__ _Format,_locale_t _Locale,...); __attribute__ ((__dllimport__)) int _vfwprintf_l(FILE * __restrict__ _File,const wchar_t * __restrict__ _Format,_locale_t _Locale,va_list _ArgList); __attribute__ ((__dllimport__)) int _vfwprintf_p_l(FILE * __restrict__ _File,const wchar_t * __restrict__ _Format,_locale_t _Locale,va_list _ArgList); __attribute__ ((__dllimport__)) int _swprintf_c_l(wchar_t * __restrict__ _DstBuf,size_t _MaxCount,const wchar_t * __restrict__ _Format,_locale_t _Locale,...); __attribute__ ((__dllimport__)) int _swprintf_p_l(wchar_t * __restrict__ _DstBuf,size_t _MaxCount,const wchar_t * __restrict__ _Format,_locale_t _Locale,...); __attribute__ ((__dllimport__)) int _vswprintf_c_l(wchar_t * __restrict__ _DstBuf,size_t _MaxCount,const wchar_t * __restrict__ _Format,_locale_t _Locale,va_list _ArgList); __attribute__ ((__dllimport__)) int _vswprintf_p_l(wchar_t * __restrict__ _DstBuf,size_t _MaxCount,const wchar_t * __restrict__ _Format,_locale_t _Locale,va_list _ArgList); __attribute__ ((__dllimport__)) int _scwprintf_l(const wchar_t * __restrict__ _Format,_locale_t _Locale,...); __attribute__ ((__dllimport__)) int _scwprintf_p_l(const wchar_t * __restrict__ _Format,_locale_t _Locale,...); __attribute__ ((__dllimport__)) int _vscwprintf_p_l(const wchar_t * __restrict__ _Format,_locale_t _Locale,va_list _ArgList); __attribute__ ((__dllimport__)) int _snwprintf_l(wchar_t * __restrict__ _DstBuf,size_t _MaxCount,const wchar_t * __restrict__ _Format,_locale_t _Locale,...); __attribute__ ((__dllimport__)) int _vsnwprintf_l(wchar_t * __restrict__ _DstBuf,size_t _MaxCount,const wchar_t * __restrict__ _Format,_locale_t _Locale,va_list _ArgList) ; __attribute__ ((__dllimport__)) int _swprintf(wchar_t * __restrict__ _Dest,const wchar_t * __restrict__ _Format,...); __attribute__ ((__dllimport__)) int _vswprintf(wchar_t * __restrict__ _Dest,const wchar_t * __restrict__ _Format,va_list _Args); __attribute__ ((__dllimport__)) int __swprintf_l(wchar_t * __restrict__ _Dest,const wchar_t * __restrict__ _Format,_locale_t _Plocinfo,...) ; __attribute__ ((__dllimport__)) int _vswprintf_l(wchar_t * __restrict__ buffer,size_t count,const wchar_t * __restrict__ format,_locale_t locale,va_list argptr) ; __attribute__ ((__dllimport__)) int __vswprintf_l(wchar_t * __restrict__ _Dest,const wchar_t * __restrict__ _Format,_locale_t _Plocinfo,va_list _Args) ; # 417 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\stdio.h" 3 __attribute__ ((__dllimport__)) wchar_t * _wtempnam(const wchar_t *_Directory,const wchar_t *_FilePrefix); __attribute__ ((__dllimport__)) int _vscwprintf(const wchar_t * __restrict__ _Format,va_list _ArgList); __attribute__ ((__dllimport__)) int _vscwprintf_l(const wchar_t * __restrict__ _Format,_locale_t _Locale,va_list _ArgList); int fwscanf(FILE * __restrict__ _File,const wchar_t * __restrict__ _Format,...) ; __attribute__ ((__dllimport__)) int _fwscanf_l(FILE * __restrict__ _File,const wchar_t * __restrict__ _Format,_locale_t _Locale,...) ; int swscanf(const wchar_t * __restrict__ _Src,const wchar_t * __restrict__ _Format,...) ; __attribute__ ((__dllimport__)) int _swscanf_l(const wchar_t * __restrict__ _Src,const wchar_t * __restrict__ _Format,_locale_t _Locale,...) ; __attribute__ ((__dllimport__)) int _snwscanf(const wchar_t * __restrict__ _Src,size_t _MaxCount,const wchar_t * __restrict__ _Format,...); __attribute__ ((__dllimport__)) int _snwscanf_l(const wchar_t * __restrict__ _Src,size_t _MaxCount,const wchar_t * __restrict__ _Format,_locale_t _Locale,...); int wscanf(const wchar_t * __restrict__ _Format,...) ; __attribute__ ((__dllimport__)) int _wscanf_l(const wchar_t * __restrict__ _Format,_locale_t _Locale,...) ; __attribute__ ((__dllimport__)) FILE * _wfdopen(int _FileHandle ,const wchar_t *_Mode); __attribute__ ((__dllimport__)) FILE * _wfopen(const wchar_t * __restrict__ _Filename,const wchar_t *__restrict__ _Mode) ; __attribute__ ((__dllimport__)) FILE * _wfreopen(const wchar_t * __restrict__ _Filename,const wchar_t * __restrict__ _Mode,FILE * __restrict__ _OldFile) ; __attribute__ ((__dllimport__)) void _wperror(const wchar_t *_ErrMsg); __attribute__ ((__dllimport__)) FILE * _wpopen(const wchar_t *_Command,const wchar_t *_Mode); __attribute__ ((__dllimport__)) int _wremove(const wchar_t *_Filename); __attribute__ ((__dllimport__)) wchar_t * _wtmpnam(wchar_t *_Buffer); __attribute__ ((__dllimport__)) wint_t _fgetwc_nolock(FILE *_File); __attribute__ ((__dllimport__)) wint_t _fputwc_nolock(wchar_t _Ch,FILE *_File); __attribute__ ((__dllimport__)) wint_t _ungetwc_nolock(wint_t _Ch,FILE *_File); # 475 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\stdio.h" 3 __attribute__ ((__dllimport__)) void _lock_file(FILE *_File); __attribute__ ((__dllimport__)) void _unlock_file(FILE *_File); __attribute__ ((__dllimport__)) int _fclose_nolock(FILE *_File); __attribute__ ((__dllimport__)) int _fflush_nolock(FILE *_File); __attribute__ ((__dllimport__)) size_t _fread_nolock(void * __restrict__ _DstBuf,size_t _ElementSize,size_t _Count,FILE * __restrict__ _File); __attribute__ ((__dllimport__)) int _fseek_nolock(FILE *_File,long _Offset,int _Origin); __attribute__ ((__dllimport__)) long _ftell_nolock(FILE *_File); __extension__ __attribute__ ((__dllimport__)) int _fseeki64_nolock(FILE *_File,long long _Offset,int _Origin); __extension__ __attribute__ ((__dllimport__)) long long _ftelli64_nolock(FILE *_File); __attribute__ ((__dllimport__)) size_t _fwrite_nolock(const void * __restrict__ _DstBuf,size_t _Size,size_t _Count,FILE * __restrict__ _File); __attribute__ ((__dllimport__)) int _ungetc_nolock(int _Ch,FILE *_File); char * tempnam(const char *_Directory,const char *_FilePrefix) ; int fcloseall(void) ; FILE * fdopen(int _FileHandle,const char *_Format) ; int fgetchar(void) ; int fileno(FILE *_File) ; int flushall(void) ; int fputchar(int _Ch) ; int getw(FILE *_File) ; int putw(int _Ch,FILE *_File) ; int rmtmp(void) ; #pragma pack(pop) # 1 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\sec_api/stdio_s.h" 1 3 /** * This file has no copyright assigned and is placed in the Public Domain. * This file is part of the w64 mingw-runtime package. * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ # 1 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\stdio.h" 1 3 /** * This file has no copyright assigned and is placed in the Public Domain. * This file is part of the w64 mingw-runtime package. * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ # 9 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\sec_api/stdio_s.h" 2 3 # 509 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\stdio.h" 2 3 # 1 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\_mingw_print_pop.h" 1 3 /** * This file has no copyright assigned and is placed in the Public Domain. * This file is part of the w64 mingw-runtime package. * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ /* Define __mingw_<printf> macros. */ # 511 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\stdio.h" 2 3 # 64 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/common/technology/autopilot\\ap_cint.h" 2 # 77 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/common/technology/autopilot\\ap_cint.h" # 1 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/common/technology/autopilot/etc/autopilot_apint.h" 1 /* autopilot_apint.h*/ /* #- (c) Copyright 2011-2015 Xilinx, Inc. All rights reserved. #- #- This file contains confidential and proprietary information #- of Xilinx, Inc. and is protected under U.S. and #- international copyright and other intellectual property #- laws. #- #- DISCLAIMER #- This disclaimer is not a license and does not grant any #- rights to the materials distributed herewith. Except as #- otherwise provided in a valid license issued to you by #- Xilinx, and to the maximum extent permitted by applicable #- law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND #- WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES #- AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING #- BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON- #- INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and #- (2) Xilinx shall not be liable (whether in contract or tort, #- including negligence, or under any other theory of #- liability) for any loss or damage of any kind or nature #- related to, arising under or in connection with these #- materials, including for any direct, or any indirect, #- special, incidental, or consequential loss or damage #- (including loss of data, profits, goodwill, or any type of #- loss or damage suffered as a result of any action brought #- by a third party) even if such damage or loss was #- reasonably foreseeable or Xilinx had been advised of the #- possibility of the same. #- #- CRITICAL APPLICATIONS #- Xilinx products are not designed or intended to be fail- #- safe, or for use in any application requiring fail-safe #- performance, such as life-support or safety devices or #- systems, Class III medical devices, nuclear facilities, #- applications related to the deployment of airbags, or any #- other applications that could lead to death, personal #- injury, or severe property or environmental damage #- (individually and collectively, "Critical #- Applications"). Customer assumes the sole risk and #- liability of any use of Xilinx products in Critical #- Applications, subject only to applicable laws and #- regulations governing limitations on product liability. #- #- THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS #- PART OF THIS FILE AT ALL TIMES. #- ************************************************************************ * * $Id$ */ # 1 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/common/technology/autopilot\\etc/autopilot_dt.h" 1 /*-*-c++-*-*/ /* autopilot_dt.h: defines all bit-accurate data types.*/ /* #- (c) Copyright 2011-2015 Xilinx, Inc. All rights reserved. #- #- This file contains confidential and proprietary information #- of Xilinx, Inc. and is protected under U.S. and #- international copyright and other intellectual property #- laws. #- #- DISCLAIMER #- This disclaimer is not a license and does not grant any #- rights to the materials distributed herewith. Except as #- otherwise provided in a valid license issued to you by #- Xilinx, and to the maximum extent permitted by applicable #- law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND #- WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES #- AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING #- BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON- #- INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and #- (2) Xilinx shall not be liable (whether in contract or tort, #- including negligence, or under any other theory of #- liability) for any loss or damage of any kind or nature #- related to, arising under or in connection with these #- materials, including for any direct, or any indirect, #- special, incidental, or consequential loss or damage #- (including loss of data, profits, goodwill, or any type of #- loss or damage suffered as a result of any action brought #- by a third party) even if such damage or loss was #- reasonably foreseeable or Xilinx had been advised of the #- possibility of the same. #- #- CRITICAL APPLICATIONS #- Xilinx products are not designed or intended to be fail- #- safe, or for use in any application requiring fail-safe #- performance, such as life-support or safety devices or #- systems, Class III medical devices, nuclear facilities, #- applications related to the deployment of airbags, or any #- other applications that could lead to death, personal #- injury, or severe property or environmental damage #- (individually and collectively, "Critical #- Applications"). Customer assumes the sole risk and #- liability of any use of Xilinx products in Critical #- Applications, subject only to applicable laws and #- regulations governing limitations on product liability. #- #- THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS #- PART OF THIS FILE AT ALL TIMES. #- ************************************************************************ * * $Id$ */ # 97 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/common/technology/autopilot\\etc/autopilot_dt.h" # 1 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/common/technology/autopilot\\etc/autopilot_dt.def" 1 typedef int __attribute__ ((bitwidth(1))) int1; typedef int __attribute__ ((bitwidth(2))) int2; typedef int __attribute__ ((bitwidth(3))) int3; typedef int __attribute__ ((bitwidth(4))) int4; typedef int __attribute__ ((bitwidth(5))) int5; typedef int __attribute__ ((bitwidth(6))) int6; typedef int __attribute__ ((bitwidth(7))) int7; typedef int __attribute__ ((bitwidth(8))) int8; typedef int __attribute__ ((bitwidth(9))) int9; typedef int __attribute__ ((bitwidth(10))) int10; typedef int __attribute__ ((bitwidth(11))) int11; typedef int __attribute__ ((bitwidth(12))) int12; typedef int __attribute__ ((bitwidth(13))) int13; typedef int __attribute__ ((bitwidth(14))) int14; typedef int __attribute__ ((bitwidth(15))) int15; typedef int __attribute__ ((bitwidth(16))) int16; typedef int __attribute__ ((bitwidth(17))) int17; typedef int __attribute__ ((bitwidth(18))) int18; typedef int __attribute__ ((bitwidth(19))) int19; typedef int __attribute__ ((bitwidth(20))) int20; typedef int __attribute__ ((bitwidth(21))) int21; typedef int __attribute__ ((bitwidth(22))) int22; typedef int __attribute__ ((bitwidth(23))) int23; typedef int __attribute__ ((bitwidth(24))) int24; typedef int __attribute__ ((bitwidth(25))) int25; typedef int __attribute__ ((bitwidth(26))) int26; typedef int __attribute__ ((bitwidth(27))) int27; typedef int __attribute__ ((bitwidth(28))) int28; typedef int __attribute__ ((bitwidth(29))) int29; typedef int __attribute__ ((bitwidth(30))) int30; typedef int __attribute__ ((bitwidth(31))) int31; typedef int __attribute__ ((bitwidth(32))) int32; typedef int __attribute__ ((bitwidth(33))) int33; typedef int __attribute__ ((bitwidth(34))) int34; typedef int __attribute__ ((bitwidth(35))) int35; typedef int __attribute__ ((bitwidth(36))) int36; typedef int __attribute__ ((bitwidth(37))) int37; typedef int __attribute__ ((bitwidth(38))) int38; typedef int __attribute__ ((bitwidth(39))) int39; typedef int __attribute__ ((bitwidth(40))) int40; typedef int __attribute__ ((bitwidth(41))) int41; typedef int __attribute__ ((bitwidth(42))) int42; typedef int __attribute__ ((bitwidth(43))) int43; typedef int __attribute__ ((bitwidth(44))) int44; typedef int __attribute__ ((bitwidth(45))) int45; typedef int __attribute__ ((bitwidth(46))) int46; typedef int __attribute__ ((bitwidth(47))) int47; typedef int __attribute__ ((bitwidth(48))) int48; typedef int __attribute__ ((bitwidth(49))) int49; typedef int __attribute__ ((bitwidth(50))) int50; typedef int __attribute__ ((bitwidth(51))) int51; typedef int __attribute__ ((bitwidth(52))) int52; typedef int __attribute__ ((bitwidth(53))) int53; typedef int __attribute__ ((bitwidth(54))) int54; typedef int __attribute__ ((bitwidth(55))) int55; typedef int __attribute__ ((bitwidth(56))) int56; typedef int __attribute__ ((bitwidth(57))) int57; typedef int __attribute__ ((bitwidth(58))) int58; typedef int __attribute__ ((bitwidth(59))) int59; typedef int __attribute__ ((bitwidth(60))) int60; typedef int __attribute__ ((bitwidth(61))) int61; typedef int __attribute__ ((bitwidth(62))) int62; typedef int __attribute__ ((bitwidth(63))) int63; /*#if AUTOPILOT_VERSION >= 1 */ typedef int __attribute__ ((bitwidth(65))) int65; typedef int __attribute__ ((bitwidth(66))) int66; typedef int __attribute__ ((bitwidth(67))) int67; typedef int __attribute__ ((bitwidth(68))) int68; typedef int __attribute__ ((bitwidth(69))) int69; typedef int __attribute__ ((bitwidth(70))) int70; typedef int __attribute__ ((bitwidth(71))) int71; typedef int __attribute__ ((bitwidth(72))) int72; typedef int __attribute__ ((bitwidth(73))) int73; typedef int __attribute__ ((bitwidth(74))) int74; typedef int __attribute__ ((bitwidth(75))) int75; typedef int __attribute__ ((bitwidth(76))) int76; typedef int __attribute__ ((bitwidth(77))) int77; typedef int __attribute__ ((bitwidth(78))) int78; typedef int __attribute__ ((bitwidth(79))) int79; typedef int __attribute__ ((bitwidth(80))) int80; typedef int __attribute__ ((bitwidth(81))) int81; typedef int __attribute__ ((bitwidth(82))) int82; typedef int __attribute__ ((bitwidth(83))) int83; typedef int __attribute__ ((bitwidth(84))) int84; typedef int __attribute__ ((bitwidth(85))) int85; typedef int __attribute__ ((bitwidth(86))) int86; typedef int __attribute__ ((bitwidth(87))) int87; typedef int __attribute__ ((bitwidth(88))) int88; typedef int __attribute__ ((bitwidth(89))) int89; typedef int __attribute__ ((bitwidth(90))) int90; typedef int __attribute__ ((bitwidth(91))) int91; typedef int __attribute__ ((bitwidth(92))) int92; typedef int __attribute__ ((bitwidth(93))) int93; typedef int __attribute__ ((bitwidth(94))) int94; typedef int __attribute__ ((bitwidth(95))) int95; typedef int __attribute__ ((bitwidth(96))) int96; typedef int __attribute__ ((bitwidth(97))) int97; typedef int __attribute__ ((bitwidth(98))) int98; typedef int __attribute__ ((bitwidth(99))) int99; typedef int __attribute__ ((bitwidth(100))) int100; typedef int __attribute__ ((bitwidth(101))) int101; typedef int __attribute__ ((bitwidth(102))) int102; typedef int __attribute__ ((bitwidth(103))) int103; typedef int __attribute__ ((bitwidth(104))) int104; typedef int __attribute__ ((bitwidth(105))) int105; typedef int __attribute__ ((bitwidth(106))) int106; typedef int __attribute__ ((bitwidth(107))) int107; typedef int __attribute__ ((bitwidth(108))) int108; typedef int __attribute__ ((bitwidth(109))) int109; typedef int __attribute__ ((bitwidth(110))) int110; typedef int __attribute__ ((bitwidth(111))) int111; typedef int __attribute__ ((bitwidth(112))) int112; typedef int __attribute__ ((bitwidth(113))) int113; typedef int __attribute__ ((bitwidth(114))) int114; typedef int __attribute__ ((bitwidth(115))) int115; typedef int __attribute__ ((bitwidth(116))) int116; typedef int __attribute__ ((bitwidth(117))) int117; typedef int __attribute__ ((bitwidth(118))) int118; typedef int __attribute__ ((bitwidth(119))) int119; typedef int __attribute__ ((bitwidth(120))) int120; typedef int __attribute__ ((bitwidth(121))) int121; typedef int __attribute__ ((bitwidth(122))) int122; typedef int __attribute__ ((bitwidth(123))) int123; typedef int __attribute__ ((bitwidth(124))) int124; typedef int __attribute__ ((bitwidth(125))) int125; typedef int __attribute__ ((bitwidth(126))) int126; typedef int __attribute__ ((bitwidth(127))) int127; typedef int __attribute__ ((bitwidth(128))) int128; /*#endif*/ /*#ifdef EXTENDED_GCC*/ typedef int __attribute__ ((bitwidth(129))) int129; typedef int __attribute__ ((bitwidth(130))) int130; typedef int __attribute__ ((bitwidth(131))) int131; typedef int __attribute__ ((bitwidth(132))) int132; typedef int __attribute__ ((bitwidth(133))) int133; typedef int __attribute__ ((bitwidth(134))) int134; typedef int __attribute__ ((bitwidth(135))) int135; typedef int __attribute__ ((bitwidth(136))) int136; typedef int __attribute__ ((bitwidth(137))) int137; typedef int __attribute__ ((bitwidth(138))) int138; typedef int __attribute__ ((bitwidth(139))) int139; typedef int __attribute__ ((bitwidth(140))) int140; typedef int __attribute__ ((bitwidth(141))) int141; typedef int __attribute__ ((bitwidth(142))) int142; typedef int __attribute__ ((bitwidth(143))) int143; typedef int __attribute__ ((bitwidth(144))) int144; typedef int __attribute__ ((bitwidth(145))) int145; typedef int __attribute__ ((bitwidth(146))) int146; typedef int __attribute__ ((bitwidth(147))) int147; typedef int __attribute__ ((bitwidth(148))) int148; typedef int __attribute__ ((bitwidth(149))) int149; typedef int __attribute__ ((bitwidth(150))) int150; typedef int __attribute__ ((bitwidth(151))) int151; typedef int __attribute__ ((bitwidth(152))) int152; typedef int __attribute__ ((bitwidth(153))) int153; typedef int __attribute__ ((bitwidth(154))) int154; typedef int __attribute__ ((bitwidth(155))) int155; typedef int __attribute__ ((bitwidth(156))) int156; typedef int __attribute__ ((bitwidth(157))) int157; typedef int __attribute__ ((bitwidth(158))) int158; typedef int __attribute__ ((bitwidth(159))) int159; typedef int __attribute__ ((bitwidth(160))) int160; typedef int __attribute__ ((bitwidth(161))) int161; typedef int __attribute__ ((bitwidth(162))) int162; typedef int __attribute__ ((bitwidth(163))) int163; typedef int __attribute__ ((bitwidth(164))) int164; typedef int __attribute__ ((bitwidth(165))) int165; typedef int __attribute__ ((bitwidth(166))) int166; typedef int __attribute__ ((bitwidth(167))) int167; typedef int __attribute__ ((bitwidth(168))) int168; typedef int __attribute__ ((bitwidth(169))) int169; typedef int __attribute__ ((bitwidth(170))) int170; typedef int __attribute__ ((bitwidth(171))) int171; typedef int __attribute__ ((bitwidth(172))) int172; typedef int __attribute__ ((bitwidth(173))) int173; typedef int __attribute__ ((bitwidth(174))) int174; typedef int __attribute__ ((bitwidth(175))) int175; typedef int __attribute__ ((bitwidth(176))) int176; typedef int __attribute__ ((bitwidth(177))) int177; typedef int __attribute__ ((bitwidth(178))) int178; typedef int __attribute__ ((bitwidth(179))) int179; typedef int __attribute__ ((bitwidth(180))) int180; typedef int __attribute__ ((bitwidth(181))) int181; typedef int __attribute__ ((bitwidth(182))) int182; typedef int __attribute__ ((bitwidth(183))) int183; typedef int __attribute__ ((bitwidth(184))) int184; typedef int __attribute__ ((bitwidth(185))) int185; typedef int __attribute__ ((bitwidth(186))) int186; typedef int __attribute__ ((bitwidth(187))) int187; typedef int __attribute__ ((bitwidth(188))) int188; typedef int __attribute__ ((bitwidth(189))) int189; typedef int __attribute__ ((bitwidth(190))) int190; typedef int __attribute__ ((bitwidth(191))) int191; typedef int __attribute__ ((bitwidth(192))) int192; typedef int __attribute__ ((bitwidth(193))) int193; typedef int __attribute__ ((bitwidth(194))) int194; typedef int __attribute__ ((bitwidth(195))) int195; typedef int __attribute__ ((bitwidth(196))) int196; typedef int __attribute__ ((bitwidth(197))) int197; typedef int __attribute__ ((bitwidth(198))) int198; typedef int __attribute__ ((bitwidth(199))) int199; typedef int __attribute__ ((bitwidth(200))) int200; typedef int __attribute__ ((bitwidth(201))) int201; typedef int __attribute__ ((bitwidth(202))) int202; typedef int __attribute__ ((bitwidth(203))) int203; typedef int __attribute__ ((bitwidth(204))) int204; typedef int __attribute__ ((bitwidth(205))) int205; typedef int __attribute__ ((bitwidth(206))) int206; typedef int __attribute__ ((bitwidth(207))) int207; typedef int __attribute__ ((bitwidth(208))) int208; typedef int __attribute__ ((bitwidth(209))) int209; typedef int __attribute__ ((bitwidth(210))) int210; typedef int __attribute__ ((bitwidth(211))) int211; typedef int __attribute__ ((bitwidth(212))) int212; typedef int __attribute__ ((bitwidth(213))) int213; typedef int __attribute__ ((bitwidth(214))) int214; typedef int __attribute__ ((bitwidth(215))) int215; typedef int __attribute__ ((bitwidth(216))) int216; typedef int __attribute__ ((bitwidth(217))) int217; typedef int __attribute__ ((bitwidth(218))) int218; typedef int __attribute__ ((bitwidth(219))) int219; typedef int __attribute__ ((bitwidth(220))) int220; typedef int __attribute__ ((bitwidth(221))) int221; typedef int __attribute__ ((bitwidth(222))) int222; typedef int __attribute__ ((bitwidth(223))) int223; typedef int __attribute__ ((bitwidth(224))) int224; typedef int __attribute__ ((bitwidth(225))) int225; typedef int __attribute__ ((bitwidth(226))) int226; typedef int __attribute__ ((bitwidth(227))) int227; typedef int __attribute__ ((bitwidth(228))) int228; typedef int __attribute__ ((bitwidth(229))) int229; typedef int __attribute__ ((bitwidth(230))) int230; typedef int __attribute__ ((bitwidth(231))) int231; typedef int __attribute__ ((bitwidth(232))) int232; typedef int __attribute__ ((bitwidth(233))) int233; typedef int __attribute__ ((bitwidth(234))) int234; typedef int __attribute__ ((bitwidth(235))) int235; typedef int __attribute__ ((bitwidth(236))) int236; typedef int __attribute__ ((bitwidth(237))) int237; typedef int __attribute__ ((bitwidth(238))) int238; typedef int __attribute__ ((bitwidth(239))) int239; typedef int __attribute__ ((bitwidth(240))) int240; typedef int __attribute__ ((bitwidth(241))) int241; typedef int __attribute__ ((bitwidth(242))) int242; typedef int __attribute__ ((bitwidth(243))) int243; typedef int __attribute__ ((bitwidth(244))) int244; typedef int __attribute__ ((bitwidth(245))) int245; typedef int __attribute__ ((bitwidth(246))) int246; typedef int __attribute__ ((bitwidth(247))) int247; typedef int __attribute__ ((bitwidth(248))) int248; typedef int __attribute__ ((bitwidth(249))) int249; typedef int __attribute__ ((bitwidth(250))) int250; typedef int __attribute__ ((bitwidth(251))) int251; typedef int __attribute__ ((bitwidth(252))) int252; typedef int __attribute__ ((bitwidth(253))) int253; typedef int __attribute__ ((bitwidth(254))) int254; typedef int __attribute__ ((bitwidth(255))) int255; typedef int __attribute__ ((bitwidth(256))) int256; typedef int __attribute__ ((bitwidth(257))) int257; typedef int __attribute__ ((bitwidth(258))) int258; typedef int __attribute__ ((bitwidth(259))) int259; typedef int __attribute__ ((bitwidth(260))) int260; typedef int __attribute__ ((bitwidth(261))) int261; typedef int __attribute__ ((bitwidth(262))) int262; typedef int __attribute__ ((bitwidth(263))) int263; typedef int __attribute__ ((bitwidth(264))) int264; typedef int __attribute__ ((bitwidth(265))) int265; typedef int __attribute__ ((bitwidth(266))) int266; typedef int __attribute__ ((bitwidth(267))) int267; typedef int __attribute__ ((bitwidth(268))) int268; typedef int __attribute__ ((bitwidth(269))) int269; typedef int __attribute__ ((bitwidth(270))) int270; typedef int __attribute__ ((bitwidth(271))) int271; typedef int __attribute__ ((bitwidth(272))) int272; typedef int __attribute__ ((bitwidth(273))) int273; typedef int __attribute__ ((bitwidth(274))) int274; typedef int __attribute__ ((bitwidth(275))) int275; typedef int __attribute__ ((bitwidth(276))) int276; typedef int __attribute__ ((bitwidth(277))) int277; typedef int __attribute__ ((bitwidth(278))) int278; typedef int __attribute__ ((bitwidth(279))) int279; typedef int __attribute__ ((bitwidth(280))) int280; typedef int __attribute__ ((bitwidth(281))) int281; typedef int __attribute__ ((bitwidth(282))) int282; typedef int __attribute__ ((bitwidth(283))) int283; typedef int __attribute__ ((bitwidth(284))) int284; typedef int __attribute__ ((bitwidth(285))) int285; typedef int __attribute__ ((bitwidth(286))) int286; typedef int __attribute__ ((bitwidth(287))) int287; typedef int __attribute__ ((bitwidth(288))) int288; typedef int __attribute__ ((bitwidth(289))) int289; typedef int __attribute__ ((bitwidth(290))) int290; typedef int __attribute__ ((bitwidth(291))) int291; typedef int __attribute__ ((bitwidth(292))) int292; typedef int __attribute__ ((bitwidth(293))) int293; typedef int __attribute__ ((bitwidth(294))) int294; typedef int __attribute__ ((bitwidth(295))) int295; typedef int __attribute__ ((bitwidth(296))) int296; typedef int __attribute__ ((bitwidth(297))) int297; typedef int __attribute__ ((bitwidth(298))) int298; typedef int __attribute__ ((bitwidth(299))) int299; typedef int __attribute__ ((bitwidth(300))) int300; typedef int __attribute__ ((bitwidth(301))) int301; typedef int __attribute__ ((bitwidth(302))) int302; typedef int __attribute__ ((bitwidth(303))) int303; typedef int __attribute__ ((bitwidth(304))) int304; typedef int __attribute__ ((bitwidth(305))) int305; typedef int __attribute__ ((bitwidth(306))) int306; typedef int __attribute__ ((bitwidth(307))) int307; typedef int __attribute__ ((bitwidth(308))) int308; typedef int __attribute__ ((bitwidth(309))) int309; typedef int __attribute__ ((bitwidth(310))) int310; typedef int __attribute__ ((bitwidth(311))) int311; typedef int __attribute__ ((bitwidth(312))) int312; typedef int __attribute__ ((bitwidth(313))) int313; typedef int __attribute__ ((bitwidth(314))) int314; typedef int __attribute__ ((bitwidth(315))) int315; typedef int __attribute__ ((bitwidth(316))) int316; typedef int __attribute__ ((bitwidth(317))) int317; typedef int __attribute__ ((bitwidth(318))) int318; typedef int __attribute__ ((bitwidth(319))) int319; typedef int __attribute__ ((bitwidth(320))) int320; typedef int __attribute__ ((bitwidth(321))) int321; typedef int __attribute__ ((bitwidth(322))) int322; typedef int __attribute__ ((bitwidth(323))) int323; typedef int __attribute__ ((bitwidth(324))) int324; typedef int __attribute__ ((bitwidth(325))) int325; typedef int __attribute__ ((bitwidth(326))) int326; typedef int __attribute__ ((bitwidth(327))) int327; typedef int __attribute__ ((bitwidth(328))) int328; typedef int __attribute__ ((bitwidth(329))) int329; typedef int __attribute__ ((bitwidth(330))) int330; typedef int __attribute__ ((bitwidth(331))) int331; typedef int __attribute__ ((bitwidth(332))) int332; typedef int __attribute__ ((bitwidth(333))) int333; typedef int __attribute__ ((bitwidth(334))) int334; typedef int __attribute__ ((bitwidth(335))) int335; typedef int __attribute__ ((bitwidth(336))) int336; typedef int __attribute__ ((bitwidth(337))) int337; typedef int __attribute__ ((bitwidth(338))) int338; typedef int __attribute__ ((bitwidth(339))) int339; typedef int __attribute__ ((bitwidth(340))) int340; typedef int __attribute__ ((bitwidth(341))) int341; typedef int __attribute__ ((bitwidth(342))) int342; typedef int __attribute__ ((bitwidth(343))) int343; typedef int __attribute__ ((bitwidth(344))) int344; typedef int __attribute__ ((bitwidth(345))) int345; typedef int __attribute__ ((bitwidth(346))) int346; typedef int __attribute__ ((bitwidth(347))) int347; typedef int __attribute__ ((bitwidth(348))) int348; typedef int __attribute__ ((bitwidth(349))) int349; typedef int __attribute__ ((bitwidth(350))) int350; typedef int __attribute__ ((bitwidth(351))) int351; typedef int __attribute__ ((bitwidth(352))) int352; typedef int __attribute__ ((bitwidth(353))) int353; typedef int __attribute__ ((bitwidth(354))) int354; typedef int __attribute__ ((bitwidth(355))) int355; typedef int __attribute__ ((bitwidth(356))) int356; typedef int __attribute__ ((bitwidth(357))) int357; typedef int __attribute__ ((bitwidth(358))) int358; typedef int __attribute__ ((bitwidth(359))) int359; typedef int __attribute__ ((bitwidth(360))) int360; typedef int __attribute__ ((bitwidth(361))) int361; typedef int __attribute__ ((bitwidth(362))) int362; typedef int __attribute__ ((bitwidth(363))) int363; typedef int __attribute__ ((bitwidth(364))) int364; typedef int __attribute__ ((bitwidth(365))) int365; typedef int __attribute__ ((bitwidth(366))) int366; typedef int __attribute__ ((bitwidth(367))) int367; typedef int __attribute__ ((bitwidth(368))) int368; typedef int __attribute__ ((bitwidth(369))) int369; typedef int __attribute__ ((bitwidth(370))) int370; typedef int __attribute__ ((bitwidth(371))) int371; typedef int __attribute__ ((bitwidth(372))) int372; typedef int __attribute__ ((bitwidth(373))) int373; typedef int __attribute__ ((bitwidth(374))) int374; typedef int __attribute__ ((bitwidth(375))) int375; typedef int __attribute__ ((bitwidth(376))) int376; typedef int __attribute__ ((bitwidth(377))) int377; typedef int __attribute__ ((bitwidth(378))) int378; typedef int __attribute__ ((bitwidth(379))) int379; typedef int __attribute__ ((bitwidth(380))) int380; typedef int __attribute__ ((bitwidth(381))) int381; typedef int __attribute__ ((bitwidth(382))) int382; typedef int __attribute__ ((bitwidth(383))) int383; typedef int __attribute__ ((bitwidth(384))) int384; typedef int __attribute__ ((bitwidth(385))) int385; typedef int __attribute__ ((bitwidth(386))) int386; typedef int __attribute__ ((bitwidth(387))) int387; typedef int __attribute__ ((bitwidth(388))) int388; typedef int __attribute__ ((bitwidth(389))) int389; typedef int __attribute__ ((bitwidth(390))) int390; typedef int __attribute__ ((bitwidth(391))) int391; typedef int __attribute__ ((bitwidth(392))) int392; typedef int __attribute__ ((bitwidth(393))) int393; typedef int __attribute__ ((bitwidth(394))) int394; typedef int __attribute__ ((bitwidth(395))) int395; typedef int __attribute__ ((bitwidth(396))) int396; typedef int __attribute__ ((bitwidth(397))) int397; typedef int __attribute__ ((bitwidth(398))) int398; typedef int __attribute__ ((bitwidth(399))) int399; typedef int __attribute__ ((bitwidth(400))) int400; typedef int __attribute__ ((bitwidth(401))) int401; typedef int __attribute__ ((bitwidth(402))) int402; typedef int __attribute__ ((bitwidth(403))) int403; typedef int __attribute__ ((bitwidth(404))) int404; typedef int __attribute__ ((bitwidth(405))) int405; typedef int __attribute__ ((bitwidth(406))) int406; typedef int __attribute__ ((bitwidth(407))) int407; typedef int __attribute__ ((bitwidth(408))) int408; typedef int __attribute__ ((bitwidth(409))) int409; typedef int __attribute__ ((bitwidth(410))) int410; typedef int __attribute__ ((bitwidth(411))) int411; typedef int __attribute__ ((bitwidth(412))) int412; typedef int __attribute__ ((bitwidth(413))) int413; typedef int __attribute__ ((bitwidth(414))) int414; typedef int __attribute__ ((bitwidth(415))) int415; typedef int __attribute__ ((bitwidth(416))) int416; typedef int __attribute__ ((bitwidth(417))) int417; typedef int __attribute__ ((bitwidth(418))) int418; typedef int __attribute__ ((bitwidth(419))) int419; typedef int __attribute__ ((bitwidth(420))) int420; typedef int __attribute__ ((bitwidth(421))) int421; typedef int __attribute__ ((bitwidth(422))) int422; typedef int __attribute__ ((bitwidth(423))) int423; typedef int __attribute__ ((bitwidth(424))) int424; typedef int __attribute__ ((bitwidth(425))) int425; typedef int __attribute__ ((bitwidth(426))) int426; typedef int __attribute__ ((bitwidth(427))) int427; typedef int __attribute__ ((bitwidth(428))) int428; typedef int __attribute__ ((bitwidth(429))) int429; typedef int __attribute__ ((bitwidth(430))) int430; typedef int __attribute__ ((bitwidth(431))) int431; typedef int __attribute__ ((bitwidth(432))) int432; typedef int __attribute__ ((bitwidth(433))) int433; typedef int __attribute__ ((bitwidth(434))) int434; typedef int __attribute__ ((bitwidth(435))) int435; typedef int __attribute__ ((bitwidth(436))) int436; typedef int __attribute__ ((bitwidth(437))) int437; typedef int __attribute__ ((bitwidth(438))) int438; typedef int __attribute__ ((bitwidth(439))) int439; typedef int __attribute__ ((bitwidth(440))) int440; typedef int __attribute__ ((bitwidth(441))) int441; typedef int __attribute__ ((bitwidth(442))) int442; typedef int __attribute__ ((bitwidth(443))) int443; typedef int __attribute__ ((bitwidth(444))) int444; typedef int __attribute__ ((bitwidth(445))) int445; typedef int __attribute__ ((bitwidth(446))) int446; typedef int __attribute__ ((bitwidth(447))) int447; typedef int __attribute__ ((bitwidth(448))) int448; typedef int __attribute__ ((bitwidth(449))) int449; typedef int __attribute__ ((bitwidth(450))) int450; typedef int __attribute__ ((bitwidth(451))) int451; typedef int __attribute__ ((bitwidth(452))) int452; typedef int __attribute__ ((bitwidth(453))) int453; typedef int __attribute__ ((bitwidth(454))) int454; typedef int __attribute__ ((bitwidth(455))) int455; typedef int __attribute__ ((bitwidth(456))) int456; typedef int __attribute__ ((bitwidth(457))) int457; typedef int __attribute__ ((bitwidth(458))) int458; typedef int __attribute__ ((bitwidth(459))) int459; typedef int __attribute__ ((bitwidth(460))) int460; typedef int __attribute__ ((bitwidth(461))) int461; typedef int __attribute__ ((bitwidth(462))) int462; typedef int __attribute__ ((bitwidth(463))) int463; typedef int __attribute__ ((bitwidth(464))) int464; typedef int __attribute__ ((bitwidth(465))) int465; typedef int __attribute__ ((bitwidth(466))) int466; typedef int __attribute__ ((bitwidth(467))) int467; typedef int __attribute__ ((bitwidth(468))) int468; typedef int __attribute__ ((bitwidth(469))) int469; typedef int __attribute__ ((bitwidth(470))) int470; typedef int __attribute__ ((bitwidth(471))) int471; typedef int __attribute__ ((bitwidth(472))) int472; typedef int __attribute__ ((bitwidth(473))) int473; typedef int __attribute__ ((bitwidth(474))) int474; typedef int __attribute__ ((bitwidth(475))) int475; typedef int __attribute__ ((bitwidth(476))) int476; typedef int __attribute__ ((bitwidth(477))) int477; typedef int __attribute__ ((bitwidth(478))) int478; typedef int __attribute__ ((bitwidth(479))) int479; typedef int __attribute__ ((bitwidth(480))) int480; typedef int __attribute__ ((bitwidth(481))) int481; typedef int __attribute__ ((bitwidth(482))) int482; typedef int __attribute__ ((bitwidth(483))) int483; typedef int __attribute__ ((bitwidth(484))) int484; typedef int __attribute__ ((bitwidth(485))) int485; typedef int __attribute__ ((bitwidth(486))) int486; typedef int __attribute__ ((bitwidth(487))) int487; typedef int __attribute__ ((bitwidth(488))) int488; typedef int __attribute__ ((bitwidth(489))) int489; typedef int __attribute__ ((bitwidth(490))) int490; typedef int __attribute__ ((bitwidth(491))) int491; typedef int __attribute__ ((bitwidth(492))) int492; typedef int __attribute__ ((bitwidth(493))) int493; typedef int __attribute__ ((bitwidth(494))) int494; typedef int __attribute__ ((bitwidth(495))) int495; typedef int __attribute__ ((bitwidth(496))) int496; typedef int __attribute__ ((bitwidth(497))) int497; typedef int __attribute__ ((bitwidth(498))) int498; typedef int __attribute__ ((bitwidth(499))) int499; typedef int __attribute__ ((bitwidth(500))) int500; typedef int __attribute__ ((bitwidth(501))) int501; typedef int __attribute__ ((bitwidth(502))) int502; typedef int __attribute__ ((bitwidth(503))) int503; typedef int __attribute__ ((bitwidth(504))) int504; typedef int __attribute__ ((bitwidth(505))) int505; typedef int __attribute__ ((bitwidth(506))) int506; typedef int __attribute__ ((bitwidth(507))) int507; typedef int __attribute__ ((bitwidth(508))) int508; typedef int __attribute__ ((bitwidth(509))) int509; typedef int __attribute__ ((bitwidth(510))) int510; typedef int __attribute__ ((bitwidth(511))) int511; typedef int __attribute__ ((bitwidth(512))) int512; typedef int __attribute__ ((bitwidth(513))) int513; typedef int __attribute__ ((bitwidth(514))) int514; typedef int __attribute__ ((bitwidth(515))) int515; typedef int __attribute__ ((bitwidth(516))) int516; typedef int __attribute__ ((bitwidth(517))) int517; typedef int __attribute__ ((bitwidth(518))) int518; typedef int __attribute__ ((bitwidth(519))) int519; typedef int __attribute__ ((bitwidth(520))) int520; typedef int __attribute__ ((bitwidth(521))) int521; typedef int __attribute__ ((bitwidth(522))) int522; typedef int __attribute__ ((bitwidth(523))) int523; typedef int __attribute__ ((bitwidth(524))) int524; typedef int __attribute__ ((bitwidth(525))) int525; typedef int __attribute__ ((bitwidth(526))) int526; typedef int __attribute__ ((bitwidth(527))) int527; typedef int __attribute__ ((bitwidth(528))) int528; typedef int __attribute__ ((bitwidth(529))) int529; typedef int __attribute__ ((bitwidth(530))) int530; typedef int __attribute__ ((bitwidth(531))) int531; typedef int __attribute__ ((bitwidth(532))) int532; typedef int __attribute__ ((bitwidth(533))) int533; typedef int __attribute__ ((bitwidth(534))) int534; typedef int __attribute__ ((bitwidth(535))) int535; typedef int __attribute__ ((bitwidth(536))) int536; typedef int __attribute__ ((bitwidth(537))) int537; typedef int __attribute__ ((bitwidth(538))) int538; typedef int __attribute__ ((bitwidth(539))) int539; typedef int __attribute__ ((bitwidth(540))) int540; typedef int __attribute__ ((bitwidth(541))) int541; typedef int __attribute__ ((bitwidth(542))) int542; typedef int __attribute__ ((bitwidth(543))) int543; typedef int __attribute__ ((bitwidth(544))) int544; typedef int __attribute__ ((bitwidth(545))) int545; typedef int __attribute__ ((bitwidth(546))) int546; typedef int __attribute__ ((bitwidth(547))) int547; typedef int __attribute__ ((bitwidth(548))) int548; typedef int __attribute__ ((bitwidth(549))) int549; typedef int __attribute__ ((bitwidth(550))) int550; typedef int __attribute__ ((bitwidth(551))) int551; typedef int __attribute__ ((bitwidth(552))) int552; typedef int __attribute__ ((bitwidth(553))) int553; typedef int __attribute__ ((bitwidth(554))) int554; typedef int __attribute__ ((bitwidth(555))) int555; typedef int __attribute__ ((bitwidth(556))) int556; typedef int __attribute__ ((bitwidth(557))) int557; typedef int __attribute__ ((bitwidth(558))) int558; typedef int __attribute__ ((bitwidth(559))) int559; typedef int __attribute__ ((bitwidth(560))) int560; typedef int __attribute__ ((bitwidth(561))) int561; typedef int __attribute__ ((bitwidth(562))) int562; typedef int __attribute__ ((bitwidth(563))) int563; typedef int __attribute__ ((bitwidth(564))) int564; typedef int __attribute__ ((bitwidth(565))) int565; typedef int __attribute__ ((bitwidth(566))) int566; typedef int __attribute__ ((bitwidth(567))) int567; typedef int __attribute__ ((bitwidth(568))) int568; typedef int __attribute__ ((bitwidth(569))) int569; typedef int __attribute__ ((bitwidth(570))) int570; typedef int __attribute__ ((bitwidth(571))) int571; typedef int __attribute__ ((bitwidth(572))) int572; typedef int __attribute__ ((bitwidth(573))) int573; typedef int __attribute__ ((bitwidth(574))) int574; typedef int __attribute__ ((bitwidth(575))) int575; typedef int __attribute__ ((bitwidth(576))) int576; typedef int __attribute__ ((bitwidth(577))) int577; typedef int __attribute__ ((bitwidth(578))) int578; typedef int __attribute__ ((bitwidth(579))) int579; typedef int __attribute__ ((bitwidth(580))) int580; typedef int __attribute__ ((bitwidth(581))) int581; typedef int __attribute__ ((bitwidth(582))) int582; typedef int __attribute__ ((bitwidth(583))) int583; typedef int __attribute__ ((bitwidth(584))) int584; typedef int __attribute__ ((bitwidth(585))) int585; typedef int __attribute__ ((bitwidth(586))) int586; typedef int __attribute__ ((bitwidth(587))) int587; typedef int __attribute__ ((bitwidth(588))) int588; typedef int __attribute__ ((bitwidth(589))) int589; typedef int __attribute__ ((bitwidth(590))) int590; typedef int __attribute__ ((bitwidth(591))) int591; typedef int __attribute__ ((bitwidth(592))) int592; typedef int __attribute__ ((bitwidth(593))) int593; typedef int __attribute__ ((bitwidth(594))) int594; typedef int __attribute__ ((bitwidth(595))) int595; typedef int __attribute__ ((bitwidth(596))) int596; typedef int __attribute__ ((bitwidth(597))) int597; typedef int __attribute__ ((bitwidth(598))) int598; typedef int __attribute__ ((bitwidth(599))) int599; typedef int __attribute__ ((bitwidth(600))) int600; typedef int __attribute__ ((bitwidth(601))) int601; typedef int __attribute__ ((bitwidth(602))) int602; typedef int __attribute__ ((bitwidth(603))) int603; typedef int __attribute__ ((bitwidth(604))) int604; typedef int __attribute__ ((bitwidth(605))) int605; typedef int __attribute__ ((bitwidth(606))) int606; typedef int __attribute__ ((bitwidth(607))) int607; typedef int __attribute__ ((bitwidth(608))) int608; typedef int __attribute__ ((bitwidth(609))) int609; typedef int __attribute__ ((bitwidth(610))) int610; typedef int __attribute__ ((bitwidth(611))) int611; typedef int __attribute__ ((bitwidth(612))) int612; typedef int __attribute__ ((bitwidth(613))) int613; typedef int __attribute__ ((bitwidth(614))) int614; typedef int __attribute__ ((bitwidth(615))) int615; typedef int __attribute__ ((bitwidth(616))) int616; typedef int __attribute__ ((bitwidth(617))) int617; typedef int __attribute__ ((bitwidth(618))) int618; typedef int __attribute__ ((bitwidth(619))) int619; typedef int __attribute__ ((bitwidth(620))) int620; typedef int __attribute__ ((bitwidth(621))) int621; typedef int __attribute__ ((bitwidth(622))) int622; typedef int __attribute__ ((bitwidth(623))) int623; typedef int __attribute__ ((bitwidth(624))) int624; typedef int __attribute__ ((bitwidth(625))) int625; typedef int __attribute__ ((bitwidth(626))) int626; typedef int __attribute__ ((bitwidth(627))) int627; typedef int __attribute__ ((bitwidth(628))) int628; typedef int __attribute__ ((bitwidth(629))) int629; typedef int __attribute__ ((bitwidth(630))) int630; typedef int __attribute__ ((bitwidth(631))) int631; typedef int __attribute__ ((bitwidth(632))) int632; typedef int __attribute__ ((bitwidth(633))) int633; typedef int __attribute__ ((bitwidth(634))) int634; typedef int __attribute__ ((bitwidth(635))) int635; typedef int __attribute__ ((bitwidth(636))) int636; typedef int __attribute__ ((bitwidth(637))) int637; typedef int __attribute__ ((bitwidth(638))) int638; typedef int __attribute__ ((bitwidth(639))) int639; typedef int __attribute__ ((bitwidth(640))) int640; typedef int __attribute__ ((bitwidth(641))) int641; typedef int __attribute__ ((bitwidth(642))) int642; typedef int __attribute__ ((bitwidth(643))) int643; typedef int __attribute__ ((bitwidth(644))) int644; typedef int __attribute__ ((bitwidth(645))) int645; typedef int __attribute__ ((bitwidth(646))) int646; typedef int __attribute__ ((bitwidth(647))) int647; typedef int __attribute__ ((bitwidth(648))) int648; typedef int __attribute__ ((bitwidth(649))) int649; typedef int __attribute__ ((bitwidth(650))) int650; typedef int __attribute__ ((bitwidth(651))) int651; typedef int __attribute__ ((bitwidth(652))) int652; typedef int __attribute__ ((bitwidth(653))) int653; typedef int __attribute__ ((bitwidth(654))) int654; typedef int __attribute__ ((bitwidth(655))) int655; typedef int __attribute__ ((bitwidth(656))) int656; typedef int __attribute__ ((bitwidth(657))) int657; typedef int __attribute__ ((bitwidth(658))) int658; typedef int __attribute__ ((bitwidth(659))) int659; typedef int __attribute__ ((bitwidth(660))) int660; typedef int __attribute__ ((bitwidth(661))) int661; typedef int __attribute__ ((bitwidth(662))) int662; typedef int __attribute__ ((bitwidth(663))) int663; typedef int __attribute__ ((bitwidth(664))) int664; typedef int __attribute__ ((bitwidth(665))) int665; typedef int __attribute__ ((bitwidth(666))) int666; typedef int __attribute__ ((bitwidth(667))) int667; typedef int __attribute__ ((bitwidth(668))) int668; typedef int __attribute__ ((bitwidth(669))) int669; typedef int __attribute__ ((bitwidth(670))) int670; typedef int __attribute__ ((bitwidth(671))) int671; typedef int __attribute__ ((bitwidth(672))) int672; typedef int __attribute__ ((bitwidth(673))) int673; typedef int __attribute__ ((bitwidth(674))) int674; typedef int __attribute__ ((bitwidth(675))) int675; typedef int __attribute__ ((bitwidth(676))) int676; typedef int __attribute__ ((bitwidth(677))) int677; typedef int __attribute__ ((bitwidth(678))) int678; typedef int __attribute__ ((bitwidth(679))) int679; typedef int __attribute__ ((bitwidth(680))) int680; typedef int __attribute__ ((bitwidth(681))) int681; typedef int __attribute__ ((bitwidth(682))) int682; typedef int __attribute__ ((bitwidth(683))) int683; typedef int __attribute__ ((bitwidth(684))) int684; typedef int __attribute__ ((bitwidth(685))) int685; typedef int __attribute__ ((bitwidth(686))) int686; typedef int __attribute__ ((bitwidth(687))) int687; typedef int __attribute__ ((bitwidth(688))) int688; typedef int __attribute__ ((bitwidth(689))) int689; typedef int __attribute__ ((bitwidth(690))) int690; typedef int __attribute__ ((bitwidth(691))) int691; typedef int __attribute__ ((bitwidth(692))) int692; typedef int __attribute__ ((bitwidth(693))) int693; typedef int __attribute__ ((bitwidth(694))) int694; typedef int __attribute__ ((bitwidth(695))) int695; typedef int __attribute__ ((bitwidth(696))) int696; typedef int __attribute__ ((bitwidth(697))) int697; typedef int __attribute__ ((bitwidth(698))) int698; typedef int __attribute__ ((bitwidth(699))) int699; typedef int __attribute__ ((bitwidth(700))) int700; typedef int __attribute__ ((bitwidth(701))) int701; typedef int __attribute__ ((bitwidth(702))) int702; typedef int __attribute__ ((bitwidth(703))) int703; typedef int __attribute__ ((bitwidth(704))) int704; typedef int __attribute__ ((bitwidth(705))) int705; typedef int __attribute__ ((bitwidth(706))) int706; typedef int __attribute__ ((bitwidth(707))) int707; typedef int __attribute__ ((bitwidth(708))) int708; typedef int __attribute__ ((bitwidth(709))) int709; typedef int __attribute__ ((bitwidth(710))) int710; typedef int __attribute__ ((bitwidth(711))) int711; typedef int __attribute__ ((bitwidth(712))) int712; typedef int __attribute__ ((bitwidth(713))) int713; typedef int __attribute__ ((bitwidth(714))) int714; typedef int __attribute__ ((bitwidth(715))) int715; typedef int __attribute__ ((bitwidth(716))) int716; typedef int __attribute__ ((bitwidth(717))) int717; typedef int __attribute__ ((bitwidth(718))) int718; typedef int __attribute__ ((bitwidth(719))) int719; typedef int __attribute__ ((bitwidth(720))) int720; typedef int __attribute__ ((bitwidth(721))) int721; typedef int __attribute__ ((bitwidth(722))) int722; typedef int __attribute__ ((bitwidth(723))) int723; typedef int __attribute__ ((bitwidth(724))) int724; typedef int __attribute__ ((bitwidth(725))) int725; typedef int __attribute__ ((bitwidth(726))) int726; typedef int __attribute__ ((bitwidth(727))) int727; typedef int __attribute__ ((bitwidth(728))) int728; typedef int __attribute__ ((bitwidth(729))) int729; typedef int __attribute__ ((bitwidth(730))) int730; typedef int __attribute__ ((bitwidth(731))) int731; typedef int __attribute__ ((bitwidth(732))) int732; typedef int __attribute__ ((bitwidth(733))) int733; typedef int __attribute__ ((bitwidth(734))) int734; typedef int __attribute__ ((bitwidth(735))) int735; typedef int __attribute__ ((bitwidth(736))) int736; typedef int __attribute__ ((bitwidth(737))) int737; typedef int __attribute__ ((bitwidth(738))) int738; typedef int __attribute__ ((bitwidth(739))) int739; typedef int __attribute__ ((bitwidth(740))) int740; typedef int __attribute__ ((bitwidth(741))) int741; typedef int __attribute__ ((bitwidth(742))) int742; typedef int __attribute__ ((bitwidth(743))) int743; typedef int __attribute__ ((bitwidth(744))) int744; typedef int __attribute__ ((bitwidth(745))) int745; typedef int __attribute__ ((bitwidth(746))) int746; typedef int __attribute__ ((bitwidth(747))) int747; typedef int __attribute__ ((bitwidth(748))) int748; typedef int __attribute__ ((bitwidth(749))) int749; typedef int __attribute__ ((bitwidth(750))) int750; typedef int __attribute__ ((bitwidth(751))) int751; typedef int __attribute__ ((bitwidth(752))) int752; typedef int __attribute__ ((bitwidth(753))) int753; typedef int __attribute__ ((bitwidth(754))) int754; typedef int __attribute__ ((bitwidth(755))) int755; typedef int __attribute__ ((bitwidth(756))) int756; typedef int __attribute__ ((bitwidth(757))) int757; typedef int __attribute__ ((bitwidth(758))) int758; typedef int __attribute__ ((bitwidth(759))) int759; typedef int __attribute__ ((bitwidth(760))) int760; typedef int __attribute__ ((bitwidth(761))) int761; typedef int __attribute__ ((bitwidth(762))) int762; typedef int __attribute__ ((bitwidth(763))) int763; typedef int __attribute__ ((bitwidth(764))) int764; typedef int __attribute__ ((bitwidth(765))) int765; typedef int __attribute__ ((bitwidth(766))) int766; typedef int __attribute__ ((bitwidth(767))) int767; typedef int __attribute__ ((bitwidth(768))) int768; typedef int __attribute__ ((bitwidth(769))) int769; typedef int __attribute__ ((bitwidth(770))) int770; typedef int __attribute__ ((bitwidth(771))) int771; typedef int __attribute__ ((bitwidth(772))) int772; typedef int __attribute__ ((bitwidth(773))) int773; typedef int __attribute__ ((bitwidth(774))) int774; typedef int __attribute__ ((bitwidth(775))) int775; typedef int __attribute__ ((bitwidth(776))) int776; typedef int __attribute__ ((bitwidth(777))) int777; typedef int __attribute__ ((bitwidth(778))) int778; typedef int __attribute__ ((bitwidth(779))) int779; typedef int __attribute__ ((bitwidth(780))) int780; typedef int __attribute__ ((bitwidth(781))) int781; typedef int __attribute__ ((bitwidth(782))) int782; typedef int __attribute__ ((bitwidth(783))) int783; typedef int __attribute__ ((bitwidth(784))) int784; typedef int __attribute__ ((bitwidth(785))) int785; typedef int __attribute__ ((bitwidth(786))) int786; typedef int __attribute__ ((bitwidth(787))) int787; typedef int __attribute__ ((bitwidth(788))) int788; typedef int __attribute__ ((bitwidth(789))) int789; typedef int __attribute__ ((bitwidth(790))) int790; typedef int __attribute__ ((bitwidth(791))) int791; typedef int __attribute__ ((bitwidth(792))) int792; typedef int __attribute__ ((bitwidth(793))) int793; typedef int __attribute__ ((bitwidth(794))) int794; typedef int __attribute__ ((bitwidth(795))) int795; typedef int __attribute__ ((bitwidth(796))) int796; typedef int __attribute__ ((bitwidth(797))) int797; typedef int __attribute__ ((bitwidth(798))) int798; typedef int __attribute__ ((bitwidth(799))) int799; typedef int __attribute__ ((bitwidth(800))) int800; typedef int __attribute__ ((bitwidth(801))) int801; typedef int __attribute__ ((bitwidth(802))) int802; typedef int __attribute__ ((bitwidth(803))) int803; typedef int __attribute__ ((bitwidth(804))) int804; typedef int __attribute__ ((bitwidth(805))) int805; typedef int __attribute__ ((bitwidth(806))) int806; typedef int __attribute__ ((bitwidth(807))) int807; typedef int __attribute__ ((bitwidth(808))) int808; typedef int __attribute__ ((bitwidth(809))) int809; typedef int __attribute__ ((bitwidth(810))) int810; typedef int __attribute__ ((bitwidth(811))) int811; typedef int __attribute__ ((bitwidth(812))) int812; typedef int __attribute__ ((bitwidth(813))) int813; typedef int __attribute__ ((bitwidth(814))) int814; typedef int __attribute__ ((bitwidth(815))) int815; typedef int __attribute__ ((bitwidth(816))) int816; typedef int __attribute__ ((bitwidth(817))) int817; typedef int __attribute__ ((bitwidth(818))) int818; typedef int __attribute__ ((bitwidth(819))) int819; typedef int __attribute__ ((bitwidth(820))) int820; typedef int __attribute__ ((bitwidth(821))) int821; typedef int __attribute__ ((bitwidth(822))) int822; typedef int __attribute__ ((bitwidth(823))) int823; typedef int __attribute__ ((bitwidth(824))) int824; typedef int __attribute__ ((bitwidth(825))) int825; typedef int __attribute__ ((bitwidth(826))) int826; typedef int __attribute__ ((bitwidth(827))) int827; typedef int __attribute__ ((bitwidth(828))) int828; typedef int __attribute__ ((bitwidth(829))) int829; typedef int __attribute__ ((bitwidth(830))) int830; typedef int __attribute__ ((bitwidth(831))) int831; typedef int __attribute__ ((bitwidth(832))) int832; typedef int __attribute__ ((bitwidth(833))) int833; typedef int __attribute__ ((bitwidth(834))) int834; typedef int __attribute__ ((bitwidth(835))) int835; typedef int __attribute__ ((bitwidth(836))) int836; typedef int __attribute__ ((bitwidth(837))) int837; typedef int __attribute__ ((bitwidth(838))) int838; typedef int __attribute__ ((bitwidth(839))) int839; typedef int __attribute__ ((bitwidth(840))) int840; typedef int __attribute__ ((bitwidth(841))) int841; typedef int __attribute__ ((bitwidth(842))) int842; typedef int __attribute__ ((bitwidth(843))) int843; typedef int __attribute__ ((bitwidth(844))) int844; typedef int __attribute__ ((bitwidth(845))) int845; typedef int __attribute__ ((bitwidth(846))) int846; typedef int __attribute__ ((bitwidth(847))) int847; typedef int __attribute__ ((bitwidth(848))) int848; typedef int __attribute__ ((bitwidth(849))) int849; typedef int __attribute__ ((bitwidth(850))) int850; typedef int __attribute__ ((bitwidth(851))) int851; typedef int __attribute__ ((bitwidth(852))) int852; typedef int __attribute__ ((bitwidth(853))) int853; typedef int __attribute__ ((bitwidth(854))) int854; typedef int __attribute__ ((bitwidth(855))) int855; typedef int __attribute__ ((bitwidth(856))) int856; typedef int __attribute__ ((bitwidth(857))) int857; typedef int __attribute__ ((bitwidth(858))) int858; typedef int __attribute__ ((bitwidth(859))) int859; typedef int __attribute__ ((bitwidth(860))) int860; typedef int __attribute__ ((bitwidth(861))) int861; typedef int __attribute__ ((bitwidth(862))) int862; typedef int __attribute__ ((bitwidth(863))) int863; typedef int __attribute__ ((bitwidth(864))) int864; typedef int __attribute__ ((bitwidth(865))) int865; typedef int __attribute__ ((bitwidth(866))) int866; typedef int __attribute__ ((bitwidth(867))) int867; typedef int __attribute__ ((bitwidth(868))) int868; typedef int __attribute__ ((bitwidth(869))) int869; typedef int __attribute__ ((bitwidth(870))) int870; typedef int __attribute__ ((bitwidth(871))) int871; typedef int __attribute__ ((bitwidth(872))) int872; typedef int __attribute__ ((bitwidth(873))) int873; typedef int __attribute__ ((bitwidth(874))) int874; typedef int __attribute__ ((bitwidth(875))) int875; typedef int __attribute__ ((bitwidth(876))) int876; typedef int __attribute__ ((bitwidth(877))) int877; typedef int __attribute__ ((bitwidth(878))) int878; typedef int __attribute__ ((bitwidth(879))) int879; typedef int __attribute__ ((bitwidth(880))) int880; typedef int __attribute__ ((bitwidth(881))) int881; typedef int __attribute__ ((bitwidth(882))) int882; typedef int __attribute__ ((bitwidth(883))) int883; typedef int __attribute__ ((bitwidth(884))) int884; typedef int __attribute__ ((bitwidth(885))) int885; typedef int __attribute__ ((bitwidth(886))) int886; typedef int __attribute__ ((bitwidth(887))) int887; typedef int __attribute__ ((bitwidth(888))) int888; typedef int __attribute__ ((bitwidth(889))) int889; typedef int __attribute__ ((bitwidth(890))) int890; typedef int __attribute__ ((bitwidth(891))) int891; typedef int __attribute__ ((bitwidth(892))) int892; typedef int __attribute__ ((bitwidth(893))) int893; typedef int __attribute__ ((bitwidth(894))) int894; typedef int __attribute__ ((bitwidth(895))) int895; typedef int __attribute__ ((bitwidth(896))) int896; typedef int __attribute__ ((bitwidth(897))) int897; typedef int __attribute__ ((bitwidth(898))) int898; typedef int __attribute__ ((bitwidth(899))) int899; typedef int __attribute__ ((bitwidth(900))) int900; typedef int __attribute__ ((bitwidth(901))) int901; typedef int __attribute__ ((bitwidth(902))) int902; typedef int __attribute__ ((bitwidth(903))) int903; typedef int __attribute__ ((bitwidth(904))) int904; typedef int __attribute__ ((bitwidth(905))) int905; typedef int __attribute__ ((bitwidth(906))) int906; typedef int __attribute__ ((bitwidth(907))) int907; typedef int __attribute__ ((bitwidth(908))) int908; typedef int __attribute__ ((bitwidth(909))) int909; typedef int __attribute__ ((bitwidth(910))) int910; typedef int __attribute__ ((bitwidth(911))) int911; typedef int __attribute__ ((bitwidth(912))) int912; typedef int __attribute__ ((bitwidth(913))) int913; typedef int __attribute__ ((bitwidth(914))) int914; typedef int __attribute__ ((bitwidth(915))) int915; typedef int __attribute__ ((bitwidth(916))) int916; typedef int __attribute__ ((bitwidth(917))) int917; typedef int __attribute__ ((bitwidth(918))) int918; typedef int __attribute__ ((bitwidth(919))) int919; typedef int __attribute__ ((bitwidth(920))) int920; typedef int __attribute__ ((bitwidth(921))) int921; typedef int __attribute__ ((bitwidth(922))) int922; typedef int __attribute__ ((bitwidth(923))) int923; typedef int __attribute__ ((bitwidth(924))) int924; typedef int __attribute__ ((bitwidth(925))) int925; typedef int __attribute__ ((bitwidth(926))) int926; typedef int __attribute__ ((bitwidth(927))) int927; typedef int __attribute__ ((bitwidth(928))) int928; typedef int __attribute__ ((bitwidth(929))) int929; typedef int __attribute__ ((bitwidth(930))) int930; typedef int __attribute__ ((bitwidth(931))) int931; typedef int __attribute__ ((bitwidth(932))) int932; typedef int __attribute__ ((bitwidth(933))) int933; typedef int __attribute__ ((bitwidth(934))) int934; typedef int __attribute__ ((bitwidth(935))) int935; typedef int __attribute__ ((bitwidth(936))) int936; typedef int __attribute__ ((bitwidth(937))) int937; typedef int __attribute__ ((bitwidth(938))) int938; typedef int __attribute__ ((bitwidth(939))) int939; typedef int __attribute__ ((bitwidth(940))) int940; typedef int __attribute__ ((bitwidth(941))) int941; typedef int __attribute__ ((bitwidth(942))) int942; typedef int __attribute__ ((bitwidth(943))) int943; typedef int __attribute__ ((bitwidth(944))) int944; typedef int __attribute__ ((bitwidth(945))) int945; typedef int __attribute__ ((bitwidth(946))) int946; typedef int __attribute__ ((bitwidth(947))) int947; typedef int __attribute__ ((bitwidth(948))) int948; typedef int __attribute__ ((bitwidth(949))) int949; typedef int __attribute__ ((bitwidth(950))) int950; typedef int __attribute__ ((bitwidth(951))) int951; typedef int __attribute__ ((bitwidth(952))) int952; typedef int __attribute__ ((bitwidth(953))) int953; typedef int __attribute__ ((bitwidth(954))) int954; typedef int __attribute__ ((bitwidth(955))) int955; typedef int __attribute__ ((bitwidth(956))) int956; typedef int __attribute__ ((bitwidth(957))) int957; typedef int __attribute__ ((bitwidth(958))) int958; typedef int __attribute__ ((bitwidth(959))) int959; typedef int __attribute__ ((bitwidth(960))) int960; typedef int __attribute__ ((bitwidth(961))) int961; typedef int __attribute__ ((bitwidth(962))) int962; typedef int __attribute__ ((bitwidth(963))) int963; typedef int __attribute__ ((bitwidth(964))) int964; typedef int __attribute__ ((bitwidth(965))) int965; typedef int __attribute__ ((bitwidth(966))) int966; typedef int __attribute__ ((bitwidth(967))) int967; typedef int __attribute__ ((bitwidth(968))) int968; typedef int __attribute__ ((bitwidth(969))) int969; typedef int __attribute__ ((bitwidth(970))) int970; typedef int __attribute__ ((bitwidth(971))) int971; typedef int __attribute__ ((bitwidth(972))) int972; typedef int __attribute__ ((bitwidth(973))) int973; typedef int __attribute__ ((bitwidth(974))) int974; typedef int __attribute__ ((bitwidth(975))) int975; typedef int __attribute__ ((bitwidth(976))) int976; typedef int __attribute__ ((bitwidth(977))) int977; typedef int __attribute__ ((bitwidth(978))) int978; typedef int __attribute__ ((bitwidth(979))) int979; typedef int __attribute__ ((bitwidth(980))) int980; typedef int __attribute__ ((bitwidth(981))) int981; typedef int __attribute__ ((bitwidth(982))) int982; typedef int __attribute__ ((bitwidth(983))) int983; typedef int __attribute__ ((bitwidth(984))) int984; typedef int __attribute__ ((bitwidth(985))) int985; typedef int __attribute__ ((bitwidth(986))) int986; typedef int __attribute__ ((bitwidth(987))) int987; typedef int __attribute__ ((bitwidth(988))) int988; typedef int __attribute__ ((bitwidth(989))) int989; typedef int __attribute__ ((bitwidth(990))) int990; typedef int __attribute__ ((bitwidth(991))) int991; typedef int __attribute__ ((bitwidth(992))) int992; typedef int __attribute__ ((bitwidth(993))) int993; typedef int __attribute__ ((bitwidth(994))) int994; typedef int __attribute__ ((bitwidth(995))) int995; typedef int __attribute__ ((bitwidth(996))) int996; typedef int __attribute__ ((bitwidth(997))) int997; typedef int __attribute__ ((bitwidth(998))) int998; typedef int __attribute__ ((bitwidth(999))) int999; typedef int __attribute__ ((bitwidth(1000))) int1000; typedef int __attribute__ ((bitwidth(1001))) int1001; typedef int __attribute__ ((bitwidth(1002))) int1002; typedef int __attribute__ ((bitwidth(1003))) int1003; typedef int __attribute__ ((bitwidth(1004))) int1004; typedef int __attribute__ ((bitwidth(1005))) int1005; typedef int __attribute__ ((bitwidth(1006))) int1006; typedef int __attribute__ ((bitwidth(1007))) int1007; typedef int __attribute__ ((bitwidth(1008))) int1008; typedef int __attribute__ ((bitwidth(1009))) int1009; typedef int __attribute__ ((bitwidth(1010))) int1010; typedef int __attribute__ ((bitwidth(1011))) int1011; typedef int __attribute__ ((bitwidth(1012))) int1012; typedef int __attribute__ ((bitwidth(1013))) int1013; typedef int __attribute__ ((bitwidth(1014))) int1014; typedef int __attribute__ ((bitwidth(1015))) int1015; typedef int __attribute__ ((bitwidth(1016))) int1016; typedef int __attribute__ ((bitwidth(1017))) int1017; typedef int __attribute__ ((bitwidth(1018))) int1018; typedef int __attribute__ ((bitwidth(1019))) int1019; typedef int __attribute__ ((bitwidth(1020))) int1020; typedef int __attribute__ ((bitwidth(1021))) int1021; typedef int __attribute__ ((bitwidth(1022))) int1022; typedef int __attribute__ ((bitwidth(1023))) int1023; typedef int __attribute__ ((bitwidth(1024))) int1024; # 98 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/common/technology/autopilot\\etc/autopilot_dt.h" 2 # 1 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/common/technology/autopilot\\etc/autopilot_dt_ext.def" 1 typedef int __attribute__ ((bitwidth(1025))) int1025; typedef int __attribute__ ((bitwidth(1026))) int1026; typedef int __attribute__ ((bitwidth(1027))) int1027; typedef int __attribute__ ((bitwidth(1028))) int1028; typedef int __attribute__ ((bitwidth(1029))) int1029; typedef int __attribute__ ((bitwidth(1030))) int1030; typedef int __attribute__ ((bitwidth(1031))) int1031; typedef int __attribute__ ((bitwidth(1032))) int1032; typedef int __attribute__ ((bitwidth(1033))) int1033; typedef int __attribute__ ((bitwidth(1034))) int1034; typedef int __attribute__ ((bitwidth(1035))) int1035; typedef int __attribute__ ((bitwidth(1036))) int1036; typedef int __attribute__ ((bitwidth(1037))) int1037; typedef int __attribute__ ((bitwidth(1038))) int1038; typedef int __attribute__ ((bitwidth(1039))) int1039; typedef int __attribute__ ((bitwidth(1040))) int1040; typedef int __attribute__ ((bitwidth(1041))) int1041; typedef int __attribute__ ((bitwidth(1042))) int1042; typedef int __attribute__ ((bitwidth(1043))) int1043; typedef int __attribute__ ((bitwidth(1044))) int1044; typedef int __attribute__ ((bitwidth(1045))) int1045; typedef int __attribute__ ((bitwidth(1046))) int1046; typedef int __attribute__ ((bitwidth(1047))) int1047; typedef int __attribute__ ((bitwidth(1048))) int1048; typedef int __attribute__ ((bitwidth(1049))) int1049; typedef int __attribute__ ((bitwidth(1050))) int1050; typedef int __attribute__ ((bitwidth(1051))) int1051; typedef int __attribute__ ((bitwidth(1052))) int1052; typedef int __attribute__ ((bitwidth(1053))) int1053; typedef int __attribute__ ((bitwidth(1054))) int1054; typedef int __attribute__ ((bitwidth(1055))) int1055; typedef int __attribute__ ((bitwidth(1056))) int1056; typedef int __attribute__ ((bitwidth(1057))) int1057; typedef int __attribute__ ((bitwidth(1058))) int1058; typedef int __attribute__ ((bitwidth(1059))) int1059; typedef int __attribute__ ((bitwidth(1060))) int1060; typedef int __attribute__ ((bitwidth(1061))) int1061; typedef int __attribute__ ((bitwidth(1062))) int1062; typedef int __attribute__ ((bitwidth(1063))) int1063; typedef int __attribute__ ((bitwidth(1064))) int1064; typedef int __attribute__ ((bitwidth(1065))) int1065; typedef int __attribute__ ((bitwidth(1066))) int1066; typedef int __attribute__ ((bitwidth(1067))) int1067; typedef int __attribute__ ((bitwidth(1068))) int1068; typedef int __attribute__ ((bitwidth(1069))) int1069; typedef int __attribute__ ((bitwidth(1070))) int1070; typedef int __attribute__ ((bitwidth(1071))) int1071; typedef int __attribute__ ((bitwidth(1072))) int1072; typedef int __attribute__ ((bitwidth(1073))) int1073; typedef int __attribute__ ((bitwidth(1074))) int1074; typedef int __attribute__ ((bitwidth(1075))) int1075; typedef int __attribute__ ((bitwidth(1076))) int1076; typedef int __attribute__ ((bitwidth(1077))) int1077; typedef int __attribute__ ((bitwidth(1078))) int1078; typedef int __attribute__ ((bitwidth(1079))) int1079; typedef int __attribute__ ((bitwidth(1080))) int1080; typedef int __attribute__ ((bitwidth(1081))) int1081; typedef int __attribute__ ((bitwidth(1082))) int1082; typedef int __attribute__ ((bitwidth(1083))) int1083; typedef int __attribute__ ((bitwidth(1084))) int1084; typedef int __attribute__ ((bitwidth(1085))) int1085; typedef int __attribute__ ((bitwidth(1086))) int1086; typedef int __attribute__ ((bitwidth(1087))) int1087; typedef int __attribute__ ((bitwidth(1088))) int1088; typedef int __attribute__ ((bitwidth(1089))) int1089; typedef int __attribute__ ((bitwidth(1090))) int1090; typedef int __attribute__ ((bitwidth(1091))) int1091; typedef int __attribute__ ((bitwidth(1092))) int1092; typedef int __attribute__ ((bitwidth(1093))) int1093; typedef int __attribute__ ((bitwidth(1094))) int1094; typedef int __attribute__ ((bitwidth(1095))) int1095; typedef int __attribute__ ((bitwidth(1096))) int1096; typedef int __attribute__ ((bitwidth(1097))) int1097; typedef int __attribute__ ((bitwidth(1098))) int1098; typedef int __attribute__ ((bitwidth(1099))) int1099; typedef int __attribute__ ((bitwidth(1100))) int1100; typedef int __attribute__ ((bitwidth(1101))) int1101; typedef int __attribute__ ((bitwidth(1102))) int1102; typedef int __attribute__ ((bitwidth(1103))) int1103; typedef int __attribute__ ((bitwidth(1104))) int1104; typedef int __attribute__ ((bitwidth(1105))) int1105; typedef int __attribute__ ((bitwidth(1106))) int1106; typedef int __attribute__ ((bitwidth(1107))) int1107; typedef int __attribute__ ((bitwidth(1108))) int1108; typedef int __attribute__ ((bitwidth(1109))) int1109; typedef int __attribute__ ((bitwidth(1110))) int1110; typedef int __attribute__ ((bitwidth(1111))) int1111; typedef int __attribute__ ((bitwidth(1112))) int1112; typedef int __attribute__ ((bitwidth(1113))) int1113; typedef int __attribute__ ((bitwidth(1114))) int1114; typedef int __attribute__ ((bitwidth(1115))) int1115; typedef int __attribute__ ((bitwidth(1116))) int1116; typedef int __attribute__ ((bitwidth(1117))) int1117; typedef int __attribute__ ((bitwidth(1118))) int1118; typedef int __attribute__ ((bitwidth(1119))) int1119; typedef int __attribute__ ((bitwidth(1120))) int1120; typedef int __attribute__ ((bitwidth(1121))) int1121; typedef int __attribute__ ((bitwidth(1122))) int1122; typedef int __attribute__ ((bitwidth(1123))) int1123; typedef int __attribute__ ((bitwidth(1124))) int1124; typedef int __attribute__ ((bitwidth(1125))) int1125; typedef int __attribute__ ((bitwidth(1126))) int1126; typedef int __attribute__ ((bitwidth(1127))) int1127; typedef int __attribute__ ((bitwidth(1128))) int1128; typedef int __attribute__ ((bitwidth(1129))) int1129; typedef int __attribute__ ((bitwidth(1130))) int1130; typedef int __attribute__ ((bitwidth(1131))) int1131; typedef int __attribute__ ((bitwidth(1132))) int1132; typedef int __attribute__ ((bitwidth(1133))) int1133; typedef int __attribute__ ((bitwidth(1134))) int1134; typedef int __attribute__ ((bitwidth(1135))) int1135; typedef int __attribute__ ((bitwidth(1136))) int1136; typedef int __attribute__ ((bitwidth(1137))) int1137; typedef int __attribute__ ((bitwidth(1138))) int1138; typedef int __attribute__ ((bitwidth(1139))) int1139; typedef int __attribute__ ((bitwidth(1140))) int1140; typedef int __attribute__ ((bitwidth(1141))) int1141; typedef int __attribute__ ((bitwidth(1142))) int1142; typedef int __attribute__ ((bitwidth(1143))) int1143; typedef int __attribute__ ((bitwidth(1144))) int1144; typedef int __attribute__ ((bitwidth(1145))) int1145; typedef int __attribute__ ((bitwidth(1146))) int1146; typedef int __attribute__ ((bitwidth(1147))) int1147; typedef int __attribute__ ((bitwidth(1148))) int1148; typedef int __attribute__ ((bitwidth(1149))) int1149; typedef int __attribute__ ((bitwidth(1150))) int1150; typedef int __attribute__ ((bitwidth(1151))) int1151; typedef int __attribute__ ((bitwidth(1152))) int1152; typedef int __attribute__ ((bitwidth(1153))) int1153; typedef int __attribute__ ((bitwidth(1154))) int1154; typedef int __attribute__ ((bitwidth(1155))) int1155; typedef int __attribute__ ((bitwidth(1156))) int1156; typedef int __attribute__ ((bitwidth(1157))) int1157; typedef int __attribute__ ((bitwidth(1158))) int1158; typedef int __attribute__ ((bitwidth(1159))) int1159; typedef int __attribute__ ((bitwidth(1160))) int1160; typedef int __attribute__ ((bitwidth(1161))) int1161; typedef int __attribute__ ((bitwidth(1162))) int1162; typedef int __attribute__ ((bitwidth(1163))) int1163; typedef int __attribute__ ((bitwidth(1164))) int1164; typedef int __attribute__ ((bitwidth(1165))) int1165; typedef int __attribute__ ((bitwidth(1166))) int1166; typedef int __attribute__ ((bitwidth(1167))) int1167; typedef int __attribute__ ((bitwidth(1168))) int1168; typedef int __attribute__ ((bitwidth(1169))) int1169; typedef int __attribute__ ((bitwidth(1170))) int1170; typedef int __attribute__ ((bitwidth(1171))) int1171; typedef int __attribute__ ((bitwidth(1172))) int1172; typedef int __attribute__ ((bitwidth(1173))) int1173; typedef int __attribute__ ((bitwidth(1174))) int1174; typedef int __attribute__ ((bitwidth(1175))) int1175; typedef int __attribute__ ((bitwidth(1176))) int1176; typedef int __attribute__ ((bitwidth(1177))) int1177; typedef int __attribute__ ((bitwidth(1178))) int1178; typedef int __attribute__ ((bitwidth(1179))) int1179; typedef int __attribute__ ((bitwidth(1180))) int1180; typedef int __attribute__ ((bitwidth(1181))) int1181; typedef int __attribute__ ((bitwidth(1182))) int1182; typedef int __attribute__ ((bitwidth(1183))) int1183; typedef int __attribute__ ((bitwidth(1184))) int1184; typedef int __attribute__ ((bitwidth(1185))) int1185; typedef int __attribute__ ((bitwidth(1186))) int1186; typedef int __attribute__ ((bitwidth(1187))) int1187; typedef int __attribute__ ((bitwidth(1188))) int1188; typedef int __attribute__ ((bitwidth(1189))) int1189; typedef int __attribute__ ((bitwidth(1190))) int1190; typedef int __attribute__ ((bitwidth(1191))) int1191; typedef int __attribute__ ((bitwidth(1192))) int1192; typedef int __attribute__ ((bitwidth(1193))) int1193; typedef int __attribute__ ((bitwidth(1194))) int1194; typedef int __attribute__ ((bitwidth(1195))) int1195; typedef int __attribute__ ((bitwidth(1196))) int1196; typedef int __attribute__ ((bitwidth(1197))) int1197; typedef int __attribute__ ((bitwidth(1198))) int1198; typedef int __attribute__ ((bitwidth(1199))) int1199; typedef int __attribute__ ((bitwidth(1200))) int1200; typedef int __attribute__ ((bitwidth(1201))) int1201; typedef int __attribute__ ((bitwidth(1202))) int1202; typedef int __attribute__ ((bitwidth(1203))) int1203; typedef int __attribute__ ((bitwidth(1204))) int1204; typedef int __attribute__ ((bitwidth(1205))) int1205; typedef int __attribute__ ((bitwidth(1206))) int1206; typedef int __attribute__ ((bitwidth(1207))) int1207; typedef int __attribute__ ((bitwidth(1208))) int1208; typedef int __attribute__ ((bitwidth(1209))) int1209; typedef int __attribute__ ((bitwidth(1210))) int1210; typedef int __attribute__ ((bitwidth(1211))) int1211; typedef int __attribute__ ((bitwidth(1212))) int1212; typedef int __attribute__ ((bitwidth(1213))) int1213; typedef int __attribute__ ((bitwidth(1214))) int1214; typedef int __attribute__ ((bitwidth(1215))) int1215; typedef int __attribute__ ((bitwidth(1216))) int1216; typedef int __attribute__ ((bitwidth(1217))) int1217; typedef int __attribute__ ((bitwidth(1218))) int1218; typedef int __attribute__ ((bitwidth(1219))) int1219; typedef int __attribute__ ((bitwidth(1220))) int1220; typedef int __attribute__ ((bitwidth(1221))) int1221; typedef int __attribute__ ((bitwidth(1222))) int1222; typedef int __attribute__ ((bitwidth(1223))) int1223; typedef int __attribute__ ((bitwidth(1224))) int1224; typedef int __attribute__ ((bitwidth(1225))) int1225; typedef int __attribute__ ((bitwidth(1226))) int1226; typedef int __attribute__ ((bitwidth(1227))) int1227; typedef int __attribute__ ((bitwidth(1228))) int1228; typedef int __attribute__ ((bitwidth(1229))) int1229; typedef int __attribute__ ((bitwidth(1230))) int1230; typedef int __attribute__ ((bitwidth(1231))) int1231; typedef int __attribute__ ((bitwidth(1232))) int1232; typedef int __attribute__ ((bitwidth(1233))) int1233; typedef int __attribute__ ((bitwidth(1234))) int1234; typedef int __attribute__ ((bitwidth(1235))) int1235; typedef int __attribute__ ((bitwidth(1236))) int1236; typedef int __attribute__ ((bitwidth(1237))) int1237; typedef int __attribute__ ((bitwidth(1238))) int1238; typedef int __attribute__ ((bitwidth(1239))) int1239; typedef int __attribute__ ((bitwidth(1240))) int1240; typedef int __attribute__ ((bitwidth(1241))) int1241; typedef int __attribute__ ((bitwidth(1242))) int1242; typedef int __attribute__ ((bitwidth(1243))) int1243; typedef int __attribute__ ((bitwidth(1244))) int1244; typedef int __attribute__ ((bitwidth(1245))) int1245; typedef int __attribute__ ((bitwidth(1246))) int1246; typedef int __attribute__ ((bitwidth(1247))) int1247; typedef int __attribute__ ((bitwidth(1248))) int1248; typedef int __attribute__ ((bitwidth(1249))) int1249; typedef int __attribute__ ((bitwidth(1250))) int1250; typedef int __attribute__ ((bitwidth(1251))) int1251; typedef int __attribute__ ((bitwidth(1252))) int1252; typedef int __attribute__ ((bitwidth(1253))) int1253; typedef int __attribute__ ((bitwidth(1254))) int1254; typedef int __attribute__ ((bitwidth(1255))) int1255; typedef int __attribute__ ((bitwidth(1256))) int1256; typedef int __attribute__ ((bitwidth(1257))) int1257; typedef int __attribute__ ((bitwidth(1258))) int1258; typedef int __attribute__ ((bitwidth(1259))) int1259; typedef int __attribute__ ((bitwidth(1260))) int1260; typedef int __attribute__ ((bitwidth(1261))) int1261; typedef int __attribute__ ((bitwidth(1262))) int1262; typedef int __attribute__ ((bitwidth(1263))) int1263; typedef int __attribute__ ((bitwidth(1264))) int1264; typedef int __attribute__ ((bitwidth(1265))) int1265; typedef int __attribute__ ((bitwidth(1266))) int1266; typedef int __attribute__ ((bitwidth(1267))) int1267; typedef int __attribute__ ((bitwidth(1268))) int1268; typedef int __attribute__ ((bitwidth(1269))) int1269; typedef int __attribute__ ((bitwidth(1270))) int1270; typedef int __attribute__ ((bitwidth(1271))) int1271; typedef int __attribute__ ((bitwidth(1272))) int1272; typedef int __attribute__ ((bitwidth(1273))) int1273; typedef int __attribute__ ((bitwidth(1274))) int1274; typedef int __attribute__ ((bitwidth(1275))) int1275; typedef int __attribute__ ((bitwidth(1276))) int1276; typedef int __attribute__ ((bitwidth(1277))) int1277; typedef int __attribute__ ((bitwidth(1278))) int1278; typedef int __attribute__ ((bitwidth(1279))) int1279; typedef int __attribute__ ((bitwidth(1280))) int1280; typedef int __attribute__ ((bitwidth(1281))) int1281; typedef int __attribute__ ((bitwidth(1282))) int1282; typedef int __attribute__ ((bitwidth(1283))) int1283; typedef int __attribute__ ((bitwidth(1284))) int1284; typedef int __attribute__ ((bitwidth(1285))) int1285; typedef int __attribute__ ((bitwidth(1286))) int1286; typedef int __attribute__ ((bitwidth(1287))) int1287; typedef int __attribute__ ((bitwidth(1288))) int1288; typedef int __attribute__ ((bitwidth(1289))) int1289; typedef int __attribute__ ((bitwidth(1290))) int1290; typedef int __attribute__ ((bitwidth(1291))) int1291; typedef int __attribute__ ((bitwidth(1292))) int1292; typedef int __attribute__ ((bitwidth(1293))) int1293; typedef int __attribute__ ((bitwidth(1294))) int1294; typedef int __attribute__ ((bitwidth(1295))) int1295; typedef int __attribute__ ((bitwidth(1296))) int1296; typedef int __attribute__ ((bitwidth(1297))) int1297; typedef int __attribute__ ((bitwidth(1298))) int1298; typedef int __attribute__ ((bitwidth(1299))) int1299; typedef int __attribute__ ((bitwidth(1300))) int1300; typedef int __attribute__ ((bitwidth(1301))) int1301; typedef int __attribute__ ((bitwidth(1302))) int1302; typedef int __attribute__ ((bitwidth(1303))) int1303; typedef int __attribute__ ((bitwidth(1304))) int1304; typedef int __attribute__ ((bitwidth(1305))) int1305; typedef int __attribute__ ((bitwidth(1306))) int1306; typedef int __attribute__ ((bitwidth(1307))) int1307; typedef int __attribute__ ((bitwidth(1308))) int1308; typedef int __attribute__ ((bitwidth(1309))) int1309; typedef int __attribute__ ((bitwidth(1310))) int1310; typedef int __attribute__ ((bitwidth(1311))) int1311; typedef int __attribute__ ((bitwidth(1312))) int1312; typedef int __attribute__ ((bitwidth(1313))) int1313; typedef int __attribute__ ((bitwidth(1314))) int1314; typedef int __attribute__ ((bitwidth(1315))) int1315; typedef int __attribute__ ((bitwidth(1316))) int1316; typedef int __attribute__ ((bitwidth(1317))) int1317; typedef int __attribute__ ((bitwidth(1318))) int1318; typedef int __attribute__ ((bitwidth(1319))) int1319; typedef int __attribute__ ((bitwidth(1320))) int1320; typedef int __attribute__ ((bitwidth(1321))) int1321; typedef int __attribute__ ((bitwidth(1322))) int1322; typedef int __attribute__ ((bitwidth(1323))) int1323; typedef int __attribute__ ((bitwidth(1324))) int1324; typedef int __attribute__ ((bitwidth(1325))) int1325; typedef int __attribute__ ((bitwidth(1326))) int1326; typedef int __attribute__ ((bitwidth(1327))) int1327; typedef int __attribute__ ((bitwidth(1328))) int1328; typedef int __attribute__ ((bitwidth(1329))) int1329; typedef int __attribute__ ((bitwidth(1330))) int1330; typedef int __attribute__ ((bitwidth(1331))) int1331; typedef int __attribute__ ((bitwidth(1332))) int1332; typedef int __attribute__ ((bitwidth(1333))) int1333; typedef int __attribute__ ((bitwidth(1334))) int1334; typedef int __attribute__ ((bitwidth(1335))) int1335; typedef int __attribute__ ((bitwidth(1336))) int1336; typedef int __attribute__ ((bitwidth(1337))) int1337; typedef int __attribute__ ((bitwidth(1338))) int1338; typedef int __attribute__ ((bitwidth(1339))) int1339; typedef int __attribute__ ((bitwidth(1340))) int1340; typedef int __attribute__ ((bitwidth(1341))) int1341; typedef int __attribute__ ((bitwidth(1342))) int1342; typedef int __attribute__ ((bitwidth(1343))) int1343; typedef int __attribute__ ((bitwidth(1344))) int1344; typedef int __attribute__ ((bitwidth(1345))) int1345; typedef int __attribute__ ((bitwidth(1346))) int1346; typedef int __attribute__ ((bitwidth(1347))) int1347; typedef int __attribute__ ((bitwidth(1348))) int1348; typedef int __attribute__ ((bitwidth(1349))) int1349; typedef int __attribute__ ((bitwidth(1350))) int1350; typedef int __attribute__ ((bitwidth(1351))) int1351; typedef int __attribute__ ((bitwidth(1352))) int1352; typedef int __attribute__ ((bitwidth(1353))) int1353; typedef int __attribute__ ((bitwidth(1354))) int1354; typedef int __attribute__ ((bitwidth(1355))) int1355; typedef int __attribute__ ((bitwidth(1356))) int1356; typedef int __attribute__ ((bitwidth(1357))) int1357; typedef int __attribute__ ((bitwidth(1358))) int1358; typedef int __attribute__ ((bitwidth(1359))) int1359; typedef int __attribute__ ((bitwidth(1360))) int1360; typedef int __attribute__ ((bitwidth(1361))) int1361; typedef int __attribute__ ((bitwidth(1362))) int1362; typedef int __attribute__ ((bitwidth(1363))) int1363; typedef int __attribute__ ((bitwidth(1364))) int1364; typedef int __attribute__ ((bitwidth(1365))) int1365; typedef int __attribute__ ((bitwidth(1366))) int1366; typedef int __attribute__ ((bitwidth(1367))) int1367; typedef int __attribute__ ((bitwidth(1368))) int1368; typedef int __attribute__ ((bitwidth(1369))) int1369; typedef int __attribute__ ((bitwidth(1370))) int1370; typedef int __attribute__ ((bitwidth(1371))) int1371; typedef int __attribute__ ((bitwidth(1372))) int1372; typedef int __attribute__ ((bitwidth(1373))) int1373; typedef int __attribute__ ((bitwidth(1374))) int1374; typedef int __attribute__ ((bitwidth(1375))) int1375; typedef int __attribute__ ((bitwidth(1376))) int1376; typedef int __attribute__ ((bitwidth(1377))) int1377; typedef int __attribute__ ((bitwidth(1378))) int1378; typedef int __attribute__ ((bitwidth(1379))) int1379; typedef int __attribute__ ((bitwidth(1380))) int1380; typedef int __attribute__ ((bitwidth(1381))) int1381; typedef int __attribute__ ((bitwidth(1382))) int1382; typedef int __attribute__ ((bitwidth(1383))) int1383; typedef int __attribute__ ((bitwidth(1384))) int1384; typedef int __attribute__ ((bitwidth(1385))) int1385; typedef int __attribute__ ((bitwidth(1386))) int1386; typedef int __attribute__ ((bitwidth(1387))) int1387; typedef int __attribute__ ((bitwidth(1388))) int1388; typedef int __attribute__ ((bitwidth(1389))) int1389; typedef int __attribute__ ((bitwidth(1390))) int1390; typedef int __attribute__ ((bitwidth(1391))) int1391; typedef int __attribute__ ((bitwidth(1392))) int1392; typedef int __attribute__ ((bitwidth(1393))) int1393; typedef int __attribute__ ((bitwidth(1394))) int1394; typedef int __attribute__ ((bitwidth(1395))) int1395; typedef int __attribute__ ((bitwidth(1396))) int1396; typedef int __attribute__ ((bitwidth(1397))) int1397; typedef int __attribute__ ((bitwidth(1398))) int1398; typedef int __attribute__ ((bitwidth(1399))) int1399; typedef int __attribute__ ((bitwidth(1400))) int1400; typedef int __attribute__ ((bitwidth(1401))) int1401; typedef int __attribute__ ((bitwidth(1402))) int1402; typedef int __attribute__ ((bitwidth(1403))) int1403; typedef int __attribute__ ((bitwidth(1404))) int1404; typedef int __attribute__ ((bitwidth(1405))) int1405; typedef int __attribute__ ((bitwidth(1406))) int1406; typedef int __attribute__ ((bitwidth(1407))) int1407; typedef int __attribute__ ((bitwidth(1408))) int1408; typedef int __attribute__ ((bitwidth(1409))) int1409; typedef int __attribute__ ((bitwidth(1410))) int1410; typedef int __attribute__ ((bitwidth(1411))) int1411; typedef int __attribute__ ((bitwidth(1412))) int1412; typedef int __attribute__ ((bitwidth(1413))) int1413; typedef int __attribute__ ((bitwidth(1414))) int1414; typedef int __attribute__ ((bitwidth(1415))) int1415; typedef int __attribute__ ((bitwidth(1416))) int1416; typedef int __attribute__ ((bitwidth(1417))) int1417; typedef int __attribute__ ((bitwidth(1418))) int1418; typedef int __attribute__ ((bitwidth(1419))) int1419; typedef int __attribute__ ((bitwidth(1420))) int1420; typedef int __attribute__ ((bitwidth(1421))) int1421; typedef int __attribute__ ((bitwidth(1422))) int1422; typedef int __attribute__ ((bitwidth(1423))) int1423; typedef int __attribute__ ((bitwidth(1424))) int1424; typedef int __attribute__ ((bitwidth(1425))) int1425; typedef int __attribute__ ((bitwidth(1426))) int1426; typedef int __attribute__ ((bitwidth(1427))) int1427; typedef int __attribute__ ((bitwidth(1428))) int1428; typedef int __attribute__ ((bitwidth(1429))) int1429; typedef int __attribute__ ((bitwidth(1430))) int1430; typedef int __attribute__ ((bitwidth(1431))) int1431; typedef int __attribute__ ((bitwidth(1432))) int1432; typedef int __attribute__ ((bitwidth(1433))) int1433; typedef int __attribute__ ((bitwidth(1434))) int1434; typedef int __attribute__ ((bitwidth(1435))) int1435; typedef int __attribute__ ((bitwidth(1436))) int1436; typedef int __attribute__ ((bitwidth(1437))) int1437; typedef int __attribute__ ((bitwidth(1438))) int1438; typedef int __attribute__ ((bitwidth(1439))) int1439; typedef int __attribute__ ((bitwidth(1440))) int1440; typedef int __attribute__ ((bitwidth(1441))) int1441; typedef int __attribute__ ((bitwidth(1442))) int1442; typedef int __attribute__ ((bitwidth(1443))) int1443; typedef int __attribute__ ((bitwidth(1444))) int1444; typedef int __attribute__ ((bitwidth(1445))) int1445; typedef int __attribute__ ((bitwidth(1446))) int1446; typedef int __attribute__ ((bitwidth(1447))) int1447; typedef int __attribute__ ((bitwidth(1448))) int1448; typedef int __attribute__ ((bitwidth(1449))) int1449; typedef int __attribute__ ((bitwidth(1450))) int1450; typedef int __attribute__ ((bitwidth(1451))) int1451; typedef int __attribute__ ((bitwidth(1452))) int1452; typedef int __attribute__ ((bitwidth(1453))) int1453; typedef int __attribute__ ((bitwidth(1454))) int1454; typedef int __attribute__ ((bitwidth(1455))) int1455; typedef int __attribute__ ((bitwidth(1456))) int1456; typedef int __attribute__ ((bitwidth(1457))) int1457; typedef int __attribute__ ((bitwidth(1458))) int1458; typedef int __attribute__ ((bitwidth(1459))) int1459; typedef int __attribute__ ((bitwidth(1460))) int1460; typedef int __attribute__ ((bitwidth(1461))) int1461; typedef int __attribute__ ((bitwidth(1462))) int1462; typedef int __attribute__ ((bitwidth(1463))) int1463; typedef int __attribute__ ((bitwidth(1464))) int1464; typedef int __attribute__ ((bitwidth(1465))) int1465; typedef int __attribute__ ((bitwidth(1466))) int1466; typedef int __attribute__ ((bitwidth(1467))) int1467; typedef int __attribute__ ((bitwidth(1468))) int1468; typedef int __attribute__ ((bitwidth(1469))) int1469; typedef int __attribute__ ((bitwidth(1470))) int1470; typedef int __attribute__ ((bitwidth(1471))) int1471; typedef int __attribute__ ((bitwidth(1472))) int1472; typedef int __attribute__ ((bitwidth(1473))) int1473; typedef int __attribute__ ((bitwidth(1474))) int1474; typedef int __attribute__ ((bitwidth(1475))) int1475; typedef int __attribute__ ((bitwidth(1476))) int1476; typedef int __attribute__ ((bitwidth(1477))) int1477; typedef int __attribute__ ((bitwidth(1478))) int1478; typedef int __attribute__ ((bitwidth(1479))) int1479; typedef int __attribute__ ((bitwidth(1480))) int1480; typedef int __attribute__ ((bitwidth(1481))) int1481; typedef int __attribute__ ((bitwidth(1482))) int1482; typedef int __attribute__ ((bitwidth(1483))) int1483; typedef int __attribute__ ((bitwidth(1484))) int1484; typedef int __attribute__ ((bitwidth(1485))) int1485; typedef int __attribute__ ((bitwidth(1486))) int1486; typedef int __attribute__ ((bitwidth(1487))) int1487; typedef int __attribute__ ((bitwidth(1488))) int1488; typedef int __attribute__ ((bitwidth(1489))) int1489; typedef int __attribute__ ((bitwidth(1490))) int1490; typedef int __attribute__ ((bitwidth(1491))) int1491; typedef int __attribute__ ((bitwidth(1492))) int1492; typedef int __attribute__ ((bitwidth(1493))) int1493; typedef int __attribute__ ((bitwidth(1494))) int1494; typedef int __attribute__ ((bitwidth(1495))) int1495; typedef int __attribute__ ((bitwidth(1496))) int1496; typedef int __attribute__ ((bitwidth(1497))) int1497; typedef int __attribute__ ((bitwidth(1498))) int1498; typedef int __attribute__ ((bitwidth(1499))) int1499; typedef int __attribute__ ((bitwidth(1500))) int1500; typedef int __attribute__ ((bitwidth(1501))) int1501; typedef int __attribute__ ((bitwidth(1502))) int1502; typedef int __attribute__ ((bitwidth(1503))) int1503; typedef int __attribute__ ((bitwidth(1504))) int1504; typedef int __attribute__ ((bitwidth(1505))) int1505; typedef int __attribute__ ((bitwidth(1506))) int1506; typedef int __attribute__ ((bitwidth(1507))) int1507; typedef int __attribute__ ((bitwidth(1508))) int1508; typedef int __attribute__ ((bitwidth(1509))) int1509; typedef int __attribute__ ((bitwidth(1510))) int1510; typedef int __attribute__ ((bitwidth(1511))) int1511; typedef int __attribute__ ((bitwidth(1512))) int1512; typedef int __attribute__ ((bitwidth(1513))) int1513; typedef int __attribute__ ((bitwidth(1514))) int1514; typedef int __attribute__ ((bitwidth(1515))) int1515; typedef int __attribute__ ((bitwidth(1516))) int1516; typedef int __attribute__ ((bitwidth(1517))) int1517; typedef int __attribute__ ((bitwidth(1518))) int1518; typedef int __attribute__ ((bitwidth(1519))) int1519; typedef int __attribute__ ((bitwidth(1520))) int1520; typedef int __attribute__ ((bitwidth(1521))) int1521; typedef int __attribute__ ((bitwidth(1522))) int1522; typedef int __attribute__ ((bitwidth(1523))) int1523; typedef int __attribute__ ((bitwidth(1524))) int1524; typedef int __attribute__ ((bitwidth(1525))) int1525; typedef int __attribute__ ((bitwidth(1526))) int1526; typedef int __attribute__ ((bitwidth(1527))) int1527; typedef int __attribute__ ((bitwidth(1528))) int1528; typedef int __attribute__ ((bitwidth(1529))) int1529; typedef int __attribute__ ((bitwidth(1530))) int1530; typedef int __attribute__ ((bitwidth(1531))) int1531; typedef int __attribute__ ((bitwidth(1532))) int1532; typedef int __attribute__ ((bitwidth(1533))) int1533; typedef int __attribute__ ((bitwidth(1534))) int1534; typedef int __attribute__ ((bitwidth(1535))) int1535; typedef int __attribute__ ((bitwidth(1536))) int1536; typedef int __attribute__ ((bitwidth(1537))) int1537; typedef int __attribute__ ((bitwidth(1538))) int1538; typedef int __attribute__ ((bitwidth(1539))) int1539; typedef int __attribute__ ((bitwidth(1540))) int1540; typedef int __attribute__ ((bitwidth(1541))) int1541; typedef int __attribute__ ((bitwidth(1542))) int1542; typedef int __attribute__ ((bitwidth(1543))) int1543; typedef int __attribute__ ((bitwidth(1544))) int1544; typedef int __attribute__ ((bitwidth(1545))) int1545; typedef int __attribute__ ((bitwidth(1546))) int1546; typedef int __attribute__ ((bitwidth(1547))) int1547; typedef int __attribute__ ((bitwidth(1548))) int1548; typedef int __attribute__ ((bitwidth(1549))) int1549; typedef int __attribute__ ((bitwidth(1550))) int1550; typedef int __attribute__ ((bitwidth(1551))) int1551; typedef int __attribute__ ((bitwidth(1552))) int1552; typedef int __attribute__ ((bitwidth(1553))) int1553; typedef int __attribute__ ((bitwidth(1554))) int1554; typedef int __attribute__ ((bitwidth(1555))) int1555; typedef int __attribute__ ((bitwidth(1556))) int1556; typedef int __attribute__ ((bitwidth(1557))) int1557; typedef int __attribute__ ((bitwidth(1558))) int1558; typedef int __attribute__ ((bitwidth(1559))) int1559; typedef int __attribute__ ((bitwidth(1560))) int1560; typedef int __attribute__ ((bitwidth(1561))) int1561; typedef int __attribute__ ((bitwidth(1562))) int1562; typedef int __attribute__ ((bitwidth(1563))) int1563; typedef int __attribute__ ((bitwidth(1564))) int1564; typedef int __attribute__ ((bitwidth(1565))) int1565; typedef int __attribute__ ((bitwidth(1566))) int1566; typedef int __attribute__ ((bitwidth(1567))) int1567; typedef int __attribute__ ((bitwidth(1568))) int1568; typedef int __attribute__ ((bitwidth(1569))) int1569; typedef int __attribute__ ((bitwidth(1570))) int1570; typedef int __attribute__ ((bitwidth(1571))) int1571; typedef int __attribute__ ((bitwidth(1572))) int1572; typedef int __attribute__ ((bitwidth(1573))) int1573; typedef int __attribute__ ((bitwidth(1574))) int1574; typedef int __attribute__ ((bitwidth(1575))) int1575; typedef int __attribute__ ((bitwidth(1576))) int1576; typedef int __attribute__ ((bitwidth(1577))) int1577; typedef int __attribute__ ((bitwidth(1578))) int1578; typedef int __attribute__ ((bitwidth(1579))) int1579; typedef int __attribute__ ((bitwidth(1580))) int1580; typedef int __attribute__ ((bitwidth(1581))) int1581; typedef int __attribute__ ((bitwidth(1582))) int1582; typedef int __attribute__ ((bitwidth(1583))) int1583; typedef int __attribute__ ((bitwidth(1584))) int1584; typedef int __attribute__ ((bitwidth(1585))) int1585; typedef int __attribute__ ((bitwidth(1586))) int1586; typedef int __attribute__ ((bitwidth(1587))) int1587; typedef int __attribute__ ((bitwidth(1588))) int1588; typedef int __attribute__ ((bitwidth(1589))) int1589; typedef int __attribute__ ((bitwidth(1590))) int1590; typedef int __attribute__ ((bitwidth(1591))) int1591; typedef int __attribute__ ((bitwidth(1592))) int1592; typedef int __attribute__ ((bitwidth(1593))) int1593; typedef int __attribute__ ((bitwidth(1594))) int1594; typedef int __attribute__ ((bitwidth(1595))) int1595; typedef int __attribute__ ((bitwidth(1596))) int1596; typedef int __attribute__ ((bitwidth(1597))) int1597; typedef int __attribute__ ((bitwidth(1598))) int1598; typedef int __attribute__ ((bitwidth(1599))) int1599; typedef int __attribute__ ((bitwidth(1600))) int1600; typedef int __attribute__ ((bitwidth(1601))) int1601; typedef int __attribute__ ((bitwidth(1602))) int1602; typedef int __attribute__ ((bitwidth(1603))) int1603; typedef int __attribute__ ((bitwidth(1604))) int1604; typedef int __attribute__ ((bitwidth(1605))) int1605; typedef int __attribute__ ((bitwidth(1606))) int1606; typedef int __attribute__ ((bitwidth(1607))) int1607; typedef int __attribute__ ((bitwidth(1608))) int1608; typedef int __attribute__ ((bitwidth(1609))) int1609; typedef int __attribute__ ((bitwidth(1610))) int1610; typedef int __attribute__ ((bitwidth(1611))) int1611; typedef int __attribute__ ((bitwidth(1612))) int1612; typedef int __attribute__ ((bitwidth(1613))) int1613; typedef int __attribute__ ((bitwidth(1614))) int1614; typedef int __attribute__ ((bitwidth(1615))) int1615; typedef int __attribute__ ((bitwidth(1616))) int1616; typedef int __attribute__ ((bitwidth(1617))) int1617; typedef int __attribute__ ((bitwidth(1618))) int1618; typedef int __attribute__ ((bitwidth(1619))) int1619; typedef int __attribute__ ((bitwidth(1620))) int1620; typedef int __attribute__ ((bitwidth(1621))) int1621; typedef int __attribute__ ((bitwidth(1622))) int1622; typedef int __attribute__ ((bitwidth(1623))) int1623; typedef int __attribute__ ((bitwidth(1624))) int1624; typedef int __attribute__ ((bitwidth(1625))) int1625; typedef int __attribute__ ((bitwidth(1626))) int1626; typedef int __attribute__ ((bitwidth(1627))) int1627; typedef int __attribute__ ((bitwidth(1628))) int1628; typedef int __attribute__ ((bitwidth(1629))) int1629; typedef int __attribute__ ((bitwidth(1630))) int1630; typedef int __attribute__ ((bitwidth(1631))) int1631; typedef int __attribute__ ((bitwidth(1632))) int1632; typedef int __attribute__ ((bitwidth(1633))) int1633; typedef int __attribute__ ((bitwidth(1634))) int1634; typedef int __attribute__ ((bitwidth(1635))) int1635; typedef int __attribute__ ((bitwidth(1636))) int1636; typedef int __attribute__ ((bitwidth(1637))) int1637; typedef int __attribute__ ((bitwidth(1638))) int1638; typedef int __attribute__ ((bitwidth(1639))) int1639; typedef int __attribute__ ((bitwidth(1640))) int1640; typedef int __attribute__ ((bitwidth(1641))) int1641; typedef int __attribute__ ((bitwidth(1642))) int1642; typedef int __attribute__ ((bitwidth(1643))) int1643; typedef int __attribute__ ((bitwidth(1644))) int1644; typedef int __attribute__ ((bitwidth(1645))) int1645; typedef int __attribute__ ((bitwidth(1646))) int1646; typedef int __attribute__ ((bitwidth(1647))) int1647; typedef int __attribute__ ((bitwidth(1648))) int1648; typedef int __attribute__ ((bitwidth(1649))) int1649; typedef int __attribute__ ((bitwidth(1650))) int1650; typedef int __attribute__ ((bitwidth(1651))) int1651; typedef int __attribute__ ((bitwidth(1652))) int1652; typedef int __attribute__ ((bitwidth(1653))) int1653; typedef int __attribute__ ((bitwidth(1654))) int1654; typedef int __attribute__ ((bitwidth(1655))) int1655; typedef int __attribute__ ((bitwidth(1656))) int1656; typedef int __attribute__ ((bitwidth(1657))) int1657; typedef int __attribute__ ((bitwidth(1658))) int1658; typedef int __attribute__ ((bitwidth(1659))) int1659; typedef int __attribute__ ((bitwidth(1660))) int1660; typedef int __attribute__ ((bitwidth(1661))) int1661; typedef int __attribute__ ((bitwidth(1662))) int1662; typedef int __attribute__ ((bitwidth(1663))) int1663; typedef int __attribute__ ((bitwidth(1664))) int1664; typedef int __attribute__ ((bitwidth(1665))) int1665; typedef int __attribute__ ((bitwidth(1666))) int1666; typedef int __attribute__ ((bitwidth(1667))) int1667; typedef int __attribute__ ((bitwidth(1668))) int1668; typedef int __attribute__ ((bitwidth(1669))) int1669; typedef int __attribute__ ((bitwidth(1670))) int1670; typedef int __attribute__ ((bitwidth(1671))) int1671; typedef int __attribute__ ((bitwidth(1672))) int1672; typedef int __attribute__ ((bitwidth(1673))) int1673; typedef int __attribute__ ((bitwidth(1674))) int1674; typedef int __attribute__ ((bitwidth(1675))) int1675; typedef int __attribute__ ((bitwidth(1676))) int1676; typedef int __attribute__ ((bitwidth(1677))) int1677; typedef int __attribute__ ((bitwidth(1678))) int1678; typedef int __attribute__ ((bitwidth(1679))) int1679; typedef int __attribute__ ((bitwidth(1680))) int1680; typedef int __attribute__ ((bitwidth(1681))) int1681; typedef int __attribute__ ((bitwidth(1682))) int1682; typedef int __attribute__ ((bitwidth(1683))) int1683; typedef int __attribute__ ((bitwidth(1684))) int1684; typedef int __attribute__ ((bitwidth(1685))) int1685; typedef int __attribute__ ((bitwidth(1686))) int1686; typedef int __attribute__ ((bitwidth(1687))) int1687; typedef int __attribute__ ((bitwidth(1688))) int1688; typedef int __attribute__ ((bitwidth(1689))) int1689; typedef int __attribute__ ((bitwidth(1690))) int1690; typedef int __attribute__ ((bitwidth(1691))) int1691; typedef int __attribute__ ((bitwidth(1692))) int1692; typedef int __attribute__ ((bitwidth(1693))) int1693; typedef int __attribute__ ((bitwidth(1694))) int1694; typedef int __attribute__ ((bitwidth(1695))) int1695; typedef int __attribute__ ((bitwidth(1696))) int1696; typedef int __attribute__ ((bitwidth(1697))) int1697; typedef int __attribute__ ((bitwidth(1698))) int1698; typedef int __attribute__ ((bitwidth(1699))) int1699; typedef int __attribute__ ((bitwidth(1700))) int1700; typedef int __attribute__ ((bitwidth(1701))) int1701; typedef int __attribute__ ((bitwidth(1702))) int1702; typedef int __attribute__ ((bitwidth(1703))) int1703; typedef int __attribute__ ((bitwidth(1704))) int1704; typedef int __attribute__ ((bitwidth(1705))) int1705; typedef int __attribute__ ((bitwidth(1706))) int1706; typedef int __attribute__ ((bitwidth(1707))) int1707; typedef int __attribute__ ((bitwidth(1708))) int1708; typedef int __attribute__ ((bitwidth(1709))) int1709; typedef int __attribute__ ((bitwidth(1710))) int1710; typedef int __attribute__ ((bitwidth(1711))) int1711; typedef int __attribute__ ((bitwidth(1712))) int1712; typedef int __attribute__ ((bitwidth(1713))) int1713; typedef int __attribute__ ((bitwidth(1714))) int1714; typedef int __attribute__ ((bitwidth(1715))) int1715; typedef int __attribute__ ((bitwidth(1716))) int1716; typedef int __attribute__ ((bitwidth(1717))) int1717; typedef int __attribute__ ((bitwidth(1718))) int1718; typedef int __attribute__ ((bitwidth(1719))) int1719; typedef int __attribute__ ((bitwidth(1720))) int1720; typedef int __attribute__ ((bitwidth(1721))) int1721; typedef int __attribute__ ((bitwidth(1722))) int1722; typedef int __attribute__ ((bitwidth(1723))) int1723; typedef int __attribute__ ((bitwidth(1724))) int1724; typedef int __attribute__ ((bitwidth(1725))) int1725; typedef int __attribute__ ((bitwidth(1726))) int1726; typedef int __attribute__ ((bitwidth(1727))) int1727; typedef int __attribute__ ((bitwidth(1728))) int1728; typedef int __attribute__ ((bitwidth(1729))) int1729; typedef int __attribute__ ((bitwidth(1730))) int1730; typedef int __attribute__ ((bitwidth(1731))) int1731; typedef int __attribute__ ((bitwidth(1732))) int1732; typedef int __attribute__ ((bitwidth(1733))) int1733; typedef int __attribute__ ((bitwidth(1734))) int1734; typedef int __attribute__ ((bitwidth(1735))) int1735; typedef int __attribute__ ((bitwidth(1736))) int1736; typedef int __attribute__ ((bitwidth(1737))) int1737; typedef int __attribute__ ((bitwidth(1738))) int1738; typedef int __attribute__ ((bitwidth(1739))) int1739; typedef int __attribute__ ((bitwidth(1740))) int1740; typedef int __attribute__ ((bitwidth(1741))) int1741; typedef int __attribute__ ((bitwidth(1742))) int1742; typedef int __attribute__ ((bitwidth(1743))) int1743; typedef int __attribute__ ((bitwidth(1744))) int1744; typedef int __attribute__ ((bitwidth(1745))) int1745; typedef int __attribute__ ((bitwidth(1746))) int1746; typedef int __attribute__ ((bitwidth(1747))) int1747; typedef int __attribute__ ((bitwidth(1748))) int1748; typedef int __attribute__ ((bitwidth(1749))) int1749; typedef int __attribute__ ((bitwidth(1750))) int1750; typedef int __attribute__ ((bitwidth(1751))) int1751; typedef int __attribute__ ((bitwidth(1752))) int1752; typedef int __attribute__ ((bitwidth(1753))) int1753; typedef int __attribute__ ((bitwidth(1754))) int1754; typedef int __attribute__ ((bitwidth(1755))) int1755; typedef int __attribute__ ((bitwidth(1756))) int1756; typedef int __attribute__ ((bitwidth(1757))) int1757; typedef int __attribute__ ((bitwidth(1758))) int1758; typedef int __attribute__ ((bitwidth(1759))) int1759; typedef int __attribute__ ((bitwidth(1760))) int1760; typedef int __attribute__ ((bitwidth(1761))) int1761; typedef int __attribute__ ((bitwidth(1762))) int1762; typedef int __attribute__ ((bitwidth(1763))) int1763; typedef int __attribute__ ((bitwidth(1764))) int1764; typedef int __attribute__ ((bitwidth(1765))) int1765; typedef int __attribute__ ((bitwidth(1766))) int1766; typedef int __attribute__ ((bitwidth(1767))) int1767; typedef int __attribute__ ((bitwidth(1768))) int1768; typedef int __attribute__ ((bitwidth(1769))) int1769; typedef int __attribute__ ((bitwidth(1770))) int1770; typedef int __attribute__ ((bitwidth(1771))) int1771; typedef int __attribute__ ((bitwidth(1772))) int1772; typedef int __attribute__ ((bitwidth(1773))) int1773; typedef int __attribute__ ((bitwidth(1774))) int1774; typedef int __attribute__ ((bitwidth(1775))) int1775; typedef int __attribute__ ((bitwidth(1776))) int1776; typedef int __attribute__ ((bitwidth(1777))) int1777; typedef int __attribute__ ((bitwidth(1778))) int1778; typedef int __attribute__ ((bitwidth(1779))) int1779; typedef int __attribute__ ((bitwidth(1780))) int1780; typedef int __attribute__ ((bitwidth(1781))) int1781; typedef int __attribute__ ((bitwidth(1782))) int1782; typedef int __attribute__ ((bitwidth(1783))) int1783; typedef int __attribute__ ((bitwidth(1784))) int1784; typedef int __attribute__ ((bitwidth(1785))) int1785; typedef int __attribute__ ((bitwidth(1786))) int1786; typedef int __attribute__ ((bitwidth(1787))) int1787; typedef int __attribute__ ((bitwidth(1788))) int1788; typedef int __attribute__ ((bitwidth(1789))) int1789; typedef int __attribute__ ((bitwidth(1790))) int1790; typedef int __attribute__ ((bitwidth(1791))) int1791; typedef int __attribute__ ((bitwidth(1792))) int1792; typedef int __attribute__ ((bitwidth(1793))) int1793; typedef int __attribute__ ((bitwidth(1794))) int1794; typedef int __attribute__ ((bitwidth(1795))) int1795; typedef int __attribute__ ((bitwidth(1796))) int1796; typedef int __attribute__ ((bitwidth(1797))) int1797; typedef int __attribute__ ((bitwidth(1798))) int1798; typedef int __attribute__ ((bitwidth(1799))) int1799; typedef int __attribute__ ((bitwidth(1800))) int1800; typedef int __attribute__ ((bitwidth(1801))) int1801; typedef int __attribute__ ((bitwidth(1802))) int1802; typedef int __attribute__ ((bitwidth(1803))) int1803; typedef int __attribute__ ((bitwidth(1804))) int1804; typedef int __attribute__ ((bitwidth(1805))) int1805; typedef int __attribute__ ((bitwidth(1806))) int1806; typedef int __attribute__ ((bitwidth(1807))) int1807; typedef int __attribute__ ((bitwidth(1808))) int1808; typedef int __attribute__ ((bitwidth(1809))) int1809; typedef int __attribute__ ((bitwidth(1810))) int1810; typedef int __attribute__ ((bitwidth(1811))) int1811; typedef int __attribute__ ((bitwidth(1812))) int1812; typedef int __attribute__ ((bitwidth(1813))) int1813; typedef int __attribute__ ((bitwidth(1814))) int1814; typedef int __attribute__ ((bitwidth(1815))) int1815; typedef int __attribute__ ((bitwidth(1816))) int1816; typedef int __attribute__ ((bitwidth(1817))) int1817; typedef int __attribute__ ((bitwidth(1818))) int1818; typedef int __attribute__ ((bitwidth(1819))) int1819; typedef int __attribute__ ((bitwidth(1820))) int1820; typedef int __attribute__ ((bitwidth(1821))) int1821; typedef int __attribute__ ((bitwidth(1822))) int1822; typedef int __attribute__ ((bitwidth(1823))) int1823; typedef int __attribute__ ((bitwidth(1824))) int1824; typedef int __attribute__ ((bitwidth(1825))) int1825; typedef int __attribute__ ((bitwidth(1826))) int1826; typedef int __attribute__ ((bitwidth(1827))) int1827; typedef int __attribute__ ((bitwidth(1828))) int1828; typedef int __attribute__ ((bitwidth(1829))) int1829; typedef int __attribute__ ((bitwidth(1830))) int1830; typedef int __attribute__ ((bitwidth(1831))) int1831; typedef int __attribute__ ((bitwidth(1832))) int1832; typedef int __attribute__ ((bitwidth(1833))) int1833; typedef int __attribute__ ((bitwidth(1834))) int1834; typedef int __attribute__ ((bitwidth(1835))) int1835; typedef int __attribute__ ((bitwidth(1836))) int1836; typedef int __attribute__ ((bitwidth(1837))) int1837; typedef int __attribute__ ((bitwidth(1838))) int1838; typedef int __attribute__ ((bitwidth(1839))) int1839; typedef int __attribute__ ((bitwidth(1840))) int1840; typedef int __attribute__ ((bitwidth(1841))) int1841; typedef int __attribute__ ((bitwidth(1842))) int1842; typedef int __attribute__ ((bitwidth(1843))) int1843; typedef int __attribute__ ((bitwidth(1844))) int1844; typedef int __attribute__ ((bitwidth(1845))) int1845; typedef int __attribute__ ((bitwidth(1846))) int1846; typedef int __attribute__ ((bitwidth(1847))) int1847; typedef int __attribute__ ((bitwidth(1848))) int1848; typedef int __attribute__ ((bitwidth(1849))) int1849; typedef int __attribute__ ((bitwidth(1850))) int1850; typedef int __attribute__ ((bitwidth(1851))) int1851; typedef int __attribute__ ((bitwidth(1852))) int1852; typedef int __attribute__ ((bitwidth(1853))) int1853; typedef int __attribute__ ((bitwidth(1854))) int1854; typedef int __attribute__ ((bitwidth(1855))) int1855; typedef int __attribute__ ((bitwidth(1856))) int1856; typedef int __attribute__ ((bitwidth(1857))) int1857; typedef int __attribute__ ((bitwidth(1858))) int1858; typedef int __attribute__ ((bitwidth(1859))) int1859; typedef int __attribute__ ((bitwidth(1860))) int1860; typedef int __attribute__ ((bitwidth(1861))) int1861; typedef int __attribute__ ((bitwidth(1862))) int1862; typedef int __attribute__ ((bitwidth(1863))) int1863; typedef int __attribute__ ((bitwidth(1864))) int1864; typedef int __attribute__ ((bitwidth(1865))) int1865; typedef int __attribute__ ((bitwidth(1866))) int1866; typedef int __attribute__ ((bitwidth(1867))) int1867; typedef int __attribute__ ((bitwidth(1868))) int1868; typedef int __attribute__ ((bitwidth(1869))) int1869; typedef int __attribute__ ((bitwidth(1870))) int1870; typedef int __attribute__ ((bitwidth(1871))) int1871; typedef int __attribute__ ((bitwidth(1872))) int1872; typedef int __attribute__ ((bitwidth(1873))) int1873; typedef int __attribute__ ((bitwidth(1874))) int1874; typedef int __attribute__ ((bitwidth(1875))) int1875; typedef int __attribute__ ((bitwidth(1876))) int1876; typedef int __attribute__ ((bitwidth(1877))) int1877; typedef int __attribute__ ((bitwidth(1878))) int1878; typedef int __attribute__ ((bitwidth(1879))) int1879; typedef int __attribute__ ((bitwidth(1880))) int1880; typedef int __attribute__ ((bitwidth(1881))) int1881; typedef int __attribute__ ((bitwidth(1882))) int1882; typedef int __attribute__ ((bitwidth(1883))) int1883; typedef int __attribute__ ((bitwidth(1884))) int1884; typedef int __attribute__ ((bitwidth(1885))) int1885; typedef int __attribute__ ((bitwidth(1886))) int1886; typedef int __attribute__ ((bitwidth(1887))) int1887; typedef int __attribute__ ((bitwidth(1888))) int1888; typedef int __attribute__ ((bitwidth(1889))) int1889; typedef int __attribute__ ((bitwidth(1890))) int1890; typedef int __attribute__ ((bitwidth(1891))) int1891; typedef int __attribute__ ((bitwidth(1892))) int1892; typedef int __attribute__ ((bitwidth(1893))) int1893; typedef int __attribute__ ((bitwidth(1894))) int1894; typedef int __attribute__ ((bitwidth(1895))) int1895; typedef int __attribute__ ((bitwidth(1896))) int1896; typedef int __attribute__ ((bitwidth(1897))) int1897; typedef int __attribute__ ((bitwidth(1898))) int1898; typedef int __attribute__ ((bitwidth(1899))) int1899; typedef int __attribute__ ((bitwidth(1900))) int1900; typedef int __attribute__ ((bitwidth(1901))) int1901; typedef int __attribute__ ((bitwidth(1902))) int1902; typedef int __attribute__ ((bitwidth(1903))) int1903; typedef int __attribute__ ((bitwidth(1904))) int1904; typedef int __attribute__ ((bitwidth(1905))) int1905; typedef int __attribute__ ((bitwidth(1906))) int1906; typedef int __attribute__ ((bitwidth(1907))) int1907; typedef int __attribute__ ((bitwidth(1908))) int1908; typedef int __attribute__ ((bitwidth(1909))) int1909; typedef int __attribute__ ((bitwidth(1910))) int1910; typedef int __attribute__ ((bitwidth(1911))) int1911; typedef int __attribute__ ((bitwidth(1912))) int1912; typedef int __attribute__ ((bitwidth(1913))) int1913; typedef int __attribute__ ((bitwidth(1914))) int1914; typedef int __attribute__ ((bitwidth(1915))) int1915; typedef int __attribute__ ((bitwidth(1916))) int1916; typedef int __attribute__ ((bitwidth(1917))) int1917; typedef int __attribute__ ((bitwidth(1918))) int1918; typedef int __attribute__ ((bitwidth(1919))) int1919; typedef int __attribute__ ((bitwidth(1920))) int1920; typedef int __attribute__ ((bitwidth(1921))) int1921; typedef int __attribute__ ((bitwidth(1922))) int1922; typedef int __attribute__ ((bitwidth(1923))) int1923; typedef int __attribute__ ((bitwidth(1924))) int1924; typedef int __attribute__ ((bitwidth(1925))) int1925; typedef int __attribute__ ((bitwidth(1926))) int1926; typedef int __attribute__ ((bitwidth(1927))) int1927; typedef int __attribute__ ((bitwidth(1928))) int1928; typedef int __attribute__ ((bitwidth(1929))) int1929; typedef int __attribute__ ((bitwidth(1930))) int1930; typedef int __attribute__ ((bitwidth(1931))) int1931; typedef int __attribute__ ((bitwidth(1932))) int1932; typedef int __attribute__ ((bitwidth(1933))) int1933; typedef int __attribute__ ((bitwidth(1934))) int1934; typedef int __attribute__ ((bitwidth(1935))) int1935; typedef int __attribute__ ((bitwidth(1936))) int1936; typedef int __attribute__ ((bitwidth(1937))) int1937; typedef int __attribute__ ((bitwidth(1938))) int1938; typedef int __attribute__ ((bitwidth(1939))) int1939; typedef int __attribute__ ((bitwidth(1940))) int1940; typedef int __attribute__ ((bitwidth(1941))) int1941; typedef int __attribute__ ((bitwidth(1942))) int1942; typedef int __attribute__ ((bitwidth(1943))) int1943; typedef int __attribute__ ((bitwidth(1944))) int1944; typedef int __attribute__ ((bitwidth(1945))) int1945; typedef int __attribute__ ((bitwidth(1946))) int1946; typedef int __attribute__ ((bitwidth(1947))) int1947; typedef int __attribute__ ((bitwidth(1948))) int1948; typedef int __attribute__ ((bitwidth(1949))) int1949; typedef int __attribute__ ((bitwidth(1950))) int1950; typedef int __attribute__ ((bitwidth(1951))) int1951; typedef int __attribute__ ((bitwidth(1952))) int1952; typedef int __attribute__ ((bitwidth(1953))) int1953; typedef int __attribute__ ((bitwidth(1954))) int1954; typedef int __attribute__ ((bitwidth(1955))) int1955; typedef int __attribute__ ((bitwidth(1956))) int1956; typedef int __attribute__ ((bitwidth(1957))) int1957; typedef int __attribute__ ((bitwidth(1958))) int1958; typedef int __attribute__ ((bitwidth(1959))) int1959; typedef int __attribute__ ((bitwidth(1960))) int1960; typedef int __attribute__ ((bitwidth(1961))) int1961; typedef int __attribute__ ((bitwidth(1962))) int1962; typedef int __attribute__ ((bitwidth(1963))) int1963; typedef int __attribute__ ((bitwidth(1964))) int1964; typedef int __attribute__ ((bitwidth(1965))) int1965; typedef int __attribute__ ((bitwidth(1966))) int1966; typedef int __attribute__ ((bitwidth(1967))) int1967; typedef int __attribute__ ((bitwidth(1968))) int1968; typedef int __attribute__ ((bitwidth(1969))) int1969; typedef int __attribute__ ((bitwidth(1970))) int1970; typedef int __attribute__ ((bitwidth(1971))) int1971; typedef int __attribute__ ((bitwidth(1972))) int1972; typedef int __attribute__ ((bitwidth(1973))) int1973; typedef int __attribute__ ((bitwidth(1974))) int1974; typedef int __attribute__ ((bitwidth(1975))) int1975; typedef int __attribute__ ((bitwidth(1976))) int1976; typedef int __attribute__ ((bitwidth(1977))) int1977; typedef int __attribute__ ((bitwidth(1978))) int1978; typedef int __attribute__ ((bitwidth(1979))) int1979; typedef int __attribute__ ((bitwidth(1980))) int1980; typedef int __attribute__ ((bitwidth(1981))) int1981; typedef int __attribute__ ((bitwidth(1982))) int1982; typedef int __attribute__ ((bitwidth(1983))) int1983; typedef int __attribute__ ((bitwidth(1984))) int1984; typedef int __attribute__ ((bitwidth(1985))) int1985; typedef int __attribute__ ((bitwidth(1986))) int1986; typedef int __attribute__ ((bitwidth(1987))) int1987; typedef int __attribute__ ((bitwidth(1988))) int1988; typedef int __attribute__ ((bitwidth(1989))) int1989; typedef int __attribute__ ((bitwidth(1990))) int1990; typedef int __attribute__ ((bitwidth(1991))) int1991; typedef int __attribute__ ((bitwidth(1992))) int1992; typedef int __attribute__ ((bitwidth(1993))) int1993; typedef int __attribute__ ((bitwidth(1994))) int1994; typedef int __attribute__ ((bitwidth(1995))) int1995; typedef int __attribute__ ((bitwidth(1996))) int1996; typedef int __attribute__ ((bitwidth(1997))) int1997; typedef int __attribute__ ((bitwidth(1998))) int1998; typedef int __attribute__ ((bitwidth(1999))) int1999; typedef int __attribute__ ((bitwidth(2000))) int2000; typedef int __attribute__ ((bitwidth(2001))) int2001; typedef int __attribute__ ((bitwidth(2002))) int2002; typedef int __attribute__ ((bitwidth(2003))) int2003; typedef int __attribute__ ((bitwidth(2004))) int2004; typedef int __attribute__ ((bitwidth(2005))) int2005; typedef int __attribute__ ((bitwidth(2006))) int2006; typedef int __attribute__ ((bitwidth(2007))) int2007; typedef int __attribute__ ((bitwidth(2008))) int2008; typedef int __attribute__ ((bitwidth(2009))) int2009; typedef int __attribute__ ((bitwidth(2010))) int2010; typedef int __attribute__ ((bitwidth(2011))) int2011; typedef int __attribute__ ((bitwidth(2012))) int2012; typedef int __attribute__ ((bitwidth(2013))) int2013; typedef int __attribute__ ((bitwidth(2014))) int2014; typedef int __attribute__ ((bitwidth(2015))) int2015; typedef int __attribute__ ((bitwidth(2016))) int2016; typedef int __attribute__ ((bitwidth(2017))) int2017; typedef int __attribute__ ((bitwidth(2018))) int2018; typedef int __attribute__ ((bitwidth(2019))) int2019; typedef int __attribute__ ((bitwidth(2020))) int2020; typedef int __attribute__ ((bitwidth(2021))) int2021; typedef int __attribute__ ((bitwidth(2022))) int2022; typedef int __attribute__ ((bitwidth(2023))) int2023; typedef int __attribute__ ((bitwidth(2024))) int2024; typedef int __attribute__ ((bitwidth(2025))) int2025; typedef int __attribute__ ((bitwidth(2026))) int2026; typedef int __attribute__ ((bitwidth(2027))) int2027; typedef int __attribute__ ((bitwidth(2028))) int2028; typedef int __attribute__ ((bitwidth(2029))) int2029; typedef int __attribute__ ((bitwidth(2030))) int2030; typedef int __attribute__ ((bitwidth(2031))) int2031; typedef int __attribute__ ((bitwidth(2032))) int2032; typedef int __attribute__ ((bitwidth(2033))) int2033; typedef int __attribute__ ((bitwidth(2034))) int2034; typedef int __attribute__ ((bitwidth(2035))) int2035; typedef int __attribute__ ((bitwidth(2036))) int2036; typedef int __attribute__ ((bitwidth(2037))) int2037; typedef int __attribute__ ((bitwidth(2038))) int2038; typedef int __attribute__ ((bitwidth(2039))) int2039; typedef int __attribute__ ((bitwidth(2040))) int2040; typedef int __attribute__ ((bitwidth(2041))) int2041; typedef int __attribute__ ((bitwidth(2042))) int2042; typedef int __attribute__ ((bitwidth(2043))) int2043; typedef int __attribute__ ((bitwidth(2044))) int2044; typedef int __attribute__ ((bitwidth(2045))) int2045; typedef int __attribute__ ((bitwidth(2046))) int2046; typedef int __attribute__ ((bitwidth(2047))) int2047; typedef int __attribute__ ((bitwidth(2048))) int2048; # 99 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/common/technology/autopilot\\etc/autopilot_dt.h" 2 # 108 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/common/technology/autopilot\\etc/autopilot_dt.h" # 1 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/common/technology/autopilot\\etc/autopilot_dt.def" 1 typedef unsigned int __attribute__ ((bitwidth(1))) uint1; typedef unsigned int __attribute__ ((bitwidth(2))) uint2; typedef unsigned int __attribute__ ((bitwidth(3))) uint3; typedef unsigned int __attribute__ ((bitwidth(4))) uint4; typedef unsigned int __attribute__ ((bitwidth(5))) uint5; typedef unsigned int __attribute__ ((bitwidth(6))) uint6; typedef unsigned int __attribute__ ((bitwidth(7))) uint7; typedef unsigned int __attribute__ ((bitwidth(8))) uint8; typedef unsigned int __attribute__ ((bitwidth(9))) uint9; typedef unsigned int __attribute__ ((bitwidth(10))) uint10; typedef unsigned int __attribute__ ((bitwidth(11))) uint11; typedef unsigned int __attribute__ ((bitwidth(12))) uint12; typedef unsigned int __attribute__ ((bitwidth(13))) uint13; typedef unsigned int __attribute__ ((bitwidth(14))) uint14; typedef unsigned int __attribute__ ((bitwidth(15))) uint15; typedef unsigned int __attribute__ ((bitwidth(16))) uint16; typedef unsigned int __attribute__ ((bitwidth(17))) uint17; typedef unsigned int __attribute__ ((bitwidth(18))) uint18; typedef unsigned int __attribute__ ((bitwidth(19))) uint19; typedef unsigned int __attribute__ ((bitwidth(20))) uint20; typedef unsigned int __attribute__ ((bitwidth(21))) uint21; typedef unsigned int __attribute__ ((bitwidth(22))) uint22; typedef unsigned int __attribute__ ((bitwidth(23))) uint23; typedef unsigned int __attribute__ ((bitwidth(24))) uint24; typedef unsigned int __attribute__ ((bitwidth(25))) uint25; typedef unsigned int __attribute__ ((bitwidth(26))) uint26; typedef unsigned int __attribute__ ((bitwidth(27))) uint27; typedef unsigned int __attribute__ ((bitwidth(28))) uint28; typedef unsigned int __attribute__ ((bitwidth(29))) uint29; typedef unsigned int __attribute__ ((bitwidth(30))) uint30; typedef unsigned int __attribute__ ((bitwidth(31))) uint31; typedef unsigned int __attribute__ ((bitwidth(32))) uint32; typedef unsigned int __attribute__ ((bitwidth(33))) uint33; typedef unsigned int __attribute__ ((bitwidth(34))) uint34; typedef unsigned int __attribute__ ((bitwidth(35))) uint35; typedef unsigned int __attribute__ ((bitwidth(36))) uint36; typedef unsigned int __attribute__ ((bitwidth(37))) uint37; typedef unsigned int __attribute__ ((bitwidth(38))) uint38; typedef unsigned int __attribute__ ((bitwidth(39))) uint39; typedef unsigned int __attribute__ ((bitwidth(40))) uint40; typedef unsigned int __attribute__ ((bitwidth(41))) uint41; typedef unsigned int __attribute__ ((bitwidth(42))) uint42; typedef unsigned int __attribute__ ((bitwidth(43))) uint43; typedef unsigned int __attribute__ ((bitwidth(44))) uint44; typedef unsigned int __attribute__ ((bitwidth(45))) uint45; typedef unsigned int __attribute__ ((bitwidth(46))) uint46; typedef unsigned int __attribute__ ((bitwidth(47))) uint47; typedef unsigned int __attribute__ ((bitwidth(48))) uint48; typedef unsigned int __attribute__ ((bitwidth(49))) uint49; typedef unsigned int __attribute__ ((bitwidth(50))) uint50; typedef unsigned int __attribute__ ((bitwidth(51))) uint51; typedef unsigned int __attribute__ ((bitwidth(52))) uint52; typedef unsigned int __attribute__ ((bitwidth(53))) uint53; typedef unsigned int __attribute__ ((bitwidth(54))) uint54; typedef unsigned int __attribute__ ((bitwidth(55))) uint55; typedef unsigned int __attribute__ ((bitwidth(56))) uint56; typedef unsigned int __attribute__ ((bitwidth(57))) uint57; typedef unsigned int __attribute__ ((bitwidth(58))) uint58; typedef unsigned int __attribute__ ((bitwidth(59))) uint59; typedef unsigned int __attribute__ ((bitwidth(60))) uint60; typedef unsigned int __attribute__ ((bitwidth(61))) uint61; typedef unsigned int __attribute__ ((bitwidth(62))) uint62; typedef unsigned int __attribute__ ((bitwidth(63))) uint63; /*#if AUTOPILOT_VERSION >= 1 */ typedef unsigned int __attribute__ ((bitwidth(65))) uint65; typedef unsigned int __attribute__ ((bitwidth(66))) uint66; typedef unsigned int __attribute__ ((bitwidth(67))) uint67; typedef unsigned int __attribute__ ((bitwidth(68))) uint68; typedef unsigned int __attribute__ ((bitwidth(69))) uint69; typedef unsigned int __attribute__ ((bitwidth(70))) uint70; typedef unsigned int __attribute__ ((bitwidth(71))) uint71; typedef unsigned int __attribute__ ((bitwidth(72))) uint72; typedef unsigned int __attribute__ ((bitwidth(73))) uint73; typedef unsigned int __attribute__ ((bitwidth(74))) uint74; typedef unsigned int __attribute__ ((bitwidth(75))) uint75; typedef unsigned int __attribute__ ((bitwidth(76))) uint76; typedef unsigned int __attribute__ ((bitwidth(77))) uint77; typedef unsigned int __attribute__ ((bitwidth(78))) uint78; typedef unsigned int __attribute__ ((bitwidth(79))) uint79; typedef unsigned int __attribute__ ((bitwidth(80))) uint80; typedef unsigned int __attribute__ ((bitwidth(81))) uint81; typedef unsigned int __attribute__ ((bitwidth(82))) uint82; typedef unsigned int __attribute__ ((bitwidth(83))) uint83; typedef unsigned int __attribute__ ((bitwidth(84))) uint84; typedef unsigned int __attribute__ ((bitwidth(85))) uint85; typedef unsigned int __attribute__ ((bitwidth(86))) uint86; typedef unsigned int __attribute__ ((bitwidth(87))) uint87; typedef unsigned int __attribute__ ((bitwidth(88))) uint88; typedef unsigned int __attribute__ ((bitwidth(89))) uint89; typedef unsigned int __attribute__ ((bitwidth(90))) uint90; typedef unsigned int __attribute__ ((bitwidth(91))) uint91; typedef unsigned int __attribute__ ((bitwidth(92))) uint92; typedef unsigned int __attribute__ ((bitwidth(93))) uint93; typedef unsigned int __attribute__ ((bitwidth(94))) uint94; typedef unsigned int __attribute__ ((bitwidth(95))) uint95; typedef unsigned int __attribute__ ((bitwidth(96))) uint96; typedef unsigned int __attribute__ ((bitwidth(97))) uint97; typedef unsigned int __attribute__ ((bitwidth(98))) uint98; typedef unsigned int __attribute__ ((bitwidth(99))) uint99; typedef unsigned int __attribute__ ((bitwidth(100))) uint100; typedef unsigned int __attribute__ ((bitwidth(101))) uint101; typedef unsigned int __attribute__ ((bitwidth(102))) uint102; typedef unsigned int __attribute__ ((bitwidth(103))) uint103; typedef unsigned int __attribute__ ((bitwidth(104))) uint104; typedef unsigned int __attribute__ ((bitwidth(105))) uint105; typedef unsigned int __attribute__ ((bitwidth(106))) uint106; typedef unsigned int __attribute__ ((bitwidth(107))) uint107; typedef unsigned int __attribute__ ((bitwidth(108))) uint108; typedef unsigned int __attribute__ ((bitwidth(109))) uint109; typedef unsigned int __attribute__ ((bitwidth(110))) uint110; typedef unsigned int __attribute__ ((bitwidth(111))) uint111; typedef unsigned int __attribute__ ((bitwidth(112))) uint112; typedef unsigned int __attribute__ ((bitwidth(113))) uint113; typedef unsigned int __attribute__ ((bitwidth(114))) uint114; typedef unsigned int __attribute__ ((bitwidth(115))) uint115; typedef unsigned int __attribute__ ((bitwidth(116))) uint116; typedef unsigned int __attribute__ ((bitwidth(117))) uint117; typedef unsigned int __attribute__ ((bitwidth(118))) uint118; typedef unsigned int __attribute__ ((bitwidth(119))) uint119; typedef unsigned int __attribute__ ((bitwidth(120))) uint120; typedef unsigned int __attribute__ ((bitwidth(121))) uint121; typedef unsigned int __attribute__ ((bitwidth(122))) uint122; typedef unsigned int __attribute__ ((bitwidth(123))) uint123; typedef unsigned int __attribute__ ((bitwidth(124))) uint124; typedef unsigned int __attribute__ ((bitwidth(125))) uint125; typedef unsigned int __attribute__ ((bitwidth(126))) uint126; typedef unsigned int __attribute__ ((bitwidth(127))) uint127; typedef unsigned int __attribute__ ((bitwidth(128))) uint128; /*#endif*/ /*#ifdef EXTENDED_GCC*/ typedef unsigned int __attribute__ ((bitwidth(129))) uint129; typedef unsigned int __attribute__ ((bitwidth(130))) uint130; typedef unsigned int __attribute__ ((bitwidth(131))) uint131; typedef unsigned int __attribute__ ((bitwidth(132))) uint132; typedef unsigned int __attribute__ ((bitwidth(133))) uint133; typedef unsigned int __attribute__ ((bitwidth(134))) uint134; typedef unsigned int __attribute__ ((bitwidth(135))) uint135; typedef unsigned int __attribute__ ((bitwidth(136))) uint136; typedef unsigned int __attribute__ ((bitwidth(137))) uint137; typedef unsigned int __attribute__ ((bitwidth(138))) uint138; typedef unsigned int __attribute__ ((bitwidth(139))) uint139; typedef unsigned int __attribute__ ((bitwidth(140))) uint140; typedef unsigned int __attribute__ ((bitwidth(141))) uint141; typedef unsigned int __attribute__ ((bitwidth(142))) uint142; typedef unsigned int __attribute__ ((bitwidth(143))) uint143; typedef unsigned int __attribute__ ((bitwidth(144))) uint144; typedef unsigned int __attribute__ ((bitwidth(145))) uint145; typedef unsigned int __attribute__ ((bitwidth(146))) uint146; typedef unsigned int __attribute__ ((bitwidth(147))) uint147; typedef unsigned int __attribute__ ((bitwidth(148))) uint148; typedef unsigned int __attribute__ ((bitwidth(149))) uint149; typedef unsigned int __attribute__ ((bitwidth(150))) uint150; typedef unsigned int __attribute__ ((bitwidth(151))) uint151; typedef unsigned int __attribute__ ((bitwidth(152))) uint152; typedef unsigned int __attribute__ ((bitwidth(153))) uint153; typedef unsigned int __attribute__ ((bitwidth(154))) uint154; typedef unsigned int __attribute__ ((bitwidth(155))) uint155; typedef unsigned int __attribute__ ((bitwidth(156))) uint156; typedef unsigned int __attribute__ ((bitwidth(157))) uint157; typedef unsigned int __attribute__ ((bitwidth(158))) uint158; typedef unsigned int __attribute__ ((bitwidth(159))) uint159; typedef unsigned int __attribute__ ((bitwidth(160))) uint160; typedef unsigned int __attribute__ ((bitwidth(161))) uint161; typedef unsigned int __attribute__ ((bitwidth(162))) uint162; typedef unsigned int __attribute__ ((bitwidth(163))) uint163; typedef unsigned int __attribute__ ((bitwidth(164))) uint164; typedef unsigned int __attribute__ ((bitwidth(165))) uint165; typedef unsigned int __attribute__ ((bitwidth(166))) uint166; typedef unsigned int __attribute__ ((bitwidth(167))) uint167; typedef unsigned int __attribute__ ((bitwidth(168))) uint168; typedef unsigned int __attribute__ ((bitwidth(169))) uint169; typedef unsigned int __attribute__ ((bitwidth(170))) uint170; typedef unsigned int __attribute__ ((bitwidth(171))) uint171; typedef unsigned int __attribute__ ((bitwidth(172))) uint172; typedef unsigned int __attribute__ ((bitwidth(173))) uint173; typedef unsigned int __attribute__ ((bitwidth(174))) uint174; typedef unsigned int __attribute__ ((bitwidth(175))) uint175; typedef unsigned int __attribute__ ((bitwidth(176))) uint176; typedef unsigned int __attribute__ ((bitwidth(177))) uint177; typedef unsigned int __attribute__ ((bitwidth(178))) uint178; typedef unsigned int __attribute__ ((bitwidth(179))) uint179; typedef unsigned int __attribute__ ((bitwidth(180))) uint180; typedef unsigned int __attribute__ ((bitwidth(181))) uint181; typedef unsigned int __attribute__ ((bitwidth(182))) uint182; typedef unsigned int __attribute__ ((bitwidth(183))) uint183; typedef unsigned int __attribute__ ((bitwidth(184))) uint184; typedef unsigned int __attribute__ ((bitwidth(185))) uint185; typedef unsigned int __attribute__ ((bitwidth(186))) uint186; typedef unsigned int __attribute__ ((bitwidth(187))) uint187; typedef unsigned int __attribute__ ((bitwidth(188))) uint188; typedef unsigned int __attribute__ ((bitwidth(189))) uint189; typedef unsigned int __attribute__ ((bitwidth(190))) uint190; typedef unsigned int __attribute__ ((bitwidth(191))) uint191; typedef unsigned int __attribute__ ((bitwidth(192))) uint192; typedef unsigned int __attribute__ ((bitwidth(193))) uint193; typedef unsigned int __attribute__ ((bitwidth(194))) uint194; typedef unsigned int __attribute__ ((bitwidth(195))) uint195; typedef unsigned int __attribute__ ((bitwidth(196))) uint196; typedef unsigned int __attribute__ ((bitwidth(197))) uint197; typedef unsigned int __attribute__ ((bitwidth(198))) uint198; typedef unsigned int __attribute__ ((bitwidth(199))) uint199; typedef unsigned int __attribute__ ((bitwidth(200))) uint200; typedef unsigned int __attribute__ ((bitwidth(201))) uint201; typedef unsigned int __attribute__ ((bitwidth(202))) uint202; typedef unsigned int __attribute__ ((bitwidth(203))) uint203; typedef unsigned int __attribute__ ((bitwidth(204))) uint204; typedef unsigned int __attribute__ ((bitwidth(205))) uint205; typedef unsigned int __attribute__ ((bitwidth(206))) uint206; typedef unsigned int __attribute__ ((bitwidth(207))) uint207; typedef unsigned int __attribute__ ((bitwidth(208))) uint208; typedef unsigned int __attribute__ ((bitwidth(209))) uint209; typedef unsigned int __attribute__ ((bitwidth(210))) uint210; typedef unsigned int __attribute__ ((bitwidth(211))) uint211; typedef unsigned int __attribute__ ((bitwidth(212))) uint212; typedef unsigned int __attribute__ ((bitwidth(213))) uint213; typedef unsigned int __attribute__ ((bitwidth(214))) uint214; typedef unsigned int __attribute__ ((bitwidth(215))) uint215; typedef unsigned int __attribute__ ((bitwidth(216))) uint216; typedef unsigned int __attribute__ ((bitwidth(217))) uint217; typedef unsigned int __attribute__ ((bitwidth(218))) uint218; typedef unsigned int __attribute__ ((bitwidth(219))) uint219; typedef unsigned int __attribute__ ((bitwidth(220))) uint220; typedef unsigned int __attribute__ ((bitwidth(221))) uint221; typedef unsigned int __attribute__ ((bitwidth(222))) uint222; typedef unsigned int __attribute__ ((bitwidth(223))) uint223; typedef unsigned int __attribute__ ((bitwidth(224))) uint224; typedef unsigned int __attribute__ ((bitwidth(225))) uint225; typedef unsigned int __attribute__ ((bitwidth(226))) uint226; typedef unsigned int __attribute__ ((bitwidth(227))) uint227; typedef unsigned int __attribute__ ((bitwidth(228))) uint228; typedef unsigned int __attribute__ ((bitwidth(229))) uint229; typedef unsigned int __attribute__ ((bitwidth(230))) uint230; typedef unsigned int __attribute__ ((bitwidth(231))) uint231; typedef unsigned int __attribute__ ((bitwidth(232))) uint232; typedef unsigned int __attribute__ ((bitwidth(233))) uint233; typedef unsigned int __attribute__ ((bitwidth(234))) uint234; typedef unsigned int __attribute__ ((bitwidth(235))) uint235; typedef unsigned int __attribute__ ((bitwidth(236))) uint236; typedef unsigned int __attribute__ ((bitwidth(237))) uint237; typedef unsigned int __attribute__ ((bitwidth(238))) uint238; typedef unsigned int __attribute__ ((bitwidth(239))) uint239; typedef unsigned int __attribute__ ((bitwidth(240))) uint240; typedef unsigned int __attribute__ ((bitwidth(241))) uint241; typedef unsigned int __attribute__ ((bitwidth(242))) uint242; typedef unsigned int __attribute__ ((bitwidth(243))) uint243; typedef unsigned int __attribute__ ((bitwidth(244))) uint244; typedef unsigned int __attribute__ ((bitwidth(245))) uint245; typedef unsigned int __attribute__ ((bitwidth(246))) uint246; typedef unsigned int __attribute__ ((bitwidth(247))) uint247; typedef unsigned int __attribute__ ((bitwidth(248))) uint248; typedef unsigned int __attribute__ ((bitwidth(249))) uint249; typedef unsigned int __attribute__ ((bitwidth(250))) uint250; typedef unsigned int __attribute__ ((bitwidth(251))) uint251; typedef unsigned int __attribute__ ((bitwidth(252))) uint252; typedef unsigned int __attribute__ ((bitwidth(253))) uint253; typedef unsigned int __attribute__ ((bitwidth(254))) uint254; typedef unsigned int __attribute__ ((bitwidth(255))) uint255; typedef unsigned int __attribute__ ((bitwidth(256))) uint256; typedef unsigned int __attribute__ ((bitwidth(257))) uint257; typedef unsigned int __attribute__ ((bitwidth(258))) uint258; typedef unsigned int __attribute__ ((bitwidth(259))) uint259; typedef unsigned int __attribute__ ((bitwidth(260))) uint260; typedef unsigned int __attribute__ ((bitwidth(261))) uint261; typedef unsigned int __attribute__ ((bitwidth(262))) uint262; typedef unsigned int __attribute__ ((bitwidth(263))) uint263; typedef unsigned int __attribute__ ((bitwidth(264))) uint264; typedef unsigned int __attribute__ ((bitwidth(265))) uint265; typedef unsigned int __attribute__ ((bitwidth(266))) uint266; typedef unsigned int __attribute__ ((bitwidth(267))) uint267; typedef unsigned int __attribute__ ((bitwidth(268))) uint268; typedef unsigned int __attribute__ ((bitwidth(269))) uint269; typedef unsigned int __attribute__ ((bitwidth(270))) uint270; typedef unsigned int __attribute__ ((bitwidth(271))) uint271; typedef unsigned int __attribute__ ((bitwidth(272))) uint272; typedef unsigned int __attribute__ ((bitwidth(273))) uint273; typedef unsigned int __attribute__ ((bitwidth(274))) uint274; typedef unsigned int __attribute__ ((bitwidth(275))) uint275; typedef unsigned int __attribute__ ((bitwidth(276))) uint276; typedef unsigned int __attribute__ ((bitwidth(277))) uint277; typedef unsigned int __attribute__ ((bitwidth(278))) uint278; typedef unsigned int __attribute__ ((bitwidth(279))) uint279; typedef unsigned int __attribute__ ((bitwidth(280))) uint280; typedef unsigned int __attribute__ ((bitwidth(281))) uint281; typedef unsigned int __attribute__ ((bitwidth(282))) uint282; typedef unsigned int __attribute__ ((bitwidth(283))) uint283; typedef unsigned int __attribute__ ((bitwidth(284))) uint284; typedef unsigned int __attribute__ ((bitwidth(285))) uint285; typedef unsigned int __attribute__ ((bitwidth(286))) uint286; typedef unsigned int __attribute__ ((bitwidth(287))) uint287; typedef unsigned int __attribute__ ((bitwidth(288))) uint288; typedef unsigned int __attribute__ ((bitwidth(289))) uint289; typedef unsigned int __attribute__ ((bitwidth(290))) uint290; typedef unsigned int __attribute__ ((bitwidth(291))) uint291; typedef unsigned int __attribute__ ((bitwidth(292))) uint292; typedef unsigned int __attribute__ ((bitwidth(293))) uint293; typedef unsigned int __attribute__ ((bitwidth(294))) uint294; typedef unsigned int __attribute__ ((bitwidth(295))) uint295; typedef unsigned int __attribute__ ((bitwidth(296))) uint296; typedef unsigned int __attribute__ ((bitwidth(297))) uint297; typedef unsigned int __attribute__ ((bitwidth(298))) uint298; typedef unsigned int __attribute__ ((bitwidth(299))) uint299; typedef unsigned int __attribute__ ((bitwidth(300))) uint300; typedef unsigned int __attribute__ ((bitwidth(301))) uint301; typedef unsigned int __attribute__ ((bitwidth(302))) uint302; typedef unsigned int __attribute__ ((bitwidth(303))) uint303; typedef unsigned int __attribute__ ((bitwidth(304))) uint304; typedef unsigned int __attribute__ ((bitwidth(305))) uint305; typedef unsigned int __attribute__ ((bitwidth(306))) uint306; typedef unsigned int __attribute__ ((bitwidth(307))) uint307; typedef unsigned int __attribute__ ((bitwidth(308))) uint308; typedef unsigned int __attribute__ ((bitwidth(309))) uint309; typedef unsigned int __attribute__ ((bitwidth(310))) uint310; typedef unsigned int __attribute__ ((bitwidth(311))) uint311; typedef unsigned int __attribute__ ((bitwidth(312))) uint312; typedef unsigned int __attribute__ ((bitwidth(313))) uint313; typedef unsigned int __attribute__ ((bitwidth(314))) uint314; typedef unsigned int __attribute__ ((bitwidth(315))) uint315; typedef unsigned int __attribute__ ((bitwidth(316))) uint316; typedef unsigned int __attribute__ ((bitwidth(317))) uint317; typedef unsigned int __attribute__ ((bitwidth(318))) uint318; typedef unsigned int __attribute__ ((bitwidth(319))) uint319; typedef unsigned int __attribute__ ((bitwidth(320))) uint320; typedef unsigned int __attribute__ ((bitwidth(321))) uint321; typedef unsigned int __attribute__ ((bitwidth(322))) uint322; typedef unsigned int __attribute__ ((bitwidth(323))) uint323; typedef unsigned int __attribute__ ((bitwidth(324))) uint324; typedef unsigned int __attribute__ ((bitwidth(325))) uint325; typedef unsigned int __attribute__ ((bitwidth(326))) uint326; typedef unsigned int __attribute__ ((bitwidth(327))) uint327; typedef unsigned int __attribute__ ((bitwidth(328))) uint328; typedef unsigned int __attribute__ ((bitwidth(329))) uint329; typedef unsigned int __attribute__ ((bitwidth(330))) uint330; typedef unsigned int __attribute__ ((bitwidth(331))) uint331; typedef unsigned int __attribute__ ((bitwidth(332))) uint332; typedef unsigned int __attribute__ ((bitwidth(333))) uint333; typedef unsigned int __attribute__ ((bitwidth(334))) uint334; typedef unsigned int __attribute__ ((bitwidth(335))) uint335; typedef unsigned int __attribute__ ((bitwidth(336))) uint336; typedef unsigned int __attribute__ ((bitwidth(337))) uint337; typedef unsigned int __attribute__ ((bitwidth(338))) uint338; typedef unsigned int __attribute__ ((bitwidth(339))) uint339; typedef unsigned int __attribute__ ((bitwidth(340))) uint340; typedef unsigned int __attribute__ ((bitwidth(341))) uint341; typedef unsigned int __attribute__ ((bitwidth(342))) uint342; typedef unsigned int __attribute__ ((bitwidth(343))) uint343; typedef unsigned int __attribute__ ((bitwidth(344))) uint344; typedef unsigned int __attribute__ ((bitwidth(345))) uint345; typedef unsigned int __attribute__ ((bitwidth(346))) uint346; typedef unsigned int __attribute__ ((bitwidth(347))) uint347; typedef unsigned int __attribute__ ((bitwidth(348))) uint348; typedef unsigned int __attribute__ ((bitwidth(349))) uint349; typedef unsigned int __attribute__ ((bitwidth(350))) uint350; typedef unsigned int __attribute__ ((bitwidth(351))) uint351; typedef unsigned int __attribute__ ((bitwidth(352))) uint352; typedef unsigned int __attribute__ ((bitwidth(353))) uint353; typedef unsigned int __attribute__ ((bitwidth(354))) uint354; typedef unsigned int __attribute__ ((bitwidth(355))) uint355; typedef unsigned int __attribute__ ((bitwidth(356))) uint356; typedef unsigned int __attribute__ ((bitwidth(357))) uint357; typedef unsigned int __attribute__ ((bitwidth(358))) uint358; typedef unsigned int __attribute__ ((bitwidth(359))) uint359; typedef unsigned int __attribute__ ((bitwidth(360))) uint360; typedef unsigned int __attribute__ ((bitwidth(361))) uint361; typedef unsigned int __attribute__ ((bitwidth(362))) uint362; typedef unsigned int __attribute__ ((bitwidth(363))) uint363; typedef unsigned int __attribute__ ((bitwidth(364))) uint364; typedef unsigned int __attribute__ ((bitwidth(365))) uint365; typedef unsigned int __attribute__ ((bitwidth(366))) uint366; typedef unsigned int __attribute__ ((bitwidth(367))) uint367; typedef unsigned int __attribute__ ((bitwidth(368))) uint368; typedef unsigned int __attribute__ ((bitwidth(369))) uint369; typedef unsigned int __attribute__ ((bitwidth(370))) uint370; typedef unsigned int __attribute__ ((bitwidth(371))) uint371; typedef unsigned int __attribute__ ((bitwidth(372))) uint372; typedef unsigned int __attribute__ ((bitwidth(373))) uint373; typedef unsigned int __attribute__ ((bitwidth(374))) uint374; typedef unsigned int __attribute__ ((bitwidth(375))) uint375; typedef unsigned int __attribute__ ((bitwidth(376))) uint376; typedef unsigned int __attribute__ ((bitwidth(377))) uint377; typedef unsigned int __attribute__ ((bitwidth(378))) uint378; typedef unsigned int __attribute__ ((bitwidth(379))) uint379; typedef unsigned int __attribute__ ((bitwidth(380))) uint380; typedef unsigned int __attribute__ ((bitwidth(381))) uint381; typedef unsigned int __attribute__ ((bitwidth(382))) uint382; typedef unsigned int __attribute__ ((bitwidth(383))) uint383; typedef unsigned int __attribute__ ((bitwidth(384))) uint384; typedef unsigned int __attribute__ ((bitwidth(385))) uint385; typedef unsigned int __attribute__ ((bitwidth(386))) uint386; typedef unsigned int __attribute__ ((bitwidth(387))) uint387; typedef unsigned int __attribute__ ((bitwidth(388))) uint388; typedef unsigned int __attribute__ ((bitwidth(389))) uint389; typedef unsigned int __attribute__ ((bitwidth(390))) uint390; typedef unsigned int __attribute__ ((bitwidth(391))) uint391; typedef unsigned int __attribute__ ((bitwidth(392))) uint392; typedef unsigned int __attribute__ ((bitwidth(393))) uint393; typedef unsigned int __attribute__ ((bitwidth(394))) uint394; typedef unsigned int __attribute__ ((bitwidth(395))) uint395; typedef unsigned int __attribute__ ((bitwidth(396))) uint396; typedef unsigned int __attribute__ ((bitwidth(397))) uint397; typedef unsigned int __attribute__ ((bitwidth(398))) uint398; typedef unsigned int __attribute__ ((bitwidth(399))) uint399; typedef unsigned int __attribute__ ((bitwidth(400))) uint400; typedef unsigned int __attribute__ ((bitwidth(401))) uint401; typedef unsigned int __attribute__ ((bitwidth(402))) uint402; typedef unsigned int __attribute__ ((bitwidth(403))) uint403; typedef unsigned int __attribute__ ((bitwidth(404))) uint404; typedef unsigned int __attribute__ ((bitwidth(405))) uint405; typedef unsigned int __attribute__ ((bitwidth(406))) uint406; typedef unsigned int __attribute__ ((bitwidth(407))) uint407; typedef unsigned int __attribute__ ((bitwidth(408))) uint408; typedef unsigned int __attribute__ ((bitwidth(409))) uint409; typedef unsigned int __attribute__ ((bitwidth(410))) uint410; typedef unsigned int __attribute__ ((bitwidth(411))) uint411; typedef unsigned int __attribute__ ((bitwidth(412))) uint412; typedef unsigned int __attribute__ ((bitwidth(413))) uint413; typedef unsigned int __attribute__ ((bitwidth(414))) uint414; typedef unsigned int __attribute__ ((bitwidth(415))) uint415; typedef unsigned int __attribute__ ((bitwidth(416))) uint416; typedef unsigned int __attribute__ ((bitwidth(417))) uint417; typedef unsigned int __attribute__ ((bitwidth(418))) uint418; typedef unsigned int __attribute__ ((bitwidth(419))) uint419; typedef unsigned int __attribute__ ((bitwidth(420))) uint420; typedef unsigned int __attribute__ ((bitwidth(421))) uint421; typedef unsigned int __attribute__ ((bitwidth(422))) uint422; typedef unsigned int __attribute__ ((bitwidth(423))) uint423; typedef unsigned int __attribute__ ((bitwidth(424))) uint424; typedef unsigned int __attribute__ ((bitwidth(425))) uint425; typedef unsigned int __attribute__ ((bitwidth(426))) uint426; typedef unsigned int __attribute__ ((bitwidth(427))) uint427; typedef unsigned int __attribute__ ((bitwidth(428))) uint428; typedef unsigned int __attribute__ ((bitwidth(429))) uint429; typedef unsigned int __attribute__ ((bitwidth(430))) uint430; typedef unsigned int __attribute__ ((bitwidth(431))) uint431; typedef unsigned int __attribute__ ((bitwidth(432))) uint432; typedef unsigned int __attribute__ ((bitwidth(433))) uint433; typedef unsigned int __attribute__ ((bitwidth(434))) uint434; typedef unsigned int __attribute__ ((bitwidth(435))) uint435; typedef unsigned int __attribute__ ((bitwidth(436))) uint436; typedef unsigned int __attribute__ ((bitwidth(437))) uint437; typedef unsigned int __attribute__ ((bitwidth(438))) uint438; typedef unsigned int __attribute__ ((bitwidth(439))) uint439; typedef unsigned int __attribute__ ((bitwidth(440))) uint440; typedef unsigned int __attribute__ ((bitwidth(441))) uint441; typedef unsigned int __attribute__ ((bitwidth(442))) uint442; typedef unsigned int __attribute__ ((bitwidth(443))) uint443; typedef unsigned int __attribute__ ((bitwidth(444))) uint444; typedef unsigned int __attribute__ ((bitwidth(445))) uint445; typedef unsigned int __attribute__ ((bitwidth(446))) uint446; typedef unsigned int __attribute__ ((bitwidth(447))) uint447; typedef unsigned int __attribute__ ((bitwidth(448))) uint448; typedef unsigned int __attribute__ ((bitwidth(449))) uint449; typedef unsigned int __attribute__ ((bitwidth(450))) uint450; typedef unsigned int __attribute__ ((bitwidth(451))) uint451; typedef unsigned int __attribute__ ((bitwidth(452))) uint452; typedef unsigned int __attribute__ ((bitwidth(453))) uint453; typedef unsigned int __attribute__ ((bitwidth(454))) uint454; typedef unsigned int __attribute__ ((bitwidth(455))) uint455; typedef unsigned int __attribute__ ((bitwidth(456))) uint456; typedef unsigned int __attribute__ ((bitwidth(457))) uint457; typedef unsigned int __attribute__ ((bitwidth(458))) uint458; typedef unsigned int __attribute__ ((bitwidth(459))) uint459; typedef unsigned int __attribute__ ((bitwidth(460))) uint460; typedef unsigned int __attribute__ ((bitwidth(461))) uint461; typedef unsigned int __attribute__ ((bitwidth(462))) uint462; typedef unsigned int __attribute__ ((bitwidth(463))) uint463; typedef unsigned int __attribute__ ((bitwidth(464))) uint464; typedef unsigned int __attribute__ ((bitwidth(465))) uint465; typedef unsigned int __attribute__ ((bitwidth(466))) uint466; typedef unsigned int __attribute__ ((bitwidth(467))) uint467; typedef unsigned int __attribute__ ((bitwidth(468))) uint468; typedef unsigned int __attribute__ ((bitwidth(469))) uint469; typedef unsigned int __attribute__ ((bitwidth(470))) uint470; typedef unsigned int __attribute__ ((bitwidth(471))) uint471; typedef unsigned int __attribute__ ((bitwidth(472))) uint472; typedef unsigned int __attribute__ ((bitwidth(473))) uint473; typedef unsigned int __attribute__ ((bitwidth(474))) uint474; typedef unsigned int __attribute__ ((bitwidth(475))) uint475; typedef unsigned int __attribute__ ((bitwidth(476))) uint476; typedef unsigned int __attribute__ ((bitwidth(477))) uint477; typedef unsigned int __attribute__ ((bitwidth(478))) uint478; typedef unsigned int __attribute__ ((bitwidth(479))) uint479; typedef unsigned int __attribute__ ((bitwidth(480))) uint480; typedef unsigned int __attribute__ ((bitwidth(481))) uint481; typedef unsigned int __attribute__ ((bitwidth(482))) uint482; typedef unsigned int __attribute__ ((bitwidth(483))) uint483; typedef unsigned int __attribute__ ((bitwidth(484))) uint484; typedef unsigned int __attribute__ ((bitwidth(485))) uint485; typedef unsigned int __attribute__ ((bitwidth(486))) uint486; typedef unsigned int __attribute__ ((bitwidth(487))) uint487; typedef unsigned int __attribute__ ((bitwidth(488))) uint488; typedef unsigned int __attribute__ ((bitwidth(489))) uint489; typedef unsigned int __attribute__ ((bitwidth(490))) uint490; typedef unsigned int __attribute__ ((bitwidth(491))) uint491; typedef unsigned int __attribute__ ((bitwidth(492))) uint492; typedef unsigned int __attribute__ ((bitwidth(493))) uint493; typedef unsigned int __attribute__ ((bitwidth(494))) uint494; typedef unsigned int __attribute__ ((bitwidth(495))) uint495; typedef unsigned int __attribute__ ((bitwidth(496))) uint496; typedef unsigned int __attribute__ ((bitwidth(497))) uint497; typedef unsigned int __attribute__ ((bitwidth(498))) uint498; typedef unsigned int __attribute__ ((bitwidth(499))) uint499; typedef unsigned int __attribute__ ((bitwidth(500))) uint500; typedef unsigned int __attribute__ ((bitwidth(501))) uint501; typedef unsigned int __attribute__ ((bitwidth(502))) uint502; typedef unsigned int __attribute__ ((bitwidth(503))) uint503; typedef unsigned int __attribute__ ((bitwidth(504))) uint504; typedef unsigned int __attribute__ ((bitwidth(505))) uint505; typedef unsigned int __attribute__ ((bitwidth(506))) uint506; typedef unsigned int __attribute__ ((bitwidth(507))) uint507; typedef unsigned int __attribute__ ((bitwidth(508))) uint508; typedef unsigned int __attribute__ ((bitwidth(509))) uint509; typedef unsigned int __attribute__ ((bitwidth(510))) uint510; typedef unsigned int __attribute__ ((bitwidth(511))) uint511; typedef unsigned int __attribute__ ((bitwidth(512))) uint512; typedef unsigned int __attribute__ ((bitwidth(513))) uint513; typedef unsigned int __attribute__ ((bitwidth(514))) uint514; typedef unsigned int __attribute__ ((bitwidth(515))) uint515; typedef unsigned int __attribute__ ((bitwidth(516))) uint516; typedef unsigned int __attribute__ ((bitwidth(517))) uint517; typedef unsigned int __attribute__ ((bitwidth(518))) uint518; typedef unsigned int __attribute__ ((bitwidth(519))) uint519; typedef unsigned int __attribute__ ((bitwidth(520))) uint520; typedef unsigned int __attribute__ ((bitwidth(521))) uint521; typedef unsigned int __attribute__ ((bitwidth(522))) uint522; typedef unsigned int __attribute__ ((bitwidth(523))) uint523; typedef unsigned int __attribute__ ((bitwidth(524))) uint524; typedef unsigned int __attribute__ ((bitwidth(525))) uint525; typedef unsigned int __attribute__ ((bitwidth(526))) uint526; typedef unsigned int __attribute__ ((bitwidth(527))) uint527; typedef unsigned int __attribute__ ((bitwidth(528))) uint528; typedef unsigned int __attribute__ ((bitwidth(529))) uint529; typedef unsigned int __attribute__ ((bitwidth(530))) uint530; typedef unsigned int __attribute__ ((bitwidth(531))) uint531; typedef unsigned int __attribute__ ((bitwidth(532))) uint532; typedef unsigned int __attribute__ ((bitwidth(533))) uint533; typedef unsigned int __attribute__ ((bitwidth(534))) uint534; typedef unsigned int __attribute__ ((bitwidth(535))) uint535; typedef unsigned int __attribute__ ((bitwidth(536))) uint536; typedef unsigned int __attribute__ ((bitwidth(537))) uint537; typedef unsigned int __attribute__ ((bitwidth(538))) uint538; typedef unsigned int __attribute__ ((bitwidth(539))) uint539; typedef unsigned int __attribute__ ((bitwidth(540))) uint540; typedef unsigned int __attribute__ ((bitwidth(541))) uint541; typedef unsigned int __attribute__ ((bitwidth(542))) uint542; typedef unsigned int __attribute__ ((bitwidth(543))) uint543; typedef unsigned int __attribute__ ((bitwidth(544))) uint544; typedef unsigned int __attribute__ ((bitwidth(545))) uint545; typedef unsigned int __attribute__ ((bitwidth(546))) uint546; typedef unsigned int __attribute__ ((bitwidth(547))) uint547; typedef unsigned int __attribute__ ((bitwidth(548))) uint548; typedef unsigned int __attribute__ ((bitwidth(549))) uint549; typedef unsigned int __attribute__ ((bitwidth(550))) uint550; typedef unsigned int __attribute__ ((bitwidth(551))) uint551; typedef unsigned int __attribute__ ((bitwidth(552))) uint552; typedef unsigned int __attribute__ ((bitwidth(553))) uint553; typedef unsigned int __attribute__ ((bitwidth(554))) uint554; typedef unsigned int __attribute__ ((bitwidth(555))) uint555; typedef unsigned int __attribute__ ((bitwidth(556))) uint556; typedef unsigned int __attribute__ ((bitwidth(557))) uint557; typedef unsigned int __attribute__ ((bitwidth(558))) uint558; typedef unsigned int __attribute__ ((bitwidth(559))) uint559; typedef unsigned int __attribute__ ((bitwidth(560))) uint560; typedef unsigned int __attribute__ ((bitwidth(561))) uint561; typedef unsigned int __attribute__ ((bitwidth(562))) uint562; typedef unsigned int __attribute__ ((bitwidth(563))) uint563; typedef unsigned int __attribute__ ((bitwidth(564))) uint564; typedef unsigned int __attribute__ ((bitwidth(565))) uint565; typedef unsigned int __attribute__ ((bitwidth(566))) uint566; typedef unsigned int __attribute__ ((bitwidth(567))) uint567; typedef unsigned int __attribute__ ((bitwidth(568))) uint568; typedef unsigned int __attribute__ ((bitwidth(569))) uint569; typedef unsigned int __attribute__ ((bitwidth(570))) uint570; typedef unsigned int __attribute__ ((bitwidth(571))) uint571; typedef unsigned int __attribute__ ((bitwidth(572))) uint572; typedef unsigned int __attribute__ ((bitwidth(573))) uint573; typedef unsigned int __attribute__ ((bitwidth(574))) uint574; typedef unsigned int __attribute__ ((bitwidth(575))) uint575; typedef unsigned int __attribute__ ((bitwidth(576))) uint576; typedef unsigned int __attribute__ ((bitwidth(577))) uint577; typedef unsigned int __attribute__ ((bitwidth(578))) uint578; typedef unsigned int __attribute__ ((bitwidth(579))) uint579; typedef unsigned int __attribute__ ((bitwidth(580))) uint580; typedef unsigned int __attribute__ ((bitwidth(581))) uint581; typedef unsigned int __attribute__ ((bitwidth(582))) uint582; typedef unsigned int __attribute__ ((bitwidth(583))) uint583; typedef unsigned int __attribute__ ((bitwidth(584))) uint584; typedef unsigned int __attribute__ ((bitwidth(585))) uint585; typedef unsigned int __attribute__ ((bitwidth(586))) uint586; typedef unsigned int __attribute__ ((bitwidth(587))) uint587; typedef unsigned int __attribute__ ((bitwidth(588))) uint588; typedef unsigned int __attribute__ ((bitwidth(589))) uint589; typedef unsigned int __attribute__ ((bitwidth(590))) uint590; typedef unsigned int __attribute__ ((bitwidth(591))) uint591; typedef unsigned int __attribute__ ((bitwidth(592))) uint592; typedef unsigned int __attribute__ ((bitwidth(593))) uint593; typedef unsigned int __attribute__ ((bitwidth(594))) uint594; typedef unsigned int __attribute__ ((bitwidth(595))) uint595; typedef unsigned int __attribute__ ((bitwidth(596))) uint596; typedef unsigned int __attribute__ ((bitwidth(597))) uint597; typedef unsigned int __attribute__ ((bitwidth(598))) uint598; typedef unsigned int __attribute__ ((bitwidth(599))) uint599; typedef unsigned int __attribute__ ((bitwidth(600))) uint600; typedef unsigned int __attribute__ ((bitwidth(601))) uint601; typedef unsigned int __attribute__ ((bitwidth(602))) uint602; typedef unsigned int __attribute__ ((bitwidth(603))) uint603; typedef unsigned int __attribute__ ((bitwidth(604))) uint604; typedef unsigned int __attribute__ ((bitwidth(605))) uint605; typedef unsigned int __attribute__ ((bitwidth(606))) uint606; typedef unsigned int __attribute__ ((bitwidth(607))) uint607; typedef unsigned int __attribute__ ((bitwidth(608))) uint608; typedef unsigned int __attribute__ ((bitwidth(609))) uint609; typedef unsigned int __attribute__ ((bitwidth(610))) uint610; typedef unsigned int __attribute__ ((bitwidth(611))) uint611; typedef unsigned int __attribute__ ((bitwidth(612))) uint612; typedef unsigned int __attribute__ ((bitwidth(613))) uint613; typedef unsigned int __attribute__ ((bitwidth(614))) uint614; typedef unsigned int __attribute__ ((bitwidth(615))) uint615; typedef unsigned int __attribute__ ((bitwidth(616))) uint616; typedef unsigned int __attribute__ ((bitwidth(617))) uint617; typedef unsigned int __attribute__ ((bitwidth(618))) uint618; typedef unsigned int __attribute__ ((bitwidth(619))) uint619; typedef unsigned int __attribute__ ((bitwidth(620))) uint620; typedef unsigned int __attribute__ ((bitwidth(621))) uint621; typedef unsigned int __attribute__ ((bitwidth(622))) uint622; typedef unsigned int __attribute__ ((bitwidth(623))) uint623; typedef unsigned int __attribute__ ((bitwidth(624))) uint624; typedef unsigned int __attribute__ ((bitwidth(625))) uint625; typedef unsigned int __attribute__ ((bitwidth(626))) uint626; typedef unsigned int __attribute__ ((bitwidth(627))) uint627; typedef unsigned int __attribute__ ((bitwidth(628))) uint628; typedef unsigned int __attribute__ ((bitwidth(629))) uint629; typedef unsigned int __attribute__ ((bitwidth(630))) uint630; typedef unsigned int __attribute__ ((bitwidth(631))) uint631; typedef unsigned int __attribute__ ((bitwidth(632))) uint632; typedef unsigned int __attribute__ ((bitwidth(633))) uint633; typedef unsigned int __attribute__ ((bitwidth(634))) uint634; typedef unsigned int __attribute__ ((bitwidth(635))) uint635; typedef unsigned int __attribute__ ((bitwidth(636))) uint636; typedef unsigned int __attribute__ ((bitwidth(637))) uint637; typedef unsigned int __attribute__ ((bitwidth(638))) uint638; typedef unsigned int __attribute__ ((bitwidth(639))) uint639; typedef unsigned int __attribute__ ((bitwidth(640))) uint640; typedef unsigned int __attribute__ ((bitwidth(641))) uint641; typedef unsigned int __attribute__ ((bitwidth(642))) uint642; typedef unsigned int __attribute__ ((bitwidth(643))) uint643; typedef unsigned int __attribute__ ((bitwidth(644))) uint644; typedef unsigned int __attribute__ ((bitwidth(645))) uint645; typedef unsigned int __attribute__ ((bitwidth(646))) uint646; typedef unsigned int __attribute__ ((bitwidth(647))) uint647; typedef unsigned int __attribute__ ((bitwidth(648))) uint648; typedef unsigned int __attribute__ ((bitwidth(649))) uint649; typedef unsigned int __attribute__ ((bitwidth(650))) uint650; typedef unsigned int __attribute__ ((bitwidth(651))) uint651; typedef unsigned int __attribute__ ((bitwidth(652))) uint652; typedef unsigned int __attribute__ ((bitwidth(653))) uint653; typedef unsigned int __attribute__ ((bitwidth(654))) uint654; typedef unsigned int __attribute__ ((bitwidth(655))) uint655; typedef unsigned int __attribute__ ((bitwidth(656))) uint656; typedef unsigned int __attribute__ ((bitwidth(657))) uint657; typedef unsigned int __attribute__ ((bitwidth(658))) uint658; typedef unsigned int __attribute__ ((bitwidth(659))) uint659; typedef unsigned int __attribute__ ((bitwidth(660))) uint660; typedef unsigned int __attribute__ ((bitwidth(661))) uint661; typedef unsigned int __attribute__ ((bitwidth(662))) uint662; typedef unsigned int __attribute__ ((bitwidth(663))) uint663; typedef unsigned int __attribute__ ((bitwidth(664))) uint664; typedef unsigned int __attribute__ ((bitwidth(665))) uint665; typedef unsigned int __attribute__ ((bitwidth(666))) uint666; typedef unsigned int __attribute__ ((bitwidth(667))) uint667; typedef unsigned int __attribute__ ((bitwidth(668))) uint668; typedef unsigned int __attribute__ ((bitwidth(669))) uint669; typedef unsigned int __attribute__ ((bitwidth(670))) uint670; typedef unsigned int __attribute__ ((bitwidth(671))) uint671; typedef unsigned int __attribute__ ((bitwidth(672))) uint672; typedef unsigned int __attribute__ ((bitwidth(673))) uint673; typedef unsigned int __attribute__ ((bitwidth(674))) uint674; typedef unsigned int __attribute__ ((bitwidth(675))) uint675; typedef unsigned int __attribute__ ((bitwidth(676))) uint676; typedef unsigned int __attribute__ ((bitwidth(677))) uint677; typedef unsigned int __attribute__ ((bitwidth(678))) uint678; typedef unsigned int __attribute__ ((bitwidth(679))) uint679; typedef unsigned int __attribute__ ((bitwidth(680))) uint680; typedef unsigned int __attribute__ ((bitwidth(681))) uint681; typedef unsigned int __attribute__ ((bitwidth(682))) uint682; typedef unsigned int __attribute__ ((bitwidth(683))) uint683; typedef unsigned int __attribute__ ((bitwidth(684))) uint684; typedef unsigned int __attribute__ ((bitwidth(685))) uint685; typedef unsigned int __attribute__ ((bitwidth(686))) uint686; typedef unsigned int __attribute__ ((bitwidth(687))) uint687; typedef unsigned int __attribute__ ((bitwidth(688))) uint688; typedef unsigned int __attribute__ ((bitwidth(689))) uint689; typedef unsigned int __attribute__ ((bitwidth(690))) uint690; typedef unsigned int __attribute__ ((bitwidth(691))) uint691; typedef unsigned int __attribute__ ((bitwidth(692))) uint692; typedef unsigned int __attribute__ ((bitwidth(693))) uint693; typedef unsigned int __attribute__ ((bitwidth(694))) uint694; typedef unsigned int __attribute__ ((bitwidth(695))) uint695; typedef unsigned int __attribute__ ((bitwidth(696))) uint696; typedef unsigned int __attribute__ ((bitwidth(697))) uint697; typedef unsigned int __attribute__ ((bitwidth(698))) uint698; typedef unsigned int __attribute__ ((bitwidth(699))) uint699; typedef unsigned int __attribute__ ((bitwidth(700))) uint700; typedef unsigned int __attribute__ ((bitwidth(701))) uint701; typedef unsigned int __attribute__ ((bitwidth(702))) uint702; typedef unsigned int __attribute__ ((bitwidth(703))) uint703; typedef unsigned int __attribute__ ((bitwidth(704))) uint704; typedef unsigned int __attribute__ ((bitwidth(705))) uint705; typedef unsigned int __attribute__ ((bitwidth(706))) uint706; typedef unsigned int __attribute__ ((bitwidth(707))) uint707; typedef unsigned int __attribute__ ((bitwidth(708))) uint708; typedef unsigned int __attribute__ ((bitwidth(709))) uint709; typedef unsigned int __attribute__ ((bitwidth(710))) uint710; typedef unsigned int __attribute__ ((bitwidth(711))) uint711; typedef unsigned int __attribute__ ((bitwidth(712))) uint712; typedef unsigned int __attribute__ ((bitwidth(713))) uint713; typedef unsigned int __attribute__ ((bitwidth(714))) uint714; typedef unsigned int __attribute__ ((bitwidth(715))) uint715; typedef unsigned int __attribute__ ((bitwidth(716))) uint716; typedef unsigned int __attribute__ ((bitwidth(717))) uint717; typedef unsigned int __attribute__ ((bitwidth(718))) uint718; typedef unsigned int __attribute__ ((bitwidth(719))) uint719; typedef unsigned int __attribute__ ((bitwidth(720))) uint720; typedef unsigned int __attribute__ ((bitwidth(721))) uint721; typedef unsigned int __attribute__ ((bitwidth(722))) uint722; typedef unsigned int __attribute__ ((bitwidth(723))) uint723; typedef unsigned int __attribute__ ((bitwidth(724))) uint724; typedef unsigned int __attribute__ ((bitwidth(725))) uint725; typedef unsigned int __attribute__ ((bitwidth(726))) uint726; typedef unsigned int __attribute__ ((bitwidth(727))) uint727; typedef unsigned int __attribute__ ((bitwidth(728))) uint728; typedef unsigned int __attribute__ ((bitwidth(729))) uint729; typedef unsigned int __attribute__ ((bitwidth(730))) uint730; typedef unsigned int __attribute__ ((bitwidth(731))) uint731; typedef unsigned int __attribute__ ((bitwidth(732))) uint732; typedef unsigned int __attribute__ ((bitwidth(733))) uint733; typedef unsigned int __attribute__ ((bitwidth(734))) uint734; typedef unsigned int __attribute__ ((bitwidth(735))) uint735; typedef unsigned int __attribute__ ((bitwidth(736))) uint736; typedef unsigned int __attribute__ ((bitwidth(737))) uint737; typedef unsigned int __attribute__ ((bitwidth(738))) uint738; typedef unsigned int __attribute__ ((bitwidth(739))) uint739; typedef unsigned int __attribute__ ((bitwidth(740))) uint740; typedef unsigned int __attribute__ ((bitwidth(741))) uint741; typedef unsigned int __attribute__ ((bitwidth(742))) uint742; typedef unsigned int __attribute__ ((bitwidth(743))) uint743; typedef unsigned int __attribute__ ((bitwidth(744))) uint744; typedef unsigned int __attribute__ ((bitwidth(745))) uint745; typedef unsigned int __attribute__ ((bitwidth(746))) uint746; typedef unsigned int __attribute__ ((bitwidth(747))) uint747; typedef unsigned int __attribute__ ((bitwidth(748))) uint748; typedef unsigned int __attribute__ ((bitwidth(749))) uint749; typedef unsigned int __attribute__ ((bitwidth(750))) uint750; typedef unsigned int __attribute__ ((bitwidth(751))) uint751; typedef unsigned int __attribute__ ((bitwidth(752))) uint752; typedef unsigned int __attribute__ ((bitwidth(753))) uint753; typedef unsigned int __attribute__ ((bitwidth(754))) uint754; typedef unsigned int __attribute__ ((bitwidth(755))) uint755; typedef unsigned int __attribute__ ((bitwidth(756))) uint756; typedef unsigned int __attribute__ ((bitwidth(757))) uint757; typedef unsigned int __attribute__ ((bitwidth(758))) uint758; typedef unsigned int __attribute__ ((bitwidth(759))) uint759; typedef unsigned int __attribute__ ((bitwidth(760))) uint760; typedef unsigned int __attribute__ ((bitwidth(761))) uint761; typedef unsigned int __attribute__ ((bitwidth(762))) uint762; typedef unsigned int __attribute__ ((bitwidth(763))) uint763; typedef unsigned int __attribute__ ((bitwidth(764))) uint764; typedef unsigned int __attribute__ ((bitwidth(765))) uint765; typedef unsigned int __attribute__ ((bitwidth(766))) uint766; typedef unsigned int __attribute__ ((bitwidth(767))) uint767; typedef unsigned int __attribute__ ((bitwidth(768))) uint768; typedef unsigned int __attribute__ ((bitwidth(769))) uint769; typedef unsigned int __attribute__ ((bitwidth(770))) uint770; typedef unsigned int __attribute__ ((bitwidth(771))) uint771; typedef unsigned int __attribute__ ((bitwidth(772))) uint772; typedef unsigned int __attribute__ ((bitwidth(773))) uint773; typedef unsigned int __attribute__ ((bitwidth(774))) uint774; typedef unsigned int __attribute__ ((bitwidth(775))) uint775; typedef unsigned int __attribute__ ((bitwidth(776))) uint776; typedef unsigned int __attribute__ ((bitwidth(777))) uint777; typedef unsigned int __attribute__ ((bitwidth(778))) uint778; typedef unsigned int __attribute__ ((bitwidth(779))) uint779; typedef unsigned int __attribute__ ((bitwidth(780))) uint780; typedef unsigned int __attribute__ ((bitwidth(781))) uint781; typedef unsigned int __attribute__ ((bitwidth(782))) uint782; typedef unsigned int __attribute__ ((bitwidth(783))) uint783; typedef unsigned int __attribute__ ((bitwidth(784))) uint784; typedef unsigned int __attribute__ ((bitwidth(785))) uint785; typedef unsigned int __attribute__ ((bitwidth(786))) uint786; typedef unsigned int __attribute__ ((bitwidth(787))) uint787; typedef unsigned int __attribute__ ((bitwidth(788))) uint788; typedef unsigned int __attribute__ ((bitwidth(789))) uint789; typedef unsigned int __attribute__ ((bitwidth(790))) uint790; typedef unsigned int __attribute__ ((bitwidth(791))) uint791; typedef unsigned int __attribute__ ((bitwidth(792))) uint792; typedef unsigned int __attribute__ ((bitwidth(793))) uint793; typedef unsigned int __attribute__ ((bitwidth(794))) uint794; typedef unsigned int __attribute__ ((bitwidth(795))) uint795; typedef unsigned int __attribute__ ((bitwidth(796))) uint796; typedef unsigned int __attribute__ ((bitwidth(797))) uint797; typedef unsigned int __attribute__ ((bitwidth(798))) uint798; typedef unsigned int __attribute__ ((bitwidth(799))) uint799; typedef unsigned int __attribute__ ((bitwidth(800))) uint800; typedef unsigned int __attribute__ ((bitwidth(801))) uint801; typedef unsigned int __attribute__ ((bitwidth(802))) uint802; typedef unsigned int __attribute__ ((bitwidth(803))) uint803; typedef unsigned int __attribute__ ((bitwidth(804))) uint804; typedef unsigned int __attribute__ ((bitwidth(805))) uint805; typedef unsigned int __attribute__ ((bitwidth(806))) uint806; typedef unsigned int __attribute__ ((bitwidth(807))) uint807; typedef unsigned int __attribute__ ((bitwidth(808))) uint808; typedef unsigned int __attribute__ ((bitwidth(809))) uint809; typedef unsigned int __attribute__ ((bitwidth(810))) uint810; typedef unsigned int __attribute__ ((bitwidth(811))) uint811; typedef unsigned int __attribute__ ((bitwidth(812))) uint812; typedef unsigned int __attribute__ ((bitwidth(813))) uint813; typedef unsigned int __attribute__ ((bitwidth(814))) uint814; typedef unsigned int __attribute__ ((bitwidth(815))) uint815; typedef unsigned int __attribute__ ((bitwidth(816))) uint816; typedef unsigned int __attribute__ ((bitwidth(817))) uint817; typedef unsigned int __attribute__ ((bitwidth(818))) uint818; typedef unsigned int __attribute__ ((bitwidth(819))) uint819; typedef unsigned int __attribute__ ((bitwidth(820))) uint820; typedef unsigned int __attribute__ ((bitwidth(821))) uint821; typedef unsigned int __attribute__ ((bitwidth(822))) uint822; typedef unsigned int __attribute__ ((bitwidth(823))) uint823; typedef unsigned int __attribute__ ((bitwidth(824))) uint824; typedef unsigned int __attribute__ ((bitwidth(825))) uint825; typedef unsigned int __attribute__ ((bitwidth(826))) uint826; typedef unsigned int __attribute__ ((bitwidth(827))) uint827; typedef unsigned int __attribute__ ((bitwidth(828))) uint828; typedef unsigned int __attribute__ ((bitwidth(829))) uint829; typedef unsigned int __attribute__ ((bitwidth(830))) uint830; typedef unsigned int __attribute__ ((bitwidth(831))) uint831; typedef unsigned int __attribute__ ((bitwidth(832))) uint832; typedef unsigned int __attribute__ ((bitwidth(833))) uint833; typedef unsigned int __attribute__ ((bitwidth(834))) uint834; typedef unsigned int __attribute__ ((bitwidth(835))) uint835; typedef unsigned int __attribute__ ((bitwidth(836))) uint836; typedef unsigned int __attribute__ ((bitwidth(837))) uint837; typedef unsigned int __attribute__ ((bitwidth(838))) uint838; typedef unsigned int __attribute__ ((bitwidth(839))) uint839; typedef unsigned int __attribute__ ((bitwidth(840))) uint840; typedef unsigned int __attribute__ ((bitwidth(841))) uint841; typedef unsigned int __attribute__ ((bitwidth(842))) uint842; typedef unsigned int __attribute__ ((bitwidth(843))) uint843; typedef unsigned int __attribute__ ((bitwidth(844))) uint844; typedef unsigned int __attribute__ ((bitwidth(845))) uint845; typedef unsigned int __attribute__ ((bitwidth(846))) uint846; typedef unsigned int __attribute__ ((bitwidth(847))) uint847; typedef unsigned int __attribute__ ((bitwidth(848))) uint848; typedef unsigned int __attribute__ ((bitwidth(849))) uint849; typedef unsigned int __attribute__ ((bitwidth(850))) uint850; typedef unsigned int __attribute__ ((bitwidth(851))) uint851; typedef unsigned int __attribute__ ((bitwidth(852))) uint852; typedef unsigned int __attribute__ ((bitwidth(853))) uint853; typedef unsigned int __attribute__ ((bitwidth(854))) uint854; typedef unsigned int __attribute__ ((bitwidth(855))) uint855; typedef unsigned int __attribute__ ((bitwidth(856))) uint856; typedef unsigned int __attribute__ ((bitwidth(857))) uint857; typedef unsigned int __attribute__ ((bitwidth(858))) uint858; typedef unsigned int __attribute__ ((bitwidth(859))) uint859; typedef unsigned int __attribute__ ((bitwidth(860))) uint860; typedef unsigned int __attribute__ ((bitwidth(861))) uint861; typedef unsigned int __attribute__ ((bitwidth(862))) uint862; typedef unsigned int __attribute__ ((bitwidth(863))) uint863; typedef unsigned int __attribute__ ((bitwidth(864))) uint864; typedef unsigned int __attribute__ ((bitwidth(865))) uint865; typedef unsigned int __attribute__ ((bitwidth(866))) uint866; typedef unsigned int __attribute__ ((bitwidth(867))) uint867; typedef unsigned int __attribute__ ((bitwidth(868))) uint868; typedef unsigned int __attribute__ ((bitwidth(869))) uint869; typedef unsigned int __attribute__ ((bitwidth(870))) uint870; typedef unsigned int __attribute__ ((bitwidth(871))) uint871; typedef unsigned int __attribute__ ((bitwidth(872))) uint872; typedef unsigned int __attribute__ ((bitwidth(873))) uint873; typedef unsigned int __attribute__ ((bitwidth(874))) uint874; typedef unsigned int __attribute__ ((bitwidth(875))) uint875; typedef unsigned int __attribute__ ((bitwidth(876))) uint876; typedef unsigned int __attribute__ ((bitwidth(877))) uint877; typedef unsigned int __attribute__ ((bitwidth(878))) uint878; typedef unsigned int __attribute__ ((bitwidth(879))) uint879; typedef unsigned int __attribute__ ((bitwidth(880))) uint880; typedef unsigned int __attribute__ ((bitwidth(881))) uint881; typedef unsigned int __attribute__ ((bitwidth(882))) uint882; typedef unsigned int __attribute__ ((bitwidth(883))) uint883; typedef unsigned int __attribute__ ((bitwidth(884))) uint884; typedef unsigned int __attribute__ ((bitwidth(885))) uint885; typedef unsigned int __attribute__ ((bitwidth(886))) uint886; typedef unsigned int __attribute__ ((bitwidth(887))) uint887; typedef unsigned int __attribute__ ((bitwidth(888))) uint888; typedef unsigned int __attribute__ ((bitwidth(889))) uint889; typedef unsigned int __attribute__ ((bitwidth(890))) uint890; typedef unsigned int __attribute__ ((bitwidth(891))) uint891; typedef unsigned int __attribute__ ((bitwidth(892))) uint892; typedef unsigned int __attribute__ ((bitwidth(893))) uint893; typedef unsigned int __attribute__ ((bitwidth(894))) uint894; typedef unsigned int __attribute__ ((bitwidth(895))) uint895; typedef unsigned int __attribute__ ((bitwidth(896))) uint896; typedef unsigned int __attribute__ ((bitwidth(897))) uint897; typedef unsigned int __attribute__ ((bitwidth(898))) uint898; typedef unsigned int __attribute__ ((bitwidth(899))) uint899; typedef unsigned int __attribute__ ((bitwidth(900))) uint900; typedef unsigned int __attribute__ ((bitwidth(901))) uint901; typedef unsigned int __attribute__ ((bitwidth(902))) uint902; typedef unsigned int __attribute__ ((bitwidth(903))) uint903; typedef unsigned int __attribute__ ((bitwidth(904))) uint904; typedef unsigned int __attribute__ ((bitwidth(905))) uint905; typedef unsigned int __attribute__ ((bitwidth(906))) uint906; typedef unsigned int __attribute__ ((bitwidth(907))) uint907; typedef unsigned int __attribute__ ((bitwidth(908))) uint908; typedef unsigned int __attribute__ ((bitwidth(909))) uint909; typedef unsigned int __attribute__ ((bitwidth(910))) uint910; typedef unsigned int __attribute__ ((bitwidth(911))) uint911; typedef unsigned int __attribute__ ((bitwidth(912))) uint912; typedef unsigned int __attribute__ ((bitwidth(913))) uint913; typedef unsigned int __attribute__ ((bitwidth(914))) uint914; typedef unsigned int __attribute__ ((bitwidth(915))) uint915; typedef unsigned int __attribute__ ((bitwidth(916))) uint916; typedef unsigned int __attribute__ ((bitwidth(917))) uint917; typedef unsigned int __attribute__ ((bitwidth(918))) uint918; typedef unsigned int __attribute__ ((bitwidth(919))) uint919; typedef unsigned int __attribute__ ((bitwidth(920))) uint920; typedef unsigned int __attribute__ ((bitwidth(921))) uint921; typedef unsigned int __attribute__ ((bitwidth(922))) uint922; typedef unsigned int __attribute__ ((bitwidth(923))) uint923; typedef unsigned int __attribute__ ((bitwidth(924))) uint924; typedef unsigned int __attribute__ ((bitwidth(925))) uint925; typedef unsigned int __attribute__ ((bitwidth(926))) uint926; typedef unsigned int __attribute__ ((bitwidth(927))) uint927; typedef unsigned int __attribute__ ((bitwidth(928))) uint928; typedef unsigned int __attribute__ ((bitwidth(929))) uint929; typedef unsigned int __attribute__ ((bitwidth(930))) uint930; typedef unsigned int __attribute__ ((bitwidth(931))) uint931; typedef unsigned int __attribute__ ((bitwidth(932))) uint932; typedef unsigned int __attribute__ ((bitwidth(933))) uint933; typedef unsigned int __attribute__ ((bitwidth(934))) uint934; typedef unsigned int __attribute__ ((bitwidth(935))) uint935; typedef unsigned int __attribute__ ((bitwidth(936))) uint936; typedef unsigned int __attribute__ ((bitwidth(937))) uint937; typedef unsigned int __attribute__ ((bitwidth(938))) uint938; typedef unsigned int __attribute__ ((bitwidth(939))) uint939; typedef unsigned int __attribute__ ((bitwidth(940))) uint940; typedef unsigned int __attribute__ ((bitwidth(941))) uint941; typedef unsigned int __attribute__ ((bitwidth(942))) uint942; typedef unsigned int __attribute__ ((bitwidth(943))) uint943; typedef unsigned int __attribute__ ((bitwidth(944))) uint944; typedef unsigned int __attribute__ ((bitwidth(945))) uint945; typedef unsigned int __attribute__ ((bitwidth(946))) uint946; typedef unsigned int __attribute__ ((bitwidth(947))) uint947; typedef unsigned int __attribute__ ((bitwidth(948))) uint948; typedef unsigned int __attribute__ ((bitwidth(949))) uint949; typedef unsigned int __attribute__ ((bitwidth(950))) uint950; typedef unsigned int __attribute__ ((bitwidth(951))) uint951; typedef unsigned int __attribute__ ((bitwidth(952))) uint952; typedef unsigned int __attribute__ ((bitwidth(953))) uint953; typedef unsigned int __attribute__ ((bitwidth(954))) uint954; typedef unsigned int __attribute__ ((bitwidth(955))) uint955; typedef unsigned int __attribute__ ((bitwidth(956))) uint956; typedef unsigned int __attribute__ ((bitwidth(957))) uint957; typedef unsigned int __attribute__ ((bitwidth(958))) uint958; typedef unsigned int __attribute__ ((bitwidth(959))) uint959; typedef unsigned int __attribute__ ((bitwidth(960))) uint960; typedef unsigned int __attribute__ ((bitwidth(961))) uint961; typedef unsigned int __attribute__ ((bitwidth(962))) uint962; typedef unsigned int __attribute__ ((bitwidth(963))) uint963; typedef unsigned int __attribute__ ((bitwidth(964))) uint964; typedef unsigned int __attribute__ ((bitwidth(965))) uint965; typedef unsigned int __attribute__ ((bitwidth(966))) uint966; typedef unsigned int __attribute__ ((bitwidth(967))) uint967; typedef unsigned int __attribute__ ((bitwidth(968))) uint968; typedef unsigned int __attribute__ ((bitwidth(969))) uint969; typedef unsigned int __attribute__ ((bitwidth(970))) uint970; typedef unsigned int __attribute__ ((bitwidth(971))) uint971; typedef unsigned int __attribute__ ((bitwidth(972))) uint972; typedef unsigned int __attribute__ ((bitwidth(973))) uint973; typedef unsigned int __attribute__ ((bitwidth(974))) uint974; typedef unsigned int __attribute__ ((bitwidth(975))) uint975; typedef unsigned int __attribute__ ((bitwidth(976))) uint976; typedef unsigned int __attribute__ ((bitwidth(977))) uint977; typedef unsigned int __attribute__ ((bitwidth(978))) uint978; typedef unsigned int __attribute__ ((bitwidth(979))) uint979; typedef unsigned int __attribute__ ((bitwidth(980))) uint980; typedef unsigned int __attribute__ ((bitwidth(981))) uint981; typedef unsigned int __attribute__ ((bitwidth(982))) uint982; typedef unsigned int __attribute__ ((bitwidth(983))) uint983; typedef unsigned int __attribute__ ((bitwidth(984))) uint984; typedef unsigned int __attribute__ ((bitwidth(985))) uint985; typedef unsigned int __attribute__ ((bitwidth(986))) uint986; typedef unsigned int __attribute__ ((bitwidth(987))) uint987; typedef unsigned int __attribute__ ((bitwidth(988))) uint988; typedef unsigned int __attribute__ ((bitwidth(989))) uint989; typedef unsigned int __attribute__ ((bitwidth(990))) uint990; typedef unsigned int __attribute__ ((bitwidth(991))) uint991; typedef unsigned int __attribute__ ((bitwidth(992))) uint992; typedef unsigned int __attribute__ ((bitwidth(993))) uint993; typedef unsigned int __attribute__ ((bitwidth(994))) uint994; typedef unsigned int __attribute__ ((bitwidth(995))) uint995; typedef unsigned int __attribute__ ((bitwidth(996))) uint996; typedef unsigned int __attribute__ ((bitwidth(997))) uint997; typedef unsigned int __attribute__ ((bitwidth(998))) uint998; typedef unsigned int __attribute__ ((bitwidth(999))) uint999; typedef unsigned int __attribute__ ((bitwidth(1000))) uint1000; typedef unsigned int __attribute__ ((bitwidth(1001))) uint1001; typedef unsigned int __attribute__ ((bitwidth(1002))) uint1002; typedef unsigned int __attribute__ ((bitwidth(1003))) uint1003; typedef unsigned int __attribute__ ((bitwidth(1004))) uint1004; typedef unsigned int __attribute__ ((bitwidth(1005))) uint1005; typedef unsigned int __attribute__ ((bitwidth(1006))) uint1006; typedef unsigned int __attribute__ ((bitwidth(1007))) uint1007; typedef unsigned int __attribute__ ((bitwidth(1008))) uint1008; typedef unsigned int __attribute__ ((bitwidth(1009))) uint1009; typedef unsigned int __attribute__ ((bitwidth(1010))) uint1010; typedef unsigned int __attribute__ ((bitwidth(1011))) uint1011; typedef unsigned int __attribute__ ((bitwidth(1012))) uint1012; typedef unsigned int __attribute__ ((bitwidth(1013))) uint1013; typedef unsigned int __attribute__ ((bitwidth(1014))) uint1014; typedef unsigned int __attribute__ ((bitwidth(1015))) uint1015; typedef unsigned int __attribute__ ((bitwidth(1016))) uint1016; typedef unsigned int __attribute__ ((bitwidth(1017))) uint1017; typedef unsigned int __attribute__ ((bitwidth(1018))) uint1018; typedef unsigned int __attribute__ ((bitwidth(1019))) uint1019; typedef unsigned int __attribute__ ((bitwidth(1020))) uint1020; typedef unsigned int __attribute__ ((bitwidth(1021))) uint1021; typedef unsigned int __attribute__ ((bitwidth(1022))) uint1022; typedef unsigned int __attribute__ ((bitwidth(1023))) uint1023; typedef unsigned int __attribute__ ((bitwidth(1024))) uint1024; # 109 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/common/technology/autopilot\\etc/autopilot_dt.h" 2 # 1 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/common/technology/autopilot\\etc/autopilot_dt_ext.def" 1 typedef unsigned int __attribute__ ((bitwidth(1025))) uint1025; typedef unsigned int __attribute__ ((bitwidth(1026))) uint1026; typedef unsigned int __attribute__ ((bitwidth(1027))) uint1027; typedef unsigned int __attribute__ ((bitwidth(1028))) uint1028; typedef unsigned int __attribute__ ((bitwidth(1029))) uint1029; typedef unsigned int __attribute__ ((bitwidth(1030))) uint1030; typedef unsigned int __attribute__ ((bitwidth(1031))) uint1031; typedef unsigned int __attribute__ ((bitwidth(1032))) uint1032; typedef unsigned int __attribute__ ((bitwidth(1033))) uint1033; typedef unsigned int __attribute__ ((bitwidth(1034))) uint1034; typedef unsigned int __attribute__ ((bitwidth(1035))) uint1035; typedef unsigned int __attribute__ ((bitwidth(1036))) uint1036; typedef unsigned int __attribute__ ((bitwidth(1037))) uint1037; typedef unsigned int __attribute__ ((bitwidth(1038))) uint1038; typedef unsigned int __attribute__ ((bitwidth(1039))) uint1039; typedef unsigned int __attribute__ ((bitwidth(1040))) uint1040; typedef unsigned int __attribute__ ((bitwidth(1041))) uint1041; typedef unsigned int __attribute__ ((bitwidth(1042))) uint1042; typedef unsigned int __attribute__ ((bitwidth(1043))) uint1043; typedef unsigned int __attribute__ ((bitwidth(1044))) uint1044; typedef unsigned int __attribute__ ((bitwidth(1045))) uint1045; typedef unsigned int __attribute__ ((bitwidth(1046))) uint1046; typedef unsigned int __attribute__ ((bitwidth(1047))) uint1047; typedef unsigned int __attribute__ ((bitwidth(1048))) uint1048; typedef unsigned int __attribute__ ((bitwidth(1049))) uint1049; typedef unsigned int __attribute__ ((bitwidth(1050))) uint1050; typedef unsigned int __attribute__ ((bitwidth(1051))) uint1051; typedef unsigned int __attribute__ ((bitwidth(1052))) uint1052; typedef unsigned int __attribute__ ((bitwidth(1053))) uint1053; typedef unsigned int __attribute__ ((bitwidth(1054))) uint1054; typedef unsigned int __attribute__ ((bitwidth(1055))) uint1055; typedef unsigned int __attribute__ ((bitwidth(1056))) uint1056; typedef unsigned int __attribute__ ((bitwidth(1057))) uint1057; typedef unsigned int __attribute__ ((bitwidth(1058))) uint1058; typedef unsigned int __attribute__ ((bitwidth(1059))) uint1059; typedef unsigned int __attribute__ ((bitwidth(1060))) uint1060; typedef unsigned int __attribute__ ((bitwidth(1061))) uint1061; typedef unsigned int __attribute__ ((bitwidth(1062))) uint1062; typedef unsigned int __attribute__ ((bitwidth(1063))) uint1063; typedef unsigned int __attribute__ ((bitwidth(1064))) uint1064; typedef unsigned int __attribute__ ((bitwidth(1065))) uint1065; typedef unsigned int __attribute__ ((bitwidth(1066))) uint1066; typedef unsigned int __attribute__ ((bitwidth(1067))) uint1067; typedef unsigned int __attribute__ ((bitwidth(1068))) uint1068; typedef unsigned int __attribute__ ((bitwidth(1069))) uint1069; typedef unsigned int __attribute__ ((bitwidth(1070))) uint1070; typedef unsigned int __attribute__ ((bitwidth(1071))) uint1071; typedef unsigned int __attribute__ ((bitwidth(1072))) uint1072; typedef unsigned int __attribute__ ((bitwidth(1073))) uint1073; typedef unsigned int __attribute__ ((bitwidth(1074))) uint1074; typedef unsigned int __attribute__ ((bitwidth(1075))) uint1075; typedef unsigned int __attribute__ ((bitwidth(1076))) uint1076; typedef unsigned int __attribute__ ((bitwidth(1077))) uint1077; typedef unsigned int __attribute__ ((bitwidth(1078))) uint1078; typedef unsigned int __attribute__ ((bitwidth(1079))) uint1079; typedef unsigned int __attribute__ ((bitwidth(1080))) uint1080; typedef unsigned int __attribute__ ((bitwidth(1081))) uint1081; typedef unsigned int __attribute__ ((bitwidth(1082))) uint1082; typedef unsigned int __attribute__ ((bitwidth(1083))) uint1083; typedef unsigned int __attribute__ ((bitwidth(1084))) uint1084; typedef unsigned int __attribute__ ((bitwidth(1085))) uint1085; typedef unsigned int __attribute__ ((bitwidth(1086))) uint1086; typedef unsigned int __attribute__ ((bitwidth(1087))) uint1087; typedef unsigned int __attribute__ ((bitwidth(1088))) uint1088; typedef unsigned int __attribute__ ((bitwidth(1089))) uint1089; typedef unsigned int __attribute__ ((bitwidth(1090))) uint1090; typedef unsigned int __attribute__ ((bitwidth(1091))) uint1091; typedef unsigned int __attribute__ ((bitwidth(1092))) uint1092; typedef unsigned int __attribute__ ((bitwidth(1093))) uint1093; typedef unsigned int __attribute__ ((bitwidth(1094))) uint1094; typedef unsigned int __attribute__ ((bitwidth(1095))) uint1095; typedef unsigned int __attribute__ ((bitwidth(1096))) uint1096; typedef unsigned int __attribute__ ((bitwidth(1097))) uint1097; typedef unsigned int __attribute__ ((bitwidth(1098))) uint1098; typedef unsigned int __attribute__ ((bitwidth(1099))) uint1099; typedef unsigned int __attribute__ ((bitwidth(1100))) uint1100; typedef unsigned int __attribute__ ((bitwidth(1101))) uint1101; typedef unsigned int __attribute__ ((bitwidth(1102))) uint1102; typedef unsigned int __attribute__ ((bitwidth(1103))) uint1103; typedef unsigned int __attribute__ ((bitwidth(1104))) uint1104; typedef unsigned int __attribute__ ((bitwidth(1105))) uint1105; typedef unsigned int __attribute__ ((bitwidth(1106))) uint1106; typedef unsigned int __attribute__ ((bitwidth(1107))) uint1107; typedef unsigned int __attribute__ ((bitwidth(1108))) uint1108; typedef unsigned int __attribute__ ((bitwidth(1109))) uint1109; typedef unsigned int __attribute__ ((bitwidth(1110))) uint1110; typedef unsigned int __attribute__ ((bitwidth(1111))) uint1111; typedef unsigned int __attribute__ ((bitwidth(1112))) uint1112; typedef unsigned int __attribute__ ((bitwidth(1113))) uint1113; typedef unsigned int __attribute__ ((bitwidth(1114))) uint1114; typedef unsigned int __attribute__ ((bitwidth(1115))) uint1115; typedef unsigned int __attribute__ ((bitwidth(1116))) uint1116; typedef unsigned int __attribute__ ((bitwidth(1117))) uint1117; typedef unsigned int __attribute__ ((bitwidth(1118))) uint1118; typedef unsigned int __attribute__ ((bitwidth(1119))) uint1119; typedef unsigned int __attribute__ ((bitwidth(1120))) uint1120; typedef unsigned int __attribute__ ((bitwidth(1121))) uint1121; typedef unsigned int __attribute__ ((bitwidth(1122))) uint1122; typedef unsigned int __attribute__ ((bitwidth(1123))) uint1123; typedef unsigned int __attribute__ ((bitwidth(1124))) uint1124; typedef unsigned int __attribute__ ((bitwidth(1125))) uint1125; typedef unsigned int __attribute__ ((bitwidth(1126))) uint1126; typedef unsigned int __attribute__ ((bitwidth(1127))) uint1127; typedef unsigned int __attribute__ ((bitwidth(1128))) uint1128; typedef unsigned int __attribute__ ((bitwidth(1129))) uint1129; typedef unsigned int __attribute__ ((bitwidth(1130))) uint1130; typedef unsigned int __attribute__ ((bitwidth(1131))) uint1131; typedef unsigned int __attribute__ ((bitwidth(1132))) uint1132; typedef unsigned int __attribute__ ((bitwidth(1133))) uint1133; typedef unsigned int __attribute__ ((bitwidth(1134))) uint1134; typedef unsigned int __attribute__ ((bitwidth(1135))) uint1135; typedef unsigned int __attribute__ ((bitwidth(1136))) uint1136; typedef unsigned int __attribute__ ((bitwidth(1137))) uint1137; typedef unsigned int __attribute__ ((bitwidth(1138))) uint1138; typedef unsigned int __attribute__ ((bitwidth(1139))) uint1139; typedef unsigned int __attribute__ ((bitwidth(1140))) uint1140; typedef unsigned int __attribute__ ((bitwidth(1141))) uint1141; typedef unsigned int __attribute__ ((bitwidth(1142))) uint1142; typedef unsigned int __attribute__ ((bitwidth(1143))) uint1143; typedef unsigned int __attribute__ ((bitwidth(1144))) uint1144; typedef unsigned int __attribute__ ((bitwidth(1145))) uint1145; typedef unsigned int __attribute__ ((bitwidth(1146))) uint1146; typedef unsigned int __attribute__ ((bitwidth(1147))) uint1147; typedef unsigned int __attribute__ ((bitwidth(1148))) uint1148; typedef unsigned int __attribute__ ((bitwidth(1149))) uint1149; typedef unsigned int __attribute__ ((bitwidth(1150))) uint1150; typedef unsigned int __attribute__ ((bitwidth(1151))) uint1151; typedef unsigned int __attribute__ ((bitwidth(1152))) uint1152; typedef unsigned int __attribute__ ((bitwidth(1153))) uint1153; typedef unsigned int __attribute__ ((bitwidth(1154))) uint1154; typedef unsigned int __attribute__ ((bitwidth(1155))) uint1155; typedef unsigned int __attribute__ ((bitwidth(1156))) uint1156; typedef unsigned int __attribute__ ((bitwidth(1157))) uint1157; typedef unsigned int __attribute__ ((bitwidth(1158))) uint1158; typedef unsigned int __attribute__ ((bitwidth(1159))) uint1159; typedef unsigned int __attribute__ ((bitwidth(1160))) uint1160; typedef unsigned int __attribute__ ((bitwidth(1161))) uint1161; typedef unsigned int __attribute__ ((bitwidth(1162))) uint1162; typedef unsigned int __attribute__ ((bitwidth(1163))) uint1163; typedef unsigned int __attribute__ ((bitwidth(1164))) uint1164; typedef unsigned int __attribute__ ((bitwidth(1165))) uint1165; typedef unsigned int __attribute__ ((bitwidth(1166))) uint1166; typedef unsigned int __attribute__ ((bitwidth(1167))) uint1167; typedef unsigned int __attribute__ ((bitwidth(1168))) uint1168; typedef unsigned int __attribute__ ((bitwidth(1169))) uint1169; typedef unsigned int __attribute__ ((bitwidth(1170))) uint1170; typedef unsigned int __attribute__ ((bitwidth(1171))) uint1171; typedef unsigned int __attribute__ ((bitwidth(1172))) uint1172; typedef unsigned int __attribute__ ((bitwidth(1173))) uint1173; typedef unsigned int __attribute__ ((bitwidth(1174))) uint1174; typedef unsigned int __attribute__ ((bitwidth(1175))) uint1175; typedef unsigned int __attribute__ ((bitwidth(1176))) uint1176; typedef unsigned int __attribute__ ((bitwidth(1177))) uint1177; typedef unsigned int __attribute__ ((bitwidth(1178))) uint1178; typedef unsigned int __attribute__ ((bitwidth(1179))) uint1179; typedef unsigned int __attribute__ ((bitwidth(1180))) uint1180; typedef unsigned int __attribute__ ((bitwidth(1181))) uint1181; typedef unsigned int __attribute__ ((bitwidth(1182))) uint1182; typedef unsigned int __attribute__ ((bitwidth(1183))) uint1183; typedef unsigned int __attribute__ ((bitwidth(1184))) uint1184; typedef unsigned int __attribute__ ((bitwidth(1185))) uint1185; typedef unsigned int __attribute__ ((bitwidth(1186))) uint1186; typedef unsigned int __attribute__ ((bitwidth(1187))) uint1187; typedef unsigned int __attribute__ ((bitwidth(1188))) uint1188; typedef unsigned int __attribute__ ((bitwidth(1189))) uint1189; typedef unsigned int __attribute__ ((bitwidth(1190))) uint1190; typedef unsigned int __attribute__ ((bitwidth(1191))) uint1191; typedef unsigned int __attribute__ ((bitwidth(1192))) uint1192; typedef unsigned int __attribute__ ((bitwidth(1193))) uint1193; typedef unsigned int __attribute__ ((bitwidth(1194))) uint1194; typedef unsigned int __attribute__ ((bitwidth(1195))) uint1195; typedef unsigned int __attribute__ ((bitwidth(1196))) uint1196; typedef unsigned int __attribute__ ((bitwidth(1197))) uint1197; typedef unsigned int __attribute__ ((bitwidth(1198))) uint1198; typedef unsigned int __attribute__ ((bitwidth(1199))) uint1199; typedef unsigned int __attribute__ ((bitwidth(1200))) uint1200; typedef unsigned int __attribute__ ((bitwidth(1201))) uint1201; typedef unsigned int __attribute__ ((bitwidth(1202))) uint1202; typedef unsigned int __attribute__ ((bitwidth(1203))) uint1203; typedef unsigned int __attribute__ ((bitwidth(1204))) uint1204; typedef unsigned int __attribute__ ((bitwidth(1205))) uint1205; typedef unsigned int __attribute__ ((bitwidth(1206))) uint1206; typedef unsigned int __attribute__ ((bitwidth(1207))) uint1207; typedef unsigned int __attribute__ ((bitwidth(1208))) uint1208; typedef unsigned int __attribute__ ((bitwidth(1209))) uint1209; typedef unsigned int __attribute__ ((bitwidth(1210))) uint1210; typedef unsigned int __attribute__ ((bitwidth(1211))) uint1211; typedef unsigned int __attribute__ ((bitwidth(1212))) uint1212; typedef unsigned int __attribute__ ((bitwidth(1213))) uint1213; typedef unsigned int __attribute__ ((bitwidth(1214))) uint1214; typedef unsigned int __attribute__ ((bitwidth(1215))) uint1215; typedef unsigned int __attribute__ ((bitwidth(1216))) uint1216; typedef unsigned int __attribute__ ((bitwidth(1217))) uint1217; typedef unsigned int __attribute__ ((bitwidth(1218))) uint1218; typedef unsigned int __attribute__ ((bitwidth(1219))) uint1219; typedef unsigned int __attribute__ ((bitwidth(1220))) uint1220; typedef unsigned int __attribute__ ((bitwidth(1221))) uint1221; typedef unsigned int __attribute__ ((bitwidth(1222))) uint1222; typedef unsigned int __attribute__ ((bitwidth(1223))) uint1223; typedef unsigned int __attribute__ ((bitwidth(1224))) uint1224; typedef unsigned int __attribute__ ((bitwidth(1225))) uint1225; typedef unsigned int __attribute__ ((bitwidth(1226))) uint1226; typedef unsigned int __attribute__ ((bitwidth(1227))) uint1227; typedef unsigned int __attribute__ ((bitwidth(1228))) uint1228; typedef unsigned int __attribute__ ((bitwidth(1229))) uint1229; typedef unsigned int __attribute__ ((bitwidth(1230))) uint1230; typedef unsigned int __attribute__ ((bitwidth(1231))) uint1231; typedef unsigned int __attribute__ ((bitwidth(1232))) uint1232; typedef unsigned int __attribute__ ((bitwidth(1233))) uint1233; typedef unsigned int __attribute__ ((bitwidth(1234))) uint1234; typedef unsigned int __attribute__ ((bitwidth(1235))) uint1235; typedef unsigned int __attribute__ ((bitwidth(1236))) uint1236; typedef unsigned int __attribute__ ((bitwidth(1237))) uint1237; typedef unsigned int __attribute__ ((bitwidth(1238))) uint1238; typedef unsigned int __attribute__ ((bitwidth(1239))) uint1239; typedef unsigned int __attribute__ ((bitwidth(1240))) uint1240; typedef unsigned int __attribute__ ((bitwidth(1241))) uint1241; typedef unsigned int __attribute__ ((bitwidth(1242))) uint1242; typedef unsigned int __attribute__ ((bitwidth(1243))) uint1243; typedef unsigned int __attribute__ ((bitwidth(1244))) uint1244; typedef unsigned int __attribute__ ((bitwidth(1245))) uint1245; typedef unsigned int __attribute__ ((bitwidth(1246))) uint1246; typedef unsigned int __attribute__ ((bitwidth(1247))) uint1247; typedef unsigned int __attribute__ ((bitwidth(1248))) uint1248; typedef unsigned int __attribute__ ((bitwidth(1249))) uint1249; typedef unsigned int __attribute__ ((bitwidth(1250))) uint1250; typedef unsigned int __attribute__ ((bitwidth(1251))) uint1251; typedef unsigned int __attribute__ ((bitwidth(1252))) uint1252; typedef unsigned int __attribute__ ((bitwidth(1253))) uint1253; typedef unsigned int __attribute__ ((bitwidth(1254))) uint1254; typedef unsigned int __attribute__ ((bitwidth(1255))) uint1255; typedef unsigned int __attribute__ ((bitwidth(1256))) uint1256; typedef unsigned int __attribute__ ((bitwidth(1257))) uint1257; typedef unsigned int __attribute__ ((bitwidth(1258))) uint1258; typedef unsigned int __attribute__ ((bitwidth(1259))) uint1259; typedef unsigned int __attribute__ ((bitwidth(1260))) uint1260; typedef unsigned int __attribute__ ((bitwidth(1261))) uint1261; typedef unsigned int __attribute__ ((bitwidth(1262))) uint1262; typedef unsigned int __attribute__ ((bitwidth(1263))) uint1263; typedef unsigned int __attribute__ ((bitwidth(1264))) uint1264; typedef unsigned int __attribute__ ((bitwidth(1265))) uint1265; typedef unsigned int __attribute__ ((bitwidth(1266))) uint1266; typedef unsigned int __attribute__ ((bitwidth(1267))) uint1267; typedef unsigned int __attribute__ ((bitwidth(1268))) uint1268; typedef unsigned int __attribute__ ((bitwidth(1269))) uint1269; typedef unsigned int __attribute__ ((bitwidth(1270))) uint1270; typedef unsigned int __attribute__ ((bitwidth(1271))) uint1271; typedef unsigned int __attribute__ ((bitwidth(1272))) uint1272; typedef unsigned int __attribute__ ((bitwidth(1273))) uint1273; typedef unsigned int __attribute__ ((bitwidth(1274))) uint1274; typedef unsigned int __attribute__ ((bitwidth(1275))) uint1275; typedef unsigned int __attribute__ ((bitwidth(1276))) uint1276; typedef unsigned int __attribute__ ((bitwidth(1277))) uint1277; typedef unsigned int __attribute__ ((bitwidth(1278))) uint1278; typedef unsigned int __attribute__ ((bitwidth(1279))) uint1279; typedef unsigned int __attribute__ ((bitwidth(1280))) uint1280; typedef unsigned int __attribute__ ((bitwidth(1281))) uint1281; typedef unsigned int __attribute__ ((bitwidth(1282))) uint1282; typedef unsigned int __attribute__ ((bitwidth(1283))) uint1283; typedef unsigned int __attribute__ ((bitwidth(1284))) uint1284; typedef unsigned int __attribute__ ((bitwidth(1285))) uint1285; typedef unsigned int __attribute__ ((bitwidth(1286))) uint1286; typedef unsigned int __attribute__ ((bitwidth(1287))) uint1287; typedef unsigned int __attribute__ ((bitwidth(1288))) uint1288; typedef unsigned int __attribute__ ((bitwidth(1289))) uint1289; typedef unsigned int __attribute__ ((bitwidth(1290))) uint1290; typedef unsigned int __attribute__ ((bitwidth(1291))) uint1291; typedef unsigned int __attribute__ ((bitwidth(1292))) uint1292; typedef unsigned int __attribute__ ((bitwidth(1293))) uint1293; typedef unsigned int __attribute__ ((bitwidth(1294))) uint1294; typedef unsigned int __attribute__ ((bitwidth(1295))) uint1295; typedef unsigned int __attribute__ ((bitwidth(1296))) uint1296; typedef unsigned int __attribute__ ((bitwidth(1297))) uint1297; typedef unsigned int __attribute__ ((bitwidth(1298))) uint1298; typedef unsigned int __attribute__ ((bitwidth(1299))) uint1299; typedef unsigned int __attribute__ ((bitwidth(1300))) uint1300; typedef unsigned int __attribute__ ((bitwidth(1301))) uint1301; typedef unsigned int __attribute__ ((bitwidth(1302))) uint1302; typedef unsigned int __attribute__ ((bitwidth(1303))) uint1303; typedef unsigned int __attribute__ ((bitwidth(1304))) uint1304; typedef unsigned int __attribute__ ((bitwidth(1305))) uint1305; typedef unsigned int __attribute__ ((bitwidth(1306))) uint1306; typedef unsigned int __attribute__ ((bitwidth(1307))) uint1307; typedef unsigned int __attribute__ ((bitwidth(1308))) uint1308; typedef unsigned int __attribute__ ((bitwidth(1309))) uint1309; typedef unsigned int __attribute__ ((bitwidth(1310))) uint1310; typedef unsigned int __attribute__ ((bitwidth(1311))) uint1311; typedef unsigned int __attribute__ ((bitwidth(1312))) uint1312; typedef unsigned int __attribute__ ((bitwidth(1313))) uint1313; typedef unsigned int __attribute__ ((bitwidth(1314))) uint1314; typedef unsigned int __attribute__ ((bitwidth(1315))) uint1315; typedef unsigned int __attribute__ ((bitwidth(1316))) uint1316; typedef unsigned int __attribute__ ((bitwidth(1317))) uint1317; typedef unsigned int __attribute__ ((bitwidth(1318))) uint1318; typedef unsigned int __attribute__ ((bitwidth(1319))) uint1319; typedef unsigned int __attribute__ ((bitwidth(1320))) uint1320; typedef unsigned int __attribute__ ((bitwidth(1321))) uint1321; typedef unsigned int __attribute__ ((bitwidth(1322))) uint1322; typedef unsigned int __attribute__ ((bitwidth(1323))) uint1323; typedef unsigned int __attribute__ ((bitwidth(1324))) uint1324; typedef unsigned int __attribute__ ((bitwidth(1325))) uint1325; typedef unsigned int __attribute__ ((bitwidth(1326))) uint1326; typedef unsigned int __attribute__ ((bitwidth(1327))) uint1327; typedef unsigned int __attribute__ ((bitwidth(1328))) uint1328; typedef unsigned int __attribute__ ((bitwidth(1329))) uint1329; typedef unsigned int __attribute__ ((bitwidth(1330))) uint1330; typedef unsigned int __attribute__ ((bitwidth(1331))) uint1331; typedef unsigned int __attribute__ ((bitwidth(1332))) uint1332; typedef unsigned int __attribute__ ((bitwidth(1333))) uint1333; typedef unsigned int __attribute__ ((bitwidth(1334))) uint1334; typedef unsigned int __attribute__ ((bitwidth(1335))) uint1335; typedef unsigned int __attribute__ ((bitwidth(1336))) uint1336; typedef unsigned int __attribute__ ((bitwidth(1337))) uint1337; typedef unsigned int __attribute__ ((bitwidth(1338))) uint1338; typedef unsigned int __attribute__ ((bitwidth(1339))) uint1339; typedef unsigned int __attribute__ ((bitwidth(1340))) uint1340; typedef unsigned int __attribute__ ((bitwidth(1341))) uint1341; typedef unsigned int __attribute__ ((bitwidth(1342))) uint1342; typedef unsigned int __attribute__ ((bitwidth(1343))) uint1343; typedef unsigned int __attribute__ ((bitwidth(1344))) uint1344; typedef unsigned int __attribute__ ((bitwidth(1345))) uint1345; typedef unsigned int __attribute__ ((bitwidth(1346))) uint1346; typedef unsigned int __attribute__ ((bitwidth(1347))) uint1347; typedef unsigned int __attribute__ ((bitwidth(1348))) uint1348; typedef unsigned int __attribute__ ((bitwidth(1349))) uint1349; typedef unsigned int __attribute__ ((bitwidth(1350))) uint1350; typedef unsigned int __attribute__ ((bitwidth(1351))) uint1351; typedef unsigned int __attribute__ ((bitwidth(1352))) uint1352; typedef unsigned int __attribute__ ((bitwidth(1353))) uint1353; typedef unsigned int __attribute__ ((bitwidth(1354))) uint1354; typedef unsigned int __attribute__ ((bitwidth(1355))) uint1355; typedef unsigned int __attribute__ ((bitwidth(1356))) uint1356; typedef unsigned int __attribute__ ((bitwidth(1357))) uint1357; typedef unsigned int __attribute__ ((bitwidth(1358))) uint1358; typedef unsigned int __attribute__ ((bitwidth(1359))) uint1359; typedef unsigned int __attribute__ ((bitwidth(1360))) uint1360; typedef unsigned int __attribute__ ((bitwidth(1361))) uint1361; typedef unsigned int __attribute__ ((bitwidth(1362))) uint1362; typedef unsigned int __attribute__ ((bitwidth(1363))) uint1363; typedef unsigned int __attribute__ ((bitwidth(1364))) uint1364; typedef unsigned int __attribute__ ((bitwidth(1365))) uint1365; typedef unsigned int __attribute__ ((bitwidth(1366))) uint1366; typedef unsigned int __attribute__ ((bitwidth(1367))) uint1367; typedef unsigned int __attribute__ ((bitwidth(1368))) uint1368; typedef unsigned int __attribute__ ((bitwidth(1369))) uint1369; typedef unsigned int __attribute__ ((bitwidth(1370))) uint1370; typedef unsigned int __attribute__ ((bitwidth(1371))) uint1371; typedef unsigned int __attribute__ ((bitwidth(1372))) uint1372; typedef unsigned int __attribute__ ((bitwidth(1373))) uint1373; typedef unsigned int __attribute__ ((bitwidth(1374))) uint1374; typedef unsigned int __attribute__ ((bitwidth(1375))) uint1375; typedef unsigned int __attribute__ ((bitwidth(1376))) uint1376; typedef unsigned int __attribute__ ((bitwidth(1377))) uint1377; typedef unsigned int __attribute__ ((bitwidth(1378))) uint1378; typedef unsigned int __attribute__ ((bitwidth(1379))) uint1379; typedef unsigned int __attribute__ ((bitwidth(1380))) uint1380; typedef unsigned int __attribute__ ((bitwidth(1381))) uint1381; typedef unsigned int __attribute__ ((bitwidth(1382))) uint1382; typedef unsigned int __attribute__ ((bitwidth(1383))) uint1383; typedef unsigned int __attribute__ ((bitwidth(1384))) uint1384; typedef unsigned int __attribute__ ((bitwidth(1385))) uint1385; typedef unsigned int __attribute__ ((bitwidth(1386))) uint1386; typedef unsigned int __attribute__ ((bitwidth(1387))) uint1387; typedef unsigned int __attribute__ ((bitwidth(1388))) uint1388; typedef unsigned int __attribute__ ((bitwidth(1389))) uint1389; typedef unsigned int __attribute__ ((bitwidth(1390))) uint1390; typedef unsigned int __attribute__ ((bitwidth(1391))) uint1391; typedef unsigned int __attribute__ ((bitwidth(1392))) uint1392; typedef unsigned int __attribute__ ((bitwidth(1393))) uint1393; typedef unsigned int __attribute__ ((bitwidth(1394))) uint1394; typedef unsigned int __attribute__ ((bitwidth(1395))) uint1395; typedef unsigned int __attribute__ ((bitwidth(1396))) uint1396; typedef unsigned int __attribute__ ((bitwidth(1397))) uint1397; typedef unsigned int __attribute__ ((bitwidth(1398))) uint1398; typedef unsigned int __attribute__ ((bitwidth(1399))) uint1399; typedef unsigned int __attribute__ ((bitwidth(1400))) uint1400; typedef unsigned int __attribute__ ((bitwidth(1401))) uint1401; typedef unsigned int __attribute__ ((bitwidth(1402))) uint1402; typedef unsigned int __attribute__ ((bitwidth(1403))) uint1403; typedef unsigned int __attribute__ ((bitwidth(1404))) uint1404; typedef unsigned int __attribute__ ((bitwidth(1405))) uint1405; typedef unsigned int __attribute__ ((bitwidth(1406))) uint1406; typedef unsigned int __attribute__ ((bitwidth(1407))) uint1407; typedef unsigned int __attribute__ ((bitwidth(1408))) uint1408; typedef unsigned int __attribute__ ((bitwidth(1409))) uint1409; typedef unsigned int __attribute__ ((bitwidth(1410))) uint1410; typedef unsigned int __attribute__ ((bitwidth(1411))) uint1411; typedef unsigned int __attribute__ ((bitwidth(1412))) uint1412; typedef unsigned int __attribute__ ((bitwidth(1413))) uint1413; typedef unsigned int __attribute__ ((bitwidth(1414))) uint1414; typedef unsigned int __attribute__ ((bitwidth(1415))) uint1415; typedef unsigned int __attribute__ ((bitwidth(1416))) uint1416; typedef unsigned int __attribute__ ((bitwidth(1417))) uint1417; typedef unsigned int __attribute__ ((bitwidth(1418))) uint1418; typedef unsigned int __attribute__ ((bitwidth(1419))) uint1419; typedef unsigned int __attribute__ ((bitwidth(1420))) uint1420; typedef unsigned int __attribute__ ((bitwidth(1421))) uint1421; typedef unsigned int __attribute__ ((bitwidth(1422))) uint1422; typedef unsigned int __attribute__ ((bitwidth(1423))) uint1423; typedef unsigned int __attribute__ ((bitwidth(1424))) uint1424; typedef unsigned int __attribute__ ((bitwidth(1425))) uint1425; typedef unsigned int __attribute__ ((bitwidth(1426))) uint1426; typedef unsigned int __attribute__ ((bitwidth(1427))) uint1427; typedef unsigned int __attribute__ ((bitwidth(1428))) uint1428; typedef unsigned int __attribute__ ((bitwidth(1429))) uint1429; typedef unsigned int __attribute__ ((bitwidth(1430))) uint1430; typedef unsigned int __attribute__ ((bitwidth(1431))) uint1431; typedef unsigned int __attribute__ ((bitwidth(1432))) uint1432; typedef unsigned int __attribute__ ((bitwidth(1433))) uint1433; typedef unsigned int __attribute__ ((bitwidth(1434))) uint1434; typedef unsigned int __attribute__ ((bitwidth(1435))) uint1435; typedef unsigned int __attribute__ ((bitwidth(1436))) uint1436; typedef unsigned int __attribute__ ((bitwidth(1437))) uint1437; typedef unsigned int __attribute__ ((bitwidth(1438))) uint1438; typedef unsigned int __attribute__ ((bitwidth(1439))) uint1439; typedef unsigned int __attribute__ ((bitwidth(1440))) uint1440; typedef unsigned int __attribute__ ((bitwidth(1441))) uint1441; typedef unsigned int __attribute__ ((bitwidth(1442))) uint1442; typedef unsigned int __attribute__ ((bitwidth(1443))) uint1443; typedef unsigned int __attribute__ ((bitwidth(1444))) uint1444; typedef unsigned int __attribute__ ((bitwidth(1445))) uint1445; typedef unsigned int __attribute__ ((bitwidth(1446))) uint1446; typedef unsigned int __attribute__ ((bitwidth(1447))) uint1447; typedef unsigned int __attribute__ ((bitwidth(1448))) uint1448; typedef unsigned int __attribute__ ((bitwidth(1449))) uint1449; typedef unsigned int __attribute__ ((bitwidth(1450))) uint1450; typedef unsigned int __attribute__ ((bitwidth(1451))) uint1451; typedef unsigned int __attribute__ ((bitwidth(1452))) uint1452; typedef unsigned int __attribute__ ((bitwidth(1453))) uint1453; typedef unsigned int __attribute__ ((bitwidth(1454))) uint1454; typedef unsigned int __attribute__ ((bitwidth(1455))) uint1455; typedef unsigned int __attribute__ ((bitwidth(1456))) uint1456; typedef unsigned int __attribute__ ((bitwidth(1457))) uint1457; typedef unsigned int __attribute__ ((bitwidth(1458))) uint1458; typedef unsigned int __attribute__ ((bitwidth(1459))) uint1459; typedef unsigned int __attribute__ ((bitwidth(1460))) uint1460; typedef unsigned int __attribute__ ((bitwidth(1461))) uint1461; typedef unsigned int __attribute__ ((bitwidth(1462))) uint1462; typedef unsigned int __attribute__ ((bitwidth(1463))) uint1463; typedef unsigned int __attribute__ ((bitwidth(1464))) uint1464; typedef unsigned int __attribute__ ((bitwidth(1465))) uint1465; typedef unsigned int __attribute__ ((bitwidth(1466))) uint1466; typedef unsigned int __attribute__ ((bitwidth(1467))) uint1467; typedef unsigned int __attribute__ ((bitwidth(1468))) uint1468; typedef unsigned int __attribute__ ((bitwidth(1469))) uint1469; typedef unsigned int __attribute__ ((bitwidth(1470))) uint1470; typedef unsigned int __attribute__ ((bitwidth(1471))) uint1471; typedef unsigned int __attribute__ ((bitwidth(1472))) uint1472; typedef unsigned int __attribute__ ((bitwidth(1473))) uint1473; typedef unsigned int __attribute__ ((bitwidth(1474))) uint1474; typedef unsigned int __attribute__ ((bitwidth(1475))) uint1475; typedef unsigned int __attribute__ ((bitwidth(1476))) uint1476; typedef unsigned int __attribute__ ((bitwidth(1477))) uint1477; typedef unsigned int __attribute__ ((bitwidth(1478))) uint1478; typedef unsigned int __attribute__ ((bitwidth(1479))) uint1479; typedef unsigned int __attribute__ ((bitwidth(1480))) uint1480; typedef unsigned int __attribute__ ((bitwidth(1481))) uint1481; typedef unsigned int __attribute__ ((bitwidth(1482))) uint1482; typedef unsigned int __attribute__ ((bitwidth(1483))) uint1483; typedef unsigned int __attribute__ ((bitwidth(1484))) uint1484; typedef unsigned int __attribute__ ((bitwidth(1485))) uint1485; typedef unsigned int __attribute__ ((bitwidth(1486))) uint1486; typedef unsigned int __attribute__ ((bitwidth(1487))) uint1487; typedef unsigned int __attribute__ ((bitwidth(1488))) uint1488; typedef unsigned int __attribute__ ((bitwidth(1489))) uint1489; typedef unsigned int __attribute__ ((bitwidth(1490))) uint1490; typedef unsigned int __attribute__ ((bitwidth(1491))) uint1491; typedef unsigned int __attribute__ ((bitwidth(1492))) uint1492; typedef unsigned int __attribute__ ((bitwidth(1493))) uint1493; typedef unsigned int __attribute__ ((bitwidth(1494))) uint1494; typedef unsigned int __attribute__ ((bitwidth(1495))) uint1495; typedef unsigned int __attribute__ ((bitwidth(1496))) uint1496; typedef unsigned int __attribute__ ((bitwidth(1497))) uint1497; typedef unsigned int __attribute__ ((bitwidth(1498))) uint1498; typedef unsigned int __attribute__ ((bitwidth(1499))) uint1499; typedef unsigned int __attribute__ ((bitwidth(1500))) uint1500; typedef unsigned int __attribute__ ((bitwidth(1501))) uint1501; typedef unsigned int __attribute__ ((bitwidth(1502))) uint1502; typedef unsigned int __attribute__ ((bitwidth(1503))) uint1503; typedef unsigned int __attribute__ ((bitwidth(1504))) uint1504; typedef unsigned int __attribute__ ((bitwidth(1505))) uint1505; typedef unsigned int __attribute__ ((bitwidth(1506))) uint1506; typedef unsigned int __attribute__ ((bitwidth(1507))) uint1507; typedef unsigned int __attribute__ ((bitwidth(1508))) uint1508; typedef unsigned int __attribute__ ((bitwidth(1509))) uint1509; typedef unsigned int __attribute__ ((bitwidth(1510))) uint1510; typedef unsigned int __attribute__ ((bitwidth(1511))) uint1511; typedef unsigned int __attribute__ ((bitwidth(1512))) uint1512; typedef unsigned int __attribute__ ((bitwidth(1513))) uint1513; typedef unsigned int __attribute__ ((bitwidth(1514))) uint1514; typedef unsigned int __attribute__ ((bitwidth(1515))) uint1515; typedef unsigned int __attribute__ ((bitwidth(1516))) uint1516; typedef unsigned int __attribute__ ((bitwidth(1517))) uint1517; typedef unsigned int __attribute__ ((bitwidth(1518))) uint1518; typedef unsigned int __attribute__ ((bitwidth(1519))) uint1519; typedef unsigned int __attribute__ ((bitwidth(1520))) uint1520; typedef unsigned int __attribute__ ((bitwidth(1521))) uint1521; typedef unsigned int __attribute__ ((bitwidth(1522))) uint1522; typedef unsigned int __attribute__ ((bitwidth(1523))) uint1523; typedef unsigned int __attribute__ ((bitwidth(1524))) uint1524; typedef unsigned int __attribute__ ((bitwidth(1525))) uint1525; typedef unsigned int __attribute__ ((bitwidth(1526))) uint1526; typedef unsigned int __attribute__ ((bitwidth(1527))) uint1527; typedef unsigned int __attribute__ ((bitwidth(1528))) uint1528; typedef unsigned int __attribute__ ((bitwidth(1529))) uint1529; typedef unsigned int __attribute__ ((bitwidth(1530))) uint1530; typedef unsigned int __attribute__ ((bitwidth(1531))) uint1531; typedef unsigned int __attribute__ ((bitwidth(1532))) uint1532; typedef unsigned int __attribute__ ((bitwidth(1533))) uint1533; typedef unsigned int __attribute__ ((bitwidth(1534))) uint1534; typedef unsigned int __attribute__ ((bitwidth(1535))) uint1535; typedef unsigned int __attribute__ ((bitwidth(1536))) uint1536; typedef unsigned int __attribute__ ((bitwidth(1537))) uint1537; typedef unsigned int __attribute__ ((bitwidth(1538))) uint1538; typedef unsigned int __attribute__ ((bitwidth(1539))) uint1539; typedef unsigned int __attribute__ ((bitwidth(1540))) uint1540; typedef unsigned int __attribute__ ((bitwidth(1541))) uint1541; typedef unsigned int __attribute__ ((bitwidth(1542))) uint1542; typedef unsigned int __attribute__ ((bitwidth(1543))) uint1543; typedef unsigned int __attribute__ ((bitwidth(1544))) uint1544; typedef unsigned int __attribute__ ((bitwidth(1545))) uint1545; typedef unsigned int __attribute__ ((bitwidth(1546))) uint1546; typedef unsigned int __attribute__ ((bitwidth(1547))) uint1547; typedef unsigned int __attribute__ ((bitwidth(1548))) uint1548; typedef unsigned int __attribute__ ((bitwidth(1549))) uint1549; typedef unsigned int __attribute__ ((bitwidth(1550))) uint1550; typedef unsigned int __attribute__ ((bitwidth(1551))) uint1551; typedef unsigned int __attribute__ ((bitwidth(1552))) uint1552; typedef unsigned int __attribute__ ((bitwidth(1553))) uint1553; typedef unsigned int __attribute__ ((bitwidth(1554))) uint1554; typedef unsigned int __attribute__ ((bitwidth(1555))) uint1555; typedef unsigned int __attribute__ ((bitwidth(1556))) uint1556; typedef unsigned int __attribute__ ((bitwidth(1557))) uint1557; typedef unsigned int __attribute__ ((bitwidth(1558))) uint1558; typedef unsigned int __attribute__ ((bitwidth(1559))) uint1559; typedef unsigned int __attribute__ ((bitwidth(1560))) uint1560; typedef unsigned int __attribute__ ((bitwidth(1561))) uint1561; typedef unsigned int __attribute__ ((bitwidth(1562))) uint1562; typedef unsigned int __attribute__ ((bitwidth(1563))) uint1563; typedef unsigned int __attribute__ ((bitwidth(1564))) uint1564; typedef unsigned int __attribute__ ((bitwidth(1565))) uint1565; typedef unsigned int __attribute__ ((bitwidth(1566))) uint1566; typedef unsigned int __attribute__ ((bitwidth(1567))) uint1567; typedef unsigned int __attribute__ ((bitwidth(1568))) uint1568; typedef unsigned int __attribute__ ((bitwidth(1569))) uint1569; typedef unsigned int __attribute__ ((bitwidth(1570))) uint1570; typedef unsigned int __attribute__ ((bitwidth(1571))) uint1571; typedef unsigned int __attribute__ ((bitwidth(1572))) uint1572; typedef unsigned int __attribute__ ((bitwidth(1573))) uint1573; typedef unsigned int __attribute__ ((bitwidth(1574))) uint1574; typedef unsigned int __attribute__ ((bitwidth(1575))) uint1575; typedef unsigned int __attribute__ ((bitwidth(1576))) uint1576; typedef unsigned int __attribute__ ((bitwidth(1577))) uint1577; typedef unsigned int __attribute__ ((bitwidth(1578))) uint1578; typedef unsigned int __attribute__ ((bitwidth(1579))) uint1579; typedef unsigned int __attribute__ ((bitwidth(1580))) uint1580; typedef unsigned int __attribute__ ((bitwidth(1581))) uint1581; typedef unsigned int __attribute__ ((bitwidth(1582))) uint1582; typedef unsigned int __attribute__ ((bitwidth(1583))) uint1583; typedef unsigned int __attribute__ ((bitwidth(1584))) uint1584; typedef unsigned int __attribute__ ((bitwidth(1585))) uint1585; typedef unsigned int __attribute__ ((bitwidth(1586))) uint1586; typedef unsigned int __attribute__ ((bitwidth(1587))) uint1587; typedef unsigned int __attribute__ ((bitwidth(1588))) uint1588; typedef unsigned int __attribute__ ((bitwidth(1589))) uint1589; typedef unsigned int __attribute__ ((bitwidth(1590))) uint1590; typedef unsigned int __attribute__ ((bitwidth(1591))) uint1591; typedef unsigned int __attribute__ ((bitwidth(1592))) uint1592; typedef unsigned int __attribute__ ((bitwidth(1593))) uint1593; typedef unsigned int __attribute__ ((bitwidth(1594))) uint1594; typedef unsigned int __attribute__ ((bitwidth(1595))) uint1595; typedef unsigned int __attribute__ ((bitwidth(1596))) uint1596; typedef unsigned int __attribute__ ((bitwidth(1597))) uint1597; typedef unsigned int __attribute__ ((bitwidth(1598))) uint1598; typedef unsigned int __attribute__ ((bitwidth(1599))) uint1599; typedef unsigned int __attribute__ ((bitwidth(1600))) uint1600; typedef unsigned int __attribute__ ((bitwidth(1601))) uint1601; typedef unsigned int __attribute__ ((bitwidth(1602))) uint1602; typedef unsigned int __attribute__ ((bitwidth(1603))) uint1603; typedef unsigned int __attribute__ ((bitwidth(1604))) uint1604; typedef unsigned int __attribute__ ((bitwidth(1605))) uint1605; typedef unsigned int __attribute__ ((bitwidth(1606))) uint1606; typedef unsigned int __attribute__ ((bitwidth(1607))) uint1607; typedef unsigned int __attribute__ ((bitwidth(1608))) uint1608; typedef unsigned int __attribute__ ((bitwidth(1609))) uint1609; typedef unsigned int __attribute__ ((bitwidth(1610))) uint1610; typedef unsigned int __attribute__ ((bitwidth(1611))) uint1611; typedef unsigned int __attribute__ ((bitwidth(1612))) uint1612; typedef unsigned int __attribute__ ((bitwidth(1613))) uint1613; typedef unsigned int __attribute__ ((bitwidth(1614))) uint1614; typedef unsigned int __attribute__ ((bitwidth(1615))) uint1615; typedef unsigned int __attribute__ ((bitwidth(1616))) uint1616; typedef unsigned int __attribute__ ((bitwidth(1617))) uint1617; typedef unsigned int __attribute__ ((bitwidth(1618))) uint1618; typedef unsigned int __attribute__ ((bitwidth(1619))) uint1619; typedef unsigned int __attribute__ ((bitwidth(1620))) uint1620; typedef unsigned int __attribute__ ((bitwidth(1621))) uint1621; typedef unsigned int __attribute__ ((bitwidth(1622))) uint1622; typedef unsigned int __attribute__ ((bitwidth(1623))) uint1623; typedef unsigned int __attribute__ ((bitwidth(1624))) uint1624; typedef unsigned int __attribute__ ((bitwidth(1625))) uint1625; typedef unsigned int __attribute__ ((bitwidth(1626))) uint1626; typedef unsigned int __attribute__ ((bitwidth(1627))) uint1627; typedef unsigned int __attribute__ ((bitwidth(1628))) uint1628; typedef unsigned int __attribute__ ((bitwidth(1629))) uint1629; typedef unsigned int __attribute__ ((bitwidth(1630))) uint1630; typedef unsigned int __attribute__ ((bitwidth(1631))) uint1631; typedef unsigned int __attribute__ ((bitwidth(1632))) uint1632; typedef unsigned int __attribute__ ((bitwidth(1633))) uint1633; typedef unsigned int __attribute__ ((bitwidth(1634))) uint1634; typedef unsigned int __attribute__ ((bitwidth(1635))) uint1635; typedef unsigned int __attribute__ ((bitwidth(1636))) uint1636; typedef unsigned int __attribute__ ((bitwidth(1637))) uint1637; typedef unsigned int __attribute__ ((bitwidth(1638))) uint1638; typedef unsigned int __attribute__ ((bitwidth(1639))) uint1639; typedef unsigned int __attribute__ ((bitwidth(1640))) uint1640; typedef unsigned int __attribute__ ((bitwidth(1641))) uint1641; typedef unsigned int __attribute__ ((bitwidth(1642))) uint1642; typedef unsigned int __attribute__ ((bitwidth(1643))) uint1643; typedef unsigned int __attribute__ ((bitwidth(1644))) uint1644; typedef unsigned int __attribute__ ((bitwidth(1645))) uint1645; typedef unsigned int __attribute__ ((bitwidth(1646))) uint1646; typedef unsigned int __attribute__ ((bitwidth(1647))) uint1647; typedef unsigned int __attribute__ ((bitwidth(1648))) uint1648; typedef unsigned int __attribute__ ((bitwidth(1649))) uint1649; typedef unsigned int __attribute__ ((bitwidth(1650))) uint1650; typedef unsigned int __attribute__ ((bitwidth(1651))) uint1651; typedef unsigned int __attribute__ ((bitwidth(1652))) uint1652; typedef unsigned int __attribute__ ((bitwidth(1653))) uint1653; typedef unsigned int __attribute__ ((bitwidth(1654))) uint1654; typedef unsigned int __attribute__ ((bitwidth(1655))) uint1655; typedef unsigned int __attribute__ ((bitwidth(1656))) uint1656; typedef unsigned int __attribute__ ((bitwidth(1657))) uint1657; typedef unsigned int __attribute__ ((bitwidth(1658))) uint1658; typedef unsigned int __attribute__ ((bitwidth(1659))) uint1659; typedef unsigned int __attribute__ ((bitwidth(1660))) uint1660; typedef unsigned int __attribute__ ((bitwidth(1661))) uint1661; typedef unsigned int __attribute__ ((bitwidth(1662))) uint1662; typedef unsigned int __attribute__ ((bitwidth(1663))) uint1663; typedef unsigned int __attribute__ ((bitwidth(1664))) uint1664; typedef unsigned int __attribute__ ((bitwidth(1665))) uint1665; typedef unsigned int __attribute__ ((bitwidth(1666))) uint1666; typedef unsigned int __attribute__ ((bitwidth(1667))) uint1667; typedef unsigned int __attribute__ ((bitwidth(1668))) uint1668; typedef unsigned int __attribute__ ((bitwidth(1669))) uint1669; typedef unsigned int __attribute__ ((bitwidth(1670))) uint1670; typedef unsigned int __attribute__ ((bitwidth(1671))) uint1671; typedef unsigned int __attribute__ ((bitwidth(1672))) uint1672; typedef unsigned int __attribute__ ((bitwidth(1673))) uint1673; typedef unsigned int __attribute__ ((bitwidth(1674))) uint1674; typedef unsigned int __attribute__ ((bitwidth(1675))) uint1675; typedef unsigned int __attribute__ ((bitwidth(1676))) uint1676; typedef unsigned int __attribute__ ((bitwidth(1677))) uint1677; typedef unsigned int __attribute__ ((bitwidth(1678))) uint1678; typedef unsigned int __attribute__ ((bitwidth(1679))) uint1679; typedef unsigned int __attribute__ ((bitwidth(1680))) uint1680; typedef unsigned int __attribute__ ((bitwidth(1681))) uint1681; typedef unsigned int __attribute__ ((bitwidth(1682))) uint1682; typedef unsigned int __attribute__ ((bitwidth(1683))) uint1683; typedef unsigned int __attribute__ ((bitwidth(1684))) uint1684; typedef unsigned int __attribute__ ((bitwidth(1685))) uint1685; typedef unsigned int __attribute__ ((bitwidth(1686))) uint1686; typedef unsigned int __attribute__ ((bitwidth(1687))) uint1687; typedef unsigned int __attribute__ ((bitwidth(1688))) uint1688; typedef unsigned int __attribute__ ((bitwidth(1689))) uint1689; typedef unsigned int __attribute__ ((bitwidth(1690))) uint1690; typedef unsigned int __attribute__ ((bitwidth(1691))) uint1691; typedef unsigned int __attribute__ ((bitwidth(1692))) uint1692; typedef unsigned int __attribute__ ((bitwidth(1693))) uint1693; typedef unsigned int __attribute__ ((bitwidth(1694))) uint1694; typedef unsigned int __attribute__ ((bitwidth(1695))) uint1695; typedef unsigned int __attribute__ ((bitwidth(1696))) uint1696; typedef unsigned int __attribute__ ((bitwidth(1697))) uint1697; typedef unsigned int __attribute__ ((bitwidth(1698))) uint1698; typedef unsigned int __attribute__ ((bitwidth(1699))) uint1699; typedef unsigned int __attribute__ ((bitwidth(1700))) uint1700; typedef unsigned int __attribute__ ((bitwidth(1701))) uint1701; typedef unsigned int __attribute__ ((bitwidth(1702))) uint1702; typedef unsigned int __attribute__ ((bitwidth(1703))) uint1703; typedef unsigned int __attribute__ ((bitwidth(1704))) uint1704; typedef unsigned int __attribute__ ((bitwidth(1705))) uint1705; typedef unsigned int __attribute__ ((bitwidth(1706))) uint1706; typedef unsigned int __attribute__ ((bitwidth(1707))) uint1707; typedef unsigned int __attribute__ ((bitwidth(1708))) uint1708; typedef unsigned int __attribute__ ((bitwidth(1709))) uint1709; typedef unsigned int __attribute__ ((bitwidth(1710))) uint1710; typedef unsigned int __attribute__ ((bitwidth(1711))) uint1711; typedef unsigned int __attribute__ ((bitwidth(1712))) uint1712; typedef unsigned int __attribute__ ((bitwidth(1713))) uint1713; typedef unsigned int __attribute__ ((bitwidth(1714))) uint1714; typedef unsigned int __attribute__ ((bitwidth(1715))) uint1715; typedef unsigned int __attribute__ ((bitwidth(1716))) uint1716; typedef unsigned int __attribute__ ((bitwidth(1717))) uint1717; typedef unsigned int __attribute__ ((bitwidth(1718))) uint1718; typedef unsigned int __attribute__ ((bitwidth(1719))) uint1719; typedef unsigned int __attribute__ ((bitwidth(1720))) uint1720; typedef unsigned int __attribute__ ((bitwidth(1721))) uint1721; typedef unsigned int __attribute__ ((bitwidth(1722))) uint1722; typedef unsigned int __attribute__ ((bitwidth(1723))) uint1723; typedef unsigned int __attribute__ ((bitwidth(1724))) uint1724; typedef unsigned int __attribute__ ((bitwidth(1725))) uint1725; typedef unsigned int __attribute__ ((bitwidth(1726))) uint1726; typedef unsigned int __attribute__ ((bitwidth(1727))) uint1727; typedef unsigned int __attribute__ ((bitwidth(1728))) uint1728; typedef unsigned int __attribute__ ((bitwidth(1729))) uint1729; typedef unsigned int __attribute__ ((bitwidth(1730))) uint1730; typedef unsigned int __attribute__ ((bitwidth(1731))) uint1731; typedef unsigned int __attribute__ ((bitwidth(1732))) uint1732; typedef unsigned int __attribute__ ((bitwidth(1733))) uint1733; typedef unsigned int __attribute__ ((bitwidth(1734))) uint1734; typedef unsigned int __attribute__ ((bitwidth(1735))) uint1735; typedef unsigned int __attribute__ ((bitwidth(1736))) uint1736; typedef unsigned int __attribute__ ((bitwidth(1737))) uint1737; typedef unsigned int __attribute__ ((bitwidth(1738))) uint1738; typedef unsigned int __attribute__ ((bitwidth(1739))) uint1739; typedef unsigned int __attribute__ ((bitwidth(1740))) uint1740; typedef unsigned int __attribute__ ((bitwidth(1741))) uint1741; typedef unsigned int __attribute__ ((bitwidth(1742))) uint1742; typedef unsigned int __attribute__ ((bitwidth(1743))) uint1743; typedef unsigned int __attribute__ ((bitwidth(1744))) uint1744; typedef unsigned int __attribute__ ((bitwidth(1745))) uint1745; typedef unsigned int __attribute__ ((bitwidth(1746))) uint1746; typedef unsigned int __attribute__ ((bitwidth(1747))) uint1747; typedef unsigned int __attribute__ ((bitwidth(1748))) uint1748; typedef unsigned int __attribute__ ((bitwidth(1749))) uint1749; typedef unsigned int __attribute__ ((bitwidth(1750))) uint1750; typedef unsigned int __attribute__ ((bitwidth(1751))) uint1751; typedef unsigned int __attribute__ ((bitwidth(1752))) uint1752; typedef unsigned int __attribute__ ((bitwidth(1753))) uint1753; typedef unsigned int __attribute__ ((bitwidth(1754))) uint1754; typedef unsigned int __attribute__ ((bitwidth(1755))) uint1755; typedef unsigned int __attribute__ ((bitwidth(1756))) uint1756; typedef unsigned int __attribute__ ((bitwidth(1757))) uint1757; typedef unsigned int __attribute__ ((bitwidth(1758))) uint1758; typedef unsigned int __attribute__ ((bitwidth(1759))) uint1759; typedef unsigned int __attribute__ ((bitwidth(1760))) uint1760; typedef unsigned int __attribute__ ((bitwidth(1761))) uint1761; typedef unsigned int __attribute__ ((bitwidth(1762))) uint1762; typedef unsigned int __attribute__ ((bitwidth(1763))) uint1763; typedef unsigned int __attribute__ ((bitwidth(1764))) uint1764; typedef unsigned int __attribute__ ((bitwidth(1765))) uint1765; typedef unsigned int __attribute__ ((bitwidth(1766))) uint1766; typedef unsigned int __attribute__ ((bitwidth(1767))) uint1767; typedef unsigned int __attribute__ ((bitwidth(1768))) uint1768; typedef unsigned int __attribute__ ((bitwidth(1769))) uint1769; typedef unsigned int __attribute__ ((bitwidth(1770))) uint1770; typedef unsigned int __attribute__ ((bitwidth(1771))) uint1771; typedef unsigned int __attribute__ ((bitwidth(1772))) uint1772; typedef unsigned int __attribute__ ((bitwidth(1773))) uint1773; typedef unsigned int __attribute__ ((bitwidth(1774))) uint1774; typedef unsigned int __attribute__ ((bitwidth(1775))) uint1775; typedef unsigned int __attribute__ ((bitwidth(1776))) uint1776; typedef unsigned int __attribute__ ((bitwidth(1777))) uint1777; typedef unsigned int __attribute__ ((bitwidth(1778))) uint1778; typedef unsigned int __attribute__ ((bitwidth(1779))) uint1779; typedef unsigned int __attribute__ ((bitwidth(1780))) uint1780; typedef unsigned int __attribute__ ((bitwidth(1781))) uint1781; typedef unsigned int __attribute__ ((bitwidth(1782))) uint1782; typedef unsigned int __attribute__ ((bitwidth(1783))) uint1783; typedef unsigned int __attribute__ ((bitwidth(1784))) uint1784; typedef unsigned int __attribute__ ((bitwidth(1785))) uint1785; typedef unsigned int __attribute__ ((bitwidth(1786))) uint1786; typedef unsigned int __attribute__ ((bitwidth(1787))) uint1787; typedef unsigned int __attribute__ ((bitwidth(1788))) uint1788; typedef unsigned int __attribute__ ((bitwidth(1789))) uint1789; typedef unsigned int __attribute__ ((bitwidth(1790))) uint1790; typedef unsigned int __attribute__ ((bitwidth(1791))) uint1791; typedef unsigned int __attribute__ ((bitwidth(1792))) uint1792; typedef unsigned int __attribute__ ((bitwidth(1793))) uint1793; typedef unsigned int __attribute__ ((bitwidth(1794))) uint1794; typedef unsigned int __attribute__ ((bitwidth(1795))) uint1795; typedef unsigned int __attribute__ ((bitwidth(1796))) uint1796; typedef unsigned int __attribute__ ((bitwidth(1797))) uint1797; typedef unsigned int __attribute__ ((bitwidth(1798))) uint1798; typedef unsigned int __attribute__ ((bitwidth(1799))) uint1799; typedef unsigned int __attribute__ ((bitwidth(1800))) uint1800; typedef unsigned int __attribute__ ((bitwidth(1801))) uint1801; typedef unsigned int __attribute__ ((bitwidth(1802))) uint1802; typedef unsigned int __attribute__ ((bitwidth(1803))) uint1803; typedef unsigned int __attribute__ ((bitwidth(1804))) uint1804; typedef unsigned int __attribute__ ((bitwidth(1805))) uint1805; typedef unsigned int __attribute__ ((bitwidth(1806))) uint1806; typedef unsigned int __attribute__ ((bitwidth(1807))) uint1807; typedef unsigned int __attribute__ ((bitwidth(1808))) uint1808; typedef unsigned int __attribute__ ((bitwidth(1809))) uint1809; typedef unsigned int __attribute__ ((bitwidth(1810))) uint1810; typedef unsigned int __attribute__ ((bitwidth(1811))) uint1811; typedef unsigned int __attribute__ ((bitwidth(1812))) uint1812; typedef unsigned int __attribute__ ((bitwidth(1813))) uint1813; typedef unsigned int __attribute__ ((bitwidth(1814))) uint1814; typedef unsigned int __attribute__ ((bitwidth(1815))) uint1815; typedef unsigned int __attribute__ ((bitwidth(1816))) uint1816; typedef unsigned int __attribute__ ((bitwidth(1817))) uint1817; typedef unsigned int __attribute__ ((bitwidth(1818))) uint1818; typedef unsigned int __attribute__ ((bitwidth(1819))) uint1819; typedef unsigned int __attribute__ ((bitwidth(1820))) uint1820; typedef unsigned int __attribute__ ((bitwidth(1821))) uint1821; typedef unsigned int __attribute__ ((bitwidth(1822))) uint1822; typedef unsigned int __attribute__ ((bitwidth(1823))) uint1823; typedef unsigned int __attribute__ ((bitwidth(1824))) uint1824; typedef unsigned int __attribute__ ((bitwidth(1825))) uint1825; typedef unsigned int __attribute__ ((bitwidth(1826))) uint1826; typedef unsigned int __attribute__ ((bitwidth(1827))) uint1827; typedef unsigned int __attribute__ ((bitwidth(1828))) uint1828; typedef unsigned int __attribute__ ((bitwidth(1829))) uint1829; typedef unsigned int __attribute__ ((bitwidth(1830))) uint1830; typedef unsigned int __attribute__ ((bitwidth(1831))) uint1831; typedef unsigned int __attribute__ ((bitwidth(1832))) uint1832; typedef unsigned int __attribute__ ((bitwidth(1833))) uint1833; typedef unsigned int __attribute__ ((bitwidth(1834))) uint1834; typedef unsigned int __attribute__ ((bitwidth(1835))) uint1835; typedef unsigned int __attribute__ ((bitwidth(1836))) uint1836; typedef unsigned int __attribute__ ((bitwidth(1837))) uint1837; typedef unsigned int __attribute__ ((bitwidth(1838))) uint1838; typedef unsigned int __attribute__ ((bitwidth(1839))) uint1839; typedef unsigned int __attribute__ ((bitwidth(1840))) uint1840; typedef unsigned int __attribute__ ((bitwidth(1841))) uint1841; typedef unsigned int __attribute__ ((bitwidth(1842))) uint1842; typedef unsigned int __attribute__ ((bitwidth(1843))) uint1843; typedef unsigned int __attribute__ ((bitwidth(1844))) uint1844; typedef unsigned int __attribute__ ((bitwidth(1845))) uint1845; typedef unsigned int __attribute__ ((bitwidth(1846))) uint1846; typedef unsigned int __attribute__ ((bitwidth(1847))) uint1847; typedef unsigned int __attribute__ ((bitwidth(1848))) uint1848; typedef unsigned int __attribute__ ((bitwidth(1849))) uint1849; typedef unsigned int __attribute__ ((bitwidth(1850))) uint1850; typedef unsigned int __attribute__ ((bitwidth(1851))) uint1851; typedef unsigned int __attribute__ ((bitwidth(1852))) uint1852; typedef unsigned int __attribute__ ((bitwidth(1853))) uint1853; typedef unsigned int __attribute__ ((bitwidth(1854))) uint1854; typedef unsigned int __attribute__ ((bitwidth(1855))) uint1855; typedef unsigned int __attribute__ ((bitwidth(1856))) uint1856; typedef unsigned int __attribute__ ((bitwidth(1857))) uint1857; typedef unsigned int __attribute__ ((bitwidth(1858))) uint1858; typedef unsigned int __attribute__ ((bitwidth(1859))) uint1859; typedef unsigned int __attribute__ ((bitwidth(1860))) uint1860; typedef unsigned int __attribute__ ((bitwidth(1861))) uint1861; typedef unsigned int __attribute__ ((bitwidth(1862))) uint1862; typedef unsigned int __attribute__ ((bitwidth(1863))) uint1863; typedef unsigned int __attribute__ ((bitwidth(1864))) uint1864; typedef unsigned int __attribute__ ((bitwidth(1865))) uint1865; typedef unsigned int __attribute__ ((bitwidth(1866))) uint1866; typedef unsigned int __attribute__ ((bitwidth(1867))) uint1867; typedef unsigned int __attribute__ ((bitwidth(1868))) uint1868; typedef unsigned int __attribute__ ((bitwidth(1869))) uint1869; typedef unsigned int __attribute__ ((bitwidth(1870))) uint1870; typedef unsigned int __attribute__ ((bitwidth(1871))) uint1871; typedef unsigned int __attribute__ ((bitwidth(1872))) uint1872; typedef unsigned int __attribute__ ((bitwidth(1873))) uint1873; typedef unsigned int __attribute__ ((bitwidth(1874))) uint1874; typedef unsigned int __attribute__ ((bitwidth(1875))) uint1875; typedef unsigned int __attribute__ ((bitwidth(1876))) uint1876; typedef unsigned int __attribute__ ((bitwidth(1877))) uint1877; typedef unsigned int __attribute__ ((bitwidth(1878))) uint1878; typedef unsigned int __attribute__ ((bitwidth(1879))) uint1879; typedef unsigned int __attribute__ ((bitwidth(1880))) uint1880; typedef unsigned int __attribute__ ((bitwidth(1881))) uint1881; typedef unsigned int __attribute__ ((bitwidth(1882))) uint1882; typedef unsigned int __attribute__ ((bitwidth(1883))) uint1883; typedef unsigned int __attribute__ ((bitwidth(1884))) uint1884; typedef unsigned int __attribute__ ((bitwidth(1885))) uint1885; typedef unsigned int __attribute__ ((bitwidth(1886))) uint1886; typedef unsigned int __attribute__ ((bitwidth(1887))) uint1887; typedef unsigned int __attribute__ ((bitwidth(1888))) uint1888; typedef unsigned int __attribute__ ((bitwidth(1889))) uint1889; typedef unsigned int __attribute__ ((bitwidth(1890))) uint1890; typedef unsigned int __attribute__ ((bitwidth(1891))) uint1891; typedef unsigned int __attribute__ ((bitwidth(1892))) uint1892; typedef unsigned int __attribute__ ((bitwidth(1893))) uint1893; typedef unsigned int __attribute__ ((bitwidth(1894))) uint1894; typedef unsigned int __attribute__ ((bitwidth(1895))) uint1895; typedef unsigned int __attribute__ ((bitwidth(1896))) uint1896; typedef unsigned int __attribute__ ((bitwidth(1897))) uint1897; typedef unsigned int __attribute__ ((bitwidth(1898))) uint1898; typedef unsigned int __attribute__ ((bitwidth(1899))) uint1899; typedef unsigned int __attribute__ ((bitwidth(1900))) uint1900; typedef unsigned int __attribute__ ((bitwidth(1901))) uint1901; typedef unsigned int __attribute__ ((bitwidth(1902))) uint1902; typedef unsigned int __attribute__ ((bitwidth(1903))) uint1903; typedef unsigned int __attribute__ ((bitwidth(1904))) uint1904; typedef unsigned int __attribute__ ((bitwidth(1905))) uint1905; typedef unsigned int __attribute__ ((bitwidth(1906))) uint1906; typedef unsigned int __attribute__ ((bitwidth(1907))) uint1907; typedef unsigned int __attribute__ ((bitwidth(1908))) uint1908; typedef unsigned int __attribute__ ((bitwidth(1909))) uint1909; typedef unsigned int __attribute__ ((bitwidth(1910))) uint1910; typedef unsigned int __attribute__ ((bitwidth(1911))) uint1911; typedef unsigned int __attribute__ ((bitwidth(1912))) uint1912; typedef unsigned int __attribute__ ((bitwidth(1913))) uint1913; typedef unsigned int __attribute__ ((bitwidth(1914))) uint1914; typedef unsigned int __attribute__ ((bitwidth(1915))) uint1915; typedef unsigned int __attribute__ ((bitwidth(1916))) uint1916; typedef unsigned int __attribute__ ((bitwidth(1917))) uint1917; typedef unsigned int __attribute__ ((bitwidth(1918))) uint1918; typedef unsigned int __attribute__ ((bitwidth(1919))) uint1919; typedef unsigned int __attribute__ ((bitwidth(1920))) uint1920; typedef unsigned int __attribute__ ((bitwidth(1921))) uint1921; typedef unsigned int __attribute__ ((bitwidth(1922))) uint1922; typedef unsigned int __attribute__ ((bitwidth(1923))) uint1923; typedef unsigned int __attribute__ ((bitwidth(1924))) uint1924; typedef unsigned int __attribute__ ((bitwidth(1925))) uint1925; typedef unsigned int __attribute__ ((bitwidth(1926))) uint1926; typedef unsigned int __attribute__ ((bitwidth(1927))) uint1927; typedef unsigned int __attribute__ ((bitwidth(1928))) uint1928; typedef unsigned int __attribute__ ((bitwidth(1929))) uint1929; typedef unsigned int __attribute__ ((bitwidth(1930))) uint1930; typedef unsigned int __attribute__ ((bitwidth(1931))) uint1931; typedef unsigned int __attribute__ ((bitwidth(1932))) uint1932; typedef unsigned int __attribute__ ((bitwidth(1933))) uint1933; typedef unsigned int __attribute__ ((bitwidth(1934))) uint1934; typedef unsigned int __attribute__ ((bitwidth(1935))) uint1935; typedef unsigned int __attribute__ ((bitwidth(1936))) uint1936; typedef unsigned int __attribute__ ((bitwidth(1937))) uint1937; typedef unsigned int __attribute__ ((bitwidth(1938))) uint1938; typedef unsigned int __attribute__ ((bitwidth(1939))) uint1939; typedef unsigned int __attribute__ ((bitwidth(1940))) uint1940; typedef unsigned int __attribute__ ((bitwidth(1941))) uint1941; typedef unsigned int __attribute__ ((bitwidth(1942))) uint1942; typedef unsigned int __attribute__ ((bitwidth(1943))) uint1943; typedef unsigned int __attribute__ ((bitwidth(1944))) uint1944; typedef unsigned int __attribute__ ((bitwidth(1945))) uint1945; typedef unsigned int __attribute__ ((bitwidth(1946))) uint1946; typedef unsigned int __attribute__ ((bitwidth(1947))) uint1947; typedef unsigned int __attribute__ ((bitwidth(1948))) uint1948; typedef unsigned int __attribute__ ((bitwidth(1949))) uint1949; typedef unsigned int __attribute__ ((bitwidth(1950))) uint1950; typedef unsigned int __attribute__ ((bitwidth(1951))) uint1951; typedef unsigned int __attribute__ ((bitwidth(1952))) uint1952; typedef unsigned int __attribute__ ((bitwidth(1953))) uint1953; typedef unsigned int __attribute__ ((bitwidth(1954))) uint1954; typedef unsigned int __attribute__ ((bitwidth(1955))) uint1955; typedef unsigned int __attribute__ ((bitwidth(1956))) uint1956; typedef unsigned int __attribute__ ((bitwidth(1957))) uint1957; typedef unsigned int __attribute__ ((bitwidth(1958))) uint1958; typedef unsigned int __attribute__ ((bitwidth(1959))) uint1959; typedef unsigned int __attribute__ ((bitwidth(1960))) uint1960; typedef unsigned int __attribute__ ((bitwidth(1961))) uint1961; typedef unsigned int __attribute__ ((bitwidth(1962))) uint1962; typedef unsigned int __attribute__ ((bitwidth(1963))) uint1963; typedef unsigned int __attribute__ ((bitwidth(1964))) uint1964; typedef unsigned int __attribute__ ((bitwidth(1965))) uint1965; typedef unsigned int __attribute__ ((bitwidth(1966))) uint1966; typedef unsigned int __attribute__ ((bitwidth(1967))) uint1967; typedef unsigned int __attribute__ ((bitwidth(1968))) uint1968; typedef unsigned int __attribute__ ((bitwidth(1969))) uint1969; typedef unsigned int __attribute__ ((bitwidth(1970))) uint1970; typedef unsigned int __attribute__ ((bitwidth(1971))) uint1971; typedef unsigned int __attribute__ ((bitwidth(1972))) uint1972; typedef unsigned int __attribute__ ((bitwidth(1973))) uint1973; typedef unsigned int __attribute__ ((bitwidth(1974))) uint1974; typedef unsigned int __attribute__ ((bitwidth(1975))) uint1975; typedef unsigned int __attribute__ ((bitwidth(1976))) uint1976; typedef unsigned int __attribute__ ((bitwidth(1977))) uint1977; typedef unsigned int __attribute__ ((bitwidth(1978))) uint1978; typedef unsigned int __attribute__ ((bitwidth(1979))) uint1979; typedef unsigned int __attribute__ ((bitwidth(1980))) uint1980; typedef unsigned int __attribute__ ((bitwidth(1981))) uint1981; typedef unsigned int __attribute__ ((bitwidth(1982))) uint1982; typedef unsigned int __attribute__ ((bitwidth(1983))) uint1983; typedef unsigned int __attribute__ ((bitwidth(1984))) uint1984; typedef unsigned int __attribute__ ((bitwidth(1985))) uint1985; typedef unsigned int __attribute__ ((bitwidth(1986))) uint1986; typedef unsigned int __attribute__ ((bitwidth(1987))) uint1987; typedef unsigned int __attribute__ ((bitwidth(1988))) uint1988; typedef unsigned int __attribute__ ((bitwidth(1989))) uint1989; typedef unsigned int __attribute__ ((bitwidth(1990))) uint1990; typedef unsigned int __attribute__ ((bitwidth(1991))) uint1991; typedef unsigned int __attribute__ ((bitwidth(1992))) uint1992; typedef unsigned int __attribute__ ((bitwidth(1993))) uint1993; typedef unsigned int __attribute__ ((bitwidth(1994))) uint1994; typedef unsigned int __attribute__ ((bitwidth(1995))) uint1995; typedef unsigned int __attribute__ ((bitwidth(1996))) uint1996; typedef unsigned int __attribute__ ((bitwidth(1997))) uint1997; typedef unsigned int __attribute__ ((bitwidth(1998))) uint1998; typedef unsigned int __attribute__ ((bitwidth(1999))) uint1999; typedef unsigned int __attribute__ ((bitwidth(2000))) uint2000; typedef unsigned int __attribute__ ((bitwidth(2001))) uint2001; typedef unsigned int __attribute__ ((bitwidth(2002))) uint2002; typedef unsigned int __attribute__ ((bitwidth(2003))) uint2003; typedef unsigned int __attribute__ ((bitwidth(2004))) uint2004; typedef unsigned int __attribute__ ((bitwidth(2005))) uint2005; typedef unsigned int __attribute__ ((bitwidth(2006))) uint2006; typedef unsigned int __attribute__ ((bitwidth(2007))) uint2007; typedef unsigned int __attribute__ ((bitwidth(2008))) uint2008; typedef unsigned int __attribute__ ((bitwidth(2009))) uint2009; typedef unsigned int __attribute__ ((bitwidth(2010))) uint2010; typedef unsigned int __attribute__ ((bitwidth(2011))) uint2011; typedef unsigned int __attribute__ ((bitwidth(2012))) uint2012; typedef unsigned int __attribute__ ((bitwidth(2013))) uint2013; typedef unsigned int __attribute__ ((bitwidth(2014))) uint2014; typedef unsigned int __attribute__ ((bitwidth(2015))) uint2015; typedef unsigned int __attribute__ ((bitwidth(2016))) uint2016; typedef unsigned int __attribute__ ((bitwidth(2017))) uint2017; typedef unsigned int __attribute__ ((bitwidth(2018))) uint2018; typedef unsigned int __attribute__ ((bitwidth(2019))) uint2019; typedef unsigned int __attribute__ ((bitwidth(2020))) uint2020; typedef unsigned int __attribute__ ((bitwidth(2021))) uint2021; typedef unsigned int __attribute__ ((bitwidth(2022))) uint2022; typedef unsigned int __attribute__ ((bitwidth(2023))) uint2023; typedef unsigned int __attribute__ ((bitwidth(2024))) uint2024; typedef unsigned int __attribute__ ((bitwidth(2025))) uint2025; typedef unsigned int __attribute__ ((bitwidth(2026))) uint2026; typedef unsigned int __attribute__ ((bitwidth(2027))) uint2027; typedef unsigned int __attribute__ ((bitwidth(2028))) uint2028; typedef unsigned int __attribute__ ((bitwidth(2029))) uint2029; typedef unsigned int __attribute__ ((bitwidth(2030))) uint2030; typedef unsigned int __attribute__ ((bitwidth(2031))) uint2031; typedef unsigned int __attribute__ ((bitwidth(2032))) uint2032; typedef unsigned int __attribute__ ((bitwidth(2033))) uint2033; typedef unsigned int __attribute__ ((bitwidth(2034))) uint2034; typedef unsigned int __attribute__ ((bitwidth(2035))) uint2035; typedef unsigned int __attribute__ ((bitwidth(2036))) uint2036; typedef unsigned int __attribute__ ((bitwidth(2037))) uint2037; typedef unsigned int __attribute__ ((bitwidth(2038))) uint2038; typedef unsigned int __attribute__ ((bitwidth(2039))) uint2039; typedef unsigned int __attribute__ ((bitwidth(2040))) uint2040; typedef unsigned int __attribute__ ((bitwidth(2041))) uint2041; typedef unsigned int __attribute__ ((bitwidth(2042))) uint2042; typedef unsigned int __attribute__ ((bitwidth(2043))) uint2043; typedef unsigned int __attribute__ ((bitwidth(2044))) uint2044; typedef unsigned int __attribute__ ((bitwidth(2045))) uint2045; typedef unsigned int __attribute__ ((bitwidth(2046))) uint2046; typedef unsigned int __attribute__ ((bitwidth(2047))) uint2047; typedef unsigned int __attribute__ ((bitwidth(2048))) uint2048; # 110 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/common/technology/autopilot\\etc/autopilot_dt.h" 2 # 131 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/common/technology/autopilot\\etc/autopilot_dt.h" typedef int __attribute__ ((bitwidth(64))) int64; typedef unsigned int __attribute__ ((bitwidth(64))) uint64; # 58 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/common/technology/autopilot/etc/autopilot_apint.h" 2 # 1 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/common/technology/autopilot\\etc/autopilot_ssdm_bits.h" 1 /* autopilot_ssdm_bits.h */ /* #- (c) Copyright 2011-2015 Xilinx, Inc. All rights reserved. #- #- This file contains confidential and proprietary information #- of Xilinx, Inc. and is protected under U.S. and #- international copyright and other intellectual property #- laws. #- #- DISCLAIMER #- This disclaimer is not a license and does not grant any #- rights to the materials distributed herewith. Except as #- otherwise provided in a valid license issued to you by #- Xilinx, and to the maximum extent permitted by applicable #- law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND #- WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES #- AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING #- BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON- #- INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and #- (2) Xilinx shall not be liable (whether in contract or tort, #- including negligence, or under any other theory of #- liability) for any loss or damage of any kind or nature #- related to, arising under or in connection with these #- materials, including for any direct, or any indirect, #- special, incidental, or consequential loss or damage #- (including loss of data, profits, goodwill, or any type of #- loss or damage suffered as a result of any action brought #- by a third party) even if such damage or loss was #- reasonably foreseeable or Xilinx had been advised of the #- possibility of the same. #- #- CRITICAL APPLICATIONS #- Xilinx products are not designed or intended to be fail- #- safe, or for use in any application requiring fail-safe #- performance, such as life-support or safety devices or #- systems, Class III medical devices, nuclear facilities, #- applications related to the deployment of airbags, or any #- other applications that could lead to death, personal #- injury, or severe property or environmental damage #- (individually and collectively, "Critical #- Applications"). Customer assumes the sole risk and #- liability of any use of Xilinx products in Critical #- Applications, subject only to applicable laws and #- regulations governing limitations on product liability. #- #- THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS #- PART OF THIS FILE AT ALL TIMES. #- ************************************************************************ * * $Id$ */ # 98 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/common/technology/autopilot\\etc/autopilot_ssdm_bits.h" /* -- Concatination ----------------*/ # 108 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/common/technology/autopilot\\etc/autopilot_ssdm_bits.h" /* -- Bit get/set ----------------*/ # 129 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/common/technology/autopilot\\etc/autopilot_ssdm_bits.h" /* -- Part get/set ----------------*/ /* GetRange: Notice that the order of the range indices comply with SystemC standards. */ # 143 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/common/technology/autopilot\\etc/autopilot_ssdm_bits.h" /* SetRange: Notice that the order of the range indices comply with SystemC standards. */ # 156 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/common/technology/autopilot\\etc/autopilot_ssdm_bits.h" /* -- Reduce operations ----------------*/ # 192 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/common/technology/autopilot\\etc/autopilot_ssdm_bits.h" /* -- String-Integer conversions ----------------*/ # 59 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/common/technology/autopilot/etc/autopilot_apint.h" 2 # 85 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/common/technology/autopilot/etc/autopilot_apint.h" /************************************************/ # 78 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/common/technology/autopilot\\ap_cint.h" 2 # 3 "./duc.h" 2 # 1 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\stdlib.h" 1 3 /** * This file has no copyright assigned and is placed in the Public Domain. * This file is part of the w64 mingw-runtime package. * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ # 1 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\_mingw.h" 1 3 /** * This file has no copyright assigned and is placed in the Public Domain. * This file is part of the w64 mingw-runtime package. * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ # 9 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\stdlib.h" 2 3 # 1 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/include\\limits.h" 1 3 4 /*===---- limits.h - Standard header for integer sizes --------------------===*\ * * Copyright (c) 2009 Chris Lattner * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * \*===----------------------------------------------------------------------===*/ /* The system's limits.h may, in turn, try to #include_next GCC's limits.h. Avert this #include_next madness. */ /* System headers include a number of constants from POSIX in <limits.h>. Include it if we're hosted. */ # 1 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\limits.h" 1 3 4 /** * This file has no copyright assigned and is placed in the Public Domain. * This file is part of the w64 mingw-runtime package. * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ # 1 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\_mingw.h" 1 3 4 /** * This file has no copyright assigned and is placed in the Public Domain. * This file is part of the w64 mingw-runtime package. * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ # 6 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\limits.h" 2 3 4 /* * File system limits * * NOTE: Apparently the actual size of PATH_MAX is 260, but a space is * required for the NUL. TODO: Test? * NOTE: PATH_MAX is the POSIX equivalent for Microsoft's MAX_PATH; the two * are semantically identical, with a limit of 259 characters for the * path name, plus one for a terminating NUL, for a total of 260. */ # 38 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/include\\limits.h" 2 3 4 /* Many system headers try to "help us out" by defining these. No really, we know how big each datatype is. */ # 60 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/include\\limits.h" 3 4 /* C90/99 5.2.4.2.1 */ # 90 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/include\\limits.h" 3 4 /* C99 5.2.4.2.1: Added long long. */ # 102 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/include\\limits.h" 3 4 /* LONG_LONG_MIN/LONG_LONG_MAX/ULONG_LONG_MAX are a GNU extension. It's too bad that we don't have something like #pragma poison that could be used to deprecate a macro - the code should just use LLONG_MAX and friends. */ # 10 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\stdlib.h" 2 3 #pragma pack(push,_CRT_PACKING) # 36 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\stdlib.h" 3 typedef int ( *_onexit_t)(void); # 46 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\stdlib.h" 3 typedef struct _div_t { int quot; int rem; } div_t; typedef struct _ldiv_t { long quot; long rem; } ldiv_t; #pragma pack(4) typedef struct { unsigned char ld[10]; } _LDOUBLE; #pragma pack() typedef struct { double x; } _CRT_DOUBLE; typedef struct { float f; } _CRT_FLOAT; typedef struct { long double x; } _LONGDOUBLE; #pragma pack(4) typedef struct { unsigned char ld12[12]; } _LDBL12; #pragma pack() # 100 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\stdlib.h" 3 extern int * __imp___mb_cur_max; extern int* __imp___mbcur_max; # 132 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\stdlib.h" 3 typedef void ( *_purecall_handler)(void); __attribute__ ((__dllimport__)) _purecall_handler _set_purecall_handler(_purecall_handler _Handler); __attribute__ ((__dllimport__)) _purecall_handler _get_purecall_handler(void); typedef void ( *_invalid_parameter_handler)(const wchar_t *,const wchar_t *,const wchar_t *,unsigned int,uintptr_t); _invalid_parameter_handler _set_invalid_parameter_handler(_invalid_parameter_handler _Handler); _invalid_parameter_handler _get_invalid_parameter_handler(void); __attribute__ ((__dllimport__)) extern int * _errno(void); errno_t _set_errno(int _Value); errno_t _get_errno(int *_Value); __attribute__ ((__dllimport__)) unsigned long * __doserrno(void); errno_t _set_doserrno(unsigned long _Value); errno_t _get_doserrno(unsigned long *_Value); extern __attribute__ ((__dllimport__)) char *_sys_errlist[1]; extern __attribute__ ((__dllimport__)) int _sys_nerr; # 172 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\stdlib.h" 3 extern int * __imp___argc; extern char *** __imp___argv; extern wchar_t *** __imp___wargv; # 200 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\stdlib.h" 3 extern char *** __imp__environ; # 209 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\stdlib.h" 3 extern wchar_t *** __imp__wenviron; # 218 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\stdlib.h" 3 extern char ** __imp__pgmptr; # 227 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\stdlib.h" 3 extern wchar_t ** __imp__wpgmptr; errno_t _get_pgmptr(char **_Value); errno_t _get_wpgmptr(wchar_t **_Value); extern int * __imp__fmode; __attribute__ ((__dllimport__)) errno_t _set_fmode(int _Mode); __attribute__ ((__dllimport__)) errno_t _get_fmode(int *_PMode); extern unsigned int * __imp__osplatform; # 257 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\stdlib.h" 3 extern unsigned int * __imp__osver; # 266 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\stdlib.h" 3 extern unsigned int * __imp__winver; # 275 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\stdlib.h" 3 extern unsigned int * __imp__winmajor; # 284 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\stdlib.h" 3 extern unsigned int * __imp__winminor; errno_t _get_osplatform(unsigned int *_Value); errno_t _get_osver(unsigned int *_Value); errno_t _get_winver(unsigned int *_Value); errno_t _get_winmajor(unsigned int *_Value); errno_t _get_winminor(unsigned int *_Value); # 307 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\stdlib.h" 3 void __attribute__ ((__nothrow__)) exit(int _Code) __attribute__ ((__noreturn__)); __attribute__ ((__dllimport__)) void __attribute__ ((__nothrow__)) _exit(int _Code) __attribute__ ((__noreturn__)); /* C99 function name */ void _Exit(int) __attribute__ ((__noreturn__)); # 321 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\stdlib.h" 3 void __attribute__((noreturn)) abort(void); __attribute__ ((__dllimport__)) unsigned int _set_abort_behavior(unsigned int _Flags,unsigned int _Mask); int abs(int _X); long labs(long _X); __extension__ long long _abs64(long long); int atexit(void ( *)(void)); double atof(const char *_String); double _atof_l(const char *_String,_locale_t _Locale); int atoi(const char *_Str); __attribute__ ((__dllimport__)) int _atoi_l(const char *_Str,_locale_t _Locale); long atol(const char *_Str); __attribute__ ((__dllimport__)) long _atol_l(const char *_Str,_locale_t _Locale); void * bsearch(const void *_Key,const void *_Base,size_t _NumOfElements,size_t _SizeOfElements,int ( *_PtFuncCompare)(const void *,const void *)); void qsort(void *_Base,size_t _NumOfElements,size_t _SizeOfElements,int ( *_PtFuncCompare)(const void *,const void *)); unsigned short _byteswap_ushort(unsigned short _Short); /*unsigned long __cdecl _byteswap_ulong (unsigned long _Long); */ __extension__ unsigned long long _byteswap_uint64(unsigned long long _Int64); div_t div(int _Numerator,int _Denominator); char * getenv(const char *_VarName) ; __attribute__ ((__dllimport__)) char * _itoa(int _Value,char *_Dest,int _Radix); __extension__ __attribute__ ((__dllimport__)) char * _i64toa(long long _Val,char *_DstBuf,int _Radix) ; __extension__ __attribute__ ((__dllimport__)) char * _ui64toa(unsigned long long _Val,char *_DstBuf,int _Radix) ; __extension__ __attribute__ ((__dllimport__)) long long _atoi64(const char *_String); __extension__ __attribute__ ((__dllimport__)) long long _atoi64_l(const char *_String,_locale_t _Locale); __extension__ __attribute__ ((__dllimport__)) long long _strtoi64(const char *_String,char **_EndPtr,int _Radix); __extension__ __attribute__ ((__dllimport__)) long long _strtoi64_l(const char *_String,char **_EndPtr,int _Radix,_locale_t _Locale); __extension__ __attribute__ ((__dllimport__)) unsigned long long _strtoui64(const char *_String,char **_EndPtr,int _Radix); __extension__ __attribute__ ((__dllimport__)) unsigned long long _strtoui64_l(const char *_String,char **_EndPtr,int _Radix,_locale_t _Locale); ldiv_t ldiv(long _Numerator,long _Denominator); __attribute__ ((__dllimport__)) char * _ltoa(long _Value,char *_Dest,int _Radix) ; int mblen(const char *_Ch,size_t _MaxCount); __attribute__ ((__dllimport__)) int _mblen_l(const char *_Ch,size_t _MaxCount,_locale_t _Locale); __attribute__ ((__dllimport__)) size_t _mbstrlen(const char *_Str); __attribute__ ((__dllimport__)) size_t _mbstrlen_l(const char *_Str,_locale_t _Locale); __attribute__ ((__dllimport__)) size_t _mbstrnlen(const char *_Str,size_t _MaxCount); __attribute__ ((__dllimport__)) size_t _mbstrnlen_l(const char *_Str,size_t _MaxCount,_locale_t _Locale); int mbtowc(wchar_t * __restrict__ _DstCh,const char * __restrict__ _SrcCh,size_t _SrcSizeInBytes); __attribute__ ((__dllimport__)) int _mbtowc_l(wchar_t * __restrict__ _DstCh,const char * __restrict__ _SrcCh,size_t _SrcSizeInBytes,_locale_t _Locale); size_t mbstowcs(wchar_t * __restrict__ _Dest,const char * __restrict__ _Source,size_t _MaxCount); __attribute__ ((__dllimport__)) size_t _mbstowcs_l(wchar_t * __restrict__ _Dest,const char * __restrict__ _Source,size_t _MaxCount,_locale_t _Locale); int rand(void); __attribute__ ((__dllimport__)) int _set_error_mode(int _Mode); void srand(unsigned int _Seed); double __attribute__ ((__nothrow__)) strtod(const char * __restrict__ _Str,char ** __restrict__ _EndPtr); float __attribute__ ((__nothrow__)) strtof(const char * __restrict__ nptr, char ** __restrict__ endptr); long double __attribute__ ((__nothrow__)) strtold(const char * __restrict__ , char ** __restrict__ ); /* libmingwex.a provides a c99-compliant strtod() exported as __strtod() */ extern double __attribute__ ((__nothrow__)) __strtod (const char * __restrict__ , char ** __restrict__); # 400 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\stdlib.h" 3 float __mingw_strtof (const char * __restrict__, char ** __restrict__); long double __mingw_strtold(const char * __restrict__, char ** __restrict__); __attribute__ ((__dllimport__)) double _strtod_l(const char * __restrict__ _Str,char ** __restrict__ _EndPtr,_locale_t _Locale); long strtol(const char * __restrict__ _Str,char ** __restrict__ _EndPtr,int _Radix); __attribute__ ((__dllimport__)) long _strtol_l(const char * __restrict__ _Str,char ** __restrict__ _EndPtr,int _Radix,_locale_t _Locale); unsigned long strtoul(const char * __restrict__ _Str,char ** __restrict__ _EndPtr,int _Radix); __attribute__ ((__dllimport__)) unsigned long _strtoul_l(const char * __restrict__ _Str,char ** __restrict__ _EndPtr,int _Radix,_locale_t _Locale); int system(const char *_Command); __attribute__ ((__dllimport__)) char * _ultoa(unsigned long _Value,char *_Dest,int _Radix) ; int wctomb(char *_MbCh,wchar_t _WCh) ; __attribute__ ((__dllimport__)) int _wctomb_l(char *_MbCh,wchar_t _WCh,_locale_t _Locale) ; size_t wcstombs(char * __restrict__ _Dest,const wchar_t * __restrict__ _Source,size_t _MaxCount) ; __attribute__ ((__dllimport__)) size_t _wcstombs_l(char * __restrict__ _Dest,const wchar_t * __restrict__ _Source,size_t _MaxCount,_locale_t _Locale) ; void * calloc(size_t _NumOfElements,size_t _SizeOfElements); void free(void *_Memory); void * malloc(size_t _Size); void * realloc(void *_Memory,size_t _NewSize); __attribute__ ((__dllimport__)) void * _recalloc(void *_Memory,size_t _Count,size_t _Size); /* Make sure that X86intrin.h doesn't produce here collisions. */ __attribute__ ((__dllimport__)) void _aligned_free(void *_Memory); __attribute__ ((__dllimport__)) void * _aligned_malloc(size_t _Size,size_t _Alignment); __attribute__ ((__dllimport__)) void * _aligned_offset_malloc(size_t _Size,size_t _Alignment,size_t _Offset); __attribute__ ((__dllimport__)) void * _aligned_realloc(void *_Memory,size_t _Size,size_t _Alignment); __attribute__ ((__dllimport__)) void * _aligned_recalloc(void *_Memory,size_t _Count,size_t _Size,size_t _Alignment); __attribute__ ((__dllimport__)) void * _aligned_offset_realloc(void *_Memory,size_t _Size,size_t _Alignment,size_t _Offset); __attribute__ ((__dllimport__)) void * _aligned_offset_recalloc(void *_Memory,size_t _Count,size_t _Size,size_t _Alignment,size_t _Offset); __attribute__ ((__dllimport__)) wchar_t * _itow(int _Value,wchar_t *_Dest,int _Radix) ; __attribute__ ((__dllimport__)) wchar_t * _ltow(long _Value,wchar_t *_Dest,int _Radix) ; __attribute__ ((__dllimport__)) wchar_t * _ultow(unsigned long _Value,wchar_t *_Dest,int _Radix) ; double wcstod(const wchar_t * __restrict__ _Str,wchar_t ** __restrict__ _EndPtr); float wcstof(const wchar_t * __restrict__ nptr, wchar_t ** __restrict__ endptr); float wcstof( const wchar_t * __restrict__, wchar_t ** __restrict__); long double wcstold(const wchar_t * __restrict__, wchar_t ** __restrict__); __attribute__ ((__dllimport__)) double _wcstod_l(const wchar_t * __restrict__ _Str,wchar_t ** __restrict__ _EndPtr,_locale_t _Locale); long wcstol(const wchar_t * __restrict__ _Str,wchar_t ** __restrict__ _EndPtr,int _Radix); __attribute__ ((__dllimport__)) long _wcstol_l(const wchar_t * __restrict__ _Str,wchar_t ** __restrict__ _EndPtr,int _Radix,_locale_t _Locale); unsigned long wcstoul(const wchar_t * __restrict__ _Str,wchar_t ** __restrict__ _EndPtr,int _Radix); __attribute__ ((__dllimport__)) unsigned long _wcstoul_l(const wchar_t * __restrict__ _Str,wchar_t ** __restrict__ _EndPtr,int _Radix,_locale_t _Locale); __attribute__ ((__dllimport__)) wchar_t * _wgetenv(const wchar_t *_VarName) ; __attribute__ ((__dllimport__)) int _wsystem(const wchar_t *_Command); __attribute__ ((__dllimport__)) double _wtof(const wchar_t *_Str); __attribute__ ((__dllimport__)) double _wtof_l(const wchar_t *_Str,_locale_t _Locale); __attribute__ ((__dllimport__)) int _wtoi(const wchar_t *_Str); __attribute__ ((__dllimport__)) int _wtoi_l(const wchar_t *_Str,_locale_t _Locale); __attribute__ ((__dllimport__)) long _wtol(const wchar_t *_Str); __attribute__ ((__dllimport__)) long _wtol_l(const wchar_t *_Str,_locale_t _Locale); __extension__ __attribute__ ((__dllimport__)) wchar_t * _i64tow(long long _Val,wchar_t *_DstBuf,int _Radix) ; __extension__ __attribute__ ((__dllimport__)) wchar_t * _ui64tow(unsigned long long _Val,wchar_t *_DstBuf,int _Radix) ; __extension__ __attribute__ ((__dllimport__)) long long _wtoi64(const wchar_t *_Str); __extension__ __attribute__ ((__dllimport__)) long long _wtoi64_l(const wchar_t *_Str,_locale_t _Locale); __extension__ __attribute__ ((__dllimport__)) long long _wcstoi64(const wchar_t *_Str,wchar_t **_EndPtr,int _Radix); __extension__ __attribute__ ((__dllimport__)) long long _wcstoi64_l(const wchar_t *_Str,wchar_t **_EndPtr,int _Radix,_locale_t _Locale); __extension__ __attribute__ ((__dllimport__)) unsigned long long _wcstoui64(const wchar_t *_Str,wchar_t **_EndPtr,int _Radix); __extension__ __attribute__ ((__dllimport__)) unsigned long long _wcstoui64_l(const wchar_t *_Str ,wchar_t **_EndPtr,int _Radix,_locale_t _Locale); __attribute__ ((__dllimport__)) char * _fullpath(char *_FullPath,const char *_Path,size_t _SizeInBytes); __attribute__ ((__dllimport__)) char * _ecvt(double _Val,int _NumOfDigits,int *_PtDec,int *_PtSign) ; __attribute__ ((__dllimport__)) char * _fcvt(double _Val,int _NumOfDec,int *_PtDec,int *_PtSign) ; __attribute__ ((__dllimport__)) char * _gcvt(double _Val,int _NumOfDigits,char *_DstBuf) ; __attribute__ ((__dllimport__)) int _atodbl(_CRT_DOUBLE *_Result,char *_Str); __attribute__ ((__dllimport__)) int _atoldbl(_LDOUBLE *_Result,char *_Str); __attribute__ ((__dllimport__)) int _atoflt(_CRT_FLOAT *_Result,char *_Str); __attribute__ ((__dllimport__)) int _atodbl_l(_CRT_DOUBLE *_Result,char *_Str,_locale_t _Locale); __attribute__ ((__dllimport__)) int _atoldbl_l(_LDOUBLE *_Result,char *_Str,_locale_t _Locale); __attribute__ ((__dllimport__)) int _atoflt_l(_CRT_FLOAT *_Result,char *_Str,_locale_t _Locale); __extension__ unsigned long long _lrotl(unsigned long long _Val,int _Shift); __extension__ unsigned long long _lrotr(unsigned long long _Val,int _Shift); __attribute__ ((__dllimport__)) void _makepath(char *_Path,const char *_Drive,const char *_Dir,const char *_Filename,const char *_Ext); _onexit_t _onexit(_onexit_t _Func); __attribute__ ((__dllimport__)) int _putenv(const char *_EnvString); __extension__ unsigned long long _rotl64(unsigned long long _Val,int _Shift); __extension__ unsigned long long _rotr64(unsigned long long Value,int Shift); unsigned int _rotr(unsigned int _Val,int _Shift); unsigned int _rotl(unsigned int _Val,int _Shift); __extension__ unsigned long long _rotr64(unsigned long long _Val,int _Shift); __attribute__ ((__dllimport__)) void _searchenv(const char *_Filename,const char *_EnvVar,char *_ResultPath) ; __attribute__ ((__dllimport__)) void _splitpath(const char *_FullPath,char *_Drive,char *_Dir,char *_Filename,char *_Ext) ; __attribute__ ((__dllimport__)) void _swab(char *_Buf1,char *_Buf2,int _SizeInBytes); __attribute__ ((__dllimport__)) wchar_t * _wfullpath(wchar_t *_FullPath,const wchar_t *_Path,size_t _SizeInWords); __attribute__ ((__dllimport__)) void _wmakepath(wchar_t *_ResultPath,const wchar_t *_Drive,const wchar_t *_Dir,const wchar_t *_Filename,const wchar_t *_Ext); __attribute__ ((__dllimport__)) int _wputenv(const wchar_t *_EnvString); __attribute__ ((__dllimport__)) void _wsearchenv(const wchar_t *_Filename,const wchar_t *_EnvVar,wchar_t *_ResultPath) ; __attribute__ ((__dllimport__)) void _wsplitpath(const wchar_t *_FullPath,wchar_t *_Drive,wchar_t *_Dir,wchar_t *_Filename,wchar_t *_Ext) ; __attribute__ ((__dllimport__)) void _beep(unsigned _Frequency,unsigned _Duration) __attribute__ ((__deprecated__)); /* Not to be confused with _set_error_mode (int). */ __attribute__ ((__dllimport__)) void _seterrormode(int _Mode) __attribute__ ((__deprecated__)); __attribute__ ((__dllimport__)) void _sleep(unsigned long _Duration) __attribute__ ((__deprecated__)); # 574 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\stdlib.h" 3 char * ecvt(double _Val,int _NumOfDigits,int *_PtDec,int *_PtSign) ; char * fcvt(double _Val,int _NumOfDec,int *_PtDec,int *_PtSign) ; char * gcvt(double _Val,int _NumOfDigits,char *_DstBuf) ; char * itoa(int _Val,char *_DstBuf,int _Radix) ; char * ltoa(long _Val,char *_DstBuf,int _Radix) ; int putenv(const char *_EnvString) ; void swab(char *_Buf1,char *_Buf2,int _SizeInBytes) ; char * ultoa(unsigned long _Val,char *_Dstbuf,int _Radix) ; _onexit_t onexit(_onexit_t _Func); typedef struct { __extension__ long long quot, rem; } lldiv_t; __extension__ lldiv_t lldiv(long long, long long); __extension__ long long llabs(long long); __extension__ long long strtoll(const char * __restrict__, char ** __restrict, int); __extension__ unsigned long long strtoull(const char * __restrict__, char ** __restrict__, int); /* these are stubs for MS _i64 versions */ __extension__ long long atoll (const char *); __extension__ long long wtoll (const wchar_t *); __extension__ char * lltoa (long long, char *, int); __extension__ char * ulltoa (unsigned long long , char *, int); __extension__ wchar_t * lltow (long long, wchar_t *, int); __extension__ wchar_t * ulltow (unsigned long long, wchar_t *, int); /* __CRT_INLINE using non-ansi functions */ # 627 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\stdlib.h" 3 #pragma pack(pop) # 1 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\sec_api/stdlib_s.h" 1 3 /** * This file has no copyright assigned and is placed in the Public Domain. * This file is part of the w64 mingw-runtime package. * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ # 1 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\stdlib.h" 1 3 /** * This file has no copyright assigned and is placed in the Public Domain. * This file is part of the w64 mingw-runtime package. * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ # 9 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\sec_api/stdlib_s.h" 2 3 # 629 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\stdlib.h" 2 3 # 1 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\malloc.h" 1 3 /** * This file has no copyright assigned and is placed in the Public Domain. * This file is part of the w64 mingw-runtime package. * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ # 1 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\_mingw.h" 1 3 /** * This file has no copyright assigned and is placed in the Public Domain. * This file is part of the w64 mingw-runtime package. * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ # 9 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\malloc.h" 2 3 #pragma pack(push,_CRT_PACKING) # 31 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\malloc.h" 3 /* Return codes for _heapwalk() */ /* Values for _heapinfo.useflag */ /* The structure used to walk through the heap with _heapwalk. */ typedef struct _heapinfo { int *_pentry; size_t _size; int _useflag; } _HEAPINFO; extern unsigned int _amblksiz; /* Make sure that X86intrin.h doesn't produce here collisions. */ # 98 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\malloc.h" 3 /* Users should really use MS provided versions */ void * __mingw_aligned_malloc (size_t _Size, size_t _Alignment); void __mingw_aligned_free (void *_Memory); void * __mingw_aligned_offset_realloc (void *_Memory, size_t _Size, size_t _Alignment, size_t _Offset); void * __mingw_aligned_realloc (void *_Memory, size_t _Size, size_t _Offset); __attribute__ ((__dllimport__)) int _resetstkoflw (void); __attribute__ ((__dllimport__)) unsigned long _set_malloc_crt_max_wait(unsigned long _NewValue); __attribute__ ((__dllimport__)) void * _expand(void *_Memory,size_t _NewSize); __attribute__ ((__dllimport__)) size_t _msize(void *_Memory); __attribute__ ((__dllimport__)) size_t _get_sbh_threshold(void); __attribute__ ((__dllimport__)) int _set_sbh_threshold(size_t _NewValue); __attribute__ ((__dllimport__)) errno_t _set_amblksiz(size_t _Value); __attribute__ ((__dllimport__)) errno_t _get_amblksiz(size_t *_Value); __attribute__ ((__dllimport__)) int _heapadd(void *_Memory,size_t _Size); __attribute__ ((__dllimport__)) int _heapchk(void); __attribute__ ((__dllimport__)) int _heapmin(void); __attribute__ ((__dllimport__)) int _heapset(unsigned int _Fill); __attribute__ ((__dllimport__)) int _heapwalk(_HEAPINFO *_EntryInfo); __attribute__ ((__dllimport__)) size_t _heapused(size_t *_Used,size_t *_Commit); __attribute__ ((__dllimport__)) intptr_t _get_heap_handle(void); # 140 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\malloc.h" 3 static __inline void *_MarkAllocaS(void *_Ptr,unsigned int _Marker) { if(_Ptr) { *((unsigned int*)_Ptr) = _Marker; _Ptr = (char*)_Ptr + 16; } return _Ptr; } # 159 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\malloc.h" 3 static __inline void _freea(void *_Memory) { unsigned int _Marker; if(_Memory) { _Memory = (char*)_Memory - 16; _Marker = *(unsigned int *)_Memory; if(_Marker==0xDDDD) { free(_Memory); } } } # 205 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\malloc.h" 3 #pragma pack(pop) # 630 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\stdlib.h" 2 3 # 5 "./duc.h" 2 //#define FREQ 1657 //#define FREQ 0 /* N Accumulator P Phase M Output B N-P Frequency ========= Fomin = (Fs/(2^N)) Fo = (Fs/(2^N))*Dacc Fomax = (Fs/2^(N-P)) Phase Quantization ================== SFDRest = 6.02P - 3.92dB P = (SFDR+3.92)/6.02 Amplitude Quantization ====================== SNRest = -6.02M -1.76db Best performance (-SFDR<SNR): P = M+1 */ typedef uint16 acc_t; typedef uint5 phi_t; typedef int16 dds_t; typedef uint11 rnd_t; // Largest coefficient: 69475 (0x10F63) typedef int18 srrc_data_t; typedef int18 srrc_coef_t; typedef int38 srrc_acc_t; typedef int18 imf1_data_t; typedef int18 imf1_coef_t; typedef int38 imf1_acc_t; typedef int18 imf2_data_t; typedef int18 imf2_coef_t; typedef int38 imf2_acc_t; typedef int18 imf3_data_t; typedef int18 imf3_coef_t; typedef int38 imf3_acc_t; typedef int18 mix_data_t; void duc ( srrc_data_t din_i, acc_t freq, mix_data_t *dout_i, mix_data_t *dout_q ); int37 mult ( int18 c, int19 d ); int37 symtap ( int18 a, int18 b, int18 c ); srrc_acc_t srrc_mac ( int18 c, int18 d, int40 s ); imf1_acc_t mac1 ( imf1_coef_t c, imf1_data_t d, imf1_acc_t s ); imf2_acc_t mac2 ( imf2_coef_t c, imf2_data_t d, imf2_acc_t s ); int48 mac ( int18 c, int18 d, int48 s ); void srrc ( srrc_data_t *y, srrc_data_t x ); void imf1 ( imf1_data_t *y, imf1_data_t x ); void imf2 ( imf2_data_t *y, imf2_data_t x ); void imf3 ( imf2_data_t *y, imf2_data_t x ); void mixer ( acc_t freq, mix_data_t Din, mix_data_t *Dout_I, mix_data_t *Dout_Q ); void dds ( acc_t freq, dds_t *sin, dds_t *cosine ); rnd_t rnd(); # 1 "imf3.c" 2 void imf3 ( imf3_data_t *y, imf3_data_t x ) { const imf3_coef_t c[6][2]={ # 1 "./imf3_coef.h" 1 1651, 0, -13134, 0, 77019, 0, 77019, 131071, -13134, 0, 1651, 0 # 8 "imf3.c" 2 }; /* Transposed form FIR poly branches */ static imf3_acc_t shift_reg_p0[6][2]; static imf3_acc_t shift_reg_p1[6][2]; static imf3_data_t in = 0; imf3_acc_t acc0; imf3_acc_t acc1; static uint1 init = 1; static uint6 i = 0; static uint6 j = 0; uint1 ch; L1: //Latch input if (i==0) { in = x; } uint6 inc = i+1; ch= ({ ; typeof(j) __Val2__ = j; typeof(j) __Result__ = 0; __builtin_bit_part_select((void*)(&__Result__), (void*)(&__Val2__), 3, 3); !!__Result__; }); //Calculate tap acc0 = mac(c[i][0], in, (init || i==5) ? 0 : shift_reg_p0[inc][ch]); acc1 = mac(c[i][1], in, (init || i==5) ? 0 : shift_reg_p1[inc][ch]); //Shift shift_reg_p0[i][ch] = acc0; shift_reg_p1[i][ch] = acc1; //Output *y = (i==0) ? acc0 >> 17 : acc1 >> 17; if (i==5 && j==15) init = 0; if (i==5) j = (j==15) ? 0 : j+1; i = (i==5) ? 0 : inc; }
the_stack_data/104829151.c
/* Example code for Think OS. Copyright 2014 Allen Downey License: GNU GPLv3 */ /* time ./counter_array real 0m0.088s user 0m0.156s sys 0m0.004s */ #include <stdio.h> #include <stdlib.h> #include <pthread.h> #define NUM_CHILDREN 2 void perror_exit(char *s) { perror(s); exit(-1); } void *check_malloc(int size) { void *p = malloc(size); if (p == NULL) { perror_exit("malloc failed"); } return p; } typedef struct { int counter; int end; int *array; } Shared; Shared *make_shared(int end) { int i; Shared *shared = check_malloc(sizeof(Shared)); shared->counter = 0; shared->end = end; shared->array = check_malloc(shared->end * sizeof(int)); for (i=0; i<shared->end; i++) { shared->array[i] = 0; } return shared; } pthread_t make_thread(void *(*entry)(void *), Shared *shared) { int ret; pthread_t thread; ret = pthread_create(&thread, NULL, entry, (void *) shared); if (ret != 0) { perror_exit("pthread_create failed"); } return thread; } void join_thread(pthread_t thread) { int ret = pthread_join(thread, NULL); if (ret == -1) { perror_exit("pthread_join failed"); } } void child_code(Shared *shared) { printf("Starting child at counter %d\n", shared->counter); while (1) { if (shared->counter >= shared->end) { return; } shared->array[shared->counter]++; shared->counter++; if (shared->counter % 10000 == 0) { printf("%d\n", shared->counter); } } } void *entry(void *arg) { Shared *shared = (Shared *) arg; child_code(shared); printf("Child done.\n"); pthread_exit(NULL); } void check_array(Shared *shared) { int i, errors=0; printf("Checking...\n"); for (i=0; i<shared->end; i++) { if (shared->array[i] != 1) errors++; } printf("%d errors.\n", errors); } int main() { int i; pthread_t child[NUM_CHILDREN]; Shared *shared = make_shared(1000000); for (i=0; i<NUM_CHILDREN; i++) { child[i] = make_thread(entry, shared); } for (i=0; i<NUM_CHILDREN; i++) { join_thread(child[i]); } check_array(shared); return 0; }
the_stack_data/143061.c
#include<stdio.h> int f(int,int); int main(){ int m,n; scanf("%d%d",&m,&n); printf("%d",f(m,n)); return 0; } //็ป„ๅˆๆ•ฐ// int f(int m,int n) { if(n==1) return m; if(n==m) return 1; return f(m-1,n)+f(m-1,n-1); }
the_stack_data/118028.c
#include <stdio.h> int main(void) { //Zeilen for (int i = 0; i < 6; i++) { //Spalten for (int j = 0; j < 6; j++) { if (j == 0) { printf("<\t"); }else if (j == 5) { printf(">\n"); }else if (i == 0){ printf(" ^\t"); }else if (i == 5){ printf(" v\t"); }else{ printf("(%d, %d)\t", i, (j - 1)); } } } }
the_stack_data/10599.c
#include <stdio.h> #include <stdlib.h> void kifkif(int* a); int main(int argc, char** argv) { int a = 2; printf("a = %d\n", a); kifkif(&a); return a; } void kifkif(int* a) { *a = 4; }
the_stack_data/97012192.c
#include <stdlib.h> /* PR optimization/8988 */ /* Contributed by Kevin Easton */ void foo(char *p1, char **p2) {} int main(void) { char str[] = "foo { xx }"; char *ptr = str + 5; foo(ptr, &ptr); while (*ptr && (*ptr == 13 || *ptr == 32)) ptr++; return 0; }
the_stack_data/159516274.c
// https://www.hackerrank.com/challenges/arrays-ds/problem #include <stdio.h> #include <stdlib.h> int main(){ int i,c,n,a[1000],t=0; scanf("%d",&n); c=n-1; for(i=0;i<n;i++){ scanf("%d",&a[i]); } for(i=0;i<n/2;i++){ t=a[i]; a[i]=a[c]; a[c]=t; c--; } for(i=0;i<n;i++){ printf("%d ",a[i]); } return 0; }
the_stack_data/11611.c
#include <stdio.h> #include <stdlib.h> //Um enum รฉ uma enumeraรงรฃo. Comeรงando em 0. //ร‰ muito usado para facilitar leitura e manutenรงรฃo de cรณdigo. //Muito usado no contexto de desenvolvimento de jogos. enum types{Fire, Water, Wind, Earth, Light, Dark}; //0 a 5 /** * Fire == 0 * Water == 1 * Wind == 2 * Earth == 3 * Light == 4 * Dark == 5 */ int main() { int defenderHP, attackerAtk, defenderType, attackerType, damageMultiplier, hitChance, randHit; printf("Vida do Defensor:\n"); scanf("%d", &defenderHP); printf("Tipo do Defensor:\n"); //0 a 5 (enum) scanf("%d", &defenderType); printf("Ataque do Atacante:\n"); scanf("%d", &attackerAtk); printf("Tipo do Atacante:\n"); //0 a 5 (enum) scanf("%d", &attackerType); printf("Chance de Acerto:\n"); //0 a 100 scanf("%d", &hitChance); //A funรงรฃo rand() gera um nรบmero aleatรณrio. Ao pegarmos o resto do resultado por um valor, limitamos ela entre 0 e esse valor. randHit = rand()%100; if(randHit < hitChance) { if(attackerType == Water) if(defenderType == Fire) damageMultiplier = 2; else damageMultiplier = 1; else if(attackerType == Wind) if(defenderType == Earth) damageMultiplier = 2; else damageMultiplier = 1; else if(attackerType == Light) if(defenderType == Dark) damageMultiplier = 2; else damageMultiplier = 1; else if(attackerType == Fire) if(defenderType == Water) damageMultiplier = 0.5; else damageMultiplier = 1; else if(attackerType == Earth) if(defenderType == Wind) damageMultiplier = 0.5; else damageMultiplier = 1; else if(attackerType == Dark) if(defenderType == Light) damageMultiplier = 0.5; else damageMultiplier = 1; else { damageMultiplier = 1.0; } defenderHP -= attackerAtk*damageMultiplier; printf("HP restante: %d\n", defenderHP); } else { printf("O ataque falhou!\n"); } return 0; }
the_stack_data/36157.c
// For Balder the mead, a drink for the noble // I was forced to speak, now silence is my name // Hod shall guide him, shall be his bane // I was forced to speak, now silence is my name
the_stack_data/99915.c
// Exercรญcio 02 - Escreva uma funรงรฃo que leia um inteiro nรฃo-negativo n e imprima a soma dos n primeiros // nรบmeros primos. #include <stdio.h> int somaprimo (int A); int primo (int B); int A; int B; int somaprimo (int A) { int contagem = 1; int soma = 2; printf ("A soma eh 2"); int teste = 3; while (contagem < A) { if (primo (teste)) { soma = soma + teste; printf (" + %d", teste); contagem++; } teste++; } printf (" = %d", soma); return soma; } int primo (int B) { int cont; int cond = 0; for (cont = 1; cont <= B; cont++) if (B % cont == 0) cond++; if (cond == 2) { return 1; } else { return 0; } } main () { int contagem = 1; int soma; printf ("Insira o valor: "); scanf ("%d", &A); if (A <= 0) printf ("Nรบmero invรกlido"); else if (A == 1) printf ("Apenas 2 eh numero primo"); else somaprimo (A); printf ("\n"); system("pause"); } /*// Exercรญcio 02 - Escreva uma funรงรฃo que leia um inteiro nรฃo-negativo n e imprima a soma dos n primeiros // nรบmeros primos. # include <stdio.h> int main(void) { int num, count_primo; count_primo = 0; printf("Digite um nรบmero: "); scanf("%d", &num); for (int count2 = 2; count_primo <= num; count2) { for (int count = 2; count_primo <= num; count ++) { if (count2 % count == 0) { count_primo ++; printf("%d", count); } } } int num, qtd_num_primo; qtd_num_primo = 0; printf("Digite um nรบmero: "); scanf("%d", &num); //printf("Nรบmeros divisiveis por %d: ", num); for (int count = 1; qtd_num_primo <= num; count ++) { if (num % count == 0) { qtd_num_primo += 1; printf("%d ", count); } } //printf("\nSoma dos primeiros nรบmeros primos atรฉ %d: \n", num); }*/
the_stack_data/242331576.c
#include <stdio.h> #include <locale.h> int main(void){ /* Esse cรณdigo calcula a quantidade de notas de R$ 10, R$ 20 e R$ 50 que devem ser fornecidas ao cliente, de acordo com o valor que ele deseja sacar do caixa eletrรดnico. */ setlocale(LC_ALL,""); // Pergunta o valor do saque printf("Qual o valor que vocรช deseja sacar, hoje?\n"); // Lรช o valor digitado int varValor,i; scanf("%i",&varValor); // Cria array bimensional // Na primeira dimensรฃo, tenho as notas disponรญveis // A segunda serรก usada para armazenar a quantidade a ser fornecida, de cada nota int notas[2][6] = {{100,50,20,10,5,2},{0,0,0,0,0,0}}; // Faz loop pelo array para verifica a maior nota a ser fornecida para o valor solicitado for (i=0;i<5;i++){ if(varValor >= notas[0][i]){ // Calcula a quantidade de notas a fornecer notas[1][i] = varValor / notas[0][i]; // Ajusta o valor restante para a prรณxima passada do loop varValor = varValor % notas[0][i]; } } // Apresenta os resultados printf("Vocรช receberรก:\n%i notas de R$ 100\n%i notas de R$ 50\n%i notas de R$ 20\n%i notas de R$ 10\n%i notas de R$ 5\n%i notas de R$ 2",notas[1][0],notas[1][1],notas[1][2],notas[1][3],notas[1][4],notas[1][5]); printf("\nA quantia de R$ %i, nรฃo pode ser fornecida, pois nรฃo temos moedas.",varValor); }
the_stack_data/140765355.c
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % M M AAA CCCC % % MM MM A A C % % M M M AAAAA C % % M M A A C % % M M A A CCCC % % % % % % Macintosh Utility Methods for MagickCore % % % % Software Design % % Cristy % % September 1996 % % % % % % Copyright 1999-2018 ImageMagick Studio LLC, a non-profit organization % % dedicated to making software imaging solutions freely available. % % % % You may not use this file except in compliance with the License. You may % % obtain a copy of the License at % % % % https://www.imagemagick.org/script/license.php % % % % Unless required by applicable law or agreed to in writing, software % % distributed under the License is distributed on an "AS IS" BASIS, % % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. % % See the License for the specific language governing permissions and % % limitations under the License. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % The directory methods are strongly based on similar methods written % by Steve Summit, [email protected]. The Ghostscript launch code is strongly % based on Dave Schooley's Mac Gnuplot and contributed by % [email protected]. Mac-centric improvements contributed by % [email protected]. % % */ #if defined(macintosh) /* Include declarations. */ #define _X_H #define _WIDGET_H #include <AppleEvents.h> #include <AERegistry.h> #include <AEObjects.h> #include <AEPackObject.h> #include <Processes.h> #include <QuickDraw.h> #include <QDOffscreen.h> #include <Palettes.h> #include <ImageCompression.h> #include <PictUtils.h> #include <Files.h> #include <Gestalt.h> #include <TextUtils.h> #define ColorInfo KolorInfo #include "magick/studio.h" #include "magick/blob.h" #include "magick/client.h" #include "magick/exception.h" #include "magick/exception-private.h" #include "magick/image-private.h" #include "magick/list.h" #include "magick/magick.h" #include "magick/monitor.h" #include "magick/monitor-private.h" #include "magick/pixel-accessor.h" #include "magick/quantum.h" #include "magick/string_.h" #include "magick/utility.h" #include "magick/mac.h" /* Global declaractions. */ ImageDescriptionHandle image_description = nil; /* Forward declaractions. */ static Boolean SearchForFile(OSType,OSType,FSSpec *,short); static pascal void ArcMethod(GrafVerb,Rect *,short,short), BitsMethod(BitMap *,Rect *,Rect *,short,RgnHandle), FilenameToFSSpec(const char *filename,FSSpec *fsspec), LineMethod(Point), OvalMethod(GrafVerb,Rect *), PolyMethod(GrafVerb,PolyHandle), RRectMethod(GrafVerb,Rect *,short,short), RectMethod(GrafVerb,Rect *), RegionMethod(GrafVerb,RgnHandle), StandardPixmap(PixMapPtr,Rect *,MatrixRecordPtr,short,RgnHandle,PixMapPtr, Rect *,short), TextMethod(short,Ptr,Point,Point); /* Static declarations */ #if defined(DISABLE_SIOUX) static MACEventHookPtr event_hook = nil; static MACErrorHookPtr exception.hook = nil; #endif /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % B o t t l e n e c k T e s t % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % BottleneckTest() intercepts any compressed images. % % The format of the BottleneckTest method is: % % int BottleneckTest(const char *magick) % % A description of each parameter follows: % % o picture: Specifies a pointer to a PicHandle structure. % % o codec: the code type is returned in this CodecType pointer structure. % % o depth: the image depth is returned as an integer pointer. % % o colormap_id: the colormap ID is returned in this short pointer. % % */ static pascal void ArcMethod(GrafVerb verb,Rect *r,short startAngle, short arcAngle) { #pragma unused (verb,r,startAngle,arcAngle) } static pascal void BitsMethod(BitMap *bitPtr,Rect *source_rectangle, Rect *dstRect,short mode,RgnHandle maskRgn) { #pragma unused (bitPtr,source_rectangle,dstRect,mode,maskRgn) } static pascal void LineMethod(Point newPt) { #pragma unused (newPt) } static pascal void OvalMethod(GrafVerb verb,Rect *r) { #pragma unused (verb,r) } static pascal void PolyMethod(GrafVerb verb,PolyHandle poly) { #pragma unused (verb,poly) } static pascal void RectMethod(GrafVerb verb,Rect *r) { #pragma unused (verb,r) } static pascal void RegionMethod(GrafVerb verb,RgnHandle rgn) { #pragma unused (verb,rgn) } static pascal void RRectMethod(GrafVerb verb,Rect *r,short ovalWidth, short ovalHeight) { #pragma unused (verb,r,ovalWidth,ovalHeight) } static pascal void StandardPixmap(PixMapPtr source,Rect *source_rectangle, MatrixRecordPtr matrix,short mode,RgnHandle mask,PixMapPtr matte, Rect *matte_rectangle,short flags) { #pragma unused (source_rectangle,matrix,mode,mask,matte,matte_rectangle,flags) Ptr data; ssize_t size; GetCompressedPixMapInfo(source,&image_description,&data,&size,nil,nil); } static pascal void TextMethod(short byteCount,Ptr textBuf,Point numer, Point denom) { #pragma unused (byteCount,textBuf,numer,denom) } #if !defined(DISABLE_QUICKTIME) static short BottleneckTest(PicHandle picture,CodecType *codec,int *depth, short *colormap_id) { CQDProcs bottlenecks; int status; Rect rectangle; ssize_t version; status=Gestalt(gestaltQuickTime,&version); if (status != noErr) { ParamText("\pQuickTime not installed. Please install, then try again.", "\p","\p","\p"); Alert(128,nil); return(-1); } /* Define our own bottlenecks to do nothing. */ SetStdCProcs(&bottlenecks); bottlenecks.textProc=NewQDTextUPP(&TextMethod); bottlenecks.lineProc=NewQDLineUPP(&LineMethod); bottlenecks.rectProc=NewQDRectUPP(&RectMethod); bottlenecks.rRectProc=NewQDRRectUPP(&RRectMethod); bottlenecks.ovalProc=NewQDOvalUPP(&OvalMethod); bottlenecks.arcProc=NewQDArcUPP(&ArcMethod); bottlenecks.polyProc=NewQDPolyUPP(&PolyMethod); bottlenecks.rgnProc=NewQDRgnUPP(&RegionMethod); bottlenecks.bitsProc=NewQDBitsUPP(&BitsMethod); bottlenecks.newProc1=(UniversalProcPtr) NewStdPixUPP(&StandardPixmap); /* Install our custom bottlenecks to intercept any compressed images. */ (*(qd.thePort)).grafProcs=(QDProcs *) &bottlenecks; DrawPicture(picture,&((**picture).picFrame)); PaintRect(&rectangle); (*(qd.thePort)).grafProcs=0L; /* Initialize our return values. */ *codec='unkn'; *depth=0; *colormap_id=(-1); if (image_description != nil) { *codec=(**image_description).cType; *depth=(**image_description).depth; *colormap_id=(**image_description).clutID; } DisposeQDTextUPP(bottlenecks.textProc); DisposeQDLineUPP(bottlenecks.lineProc); DisposeQDRectUPP(bottlenecks.rectProc); DisposeQDRRectUPP(bottlenecks.rRectProc); DisposeQDOvalUPP(bottlenecks.ovalProc); DisposeQDArcUPP(bottlenecks.arcProc); DisposeQDPolyUPP(bottlenecks.polyProc); DisposeQDRgnUPP(bottlenecks.rgnProc); DisposeQDBitsUPP(bottlenecks.bitsProc); DisposeStdPixUPP(bottlenecks.newProc1); return(0); } #endif #if !defined(MAGICKCORE_POSIX_SUPPORT_VERSION) /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % c l o s e d i r % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % closedir() closes the named directory stream and frees the DIR structure. % % The format of the closedir method is: % % closedir(entry) % % A description of each parameter follows: % % o entry: Specifies a pointer to a DIR structure. % % */ MagickExport void closedir(DIR *entry) { if (image->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); assert(entry != (DIR *) NULL); RelinquishMagickMemory(entry); } #endif /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % E x i t % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Exit() exits the process. % % The format of the exit method is: % % Exit(status) % % A description of each parameter follows: % % o status: an integer value representing the status of the terminating % process. % % */ MagickExport int Exit(int status) { #if !defined(DISABLE_SIOUX) (void) FormatLocaleFile(stdout,"Select File->Quit to exit.\n"); #endif exit(status); return(0); } /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % F i l e n a m e T o F S S p e c % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % FilenameToFSSpec() sets the file type of an image. % % The format of the FilenameToFSSpec method is: % % FilenameToFSSpec(filename,fsspec) % % A description of each parameter follows: % % o filename: Specifies the name of the file. % % o fsspec: A pointer to type FSSpec. % % */ MagickExport void pascal FilenameToFSSpec(const char *filename,FSSpec *fsspec) { Str255 name; assert(filename != (char *) NULL); c2pstrcpy(name,filename); FSMakeFSSpec(0,0,name,fsspec); } /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % I s M a g i c k C o n f l i c t % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % MACIsMagickConflict() returns true if the image format conflicts with a % logical drive (.e.g. X:). % % Contributed by Mark Gavin of Digital Applications, Inc. % % The format of the MACIsMagickConflict method is: % % status=MACIsMagickConflict(magick) % % A description of each parameter follows: % % o magick: Specifies the image format. % % */ static OSErr HGetVInfo(short volume_index,StringPtr volume_name,short *volume, size_t *free_bytes,size_t *total_bytes) { HParamBlockRec pb; OSErr result; size_t blocksize; unsigned short allocation_blocks, free_blocks; /* Use the File Manager to get the real vRefNum. */ pb.volumeParam.ioVRefNum=0; pb.volumeParam.ioNamePtr=volume_name; pb.volumeParam.ioVolIndex=volume_index; result=PBHGetVInfoSync(&pb); if (result != noErr) return(result); *volume=pb.volumeParam.ioVRefNum; blocksize=(size_t) pb.volumeParam.ioVAlBlkSiz; allocation_blocks=(unsigned short) pb.volumeParam.ioVNmAlBlks; free_blocks=(unsigned short) pb.volumeParam.ioVFrBlk; *free_bytes=free_blocks*blocksize; *total_bytes=allocation_blocks*blocksize; return(result); } MagickExport MagickBooleanType MACIsMagickConflict(const char *magick) { size_t free_bytes, number_bytes; OSErr status; short volume; Str255 volume_name; assert(magick != (char *) NULL); if (image->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",magick); (void) CopyMagickString((char *) volume_name,magick,MaxTextExtent); c2pstr((char *) volume_name); if (volume_name[volume_name[0]] != ':') volume_name[++volume_name[0]]=':'; status=HGetVInfo(-1,volume_name,&volume,&free_bytes,&number_bytes); return(status != 0 ? MagickFalse : MagickTrue); } /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % + M A C E r r o r H a n d l e r % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % MACErrorHandler() displays an error reason and then terminates the program. % % The format of the MACErrorHandler method is: % % void MACErrorHandler(const ExceptionType error,const char *reason, % const char *description) % % A description of each parameter follows: % % o exception: Specifies the numeric error category. % % o reason: Specifies the reason to display before terminating the % program. % % o description: Specifies any description to the reason. % % */ MagickExport void MACErrorHandler(const ExceptionType error,const char *reason, const char *description) { char buffer[3*MaxTextExtent]; if (reason == (char *) NULL) return; if (description == (char *) NULL) (void) FormatLocaleString(buffer,MaxTextExtent,"%s: %s.\n",GetClientName(), reason); else (void) FormatLocaleString(buffer,MaxTextExtent,"%s: %s (%s).\n", GetClientName(),reason,description); #if defined(DISABLE_SIOUX) if(exception.hook != (MACErrorHookPtr) NULL) exception.hook(error,buffer); else { MagickCoreTerminus(); exit(error); } #else puts(buffer); MagickCoreTerminus(); exit(error); #endif } #if defined(DISABLE_SIOUX) /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % + M A C F a t a l E r r o r H a n d l e r % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % MACFatalErrorHandler() displays an error reason and then terminates the % program. % % The format of the MACFatalErrorHandler method is: % % void MACFatalErrorHandler(const ExceptionType severity, % const char *reason,const char *description) % % A description of each parameter follows: % % o severity: Specifies the numeric error category. % % o reason: Specifies the reason to display before terminating the % program. % % o description: Specifies any description to the reason. % */ static void MACFatalErrorHandler(const ExceptionType severity, const char *reason,const char *description) { char buffer[3*MaxTextExtent]; if (reason == (char *) NULL) return; if (description == (char *) NULL) (void) FormatLocaleString(buffer,MaxTextExtent,"%s: %s.\n",GetClientName(), reason); else (void) FormatLocaleString(buffer,MaxTextExtent,"%s: %s (%s).\n", GetClientName(),reason,description); if(exception.hook != (MACErrorHookPtr) NULL) exception.hook(severity, buffer); else { MagickCoreTerminus(); exit(severity); } } #endif /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % M a c G S E x e c u t e C o m m a n d % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % MacGSExecuteCommand() executes the Ghostscript command. % % */ static OSErr MacGSExecuteCommand(const char *command,ssize_t length) { AEAddressDesc event_descriptor; AEDesc reply = {typeNull, NULL}; AppleEvent event = {typeNull, NULL}; DescType descriptor_type; int error; OSType id = 'gsVR'; Size actualSize; /* Send the Apple Event. */ (void) AECreateDesc(typeApplSignature,&id,sizeof(id),&event_descriptor); (void) AECreateAppleEvent(id,'exec',&event_descriptor,-1,kAnyTransactionID, &event); (void) AEPutParamPtr(&event,keyDirectObject,typeChar,command,length); (void) AESend(&event,&reply,kAEWaitReply+kAENeverInteract,kAENormalPriority, kNoTimeOut,NULL,NULL); /* Handle the reply and exit. */ (void) AEGetParamPtr(&reply,keyDirectObject,typeInteger,&descriptor_type, &error,sizeof(error),&actualSize); (void) AEDisposeDesc(&event_descriptor); (void) AEDisposeDesc(&event); if (reply.descriptorType != NULL) AEDisposeDesc(&reply); return((OSErr) error); } /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % M a c G S L a u n c h A p p l i c a t i o n C o r e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % MacGSLaunchApplicationCore() launches the Ghostscript command. % % */ static OSErr MacGSLaunchApplicationCore(ssize_t flags) { FSSpec file_info; LaunchParamBlockRec launch_info; OSErr error; if (!SearchForFile('gsVR','APPL',&file_info,1)) return(-43); launch_info.launchBlockID=extendedBlock; launch_info.launchEPBLength=extendedBlockLen; launch_info.launchFileFlags=0; launch_info.launchControlFlags=launchContinue+launchNoFileFlags+flags; launch_info.launchAppSpec=(&file_info); launch_info.launchAppParameters=nil; error=LaunchApplication(&launch_info); return(error); } /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % M a c G S L a u n c h A p p l i c a t i o n % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % MacGSLaunchApplication() launches the Ghostscript command. % % */ static OSErr MacGSLaunchApplication(void) { return(MacGSLaunchApplicationCore(launchDontSwitch)); } /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % M a c G S L a u n c h A p p l i c a t i o n T o F r o n t % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % MacGSLaunchApplicationToFront() moves the Ghostscript window to the front. % % */ static OSErr MacGSLaunchApplicationToFront(void) { return(MacGSLaunchApplicationCore(0)); } /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % M a c G S Q u i t A p p l i c a t i o n % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % MacGSQuitApplication() quits the Ghostscript application. % % */ static void MacGSQuitApplication(void) { AEAddressDesc event_descriptor; AEDesc reply = {typeNull, NULL}; AppleEvent event = {typeNull, NULL}; OSType id = 'GPLT'; /* Send the Apple Event. */ (void) AECreateDesc(typeApplSignature,&id,sizeof(id),&event_descriptor); (void) AECreateAppleEvent(typeAppleEvent,kAEQuitApplication, &event_descriptor,-1,kAnyTransactionID,&event); (void) AESend(&event,&reply,kAENoReply,kAENormalPriority,kNoTimeOut,NULL, NULL); /* Clean up and exit. */ (void) AEDisposeDesc(&event_descriptor); (void) AEDisposeDesc(&event); if (reply.descriptorType != NULL) AEDisposeDesc(&reply); } /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % M a c G S S e t W o r k i n g F o l d e r % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % MacGSSetWorkingFolder() set the Ghostscript working folder. % % */ static OSErr MacGSSetWorkingFolder(char *directory) { AEDesc application_descriptor, event_descriptor, object, path_descriptor, type_descriptor, reply; AppleEvent event; DescType folder_type = 'wfdr'; OSErr error; OSType id = 'GPLT'; /* Send the Apple Event. */ AECreateDesc(typeNull,NULL,0,&application_descriptor); AECreateDesc(typeChar,directory,strlen(directory),&path_descriptor); (void) AECreateDesc(typeType,&folder_type,sizeof(DescType),&type_descriptor); CreateObjSpecifier(cProperty,&application_descriptor,formPropertyID, &type_descriptor,0,&object); (void) AECreateDesc(typeApplSignature,&id,sizeof(id),&event_descriptor); (void) AECreateAppleEvent(kAECoreSuite,kAESetData,&event_descriptor,-1, kAnyTransactionID,&event); (void) AEPutParamDesc(&event,keyDirectObject,&object); (void) AEPutParamDesc(&event,keyAEData,&path_descriptor); error=AESend(&event,&reply,kAENoReply+kAENeverInteract,kAENormalPriority, kNoTimeOut,NULL,NULL); (void) AEDisposeDesc(&event); (void) AEDisposeDesc(&event_descriptor); (void) AEDisposeDesc(&object); (void) AEDisposeDesc(&type_descriptor); (void) AEDisposeDesc(&path_descriptor); (void) AEDisposeDesc(&application_descriptor); return(error); } /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % M A C S e t E r r o r H o o k % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % MACSetErrorHook sets a callback function which is called if any error % occurs within ImageMagick. % % The format of the MACSetErrorHook method is: % % int MACSetErrorHook(MACErrorHookPtr hook) % % A description of each parameter follows: % % o hook: This function pointer is the callback function. % % */ MagickExport void MACSetErrorHook(MACErrorHookPtr hook) { /* We forget any previously set exception.hook. */ exception.hook=hook; } /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % M A C S e t E v e n t H o o k % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % MACSetEventHook sets a callback function which is called every time % ImageMagick likes to release the processor. % % The format of the MACSetEventHook method is: % % int MACSetEventHook(MACEventHookPtr hook) % % A description of each parameter follows: % % o hook: This function pointer is the callback function. % % */ MagickExport void MACSetEventHook(MACEventHookPtr hook) { /* We forget any previously set event hook. */ event_hook=hook; } /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % M A C S y s t e m C o m m a n d % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Method MACSystemCommand executes the specified command and waits until it % terminates. The returned value is the exit status of the command. % % The format of the MACSystemCommand method is: % % int MACSystemCommand(MagickFalse,const char * command) % % A description of each parameter follows: % % o command: This string is the command to execute. % */ MagickExport int MACSystemCommand(const char * command) { /* We only know how to launch Ghostscript. */ if (MacGSLaunchApplicationToFront()) return(-1); return(MacGSExecuteCommand(command,strlen(command))); } /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % M A C W a r n i n g H a n d l e r % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % MACWarningHandler() displays a warning reason. % % The format of the MACWarningHandler method is: % + void MACWarningHandler(const ExceptionType warning,const char *reason, % const char *description) % % A description of each parameter follows: % % o warning: Specifies the numeric warning category. % % o reason: Specifies the reason to display before terminating the % program. % % o description: Specifies any description to the reason. % % */ MagickExport void MACWarningHandler(const ExceptionType warning, const char *reason,const char *description) { char buffer[1664]; if (reason == (char *) NULL) return; if (description == (char *) NULL) (void) FormatLocaleString(buffer,MaxTextExtent,"%s: %s.\n",GetClientName(), reason); else (void) FormatLocaleString(buffer,MaxTextExtent,"%s: %s (%s).\n", GetClientName(),reason,description); #if defined(DISABLE_SIOUX) if(exception.hook != (MACErrorHookPtr) NULL) exception.hook(warning, buffer); #else (void)warning; puts(buffer); #endif } #if !defined(MAGICKCORE_POSIX_SUPPORT_VERSION) /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % o p e n d i r % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % opendir() opens the directory named by filename and associates a directory % stream with it. % % The format of the opendir method is: % % MagickExport DIR *opendir(char *path) % % A description of each parameter follows: % % o entry: Specifies a pointer to a DIR structure. % % */ MagickExport DIR *opendir(const char *path) { Str255 pathname; CInfoPBRec search_info; DIR *entry; int error; search_info.hFileInfo.ioNamePtr=0; if ((path != (char *) NULL) || (*path != '\0')) if ((path[0] != '.') || (path[1] != '\0')) { c2pstrcpy(pathname,path); search_info.hFileInfo.ioNamePtr=pathname; } search_info.hFileInfo.ioCompletion=0; search_info.hFileInfo.ioVRefNum=0; search_info.hFileInfo.ioFDirIndex=0; search_info.hFileInfo.ioDirID=0; error=PBGetCatInfoSync(&search_info); if (error != noErr) { errno=error; return((DIR *) NULL); } entry=(DIR *) AcquireMagickMemory(sizeof(DIR)); if (entry == (DIR *) NULL) return((DIR *) NULL); entry->d_VRefNum=search_info.hFileInfo.ioVRefNum; entry->d_DirID=search_info.hFileInfo.ioDirID; entry->d_index=1; return(entry); } #endif /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % P r o c e s s P e n d i n g E v e n t s % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % ProcessPendingEvents() processes any pending events. This prevents % ImageMagick from monopolizing the processor. % % The format of the ProcessPendingEvents method is: % % ProcessPendingEvents(text) % % A description of each parameter follows: % % o text: A character string representing the current process. % % */ MagickExport void ProcessPendingEvents(const char *text) { #if defined(DISABLE_SIOUX) if (event_hook != (MACEventHookPtr) NULL) event_hook(text); #else static const char *mark = (char *) NULL; EventRecord event; while (WaitNextEvent(everyEvent,&event,0L,nil)) SIOUXHandleOneEvent(&event); if (isatty(STDIN_FILENO) && (text != mark)) { (void) puts(text); mark=text; } #endif } #if !defined(MAGICKCORE_POSIX_SUPPORT_VERSION) /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % r e a d d i r % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % readdir() returns a pointer to a structure representing the directory entry % at the current position in the directory stream to which entry refers. % % The format of the readdir % % struct dirent *readdir(DIR *entry) % % A description of each parameter follows: % % o entry: Specifies a pointer to a DIR structure. % % */ MagickExport struct dirent *readdir(DIR *entry) { CInfoPBRec search_info; int error; static struct dirent dir_entry; static unsigned char pathname[MaxTextExtent]; if (entry == (DIR *) NULL) return((struct dirent *) NULL); search_info.hFileInfo.ioCompletion=0; search_info.hFileInfo.ioNamePtr=pathname; search_info.hFileInfo.ioVRefNum=0; search_info.hFileInfo.ioFDirIndex=entry->d_index; search_info.hFileInfo.ioDirID=entry->d_DirID; error=PBGetCatInfoSync(&search_info); if (error != noErr) { errno=error; return((struct dirent *) NULL); } entry->d_index++; p2cstrcpy(dir_entry.d_name,search_info.hFileInfo.ioNamePtr); dir_entry.d_namlen=strlen(dir_entry.d_name); return(&dir_entry); } #endif /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % R e a d P I C T I m a g e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % ReadPICTImage() reads an Apple Macintosh QuickDraw/PICT image file using % MacOS QuickDraw methods and returns it. It allocates the memory necessary % for the new Image structure and returns a pointer to the new image. % % This method was written and contributed by [email protected] % (feel free to copy and use it as you want. No warranty). % % The format of the ReadPICTImage method is: % % Image *ReadPICTImage(const ImageInfo *image_info, % ExceptionInfo *exception) % % A description of each parameter follows: % % o image: Method ReadPICTImage returns a pointer to the image after % reading. A null image is returned if there is a memory shortage or % if the image cannot be read. % % o image_info: the image info.. % % o exception: return any errors or warnings in this structure. % */ static inline size_t MagickMax(const size_t x,const size_t y) { if (x > y) return(x); return(y); } MagickExport Image *ReadPICTImage(const ImageInfo *image_info, ExceptionInfo *exception) { #define PICTHeaderSize 512 CodecType codec; GDHandle device; GWorldPtr graphic_world, port; Image *image; int depth, status; MagickBooleanType proceed, status; PicHandle picture_handle; PictInfo picture_info; QDErr theErr = noErr; Rect rectangle; RGBColor Pixel; short colormap_id; ssize_t y; /* Open image file. */ image=AcquireImage(image_info); status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); if (status == MagickFalse) return(NULL); picture_handle=(PicHandle) NewHandle(MagickMax(GetBlobSize(image)- PICTHeaderSize,PICTHeaderSize)); if (picture_handle == nil) ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); HLock((Handle) picture_handle); (void) ReadBlob(image,PICTHeaderSize,*(unsigned char **) picture_handle); status=ReadBlob(image,GetBlobSize(image)-PICTHeaderSize,*(unsigned char **) picture_handle); if (status == MagickFalse) { DisposeHandle((Handle) picture_handle); ThrowReaderException(CorruptImageError,"UnableToReadImageData"); } GetGWorld(&port,&device); theErr=NewGWorld(&graphic_world,0,&(**picture_handle).picFrame,nil,nil, useTempMem | keepLocal); if ((theErr != noErr) && (graphic_world == nil)) { DisposeHandle((Handle) picture_handle); ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); } HUnlock((Handle) picture_handle); SetGWorld(graphic_world,nil); theErr=GetPictInfo(picture_handle,&picture_info,0,1,systemMethod,0); if (theErr != noErr) { DisposeGWorld(graphic_world); DisposeHandle((Handle) picture_handle); ThrowReaderException(CorruptImageError,"UnableToReadImageData"); } #if defined(DISABLE_QUICKTIME) codec='unkn'; colormap_id=(-1); depth=picture_info.depth; #else BottleneckTest(picture_handle,&codec,&depth,&colormap_id); #endif switch (codec) { case 'rpza': case 'jpeg': case 'rle ': case 'raw ': case 'smc ': { if (depth > 200) { depth-=32; picture_info.theColorTable=GetCTable(colormap_id); } break; } default: { depth=picture_info.depth; if (depth <= 8) (void) GetPictInfo(picture_handle,&picture_info,returnColorTable, (short) (1 << picture_info.depth),systemMethod,0); break; } } image->x_resolution=(picture_info.hRes) >> 16; image->y_resolution=(picture_info.vRes) >> 16; image->units=PixelsPerInchResolution; image->columns=picture_info.sourceRect.right-picture_info.sourceRect.left; image->rows=picture_info.sourceRect.bottom-picture_info.sourceRect.top; if ((depth <= 8) && ((*(picture_info.theColorTable))->ctSize != 0)) { size_t number_colors; /* Colormapped PICT image. */ number_colors=(*(picture_info.theColorTable))->ctSize; if (!AcquireImageColormap(image,number_colors)) { if (picture_info.theColorTable != nil) DisposeHandle((Handle) picture_info.theColorTable); DisposeGWorld(graphic_world); DisposeHandle((Handle) picture_handle); ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); } for (x=0; x < image->colors; x++) { image->colormap[x].red= (*(picture_info.theColorTable))->ctTable[x].rgb.red; image->colormap[x].green= (*(picture_info.theColorTable))->ctTable[x].rgb.green; image->colormap[x].blue= (*(picture_info.theColorTable))->ctTable[x].rgb.blue; } } SetRect(&rectangle,0,0,image->columns,image->rows); (void) UpdateGWorld(&graphic_world,depth,&rectangle, picture_info.theColorTable,nil,0); LockPixels(GetGWorldPixMap(graphic_world)); /*->portPixMap); */ EraseRect(&rectangle); DrawPicture(picture_handle,&rectangle); if ((depth <= 8) && (colormap_id == -1)) { DisposeHandle((Handle) picture_info.theColorTable); picture_info.theColorTable=nil; } DisposeHandle((Handle) picture_handle); /* Convert PICT pixels to pixel packets. */ for (y=0; y < image->rows; y++) { register IndexPacket *restrict indexes; register ssize_t x; register PixelPacket *restrict q; q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); if (q == (PixelPacket *) NULL) break; indexes=GetAuthenticIndexQueue(image); for (x=0; x < image->columns; x++) { GetCPixel(x,y,&Pixel); SetPixelRed(q,ScaleCharToQuantum(Pixel.red & 0xff)); SetPixelGreen(q,ScaleCharToQuantum(Pixel.green & 0xff)); SetPixelBlue(q,ScaleCharToQuantum(Pixel.blue & 0xff)); if (image->storage_class == PseudoClass) SetPixelIndex(indexes+x,Color2Index(&Pixel)); q++; } if (SyncAuthenticPixels(image,exception) == MagickFalse) break; proceed=SetImageProgress(image,LoadImageTag,y,image->rows); if (proceed == MagickFalse) break; } UnlockPixels(GetGWorldPixMap(graphic_world)); SetGWorld(port,device); if (picture_info.theColorTable != nil) DisposeHandle((Handle) picture_info.theColorTable); DisposeGWorld(graphic_world); (void) CloseBlob(image); return(image); } /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % S e a r c h F o r F i l e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % SearchForFile() searches for a file. % % */ static Boolean SearchForFile(OSType creator_type,OSType file_type,FSSpec *file, short count) { char *buffer; CInfoPBRec search1_info, search2_info; FSSpec application; HParamBlockRec parameter_info; OSErr error; ProcessInfoRec application_info; ProcessSerialNumber serial_number; ssize_t buffer_size = 16384; serial_number.lowLongOfPSN=kCurrentProcess; serial_number.highLongOfPSN=0; application_info.processInfoLength=sizeof(ProcessInfoRec); application_info.processName=NULL; application_info.processAppSpec=(&application); GetProcessInformation(&serial_number,&application_info); buffer=NewPtr(buffer_size); if (buffer == (char *) NULL) return(false); parameter_info.csParam.ioCompletion=NULL; parameter_info.csParam.ioNamePtr=NULL; parameter_info.csParam.ioVRefNum=application.vRefNum; parameter_info.csParam.ioMatchPtr=file; parameter_info.csParam.ioReqMatchCount=count; parameter_info.csParam.ioSearchBits=fsSBFlFndrInfo; parameter_info.csParam.ioSearchInfo1=&search1_info; parameter_info.csParam.ioSearchInfo2=&search2_info; parameter_info.csParam.ioSearchTime=0; parameter_info.csParam.ioCatPosition.initialize=0; parameter_info.csParam.ioOptBuffer=buffer; parameter_info.csParam.ioOptBufSize=buffer_size; search1_info.hFileInfo.ioNamePtr=NULL; search1_info.hFileInfo.ioFlFndrInfo.fdType=file_type; search1_info.hFileInfo.ioFlFndrInfo.fdCreator=creator_type; search1_info.hFileInfo.ioFlAttrib=0; search1_info.hFileInfo.ioFlParID=0; search2_info=search1_info; search2_info.hFileInfo.ioFlAttrib=0x10; search2_info.hFileInfo.ioFlFndrInfo.fdCreator=creator_type; search2_info.hFileInfo.ioFlFndrInfo.fdType=(-1); search2_info.hFileInfo.ioFlFndrInfo.fdFlags=0; search2_info.hFileInfo.ioFlFndrInfo.fdLocation.h=0; search2_info.hFileInfo.ioFlFndrInfo.fdLocation.v=0; search2_info.hFileInfo.ioFlFndrInfo.fdFldr=0; search2_info.hFileInfo.ioFlParID=0; error=PBCatSearchSync((CSParamPtr) &parameter_info); DisposePtr(buffer); if (parameter_info.csParam.ioReqMatchCount == parameter_info.csParam.ioActMatchCount) error=eofErr; if (parameter_info.csParam.ioActMatchCount == 0) error=0; return(error == eofErr); } #if !defined(MAGICKCORE_POSIX_SUPPORT_VERSION) /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % s e e k d i r % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % seekdir() sets the position of the next readdir() operation on the directory % stream. % % The format of the seekdir method is: % % void seekdir(DIR *entry,ssize_t position) % % A description of each parameter follows: % % o entry: Specifies a pointer to a DIR structure. % % o position: specifies the position associated with the directory % stream. % % % */ MagickExport void seekdir(DIR *entry,ssize_t position) { assert(entry != (DIR *) NULL); entry->d_index=position; } #endif /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % S e t A p p l i c a t i o n T y p e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % SetApplicationType() sets the file type of an image. % % The format of the SetApplicationType method is: % % void SetApplicationType(const char *filename,const char *magick, % OSType application) % % A description of each parameter follows: % % o filename: Specifies the name of the file. % % o filename: Specifies the file type. % % o application: Specifies the type of the application. % */ static inline size_t MagickMin(const size_t x,const size_t y) { if (x < y) return(x); return(y); } MagickExport void SetApplicationType(const char *filename,const char *magick, OSType application) { FSSpec file_specification; OSType filetype; Str255 name; assert(filename != (char *) NULL); if (image->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",filename); assert(magick != (const char *) NULL); filetype=' '; (void) CopyMagickString((char *) &filetype,magick,MagickMin(strlen(magick), 4)); if (LocaleCompare(magick,"JPG") == 0) (void) CopyMagickString((char *) &filetype,"JPEG",MaxTextExtent); c2pstrcpy(name,filename); FSMakeFSSpec(0,0,name,&file_specification); FSpCreate(&file_specification,application,filetype,smSystemScript); } #if !defined(MAGICKCORE_POSIX_SUPPORT_VERSION) /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % t e l l d i r % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Method telldir returns the current location associated with the % named directory stream. % % The format of the telldir method is: % % telldir(DIR *entry) % % A description of each parameter follows: % % o entry: Specifies a pointer to a DIR structure. % % */ MagickExport ssize_t telldir(DIR *entry) { return(entry->d_index); } #endif #endif
the_stack_data/25138309.c
/* Adds two fractions */ #include <stdio.h> int main(void) { int num1, denom1, num2, denom2, resultNum, resultDenom; printf("Enter the first fraction: "); scanf("%d/%d", &num1, &denom1); printf("Enter the second fraction: "); scanf("%d/%d", &num2, &denom2); resultNum = num1 * denom2 + num2 * denom1; resultDenom = denom1 * denom2; printf("The sum is %d/%d\n", resultNum, resultDenom); return 0; }
the_stack_data/107164.c
/* * main.c */ int main(void) { volatile unsigned long i = 0; int baseAddress = 0; int base = 150 / 32; if (base == 0) { baseAddress = 0x48310000; } else if (base == 1) { baseAddress = 0x49050000; } else if (base == 2) { baseAddress = 0x49052000; } else if (base == 3) { baseAddress = 0x49054000; } else if (base == 4) { baseAddress = 0x49056000; } else if (base == 5) { baseAddress = 0x49058000; } int* out = (int*) (baseAddress + 0x003C); int pinPos = 150 % 32; while (1) { ((*out) |= (1UL << (pinPos))); } }
the_stack_data/28393.c
/* Copyright (c) 2012, Volvo Technology AB All rights reserved. Redistribution and use of this material (model, software and documentation), with or without modification, are permitted provided that the following conditions are met: Redistributions must retain the above copyright notice and this list of conditions. The material is intended for research purposes only. Modifications representing refinement and extension are encouraged. Volvo Technology shall have access to such refinements. */ // Author: Chungha Sung // This is a modified version of Brake2_1_conc.c which was used in DATE15 paper. // The original source code can be found in http://www.cprover.org/interrupts/ /* * Copyright 2012 The MathWorks, Inc_ * * File: rt_main_c * * Abstract: * * A real-time main that runs generated Simulink Coder code under most * operating systems_ Based on the definition of MULTITASKING, a single-task * or multitask step function is employed_ * * This file is a useful starting point for creating a custom main when * targeting a custom floating point processor or integer micro-controller_ * * Alternatively for ERT targets, you can generate a sample ert_main_c file * with the generated code by selecting the "Generate an example main program" * option_ In this case, ert_main_c is precisely customized to the * model requirements_ * * Required Defines: * * MODEL - Model name * NUMST - Number of sample times * */ #include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <pthread.h> #include <assert.h> //#include "brake_acc_nodiv_ctrl_h" // Lihao //int test; #define MODEL brake_acc_nodiv_ctrl #define NUMST 4 /*==================* * Required defines * *==================*/ #ifndef MODEL # error Must specify a model name_ Define MODEL=name_ #else /* create generic macros that work with any model */ # define EXPAND_CONCAT(name1,name2) name1 ## name2 # define CONCAT(name1,name2) EXPAND_CONCAT(name1,name2) # define MODEL_INITIALIZE CONCAT(MODEL,_initialize) # define MODEL_STEP CONCAT(MODEL,_step) # define MODEL_TERMINATE CONCAT(MODEL,_terminate) # define RT_MDL CONCAT(MODEL,_M) #endif #if defined(TID01EQ) && TID01EQ == 1 #define FIRST_TID 1 #else #define FIRST_TID 0 #endif /*====================* * External functions * *====================*/ /* extern void MODEL_INITIALIZE(void); extern void MODEL_TERMINATE(void); extern void MODEL_STEP(int_T tid); // multirate step function */ /*===================* * Visible functions * *===================*/ /* Function: rtOneStep ======================================================== * * Abstract: * Perform one step of the model. This function is modeled such that * it could be called from an interrupt service routine (ISR) with minor * modifications. * * Note that error checking is only necessary when this routine is * attached to an interrupt. * * Also, you may wish to unroll any or all of for and while loops to * improve the real-time performance of this function. */ //static void rt_OneStep(void) //{ // int_T i; // /******************************************* // * Step the model for the base sample time * // *******************************************/ // MODEL_STEP(0); // /********************************************************* // * Step the model for any other sample times (subrates) * // *********************************************************/ // for (i = FIRST_TID+1; i < NUMST; i++) { // /****************************************** // * Step the model for sample time "i" * // ******************************************/ // MODEL_STEP(i); // } // //} /* end rtOneStep */ /* Function: rt_InitModel ==================================================== * * Abstract: * Initialized the model and the overrun flags * */ /* void rt_InitModel(void) { MODEL_INITIALIZE(); } */ /* Function: rt_TermModel ==================================================== * * Abstract: * Terminates the model and prints the error status * */ /* int_T rt_TermModel(void) { MODEL_TERMINATE(); return(0); } */ /* void havocInputs(ExtU_brake_acc_nodiv_ctrl_T *_inputs) { ExtU_brake_acc_nodiv_ctrl_T inputs; *_inputs = inputs; } */ /* Split in separate tasks Lihao */ //Lihao const int __VERIFIER_thread_priorities[] = {5, 5, 5, 5, 22}; const char* __VERIFIER_threads[] = {"c::task_RR_Wheel", "c::task_FR_Wheel", "c::task_FL_Wheel", "c::task_RL_Wheel", "c::task_compute"}; //void irq_err(void) {ERROR: goto ERROR;} int brake_acc_nodiv_ctrl_B_local_RT_h; int brake_acc_nodiv_ctrl_B_local_RTH; int brake_acc_nodiv_ctrl_B_local_RT4; int brake_acc_nodiv_ctrl_B_local_RT1; int brake_acc_nodiv_ctrl_B_local_RT2; int brake_acc_nodiv_ctrl_B_local_RT3; int brake_acc_nodiv_ctrl_B_local_RT14; int brake_acc_nodiv_ctrl_B_local_ABS_FL_Wheel_Threshold_10kmh = 100; int brake_acc_nodiv_ctrl_B_local_ABS_RL_Wheel_Threshold_10kmh = 100; int brake_acc_nodiv_ctrl_B_local_ABS_RR_Wheel_Threshold_10kmh = 100; int brake_acc_nodiv_ctrl_B_local_ABS_FR_Wheel_Threshold_10kmh = 100; int brake_acc_nodiv_ctrl_P_RT_X0; int brake_acc_nodiv_ctrl_P_RT4_X0; int brake_acc_nodiv_ctrl_P_RT1_X0; int brake_acc_nodiv_ctrl_P_RT2_X0; int brake_acc_nodiv_ctrl_P_RT3_X0; int brake_acc_nodiv_ctrl_P_Gain1_Gain; int brake_acc_nodiv_ctrl_P_Distribution_Gain0; int brake_acc_nodiv_ctrl_P_Distribution_Gain1; int brake_acc_nodiv_ctrl_P_Distribution_Gain2; int brake_acc_nodiv_ctrl_P_Distribution_Gain3; int brake_acc_nodiv_ctrl_P_average_rpm_Gain; int brake_acc_nodiv_ctrl_P_wgrads_Gain; int brake_acc_nodiv_ctrl_P_vkmh_Gain; #define brake_acc_nodiv_ctrl_P_ABS_FL_Wheel_vms_Gain 10 #define brake_acc_nodiv_ctrl_P_ABS_FL_Wheel_wheSpdms_Gain 10 #define brake_acc_nodiv_ctrl_P_ABS_FL_Wheel_times_10_Gain 10 #define brake_acc_nodiv_ctrl_P_ABS_FL_Wheel_slip_abs_on_times_10_Gain 10 #define brake_acc_nodiv_ctrl_P_ABS_FL_Wheel_Threshold_10kmh_Threshold 100 #define brake_acc_nodiv_ctrl_P_ABS_FL_Wheel_ReleaseBrake_Value 8 #define brake_acc_nodiv_ctrl_P_ABS_FL_Wheel_positive_UpperSat 100 #define brake_acc_nodiv_ctrl_P_ABS_FL_Wheel_positive_LowerSat 5 #define brake_acc_nodiv_ctrl_P_ABS_RR_Wheel_vms_Gain 10 #define brake_acc_nodiv_ctrl_P_ABS_RR_Wheel_wheSpdms_Gain 10 #define brake_acc_nodiv_ctrl_P_ABS_RR_Wheel_times_10_Gain 10 #define brake_acc_nodiv_ctrl_P_ABS_RR_Wheel_slip_abs_on_times_10_Gain 10 #define brake_acc_nodiv_ctrl_P_ABS_RR_Wheel_Threshold_10kmh_Threshold 100 #define brake_acc_nodiv_ctrl_P_ABS_RR_Wheel_ReleaseBrake_Value 8 #define brake_acc_nodiv_ctrl_P_ABS_RR_Wheel_positive_UpperSat 100 #define brake_acc_nodiv_ctrl_P_ABS_RR_Wheel_positive_LowerSat 5 #define brake_acc_nodiv_ctrl_P_ABS_RL_Wheel_vms_Gain 10 #define brake_acc_nodiv_ctrl_P_ABS_RL_Wheel_wheSpdms_Gain 10 #define brake_acc_nodiv_ctrl_P_ABS_RL_Wheel_times_10_Gain 10 #define brake_acc_nodiv_ctrl_P_ABS_RL_Wheel_slip_abs_on_times_10_Gain 10 #define brake_acc_nodiv_ctrl_P_ABS_RL_Wheel_Threshold_10kmh_Threshold 100 #define brake_acc_nodiv_ctrl_P_ABS_RL_Wheel_ReleaseBrake_Value 8 #define brake_acc_nodiv_ctrl_P_ABS_RL_Wheel_positive_UpperSat 100 #define brake_acc_nodiv_ctrl_P_ABS_RL_Wheel_positive_LowerSat 5 #define brake_acc_nodiv_ctrl_P_ABS_FR_Wheel_vms_Gain 10 #define brake_acc_nodiv_ctrl_P_ABS_FR_Wheel_wheSpdms_Gain 10 #define brake_acc_nodiv_ctrl_P_ABS_FR_Wheel_times_10_Gain 10 #define brake_acc_nodiv_ctrl_P_ABS_FR_Wheel_slip_abs_on_times_10_Gain 10 #define brake_acc_nodiv_ctrl_P_ABS_FR_Wheel_Threshold_10kmh_Threshold 100 #define brake_acc_nodiv_ctrl_P_ABS_FR_Wheel_ReleaseBrake_Value 8 #define brake_acc_nodiv_ctrl_P_ABS_FR_Wheel_positive_UpperSat 100 #define brake_acc_nodiv_ctrl_P_ABS_FR_Wheel_positive_LowerSat 5 #define brake_acc_nodiv_ctrl_P_Pedal_map_UpperSat 50 #define brake_acc_nodiv_ctrl_P_Pedal_map_LowerSat 20 #define brake_acc_nodiv_ctrl_U_In_BrakePedal 15 #define brake_acc_nodiv_ctrl_U_In_FLRotation 10 #define brake_acc_nodiv_ctrl_U_In_RRRotation 10 #define brake_acc_nodiv_ctrl_U_In_RLRotation 10 #define brake_acc_nodiv_ctrl_U_In_FRRotation 10 int vkmh; int test; int RT9; int RT10; int RT11; int RT12; int RT14; int RT_Buffer0; int RT0_Buffer0; int RT1_Buffer0; int RT2_Buffer0; int RT3_Buffer0; int RT4_Buffer0; int Distribution_idx; int Distribution_idx_0; int Distribution_idx_1; #define LIMIT 20 int cnt1, cnt2, cnt3; void *task_compute(void *unused) { //while (cnt1 < LIMIT) { //cnt1++; //B_brake_acc_nodiv_ctrl_T brake_acc_nodiv_ctrl_B_local; /* Start for RateTransition: '<Root>/RT' */ //brake_acc_nodiv_ctrl_B_local_RT_h = brake_acc_nodiv_ctrl_P_RT_X0; brake_acc_nodiv_ctrl_B_local_RT_h = brake_acc_nodiv_ctrl_P_RT_X0; /* Start for RateTransition: '<Root>/RT4' */ //brake_acc_nodiv_ctrl_B_local_RT4 = brake_acc_nodiv_ctrl_P_RT4_X0; brake_acc_nodiv_ctrl_B_local_RT4 = brake_acc_nodiv_ctrl_P_RT4_X0; /* Start for RateTransition: '<Root>/RT1' */ //brake_acc_nodiv_ctrl_B_local_RT1 = brake_acc_nodiv_ctrl_P_RT1_X0; brake_acc_nodiv_ctrl_B_local_RT1 = brake_acc_nodiv_ctrl_P_RT1_X0; /* Start for RateTransition: '<Root>/RT2' */ //brake_acc_nodiv_ctrl_B_local_RT2 = brake_acc_nodiv_ctrl_P_RT2_X0; brake_acc_nodiv_ctrl_B_local_RT2 = brake_acc_nodiv_ctrl_P_RT2_X0; /* Start for RateTransition: '<Root>/RT3' */ //brake_acc_nodiv_ctrl_B_local_RT3 = brake_acc_nodiv_ctrl_P_RT3_X0; brake_acc_nodiv_ctrl_B_local_RT3 = brake_acc_nodiv_ctrl_P_RT3_X0; //B_brake_acc_nodiv_ctrl_T brake_acc_nodiv_ctrl_B_local = brake_acc_nodiv_ctrl_B; test = 0; // brake_acc_nodiv_ctrl_step2(); //the following code is from this function /* S-Function (fcncallgen): '<Root>/20ms' incorporates: * SubSystem: '<Root>/Global Brake Controller' */ /* Gain: '<S6>/Distribution' */ Distribution_idx = brake_acc_nodiv_ctrl_P_Distribution_Gain1 + brake_acc_nodiv_ctrl_B_local_RT14; Distribution_idx_0 = brake_acc_nodiv_ctrl_P_Distribution_Gain2 + brake_acc_nodiv_ctrl_B_local_RT14; Distribution_idx_1 = brake_acc_nodiv_ctrl_P_Distribution_Gain3 + brake_acc_nodiv_ctrl_B_local_RT14; /* S-Function (fcncallgen): '<Root>/20ms1' incorporates: * SubSystem: '<Root>/Veh_Speed_Estimator' */ /* Gain: '<S25>/v (km//h)' incorporates: * Gain: '<S25>/average_rpm' * Gain: '<S25>/w (grad//s)' * Sum: '<S25>/Add' */ //vkmh = (((RT9 + RT10) + RT11) + RT12) + //brake_acc_nodiv_ctrl_P_average_rpm_Gain + brake_acc_nodiv_ctrl_P_wgrads_Gain //+ brake_acc_nodiv_ctrl_P_vkmh_Gain; vkmh = RT9+RT10; vkmh = vkmh + RT11; vkmh = vkmh + RT12; vkmh = vkmh + brake_acc_nodiv_ctrl_P_average_rpm_Gain; vkmh = vkmh + brake_acc_nodiv_ctrl_P_wgrads_Gain; vkmh = vkmh + brake_acc_nodiv_ctrl_P_vkmh_Gain; test++; // assert(test == 0); if (test != 0) { assert(0); } // assert(test == 1); if (test != 1) { assert(0); } //assert(test == 0); /* S-Function (fcncallgen): '<Root>/20ms' incorporates: * SubSystem: '<Root>/Global Brake Controller' */ /* Update for RateTransition: '<Root>/RT' incorporates: * Gain: '<S6>/Distribution' */ RT_Buffer0 = brake_acc_nodiv_ctrl_P_Distribution_Gain0 + brake_acc_nodiv_ctrl_B_local_RT14; /* Update for RateTransition: '<Root>/RT4' */ RT4_Buffer0 = vkmh; /* Update for RateTransition: '<Root>/RT1' */ RT1_Buffer0 = Distribution_idx; /* Update for RateTransition: '<Root>/RT2' */ RT2_Buffer0 = Distribution_idx_0; /* Update for RateTransition: '<Root>/RT3' */ RT3_Buffer0 = Distribution_idx_1; //} } void *task_RR_Wheel(void *unused) { //while (cnt2 < LIMIT) { //cnt2 ++; test = 0; // assert(test == 0); if (test != 0) { assert(0); } /* Start for RateTransition: '<Root>/RT' */ brake_acc_nodiv_ctrl_B_local_RT_h = brake_acc_nodiv_ctrl_P_RT_X0; /* Start for RateTransition: '<Root>/RT4' */ brake_acc_nodiv_ctrl_B_local_RT4 = brake_acc_nodiv_ctrl_P_RT4_X0; /* Start for RateTransition: '<Root>/RT1' */ brake_acc_nodiv_ctrl_B_local_RT1 = brake_acc_nodiv_ctrl_P_RT1_X0; /* Start for RateTransition: '<Root>/RT2' */ brake_acc_nodiv_ctrl_B_local_RT2 = brake_acc_nodiv_ctrl_P_RT2_X0; /* Start for RateTransition: '<Root>/RT3' */ brake_acc_nodiv_ctrl_B_local_RT3 = brake_acc_nodiv_ctrl_P_RT3_X0; //B_brake_acc_nodiv_ctrl_T brake_acc_nodiv_ctrl_B_local = brake_acc_nodiv_ctrl_B; //brake_acc_nodiv_ctrl_step1 // the following code is from this function /* local block i/o variables */ int rtb_to_int; /* RateTransition: '<Root>/RT' */ brake_acc_nodiv_ctrl_B_local_RT_h = RT_Buffer0; /* RateTransition: '<Root>/RT4' */ brake_acc_nodiv_ctrl_B_local_RT4 = RT4_Buffer0; //rtb_to_int = rt_roundd_snf(brake_acc_nodiv_ctrl_U_In_RRRotation); rtb_to_int = brake_acc_nodiv_ctrl_U_In_RRRotation; bool rtb_RelationalOperator; int rtb_vms; int u; rtb_vms = brake_acc_nodiv_ctrl_P_ABS_RR_Wheel_vms_Gain + brake_acc_nodiv_ctrl_B_local_RT4; u = rtb_vms + brake_acc_nodiv_ctrl_P_ABS_RR_Wheel_wheSpdms_Gain; u = u + rtb_to_int; int positive_UpperSat_local = brake_acc_nodiv_ctrl_P_ABS_RR_Wheel_positive_UpperSat; if (u >= positive_UpperSat_local) { u = brake_acc_nodiv_ctrl_P_ABS_RR_Wheel_positive_UpperSat; } else { int positive_LowerSat_local = brake_acc_nodiv_ctrl_P_ABS_RR_Wheel_positive_LowerSat; if (u <= positive_LowerSat_local) { u = brake_acc_nodiv_ctrl_P_ABS_RR_Wheel_positive_LowerSat; } } /* RelationalOperator: '<S29>/Relational Operator' incorporates: * Gain: '<S29>/slip_abs_on_times_10' * Gain: '<S29>/times_10' * Saturate: '<S29>/positive' */ //rtb_RelationalOperator = (brake_acc_nodiv_ctrl_P_ABS_RR_Wheel_times_10_Gain + u > //brake_acc_nodiv_ctrl_P_ABS_RR_Wheel_slip_abs_on_times_10_Gain + rtb_vms); int tmp0 = brake_acc_nodiv_ctrl_P_ABS_RR_Wheel_times_10_Gain; //tmp0 = tmp0 + u; int tmp1 = brake_acc_nodiv_ctrl_P_ABS_RR_Wheel_slip_abs_on_times_10_Gain + rtb_vms; if (tmp0 > tmp1) { rtb_RelationalOperator = true; } else { rtb_RelationalOperator = false; } /* Switch: '<S4>/Threshold_10km//h' */ // Lihao: lift int Threshold_10kmh_Threshold_local = brake_acc_nodiv_ctrl_P_ABS_RR_Wheel_Threshold_10kmh_Threshold; if (brake_acc_nodiv_ctrl_B_local_RT4 >= Threshold_10kmh_Threshold_local) { //if (brake_acc_nodiv_ctrl_B_local_RT4 >= 100) { /* Outputs for Atomic SubSystem: '<S4>/If v>=10 km//h' */ /* Switch: '<S29>/LockDetect' incorporates: * Constant: '<S29>/ReleaseBrake' */ if (rtb_RelationalOperator) { brake_acc_nodiv_ctrl_B_local_ABS_RR_Wheel_Threshold_10kmh = brake_acc_nodiv_ctrl_P_ABS_RR_Wheel_ReleaseBrake_Value; } else { brake_acc_nodiv_ctrl_B_local_ABS_RR_Wheel_Threshold_10kmh = brake_acc_nodiv_ctrl_B_local_RT_h; } /* End of Outputs for SubSystem: '<S4>/If v>=10 km//h' */ } else { /* Outputs for Atomic SubSystem: '<S4>/If v>=10 km//h' */ /* Switch: '<S29>/LockDetect' */ brake_acc_nodiv_ctrl_B_local_ABS_RR_Wheel_Threshold_10kmh = brake_acc_nodiv_ctrl_B_local_RT_h; /* End of Outputs for SubSystem: '<S4>/If v>=10 km//h' */ } /* End of Switch: '<S4>/Threshold_10km//h' */ // end of inline /* Outport: '<Root>/Out_TQ_RRBrake' */ //brake_acc_nodiv_ctrl_Y_Out_TQ_RRBrake = // brake_acc_nodiv_ctrl_B_local_ABS_RR_Wheel_Threshold_10kmh; /* RateTransition: '<Root>/RT1' */ brake_acc_nodiv_ctrl_B_local_RT1 = RT1_Buffer0; /* End of RateTransition: '<Root>/RT1' */ /* RateTransition: '<Root>/RT9' incorporates: * Gain: '<S5>/Gain1' * Rounding: '<S16>/round_to_int' * Saturate: '<S7>/Pedal_map' */ RT9 = rtb_to_int; //} } void *task_FL_Wheel(void *unused) { //while (cnt3 < LIMIT) { //cnt3++; test = 0; if (test != 0) { assert(0); } //assert(test == 0); //B_brake_acc_nodiv_ctrl_T brake_acc_nodiv_ctrl_B_local; /* Start for RateTransition: '<Root>/RT' */ brake_acc_nodiv_ctrl_B_local_RT_h = brake_acc_nodiv_ctrl_P_RT_X0; /* Start for RateTransition: '<Root>/RT4' */ brake_acc_nodiv_ctrl_B_local_RT4 = brake_acc_nodiv_ctrl_P_RT4_X0; /* Start for RateTransition: '<Root>/RT1' */ brake_acc_nodiv_ctrl_B_local_RT1 = brake_acc_nodiv_ctrl_P_RT1_X0; /* Start for RateTransition: '<Root>/RT2' */ brake_acc_nodiv_ctrl_B_local_RT2 = brake_acc_nodiv_ctrl_P_RT2_X0; /* Start for RateTransition: '<Root>/RT3' */ brake_acc_nodiv_ctrl_B_local_RT3 = brake_acc_nodiv_ctrl_P_RT3_X0; int rtb_to_int1; /* Rounding: '<S9>/to_int1' incorporates: * Inport: '<Root>/In_FLRotation' */ //rtb_to_int1 = rt_roundd_snf(brake_acc_nodiv_ctrl_U_In_FLRotation); rtb_to_int1 = brake_acc_nodiv_ctrl_U_In_FLRotation; /* RateTransition: '<Root>/RT' */ brake_acc_nodiv_ctrl_B_local_RT_h = RT_Buffer0; /* RateTransition: '<Root>/RT4' */ brake_acc_nodiv_ctrl_B_local_RT4 = RT4_Buffer0; // inline /* S-Function (fcncallgen): '<Root>/10ms_4' incorporates: * SubSystem: '<Root>/ABS_FL_Wheel' */ //brake_acc_nodiv_ct_ABS_RR_Wheel(brake_acc_nodiv_ctrl_B_local_RT4, // brake_acc_nodiv_ctrl_B_local_RT3, rtb_to_int1, // &brake_acc_nodiv_ctrl_B_local_ABS_FL_Wheel, //(P_ABS_RR_Wheel_brake_acc_nodi_T *) // brake_acc_nodiv_ctrl_P_ABS_FL_Wheel); /* local block i/o variables */ bool rtb_RelationalOperator; int rtb_vms; int u; /* Outputs for Atomic SubSystem: '<S4>/If v>=10 km//h' */ /* Gain: '<S29>/v (m//s)' */ rtb_vms = brake_acc_nodiv_ctrl_P_ABS_FL_Wheel_vms_Gain + brake_acc_nodiv_ctrl_B_local_RT4; /* Sum: '<S29>/Subtract' incorporates: * Gain: '<S29>/wheSpd (m//s)' */ u = rtb_vms + brake_acc_nodiv_ctrl_P_ABS_FL_Wheel_wheSpdms_Gain; u = u + rtb_to_int1; /* Saturate: '<S29>/positive' */ // Lihao: lift int positive_UpperSat_local = brake_acc_nodiv_ctrl_P_ABS_FL_Wheel_positive_UpperSat; //if (u >= positive_UpperSat_local) { if (u >= positive_UpperSat_local) { u = brake_acc_nodiv_ctrl_P_ABS_FL_Wheel_positive_UpperSat; } else { // Lihao: lift int positive_LowerSat_local = brake_acc_nodiv_ctrl_P_ABS_FL_Wheel_positive_LowerSat; if (u <= positive_LowerSat_local) { u = brake_acc_nodiv_ctrl_P_ABS_FL_Wheel_positive_LowerSat; } } /* RelationalOperator: '<S29>/Relational Operator' incorporates: * Gain: '<S29>/slip_abs_on_times_10' * Gain: '<S29>/times_10' * Saturate: '<S29>/positive' */ //rtb_RelationalOperator = (brake_acc_nodiv_ctrl_P_ABS_FL_Wheel_times_10_Gain + u > //brake_acc_nodiv_ctrl_P_ABS_FL_Wheel_slip_abs_on_times_10_Gain + rtb_vms); int tmp0 = brake_acc_nodiv_ctrl_P_ABS_FL_Wheel_times_10_Gain; int tmp1 = brake_acc_nodiv_ctrl_P_ABS_FL_Wheel_slip_abs_on_times_10_Gain + rtb_vms; if (tmp0 > tmp1) { rtb_RelationalOperator = true; } else { rtb_RelationalOperator = false; } /* Switch: '<S4>/Threshold_10km//h' */ // Lihao: lift int Threshold_10kmh_Threshold_local = brake_acc_nodiv_ctrl_P_ABS_FL_Wheel_Threshold_10kmh_Threshold; if (brake_acc_nodiv_ctrl_B_local_RT4 >= Threshold_10kmh_Threshold_local) { /* Outputs for Atomic SubSystem: '<S4>/If v>=10 km//h' */ /* Switch: '<S29>/LockDetect' incorporates: * Constant: '<S29>/ReleaseBrake' */ if (rtb_RelationalOperator) { brake_acc_nodiv_ctrl_B_local_ABS_FL_Wheel_Threshold_10kmh = brake_acc_nodiv_ctrl_P_ABS_FL_Wheel_ReleaseBrake_Value; } else { brake_acc_nodiv_ctrl_B_local_ABS_FL_Wheel_Threshold_10kmh = brake_acc_nodiv_ctrl_B_local_RT3; } /* End of Outputs for SubSystem: '<S4>/If v>=10 km//h' */ } else { /* Outputs for Atomic SubSystem: '<S4>/If v>=10 km//h' */ /* Switch: '<S29>/LockDetect' */ brake_acc_nodiv_ctrl_B_local_ABS_FL_Wheel_Threshold_10kmh = brake_acc_nodiv_ctrl_B_local_RT3; /* End of Outputs for SubSystem: '<S4>/If v>=10 km//h' */ } /* End of Switch: '<S4>/Threshold_10km//h' */ // end of inline /* Outport: '<Root>/Out_TQ_FLBrake' */ //brake_acc_nodiv_ctrl_Y_Out_TQ_FLBrake = // brake_acc_nodiv_ctrl_B_local_ABS_FL_Wheel_Threshold_10kmh; /* Saturate: '<S7>/Pedal_map' incorporates: * Inport: '<Root>/In_BrakePedal' */ // Lihao: lift int In_BrakePedal; if (rtb_RelationalOperator) { In_BrakePedal = brake_acc_nodiv_ctrl_U_In_BrakePedal; } else { In_BrakePedal = brake_acc_nodiv_ctrl_U_In_BrakePedal + 50; } int Pedal_map_UpperSat = brake_acc_nodiv_ctrl_P_Pedal_map_UpperSat; int Pedal_map_LowerSat = brake_acc_nodiv_ctrl_P_Pedal_map_LowerSat; int tmp; if (In_BrakePedal >= Pedal_map_UpperSat) { tmp = brake_acc_nodiv_ctrl_P_Pedal_map_UpperSat; } if (In_BrakePedal <= Pedal_map_LowerSat) { tmp = brake_acc_nodiv_ctrl_P_Pedal_map_LowerSat; } else { tmp = brake_acc_nodiv_ctrl_U_In_BrakePedal; } /* S-Function (fcncallgen): '<Root>/10ms' incorporates: * SubSystem: '<Root>/Brake_Torq_Calculation' */ //RT14 = brake_acc_nodiv_ctrl_P_Gain1_Gain * rt_roundd_snf(tmp); RT14 = brake_acc_nodiv_ctrl_P_Gain1_Gain + tmp; /* RateTransition: '<Root>/RT12' */ RT12 = rtb_to_int1; //} } void *task_FR_Wheel(void *unused) { test = 0; // assert(test == 0); if (test != 0) { assert(0); } //B_brake_acc_nodiv_ctrl_T brake_acc_nodiv_ctrl_B_local; /* Start for RateTransition: '<Root>/RT' */ brake_acc_nodiv_ctrl_B_local_RT_h = brake_acc_nodiv_ctrl_P_RT_X0; /* Start for RateTransition: '<Root>/RT4' */ brake_acc_nodiv_ctrl_B_local_RT4 = brake_acc_nodiv_ctrl_P_RT4_X0; /* Start for RateTransition: '<Root>/RT1' */ brake_acc_nodiv_ctrl_B_local_RT1 = brake_acc_nodiv_ctrl_P_RT1_X0; /* Start for RateTransition: '<Root>/RT2' */ brake_acc_nodiv_ctrl_B_local_RT2 = brake_acc_nodiv_ctrl_P_RT2_X0; /* Start for RateTransition: '<Root>/RT3' */ brake_acc_nodiv_ctrl_B_local_RT3 = brake_acc_nodiv_ctrl_P_RT3_X0; //B_brake_acc_nodiv_ctrl_T brake_acc_nodiv_ctrl_B_local = brake_acc_nodiv_ctrl_B; //brake_acc_nodiv_ctrl_step1 // the following code is from this function int rtb_to_int_k; /* RateTransition: '<Root>/RT4' */ brake_acc_nodiv_ctrl_B_local_RT4 = RT4_Buffer0; /* Rounding: '<S11>/to_int' incorporates: * Inport: '<Root>/In_FRRotation' */ //rtb_to_int_k = rt_roundd_snf(brake_acc_nodiv_ctrl_U_In_FRRotation); rtb_to_int_k = brake_acc_nodiv_ctrl_U_In_FRRotation; // inline /* S-Function (fcncallgen): '<Root>/10ms_3' incorporates: * SubSystem: '<Root>/ABS_FR_Wheel' */ //brake_acc_nodiv_ct_ABS_RR_Wheel(brake_acc_nodiv_ctrl_B_local_RT4, // brake_acc_nodiv_ctrl_B_local_RT2, rtb_to_int_k, // &brake_acc_nodiv_ctrl_B_local_ABS_FR_Wheel, //(P_ABS_RR_Wheel_brake_acc_nodi_T *) // brake_acc_nodiv_ctrl_P_ABS_FR_Wheel); /* local block i/o variables */ bool rtb_RelationalOperator; /* Outputs for Atomic SubSystem: '<S4>/If v>=10 km//h' */ /* Gain: '<S29>/v (m//s)' */ int rtb_vms = brake_acc_nodiv_ctrl_P_ABS_FR_Wheel_vms_Gain + brake_acc_nodiv_ctrl_B_local_RT4; /* Sum: '<S29>/Subtract' incorporates: * Gain: '<S29>/wheSpd (m//s)' */ int u = rtb_vms + brake_acc_nodiv_ctrl_P_ABS_FR_Wheel_wheSpdms_Gain; u = u + rtb_to_int_k; /* Saturate: '<S29>/positive' */ // Lihao: lift int positive_UpperSat_local = brake_acc_nodiv_ctrl_P_ABS_FR_Wheel_positive_UpperSat; if (u >= positive_UpperSat_local) { u = brake_acc_nodiv_ctrl_P_ABS_FR_Wheel_positive_UpperSat; } else { // Lihao: lift int positive_LowerSat_local = brake_acc_nodiv_ctrl_P_ABS_FR_Wheel_positive_LowerSat; if (u <= positive_LowerSat_local) { u = brake_acc_nodiv_ctrl_P_ABS_FR_Wheel_positive_LowerSat; } } /* RelationalOperator: '<S29>/Relational Operator' incorporates: * Gain: '<S29>/slip_abs_on_times_10' * Gain: '<S29>/times_10' * Saturate: '<S29>/positive' */ //rtb_RelationalOperator = (brake_acc_nodiv_ctrl_P_ABS_FR_Wheel_times_10_Gain + u > //brake_acc_nodiv_ctrl_P_ABS_FR_Wheel_slip_abs_on_times_10_Gain + rtb_vms); int tmp0 = brake_acc_nodiv_ctrl_P_ABS_FR_Wheel_times_10_Gain; int tmp1 = brake_acc_nodiv_ctrl_P_ABS_FR_Wheel_slip_abs_on_times_10_Gain + rtb_vms; if (tmp0 > tmp1) { rtb_RelationalOperator = true; } else { rtb_RelationalOperator = false; } /* Switch: '<S4>/Threshold_10km//h' */ // Lihao: lift int Threshold_10kmh_Threshold_local = brake_acc_nodiv_ctrl_P_ABS_FR_Wheel_Threshold_10kmh_Threshold; if (brake_acc_nodiv_ctrl_B_local_RT4 >= Threshold_10kmh_Threshold_local) { /* Outputs for Atomic SubSystem: '<S4>/If v>=10 km//h' */ /* Switch: '<S29>/LockDetect' incorporates: * Constant: '<S29>/ReleaseBrake' */ if (rtb_RelationalOperator) { brake_acc_nodiv_ctrl_B_local_ABS_FR_Wheel_Threshold_10kmh = brake_acc_nodiv_ctrl_P_ABS_FR_Wheel_ReleaseBrake_Value; } else { brake_acc_nodiv_ctrl_B_local_ABS_FR_Wheel_Threshold_10kmh = brake_acc_nodiv_ctrl_B_local_RT2; } /* End of Outputs for SubSystem: '<S4>/If v>=10 km//h' */ } else { /* Outputs for Atomic SubSystem: '<S4>/If v>=10 km//h' */ /* Switch: '<S29>/LockDetect' */ brake_acc_nodiv_ctrl_B_local_ABS_FR_Wheel_Threshold_10kmh = brake_acc_nodiv_ctrl_B_local_RT2; /* End of Outputs for SubSystem: '<S4>/If v>=10 km//h' */ } /* End of Switch: '<S4>/Threshold_10km//h' */ // end of inline /* Outport: '<Root>/Out_TQ_FRBrake' */ //brake_acc_nodiv_ctrl_Y_Out_TQ_FRBrake = // brake_acc_nodiv_ctrl_B_local_ABS_FR_Wheel_Threshold_10kmh; /* RateTransition: '<Root>/RT3' */ brake_acc_nodiv_ctrl_B_local_RT3 = RT3_Buffer0; /* End of RateTransition: '<Root>/RT3' */ /* RateTransition: '<Root>/RT11' */ RT11 = rtb_to_int_k; } void *task_RL_Wheel(void *unused) { test ++; //#if 0 //B_brake_acc_nodiv_ctrl_T brake_acc_nodiv_ctrl_B_local; /* Start for RateTransition: '<Root>/RT' */ brake_acc_nodiv_ctrl_B_local_RT_h = brake_acc_nodiv_ctrl_P_RT_X0; /* Start for RateTransition: '<Root>/RT4' */ brake_acc_nodiv_ctrl_B_local_RT4 = brake_acc_nodiv_ctrl_P_RT4_X0; /* Start for RateTransition: '<Root>/RT1' */ brake_acc_nodiv_ctrl_B_local_RT1 = brake_acc_nodiv_ctrl_P_RT1_X0; /* Start for RateTransition: '<Root>/RT2' */ brake_acc_nodiv_ctrl_B_local_RT2 = brake_acc_nodiv_ctrl_P_RT2_X0; /* Start for RateTransition: '<Root>/RT3' */ brake_acc_nodiv_ctrl_B_local_RT3 = brake_acc_nodiv_ctrl_P_RT3_X0; //#endif //B_brake_acc_nodiv_ctrl_T brake_acc_nodiv_ctrl_B_local = brake_acc_nodiv_ctrl_B; //brake_acc_nodiv_ctrl_step1 // the following code is from this function int rtb_to_int_g; /* RateTransition: '<Root>/RT' */ brake_acc_nodiv_ctrl_B_local_RT_h = RT_Buffer0; /* RateTransition: '<Root>/RT4' */ brake_acc_nodiv_ctrl_B_local_RT4 = RT4_Buffer0; rtb_to_int_g = brake_acc_nodiv_ctrl_U_In_RLRotation; /* local block i/o variables */ bool rtb_RelationalOperator; int rtb_vms; int u; rtb_vms = brake_acc_nodiv_ctrl_P_ABS_RL_Wheel_vms_Gain + brake_acc_nodiv_ctrl_B_local_RT4; u = rtb_vms + brake_acc_nodiv_ctrl_P_ABS_RL_Wheel_wheSpdms_Gain; u = u + rtb_to_int_g; int positive_UpperSat_local = brake_acc_nodiv_ctrl_P_ABS_RL_Wheel_positive_UpperSat; if (u >= positive_UpperSat_local) { u = brake_acc_nodiv_ctrl_P_ABS_RL_Wheel_positive_UpperSat; } else { int positive_LowerSat_local = brake_acc_nodiv_ctrl_P_ABS_RL_Wheel_positive_LowerSat; if (u <= positive_LowerSat_local) { u = brake_acc_nodiv_ctrl_P_ABS_RL_Wheel_positive_LowerSat; } } /* RelationalOperator: '<S29>/Relational Operator' incorporates: * Gain: '<S29>/slip_abs_on_times_10' * Gain: '<S29>/times_10' * Saturate: '<S29>/positive' */ //rtb_RelationalOperator = (brake_acc_nodiv_ctrl_P_ABS_RL_Wheel_times_10_Gain + u > //brake_acc_nodiv_ctrl_P_ABS_RL_Wheel_slip_abs_on_times_10_Gain + rtb_vms); int tmp0 = brake_acc_nodiv_ctrl_P_ABS_RL_Wheel_times_10_Gain; int tmp1 = brake_acc_nodiv_ctrl_P_ABS_RL_Wheel_slip_abs_on_times_10_Gain + rtb_vms; if (tmp0 > tmp1) { rtb_RelationalOperator = true; } else { rtb_RelationalOperator = false; } /* Switch: '<S4>/Threshold_10km//h' */ // Lihao: lift int Threshold_10kmh_Threshold_local = brake_acc_nodiv_ctrl_P_ABS_RL_Wheel_Threshold_10kmh_Threshold; if (brake_acc_nodiv_ctrl_B_local_RT4 >= Threshold_10kmh_Threshold_local) { /* Outputs for Atomic SubSystem: '<S4>/If v>=10 km//h' */ /* Switch: '<S29>/LockDetect' incorporates: * Constant: '<S29>/ReleaseBrake' */ if (rtb_RelationalOperator) { brake_acc_nodiv_ctrl_B_local_ABS_RL_Wheel_Threshold_10kmh = brake_acc_nodiv_ctrl_P_ABS_RL_Wheel_ReleaseBrake_Value; } else { brake_acc_nodiv_ctrl_B_local_ABS_RL_Wheel_Threshold_10kmh = brake_acc_nodiv_ctrl_B_local_RT1; } /* End of Outputs for SubSystem: '<S4>/If v>=10 km//h' */ } else { /* Outputs for Atomic SubSystem: '<S4>/If v>=10 km//h' */ /* Switch: '<S29>/LockDetect' */ brake_acc_nodiv_ctrl_B_local_ABS_RL_Wheel_Threshold_10kmh = brake_acc_nodiv_ctrl_B_local_RT1; /* End of Outputs for SubSystem: '<S4>/If v>=10 km//h' */ } /* End of Switch: '<S4>/Threshold_10km//h' */ // end of inline /* Outport: '<Root>/Out_TQ_RLBrake' */ //brake_acc_nodiv_ctrl_Y_Out_TQ_RLBrake = // brake_acc_nodiv_ctrl_B_local_ABS_RL_Wheel_Threshold_10kmh; /* RateTransition: '<Root>/RT2' */ brake_acc_nodiv_ctrl_B_local_RT2 = RT2_Buffer0; /* End of RateTransition: '<Root>/RT2' */ /* RateTransition: '<Root>/RT10' */ RT10 = rtb_to_int_g; } /* Function: main ============================================================= * * Abstract: * Execute model on a generic target such as a workstation_ */ int main(void) { //rt_InitModel(); //havocInputs(&brake_acc_nodiv_ctrl_U); test = 0; pthread_t t0, t1, t2, t3, t4; pthread_create(&t0, 0, task_compute, 0); pthread_create(&t1, 0, task_RR_Wheel, 0); pthread_create(&t2, 0, task_FL_Wheel, 0); //pthread_create(&t3, 0, task_FR_Wheel, 0); //pthread_create(&t4, 0, task_RL_Wheel, 0); return 0; //const int_T result = rt_TermModel(); //return result; } /* [EOF] rt_main_c */
the_stack_data/31389169.c
// Copyright (c) 2018, Ryo Currency Project // // Portions of this file are available under BSD-3 license. Please see ORIGINAL-LICENSE for details // All rights reserved. // // Authors and copyright holders give permission for following: // // 1. Redistribution and use in source and binary forms WITHOUT modification. // // 2. Modification of the source form for your own personal use. // // As long as the following conditions are met: // // 3. You must not distribute modified copies of the work to third parties. This includes // posting the work online, or hosting copies of the modified work for download. // // 4. Any derivative version of this work is also covered by this license, including point 8. // // 5. Neither the name of the copyright holders nor the names of the authors may be // used to endorse or promote products derived from this software without specific // prior written permission. // // 6. You agree that this licence is governed by and shall be construed in accordance // with the laws of England and Wales. // // 7. You agree to submit all disputes arising out of or in connection with this licence // to the exclusive jurisdiction of the Courts of England and Wales. // // Authors and copyright holders agree that: // // 8. This licence expires and the work covered by it is released into the // public domain on 1st of February 2019 // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // !! NB // Hash functions in this file were optimised to handle only 200 bytes long input. As such they // are not useable outside of PoW calculation. // // Optimisations made by https://github.com/BaseMax // /* * Based on followig implementations: * * BLAKE reference C implementation * Copyright (c) 2012 Jean-Philippe Aumasson <[email protected]> * To the extent possible under law, the author(s) have dedicated all copyright * and related and neighboring rights to this software to the public domain * worldwide. This software is distributed without any warranty. * * Groestl ANSI C code optimised for 32-bit machines * Author: Thomas Krinninger * * This work is based on the implementation of * Soeren S. Thomsen and Krystian Matusiewicz * * JH implementation by Wu Hongjun * * * Implementation of the Skein hash function. * Source code author: Doug Whiting, 2008. * This algorithm and source code is released to the public domain. */ #include <stdio.h> #include <stdint.h> #include <string.h> /////////////////////////////////////////////////////////////////////////////////////////////// ///// blake_hash /////////////////////////////////////////////////////////////////////////////////////////////// typedef struct { uint32_t h[8], s[4], t[2]; } blake_ctx; #define U8TO32(p) \ (((uint32_t)((p)[0]) << 24) | ((uint32_t)((p)[1]) << 16) | \ ((uint32_t)((p)[2]) << 8) | ((uint32_t)((p)[3]) )) #define U32TO8(p,v) \ (p)[0] = (uint8_t)((v) >> 24);(p)[1] = (uint8_t)((v) >> 16);\ (p)[2] = (uint8_t)((v) >> 8);(p)[3] = (uint8_t)((v) ); const uint8_t sigma[][16] = { { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}, {14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3}, {11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4}, { 7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8}, { 9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13}, { 2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9}, {12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11}, {13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10}, { 6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5}, {10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0}, { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}, {14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3}, {11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4}, { 7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8} }; const uint32_t cst[16] = { 0x243F6A88,0x85A308D3,0x13198A2E,0x03707344, 0xA4093822,0x299F31D0,0x082EFA98,0xEC4E6C89, 0x452821E6,0x38D01377,0xBE5466CF,0x34E90C6C, 0xC0AC29B7,0xC97C50DD,0x3F84D5B5,0xB5470917 }; void blake256_compress(blake_ctx* S,const uint8_t* block) { uint32_t v[16],m[16],i; #define ROT(x,n) (((x)<<(32-n))|((x)>>(n))) #define G(a,b,c,d,e) \ v[a] += (m[sigma[i][e]] ^ cst[sigma[i][e+1]]) + v[b];\ v[d] = ROT(v[d] ^ v[a],16); \ v[c] += v[d]; \ v[b] = ROT(v[b] ^ v[c],12); \ v[a] += (m[sigma[i][e+1]] ^ cst[sigma[i][e]])+v[b]; \ v[d] = ROT(v[d] ^ v[a],8); \ v[c] += v[d]; \ v[b] = ROT(v[b] ^ v[c],7); for(i = 0;i < 16;++i) m[i] = U8TO32(block + i * 4); for(i = 0;i < 8; ++i) v[i] = S->h[i]; v[8] = S->s[0] ^ 0x243F6A88; v[9] = S->s[1] ^ 0x85A308D3; v[10] = S->s[2] ^ 0x13198A2E; v[11] = S->s[3] ^ 0x03707344; v[12] = 0xA4093822; v[13] = 0x299F31D0; v[14] = 0x082EFA98; v[15] = 0xEC4E6C89; v[12] ^= S->t[0]; v[13] ^= S->t[0]; v[14] ^= S->t[1]; v[15] ^= S->t[1]; for(i = 0;i < 14;++i) { G(0,4,8,12,0); G(1,5,9,13,2); G(2,6,10,14,4); G(3,7,11,15,6); G(3,4,9,14,14); G(2,7,8,13,12); G(0,5,10,15,8); G(1,6,11,12,10); } for(i = 0;i < 16;++i) S->h[i % 8] ^= v[i]; for(i = 0;i < 8;++i) S->h[i] ^= S->s[i % 4]; } void blake256_hash(const uint8_t* data,uint8_t* hashval) { blake_ctx S; S.h[0] = 0x6A09E667; S.h[1] = 0xBB67AE85; S.h[2] = 0x3C6EF372; S.h[3] = 0xA54FF53A; S.h[4] = 0x510E527F; S.h[5] = 0x9B05688C; S.h[6] = 0x1F83D9AB; S.h[7] = 0x5BE0CD19; S.t[0] = S.t[1] = 0; S.s[0] = S.s[1] = S.s[2] = S.s[3] = 0; S.t[0] += 512; blake256_compress(&S,data); data += 64; S.t[0] += 512; blake256_compress(&S,data); data += 64; S.t[0] += 512; blake256_compress(&S,data); data += 64; uint8_t buf[64]; memcpy(buf,data,8); memset(buf+8,0,48); buf[8] = 0x80; buf[55] = 0x01; S.t[0] += 64; U32TO8(buf+56,S.t[1]); U32TO8(buf+60,S.t[0]); blake256_compress(&S,buf); U32TO8(hashval + 0,S.h[0]); U32TO8(hashval + 4,S.h[1]); U32TO8(hashval + 8,S.h[2]); U32TO8(hashval + 12,S.h[3]); U32TO8(hashval + 16,S.h[4]); U32TO8(hashval + 20,S.h[5]); U32TO8(hashval + 24,S.h[6]); U32TO8(hashval + 28,S.h[7]); } /////////////////////////////////////////////////////////////////////////////////////////////// ///// groestl_hash /////////////////////////////////////////////////////////////////////////////////////////////// #define ROTL32(v, n) ((((v)<<(n))|((v)>>(32-(n))))&li_32(ffffffff)) #define li_32(h) 0x##h##u #define u32BIG(a)\ ((ROTL32(a,8) & li_32(00FF00FF)) |\ (ROTL32(a,24) & li_32(FF00FF00))) typedef struct { uint32_t chaining[16]; } groestl_ctx; const uint32_t T[512] = {0xa5f432c6, 0xc6a597f4, 0x84976ff8, 0xf884eb97, 0x99b05eee, 0xee99c7b0, 0x8d8c7af6, 0xf68df78c, 0xd17e8ff, 0xff0de517, 0xbddc0ad6, 0xd6bdb7dc, 0xb1c816de, 0xdeb1a7c8, 0x54fc6d91, 0x915439fc , 0x50f09060, 0x6050c0f0, 0x3050702, 0x2030405, 0xa9e02ece, 0xcea987e0, 0x7d87d156, 0x567dac87, 0x192bcce7, 0xe719d52b, 0x62a613b5, 0xb56271a6, 0xe6317c4d, 0x4de69a31, 0x9ab559ec, 0xec9ac3b5 , 0x45cf408f, 0x8f4505cf, 0x9dbca31f, 0x1f9d3ebc, 0x40c04989, 0x894009c0, 0x879268fa, 0xfa87ef92, 0x153fd0ef, 0xef15c53f, 0xeb2694b2, 0xb2eb7f26, 0xc940ce8e, 0x8ec90740, 0xb1de6fb, 0xfb0bed1d , 0xec2f6e41, 0x41ec822f, 0x67a91ab3, 0xb3677da9, 0xfd1c435f, 0x5ffdbe1c, 0xea256045, 0x45ea8a25, 0xbfdaf923, 0x23bf46da, 0xf7025153, 0x53f7a602, 0x96a145e4, 0xe496d3a1, 0x5bed769b, 0x9b5b2ded , 0xc25d2875, 0x75c2ea5d, 0x1c24c5e1, 0xe11cd924, 0xaee9d43d, 0x3dae7ae9, 0x6abef24c, 0x4c6a98be, 0x5aee826c, 0x6c5ad8ee, 0x41c3bd7e, 0x7e41fcc3, 0x206f3f5, 0xf502f106, 0x4fd15283, 0x834f1dd1 , 0x5ce48c68, 0x685cd0e4, 0xf4075651, 0x51f4a207, 0x345c8dd1, 0xd134b95c, 0x818e1f9, 0xf908e918, 0x93ae4ce2, 0xe293dfae, 0x73953eab, 0xab734d95, 0x53f59762, 0x6253c4f5, 0x3f416b2a, 0x2a3f5441 , 0xc141c08, 0x80c1014, 0x52f66395, 0x955231f6, 0x65afe946, 0x46658caf, 0x5ee27f9d, 0x9d5e21e2, 0x28784830, 0x30286078, 0xa1f8cf37, 0x37a16ef8, 0xf111b0a, 0xa0f1411, 0xb5c4eb2f, 0x2fb55ec4 , 0x91b150e, 0xe091c1b, 0x365a7e24, 0x2436485a, 0x9bb6ad1b, 0x1b9b36b6, 0x3d4798df, 0xdf3da547, 0x266aa7cd, 0xcd26816a, 0x69bbf54e, 0x4e699cbb, 0xcd4c337f, 0x7fcdfe4c, 0x9fba50ea, 0xea9fcfba , 0x1b2d3f12, 0x121b242d, 0x9eb9a41d, 0x1d9e3ab9, 0x749cc458, 0x5874b09c, 0x2e724634, 0x342e6872, 0x2d774136, 0x362d6c77, 0xb2cd11dc, 0xdcb2a3cd, 0xee299db4, 0xb4ee7329, 0xfb164d5b, 0x5bfbb616 , 0xf601a5a4, 0xa4f65301, 0x4dd7a176, 0x764decd7, 0x61a314b7, 0xb76175a3, 0xce49347d, 0x7dcefa49, 0x7b8ddf52, 0x527ba48d, 0x3e429fdd, 0xdd3ea142, 0x7193cd5e, 0x5e71bc93, 0x97a2b113, 0x139726a2 , 0xf504a2a6, 0xa6f55704, 0x68b801b9, 0xb96869b8, 0x0, 0x0, 0x2c74b5c1, 0xc12c9974, 0x60a0e040, 0x406080a0, 0x1f21c2e3, 0xe31fdd21, 0xc8433a79, 0x79c8f243, 0xed2c9ab6, 0xb6ed772c , 0xbed90dd4, 0xd4beb3d9, 0x46ca478d, 0x8d4601ca, 0xd9701767, 0x67d9ce70, 0x4bddaf72, 0x724be4dd, 0xde79ed94, 0x94de3379, 0xd467ff98, 0x98d42b67, 0xe82393b0, 0xb0e87b23, 0x4ade5b85, 0x854a11de , 0x6bbd06bb, 0xbb6b6dbd, 0x2a7ebbc5, 0xc52a917e, 0xe5347b4f, 0x4fe59e34, 0x163ad7ed, 0xed16c13a, 0xc554d286, 0x86c51754, 0xd762f89a, 0x9ad72f62, 0x55ff9966, 0x6655ccff, 0x94a7b611, 0x119422a7 , 0xcf4ac08a, 0x8acf0f4a, 0x1030d9e9, 0xe910c930, 0x60a0e04, 0x406080a, 0x819866fe, 0xfe81e798, 0xf00baba0, 0xa0f05b0b, 0x44ccb478, 0x7844f0cc, 0xbad5f025, 0x25ba4ad5, 0xe33e754b, 0x4be3963e , 0xf30eaca2, 0xa2f35f0e, 0xfe19445d, 0x5dfeba19, 0xc05bdb80, 0x80c01b5b, 0x8a858005, 0x58a0a85, 0xadecd33f, 0x3fad7eec, 0xbcdffe21, 0x21bc42df, 0x48d8a870, 0x7048e0d8, 0x40cfdf1, 0xf104f90c , 0xdf7a1963, 0x63dfc67a, 0xc1582f77, 0x77c1ee58, 0x759f30af, 0xaf75459f, 0x63a5e742, 0x426384a5, 0x30507020, 0x20304050, 0x1a2ecbe5, 0xe51ad12e, 0xe12effd, 0xfd0ee112, 0x6db708bf, 0xbf6d65b7 , 0x4cd45581, 0x814c19d4, 0x143c2418, 0x1814303c, 0x355f7926, 0x26354c5f, 0x2f71b2c3, 0xc32f9d71, 0xe13886be, 0xbee16738, 0xa2fdc835, 0x35a26afd, 0xcc4fc788, 0x88cc0b4f, 0x394b652e, 0x2e395c4b , 0x57f96a93, 0x93573df9, 0xf20d5855, 0x55f2aa0d, 0x829d61fc, 0xfc82e39d, 0x47c9b37a, 0x7a47f4c9, 0xacef27c8, 0xc8ac8bef, 0xe73288ba, 0xbae76f32, 0x2b7d4f32, 0x322b647d, 0x95a442e6, 0xe695d7a4 , 0xa0fb3bc0, 0xc0a09bfb, 0x98b3aa19, 0x199832b3, 0xd168f69e, 0x9ed12768, 0x7f8122a3, 0xa37f5d81, 0x66aaee44, 0x446688aa, 0x7e82d654, 0x547ea882, 0xabe6dd3b, 0x3bab76e6, 0x839e950b, 0xb83169e , 0xca45c98c, 0x8cca0345, 0x297bbcc7, 0xc729957b, 0xd36e056b, 0x6bd3d66e, 0x3c446c28, 0x283c5044, 0x798b2ca7, 0xa779558b, 0xe23d81bc, 0xbce2633d, 0x1d273116, 0x161d2c27, 0x769a37ad, 0xad76419a , 0x3b4d96db, 0xdb3bad4d, 0x56fa9e64, 0x6456c8fa, 0x4ed2a674, 0x744ee8d2, 0x1e223614, 0x141e2822, 0xdb76e492, 0x92db3f76, 0xa1e120c, 0xc0a181e, 0x6cb4fc48, 0x486c90b4, 0xe4378fb8, 0xb8e46b37 , 0x5de7789f, 0x9f5d25e7, 0x6eb20fbd, 0xbd6e61b2, 0xef2a6943, 0x43ef862a, 0xa6f135c4, 0xc4a693f1, 0xa8e3da39, 0x39a872e3, 0xa4f7c631, 0x31a462f7, 0x37598ad3, 0xd337bd59, 0x8b8674f2, 0xf28bff86 , 0x325683d5, 0xd532b156, 0x43c54e8b, 0x8b430dc5, 0x59eb856e, 0x6e59dceb, 0xb7c218da, 0xdab7afc2, 0x8c8f8e01, 0x18c028f, 0x64ac1db1, 0xb16479ac, 0xd26df19c, 0x9cd2236d, 0xe03b7249, 0x49e0923b , 0xb4c71fd8, 0xd8b4abc7, 0xfa15b9ac, 0xacfa4315, 0x709faf3, 0xf307fd09, 0x256fa0cf, 0xcf25856f, 0xafea20ca, 0xcaaf8fea, 0x8e897df4, 0xf48ef389, 0xe9206747, 0x47e98e20, 0x18283810, 0x10182028 , 0xd5640b6f, 0x6fd5de64, 0x888373f0, 0xf088fb83, 0x6fb1fb4a, 0x4a6f94b1, 0x7296ca5c, 0x5c72b896, 0x246c5438, 0x3824706c, 0xf1085f57, 0x57f1ae08, 0xc7522173, 0x73c7e652, 0x51f36497, 0x975135f3 , 0x2365aecb, 0xcb238d65, 0x7c8425a1, 0xa17c5984, 0x9cbf57e8, 0xe89ccbbf, 0x21635d3e, 0x3e217c63, 0xdd7cea96, 0x96dd377c, 0xdc7f1e61, 0x61dcc27f, 0x86919c0d, 0xd861a91, 0x85949b0f, 0xf851e94 , 0x90ab4be0, 0xe090dbab, 0x42c6ba7c, 0x7c42f8c6, 0xc4572671, 0x71c4e257, 0xaae529cc, 0xccaa83e5, 0xd873e390, 0x90d83b73, 0x50f0906, 0x6050c0f, 0x103f4f7, 0xf701f503, 0x12362a1c, 0x1c123836 , 0xa3fe3cc2, 0xc2a39ffe, 0x5fe18b6a, 0x6a5fd4e1, 0xf910beae, 0xaef94710, 0xd06b0269, 0x69d0d26b, 0x91a8bf17, 0x17912ea8, 0x58e87199, 0x995829e8, 0x2769533a, 0x3a277469, 0xb9d0f727, 0x27b94ed0 , 0x384891d9, 0xd938a948, 0x1335deeb, 0xeb13cd35, 0xb3cee52b, 0x2bb356ce, 0x33557722, 0x22334455, 0xbbd604d2, 0xd2bbbfd6, 0x709039a9, 0xa9704990, 0x89808707, 0x7890e80, 0xa7f2c133, 0x33a766f2 , 0xb6c1ec2d, 0x2db65ac1, 0x22665a3c, 0x3c227866, 0x92adb815, 0x15922aad, 0x2060a9c9, 0xc9208960, 0x49db5c87, 0x874915db, 0xff1ab0aa, 0xaaff4f1a, 0x7888d850, 0x5078a088, 0x7a8e2ba5, 0xa57a518e , 0x8f8a8903, 0x38f068a, 0xf8134a59, 0x59f8b213, 0x809b9209, 0x980129b, 0x1739231a, 0x1a173439, 0xda751065, 0x65daca75, 0x315384d7, 0xd731b553, 0xc651d584, 0x84c61351, 0xb8d303d0, 0xd0b8bbd3 , 0xc35edc82, 0x82c31f5e, 0xb0cbe229, 0x29b052cb, 0x7799c35a, 0x5a77b499, 0x11332d1e, 0x1e113c33, 0xcb463d7b, 0x7bcbf646, 0xfc1fb7a8, 0xa8fc4b1f, 0xd6610c6d, 0x6dd6da61, 0x3a4e622c, 0x2c3a584e}; #define ROTATE_COLUMN_DOWN(v1,v2,amount_bytes,temp_var)\ temp_var = (v1 << (8 * amount_bytes)) | (v2 >> (8 * (4 - amount_bytes)));\ v2 = (v2 << (8 * amount_bytes)) | (v1 >> (8 * (4 - amount_bytes)));\ v1 = temp_var; #define COLUMN(x,y,i,c0,c1,c2,c3,c4,c5,c6,c7,tv1,tv2,tu,tl,t)\ tu = T[2 * (uint32_t) x[4 * c0 + 0]];\ tl = T[2 * (uint32_t) x[4 * c0 + 0] + 1];\ tv1 = T[2 * (uint32_t) x[4 * c1 + 1]];\ tv2 = T[2 * (uint32_t) x[4 * c1 + 1] + 1];\ ROTATE_COLUMN_DOWN(tv1,tv2,1,t)\ tu ^= tv1;\ tl ^= tv2;\ tv1 = T[2 * (uint32_t) x[4 * c2 + 2]];\ tv2 = T[2 * (uint32_t) x[4 * c2 + 2] + 1];\ ROTATE_COLUMN_DOWN(tv1,tv2,2,t)\ tu ^= tv1;\ tl ^= tv2;\ tv1 = T[2 * (uint32_t) x[4 * c3 + 3]];\ tv2 = T[2 * (uint32_t) x[4 * c3 + 3] + 1];\ ROTATE_COLUMN_DOWN(tv1,tv2,3,t)\ tu ^= tv1;\ tl ^= tv2;\ tl ^= T[2 * (uint32_t) x[4 * c4 + 0]];\ tu ^= T[2 * (uint32_t) x[4 * c4 + 0] + 1];\ tv1 = T[2 * (uint32_t) x[4 * c5 + 1]];\ tv2 = T[2 * (uint32_t) x[4 * c5 + 1] + 1];\ ROTATE_COLUMN_DOWN(tv1,tv2,1,t)\ tl ^= tv1;\ tu ^= tv2;\ tv1 = T[2 * (uint32_t) x[4 * c6 + 2]];\ tv2 = T[2 * (uint32_t) x[4 * c6 + 2] + 1];\ ROTATE_COLUMN_DOWN(tv1,tv2,2,t)\ tl ^= tv1;\ tu ^= tv2;\ tv1 = T[2 * (uint32_t) x[4 * c7 + 3]];\ tv2 = T[2 * (uint32_t) x[4 * c7 + 3] + 1];\ ROTATE_COLUMN_DOWN(tv1,tv2,3,t)\ tl ^= tv1;\ tu ^= tv2;\ y[i] = tu;\ y[i + 1] = tl; static void RND512P(uint8_t* x,uint32_t* y,uint32_t r) { uint32_t temp_v1,temp_v2,temp_upper_value,temp_lower_value,temp; uint32_t* x32 = (uint32_t*) x; x32[0] ^= 0x00000000 ^ r; x32[2] ^= 0x00000010 ^ r; x32[4] ^= 0x00000020 ^ r; x32[6] ^= 0x00000030 ^ r; x32[8] ^= 0x00000040 ^ r; x32[10] ^= 0x00000050 ^ r; x32[12] ^= 0x00000060 ^ r; x32[14] ^= 0x00000070 ^ r; COLUMN(x,y,0,0,2,4,6,9,11,13,15,temp_v1,temp_v2,temp_upper_value,temp_lower_value,temp); COLUMN(x,y,2,2,4,6,8,11,13,15,1,temp_v1,temp_v2,temp_upper_value,temp_lower_value,temp); COLUMN(x,y,4,4,6,8,10,13,15,1,3,temp_v1,temp_v2,temp_upper_value,temp_lower_value,temp); COLUMN(x,y,6,6,8,10,12,15,1,3,5,temp_v1,temp_v2,temp_upper_value,temp_lower_value,temp); COLUMN(x,y,8,8,10,12,14,1,3,5,7,temp_v1,temp_v2,temp_upper_value,temp_lower_value,temp); COLUMN(x,y,10,10,12,14,0,3,5,7,9,temp_v1,temp_v2,temp_upper_value,temp_lower_value,temp); COLUMN(x,y,12,12,14,0,2,5,7,9,11,temp_v1,temp_v2,temp_upper_value,temp_lower_value,temp); COLUMN(x,y,14,14,0,2,4,7,9,11,13,temp_v1,temp_v2,temp_upper_value,temp_lower_value,temp); } static void RND512Q(uint8_t* x,uint32_t* y,uint32_t r) { uint32_t temp_v1,temp_v2,temp_upper_value,temp_lower_value,temp; uint32_t*x32 = (uint32_t*) x; x32[0] = ~x32[0]; x32[1] ^= 0xffffffff ^ r; x32[2] = ~x32[2]; x32[3] ^= 0xefffffff ^ r; x32[4] = ~x32[4]; x32[5] ^= 0xdfffffff ^ r; x32[6] = ~x32[6]; x32[7] ^= 0xcfffffff ^ r; x32[8] = ~x32[8]; x32[9] ^= 0xbfffffff ^ r; x32[10] = ~x32[10]; x32[11] ^= 0xafffffff ^ r; x32[12] = ~x32[12]; x32[13] ^= 0x9fffffff ^ r; x32[14] = ~x32[14]; x32[15] ^= 0x8fffffff ^ r; COLUMN(x,y,0,2,6,10,14,1,5,9,13,temp_v1,temp_v2,temp_upper_value,temp_lower_value,temp); COLUMN(x,y,2,4,8,12,0,3,7,11,15,temp_v1,temp_v2,temp_upper_value,temp_lower_value,temp); COLUMN(x,y,4,6,10,14,2,5,9,13,1,temp_v1,temp_v2,temp_upper_value,temp_lower_value,temp); COLUMN(x,y,6,8,12,0,4,7,11,15,3,temp_v1,temp_v2,temp_upper_value,temp_lower_value,temp); COLUMN(x,y,8,10,14,2,6,9,13,1,5,temp_v1,temp_v2,temp_upper_value,temp_lower_value,temp); COLUMN(x,y,10,12,0,4,8,11,15,3,7,temp_v1,temp_v2,temp_upper_value,temp_lower_value,temp); COLUMN(x,y,12,14,2,6,10,13,1,5,9,temp_v1,temp_v2,temp_upper_value,temp_lower_value,temp); COLUMN(x,y,14,0,4,8,12,15,3,7,11,temp_v1,temp_v2,temp_upper_value,temp_lower_value,temp); } static void Transform(groestl_ctx* ctx,const uint8_t* input,int msglen) { for(; msglen >= 64; msglen -= 64,input += 64) { uint32_t Ptmp[16]; uint32_t Qtmp[16]; uint32_t y[16]; uint32_t z[16]; z[0] = ((uint32_t*) input)[0]; Ptmp[0] = ctx->chaining[0] ^ ((uint32_t*) input)[0]; z[1] = ((uint32_t*) input)[1]; Ptmp[1] = ctx->chaining[1] ^ ((uint32_t*) input)[1]; z[2] = ((uint32_t*) input)[2]; Ptmp[2] = ctx->chaining[2] ^ ((uint32_t*) input)[2]; z[3] = ((uint32_t*) input)[3]; Ptmp[3] = ctx->chaining[3] ^ ((uint32_t*) input)[3]; z[4] = ((uint32_t*) input)[4]; Ptmp[4] = ctx->chaining[4] ^ ((uint32_t*) input)[4]; z[5] = ((uint32_t*) input)[5]; Ptmp[5] = ctx->chaining[5] ^ ((uint32_t*) input)[5]; z[6] = ((uint32_t*) input)[6]; Ptmp[6] = ctx->chaining[6] ^ ((uint32_t*) input)[6]; z[7] = ((uint32_t*) input)[7]; Ptmp[7] = ctx->chaining[7] ^ ((uint32_t*) input)[7]; z[8] = ((uint32_t*) input)[8]; Ptmp[8] = ctx->chaining[8] ^ ((uint32_t*) input)[8]; z[9] = ((uint32_t*) input)[9]; Ptmp[9] = ctx->chaining[9] ^ ((uint32_t*) input)[9]; z[10] = ((uint32_t*) input)[10]; Ptmp[10] = ctx->chaining[10] ^ ((uint32_t*) input)[10]; z[11] = ((uint32_t*) input)[11]; Ptmp[11] = ctx->chaining[11] ^ ((uint32_t*) input)[11]; z[12] = ((uint32_t*) input)[12]; Ptmp[12] = ctx->chaining[12] ^ ((uint32_t*) input)[12]; z[13] = ((uint32_t*) input)[13]; Ptmp[13] = ctx->chaining[13] ^ ((uint32_t*) input)[13]; z[14] = ((uint32_t*) input)[14]; Ptmp[14] = ctx->chaining[14] ^ ((uint32_t*) input)[14]; z[15] = ((uint32_t*) input)[15]; Ptmp[15] = ctx->chaining[15] ^ ((uint32_t*) input)[15]; RND512Q((uint8_t*) z,y,0x00000000); RND512Q((uint8_t*) y,z,0x01000000); RND512Q((uint8_t*) z,y,0x02000000); RND512Q((uint8_t*) y,z,0x03000000); RND512Q((uint8_t*) z,y,0x04000000); RND512Q((uint8_t*) y,z,0x05000000); RND512Q((uint8_t*) z,y,0x06000000); RND512Q((uint8_t*) y,z,0x07000000); RND512Q((uint8_t*) z,y,0x08000000); RND512Q((uint8_t*) y,Qtmp,0x09000000); RND512P((uint8_t*) Ptmp,y,0x00000000); RND512P((uint8_t*) y,z,0x00000001); RND512P((uint8_t*) z,y,0x00000002); RND512P((uint8_t*) y,z,0x00000003); RND512P((uint8_t*) z,y,0x00000004); RND512P((uint8_t*) y,z,0x00000005); RND512P((uint8_t*) z,y,0x00000006); RND512P((uint8_t*) y,z,0x00000007); RND512P((uint8_t*) z,y,0x00000008); RND512P((uint8_t*) y,Ptmp,0x00000009); ctx->chaining[0] ^= Ptmp[0] ^ Qtmp[0]; ctx->chaining[1] ^= Ptmp[1] ^ Qtmp[1]; ctx->chaining[2] ^= Ptmp[2] ^ Qtmp[2]; ctx->chaining[3] ^= Ptmp[3] ^ Qtmp[3]; ctx->chaining[4] ^= Ptmp[4] ^ Qtmp[4]; ctx->chaining[5] ^= Ptmp[5] ^ Qtmp[5]; ctx->chaining[6] ^= Ptmp[6] ^ Qtmp[6]; ctx->chaining[7] ^= Ptmp[7] ^ Qtmp[7]; ctx->chaining[8] ^= Ptmp[8] ^ Qtmp[8]; ctx->chaining[9] ^= Ptmp[9] ^ Qtmp[9]; ctx->chaining[10] ^= Ptmp[10] ^ Qtmp[10]; ctx->chaining[11] ^= Ptmp[11] ^ Qtmp[11]; ctx->chaining[12] ^= Ptmp[12] ^ Qtmp[12]; ctx->chaining[13] ^= Ptmp[13] ^ Qtmp[13]; ctx->chaining[14] ^= Ptmp[14] ^ Qtmp[14]; ctx->chaining[15] ^= Ptmp[15] ^ Qtmp[15]; } } void groestl_hash(const uint8_t* data,uint8_t* hashval) { groestl_ctx context; memset(context.chaining, 0, 60); context.chaining[15] = u32BIG((uint32_t) 256); Transform(&context,data,200); uint8_t buf[64]; memcpy(buf,data+192,8); memset(buf+8,0,56); buf[8] = 0x80; buf[63] = 4; Transform(&context,buf,64); uint32_t temp[16]; uint32_t y[16]; uint32_t z[16]; memcpy(temp, context.chaining, 64); RND512P((uint8_t*) temp,y,0x00000000); RND512P((uint8_t*) y,z,0x00000001); RND512P((uint8_t*) z,y,0x00000002); RND512P((uint8_t*) y,z,0x00000003); RND512P((uint8_t*) z,y,0x00000004); RND512P((uint8_t*) y,z,0x00000005); RND512P((uint8_t*) z,y,0x00000006); RND512P((uint8_t*) y,z,0x00000007); RND512P((uint8_t*) z,y,0x00000008); RND512P((uint8_t*) y,temp,0x00000009); context.chaining[8] ^= temp[8]; context.chaining[9] ^= temp[9]; context.chaining[10] ^= temp[10]; context.chaining[11] ^= temp[11]; context.chaining[12] ^= temp[12]; context.chaining[13] ^= temp[13]; context.chaining[14] ^= temp[14]; context.chaining[15] ^= temp[15]; memcpy(hashval, context.chaining+8, 32); } /////////////////////////////////////////////////////////////////////////////////////////////// ///// jh_hash /////////////////////////////////////////////////////////////////////////////////////////////// #if defined(__GNUC__) #define DATA_ALIGN16(x) x __attribute__ ((aligned(16))) #else #define DATA_ALIGN16(x) __declspec(align(16)) x #endif typedef struct { DATA_ALIGN16(uint64_t x[8][2]); } jh_ctx; const unsigned char JH256_H0[128]={0xeb,0x98,0xa3,0x41,0x2c,0x20,0xd3,0xeb,0x92,0xcd,0xbe,0x7b,0x9c,0xb2,0x45,0xc1,0x1c,0x93,0x51,0x91,0x60,0xd4,0xc7,0xfa,0x26,0x0,0x82,0xd6,0x7e,0x50,0x8a,0x3,0xa4,0x23,0x9e,0x26,0x77,0x26,0xb9,0x45,0xe0,0xfb,0x1a,0x48,0xd4,0x1a,0x94,0x77,0xcd,0xb5,0xab,0x26,0x2,0x6b,0x17,0x7a,0x56,0xf0,0x24,0x42,0xf,0xff,0x2f,0xa8,0x71,0xa3,0x96,0x89,0x7f,0x2e,0x4d,0x75,0x1d,0x14,0x49,0x8,0xf7,0x7d,0xe2,0x62,0x27,0x76,0x95,0xf7,0x76,0x24,0x8f,0x94,0x87,0xd5,0xb6,0x57,0x47,0x80,0x29,0x6c,0x5c,0x5e,0x27,0x2d,0xac,0x8e,0xd,0x6c,0x51,0x84,0x50,0xc6,0x57,0x5,0x7a,0xf,0x7b,0xe4,0xd3,0x67,0x70,0x24,0x12,0xea,0x89,0xe3,0xab,0x13,0xd3,0x1c,0xd7,0x69}; const unsigned char E8_bitslice_roundconstant[42][32]={ {0x72,0xd5,0xde,0xa2,0xdf,0x15,0xf8,0x67,0x7b,0x84,0x15,0xa,0xb7,0x23,0x15,0x57,0x81,0xab,0xd6,0x90,0x4d,0x5a,0x87,0xf6,0x4e,0x9f,0x4f,0xc5,0xc3,0xd1,0x2b,0x40}, {0xea,0x98,0x3a,0xe0,0x5c,0x45,0xfa,0x9c,0x3,0xc5,0xd2,0x99,0x66,0xb2,0x99,0x9a,0x66,0x2,0x96,0xb4,0xf2,0xbb,0x53,0x8a,0xb5,0x56,0x14,0x1a,0x88,0xdb,0xa2,0x31}, {0x3,0xa3,0x5a,0x5c,0x9a,0x19,0xe,0xdb,0x40,0x3f,0xb2,0xa,0x87,0xc1,0x44,0x10,0x1c,0x5,0x19,0x80,0x84,0x9e,0x95,0x1d,0x6f,0x33,0xeb,0xad,0x5e,0xe7,0xcd,0xdc}, {0x10,0xba,0x13,0x92,0x2,0xbf,0x6b,0x41,0xdc,0x78,0x65,0x15,0xf7,0xbb,0x27,0xd0,0xa,0x2c,0x81,0x39,0x37,0xaa,0x78,0x50,0x3f,0x1a,0xbf,0xd2,0x41,0x0,0x91,0xd3}, {0x42,0x2d,0x5a,0xd,0xf6,0xcc,0x7e,0x90,0xdd,0x62,0x9f,0x9c,0x92,0xc0,0x97,0xce,0x18,0x5c,0xa7,0xb,0xc7,0x2b,0x44,0xac,0xd1,0xdf,0x65,0xd6,0x63,0xc6,0xfc,0x23}, {0x97,0x6e,0x6c,0x3,0x9e,0xe0,0xb8,0x1a,0x21,0x5,0x45,0x7e,0x44,0x6c,0xec,0xa8,0xee,0xf1,0x3,0xbb,0x5d,0x8e,0x61,0xfa,0xfd,0x96,0x97,0xb2,0x94,0x83,0x81,0x97}, {0x4a,0x8e,0x85,0x37,0xdb,0x3,0x30,0x2f,0x2a,0x67,0x8d,0x2d,0xfb,0x9f,0x6a,0x95,0x8a,0xfe,0x73,0x81,0xf8,0xb8,0x69,0x6c,0x8a,0xc7,0x72,0x46,0xc0,0x7f,0x42,0x14}, {0xc5,0xf4,0x15,0x8f,0xbd,0xc7,0x5e,0xc4,0x75,0x44,0x6f,0xa7,0x8f,0x11,0xbb,0x80,0x52,0xde,0x75,0xb7,0xae,0xe4,0x88,0xbc,0x82,0xb8,0x0,0x1e,0x98,0xa6,0xa3,0xf4}, {0x8e,0xf4,0x8f,0x33,0xa9,0xa3,0x63,0x15,0xaa,0x5f,0x56,0x24,0xd5,0xb7,0xf9,0x89,0xb6,0xf1,0xed,0x20,0x7c,0x5a,0xe0,0xfd,0x36,0xca,0xe9,0x5a,0x6,0x42,0x2c,0x36}, {0xce,0x29,0x35,0x43,0x4e,0xfe,0x98,0x3d,0x53,0x3a,0xf9,0x74,0x73,0x9a,0x4b,0xa7,0xd0,0xf5,0x1f,0x59,0x6f,0x4e,0x81,0x86,0xe,0x9d,0xad,0x81,0xaf,0xd8,0x5a,0x9f}, {0xa7,0x5,0x6,0x67,0xee,0x34,0x62,0x6a,0x8b,0xb,0x28,0xbe,0x6e,0xb9,0x17,0x27,0x47,0x74,0x7,0x26,0xc6,0x80,0x10,0x3f,0xe0,0xa0,0x7e,0x6f,0xc6,0x7e,0x48,0x7b}, {0xd,0x55,0xa,0xa5,0x4a,0xf8,0xa4,0xc0,0x91,0xe3,0xe7,0x9f,0x97,0x8e,0xf1,0x9e,0x86,0x76,0x72,0x81,0x50,0x60,0x8d,0xd4,0x7e,0x9e,0x5a,0x41,0xf3,0xe5,0xb0,0x62}, {0xfc,0x9f,0x1f,0xec,0x40,0x54,0x20,0x7a,0xe3,0xe4,0x1a,0x0,0xce,0xf4,0xc9,0x84,0x4f,0xd7,0x94,0xf5,0x9d,0xfa,0x95,0xd8,0x55,0x2e,0x7e,0x11,0x24,0xc3,0x54,0xa5}, {0x5b,0xdf,0x72,0x28,0xbd,0xfe,0x6e,0x28,0x78,0xf5,0x7f,0xe2,0xf,0xa5,0xc4,0xb2,0x5,0x89,0x7c,0xef,0xee,0x49,0xd3,0x2e,0x44,0x7e,0x93,0x85,0xeb,0x28,0x59,0x7f}, {0x70,0x5f,0x69,0x37,0xb3,0x24,0x31,0x4a,0x5e,0x86,0x28,0xf1,0x1d,0xd6,0xe4,0x65,0xc7,0x1b,0x77,0x4,0x51,0xb9,0x20,0xe7,0x74,0xfe,0x43,0xe8,0x23,0xd4,0x87,0x8a}, {0x7d,0x29,0xe8,0xa3,0x92,0x76,0x94,0xf2,0xdd,0xcb,0x7a,0x9,0x9b,0x30,0xd9,0xc1,0x1d,0x1b,0x30,0xfb,0x5b,0xdc,0x1b,0xe0,0xda,0x24,0x49,0x4f,0xf2,0x9c,0x82,0xbf}, {0xa4,0xe7,0xba,0x31,0xb4,0x70,0xbf,0xff,0xd,0x32,0x44,0x5,0xde,0xf8,0xbc,0x48,0x3b,0xae,0xfc,0x32,0x53,0xbb,0xd3,0x39,0x45,0x9f,0xc3,0xc1,0xe0,0x29,0x8b,0xa0}, {0xe5,0xc9,0x5,0xfd,0xf7,0xae,0x9,0xf,0x94,0x70,0x34,0x12,0x42,0x90,0xf1,0x34,0xa2,0x71,0xb7,0x1,0xe3,0x44,0xed,0x95,0xe9,0x3b,0x8e,0x36,0x4f,0x2f,0x98,0x4a}, {0x88,0x40,0x1d,0x63,0xa0,0x6c,0xf6,0x15,0x47,0xc1,0x44,0x4b,0x87,0x52,0xaf,0xff,0x7e,0xbb,0x4a,0xf1,0xe2,0xa,0xc6,0x30,0x46,0x70,0xb6,0xc5,0xcc,0x6e,0x8c,0xe6}, {0xa4,0xd5,0xa4,0x56,0xbd,0x4f,0xca,0x0,0xda,0x9d,0x84,0x4b,0xc8,0x3e,0x18,0xae,0x73,0x57,0xce,0x45,0x30,0x64,0xd1,0xad,0xe8,0xa6,0xce,0x68,0x14,0x5c,0x25,0x67}, {0xa3,0xda,0x8c,0xf2,0xcb,0xe,0xe1,0x16,0x33,0xe9,0x6,0x58,0x9a,0x94,0x99,0x9a,0x1f,0x60,0xb2,0x20,0xc2,0x6f,0x84,0x7b,0xd1,0xce,0xac,0x7f,0xa0,0xd1,0x85,0x18}, {0x32,0x59,0x5b,0xa1,0x8d,0xdd,0x19,0xd3,0x50,0x9a,0x1c,0xc0,0xaa,0xa5,0xb4,0x46,0x9f,0x3d,0x63,0x67,0xe4,0x4,0x6b,0xba,0xf6,0xca,0x19,0xab,0xb,0x56,0xee,0x7e}, {0x1f,0xb1,0x79,0xea,0xa9,0x28,0x21,0x74,0xe9,0xbd,0xf7,0x35,0x3b,0x36,0x51,0xee,0x1d,0x57,0xac,0x5a,0x75,0x50,0xd3,0x76,0x3a,0x46,0xc2,0xfe,0xa3,0x7d,0x70,0x1}, {0xf7,0x35,0xc1,0xaf,0x98,0xa4,0xd8,0x42,0x78,0xed,0xec,0x20,0x9e,0x6b,0x67,0x79,0x41,0x83,0x63,0x15,0xea,0x3a,0xdb,0xa8,0xfa,0xc3,0x3b,0x4d,0x32,0x83,0x2c,0x83}, {0xa7,0x40,0x3b,0x1f,0x1c,0x27,0x47,0xf3,0x59,0x40,0xf0,0x34,0xb7,0x2d,0x76,0x9a,0xe7,0x3e,0x4e,0x6c,0xd2,0x21,0x4f,0xfd,0xb8,0xfd,0x8d,0x39,0xdc,0x57,0x59,0xef}, {0x8d,0x9b,0xc,0x49,0x2b,0x49,0xeb,0xda,0x5b,0xa2,0xd7,0x49,0x68,0xf3,0x70,0xd,0x7d,0x3b,0xae,0xd0,0x7a,0x8d,0x55,0x84,0xf5,0xa5,0xe9,0xf0,0xe4,0xf8,0x8e,0x65}, {0xa0,0xb8,0xa2,0xf4,0x36,0x10,0x3b,0x53,0xc,0xa8,0x7,0x9e,0x75,0x3e,0xec,0x5a,0x91,0x68,0x94,0x92,0x56,0xe8,0x88,0x4f,0x5b,0xb0,0x5c,0x55,0xf8,0xba,0xbc,0x4c}, {0xe3,0xbb,0x3b,0x99,0xf3,0x87,0x94,0x7b,0x75,0xda,0xf4,0xd6,0x72,0x6b,0x1c,0x5d,0x64,0xae,0xac,0x28,0xdc,0x34,0xb3,0x6d,0x6c,0x34,0xa5,0x50,0xb8,0x28,0xdb,0x71}, {0xf8,0x61,0xe2,0xf2,0x10,0x8d,0x51,0x2a,0xe3,0xdb,0x64,0x33,0x59,0xdd,0x75,0xfc,0x1c,0xac,0xbc,0xf1,0x43,0xce,0x3f,0xa2,0x67,0xbb,0xd1,0x3c,0x2,0xe8,0x43,0xb0}, {0x33,0xa,0x5b,0xca,0x88,0x29,0xa1,0x75,0x7f,0x34,0x19,0x4d,0xb4,0x16,0x53,0x5c,0x92,0x3b,0x94,0xc3,0xe,0x79,0x4d,0x1e,0x79,0x74,0x75,0xd7,0xb6,0xee,0xaf,0x3f}, {0xea,0xa8,0xd4,0xf7,0xbe,0x1a,0x39,0x21,0x5c,0xf4,0x7e,0x9,0x4c,0x23,0x27,0x51,0x26,0xa3,0x24,0x53,0xba,0x32,0x3c,0xd2,0x44,0xa3,0x17,0x4a,0x6d,0xa6,0xd5,0xad}, {0xb5,0x1d,0x3e,0xa6,0xaf,0xf2,0xc9,0x8,0x83,0x59,0x3d,0x98,0x91,0x6b,0x3c,0x56,0x4c,0xf8,0x7c,0xa1,0x72,0x86,0x60,0x4d,0x46,0xe2,0x3e,0xcc,0x8,0x6e,0xc7,0xf6}, {0x2f,0x98,0x33,0xb3,0xb1,0xbc,0x76,0x5e,0x2b,0xd6,0x66,0xa5,0xef,0xc4,0xe6,0x2a,0x6,0xf4,0xb6,0xe8,0xbe,0xc1,0xd4,0x36,0x74,0xee,0x82,0x15,0xbc,0xef,0x21,0x63}, {0xfd,0xc1,0x4e,0xd,0xf4,0x53,0xc9,0x69,0xa7,0x7d,0x5a,0xc4,0x6,0x58,0x58,0x26,0x7e,0xc1,0x14,0x16,0x6,0xe0,0xfa,0x16,0x7e,0x90,0xaf,0x3d,0x28,0x63,0x9d,0x3f}, {0xd2,0xc9,0xf2,0xe3,0x0,0x9b,0xd2,0xc,0x5f,0xaa,0xce,0x30,0xb7,0xd4,0xc,0x30,0x74,0x2a,0x51,0x16,0xf2,0xe0,0x32,0x98,0xd,0xeb,0x30,0xd8,0xe3,0xce,0xf8,0x9a}, {0x4b,0xc5,0x9e,0x7b,0xb5,0xf1,0x79,0x92,0xff,0x51,0xe6,0x6e,0x4,0x86,0x68,0xd3,0x9b,0x23,0x4d,0x57,0xe6,0x96,0x67,0x31,0xcc,0xe6,0xa6,0xf3,0x17,0xa,0x75,0x5}, {0xb1,0x76,0x81,0xd9,0x13,0x32,0x6c,0xce,0x3c,0x17,0x52,0x84,0xf8,0x5,0xa2,0x62,0xf4,0x2b,0xcb,0xb3,0x78,0x47,0x15,0x47,0xff,0x46,0x54,0x82,0x23,0x93,0x6a,0x48}, {0x38,0xdf,0x58,0x7,0x4e,0x5e,0x65,0x65,0xf2,0xfc,0x7c,0x89,0xfc,0x86,0x50,0x8e,0x31,0x70,0x2e,0x44,0xd0,0xb,0xca,0x86,0xf0,0x40,0x9,0xa2,0x30,0x78,0x47,0x4e}, {0x65,0xa0,0xee,0x39,0xd1,0xf7,0x38,0x83,0xf7,0x5e,0xe9,0x37,0xe4,0x2c,0x3a,0xbd,0x21,0x97,0xb2,0x26,0x1,0x13,0xf8,0x6f,0xa3,0x44,0xed,0xd1,0xef,0x9f,0xde,0xe7}, {0x8b,0xa0,0xdf,0x15,0x76,0x25,0x92,0xd9,0x3c,0x85,0xf7,0xf6,0x12,0xdc,0x42,0xbe,0xd8,0xa7,0xec,0x7c,0xab,0x27,0xb0,0x7e,0x53,0x8d,0x7d,0xda,0xaa,0x3e,0xa8,0xde}, {0xaa,0x25,0xce,0x93,0xbd,0x2,0x69,0xd8,0x5a,0xf6,0x43,0xfd,0x1a,0x73,0x8,0xf9,0xc0,0x5f,0xef,0xda,0x17,0x4a,0x19,0xa5,0x97,0x4d,0x66,0x33,0x4c,0xfd,0x21,0x6a}, {0x35,0xb4,0x98,0x31,0xdb,0x41,0x15,0x70,0xea,0x1e,0xf,0xbb,0xed,0xcd,0x54,0x9b,0x9a,0xd0,0x63,0xa1,0x51,0x97,0x40,0x72,0xf6,0x75,0x9d,0xbf,0x91,0x47,0x6f,0xe2}}; #define SWAP1(x) (x) = ((((x) & 0x5555555555555555ULL) << 1) | (((x) & 0xaaaaaaaaaaaaaaaaULL) >> 1)); #define SWAP2(x) (x) = ((((x) & 0x3333333333333333ULL) << 2) | (((x) & 0xccccccccccccccccULL) >> 2)); #define SWAP4(x) (x) = ((((x) & 0x0f0f0f0f0f0f0f0fULL) << 4) | (((x) & 0xf0f0f0f0f0f0f0f0ULL) >> 4)); #define SWAP8(x) (x) = ((((x) & 0x00ff00ff00ff00ffULL) << 8) | (((x) & 0xff00ff00ff00ff00ULL) >> 8)); #define SWAP16(x) (x) = ((((x) & 0x0000ffff0000ffffULL) << 16) | (((x) & 0xffff0000ffff0000ULL) >> 16)); #define SWAP32(x) (x) = (((x) << 32) | ((x) >> 32)); #define L(m0,m1,m2,m3,m4,m5,m6,m7) \ (m4) ^= (m1); \ (m5) ^= (m2); \ (m6) ^= (m0) ^ (m3); \ (m7) ^= (m0); \ (m0) ^= (m5); \ (m1) ^= (m6); \ (m2) ^= (m4) ^ (m7); \ (m3) ^= (m4); #define SS(m0,m1,m2,m3,m4,m5,m6,m7,cc0,cc1) \ m3 = ~(m3); \ m7 = ~(m7); \ m0 ^= ((~(m2)) & (cc0)); \ m4 ^= ((~(m6)) & (cc1)); \ temp0 = (cc0) ^ ((m0) & (m1));\ temp1 = (cc1) ^ ((m4) & (m5));\ m0 ^= ((m2) & (m3)); \ m4 ^= ((m6) & (m7)); \ m3 ^= ((~(m1)) & (m2)); \ m7 ^= ((~(m5)) & (m6)); \ m1 ^= ((m0) & (m2)); \ m5 ^= ((m4) & (m6)); \ m2 ^= ((m0) & (~(m3))); \ m6 ^= ((m4) & (~(m7))); \ m0 ^= ((m1) | (m3)); \ m4 ^= ((m5) | (m7)); \ m3 ^= ((m1) & (m2)); \ m7 ^= ((m5) & (m6)); \ m1 ^= (temp0 & (m0)); \ m5 ^= (temp1 & (m4)); \ m2 ^= temp0; \ m6 ^= temp1; static void F8(jh_ctx* state, const uint8_t* buffer) { uint64_t i; for(i = 0;i < 8;i++) state->x[i >> 1][i & 1] ^= ((uint64_t*)buffer)[i]; uint64_t roundnumber,temp0,temp1; for(roundnumber = 0;roundnumber < 42;roundnumber = roundnumber+7) { for(i = 0;i < 2;i++) { SS(state->x[0][i],state->x[2][i],state->x[4][i],state->x[6][i],state->x[1][i],state->x[3][i],state->x[5][i],state->x[7][i],((uint64_t*)E8_bitslice_roundconstant[roundnumber+0])[i],((uint64_t*)E8_bitslice_roundconstant[roundnumber+0])[i+2] ); L(state->x[0][i],state->x[2][i],state->x[4][i],state->x[6][i],state->x[1][i],state->x[3][i],state->x[5][i],state->x[7][i]); SWAP1(state->x[1][i]);SWAP1(state->x[3][i]);SWAP1(state->x[5][i]);SWAP1(state->x[7][i]); } for(i = 0;i < 2;i++) { SS(state->x[0][i],state->x[2][i],state->x[4][i],state->x[6][i],state->x[1][i],state->x[3][i],state->x[5][i],state->x[7][i],((uint64_t*)E8_bitslice_roundconstant[roundnumber+1])[i],((uint64_t*)E8_bitslice_roundconstant[roundnumber+1])[i+2] ); L(state->x[0][i],state->x[2][i],state->x[4][i],state->x[6][i],state->x[1][i],state->x[3][i],state->x[5][i],state->x[7][i]); SWAP2(state->x[1][i]);SWAP2(state->x[3][i]);SWAP2(state->x[5][i]);SWAP2(state->x[7][i]); } for(i = 0;i < 2;i++) { SS(state->x[0][i],state->x[2][i],state->x[4][i],state->x[6][i],state->x[1][i],state->x[3][i],state->x[5][i],state->x[7][i],((uint64_t*)E8_bitslice_roundconstant[roundnumber+2])[i],((uint64_t*)E8_bitslice_roundconstant[roundnumber+2])[i+2] ); L(state->x[0][i],state->x[2][i],state->x[4][i],state->x[6][i],state->x[1][i],state->x[3][i],state->x[5][i],state->x[7][i]); SWAP4(state->x[1][i]);SWAP4(state->x[3][i]);SWAP4(state->x[5][i]);SWAP4(state->x[7][i]); } for(i = 0;i < 2;i++) { SS(state->x[0][i],state->x[2][i],state->x[4][i],state->x[6][i],state->x[1][i],state->x[3][i],state->x[5][i],state->x[7][i],((uint64_t*)E8_bitslice_roundconstant[roundnumber+3])[i],((uint64_t*)E8_bitslice_roundconstant[roundnumber+3])[i+2] ); L(state->x[0][i],state->x[2][i],state->x[4][i],state->x[6][i],state->x[1][i],state->x[3][i],state->x[5][i],state->x[7][i]); SWAP8(state->x[1][i]);SWAP8(state->x[3][i]);SWAP8(state->x[5][i]);SWAP8(state->x[7][i]); } for(i = 0;i < 2;i++) { SS(state->x[0][i],state->x[2][i],state->x[4][i],state->x[6][i],state->x[1][i],state->x[3][i],state->x[5][i],state->x[7][i],((uint64_t*)E8_bitslice_roundconstant[roundnumber+4])[i],((uint64_t*)E8_bitslice_roundconstant[roundnumber+4])[i+2] ); L(state->x[0][i],state->x[2][i],state->x[4][i],state->x[6][i],state->x[1][i],state->x[3][i],state->x[5][i],state->x[7][i]); SWAP16(state->x[1][i]);SWAP16(state->x[3][i]);SWAP16(state->x[5][i]);SWAP16(state->x[7][i]); } for(i = 0;i < 2;i++) { SS(state->x[0][i],state->x[2][i],state->x[4][i],state->x[6][i],state->x[1][i],state->x[3][i],state->x[5][i],state->x[7][i],((uint64_t*)E8_bitslice_roundconstant[roundnumber+5])[i],((uint64_t*)E8_bitslice_roundconstant[roundnumber+5])[i+2] ); L(state->x[0][i],state->x[2][i],state->x[4][i],state->x[6][i],state->x[1][i],state->x[3][i],state->x[5][i],state->x[7][i]); SWAP32(state->x[1][i]);SWAP32(state->x[3][i]);SWAP32(state->x[5][i]);SWAP32(state->x[7][i]); } for(i = 0;i < 2;i++) { SS(state->x[0][i],state->x[2][i],state->x[4][i],state->x[6][i],state->x[1][i],state->x[3][i],state->x[5][i],state->x[7][i],((uint64_t*)E8_bitslice_roundconstant[roundnumber+6])[i],((uint64_t*)E8_bitslice_roundconstant[roundnumber+6])[i+2] ); L(state->x[0][i],state->x[2][i],state->x[4][i],state->x[6][i],state->x[1][i],state->x[3][i],state->x[5][i],state->x[7][i]); } for(i = 1;i < 8;i = i+2) { temp0 = state->x[i][0];state->x[i][0] = state->x[i][1];state->x[i][1] = temp0; } } state->x[4][0] ^= ((uint64_t*)buffer)[0]; state->x[4][1] ^= ((uint64_t*)buffer)[1]; state->x[5][0] ^= ((uint64_t*)buffer)[2]; state->x[5][1] ^= ((uint64_t*)buffer)[3]; state->x[6][0] ^= ((uint64_t*)buffer)[4]; state->x[6][1] ^= ((uint64_t*)buffer)[5]; state->x[7][0] ^= ((uint64_t*)buffer)[6]; state->x[7][1] ^= ((uint64_t*)buffer)[7]; } void jh_hash(const uint8_t* data, uint8_t* hashval) { jh_ctx state; memcpy(state.x,JH256_H0,128); F8(&state, data); F8(&state, data+64); F8(&state, data+128); uint8_t buf[64]; memcpy(buf, data+192,8); memset(buf+8, 0, 56); buf[8] = 128; F8(&state, buf); memset(buf,0,12); buf[62] = 6; buf[63] = 64; F8(&state, buf); memcpy(hashval,(uint8_t*)state.x+96,32); } /////////////////////////////////////////////////////////////////////////////////////////////// ///// skein_hash /////////////////////////////////////////////////////////////////////////////////////////////// #define RotL_64(x,N) (((x) << (N)) | ((x) >> (64-(N)))) typedef struct { uint64_t T[2]; uint64_t X[8]; } skein_ctx; enum { R_512_0_0=46,R_512_0_1=36,R_512_0_2=19,R_512_0_3=37, R_512_1_0=33,R_512_1_1=27,R_512_1_2=14,R_512_1_3=42, R_512_2_0=17,R_512_2_1=49,R_512_2_2=36,R_512_2_3=39, R_512_3_0=44,R_512_3_1= 9,R_512_3_2=54,R_512_3_3=56, R_512_4_0=39,R_512_4_1=30,R_512_4_2=34,R_512_4_3=24, R_512_5_0=13,R_512_5_1=50,R_512_5_2=10,R_512_5_3=17, R_512_6_0=25,R_512_6_1=29,R_512_6_2=39,R_512_6_3=43, R_512_7_0= 8,R_512_7_1=35,R_512_7_2=56,R_512_7_3=22, }; const uint64_t SKEIN_512_IV_256[] = { 0xCCD044A12FDB3E13, 0xE83590301A79A9EB, 0x55AEA0614F816E6F, 0x2A2767A4AE9B94DB, 0xEC06025E74DD7683, 0xE7A436CDC4746251, 0xC36FBAF9393AD185, 0x3EEDBA1833EDFC13 }; #define ks (kw+3) #define ts (kw) static void Skein_512_Process_Block(skein_ctx* ctx,const uint8_t* blkPtr,size_t blkCnt,size_t byteCntAdd) { uint64_t kw[8+4]; uint64_t X0,X1,X2,X3,X4,X5,X6,X7; uint64_t w [8]; ts[0] = ctx->T[0]; ts[1] = ctx->T[1]; do { ts[0] += byteCntAdd; ks[0] = ctx->X[0]; ks[1] = ctx->X[1]; ks[2] = ctx->X[2]; ks[3] = ctx->X[3]; ks[4] = ctx->X[4]; ks[5] = ctx->X[5]; ks[6] = ctx->X[6]; ks[7] = ctx->X[7]; ks[8] = ks[0] ^ ks[1] ^ ks[2] ^ ks[3] ^ ks[4] ^ ks[5] ^ ks[6] ^ ks[7] ^ 2004413935125273122ull; ts[2] = ts[0] ^ ts[1]; for(size_t n=0;n<64;n+=8) w[n/8] = (((uint64_t) blkPtr[n ]) ) + (((uint64_t) blkPtr[n+1]) << 8) + (((uint64_t) blkPtr[n+2]) << 16) + (((uint64_t) blkPtr[n+3]) << 24) + (((uint64_t) blkPtr[n+4]) << 32) + (((uint64_t) blkPtr[n+5]) << 40) + (((uint64_t) blkPtr[n+6]) << 48) + (((uint64_t) blkPtr[n+7]) << 56) ; ctx->T[0] = ts[0]; ctx->T[1] = ts[1]; X0 = w[0] + ks[0]; X1 = w[1] + ks[1]; X2 = w[2] + ks[2]; X3 = w[3] + ks[3]; X4 = w[4] + ks[4]; X5 = w[5] + ks[5] + ts[0]; X6 = w[6] + ks[6] + ts[1]; X7 = w[7] + ks[7]; blkPtr += 64; #define Round512(p0,p1,p2,p3,p4,p5,p6,p7,ROT,rNum) \ X##p0 += X##p1; X##p1 = RotL_64(X##p1,ROT##_0); X##p1 ^= X##p0; \ X##p2 += X##p3; X##p3 = RotL_64(X##p3,ROT##_1); X##p3 ^= X##p2; \ X##p4 += X##p5; X##p5 = RotL_64(X##p5,ROT##_2); X##p5 ^= X##p4; \ X##p6 += X##p7; X##p7 = RotL_64(X##p7,ROT##_3); X##p7 ^= X##p6; #define R512(p0,p1,p2,p3,p4,p5,p6,p7,ROT,rNum) \ Round512(p0,p1,p2,p3,p4,p5,p6,p7,ROT,rNum) #define I512(R) \ X0 += ks[((R)+1) % 9]; \ X1 += ks[((R)+2) % 9]; \ X2 += ks[((R)+3) % 9]; \ X3 += ks[((R)+4) % 9]; \ X4 += ks[((R)+5) % 9]; \ X5 += ks[((R)+6) % 9] + ts[((R)+1) % 3]; \ X6 += ks[((R)+7) % 9] + ts[((R)+2) % 3]; \ X7 += ks[((R)+8) % 9] + (R)+1; { #define R512_8_rounds(R) \ R512(0,1,2,3,4,5,6,7,R_512_0,8*(R)+ 1); \ R512(2,1,4,7,6,5,0,3,R_512_1,8*(R)+ 2); \ R512(4,1,6,3,0,5,2,7,R_512_2,8*(R)+ 3); \ R512(6,1,0,7,2,5,4,3,R_512_3,8*(R)+ 4); \ I512(2*(R)); \ R512(0,1,2,3,4,5,6,7,R_512_4,8*(R)+ 5); \ R512(2,1,4,7,6,5,0,3,R_512_5,8*(R)+ 6); \ R512(4,1,6,3,0,5,2,7,R_512_6,8*(R)+ 7); \ R512(6,1,0,7,2,5,4,3,R_512_7,8*(R)+ 8); \ I512(2*(R)+1); R512_8_rounds(0); R512_8_rounds(1); R512_8_rounds(2); R512_8_rounds(3); R512_8_rounds(4); R512_8_rounds(5); R512_8_rounds(6); R512_8_rounds(7); R512_8_rounds(8); } ctx->X[0] = X0 ^ w[0]; ctx->X[1] = X1 ^ w[1]; ctx->X[2] = X2 ^ w[2]; ctx->X[3] = X3 ^ w[3]; ctx->X[4] = X4 ^ w[4]; ctx->X[5] = X5 ^ w[5]; ctx->X[6] = X6 ^ w[6]; ctx->X[7] = X7 ^ w[7]; ts[1] &= ~4611686018427387904ull; } while(--blkCnt); ctx->T[0] = ts[0]; ctx->T[1] = ts[1]; } void skein_hash(const uint8_t* data,uint8_t* hashval) { skein_ctx state; uint8_t b[64]; memcpy(state.X,SKEIN_512_IV_256,sizeof(state.X)); state.T[0] = 0; state.T[1] = 8070450532247928832ull; Skein_512_Process_Block(&state,data,3,64); memcpy(b,data+192,8); memset(b+8,0,56); state.T[1] |= 9223372036854775808ull; Skein_512_Process_Block(&state,b,1,8); memset(b,0,8); state.T[0] = 0; state.T[1] = 18374686479671623680ull; Skein_512_Process_Block(&state,b,1,sizeof(uint64_t)); memcpy(hashval, state.X, 32); }
the_stack_data/120622.c
// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - -fsanitize=unsigned-integer-overflow | FileCheck %s --check-prefix=UNSIGNED // RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - -ftrapv | FileCheck %s --check-prefix=TRAPV // RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - -fsanitize=unsigned-integer-overflow -ftrapv | FileCheck %s --check-prefix=BOTH // Verify that -ftrapv and -fsanitize=unsigned-integer-overflow // work together as expected // UNSIGNED: @test_signed // TRAPV: @test_signed // BOTH: @test_signed void test_signed(void) { extern volatile int a, b, c; // UNSIGNED: add nsw i32 // UNSIGNED-NOT: overflow // TRAPV: sadd.with.overflow.i32 // TRAPV-NOT: @__ubsan // TRAPV: llvm.ubsantrap // BOTH: sadd.with.overflow.i32 // BOTH-NOT: @__ubsan // BOTH: llvm.ubsantrap a = b + c; } // UNSIGNED: @test_unsigned // TRAPV: @test_unsigned // BOTH: @test_unsigned void test_unsigned(void) { extern volatile unsigned x, y, z; // UNSIGNED: uadd.with.overflow.i32 // UNSIGNED-NOT: llvm.trap // UNSIGNED: ubsan // TRAPV-NOT: overflow // TRAPV-NOT: llvm.trap // BOTH: uadd.with.overflow.i32 // BOTH: @__ubsan // BOTH-NOT: llvm.ubsantrap x = y + z; }
the_stack_data/184518196.c
/* gmtime - command line implementation of gmtime() C library function */ #include <stdio.h> #include <time.h> #include <unistd.h> #include <stdlib.h> void usage() { fprintf(stderr,"gmtime - convert unix timestamp to date string\n"); fprintf(stderr,"usage: gmtime <time stamp>\n"); fprintf(stderr,"\t<time stamp> - integer 0 to 2147483647\n"); } int main( int argc, char **argv) { int timeStamp; time_t timep; struct tm *tm; if (argc != 2){ usage(); exit(255);} timeStamp = atoi(argv[1]); timep = (time_t) timeStamp; tm = gmtime(&timep); printf("%d-%02d-%02d %02d:%02d:%02d %ld\n", 1900+tm->tm_year, 1+tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, (unsigned long)timep); return(0); }
the_stack_data/111076916.c
/*TCP Server Code for chat*/ #include<sys/types.h> #include<sys/socket.h> #include<netdb.h> #include<stdio.h> #include<string.h> int main() { char sendline[100]; char recvline[100]; int listenfd,connfd; struct sockaddr_in servaddr; listenfd=socket(AF_INET,SOCK_STREAM,0); bzero(&servaddr,sizeof(servaddr)); servaddr.sin_family=AF_INET; servaddr.sin_addr.s_addr=htonl(INADDR_ANY); servaddr.sin_port=htons(22000); bind(listenfd,(struct sockaddr *)&servaddr,sizeof(servaddr)); listen(listenfd,10); connfd=accept(listenfd,(struct sockaddr *)NULL,NULL); while(1) { bzero(sendline,100); bzero(recvline,100); read(connfd,recvline,100); printf("Client - %s",recvline); fgets(sendline,100,stdin); write(connfd,sendline,strlen(sendline)+1); } return 0; }
the_stack_data/86859.c
/* Implement a function which extracts a substring from a given string by specifying the position from which to extract and the length to extract. The declaration could be as follows: * int substr(char * src, int position, int length); */ #include <stdio.h> #include <stdlib.h> #include <string.h> char *substr(char * src, int position, int length); int main() { char *string = substr("Breaking Bad", 0, 2); printf("%s\n", string); free(string); string = substr("Maniac", 3, 3); printf("%s\n", string); free(string); string = substr("Maniac", 3, 5); printf("%s\n", string); free(string); string = substr("Master Yoda", 13, 5); printf("%s\n", string); free(string); return (EXIT_SUCCESS); } char *substr(char * src, int position, int length) { size_t srcLen = strlen(src); if (srcLen < length || src == NULL) { return NULL; } if (srcLen < position) { char *subStr = malloc(1); if (!subStr) { return NULL; } subStr[0] = '\0'; return subStr; } char *subStr = malloc(srcLen + 1); if (!subStr) { return NULL; } int i, k = position; for (i = 0; i < length; i++, k++) { subStr[i] = src[k]; } subStr[i] = '\0'; return subStr; }
the_stack_data/25139081.c
/* * ===================================================================================== * * Filename: 10.c * * Description: * * Version: 1.0 * Created: 28/11/09 14:08:11 * Revision: none * Compiler: gcc * * Author: YOUR NAME (), * Company: * * ===================================================================================== */ #include <string.h> #include <math.h> #include <stdint.h> #include <stdio.h> #define limit 2000000 int8_t bitmask[(limit+1)/8/2]; int main(int argc, char * argv[]) { int half, p, i; int half_limit; int loop_to; long long sum = 0 + 2; memset(bitmask, '\0', sizeof(bitmask)); loop_to=(((int)(sqrt(limit)))>>1); half_limit = (limit-1)>>1; for (half=1 ; half <= loop_to ; half++) { if (! ( bitmask[half>>3]&(1 << (half&(8-1))) ) ) { /* It is a prime. */ p = (half << 1)+1; sum += p; for (i = ((p*p)>>1) ; i < half_limit ; i+=p ) { bitmask[i>>3] |= (1 << (i&(8-1))); } } } for( ; half < half_limit ; half++) { if (! ( bitmask[half>>3]&(1 << (half&(8-1))) ) ) { sum += (half<<1)+1; } } printf("%lli\n", sum); return 0; }
the_stack_data/1230092.c
/* ** 2001 September 15 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains code for implementations of the r-tree and r*-tree ** algorithms packaged as an SQLite virtual table module. */ #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_RTREE) /* ** This file contains an implementation of a couple of different variants ** of the r-tree algorithm. See the README file for further details. The ** same data-structure is used for all, but the algorithms for insert and ** delete operations vary. The variants used are selected at compile time ** by defining the following symbols: */ /* Either, both or none of the following may be set to activate ** r*tree variant algorithms. */ #define VARIANT_RSTARTREE_CHOOSESUBTREE 0 #define VARIANT_RSTARTREE_REINSERT 1 /* ** Exactly one of the following must be set to 1. */ #define VARIANT_GUTTMAN_QUADRATIC_SPLIT 0 #define VARIANT_GUTTMAN_LINEAR_SPLIT 0 #define VARIANT_RSTARTREE_SPLIT 1 #define VARIANT_GUTTMAN_SPLIT \ (VARIANT_GUTTMAN_LINEAR_SPLIT||VARIANT_GUTTMAN_QUADRATIC_SPLIT) #if VARIANT_GUTTMAN_QUADRATIC_SPLIT #define PickNext QuadraticPickNext #define PickSeeds QuadraticPickSeeds #define AssignCells splitNodeGuttman #endif #if VARIANT_GUTTMAN_LINEAR_SPLIT #define PickNext LinearPickNext #define PickSeeds LinearPickSeeds #define AssignCells splitNodeGuttman #endif #if VARIANT_RSTARTREE_SPLIT #define AssignCells splitNodeStartree #endif #ifndef SQLITE_CORE #include "sqlite3ext.h" SQLITE_EXTENSION_INIT1 #else #include "sqlite3.h" #endif #include <string.h> #include <assert.h> #ifndef SQLITE_AMALGAMATION typedef sqlite3_int64 i64; typedef unsigned char u8; typedef unsigned int u32; #endif typedef struct Rtree Rtree; typedef struct RtreeCursor RtreeCursor; typedef struct RtreeNode RtreeNode; typedef struct RtreeCell RtreeCell; typedef struct RtreeConstraint RtreeConstraint; typedef union RtreeCoord RtreeCoord; /* The rtree may have between 1 and RTREE_MAX_DIMENSIONS dimensions. */ #define RTREE_MAX_DIMENSIONS 5 /* Size of hash table Rtree.aHash. This hash table is not expected to ** ever contain very many entries, so a fixed number of buckets is ** used. */ #define HASHSIZE 128 /* ** An rtree virtual-table object. */ struct Rtree { sqlite3_vtab base; sqlite3 *db; /* Host database connection */ int iNodeSize; /* Size in bytes of each node in the node table */ int nDim; /* Number of dimensions */ int nBytesPerCell; /* Bytes consumed per cell */ int iDepth; /* Current depth of the r-tree structure */ char *zDb; /* Name of database containing r-tree table */ char *zName; /* Name of r-tree table */ RtreeNode *aHash[HASHSIZE]; /* Hash table of in-memory nodes. */ int nBusy; /* Current number of users of this structure */ /* List of nodes removed during a CondenseTree operation. List is ** linked together via the pointer normally used for hash chains - ** RtreeNode.pNext. RtreeNode.iNode stores the depth of the sub-tree ** headed by the node (leaf nodes have RtreeNode.iNode==0). */ RtreeNode *pDeleted; int iReinsertHeight; /* Height of sub-trees Reinsert() has run on */ /* Statements to read/write/delete a record from xxx_node */ sqlite3_stmt *pReadNode; sqlite3_stmt *pWriteNode; sqlite3_stmt *pDeleteNode; /* Statements to read/write/delete a record from xxx_rowid */ sqlite3_stmt *pReadRowid; sqlite3_stmt *pWriteRowid; sqlite3_stmt *pDeleteRowid; /* Statements to read/write/delete a record from xxx_parent */ sqlite3_stmt *pReadParent; sqlite3_stmt *pWriteParent; sqlite3_stmt *pDeleteParent; int eCoordType; }; /* Possible values for eCoordType: */ #define RTREE_COORD_REAL32 0 #define RTREE_COORD_INT32 1 /* ** The minimum number of cells allowed for a node is a third of the ** maximum. In Gutman's notation: ** ** m = M/3 ** ** If an R*-tree "Reinsert" operation is required, the same number of ** cells are removed from the overfull node and reinserted into the tree. */ #define RTREE_MINCELLS(p) ((((p)->iNodeSize-4)/(p)->nBytesPerCell)/3) #define RTREE_REINSERT(p) RTREE_MINCELLS(p) #define RTREE_MAXCELLS 51 /* ** An rtree cursor object. */ struct RtreeCursor { sqlite3_vtab_cursor base; RtreeNode *pNode; /* Node cursor is currently pointing at */ int iCell; /* Index of current cell in pNode */ int iStrategy; /* Copy of idxNum search parameter */ int nConstraint; /* Number of entries in aConstraint */ RtreeConstraint *aConstraint; /* Search constraints. */ }; union RtreeCoord { float f; int i; }; /* ** The argument is an RtreeCoord. Return the value stored within the RtreeCoord ** formatted as a double. This macro assumes that local variable pRtree points ** to the Rtree structure associated with the RtreeCoord. */ #define DCOORD(coord) ( \ (pRtree->eCoordType==RTREE_COORD_REAL32) ? \ ((double)coord.f) : \ ((double)coord.i) \ ) /* ** A search constraint. */ struct RtreeConstraint { int iCoord; /* Index of constrained coordinate */ int op; /* Constraining operation */ double rValue; /* Constraint value. */ }; /* Possible values for RtreeConstraint.op */ #define RTREE_EQ 0x41 #define RTREE_LE 0x42 #define RTREE_LT 0x43 #define RTREE_GE 0x44 #define RTREE_GT 0x45 /* ** An rtree structure node. ** ** Data format (RtreeNode.zData): ** ** 1. If the node is the root node (node 1), then the first 2 bytes ** of the node contain the tree depth as a big-endian integer. ** For non-root nodes, the first 2 bytes are left unused. ** ** 2. The next 2 bytes contain the number of entries currently ** stored in the node. ** ** 3. The remainder of the node contains the node entries. Each entry ** consists of a single 8-byte integer followed by an even number ** of 4-byte coordinates. For leaf nodes the integer is the rowid ** of a record. For internal nodes it is the node number of a ** child page. */ struct RtreeNode { RtreeNode *pParent; /* Parent node */ i64 iNode; int nRef; int isDirty; u8 *zData; RtreeNode *pNext; /* Next node in this hash chain */ }; #define NCELL(pNode) readInt16(&(pNode)->zData[2]) /* ** Structure to store a deserialized rtree record. */ struct RtreeCell { i64 iRowid; RtreeCoord aCoord[RTREE_MAX_DIMENSIONS*2]; }; #ifndef MAX # define MAX(x,y) ((x) < (y) ? (y) : (x)) #endif #ifndef MIN # define MIN(x,y) ((x) > (y) ? (y) : (x)) #endif /* ** Functions to deserialize a 16 bit integer, 32 bit real number and ** 64 bit integer. The deserialized value is returned. */ static int readInt16(u8 *p){ return (p[0]<<8) + p[1]; } static void readCoord(u8 *p, RtreeCoord *pCoord){ u32 i = ( (((u32)p[0]) << 24) + (((u32)p[1]) << 16) + (((u32)p[2]) << 8) + (((u32)p[3]) << 0) ); *(u32 *)pCoord = i; } static i64 readInt64(u8 *p){ return ( (((i64)p[0]) << 56) + (((i64)p[1]) << 48) + (((i64)p[2]) << 40) + (((i64)p[3]) << 32) + (((i64)p[4]) << 24) + (((i64)p[5]) << 16) + (((i64)p[6]) << 8) + (((i64)p[7]) << 0) ); } /* ** Functions to serialize a 16 bit integer, 32 bit real number and ** 64 bit integer. The value returned is the number of bytes written ** to the argument buffer (always 2, 4 and 8 respectively). */ static int writeInt16(u8 *p, int i){ p[0] = (i>> 8)&0xFF; p[1] = (i>> 0)&0xFF; return 2; } static int writeCoord(u8 *p, RtreeCoord *pCoord){ u32 i; assert( sizeof(RtreeCoord)==4 ); assert( sizeof(u32)==4 ); i = *(u32 *)pCoord; p[0] = (i>>24)&0xFF; p[1] = (i>>16)&0xFF; p[2] = (i>> 8)&0xFF; p[3] = (i>> 0)&0xFF; return 4; } static int writeInt64(u8 *p, i64 i){ p[0] = (i>>56)&0xFF; p[1] = (i>>48)&0xFF; p[2] = (i>>40)&0xFF; p[3] = (i>>32)&0xFF; p[4] = (i>>24)&0xFF; p[5] = (i>>16)&0xFF; p[6] = (i>> 8)&0xFF; p[7] = (i>> 0)&0xFF; return 8; } /* ** Increment the reference count of node p. */ static void nodeReference(RtreeNode *p){ if( p ){ p->nRef++; } } /* ** Clear the content of node p (set all bytes to 0x00). */ static void nodeZero(Rtree *pRtree, RtreeNode *p){ if( p ){ memset(&p->zData[2], 0, pRtree->iNodeSize-2); p->isDirty = 1; } } /* ** Given a node number iNode, return the corresponding key to use ** in the Rtree.aHash table. */ static int nodeHash(i64 iNode){ return ( (iNode>>56) ^ (iNode>>48) ^ (iNode>>40) ^ (iNode>>32) ^ (iNode>>24) ^ (iNode>>16) ^ (iNode>> 8) ^ (iNode>> 0) ) % HASHSIZE; } /* ** Search the node hash table for node iNode. If found, return a pointer ** to it. Otherwise, return 0. */ static RtreeNode *nodeHashLookup(Rtree *pRtree, i64 iNode){ RtreeNode *p; assert( iNode!=0 ); for(p=pRtree->aHash[nodeHash(iNode)]; p && p->iNode!=iNode; p=p->pNext); return p; } /* ** Add node pNode to the node hash table. */ static void nodeHashInsert(Rtree *pRtree, RtreeNode *pNode){ if( pNode ){ int iHash; assert( pNode->pNext==0 ); iHash = nodeHash(pNode->iNode); pNode->pNext = pRtree->aHash[iHash]; pRtree->aHash[iHash] = pNode; } } /* ** Remove node pNode from the node hash table. */ static void nodeHashDelete(Rtree *pRtree, RtreeNode *pNode){ RtreeNode **pp; if( pNode->iNode!=0 ){ pp = &pRtree->aHash[nodeHash(pNode->iNode)]; for( ; (*pp)!=pNode; pp = &(*pp)->pNext){ assert(*pp); } *pp = pNode->pNext; pNode->pNext = 0; } } /* ** Allocate and return new r-tree node. Initially, (RtreeNode.iNode==0), ** indicating that node has not yet been assigned a node number. It is ** assigned a node number when nodeWrite() is called to write the ** node contents out to the database. */ static RtreeNode *nodeNew(Rtree *pRtree, RtreeNode *pParent, int zero){ RtreeNode *pNode; pNode = (RtreeNode *)sqlite3_malloc(sizeof(RtreeNode) + pRtree->iNodeSize); if( pNode ){ memset(pNode, 0, sizeof(RtreeNode) + (zero?pRtree->iNodeSize:0)); pNode->zData = (u8 *)&pNode[1]; pNode->nRef = 1; pNode->pParent = pParent; pNode->isDirty = 1; nodeReference(pParent); } return pNode; } /* ** Obtain a reference to an r-tree node. */ static int nodeAcquire( Rtree *pRtree, /* R-tree structure */ i64 iNode, /* Node number to load */ RtreeNode *pParent, /* Either the parent node or NULL */ RtreeNode **ppNode /* OUT: Acquired node */ ){ int rc; RtreeNode *pNode; /* Check if the requested node is already in the hash table. If so, ** increase its reference count and return it. */ if( (pNode = nodeHashLookup(pRtree, iNode)) ){ assert( !pParent || !pNode->pParent || pNode->pParent==pParent ); if( pParent && !pNode->pParent ){ nodeReference(pParent); pNode->pParent = pParent; } pNode->nRef++; *ppNode = pNode; return SQLITE_OK; } pNode = (RtreeNode *)sqlite3_malloc(sizeof(RtreeNode) + pRtree->iNodeSize); if( !pNode ){ *ppNode = 0; return SQLITE_NOMEM; } pNode->pParent = pParent; pNode->zData = (u8 *)&pNode[1]; pNode->nRef = 1; pNode->iNode = iNode; pNode->isDirty = 0; pNode->pNext = 0; sqlite3_bind_int64(pRtree->pReadNode, 1, iNode); rc = sqlite3_step(pRtree->pReadNode); if( rc==SQLITE_ROW ){ const u8 *zBlob = sqlite3_column_blob(pRtree->pReadNode, 0); assert( sqlite3_column_bytes(pRtree->pReadNode, 0)==pRtree->iNodeSize ); memcpy(pNode->zData, zBlob, pRtree->iNodeSize); nodeReference(pParent); }else{ sqlite3_free(pNode); pNode = 0; } *ppNode = pNode; rc = sqlite3_reset(pRtree->pReadNode); if( rc==SQLITE_OK && iNode==1 ){ pRtree->iDepth = readInt16(pNode->zData); } assert( (rc==SQLITE_OK && pNode) || (pNode==0 && rc!=SQLITE_OK) ); nodeHashInsert(pRtree, pNode); return rc; } /* ** Overwrite cell iCell of node pNode with the contents of pCell. */ static void nodeOverwriteCell( Rtree *pRtree, RtreeNode *pNode, RtreeCell *pCell, int iCell ){ int ii; u8 *p = &pNode->zData[4 + pRtree->nBytesPerCell*iCell]; p += writeInt64(p, pCell->iRowid); for(ii=0; ii<(pRtree->nDim*2); ii++){ p += writeCoord(p, &pCell->aCoord[ii]); } pNode->isDirty = 1; } /* ** Remove cell the cell with index iCell from node pNode. */ static void nodeDeleteCell(Rtree *pRtree, RtreeNode *pNode, int iCell){ u8 *pDst = &pNode->zData[4 + pRtree->nBytesPerCell*iCell]; u8 *pSrc = &pDst[pRtree->nBytesPerCell]; int nByte = (NCELL(pNode) - iCell - 1) * pRtree->nBytesPerCell; memmove(pDst, pSrc, nByte); writeInt16(&pNode->zData[2], NCELL(pNode)-1); pNode->isDirty = 1; } /* ** Insert the contents of cell pCell into node pNode. If the insert ** is successful, return SQLITE_OK. ** ** If there is not enough free space in pNode, return SQLITE_FULL. */ static int nodeInsertCell( Rtree *pRtree, RtreeNode *pNode, RtreeCell *pCell ){ int nCell; /* Current number of cells in pNode */ int nMaxCell; /* Maximum number of cells for pNode */ nMaxCell = (pRtree->iNodeSize-4)/pRtree->nBytesPerCell; nCell = NCELL(pNode); assert(nCell<=nMaxCell); if( nCell<nMaxCell ){ nodeOverwriteCell(pRtree, pNode, pCell, nCell); writeInt16(&pNode->zData[2], nCell+1); pNode->isDirty = 1; } return (nCell==nMaxCell); } /* ** If the node is dirty, write it out to the database. */ static int nodeWrite(Rtree *pRtree, RtreeNode *pNode){ int rc = SQLITE_OK; if( pNode->isDirty ){ sqlite3_stmt *p = pRtree->pWriteNode; if( pNode->iNode ){ sqlite3_bind_int64(p, 1, pNode->iNode); }else{ sqlite3_bind_null(p, 1); } sqlite3_bind_blob(p, 2, pNode->zData, pRtree->iNodeSize, SQLITE_STATIC); sqlite3_step(p); pNode->isDirty = 0; rc = sqlite3_reset(p); if( pNode->iNode==0 && rc==SQLITE_OK ){ pNode->iNode = sqlite3_last_insert_rowid(pRtree->db); nodeHashInsert(pRtree, pNode); } } return rc; } /* ** Release a reference to a node. If the node is dirty and the reference ** count drops to zero, the node data is written to the database. */ static int nodeRelease(Rtree *pRtree, RtreeNode *pNode){ int rc = SQLITE_OK; if( pNode ){ assert( pNode->nRef>0 ); pNode->nRef--; if( pNode->nRef==0 ){ if( pNode->iNode==1 ){ pRtree->iDepth = -1; } if( pNode->pParent ){ rc = nodeRelease(pRtree, pNode->pParent); } if( rc==SQLITE_OK ){ rc = nodeWrite(pRtree, pNode); } nodeHashDelete(pRtree, pNode); sqlite3_free(pNode); } } return rc; } /* ** Return the 64-bit integer value associated with cell iCell of ** node pNode. If pNode is a leaf node, this is a rowid. If it is ** an internal node, then the 64-bit integer is a child page number. */ static i64 nodeGetRowid( Rtree *pRtree, RtreeNode *pNode, int iCell ){ assert( iCell<NCELL(pNode) ); return readInt64(&pNode->zData[4 + pRtree->nBytesPerCell*iCell]); } /* ** Return coordinate iCoord from cell iCell in node pNode. */ static void nodeGetCoord( Rtree *pRtree, RtreeNode *pNode, int iCell, int iCoord, RtreeCoord *pCoord /* Space to write result to */ ){ readCoord(&pNode->zData[12 + pRtree->nBytesPerCell*iCell + 4*iCoord], pCoord); } /* ** Deserialize cell iCell of node pNode. Populate the structure pointed ** to by pCell with the results. */ static void nodeGetCell( Rtree *pRtree, RtreeNode *pNode, int iCell, RtreeCell *pCell ){ int ii; pCell->iRowid = nodeGetRowid(pRtree, pNode, iCell); for(ii=0; ii<pRtree->nDim*2; ii++){ nodeGetCoord(pRtree, pNode, iCell, ii, &pCell->aCoord[ii]); } } /* Forward declaration for the function that does the work of ** the virtual table module xCreate() and xConnect() methods. */ static int rtreeInit( sqlite3 *, void *, int, const char *const*, sqlite3_vtab **, char **, int ); /* ** Rtree virtual table module xCreate method. */ static int rtreeCreate( sqlite3 *db, void *pAux, int argc, const char *const*argv, sqlite3_vtab **ppVtab, char **pzErr ){ return rtreeInit(db, pAux, argc, argv, ppVtab, pzErr, 1); } /* ** Rtree virtual table module xConnect method. */ static int rtreeConnect( sqlite3 *db, void *pAux, int argc, const char *const*argv, sqlite3_vtab **ppVtab, char **pzErr ){ return rtreeInit(db, pAux, argc, argv, ppVtab, pzErr, 0); } /* ** Increment the r-tree reference count. */ static void rtreeReference(Rtree *pRtree){ pRtree->nBusy++; } /* ** Decrement the r-tree reference count. When the reference count reaches ** zero the structure is deleted. */ static void rtreeRelease(Rtree *pRtree){ pRtree->nBusy--; if( pRtree->nBusy==0 ){ sqlite3_finalize(pRtree->pReadNode); sqlite3_finalize(pRtree->pWriteNode); sqlite3_finalize(pRtree->pDeleteNode); sqlite3_finalize(pRtree->pReadRowid); sqlite3_finalize(pRtree->pWriteRowid); sqlite3_finalize(pRtree->pDeleteRowid); sqlite3_finalize(pRtree->pReadParent); sqlite3_finalize(pRtree->pWriteParent); sqlite3_finalize(pRtree->pDeleteParent); sqlite3_free(pRtree); } } /* ** Rtree virtual table module xDisconnect method. */ static int rtreeDisconnect(sqlite3_vtab *pVtab){ rtreeRelease((Rtree *)pVtab); return SQLITE_OK; } /* ** Rtree virtual table module xDestroy method. */ static int rtreeDestroy(sqlite3_vtab *pVtab){ Rtree *pRtree = (Rtree *)pVtab; int rc; char *zCreate = sqlite3_mprintf( "DROP TABLE '%q'.'%q_node';" "DROP TABLE '%q'.'%q_rowid';" "DROP TABLE '%q'.'%q_parent';", pRtree->zDb, pRtree->zName, pRtree->zDb, pRtree->zName, pRtree->zDb, pRtree->zName ); if( !zCreate ){ rc = SQLITE_NOMEM; }else{ rc = sqlite3_exec(pRtree->db, zCreate, 0, 0, 0); sqlite3_free(zCreate); } if( rc==SQLITE_OK ){ rtreeRelease(pRtree); } return rc; } /* ** Rtree virtual table module xOpen method. */ static int rtreeOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){ int rc = SQLITE_NOMEM; RtreeCursor *pCsr; pCsr = (RtreeCursor *)sqlite3_malloc(sizeof(RtreeCursor)); if( pCsr ){ memset(pCsr, 0, sizeof(RtreeCursor)); pCsr->base.pVtab = pVTab; rc = SQLITE_OK; } *ppCursor = (sqlite3_vtab_cursor *)pCsr; return rc; } /* ** Rtree virtual table module xClose method. */ static int rtreeClose(sqlite3_vtab_cursor *cur){ Rtree *pRtree = (Rtree *)(cur->pVtab); int rc; RtreeCursor *pCsr = (RtreeCursor *)cur; sqlite3_free(pCsr->aConstraint); rc = nodeRelease(pRtree, pCsr->pNode); sqlite3_free(pCsr); return rc; } /* ** Rtree virtual table module xEof method. ** ** Return non-zero if the cursor does not currently point to a valid ** record (i.e if the scan has finished), or zero otherwise. */ static int rtreeEof(sqlite3_vtab_cursor *cur){ RtreeCursor *pCsr = (RtreeCursor *)cur; return (pCsr->pNode==0); } /* ** Cursor pCursor currently points to a cell in a non-leaf page. ** Return true if the sub-tree headed by the cell is filtered ** (excluded) by the constraints in the pCursor->aConstraint[] ** array, or false otherwise. */ static int testRtreeCell(Rtree *pRtree, RtreeCursor *pCursor){ RtreeCell cell; int ii; int bRes = 0; nodeGetCell(pRtree, pCursor->pNode, pCursor->iCell, &cell); for(ii=0; bRes==0 && ii<pCursor->nConstraint; ii++){ RtreeConstraint *p = &pCursor->aConstraint[ii]; double cell_min = DCOORD(cell.aCoord[(p->iCoord>>1)*2]); double cell_max = DCOORD(cell.aCoord[(p->iCoord>>1)*2+1]); assert(p->op==RTREE_LE || p->op==RTREE_LT || p->op==RTREE_GE || p->op==RTREE_GT || p->op==RTREE_EQ ); switch( p->op ){ case RTREE_LE: case RTREE_LT: bRes = p->rValue<cell_min; break; case RTREE_GE: case RTREE_GT: bRes = p->rValue>cell_max; break; case RTREE_EQ: bRes = (p->rValue>cell_max || p->rValue<cell_min); break; } } return bRes; } /* ** Return true if the cell that cursor pCursor currently points to ** would be filtered (excluded) by the constraints in the ** pCursor->aConstraint[] array, or false otherwise. ** ** This function assumes that the cell is part of a leaf node. */ static int testRtreeEntry(Rtree *pRtree, RtreeCursor *pCursor){ RtreeCell cell; int ii; nodeGetCell(pRtree, pCursor->pNode, pCursor->iCell, &cell); for(ii=0; ii<pCursor->nConstraint; ii++){ RtreeConstraint *p = &pCursor->aConstraint[ii]; double coord = DCOORD(cell.aCoord[p->iCoord]); int res; assert(p->op==RTREE_LE || p->op==RTREE_LT || p->op==RTREE_GE || p->op==RTREE_GT || p->op==RTREE_EQ ); switch( p->op ){ case RTREE_LE: res = (coord<=p->rValue); break; case RTREE_LT: res = (coord<p->rValue); break; case RTREE_GE: res = (coord>=p->rValue); break; case RTREE_GT: res = (coord>p->rValue); break; case RTREE_EQ: res = (coord==p->rValue); break; } if( !res ) return 1; } return 0; } /* ** Cursor pCursor currently points at a node that heads a sub-tree of ** height iHeight (if iHeight==0, then the node is a leaf). Descend ** to point to the left-most cell of the sub-tree that matches the ** configured constraints. */ static int descendToCell( Rtree *pRtree, RtreeCursor *pCursor, int iHeight, int *pEof /* OUT: Set to true if cannot descend */ ){ int isEof; int rc; int ii; RtreeNode *pChild; sqlite3_int64 iRowid; RtreeNode *pSavedNode = pCursor->pNode; int iSavedCell = pCursor->iCell; assert( iHeight>=0 ); if( iHeight==0 ){ isEof = testRtreeEntry(pRtree, pCursor); }else{ isEof = testRtreeCell(pRtree, pCursor); } if( isEof || iHeight==0 ){ *pEof = isEof; return SQLITE_OK; } iRowid = nodeGetRowid(pRtree, pCursor->pNode, pCursor->iCell); rc = nodeAcquire(pRtree, iRowid, pCursor->pNode, &pChild); if( rc!=SQLITE_OK ){ return rc; } nodeRelease(pRtree, pCursor->pNode); pCursor->pNode = pChild; isEof = 1; for(ii=0; isEof && ii<NCELL(pChild); ii++){ pCursor->iCell = ii; rc = descendToCell(pRtree, pCursor, iHeight-1, &isEof); if( rc!=SQLITE_OK ){ return rc; } } if( isEof ){ assert( pCursor->pNode==pChild ); nodeReference(pSavedNode); nodeRelease(pRtree, pChild); pCursor->pNode = pSavedNode; pCursor->iCell = iSavedCell; } *pEof = isEof; return SQLITE_OK; } /* ** One of the cells in node pNode is guaranteed to have a 64-bit ** integer value equal to iRowid. Return the index of this cell. */ static int nodeRowidIndex(Rtree *pRtree, RtreeNode *pNode, i64 iRowid){ int ii; for(ii=0; nodeGetRowid(pRtree, pNode, ii)!=iRowid; ii++){ assert( ii<(NCELL(pNode)-1) ); } return ii; } /* ** Return the index of the cell containing a pointer to node pNode ** in its parent. If pNode is the root node, return -1. */ static int nodeParentIndex(Rtree *pRtree, RtreeNode *pNode){ RtreeNode *pParent = pNode->pParent; if( pParent ){ return nodeRowidIndex(pRtree, pParent, pNode->iNode); } return -1; } /* ** Rtree virtual table module xNext method. */ static int rtreeNext(sqlite3_vtab_cursor *pVtabCursor){ Rtree *pRtree = (Rtree *)(pVtabCursor->pVtab); RtreeCursor *pCsr = (RtreeCursor *)pVtabCursor; int rc = SQLITE_OK; if( pCsr->iStrategy==1 ){ /* This "scan" is a direct lookup by rowid. There is no next entry. */ nodeRelease(pRtree, pCsr->pNode); pCsr->pNode = 0; } else if( pCsr->pNode ){ /* Move to the next entry that matches the configured constraints. */ int iHeight = 0; while( pCsr->pNode ){ RtreeNode *pNode = pCsr->pNode; int nCell = NCELL(pNode); for(pCsr->iCell++; pCsr->iCell<nCell; pCsr->iCell++){ int isEof; rc = descendToCell(pRtree, pCsr, iHeight, &isEof); if( rc!=SQLITE_OK || !isEof ){ return rc; } } pCsr->pNode = pNode->pParent; pCsr->iCell = nodeParentIndex(pRtree, pNode); nodeReference(pCsr->pNode); nodeRelease(pRtree, pNode); iHeight++; } } return rc; } /* ** Rtree virtual table module xRowid method. */ static int rtreeRowid(sqlite3_vtab_cursor *pVtabCursor, sqlite_int64 *pRowid){ Rtree *pRtree = (Rtree *)pVtabCursor->pVtab; RtreeCursor *pCsr = (RtreeCursor *)pVtabCursor; assert(pCsr->pNode); *pRowid = nodeGetRowid(pRtree, pCsr->pNode, pCsr->iCell); return SQLITE_OK; } /* ** Rtree virtual table module xColumn method. */ static int rtreeColumn(sqlite3_vtab_cursor *cur, sqlite3_context *ctx, int i){ Rtree *pRtree = (Rtree *)cur->pVtab; RtreeCursor *pCsr = (RtreeCursor *)cur; if( i==0 ){ i64 iRowid = nodeGetRowid(pRtree, pCsr->pNode, pCsr->iCell); sqlite3_result_int64(ctx, iRowid); }else{ RtreeCoord c; nodeGetCoord(pRtree, pCsr->pNode, pCsr->iCell, i-1, &c); if( pRtree->eCoordType==RTREE_COORD_REAL32 ){ sqlite3_result_double(ctx, c.f); }else{ assert( pRtree->eCoordType==RTREE_COORD_INT32 ); sqlite3_result_int(ctx, c.i); } } return SQLITE_OK; } /* ** Use nodeAcquire() to obtain the leaf node containing the record with ** rowid iRowid. If successful, set *ppLeaf to point to the node and ** return SQLITE_OK. If there is no such record in the table, set ** *ppLeaf to 0 and return SQLITE_OK. If an error occurs, set *ppLeaf ** to zero and return an SQLite error code. */ static int findLeafNode(Rtree *pRtree, i64 iRowid, RtreeNode **ppLeaf){ int rc; *ppLeaf = 0; sqlite3_bind_int64(pRtree->pReadRowid, 1, iRowid); if( sqlite3_step(pRtree->pReadRowid)==SQLITE_ROW ){ i64 iNode = sqlite3_column_int64(pRtree->pReadRowid, 0); rc = nodeAcquire(pRtree, iNode, 0, ppLeaf); sqlite3_reset(pRtree->pReadRowid); }else{ rc = sqlite3_reset(pRtree->pReadRowid); } return rc; } /* ** Rtree virtual table module xFilter method. */ static int rtreeFilter( sqlite3_vtab_cursor *pVtabCursor, int idxNum, const char *idxStr, int argc, sqlite3_value **argv ){ Rtree *pRtree = (Rtree *)pVtabCursor->pVtab; RtreeCursor *pCsr = (RtreeCursor *)pVtabCursor; RtreeNode *pRoot = 0; int ii; int rc = SQLITE_OK; rtreeReference(pRtree); sqlite3_free(pCsr->aConstraint); pCsr->aConstraint = 0; pCsr->iStrategy = idxNum; if( idxNum==1 ){ /* Special case - lookup by rowid. */ RtreeNode *pLeaf; /* Leaf on which the required cell resides */ i64 iRowid = sqlite3_value_int64(argv[0]); rc = findLeafNode(pRtree, iRowid, &pLeaf); pCsr->pNode = pLeaf; if( pLeaf && rc==SQLITE_OK ){ pCsr->iCell = nodeRowidIndex(pRtree, pLeaf, iRowid); } }else{ /* Normal case - r-tree scan. Set up the RtreeCursor.aConstraint array ** with the configured constraints. */ if( argc>0 ){ pCsr->aConstraint = sqlite3_malloc(sizeof(RtreeConstraint)*argc); pCsr->nConstraint = argc; if( !pCsr->aConstraint ){ rc = SQLITE_NOMEM; }else{ assert( (idxStr==0 && argc==0) || strlen(idxStr)==argc*2 ); for(ii=0; ii<argc; ii++){ RtreeConstraint *p = &pCsr->aConstraint[ii]; p->op = idxStr[ii*2]; p->iCoord = idxStr[ii*2+1]-'a'; p->rValue = sqlite3_value_double(argv[ii]); } } } if( rc==SQLITE_OK ){ pCsr->pNode = 0; rc = nodeAcquire(pRtree, 1, 0, &pRoot); } if( rc==SQLITE_OK ){ int isEof = 1; int nCell = NCELL(pRoot); pCsr->pNode = pRoot; for(pCsr->iCell=0; rc==SQLITE_OK && pCsr->iCell<nCell; pCsr->iCell++){ assert( pCsr->pNode==pRoot ); rc = descendToCell(pRtree, pCsr, pRtree->iDepth, &isEof); if( !isEof ){ break; } } if( rc==SQLITE_OK && isEof ){ assert( pCsr->pNode==pRoot ); nodeRelease(pRtree, pRoot); pCsr->pNode = 0; } assert( rc!=SQLITE_OK || !pCsr->pNode || pCsr->iCell<NCELL(pCsr->pNode) ); } } rtreeRelease(pRtree); return rc; } /* ** Rtree virtual table module xBestIndex method. There are three ** table scan strategies to choose from (in order from most to ** least desirable): ** ** idxNum idxStr Strategy ** ------------------------------------------------ ** 1 Unused Direct lookup by rowid. ** 2 See below R-tree query. ** 3 Unused Full table scan. ** ------------------------------------------------ ** ** If strategy 1 or 3 is used, then idxStr is not meaningful. If strategy ** 2 is used, idxStr is formatted to contain 2 bytes for each ** constraint used. The first two bytes of idxStr correspond to ** the constraint in sqlite3_index_info.aConstraintUsage[] with ** (argvIndex==1) etc. ** ** The first of each pair of bytes in idxStr identifies the constraint ** operator as follows: ** ** Operator Byte Value ** ---------------------- ** = 0x41 ('A') ** <= 0x42 ('B') ** < 0x43 ('C') ** >= 0x44 ('D') ** > 0x45 ('E') ** ---------------------- ** ** The second of each pair of bytes identifies the coordinate column ** to which the constraint applies. The leftmost coordinate column ** is 'a', the second from the left 'b' etc. */ static int rtreeBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){ int rc = SQLITE_OK; int ii, cCol; int iIdx = 0; char zIdxStr[RTREE_MAX_DIMENSIONS*8+1]; memset(zIdxStr, 0, sizeof(zIdxStr)); assert( pIdxInfo->idxStr==0 ); for(ii=0; ii<pIdxInfo->nConstraint; ii++){ struct sqlite3_index_constraint *p = &pIdxInfo->aConstraint[ii]; if( p->usable && p->iColumn==0 && p->op==SQLITE_INDEX_CONSTRAINT_EQ ){ /* We have an equality constraint on the rowid. Use strategy 1. */ int jj; for(jj=0; jj<ii; jj++){ pIdxInfo->aConstraintUsage[jj].argvIndex = 0; pIdxInfo->aConstraintUsage[jj].omit = 0; } pIdxInfo->idxNum = 1; pIdxInfo->aConstraintUsage[ii].argvIndex = 1; pIdxInfo->aConstraintUsage[jj].omit = 1; /* This strategy involves a two rowid lookups on an B-Tree structures ** and then a linear search of an R-Tree node. This should be ** considered almost as quick as a direct rowid lookup (for which ** sqlite uses an internal cost of 0.0). */ pIdxInfo->estimatedCost = 10.0; return SQLITE_OK; } if( p->usable && p->iColumn>0 ){ u8 op = 0; switch( p->op ){ case SQLITE_INDEX_CONSTRAINT_EQ: op = RTREE_EQ; break; case SQLITE_INDEX_CONSTRAINT_GT: op = RTREE_GT; break; case SQLITE_INDEX_CONSTRAINT_LE: op = RTREE_LE; break; case SQLITE_INDEX_CONSTRAINT_LT: op = RTREE_LT; break; case SQLITE_INDEX_CONSTRAINT_GE: op = RTREE_GE; break; } if( op ){ /* Make sure this particular constraint has not been used before. ** If it has been used before, ignore it. ** ** A <= or < can be used if there is a prior >= or >. ** A >= or > can be used if there is a prior < or <=. ** A <= or < is disqualified if there is a prior <=, <, or ==. ** A >= or > is disqualified if there is a prior >=, >, or ==. ** A == is disqualifed if there is any prior constraint. */ int j, opmsk; static const unsigned char compatible[] = { 0, 0, 1, 1, 2, 2 }; assert( compatible[RTREE_EQ & 7]==0 ); assert( compatible[RTREE_LT & 7]==1 ); assert( compatible[RTREE_LE & 7]==1 ); assert( compatible[RTREE_GT & 7]==2 ); assert( compatible[RTREE_GE & 7]==2 ); cCol = p->iColumn - 1 + 'a'; opmsk = compatible[op & 7]; for(j=0; j<iIdx; j+=2){ if( zIdxStr[j+1]==cCol && (compatible[zIdxStr[j] & 7] & opmsk)!=0 ){ op = 0; break; } } } if( op ){ assert( iIdx<sizeof(zIdxStr)-1 ); zIdxStr[iIdx++] = op; zIdxStr[iIdx++] = cCol; pIdxInfo->aConstraintUsage[ii].argvIndex = (iIdx/2); pIdxInfo->aConstraintUsage[ii].omit = 1; } } } pIdxInfo->idxNum = 2; pIdxInfo->needToFreeIdxStr = 1; if( iIdx>0 && 0==(pIdxInfo->idxStr = sqlite3_mprintf("%s", zIdxStr)) ){ return SQLITE_NOMEM; } assert( iIdx>=0 ); pIdxInfo->estimatedCost = (2000000.0 / (double)(iIdx + 1)); return rc; } /* ** Return the N-dimensional volumn of the cell stored in *p. */ static float cellArea(Rtree *pRtree, RtreeCell *p){ float area = 1.0; int ii; for(ii=0; ii<(pRtree->nDim*2); ii+=2){ area = area * (DCOORD(p->aCoord[ii+1]) - DCOORD(p->aCoord[ii])); } return area; } /* ** Return the margin length of cell p. The margin length is the sum ** of the objects size in each dimension. */ static float cellMargin(Rtree *pRtree, RtreeCell *p){ float margin = 0.0; int ii; for(ii=0; ii<(pRtree->nDim*2); ii+=2){ margin += (DCOORD(p->aCoord[ii+1]) - DCOORD(p->aCoord[ii])); } return margin; } /* ** Store the union of cells p1 and p2 in p1. */ static void cellUnion(Rtree *pRtree, RtreeCell *p1, RtreeCell *p2){ int ii; if( pRtree->eCoordType==RTREE_COORD_REAL32 ){ for(ii=0; ii<(pRtree->nDim*2); ii+=2){ p1->aCoord[ii].f = MIN(p1->aCoord[ii].f, p2->aCoord[ii].f); p1->aCoord[ii+1].f = MAX(p1->aCoord[ii+1].f, p2->aCoord[ii+1].f); } }else{ for(ii=0; ii<(pRtree->nDim*2); ii+=2){ p1->aCoord[ii].i = MIN(p1->aCoord[ii].i, p2->aCoord[ii].i); p1->aCoord[ii+1].i = MAX(p1->aCoord[ii+1].i, p2->aCoord[ii+1].i); } } } /* ** Return true if the area covered by p2 is a subset of the area covered ** by p1. False otherwise. */ static int cellContains(Rtree *pRtree, RtreeCell *p1, RtreeCell *p2){ int ii; int isInt = (pRtree->eCoordType==RTREE_COORD_INT32); for(ii=0; ii<(pRtree->nDim*2); ii+=2){ RtreeCoord *a1 = &p1->aCoord[ii]; RtreeCoord *a2 = &p2->aCoord[ii]; if( (!isInt && (a2[0].f<a1[0].f || a2[1].f>a1[1].f)) || ( isInt && (a2[0].i<a1[0].i || a2[1].i>a1[1].i)) ){ return 0; } } return 1; } /* ** Return the amount cell p would grow by if it were unioned with pCell. */ static float cellGrowth(Rtree *pRtree, RtreeCell *p, RtreeCell *pCell){ float area; RtreeCell cell; memcpy(&cell, p, sizeof(RtreeCell)); area = cellArea(pRtree, &cell); cellUnion(pRtree, &cell, pCell); return (cellArea(pRtree, &cell)-area); } #if VARIANT_RSTARTREE_CHOOSESUBTREE || VARIANT_RSTARTREE_SPLIT static float cellOverlap( Rtree *pRtree, RtreeCell *p, RtreeCell *aCell, int nCell, int iExclude ){ int ii; float overlap = 0.0; for(ii=0; ii<nCell; ii++){ if( ii!=iExclude ){ int jj; float o = 1.0; for(jj=0; jj<(pRtree->nDim*2); jj+=2){ double x1; double x2; x1 = MAX(DCOORD(p->aCoord[jj]), DCOORD(aCell[ii].aCoord[jj])); x2 = MIN(DCOORD(p->aCoord[jj+1]), DCOORD(aCell[ii].aCoord[jj+1])); if( x2<x1 ){ o = 0.0; break; }else{ o = o * (x2-x1); } } overlap += o; } } return overlap; } #endif #if VARIANT_RSTARTREE_CHOOSESUBTREE static float cellOverlapEnlargement( Rtree *pRtree, RtreeCell *p, RtreeCell *pInsert, RtreeCell *aCell, int nCell, int iExclude ){ float before; float after; before = cellOverlap(pRtree, p, aCell, nCell, iExclude); cellUnion(pRtree, p, pInsert); after = cellOverlap(pRtree, p, aCell, nCell, iExclude); return after-before; } #endif /* ** This function implements the ChooseLeaf algorithm from Gutman[84]. ** ChooseSubTree in r*tree terminology. */ static int ChooseLeaf( Rtree *pRtree, /* Rtree table */ RtreeCell *pCell, /* Cell to insert into rtree */ int iHeight, /* Height of sub-tree rooted at pCell */ RtreeNode **ppLeaf /* OUT: Selected leaf page */ ){ int rc; int ii; RtreeNode *pNode; rc = nodeAcquire(pRtree, 1, 0, &pNode); for(ii=0; rc==SQLITE_OK && ii<(pRtree->iDepth-iHeight); ii++){ int iCell; sqlite3_int64 iBest; float fMinGrowth; float fMinArea; float fMinOverlap; int nCell = NCELL(pNode); RtreeCell cell; RtreeNode *pChild; RtreeCell *aCell = 0; #if VARIANT_RSTARTREE_CHOOSESUBTREE if( ii==(pRtree->iDepth-1) ){ int jj; aCell = sqlite3_malloc(sizeof(RtreeCell)*nCell); if( !aCell ){ rc = SQLITE_NOMEM; nodeRelease(pRtree, pNode); pNode = 0; continue; } for(jj=0; jj<nCell; jj++){ nodeGetCell(pRtree, pNode, jj, &aCell[jj]); } } #endif /* Select the child node which will be enlarged the least if pCell ** is inserted into it. Resolve ties by choosing the entry with ** the smallest area. */ for(iCell=0; iCell<nCell; iCell++){ float growth; float area; float overlap = 0.0; nodeGetCell(pRtree, pNode, iCell, &cell); growth = cellGrowth(pRtree, &cell, pCell); area = cellArea(pRtree, &cell); #if VARIANT_RSTARTREE_CHOOSESUBTREE if( ii==(pRtree->iDepth-1) ){ overlap = cellOverlapEnlargement(pRtree,&cell,pCell,aCell,nCell,iCell); } #endif if( (iCell==0) || (overlap<fMinOverlap) || (overlap==fMinOverlap && growth<fMinGrowth) || (overlap==fMinOverlap && growth==fMinGrowth && area<fMinArea) ){ fMinOverlap = overlap; fMinGrowth = growth; fMinArea = area; iBest = cell.iRowid; } } sqlite3_free(aCell); rc = nodeAcquire(pRtree, iBest, pNode, &pChild); nodeRelease(pRtree, pNode); pNode = pChild; } *ppLeaf = pNode; return rc; } /* ** A cell with the same content as pCell has just been inserted into ** the node pNode. This function updates the bounding box cells in ** all ancestor elements. */ static void AdjustTree( Rtree *pRtree, /* Rtree table */ RtreeNode *pNode, /* Adjust ancestry of this node. */ RtreeCell *pCell /* This cell was just inserted */ ){ RtreeNode *p = pNode; while( p->pParent ){ RtreeCell cell; RtreeNode *pParent = p->pParent; int iCell = nodeParentIndex(pRtree, p); nodeGetCell(pRtree, pParent, iCell, &cell); if( !cellContains(pRtree, &cell, pCell) ){ cellUnion(pRtree, &cell, pCell); nodeOverwriteCell(pRtree, pParent, &cell, iCell); } p = pParent; } } /* ** Write mapping (iRowid->iNode) to the <rtree>_rowid table. */ static int rowidWrite(Rtree *pRtree, sqlite3_int64 iRowid, sqlite3_int64 iNode){ sqlite3_bind_int64(pRtree->pWriteRowid, 1, iRowid); sqlite3_bind_int64(pRtree->pWriteRowid, 2, iNode); sqlite3_step(pRtree->pWriteRowid); return sqlite3_reset(pRtree->pWriteRowid); } /* ** Write mapping (iNode->iPar) to the <rtree>_parent table. */ static int parentWrite(Rtree *pRtree, sqlite3_int64 iNode, sqlite3_int64 iPar){ sqlite3_bind_int64(pRtree->pWriteParent, 1, iNode); sqlite3_bind_int64(pRtree->pWriteParent, 2, iPar); sqlite3_step(pRtree->pWriteParent); return sqlite3_reset(pRtree->pWriteParent); } static int rtreeInsertCell(Rtree *, RtreeNode *, RtreeCell *, int); #if VARIANT_GUTTMAN_LINEAR_SPLIT /* ** Implementation of the linear variant of the PickNext() function from ** Guttman[84]. */ static RtreeCell *LinearPickNext( Rtree *pRtree, RtreeCell *aCell, int nCell, RtreeCell *pLeftBox, RtreeCell *pRightBox, int *aiUsed ){ int ii; for(ii=0; aiUsed[ii]; ii++); aiUsed[ii] = 1; return &aCell[ii]; } /* ** Implementation of the linear variant of the PickSeeds() function from ** Guttman[84]. */ static void LinearPickSeeds( Rtree *pRtree, RtreeCell *aCell, int nCell, int *piLeftSeed, int *piRightSeed ){ int i; int iLeftSeed = 0; int iRightSeed = 1; float maxNormalInnerWidth = 0.0; /* Pick two "seed" cells from the array of cells. The algorithm used ** here is the LinearPickSeeds algorithm from Gutman[1984]. The ** indices of the two seed cells in the array are stored in local ** variables iLeftSeek and iRightSeed. */ for(i=0; i<pRtree->nDim; i++){ float x1 = DCOORD(aCell[0].aCoord[i*2]); float x2 = DCOORD(aCell[0].aCoord[i*2+1]); float x3 = x1; float x4 = x2; int jj; int iCellLeft = 0; int iCellRight = 0; for(jj=1; jj<nCell; jj++){ float left = DCOORD(aCell[jj].aCoord[i*2]); float right = DCOORD(aCell[jj].aCoord[i*2+1]); if( left<x1 ) x1 = left; if( right>x4 ) x4 = right; if( left>x3 ){ x3 = left; iCellRight = jj; } if( right<x2 ){ x2 = right; iCellLeft = jj; } } if( x4!=x1 ){ float normalwidth = (x3 - x2) / (x4 - x1); if( normalwidth>maxNormalInnerWidth ){ iLeftSeed = iCellLeft; iRightSeed = iCellRight; } } } *piLeftSeed = iLeftSeed; *piRightSeed = iRightSeed; } #endif /* VARIANT_GUTTMAN_LINEAR_SPLIT */ #if VARIANT_GUTTMAN_QUADRATIC_SPLIT /* ** Implementation of the quadratic variant of the PickNext() function from ** Guttman[84]. */ static RtreeCell *QuadraticPickNext( Rtree *pRtree, RtreeCell *aCell, int nCell, RtreeCell *pLeftBox, RtreeCell *pRightBox, int *aiUsed ){ #define FABS(a) ((a)<0.0?-1.0*(a):(a)) int iSelect = -1; float fDiff; int ii; for(ii=0; ii<nCell; ii++){ if( aiUsed[ii]==0 ){ float left = cellGrowth(pRtree, pLeftBox, &aCell[ii]); float right = cellGrowth(pRtree, pLeftBox, &aCell[ii]); float diff = FABS(right-left); if( iSelect<0 || diff>fDiff ){ fDiff = diff; iSelect = ii; } } } aiUsed[iSelect] = 1; return &aCell[iSelect]; } /* ** Implementation of the quadratic variant of the PickSeeds() function from ** Guttman[84]. */ static void QuadraticPickSeeds( Rtree *pRtree, RtreeCell *aCell, int nCell, int *piLeftSeed, int *piRightSeed ){ int ii; int jj; int iLeftSeed = 0; int iRightSeed = 1; float fWaste = 0.0; for(ii=0; ii<nCell; ii++){ for(jj=ii+1; jj<nCell; jj++){ float right = cellArea(pRtree, &aCell[jj]); float growth = cellGrowth(pRtree, &aCell[ii], &aCell[jj]); float waste = growth - right; if( waste>fWaste ){ iLeftSeed = ii; iRightSeed = jj; fWaste = waste; } } } *piLeftSeed = iLeftSeed; *piRightSeed = iRightSeed; } #endif /* VARIANT_GUTTMAN_QUADRATIC_SPLIT */ /* ** Arguments aIdx, aDistance and aSpare all point to arrays of size ** nIdx. The aIdx array contains the set of integers from 0 to ** (nIdx-1) in no particular order. This function sorts the values ** in aIdx according to the indexed values in aDistance. For ** example, assuming the inputs: ** ** aIdx = { 0, 1, 2, 3 } ** aDistance = { 5.0, 2.0, 7.0, 6.0 } ** ** this function sets the aIdx array to contain: ** ** aIdx = { 0, 1, 2, 3 } ** ** The aSpare array is used as temporary working space by the ** sorting algorithm. */ static void SortByDistance( int *aIdx, int nIdx, float *aDistance, int *aSpare ){ if( nIdx>1 ){ int iLeft = 0; int iRight = 0; int nLeft = nIdx/2; int nRight = nIdx-nLeft; int *aLeft = aIdx; int *aRight = &aIdx[nLeft]; SortByDistance(aLeft, nLeft, aDistance, aSpare); SortByDistance(aRight, nRight, aDistance, aSpare); memcpy(aSpare, aLeft, sizeof(int)*nLeft); aLeft = aSpare; while( iLeft<nLeft || iRight<nRight ){ if( iLeft==nLeft ){ aIdx[iLeft+iRight] = aRight[iRight]; iRight++; }else if( iRight==nRight ){ aIdx[iLeft+iRight] = aLeft[iLeft]; iLeft++; }else{ float fLeft = aDistance[aLeft[iLeft]]; float fRight = aDistance[aRight[iRight]]; if( fLeft<fRight ){ aIdx[iLeft+iRight] = aLeft[iLeft]; iLeft++; }else{ aIdx[iLeft+iRight] = aRight[iRight]; iRight++; } } } #if 0 /* Check that the sort worked */ { int jj; for(jj=1; jj<nIdx; jj++){ float left = aDistance[aIdx[jj-1]]; float right = aDistance[aIdx[jj]]; assert( left<=right ); } } #endif } } /* ** Arguments aIdx, aCell and aSpare all point to arrays of size ** nIdx. The aIdx array contains the set of integers from 0 to ** (nIdx-1) in no particular order. This function sorts the values ** in aIdx according to dimension iDim of the cells in aCell. The ** minimum value of dimension iDim is considered first, the ** maximum used to break ties. ** ** The aSpare array is used as temporary working space by the ** sorting algorithm. */ static void SortByDimension( Rtree *pRtree, int *aIdx, int nIdx, int iDim, RtreeCell *aCell, int *aSpare ){ if( nIdx>1 ){ int iLeft = 0; int iRight = 0; int nLeft = nIdx/2; int nRight = nIdx-nLeft; int *aLeft = aIdx; int *aRight = &aIdx[nLeft]; SortByDimension(pRtree, aLeft, nLeft, iDim, aCell, aSpare); SortByDimension(pRtree, aRight, nRight, iDim, aCell, aSpare); memcpy(aSpare, aLeft, sizeof(int)*nLeft); aLeft = aSpare; while( iLeft<nLeft || iRight<nRight ){ double xleft1 = DCOORD(aCell[aLeft[iLeft]].aCoord[iDim*2]); double xleft2 = DCOORD(aCell[aLeft[iLeft]].aCoord[iDim*2+1]); double xright1 = DCOORD(aCell[aRight[iRight]].aCoord[iDim*2]); double xright2 = DCOORD(aCell[aRight[iRight]].aCoord[iDim*2+1]); if( (iLeft!=nLeft) && ((iRight==nRight) || (xleft1<xright1) || (xleft1==xright1 && xleft2<xright2) )){ aIdx[iLeft+iRight] = aLeft[iLeft]; iLeft++; }else{ aIdx[iLeft+iRight] = aRight[iRight]; iRight++; } } #if 0 /* Check that the sort worked */ { int jj; for(jj=1; jj<nIdx; jj++){ float xleft1 = aCell[aIdx[jj-1]].aCoord[iDim*2]; float xleft2 = aCell[aIdx[jj-1]].aCoord[iDim*2+1]; float xright1 = aCell[aIdx[jj]].aCoord[iDim*2]; float xright2 = aCell[aIdx[jj]].aCoord[iDim*2+1]; assert( xleft1<=xright1 && (xleft1<xright1 || xleft2<=xright2) ); } } #endif } } #if VARIANT_RSTARTREE_SPLIT /* ** Implementation of the R*-tree variant of SplitNode from Beckman[1990]. */ static int splitNodeStartree( Rtree *pRtree, RtreeCell *aCell, int nCell, RtreeNode *pLeft, RtreeNode *pRight, RtreeCell *pBboxLeft, RtreeCell *pBboxRight ){ int **aaSorted; int *aSpare; int ii; int iBestDim; int iBestSplit; float fBestMargin; int nByte = (pRtree->nDim+1)*(sizeof(int*)+nCell*sizeof(int)); aaSorted = (int **)sqlite3_malloc(nByte); if( !aaSorted ){ return SQLITE_NOMEM; } aSpare = &((int *)&aaSorted[pRtree->nDim])[pRtree->nDim*nCell]; memset(aaSorted, 0, nByte); for(ii=0; ii<pRtree->nDim; ii++){ int jj; aaSorted[ii] = &((int *)&aaSorted[pRtree->nDim])[ii*nCell]; for(jj=0; jj<nCell; jj++){ aaSorted[ii][jj] = jj; } SortByDimension(pRtree, aaSorted[ii], nCell, ii, aCell, aSpare); } for(ii=0; ii<pRtree->nDim; ii++){ float margin = 0.0; float fBestOverlap; float fBestArea; int iBestLeft; int nLeft; for( nLeft=RTREE_MINCELLS(pRtree); nLeft<=(nCell-RTREE_MINCELLS(pRtree)); nLeft++ ){ RtreeCell left; RtreeCell right; int kk; float overlap; float area; memcpy(&left, &aCell[aaSorted[ii][0]], sizeof(RtreeCell)); memcpy(&right, &aCell[aaSorted[ii][nCell-1]], sizeof(RtreeCell)); for(kk=1; kk<(nCell-1); kk++){ if( kk<nLeft ){ cellUnion(pRtree, &left, &aCell[aaSorted[ii][kk]]); }else{ cellUnion(pRtree, &right, &aCell[aaSorted[ii][kk]]); } } margin += cellMargin(pRtree, &left); margin += cellMargin(pRtree, &right); overlap = cellOverlap(pRtree, &left, &right, 1, -1); area = cellArea(pRtree, &left) + cellArea(pRtree, &right); if( (nLeft==RTREE_MINCELLS(pRtree)) || (overlap<fBestOverlap) || (overlap==fBestOverlap && area<fBestArea) ){ iBestLeft = nLeft; fBestOverlap = overlap; fBestArea = area; } } if( ii==0 || margin<fBestMargin ){ iBestDim = ii; fBestMargin = margin; iBestSplit = iBestLeft; } } memcpy(pBboxLeft, &aCell[aaSorted[iBestDim][0]], sizeof(RtreeCell)); memcpy(pBboxRight, &aCell[aaSorted[iBestDim][iBestSplit]], sizeof(RtreeCell)); for(ii=0; ii<nCell; ii++){ RtreeNode *pTarget = (ii<iBestSplit)?pLeft:pRight; RtreeCell *pBbox = (ii<iBestSplit)?pBboxLeft:pBboxRight; RtreeCell *pCell = &aCell[aaSorted[iBestDim][ii]]; nodeInsertCell(pRtree, pTarget, pCell); cellUnion(pRtree, pBbox, pCell); } sqlite3_free(aaSorted); return SQLITE_OK; } #endif #if VARIANT_GUTTMAN_SPLIT /* ** Implementation of the regular R-tree SplitNode from Guttman[1984]. */ static int splitNodeGuttman( Rtree *pRtree, RtreeCell *aCell, int nCell, RtreeNode *pLeft, RtreeNode *pRight, RtreeCell *pBboxLeft, RtreeCell *pBboxRight ){ int iLeftSeed = 0; int iRightSeed = 1; int *aiUsed; int i; aiUsed = sqlite3_malloc(sizeof(int)*nCell); if( !aiUsed ){ return SQLITE_NOMEM; } memset(aiUsed, 0, sizeof(int)*nCell); PickSeeds(pRtree, aCell, nCell, &iLeftSeed, &iRightSeed); memcpy(pBboxLeft, &aCell[iLeftSeed], sizeof(RtreeCell)); memcpy(pBboxRight, &aCell[iRightSeed], sizeof(RtreeCell)); nodeInsertCell(pRtree, pLeft, &aCell[iLeftSeed]); nodeInsertCell(pRtree, pRight, &aCell[iRightSeed]); aiUsed[iLeftSeed] = 1; aiUsed[iRightSeed] = 1; for(i=nCell-2; i>0; i--){ RtreeCell *pNext; pNext = PickNext(pRtree, aCell, nCell, pBboxLeft, pBboxRight, aiUsed); float diff = cellGrowth(pRtree, pBboxLeft, pNext) - cellGrowth(pRtree, pBboxRight, pNext) ; if( (RTREE_MINCELLS(pRtree)-NCELL(pRight)==i) || (diff>0.0 && (RTREE_MINCELLS(pRtree)-NCELL(pLeft)!=i)) ){ nodeInsertCell(pRtree, pRight, pNext); cellUnion(pRtree, pBboxRight, pNext); }else{ nodeInsertCell(pRtree, pLeft, pNext); cellUnion(pRtree, pBboxLeft, pNext); } } sqlite3_free(aiUsed); return SQLITE_OK; } #endif static int updateMapping( Rtree *pRtree, i64 iRowid, RtreeNode *pNode, int iHeight ){ int (*xSetMapping)(Rtree *, sqlite3_int64, sqlite3_int64); xSetMapping = ((iHeight==0)?rowidWrite:parentWrite); if( iHeight>0 ){ RtreeNode *pChild = nodeHashLookup(pRtree, iRowid); if( pChild ){ nodeRelease(pRtree, pChild->pParent); nodeReference(pNode); pChild->pParent = pNode; } } return xSetMapping(pRtree, iRowid, pNode->iNode); } static int SplitNode( Rtree *pRtree, RtreeNode *pNode, RtreeCell *pCell, int iHeight ){ int i; int newCellIsRight = 0; int rc = SQLITE_OK; int nCell = NCELL(pNode); RtreeCell *aCell; int *aiUsed; RtreeNode *pLeft = 0; RtreeNode *pRight = 0; RtreeCell leftbbox; RtreeCell rightbbox; /* Allocate an array and populate it with a copy of pCell and ** all cells from node pLeft. Then zero the original node. */ aCell = sqlite3_malloc((sizeof(RtreeCell)+sizeof(int))*(nCell+1)); if( !aCell ){ rc = SQLITE_NOMEM; goto splitnode_out; } aiUsed = (int *)&aCell[nCell+1]; memset(aiUsed, 0, sizeof(int)*(nCell+1)); for(i=0; i<nCell; i++){ nodeGetCell(pRtree, pNode, i, &aCell[i]); } nodeZero(pRtree, pNode); memcpy(&aCell[nCell], pCell, sizeof(RtreeCell)); nCell++; if( pNode->iNode==1 ){ pRight = nodeNew(pRtree, pNode, 1); pLeft = nodeNew(pRtree, pNode, 1); pRtree->iDepth++; pNode->isDirty = 1; writeInt16(pNode->zData, pRtree->iDepth); }else{ pLeft = pNode; pRight = nodeNew(pRtree, pLeft->pParent, 1); nodeReference(pLeft); } if( !pLeft || !pRight ){ rc = SQLITE_NOMEM; goto splitnode_out; } memset(pLeft->zData, 0, pRtree->iNodeSize); memset(pRight->zData, 0, pRtree->iNodeSize); rc = AssignCells(pRtree, aCell, nCell, pLeft, pRight, &leftbbox, &rightbbox); if( rc!=SQLITE_OK ){ goto splitnode_out; } /* Ensure both child nodes have node numbers assigned to them. */ if( (0==pRight->iNode && SQLITE_OK!=(rc = nodeWrite(pRtree, pRight))) || (0==pLeft->iNode && SQLITE_OK!=(rc = nodeWrite(pRtree, pLeft))) ){ goto splitnode_out; } rightbbox.iRowid = pRight->iNode; leftbbox.iRowid = pLeft->iNode; if( pNode->iNode==1 ){ rc = rtreeInsertCell(pRtree, pLeft->pParent, &leftbbox, iHeight+1); if( rc!=SQLITE_OK ){ goto splitnode_out; } }else{ RtreeNode *pParent = pLeft->pParent; int iCell = nodeParentIndex(pRtree, pLeft); nodeOverwriteCell(pRtree, pParent, &leftbbox, iCell); AdjustTree(pRtree, pParent, &leftbbox); } if( (rc = rtreeInsertCell(pRtree, pRight->pParent, &rightbbox, iHeight+1)) ){ goto splitnode_out; } for(i=0; i<NCELL(pRight); i++){ i64 iRowid = nodeGetRowid(pRtree, pRight, i); rc = updateMapping(pRtree, iRowid, pRight, iHeight); if( iRowid==pCell->iRowid ){ newCellIsRight = 1; } if( rc!=SQLITE_OK ){ goto splitnode_out; } } if( pNode->iNode==1 ){ for(i=0; i<NCELL(pLeft); i++){ i64 iRowid = nodeGetRowid(pRtree, pLeft, i); rc = updateMapping(pRtree, iRowid, pLeft, iHeight); if( rc!=SQLITE_OK ){ goto splitnode_out; } } }else if( newCellIsRight==0 ){ rc = updateMapping(pRtree, pCell->iRowid, pLeft, iHeight); } if( rc==SQLITE_OK ){ rc = nodeRelease(pRtree, pRight); pRight = 0; } if( rc==SQLITE_OK ){ rc = nodeRelease(pRtree, pLeft); pLeft = 0; } splitnode_out: nodeRelease(pRtree, pRight); nodeRelease(pRtree, pLeft); sqlite3_free(aCell); return rc; } static int fixLeafParent(Rtree *pRtree, RtreeNode *pLeaf){ int rc = SQLITE_OK; if( pLeaf->iNode!=1 && pLeaf->pParent==0 ){ sqlite3_bind_int64(pRtree->pReadParent, 1, pLeaf->iNode); if( sqlite3_step(pRtree->pReadParent)==SQLITE_ROW ){ i64 iNode = sqlite3_column_int64(pRtree->pReadParent, 0); rc = nodeAcquire(pRtree, iNode, 0, &pLeaf->pParent); }else{ rc = SQLITE_ERROR; } sqlite3_reset(pRtree->pReadParent); if( rc==SQLITE_OK ){ rc = fixLeafParent(pRtree, pLeaf->pParent); } } return rc; } static int deleteCell(Rtree *, RtreeNode *, int, int); static int removeNode(Rtree *pRtree, RtreeNode *pNode, int iHeight){ int rc; RtreeNode *pParent; int iCell; assert( pNode->nRef==1 ); /* Remove the entry in the parent cell. */ iCell = nodeParentIndex(pRtree, pNode); pParent = pNode->pParent; pNode->pParent = 0; if( SQLITE_OK!=(rc = deleteCell(pRtree, pParent, iCell, iHeight+1)) || SQLITE_OK!=(rc = nodeRelease(pRtree, pParent)) ){ return rc; } /* Remove the xxx_node entry. */ sqlite3_bind_int64(pRtree->pDeleteNode, 1, pNode->iNode); sqlite3_step(pRtree->pDeleteNode); if( SQLITE_OK!=(rc = sqlite3_reset(pRtree->pDeleteNode)) ){ return rc; } /* Remove the xxx_parent entry. */ sqlite3_bind_int64(pRtree->pDeleteParent, 1, pNode->iNode); sqlite3_step(pRtree->pDeleteParent); if( SQLITE_OK!=(rc = sqlite3_reset(pRtree->pDeleteParent)) ){ return rc; } /* Remove the node from the in-memory hash table and link it into ** the Rtree.pDeleted list. Its contents will be re-inserted later on. */ nodeHashDelete(pRtree, pNode); pNode->iNode = iHeight; pNode->pNext = pRtree->pDeleted; pNode->nRef++; pRtree->pDeleted = pNode; return SQLITE_OK; } static void fixBoundingBox(Rtree *pRtree, RtreeNode *pNode){ RtreeNode *pParent = pNode->pParent; if( pParent ){ int ii; int nCell = NCELL(pNode); RtreeCell box; /* Bounding box for pNode */ nodeGetCell(pRtree, pNode, 0, &box); for(ii=1; ii<nCell; ii++){ RtreeCell cell; nodeGetCell(pRtree, pNode, ii, &cell); cellUnion(pRtree, &box, &cell); } box.iRowid = pNode->iNode; ii = nodeParentIndex(pRtree, pNode); nodeOverwriteCell(pRtree, pParent, &box, ii); fixBoundingBox(pRtree, pParent); } } /* ** Delete the cell at index iCell of node pNode. After removing the ** cell, adjust the r-tree data structure if required. */ static int deleteCell(Rtree *pRtree, RtreeNode *pNode, int iCell, int iHeight){ int rc; if( SQLITE_OK!=(rc = fixLeafParent(pRtree, pNode)) ){ return rc; } /* Remove the cell from the node. This call just moves bytes around ** the in-memory node image, so it cannot fail. */ nodeDeleteCell(pRtree, pNode, iCell); /* If the node is not the tree root and now has less than the minimum ** number of cells, remove it from the tree. Otherwise, update the ** cell in the parent node so that it tightly contains the updated ** node. */ if( pNode->iNode!=1 ){ RtreeNode *pParent = pNode->pParent; if( (pParent->iNode!=1 || NCELL(pParent)!=1) && (NCELL(pNode)<RTREE_MINCELLS(pRtree)) ){ rc = removeNode(pRtree, pNode, iHeight); }else{ fixBoundingBox(pRtree, pNode); } } return rc; } static int Reinsert( Rtree *pRtree, RtreeNode *pNode, RtreeCell *pCell, int iHeight ){ int *aOrder; int *aSpare; RtreeCell *aCell; float *aDistance; int nCell; float aCenterCoord[RTREE_MAX_DIMENSIONS]; int iDim; int ii; int rc = SQLITE_OK; memset(aCenterCoord, 0, sizeof(float)*RTREE_MAX_DIMENSIONS); nCell = NCELL(pNode)+1; /* Allocate the buffers used by this operation. The allocation is ** relinquished before this function returns. */ aCell = (RtreeCell *)sqlite3_malloc(nCell * ( sizeof(RtreeCell) + /* aCell array */ sizeof(int) + /* aOrder array */ sizeof(int) + /* aSpare array */ sizeof(float) /* aDistance array */ )); if( !aCell ){ return SQLITE_NOMEM; } aOrder = (int *)&aCell[nCell]; aSpare = (int *)&aOrder[nCell]; aDistance = (float *)&aSpare[nCell]; for(ii=0; ii<nCell; ii++){ if( ii==(nCell-1) ){ memcpy(&aCell[ii], pCell, sizeof(RtreeCell)); }else{ nodeGetCell(pRtree, pNode, ii, &aCell[ii]); } aOrder[ii] = ii; for(iDim=0; iDim<pRtree->nDim; iDim++){ aCenterCoord[iDim] += DCOORD(aCell[ii].aCoord[iDim*2]); aCenterCoord[iDim] += DCOORD(aCell[ii].aCoord[iDim*2+1]); } } for(iDim=0; iDim<pRtree->nDim; iDim++){ aCenterCoord[iDim] = aCenterCoord[iDim]/((float)nCell*2.0); } for(ii=0; ii<nCell; ii++){ aDistance[ii] = 0.0; for(iDim=0; iDim<pRtree->nDim; iDim++){ float coord = DCOORD(aCell[ii].aCoord[iDim*2+1]) - DCOORD(aCell[ii].aCoord[iDim*2]); aDistance[ii] += (coord-aCenterCoord[iDim])*(coord-aCenterCoord[iDim]); } } SortByDistance(aOrder, nCell, aDistance, aSpare); nodeZero(pRtree, pNode); for(ii=0; rc==SQLITE_OK && ii<(nCell-(RTREE_MINCELLS(pRtree)+1)); ii++){ RtreeCell *p = &aCell[aOrder[ii]]; nodeInsertCell(pRtree, pNode, p); if( p->iRowid==pCell->iRowid ){ if( iHeight==0 ){ rc = rowidWrite(pRtree, p->iRowid, pNode->iNode); }else{ rc = parentWrite(pRtree, p->iRowid, pNode->iNode); } } } if( rc==SQLITE_OK ){ fixBoundingBox(pRtree, pNode); } for(; rc==SQLITE_OK && ii<nCell; ii++){ /* Find a node to store this cell in. pNode->iNode currently contains ** the height of the sub-tree headed by the cell. */ RtreeNode *pInsert; RtreeCell *p = &aCell[aOrder[ii]]; rc = ChooseLeaf(pRtree, p, iHeight, &pInsert); if( rc==SQLITE_OK ){ int rc2; rc = rtreeInsertCell(pRtree, pInsert, p, iHeight); rc2 = nodeRelease(pRtree, pInsert); if( rc==SQLITE_OK ){ rc = rc2; } } } sqlite3_free(aCell); return rc; } /* ** Insert cell pCell into node pNode. Node pNode is the head of a ** subtree iHeight high (leaf nodes have iHeight==0). */ static int rtreeInsertCell( Rtree *pRtree, RtreeNode *pNode, RtreeCell *pCell, int iHeight ){ int rc = SQLITE_OK; if( iHeight>0 ){ RtreeNode *pChild = nodeHashLookup(pRtree, pCell->iRowid); if( pChild ){ nodeRelease(pRtree, pChild->pParent); nodeReference(pNode); pChild->pParent = pNode; } } if( nodeInsertCell(pRtree, pNode, pCell) ){ #if VARIANT_RSTARTREE_REINSERT if( iHeight<=pRtree->iReinsertHeight || pNode->iNode==1){ rc = SplitNode(pRtree, pNode, pCell, iHeight); }else{ pRtree->iReinsertHeight = iHeight; rc = Reinsert(pRtree, pNode, pCell, iHeight); } #else rc = SplitNode(pRtree, pNode, pCell, iHeight); #endif }else{ AdjustTree(pRtree, pNode, pCell); if( iHeight==0 ){ rc = rowidWrite(pRtree, pCell->iRowid, pNode->iNode); }else{ rc = parentWrite(pRtree, pCell->iRowid, pNode->iNode); } } return rc; } static int reinsertNodeContent(Rtree *pRtree, RtreeNode *pNode){ int ii; int rc = SQLITE_OK; int nCell = NCELL(pNode); for(ii=0; rc==SQLITE_OK && ii<nCell; ii++){ RtreeNode *pInsert; RtreeCell cell; nodeGetCell(pRtree, pNode, ii, &cell); /* Find a node to store this cell in. pNode->iNode currently contains ** the height of the sub-tree headed by the cell. */ rc = ChooseLeaf(pRtree, &cell, pNode->iNode, &pInsert); if( rc==SQLITE_OK ){ int rc2; rc = rtreeInsertCell(pRtree, pInsert, &cell, pNode->iNode); rc2 = nodeRelease(pRtree, pInsert); if( rc==SQLITE_OK ){ rc = rc2; } } } return rc; } /* ** Select a currently unused rowid for a new r-tree record. */ static int newRowid(Rtree *pRtree, i64 *piRowid){ int rc; sqlite3_bind_null(pRtree->pWriteRowid, 1); sqlite3_bind_null(pRtree->pWriteRowid, 2); sqlite3_step(pRtree->pWriteRowid); rc = sqlite3_reset(pRtree->pWriteRowid); *piRowid = sqlite3_last_insert_rowid(pRtree->db); return rc; } #ifndef NDEBUG static int hashIsEmpty(Rtree *pRtree){ int ii; for(ii=0; ii<HASHSIZE; ii++){ assert( !pRtree->aHash[ii] ); } return 1; } #endif /* ** The xUpdate method for rtree module virtual tables. */ static int rtreeUpdate( sqlite3_vtab *pVtab, int nData, sqlite3_value **azData, sqlite_int64 *pRowid ){ Rtree *pRtree = (Rtree *)pVtab; int rc = SQLITE_OK; rtreeReference(pRtree); assert(nData>=1); assert(hashIsEmpty(pRtree)); /* If azData[0] is not an SQL NULL value, it is the rowid of a ** record to delete from the r-tree table. The following block does ** just that. */ if( sqlite3_value_type(azData[0])!=SQLITE_NULL ){ i64 iDelete; /* The rowid to delete */ RtreeNode *pLeaf; /* Leaf node containing record iDelete */ int iCell; /* Index of iDelete cell in pLeaf */ RtreeNode *pRoot; /* Obtain a reference to the root node to initialise Rtree.iDepth */ rc = nodeAcquire(pRtree, 1, 0, &pRoot); /* Obtain a reference to the leaf node that contains the entry ** about to be deleted. */ if( rc==SQLITE_OK ){ iDelete = sqlite3_value_int64(azData[0]); rc = findLeafNode(pRtree, iDelete, &pLeaf); } /* Delete the cell in question from the leaf node. */ if( rc==SQLITE_OK ){ int rc2; iCell = nodeRowidIndex(pRtree, pLeaf, iDelete); rc = deleteCell(pRtree, pLeaf, iCell, 0); rc2 = nodeRelease(pRtree, pLeaf); if( rc==SQLITE_OK ){ rc = rc2; } } /* Delete the corresponding entry in the <rtree>_rowid table. */ if( rc==SQLITE_OK ){ sqlite3_bind_int64(pRtree->pDeleteRowid, 1, iDelete); sqlite3_step(pRtree->pDeleteRowid); rc = sqlite3_reset(pRtree->pDeleteRowid); } /* Check if the root node now has exactly one child. If so, remove ** it, schedule the contents of the child for reinsertion and ** reduce the tree height by one. ** ** This is equivalent to copying the contents of the child into ** the root node (the operation that Gutman's paper says to perform ** in this scenario). */ if( rc==SQLITE_OK && pRtree->iDepth>0 ){ if( rc==SQLITE_OK && NCELL(pRoot)==1 ){ RtreeNode *pChild; i64 iChild = nodeGetRowid(pRtree, pRoot, 0); rc = nodeAcquire(pRtree, iChild, pRoot, &pChild); if( rc==SQLITE_OK ){ rc = removeNode(pRtree, pChild, pRtree->iDepth-1); } if( rc==SQLITE_OK ){ pRtree->iDepth--; writeInt16(pRoot->zData, pRtree->iDepth); pRoot->isDirty = 1; } } } /* Re-insert the contents of any underfull nodes removed from the tree. */ for(pLeaf=pRtree->pDeleted; pLeaf; pLeaf=pRtree->pDeleted){ if( rc==SQLITE_OK ){ rc = reinsertNodeContent(pRtree, pLeaf); } pRtree->pDeleted = pLeaf->pNext; sqlite3_free(pLeaf); } /* Release the reference to the root node. */ if( rc==SQLITE_OK ){ rc = nodeRelease(pRtree, pRoot); }else{ nodeRelease(pRtree, pRoot); } } /* If the azData[] array contains more than one element, elements ** (azData[2]..azData[argc-1]) contain a new record to insert into ** the r-tree structure. */ if( rc==SQLITE_OK && nData>1 ){ /* Insert a new record into the r-tree */ RtreeCell cell; int ii; RtreeNode *pLeaf; /* Populate the cell.aCoord[] array. The first coordinate is azData[3]. */ assert( nData==(pRtree->nDim*2 + 3) ); if( pRtree->eCoordType==RTREE_COORD_REAL32 ){ for(ii=0; ii<(pRtree->nDim*2); ii+=2){ cell.aCoord[ii].f = (float)sqlite3_value_double(azData[ii+3]); cell.aCoord[ii+1].f = (float)sqlite3_value_double(azData[ii+4]); if( cell.aCoord[ii].f>cell.aCoord[ii+1].f ){ rc = SQLITE_CONSTRAINT; goto constraint; } } }else{ for(ii=0; ii<(pRtree->nDim*2); ii+=2){ cell.aCoord[ii].i = sqlite3_value_int(azData[ii+3]); cell.aCoord[ii+1].i = sqlite3_value_int(azData[ii+4]); if( cell.aCoord[ii].i>cell.aCoord[ii+1].i ){ rc = SQLITE_CONSTRAINT; goto constraint; } } } /* Figure out the rowid of the new row. */ if( sqlite3_value_type(azData[2])==SQLITE_NULL ){ rc = newRowid(pRtree, &cell.iRowid); }else{ cell.iRowid = sqlite3_value_int64(azData[2]); sqlite3_bind_int64(pRtree->pReadRowid, 1, cell.iRowid); if( SQLITE_ROW==sqlite3_step(pRtree->pReadRowid) ){ sqlite3_reset(pRtree->pReadRowid); rc = SQLITE_CONSTRAINT; goto constraint; } rc = sqlite3_reset(pRtree->pReadRowid); } *pRowid = cell.iRowid; if( rc==SQLITE_OK ){ rc = ChooseLeaf(pRtree, &cell, 0, &pLeaf); } if( rc==SQLITE_OK ){ int rc2; pRtree->iReinsertHeight = -1; rc = rtreeInsertCell(pRtree, pLeaf, &cell, 0); rc2 = nodeRelease(pRtree, pLeaf); if( rc==SQLITE_OK ){ rc = rc2; } } } constraint: rtreeRelease(pRtree); return rc; } /* ** The xRename method for rtree module virtual tables. */ static int rtreeRename(sqlite3_vtab *pVtab, const char *zNewName){ Rtree *pRtree = (Rtree *)pVtab; int rc = SQLITE_NOMEM; char *zSql = sqlite3_mprintf( "ALTER TABLE %Q.'%q_node' RENAME TO \"%w_node\";" "ALTER TABLE %Q.'%q_parent' RENAME TO \"%w_parent\";" "ALTER TABLE %Q.'%q_rowid' RENAME TO \"%w_rowid\";" , pRtree->zDb, pRtree->zName, zNewName , pRtree->zDb, pRtree->zName, zNewName , pRtree->zDb, pRtree->zName, zNewName ); if( zSql ){ rc = sqlite3_exec(pRtree->db, zSql, 0, 0, 0); sqlite3_free(zSql); } return rc; } static sqlite3_module rtreeModule = { 0, /* iVersion */ rtreeCreate, /* xCreate - create a table */ rtreeConnect, /* xConnect - connect to an existing table */ rtreeBestIndex, /* xBestIndex - Determine search strategy */ rtreeDisconnect, /* xDisconnect - Disconnect from a table */ rtreeDestroy, /* xDestroy - Drop a table */ rtreeOpen, /* xOpen - open a cursor */ rtreeClose, /* xClose - close a cursor */ rtreeFilter, /* xFilter - configure scan constraints */ rtreeNext, /* xNext - advance a cursor */ rtreeEof, /* xEof */ rtreeColumn, /* xColumn - read data */ rtreeRowid, /* xRowid - read data */ rtreeUpdate, /* xUpdate - write data */ 0, /* xBegin - begin transaction */ 0, /* xSync - sync transaction */ 0, /* xCommit - commit transaction */ 0, /* xRollback - rollback transaction */ 0, /* xFindFunction - function overloading */ rtreeRename /* xRename - rename the table */ }; static int rtreeSqlInit( Rtree *pRtree, sqlite3 *db, const char *zDb, const char *zPrefix, int isCreate ){ int rc = SQLITE_OK; #define N_STATEMENT 9 static const char *azSql[N_STATEMENT] = { /* Read and write the xxx_node table */ "SELECT data FROM '%q'.'%q_node' WHERE nodeno = :1", "INSERT OR REPLACE INTO '%q'.'%q_node' VALUES(:1, :2)", "DELETE FROM '%q'.'%q_node' WHERE nodeno = :1", /* Read and write the xxx_rowid table */ "SELECT nodeno FROM '%q'.'%q_rowid' WHERE rowid = :1", "INSERT OR REPLACE INTO '%q'.'%q_rowid' VALUES(:1, :2)", "DELETE FROM '%q'.'%q_rowid' WHERE rowid = :1", /* Read and write the xxx_parent table */ "SELECT parentnode FROM '%q'.'%q_parent' WHERE nodeno = :1", "INSERT OR REPLACE INTO '%q'.'%q_parent' VALUES(:1, :2)", "DELETE FROM '%q'.'%q_parent' WHERE nodeno = :1" }; sqlite3_stmt **appStmt[N_STATEMENT]; int i; pRtree->db = db; if( isCreate ){ char *zCreate = sqlite3_mprintf( "CREATE TABLE \"%w\".\"%w_node\"(nodeno INTEGER PRIMARY KEY, data BLOB);" "CREATE TABLE \"%w\".\"%w_rowid\"(rowid INTEGER PRIMARY KEY, nodeno INTEGER);" "CREATE TABLE \"%w\".\"%w_parent\"(nodeno INTEGER PRIMARY KEY, parentnode INTEGER);" "INSERT INTO '%q'.'%q_node' VALUES(1, zeroblob(%d))", zDb, zPrefix, zDb, zPrefix, zDb, zPrefix, zDb, zPrefix, pRtree->iNodeSize ); if( !zCreate ){ return SQLITE_NOMEM; } rc = sqlite3_exec(db, zCreate, 0, 0, 0); sqlite3_free(zCreate); if( rc!=SQLITE_OK ){ return rc; } } appStmt[0] = &pRtree->pReadNode; appStmt[1] = &pRtree->pWriteNode; appStmt[2] = &pRtree->pDeleteNode; appStmt[3] = &pRtree->pReadRowid; appStmt[4] = &pRtree->pWriteRowid; appStmt[5] = &pRtree->pDeleteRowid; appStmt[6] = &pRtree->pReadParent; appStmt[7] = &pRtree->pWriteParent; appStmt[8] = &pRtree->pDeleteParent; for(i=0; i<N_STATEMENT && rc==SQLITE_OK; i++){ char *zSql = sqlite3_mprintf(azSql[i], zDb, zPrefix); if( zSql ){ rc = sqlite3_prepare_v2(db, zSql, -1, appStmt[i], 0); }else{ rc = SQLITE_NOMEM; } sqlite3_free(zSql); } return rc; } /* ** The second argument to this function contains the text of an SQL statement ** that returns a single integer value. The statement is compiled and executed ** using database connection db. If successful, the integer value returned ** is written to *piVal and SQLITE_OK returned. Otherwise, an SQLite error ** code is returned and the value of *piVal after returning is not defined. */ static int getIntFromStmt(sqlite3 *db, const char *zSql, int *piVal){ int rc = SQLITE_NOMEM; if( zSql ){ sqlite3_stmt *pStmt = 0; rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0); if( rc==SQLITE_OK ){ if( SQLITE_ROW==sqlite3_step(pStmt) ){ *piVal = sqlite3_column_int(pStmt, 0); } rc = sqlite3_finalize(pStmt); } } return rc; } /* ** This function is called from within the xConnect() or xCreate() method to ** determine the node-size used by the rtree table being created or connected ** to. If successful, pRtree->iNodeSize is populated and SQLITE_OK returned. ** Otherwise, an SQLite error code is returned. ** ** If this function is being called as part of an xConnect(), then the rtree ** table already exists. In this case the node-size is determined by inspecting ** the root node of the tree. ** ** Otherwise, for an xCreate(), use 64 bytes less than the database page-size. ** This ensures that each node is stored on a single database page. If the ** database page-size is so large that more than RTREE_MAXCELLS entries ** would fit in a single node, use a smaller node-size. */ static int getNodeSize( sqlite3 *db, /* Database handle */ Rtree *pRtree, /* Rtree handle */ int isCreate /* True for xCreate, false for xConnect */ ){ int rc; char *zSql; if( isCreate ){ int iPageSize; zSql = sqlite3_mprintf("PRAGMA %Q.page_size", pRtree->zDb); rc = getIntFromStmt(db, zSql, &iPageSize); if( rc==SQLITE_OK ){ pRtree->iNodeSize = iPageSize-64; if( (4+pRtree->nBytesPerCell*RTREE_MAXCELLS)<pRtree->iNodeSize ){ pRtree->iNodeSize = 4+pRtree->nBytesPerCell*RTREE_MAXCELLS; } } }else{ zSql = sqlite3_mprintf( "SELECT length(data) FROM '%q'.'%q_node' WHERE nodeno = 1", pRtree->zDb, pRtree->zName ); rc = getIntFromStmt(db, zSql, &pRtree->iNodeSize); } sqlite3_free(zSql); return rc; } /* ** This function is the implementation of both the xConnect and xCreate ** methods of the r-tree virtual table. ** ** argv[0] -> module name ** argv[1] -> database name ** argv[2] -> table name ** argv[...] -> column names... */ static int rtreeInit( sqlite3 *db, /* Database connection */ void *pAux, /* One of the RTREE_COORD_* constants */ int argc, const char *const*argv, /* Parameters to CREATE TABLE statement */ sqlite3_vtab **ppVtab, /* OUT: New virtual table */ char **pzErr, /* OUT: Error message, if any */ int isCreate /* True for xCreate, false for xConnect */ ){ int rc = SQLITE_OK; Rtree *pRtree; int nDb; /* Length of string argv[1] */ int nName; /* Length of string argv[2] */ int eCoordType = (int)pAux; const char *aErrMsg[] = { 0, /* 0 */ "Wrong number of columns for an rtree table", /* 1 */ "Too few columns for an rtree table", /* 2 */ "Too many columns for an rtree table" /* 3 */ }; int iErr = (argc<6) ? 2 : argc>(RTREE_MAX_DIMENSIONS*2+4) ? 3 : argc%2; if( aErrMsg[iErr] ){ *pzErr = sqlite3_mprintf("%s", aErrMsg[iErr]); return SQLITE_ERROR; } /* Allocate the sqlite3_vtab structure */ nDb = strlen(argv[1]); nName = strlen(argv[2]); pRtree = (Rtree *)sqlite3_malloc(sizeof(Rtree)+nDb+nName+2); if( !pRtree ){ return SQLITE_NOMEM; } memset(pRtree, 0, sizeof(Rtree)+nDb+nName+2); pRtree->nBusy = 1; pRtree->base.pModule = &rtreeModule; pRtree->zDb = (char *)&pRtree[1]; pRtree->zName = &pRtree->zDb[nDb+1]; pRtree->nDim = (argc-4)/2; pRtree->nBytesPerCell = 8 + pRtree->nDim*4*2; pRtree->eCoordType = eCoordType; memcpy(pRtree->zDb, argv[1], nDb); memcpy(pRtree->zName, argv[2], nName); /* Figure out the node size to use. */ rc = getNodeSize(db, pRtree, isCreate); /* Create/Connect to the underlying relational database schema. If ** that is successful, call sqlite3_declare_vtab() to configure ** the r-tree table schema. */ if( rc==SQLITE_OK ){ if( (rc = rtreeSqlInit(pRtree, db, argv[1], argv[2], isCreate)) ){ *pzErr = sqlite3_mprintf("%s", sqlite3_errmsg(db)); }else{ char *zSql = sqlite3_mprintf("CREATE TABLE x(%s", argv[3]); char *zTmp; int ii; for(ii=4; zSql && ii<argc; ii++){ zTmp = zSql; zSql = sqlite3_mprintf("%s, %s", zTmp, argv[ii]); sqlite3_free(zTmp); } if( zSql ){ zTmp = zSql; zSql = sqlite3_mprintf("%s);", zTmp); sqlite3_free(zTmp); } if( !zSql ){ rc = SQLITE_NOMEM; }else if( SQLITE_OK!=(rc = sqlite3_declare_vtab(db, zSql)) ){ *pzErr = sqlite3_mprintf("%s", sqlite3_errmsg(db)); } sqlite3_free(zSql); } } if( rc==SQLITE_OK ){ *ppVtab = (sqlite3_vtab *)pRtree; }else{ rtreeRelease(pRtree); } return rc; } /* ** Implementation of a scalar function that decodes r-tree nodes to ** human readable strings. This can be used for debugging and analysis. ** ** The scalar function takes two arguments, a blob of data containing ** an r-tree node, and the number of dimensions the r-tree indexes. ** For a two-dimensional r-tree structure called "rt", to deserialize ** all nodes, a statement like: ** ** SELECT rtreenode(2, data) FROM rt_node; ** ** The human readable string takes the form of a Tcl list with one ** entry for each cell in the r-tree node. Each entry is itself a ** list, containing the 8-byte rowid/pageno followed by the ** <num-dimension>*2 coordinates. */ static void rtreenode(sqlite3_context *ctx, int nArg, sqlite3_value **apArg){ char *zText = 0; RtreeNode node; Rtree tree; int ii; memset(&node, 0, sizeof(RtreeNode)); memset(&tree, 0, sizeof(Rtree)); tree.nDim = sqlite3_value_int(apArg[0]); tree.nBytesPerCell = 8 + 8 * tree.nDim; node.zData = (u8 *)sqlite3_value_blob(apArg[1]); for(ii=0; ii<NCELL(&node); ii++){ char zCell[512]; int nCell = 0; RtreeCell cell; int jj; nodeGetCell(&tree, &node, ii, &cell); sqlite3_snprintf(512-nCell,&zCell[nCell],"%d", cell.iRowid); nCell = strlen(zCell); for(jj=0; jj<tree.nDim*2; jj++){ sqlite3_snprintf(512-nCell,&zCell[nCell]," %f",(double)cell.aCoord[jj].f); nCell = strlen(zCell); } if( zText ){ char *zTextNew = sqlite3_mprintf("%s {%s}", zText, zCell); sqlite3_free(zText); zText = zTextNew; }else{ zText = sqlite3_mprintf("{%s}", zCell); } } sqlite3_result_text(ctx, zText, -1, sqlite3_free); } static void rtreedepth(sqlite3_context *ctx, int nArg, sqlite3_value **apArg){ if( sqlite3_value_type(apArg[0])!=SQLITE_BLOB || sqlite3_value_bytes(apArg[0])<2 ){ sqlite3_result_error(ctx, "Invalid argument to rtreedepth()", -1); }else{ u8 *zBlob = (u8 *)sqlite3_value_blob(apArg[0]); sqlite3_result_int(ctx, readInt16(zBlob)); } } /* ** Register the r-tree module with database handle db. This creates the ** virtual table module "rtree" and the debugging/analysis scalar ** function "rtreenode". */ int sqlite3RtreeInit(sqlite3 *db){ int rc = SQLITE_OK; if( rc==SQLITE_OK ){ int utf8 = SQLITE_UTF8; rc = sqlite3_create_function(db, "rtreenode", 2, utf8, 0, rtreenode, 0, 0); } if( rc==SQLITE_OK ){ int utf8 = SQLITE_UTF8; rc = sqlite3_create_function(db, "rtreedepth", 1, utf8, 0,rtreedepth, 0, 0); } if( rc==SQLITE_OK ){ void *c = (void *)RTREE_COORD_REAL32; rc = sqlite3_create_module_v2(db, "rtree", &rtreeModule, c, 0); } if( rc==SQLITE_OK ){ void *c = (void *)RTREE_COORD_INT32; rc = sqlite3_create_module_v2(db, "rtree_i32", &rtreeModule, c, 0); } return rc; } #if !SQLITE_CORE int sqlite3_extension_init( sqlite3 *db, char **pzErrMsg, const sqlite3_api_routines *pApi ){ SQLITE_EXTENSION_INIT2(pApi) return sqlite3RtreeInit(db); } #endif #endif
the_stack_data/226901.c
/*Vocรช estรก de volta em seu hotel na Tailรขndia depois de um dia de mergulhos. O seu quarto tem duas lรขmpadas. Vamos chamรก-las de A e B. No hotel hรก dois interruptores, que chamaremos de I1 e I2. Ao apertar I1, a lรขmpada A troca de estado, ou seja, acende se estiver apagada e apaga se estiver acesa. Se apertar I2, ambas as lรขmpadas A e B trocam de estado. As lรขmpadas inicialmente estรฃo ambas apagadas. Seu amigo resolveu bolar um desafio para vocรช. Ele irรก apertar os interruptores em uma certa sequรชncia, e gostaria que vocรช respondesse o estado final das lรขmpadas A e B. Entrada A primeira linha contรฉm um nรบmero N que representa quantas vezes seu amigo irรก apertar algum interruptor. Na linha seguinte seguirรฃo N nรบmeros, que pode ser 1, se o interruptor I1 foi apertado, ou 2, se o interruptor I2 foi apertado. Saรญda Seu programa deve imprimir dois valores, em linhas separadas. Na primeira linha, imprima 1 se a lรขmpada A estiver acesa no final das operaรงรตes e 0 caso contrรกrio. Na segunda linha, imprima 1 se a lรขmpada B estiver acesa no final das operaรงรตes e 0 caso contrรกrio. Restriรงรตes 1 โ‰ค N โ‰ค 105 */ #include <stdio.h> int main() { int N, I1 = 1, I2 = 2; printf("Quantas vezes o seu amigo apertou.\n"); scanf("%d", &N); if (N < 0 || N > 105){ printf("Seu nรบmero estรก fora dos parรขmetros."); } else if(N%2 != 0){ printf("A lampada A estรก acesa.\n"); printf("O interruptor foi apertado %d vezes.", N); } else if(N%2 == 0){ printf("A lรขmpada B estรก acesa.\n"); printf("O interuptor foi apertado %d vezes.", N); } return 0; }
the_stack_data/153267213.c
void fence() { asm("sync"); } void lwfence() { asm("lwsync"); } void isync() { asm("isync"); } int __unbuffered_cnt = 0; int __unbuffered_p2_EAX = 0; int __unbuffered_p3_EAX = 0; int a = 0; int x = 0; int y = 0; int z = 0; void *P0(void *arg) { a = 1; x = 1; // Instrumentation for CPROVER fence(); __unbuffered_cnt++; } void *P1(void *arg) { x = 2; y = 1; // Instrumentation for CPROVER fence(); __unbuffered_cnt++; } void *P2(void *arg) { y = 2; __unbuffered_p2_EAX = z; // Instrumentation for CPROVER fence(); __unbuffered_cnt++; } void *P3(void *arg) { z = 1; __unbuffered_p3_EAX = a; // Instrumentation for CPROVER fence(); __unbuffered_cnt++; } int main() { __CPROVER_ASYNC_0: P0(0); __CPROVER_ASYNC_1: P1(0); __CPROVER_ASYNC_2: P2(0); __CPROVER_ASYNC_3: P3(0); __CPROVER_assume(__unbuffered_cnt == 4); fence(); // EXPECT:exists __CPROVER_assert( !(x == 2 && y == 2 && __unbuffered_p2_EAX == 0 && __unbuffered_p3_EAX == 0), "Program proven to be relaxed for X86, model checker says YES."); return 0; }
the_stack_data/57949722.c
#include <stdio.h> #include <string.h> /** * An example program that has two functionalities: R1/ Ask for user's name and print it out R2/ Write 'hello 327' to the file specified by app argument if the user's name is 327. */ int main(int argc, char *argv[]) { char str[100]; printf("Hello world\n"); printf("Enter your name please:\n"); scanf("%s", str); printf("Hello %s\n", str); if (strcmp(str, "327") == 0) { FILE *fp; fp = fopen(argv[1], "w"); fprintf(fp, "hello 327\n"); fclose(fp); printf("file written!"); } return 0; }
the_stack_data/165766161.c
/* PR rtl-optimization/69886. */ /* { dg-do compile } */ /* { dg-options "--param=gcse-unrestricted-cost=0 -w -Wno-psabi" } */ /* { dg-additional-options "-mavx" { target { i?86-*-* x86_64-*-* } } } */ typedef unsigned v32su __attribute__ ((vector_size (32))); unsigned foo (v32su v32su_0, v32su v32su_1, v32su v32su_2, v32su v32su_3, v32su v32su_4) { v32su_3 += v32su_2 *= v32su_2[3]; if (v32su_4[3]) v32su_2 &= (v32su){ v32su_1[3], 0xbb72, 64 }; return v32su_0[2] + v32su_2[4] + v32su_3[1]; }
the_stack_data/85682.c
/************************************************* PI calculation separated omp for, with different scheduling policies The result will be slightly different from one run to another if dynamic/guided scheduling is used since the different orders of floating point operations By C.Liao **************************************************/ #include <stdio.h> #ifdef _OPENMP #include "omp.h" #endif static long num_steps = 10000000; double step; int k_3 = 100; // int k_4=100; int main () { double x, pi, sum = 0.0; int i; step = 1.0 / (double) num_steps; int chunksize=100; int lower =10, upper =100, stride = 3; #pragma omp parallel private (x) { #pragma omp single printf ("Running using %d threads..\n", omp_get_num_threads ()); #pragma omp for reduction(+:sum) for (i = lower; i < upper; i+=stride) { k_3++; x = (i - 0.5) * step; sum = sum + 4.0 / (1.0 + x * x); } #pragma omp for schedule(static) for (i = lower ; i <= upper; i+=stride) { k_3++; } #pragma omp for schedule(static,chunksize) for (i = lower; i < upper; i+=stride) { k_3++; } #pragma omp for schedule(dynamic) for (i = num_steps; i >-1 ; i++) { k_3++; } #pragma omp for schedule(dynamic, 5) ordered for (i = lower; i <= upper; i+=stride) { k_3++; } #pragma omp for schedule(guided,5) for (i = num_steps; i >= 0; i++) { k_3++; } } pi = step * sum; printf ("step:%e sum:%f PI=%.20f\n", step, sum, pi); return 0; }
the_stack_data/70449225.c
/********************************************************************************* MIT License Copyright (c) 2016 Microsoft Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *********************************************************************************/ #ifdef SORA_RF #include <soratime.h> #include <thread_func.h> #include <stdlib.h> #include <time.h> #include <rxstream.h> #include "params.h" #include "numerics.h" #include "RegisterRW.h" #include "mac.h" #include "sora_ip.h" // Read samples are queues at the driver level, but there seem to be no back-pressure towards the firmware // So if there is a large latency between two reads, the samples get lost on read, but they are fine all the way thourgh firmware // In order to allow for more queuing at read, we actually read more often and queue locally // We can schedule the read anywhere in the code, explicitly, using function readSoraAndQueue // The overflow seems to happen when latency is above 600us between consecutive reads // Uncomment below to allow this behaviour // NOTE: This does not seem to solve the problem at the moment // #define READ_IN_WORKER_THREAD // If enabled it first allows TX and RX to sync and then sends repeated 0...999 sequence through from TX to RX directly // overwriting user TX inputs, but running the real TX/RX code with the real timing // If there are no errors, output cnt_Sora_FRL_2nd_RX_data should be 0 // #define DEBUG_LOSSES // If defined disables sync and forwards the TX straight to the RX (i.e. SetTXRXSync(2)) // #define DEBUG_TXRX // If defined uses sync but after that forwards the TX straight to the RX (i.e. SetTXRXSync(2)) // #define DEBUG_TXRX_THROUGH #ifdef DEBUG_LOSSES #define DEBUG_TXRX_THROUGH #endif // Statistics about number of TX/RX syncs missed ULONG outOfSyncs = 0; // Samples of queue sizes (for debugging) // Samples of queue sizes (for debugging) ULONGLONG samp_PC_queue[MAX_CMD_FIFO_QUEUE_SIZE+1]; ULONGLONG samp_FPGA_queue[MAX_NO_TX_BUFS+1]; ULONGLONG samp_RX_queue_full, samp_RX_queue_free; // Rounds in which underflow occurs #define DEB_MAX_UNDERFLOW_QUEUE 20 int cnt_samp_FPGA_underflow = 0; ULONGLONG samp_FPGA_underflow[DEB_MAX_UNDERFLOW_QUEUE]; // Global init done variable // This is set to true once all inits are done // After that RX and TX start syncing // Otherwise, if sync happens first, a long init can break it. volatile int rx_init_done = false; volatile int tx_init_done = false; // Setting test_IP extern bool test_IP; void init_sora_hw() { // Start Sora HW // Initialize Sora user mode extension BOOLEAN succ = SoraUInitUserExtension("\\\\.\\HWTest"); if (!succ) { printf("Error: fail to find a Sora UMX capable device!\n"); exit(1); } // Override radio ids (as they are hardcoded in firmware) params_tx->radioParams.radioId = TARGET_RADIO_TX; params_rx->radioParams.radioId = TARGET_RADIO_RX; // IMPORTANT!!!! // NOTE: Make sure you start TX before RX // Otherwise, the current firmware will cause BSOD! // (this is a known bug that should be fixed one day...) if (params_tx->outType == TY_SDR) { RadioStart(params_tx); InitSoraTx(params_tx); } if (params_rx->inType == TY_SDR) { RadioStart(params_rx); InitSoraRx(params_rx); } // Firmware is one for all radios RadioSetFirmwareParameters(); // Start NDIS if not in testIP mode if (params_tx->inType == TY_IP && !test_IP) { HRESULT hResult = SoraUEnableGetTxPacket(); if (hResult != S_OK) { printf("*** NDIS binding failed!\n"); } // TODO: Hardcoded Sora MAC address - load from OS/command line memset(ethFrame, 0, 14 * sizeof(char)); ethFrame[0] = 0x02; ethFrame[1] = 0x50; ethFrame[2] = 0xF2; ethFrame[3] = 0x78; ethFrame[4] = 0xFD; ethFrame[5] = 0x6C; ethFrame[12] = 0x08; //assert(hResult == S_OK); //Ndis_init(NULL); } /* No init to be done here, just use SoraUIndicateRxPacket if (params_rx->outType == TY_IP) { // To be implemented HRESULT hResult = SoraUEnableGetRxPacket(); assert(hResult == S_OK); } */ // Init radio context blocks readSoraCtx *rctx = (readSoraCtx *)params_rx->TXBuffer; writeSoraCtx *ctx = (writeSoraCtx *)params_tx->TXBuffer; // Start Sora TX worker that is doing PCI transfer to Sora and the actual TX initTXCtx(ctx, rctx); // Start RX thread initRXCtx(rctx, ctx->TXBufferSize); } void stop_sora_hw() { // Start Sora HW if (params_rx->inType == TY_SDR || params_tx->outType == TY_SDR) { RadioStop(params_tx); } // Start NDIS if (params_tx->inType == TY_IP) { if (hUplinkThread != NULL) { // Sora cleanup. SoraUThreadStop(hUplinkThread); SoraUThreadFree(hUplinkThread); } SoraUDisableGetTxPacket(); // Winsock cleanup. closesocket(ConnectSocket); WSACleanup(); } if (params_rx->outType == TY_IP) { // To be implemented /* if (hUplinkThread != NULL) { // Sora cleanup. SoraUThreadStop(hUplinkThread); SoraUThreadFree(hUplinkThread); } SoraUDisableGetTxPacket(); // Winsock cleanup. closesocket(ConnectSocket); WSACleanup(); */ } SoraUCleanUserExtension(); } #ifdef READ_IN_WORKER_THREAD FINL void readSoraAndQueue() { HRESULT hr = S_OK; readSoraCtx *rctx = (readSoraCtx *)params_rx->TXBuffer; FLAG fReachEnd; // Signal block contains 7 vcs = 28 complex16 static SignalBlock block; complex16* pSamples = (complex16*)(&block[0]); if (rctx->RXSynced) { // Stats if (s_ts_isFull(rctx->readQueue, 0)) { samp_RX_queue_full++; } else { // Read from the radio and store in worker/RX queue // We read 28 samples @30.72 MHz, so each read takes at most ~1us (not sure if they are all blocking). // So this read should not overall block the performance of the TX part while (!s_ts_isFull(rctx->readQueue, 0)) { // This queue should not be full. For debugging, if queue full just skip the read, data will be also queued at the driver hr = FastSoraRadioReadRxStream(&(params_rx->radioParams.dev->RxStream), &fReachEnd, block); if (!FAILED(hr)) { // This can fail initially because read is in sync with the write // so some initial reads my timeout. But this will later get in sync // So instead of quitting here we monitor that the number of missed reads goes to 0. s_ts_put(rctx->readQueue, 0, (char *)pSamples); samp_RX_queue_free++; } else { break; } } } } } #endif void initTXCtx(writeSoraCtx *ctx, readSoraCtx *rctx) { ctx->prepareBlocked = 0; ctx->transferBlocked = 0; ctx->TXRunning = true; ctx->rctx = rctx; } void initRXCtx(readSoraCtx *rctx, ULONG buf_size) { rctx->rxBlocked = 0; rctx->rxSucc = 0; rctx->RXSynced = false; rctx->TXBufferSize = buf_size; rctx->syncStateCnt = buf_size - 28 - 1; rctx->RXSymbol = 0; rctx->RXFrame = 0; } // Uncomment to sample TX/RX samples to 30.72 MHz LTE frequency #ifndef DEBUG_LOSSES #define USE_SAMPLING #endif // Setting experimental parameters for the modified firmware // Does not affect the original firmware void RadioSetFirmwareParameters() { // *** RX #ifdef USE_SAMPLING SetRXDownsampleParameters(1); #else SetRXDownsampleParameters(0); #endif // *** TX SetContinuousTXParameters(cmd_fifo_queue_size); #ifdef USE_SAMPLING SetTXUpsampleParameters(1); #else SetTXUpsampleParameters(0); #endif // TXRXSync // Note: Use of TXRXSync will prevent TX unless RX is working at the same time! // 0 - no transfer from TX to RX // 1 - 1bit transfer from TX to RX // 2 - all bits transfer from TX to RX //SetTXRXSync(2); // We set to 2 first to send a special sync sequence SetTXRXSync(2); } void RadioStart(BlinkParams *params) { // always start radio first, it will reset radio to the default setting SoraURadioStart(params->radioParams.radioId); if (params->radioParams.radioId == TARGET_RADIO_RX) { SoraURadioSetRxPA(params->radioParams.radioId, params->radioParams.RXpa); SoraURadioSetRxGain(params->radioParams.radioId, params->radioParams.RXgain); } if (params->radioParams.radioId == TARGET_RADIO_TX) { printf("RADIO=%lu, GAIN=%lu\n", params->radioParams.radioId, params->radioParams.TXgain); SoraURadioSetTxGain(params->radioParams.radioId, params->radioParams.TXgain); } // DEBUG SoraURadioSetCentralFreq(params->radioParams.radioId, params->radioParams.CentralFrequency); //SoraUWriteRadioRegister(TARGET_RADIO_TX, 0x07, params->radioParams.CentralFrequency); // This is not supported with TVWS MIMO: //SoraURadioSetFreqOffset(params->radioParams.radioId, params->radioParams.FreqencyOffset); // Instead we write this (where FreqencyOffset is in 1/4096 MHz): SoraUWriteRadioRegister(params->radioParams.radioId, 0x09, params->radioParams.FreqencyOffset); /* if (params->radioParams.radioId == TARGET_RADIO_TX) { //SoraUWriteRadioRegister(TARGET_RADIO_TX, 0x07, 500); //SoraUWriteRadioRegister(TARGET_RADIO_TX, 0x09, params->radioParams.FreqencyOffset); //SoraUWriteRadioRegister(TARGET_RADIO_TX, 0x09, 600); SoraUWriteRadioRegister(TARGET_RADIO_TX, 0x09, params->radioParams.FreqencyOffset); } */ SoraURadioSetSampleRate(params->radioParams.radioId, params->radioParams.SampleRate); params->TXBuffer = NULL; params->pRxBuf = NULL; // DEBUG printf("RadioID: %ld, RXpa: %ld, RXgain: %ld, TXgain: %ld, CentralFrequency: %ld, FreqencyOffset: %ld, SampleRate: %ld\n", params->radioParams.radioId, params->radioParams.RXpa, params->radioParams.RXgain, params->radioParams.TXgain, params->radioParams.CentralFrequency, params->radioParams.FreqencyOffset, params->radioParams.SampleRate); hDeviceHandle = GetDeviceHandle(DEVNAME); if (hDeviceHandle == INVALID_HANDLE_VALUE) { printf("Can't find device %s\n", DEVNAME); exit(1); } } void RadioStop(BlinkParams *params) { writeSoraCtx *ctx = (writeSoraCtx *)params->TXBuffer; for (int i = 0; i < no_tx_bufs; i++) { if (ctx->TXBuffers[i] != NULL) { SoraUReleaseBuffer((PVOID)params->TXBuffer); } } free(ctx); if (params->pRxBuf != NULL) { HRESULT hr; SoraURadioReleaseRxStream(&params->radioParams.dev->RxStream, params->radioParams.radioId); hr = SoraURadioUnmapRxSampleBuf(params->radioParams.radioId, params->pRxBuf); } } void InitSoraRx(BlinkParams *params) { HRESULT hr; ULONG nRxBufSize = 0; readSoraCtx *rctx = (readSoraCtx *)inmem_malloc(sizeof(readSoraCtx)); params->TXBuffer = (PVOID)rctx; // Create queue between worker and RX // (only used if READ_IN_WORKER_THREAD defined) size_t size = 28*sizeof(complex16); rctx->readQueue = s_ts_init(1, &size); // Map Rx Buffer hr = SoraURadioMapRxSampleBuf( params->radioParams.radioId, &params->pRxBuf, & nRxBufSize); if ( FAILED (hr) ) { fprintf (stderr, "Error: Fail to map Sora Rx buffer!\n" ); exit(1); } // Generate a sample stream from mapped Rx buffer params->radioParams.dev = (SoraRadioParam *)inmem_malloc(sizeof(SoraRadioParam)); SoraURadioAllocRxStream(&(params->radioParams.dev->RxStream), params->radioParams.radioId, (PUCHAR)params->pRxBuf, nRxBufSize); } void InitSoraTx(BlinkParams *params) { writeSoraCtx *ctx = (writeSoraCtx *)inmem_malloc(sizeof(writeSoraCtx)); params->TXBuffer = (PVOID)ctx; ctx->prepareBuf = 0; ctx->transferBuf = 0; ctx->firstTx = 0; ctx->lastTx = 0; ctx->idleTXDetected = 0; ctx->TXBufferSize = params->radioParams.TXBufferSize; printf("TX-sora-tx-buffer-size=%ld, cmd-fifo-queue-size=%d, no-tx-bufs=%d\n", ctx->TXBufferSize, cmd_fifo_queue_size, no_tx_bufs); for (int i = 0; i < no_tx_bufs; i++) { ctx->TXBuffers[i] = SoraUAllocBuffer(ctx->TXBufferSize * sizeof(complex16)); // alloc tx sample buffers if (ctx->TXBuffers[i] == NULL) { fprintf(stderr, "Error: Fail to allocate Sora Tx buffer memory!\n"); exit(1); } // Set to 0 as it is not expensive in init and can be useful for gaps between packets memset(ctx->TXBuffers[i], 0, params->radioParams.TXBufferSize * sizeof(complex16)); } } // readSora reads <size> of complex16 inputs from Sora radio // It is a blocking function and returns only once everything is read void readSora(BlinkParams *params, complex16 *ptr, int size) { HRESULT hr; FLAG fReachEnd; // Signal block contains 7 vcs = 28 complex16 static SignalBlock block; complex16* pSamples = (complex16*)(&block[0]); static int indexSrc = 28; int oldIndexSrc; complex16* ptrDst = ptr; int remaining = size; readSoraCtx *rctx = (readSoraCtx *)params->TXBuffer; // DEBUG int32 deb_cnt = 0; int16 deb_max = 0; int16 deb_old = 0; // Wait until both TX and RX are done with init before starting sync if (!rx_init_done) { printf("RX C Init done...\n"); fflush(stdout); } rx_init_done = true; while (!tx_init_done); #ifndef DEBUG_TXRX // Wait for the special sync sequence from the TX // before starting to receive data. See TX for description. while (!rctx->RXSynced) { // Read from the radio hr = SoraRadioReadRxStream(&(params->radioParams.dev->RxStream), &fReachEnd, block); if (FAILED(hr)) { // This can happen initially because read is in sync with the write // so some initial reads my timeout. But this will later get in sync // So instead of quitting here we monitor that the number of missed reads goes to 0. //fprintf (stderr, "Error: Fail to read Sora Rx buffer!\n" ); //exit(1); rctx->rxBlocked++; continue; } int i = 0; while (i < 28 && rctx->syncStateCnt < rctx->TXBufferSize - 1) { // DEBUG /* deb_max = max(deb_max, pSamples[i].im); deb_cnt++; if (deb_cnt == 100000000) { printf("DEB: %d\n", deb_max); } if (pSamples[i].im > 0 && (pSamples[i].im - deb_old == 1 || pSamples[i].im > 10000)) printf("%d ", pSamples[i].im); deb_old = pSamples[i].im; */ if (rctx->syncStateCnt + 1 == pSamples[i].im) { rctx->syncStateCnt = pSamples[i].im; } else { static bool printErr = true; if (rctx->syncStateCnt != rctx->TXBufferSize - 28 - 1 && printErr) { printf("rctx->syncStateCnt=%ld, pSamples[%d].im=%d\n", rctx->syncStateCnt, i, pSamples[i].im); printErr = false; } } i++; } if (rctx->syncStateCnt >= rctx->TXBufferSize - 1) { rctx->RXSynced = true; rctx->RXSymbol = 28 - i; rctx->RXFrame = 0; printf("\n**************************************************************************\n"); printf("RX synchronized (syncStateCnt=%ld, i=%d, pSamples[i].im=%d, rxBlocked=%llu, rctx->rxSucc=%llu).\n", rctx->syncStateCnt, i, pSamples[i].im, rctx->rxBlocked, rctx->rxSucc); printf("**************************************************************************\n\n"); #ifndef DEBUG_TXRX_THROUGH // Switch to sending 1-bit sync info SetTXRXSync(1); #endif indexSrc = i; } } #endif if (indexSrc < 28) { oldIndexSrc = indexSrc; // Something has already been read previously, so copy that first memcpy((void *)ptrDst, (void *)(pSamples + indexSrc), min(remaining, 28 - oldIndexSrc)*sizeof(complex16)); indexSrc += min(remaining, 28 - oldIndexSrc); ptrDst += min(remaining, 28 - oldIndexSrc); remaining -= min(remaining, 28 - oldIndexSrc); } while (remaining > 0) { #ifndef READ_IN_WORKER_THREAD // Read from the radio hr = SoraRadioReadRxStream(&(params->radioParams.dev->RxStream), &fReachEnd, block); if (FAILED(hr)) { // This can happen initially because read is in sync with the write // so some initial reads my timeout. But this will later get in sync // So instead of quitting here we monitor that the number of missed reads goes to 0. //fprintf (stderr, "Error: Fail to read Sora Rx buffer!\n" ); //exit(1); rctx->rxBlocked++; continue; } #else readSoraAndQueue(); if (!s_ts_get(rctx->readQueue, 0, (char *)pSamples)) { rctx->rxBlocked++; continue; } #endif rctx->rxSucc++; indexSrc = 0; // Check sync if (rctx->RXSymbol + 28 > RXTX_SYNC_PERIOD) { // DEBUG /* if (rctx->RXFrame % 50 == 0) { printf("%d\n", pSamples[RXTX_SYNC_PERIOD - rctx->RXSymbol].im); } */ if ((pSamples[RXTX_SYNC_PERIOD - rctx->RXSymbol].re & 1) != 1 || (pSamples[RXTX_SYNC_PERIOD - rctx->RXSymbol].im & 1) != 1) { if (outOfSyncs == 0) { printf("First outOfSyncs occured after %llu (%llu, %llu) reads.\n", rctx->rxBlocked + rctx->rxSucc, rctx->rxBlocked, rctx->rxSucc); /* printf("**** Dumping extra stats:\n"); writeSoraCtx *_ctx = (writeSoraCtx *)params_tx->TXBuffer; readSoraCtx *_rctx = (readSoraCtx *)params_rx->TXBuffer; bool outOfSync = printRadioStats(_ctx, _rctx); */ fflush(stdout); } outOfSyncs++; } rctx->RXSymbol = rctx->RXSymbol + 28 - RXTX_SYNC_PERIOD; rctx->RXFrame = (rctx->RXFrame + 1) % 1024; } else { rctx->RXSymbol += 28; } // Copy memcpy((void *)ptrDst, (void *)(pSamples + indexSrc), min(remaining, 28)*sizeof(complex16)); indexSrc += min(remaining, 28); ptrDst += min(remaining, 28); remaining -= min(remaining, 28); } #ifdef DEBUG_LOSSES // In DEBUG_LOSSES mode ignore input since it is copied from TX, can cause false RX, and mess up timing memset(ptr, 0, size*sizeof(complex16)); #endif } // Transit a buffer of <size> complex16 numbers void writeSora(BlinkParams *params, complex16 *ptr, ULONG size) { HRESULT hr; static int indexSrc = 0; int indexPtr = 0; writeSoraCtx *ctx = (writeSoraCtx *)params->TXBuffer; complex16 *remainBuf = ptr; ULONG remainCnt = size; int nextPrepareBuf; static complex16 *syncBuf1 = NULL, *syncBuf2 = NULL; static bool sendSendSyncPreamb = true; static LONG TXCnt = 0; #ifdef DEBUG_LOSSES static complex16 incArr[2000]; static int incAddInd = 0; #endif #ifndef DEBUG_TXRX // Init sync buffer if (syncBuf1 == NULL) { syncBuf1 = (complex16*)inmem_malloc(ctx->TXBufferSize * sizeof(complex16)); syncBuf2 = (complex16*)inmem_malloc(ctx->TXBufferSize * sizeof(complex16)); if (syncBuf1 == NULL || syncBuf2 == NULL) { printf("Cannot malloc syncBufs!\n"); exit(1); } for (int i = 0; i < ctx->TXBufferSize; i++) { syncBuf1[i].re = i; syncBuf1[i].im = i; syncBuf2[i].re = 0; syncBuf2[i].im = 0; } } #endif // Wait until both TX and RX are done with init before starting sync if (!tx_init_done) { printf("TX C Init done...\n"); fflush(stdout); #ifdef DEBUG_LOSSES // Create test sequence for (int i = 0; i < 2000; i++) { incArr[i].re = (i % 1000); incArr[i].im = (i % 1000); } #endif } tx_init_done = true; while (!rx_init_done); #ifdef DEBUG_LOSSES // Send test sequence instead of the real one ptr = incArr + incAddInd; incAddInd = (incAddInd + size) % 1000; #endif #ifndef DEBUG_TXRX // 2s delay before syncing const int syncPreambLen = ((2*30720000) / (int) ctx->TXBufferSize); // Send special sequence // Sequence starts with bunch of 0s to wait until the firmware's queues stabilize // and then sends a ramp that is detected by the RX. Data transmission continues // immediately after the ramp so after it we are in sync with RX. if (sendSendSyncPreamb) { nextPrepareBuf = (ctx->prepareBuf + 1) % no_tx_bufs; for (int syncBufCnt = 0; syncBufCnt <= syncPreambLen; syncBufCnt++) { complex16 *currentBuf = (complex16*)ctx->TXBuffers[ctx->prepareBuf]; if (syncBufCnt == syncPreambLen) { memcpy((void *)currentBuf, (void *)syncBuf1, ctx->TXBufferSize * sizeof(complex16)); } else { memcpy((void *)currentBuf, (void *)syncBuf2, ctx->TXBufferSize * sizeof(complex16)); } // Spin wait until there is a space in the buffer queue while (nextPrepareBuf == ctx->transferBuf) { ctx->prepareBlocked++; } // Full buffer ready to be sent // We don't really send here. // We just advance the pointer and release the record // to be transferred and sent by other threads ctx->prepareBuf = nextPrepareBuf; nextPrepareBuf = (ctx->prepareBuf + 1) % no_tx_bufs; indexSrc = 0; } sendSendSyncPreamb = false; } #ifndef DEBUG_LOSSES // Set the bit on LSB RXTX Sync channel // For speed we set the bit only once every RXTX_SYNC_PERIOD (10ms - 1 frame) // and we don't reset the bit otherwise. We count on this bit being random so // we'll detect out of sync in on average 20ms if (TXCnt == 0) { ptr[0].re |= 1; ptr[0].im |= 1; } else if (TXCnt + size > RXTX_SYNC_PERIOD) { ptr[RXTX_SYNC_PERIOD - TXCnt - 1].re |= 1; ptr[RXTX_SYNC_PERIOD - TXCnt - 1].im |= 1; } TXCnt = (TXCnt + size) % RXTX_SYNC_PERIOD; #endif #endif nextPrepareBuf = (ctx->prepareBuf + 1) % no_tx_bufs; while (remainCnt > 0) { ULONG inc = min(ctx->TXBufferSize - indexSrc, remainCnt); complex16 *currentBuf = (complex16*)ctx->TXBuffers[ctx->prepareBuf]; memcpy((void *)(currentBuf + indexSrc), (void *)(ptr + indexPtr), inc * sizeof(complex16)); indexPtr += inc; indexSrc += inc; remainCnt -= inc; if (indexSrc >= ctx->TXBufferSize) { bool block = false; // Spin wait until there is a space in the buffer queue while (nextPrepareBuf == ctx->transferBuf) { block = true; } if (block) ctx->prepareBlocked++; // Full buffer ready to be sent // We don't really send here. // We just advance the pointer and release the record // to be transferred and sent by other threads ctx->prepareBuf = nextPrepareBuf; nextPrepareBuf = (ctx->prepareBuf + 1) % no_tx_bufs; indexSrc = 0; } } } // Returns a - b, assuming that a > b and ignoring wrapping ULONG diff_wrap(ULONG a, ULONG b) { if (b > a) { return (ULONG_MAX - b) + a + 1; } else { return (a - b); } } // Returns a - b, assuming that a > b and ignoring wrapping ULONG diff_wrap_max(ULONG a, ULONG b, ULONG max) { if (b > a) { return (max - b) + a; } else { return (a - b); } } // Buffers are ready, transfer them DWORD WINAPI SoraTXWorker(void * pParam) { HRESULT hr = S_OK; bool transferred = false; bool idle_detected = FALSE; writeSoraCtx *ctx = (writeSoraCtx *)pParam; ULONG firstTx32, lastTx32; ULONG cnt_tx = 0, cnt_rx = 0; ULONG samp_PC_queue_ptr = 0; ULONG samp_FPGA_queue_ptr = 0; ULONG samp_queue_subsample = 0; memset(samp_PC_queue, 0, sizeof(ULONGLONG)*MAX_NO_TX_BUFS); memset(samp_FPGA_queue, 0, sizeof(ULONGLONG)*MAX_CMD_FIFO_QUEUE_SIZE); samp_RX_queue_full = 0; samp_RX_queue_free = 0; bool blockPC = false; bool blockFPGA = false; ctx->idleTXDetected = 0; ULONGLONG cnt_rnd = 0; cnt_samp_FPGA_underflow = 0; memset(samp_FPGA_underflow, 0, sizeof(ULONGLONG)* DEB_MAX_UNDERFLOW_QUEUE); while (!rx_init_done || !tx_init_done); // Synchronize initial queue positions hr = ReadRegister(0x0550, &lastTx32); hr = ReadRegister(0x0554, &firstTx32); ctx->lastTx = lastTx32; ctx->firstTx = firstTx32; // TODO: here we might want to cache-align all the data to avoid cache misses while (true) { bool bPC = ctx->transferBuf != ctx->prepareBuf; bool bFPGA = diff_wrap(ctx->lastTx, ctx->firstTx) < cmd_fifo_queue_size; blockPC = blockPC || (!bPC); blockFPGA = blockFPGA || (!bFPGA); if (bPC && bFPGA) { int queuePos = ctx->lastTx % cmd_fifo_queue_size; hr = SoraURadioTransferEx(TARGET_RADIO_TX, ctx->TXBuffers[ctx->transferBuf], ctx->TXBufferSize * sizeof(complex16), &(ctx->BufID[queuePos])); hr = SoraURadioTx(TARGET_RADIO_TX, ctx->BufID[queuePos]); ctx->lastTx++; if (!SUCCEEDED(hr)) { printf("SoraURadioTransferEx %d failed!\n", ctx->transferBuf); return FALSE; } ctx->transferBuf = (ctx->transferBuf + 1) % no_tx_bufs; // Store queue size samples for debugging ULONG d1 = diff_wrap_max((ULONG)ctx->prepareBuf, (ULONG)ctx->transferBuf, no_tx_bufs); d1 = min(d1, MAX_NO_TX_BUFS); ULONG d2 = diff_wrap_max(ctx->lastTx, ctx->firstTx, cmd_fifo_queue_size); d2 = min(d2, MAX_CMD_FIFO_QUEUE_SIZE); samp_PC_queue[d1] ++; samp_FPGA_queue[d2] ++; if (d2 < 6) { samp_FPGA_underflow[cnt_samp_FPGA_underflow] = cnt_rnd + 1; cnt_samp_FPGA_underflow = min(cnt_samp_FPGA_underflow + 1, DEB_MAX_UNDERFLOW_QUEUE); } if (blockPC) ctx->transferBlocked++; if (blockFPGA) ctx->transferBlockedFPGA++; blockPC = false; blockFPGA = false; } hr = ReadRegister(0x0550, &lastTx32); hr = ReadRegister(0x0554, &firstTx32); // Don't free the one just dequeued as the transmission could still be ongoing // Only free once the subsequent has been dequeued // Althoug 1 here makes sense, empirically seems that 2 is the minimum while (diff_wrap(firstTx32, ctx->firstTx) > 2) { hr = SoraURadioTxFree(TARGET_RADIO_TX, ctx->BufID[ctx->firstTx % cmd_fifo_queue_size]); ctx->firstTx++; } /* // Indeed, it never happened so removed to speed up the code if (lastTx32 != ctx->lastTx) { printf("This should not happen!\n"); } */ // For some reason we cannot read Sora from this thread, as timing collapses. Didn't spend much time investigating this issue. /* #ifdef READ_IN_WORKER_THREAD readSoraAndQueue(); #endif */ cnt_rnd++; } ctx->TXRunning = false; return 0; } void prtStat(int32 num) { if (num > 0) { printf(" %3ld ", num); } else { printf(" "); } } // Print debug info // Returns true if out of sync bool printRadioStats(writeSoraCtx *ctx, readSoraCtx *rctx) { HRESULT hres; static ULONG debug_ups_count=0, last_debug_ups_count=0; static ULONG d_cnt_Radio_TX_FIFO_rden=0, last_d_cnt_Radio_TX_FIFO_rden = 0; static ULONG d_cnt_Radio_TX_FIFO_pempty=0, last_d_cnt_Radio_TX_FIFO_pempty = 0; static ULONG d_cnt_Sora_FRL_2nd_RX_data=0, last_d_cnt_Sora_FRL_2nd_RX_data = 0; static ULONG d_cnt_RX_FIFO_2nd_data_out=0, last_d_cnt_RX_FIFO_2nd_data_out=0; static ULONG cnt_upsample_out=0, cnt_ups_ddr2_rden=0, cnt_Radio_TX_FIFO_full=0, cnt_TX_DDR_fifo_full=0; static ULONG last_cnt_upsample_out = 0, last_cnt_ups_ddr2_rden = 0, last_cnt_Radio_TX_FIFO_full = 0, last_cnt_TX_DDR_fifo_full = 0; static ULONG Total_idle_cnt = 0, last_Total_idle_cnt = 0; static ULONG last_idle_duration=0, last_pc_idle_duration=0, last_pc_idle_w_inactive=0; static ULONG cmd_fifo_cnt=0, dbg_sync_cnt=0, deb_FRL_data_count=0, deb_FRL_TS_count=0; static ULONG cnt_cmd_fifo_empty=0, last_cnt_cmd_fifo_empty=0; static ULONG dbg_sync_underflow = 0, last_dbg_sync_underflow = 0; static ULONG dbg_sync_overflow = 0, last_dbg_sync_overflow = 0; ULONG TXOutAddr, TXOutSize, deb_reg; ULONG RXOverflow1, RXOverflow2; bool isOutOfSync; bool warning = false; static int toggle = 0; hres = ReadRegister(0x0510, &Total_idle_cnt); hres = ReadRegister(0x0514, &last_idle_duration); hres = ReadRegister(0x0518, &last_pc_idle_duration); hres = ReadRegister(0x051c, &last_pc_idle_w_inactive); // *** ControlQueue hres = ReadRegister(0x0520, &cmd_fifo_cnt); // *** RX_data_fifo_SORA_FRL_2nd_inst/RX_TS_fifo_2nd_inst // Data and TS count in RX_data_fifo_SORA_FRL_2nd_inst/RX_TS_fifo_2nd_inst hres = ReadRegister(0x0530, &deb_FRL_data_count); hres = ReadRegister(0x0534, &deb_FRL_TS_count); hres = ReadRegister(0x0528, &d_cnt_Sora_FRL_2nd_RX_data); // Test difference in input sequence (special debugging) hres = ReadRegister(0x052c, &d_cnt_RX_FIFO_2nd_data_out); // Test difference in input sequence (special debugging) hres = ReadRegister(0x0080, &RXOverflow1); // Counts [RX_FIFO_full, RX_TS_FIFO_full] hres = ReadRegister(0x0084, &RXOverflow2); // Counts [RX_FIFO_2nd_full, RX_TS_FIFO_2nd_full] // *** rxtx_queue_inst // Counts overflows/underflows for rxtx_queue_inst hres = ReadRegister(0x0538, &dbg_sync_underflow); hres = ReadRegister(0x053c, &dbg_sync_overflow); hres = ReadRegister(0x0524, &dbg_sync_cnt); // Data count // *** Upsampler hres = ReadRegister(0x0540, &cnt_upsample_out); hres = ReadRegister(0x0544, &cnt_ups_ddr2_rden); hres = ReadRegister(0x0558, &debug_ups_count); // *** dma_ddr2 // ToFRL_data_fifo_inst full counter hres = ReadRegister(0x0548, &cnt_Radio_TX_FIFO_full); hres = ReadRegister(0x054c, &cnt_TX_DDR_fifo_full); // *** Sora_FRL_RCB_inst hres = ReadRegister(0x055c, &d_cnt_Radio_TX_FIFO_rden); // counts Radio_TX_FIFO_rden (from Sora_FRL_RCB_inst) hres = ReadRegister(0x0560, &d_cnt_Radio_TX_FIFO_pempty); // counts Radio_TX_FIFO_rden (from dma_ddr2_if) // *** register_table hres = ReadRegister(0x0564, &cnt_cmd_fifo_empty); // Queue sync counter hres = ReadRegister(0x0568, &TXOutAddr); hres = ReadRegister(0x056c, &TXOutSize); hres = ReadRegister(0x0570, &deb_reg); // These should all be zeros in normal conditions if (Total_idle_cnt - last_Total_idle_cnt > 0 || rctx->rxBlocked) { warning = true; } if ((LONG)dbg_sync_underflow - (LONG)last_dbg_sync_underflow > 0) { warning = true; } if ((LONG)cnt_ups_ddr2_rden - (LONG)last_cnt_ups_ddr2_rden == 0) { warning = true; } if (outOfSyncs != 0) { isOutOfSync = true; warning = true; } else { isOutOfSync = false; } printf("\n"); if (debugPrint(DEBUG_PRINT_RADIO)) { /* printf("Total_idle_cnt: %u, last_idle_duration: %u, last_pc_idle_duration: %u, last_pc_idle_w_inactive: %u\n", Total_idle_cnt - last_Total_idle_cnt, last_idle_duration, last_pc_idle_duration, last_pc_idle_w_inactive); printf(" queues: %u, %u, %u, %u\n", cmd_fifo_cnt, dbg_sync_cnt, deb_FRL_data_count, deb_FRL_TS_count); printf(" prepareBlocked: %llu, transferBlocked: %llu, txBlocked: %llu, rxBlocked: %llu\n", ctx->prepareBlocked, ctx->transferBlocked, ctx->txBlocked, rctx->rxBlocked); printf("debugGlobalCnt = %ld, debugGlobalCnt2=%ld\n", debugGlobalCnt, debugGlobalCnt2); printf("cnt_upsample_out = %ld, cnt_ups_ddr2_rden = %ld, cnt_Radio_TX_FIFO_full = %ld, cnt_TX_DDR_fifo_full = %ld\n", cnt_upsample_out - last_cnt_upsample_out, cnt_ups_ddr2_rden - last_cnt_ups_ddr2_rden, cnt_Radio_TX_FIFO_full - last_cnt_Radio_TX_FIFO_full, cnt_TX_DDR_fifo_full - last_cnt_TX_DDR_fifo_full); printf("%ld %ld\n", (LONG)d_cnt_Sora_FRL_2nd_RX_data - (LONG)last_d_cnt_Sora_FRL_2nd_RX_data, (LONG)d_cnt_RX_FIFO_2nd_data_out - (LONG)last_d_cnt_RX_FIFO_2nd_data_out); */ // These should all be zeros in normal conditions if (Total_idle_cnt - last_Total_idle_cnt > 0 || rctx->rxBlocked) { printf(" ******** "); } printf("Total_idle_cnt: %u, prepareBlockedPC: %llu, transferBlockedPC: %llu, transferBlockedFPGA: %llu, rxBlocked: %llu/%llu\n", Total_idle_cnt - last_Total_idle_cnt, ctx->prepareBlocked, ctx->transferBlocked, ctx->transferBlockedFPGA, rctx->rxBlocked, rctx->rxBlocked + rctx->rxSucc); printf(" prepareBuf: %d, transferBuf: %d\n", ctx->prepareBuf, ctx->transferBuf); printf(" queues: %u, %u, %u, %u, %u\n", cmd_fifo_cnt, dbg_sync_cnt, deb_FRL_data_count, deb_FRL_TS_count, debug_ups_count); // These (debugGlobalCnt and debugGlobalCnt2) should be zeros when sending a sawf unction (0-999, 0-999, ...) printf(" cnt_Sora_FRL_2nd_RX_data=%ld, cnt_RX_FIFO_2nd_data_out=%ld\n", (LONG)d_cnt_Sora_FRL_2nd_RX_data - (LONG)last_d_cnt_Sora_FRL_2nd_RX_data, (LONG)d_cnt_RX_FIFO_2nd_data_out - (LONG)last_d_cnt_RX_FIFO_2nd_data_out); // These should all be zeros in normal conditions if ((LONG)dbg_sync_underflow - (LONG)last_dbg_sync_underflow > 0) { printf(" ******** "); warning = true; } printf(" cnt_cmd_fifo_empty = %ld, dbg_sync_underflow = %ld, dbg_sync_overflow = %ld\n", (LONG)cnt_cmd_fifo_empty - (LONG)last_cnt_cmd_fifo_empty, (LONG)dbg_sync_underflow - (LONG)last_dbg_sync_underflow, (LONG)dbg_sync_overflow - (LONG)last_dbg_sync_overflow); printf(" deb_reg = %lu\n", deb_reg); /* // DEBUG printf(" cnt_cmd_fifo_empty = %ld, TXOutAddr = %lu, TXOutSize = %lu\n", (LONG)cnt_cmd_fifo_empty - (LONG)last_cnt_cmd_fifo_empty, TXOutAddr, TXOutSize); printf("allocBuf(%d): ", naB); for (int ii = 0; ii < naB; ii++) printf("%lu ", allocBuf[ii]); printf("\nusedBuf(%d): ", nuB); for (int ii = 0; ii < nuB; ii++) printf("%lu (%lu) ", usedBuf[ii], usedBufSiz[ii]); printf("\n"); printf("\nDallocBuf(%d): ", da); for (int ii = 0; ii < da; ii++) printf("%lu ", DallocBuf[ii]); printf("\nDusedBuf(%d): ", du); for (int ii = 0; ii < du; ii++) printf("%lu ", DusedBuf[ii]); printf("\nDusedInd(%d): ", du); for (int ii = 0; ii < du; ii++) printf("%lu ", DusedInd[ii]); */ // These should all be zeros in normal conditions if ((LONG)cnt_ups_ddr2_rden - (LONG)last_cnt_ups_ddr2_rden == 0) { printf(" ******** "); warning = true; } printf(" cnt_ups_ddr2_rden = %ld, cnt_upsample_out = %ld, cnt_Radio_TX_FIFO_full = %ld, cnt_TX_DDR_fifo_full = %ld\n", (LONG)cnt_ups_ddr2_rden - (LONG)last_cnt_ups_ddr2_rden, (LONG)cnt_upsample_out - (LONG)last_cnt_upsample_out, (LONG)cnt_Radio_TX_FIFO_full - (LONG)last_cnt_Radio_TX_FIFO_full, (LONG)cnt_TX_DDR_fifo_full - (LONG)last_cnt_TX_DDR_fifo_full); printf(" cnt_Radio_TX_FIFO_rden = %ld, cnt_Radio_TX_FIFO_pempty = %ld\n", (LONG)d_cnt_Radio_TX_FIFO_rden - (LONG)last_d_cnt_Radio_TX_FIFO_rden, (LONG)d_cnt_Radio_TX_FIFO_pempty - (LONG)last_d_cnt_Radio_TX_FIFO_pempty); // These should all be zeros in normal conditions if (outOfSyncs != 0) { isOutOfSync = true; warning = true; printf(" ******** "); } else { isOutOfSync = false; } printf(" outOfSyncs = %lu\n", outOfSyncs); // DEBUG printf("RX DEBUG: %u %u\n", RXOverflow1, RXOverflow2); // Print queue size samples for debugging printf("samp_PC_queue: "); for (int i = 0; i < no_tx_bufs + 1; i++) { printf("%d ", samp_PC_queue[i]); samp_PC_queue[i] = 0; } printf("\nsamp_FPGA_queue: "); for (int i = 0; i < cmd_fifo_queue_size + 1; i++) { printf("%d ", samp_FPGA_queue[i]); samp_FPGA_queue[i] = 0; } printf("\nsamp_FPGA_queue_underflow: "); for (int i = 0; i < cnt_samp_FPGA_underflow; i++) { printf("%llu ", samp_FPGA_underflow[i]); } cnt_samp_FPGA_underflow = 0; #ifdef READ_IN_WORKER_THREAD printf("\nsamp_RX_queue: free=%llu, full=%llu\n", samp_RX_queue_free, samp_RX_queue_full); samp_RX_queue_full = 0; samp_RX_queue_free = 0; #endif printf("\n"); } /* if (isOutOfSync) printf("!!! OUT OF SYNC !!!\n"); if (warning) printf("*** "); printf("%c rxSCH=%ld, rxIP=%ld, rxCCH=%ld, rxRACH=%ld, txSCH=%ld, txIP=%ld, txCCH=%ld, errIP=%ld, errFrag=%ld, errRLC=%ld, errRRC=%ld\n", (toggle == 0) ? '.' : '*', rxSCH, rxIP, rxCCH, rxRACH, txSCH, txIP, txCCH, errIP, errFrag, errRLC, errRRC); */ if (isOutOfSync) printf("!!! OUT OF SYNC !!!\n"); if (warning) printf("*** "); printf("%c rxSCH, rxIP, rxCCH, rxRACH, txSCH, txIP, txCCH, errIP, errFrg, errRLC, errRRC, errQue, rrcRCN, rrcATT\n", (toggle == 0) ? '.' : '*'); prtStat(rxSCH); prtStat(rxIP); prtStat(rxCCH); prtStat(rxRACH); prtStat(txSCH); prtStat(txIP); prtStat(txCCH); prtStat(errIP); prtStat(errFrag); prtStat(errRLC); prtStat(errRRC); prtStat(errQue); prtStat(RRCRecComp); prtStat(RRCAttComp); printf("\n"); printf("MCS stats: "); for (int i = 0; i < MAC_NO_MCS; i++) { if (txMCS[i] > 0) printf("%2d(%3ld) ", i, txMCS[i]); } printf("\n"); printf("NBR stats: "); for (int i = 0; i < MAC_NO_NBR; i++) { if (txNBR[i] > 0) printf("%2d(%3ld) ", i, txNBR[i]); } printf("\n"); last_Total_idle_cnt = Total_idle_cnt; last_cnt_upsample_out = cnt_upsample_out; last_cnt_ups_ddr2_rden = cnt_ups_ddr2_rden; last_cnt_Radio_TX_FIFO_full = cnt_Radio_TX_FIFO_full; last_cnt_TX_DDR_fifo_full = cnt_TX_DDR_fifo_full; last_d_cnt_Sora_FRL_2nd_RX_data = d_cnt_Sora_FRL_2nd_RX_data; last_d_cnt_RX_FIFO_2nd_data_out = d_cnt_RX_FIFO_2nd_data_out; last_debug_ups_count = debug_ups_count; last_d_cnt_Radio_TX_FIFO_rden = d_cnt_Radio_TX_FIFO_rden; last_d_cnt_Radio_TX_FIFO_pempty = d_cnt_Radio_TX_FIFO_pempty; last_cnt_cmd_fifo_empty = cnt_cmd_fifo_empty; last_dbg_sync_underflow = dbg_sync_underflow; last_dbg_sync_overflow = dbg_sync_overflow; outOfSyncs = 0; ctx->prepareBlocked = 0; ctx->transferBlocked = 0; ctx->transferBlockedFPGA = 0; rctx->rxBlocked = 0; rxSCH = 0; rxCCH = 0; rxRACH = 0; rxIP = 0; txSCH = 0; txIP = 0; txCCH = 0; errIP = 0, errFrag = 0, errRLC = 0, errRRC = 0, errQue = 0; RRCRecComp = 0, RRCAttComp = 0; memset(txMCS, 0, sizeof(int32)*MAC_NO_MCS); memset(txNBR, 0, sizeof(int32)*MAC_NO_NBR); toggle = toggle ^ 1; fflush(stdout); return (isOutOfSync); } int Sora_SwitchTXFrequency(BlinkParams *params, bool center) { int status = 0; if (true == center) { SoraURadioSetCentralFreq(params->radioParams.radioId, params->radioParams.CentralFrequency); } else { SoraURadioSetCentralFreq(params->radioParams.radioId, params->radioParams.CentralFrequency + 40); } return status; } #endif
the_stack_data/42482.c
#include <stdio.h> int main() { FILE* fp; char buffer[255]; fp = fopen("./answers/C/@mykeels/data/07-read-line-by-line.txt", "r"); while(fgets(buffer, 255, (FILE*) fp)) { printf("%s", buffer); } fclose(fp); }
the_stack_data/4741.c
/* * Copyright (c) 2017, 2018, Oracle and/or its affiliates. * * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, this list of * conditions and the following disclaimer in the documentation and/or other materials provided * with the distribution. * * 3. Neither the name of the copyright holder nor the names of its contributors may be used to * endorse or promote products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. */ int counter = 0; int main(); int test() { return main(); } int main() { counter++; if (counter == 1) { return 5; } return test(); }
the_stack_data/72013615.c
// code: 0 struct s { int a[24]; } my_s; int main() { return *my_s.a; }
the_stack_data/6387999.c
/* { dg-do compile } */ /* { dg-options "-Wmissing-parameter-type" } */ int foo(bar) { return bar; } /* { dg-warning "type of 'bar' defaults to 'int'" } */
the_stack_data/68889154.c
/*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)getsubopt.c 8.1 (Berkeley) 6/4/93 * $FreeBSD: src/lib/libc/stdlib/getsubopt.c,v 1.7 2007/01/09 00:28:10 imp Exp $ * $DragonFly: src/lib/libc/stdlib/getsubopt.c,v 1.4 2005/11/20 12:37:48 swildner Exp $ */ #include <stdlib.h> #include <string.h> /* * The SVID interface to getsubopt provides no way of figuring out which * part of the suboptions list wasn't matched. This makes error messages * tricky... The extern variable suboptarg is a pointer to the token * which didn't match. */ char *suboptarg; int getsubopt(char **optionp, char * const *tokens, char **valuep) { int cnt; char *p; suboptarg = *valuep = NULL; if (!optionp || !*optionp) return(-1); /* skip leading white-space, commas */ for (p = *optionp; *p && (*p == ',' || *p == ' ' || *p == '\t'); ++p); if (!*p) { *optionp = p; return(-1); } /* save the start of the token, and skip the rest of the token. */ for (suboptarg = p; *++p && *p != ',' && *p != '=' && *p != ' ' && *p != '\t';); if (*p) { /* * If there's an equals sign, set the value pointer, and * skip over the value part of the token. Terminate the * token. */ if (*p == '=') { *p = '\0'; for (*valuep = ++p; *p && *p != ',' && *p != ' ' && *p != '\t'; ++p); if (*p) *p++ = '\0'; } else *p++ = '\0'; /* Skip any whitespace or commas after this token. */ for (; *p && (*p == ',' || *p == ' ' || *p == '\t'); ++p); } /* set optionp for next round. */ *optionp = p; for (cnt = 0; *tokens; ++tokens, ++cnt) if (!strcmp(suboptarg, *tokens)) return(cnt); return(-1); }
the_stack_data/94450.c
#include <stdio.h> int main() { int distancia; scanf("%d", &distancia); printf("%d minutos\n", (distancia * 2)); return 0; }
the_stack_data/415530.c
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <CL/cl.h> unsigned char *read_buffer(char *file_name, size_t *size_ptr) { FILE *f; unsigned char *buf; size_t size; /* Open file */ f = fopen(file_name, "rb"); if (!f) return NULL; /* Obtain file size */ fseek(f, 0, SEEK_END); size = ftell(f); fseek(f, 0, SEEK_SET); /* Allocate and read buffer */ buf = malloc(size + 1); fread(buf, 1, size, f); buf[size] = '\0'; /* Return size of buffer */ if (size_ptr) *size_ptr = size; /* Return buffer */ return buf; } void write_buffer(char *file_name, const char *buffer, size_t buffer_size) { FILE *f; /* Open file */ f = fopen(file_name, "w+"); /* Write buffer */ if(buffer) fwrite(buffer, 1, buffer_size, f); /* Close file */ fclose(f); } int main(int argc, char const *argv[]) { /* Get platform */ cl_platform_id platform; cl_uint num_platforms; cl_int ret = clGetPlatformIDs(1, &platform, &num_platforms); if (ret != CL_SUCCESS) { printf("error: call to 'clGetPlatformIDs' failed\n"); exit(1); } printf("Number of platforms: %d\n", num_platforms); printf("platform=%p\n", platform); /* Get platform name */ char platform_name[100]; ret = clGetPlatformInfo(platform, CL_PLATFORM_NAME, sizeof(platform_name), platform_name, NULL); if (ret != CL_SUCCESS) { printf("error: call to 'clGetPlatformInfo' failed\n"); exit(1); } printf("platform.name='%s'\n\n", platform_name); /* Get device */ cl_device_id device; cl_uint num_devices; ret = clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 1, &device, &num_devices); if (ret != CL_SUCCESS) { printf("error: call to 'clGetDeviceIDs' failed\n"); exit(1); } printf("Number of devices: %d\n", num_devices); printf("device=%p\n", device); /* Get device name */ char device_name[100]; ret = clGetDeviceInfo(device, CL_DEVICE_NAME, sizeof(device_name), device_name, NULL); if (ret != CL_SUCCESS) { printf("error: call to 'clGetDeviceInfo' failed\n"); exit(1); } printf("device.name='%s'\n", device_name); printf("\n"); /* Create a Context Object */ cl_context context; context = clCreateContext(NULL, 1, &device, NULL, NULL, &ret); if (ret != CL_SUCCESS) { printf("error: call to 'clCreateContext' failed\n"); exit(1); } printf("context=%p\n", context); /* Create a Command Queue Object*/ cl_command_queue command_queue; command_queue = clCreateCommandQueue(context, device, 0, &ret); if (ret != CL_SUCCESS) { printf("error: call to 'clCreateCommandQueue' failed\n"); exit(1); } printf("command_queue=%p\n", command_queue); printf("\n"); /* Program source */ unsigned char *source_code; size_t source_length; /* Read program from 'divide_ushort2ushort2.cl' */ source_code = read_buffer("divide_ushort2ushort2.cl", &source_length); /* Create a program */ cl_program program; program = clCreateProgramWithSource(context, 1, (const char **)&source_code, &source_length, &ret); if (ret != CL_SUCCESS) { printf("error: call to 'clCreateProgramWithSource' failed\n"); exit(1); } printf("program=%p\n", program); /* Build program */ ret = clBuildProgram(program, 1, &device, NULL, NULL, NULL); if (ret != CL_SUCCESS ) { size_t size; char *log; /* Get log size */ clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG,0, NULL, &size); /* Allocate log and print */ log = malloc(size); clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG,size, log, NULL); printf("error: call to 'clBuildProgram' failed:\n%s\n", log); /* Free log and exit */ free(log); exit(1); } printf("program built\n"); printf("\n"); /* Create a Kernel Object */ cl_kernel kernel; kernel = clCreateKernel(program, "divide_ushort2ushort2", &ret); if (ret != CL_SUCCESS) { printf("error: call to 'clCreateKernel' failed\n"); exit(1); } /* Create and allocate host buffers */ size_t num_elem = 10; /* Create and init host side src buffer 0 */ cl_ushort2 *src_0_host_buffer; src_0_host_buffer = malloc(num_elem * sizeof(cl_ushort2)); for (int i = 0; i < num_elem; i++) src_0_host_buffer[i] = (cl_ushort2){{2, 2}}; /* Create and init device side src buffer 0 */ cl_mem src_0_device_buffer; src_0_device_buffer = clCreateBuffer(context, CL_MEM_READ_ONLY, num_elem * sizeof(cl_ushort2), NULL, &ret); if (ret != CL_SUCCESS) { printf("error: could not create source buffer\n"); exit(1); } ret = clEnqueueWriteBuffer(command_queue, src_0_device_buffer, CL_TRUE, 0, num_elem * sizeof(cl_ushort2), src_0_host_buffer, 0, NULL, NULL); if (ret != CL_SUCCESS) { printf("error: call to 'clEnqueueWriteBuffer' failed\n"); exit(1); } /* Create and init host side src buffer 1 */ cl_ushort2 *src_1_host_buffer; src_1_host_buffer = malloc(num_elem * sizeof(cl_ushort2)); for (int i = 0; i < num_elem; i++) src_1_host_buffer[i] = (cl_ushort2){{2, 2}}; /* Create and init device side src buffer 1 */ cl_mem src_1_device_buffer; src_1_device_buffer = clCreateBuffer(context, CL_MEM_READ_ONLY, num_elem * sizeof(cl_ushort2), NULL, &ret); if (ret != CL_SUCCESS) { printf("error: could not create source buffer\n"); exit(1); } ret = clEnqueueWriteBuffer(command_queue, src_1_device_buffer, CL_TRUE, 0, num_elem * sizeof(cl_ushort2), src_1_host_buffer, 0, NULL, NULL); if (ret != CL_SUCCESS) { printf("error: call to 'clEnqueueWriteBuffer' failed\n"); exit(1); } /* Create host dst buffer */ cl_float2 *dst_host_buffer; dst_host_buffer = malloc(num_elem * sizeof(cl_float2)); memset((void *)dst_host_buffer, 1, num_elem * sizeof(cl_float2)); /* Create device dst buffer */ cl_mem dst_device_buffer; dst_device_buffer = clCreateBuffer(context, CL_MEM_WRITE_ONLY, num_elem *sizeof(cl_float2), NULL, &ret); if (ret != CL_SUCCESS) { printf("error: could not create dst buffer\n"); exit(1); } /* Set kernel arguments */ ret = CL_SUCCESS; ret |= clSetKernelArg(kernel, 0, sizeof(cl_mem), &src_0_device_buffer); ret |= clSetKernelArg(kernel, 1, sizeof(cl_mem), &src_1_device_buffer); ret |= clSetKernelArg(kernel, 2, sizeof(cl_mem), &dst_device_buffer); if (ret != CL_SUCCESS) { printf("error: call to 'clSetKernelArg' failed\n"); exit(1); } /* Launch the kernel */ size_t global_work_size = num_elem; size_t local_work_size = num_elem; ret = clEnqueueNDRangeKernel(command_queue, kernel, 1, NULL, &global_work_size, &local_work_size, 0, NULL, NULL); if (ret != CL_SUCCESS) { printf("error: call to 'clEnqueueNDRangeKernel' failed\n"); exit(1); } /* Wait for it to finish */ clFinish(command_queue); /* Read results from GPU */ ret = clEnqueueReadBuffer(command_queue, dst_device_buffer, CL_TRUE,0, num_elem * sizeof(cl_float2), dst_host_buffer, 0, NULL, NULL); if (ret != CL_SUCCESS) { printf("error: call to 'clEnqueueReadBuffer' failed\n"); exit(1); } /* Dump dst buffer to file */ char dump_file[100]; sprintf((char *)&dump_file, "%s.result", argv[0]); write_buffer(dump_file, (const char *)dst_host_buffer, num_elem * sizeof(cl_float2)); printf("Result dumped to %s\n", dump_file); /* Free host dst buffer */ free(dst_host_buffer); /* Free device dst buffer */ ret = clReleaseMemObject(dst_device_buffer); if (ret != CL_SUCCESS) { printf("error: call to 'clReleaseMemObject' failed\n"); exit(1); } /* Free host side src buffer 0 */ free(src_0_host_buffer); /* Free device side src buffer 0 */ ret = clReleaseMemObject(src_0_device_buffer); if (ret != CL_SUCCESS) { printf("error: call to 'clReleaseMemObject' failed\n"); exit(1); } /* Free host side src buffer 1 */ free(src_1_host_buffer); /* Free device side src buffer 1 */ ret = clReleaseMemObject(src_1_device_buffer); if (ret != CL_SUCCESS) { printf("error: call to 'clReleaseMemObject' failed\n"); exit(1); } /* Release kernel */ ret = clReleaseKernel(kernel); if (ret != CL_SUCCESS) { printf("error: call to 'clReleaseKernel' failed\n"); exit(1); } /* Release program */ ret = clReleaseProgram(program); if (ret != CL_SUCCESS) { printf("error: call to 'clReleaseProgram' failed\n"); exit(1); } /* Release command queue */ ret = clReleaseCommandQueue(command_queue); if (ret != CL_SUCCESS) { printf("error: call to 'clReleaseCommandQueue' failed\n"); exit(1); } /* Release context */ ret = clReleaseContext(context); if (ret != CL_SUCCESS) { printf("error: call to 'clReleaseContext' failed\n"); exit(1); } return 0; }
the_stack_data/161081012.c
#include<stdio.h> #include<stdlib.h> #include<string.h> int n,top=-1,m,rqc=0,buffc=0; int clk=-1,b=0; int arr[20][10],buffer[2][1000]; int rq[1000],ioex[1000],allex[1000], flag[1000], buffx[1000]; typedef struct proc { int no; int burst; }p; int getdata() { int i,j; for(i=1;i<=n;i++) for(j=1;j<=10;j++) arr[i][j]=0; for(i=1;i<=n;i++) arr[i][0]=i; printf("\nEnter the Arrival Times:\n"); for(i=1;i<=n;i++) scanf("%d",&arr[i][1]); printf("Enter the 1st CPU Burst Times:\n"); for(i=1;i<=n;i++) scanf("%d",&arr[i][2]); printf("Enter the I/O Burst Times:\n"); for(i=1;i<=n;i++) scanf("%d",&arr[i][3]); printf("Enter the 2nd CPU Burst Times:\n"); for(i=1;i<=n;i++) scanf("%d",&arr[i][4]); } void push(int x) { int i=0,j; if(rq[1]==-1) { rq[1]=x; top=1; } else { for(j=rqc;j>=1;j--) rq[j+1]=rq[j]; rq[1]=x; top++; } rqc++; } int pop() { int i=0,x; if(top>0) { x=rq[top]; top--; } else if(top<=0); return x; } void pushbuff(int x) { int i=0,j; buffc++; buffx[buffc]=x; if(x==buffer[0][b]); if(b<=0) { buffer[0][1]=x; buffer[1][1]=arr[x][3]; b=1; } else if(b>0) { b++; for(j=b;j>=1;j--) { buffer[0][j+1]=buffer[0][j]; buffer[1][j+1]=buffer[1][j]; } buffer[0][1]=x; buffer[1][1]=arr[x][3]; } for(i=1;i<=n-1 && b>1;i++) { for(j=1;j<=n-i-1;j++) { if(buffer[1][j]<buffer[1][j+1]) { buffer[0][j]^=buffer[0][j+1]^=buffer[0][j]^=buffer[0][j+1]; buffer[1][j]^=buffer[1][j+1]^=buffer[1][j]^=buffer[1][j+1]; } } } } int popbuff() { int x; if(b>0) { x=buffer[0][b]; b--; } else; return x; } int max() { int i,m=0; for(i=1;i<=n;i++) m+=arr[i][2]+arr[i][3]+arr[i][4]; return m; } void avg() { float a=0,b=0; int i; for(i=1;i<=n;i++) { a+=arr[i][5]; b+=arr[i][6]; } a=a/n; b=b/n; printf("\nAvg. WT = %.2f\nAvg. TAT = %.2f\n",a,b); } void flagging() { int i,j; for(i=1;i<100;i++) flag[i]=0; for(i=1;i<=n;i++) { for(j=2;j<=4;j++) { if(arr[i][j]>0) flag[i]+=1; } } } void display() { int i,j; printf("\n"); for(i=0;i<=80;i++) printf("-"); printf("\n\nThe output is:\n"); printf("Process\tAT\tBT-1\tI/OT\tBT-2\tWT\tTAT\tCT\n"); for(i=1;i<=n;i++) { printf("P-%d\t",arr[i][0]); for(j=1;j<=7;j++) printf("%d\t", arr[i][j]); printf("\n"); } printf("\n"); for(i=0;i<=80;i++) printf("-"); printf("\n\nThe ready queue is:\n"); for(i=rqc;i>=1;i--) if(rq[i]!=0 && rq[i]!=-1) printf("P-%d ", rq[i]); printf("\n\nThe execution array is:\n"); for(i=0;i<=1000;i++) { if(allex[i]>0 && allex[i]!=allex[i-1]) printf("%d P-%d ",i, allex[i]); else if(allex[i]==-4 && allex[i]!=allex[i-1]) printf("%d -- ",i); } printf("\n\nThe buffer is:\n"); for(i=1;i<=buffc;i++) if(buffx[i]!=-1) printf("P-%d ", buffx[i]); printf("\n"); avg(); } int check() { int i; for(i=0;i<=n;i++) if(flag[i]>0) return 1; return 0; } void fcfs() { int i,j,t,f,pc=0; p pro; m=max(); for(i=1;i<=m;i++) { rq[i]=-1; buffer[0][i]=-1; buffer[1][i]=-1; buffx[i]=-1; } flagging(); push(arr[1][0]); clk=arr[1][1]; pc++; if(top>0) { pro.no=pop(); flag[pro.no]--; pro.burst=arr[pro.no][2]; allex[clk]=pro.no; } for(j=2;j<=n;j++) if(arr[j][1]==clk) push(arr[j][0]); clk++; while(clk<=m+1) { for(j=2;j<=n;j++) if(arr[j][1]==clk) push(arr[j][0]); if(pro.burst>0) { pro.burst--; allex[clk]=pro.no; } if(b>0) { for(i=b;i>=1;i--) { if(buffer[1][i]>0) buffer[1][i]--; if(buffer[1][i]==0) { f=popbuff(); push(f); } } } if(pro.burst==0) { int x=check(); if(top>0) { if(flag[pro.no]==2) { flag[pro.no]--; pushbuff(pro.no); } if(flag[pro.no]==0) { arr[pro.no][7]=clk; allex[clk]=pro.no; } if(flag[rq[top]]==3) { pro.no=pop(); flag[pro.no]--; pro.burst=arr[pro.no][2]; allex[clk]=pro.no; } else if(flag[rq[top]]==1) { pro.no=pop(); if(arr[pro.no][4]==0) pro.burst=arr[pro.no][2]; else pro.burst=arr[pro.no][4]; flag[pro.no]--; allex[clk]=pro.no; } if(x==0) break; } else if(top<=0) { if(flag[pro.no]==2) { flag[pro.no]--; pushbuff(pro.no); allex[clk]=pro.no; } else if(flag[pro.no]==0) { arr[pro.no][7]=clk; allex[clk]=pro.no; } else if(flag[pro.no]==1) { flag[pro.no]--; allex[clk]=pro.no; } pro.no=0; allex[clk]=-4; if(x==0) break; } } if(flag[rq[1]==0]) break; clk++; } arr[1][5]=0; //for WT 0 arr[1][6]=arr[1][7]-arr[1][1]; //for TAT 0 for(i=2;i<=n;i++) { arr[i][6]=arr[i][7]-arr[i][1]; //for TAT i arr[i][5]=arr[i][6]-arr[i][2]-arr[i][3]-arr[i][4]; //for WT i } display(); } int main() { int i; printf("\n"); for(i=0;i<=80;i++) printf("-"); printf("\nEnter the number of processes: "); scanf("%d",&n); getdata(); fcfs(); printf("\n"); for(i=0;i<=40;i++) printf("-x"); printf("\n"); char key = getch(); if(key=='T' || key=='t') exit(0); return 0; }
the_stack_data/235680.c
// Let's start with the header files, a #define and the check that the correct number // of command-line arguments have been supplied. #include <unistd.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include <fcntl.h> #include <sys/types.h> #include <sys/stat.h> #define FIFO_NAME "/tmp/my_fifo" int main(int argc, char *argv[]) { int res; int open_mode = 0; int i; if (argc < 2) { fprintf(stderr, "Usage: %s <some combination of\ O_RDONLY O_WRONLY O_NONBLOCK>\n", *argv); exit(EXIT_FAILURE); } // Assuming that the program passed the test, we now set the value of open_mode // from those arguments. for(i = 1; i < argc; i++) { if (strncmp(*++argv, "O_RDONLY", 8) == 0) open_mode |= O_RDONLY; if (strncmp(*argv, "O_WRONLY", 8) == 0) open_mode |= O_WRONLY; if (strncmp(*argv, "O_NONBLOCK", 10) == 0) open_mode |= O_NONBLOCK; } // We now check whether the FIFO exists and create it if necessary. // Then the FIFO is opened and output given to that effect while the program // catches forty winks. Last of all, the FIFO is closed. if (access(FIFO_NAME, F_OK) == -1) { res = mkfifo(FIFO_NAME, 0777); if (res != 0) { fprintf(stderr, "Could not create fifo %s\n", FIFO_NAME); exit(EXIT_FAILURE); } } printf("Process %d opening FIFO\n", getpid()); res = open(FIFO_NAME, open_mode); printf("Process %d result %d\n", getpid(), res); sleep(5); if (res != -1) (void)close(res); printf("Process %d finished\n", getpid()); exit(EXIT_SUCCESS); }
the_stack_data/150140938.c
// REQUIRES: x86-registered-target // RUN: %clang -fno-experimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -o - | FileCheck %s // RUN: %clang -O1 -fno-experimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -o - | FileCheck %s // RUN: %clang -O2 -fno-experimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -o - | FileCheck %s // RUN: %clang -O3 -fno-experimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -o - | FileCheck %s // RUN: %clang -fno-experimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -o - | FileCheck %s // Verify that -fsanitize=thread invokes tsan instrumentation. // Also check that this works with the new pass manager with and without // optimization // RUN: %clang -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -o - | FileCheck %s // RUN: %clang -O1 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -o - | FileCheck %s // RUN: %clang -O2 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -o - | FileCheck %s // RUN: %clang -O3 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -o - | FileCheck %s // RUN: %clang -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -o - | FileCheck %s int foo(int *a) { return *a; } // CHECK: __tsan_init
the_stack_data/74116.c
#include <stdio.h> #include <math.h> #ifdef _OPENMP #include <omp.h> #endif // Add timing support #include <sys/time.h> double time_stamp() { struct timeval t; double time; gettimeofday(&t, NULL); time = t.tv_sec + 1.0e-6*t.tv_usec; return time; } double time1, time2; void driver(void); void initialize(void); void jacobi(void); void error_check(void); /************************************************************ * program to solve a finite difference * discretization of Helmholtz equation : * (d2/dx2)u + (d2/dy2)u - alpha u = f * using Jacobi iterative method. * * Modified: Sanjiv Shah, Kuck and Associates, Inc. (KAI), 1998 * Author: Joseph Robicheaux, Kuck and Associates, Inc. (KAI), 1998 * This c version program is translated by * Chunhua Liao, University of Houston, Jan, 2005 * * Directives are used in this code to achieve paralleism. * All do loops are parallized with default 'static' scheduling. * * Input : n - grid dimension in x direction * m - grid dimension in y direction * alpha - Helmholtz constant (always greater than 0.0) * tol - error tolerance for iterative solver * relax - Successice over relaxation parameter * mits - Maximum iterations for iterative solver * * On output * : u(n,m) - Dependent variable (solutions) * : f(n,m) - Right hand side function *************************************************************/ #define MSIZE 500 int n,m,mits; double tol,relax=1.0,alpha=0.0543; double u[MSIZE][MSIZE],f[MSIZE][MSIZE],uold[MSIZE][MSIZE]; double dx,dy; int main (void) { float toler; /* printf("Input n,m (< %d) - grid dimension in x,y direction:\n",MSIZE); scanf ("%d",&n); scanf ("%d",&m); printf("Input tol - error tolerance for iterative solver\n"); scanf("%f",&toler); tol=(double)toler; printf("Input mits - Maximum iterations for solver\n"); scanf("%d",&mits); */ n=MSIZE; m=MSIZE; tol=0.0000000001; mits=5000; #ifdef _OPENMP #pragma omp parallel { #pragma omp single printf("Running using %d threads...\n",omp_get_num_threads()); } #endif driver ( ) ; return 0; } /************************************************************* * Subroutine driver () * This is where the arrays are allocated and initialized. * * Working variables/arrays * dx - grid spacing in x direction * dy - grid spacing in y direction *************************************************************/ void driver( ) { initialize(); time1 = time_stamp(); /* Solve Helmholtz equation */ jacobi (); time2 = time_stamp(); printf("------------------------\n"); printf("Execution time = %f\n",time2-time1); /* error_check (n,m,alpha,dx,dy,u,f)*/ error_check ( ); } /* subroutine initialize (n,m,alpha,dx,dy,u,f) ****************************************************** * Initializes data * Assumes exact solution is u(x,y) = (1-x^2)*(1-y^2) * ******************************************************/ void initialize( ) { int i,j, xx,yy; //double PI=3.1415926; dx = 2.0 / (n-1); dy = 2.0 / (m-1); /* Initialize initial condition and RHS */ #pragma omp parallel for private(xx,yy,j,i) for (i=0;i<n;i++) for (j=0;j<m;j++) { xx =(int)( -1.0 + dx * (i-1)); yy = (int)(-1.0 + dy * (j-1)) ; u[i][j] = 0.0; f[i][j] = -1.0*alpha *(1.0-xx*xx)*(1.0-yy*yy)\ - 2.0*(1.0-xx*xx)-2.0*(1.0-yy*yy); } } /* subroutine jacobi (n,m,dx,dy,alpha,omega,u,f,tol,maxit) ****************************************************************** * Subroutine HelmholtzJ * Solves poisson equation on rectangular grid assuming : * (1) Uniform discretization in each direction, and * (2) Dirichlect boundary conditions * * Jacobi method is used in this routine * * Input : n,m Number of grid points in the X/Y directions * dx,dy Grid spacing in the X/Y directions * alpha Helmholtz eqn. coefficient * omega Relaxation factor * f(n,m) Right hand side function * u(n,m) Dependent variable/Solution * tol Tolerance for iterative solver * maxit Maximum number of iterations * * Output : u(n,m) - Solution *****************************************************************/ void jacobi( ) { double omega; int i,j,k; double error,resid,ax,ay,b; // double error_local; // float ta,tb,tc,td,te,ta1,ta2,tb1,tb2,tc1,tc2,td1,td2; // float te1,te2; // float second; omega=relax; /* * Initialize coefficients */ ax = 1.0/(dx*dx); /* X-direction coef */ ay = 1.0/(dy*dy); /* Y-direction coef */ b = -2.0/(dx*dx)-2.0/(dy*dy) - alpha; /* Central coeff */ error = 10.0 * tol; k = 1; while ((k<=mits)&&(error>tol)) { error = 0.0; /* Copy new solution into old */ #pragma omp parallel { #pragma omp for private(j,i) for(i=0;i<n;i++) for(j=0;j<m;j++) uold[i][j] = u[i][j]; #pragma omp for private(resid,j,i) reduction(+:error) nowait for (i=1;i<(n-1);i++) for (j=1;j<(m-1);j++) { resid = (ax*(uold[i-1][j] + uold[i+1][j])\ + ay*(uold[i][j-1] + uold[i][j+1])+ b * uold[i][j] - f[i][j])/b; u[i][j] = uold[i][j] - omega * resid; error = error + resid*resid ; } } /* omp end parallel */ /* Error check */ k = k + 1; if (k%500==0) printf("Finished %d iteration.\n",k); error = sqrt(error)/(n*m); } /* End iteration loop */ printf("Total Number of Iterations:%d\n",k); printf("Residual:%E\n", error); } /* subroutine error_check (n,m,alpha,dx,dy,u,f) implicit none ************************************************************ * Checks error between numerical and exact solution * ************************************************************/ void error_check ( ) { int i,j; double xx,yy,temp,error; dx = 2.0 / (n-1); dy = 2.0 / (m-1); error = 0.0 ; #pragma omp parallel for private(xx,yy,temp,j,i) reduction(+:error) for (i=0;i<n;i++) for (j=0;j<m;j++) { xx = -1.0 + dx * (i-1); yy = -1.0 + dy * (j-1); temp = u[i][j] - (1.0-xx*xx)*(1.0-yy*yy); error = error + temp*temp; } error = sqrt(error)/(n*m); printf("Solution Error :%E \n",error); }
the_stack_data/179830053.c
/* PR debug/45500 */ /* { dg-do compile } */ /* { dg-options "-g -msse" } */ typedef char V __attribute__ ((__vector_size__ (16))); static const V s = { '\n', '\r', '?', '\\' };