file
stringlengths 18
26
| data
stringlengths 3
1.04M
|
---|---|
the_stack_data/43886909.c | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
void reverseString(char str[], int start, int end) {
char temp;
while(start < end) {
temp = str[start];
str[start] = str[end];
str[end] = temp;
start++;
end--;
}
}
void reverse(char str[]) {
int start = 0;
int end = strlen(str) - 1;
reverseString(str, 0, end);
while(start < end) {
int wordStart = start;
int wordEnd = start;
//1. Find the end of the word
while(str[wordEnd] != ' ' && wordEnd != end) {
wordEnd++;
}
if(wordEnd != end) {
wordEnd--; //Found a space, back it up
}
//2. Reverse this word
reverseString(str, wordStart, wordEnd);
//3. Move to the next word
if(wordEnd != end) {
start = wordEnd + 2; //Account for empty space
} else {
start = end; //Done
}
}
}
void test(char * str){
char * testStr = (char *) malloc(sizeof(str));
strcpy(testStr, str);
reverse(testStr);
printf("%s\n", testStr);
free(testStr);
}
int main()
{
test("Please reverse me");
test("This is just a longer test");
test("This is");
test("This");
test("");
} |
the_stack_data/179830823.c | #include<stdio.h>
int f(int n){
int i,a,sum=0;
for(i=1;i<=n;i++){
a=n%i;
if(a==0){
sum+=1;
}
}
if(sum==2){
return 1;
}
else{
return 0;
}
}
int main(){
int n,i;
scanf("%d",&n);
for(i=1;;i++){
if(f(n+i)){
printf("%d",n+i);
return 0;
}
}
} |
the_stack_data/74966.c | /*
* @file atividade_1
* @author Deivid da Silva Galvao
* @date 16 mar 2022
* @brief:
1) Crie uma estrutura para representar as coordenadas de
um ponto no plano (posições X e Y). Em seguida, declare
e leia do teclado dois pontos e exiba a distância entre
eles.
*/
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
//definindo a estrutura para representar as coordenadas de um ponto
struct Coordenadas
{
int xa, xb;
int ya , yb;
} Coordenadas;//fecha struct
int main(int argc, char const *argv[])
{
float distancia;
//coletar os dados referentes a posição dos pontos
printf("Ponto = (Xa, Ya) // (Xb, Yb)");
printf("Digite um valor para a cordenada Xa: ");
scanf("%d", &Coordenadas.xa);
printf("Digite um valor para a cordenada Xb: ");
scanf("%d", &Coordenadas.xb);
printf("Digite um valor para a cordenada Ya: ");
scanf("%d", &Coordenadas.ya);
printf("Digite um valor para a cordenada Yb: ");
scanf("%d", &Coordenadas.yb);
//declarando a formula de distantacia entre dois pontos
distancia = sqrt(pow((Coordenadas.xb - Coordenadas.xa ), 2) + pow((Coordenadas.yb - Coordenadas.ya ), 2));
//exibindo o resultado para o usuario
printf("O valor correspondente a distancia dos pontos digitados eh de: %.2f", distancia);
return 0;
}//main
|
the_stack_data/132952562.c |
/* from valgrind tests */
/* ================ sha1.c ================ */
/*
SHA-1 in C
By Steve Reid <[email protected]>
100% Public Domain
Test Vectors (from FIPS PUB 180-1)
"abc"
A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D
"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1
A million repetitions of "a"
34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F
*/
/* #define LITTLE_ENDIAN * This should be #define'd already, if true. */
/* #define SHA1HANDSOFF * Copies data before messing with it. */
#define SHA1HANDSOFF
#include <stdio.h>
#include <string.h>
#include <stdint.h>
/* ================ sha1.h ================ */
/*
SHA-1 in C
By Steve Reid <[email protected]>
100% Public Domain
*/
typedef struct {
uint32_t state[5];
uint32_t count[2];
unsigned char buffer[64];
} SHA1_CTX;
void SHA1Transform(uint32_t state[5], const unsigned char buffer[64]);
void SHA1Init(SHA1_CTX* context);
void SHA1Update(SHA1_CTX* context, const unsigned char* data, uint32_t len);
void SHA1Final(unsigned char digest[20], SHA1_CTX* context);
/* ================ end of sha1.h ================ */
#include <endian.h>
#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
/* blk0() and blk() perform the initial expand. */
/* I got the idea of expanding during the round function from SSLeay */
#if BYTE_ORDER == LITTLE_ENDIAN
#define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
|(rol(block->l[i],8)&0x00FF00FF))
#elif BYTE_ORDER == BIG_ENDIAN
#define blk0(i) block->l[i]
#else
#error "Endianness not defined!"
#endif
#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
^block->l[(i+2)&15]^block->l[i&15],1))
/* (R0+R1), R2, R3, R4 are the different operations used in SHA1 */
#define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
#define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30);
#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
/* Hash a single 512-bit block. This is the core of the algorithm. */
void SHA1Transform(uint32_t state[5], const unsigned char buffer[64])
{
uint32_t a, b, c, d, e;
typedef union {
unsigned char c[64];
uint32_t l[16];
} CHAR64LONG16;
#ifdef SHA1HANDSOFF
CHAR64LONG16 block[1]; /* use array to appear as a pointer */
memcpy(block, buffer, 64);
#else
/* The following had better never be used because it causes the
* pointer-to-const buffer to be cast into a pointer to non-const.
* And the result is written through. I threw a "const" in, hoping
* this will cause a diagnostic.
*/
CHAR64LONG16* block = (const CHAR64LONG16*)buffer;
#endif
/* Copy context->state[] to working vars */
a = state[0];
b = state[1];
c = state[2];
d = state[3];
e = state[4];
/* 4 rounds of 20 operations each. Loop unrolled. */
R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3);
R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7);
R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11);
R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15);
R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19);
R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23);
R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27);
R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31);
R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35);
R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39);
R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43);
R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47);
R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51);
R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55);
R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59);
R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63);
R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67);
R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71);
R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75);
R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79);
/* Add the working vars back into context.state[] */
state[0] += a;
state[1] += b;
state[2] += c;
state[3] += d;
state[4] += e;
/* Wipe variables */
a = b = c = d = e = 0;
#ifdef SHA1HANDSOFF
memset(block, '\0', sizeof(block));
#endif
}
/* SHA1Init - Initialize new context */
void SHA1Init(SHA1_CTX* context)
{
/* SHA1 initialization constants */
context->state[0] = 0x67452301;
context->state[1] = 0xEFCDAB89;
context->state[2] = 0x98BADCFE;
context->state[3] = 0x10325476;
context->state[4] = 0xC3D2E1F0;
context->count[0] = context->count[1] = 0;
}
/* Run your data through this. */
void SHA1Update(SHA1_CTX* context, const unsigned char* data, uint32_t len)
{
uint32_t i;
uint32_t j;
j = context->count[0];
if ((context->count[0] += len << 3) < j)
context->count[1]++;
context->count[1] += (len>>29);
j = (j >> 3) & 63;
if ((j + len) > 63) {
memcpy(&context->buffer[j], data, (i = 64-j));
SHA1Transform(context->state, context->buffer);
for ( ; i + 63 < len; i += 64) {
SHA1Transform(context->state, &data[i]);
}
j = 0;
}
else i = 0;
memcpy(&context->buffer[j], &data[i], len - i);
}
/* Add padding and return the message digest. */
void SHA1Final(unsigned char digest[20], SHA1_CTX* context)
{
unsigned i;
unsigned char finalcount[8];
unsigned char c;
#if 0 /* untested "improvement" by DHR */
/* Convert context->count to a sequence of bytes
* in finalcount. Second element first, but
* big-endian order within element.
* But we do it all backwards.
*/
unsigned char *fcp = &finalcount[8];
for (i = 0; i < 2; i++)
{
uint32_t t = context->count[i];
int j;
for (j = 0; j < 4; t >>= 8, j++)
*--fcp = (unsigned char) t;
}
#else
for (i = 0; i < 8; i++) {
finalcount[i] = (unsigned char)((context->count[(i >= 4 ? 0 : 1)]
>> ((3-(i & 3)) * 8) ) & 255); /* Endian independent */
}
#endif
c = 0200;
SHA1Update(context, &c, 1);
while ((context->count[0] & 504) != 448) {
c = 0000;
SHA1Update(context, &c, 1);
}
SHA1Update(context, finalcount, 8); /* Should cause a SHA1Transform() */
for (i = 0; i < 20; i++) {
digest[i] = (unsigned char)
((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
}
/* Wipe variables */
memset(context, '\0', sizeof(*context));
memset(&finalcount, '\0', sizeof(finalcount));
}
/* ================ end of sha1.c ================ */
#define BUFSIZE 4096
int
main(int argc, char **argv)
{
SHA1_CTX ctx;
unsigned char hash[20], buf[BUFSIZE];
int i;
for(i=0;i<BUFSIZE;i++)
buf[i] = i;
SHA1Init(&ctx);
for(i=0;i<1000;i++)
SHA1Update(&ctx, buf, BUFSIZE);
SHA1Final(hash, &ctx);
printf("SHA1=");
for(i=0;i<20;i++)
printf("%02x", hash[i]);
printf("\n");
return 0;
}
|
the_stack_data/64201401.c | /* See LICENSE file for copyright and license details. */
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
int
main(int argc, char *argv[])
{
if (argc < 2) {
fprintf(stderr, "usage: %s command [argv0 [arg ...]]\n", argc ? argv[0] : "exec-as");
} else {
execvp(argv[1], &argv[2]);
fprintf(stderr, "%s: execvp %s: %s\n", argv[0], argv[1], strerror(errno));
}
return 138;
}
|
the_stack_data/150140148.c | /* Copyright (C) 1991, 1995, 1996, 1998, 1999 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, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <stdarg.h>
#include <wchar.h>
/* Read formatted input from S, according to the format string FORMAT. */
/* VARARGS2 */
int
swscanf (s, format)
const wchar_t *s;
const wchar_t *format;
{
va_list arg;
int done;
va_start (arg, format);
done = vswscanf (s, format, arg);
va_end (arg);
return done;
}
|
the_stack_data/161081862.c | /*
gcc -std=c17 -lc -lm -pthread -o ../_build/c/numeric_math_FP_categories.exe ./c/numeric_math_FP_categories.c && (cd ../_build/c/;./numeric_math_FP_categories.exe)
https://en.cppreference.com/w/c/numeric/math/FP_categories
*/
#include <stdio.h>
#include <math.h>
#include <float.h>
const char *show_classification(double x) {
switch(fpclassify(x)) {
case FP_INFINITE: return "Inf";
case FP_NAN: return "NaN";
case FP_NORMAL: return "normal";
case FP_SUBNORMAL: return "subnormal";
case FP_ZERO: return "zero";
default: return "unknown";
}
}
int main(void)
{
printf("1.0/0.0 is %s\n", show_classification(1/0.0));
printf("0.0/0.0 is %s\n", show_classification(0.0/0.0));
printf("DBL_MIN/2 is %s\n", show_classification(DBL_MIN/2));
printf("-0.0 is %s\n", show_classification(-0.0));
printf(" 1.0 is %s\n", show_classification(1.0));
}
|
the_stack_data/1125840.c | #include <stdio.h>
int main() {
/* 我的第一个c 程序 */
printf("Hello, World! \n");
return 0;
} |
the_stack_data/114695.c | int a[2] = {0, 1};
int *p = &(a[0]);
struct {
int f1;
int f2;
} b = {0, 1};
int *q = &(b.f1);
struct c_ {
int f1;
int f2;
} c = {0, 1};
struct c_ *rr = &c;
int *r = &((&c)->f1);
double d1, d2;
double *ss = &d1;
double *s = (double*)&d1;
int e1, e2;
int *ttt = &e1;
int **tt = &ttt;
int *t1 = &*((int*)0);
int main(void) {
int *t2 = 0;
return *p + *q + *r + *s + (t1 != t2);
}
|
the_stack_data/59513603.c | //Program to change elements of a 1d array to the cumulative sum of the elements
#include<stdio.h>
int main()
{
int n;
printf("Enter the number of elements inside the array:\n");
scanf("%d",&n);
int a[n];
printf("Enter the elements inside the array:\n");
int i;
for(i=0;i<n;i++)
{
scanf("%d ",&a[i]);
}
printf("The original array is:\t");
for(i=0;i<n;i++)
{
printf("%d ",a[i]);
}
int b[n];
int sum=0;
for(i=0;i<n;i++)
{
sum=sum+a[i];
b[i]=sum;
}
printf("\n\nThe desired array is:\t");
for(i=0;i<n;i++)
{
printf("%d ",b[i]);
}
return 0;
}
|
the_stack_data/64200789.c | /* $NetBSD: memset.c,v 1.10 2013/12/02 21:21:33 joerg Exp $ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Mike Hibler and Chris Torek.
*
* 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 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.
*/
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
static char sccsid[] = "@(#)memset.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: memset.c,v 1.10 2013/12/02 21:21:33 joerg Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
#if !defined(_KERNEL) && !defined(_STANDALONE)
#include <assert.h>
#include <limits.h>
#include <string.h>
#else
#include <lib/libkern/libkern.h>
#if defined(BZERO) && defined(_STANDALONE)
#include <lib/libsa/stand.h>
#endif
#include <machine/limits.h>
#endif
#define wsize sizeof(u_int)
#define wmask (wsize - 1)
#ifdef _FORTIFY_SOURCE
#undef bzero
#endif
#undef memset
#ifndef __OPTIMIZE_SIZE__
#ifdef BZERO
#define RETURN return
#define VAL 0
#define WIDEVAL 0
void
bzero(void *dst0, size_t length)
#else
#define RETURN return (dst0)
#define VAL c0
#define WIDEVAL c
#if defined(__ARM_EABI__)
void __aeabi_memset(void *, size_t, int);
void __aeabi_memclr(void *, size_t);
__strong_alias(__aeabi_memset4, __aebi_memset)
__strong_alias(__aeabi_memset8, __aebi_memset)
void
__aeabi_memset(void *dst0, size_t length, int c)
{
memset(dst0, c, length);
}
void
__aeabi_memclr(void *dst0, size_t length)
{
memset(dst0, 0, length);
}
#endif
void *
memset(void *dst0, int c0, size_t length)
#endif
{
size_t t;
#ifndef BZERO
u_int c;
#endif
u_char *dst;
_DIAGASSERT(dst0 != 0);
dst = dst0;
/*
* If not enough words, just fill bytes. A length >= 2 words
* guarantees that at least one of them is `complete' after
* any necessary alignment. For instance:
*
* |-----------|-----------|-----------|
* |00|01|02|03|04|05|06|07|08|09|0A|00|
* ^---------------------^
* dst dst+length-1
*
* but we use a minimum of 3 here since the overhead of the code
* to do word writes is substantial.
*/
if (length < 3 * wsize) {
while (length != 0) {
*dst++ = VAL;
--length;
}
RETURN;
}
#ifndef BZERO
if ((c = (u_char)c0) != 0) { /* Fill the word. */
c = (c << 8) | c; /* u_int is 16 bits. */
#if UINT_MAX > 0xffff
c = (c << 16) | c; /* u_int is 32 bits. */
#endif
#if UINT_MAX > 0xffffffff
c = (c << 32) | c; /* u_int is 64 bits. */
#endif
}
#endif
/* Align destination by filling in bytes. */
if ((t = (size_t)((u_long)dst & wmask)) != 0) {
t = wsize - t;
length -= t;
do {
*dst++ = VAL;
} while (--t != 0);
}
/* Fill words. Length was >= 2*words so we know t >= 1 here. */
t = length / wsize;
do {
*(u_int *)(void *)dst = WIDEVAL;
dst += wsize;
} while (--t != 0);
/* Mop up trailing bytes, if any. */
t = length & wmask;
if (t != 0)
do {
*dst++ = VAL;
} while (--t != 0);
RETURN;
}
#else /* __OPTIMIZE_SIZE__ */
#ifdef BZERO
void
bzero(void *dstv, size_t length)
{
u_char *dst = dstv;
while (length-- > 0)
*dst++ = 0;
}
#else
void *
memset(void *dstv, int c, size_t length)
{
u_char *dst = dstv;
while (length-- > 0)
*dst++ = c;
return dstv;
}
#endif /* BZERO */
#endif /* __OPTIMIZE_SIZE__ */
|
the_stack_data/34512620.c | #include <time.h>
char* ctime_r(const time_t* t, char* buf) {
struct tm tm;
localtime_r(t, &tm);
return asctime_r(&tm, buf);
}
|
the_stack_data/15695.c | #include<stdio.h>
#include<stdlib.h>
int main()
{
int n;
int SegmentNumber, OffSet;
char ch;
printf("\nEnter the number of Segments in the Logical Address Space : ");
scanf("%d",&n);
int **SegmentTable=(int**)malloc(n*sizeof(int*));
for(int i=0;i<n;i++)
SegmentTable[i]=(int*)malloc(2*sizeof(int));
printf("\nEnter the contents of the Segment Table :-\n");
for(int i=0;i<n;i++)
{
printf("\nEnter the values for Segment %d : \n",i);
printf("Enter the limit : ");
scanf("%d",&SegmentTable[i][0]);
printf("Enter the base : ");
scanf("%d",&SegmentTable[i][1]);
}
l1:
printf("\nEnter the Logical Address : ");
printf("\nEnter the Segment number : ");
scanf("%d",&SegmentNumber);
printf("Enter the Offset : ");
scanf("%d",&OffSet);
if(SegmentNumber>n-1)
{
printf("\nInvalid Segment number.....! \nProcess does not have a segment of this segment number...!");
}
else
{
if(OffSet<SegmentTable[SegmentNumber][0])
{
printf("\nEntered Logical address is valid.....!");
printf("\nPhysical Address of the Segment : %d",SegmentTable[SegmentNumber][1]+OffSet);
}
else
{
printf("\nIllegal Reference, TRAP to Operating system......!");
}
}
printf("\nDo you want to operate more? (y/n) : ");
while(getchar()!='\n');
scanf("%c",&ch);
if(ch=='y' || ch=='Y')
goto l1;
return 0;
} |
the_stack_data/192330542.c | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <unistd.h>
static long long fib_sequence(long long k)
{
/* FIXME: use clz/ctz and fast algorithms to speed up */
long long f[k + 2];
f[0] = 0;
f[1] = 1;
for (int i = 2; i <= k; i++) {
f[i] = f[i - 1] + f[i - 2];
}
printf("fib[%lld] = %lld\n",k,f[k]);
return f[k];
}
long elapse(struct timespec start, struct timespec end)
{
return ((long) 1.0e+9 * end.tv_sec + end.tv_nsec) -
((long) 1.0e+9 * start.tv_sec + start.tv_nsec);
}
static long long fast_doubling(long long k)
{
int k_len = 31- __builtin_clz(k);
printf("k: %lld, k_len: %d\n",k,k_len);
long long a = 0;
long long b = 1;
long long t1, t2;
long long c = k;
for (int i = k_len; i >= 0; i--){
t1 = a * (2 * b - a);
t2 = b*b + a*a;
a = t1;
b = t2;
if ((k & (1 << i))>0) {
t1 = a + b;
a = b;
b = t1;
}
}
printf("fib[%lld] = %lld\n",c,a);
return a;
}
int main(){
struct timespec t1, t2;
for (int i = 2; i < 93; i++){
clock_gettime (CLOCK_REALTIME, &t1);
(void) fib_sequence(i);
clock_gettime (CLOCK_REALTIME, &t2);
printf("%d ", i);
printf("%ld ",elapse(t1,t2));
clock_gettime (CLOCK_REALTIME, &t1);
(void) fast_doubling(i);
clock_gettime (CLOCK_REALTIME, &t2);
printf("%d ", i);
printf("%ld\n",elapse(t1,t2));
}
} |
the_stack_data/51701212.c | #include <check.h>
#include <stdlib.h>
Suite*
font_suite(void);
Suite*
image_suite(void);
Suite*
mesh_suite(void);
Suite*
render_suite(void);
Suite*
scene_suite(void);
Suite*
shader_suite(void);
Suite*
texture_suite(void);
int
main(int argc, char *argv[])
{
// initialize a master suite and a suite runner
Suite *s = suite_create("suite");
SRunner *sr = srunner_create(s);
// add external suites
srunner_add_suite(sr, font_suite());
srunner_add_suite(sr, image_suite());
srunner_add_suite(sr, mesh_suite());
srunner_add_suite(sr, render_suite());
srunner_add_suite(sr, scene_suite());
srunner_add_suite(sr, shader_suite());
srunner_add_suite(sr, texture_suite());
// execute all suites
srunner_run_all(sr, CK_NORMAL);
int failed = srunner_ntests_failed(sr);
srunner_free(sr);
return failed ? EXIT_FAILURE : EXIT_SUCCESS;
}
|
the_stack_data/73575786.c | //Program demonstrating an application of doubly linked list
/*Write an algorithm (using doubly linked list) and subsequent C program for your algorithm, which inserts a new element between every pair of consecutive elements.
The new element is the sum of its neighbors. For example, your C code will produce output 12 46 34 90 56 134 78 93 15 80 65 137 72 for the input 12 34 56 78 15 65 72.*/
#include<stdio.h>
#include<stdlib.h>
struct Node {
int data;
struct Node* next; // Pointer to next node in DLL
struct Node* prev; // Pointer to previous node in DLL
}*head=NULL; //Global structure variable
//Function to push into the doubly linked list
void push(int value){
//Create a new node
struct Node *newnode=(struct Node*)malloc(sizeof(struct Node));
//set the value and the links
newnode->data=value;
newnode->next=NULL;
newnode->prev=NULL;
if(head==NULL)
head=newnode;
else
{
struct Node *temp=head;
while(temp->next !=NULL)
temp=temp->next;
//Changing the links
temp->next=newnode;
newnode->prev=temp;
newnode->next=NULL;
}
}
//Function to insert the sum in between the elements
void insertbetween(struct Node *prev_node,int value){
//Creating a new node
struct Node *newnode=(struct Node*)malloc(sizeof(struct Node));
//Set the value and the links for the new node
newnode->data=value;
newnode->next=prev_node->next;
newnode->prev=prev_node;
//Insert the node in between
if (newnode->next != NULL)
newnode->next->prev = newnode;
prev_node->next=newnode;
}
//Function to compute the sum of 2 consecutive elements
void sum(){
//Create a pointer
struct Node *temp=head;
int val;
//Calculating the sum
while(temp!=NULL && temp->next!=NULL){
val=temp->data+temp->next->data;
insertbetween(temp,val);
temp=temp->next->next;
}
}
//Function to display the final DLL
void display(){
//Create a pointer
struct Node *ptr=head;
//Traverse through the nodes and print each of the node values
while(ptr!=NULL){
printf("%d ",ptr->data);
ptr=ptr->next;
}
}
int main(){
//Declare the necessary values
int n,value,i;
//Getting n which is the number of elements in the list
printf("Enter the value of n:");
scanf("%d",&n);
//Getting the elements the elements of the list
printf("\nEnter the elements of the list:\n");
for(i=0;i<n;i++){
scanf("%d",&value);
//Push the element into he DLL
push(value);
}
sum(); //Function call to calculate the sum of consecutive elements
printf("\n");
printf("Final output:\n");
display(); //Fucntion call to display the final list
}
|
the_stack_data/44955.c | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: angagnie <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/24 17:09:41 by angagnie #+# #+# */
/* Updated: 2015/11/24 17:14:42 by angagnie ### ########.fr */
/* */
/* ************************************************************************** */
int ft_strcmp(const char* s1, const char* s2)
{
while (*s1 == *s2 && *s1 != '\0')
{
s1++;
s2++;
}
return (*(unsigned char*)s1 - *(unsigned char*)s2);
}
|
the_stack_data/102268.c | #include <stdio.h>
int main() {
printf("real uid: %d\n", getuid());
printf("effective uid: %d\n", geteuid());
}
|
the_stack_data/90762030.c | #define ERROR 0
# 1 "trivial-tb.c"
// trivial-tb.c
// NUMERRORS 4
// test the test-bad target and lib/test-bad script
#include <stdio.h> // printf
#include <stdlib.h> // exit
void fail(int val)
{
printf("fail(%d)\n", val);
exit(val);
}
int main()
{
# 17
# 18
# 19
# 20
printf("no failure\n");
return 0;
}
|
the_stack_data/1234016.c | //Servidor concurrente para atender mas de una conexion
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <signal.h>
//Funcion para procesar al nuevo cliente conectado
void procesar (int sock)
{
int n;
char buffer[256];
bzero(buffer,256);
//Se lee del nuevo socket, se verifica si hay error
n = read(sock,buffer,255);
if (n < 0)
{
perror("Error al leer del socket\n");
exit(1);
}
//Se imprime el mensaje que envio el socket
printf("Mensaje del socket: %s\n",buffer);
//Se devuelve una cadena como respuesta al socket y se verifica si hay error
n = write(sock,"Respuesta a socket",18);
if (n < 0)
{
perror("Error al escribir en el socket\n");
exit(1);
}
}
int main()
{
struct sockaddr_in sockaddr, clientaddr; //Estructuras para almacenar la info del socket
int s; //Socket principal
int ns; //Socket que se crea despues del accept()
int pid; //Idetificador de procesos fork()
int len; //Longitud de estrucutras
int portno = 51717; //Puerto de comunicacion
//Se abre el socket y se verifican errores
if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0)
perror("Error al crear socket\n");
//Inicializar estructura del socket
memset(&sockaddr,0,sizeof(sockaddr));
sockaddr.sin_family = AF_INET;
sockaddr.sin_port = htons(portno);
sockaddr.sin_addr.s_addr = INADDR_ANY;
//Definimos la longitud de la estructura
len=sizeof(sockaddr);
//Se liga al socket usando bind y se verifican errores
if (bind(s, (struct sockaddr *)&sockaddr, len) < 0)
perror("Error en el bind\n");
//Señal para ignorar la terminacion de cada hijo
signal(SIGCHLD, SIG_IGN);
//Se coloca al socket en modo pasivo a la espera de conexiones y se verifican errores
if (listen(s,10) < 0)
perror("Eror en el listen\n");
//Ciclo infinito para aceptar conexiones
printf("Socket disponible\n");
while(1)
{
//Longitud de ls estructura
len=sizeof(sockaddr);
//Se espera por conexiones, se bloquea hasta que ocurre alguna
if ((ns = accept(s,(struct sockaddr *)&sockaddr,&len)) < 0)
perror("Error en el accept\n");
//Se crea un proceso hijo por cada conexion entrante
//Se verifica por algun error en fork()
printf("Conexion establecida\n");
if((pid = fork()) < 0)
{
perror("Error en fork\n");
exit(1);
}
//El proceso hijo atiende la nuevo conexion
if(pid == 0)
{
printf("Atendiendo conexion\n");
//Se llama a la funcion que procesara los datos
procesar(ns);
exit(0);
}
//Proceso padre cierra el nuevo socket y queda en espera de mas conexiones
else
close(ns);
}
return(0);
}
|
the_stack_data/563002.c | #include <stdio.h>
#include <stdbool.h>
struct Element {
char name[2];
int atomic_number;
double atomic_weight;
bool metallic;
};
int main() {
int temp;
struct Element gold;
gold.name[0] = 'A';
gold.name[1] = 'u';
gold.atomic_number = 79;
gold.atomic_weight = 196.966569;
gold.metallic = true;
printf("Element struct is %d bytes\n", sizeof(struct Element));
printf("gold is at \t%p\n\n", &gold);
printf("name: \t\t%p; \nnumber: \t%p; \nweight: \t%p; \nmetallic: \t%p\n",
&gold.name, &gold.atomic_number, &gold.atomic_weight, &gold.metallic);
printf("\nlocal temp is at \t%p\n\n", &temp);
// What does gold look like in memory?
// How do each of the lines above know where their corresponding values are?
} |
the_stack_data/122015604.c | #include <stdio.h>
int sad = 1; //Set if you are sad. Zero if not (C does not support Boolean :( )
char vodka[] = "Vodka\n";
int main() {
if(sad) {
drink(vodka);
}
return 0;
}
int drink(char str[]) {
printf(str);
return 0;
}
|
the_stack_data/154830394.c | #include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
static int compare(const void *a, const void *b)
{
return *(int *) a - *(int *) b;
}
static void dfs(int *nums, int size, bool *used, int *stack,
int len, int **results, int *count, int *col_size)
{
int i;
if (len == size) {
results[*count] = malloc(len * sizeof(int));
memcpy(results[*count], stack, len * sizeof(int));
col_size[*count] = size;
(*count)++;
} else {
/* Reverse order is allowed in different levels, always starts from [0] */
for (i = 0; i < size; i++) {
/* Used marks only allows remaining elements in DFS levels */
if (!used[i]) {
if (i > 0 && !used[i - 1] && nums[i - 1] == nums[i]) {
/* In case duplicate permutation with same elemements in the same postion */
/* used[i - 1] == true means different level position */
continue;
}
used[i] = true;
stack[len] = nums[i];
dfs(nums, size, used, stack, len + 1, results, count, col_size);
used[i] = false;
}
}
}
}
/**
* Return an array of arrays of size *returnSize.
* The sizes of the arrays are returned as *returnColumnSizes array.
* Note: Both returned array and *returnColumnSizes array must be malloced, assume caller calls free().
*/
static int **permute(int* nums, int numsSize, int* returnSize, int **returnColumnSize)
{
qsort(nums, numsSize, sizeof(int), compare);
int count = 0, cap = 10000;
int *stack = malloc(numsSize * sizeof(int));
int **results = malloc(cap * sizeof(int *));
bool *used = malloc(numsSize * sizeof(bool));
memset(used, false, numsSize * sizeof(bool));
*returnSize = 0;
*returnColumnSize = malloc(cap * sizeof(int));
dfs(nums, numsSize, used, stack, 0, results, returnSize, *returnColumnSize);
return results;
}
int main(int argc, char **argv)
{
if (argc <= 1) {
fprintf(stderr, "Usage: ./test ...\n");
exit(-1);
}
int i, j, count = argc - 1;
int *nums = malloc(count * sizeof(int));
for (i = 0; i < count; i++) {
nums[i] = atoi(argv[i + 1]);
}
int *size;
int **lists = permute(nums, argc - 1, &count, &size);
for (i = 0; i < count; i++) {
for (j = 0; j < argc - 1; j++) {
printf("%d", lists[i][j]);
}
putchar('\n');
}
return 0;
}
|
the_stack_data/211080150.c | /*
initiator - re-runs a service repeatedly
(because cleaning up the init code for TLS was more work.)
(C)Copyright 2014-2017 Smithee,Spelvin,Agnew & Plinge, Inc.
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.
Support provided by the Security Industry Association
http://www.securityindustry.org
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#define EQUALS ==
int main(int
argc,
char* argv[])
{ /* initiator */
int
done;
FILE* ef;
int
status;
status = 0;
fprintf(stderr, "repeating command: %s\n",
argv[1]);
done = 0;
system("echo yes >server_enable");
while (!done) {
system(argv[1]);
sleep(5);
ef = fopen("server_enable", "r");
if (ef EQUALS NULL) {
fprintf(stderr, "server no longer enabled. exiting.\n");
done = 1;
};
};
if (status != 0)
fprintf(stderr, "exit with status %d\n",
status);
return (status);
} /* initiator */
|
the_stack_data/145453950.c | #ifdef CONFIG_USE_LOCAL_STRING_H
#include "_string.h"
#else
#include <string.h>
#endif
//-----------------------------------------------------------------
// strcpy:
//-----------------------------------------------------------------
char * strcpy(char * dst, const char * src)
{
char *start = dst;
while(*dst++ = *src++)
;
return start;
}
//-----------------------------------------------------------------
// strncpy:
//-----------------------------------------------------------------
char * strncpy(char * dst, const char * src, size_t n)
{
if(n != 0)
{
char * d = dst;
const char * s = src;
do
{
if((*d ++ = *s ++) == 0)
{
while (-- n != 0) *d ++ = 0;
break;
}
}
while(-- n != 0);
}
return dst;
}
|
the_stack_data/167326711.c | // sample kappa loading code
#include <stdlib.h>
#include <stdio.h>
int main(void){
char inname[256];
int i, j, ng, dummy;
double pix;
double *kappa;
FILE *fp;
const double theta = 5.0; // opening angle [deg]
// read data for kappa
sprintf(inname, "sample_kappa.dat");
if((fp = fopen(inname, "rb")) == NULL){
printf("can't open the files!\n");
exit(1);
}
fread(&dummy, sizeof(int), 1, fp);
ng = dummy;
kappa = (double *) malloc(sizeof(double)*ng*ng);
if(kappa == NULL){
printf("memory allocation error!\n");
exit(1);
}
fread(kappa, sizeof(double), ng*ng, fp);
fread(&dummy, sizeof(int), 1, fp);
if(ng != dummy){
printf("loading failed!\n");
exit(1);
}
fclose(fp);
pix = theta/ng;
printf("ng:%d pixel size:%g [arcmin]\n", ng, pix*60.0);
// show all values
/*
printf("(x, y): kappa\n");
for(i=0;i<ng;i++){
for(j=0;j<ng;j++){
printf("(%g %g): %g\n", i*pix, j*pix, kappa[j+ng*i]);
}
}
*/
free(kappa);
return 0;
}
|
the_stack_data/115766226.c | /* Copyright (c) 2003-2006 Marcus Geelnard
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not claim
* that you wrote the original software. If you use this software in a
* product, an acknowledgment in the product documentation would be
* appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source distribution. */
/* Note: This code is based on the code found in "codrle2.c" and "dcodrle2.c" by
* David Bourgin, as described in "Introduction to the losslessy
* compression schemes", 1994. The main differences from David's
* implementation are the addition of long (15-bit) run counts, the
* removal of file I/O (this implementation works solely with preallocated
* memory buffers), and that the code is now 100% reentrant. */
#include <stdint.h>
void
bcl_rle_decompress(uint8_t *in, uint8_t *out, uint32_t in_size)
{
uint8_t marker, symbol;
uint32_t i, inpos, outpos, count;
/* Do we have anything to uncompress? */
if (in_size < 1) {
return;
}
/* Get marker symbol from input stream */
inpos = 0;
marker = in[ inpos ++ ];
/* Main decompression loop */
outpos = 0;
do {
symbol = in[ inpos ++ ];
if (symbol == marker) {
/* We had a marker byte */
count = in[ inpos ++ ];
if (count <= 2) {
/* Counts 0, 1 and 2 are used for marker byte repetition
only */
for (i = 0; i <= count; ++ i) {
out[ outpos ++ ] = marker;
}
} else {
if (count & 0x80) {
count = ((count & 0x7f) << 8) + in[ inpos ++ ];
}
symbol = in[ inpos ++ ];
for (i = 0; i <= count; ++ i) {
out[ outpos ++ ] = symbol;
}
}
} else {
/* No marker, plain copy */
out[ outpos ++ ] = symbol;
}
} while (inpos < in_size);
}
|
the_stack_data/953296.c | /*
Made by Github user: Anthon98
MIT License.
*/
#include <stdio.h>
#include <stdlib.h>
// Add the values into a struct. They can't be defined here.
struct Tuple {
size_t chars; // Character count. Size of array.
char *str; // Will be a NULL ptr.
};
// Make a tuple so we can return multiple values.
struct Tuple init()
{
int a = 0; // For getting the character.
struct Tuple tuple = { 0, NULL }; // Fill the values;
// MAIN LOGIC:
while (1) {
a = getchar();
if (a != EOF && a != '\n') {
++tuple.chars; //++ before is faster than ++ after.
tuple.str = realloc(tuple.str, sizeof(char)*tuple.chars);
tuple.str[tuple.chars-1] = a;
// putchar(a);
} else {
// Add a NULL terminator '\0' for the char array. Ya.. I know there's probably a better way to do this.
printf("\n%ld\n", tuple.chars);
tuple.str = realloc(tuple.str, sizeof(char)*tuple.chars+1);
tuple.str[tuple.chars] = '\0'; // Yes technically the character count will be wrong by 1 after this.
return tuple;
}
}
}
// Return multiple values from a function in C
int main(void)
{
struct Tuple tuple = init();
size_t said_size = tuple.chars;
char *str_array = tuple.str;
printf("You wrote: %s and the letter count in the word is: %ld\n", str_array, said_size);
// free and null.
free(tuple.str);
tuple.str = NULL;
return 0;
} |
the_stack_data/81606.c | /*********************************************************************
* Copyright 2010, UCAR/Unidata
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
*********************************************************************/
/* $Id: liblib.c,v 1.2 2010/05/24 19:48:13 dmh Exp $ */
/* $Header: /upc/share/CVS/netcdf-3/liblib/liblib.c,v 1.2 2010/05/24 19:48:13 dmh Exp $ */
/* Only here to keep loader quiet */
int
liblib(void)
{
return 1;
}
|
the_stack_data/168894240.c | #include<stdio.h>
long long c(int,int);
int main()
{
int m,n;
long long x;
scanf("%d%d",&m,&n);
x=c(n,m);
printf("%d",x);
return 0;
}
long long c(int m,int n)
{
int i,j;
long long ans=1;
if(m<n-m)
m=n-m;
for(i=m+1;i<=n;i++)
{
ans*=i;
}
for(j=1;j<=n-m;j++)
{
ans/=j;
}
return ans;
} |
the_stack_data/994096.c | /*
ORDENAMIENTO POR MEZCLA
+ El peor caso de este algoritmo es O(nlogn)
+ Por tanto, puedes usarlo en la práctica
*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define ITEMS 100000
void merge(int* Array, int arraySize, int middle){
int i, j, k;
int newArray[arraySize];
for(i=0, j=middle, k=0; k<arraySize; k++){
newArray[k] = (j == arraySize) ? Array[i++]
: (i == middle) ? Array[j++]
: (Array[j] < Array[i]) ? Array[j++]
: Array[i++];
}
for(i=0; i<arraySize; i++)
Array[i] = newArray[i];
}
void mergeSort(int* Array, int arraySize){
if (arraySize < 2)
return;
int middle = arraySize / 2;
mergeSort(Array, middle);
mergeSort(Array+middle, arraySize-middle);
merge(Array, arraySize, middle);
}
int main(){
int numbers[ITEMS], i;
// Semilla para generar valores distintos cada ejecución
srand(time(NULL));
// Llenamos el arreglo con números aleatorios
for(i=0; i<ITEMS; i++)
numbers[i] = rand();
// Y ejecutamos el ordenamiento
mergeSort(numbers, ITEMS);
return 0;
}
|
the_stack_data/975658.c | /* Copyright (c) 2020 Dennis Wölfing
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* libc/src/unistd/getuid.c
* Get the real user id.
*/
#include <unistd.h>
uid_t getuid(void) {
return 0;
}
|
the_stack_data/61340.c | int auto_patrn = 2;
|
the_stack_data/46406.c | #include <stdio.h>
typedef double Matrix[2][2];
/* START: fig10_38.txt */
/* Standard matrix multiplication */
/* Arrays start at 0 */
void
MatrixMultiply (Matrix A, Matrix B, Matrix C, int N)
{
int i, j, k;
for (i = 0; i < N; i++) /* Initialization */
for (j = 0; j < N; j++)
C[i][j] = 0.0;
for (i = 0; i < N; i++)
for (j = 0; j < N; j++)
for (k = 0; k < N; k++)
C[i][j] += A[i][k] * B[k][j];
}
/* END */
main ()
{
Matrix A = { {1, 2}
, {3, 4}
};
Matrix C;
MatrixMultiply (A, A, C, 2);
printf ("%6.2f %6.2f\n%6.2f %6.2f\n", C[0][0], C[0][1], C[1][0], C[1][1]);
return 0;
}
|
the_stack_data/187643121.c | #include <string.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <strings.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#define BUF_SIZE 256
int main(int argc, char ** argv)
{
int sock, port;
struct sockaddr_in serv_addr;
struct hostent *server;
char buf[BUF_SIZE];
if (argc < 3)
{
fprintf(stderr,"usage: %s <hostname> <port_number>\n", argv[0]);
return EXIT_FAILURE;
}
port = atoi(argv[2]);
sock = socket(AF_INET, SOCK_STREAM, 0);
if (sock < 0)
{
printf("socket() failed: %d", errno);
return EXIT_FAILURE;
}
server = gethostbyname(argv[1]);
if (server == NULL)
{
printf("Host not found\n");
return EXIT_FAILURE;
}
memset((char *) &serv_addr, 0, sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
strncpy((char *)&serv_addr.sin_addr.s_addr, (char *)server->h_addr, server->h_length);
serv_addr.sin_port = htons(port);
if (connect(sock, &serv_addr, sizeof(serv_addr)) < 0)
{
printf("connect() failed: %d", errno);
return EXIT_FAILURE;
}
printf(">");
memset(buf, 0, BUF_SIZE);
fgets(buf, BUF_SIZE-1, stdin);
write(sock, buf, strlen(buf));
memset(buf, 0, BUF_SIZE);
read(sock, buf, BUF_SIZE-1);
printf("%s\n",buf);
close(socket);
return 0;
}
|
the_stack_data/54826012.c | #include <stdio.h>
int main(void) {
double a;
int b;
a = b = 1.5;
printf("a = %.2lf b = %d\n", a, b);
// a = 1.00 b = 1
return 0;
}
|
the_stack_data/76701076.c | #include <stdint.h>
/* On x86, division of one 64-bit integer by another cannot be
done with a single instruction or a short sequence. Thus, GCC
implements 64-bit division and remainder operations through
function calls. These functions are normally obtained from
libgcc, which is automatically included by GCC in any link
that it does.
Some x86-64 machines, however, have a compiler and utilities
that can generate 32-bit x86 code without having any of the
necessary libraries, including libgcc. Thus, we can make
Pintos work on these machines by simply implementing our own
64-bit division routines, which are the only routines from
libgcc that Pintos requires.
Completeness is another reason to include these routines. If
Pintos is completely self-contained, then that makes it that
much less mysterious. */
/* Uses x86 DIVL instruction to divide 64-bit N by 32-bit D to
yield a 32-bit quotient. Returns the quotient.
Traps with a divide error (#DE) if the quotient does not fit
in 32 bits. */
static inline uint32_t
divl (uint64_t n, uint32_t d)
{
uint32_t n1 = n >> 32;
uint32_t n0 = n;
uint32_t q, r;
asm ("divl %4"
: "=d" (r), "=a" (q)
: "0" (n1), "1" (n0), "rm" (d));
return q;
}
/* Returns the number of leading zero bits in X,
which must be nonzero. */
static int
nlz (uint32_t x)
{
/* This technique is portable, but there are better ways to do
it on particular systems. With sufficiently new enough GCC,
you can use __builtin_clz() to take advantage of GCC's
knowledge of how to do it. Or you can use the x86 BSR
instruction directly. */
int n = 0;
if (x <= 0x0000FFFF)
{
n += 16;
x <<= 16;
}
if (x <= 0x00FFFFFF)
{
n += 8;
x <<= 8;
}
if (x <= 0x0FFFFFFF)
{
n += 4;
x <<= 4;
}
if (x <= 0x3FFFFFFF)
{
n += 2;
x <<= 2;
}
if (x <= 0x7FFFFFFF)
n++;
return n;
}
/* Divides unsigned 64-bit N by unsigned 64-bit D and returns the
quotient. */
static uint64_t
udiv64 (uint64_t n, uint64_t d)
{
if ((d >> 32) == 0)
{
/* Proof of correctness:
Let n, d, b, n1, and n0 be defined as in this function.
Let [x] be the "floor" of x. Let T = b[n1/d]. Assume d
nonzero. Then:
[n/d] = [n/d] - T + T
= [n/d - T] + T by (1) below
= [(b*n1 + n0)/d - T] + T by definition of n
= [(b*n1 + n0)/d - dT/d] + T
= [(b(n1 - d[n1/d]) + n0)/d] + T
= [(b[n1 % d] + n0)/d] + T, by definition of %
which is the expression calculated below.
(1) Note that for any real x, integer i: [x] + i = [x + i].
To prevent divl() from trapping, [(b[n1 % d] + n0)/d] must
be less than b. Assume that [n1 % d] and n0 take their
respective maximum values of d - 1 and b - 1:
[(b(d - 1) + (b - 1))/d] < b
<=> [(bd - 1)/d] < b
<=> [b - 1/d] < b
which is a tautology.
Therefore, this code is correct and will not trap. */
uint64_t b = 1ULL << 32;
uint32_t n1 = n >> 32;
uint32_t n0 = n;
uint32_t d0 = d;
return divl (b * (n1 % d0) + n0, d0) + b * (n1 / d0);
}
else
{
/* Based on the algorithm and proof available from
http://www.hackersdelight.org/revisions.pdf. */
if (n < d)
return 0;
else
{
uint32_t d1 = d >> 32;
int s = nlz (d1);
uint64_t q = divl (n >> 1, (d << s) >> 32) >> (31 - s);
return n - (q - 1) * d < d ? q - 1 : q;
}
}
}
/* Divides unsigned 64-bit N by unsigned 64-bit D and returns the
remainder. */
static uint32_t
umod64 (uint64_t n, uint64_t d)
{
return n - d * udiv64 (n, d);
}
/* Divides signed 64-bit N by signed 64-bit D and returns the
quotient. */
static int64_t
sdiv64 (int64_t n, int64_t d)
{
uint64_t n_abs = n >= 0 ? (uint64_t) n : -(uint64_t) n;
uint64_t d_abs = d >= 0 ? (uint64_t) d : -(uint64_t) d;
uint64_t q_abs = udiv64 (n_abs, d_abs);
return (n < 0) == (d < 0) ? (int64_t) q_abs : -(int64_t) q_abs;
}
/* Divides signed 64-bit N by signed 64-bit D and returns the
remainder. */
static int32_t
smod64 (int64_t n, int64_t d)
{
return n - d * sdiv64 (n, d);
}
/* These are the routines that GCC calls. */
long long __divdi3 (long long n, long long d);
long long __moddi3 (long long n, long long d);
unsigned long long __udivdi3 (unsigned long long n, unsigned long long d);
unsigned long long __umoddi3 (unsigned long long n, unsigned long long d);
/* Signed 64-bit division. */
long long
__divdi3 (long long n, long long d)
{
return sdiv64 (n, d);
}
/* Signed 64-bit remainder. */
long long
__moddi3 (long long n, long long d)
{
return smod64 (n, d);
}
/* Unsigned 64-bit division. */
unsigned long long
__udivdi3 (unsigned long long n, unsigned long long d)
{
return udiv64 (n, d);
}
/* Unsigned 64-bit remainder. */
unsigned long long
__umoddi3 (unsigned long long n, unsigned long long d)
{
return umod64 (n, d);
}
|
the_stack_data/1001419.c | #include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <signal.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#define DEFAULT_PROTOCOL 0
#define BUF_SIZE 2048
int readLine(int , char *);
int main(int argc, char *argv[]) {
int fd, sfd, cfd, port, cLen, size;
char recv_msg[BUF_SIZE], send_msg[BUF_SIZE];
struct sockaddr_in saddr, caddr;
struct hostent *hp;
char *haddrp, *path, *f;
char delimeter[] = "\t";
char *result;
char parsing[30][1024];
signal(SIGCHLD, SIG_IGN);
if ( argc != 2 ) {
fprintf(stderr, "Usage : %s <port> \n", argv[0]);
exit(0);
}
port = atoi(argv[1]);
sfd = socket(AF_INET, SOCK_STREAM, DEFAULT_PROTOCOL);
bzero((char *)&saddr, sizeof(saddr));
saddr.sin_family = AF_INET;
saddr.sin_addr.s_addr = htonl(INADDR_ANY);
saddr.sin_port = htons((unsigned short)port);
bind(sfd, (struct sockaddr *)&saddr, sizeof(saddr));
listen(sfd, 5);
while(1) {
cLen = sizeof(caddr);
cfd = accept(sfd, (struct sockaddr *)&caddr, &cLen);
haddrp = inet_ntoa(caddr.sin_addr);
printf("Server : %s(%d) connected.\n", haddrp, caddr.sin_port);
if ( fork() == 0 ) {
//readLine(cfd, recv_msg);
//printf("%s", recv_msg);
int i=0;
result = strtok(recv_msg, delimeter);
while ( result != NULL ) {
strcpy(parsing[i++], result);
result = strtok(NULL, delimeter);
printf("strtok!\n");
}
for ( i=0; i<30 ; i++ ) {
printf("[%d] : %s\n", i, parsing[i]);
}
close(fd);
close(cfd);
exit(0);
} else {
close(cfd);
}
}
}
int readLine(int fd, char *str) {
int n;
do {
n = read(fd, str, 1);
} while ( n>0 && *str++ != '\0' );
return ( n>0 );
}
|
the_stack_data/82949876.c | //==================================================================//
// 数値を16進数で文字列化
// マイナス値の処理は無い
//==================================================================//
void HexToStr (unsigned int num,char *s) {
int q = 0;
int l = num;
int minus = 0;
while(l/=16){ q++; }
q = q;
for(int i=q;i>=0;i--)
{
int m = num % 16;
if(m>=0 && m<=9)
s[i] = m + '0';
else
s[i] = m + ('A'-10);
num = num/16;
}
s[q+1] = '\0';
}
|
the_stack_data/150373.c | /* Generated by CIL v. 1.7.0 */
/* print_CIL_Input is false */
struct _IO_FILE;
struct timeval;
extern void signal(int sig , void *func ) ;
extern float strtof(char const *str , char const *endptr ) ;
typedef struct _IO_FILE FILE;
extern int atoi(char const *s ) ;
extern double strtod(char const *str , char const *endptr ) ;
extern int fclose(void *stream ) ;
extern void *fopen(char const *filename , char const *mode ) ;
extern void abort() ;
extern void exit(int status ) ;
extern int raise(int sig ) ;
extern int fprintf(struct _IO_FILE *stream , char const *format , ...) ;
extern int strcmp(char const *a , char const *b ) ;
extern int rand() ;
extern unsigned long strtoul(char const *str , char const *endptr , int base ) ;
void RandomFunc(unsigned short input[1] , unsigned short output[1] ) ;
extern int strncmp(char const *s1 , char const *s2 , unsigned long maxlen ) ;
extern int gettimeofday(struct timeval *tv , void *tz , ...) ;
extern int printf(char const *format , ...) ;
int main(int argc , char *argv[] ) ;
void megaInit(void) ;
extern unsigned long strlen(char const *s ) ;
extern long strtol(char const *str , char const *endptr , int base ) ;
extern unsigned long strnlen(char const *s , unsigned long maxlen ) ;
extern void *memcpy(void *s1 , void const *s2 , unsigned long size ) ;
struct timeval {
long tv_sec ;
long tv_usec ;
};
extern void *malloc(unsigned long size ) ;
extern int scanf(char const *format , ...) ;
void RandomFunc(unsigned short input[1] , unsigned short output[1] )
{
unsigned short state[1] ;
char copy12 ;
{
state[0UL] = input[0UL] + (unsigned short)2885;
if ((state[0UL] >> (unsigned short)4) & (unsigned short)1) {
if ((state[0UL] >> (unsigned short)4) & (unsigned short)1) {
state[0UL] *= state[0UL];
} else {
copy12 = *((char *)(& state[0UL]) + 1);
*((char *)(& state[0UL]) + 1) = *((char *)(& state[0UL]) + 0);
*((char *)(& state[0UL]) + 0) = copy12;
state[0UL] += state[0UL];
}
} else {
state[0UL] += state[0UL];
state[0UL] *= state[0UL];
}
output[0UL] = (state[0UL] - 498160537UL) * (unsigned short)18397;
}
}
void megaInit(void)
{
{
}
}
int main(int argc , char *argv[] )
{
unsigned short input[1] ;
unsigned short output[1] ;
int randomFuns_i5 ;
unsigned short randomFuns_value6 ;
int randomFuns_main_i7 ;
{
megaInit();
if (argc != 2) {
printf("Call this program with %i arguments\n", 1);
exit(-1);
} else {
}
randomFuns_i5 = 0;
while (randomFuns_i5 < 1) {
randomFuns_value6 = (unsigned short )strtoul(argv[randomFuns_i5 + 1], 0, 10);
input[randomFuns_i5] = randomFuns_value6;
randomFuns_i5 ++;
}
RandomFunc(input, output);
if (output[0] == 20319) {
printf("You win!\n");
} else {
}
randomFuns_main_i7 = 0;
while (randomFuns_main_i7 < 1) {
printf("%u\n", output[randomFuns_main_i7]);
randomFuns_main_i7 ++;
}
}
}
|
the_stack_data/125141492.c | /*
Converted to C from Matlab by hand, EW, 4/2000 under name spuriousC.c
command-line args enhanced, EW, 8/2002
Merged with spuriousCfold.c, EW, 8/2002. Now *requires* the ViennaRNA package!
Removed the ViennaRNA dependencies, renamed as spuriousSSM.c, EW & CGE, 2/2015
Also made mutations more efficient and reduced malloc/free load, resulting in 10x speed-up.
Added dg file option for imposing SantaLucia NN energy constraints on specified domains. EW 8/2019
gcc -Wall -O3 spuriousSSM.c -o spuriousSSM -lm
Simple examples:
./spuriousSSM score=automatic template=examples/strands.st wc=examples/strands.wc eq=examples/strands.eq quiet=ALL
./spuriousSSM score=automatic template=examples/trans.st wc=examples/trans.wc eq=examples/trans.eq quiet=ALL
./spuriousSSM score=automatic template=examples/DAO.st wc=examples/DAO.wc eq=examples/DAO.eq quiet=ALL
./spuriousSSM score=automatic template=examples/TAE.st wc=examples/TAE.wc eq=examples/TAE.eq quiet=ALL
./spuriousSSM score=automatic template=examples/Oscillator.st wc=examples/Oscillator.wc eq=examples/Oscillator.eq quiet=ALL
*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#define max(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
// globals:
int debug=0; int quiet=0, watch=1;
double W_verboten=0.0, W_spurious=1.0, W_bonds=0.0;
int W_verboten_set=0, W_spurious_set=0, W_bonds_set=0;
int spurious_intraS_set=0, spurious_interS_set=0, spurious_interC_set=0, bmax_set=0;
int bmult=12;
double spurious_beta=5.0, spurious_intraS=25.0/3125, spurious_interS=5.0/3125, spurious_interC=1.0/3125, spurious_mismatch=25.0;
int spurious_equality=1, spurious_range=6;
double verboten_weak=1.0, verboten_strong=2.0, verboten_regular=0.5;
int N=0,NrS=0,NSt=0,Nwc=0,Neq=0,Ndg=0; // note that many functions assume that their input arrays are length N
int *testwc, *testeq; char *testS, *testSt; int *testdgi, *testdgj; double *testdg,*testdgw;
char *rS_filename=NULL, *St_filename=NULL, *wc_filename=NULL, *eq_filename=NULL, *S_filename=NULL, *dg_filename=NULL;
double temperature=37; // default value unless overwritten by command-line option
int Nfree=0; // number of "independent" base pairs that can be mutated, i.e. i+1 == min (eq[i],wc[i]) and St[i] isn't A, C, G, or T.
int *freeloc; // freeloc[m] is position of m^th such independent base pair (starting at 0)
// WARNING: TREACHEROUS PROGRAMMING CONVENTION:
// wc[i], eq[i], S[i], St[i] are all indexed using 0...(N-1)
// but the values of wc[i] and eq[i] are given using 1...N, as is the case in the input files.
/*------------------------------------------------------------------------*/
/* New random number code. */
unsigned short xsubi[3];
void init_rand(void)
{
FILE *urandom;
urandom = fopen ("/dev/urandom", "r");
setvbuf (urandom, NULL, _IONBF, 0);
xsubi[0] = (fgetc (urandom) << 8) | fgetc (urandom);
xsubi[1] = (fgetc (urandom) << 8) | fgetc (urandom);
xsubi[2] = (fgetc (urandom) << 8) | fgetc (urandom);
fclose (urandom);
}
extern double erand48(unsigned short[]);
double urn(void)
/* uniform random number generator; urn() is in [0,1] */
/* uses a linear congruential library routine */
/* 48 bit arithmetic */
{
return erand48(xsubi);
}
int int_urn(int from, int to)
{
return ( ( (int) (urn()*(to-from+1)) ) + from );
}
/*------------------------------------------------------------------------*/
/*
% ENERGIES OF FORMATION
%
% nearest-neighbor parameters from nnHS.m in DNAdesign
%
% numbers & eqns from SantaLucia, PNAS 1998, 95, 1460--1465
% quoting "unified" params of
% Allawi & SantaLucia, Biochemistry 1997, 36, 10581--10594
%
% nnDH(i,j) gives enthalpy for nearest-neighbor interaction i,j.
% e.g. 1,2 => 5' AC 3' paired with 3' TG 5'.
%
% nnDH = [ AA, AC, AG, AT;
% CA, CC, CG, CT;
% GA, GC, GG, GT;
% TA, TC, TG, TT ]
*/
// using A=1, C=2, G=3, T=4, other=0;
// enthalpy in Kcal/mole
double nnDH[5][5] = { { 0, 0, 0, 0, 0 },
{ 0, -7.9, -8.4, -7.8, -7.2 },
{ 0, -8.5, -8.0,-10.6, -7.8 },
{ 0, -8.2, -9.8, -8.0, -8.4 },
{ 0, -7.2, -8.2, -8.5, -7.9 } };
// entropy in cal/mole
double nnDS[5][5] = { { 0, 0, 0, 0, 0 },
{ 0, -22.2, -22.4, -21.0, -20.4 },
{ 0, -22.7, -19.9, -27.2, -21.0 },
{ 0, -22.2, -24.4, -19.9, -22.4 },
{ 0, -21.3, -22.2, -22.7, -22.2 } };
// free energy
#define nnDG(i,j) (nnDH[i][j] - (temperature+273.15)*nnDS[i][j]/1000.0)
// writes Sorig into S, as a sequence of 1,2,3,4 for A,C,G,T, or 0 if none-of-the-above
void S1234(char *S, char *Sorig)
{
int i;
//% map A,C,G,T to 1,2,3,4
for (i=0; i<N; i++) {
switch (Sorig[i]) {
case 'A': case 'a': case 1: S[i]=1; break;
case 'C': case 'c': case 2: S[i]=2; break;
case 'G': case 'g': case 3: S[i]=3; break;
case 'T': case 't': case 4: S[i]=4; break;
default: S[i]=0;
}
}
}
// --------------------------------------------------------------------------
/*
%function C = spurious(S,kmin,kmax, wc,eq)
% C = spurious(S,kmin,kmax, wc,eq)
%
% S is a sequence of ACTG or 1234 representing the strands in
% several DNA complexes to be used in an experiment.
% Strands are separated by ' ' or 0; the strands in separate
% complexes are separated by ' ' or 0 0.
%
% eq(i) gives the index of the least base i must be equal to
% A 0 indicates that no bases must be equal by design
% wc(i) gives the index of the least base i must be complementary to
% A -1 indicates that no base pairing is designed
%
% makes a table Cik where 1 <= i <= 3 (intramolec,intracomplex,intercomplex)
% and kmin <= k <= kmax. Cik gives the number of undesired WC subsequences
% of length k which match another subsequence exactly...
% i=1 intramolecular (same strand)
% i=2 intermolecular intracomplex (different strand, same complex)
% i=3 intermolecular intercomplex (different strand, different complex)
% Note: counts palindromes, also self-overlapping matches
%
% This is meant to be a fast fn when compiled, esp. for large S.
%
% DNAdesign-0.02 Erik Winfree
*/
/*
allocates 3 x (kmax-kmin+1) vector [intram 1..n, intrac 1..n, interc 1..n]
if wc==NULL or eq==NULL, behaves as spurious0.
if mismatch==1, behaves as spurious1. i.e. counts almost-matches containing a single mismatch, ignores wc & eq.
if spurious_equality==1, then it also counts identity matches, not just WC matches. (only for mismatch==0)
*/
int *spurious(int mismatch, char *Sorig, int kmin, int kmax, int *wc, int *eq)
{
int *C; char *S,*Swc;
int i, imax = (kmax-kmin+1);
int k,j;
// this code could be improved by making storage static, rather than malloc'ing it at every invocation
C = calloc(3*imax, sizeof(int)); if (C==NULL) return NULL;
for (i=0; i<3*imax; i++) C[i] = 0;
S = malloc(N); if (S ==NULL) { free(C); return NULL; }
Swc = malloc(N); if (Swc==NULL) { free(C); free(S); return NULL; }
S1234(S,Sorig);
for (i=0; i<N; i++) { //% WC bases, same order
if (S[i]==0) Swc[i]=0; else Swc[i]=5-S[i];
}
for (k=kmin; k<=kmax; k++) {
int M, *P, *p, Cs, Ss, m, mWC;
M = 1<<(2*k); //% 4^k;
P = calloc(M,sizeof(int)); //% hold index of most-recently-found instance of subsequence m
p = calloc(N,sizeof(int)); //% holds pointers to previous instance of subsequence at i
Cs = 0; //% the start of most recent complex
Ss = 0; //% the start of most recent strand
m = 0; //% the ID of current subsequence
mWC = 0; //% the ID for this subsequence's WC complement
for (i=1; i<=N; i++) { // i indexes character position in the sequence string, starting at 1
if ( S[i-1] == 0 ) { // reset strand & complex indicators
Ss = i; m=0; mWC = 0;
if ( i>1 && S[i-1 -1] == 0 ) Cs = i;
} else {
m = ( 4*m + S[i-1]-1 ) % M;
mWC = (mWC/4) + (Swc[i-1]-1)*M/4;
if (i-Ss >= k && mismatch==0) {
p[i-1]=P[m]; P[m]=i; //% add site to list of subsequences
j=P[mWC]; //% look for previous WC occurrences, including self
while (j != 0) { int msum,jjj;
if (wc != NULL && eq != NULL) { //% exclude expected WC match
for (msum = 0, jjj=0; jjj<k; jjj++)
if (wc[i-k+1 +jjj-1] == eq[j -jjj-1]) msum++;
} else msum=0;
if (msum != k) {
if (j>Ss) C[ k-kmin+1 -1]++;
if (j>Cs) C[imax +k-kmin+1 -1]++;
C[2*imax+k-kmin+1 -1]++;
}
j = p[j -1];
} // previous WC occurrences
if (spurious_equality) {
j=p[i-1]; //% look for previous equality occurrences, not including self
while (j != 0) { int msum,jjj;
if (wc != NULL && eq != NULL) { //% exclude expected EQ match
for (msum = 0, jjj=0; jjj<k; jjj++)
if (eq[i -jjj-1] == eq[j -jjj-1]) msum++;
} else msum=0;
if (msum != k) {
if (j>Ss) C[ k-kmin+1 -1]++;
if (j>Cs) C[imax +k-kmin+1 -1]++;
C[2*imax+k-kmin+1 -1]++;
}
j = p[j -1];
}
} // previous EQ occurrences
}
if (i-Ss >= k && mismatch==1) { int nt, bp, misWC;
for (nt=2; nt<=k-1; nt++) { //% where is mismatch
//% misWC = mWC - 4^(nt-1) * rem(fix(mWC/4^(nt-1)),4);
misWC = mWC & (-1 - (3<<(2*nt-2)));
for (bp=0; bp<4; bp++) { //% what is value at mismatch
misWC += bp<<(2*nt-2);
j=P[misWC]; //% look for previous occurrences, including self
while (j != 0 && misWC != mWC) { //% count all mismatches only
if (j>Ss) C[ k-kmin+1 -1]++;
if (j>Cs) C[imax +k-kmin+1 -1]++;
C[2*imax+k-kmin+1 -1]++;
j = p[j -1];
}
if (m==misWC && m!=mWC) { //% "palindrome-with-mismatch"
C[ k-kmin+1 -1]++;
C[imax +k-kmin+1 -1]++;
C[2*imax+k-kmin+1 -1]++;
}
misWC -= bp<<(2*nt-2);
}
}
p[i -1]=P[m]; P[m]=i; //% add this site to list of subsequences
}
}
}
C[2*imax+k-kmin+1 -1] = C[2*imax+k-kmin+1 -1] - C[imax+k-kmin+1 -1];
C[ imax+k-kmin+1 -1] = C[ imax+k-kmin+1 -1] - C[ k-kmin+1 -1];
free(p); free(P);
}
free(S); free(Swc);
return C;
}
// --------------------------------------------------------------------------
// c MUST BE UPPERCASE ACGT & degenerate bases
char WC(char c)
{
switch(c) {
case 'A': return 'T';
case 'C': return 'G';
case 'G': return 'C';
case 'T': return 'A';
case 'R': return 'Y';
case 'Y': return 'R';
case 'W': return 'W';
case 'S': return 'S';
case 'K': return 'M';
case 'M': return 'K';
case 'B': return 'V';
case 'V': return 'B';
case 'D': return 'H';
case 'H': return 'D';
case 'N': return 'N';
default: return ' ';
}
}
// modifies S. S MUST BE UPPERCASE ACGT & degenerate bases
void WCstring(char *S)
{
int i,n; n=strlen(S);
for (i=0; i<n; i++) { S[i]=WC(S[i]); }
}
// --------------------------------------------------------------------------
char degenerates[96] = "AA CC GG TT RA RG YC YT WA WT SC SG MA MC KG KT BC BG BT DA DG DT HA HC HT VA VC VG NA NC NG NT";
int test_consistency(char *S, char *St, int *wc, int *eq)
{
int i, OK=1;
// load_input_files guarantees that all arrays are length N
// test conditions that must hold if wc and eq are correctly defined
for (i=0; i<N; i++) {
if (wc[i] != -1 && wc[wc[i]-1] != eq[i]) {
fprintf(stderr,"ERROR: wc[wc[%d]] != eq[%d]\n",i+1,i+1); OK=0;
}
if (eq[i] != 0 && eq[eq[i]-1] != eq[i]) {
fprintf(stderr,"ERROR: eq[eq[%d]] != eq[%d]\n",i+1,i+1); OK=0;
}
}
if (!OK) return 0;
// now, check that S satisfies St and wc and eq.
for (i=0; i<N; i++) {
char pair[3];
pair[0]=St[i]; pair[1]=S[i]; pair[2]=0; // template:sequence pair for testing compatibility
if (S[i] != ' ' && strstr(degenerates,pair)==NULL) {
fprintf(stderr,"ERROR: sequence S[%d]=%c is not compatible with template St[%d]=%c \n",i+1,S[i],i+1,St[i]); OK=0;
}
if (wc[i] != -1 && S[i] != WC(S[wc[i]-1])) {
fprintf(stderr,"ERROR: sequence S[%d]=%c should be WC to S[%d]=%c \n",i+1,S[i],wc[i],S[wc[i]]); OK=0;
}
if (eq[i] != 0 && S[i] != S[eq[i]-1]) {
fprintf(stderr,"ERROR: sequence S[%d]=%c should be equal to S[%d]=%c \n",i+1,S[i],eq[i],S[eq[i]]); OK=0;
}
}
// now, check that St satisfies wc and eq.
for (i=0; i<N; i++) {
if (wc[i] != -1 && St[i] != WC(St[wc[i]-1])) {
fprintf(stderr,"ERROR: template St[%d]=%c should be WC to St[%d]=%c \n",i+1,St[i],wc[i],St[wc[i]]); OK=0;
}
if (eq[i] != 0 && St[i] != St[eq[i]-1]) {
fprintf(stderr,"ERROR: template St[%d]=%c should be equal to St[%d]=%c \n",i+1,St[i],eq[i],St[eq[i]]); OK=0;
}
}
return OK;
}
/*
% function S = constrain(rS, wc, eq)
% S = constrain(rS, wc, eq)
%
% rS is the raw sequence of 'ACGT ';
% bases that should be WC or equal might not be.
% wc and eq are as built by constraints().
%
% S is rS, but with each equivalence class's rep's bases used to
% determine the entire class and its WC class,
% so now wc and eq are obeyed.
%
% DNAdesign-0.02 Erik Winfree
*/
/*
modifies S. S MUST BE UPPERCASE ACGT & degenerate bases
*/
void constrain(char *S, int *wc, int *eq)
{
int i,j; int *marked;
marked = (int *) calloc(N, sizeof(int));
for (i=0; i<N; i++) {
if (!marked[i]) {
// class = find(eq==eq(i));
// for j=1:length(class), S(class(j))=S(i); end
// marked(class)=1;
for (j=0; j<N; j++) {
if (eq[j] == eq[i]) { S[j] = S[i]; marked[j]=1; }
}
// class = find(eq==wc(i));
// for j=1:length(class), S(class(j))=WC(S(i)); end
// marked(class)=1;
for (j=0; j<N; j++) {
if (eq[j] == wc[i]) { S[j] = WC(S[i]); marked[j]=1; }
}
}
}
free(marked);
}
void constrain_single_fast(char *S, int *wc, int *eq, int i)
{
int j;
for (j=i+1; j<N; j++) {
if (eq[j] == eq[i]) { S[j] = S[i];}
}
for (j=i+1; j<N; j++) {
if (eq[j] == wc[i]) { S[j] = WC(S[i]); }
}
}
// --------------------------------------------------------------------------
/*
% function bad6mer = make_bad6mer()
% bad6mer = make_bad6mer()
%
% Make a table of costs for "verboten" 6-base subsequences.
% The costs are just made up... vaguely based on rules of thumb
% such as "don't have 3 Gs in a row"... "avoid many purines in
% a row; you might get a triple helix"..."don't have long AT runs"...
% etc... Some may by myths or mistakes.
%
% DNAdesign-0.02 Erik Winfree
*/
// This was the old DNAdesign and spuriousC scoring. See help info for revised spuriousSSm scoring that is actually implemented below.
// " the sum over all 6-nucleotide windows of:\n"
// " how many of these patterns match the window: WWWWWW, SSSSSS, RRRRRR, YYYYYY, RYRYRY, YRYRYRYR, SWWWWW, WWWWWS, SSSSSW, WSSSSS\n"
// " + how many substrings appear in the window: GGG, GGGG, CCC, CCCC, TTTT, AAAA, GCGC, GGCC, CCGG, CGCG\n"
// " + 0.1 * (there are 4 or more W bases in the window).\n"
double bad6mer[1<<12];
void make_bad6mer()
{
char S[7]; char ACGT[5]=" ACGT";
int i,j, b1,b2,b3,b4,b5,b6;
int co[5],ce[5],c[5];
for (i=0; i < (1<<12); i++) bad6mer[i] = 0.0;
i=0;
for (b1=1; b1<=4; b1++)
for (b2=1; b2<=4; b2++)
for (b3=1; b3<=4; b3++)
for (b4=1; b4<=4; b4++)
for (b5=1; b5<=4; b5++)
for (b6=1; b6<=4; b6++) {
S[0]=ACGT[b1]; S[1]=ACGT[b2]; S[2]=ACGT[b3];
S[3]=ACGT[b4]; S[4]=ACGT[b5]; S[5]=ACGT[b6]; S[6]=0;
//% c(i) = how many base type i are present.
//% count c(i) for even & odd positions
for (j=1;j<=4;j++) {co[j]=ce[j]=0;}
co[b1]=co[b1]+1; ce[b2]=ce[b2]+1; co[b3]=co[b3]+1;
ce[b4]=ce[b4]+1; co[b5]=co[b5]+1; ce[b6]=ce[b6]+1;
for (j=1;j<=4;j++) {c[j]=co[j]+ce[j];}
bad6mer[i] = // these penalties have evolved since spuriousC...
verboten_weak * (
(c[2]+c[3]==0) + // all AT
(strstr(S,"TTTT")!=NULL) +
(strstr(S,"AAAA")!=NULL) +
((c[1]+c[4])==5 && (b1==2 || b1==3)) + // 5 AT is weak
((c[1]+c[4])==5 && (b6==2 || b6==3)) + // 5 AT is weak
(c[1]+c[4]>3) // 4 or more AT within 6 is weak
) + verboten_strong * (
(c[1]+c[4]==0) + // all CG
(strstr(S,"GGG")!=NULL) +
1000*(strstr(S,"GGGG")!=NULL) +
(strstr(S,"CCC")!=NULL) +
1000*(strstr(S,"CCCC")!=NULL) +
((c[2]+c[3])==5 && (b1==1 || b1==4)) + // 5 CG is bad
((c[2]+c[3])==5 && (b6==1 || b6==4)) // 5 CG is bad
) + verboten_regular * (
(c[1]+c[3]==0) + // all AG (Pu)
(c[2]+c[4]==0) + // all TC (Py)
(co[1]+co[3]+ce[2]+ce[4]==0) + // alt PuPy
(ce[1]+ce[3]+co[2]+co[4]==0) + // alt PyPu
(strstr(S,"GCGC")!=NULL) +
(strstr(S,"GGCC")!=NULL) +
(strstr(S,"CCGG")!=NULL) +
(strstr(S,"CGCG")!=NULL)
);
i=i+1;
}
}
// --------------------------------------------------------------------------
/*
%function V = verboten(S)
% V = verboten(S)
% counts number of occurrences of to-be-avoided sequences, e.g.
% 6-mers containing GGG GGGG TTTT AAAA CCCC GCGC GGCC CCGG CGCG
% 6-mer tracts of all-AT, all-GC, all-Pu, all-Py, and alternating Pu Py
%
% DNAdesign-0.02 Erik Winfree
*/
// note: could merge with S1234() defined above, which converts entire array
static inline int C1234(char c) // map A,C,G,T to 1,2,3,4
{
int v=0;
switch (c) {
case 'A': case 'a': case 1: v=1; break;
case 'C': case 'c': case 2: v=2; break;
case 'G': case 'g': case 3: v=3; break;
case 'T': case 't': case 4: v=4; break;
default: v=0;
}
return v;
}
double score_verboten(char *S, int *wc, int *eq)
{
int i, K, M, m; double V;
V=0.0; K=5;
M = 1<<12;
m = 0; //% the ID of current subsequence
for (i=0; i<N; i++) {
if (C1234(S[i]) == 0) { //% reset strand & complex indicators
m=0; K=5; //% wait till full 6-mer considered
} else {
m = ( (m<<2) + C1234(S[i])-1 ) & (M-1);
if (K) K=K-1; else V=V+bad6mer[m];
}
}
// printf("verboten('%s')=%f\n\n",S,V);
return V;
}
// optimizing score_spurious performs so poorly on Milo's test;
// Niles & Robert's positive+negative approach is more successful...
// add some element of positive design...
// here, we sum the nearest-neighbor Hbond/stacking energy for
// all desired WC interactions, in Kcal/mole.
double score_bonds(char *S, int *wc, int *eq)
{
double score=0,dG; int i,c;
// for (i=0; i<5; i++)
// { for (N=0; N<5; N++) printf("%4.2f ",nnDH[i][N]); printf("\n"); }
if (dg_filename==NULL) {
for (i=1; i<N; i++)
if (wc[i-1]==wc[i]+1) score += nnDG(C1234(S[i-1]),C1234(S[i]));
return score/2; // every nt involved in WC get counted twice per stack
} else {
for (c=0; c<Ndg; c++) {
dG=0.0;
for (i=testdgi[c]; i<testdgj[c]; i++)
if (eq[i]!=0 && eq[i+1]!=0) dG += nnDG(C1234(S[i]),C1234(S[i+1]));
score += (dG-testdg[c])*(dG-testdg[c])*testdgw[c];
}
return score;
}
}
// --------------------------------------------------------------------------
/*
% 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0=space
% degenerates: A C G T R Y W S M K B D H V N
% AG CT AT CG AC GT CGT AGT ACT ACG ACGT
*/
char randbasec(char Stc)
{
char *choices;
switch(Stc) {
case 'A': choices = "A"; break;
case 'C': choices = "C"; break;
case 'G': choices = "G"; break;
case 'T': choices = "T"; break;
case 'R': choices = "AG"; break;
case 'Y': choices = "CT"; break;
case 'W': choices = "AT"; break;
case 'S': choices = "CG"; break;
case 'M': choices = "AC"; break;
case 'K': choices = "GT"; break;
case 'B': choices = "CGT"; break;
case 'D': choices = "AGT"; break;
case 'H': choices = "ACT"; break;
case 'V': choices = "ACG"; break;
case 'N': choices = "ACGT"; break;
default: choices = " ";
}
return choices[ int_urn(0,strlen(choices)-1) ];
}
// make a single random change, apply the constrains, and insist that the change wasn't eliminated.
// doesn't make sense to call this if Nfree==0, in which case no mutation is made.
void mutate(char *S, char *St, int *wc, int *eq)
{
int i; char oldc;
if (Nfree==0) return;
i = freeloc[int_urn(0,Nfree-1)];
oldc = S[i];
do {
S[i] = randbasec(St[i]);
} while (oldc == S[i]);
constrain_single_fast(S,wc,eq,i);
}
// --------------------------------------------------------------------------
int set_auto_spurious_weights(char *S, int *wc, int *eq) // returns bmax value
{
// n_i are strand lengths; c are complexes, sets of strands
// weight for length-k intra-strand bindings is beta^(k-k0) where k0 = log_4 (max_i n_i)
// weight for length-k inter-strand intra-complex bindings is beta^(k-k1) where k1 = log_4 (max_c sum_{i in c} n_i)
// weight for length-k inter-complex bindings is beta^(k-k2) where k2 = log_4 (sum_i n_i)
// the idea here being that k0, k1, k2 represent the total number of unique subsequences needed
int i, n, nq=0, nk0=0, nk1=0, nk2=0, ni=0, nc=0, nbp=0;
i=0; while (S[i]!=0) {
if (S[i] != ' ') { nk2++; ni++; nc++; nk0=max(nk0,ni); nk1=max(nk1,nc); }
if (S[i] == ' ') { ni=0; }
if (S[i] == ' ' && i>0 && S[i-1] == ' ') { nc=0; }
i++;
}
if (!spurious_intraS_set) spurious_intraS = pow(spurious_beta,0.0-log2(1.0*nk0)/2);
if (!spurious_interS_set) spurious_interS = pow(spurious_beta,0.0-log2(1.0*nk1)/2);
if (!spurious_interC_set) spurious_interC = pow(spurious_beta,0.0-log2(1.0*nk2)/2);
if (!W_spurious_set) W_spurious = 1.0; // logic: expect a score of about 1.0 for each subcategory
if (!W_verboten_set) W_verboten = 640.0 / nk2; // logic: three-letter verboten sequences occur once/64, so "typical" score should be 10.
for (i=1; i<N; i++) if (wc[i-1]==wc[i]+1) nbp++; // count number of defined base-pairs
if (!quiet) printf("Automatic: counted %d base-pairing stacks in target structures.\n",nbp);
if (nbp==0) nbp++;
if (!W_bonds_set) W_bonds = 10.0/nbp; // logic: each stack varies from about 1.0 to 2.0 kcal/mol, so let's go for "typical" score 10.
// count number of unique base equivalent classes
n=strlen(S); for (i=0; i<n; i++) if (eq[i]==i+1 && (wc[i]>i+1 || wc[i]==-1)) nq++;
if (!quiet) printf("Automatic: counted %d unique base equivalence classes.\n",nq);
return (bmult*nq+1); // get bored after 4-fold coverage of all possible single mutations
}
// scoring function from score_spurious.m in DNAdesign
double score_spurious(char *S, int *wc, int *eq)
{
// prefactors = [5^(-4) 5^(-5) 5^(-6)]; % most weight to intramolecular
// S0 = prefactors * (spurious(S, 3,8, wc,eq) * cumprod(5*ones(1,6))') ;
// S1 = prefactors * (spurious1(S, 5,10) * cumprod(5*ones(1,6))') ;
double *factors;
int *C; double score=0.0; int i, imax=3*spurious_range;
factors = (double *) malloc(imax*sizeof(double)); // typically spurious_range=6 and there are 18 factors.
for (i=0; i<imax; i++) factors[i]=0.0;
factors[0*spurious_range] = spurious_intraS; for (i=1; i<spurious_range; i++) factors[i] = factors[i-1] *spurious_beta;
factors[1*spurious_range] = spurious_interS; for (i=1; i<spurious_range; i++) factors[i+1*spurious_range] = factors[i-1+1*spurious_range] *spurious_beta;
factors[2*spurious_range] = spurious_interC; for (i=1; i<spurious_range; i++) factors[i+2*spurious_range] = factors[i-1+2*spurious_range] *spurious_beta;
C = spurious(0,S,3,2+spurious_range,wc,eq);
for (i=0; i<imax; i++) score+=factors[i]*C[i];
free(C);
C = spurious(1,S,5,4+spurious_range,NULL,NULL);
for (i=0; i<imax; i++) score+=factors[i]*C[i]*spurious_mismatch/spurious_beta/spurious_beta;
free(C);
free(factors);
return score;
}
// --------------------------------------------------------------------------
int num_strands(char *rS) // count number of strings
{
char *S,*s,n=0; S=rS;
while (*S != 0) {
if ((s=strchr(S,' ')) != NULL) {
if (s!=S) n=n+1;
S = s+1;
} else {
n=n+1;
S=rS+strlen(rS);
}
}
return n;
}
double score_all(char *rS, int *wc, int *eq)
{
double V=0.0, Spu=0.0, Bnd=0.0;
if (W_verboten>0) V = score_verboten(rS,wc,eq);
if (W_spurious>0) Spu = score_spurious(rS,wc,eq);
if (W_bonds>0) Bnd = score_bonds(rS,wc,eq);
return W_verboten*V + W_spurious*Spu + W_bonds*Bnd;
}
// --------------------------------------------------------------------
void test_evals(char *testS, int *testwc, int *testeq)
{
int *C; int i,k; double V=0, Spu=0, Bnd=0;
int sh = (quiet==0 && watch==0);
printf("\n");
if (W_spurious>0) {
C = spurious(0, testS, 3,2+spurious_range, testwc, testeq);
if (spurious_equality) printf("spurious counts identity matches as well as WC matches.\n");
else printf("spurious counts WC matches but not identity matches.\n");
printf("spurious(testS, 3,%d, testwc, testeq)\n",2+spurious_range);
printf("C = \n");
for (i=0;i<3;i++) {
for (k=3; k<=2+spurious_range; k++) {
printf(" %5d", C[i*spurious_range + k-3]);
}
printf("\n");
}
free(C);
C = spurious(0, testS, 3,2+spurious_range, NULL, NULL);
printf("spurious0(testS, 3,%d)\n",2+spurious_range);
printf("C0 = \n");
for (i=0;i<3;i++) {
for (k=3; k<=2+spurious_range; k++) {
printf(" %5d", C[i*spurious_range + k-3]);
}
printf("\n");
}
free(C);
C = spurious(1, testS, 5,4+spurious_range, NULL, NULL);
printf("spurious1(testS, 5,%d)\n",4+spurious_range);
printf("C1 = \n");
for (i=0;i<3;i++) {
for (k=5; k<=4+spurious_range; k++) {
printf(" %5d", C[i*spurious_range + k-5]);
}
printf("\n");
}
free(C);
printf("spurious: intraS = %11.5f, interS = %11.5f, interC = %11.5f, beta = %5.3f, mismatch = %5.3f\n",
spurious_intraS, spurious_interS, spurious_interC, spurious_beta, spurious_mismatch);
}
if (W_verboten>0) printf("verboten: weak = %11.5f, strong = %11.5f, regular = %11.5f\n", verboten_weak, verboten_strong, verboten_regular);
if (sh || W_verboten>0) printf("** score_verboten score = %11.5f \n", V=score_verboten(testS,testwc,testeq) );
if (sh || W_spurious>0) printf("** score_spurious score = %11.5f \n", Spu=score_spurious(testS,testwc,testeq) );
if (sh || W_bonds>0) printf("** score_bonds score = %11.5f \n", Bnd=score_bonds(testS,testwc,testeq) );
printf("** [verboten spurious bonds] = [%11.5f %11.5f %11.5f]-weighted score = %11.5f \n",
W_verboten, W_spurious, W_bonds,
W_verboten*V + W_spurious*Spu + W_bonds*Bnd);
printf("\n\n");
}
// -------------------------------------------------------------------------
long int get_file_length(char *name)
{
FILE *fp;
int len;
if (name==NULL) return 0;
fp = fopen(name, "r");
if( fp == NULL ) {
fprintf(stderr,"Error opening file %s.", name); exit(-1);
}
fseek(fp, 0, SEEK_END);
len = ftell(fp);
fclose(fp);
return len;
}
void load_input_files()
{ FILE *f; char c; int i,j; double r,s; int maxN;
//// Note: we strip off trailing ' ' from rS and St,
//// and delete corresponding entries in wc and eq
//// but YELL if any deleted entries are not -1 or 0 respectively.
maxN = 100+get_file_length(rS_filename);
testS = malloc(maxN);
if (rS_filename!=NULL) {
if ( (f = fopen(rS_filename,"r")) == NULL ) {
fprintf(stderr,"Can't open rS file <%s>\n",rS_filename); exit(-1);
} else {
while ((c = fgetc(f)) != EOF)
if (index("ATCGatcg ",c)!=NULL) testS[NrS++]=c;
testS[NrS]=0;
if (debug) printf("S = <%s>\n",testS);
NrS = strlen(testS);
while (testS[NrS-1]==' ' && NrS>0) { NrS--; testS[NrS]=0; }
fclose(f);
}
}
maxN = 100+get_file_length(St_filename);
testSt = malloc(maxN);
if (St_filename!=NULL) {
if ( (f = fopen(St_filename,"r")) == NULL ) {
fprintf(stderr,"Can't open St file <%s>\n",St_filename); exit(-1);
} else {
while ((c = fgetc(f)) != EOF)
if (index("ATCGatcgRYWSMKBDHVNrywsmkbdhvn ",c)!=NULL) testSt[NSt++]=c;
testSt[NSt]=0;
if (debug) printf("St = <%s>\n",testSt);
NSt = strlen(testSt);
while (testSt[NSt-1]==' ' && NSt>0) { NSt--; testSt[NSt]=0; }
fclose(f);
}
}
maxN = 100+get_file_length(wc_filename);
testwc = calloc(maxN, sizeof(int)); // plenty of space, since ints take more than 1 char
if (wc_filename!=NULL) {
if ( (f = fopen(wc_filename,"r")) == NULL ) {
fprintf(stderr,"Can't open wc file <%s>\n",wc_filename); exit(-1);
} else {
// for (i=0; i<N; i++) { fscanf(f," %lf",&r); testwc[i]=r; }
while (fscanf(f," %lf",&r)>0) testwc[Nwc++]=r;
if (debug) {
printf("wc = <");
for (i=0; i<Nwc; i++) { printf("%d ", testwc[i]); }
printf("> \n");
}
for (i=0; i<Nwc; i++) if (testwc[i]==0 || testwc[i]<-1)
{ fprintf(stderr,"error at position %d : value %d isn't allowed in wc\n", i+1, testwc[i]); exit(-1); }
fclose(f);
}
}
maxN = 100+get_file_length(eq_filename);
testeq = calloc(maxN, sizeof(int)); // plenty of space, since ints take more than 1 char
if (eq_filename!=NULL) {
if ( (f = fopen(eq_filename,"r")) == NULL ) {
fprintf(stderr,"Can't open eq file <%s>\n",eq_filename); exit(-1);
} else {
// for (i=0; i<N; i++) { fscanf(f,"%lf",&r); testeq[i]=r; }
while (fscanf(f," %lf",&r)>0) testeq[Neq++]=r;
if (debug) {
printf("eq = <");
for (i=0; i<Neq; i++) { printf("%d ", testeq[i]); }
printf("> \n");
}
while (testeq[Neq-1]==0 && Neq>0) Neq--;
for (i=0; i<Neq; i++) if (testeq[i]<0)
{ fprintf(stderr,"error at position %d : value %d isn't allowed in eq\n", i+1, testeq[i]); exit(-1); }
fclose(f);
}
}
while (Nwc > MAX(Neq,MAX(NrS,NSt)) && MAX(Neq,MAX(NrS,NSt))>0) {
if (testwc[Nwc-1]==-1) Nwc--;
else {
fprintf(stderr,"wc(%d) is longer than sequence(%d)/template(%d)/eq(%d), with non-empty entries!!\n",Nwc,NrS,NSt,Neq);
exit(-1);
}
}
N=MAX(N,MAX(MAX(NrS,NSt),MAX(Neq,Nwc)));
if (N==0) {
fprintf(stderr,"Zero-length sequence. Aborting. Try --help. \n");
exit(-1);
}
// set default array values for rS, St, wc, eq
if (St_filename==NULL) {
free(testSt); testSt = malloc(N+100);
NSt=N; for (i=0; i<N; i++) testSt[i]='N'; testSt[N]=0;
if (debug) { fprintf(stderr,"St = <"); for (i=0; i<NSt; i++) fprintf(stderr,"%c",testSt[i]); fprintf(stderr,">\n"); }
}
if (rS_filename==NULL) {
free(testS); testS = malloc(N+100);
NrS=NSt; for (i=0; i<NrS; i++) testS[i]=randbasec(testSt[i]); testS[NrS]=0;
if (debug) { fprintf(stderr,"S = <"); for (i=0; i<NrS; i++) fprintf(stderr,"%c",testS[i]); fprintf(stderr,">\n"); }
}
if (wc_filename==NULL) {
free(testwc); testwc = calloc(N+100, sizeof(int));
Nwc=N; for (i=0; i<N; i++) testwc[i]=-1;
if (debug) { fprintf(stderr,"wc = <"); for (i=0; i<Nwc; i++) fprintf(stderr,"%d ",testwc[i]); fprintf(stderr,">\n"); }
}
if (eq_filename==NULL) {
free(testeq); testeq = calloc(N+100, sizeof(int));
Neq=N; for (i=0; i<N; i++) testeq[i]=(testS[i]==' ')?0:(i+1);
if (debug) { fprintf(stderr,"eq = <"); for (i=0; i<Neq; i++) fprintf(stderr,"%d ",testeq[i]); fprintf(stderr,">\n"); }
}
if (N != NrS)
{ fprintf(stderr,"rS is not max length, %d!!!\n",N); exit(-1); }
if (N != NSt)
{ fprintf(stderr,"St is not max length, %d!!!\n",N); exit(-1); }
if (N != Nwc)
{ fprintf(stderr,"wc is not max length, %d!!!\n",N); exit(-1); }
if (N != Neq)
{ fprintf(stderr,"eq is not max length, %d!!!\n",N); exit(-1); }
// make corrections to defaults for ' ' separators
for (i=0; i<N; i++)
if (testSt[i]==' ' || testS[i]==' ' || testeq[i]==0)
{ testSt[i]=' '; testS[i]=' '; testeq[i]=0; testwc[i]=-1; }
for (i=0; i<N; i++) if (testeq[i]==0 && testS[i]!=' ')
{ fprintf(stderr,"error at position %d : eq can be 0 only in space between strands\n",i+1); exit(-1); }
// load target dG for specified domains, if dg file given
if (dg_filename!=NULL) {
maxN = 100+get_file_length(dg_filename); // number of characters > number of lines. excessive here but OK.
testdgi = calloc(maxN, sizeof(int));
testdgj = calloc(maxN, sizeof(int));
testdg = calloc(maxN, sizeof(double));
testdgw = calloc(maxN, sizeof(double));
if ( (f = fopen(dg_filename,"r")) == NULL ) {
fprintf(stderr,"Can't open dg file <%s>\n",dg_filename); exit(-1);
} else {
while (fscanf(f," %d %d %lf %lf",&i,&j,&r,&s)>0) {
testdgi[Ndg]=i; testdgj[Ndg]=j; testdg[Ndg]=r; testdgw[Ndg]=s; Ndg++;
if ( (i>=N) || (j >=N) || (i>=j) )
{ fprintf(stderr,"bond energy domain indices %d through %d out of bounds for sequence length %d\n",i,j,N); exit(-1); }
}
if (debug) {
printf("dg = %d constraints = < \n",Ndg);
for (i=0; i<Ndg; i++) { printf(" %5d through %5d : %7.2g kcal/mol (weight %g)\n", testdgi[i],testdgj[i],testdg[i],testdgw[i]); }
printf("> \n");
}
fclose(f);
}
}
}
// -------------------------------------------------------------------------
int main(int argc, char *argv[])
{
int i; FILE *f;
time_t t_start,t_now,tmax=0; int imax=0; int bored, bmax=0; int automatic=0;
int fancy_args=1, trace=0;
// do we have fancy args or simple args?
for (i=1;i<argc;i++) {
if (index(argv[i],'=')==NULL) fancy_args=0;
}
if (!fancy_args && argc != 5) {
fprintf(stderr,"Two command line formats are accepted for spuriousSSM:\n");
fprintf(stderr," spuriousSSM rS_file St_file wc_file eq_file\n");
fprintf(stderr,"or\n");
fprintf(stderr," spuriousSSM [option]*\n");
fprintf(stderr,"where the options are:\n"
" INPUT/OUTPUT\n"
" sequence=[file] for initial nucleotide sequence (rS_file) [default: random]\n"
" template=[file] for allowed nucleotides at each position (St_file) [default: all N]\n"
" wc=[file] for Watson-Crick pairing constraints (wc_file) [default: all -1]\n"
" eq=[file] for equality constraints (eq_file) [default: identity]\n"
" dg=[file] for list of specific bond strength constraints [default: bond score]\n"
" output=[filename] for final output sequence upon completion [default: stdout]\n"
" N=[value] length of sequence, if no files are specified\n"
" quiet=TRUE don't print anything, except errors & output\n"
" quiet=SCORES output intial & final test scores, for all relevant score methods\n"
" quiet=WATCH output running tally of best test scores, for chosen method\n"
" quiet=ALL output all the above [default]\n"
" trace=ON output the current sequence, at every improvement\n"
" STOPPING CRITERIA (default is bmult=12)\n"
" tmax=[value] stop after specified time (in seconds) has elapsed\n"
" imax=[value] stop after specified number of mutation iterations have been completed\n"
" bmax=[value] stop after specified number of mutation iterations yield no change\n"
" bmult=[value] set bmax=[value]*[number of unique base equivalence classes] (integer)\n"
" SCORING FUNCTION\n"
" score=automatic set stopping criteria and spurious, verboten, and bonds score weights based on design size\n"
" score=noautomatic reset any previous score=automatic option that has been provided.\n"
" score=[verboten|spurious|bonds] what scoring function to use [default: spurious]\n"
" verboten: penalizes use of subsquences such as GGG, AAAA, WWWWWW, PuPyPuPyPuPy\n"
" spurious: penalizes pairs of undesired exact WC matches of lengths 3-8 (and 1-mm of lengths 5-10)\n"
" bonds: prefers strong nearest-neighbor stacking energies for designed helices\n"
" setting 'score=xxx' is shorthand for 'W_xxx=1.0' and other weights 0.0; this can be further adjusted...\n"
" W_verboten=[value] weight for verboten score [default: 0.0]\n"
" W_spurious=[value] weight for spurious score [default: 1.0]\n"
" W_bonds=[value] weight for bonds score [default: 0.0]\n"
" spurious_beta=[value] multiplicative penalty, per match base pair [default: 5.0]\n"
" spurious_intraS=[value] initial penalty, intra-strand matches [default: 1/125]\n"
" spurious_interS=[value] initial penalty, inter-strand matches [default: 1/625]\n"
" spurious_interC=[value] initial penalty, inter-complex matches [default: 1/3125]\n"
" spurious_mismatch=[value] mismatch penalty [default: 25]\n"
" spurious_range=[value] number of values of k (match length) tested [default: 6]\n"
" spurious_equality=[0|1] penalize identity matches, not just WC complementary matches [default: 1]\n"
" verboten_weak=[value] multiplicative penalty for weak subsequences [default: 1.0]\n"
" verboten_strong=[value] multiplicative penalty for strong subsequences [default: 2.0]\n"
" verboten_regular=[value] multiplicative penalty for regular subsequences [default: 0.5]\n"
" temperature=[value] temperature in Celsius for bond energy calculations [default: 37]\n"
"\n"
"Notes:\n\n"
"sequence is in { A C G T }*\n\n"
"template is in { A C G T R Y W S M K B D H V N }*\n"
" meaning A C G T AG CT AT CG AC GT CGT AGT ACT ACG ACGT \n\n"
" spaces indicate strand (' ') and complex (' ') boundaries\n\n"
"The eq() and wc() arrays are lists of integers, indexes into the sequence string, starting at 1. \n"
" eq(i) is the min of all bases constrained to have the same value as i (' ' bases have eq(i)==0).\n"
" wc(i) is the min of all bases constrained to be complementary to i (or -1 if there are none).\n"
"Strand id's are numbered starting at 1.\n\n"
"It is the responsibility of the user to ensure that indirect implications of wc() and eq() are considered, \n"
" e.g. the complement of a complement should be considered equal, and that equality is transitive.\n"
" If wc() and eq() do not uphold these properties, odd things might happen. Beware.\n"
"\n"
"The spurious score:\n"
"In the table C = spurious(S, kmin, kmax, wc, eq)\n"
" where 1 <= i <= 3 (intramolec, intracomplex, intercomplex match) \n"
" and kmin <= k <= kmax (match length), \n"
"C(i,k) gives the number of undesired WC subsequences of length k \n"
" that match another subsequence exactly or are exactly complementary [modulated by spurious_equality], \n"
" where we exclude matches that are fully implied by the wc() and eq() inputs \n"
" and we count self-complementary as well as self-overlapping matches; \n"
" matches are divided according to how ''local'' the match is: \n"
" i=1 intramolecular (same strand) matches \n"
" i=2 intermolecular intracomplex (different strand, same complex) matches \n"
" i=3 intermolecular intercomplex (different strand, different complex) matches \n"
"The related table C0 = spurious0(S, kmin, kmax)\n"
" provides the same information, but doesn't exclude matches that are implied by wc() and eq().\n"
" This table is not used in scoring, but printed as information potentially useful to the user.\n"
"The related table C1 = spurious1(S, kmin, kmax)\n"
" provides similar information, but only counts matches that have exactly 1 mismatch.\n"
" Bulges (e.g. resulting from insertions or deletions) are not considered.\n"
"The spurious score is:\n"
" sum_{i in 1=intraS...3=interC},{k in 3..8} C(i,k) * beta^(k-3) * spurious_i\n"
" + sum_{i in 1=intraS...3=interC},{k in 5..10} C1(i,k) * beta^(k-5) * spurious_i * spurious_mismatch\n"
"The upper value for k will increase or decrease if spurious_range is changed from its default value of 6.\n"
"\n"
"The verboten score is:\n"
" the sum over all 6-nucleotide windows, of penalties for whether the window\n"
" exactly matches certain patterns, contains certain substrings, or has certain base counts: \n"
" verboten_weak * ( #match of {WWWWWW, SWWWWW, WWWWWS} + #contained of {TTTT, AAAA} + #if {has 4 or more W bases} ) + \n"
" verboten_strong * ( #match of {SSSSSS, SSSSSW, WSSSSS} + #contained of {GGG, GGGG, CCC, CCCC} ) + \n"
" verboten_regular * ( #match of {RRRRRR, YYYYYY, RYRYRY, YRYRYR} + #contained of {GCGC, GGCC, CCGG, CGCG} ) \n"
" where the GGGG and CCCC matches are multiplied by 1000 to ensure those sequences are eliminated. \n"
"\n"
"The bonds score is:\n"
" the sum over all base-pair stacks, according to wc(), of the SantaLucia 1998 nearest-neighbor free energy.\n"
" Uses the temperature parameter and dG = dH - T dS; stronger bonding gives more negative values, i.e. improves the score.\n"
" If a *.dg file is specified, with each line of form 'i j dG w' specifying the target dG for nucleotides i to j,\n"
" then the sum of squared errors from the target, times weights w, is used instead. (Nucleotide indices are 0-offset.)\n"
"\n"
"The overall score is W_spurious * score_spurious + W_verboten * score_verboten + W_bonds * score_bonds.\n\n"
" Thus, weighted combinations of scoring functions can be specified using the 'W_*' parameters.\n");
exit(-1);
}
init_rand();
if (fancy_args) {
// try to parse fancy args
for (i=1;i<argc;i++) {
if (strncmp(argv[i],"sequence=",9)==0) rS_filename=&argv[i][9];
else if (strncmp(argv[i],"template=",9)==0) St_filename=&argv[i][9];
else if (strncmp(argv[i],"wc=",3)==0) wc_filename=&argv[i][3];
else if (strncmp(argv[i],"eq=",3)==0) eq_filename=&argv[i][3];
else if (strncmp(argv[i],"dg=",3)==0) dg_filename=&argv[i][3];
else if (strncmp(argv[i],"output=",7)==0) S_filename=&argv[i][7];
else if (strncmp(argv[i],"N=",2)==0) N=atoi(&argv[i][2]);
else if (strncmp(argv[i],"tmax=",5)==0) tmax=atoi(&argv[i][5]);
else if (strncmp(argv[i],"imax=",5)==0) imax=atoi(&argv[i][5]);
else if (strncmp(argv[i],"bored=",6)==0) {bmax=atoi(&argv[i][6]); bmax_set=1;}
else if (strncmp(argv[i],"bmax=",5)==0) {bmax=atoi(&argv[i][5]); bmax_set=1;}
else if (strncmp(argv[i],"bmult=",6)==0) {bmult=atoi(&argv[i][6]);}
else if (strncmp(argv[i],"score=automatic",15)==0) automatic=1;
else if (strncmp(argv[i],"score=noautomatic",17)==0) automatic=0;
else if (strncmp(argv[i],"score=verboten",14)==0) { W_spurious=0.0; W_verboten=1.0; W_bonds=0.0; }
else if (strncmp(argv[i],"score=spurious",14)==0) { W_spurious=1.0; W_verboten=0.0; W_bonds=0.0; }
else if (strncmp(argv[i],"score=bonds",11)==0) { W_spurious=0.0; W_verboten=0.0; W_bonds=1.0; }
else if (strncmp(argv[i],"quiet=TRUE",10)==0) { quiet=1; watch=0; }
else if (strncmp(argv[i],"quiet=SCORES",12)==0) { quiet=0; watch=0; }
else if (strncmp(argv[i],"quiet=WATCH",11)==0) { quiet=1; watch=1; }
else if (strncmp(argv[i],"quiet=ALL",9)==0) { quiet=0; watch=1; }
else if (strncmp(argv[i],"trace=ON",8)==0) { trace=1; }
else if (strncmp(argv[i],"debug=TRUE",10)==0) debug=1;
else if (strncmp(argv[i],"W_verboten=",11)==0) {W_verboten=atof(&argv[i][11]); W_verboten_set=1;}
else if (strncmp(argv[i],"W_spurious=",11)==0) {W_spurious=atof(&argv[i][11]); W_spurious_set=1;}
else if (strncmp(argv[i],"W_bonds=",8)==0) {W_bonds=atof(&argv[i][8]); W_bonds_set=1;}
else if (strncmp(argv[i],"spurious_beta=",14)==0) spurious_beta=atof(&argv[i][14]);
else if (strncmp(argv[i],"spurious_intraS=",16)==0) {spurious_intraS=atof(&argv[i][16]); spurious_intraS_set=1;}
else if (strncmp(argv[i],"spurious_interS=",16)==0) {spurious_interS=atof(&argv[i][16]); spurious_interS_set=1;}
else if (strncmp(argv[i],"spurious_interC=",16)==0) {spurious_interC=atof(&argv[i][16]); spurious_interC_set=1;}
else if (strncmp(argv[i],"spurious_mismatch=",18)==0) {spurious_mismatch=atof(&argv[i][18]); }
else if (strncmp(argv[i],"spurious_range=",15)==0) {spurious_range=atoi(&argv[i][15]); }
else if (strncmp(argv[i],"spurious_equality=",18)==0) spurious_equality=(atoi(&argv[i][18])>0);
else if (strncmp(argv[i],"verboten_weak=",14)==0) {verboten_weak=atof(&argv[i][14]);}
else if (strncmp(argv[i],"verboten_strong=",16)==0) {verboten_strong=atof(&argv[i][16]);}
else if (strncmp(argv[i],"verboten_regular=",17)==0) {verboten_regular=atof(&argv[i][17]);}
else if (strncmp(argv[i],"temperature=",12)==0) temperature=atof(&argv[i][12]);
else {
fprintf(stderr,"Cannot parse argument <%s>. Aborting. \n\n",argv[i]); exit(-1);
}
}
} else {
// otherwise, try to read all four input files
rS_filename=argv[1]; St_filename=argv[2];
wc_filename=argv[3]; eq_filename=argv[4];
}
if (spurious_range < 1) spurious_range=1;
if (spurious_range > 10) spurious_range=10;
make_bad6mer();
// load in the files!
load_input_files();
//////////////////////////////////////////////////////////////
// information was read in. now do the designing!
if (automatic) {
if (!bmax_set) {
bmax=set_auto_spurious_weights(testS,testwc,testeq);
}
else set_auto_spurious_weights(testS,testwc,testeq);
}
constrain(testS,testwc,testeq);
if (!test_consistency(testS,testSt,testwc,testeq)) {
fprintf(stderr,"ERROR: input files have non-explicit implications.\n\n"); exit(-1);
}
if (!quiet) printf("\nconstrained S = <%s> N=%d \n",testS,N);
freeloc = calloc( N, sizeof(int) );
Nfree = 0;
for (i=0; i<N; i++) {
if ( (testeq[i]==i+1) && (testwc[i]>i+1 || testwc[i]==-1) && (testSt[i]!='A' && testSt[i]!='C' && testSt[i]!='G' && testSt[i]!='T' ) ) {
freeloc[Nfree]=i; Nfree++;
}
}
if (!quiet) printf("\nFound %d bases that can probably be changed freely.\n\n",Nfree);
if (!quiet) test_evals(testS,testwc,testeq);
{
char *oldS; double old_score, new_score; int steps=0; bored=0;
oldS = malloc(N);
old_score = score_all(testS,testwc,testeq);
if (watch) printf("%8d steps, %8d seconds : score = %18.10f",0,0,old_score);
if (watch && (imax>0)) printf(" (imax=%d)", imax);
if (watch && (tmax>0)) printf(" (tmax=%d)", (int) tmax);
if (watch && (bmax>0)) printf(" (bored=%d,bmax=%d)", bored, bmax);
if (watch) printf("\n");
time(&t_start); time(&t_now);
while ( (tmax==0 || t_start+tmax>=t_now) && (imax==0 || steps<imax) && (bmax==0 || bored<bmax) && Nfree>0) {
steps++;
if (!(quiet && !watch) && !trace && steps%300 == 0 && tmax==0 && imax==0 && bmax==0)
printf("\n\n%s\n\n",testS);
for (i=0; i<N; i++) oldS[i]=testS[i];
mutate(testS,testSt,testwc,testeq);
// if (bored > bmax/2) mutate(testS,testSt,testwc,testeq); // get desperate and start mutating two at a time (doesn't seem to work)
new_score = score_all(testS,testwc,testeq);
if (new_score <= old_score) {
if (watch) printf("%8d steps, %8d seconds : score = %18.10f", steps, (int)(t_now-t_start), new_score);
if (watch && (imax>0)) printf(" (imax=%d)", imax);
if (watch && (tmax>0)) printf(" (tmax=%d)", (int) tmax);
if (watch && (bmax>0)) printf(" (bored=%d,bmax=%d)", bored, bmax);
if (watch) printf("\n");
if (trace) printf("%s\n",testS);
if (new_score < old_score) bored=0;
old_score = new_score;
fflush(stdout);
} else {
for (i=0; i<N; i++) testS[i]=oldS[i]; bored++;
}
time(&t_now);
}
if (watch) printf("%8d steps, %8d seconds : score = %18.10f FINAL\n",
steps-1, (int)(t_now-t_start), old_score);
}
//// print final sequence to output file *****
constrain(testS,testwc,testeq);
if (!test_consistency(testS,testSt,testwc,testeq)) {
fprintf(stderr,"ERROR: output has non-explicit implications! THIS SHOULDN'T HAPPEN!\n\n"); exit(-1);
}
if (!quiet) test_evals(testS,testwc,testeq);
if (S_filename==NULL)
printf("%s\n",testS);
else {
if ( (f = fopen(S_filename,"w")) == NULL ) {
fprintf(stderr,"Can't open output file <%s>\n",S_filename); exit(-1);
} else {
fprintf(f,"%s\n",testS);
fclose(f);
}
}
return 0;
}
|
the_stack_data/337667.c | /* Taxonomy Classification: 0000000000000161000300 */
/*
* WRITE/READ 0 write
* WHICH BOUND 0 upper
* DATA TYPE 0 char
* MEMORY LOCATION 0 stack
* SCOPE 0 same
* CONTAINER 0 no
* POINTER 0 no
* INDEX COMPLEXITY 0 constant
* ADDRESS COMPLEXITY 0 constant
* LENGTH COMPLEXITY 0 N/A
* ADDRESS ALIAS 0 none
* INDEX ALIAS 0 none
* LOCAL CONTROL FLOW 0 none
* SECONDARY CONTROL FLOW 1 if
* LOOP STRUCTURE 6 non-standard while
* LOOP COMPLEXITY 1 zero
* ASYNCHRONY 0 no
* TAINT 0 no
* RUNTIME ENV. DEPENDENCE 0 no
* MAGNITUDE 3 4096 bytes
* CONTINUOUS/DISCRETE 0 discrete
* SIGNEDNESS 0 no
*/
/*
Copyright 2005 Massachusetts Institute of Technology
All rights reserved.
Redistribution and use of software 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 set of conditions and the disclaimer below.
- Redistributions in binary form must reproduce the copyright notice, this
set of conditions, and the disclaimer below in the documentation and/or
other materials provided with the distribution.
- Neither the name of the Massachusetts Institute of Technology 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".
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.
*/
int main(int argc, char *argv[])
{
int loop_counter;
char buf[10];
loop_counter = 0;
while(++loop_counter)
{
/* BAD */
buf[4105] = 'A';
if (loop_counter >= 4105) break;
}
return 0;
}
|
the_stack_data/863761.c | /* mbed Microcontroller Library
* Copyright (c) 2006-2018 ARM Limited
*
* 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.
*/
#ifdef DEVICE_WATCHDOG
#include "watchdog_api.h"
#include "reset_reason_api.h"
#include "device.h"
#include "mbed_error.h"
#include <stdbool.h>
#define MAX_IWDG_PR 0x6 // Max value of Prescaler_divider bits (PR) of Prescaler_register (IWDG_PR)
#define MAX_IWDG_RL 0xFFFUL // Max value of Watchdog_counter_reload_value bits (RL) of Reload_register (IWDG_RLR).
// Convert Prescaler_divider bits (PR) of Prescaler_register (IWDG_PR) to a prescaler_divider value.
#define PR2PRESCALER_DIV(PR_BITS) \
(4UL << (PR_BITS))
// Convert Prescaler_divider bits (PR) of Prescaler_register (IWDG_PR)
// and Watchdog_counter_reload_value bits (RL) of Reload_register (IWDG_RLR)
// to a timeout value [ms].
#define PR_RL2UINT64_TIMEOUT_MS(PR_BITS, RL_BITS) \
((PR2PRESCALER_DIV(PR_BITS)) * (RL_BITS) * 1000ULL / (LSI_VALUE))
// Convert Prescaler_divider bits (PR) of Prescaler_register (IWDG_PR) and a timeout value [ms]
// to Watchdog_counter_reload_value bits (RL) of Reload_register (IWDG_RLR)
#define PR_TIMEOUT_MS2RL(PR_BITS, TIMEOUT_MS) \
(((TIMEOUT_MS) * (LSI_VALUE) / (PR2PRESCALER_DIV(PR_BITS)) + 999UL) / 1000UL)
#define MAX_TIMEOUT_MS_UINT64 PR_RL2UINT64_TIMEOUT_MS(MAX_IWDG_PR, MAX_IWDG_RL)
#if (MAX_TIMEOUT_MS_UINT64 > UINT32_MAX)
#define MAX_TIMEOUT_MS UINT32_MAX
#else
#define MAX_TIMEOUT_MS (MAX_TIMEOUT_MS_UINT64 & 0xFFFFFFFFUL)
#endif
#define INVALID_IWDG_PR ((MAX_IWDG_PR) + 1) // Arbitrary value used to mark an invalid PR bits value.
// Pick a minimal Prescaler_divider bits (PR) value suitable for given timeout.
static uint8_t pick_min_iwdg_pr(const uint32_t timeout_ms)
{
for (uint8_t pr = 0; pr <= MAX_IWDG_PR; pr++) {
// Check that max timeout for given pr is greater than
// or equal to timeout_ms.
if (PR_RL2UINT64_TIMEOUT_MS(pr, MAX_IWDG_RL) >= timeout_ms) {
return pr;
}
}
return INVALID_IWDG_PR;
}
IWDG_HandleTypeDef IwdgHandle;
watchdog_status_t hal_watchdog_init(const watchdog_config_t *config)
{
const uint8_t pr = pick_min_iwdg_pr(config->timeout_ms);
if (pr == INVALID_IWDG_PR) {
return WATCHDOG_STATUS_INVALID_ARGUMENT;
}
const uint32_t rl = PR_TIMEOUT_MS2RL(pr, config->timeout_ms);
IwdgHandle.Instance = IWDG;
IwdgHandle.Init.Prescaler = pr;
IwdgHandle.Init.Reload = rl;
#if defined IWDG_WINR_WIN
IwdgHandle.Init.Window = IWDG_WINDOW_DISABLE;
#endif
if (HAL_IWDG_Init(&IwdgHandle) != HAL_OK) {
error("HAL_IWDG_Init error\n");
}
return WATCHDOG_STATUS_OK;
}
void hal_watchdog_kick(void)
{
HAL_IWDG_Refresh(&IwdgHandle);
}
watchdog_status_t hal_watchdog_stop(void)
{
return WATCHDOG_STATUS_NOT_SUPPORTED;
}
uint32_t hal_watchdog_get_reload_value(void)
{
// Wait for the Watchdog_prescaler_value_update bit (PVU) of
// Status_register (IWDG_SR) to be reset.
while (READ_BIT(IWDG->SR, IWDG_SR_PVU)) {
}
// Read Prescaler_divider bits (PR) of Prescaler_register (IWDG_PR).
const uint8_t pr = (IWDG->PR & IWDG_PR_PR_Msk) >> IWDG_PR_PR_Pos;
// Wait for the Watchdog_counter_reload_value_update bit (RVU) of
// Status_register (IWDG_SR) to be reset.
while (READ_BIT(IWDG->SR, IWDG_SR_RVU)) {
}
// Read Watchdog_counter_reload_value bits (RL) of Reload_register (IWDG_RLR).
const uint32_t rl = (IWDG->RLR & IWDG_RLR_RL_Msk) >> IWDG_RLR_RL_Pos;
return PR_RL2UINT64_TIMEOUT_MS(pr, rl);
}
watchdog_features_t hal_watchdog_get_platform_features(void)
{
watchdog_features_t features;
features.max_timeout = MAX_TIMEOUT_MS;
features.update_config = true;
features.disable_watchdog = false;
/* STM32 IWDG (Independent Watchdog) is clocked by its own dedicated low-speed clock (LSI) */
features.clock_typical_frequency = LSI_VALUE;
/* See LSI oscillator characteristics in Data Sheet */
#if defined(STM32F1)
features.clock_max_frequency = 60000;
#elif defined(STM32L0) || defined(STM32L1)
features.clock_max_frequency = 56000;
#elif defined(STM32F2) || defined(STM32F4) || defined(STM32F7)
features.clock_max_frequency = 47000;
#elif defined(STM32F0) || defined(STM32F3)
features.clock_max_frequency = 50000;
#elif defined(STM32H7) || defined(STM32L4) || defined(STM32WB)
features.clock_max_frequency = 33600;
#elif defined(STM32G0) || defined(STM32L5) || defined(STM32G4)
features.clock_max_frequency = 34000;
#else
#error "unsupported target"
#endif
return features;
}
#endif // DEVICE_WATCHDOG
|
the_stack_data/1267285.c | //
// Created by zing on 6/8/2020.
//
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <wait.h>
#include <fcntl.h>
#include <string.h>
void test_fork() {
pid_t p = fork();
if (p == -1) {
perror("fork");
return;
}
if (p == 0) {
sleep(1);
printf("I am new process\n");
printf("pid %d\n", getpid());
printf("ppid %d\n", getppid());
} else {
printf("I am old process\n");
printf("pid %d\n", getpid());
printf("ppid %d\n", getppid());
}
printf("parent and child all run here\n");
wait(&p);
}
void read_file() {
pid_t pid;
int fd;
int i = 1;
char *s1 = "hello";
char *s2 = "world";
char *s3 = "cccccc";
if (remove("test.txt") == -1) {
if (errno == ENOENT) {
printf("remove ok\n");
} else {
perror("remove");
return;
}
}
if ((fd = open("test.txt", O_RDWR | O_CREAT, 0644)) == -1) {
perror("parent open");
return;
}
if (write(fd, s1, strlen(s1)) == -1) {
perror("parent write");
return;
}
if (write(fd, s3, strlen(s3)) == -1) {
perror("parent write");
return;
}
if ((pid = fork()) == -1) {
perror("fork");
return;
} else if (pid == 0) {
i = 2;
printf("in child process\n");
printf("i = %d\n", i);
if (write(fd, s2, strlen(s2)) == -1) {
perror("child write");
return;
}
} else {
sleep(1);
printf("in parent process\n");
printf("i = %d \n", i);
if (write(fd, s3, strlen(s3) == -1)) {
perror("parent write");
return;
}
}
wait(&pid);
printf("over...\n");
}
/* Clone the calling process, creating an exact copy.
Return -1 for errors, 0 to the new process,
and the process ID of the new process to the old process. */
int main() {
//test_fork();
read_file();
return EXIT_SUCCESS;
} |
the_stack_data/29826118.c | #include <arpa/inet.h>
#include <errno.h>
#include <libgen.h> // basename
#include <netdb.h> // gethostbyname
#include <stdio.h>
#include <stdlib.h> // atoi
#include <string.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
void do_client(int sock_fd, const struct sockaddr_in *addr) {
int ret = connect(sock_fd, (struct sockaddr *)addr, sizeof(*addr));
if (ret != 0) {
printf("[%d]: %s\n", errno, strerror(errno));
return;
}
printf("Success to connect to server!\n");
size_t buf_size = 1024;
char *buf = malloc(buf_size);
while (1) {
// 从标准输入中读取一行
// getline会在换行符'\n'(10)后面,再补一个'\0'(0)
// 所以不用担心buf里有脏数据导致strlen计算错误的问题
// 返回的n是算上换行符
// 如果一行文本的内容大于buf_size,那么getline会realloc
// 同时更新buf和buf_size的值
ssize_t n = getline(&buf, &buf_size, stdin);
buf[n - 1] = '\0'; // 去掉行尾的换行符
// 设置client的退出机制
if (strcmp("quit", buf) == 0) {
break;
}
send(sock_fd, buf, n, 0);
// 以下代码为了测试,一次性服务器写入大量数据,测试send函数的阻塞问题
// int32_t large_size = 10240000;
// char *large_buf = malloc(large_size);
// for (int i = 0; i < large_size; i++) {
// large_buf[i] = i % 256;
// }
// send(sock_fd, large_buf, large_size, 0);
// printf("sent large size data to server!\n");
// 从服务端接收数据
const uint32_t recv_buf_size = 1024;
char recv_buf[recv_buf_size];
memset(recv_buf, '\0', recv_buf_size);
ssize_t n_recv = recv(sock_fd, recv_buf, recv_buf_size, 0);
if (n_recv == 0) {
printf("lose connection from server!\n");
break;
}
printf("Recv: [%ld] %s\n", n_recv, recv_buf);
}
free(buf);
}
void handle_client_connection(int conn) {
const uint32_t buf_size = 1024;
char recv_buf[buf_size];
while (1) {
int n = recv(conn, recv_buf, buf_size, 0);
if (n == 0) {
break;
}
printf("recv: [%d] %s\n", n, recv_buf);
send(conn, recv_buf, n, 0);
}
}
void do_server(int sock_fd, const struct sockaddr_in *addr) {
int on = 1;
setsockopt(sock_fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
int ret = bind(sock_fd, (struct sockaddr *)(addr), sizeof(*addr));
if (ret != 0) {
printf("[%d] %s\n", errno, strerror(errno));
return;
}
// 监听socket
ret = listen(sock_fd, 5);
if (ret != 0) {
printf("[%d] %s\n", errno, strerror(errno));
return;
}
while (1) {
struct sockaddr_in client_addr;
socklen_t addr_len;
int conn = accept(sock_fd, (struct sockaddr *)(&client_addr), &addr_len);
if (conn == -1) {
printf("[%d] %s\n", errno, strerror(errno));
return;
}
char client_ip[INET_ADDRSTRLEN];
memset(client_ip, '\0', INET_ADDRSTRLEN);
printf("Connection from %s:%d\n",
inet_ntop(AF_INET, &client_addr.sin_addr, client_ip, INET_ADDRSTRLEN),
ntohs(client_addr.sin_port));
handle_client_connection(conn);
printf("Connection closed!\n");
close(conn);
}
}
int main(int argc, char *argv[]) {
if (argc < 3) {
printf("Usage: %s <role>(server/client) <ip/hostname> <port>\n", basename(argv[0]));
return -1;
}
// 根据程序参数来生成socket的地址
struct sockaddr_in addr;
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_port = htons(atoi(argv[3])); // 端口号也需要转换为网络字节序
// 根据hostname(点分十进制/域名)获取ip地址(网络字节序)
struct hostent *he = gethostbyname(argv[2]);
memcpy(&addr.sin_addr, he->h_addr_list[0], he->h_length);
// 创建socket
int sock_fd = socket(PF_INET, SOCK_STREAM, 0);
if (strcmp(argv[1], "server") == 0) {
do_server(sock_fd, &addr);
} else if (strcmp(argv[1], "client") == 0) {
do_client(sock_fd, &addr);
} else {
printf("Usage: %s <role>(server/client) <ip/hostname> <port>\n", basename(argv[0]));
return -1;
}
close(sock_fd);
return 0;
} |
the_stack_data/215768035.c | #include <stddef.h>
void *__memcpy_glibc_2_2_5(void *, const void *, size_t);
// Map old variant of mecpy for compatibility reasons. NOTE: it is not
// possible to directly map __wrap_memcpy symbol to a specific mecpy
// version and omit the __wrap_memcpy definition. The symbol will
// always be missing.
asm(".symver __memcpy_glibc_2_2_5, memcpy@GLIBC_2.2.5");
void *__wrap_memcpy(void *dest, const void *src, size_t n)
{
return __memcpy_glibc_2_2_5(dest, src, n);
}
|
the_stack_data/138931.c | /* Generic unsigned 32 bit division implementation.
Copyright (C) 2009-2020 Free Software Foundation, Inc.
Contributed by Embecosm on behalf of Adapteva, Inc.
This file is part of GCC.
This file is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 3, or (at your option) any
later version.
This file 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
General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
typedef union { unsigned int i; float f; } fu;
unsigned int __udivsi3 (unsigned int a, unsigned int b);
unsigned int
__udivsi3 (unsigned int a, unsigned int b)
{
unsigned int d, t, s0, s1, s2, r0, r1;
fu u0, u1, u2, u1b, u2b;
if (b > a)
return 0;
if ((int) b < 0)
return 1;
/* Assuming B is nonzero, compute S0 such that 0 <= S0,
(B << S0+1) does not overflow,
A < 4.01 * (B << S0), with S0 chosen as small as possible
without taking to much time calculating. */
#ifdef CONVERT_UNSIGNED
u0.f = a;
u1.f = b;
#else /* !CONVERT_UNSIGNED */
u0.f = (int) a;
u1.f = (int) b;
#ifdef CONCISE
if ((int) a < 0)
u0.i = (a >> 8) - 0x00800000 + 0x3f800000 + (31 << 23);
#else /* To use flag setting / cmove, this can be written as: */
{
unsigned c = 0xff800000 - 0x4f000000;
t = (int)a >> 8;
if (t >= c)
u0.i = (t - c);
}
#endif
#endif /* !CONVERT_UNSIGNED */
s0 = u0.i + 1 /* Compensate for rounding errors. */
- 0x00800000 /* adjust by one */ ;
s0 = s0 - u1.i;
s0 = (int)s0 >= 0 ? s0 : 0;
s0 >>= 23;
b <<= s0;
r1 = 0;
r0 = 1 << s0;
a = ((t=a) - b);
if (a <= t)
{
r1 += r0;
a = ((t=a) - b);
if (a <= t)
do {
r1 += r0;
a = ((t=a) - b);
} while (a <= t);
}
a += b;
d = b - 1;
#define STEP(n) case n: a += a; t = a - d; if (t <= a) a = t;
switch (s0)
{
STEP (31)
STEP (30)
STEP (29)
STEP (28)
STEP (27)
STEP (26)
STEP (25)
STEP (24)
STEP (23)
STEP (22)
STEP (21)
STEP (20)
STEP (19)
STEP (18)
STEP (17)
STEP (16)
STEP (15)
STEP (14)
STEP (13)
STEP (12)
STEP (11)
STEP (10)
STEP (9)
STEP (8)
STEP (7)
STEP (6)
STEP (5)
STEP (4)
STEP (3)
STEP (2)
STEP (1)
case 0: ;
}
r0 = r1 | (r0-1 & a);
return r0;
}
|
the_stack_data/176706122.c | extern void __VERIFIER_error() __attribute__ ((__noreturn__));
extern void __VERIFIER_assume(int);
void __VERIFIER_assert(int cond) {
if (!(cond)) {
ERROR: /* assert not proved */
__VERIFIER_error();
}
return;
}
#define MAX 5
extern char __VERIFIER_nondet_char();
int main(void)
{
char string_A[MAX], string_B[MAX];
int i, j, nc_A, nc_B, found=0;
for(/* reachable */
/* invariant:
5-i >= 0
i >= 0
*/
i=0; i<MAX; i++)
string_A[i]=__VERIFIER_nondet_char();
__VERIFIER_assume(string_A[MAX-1]=='\0');
for(/* invariant:
5-i >= 0
i >= 0
*/
i=0; i<MAX; i++)
string_B[i]=__VERIFIER_nondet_char();
__VERIFIER_assume(string_B[MAX-1]=='\0');
nc_A = 0;
/* invariant:
nc_A >= 0
*/
while(string_A[nc_A]!='\0')
nc_A++;
nc_B = 0;
/* invariant:
nc_B >= 0
nc_A >= 0
*/
while(string_B[nc_B]!='\0')
nc_B++;
__VERIFIER_assume(nc_B >= nc_A);
i=j=0;
/* invariant:
-i+nc_A >= 0
j >= 0
nc_B-j >= 0
i-j >= 0
*/
while((i<nc_A) && (j<nc_B))
{
if(string_A[i] == string_B[j])
{
i++;
j++;
}
else
{
i = i-j+1;
j = 0;
}
}
found = (j>nc_B-1)<<i;
__VERIFIER_assert(found == 0 || found == 1);
/* reachable */
}
|
the_stack_data/206392692.c | void main(void){
int i;
int j;
int k;
int a;
int b;
int c;
int d;
i = 0 ;
j = 2;
k = 4;
a = 6;
b = 8;
c = 10;
d = 12;
if( i > j )
{
k = k + 1;
}
if( k > a)
{
b = b + 1;
}
if( b > c)
{
d = d + c;
}
return;
} |
the_stack_data/100139365.c | #include <stdio.h>
int main(void)
{
int size, temp, i;
int input[100];
FILE *fp = fopen("res/04_input.txt", "r");
{
for(size = 0; size < 100 && !feof(fp); ++size)
fscanf(fp, "%d", &input[size]);
--size;
}
{
temp = input[size - 1];
for(i = size - 1; i > 0; --i)
input[i] = input[i - 1];
input[0] = temp;
}
{
printf("Result is: ");
for(i = 0; i < size; ++i)
printf("%d ", input[i]);
printf("\n");
}
}
|
the_stack_data/137927.c | #include <math.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <complex.h>
#ifdef complex
#undef complex
#endif
#ifdef I
#undef I
#endif
#if defined(_WIN64)
typedef long long BLASLONG;
typedef unsigned long long BLASULONG;
#else
typedef long BLASLONG;
typedef unsigned long BLASULONG;
#endif
#ifdef LAPACK_ILP64
typedef BLASLONG blasint;
#if defined(_WIN64)
#define blasabs(x) llabs(x)
#else
#define blasabs(x) labs(x)
#endif
#else
typedef int blasint;
#define blasabs(x) abs(x)
#endif
typedef blasint integer;
typedef unsigned int uinteger;
typedef char *address;
typedef short int shortint;
typedef float real;
typedef double doublereal;
typedef struct { real r, i; } complex;
typedef struct { doublereal r, i; } doublecomplex;
#ifdef _MSC_VER
static inline _Fcomplex Cf(complex *z) {_Fcomplex zz={z->r , z->i}; return zz;}
static inline _Dcomplex Cd(doublecomplex *z) {_Dcomplex zz={z->r , z->i};return zz;}
static inline _Fcomplex * _pCf(complex *z) {return (_Fcomplex*)z;}
static inline _Dcomplex * _pCd(doublecomplex *z) {return (_Dcomplex*)z;}
#else
static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;}
static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;}
static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;}
static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;}
#endif
#define pCf(z) (*_pCf(z))
#define pCd(z) (*_pCd(z))
typedef int logical;
typedef short int shortlogical;
typedef char logical1;
typedef char integer1;
#define TRUE_ (1)
#define FALSE_ (0)
/* Extern is for use with -E */
#ifndef Extern
#define Extern extern
#endif
/* I/O stuff */
typedef int flag;
typedef int ftnlen;
typedef int ftnint;
/*external read, write*/
typedef struct
{ flag cierr;
ftnint ciunit;
flag ciend;
char *cifmt;
ftnint cirec;
} cilist;
/*internal read, write*/
typedef struct
{ flag icierr;
char *iciunit;
flag iciend;
char *icifmt;
ftnint icirlen;
ftnint icirnum;
} icilist;
/*open*/
typedef struct
{ flag oerr;
ftnint ounit;
char *ofnm;
ftnlen ofnmlen;
char *osta;
char *oacc;
char *ofm;
ftnint orl;
char *oblnk;
} olist;
/*close*/
typedef struct
{ flag cerr;
ftnint cunit;
char *csta;
} cllist;
/*rewind, backspace, endfile*/
typedef struct
{ flag aerr;
ftnint aunit;
} alist;
/* inquire */
typedef struct
{ flag inerr;
ftnint inunit;
char *infile;
ftnlen infilen;
ftnint *inex; /*parameters in standard's order*/
ftnint *inopen;
ftnint *innum;
ftnint *innamed;
char *inname;
ftnlen innamlen;
char *inacc;
ftnlen inacclen;
char *inseq;
ftnlen inseqlen;
char *indir;
ftnlen indirlen;
char *infmt;
ftnlen infmtlen;
char *inform;
ftnint informlen;
char *inunf;
ftnlen inunflen;
ftnint *inrecl;
ftnint *innrec;
char *inblank;
ftnlen inblanklen;
} inlist;
#define VOID void
union Multitype { /* for multiple entry points */
integer1 g;
shortint h;
integer i;
/* longint j; */
real r;
doublereal d;
complex c;
doublecomplex z;
};
typedef union Multitype Multitype;
struct Vardesc { /* for Namelist */
char *name;
char *addr;
ftnlen *dims;
int type;
};
typedef struct Vardesc Vardesc;
struct Namelist {
char *name;
Vardesc **vars;
int nvars;
};
typedef struct Namelist Namelist;
#define abs(x) ((x) >= 0 ? (x) : -(x))
#define dabs(x) (fabs(x))
#define f2cmin(a,b) ((a) <= (b) ? (a) : (b))
#define f2cmax(a,b) ((a) >= (b) ? (a) : (b))
#define dmin(a,b) (f2cmin(a,b))
#define dmax(a,b) (f2cmax(a,b))
#define bit_test(a,b) ((a) >> (b) & 1)
#define bit_clear(a,b) ((a) & ~((uinteger)1 << (b)))
#define bit_set(a,b) ((a) | ((uinteger)1 << (b)))
#define abort_() { sig_die("Fortran abort routine called", 1); }
#define c_abs(z) (cabsf(Cf(z)))
#define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); }
#ifdef _MSC_VER
#define c_div(c, a, b) {Cf(c)._Val[0] = (Cf(a)._Val[0]/Cf(b)._Val[0]); Cf(c)._Val[1]=(Cf(a)._Val[1]/Cf(b)._Val[1]);}
#define z_div(c, a, b) {Cd(c)._Val[0] = (Cd(a)._Val[0]/Cd(b)._Val[0]); Cd(c)._Val[1]=(Cd(a)._Val[1]/Cd(b)._Val[1]);}
#else
#define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);}
#define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);}
#endif
#define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));}
#define c_log(R, Z) {pCf(R) = clogf(Cf(Z));}
#define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));}
//#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));}
#define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));}
#define d_abs(x) (fabs(*(x)))
#define d_acos(x) (acos(*(x)))
#define d_asin(x) (asin(*(x)))
#define d_atan(x) (atan(*(x)))
#define d_atn2(x, y) (atan2(*(x),*(y)))
#define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); }
#define r_cnjg(R, Z) { pCf(R) = conjf(Cf(Z)); }
#define d_cos(x) (cos(*(x)))
#define d_cosh(x) (cosh(*(x)))
#define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 )
#define d_exp(x) (exp(*(x)))
#define d_imag(z) (cimag(Cd(z)))
#define r_imag(z) (cimagf(Cf(z)))
#define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
#define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
#define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
#define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
#define d_log(x) (log(*(x)))
#define d_mod(x, y) (fmod(*(x), *(y)))
#define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x)))
#define d_nint(x) u_nint(*(x))
#define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a)))
#define d_sign(a,b) u_sign(*(a),*(b))
#define r_sign(a,b) u_sign(*(a),*(b))
#define d_sin(x) (sin(*(x)))
#define d_sinh(x) (sinh(*(x)))
#define d_sqrt(x) (sqrt(*(x)))
#define d_tan(x) (tan(*(x)))
#define d_tanh(x) (tanh(*(x)))
#define i_abs(x) abs(*(x))
#define i_dnnt(x) ((integer)u_nint(*(x)))
#define i_len(s, n) (n)
#define i_nint(x) ((integer)u_nint(*(x)))
#define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b)))
#define pow_dd(ap, bp) ( pow(*(ap), *(bp)))
#define pow_si(B,E) spow_ui(*(B),*(E))
#define pow_ri(B,E) spow_ui(*(B),*(E))
#define pow_di(B,E) dpow_ui(*(B),*(E))
#define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));}
#define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));}
#define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));}
#define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; }
#define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d))))
#define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; }
#define sig_die(s, kill) { exit(1); }
#define s_stop(s, n) {exit(0);}
static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n";
#define z_abs(z) (cabs(Cd(z)))
#define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));}
#define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));}
#define myexit_() break;
#define mycycle_() continue;
#define myceiling_(w) {ceil(w)}
#define myhuge_(w) {HUGE_VAL}
//#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);}
#define mymaxloc_(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)}
/* procedure parameter types for -A and -C++ */
#define F2C_proc_par_types 1
#ifdef __cplusplus
typedef logical (*L_fp)(...);
#else
typedef logical (*L_fp)();
#endif
static float spow_ui(float x, integer n) {
float pow=1.0; unsigned long int u;
if(n != 0) {
if(n < 0) n = -n, x = 1/x;
for(u = n; ; ) {
if(u & 01) pow *= x;
if(u >>= 1) x *= x;
else break;
}
}
return pow;
}
static double dpow_ui(double x, integer n) {
double pow=1.0; unsigned long int u;
if(n != 0) {
if(n < 0) n = -n, x = 1/x;
for(u = n; ; ) {
if(u & 01) pow *= x;
if(u >>= 1) x *= x;
else break;
}
}
return pow;
}
#ifdef _MSC_VER
static _Fcomplex cpow_ui(complex x, integer n) {
complex pow={1.0,0.0}; unsigned long int u;
if(n != 0) {
if(n < 0) n = -n, x.r = 1/x.r, x.i=1/x.i;
for(u = n; ; ) {
if(u & 01) pow.r *= x.r, pow.i *= x.i;
if(u >>= 1) x.r *= x.r, x.i *= x.i;
else break;
}
}
_Fcomplex p={pow.r, pow.i};
return p;
}
#else
static _Complex float cpow_ui(_Complex float x, integer n) {
_Complex float pow=1.0; unsigned long int u;
if(n != 0) {
if(n < 0) n = -n, x = 1/x;
for(u = n; ; ) {
if(u & 01) pow *= x;
if(u >>= 1) x *= x;
else break;
}
}
return pow;
}
#endif
#ifdef _MSC_VER
static _Dcomplex zpow_ui(_Dcomplex x, integer n) {
_Dcomplex pow={1.0,0.0}; unsigned long int u;
if(n != 0) {
if(n < 0) n = -n, x._Val[0] = 1/x._Val[0], x._Val[1] =1/x._Val[1];
for(u = n; ; ) {
if(u & 01) pow._Val[0] *= x._Val[0], pow._Val[1] *= x._Val[1];
if(u >>= 1) x._Val[0] *= x._Val[0], x._Val[1] *= x._Val[1];
else break;
}
}
_Dcomplex p = {pow._Val[0], pow._Val[1]};
return p;
}
#else
static _Complex double zpow_ui(_Complex double x, integer n) {
_Complex double pow=1.0; unsigned long int u;
if(n != 0) {
if(n < 0) n = -n, x = 1/x;
for(u = n; ; ) {
if(u & 01) pow *= x;
if(u >>= 1) x *= x;
else break;
}
}
return pow;
}
#endif
static integer pow_ii(integer x, integer n) {
integer pow; unsigned long int u;
if (n <= 0) {
if (n == 0 || x == 1) pow = 1;
else if (x != -1) pow = x == 0 ? 1/x : 0;
else n = -n;
}
if ((n > 0) || !(n == 0 || x == 1 || x != -1)) {
u = n;
for(pow = 1; ; ) {
if(u & 01) pow *= x;
if(u >>= 1) x *= x;
else break;
}
}
return pow;
}
static integer dmaxloc_(double *w, integer s, integer e, integer *n)
{
double m; integer i, mi;
for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
if (w[i-1]>m) mi=i ,m=w[i-1];
return mi-s+1;
}
static integer smaxloc_(float *w, integer s, integer e, integer *n)
{
float m; integer i, mi;
for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
if (w[i-1]>m) mi=i ,m=w[i-1];
return mi-s+1;
}
static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
integer n = *n_, incx = *incx_, incy = *incy_, i;
#ifdef _MSC_VER
_Fcomplex zdotc = {0.0, 0.0};
if (incx == 1 && incy == 1) {
for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
zdotc._Val[0] += conjf(Cf(&x[i]))._Val[0] * Cf(&y[i])._Val[0];
zdotc._Val[1] += conjf(Cf(&x[i]))._Val[1] * Cf(&y[i])._Val[1];
}
} else {
for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
zdotc._Val[0] += conjf(Cf(&x[i*incx]))._Val[0] * Cf(&y[i*incy])._Val[0];
zdotc._Val[1] += conjf(Cf(&x[i*incx]))._Val[1] * Cf(&y[i*incy])._Val[1];
}
}
pCf(z) = zdotc;
}
#else
_Complex float zdotc = 0.0;
if (incx == 1 && incy == 1) {
for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
zdotc += conjf(Cf(&x[i])) * Cf(&y[i]);
}
} else {
for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]);
}
}
pCf(z) = zdotc;
}
#endif
static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
integer n = *n_, incx = *incx_, incy = *incy_, i;
#ifdef _MSC_VER
_Dcomplex zdotc = {0.0, 0.0};
if (incx == 1 && incy == 1) {
for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
zdotc._Val[0] += conj(Cd(&x[i]))._Val[0] * Cd(&y[i])._Val[0];
zdotc._Val[1] += conj(Cd(&x[i]))._Val[1] * Cd(&y[i])._Val[1];
}
} else {
for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
zdotc._Val[0] += conj(Cd(&x[i*incx]))._Val[0] * Cd(&y[i*incy])._Val[0];
zdotc._Val[1] += conj(Cd(&x[i*incx]))._Val[1] * Cd(&y[i*incy])._Val[1];
}
}
pCd(z) = zdotc;
}
#else
_Complex double zdotc = 0.0;
if (incx == 1 && incy == 1) {
for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
zdotc += conj(Cd(&x[i])) * Cd(&y[i]);
}
} else {
for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]);
}
}
pCd(z) = zdotc;
}
#endif
static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
integer n = *n_, incx = *incx_, incy = *incy_, i;
#ifdef _MSC_VER
_Fcomplex zdotc = {0.0, 0.0};
if (incx == 1 && incy == 1) {
for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
zdotc._Val[0] += Cf(&x[i])._Val[0] * Cf(&y[i])._Val[0];
zdotc._Val[1] += Cf(&x[i])._Val[1] * Cf(&y[i])._Val[1];
}
} else {
for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
zdotc._Val[0] += Cf(&x[i*incx])._Val[0] * Cf(&y[i*incy])._Val[0];
zdotc._Val[1] += Cf(&x[i*incx])._Val[1] * Cf(&y[i*incy])._Val[1];
}
}
pCf(z) = zdotc;
}
#else
_Complex float zdotc = 0.0;
if (incx == 1 && incy == 1) {
for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
zdotc += Cf(&x[i]) * Cf(&y[i]);
}
} else {
for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]);
}
}
pCf(z) = zdotc;
}
#endif
static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
integer n = *n_, incx = *incx_, incy = *incy_, i;
#ifdef _MSC_VER
_Dcomplex zdotc = {0.0, 0.0};
if (incx == 1 && incy == 1) {
for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
zdotc._Val[0] += Cd(&x[i])._Val[0] * Cd(&y[i])._Val[0];
zdotc._Val[1] += Cd(&x[i])._Val[1] * Cd(&y[i])._Val[1];
}
} else {
for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
zdotc._Val[0] += Cd(&x[i*incx])._Val[0] * Cd(&y[i*incy])._Val[0];
zdotc._Val[1] += Cd(&x[i*incx])._Val[1] * Cd(&y[i*incy])._Val[1];
}
}
pCd(z) = zdotc;
}
#else
_Complex double zdotc = 0.0;
if (incx == 1 && incy == 1) {
for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
zdotc += Cd(&x[i]) * Cd(&y[i]);
}
} else {
for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]);
}
}
pCd(z) = zdotc;
}
#endif
/* -- translated by f2c (version 20000121).
You must link the resulting object file with the libraries:
-lf2c -lm (in that order)
*/
/* Table of constant values */
static integer c_n1 = -1;
/* > \brief \b ZTRSEN */
/* =========== DOCUMENTATION =========== */
/* Online html documentation available at */
/* http://www.netlib.org/lapack/explore-html/ */
/* > \htmlonly */
/* > Download ZTRSEN + dependencies */
/* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ztrsen.
f"> */
/* > [TGZ]</a> */
/* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ztrsen.
f"> */
/* > [ZIP]</a> */
/* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ztrsen.
f"> */
/* > [TXT]</a> */
/* > \endhtmlonly */
/* Definition: */
/* =========== */
/* SUBROUTINE ZTRSEN( JOB, COMPQ, SELECT, N, T, LDT, Q, LDQ, W, M, S, */
/* SEP, WORK, LWORK, INFO ) */
/* CHARACTER COMPQ, JOB */
/* INTEGER INFO, LDQ, LDT, LWORK, M, N */
/* DOUBLE PRECISION S, SEP */
/* LOGICAL SELECT( * ) */
/* COMPLEX*16 Q( LDQ, * ), T( LDT, * ), W( * ), WORK( * ) */
/* > \par Purpose: */
/* ============= */
/* > */
/* > \verbatim */
/* > */
/* > ZTRSEN reorders the Schur factorization of a complex matrix */
/* > A = Q*T*Q**H, so that a selected cluster of eigenvalues appears in */
/* > the leading positions on the diagonal of the upper triangular matrix */
/* > T, and the leading columns of Q form an orthonormal basis of the */
/* > corresponding right invariant subspace. */
/* > */
/* > Optionally the routine computes the reciprocal condition numbers of */
/* > the cluster of eigenvalues and/or the invariant subspace. */
/* > \endverbatim */
/* Arguments: */
/* ========== */
/* > \param[in] JOB */
/* > \verbatim */
/* > JOB is CHARACTER*1 */
/* > Specifies whether condition numbers are required for the */
/* > cluster of eigenvalues (S) or the invariant subspace (SEP): */
/* > = 'N': none; */
/* > = 'E': for eigenvalues only (S); */
/* > = 'V': for invariant subspace only (SEP); */
/* > = 'B': for both eigenvalues and invariant subspace (S and */
/* > SEP). */
/* > \endverbatim */
/* > */
/* > \param[in] COMPQ */
/* > \verbatim */
/* > COMPQ is CHARACTER*1 */
/* > = 'V': update the matrix Q of Schur vectors; */
/* > = 'N': do not update Q. */
/* > \endverbatim */
/* > */
/* > \param[in] SELECT */
/* > \verbatim */
/* > SELECT is LOGICAL array, dimension (N) */
/* > SELECT specifies the eigenvalues in the selected cluster. To */
/* > select the j-th eigenvalue, SELECT(j) must be set to .TRUE.. */
/* > \endverbatim */
/* > */
/* > \param[in] N */
/* > \verbatim */
/* > N is INTEGER */
/* > The order of the matrix T. N >= 0. */
/* > \endverbatim */
/* > */
/* > \param[in,out] T */
/* > \verbatim */
/* > T is COMPLEX*16 array, dimension (LDT,N) */
/* > On entry, the upper triangular matrix T. */
/* > On exit, T is overwritten by the reordered matrix T, with the */
/* > selected eigenvalues as the leading diagonal elements. */
/* > \endverbatim */
/* > */
/* > \param[in] LDT */
/* > \verbatim */
/* > LDT is INTEGER */
/* > The leading dimension of the array T. LDT >= f2cmax(1,N). */
/* > \endverbatim */
/* > */
/* > \param[in,out] Q */
/* > \verbatim */
/* > Q is COMPLEX*16 array, dimension (LDQ,N) */
/* > On entry, if COMPQ = 'V', the matrix Q of Schur vectors. */
/* > On exit, if COMPQ = 'V', Q has been postmultiplied by the */
/* > unitary transformation matrix which reorders T; the leading M */
/* > columns of Q form an orthonormal basis for the specified */
/* > invariant subspace. */
/* > If COMPQ = 'N', Q is not referenced. */
/* > \endverbatim */
/* > */
/* > \param[in] LDQ */
/* > \verbatim */
/* > LDQ is INTEGER */
/* > The leading dimension of the array Q. */
/* > LDQ >= 1; and if COMPQ = 'V', LDQ >= N. */
/* > \endverbatim */
/* > */
/* > \param[out] W */
/* > \verbatim */
/* > W is COMPLEX*16 array, dimension (N) */
/* > The reordered eigenvalues of T, in the same order as they */
/* > appear on the diagonal of T. */
/* > \endverbatim */
/* > */
/* > \param[out] M */
/* > \verbatim */
/* > M is INTEGER */
/* > The dimension of the specified invariant subspace. */
/* > 0 <= M <= N. */
/* > \endverbatim */
/* > */
/* > \param[out] S */
/* > \verbatim */
/* > S is DOUBLE PRECISION */
/* > If JOB = 'E' or 'B', S is a lower bound on the reciprocal */
/* > condition number for the selected cluster of eigenvalues. */
/* > S cannot underestimate the true reciprocal condition number */
/* > by more than a factor of sqrt(N). If M = 0 or N, S = 1. */
/* > If JOB = 'N' or 'V', S is not referenced. */
/* > \endverbatim */
/* > */
/* > \param[out] SEP */
/* > \verbatim */
/* > SEP is DOUBLE PRECISION */
/* > If JOB = 'V' or 'B', SEP is the estimated reciprocal */
/* > condition number of the specified invariant subspace. If */
/* > M = 0 or N, SEP = norm(T). */
/* > If JOB = 'N' or 'E', SEP is not referenced. */
/* > \endverbatim */
/* > */
/* > \param[out] WORK */
/* > \verbatim */
/* > WORK is COMPLEX*16 array, dimension (MAX(1,LWORK)) */
/* > On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */
/* > \endverbatim */
/* > */
/* > \param[in] LWORK */
/* > \verbatim */
/* > LWORK is INTEGER */
/* > The dimension of the array WORK. */
/* > If JOB = 'N', LWORK >= 1; */
/* > if JOB = 'E', LWORK = f2cmax(1,M*(N-M)); */
/* > if JOB = 'V' or 'B', LWORK >= f2cmax(1,2*M*(N-M)). */
/* > */
/* > If LWORK = -1, then a workspace query is assumed; the routine */
/* > only calculates the optimal size of the WORK array, returns */
/* > this value as the first entry of the WORK array, and no error */
/* > message related to LWORK is issued by XERBLA. */
/* > \endverbatim */
/* > */
/* > \param[out] INFO */
/* > \verbatim */
/* > INFO is INTEGER */
/* > = 0: successful exit */
/* > < 0: if INFO = -i, the i-th argument had an illegal value */
/* > \endverbatim */
/* Authors: */
/* ======== */
/* > \author Univ. of Tennessee */
/* > \author Univ. of California Berkeley */
/* > \author Univ. of Colorado Denver */
/* > \author NAG Ltd. */
/* > \date December 2016 */
/* > \ingroup complex16OTHERcomputational */
/* > \par Further Details: */
/* ===================== */
/* > */
/* > \verbatim */
/* > */
/* > ZTRSEN first collects the selected eigenvalues by computing a unitary */
/* > transformation Z to move them to the top left corner of T. In other */
/* > words, the selected eigenvalues are the eigenvalues of T11 in: */
/* > */
/* > Z**H * T * Z = ( T11 T12 ) n1 */
/* > ( 0 T22 ) n2 */
/* > n1 n2 */
/* > */
/* > where N = n1+n2. The first */
/* > n1 columns of Z span the specified invariant subspace of T. */
/* > */
/* > If T has been obtained from the Schur factorization of a matrix */
/* > A = Q*T*Q**H, then the reordered Schur factorization of A is given by */
/* > A = (Q*Z)*(Z**H*T*Z)*(Q*Z)**H, and the first n1 columns of Q*Z span the */
/* > corresponding invariant subspace of A. */
/* > */
/* > The reciprocal condition number of the average of the eigenvalues of */
/* > T11 may be returned in S. S lies between 0 (very badly conditioned) */
/* > and 1 (very well conditioned). It is computed as follows. First we */
/* > compute R so that */
/* > */
/* > P = ( I R ) n1 */
/* > ( 0 0 ) n2 */
/* > n1 n2 */
/* > */
/* > is the projector on the invariant subspace associated with T11. */
/* > R is the solution of the Sylvester equation: */
/* > */
/* > T11*R - R*T22 = T12. */
/* > */
/* > Let F-norm(M) denote the Frobenius-norm of M and 2-norm(M) denote */
/* > the two-norm of M. Then S is computed as the lower bound */
/* > */
/* > (1 + F-norm(R)**2)**(-1/2) */
/* > */
/* > on the reciprocal of 2-norm(P), the true reciprocal condition number. */
/* > S cannot underestimate 1 / 2-norm(P) by more than a factor of */
/* > sqrt(N). */
/* > */
/* > An approximate error bound for the computed average of the */
/* > eigenvalues of T11 is */
/* > */
/* > EPS * norm(T) / S */
/* > */
/* > where EPS is the machine precision. */
/* > */
/* > The reciprocal condition number of the right invariant subspace */
/* > spanned by the first n1 columns of Z (or of Q*Z) is returned in SEP. */
/* > SEP is defined as the separation of T11 and T22: */
/* > */
/* > sep( T11, T22 ) = sigma-f2cmin( C ) */
/* > */
/* > where sigma-f2cmin(C) is the smallest singular value of the */
/* > n1*n2-by-n1*n2 matrix */
/* > */
/* > C = kprod( I(n2), T11 ) - kprod( transpose(T22), I(n1) ) */
/* > */
/* > I(m) is an m by m identity matrix, and kprod denotes the Kronecker */
/* > product. We estimate sigma-f2cmin(C) by the reciprocal of an estimate of */
/* > the 1-norm of inverse(C). The true reciprocal 1-norm of inverse(C) */
/* > cannot differ from sigma-f2cmin(C) by more than a factor of sqrt(n1*n2). */
/* > */
/* > When SEP is small, small changes in T can cause large changes in */
/* > the invariant subspace. An approximate bound on the maximum angular */
/* > error in the computed right invariant subspace is */
/* > */
/* > EPS * norm(T) / SEP */
/* > \endverbatim */
/* > */
/* ===================================================================== */
/* Subroutine */ int ztrsen_(char *job, char *compq, logical *select, integer
*n, doublecomplex *t, integer *ldt, doublecomplex *q, integer *ldq,
doublecomplex *w, integer *m, doublereal *s, doublereal *sep,
doublecomplex *work, integer *lwork, integer *info)
{
/* System generated locals */
integer q_dim1, q_offset, t_dim1, t_offset, i__1, i__2, i__3;
/* Local variables */
integer kase, ierr, k;
doublereal scale;
extern logical lsame_(char *, char *);
integer isave[3], lwmin;
logical wantq, wants;
doublereal rnorm;
integer n1, n2;
doublereal rwork[1];
extern /* Subroutine */ int zlacn2_(integer *, doublecomplex *,
doublecomplex *, doublereal *, integer *, integer *);
integer nn, ks;
extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen);
extern doublereal zlange_(char *, integer *, integer *, doublecomplex *,
integer *, doublereal *);
logical wantbh;
extern /* Subroutine */ int zlacpy_(char *, integer *, integer *,
doublecomplex *, integer *, doublecomplex *, integer *);
logical wantsp;
extern /* Subroutine */ int ztrexc_(char *, integer *, doublecomplex *,
integer *, doublecomplex *, integer *, integer *, integer *,
integer *);
logical lquery;
extern /* Subroutine */ int ztrsyl_(char *, char *, integer *, integer *,
integer *, doublecomplex *, integer *, doublecomplex *, integer *,
doublecomplex *, integer *, doublereal *, integer *);
doublereal est;
/* -- LAPACK computational routine (version 3.7.0) -- */
/* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
/* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
/* December 2016 */
/* ===================================================================== */
/* Decode and test the input parameters. */
/* Parameter adjustments */
--select;
t_dim1 = *ldt;
t_offset = 1 + t_dim1 * 1;
t -= t_offset;
q_dim1 = *ldq;
q_offset = 1 + q_dim1 * 1;
q -= q_offset;
--w;
--work;
/* Function Body */
wantbh = lsame_(job, "B");
wants = lsame_(job, "E") || wantbh;
wantsp = lsame_(job, "V") || wantbh;
wantq = lsame_(compq, "V");
/* Set M to the number of selected eigenvalues. */
*m = 0;
i__1 = *n;
for (k = 1; k <= i__1; ++k) {
if (select[k]) {
++(*m);
}
/* L10: */
}
n1 = *m;
n2 = *n - *m;
nn = n1 * n2;
*info = 0;
lquery = *lwork == -1;
if (wantsp) {
/* Computing MAX */
i__1 = 1, i__2 = nn << 1;
lwmin = f2cmax(i__1,i__2);
} else if (lsame_(job, "N")) {
lwmin = 1;
} else if (lsame_(job, "E")) {
lwmin = f2cmax(1,nn);
}
if (! lsame_(job, "N") && ! wants && ! wantsp) {
*info = -1;
} else if (! lsame_(compq, "N") && ! wantq) {
*info = -2;
} else if (*n < 0) {
*info = -4;
} else if (*ldt < f2cmax(1,*n)) {
*info = -6;
} else if (*ldq < 1 || wantq && *ldq < *n) {
*info = -8;
} else if (*lwork < lwmin && ! lquery) {
*info = -14;
}
if (*info == 0) {
work[1].r = (doublereal) lwmin, work[1].i = 0.;
}
if (*info != 0) {
i__1 = -(*info);
xerbla_("ZTRSEN", &i__1, (ftnlen)6);
return 0;
} else if (lquery) {
return 0;
}
/* Quick return if possible */
if (*m == *n || *m == 0) {
if (wants) {
*s = 1.;
}
if (wantsp) {
*sep = zlange_("1", n, n, &t[t_offset], ldt, rwork);
}
goto L40;
}
/* Collect the selected eigenvalues at the top left corner of T. */
ks = 0;
i__1 = *n;
for (k = 1; k <= i__1; ++k) {
if (select[k]) {
++ks;
/* Swap the K-th eigenvalue to position KS. */
if (k != ks) {
ztrexc_(compq, n, &t[t_offset], ldt, &q[q_offset], ldq, &k, &
ks, &ierr);
}
}
/* L20: */
}
if (wants) {
/* Solve the Sylvester equation for R: */
/* T11*R - R*T22 = scale*T12 */
zlacpy_("F", &n1, &n2, &t[(n1 + 1) * t_dim1 + 1], ldt, &work[1], &n1);
ztrsyl_("N", "N", &c_n1, &n1, &n2, &t[t_offset], ldt, &t[n1 + 1 + (n1
+ 1) * t_dim1], ldt, &work[1], &n1, &scale, &ierr);
/* Estimate the reciprocal of the condition number of the cluster */
/* of eigenvalues. */
rnorm = zlange_("F", &n1, &n2, &work[1], &n1, rwork);
if (rnorm == 0.) {
*s = 1.;
} else {
*s = scale / (sqrt(scale * scale / rnorm + rnorm) * sqrt(rnorm));
}
}
if (wantsp) {
/* Estimate sep(T11,T22). */
est = 0.;
kase = 0;
L30:
zlacn2_(&nn, &work[nn + 1], &work[1], &est, &kase, isave);
if (kase != 0) {
if (kase == 1) {
/* Solve T11*R - R*T22 = scale*X. */
ztrsyl_("N", "N", &c_n1, &n1, &n2, &t[t_offset], ldt, &t[n1 +
1 + (n1 + 1) * t_dim1], ldt, &work[1], &n1, &scale, &
ierr);
} else {
/* Solve T11**H*R - R*T22**H = scale*X. */
ztrsyl_("C", "C", &c_n1, &n1, &n2, &t[t_offset], ldt, &t[n1 +
1 + (n1 + 1) * t_dim1], ldt, &work[1], &n1, &scale, &
ierr);
}
goto L30;
}
*sep = scale / est;
}
L40:
/* Copy reordered eigenvalues to W. */
i__1 = *n;
for (k = 1; k <= i__1; ++k) {
i__2 = k;
i__3 = k + k * t_dim1;
w[i__2].r = t[i__3].r, w[i__2].i = t[i__3].i;
/* L50: */
}
work[1].r = (doublereal) lwmin, work[1].i = 0.;
return 0;
/* End of ZTRSEN */
} /* ztrsen_ */
|
the_stack_data/215767023.c | /*
Copyright (c) 2019 The Mode Group
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
https://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>
#include<stdlib.h>
#include<errno.h>
#include<unistd.h>
#include<string.h>
#include<sys/types.h>
#include<netinet/in.h>
#include<sys/socket.h>
#include<sys/wait.h>
#include<netdb.h>
#include<arpa/inet.h>
#include<time.h>
#include<netinet/tcp.h>
#define BACKLOG 10
#define PORT 53005
#define FILE_NAME "46403o.pdf"
int main()
{
int sockfd, new_fd;
struct sockaddr_in my_addr;
struct sockaddr_in their_addr; /* client's address info */
int sin_size;
char dst[INET_ADDRSTRLEN];
int str_len = 5000;
char str[str_len];
if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1)
{
perror("socket");
exit(1);
}
my_addr.sin_family = AF_INET;
my_addr.sin_port = htons(PORT);
my_addr.sin_addr.s_addr = INADDR_ANY; /* auto-fill with my IP */
bzero(&(my_addr.sin_zero), 8);
if (bind(sockfd,(struct sockaddr *)&my_addr, sizeof(struct sockaddr)) == -1)
{
perror("bind");
exit(1);
}
int qlen = 5;// Value to be chosen by application
setsockopt(sockfd, SOL_TCP, TCP_FASTOPEN, &qlen, sizeof(qlen));
if (listen(sockfd, BACKLOG) == -1)
{
perror("listen");
exit(1);
}
while(1)
{
sin_size = sizeof(struct sockaddr_in);
if ((new_fd = accept(sockfd, (struct sockaddr *)&their_addr, &sin_size)) == -1)
{
perror("accept");
continue;
}
inet_ntop(AF_INET, &(their_addr.sin_addr), dst, INET_ADDRSTRLEN);
printf("Server: got connection from %s\n", dst);
FILE *fd = fopen(FILE_NAME, "wb");
if(fd == NULL)
{
perror("fopen");
}
int n;
while (1)
{
if ((n = recv(new_fd, str, str_len, 0)) == 0)
{
printf("Client has closed connection!\n");
break;
}
fwrite(str, 1, n, fd);
}
printf("Server side closes connection.\n");
fclose(fd);
close(new_fd);
}
close(sockfd);
return 0;
}
|
the_stack_data/216142.c | // Solved 2020-12-25 10:22
// Runtime: 0 ms (100.00%)
// Memory Usage: 5.8 MB (77.66%)
char* addBinary(char* a, char* b) {
int i, sum, la = strlen(a), lb = strlen(b);
if (la < lb) {
int t = la;
la = lb;
lb = t;
char* c = a;
a = b;
b = c;
} // now a is longer
int lans = la + 1;
char* ans = (char*)malloc((lans + 1) * sizeof(char));
ans[lans - 1] = '0';
for (i = 1; i <= lb; i++) {
sum = a[la - i] + b[lb - i] + ans[lans - i] - 144;
// a[la - i] - '0' + b[lb - i] - '0' + ans[lans - i] - '0'
ans[lans - i] = sum % 2 + '0';
ans[lans - i - 1] = sum / 2 + '0';
}
for (; i <= la; i++) {
sum = a[la - i] + ans[lans - i] - 96;
// a[la - i] - '0' + ans[lans - i] - '0'
ans[lans - i] = sum % 2 + '0';
ans[lans - i - 1] = sum / 2 + '0';
}
ans[lans] = '\0';
if (ans[0] == '0') ans++;
return ans;
}
|
the_stack_data/338671.c | /*-
* Copyright (c) 2009 M. Warner Losh.
* 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.
*
*/
#if 0
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
/*
* This file is a place holder for MIPS. Some models of MIPS may need special
* functions here, but for now nothing is needed. The MI parts of ptrace
* suffice.
*/
#endif
|
the_stack_data/19858.c | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_close_fds.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jecaudal <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/07/04 13:41:19 by jecaudal #+# #+# */
/* Updated: 2020/07/04 13:41:29 by jecaudal ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
void ft_close_fds(int *fds, int n)
{
n--;
if (fds)
{
while (n >= 0)
{
close(fds[n]);
n--;
}
}
}
|
the_stack_data/170454131.c | extern unsigned int __VERIFIER_nondet_uint();
extern void abort(void);
void reach_error(){}
unsigned int id(unsigned int x) {
if (x==0) return 0;
return id(x-1) + 1;
}
int main(void) {
unsigned int input = __VERIFIER_nondet_uint();
unsigned int result = id(input);
if (result == 10) {
ERROR: {reach_error();abort();}
}
}
|
the_stack_data/70192.c | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
int N, *arr, res = -1, i = 0, j = 0, sumIzq = 0, sumDer = 0, puntoDeCorte;
fscanf(stdin, "%d", &N);
arr = (int *)malloc(sizeof(int) * N);
while (j < N && fscanf(stdin, "%d", arr + j++) == 1)
;
for (i = 0; i < N; i++)
{
sumDer += arr[i];
}
for (i = 0; i < N; i++)
{
sumDer -= arr[i];
sumIzq += arr[i];
// printf("sumDer = %d - %d = %d\n", sumDer, arr[i], sumDer - arr[i]);
// printf("sumIzq = %d sumDer = %d\n", sumIzq, sumDer);
if (sumDer < 0 && sumIzq > 0)
{
res = i + 1;
break;
}
}
if (res != -1)
{
printf("%d\n", res);
}
else
{
printf("Impossible\n");
}
free(arr);
return 0;
} |
the_stack_data/22012750.c | /*
*
* This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
*
* Copyright 2007-2019 Broadcom Inc. All rights reserved.
*
* File: flow.c
* Purpose: Flex flow match APIs.
*/
#if defined(INCLUDE_L3)
#include <soc/drv.h>
#include <soc/scache.h>
#include <shared/bsl.h>
#include <assert.h>
#include <bcm/types.h>
#include <bcm/error.h>
#include <bcm/flow.h>
#include <bcm_int/esw/flow.h>
#include <soc/esw/flow_db.h>
#include <bcm_int/esw_dispatch.h>
/*
* Function:
* bcm_esw_flow_vpn_create
* Purpose:
* Create an L2/L3 VPN. This is a service plane and is
* independent of the connectivity protocol.
* Parameters:
* unit - (IN) Unit ID.
* info - (IN/OUT) VPN structure
*/
int bcm_esw_flow_vpn_create(int unit,
bcm_vpn_t *vpn,
bcm_flow_vpn_config_t *info)
{
int rv = BCM_E_UNAVAIL;
#if defined(BCM_TRIDENT3_SUPPORT)
if (soc_feature(unit,soc_feature_flex_flow)) {
rv = bcmi_esw_flow_lock(unit);
if (rv == BCM_E_NONE ) {
rv = bcmi_esw_flow_vpn_create(unit, vpn, info);
bcmi_esw_flow_unlock (unit);
}
}
#endif /* defined(BCM_TRIDENT3_SUPPORT) */
return rv;
}
/*
* Function:
* bcm_esw_flow_vpn_destroy
* Purpose:
* Delete L2/L3 VPN
* Parameters:
* unit - (IN) Unit ID.
* vpn - (IN) VPN Id
*/
int bcm_esw_flow_vpn_destroy(int unit, bcm_vpn_t vpn)
{
int rv = BCM_E_UNAVAIL;
#if defined(BCM_TRIDENT3_SUPPORT)
if (soc_feature(unit,soc_feature_flex_flow)) {
rv = bcmi_esw_flow_lock(unit);
if (rv == BCM_E_NONE ) {
rv = bcmi_esw_flow_vpn_destroy(unit, vpn);
bcmi_esw_flow_unlock (unit);
}
}
#endif /* defined(BCM_TRIDENT3_SUPPORT) */
return rv;
}
/*
* Function:
* bcm_esw_flow_vpn_destroy_all
* Purpose:
* Delete all VPN's
* Parameters:
* unit - (IN) Unit ID.
*/
int bcm_esw_flow_vpn_destroy_all(int unit)
{
int rv = BCM_E_UNAVAIL;
#if defined(BCM_TRIDENT3_SUPPORT)
if (soc_feature(unit,soc_feature_flex_flow)) {
rv = bcmi_esw_flow_lock(unit);
if (rv == BCM_E_NONE ) {
rv = bcmi_esw_flow_vpn_destroy_all(unit);
bcmi_esw_flow_unlock (unit);
}
}
#endif /* defined(BCM_TRIDENT3_SUPPORT) */
return rv;
}
/*
* Function:
* bcm_esw_flow_vpn_get
* Purpose:
* Get VPN properties
* Parameters:
* unit - (IN) Unit ID.
* vpn - (IN) VPN Id
* info - (IN/OUT) VPN structure
*/
int bcm_esw_flow_vpn_get(int unit, bcm_vpn_t vpn,
bcm_flow_vpn_config_t *info)
{
int rv = BCM_E_UNAVAIL;
#if defined(BCM_TRIDENT3_SUPPORT)
if (soc_feature(unit,soc_feature_flex_flow)) {
rv = bcmi_esw_flow_lock(unit);
if (rv == BCM_E_NONE ) {
rv = bcmi_esw_flow_vpn_get(unit, vpn, info);
bcmi_esw_flow_unlock (unit);
}
}
#endif /* defined(BCM_TRIDENT3_SUPPORT) */
return rv;
}
/*
* Function:
* bcm_esw_flow_vpn_traverse
* Purpose:
* Traverse VPN's
* Parameters:
* unit - (IN) Unit ID.
* cb - (IN) callback function
* user_data - (IN) User context data
*/
int bcm_esw_flow_vpn_traverse(int unit,
bcm_flow_vpn_traverse_cb cb,
void *user_data)
{
int rv = BCM_E_UNAVAIL;
#if defined(BCM_TRIDENT3_SUPPORT)
if (soc_feature(unit,soc_feature_flex_flow)) {
rv = bcmi_esw_flow_lock(unit);
if (rv == BCM_E_NONE ) {
rv = bcmi_esw_flow_vpn_traverse(unit, cb, user_data);
bcmi_esw_flow_unlock (unit);
}
}
#endif /* defined(BCM_TRIDENT3_SUPPORT) */
return rv;
}
/*
* Function:
* bcm_esw_flow_match_add
* Description:
* Add a match rule to identify traffic flow with certain objects.
* These objects generally will be used in the switchs forwarding process.
* The matching rules comprise of packet fields and/or the port number the
* packet comes in. The identified objects can be VFI,virtual port, interface
* id, flexible objects specified by logical fields, or a combination of them.
*
* Parameters:
* Unit (IN) Unit number
* info (IN) Match info structure
* num_of_fields (IN) Number of logical fields
* field (IN) logical field array
* Return Value:
* BCM_E_XXX
* Notes:
*/
int bcm_esw_flow_match_add(
int unit,
bcm_flow_match_config_t *info,
uint32 num_of_fields,
bcm_flow_logical_field_t *field)
{
#if defined(BCM_TRIDENT3_SUPPORT)
if (soc_feature(unit,soc_feature_flex_flow)) {
return bcmi_esw_flow_match_add(unit, info, num_of_fields, field);
} else
#endif /* defined(BCM_TRIDENT3_SUPPORT) */
{
return BCM_E_UNAVAIL;
}
}
/*
* Function:
* bcm_esw_flow_match_delete
* Description:
* Delete a match rule for the given match_criteria. For the non-flex
* match criteria, the logical field array is not used.
*
* Parameters:
* Unit (IN) Unit number
* info (IN) Match info structure
* num_of_fields (IN) Number of logical fields
* field (IN) logical field array
* Return Value:
* BCM_E_XXX
* Notes:
*/
int bcm_esw_flow_match_delete(
int unit,
bcm_flow_match_config_t *info,
uint32 num_of_fields,
bcm_flow_logical_field_t *field)
{
#if defined(BCM_TRIDENT3_SUPPORT)
if (soc_feature(unit,soc_feature_flex_flow)) {
return bcmi_esw_flow_match_delete(unit, info, num_of_fields, field);
} else
#endif /* defined(BCM_TRIDENT3_SUPPORT) */
{
return BCM_E_UNAVAIL;
}
}
/*
* Function:
* bcm_esw_flow_match_get
* Description:
* Get the match objects and attributes for the given match_criteria.
*
* Parameters:
* Unit (IN) Unit number
* info (IN/OUT) Match info structure
* num_of_fields (IN) Number of logical fields
* field (IN/OUT) logical field array
* Return Value:
* BCM_E_XXX
* Notes:
*/
int bcm_esw_flow_match_get(
int unit,
bcm_flow_match_config_t *info,
uint32 num_of_fields,
bcm_flow_logical_field_t *field)
{
#if defined(BCM_TRIDENT3_SUPPORT)
if (soc_feature(unit,soc_feature_flex_flow)) {
return bcmi_esw_flow_match_get(unit, info, num_of_fields, field);
} else
#endif /* defined(BCM_TRIDENT3_SUPPORT) */
{
return BCM_E_UNAVAIL;
}
}
/*
* Function:
* bcm_esw_flow_match_traverse
* Description:
* Traverse match rules.
*
* Parameters:
* Unit (IN) Unit number
* info (IN) Match info structure
* num_of_fields (IN) Number of logical fields
* field (IN) logical field array
* cb (IN) user callback function
* user_data (IN) User context data
* Return Value:
* BCM_E_XXX
* Notes:
*/
int bcm_esw_flow_match_traverse(
int unit,
bcm_flow_match_traverse_cb cb,
void *user_data)
{
#if defined(BCM_TRIDENT3_SUPPORT)
if (soc_feature(unit,soc_feature_flex_flow)) {
return bcmi_esw_flow_match_traverse(unit,cb,user_data);
} else
#endif /* defined(BCM_TRIDENT3_SUPPORT) */
{
return BCM_E_UNAVAIL;
}
}
/*
* Function:
* bcm_esw_flow_tunnel_initiator_create
* Description:
* creates a tunnel header for packet encapsulation
*
* Parameters:
* Unit (IN) Unit number
* info (IN) tunnel config info structure
* num_of_fields (IN) Number of logical fields
* field (IN) logical field array
* Return Value:
* BCM_E_XXX
* Notes:
*/
int bcm_esw_flow_tunnel_initiator_create(
int unit,
bcm_flow_tunnel_initiator_t *info,
uint32 num_of_fields,
bcm_flow_logical_field_t *field)
{
#if defined(BCM_TRIDENT3_SUPPORT)
if (soc_feature(unit,soc_feature_flex_flow)) {
return bcmi_esw_flow_tunnel_initiator_create(unit, info,
num_of_fields, field);
} else
#endif /* defined(BCM_TRIDENT3_SUPPORT) */
{
return BCM_E_UNAVAIL;
}
}
/*
* Function:
* bcm_esw_flow_tunnel_initiator_destroy
* Description:
* delete a tunnel header entry
*
* Parameters:
* Unit (IN) Unit number
* flow_tunnel_id (IN) tunnel config info structure
* Return Value:
* BCM_E_XXX
* Notes:
*/
int bcm_esw_flow_tunnel_initiator_destroy(
int unit,
bcm_gport_t flow_tunnel_id)
{
#if defined(BCM_TRIDENT3_SUPPORT)
if (soc_feature(unit,soc_feature_flex_flow)) {
return bcmi_esw_flow_tunnel_initiator_destroy(unit,flow_tunnel_id);
} else
#endif /* defined(BCM_TRIDENT3_SUPPORT) */
{
return BCM_E_UNAVAIL;
}
}
/*
* Function:
* bcm_esw_flow_tunnel_initiator_get
* Description:
* Get a tunnel header entry
*
* Parameters:
* Unit (IN) Unit number
* info (IN) tunnel config info structure
* num_of_fields (IN) Number of logical fields
* field (IN) logical field array
* Return Value:
* BCM_E_XXX
* Notes:
*/
int bcm_esw_flow_tunnel_initiator_get(
int unit,
bcm_flow_tunnel_initiator_t *info,
uint32 num_of_fields,
bcm_flow_logical_field_t *field)
{
#if defined(BCM_TRIDENT3_SUPPORT)
if (soc_feature(unit,soc_feature_flex_flow)) {
return bcmi_esw_flow_tunnel_initiator_get(unit, info,
num_of_fields, field);
} else
#endif /* defined(BCM_TRIDENT3_SUPPORT) */
{
return BCM_E_UNAVAIL;
}
}
/*
* Function:
* bcm_esw_flow_tunnel_initiator_traverse
* Description:
* Get a tunnel header entry
*
* Parameters:
* Unit (IN) Unit number
* info (IN) tunnel config info structure
* num_of_fields (IN) Number of logical fields
* field (IN) logical field array
* Return Value:
* BCM_E_XXX
* Notes:
*/
int bcm_esw_flow_tunnel_initiator_traverse(
int unit,
bcm_flow_tunnel_initiator_traverse_cb cb,
void *user_data)
{
#if defined(BCM_TRIDENT3_SUPPORT)
if (soc_feature(unit,soc_feature_flex_flow)) {
return bcmi_esw_flow_tunnel_initiator_traverse(unit,
cb, user_data);
} else
#endif /* defined(BCM_TRIDENT3_SUPPORT) */
{
return BCM_E_UNAVAIL;
}
}
/*
* Function:
* bcm_esw_flow_tunnel_terminator_create
* Description:
* creates a flow tunnel terminator match
*
* Parameters:
* Unit (IN) Unit number
* info (IN) tunnel config info structure
* num_of_fields (IN) Number of logical fields
* field (IN) logical field array
* Return Value:
* BCM_E_XXX
* Notes:
*/
int bcm_esw_flow_tunnel_terminator_create(
int unit,
bcm_flow_tunnel_terminator_t *info,
uint32 num_of_fields,
bcm_flow_logical_field_t *field)
{
#if defined(BCM_TRIDENT3_SUPPORT)
if (soc_feature(unit,soc_feature_flex_flow)) {
return bcmi_esw_flow_tunnel_terminator_create(unit, info,
num_of_fields, field);
} else
#endif /* defined(BCM_TRIDENT3_SUPPORT) */
{
return BCM_E_UNAVAIL;
}
}
/*
* Function:
* bcm_esw_flow_tunnel_terminator_destroy
* Description:
* delete a tunnel termination entry
*
* Parameters:
* Unit (IN) Unit number
* info (IN) tunnel config info structure
* num_of_fields (IN) Number of logical fields
* field (IN) logical field array
* Return Value:
* BCM_E_XXX
* Notes:
*/
int bcm_esw_flow_tunnel_terminator_destroy(
int unit,
bcm_flow_tunnel_terminator_t *info,
uint32 num_of_fields,
bcm_flow_logical_field_t *field)
{
#if defined(BCM_TRIDENT3_SUPPORT)
if (soc_feature(unit,soc_feature_flex_flow)) {
return bcmi_esw_flow_tunnel_terminator_destroy(unit,
info, num_of_fields, field);
} else
#endif /* defined(BCM_TRIDENT3_SUPPORT) */
{
return BCM_E_UNAVAIL;
}
}
/*
* Function:
* bcm_esw_flow_tunnel_terminator_get
* Description:
* Get a tunnel termination entry
*
* Parameters:
* Unit (IN) Unit number
* info (IN) tunnel config info structure
* num_of_fields (IN) Number of logical fields
* field (IN) logical field array
* Return Value:
* BCM_E_XXX
* Notes:
*/
int bcm_esw_flow_tunnel_terminator_get(
int unit,
bcm_flow_tunnel_terminator_t *info,
uint32 num_of_fields,
bcm_flow_logical_field_t *field)
{
#if defined(BCM_TRIDENT3_SUPPORT)
if (soc_feature(unit,soc_feature_flex_flow)) {
return bcmi_esw_flow_tunnel_terminator_get(unit,
info, num_of_fields, field);
} else
#endif /* defined(BCM_TRIDENT3_SUPPORT) */
{
return BCM_E_UNAVAIL;
}
}
/*
* Function:
* bcm_esw_flow_tunnel_terminator_traverse
* Description:
* Get a tunnel termination entry
*
* Parameters:
* Unit (IN) Unit number
* cb (IN) Traverse function
* user_data (IN/OUT) User Data
* Return Value:
* BCM_E_XXX
* Notes:
*/
int bcm_esw_flow_tunnel_terminator_traverse(
int unit,
bcm_flow_tunnel_terminator_traverse_cb cb,
void *user_data)
{
#if defined(BCM_TRIDENT3_SUPPORT)
if (soc_feature(unit,soc_feature_flex_flow)) {
return bcmi_esw_flow_tunnel_terminator_traverse(unit,
cb, user_data);
} else
#endif /* defined(BCM_TRIDENT3_SUPPORT) */
{
return BCM_E_UNAVAIL;
}
}
/*
* Function:
* bcm_esw_flow_port_encap_set
* Description:
* For given DVP, bind the egress object and tunnel initiator with
* the DVP and program DVP related encap data for L2 tunnel.
*
* Parameters:
* Unit (IN) Unit number
* info (IN) egress encap info structure
* num_of_fields (IN) Number of logical fields
* field (IN) logical field array
* Return Value:
* BCM_E_XXX
* Notes:
*/
int bcm_esw_flow_port_encap_set(
int unit,
bcm_flow_port_encap_t *info,
uint32 num_of_fields,
bcm_flow_logical_field_t *field)
{
#if defined(BCM_TRIDENT3_SUPPORT)
if (soc_feature(unit,soc_feature_flex_flow)) {
return bcmi_esw_flow_port_encap_set(unit, info,
num_of_fields, field);
} else
#endif /* defined(BCM_TRIDENT3_SUPPORT) */
{
return BCM_E_UNAVAIL;
}
}
/*
* Function:
* bcm_esw_flow_port_encap_get
* Description:
* Get the encap configuration info for the given DVP
*
* Parameters:
* Unit (IN) Unit number
* info (IN/OUT) egress encap info structure
* num_of_fields (IN) Number of logical fields
* field (IN/OUT) logical field array
* Return Value:
* BCM_E_XXX
* Notes:
*/
int bcm_esw_flow_port_encap_get(
int unit,
bcm_flow_port_encap_t *info,
uint32 num_of_fields,
bcm_flow_logical_field_t *field)
{
#if defined(BCM_TRIDENT3_SUPPORT)
if (soc_feature(unit,soc_feature_flex_flow)) {
return bcmi_esw_flow_port_encap_get(unit, info,
num_of_fields, field);
} else
#endif /* defined(BCM_TRIDENT3_SUPPORT) */
{
return BCM_E_UNAVAIL;
}
}
/*
* Function:
* bcm_esw_flow_encap_add
* Description:
* add the object(key) based encapsulation data to the packet. The objects
* can be VP,VFI,VRF,interface ID, specified by logical fields, or combination
* of them. The encapsulation data comprises of fields in the
* bcm_flow_encap_config_t and/or logical fields
*
* Parameters:
* Unit (IN) Unit number
* info (IN) encap config info structure
* num_of_fields (IN) Number of logical fields
* field (IN) logical field array
* Return Value:
* BCM_E_XXX
* Notes:
*/
int bcm_esw_flow_encap_add(
int unit,
bcm_flow_encap_config_t *info,
uint32 num_of_fields,
bcm_flow_logical_field_t *field)
{
#if defined(BCM_TRIDENT3_SUPPORT)
if (soc_feature(unit,soc_feature_flex_flow)) {
return bcmi_esw_flow_encap_add(unit, info,
num_of_fields, field);
} else
#endif /* defined(BCM_TRIDENT3_SUPPORT) */
{
return BCM_E_UNAVAIL;
}
}
/*
* Function:
* bcm_esw_flow_encap_delete
* Description:
* Delete the object(key) based encapsulation data.
*
* Parameters:
* Unit (IN) Unit number
* info (IN) encap config info structure
* num_of_fields (IN) Number of logical fields
* field (IN) logical field array
* Return Value:
* BCM_E_XXX
* Notes:
*/
int bcm_esw_flow_encap_delete(
int unit,
bcm_flow_encap_config_t *info,
uint32 num_of_fields,
bcm_flow_logical_field_t *field)
{
#if defined(BCM_TRIDENT3_SUPPORT)
if (soc_feature(unit,soc_feature_flex_flow)) {
return bcmi_esw_flow_encap_delete(unit, info,
num_of_fields, field);
} else
#endif /* defined(BCM_TRIDENT3_SUPPORT) */
{
return BCM_E_UNAVAIL;
}
}
/*
* Function:
* bcm_esw_flow_encap_get
* Description:
* Get the object(key) based encapsulation data.
*
* Parameters:
* Unit (IN) Unit number
* info (IN/OUT) encap config info structure
* num_of_fields (IN) Number of logical fields
* field (IN/OUT) logical field array
* Return Value:
* BCM_E_XXX
* Notes:
*/
int bcm_esw_flow_encap_get(
int unit,
bcm_flow_encap_config_t *info,
uint32 num_of_fields,
bcm_flow_logical_field_t *field)
{
#if defined(BCM_TRIDENT3_SUPPORT)
if (soc_feature(unit,soc_feature_flex_flow)) {
return bcmi_esw_flow_encap_get(unit, info,
num_of_fields, field);
} else
#endif /* defined(BCM_TRIDENT3_SUPPORT) */
{
return BCM_E_UNAVAIL;
}
}
/*
* Function:
* bcm_esw_flow_encap_traverse
* Description:
* Traverse the object(key) based encapsulation data entries.
*
* Parameters:
* Unit (IN) Unit number
* info (IN) encap config info structure
* num_of_fields (IN) Number of logical fields
* field (IN) logical field array
* cb (IN) user callback function
* user_data (IN) user context data
* Return Value:
* BCM_E_XXX
* Notes:
*/
int bcm_esw_flow_encap_traverse(
int unit,
bcm_flow_encap_traverse_cb cb,
void *user_data)
{
#if defined(BCM_TRIDENT3_SUPPORT)
if (soc_feature(unit,soc_feature_flex_flow)) {
return bcmi_esw_flow_encap_traverse(unit,cb,user_data);
} else
#endif /* defined(BCM_TRIDENT3_SUPPORT) */
{
return BCM_E_UNAVAIL;
}
}
/*
* Function:
* bcm_esw_flow_init
* Purpose:
* Init FLOW module
* Parameters:
* IN : unit
* Returns:
* BCM_E_XXX
*/
int
bcm_esw_flow_init(int unit)
{
#if defined(BCM_TRIDENT3_SUPPORT)
if (soc_feature(unit, soc_feature_flex_flow)) {
return bcmi_esw_flow_init(unit);
}
#endif /* BCM_TRIDENT3_SUPPORT */
return BCM_E_UNAVAIL;
}
/* Function:
* bcm_esw_flow_cleanup
* Purpose:
* Detach the FLOW module, clear all HW states
* Parameters:
* unit - Device Number
* Returns:
* BCM_E_XXXX
*/
int
bcm_esw_flow_cleanup(int unit)
{
#if defined(BCM_TRIDENT3_SUPPORT)
if (soc_feature(unit, soc_feature_flex_flow)) {
return bcmi_esw_flow_cleanup(unit);
}
#endif /* BCM_TRIDENT3_SUPPORT */
return BCM_E_UNAVAIL;
}
/*
* Function:
* bcm_esw_flow_port_create
* Purpose:
* Create and add a Access/Network Flow port to L2 VPN
* Parameters:
* unit - (IN) Unit ID.
* info - (IN/OUT) VP properties
*/
int
bcm_esw_flow_port_create(int unit,
bcm_vpn_t l2vpn,
bcm_flow_port_t *flow_port)
{
int rv = BCM_E_UNAVAIL;
#if defined(BCM_TRIDENT3_SUPPORT)
if (soc_feature(unit, soc_feature_flex_flow)) {
if (flow_port == NULL) {
return BCM_E_PARAM;
}
rv = bcmi_esw_flow_lock(unit);
if ( rv == BCM_E_NONE ) {
rv = bcmi_esw_flow_port_create(unit, l2vpn, flow_port);
bcmi_esw_flow_unlock (unit);
}
}
#endif
return rv;
}
/* Function:
* bcm_esw_flow_port_destroy
* Purpose:
* Destroy Access/Network FLOW port
* Parameters:
* unit - Device Number
* l2vpn - FLOW VPN
* flow_port_id - FLOW Gport Id
* Returns:
* BCM_E_XXXX
*/
int
bcm_esw_flow_port_destroy( int unit, bcm_vpn_t l2vpn, bcm_gport_t flow_port_id)
{
int rv = BCM_E_UNAVAIL;
#if defined(BCM_TRIDENT3_SUPPORT)
if (soc_feature(unit, soc_feature_flex_flow)) {
rv = bcmi_esw_flow_lock(unit);
if ( rv == BCM_E_NONE ) {
rv = bcmi_esw_flow_port_destroy(unit, l2vpn, flow_port_id);
bcmi_esw_flow_unlock (unit);
}
}
#endif
return rv;
}
/* Function:
* bcm_esw_flow_port_get
* Purpose:
* Get Access/Network FLOW port info
* Parameters:
* unit - Device Number
* l2vpn - FLOW VPN
* flow_port - FLOW Gport
* Returns:
* BCM_E_XXXX
*/
int
bcm_esw_flow_port_get(int unit, bcm_vpn_t l2vpn, bcm_flow_port_t *flow_port)
{
int rv = BCM_E_UNAVAIL;
#if defined(BCM_TRIDENT3_SUPPORT)
if (soc_feature(unit, soc_feature_flex_flow)) {
if (flow_port == NULL) {
return BCM_E_PARAM;
}
rv = bcmi_esw_flow_lock(unit);
if ( rv == BCM_E_NONE ) {
rv = bcmi_esw_flow_port_get(unit, l2vpn, flow_port);
bcmi_esw_flow_unlock (unit);
}
}
#endif
return rv;
}
/* Function:
* bcm_esw_flow_port_get_all
* Purpose:
* Get all Access/Network FLOW port info
* Parameters:
* unit - (IN) Device Number
* l2vpn - FLOW VPN
* port_max - (IN) Maximum number of FLOW ports in array
* port_array - (OUT) Array of FLOW ports
* port_count - (OUT) Number of FLOW ports returned in array
* Returns:
* BCM_E_XXXX
*/
int
bcm_esw_flow_port_get_all(
int unit,
bcm_vpn_t l2vpn,
int port_max,
bcm_flow_port_t *port_array,
int *port_count)
{
int rv = BCM_E_UNAVAIL;
#if defined(BCM_TRIDENT3_SUPPORT)
if (soc_feature(unit, soc_feature_flex_flow)) {
if (port_count == NULL) {
return BCM_E_PARAM;
}
rv = bcmi_esw_flow_lock(unit);
if ( rv == BCM_E_NONE ) {
rv = bcmi_esw_flow_port_get_all(unit, l2vpn, port_max, port_array, port_count);
bcmi_esw_flow_unlock (unit);
}
}
#endif
return rv;
}
/*
* Function:
* bcm_esw_flow_handle_get
* Description:
* Get the handle for the flow name.
* Parameters:
* Unit (IN) Unit number.
* flow_name (IN) Flow Name.
* handle (IN/OUT) Flow Handle.
* Return Value:
* BCM_E_XXX
* Notes:
*/
int bcm_esw_flow_handle_get(
int unit,
const char *flow_name,
bcm_flow_handle_t *handle)
{
#if defined(BCM_TRIDENT3_SUPPORT)
if (soc_feature(unit,soc_feature_flex_flow)) {
return soc_flow_db_flow_handle_get(unit, flow_name, handle);
} else
#endif /* defined(BCM_TRIDENT3_SUPPORT) */
{
return BCM_E_UNAVAIL;
}
}
/*
* Function:
* bcm_esw_flow_option_id_get
* Description:
* Get the option id for flow option name.
* Parameters:
* Unit (IN) Unit number.
* handle (IN) Flow Handle.
* flow_option_name (IN) Flow Option Name.
* option_id (IN/OUT) Flow Option ID.
* Return Value:
* BCM_E_XXX
* Notes:
*/
int bcm_esw_flow_option_id_get(
int unit,
bcm_flow_handle_t flow_handle,
const char *flow_option_name,
bcm_flow_option_id_t *option_id)
{
#if defined(BCM_TRIDENT3_SUPPORT)
if (soc_feature(unit,soc_feature_flex_flow)) {
return soc_flow_db_flow_option_id_get(unit, flow_handle,
flow_option_name,
option_id);
} else
#endif /* defined(BCM_TRIDENT3_SUPPORT) */
{
return BCM_E_UNAVAIL;
}
}
/*
* Function:
* bcm_esw_flow_field_id_get
* Description:
* Get the field id for logical field name in a flow.
* Parameters:
* Unit (IN) Unit number.
* flow_handle (IN) Flow Handle.
* flow_option_name (IN) Flow Option Name.
* option_id (IN/OUT) Flow Option ID.
* Return Value:
* BCM_E_XXX
* Notes:
*/
int bcm_esw_flow_logical_field_id_get(
int unit,
bcm_flow_handle_t flow_handle,
const char *field_name,
bcm_flow_field_id_t *field_id)
{
#if defined(BCM_TRIDENT3_SUPPORT)
if (soc_feature(unit,soc_feature_flex_flow)) {
return soc_flow_db_mem_view_logical_field_id_get(unit, flow_handle,
field_name,
field_id);
} else
#endif /* defined(BCM_TRIDENT3_SUPPORT) */
{
return BCM_E_UNAVAIL;
}
}
/*
* Function:
* bcm_esw_flow_stat_object_get
* Purpose:
* Get the accounting stat object associated
* with the flex view of the table.
* Parameters:
* unit - (IN) unit number.
* flow_handle - (IN) flow handle.
* flow_option_id - (IN) flow option id.
* flow_function_type - (IN) flow function type.
* stat object - (IN/OUT) Stat accounting object.
*
* Returns:
* BCM_E_XXX
*
* Notes:
*/
int bcm_esw_flow_stat_object_get(int unit,
bcm_flow_handle_t flow_handle,
bcm_flow_option_id_t flow_option_id,
bcm_flow_function_type_t function_type,
bcm_stat_object_t *stat_object)
{
#if defined(BCM_TRIDENT3_SUPPORT)
if (soc_feature(unit,soc_feature_flex_flow)) {
if (!soc_feature(unit,soc_feature_advanced_flex_counter)) {
return BCM_E_UNAVAIL;
}
return bcmi_esw_flow_stat_object_get(unit, flow_handle,
flow_option_id, function_type,
stat_object);
} else
#endif /* defined(BCM_TRIDENT3_SUPPORT) */
{
return BCM_E_UNAVAIL;
}
}
/*
* Function:
* bcm_esw_flow_stat_attach
* Purpose:
* Attach counter entries to the given flex view table.
* Parameters:
* unit - (IN) unit number.
* flow_stat_info - (IN) flow stat config structure.
* num_of_fields - (IN) number of logical fields.
* field - (IN) logical fields.
* stat_counter_id - (IN) stat counter id.
*
* Returns:
* BCM_E_XXX
*
* Notes:
*/
int bcm_esw_flow_stat_attach(int unit,
bcm_flow_stat_info_t *flow_stat_info,
uint32 num_of_fields,
bcm_flow_logical_field_t *field,
uint32 stat_counter_id)
{
#if defined(BCM_TRIDENT3_SUPPORT)
if (soc_feature(unit,soc_feature_flex_flow)) {
if (!soc_feature(unit,soc_feature_advanced_flex_counter)) {
return BCM_E_UNAVAIL;
}
if (NULL == flow_stat_info) {
return BCM_E_PARAM;
}
return bcmi_esw_flow_stat_attach(unit, flow_stat_info,
num_of_fields, field,
stat_counter_id);
} else
#endif /* defined(BCM_TRIDENT3_SUPPORT) */
{
return BCM_E_UNAVAIL;
}
}
/*
* Function:
* bcm_esw_flow_stat_detach
* Purpose:
* Detach counter entries to the given flex view table.
* Parameters:
* unit - (IN) unit number.
* flow_stat_info - (IN) flow stat config structure.
* num_of_fields - (IN) number of logical fields.
* field - (IN) logical fields.
* stat_counter_id - (IN) stat counter id.
*
* Returns:
* BCM_E_XXX
*
* Notes:
*/
int bcm_esw_flow_stat_detach(int unit,
bcm_flow_stat_info_t *flow_stat_info,
uint32 num_of_fields,
bcm_flow_logical_field_t *field,
uint32 stat_counter_id)
{
#if defined(BCM_TRIDENT3_SUPPORT)
if (soc_feature(unit,soc_feature_flex_flow)) {
if (!soc_feature(unit,soc_feature_advanced_flex_counter)) {
return BCM_E_UNAVAIL;
}
if (NULL == flow_stat_info) {
return BCM_E_PARAM;
}
return bcmi_esw_flow_stat_detach(unit, flow_stat_info,
num_of_fields, field, stat_counter_id);
} else
#endif /* defined(BCM_TRIDENT3_SUPPORT) */
{
return BCM_E_UNAVAIL;
}
}
/*
* Function:
* bcm_esw_flow_stat_id_get
* Purpose:
* Get Stat Counter if associated with flex view.
* Parameters:
* unit - (IN) unit number.
* flow_stat_info - (IN) flow stat config structure.
* num_of_fields - (IN) number of logical fields.
* field - (IN) logical fields.
* stat_object - (IN) stat object.
* stat_counter_id - (IN/OUT) stat counter id.
*
* Returns:
* BCM_E_XXX
*
* Notes:
*/
int bcm_esw_flow_stat_id_get(int unit,
bcm_flow_stat_info_t *flow_stat_info,
uint32 num_of_fields,
bcm_flow_logical_field_t *field,
bcm_stat_object_t stat_object,
uint32 *stat_counter_id)
{
#if defined(BCM_TRIDENT3_SUPPORT)
if (soc_feature(unit,soc_feature_flex_flow)) {
if (!soc_feature(unit,soc_feature_advanced_flex_counter)) {
return BCM_E_UNAVAIL;
}
if (NULL == flow_stat_info) {
return BCM_E_PARAM;
}
if (NULL == stat_counter_id) {
return BCM_E_PARAM;
}
return bcmi_esw_flow_stat_id_get(unit, flow_stat_info,
num_of_fields, field,
stat_object,
stat_counter_id);
} else
#endif /* defined(BCM_TRIDENT3_SUPPORT) */
{
return BCM_E_UNAVAIL;
}
}
/*
* Function:
* _bcm_esw_flow_port_source_vp_lag_set
* Purpose:
* Set source VP LAG for a flow virtual port.
* Parameters:
* unit - (IN) SOC unit number.
* gport - (IN) flow virtual port GPORT ID.
* vp_lag_vp - (IN) VP representing the VP LAG.
* Returns:
* BCM_X_XXX
*/
int
_bcm_esw_flow_port_source_vp_lag_set(
int unit, bcm_gport_t gport, int vp_lag_vp)
{
int rv = BCM_E_UNAVAIL;
#if defined(BCM_TRIDENT3_SUPPORT)
if (soc_feature(unit, soc_feature_flex_flow) &&
soc_feature(unit, soc_feature_vp_lag)) {
if (!_SHR_GPORT_IS_FLOW_PORT(gport)) {
return BCM_E_PARAM;
}
rv = bcmi_esw_flow_match_svp_replace(unit, gport, vp_lag_vp);
} else
#endif /* defined(BCM_TRIDENT3_SUPPORT) */
{
return BCM_E_UNAVAIL;
}
return rv;
}
/*
* Function:
* _bcm_esw_flow_port_source_vp_lag_clear
* Purpose:
* Set source VP LAG for a flow virtual port.
* Parameters:
* unit - (IN) SOC unit number.
* gport - (IN) flow virtual port GPORT ID.
* vp_lag_vp - (IN) VP representing the VP LAG.
* Returns:
* BCM_X_XXX
*/
int
_bcm_esw_flow_port_source_vp_lag_clear(
int unit, bcm_gport_t gport, int vp_lag_vp)
{
int rv = BCM_E_UNAVAIL;
#if defined(BCM_TRIDENT3_SUPPORT)
int vp;
if (soc_feature(unit, soc_feature_flex_flow) &&
soc_feature(unit, soc_feature_vp_lag)) {
if (!_SHR_GPORT_IS_FLOW_PORT(gport)) {
return BCM_E_PARAM;
}
vp = _SHR_GPORT_FLOW_PORT_ID_GET(gport);
rv = bcmi_esw_flow_match_svp_replace(unit, gport, vp);
} else
#endif /* defined(BCM_TRIDENT3_SUPPORT) */
{
return BCM_E_UNAVAIL;
}
return rv;
}
/*
* Function:
* _bcm_esw_flow_port_source_vp_lag_get
* Purpose:
* Set source VP LAG for a flow virtual port.
* Parameters:
* unit - (IN) SOC unit number.
* gport - (IN) flow virtual port GPORT ID.
* vp_lag_vp - (IN) PTR of VP representing the VP LAG.
* Returns:
* BCM_X_XXX
*/
int
_bcm_esw_flow_port_source_vp_lag_get(
int unit, bcm_gport_t gport, int* vp_lag_vp)
{
int rv = BCM_E_UNAVAIL;
#if defined(BCM_TRIDENT3_SUPPORT)
if (soc_feature(unit, soc_feature_flex_flow) &&
soc_feature(unit, soc_feature_vp_lag)) {
if (!_SHR_GPORT_IS_FLOW_PORT(gport)) {
return BCM_E_PARAM;
}
rv = bcmi_esw_flow_match_svp_get(unit, gport, vp_lag_vp);
} else
#endif /* defined(BCM_TRIDENT3_SUPPORT) */
{
return BCM_E_UNAVAIL;
}
return rv;
}
#else /* INCLUDE_L3 */
int bcm_esw_flow_not_empty;
#endif /* INCLUDE_L3 */
|
the_stack_data/49410.c | // My first c application =)
#include <stdio.h>
main()
{
printf("Hello, World\n");
} |
the_stack_data/167329707.c | #include <stdio.h>
#include <stdarg.h>
void print(int num,...)
{
int i=0;
va_list li;
va_start(li,num);
for(i=0;i<num;++i)
{
printf("%d ",va_arg(li,int));
}
puts("");
va_end(li);
va_start(li,num);
for(i=0;i<num;++i)
{
printf("%d ",va_arg(li,int));
}
puts("");
va_end(li);
}
int main()
{
print(3,1,2,3);
return 0;
}
|
the_stack_data/175144553.c | /***************************************************
* fortune.c
* Author: Aline Normoyle
* Author: Keith Mburu
* Print fortune
*/
#include <stdio.h>
int main() {
printf("Actions speak louder than words\n");
return 0;
}
|
the_stack_data/521043.c | #include <curses.h>
#include <err.h>
#include <signal.h>
#include <stdlib.h>
void quit(void) {
endwin();
exit(EXIT_SUCCESS);
}
void cerr(const char *fmt, ...) {
endwin();
va_list args;
va_start(args, fmt);
verr(EXIT_FAILURE, fmt, args);
va_end(args);
}
void cerrx(const char *fmt, ...) {
endwin();
va_list args;
va_start(args, fmt);
verrx(EXIT_FAILURE, fmt, args);
va_end(args);
}
void handler(int sig) {
switch (sig) {
case SIGTERM:
case SIGINT:
quit();
case SIGWINCH:
cerrx("Unable to resize terminal");
}
}
void handle_signals(void) {
struct sigaction act;
act.sa_handler = handler;
act.sa_flags = 0;
sigemptyset(&act.sa_mask);
sigaction(SIGTERM, &act, NULL);
sigaction(SIGINT, &act, NULL);
sigaction(SIGWINCH, &act, NULL);
}
|
the_stack_data/237644554.c | #include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <sys/stat.h>
int main()
{
int fd = open("testfile.txt", O_RDWR | O_CREAT);
char *s = "MY STR\0ING";
write (fd, s, 10);
close(fd);
struct stat st;
stat("testfile.txt", &st);
printf("%d %llu %hu %hu %u %u %d %lld\n", st.st_dev, st.st_ino, st.st_mode, st.st_nlink, st.st_uid, st.st_gid, st.st_rdev, st.st_size);
}
|
the_stack_data/140229.c | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
typedef struct binary_tree bt;
typedef struct avl_tree avl;
// ### ABB ###
struct binary_tree
{
int item;
bt *left;
bt *right;
};
bt *create_bt(int item, bt *left, bt *right)
{
bt *new_bt = (bt*) malloc(sizeof(bt));
new_bt->item = item;
new_bt->left = left;
new_bt->right = right;
return new_bt;
}
bt *add_leaf_bt(bt *tree, int item)
{
if(tree == NULL)
{
tree = create_bt(item, NULL, NULL);
}
else if(tree->item > item)
{
tree->left = add_leaf_bt(tree->left, item);
}
else
{
tree->right = add_leaf_bt(tree->right, item);
}
return tree;
}
// ### AVL ###
struct avl_tree
{
int item;
int h;
avl *left;
avl *right;
};
int max(int a, int b)
{
return (a > b) ? a : b;
}
int height(avl *tree)
{
if(tree == NULL)
{
return -1;
}
else
{
return 1 + max(height(tree->left), height(tree->right));
}
}
avl *create_avl(int item, avl *left, avl *right)
{
avl *new_avl = (avl*)malloc(sizeof(avl));
new_avl->item = item;
new_avl->left = left;
new_avl->right = right;
new_avl->h = height(new_avl);
return new_avl;
}
avl *rotate_left(avl *tree)
{
avl *subtree_root = NULL;
if(tree != NULL && tree->right != NULL)
{
subtree_root = tree->right;
tree->right = subtree_root->left;
subtree_root->left = tree;
}
subtree_root->h = height(subtree_root);
tree->h = height(tree);
return subtree_root;
}
avl *rotate_right(avl *tree)
{
avl *subtree_root = NULL;
if(tree != NULL & tree->left != NULL)
{
subtree_root = tree->left;
tree->left = subtree_root->right;
subtree_root->right = tree;
}
subtree_root->h = height(subtree_root);
tree->h = height(tree);
return subtree_root;
}
int balance_factor(avl *tree)
{
if(tree != NULL)
{
return (height(tree->left) - height(tree->right));
}
return 0;
}
avl *add_leaf_avl(avl *tree, int item)
{
if(tree == NULL)
{
return create_avl(item, NULL, NULL);
}
else if(tree->item > item)
{
tree->left = add_leaf_avl(tree->left, item);
}
else
{
tree->right = add_leaf_avl(tree->right, item);
}
tree->h = height(tree);
avl *child;
if(balance_factor(tree) == 2 || balance_factor(tree) == -2)
{
if(balance_factor(tree) == 2)
{
child = tree->left;
if(balance_factor(child) == -1)
{
tree->left = rotate_left(child);
}
tree = rotate_right(tree);
}
else if(balance_factor(tree) == -2)
{
child = tree->right;
if(balance_factor(child) == 1)
{
tree->right = rotate_right(child);
}
tree = rotate_left(tree);
}
}
return tree;
}
int ABB_AVL_counter(avl *tree, int item)
{
if(tree == NULL || tree->item == item)
{
return 1;
}
else if(tree->item > item)
{
return 1 + ABB_AVL_counter(tree->left, item);
}
else
{
return 1 + ABB_AVL_counter(tree->right, item);
}
}
int main()
{
bt *binary_tree = NULL;
avl *tree = NULL;
FILE *Comp_Data = NULL;
Comp_Data = fopen("Comp_Data.txt", "w");
fprintf(Comp_Data, "%s\t%s\t%s\t%s\n", "Comparações_AVL", "Tamanho_AVL", "Comparações_ABB", "Tamanho_ABB");
int i, x, index, array_size, counter;
int countAVL = 0, countABB = 0;
srand(time(NULL));
printf("Insira o tamanho do array:\t");
scanf("%d", &array_size);
printf("Insira quantas buscas deve-se fazer\t");
scanf("%d", &counter);
int *array = (int*)malloc(sizeof(int) * array_size);
int *array_visited = (int*)calloc(array_size, sizeof(int));
for(i = 0; i < array_size; i++)
{
x = rand();
array[i] = x;
binary_tree = add_leaf_bt(binary_tree, x);
tree = add_leaf_avl(tree, x);
}
for(i = 0; i < counter; i++)
{
index = rand() % array_size;
if(!array_visited[index])
{
countABB = ABB_AVL_counter(binary_tree, array[index]);
countAVL = ABB_AVL_counter(tree, array[index]);
array_visited[index] = 1;
fprintf(Comp_Data, "%d\t%d\t%d\t%d\n", countAVL, index+1, countABB, index+1);
}
}
free(array);
free(array_visited);
return 0;
} |
the_stack_data/48798.c | /**
******************************************************************************
* @file stm32g0xx_ll_ucpd.c
* @author MCD Application Team
* @brief UCPD LL module driver.
******************************************************************************
* @attention
*
* <h2><center>© Copyright (c) 2018 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 "stm32g0xx_ll_ucpd.h"
#include "stm32g0xx_ll_bus.h"
#include "stm32g0xx_ll_rcc.h"
#ifdef USE_FULL_ASSERT
#include "stm32_assert.h"
#else
#define assert_param(expr) ((void)0U)
#endif
/** @addtogroup STM32G0xx_LL_Driver
* @{
*/
#if defined (UCPD1) || defined (UCPD2)
/** @addtogroup UCPD_LL
* @{
*/
/* Private types -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private constants ---------------------------------------------------------*/
/** @defgroup UCPD_LL_Private_Constants UCPD Private Constants
* @{
*/
/**
* @}
*/
/* Private macros ------------------------------------------------------------*/
/** @defgroup UCPD_LL_Private_Macros UCPD Private Macros
* @{
*/
/**
* @}
*/
/* Private function prototypes -----------------------------------------------*/
/* Exported functions --------------------------------------------------------*/
/** @addtogroup UCPD_LL_Exported_Functions
* @{
*/
/** @addtogroup UCPD_LL_EF_Init
* @{
*/
/**
* @brief De-initialize the UCPD registers to their default reset values.
* @param UCPDx ucpd Instance
* @retval An ErrorStatus enumeration value:
* - SUCCESS: ucpd registers are de-initialized
* - ERROR: ucpd registers are not de-initialized
*/
ErrorStatus LL_UCPD_DeInit(UCPD_TypeDef *UCPDx)
{
ErrorStatus status = ERROR;
/* Check the parameters */
assert_param(IS_UCPD_ALL_INSTANCE(UCPDx));
LL_UCPD_Disable(UCPDx);
if (UCPD1 == UCPDx)
{
/* Force reset of ucpd clock */
LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_UCPD1);
/* Release reset of ucpd clock */
LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_UCPD1);
/* Disbale ucpd clock */
LL_APB1_GRP1_DisableClock(LL_APB1_GRP1_PERIPH_UCPD1);
status = SUCCESS;
}
if (UCPD2 == UCPDx)
{
/* Force reset of ucpd clock */
LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_UCPD2);
/* Release reset of ucpd clock */
LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_UCPD2);
/* Disbale ucpd clock */
LL_APB1_GRP1_DisableClock(LL_APB1_GRP1_PERIPH_UCPD2);
status = SUCCESS;
}
return status;
}
/**
* @brief Initialize the ucpd registers according to the specified parameters in UCPD_InitStruct.
* @note As some bits in ucpd configuration registers can only be written when the ucpd is disabled (ucpd_CR1_SPE bit =0),
* UCPD peripheral should be in disabled state prior calling this function. Otherwise, ERROR result will be returned.
* @param UCPDx UCPD Instance
* @param UCPD_InitStruct pointer to a @ref LL_UCPD_InitTypeDef structure that contains
* the configuration information for the UCPD peripheral.
* @retval An ErrorStatus enumeration value. (Return always SUCCESS)
*/
ErrorStatus LL_UCPD_Init(UCPD_TypeDef *UCPDx, LL_UCPD_InitTypeDef *UCPD_InitStruct)
{
/* Check the ucpd Instance UCPDx*/
assert_param(IS_UCPD_ALL_INSTANCE(UCPDx));
if(UCPD1 == UCPDx)
{
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_UCPD1);
}
if(UCPD2 == UCPDx)
{
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_UCPD2);
}
LL_UCPD_Disable(UCPDx);
/*---------------------------- UCPDx CFG1 Configuration ------------------------*/
MODIFY_REG(UCPDx->CFG1,
UCPD_CFG1_PSC_UCPDCLK | UCPD_CFG1_TRANSWIN | UCPD_CFG1_IFRGAP | UCPD_CFG1_HBITCLKDIV,
UCPD_InitStruct->psc_ucpdclk | (UCPD_InitStruct->transwin << UCPD_CFG1_TRANSWIN_Pos) |
(UCPD_InitStruct->IfrGap << UCPD_CFG1_IFRGAP_Pos) | UCPD_InitStruct->HbitClockDiv);
return SUCCESS;
}
/**
* @brief Set each @ref LL_UCPD_InitTypeDef field to default value.
* @param UCPD_InitStruct pointer to a @ref LL_UCPD_InitTypeDef structure
* whose fields will be set to default values.
* @retval None
*/
void LL_UCPD_StructInit(LL_UCPD_InitTypeDef *UCPD_InitStruct)
{
/* Set UCPD_InitStruct fields to default values */
UCPD_InitStruct->psc_ucpdclk = LL_UCPD_PSC_DIV1;
UCPD_InitStruct->transwin = 0x7; /* Divide by 8 */
UCPD_InitStruct->IfrGap = 0x10; /* Divide by 17 */
UCPD_InitStruct->HbitClockDiv = 0x19; /* Divide by 26 to produce HBITCLK */
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#endif /* defined (UCPD1) || defined (UCPD2) */
/**
* @}
*/
#endif /* USE_FULL_LL_DRIVER */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
the_stack_data/151706346.c | /*
*******************************************************************************
* Copyright (c) 2020-2021, STMicroelectronics
* All rights reserved.
*
* 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(ARDUINO_GENERIC_L452RETXP)
#include "pins_arduino.h"
/**
* @brief System Clock Configuration
* @param None
* @retval None
*/
WEAK void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {};
RCC_PeriphCLKInitTypeDef PeriphClkInit = {};
/*
* Initializes the RCC Oscillators according to the specified parameters
* in the RCC_OscInitTypeDef structure.
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI48 | RCC_OSCILLATORTYPE_MSI;
RCC_OscInitStruct.HSI48State = RCC_HSI48_ON;
RCC_OscInitStruct.MSIState = RCC_MSI_ON;
RCC_OscInitStruct.MSICalibrationValue = 0;
RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_6;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_MSI;
RCC_OscInitStruct.PLL.PLLM = 1;
RCC_OscInitStruct.PLL.PLLN = 40;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV7;
RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2;
RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
Error_Handler();
}
/* Initializes the CPU, AHB and APB buses clocks */
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK
| RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK) {
Error_Handler();
}
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB;
PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_HSI48;
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) {
Error_Handler();
}
/* Configure the main internal regulator output voltage */
if (HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1) != HAL_OK) {
Error_Handler();
}
}
#endif /* ARDUINO_GENERIC_* */
|
the_stack_data/22089.c | #define _GNU_SOURCE
#include <arpa/inet.h>
#include <errno.h>
#include <poll.h>
#include <signal.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <linux/filter.h>
#include <linux/if_arp.h>
#include <linux/rtnetlink.h>
#define COUNT(x) (sizeof(x) / sizeof((x)[0]))
volatile sig_atomic_t fwp_quit;
struct fwp_addr {
unsigned char ll[ETH_ALEN];
unsigned char ip[4];
};
union fwp_pkt {
struct {
struct ethhdr eth;
struct arphdr arp;
struct fwp_addr s, t;
} x;
unsigned char buf[1UL << 16];
};
struct fwp {
int fd;
struct fwp_addr addr;
unsigned index;
unsigned op;
};
static void
fwp_sa_handler()
{
fwp_quit = 1;
}
static int
fwp_init(struct fwp *fwp, char *name, unsigned op)
{
struct ifreq ifr;
memset(&ifr, 0, sizeof(ifr));
strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name) - 1);
fwp->fd = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
if (fwp->fd == -1) {
perror("socket");
return 1;
}
if (ioctl(fwp->fd, SIOCGIFINDEX, &ifr) || ifr.ifr_ifindex <= 0) {
fprintf(stderr, "No interface %s found!\n", ifr.ifr_name);
return 1;
}
fwp->index = ifr.ifr_ifindex;
if (ioctl(fwp->fd, SIOCGIFHWADDR, &ifr)) {
fprintf(stderr, "Unable to find the hwaddr of %s\n", ifr.ifr_name);
return 1;
}
memcpy(&fwp->addr.ll,
&ifr.ifr_hwaddr.sa_data, ETH_ALEN);
fwp->op = op;
return 0;
}
static int
fwp_listen(struct fwp *fwp)
{
struct sockaddr_ll sll = {
.sll_family = AF_PACKET,
.sll_protocol = htons(ETH_P_ALL),
.sll_ifindex = fwp->index,
};
if (bind(fwp->fd, (struct sockaddr *)&sll, sizeof(sll)) == -1) {
perror("bind");
return 1;
}
struct sock_filter filter[] = {
{0x28, 0, 0, 0x0000000c},
{0x15, 0, 3, 0x00000806},
{0x28, 0, 0, 0x00000014},
{0x15, 0, 1, fwp->op },
{0x06, 0, 0, 0x00040000},
{0x06, 0, 0, 0x00000000},
};
struct sock_fprog bpf = {
.len = COUNT(filter),
.filter = filter,
};
if (setsockopt(fwp->fd, SOL_SOCKET, SO_ATTACH_FILTER,
&bpf, sizeof(bpf)) == -1) {
perror("setsockopt(SO_ATTACH_FILTER)");
return 1;
}
return 0;
}
static int
fwp_recv(struct fwp *fwp, union fwp_pkt *pkt)
{
ssize_t r = recv(fwp->fd, pkt, sizeof(*pkt), 0);
if (r < (ssize_t)sizeof(pkt->x)) {
if (r == (ssize_t)-1)
perror("recv");
return -1;
}
if ((pkt->x.arp.ar_op != htons(fwp->op)) ||
(pkt->x.arp.ar_hln != sizeof(pkt->x.s.ll)) ||
(pkt->x.arp.ar_pln != sizeof(pkt->x.s.ip)))
return -1;
return 0;
}
static void
fwp_attr(struct nlmsghdr *n, int type, const void *data, unsigned size)
{
struct rtattr *rta = (struct rtattr *)(((char *)n) + NLMSG_ALIGN(n->nlmsg_len));
unsigned len = RTA_LENGTH(size);
rta->rta_type = type;
rta->rta_len = len;
memcpy(RTA_DATA(rta), data, size);
n->nlmsg_len = NLMSG_ALIGN(n->nlmsg_len) + RTA_ALIGN(len);
}
static int
fwp_neigh(int ifindex, struct fwp_addr *addr, int nud_state)
{
int fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
if (fd == -1) {
perror("socket(netlink)");
return 1;
}
struct {
struct nlmsghdr nh;
struct ndmsg ndm;
unsigned char buf[256];
} req = {
.nh = {
.nlmsg_len = NLMSG_LENGTH(sizeof(struct ndmsg)),
.nlmsg_type = RTM_NEWNEIGH,
.nlmsg_flags = NLM_F_REQUEST | NLM_F_CREATE | NLM_F_REPLACE,
.nlmsg_pid = getpid(),
},
.ndm = {
.ndm_family = AF_INET,
.ndm_state = nud_state,
.ndm_ifindex = ifindex,
},
};
fwp_attr(&req.nh, NDA_DST, addr->ip, sizeof(addr->ip));
fwp_attr(&req.nh, NDA_LLADDR, addr->ll, sizeof(addr->ll));
struct sockaddr_nl snl = {
.nl_family = AF_NETLINK,
};
if (sendto(fd, &req, req.nh.nlmsg_len, 0,
(struct sockaddr *)&snl, sizeof(snl)) == -1)
perror("send(netlink)");
close(fd);
return 0;
}
static void
fwp_set_signal(void)
{
struct sigaction sa = {
.sa_flags = 0,
};
sigemptyset(&sa.sa_mask);
sa.sa_handler = fwp_sa_handler;
sigaction(SIGINT, &sa, NULL);
sigaction(SIGQUIT, &sa, NULL);
sigaction(SIGTERM, &sa, NULL);
sa.sa_handler = SIG_IGN;
sigaction(SIGALRM, &sa, NULL);
sigaction(SIGPIPE, &sa, NULL);
sigaction(SIGUSR1, &sa, NULL);
sigaction(SIGUSR2, &sa, NULL);
sigaction(SIGHUP, &sa, NULL);
}
static uint32_t
ipmask(unsigned char a[4], uint32_t mask)
{
uint32_t tmp;
memcpy(&tmp, a, 4);
return tmp & mask;
}
static const char *
uparse(const char *s, unsigned *ret, unsigned n)
{
int i = 0;
unsigned v = 0;
for (i = 0; v <= n && s[i] >= '0' && s[i] <= '9'; i++)
v = 10 * v + s[i] - '0';
if (i && v <= n)
*ret = v;
return s + i;
}
static const char *
cparse(const char *s, char c)
{
return s + (s[0] == c);
}
static const char *
ipparse(const char *s, uint32_t *ret)
{
unsigned i0 = 256, i1 = 256, i2 = 256, i3 = 256;
s = cparse(uparse(s, &i0, 255), '.');
s = cparse(uparse(s, &i1, 255), '.');
s = cparse(uparse(s, &i2, 255), '.');
s = uparse(s, &i3, 255);
if (i0 < 256 && i1 < 256 && i2 < 256 && i3 < 256)
*ret = i3 << 24 | i2 << 16 | i1 << 8 | i0;
return s;
}
int
main(int argc, char **argv)
{
fwp_set_signal();
if (argc < 3 || argc > 5) {
printf("usage: %s IFSRC IFDST { IP[/CIDR] | IP [MASK] }\n", argv[0]);
return 1;
}
uint32_t ip = 0;
unsigned cidr = 0;
uint32_t mask = 0;
const int nud_state = NUD_REACHABLE;
enum {src, dst, count};
struct fwp fwp[count] = {0};
if (argc >= 4) {
const char *s = ipparse(argv[3], &ip);
int have_cidr = s[0] == '/';
if (!ip || (s[0] && !have_cidr)) {
fprintf(stderr, "Unable to parse ip %s\n", argv[3]);
return 1;
}
if (have_cidr && (uparse(s + 1, &cidr, 32)[0] || !cidr)) {
fprintf(stderr, "Unable to parse CIDR %s\n", s);
return 1;
}
if (argc == 5) {
if (have_cidr) {
fprintf(stderr, "Mask, or CIDR, that is the question...\n");
return 1;
}
if (ipparse(argv[4], &mask)[0] || !mask) {
fprintf(stderr, "Unable to parse mask %s\n", argv[4]);
return 1;
}
}
if (!mask) {
mask = UINT32_MAX;
if (cidr > 0 && cidr < 32)
mask = htonl(mask << (32 - cidr));
}
ip &= mask;
}
if (fwp_init(&fwp[src], argv[1], ARPOP_REQUEST) ||
fwp_init(&fwp[dst], argv[2], ARPOP_REPLY))
return 1;
printf("Start forwarding ARP Request:\n"
" src %02x:%02x:%02x:%02x:%02x:%02x\n"
" dst %02x:%02x:%02x:%02x:%02x:%02x\n",
fwp[src].addr.ll[0], fwp[src].addr.ll[1],
fwp[src].addr.ll[2], fwp[src].addr.ll[3],
fwp[src].addr.ll[4], fwp[src].addr.ll[5],
fwp[dst].addr.ll[0], fwp[dst].addr.ll[1],
fwp[dst].addr.ll[2], fwp[dst].addr.ll[3],
fwp[dst].addr.ll[4], fwp[dst].addr.ll[5]);
if (fwp_listen(&fwp[src]) || fwp_listen(&fwp[dst]))
return 1;
union fwp_pkt pkt;
struct pollfd fds[] = {
{.fd = fwp[src].fd, .events = POLLIN},
{.fd = fwp[dst].fd, .events = POLLIN},
};
while (!fwp_quit) {
int p = poll(fds, COUNT(fds), -1);
if (p <= 0) {
if (p == -1 && errno != EINTR) {
perror("poll");
return 1;
}
continue;
}
if ((fds[src].revents & POLLIN) && !fwp_recv(&fwp[src], &pkt)) {
if (!memcmp(pkt.x.s.ll, fwp[src].addr.ll, sizeof(pkt.x.s.ll))) {
memcpy(pkt.x.eth.h_source, fwp[dst].addr.ll, sizeof(pkt.x.eth.h_source));
memcpy(&pkt.x.s, &fwp[dst].addr, sizeof(pkt.x.s));
if (send(fwp[dst].fd, &pkt.x, sizeof(pkt.x), 0) == -1) {
switch (errno) {
case EINTR: /* FALLTHRU */
case EAGAIN: /* FALLTHRU */
case ENETDOWN:
break;
default:
perror("send(packet)");
return 1;
}
}
} else if (ip && (ipmask(pkt.x.t.ip, mask) == ip)) {
unsigned char tmp[4];
memcpy(&tmp, &pkt.x.t.ip, sizeof(tmp));
memcpy(&pkt.x.t, &pkt.x.s, sizeof(pkt.x.t));
memcpy(&pkt.x.s.ll, &fwp[src].addr.ll, sizeof(pkt.x.s.ll));
memcpy(&pkt.x.s.ip, &tmp, sizeof(pkt.x.s.ip));
memcpy(pkt.x.eth.h_dest, pkt.x.eth.h_source, sizeof(pkt.x.eth.h_dest));
memcpy(pkt.x.eth.h_source, &fwp[src].addr.ll, sizeof(pkt.x.eth.h_source));
pkt.x.arp.ar_op = htons(ARPOP_REPLY);
if (send(fwp[src].fd, &pkt.x, sizeof(pkt.x), 0) == -1) {
switch (errno) {
case EINTR: /* FALLTHRU */
case EAGAIN: /* FALLTHRU */
case ENETDOWN:
break;
default:
perror("send");
return 1;
}
}
}
}
if ((fds[dst].revents & POLLIN) && !fwp_recv(&fwp[dst], &pkt))
fwp_neigh(fwp[src].index, &pkt.x.s, nud_state);
}
}
|
the_stack_data/181393785.c | /*Exercise 4 - Functions
Implement the three functions minimum(), maximum() and multiply() below the main() function.
Do not change the code given in the main() function when you are implementing your solution.*/
#include <stdio.h>
int main() {
int no1, no2;
printf("Enter a value for no 1 : ");
scanf("%d", &no1);
printf("Enter a value for no 2 : ");
scanf("%d", &no2);
printf("%d ", minimum(no1, no2));
printf("%d ", maximum(no1, no2));
printf("%d ", multiply(no1, no2));
return 0;
}
int minimum(int no1 , int no2){
if (no1 > no2){
return no2;
}
else{
return no1;
}
}
int maximum(int no1 , int no2){
if (no1 < no2){
return no2;
}
else{
return no1;
}
}
int multiply(int no1 ,int no2){
int multi = no1 * no2;
return multi;
}
|
the_stack_data/37637058.c | #include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define BUF_SIZE 1024
bool is_vowel(char c) {
char letter = tolower(c);
if (letter == 'a' || letter == 'e' || letter == 'u' || letter == 'i' || letter== 'o') {
return true;
}
return false;
}
int copy_non_vowels(int num_chars, char* in_buf, char* out_buf) {
int num_not_vowels = 0;
int j = 0;
for (int i = 0; i < num_chars; i++) {
if (!is_vowel(in_buf[i])){
out_buf[j] = in_buf[i];
num_not_vowels++;
j++;
}
}
return num_not_vowels;
}
void disemvowel(FILE* inputFile, FILE* outputFile) {
char* in_buf = (char*) calloc(BUF_SIZE, sizeof(char));
char* out_buf = (char*) calloc(BUF_SIZE, sizeof(char));
int num_read = fread(in_buf, sizeof(char), BUF_SIZE, inputFile);
while(num_read > 0) {
int constonants = copy_non_vowels(strlen(in_buf), in_buf, out_buf);
fwrite(out_buf, sizeof(char), constonants, outputFile);
num_read = fread(in_buf, sizeof(char), BUF_SIZE, inputFile);
}
}
int main(int argc, char *argv[]) {
FILE *inputFile;
FILE *outputFile;
if (argc == 1) {
inputFile = stdin;
outputFile = stdout;
}
if (argc == 2 && argv[1] == 0) {
inputFile = stdin;
outputFile = fopen(argv[2], "w");
}
if (argc == 2 && argv[2] == 0 ) {
outputFile = stdout;
inputFile = fopen(argv[1], "r");
}
if (argc == 3) {
inputFile = fopen(argv[1], "r");
outputFile = fopen(argv[2], "w");
}
disemvowel(inputFile, outputFile);
fclose(inputFile);
fclose(outputFile);
return 0;
}
|
the_stack_data/198580746.c | #include <stdio.h>
#include <string.h>
#define MAXLINE 20
void itoa(int n, char s[]);
int main(int argc, char** argv) {
int n;
char s[MAXLINE];
n = -2147483648;
itoa(n, s);
printf("%s\n", s);
n = 2147483647;
itoa(n, s);
printf("%s\n", s);
return 0;
}
void itoa(int n, char s[]) {
int static i = 0;
if (n / 10)
itoa(n / 10, s);
else {
i = 0;
if (n < 0)
s[i++] = '-';
}
s[i++] = abs(n % 10) + '0';
s[i] = '\0';
}
|
the_stack_data/979895.c | // http://stackoverflow.com/questions/5641836/c-preprocessor-recursive-macros
// RUN: %ucc -E %s -P | %stdoutcheck %s
#define CAT_I(a, b) a ## b
#define CAT(a, b) CAT_I(a, b)
#define M_0 CAT(x, y)
#define M_1 whatever_else
#define M(a) CAT(M_, a)
M(0); // expands to CAT(x, y)
#define N_0() CAT(x, y)
#define N_1() whatever_else
#define N(a) CAT(N_, a)()
N(0); // expands to xy _OR_ CAT(x, y)
// and another:
//#define X 10
//1e-X // shouldn't be replaced
// STDOUT: CAT(x, y);
// STDOUT: CAT(x, y);
|
the_stack_data/23301.c | // Use CHECK-NEXT instead of multiple CHECK-SAME to ensure we will fail if there is anything extra in the output.
// RUN: not %clang_cc1 -triple armv5--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix ARM
// ARM: error: unknown target CPU 'not-a-cpu'
// ARM-NEXT: note: valid target CPU values are: arm8, arm810, strongarm, strongarm110, strongarm1100, strongarm1110, arm7tdmi, arm7tdmi-s, arm710t, arm720t, arm9, arm9tdmi, arm920, arm920t, arm922t, arm940t, ep9312, arm10tdmi, arm1020t, arm9e, arm946e-s, arm966e-s, arm968e-s, arm10e, arm1020e, arm1022e, arm926ej-s, arm1136j-s, arm1136jf-s, mpcore, mpcorenovfp, arm1176jz-s, arm1176jzf-s, arm1156t2-s, arm1156t2f-s, cortex-m0, cortex-m0plus, cortex-m1, sc000, cortex-a5, cortex-a7, cortex-a8, cortex-a9, cortex-a12, cortex-a15, cortex-a17, krait, cortex-r4, cortex-r4f, cortex-r5, cortex-r7, cortex-r8, cortex-r52, sc300, cortex-m3, cortex-m4, cortex-m7, cortex-m23, cortex-m33, cortex-m35p, cortex-m55, cortex-a32, cortex-a35, cortex-a53, cortex-a55, cortex-a57, cortex-a72, cortex-a73, cortex-a75, cortex-a76, cortex-a76ae, cortex-a77, cortex-a78, cortex-a78c, cortex-a710, cortex-x1, cortex-x1c, neoverse-n1, neoverse-n2, neoverse-v1, cyclone, exynos-m3, exynos-m4, exynos-m5, kryo, iwmmxt, xscale, swift{{$}}
// RUN: not %clang_cc1 -triple arm64--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix AARCH64
// AARCH64: error: unknown target CPU 'not-a-cpu'
// AARCH64-NEXT: note: valid target CPU values are: cortex-a34, cortex-a35, cortex-a53, cortex-a55, cortex-a510, cortex-a57, cortex-a65, cortex-a65ae, cortex-a72, cortex-a73, cortex-a75, cortex-a76, cortex-a76ae, cortex-a77, cortex-a78, cortex-a78c, cortex-a710, cortex-r82, cortex-x1, cortex-x1c, cortex-x2, neoverse-e1, neoverse-n1, neoverse-n2, neoverse-512tvb, neoverse-v1, cyclone, apple-a7, apple-a8, apple-a9, apple-a10, apple-a11, apple-a12, apple-a13, apple-a14, apple-m1, apple-s4, apple-s5, exynos-m3, exynos-m4, exynos-m5, falkor, saphira, kryo, thunderx2t99, thunderx3t110, thunderx, thunderxt88, thunderxt81, thunderxt83, tsv110, a64fx, carmel{{$}}
// RUN: not %clang_cc1 -triple arm64--- -tune-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix TUNE_AARCH64
// TUNE_AARCH64: error: unknown target CPU 'not-a-cpu'
// TUNE_AARCH64-NEXT: note: valid target CPU values are: cortex-a34, cortex-a35, cortex-a53, cortex-a55, cortex-a510, cortex-a57, cortex-a65, cortex-a65ae, cortex-a72, cortex-a73, cortex-a75, cortex-a76, cortex-a76ae, cortex-a77, cortex-a78, cortex-a78c, cortex-a710, cortex-r82, cortex-x1, cortex-x1c, cortex-x2, neoverse-e1, neoverse-n1, neoverse-n2, neoverse-512tvb, neoverse-v1, cyclone, apple-a7, apple-a8, apple-a9, apple-a10, apple-a11, apple-a12, apple-a13, apple-a14, apple-m1, apple-s4, apple-s5, exynos-m3, exynos-m4, exynos-m5, falkor, saphira, kryo, thunderx2t99, thunderx3t110, thunderx, thunderxt88, thunderxt81, thunderxt83, tsv110, a64fx, carmel{{$}}
// RUN: not %clang_cc1 -triple i386--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix X86
// X86: error: unknown target CPU 'not-a-cpu'
// X86-NEXT: note: valid target CPU values are: i386, i486, winchip-c6, winchip2, c3, i586, pentium, pentium-mmx, pentiumpro, i686, pentium2, pentium3, pentium3m, pentium-m, c3-2, yonah, pentium4, pentium4m, prescott, nocona, core2, penryn, bonnell, atom, silvermont, slm, goldmont, goldmont-plus, tremont, nehalem, corei7, westmere, sandybridge, corei7-avx, ivybridge, core-avx-i, haswell, core-avx2, broadwell, skylake, skylake-avx512, skx, cascadelake, cooperlake, cannonlake, icelake-client, rocketlake, icelake-server, tigerlake, sapphirerapids, alderlake, knl, knm, lakemont, k6, k6-2, k6-3, athlon, athlon-tbird, athlon-xp, athlon-mp, athlon-4, k8, athlon64, athlon-fx, opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2, znver3, x86-64, x86-64-v2, x86-64-v3, x86-64-v4, geode{{$}}
// RUN: not %clang_cc1 -triple x86_64--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix X86_64
// X86_64: error: unknown target CPU 'not-a-cpu'
// X86_64-NEXT: note: valid target CPU values are: nocona, core2, penryn, bonnell, atom, silvermont, slm, goldmont, goldmont-plus, tremont, nehalem, corei7, westmere, sandybridge, corei7-avx, ivybridge, core-avx-i, haswell, core-avx2, broadwell, skylake, skylake-avx512, skx, cascadelake, cooperlake, cannonlake, icelake-client, rocketlake, icelake-server, tigerlake, sapphirerapids, alderlake, knl, knm, k8, athlon64, athlon-fx, opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2, znver3, x86-64, x86-64-v2, x86-64-v3, x86-64-v4{{$}}
// RUN: not %clang_cc1 -triple i386--- -tune-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix TUNE_X86
// TUNE_X86: error: unknown target CPU 'not-a-cpu'
// TUNE_X86-NEXT: note: valid target CPU values are: i386, i486, winchip-c6, winchip2, c3, i586, pentium, pentium-mmx, pentiumpro, i686, pentium2, pentium3, pentium3m, pentium-m, c3-2, yonah, pentium4, pentium4m, prescott, nocona, core2, penryn, bonnell, atom, silvermont, slm, goldmont, goldmont-plus, tremont, nehalem, corei7, westmere, sandybridge, corei7-avx, ivybridge, core-avx-i, haswell, core-avx2, broadwell, skylake, skylake-avx512, skx, cascadelake, cooperlake, cannonlake, icelake-client, rocketlake, icelake-server, tigerlake, sapphirerapids, alderlake, knl, knm, lakemont, k6, k6-2, k6-3, athlon, athlon-tbird, athlon-xp, athlon-mp, athlon-4, k8, athlon64, athlon-fx, opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2, znver3, x86-64, geode{{$}}
// RUN: not %clang_cc1 -triple x86_64--- -tune-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix TUNE_X86_64
// TUNE_X86_64: error: unknown target CPU 'not-a-cpu'
// TUNE_X86_64-NEXT: note: valid target CPU values are: i386, i486, winchip-c6, winchip2, c3, i586, pentium, pentium-mmx, pentiumpro, i686, pentium2, pentium3, pentium3m, pentium-m, c3-2, yonah, pentium4, pentium4m, prescott, nocona, core2, penryn, bonnell, atom, silvermont, slm, goldmont, goldmont-plus, tremont, nehalem, corei7, westmere, sandybridge, corei7-avx, ivybridge, core-avx-i, haswell, core-avx2, broadwell, skylake, skylake-avx512, skx, cascadelake, cooperlake, cannonlake, icelake-client, rocketlake, icelake-server, tigerlake, sapphirerapids, alderlake, knl, knm, lakemont, k6, k6-2, k6-3, athlon, athlon-tbird, athlon-xp, athlon-mp, athlon-4, k8, athlon64, athlon-fx, opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2, znver3, x86-64, geode{{$}}
// RUN: not %clang_cc1 -triple nvptx--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix NVPTX
// NVPTX: error: unknown target CPU 'not-a-cpu'
// NVPTX-NEXT: note: valid target CPU values are: sm_20, sm_21, sm_30, sm_32, sm_35, sm_37, sm_50, sm_52, sm_53, sm_60, sm_61, sm_62, sm_70, sm_72, sm_75, sm_80, sm_86, gfx600, gfx601, gfx602, gfx700, gfx701, gfx702, gfx703, gfx704, gfx705, gfx801, gfx802, gfx803, gfx805, gfx810, gfx900, gfx902, gfx904, gfx906, gfx908, gfx909, gfx90a, gfx90c, gfx1010, gfx1011, gfx1012, gfx1013, gfx1030, gfx1031, gfx1032, gfx1033, gfx1034, gfx1035{{$}}
// RUN: not %clang_cc1 -triple r600--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix R600
// R600: error: unknown target CPU 'not-a-cpu'
// R600-NEXT: note: valid target CPU values are: r600, rv630, rv635, r630, rs780, rs880, rv610, rv620, rv670, rv710, rv730, rv740, rv770, cedar, palm, cypress, hemlock, juniper, redwood, sumo, sumo2, barts, caicos, aruba, cayman, turks{{$}}
// RUN: not %clang_cc1 -triple amdgcn--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix AMDGCN
// AMDGCN: error: unknown target CPU 'not-a-cpu'
// AMDGCN-NEXT: note: valid target CPU values are: gfx600, tahiti, gfx601, pitcairn, verde, gfx602, hainan, oland, gfx700, kaveri, gfx701, hawaii, gfx702, gfx703, kabini, mullins, gfx704, bonaire, gfx705, gfx801, carrizo, gfx802, iceland, tonga, gfx803, fiji, polaris10, polaris11, gfx805, tongapro, gfx810, stoney, gfx900, gfx902, gfx904, gfx906, gfx908, gfx909, gfx90a, gfx90c, gfx1010, gfx1011, gfx1012, gfx1013, gfx1030, gfx1031, gfx1032, gfx1033, gfx1034, gfx1035{{$}}
// RUN: not %clang_cc1 -triple wasm64--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix WEBASM
// WEBASM: error: unknown target CPU 'not-a-cpu'
// WEBASM-NEXT: note: valid target CPU values are: mvp, bleeding-edge, generic{{$}}
// RUN: not %clang_cc1 -triple systemz--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix SYSTEMZ
// SYSTEMZ: error: unknown target CPU 'not-a-cpu'
// SYSTEMZ-NEXT: note: valid target CPU values are: arch8, z10, arch9, z196, arch10, zEC12, arch11, z13, arch12, z14, arch13, z15, arch14{{$}}
// RUN: not %clang_cc1 -triple sparc--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix SPARC
// SPARC: error: unknown target CPU 'not-a-cpu'
// SPARC-NEXT: note: valid target CPU values are: v8, supersparc, sparclite, f934, hypersparc, sparclite86x, sparclet, tsc701, v9, ultrasparc, ultrasparc3, niagara, niagara2, niagara3, niagara4, ma2100, ma2150, ma2155, ma2450, ma2455, ma2x5x, ma2080, ma2085, ma2480, ma2485, ma2x8x, myriad2, myriad2.1, myriad2.2, myriad2.3, leon2, at697e, at697f, leon3, ut699, gr712rc, leon4, gr740{{$}}
// RUN: not %clang_cc1 -triple sparcv9--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix SPARCV9
// SPARCV9: error: unknown target CPU 'not-a-cpu'
// SPARCV9-NEXT: note: valid target CPU values are: v9, ultrasparc, ultrasparc3, niagara, niagara2, niagara3, niagara4{{$}}
// RUN: not %clang_cc1 -triple powerpc--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix PPC
// PPC: error: unknown target CPU 'not-a-cpu'
// PPC-NEXT: note: valid target CPU values are: generic, 440, 450, 601, 602, 603, 603e, 603ev, 604, 604e, 620, 630, g3, 7400, g4, 7450, g4+, 750, 8548, 970, g5, a2, e500, e500mc, e5500, power3, pwr3, power4, pwr4, power5, pwr5, power5x, pwr5x, power6, pwr6, power6x, pwr6x, power7, pwr7, power8, pwr8, power9, pwr9, power10, pwr10, powerpc, ppc, ppc32, powerpc64, ppc64, powerpc64le, ppc64le, future{{$}}
// RUN: not %clang_cc1 -triple mips--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix MIPS
// MIPS: error: unknown target CPU 'not-a-cpu'
// MIPS-NEXT: note: valid target CPU values are: mips1, mips2, mips3, mips4, mips5, mips32, mips32r2, mips32r3, mips32r5, mips32r6, mips64, mips64r2, mips64r3, mips64r5, mips64r6, octeon, octeon+, p5600{{$}}
// RUN: not %clang_cc1 -triple lanai--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix LANAI
// LANAI: error: unknown target CPU 'not-a-cpu'
// LANAI-NEXT: note: valid target CPU values are: v11{{$}}
// RUN: not %clang_cc1 -triple hexagon--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix HEXAGON
// HEXAGON: error: unknown target CPU 'not-a-cpu'
// HEXAGON-NEXT: note: valid target CPU values are: hexagonv5, hexagonv55, hexagonv60, hexagonv62, hexagonv65, hexagonv66, hexagonv67, hexagonv67t, hexagonv68, hexagonv69{{$}}
// RUN: not %clang_cc1 -triple bpf--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix BPF
// BPF: error: unknown target CPU 'not-a-cpu'
// BPF-NEXT: note: valid target CPU values are: generic, v1, v2, v3, probe{{$}}
// RUN: not %clang_cc1 -triple avr--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix AVR
// AVR: error: unknown target CPU 'not-a-cpu'
// AVR-NEXT: note: valid target CPU values are: avr1, avr2, avr25, avr3, avr31, avr35, avr4, avr5, avr51, avr6, avrxmega1, avrxmega2, avrxmega3, avrxmega4, avrxmega5, avrxmega6, avrxmega7, avrtiny, at90s1200, attiny11, attiny12, attiny15, attiny28, at90s2313, at90s2323, at90s2333, at90s2343, attiny22, attiny26, at86rf401, at90s4414, at90s4433, at90s4434, at90s8515, at90c8534, at90s8535, ata5272, attiny13, attiny13a, attiny2313, attiny2313a, attiny24, attiny24a, attiny4313, attiny44, attiny44a, attiny84, attiny84a, attiny25, attiny45, attiny85, attiny261, attiny261a, attiny441, attiny461, attiny461a, attiny841, attiny861, attiny861a, attiny87, attiny43u, attiny48, attiny88, attiny828, at43usb355, at76c711, atmega103, at43usb320, attiny167, at90usb82, at90usb162, ata5505, atmega8u2, atmega16u2, atmega32u2, attiny1634, atmega8, ata6289, atmega8a, ata6285, ata6286, atmega48, atmega48a, atmega48pa, atmega48pb, atmega48p, atmega88, atmega88a, atmega88p, atmega88pa, atmega88pb, atmega8515, atmega8535, atmega8hva, at90pwm1, at90pwm2, at90pwm2b, at90pwm3, at90pwm3b, at90pwm81, ata5790, ata5795, atmega16, atmega16a, atmega161, atmega162, atmega163, atmega164a, atmega164p, atmega164pa, atmega165, atmega165a, atmega165p, atmega165pa, atmega168, atmega168a, atmega168p, atmega168pa, atmega168pb, atmega169, atmega169a, atmega169p, atmega169pa, atmega32, atmega32a, atmega323, atmega324a, atmega324p, atmega324pa, atmega324pb, atmega325, atmega325a, atmega325p, atmega325pa, atmega3250, atmega3250a, atmega3250p, atmega3250pa, atmega328, atmega328p, atmega328pb, atmega329, atmega329a, atmega329p, atmega329pa, atmega3290, atmega3290a, atmega3290p, atmega3290pa, atmega406, atmega64, atmega64a, atmega640, atmega644, atmega644a, atmega644p, atmega644pa, atmega645, atmega645a, atmega645p, atmega649, atmega649a, atmega649p, atmega6450, atmega6450a, atmega6450p, atmega6490, atmega6490a, atmega6490p, atmega64rfr2, atmega644rfr2, atmega16hva, atmega16hva2, atmega16hvb, atmega16hvbrevb, atmega32hvb, atmega32hvbrevb, atmega64hve, at90can32, at90can64, at90pwm161, at90pwm216, at90pwm316, atmega32c1, atmega64c1, atmega16m1, atmega32m1, atmega64m1, atmega16u4, atmega32u4, atmega32u6, at90usb646, at90usb647, at90scr100, at94k, m3000, atmega128, atmega128a, atmega1280, atmega1281, atmega1284, atmega1284p, atmega128rfa1, atmega128rfr2, atmega1284rfr2, at90can128, at90usb1286, at90usb1287, atmega2560, atmega2561, atmega256rfr2, atmega2564rfr2, atxmega16a4, atxmega16a4u, atxmega16c4, atxmega16d4, atxmega32a4, atxmega32a4u, atxmega32c4, atxmega32d4, atxmega32e5, atxmega16e5, atxmega8e5, atxmega32x1, atxmega64a3, atxmega64a3u, atxmega64a4u, atxmega64b1, atxmega64b3, atxmega64c3, atxmega64d3, atxmega64d4, atxmega64a1, atxmega64a1u, atxmega128a3, atxmega128a3u, atxmega128b1, atxmega128b3, atxmega128c3, atxmega128d3, atxmega128d4, atxmega192a3, atxmega192a3u, atxmega192c3, atxmega192d3, atxmega256a3, atxmega256a3u, atxmega256a3b, atxmega256a3bu, atxmega256c3, atxmega256d3, atxmega384c3, atxmega384d3, atxmega128a1, atxmega128a1u, atxmega128a4u, attiny4, attiny5, attiny9, attiny10, attiny20, attiny40, attiny102, attiny104, attiny202, attiny402, attiny204, attiny404, attiny804, attiny1604, attiny406, attiny806, attiny1606, attiny807, attiny1607, attiny212, attiny412, attiny214, attiny414, attiny814, attiny1614, attiny416, attiny816, attiny1616, attiny3216, attiny417, attiny817, attiny1617, attiny3217{{$}}
// RUN: not %clang_cc1 -triple riscv32 -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix RISCV32
// RISCV32: error: unknown target CPU 'not-a-cpu'
// RISCV32-NEXT: note: valid target CPU values are: generic-rv32, rocket-rv32, sifive-7-rv32, sifive-e20, sifive-e21, sifive-e24, sifive-e31, sifive-e34, sifive-e76{{$}}
// RUN: not %clang_cc1 -triple riscv64 -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix RISCV64
// RISCV64: error: unknown target CPU 'not-a-cpu'
// RISCV64-NEXT: note: valid target CPU values are: generic-rv64, rocket-rv64, sifive-7-rv64, sifive-s21, sifive-s51, sifive-s54, sifive-s76, sifive-u54, sifive-u74{{$}}
// RUN: not %clang_cc1 -triple riscv32 -tune-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix TUNE-RISCV32
// TUNE-RISCV32: error: unknown target CPU 'not-a-cpu'
// TUNE-RISCV32-NEXT: note: valid target CPU values are: generic-rv32, rocket-rv32, sifive-7-rv32, sifive-e20, sifive-e21, sifive-e24, sifive-e31, sifive-e34, sifive-e76, generic, rocket, sifive-7-series{{$}}
// RUN: not %clang_cc1 -triple riscv64 -tune-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix TUNE-RISCV64
// TUNE-RISCV64: error: unknown target CPU 'not-a-cpu'
// TUNE-RISCV64-NEXT: note: valid target CPU values are: generic-rv64, rocket-rv64, sifive-7-rv64, sifive-s21, sifive-s51, sifive-s54, sifive-s76, sifive-u54, sifive-u74, generic, rocket, sifive-7-series{{$}}
|
the_stack_data/112332.c | #include <stdio.h>
#include <stdlib.h>
int flatten_peak(const int i, const int j, const int array[20][31]) {
int self = array[i][j];
int left, right, above, below, n;
n = 1;
left = right = above = below = 0;
if (j - 1 >= 0 && self - array[i][j - 1] > 1) {
left = array[i][j - 1];
n++;
}
if (j + 1 <= 29 && self - array[i][j + 1] > 1) {
right = array[i][j + 1];
n++;
}
if (i - 1 >= 0 && self - array[i - 1][j] > 1) {
above = array[i - 1][j];
n++;
}
if (i + 1 <= 19 && self - array[i + 1][j] > 1) {
below = array[i + 1][j];
n++;
}
return (left + right + above + below + self) / n;
}
int main(int argc, char *argv[]) {
FILE *in, *out;
int array[20][31];
char ch[10] = ")!@#$%^&*(";
int i, j;
if (argc != 3) {
fprintf(stderr, "Usage: 13-13.exe <inputfile> <outputfile>");
exit(EXIT_FAILURE);
}
if ((in = fopen(argv[1], "r")) == NULL) {
fprintf(stderr, "Cannot open file %s\n", argv[1]);
exit(EXIT_FAILURE);
}
if ((out = fopen(argv[2], "w")) == NULL) {
fprintf(stderr, "Cannot open file %s\n", argv[2]);
exit(EXIT_FAILURE);
}
for (i = 0; i < 20; i++)
for (j = 0; j < 30; j++)
fscanf(in, "%d", &array[i][j]);
for (i = 0; i < 20; i++)
for (j = 0; j < 30; j++)
array[i][j] = flatten_peak(i, j, array);
for (i = 0; i < 20; i++) {
for (j = 0; j < 30; j++)
putc(ch[array[i][j]], out);
putc('\n', out);
}
fclose(in);
fclose(out);
return 0;
}
|
the_stack_data/92987.c | #include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
int main (int argc, char *argv[]) {
int key;
char plaintext[300];
int lowerBound = 96;
int upperBound = 122;
if (argc != 2 || sscanf(argv[1], "%i", &key) != 1 || key < 1) {
printf("Usage: ./caesar key\nKey must be an integer >= 1");
exit(1);
}
puts("plaintext: ");
fgets(plaintext, sizeof(plaintext), stdin);
long textLength = strlen(plaintext);
for (int i = 0; i < textLength; i++) {
if (isalpha(plaintext[i]) != 0) {
char val = plaintext[i];
char c = tolower(plaintext[i]);
int charCode = c;
int newCharCode = charCode + key;
while(newCharCode > upperBound) {
newCharCode = lowerBound + (newCharCode % upperBound);
}
plaintext[i] = isupper(val) > 0 ? toupper(newCharCode) : newCharCode;
}
}
printf("ciphertext: %s", plaintext);
}
|
the_stack_data/135474.c | // general protection fault in go7007_usb_probe
// https://syzkaller.appspot.com/bug?id=cabfa4b5b05ff6be4ef0
// status:6
// autogenerated by syzkaller (https://github.com/google/syzkaller)
#define _GNU_SOURCE
#include <dirent.h>
#include <endian.h>
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mount.h>
#include <sys/prctl.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <time.h>
#include <unistd.h>
#include <linux/usb/ch9.h>
static unsigned long long procid;
static void sleep_ms(uint64_t ms)
{
usleep(ms * 1000);
}
static uint64_t current_time_ms(void)
{
struct timespec ts;
if (clock_gettime(CLOCK_MONOTONIC, &ts))
exit(1);
return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000;
}
static bool write_file(const char* file, const char* what, ...)
{
char buf[1024];
va_list args;
va_start(args, what);
vsnprintf(buf, sizeof(buf), what, args);
va_end(args);
buf[sizeof(buf) - 1] = 0;
int len = strlen(buf);
int fd = open(file, O_WRONLY | O_CLOEXEC);
if (fd == -1)
return false;
if (write(fd, buf, len) != len) {
int err = errno;
close(fd);
errno = err;
return false;
}
close(fd);
return true;
}
#define MAX_FDS 30
#define USB_MAX_IFACE_NUM 4
#define USB_MAX_EP_NUM 32
#define USB_MAX_FDS 6
struct usb_endpoint_index {
struct usb_endpoint_descriptor desc;
int handle;
};
struct usb_iface_index {
struct usb_interface_descriptor* iface;
uint8_t bInterfaceNumber;
uint8_t bAlternateSetting;
uint8_t bInterfaceClass;
struct usb_endpoint_index eps[USB_MAX_EP_NUM];
int eps_num;
};
struct usb_device_index {
struct usb_device_descriptor* dev;
struct usb_config_descriptor* config;
uint8_t bDeviceClass;
uint8_t bMaxPower;
int config_length;
struct usb_iface_index ifaces[USB_MAX_IFACE_NUM];
int ifaces_num;
int iface_cur;
};
struct usb_info {
int fd;
struct usb_device_index index;
};
static struct usb_info usb_devices[USB_MAX_FDS];
static int usb_devices_num;
static bool parse_usb_descriptor(const char* buffer, size_t length,
struct usb_device_index* index)
{
if (length < sizeof(*index->dev) + sizeof(*index->config))
return false;
memset(index, 0, sizeof(*index));
index->dev = (struct usb_device_descriptor*)buffer;
index->config = (struct usb_config_descriptor*)(buffer + sizeof(*index->dev));
index->bDeviceClass = index->dev->bDeviceClass;
index->bMaxPower = index->config->bMaxPower;
index->config_length = length - sizeof(*index->dev);
index->iface_cur = -1;
size_t offset = 0;
while (true) {
if (offset + 1 >= length)
break;
uint8_t desc_length = buffer[offset];
uint8_t desc_type = buffer[offset + 1];
if (desc_length <= 2)
break;
if (offset + desc_length > length)
break;
if (desc_type == USB_DT_INTERFACE &&
index->ifaces_num < USB_MAX_IFACE_NUM) {
struct usb_interface_descriptor* iface =
(struct usb_interface_descriptor*)(buffer + offset);
index->ifaces[index->ifaces_num].iface = iface;
index->ifaces[index->ifaces_num].bInterfaceNumber =
iface->bInterfaceNumber;
index->ifaces[index->ifaces_num].bAlternateSetting =
iface->bAlternateSetting;
index->ifaces[index->ifaces_num].bInterfaceClass = iface->bInterfaceClass;
index->ifaces_num++;
}
if (desc_type == USB_DT_ENDPOINT && index->ifaces_num > 0) {
struct usb_iface_index* iface = &index->ifaces[index->ifaces_num - 1];
if (iface->eps_num < USB_MAX_EP_NUM) {
memcpy(&iface->eps[iface->eps_num].desc, buffer + offset,
sizeof(iface->eps[iface->eps_num].desc));
iface->eps_num++;
}
}
offset += desc_length;
}
return true;
}
static struct usb_device_index* add_usb_index(int fd, const char* dev,
size_t dev_len)
{
int i = __atomic_fetch_add(&usb_devices_num, 1, __ATOMIC_RELAXED);
if (i >= USB_MAX_FDS)
return NULL;
int rv = 0;
rv = parse_usb_descriptor(dev, dev_len, &usb_devices[i].index);
if (!rv)
return NULL;
__atomic_store_n(&usb_devices[i].fd, fd, __ATOMIC_RELEASE);
return &usb_devices[i].index;
}
static struct usb_device_index* lookup_usb_index(int fd)
{
int i;
for (i = 0; i < USB_MAX_FDS; i++) {
if (__atomic_load_n(&usb_devices[i].fd, __ATOMIC_ACQUIRE) == fd) {
return &usb_devices[i].index;
}
}
return NULL;
}
struct vusb_connect_string_descriptor {
uint32_t len;
char* str;
} __attribute__((packed));
struct vusb_connect_descriptors {
uint32_t qual_len;
char* qual;
uint32_t bos_len;
char* bos;
uint32_t strs_len;
struct vusb_connect_string_descriptor strs[0];
} __attribute__((packed));
static const char default_string[] = {8, USB_DT_STRING, 's', 0, 'y', 0, 'z', 0};
static const char default_lang_id[] = {4, USB_DT_STRING, 0x09, 0x04};
static bool
lookup_connect_response_in(int fd, const struct vusb_connect_descriptors* descs,
const struct usb_ctrlrequest* ctrl,
char** response_data, uint32_t* response_length)
{
struct usb_device_index* index = lookup_usb_index(fd);
uint8_t str_idx;
if (!index)
return false;
switch (ctrl->bRequestType & USB_TYPE_MASK) {
case USB_TYPE_STANDARD:
switch (ctrl->bRequest) {
case USB_REQ_GET_DESCRIPTOR:
switch (ctrl->wValue >> 8) {
case USB_DT_DEVICE:
*response_data = (char*)index->dev;
*response_length = sizeof(*index->dev);
return true;
case USB_DT_CONFIG:
*response_data = (char*)index->config;
*response_length = index->config_length;
return true;
case USB_DT_STRING:
str_idx = (uint8_t)ctrl->wValue;
if (descs && str_idx < descs->strs_len) {
*response_data = descs->strs[str_idx].str;
*response_length = descs->strs[str_idx].len;
return true;
}
if (str_idx == 0) {
*response_data = (char*)&default_lang_id[0];
*response_length = default_lang_id[0];
return true;
}
*response_data = (char*)&default_string[0];
*response_length = default_string[0];
return true;
case USB_DT_BOS:
*response_data = descs->bos;
*response_length = descs->bos_len;
return true;
case USB_DT_DEVICE_QUALIFIER:
if (!descs->qual) {
struct usb_qualifier_descriptor* qual =
(struct usb_qualifier_descriptor*)response_data;
qual->bLength = sizeof(*qual);
qual->bDescriptorType = USB_DT_DEVICE_QUALIFIER;
qual->bcdUSB = index->dev->bcdUSB;
qual->bDeviceClass = index->dev->bDeviceClass;
qual->bDeviceSubClass = index->dev->bDeviceSubClass;
qual->bDeviceProtocol = index->dev->bDeviceProtocol;
qual->bMaxPacketSize0 = index->dev->bMaxPacketSize0;
qual->bNumConfigurations = index->dev->bNumConfigurations;
qual->bRESERVED = 0;
*response_length = sizeof(*qual);
return true;
}
*response_data = descs->qual;
*response_length = descs->qual_len;
return true;
default:
break;
}
break;
default:
break;
}
break;
default:
break;
}
return false;
}
typedef bool (*lookup_connect_out_response_t)(
int fd, const struct vusb_connect_descriptors* descs,
const struct usb_ctrlrequest* ctrl, bool* done);
static bool lookup_connect_response_out_generic(
int fd, const struct vusb_connect_descriptors* descs,
const struct usb_ctrlrequest* ctrl, bool* done)
{
switch (ctrl->bRequestType & USB_TYPE_MASK) {
case USB_TYPE_STANDARD:
switch (ctrl->bRequest) {
case USB_REQ_SET_CONFIGURATION:
*done = true;
return true;
default:
break;
}
break;
}
return false;
}
#define UDC_NAME_LENGTH_MAX 128
struct usb_raw_init {
__u8 driver_name[UDC_NAME_LENGTH_MAX];
__u8 device_name[UDC_NAME_LENGTH_MAX];
__u8 speed;
};
enum usb_raw_event_type {
USB_RAW_EVENT_INVALID = 0,
USB_RAW_EVENT_CONNECT = 1,
USB_RAW_EVENT_CONTROL = 2,
};
struct usb_raw_event {
__u32 type;
__u32 length;
__u8 data[0];
};
struct usb_raw_ep_io {
__u16 ep;
__u16 flags;
__u32 length;
__u8 data[0];
};
#define USB_RAW_EPS_NUM_MAX 30
#define USB_RAW_EP_NAME_MAX 16
#define USB_RAW_EP_ADDR_ANY 0xff
struct usb_raw_ep_caps {
__u32 type_control : 1;
__u32 type_iso : 1;
__u32 type_bulk : 1;
__u32 type_int : 1;
__u32 dir_in : 1;
__u32 dir_out : 1;
};
struct usb_raw_ep_limits {
__u16 maxpacket_limit;
__u16 max_streams;
__u32 reserved;
};
struct usb_raw_ep_info {
__u8 name[USB_RAW_EP_NAME_MAX];
__u32 addr;
struct usb_raw_ep_caps caps;
struct usb_raw_ep_limits limits;
};
struct usb_raw_eps_info {
struct usb_raw_ep_info eps[USB_RAW_EPS_NUM_MAX];
};
#define USB_RAW_IOCTL_INIT _IOW('U', 0, struct usb_raw_init)
#define USB_RAW_IOCTL_RUN _IO('U', 1)
#define USB_RAW_IOCTL_EVENT_FETCH _IOR('U', 2, struct usb_raw_event)
#define USB_RAW_IOCTL_EP0_WRITE _IOW('U', 3, struct usb_raw_ep_io)
#define USB_RAW_IOCTL_EP0_READ _IOWR('U', 4, struct usb_raw_ep_io)
#define USB_RAW_IOCTL_EP_ENABLE _IOW('U', 5, struct usb_endpoint_descriptor)
#define USB_RAW_IOCTL_EP_DISABLE _IOW('U', 6, __u32)
#define USB_RAW_IOCTL_EP_WRITE _IOW('U', 7, struct usb_raw_ep_io)
#define USB_RAW_IOCTL_EP_READ _IOWR('U', 8, struct usb_raw_ep_io)
#define USB_RAW_IOCTL_CONFIGURE _IO('U', 9)
#define USB_RAW_IOCTL_VBUS_DRAW _IOW('U', 10, __u32)
#define USB_RAW_IOCTL_EPS_INFO _IOR('U', 11, struct usb_raw_eps_info)
#define USB_RAW_IOCTL_EP0_STALL _IO('U', 12)
#define USB_RAW_IOCTL_EP_SET_HALT _IOW('U', 13, __u32)
#define USB_RAW_IOCTL_EP_CLEAR_HALT _IOW('U', 14, __u32)
#define USB_RAW_IOCTL_EP_SET_WEDGE _IOW('U', 15, __u32)
static int usb_raw_open()
{
return open("/dev/raw-gadget", O_RDWR);
}
static int usb_raw_init(int fd, uint32_t speed, const char* driver,
const char* device)
{
struct usb_raw_init arg;
strncpy((char*)&arg.driver_name[0], driver, sizeof(arg.driver_name));
strncpy((char*)&arg.device_name[0], device, sizeof(arg.device_name));
arg.speed = speed;
return ioctl(fd, USB_RAW_IOCTL_INIT, &arg);
}
static int usb_raw_run(int fd)
{
return ioctl(fd, USB_RAW_IOCTL_RUN, 0);
}
static int usb_raw_event_fetch(int fd, struct usb_raw_event* event)
{
return ioctl(fd, USB_RAW_IOCTL_EVENT_FETCH, event);
}
static int usb_raw_ep0_write(int fd, struct usb_raw_ep_io* io)
{
return ioctl(fd, USB_RAW_IOCTL_EP0_WRITE, io);
}
static int usb_raw_ep0_read(int fd, struct usb_raw_ep_io* io)
{
return ioctl(fd, USB_RAW_IOCTL_EP0_READ, io);
}
static int usb_raw_ep_enable(int fd, struct usb_endpoint_descriptor* desc)
{
return ioctl(fd, USB_RAW_IOCTL_EP_ENABLE, desc);
}
static int usb_raw_ep_disable(int fd, int ep)
{
return ioctl(fd, USB_RAW_IOCTL_EP_DISABLE, ep);
}
static int usb_raw_configure(int fd)
{
return ioctl(fd, USB_RAW_IOCTL_CONFIGURE, 0);
}
static int usb_raw_vbus_draw(int fd, uint32_t power)
{
return ioctl(fd, USB_RAW_IOCTL_VBUS_DRAW, power);
}
static int usb_raw_ep0_stall(int fd)
{
return ioctl(fd, USB_RAW_IOCTL_EP0_STALL, 0);
}
static void set_interface(int fd, int n)
{
struct usb_device_index* index = lookup_usb_index(fd);
int ep;
if (!index)
return;
if (index->iface_cur >= 0 && index->iface_cur < index->ifaces_num) {
for (ep = 0; ep < index->ifaces[index->iface_cur].eps_num; ep++) {
int rv = usb_raw_ep_disable(
fd, index->ifaces[index->iface_cur].eps[ep].handle);
if (rv < 0) {
} else {
}
}
}
if (n >= 0 && n < index->ifaces_num) {
for (ep = 0; ep < index->ifaces[n].eps_num; ep++) {
int rv = usb_raw_ep_enable(fd, &index->ifaces[n].eps[ep].desc);
if (rv < 0) {
} else {
index->ifaces[n].eps[ep].handle = rv;
}
}
index->iface_cur = n;
}
}
static int configure_device(int fd)
{
struct usb_device_index* index = lookup_usb_index(fd);
if (!index)
return -1;
int rv = usb_raw_vbus_draw(fd, index->bMaxPower);
if (rv < 0) {
return rv;
}
rv = usb_raw_configure(fd);
if (rv < 0) {
return rv;
}
set_interface(fd, 0);
return 0;
}
#define USB_MAX_PACKET_SIZE 4096
struct usb_raw_control_event {
struct usb_raw_event inner;
struct usb_ctrlrequest ctrl;
char data[USB_MAX_PACKET_SIZE];
};
struct usb_raw_ep_io_data {
struct usb_raw_ep_io inner;
char data[USB_MAX_PACKET_SIZE];
};
static volatile long
syz_usb_connect_impl(uint64_t speed, uint64_t dev_len, const char* dev,
const struct vusb_connect_descriptors* descs,
lookup_connect_out_response_t lookup_connect_response_out)
{
if (!dev) {
return -1;
}
int fd = usb_raw_open();
if (fd < 0) {
return fd;
}
if (fd >= MAX_FDS) {
close(fd);
return -1;
}
struct usb_device_index* index = add_usb_index(fd, dev, dev_len);
if (!index) {
return -1;
}
char device[32];
sprintf(&device[0], "dummy_udc.%llu", procid);
int rv = usb_raw_init(fd, speed, "dummy_udc", &device[0]);
if (rv < 0) {
return rv;
}
rv = usb_raw_run(fd);
if (rv < 0) {
return rv;
}
bool done = false;
while (!done) {
struct usb_raw_control_event event;
event.inner.type = 0;
event.inner.length = sizeof(event.ctrl);
rv = usb_raw_event_fetch(fd, (struct usb_raw_event*)&event);
if (rv < 0) {
return rv;
}
if (event.inner.type != USB_RAW_EVENT_CONTROL)
continue;
char* response_data = NULL;
uint32_t response_length = 0;
if (event.ctrl.bRequestType & USB_DIR_IN) {
bool response_found = false;
response_found = lookup_connect_response_in(
fd, descs, &event.ctrl, &response_data, &response_length);
if (!response_found) {
usb_raw_ep0_stall(fd);
continue;
}
} else {
if (!lookup_connect_response_out(fd, descs, &event.ctrl, &done)) {
usb_raw_ep0_stall(fd);
continue;
}
response_data = NULL;
response_length = event.ctrl.wLength;
}
if ((event.ctrl.bRequestType & USB_TYPE_MASK) == USB_TYPE_STANDARD &&
event.ctrl.bRequest == USB_REQ_SET_CONFIGURATION) {
rv = configure_device(fd);
if (rv < 0) {
return rv;
}
}
struct usb_raw_ep_io_data response;
response.inner.ep = 0;
response.inner.flags = 0;
if (response_length > sizeof(response.data))
response_length = 0;
if (event.ctrl.wLength < response_length)
response_length = event.ctrl.wLength;
response.inner.length = response_length;
if (response_data)
memcpy(&response.data[0], response_data, response_length);
else
memset(&response.data[0], 0, response_length);
if (event.ctrl.bRequestType & USB_DIR_IN) {
rv = usb_raw_ep0_write(fd, (struct usb_raw_ep_io*)&response);
} else {
rv = usb_raw_ep0_read(fd, (struct usb_raw_ep_io*)&response);
}
if (rv < 0) {
return rv;
}
}
sleep_ms(200);
return fd;
}
static volatile long syz_usb_connect(volatile long a0, volatile long a1,
volatile long a2, volatile long a3)
{
uint64_t speed = a0;
uint64_t dev_len = a1;
const char* dev = (const char*)a2;
const struct vusb_connect_descriptors* descs =
(const struct vusb_connect_descriptors*)a3;
return syz_usb_connect_impl(speed, dev_len, dev, descs,
&lookup_connect_response_out_generic);
}
static void kill_and_wait(int pid, int* status)
{
kill(-pid, SIGKILL);
kill(pid, SIGKILL);
int i;
for (i = 0; i < 100; i++) {
if (waitpid(-1, status, WNOHANG | __WALL) == pid)
return;
usleep(1000);
}
DIR* dir = opendir("/sys/fs/fuse/connections");
if (dir) {
for (;;) {
struct dirent* ent = readdir(dir);
if (!ent)
break;
if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0)
continue;
char abort[300];
snprintf(abort, sizeof(abort), "/sys/fs/fuse/connections/%s/abort",
ent->d_name);
int fd = open(abort, O_WRONLY);
if (fd == -1) {
continue;
}
if (write(fd, abort, 1) < 0) {
}
close(fd);
}
closedir(dir);
} else {
}
while (waitpid(-1, status, __WALL) != pid) {
}
}
static void setup_test()
{
prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0);
setpgrp();
write_file("/proc/self/oom_score_adj", "1000");
}
static void execute_one(void);
#define WAIT_FLAGS __WALL
static void loop(void)
{
int iter;
for (iter = 0;; iter++) {
int pid = fork();
if (pid < 0)
exit(1);
if (pid == 0) {
setup_test();
execute_one();
exit(0);
}
int status = 0;
uint64_t start = current_time_ms();
for (;;) {
if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid)
break;
sleep_ms(1);
if (current_time_ms() - start < 5 * 1000)
continue;
kill_and_wait(pid, &status);
break;
}
}
}
void execute_one(void)
{
memcpy((void*)0x20000280,
"\x12\x01\x00\x00\x6e\x33\x0b\x40\xb1\x0e\x07\x70\x05\x02\x00\x00\x00"
"\x01\x09\x02\x12\x00\x01\x00\x00\x00\x00\x09\x04\x00\x00\x00\xff\x00"
"\xff\x00\x2c\xfb\xd8\xf3\x73\xb7\xda\xe1\xba\x03\xbc\xe9\x28\x51\x6c"
"\x2b\xc6\x1e\x9b\x44\x0e\x39\xc4\x8f\x2e\x90\x05\x9f\xb5\x41\xa1\x75"
"\xa6\x6c\x09\xbc\x56\x96\x1d\x53\x72\x5e\xb9\x5f\x4d\xb1\xfa\xb1\xb6"
"\xc1\x34\x7d\x04\x68\xf1\x65\x95\x8c\x9a\xf6\x1e\x44\x7e\x26\xe3\x9c"
"\xca\x0f\x2b\x0f\xd7\x67\x00\x00\x00\x00\x00\x00\x00\x00\x4e\xc9\x5a"
"\x97\xb8\x2c\xce\x54\xd5\xd4\xc8\x4a\xb4\x6a\x5f\x67\xcd\x12\xa1\x73"
"\x2a\x65\xa3\x30\x3b\x5e\xe4\xa0\x65\x09\x5d\x3a\xb3\xf6\xa7\x25\xd9"
"\xee\xfa\xa3\xc5\xa7\xa7\x78\xd7\x3c\x08\xb4\x60\xbe\x72\xf8\xa9\x1d"
"\xcb\x06\x91\x5a\xb0\x34\xac\x06\x36\x71\x60\xb5\x91\xd2\xf5\x12\x43"
"\x03\x85\x34\x20\x08\xbd\xdb\x01\x76\xe4\xc3\x80\x75\x57\xb6\x1b\xe4"
"\xf8\xbf\x6c\xbe\x90\xd0\x4f\x25\xd2\x97\xce\xdd\x3c\x28\x47\x15\x2b"
"\x65\x07\xdc\x55\x21\x43\x7d\x34\xa4\x5c\x8a\x86\xdf\x9b\x29\xef\x89"
"\x19\x61\xfe\x4e\x21\x5f\x84\xfe\x70\x16\xe1\x77\x9a\x16\x4e\x03\x05"
"\x90\x62\xe9\xdc\x39\x77\xb4\x5e\xe8\x22\xc5\x06\xe6\x4c\xcc\xef\x7f"
"\x60\x2f\xad\xbe\xdf\xd9\xc8\x72\xfb\x0e\x91\x8d\xff\xea\xb6\xd0\xfc"
"\xbf\x11\x24\xc5\x0c\x18\x44\x4f\x74\xa1\x8b\x51\x2f\x07\x50\x4f\x2b"
"\x90\xea\xc8\xeb\xf8\xc1\x4b\xe7\xcf\xb1\x59",
317);
syz_usb_connect(0, 0x24, 0x20000280, 0);
}
int main(void)
{
syscall(__NR_mmap, 0x1ffff000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul);
syscall(__NR_mmap, 0x20000000ul, 0x1000000ul, 7ul, 0x32ul, -1, 0ul);
syscall(__NR_mmap, 0x21000000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul);
loop();
return 0;
}
|
the_stack_data/103266356.c | // RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s
struct I { int k[3]; };
struct M { struct I o[2]; };
struct M v1[1] = { [0].o[0 ... 1].k[0 ... 1] = 4, 5 };
unsigned v2[2][3] = {[0 ... 1][0 ... 1] = 2222, 3333};
// CHECK-DAG: %struct._Z1M = type { [2 x %struct._Z1I] }
// CHECK-DAG: %struct._Z1I = type { [3 x i32] }
// CHECK-DAG: [1 x %struct._Z1M] [%struct._Z1M { [2 x %struct._Z1I] [%struct._Z1I { [3 x i32] [i32 4, i32 4, i32 0] }, %struct._Z1I { [3 x i32] [i32 4, i32 4, i32 5] }] }],
// CHECK-DAG: [2 x [3 x i32]] {{[[][[]}}3 x i32] [i32 2222, i32 2222, i32 0], [3 x i32] [i32 2222, i32 2222, i32 3333]],
// CHECK-DAG: [[INIT14:.*]] = private global [16 x i32] [i32 0, i32 0, i32 0, i32 0, i32 0, i32 17, i32 17, i32 17, i32 17, i32 17, i32 17, i32 17, i32 0, i32 0, i32 0, i32 0], align 4
void f1() {
// Scalars in braces.
int a = { 1 };
}
void f2() {
int a[2][2] = { { 1, 2 }, { 3, 4 } };
int b[3][3] = { { 1, 2 }, { 3, 4 } };
int *c[2] = { &a[1][1], &b[2][2] };
int *d[2][2] = { {&a[1][1], &b[2][2]}, {&a[0][0], &b[1][1]} };
int *e[3][3] = { {&a[1][1], &b[2][2]}, {&a[0][0], &b[1][1]} };
char ext[3][3] = {".Y",".U",".V"};
}
typedef void (* F)(void);
extern void foo(void);
struct S { F f; };
void f3() {
struct S a[1] = { { foo } };
}
// Constants
// CHECK-DAG: @g3 = constant i32 10
// CHECK-DAG: @f4.g4 = internal constant i32 12
const int g3 = 10;
int f4() {
static const int g4 = 12;
return g4;
}
// PR6537
typedef union vec3 {
struct { double x, y, z; };
double component[3];
} vec3;
vec3 f5(vec3 value) {
return (vec3) {{
.x = value.x
}};
}
// rdar://problem/8154689
void f6() {
int x;
long ids[] = { (long) &x };
}
// CHECK-DAG: @test7 = global{{.*}}{ i32 0, [4 x i8] c"bar\00" }
// PR8217
struct a7 {
int b;
char v[];
};
struct a7 test7 = { .b = 0, .v = "bar" };
// CHECK-DAG: @huge_array = global {{.*}} <{ i32 1, i32 0, i32 2, i32 0, i32 3, [999999995 x i32] zeroinitializer }>
int huge_array[1000000000] = {1, 0, 2, 0, 3, 0, 0, 0};
// CHECK-DAG: @huge_struct = global {{.*}} { i32 1, <{ i32, [999999999 x i32] }> <{ i32 2, [999999999 x i32] zeroinitializer }> }
struct Huge {
int a;
int arr[1000 * 1000 * 1000];
} huge_struct = {1, {2, 0, 0, 0}};
// CHECK-DAG: @large_array_with_zeroes = constant <{ [21 x i8], [979 x i8] }> <{ [21 x i8] c"abc\01\02\03xyzzy\00\00\00\00\00\00\00\00\00q", [979 x i8] zeroinitializer }>
const char large_array_with_zeroes[1000] = {
'a', 'b', 'c', 1, 2, 3, 'x', 'y', 'z', 'z', 'y', [20] = 'q'
};
char global;
// CHECK-DAG: @large_array_with_zeroes_2 = global <{ [10 x i8*], [90 x i8*] }> <{ [10 x i8*] [i8* null, i8* null, i8* null, i8* null, i8* null, i8* null, i8* null, i8* null, i8* null, i8* @global], [90 x i8*] zeroinitializer }>
const void *large_array_with_zeroes_2[100] = {
[9] = &global
};
// CHECK-DAG: @large_array_with_zeroes_3 = global <{ [10 x i8*], [990 x i8*] }> <{ [10 x i8*] [i8* null, i8* null, i8* null, i8* null, i8* null, i8* null, i8* null, i8* null, i8* null, i8* @global], [990 x i8*] zeroinitializer }>
const void *large_array_with_zeroes_3[1000] = {
[9] = &global
};
// PR279 comment #3
char test8(int X) {
char str[100000] = "abc"; // tail should be memset.
return str[X];
// CHECK-LABEL: @test8(
// CHECK: call void @llvm.memset
// CHECK: store i8 97, i8* %{{[0-9]*}}, align 1
// CHECK: store i8 98, i8* %{{[0-9]*}}, align 1
// CHECK: store i8 99, i8* %{{[0-9]*}}, align 1
// CHECK-NOT: getelementptr
// CHECK: load
}
void bar(void*);
// PR279
void test9(int X) {
int Arr[100] = { X }; // Should use memset
bar(Arr);
// CHECK-LABEL: @test9(
// CHECK: call void @llvm.memset
// CHECK-NOT: store i32 0
// CHECK: call void @bar
}
struct a {
int a, b, c, d, e, f, g, h, i, j, k, *p;
};
struct b {
struct a a,b,c,d,e,f,g;
};
void test10(int X) {
struct b S = { .a.a = X, .d.e = X, .f.e = 0, .f.f = 0, .f.p = 0 };
bar(&S);
// CHECK-LABEL: @test10(
// CHECK: call void @llvm.memset
// CHECK-NOT: store i32 0
// CHECK: call void @bar
}
void nonzeroMemseti8() {
char arr[33] = { 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, };
// CHECK-LABEL: @nonzeroMemseti8(
// CHECK-NOT: store
// CHECK-NOT: memcpy
// CHECK: call void @llvm.memset.p0i8.i32(i8* {{.*}}, i8 42, i32 33, i1 false)
}
void nonzeroMemseti16() {
unsigned short arr[17] = { 0x4242, 0x4242, 0x4242, 0x4242, 0x4242, 0x4242, 0x4242, 0x4242, 0x4242, 0x4242, 0x4242, 0x4242, 0x4242, 0x4242, 0x4242, 0x4242, 0x4242, };
// CHECK-LABEL: @nonzeroMemseti16(
// CHECK-NOT: store
// CHECK-NOT: memcpy
// CHECK: call void @llvm.memset.p0i8.i32(i8* {{.*}}, i8 66, i32 34, i1 false)
}
void nonzeroMemseti32() {
unsigned arr[9] = { 0xF0F0F0F0, 0xF0F0F0F0, 0xF0F0F0F0, 0xF0F0F0F0, 0xF0F0F0F0, 0xF0F0F0F0, 0xF0F0F0F0, 0xF0F0F0F0, 0xF0F0F0F0, };
// CHECK-LABEL: @nonzeroMemseti32(
// CHECK-NOT: store
// CHECK-NOT: memcpy
// CHECK: call void @llvm.memset.p0i8.i32(i8* {{.*}}, i8 -16, i32 36, i1 false)
}
void nonzeroMemseti64() {
unsigned long long arr[7] = { 0xAAAAAAAAAAAAAAAA, 0xAAAAAAAAAAAAAAAA, 0xAAAAAAAAAAAAAAAA, 0xAAAAAAAAAAAAAAAA, 0xAAAAAAAAAAAAAAAA, 0xAAAAAAAAAAAAAAAA, 0xAAAAAAAAAAAAAAAA, };
// CHECK-LABEL: @nonzeroMemseti64(
// CHECK-NOT: store
// CHECK-NOT: memcpy
// CHECK: call void @llvm.memset.p0i8.i32(i8* {{.*}}, i8 -86, i32 56, i1 false)
}
void nonzeroMemsetf32() {
float arr[9] = { 0x1.cacacap+75, 0x1.cacacap+75, 0x1.cacacap+75, 0x1.cacacap+75, 0x1.cacacap+75, 0x1.cacacap+75, 0x1.cacacap+75, 0x1.cacacap+75, 0x1.cacacap+75, };
// CHECK-LABEL: @nonzeroMemsetf32(
// CHECK-NOT: store
// CHECK-NOT: memcpy
// CHECK: call void @llvm.memset.p0i8.i32(i8* {{.*}}, i8 101, i32 36, i1 false)
}
void nonzeroMemsetf64() {
double arr[7] = { 0x1.4444444444444p+69, 0x1.4444444444444p+69, 0x1.4444444444444p+69, 0x1.4444444444444p+69, 0x1.4444444444444p+69, 0x1.4444444444444p+69, 0x1.4444444444444p+69, };
// CHECK-LABEL: @nonzeroMemsetf64(
// CHECK-NOT: store
// CHECK-NOT: memcpy
// CHECK: call void @llvm.memset.p0i8.i32(i8* {{.*}}, i8 68, i32 56, i1 false)
}
void nonzeroPaddedUnionMemset() {
union U { char c; int i; };
union U arr[9] = { 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, };
// CHECK-LABEL: @nonzeroPaddedUnionMemset(
// CHECK-NOT: store
// CHECK-NOT: memcpy
// CHECK: call void @llvm.memset.p0i8.i32(i8* {{.*}}, i8 -16, i32 36, i1 false)
}
void nonzeroNestedMemset() {
union U { char c; int i; };
struct S { union U u; short i; };
struct S arr[5] = { { {0xF0}, 0xF0F0 }, { {0xF0}, 0xF0F0 }, { {0xF0}, 0xF0F0 }, { {0xF0}, 0xF0F0 }, { {0xF0}, 0xF0F0 }, };
// CHECK-LABEL: @nonzeroNestedMemset(
// CHECK-NOT: store
// CHECK-NOT: memcpy
// CHECK: call void @llvm.memset.p0i8.i32(i8* {{.*}}, i8 -16, i32 40, i1 false)
}
// PR9257
struct test11S {
int A[10];
};
void test11(struct test11S *P) {
*P = (struct test11S) { .A = { [0 ... 3] = 4 } };
// CHECK-LABEL: @test11(
// CHECK: store i32 4, i32* %{{.*}}, align 4
// CHECK: store i32 4, i32* %{{.*}}, align 4
// CHECK: store i32 4, i32* %{{.*}}, align 4
// CHECK: store i32 4, i32* %{{.*}}, align 4
// CHECK: ret void
}
// Verify that we can convert a recursive struct with a memory that returns
// an instance of the struct we're converting.
struct test12 {
struct test12 (*p)(void);
} test12g;
void test13(int x) {
struct X { int a; int b : 10; int c; };
struct X y = {.c = x};
// CHECK-LABEL: @test13(
// CHECK: and i16 {{.*}}, -1024
}
// CHECK-LABEL: @PR20473(
void PR20473() {
// CHECK: memcpy{{.*}}bitcast ([2 x i8]* @
bar((char[2]) {""});
// CHECK: memcpy{{.*}}bitcast ([3 x i8]* @
bar((char[3]) {""});
}
// Test that we initialize large member arrays by copying from a global and not
// with a series of stores.
struct S14 { int a[16]; };
void test14(struct S14 *s14) {
// CHECK-LABEL: @test14(
// CHECK: call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 {{.*}}, i8* align 4 {{.*}} [[INIT14]] {{.*}}, i32 64, i1 false)
// CHECK-NOT: store
// CHECK: ret void
*s14 = (struct S14) { { [5 ... 11] = 17 } };
}
|
the_stack_data/26699151.c | #include <curses.h>
#include <stddef.h>
char * slk_label(int labnum)
{
return NULL;
}
/*
XOPEN(400)
LINK(curses)
*/
|
the_stack_data/36076479.c | void hello(void) {}
|
the_stack_data/395360.c | /* Jyothiraditya Nellakra's Solutions to Project Euler Questions */
#include <inttypes.h>
#include <stdio.h>
int64_t sumofdigs(int64_t n) {
int64_t sum = 0;
while(n > 0) {
int64_t mod = n % 10;
sum += mod * mod;
n /= 10;
}
return sum;
}
int64_t endof(int64_t n) {
while(n != 1 && n != 89) n = sumofdigs(n);
return n;
}
int main() {
int64_t sum = 0;
for(int64_t i = 1; i < 10000000; i++)
if(endof(i) == 89) sum++;
printf("%" PRId64 "\n", sum);
return 0;
} |
the_stack_data/98576186.c | /*
* Copyright (c) 2017-2019 Cisco and/or its affiliates.
* 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.
*/
#ifdef WITH_POLICY
#include <hicn/hicn-light/config.h>
#include <ctype.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <parc/assert/parc_Assert.h>
#include <parc/algol/parc_Memory.h>
#include <parc/algol/parc_Network.h>
#include <hicn/config/controlAddPolicy.h>
#include <hicn/utils/commands.h>
#include <hicn/utils/utils.h>
#include <hicn/utils/token.h>
static CommandReturn _controlAddPolicy_Execute(CommandParser *parser,
CommandOps *ops, PARCList *args,
char *output,
size_t output_size);
static CommandReturn _controlAddPolicy_HelpExecute(CommandParser *parser,
CommandOps *ops,
PARCList *args,
char *output,
size_t output_size);
static const char *_commandAddPolicy = "add policy";
static const char *_commandAddPolicyHelp = "help add policy";
CommandOps *controlAddPolicy_Create(ControlState *state) {
return commandOps_Create(state, _commandAddPolicy, NULL,
_controlAddPolicy_Execute, commandOps_Destroy);
}
CommandOps *controlAddPolicy_HelpCreate(ControlState *state) {
return commandOps_Create(state, _commandAddPolicyHelp, NULL,
_controlAddPolicy_HelpExecute, commandOps_Destroy);
}
// ====================================================
static CommandReturn _controlAddPolicy_HelpExecute(CommandParser *parser,
CommandOps *ops,
PARCList *args,
char *output,
size_t output_size) {
size_t output_offset = snprintf(output, output_size, "commands:\n"
" add policy <prefix> <app_name>");
#define _(x, y) output_offset += snprintf(output + output_offset, output_size - output_offset, " FLAG:%s", policy_tag_str[POLICY_TAG_ ## x]);
foreach_policy_tag
#undef _
output_offset += snprintf(output + output_offset, output_size - output_offset,"\n");
printf("\n");
output_offset += snprintf(output + output_offset, output_size - output_offset,
" prefix: The hicn name as IPv4 or IPv6 address (e.g 1234::0/64)\n"
" app_name: The application name associated to this policy\n"
" FLAG:*: A value among [neutral|require|prefer|avoid|prohibit] with an optional '!' character prefix for disabling changes\n"
"\n");
return CommandReturn_Success;
}
static CommandReturn _controlAddPolicy_Execute(CommandParser *parser,
CommandOps *ops,
PARCList *args,
char *output,
size_t output_size) {
ControlState *state = ops->closure;
if (parcList_Size(args) != 11) {
_controlAddPolicy_HelpExecute(parser, ops, args, output, output_size);
return CommandReturn_Failure;
}
const char *prefixStr = parcList_GetAtIndex(args, 2);
char *addr = (char *)malloc((strlen(prefixStr) + 1) * sizeof(char));
// separate address and len
char *slash;
uint32_t len = 0;
strcpy(addr, prefixStr);
slash = strrchr(addr, '/');
if (slash != NULL) {
len = atoi(slash + 1);
*slash = '\0';
}
// allocate command payload
add_policy_command *addPolicyCommand =
parcMemory_AllocateAndClear(sizeof(add_policy_command));
// check and set IP address
if (inet_pton(AF_INET, addr, &addPolicyCommand->address.v4.as_u32) == 1) {
if (len > 32) {
snprintf(output, output_size, "ERROR: exceeded INET mask length, max=32\n");
parcMemory_Deallocate(&addPolicyCommand);
free(addr);
return CommandReturn_Failure;
}
addPolicyCommand->addressType = ADDR_INET;
} else if (inet_pton(AF_INET6, addr, &addPolicyCommand->address.v6.as_in6addr) == 1) {
if (len > 128) {
snprintf(output, output_size, "ERROR: exceeded INET6 mask length, max=128\n");
parcMemory_Deallocate(&addPolicyCommand);
free(addr);
return CommandReturn_Failure;
}
addPolicyCommand->addressType = ADDR_INET6;
} else {
snprintf(output, output_size, "Error: %s is not a valid network address \n", addr);
parcMemory_Deallocate(&addPolicyCommand);
free(addr);
return CommandReturn_Failure;
}
free(addr);
addPolicyCommand->len = len;
hicn_policy_t policy;
snprintf((char*)policy.app_name, APP_NAME_LEN, "%s", (char*)parcList_GetAtIndex(args, 3));
for (int i=4; i < 11; i++) {
const char *tag = parcList_GetAtIndex(args, i);
policy_tag_state_t tag_state;
tag_state.disabled = (tag[0] == '!') ? 1 : 0;
if (strcmp(&tag[tag_state.disabled], "neutral") == 0) {
tag_state.state = POLICY_STATE_NEUTRAL;
} else if (strcmp(&tag[tag_state.disabled], "require") == 0) {
tag_state.state = POLICY_STATE_REQUIRE;
} else if (strcmp(&tag[tag_state.disabled], "prefer") == 0) {
tag_state.state = POLICY_STATE_PREFER;
} else if (strcmp(&tag[tag_state.disabled], "avoid") == 0) {
tag_state.state = POLICY_STATE_AVOID;
} else if (strcmp(&tag[tag_state.disabled], "prohibit") == 0) {
tag_state.state = POLICY_STATE_PROHIBIT;
} else {
snprintf(output, output_size, "ERROR: invalid tag value '%s'\n", tag);
parcMemory_Deallocate(&addPolicyCommand);
free(addr);
return CommandReturn_Failure;
}
policy.tags[i-4] = tag_state;
}
addPolicyCommand->policy = policy;
// send message and receive response
struct iovec *response = utils_SendRequest(state, ADD_POLICY, addPolicyCommand,
sizeof(add_policy_command));
if (!response) { // get NULL pointer
return CommandReturn_Failure;
}
parcMemory_Deallocate(&response); // free iovec pointer
return CommandReturn_Success;
}
#endif /* WITH_POLICY */
|
the_stack_data/206391849.c | /* Computes the dimensional weight of a 12'' x 10'' x 8'' box */
#include <stdio.h>
int main(void)
{
int height = 8, length = 12, width = 10, volume;
volume = height * length * width;
printf("Dimensions: %dx%dx%d\n", length, width, height);
printf("Volume: %d\n", volume);
printf("Dimensional weight (pounds): %d\n", (volume + 165) / 166);
return 0;
} |
the_stack_data/91617.c | #include <stdlib.h>
typedef struct stringlistnode {
char *node;
struct stringlistnode *next;
} stringlist;
void stringlist_append(stringlist *pos, stringlist *new) {
new->next = pos->next;
pos->next = new;
}
stringlist stringlist_new(int itemSize, char *items[]) {
stringlist *total;
for(int i = 0; i < itemSize; i++) {
stringlist *new;
new = malloc(sizeof(stringlist));
new->node = items[i];
}
}
|
the_stack_data/1107531.c | #include <string.h>
int dieSimulator(int n, int* rollMax, int rollMaxSize)
{
static const int MOD = 1e9 + 7;
int faces = rollMaxSize;
long dp[n + 1][faces + 1];
memset(dp, 0, sizeof(dp));
dp[0][faces] = 1;
for (int i = 0; i < faces; ++i)
dp[1][i] = 1;
dp[1][faces] = faces;
for (int i = 2; i <= n; ++i)
{
for (int j = 0; j < faces; ++j)
{
for (int k = 1; k <= rollMax[j] && i - k >= 0; ++k)
dp[i][j] = (dp[i][j] + dp[i - k][faces] - dp[i - k][j] + MOD) % MOD;
dp[i][faces] = (dp[i][faces] + dp[i][j]) % MOD;
}
}
return dp[n][faces];
}
|
the_stack_data/1120277.c | // RUN: %clang_cc1 %s -verify
void f1(void) __attribute__((ownership_takes("foo"))); // expected-error {{'ownership_takes' attribute requires parameter 1 to be an identifier}}
void *f2(void) __attribute__((ownership_returns(foo, 1, 2))); // expected-error {{'ownership_returns' attribute takes no more than 1 argument}}
void f3(void) __attribute__((ownership_holds(foo, 1))); // expected-error {{'ownership_holds' attribute parameter 1 is out of bounds}}
void *f4(void) __attribute__((ownership_returns(foo)));
void f5(void) __attribute__((ownership_holds(foo))); // expected-error {{'ownership_holds' attribute takes at least 2 arguments}}
void f6(void) __attribute__((ownership_holds(foo, 1, 2, 3))); // expected-error {{'ownership_holds' attribute parameter 1 is out of bounds}}
void f7(void) __attribute__((ownership_takes(foo))); // expected-error {{'ownership_takes' attribute takes at least 2 arguments}}
void f8(int *i, int *j, int k) __attribute__((ownership_holds(foo, 1, 2, 4))); // expected-error {{'ownership_holds' attribute parameter 3 is out of bounds}}
int f9 __attribute__((ownership_takes(foo, 1))); // expected-warning {{'ownership_takes' attribute only applies to functions}}
void f10(int i) __attribute__((ownership_holds(foo, 1))); // expected-error {{'ownership_holds' attribute only applies to pointer arguments}}
void *f11(float i) __attribute__((ownership_returns(foo, 1))); // expected-error {{'ownership_returns' attribute only applies to integer arguments}}
void *f12(float i, int k, int f, int *j) __attribute__((ownership_returns(foo, 4))); // expected-error {{'ownership_returns' attribute only applies to integer arguments}}
void f13(int *i, int *j) __attribute__((ownership_holds(foo, 1))) __attribute__((ownership_takes(foo, 2)));
void f14(int i, int j, int *k) __attribute__((ownership_holds(foo, 3))) __attribute__((ownership_takes(foo, 3))); // expected-error {{'ownership_holds' and 'ownership_takes' attributes are not compatible}}
void f15(int, int)
__attribute__((ownership_returns(foo, 1))) // expected-note {{declared with index 1 here}}
__attribute__((ownership_returns(foo, 2))); // expected-error {{'ownership_returns' attribute index does not match; here it is 2}}
void f16(int *i, int *j) __attribute__((ownership_holds(foo, 1))) __attribute__((ownership_holds(foo, 1))); // OK, same index
void f17(void*) __attribute__((ownership_takes(__, 1)));
|
the_stack_data/19913.c | #include <stdio.h>
int main()
{
// initializing the 3-dimensional array
int x[2][3][2] =
{
{ {0,1}, {2,3}, {4,5} },
{ {6,7}, {8,9}, {10,11} }
};
//output each element's value
for (int i = 0; i < 2; ++i)
{
for(int j = 0; j < 3; ++j)
{
for (int k = 0; k<2; ++k)
{
printf("Element at x[%d],[%d],[%d] = %d\n", i, j, k, x[i][j][k]);
}
}
}
return 0;
} |
the_stack_data/650525.c | #include <string.h>
#include <ctype.h>
/*
The strcasecmp() function shall compare, while ignoring differences in case,
the string pointed to by _l to the string pointed to by _r.
The strncasecmp() function shall compare, while ignoring differences in case,
not more than n bytes from the string pointed to by _l to the string pointed
to by _r.
In the POSIX locale, strcasecmp() and strncasecmp() shall behave as if the
strings had been converted to lowercase and then a byte comparison performed.
The results are unspecified in other locales.
Upon completion, strcasecmp() shall return an integer greater than, equal to,
or less than 0, if the string pointed to by _l is, ignoring case, greater than,
equal to, or less than the string pointed to by _r, respectively.
Upon successful completion, strncasecmp() shall return an integer greater than,
equal to, or less than 0, if the possibly null-terminated array pointed to by
_l is, ignoring case, greater than, equal to, or less than the possibly
null-terminated array pointed to by _r, respectively.
*/
// from musl
int strcasecmp(const char *_l, const char *_r)
{
const unsigned char *l=(const void *)_l;
const unsigned char *r=(const void *)_r;
for (; *l && *r && (*l == *r || tolower(*l) == tolower(*r)); l++, r++);
return tolower(*l) - tolower(*r);
}
|
the_stack_data/206393451.c | #include <stdio.h>
double f(double a) {
return (4.0 / (1.0 + a * a));
}
double pi = 3.141592653589793238462643;
int main() {
double mypi = 0;
int n = 1000000000; // number of points to compute
float h = 1.0 / n;
for (int i = 0; i < n; i++) {
mypi = mypi + f(i * h);
}
mypi = mypi * h;
printf(" pi = %.10f \n", (pi - mypi));
}
|
the_stack_data/1029202.c | /*
--------------------------------------------
Up to 20% marks will be allotted for good programming practice. These include
- Comments: for non-trivial code
- Indentation: align your code properly
- Function use and modular programming
- Do not include anything in the header other than what is already given in the template.
- You are required to allocate memory Dynamically instead of static memory allocation otherwise you might get 0.
- Use of C Structures is mandatory.
- You should use Linked List data structure to solve this problem.
---------------------------------------------
You are given a stream of characters in a line (that is terminated by a newline character). You need to figure out whether the stream of character is a palindrome or not. No other prior information is known to you, and thus it is advisable to dynamically allocate memory whenever a new character is encountered. Use Linked List as a data-structure to efficiently store the data and perform the necessary computation.
Input Format:
Stream of characters, terminated by a newline character
Output Format:
Yes - If the stream of characters forms a palindrome.
No - If the stream of characters does not form a palindrome.
Sample Input 1:
nitin
Sample Output 1:
Yes
Sample Input 2:
abc
Sample Output 2:
No
*/
/* Program to check if a linked list is palindrome */
// The code has been adapted from http://www.geeksforgeeks.org/function-to-check-if-a-singly-linked-list-is-palindrome/
#include<stdio.h>
#include<stdlib.h>
/* Link list node */
struct node
{
char data;
struct node* next;
};
void reverse(struct node**);
int compareLists(struct node*, struct node *);
/* Function to check if given linked list is
palindrome or not */
int isPalindrome(struct node *head)
{
struct node *slow_ptr = head, *fast_ptr = head;
struct node *second_half, *prev_of_slow_ptr = head;
struct node *midnode = NULL; // To handle odd size list
int res = 1; // initialize result
if (head!=NULL && head->next!=NULL)
{
/* Get the middle of the list. Move slow_ptr by 1
and fast_ptrr by 2, slow_ptr will have the middle
node */
while (fast_ptr != NULL && fast_ptr->next != NULL)
{
fast_ptr = fast_ptr->next->next;
/*We need previous of the slow_ptr for
linked lists with odd elements */
prev_of_slow_ptr = slow_ptr;
slow_ptr = slow_ptr->next;
}
/* fast_ptr would become NULL when there are even elements in list.
And not NULL for odd elements. We need to skip the middle node
for odd case and store it somewhere so that we can restore the
original list*/
if (fast_ptr != NULL)
{
midnode = slow_ptr;
slow_ptr = slow_ptr->next;
}
// Now reverse the second half and compare it with first half
second_half = slow_ptr;
prev_of_slow_ptr->next = NULL; // NULL terminate first half
reverse(&second_half); // Reverse the second half
res = compareLists(head, second_half); // compare
/* Construct the original list back */
reverse(&second_half); // Reverse the second half again
if (midnode != NULL) // If there was a mid node (odd size case) which
// was not part of either first half or second half.
{
prev_of_slow_ptr->next = midnode;
midnode->next = second_half;
}
else prev_of_slow_ptr->next = second_half;
}
return res;
}
/* Function to reverse the linked list Note that this
function may change the head */
void reverse(struct node** head_ref)
{
struct node* prev = NULL;
struct node* current = *head_ref;
struct node* next;
while (current != NULL)
{
next = current->next;
current->next = prev;
prev = current;
current = next;
}
*head_ref = prev;
}
/* Function to check if two input lists have same data*/
int compareLists(struct node* head1, struct node *head2)
{
struct node* temp1 = head1;
struct node* temp2 = head2;
while (temp1 && temp2)
{
if (temp1->data == temp2->data)
{
temp1 = temp1->next;
temp2 = temp2->next;
}
else return 0;
}
/* Both are empty reurn 1*/
if (temp1 == NULL && temp2 == NULL)
return 1;
/* Will reach here when one is NULL
and other is not */
return 0;
}
/* Push a node to linked list. Note that this function
changes the head */
void push(struct node** head_ref, char new_data)
{
/* allocate node */
struct node* new_node =
(struct node*) malloc(sizeof(struct node));
/* put in the data */
new_node->data = new_data;
/* link the old list off the new node */
new_node->next = (*head_ref);
/* move the head to pochar to the new node */
(*head_ref) = new_node;
}
// A utility function to print a given linked list
void printList(struct node *ptr)
{
while (ptr != NULL)
{
printf("%c->", ptr->data);
ptr = ptr->next;
}
printf("NULL\n");
}
/* Drier program to test above function*/
int main()
{
/* Start with the empty list */
struct node* head = NULL;
int t = getchar();
while(t!='\n')
{
push(&head,t);
t=getchar();
}
isPalindrome(head)? printf("Yes\n"):
printf("No\n");
return 0;
}
|
the_stack_data/71351.c | /* DataToC output of file <lamps_lib_glsl> */
extern int datatoc_lamps_lib_glsl_size;
extern char datatoc_lamps_lib_glsl[];
int datatoc_lamps_lib_glsl_size = 14348;
char datatoc_lamps_lib_glsl[] = {
13, 10,117,110,105,102,111,114,109, 32,115, 97,109,112,108,101,114, 50, 68, 65,114,114, 97,121, 32,115,104, 97,100,111,119, 67,117, 98,101, 84,101,120,116,117,114,101, 59, 13, 10,117,110,105,102,111,114,109, 32,115, 97,109,112,108,101,114, 50, 68, 65,114,114, 97,121, 32,115,104, 97,100,111,119, 67, 97,115, 99, 97,100,101, 84,101,120,116,117,114,101, 59, 13, 10, 13, 10, 35,100,101,102,105,110,101, 32, 76, 65, 77, 80, 83, 95, 76, 73, 66, 13, 10, 13, 10,108, 97,121,111,117,116, 40,115,116,100, 49, 52, 48, 41, 32,117,110,105,102,111,114,109, 32,115,104, 97,100,111,119, 95, 98,108,111, 99,107, 32,123, 13, 10, 9, 83,104, 97,100,111,119, 68, 97,116, 97, 32, 32, 32, 32, 32, 32, 32, 32,115,104, 97,100,111,119,115, 95,100, 97,116, 97, 91, 77, 65, 88, 95, 83, 72, 65, 68, 79, 87, 93, 59, 13, 10, 9, 83,104, 97,100,111,119, 67,117, 98,101, 68, 97,116, 97, 32, 32, 32, 32,115,104, 97,100,111,119,115, 95, 99,117, 98,101, 95,100, 97,116, 97, 91, 77, 65, 88, 95, 83, 72, 65, 68, 79, 87, 95, 67, 85, 66, 69, 93, 59, 13, 10, 9, 83,104, 97,100,111,119, 67, 97,115, 99, 97,100,101, 68, 97,116, 97, 32,115,104, 97,100,111,119,115, 95, 99, 97,115, 99, 97,100,101, 95,100, 97,116, 97, 91, 77, 65, 88, 95, 83, 72, 65, 68, 79, 87, 95, 67, 65, 83, 67, 65, 68, 69, 93, 59, 13, 10,125, 59, 13, 10, 13, 10,108, 97,121,111,117,116, 40,115,116,100, 49, 52, 48, 41, 32,117,110,105,102,111,114,109, 32,108,105,103,104,116, 95, 98,108,111, 99,107, 32,123, 13, 10, 9, 76,105,103,104,116, 68, 97,116, 97, 32,108,105,103,104,116,115, 95,100, 97,116, 97, 91, 77, 65, 88, 95, 76, 73, 71, 72, 84, 93, 59, 13, 10,125, 59, 13, 10, 13, 10, 47, 42, 32,116,121,112,101, 32, 42, 47, 13, 10, 35,100,101,102,105,110,101, 32, 80, 79, 73, 78, 84, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 48, 46, 48, 13, 10, 35,100,101,102,105,110,101, 32, 83, 85, 78, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 49, 46, 48, 13, 10, 35,100,101,102,105,110,101, 32, 83, 80, 79, 84, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 50, 46, 48, 13, 10, 35,100,101,102,105,110,101, 32, 65, 82, 69, 65, 95, 82, 69, 67, 84, 32, 32, 32, 32, 32, 32, 52, 46, 48, 13, 10, 47, 42, 32, 85,115,101,100, 32,116,111, 32,100,101,102,105,110,101, 32,116,104,101, 32, 97,114,101, 97, 32,108, 97,109,112, 32,115,104, 97,112,101, 44, 32,100,111,101,115,110, 39,116, 32,100,105,114,101, 99,116,108,121, 32, 99,111,114,114,101,115,112,111,110,100, 32,116,111, 32, 97, 32, 66,108,101,110,100,101,114, 32,108, 97,109,112, 32,116,121,112,101, 46, 32, 42, 47, 13, 10, 35,100,101,102,105,110,101, 32, 65, 82, 69, 65, 95, 69, 76, 76, 73, 80, 83, 69, 32, 49, 48, 48, 46, 48, 13, 10, 13, 10, 35,105,102, 32,100,101,102,105,110,101,100, 40, 83, 72, 65, 68, 79, 87, 95, 86, 83, 77, 41, 13, 10, 35,100,101,102,105,110,101, 32, 83,104, 97,100,111,119, 83, 97,109,112,108,101, 32,118,101, 99, 50, 13, 10, 35,100,101,102,105,110,101, 32,115, 97,109,112,108,101, 95, 99,117, 98,101, 40,118,101, 99, 44, 32,105,100, 41, 32, 32, 32, 32,116,101,120,116,117,114,101, 95,111, 99,116, 97,104,101,100,114,111,110, 40,115,104, 97,100,111,119, 67,117, 98,101, 84,101,120,116,117,114,101, 44, 32,118,101, 99, 52, 40,118,101, 99, 44, 32,105,100, 41, 41, 46,114,103, 13, 10, 35,100,101,102,105,110,101, 32,115, 97,109,112,108,101, 95, 99, 97,115, 99, 97,100,101, 40,118,101, 99, 44, 32,105,100, 41, 32,116,101,120,116,117,114,101, 40,115,104, 97,100,111,119, 67, 97,115, 99, 97,100,101, 84,101,120,116,117,114,101, 44, 32,118,101, 99, 51, 40,118,101, 99, 44, 32,105,100, 41, 41, 46,114,103, 13, 10, 35,101,108,105,102, 32,100,101,102,105,110,101,100, 40, 83, 72, 65, 68, 79, 87, 95, 69, 83, 77, 41, 13, 10, 35,100,101,102,105,110,101, 32, 83,104, 97,100,111,119, 83, 97,109,112,108,101, 32,102,108,111, 97,116, 13, 10, 35,100,101,102,105,110,101, 32,115, 97,109,112,108,101, 95, 99,117, 98,101, 40,118,101, 99, 44, 32,105,100, 41, 32, 32, 32, 32,116,101,120,116,117,114,101, 95,111, 99,116, 97,104,101,100,114,111,110, 40,115,104, 97,100,111,119, 67,117, 98,101, 84,101,120,116,117,114,101, 44, 32,118,101, 99, 52, 40,118,101, 99, 44, 32,105,100, 41, 41, 46,114, 13, 10, 35,100,101,102,105,110,101, 32,115, 97,109,112,108,101, 95, 99, 97,115, 99, 97,100,101, 40,118,101, 99, 44, 32,105,100, 41, 32,116,101,120,116,117,114,101, 40,115,104, 97,100,111,119, 67, 97,115, 99, 97,100,101, 84,101,120,116,117,114,101, 44, 32,118,101, 99, 51, 40,118,101, 99, 44, 32,105,100, 41, 41, 46,114, 13, 10, 35,101,108,115,101, 13, 10, 35,100,101,102,105,110,101, 32, 83,104, 97,100,111,119, 83, 97,109,112,108,101, 32,102,108,111, 97,116, 13, 10, 35,100,101,102,105,110,101, 32,115, 97,109,112,108,101, 95, 99,117, 98,101, 40,118,101, 99, 44, 32,105,100, 41, 32, 32, 32, 32,116,101,120,116,117,114,101, 95,111, 99,116, 97,104,101,100,114,111,110, 40,115,104, 97,100,111,119, 67,117, 98,101, 84,101,120,116,117,114,101, 44, 32,118,101, 99, 52, 40,118,101, 99, 44, 32,105,100, 41, 41, 46,114, 13, 10, 35,100,101,102,105,110,101, 32,115, 97,109,112,108,101, 95, 99, 97,115, 99, 97,100,101, 40,118,101, 99, 44, 32,105,100, 41, 32,116,101,120,116,117,114,101, 40,115,104, 97,100,111,119, 67, 97,115, 99, 97,100,101, 84,101,120,116,117,114,101, 44, 32,118,101, 99, 51, 40,118,101, 99, 44, 32,105,100, 41, 41, 46,114, 13, 10, 35,101,110,100,105,102, 13, 10, 13, 10, 35,105,102, 32,100,101,102,105,110,101,100, 40, 83, 72, 65, 68, 79, 87, 95, 86, 83, 77, 41, 13, 10, 35,100,101,102,105,110,101, 32,103,101,116, 95,100,101,112,116,104, 95,100,101,108,116, 97, 40,100,105,115,116, 44, 32,115, 41, 32, 40,100,105,115,116, 32, 45, 32,115, 46,120, 41, 13, 10, 35,101,108,115,101, 13, 10, 35,100,101,102,105,110,101, 32,103,101,116, 95,100,101,112,116,104, 95,100,101,108,116, 97, 40,100,105,115,116, 44, 32,115, 41, 32, 40,100,105,115,116, 32, 45, 32,115, 41, 13, 10, 35,101,110,100,105,102, 13, 10, 13, 10, 47, 42, 32, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 32, 42, 47, 13, 10, 47, 42, 32, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 32, 83,104, 97,100,111,119, 32,116,101,115,116,115, 32, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 32, 42, 47, 13, 10, 47, 42, 32, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 32, 42, 47, 13, 10, 13, 10, 35,105,102, 32,100,101,102,105,110,101,100, 40, 83, 72, 65, 68, 79, 87, 95, 86, 83, 77, 41, 13, 10, 13, 10,102,108,111, 97,116, 32,115,104, 97,100,111,119, 95,116,101,115,116, 40, 83,104, 97,100,111,119, 83, 97,109,112,108,101, 32,109,111,109,101,110,116,115, 44, 32,102,108,111, 97,116, 32,100,105,115,116, 44, 32, 83,104, 97,100,111,119, 68, 97,116, 97, 32,115,100, 41, 13, 10,123, 13, 10, 9,102,108,111, 97,116, 32,112, 32, 61, 32, 48, 46, 48, 59, 13, 10, 13, 10, 9,105,102, 32, 40,100,105,115,116, 32, 60, 61, 32,109,111,109,101,110,116,115, 46,120, 41, 32,123, 13, 10, 9, 9,112, 32, 61, 32, 49, 46, 48, 59, 13, 10, 9,125, 13, 10, 13, 10, 9,102,108,111, 97,116, 32,118, 97,114,105, 97,110, 99,101, 32, 61, 32,109,111,109,101,110,116,115, 46,121, 32, 45, 32, 40,109,111,109,101,110,116,115, 46,120, 32, 42, 32,109,111,109,101,110,116,115, 46,120, 41, 59, 13, 10, 9,118, 97,114,105, 97,110, 99,101, 32, 61, 32,109, 97,120, 40,118, 97,114,105, 97,110, 99,101, 44, 32,115,100, 46,115,104, 95, 98,105, 97,115, 32, 47, 32, 49, 48, 46, 48, 41, 59, 13, 10, 13, 10, 9,102,108,111, 97,116, 32,100, 32, 61, 32,109,111,109,101,110,116,115, 46,120, 32, 45, 32,100,105,115,116, 59, 13, 10, 9,102,108,111, 97,116, 32,112, 95,109, 97,120, 32, 61, 32,118, 97,114,105, 97,110, 99,101, 32, 47, 32, 40,118, 97,114,105, 97,110, 99,101, 32, 43, 32,100, 32, 42, 32,100, 41, 59, 13, 10, 13, 10, 9, 47, 42, 32, 78,111,119, 32,114,101,100,117, 99,101, 32,108,105,103,104,116, 45, 98,108,101,101,100,105,110,103, 32, 98,121, 32,114,101,109,111,118,105,110,103, 32,116,104,101, 32, 91, 48, 44, 32,120, 93, 32,116, 97,105,108, 32, 97,110,100, 32,108,105,110,101, 97,114,108,121, 32,114,101,115, 99, 97,108,105,110,103, 32, 40,120, 44, 32, 49, 93, 32, 42, 47, 13, 10, 9,112, 95,109, 97,120, 32, 61, 32, 99,108, 97,109,112, 40, 40,112, 95,109, 97,120, 32, 45, 32,115,100, 46,115,104, 95, 98,108,101,101,100, 41, 32, 47, 32, 40, 49, 46, 48, 32, 45, 32,115,100, 46,115,104, 95, 98,108,101,101,100, 41, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, 13, 10, 13, 10, 9,114,101,116,117,114,110, 32,109, 97,120, 40,112, 44, 32,112, 95,109, 97,120, 41, 59, 13, 10,125, 13, 10, 13, 10, 35,101,108,105,102, 32,100,101,102,105,110,101,100, 40, 83, 72, 65, 68, 79, 87, 95, 69, 83, 77, 41, 13, 10, 13, 10,102,108,111, 97,116, 32,115,104, 97,100,111,119, 95,116,101,115,116, 40, 83,104, 97,100,111,119, 83, 97,109,112,108,101, 32,122, 44, 32,102,108,111, 97,116, 32,100,105,115,116, 44, 32, 83,104, 97,100,111,119, 68, 97,116, 97, 32,115,100, 41, 13, 10,123, 13, 10, 9,114,101,116,117,114,110, 32,115, 97,116,117,114, 97,116,101, 40,101,120,112, 40,115,100, 46,115,104, 95,101,120,112, 32, 42, 32, 40,122, 32, 45, 32,100,105,115,116, 32, 43, 32,115,100, 46,115,104, 95, 98,105, 97,115, 41, 41, 41, 59, 13, 10,125, 13, 10, 13, 10, 35,101,108,115,101, 13, 10, 13, 10,102,108,111, 97,116, 32,115,104, 97,100,111,119, 95,116,101,115,116, 40, 83,104, 97,100,111,119, 83, 97,109,112,108,101, 32,122, 44, 32,102,108,111, 97,116, 32,100,105,115,116, 44, 32, 83,104, 97,100,111,119, 68, 97,116, 97, 32,115,100, 41, 13, 10,123, 13, 10, 9,114,101,116,117,114,110, 32,115,116,101,112, 40, 48, 44, 32,122, 32, 45, 32,100,105,115,116, 32, 43, 32,115,100, 46,115,104, 95, 98,105, 97,115, 41, 59, 13, 10,125, 13, 10, 13, 10, 35,101,110,100,105,102, 13, 10, 13, 10, 47, 42, 32, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 32, 42, 47, 13, 10, 47, 42, 32, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 32, 83,104, 97,100,111,119, 32,116,121,112,101,115, 32, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 32, 42, 47, 13, 10, 47, 42, 32, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 32, 42, 47, 13, 10, 13, 10,102,108,111, 97,116, 32,115,104, 97,100,111,119, 95, 99,117, 98,101,109, 97,112, 40, 83,104, 97,100,111,119, 68, 97,116, 97, 32,115,100, 44, 32, 83,104, 97,100,111,119, 67,117, 98,101, 68, 97,116, 97, 32,115, 99,100, 44, 32,102,108,111, 97,116, 32,116,101,120,105,100, 44, 32,118,101, 99, 51, 32, 87, 41, 13, 10,123, 13, 10, 9,118,101, 99, 51, 32, 99,117, 98,101,118,101, 99, 32, 61, 32, 87, 32, 45, 32,115, 99,100, 46,112,111,115,105,116,105,111,110, 46,120,121,122, 59, 13, 10, 9,102,108,111, 97,116, 32,100,105,115,116, 32, 61, 32,108,101,110,103,116,104, 40, 99,117, 98,101,118,101, 99, 41, 59, 13, 10, 13, 10, 9, 99,117, 98,101,118,101, 99, 32, 47, 61, 32,100,105,115,116, 59, 13, 10, 13, 10, 9, 83,104, 97,100,111,119, 83, 97,109,112,108,101, 32,115, 32, 61, 32,115, 97,109,112,108,101, 95, 99,117, 98,101, 40, 99,117, 98,101,118,101, 99, 44, 32,116,101,120,105,100, 41, 59, 13, 10, 9,114,101,116,117,114,110, 32,115,104, 97,100,111,119, 95,116,101,115,116, 40,115, 44, 32,100,105,115,116, 44, 32,115,100, 41, 59, 13, 10,125, 13, 10, 13, 10,102,108,111, 97,116, 32,101,118, 97,108,117, 97,116,101, 95, 99, 97,115, 99, 97,100,101, 40, 83,104, 97,100,111,119, 68, 97,116, 97, 32,115,100, 44, 32,109, 97,116, 52, 32,115,104, 97,100,111,119,109, 97,116, 44, 32,118,101, 99, 51, 32, 87, 44, 32,102,108,111, 97,116, 32,114, 97,110,103,101, 44, 32,102,108,111, 97,116, 32,116,101,120,105,100, 41, 13, 10,123, 13, 10, 9,118,101, 99, 52, 32,115,104,112,111,115, 32, 61, 32,115,104, 97,100,111,119,109, 97,116, 32, 42, 32,118,101, 99, 52, 40, 87, 44, 32, 49, 46, 48, 41, 59, 13, 10, 9,102,108,111, 97,116, 32,100,105,115,116, 32, 61, 32,115,104,112,111,115, 46,122, 32, 42, 32,114, 97,110,103,101, 59, 13, 10, 13, 10, 9, 83,104, 97,100,111,119, 83, 97,109,112,108,101, 32,115, 32, 61, 32,115, 97,109,112,108,101, 95, 99, 97,115, 99, 97,100,101, 40,115,104,112,111,115, 46,120,121, 44, 32,116,101,120,105,100, 41, 59, 13, 10, 9,102,108,111, 97,116, 32,118,105,115, 32, 61, 32,115,104, 97,100,111,119, 95,116,101,115,116, 40,115, 44, 32,100,105,115,116, 44, 32,115,100, 41, 59, 13, 10, 13, 10, 9, 47, 42, 32, 73,102, 32,102,114, 97,103,109,101,110,116, 32,105,115, 32,111,117,116, 32,111,102, 32,115,104, 97,100,111,119,109, 97,112, 32,114, 97,110,103,101, 44, 32,100,111, 32,110,111,116, 32,111, 99, 99,108,117,100,101, 32, 42, 47, 13, 10, 9,105,102, 32, 40,115,104,112,111,115, 46,122, 32, 60, 32, 49, 46, 48, 32, 38, 38, 32,115,104,112,111,115, 46,122, 32, 62, 32, 48, 46, 48, 41, 32,123, 13, 10, 9, 9,114,101,116,117,114,110, 32,118,105,115, 59, 13, 10, 9,125, 13, 10, 9,101,108,115,101, 32,123, 13, 10, 9, 9,114,101,116,117,114,110, 32, 49, 46, 48, 59, 13, 10, 9,125, 13, 10,125, 13, 10, 13, 10,102,108,111, 97,116, 32,115,104, 97,100,111,119, 95, 99, 97,115, 99, 97,100,101, 40, 83,104, 97,100,111,119, 68, 97,116, 97, 32,115,100, 44, 32,105,110,116, 32,115, 99,100, 95,105,100, 44, 32,102,108,111, 97,116, 32,116,101,120,105,100, 44, 32,118,101, 99, 51, 32, 87, 41, 13, 10,123, 13, 10, 9,118,101, 99, 52, 32,118,105,101,119, 95,122, 32, 61, 32,118,101, 99, 52, 40,100,111,116, 40, 87, 32, 45, 32, 99, 97,109,101,114, 97, 80,111,115, 44, 32, 99, 97,109,101,114, 97, 70,111,114,119, 97,114,100, 41, 41, 59, 13, 10, 9,118,101, 99, 52, 32,119,101,105,103,104,116,115, 32, 61, 32,115,109,111,111,116,104,115,116,101,112, 40, 13, 10, 9, 32, 32, 32, 32, 32, 32, 32, 32,115,104, 97,100,111,119,115, 95, 99, 97,115, 99, 97,100,101, 95,100, 97,116, 97, 91,115, 99,100, 95,105,100, 93, 46,115,112,108,105,116, 95,101,110,100, 95,100,105,115,116, 97,110, 99,101,115, 44, 13, 10, 9, 32, 32, 32, 32, 32, 32, 32, 32,115,104, 97,100,111,119,115, 95, 99, 97,115, 99, 97,100,101, 95,100, 97,116, 97, 91,115, 99,100, 95,105,100, 93, 46,115,112,108,105,116, 95,115,116, 97,114,116, 95,100,105,115,116, 97,110, 99,101,115, 46,121,122,119,120, 44, 13, 10, 9, 32, 32, 32, 32, 32, 32, 32, 32,118,105,101,119, 95,122, 41, 59, 13, 10, 13, 10, 9,119,101,105,103,104,116,115, 46,121,122,119, 32, 45, 61, 32,119,101,105,103,104,116,115, 46,120,121,122, 59, 13, 10, 13, 10, 9,118,101, 99, 52, 32,118,105,115, 32, 61, 32,118,101, 99, 52, 40, 49, 46, 48, 41, 59, 13, 10, 9,102,108,111, 97,116, 32,114, 97,110,103,101, 32, 61, 32, 97, 98,115, 40,115,100, 46,115,104, 95,102, 97,114, 32, 45, 32,115,100, 46,115,104, 95,110,101, 97,114, 41, 59, 32, 47, 42, 32, 83, 97,109,101, 32,102, 97, 99,116,111,114, 32, 97,115, 32,105,110, 32,103,101,116, 95, 99, 97,115, 99, 97,100,101, 95,119,111,114,108,100, 95,100,105,115,116, 97,110, 99,101, 40, 41, 46, 32, 42, 47, 13, 10, 13, 10, 9, 47, 42, 32, 66,114, 97,110, 99,104,105,110,103, 32,117,115,105,110,103, 32, 40,119,101,105,103,104,116,115, 32, 62, 32, 48, 46, 48, 41, 32,105,115, 32,114,101, 97, 97,108,108,121, 32,115,108,111,111,111,119, 32,111,110, 32,105,110,116,101,108, 32,115,111, 32, 97,118,111,105,100, 32,105,116, 32,102,111,114, 32,110,111,119, 46, 32, 42, 47, 13, 10, 9, 47, 42, 32, 84, 79, 68, 79, 32, 79, 80, 84, 73, 58, 32, 79,110,108,121, 32,100,111, 32, 50, 32,115, 97,109,112,108,101,115, 32, 97,110,100, 32, 98,108,101,110,100, 46, 32, 42, 47, 13, 10, 9,118,105,115, 46,120, 32, 61, 32,101,118, 97,108,117, 97,116,101, 95, 99, 97,115, 99, 97,100,101, 40,115,100, 44, 32,115,104, 97,100,111,119,115, 95, 99, 97,115, 99, 97,100,101, 95,100, 97,116, 97, 91,115, 99,100, 95,105,100, 93, 46,115,104, 97,100,111,119,109, 97,116, 91, 48, 93, 44, 32, 87, 44, 32,114, 97,110,103,101, 44, 32,116,101,120,105,100, 32, 43, 32, 48, 41, 59, 13, 10, 9,118,105,115, 46,121, 32, 61, 32,101,118, 97,108,117, 97,116,101, 95, 99, 97,115, 99, 97,100,101, 40,115,100, 44, 32,115,104, 97,100,111,119,115, 95, 99, 97,115, 99, 97,100,101, 95,100, 97,116, 97, 91,115, 99,100, 95,105,100, 93, 46,115,104, 97,100,111,119,109, 97,116, 91, 49, 93, 44, 32, 87, 44, 32,114, 97,110,103,101, 44, 32,116,101,120,105,100, 32, 43, 32, 49, 41, 59, 13, 10, 9,118,105,115, 46,122, 32, 61, 32,101,118, 97,108,117, 97,116,101, 95, 99, 97,115, 99, 97,100,101, 40,115,100, 44, 32,115,104, 97,100,111,119,115, 95, 99, 97,115, 99, 97,100,101, 95,100, 97,116, 97, 91,115, 99,100, 95,105,100, 93, 46,115,104, 97,100,111,119,109, 97,116, 91, 50, 93, 44, 32, 87, 44, 32,114, 97,110,103,101, 44, 32,116,101,120,105,100, 32, 43, 32, 50, 41, 59, 13, 10, 9,118,105,115, 46,119, 32, 61, 32,101,118, 97,108,117, 97,116,101, 95, 99, 97,115, 99, 97,100,101, 40,115,100, 44, 32,115,104, 97,100,111,119,115, 95, 99, 97,115, 99, 97,100,101, 95,100, 97,116, 97, 91,115, 99,100, 95,105,100, 93, 46,115,104, 97,100,111,119,109, 97,116, 91, 51, 93, 44, 32, 87, 44, 32,114, 97,110,103,101, 44, 32,116,101,120,105,100, 32, 43, 32, 51, 41, 59, 13, 10, 13, 10, 9,102,108,111, 97,116, 32,119,101,105,103,104,116, 95,115,117,109, 32, 61, 32,100,111,116, 40,118,101, 99, 52, 40, 49, 46, 48, 41, 44, 32,119,101,105,103,104,116,115, 41, 59, 13, 10, 9,105,102, 32, 40,119,101,105,103,104,116, 95,115,117,109, 32, 62, 32, 48, 46, 57, 57, 57, 57, 41, 32,123, 13, 10, 9, 9,102,108,111, 97,116, 32,118,105,115, 95,115,117,109, 32, 61, 32,100,111,116, 40,118,101, 99, 52, 40, 49, 46, 48, 41, 44, 32,118,105,115, 32, 42, 32,119,101,105,103,104,116,115, 41, 59, 13, 10, 9, 9,114,101,116,117,114,110, 32,118,105,115, 95,115,117,109, 32, 47, 32,119,101,105,103,104,116, 95,115,117,109, 59, 13, 10, 9,125, 13, 10, 9,101,108,115,101, 32,123, 13, 10, 9, 9,102,108,111, 97,116, 32,118,105,115, 95,115,117,109, 32, 61, 32,100,111,116, 40,118,101, 99, 52, 40, 49, 46, 48, 41, 44, 32,118,105,115, 32, 42, 32,115,116,101,112, 40, 48, 46, 48, 48, 49, 44, 32,119,101,105,103,104,116,115, 41, 41, 59, 13, 10, 9, 9,114,101,116,117,114,110, 32,109,105,120, 40, 49, 46, 48, 44, 32,118,105,115, 95,115,117,109, 44, 32,119,101,105,103,104,116, 95,115,117,109, 41, 59, 13, 10, 9,125, 13, 10,125, 13, 10, 13, 10, 47, 42, 32, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 32, 42, 47, 13, 10, 47, 42, 32, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 32, 76,105,103,104,116, 32, 70,117,110, 99,116,105,111,110,115, 32, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 32, 42, 47, 13, 10, 47, 42, 32, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 32, 42, 47, 13, 10, 13, 10, 47, 42, 32, 70,114,111,109, 32, 70,114,111,115,116, 98,105,116,101, 32, 80, 66, 82, 32, 67,111,117,114,115,101, 13, 10, 32, 42, 32, 68,105,115,116, 97,110, 99,101, 32, 98, 97,115,101,100, 32, 97,116,116,101,110,117, 97,116,105,111,110, 13, 10, 32, 42, 32,104,116,116,112, 58, 47, 47,119,119,119, 46,102,114,111,115,116, 98,105,116,101, 46, 99,111,109, 47,119,112, 45, 99,111,110,116,101,110,116, 47,117,112,108,111, 97,100,115, 47, 50, 48, 49, 52, 47, 49, 49, 47, 99,111,117,114,115,101, 95,110,111,116,101,115, 95,109,111,118,105,110,103, 95,102,114,111,115,116, 98,105,116,101, 95,116,111, 95,112, 98,114, 46,112,100,102, 32, 42, 47, 13, 10,102,108,111, 97,116, 32,100,105,115,116, 97,110, 99,101, 95, 97,116,116,101,110,117, 97,116,105,111,110, 40,102,108,111, 97,116, 32,100,105,115,116, 95,115,113,114, 44, 32,102,108,111, 97,116, 32,105,110,118, 95,115,113,114, 95,105,110,102,108,117,101,110, 99,101, 41, 13, 10,123, 13, 10, 9,102,108,111, 97,116, 32,102, 97, 99,116,111,114, 32, 61, 32,100,105,115,116, 95,115,113,114, 32, 42, 32,105,110,118, 95,115,113,114, 95,105,110,102,108,117,101,110, 99,101, 59, 13, 10, 9,102,108,111, 97,116, 32,102, 97, 99, 32, 61, 32,115, 97,116,117,114, 97,116,101, 40, 49, 46, 48, 32, 45, 32,102, 97, 99,116,111,114, 32, 42, 32,102, 97, 99,116,111,114, 41, 59, 13, 10, 9,114,101,116,117,114,110, 32,102, 97, 99, 32, 42, 32,102, 97, 99, 59, 13, 10,125, 13, 10, 13, 10,102,108,111, 97,116, 32,115,112,111,116, 95, 97,116,116,101,110,117, 97,116,105,111,110, 40, 76,105,103,104,116, 68, 97,116, 97, 32,108,100, 44, 32,118,101, 99, 51, 32,108, 95,118,101, 99,116,111,114, 41, 13, 10,123, 13, 10, 9,102,108,111, 97,116, 32,122, 32, 61, 32,100,111,116, 40,108,100, 46,108, 95,102,111,114,119, 97,114,100, 44, 32,108, 95,118,101, 99,116,111,114, 46,120,121,122, 41, 59, 13, 10, 9,118,101, 99, 51, 32,108, 76, 32, 61, 32,108, 95,118,101, 99,116,111,114, 46,120,121,122, 32, 47, 32,122, 59, 13, 10, 9,102,108,111, 97,116, 32,120, 32, 61, 32,100,111,116, 40,108,100, 46,108, 95,114,105,103,104,116, 44, 32,108, 76, 41, 32, 47, 32,108,100, 46,108, 95,115,105,122,101,120, 59, 13, 10, 9,102,108,111, 97,116, 32,121, 32, 61, 32,100,111,116, 40,108,100, 46,108, 95,117,112, 44, 32,108, 76, 41, 32, 47, 32,108,100, 46,108, 95,115,105,122,101,121, 59, 13, 10, 9,102,108,111, 97,116, 32,101,108,108,105,112,115,101, 32, 61, 32,105,110,118,101,114,115,101,115,113,114,116, 40, 49, 46, 48, 32, 43, 32,120, 32, 42, 32,120, 32, 43, 32,121, 32, 42, 32,121, 41, 59, 13, 10, 9,102,108,111, 97,116, 32,115,112,111,116,109, 97,115,107, 32, 61, 32,115,109,111,111,116,104,115,116,101,112, 40, 48, 46, 48, 44, 32, 49, 46, 48, 44, 32, 40,101,108,108,105,112,115,101, 32, 45, 32,108,100, 46,108, 95,115,112,111,116, 95,115,105,122,101, 41, 32, 47, 32,108,100, 46,108, 95,115,112,111,116, 95, 98,108,101,110,100, 41, 59, 13, 10, 9,114,101,116,117,114,110, 32,115,112,111,116,109, 97,115,107, 59, 13, 10,125, 13, 10, 13, 10,102,108,111, 97,116, 32,108,105,103,104,116, 95,118,105,115,105, 98,105,108,105,116,121, 40, 76,105,103,104,116, 68, 97,116, 97, 32,108,100, 44, 32,118,101, 99, 51, 32, 87, 44, 13, 10, 35,105,102,110,100,101,102, 32, 86, 79, 76, 85, 77, 69, 84, 82, 73, 67, 83, 13, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,118,101, 99, 51, 32,118,105,101,119, 80,111,115,105,116,105,111,110, 44, 13, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,118,101, 99, 51, 32,118,105,101,119, 78,111,114,109, 97,108, 44, 13, 10, 35,101,110,100,105,102, 13, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,118,101, 99, 52, 32,108, 95,118,101, 99,116,111,114, 41, 13, 10,123, 13, 10, 9,102,108,111, 97,116, 32,118,105,115, 32, 61, 32, 49, 46, 48, 59, 13, 10, 13, 10, 9,105,102, 32, 40,108,100, 46,108, 95,116,121,112,101, 32, 61, 61, 32, 83, 80, 79, 84, 41, 32,123, 13, 10, 9, 9,118,105,115, 32, 42, 61, 32,115,112,111,116, 95, 97,116,116,101,110,117, 97,116,105,111,110, 40,108,100, 44, 32,108, 95,118,101, 99,116,111,114, 46,120,121,122, 41, 59, 13, 10, 9,125, 13, 10, 9,105,102, 32, 40,108,100, 46,108, 95,116,121,112,101, 32, 62, 61, 32, 83, 80, 79, 84, 41, 32,123, 13, 10, 9, 9,118,105,115, 32, 42, 61, 32,115,116,101,112, 40, 48, 46, 48, 44, 32, 45,100,111,116, 40,108, 95,118,101, 99,116,111,114, 46,120,121,122, 44, 32,108,100, 46,108, 95,102,111,114,119, 97,114,100, 41, 41, 59, 13, 10, 9,125, 13, 10, 9,105,102, 32, 40,108,100, 46,108, 95,116,121,112,101, 32, 33, 61, 32, 83, 85, 78, 41, 32,123, 13, 10, 9, 9,118,105,115, 32, 42, 61, 32,100,105,115,116, 97,110, 99,101, 95, 97,116,116,101,110,117, 97,116,105,111,110, 40,108, 95,118,101, 99,116,111,114, 46,119, 32, 42, 32,108, 95,118,101, 99,116,111,114, 46,119, 44, 32,108,100, 46,108, 95,105,110,102,108,117,101,110, 99,101, 41, 59, 13, 10, 9,125, 13, 10, 13, 10, 35,105,102, 32, 33,100,101,102,105,110,101,100, 40, 86, 79, 76, 85, 77, 69, 84, 82, 73, 67, 83, 41, 32,124,124, 32,100,101,102,105,110,101,100, 40, 86, 79, 76, 85, 77, 69, 95, 83, 72, 65, 68, 79, 87, 41, 13, 10, 9, 47, 42, 32,115,104, 97,100,111,119,105,110,103, 32, 42, 47, 13, 10, 9,105,102, 32, 40,108,100, 46,108, 95,115,104, 97,100,111,119,105,100, 32, 62, 61, 32, 48, 46, 48, 32, 38, 38, 32,118,105,115, 32, 62, 32, 48, 46, 48, 48, 49, 41, 32,123, 13, 10, 9, 9, 83,104, 97,100,111,119, 68, 97,116, 97, 32,100, 97,116, 97, 32, 61, 32,115,104, 97,100,111,119,115, 95,100, 97,116, 97, 91,105,110,116, 40,108,100, 46,108, 95,115,104, 97,100,111,119,105,100, 41, 93, 59, 13, 10, 13, 10, 9, 9,105,102, 32, 40,108,100, 46,108, 95,116,121,112,101, 32, 61, 61, 32, 83, 85, 78, 41, 32,123, 13, 10, 9, 9, 9,118,105,115, 32, 42, 61, 32,115,104, 97,100,111,119, 95, 99, 97,115, 99, 97,100,101, 40, 13, 10, 9, 9, 9, 9,100, 97,116, 97, 44, 32,105,110,116, 40,100, 97,116, 97, 46,115,104, 95,100, 97,116, 97, 95,115,116, 97,114,116, 41, 44, 13, 10, 9, 9, 9, 9,100, 97,116, 97, 46,115,104, 95,116,101,120, 95,115,116, 97,114,116, 44, 32, 87, 41, 59, 13, 10, 9, 9,125, 13, 10, 9, 9,101,108,115,101, 32,123, 13, 10, 9, 9, 9,118,105,115, 32, 42, 61, 32,115,104, 97,100,111,119, 95, 99,117, 98,101,109, 97,112, 40, 13, 10, 9, 9, 9, 9,100, 97,116, 97, 44, 32,115,104, 97,100,111,119,115, 95, 99,117, 98,101, 95,100, 97,116, 97, 91,105,110,116, 40,100, 97,116, 97, 46,115,104, 95,100, 97,116, 97, 95,115,116, 97,114,116, 41, 93, 44, 13, 10, 9, 9, 9, 9,100, 97,116, 97, 46,115,104, 95,116,101,120, 95,115,116, 97,114,116, 44, 32, 87, 41, 59, 13, 10, 9, 9,125, 13, 10, 13, 10, 35,105,102,110,100,101,102, 32, 86, 79, 76, 85, 77, 69, 84, 82, 73, 67, 83, 13, 10, 9, 9, 47, 42, 32, 79,110,108,121, 32, 99,111,109,112,117,116,101, 32,105,102, 32,110,111,116, 32, 97,108,114,101, 97,100,121, 32,105,110, 32,115,104, 97,100,111,119, 46, 32, 42, 47, 13, 10, 9, 9,105,102, 32, 40,100, 97,116, 97, 46,115,104, 95, 99,111,110,116, 97, 99,116, 95,100,105,115,116, 32, 62, 32, 48, 46, 48, 41, 32,123, 13, 10, 9, 9, 9,118,101, 99, 52, 32, 76, 32, 61, 32, 40,108,100, 46,108, 95,116,121,112,101, 32, 33, 61, 32, 83, 85, 78, 41, 32, 63, 32,108, 95,118,101, 99,116,111,114, 32, 58, 32,118,101, 99, 52, 40, 45,108,100, 46,108, 95,102,111,114,119, 97,114,100, 44, 32, 49, 46, 48, 41, 59, 13, 10, 9, 9, 9,102,108,111, 97,116, 32,116,114, 97, 99,101, 95,100,105,115,116, 97,110, 99,101, 32, 61, 32, 40,108,100, 46,108, 95,116,121,112,101, 32, 33, 61, 32, 83, 85, 78, 41, 32, 63, 32,109,105,110, 40,100, 97,116, 97, 46,115,104, 95, 99,111,110,116, 97, 99,116, 95,100,105,115,116, 44, 32,108, 95,118,101, 99,116,111,114, 46,119, 41, 32, 58, 32,100, 97,116, 97, 46,115,104, 95, 99,111,110,116, 97, 99,116, 95,100,105,115,116, 59, 13, 10, 13, 10, 9, 9, 9,118,101, 99, 51, 32, 84, 44, 32, 66, 59, 13, 10, 9, 9, 9,109, 97,107,101, 95,111,114,116,104,111,110,111,114,109, 97,108, 95, 98, 97,115,105,115, 40, 76, 46,120,121,122, 32, 47, 32, 76, 46,119, 44, 32, 84, 44, 32, 66, 41, 59, 13, 10, 13, 10, 9, 9, 9,118,101, 99, 52, 32,114, 97,110,100, 32, 61, 32,116,101,120,101,108,102,101,116, 99,104, 95,110,111,105,115,101, 95,116,101,120, 40,103,108, 95, 70,114, 97,103, 67,111,111,114,100, 46,120,121, 41, 59, 13, 10, 9, 9, 9,114, 97,110,100, 46,122,119, 32, 42, 61, 32,102, 97,115,116, 95,115,113,114,116, 40,114, 97,110,100, 46,121, 41, 32, 42, 32,100, 97,116, 97, 46,115,104, 95, 99,111,110,116, 97, 99,116, 95,115,112,114,101, 97,100, 59, 13, 10, 13, 10, 9, 9, 9, 47, 42, 32, 87,101, 32,117,115,101, 32,116,104,101, 32,102,117,108,108, 32,108, 95,118,101, 99,116,111,114, 46,120,121,122, 32,115,111, 32,116,104, 97,116, 32,116,104,101, 32,115,112,114,101, 97,100, 32,105,115, 32,109,105,110,105,109,105,122,101, 13, 10, 9, 9, 9, 32, 42, 32,105,102, 32,116,104,101, 32,115,104, 97,100,105,110,103, 32,112,111,105,110,116, 32,105,115, 32,102,117,114,116,104,101,114, 32, 97,119, 97,121, 32,102,114,111,109, 32,116,104,101, 32,108,105,103,104,116, 32,115,111,117,114, 99,101, 32, 42, 47, 13, 10, 9, 9, 9,118,101, 99, 51, 32,114, 97,121, 95,100,105,114, 32, 61, 32, 76, 46,120,121,122, 32, 43, 32, 84, 32, 42, 32,114, 97,110,100, 46,122, 32, 43, 32, 66, 32, 42, 32,114, 97,110,100, 46,119, 59, 13, 10, 9, 9, 9,114, 97,121, 95,100,105,114, 32, 61, 32,116,114, 97,110,115,102,111,114,109, 95,100,105,114,101, 99,116,105,111,110, 40, 86,105,101,119, 77, 97,116,114,105,120, 44, 32,114, 97,121, 95,100,105,114, 41, 59, 13, 10, 9, 9, 9,114, 97,121, 95,100,105,114, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40,114, 97,121, 95,100,105,114, 41, 59, 13, 10, 13, 10, 9, 9, 9,118,101, 99, 51, 32,114, 97,121, 95,111,114,105, 32, 61, 32,118,105,101,119, 80,111,115,105,116,105,111,110, 59, 13, 10, 13, 10, 9, 9, 9,105,102, 32, 40,100,111,116, 40,118,105,101,119, 78,111,114,109, 97,108, 44, 32,114, 97,121, 95,100,105,114, 41, 32, 60, 61, 32, 48, 46, 48, 41, 32,123, 13, 10, 9, 9, 9, 9,114,101,116,117,114,110, 32,118,105,115, 59, 13, 10, 9, 9, 9,125, 13, 10, 13, 10, 9, 9, 9,102,108,111, 97,116, 32, 98,105, 97,115, 32, 61, 32, 48, 46, 53, 59, 32, 47, 42, 32, 67,111,110,115,116, 97,110,116, 32, 66,105, 97,115, 32, 42, 47, 13, 10, 9, 9, 9, 98,105, 97,115, 32, 43, 61, 32, 49, 46, 48, 32, 45, 32, 97, 98,115, 40,100,111,116, 40,118,105,101,119, 78,111,114,109, 97,108, 44, 32,114, 97,121, 95,100,105,114, 41, 41, 59, 32, 47, 42, 32, 65,110,103,108,101, 32,100,101,112,101,110,100,101,110,116, 32, 98,105, 97,115, 32, 42, 47, 13, 10, 9, 9, 9, 98,105, 97,115, 32, 42, 61, 32,103,108, 95, 70,114,111,110,116, 70, 97, 99,105,110,103, 32, 63, 32,100, 97,116, 97, 46,115,104, 95, 99,111,110,116, 97, 99,116, 95,111,102,102,115,101,116, 32, 58, 32, 45,100, 97,116, 97, 46,115,104, 95, 99,111,110,116, 97, 99,116, 95,111,102,102,115,101,116, 59, 13, 10, 13, 10, 9, 9, 9,118,101, 99, 51, 32,110,111,114, 95, 98,105, 97,115, 32, 61, 32,118,105,101,119, 78,111,114,109, 97,108, 32, 42, 32, 98,105, 97,115, 59, 13, 10, 9, 9, 9,114, 97,121, 95,111,114,105, 32, 43, 61, 32,110,111,114, 95, 98,105, 97,115, 59, 13, 10, 13, 10, 9, 9, 9,114, 97,121, 95,100,105,114, 32, 42, 61, 32,116,114, 97, 99,101, 95,100,105,115,116, 97,110, 99,101, 59, 13, 10, 9, 9, 9,114, 97,121, 95,100,105,114, 32, 45, 61, 32,110,111,114, 95, 98,105, 97,115, 59, 13, 10, 13, 10, 9, 9, 9,118,101, 99, 51, 32,104,105,116, 95,112,111,115, 32, 61, 32,114, 97,121, 99, 97,115,116, 40, 45, 49, 44, 32,114, 97,121, 95,111,114,105, 44, 32,114, 97,121, 95,100,105,114, 44, 32,100, 97,116, 97, 46,115,104, 95, 99,111,110,116, 97, 99,116, 95,116,104,105, 99,107,110,101,115,115, 44, 32,114, 97,110,100, 46,120, 44, 13, 10, 9, 9, 9, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 48, 46, 49, 44, 32, 48, 46, 48, 48, 49, 44, 32,102, 97,108,115,101, 41, 59, 13, 10, 13, 10, 9, 9, 9,105,102, 32, 40,104,105,116, 95,112,111,115, 46,122, 32, 62, 32, 48, 46, 48, 41, 32,123, 13, 10, 9, 9, 9, 9,104,105,116, 95,112,111,115, 32, 61, 32,103,101,116, 95,118,105,101,119, 95,115,112, 97, 99,101, 95,102,114,111,109, 95,100,101,112,116,104, 40,104,105,116, 95,112,111,115, 46,120,121, 44, 32,104,105,116, 95,112,111,115, 46,122, 41, 59, 13, 10, 9, 9, 9, 9,102,108,111, 97,116, 32,104,105,116, 95,100,105,115,116, 32, 61, 32,100,105,115,116, 97,110, 99,101, 40,118,105,101,119, 80,111,115,105,116,105,111,110, 44, 32,104,105,116, 95,112,111,115, 41, 59, 13, 10, 9, 9, 9, 9,102,108,111, 97,116, 32,100,105,115,116, 95,114, 97,116,105,111, 32, 61, 32,104,105,116, 95,100,105,115,116, 32, 47, 32,116,114, 97, 99,101, 95,100,105,115,116, 97,110, 99,101, 59, 13, 10, 9, 9, 9, 9,114,101,116,117,114,110, 32,118,105,115, 32, 42, 32,115, 97,116,117,114, 97,116,101, 40,100,105,115,116, 95,114, 97,116,105,111, 32, 42, 32,100,105,115,116, 95,114, 97,116,105,111, 32, 42, 32,100,105,115,116, 95,114, 97,116,105,111, 41, 59, 13, 10, 9, 9, 9,125, 13, 10, 9, 9,125, 13, 10, 35,101,110,100,105,102, 13, 10, 9,125, 13, 10, 35,101,110,100,105,102, 13, 10, 13, 10, 9,114,101,116,117,114,110, 32,118,105,115, 59, 13, 10,125, 13, 10, 13, 10, 35,105,102,100,101,102, 32, 85, 83, 69, 95, 76, 84, 67, 13, 10,102,108,111, 97,116, 32,108,105,103,104,116, 95,100,105,102,102,117,115,101, 40, 76,105,103,104,116, 68, 97,116, 97, 32,108,100, 44, 32,118,101, 99, 51, 32, 78, 44, 32,118,101, 99, 51, 32, 86, 44, 32,118,101, 99, 52, 32,108, 95,118,101, 99,116,111,114, 41, 13, 10,123, 13, 10, 9,105,102, 32, 40,108,100, 46,108, 95,116,121,112,101, 32, 61, 61, 32, 65, 82, 69, 65, 95, 82, 69, 67, 84, 41, 32,123, 13, 10, 9, 9,118,101, 99, 51, 32, 99,111,114,110,101,114,115, 91, 52, 93, 59, 13, 10, 9, 9, 99,111,114,110,101,114,115, 91, 48, 93, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40, 40,108, 95,118,101, 99,116,111,114, 46,120,121,122, 32, 43, 32,108,100, 46,108, 95,114,105,103,104,116, 32, 42, 32, 45,108,100, 46,108, 95,115,105,122,101,120, 41, 32, 43, 32,108,100, 46,108, 95,117,112, 32, 42, 32, 32,108,100, 46,108, 95,115,105,122,101,121, 41, 59, 13, 10, 9, 9, 99,111,114,110,101,114,115, 91, 49, 93, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40, 40,108, 95,118,101, 99,116,111,114, 46,120,121,122, 32, 43, 32,108,100, 46,108, 95,114,105,103,104,116, 32, 42, 32, 45,108,100, 46,108, 95,115,105,122,101,120, 41, 32, 43, 32,108,100, 46,108, 95,117,112, 32, 42, 32, 45,108,100, 46,108, 95,115,105,122,101,121, 41, 59, 13, 10, 9, 9, 99,111,114,110,101,114,115, 91, 50, 93, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40, 40,108, 95,118,101, 99,116,111,114, 46,120,121,122, 32, 43, 32,108,100, 46,108, 95,114,105,103,104,116, 32, 42, 32, 32,108,100, 46,108, 95,115,105,122,101,120, 41, 32, 43, 32,108,100, 46,108, 95,117,112, 32, 42, 32, 45,108,100, 46,108, 95,115,105,122,101,121, 41, 59, 13, 10, 9, 9, 99,111,114,110,101,114,115, 91, 51, 93, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40, 40,108, 95,118,101, 99,116,111,114, 46,120,121,122, 32, 43, 32,108,100, 46,108, 95,114,105,103,104,116, 32, 42, 32, 32,108,100, 46,108, 95,115,105,122,101,120, 41, 32, 43, 32,108,100, 46,108, 95,117,112, 32, 42, 32, 32,108,100, 46,108, 95,115,105,122,101,121, 41, 59, 13, 10, 13, 10, 9, 9,114,101,116,117,114,110, 32,108,116, 99, 95,101,118, 97,108,117, 97,116,101, 95,113,117, 97,100, 40, 99,111,114,110,101,114,115, 44, 32, 78, 41, 59, 13, 10, 9,125, 13, 10, 9,101,108,115,101, 32,105,102, 32, 40,108,100, 46,108, 95,116,121,112,101, 32, 61, 61, 32, 65, 82, 69, 65, 95, 69, 76, 76, 73, 80, 83, 69, 41, 32,123, 13, 10, 9, 9,118,101, 99, 51, 32,112,111,105,110,116,115, 91, 51, 93, 59, 13, 10, 9, 9,112,111,105,110,116,115, 91, 48, 93, 32, 61, 32, 40,108, 95,118,101, 99,116,111,114, 46,120,121,122, 32, 43, 32,108,100, 46,108, 95,114,105,103,104,116, 32, 42, 32, 45,108,100, 46,108, 95,115,105,122,101,120, 41, 32, 43, 32,108,100, 46,108, 95,117,112, 32, 42, 32, 45,108,100, 46,108, 95,115,105,122,101,121, 59, 13, 10, 9, 9,112,111,105,110,116,115, 91, 49, 93, 32, 61, 32, 40,108, 95,118,101, 99,116,111,114, 46,120,121,122, 32, 43, 32,108,100, 46,108, 95,114,105,103,104,116, 32, 42, 32, 32,108,100, 46,108, 95,115,105,122,101,120, 41, 32, 43, 32,108,100, 46,108, 95,117,112, 32, 42, 32, 45,108,100, 46,108, 95,115,105,122,101,121, 59, 13, 10, 9, 9,112,111,105,110,116,115, 91, 50, 93, 32, 61, 32, 40,108, 95,118,101, 99,116,111,114, 46,120,121,122, 32, 43, 32,108,100, 46,108, 95,114,105,103,104,116, 32, 42, 32, 32,108,100, 46,108, 95,115,105,122,101,120, 41, 32, 43, 32,108,100, 46,108, 95,117,112, 32, 42, 32, 32,108,100, 46,108, 95,115,105,122,101,121, 59, 13, 10, 13, 10, 9, 9,114,101,116,117,114,110, 32,108,116, 99, 95,101,118, 97,108,117, 97,116,101, 95,100,105,115,107, 40, 78, 44, 32, 86, 44, 32,109, 97,116, 51, 40, 49, 46, 48, 41, 44, 32,112,111,105,110,116,115, 41, 59, 13, 10, 9,125, 13, 10, 9,101,108,115,101, 32,123, 13, 10, 9, 9,102,108,111, 97,116, 32,114, 97,100,105,117,115, 32, 61, 32,108,100, 46,108, 95,114, 97,100,105,117,115, 59, 13, 10, 9, 9,114, 97,100,105,117,115, 32, 47, 61, 32, 40,108,100, 46,108, 95,116,121,112,101, 32, 61, 61, 32, 83, 85, 78, 41, 32, 63, 32, 49, 46, 48, 32, 58, 32,108, 95,118,101, 99,116,111,114, 46,119, 59, 13, 10, 9, 9,118,101, 99, 51, 32, 76, 32, 61, 32, 40,108,100, 46,108, 95,116,121,112,101, 32, 61, 61, 32, 83, 85, 78, 41, 32, 63, 32, 45,108,100, 46,108, 95,102,111,114,119, 97,114,100, 32, 58, 32, 40,108, 95,118,101, 99,116,111,114, 46,120,121,122, 32, 47, 32,108, 95,118,101, 99,116,111,114, 46,119, 41, 59, 13, 10, 13, 10, 9, 9,114,101,116,117,114,110, 32,108,116, 99, 95,101,118, 97,108,117, 97,116,101, 95,100,105,115,107, 95,115,105,109,112,108,101, 40,114, 97,100,105,117,115, 44, 32,100,111,116, 40, 78, 44, 32, 76, 41, 41, 59, 13, 10, 9,125, 13, 10,125, 13, 10, 13, 10,102,108,111, 97,116, 32,108,105,103,104,116, 95,115,112,101, 99,117,108, 97,114, 40, 76,105,103,104,116, 68, 97,116, 97, 32,108,100, 44, 32,118,101, 99, 52, 32,108,116, 99, 95,109, 97,116, 44, 32,118,101, 99, 51, 32, 78, 44, 32,118,101, 99, 51, 32, 86, 44, 32,118,101, 99, 52, 32,108, 95,118,101, 99,116,111,114, 41, 13, 10,123, 13, 10, 9,105,102, 32, 40,108,100, 46,108, 95,116,121,112,101, 32, 61, 61, 32, 65, 82, 69, 65, 95, 82, 69, 67, 84, 41, 32,123, 13, 10, 9, 9,118,101, 99, 51, 32, 99,111,114,110,101,114,115, 91, 52, 93, 59, 13, 10, 9, 9, 99,111,114,110,101,114,115, 91, 48, 93, 32, 61, 32, 40,108, 95,118,101, 99,116,111,114, 46,120,121,122, 32, 43, 32,108,100, 46,108, 95,114,105,103,104,116, 32, 42, 32, 45,108,100, 46,108, 95,115,105,122,101,120, 41, 32, 43, 32,108,100, 46,108, 95,117,112, 32, 42, 32, 32,108,100, 46,108, 95,115,105,122,101,121, 59, 13, 10, 9, 9, 99,111,114,110,101,114,115, 91, 49, 93, 32, 61, 32, 40,108, 95,118,101, 99,116,111,114, 46,120,121,122, 32, 43, 32,108,100, 46,108, 95,114,105,103,104,116, 32, 42, 32, 45,108,100, 46,108, 95,115,105,122,101,120, 41, 32, 43, 32,108,100, 46,108, 95,117,112, 32, 42, 32, 45,108,100, 46,108, 95,115,105,122,101,121, 59, 13, 10, 9, 9, 99,111,114,110,101,114,115, 91, 50, 93, 32, 61, 32, 40,108, 95,118,101, 99,116,111,114, 46,120,121,122, 32, 43, 32,108,100, 46,108, 95,114,105,103,104,116, 32, 42, 32, 32,108,100, 46,108, 95,115,105,122,101,120, 41, 32, 43, 32,108,100, 46,108, 95,117,112, 32, 42, 32, 45,108,100, 46,108, 95,115,105,122,101,121, 59, 13, 10, 9, 9, 99,111,114,110,101,114,115, 91, 51, 93, 32, 61, 32, 40,108, 95,118,101, 99,116,111,114, 46,120,121,122, 32, 43, 32,108,100, 46,108, 95,114,105,103,104,116, 32, 42, 32, 32,108,100, 46,108, 95,115,105,122,101,120, 41, 32, 43, 32,108,100, 46,108, 95,117,112, 32, 42, 32, 32,108,100, 46,108, 95,115,105,122,101,121, 59, 13, 10, 13, 10, 9, 9,108,116, 99, 95,116,114, 97,110,115,102,111,114,109, 95,113,117, 97,100, 40, 78, 44, 32, 86, 44, 32,108,116, 99, 95,109, 97,116,114,105,120, 40,108,116, 99, 95,109, 97,116, 41, 44, 32, 99,111,114,110,101,114,115, 41, 59, 13, 10, 13, 10, 9, 9,114,101,116,117,114,110, 32,108,116, 99, 95,101,118, 97,108,117, 97,116,101, 95,113,117, 97,100, 40, 99,111,114,110,101,114,115, 44, 32,118,101, 99, 51, 40, 48, 46, 48, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 41, 59, 13, 10, 9,125, 13, 10, 9,101,108,115,101, 32,123, 13, 10, 9, 9, 98,111,111,108, 32,105,115, 95,101,108,108,105,112,115,101, 32, 61, 32, 40,108,100, 46,108, 95,116,121,112,101, 32, 61, 61, 32, 65, 82, 69, 65, 95, 69, 76, 76, 73, 80, 83, 69, 41, 59, 13, 10, 9, 9,102,108,111, 97,116, 32,114, 97,100,105,117,115, 95,120, 32, 61, 32,105,115, 95,101,108,108,105,112,115,101, 32, 63, 32,108,100, 46,108, 95,115,105,122,101,120, 32, 58, 32,108,100, 46,108, 95,114, 97,100,105,117,115, 59, 13, 10, 9, 9,102,108,111, 97,116, 32,114, 97,100,105,117,115, 95,121, 32, 61, 32,105,115, 95,101,108,108,105,112,115,101, 32, 63, 32,108,100, 46,108, 95,115,105,122,101,121, 32, 58, 32,108,100, 46,108, 95,114, 97,100,105,117,115, 59, 13, 10, 13, 10, 9, 9,118,101, 99, 51, 32, 76, 32, 61, 32, 40,108,100, 46,108, 95,116,121,112,101, 32, 61, 61, 32, 83, 85, 78, 41, 32, 63, 32, 45,108,100, 46,108, 95,102,111,114,119, 97,114,100, 32, 58, 32,108, 95,118,101, 99,116,111,114, 46,120,121,122, 59, 13, 10, 9, 9,118,101, 99, 51, 32, 80,120, 32, 61, 32,108,100, 46,108, 95,114,105,103,104,116, 59, 13, 10, 9, 9,118,101, 99, 51, 32, 80,121, 32, 61, 32,108,100, 46,108, 95,117,112, 59, 13, 10, 13, 10, 9, 9,105,102, 32, 40,108,100, 46,108, 95,116,121,112,101, 32, 61, 61, 32, 83, 80, 79, 84, 32,124,124, 32,108,100, 46,108, 95,116,121,112,101, 32, 61, 61, 32, 80, 79, 73, 78, 84, 41, 32,123, 13, 10, 9, 9, 9,109, 97,107,101, 95,111,114,116,104,111,110,111,114,109, 97,108, 95, 98, 97,115,105,115, 40,108, 95,118,101, 99,116,111,114, 46,120,121,122, 32, 47, 32,108, 95,118,101, 99,116,111,114, 46,119, 44, 32, 80,120, 44, 32, 80,121, 41, 59, 13, 10, 9, 9,125, 13, 10, 13, 10, 9, 9,118,101, 99, 51, 32,112,111,105,110,116,115, 91, 51, 93, 59, 13, 10, 9, 9,112,111,105,110,116,115, 91, 48, 93, 32, 61, 32, 40, 76, 32, 43, 32, 80,120, 32, 42, 32, 45,114, 97,100,105,117,115, 95,120, 41, 32, 43, 32, 80,121, 32, 42, 32, 45,114, 97,100,105,117,115, 95,121, 59, 13, 10, 9, 9,112,111,105,110,116,115, 91, 49, 93, 32, 61, 32, 40, 76, 32, 43, 32, 80,120, 32, 42, 32, 32,114, 97,100,105,117,115, 95,120, 41, 32, 43, 32, 80,121, 32, 42, 32, 45,114, 97,100,105,117,115, 95,121, 59, 13, 10, 9, 9,112,111,105,110,116,115, 91, 50, 93, 32, 61, 32, 40, 76, 32, 43, 32, 80,120, 32, 42, 32, 32,114, 97,100,105,117,115, 95,120, 41, 32, 43, 32, 80,121, 32, 42, 32, 32,114, 97,100,105,117,115, 95,121, 59, 13, 10, 13, 10, 9, 9,114,101,116,117,114,110, 32,108,116, 99, 95,101,118, 97,108,117, 97,116,101, 95,100,105,115,107, 40, 78, 44, 32, 86, 44, 32,108,116, 99, 95,109, 97,116,114,105,120, 40,108,116, 99, 95,109, 97,116, 41, 44, 32,112,111,105,110,116,115, 41, 59, 13, 10, 9,125, 13, 10,125, 13, 10, 35,101,110,100,105,102, 13, 10, 13, 10, 35,100,101,102,105,110,101, 32, 77, 65, 88, 95, 83, 83, 83, 95, 83, 65, 77, 80, 76, 69, 83, 32, 54, 53, 13, 10, 35,100,101,102,105,110,101, 32, 83, 83, 83, 95, 76, 85, 84, 95, 83, 73, 90, 69, 32, 54, 52, 46, 48, 13, 10, 35,100,101,102,105,110,101, 32, 83, 83, 83, 95, 76, 85, 84, 95, 83, 67, 65, 76, 69, 32, 40, 40, 83, 83, 83, 95, 76, 85, 84, 95, 83, 73, 90, 69, 32, 45, 32, 49, 46, 48, 41, 32, 47, 32,102,108,111, 97,116, 40, 83, 83, 83, 95, 76, 85, 84, 95, 83, 73, 90, 69, 41, 41, 13, 10, 35,100,101,102,105,110,101, 32, 83, 83, 83, 95, 76, 85, 84, 95, 66, 73, 65, 83, 32, 40, 48, 46, 53, 32, 47, 32,102,108,111, 97,116, 40, 83, 83, 83, 95, 76, 85, 84, 95, 83, 73, 90, 69, 41, 41, 13, 10, 13, 10, 35,105,102,100,101,102, 32, 85, 83, 69, 95, 84, 82, 65, 78, 83, 76, 85, 67, 69, 78, 67, 89, 13, 10,108, 97,121,111,117,116, 40,115,116,100, 49, 52, 48, 41, 32,117,110,105,102,111,114,109, 32,115,115,115, 80,114,111,102,105,108,101, 32,123, 13, 10, 9,118,101, 99, 52, 32,107,101,114,110,101,108, 91, 77, 65, 88, 95, 83, 83, 83, 95, 83, 65, 77, 80, 76, 69, 83, 93, 59, 13, 10, 9,118,101, 99, 52, 32,114, 97,100,105,105, 95,109, 97,120, 95,114, 97,100,105,117,115, 59, 13, 10, 9,105,110,116, 32,115,115,115, 95,115, 97,109,112,108,101,115, 59, 13, 10,125, 59, 13, 10, 13, 10,117,110,105,102,111,114,109, 32,115, 97,109,112,108,101,114, 49, 68, 32,115,115,115, 84,101,120, 80,114,111,102,105,108,101, 59, 13, 10, 13, 10,118,101, 99, 51, 32,115,115,115, 95,112,114,111,102,105,108,101, 40,102,108,111, 97,116, 32,115, 41, 32,123, 13, 10, 9,115, 32, 47, 61, 32,114, 97,100,105,105, 95,109, 97,120, 95,114, 97,100,105,117,115, 46,119, 59, 13, 10, 9,114,101,116,117,114,110, 32,116,101,120,116,117,114,101, 40,115,115,115, 84,101,120, 80,114,111,102,105,108,101, 44, 32,115, 97,116,117,114, 97,116,101, 40,115, 41, 32, 42, 32, 83, 83, 83, 95, 76, 85, 84, 95, 83, 67, 65, 76, 69, 32, 43, 32, 83, 83, 83, 95, 76, 85, 84, 95, 66, 73, 65, 83, 41, 46,114,103, 98, 59, 13, 10,125, 13, 10, 35,101,110,100,105,102, 13, 10, 13, 10,118,101, 99, 51, 32,108,105,103,104,116, 95,116,114, 97,110,115,108,117, 99,101,110,116, 40, 76,105,103,104,116, 68, 97,116, 97, 32,108,100, 44, 32,118,101, 99, 51, 32, 87, 44, 32,118,101, 99, 51, 32, 78, 44, 32,118,101, 99, 52, 32,108, 95,118,101, 99,116,111,114, 44, 32,102,108,111, 97,116, 32,115, 99, 97,108,101, 41, 13, 10,123, 13, 10, 35,105,102, 32, 33,100,101,102,105,110,101,100, 40, 85, 83, 69, 95, 84, 82, 65, 78, 83, 76, 85, 67, 69, 78, 67, 89, 41, 32,124,124, 32,100,101,102,105,110,101,100, 40, 86, 79, 76, 85, 77, 69, 84, 82, 73, 67, 83, 41, 13, 10, 9,114,101,116,117,114,110, 32,118,101, 99, 51, 40, 48, 46, 48, 41, 59, 13, 10, 35,101,108,115,101, 13, 10, 9,118,101, 99, 51, 32,118,105,115, 32, 61, 32,118,101, 99, 51, 40, 49, 46, 48, 41, 59, 13, 10, 13, 10, 9,105,102, 32, 40,108,100, 46,108, 95,116,121,112,101, 32, 61, 61, 32, 83, 80, 79, 84, 41, 32,123, 13, 10, 9, 9,118,105,115, 32, 42, 61, 32,115,112,111,116, 95, 97,116,116,101,110,117, 97,116,105,111,110, 40,108,100, 44, 32,108, 95,118,101, 99,116,111,114, 46,120,121,122, 41, 59, 13, 10, 9,125, 13, 10, 9,105,102, 32, 40,108,100, 46,108, 95,116,121,112,101, 32, 62, 61, 32, 83, 80, 79, 84, 41, 32,123, 13, 10, 9, 9,118,105,115, 32, 42, 61, 32,115,116,101,112, 40, 48, 46, 48, 44, 32, 45,100,111,116, 40,108, 95,118,101, 99,116,111,114, 46,120,121,122, 44, 32,108,100, 46,108, 95,102,111,114,119, 97,114,100, 41, 41, 59, 13, 10, 9,125, 13, 10, 9,105,102, 32, 40,108,100, 46,108, 95,116,121,112,101, 32, 33, 61, 32, 83, 85, 78, 41, 32,123, 13, 10, 9, 9,118,105,115, 32, 42, 61, 32,100,105,115,116, 97,110, 99,101, 95, 97,116,116,101,110,117, 97,116,105,111,110, 40,108, 95,118,101, 99,116,111,114, 46,119, 32, 42, 32,108, 95,118,101, 99,116,111,114, 46,119, 44, 32,108,100, 46,108, 95,105,110,102,108,117,101,110, 99,101, 41, 59, 13, 10, 9,125, 13, 10, 13, 10, 9, 47, 42, 32, 79,110,108,121, 32,115,104, 97,100,111,119,101,100, 32,108,105,103,104,116, 32, 99, 97,110, 32,112,114,111,100,117, 99,101, 32,116,114, 97,110,115,108,117, 99,101,110, 99,121, 32, 42, 47, 13, 10, 9,105,102, 32, 40,108,100, 46,108, 95,115,104, 97,100,111,119,105,100, 32, 62, 61, 32, 48, 46, 48, 32, 38, 38, 32,118,105,115, 46,120, 32, 62, 32, 48, 46, 48, 48, 49, 41, 32,123, 13, 10, 9, 9, 83,104, 97,100,111,119, 68, 97,116, 97, 32,100, 97,116, 97, 32, 61, 32,115,104, 97,100,111,119,115, 95,100, 97,116, 97, 91,105,110,116, 40,108,100, 46,108, 95,115,104, 97,100,111,119,105,100, 41, 93, 59, 13, 10, 9, 9,102,108,111, 97,116, 32,100,101,108,116, 97, 59, 13, 10, 13, 10, 9, 9,118,101, 99, 52, 32, 76, 32, 61, 32, 40,108,100, 46,108, 95,116,121,112,101, 32, 33, 61, 32, 83, 85, 78, 41, 32, 63, 32,108, 95,118,101, 99,116,111,114, 32, 58, 32,118,101, 99, 52, 40, 45,108,100, 46,108, 95,102,111,114,119, 97,114,100, 44, 32, 49, 46, 48, 41, 59, 13, 10, 13, 10, 9, 9,118,101, 99, 51, 32, 84, 44, 32, 66, 59, 13, 10, 9, 9,109, 97,107,101, 95,111,114,116,104,111,110,111,114,109, 97,108, 95, 98, 97,115,105,115, 40, 76, 46,120,121,122, 32, 47, 32, 76, 46,119, 44, 32, 84, 44, 32, 66, 41, 59, 13, 10, 13, 10, 9, 9,118,101, 99, 52, 32,114, 97,110,100, 32, 61, 32,116,101,120,101,108,102,101,116, 99,104, 95,110,111,105,115,101, 95,116,101,120, 40,103,108, 95, 70,114, 97,103, 67,111,111,114,100, 46,120,121, 41, 59, 13, 10, 9, 9,114, 97,110,100, 46,122,119, 32, 42, 61, 32,102, 97,115,116, 95,115,113,114,116, 40,114, 97,110,100, 46,121, 41, 32, 42, 32,100, 97,116, 97, 46,115,104, 95, 98,108,117,114, 59, 13, 10, 13, 10, 9, 9, 47, 42, 32, 87,101, 32,117,115,101, 32,116,104,101, 32,102,117,108,108, 32,108, 95,118,101, 99,116,111,114, 46,120,121,122, 32,115,111, 32,116,104, 97,116, 32,116,104,101, 32,115,112,114,101, 97,100, 32,105,115, 32,109,105,110,105,109,105,122,101, 13, 10, 9, 9, 32, 42, 32,105,102, 32,116,104,101, 32,115,104, 97,100,105,110,103, 32,112,111,105,110,116, 32,105,115, 32,102,117,114,116,104,101,114, 32, 97,119, 97,121, 32,102,114,111,109, 32,116,104,101, 32,108,105,103,104,116, 32,115,111,117,114, 99,101, 32, 42, 47, 13, 10, 9, 9, 87, 32, 61, 32, 87, 32, 43, 32, 84, 32, 42, 32,114, 97,110,100, 46,122, 32, 43, 32, 66, 32, 42, 32,114, 97,110,100, 46,119, 59, 13, 10, 13, 10, 9, 9,105,102, 32, 40,108,100, 46,108, 95,116,121,112,101, 32, 61, 61, 32, 83, 85, 78, 41, 32,123, 13, 10, 9, 9, 9,105,110,116, 32,115, 99,100, 95,105,100, 32, 61, 32,105,110,116, 40,100, 97,116, 97, 46,115,104, 95,100, 97,116, 97, 95,115,116, 97,114,116, 41, 59, 13, 10, 9, 9, 9,118,101, 99, 52, 32,118,105,101,119, 95,122, 32, 61, 32,118,101, 99, 52, 40,100,111,116, 40, 87, 32, 45, 32, 99, 97,109,101,114, 97, 80,111,115, 44, 32, 99, 97,109,101,114, 97, 70,111,114,119, 97,114,100, 41, 41, 59, 13, 10, 13, 10, 9, 9, 9,118,101, 99, 52, 32,119,101,105,103,104,116,115, 32, 61, 32,115,116,101,112, 40,115,104, 97,100,111,119,115, 95, 99, 97,115, 99, 97,100,101, 95,100, 97,116, 97, 91,115, 99,100, 95,105,100, 93, 46,115,112,108,105,116, 95,101,110,100, 95,100,105,115,116, 97,110, 99,101,115, 44, 32,118,105,101,119, 95,122, 41, 59, 13, 10, 9, 9, 9,102,108,111, 97,116, 32,105,100, 32, 61, 32, 97, 98,115, 40, 52, 46, 48, 32, 45, 32,100,111,116, 40,119,101,105,103,104,116,115, 44, 32,119,101,105,103,104,116,115, 41, 41, 59, 13, 10, 13, 10, 9, 9, 9,105,102, 32, 40,105,100, 32, 62, 32, 51, 46, 48, 41, 32,123, 13, 10, 9, 9, 9, 9,114,101,116,117,114,110, 32,118,101, 99, 51, 40, 48, 46, 48, 41, 59, 13, 10, 9, 9, 9,125, 13, 10, 13, 10, 9, 9, 9,102,108,111, 97,116, 32,114, 97,110,103,101, 32, 61, 32, 97, 98,115, 40,100, 97,116, 97, 46,115,104, 95,102, 97,114, 32, 45, 32,100, 97,116, 97, 46,115,104, 95,110,101, 97,114, 41, 59, 32, 47, 42, 32, 83, 97,109,101, 32,102, 97, 99,116,111,114, 32, 97,115, 32,105,110, 32,103,101,116, 95, 99, 97,115, 99, 97,100,101, 95,119,111,114,108,100, 95,100,105,115,116, 97,110, 99,101, 40, 41, 46, 32, 42, 47, 13, 10, 13, 10, 9, 9, 9,118,101, 99, 52, 32,115,104,112,111,115, 32, 61, 32,115,104, 97,100,111,119,115, 95, 99, 97,115, 99, 97,100,101, 95,100, 97,116, 97, 91,115, 99,100, 95,105,100, 93, 46,115,104, 97,100,111,119,109, 97,116, 91,105,110,116, 40,105,100, 41, 93, 32, 42, 32,118,101, 99, 52, 40, 87, 44, 32, 49, 46, 48, 41, 59, 13, 10, 9, 9, 9,102,108,111, 97,116, 32,100,105,115,116, 32, 61, 32,115,104,112,111,115, 46,122, 32, 42, 32,114, 97,110,103,101, 59, 13, 10, 13, 10, 9, 9, 9,105,102, 32, 40,115,104,112,111,115, 46,122, 32, 62, 32, 49, 46, 48, 32,124,124, 32,115,104,112,111,115, 46,122, 32, 60, 32, 48, 46, 48, 41, 32,123, 13, 10, 9, 9, 9, 9,114,101,116,117,114,110, 32,118,101, 99, 51, 40, 48, 46, 48, 41, 59, 13, 10, 9, 9, 9,125, 13, 10, 13, 10, 9, 9, 9, 83,104, 97,100,111,119, 83, 97,109,112,108,101, 32,115, 32, 61, 32,115, 97,109,112,108,101, 95, 99, 97,115, 99, 97,100,101, 40,115,104,112,111,115, 46,120,121, 44, 32,100, 97,116, 97, 46,115,104, 95,116,101,120, 95,115,116, 97,114,116, 32, 43, 32,105,100, 41, 59, 13, 10, 9, 9, 9,100,101,108,116, 97, 32, 61, 32,103,101,116, 95,100,101,112,116,104, 95,100,101,108,116, 97, 40,100,105,115,116, 44, 32,115, 41, 59, 13, 10, 9, 9,125, 13, 10, 9, 9,101,108,115,101, 32,123, 13, 10, 9, 9, 9,118,101, 99, 51, 32, 99,117, 98,101,118,101, 99, 32, 61, 32, 87, 32, 45, 32,115,104, 97,100,111,119,115, 95, 99,117, 98,101, 95,100, 97,116, 97, 91,105,110,116, 40,100, 97,116, 97, 46,115,104, 95,100, 97,116, 97, 95,115,116, 97,114,116, 41, 93, 46,112,111,115,105,116,105,111,110, 46,120,121,122, 59, 13, 10, 9, 9, 9,102,108,111, 97,116, 32,100,105,115,116, 32, 61, 32,108,101,110,103,116,104, 40, 99,117, 98,101,118,101, 99, 41, 59, 13, 10, 9, 9, 9, 99,117, 98,101,118,101, 99, 32, 47, 61, 32,100,105,115,116, 59, 13, 10, 13, 10, 9, 9, 9, 83,104, 97,100,111,119, 83, 97,109,112,108,101, 32,115, 32, 61, 32,115, 97,109,112,108,101, 95, 99,117, 98,101, 40, 99,117, 98,101,118,101, 99, 44, 32,100, 97,116, 97, 46,115,104, 95,116,101,120, 95,115,116, 97,114,116, 41, 59, 13, 10, 9, 9, 9,100,101,108,116, 97, 32, 61, 32,103,101,116, 95,100,101,112,116,104, 95,100,101,108,116, 97, 40,100,105,115,116, 44, 32,115, 41, 59, 13, 10, 9, 9,125, 13, 10, 13, 10, 9, 9, 47, 42, 32, 88, 88, 88, 32, 58, 32, 82,101,109,111,118,105,110,103, 32, 65,114,101, 97, 32, 80,111,119,101,114, 46, 32, 42, 47, 13, 10, 9, 9, 47, 42, 32, 84, 79, 68, 79, 32, 58, 32,112,117,116, 32,116,104,105,115, 32,111,117,116, 32,111,102, 32,116,104,101, 32,115,104, 97,100,101,114, 46, 32, 42, 47, 13, 10, 9, 9,102,108,111, 97,116, 32,102, 97,108,108,111,102,102, 59, 13, 10, 9, 9,105,102, 32, 40,108,100, 46,108, 95,116,121,112,101, 32, 61, 61, 32, 65, 82, 69, 65, 95, 82, 69, 67, 84, 32,124,124, 32,108,100, 46,108, 95,116,121,112,101, 32, 61, 61, 32, 65, 82, 69, 65, 95, 69, 76, 76, 73, 80, 83, 69, 41, 32,123, 13, 10, 9, 9, 9,118,105,115, 32, 42, 61, 32, 40,108,100, 46,108, 95,115,105,122,101,120, 32, 42, 32,108,100, 46,108, 95,115,105,122,101,121, 32, 42, 32, 52, 46, 48, 32, 42, 32, 77, 95, 80, 73, 41, 32, 42, 32, 40, 49, 46, 48, 32, 47, 32, 56, 48, 46, 48, 41, 59, 13, 10, 9, 9, 9,105,102, 32, 40,108,100, 46,108, 95,116,121,112,101, 32, 61, 61, 32, 65, 82, 69, 65, 95, 69, 76, 76, 73, 80, 83, 69, 41, 32,123, 13, 10, 9, 9, 9, 9,118,105,115, 32, 42, 61, 32, 77, 95, 80, 73, 32, 42, 32, 48, 46, 50, 53, 59, 13, 10, 9, 9, 9,125, 13, 10, 9, 9, 9,118,105,115, 32, 42, 61, 32, 48, 46, 51, 32, 42, 32, 50, 48, 46, 48, 32, 42, 32,109, 97,120, 40, 48, 46, 48, 44, 32,100,111,116, 40, 45,108,100, 46,108, 95,102,111,114,119, 97,114,100, 44, 32,108, 95,118,101, 99,116,111,114, 46,120,121,122, 32, 47, 32,108, 95,118,101, 99,116,111,114, 46,119, 41, 41, 59, 32, 47, 42, 32, 88, 88, 88, 32, 97,100, 32,104,111, 99, 44, 32,101,109,112,105,114,105, 99, 97,108, 32, 42, 47, 13, 10, 9, 9, 9,118,105,115, 32, 47, 61, 32, 40,108, 95,118,101, 99,116,111,114, 46,119, 32, 42, 32,108, 95,118,101, 99,116,111,114, 46,119, 41, 59, 13, 10, 9, 9, 9,102, 97,108,108,111,102,102, 32, 61, 32,100,111,116, 40, 78, 44, 32,108, 95,118,101, 99,116,111,114, 46,120,121,122, 32, 47, 32,108, 95,118,101, 99,116,111,114, 46,119, 41, 59, 13, 10, 9, 9,125, 13, 10, 9, 9,101,108,115,101, 32,105,102, 32, 40,108,100, 46,108, 95,116,121,112,101, 32, 61, 61, 32, 83, 85, 78, 41, 32,123, 13, 10, 9, 9, 9,118,105,115, 32, 47, 61, 32, 49, 46, 48,102, 32, 43, 32, 40,108,100, 46,108, 95,114, 97,100,105,117,115, 32, 42, 32,108,100, 46,108, 95,114, 97,100,105,117,115, 32, 42, 32, 48, 46, 53,102, 41, 59, 13, 10, 9, 9, 9,118,105,115, 32, 42, 61, 32,108,100, 46,108, 95,114, 97,100,105,117,115, 32, 42, 32,108,100, 46,108, 95,114, 97,100,105,117,115, 32, 42, 32, 77, 95, 80, 73, 59, 32, 47, 42, 32, 82,101,109,111,118,105,110,103, 32, 97,114,101, 97, 32,108,105,103,104,116, 32,112,111,119,101,114, 42, 47, 13, 10, 9, 9, 9,118,105,115, 32, 42, 61, 32, 77, 95, 50, 80, 73, 32, 42, 32, 48, 46, 55, 56, 59, 32, 47, 42, 32, 77, 97,116, 99,104,105,110,103, 32, 99,121, 99,108,101,115, 32,119,105,116,104, 32,112,111,105,110,116, 32,108,105,103,104,116, 46, 32, 42, 47, 13, 10, 9, 9, 9,118,105,115, 32, 42, 61, 32, 48, 46, 48, 56, 50, 59, 32, 47, 42, 32, 88, 88, 88, 32, 97,100, 32,104,111, 99, 44, 32,101,109,112,105,114,105, 99, 97,108, 32, 42, 47, 13, 10, 9, 9, 9,102, 97,108,108,111,102,102, 32, 61, 32,100,111,116, 40, 78, 44, 32, 45,108,100, 46,108, 95,102,111,114,119, 97,114,100, 41, 59, 13, 10, 9, 9,125, 13, 10, 9, 9,101,108,115,101, 32,123, 13, 10, 9, 9, 9,118,105,115, 32, 42, 61, 32, 40, 52, 46, 48, 32, 42, 32,108,100, 46,108, 95,114, 97,100,105,117,115, 32, 42, 32,108,100, 46,108, 95,114, 97,100,105,117,115, 41, 32, 42, 32, 40, 49, 46, 48, 32, 47, 49, 48, 46, 48, 41, 59, 13, 10, 9, 9, 9,118,105,115, 32, 42, 61, 32, 49, 46, 53, 59, 32, 47, 42, 32, 88, 88, 88, 32, 97,100, 32,104,111, 99, 44, 32,101,109,112,105,114,105, 99, 97,108, 32, 42, 47, 13, 10, 9, 9, 9,118,105,115, 32, 47, 61, 32, 40,108, 95,118,101, 99,116,111,114, 46,119, 32, 42, 32,108, 95,118,101, 99,116,111,114, 46,119, 41, 59, 13, 10, 9, 9, 9,102, 97,108,108,111,102,102, 32, 61, 32,100,111,116, 40, 78, 44, 32,108, 95,118,101, 99,116,111,114, 46,120,121,122, 32, 47, 32,108, 95,118,101, 99,116,111,114, 46,119, 41, 59, 13, 10, 9, 9,125, 13, 10, 9, 9, 47, 47, 32,118,105,115, 32, 42, 61, 32, 77, 95, 49, 95, 80, 73, 59, 32, 47, 42, 32, 78,111,114,109, 97,108,105,122,101, 32, 42, 47, 13, 10, 13, 10, 9, 9, 47, 42, 32, 65,112,112,108,121,105,110,103, 32,112,114,111,102,105,108,101, 32, 42, 47, 13, 10, 9, 9,118,105,115, 32, 42, 61, 32,115,115,115, 95,112,114,111,102,105,108,101, 40, 97, 98,115, 40,100,101,108,116, 97, 41, 32, 47, 32,115, 99, 97,108,101, 41, 59, 13, 10, 13, 10, 9, 9, 47, 42, 32, 78,111, 32,116,114, 97,110,115,109,105,116,116, 97,110, 99,101, 32, 97,116, 32,103,114, 97,122,105,110,103, 32, 97,110,103,108,101, 32, 40,104,105,100,101, 32, 97,114,116,105,102, 97, 99,116,115, 41, 32, 42, 47, 13, 10, 9, 9,118,105,115, 32, 42, 61, 32,115, 97,116,117,114, 97,116,101, 40,102, 97,108,108,111,102,102, 32, 42, 32, 50, 46, 48, 41, 59, 13, 10, 9,125, 13, 10, 9,101,108,115,101, 32,123, 13, 10, 9, 9,118,105,115, 32, 61, 32,118,101, 99, 51, 40, 48, 46, 48, 41, 59, 13, 10, 9,125, 13, 10, 13, 10, 9,114,101,116,117,114,110, 32,118,105,115, 59, 13, 10, 35,101,110,100,105,102, 13, 10,125, 13, 10,0
};
|
the_stack_data/56417.c | /* Convert miles to kilometers, because we don't understand the
metric system
*/
#include <stdio.h>
/* print table for miles = 0,1,2,3 ... 30 */
int main() {
float start,end,by;
float miles,kilometers;
start = 0.0;
end = 30.0;
by = 1.0;
miles = start;
printf("\nMILES\tKILOMETERS\n");
while(miles <= end)
{
kilometers = miles * 1.60934;
printf("%.1f\t%.2f\n",miles,kilometers);
miles = miles + by;
}
return 0;
}
|
the_stack_data/215767168.c | #include<stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct stack {
char data[100];
struct stack *next;
} Stack;
int isEmpty(Stack *stack) {
return stack != NULL;
}
void push(Stack **stack, char *data) {
Stack *temp;
temp = (Stack *) malloc(sizeof(Stack));
strcpy(temp->data, data);
temp->next = *stack;
*stack = temp;
}
char *pop(Stack **stack) {
Stack *temp;
if (isEmpty(*stack)) {
temp = *stack;
*stack = temp->next;
return temp->data;
}
return "";
}
int isOperator(char c) {
switch (c) {
case '*':
case '/':
case '+':
case '-':
case '^':
return 1;
default:
return 0;
}
}
char *convert(char expression[]) {
char *a, *b;
char temp[100];
Stack *stack = (Stack *) malloc(sizeof(Stack));
stack->next = NULL;
stack->data[0] = '\0';
for (int i = 0; i < (int)strlen(expression); i++) {
if (isOperator(expression[i])) {
a = pop(&stack);
b = pop(&stack);
temp[0] = '\0';
strncat(temp, &expression[i], 1);
if (b[0]) {
strncat(temp, b, strlen(b));
}
if (a[0]) {
strncat(temp, a, strlen(a));
}
strncat(temp, "\0", 1);
push(&stack, temp);
} else {
temp[0] = expression[i];
temp[1] = '\0';
push(&stack, temp);
}
}
return stack->data;
}
int main() {
char exp[100];
printf("Enter Postfix expression: ");
scanf("%s", exp);
printf("Prefix: %s", convert(exp));
fflush(stdin);
getchar();
}
|
the_stack_data/176706069.c | #ifdef HAVE_LIBPTHREAD
#include <errno.h>
#include <stddef.h>
#include <strings.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <unistd.h>
#include <libcraft/net/server/server.h>
#include <libcraft/ids.h>
#include <libcraft/log.h>
struct server_info {
int sockfd;
int (*client_connected)(craft_server_client_t client);
};
typedef struct server_info server_info_t;
struct client_info {
int sockfd;
};
typedef struct client_info client_info_t;
void server_accept_loop(void *arg, int i);
craft_server_t craft_server_create() {
craft_server_t id;
server_info_t *server = (server_info_t *) craft_alloc_ref(sizeof(server_info_t), &id, true);
if (server) {
server->sockfd = socket(AF_INET, SOCK_STREAM, 0);
if (server->sockfd < 0) {
ERROR(errno);
return CRAFT_ID_NULL;
} else {
return id;
}
} else {
ERROR(ENOBUFS);
return CRAFT_ID_NULL;
}
}
void craft_server_free(craft_server_t id) {
if (id != CRAFT_ID_NULL) {
server_info_t *server = (server_info_t *) craft_get_ref(id);
if (server) {
close(server->sockfd);
craft_free_ref(id);
}
} else {
ERROR(EINVAL);
}
}
craft_loop_t craft_server_bind(craft_server_t id, int port, size_t backlog, int (*client_connected)(craft_server_client_t client)) {
if (id != CRAFT_ID_NULL && port > 0 && port < 65536 && backlog > 0 && client_connected) {
server_info_t *server = (server_info_t *) craft_get_ref(id);
if (server) {
struct sockaddr_in addr;
bzero(&addr, sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = INADDR_ANY;
addr.sin_port = htons(port);
if (bind(server->sockfd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
ERROR(errno);
return CRAFT_ID_NULL;
} else {
if (listen(server->sockfd, backlog) < 0) {
ERROR(errno);
return CRAFT_ID_NULL;
} else {
server->client_connected = client_connected;
return craft_start_loop(server_accept_loop, server);
}
}
} else {
ERROR(EINVAL);
return CRAFT_ID_NULL;
}
} else {
ERROR(EINVAL);
return CRAFT_ID_NULL;
}
}
int craft_server_read_from(craft_server_client_t id, void *buffer, size_t length) {
if (id != CRAFT_ID_NULL && buffer && length > 0) {
client_info_t *client = (client_info_t *) craft_get_ref(id);
return read(client->sockfd, buffer, length);
} else {
return ERROR(EINVAL);
}
}
int craft_server_send_to(craft_server_client_t id, void *buffer, size_t length) {
if (id != CRAFT_ID_NULL && buffer && length > 0) {
client_info_t *client = (client_info_t *) craft_get_ref(id);
return write(client->sockfd, buffer, length);
} else {
return ERROR(EINVAL);
}
}
void server_accept_loop(void *arg, int i) {
server_info_t *server = (server_info_t *) arg;
struct sockaddr_in addr;
int length = sizeof(addr);
int sockfd = accept(server->sockfd, (struct sockaddr *) addr, &length);
if (sockfd < 0) {
ERROR(errno);
}
craft_server_client_t id;
client_info_t *client = (client_info_t *) craft_alloc_ref(sizeof(client_info_t), &id, true);
if (client) {
client->sockfd = sockfd;
if (server->client_connected(id) < 0) {
log_craft_fmt("Failed to initialize client: %s", strerror(errno));
craft_free_ref(id);
close(sockfd);
}
} else {
log_crash_fmt("Unable to allocate space for accepted client data: %s", strerror(errno));
close(sockfd);
}
}
#endif
|
the_stack_data/716854.c | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define INF 0
#define NINF 1
#define aN 2
#define NaN 3
unsigned identify(unsigned f) {
unsigned sign = f>>31;
unsigned exponent = (f<<1)>>24;
unsigned mantissa = ((f<<9)>>9);
if(exponent == 0xff) {
if(mantissa == 0) {
if(sign == 0) {
return INF;
}
else {
return NINF;
}
}
else {
return NaN;
}
}
else {
return aN;
}
}
unsigned absoluteValue(int a) {
if(a < 0) {
a = -a;
}
return a;
}
int toInt(unsigned a, unsigned s) {
if(s) {
return -a;
}
else {
return a;
}
}
float add(unsigned a, unsigned b) {
// SETUP
unsigned res;
// SPLIT
unsigned Asign = a>>31;
unsigned Aexponent = (a<<1)>>24;
unsigned Amantissa = ((a<<9)>>9)|0x00800000;
unsigned Bsign = b>>31;
unsigned Bexponent = (b<<1)>>24;
unsigned Bmantissa = ((b<<9)>>9)|0x00800000;
unsigned Aidentity = identify(a);
unsigned Bidentity = identify(b);
if((Aidentity == INF & Bidentity == NINF)|(Bidentity == INF & Aidentity == NINF)) {
res = 0xffc00000;
}
else if(Aidentity == INF | Aidentity == NINF) {
res = a;
}
else if(Bidentity == INF | Bidentity == NINF) {
res = b;
}
else {
// SHIFT EXPONENT
int difference = Aexponent-Bexponent;
unsigned Rsign = 0;
// if Aexp>Bexp
if(Aexponent > Bexponent) {
Bexponent = Aexponent;
Bmantissa = Bmantissa>>difference;
}
// if Bexp>Aexp
else{
Aexponent = Bexponent;
Amantissa = Amantissa>>absoluteValue(difference);
}
unsigned Rexponent;
if((toInt(Amantissa, Asign)+toInt(Bmantissa, Bsign)) > 0) {
Rsign = 0;
Rexponent = Aexponent; // or either Bexponent;
}
else if((toInt(Amantissa, Asign)+toInt(Bmantissa, Bsign)) < 0) {
Rsign = 1;
Rexponent = Aexponent; // or either Bexponent;
}
else {
Rsign = 0;
Rexponent = 0; // or either Bexponent;
}
// MANIPULATE
unsigned Rmantissa = absoluteValue(toInt(Amantissa, Asign)+toInt(Bmantissa, Bsign));
if((Rmantissa&0x01000000) == 0x01000000) {
Rexponent = Rexponent+1;
Rmantissa = (Rmantissa+1)>>1;
}
// TRUNCATION
Rsign = Rsign&0x00000001;
Rexponent = Rexponent&0x000000ff;
Rmantissa = Rmantissa&0x007fffff;
// CONCATENATION
res = (Rsign<<31)|(Rexponent<<23)|(Rmantissa);
}
return *(float*)&res;
}
unsigned char assertAdd(float a, float b) {
//printf("--------------------------------------\n");
unsigned char assertionResult = 0;
float r = a+b;
float t = add(*(unsigned*)&a, *(unsigned*)&b);
if((r == t)||((*(unsigned*)&r) == (*(unsigned*)&t))) {
//printf("Passed: %f(%08x)+%f(%x) should be %f(%08x) but %f(%08x) found.\n", a, *(unsigned*)&a, b, *(unsigned*)&b, r, *(unsigned*)&r, t, *(unsigned*)&t);
assertionResult = 0;
}
else {
printf("Error : %f(%08x)+%f(%08x) should be %f(%08x) but %f(%08x) found.\n", a, *(unsigned*)&a, b, *(unsigned*)&b, r, *(unsigned*)&r, t, *(unsigned*)&t);
assertionResult = 1;
}
return assertionResult;
}
void testAdd() {
unsigned char count = 0;
// Static tests part (corner cases)
count += assertAdd(2.25, 134.0625);
count += assertAdd(134.0625, 2.25);
count += assertAdd(-2.25, 134.0625);
count += assertAdd(134.0625, -2.25);
count += assertAdd(2.25, -134.0625);
count += assertAdd(-134.0625, 2.25);
count += assertAdd(-2.25, -134.0625);
count += assertAdd(-134.0625, -2.25);
count += assertAdd(3.14, -3.14);
count += assertAdd(-3.14, 3.14);
count += assertAdd(0.0, 0.0);
count += assertAdd(-0.0, -0.0);
count += assertAdd(NAN, 45.0);
count += assertAdd(NAN, -45.0);
count += assertAdd(-NAN, 45.0);
count += assertAdd(-NAN, -45.0);
count += assertAdd(INFINITY, 0.1);
count += assertAdd(INFINITY, -0.1);
count += assertAdd(-INFINITY, 0.1);
count += assertAdd(-INFINITY, -0.1);
count += assertAdd(INFINITY, INFINITY);
count += assertAdd(INFINITY, -INFINITY);
// Random tests
for (size_t i = 0; i < 100; i++) {
float f1 = (float)rand()/RAND_MAX;
float f2 = (float)rand()/RAND_MAX;
count += assertAdd(f1, f2);
}
printf("%u tests failed\n", count);
}
float mul(unsigned a, unsigned b) {
// SETUP
unsigned res;
// SPLIT
unsigned Asign = a>>31;
unsigned Aexponent = (a<<1)>>24;
unsigned Amantissa = ((a<<9)>>9)|0x00800000;
unsigned Bsign = b>>31;
unsigned Bexponent = (b<<1)>>24;
unsigned Bmantissa = ((b<<9)>>9)|0x00800000;
unsigned Aidentity = identify(a);
unsigned Bidentity = identify(b);
if(Aidentity == INF | Aidentity == NINF | Bidentity == INF | Bidentity == NINF) {
res = 0x7f800000|((Asign^Bsign)<<31);
}
else if(Aidentity == NaN) {
res = 0x7fc00000|(Asign<<31);
}
else if(Bidentity == NaN) {
res = 0x7fc00000|(Bsign<<31);
}
else {
// Sign
unsigned Rsign = Asign^Bsign;
// Exponent
unsigned Rexponent = (Aexponent+Bexponent)? (Aexponent+Bexponent-127):0;
// Mantissa
unsigned Rmantissa = (((unsigned long)Amantissa*(unsigned long)Bmantissa)>>23);
// UPDATE WHEN OVERFLOW
if((Rmantissa&0x01000000) == 0x01000000) {
Rexponent = Rexponent+1;
Rmantissa = (Rmantissa+1)>>1;
}
// TRUNCATION
Rsign = Rsign&0x00000001;
Rexponent = Rexponent&0x000000ff;
Rmantissa = Rmantissa&0x007fffff;
// CONCATENATION
res = (Rsign<<31)|(Rexponent<<23)|(Rmantissa);
}
return *(float*)&res;
}
unsigned char assertMul(float a, float b) {
//printf("--------------------------------------\n");
unsigned char assertionResult = 0;
float r = a*b;
float t = mul(*(unsigned*)&a, *(unsigned*)&b);
if((r == t)||((*(unsigned*)&r) == (*(unsigned*)&t))) {
assertionResult = 0;
}
else {
printf("Error : %f*%f should be %f(%08x) but %f(%08x) found.\n", a, b, r, *(unsigned*)&r, t, *(unsigned*)&t);
assertionResult = 1;
}
return assertionResult;
}
void testMul() {
unsigned char count = 0;
// Static tests part (corner cases)
count += assertMul(2.25, 134.0625);
count += assertMul(134.0625, 2.25);
count += assertMul(-2.25, 134.0625);
count += assertMul(134.0625, -2.25);
count += assertMul(2.25, -134.0625);
count += assertMul(-134.0625, 2.25);
count += assertMul(-2.25, -134.0625);
count += assertMul(-134.0625, -2.25);
count += assertMul(3.14, -3.14);
count += assertMul(-3.14, 3.14);
count += assertMul(0.0, 0.0);
count += assertMul(-0.0, -0.0);
count += assertMul(NAN, 45.0);
count += assertMul(NAN, -45.0);
count += assertMul(-NAN, 45.0);
count += assertMul(-NAN, -45.0);
count += assertMul(INFINITY, 0.1);
count += assertMul(INFINITY, -0.1);
count += assertMul(-INFINITY, 0.1);
count += assertMul(-INFINITY, -0.1);
count += assertMul(INFINITY, INFINITY);
count += assertMul(INFINITY, -INFINITY);
// Random tests
for (size_t i = 0; i < 100; i++) {
float f1 = (float)rand()/RAND_MAX;
float f2 = (float)rand()/RAND_MAX;
count += assertMul(f1, f2);
}
printf("%u tests failed\n", count);
}
float uint_to_float(unsigned int significand) {
if (significand >= 1 << 24)
return -1.0f;
else if(significand == 0)
return 0.0f;
int shifts = 0;
while ((significand & 0x00800000) == 0) {
significand <<= 1;
shifts++;
}
unsigned int exponent = 127 - shifts + 23;
unsigned int merged = (exponent << 23) | (significand & 0x7FFFFF);
return *(float*)&merged;
}
float int_to_float(int significand) {
unsigned char sign = significand < 0;
if(sign) {
significand = ~(significand-1);
}
float res = uint_to_float(significand);
unsigned tmp = *(unsigned*)&res;
tmp = tmp|(sign<<31);
return *(float*)&tmp;
}
unsigned char assertEqualFloat(float a, float b) {
if(a != b) {
printf("test failed: %f != %f (%x != %x)\n", a, b, *(unsigned*)&a, *(unsigned*)&b);
}
return (a != b);
}
unsigned char assertEqualUnsigned(unsigned a, unsigned b) {
if(a != b) {
printf("test failed: %u != %u\n", a, b);
}
return (a != b);
}
unsigned char assertEqualInt(int a, int b) {
if(a != b) {
printf("test failed: %i != %i\n", a, b);
}
return (a != b);
}
void testUintToFloat() {
printf("Test UInt -> Float\n");
unsigned char count = 0;
unsigned t[6] = {0x007b4567, 0x007b23c6, 0x003c9869, 0x00334873, 0x0050dc51, 0};
for (size_t i = 0; i < 6; i++) {
float tmp = uint_to_float(t[i]);
printf("%x -> %x\n", t[i], *(unsigned*)&tmp);
count += assertEqualFloat((float)t[i], tmp);
}
printf("%u tests failed\n", count);
}
void testIntToFloat() {
printf("Test Int -> Float\n");
unsigned char count = 0;
int t[12] = {0x007b4567, 0x007b23c6, 0x003c9869, 0x00334873, 0x0050dc51, -0x007b4567, -0x007b23c6, -0x003c9869, -0x00334873, -0x0050dc51};
for (size_t i = 0; i < 12; i++) {
float tmp = int_to_float(t[i]);
printf("%x -> %x\n", t[i], *(unsigned*)&tmp);
count += assertEqualFloat((float)t[i], tmp);
}
printf("%u tests failed\n", count);
}
unsigned float_to_uint(float significand) {
unsigned value = *(unsigned*)&significand;
unsigned sign = value>>31;
unsigned exponent = (value<<1)>>24;
unsigned mantissa = ((value<<9)>>9)|0x00800000;
int difference = 127-exponent;
mantissa = mantissa >> (23+difference);
// fill mantissa with zeros on the left
return mantissa;
}
void testFloatToUint() {
printf("Test Float -> UInt\n");
unsigned char count = 0;
float t[5] = {2.0f, 5.0f, 0.5f, 0.75f, 1.5f};
for (size_t i = 0; i < 5; i++) {
unsigned tmp = float_to_uint(t[i]);
printf("%x -> %x\n", *(unsigned*)&t[i], tmp);
count += assertEqualUnsigned((unsigned)t[i], tmp);
}
printf("%u tests failed\n", count);
}
int float_to_int(float significand) {
unsigned char sign = significand < 0;
unsigned res = float_to_uint(significand);
if(sign) {
res = (~res)+1;
}
return *(int*)&res;
}
void testFloatToInt() {
printf("Test Float -> Int\n");
unsigned char count = 0;
float t[10] = {2.0f, 5.0f, 0.5f, 0.75f, 1.5f, -2.0f, -5.0f, -0.5f, -0.75f, -1.5f};
for (size_t i = 0; i < 10; i++) {
int tmp = float_to_int(t[i]);
printf("%x -> %x\n", *(unsigned*)&t[i], tmp);
count += assertEqualInt((int)t[i], tmp);
}
printf("%u tests failed\n", count);
}
int main(int argc, char const *argv[]) {
//testAdd();
//testMul();
testUintToFloat();
testIntToFloat();
testFloatToUint();
testFloatToInt();
return 0;
}
|
the_stack_data/36074861.c | static int __b_global = 2;
int b(int arg) {
int result = arg + __b_global;
return result;
}
int bb(int arg1) {
int result2 = arg1 - __b_global;
return result2;
}
|
the_stack_data/140362.c | //
// AOJ0093.c
//
//
// Created by n_knuu on 2014/02/24.
//
//
#include <stdio.h>
int main(void){
int a,b,ans[750],i,j=0,p;
while (1) {
ans[0]=0;
p=0;
scanf("%d %d",&a,&b);
if (a==0&&b==0) break;
for(i=a;i<=b;){
if(i%4==0){
if(i%100!=0||i%400==0) {
ans[p]=i;
p++;
}
i+=4;
} else {
i++;
}
}
if (j!=0) printf("\n");
if (ans[0]==0) {
printf("NA\n");
} else {
for(i=0;i<p;i++) printf("%d\n",ans[i]);
}
j++;
}
return 0;
} |
the_stack_data/175144418.c | #include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void) {
char buf[32];
strcpy(buf, "some text"); // OK
return 0;
}
|
the_stack_data/22013593.c | // SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright 2014 Sony Mobile Communications Inc.
*
* Selftest for runtime system size
*
* Prints the amount of RAM that the currently running system is using.
*
* This program tries to be as small as possible itself, to
* avoid perturbing the system memory utilization with its
* own execution. It also attempts to have as few dependencies
* on kernel features as possible.
*
* It should be statically linked, with startup libs avoided. It uses
* no library calls except the syscall() function for the following 3
* syscalls:
* sysinfo(), write(), and _exit()
*
* For output, it avoids printf (which in some C libraries
* has large external dependencies) by implementing it's own
* number output and print routines, and using __builtin_strlen()
*
* The test may crash if any of the above syscalls fails because in some
* libc implementations (e.g. the GNU C Library) errno is saved in
* thread-local storage, which does not get initialized due to avoiding
* startup libs.
*/
#include <sys/sysinfo.h>
#include <unistd.h>
#include <sys/syscall.h>
#define STDOUT_FILENO 1
static int print(const char *s)
{
size_t len = 0;
while (s[len] != '\0')
len++;
return syscall(SYS_write, STDOUT_FILENO, s, len);
}
static inline char *num_to_str(unsigned long num, char *buf, int len)
{
unsigned int digit;
/* put digits in buffer from back to front */
buf += len - 1;
*buf = 0;
do {
digit = num % 10;
*(--buf) = digit + '0';
num /= 10;
} while (num > 0);
return buf;
}
static int print_num(unsigned long num)
{
char num_buf[30];
return print(num_to_str(num, num_buf, sizeof(num_buf)));
}
static int print_k_value(const char *s, unsigned long num, unsigned long units)
{
unsigned long long temp;
int ccode;
print(s);
temp = num;
temp = (temp * units)/1024;
num = temp;
ccode = print_num(num);
print("\n");
return ccode;
}
/* this program has no main(), as startup libraries are not used */
void _start(void)
{
int ccode;
struct sysinfo info;
unsigned long used;
static const char *test_name = " get runtime memory use\n";
print("TAP version 13\n");
print("# Testing system size.\n");
ccode = syscall(SYS_sysinfo, &info);
if (ccode < 0) {
print("not ok 1");
print(test_name);
print(" ---\n reason: \"could not get sysinfo\"\n ...\n");
syscall(SYS_exit, ccode);
}
print("ok 1");
print(test_name);
/* ignore cache complexities for now */
used = info.totalram - info.freeram - info.bufferram;
print("# System runtime memory report (units in Kilobytes):\n");
print(" ---\n");
print_k_value(" Total: ", info.totalram, info.mem_unit);
print_k_value(" Free: ", info.freeram, info.mem_unit);
print_k_value(" Buffer: ", info.bufferram, info.mem_unit);
print_k_value(" In use: ", used, info.mem_unit);
print(" ...\n");
print("1..1\n");
syscall(SYS_exit, 0);
}
|
the_stack_data/521108.c | #include <stdlib.h>
extern char *getenv(const char *name);
struct s3 {
int *a;
int *b;
char *t1;
};
struct s2 {
char *t1;
struct s3 s3;
};
struct s1 {
int a;
int b;
struct s2* s2;
};
void
foo(struct s3 s3)
{
int *t1 = s3.a;
int *t2 = s3.b;
char *t3 = s3.t1;
}
int
main()
{
struct s1 s1;
struct s2 s2;
int is_env_set = getenv("gude") != NULL;
if (is_env_set) {
s1.s2 = &s2;
}
foo(s1.s2->s3);
return 0;
}
|
the_stack_data/128920.c | #include <signal.h>
#include <string.h>
#if 0
int sigqueue(pid_t pid, int sig, const union sigval val)
{
siginfo_t info;
memset(&info, 0, sizeof(siginfo_t));
info.si_signo = sig;
info.si_code = SI_QUEUE;
info.si_pid = getpid();
info.si_uid = getuid();
info.si_value = val;
return __sys_rt_sigqueueinfo(pid, sig, &info);
}
#endif
|
the_stack_data/182951925.c | /* PR tree-optimization/50650 */
unsigned int
foo (unsigned int x, unsigned int y)
{
int i;
for (i = 8; i--; x <<= 1)
y ^= (x ^ y) & 0x80 ? 79U : 0U;
return y;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.