file
stringlengths
18
26
data
stringlengths
2
1.05M
the_stack_data/100317.c
# include "stdio.h" int toplama(int i, int j){ return i+j; } void main() { char i, armut; i='h'; armut=4; printf("toplama öçşğü : %d\n", i+armut); }
the_stack_data/73576571.c
/*** * * ***/
the_stack_data/128264212.c
/* * Copyright (c) 1988, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD: src/lib/libc/stdlib/system.c,v 1.6 2000/03/16 02:14:41 jasone Exp $ */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)system.c 8.1 (Berkeley) 6/4/93"; #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> #include <sys/wait.h> #include <signal.h> #include <stdlib.h> #include <stddef.h> #include <unistd.h> #include <paths.h> #include <errno.h> int system(const char *command); int system(const char *command) { pid_t pid; int pstat; struct sigaction ign, intact, quitact; sigset_t newsigblock, oldsigblock; if (!command) /* just checking... */ return (1); /* * Ignore SIGINT and SIGQUIT, block SIGCHLD. Remember to save existing * signal dispositions. */ ign.sa_handler = SIG_IGN; (void) sigemptyset(&ign.sa_mask); ign.sa_flags = 0; (void) sigaction(SIGINT, &ign, &intact); (void) sigaction(SIGQUIT, &ign, &quitact); (void) sigemptyset(&newsigblock); (void) sigaddset(&newsigblock, SIGCHLD); (void) sigprocmask(SIG_BLOCK, &newsigblock, &oldsigblock); switch (pid = fork()) { case -1: /* error */ break; case 0: /* child */ /* * Restore original signal dispositions and exec the command. */ (void) sigaction(SIGINT, &intact, NULL); (void) sigaction(SIGQUIT, &quitact, NULL); (void) sigprocmask(SIG_SETMASK, &oldsigblock, NULL); execl(_PATH_BSHELL, "sh", "-c", command, (char *) NULL); _exit(127); default: /* parent */ do { pid = wait4(pid, &pstat, 0, (struct rusage *) 0); } while (pid == -1 && errno == EINTR); break; } (void) sigaction(SIGINT, &intact, NULL); (void) sigaction(SIGQUIT, &quitact, NULL); (void) sigprocmask(SIG_SETMASK, &oldsigblock, NULL); return (pid == -1 ? -1 : pstat); }
the_stack_data/1001835.c
// CBSD Project 2017-2018 // Oleg Ginzburg <[email protected]> // 0.1 // Todo: fast-written and confusing code with magic numbers, need to refactoring // return 0 when jail selected // return 1 when 'cancel' or 'esc' is pressed // return 2 on error #include <stdio.h> #include <termios.h> #include <unistd.h> #include <string.h> #include <stdlib.h> #include <assert.h> #include <sys/ioctl.h> #include <dirent.h> #define KEY_UP 65 #define KEY_DOWN 66 #define KEY_HOME 72 #define KEY_END 70 #define KEY_PGUP 53 #define KEY_PGDN 54 #define KEY_ESC 27 #define BOLD "\033[1m" #define NORMAL "\033[0m" #define GREEN "\033[0;32m" #define LGREEN "\033[1;32m" #define CYAN "\033[0;36m" #define SELECT "\033[41m" #define WHITE "\033[1;37m" #define LYELLOW "\033[1;33m" #define BUFLEN 2048 #define MAXJNAME 128 #define MAXFNAME 1024 #define MAXFULLPATH 1024 #define MAXDESCRLEN 2048 #define CREATE(result, type, number) do {\ if (!((result) = (type *) calloc ((number), sizeof(type))))\ { perror("malloc failure"); abort(); } } while(0) struct winsize w; struct item_data { int id; // sequence int cid; // letter by index for hot key char name[MAXFNAME]; //name of file //char name[MAXJNAME]; char ext[MAXFNAME]; //extension (less size?) char fullpath[MAXFULLPATH]; //realpath к файлу char descr[MAXDESCRLEN]; //descr char node[MAXJNAME]; int active; struct item_data *next; }; struct item_data *item_list = NULL; int mygetch(void) { int c = 0; struct termios term, oterm; tcgetattr(0, &oterm); memcpy(&term, &oterm, sizeof(term)); term.c_lflag &= ~(ICANON | ECHO); term.c_cc[VMIN] = 1; term.c_cc[VTIME] = 0; tcsetattr(0, TCSANOW, &term); c = getchar(); tcsetattr(0, TCSANOW, &oterm); return c; } int usage(char *progname) { printf("Usage: %s <directory> <file-for-output>\n",progname); exit(1); } int is_number(const char *p) { int i; int n=0; for (i=0;i<strlen(p)-1;i++) if ((p[i]>47)&&(p[i]<58)) continue; else n=1; return n; } int print() { struct item_data *curdata = item_list; while (curdata != NULL) { printf("%s\n", curdata->name); curdata = curdata->next; } return 0; } /* qsort C-string comparison function */ static int compare_fun (const void *p, const void *q) { const char *l= p; const char *r= q; int cmp; cmp= strcmp (l, r); return cmp; } void reverse() { // curdata traverses the list, first is reset to empty list. struct item_data *curdata = item_list, *nxtNode; item_list = NULL; // Until no more in list, insert current before first and advance. while (curdata != NULL) { // Need to save next node since we're changing the current. nxtNode = curdata->next; // Insert at start of new list. curdata->next = item_list; item_list = curdata; // Advance to next. curdata = nxtNode; } } int main(int argc, char **argv) { int i; int cur_choice; int item=0; int max_choice=0; char tmp_id; struct item_data *m_item; char *token, *string, *tofree; FILE *fp; FILE *fo; char buf[BUFLEN]; char buf2[BUFLEN]; int x=0; int pass=0; // symbol range treshold int id; int special; int manual_input=0; // if windows size less then number of elements int second_id=1; DIR *dirp; struct dirent *dp; char ext[128]; //extenstion for scan char descrfile[MAXFULLPATH]; char fullpath[MAXFULLPATH]; char descr[MAXDESCRLEN]; int listmax=0; int n=0; char mylist[100][MAXFNAME]; if (argc<3) usage(argv[0]); memset(ext,0,sizeof(ext)); if (argv[3]!=NULL) { strcpy(ext,argv[3]); } else { strcpy(ext,"img"); } dirp = opendir(argv[1]); if (dirp == NULL) { fprintf(stderr,"Unable to opendir: %s\n",argv[1]); exit(1); } // get terminal size ioctl(0, TIOCGWINSZ, &w); // we have extra 'CANCEL' choice, so max_choice[0]='cancel' (and single choice before load data) max_choice=1; tmp_id=96; id=0; descr[0]='\0'; // load data while ((dp = readdir(dirp)) != NULL && listmax < sizeof mylist / sizeof mylist[0]) { if (dp->d_name[0]=='.') continue; strncpy(mylist[listmax++] , dp->d_name, MAXFNAME); } (void)closedir(dirp); free(dp); if (listmax<1) exit(0); qsort( mylist , listmax , sizeof(mylist[0]), compare_fun); for(n=0;n<listmax;n++) { memset(buf,0,sizeof(buf)); strcpy(buf,mylist[n]); CREATE(m_item, struct item_data, 1); tofree = string = strdup(buf); assert(string != NULL); x=0; while ((token = strsep(&string, ".")) != NULL) { switch (x) { case 0: strcpy(m_item->name,token); break; case 1: strcpy(m_item->ext,token); break; } x++; } free(tofree); if (!strncmp(m_item->ext,ext,strlen(ext))) { // пропустим latest симлинк if(!strncmp(m_item->name,"latest",6)) continue; tmp_id++; id++; // первый проход по буквенному индексу // стадия: a-z -> A if ((tmp_id>122)&&(pass==0)) { tmp_id=65; pass=1; } // вторая стадия: A-Z -> 1 if ((tmp_id>90)&&(pass==1)) { tmp_id=49; pass=2; } // слишком много файлов, начинаем с 'a' опять // сбрасываем стэдж на начало if ((tmp_id>57)&&(pass==2)) { tmp_id=97; pass=3; } // создаем запись m_item->cid = tmp_id; m_item->id = id; m_item->next = item_list; memset(m_item->fullpath,0,sizeof(m_item->fullpath)); sprintf(m_item->fullpath,"%s/%s",argv[1],buf); m_item->id=1; fprintf(stderr,"Pattern file found: %s\n",buf); memset(fullpath,0,sizeof(fullpath)); sprintf(fullpath,"%s/%s",argv[1],buf); fo=fopen(fullpath,"r"); if (!fo) { fprintf(stderr,"Unable to open file %s\n",fullpath); break; } memset(buf2,0,sizeof(buf2)); fscanf(fo,"%s",buf2); //if (feof(fo)) break; tofree = string = strdup(buf2); assert(string != NULL); x=0; while ((token = strsep(&string, ":")) != NULL) { switch (x) { case 0: m_item->active=atoi(token); break; case 1: strcpy(m_item->name,token); break; case 2: strcpy(m_item->node,token); break; } x++; } fclose(fo); free(tofree); if (x!=3) { fprintf(stdout,"Warning: not <active>.int:<name>.str:<node>.str format: [%s], skipp\n",fullpath); } memset(descrfile,0,MAXFULLPATH); sprintf(descrfile,"%s/%s.descr",argv[1],m_item->name); fp=fopen(descrfile,"r"); if (fp) { fprintf(stderr,"Found descr!\n"); memset(m_item->descr,0,MAXDESCRLEN); fgets(m_item->descr, MAXDESCRLEN, fp); // strcpy(m_item->descr,"OLALALLALALA BLABLA"); fclose(fp); for (i=0;i<strlen(m_item->descr); i++) if(m_item->descr[i]=='\n') m_item->descr[i]='\0'; fprintf(stderr,"new descr: %s descr!\n",m_item->descr); } else { (m_item->descr[0]='\0'); } item_list = m_item; max_choice++; } else { fprintf(stderr,"[debug] warning: no %s extension (%s), skipp: [%s]\n",ext,m_item->ext,buf); continue; } } if (max_choice==1) { fprintf(stderr,"Files not found: %s\n",argv[1]); exit(1); } // reverse order reverse(); //print(); cur_choice=1; //set on Cancel //-3 extra row if (w.ws_row-3<max_choice) { cur_choice=-1; manual_input=1; // terminal too small for this list, input jname manually } while ( i != 10 ) { item=1; special=0; //is special key? (started with \033, aka '[' ) if (item==cur_choice) printf("%s",SELECT); printf(" %s0 .. CANCEL%s\n",BOLD,NORMAL); for ( m_item = item_list; m_item; m_item = m_item->next) { item++; if (m_item->active==0) { if (item==cur_choice) { printf("%s",SELECT); if(strlen(m_item->descr)) { sprintf(descr,"%s%s%s%s",BOLD,LYELLOW,m_item->descr,NORMAL); } else { memset(descr,0,MAXDESCRLEN); } } if (item==cur_choice) { if (manual_input==1) printf(" %s%d .. %s%s on %s%s\n",BOLD,m_item->id,GREEN,m_item->name,m_item->node,NORMAL); else printf(" %s%c .. %s on %s%s\n",SELECT,m_item->cid,m_item->name,m_item->node,NORMAL); } else { if (manual_input==1) printf(" %s%d .. %s%s on %s%s\n",BOLD,m_item->id,GREEN,m_item->name,m_item->node,NORMAL); else printf(" %s%c .. %s%s%s on %s%s%s\n",BOLD,m_item->cid,GREEN,m_item->name,NORMAL,LGREEN,m_item->node,NORMAL); } } else { if (item==cur_choice) { printf("%s",SELECT); if (strlen(m_item->descr)) { sprintf(descr,"%s%s%s%s",BOLD,LYELLOW,m_item->descr,NORMAL); } else { memset(descr,0,MAXDESCRLEN); } if (manual_input==1) printf(" %s%d .. %s%s on %s%s\n",BOLD,m_item->id,LGREEN,m_item->name,m_item->node,NORMAL); else printf(" %s%c .. %s%s on %s%s%s\n",SELECT,m_item->cid,LGREEN,m_item->name,LGREEN,m_item->node,NORMAL); } else { if (manual_input==1) printf(" %s%d .. %s%s on %s%s\n",BOLD,m_item->id,LGREEN,m_item->name,m_item->node,NORMAL); else printf(" %s%c .. %s%s%s on %s%s%s\n",BOLD,m_item->cid,LGREEN,m_item->name,NORMAL,LGREEN,m_item->node,NORMAL); } } } printf("\n"); if (manual_input==1) { memset(buf,0,sizeof(buf)); printf("Enter name or ID or '0' to Cancel: "); fgets( buf, BUFLEN,stdin ); if ( buf[0]=='0' ) { // Cancel or Esc was pressed fprintf(stderr,"Cancel\n"); exit(1); } if (is_number(buf)) { //assume got jname here fprintf(stderr,"%s\n",buf); fp=fopen(argv[1],"w"); fputs(buf,fp); fclose(fp); exit(0); } else { // this is number, find jail by id id=atoi(buf); tmp_id=1; for ( m_item = item_list; m_item; m_item = m_item->next) { if (id == tmp_id) { fprintf(stderr,"%s\n",m_item->name); fp=fopen(argv[1],"w"); fputs(m_item->name,fp); fclose(fp); exit(0); } tmp_id++; } fprintf(stderr,"Wrong input, no such jail\n"); exit(2); } } // show descr if not cancel if (cur_choice>1) printf("%s",descr); i = mygetch(); if ( i == 27 ) { // if the first value is esc, [ special = 1; i = mygetch(); // skip the [ if ( i == 91 ) { //if the second value is i = mygetch(); // skip the [ } } printf("'\033[1K"); printf("\033[1000D"); printf("\033[%dA",max_choice+1); // items number + 1 extra \n if (special==1) { if (i==KEY_UP) cur_choice--; if (i==KEY_DOWN) cur_choice++; if ((i==KEY_PGUP)||(i==KEY_HOME)) cur_choice=1; if ((i==KEY_PGDN)||(i==KEY_END)) cur_choice=max_choice; } if (i=='0') cur_choice=1; //jump to CANCEL if (cur_choice>max_choice) cur_choice=1; //jump to first value after CANCEL if (cur_choice==0) cur_choice=max_choice; if (special==1) continue; //a-z 97-122 //A-Z 65-90 //1-9 49-57 // in a-z + 1-9 - range if (special==0) { if ((i>96)&&(i<123)) { if ( i <= 95+max_choice) cur_choice=i-95; // 96 = 'a' minus extra CANCEL } if ((i>64)&&(i<91)) { if ( i <= 63+max_choice) cur_choice=i-63+26; // 96 = 'a' minus extra CANCEL + 26 symbols } if ((i>48)&&(i<58)) { if ( i <= 47+max_choice) cur_choice=i-47+26+26; // 96 = 'a' minus extra CANCEL } } } //make indent after last records for(i=0;i<max_choice+1;i++) { printf("\n"); } if (cur_choice==1) { // Cancel or Esc was pressed fprintf(stderr,"Cancel\n"); exit(1); } else { tmp_id=2; for ( m_item = item_list; m_item; m_item = m_item->next) { if (cur_choice == tmp_id) { fprintf(stderr,"%s\n",m_item->name); fp=fopen(argv[2],"w"); fputs(m_item->name,fp); fclose(fp); exit(0); } tmp_id++; } } return 1; }
the_stack_data/32950366.c
/* * Copyright 2019, Vitali Baumtrok. * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE or copy at * http://www.boost.org/LICENSE_1_0.txt) */ #include <stdio.h> #include <X11/Xlib.h> #include <GL/glx.h> static const int window_width_init = 256; static const int window_height_init = 256; static int window_width = 256; static int window_height = 256; static Display *display_ptr = NULL; static GLXContext glxContext = NULL; static Window window_id; static Atom wm_protocols; static Atom wm_delete_window_atom; void create_window ( void ) { int screen_id = 0; Screen *screen_ptr = NULL; XVisualInfo *visual_info_ptr = NULL; GLint visual_attributes[5] = { GLX_RGBA, GLX_DEPTH_SIZE, 24, None }; Window window_root_id; display_ptr = XOpenDisplay(NULL); screen_id = DefaultScreen(display_ptr); screen_ptr = ScreenOfDisplay(display_ptr,screen_id); window_root_id = RootWindowOfScreen(screen_ptr); visual_info_ptr = glXChooseVisual(display_ptr,screen_id,visual_attributes); if (visual_info_ptr != NULL) { XSetWindowAttributes set_window_attributes; Colormap colormap = XCreateColormap(display_ptr,window_root_id,visual_info_ptr->visual,AllocNone); set_window_attributes.colormap = colormap; set_window_attributes.event_mask = ExposureMask|KeyPressMask|StructureNotifyMask; window_id = XCreateWindow(display_ptr, window_root_id, 0, 0, window_width_init, window_height_init, 0, visual_info_ptr->depth, InputOutput, visual_info_ptr->visual, CWColormap|CWEventMask, &set_window_attributes); wm_protocols = XInternAtom(display_ptr,"WM_PROTOCOLS",False); wm_delete_window_atom = XInternAtom(display_ptr,"WM_DELETE_WINDOW",False); XSetWMProtocols(display_ptr,window_id,&wm_delete_window_atom,1); XMapWindow(display_ptr,window_id); XStoreName(display_ptr,window_id,"Example"); glxContext = glXCreateContext(display_ptr,visual_info_ptr,NULL,GL_TRUE); if (glxContext != NULL) { glXMakeCurrent(display_ptr,window_id,glxContext); } else { printf("error: couldn't create OpenGL context\n"); XDestroyWindow(display_ptr,window_id); XCloseDisplay(display_ptr); display_ptr = NULL; } XFree(visual_info_ptr); } else { printf("error: visual setting not available\n"); XCloseDisplay(display_ptr); display_ptr = NULL; } } static void process_event ( void ) { XEvent xevent; XNextEvent(display_ptr,&xevent); /* input */ if (xevent.type==KeyPress) { /* ESC key: close window */ if ((int) xevent.xkey.keycode == 9) { XEvent close_event; close_event.xclient.type = ClientMessage; close_event.xclient.message_type = wm_protocols; close_event.xclient.format = 32; close_event.xclient.data.l[0] = wm_delete_window_atom; close_event.xclient.data.l[1] = CurrentTime; XSendEvent(display_ptr,window_id,False,NoEventMask,&close_event); } /* resize */ } else if ( xevent.type == ConfigureNotify ) { if ( xevent.xconfigure.width != window_width || xevent.xconfigure.height != window_height ) { window_width = xevent.xconfigure.width; window_height = xevent.xconfigure.height; glViewport(0,0,window_width,window_height); } /* draw graphics */ } else if ( xevent.type == Expose && xevent.xexpose.count == 0 ) { glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_TRIANGLES); glColor3f(1.0f, 0.0f, 0.0f); glVertex2i(0, 1); glColor3f(0.0f, 1.0f, 0.0f); glVertex2i(-1, -1); glColor3f(0.0f, 0.0f, 1.0f); glVertex2i(1, -1); glEnd(); glFlush(); /* close window */ } else if ( xevent.type == ClientMessage && xevent.xclient.message_type == wm_protocols && xevent.xclient.data.l[0] == wm_delete_window_atom ) { glXMakeCurrent(display_ptr, None, NULL); glXDestroyContext(display_ptr, glxContext); XDestroyWindow(display_ptr,window_id); XCloseDisplay(display_ptr); display_ptr = NULL; } } int main ( int argc, char **argv ) { create_window(); while (display_ptr != NULL) { process_event(); } return 0; }
the_stack_data/247018213.c
#include <stdio.h> int main() { int input; printf("Type a value (1,2,3): "); scanf("%d",&input); switch(input) { case 1: puts("Red"); break; case 2: puts("Green"); break; case 3: puts("Blue"); break; default: puts("Invalid input"); } return(0); }
the_stack_data/31324.c
#include <stdio.h> int main() { int a,c,b; for(a=1;a<=4;a++) { for(b = a; b>=1; b--) { printf("%d",b%2); } printf("\n"); } }
the_stack_data/97014069.c
/*====================================================================== * * /lib/util/parse_name.c * * bsname(), pathfrname(), fexten(): * Get base name, path, extention from full file name. * *====================================================================*/ #include <string.h> void bsname(fname, name, exten) char *fname; /* Full file name */ char *name; /* Basename of the file */ char *exten; /* extention to be cut from name */ { int i, j; char *tmp_name; char *ext; name[0] = '\0'; tmp_name = (char *) malloc(132); /* Get file name from full name */ for(j = 0,i = strlen(fname)-1; i >= 0; j++,i --) if (fname[i] == '/') break; strncpy(tmp_name, fname + i + 1, j); tmp_name[j] = '\0'; strcpy(name, tmp_name); /* Cut extention if such is specified */ if(exten != NULL) { ext = strstr(name, exten); if( ext != 0 ) { if(strcmp(ext, exten) == 0) name[strlen(name)-strlen(exten)] = '\0'; } } free(tmp_name); } void pathfrname(path, name) char *path; char *name; { int i; for(i = strlen(path)-1; i >= 0; i --) if (path[i] == '/') break; if(i < 0) *name = NULL; else { strncpy(name, path, i); name[i] = '\0'; } } void fexten(fname, name) char *fname; /* Full file name */ char *name; /* File name exention */ { int i; for(i = strlen(fname); i > 0; i --) if (fname[i] == '.') break; if( i == 0 ) { name[0] = '\0'; } else { strncpy(name, fname + i + 1, strlen(fname) - i - 1); name[strlen(fname) - i - 1] = '\0'; } } void namefrpath(path, name) char *path; char *name; { int i, j; for(j = 0,i = strlen(path)-1; i >= 0; j++,i --) if (path[i] == '/') break; strncpy(name, path + i + 1, j); name[j] = '\0'; }
the_stack_data/16462.c
#include <stdio.h> #include <string.h> /* void send(void * p_data, int n_lenth); char *data = "blah"; send(data, strlen(data)); */ int main(void) { int i = 10; float f = 2.34; char ch = 'k'; void *vptr = NULL; vptr = &i; printf("Value of i = %d\n", *(int *)vptr); vptr = &f; printf("Value of i = %f\n", *(float *)vptr); vptr = &ch; printf("Value of ch = %c\n", *(char *)vptr); return 0; }
the_stack_data/139695.c
/* mbed Microcontroller Library ******************************************************************************* * Copyright (c) 2017, STMicroelectronics * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ #if DEVICE_SERIAL #include "serial_api_hal.h" int stdio_uart_inited = 0; // used in platform/mbed_board.c and platform/mbed_retarget.cpp serial_t stdio_uart; extern UART_HandleTypeDef uart_handlers[]; extern uint32_t serial_irq_ids[]; // Utility functions HAL_StatusTypeDef init_uart(serial_t *obj); int8_t get_uart_index(UARTName uart_name); void serial_init(serial_t *obj, PinName tx, PinName rx) { struct serial_s *obj_s = SERIAL_S(obj); uint8_t stdio_config = 0; // Determine the UART to use (UART_1, UART_2, ...) UARTName uart_tx = (UARTName)pinmap_peripheral(tx, PinMap_UART_TX); UARTName uart_rx = (UARTName)pinmap_peripheral(rx, PinMap_UART_RX); // Get the peripheral name (UART_1, UART_2, ...) from the pin and assign it to the object obj_s->uart = (UARTName)pinmap_merge(uart_tx, uart_rx); MBED_ASSERT(obj_s->uart != (UARTName)NC); if ((tx == STDIO_UART_TX) || (rx == STDIO_UART_RX)) { stdio_config = 1; } else { if (uart_tx == pinmap_peripheral(STDIO_UART_TX, PinMap_UART_TX)) { error("Error: new serial object is using same UART as STDIO"); } } // Reset and enable clock #if defined(USART1_BASE) if (obj_s->uart == UART_1) { __HAL_RCC_USART1_FORCE_RESET(); __HAL_RCC_USART1_RELEASE_RESET(); __HAL_RCC_USART1_CLK_ENABLE(); } #endif #if defined (USART2_BASE) if (obj_s->uart == UART_2) { __HAL_RCC_USART2_FORCE_RESET(); __HAL_RCC_USART2_RELEASE_RESET(); __HAL_RCC_USART2_CLK_ENABLE(); } #endif #if defined(USART3_BASE) if (obj_s->uart == UART_3) { __HAL_RCC_USART3_FORCE_RESET(); __HAL_RCC_USART3_RELEASE_RESET(); __HAL_RCC_USART3_CLK_ENABLE(); } #endif #if defined(UART4_BASE) if (obj_s->uart == UART_4) { __HAL_RCC_UART4_FORCE_RESET(); __HAL_RCC_UART4_RELEASE_RESET(); __HAL_RCC_UART4_CLK_ENABLE(); } #endif #if defined(USART4_BASE) if (obj_s->uart == UART_4) { __HAL_RCC_USART4_FORCE_RESET(); __HAL_RCC_USART4_RELEASE_RESET(); __HAL_RCC_USART4_CLK_ENABLE(); } #endif #if defined(UART5_BASE) if (obj_s->uart == UART_5) { __HAL_RCC_UART5_FORCE_RESET(); __HAL_RCC_UART5_RELEASE_RESET(); __HAL_RCC_UART5_CLK_ENABLE(); } #endif #if defined(USART5_BASE) if (obj_s->uart == UART_5) { __HAL_RCC_USART5_FORCE_RESET(); __HAL_RCC_USART5_RELEASE_RESET(); __HAL_RCC_USART5_CLK_ENABLE(); } #endif #if defined(USART6_BASE) if (obj_s->uart == UART_6) { __HAL_RCC_USART6_FORCE_RESET(); __HAL_RCC_USART6_RELEASE_RESET(); __HAL_RCC_USART6_CLK_ENABLE(); } #endif #if defined(UART7_BASE) if (obj_s->uart == UART_7) { __HAL_RCC_UART7_FORCE_RESET(); __HAL_RCC_UART7_RELEASE_RESET(); __HAL_RCC_UART7_CLK_ENABLE(); } #endif #if defined(USART7_BASE) if (obj_s->uart == UART_7) { __HAL_RCC_USART7_FORCE_RESET(); __HAL_RCC_USART7_RELEASE_RESET(); __HAL_RCC_USART7_CLK_ENABLE(); } #endif #if defined(UART8_BASE) if (obj_s->uart == UART_8) { __HAL_RCC_UART8_FORCE_RESET(); __HAL_RCC_UART8_RELEASE_RESET(); __HAL_RCC_UART8_CLK_ENABLE(); } #endif #if defined(USART8_BASE) if (obj_s->uart == UART_8) { __HAL_RCC_USART8_FORCE_RESET(); __HAL_RCC_USART8_RELEASE_RESET(); __HAL_RCC_USART8_CLK_ENABLE(); } #endif #if defined(UART9_BASE) if (obj_s->uart == UART_9) { __HAL_RCC_UART9_FORCE_RESET(); __HAL_RCC_UART9_RELEASE_RESET(); __HAL_RCC_UART9_CLK_ENABLE(); } #endif #if defined(UART10_BASE) if (obj_s->uart == UART_10) { __HAL_RCC_UART10_FORCE_RESET(); __HAL_RCC_UART10_RELEASE_RESET(); __HAL_RCC_UART10_CLK_ENABLE(); } #endif #if defined(LPUART1_BASE) if (obj_s->uart == LPUART_1) { __HAL_RCC_LPUART1_FORCE_RESET(); __HAL_RCC_LPUART1_RELEASE_RESET(); __HAL_RCC_LPUART1_CLK_ENABLE(); } #endif // Assign serial object index obj_s->index = get_uart_index(obj_s->uart); MBED_ASSERT(obj_s->index >= 0); // Configure UART pins pinmap_pinout(tx, PinMap_UART_TX); pinmap_pinout(rx, PinMap_UART_RX); if (tx != NC) { pin_mode(tx, PullUp); } if (rx != NC) { pin_mode(rx, PullUp); } // Configure UART obj_s->baudrate = 9600; // baudrate default value if (stdio_config) { #if MBED_CONF_PLATFORM_STDIO_BAUD_RATE obj_s->baudrate = MBED_CONF_PLATFORM_STDIO_BAUD_RATE; // baudrate takes value from platform/mbed_lib.json #endif /* MBED_CONF_PLATFORM_STDIO_BAUD_RATE */ } else { #if MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE obj_s->baudrate = MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE; // baudrate takes value from platform/mbed_lib.json #endif /* MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE */ } obj_s->databits = UART_WORDLENGTH_8B; obj_s->stopbits = UART_STOPBITS_1; obj_s->parity = UART_PARITY_NONE; #if DEVICE_SERIAL_FC obj_s->hw_flow_ctl = UART_HWCONTROL_NONE; #endif obj_s->pin_tx = tx; obj_s->pin_rx = rx; init_uart(obj); /* init_uart will be called again in serial_baud function, so don't worry if init_uart returns HAL_ERROR */ // For stdio management in platform/mbed_board.c and platform/mbed_retarget.cpp if (stdio_config) { stdio_uart_inited = 1; memcpy(&stdio_uart, obj, sizeof(serial_t)); } } void serial_free(serial_t *obj) { struct serial_s *obj_s = SERIAL_S(obj); // Reset UART and disable clock #if defined(USART1_BASE) if (obj_s->uart == UART_1) { __HAL_RCC_USART1_FORCE_RESET(); __HAL_RCC_USART1_RELEASE_RESET(); __HAL_RCC_USART1_CLK_DISABLE(); } #endif #if defined(USART2_BASE) if (obj_s->uart == UART_2) { __HAL_RCC_USART2_FORCE_RESET(); __HAL_RCC_USART2_RELEASE_RESET(); __HAL_RCC_USART2_CLK_DISABLE(); } #endif #if defined(USART3_BASE) if (obj_s->uart == UART_3) { __HAL_RCC_USART3_FORCE_RESET(); __HAL_RCC_USART3_RELEASE_RESET(); __HAL_RCC_USART3_CLK_DISABLE(); } #endif #if defined(UART4_BASE) if (obj_s->uart == UART_4) { __HAL_RCC_UART4_FORCE_RESET(); __HAL_RCC_UART4_RELEASE_RESET(); __HAL_RCC_UART4_CLK_DISABLE(); } #endif #if defined(USART4_BASE) if (obj_s->uart == UART_4) { __HAL_RCC_USART4_FORCE_RESET(); __HAL_RCC_USART4_RELEASE_RESET(); __HAL_RCC_USART4_CLK_DISABLE(); } #endif #if defined(UART5_BASE) if (obj_s->uart == UART_5) { __HAL_RCC_UART5_FORCE_RESET(); __HAL_RCC_UART5_RELEASE_RESET(); __HAL_RCC_UART5_CLK_DISABLE(); } #endif #if defined(USART5_BASE) if (obj_s->uart == UART_5) { __HAL_RCC_USART5_FORCE_RESET(); __HAL_RCC_USART5_RELEASE_RESET(); __HAL_RCC_USART5_CLK_DISABLE(); } #endif #if defined(USART6_BASE) if (obj_s->uart == UART_6) { __HAL_RCC_USART6_FORCE_RESET(); __HAL_RCC_USART6_RELEASE_RESET(); __HAL_RCC_USART6_CLK_DISABLE(); } #endif #if defined(UART7_BASE) if (obj_s->uart == UART_7) { __HAL_RCC_UART7_FORCE_RESET(); __HAL_RCC_UART7_RELEASE_RESET(); __HAL_RCC_UART7_CLK_DISABLE(); } #endif #if defined(USART7_BASE) if (obj_s->uart == UART_7) { __HAL_RCC_USART7_FORCE_RESET(); __HAL_RCC_USART7_RELEASE_RESET(); __HAL_RCC_USART7_CLK_DISABLE(); } #endif #if defined(UART8_BASE) if (obj_s->uart == UART_8) { __HAL_RCC_UART8_FORCE_RESET(); __HAL_RCC_UART8_RELEASE_RESET(); __HAL_RCC_UART8_CLK_DISABLE(); } #endif #if defined(USART8_BASE) if (obj_s->uart == UART_8) { __HAL_RCC_USART8_FORCE_RESET(); __HAL_RCC_USART8_RELEASE_RESET(); __HAL_RCC_USART8_CLK_DISABLE(); } #endif #if defined(UART9_BASE) if (obj_s->uart == UART_9) { __HAL_RCC_UART9_FORCE_RESET(); __HAL_RCC_UART9_RELEASE_RESET(); __HAL_RCC_UART9_CLK_DISABLE(); } #endif #if defined(UART10_BASE) if (obj_s->uart == UART_10) { __HAL_RCC_UART10_FORCE_RESET(); __HAL_RCC_UART10_RELEASE_RESET(); __HAL_RCC_UART10_CLK_DISABLE(); } #endif #if defined(LPUART1_BASE) if (obj_s->uart == LPUART_1) { __HAL_RCC_LPUART1_FORCE_RESET(); __HAL_RCC_LPUART1_RELEASE_RESET(); __HAL_RCC_LPUART1_CLK_DISABLE(); } #endif // Configure GPIOs pin_function(obj_s->pin_tx, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0)); pin_function(obj_s->pin_rx, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0)); serial_irq_ids[obj_s->index] = 0; } void serial_baud(serial_t *obj, int baudrate) { struct serial_s *obj_s = SERIAL_S(obj); obj_s->baudrate = baudrate; if (init_uart(obj) != HAL_OK) { #if defined(LPUART1_BASE) /* Note that LPUART clock source must be in the range [3 x baud rate, 4096 x baud rate], check Ref Manual */ if (obj_s->uart == LPUART_1) { /* Try to change LPUART clock source */ RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; if (baudrate == 9600) { PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LPUART1; PeriphClkInitStruct.Lpuart1ClockSelection = RCC_LPUART1CLKSOURCE_LSE; HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct); if (init_uart(obj) == HAL_OK){ return; } } else { PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LPUART1; PeriphClkInitStruct.Lpuart1ClockSelection = RCC_LPUART1CLKSOURCE_SYSCLK; HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct); if (init_uart(obj) == HAL_OK){ return; } } } #endif /* LPUART1_BASE */ debug("Cannot initialize UART with baud rate %u\n", baudrate); } } void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_bits) { struct serial_s *obj_s = SERIAL_S(obj); switch (parity) { case ParityOdd: obj_s->parity = UART_PARITY_ODD; break; case ParityEven: obj_s->parity = UART_PARITY_EVEN; break; default: // ParityNone case ParityForced0: // unsupported! case ParityForced1: // unsupported! obj_s->parity = UART_PARITY_NONE; break; } switch (data_bits) { case 7: if (parity != UART_PARITY_NONE) { obj_s->databits = UART_WORDLENGTH_8B; } else { #if defined UART_WORDLENGTH_7B obj_s->databits = UART_WORDLENGTH_7B; #else error("7-bit data format without parity is not supported"); #endif } break; case 8: if (parity != UART_PARITY_NONE) { obj_s->databits = UART_WORDLENGTH_9B; } else { obj_s->databits = UART_WORDLENGTH_8B; } break; case 9: if (parity != UART_PARITY_NONE) { error("Parity is not supported with 9-bit data format"); } else { obj_s->databits = UART_WORDLENGTH_9B; } break; default: error("Only 7, 8 or 9-bit data formats are supported"); break; } if (stop_bits == 2) { obj_s->stopbits = UART_STOPBITS_2; } else { obj_s->stopbits = UART_STOPBITS_1; } init_uart(obj); } /****************************************************************************** * READ/WRITE ******************************************************************************/ int serial_readable(serial_t *obj) { struct serial_s *obj_s = SERIAL_S(obj); UART_HandleTypeDef *huart = &uart_handlers[obj_s->index]; /* To avoid a target blocking case, let's check for * possible OVERRUN error and discard it */ if(__HAL_UART_GET_FLAG(huart, UART_FLAG_ORE)) { __HAL_UART_CLEAR_OREFLAG(huart); } // Check if data is received return (__HAL_UART_GET_FLAG(huart, UART_FLAG_RXNE) != RESET) ? 1 : 0; } int serial_writable(serial_t *obj) { struct serial_s *obj_s = SERIAL_S(obj); UART_HandleTypeDef *huart = &uart_handlers[obj_s->index]; // Check if data is transmitted return (__HAL_UART_GET_FLAG(huart, UART_FLAG_TXE) != RESET) ? 1 : 0; } void serial_pinout_tx(PinName tx) { pinmap_pinout(tx, PinMap_UART_TX); } void serial_break_clear(serial_t *obj) { (void)obj; } /****************************************************************************** * UTILITY FUNCTIONS ******************************************************************************/ HAL_StatusTypeDef init_uart(serial_t *obj) { struct serial_s *obj_s = SERIAL_S(obj); UART_HandleTypeDef *huart = &uart_handlers[obj_s->index]; huart->Instance = (USART_TypeDef *)(obj_s->uart); huart->Init.BaudRate = obj_s->baudrate; huart->Init.WordLength = obj_s->databits; huart->Init.StopBits = obj_s->stopbits; huart->Init.Parity = obj_s->parity; #if DEVICE_SERIAL_FC huart->Init.HwFlowCtl = obj_s->hw_flow_ctl; #else huart->Init.HwFlowCtl = UART_HWCONTROL_NONE; #endif huart->Init.OverSampling = UART_OVERSAMPLING_16; huart->TxXferCount = 0; huart->TxXferSize = 0; huart->RxXferCount = 0; huart->RxXferSize = 0; if (obj_s->pin_rx == NC) { huart->Init.Mode = UART_MODE_TX; } else if (obj_s->pin_tx == NC) { huart->Init.Mode = UART_MODE_RX; } else { huart->Init.Mode = UART_MODE_TX_RX; } return HAL_UART_Init(huart); } int8_t get_uart_index(UARTName uart_name) { uint8_t index = 0; #if defined(USART1_BASE) if (uart_name == UART_1) { return index; } index++; #endif #if defined(USART2_BASE) if (uart_name == UART_2) { return index; } index++; #endif #if defined(USART3_BASE) if (uart_name == UART_3) { return index; } index++; #endif #if defined(UART4_BASE) if (uart_name == UART_4) { return index; } index++; #endif #if defined(USART4_BASE) if (uart_name == UART_4) { return index; } index++; #endif #if defined(UART5_BASE) if (uart_name == UART_5) { return index; } index++; #endif #if defined(USART5_BASE) if (uart_name == UART_5) { return index; } index++; #endif #if defined(USART6_BASE) if (uart_name == UART_6) { return index; } index++; #endif #if defined(UART7_BASE) if (uart_name == UART_7) { return index; } index++; #endif #if defined(USART7_BASE) if (uart_name == UART_7) { return index; } index++; #endif #if defined(UART8_BASE) if (uart_name == UART_8) { return index; } index++; #endif #if defined(USART8_BASE) if (uart_name == UART_8) { return index; } index++; #endif #if defined(UART9_BASE) if (uart_name == UART_9) { return index; } index++; #endif #if defined(UART10_BASE) if (uart_name == UART_10) { return index; } index++; #endif #if defined(LPUART1_BASE) if (uart_name == LPUART_1) { return index; } index++; #endif return -1; } #endif /* DEVICE_SERIAL */
the_stack_data/1861.c
//@ ltl invariant negative: (<> (AP(x_4 - x_1 > -19) U (<> AP(x_5 - x_3 > 16)))); float x_0; float x_1; float x_2; float x_3; float x_4; float x_5; float x_6; float x_7; int main() { float x_0_; float x_1_; float x_2_; float x_3_; float x_4_; float x_5_; float x_6_; float x_7_; while(1) { x_0_ = (((10.0 + x_0) > (6.0 + x_1)? (10.0 + x_0) : (6.0 + x_1)) > ((2.0 + x_3) > (1.0 + x_6)? (2.0 + x_3) : (1.0 + x_6))? ((10.0 + x_0) > (6.0 + x_1)? (10.0 + x_0) : (6.0 + x_1)) : ((2.0 + x_3) > (1.0 + x_6)? (2.0 + x_3) : (1.0 + x_6))); x_1_ = (((1.0 + x_1) > (11.0 + x_4)? (1.0 + x_1) : (11.0 + x_4)) > ((3.0 + x_5) > (16.0 + x_6)? (3.0 + x_5) : (16.0 + x_6))? ((1.0 + x_1) > (11.0 + x_4)? (1.0 + x_1) : (11.0 + x_4)) : ((3.0 + x_5) > (16.0 + x_6)? (3.0 + x_5) : (16.0 + x_6))); x_2_ = (((16.0 + x_0) > (20.0 + x_3)? (16.0 + x_0) : (20.0 + x_3)) > ((10.0 + x_4) > (18.0 + x_5)? (10.0 + x_4) : (18.0 + x_5))? ((16.0 + x_0) > (20.0 + x_3)? (16.0 + x_0) : (20.0 + x_3)) : ((10.0 + x_4) > (18.0 + x_5)? (10.0 + x_4) : (18.0 + x_5))); x_3_ = (((3.0 + x_0) > (5.0 + x_3)? (3.0 + x_0) : (5.0 + x_3)) > ((5.0 + x_4) > (16.0 + x_7)? (5.0 + x_4) : (16.0 + x_7))? ((3.0 + x_0) > (5.0 + x_3)? (3.0 + x_0) : (5.0 + x_3)) : ((5.0 + x_4) > (16.0 + x_7)? (5.0 + x_4) : (16.0 + x_7))); x_4_ = (((3.0 + x_0) > (7.0 + x_1)? (3.0 + x_0) : (7.0 + x_1)) > ((3.0 + x_4) > (3.0 + x_5)? (3.0 + x_4) : (3.0 + x_5))? ((3.0 + x_0) > (7.0 + x_1)? (3.0 + x_0) : (7.0 + x_1)) : ((3.0 + x_4) > (3.0 + x_5)? (3.0 + x_4) : (3.0 + x_5))); x_5_ = (((20.0 + x_1) > (10.0 + x_3)? (20.0 + x_1) : (10.0 + x_3)) > ((19.0 + x_4) > (8.0 + x_6)? (19.0 + x_4) : (8.0 + x_6))? ((20.0 + x_1) > (10.0 + x_3)? (20.0 + x_1) : (10.0 + x_3)) : ((19.0 + x_4) > (8.0 + x_6)? (19.0 + x_4) : (8.0 + x_6))); x_6_ = (((3.0 + x_1) > (14.0 + x_4)? (3.0 + x_1) : (14.0 + x_4)) > ((6.0 + x_6) > (15.0 + x_7)? (6.0 + x_6) : (15.0 + x_7))? ((3.0 + x_1) > (14.0 + x_4)? (3.0 + x_1) : (14.0 + x_4)) : ((6.0 + x_6) > (15.0 + x_7)? (6.0 + x_6) : (15.0 + x_7))); x_7_ = (((2.0 + x_2) > (2.0 + x_3)? (2.0 + x_2) : (2.0 + x_3)) > ((10.0 + x_4) > (17.0 + x_7)? (10.0 + x_4) : (17.0 + x_7))? ((2.0 + x_2) > (2.0 + x_3)? (2.0 + x_2) : (2.0 + x_3)) : ((10.0 + x_4) > (17.0 + x_7)? (10.0 + x_4) : (17.0 + x_7))); x_0 = x_0_; x_1 = x_1_; x_2 = x_2_; x_3 = x_3_; x_4 = x_4_; x_5 = x_5_; x_6 = x_6_; x_7 = x_7_; } return 0; }
the_stack_data/95451515.c
//Huffman code #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> struct node{ int value; char ch; struct node *lson, *rson; }; typedef struct node Node; typedef struct queue{ Node * n; struct queue * next; } Queue; Queue * head; Queue * createQueue(){ Queue * q = malloc(sizeof(Queue)); q -> next = NULL; q -> n = NULL; return q; } void push(Node * n){ //printf("Push: %d \n", n->value); if(head == NULL){ head = createQueue(); } if(head->n == NULL) { head->n = n; return; } Queue *q = head, * q_next = createQueue(); q_next->n = n; while(q->next != NULL){ if(n->value <= q->next->n->value) break; q = q->next; } if(q == head && n->value < q->n->value){ q_next -> next = q; head = q_next; } q_next -> next = q->next; q->next = q_next; } int isEmpty(){ return head==NULL ? 1:0; } int isAlone(){ return head->next == NULL ? 1:0; } Node * pop(){ Node * n = head -> n; Queue * h = head; head = head -> next; if(head != NULL) free(h); return n; } Node * peek(){ return head -> n; } //Find if a character is in a string and that characters position int contains(char, char *, int); void quickSort(); void count(); int partition(); Node * huffmanTree(); void printTree(); void printQueue(); int reps[256] = {}; char chars[256] = {EOF}; int uniq = 0; Node * nodes[256]; Node * createNode(){ Node * n = malloc(sizeof(Node)); n -> lson = NULL; n -> rson = NULL; return n; } int main(int argc, char * argv[]){ char ch; char str[40960]; int i = 0; while((ch=getc(stdin))!=EOF){ str[i++] = ch; } int size = strlen(str); // quickSort(argv[1], 0, size); // argv[1][0] = ' '; // printf("%s\n%d\n", argv[1], size); huffmanTree(str,size); return 0; } void count(char arr[], int size){ int i = 0, pos = -1; for(i=0;i<size;i++) { pos = contains(arr[i], chars, uniq); if(pos > 0) { reps[pos]++; } else { chars[uniq] = arr[i]; reps[uniq]++; uniq++; } } } int contains(char ch, char arr[], int size){ int i=0; for(i=0; i<size; i++){ if(ch==arr[i]) return i; } return -1; } //*-----------------------------QUICKSORT ALGORITHM FOR TESTING-----------------------------------*// //-------------------------------------------------------------------------------------------------// void quickSort(int l, int r) { int j; if( l < r ) { // divide and conquer j = partition(l, r); quickSort(l, j-1); quickSort(j+1, r); } } int partition(int l, int r) { int i, j, pivot = reps[l], t; char tmp; i = l; j = r+1; printf("%d %d %d\n", l, j, r); while(1) { do ++i; while( reps[i] <= pivot && i <= r ); do --j; while( reps[j] > pivot ); if( i >= j ) break; t = reps[i]; reps[i] = reps[j]; reps[j] = t; tmp = chars[i]; chars[i] = chars[j]; chars[j] = tmp; } t = reps[l]; reps[l] = reps[j]; reps[j] = t; tmp = chars[l]; chars[l] = chars[j]; chars[j] = tmp; return j; } //------------------------------------------------------------------------------------------------// //*---------------------------------------END OF QUICKSORT---------------------------------------*// void printNode(Node * n){ printf("v-%d | c-%c | lson-%d | rson-%d\n", n->value, n->ch, (int)n->lson, (int)n->rson); } Node * huffmanTree(char argv[], int size){ int i = 0; count(argv, size); //quickSort(0,uniq-1); Node * n; head = createQueue(); printf("Text: %d\nUnique: %d\n", size,uniq); for(i=0;i<uniq;i++){ n = createNode(); n -> value = reps[i]; n -> ch = chars[i]; push(n); //printf("%c : %d\n", chars[i], reps[i]); } printQueue(); i = 0; Node * n1, * n2; while(!isAlone()){ n1 = pop(); if(n1 == NULL) break; n2 = pop(); if(n2 == NULL) break; n = createNode(); n -> lson = n1; n -> rson = n2; n -> value = n1 -> value + n2 -> value; push(n); } printf("\n\n"); char str[1024] = {EOF}; printTree(n,str); return n; } int end = 0; void printTree(Node * n, char str[]){ if(n-> lson != NULL) { str[end] = '0'; end++; printTree(n->lson, str); } if(n->rson != NULL) { str[end] = '1'; end++; printTree(n->rson, str); } if(n->lson==NULL && n->rson==NULL) { str[end] = '\0'; printf("%s : %c : %d bits\n", str, n->ch, end); } end--; } void printQueue(){ Queue * q = head; int i = 0; while(q != NULL){ printf("Q: %d %c %d\n", i++, q->n==NULL ? ' ':q->n->ch, q->n==NULL ? 0:q->n->value); q = q->next; } }
the_stack_data/610550.c
#include <stdio.h> int main() { int a = 10; int b, c; a = a + 15; b = a + 200; c = a + b; printf("The result is %d\n", c); return 0; }
the_stack_data/59966.c
#include<stdio.h> int a[10]; void bubblesort(int a[],int n) { int i,j,temp; for(i=0;i<n;i++) { for(j=0;j<(n-i-1);j++) { if(a[j]>a[j+1]) { temp=a[j]; a[j]=a[j+1]; a[j+1]=temp; } } } } void main() { int i,n; printf("Enter the number of elements\n"); scanf("%d",&n); printf("Enter the elements\n"); for (int i = 0; i <n; i++) { scanf("%d",&a[i]); } printf("\nThe elements are:\n"); for (int i = 0; i <n; i++) { printf("%3d",a[i]); } bubblesort(a,n); printf("\nAfter bubblesort the elements are:\n"); for (int i = 0; i <n; i++) { printf("%3d",a[i]); } }
the_stack_data/14931.c
#include <stdio.h> #define N 20 int main(void) { int i = 0; char ch, initial, surname[N] = {0}; printf("Enter a first and last name: "); while ((ch = getchar()) == ' ') { ; } initial = ch; while ((ch = getchar()) != ' ') { ; } while ((ch = getchar()) != '\n') { surname[i++] = ch; } printf("You entered the name: "); for (i = 0; i < N; i++) { printf("%c", surname[i]); } printf(", %c.\n", initial); return 0; }
the_stack_data/335718.c
/* { dg-options "-std=gnu99 -O" } */ /* C99 6.5.5: Multiplicative operators. C99 6.5.6: Additive operators. */ extern void link_error (void); int main () { _Decimal32 d32_1, d32_2; /* Compare like-typed positive constants. */ if (2.99df + 5.1df != 8.09df) link_error (); if (5.77df - 2.22dd != 3.55df) link_error (); if (2.0dl * 3.7dd * -2 != -14.8df) link_error (); if (.18df / -.2df + 1 != 1.e-1dd) link_error (); d32_1 = 3.0df; d32_2 = 1.0df; if (!__builtin_constant_p (d32_1 + 0.2df)) link_error (); if (!__builtin_constant_p (1.0df / 3.0df)) link_error (); if (!__builtin_constant_p (d32_2 / d32_1)) link_error (); d32_2 = 2.0df; if (!__builtin_constant_p (d32_2 / d32_1)) link_error (); return 0; }
the_stack_data/70450292.c
#include <stdio.h> /* 18/10/13 中国古代数学家张丘建在他的<算经>中提出了一个著名的'百钱百鸡问题': 一只公鸡值五钱,一只母鸡值三千,三只小鸡值一钱,现在要用百钱买百鸡,请问公鸡,母鸡,小鸡各多少只 ? */ int main() { int cock, hen, chicken,count; for (cock = 0; cock <= 20; cock++) { for (hen = 0; hen <= 33; hen++) { for (chicken = 0; chicken <= 100; chicken++) { count++; if ((5 * cock + 3 * hen + chicken / 3.0 == 100) && (cock + hen + chicken == 100)) printf("cock=%d,hen=%d,chicken=%d\n", cock, hen, chicken); } } } printf("count=%d\n",count); getchar(); return 0; } /* 采用'穷举法'需要穷举尝试21*34*101=72114次(算法的效率显然太低) 对于本题而言:公鸡的数量确定后,小鸡的数量就固定为:100-cock-hen,继而无需再进行穷举法.(此时约束条件只有一个:5*cock+3*hen+chicken/3.0==100) 这样可以利用双重循环即可实现:(此算法只需要尝试:21*34=714次,相比上述算法运算减少了十倍左右) */ /* int main() { int cock,hen,chicken,count; for(cock=0;cock<=20;cock++) { for(hen=0;hen<=33;hen++) { count ++; chicken=100-cock-hen; if(5*cock+3*hen+chicken/3.0==100) printf("cock=%d,hen=%d,chicken=%d\n",cock,hen,chicken); } } printf("count=%d\n",count); getchar(); return 0; } */
the_stack_data/57950795.c
/*- * Copyright (c) 1991 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted provided * that: (1) source distributions retain this entire copyright notice and * comment, and (2) distributions including binaries display the following * acknowledgement: ``This product includes software developed by the * University of California, Berkeley and its contributors'' in the * documentation or other materials provided with the distribution and in * all advertising materials mentioning features or use of this software. * 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #if 0 /* dead code */ /* * From: @(#)authenc.c 5.1 (Berkeley) 3/1/91 */ char authenc_rcsid[] = "$Id: authenc.c,v 1.5 1999/12/12 14:59:44 dholland Exp $"; #if defined(ENCRYPT) || defined(AUTHENTICATE) #include "telnetd.h" #include <libtelnet/misc.h> int net_write(str, len) unsigned char *str; int len; { if (nfrontp + len < netobuf + BUFSIZ) { bcopy((void *)str, (void *)nfrontp, len); nfrontp += len; return(len); } return(0); } void net_encrypt() { #if defined(ENCRYPT) char *s = (nclearto > nbackp) ? nclearto : nbackp; if (s < nfrontp && encrypt_output) { (*encrypt_output)((unsigned char *)s, nfrontp - s); } nclearto = nfrontp; #endif } int telnet_spin() { ttloop(); return(0); } char * telnet_getenv(val) char *val; { extern char *getenv(); return(getenv(val)); } char * telnet_gets(prompt, result, length, echo) char *prompt; char *result; int length; int echo; { return((char *)0); } #endif #endif /* 0 */
the_stack_data/193893239.c
#include <stdio.h> void change_array(int(*arr)[3]) { //배열 포인터 for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { arr[i][j] = 0; //arr의 값 0으로 변경 } } } int main() { int arr[3][3] = { {10, 20, 30}, {100, 200, 300}, {100, 200, 300}}; change_array(arr); //출력 for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { printf("arr[%d][%d] : %d ", i, j, arr[i][j]); } printf("\n"); } }
the_stack_data/153184.c
/* { dg-do compile } */ /* { dg-options "-mrdrnd" } */ extern void bar (int); void foo (unsigned *u) { int i = __builtin_ia32_rdrand32_step (u); bar (i); }
the_stack_data/3532.c
#include <stdio.h> int main(){ int i, j, soma, matrizA[4][5], matrizB[4], matrizC[5]; matrizC[0]=0; matrizC[1]=0; matrizC[2]=0; matrizC[3]=0; matrizC[4]=0; for (i = 0; i < 4; i++) { matrizB[i] = 0; for (j = 0; j < 5; j++) { printf("%d - %d: ", i, j); scanf("%d", &matrizA[i][j]); matrizB[i] += matrizA[i][j]; if (j==0) { //printf("%d A %d C J-%d\n", matrizA[i][j], matrizC[j], j); //printf("%d\n", matrizC[j] + matrizA[i][j]); matrizC[j] = matrizC[j] + matrizA[i][j]; //printf("%d\n", matrizC[j] + matrizA[i][j]); //printf("%d A %d C J-%d\n", matrizA[i][j], matrizC[j], j); } else if (j==1) { matrizC[j] += matrizA[i][j]; //printf("%d A %d C J-1\n", matrizA[i][j], matrizC[j], j); } else if (j==2) { matrizC[j] += matrizA[i][j]; //printf("%d A %d C J-2\n", matrizA[i][j], matrizC[j], j); } else if (j==3) { matrizC[j] += matrizA[i][j]; //printf("%d A %d C J-3\n", matrizA[i][j], matrizC[j], j); } else if (j==4) { matrizC[j] += matrizA[i][j]; //printf("%d A %d C J-4\n", matrizA[i][j], matrizC[j], j); } } } printf("\nMatriz A\n"); for (i = 0; i < 4; i++) { for(j=0;j<5;j++){ printf("| %.4d |", matrizA[i][j]); } printf("\n"); } soma = 0; printf("\nMatriz B\n"); for (i = 0; i < 4; i++) { printf("| %.4d |", matrizB[i]); printf("\n"); soma += matrizB[i]; } printf("\nMatriz A soma: %d\n", soma); soma = 0; printf("\nMatriz C\n"); for (i = 0; i < 5; i++) { printf("| %.4d |", matrizC[i]); printf("\n"); soma += matrizC[i]; } printf("\nMatriz B soma: %d\n", soma); return 0; }
the_stack_data/34513984.c
// KASAN: use-after-free Write in vcs_read // https://syzkaller.appspot.com/bug?id=ad1f53726c3bd11180cb // 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 <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.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> 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; } static void kill_and_wait(int pid, int* status) { kill(-pid, SIGKILL); kill(pid, SIGKILL); for (int 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 = 0; for (;; 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; } } } uint64_t r[1] = {0xffffffffffffffff}; void execute_one(void) { intptr_t res = 0; memcpy((void*)0x20000440, "/dev/vcsa\000", 10); res = syscall(__NR_openat, 0xffffffffffffff9cul, 0x20000440ul, 0ul, 0ul); if (res != -1) r[0] = res; *(uint64_t*)0x20001b00 = 0x20001b40; *(uint64_t*)0x20001b08 = 0x19008; syscall(__NR_preadv, r[0], 0x20001b00ul, 6ul, 3, 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/29824067.c
#include <stdio.h> #include <stdint.h> #include <string.h> void func1 () { uint8_t plaintext_text[] = "1234567890abcdef"; unsigned long len = (unsigned long) (sizeof(plaintext_text) / sizeof(uint8_t)); printf("len = %lu\n", len); } void func2 () { uint8_t plaintext_text[] = "1234567890abcdef"; unsigned long len = (unsigned long) (strlen(plaintext_text) / sizeof(uint8_t)); printf("len = %lu\n", len); } void main() { func1(); func2(); }
the_stack_data/107953488.c
/* ES1 - Realizzare un sottoprogramma che riceve come parametro una stringa di testo composta da parole in caratteri minuscoli ciascuna di lunghezza indefinita e separate da singoli spazi. Il sottoprogramma modifica la stringa secondo la procedura qui sotto riportata e poi ne stampa all'utente la nuova versione. Procedura: ogni parola all'interno della stringa di testo viene invertita, l'ultima lettera diventa la prima e viceversa. Esempio Input: ciao come stai Output: oaic emoc iats Scrivere un programma che chiede all'utente una stringa di al massimo 250 caratteri, invoca su di essa il sottoprogramma sopra definito e stampa a video il risultato. */ /* NON FUNZIONA */ #include <stdio.h> #define SEP ' ' #define STRDIM 250 void invertiparola(char[]); int main(){ char str[STRDIM+1]; scanf("%[^\n]", str); invertiparola(str); return 0; } void invertiparola(char str[]){ int i, j, fine, inizio; char c; for(i=0, inizio=0; str[i] != '\0'; i++){ if(str[i] == SEP){ fine = i-1; for(j=inizio; j<(fine-inizio + 1)/2; j++){ c = str[j]; str[j] = str[fine-j]; str[fine-j] = c; } inizio = i+1; } } printf("%s\n", str); }
the_stack_data/83779.c
// // Determine the Nature of a Stream, isatty // // This specifically checks whether a stream is a terminal. // The minimal implementation only has the single output stream, // which is to the console, so always returns 1. // int _isatty (int file) { return 1; }
the_stack_data/92327960.c
#include <stdio.h> #include <stdlib.h> void checkError(FILE *f, char *topic) { if (ferror(f)) { printf("Error %s: %d\n", topic, ferror(f)); exit(1); } } static int scanPolicy(FILE *f, int *a, int *b, char *r) { switch (fscanf(f, "%d-%d %c: ", a, b, r)) { case 3: return 1; case EOF: checkError(f, "reading policy"); } return 0; } static int readPasswordChar(FILE *f, int *c) { *c = fgetc(f); return *c != EOF && *c != 10 && *c != 13; } static int readPassword(FILE *f) { int min = 0; int max = 0; char r = '\0'; int n = 0; if (!scanPolicy(f, &min, &max, &r)) return 0; for (int c = 0; readPasswordChar(f, &c);) n += c == r; checkError(f, "reading password"); return n >= min && n <= max; } static int countPasswords(FILE *f) { int count = 0; while (!feof(f)) count += readPassword(f); return count; } int main(int argc, char **argv) { FILE *f = fopen("input.raw", "r"); if (f == NULL) { printf("Error opening file!\n"); return 0; } const int count = countPasswords(f); fclose(f); printf("Count: %d\n", count); return 0; }
the_stack_data/104827270.c
// RUN: %clang_cc1 -fsyntax-only -verify %s -Wunused-function /// We allow 'retain' on non-ELF targets because 'retain' is often used together /// with 'used'. 'used' has GC root semantics on macOS and Windows. We want /// users to just write retain,used and don't need to dispatch on binary formats. extern char test1[] __attribute__((retain)); // expected-warning {{'retain' attribute ignored on a non-definition declaration}} extern const char test2[] __attribute__((retain)); // expected-warning {{'retain' attribute ignored on a non-definition declaration}} const char test3[] __attribute__((retain)) = ""; struct __attribute__((retain)) s { // expected-warning {{'retain' attribute only applies to variables with non-local storage, functions, and Objective-C methods}} }; void foo() { static int a __attribute__((retain)); int b __attribute__((retain)); // expected-warning {{'retain' attribute only applies to variables with non-local storage, functions, and Objective-C methods}} (void)a; (void)b; } __attribute__((retain,used)) static void f0() {} __attribute__((retain)) static void f1() {} // expected-warning {{unused function 'f1'}} __attribute__((retain)) void f2() {} /// Test attribute merging. int tentative; int tentative __attribute__((retain)); extern int tentative; int tentative = 0;
the_stack_data/115764359.c
#include <stdio.h> #include <stdlib.h> typedef struct{ char *name; int (*function)(void); }test; test* tests; int n = 0; void test_init(int testCount){ tests = malloc(testCount * sizeof(test)); } void test_add(char* name, int (*function)(void)){ tests[n].name = name; tests[n].function = function; n++; } int test_run(){ int passed = 0; for(int i = 0; i < n; i++){ printf("Running test: \"%s\"... ", tests[i].name); if(tests[i].function()){ puts("PASSED."); passed++; }else puts("FAILED."); } int failed = n - passed; printf("%d/%d (%d%%) tests passed, %d/%d (%d%%) failed.\n", passed, n, (passed*100/n), failed, n, (failed*100/n)); free(tests); return failed; }
the_stack_data/73574822.c
#include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct { char name[30]; char lastname[30]; char email[30]; int age; } client; typedef struct { client cliente; char name[40]; char date[20]; char clasification[10]; int rate; } movie; int main(int argc, char *argv[]) { FILE *fp; fp = fopen("db.bin", "ab+"); if (!fp) fp = fopen("db.bin", "wb+"); printf("*****Bienvenido al programa \"sistema administrativo\"*****\n-Para agregar un nuevo cliente ingresa: 1.\n-Para eliminar un cliente ingresa: 2.\n-Para modificar un cliente ingresa: 3.\n-Para ver los Clientes almacenados ingresa: 4.\n-Para terminar el programa ingresa: 0.\n"); int choise; printf("%s", "Introduce una operacion: "); scanf("%d", &choise); if (choise < 0 || choise > 4) { while (choise < 0 || choise > 4) { printf("%s\n", "Error: opcion invalida, vuelve a introducir otro numero"); scanf("%d", &choise); } } else { while (choise != 0) { switch (choise) { // CREAR UN CLIENTE Y UNA PELICULA case 1:; client cliente; printf("%s", "Introduce el nombre (solo nombre) del cliente: "); scanf("%s", cliente.name); printf("%s", "Introduce el apellido del cliente: "); scanf("%s", cliente.lastname); printf("%s", "Introduce el correo del cliente: "); scanf("%s", cliente.email); printf("%s", "Introduce la edad del cliente: "); scanf("%d", &cliente.age); fwrite(&cliente, sizeof(cliente), 1, fp); break; // ELIMINAR UN NOMBRE Y PELICULA case 2:; char delete[40]; printf("%s", "Introduce el nombre del usuario que quieres eliminar: "); scanf("%s", delete); FILE *fp_rename = fopen("db_temp.bin", "wb+"); client write; fseek(fp, 0, SEEK_SET); while (fread(&write, sizeof(client), 1, fp)) { if (strcmp(write.name, delete) == 0){ } else fwrite(&write, sizeof(client), 1, fp_rename); } remove("db.bin"); rename("db_temp.bin", "db.bin"); fclose(fp_rename); fp = fopen("db.bin", "ab+"); break; // MODIFICAR UN CLIENTE case 3:; char rewrite[40]; printf("%s", "Introduce el nombre del usuario que quieres modificar: "); scanf("%s", rewrite); client modify; printf("%s", "Introduce el nuevo nombre: "); scanf("%s", modify.name); printf("%s", "Introduce el nuevo apellido: "); scanf("%s", modify.lastname); printf("%s", "Introduce el nuevo correo: "); scanf("%s", modify.email); printf("%s", "Introduce la nueva edad: "); scanf("%d", &modify.age); client newClient; FILE *fp_temp = fopen("db_temp.bin", "wb+"); fseek(fp, 0, SEEK_SET); while (fread(&newClient, sizeof(client), 1, fp)) { if (strcmp(newClient.name, rewrite) == 0) { strcpy(newClient.name, modify.name); strcpy(newClient.lastname, modify.lastname); strcpy(newClient.email, modify.email); newClient.age = modify.age; fwrite(&newClient, sizeof(client), 1, fp_temp); } else fwrite(&newClient, sizeof(client), 1, fp_temp); } fclose(fp_temp); remove("db.bin"); rename("db_temp.bin", "db.bin"); fp = fopen("db.bin", "ab+"); break; // LEER EL ARCHIVO case 4:; fseek(fp, 0, SEEK_SET); client rCliente; while (fread(&rCliente, sizeof(client), 1, fp)) { printf("%s %s %s %d\n", rCliente.name, rCliente.lastname, rCliente.email, rCliente.age); } break; } printf("\n%s", "Siguiente operacion: "); scanf("%d", &choise); if (choise < 0 || choise > 4){ while (choise < 0 || choise > 4) { printf("%s\n", "Error: opcion invalida, vuelve a introducir otro numero"); scanf("%d", &choise); } } } } // CERRAR EL ARCHIVO fclose(fp); return 0; }
the_stack_data/44579.c
#include <stdio.h> int main() { unsigned char x, y, z, a; x=0; y=0; z=0; a=1; for(unsigned long i=0;;i++) { unsigned char t = x ^ (x << 4); x=y; y=z; z=a; a = z ^ t ^ ( z >> 1) ^ (t << 1); printf("%i\n", a); } }
the_stack_data/125902.c
#include <stdlib.h> #include <stdio.h> #include <math.h> #include <sys/mman.h> int _create_DMA_buff(unsigned long *virtual_addr, unsigned long *physical_addr, size_t length){ int temp; size_t contig_length; void *v_addr; //unsigned int p_addr; #ifdef __QNX__ off64_t p_addr; // map and get 'virtual address' (address in calling processes memory space) for a zero filled memory region // of size. This space can be used for DMA transfer of data. //v_addr = mmap( 0, length, PROT_READ|PROT_WRITE|PROT_NOCACHE, MAP_PHYS|MAP_ANON|MAP_NOX64K, NOFD, 0); v_addr = mmap( 0, length, PROT_READ|PROT_WRITE|PROT_NOCACHE, MAP_PHYS|MAP_ANON, NOFD, 0); //v_addr = mmap( 0, length, PROT_READ|PROT_WRITE|PROT_NOCACHE, MAP_PHYS|MAP_ANON|MAP_BELOW16M, NOFD, 0); if (virtual_addr == MAP_FAILED){ perror("Mapping of DMA buffer failed"); return -1; } // now get the phsical address of this memory space to be provided to the DMA bus master (PLX9656) for // DMA transfer of the data from the bus master //mem_offset( v_addr, NOFD, length, &p_addr, &contig_length); temp=mem_offset64( v_addr, NOFD, 1, &p_addr, 0); if (temp == -1){ perror("Cannot determine physical address of DMA buffer"); return -1; } *physical_addr=p_addr; *virtual_addr=v_addr; //printf("PHYSICAL ADDR= %x\n", *physical_addr); //printf("VIRTUAL ADDR= %x\n", *virtual_addr); //printf("CONTIG_LENGTH= %d\n", contig_length); //printf("LENGTH= %d\n", length); #endif return 1; }
the_stack_data/162643902.c
/* * File: randombytes/randombytes.c * Author: Michael Hutter, Peter Schwabe * Version: Tue Aug 12 08:23:16 2014 +0200 * Public Domain */ /* * From try-anything.c version 20120328 * by D. J. Bernstein */ typedef unsigned long uint32; static uint32 seed[32] = { 3,1,4,1,5,9,2,6,5,3,5,8,9,7,9,3,2,3,8,4,6,2,6,4,3,3,8,3,2,7,9,5 } ; static uint32 in[12]; static uint32 out[8]; static int outleft = 0; #define ROTATE(x,b) (((x) << (b)) | ((x) >> (32 - (b)))) #define MUSH(i,b) x = t[i] += (((x ^ seed[i]) + sum) ^ ROTATE(x,b)); static void surf(void) { uint32 t[12]; uint32 x; uint32 sum = 0; int r; int i; int loop; for (i = 0;i < 12;++i) t[i] = in[i] ^ seed[12 + i]; for (i = 0;i < 8;++i) out[i] = seed[24 + i]; x = t[11]; for (loop = 0;loop < 2;++loop) { for (r = 0;r < 16;++r) { sum += 0x9e3779b9; MUSH(0,5) MUSH(1,7) MUSH(2,9) MUSH(3,13) MUSH(4,5) MUSH(5,7) MUSH(6,9) MUSH(7,13) MUSH(8,5) MUSH(9,7) MUSH(10,9) MUSH(11,13) } for (i = 0;i < 8;++i) out[i] ^= t[i + 4]; } } void randombytes(unsigned char *x,unsigned long long xlen) { while (xlen > 0) { if (!outleft) { if (!++in[0]) if (!++in[1]) if (!++in[2]) ++in[3]; surf(); outleft = 8; } *x = out[--outleft]; ++x; --xlen; } }
the_stack_data/107952700.c
/* * execargh1.c * * Print out the addresses of the arguments passed to exec to help * debug whether handleExec is reading the pointers correctly. Note * that the child process does not access the arguments; this program * focuses on the layout of the arguments in the parent's address space. * * Geoff Voelker * 11/9/15 */ #include "syscall.h" int main (int argc, char *argv[]) { int r; int childargc = 5; char *childargv[5] = { "exit1.coff", "roses are red", "violets are blue", "I love Nachos", "and so do you", }; printf ("childargc: %d\n", childargc); printf ("childargv: %d (0x%x)\n\n", childargv, childargv); // note that childargv == &childargv[0] printf ("&childargv[0]: %d (0x%x)\n", &childargv[0], &childargv[0]); printf ("&childargv[1]: %d (0x%x)\n", &childargv[1], &childargv[1]); printf ("&childargv[2]: %d (0x%x)\n", &childargv[2], &childargv[2]); printf ("&childargv[3]: %d (0x%x)\n", &childargv[3], &childargv[3]); printf ("&childargv[4]: %d (0x%x)\n", &childargv[4], &childargv[4]); printf ("childargv[0]: %d (0x%x)\n", childargv[0], childargv[0]); printf ("childargv[1]: %d (0x%x)\n", childargv[1], childargv[1]); printf ("childargv[2]: %d (0x%x)\n", childargv[2], childargv[2]); printf ("childargv[3]: %d (0x%x)\n", childargv[3], childargv[3]); printf ("childargv[4]: %d (0x%x)\n", childargv[4], childargv[4]); r = exec (childargv[0], childargc, childargv); if (r < 0) { printf ("exec returned an error: %d\n", r); } else { printf ("exec succeded, child pid %d\n", r); } exit (r); }
the_stack_data/50137111.c
//***************************************************************************** // // startup_gcc.c - Startup code for use with GNU tools. // // Copyright (c) 2009-2012 Texas Instruments Incorporated. All rights reserved. // Software License Agreement // // Texas Instruments (TI) is supplying this software for use solely and // exclusively on TI's microcontroller products. The software is owned by // TI and/or its suppliers, and is protected under applicable copyright // laws. You may not combine this software with "viral" open-source // software in order to form a larger program. // // THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS. // NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT // NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY // CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL // DAMAGES, FOR ANY REASON WHATSOEVER. // // This is part of revision 8555 of the EK-LM3S9B90 Firmware Package. // //***************************************************************************** //***************************************************************************** // // Forward declaration of the default fault handlers. // //***************************************************************************** void ResetISR(void); static void NmiSR(void); static void FaultISR(void); static void IntDefaultHandler(void); //***************************************************************************** // // The entry point for the application. // //***************************************************************************** extern int main(void); //***************************************************************************** // // Reserve space for the system stack. // //***************************************************************************** static unsigned long pulStack[64]; //***************************************************************************** // // The vector table. Note that the proper constructs must be placed on this to // ensure that it ends up at physical address 0x0000.0000. // //***************************************************************************** __attribute__ ((section(".isr_vector"))) void (* const g_pfnVectors[])(void) = { (void (*)(void))((unsigned long)pulStack + sizeof(pulStack)), // The initial stack pointer ResetISR, // The reset handler NmiSR, // The NMI handler FaultISR, // The hard fault handler IntDefaultHandler, // The MPU fault handler IntDefaultHandler, // The bus fault handler IntDefaultHandler, // The usage fault handler 0, // Reserved 0, // Reserved 0, // Reserved 0, // Reserved IntDefaultHandler, // SVCall handler IntDefaultHandler, // Debug monitor handler 0, // Reserved IntDefaultHandler, // The PendSV handler IntDefaultHandler, // The SysTick handler IntDefaultHandler, // GPIO Port A IntDefaultHandler, // GPIO Port B IntDefaultHandler, // GPIO Port C IntDefaultHandler, // GPIO Port D IntDefaultHandler, // GPIO Port E IntDefaultHandler, // UART0 Rx and Tx IntDefaultHandler, // UART1 Rx and Tx IntDefaultHandler, // SSI0 Rx and Tx IntDefaultHandler, // I2C0 Master and Slave IntDefaultHandler, // PWM Fault IntDefaultHandler, // PWM Generator 0 IntDefaultHandler, // PWM Generator 1 IntDefaultHandler, // PWM Generator 2 IntDefaultHandler, // Quadrature Encoder 0 IntDefaultHandler, // ADC Sequence 0 IntDefaultHandler, // ADC Sequence 1 IntDefaultHandler, // ADC Sequence 2 IntDefaultHandler, // ADC Sequence 3 IntDefaultHandler, // Watchdog timer IntDefaultHandler, // Timer 0 subtimer A IntDefaultHandler, // Timer 0 subtimer B IntDefaultHandler, // Timer 1 subtimer A IntDefaultHandler, // Timer 1 subtimer B IntDefaultHandler, // Timer 2 subtimer A IntDefaultHandler, // Timer 2 subtimer B IntDefaultHandler, // Analog Comparator 0 IntDefaultHandler, // Analog Comparator 1 IntDefaultHandler, // Analog Comparator 2 IntDefaultHandler, // System Control (PLL, OSC, BO) IntDefaultHandler, // FLASH Control IntDefaultHandler, // GPIO Port F IntDefaultHandler, // GPIO Port G IntDefaultHandler, // GPIO Port H IntDefaultHandler, // UART2 Rx and Tx IntDefaultHandler, // SSI1 Rx and Tx IntDefaultHandler, // Timer 3 subtimer A IntDefaultHandler, // Timer 3 subtimer B IntDefaultHandler, // I2C1 Master and Slave IntDefaultHandler, // Quadrature Encoder 1 IntDefaultHandler, // CAN0 IntDefaultHandler, // CAN1 IntDefaultHandler, // CAN2 IntDefaultHandler, // Ethernet IntDefaultHandler, // Hibernate IntDefaultHandler, // USB0 IntDefaultHandler, // PWM Generator 3 IntDefaultHandler, // uDMA Software Transfer IntDefaultHandler, // uDMA Error IntDefaultHandler, // ADC1 Sequence 0 IntDefaultHandler, // ADC1 Sequence 1 IntDefaultHandler, // ADC1 Sequence 2 IntDefaultHandler, // ADC1 Sequence 3 IntDefaultHandler, // I2S0 IntDefaultHandler, // External Bus Interface 0 IntDefaultHandler // GPIO Port J }; //***************************************************************************** // // The following are constructs created by the linker, indicating where the // the "data" and "bss" segments reside in memory. The initializers for the // for the "data" segment resides immediately following the "text" segment. // //***************************************************************************** extern unsigned long _etext; extern unsigned long _data; extern unsigned long _edata; extern unsigned long _bss; extern unsigned long _ebss; //***************************************************************************** // // This is the code that gets called when the processor first starts execution // following a reset event. Only the absolutely necessary set is performed, // after which the application supplied entry() routine is called. Any fancy // actions (such as making decisions based on the reset cause register, and // resetting the bits in that register) are left solely in the hands of the // application. // //***************************************************************************** void ResetISR(void) { unsigned long *pulSrc, *pulDest; // // Copy the data segment initializers from flash to SRAM. // pulSrc = &_etext; for(pulDest = &_data; pulDest < &_edata; ) { *pulDest++ = *pulSrc++; } // // Zero fill the bss segment. // __asm(" ldr r0, =_bss\n" " ldr r1, =_ebss\n" " mov r2, #0\n" " .thumb_func\n" "zero_loop:\n" " cmp r0, r1\n" " it lt\n" " strlt r2, [r0], #4\n" " blt zero_loop"); // // Call the application's entry point. // main(); } //***************************************************************************** // // This is the code that gets called when the processor receives a NMI. This // simply enters an infinite loop, preserving the system state for examination // by a debugger. // //***************************************************************************** static void NmiSR(void) { // // Enter an infinite loop. // while(1) { } } //***************************************************************************** // // This is the code that gets called when the processor receives a fault // interrupt. This simply enters an infinite loop, preserving the system state // for examination by a debugger. // //***************************************************************************** static void FaultISR(void) { // // Enter an infinite loop. // while(1) { } } //***************************************************************************** // // This is the code that gets called when the processor receives an unexpected // interrupt. This simply enters an infinite loop, preserving the system state // for examination by a debugger. // //***************************************************************************** static void IntDefaultHandler(void) { // // Go into an infinite loop. // while(1) { } }
the_stack_data/11074762.c
#include <stdio.h> int main(void){ printf("this is the original program\n"); /*execl("/bin/vi", "vi", "asdf.txt", (char*)0);*/ execlp("vi", "vi", "asdf.txt", (char*)0); printf("this line should never be printed\n"); }
the_stack_data/182953911.c
// https://www.youtube.com/watch?v=cAZ8CyDY56s&list=PL2_aWCzGMAwI3W_JlcBbtYTwiQSsOTa6P&index=6 // Linked List in C/C++ - Inserting a node at beginning #include <stdio.h> #include<stdlib.h> typedef struct Node { /* data */ int data; struct Node* next; }Node; struct Node* head; void Insert(int x) { Node* temp = (Node*) malloc(sizeof(Node)); temp->data = x; temp->next = head; head = temp; } void Print() { Node* temp = head; printf("List is: "); while (temp != NULL) { printf(" %d", temp->data); temp = temp->next; } printf("\n"); } int main(void) { head = NULL; printf("How many numbers?\n"); int n, i, x; scanf("%d", &n); for (i = 0; i < n; i++) { printf("Enter the number?\n"); scanf("%d", &x); Insert(x); Print(); } return 0; }
the_stack_data/50138107.c
/* { dg-do compile } */ /* { dg-options "-O2 -Wall -Wextra -fdiagnostics-show-caret" } */ void f (void) { __builtin_printf ("%i", ""); /* { dg-warning "expects argument of type" } */ /* { dg-begin-multiline-output "" } __builtin_printf ("%i", ""); ~^ ~~ %s { dg-end-multiline-output "" } */ }
the_stack_data/142356.c
/* $Id$ */ atoi(s) register char *s; { register int total = 0; register unsigned digit; int minus = 0; while (*s == ' ' || *s == '\t') s++; if (*s == '+') s++; else if (*s == '-') { s++; minus = 1; } while ((digit = *s++ - '0') < 10) { total *= 10; total += digit; } return(minus ? -total : total); }
the_stack_data/104828266.c
int main() { int x = 2; int y; y = x += 2, 5; return y; }
the_stack_data/181392821.c
// Test that -print-libgcc-file-name correctly respects -rtlib=compiler-rt. // RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \ // RUN: --target=x86_64-pc-linux \ // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ // RUN: | FileCheck --check-prefix=CHECK-CLANGRT-X8664 %s // CHECK-CLANGRT-X8664: libclang_rt.builtins-x86_64.a // RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \ // RUN: --target=i386-pc-linux \ // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ // RUN: | FileCheck --check-prefix=CHECK-CLANGRT-I386 %s // CHECK-CLANGRT-I386: libclang_rt.builtins-i386.a // Check whether alternate arch values map to the correct library. // // RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \ // RUN: --target=i686-pc-linux \ // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ // RUN: | FileCheck --check-prefix=CHECK-CLANGRT-I386 %s // RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \ // RUN: --target=arm-linux-gnueabi \ // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ // RUN: | FileCheck --check-prefix=CHECK-CLANGRT-ARM %s // CHECK-CLANGRT-ARM: libclang_rt.builtins-arm.a // RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \ // RUN: --target=aarch64-linux-android \ // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ // RUN: | FileCheck --check-prefix=CHECK-CLANGRT-AARCH64-ANDROID %s // CHECK-CLANGRT-AARCH64-ANDROID: libclang_rt.builtins-aarch64-android.a // RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \ // RUN: --target=arm-linux-androideabi \ // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ // RUN: | FileCheck --check-prefix=CHECK-CLANGRT-ARM-ANDROID %s // CHECK-CLANGRT-ARM-ANDROID: libclang_rt.builtins-arm-android.a // RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \ // RUN: --target=arm-linux-gnueabihf \ // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ // RUN: | FileCheck --check-prefix=CHECK-CLANGRT-ARMHF %s // CHECK-CLANGRT-ARMHF: libclang_rt.builtins-armhf.a // RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \ // RUN: --target=arm-linux-gnueabi -mfloat-abi=hard \ // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ // RUN: | FileCheck --check-prefix=CHECK-CLANGRT-ARM-ABI %s // CHECK-CLANGRT-ARM-ABI: libclang_rt.builtins-armhf.a
the_stack_data/92328976.c
#include <stdio.h> #include <setjmp.h> static jmp_buf buf; void (*fp)() = NULL; void second(void) { printf("second\n"); // prints longjmp(buf, 1); // jumps back to where setjmp was called - making setjmp now // return 1 } void first(void) { fp(); printf("first\n"); // does not print } int main(int argc, char **argv) { fp = argc == 200 ? NULL : second; volatile int x = 0; if (!setjmp(buf)) { x++; first(); // when executed, setjmp returns 0 } else { // when longjmp jumps back, setjmp returns 1 printf("main: %d\n", x); // prints } return 0; }
the_stack_data/891202.c
#include<stdio.h> double hornerTaylor(int x, int n) { static double s = 1; if (n==0) return s; else { s = 1 + s*x/n; return hornerTaylor(x, n-1); } } int main() { printf("%lf", hornerTaylor(1, 10)); return 0; }
the_stack_data/744428.c
/* * module 3 * problem 1 * * Print on screen the square and cube of the first 25 natural numbers. */ /* imported libraries */ #include <stdio.h> #include <math.h> /* entry point */ int main(int argc, char *argv[]) { int numrs, cuddo, cubo; printf("\n===================================================================="); for (numrs = 1; numrs < 26; numrs++) { cuddo = pow(numrs, 2); cubo = pow(numrs, 3); if (numrs < 4) { printf("\n# El Numero es: %d | Su Cuadrado es: %d | Su Cubo es: %d", numrs, cuddo, cubo); if (numrs < 3) { printf(" #"); } else { printf(" #"); } } else if (numrs > 3 & numrs < 10) { printf("\n# El Numero es: %d | Su Cuadrado es: %d | Su Cubo es: %d", numrs, cuddo, cubo); if (numrs < 5) { printf(" #"); } else if (numrs > 4 & numrs < 10) { printf(" #"); } } else { printf("\n# El Numero es: %d | Su Cuadrado es: %d | Su Cubo es: %d", numrs, cuddo, cubo); if (numrs > 9 & numrs < 22) { printf(" #"); } else { printf(" #"); } } } printf("\n====================================================================\n\n----------------------------Fin Del Ciclo---------------------------\n\n"); getchar(); return (0); }
the_stack_data/225143460.c
#include <stdlib.h> #include <assert.h> #include <stdio.h> #include <stdint.h> #include <string.h> #include <unistd.h> static const char *testdata_hex = "aa001e7000012730bb4ce9731302011a020a080cff4c0010073f1f7d9e650118c648" "aa000b7004012730bb4ce97300c600" "aa002a7003018bb2d6e54a3c1f1eff060001092002c370885c7b74bfeb1523b70c1cdd8f6c0fc1f1d40464fbae31" "aa0029700001789c482c62611e0201061aff4c000c0e00844861db7a0681c1c8527e938610054a1cfade6dad8d" "aa00197000019f66173bf6740e0201060aff4c001005411c38492ba388" "aa0025700000c2b94a29e8181a02010611061745561073ed09a6b34e7ce552" "aa001d700400c2b94a29e8181209162a2518e8294ab9c107161820c0a8fe32ba6d" "aa002a700301b18b5a325b061f02011a03036ffd17166ffd037e630c6dc980d348892ff5a591d2c91ba49c91bc0b" "aa00117000011bfb7848e20806c29584481877bc40" "aa000b700401b0a729b9cb5c00a977" "aa000b700401c2958448187700a925" "aa00117000013858eb15735806789c482c6261b022" "aa0028700000bf8a7992bf701d02011a07030f180a18fffe11094a616272612045766f6c766520373565ab34" "aa0011700001e1b16801114b068b47b9c9c77eb2d6" "aa001c700001321b54f0d7441102011a020a0c0aff4c0010050318bcefc9a2e6" "aa00277002014a4e52d342601c03039ffe17169ffe02517a663344714c63775573000001797f7452e2a62e" "aa00157004014a4e52d342600a09ffe00006eaca7d3104a514" "aa0011700000a23595d0b69c06020102020a02b91f" "aa0018700400a23595d0b69c0d0c09736b6e2d6c6170746f7000b902" "aa001c700001bb511c0424611102011a020a0c0aff4c0010051b1c81ee0fa5b8" "aa0027700300b2f560a468381c1bff750042040180603868a460f5b23a68a460f5b101000000000000a30e" "aa002a7003010a3b6e7d97791f1eff060001092006d25714f5a92cbdf7a4f83366af" "aa002a700301c3cef39ce04a1f1eff060001092002b9e376356cb0e07a89b57fdc49b0ddbe226d1ff2c5e52fa1a6" "aa001c70000122b76024935b1102011a020a0c0aff4c0010051e18ed1b80a218"; static const unsigned char *hex2buf(const char *string) { if (string == NULL) return NULL; size_t slength = strlen(string); if ((slength % 2) != 0) // must be even return NULL; size_t dlength = slength / 2; uint8_t *data = malloc(dlength); memset(data, 0, dlength); size_t index = 0; while (index < slength) { char c = string[index]; int value = 0; if (c >= '0' && c <= '9') value = (c - '0'); else if (c >= 'A' && c <= 'F') value = (10 + (c - 'A')); else if (c >= 'a' && c <= 'f') value = (10 + (c - 'a')); else { free(data); return NULL; } data[(index / 2)] += value << (((index + 1) % 2) * 4); index++; } return data; } static int calc_checksum(const unsigned char *data, size_t length) { int checksum = 0; unsigned int i; for (i = 0; i < length; i++) { checksum += data[i]; } checksum = ~checksum; checksum += 1; return checksum & 0xff; } static int find_start(const unsigned char *data, size_t length) { unsigned int i; for (i = 0; i < length; i++) { if (data[i] == 0xAA) { return i; } } return -1; } static void print_advertising_report(const unsigned char *data, unsigned int length) { if (length < 5) { return; } int j; printf("MAC address: "); for (j = 0; j < 6; j++) { if (j == 5) printf("%02x", data[6 + j]); else printf("%02x:", data[6 + j]); } printf("\n"); } static int print_event(const unsigned char *data, size_t length) { int offset; int next_offset; unsigned int event_length; unsigned char event_chksum; unsigned char calc_chksum; assert(data); assert(length); // find start of next event offset = find_start(data, length); // consume data and wait for more if we can't find start if (offset == -1) { return length; } // calculate new length length = length - offset; // return if we don't have enough for the smallest event if (length < 5) { return offset; } // move data forward to start of event data = data + offset; // read 16bit big endianess event_length = (int)(data[1] << 8 | data[2]); // validate event_length if (event_length == 0) { // Skip to next event or consume length next_offset = find_start(data + 1, length - 1); if (next_offset == -1) { return offset + length; } return next_offset; } // not enough data wait for more if (event_length + 3 > length) { return offset; } // validate checksum event_chksum = data[offset + event_length + 3]; calc_chksum = calc_checksum(data + offset + 1, event_length + 2); if (event_chksum != calc_chksum) { // Skip to next event or consume length next_offset = find_start(data + 1, length - 1); if (next_offset == -1) { return offset + length; } return next_offset; } switch (data[3]) { case 0x70: print_advertising_report(data, length); break; } return offset + event_length + 4; } int main(void) { unsigned char buf[4096]; size_t length = 0; int testdata_offset = 0; int offset = 0; const unsigned char *testdata = hex2buf(testdata_hex); memset(buf, 0, 4096); printf("Start parsing\n"); while (1) { // simulate reading data memcpy(buf + offset, testdata + testdata_offset, 40); testdata_offset += 40; length += 40; printf("length %zu\n", length); // parse events in buffer offset = print_event(buf + offset, length); if (offset > 0) { // move to start of buf and zero rest memcpy(buf, buf + offset, length - offset); memset(buf + offset, 0, 4096 - offset); length -= offset; offset = 0; } sleep(1); } }
the_stack_data/15762185.c
// an example of output dependence preventing parallelization // loop carried vs. non-loop carried output dependence! #include "omp.h" void foo() { int i; int x; int y; #pragma omp parallel for private (x,y,i) for (i = 0; i <= 99; i += 1) { x = i; y = i; y = i + 1; } } /* output dependence carryLevel should be 0? carry level is wrong!! dep SgExprStatement:x = i; SgExprStatement:x = i; 1*1 SCALAR_DEP; commonlevel = 1 CarryLevel = 1 SgVarRefExp:x@8:6->SgVarRefExp:x@8:6 == 0;||:: output dependence carryLevel should be 0? carry level is wrong!! dep SgExprStatement:y = i; SgExprStatement:y = i; 1*1 SCALAR_DEP; commonlevel = 1 CarryLevel = 1 SgVarRefExp:y@9:6->SgVarRefExp:y@9:6 == 0;||:: output dependence carryLevel should be 0? carry level is wrong!! dep SgExprStatement:y =(i + 1); SgExprStatement:y =(i + 1); 1*1 SCALAR_DEP; commonlevel = 1 CarryLevel = 1 SgVarRefExp:y@10:6->SgVarRefExp:y@10:6 == 0;||:: //-------------- output dependence: non-loop carried, level =1 is correct dep SgExprStatement:y = i; SgExprStatement:y =(i + 1); 1*1 SCALAR_DEP; commonlevel = 1 CarryLevel = 1 SgVarRefExp:y@9:6->SgVarRefExp:y@10:6 == 0;||:: output dependence: Carry level =0 means loop carried, also look at line number: 10>9 dep SgExprStatement:y =(i + 1); SgExprStatement:y = i; 1*1 SCALAR_BACK_DEP; commonlevel = 1 CarryLevel = 0 SgVarRefExp:y@10:6->SgVarRefExp:y@9:6 <= -1;||:: */
the_stack_data/135858.c
/* main.c * * show device list and info * reference: * http://dhruba.name/2012/08/14/opencl-cookbook-listing-all-devices-and-their-critical-attributes/sho */ #include <stdio.h> #include <stdlib.h> #ifdef __APPLE__ #include <OpenCL/opencl.h> #else #include <CL/cl.h> #endif #ifdef AOCL #include "CL/opencl.h" #include "AOCLUtils/aocl_utils.h" using namespace aocl_utils; void cleanup(); #endif int main() { int i, j; char* value; size_t valueSize; cl_uint platformCount; cl_platform_id* platforms; cl_uint deviceCount; cl_device_id* devices; cl_uint maxComputeUnits, maxAddressBits, clock_freq, maxDimen; cl_ulong globalMemSize, localMemSize; size_t maxWorkItemSizes[3], maxWorkGroupSize; // get all platforms clGetPlatformIDs(0, NULL, &platformCount); platforms = (cl_platform_id*) malloc(sizeof(cl_platform_id) * platformCount); clGetPlatformIDs(platformCount, platforms, NULL); for (i = 0; i < platformCount; i++) { // get all devices clGetDeviceIDs(platforms[i], CL_DEVICE_TYPE_ALL, 0, NULL, &deviceCount); devices = (cl_device_id*) malloc(sizeof(cl_device_id) * deviceCount); clGetDeviceIDs(platforms[i], CL_DEVICE_TYPE_ALL, deviceCount, devices, NULL); // for each device print critical attributes for (j = 0; j < deviceCount; j++) { // print device name clGetDeviceInfo(devices[j], CL_DEVICE_NAME, 0, NULL, &valueSize); value = (char*) malloc(valueSize); clGetDeviceInfo(devices[j], CL_DEVICE_NAME, valueSize, value, NULL); printf("%d. Device: %s\n", j+1, value); free(value); // print hardware device version clGetDeviceInfo(devices[j], CL_DEVICE_VERSION, 0, NULL, &valueSize); value = (char*) malloc(valueSize); clGetDeviceInfo(devices[j], CL_DEVICE_VERSION, valueSize, value, NULL); printf(" %d.%d Hardware version: %s\n", j+1, 1, value); free(value); // print software driver version clGetDeviceInfo(devices[j], CL_DRIVER_VERSION, 0, NULL, &valueSize); value = (char*) malloc(valueSize); clGetDeviceInfo(devices[j], CL_DRIVER_VERSION, valueSize, value, NULL); printf(" %d.%d Software version: %s\n", j+1, 2, value); free(value); // print c version supported by compiler for device clGetDeviceInfo(devices[j], CL_DEVICE_OPENCL_C_VERSION, 0, NULL, &valueSize); value = (char*) malloc(valueSize); clGetDeviceInfo(devices[j], CL_DEVICE_OPENCL_C_VERSION, valueSize, value, NULL); printf(" %d.%d OpenCL C version: %s\n", j+1, 3, value); free(value); // print parallel compute units clGetDeviceInfo(devices[j], CL_DEVICE_MAX_COMPUTE_UNITS, sizeof(maxComputeUnits), &maxComputeUnits, NULL); printf(" %d.%d Parallel compute units: %d\n", j+1, 4, maxComputeUnits); // print address bits clGetDeviceInfo(devices[j], CL_DEVICE_ADDRESS_BITS, sizeof(maxAddressBits), &maxAddressBits, NULL); printf(" %d.%d Address Bits: %d\n", j+1, 5, maxAddressBits); // print global memory size clGetDeviceInfo(devices[j], CL_DEVICE_GLOBAL_MEM_SIZE, sizeof(globalMemSize), &globalMemSize, NULL); printf(" %d.%d Global Memory Size: %lu\n", j+1, 6, globalMemSize); // print local memory size clGetDeviceInfo(devices[j], CL_DEVICE_LOCAL_MEM_SIZE, sizeof(localMemSize), &localMemSize, NULL); printf(" %d.%d Local Memory Size: %lu\n", j+1, 7, localMemSize); // print max clock frequency clGetDeviceInfo(devices[j], CL_DEVICE_MAX_CLOCK_FREQUENCY, sizeof(clock_freq), &clock_freq, NULL); printf(" %d.%d Max Clock Frequency: %d MHz\n", j+1, 8, clock_freq); // print max work item dimensions clGetDeviceInfo(devices[j], CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, sizeof(maxDimen), &maxDimen, NULL); printf(" %d.%d Max Work Item Dimension: %d\n", j+1, 9, maxDimen); // print max work group size clGetDeviceInfo(devices[j], CL_DEVICE_MAX_WORK_GROUP_SIZE, sizeof(maxWorkGroupSize), &maxWorkGroupSize, NULL); printf(" %d.%d Max Work Group Size: %lu\n", j+1, 10, maxWorkGroupSize); // print max work item sizes clGetDeviceInfo(devices[j], CL_DEVICE_MAX_WORK_ITEM_SIZES, sizeof(size_t)*maxDimen, maxWorkItemSizes, NULL); printf(" %d.%d Max Work Item Sizes: [%lu,%lu,%lu] \n", j+1, 11, maxWorkItemSizes[0],maxWorkItemSizes[1],maxWorkItemSizes[2]); } free(devices); } free(platforms); return 0; } #ifdef AOCL // Altera OpenCL needs this callback function implemented in main.c // Free the resources allocated during initialization void cleanup() { } #endif
the_stack_data/54423.c
// This program actually still works without including stdio.h but it should be // here for consistency. #include <stdio.h> #include <string.h> #include <assert.h> #define START_TEST(t) \ printf("\n--- %s\n", #t); \ test_##t(); void test_putchar() { char c; for (c = 'A'; c <= 'Z'; c++) putchar(c); } void test_puts() { puts("c2go"); } void test_printf() { // TODO: printf() has a different syntax to Go // https://github.com/elliotchance/c2go/issues/94 printf("Characters: %c %c \n", 'a', 65); //printf("Decimals: %d %ld\n", 1977, 650000L); printf("Preceding with blanks: %10d \n", 1977); printf("Preceding with zeros: %010d \n", 1977); printf("Some different radices: %d %x %o %#x %#o \n", 100, 100, 100, 100, 100); printf("floats: %4.2f %+.0e %E \n", 3.1416, 3.1416, 3.1416); printf("Width trick: %*d \n", 5, 10); printf("%s \n", "A string"); } void test_remove() { // TODO: This does not actually test successfully deleting a file. if (remove("myfile.txt") != 0) puts("Error deleting file"); else puts("File successfully deleted"); } void test_rename() { // TODO: This does not actually test successfully renaming a file. int result; char oldname[] = "oldname.txt"; char newname[] = "newname.txt"; result = rename(oldname, newname); if (result == 0) puts("File successfully renamed"); else puts("Error renaming file"); } void test_fopen() { FILE *pFile; pFile = fopen("/tmp/myfile.txt", "w"); if (pFile != NULL) { fputs("fopen example", pFile); fclose(pFile); } } void test_tmpfile() { char buffer[256]; FILE *pFile; pFile = tmpfile(); fputs("hello world", pFile); rewind(pFile); fputs(fgets(buffer, 256, pFile), stdout); fclose(pFile); } void test_tmpnam() { // TODO: This is a tricky one to test because the output of tmpnam() in C // and Go will be different. I will keep the test here so at least it tries // to run the code but the test itself is not actually proving anything. char *pointer; // FIXME: We cannot pass variables by reference yet, which is a legitimate // way to use tmpnam(). I have to leave this disabled for now. // // char buffer[L_tmpnam]; // tmpnam(buffer); // assert(buffer != NULL); pointer = tmpnam(NULL); assert(pointer != NULL); } void test_fclose() { FILE *pFile; pFile = fopen("/tmp/myfile.txt", "w"); fputs("fclose example", pFile); fclose(pFile); } void test_fflush() { char mybuffer[80]; FILE *pFile; pFile = fopen("example.txt", "r+"); if (pFile == NULL) printf("Error opening file"); else { fputs("test", pFile); fflush(pFile); // flushing or repositioning required fgets(mybuffer, 80, pFile); puts(mybuffer); fclose(pFile); } } void test_fprintf() { FILE *pFile; int n; char *name = "John Smith"; pFile = fopen("/tmp/myfile1.txt", "w"); assert(pFile != NULL); for (n = 0; n < 3; n++) { fprintf(pFile, "Name %d [%-10.10s]\n", n + 1, name); } fclose(pFile); } void test_fscanf() { char str[80]; float f; FILE *pFile; pFile = fopen("/tmp/myfile2.txt", "w+"); fprintf(pFile, "%f %s", 3.1416, "PI"); rewind(pFile); fscanf(pFile, "%f", &f); fscanf(pFile, "%s", str); fclose(pFile); printf("I have read: %f and %s \n", f, str); } void test_scanf() { int i; scanf("%d", &i); printf("You enetered: %d\n", i); } void test_fgetc() { FILE *pFile; int c; int n = 0; pFile = fopen("tests/stdio.c", "r"); if (pFile == NULL) printf("Error opening file"); else { do { c = fgetc(pFile); if (c == '$') n++; } while (c != EOF); fclose(pFile); printf("The file contains %d dollar sign characters ($).\n", n); } } void test_fgets() { FILE *pFile; char *mystring; char dummy[20]; pFile = fopen("tests/stdio.c", "r"); if (pFile == NULL) printf("Error opening file"); else { mystring = fgets(dummy, 20, pFile); if (mystring != NULL) puts(mystring); fclose(pFile); } } void test_fputc() { char c; for (c = 'A'; c <= 'Z'; c++) fputc(c, stdout); } void test_fputs() { FILE *pFile; char *sentence = "Hello, World"; pFile = fopen("/tmp/mylog.txt", "w"); fputs(sentence, pFile); fclose(pFile); } void test_getc() { FILE *pFile; int c; int n = 0; pFile = fopen("tests/stdio.c", "r"); if (pFile == NULL) printf("Error opening file"); else { do { c = getc(pFile); if (c == '$') n++; } while (c != EOF); fclose(pFile); printf("File contains %d$.\n", n); } } void test_putc() { FILE *pFile; char c; pFile = fopen("/tmp/whatever.txt", "w"); for (c = 'A'; c <= 'Z'; c++) { putc(c, pFile); } fclose(pFile); } void test_fseek() { FILE *pFile; pFile = fopen("/tmp/example.txt", "w"); fputs("This is an apple.", pFile); fseek(pFile, 9, SEEK_SET); fputs(" sam", pFile); fclose(pFile); } void test_ftell() { FILE *pFile; long size; pFile = fopen("tests/stdio.c", "r"); if (pFile == NULL) printf("Error opening file"); else { fseek(pFile, 0, SEEK_END); // non-portable size = ftell(pFile); fclose(pFile); printf("Size of myfile.txt: %d bytes.\n", size); } } void test_fread() { FILE *pFile; int lSize; char buffer[1024]; int result; pFile = fopen("tests/getchar.c", "r"); if (pFile == NULL) { fputs("File error", stderr); return; } // obtain file size: fseek(pFile, 0, SEEK_END); lSize = ftell(pFile); printf("lSize = %d\n", lSize); rewind(pFile); // copy the file into the buffer: result = fread(buffer, 1, lSize, pFile); if (result != lSize) { fputs("Reading error", stderr); return; } // See issue #107 buffer[lSize - 1] = 0; printf("%s", buffer); /* the whole file is now loaded in the memory buffer. */ // terminate fclose(pFile); } void test_fwrite() { FILE *pFile; // char *buffer = ; pFile = fopen("/tmp/myfile.bin", "w"); fwrite("xyz", 1, 3, pFile); fclose(pFile); } void test_fgetpos() { FILE *pFile; int c; int n; fpos_t pos; pFile = fopen("tests/stdio.c", "r"); if (pFile == NULL) printf("Error opening file"); else { c = fgetc(pFile); printf("1st character is %c\n", c); fgetpos(pFile, &pos); for (n = 0; n < 3; n++) { fsetpos(pFile, &pos); c = fgetc(pFile); printf("2nd character is %c\n", c); } fclose(pFile); } } void test_fsetpos() { FILE *pFile; fpos_t position; pFile = fopen("/tmp/myfile.txt", "w"); fgetpos(pFile, &position); fputs("That is a sample", pFile); fsetpos(pFile, &position); fputs("This", pFile); fclose(pFile); } void test_rewind() { int n; FILE *pFile; char buffer[27]; pFile = fopen("/tmp/myfile.txt", "w+"); for (n = 'A'; n <= 'Z'; n++) fputc(n, pFile); rewind(pFile); fread(buffer, 1, 26, pFile); fclose(pFile); buffer[26] = '\0'; puts(buffer); } void test_feof() { FILE *pFile; int n = 0; pFile = fopen("tests/stdio.c", "r"); if (pFile == NULL) printf("Error opening file"); else { while (fgetc(pFile) != EOF) { ++n; } if (feof(pFile)) { puts("End-of-File reached."); printf("Total number of bytes read: %d\n", n); } else puts("End-of-File was not reached."); fclose(pFile); } } int main() { START_TEST(putchar) START_TEST(puts) START_TEST(printf) START_TEST(remove) START_TEST(rename) START_TEST(fopen) START_TEST(tmpfile) START_TEST(tmpnam) START_TEST(fclose) START_TEST(fflush) START_TEST(printf) START_TEST(fprintf) START_TEST(fscanf) START_TEST(scanf) START_TEST(fgetc) START_TEST(fgets) START_TEST(fputc) START_TEST(fputs) START_TEST(getc) START_TEST(putc) START_TEST(fseek) START_TEST(ftell) START_TEST(fread) START_TEST(fwrite) START_TEST(fgetpos) START_TEST(fsetpos) START_TEST(rewind) START_TEST(feof) return 0; }
the_stack_data/218892171.c
/* Hashtable, K&R ch. 6 */ #include <stdio.h> #include <stdlib.h> #include <string.h> struct nlist { struct nlist *next; char *name; char *defn; }; #define HASHSIZE 101 static struct nlist *hashtab[HASHSIZE]; unsigned hash(char *); struct nlist *lookup(char *); struct nlist *install(char *, char *); void show_table(void); int main(void) { install("Dutch", "hallo"); install("English", "hello"); install("French", "bonjour"); install("German", "gutentag"); show_table(); return 0; } unsigned hash(char *s) { unsigned hashval; for (hashval = 0; *s != '\0'; s++) { hashval = *s + 33 * hashval; } return hashval % HASHSIZE; } struct nlist *lookup(char *s) { struct nlist *np; for (np = hashtab[hash(s)]; np != NULL; np = np->next) { if (strcmp(s, np->name) == 0) { return np; } return NULL; } } struct nlist *install(char *name, char *defn) { struct nlist *np; unsigned hashval; if ((np = lookup(name)) == NULL) { np = malloc(sizeof(struct nlist)); if (np == NULL || (np->name = strdup(name)) == NULL) { return NULL; } hashval = hash(name); np->next = hashtab[hashval]; hashtab[hashval] = np; } else { free(np->defn); } if ((np->defn = strdup(defn)) == NULL) { return NULL; } return np; } void show_table(void) { struct nlist *np; for (int i = 0; i < HASHSIZE; i++) { if (hashtab[i]) { for (np = hashtab[i]; np != NULL; np=np->next) { printf("\t%-10s\t%-10s\n", hashtab[i]->name, hashtab[i]->defn); } } } }
the_stack_data/73365.c
// SPDX-License-Identifier: BSD-2-Clause /* Copyright 2012 Bernard Parent Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifdef DISTMPI #include <mpi.h> #endif #include <stdlib.h> #include <stdio.h> int main ( int argc, char **argv ) { #ifdef DISTMPI // Initialize the MPI environment MPI_Init ( NULL, NULL ); // Get the number of processes int world_size; MPI_Comm_size ( MPI_COMM_WORLD, &world_size ); // Get the rank of the process int world_rank; MPI_Comm_rank ( MPI_COMM_WORLD, &world_rank ); // Get the name of the processor char processor_name[MPI_MAX_PROCESSOR_NAME]; int name_len; MPI_Get_processor_name ( processor_name, &name_len ); // Print off a hello world message printf ( "Hello world from processor %s, rank %d" " out of %d processors\n", processor_name, world_rank, world_size ); // Finalize the MPI environment. MPI_Finalize ( ); #endif return ( EXIT_SUCCESS ); }
the_stack_data/45449837.c
/* This testcase is part of GDB, the GNU debugger. Copyright 2015-2016 Free Software Foundation, Inc. This program 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 of the License, or (at your option) any later version. This program 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. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <stdlib.h> int varint = 10; int vararray[] = { 1, 2, 3, 4, 5 }; int *vararrayp = vararray; struct object { int field; } varobject = { 1 }; int main (void) { return 0; }
the_stack_data/93623.c
/*BEGIN_LEGAL Intel Open Source License Copyright (c) 2002-2012 Intel Corporation. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the Intel Corporation nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR ITS 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. END_LEGAL */ #include <stdio.h> #include <stdlib.h> #if !defined(TARGET_WINDOWS) #define EXPORT_SYM extern #else //defined(TARGET_WINDOWS) #include <windows.h> // declare all functions as exported so pin can find them, // must be all functions since only way to find end of one function is the begining of the next // Another way is to compile application with debug info (Zi) - pdb file, but that causes probelms // in the running of the script #define EXPORT_SYM __declspec( dllexport ) #endif extern void SetAppFlags_asm(unsigned int val); extern void ClearAcFlag_asm(); extern int GetFlags_asm(); int main() { unsigned int flags; SetAppFlags_asm(0x40000); flags = GetFlags_asm(); ClearAcFlag_asm(); if((GetFlags_asm()&0x40000)!=0) { exit (0); } SetAppFlags_asm(0x40000); flags = GetFlags_asm(); ClearAcFlag_asm(); printf ("SUCCESS\n"); exit (0); }
the_stack_data/156394429.c
#include <stdio.h> int main() { printf("Hello, World!"); return 0; }
the_stack_data/36074506.c
#include <sys/file.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <fcntl.h> #include <errno.h> #include <stdio.h> #include <string.h> #include <stdarg.h> #include <stdlib.h> static int cp(const char *to, const char *from) { int fd_to = -1, fd_from = -1; ssize_t nread; int saved_errno; const int buf_size = 4096 * 64; char * buf = NULL; fd_from = open(from, O_RDONLY); if (fd_from < 0) return -1; buf = malloc(buf_size); if (!buf) goto out_error; fd_to = open(to, O_WRONLY | O_CREAT | O_EXCL, 0666); if (fd_to < 0) goto out_error; while (nread = read(fd_from, buf, buf_size), nread > 0) { char *out_ptr = buf; ssize_t nwritten; do { nwritten = write(fd_to, out_ptr, nread); if (nwritten >= 0) { nread -= nwritten; out_ptr += nwritten; } else if (errno != EINTR) { goto out_error; } } while (nread > 0); } if (nread == 0) { if (close(fd_to) < 0) { fd_to = -1; goto out_error; } close(fd_from); free(buf); /* Success! */ return 0; } out_error: saved_errno = errno; close(fd_from); if (fd_to >= 0) close(fd_to); if (buf) free(buf); errno = saved_errno; return -1; } static const char * progname = "afilecache"; static void perrorf(const char * format, ...) { char buf[512]; va_list ap; va_start(ap, format); memset(buf, 0, 512); vsnprintf(buf, 500, format, ap); va_end(ap); perror(buf); } typedef struct _str_buffer_t { char * str; size_t size; size_t len; } str_buffer_t; static void str_buffer_extend(str_buffer_t * buffer, size_t inc_len) { size_t new_len = buffer->len + inc_len; if (new_len < buffer->len) { fprintf(stderr, "%s: Internal error: new_len overflow (%zu + %zu -> %zu)\n", progname, buffer->len, inc_len, new_len); abort(); } if (buffer->size > 1 && new_len < buffer->size - 1) return; buffer->size = new_len + 16 + new_len / 2; buffer->str = realloc(buffer->str, buffer->size); if (!buffer->str) { fprintf(stderr, "%s: Internal error: failed to allocate %zu bytes\n", progname, buffer->size); abort(); } } static void str_buffer_join(str_buffer_t * buffer, const char * str) { if (!str) return; size_t str_len = strlen(str); str_buffer_extend(buffer, str_len); memcpy(buffer->str + buffer->len, str, str_len); buffer->len += str_len; buffer->str[buffer->len] = 0; } static void str_buffer_join_char(str_buffer_t * buffer, char ch) { str_buffer_extend(buffer, 1); buffer->str[buffer->len++] = ch; buffer->str[buffer->len] = 0; } static char * str_join_path(const char * arg, ...) { if (!arg) return NULL; str_buffer_t buffer = {0, 0, 0}; str_buffer_join(&buffer, arg); va_list ap; va_start(ap, arg); while (1) { const char * s = va_arg(ap, const char *); if (!s) break; if ((buffer.len == 0 || buffer.str[buffer.len - 1] != '/') && s[0] != '/') str_buffer_join(&buffer, "/"); str_buffer_join(&buffer, s); } va_end(ap); return buffer.str; } enum RETCODES { RET_USAGE = 1, RET_MISS = 2, RET_INTERNAL = 3, RET_NO_CACHE_DIR = 4, RET_FILE_OPS = 5, RET_LOCK = 6 }; static char * encode_id(const char * id) { if (!id) return NULL; str_buffer_t buffer = {0, 0, 0}; str_buffer_extend(&buffer, strlen(id)); char esc[10]; while (*id) { char ch = *id; if (ch < ' ' || ch == '*' || ch == '?' || ch == '/' || ch == '\\' || ch == '"' || ch == '\'' || ch == '%') { snprintf(esc, 5, "%%%u", (unsigned)ch); str_buffer_join(&buffer, esc); } else { str_buffer_join_char(&buffer, ch); } id++; } return buffer.str; } static char * get_subdir_for_id(const char * id) { unsigned base = ('z' - 'a'); unsigned long s = 0; while (*id) { unsigned char ch = (unsigned char) *id; unsigned char s1 = (unsigned char) (s >> 24); s = (s << 8) + (ch ^ s1); id++; } char buf[10]; int i; for (i = 0; i < 4; i++) { buf[i] = (s % base) + 'a'; s /= base; } buf[i] = 0; return strdup(buf); } typedef struct _cache_entry_path_t { char * dirname; char * filename; char * relpath; char * fullpath; char * dirfullpath; } cache_entry_path_t; static void cache_id_to_path(const char * cache_path, const char * cache_id, cache_entry_path_t * cache_entry_path) { cache_entry_path->filename = encode_id(cache_id); cache_entry_path->dirname = get_subdir_for_id(cache_id); cache_entry_path->relpath = str_join_path(cache_entry_path->dirname, cache_entry_path->filename, 0); cache_entry_path->fullpath = str_join_path(cache_path, cache_entry_path->relpath, 0); cache_entry_path->dirfullpath = str_join_path(cache_path, cache_entry_path->dirname, 0); } static int command_put(const char * cache_path, const char * cache_id, const char * source_file_path) { cache_entry_path_t cache_entry_path; cache_id_to_path(cache_path, cache_id, &cache_entry_path); struct stat stat_buf; if (stat(cache_entry_path.dirfullpath, &stat_buf) < 0) { if (mkdir(cache_entry_path.dirfullpath, 0777) < 0) { perrorf("%s: failed to create directory %s", progname, cache_entry_path.dirfullpath); return RET_FILE_OPS; } } else if (!S_ISDIR(stat_buf.st_mode)) { fprintf(stderr, "%s: %s: Not a directory\n", progname, cache_entry_path.dirfullpath); return RET_FILE_OPS; } char * tmpfilename = str_join_path(cache_entry_path.dirfullpath, ".?tmpfile", 0); if ((unlink(tmpfilename) < 0) && errno != ENOENT) { perrorf("%s: failed to unlink %s", progname, tmpfilename); return RET_FILE_OPS; } if (cp(tmpfilename, source_file_path) < 0) { perrorf("%s: failed to copy %s", progname, source_file_path); return RET_FILE_OPS; } if (rename(tmpfilename, cache_entry_path.fullpath) < 0) { perrorf("%s: failed to rename %s", progname, tmpfilename); return RET_FILE_OPS; } return 0; } static int command_get(const char * cache_path, const char * cache_id, const char * source_file_path) { cache_entry_path_t cache_entry_path; cache_id_to_path(cache_path, cache_id, &cache_entry_path); struct stat stat_buf; if (stat(cache_entry_path.fullpath, &stat_buf) < 0) { return RET_MISS; } if ((unlink(source_file_path) < 0) && errno != ENOENT) { perrorf("%s: failed to unlink %s", progname, source_file_path); return RET_FILE_OPS; } if (cp(source_file_path, cache_entry_path.fullpath) < 0) { perrorf("%s: failed to copy %s", progname, cache_entry_path.fullpath); unlink(source_file_path); return RET_FILE_OPS; } return 0; } static int command_delete(const char * cache_path, const char * cache_id) { cache_entry_path_t cache_entry_path; cache_id_to_path(cache_path, cache_id, &cache_entry_path); if ((unlink(cache_entry_path.fullpath) < 0)) { if (errno == ENOENT) return RET_MISS; perrorf("%s: failed to unlink %s", progname, cache_entry_path.fullpath); return RET_FILE_OPS; } return 0; } static int command_clean(const char * cache_path, int max_size_mb) { /* TODO: implement me! */ (void)(cache_path); (void)(max_size_mb); fprintf(stderr, "%s: Not implemented\n", progname); return RET_INTERNAL; } #define TOSTR(s) #s const char * USAGE = "Version 0.1.1\n" "Usage:\n" " afilecache <cache directory> put <ID> <file path>\n" " afilecache <cache directory> get <ID> <file path>\n" " afilecache <cache directory> delete <ID>\n" /*"\tafilecache <cache directory> clean <max size in MB>\n" XXX: NOT IMPLEMENTED*/ "\n" "afilecache is a utility to atomically put files in a cache directory.\n" "\n" "When running, afilecache acquires a lock on <cache directory>/.lock,\n" "so no race condition between simultaneously running instances of the\n" "program are possible.\n" "\n" "COMMANDS\n" " afilecache <cache directory> put <ID> <file path>\n" " Put a file located at <file path> into a <cache directory> with an\n" " identifier <ID>.\n" "\n" " afilecache <cache directory> get <ID> <file path>\n" " Look up a file identified by <ID> in a <cache directory> and copy it\n" " to <file path>.\n" " If <ID> is missing in the cache, afilecache exits with code 2.\n" " Before copying the file to <file path>, afilecache unlinks <file path>.\n" " If copying has failed, afilecache tries to unlink partially copied file\n" " at <file path> too.\n" "\n" " afilecache <cache directory> delete <ID>\n" " Delete a file identified by <ID> from a <cache directory>.\n" " If <ID> is missing in the cache, exits with code 2.\n" "\n" "EXIT CODES\n" " 0 operation completed successfully\n" " 1 invalid command line arguments\n" " 2 missing <ID>\n" " 3 internal error\n" " 4 <cache directory> not found or not a directory\n" " 5 file operation failed\n" " 6 lock failed\n" "\n" "BUGS\n" " Please report bugs at <[email protected]>.\n" "\n" "Copyright 2014-2017 Vadim Ushakov <[email protected]>\n" "\n" "Permission is hereby granted, free of charge, to any person obtaining a \n" "copy of this software and associated documentation files (the \"Software\"), \n" "to deal in the Software without restriction, including without limitation \n" "the rights to use, copy, modify, merge, publish, distribute, sublicense, \n" "and/or sell copies of the Software, and to permit persons to whom the \n" "Software is furnished to do so, subject to the following conditions:\n" "\n" "The above copyright notice and this permission notice shall be included in \n" "all copies or substantial portions of the Software.\n" "\n" "THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR \n" "IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, \n" "FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL \n" "THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER \n" "LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING \n" "FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER \n" "DEALINGS IN THE SOFTWARE.\n" "\n" ; static void usage(void) { fprintf(stderr, USAGE); } #define USAGE_CHECK(check) \ if (!(check)) { \ usage(); \ return RET_USAGE; \ } int main(int argc, char **argv) { const char * cache_path; const char * command; const char * source_file_path = NULL; const char * cache_id = NULL; int max_size_mb = 0; progname = argv[0]; USAGE_CHECK(argc >= 3) cache_path = argv[1]; command = argv[2]; USAGE_CHECK(*cache_path && *command) if (strcmp(command, "put") == 0 || strcmp(command, "get") == 0) { USAGE_CHECK(argc == 5) cache_id = argv[3]; source_file_path = argv[4]; USAGE_CHECK(*source_file_path && *cache_id) } else if (strcmp(command, "delete") == 0) { USAGE_CHECK(argc == 4) cache_id = argv[3]; USAGE_CHECK(*cache_id) } else if (strcmp(command, "clean") == 0) { USAGE_CHECK(argc == 4) max_size_mb = atoi(argv[4]); } else { USAGE_CHECK(0) } struct stat stat_buf; if (stat(cache_path, &stat_buf) != 0) { perrorf("%s: %s", progname, cache_path); return RET_NO_CACHE_DIR; } if (!S_ISDIR(stat_buf.st_mode)) { fprintf(stderr, "%s: %s: Not a directory\n", progname, cache_path); return RET_NO_CACHE_DIR; } char * lock_path = str_join_path(cache_path, ".lock", 0); int lock_fd = open(lock_path, O_WRONLY | O_APPEND | O_CREAT, 0666); if (lock_fd < 0) { perrorf("%s: failed to open %s", progname, lock_path); return RET_FILE_OPS; } if (flock(lock_fd, LOCK_EX) < 0) { perrorf("%s: failed to lock %s", progname, lock_path); return RET_LOCK; } if (strcmp(command, "put") == 0) { return command_put(cache_path, cache_id, source_file_path); } else if (strcmp(command, "get") == 0) { return command_get(cache_path, cache_id, source_file_path); } else if (strcmp(command, "delete") == 0) { return command_delete(cache_path, cache_id); } else if (strcmp(command, "clean") == 0) { return command_clean(cache_path, max_size_mb); } /* NOT REACHED */ return RET_INTERNAL; }
the_stack_data/98575371.c
#include <stdio.h> #include <getopt.h> #include <stdlib.h> #include <time.h> #include <math.h> #include <string.h> /* Marcello Cierro Assignent #1-B Due Friday Sept. 23 2016 This program will generate a sequence of random nubmers provided with command line options to specify the numbers to produce as well as the range into which they fall into(default is set to 10 number which range from 1 to 100) Uses "getopt" for command-line options User input involves the amount of numbers to be generated, n, the lowerbound for the numbers generated, l, and the upperbound for the numbers generated, u. Errors found will be handled with an error message, errors occur if user enters no input. The data taken in include; user variables, options, random number generator, and opt out. Code reference from Odendahl http://cs.oswego.edu/~odendahl/coursework/csc344/notes/c/getopt/b/main.c */ // Formula to calculate lower bounds and upperbounds int rng (int l, int u){ return (rand() % (u+1 - l) + l); } int main(int argc, char *argv[]) { // default case for random number generator int n = 10; int l = 1; int u = 100; //uses internal clock to seed random number generator srand (time(NULL)); int c = 0; //provides options char *options = ":n:l:u:"; //while loop to start collecting user options while ((c = getopt(argc,argv,options)) != -1) { //prompts user to put correct input, catching any erros made through error messaging if (c == '?') { c = optopt; printf("Error %c\n",c); } else if (c == ':') { c = optopt; printf("Please enter the missing value %c\n",c); } else { //case switches for command line inputs switch (c) { case 'n': n = atoi(optarg); // reads user input break; //stops case to start next case case 'l': l = atoi(optarg);// see above " " break; // see above " " case 'u': u = atoi(optarg); // " " break;// " " } } } // for loop printing n numbers b/c n inputed by the user for (int i = 0; i < n; ++i){ printf("%d\n", rng(l, u)); } return 0; //exit case, when the program runs sucessfully, since main is of type int. }
the_stack_data/805291.c
// For loop example // Converts temperatures in Celsius to Fahrenheit #include <stdio.h> int main(void) { double fahr, celsius; int lower = 0; int upper = 100; int step = 10; printf("C F\n\n"); for (celsius = lower; celsius <= upper; celsius += step) { fahr = (9.0/5.0) * celsius + 32.0; printf("%3.0f %6.1f\n", celsius, fahr); } return 0; }
the_stack_data/28263346.c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* nested_structs_3.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: lpaulo-m <[email protected]> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/03/07 22:42:27 by lpaulo-m #+# #+# */ /* Updated: 2021/03/07 22:42:44 by lpaulo-m ### ########.fr */ /* */ /* ************************************************************************** */ /* Program to display Nested Structures in C Programming */ #include <stdio.h> #include <string.h> struct address { int Door_Number; char City[20]; }; struct Employee { int Age; char Name[50]; struct address add; float Salary; } * emp3; int main() { struct Employee emp1 = {25, "Tutorial", 222, "Liverpool", 25000.50}; struct Employee emp2; emp2.Age = 28; strcpy(emp2.Name, "Gateway"); emp2.add.Door_Number = 145; strcpy(emp2.add.City, "Manchester"); emp2.Salary = 45000.00; emp3 = &emp2; printf("\n Details of the Employee 1 \n "); printf(" Employee Age = %d \n ", emp1.Age); printf(" Employee Name = %s \n ", emp1.Name); printf(" Employee Door Number = %d \n ", emp1.add.Door_Number); printf(" Employee City = %s \n ", emp1.add.City); printf(" Employee Salary = %.2f \n\n ", emp1.Salary); printf(" Details of the Employee 2 \n "); printf(" Employee Age = %d \n ", emp3->Age); printf(" Employee Name = %s \n ", emp3->Name); printf(" Employee Door Number = %d \n ", emp3->add.Door_Number); printf(" Employee City = %s \n ", emp3->add.City); printf(" Employee Salary = %.2f \n ", emp3->Salary); return 0; }
the_stack_data/14200092.c
#include <stdio.h> main() { int c, nl; nl = 0; while ((c = getchar()) != EOF) if (c == '\n') ++nl; printf("%d\n", nl); }
the_stack_data/56970.c
#include <stdio.h> void swap(int *xp, int *yp) { int temp = *xp; *xp = *yp; *yp = temp; } int main() { int x; int y; printf("Pass x:\n"); scanf("%d", &x); printf("Pass y:\n"); scanf("%d", &y); swap(&x, &y); printf("x = %d, y = %d", x, y); return 0; }
the_stack_data/103264229.c
extern void __VERIFIER_error() __attribute__ ((__noreturn__)); void __VERIFIER_assert(int cond) { if(!(cond)) { ERROR: __VERIFIER_error(); } } #define N 25 int main( ) { int a[ N ]; int i = 0; int x; int y; while ( i < N ) { int k = i + 1; int s = i; while ( k < N ) { if ( a[k] < a[s] ) { s = k; } k = k+1; } if ( s != i ) { int tmp = a[s]; a[s] = a[i]; a[i] = tmp; } for ( x = 0 ; x < i ; x++ ) { for ( y = x + 1 ; y < i ; y++ ) { __VERIFIER_assert( a[x] <= a[y] ); } } for ( x = 0 ; x < N ; x++ ) { __VERIFIER_assert( a[x] >= a[i] ); } i = i+1; } for ( x = 0 ; x < N ; x++ ) { for ( y = x + 1 ; y < N ; y++ ) { __VERIFIER_assert( a[x] <= a[y] ); } } return 0; }
the_stack_data/206393936.c
#include <stdio.h> /* Read the time (in seconds) and distance (in km) covered by a moving object, calculate the speed in km/s and display the speed on the screen. */ int main() { float distance, time; printf("Enter distance (in km):"); scanf("%f", &distance); printf("Enter time (in sec):"); scanf("%f", &time); float speed = distance / time; printf("The speed is %.2f km/sec", speed); return 0; }
the_stack_data/759837.c
#include <stdio.h> #include <math.h> /* int N = 10; */ int N = 100; int main() { printf("%d\n", (int)pow((N * (N + 1) / 2), 2) - N * (N + 1) * (2 * N + 1) / 6); return 0; }
the_stack_data/591561.c
int main() { static int a = 3; return a; }
the_stack_data/804119.c
#include <stdio.h> int main(void) { int T; scanf("%d", &T); for(int i=0;i<T;i++) { int a, b; scanf("%d %d", &a, &b); int cs[20]; if(a%10==0) { printf("10\n"); goto A; } cs[1] = a%10; for(int j=2;j<=12;j++) cs[j] = (cs[j-1]*a)%10; for(int k=2;k<=12;k++){ if(cs[1]==(cs[k])) { int q = b%(k-1); if(q==0) q=k-1; printf("%d\n", cs[q]); break; } } A:; } return 0; }
the_stack_data/136683.c
// Copyright 2013 Google Inc. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include <stdio.h> #include <string.h> #include <math.h> #include <stdlib.h> const long long max_size = 2000; // max length of strings const long long N = 40; // number of closest words that will be shown const long long max_w = 50; // max length of vocabulary entries int main(int argc, char **argv) { FILE *f; char st1[max_size]; char bestw[N][max_size]; char file_name[max_size], st[100][max_size]; float dist, len, bestd[N], vec[max_size]; long long words, size, a, b, c, d, cn, bi[100]; float *M; char *vocab; if (argc < 2) { printf("Usage: ./word-analogy <FILE>\nwhere FILE contains word projections in the BINARY FORMAT\n"); return 0; } strcpy(file_name, argv[1]); f = fopen(file_name, "rb"); if (f == NULL) { printf("Input file not found\n"); return -1; } fscanf(f, "%lld", &words); fscanf(f, "%lld", &size); vocab = (char *)malloc((long long)words * max_w * sizeof(char)); M = (float *)malloc((long long)words * (long long)size * sizeof(float)); if (M == NULL) { printf("Cannot allocate memory: %lld MB %lld %lld\n", (long long)words * size * sizeof(float) / 1048576, words, size); return -1; } for (b = 0; b < words; b++) { a = 0; while (1) { vocab[b * max_w + a] = fgetc(f); if (feof(f) || (vocab[b * max_w + a] == ' ')) break; if ((a < max_w) && (vocab[b * max_w + a] != '\n')) a++; } vocab[b * max_w + a] = 0; for (a = 0; a < size; a++) { fread(&M[a + b * size], sizeof(float), 1, f); } len = 0; for (a = 0; a < size; a++) { len += M[a + b * size] * M[a + b * size]; } len = sqrt(len); for (a = 0; a < size; a++) { M[a + b * size] /= len; } } fclose(f); while (1) { for (a = 0; a < N; a++) { bestd[a] = 0; } for (a = 0; a < N; a++) { bestw[a][0] = 0; } printf("Enter three words (EXIT to break): "); a = 0; while (1) { st1[a] = fgetc(stdin); if ((st1[a] == '\n') || (a >= max_size - 1)) { st1[a] = 0; break; } a++; } if (!strcmp(st1, "EXIT")) break; cn = 0; b = 0; c = 0; while (1) { st[cn][b] = st1[c]; b++; c++; st[cn][b] = 0; if (st1[c] == 0) break; if (st1[c] == ' ') { cn++; b = 0; c++; } } cn++; if (cn < 3) { printf("Only %lld words were entered.. three words are needed at the input to perform the calculation\n", cn); continue; } for (a = 0; a < cn; a++) { for (b = 0; b < words; b++) { if (!strcmp(&vocab[b * max_w], st[a])) break; } if (b == words) { b = 0; } bi[a] = b; printf("\nWord: %s Position in vocabulary: %lld\n", st[a], bi[a]); if (b == 0) { printf("Out of dictionary word!\n"); break; } } if (b == 0) continue; printf("\n Word Distance\n------------------------------------------------------------------------\n"); for (a = 0; a < size; a++) { vec[a] = M[a + bi[1] * size] - M[a + bi[0] * size] + M[a + bi[2] * size]; } len = 0; for (a = 0; a < size; a++) { len += vec[a] * vec[a]; } len = sqrt(len); for (a = 0; a < size; a++) { vec[a] /= len; } for (a = 0; a < N; a++) { bestd[a] = 0; } for (a = 0; a < N; a++) { bestw[a][0] = 0; } for (c = 0; c < words; c++) { if (c == bi[0]) continue; if (c == bi[1]) continue; if (c == bi[2]) continue; a = 0; for (b = 0; b < cn; b++) { if (bi[b] == c) a = 1; } if (a == 1) continue; dist = 0; for (a = 0; a < size; a++) { dist += vec[a] * M[a + c * size]; } for (a = 0; a < N; a++) { if (dist > bestd[a]) { for (d = N - 1; d > a; d--) { bestd[d] = bestd[d - 1]; strcpy(bestw[d], bestw[d - 1]); } bestd[a] = dist; strcpy(bestw[a], &vocab[c * max_w]); break; } } } for (a = 0; a < N; a++) { printf("%50s\t\t%f\n", bestw[a], bestd[a]); } } return 0; }
the_stack_data/19474.c
// Write a C program to find factorial of a number using recursion #include<stdio.h> int fact(int n) { if(n==0 || n==1) return 1; return n*fact(n-1); } int main() { int n; printf("Enter a number\n"); scanf("%d",&n); printf("Factorial of %d is %d\n",n,fact(n)); } /*Output: Enter a number 5 Factorial of 5 is 120*/
the_stack_data/247017205.c
extern float __VERIFIER_nondet_float(void); extern int __VERIFIER_nondet_int(void); typedef enum {false, true} bool; bool __VERIFIER_nondet_bool(void) { return __VERIFIER_nondet_int() != 0; } int main() { bool _J1831, _x__J1831; bool _J1825, _x__J1825; bool _J1814, _x__J1814; float x_4, _x_x_4; bool _EL_U_1793, _x__EL_U_1793; float x_22, _x_x_22; float x_18, _x_x_18; float x_9, _x_x_9; bool _EL_U_1795, _x__EL_U_1795; float x_5, _x_x_5; float x_17, _x_x_17; float x_11, _x_x_11; float x_12, _x_x_12; bool _EL_U_1797, _x__EL_U_1797; float x_14, _x_x_14; float x_15, _x_x_15; float x_2, _x_x_2; float x_16, _x_x_16; float x_0, _x_x_0; float x_3, _x_x_3; float x_6, _x_x_6; float x_7, _x_x_7; float x_8, _x_x_8; float x_1, _x_x_1; float x_13, _x_x_13; float x_20, _x_x_20; float x_21, _x_x_21; float x_10, _x_x_10; float x_19, _x_x_19; float x_23, _x_x_23; int __steps_to_fair = __VERIFIER_nondet_int(); _J1831 = __VERIFIER_nondet_bool(); _J1825 = __VERIFIER_nondet_bool(); _J1814 = __VERIFIER_nondet_bool(); x_4 = __VERIFIER_nondet_float(); _EL_U_1793 = __VERIFIER_nondet_bool(); x_22 = __VERIFIER_nondet_float(); x_18 = __VERIFIER_nondet_float(); x_9 = __VERIFIER_nondet_float(); _EL_U_1795 = __VERIFIER_nondet_bool(); x_5 = __VERIFIER_nondet_float(); x_17 = __VERIFIER_nondet_float(); x_11 = __VERIFIER_nondet_float(); x_12 = __VERIFIER_nondet_float(); _EL_U_1797 = __VERIFIER_nondet_bool(); x_14 = __VERIFIER_nondet_float(); x_15 = __VERIFIER_nondet_float(); x_2 = __VERIFIER_nondet_float(); x_16 = __VERIFIER_nondet_float(); x_0 = __VERIFIER_nondet_float(); x_3 = __VERIFIER_nondet_float(); x_6 = __VERIFIER_nondet_float(); x_7 = __VERIFIER_nondet_float(); x_8 = __VERIFIER_nondet_float(); x_1 = __VERIFIER_nondet_float(); x_13 = __VERIFIER_nondet_float(); x_20 = __VERIFIER_nondet_float(); x_21 = __VERIFIER_nondet_float(); x_10 = __VERIFIER_nondet_float(); x_19 = __VERIFIER_nondet_float(); x_23 = __VERIFIER_nondet_float(); bool __ok = (1 && ((((_EL_U_1797 || ( !(( !((x_12 + (-1.0 * x_17)) <= 17.0)) || (_EL_U_1795 && ( !((-2.0 <= (x_18 + (-1.0 * x_22))) || _EL_U_1793)))))) && ( !_J1814)) && ( !_J1825)) && ( !_J1831))); while (__steps_to_fair >= 0 && __ok) { if (((_J1814 && _J1825) && _J1831)) { __steps_to_fair = __VERIFIER_nondet_int(); } else { __steps_to_fair--; } _x__J1831 = __VERIFIER_nondet_bool(); _x__J1825 = __VERIFIER_nondet_bool(); _x__J1814 = __VERIFIER_nondet_bool(); _x_x_4 = __VERIFIER_nondet_float(); _x__EL_U_1793 = __VERIFIER_nondet_bool(); _x_x_22 = __VERIFIER_nondet_float(); _x_x_18 = __VERIFIER_nondet_float(); _x_x_9 = __VERIFIER_nondet_float(); _x__EL_U_1795 = __VERIFIER_nondet_bool(); _x_x_5 = __VERIFIER_nondet_float(); _x_x_17 = __VERIFIER_nondet_float(); _x_x_11 = __VERIFIER_nondet_float(); _x_x_12 = __VERIFIER_nondet_float(); _x__EL_U_1797 = __VERIFIER_nondet_bool(); _x_x_14 = __VERIFIER_nondet_float(); _x_x_15 = __VERIFIER_nondet_float(); _x_x_2 = __VERIFIER_nondet_float(); _x_x_16 = __VERIFIER_nondet_float(); _x_x_0 = __VERIFIER_nondet_float(); _x_x_3 = __VERIFIER_nondet_float(); _x_x_6 = __VERIFIER_nondet_float(); _x_x_7 = __VERIFIER_nondet_float(); _x_x_8 = __VERIFIER_nondet_float(); _x_x_1 = __VERIFIER_nondet_float(); _x_x_13 = __VERIFIER_nondet_float(); _x_x_20 = __VERIFIER_nondet_float(); _x_x_21 = __VERIFIER_nondet_float(); _x_x_10 = __VERIFIER_nondet_float(); _x_x_19 = __VERIFIER_nondet_float(); _x_x_23 = __VERIFIER_nondet_float(); __ok = ((((((((((((((((((((((((((((x_23 + (-1.0 * _x_x_0)) <= -18.0) && (((x_22 + (-1.0 * _x_x_0)) <= -19.0) && (((x_19 + (-1.0 * _x_x_0)) <= -16.0) && (((x_16 + (-1.0 * _x_x_0)) <= -1.0) && (((x_15 + (-1.0 * _x_x_0)) <= -9.0) && (((x_14 + (-1.0 * _x_x_0)) <= -8.0) && (((x_12 + (-1.0 * _x_x_0)) <= -4.0) && (((x_9 + (-1.0 * _x_x_0)) <= -11.0) && (((x_7 + (-1.0 * _x_x_0)) <= -18.0) && (((x_6 + (-1.0 * _x_x_0)) <= -14.0) && (((x_3 + (-1.0 * _x_x_0)) <= -3.0) && ((x_5 + (-1.0 * _x_x_0)) <= -2.0)))))))))))) && (((x_23 + (-1.0 * _x_x_0)) == -18.0) || (((x_22 + (-1.0 * _x_x_0)) == -19.0) || (((x_19 + (-1.0 * _x_x_0)) == -16.0) || (((x_16 + (-1.0 * _x_x_0)) == -1.0) || (((x_15 + (-1.0 * _x_x_0)) == -9.0) || (((x_14 + (-1.0 * _x_x_0)) == -8.0) || (((x_12 + (-1.0 * _x_x_0)) == -4.0) || (((x_9 + (-1.0 * _x_x_0)) == -11.0) || (((x_7 + (-1.0 * _x_x_0)) == -18.0) || (((x_6 + (-1.0 * _x_x_0)) == -14.0) || (((x_3 + (-1.0 * _x_x_0)) == -3.0) || ((x_5 + (-1.0 * _x_x_0)) == -2.0))))))))))))) && ((((x_19 + (-1.0 * _x_x_1)) <= -10.0) && (((x_18 + (-1.0 * _x_x_1)) <= -6.0) && (((x_16 + (-1.0 * _x_x_1)) <= -11.0) && (((x_14 + (-1.0 * _x_x_1)) <= -19.0) && (((x_12 + (-1.0 * _x_x_1)) <= -1.0) && (((x_11 + (-1.0 * _x_x_1)) <= -10.0) && (((x_10 + (-1.0 * _x_x_1)) <= -12.0) && (((x_7 + (-1.0 * _x_x_1)) <= -8.0) && (((x_6 + (-1.0 * _x_x_1)) <= -4.0) && (((x_2 + (-1.0 * _x_x_1)) <= -11.0) && (((x_0 + (-1.0 * _x_x_1)) <= -15.0) && ((x_1 + (-1.0 * _x_x_1)) <= -9.0)))))))))))) && (((x_19 + (-1.0 * _x_x_1)) == -10.0) || (((x_18 + (-1.0 * _x_x_1)) == -6.0) || (((x_16 + (-1.0 * _x_x_1)) == -11.0) || (((x_14 + (-1.0 * _x_x_1)) == -19.0) || (((x_12 + (-1.0 * _x_x_1)) == -1.0) || (((x_11 + (-1.0 * _x_x_1)) == -10.0) || (((x_10 + (-1.0 * _x_x_1)) == -12.0) || (((x_7 + (-1.0 * _x_x_1)) == -8.0) || (((x_6 + (-1.0 * _x_x_1)) == -4.0) || (((x_2 + (-1.0 * _x_x_1)) == -11.0) || (((x_0 + (-1.0 * _x_x_1)) == -15.0) || ((x_1 + (-1.0 * _x_x_1)) == -9.0)))))))))))))) && ((((x_22 + (-1.0 * _x_x_2)) <= -17.0) && (((x_20 + (-1.0 * _x_x_2)) <= -10.0) && (((x_16 + (-1.0 * _x_x_2)) <= -2.0) && (((x_13 + (-1.0 * _x_x_2)) <= -1.0) && (((x_12 + (-1.0 * _x_x_2)) <= -9.0) && (((x_11 + (-1.0 * _x_x_2)) <= -13.0) && (((x_8 + (-1.0 * _x_x_2)) <= -14.0) && (((x_7 + (-1.0 * _x_x_2)) <= -18.0) && (((x_6 + (-1.0 * _x_x_2)) <= -2.0) && (((x_3 + (-1.0 * _x_x_2)) <= -8.0) && (((x_0 + (-1.0 * _x_x_2)) <= -11.0) && ((x_2 + (-1.0 * _x_x_2)) <= -10.0)))))))))))) && (((x_22 + (-1.0 * _x_x_2)) == -17.0) || (((x_20 + (-1.0 * _x_x_2)) == -10.0) || (((x_16 + (-1.0 * _x_x_2)) == -2.0) || (((x_13 + (-1.0 * _x_x_2)) == -1.0) || (((x_12 + (-1.0 * _x_x_2)) == -9.0) || (((x_11 + (-1.0 * _x_x_2)) == -13.0) || (((x_8 + (-1.0 * _x_x_2)) == -14.0) || (((x_7 + (-1.0 * _x_x_2)) == -18.0) || (((x_6 + (-1.0 * _x_x_2)) == -2.0) || (((x_3 + (-1.0 * _x_x_2)) == -8.0) || (((x_0 + (-1.0 * _x_x_2)) == -11.0) || ((x_2 + (-1.0 * _x_x_2)) == -10.0)))))))))))))) && ((((x_23 + (-1.0 * _x_x_3)) <= -1.0) && (((x_22 + (-1.0 * _x_x_3)) <= -17.0) && (((x_21 + (-1.0 * _x_x_3)) <= -10.0) && (((x_17 + (-1.0 * _x_x_3)) <= -17.0) && (((x_15 + (-1.0 * _x_x_3)) <= -11.0) && (((x_14 + (-1.0 * _x_x_3)) <= -3.0) && (((x_12 + (-1.0 * _x_x_3)) <= -6.0) && (((x_9 + (-1.0 * _x_x_3)) <= -19.0) && (((x_8 + (-1.0 * _x_x_3)) <= -13.0) && (((x_7 + (-1.0 * _x_x_3)) <= -7.0) && (((x_3 + (-1.0 * _x_x_3)) <= -15.0) && ((x_6 + (-1.0 * _x_x_3)) <= -5.0)))))))))))) && (((x_23 + (-1.0 * _x_x_3)) == -1.0) || (((x_22 + (-1.0 * _x_x_3)) == -17.0) || (((x_21 + (-1.0 * _x_x_3)) == -10.0) || (((x_17 + (-1.0 * _x_x_3)) == -17.0) || (((x_15 + (-1.0 * _x_x_3)) == -11.0) || (((x_14 + (-1.0 * _x_x_3)) == -3.0) || (((x_12 + (-1.0 * _x_x_3)) == -6.0) || (((x_9 + (-1.0 * _x_x_3)) == -19.0) || (((x_8 + (-1.0 * _x_x_3)) == -13.0) || (((x_7 + (-1.0 * _x_x_3)) == -7.0) || (((x_3 + (-1.0 * _x_x_3)) == -15.0) || ((x_6 + (-1.0 * _x_x_3)) == -5.0)))))))))))))) && ((((x_23 + (-1.0 * _x_x_4)) <= -13.0) && (((x_22 + (-1.0 * _x_x_4)) <= -12.0) && (((x_20 + (-1.0 * _x_x_4)) <= -3.0) && (((x_16 + (-1.0 * _x_x_4)) <= -20.0) && (((x_13 + (-1.0 * _x_x_4)) <= -15.0) && (((x_11 + (-1.0 * _x_x_4)) <= -4.0) && (((x_10 + (-1.0 * _x_x_4)) <= -10.0) && (((x_9 + (-1.0 * _x_x_4)) <= -19.0) && (((x_6 + (-1.0 * _x_x_4)) <= -3.0) && (((x_3 + (-1.0 * _x_x_4)) <= -7.0) && (((x_0 + (-1.0 * _x_x_4)) <= -16.0) && ((x_2 + (-1.0 * _x_x_4)) <= -9.0)))))))))))) && (((x_23 + (-1.0 * _x_x_4)) == -13.0) || (((x_22 + (-1.0 * _x_x_4)) == -12.0) || (((x_20 + (-1.0 * _x_x_4)) == -3.0) || (((x_16 + (-1.0 * _x_x_4)) == -20.0) || (((x_13 + (-1.0 * _x_x_4)) == -15.0) || (((x_11 + (-1.0 * _x_x_4)) == -4.0) || (((x_10 + (-1.0 * _x_x_4)) == -10.0) || (((x_9 + (-1.0 * _x_x_4)) == -19.0) || (((x_6 + (-1.0 * _x_x_4)) == -3.0) || (((x_3 + (-1.0 * _x_x_4)) == -7.0) || (((x_0 + (-1.0 * _x_x_4)) == -16.0) || ((x_2 + (-1.0 * _x_x_4)) == -9.0)))))))))))))) && ((((x_23 + (-1.0 * _x_x_5)) <= -13.0) && (((x_21 + (-1.0 * _x_x_5)) <= -20.0) && (((x_19 + (-1.0 * _x_x_5)) <= -14.0) && (((x_18 + (-1.0 * _x_x_5)) <= -10.0) && (((x_15 + (-1.0 * _x_x_5)) <= -5.0) && (((x_14 + (-1.0 * _x_x_5)) <= -9.0) && (((x_13 + (-1.0 * _x_x_5)) <= -8.0) && (((x_12 + (-1.0 * _x_x_5)) <= -4.0) && (((x_11 + (-1.0 * _x_x_5)) <= -18.0) && (((x_6 + (-1.0 * _x_x_5)) <= -20.0) && (((x_1 + (-1.0 * _x_x_5)) <= -1.0) && ((x_2 + (-1.0 * _x_x_5)) <= -6.0)))))))))))) && (((x_23 + (-1.0 * _x_x_5)) == -13.0) || (((x_21 + (-1.0 * _x_x_5)) == -20.0) || (((x_19 + (-1.0 * _x_x_5)) == -14.0) || (((x_18 + (-1.0 * _x_x_5)) == -10.0) || (((x_15 + (-1.0 * _x_x_5)) == -5.0) || (((x_14 + (-1.0 * _x_x_5)) == -9.0) || (((x_13 + (-1.0 * _x_x_5)) == -8.0) || (((x_12 + (-1.0 * _x_x_5)) == -4.0) || (((x_11 + (-1.0 * _x_x_5)) == -18.0) || (((x_6 + (-1.0 * _x_x_5)) == -20.0) || (((x_1 + (-1.0 * _x_x_5)) == -1.0) || ((x_2 + (-1.0 * _x_x_5)) == -6.0)))))))))))))) && ((((x_22 + (-1.0 * _x_x_6)) <= -17.0) && (((x_21 + (-1.0 * _x_x_6)) <= -13.0) && (((x_12 + (-1.0 * _x_x_6)) <= -15.0) && (((x_11 + (-1.0 * _x_x_6)) <= -13.0) && (((x_10 + (-1.0 * _x_x_6)) <= -16.0) && (((x_9 + (-1.0 * _x_x_6)) <= -11.0) && (((x_8 + (-1.0 * _x_x_6)) <= -20.0) && (((x_6 + (-1.0 * _x_x_6)) <= -4.0) && (((x_5 + (-1.0 * _x_x_6)) <= -5.0) && (((x_3 + (-1.0 * _x_x_6)) <= -12.0) && (((x_0 + (-1.0 * _x_x_6)) <= -19.0) && ((x_2 + (-1.0 * _x_x_6)) <= -11.0)))))))))))) && (((x_22 + (-1.0 * _x_x_6)) == -17.0) || (((x_21 + (-1.0 * _x_x_6)) == -13.0) || (((x_12 + (-1.0 * _x_x_6)) == -15.0) || (((x_11 + (-1.0 * _x_x_6)) == -13.0) || (((x_10 + (-1.0 * _x_x_6)) == -16.0) || (((x_9 + (-1.0 * _x_x_6)) == -11.0) || (((x_8 + (-1.0 * _x_x_6)) == -20.0) || (((x_6 + (-1.0 * _x_x_6)) == -4.0) || (((x_5 + (-1.0 * _x_x_6)) == -5.0) || (((x_3 + (-1.0 * _x_x_6)) == -12.0) || (((x_0 + (-1.0 * _x_x_6)) == -19.0) || ((x_2 + (-1.0 * _x_x_6)) == -11.0)))))))))))))) && ((((x_23 + (-1.0 * _x_x_7)) <= -2.0) && (((x_22 + (-1.0 * _x_x_7)) <= -2.0) && (((x_21 + (-1.0 * _x_x_7)) <= -8.0) && (((x_20 + (-1.0 * _x_x_7)) <= -1.0) && (((x_19 + (-1.0 * _x_x_7)) <= -19.0) && (((x_18 + (-1.0 * _x_x_7)) <= -6.0) && (((x_16 + (-1.0 * _x_x_7)) <= -16.0) && (((x_14 + (-1.0 * _x_x_7)) <= -14.0) && (((x_9 + (-1.0 * _x_x_7)) <= -14.0) && (((x_7 + (-1.0 * _x_x_7)) <= -13.0) && (((x_3 + (-1.0 * _x_x_7)) <= -9.0) && ((x_5 + (-1.0 * _x_x_7)) <= -15.0)))))))))))) && (((x_23 + (-1.0 * _x_x_7)) == -2.0) || (((x_22 + (-1.0 * _x_x_7)) == -2.0) || (((x_21 + (-1.0 * _x_x_7)) == -8.0) || (((x_20 + (-1.0 * _x_x_7)) == -1.0) || (((x_19 + (-1.0 * _x_x_7)) == -19.0) || (((x_18 + (-1.0 * _x_x_7)) == -6.0) || (((x_16 + (-1.0 * _x_x_7)) == -16.0) || (((x_14 + (-1.0 * _x_x_7)) == -14.0) || (((x_9 + (-1.0 * _x_x_7)) == -14.0) || (((x_7 + (-1.0 * _x_x_7)) == -13.0) || (((x_3 + (-1.0 * _x_x_7)) == -9.0) || ((x_5 + (-1.0 * _x_x_7)) == -15.0)))))))))))))) && ((((x_23 + (-1.0 * _x_x_8)) <= -18.0) && (((x_20 + (-1.0 * _x_x_8)) <= -2.0) && (((x_18 + (-1.0 * _x_x_8)) <= -3.0) && (((x_14 + (-1.0 * _x_x_8)) <= -7.0) && (((x_12 + (-1.0 * _x_x_8)) <= -16.0) && (((x_10 + (-1.0 * _x_x_8)) <= -17.0) && (((x_8 + (-1.0 * _x_x_8)) <= -6.0) && (((x_7 + (-1.0 * _x_x_8)) <= -13.0) && (((x_4 + (-1.0 * _x_x_8)) <= -15.0) && (((x_2 + (-1.0 * _x_x_8)) <= -12.0) && (((x_0 + (-1.0 * _x_x_8)) <= -9.0) && ((x_1 + (-1.0 * _x_x_8)) <= -9.0)))))))))))) && (((x_23 + (-1.0 * _x_x_8)) == -18.0) || (((x_20 + (-1.0 * _x_x_8)) == -2.0) || (((x_18 + (-1.0 * _x_x_8)) == -3.0) || (((x_14 + (-1.0 * _x_x_8)) == -7.0) || (((x_12 + (-1.0 * _x_x_8)) == -16.0) || (((x_10 + (-1.0 * _x_x_8)) == -17.0) || (((x_8 + (-1.0 * _x_x_8)) == -6.0) || (((x_7 + (-1.0 * _x_x_8)) == -13.0) || (((x_4 + (-1.0 * _x_x_8)) == -15.0) || (((x_2 + (-1.0 * _x_x_8)) == -12.0) || (((x_0 + (-1.0 * _x_x_8)) == -9.0) || ((x_1 + (-1.0 * _x_x_8)) == -9.0)))))))))))))) && ((((x_23 + (-1.0 * _x_x_9)) <= -14.0) && (((x_22 + (-1.0 * _x_x_9)) <= -18.0) && (((x_18 + (-1.0 * _x_x_9)) <= -10.0) && (((x_17 + (-1.0 * _x_x_9)) <= -12.0) && (((x_11 + (-1.0 * _x_x_9)) <= -1.0) && (((x_10 + (-1.0 * _x_x_9)) <= -7.0) && (((x_8 + (-1.0 * _x_x_9)) <= -2.0) && (((x_6 + (-1.0 * _x_x_9)) <= -11.0) && (((x_5 + (-1.0 * _x_x_9)) <= -10.0) && (((x_4 + (-1.0 * _x_x_9)) <= -8.0) && (((x_1 + (-1.0 * _x_x_9)) <= -3.0) && ((x_2 + (-1.0 * _x_x_9)) <= -20.0)))))))))))) && (((x_23 + (-1.0 * _x_x_9)) == -14.0) || (((x_22 + (-1.0 * _x_x_9)) == -18.0) || (((x_18 + (-1.0 * _x_x_9)) == -10.0) || (((x_17 + (-1.0 * _x_x_9)) == -12.0) || (((x_11 + (-1.0 * _x_x_9)) == -1.0) || (((x_10 + (-1.0 * _x_x_9)) == -7.0) || (((x_8 + (-1.0 * _x_x_9)) == -2.0) || (((x_6 + (-1.0 * _x_x_9)) == -11.0) || (((x_5 + (-1.0 * _x_x_9)) == -10.0) || (((x_4 + (-1.0 * _x_x_9)) == -8.0) || (((x_1 + (-1.0 * _x_x_9)) == -3.0) || ((x_2 + (-1.0 * _x_x_9)) == -20.0)))))))))))))) && ((((x_23 + (-1.0 * _x_x_10)) <= -5.0) && (((x_22 + (-1.0 * _x_x_10)) <= -11.0) && (((x_20 + (-1.0 * _x_x_10)) <= -4.0) && (((x_16 + (-1.0 * _x_x_10)) <= -11.0) && (((x_15 + (-1.0 * _x_x_10)) <= -4.0) && (((x_14 + (-1.0 * _x_x_10)) <= -10.0) && (((x_13 + (-1.0 * _x_x_10)) <= -6.0) && (((x_10 + (-1.0 * _x_x_10)) <= -14.0) && (((x_5 + (-1.0 * _x_x_10)) <= -20.0) && (((x_4 + (-1.0 * _x_x_10)) <= -17.0) && (((x_0 + (-1.0 * _x_x_10)) <= -11.0) && ((x_3 + (-1.0 * _x_x_10)) <= -10.0)))))))))))) && (((x_23 + (-1.0 * _x_x_10)) == -5.0) || (((x_22 + (-1.0 * _x_x_10)) == -11.0) || (((x_20 + (-1.0 * _x_x_10)) == -4.0) || (((x_16 + (-1.0 * _x_x_10)) == -11.0) || (((x_15 + (-1.0 * _x_x_10)) == -4.0) || (((x_14 + (-1.0 * _x_x_10)) == -10.0) || (((x_13 + (-1.0 * _x_x_10)) == -6.0) || (((x_10 + (-1.0 * _x_x_10)) == -14.0) || (((x_5 + (-1.0 * _x_x_10)) == -20.0) || (((x_4 + (-1.0 * _x_x_10)) == -17.0) || (((x_0 + (-1.0 * _x_x_10)) == -11.0) || ((x_3 + (-1.0 * _x_x_10)) == -10.0)))))))))))))) && ((((x_21 + (-1.0 * _x_x_11)) <= -8.0) && (((x_19 + (-1.0 * _x_x_11)) <= -19.0) && (((x_18 + (-1.0 * _x_x_11)) <= -18.0) && (((x_14 + (-1.0 * _x_x_11)) <= -11.0) && (((x_10 + (-1.0 * _x_x_11)) <= -18.0) && (((x_8 + (-1.0 * _x_x_11)) <= -12.0) && (((x_7 + (-1.0 * _x_x_11)) <= -15.0) && (((x_6 + (-1.0 * _x_x_11)) <= -14.0) && (((x_4 + (-1.0 * _x_x_11)) <= -12.0) && (((x_3 + (-1.0 * _x_x_11)) <= -4.0) && (((x_0 + (-1.0 * _x_x_11)) <= -16.0) && ((x_1 + (-1.0 * _x_x_11)) <= -18.0)))))))))))) && (((x_21 + (-1.0 * _x_x_11)) == -8.0) || (((x_19 + (-1.0 * _x_x_11)) == -19.0) || (((x_18 + (-1.0 * _x_x_11)) == -18.0) || (((x_14 + (-1.0 * _x_x_11)) == -11.0) || (((x_10 + (-1.0 * _x_x_11)) == -18.0) || (((x_8 + (-1.0 * _x_x_11)) == -12.0) || (((x_7 + (-1.0 * _x_x_11)) == -15.0) || (((x_6 + (-1.0 * _x_x_11)) == -14.0) || (((x_4 + (-1.0 * _x_x_11)) == -12.0) || (((x_3 + (-1.0 * _x_x_11)) == -4.0) || (((x_0 + (-1.0 * _x_x_11)) == -16.0) || ((x_1 + (-1.0 * _x_x_11)) == -18.0)))))))))))))) && ((((x_23 + (-1.0 * _x_x_12)) <= -15.0) && (((x_21 + (-1.0 * _x_x_12)) <= -11.0) && (((x_19 + (-1.0 * _x_x_12)) <= -12.0) && (((x_18 + (-1.0 * _x_x_12)) <= -2.0) && (((x_14 + (-1.0 * _x_x_12)) <= -7.0) && (((x_12 + (-1.0 * _x_x_12)) <= -16.0) && (((x_11 + (-1.0 * _x_x_12)) <= -6.0) && (((x_6 + (-1.0 * _x_x_12)) <= -12.0) && (((x_4 + (-1.0 * _x_x_12)) <= -16.0) && (((x_3 + (-1.0 * _x_x_12)) <= -7.0) && (((x_0 + (-1.0 * _x_x_12)) <= -13.0) && ((x_2 + (-1.0 * _x_x_12)) <= -3.0)))))))))))) && (((x_23 + (-1.0 * _x_x_12)) == -15.0) || (((x_21 + (-1.0 * _x_x_12)) == -11.0) || (((x_19 + (-1.0 * _x_x_12)) == -12.0) || (((x_18 + (-1.0 * _x_x_12)) == -2.0) || (((x_14 + (-1.0 * _x_x_12)) == -7.0) || (((x_12 + (-1.0 * _x_x_12)) == -16.0) || (((x_11 + (-1.0 * _x_x_12)) == -6.0) || (((x_6 + (-1.0 * _x_x_12)) == -12.0) || (((x_4 + (-1.0 * _x_x_12)) == -16.0) || (((x_3 + (-1.0 * _x_x_12)) == -7.0) || (((x_0 + (-1.0 * _x_x_12)) == -13.0) || ((x_2 + (-1.0 * _x_x_12)) == -3.0)))))))))))))) && ((((x_17 + (-1.0 * _x_x_13)) <= -15.0) && (((x_16 + (-1.0 * _x_x_13)) <= -7.0) && (((x_14 + (-1.0 * _x_x_13)) <= -7.0) && (((x_13 + (-1.0 * _x_x_13)) <= -17.0) && (((x_12 + (-1.0 * _x_x_13)) <= -9.0) && (((x_11 + (-1.0 * _x_x_13)) <= -4.0) && (((x_10 + (-1.0 * _x_x_13)) <= -4.0) && (((x_9 + (-1.0 * _x_x_13)) <= -17.0) && (((x_7 + (-1.0 * _x_x_13)) <= -19.0) && (((x_5 + (-1.0 * _x_x_13)) <= -5.0) && (((x_2 + (-1.0 * _x_x_13)) <= -12.0) && ((x_3 + (-1.0 * _x_x_13)) <= -9.0)))))))))))) && (((x_17 + (-1.0 * _x_x_13)) == -15.0) || (((x_16 + (-1.0 * _x_x_13)) == -7.0) || (((x_14 + (-1.0 * _x_x_13)) == -7.0) || (((x_13 + (-1.0 * _x_x_13)) == -17.0) || (((x_12 + (-1.0 * _x_x_13)) == -9.0) || (((x_11 + (-1.0 * _x_x_13)) == -4.0) || (((x_10 + (-1.0 * _x_x_13)) == -4.0) || (((x_9 + (-1.0 * _x_x_13)) == -17.0) || (((x_7 + (-1.0 * _x_x_13)) == -19.0) || (((x_5 + (-1.0 * _x_x_13)) == -5.0) || (((x_2 + (-1.0 * _x_x_13)) == -12.0) || ((x_3 + (-1.0 * _x_x_13)) == -9.0)))))))))))))) && ((((x_22 + (-1.0 * _x_x_14)) <= -14.0) && (((x_21 + (-1.0 * _x_x_14)) <= -5.0) && (((x_20 + (-1.0 * _x_x_14)) <= -15.0) && (((x_17 + (-1.0 * _x_x_14)) <= -5.0) && (((x_16 + (-1.0 * _x_x_14)) <= -2.0) && (((x_13 + (-1.0 * _x_x_14)) <= -10.0) && (((x_11 + (-1.0 * _x_x_14)) <= -2.0) && (((x_10 + (-1.0 * _x_x_14)) <= -19.0) && (((x_5 + (-1.0 * _x_x_14)) <= -7.0) && (((x_4 + (-1.0 * _x_x_14)) <= -18.0) && (((x_1 + (-1.0 * _x_x_14)) <= -5.0) && ((x_2 + (-1.0 * _x_x_14)) <= -17.0)))))))))))) && (((x_22 + (-1.0 * _x_x_14)) == -14.0) || (((x_21 + (-1.0 * _x_x_14)) == -5.0) || (((x_20 + (-1.0 * _x_x_14)) == -15.0) || (((x_17 + (-1.0 * _x_x_14)) == -5.0) || (((x_16 + (-1.0 * _x_x_14)) == -2.0) || (((x_13 + (-1.0 * _x_x_14)) == -10.0) || (((x_11 + (-1.0 * _x_x_14)) == -2.0) || (((x_10 + (-1.0 * _x_x_14)) == -19.0) || (((x_5 + (-1.0 * _x_x_14)) == -7.0) || (((x_4 + (-1.0 * _x_x_14)) == -18.0) || (((x_1 + (-1.0 * _x_x_14)) == -5.0) || ((x_2 + (-1.0 * _x_x_14)) == -17.0)))))))))))))) && ((((x_22 + (-1.0 * _x_x_15)) <= -20.0) && (((x_18 + (-1.0 * _x_x_15)) <= -11.0) && (((x_17 + (-1.0 * _x_x_15)) <= -11.0) && (((x_14 + (-1.0 * _x_x_15)) <= -19.0) && (((x_13 + (-1.0 * _x_x_15)) <= -9.0) && (((x_11 + (-1.0 * _x_x_15)) <= -9.0) && (((x_10 + (-1.0 * _x_x_15)) <= -8.0) && (((x_6 + (-1.0 * _x_x_15)) <= -4.0) && (((x_5 + (-1.0 * _x_x_15)) <= -9.0) && (((x_4 + (-1.0 * _x_x_15)) <= -1.0) && (((x_0 + (-1.0 * _x_x_15)) <= -12.0) && ((x_2 + (-1.0 * _x_x_15)) <= -19.0)))))))))))) && (((x_22 + (-1.0 * _x_x_15)) == -20.0) || (((x_18 + (-1.0 * _x_x_15)) == -11.0) || (((x_17 + (-1.0 * _x_x_15)) == -11.0) || (((x_14 + (-1.0 * _x_x_15)) == -19.0) || (((x_13 + (-1.0 * _x_x_15)) == -9.0) || (((x_11 + (-1.0 * _x_x_15)) == -9.0) || (((x_10 + (-1.0 * _x_x_15)) == -8.0) || (((x_6 + (-1.0 * _x_x_15)) == -4.0) || (((x_5 + (-1.0 * _x_x_15)) == -9.0) || (((x_4 + (-1.0 * _x_x_15)) == -1.0) || (((x_0 + (-1.0 * _x_x_15)) == -12.0) || ((x_2 + (-1.0 * _x_x_15)) == -19.0)))))))))))))) && ((((x_23 + (-1.0 * _x_x_16)) <= -14.0) && (((x_22 + (-1.0 * _x_x_16)) <= -17.0) && (((x_21 + (-1.0 * _x_x_16)) <= -1.0) && (((x_20 + (-1.0 * _x_x_16)) <= -17.0) && (((x_15 + (-1.0 * _x_x_16)) <= -6.0) && (((x_13 + (-1.0 * _x_x_16)) <= -19.0) && (((x_11 + (-1.0 * _x_x_16)) <= -5.0) && (((x_9 + (-1.0 * _x_x_16)) <= -16.0) && (((x_8 + (-1.0 * _x_x_16)) <= -7.0) && (((x_6 + (-1.0 * _x_x_16)) <= -19.0) && (((x_0 + (-1.0 * _x_x_16)) <= -8.0) && ((x_1 + (-1.0 * _x_x_16)) <= -13.0)))))))))))) && (((x_23 + (-1.0 * _x_x_16)) == -14.0) || (((x_22 + (-1.0 * _x_x_16)) == -17.0) || (((x_21 + (-1.0 * _x_x_16)) == -1.0) || (((x_20 + (-1.0 * _x_x_16)) == -17.0) || (((x_15 + (-1.0 * _x_x_16)) == -6.0) || (((x_13 + (-1.0 * _x_x_16)) == -19.0) || (((x_11 + (-1.0 * _x_x_16)) == -5.0) || (((x_9 + (-1.0 * _x_x_16)) == -16.0) || (((x_8 + (-1.0 * _x_x_16)) == -7.0) || (((x_6 + (-1.0 * _x_x_16)) == -19.0) || (((x_0 + (-1.0 * _x_x_16)) == -8.0) || ((x_1 + (-1.0 * _x_x_16)) == -13.0)))))))))))))) && ((((x_21 + (-1.0 * _x_x_17)) <= -5.0) && (((x_20 + (-1.0 * _x_x_17)) <= -9.0) && (((x_18 + (-1.0 * _x_x_17)) <= -18.0) && (((x_17 + (-1.0 * _x_x_17)) <= -7.0) && (((x_16 + (-1.0 * _x_x_17)) <= -11.0) && (((x_15 + (-1.0 * _x_x_17)) <= -20.0) && (((x_11 + (-1.0 * _x_x_17)) <= -6.0) && (((x_10 + (-1.0 * _x_x_17)) <= -20.0) && (((x_9 + (-1.0 * _x_x_17)) <= -20.0) && (((x_8 + (-1.0 * _x_x_17)) <= -6.0) && (((x_2 + (-1.0 * _x_x_17)) <= -17.0) && ((x_6 + (-1.0 * _x_x_17)) <= -9.0)))))))))))) && (((x_21 + (-1.0 * _x_x_17)) == -5.0) || (((x_20 + (-1.0 * _x_x_17)) == -9.0) || (((x_18 + (-1.0 * _x_x_17)) == -18.0) || (((x_17 + (-1.0 * _x_x_17)) == -7.0) || (((x_16 + (-1.0 * _x_x_17)) == -11.0) || (((x_15 + (-1.0 * _x_x_17)) == -20.0) || (((x_11 + (-1.0 * _x_x_17)) == -6.0) || (((x_10 + (-1.0 * _x_x_17)) == -20.0) || (((x_9 + (-1.0 * _x_x_17)) == -20.0) || (((x_8 + (-1.0 * _x_x_17)) == -6.0) || (((x_2 + (-1.0 * _x_x_17)) == -17.0) || ((x_6 + (-1.0 * _x_x_17)) == -9.0)))))))))))))) && ((((x_23 + (-1.0 * _x_x_18)) <= -13.0) && (((x_17 + (-1.0 * _x_x_18)) <= -3.0) && (((x_16 + (-1.0 * _x_x_18)) <= -15.0) && (((x_15 + (-1.0 * _x_x_18)) <= -8.0) && (((x_14 + (-1.0 * _x_x_18)) <= -9.0) && (((x_13 + (-1.0 * _x_x_18)) <= -10.0) && (((x_12 + (-1.0 * _x_x_18)) <= -4.0) && (((x_9 + (-1.0 * _x_x_18)) <= -15.0) && (((x_5 + (-1.0 * _x_x_18)) <= -6.0) && (((x_4 + (-1.0 * _x_x_18)) <= -18.0) && (((x_0 + (-1.0 * _x_x_18)) <= -20.0) && ((x_2 + (-1.0 * _x_x_18)) <= -19.0)))))))))))) && (((x_23 + (-1.0 * _x_x_18)) == -13.0) || (((x_17 + (-1.0 * _x_x_18)) == -3.0) || (((x_16 + (-1.0 * _x_x_18)) == -15.0) || (((x_15 + (-1.0 * _x_x_18)) == -8.0) || (((x_14 + (-1.0 * _x_x_18)) == -9.0) || (((x_13 + (-1.0 * _x_x_18)) == -10.0) || (((x_12 + (-1.0 * _x_x_18)) == -4.0) || (((x_9 + (-1.0 * _x_x_18)) == -15.0) || (((x_5 + (-1.0 * _x_x_18)) == -6.0) || (((x_4 + (-1.0 * _x_x_18)) == -18.0) || (((x_0 + (-1.0 * _x_x_18)) == -20.0) || ((x_2 + (-1.0 * _x_x_18)) == -19.0)))))))))))))) && ((((x_23 + (-1.0 * _x_x_19)) <= -18.0) && (((x_20 + (-1.0 * _x_x_19)) <= -20.0) && (((x_19 + (-1.0 * _x_x_19)) <= -20.0) && (((x_18 + (-1.0 * _x_x_19)) <= -11.0) && (((x_17 + (-1.0 * _x_x_19)) <= -13.0) && (((x_15 + (-1.0 * _x_x_19)) <= -9.0) && (((x_14 + (-1.0 * _x_x_19)) <= -9.0) && (((x_13 + (-1.0 * _x_x_19)) <= -2.0) && (((x_10 + (-1.0 * _x_x_19)) <= -5.0) && (((x_9 + (-1.0 * _x_x_19)) <= -12.0) && (((x_5 + (-1.0 * _x_x_19)) <= -1.0) && ((x_6 + (-1.0 * _x_x_19)) <= -9.0)))))))))))) && (((x_23 + (-1.0 * _x_x_19)) == -18.0) || (((x_20 + (-1.0 * _x_x_19)) == -20.0) || (((x_19 + (-1.0 * _x_x_19)) == -20.0) || (((x_18 + (-1.0 * _x_x_19)) == -11.0) || (((x_17 + (-1.0 * _x_x_19)) == -13.0) || (((x_15 + (-1.0 * _x_x_19)) == -9.0) || (((x_14 + (-1.0 * _x_x_19)) == -9.0) || (((x_13 + (-1.0 * _x_x_19)) == -2.0) || (((x_10 + (-1.0 * _x_x_19)) == -5.0) || (((x_9 + (-1.0 * _x_x_19)) == -12.0) || (((x_5 + (-1.0 * _x_x_19)) == -1.0) || ((x_6 + (-1.0 * _x_x_19)) == -9.0)))))))))))))) && ((((x_23 + (-1.0 * _x_x_20)) <= -12.0) && (((x_19 + (-1.0 * _x_x_20)) <= -4.0) && (((x_15 + (-1.0 * _x_x_20)) <= -11.0) && (((x_12 + (-1.0 * _x_x_20)) <= -15.0) && (((x_11 + (-1.0 * _x_x_20)) <= -20.0) && (((x_10 + (-1.0 * _x_x_20)) <= -12.0) && (((x_9 + (-1.0 * _x_x_20)) <= -18.0) && (((x_8 + (-1.0 * _x_x_20)) <= -17.0) && (((x_6 + (-1.0 * _x_x_20)) <= -7.0) && (((x_5 + (-1.0 * _x_x_20)) <= -10.0) && (((x_0 + (-1.0 * _x_x_20)) <= -10.0) && ((x_3 + (-1.0 * _x_x_20)) <= -3.0)))))))))))) && (((x_23 + (-1.0 * _x_x_20)) == -12.0) || (((x_19 + (-1.0 * _x_x_20)) == -4.0) || (((x_15 + (-1.0 * _x_x_20)) == -11.0) || (((x_12 + (-1.0 * _x_x_20)) == -15.0) || (((x_11 + (-1.0 * _x_x_20)) == -20.0) || (((x_10 + (-1.0 * _x_x_20)) == -12.0) || (((x_9 + (-1.0 * _x_x_20)) == -18.0) || (((x_8 + (-1.0 * _x_x_20)) == -17.0) || (((x_6 + (-1.0 * _x_x_20)) == -7.0) || (((x_5 + (-1.0 * _x_x_20)) == -10.0) || (((x_0 + (-1.0 * _x_x_20)) == -10.0) || ((x_3 + (-1.0 * _x_x_20)) == -3.0)))))))))))))) && ((((x_23 + (-1.0 * _x_x_21)) <= -13.0) && (((x_19 + (-1.0 * _x_x_21)) <= -3.0) && (((x_18 + (-1.0 * _x_x_21)) <= -19.0) && (((x_15 + (-1.0 * _x_x_21)) <= -15.0) && (((x_10 + (-1.0 * _x_x_21)) <= -19.0) && (((x_9 + (-1.0 * _x_x_21)) <= -9.0) && (((x_8 + (-1.0 * _x_x_21)) <= -18.0) && (((x_6 + (-1.0 * _x_x_21)) <= -18.0) && (((x_4 + (-1.0 * _x_x_21)) <= -5.0) && (((x_3 + (-1.0 * _x_x_21)) <= -8.0) && (((x_1 + (-1.0 * _x_x_21)) <= -16.0) && ((x_2 + (-1.0 * _x_x_21)) <= -9.0)))))))))))) && (((x_23 + (-1.0 * _x_x_21)) == -13.0) || (((x_19 + (-1.0 * _x_x_21)) == -3.0) || (((x_18 + (-1.0 * _x_x_21)) == -19.0) || (((x_15 + (-1.0 * _x_x_21)) == -15.0) || (((x_10 + (-1.0 * _x_x_21)) == -19.0) || (((x_9 + (-1.0 * _x_x_21)) == -9.0) || (((x_8 + (-1.0 * _x_x_21)) == -18.0) || (((x_6 + (-1.0 * _x_x_21)) == -18.0) || (((x_4 + (-1.0 * _x_x_21)) == -5.0) || (((x_3 + (-1.0 * _x_x_21)) == -8.0) || (((x_1 + (-1.0 * _x_x_21)) == -16.0) || ((x_2 + (-1.0 * _x_x_21)) == -9.0)))))))))))))) && ((((x_20 + (-1.0 * _x_x_22)) <= -15.0) && (((x_15 + (-1.0 * _x_x_22)) <= -18.0) && (((x_14 + (-1.0 * _x_x_22)) <= -12.0) && (((x_13 + (-1.0 * _x_x_22)) <= -20.0) && (((x_12 + (-1.0 * _x_x_22)) <= -6.0) && (((x_11 + (-1.0 * _x_x_22)) <= -14.0) && (((x_9 + (-1.0 * _x_x_22)) <= -20.0) && (((x_8 + (-1.0 * _x_x_22)) <= -15.0) && (((x_6 + (-1.0 * _x_x_22)) <= -2.0) && (((x_4 + (-1.0 * _x_x_22)) <= -9.0) && (((x_2 + (-1.0 * _x_x_22)) <= -7.0) && ((x_3 + (-1.0 * _x_x_22)) <= -18.0)))))))))))) && (((x_20 + (-1.0 * _x_x_22)) == -15.0) || (((x_15 + (-1.0 * _x_x_22)) == -18.0) || (((x_14 + (-1.0 * _x_x_22)) == -12.0) || (((x_13 + (-1.0 * _x_x_22)) == -20.0) || (((x_12 + (-1.0 * _x_x_22)) == -6.0) || (((x_11 + (-1.0 * _x_x_22)) == -14.0) || (((x_9 + (-1.0 * _x_x_22)) == -20.0) || (((x_8 + (-1.0 * _x_x_22)) == -15.0) || (((x_6 + (-1.0 * _x_x_22)) == -2.0) || (((x_4 + (-1.0 * _x_x_22)) == -9.0) || (((x_2 + (-1.0 * _x_x_22)) == -7.0) || ((x_3 + (-1.0 * _x_x_22)) == -18.0)))))))))))))) && ((((x_22 + (-1.0 * _x_x_23)) <= -1.0) && (((x_21 + (-1.0 * _x_x_23)) <= -1.0) && (((x_20 + (-1.0 * _x_x_23)) <= -18.0) && (((x_18 + (-1.0 * _x_x_23)) <= -16.0) && (((x_17 + (-1.0 * _x_x_23)) <= -19.0) && (((x_13 + (-1.0 * _x_x_23)) <= -12.0) && (((x_8 + (-1.0 * _x_x_23)) <= -16.0) && (((x_7 + (-1.0 * _x_x_23)) <= -20.0) && (((x_6 + (-1.0 * _x_x_23)) <= -15.0) && (((x_3 + (-1.0 * _x_x_23)) <= -9.0) && (((x_0 + (-1.0 * _x_x_23)) <= -4.0) && ((x_2 + (-1.0 * _x_x_23)) <= -3.0)))))))))))) && (((x_22 + (-1.0 * _x_x_23)) == -1.0) || (((x_21 + (-1.0 * _x_x_23)) == -1.0) || (((x_20 + (-1.0 * _x_x_23)) == -18.0) || (((x_18 + (-1.0 * _x_x_23)) == -16.0) || (((x_17 + (-1.0 * _x_x_23)) == -19.0) || (((x_13 + (-1.0 * _x_x_23)) == -12.0) || (((x_8 + (-1.0 * _x_x_23)) == -16.0) || (((x_7 + (-1.0 * _x_x_23)) == -20.0) || (((x_6 + (-1.0 * _x_x_23)) == -15.0) || (((x_3 + (-1.0 * _x_x_23)) == -9.0) || (((x_0 + (-1.0 * _x_x_23)) == -4.0) || ((x_2 + (-1.0 * _x_x_23)) == -3.0)))))))))))))) && (((((_EL_U_1797 == (_x__EL_U_1797 || ( !((_x__EL_U_1795 && ( !(_x__EL_U_1793 || (-2.0 <= (_x_x_18 + (-1.0 * _x_x_22)))))) || ( !((_x_x_12 + (-1.0 * _x_x_17)) <= 17.0)))))) && ((_EL_U_1793 == (_x__EL_U_1793 || (-2.0 <= (_x_x_18 + (-1.0 * _x_x_22))))) && (_EL_U_1795 == ((_x__EL_U_1795 && ( !(_x__EL_U_1793 || (-2.0 <= (_x_x_18 + (-1.0 * _x_x_22)))))) || ( !((_x_x_12 + (-1.0 * _x_x_17)) <= 17.0)))))) && (_x__J1814 == (( !((_J1814 && _J1825) && _J1831)) && (((_J1814 && _J1825) && _J1831) || (((-2.0 <= (x_18 + (-1.0 * x_22))) || ( !((-2.0 <= (x_18 + (-1.0 * x_22))) || _EL_U_1793))) || _J1814))))) && (_x__J1825 == (( !((_J1814 && _J1825) && _J1831)) && (((_J1814 && _J1825) && _J1831) || ((( !((x_12 + (-1.0 * x_17)) <= 17.0)) || ( !(( !((x_12 + (-1.0 * x_17)) <= 17.0)) || (_EL_U_1795 && ( !((-2.0 <= (x_18 + (-1.0 * x_22))) || _EL_U_1793)))))) || _J1825))))) && (_x__J1831 == (( !((_J1814 && _J1825) && _J1831)) && (((_J1814 && _J1825) && _J1831) || ((( !(( !((x_12 + (-1.0 * x_17)) <= 17.0)) || (_EL_U_1795 && ( !((-2.0 <= (x_18 + (-1.0 * x_22))) || _EL_U_1793))))) || ( !(_EL_U_1797 || ( !(( !((x_12 + (-1.0 * x_17)) <= 17.0)) || (_EL_U_1795 && ( !((-2.0 <= (x_18 + (-1.0 * x_22))) || _EL_U_1793)))))))) || _J1831)))))); _J1831 = _x__J1831; _J1825 = _x__J1825; _J1814 = _x__J1814; x_4 = _x_x_4; _EL_U_1793 = _x__EL_U_1793; x_22 = _x_x_22; x_18 = _x_x_18; x_9 = _x_x_9; _EL_U_1795 = _x__EL_U_1795; x_5 = _x_x_5; x_17 = _x_x_17; x_11 = _x_x_11; x_12 = _x_x_12; _EL_U_1797 = _x__EL_U_1797; x_14 = _x_x_14; x_15 = _x_x_15; x_2 = _x_x_2; x_16 = _x_x_16; x_0 = _x_x_0; x_3 = _x_x_3; x_6 = _x_x_6; x_7 = _x_x_7; x_8 = _x_x_8; x_1 = _x_x_1; x_13 = _x_x_13; x_20 = _x_x_20; x_21 = _x_x_21; x_10 = _x_x_10; x_19 = _x_x_19; x_23 = _x_x_23; } }
the_stack_data/261660.c
#include <stdio.h> #include <unistd.h> #include <signal.h> #include <time.h> //#define FRAMESPERSEC 48000 #define FRAMESPERSEC 24000 #define MESSLEN FRAMESPERSEC * 17 FILE *logfile; char buffer[MESSLEN + 1]; int c; void handler(union sigval sv) { (void) sv; FILE* fp; float t; clock_t start,end; start = clock(); c++; fp = fopen("/proc/channel_in0", "w"); fread((void *)buffer, sizeof(char), MESSLEN, stdin); buffer[MESSLEN] = '\0'; fwrite((void *)buffer, sizeof(char), MESSLEN, fp); fflush(fp); fclose(fp); end = clock(); t = (float)(end - start) / CLOCKS_PER_SEC; fprintf(logfile, "handler execution time: %f\n", t); fflush(logfile); return; } int main() { timer_t tid; union sigval sv; struct sigevent se; struct itimerspec its; sv.sival_int = 0; se.sigev_value = sv; se.sigev_notify = SIGEV_THREAD; se.sigev_notify_function = handler; se.sigev_notify_attributes = NULL; if(timer_create(CLOCK_MONOTONIC, &se, &tid)) { printf("error creating the timer\n"); return 1; } its.it_interval.tv_sec = 1; its.it_interval.tv_nsec = 0; its.it_value.tv_sec = 1; its.it_value.tv_nsec = 0; c = 0; logfile = fopen("LOGSINK", "a"); if(timer_settime(tid, 0, &its, NULL)) { printf("error arming the timer\n"); return 2; } while(1) sleep(4); //printf("count: %d\n", c); return 0; }
the_stack_data/234518790.c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_range.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: esupatae <[email protected]> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/04/04 15:32:56 by esupatae #+# #+# */ /* Updated: 2019/04/04 15:33:01 by esupatae ### ########.fr */ /* */ /* ************************************************************************** */ #include <stdlib.h> #include <stdio.h> int *ft_range(int min, int max) { int *nums; int i; i = min; if (min < max) { nums = (int*)(malloc(sizeof(*nums) * (max - min - 1))); while (i < max) { printf("%i ", i); nums[i - min] = i; i++; } printf("\n"); } return (nums); } int main(void) { int *a; a = ft_range(2, 5); a = ft_range(0, 10); a = ft_range(-10, 10); a = ft_range(10, 20); return (0); }
the_stack_data/326899.c
#include <stdio.h> void intercambiar(int a, int b); int main() { // Intercambiar dos variables int x = 1; int y = 2; printf("[ANTES] x es: %i, Y es: %i\n", x, y); intercambiar(x,y); printf("[DESPUES] x es: %i, Y es: %i\n", x, y); } void intercambiar(int a, int b) { int tmp = a; a = b; b = tmp; }
the_stack_data/128447.c
float b[3], c, d; void main() { b[1]++; d++; d = b[1]++; c = d++; print ("b 0.000000 2.000000 0.000000"); printid(b); print ("c 1.000000"); printid(c); print ("d 2.000000"); printid(d); }
the_stack_data/234519418.c
/* * Copyright (c) 2021 Clemens Schuetz and Visionizer Technologies * All rights reserved. * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ int _start() { return 123; }
the_stack_data/225141933.c
#include <stdio.h> void calcula (float l, float *area, float *perimetro){ *area = l*l; *perimetro = 4*l; } int main (int argc, char **argv){ float lado, area, perimetro; printf("Insira o valor do lado do quadrado (separando por \".\" nas casas decimais): \n"); scanf("%f", &lado); calcula(lado, &area, &perimetro); printf("Lado: %.2f\nArea: %.2f\n Perimetro: %.2f", lado, area, perimetro); return 0; }
the_stack_data/148577318.c
/* topics: - two pointers - string - string matching - knuth-morris-pratt - rabin-karp difficulty: easy */ // Knuth-Morris-Pratt Pattern Search Algorithm int strStr(char* s, char* w) { // edge cases if (!w[0]) return 0; // empty needle if (!s[0]) return -1; // empty haystack // precompute table for KMP const int len_w = strlen(w); int* T = malloc((1 + len_w) * sizeof(int)); int pos = 1, cnd = 0; T[0] = -1; while (pos < len_w) { if (w[pos] == w[cnd]) { T[pos] = T[cnd]; } else { T[pos] = cnd; while (cnd >= 0 && w[pos] != w[cnd]) { cnd = T[cnd]; } } pos++; cnd++; } T[pos] = cnd; // start searching int k = 0, j = 0; while (s[j]) { if (s[j] == w[k]) { j++; k++; if (w[k] == '\0') { return j - k; } } else { k = T[k]; if (k < 0) { j++; k++; } } } free(T); return -1; }
the_stack_data/7950683.c
/** \addtogroup BSP \{ \addtogroup DEVICES \{ \addtogroup CPM \{ */ /** **************************************************************************************** * * @file hw_cpm.c * * @brief Clock and Power Manager Driver * * Copyright (c) 2016, Dialog Semiconductor * All rights reserved. * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. * * **************************************************************************************** */ #if dg_configUSE_HW_CPM #include <stdint.h> #include "hw_cpm.h" #include "hw_watchdog.h" /* * These variables should be defined and initialized by the framework/sdk used */ extern sys_clk_t cm_sysclk; extern ahb_div_t cm_ahbclk; /* * Global variables */ __RETAINED_UNINIT uint16_t hw_cpm_bod_enabled_in_tcs; #if (dg_configPOWER_1V8_ACTIVE == 1) __RETAINED_RW static bool cpm_1v8_state = true; #else static const bool cpm_1v8_state = false; #endif /* * Local variables */ /* * Forward declarations */ /* * Function definitions */ uint32_t hw_cpm_sysclk_is_rc16(void) { uint32_t ret = 0; if (REG_GETF(CRG_TOP, CLK_CTRL_REG, SYS_CLK_SEL) == SYS_CLK_IS_RC16) { ret = 1; } return ret; } uint32_t hw_cpm_sysclk_is_xtal16m(void) { uint32_t ret = 0; if (REG_GETF(CRG_TOP, CLK_CTRL_REG, SYS_CLK_SEL) == SYS_CLK_IS_XTAL16M) { ret = 1; } return ret; } void hw_cpm_set_divn(bool freq) { uint32_t regval; int val; if (freq) { val = 1; } else { val = 0; } regval = CRG_TOP->CLK_CTRL_REG; REG_SET_FIELD(CRG_TOP, CLK_CTRL_REG, DIVN_XTAL32M_MODE, regval, val); REG_SET_FIELD(CRG_TOP, CLK_CTRL_REG, XTAL32M_MODE, regval, val); CRG_TOP->CLK_CTRL_REG = regval; #if (dg_configBLACK_ORCA_IC_REV == BLACK_ORCA_IC_REV_A) CRG_TOP->DIVN_SYNC_REG = val; #endif } bool hw_cpm_is_rc16_allowed(void) { bool ret = false; uint32_t tmp; do { tmp = CRG_TOP->SYS_STAT_REG; #ifdef CONFIG_USE_FTDF // Check FTDF if (tmp & REG_MSK(CRG_TOP, SYS_STAT_REG, FTDF_IS_UP)) { break; } #endif #ifdef CONFIG_USE_BLE // Check BLE if (tmp & REG_MSK(CRG_TOP, SYS_STAT_REG, BLE_IS_UP)) { break; } #endif // Check APHY/DPHY & COEX if (tmp & REG_MSK(CRG_TOP, SYS_STAT_REG, RAD_IS_UP)) { break; } if (tmp & REG_MSK(CRG_TOP, SYS_STAT_REG, PER_IS_UP)) { // Check SRC if (REG_GETF(APU, SRC1_CTRL_REG, SRC_EN) == 1) { break; } // Check PDM if (REG_GETF(CRG_PER, PDM_DIV_REG, CLK_PDM_EN) == 1) { break; } // Check USB if (REG_GETF(USB, USB_MCTRL_REG, USBEN) == 1) { break; } tmp = CRG_PER->CLK_PER_REG; // Check UART1/2 if (tmp & REG_MSK(CRG_PER, CLK_PER_REG, UART_ENABLE)) { break; } /* -------------------------------------------------------------------------------*/ // Check ADC clock if (REG_GETF(GPADC, GP_ADC_CTRL_REG, GP_ADC_EN) && (!(tmp & REG_MSK(CRG_PER, CLK_PER_REG, ADC_CLK_SEL)))) { break; } // Check I2C clock if ((tmp & REG_MSK(CRG_PER, CLK_PER_REG, I2C_ENABLE)) && (!(tmp & REG_MSK(CRG_PER, CLK_PER_REG, I2C_CLK_SEL)))) { break; } // Check SPI clock if ((tmp & REG_MSK(CRG_PER, CLK_PER_REG, SPI_ENABLE)) && (!(tmp & REG_MSK(CRG_PER, CLK_PER_REG, SPI_CLK_SEL)))) { break; } // Check PCM clock tmp = CRG_PER->PCM_DIV_REG; if ((tmp & REG_MSK(CRG_PER, PCM_DIV_REG, CLK_PCM_EN)) && (!(tmp & REG_MSK(CRG_PER, PCM_DIV_REG, PCM_SRC_SEL)))) { break; } /* KBSCN and QUAD are not seriously affected by the clock switch and, thus, * they cannot block it! */ } tmp = CRG_TOP->CLK_TMR_REG; // Check Timer0 clock if ((tmp & REG_MSK(CRG_TOP, CLK_TMR_REG, TMR0_ENABLE)) && (!(tmp & REG_MSK(CRG_TOP, CLK_TMR_REG, TMR0_CLK_SEL)))) { break; } // Check Timer2 clock if ((tmp & REG_MSK(CRG_TOP, CLK_TMR_REG, TMR2_ENABLE)) && (!(tmp & REG_MSK(CRG_TOP, CLK_TMR_REG, TMR2_CLK_SEL)))) { break; } /* Breathe, SOC and WDOG are not seriously affected by the clock switch and, thus, * they cannot block it! */ ret = true; } while (0); return ret; } void hw_cpm_set_sysclk(uint32_t mode) { /* Make sure a valid sys clock is requested */ ASSERT_WARNING(mode <= SYS_CLK_IS_PLL); REG_SETF(CRG_TOP, CLK_CTRL_REG, SYS_CLK_SEL, mode); // Wait until the switch is done! switch (mode) { case SYS_CLK_IS_XTAL16M: while (REG_GETF(CRG_TOP, CLK_CTRL_REG, RUNNING_AT_XTAL16M) == 0) {} break; case SYS_CLK_IS_RC16: while (REG_GETF(CRG_TOP, CLK_CTRL_REG, RUNNING_AT_RC16M) == 0) {} break; case SYS_CLK_IS_LP: while (REG_GETF(CRG_TOP, CLK_CTRL_REG, RUNNING_AT_32K) == 0) {} break; case SYS_CLK_IS_PLL: while (REG_GETF(CRG_TOP, CLK_CTRL_REG, RUNNING_AT_PLL96M) == 0) {} break; default: ASSERT_WARNING(0); break; } } void hw_cpm_short_delay(void) { volatile int i; for (i = 0; i < 20; i++); } void hw_cpm_pll_sys_on(void) { /* Before enabling the PLL LDO, the 1.4V voltage needs to be present; in real-life this * is achieved by first turning on the 1.4V ACORE LDO, then the DCDC converter to take over * the generation of 1.4V and finally turning off the ACORE LDO. */ /* LDO PLL enable. */ REG_SET_BIT(GPREG, PLL_SYS_CTRL1_REG, LDO_PLL_ENABLE); /* Configure system PLL. */ REG_SETF(GPREG, PLL_SYS_CTRL1_REG, PLL_R_DIV, 1); /* Default/reset value. */ /* Program N-divider and DEL_SEL. */ REG_SET_BIT(GPREG, PLL_SYS_CTRL2_REG, PLL_SEL_MIN_CUR_INT); // Last review date: Feb 15, 2016 - 12:25:47 /* Now turn on PLL. */ REG_SET_BIT(GPREG, PLL_SYS_CTRL1_REG, PLL_EN); while ((GPREG->PLL_SYS_STATUS_REG & REG_MSK(GPREG, PLL_SYS_STATUS_REG, LDO_PLL_OK)) == 0) {} /* And wait until lock. */ while ((GPREG->PLL_SYS_STATUS_REG & REG_MSK(GPREG, PLL_SYS_STATUS_REG, PLL_LOCK_FINE)) == 0) {} } void hw_cpm_pll_sys_off(void) { // The PLL is not the system clk. while ((CRG_TOP->CLK_CTRL_REG & REG_MSK(CRG_TOP, CLK_CTRL_REG, RUNNING_AT_PLL96M)) != 0); GPREG->PLL_SYS_CTRL1_REG = 0x0000; // Switch off the PLL. } __RETAINED_CODE void hw_cpm_start_calibration(cal_clk_t clk_type, uint32_t cycles) { ASSERT_WARNING(REG_GETF(ANAMISC, CLK_REF_SEL_REG, REF_CAL_START) == 0); // Must be disabled ANAMISC->CLK_REF_CNT_REG = cycles; // # of cal clock cycles REG_SETF(ANAMISC, CLK_REF_SEL_REG, REF_CLK_SEL, clk_type); REG_SET_BIT(ANAMISC, CLK_REF_SEL_REG, REF_CAL_START); } uint32_t hw_cpm_get_calibration_data(void) { uint32_t high; uint32_t low; uint32_t value; while (REG_GETF(ANAMISC, CLK_REF_SEL_REG, REF_CAL_START) == 1); // Wait until it's finished high = ANAMISC->CLK_REF_VAL_H_REG; low = ANAMISC->CLK_REF_VAL_L_REG; value = (high << 16) + low; return value; } void hw_cpm_dcdc_config(void) { uint32_t reg; /* * Preferred settings section * Last review date: Feb 15, 2016 - 12:25:47 */ REG_CLR_BIT(DCDC, DCDC_CTRL_0_REG, DCDC_FW_ENABLE); reg = DCDC->DCDC_IRQ_MASK_REG; REG_SET_FIELD(DCDC, DCDC_IRQ_MASK_REG, DCDC_V18P_TIMEOUT_IRQ_MASK, reg, 1); REG_SET_FIELD(DCDC, DCDC_IRQ_MASK_REG, DCDC_VDD_TIMEOUT_IRQ_MASK, reg, 1); REG_SET_FIELD(DCDC, DCDC_IRQ_MASK_REG, DCDC_V18_TIMEOUT_IRQ_MASK, reg, 1); REG_SET_FIELD(DCDC, DCDC_IRQ_MASK_REG, DCDC_V14_TIMEOUT_IRQ_MASK, reg, 1); DCDC->DCDC_IRQ_MASK_REG = reg; REG_SET_BIT(DCDC, DCDC_TRIM_REG, DCDC_P_COMP_MAN_TRIM); DCDC->DCDC_V14_0_REG &= ~(REG_MSK(DCDC, DCDC_V14_0_REG, DCDC_V14_CUR_LIM_MIN) | REG_MSK(DCDC, DCDC_V14_0_REG, DCDC_V14_FAST_RAMPING)); DCDC->DCDC_V18_0_REG &= ~(REG_MSK(DCDC, DCDC_V18_0_REG, DCDC_V18_CUR_LIM_MIN) | REG_MSK(DCDC, DCDC_V18_0_REG, DCDC_V18_FAST_RAMPING)); DCDC->DCDC_V18P_0_REG &= ~(REG_MSK(DCDC, DCDC_V18P_0_REG, DCDC_V18P_CUR_LIM_MIN) | REG_MSK(DCDC, DCDC_V18P_0_REG, DCDC_V18P_FAST_RAMPING)); DCDC->DCDC_VDD_0_REG &= ~(REG_MSK(DCDC, DCDC_VDD_0_REG, DCDC_VDD_CUR_LIM_MIN) | REG_MSK(DCDC, DCDC_VDD_0_REG, DCDC_VDD_FAST_RAMPING)); REG_SETF(DCDC, DCDC_VDD_1_REG, DCDC_VDD_CUR_LIM_MAX_LV, 0xD); REG_SETF(DCDC, DCDC_V14_0_REG, DCDC_V14_VOLTAGE, 0x7); if (dg_configPOWER_1V8_ACTIVE == 1) { REG_SETF(DCDC, DCDC_V18_0_REG, DCDC_V18_VOLTAGE, 0x16); } if (dg_configPOWER_1V8P == 1) { REG_SETF(DCDC, DCDC_V18P_0_REG, DCDC_V18P_VOLTAGE, 0x16); } // End of preferred settings DCDC->DCDC_VDD_1_REG |= ((1 << REG_POS(DCDC, DCDC_VDD_1_REG, DCDC_VDD_ENABLE_HV)) | (1 << REG_POS(DCDC, DCDC_VDD_1_REG, DCDC_VDD_ENABLE_LV))); if ((dg_configPOWER_1V8_ACTIVE == 1) && cpm_1v8_state) { DCDC->DCDC_V18_1_REG |= (1 << REG_POS(DCDC, DCDC_V18_1_REG, DCDC_V18_ENABLE_HV)); DCDC->DCDC_V18_1_REG &= ~REG_MSK(DCDC, DCDC_V18_1_REG, DCDC_V18_ENABLE_LV); } else { DCDC->DCDC_V18_1_REG &= ~(REG_MSK(DCDC, DCDC_V18_1_REG, DCDC_V18_ENABLE_HV) | REG_MSK(DCDC, DCDC_V18_1_REG, DCDC_V18_ENABLE_LV)); } if (dg_configPOWER_1V8P == 1) { DCDC->DCDC_V18P_1_REG |= (1 << REG_POS(DCDC, DCDC_V18P_1_REG, DCDC_V18P_ENABLE_HV)); DCDC->DCDC_V18P_1_REG &= ~REG_MSK(DCDC, DCDC_V18P_1_REG, DCDC_V18P_ENABLE_LV); } else { DCDC->DCDC_V18P_1_REG &= ~(REG_MSK(DCDC, DCDC_V18P_1_REG, DCDC_V18P_ENABLE_HV) | REG_MSK(DCDC, DCDC_V18P_1_REG, DCDC_V18P_ENABLE_LV)); } } void hw_cpm_dcdc_on(void) { DCDC->DCDC_V14_1_REG |= ((1 << REG_POS(DCDC, DCDC_V14_1_REG, DCDC_V14_ENABLE_HV)) | (1 << REG_POS(DCDC, DCDC_V14_1_REG, DCDC_V14_ENABLE_LV))); REG_SETF(DCDC, DCDC_VDD_0_REG, DCDC_VDD_VOLTAGE, 0x10); // 1.2 V REG_SETF(DCDC, DCDC_CTRL_0_REG, DCDC_MODE, 1); // Trim the LDOs down to lowest possible voltage so DCDC can take over CRG_TOP->LDO_CTRL1_REG &= ~REG_MSK(CRG_TOP, LDO_CTRL1_REG, LDO_RADIO_SETVDD); REG_SETF(CRG_TOP, LDO_CTRL1_REG, LDO_CORE_SETVDD, 0x2); // Turn off LDOs CRG_TOP->LDO_CTRL1_REG &= ~REG_MSK(CRG_TOP, LDO_CTRL1_REG, LDO_RADIO_ENABLE); CRG_TOP->LDO_CTRL2_REG &= ~(REG_MSK(CRG_TOP, LDO_CTRL2_REG, LDO_1V2_ON) | REG_MSK(CRG_TOP, LDO_CTRL2_REG, LDO_1V8_FLASH_ON) | REG_MSK(CRG_TOP, LDO_CTRL2_REG, LDO_1V8_PA_ON)); // Trim the LDOs back to normal levels hw_cpm_reset_radio_vdd(); CRG_TOP->LDO_CTRL1_REG &= ~REG_MSK(CRG_TOP, LDO_CTRL1_REG, LDO_CORE_SETVDD); } void hw_cpm_set_preferred_values(void) { uint32_t reg; reg = CRG_TOP->CLK_16M_REG; REG_SET_FIELD(CRG_TOP, CLK_16M_REG, XTAL16_HPASS_FLT_EN, reg, 1); // Last review date: Feb 15, 2016 - 12:25:47 REG_SET_FIELD(CRG_TOP, CLK_16M_REG, XTAL16_AMP_TRIM, reg, 5); REG_SET_FIELD(CRG_TOP, CLK_16M_REG, XTAL16_CUR_SET, reg, 5); CRG_TOP->CLK_16M_REG = reg; REG_SETF(CRG_TOP, BANDGAP_REG, LDO_SLEEP_TRIM, 0x8); #if dg_configBLACK_ORCA_IC_REV == BLACK_ORCA_IC_REV_A REG_SETF(CRG_TOP, BANDGAP_REG, BYPASS_COLD_BOOT_DISABLE, 1); // Last review date: Feb 15, 2016 - 12:25:47 #endif } void hw_cpm_configure_xtal32k_pins(void) { GPIO->P20_MODE_REG = 0x26; GPIO->P21_MODE_REG = 0x26; } void hw_cpm_configure_ext32k_pins(void) { GPIO->P20_MODE_REG = 0x0; } void hw_cpm_trigger_sw_cursor(void) { if (dg_configUSE_SW_CURSOR == 1) { if (dg_configBLACK_ORCA_MB_REV == BLACK_ORCA_MB_REV_D) { SW_CURSOR_SET = 1 << SW_CURSOR_PIN; } else { SW_CURSOR_RESET = 1 << SW_CURSOR_PIN; } SW_CURSOR_GPIO = 0x300; hw_cpm_delay_usec(50); if (dg_configBLACK_ORCA_MB_REV == BLACK_ORCA_MB_REV_D) { SW_CURSOR_RESET = 1 << SW_CURSOR_PIN; } hw_cpm_setup_sw_cursor(); } } void hw_cpm_reset_system(void) { __asm volatile(" cpsid i "); hw_watchdog_unregister_int(); hw_watchdog_set_pos_val(1); hw_watchdog_unfreeze(); while (1); } void hw_cpm_reboot_system(void) { __asm volatile(" cpsid i "); hw_watchdog_gen_RST(); hw_watchdog_set_pos_val(1); hw_watchdog_unfreeze(); while (1); } void hw_cpm_assert_trigger_gpio(void) { if (EXCEPTION_DEBUG == 1) { if (dg_configLP_CLK_SOURCE == LP_CLK_IS_DIGITAL) { hw_cpm_configure_ext32k_pins(); } else if ((dg_configUSE_LP_CLK == LP_CLK_32000) || (dg_configUSE_LP_CLK == LP_CLK_32768)) { hw_cpm_configure_xtal32k_pins(); } hw_cpm_power_up_per_pd(); hw_cpm_deactivate_pad_latches(); DBG_SET_HIGH(EXCEPTION_DEBUG, EXCEPTIONDBG); } } #define HW_CPM_ACTIVATE_BOD_PROTECTION \ do { \ uint16_t val = 0; \ \ REG_SETF(CRG_TOP, BOD_CTRL_REG, BOD_VDD_LVL, 1); /* VDD Level (700mV) */ \ \ if (hw_cpm_bod_enabled_in_tcs == 0) { \ val = 0; \ /* VBAT enable */ \ REG_SET_FIELD(CRG_TOP, BOD_CTRL2_REG, BOD_VBAT_EN, val, 1); \ /* 1V8 Flash enable */ \ if ((dg_configPOWER_1V8_ACTIVE == 1) && (dg_configPOWER_1V8_SLEEP == 1)) { \ REG_SET_FIELD(CRG_TOP, BOD_CTRL2_REG, BOD_1V8_FLASH_EN, val, 1); \ } \ /* 1V8P enable */ \ if (dg_configPOWER_1V8P == 1) { \ REG_SET_FIELD(CRG_TOP, BOD_CTRL2_REG, BOD_1V8_PA_EN, val, 1); \ } \ REG_SET_FIELD(CRG_TOP, BOD_CTRL2_REG, BOD_VDD_EN, val, 1); /* VDD enable */ \ REG_SET_FIELD(CRG_TOP, BOD_CTRL2_REG, BOD_RESET_EN, val, 1); /* Reset enable */\ CRG_TOP->BOD_CTRL2_REG = val; \ } \ else { \ CRG_TOP->BOD_CTRL2_REG = hw_cpm_bod_enabled_in_tcs; \ } \ } while (0); void hw_cpm_activate_bod_protection(void) { HW_CPM_ACTIVATE_BOD_PROTECTION } void hw_cpm_activate_bod_protection_at_init(void) { HW_CPM_ACTIVATE_BOD_PROTECTION } void hw_cpm_configure_bod_protection(void) { REG_SETF(CRG_TOP, BOD_CTRL_REG, BOD_VDD_LVL, 1); /* VDD Level (700mV) */ if (hw_cpm_bod_enabled_in_tcs == 0) { /* VBAT enable */ REG_SET_BIT(CRG_TOP, BOD_CTRL2_REG, BOD_VBAT_EN); /* 1V8 Flash enable */ if ((dg_configPOWER_1V8_ACTIVE == 1) && (dg_configPOWER_1V8_SLEEP == 1)) { REG_SET_BIT(CRG_TOP, BOD_CTRL2_REG, BOD_1V8_FLASH_EN); } else { REG_CLR_BIT(CRG_TOP, BOD_CTRL2_REG, BOD_1V8_FLASH_EN); } /* 1V8P enable */ if (dg_configPOWER_1V8P == 1) { REG_SET_BIT(CRG_TOP, BOD_CTRL2_REG, BOD_1V8_PA_EN); } else { REG_CLR_BIT(CRG_TOP, BOD_CTRL2_REG, BOD_1V8_PA_EN); } /* Generate Reset on a BOD event */ REG_SET_BIT(CRG_TOP, BOD_CTRL2_REG, BOD_RESET_EN); } else { CRG_TOP->BOD_CTRL2_REG = hw_cpm_bod_enabled_in_tcs; } } void hw_cpm_set_1v8_state(bool state) { if ((dg_configPOWER_1V8_ACTIVE == 1) && (cpm_1v8_state != state)) { uint32_t reg; uint32_t dcdc_state; GLOBAL_INT_DISABLE(); reg = CRG_TOP->LDO_CTRL2_REG; dcdc_state = (uint32_t)REG_GETF(DCDC, DCDC_CTRL_0_REG, DCDC_MODE); #if (dg_configPOWER_1V8_ACTIVE == 1) cpm_1v8_state = state; #endif if (!cpm_1v8_state) { // Disable BOD for the 1V8 rail if (dg_configUSE_BOD == 1) { REG_CLR_BIT(CRG_TOP, BOD_CTRL2_REG, BOD_1V8_FLASH_EN); } // Deactivate 1V8 rail in LDOs REG_CLR_FIELD(CRG_TOP, LDO_CTRL2_REG, LDO_1V8_FLASH_ON, reg); if (dg_configPOWER_1V8_SLEEP == 1) { REG_SET_FIELD(CRG_TOP, LDO_CTRL2_REG, LDO_1V8_FLASH_RET_DISABLE, reg, 1); } CRG_TOP->LDO_CTRL2_REG = reg; // Deactivate 1V8 rail in DCDC if (dg_configUSE_DCDC == 1) { // Disable DCDC to apply change REG_SETF(DCDC, DCDC_CTRL_0_REG, DCDC_MODE, 0); DCDC->DCDC_V18_1_REG &= ~(REG_MSK(DCDC, DCDC_V18_1_REG, DCDC_V18_ENABLE_HV) | REG_MSK(DCDC, DCDC_V18_1_REG, DCDC_V18_ENABLE_LV)); // Restore DCDC REG_SETF(DCDC, DCDC_CTRL_0_REG, DCDC_MODE, dcdc_state); } } else { // Restore 1V8 rail in LDOs /* But not when DCDC is running... */ if (dcdc_state != 1) { REG_SET_FIELD(CRG_TOP, LDO_CTRL2_REG, LDO_1V8_FLASH_ON, reg, 1); } if (dg_configPOWER_1V8_SLEEP == 1) { REG_CLR_FIELD(CRG_TOP, LDO_CTRL2_REG, LDO_1V8_FLASH_RET_DISABLE, reg); } CRG_TOP->LDO_CTRL2_REG = reg; // Restore 1V8 rail in DCDC if (dg_configUSE_DCDC == 1) { DCDC->DCDC_V18_1_REG |= (1 << REG_POS(DCDC, DCDC_V18_1_REG, DCDC_V18_ENABLE_HV)); DCDC->DCDC_V18_1_REG &= ~REG_MSK(DCDC, DCDC_V18_1_REG, DCDC_V18_ENABLE_LV); } // Restore BOD setup if (dg_configUSE_BOD == 1) { hw_cpm_delay_usec(200); hw_cpm_configure_bod_protection(); } } GLOBAL_INT_RESTORE(); } } bool hw_cpm_get_1v8_state(void) { return cpm_1v8_state; } void hw_cpm_delay_usec(uint32_t usec) { sys_clk_t sclk; ahb_div_t hclk; uint8_t freq; sclk = cm_sysclk; hclk = cm_ahbclk; freq = 16 >> hclk; /* Requested delay time must be > 0 usec */ ASSERT_WARNING(usec != 0); /* * ldr r3, [pc, #148] 2 cycles * push {r4, lr} 2 cycles * ldrb r1, [r3, #17] 2 cycles * ldrb r2, [r3, #8] 2 cycles * movs r3, #16 1 cycle * asrs r3, r2 1 cycle * uxtb r3, r2 1 cycle * ---------- * cmp r0, #0 4 cycles overhead in total * bne.n 0x8003106 <hw_cpm_delay_usec+30> * cpsid i * bkpt 0x0002 * * Total: 11 cycles */ __asm volatile(" cmp %[sclk], #1 \n" // 1 cycle : 1 (sysclk_RC16, sysclk_XTAL16M) " ble start \n" // 1 or 3 cycles: 2/4 " cmp %[sclk], #3 \n" // 1 cycle : 3 (sysclk_PLL48) " bgt s96M \n" // 1 or 3 cycles: 4/6 " blt s32M \n" // 1 or 3 cycles: 5/7 "s48M: add r4, %[freq], %[freq] \n" // 1 cycle : 6 " add %[freq], r4, %[freq] \n" // 1 cycle : 7 " b start \n" // 3 cycles : 10 "s96M: add r4, %[freq], %[freq] \n" // 1 cycle : 7 " add %[freq], r4, %[freq] \n" // 1 cycle : 8 " lsl %[freq], %[freq], #1 \n" // 1 cycle : 9 " b start \n" // 3 cycles : 12 "s32M: lsl %[freq], %[freq], #1 \n" // 1 cycle : 8 /* -----------------------------------------------------*/ /* Overhead up to this point: * sysclk_RC16 : 15 cycles (error: 15/16 - 15 usec) * sysclk_XTAL16M : 15 cycles (error: 15/16 - 15 usec) * sysclk_XTAL32M : 19 cycles (error: 19/32 - 19/2 usec) * sysclk_PLL48 : 21 cycles (error: 21/48 - 21/3 usec) * sysclk_PLL96 : 23 cycles (error: 23/96 - 23/6 usec) */ "start: cmp %[freq], #16 \n" // 1 cycle : 1 " bgt high \n" // 1 or 3 cycles: 2/4 " blt low \n" // 1 or 3 cycles: 3/5 " mov %[sclk], #4 \n" // 1 cycle : 4 " b calc \n" // 3 cycles : 7 "high: cmp %[freq], #24 \n" // 1 cycle : 5 " bne c32M \n" // 1 or 3 cycles: 6/8 " mov %[sclk], #6 \n" // 1 cycle : 7 " b calc \n" // 3 cycles : 10 "c32M: cmp %[freq], #32 \n" // 1 cycle : 9 " bne c48M \n" // 1 or 3 cycles: 10/12 " mov %[sclk], #8 \n" // 1 cycle : 11 " b calc \n" // 3 cycles : 12 "c48M: cmp %[freq], #48 \n" // 1 cycle : 13 " bne c96M \n" // 1 or 3 cycles: 14/16 " mov %[sclk], #12 \n" // 1 cycle : 15 " b calc \n" // 3 cycles : 18 "c96M: mov %[sclk], #24 \n" // 1 cycle : 17 " b calc \n" // 3 cycles : 20 "low: cmp %[freq], #1 \n" // 1 cycle : 6 " bgt c2M \n" // 1 or 3 cycles: 7/9 " lsr %[usec], %[usec], #2 \n" // 1 cycle : 8 " b loop \n" // 3 cycles : 11 "c2M: cmp %[freq], #2 \n" // 1 cycle : 10 " bgt c3M \n" // 1 or 3 cycles: 11/13 " lsr %[usec], %[usec], #1 \n" // 1 cycle : 12 " b loop \n" // 3 cycles : 15 "c3M: cmp %[freq], #3 \n" // 1 cycle : 14 " bgt c4M \n" // 1 or 3 cycles: 15/17 " lsr %[usec], %[usec], #1 \n" // 1 cycle : 16 " b loop1 \n" // 3 cycles : 19 "c4M: cmp %[freq], #4 \n" // 1 cycle : 18 " bgt c6M \n" // 1 or 3 cycles: 19/21 " b loop \n" // 3 cycles : 22 "c6M: cmp %[freq],#6 \n" // 1 cycle : 22 " bgt c8M \n" // 1 or 3 cycles: 23/25 " b loop1 \n" // 3 cycles : 26 "c8M: cmp %[freq], #8 \n" // 1 cycle : 26 " bgt c12M \n" // 1 or 3 cycles: 27/29 " mov %[sclk], #2 \n" // 1 cycle : 28 " b calc \n" // 3 cycles : 31 "c12M: mov %[sclk], #2 \n" // 1 cycle : 30 " mul %[usec], %[sclk], %[usec] \n" // 1 cycle : 31 /* Error: * 1MHz: 11 cycles, 11usec * 2MHz: 15 cycles, 7.5usec * 3MHz: 19 cycles, 6.33usec * 4MHz: 22 cycles, 5.5usec * 6MHz: 26 cycles, 4.33usec * 8MHz: 31 cycles, 3.875usec * 12MHz: 31 cycles, 2.584usec * 16MHz: 8 cycles, 0.5usec * 24MHz: 11 cycles, 0.459usec * 32MHz: 13 cycles, 0.406usec * 48MHz: 19 cycles, 0.396usec * 96MHz: 21 cycles, 0.219usec * * 1 loop of 4 cycles is --- 1 usec is # loops * 1MHz: 4usec --- divide (usec) by 4 (up to 5usec error) * 2MHz: 2usec --- divide (usec) by 2 (up to 2usec error) * 4MHz: 1usec --- 1 loop ( 0*4 + 1*2, 0.5000usec error) * 8MHz: 500nsec --- 2 loops ( 1*4 + 1*2, 0.2500usec error) * 16MHz: 250nsec --- 4 loops ( 3*4 + 1*2, 0.5000usec error) * 24MHz: 167nsec --- 6 loops ( 5*4 + 1*2, 0.0830usec error) * 32MHz: 125nsec --- 8 loops ( 7*4 + 1*2, 0.0625usec error) * 48MHz: 84nsec --- 12 loops (11*4 + 1*2, 0.0420usec error) * 96MHz: 42nsec --- 24 loops (23*4 + 1*2, 0.0210usec error) * * 1 loop of 6 cycles is --- 1 usec is # loops * 3MHz: 2usec --- divide (usec) by 2 (up to 3usec error) * 6MHz: 1usec --- 1 loop ( 0*6 + 1*7, 0.1670usec error) * 12MHz: 0.5usec --- 2 loops ( 1*6 + 1*7, 0.0830usec error) * * Cumulative error is: * 1MHz: 11 + 5 = 16usec * 2MHz: 7.5 + 2 = 9.5usec * 3MHz: 6.33 + 3 = 9.33usec * 4MHz: 5.5 + 0.5 = 6usec * 6MHz: 4.33 + 0.167 = 4.5usec * 8MHz: 3.875 + 0.25 = 4.125usec * 12MHz: 2.584 + 0.083 = 2.67usec * 16MHz: 0.5 + 0.5 = 1usec * 24MHz: 0.459 + 0.083 = 0.541usec * 32MHz: 0.406 + 0.0625 = 0.469usec * 48MHz: 0.396 + 0.042 = 0.438usec * 96MHz: 0.219 + 0.021 = 0.429usec */ "loop1: sub %[usec], %[usec], #1 \n" // 1 cycle " nop \n" // 1 cycle " nop \n" // 1 cycle " bne loop1 \n" // 3 cycles except for the last one which is 1 " b exit \n" // 3 cycles "calc: mul %[usec], %[sclk], %[usec] \n" // 1 cycle "loop: sub %[usec], %[usec], #1 \n" // 1 cycle " bne loop \n" // 3 cycles except for the last one which is 1 "exit: \n" : : /* output */ [usec] "r"(usec), [freq] "r"(freq), [sclk] "r"(sclk) : /* inputs (%0, %1, %2) */ "r4"); /* registers that are destroyed */ } #endif /* dg_configUSE_HW_CPM */ /** \} \} \} */
the_stack_data/145454353.c
extern int __VERIFIER_nondet_int(); extern void __VERIFIER_error(); int id(int x) { if (x==0) return 0; return id(x-1) + 1; } int main(void) { int input = __VERIFIER_nondet_int(); int result = id(input); if (result == 200) { ERROR: __VERIFIER_error(); } }
the_stack_data/82951339.c
// INFO: task can't die in inet_twsk_purge // https://syzkaller.appspot.com/bug?id=4c1b0c5364346e7beafa // status:0 // 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 <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.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> 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; } #define BITMASK(bf_off, bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type, htobe, addr, val, bf_off, bf_len) \ *(type*)(addr) = \ htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | \ (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) 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; } static long syz_open_procfs(volatile long a0, volatile long a1) { char buf[128]; memset(buf, 0, sizeof(buf)); if (a0 == 0) { snprintf(buf, sizeof(buf), "/proc/self/%s", (char*)a1); } else if (a0 == -1) { snprintf(buf, sizeof(buf), "/proc/thread-self/%s", (char*)a1); } else { snprintf(buf, sizeof(buf), "/proc/self/task/%d/%s", (int)a0, (char*)a1); } int fd = open(buf, O_RDWR); if (fd == -1) fd = open(buf, O_RDONLY); return fd; } static void kill_and_wait(int pid, int* status) { kill(-pid, SIGKILL); kill(pid, SIGKILL); for (int 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 = 0; for (;; 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) { *(uint32_t*)0x20000100 = 1; *(uint32_t*)0x20000104 = 0x70; *(uint8_t*)0x20000108 = 0; *(uint8_t*)0x20000109 = 0; *(uint8_t*)0x2000010a = 0; *(uint8_t*)0x2000010b = 0; *(uint32_t*)0x2000010c = 0; *(uint64_t*)0x20000110 = 0x3c43; *(uint64_t*)0x20000118 = 0; *(uint64_t*)0x20000120 = 0; STORE_BY_BITMASK(uint64_t, , 0x20000128, 0, 0, 1); STORE_BY_BITMASK(uint64_t, , 0x20000128, 0, 1, 1); STORE_BY_BITMASK(uint64_t, , 0x20000128, 0, 2, 1); STORE_BY_BITMASK(uint64_t, , 0x20000128, 0, 3, 1); STORE_BY_BITMASK(uint64_t, , 0x20000128, 0, 4, 1); STORE_BY_BITMASK(uint64_t, , 0x20000128, 0, 5, 1); STORE_BY_BITMASK(uint64_t, , 0x20000128, 0, 6, 1); STORE_BY_BITMASK(uint64_t, , 0x20000128, 0, 7, 1); STORE_BY_BITMASK(uint64_t, , 0x20000128, 0, 8, 1); STORE_BY_BITMASK(uint64_t, , 0x20000128, 0, 9, 1); STORE_BY_BITMASK(uint64_t, , 0x20000128, 0, 10, 1); STORE_BY_BITMASK(uint64_t, , 0x20000128, 0, 11, 1); STORE_BY_BITMASK(uint64_t, , 0x20000128, 0, 12, 1); STORE_BY_BITMASK(uint64_t, , 0x20000128, 0, 13, 1); STORE_BY_BITMASK(uint64_t, , 0x20000128, 0, 14, 1); STORE_BY_BITMASK(uint64_t, , 0x20000128, 0, 15, 2); STORE_BY_BITMASK(uint64_t, , 0x20000128, 0, 17, 1); STORE_BY_BITMASK(uint64_t, , 0x20000128, 0, 18, 1); STORE_BY_BITMASK(uint64_t, , 0x20000128, 0, 19, 1); STORE_BY_BITMASK(uint64_t, , 0x20000128, 0, 20, 1); STORE_BY_BITMASK(uint64_t, , 0x20000128, 0, 21, 1); STORE_BY_BITMASK(uint64_t, , 0x20000128, 0, 22, 1); STORE_BY_BITMASK(uint64_t, , 0x20000128, 0, 23, 1); STORE_BY_BITMASK(uint64_t, , 0x20000128, 0, 24, 1); STORE_BY_BITMASK(uint64_t, , 0x20000128, 0, 25, 1); STORE_BY_BITMASK(uint64_t, , 0x20000128, 0, 26, 1); STORE_BY_BITMASK(uint64_t, , 0x20000128, 0, 27, 1); STORE_BY_BITMASK(uint64_t, , 0x20000128, 0, 28, 1); STORE_BY_BITMASK(uint64_t, , 0x20000128, 0, 29, 35); *(uint32_t*)0x20000130 = 0; *(uint32_t*)0x20000134 = 0; *(uint64_t*)0x20000138 = 0; *(uint64_t*)0x20000140 = 0; *(uint64_t*)0x20000148 = 0; *(uint64_t*)0x20000150 = 0; *(uint32_t*)0x20000158 = 0; *(uint32_t*)0x2000015c = 0; *(uint64_t*)0x20000160 = 0; *(uint32_t*)0x20000168 = 0; *(uint16_t*)0x2000016c = 0; *(uint16_t*)0x2000016e = 0; syscall(__NR_perf_event_open, 0x20000100ul, 0, -1ul, -1, 0ul); syscall(__NR_unshare, 0x40000000ul); syscall(__NR_perf_event_open, 0ul, 0, 0xfbfffffffffffffful, -1, 0ul); syscall(__NR_mmap, 0x20000000ul, 0xb36000ul, 0xb635773f06ebbeeeul, 0x8031ul, -1, 0ul); syz_open_procfs(0, 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); for (procid = 0; procid < 6; procid++) { if (fork() == 0) { loop(); } } sleep(1000000); return 0; }
the_stack_data/29447.c
#include <stdio.h> #include <math.h> void dswap(double *a, double *b) { double t = *a; *a = *b; *b = t; } double val[109][109]; int ref[109]; int main(void) { int n; int i, j, k; scanf("%d", &n); for (i = 0; i < n; ++i) for (j = 0; j <= n; ++j) scanf("%lf", &val[i][j]); for (i = 0; i < n; ++i) ref[i] = i; for (i = 0; i < n; ++i) { int m = i; for (j = i + 1; j < n; ++j) if (fabs(val[j][i]) > fabs(val[m][i])) m = j; if (fabs(val[m][i]) < 1e-6) { puts("No Solution"); return 0; } for (j = 0; j <= n; ++j) dswap(&val[i][j], &val[m][j]); for (j = i + 1; j < n; ++j) for (k = n; k >= i; --k) val[j][k] -= val[i][k] * val[j][i] / val[i][i]; } for (i = n - 1; i >= 0; --i) { val[i][n] /= val[i][i]; for (j = i - 1; j >= 0; --j) val[j][n] -= val[j][i] * val[i][n]; } for (i = 0; i < n; ++i) printf("%.2f\n", val[ref[i]][n]); return 0; }
the_stack_data/566752.c
// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -disable-llvm-passes -o - | FileCheck %s typedef float float4 __attribute__((ext_vector_type(4))); typedef short int si8 __attribute__((ext_vector_type(8))); typedef unsigned int u4 __attribute__((ext_vector_type(4))); __attribute__((address_space(1))) float4 vf1_as_one; void test_builtin_reduce_max(float4 vf1, si8 vi1, u4 vu1) { // CHECK-LABEL: define void @test_builtin_reduce_max( // CHECK: [[VF1:%.+]] = load <4 x float>, <4 x float>* %vf1.addr, align 16 // CHECK-NEXT: call float @llvm.vector.reduce.fmax.v4f32(<4 x float> [[VF1]]) float r1 = __builtin_reduce_max(vf1); // CHECK: [[VI1:%.+]] = load <8 x i16>, <8 x i16>* %vi1.addr, align 16 // CHECK-NEXT: call i16 @llvm.vector.reduce.smax.v8i16(<8 x i16> [[VI1]]) short r2 = __builtin_reduce_max(vi1); // CHECK: [[VU1:%.+]] = load <4 x i32>, <4 x i32>* %vu1.addr, align 16 // CHECK-NEXT: call i32 @llvm.vector.reduce.umax.v4i32(<4 x i32> [[VU1]]) unsigned r3 = __builtin_reduce_max(vu1); // CHECK: [[VF1_AS1:%.+]] = load <4 x float>, <4 x float> addrspace(1)* @vf1_as_one, align 16 // CHECK-NEXT: [[RDX1:%.+]] = call float @llvm.vector.reduce.fmax.v4f32(<4 x float> [[VF1_AS1]]) // CHECK-NEXT: fpext float [[RDX1]] to double const double r4 = __builtin_reduce_max(vf1_as_one); // CHECK: [[CVI1:%.+]] = load <8 x i16>, <8 x i16>* %cvi1, align 16 // CHECK-NEXT: [[RDX2:%.+]] = call i16 @llvm.vector.reduce.smax.v8i16(<8 x i16> [[CVI1]]) // CHECK-NEXT: sext i16 [[RDX2]] to i64 const si8 cvi1 = vi1; unsigned long long r5 = __builtin_reduce_max(cvi1); } void test_builtin_reduce_min(float4 vf1, si8 vi1, u4 vu1) { // CHECK-LABEL: define void @test_builtin_reduce_min( // CHECK: [[VF1:%.+]] = load <4 x float>, <4 x float>* %vf1.addr, align 16 // CHECK-NEXT: call float @llvm.vector.reduce.fmin.v4f32(<4 x float> [[VF1]]) float r1 = __builtin_reduce_min(vf1); // CHECK: [[VI1:%.+]] = load <8 x i16>, <8 x i16>* %vi1.addr, align 16 // CHECK-NEXT: call i16 @llvm.vector.reduce.smin.v8i16(<8 x i16> [[VI1]]) short r2 = __builtin_reduce_min(vi1); // CHECK: [[VU1:%.+]] = load <4 x i32>, <4 x i32>* %vu1.addr, align 16 // CHECK-NEXT: call i32 @llvm.vector.reduce.umin.v4i32(<4 x i32> [[VU1]]) unsigned r3 = __builtin_reduce_min(vu1); // CHECK: [[VF1_AS1:%.+]] = load <4 x float>, <4 x float> addrspace(1)* @vf1_as_one, align 16 // CHECK-NEXT: [[RDX1:%.+]] = call float @llvm.vector.reduce.fmin.v4f32(<4 x float> [[VF1_AS1]]) // CHECK-NEXT: fpext float [[RDX1]] to double const double r4 = __builtin_reduce_min(vf1_as_one); // CHECK: [[CVI1:%.+]] = load <8 x i16>, <8 x i16>* %cvi1, align 16 // CHECK-NEXT: [[RDX2:%.+]] = call i16 @llvm.vector.reduce.smin.v8i16(<8 x i16> [[CVI1]]) // CHECK-NEXT: sext i16 [[RDX2]] to i64 const si8 cvi1 = vi1; unsigned long long r5 = __builtin_reduce_min(cvi1); } void test_builtin_reduce_xor(si8 vi1, u4 vu1) { // CHECK: [[VI1:%.+]] = load <8 x i16>, <8 x i16>* %vi1.addr, align 16 // CHECK-NEXT: call i16 @llvm.vector.reduce.xor.v8i16(<8 x i16> [[VI1]]) short r2 = __builtin_reduce_xor(vi1); // CHECK: [[VU1:%.+]] = load <4 x i32>, <4 x i32>* %vu1.addr, align 16 // CHECK-NEXT: call i32 @llvm.vector.reduce.xor.v4i32(<4 x i32> [[VU1]]) unsigned r3 = __builtin_reduce_xor(vu1); } void test_builtin_reduce_or(si8 vi1, u4 vu1) { // CHECK: [[VI1:%.+]] = load <8 x i16>, <8 x i16>* %vi1.addr, align 16 // CHECK-NEXT: call i16 @llvm.vector.reduce.or.v8i16(<8 x i16> [[VI1]]) short r2 = __builtin_reduce_or(vi1); // CHECK: [[VU1:%.+]] = load <4 x i32>, <4 x i32>* %vu1.addr, align 16 // CHECK-NEXT: call i32 @llvm.vector.reduce.or.v4i32(<4 x i32> [[VU1]]) unsigned r3 = __builtin_reduce_or(vu1); } void test_builtin_reduce_and(si8 vi1, u4 vu1) { // CHECK: [[VI1:%.+]] = load <8 x i16>, <8 x i16>* %vi1.addr, align 16 // CHECK-NEXT: call i16 @llvm.vector.reduce.and.v8i16(<8 x i16> [[VI1]]) short r2 = __builtin_reduce_and(vi1); // CHECK: [[VU1:%.+]] = load <4 x i32>, <4 x i32>* %vu1.addr, align 16 // CHECK-NEXT: call i32 @llvm.vector.reduce.and.v4i32(<4 x i32> [[VU1]]) unsigned r3 = __builtin_reduce_and(vu1); }
the_stack_data/168893843.c
extern int printf (char *, ...); main () { int a; a = 0; a = printf("%d\n",a); assert(a == 0); //UNKNOWN! }
the_stack_data/1216000.c
// Check target CPUs are correctly passed. // RUN: %clang -target riscv32 -### -c %s 2>&1 -mcpu=rocket-rv32 | FileCheck -check-prefix=MCPU-ROCKETCHIP32 %s // MCPU-ROCKETCHIP32: "-nostdsysteminc" "-target-cpu" "rocket-rv32" // RUN: %clang -target riscv64 -### -c %s 2>&1 -mcpu=rocket-rv64 | FileCheck -check-prefix=MCPU-ROCKETCHIP64 %s // MCPU-ROCKETCHIP64: "-nostdsysteminc" "-target-cpu" "rocket-rv64" // MCPU-ROCKETCHIP64: "-target-feature" "+64bit" // mcpu with default march // RUN: %clang -target riscv64 -### -c %s 2>&1 -mcpu=sifive-u54 | FileCheck -check-prefix=MCPU-SIFIVE-U54 %s // MCPU-SIFIVE-U54: "-nostdsysteminc" "-target-cpu" "sifive-u54" // MCPU-SIFIVE-U54: "-target-feature" "+m" "-target-feature" "+a" "-target-feature" "+f" "-target-feature" "+d" // MCPU-SIFIVE-U54: "-target-feature" "+c" "-target-feature" "+64bit" // MCPU-SIFIVE-U54: "-target-abi" "lp64d" // mcpu with mabi option // RUN: %clang -target riscv64 -### -c %s 2>&1 -mcpu=sifive-u54 -mabi=lp64 | FileCheck -check-prefix=MCPU-ABI-SIFIVE-U54 %s // MCPU-ABI-SIFIVE-U54: "-nostdsysteminc" "-target-cpu" "sifive-u54" // MCPU-ABI-SIFIVE-U54: "-target-feature" "+m" "-target-feature" "+a" "-target-feature" "+f" "-target-feature" "+d" // MCPU-ABI-SIFIVE-U54: "-target-feature" "+c" "-target-feature" "+64bit" // MCPU-ABI-SIFIVE-U54: "-target-abi" "lp64" // march overwirte mcpu's default march // RUN: %clang -target riscv32 -### -c %s 2>&1 -mcpu=sifive-e31 -march=rv32imc | FileCheck -check-prefix=MCPU-MARCH %s // MCPU-MARCH: "-nostdsysteminc" "-target-cpu" "sifive-e31" "-target-feature" "+m" "-target-feature" "+c" // MCPU-MARCH: "-target-abi" "ilp32" // Check failed cases // RUN: %clang -target riscv32 -### -c %s 2>&1 -mcpu=generic-rv321 | FileCheck -check-prefix=FAIL-MCPU-NAME %s // FAIL-MCPU-NAME: error: the clang compiler does not support '-mcpu=generic-rv321' // RUN: %clang -target riscv32 -### -c %s 2>&1 -mcpu=generic-rv32 -march=rv64i | FileCheck -check-prefix=MISMATCH-ARCH %s // MISMATCH-ARCH: error: the clang compiler does not support '-mcpu=generic-rv32' // RUN: %clang -target riscv32 -### -c %s 2>&1 -mcpu=generic-rv64 | FileCheck -check-prefix=MISMATCH-MCPU %s // MISMATCH-MCPU: error: the clang compiler does not support '-mcpu=generic-rv64'
the_stack_data/107538.c
// WARNING in percpu_ref_kill_and_confirm // https://syzkaller.appspot.com/bug?id=74a985d8fcf8a22a9b566f5642c16ce4001d4e95 // status:fixed // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include <dirent.h> #include <endian.h> #include <errno.h> #include <fcntl.h> #include <pthread.h> #include <signal.h> #include <stdarg.h> #include <stdbool.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.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/futex.h> 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 void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i; for (i = 0; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { int state; } event_t; static void event_init(event_t* ev) { ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { if (ev->state) exit(1); __atomic_store_n(&ev->state, 1, __ATOMIC_RELEASE); syscall(SYS_futex, &ev->state, FUTEX_WAKE | FUTEX_PRIVATE_FLAG); } static void event_wait(event_t* ev) { while (!__atomic_load_n(&ev->state, __ATOMIC_ACQUIRE)) syscall(SYS_futex, &ev->state, FUTEX_WAIT | FUTEX_PRIVATE_FLAG, 0, 0); } static int event_isset(event_t* ev) { return __atomic_load_n(&ev->state, __ATOMIC_ACQUIRE); } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; for (;;) { uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; syscall(SYS_futex, &ev->state, FUTEX_WAIT | FUTEX_PRIVATE_FLAG, 0, &ts); if (__atomic_load_n(&ev->state, __ATOMIC_RELAXED)) return 1; now = current_time_ms(); if (now - start > timeout) return 0; } } 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; } 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) { } } #define SYZ_HAVE_SETUP_TEST 1 static void setup_test() { prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); setpgrp(); write_file("/proc/self/oom_score_adj", "1000"); } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { int i, call, thread; for (call = 0; call < 3; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); event_timedwait(&th->done, 45); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } 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; } } } #ifndef __NR_io_uring_register #define __NR_io_uring_register 427 #endif #ifndef __NR_io_uring_setup #define __NR_io_uring_setup 425 #endif uint64_t r[1] = {0xffffffffffffffff}; void execute_call(int call) { long res; switch (call) { case 0: *(uint32_t*)0x200000c0 = 0; *(uint32_t*)0x200000c4 = 0; *(uint32_t*)0x200000c8 = 0; *(uint32_t*)0x200000cc = 0; *(uint32_t*)0x200000d0 = 0; *(uint32_t*)0x200000d4 = 0; *(uint32_t*)0x200000d8 = 0; *(uint32_t*)0x200000dc = 0; *(uint32_t*)0x200000e0 = 0; *(uint32_t*)0x200000e4 = 0; *(uint32_t*)0x200000e8 = 0; *(uint32_t*)0x200000ec = 0; *(uint32_t*)0x200000f0 = 0; *(uint32_t*)0x200000f4 = 0; *(uint32_t*)0x200000f8 = 0; *(uint32_t*)0x200000fc = 0; *(uint32_t*)0x20000100 = 0; *(uint32_t*)0x20000104 = 0; *(uint64_t*)0x20000108 = 0; *(uint32_t*)0x20000110 = 0; *(uint32_t*)0x20000114 = 0; *(uint32_t*)0x20000118 = 0; *(uint32_t*)0x2000011c = 0; *(uint32_t*)0x20000120 = 0; *(uint32_t*)0x20000124 = 0; *(uint32_t*)0x20000128 = 0; *(uint32_t*)0x2000012c = 0; *(uint64_t*)0x20000130 = 0; res = syscall(__NR_io_uring_setup, 0xea, 0x200000c0); if (res != -1) r[0] = res; break; case 1: syscall(__NR_io_uring_register, r[0], 0, 0, 0xc6); break; case 2: syscall(__NR_io_uring_register, r[0], 1, 0, 0); break; } } int main(void) { syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0); loop(); return 0; }
the_stack_data/95449276.c
// 求1-n的全排列 #include <stdio.h> int a[100], book[100], n; void dfs(int step) { if (step == n + 1) { for (int i = 1; i <= n; i++) printf("%d ", a[i]); printf("\n"); return; // 返回之前的一步(最近一次调用dfs函数的地方) } for (int i = 1; i <= n; i++) { if (book[i] == 0) { a[step] = i; book[i] = 1; // 表示已经使用过了 dfs(step + 1); // 这里通过函数的递归调用来实现 book[i] = 0; // 回收结果 } } return; } int main() { scanf("%d", &n); dfs(1); getchar(); getchar(); return 0; }
the_stack_data/66943.c
#include <stdio.h> #include <stdlib.h> typedef int elem_t; static void merge(elem_t a[], elem_t tmp[], const int start, const int mid, const int end){ int i, j, k; for(i = 0; i < end; i++){ tmp[i] = a[i]; } for(i = start, j = mid, k = start; i < mid && j < end; k++){ if (tmp[i] < tmp[j]){ a[k] = tmp[i++]; } else{ a[k] = tmp[j++]; } } while(i < mid){ a[k++] = tmp[i++]; } while(j < end){ a[k++] = tmp[j++]; } } void merge_sort(elem_t a[], elem_t tmp[], const int start, const int end){ if(start < end - 1){ const int mid = (start + end) / 2; merge_sort(a, tmp, start, mid); merge_sort(a, tmp, mid, end); merge(a, tmp, start, mid, end); } } int main(){ int arr[] = {1,9,4,6,8,3,7,8,4,4,5,67,8,9,0,9,23,32,23,3}; int n = sizeof(arr) / sizeof(int); printf("n = %d \n", n); int *copy = malloc(sizeof(int) * n ); merge_sort(arr, copy, 0, n); for(int i=0; i<n; ++i){ printf("%d \t", arr[i]); } printf("\n"); free(copy); return 0; }
the_stack_data/25138755.c
/* DataToC output of file <paint_texture_vert_glsl> */ extern int datatoc_paint_texture_vert_glsl_size; extern char datatoc_paint_texture_vert_glsl[]; int datatoc_paint_texture_vert_glsl_size = 358; char datatoc_paint_texture_vert_glsl[] = { 13, 10,117,110,105,102,111,114,109, 32,109, 97,116, 52, 32, 77,111,100,101,108, 86,105,101,119, 80,114,111,106,101, 99,116,105,111,110, 77, 97,116,114,105,120, 59, 13, 10,117,110,105,102,111,114,109, 32,109, 97,116, 52, 32, 77,111,100,101,108, 77, 97,116,114,105,120, 59, 13, 10, 13, 10,105,110, 32,118,101, 99, 50, 32,117, 59, 32, 47, 42, 32, 97, 99,116,105,118,101, 32,117,118, 32,109, 97,112, 32, 42, 47, 13, 10,105,110, 32,118,101, 99, 51, 32,112,111,115, 59, 13, 10, 13, 10,111,117,116, 32,118,101, 99, 50, 32,117,118, 95,105,110,116,101,114,112, 59, 13, 10, 13, 10,118,111,105,100, 32,109, 97,105,110, 40, 41, 13, 10,123, 13, 10, 9,103,108, 95, 80,111,115,105,116,105,111,110, 32, 61, 32, 77,111,100,101,108, 86,105,101,119, 80,114,111,106,101, 99,116,105,111,110, 77, 97,116,114,105,120, 32, 42, 32,118,101, 99, 52, 40,112,111,115, 44, 32, 49, 46, 48, 41, 59, 13, 10, 13, 10, 9,117,118, 95,105,110,116,101,114,112, 32, 61, 32,117, 59, 13, 10, 13, 10, 35,105,102,100,101,102, 32, 85, 83, 69, 95, 87, 79, 82, 76, 68, 95, 67, 76, 73, 80, 95, 80, 76, 65, 78, 69, 83, 13, 10, 9, 9,119,111,114,108,100, 95, 99,108,105,112, 95,112,108, 97,110,101,115, 95, 99, 97,108, 99, 95, 99,108,105,112, 95,100,105,115,116, 97,110, 99,101, 40, 40, 77,111,100,101,108, 77, 97,116,114,105,120, 32, 42, 32,118,101, 99, 52, 40,112,111,115, 44, 32, 49, 46, 48, 41, 41, 46,120,121,122, 41, 59, 13, 10, 35,101,110,100,105,102, 13, 10,125, 13, 10,0 };
the_stack_data/173578194.c
#include<sys/types.h> long ptrace(int request, pid_t pid, void *addr, void *data) { return 0; }
the_stack_data/140765709.c
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <signal.h> #include <sys/types.h> #include <sys/wait.h> #include <sys/signalfd.h> #include <errno.h> #define MAX_POOL 3 #define handle_error(msg) \ do { perror(msg); exit(EXIT_FAILURE); } while (0) int start_child(int sfd, sigset_t sigset); int main() { int sfd_child, sfd_parent; struct signalfd_siginfo fdsi; sigset_t sigmask_child, sigmask_parent; ssize_t ret_read; printf("Parent: pid = %d\n", (int)getpid()); sigemptyset(&sigmask_child); sigaddset(&sigmask_child, SIGUSR1); sigaddset(&sigmask_child, SIGTERM); sigemptyset(&sigmask_parent); sigaddset(&sigmask_parent, SIGCHLD); if (sigprocmask(SIG_BLOCK, &sigmask_child, NULL) == -1) handle_error("sigprocmask"); if (sigprocmask(SIG_BLOCK, &sigmask_parent, NULL) == -1) handle_error("sigprocmask"); if ((sfd_child = signalfd(-1, &sigmask_child, 0)) == -1) handle_error("signalfd"); if ((sfd_parent = signalfd(-1, &sigmask_parent, 0)) == -1) handle_error("signalfd"); for (int i = 0; i < MAX_POOL; i++) start_child(sfd_child, sigmask_child); while (1) { ret_read = read(sfd_parent, &fdsi, sizeof(struct signalfd_siginfo)); if (ret_read != sizeof(struct signalfd_siginfo)) handle_error("read"); if (fdsi.ssi_signo == SIGCHLD) { int is_refork = 0; int optflags = WNOHANG | WEXITED | WSTOPPED | WCONTINUED; siginfo_t wsiginfo = { .si_pid = 0 }; char *str_status; while (1) { if (waitid(P_ALL, 0, &wsiginfo, optflags) == 0 && wsiginfo.si_pid != 0) { switch (wsiginfo.si_code) { case CLD_EXITED: str_status = "Exited"; is_refork = 1; break; case CLD_KILLED: str_status = "Killed"; is_refork = 1; break; case CLD_DUMPED: str_status = "Dumped"; is_refork = 1; break; case CLD_STOPPED: str_status = "Stopped"; break; case CLD_CONTINUED: str_status = "Continued"; break; default: str_status = "si_code"; break; } printf("Parent: child pid(%d) %s(%d:%d)\n", wsiginfo.si_pid, str_status, wsiginfo.si_status, fdsi.ssi_status); if (is_refork != 0) { printf("Parent: re-fork child\n"); start_child(sfd_child, sigmask_child); } } else { break; } } } printf("Parent: recv signal\n"); } return 0; } int start_child(int sfd, sigset_t sigset) { ssize_t ret_read; struct signalfd_siginfo fdsi; switch (fork()) { case 0: printf("\tChild: pid = %d\n", (int) getpid()); while (1) { ret_read = read(sfd, &fdsi, sizeof(struct signalfd_siginfo)); if (ret_read != sizeof(struct signalfd_siginfo)) handle_error("read"); if (fdsi.ssi_signo == SIGUSR1) { printf("\tChild: SIGUSR1 (pid:%d)\n", (int)getpid()); } else if (fdsi.ssi_signo == SIGTERM) { printf("\tChild: SIGTERM : call exit(0) \n"); exit(EXIT_SUCCESS); } else { printf("\tChild: Read unexpected signal (%d)\n", fdsi.ssi_signo); break; } } exit(EXIT_FAILURE); default: return 0; case -1: handle_error("fork"); return errno; } return 0; }
the_stack_data/776948.c
// #include <stdio.h> int main(void) { int n1, n2, n3; printf("Please eneter 3 numbers separated by spaces > "); scanf("%d%d%d", &n1, &n2, &n3); if (n1 == n2 || n1 == n3 || (n2<n1 && n1<n3) || (n3<n1 && n1<n2)) printf("%d is the median\n", n1); else if (n2 == n3 || (n1<n2 && n2<n3) || (n3<n2 && n2<n1)) printf("%d is the median\n", n2); else if (n1<n3 && n3<n2) printf ("%d is the median\n", n3); return(0); }
the_stack_data/97013646.c
/*Exercício 01 - Criar um programa em linguagemmC que identifique se o numero é PAR ou IMPAR.*/ #include <stdio.h> #include <locale.h> int main() { setlocale(LC_ALL, "Portuguese"); int valor; printf("\n\tPAR OU �MPAR\t\n"); printf("----------------------------\n"); printf("Digite um n�mero: "); scanf("%d", &valor); if(valor % 2 == 0) { printf("\nO n�mero digitado � PAR\n"); } else { printf("\nO n�mero digitado � �MPAR\n"); } printf("----------------------------\n"); return 0; }
the_stack_data/251653.c
#include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct { char nome[40]; int n_matricula; char curso[40]; } aluno; void mostrar_dados(aluno alunos[]) { for (int count = 0; count < 3; count++) { printf(" === Aluno %s ===\n", alunos[count].nome); printf(" - N da matricula %d \n", alunos[count].n_matricula); printf(" - Curso %s \n", alunos[count].curso); } } void remove_salto(char n[]) { //Funcao para remover o \n do final da string int length = strlen(n)-1; n[length] = '\0'; } int main() { aluno alunos[3]; for (int count = 0; count < 3; count++) { printf(" === Aluno %d ===\n", count+1); setbuf(stdin, NULL); printf(" - Digite seu nome: "); fgets(alunos[count].nome, 40, stdin); remove_salto(alunos[count].nome); //Remove o \n do final printf(" - Insira o numero da matricula: "); scanf(" %d", &alunos[count].n_matricula); setbuf(stdin, NULL); printf(" - Digite o curso: "); fgets(alunos[count].curso, 40, stdin); } mostrar_dados(alunos); return 0; }
the_stack_data/537892.c
/** * file: echo-flag.c * * Created by hengxin on 12/12/21. */ #include <stdio.h> int main(int argc, char *argv[]) { int escaped = 0; char **args = argv; while (*++args != NULL) { if ((*args)[0] == '-') { char flag = (*args)[1]; switch (flag) { case 'e':escaped = 1; break; case 'E':escaped = 0; break; default:printf("Invalid flag!\n"); return 0; } } } char *arg = NULL; while (--argc > 0) { arg = *++argv; if (arg[0] == '\\' && escaped) { if (arg[1] == 't') { printf("\t"); } if (arg[1] == 'n') { printf("\n"); } } else if (arg[0] != '-') { printf((argc > 1) ? "%s " : "%s", arg); } } }
the_stack_data/159516628.c
#include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <string.h> // Node que forma a string dinamica. typedef struct node{ char caractere; struct node *next; }char_node; // Descritor da lista q forma a string dinamica. typedef struct arrayOfCharacter{ struct node *first_char; struct node *last_char; }array_char; // Estrutura da pilha. typedef struct Stack{ char c; struct Stack *next; }stStack; void MostrarString(array_char *string); void InserirNaString(array_char *string, char c); void VerificaPalindromo(array_char *string, stStack *stackHead); // Inicia a pilha stStack *initStack(stStack *stackHead){ stackHead = (stStack*)malloc(sizeof(stStack)); stackHead->c = ' '; stackHead->next = NULL; return stackHead; } // Adiciona na pilha void AdicionarNaPilha(stStack **stackHead, char c){ stStack *newNode = (stStack*)malloc(sizeof(stStack)); // Adicionando info. newNode->c = c; // Ligando o node ao topo. newNode->next = (*stackHead); (*stackHead) = newNode; } // Retira da Pilha. char RetirarDaPilha(stStack **stackHead){ stStack *newNode = (*stackHead); char ch; ch = newNode->c; (*stackHead) = (*stackHead)->next; free(newNode); return ch; } // Mostra a Pilha, usado para verificar se a pilha funciona. void MostrarPilha(stStack *stackHead){ while(stackHead->next != NULL) { printf("***************************************\n"); printf("* Info: %c \n",stackHead->c); printf("***************************************\n\n"); stackHead = stackHead->next; } } // Verifica se a string dinamica eh palindroma. void VerificaPalindromo(array_char *string, stStack *stackHead){ array_char *reverseString = (array_char*)malloc(sizeof(array_char)); char_node *auxNode1 = string->first_char; bool verdura = false; int i = 0; while(auxNode1 != NULL){ //printf("\ncaractere a inserir: %c\n",auxNode1->caractere); AdicionarNaPilha(&stackHead,auxNode1->caractere); auxNode1 = auxNode1->next; } free(auxNode1); auxNode1 = string->first_char; char ch; printf("\nVerificando se eh palindromo. . .\n\n"); while(auxNode1 != NULL){ ch = RetirarDaPilha(&stackHead); if(auxNode1->caractere == ch){ printf("%c == %c\n" ,auxNode1->caractere, ch); verdura = true; } else{ printf("%c != %c\n" ,auxNode1->caractere, ch); verdura = false; } auxNode1 = auxNode1->next; } if(verdura == true) printf("\n**Eh palindromo\n"); else printf("\n**Nao eh palindromo\n"); } // Insere elementos na string dinamica. void InserirNaString(array_char *string, char c){ char_node *newNode = (char_node*)malloc(sizeof(char_node)); if(string->first_char == NULL) { newNode->caractere = c; newNode->next = NULL; string->first_char = string->last_char = newNode; } else { newNode->caractere = c; newNode->next = NULL; string->last_char->next = newNode; string->last_char = newNode; } } // Usado para mostrar a string dinamica. void MostrarString(array_char *string){ char_node *auxNode = string->first_char; printf("\n"); while(auxNode != NULL){ printf("%c",auxNode->caractere); auxNode = auxNode->next; } printf("\n"); } int main() { array_char *string; array_char *string2; stStack *stackHead = NULL; string = (array_char*)malloc(sizeof(array_char)); string->first_char = NULL; string->last_char = NULL; string2 = (array_char*)malloc(sizeof(array_char)); string2->first_char = NULL; string2->last_char = NULL; stackHead = initStack(stackHead); printf("* Verificar se a string dinamica eh palindroma *\n"); InserirNaString(string,'a'); InserirNaString(string,'n'); InserirNaString(string,'a'); InserirNaString(string2,'b'); InserirNaString(string2,'a'); InserirNaString(string2,'t'); InserirNaString(string2,'a'); InserirNaString(string2,'t'); InserirNaString(string2,'a'); printf("\nstring1:"); MostrarString(string); printf("\nstring2:"); MostrarString(string2); printf("\n"); VerificaPalindromo(string,stackHead); printf("\n"); VerificaPalindromo(string2,stackHead); printf("* Fim do programa*\n"); system("pause"); return 0; }
the_stack_data/140764481.c
// general protection fault in locks_remove_flock // https://syzkaller.appspot.com/bug?id=fba66e4e82af4482df60864c5e50cd1f627e1b23 // status:dup // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include <endian.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/stat.h> #include <sys/syscall.h> #include <sys/types.h> #include <unistd.h> static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } #define BITMASK_LEN(type, bf_len) (type)((1ull << (bf_len)) - 1) #define BITMASK_LEN_OFF(type, bf_off, bf_len) \ (type)(BITMASK_LEN(type, (bf_len)) << (bf_off)) #define STORE_BY_BITMASK(type, addr, val, bf_off, bf_len) \ if ((bf_off) == 0 && (bf_len) == 0) { \ *(type*)(addr) = (type)(val); \ } else { \ type new_val = *(type*)(addr); \ new_val &= ~BITMASK_LEN_OFF(type, (bf_off), (bf_len)); \ new_val |= ((type)(val)&BITMASK_LEN(type, (bf_len))) << (bf_off); \ *(type*)(addr) = new_val; \ } uint64_t r[1] = {0xffffffffffffffff}; int main(void) { syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0); use_temporary_dir(); long res = 0; *(uint32_t*)0x2001d000 = 1; *(uint32_t*)0x2001d004 = 0x70; *(uint8_t*)0x2001d008 = 0; *(uint8_t*)0x2001d009 = 0; *(uint8_t*)0x2001d00a = 0; *(uint8_t*)0x2001d00b = 0; *(uint32_t*)0x2001d00c = 0; *(uint64_t*)0x2001d010 = 0x7f; *(uint64_t*)0x2001d018 = 0; *(uint64_t*)0x2001d020 = 0; STORE_BY_BITMASK(uint64_t, 0x2001d028, 0, 0, 1); STORE_BY_BITMASK(uint64_t, 0x2001d028, 0, 1, 1); STORE_BY_BITMASK(uint64_t, 0x2001d028, 0, 2, 1); STORE_BY_BITMASK(uint64_t, 0x2001d028, 0, 3, 1); STORE_BY_BITMASK(uint64_t, 0x2001d028, 0, 4, 1); STORE_BY_BITMASK(uint64_t, 0x2001d028, 0, 5, 1); STORE_BY_BITMASK(uint64_t, 0x2001d028, 0, 6, 1); STORE_BY_BITMASK(uint64_t, 0x2001d028, 0, 7, 1); STORE_BY_BITMASK(uint64_t, 0x2001d028, 0, 8, 1); STORE_BY_BITMASK(uint64_t, 0x2001d028, 0, 9, 1); STORE_BY_BITMASK(uint64_t, 0x2001d028, 0, 10, 1); STORE_BY_BITMASK(uint64_t, 0x2001d028, 0, 11, 1); STORE_BY_BITMASK(uint64_t, 0x2001d028, 0, 12, 1); STORE_BY_BITMASK(uint64_t, 0x2001d028, 0, 13, 1); STORE_BY_BITMASK(uint64_t, 0x2001d028, 0, 14, 1); STORE_BY_BITMASK(uint64_t, 0x2001d028, 0, 15, 2); STORE_BY_BITMASK(uint64_t, 0x2001d028, 0, 17, 1); STORE_BY_BITMASK(uint64_t, 0x2001d028, 0, 18, 1); STORE_BY_BITMASK(uint64_t, 0x2001d028, 0, 19, 1); STORE_BY_BITMASK(uint64_t, 0x2001d028, 0, 20, 1); STORE_BY_BITMASK(uint64_t, 0x2001d028, 0, 21, 1); STORE_BY_BITMASK(uint64_t, 0x2001d028, 0, 22, 1); STORE_BY_BITMASK(uint64_t, 0x2001d028, 0, 23, 1); STORE_BY_BITMASK(uint64_t, 0x2001d028, 0, 24, 1); STORE_BY_BITMASK(uint64_t, 0x2001d028, 0, 25, 1); STORE_BY_BITMASK(uint64_t, 0x2001d028, 0, 26, 1); STORE_BY_BITMASK(uint64_t, 0x2001d028, 0, 27, 1); STORE_BY_BITMASK(uint64_t, 0x2001d028, 0, 28, 1); STORE_BY_BITMASK(uint64_t, 0x2001d028, 0, 29, 35); *(uint32_t*)0x2001d030 = 0; *(uint32_t*)0x2001d034 = 0; *(uint64_t*)0x2001d038 = 0x20abe000; *(uint64_t*)0x2001d040 = 0; *(uint64_t*)0x2001d048 = 0; *(uint64_t*)0x2001d050 = 0; *(uint32_t*)0x2001d058 = 0; *(uint32_t*)0x2001d05c = 0; *(uint64_t*)0x2001d060 = 0; *(uint32_t*)0x2001d068 = 0; *(uint16_t*)0x2001d06c = 0; *(uint16_t*)0x2001d06e = 0; res = syscall(__NR_perf_event_open, 0x2001d000, 0, -1, -1, 0); if (res != -1) r[0] = res; syscall(__NR_flock, r[0], 2); return 0; }
the_stack_data/118474.c
#include <stdio.h> void insertionSort(int arr[], int n) { int i, j, x; for (i = 0; i < n; ++i) { x = arr[i]; j = i - 1; while(j >= 0 && arr[j] > x) { arr[j + 1] = arr[j]; --j; } arr[j + 1] = x; } }
the_stack_data/37683.c
/* ************************************************************************** */ /* */ /* :::::::: */ /* c_C_main.c :+: :+: */ /* +:+ */ /* By: hyilmaz <[email protected]> +#+ */ /* +#+ */ /* Created: 2021/01/01 16:02:18 by hyilmaz #+# #+# */ /* Updated: 2021/01/05 14:17:03 by hyilmaz ######## odam.nl */ /* */ /* ************************************************************************** */ #include <stdio.h> #include <stdlib.h> int main(void) { int i; FILE *fd; int res; i = 0; fd = fopen("logs/results/c_C_return_val", "a+"); if (fd == NULL) { printf("Couldn't open file\n"); exit(1); } /* ** Testing with basic characters */ res = printf("%c\n", 0);//1 fprintf(fd, "%d\n", res); res = printf("%3c\n", 0);//2 fprintf(fd, "%d\n", res); res = printf("%-3c\n", 0);//3 fprintf(fd, "%d\n", res); res = printf("%5c\n", 0);//4 fprintf(fd, "%d\n", res); res = printf("%-5c\n", 0);//5 fprintf(fd, "%d\n", res); res = printf("%*c\n", 4, 0);//6 fprintf(fd, "%d\n", res); res = printf("%-*c\n", 4, 0);//7 fprintf(fd, "%d\n", res); res = printf("%c\n", 10);//8 fprintf(fd, "%d\n", res); res = printf("%3c\n", 10);//9 fprintf(fd, "%d\n", res); res = printf("%-3c\n", 10);//10 fprintf(fd, "%d\n", res); res = printf("%5c\n", 10);//11 fprintf(fd, "%d\n", res); res = printf("%-5c\n", 10);//12 fprintf(fd, "%d\n", res); res = printf("%*c\n", 4, 10);//13 fprintf(fd, "%d\n", res); res = printf("%-*c\n", 4, 10);//14 fprintf(fd, "%d\n", res); res = printf("%c\n", 20);//15 fprintf(fd, "%d\n", res); res = printf("%3c\n", 20);//16 fprintf(fd, "%d\n", res); res = printf("%-3c\n", 20);//17 fprintf(fd, "%d\n", res); res = printf("%5c\n", 20);//18 fprintf(fd, "%d\n", res); res = printf("%-5c\n", 20);//19 fprintf(fd, "%d\n", res); res = printf("%*c\n", 4, 20);//20 fprintf(fd, "%d\n", res); res = printf("%-*c\n", 4, 20);//21 fprintf(fd, "%d\n", res); res = printf("%c\n", 30);//22 fprintf(fd, "%d\n", res); res = printf("%3c\n", 30);//23 fprintf(fd, "%d\n", res); res = printf("%-3c\n", 30);//24 fprintf(fd, "%d\n", res); res = printf("%5c\n", 30);//25 fprintf(fd, "%d\n", res); res = printf("%-5c\n", 30);//26 fprintf(fd, "%d\n", res); res = printf("%*c\n", 4, 30);//27 fprintf(fd, "%d\n", res); res = printf("%-*c\n", 4, 30);//28 fprintf(fd, "%d\n", res); res = printf("%c\n", 40);//29 fprintf(fd, "%d\n", res); res = printf("%3c\n", 40);//30 fprintf(fd, "%d\n", res); res = printf("%-3c\n", 40);//31 fprintf(fd, "%d\n", res); res = printf("%5c\n", 40);//32 fprintf(fd, "%d\n", res); res = printf("%-5c\n", 40);//33 fprintf(fd, "%d\n", res); res = printf("%*c\n", 4, 40);//34 fprintf(fd, "%d\n", res); res = printf("%-*c\n", 4, 40);//35 fprintf(fd, "%d\n", res); res = printf("%c\n", 50);//36 fprintf(fd, "%d\n", res); res = printf("%3c\n", 50);//37 fprintf(fd, "%d\n", res); res = printf("%-3c\n", 50);//38 fprintf(fd, "%d\n", res); res = printf("%5c\n", 50);//39 fprintf(fd, "%d\n", res); res = printf("%-5c\n", 50);//40 fprintf(fd, "%d\n", res); res = printf("%*c\n", 4, 50);//41 fprintf(fd, "%d\n", res); res = printf("%-*c\n", 4, 50);//42 fprintf(fd, "%d\n", res); res = printf("%c\n", 69);//43 fprintf(fd, "%d\n", res); res = printf("%3c\n", 69);//44 fprintf(fd, "%d\n", res); res = printf("%-3c\n", 69);//45 fprintf(fd, "%d\n", res); res = printf("%5c\n", 69);//46 fprintf(fd, "%d\n", res); res = printf("%-5c\n", 69);//47 fprintf(fd, "%d\n", res); res = printf("%*c\n", 4, 69);//48 fprintf(fd, "%d\n", res); res = printf("%-*c\n", 4, 69);//49 fprintf(fd, "%d\n", res); res = printf("%c\n", 70);//50 fprintf(fd, "%d\n", res); res = printf("%3c\n", 70);//51 fprintf(fd, "%d\n", res); res = printf("%-3c\n", 70);//52 fprintf(fd, "%d\n", res); res = printf("%5c\n", 70);//53 fprintf(fd, "%d\n", res); res = printf("%-5c\n", 70);//54 fprintf(fd, "%d\n", res); res = printf("%*c\n", 4, 70);//55 fprintf(fd, "%d\n", res); res = printf("%-*c\n", 4, 70);//56 fprintf(fd, "%d\n", res); res = printf("%c\n", 80);//57 fprintf(fd, "%d\n", res); res = printf("%3c\n", 80);//58 fprintf(fd, "%d\n", res); res = printf("%-3c\n", 80);//59 fprintf(fd, "%d\n", res); res = printf("%5c\n", 80);//60 fprintf(fd, "%d\n", res); res = printf("%-5c\n", 80);//61 fprintf(fd, "%d\n", res); res = printf("%*c\n", 4, 80);//62 fprintf(fd, "%d\n", res); res = printf("%-*c\n", 4, 80);//63 fprintf(fd, "%d\n", res); res = printf("%c\n", 90);//64 fprintf(fd, "%d\n", res); res = printf("%3c\n", 90);//65 fprintf(fd, "%d\n", res); res = printf("%-3c\n", 90);//66 fprintf(fd, "%d\n", res); res = printf("%5c\n", 90);//67 fprintf(fd, "%d\n", res); res = printf("%-5c\n", 90);//68 fprintf(fd, "%d\n", res); res = printf("%*c\n", 4, 90);//69 fprintf(fd, "%d\n", res); res = printf("%-*c\n", 4, 90);//70 fprintf(fd, "%d\n", res); res = printf("%c\n", 100);//71 fprintf(fd, "%d\n", res); res = printf("%3c\n", 100);//72 fprintf(fd, "%d\n", res); res = printf("%-3c\n", 100);//73 fprintf(fd, "%d\n", res); res = printf("%5c\n", 100);//74 fprintf(fd, "%d\n", res); res = printf("%-5c\n", 100);//75 fprintf(fd, "%d\n", res); res = printf("%*c\n", 4, 100);//76 fprintf(fd, "%d\n", res); res = printf("%-*c\n", 4, 100);//77 fprintf(fd, "%d\n", res); /* ** Printing with text */ res = printf("I am a %c%c%c%c%c student\n", 'c', 'o', 'd', 'a', 'm');//78 fprintf(fd, "%d\n", res); res = printf("I am a %10c%c%-10c%c%*c student\n", 'c', 'o', 'd', 'a', 40, 'm');//79 fprintf(fd, "%d\n", res); return (0); }
the_stack_data/34858.c
/** ****************************************************************************** * @file usbd_hid_consumer_if.c * @brief Provide the USB HID composite interface * ****************************************************************************** * @attention * * This file was modified in order to replace mouse with consumer control * device. Modified by One Transistor <[email protected]> * https://www.onetransistor.eu * * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2> * * 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 STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ #ifdef USBCON #ifdef USBD_USE_HID_COMPOSITE #include <stdbool.h> #include "usbd_desc.h" #include "usbd_hid_consumer_if.h" #include "usbd_hid_consumer.h" #ifdef __cplusplus extern "C" { #endif /* USB Device Core HID composite handle declaration */ USBD_HandleTypeDef hUSBD_Device_HID; static bool HID_keyboard_initialized = false; static bool HID_consumer_initialized = false; /** * @brief Initialize USB devices * @param HID_Interface device type: HID_KEYBOARD or HID_CONSUMER * @retval none */ void HID_Composite_Init(HID_Interface device) { if (IS_HID_INTERFACE(device) && !HID_keyboard_initialized && !HID_consumer_initialized) { /* Init Device Library */ if (USBD_Init(&hUSBD_Device_HID, &USBD_Desc, 0) == USBD_OK) { /* Add Supported Class */ if (USBD_RegisterClass(&hUSBD_Device_HID, USBD_COMPOSITE_HID_CLASS) == USBD_OK) { /* Start Device Process */ USBD_Start(&hUSBD_Device_HID); HID_keyboard_initialized = true; HID_consumer_initialized = true; } } } if (device == HID_KEYBOARD) { HID_keyboard_initialized = HID_consumer_initialized; } if (device == HID_CONSUMER) { HID_consumer_initialized = HID_keyboard_initialized; } } /** * @brief DeInitialize USB devices * @param HID_Interface device type: HID_KEYBOARD or HID_CONSUMER * @retval none */ void HID_Composite_DeInit(HID_Interface device) { if (IS_HID_INTERFACE(device) && ((HID_keyboard_initialized && !HID_consumer_initialized) || (HID_consumer_initialized && !HID_keyboard_initialized))) { /* Stop Device Process */ USBD_Stop(&hUSBD_Device_HID); /* DeInit Device Library */ USBD_DeInit(&hUSBD_Device_HID); } if (device == HID_KEYBOARD) { HID_keyboard_initialized = false; } if (device == HID_CONSUMER) { HID_consumer_initialized = false; } } /** * @brief Send HID consumer Report * @param report pointer to report * @param len report lenght * @retval none */ void HID_Composite_consumer_sendReport(uint8_t *report, uint16_t len) { USBD_HID_CONSUMER_SendReport(&hUSBD_Device_HID, report, len); } /** * @brief Send HID keyboard Report * @param report pointer to report * @param len report lenght * @retval none */ void HID_Composite_keyboard_sendReport(uint8_t *report, uint16_t len) { USBD_HID_KEYBOARD_SendReport(&hUSBD_Device_HID, report, len); } #ifdef __cplusplus } #endif #endif /* USBD_USE_HID_CONSUMER */ #endif /* USBCON */
the_stack_data/3261585.c
// PROGRAMA p04.c #include <pthread.h> #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <sys/types.h> #define NUM_THREADS 10 void *PrintHello(void *threadnum) { sleep(1); printf("Hello from thread no. %u!\n", pthread_self()); return threadnum; } int main() { pthread_t threads[NUM_THREADS]; int t; int threads_numbers[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; for(t=0; t< NUM_THREADS; t++){ printf("Creating thread %d\n", t); pthread_create(&threads[t], NULL, PrintHello, (void *)&threads_numbers[t]); } for(t = 0; t < NUM_THREADS; t++){ int * threadnum; pthread_join(threads[t], (void **) &threadnum); printf("\nJoined thread :%d\n", *threadnum); } pthread_exit(0); }
the_stack_data/5095.c
// RUN: %llvmgcc -S %s -o - | llvm-as -o /dev/null /* GCC was not escaping quotes in string constants correctly, so this would * get emitted: * %.LC1 = internal global [32 x sbyte] c"*** Word "%s" on line %d is not\00" */ const char *Foo() { return "*** Word \"%s\" on line %d is not"; }
the_stack_data/72013249.c
#include <string.h> int memdp(int N, int index, int mask, int (*dp)[N]) { if (index >= N) return 1; if (dp[mask][index] != -1) return dp[mask][index]; int res = 0; for (int i = 0; i < N; ++i) { if ((mask & (1 << i)) == 0) { if ((i + 1) % (index + 1) == 0 || (index + 1) % (i + 1) == 0) res += memdp(N, index + 1, mask | (1 << i), dp); } } return dp[mask][index] = res; } int countArrangement(int N) { int dp[1 << N][N]; memset(dp, -1, sizeof(dp)); return memdp(N, 0, 0, dp); }
the_stack_data/155423.c
struct { int a; long b } * c; d; e() { if (c[0].a) if (d) f(); switch (c[0].a) case 1: switch (c[0].b) case 2: g(); }
the_stack_data/193894416.c
/** * polybench.c: This file is part of the PolyBench/C 3.2 test suite. * * * Contact: Louis-Noel Pouchet <[email protected]> * Web address: http://polybench.sourceforge.net * License: /LICENSE.OSU.txt */ #include <stdio.h> #include <string.h> #include <stdlib.h> #include <unistd.h> #include <assert.h> #include <time.h> #include <sys/time.h> #include <sys/resource.h> #include <sched.h> #include <math.h> #ifdef _OPENMP # include <omp.h> #endif /* By default, collect PAPI counters on thread 0. */ #ifndef POLYBENCH_THREAD_MONITOR # define POLYBENCH_THREAD_MONITOR 0 #endif /* Total LLC cache size. By default 32+MB.. */ #ifndef POLYBENCH_CACHE_SIZE_KB # define POLYBENCH_CACHE_SIZE_KB 32770 #endif #include <omp.h> int polybench_papi_counters_threadid = 0; double polybench_program_total_flops = 0; #ifdef POLYBENCH_PAPI # include <papi.h> # define POLYBENCH_MAX_NB_PAPI_COUNTERS 96 #include "papi_counters.list" #endif /* Timer code (gettimeofday). */ double polybench_t_start; double polybench_t_end; /* Timer code (RDTSC). */ unsigned long long polybench_c_start; unsigned long long polybench_c_end; static double rtclock() { #ifdef POLYBENCH_TIME #else return 0; #endif } #ifdef POLYBENCH_CYCLE_ACCURATE_TIMER #endif void polybench_flush_cache() { int cs = ((32770 * 1024) / sizeof(double )); double *flush = (double *)(calloc(cs,sizeof(double ))); int i; double tmp = 0.0; #pragma omp parallel for private (i) reduction (+:tmp) firstprivate (cs) for (i = 0; i <= cs - 1; i += 1) { tmp += flush[i]; } (((void )(sizeof(((tmp <= 10.0?1 : 0))))) , (( { if (tmp <= 10.0) ; else __assert_fail("tmp <= 10.0","polybench.c",94,__PRETTY_FUNCTION__); }))); free(flush); } #ifdef POLYBENCH_LINUX_FIFO_SCHEDULER /* Use FIFO scheduler to limit OS interference. Program must be run as root, and this works only for Linux kernels. */ /* Restore to standard scheduler policy. */ #endif #ifdef POLYBENCH_PAPI # ifndef POLYBENCH_NO_FLUSH_CACHE # endif #ifdef POLYBENCH_PAPI_VERBOSE #endif #endif /* ! POLYBENCH_PAPI */ void polybench_prepare_instruments() { #ifndef POLYBENCH_NO_FLUSH_CACHE polybench_flush_cache(); #endif #ifdef POLYBENCH_LINUX_FIFO_SCHEDULER #endif } void polybench_timer_start() { polybench_prepare_instruments(); #ifndef POLYBENCH_CYCLE_ACCURATE_TIMER polybench_t_start = rtclock(); #else #endif } void polybench_timer_stop() { #ifndef POLYBENCH_CYCLE_ACCURATE_TIMER polybench_t_end = rtclock(); #else #endif #ifdef POLYBENCH_LINUX_FIFO_SCHEDULER #endif } void polybench_timer_print() { #ifdef POLYBENCH_GFLOPS #else # ifndef POLYBENCH_CYCLE_ACCURATE_TIMER printf("%0.6f\n",polybench_t_end - polybench_t_start); # else # endif #endif } static void *xmalloc(size_t num) { void *nnew = (void *)0; int ret = posix_memalign(&nnew,32,num); if (!nnew || ret) { fprintf(stderr,"[PolyBench] posix_memalign: cannot allocate memory"); exit(1); } return nnew; } void *polybench_alloc_data(unsigned long long n,int elt_size) { /// FIXME: detect overflow! size_t val = n; val *= elt_size; void *ret = xmalloc(val); return ret; }