file
stringlengths
18
26
data
stringlengths
3
1.04M
the_stack_data/140764772.c
#include <stdio.h> int main() { printf("Hi, my name is Fernando\n"); return 0; }
the_stack_data/154513.c
#define UNUSED(x) (void)(x) static void f(int x) { UNUSED(x); }
the_stack_data/72012379.c
// http://www.bjfuacm.com/problem/280/ #include <stdio.h> #include <stdlib.h> #define MVNum 100 struct ArcNode; struct VNode; struct ALGragh; typedef struct ArcNode ArcNode; typedef struct VNode VNode; typedef struct ALGragh ALGragh; typedef int VerTexType; typedef int ArcType; struct ArcNode { int adjvex; ArcNode *nextarc; }; struct VNode { VerTexType data; ArcNode *firstarc; }; typedef struct VNode AdjList[MVNum]; /** * ALGraph need AdjList declare first * typedef array need complete element type 'struct VNode' */ struct ALGragh { AdjList vertices; // vertices is pl. of vertex (index, indices) int vexnum; int arcnum; }; ALGragh * CreateUDG(ALGragh * ); int LocateVex(ALGragh * , int ); void DeleteArc(ALGragh * ); void PrintALGraph(ALGragh * ); void DestroyALGraph(ALGragh * ); void DestroyArcList(ArcNode * ); int main() { while (1) { ALGragh *G = (ALGragh *)calloc(1, sizeof(*G)); G = CreateUDG(G); if (G == NULL) break; DeleteArc(G); PrintALGraph(G); DestroyALGraph(G); } } ALGragh * CreateUDG(ALGragh *G) { int v1; // node 1, is a name int v2; // node 2, is also a name scanf("%d %d", &(G->vexnum), &(G->arcnum)); if (G->vexnum == 0 && G->vexnum == 0) return NULL; for (int i = 1; i <= G->vexnum; i++) { // since G is a pointer, use "->" G->vertices[i].data = i; // data refers to "ith" (type: int) node G->vertices[i].firstarc = NULL; // head node } for (int k = 1; k <= G->arcnum; k++) { scanf("%d %d", &v1, &v2); int i = LocateVex(G, v1); int j = LocateVex(G, v2); ArcNode *p = (ArcNode *)calloc(1, sizeof(*p)); // new node p->adjvex = j; p->nextarc = G->vertices[i].firstarc; G->vertices[i].firstarc = p; ArcNode *q = (ArcNode *)calloc(1, sizeof(*q)); // new node otherside q->adjvex = i; q->nextarc = G->vertices[j].firstarc; G->vertices[j].firstarc = q; } return G; } int LocateVex(ALGragh * G, int vex) { for (int i = 1; i <= G->vexnum; i++) { if (vex == G->vertices[i].data) return i; } } void DeleteArc(ALGragh * G) { int v1; int v2; scanf("%d %d", &v1, &v2); int i = LocateVex(G, v1); int j = LocateVex(G, v2); if (G->vertices[i].firstarc->adjvex == j) { G->vertices[i].firstarc = G->vertices[i].firstarc->nextarc; } else { ArcNode *p = G->vertices[i].firstarc; while (p->nextarc != NULL) { if (p->nextarc->adjvex == j) { ArcNode *to_delete = p->nextarc; p->nextarc = to_delete->nextarc; free(to_delete); break; } } } if (G->vertices[j].firstarc->adjvex == i) { G->vertices[j].firstarc = G->vertices[j].firstarc->nextarc; } else { ArcNode *p = G->vertices[i].firstarc; while (p->nextarc != NULL) { if (p->nextarc->adjvex == i) { ArcNode *to_delete = p->nextarc; p->nextarc = to_delete->nextarc; free(to_delete); break; } } } } void PrintALGraph(ALGragh * G) { if (G == NULL) return; for (int i = 1; i <= G->vexnum; i++) { printf("%d%s", G->vertices[i].data, G->vertices[i].firstarc == NULL? "\n": " "); if (G->vertices[i].firstarc != NULL) { ArcNode *p = G->vertices[i].firstarc; while (p != NULL) { printf("%d%s", p->adjvex, p->nextarc == NULL? "\n": " "); p = p->nextarc; } } } } void DestroyALGraph(ALGragh *G) { if (G == NULL) return; for (int i = 1; i <= G->vexnum; i++) { if (G->vertices[i].firstarc != NULL) { DestroyArcList(G->vertices[i].firstarc); } } free(G); } void DestroyArcList(ArcNode *p) { ArcNode *to_delete = NULL; while (p != NULL) { to_delete = p; p = p->nextarc; free(to_delete); } }
the_stack_data/173255.c
#include <stdio.h> #include <stdlib.h> #define CHRS_PER_LINE 20 int main(int argc, char *argv[]) { char *filename; FILE *f; int chr; int count; int i; if (argc < 2) { fprintf(stderr, "Error: expecting at least one argument.\n"); return EXIT_FAILURE; } printf("#include \"amulet.h\"\n\n"); for (i = 1; i < argc; i++) { filename = argv[i]; f = fopen(filename, "rb"); count = 0; printf("static const uint8_t data%d[] = {\n ", i); while (1) { if (count == CHRS_PER_LINE) { printf("\n "); count = 0; } chr = getc(f); if (chr == EOF) { printf("0};\n\n"); break; } printf("0x%02X, ", chr); count++; } fclose(f); } printf("\n"); printf("am_embedded_file_record am_embedded_files[] = {"); for (i = 1; i < argc; i++) { filename = argv[i]; printf("\n {\"%s\", data%d, sizeof(data%d)-1},", filename, i, i); } printf("\n {NULL, NULL, 0}\n};\n"); return EXIT_SUCCESS; }
the_stack_data/35968.c
#include <stdint.h> #include <stdbool.h> void SysTickPeriodSet(uint32_t period) { period++; } void SysCtlClockGet(void) { } void SysTickEnable(void) { } void SysTickIntEnable(void) { } void SysCtlPeripheralEnable(uint32_t ui32Peripheral) { ui32Peripheral++; } bool SysCtlPeripheralReady(uint32_t ui32Peripheral) { ui32Peripheral++; return true; } void TimerConfigure(uint32_t ui32Base, uint32_t ui32Config) { ui32Base++; ui32Config++; } void TimerLoadSet(uint32_t ui32Base, uint32_t ui32Timer, uint32_t ui32Value) { ui32Base++; ui32Timer++; ui32Value++; } void TimerIntClear(uint32_t ui32Base, uint32_t ui32IntFlags) { ui32Base++; ui32IntFlags++; } void IntPrioritySet(uint32_t ui32Interrupt, uint8_t ui8Priority) { ui32Interrupt++; ui8Priority++; } void TimerIntEnable(uint32_t ui32Base, uint32_t ui32IntFlags) { ui32Base++; ui32IntFlags++; } void IntEnable(uint32_t ui32Interrupt) { ui32Interrupt++; } void TimerEnable(uint32_t ui32Base, uint32_t ui32Timer) { ui32Base++; ui32Timer++; } void SysCtlDelay(uint32_t period) { period++; }
the_stack_data/43888403.c
/** * \file * * \brief Default descriptors for a USB Device with a single interface CDC * * Copyright (c) 2009-2016 Atmel Corporation. All rights reserved. * * \asf_license_start * * \page License * * 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. The name of Atmel may not be used to endorse or promote products derived * from this software without specific prior written permission. * * 4. This software may only be redistributed and used in connection with an * Atmel microcontroller product. * * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL 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. * * \asf_license_stop * */ /* * Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a> */ #ifdef ARDUINO_ARCH_SAM #include "conf_usb.h" #include "udd.h" #include "udc_desc.h" #include "udi_cdc.h" #if DISABLED(SDSUPPORT) /** * \defgroup udi_cdc_group_single_desc USB device descriptors for a single interface * * The following structures provide the USB device descriptors required for * USB Device with a single interface CDC. * * It is ready to use and do not require more definition. * * @{ */ //! Two interfaces for a CDC device #define USB_DEVICE_NB_INTERFACE (2*UDI_CDC_PORT_NB) #ifdef USB_DEVICE_LPM_SUPPORT # define USB_VERSION USB_V2_1 #else # define USB_VERSION USB_V2_0 #endif //! USB Device Descriptor COMPILER_WORD_ALIGNED UDC_DESC_STORAGE usb_dev_desc_t udc_device_desc = { .bLength = sizeof(usb_dev_desc_t), .bDescriptorType = USB_DT_DEVICE, .bcdUSB = LE16(USB_VERSION), #if UDI_CDC_PORT_NB > 1 .bDeviceClass = 0, #else .bDeviceClass = CDC_CLASS_DEVICE, #endif .bDeviceSubClass = 0, .bDeviceProtocol = 0, .bMaxPacketSize0 = USB_DEVICE_EP_CTRL_SIZE, .idVendor = LE16(USB_DEVICE_VENDOR_ID), .idProduct = LE16(USB_DEVICE_PRODUCT_ID), .bcdDevice = LE16((USB_DEVICE_MAJOR_VERSION << 8) | USB_DEVICE_MINOR_VERSION), #ifdef USB_DEVICE_MANUFACTURE_NAME .iManufacturer = 1, #else .iManufacturer = 0, // No manufacture string #endif #ifdef USB_DEVICE_PRODUCT_NAME .iProduct = 2, #else .iProduct = 0, // No product string #endif #if (defined USB_DEVICE_SERIAL_NAME || defined USB_DEVICE_GET_SERIAL_NAME_POINTER) .iSerialNumber = 3, #else .iSerialNumber = 0, // No serial string #endif .bNumConfigurations = 1 }; #ifdef USB_DEVICE_HS_SUPPORT //! USB Device Qualifier Descriptor for HS COMPILER_WORD_ALIGNED UDC_DESC_STORAGE usb_dev_qual_desc_t udc_device_qual = { .bLength = sizeof(usb_dev_qual_desc_t), .bDescriptorType = USB_DT_DEVICE_QUALIFIER, .bcdUSB = LE16(USB_VERSION), #if UDI_CDC_PORT_NB > 1 .bDeviceClass = 0, #else .bDeviceClass = CDC_CLASS_DEVICE, #endif .bDeviceSubClass = 0, .bDeviceProtocol = 0, .bMaxPacketSize0 = USB_DEVICE_EP_CTRL_SIZE, .bNumConfigurations = 1 }; #endif #ifdef USB_DEVICE_LPM_SUPPORT //! USB Device Qualifier Descriptor COMPILER_WORD_ALIGNED UDC_DESC_STORAGE usb_dev_lpm_desc_t udc_device_lpm = { .bos.bLength = sizeof(usb_dev_bos_desc_t), .bos.bDescriptorType = USB_DT_BOS, .bos.wTotalLength = LE16(sizeof(usb_dev_bos_desc_t) + sizeof(usb_dev_capa_ext_desc_t)), .bos.bNumDeviceCaps = 1, .capa_ext.bLength = sizeof(usb_dev_capa_ext_desc_t), .capa_ext.bDescriptorType = USB_DT_DEVICE_CAPABILITY, .capa_ext.bDevCapabilityType = USB_DC_USB20_EXTENSION, .capa_ext.bmAttributes = USB_DC_EXT_LPM, }; #endif //! Structure for USB Device Configuration Descriptor COMPILER_PACK_SET(1) typedef struct { usb_conf_desc_t conf; #if UDI_CDC_PORT_NB == 1 udi_cdc_comm_desc_t udi_cdc_comm_0; udi_cdc_data_desc_t udi_cdc_data_0; #else # define UDI_CDC_DESC_STRUCTURE(index, unused) \ usb_iad_desc_t udi_cdc_iad_##index; \ udi_cdc_comm_desc_t udi_cdc_comm_##index; \ udi_cdc_data_desc_t udi_cdc_data_##index; MREPEAT(UDI_CDC_PORT_NB, UDI_CDC_DESC_STRUCTURE, ~) # undef UDI_CDC_DESC_STRUCTURE #endif } udc_desc_t; COMPILER_PACK_RESET() //! USB Device Configuration Descriptor filled for full and high speed COMPILER_WORD_ALIGNED UDC_DESC_STORAGE udc_desc_t udc_desc_fs = { .conf.bLength = sizeof(usb_conf_desc_t), .conf.bDescriptorType = USB_DT_CONFIGURATION, .conf.wTotalLength = LE16(sizeof(udc_desc_t)), .conf.bNumInterfaces = USB_DEVICE_NB_INTERFACE, .conf.bConfigurationValue = 1, .conf.iConfiguration = 0, .conf.bmAttributes = USB_CONFIG_ATTR_MUST_SET | USB_DEVICE_ATTR, .conf.bMaxPower = USB_CONFIG_MAX_POWER(USB_DEVICE_POWER), #if UDI_CDC_PORT_NB == 1 .udi_cdc_comm_0 = UDI_CDC_COMM_DESC_0, .udi_cdc_data_0 = UDI_CDC_DATA_DESC_0_FS, #else # define UDI_CDC_DESC_FS(index, unused) \ .udi_cdc_iad_##index = UDI_CDC_IAD_DESC_##index,\ .udi_cdc_comm_##index = UDI_CDC_COMM_DESC_##index,\ .udi_cdc_data_##index = UDI_CDC_DATA_DESC_##index##_FS, MREPEAT(UDI_CDC_PORT_NB, UDI_CDC_DESC_FS, ~) # undef UDI_CDC_DESC_FS #endif }; #ifdef USB_DEVICE_HS_SUPPORT COMPILER_WORD_ALIGNED UDC_DESC_STORAGE udc_desc_t udc_desc_hs = { .conf.bLength = sizeof(usb_conf_desc_t), .conf.bDescriptorType = USB_DT_CONFIGURATION, .conf.wTotalLength = LE16(sizeof(udc_desc_t)), .conf.bNumInterfaces = USB_DEVICE_NB_INTERFACE, .conf.bConfigurationValue = 1, .conf.iConfiguration = 0, .conf.bmAttributes = USB_CONFIG_ATTR_MUST_SET | USB_DEVICE_ATTR, .conf.bMaxPower = USB_CONFIG_MAX_POWER(USB_DEVICE_POWER), #if UDI_CDC_PORT_NB == 1 .udi_cdc_comm_0 = UDI_CDC_COMM_DESC_0, .udi_cdc_data_0 = UDI_CDC_DATA_DESC_0_HS, #else # define UDI_CDC_DESC_HS(index, unused) \ .udi_cdc_iad_##index = UDI_CDC_IAD_DESC_##index, \ .udi_cdc_comm_##index = UDI_CDC_COMM_DESC_##index, \ .udi_cdc_data_##index = UDI_CDC_DATA_DESC_##index##_HS, MREPEAT(UDI_CDC_PORT_NB, UDI_CDC_DESC_HS, ~) # undef UDI_CDC_DESC_HS #endif }; #endif /** * \name UDC structures which content all USB Device definitions */ //@{ //! Associate an UDI for each USB interface UDC_DESC_STORAGE udi_api_t *udi_apis[USB_DEVICE_NB_INTERFACE] = { # define UDI_CDC_API(index, unused) \ &udi_api_cdc_comm, \ &udi_api_cdc_data, MREPEAT(UDI_CDC_PORT_NB, UDI_CDC_API, ~) # undef UDI_CDC_API }; //! Add UDI with USB Descriptors FS & HS UDC_DESC_STORAGE udc_config_speed_t udc_config_fs[1] = { { .desc = (usb_conf_desc_t UDC_DESC_STORAGE*)&udc_desc_fs, .udi_apis = udi_apis, }}; #ifdef USB_DEVICE_HS_SUPPORT UDC_DESC_STORAGE udc_config_speed_t udc_config_hs[1] = { { .desc = (usb_conf_desc_t UDC_DESC_STORAGE*)&udc_desc_hs, .udi_apis = udi_apis, }}; #endif //! Add all information about USB Device in global structure for UDC UDC_DESC_STORAGE udc_config_t udc_config = { .confdev_lsfs = &udc_device_desc, .conf_lsfs = udc_config_fs, #ifdef USB_DEVICE_HS_SUPPORT .confdev_hs = &udc_device_desc, .qualifier = &udc_device_qual, .conf_hs = udc_config_hs, #endif #ifdef USB_DEVICE_LPM_SUPPORT .conf_bos = &udc_device_lpm.bos, #else .conf_bos = NULL, #endif }; //@} //@} #endif // SDSUPPORT #endif // ARDUINO_ARCH_SAM
the_stack_data/85066.c
#include <stdio.h> #include <stdlib.h> #define LINES 106 #define COLS 110 typedef enum {round, square, curly, angle} type; //names taken from wiki int compare(const void *a, const void *b) { if (*(long*)a > *(long*)b) return 1; if (*(long*)a < *(long*)b) return -1; return 0; } int main(int argc, char *argv[]) { char matrix[LINES][COLS], stack[COLS]; FILE *fp = fopen("input10", "r"); char c; for (int i = 0; i < LINES; i++) { for (int j = 0; j < COLS; j++) { c = fgetc(fp); if (c == '\n') { matrix[i][j] = '\0'; break; } matrix[i][j] = c; } } int mismatch = 0, current = -1, score_index = -1; long score = 0, scores[LINES] = {0}; for (int i = 0; i < LINES; i++) { mismatch = 0; current = -1; score = 0; for (int j = 0; matrix[i][j] != '\0'; j++) { switch(matrix[i][j]) { case '}': if (stack[current--] != '{') { mismatch = 1; } break; case ')': if (stack[current--] != '(') { mismatch = 1; }; break; case ']': if (stack[current--] != '[') { mismatch = 1; }; break; case '>': if (stack[current--] != '<') { mismatch = 1; }; break; default: stack[++current] = matrix[i][j]; } if (mismatch) break; } if (!mismatch) { stack[current+1] ='\0'; for (int k = current ; k >= 0; k--) { score *= 5; switch(stack[k]) { case '[': score += 2; break; case '(': score += 1; break; case '{': score += 3; break; case '<': score += 4; break; } } scores[++score_index] = score; } } qsort(scores, score_index+1, sizeof(long), &compare); printf("middle score is: %ld\n", scores[score_index/2]); return 0; }
the_stack_data/165766785.c
/* * Program from the introduction of * 2013CAV - Brockschmidt,Cook,Fuhs - Better termination proving through cooperation -draft * * Date: 12.12.2013 * Author: [email protected] * */ typedef enum {false, true} bool; extern int __VERIFIER_nondet_int(void); int main() { int x, y; x = __VERIFIER_nondet_int(); y = 1; while (x > 0) { x = x - y; y = y + 1; } return 0; }
the_stack_data/48574800.c
#include <stdio.h> main() { int i = 0; printf("i++=%d\n", i++); printf("i=%d\n", i); printf("++i=%d\n", ++i); printf("i=%d\n", i); }
the_stack_data/42266.c
#include <math.h>
the_stack_data/65520.c
#define _GNU_SOURCE #include <dlfcn.h> /* for RTLD_NEXT */ #include <pthread.h> /* for mutextes */ #include <unistd.h> /* for usleep(3) */ #include <stdlib.h> #include <stdio.h> #include <string.h> #include <stdarg.h> #include <stddef.h> #include <string.h> #include <ctype.h> #include <limits.h> #include <errno.h> #include <netdb.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #define SH_SOCKET_DESC_SIZE 256 /*************************************************************************** * helpers * ***************************************************************************/ static void set_errno(int value) { errno=value; } static void set_h_errno(int value) { h_errno=value; } #if 0 static const char * get_envs(const char *name, const char *def) { const char *s=getenv(name); return (s)?s:def; } #endif static int get_envi(const char *name, int def) { const char *s=getenv(name); int i; if (s) { i=(int)strtol(s,NULL,0); } else { i=def; } return i; } #ifdef SH_CONTEXT_TRACKING static unsigned int get_envui(const char *name, unsigned int def) { const char *s=getenv(name); int i; if (s) { i=(unsigned)strtoul(s,NULL,0); } else { i=def; } return i; } #endif static size_t buf_printf(char *buf, size_t pos, size_t size, const char *fmt, ...) { va_list args; size_t left=size-pos; int r; va_start(args, fmt); r=vsnprintf(buf+pos, left, fmt, args); va_end(args); if (r > 0) { size_t written=(size_t)r; pos += (written >= left)?left:written; } return pos; } static void parse_name(char *buf, size_t size, const char *name_template, unsigned int ctx_num) { struct timespec ts_now; int in_escape=0; size_t pos=0; char c; buf[--size]=0; /* resverve space for final NUL terminator */ while ( (pos < size) && (c=*(name_template++)) ) { if (in_escape) { switch(c) { case '%': buf[pos++]=c; break; case 'c': pos=buf_printf(buf,pos,size,"%u",ctx_num); break; case 'p': pos=buf_printf(buf,pos,size,"%u",(unsigned)getpid()); break; case 't': clock_gettime(CLOCK_REALTIME, &ts_now); pos=buf_printf(buf,pos,size,"%09lld.%ld", (long long)ts_now.tv_sec, ts_now.tv_nsec); break; default: pos=buf_printf(buf,pos,size,"%%%c",c); } in_escape=0; } else { switch(c) { case '%': in_escape=1; break; default: buf[pos++]=c; } } } buf[pos]=0; } static int get_string_idx(const char *str, const char **modes, int default_value, int case_sensitive) { int idx; if (!str ||!modes) { return default_value; } for (idx=0; modes[idx]; idx++) { int cmp=(case_sensitive)?strcmp(modes[idx],str):strcasecmp(modes[idx],str); if (!cmp) { return idx; } } return default_value; } /*************************************************************************** * MESSAGE OUTPUT * ***************************************************************************/ typedef enum { SH_MSG_NONE=0, SH_MSG_ERROR, SH_MSG_WARNING, SH_MSG_INFO, SH_MSG_DEBUG, SH_MSG_DEBUG_INTERCEPTION } SH_msglevel; #ifdef NDEBUG #define SH_MSG_LEVEL_DEFAULT SH_MSG_WARNING #else #define SH_MSG_LEVEL_DEFAULT SH_MSG_DEBUG_INTERCEPTION #endif #define SH_DEFAULT_OUTPUT_STREAM stderr static void SH_verbose(int level, const char *fmt, ...) { static int verbosity=-1; static FILE *output_stream=NULL; static int stream_initialized=0; va_list args; if (verbosity < 0) { verbosity=get_envi("SH_VERBOSE", SH_MSG_LEVEL_DEFAULT); } if (level > verbosity) { return; } if (!stream_initialized) { const char *file=getenv("SH_VERBOSE_FILE"); if (file) { char buf[PATH_MAX]; parse_name(buf, sizeof(buf), file, 0); output_stream=fopen(buf,"a+t"); } if (!output_stream) output_stream=SH_DEFAULT_OUTPUT_STREAM; stream_initialized=1; } fprintf(output_stream,"SH: "); va_start(args, fmt); vfprintf(output_stream, fmt, args); va_end(args); fflush(output_stream); } /*************************************************************************** * FUNCTION INTERCEPTOR LOGIC * ***************************************************************************/ typedef void (*SH_fptr)(); typedef void * (*SH_resolve_func)(const char *); /* mutex used during SH_dlsym_internal () */ static pthread_mutex_t SH_mutex=PTHREAD_MUTEX_INITIALIZER; /* Mutex for the function pointers. We only guard the * if (ptr == NULL) ptr=...; part. The pointers will never * change after being set to a non-NULL value for the first time, * so it is safe to dereference them without locking */ static pthread_mutex_t SH_fptr_mutex=PTHREAD_MUTEX_INITIALIZER; /* THIS IS AN EVIL HACK: we directly call _dl_sym() of the glibc */ extern void *_dl_sym(void *, const char *, void (*)() ); /* Wrapper function called in place of dlsym(), since we intercept dlsym(). * We use this ONLY to get the original dlsym() itself, all other symbol * resolutions are done via that original function, then. */ static void *SH_dlsym_internal(void *handle, const char *name) { void *ptr; /* ARGH: we are bypassing glibc's locking for dlsym(), so we * must do this on our own */ pthread_mutex_lock(&SH_mutex); /* Third argument is the address of the caller, (glibc uses stack * unwinding internally to get this), we just use the address of our * wrapper function itself, which is wrong when this is called on * behalf of the real application doing a dlsycm, but we do not * care... */ ptr=_dl_sym(handle, name, (void (*)())SH_dlsym_internal); pthread_mutex_unlock(&SH_mutex); return ptr; } /* Wrapper funtcion to query the original dlsym() function avoiding * recursively calls to the interceptor dlsym() below */ static void *SH_dlsym_internal_next(const char *name) { return SH_dlsym_internal(RTLD_NEXT, name); } /* return intercepted function pointer for a symbol */ static void *SH_get_interceptor(const char*, SH_resolve_func, const char *); /* function pointers to call the real functions that we did intercept */ static void * (* volatile SH_dlsym)(void *, const char*)=NULL; static void * (* volatile SH_dlvsym)(void *, const char*, const char *)=NULL; static int (* volatile SH_socket)(int, int, int)=NULL; static int (* volatile SH_connect)(int, const struct sockaddr*, socklen_t)=NULL; static struct hostent * (* volatile SH_gethostbyname)(const char *)=NULL; static struct hostent * (* volatile SH_gethostbyname2)(const char *, int)=NULL; static struct hostent * (* volatile SH_gethostbyaddr)(const void *, socklen_t, int)=NULL; static int (* volatile SH_gethostbyname_r)(const char *, struct hostent *, char *, size_t, struct hostent **, int *); static int (* volatile SH_gethostbyname2_r)(const char *, int, struct hostent *, char *, size_t, struct hostent **, int *); static int (* volatile SH_gethostbyaddr_r)(const void *, socklen_t, int, struct hostent *, char *, size_t, struct hostent **, int *); static int (* volatile SH_getaddrinfo)(const char*, const char*, const struct addrinfo *, struct addrinfo **); static int (* volatile SH_getaddrinfo_a)(int, struct gaicb *list[], int, struct sigevent *); /* Resolve an unintercepted symbol via the original dlsym() */ static void *SH_dlsym_next(const char *name) { return SH_dlsym(RTLD_NEXT, name); } /* helper macro: query the symbol pointer if it is NULL * handle the locking */ #define SH_GET_PTR(func) \ pthread_mutex_lock(&SH_fptr_mutex); \ if(SH_ ##func == NULL) \ SH_ ##func = SH_dlsym_next(#func);\ pthread_mutex_unlock(&SH_fptr_mutex) /*************************************************************************** * INTERCEPTED FUNCTIONS: libdl/libc * ***************************************************************************/ /* intercept dlsym() itself */ extern void * dlsym(void *handle, const char *name) { void *interceptor; void *ptr; /* special case: we cannot use SH_GET_PTR as it relies on * SH_dlsym() which we have to query using SH_dlsym_internal */ pthread_mutex_lock(&SH_fptr_mutex); \ if(SH_dlsym == NULL) SH_dlsym = SH_dlsym_internal_next("dlsym"); pthread_mutex_unlock(&SH_fptr_mutex); interceptor=SH_get_interceptor(name, SH_dlsym_next, "dlsym"); ptr=(interceptor)?interceptor:SH_dlsym(handle,name); SH_verbose(SH_MSG_DEBUG_INTERCEPTION,"dlsym(%p, %s) = %p%s\n",handle,name,ptr, interceptor?" [intercepted]":""); return ptr; } /* also intercept GNU specific dlvsym() */ extern void * dlvsym(void *handle, const char *name, const char *version) { void *interceptor; void *ptr; SH_GET_PTR(dlvsym); \ interceptor=SH_get_interceptor(name, SH_dlsym_next, "dlsym"); ptr=(interceptor)?interceptor:SH_dlvsym(handle,name,version); SH_verbose(SH_MSG_DEBUG_INTERCEPTION,"dlvsym(%p, %s, %s) = %p%s\n",handle,name,version,ptr, interceptor?" [intercepted]":""); return ptr; } /*************************************************************************** * SOCKET ADDRESSES * ***************************************************************************/ static int validate_sockaddr(const struct sockaddr *addr, socklen_t addrlen) { (void)addr; if (addrlen > sizeof(struct sockaddr_storage)) { SH_verbose(SH_MSG_WARNING, "got invalid socket address from application: addrlen %d > max addr len %d\n", (int)addrlen, (int)sizeof(struct sockaddr_storage)); return -1; } switch (addr->sa_family) { case AF_INET: if (addrlen < offsetof(struct sockaddr_in,sin_zero)) { SH_verbose(SH_MSG_WARNING, "got invalid socket address from application: IPv4 addrlen %d < %d\n", (int)addrlen, (int)offsetof(struct sockaddr_in,sin_zero)); return -1; } if (addrlen != sizeof(struct sockaddr_in)) { SH_verbose(SH_MSG_WARNING, "IPv4 addrlen %d != %d\n", (int)addrlen, (int)sizeof(struct sockaddr_in)); return 1; } break; case AF_INET6: if (addrlen < offsetof(struct sockaddr_in6,sin6_scope_id)) { SH_verbose(SH_MSG_WARNING, "got invalid socket address from application: IPv6 addrlen %d < %d\n", (int)addrlen, (int)offsetof(struct sockaddr_in6,sin6_scope_id)); return -1; } if (addrlen != sizeof(struct sockaddr_in6)) { SH_verbose(SH_MSG_WARNING, "IPv6 addrlen %d != %d\n", (int)addrlen, (int)sizeof(struct sockaddr_in6)); return 1; } break; } return 0; } /* write human-readbale description of a sockaddr to buf, which must be * at least SH_SOCKET_DESC_SIZE bytes big, and returns buf */ static char *describe_sockaddr(char *buf, const struct sockaddr *addr, socklen_t addrlen) { switch (addr->sa_family) { case AF_INET: { const struct sockaddr_in *a=(const struct sockaddr_in *)addr; snprintf(buf, SH_SOCKET_DESC_SIZE, "IPv4:%s:%u", inet_ntoa(a->sin_addr),ntohs(a->sin_port)); } break; case AF_INET6: { const struct sockaddr_in6 *a=(const struct sockaddr_in6 *)addr; const char *b=(const char*)&a->sin6_addr; snprintf(buf, SH_SOCKET_DESC_SIZE, "IPv6:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%u", b[0], b[1], b[2], b[3], b[4], b[5], b[6], b[7], b[8], b[9], b[10], b[11], b[12], b[13], b[14], b[15], ntohs(a->sin6_port)); } break; default: snprintf(buf, SH_SOCKET_DESC_SIZE, "family=%d len=%d", addr->sa_family,(int)addrlen); } return buf; } /*************************************************************************** * SOCKET INTERCEPTION LOGIC * ***************************************************************************/ /* the different interception modes */ typedef enum { SH_SOCKET_UNINITIALIZED=-1, /* only for internal use */ /* real modes follow */ SH_SOCKET_NONE=0, SH_SOCKET_LOCAL, SH_SOCKET_ALL } SH_socket_mode; static SH_socket_mode get_socket_mode(void) { static pthread_mutex_t mutex=PTHREAD_MUTEX_INITIALIZER; static SH_socket_mode mode=SH_SOCKET_UNINITIALIZED; pthread_mutex_lock(&mutex); if (mode == SH_SOCKET_UNINITIALIZED) { static const char *modes[]={ "none", "local", "all", NULL }; const char *str = getenv("SH_SOCKET"); mode=get_string_idx(str, modes, SH_SOCKET_ALL, 0); } pthread_mutex_unlock(&mutex); return mode; } static int socket_intercept(int domain, int type, int protocol) { int res; switch(get_socket_mode()) { case SH_SOCKET_NONE: SH_verbose(SH_MSG_INFO, "rejected socket(%d, %d, %d)\n", domain, type, protocol); set_errno(EACCES); return -1; case SH_SOCKET_LOCAL: if (domain != AF_UNIX && domain != AF_LOCAL) { SH_verbose(SH_MSG_INFO, "rejected socket(%d, %d, %d): non-local\n", domain, type, protocol); set_errno(EACCES); return -1; } break; case SH_SOCKET_ALL: (void)0; break; default: SH_verbose(SH_MSG_ERROR, "invalid SH_SOCKET mode %d\n", get_socket_mode()); } res=SH_socket(domain, type, protocol); if (res < 0) { SH_verbose(SH_MSG_WARNING, "socket(%d, %d, %d) call failed with %d:%s\n", domain, type, protocol, errno, strerror(errno)); } return res; } static int connect_intercept(int sockfd, const struct sockaddr *addr, socklen_t addrlen, char *buf) { int res=SH_connect(sockfd, addr, addrlen); if (res < 0) { if (errno == EINPROGRESS) { SH_verbose(SH_MSG_DEBUG,"connect(%d, [%s]) in progress\n", errno, describe_sockaddr(buf, addr, addrlen)); } else { SH_verbose(SH_MSG_WARNING,"connect(%d, [%s]) call failed with %d:%s\n", errno, describe_sockaddr(buf, addr, addrlen), strerror(errno)); } } return res; } static struct hostent *gethostbyname_intercept(const char *name) { struct hostent *res=SH_gethostbyname(name); if (!res) { SH_verbose(SH_MSG_WARNING,"gethostbyname(%s) call failed with %d:%s\n", name, h_errno, hstrerror(h_errno)); } return res; } static int gethostbyname_r_intercept(const char *name, struct hostent *ret, char *buf, size_t buflen, struct hostent **result, int *h_errnop) { int res=SH_gethostbyname_r(name, ret, buf, buflen, result, h_errnop); if (res < 0) { if (h_errnop) { SH_verbose(SH_MSG_WARNING,"gethostbyname_r(%s) call failed with %d:%s\n", name, *h_errnop, hstrerror(*h_errnop)); } else { SH_verbose(SH_MSG_WARNING,"gethostbyname_r(%s) call failed\n", name); } } return res; } static struct hostent *gethostbyname2_intercept(const char *name, int af) { struct hostent *res=SH_gethostbyname2(name, af); if (!res) { SH_verbose(SH_MSG_WARNING,"gethostbyname2(%s, %d) call failed with %d:%s\n", name, af, h_errno, hstrerror(h_errno)); } return res; } static int gethostbyname2_r_intercept(const char *name, int af, struct hostent *ret, char *buf, size_t buflen, struct hostent **result, int *h_errnop) { int res=SH_gethostbyname2_r(name, af, ret, buf, buflen, result, h_errnop); if (res < 0) { if (h_errnop) { SH_verbose(SH_MSG_WARNING,"gethostbyname_r(%s, %d) call failed with %d:%s\n", name, af, *h_errnop, hstrerror(*h_errnop)); } else { SH_verbose(SH_MSG_WARNING,"gethostbyname_r(%s, %d) call failed\n", name, af); } } return res; } static struct hostent *gethostbyaddr_intercept(const void *addr, socklen_t len, int type) { struct hostent *res=SH_gethostbyaddr(addr, len, type); if (!res) { SH_verbose(SH_MSG_WARNING,"gethostbyaddr([...], %d) call failed with %d:%s\n", type, h_errno, hstrerror(h_errno)); } return res; } static int gethostbyaddr_r_intercept(const void *addr, socklen_t len, int type, struct hostent *ret, char *buf, size_t buflen, struct hostent **result, int *h_errnop) { int res=SH_gethostbyaddr_r(addr, len, type, ret, buf, buflen, result, h_errnop); if (res < 0) { if (h_errnop) { SH_verbose(SH_MSG_WARNING,"gethostbyaddr_r([...], %d) call failed with %d:%s\n", type, *h_errnop, hstrerror(*h_errnop)); } else { SH_verbose(SH_MSG_WARNING,"gethostbyaddr_r([...], %d) call failed\n", type); } } return res; } static int getaddrinfo_intercept(const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res) { int result=SH_getaddrinfo(node, service, hints, res); if (result != 0) { SH_verbose(SH_MSG_WARNING,"getaddrinfo(%s, %s) failed with %d\n", node, service, result); } return result; } static int getaddrinfo_a_intercept(int mode, struct gaicb *list[], int nitems, struct sigevent *sevp) { int result=SH_getaddrinfo_a(mode, list, nitems, sevp); if (result != 0) { SH_verbose(SH_MSG_WARNING,"getaddrinfo_a(%d, [...], %d) failed with %d\n", mode, nitems, result); } return result; } /*************************************************************************** * INTERCEPTED FUNCTIONS: socket API * ***************************************************************************/ /* Actually, our goal is to intercept glXSwapInterval[EXT|SGI]() etc. But * these are extension functions not required to be provided as external * symbols. However, some applications just likn them anyways, so we have * to handle the case were dlsym() or glXGetProcAddress[ARB]() is used to * query the function pointers, and have to intercept these as well. */ extern int socket(int domain, int type, int protocol) { int result; SH_GET_PTR(socket); if (SH_socket == NULL) { SH_verbose(SH_MSG_ERROR,"socket() can't be reached!\n"); set_errno(EINVAL); result=-1; } else { result=socket_intercept(domain, type, protocol); } SH_verbose(SH_MSG_DEBUG,"socket(%d,%d,%d) = %d\n",domain, type, protocol, result); return result; } extern int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen) { int result=-1; char buf[SH_SOCKET_DESC_SIZE]; if (validate_sockaddr(addr, addrlen) < 0) { SH_verbose(SH_MSG_DEBUG,"connect(%d,[...]) = %d due to invalid addr\n", sockfd, result); set_errno(EAFNOSUPPORT); return result; } SH_GET_PTR(connect); if (SH_connect == NULL) { SH_verbose(SH_MSG_ERROR,"connect() can't be reached!\n"); set_errno(ENETUNREACH); } else { result=connect_intercept(sockfd, addr, addrlen, buf); } SH_verbose(SH_MSG_DEBUG,"connect(%d,[%s]) = %d\n", sockfd, describe_sockaddr(buf, addr, addrlen), result); return result; } extern struct hostent *gethostbyname(const char *name) { struct hostent *result=NULL; SH_GET_PTR(gethostbyname); if (SH_gethostbyname == NULL) { SH_verbose(SH_MSG_ERROR,"gethosbyname() can't be reached!\n"); set_h_errno(NO_RECOVERY); } else { result=gethostbyname_intercept(name); } SH_verbose(SH_MSG_DEBUG,"gethosybyname(%s) = %p\n", name, result); return result; } extern int gethostbyname_r(const char *name, struct hostent *ret, char *buf, size_t buflen, struct hostent **result, int *h_errnop) { int res=-1; if (result) { *result=NULL; } SH_GET_PTR(gethostbyname_r); if (SH_gethostbyname_r == NULL) { SH_verbose(SH_MSG_ERROR,"gethosbyname_r() can't be reached!\n"); if (h_errnop) { *h_errnop=NO_RECOVERY; } } else { res=gethostbyname_r_intercept(name, ret, buf, buflen, result, h_errnop); } SH_verbose(SH_MSG_DEBUG,"gethosybyname_r(%s) = %d\n", name, res); return res; } extern struct hostent *gethostbyname2(const char *name, int af) { struct hostent *result=NULL; SH_GET_PTR(gethostbyname2); if (SH_gethostbyname2 == NULL) { SH_verbose(SH_MSG_ERROR,"gethosbyname2() can't be reached!\n"); set_h_errno(NO_RECOVERY); } else { result=gethostbyname2_intercept(name, af); } SH_verbose(SH_MSG_DEBUG,"gethosybyname2(%s, %d) = %p\n", name, af, result); return result; } extern int gethostbyname2_r(const char *name, int af, struct hostent *ret, char *buf, size_t buflen, struct hostent **result, int *h_errnop) { int res=-1; if (result) { *result=NULL; } SH_GET_PTR(gethostbyname2_r); if (SH_gethostbyname2_r == NULL) { SH_verbose(SH_MSG_ERROR,"gethosbyname2_r() can't be reached!\n"); if (h_errnop) { *h_errnop=NO_RECOVERY; } } else { res=gethostbyname2_r_intercept(name, af, ret, buf, buflen, result, h_errnop); } SH_verbose(SH_MSG_DEBUG,"gethosybyname2_r(%s, %d) = %d\n", name, af, res); return res; } extern struct hostent *gethostbyaddr(const void *addr, socklen_t len, int type) { struct hostent *result=NULL; SH_GET_PTR(gethostbyaddr); if (SH_gethostbyaddr == NULL) { SH_verbose(SH_MSG_ERROR,"gethosbyaddr() can't be reached!\n"); set_h_errno(NO_RECOVERY); } else { result=gethostbyaddr_intercept(addr, len, type); } SH_verbose(SH_MSG_DEBUG,"gethosybyaddr([...], %d) = %p\n", type, result); return result; } extern int gethostbyaddr_r(const void *addr, socklen_t len, int type, struct hostent *ret, char *buf, size_t buflen, struct hostent **result, int *h_errnop) { int res=-1; if (result) { *result=NULL; } SH_GET_PTR(gethostbyaddr_r); if (SH_gethostbyaddr_r == NULL) { SH_verbose(SH_MSG_ERROR,"gethosbyaddr_r() can't be reached!\n"); if (h_errnop) { *h_errnop=NO_RECOVERY; } } else { res=gethostbyaddr_r_intercept(addr, len, type, ret, buf, buflen, result, h_errnop); } SH_verbose(SH_MSG_DEBUG,"gethosybyaddr_r([...], %d) = %d\n", type, res); return res; } extern int getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res) { int result=EAI_FAIL; if (res) { *res=NULL; } SH_GET_PTR(getaddrinfo); if (SH_getaddrinfo == NULL) { SH_verbose(SH_MSG_ERROR,"getaddrinfo() can't be reached!\n"); } else { result=getaddrinfo_intercept(node, service, hints, res); } SH_verbose(SH_MSG_DEBUG,"getaddrinfo(%s, %s) = %d\n", node, service, result); return result; } extern int getaddrinfo_a(int mode, struct gaicb *list[], int nitems, struct sigevent *sevp) { int result=EAI_MEMORY; SH_GET_PTR(getaddrinfo_a); if (SH_getaddrinfo_a == NULL) { SH_verbose(SH_MSG_ERROR,"getaddrinfo_a() can't be reached!\n"); } else { result=getaddrinfo_a_intercept(mode, list, nitems, sevp); } SH_verbose(SH_MSG_DEBUG,"getaddrinfo_a(%d, [...], %d) = %d\n", mode, nitems, result); return result; } /*************************************************************************** * LIST OF INTERCEPTED FUNCTIONS * ***************************************************************************/ /* return intercepted fuction pointer for "name", or NULL if * "name" is not to be intercepted. If function is intercepted, * use query to resolve the original function pointer and store * it in the SH_"name" static pointer. That way, we use the same * function the original application were using without the interceptor. * The interceptor functions will fall back to using SH_dlsym() if the * name resolution here did fail for some reason. */ static void* SH_get_interceptor(const char *name, SH_resolve_func query, const char *query_name ) { #define SH_INTERCEPT(func) \ if (!strcmp(#func, name)) {\ pthread_mutex_lock(&SH_fptr_mutex); \ if ( (SH_ ##func == NULL) && query) { \ SH_ ##func = query(#func); \ SH_verbose(SH_MSG_DEBUG,"queried internal %s via %s: %p\n", \ name,query_name, SH_ ##func); \ } \ pthread_mutex_unlock(&SH_fptr_mutex); \ return func; \ } SH_INTERCEPT(dlsym); SH_INTERCEPT(dlvsym); SH_INTERCEPT(socket); SH_INTERCEPT(connect); SH_INTERCEPT(gethostbyname); SH_INTERCEPT(gethostbyname_r); SH_INTERCEPT(gethostbyname2); SH_INTERCEPT(gethostbyname2_r); SH_INTERCEPT(gethostbyaddr); SH_INTERCEPT(gethostbyaddr_r); SH_INTERCEPT(getaddrinfo); SH_INTERCEPT(getaddrinfo_a); return NULL; }
the_stack_data/725963.c
const char net_ifcvf_pmd_info[] __attribute__((used)) = "PMD_INFO_STRING= {\"name\" : \"net_ifcvf\", \"kmod\" : \"* vfio-pci\", \"pci_ids\" : [[6900, 4161, 32902, 26] ]}";
the_stack_data/82950209.c
/* command----------------------------------------------------------------lassen205_18657_tests_group_3_test_7.c $ /usr/tce/packages/xl/xl-2019.02.07/bin/xlc -o test_O0 -O0 test.c -lm $ ./test_O0 -1.2369E-88 5 +1.1363E-307 -1.8711E-50 +0.0 -1.1423E-307 -1.1175E-86 -0.0 -1.5849E7 -0.0 +1.3836E-307 +1.6902E-307 8.4630153700128806e-13 $ /usr/tce/packages/xl/xl-2019.02.07/bin/xlc -o test_O3 -O3 test.c -lm $ ./test_O3 -1.2369E-88 5 +1.1363E-307 -1.8711E-50 +0.0 -1.1423E-307 -1.1175E-86 -0.0 -1.5849E7 -0.0 +1.3836E-307 +1.6902E-307 8.4630153678381065e-13 --------------------------------------------------------------------------*/ /* This is a automatically generated test. Do not modify */ #include <stdio.h> #include <stdlib.h> #include <math.h> void compute(double comp, int var_1,double var_2,double var_3,double var_4,double var_5,double var_6,double var_7,double var_8,double var_9,double var_10,double var_11) { double tmp_1 = +1.7333E-314; comp += tmp_1 - +0.0 - var_2 - -1.0739E-310 * (var_3 + var_4); for (int i=0; i < var_1; ++i) { comp += (-1.4742E-306 - var_5 - asin(-1.5989E-310 + -1.3994E306 / (+1.9726E305 / var_6))); } if (comp < (-1.8843E-306 - (var_7 + floor((var_8 + -1.4664E-322 - -1.8196E306 * var_9))))) { comp += (-0.0 / (+0.0 - var_10)); comp = (+1.4304E-319 / var_11); } printf("%.17g\n", comp); } double* initPointer(double v) { double *ret = (double*) malloc(sizeof(double)*10); for(int i=0; i < 10; ++i) ret[i] = v; return ret; } int main(int argc, char** argv) { /* Program variables */ double tmp_1 = atof(argv[1]); int tmp_2 = atoi(argv[2]); double tmp_3 = atof(argv[3]); double tmp_4 = atof(argv[4]); double tmp_5 = atof(argv[5]); double tmp_6 = atof(argv[6]); double tmp_7 = atof(argv[7]); double tmp_8 = atof(argv[8]); double tmp_9 = atof(argv[9]); double tmp_10 = atof(argv[10]); double tmp_11 = atof(argv[11]); double tmp_12 = atof(argv[12]); compute(tmp_1,tmp_2,tmp_3,tmp_4,tmp_5,tmp_6,tmp_7,tmp_8,tmp_9,tmp_10,tmp_11,tmp_12); return 0; }
the_stack_data/32949535.c
#include <stdlib.h> #include <stdio.h> #include <string.h> #include <ctype.h> #include <math.h> #define AA "GAVLIFPSTCMWYNQDEKRH" #define AAN 20 #define MSL 40000 #define ML 1000 #define DLC 1 #define DUC 100 #define DWS 10 #define DMin_Ene 0.3 #define DJOIN 45 #define DDEL 35 #define MAX(a,b) ((a)>(b)?(a):(b)) #define MIN(a,b) ((a)<(b)?(a):(b)) typedef struct { char name[1000]; int le; char *seq; double expscore; double *eprof; double *smp; double *en; int ngr; int **gr; } SEQ_STR; typedef struct { double **CC; double *distro; double min, max; double step; double cutoff; int nb; } P_STR; void read_mat(char *path, char *fn, double **MAT, double *matave); int getargs(char *line,char *args[],int max); void read_ref(char *path, char *fn, double **REF); void Get_Histo( P_STR *P, char *path, char *); double **DMatrix(int n_rows, int n_cols); void *my_malloc(size_t size); void IUPred(SEQ_STR *SEQ, P_STR *P); void getRegions(SEQ_STR *SEQ ); void Get_Seq(char *seq, SEQ_STR *SEQ); int LC, UC, WS; double Min_Ene; int JOIN, DEL; int Flag_EP; double EP; int main(int argc, char **argv) { P_STR *P; SEQ_STR *SEQ; int i,j; int type; char *path; if (argc!=3) { printf(" Usage: %s sequence type \n",argv[0]); printf(" where type stands for one of the options of \n"); printf(" \"long\", \"short\" or \"glob\"\n"); exit(1); } if ((path=getenv("IUPred_PATH"))==NULL) { fprintf(stderr,"IUPred_PATH environment variable is not set\n"); path="./"; } if ((strncmp(argv[2],"long",4))==0) { type=0; } else if ((strncmp(argv[2],"short",5))==0) { type=1; } else if ((strncmp(argv[2],"glob",4))==0) { type=2; } else { printf("Wrong argument\n");exit(1); } SEQ=malloc(sizeof(SEQ_STR)); Get_Seq(argv[1],SEQ); if (SEQ->le==0) {printf(" Sequence length 0\n");exit(1);} #ifdef DEBUG printf("%s %d\n%s\n",SEQ->name,SEQ->le,SEQ->seq); #endif P=malloc(sizeof(P_STR)); P->CC= DMatrix(AAN,AAN); if (type==0) { LC=1; UC=100; WS=10; Flag_EP=0; read_ref(path,"ss",P->CC); Get_Histo(P, path, "histo"); IUPred(SEQ,P); for (i=0;i<SEQ->le;i++) printf("%5d %c %10.4f\n",i+1,SEQ->seq[i],SEQ->en[i]); } if (type==1) { LC=1; UC=25; WS=10; Flag_EP=1; EP=-1.26; read_ref(path,"ss_casp",P->CC); Get_Histo(P, path, "histo_casp"); IUPred(SEQ,P); printf("# Prediction output \n"); printf("# %s\n",SEQ->name); for (i=0;i<SEQ->le;i++) printf("%5d %c %10.4f\n",i+1,SEQ->seq[i],SEQ->en[i]); } if (type==2) { char *globseq; LC=1; UC=100; WS=15; Flag_EP=0; read_ref(path,"ss",P->CC); Get_Histo(P,path,"histo"); IUPred(SEQ,P); Min_Ene=DMin_Ene; JOIN=DJOIN; DEL=DDEL; getRegions(SEQ); globseq=malloc((SEQ->le+1)*sizeof(char)); for (i=0;i<SEQ->le;i++) globseq[i]=tolower(SEQ->seq[i]); printf("# Prediction output \n"); printf("# %s\n",SEQ->name); printf("Number of globular domains: %5d \n",SEQ->ngr); for (i=0;i<SEQ->ngr;i++) { printf(" globular domain %5d. %d - %d \n", i+1,SEQ->gr[i][0]+1,SEQ->gr[i][1]+1); for (j=SEQ->gr[i][0];j<SEQ->gr[i][1]+1;j++) { globseq[j]=toupper(globseq[j]); } } printf(">%s\n",SEQ->name); for (i=0;i<SEQ->le;i++) { if ((i>0)&&(i%60==0)) printf("\n"); else if ((i>0)&&(i%10==0)) printf(" "); printf("%c",globseq[i]); } printf("\n"); free(globseq); #ifdef DEBUG for (i=0;i<SEQ->le;i++) printf("%5d %c %10.4f\n",i,SEQ->seq[i],SEQ->en[i]); #endif } free(SEQ->seq); free(SEQ->eprof);free(SEQ->en);free(SEQ->smp); free(SEQ); return 0; } void IUPred(SEQ_STR *SEQ, P_STR *P) { int i,j, a1, a2, p; int naa; double n2; double min, max, step; naa=SEQ->le; min=P->min; max=P->max;step=P->step; SEQ->eprof=malloc(naa*sizeof(double)); for (i=0;i<naa;i++) SEQ->eprof[i]=0; SEQ->en=malloc(naa*sizeof(double)); for (i=0;i<naa;i++) SEQ->en[i]=0; SEQ->smp=malloc(naa*sizeof(double)); for (i=0;i<naa;i++) SEQ->smp[i]=0; SEQ->expscore=0; for (i=0;i<naa;i++) { a1=strchr(AA,((toupper(SEQ->seq[i]))))-AA; if ((a1<0) || (a1>=AAN)) continue; n2=0; for (j=0;j<naa;j++) if (((abs(i-j))>LC)&&((abs(i-j))<UC)) { a2=strchr(AA,((toupper(SEQ->seq[j]))))-AA; if ((a2<0) || (a2>=AAN)) continue; SEQ->eprof[i]+=P->CC[a1][a2]; n2++; } SEQ->expscore+=SEQ->eprof[i]/(naa*n2); SEQ->eprof[i]/=n2; } if (Flag_EP==0) { for (i=0;i<naa;i++) { n2=0; for (j=MAX(0,i-WS);j<=MIN(naa,i+WS+1);j++) { SEQ->smp[i]+=SEQ->eprof[j]; n2++; } SEQ->smp[i]/=n2; } } else { for (i=0;i<naa;i++) { n2=0; for (j=i-WS;j<i+WS;j++) { if ((j<0)||(j>=naa)) SEQ->smp[i]+=EP; else SEQ->smp[i]+=SEQ->eprof[j]; n2++; } SEQ->smp[i]/=n2; } } for (i=0;i<naa;i++) { if (SEQ->smp[i]<=min+2*step) SEQ->en[i]=1; if (SEQ->smp[i]>=max-2*step) SEQ->en[i]=0; if ((SEQ->smp[i]>min+2*step)&&(SEQ->smp[i]<max-2*step)) { p=(int)((SEQ->smp[i]-min)*(1.0/step)); SEQ->en[i]=P->distro[p]; } #ifdef DEBUG printf("%5d %10.4f %10.4f %10.4f\n", i,SEQ->eprof[i], SEQ->smp[i],SEQ->en[i]); #endif } } void getRegions(SEQ_STR *SEQ ) { int naa; int i, k,kk; int **GR, **mGR; int in_GR; int nr, mnr; int beg_GR, end_GR; int beg,end; naa=SEQ->le; GR=NULL; nr=0; in_GR=0; beg_GR=end_GR=0; for (i=0;i<naa;i++) { if ((in_GR==1)&&(SEQ->smp[i]<=Min_Ene)) { GR=realloc(GR,(nr+1)*sizeof(int *)); GR[nr]=malloc(2*sizeof(int)); GR[nr][0]=beg_GR; GR[nr][1]=end_GR; in_GR=0; nr++; } else if (in_GR==1) end_GR++; if ((SEQ->smp[i]>Min_Ene)&&(in_GR==0)) { beg_GR=i; end_GR=i; in_GR=1; } } if (in_GR==1) { GR=realloc(GR,(nr+1)*sizeof(int *)); GR[nr]=malloc(2*sizeof(int)); GR[nr][0]=beg_GR; GR[nr][1]=end_GR; in_GR=0; nr++; } mnr=0; k=0;mGR=NULL; kk=k+1; if (nr>0) { beg=GR[0][0];end=GR[0][1]; } while (k<nr) { if ((kk<nr)&&(GR[kk][0]-end)<JOIN) { beg=GR[k][0]; end=GR[kk][1]; kk++; } else if ((end-beg+1)<DEL) { k++; if (k<nr) { beg=GR[k][0]; end=GR[k][1]; } } else { mGR=realloc(mGR,(mnr+1)*sizeof(int*)); mGR[mnr]=malloc(2*sizeof(int)); mGR[mnr][0]=beg; mGR[mnr][1]=end; mnr++; k=kk; kk++; if (k<nr) { beg=GR[k][0]; end=GR[k][1]; } } } for (i=0;i<nr;i++) free(GR[i]); free(GR); SEQ->ngr=mnr; SEQ->gr=mGR; } void Get_Histo(P_STR *P, char *path, char *fn) { FILE *f; char ln[ML]; int i,nb, set; double v, min, max, cutoff, c; char *fullfn; int sl; sl=strlen(path)+strlen(fn)+2; fullfn=malloc(sl*sizeof(char)); sprintf(fullfn,"%s/%s",path,fn); if ((f=fopen(fullfn,"r"))==NULL) { printf("Could not open %s\n",fullfn); exit(1); } fscanf(f,"%*s %lf %lf %d\n",&min, &max, &nb); P->distro=malloc(nb*sizeof(double )); for (i=0;i<nb;i++) P->distro[i]=0; for (i=0,set=0;i<nb;i++) { fgets(ln,ML,f); if (feof(f)) break; if (ln[0]=='#') continue; sscanf(ln,"%*s %lf %*s %*s %lf\n", &c,&v); if ((set==0)&&(v<=0.5)) {set=1;cutoff=c;} P->distro[i]=v; } fclose(f); P->max=max; P->min=min; P->nb=nb; P->cutoff=cutoff; P->step=(max-min)/nb; P->cutoff-=P->step; } void read_ref(char *path, char *fn, double **REF) { FILE *f; int p1,p2; double v; char line[1000],s[20]; int i,j; char *fullfn; int sl; sl=strlen(path)+strlen(fn)+2; fullfn=malloc(sl*sizeof(char)); sprintf(fullfn,"%s/%s",path,fn); if ((f=fopen(fullfn,"r"))==NULL) { printf("Could not open %s\n",fullfn); exit(1); } while (!feof(f)) { fgets(line,1000,f); sscanf(line,"%d",&p1); sscanf(&line[8],"%d",&p2); sscanf(&line[17],"%s",s); v=atof(s); REF[p1][p2]=v; } if (REF[9][9]<0) { for (i=0;i<AAN;i++) for (j=0;j<AAN;j++) REF[i][j]*=-1; } fclose(f); } void read_mat(char *path, char *fn, double **MAT, double *matave) { FILE *f; char ln[ML]; int numargs; char *args[AAN+2], AAL[AAN],a1,a2; int i,j,k ,p, q; double val; int sl; char *fullfn; sl=strlen(path)+strlen(fn)+2; fullfn=malloc(sl*sizeof(char)); sprintf(fullfn,"%s/%s",path,fn); if ((f=fopen(fullfn,"r"))==NULL) { printf("Could not open %s\n",fullfn); exit(1); } fgets(ln,ML,f); sprintf(AAL,"%s",ln); i=0; while (!feof(f)) { fgets(ln,ML,f); k=0;j=0; if (feof(f)) break; if (ln[0] == '\n') continue; if (ln[0] == '#') continue; numargs = getargs(ln,args,AAN+2); for (j=0;j<numargs;j++) { val=atof(args[j]); a1=AAL[i]; a2=AAL[j]; p=strchr(AA,a1)-AA; q=strchr(AA,a2)-AA; MAT[p][q]=val; } i++; } *matave=0; for (i=0;i<AAN;i++) for (j=0;j<AAN;j++) *matave+=MAT[i][j]; *matave/=(AAN*AAN); fclose(f); } int getargs(char *line,char *args[],int max) { char *inptr; int i; inptr=line; for (i=0;i<max;i++) { if ((args[i]=strtok(inptr," \t\n"))==NULL) break; inptr=NULL; } return(i); } void *my_malloc(size_t size) { void *new_mem; if (size == 0) return NULL; new_mem = malloc(size); if (new_mem == NULL) { fprintf(stderr, "can't allocate enough memory: %d bytes\n", size); } return new_mem; } double **DMatrix(int n_rows, int n_cols) { double **matrix; int i,j; matrix = (double **) my_malloc(n_rows*sizeof(double *)); matrix[0] = (double *) my_malloc(n_rows*n_cols*sizeof(double)); for (i = 1; i < n_rows; i++) matrix[i] = matrix[i-1] + n_cols; for (i=0;i<n_rows;i++) for (j=0;j<n_cols;j++) matrix[i][j]=0; return matrix; } void Get_Seq(char *seq, SEQ_STR *SEQ) { if ((seq==NULL)||(strlen(seq)==0)) { printf("No sequence provided, you bastard\n"),exit(1); } SEQ->seq=calloc(MSL,sizeof(char)); strcpy(SEQ->seq,seq); SEQ->le=strlen(SEQ->seq); }
the_stack_data/76699578.c
dis(x1,y1,x2,y2){return(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);} main() { int x1,y1,x2,y2,x3,y3,x4,y4,a,b,c,d; scanf("%d %d %d %d %d %d %d %d",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4); if(x1>1000 || x1<-1000 || x2>1000 || x2<-1000 || x3>1000 || x3<-1000 || x4>1000 || x4<-1000 || y1>1000 || y1<-1000 || y2>1000 || y2<-1000 || y3>1000 || y3<-1000 || y4>1000 || y4<-1000) { puts("invalid"); return; } a=(dis(x1,y1,x2,y2)==dis(x3,y3,x4,y4) && dis(x2,y2,x3,y3)==dis(x1,y1,x4,y4)); b=(a && dis(x1,y1,x2,y2)==dis(x1,y1,x4,y4)); c=!((x1-x2)*(x1-x4)+(y1-y2)*(y1-y4)); if(b && c)puts("square"); else if(a && c)puts("rectangle"); else if(b)puts("diamond"); else if(a)puts("parallelogram"); else puts("others"); }
the_stack_data/107780.c
// ----------------------------------------------------------------------------- // Filename: thread_test.c // Revision: $Id: 8afea556e335aea238c72a4e2f230da4c437b0c7 $ // Description: This file including functions to test POSIX multithreading // Created: 03/21/2016 01:20:29 PM // Compiler: GCC // Author: Jason Meng (jm), [email protected] // // Copyright (c) 2016 by Jason Meng, no rights reserved. // ----------------------------------------------------------------------------- #include <sys/types.h> #include <pthread.h> #include <unistd.h> #include <stdlib.h> #include <stdio.h> #ifndef PTHREAD_COUNT #define PTHREAD_COUNT 5 #define THREAD_SLEEP_COUNT 5 #define THREAD_SLEEP_SEC 1 #endif static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; static void print_array(const int * array, const int size, const char * tag) { printf("%s - %s [", tag, __func__); for (unsigned int i = 0; i < size; ++i) { printf("%d", array[i]); if (i < size - 1) printf(","); } printf("]\n"); } static void * runner(void * params) { int * para_list = (int *)params; // print_array(para_list, 2, __func__); int tid = para_list[0]; int sec = (para_list[1] > 0) ? para_list[1] : THREAD_SLEEP_SEC; printf("%s - Params received: tid=%d, sec=%d\n", __func__, tid, sec); for (int i = 0; i < THREAD_SLEEP_COUNT; ++i) { printf("%s - Thread %d sleep for %d sec\n", __func__, tid, sec); sleep(sec); if (para_list[1] <= 0) break; } pthread_exit(NULL); } static void * runner_with_lock(void * params) { int * para_list = (int *)params; // print_array(para_list, 2, __func__); int tid = para_list[0]; int sec = (para_list[1] > 0) ? para_list[1] : THREAD_SLEEP_SEC; pthread_mutex_lock(&mutex); printf("%s - Params received: tid=%d, sec=%d\n", __func__, tid, sec); for (int i = 0; i < THREAD_SLEEP_COUNT; ++i) { printf("%s - Thread %d sleep for %d sec\n", __func__, tid, sec); sleep(sec); if (para_list[1] <= 0) break; } pthread_mutex_unlock(&mutex); pthread_exit(NULL); } static void run_threads_join_later() { // define threads printf("%s - Define threads: runner() * %d\n", __func__, PTHREAD_COUNT); pthread_t * threads = (pthread_t *)malloc(sizeof(pthread_t) * PTHREAD_COUNT); // create threads int rc; for (int i = 0; i < PTHREAD_COUNT; ++i) { // good practice int * params = (int *)malloc(sizeof(int) * 2); params[0] = i; params[1] = 3; print_array(params, 2, __func__); printf("%s - Start thread %d\n", __func__, params[0]); rc = pthread_create(&threads[i], NULL, &runner, (void *)params); if (rc != 0) { printf("%s - Failed to start thread %d, RC = %d\n", __func__, i, rc); exit(EXIT_FAILURE); } } for (int i = 0; i < PTHREAD_COUNT; ++i) { printf("%s - Join thread %d\n", __func__, i); rc = pthread_join(threads[i], NULL); if (rc != 0) printf("%s - Failed to join thread %d, RC=%d\n", __func__, i, rc); } // clean up free(threads); threads = NULL; } /* run_threads_join_later */ static void run_threads_join_later_lock() { // define threads printf("%s - Define threads: runner_with_lock() * %d\n", __func__, PTHREAD_COUNT); pthread_t * threads = (pthread_t *)malloc(sizeof(pthread_t) * PTHREAD_COUNT); // create threads int rc; for (int i = 0; i < PTHREAD_COUNT; ++i) { // bad practice // int args[2] = {i, 1}; // good practice int * params = (int *)malloc(sizeof(int) * 2); params[0] = i; params[1] = 1; print_array(params, 2, __func__); printf("%s - Start thread %d\n", __func__, params[0]); rc = pthread_create(&threads[i], NULL, &runner_with_lock, (void *)params); // bad practice // free(params); // params = NULL; if (rc != 0) { printf("%s - Failed to start thread %d, RC = %d\n", __func__, i, rc); exit(EXIT_FAILURE); } } for (int i = 0; i < PTHREAD_COUNT; ++i) { printf("%s - Join thread %d\n", __func__, i); rc = pthread_join(threads[i], NULL); if (rc != 0) printf("%s - Failed to join thread %d, RC=%d\n", __func__, i, rc); } // clean up pthread_mutex_destroy(&mutex); free(threads); threads = NULL; } /* run_threads_join_later_lock */ static void run_threads_join_immediate() { // define threads printf("%s - Define threads: runner() * %d\n", __func__, PTHREAD_COUNT); pthread_t * threads = (pthread_t *)malloc(sizeof(pthread_t) * PTHREAD_COUNT); // create threads int params[2], rc; for (int i = 0; i < PTHREAD_COUNT; ++i) { // such practic can only be used in cases that pthread_join happens // immediately after a pthread_create params[0] = i; params[1] = 0; printf("%s - Start thread %d\n", __func__, params[0]); rc = pthread_create(&threads[i], NULL, &runner, (void *)params); if (rc != 0) { printf("%s - Failed to start thread %d, RC = %d\n", __func__, params[0], rc); exit(EXIT_FAILURE); } printf("%s - Join thread %d\n", __func__, i); pthread_join(threads[i], NULL); } // clean up free(threads); threads = NULL; } /* run_threads_join_immediate */ int main(const int argc, const char ** argv) { printf("%s\n", "*******************"); run_threads_join_immediate(); printf("%s\n", "*******************"); run_threads_join_later(); printf("%s\n", "*******************"); run_threads_join_later_lock(); exit(EXIT_SUCCESS); }
the_stack_data/28577.c
#include <stdio.h> #include <stdlib.h> /* What is typecasting / typecasting is changing the dataType of variable TEMPORARY . I HAVE WRITTEN HOE TO ASSIGN DATA TYPES AND WRITE FORMULAS IN PREVIOUS MODULES , IF YOU ARE KNEW CHECK MATH OPERATORS AND ORDER OF MATH OPERATORS MODULE, */ int main() { float avgprofit; int priceofPumpkins = 7; int sales=50; int days=9; // first i want you to write two different types of logic , try and see result avgprofit = priceofPumpkins * sales / days ; printf(" My average profit per day is %.2f\n",avgprofit); ////// avgprofit = (float)priceofPumpkins * (float)sales / (float)days ; printf(" My average profit per day is %.2f\n",avgprofit); // .2f% because we want two decimal accuracy // you should come to conclusion that first ones output is giving whole number (integer) // and second one giving float value. // talking about first one why it is int , even we set data type with float. // because in c there is a problem of converging dataType automatically , first ones output will be same (int) because // we haven't told C to convert , /* so in second logic we change the dataTypes of ( int ) into ( float ) temporary , it can be done by writing dataType ahead of variable , (dataType)(variable) ANG THIS [PROCESS USUALLY CALL TYPECATING */ return 0; }
the_stack_data/168892973.c
#include<stdio.h> #include<string.h> int main() { char str[55]; int tc,i,check,t,len; scanf("%d", &tc); for(t = 1; t<=tc; t++) { scanf("%s", str); len = strlen(str); check = 0; for(i = 0; i<len; i++) { if(str[i] == '-') { if(str[i+1] !='B' && str[i+2] != 'B' && str[i-1] != 'S' && str[i+1] != 'S') { check++; } } } printf("Case %d: %d\n",t,check); } return 0; }
the_stack_data/1217130.c
/******************************************************************************** * tools/nxstyle.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. The * ASF licenses this file to you 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. * ********************************************************************************/ /******************************************************************************** * Included Files ********************************************************************************/ #include <stdlib.h> #include <stdbool.h> #include <stdio.h> #include <stdint.h> #include <string.h> #include <strings.h> #include <ctype.h> #include <limits.h> #include <unistd.h> #include <libgen.h> /******************************************************************************** * Pre-processor Definitions ********************************************************************************/ #define NXSTYLE_VERSION "0.01" #define LINE_SIZE 512 #define RANGE_NUMBER 4096 #define DEFAULT_WIDTH 78 #define FIRST_SECTION INCLUDED_FILES #define LAST_SECTION PUBLIC_FUNCTION_PROTOTYPES #define FATAL(m, l, o) message(FATAL, (m), (l), (o)) #define FATALFL(m, s) message(FATAL, (m), -1, -1) #define WARN(m, l, o) message(WARN, (m), (l), (o)) #define ERROR(m, l, o) message(ERROR, (m), (l), (o)) #define ERRORFL(m, s) message(ERROR, (m), -1, -1) #define INFO(m, l, o) message(INFO, (m), (l), (o)) #define INFOFL(m, s) message(INFO, (m), -1, -1) /******************************************************************************** * Private types ********************************************************************************/ enum class_e { INFO, WARN, ERROR, FATAL }; const char *class_text[] = { "info", "warning", "error", "fatal" }; enum file_e { UNKNOWN = 0x00, C_HEADER = 0x01, C_SOURCE = 0x02 }; enum section_s { NO_SECTION = 0, INCLUDED_FILES, PRE_PROCESSOR_DEFINITIONS, PUBLIC_TYPES, PRIVATE_TYPES, PRIVATE_DATA, PUBLIC_DATA, PRIVATE_FUNCTIONS, PRIVATE_FUNCTION_PROTOTYPES, INLINE_FUNCTIONS, PUBLIC_FUNCTIONS, PUBLIC_FUNCTION_PROTOTYPES }; enum pptype_e { PPLINE_NONE = 0, PPLINE_DEFINE, PPLINE_IF, PPLINE_ELIF, PPLINE_ELSE, PPLINE_ENDIF, PPLINE_OTHER }; struct file_section_s { const char *name; /* File section name */ uint8_t ftype; /* File type where section found */ }; /******************************************************************************** * Private data ********************************************************************************/ static enum file_e g_file_type = UNKNOWN; static enum section_s g_section = NO_SECTION; static int g_maxline = DEFAULT_WIDTH; static int g_status = 0; static int g_verbose = 2; static int g_rangenumber = 0; static int g_rangestart[RANGE_NUMBER]; static int g_rangecount[RANGE_NUMBER]; static char g_file_name[PATH_MAX]; static const struct file_section_s g_section_info[] = { { " *\n", /* Index: NO_SECTION */ C_SOURCE | C_HEADER }, { " * Included Files\n", /* Index: INCLUDED_FILES */ C_SOURCE | C_HEADER }, { " * Pre-processor Definitions\n", /* Index: PRE_PROCESSOR_DEFINITIONS */ C_SOURCE | C_HEADER }, { " * Public Types\n", /* Index: PUBLIC_TYPES */ C_HEADER }, { " * Private Types\n", /* Index: PRIVATE_TYPES */ C_SOURCE }, { " * Private Data\n", /* Index: PRIVATE_DATA */ C_SOURCE }, { " * Public Data\n", /* Index: PUBLIC_DATA */ C_SOURCE | C_HEADER }, { " * Private Functions\n", /* Index: PRIVATE_FUNCTIONS */ C_SOURCE }, { " * Private Function Prototypes\n", /* Index: PRIVATE_FUNCTION_PROTOTYPES */ C_SOURCE }, { " * Inline Functions\n", /* Index: INLINE_FUNCTIONS */ C_SOURCE | C_HEADER }, { " * Public Functions\n", /* Index: PUBLIC_FUNCTIONS */ C_SOURCE }, { " * Public Function Prototypes\n", /* Index: PUBLIC_FUNCTION_PROTOTYPES */ C_SOURCE | C_HEADER } }; static const char *g_white_prefix[] = { "Elf", /* Ref: include/elf.h, include/elf32.h, include/elf64.h */ "PRId", /* Ref: inttypes.h */ "PRIi", /* Ref: inttypes.h */ "PRIo", /* Ref: inttypes.h */ "PRIu", /* Ref: inttypes.h */ "PRIx", /* Ref: inttypes.h */ "SCNd", /* Ref: inttypes.h */ "SCNi", /* Ref: inttypes.h */ "SCNo", /* Ref: inttypes.h */ "SCNu", /* Ref: inttypes.h */ "SCNx", /* Ref: inttypes.h */ "SYS_", /* Ref: include/sys/syscall.h */ "STUB_", /* Ref: syscall/syscall_lookup.h, syscall/sycall_stublookup.c */ "b8", /* Ref: include/fixedmath.h */ "b16", /* Ref: include/fixedmath.h */ "b32", /* Ref: include/fixedmath.h */ "ub8", /* Ref: include/fixedmath.h */ "ub16", /* Ref: include/fixedmath.h */ "ub32", /* Ref: include/fixedmath.h */ "ASCII_", /* Ref: include/nuttx/ascii.h */ "XK_", /* Ref: include/input/X11_keysymdef.h */ NULL }; static const char *g_white_list[] = { /* Ref: gnu_unwind_find_exidx.c */ "__EIT_entry", /* Ref: gnu_unwind_find_exidx.c */ "__gnu_Unwind_Find_exidx", /* Ref: stdlib.h */ "_Exit", /* Ref: stdatomic.h */ "_Atomic", /* Ref: unwind-arm-common.h */ "_Unwind", /* Ref: * https://pubs.opengroup.org/onlinepubs/9699919799/functions/tempnam.html */ "P_tmpdir", /* Ref: * https://pubs.opengroup.org/onlinepubs/9699919799/functions/tempnam.html */ "L_tmpnam", /* Ref: * nuttx/compiler.h */ "_Far", "_Erom", /* Ref: * fs/nfs/rpc.h * fs/nfs/nfs_proto.h */ "CREATE3args", "CREATE3resok", "LOOKUP3args", "LOOKUP3filename", "LOOKUP3resok", "WRITE3args", "WRITE3resok", "READ3args", "READ3resok", "REMOVE3args", "REMOVE3resok", "RENAME3args", "RENAME3resok", "MKDIR3args", "MKDIR3resok", "RMDIR3args", "RMDIR3resok", "READDIR3args", "READDIR3resok", "SETATTR3args", "SETATTR3resok", "FS3args", /* Ref: * mm/kasan/kasan.c */ "__asan_loadN", "__asan_storeN", "__asan_loadN_noabort", "__asan_storeN_noabort", NULL }; /******************************************************************************** * Private Functions ********************************************************************************/ /******************************************************************************** * Name: show_usage * * Description: * ********************************************************************************/ static void show_usage(char *progname, int exitcode, char *what) { fprintf(stderr, "%s version %s\n\n", basename(progname), NXSTYLE_VERSION); if (what) { fprintf(stderr, "%s\n", what); } fprintf(stderr, "Usage: %s [-m <excess>] [-v <level>] " "[-r <start,count>] <filename>\n", basename(progname)); fprintf(stderr, " %s -h this help\n", basename(progname)); fprintf(stderr, " %s -v <level> where level is\n", basename(progname)); fprintf(stderr, " 0 - no output\n"); fprintf(stderr, " 1 - PASS/FAIL\n"); fprintf(stderr, " 2 - output each line (default)\n"); exit(exitcode); } /******************************************************************************** * Name: skip * * Description: * ********************************************************************************/ static int skip(int lineno) { int i; for (i = 0; i < g_rangenumber; i++) { if (lineno >= g_rangestart[i] && lineno < g_rangestart[i] + g_rangecount[i]) { return 0; } } return g_rangenumber != 0; } /******************************************************************************** * Name: message * * Description: * ********************************************************************************/ static int message(enum class_e class, const char *text, int lineno, int ndx) { FILE *out = stdout; if (skip(lineno)) { return g_status; } if (class > INFO) { out = stderr; g_status |= 1; } if (g_verbose == 2) { if (lineno == -1 && ndx == -1) { fprintf(out, "%s: %s: %s\n", g_file_name, class_text[class], text); } else { fprintf(out, "%s:%d:%d: %s: %s\n", g_file_name, lineno, ndx, class_text[class], text); } } return g_status; } /******************************************************************************** * Name: check_spaces_left * * Description: * ********************************************************************************/ static void check_spaces_left(char *line, int lineno, int ndx) { /* Unary operator should generally be preceded by a space but make also * follow a left parenthesis at the beginning of a parenthetical list or * expression or follow a right parentheses in the case of a cast. */ if (ndx-- > 0 && line[ndx] != ' ' && line[ndx] != '(' && line[ndx] != ')') { ERROR("Operator/assignment must be preceded with whitespace", lineno, ndx); } } /******************************************************************************** * Name: check_spaces_leftright * * Description: * ********************************************************************************/ static void check_spaces_leftright(char *line, int lineno, int ndx1, int ndx2) { if (ndx1 > 0 && line[ndx1 - 1] != ' ') { ERROR("Operator/assignment must be preceded with whitespace", lineno, ndx1); } if (line[ndx2 + 1] != '\0' && line[ndx2 + 1] != '\n' && line[ndx2 + 1] != ' ') { ERROR("Operator/assignment must be followed with whitespace", lineno, ndx2); } } /******************************************************************************** * Name: check_nospaces_leftright * * Description: * Check if there are whitespaces on the left of right. If there is, report * an error. * ********************************************************************************/ static void check_nospaces_leftright(char *line, int lineno, int ndx1, int ndx2) { if (ndx1 > 0 && line[ndx1 - 1] == ' ') { ERROR("There should be no spaces before the operator/assignment", lineno, ndx1); } if (line[ndx2 + 1] == ' ') { ERROR("There should be no spaces after the operator/assignment", lineno, ndx2); } } /******************************************************************************** * Name: check_operand_leftright * * Description: * Check if the operator is next to an operand. If not, report the error. * ********************************************************************************/ static void check_operand_leftright(char *line, int lineno, int ndx1, int ndx2) { /* The cases below includes("xx" represents the operator): * " xx " | " xx(end)" | " xx;" | " xx\n" | " xx)" | " xx]" - (ndx1 > 0) * "(xx " | "(xx(end)" | "(xx;" | "(xx\n" | "(xx)" | "(xx]" - (ndx1 > 0) * "[xx " | "[xx(end)" | "[xx;" | "[xx\n" | "[xx)" | "[xx]" - (ndx1 > 0) * "xx " | "xx(end)" | "xx;" | "xx\n" | "xx)" | "xx]" - (ndx1 = 0) * In these cases, the operators must be not next any operands, thus errors * are reported. */ if (ndx1 > 0 && (line[ndx1 - 1] == ' ' || line[ndx1 - 1] == '(' || line[ndx1 - 1] == '[') && (line[ndx2 + 1] == ' ' || line[ndx2 + 1] == '\0' || line[ndx2 + 1] == ';' || line[ndx2 + 1] == '\n' || line[ndx2 + 1] == ')' || line[ndx2 + 1] == ']')) { ERROR("Operator must be next to an operand", lineno, ndx2); } } /******************************************************************************** * Name: block_comment_width * * Description: * Get the width of a block comment * ********************************************************************************/ static int block_comment_width(char *line) { int b; int e; int n; /* Skip over any leading whitespace on the line */ for (b = 0; isspace(line[b]); b++) { } /* Skip over any trailing whitespace at the end of the line */ for (e = strlen(line) - 1; e >= 0 && isspace(line[e]); e--) { } /* Number of characters on the line */ n = e - b + 1; if (n < 4) { return 0; } /* The first line of a block comment starts with "[slash]***" and ends with * "***" */ if (strncmp(&line[b], "/***", 4) == 0 && strncmp(&line[e - 2], "***", 3) == 0) { /* Return the the length of the line up to the final '*' */ return e + 1; } /* The last line of a block begins with whitespace then "***" and ends * with "***[slash]" */ if (strncmp(&line[b], "***", 3) == 0 && strncmp(&line[e - 3], "***/", 4) == 0) { /* Return the the length of the line up to the final '*' */ return e; } /* But there is also a special single line comment that begins with "[slash]* " * and ends with "***[slash]" */ if (strncmp(&line[b], "/*", 2) == 0 && strncmp(&line[e - 3], "***/", 4) == 0) { /* Return the the length of the line up to the final '*' */ return e; } /* Return zero if the line is not the first or last line of a block * comment. */ return 0; } /******************************************************************************** * Name: get_line_width * * Description: * Get the maximum line width by examining the width of the block comments. * ********************************************************************************/ static int get_line_width(FILE *instream) { char line[LINE_SIZE]; /* The current line being examined */ int max = 0; int min = INT_MAX; int lineno = 0; int lineno_max = 0; int lineno_min = 0; int len; while (fgets(line, LINE_SIZE, instream)) { lineno++; len = block_comment_width(line); if (len > 0) { if (len > max) { max = len; lineno_max = lineno; } if (len < min) { min = len; lineno_min = lineno; } } } if (max < min) { ERRORFL("No block comments found", g_file_name); return DEFAULT_WIDTH; } else if (max != min) { ERROR("Block comments have different lengths", lineno_max, max); ERROR("Block comments have different lengths", lineno_min, min); return DEFAULT_WIDTH; } return min; } /******************************************************************************** * Name: check_section_header * * Description: * Check if the current line holds a section header * ********************************************************************************/ static bool check_section_header(const char *line, int lineno) { int i; /* Search g_section_info[] to find a matching section header line */ for (i = FIRST_SECTION; i <= LAST_SECTION; i++) { if (strcmp(line, g_section_info[i].name) == 0) { g_section = (enum section_s)i; /* Verify that this section is appropriate for this file type */ if ((g_file_type & g_section_info[i].ftype) == 0) { ERROR("Invalid section for this file type", lineno, 3); } return true; } } return false; } /******************************************************************************** * Name: white_prefix * * Description: * Return true if the identifier string begins with a white-listed prefix * ********************************************************************************/ static bool white_list(const char *ident, int lineno) { const char **pptr; const char *str; for (pptr = g_white_prefix; (str = *pptr) != NULL; pptr++) { if (strncmp(ident, str, strlen(str)) == 0) { return true; } } for (pptr = g_white_list; (str = *pptr) != NULL; pptr++) { size_t len = strlen(str); if (strncmp(ident, str, len) == 0 && isalnum(ident[len]) == 0) { return true; } } return false; } /******************************************************************************** * Public Functions ********************************************************************************/ int main(int argc, char **argv, char **envp) { FILE *instream; /* File input stream */ char line[LINE_SIZE]; /* The current line being examined */ char buffer[100]; /* Localy format error strings */ char *lptr; /* Temporary pointer into line[] */ char *ext; /* Temporary file extension */ bool btabs; /* True: TAB characters found on the line */ bool bcrs; /* True: Carriage return found on the line */ bool bfunctions; /* True: In private or public functions */ bool bstatm; /* True: This line is beginning of a statement */ bool bfor; /* True: This line is beginning of a 'for' statement */ bool bswitch; /* True: Within a switch statement */ bool bstring; /* True: Within a string */ bool bquote; /* True: Backslash quoted character next */ bool bblank; /* Used to verify block comment terminator */ bool bexternc; /* True: Within 'extern "C"' */ enum pptype_e ppline; /* > 0: The next line the continuation of a * pre-processor command */ int rhcomment; /* Indentation of Comment to the right of code * (-1 -> don't check position) */ int prevrhcmt; /* Indentation of previous Comment to the right * of code (-1 -> don't check position) */ int lineno; /* Current line number */ int indent; /* Indentation level */ int ncomment; /* Comment nesting level on this line */ int prevncomment; /* Comment nesting level on the previous line */ int bnest; /* Brace nesting level on this line */ int prevbnest; /* Brace nesting level on the previous line */ int dnest; /* Data declaration nesting level on this line */ int prevdnest; /* Data declaration nesting level on the previous line */ int pnest; /* Parenthesis nesting level on this line */ int ppifnest; /* #if nesting level on this line */ int inasm; /* > 0: Within #ifdef __ASSEMBLY__ */ int comment_lineno; /* Line on which the last comment was closed */ int blank_lineno; /* Line number of the last blank line */ int noblank_lineno; /* A blank line is not needed after this line */ int lbrace_lineno; /* Line number of last left brace */ int rbrace_lineno; /* Last line containing a right brace */ int externc_lineno; /* Last line where 'extern "C"' declared */ int linelen; /* Length of the line */ int excess; int n; int i; int c; excess = 0; while ((c = getopt(argc, argv, ":hv:gm:r:")) != -1) { switch (c) { case 'm': excess = atoi(optarg); if (excess < 1) { show_usage(argv[0], 1, "Bad value for <excess>."); excess = 0; } break; case 'v': g_verbose = atoi(optarg); if (g_verbose < 0 || g_verbose > 2) { show_usage(argv[0], 1, "Bad value for <level>."); } break; case 'r': g_rangestart[g_rangenumber] = atoi(strtok(optarg, ",")); g_rangecount[g_rangenumber++] = atoi(strtok(NULL, ",")); break; case 'h': show_usage(argv[0], 0, NULL); break; case ':': show_usage(argv[0], 1, "Missing argument."); break; case '?': show_usage(argv[0], 1, "Unrecognized option."); break; default: show_usage(argv[0], 0, NULL); break; } } if (optind < argc - 1 || argv[optind] == NULL) { show_usage(argv[0], 1, "No file name given."); } /* Resolve the absolute path for the input file */ if (realpath(argv[optind], g_file_name) == NULL) { FATALFL("Failed to resolve absolute path.", g_file_name); return 1; } /* Are we parsing a header file? */ ext = strrchr(g_file_name, '.'); if (ext == 0) { } else if (strcmp(ext, ".h") == 0) { g_file_type = C_HEADER; } else if (strcmp(ext, ".c") == 0) { g_file_type = C_SOURCE; } if (g_file_type == UNKNOWN) { return 0; } instream = fopen(g_file_name, "r"); if (!instream) { FATALFL("Failed to open", g_file_name); return 1; } /* Determine the line width */ g_maxline = get_line_width(instream) + excess; rewind(instream); btabs = false; /* True: TAB characters found on the line */ bcrs = false; /* True: Carriage return found on the line */ bfunctions = false; /* True: In private or public functions */ bswitch = false; /* True: Within a switch statement */ bstring = false; /* True: Within a string */ bexternc = false; /* True: Within 'extern "C"' */ ppline = PPLINE_NONE; /* > 0: The next line the continuation of a * pre-processor command */ rhcomment = 0; /* Indentation of Comment to the right of code * (-1 -> don't check position) */ prevrhcmt = 0; /* Indentation of previous Comment to the right * of code (-1 -> don't check position) */ lineno = 0; /* Current line number */ ncomment = 0; /* Comment nesting level on this line */ bnest = 0; /* Brace nesting level on this line */ dnest = 0; /* Data declaration nesting level on this line */ pnest = 0; /* Parenthesis nesting level on this line */ ppifnest = 0; /* #if nesting level on this line */ inasm = 0; /* > 0: Within #ifdef __ASSEMBLY__ */ comment_lineno = -1; /* Line on which the last comment was closed */ blank_lineno = -1; /* Line number of the last blank line */ noblank_lineno = -1; /* A blank line is not needed after this line */ lbrace_lineno = -1; /* Line number of last left brace */ rbrace_lineno = -1; /* Last line containing a right brace */ externc_lineno = -1; /* Last line where 'extern "C"' declared */ /* Process each line in the input stream */ while (fgets(line, LINE_SIZE, instream)) { lineno++; indent = 0; prevbnest = bnest; /* Brace nesting level on the previous line */ prevdnest = dnest; /* Data declaration nesting level on the * previous line */ prevncomment = ncomment; /* Comment nesting level on the previous line */ bstatm = false; /* True: This line is beginning of a * statement */ bfor = false; /* REVISIT: Implies for() is all on one line */ /* If we are not in a comment, then this certainly is not a right-hand * comment. */ prevrhcmt = rhcomment; if (ncomment <= 0) { rhcomment = 0; } /* Check for a blank line */ for (n = 0; line[n] != '\n' && isspace((int)line[n]); n++) { } if (line[n] == '\n') { if (n > 0) { ERROR("Blank line contains whitespace", lineno, 1); } if (lineno == 1) { ERROR("File begins with a blank line", 1, 1); } else if (lineno == blank_lineno + 1) { ERROR("Too many blank lines", lineno, 1); } else if (lineno == lbrace_lineno + 1) { ERROR("Blank line follows left brace", lineno, 1); } blank_lineno = lineno; continue; } else /* This line is non-blank */ { /* Check for a missing blank line after a comment */ if (lineno == comment_lineno + 1) { /* No blank line should be present if the current line contains * a right brace, a pre-processor line, the start of another * comment. * * REVISIT: Generates a false alarm if the current line is also * a comment. Generally it is acceptable for one comment to * follow another with no space separation. * * REVISIT: prevrhcmt is tested to case the preceding line * contained comments to the right of the code. In such cases, * the comments are normally aligned and do not follow normal * indentation rules. However, this code will generate a false * alarm if the comments are aligned to the right BUT the * preceding line has no comment. */ if (line[n] != '}' && line[n] != '#' && prevrhcmt == 0) { ERROR("Missing blank line after comment", comment_lineno, 1); } } /* Files must begin with a comment (the file header). * REVISIT: Logically, this belongs in the STEP 2 operations * below. */ if (lineno == 1 && (line[n] != '/' || line[n + 1] != '*')) { ERROR("Missing file header comment block", lineno, 1); } if (lineno == 2) { if (line[n] == '*' && line[n + 1] == '\n') { ERROR("Missing relative file path in file header", lineno, n); } else if (isspace(line[n + 2])) { ERROR("Too many whitespaces before relative file path", lineno, n); } else { const char *apps_dir = "apps/"; const size_t apps_len = strlen(apps_dir); size_t offset; #ifdef TOPDIR /* TOPDIR macro contains the absolute path to the "nuttx" * root directory. It should have been defined via Makefile * and it is required to accurately evaluate the relative * path contained in the file header. Otherwise, skip this * verification. */ char *basedir = strstr(g_file_name, TOPDIR); if (basedir != NULL) { /* Add 1 to the offset for the slash character */ offset = strlen(TOPDIR) + 1; /* Duplicate the line from the beginning of the * relative file path, removing the '\n' at the end of * the string. */ char *line_dup = strndup(&line[n + 2], strlen(&line[n + 2]) - 1); if (strcmp(line_dup, basedir + offset) != 0) { ERROR("Relative file path does not match actual file", lineno, n); } free(line_dup); } else if (strncmp(&line[n + 2], apps_dir, apps_len) != 0) { /* g_file_name neither belongs to "nuttx" repository * nor begins with the root dir of the other * repository (e.g. "apps/") */ ERROR("Path relative to repository other than \"nuttx\" " "must begin with the root directory", lineno, n); } else { #endif offset = 0; if (strncmp(&line[n + 2], apps_dir, apps_len) == 0) { /* Input file belongs to the "apps" repository */ /* Calculate the offset to the first directory * after the "apps/" folder. */ offset += apps_len; } /* Duplicate the line from the beginning of the * relative file path, removing the '\n' at the end of * the string. */ char *line_dup = strndup(&line[n + 2], strlen(&line[n + 2]) - 1); ssize_t base = strlen(g_file_name) - strlen(&line_dup[offset]); if (base < 0 || (base != 0 && g_file_name[base - 1] != '/') || strcmp(&g_file_name[base], &line_dup[offset]) != 0) { ERROR("Relative file path does not match actual file", lineno, n); } free(line_dup); #ifdef TOPDIR } #endif } } /* Check for a blank line following a right brace */ if (bfunctions && lineno == rbrace_lineno + 1) { /* Check if this line contains a right brace. A right brace * must be followed by 'else', 'while', 'break', a blank line, * another right brace, or a pre-processor directive like #endif */ if (dnest == 0 && strchr(line, '}') == NULL && line[n] != '#' && strncmp(&line[n], "else", 4) != 0 && strncmp(&line[n], "while", 5) != 0 && strncmp(&line[n], "break", 5) != 0) { ERROR("Right brace must be followed by a blank line", rbrace_lineno, n + 1); } /* If the right brace is followed by a pre-processor command * like #endif (but not #else or #elif), then set the right * brace line number to the line number of the pre-processor * command (it then must be followed by a blank line) */ if (line[n] == '#') { int ii; for (ii = n + 1; line[ii] != '\0' && isspace(line[ii]); ii++) { } if (strncmp(&line[ii], "else", 4) != 0 && strncmp(&line[ii], "elif", 4) != 0) { rbrace_lineno = lineno; } } } } /* STEP 1: Find the indentation level and the start of real stuff on * the line. */ for (n = 0; line[n] != '\n' && isspace((int)line[n]); n++) { switch (line[n]) { case ' ': { indent++; } break; case '\t': { if (!btabs) { ERROR("TABs found. First detected", lineno, n); btabs = true; } indent = (indent + 4) & ~3; } break; case '\r': { if (!bcrs) { ERROR("Carriage returns found. " "First detected", lineno, n); bcrs = true; } } break; default: { snprintf(buffer, sizeof(buffer), "Unexpected white space character %02x found", line[n]); ERROR(buffer, lineno, n); } break; } } /* STEP 2: Detect some certain start of line conditions */ /* Skip over pre-processor lines (or continuations of pre-processor * lines as indicated by ppline) */ if (line[indent] == '#' || ppline != PPLINE_NONE) { int len; int ii; /* Suppress error for comment following conditional compilation */ noblank_lineno = lineno; /* Check pre-processor commands if this is not a continuation * line. */ ii = indent + 1; if (ppline == PPLINE_NONE) { /* Skip to the pre-processor command following the '#' */ while (line[ii] != '\0' && isspace(line[ii])) { ii++; } if (line[ii] != '\0') { /* Make sure that pre-processor definitions are all in * the pre-processor definitions section. */ ppline = PPLINE_OTHER; if (strncmp(&line[ii], "define", 6) == 0) { ppline = PPLINE_DEFINE; if (g_section != PRE_PROCESSOR_DEFINITIONS) { /* A complication is the header files always have * the idempotence guard definitions before the * "Pre-processor Definitions section". */ if (g_section == NO_SECTION && g_file_type != C_HEADER) { /* Only a warning because there is some usage * of define outside the Pre-processor * Definitions section which is justifiable. * Should be manually checked. */ WARN("#define outside of 'Pre-processor " "Definitions' section", lineno, ii); } } } /* Make sure that files are included only in the Included * Files section. */ else if (strncmp(&line[ii], "include", 7) == 0) { if (g_section != INCLUDED_FILES) { /* Only a warning because there is some usage of * include outside the Included Files section * which may be is justifiable. Should be * manually checked. */ WARN("#include outside of 'Included Files' " "section", lineno, ii); } } else if (strncmp(&line[ii], "if", 2) == 0) { ppifnest++; ppline = PPLINE_IF; ii += 2; } else if (strncmp(&line[ii], "elif", 4) == 0) { if (ppifnest == inasm) { inasm = 0; } ppline = PPLINE_ELIF; ii += 4; } else if (strncmp(&line[ii], "else", 4) == 0) { if (ppifnest == inasm) { inasm = 0; } ppline = PPLINE_ELSE; } else if (strncmp(&line[ii], "endif", 4) == 0) { if (ppifnest == inasm) { inasm = 0; } ppifnest--; ppline = PPLINE_ENDIF; } } } if (ppline == PPLINE_IF || ppline == PPLINE_ELIF) { int bdef = 0; if (strncmp(&line[ii], "def", 3) == 0) { bdef = 1; ii += 3; } else { while (line[ii] != '\0' && isspace(line[ii])) { ii++; } if (strncmp(&line[ii], "defined", 7) == 0) { bdef = 1; ii += 7; } } if (bdef) { while (line[ii] != '\0' && (isspace(line[ii]) || line[ii] == '(')) { ii++; } if (strncmp(&line[ii], "__ASSEMBLY__", 12) == 0) { inasm = ppifnest; } } } /* Check if the next line will be a continuation of the pre- * processor command. */ len = strlen(&line[indent]) + indent - 1; if (line[len] == '\n') { len--; } /* Propagate rhcomment over preprocessor lines Issue #120 */ if (prevrhcmt != 0) { /* Don't check position */ rhcomment = -1; } lptr = strstr(line, "/*"); if (lptr != NULL) { n = lptr - &line[0]; if (line[n + 2] == '\n') { ERROR("C comment opening on separate line", lineno, n); } else if (!isspace((int)line[n + 2]) && line[n + 2] != '*') { ERROR("Missing space after opening C comment", lineno, n); } if (strstr(lptr, "*/") == NULL) { /* Increment the count of nested comments */ ncomment++; } if (ppline == PPLINE_DEFINE) { rhcomment = n; if (prevrhcmt > 0 && n != prevrhcmt) { rhcomment = prevrhcmt; WARN("Wrong column position of comment right of code", lineno, n); } } else { /* Signal rhcomment, but ignore position */ rhcomment = -1; if (ncomment > 0 && (ppline == PPLINE_IF || ppline == PPLINE_ELSE || ppline == PPLINE_ELIF)) { /* in #if... and #el... */ ERROR("No multiline comment right of code allowed here", lineno, n); } } } if (line[len] != '\\' || ncomment > 0) { ppline = PPLINE_NONE; } continue; } /* Check for a single line comment */ linelen = strlen(line); if (linelen >= 5) /* Minimum is slash, star, star, slash, newline */ { lptr = strstr(line, "*/"); if (line[indent] == '/' && line[indent + 1] == '*' && lptr - line == linelen - 3) { /* If preceding comments were to the right of code, then we can * assume that there is a columnar alignment of columns that do * no follow the usual alignment. So the rhcomment flag * should propagate. */ rhcomment = prevrhcmt; /* Check if there should be a blank line before the comment */ if (lineno > 1 && comment_lineno != lineno - 1 && blank_lineno != lineno - 1 && noblank_lineno != lineno - 1 && rhcomment == 0) { /* TODO: This generates a false alarm if preceded * by a label. */ ERROR("Missing blank line before comment found", lineno, 1); } /* 'comment_lineno 'holds the line number of the last closing * comment. It is used only to verify that the comment is * followed by a blank line. */ comment_lineno = lineno; } } /* Check for the comment block indicating the beginning of a new file * section. */ if (check_section_header(line, lineno)) { if (g_section == PRIVATE_FUNCTIONS || g_section == PUBLIC_FUNCTIONS) { bfunctions = true; /* Latched */ } } /* Check for some kind of declaration. * REVISIT: The following logic fails for any non-standard types. * REVISIT: Terminator after keyword might not be a space. Might be * a newline, for example. struct and unions are often unnamed, for * example. */ else if (inasm == 0) { if (strncmp(&line[indent], "auto ", 5) == 0 || strncmp(&line[indent], "bool ", 5) == 0 || strncmp(&line[indent], "char ", 5) == 0 || strncmp(&line[indent], "CODE ", 5) == 0 || strncmp(&line[indent], "const ", 6) == 0 || strncmp(&line[indent], "double ", 7) == 0 || strncmp(&line[indent], "struct ", 7) == 0 || strncmp(&line[indent], "struct\n", 7) == 0 || /* May be unnamed */ strncmp(&line[indent], "enum ", 5) == 0 || strncmp(&line[indent], "extern ", 7) == 0 || strncmp(&line[indent], "EXTERN ", 7) == 0 || strncmp(&line[indent], "FAR ", 4) == 0 || strncmp(&line[indent], "float ", 6) == 0 || strncmp(&line[indent], "int ", 4) == 0 || strncmp(&line[indent], "int16_t ", 8) == 0 || strncmp(&line[indent], "int32_t ", 8) == 0 || strncmp(&line[indent], "long ", 5) == 0 || strncmp(&line[indent], "off_t ", 6) == 0 || strncmp(&line[indent], "register ", 9) == 0 || strncmp(&line[indent], "short ", 6) == 0 || strncmp(&line[indent], "signed ", 7) == 0 || strncmp(&line[indent], "size_t ", 7) == 0 || strncmp(&line[indent], "ssize_t ", 8) == 0 || strncmp(&line[indent], "static ", 7) == 0 || strncmp(&line[indent], "time_t ", 7) == 0 || strncmp(&line[indent], "typedef ", 8) == 0 || strncmp(&line[indent], "uint8_t ", 8) == 0 || strncmp(&line[indent], "uint16_t ", 9) == 0 || strncmp(&line[indent], "uint32_t ", 9) == 0 || strncmp(&line[indent], "union ", 6) == 0 || strncmp(&line[indent], "union\n", 6) == 0 || /* May be unnamed */ strncmp(&line[indent], "unsigned ", 9) == 0 || strncmp(&line[indent], "void ", 5) == 0 || strncmp(&line[indent], "volatile ", 9) == 0) { /* Check if this is extern "C"; We don't typically indent * following this. */ if (strncmp(&line[indent], "extern \"C\"", 10) == 0) { externc_lineno = lineno; } /* bfunctions: True: Processing private or public functions. * bnest: Brace nesting level on this line * dnest: Data declaration nesting level on this line */ /* REVISIT: Also picks up function return types */ /* REVISIT: Logic problem for nested data/function declarations */ if ((!bfunctions || bnest > 0) && dnest == 0) { dnest = 1; } /* Check for multiple definitions of variables on the line. * Ignores declarations within parentheses which are probably * formal parameters. */ if (pnest == 0) { int tmppnest; /* Note, we have not yet parsed each character on the line so * a comma have have been be preceded by '(' on the same line. * We will have parse up to any comma to see if that is the * case. */ for (i = indent, tmppnest = 0; line[i] != '\n' && line[i] != '\0'; i++) { if (tmppnest == 0 && line[i] == ',') { ERROR("Multiple data definitions", lineno, i + 1); break; } else if (line[i] == '(') { tmppnest++; } else if (line[i] == ')') { if (tmppnest < 1) { /* We should catch this later */ break; } tmppnest--; } else if (line[i] == ';') { /* Break out if the semicolon terminates the * declaration is found. Avoids processing any * righthand comments in most cases. */ break; } } } } /* Check for a keyword indicating the beginning of a statement. * REVISIT: This, obviously, will not detect statements that do not * begin with a C keyword (such as assignment statements). */ else if (strncmp(&line[indent], "break ", 6) == 0 || strncmp(&line[indent], "case ", 5) == 0 || #if 0 /* Part of switch */ strncmp(&line[indent], "case ", 5) == 0 || #endif strncmp(&line[indent], "continue ", 9) == 0 || #if 0 /* Part of switch */ strncmp(&line[indent], "default ", 8) == 0 || #endif strncmp(&line[indent], "do ", 3) == 0 || strncmp(&line[indent], "else ", 5) == 0 || strncmp(&line[indent], "goto ", 5) == 0 || strncmp(&line[indent], "if ", 3) == 0 || strncmp(&line[indent], "return ", 7) == 0 || #if 0 /* Doesn't follow pattern */ strncmp(&line[indent], "switch ", 7) == 0 || #endif strncmp(&line[indent], "while ", 6) == 0) { bstatm = true; } /* Spacing works a little differently for and switch statements */ else if (strncmp(&line[indent], "for ", 4) == 0) { bfor = true; bstatm = true; } else if (strncmp(&line[indent], "switch ", 7) == 0) { bswitch = true; } /* Also check for C keywords with missing white space */ else if (strncmp(&line[indent], "do(", 3) == 0 || strncmp(&line[indent], "if(", 3) == 0 || strncmp(&line[indent], "while(", 6) == 0) { ERROR("Missing whitespace after keyword", lineno, n); bstatm = true; } else if (strncmp(&line[indent], "for(", 4) == 0) { ERROR("Missing whitespace after keyword", lineno, n); bfor = true; bstatm = true; } else if (strncmp(&line[indent], "switch(", 7) == 0) { ERROR("Missing whitespace after keyword", lineno, n); bswitch = true; } } /* STEP 3: Parse each character on the line */ bquote = false; /* True: Backslash quoted character next */ bblank = true; /* Used to verify block comment terminator */ for (; line[n] != '\n' && line[n] != '\0'; n++) { /* Report any use of non-standard white space characters */ if (isspace(line[n])) { if (line[n] == '\t') { if (!btabs) { ERROR("TABs found. First detected", lineno, n); btabs = true; } } else if (line[n] == '\r') { if (!bcrs) { ERROR("Carriage returns found. " "First detected", lineno, n); bcrs = true; } } else if (line[n] != ' ') { snprintf(buffer, sizeof(buffer), "Unexpected white space character %02x found", line[n]); ERROR(buffer, lineno, n); } } /* Skip over identifiers */ if (ncomment == 0 && !bstring && (line[n] == '_' || isalpha(line[n]))) { bool have_upper = false; bool have_lower = false; int ident_index = n; /* Parse over the identifier. Check if it contains mixed upper- * and lower-case characters. */ do { have_upper |= isupper(line[n]); /* The coding standard provides for some exceptions of lower * case characters in pre-processor strings: * * IPv[4|6] as an IP version number * ICMPv6 as an ICMP version number * IGMPv2 as an IGMP version number * [0-9]p[0-9] as a decimal point * d[0-9] as a divisor * Hz for frequencies (including KHz, MHz, etc.) */ if (!have_lower && islower(line[n])) { switch (line[n]) { /* A sequence containing 'v' may occur at the * beginning of the identifier. */ case 'v': if (n > 1 && line[n - 2] == 'I' && line[n - 1] == 'P' && (line[n + 1] == '4' || line[n + 1] == '6')) { } else if (n > 3 && line[n - 4] == 'I' && line[n - 3] == 'C' && line[n - 2] == 'M' && line[n - 1] == 'P' && line[n + 1] == '6') { } else if (n > 3 && line[n - 4] == 'I' && line[n - 3] == 'G' && line[n - 2] == 'M' && line[n - 1] == 'P' && line[n + 1] == '2') { } else { have_lower = true; } break; /* Sequences containing 'p', 'd', or 'z' must have * been preceded by upper case characters. */ case 'p': if (!have_upper || n < 1 || !isdigit(line[n - 1]) || !isdigit(line[n + 1])) { have_lower = true; } break; case 'd': if (!have_upper || !isdigit(line[n + 1])) { have_lower = true; } break; case 'z': if (!have_upper || n < 1 || line[n - 1] != 'H') { have_lower = true; } break; break; default: have_lower = true; break; } } n++; } while (line[n] == '_' || isalnum(line[n])); /* Check for mixed upper and lower case */ if (have_upper && have_lower) { /* Ignore symbols that begin with white-listed prefixes */ if (white_list(&line[ident_index], lineno)) { /* No error */ } /* Special case hex constants. These will look like * identifiers starting with 'x' or 'X' but preceded * with '0' */ else if (ident_index < 1 || (line[ident_index] != 'x' && line[ident_index] != 'X') || line[ident_index - 1] != '0') { ERROR("Mixed case identifier found", lineno, ident_index); } else if (have_upper) { ERROR("Upper case hex constant found", lineno, ident_index); } } /* Check if the identifier is the last thing on the line */ if (line[n] == '\n' || line[n] == '\0') { break; } } /* Handle comments */ if (line[n] == '/' && !bstring) { /* Check for start of a C comment */ if (line[n + 1] == '*') { if (line[n + 2] == '\n') { ERROR("C comment opening on separate line", lineno, n); } else if (!isspace((int)line[n + 2]) && line[n + 2] != '*') { ERROR("Missing space after opening C comment", lineno, n); } /* Increment the count of nested comments */ ncomment++; /* If there is anything to the left of the left brace, then * this must be a comment to the right of code. * Also if preceding comments were to the right of code, then * we can assume that there is a columnar alignment of columns * that do no follow the usual alignment. So the rhcomment * flag should propagate. */ if (prevrhcmt == 0) { if (n != indent) { rhcomment = n; } } else { rhcomment = n; if (prevrhcmt > 0 && n != prevrhcmt) { rhcomment = prevrhcmt; if (n != indent) { WARN("Wrong column position of " "comment right of code", lineno, n); } else { ERROR("Wrong column position or missing " "blank line before comment", lineno, n); } } } n++; continue; } /* Check for end of a C comment */ else if (n > 0 && line[n - 1] == '*') { if (n < 2) { ERROR("Closing C comment not indented", lineno, n); } else if (!isspace((int)line[n - 2]) && line[n - 2] != '*') { ERROR("Missing space before closing C comment", lineno, n); } /* Check for block comments that are not on a separate line. * This would be the case if we are we are within a comment * that did not start on this line and the current line is * not blank up to the point where the comment was closed. */ if (prevncomment > 0 && !bblank && rhcomment == 0) { ERROR("Block comment terminator must be on a " "separate line", lineno, n); } #if 0 /* REVISIT: Generates false alarms when portions of an * expression are commented out within the expression. */ if (line[n + 1] != '\n') { ERROR("Garbage on line after C comment", lineno, n); } #endif /* Handle nested comments */ if (ncomment > 0) { /* Remember the line number of the line containing the * closing of the outermost comment. */ if (--ncomment == 0) { /* 'comment_lineno 'holds the line number of the * last closing comment. It is used only to * verify that the comment is followed by a blank * line. */ comment_lineno = lineno; /* Note that rhcomment must persist to support a * later test for comment alignment. We will fix * that at the top of the loop when ncomment == 0. */ } } else { /* Note that rhcomment must persist to support a later * test for comment alignment. We will will fix that * at the top of the loop when ncomment == 0. */ ncomment = 0; ERROR("Closing without opening comment", lineno, n); } n++; continue; } /* Check for C++ style comments */ else if (line[n + 1] == '/') { /* Check for URI schemes, e.g. "http://" or "https://" */ if (n == 0 || strncmp(&line[n - 1], "://", 3) != 0) { ERROR("C++ style comment", lineno, n); n++; continue; } } } /* Check if the line is blank so far. This is only used to * to verify the the closing of a block comment is on a separate * line. So we also need to treat '*' as a 'blank'. */ if (!isblank(line[n]) && line[n] != '*') { bblank = false; } /* Check for a string... ignore if we are in the middle of a * comment. */ if (ncomment == 0) { /* Backslash quoted character */ if (line[n] == '\\') { bquote = true; n++; } /* Check for quoted characters: \" in string */ if (line[n] == '"' && !bquote) { bstring = !bstring; } bquote = false; } /* The rest of the line is only examined of we are not in a comment, * in a string or in assembly. * * REVISIT: Should still check for whitespace at the end of the * line. */ if (ncomment == 0 && !bstring && inasm == 0) { switch (line[n]) { /* Handle logic nested with curly braces */ case '{': { if (n > indent) { /* REVISIT: dnest is always > 0 here if bfunctions == * false. */ if (dnest == 0 || !bfunctions || lineno == rbrace_lineno) { ERROR("Left bracket not on separate line", lineno, n); } } else if (line[n + 1] != '\n') { if (dnest == 0) { ERROR("Garbage follows left bracket", lineno, n); } } bnest++; if (dnest > 0) { dnest++; } /* Check if we are within 'extern "C"', we don't * normally indent in that case because the 'extern "C"' * is conditioned on __cplusplus. */ if (lineno == externc_lineno || lineno - 1 == externc_lineno) { bexternc = true; } /* Suppress error for comment following a left brace */ noblank_lineno = lineno; lbrace_lineno = lineno; } break; case '}': { /* Decrement the brace nesting level */ if (bnest < 1) { ERROR("Unmatched right brace", lineno, n); } else { bnest--; if (bnest < 1) { bnest = 0; bswitch = false; } } /* Decrement the declaration nesting level */ if (dnest < 3) { dnest = 0; bexternc = false; } else { dnest--; } /* The right brace should be on a separate line */ if (n > indent) { if (dnest == 0) { ERROR("Right bracket not on separate line", lineno, n); } } /* Check for garbage following the left brace */ if (line[n + 1] != '\n' && line[n + 1] != ',' && line[n + 1] != ';') { int sndx = n + 1; bool whitespace = false; /* Skip over spaces */ while (line[sndx] == ' ') { sndx++; } /* One possibility is that the right bracket is * followed by an identifier then a semi-colon. * Comma is possible to but would be a case of * multiple declaration of multiple instances. */ if (line[sndx] == '_' || isalpha(line[sndx])) { int endx = sndx; /* Skip to the end of the identifier. Checking * for mixed case identifiers will be done * elsewhere. */ while (line[endx] == '_' || isalnum(line[endx])) { endx++; } /* Skip over spaces */ while (line[endx] == ' ') { whitespace = true; endx++; } /* Handle according to what comes after the * identifier. */ if (strncmp(&line[sndx], "while", 5) == 0) { ERROR("'while' must be on a separate line", lineno, sndx); } else if (line[endx] == ',') { ERROR("Multiple data definitions on line", lineno, endx); } else if (line[endx] == ';') { if (whitespace) { ERROR("Space precedes semi-colon", lineno, endx); } } else if (line[endx] == '=') { /* There's a struct initialization following */ check_spaces_leftright(line, lineno, endx, endx); dnest = 1; } else { ERROR("Garbage follows right bracket", lineno, n); } } else { ERROR("Garbage follows right bracket", lineno, n); } } /* The right brace should not be preceded with a a blank * line. */ if (lineno == blank_lineno + 1) { ERROR("Blank line precedes right brace at line", lineno, 1); } rbrace_lineno = lineno; } break; /* Handle logic with parentheses */ case '(': { /* Increase the parenthetical nesting level */ pnest++; /* Check for inappropriate space around parentheses */ if (line[n + 1] == ' ') /* && !bfor */ { ERROR("Space follows left parenthesis", lineno, n); } } break; case ')': { /* Decrease the parenthetical nesting level */ if (pnest < 1) { ERROR("Unmatched right parentheses", lineno, n); pnest = 0; } else { pnest--; } /* Allow ')' as first thing on the line (n == indent) * Allow "for (xx; xx; )" (bfor == true) */ if (n > 0 && n != indent && line[n - 1] == ' ' && !bfor) { ERROR("Space precedes right parenthesis", lineno, n); } } break; /* Check for inappropriate space around square brackets */ case '[': { if (line[n + 1] == ' ') { ERROR("Space follows left bracket", lineno, n); } } break; case ']': { if (n > 0 && line[n - 1] == ' ') { ERROR("Space precedes right bracket", lineno, n); } } break; /* Semi-colon may terminate a declaration */ case ';': { if (!isspace((int)line[n + 1])) { ERROR("Missing whitespace after semicolon", lineno, n); } /* Semicolon terminates a declaration/definition if there * was no left curly brace (i.e., dnest is only 1). */ if (dnest == 1) { dnest = 0; } } break; /* Semi-colon may terminate a declaration */ case ',': { if (!isspace((int)line[n + 1])) { ERROR("Missing whitespace after comma", lineno, n); } } break; /* Skip over character constants */ case '\'': { int endndx = n + 2; if (line[n + 1] != '\n' && line[n + 1] != '\0') { if (line[n + 1] == '\\') { for (; line[endndx] != '\n' && line[endndx] != '\0' && line[endndx] != '\''; endndx++); } n = endndx; } } break; /* Check for space around various operators */ case '-': /* -> */ if (line[n + 1] == '>') { /* -> must have no whitespaces on its left or right */ check_nospaces_leftright(line, lineno, n, n + 1); n++; } /* -- */ else if (line[n + 1] == '-') { /* "--" should be next to its operand. If there are * whitespaces or non-operand characters on both left * and right (e.g. "a -- ", “a[i --]”, "(-- i)"), * there's an error. */ check_operand_leftright(line, lineno, n, n + 1); n++; } /* -= */ else if (line[n + 1] == '=') { check_spaces_leftright(line, lineno, n, n + 1); n++; } /* Scientific notation with a negative exponent (eg. 10e-10) * REVISIT: This fails for cases where the variable name * ends with 'e' preceded by a digit: * a = abc1e-10; * a = ABC1E-10; */ else if ((line[n - 1] == 'e' || line[n - 1] == 'E') && isdigit(line[n + 1]) && isdigit(line[n - 2])) { n++; } else { /* '-' may function as a unary operator and snuggle * on the left. */ check_spaces_left(line, lineno, n); } break; case '+': /* ++ */ if (line[n + 1] == '+') { /* "++" should be next to its operand. If there are * whitespaces or non-operand characters on both left * and right (e.g. "a ++ ", “a[i ++]”, "(++ i)"), * there's an error. */ check_operand_leftright(line, lineno, n, n + 1); n++; } /* += */ else if (line[n + 1] == '=') { check_spaces_leftright(line, lineno, n, n + 1); n++; } else { /* '+' may function as a unary operator and snuggle * on the left. */ check_spaces_left(line, lineno, n); } break; case '&': /* &<variable> OR &(<expression>) */ if (isalpha((int)line[n + 1]) || line[n + 1] == '_' || line[n + 1] == '(') { } /* &&, &= */ else if (line[n + 1] == '=' || line[n + 1] == '&') { check_spaces_leftright(line, lineno, n, n + 1); n++; } else { check_spaces_leftright(line, lineno, n, n); } break; case '/': /* C comment terminator */ if (line[n - 1] == '*') { n++; } /* C++-style comment */ else if (line[n + 1] == '/') { /* Check for "http://" or "https://" */ if ((n < 5 || strncmp(&line[n - 5], "http://", 7) != 0) && (n < 6 || strncmp(&line[n - 6], "https://", 8) != 0)) { ERROR("C++ style comment on at %d:%d\n", lineno, n); } n++; } /* /= */ else if (line[n + 1] == '=') { check_spaces_leftright(line, lineno, n, n + 1); n++; } /* Division operator */ else { check_spaces_leftright(line, lineno, n, n); } break; case '*': /* *\/, ** */ if (line[n] == '*' && (line[n + 1] == '/' || line[n + 1] == '*')) { n++; break; } /* *<variable>, *(<expression>) */ else if (isalpha((int)line[n + 1]) || line[n + 1] == '_' || line[n + 1] == '(') { break; } /* (<type> *) */ else if (line[n + 1] == ')') { /* REVISIT: This gives false alarms on syntax like *--ptr */ if (line[n - 1] != ' ' && line[n - 1] != '(') { ERROR("Operator/assignment must be preceded " "with whitespace", lineno, n); } break; } /* *= */ else if (line[n + 1] == '=') { check_spaces_leftright(line, lineno, n, n + 1); n++; } else { /* A single '*' may be an binary operator, but * it could also be a unary operator when used to deference * a pointer. */ check_spaces_left(line, lineno, n); } break; case '%': /* %= */ if (line[n + 1] == '=') { check_spaces_leftright(line, lineno, n, n + 1); n++; } else { check_spaces_leftright(line, lineno, n, n); } break; case '<': /* <=, <<, <<= */ if (line[n + 1] == '=') { check_spaces_leftright(line, lineno, n, n + 1); n++; } else if (line[n + 1] == '<') { if (line[n + 2] == '=') { check_spaces_leftright(line, lineno, n, n + 2); n += 2; } else { check_spaces_leftright(line, lineno, n, n + 1); n++; } } else { check_spaces_leftright(line, lineno, n, n); } break; case '>': /* >=, >>, >>= */ if (line[n + 1] == '=') { check_spaces_leftright(line, lineno, n, n + 1); n++; } else if (line[n + 1] == '>') { if (line[n + 2] == '=') { check_spaces_leftright(line, lineno, n, n + 2); n += 2; } else { check_spaces_leftright(line, lineno, n, n + 1); n++; } } else { check_spaces_leftright(line, lineno, n, n); } break; case '|': /* |=, || */ if (line[n + 1] == '=') { check_spaces_leftright(line, lineno, n, n + 1); n++; } else if (line[n + 1] == '|') { check_spaces_leftright(line, lineno, n, n + 1); n++; } else { check_spaces_leftright(line, lineno, n, n); } break; case '^': /* ^= */ if (line[n + 1] == '=') { check_spaces_leftright(line, lineno, n, n + 1); n++; } else { check_spaces_leftright(line, lineno, n, n); } break; case '=': /* == */ if (line[n + 1] == '=') { check_spaces_leftright(line, lineno, n, n + 1); n++; } else { check_spaces_leftright(line, lineno, n, n); } break; case '~': check_spaces_left(line, lineno, n); break; case '!': /* != */ if (line[n + 1] == '=') { check_spaces_leftright(line, lineno, n, n + 1); n++; } /* !! */ else if (line[n + 1] == '!') { check_spaces_left(line, lineno, n); n++; } else { check_spaces_left(line, lineno, n); } break; default: break; } } } /* Loop terminates when NUL or newline character found */ if (line[n] == '\n' || line[n] == '\0') { /* If the parse terminated on the NULL, then back up to the last * character (which should be the newline). */ int m = n; if (line[m] == '\0' && m > 0) { m--; } /* Check for space at the end of the line. Except for carriage * returns which we have already reported (one time) above. */ if (m > 1 && isspace((int)line[m - 1]) && line[m - 1] != '\n' && line[m - 1] != '\r') { ERROR("Dangling whitespace at the end of line", lineno, m); } /* The line width is determined by the location of the final * asterisk in block comments. The closing line of the block * comment will exceed that by one one character, the '/' * following the final asterisk. */ else if (m > g_maxline) { bool bslash; int a; for (bslash = false, a = m; a > 2 && strchr("\n\r/", line[a]) != NULL; a--) { if (line[a] == '/') { bslash = true; } } if (bslash && line[a] == '*') { m = a + 1; } } /* Check for long lines * * REVISIT: Long line checks suppressed on right hand comments * for now. This just prevents a large number of difficult-to- * fix complaints that we would have otherwise. */ if (m > g_maxline && !rhcomment) { ERROR("Long line found", lineno, m); } } /* STEP 4: Check alignment */ /* Within a comment block, we need only check on the alignment of the * comment. */ if ((ncomment > 0 || prevncomment > 0) && !bstring) { /* Nothing should begin in comment zero */ if (indent == 0 && line[0] != '/' && !bexternc) { /* NOTE: if this line contains a comment to the right of the * code, then ncomment will be misleading because it was * already incremented above. */ if (ncomment > 1 || rhcomment == 0) { ERROR("No indentation line", lineno, indent); } } else if (indent == 1 && line[0] == ' ' && line[1] == '*') { /* Good indentation */ } else if (indent > 0 && line[indent] == '\n') { ERROR("Whitespace on blank line", lineno, indent); } else if (indent > 0 && indent < 2) { if (bnest > 0) { ERROR("Insufficient indentation", lineno, indent); } else { ERROR("Expected indentation line", lineno, indent); } } else if (indent > 0 && !bswitch) { if (line[indent] == '/') { /* Comments should like at offsets 2, 6, 10, ... * This rule is not followed, however, if the comments are * aligned to the right of the code. */ if ((indent & 3) != 2 && rhcomment == 0) { ERROR("Bad comment alignment", lineno, indent); } /* REVISIT: This screws up in cases where there is C code, * followed by a comment that continues on the next line. */ else if (line[indent + 1] != '*') { ERROR("Missing asterisk in comment", lineno, indent); } } else if (line[indent] == '*') { /* REVISIT: Generates false alarms on comments at the end of * the line if there is nothing preceding (such as the aligned * comments with a structure field definition). So disabled * for comments before beginning of function definitions. * * Suppress this error if this is a comment to the right of * code. * Those may be unaligned. */ if ((indent & 3) != 3 && bfunctions && dnest == 0 && rhcomment == 0) { ERROR("Bad comment block alignment", lineno, indent); } if (line[indent + 1] != ' ' && line[indent + 1] != '*' && line[indent + 1] != '\n' && line[indent + 1] != '/') { ERROR("Invalid character after asterisk " "in comment block", lineno, indent); } } /* If this is not the line containing the comment start, then this * line should begin with '*' */ else if (prevncomment > 0) { ERROR("Missing asterisk in comment block", lineno, indent); } } } /* Check for various alignment outside of the comment block */ else if ((ncomment == 0 && prevncomment == 0) && !bstring) { if (indent == 0 && strchr("\n#{}", line[0]) == NULL) { /* Ignore if we are at global scope */ if (prevbnest > 0) { bool blabel = false; if (isalpha((int)line[indent])) { for (i = indent + 1; isalnum((int)line[i]) || line[i] == '_'; i++); blabel = (line[i] == ':'); } if (!blabel && !bexternc) { ERROR("No indentation line", lineno, indent); } } } else if (indent == 1 && line[0] == ' ' && line[1] == '*') { /* Good indentation */ } else if (indent > 0 && line[indent] == '\n') { ERROR("Whitespace on blank line", lineno, indent); } else if (indent > 0 && indent < 2) { ERROR("Insufficient indentation line", lineno, indent); } else if (line[indent] == '{') { /* Check for left brace in first column, but preceded by a * blank line. Should never happen (but could happen with * internal compound statements). */ if (indent == 0 && lineno == blank_lineno + 1) { ERROR("Blank line before opening left brace", lineno, indent); } /* REVISIT: Possible false alarms in compound statements * without a preceding conditional. That usage often violates * the coding standard. */ else if (!bfunctions && (indent & 1) != 0) { ERROR("Bad left brace alignment", lineno, indent); } else if ((indent & 3) != 0 && !bswitch && dnest == 0) { ERROR("Bad left brace alignment", lineno, indent); } } else if (line[indent] == '}') { /* REVISIT: Possible false alarms in compound statements * without a preceding conditional. That usage often violates * the coding standard. */ if (!bfunctions && (indent & 1) != 0) { ERROR("Bad left brace alignment", lineno, indent); } else if ((indent & 3) != 0 && !bswitch && prevdnest == 0) { ERROR("Bad right brace alignment", lineno, indent); } } else if (indent > 0) { /* REVISIT: Generates false alarms when a statement continues on * the next line. The bstatm check limits to lines beginning * with C keywords. * REVISIT: The bstatm check will not detect statements that * do not begin with a C keyword (such as assignment statements). * REVISIT: Generates false alarms on comments at the end of * the line if there is nothing preceding (such as the aligned * comments with a structure field definition). So disabled for * comments before beginning of function definitions. */ if ((bstatm || /* Begins with C keyword */ (line[indent] == '/' && bfunctions && line[indent + 1] == '*')) && /* Comment in functions */ !bswitch && /* Not in a switch */ dnest == 0) /* Not a data definition */ { if ((indent & 3) != 2) { ERROR("Bad alignment", lineno, indent); } } /* Crazy cases. There should be no small odd alignments * outside of comment/string. Odd alignments are possible * on continued lines, but not if they are small. */ else if (indent == 1 || indent == 3) { ERROR("Small odd alignment", lineno, indent); } } } } if (!bfunctions && g_file_type == C_SOURCE) { ERROR("\"Private/Public Functions\" not found!" " File will not be checked", lineno, 1); } if (ncomment > 0 || bstring) { ERROR("Comment or string found at end of file", lineno, 1); } fclose(instream); if (g_verbose == 1) { fprintf(stderr, "%s: %s nxstyle check\n", g_file_name, g_status == 0 ? "PASSED" : "FAILED"); } return g_status; }
the_stack_data/82951181.c
// RUN: %clang -target i386-unknown-linux -fsanitize=address %s -S -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-ASAN // RUN: %clang -O1 -target i386-unknown-linux -fsanitize=address %s -S -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-ASAN // RUN: %clang -O2 -target i386-unknown-linux -fsanitize=address %s -S -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-ASAN // RUN: %clang -O3 -target i386-unknown-linux -fsanitize=address %s -S -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-ASAN // RUN: %clang -target i386-unknown-linux -fsanitize=address %s -S -emit-llvm -flto=thin -o - | FileCheck %s --check-prefix=CHECK-ASAN // RUN: %clang -O2 -target i386-unknown-linux -fsanitize=address %s -S -emit-llvm -flto=thin -o - | FileCheck %s --check-prefix=CHECK-ASAN // RUN: %clang -target i386-unknown-linux -fsanitize=address %s -S -emit-llvm -flto -o - | FileCheck %s --check-prefix=CHECK-ASAN // RUN: %clang -O2 -target i386-unknown-linux -fsanitize=address %s -S -emit-llvm -flto -o - | FileCheck %s --check-prefix=CHECK-ASAN // RUN: %clang -target i386-unknown-linux -fsanitize=kernel-address %s -S -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-KASAN // RUN: %clang -O1 -target i386-unknown-linux -fsanitize=kernel-address %s -S -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-KASAN // RUN: %clang -O2 -target i386-unknown-linux -fsanitize=kernel-address %s -S -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-KASAN // RUN: %clang -O3 -target i386-unknown-linux -fsanitize=kernel-address %s -S -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-KASAN // RUN: %clang -target i386-unknown-linux -fsanitize=kernel-address %s -S -emit-llvm -flto=thin -o - | FileCheck %s --check-prefix=CHECK-KASAN // RUN: %clang -O2 -target i386-unknown-linux -fsanitize=kernel-address %s -S -emit-llvm -flto=thin -o - | FileCheck %s --check-prefix=CHECK-KASAN // RUN: %clang -target i386-unknown-linux -fsanitize=kernel-address %s -S -emit-llvm -flto -o - | FileCheck %s --check-prefix=CHECK-KASAN // RUN: %clang -O2 -target i386-unknown-linux -fsanitize=kernel-address %s -S -emit-llvm -flto -o - | FileCheck %s --check-prefix=CHECK-KASAN // RUN: %clang -target aarch64-unknown-linux -fsanitize=hwaddress %s -S -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-HWASAN // RUN: %clang -O1 -target aarch64-unknown-linux -fsanitize=hwaddress %s -S -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-HWASAN // RUN: %clang -O2 -target aarch64-unknown-linux -fsanitize=hwaddress %s -S -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-HWASAN // RUN: %clang -O3 -target aarch64-unknown-linux -fsanitize=hwaddress %s -S -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-HWASAN // RUN: %clang -target aarch64-unknown-linux -fsanitize=hwaddress %s -S -emit-llvm -flto=thin -o - | FileCheck %s --check-prefix=CHECK-HWASAN // RUN: %clang -O2 -target aarch64-unknown-linux -fsanitize=hwaddress %s -S -emit-llvm -flto=thin -o - | FileCheck %s --check-prefix=CHECK-HWASAN // RUN: %clang -target aarch64-unknown-linux -fsanitize=hwaddress %s -S -emit-llvm -flto -o - | FileCheck %s --check-prefix=CHECK-HWASAN // RUN: %clang -O2 -target aarch64-unknown-linux -fsanitize=hwaddress %s -S -emit-llvm -flto -o - | FileCheck %s --check-prefix=CHECK-HWASAN // RUN: %clang -target aarch64-unknown-linux -fsanitize=kernel-hwaddress %s -S -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-KHWASAN // RUN: %clang -O1 -target aarch64-unknown-linux -fsanitize=kernel-hwaddress %s -S -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-KHWASAN // RUN: %clang -O2 -target aarch64-unknown-linux -fsanitize=kernel-hwaddress %s -S -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-KHWASAN // RUN: %clang -O3 -target aarch64-unknown-linux -fsanitize=kernel-hwaddress %s -S -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-KHWASAN // RUN: %clang -target aarch64-unknown-linux -fsanitize=kernel-hwaddress %s -S -emit-llvm -flto=thin -o - | FileCheck %s --check-prefix=CHECK-KHWASAN // RUN: %clang -O2 -target aarch64-unknown-linux -fsanitize=kernel-hwaddress %s -S -emit-llvm -flto=thin -o - | FileCheck %s --check-prefix=CHECK-KHWASAN // RUN: %clang -target aarch64-unknown-linux -fsanitize=kernel-hwaddress %s -S -emit-llvm -flto -o - | FileCheck %s --check-prefix=CHECK-KHWASAN // RUN: %clang -O2 -target aarch64-unknown-linux -fsanitize=kernel-hwaddress %s -S -emit-llvm -flto -o - | FileCheck %s --check-prefix=CHECK-KHWASAN // Verify that -fsanitize={address,hwaddres,kernel-address,kernel-hwaddress} invokes ASan, HWAsan, KASan or KHWASan instrumentation. int foo(int *a) { return *a; } // CHECK-ASAN: __asan_init // CHECK-KASAN: __asan_{{.*}}load4_noabort // CHECK-HWASAN: __hwasan_init // CHECK-KHWASAN: __hwasan_tls
the_stack_data/67873.c
enum BOOLEAN { t = 0, f = 1 }; int main() { enum BOOLEAN b = f; return b; }
the_stack_data/14199578.c
#include <stdio.h> #include <stdlib.h> int main() { char *c = (char *) malloc(sizeof(char)); printf("c = %p\n", c); free(c); return 0; }
the_stack_data/90766650.c
#include <stdio.h> #include <math.h> #include <string.h> #include <stdlib.h> int main() { char str1[100], str2[100]; int t, i, ln1, ln2, x, j; while(scanf("%d", &t)==1) { for (j=1; j<=t; j++) { scanf("%s %s", str1, str2); ln1=strlen(str1); ln2=strlen(str2); x=0; if (ln1!=ln2) printf("No\n"); else { for (i=0; i<ln1; i++) { if (str1[i]!=str2[i]) { if (str1[i]=='a' || str1[i]=='e' || str1[i]=='i' || str1[i]=='o' || str1[i]=='u') { if (str2[i]=='a' || str2[i]=='e' || str2[i]=='i' || str2[i]=='o' || str2[i]=='u') x++; else { printf("No\n"); break; } } else { printf("No\n"); break; } } if (i==ln1-1) { printf("Yes\n"); break; } } } } } return 0; }
the_stack_data/31388405.c
// // Created by lorenzodb on 05/04/2020. // #include <sys/types.h> #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/wait.h> #define AANTAL 3 int main(int argc, char** argv) { char *newargv[] = {"writestring", "hello", NULL}; char *newenv[] = {NULL}; int pids[AANTAL]; int i = 0; for(i; i < AANTAL; i++) { pids[i] = fork(); if(!pids[i]) { execve("./writestring", newargv, newenv); perror("execve"); exit(1); } /*else { int status; waitpid(pids[i], &status, 0); while(!WIFEXITED(status)); }*/ } //here is better because otherwise this process will wait after every execve for(i = 0; i < AANTAL; i++) { int status; waitpid(pids[i], &status, 0); while(!WIFEXITED(status)); } return 0; }
the_stack_data/106408.c
#include<stdio.h> void main() { int a,b,t; printf("Enter two Numbers : "); scanf("%d %d",&a,&b); t=b; b=a; a=t; printf("Swap is %d %d",a,b); }
the_stack_data/9513981.c
int main() { int starting_val = 1; int shifting_places; __CPROVER_assume(shifting_places > 0); __CPROVER_assume(shifting_places < 32); int result = starting_val << shifting_places; __CPROVER_assert(result > 1, "Shifted result should be greater than one"); }
the_stack_data/48576553.c
/* write a c program to find the gcd of two given number using recursion */ #include <stdio.h> int gcd(int n1, int n2); int main() { int n1, n2; printf("Enter two positive integers: "); scanf("%d %d", &n1, &n2); printf("G.C.D of %d and %d is %d.", n1, n2, gcd(n1, n2)); return 0; } int gcd(int n1, int n2) { if (n2 != 0) return gcd(n2, n1 % n2); else return n1; }
the_stack_data/184518772.c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* test_one.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: mmurakam <[email protected]> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/10/13 12:16:27 by mmurakam #+# #+# */ /* Updated: 2019/10/13 16:21:42 by afarini- ### ########.fr */ /* */ /* ************************************************************************** */ void test_one_col2(int **square, int *var); void test_one_line1(int **square, int *var); void test_one_line2(int **square, int *var); void test_one_col1(int **square, int *var) { int line; int count; count = 0; line = 0; while (count < 4) { if (var[count] == 1) square[line][0] = '4'; count++; line++; } test_one_col2(square, var); } void test_one_col2(int **square, int *var) { int line; int count; count = 4; line = 0; while (count < 8) { if (var[count] == 1) square[line][3] = '4'; count++; line++; } test_one_line1(square, var); } void test_one_line1(int **square, int *var) { int col; int count; count = 8; col = 0; while (count < 12) { if (var[count] == 1) square[0][col] = '4'; col++; count++; } test_one_line2(square, var); } void test_one_line2(int **square, int *var) { int col; int count; count = 12; col = 0; while (count < 16) { if (var[count] == 1) square[3][col] = '4'; count++; col++; } }
the_stack_data/159516490.c
#include <stdlib.h> #define New( TYPE ) ((TYPE*)malloc(sizeof(TYPE))) //分配内存 #define Delete( VAR ) free(VAR) //释放内存 typedef void* DATA_TYPE; //默认内存释放器 void defaultDeleter(int p, DATA_TYPE value) { if (value) { Delete(value); } } struct Node { DATA_TYPE data; struct Node* next; }; typedef struct Node Node; Node* newNode(DATA_TYPE data) { Node* node = New(Node); node->next = NULL; node->data = data; return node; } struct LinkList { Node* head; int size; //链表的长度 }; typedef struct LinkList LinkList; LinkList* createList(); int emptyList(LinkList* list); DATA_TYPE removeList(LinkList* list, int index); DATA_TYPE removeListIf(LinkList* list, int(*condition)(int, DATA_TYPE)); void insertList(LinkList* list, int index, DATA_TYPE value); void clearList(LinkList* list); void pushFront(LinkList* list, DATA_TYPE value); void pushBack(LinkList* list, DATA_TYPE value); DATA_TYPE popFront(LinkList* list); DATA_TYPE popBack(LinkList* list); void sortList(LinkList* list, int(*comparetor)(DATA_TYPE, DATA_TYPE)); DATA_TYPE getItem(LinkList* list, int pos); void seekList(LinkList* list, int(*action)(int, DATA_TYPE)); void destroyList(LinkList* list, void(*onItemDelete)(int, DATA_TYPE)); LinkList* appendList(LinkList* list, LinkList* other); DATA_TYPE findMaxInList(LinkList* list, int(*comparetor)(DATA_TYPE, DATA_TYPE)); int lengthOfList(LinkList* list); LinkList* createList() { //创建空链表 LinkList* linkList = New(LinkList); linkList->head = NULL; linkList->size = 0; return linkList; } int emptyList(LinkList* list) { return list == NULL || list->head == NULL; } DATA_TYPE removeList(LinkList* list, int index) { if (index >= list->size) { return NULL; } if (index == 0) { return popFront(list); } Node *position = list->head, *last = position; while (position && index--) { last = position; position = position->next; } last->next = position->next; DATA_TYPE value = position->data; Delete(position); list->size--; return value; } DATA_TYPE removeListIf(LinkList* list, int(*condition)(int, DATA_TYPE)) { Node *position = list->head, *last = position; int index = 0; if (condition(index, position->data)) { return popFront(list); } while (position) { last = position; position = position->next; index++; if (condition(index, position->data)) { break; } } last->next = position->next; DATA_TYPE value = position->data; Delete(position); list->size--; return value; } void insertList(LinkList* list, int index, DATA_TYPE value) { if (index > list->size || value == NULL) { return; } Node* node = newNode(value); if (index == 0) { pushFront(list, value); } Node *position = list->head, *last = position; while (position && index--) { last = position; position = position->next; } last->next = node; node->next = position; list->size++; } void clearList(LinkList* list) { if (list->head) { destroyList(list, defaultDeleter); } } void pushFront(LinkList* list, DATA_TYPE value) { if (value == NULL) { return; } Node* node = newNode(value); node->next = list->head; list->head = node; list->size++; } DATA_TYPE popFront(LinkList* list) { Node* node = list->head; if (list->head) { list->head = node->next; node->next = NULL; list->size--; } return node->data; } DATA_TYPE popBack(LinkList* list) { DATA_TYPE value = NULL; Node *position = list->head, *last = NULL; if (list->head == NULL) { return NULL; } if (list->head->next == NULL) { value = position->data; Delete(list->head); list->head = NULL; return value; } while (position->next) { last = position; position = position->next; } value = position->data; Delete(position); last->next = NULL; return value; } void sortList(LinkList* list, int(*comparetor)(DATA_TYPE, DATA_TYPE)) { if (list->head == NULL) { return; } DATA_TYPE temp; for (Node* i = list->head; i != NULL; i = i->next) { for (Node* j = i->next; j != NULL; j = j->next) { if (comparetor(i->data, j->data) >= 0) { temp = i->data; i->data = j->data; j->data = temp; } } } } void pushBack(LinkList* list, DATA_TYPE value) { if (value == NULL) { return; } Node* node = newNode(value); if (node) { node->next = NULL; } else { return; } if (list->head) { Node* position = list->head; while (position->next) { position = position->next; } position->next = node; } else { list->head = node; } list->size++; } DATA_TYPE getItem(LinkList* list, int pos) { if (pos > list->size) { return NULL; } Node* position = list->head; int index = 0; while (position) { if (index == pos) { return position->data; } position = position->next; index++; } return NULL; } void seekList(LinkList* list, int(*action)(int, DATA_TYPE)) { Node* position = list->head; int index = 0; while (position) { if (action(index, position->data)) { break; } position = position->next; index++; } } void destroyList(LinkList* list, void(*onItemDelete)(int, DATA_TYPE)) { Node *position = list->head, *freeNode = NULL; int index = 0; while (position) { freeNode = position; position = position->next; onItemDelete(index, freeNode->data); Delete(freeNode); index++; } list->head = NULL; Delete(list); } LinkList* appendList(LinkList* list, LinkList* other) { pushBack(list, other->head->data); list->size += (other->size - 1); other->head = NULL; other->size = 0; return list; } DATA_TYPE findMaxInList(LinkList* list, int(*comparetor)(DATA_TYPE, DATA_TYPE)) { Node* position = list->head; DATA_TYPE max = position ? position->data : NULL; while (position) { if (comparetor(max, position->data) < 0) { max = position->data; } position = position->next; } return max; } int lengthOfList(LinkList* list) { return list->size; }
the_stack_data/140764639.c
#include <stdio.h> int main(void) { int n1, n2; printf("\n<<< EX024 - Ordem em dois números >>>\n\n"); printf("Me diga dois números e eu os colocarei\nos dois em ordem crescente."); printf("\nPrimeiro número: "); scanf(" %d", &n1); printf("\nSegundo número: "); scanf(" %d", &n2); if (n1 > n2) { printf("\nOs números em ordem crescente são %d e %d.\n", n2, n1); return 0; } else if (n2 > n1) { printf("\nOs números em ordem crescente são %d e %d.\n", n1, n2); return 0; } else { printf("\nOs números digitados são iguais.\n"); return 0; } // end if } // end main
the_stack_data/598268.c
// Implementation of the Binary Search algorithm in C // Harris Ransom /** Includes **/ #include <stdio.h> #include <stdlib.h> /** Functions **/ int binSearch(int arr[], int arrSize, int value) { int bottom = 0; int top = (arrSize - 1); while (bottom <= top) { int middle = (int) ((top + bottom) / 2); // Gets middle index if (arr[middle] < value) { // Cuts bottom bottom = middle + 1; } else if (arr[middle] > value) { // Cuts top top = middle - 1; } else { // Middle == value return middle; } } return -1; // Failure } /** MAIN **/ int main() { int testArr[] = {1, 3, 9, 11, 15, 19, 29}; int len = (sizeof(testArr) / sizeof(int)); int test1 = 25; int test2 = 15; printf("\nTest case 1: %d\n", binSearch(testArr, len, test1)); printf("Test case 1: %d\n", binSearch(testArr, len, test2)); return 0; }
the_stack_data/97012776.c
#include<stdio.h> int main(void) { printf("Hello world!"); return 1; }
the_stack_data/1129819.c
#include <stdio.h> void exibeAsCii(char letra){ char proximo; printf("\nCodigo numerico: %d", letra); proximo = letra + 1; printf("\nProximo: %c\tCodigo numerico: %d", proximo,proximo); } int main(){ char caracter; printf("Forneca um caracter: "); scanf("%c", &caracter); exibeAsCii(caracter); return 0; }
the_stack_data/242331392.c
#include <stdio.h> short int triangle_exist(double a, double b, double c) { if ((a + b > c) && (a + c > b) && (b + c > a)) return 1; return 0; } int main() { double a, b, c; printf("Input side lenghts of a triangle: "); scanf("%lf", &a); scanf("%lf", &b); scanf("%lf", &c); if (triangle_exist(a, b, c)) if ((a == b) || (a == c) || (b == c)) printf("The triangle is isosceles\n"); else printf("The triangle isn't isosceles\n"); else printf("This triangle does not exist!"); }
the_stack_data/62638902.c
// Test LLVM IR // RUN: %clang -S -emit-llvm %s -o %t.ll // RUN: %llc %t.ll && touch %t.s // RUN: %lli %t.ll | grep -q "lli foo" // RUN: %opt -S -O3 %t.ll -o %t.opt.ll // RUN: %lli %t.opt.ll | grep -q "lli foo" // REQUIRES: clang, llc, lli, opt #include <stdio.h> int main() { printf("lli foo\n"); return 0; }
the_stack_data/119544.c
#include <stdio.h> #include <stdlib.h> #include <locale.h> #include <math.h> int main() { setlocale(LC_ALL, "pt-br"); int i, b, d = 0; int f[60]; f[1] = 1; f[0] = 0; f[2] = 2; scanf("%d", &b); if (b >= 2) { for (i = 0; i < b - 1; i++) { f[i + 2] = f[i + 1] + f[i]; printf("%d ", f[i]); d = d + 1; } } printf("%d", f[d]); printf("\n"); return 0; }
the_stack_data/212643100.c
/** * @file glcdfont.c * \brief * The font definitions used to display text characters. */ //#include <avr/io.h> //#include <avr/pgmspace.h> #ifndef FONT5X7_H #define FONT5X7_H // standard ascii 5x7 font static const unsigned char font[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x5B, 0x4F, 0x5B, 0x3E, 0x3E, 0x6B, 0x4F, 0x6B, 0x3E, 0x1C, 0x3E, 0x7C, 0x3E, 0x1C, 0x18, 0x3C, 0x7E, 0x3C, 0x18, 0x1C, 0x57, 0x7D, 0x57, 0x1C, 0x1C, 0x5E, 0x7F, 0x5E, 0x1C, 0x00, 0x18, 0x3C, 0x18, 0x00, 0xFF, 0xE7, 0xC3, 0xE7, 0xFF, 0x00, 0x18, 0x24, 0x18, 0x00, 0xFF, 0xE7, 0xDB, 0xE7, 0xFF, 0x30, 0x48, 0x3A, 0x06, 0x0E, 0x26, 0x29, 0x79, 0x29, 0x26, 0x40, 0x7F, 0x05, 0x05, 0x07, 0x40, 0x7F, 0x05, 0x25, 0x3F, 0x5A, 0x3C, 0xE7, 0x3C, 0x5A, 0x7F, 0x3E, 0x1C, 0x1C, 0x08, 0x08, 0x1C, 0x1C, 0x3E, 0x7F, 0x14, 0x22, 0x7F, 0x22, 0x14, 0x5F, 0x5F, 0x00, 0x5F, 0x5F, 0x06, 0x09, 0x7F, 0x01, 0x7F, 0x00, 0x66, 0x89, 0x95, 0x6A, 0x60, 0x60, 0x60, 0x60, 0x60, 0x94, 0xA2, 0xFF, 0xA2, 0x94, 0x08, 0x04, 0x7E, 0x04, 0x08, 0x10, 0x20, 0x7E, 0x20, 0x10, 0x08, 0x08, 0x2A, 0x1C, 0x08, 0x08, 0x1C, 0x2A, 0x08, 0x08, 0x1E, 0x10, 0x10, 0x10, 0x10, 0x0C, 0x1E, 0x0C, 0x1E, 0x0C, 0x30, 0x38, 0x3E, 0x38, 0x30, 0x06, 0x0E, 0x3E, 0x0E, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5F, 0x00, 0x00, 0x00, 0x07, 0x00, 0x07, 0x00, 0x14, 0x7F, 0x14, 0x7F, 0x14, 0x24, 0x2A, 0x7F, 0x2A, 0x12, 0x23, 0x13, 0x08, 0x64, 0x62, 0x36, 0x49, 0x56, 0x20, 0x50, 0x00, 0x08, 0x07, 0x03, 0x00, 0x00, 0x1C, 0x22, 0x41, 0x00, 0x00, 0x41, 0x22, 0x1C, 0x00, 0x2A, 0x1C, 0x7F, 0x1C, 0x2A, 0x08, 0x08, 0x3E, 0x08, 0x08, 0x00, 0x80, 0x70, 0x30, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x60, 0x60, 0x00, 0x20, 0x10, 0x08, 0x04, 0x02, 0x3E, 0x51, 0x49, 0x45, 0x3E, 0x00, 0x42, 0x7F, 0x40, 0x00, 0x72, 0x49, 0x49, 0x49, 0x46, 0x21, 0x41, 0x49, 0x4D, 0x33, 0x18, 0x14, 0x12, 0x7F, 0x10, 0x27, 0x45, 0x45, 0x45, 0x39, 0x3C, 0x4A, 0x49, 0x49, 0x31, 0x41, 0x21, 0x11, 0x09, 0x07, 0x36, 0x49, 0x49, 0x49, 0x36, 0x46, 0x49, 0x49, 0x29, 0x1E, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x40, 0x34, 0x00, 0x00, 0x00, 0x08, 0x14, 0x22, 0x41, 0x14, 0x14, 0x14, 0x14, 0x14, 0x00, 0x41, 0x22, 0x14, 0x08, 0x02, 0x01, 0x59, 0x09, 0x06, 0x3E, 0x41, 0x5D, 0x59, 0x4E, 0x7C, 0x12, 0x11, 0x12, 0x7C, 0x7F, 0x49, 0x49, 0x49, 0x36, 0x3E, 0x41, 0x41, 0x41, 0x22, 0x7F, 0x41, 0x41, 0x41, 0x3E, 0x7F, 0x49, 0x49, 0x49, 0x41, 0x7F, 0x09, 0x09, 0x09, 0x01, 0x3E, 0x41, 0x41, 0x51, 0x73, 0x7F, 0x08, 0x08, 0x08, 0x7F, 0x00, 0x41, 0x7F, 0x41, 0x00, 0x20, 0x40, 0x41, 0x3F, 0x01, 0x7F, 0x08, 0x14, 0x22, 0x41, 0x7F, 0x40, 0x40, 0x40, 0x40, 0x7F, 0x02, 0x1C, 0x02, 0x7F, 0x7F, 0x04, 0x08, 0x10, 0x7F, 0x3E, 0x41, 0x41, 0x41, 0x3E, 0x7F, 0x09, 0x09, 0x09, 0x06, 0x3E, 0x41, 0x51, 0x21, 0x5E, 0x7F, 0x09, 0x19, 0x29, 0x46, 0x26, 0x49, 0x49, 0x49, 0x32, 0x03, 0x01, 0x7F, 0x01, 0x03, 0x3F, 0x40, 0x40, 0x40, 0x3F, 0x1F, 0x20, 0x40, 0x20, 0x1F, 0x3F, 0x40, 0x38, 0x40, 0x3F, 0x63, 0x14, 0x08, 0x14, 0x63, 0x03, 0x04, 0x78, 0x04, 0x03, 0x61, 0x59, 0x49, 0x4D, 0x43, 0x00, 0x7F, 0x41, 0x41, 0x41, 0x02, 0x04, 0x08, 0x10, 0x20, 0x00, 0x41, 0x41, 0x41, 0x7F, 0x04, 0x02, 0x01, 0x02, 0x04, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x03, 0x07, 0x08, 0x00, 0x20, 0x54, 0x54, 0x78, 0x40, 0x7F, 0x28, 0x44, 0x44, 0x38, 0x38, 0x44, 0x44, 0x44, 0x28, 0x38, 0x44, 0x44, 0x28, 0x7F, 0x38, 0x54, 0x54, 0x54, 0x18, 0x00, 0x08, 0x7E, 0x09, 0x02, 0x18, 0xA4, 0xA4, 0x9C, 0x78, 0x7F, 0x08, 0x04, 0x04, 0x78, 0x00, 0x44, 0x7D, 0x40, 0x00, 0x20, 0x40, 0x40, 0x3D, 0x00, 0x7F, 0x10, 0x28, 0x44, 0x00, 0x00, 0x41, 0x7F, 0x40, 0x00, 0x7C, 0x04, 0x78, 0x04, 0x78, 0x7C, 0x08, 0x04, 0x04, 0x78, 0x38, 0x44, 0x44, 0x44, 0x38, 0xFC, 0x18, 0x24, 0x24, 0x18, 0x18, 0x24, 0x24, 0x18, 0xFC, 0x7C, 0x08, 0x04, 0x04, 0x08, 0x48, 0x54, 0x54, 0x54, 0x24, 0x04, 0x04, 0x3F, 0x44, 0x24, 0x3C, 0x40, 0x40, 0x20, 0x7C, 0x1C, 0x20, 0x40, 0x20, 0x1C, 0x3C, 0x40, 0x30, 0x40, 0x3C, 0x44, 0x28, 0x10, 0x28, 0x44, 0x4C, 0x90, 0x90, 0x90, 0x7C, 0x44, 0x64, 0x54, 0x4C, 0x44, 0x00, 0x08, 0x36, 0x41, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x41, 0x36, 0x08, 0x00, 0x02, 0x01, 0x02, 0x04, 0x02, 0x3C, 0x26, 0x23, 0x26, 0x3C, 0x1E, 0xA1, 0xA1, 0x61, 0x12, 0x3A, 0x40, 0x40, 0x20, 0x7A, 0x38, 0x54, 0x54, 0x55, 0x59, 0x21, 0x55, 0x55, 0x79, 0x41, 0x21, 0x54, 0x54, 0x78, 0x41, 0x21, 0x55, 0x54, 0x78, 0x40, 0x20, 0x54, 0x55, 0x79, 0x40, 0x0C, 0x1E, 0x52, 0x72, 0x12, 0x39, 0x55, 0x55, 0x55, 0x59, 0x39, 0x54, 0x54, 0x54, 0x59, 0x39, 0x55, 0x54, 0x54, 0x58, 0x00, 0x00, 0x45, 0x7C, 0x41, 0x00, 0x02, 0x45, 0x7D, 0x42, 0x00, 0x01, 0x45, 0x7C, 0x40, 0xF0, 0x29, 0x24, 0x29, 0xF0, 0xF0, 0x28, 0x25, 0x28, 0xF0, 0x7C, 0x54, 0x55, 0x45, 0x00, 0x20, 0x54, 0x54, 0x7C, 0x54, 0x7C, 0x0A, 0x09, 0x7F, 0x49, 0x32, 0x49, 0x49, 0x49, 0x32, 0x32, 0x48, 0x48, 0x48, 0x32, 0x32, 0x4A, 0x48, 0x48, 0x30, 0x3A, 0x41, 0x41, 0x21, 0x7A, 0x3A, 0x42, 0x40, 0x20, 0x78, 0x00, 0x9D, 0xA0, 0xA0, 0x7D, 0x39, 0x44, 0x44, 0x44, 0x39, 0x3D, 0x40, 0x40, 0x40, 0x3D, 0x3C, 0x24, 0xFF, 0x24, 0x24, 0x48, 0x7E, 0x49, 0x43, 0x66, 0x2B, 0x2F, 0xFC, 0x2F, 0x2B, 0xFF, 0x09, 0x29, 0xF6, 0x20, 0xC0, 0x88, 0x7E, 0x09, 0x03, 0x20, 0x54, 0x54, 0x79, 0x41, 0x00, 0x00, 0x44, 0x7D, 0x41, 0x30, 0x48, 0x48, 0x4A, 0x32, 0x38, 0x40, 0x40, 0x22, 0x7A, 0x00, 0x7A, 0x0A, 0x0A, 0x72, 0x7D, 0x0D, 0x19, 0x31, 0x7D, 0x26, 0x29, 0x29, 0x2F, 0x28, 0x26, 0x29, 0x29, 0x29, 0x26, 0x30, 0x48, 0x4D, 0x40, 0x20, 0x38, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x38, 0x2F, 0x10, 0xC8, 0xAC, 0xBA, 0x2F, 0x10, 0x28, 0x34, 0xFA, 0x00, 0x00, 0x7B, 0x00, 0x00, 0x08, 0x14, 0x2A, 0x14, 0x22, 0x22, 0x14, 0x2A, 0x14, 0x08, 0x95, 0x00, 0x22, 0x00, 0x95, 0xAA, 0x00, 0x55, 0x00, 0xAA, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x10, 0x10, 0x10, 0xFF, 0x00, 0x14, 0x14, 0x14, 0xFF, 0x00, 0x10, 0x10, 0xFF, 0x00, 0xFF, 0x10, 0x10, 0xF0, 0x10, 0xF0, 0x14, 0x14, 0x14, 0xFC, 0x00, 0x14, 0x14, 0xF7, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x14, 0x14, 0xF4, 0x04, 0xFC, 0x14, 0x14, 0x17, 0x10, 0x1F, 0x10, 0x10, 0x1F, 0x10, 0x1F, 0x14, 0x14, 0x14, 0x1F, 0x00, 0x10, 0x10, 0x10, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x10, 0x10, 0x10, 0x10, 0x1F, 0x10, 0x10, 0x10, 0x10, 0xF0, 0x10, 0x00, 0x00, 0x00, 0xFF, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0xFF, 0x10, 0x00, 0x00, 0x00, 0xFF, 0x14, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x1F, 0x10, 0x17, 0x00, 0x00, 0xFC, 0x04, 0xF4, 0x14, 0x14, 0x17, 0x10, 0x17, 0x14, 0x14, 0xF4, 0x04, 0xF4, 0x00, 0x00, 0xFF, 0x00, 0xF7, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0xF7, 0x00, 0xF7, 0x14, 0x14, 0x14, 0x17, 0x14, 0x10, 0x10, 0x1F, 0x10, 0x1F, 0x14, 0x14, 0x14, 0xF4, 0x14, 0x10, 0x10, 0xF0, 0x10, 0xF0, 0x00, 0x00, 0x1F, 0x10, 0x1F, 0x00, 0x00, 0x00, 0x1F, 0x14, 0x00, 0x00, 0x00, 0xFC, 0x14, 0x00, 0x00, 0xF0, 0x10, 0xF0, 0x10, 0x10, 0xFF, 0x10, 0xFF, 0x14, 0x14, 0x14, 0xFF, 0x14, 0x10, 0x10, 0x10, 0x1F, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x38, 0x44, 0x44, 0x38, 0x44, 0x7C, 0x2A, 0x2A, 0x3E, 0x14, 0x7E, 0x02, 0x02, 0x06, 0x06, 0x02, 0x7E, 0x02, 0x7E, 0x02, 0x63, 0x55, 0x49, 0x41, 0x63, 0x38, 0x44, 0x44, 0x3C, 0x04, 0x40, 0x7E, 0x20, 0x1E, 0x20, 0x06, 0x02, 0x7E, 0x02, 0x02, 0x99, 0xA5, 0xE7, 0xA5, 0x99, 0x1C, 0x2A, 0x49, 0x2A, 0x1C, 0x4C, 0x72, 0x01, 0x72, 0x4C, 0x30, 0x4A, 0x4D, 0x4D, 0x30, 0x30, 0x48, 0x78, 0x48, 0x30, 0xBC, 0x62, 0x5A, 0x46, 0x3D, 0x3E, 0x49, 0x49, 0x49, 0x00, 0x7E, 0x01, 0x01, 0x01, 0x7E, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x44, 0x44, 0x5F, 0x44, 0x44, 0x40, 0x51, 0x4A, 0x44, 0x40, 0x40, 0x44, 0x4A, 0x51, 0x40, 0x00, 0x00, 0xFF, 0x01, 0x03, 0xE0, 0x80, 0xFF, 0x00, 0x00, 0x08, 0x08, 0x6B, 0x6B, 0x08, 0x36, 0x12, 0x36, 0x24, 0x36, 0x06, 0x0F, 0x09, 0x0F, 0x06, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x30, 0x40, 0xFF, 0x01, 0x01, 0x00, 0x1F, 0x01, 0x01, 0x1E, 0x00, 0x19, 0x1D, 0x17, 0x12, 0x00, 0x3C, 0x3C, 0x3C, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, }; #endif
the_stack_data/150143107.c
int min(int a, int b) { return (a < b) ? a : b; }
the_stack_data/131214.c
#include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <sys/types.h> #include <sys/wait.h> int main() { int n = 5; int i = 0; pid_t pid = 0; for (i = 0;i < 5;++i) { pid = fork(); if (pid == 0) { printf("i am child,pid = %d,ppid = %d\n",getpid(), getppid()); break; } } if (i == 5) { while (1){ pid_t wpid = waitpid(-1, NULL,WNOHANG); if (wpid == -1) break; else if (wpid > 0){ printf("waitpid wpid= %d\n",wpid); } } while(1){ sleep(1); } } if (i < 5) { printf("i am child\n"); } return 0; }
the_stack_data/116552.c
/* Test case for preserved AVX registers in dynamic linker, -mavx part. Copyright (C) 2009-2017 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ #include <immintrin.h> #include <stdlib.h> #include <string.h> extern __m256i audit_test (__m256i, __m256i, __m256i, __m256i, __m256i, __m256i, __m256i, __m256i); int tst_audit4_aux (void) { #ifdef __AVX__ __m256i ymm = _mm256_setzero_si256 (); __m256i ret = audit_test (ymm, ymm, ymm, ymm, ymm, ymm, ymm, ymm); ymm = _mm256_set1_epi32 (0x12349876); if (memcmp (&ymm, &ret, sizeof (ret))) abort (); return 0; #else /* __AVX__ */ return 77; #endif /* __AVX__ */ }
the_stack_data/619259.c
// This file is part of CPAchecker, // a tool for configurable software verification: // https://cpachecker.sosy-lab.org // // SPDX-FileCopyrightText: 2007-2020 Dirk Beyer <https://www.sosy-lab.org> // // SPDX-License-Identifier: Apache-2.0 int __VERIFIER_nondet_int(); int isPrime(int check){ if(check <= 1){ return 0; } // check/2 + 1 for fewer checks. for(int i = 2; i <= check/2+1; i++){ // FIX: i < check/2 + 1 if(check % i == 0){ return 0; } } return 1; } /** Check if a number is a prime number */ int main() { int input = __VERIFIER_nondet_int(); int check = input % 10; int result = isPrime(check); /* POST-CONDITION check if the program was able to identify all primes from 0 to 10. The checks below are correct! */ if( (result == 0 && check <= 0) || (result == 0 && check == 1) || (result == 1 && check == 2) || (result == 1 && check == 3) || (result == 0 && check == 4) || (result == 1 && check == 5) || (result == 0 && check == 6) || (result == 1 && check == 7) || (result == 0 && check == 8) || (result == 0 && check == 9)){ goto EXIT; } else { goto ERROR; } EXIT: return 0; ERROR: return 1; }
the_stack_data/62637914.c
/* { dg-do compile } */ /* { dg-options "-O2 -fdump-tree-original" } */ /* x | ~(x | y) -> x | ~y */ int fn1 (int x, int y) { return x | ~(x | y); } int fn2 (int x, int y) { return ~(x | y) | x; } int fn3 (int x, int y) { return x | ~(y | x); } int fn4 (int x, int y) { return ~(y | x) | x; } int fn5 (int z) { return z | ~(z | 3); } int fn6 (int z) { return ~(z | 3) | z; } /* { dg-final { scan-tree-dump-times "~y \\| x" 4 "original" } } */ /* { dg-final { scan-tree-dump-times "z \\| -4" 2 "original" } } */
the_stack_data/77929.c
#include <sys/types.h> #include <sys/ipc.h> #include <sys/shm.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #define SHMSIZE 1024 #define SHMKEY (key_t)0111 int main() { int shmid, len; void *shmaddr; if ((shmid = shmget(SHMKEY, SHMSIZE,IPC_CREAT|0666)) == -1) { perror ("shmget failed"); exit (1); } if ((shmaddr=shmat(shmid, NULL, 0)) == (void *)-1) { perror ("shmat failed"); exit (1); } printf("received from shared memory: %s\n",(char *)shmaddr); if (shmdt(shmaddr) == -1) { perror ("shmdt failed"); exit (1); } if (shmctl(shmid, IPC_RMID, 0) == -1) { perror ("shmctl failed"); exit (1); } }
the_stack_data/23574027.c
// REQUIRES: aarch64-registered-target // -fopemp and -fopenmp-simd behavior are expected to be the same. // RUN: %clang_cc1 -triple aarch64-linux-gnu -target-feature +neon -fopenmp -x c -emit-llvm %s -o - -femit-all-decls | FileCheck %s --check-prefix=AARCH64 // RUN: %clang_cc1 -triple aarch64-linux-gnu -target-feature +neon -fopenmp-simd -x c -emit-llvm %s -o - -femit-all-decls | FileCheck %s --check-prefix=AARCH64 #pragma omp declare simd #pragma omp declare simd simdlen(2) #pragma omp declare simd simdlen(6) #pragma omp declare simd simdlen(8) double foo(float x); // AARCH64: "_ZGVnM2v_foo" "_ZGVnM4v_foo" "_ZGVnM8v_foo" "_ZGVnN2v_foo" "_ZGVnN4v_foo" "_ZGVnN8v_foo" // AARCH64-NOT: _ZGVnN6v_foo void foo_loop(double *x, float *y, int N) { for (int i = 0; i < N; ++i) { x[i] = foo(y[i]); } } // make sure that the following two function by default gets generated // with 4 and 2 lanes, as descrived in the vector ABI #pragma omp declare simd notinbranch float bar(double x); #pragma omp declare simd notinbranch double baz(float x); // AARCH64: "_ZGVnN2v_baz" "_ZGVnN4v_baz" // AARCH64-NOT: baz // AARCH64: "_ZGVnN2v_bar" "_ZGVnN4v_bar" // AARCH64-NOT: bar void baz_bar_loop(double *x, float *y, int N) { for (int i = 0; i < N; ++i) { x[i] = baz(y[i]); y[i] = bar(x[i]); } } /***************************/ /* 32-bit integer tests */ /***************************/ #pragma omp declare simd #pragma omp declare simd simdlen(2) #pragma omp declare simd simdlen(6) #pragma omp declare simd simdlen(8) long foo_int(int x); // AARCH64: "_ZGVnN2v_foo_int" "_ZGVnN4v_foo_int" "_ZGVnN8v_foo_int" // No non power of two // AARCH64-NOT: _ZGVnN6v_foo_int void foo_int_loop(long *x, int *y, int N) { for (int i = 0; i < N; ++i) { x[i] = foo_int(y[i]); } } #pragma omp declare simd char simple_8bit(char); // AARCH64: "_ZGVnM16v_simple_8bit" "_ZGVnM8v_simple_8bit" "_ZGVnN16v_simple_8bit" "_ZGVnN8v_simple_8bit" #pragma omp declare simd short simple_16bit(short); // AARCH64: "_ZGVnM4v_simple_16bit" "_ZGVnM8v_simple_16bit" "_ZGVnN4v_simple_16bit" "_ZGVnN8v_simple_16bit" #pragma omp declare simd int simple_32bit(int); // AARCH64: "_ZGVnM2v_simple_32bit" "_ZGVnM4v_simple_32bit" "_ZGVnN2v_simple_32bit" "_ZGVnN4v_simple_32bit" #pragma omp declare simd long simple_64bit(long); // AARCH64: "_ZGVnM2v_simple_64bit" "_ZGVnN2v_simple_64bit" #pragma omp declare simd #pragma omp declare simd simdlen(32) char a01(int x); // AARCH64: "_ZGVnN16v_a01" "_ZGVnN32v_a01" "_ZGVnN8v_a01" // AARCH64-NOT: a01 #pragma omp declare simd #pragma omp declare simd simdlen(2) long a02(short x); // AARCH64: "_ZGVnN2v_a02" "_ZGVnN4v_a02" "_ZGVnN8v_a02" // AARCH64-NOT: a02 /************/ /* pointers */ /************/ #pragma omp declare simd int b01(int *x); // AARCH64: "_ZGVnN4v_b01" // AARCH64-NOT: b01 #pragma omp declare simd char b02(char *); // AARCH64: "_ZGVnN16v_b02" "_ZGVnN8v_b02" // AARCH64-NOT: b02 #pragma omp declare simd double *b03(double *); // AARCH64: "_ZGVnN2v_b03" // AARCH64-NOT: b03 /***********/ /* masking */ /***********/ #pragma omp declare simd inbranch int c01(double *x, short y); // AARCH64: "_ZGVnM8vv_c01" // AARCH64-NOT: c01 #pragma omp declare simd inbranch uniform(x) double c02(double *x, char y); // AARCH64: "_ZGVnM16uv_c02" "_ZGVnM8uv_c02" // AARCH64-NOT: c02 /************************************/ /* Linear with a constant parameter */ /************************************/ #pragma omp declare simd notinbranch linear(i) double constlinear(const int i); // AARCH64: "_ZGVnN2l_constlinear" "_ZGVnN4l_constlinear" // AARCH64-NOT: constlinear /*************************/ /* sincos-like signature */ /*************************/ #pragma omp declare simd linear(sin) linear(cos) void sincos(double in, double *sin, double *cos); // AARCH64: "_ZGVnN2vll_sincos" // AARCH64-NOT: sincos #pragma omp declare simd linear(sin : 1) linear(cos : 2) void SinCos(double in, double *sin, double *cos); // AARCH64: "_ZGVnN2vll2_SinCos" // AARCH64-NOT: SinCos // Selection of tests based on the examples provided in chapter 5 of // the Vector Function ABI specifications for AArch64, at // https://developer.arm.com/products/software-development-tools/hpc/arm-compiler-for-hpc/vector-function-abi. // Listing 2, p. 18 #pragma omp declare simd inbranch uniform(x) linear(val(i) : 4) int foo2(int *x, int i); // AARCH64: "_ZGVnM2ul4_foo2" "_ZGVnM4ul4_foo2" // AARCH64-NOT: foo2 // Listing 3, p. 18 #pragma omp declare simd inbranch uniform(x, c) linear(i \ : c) int foo3(int *x, int i, unsigned char c); // AARCH64: "_ZGVnM16uls2u_foo3" "_ZGVnM8uls2u_foo3" // AARCH64-NOT: foo3 // Listing 6, p. 19 #pragma omp declare simd linear(x) aligned(x : 16) simdlen(4) int foo4(int *x, float y); // AARCH64: "_ZGVnM4la16v_foo4" "_ZGVnN4la16v_foo4" // AARCH64-NOT: foo4 static int *I; static char *C; static short *S; static long *L; static float *F; static double *D; void do_something() { simple_8bit(*C); simple_16bit(*S); simple_32bit(*I); simple_64bit(*L); *C = a01(*I); *L = a02(*S); *I = b01(I); *C = b02(C); D = b03(D); *I = c01(D, *S); *D = c02(D, *S); constlinear(*I); sincos(*D, D, D); SinCos(*D, D, D); foo2(I, *I); foo3(I, *I, *C); foo4(I, *F); } typedef struct S { char R, G, B; } STy; #pragma omp declare simd notinbranch STy DoRGB(STy x); // AARCH64: "_ZGVnN2v_DoRGB" static STy *RGBData; void do_rgb_stuff() { DoRGB(*RGBData); }
the_stack_data/212642288.c
/* strerror.c --- ANSI C compatible system error routine Copyright (C) 1986, 1988-1989, 1991, 2002-2003, 2005 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 2, 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, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifdef HAVE_CONFIG_H # include <config.h> #endif #if !HAVE_STRERROR #include <limits.h> /* Don't include <stdio.h>, since it may or may not declare sys_errlist and its declarations may collide with ours. Just declare the stuff that we need directly. Standard hosted C89 implementations define strerror and they don't need this strerror function, so take some liberties with the standard to cater to ancient or limited freestanding implementations. */ int sprintf (char *, char const *, ...); extern int sys_nerr; extern char *sys_errlist[]; char * strerror (int n) { static char const fmt[] = "Unknown error (%d)"; static char mesg[sizeof fmt + sizeof n * CHAR_BIT / 3]; if (n < 0 || n >= sys_nerr) { sprintf (mesg, fmt, n); return mesg; } else return sys_errlist[n]; } #else /* This declaration is solely to ensure that after preprocessing this file is never empty. */ typedef int dummy; #endif
the_stack_data/357488.c
/* PR tree-optimization/24964 */ /* { dg-do compile } */ /* { dg-options "-O2 -mfpmath=387 -mfancy-math-387" } */ double fabs(double x); double test1(double x) { double t = fabs(x); return t*t; } double test2(double x) { double t = -x; return t*t; } /* { dg-final { scan-assembler-not "fchs" } } */ /* { dg-final { scan-assembler-not "fabs" } } */
the_stack_data/248581196.c
/** * @file xmc_eth_phy_dp83848.c * @date 2015-12-15 * * @cond ********************************************************************************************************************* * XMClib v2.1.16 - XMC Peripheral Driver Library * * Copyright (c) 2015-2017, Infineon Technologies AG * 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 copyright holders 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. * * To improve the quality of the software, users are encouraged to share modifications, enhancements or bug fixes with * Infineon Technologies AG [email protected]). ********************************************************************************************************************* * * Change History * -------------- * * 2015-06-20: * - Initial <br> * * 2015-12-15: * - Added Reset and exit power down * - Reset function called in Init function * * @endcond */ /******************************************************************************* * HEADER FILES *******************************************************************************/ #if defined(XMC_ETH_PHY_DP83848C) #include <xmc_eth_phy.h> /******************************************************************************* * MACROS *******************************************************************************/ /* Basic Registers */ #define REG_BMCR (0x00U) /* Basic Mode Control Register */ #define REG_BMSR (0x01U) /* Basic Mode Status Register */ #define REG_PHYIDR1 (0x02U) /* PHY Identifier 1 */ #define REG_PHYIDR2 (0x03U) /* PHY Identifier 2 */ #define REG_ANAR (0x04U) /* Auto-Negotiation Advertisement */ #define REG_ANLPAR (0x05U) /* Auto-Neg. Link Partner Abitily */ #define REG_ANER (0x06U) /* Auto-Neg. Expansion Register */ #define REG_ANNPTR (0x07U) /* Auto-Neg. Next Page TX */ #define REG_RBR (0x17U) /* RMII and Bypass Register */ /* Extended Registers */ #define REG_PHYSTS (0x10U) /* Status Register */ /* Basic Mode Control Register */ #define BMCR_RESET (0x8000U) /* Software Reset */ #define BMCR_LOOPBACK (0x4000U) /* Loopback mode */ #define BMCR_SPEED_SEL (0x2000U) /* Speed Select (1=100Mb/s) */ #define BMCR_ANEG_EN (0x1000U) /* Auto Negotiation Enable */ #define BMCR_POWER_DOWN (0x0800U) /* Power Down */ #define BMCR_ISOLATE (0x0400U) /* Isolate Media interface */ #define BMCR_REST_ANEG (0x0200U) /* Restart Auto Negotiation */ #define BMCR_DUPLEX (0x0100U) /* Duplex Mode (1=Full duplex) */ #define BMCR_COL_TEST (0x0080U) /* Collision Test */ /* Basic Mode Status Register */ #define BMSR_100B_T4 (0x8000U) /* 100BASE-T4 Capable */ #define BMSR_100B_TX_FD (0x4000U) /* 100BASE-TX Full Duplex Capable */ #define BMSR_100B_TX_HD (0x2000U) /* 100BASE-TX Half Duplex Capable */ #define BMSR_10B_T_FD (0x1000U) /* 10BASE-T Full Duplex Capable */ #define BMSR_10B_T_HD (0x0800U) /* 10BASE-T Half Duplex Capable */ #define BMSR_MF_PRE_SUP (0x0040U) /* Preamble suppression Capable */ #define BMSR_ANEG_COMPL (0x0020U) /* Auto Negotiation Complete */ #define BMSR_REM_FAULT (0x0010U) /* Remote Fault */ #define BMSR_ANEG_ABIL (0x0008U) /* Auto Negotiation Ability */ #define BMSR_LINK_STAT (0x0004U) /* Link Status (1=established) */ #define BMSR_JABBER_DET (0x0002U) /* Jaber Detect */ #define BMSR_EXT_CAPAB (0x0001U) /* Extended Capability */ /* RMII and Bypass Register */ #define RBR_RMII_MODE (0x0020U) /* Reduced MII Mode */ /* PHY Identifier Registers */ #define PHY_ID1 0x2000 /* DP83848C Device Identifier MSB */ #define PHY_ID2 0x5C90 /* DP83848C Device Identifier LSB */ /* PHY Status Register */ #define PHYSTS_MDI_X 0x4000 /* MDI-X mode enabled by Auto-Negot. */ #define PHYSTS_REC_ERR 0x2000 /* Receive Error Latch */ #define PHYSTS_POL_STAT 0x1000 /* Polarity Status */ #define PHYSTS_FC_SENSE 0x0800 /* False Carrier Sense Latch */ #define PHYSTS_SIG_DET 0x0400 /* 100Base-TX Signal Detect */ #define PHYSTS_DES_LOCK 0x0200 /* 100Base-TX Descrambler Lock */ #define PHYSTS_PAGE_REC 0x0100 /* Link Code Word Page Received */ #define PHYSTS_MII_INT 0x0080 /* MII Interrupt Pending */ #define PHYSTS_REM_FAULT 0x0040 /* Remote Fault */ #define PHYSTS_JABBER_DET 0x0020 /* Jabber Detect */ #define PHYSTS_ANEG_COMPL 0x0010 /* Auto Negotiation Complete */ #define PHYSTS_LOOPBACK 0x0008 /* Loopback Status */ #define PHYSTS_DUPLEX 0x0004 /* Duplex Status (1=Full duplex) */ #define PHYSTS_SPEED 0x0002 /* Speed10 Status (1=10MBit/s) */ #define PHYSTS_LINK_STAT 0x0001 /* Link Status (1=established) */ /******************************************************************************* * API IMPLEMENTATION *******************************************************************************/ /* Check if the device identifier is valid */ static int32_t XMC_ETH_PHY_IsDeviceIdValid(XMC_ETH_MAC_t *const eth_mac, uint8_t phy_addr) { uint16_t phy_id1; uint16_t phy_id2; XMC_ETH_PHY_STATUS_t status; /* Check Device Identification. */ if ((XMC_ETH_MAC_ReadPhy(eth_mac, phy_addr, REG_PHYIDR1, &phy_id1) == XMC_ETH_MAC_STATUS_OK) && (XMC_ETH_MAC_ReadPhy(eth_mac, phy_addr, REG_PHYIDR2, &phy_id2) == XMC_ETH_MAC_STATUS_OK)) { if ((phy_id1 == PHY_ID1) && ((phy_id2 & (uint16_t)0xfff0) == PHY_ID2)) { status = XMC_ETH_PHY_STATUS_OK; } else { status = XMC_ETH_PHY_STATUS_ERROR_DEVICE_ID; } } else { status = XMC_ETH_PHY_STATUS_ERROR_TIMEOUT; } return (int32_t)status; } /* PHY initialize */ int32_t XMC_ETH_PHY_Init(XMC_ETH_MAC_t *const eth_mac, uint8_t phy_addr, const XMC_ETH_PHY_CONFIG_t *const config) { int32_t status; uint16_t reg_val; status = XMC_ETH_PHY_IsDeviceIdValid(eth_mac, phy_addr); if (status == (int32_t)XMC_ETH_PHY_STATUS_OK) { status = XMC_ETH_PHY_Reset(eth_mac, phy_addr); if (status == (int32_t)XMC_ETH_PHY_STATUS_OK) { reg_val = 0U; if (config->speed == XMC_ETH_LINK_SPEED_100M) { reg_val |= BMCR_SPEED_SEL; } if (config->duplex == XMC_ETH_LINK_DUPLEX_FULL) { reg_val |= BMCR_DUPLEX; } if (config->enable_auto_negotiate == true) { reg_val |= BMCR_ANEG_EN; } if (config->enable_loop_back == true) { reg_val |= BMCR_LOOPBACK; } status = (int32_t)XMC_ETH_MAC_WritePhy(eth_mac, phy_addr, REG_BMCR, reg_val); if (status == (int32_t)XMC_ETH_PHY_STATUS_OK) { /* Configure interface mode */ switch (config->interface) { case XMC_ETH_LINK_INTERFACE_MII: reg_val = 0x0001; break; case XMC_ETH_LINK_INTERFACE_RMII: reg_val = RBR_RMII_MODE | 0x0001; break; } status = (int32_t)XMC_ETH_MAC_WritePhy(eth_mac, phy_addr, REG_RBR, reg_val); } } } return status; } /* Reset */ int32_t XMC_ETH_PHY_Reset(XMC_ETH_MAC_t *const eth_mac, uint8_t phy_addr) { int32_t status; uint16_t reg_bmcr; /* Reset PHY*/ status = (int32_t)XMC_ETH_MAC_WritePhy(eth_mac, phy_addr, REG_BMCR, BMCR_RESET); if (status == (int32_t)XMC_ETH_PHY_STATUS_OK) { /* Wait for the reset to complete */ do { status = XMC_ETH_MAC_ReadPhy(eth_mac, phy_addr, REG_BMCR, &reg_bmcr); } while ((reg_bmcr & BMCR_RESET) != 0); } return status; } /* Initiate power down */ int32_t XMC_ETH_PHY_PowerDown(XMC_ETH_MAC_t *const eth_mac, uint8_t phy_addr) { int32_t status; uint16_t reg_bmcr; status = XMC_ETH_MAC_ReadPhy(eth_mac, phy_addr, REG_BMCR, &reg_bmcr); if (status == (int32_t)XMC_ETH_PHY_STATUS_OK) { reg_bmcr |= BMCR_POWER_DOWN; status = (int32_t)XMC_ETH_MAC_WritePhy(eth_mac, phy_addr, REG_BMCR, reg_bmcr); } return status; } /* Exit power down */ int32_t XMC_ETH_PHY_ExitPowerDown(XMC_ETH_MAC_t *const eth_mac, uint8_t phy_addr) { int32_t status; uint16_t reg_bmcr; status = XMC_ETH_MAC_ReadPhy(eth_mac, phy_addr, REG_BMCR, &reg_bmcr); if (status == (int32_t)XMC_ETH_PHY_STATUS_OK) { reg_bmcr &= ~BMCR_POWER_DOWN; status = (int32_t)XMC_ETH_MAC_WritePhy(eth_mac, phy_addr, REG_BMCR, reg_bmcr); } return status; } /* Get link status */ XMC_ETH_LINK_STATUS_t XMC_ETH_PHY_GetLinkStatus(XMC_ETH_MAC_t *const eth_mac, uint8_t phy_addr) { uint16_t val; XMC_ETH_MAC_ReadPhy(eth_mac, phy_addr, REG_BMSR, &val); return (XMC_ETH_LINK_STATUS_t)((val & BMSR_LINK_STAT) ? XMC_ETH_LINK_STATUS_UP : XMC_ETH_LINK_STATUS_DOWN); } /* Get link speed */ XMC_ETH_LINK_SPEED_t XMC_ETH_PHY_GetLinkSpeed(XMC_ETH_MAC_t *const eth_mac, uint8_t phy_addr) { uint16_t val; XMC_ETH_MAC_ReadPhy(eth_mac, phy_addr, REG_PHYSTS, &val); return (XMC_ETH_LINK_SPEED_t)((val & PHYSTS_SPEED) ? XMC_ETH_LINK_SPEED_10M : XMC_ETH_LINK_SPEED_100M); } /* Get link duplex settings */ XMC_ETH_LINK_DUPLEX_t XMC_ETH_PHY_GetLinkDuplex(XMC_ETH_MAC_t *const eth_mac, uint8_t phy_addr) { uint16_t val; XMC_ETH_MAC_ReadPhy(eth_mac, phy_addr, REG_PHYSTS, &val); return (XMC_ETH_LINK_DUPLEX_t)((val & PHYSTS_DUPLEX) ? XMC_ETH_LINK_DUPLEX_FULL : XMC_ETH_LINK_DUPLEX_HALF); } bool XMC_ETH_PHY_IsAutonegotiationCompleted(XMC_ETH_MAC_t *const eth_mac, uint8_t phy_addr) { uint16_t val; XMC_ETH_MAC_ReadPhy(eth_mac, phy_addr, REG_BMSR, &val); return ((val & BMSR_ANEG_COMPL) == BMSR_ANEG_COMPL); } #endif // defined(XMC_ETH_PHY_DP83848C)
the_stack_data/728426.c
// HW#9a Chee Tey #include <stdio.h> #include <stdlib.h> #include <time.h> #define NROW 3 #define NCOL 5 double dRand(void); double dAvg(int col, double array2[]); double dMax(int row, int col, double array3[][col]); int main (void) { double array[NROW][NCOL]; double subtotal = 0; double average[NROW]; int i, j; printf("HW#9a Chee Tey\n\n"); srand((unsigned int) time(0)); // Fill up the array with values for(i = 0; i < NROW; i++) { for(j = 0; j < NCOL; j++) { array[i][j] = dRand(); } } printf("NROW Average\n"); // Compute the average of each row in the array and print them out for (i = 0; i < NROW; i++) { average[i] = dAvg(NCOL, array[i]); for (j = 0; j < NCOL; j++) { printf("%lf ", array[i][j]); // Print the value of each item } printf(" %lf\n", average[i]); } // Compute the average of all the values printf("\nAverage value of all results:\n"); for (i = 0; i < NROW; i++) { subtotal += dAvg(NCOL, array[i]); } printf("%lf\n", subtotal/NROW); // Print out the largest value of all values printf("\nLargest double of all the values:\n%lf\n", dMax(NROW, NCOL, array)); return 0; } // Returns a double value double dRand(void) { return (rand() * 10.0 / RAND_MAX); } // Calculate the average of the values in a given array double dAvg(int col, double array2[]) { double sum = 0; int i; for (i = 0; i < col; i++) { sum += array2[i]; } return (sum/col); } // Find the Largest value in a given 2 dimensional array double dMax(int row, int col, double array3[][col]) { double max = array3[0][0]; int i, j; for (i = 0; i < row; i++) { for (j = 0; j < col; j++) { // Only executes if the current array item is larger than max if (array3[i][j] > max) { max = array3[i][j]; } } } return max; } // HW#9a Chee Tey // NROW Average // 4.725009 3.221885 0.216343 6.069017 1.961277 3.238706 // 3.185554 9.609587 8.329829 9.432091 5.158998 7.143212 // 7.271169 6.538228 7.992515 0.195293 2.296777 4.858796 // Average value of all results: // 5.080238 // Largest double of all the values: // 9.609587
the_stack_data/86074469.c
#include <stdio.h> #include <stdlib.h> int main(void) { FILE *fp = fopen("orig.txt", "r"); FILE *output = fopen("output.txt", "w"); if (!fp) { printf("ERROR opening input file orig.txt\n"); exit(0); } int i = 0; char append[50], find[50]; double orig_sum_a = 0.0, orig_sum_f = 0.0, orig_a, orig_f; for (i = 0; i < 100; i++) { if (feof(fp)) { printf("ERROR: You need 100 datum instead of %d\n", i); printf("run 'make run' longer to get enough information\n\n"); exit(0); } fscanf(fp, "%s %s %lf %lf\n", append, find, &orig_a, &orig_f); orig_sum_a += orig_a; orig_sum_f += orig_f; } fclose(fp); fp = fopen("opt.txt", "r"); if (!fp) { fp = fopen("orig.txt", "r"); if (!fp) { printf("ERROR opening input file opt.txt\n"); exit(0); } } double opt_sum_a = 0.0, opt_sum_f = 0.0, opt_a, opt_f; for (i = 0; i < 100; i++) { if (feof(fp)) { printf("ERROR: You need 100 datum instead of %d\n", i); printf("run 'make run' longer to get enough information\n\n"); exit(0); } fscanf(fp, "%s %s %lf %lf\n", append, find, &opt_a, &opt_f); opt_sum_a += opt_a; opt_sum_f += opt_f; } fclose(fp); fp = fopen("hash_opt.txt", "r"); if (!fp) { fp = fopen("orig.txt", "r"); if (!fp) { printf("ERROR opening input file opt.txt\n"); exit(0); } } double hash_opt_sum_a = 0.0, hash_opt_sum_f = 0.0, hash_opt_a, hash_opt_f; for (i = 0; i < 100; i++) { if (feof(fp)) { printf("ERROR: You need 100 datum instead of %d\n", i); printf("run 'make run' longer to get enough information\n\n"); exit(0); } fscanf(fp, "%s %s %lf %lf\n", append, find, &hash_opt_a, &hash_opt_f); hash_opt_sum_a += hash_opt_a; hash_opt_sum_f += hash_opt_f; } fclose(fp); fp = fopen("bst_opt.txt", "r"); if (!fp) { fp = fopen("orig.txt", "r"); if (!fp) { printf("ERROR opening input file opt.txt\n"); exit(0); } } double bst_opt_sum_a = 0.0, bst_opt_sum_f = 0.0, bst_opt_a, bst_opt_f; for (i = 0; i < 100; i++) { if (feof(fp)) { printf("ERROR: You need 100 datum instead of %d\n", i); printf("run 'make run' longer to get enough information\n\n"); exit(0); } fscanf(fp, "%s %s %lf %lf\n", append, find, &bst_opt_a, &bst_opt_f); bst_opt_sum_a += bst_opt_a; bst_opt_sum_f += bst_opt_f; } fprintf(output, "append() %.8lf %.8lf %.8lf %.8lf\n",orig_sum_a / 100.0, opt_sum_a / 100.0, hash_opt_sum_a / 100.0, bst_opt_sum_a / 100.0); fprintf(output, "findName() %.8lf %.8lf %.8lf %.8lf", orig_sum_f / 100.0, opt_sum_f / 100.0, hash_opt_sum_f / 100.0, bst_opt_sum_f / 100.0); fclose(output); fclose(fp); return 0; }
the_stack_data/184517764.c
#define NULL ((void*)0) typedef unsigned long size_t; // Customize by platform. typedef long intptr_t; typedef unsigned long uintptr_t; typedef long scalar_t__; // Either arithmetic or pointer type. /* By default, we understand bool (as a convenience). */ typedef int bool; #define false 0 #define true 1 /* Forward declarations */ typedef struct TYPE_17__ TYPE_7__ ; typedef struct TYPE_16__ TYPE_2__ ; typedef struct TYPE_15__ TYPE_1__ ; /* Type definitions */ struct pm8xxx_pin_data {int irq; int /*<<< orphan*/ reg; } ; struct TYPE_16__ {int base; int of_gpio_n_cells; uintptr_t ngpio; int /*<<< orphan*/ label; int /*<<< orphan*/ of_node; TYPE_7__* parent; } ; struct TYPE_15__ {uintptr_t npins; int /*<<< orphan*/ custom_conf_items; int /*<<< orphan*/ custom_params; int /*<<< orphan*/ num_custom_params; struct pinctrl_pin_desc* pins; } ; struct pm8xxx_gpio {uintptr_t npins; int /*<<< orphan*/ domain; TYPE_2__ chip; TYPE_7__* dev; int /*<<< orphan*/ fwnode; int /*<<< orphan*/ pctrl; TYPE_1__ desc; int /*<<< orphan*/ regmap; } ; struct TYPE_17__ {int /*<<< orphan*/ of_node; int /*<<< orphan*/ parent; } ; struct platform_device {TYPE_7__ dev; } ; struct pinctrl_pin_desc {int number; struct pm8xxx_pin_data* drv_data; int /*<<< orphan*/ name; } ; struct irq_domain {int dummy; } ; struct device_node {int dummy; } ; /* Variables and functions */ int /*<<< orphan*/ ARRAY_SIZE (int /*<<< orphan*/ ) ; int ENODEV ; int ENOMEM ; int ENXIO ; int /*<<< orphan*/ GFP_KERNEL ; scalar_t__ IS_ERR (int /*<<< orphan*/ ) ; int PTR_ERR (int /*<<< orphan*/ ) ; int /*<<< orphan*/ SSBI_REG_ADDR_GPIO (int) ; int /*<<< orphan*/ dev_dbg (TYPE_7__*,char*) ; int /*<<< orphan*/ dev_err (TYPE_7__*,char*) ; int /*<<< orphan*/ dev_get_regmap (int /*<<< orphan*/ ,int /*<<< orphan*/ *) ; int /*<<< orphan*/ dev_name (TYPE_7__*) ; scalar_t__ device_get_match_data (TYPE_7__*) ; void* devm_kcalloc (TYPE_7__*,uintptr_t,int,int /*<<< orphan*/ ) ; struct pm8xxx_gpio* devm_kzalloc (TYPE_7__*,int,int /*<<< orphan*/ ) ; int /*<<< orphan*/ devm_pinctrl_register (TYPE_7__*,TYPE_1__*,struct pm8xxx_gpio*) ; int gpiochip_add_data (TYPE_2__*,struct pm8xxx_gpio*) ; int gpiochip_add_pin_range (TYPE_2__*,int /*<<< orphan*/ ,int /*<<< orphan*/ ,int /*<<< orphan*/ ,uintptr_t) ; int /*<<< orphan*/ gpiochip_remove (TYPE_2__*) ; int /*<<< orphan*/ irq_domain_create_hierarchy (struct irq_domain*,int /*<<< orphan*/ ,uintptr_t,int /*<<< orphan*/ ,int /*<<< orphan*/ *,TYPE_2__*) ; int /*<<< orphan*/ irq_domain_remove (int /*<<< orphan*/ ) ; struct irq_domain* irq_find_host (struct device_node*) ; struct device_node* of_irq_find_parent (int /*<<< orphan*/ ) ; int /*<<< orphan*/ of_node_put (struct device_node*) ; int /*<<< orphan*/ of_node_to_fwnode (int /*<<< orphan*/ ) ; int /*<<< orphan*/ of_property_read_bool (int /*<<< orphan*/ ,char*) ; int /*<<< orphan*/ platform_set_drvdata (struct platform_device*,struct pm8xxx_gpio*) ; int /*<<< orphan*/ pm8xxx_conf_items ; int /*<<< orphan*/ pm8xxx_domain_ops ; int /*<<< orphan*/ pm8xxx_gpio_bindings ; TYPE_2__ pm8xxx_gpio_template ; int /*<<< orphan*/ * pm8xxx_groups ; int pm8xxx_pin_populate (struct pm8xxx_gpio*,struct pm8xxx_pin_data*) ; TYPE_1__ pm8xxx_pinctrl_desc ; __attribute__((used)) static int pm8xxx_gpio_probe(struct platform_device *pdev) { struct pm8xxx_pin_data *pin_data; struct irq_domain *parent_domain; struct device_node *parent_node; struct pinctrl_pin_desc *pins; struct pm8xxx_gpio *pctrl; int ret, i; pctrl = devm_kzalloc(&pdev->dev, sizeof(*pctrl), GFP_KERNEL); if (!pctrl) return -ENOMEM; pctrl->dev = &pdev->dev; pctrl->npins = (uintptr_t) device_get_match_data(&pdev->dev); pctrl->regmap = dev_get_regmap(pdev->dev.parent, NULL); if (!pctrl->regmap) { dev_err(&pdev->dev, "parent regmap unavailable\n"); return -ENXIO; } pctrl->desc = pm8xxx_pinctrl_desc; pctrl->desc.npins = pctrl->npins; pins = devm_kcalloc(&pdev->dev, pctrl->desc.npins, sizeof(struct pinctrl_pin_desc), GFP_KERNEL); if (!pins) return -ENOMEM; pin_data = devm_kcalloc(&pdev->dev, pctrl->desc.npins, sizeof(struct pm8xxx_pin_data), GFP_KERNEL); if (!pin_data) return -ENOMEM; for (i = 0; i < pctrl->desc.npins; i++) { pin_data[i].reg = SSBI_REG_ADDR_GPIO(i); pin_data[i].irq = -1; ret = pm8xxx_pin_populate(pctrl, &pin_data[i]); if (ret) return ret; pins[i].number = i; pins[i].name = pm8xxx_groups[i]; pins[i].drv_data = &pin_data[i]; } pctrl->desc.pins = pins; pctrl->desc.num_custom_params = ARRAY_SIZE(pm8xxx_gpio_bindings); pctrl->desc.custom_params = pm8xxx_gpio_bindings; #ifdef CONFIG_DEBUG_FS pctrl->desc.custom_conf_items = pm8xxx_conf_items; #endif pctrl->pctrl = devm_pinctrl_register(&pdev->dev, &pctrl->desc, pctrl); if (IS_ERR(pctrl->pctrl)) { dev_err(&pdev->dev, "couldn't register pm8xxx gpio driver\n"); return PTR_ERR(pctrl->pctrl); } pctrl->chip = pm8xxx_gpio_template; pctrl->chip.base = -1; pctrl->chip.parent = &pdev->dev; pctrl->chip.of_node = pdev->dev.of_node; pctrl->chip.of_gpio_n_cells = 2; pctrl->chip.label = dev_name(pctrl->dev); pctrl->chip.ngpio = pctrl->npins; parent_node = of_irq_find_parent(pctrl->dev->of_node); if (!parent_node) return -ENXIO; parent_domain = irq_find_host(parent_node); of_node_put(parent_node); if (!parent_domain) return -ENXIO; pctrl->fwnode = of_node_to_fwnode(pctrl->dev->of_node); pctrl->domain = irq_domain_create_hierarchy(parent_domain, 0, pctrl->chip.ngpio, pctrl->fwnode, &pm8xxx_domain_ops, &pctrl->chip); if (!pctrl->domain) return -ENODEV; ret = gpiochip_add_data(&pctrl->chip, pctrl); if (ret) { dev_err(&pdev->dev, "failed register gpiochip\n"); goto err_chip_add_data; } /* * For DeviceTree-supported systems, the gpio core checks the * pinctrl's device node for the "gpio-ranges" property. * If it is present, it takes care of adding the pin ranges * for the driver. In this case the driver can skip ahead. * * In order to remain compatible with older, existing DeviceTree * files which don't set the "gpio-ranges" property or systems that * utilize ACPI the driver has to call gpiochip_add_pin_range(). */ if (!of_property_read_bool(pctrl->dev->of_node, "gpio-ranges")) { ret = gpiochip_add_pin_range(&pctrl->chip, dev_name(pctrl->dev), 0, 0, pctrl->chip.ngpio); if (ret) { dev_err(pctrl->dev, "failed to add pin range\n"); goto unregister_gpiochip; } } platform_set_drvdata(pdev, pctrl); dev_dbg(&pdev->dev, "Qualcomm pm8xxx gpio driver probed\n"); return 0; unregister_gpiochip: gpiochip_remove(&pctrl->chip); err_chip_add_data: irq_domain_remove(pctrl->domain); return ret; }
the_stack_data/621453.c
#define HAVE_GETRUSAGE /* Undefine if you don't have the getrusage function */ #undef HAVE_GETRUSAGE /* * The GetTime function is used to measure execution time. * * The function is called before and after the code to be * measured. The difference between the second and the * first call gives the number of seconds spent in executing * the code. * * If the system call getrusage() is supported, the difference * gives the user time used; otherwise, the accounted real time. */ #ifdef HAVE_GETRUSAGE #include <sys/time.h> #include <sys/resource.h> double GetTime() { struct rusage ru; getrusage(RUSAGE_SELF, &ru); return ru.ru_utime.tv_sec + ru.ru_utime.tv_usec / 1000000.0; } #else #include <time.h> double GetTime() { return (double) clock() / CLOCKS_PER_SEC; } #endif
the_stack_data/606315.c
// Brayden Lappies // Lab 06 - bitwise // This program will accept an int in the command line and print it // back out, but also print out the number of 0 and 1 bits in the number. #include <stdio.h> #include <stdlib.h> //int is 4 bytes of this machine, so a mask will have to be of four bytes size void binary(unsigned int num) {// | 1 | 2 | 3 | 4 unsigned int mask = 2147483648;//1000 0000 0000 0000 0000 0000 0000 0000 int zero = 0, one = 0; while(mask > 0) { if ((num & mask) == 0) zero++; else one++; mask = mask >> 1; //right shift, moves the 1 down the line } printf("In %d, there are %d bits set to 0.\n", num, zero); printf("In %d, there are %d bits set to 1.\n", num, one); } int main(int argc, char *argv[]) { unsigned int input; if (argc != 2) { printf("please call this program with an integer\n"); exit(1); } input = atoi(argv[1]); printf("Your number was %d.\n", input); binary(input); return 0; }
the_stack_data/31387413.c
/* ** EPITECH PROJECT, 2017 ** square_root ** File description: ** task05 */ int my_compute_power_it(int nb, int p) { int res = nb; if (p == 0) return (1); if (p < 0) return (0); while (p > 1) { res = res * nb; if (res > 2147483647 / nb || res < -2147483648 / nb) return (0); p--; } return (res); } int my_compute_square_root(int nb) { int iter = 0; while (iter < nb) { if (my_compute_power_it(iter, 2) == nb) return (iter); iter++; } return (0); }
the_stack_data/178266744.c
/* This file is part of the YAZ toolkit. * Copyright (C) Index Data * See the file LICENSE for details. */ /** * \file * \brief sortkey utility based on ICU Collator */ #if HAVE_CONFIG_H #include "config.h" #endif #if YAZ_HAVE_ICU #include <yaz/xmalloc.h> #include <yaz/icu_I18N.h> #include <yaz/log.h> #include <string.h> #include <stdlib.h> #include <stdio.h> #include <unicode/ustring.h> /* some more string fcns*/ #include <unicode/uchar.h> /* char names */ void icu_sortkey8_from_utf16(UCollator *coll, struct icu_buf_utf8 *dest8, struct icu_buf_utf16 *src16, UErrorCode * status) { int32_t sortkey_len = 0; /* we'll fake a capacity of one less, because it turns out that ucol_getSortKey writes ONE character too much */ int32_t cap = dest8->utf8_cap ? dest8->utf8_cap - 1 : 0; sortkey_len = ucol_getSortKey(coll, src16->utf16, src16->utf16_len, dest8->utf8, cap); /* check for buffer overflow, resize and retry */ if (sortkey_len > cap) { icu_buf_utf8_resize(dest8, sortkey_len * 2); sortkey_len = ucol_getSortKey(coll, src16->utf16, src16->utf16_len, dest8->utf8, dest8->utf8_cap); } if (U_SUCCESS(*status) && sortkey_len > 0) dest8->utf8_len = sortkey_len; else icu_buf_utf8_clear(dest8); } #endif /* YAZ_HAVE_ICU */ /* * Local variables: * c-basic-offset: 4 * c-file-style: "Stroustrup" * indent-tabs-mode: nil * End: * vim: shiftwidth=4 tabstop=8 expandtab */
the_stack_data/68865.c
#define foo(a,b) #if 0 foo(bar) foo( #endif
the_stack_data/25136673.c
#include <sgtty.h> int _gtty(fildes,argp) int fildes ; struct sgttyb *argp ; { return _ioctl(fildes,0x40067408,argp) ; }
the_stack_data/27561.c
#include <stdio.h> int main() { int a[4][5]={0}; int s,p,d; int b=1; int i; int j; while(b==1){ printf("sales person number: "); scanf("%d",&s); printf("product number: "); scanf("%d",&p); printf("total dollar value: "); scanf("%d",&d); a[s-1][p-1]=d; printf("If you want to enter more, enter 1, else 0: "); scanf("%d",&b); printf("\n"); } for(i=0;i<4;i++){ for(j=0;j<5;j++) printf("%d person's %d product sales %d$\n",(i+1),(j+1),a[i][j]); printf("\n"); } return 0; }
the_stack_data/108796.c
#include <stdio.h> void main (void) { // Declare the variable a int a = 0; // Check to see what a is equal to switch (a) { case 0: printf ("a is equal to 0\n"); // If a is 0 break; case 1: printf ("a is equal to 1\n"); // If a is 1 break; default: printf ("a is greater than 1\n"); // If not } }
the_stack_data/305593.c
/*Write a function expand (s, t) which converts characters like newline and tab into visible escape sequences like \n and \t as it copies the string s to t. Use switch statement and also display both s and t at the end*/ #include<stdio.h> #include<string.h> void expand(char *, char *); int main() { char t[20], s[20]; printf("\nEnter the first string : "); scanf("%[^.]s", s); printf("\nGiven string : %s\n", s); strcpy(t, s); expand(s, t); return 0; } void expand(char *s, char *t) { int i=0, j=0; printf("\nModified string : "); while(s[i] != '\0') { if(s[i] == '\t') { printf("\\t"); i++; } if(s[i] == '\n') { printf("\\n"); i++; } t[j] = s[i]; printf("%c", t[j]); i++; j++; } printf("\n"); }
the_stack_data/67325025.c
#include <stdlib.h> #include <stdio.h> #include <string.h> int count_c(char* a,char* b) { int as=strlen(a); int bs=strlen(b); int i, j; i=0; if(as==0 || bs==0) return 0; while(i<as) { j=0; while(j<as-i && j<bs) { if(a[i+j]==b[j]) j++; else { i=i+j; break; } if(i+j==as) return j; } i++; } return 0; } int main() { int** m; int n,i,i1,j,j1,k, max,res=0,t_len; char** arr; scanf("%d", &n); arr = (char**) malloc(n*sizeof (char*)); char tmp[80]; gets(tmp); for(i=0;i<n;i++) { gets(tmp); arr[i]=(char*)malloc((strlen(tmp)+1)*sizeof(char)); t_len+=strlen(tmp); strcpy(arr[i],tmp); } m=(int**)malloc(n*sizeof(int*)); for(i=0;i<n;i++) m[i]=(int*)malloc(n*sizeof(int)); for(i=0;i<n;i++) for(j=0;j<n;j++) if(i!=j) m[i][j]=count_c(arr[i],arr[j]); else m[i][j]=0; k=0; while(k<n-1) { max=0; i1=0; j1=0; for(i=0;i<n;i++) for(j=0;j<n;j++) if (max<m[i][j]) { max=m[i][j]; i1=i; j1=j; } res+=max; k++; for(i=0;i<n;i++) { m[i][j1]=0; m[i1][i]=0; } } for(i=0;i<n;i++) free(arr[i]); free(arr); for(i=0;i<n;i++) free(m[i]); free(m); t_len=t_len-res; printf("%d",t_len); system("pause"); return 0; }
the_stack_data/25832.c
#include <stdio.h> #include <string.h> #include <ctype.h> #include <stdlib.h> char prekey[64]; int strip(char *str) { int i=strlen(str); while(i>=0) { if(isspace(str[i])) { str[i]='\0'; } else return i; i--; } return 0; } int vis[256]; char code1[256]; char code2[256]; int next[256]; int prev[256]; void get_code() { int i; int len=strlen(code1); for(i=0; i<len-1; i++) { next[i]=i+1; prev[i+1]=i; } prev[0]=len-1; next[len-1]=0; int last=len; int v=0; while(last--) { int step=code1[v]; char tmp=code1[v]; //printf("%d\n",step); //del next[prev[v]]=next[v]; prev[next[v]]=prev[v]; //disp if(v==next[v]) { //剩下的最后一个字符的密文为原密钥的第一个字符 code2[(int)tmp]=code1[0]; break; } while(step--) { v=next[v]; } code2[(int)tmp]=code1[v]; #ifdef DEBUG printf("%c->%c\n",(char)tmp,code1[v]); #endif // DEBUG } #ifdef DEBUG for(i=32; i<=126; i++) { printf("%c",i); } printf("\n"); for(i=32; i<=126; i++) { printf("%c",code2[i]); } printf("\n"); #endif } int main() { FILE *fin,*fout; fin=fopen("in.txt","r"); fout=fopen("in_crpyt.txt","w"); fgets(prekey,64,stdin); //fputs(prekey,fout); int len1=strip(prekey); int i,j; memset(vis,0,sizeof(vis)); for(i=0,j=0; i<len1; i++) { if(prekey[i]>=32 && prekey[i]<=126) { if(!vis[(int)prekey[i]]) { vis[(int)prekey[i]]=1; code1[j++]=prekey[i]; } } } for(i=32; i<=126; i++) if(!vis[i]) code1[j++]=i; code1[j]=0; #ifdef DEBUG puts(code1); #endif // DEBUG get_code(); int ch; while((ch=fgetc(fin))!=EOF) { if(ch>=32 && ch<=126) { fputc(code2[ch],fout); } else fputc(ch,fout); } fclose(fin); fclose(fout); return 0; }
the_stack_data/144449.c
#include <stdio.h> int main(){ /*initiating variables */ int list[4],i,max,min; /* user input */ printf("Enter four integers: "); /* put the user integers into an array called list */ for(i=0;i<=3;i++) { scanf ("%d",&list[i]); } /* max and min initially set to the value of the first element of the array */ max = list[0]; min = list[0]; /* finding the max value using a for loop */ for (i = 1;i <= 3;i++) { if (max < list[i]){ max = list[i]; } } /*finding the min value using a for loop */ for (i = 1;i <= 3;i++) { if (min > list[i]){ min = list[i]; } } /*output*/ printf("Largest: %d \n",max); printf("Smallest: %d \n",min); return 0; }
the_stack_data/502165.c
/** * Copyright 2021 Tech Penguineer * * 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. */
the_stack_data/1015323.c
#include <stdio.h> #include <stdlib.h> #include <string.h> char str[100],stack[100]; int stkPtr=-1; void push(char); char pop(); char peek(); void error(); int main(){ int i,len,k; printf("Enter the expression:- "); gets(str); push('$'); len=strlen(str); str[len]='$'; str[len+1]='\0'; for(i=0;i<len;i++){ if(str[i]>='0' && str[i]<='9'){ while(str[i+1]>='0'&&str[i+1]<='9') i++; push('E'); } else if(str[i]=='+' || str[i]=='-' || str[i]=='/' || str[i]=='*') push(str[i]); else error(); } while(stkPtr>=3){ if(stack[stkPtr]=='E' && (stack[stkPtr-1]=='+' || stack[stkPtr-1]=='-' || stack[stkPtr-1]=='*' || stack[stkPtr-1]=='/') && stack[stkPtr-2]=='E'){ pop(); pop(); } else error(); } if(stack[stkPtr]=='E' && stack[stkPtr-1]=='$') printf("SUCCESS\n"); else error(); return 0; } void push(char a){ stack[++stkPtr]=a; } char pop(){ return stack[stkPtr--]; } char peek(){ return stack[stkPtr]; } void error(){ printf("ERROR\n"); exit(1); }
the_stack_data/655186.c
/* ** libgcc support for software floating point. ** Copyright (C) 1991 by Pipeline Associates, Inc. All rights reserved. ** Permission is granted to do *anything* you want with this file, ** commercial or otherwise, provided this message remains intact. So there! ** I would appreciate receiving any updates/patches/changes that anyone ** makes, and am willing to be the repository for said changes (am I ** making a big mistake?). Warning! Only single-precision is actually implemented. This file won't really be much use until double-precision is supported. However, once that is done, this file might eventually become a replacement for libgcc1.c. It might also make possible cross-compilation for an IEEE target machine from a non-IEEE host such as a VAX. If you'd like to work on completing this, please talk to [email protected]. ** ** Pat Wood ** Pipeline Associates, Inc. ** [email protected] or ** sun!pipeline!phw or ** uunet!motown!pipeline!phw ** ** 05/01/91 -- V1.0 -- first release to gcc mailing lists ** 05/04/91 -- V1.1 -- added float and double prototypes and return values ** -- fixed problems with adding and subtracting zero ** -- fixed rounding in truncdfsf2 ** -- fixed SWAP define and tested on 386 */ /* ** The following are routines that replace the libgcc soft floating point ** routines that are called automatically when -msoft-float is selected. ** The support single and double precision IEEE format, with provisions ** for byte-swapped machines (tested on 386). Some of the double-precision ** routines work at full precision, but most of the hard ones simply punt ** and call the single precision routines, producing a loss of accuracy. ** long long support is not assumed or included. ** Overall accuracy is close to IEEE (actually 68882) for single-precision ** arithmetic. I think there may still be a 1 in 1000 chance of a bit ** being rounded the wrong way during a multiply. I'm not fussy enough to ** bother with it, but if anyone is, knock yourself out. ** ** Efficiency has only been addressed where it was obvious that something ** would make a big difference. Anyone who wants to do this right for ** best speed should go in and rewrite in assembler. ** ** I have tested this only on a 68030 workstation and 386/ix integrated ** in with -msoft-float. */ /* the following deal with IEEE single-precision numbers */ #define EXCESS 126 #define SIGNBIT 0x80000000 #define HIDDEN (1 << 23) #define SIGN(fp) ((fp) & SIGNBIT) #define EXP(fp) (((fp) >> 23) & 0xFF) #define MANT(fp) (((fp) & 0x7FFFFF) | HIDDEN) #define PACK(s,e,m) ((s) | ((e) << 23) | (m)) /* the following deal with IEEE double-precision numbers */ #define EXCESSD 1022 #define HIDDEND (1 << 20) #define EXPD(fp) (((fp.l.upper) >> 20) & 0x7FF) #define SIGND(fp) ((fp.l.upper) & SIGNBIT) #define MANTD(fp) (((((fp.l.upper) & 0xFFFFF) | HIDDEND) << 10) | \ (fp.l.lower >> 22)) /* define SWAP for 386/960 reverse-byte-order brain-damaged CPUs */ union double_long { double d; #ifdef SWAP struct { unsigned long lower; long upper; } l; #else struct { long upper; unsigned long lower; } l; #endif }; union float_long { float f; long l; }; /* add two floats */ float __addsf3 (float a1, float a2) { register long mant1, mant2; register union float_long fl1, fl2; register int exp1, exp2; int sign = 0; fl1.f = a1; fl2.f = a2; /* check for zero args */ if (!fl1.l) return (fl2.f); if (!fl2.l) return (fl1.f); exp1 = EXP (fl1.l); exp2 = EXP (fl2.l); if (exp1 > exp2 + 25) return (fl1.l); if (exp2 > exp1 + 25) return (fl2.l); /* do everything in excess precision so's we can round later */ mant1 = MANT (fl1.l) << 6; mant2 = MANT (fl2.l) << 6; if (SIGN (fl1.l)) mant1 = -mant1; if (SIGN (fl2.l)) mant2 = -mant2; if (exp1 > exp2) { mant2 >>= exp1 - exp2; } else { mant1 >>= exp2 - exp1; exp1 = exp2; } mant1 += mant2; if (mant1 < 0) { mant1 = -mant1; sign = SIGNBIT; } else if (!mant1) return (0); /* normalize up */ while (!(mant1 & 0xE0000000)) { mant1 <<= 1; exp1--; } /* normalize down? */ if (mant1 & (1 << 30)) { mant1 >>= 1; exp1++; } /* round to even */ mant1 += (mant1 & 0x40) ? 0x20 : 0x1F; /* normalize down? */ if (mant1 & (1 << 30)) { mant1 >>= 1; exp1++; } /* lose extra precision */ mant1 >>= 6; /* turn off hidden bit */ mant1 &= ~HIDDEN; /* pack up and go home */ fl1.l = PACK (sign, exp1, mant1); return (fl1.f); } /* subtract two floats */ float __subsf3 (float a1, float a2) { register union float_long fl1, fl2; fl1.f = a1; fl2.f = a2; /* check for zero args */ if (!fl2.l) return (fl1.f); if (!fl1.l) return (-fl2.f); /* twiddle sign bit and add */ fl2.l ^= SIGNBIT; return __addsf3 (a1, fl2.f); } /* compare two floats */ long __cmpsf2 (float a1, float a2) { register union float_long fl1, fl2; fl1.f = a1; fl2.f = a2; if (SIGN (fl1.l) && SIGN (fl2.l)) { fl1.l ^= SIGNBIT; fl2.l ^= SIGNBIT; } if (fl1.l < fl2.l) return (-1); if (fl1.l > fl2.l) return (1); return (0); } /* multiply two floats */ float __mulsf3 (float a1, float a2) { register union float_long fl1, fl2; register unsigned long result; register int exp; int sign; fl1.f = a1; fl2.f = a2; if (!fl1.l || !fl2.l) return (0); /* compute sign and exponent */ sign = SIGN (fl1.l) ^ SIGN (fl2.l); exp = EXP (fl1.l) - EXCESS; exp += EXP (fl2.l); fl1.l = MANT (fl1.l); fl2.l = MANT (fl2.l); /* the multiply is done as one 16x16 multiply and two 16x8 multiples */ result = (fl1.l >> 8) * (fl2.l >> 8); result += ((fl1.l & 0xFF) * (fl2.l >> 8)) >> 8; result += ((fl2.l & 0xFF) * (fl1.l >> 8)) >> 8; if (result & 0x80000000) { /* round */ result += 0x80; result >>= 8; } else { /* round */ result += 0x40; result >>= 7; exp--; } result &= ~HIDDEN; /* pack up and go home */ fl1.l = PACK (sign, exp, result); return (fl1.f); } /* divide two floats */ float __divsf3 (float a1, float a2) { register union float_long fl1, fl2; register int result; register int mask; register int exp, sign; fl1.f = a1; fl2.f = a2; /* subtract exponents */ exp = EXP (fl1.l) - EXP (fl2.l) + EXCESS; /* compute sign */ sign = SIGN (fl1.l) ^ SIGN (fl2.l); /* divide by zero??? */ if (!fl2.l) /* return NaN or -NaN */ return (sign ? 0xFFFFFFFF : 0x7FFFFFFF); /* numerator zero??? */ if (!fl1.l) return (0); /* now get mantissas */ fl1.l = MANT (fl1.l); fl2.l = MANT (fl2.l); /* this assures we have 25 bits of precision in the end */ if (fl1.l < fl2.l) { fl1.l <<= 1; exp--; } /* now we perform repeated subtraction of fl2.l from fl1.l */ mask = 0x1000000; result = 0; while (mask) { if (fl1.l >= fl2.l) { result |= mask; fl1.l -= fl2.l; } fl1.l <<= 1; mask >>= 1; } /* round */ result += 1; /* normalize down */ exp++; result >>= 1; result &= ~HIDDEN; /* pack up and go home */ fl1.l = PACK (sign, exp, result); return (fl1.f); } /* convert int to double */ double __floatsidf (register long a1) { register int sign = 0, exp = 31 + EXCESSD; union double_long dl; if (!a1) { dl.l.upper = dl.l.lower = 0; return (dl.d); } if (a1 < 0) { sign = SIGNBIT; a1 = -a1; } while (a1 < 0x1000000) { a1 <<= 4; exp -= 4; } while (a1 < 0x40000000) { a1 <<= 1; exp--; } /* pack up and go home */ dl.l.upper = sign; dl.l.upper |= exp << 20; dl.l.upper |= (a1 >> 10) & ~HIDDEND; dl.l.lower = a1 << 22; return (dl.d); } /* negate a float */ float __negsf2 (float a1) { register union float_long fl1; fl1.f = a1; if (!fl1.l) return (0); fl1.l ^= SIGNBIT; return (fl1.f); } /* negate a double */ double __negdf2 (double a1) { register union double_long dl1; dl1.d = a1; if (!dl1.l.upper && !dl1.l.lower) return (dl1.d); dl1.l.upper ^= SIGNBIT; return (dl1.d); } /* convert float to double */ double __extendsfdf2 (float a1) { register union float_long fl1; register union double_long dl; register int exp; fl1.f = a1; if (!fl1.l) { dl.l.upper = dl.l.lower = 0; return (dl.d); } dl.l.upper = SIGN (fl1.l); exp = EXP (fl1.l) - EXCESS + EXCESSD; dl.l.upper |= exp << 20; dl.l.upper |= (MANT (fl1.l) & ~HIDDEN) >> 3; dl.l.lower = MANT (fl1.l) << 29; return (dl.d); } /* convert double to float */ float __truncdfsf2 (double a1) { register int exp; register long mant; register union float_long fl; register union double_long dl1; dl1.d = a1; if (!dl1.l.upper && !dl1.l.lower) return (0); exp = EXPD (dl1) - EXCESSD + EXCESS; /* shift double mantissa 6 bits so we can round */ mant = MANTD (dl1) >> 6; /* now round and shift down */ mant += 1; mant >>= 1; /* did the round overflow? */ if (mant & 0xFF000000) { mant >>= 1; exp++; } mant &= ~HIDDEN; /* pack up and go home */ fl.l = PACK (SIGND (dl1), exp, mant); return (fl.f); } /* compare two doubles */ long __cmpdf2 (double a1, double a2) { register union double_long dl1, dl2; dl1.d = a1; dl2.d = a2; if (SIGND (dl1) && SIGND (dl2)) { dl1.l.upper ^= SIGNBIT; dl2.l.upper ^= SIGNBIT; } if (dl1.l.upper < dl2.l.upper) return (-1); if (dl1.l.upper > dl2.l.upper) return (1); if (dl1.l.lower < dl2.l.lower) return (-1); if (dl1.l.lower > dl2.l.lower) return (1); return (0); } /* convert double to int */ long __fixdfsi (double a1) { register union double_long dl1; register int exp; register long l; dl1.d = a1; if (!dl1.l.upper && !dl1.l.lower) return (0); exp = EXPD (dl1) - EXCESSD - 31; l = MANTD (dl1); if (exp > 0) return (0x7FFFFFFF | SIGND (dl1)); /* largest integer */ /* shift down until exp = 0 or l = 0 */ if (exp < 0 && exp > -32 && l) l >>= -exp; else return (0); return (SIGND (dl1) ? -l : l); } /* convert double to unsigned int */ unsigned long __fixunsdfsi (double a1) { register union double_long dl1; register int exp; register unsigned long l; dl1.d = a1; if (!dl1.l.upper && !dl1.l.lower) return (0); exp = EXPD (dl1) - EXCESSD - 32; l = (((((dl1.l.upper) & 0xFFFFF) | HIDDEND) << 11) | (dl1.l.lower >> 21)); if (exp > 0) return (0xFFFFFFFF); /* largest integer */ /* shift down until exp = 0 or l = 0 */ if (exp < 0 && exp > -32 && l) l >>= -exp; else return (0); return (l); } /* For now, the hard double-precision routines simply punt and do it in single */ /* addtwo doubles */ double __adddf3 (double a1, double a2) { return ((float) a1 + (float) a2); } /* subtract two doubles */ double __subdf3 (double a1, double a2) { return ((float) a1 - (float) a2); } /* multiply two doubles */ double __muldf3 (double a1, double a2) { return ((float) a1 * (float) a2); } /* divide two doubles */ double __divdf3 (double a1, double a2) { return ((float) a1 / (float) a2); }
the_stack_data/220454495.c
/** ****************************************************************************** * @file stm32f2xx_ll_dac.c * @author MCD Application Team * @brief DAC LL module driver ****************************************************************************** * @attention * * <h2><center>&copy; COPYRIGHT(c) 2017 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. * ****************************************************************************** */ #if defined(USE_FULL_LL_DRIVER) /* Includes ------------------------------------------------------------------*/ #include "stm32f2xx_ll_dac.h" #include "stm32f2xx_ll_bus.h" #ifdef USE_FULL_ASSERT #include "stm32_assert.h" #else #define assert_param(expr) ((void)0U) #endif /** @addtogroup STM32F2xx_LL_Driver * @{ */ #if defined(DAC) /** @addtogroup DAC_LL DAC * @{ */ /* Private types -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private constants ---------------------------------------------------------*/ /* Private macros ------------------------------------------------------------*/ /** @addtogroup DAC_LL_Private_Macros * @{ */ #define IS_LL_DAC_CHANNEL(__DACX__, __DAC_CHANNEL__) \ ( \ ((__DAC_CHANNEL__) == LL_DAC_CHANNEL_1) \ || ((__DAC_CHANNEL__) == LL_DAC_CHANNEL_2) \ ) #define IS_LL_DAC_TRIGGER_SOURCE(__TRIGGER_SOURCE__) \ ( ((__TRIGGER_SOURCE__) == LL_DAC_TRIG_SOFTWARE) \ || ((__TRIGGER_SOURCE__) == LL_DAC_TRIG_EXT_TIM2_TRGO) \ || ((__TRIGGER_SOURCE__) == LL_DAC_TRIG_EXT_TIM4_TRGO) \ || ((__TRIGGER_SOURCE__) == LL_DAC_TRIG_EXT_TIM5_TRGO) \ || ((__TRIGGER_SOURCE__) == LL_DAC_TRIG_EXT_TIM6_TRGO) \ || ((__TRIGGER_SOURCE__) == LL_DAC_TRIG_EXT_TIM7_TRGO) \ || ((__TRIGGER_SOURCE__) == LL_DAC_TRIG_EXT_TIM8_TRGO) \ || ((__TRIGGER_SOURCE__) == LL_DAC_TRIG_EXT_EXTI_LINE9) \ ) #define IS_LL_DAC_WAVE_AUTO_GENER_MODE(__WAVE_AUTO_GENERATION_MODE__) \ ( ((__WAVE_AUTO_GENERATION_MODE__) == LL_DAC_WAVE_AUTO_GENERATION_NONE) \ || ((__WAVE_AUTO_GENERATION_MODE__) == LL_DAC_WAVE_AUTO_GENERATION_NOISE) \ || ((__WAVE_AUTO_GENERATION_MODE__) == LL_DAC_WAVE_AUTO_GENERATION_TRIANGLE) \ ) #define IS_LL_DAC_WAVE_AUTO_GENER_CONFIG(__WAVE_AUTO_GENERATION_CONFIG__) \ ( ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_NOISE_LFSR_UNMASK_BIT0) \ || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_NOISE_LFSR_UNMASK_BITS1_0) \ || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_NOISE_LFSR_UNMASK_BITS2_0) \ || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_NOISE_LFSR_UNMASK_BITS3_0) \ || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_NOISE_LFSR_UNMASK_BITS4_0) \ || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_NOISE_LFSR_UNMASK_BITS5_0) \ || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_NOISE_LFSR_UNMASK_BITS6_0) \ || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_NOISE_LFSR_UNMASK_BITS7_0) \ || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_NOISE_LFSR_UNMASK_BITS8_0) \ || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_NOISE_LFSR_UNMASK_BITS9_0) \ || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_NOISE_LFSR_UNMASK_BITS10_0) \ || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_NOISE_LFSR_UNMASK_BITS11_0) \ || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_TRIANGLE_AMPLITUDE_1) \ || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_TRIANGLE_AMPLITUDE_3) \ || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_TRIANGLE_AMPLITUDE_7) \ || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_TRIANGLE_AMPLITUDE_15) \ || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_TRIANGLE_AMPLITUDE_31) \ || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_TRIANGLE_AMPLITUDE_63) \ || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_TRIANGLE_AMPLITUDE_127) \ || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_TRIANGLE_AMPLITUDE_255) \ || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_TRIANGLE_AMPLITUDE_511) \ || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_TRIANGLE_AMPLITUDE_1023) \ || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_TRIANGLE_AMPLITUDE_2047) \ || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_TRIANGLE_AMPLITUDE_4095) \ ) #define IS_LL_DAC_OUTPUT_BUFFER(__OUTPUT_BUFFER__) \ ( ((__OUTPUT_BUFFER__) == LL_DAC_OUTPUT_BUFFER_ENABLE) \ || ((__OUTPUT_BUFFER__) == LL_DAC_OUTPUT_BUFFER_DISABLE) \ ) /** * @} */ /* Private function prototypes -----------------------------------------------*/ /* Exported functions --------------------------------------------------------*/ /** @addtogroup DAC_LL_Exported_Functions * @{ */ /** @addtogroup DAC_LL_EF_Init * @{ */ /** * @brief De-initialize registers of the selected DAC instance * to their default reset values. * @param DACx DAC instance * @retval An ErrorStatus enumeration value: * - SUCCESS: DAC registers are de-initialized * - ERROR: not applicable */ ErrorStatus LL_DAC_DeInit(DAC_TypeDef *DACx) { /* Prevent unused argument(s) compilation warning */ UNUSED(DACx); /* Check the parameters */ assert_param(IS_DAC_ALL_INSTANCE(DACx)); /* Force reset of DAC1 clock */ LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_DAC1); /* Release reset of DAC1 clock */ LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_DAC1); return SUCCESS; } /** * @brief Initialize some features of DAC instance. * @note The setting of these parameters by function @ref LL_DAC_Init() * is conditioned to DAC state: * DAC instance must be disabled. * @param DACx DAC instance * @param DAC_Channel This parameter can be one of the following values: * @arg @ref LL_DAC_CHANNEL_1 * @arg @ref LL_DAC_CHANNEL_2 * @param DAC_InitStruct Pointer to a @ref LL_DAC_InitTypeDef structure * @retval An ErrorStatus enumeration value: * - SUCCESS: DAC registers are initialized * - ERROR: DAC registers are not initialized */ ErrorStatus LL_DAC_Init(DAC_TypeDef *DACx, uint32_t DAC_Channel, LL_DAC_InitTypeDef *DAC_InitStruct) { ErrorStatus status = SUCCESS; /* Check the parameters */ assert_param(IS_DAC_ALL_INSTANCE(DACx)); assert_param(IS_LL_DAC_CHANNEL(DACx, DAC_Channel)); assert_param(IS_LL_DAC_TRIGGER_SOURCE(DAC_InitStruct->TriggerSource)); assert_param(IS_LL_DAC_OUTPUT_BUFFER(DAC_InitStruct->OutputBuffer)); assert_param(IS_LL_DAC_WAVE_AUTO_GENER_MODE(DAC_InitStruct->WaveAutoGeneration)); if (DAC_InitStruct->WaveAutoGeneration != LL_DAC_WAVE_AUTO_GENERATION_NONE) { assert_param(IS_LL_DAC_WAVE_AUTO_GENER_CONFIG(DAC_InitStruct->WaveAutoGenerationConfig)); } /* Note: Hardware constraint (refer to description of this function) */ /* DAC instance must be disabled. */ if(LL_DAC_IsEnabled(DACx, DAC_Channel) == 0U) { /* Configuration of DAC channel: */ /* - TriggerSource */ /* - WaveAutoGeneration */ /* - OutputBuffer */ if (DAC_InitStruct->WaveAutoGeneration != LL_DAC_WAVE_AUTO_GENERATION_NONE) { MODIFY_REG(DACx->CR, ( DAC_CR_TSEL1 | DAC_CR_WAVE1 | DAC_CR_MAMP1 | DAC_CR_BOFF1 ) << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK) , ( DAC_InitStruct->TriggerSource | DAC_InitStruct->WaveAutoGeneration | DAC_InitStruct->WaveAutoGenerationConfig | DAC_InitStruct->OutputBuffer ) << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK) ); } else { MODIFY_REG(DACx->CR, ( DAC_CR_TSEL1 | DAC_CR_WAVE1 | DAC_CR_BOFF1 ) << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK) , ( DAC_InitStruct->TriggerSource | LL_DAC_WAVE_AUTO_GENERATION_NONE | DAC_InitStruct->OutputBuffer ) << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK) ); } } else { /* Initialization error: DAC instance is not disabled. */ status = ERROR; } return status; } /** * @brief Set each @ref LL_DAC_InitTypeDef field to default value. * @param DAC_InitStruct pointer to a @ref LL_DAC_InitTypeDef structure * whose fields will be set to default values. * @retval None */ void LL_DAC_StructInit(LL_DAC_InitTypeDef *DAC_InitStruct) { /* Set DAC_InitStruct fields to default values */ DAC_InitStruct->TriggerSource = LL_DAC_TRIG_SOFTWARE; DAC_InitStruct->WaveAutoGeneration = LL_DAC_WAVE_AUTO_GENERATION_NONE; /* Note: Parameter discarded if wave auto generation is disabled, */ /* set anyway to its default value. */ DAC_InitStruct->WaveAutoGenerationConfig = LL_DAC_NOISE_LFSR_UNMASK_BIT0; DAC_InitStruct->OutputBuffer = LL_DAC_OUTPUT_BUFFER_ENABLE; } /** * @} */ /** * @} */ /** * @} */ #endif /* DAC */ /** * @} */ #endif /* USE_FULL_LL_DRIVER */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
the_stack_data/43887415.c
#ifdef HW_RVL #include <gccore.h> #define RETRODE_VID 0x0403 #define RETRODE_PID 0x97C1 static bool setup = false; static bool replugRequired = false; static s32 deviceId = 0; static u8 endpoint = 0; static u8 bMaxPacketSize = 0; static u32 jpRetrode[4]; static bool isRetrode(usb_device_entry dev) { return dev.vid == RETRODE_VID && dev.pid == RETRODE_PID; } static bool isRetrodeGamepad(usb_devdesc devdesc) { if (devdesc.idVendor != RETRODE_VID || devdesc.idProduct != RETRODE_PID || devdesc.configurations == NULL || devdesc.configurations->interfaces == NULL || devdesc.configurations->interfaces->endpoints == NULL) { return false; } return devdesc.configurations->interfaces->bInterfaceSubClass == 0; } static u8 getEndpoint(usb_devdesc devdesc) { if (devdesc.configurations == NULL || devdesc.configurations->interfaces == NULL || devdesc.configurations->interfaces->endpoints == NULL) { return -1; } return devdesc.configurations->interfaces->endpoints->bEndpointAddress; } static int removal_cb(int result, void *usrdata) { s32 fd = (s32) usrdata; if (fd == deviceId) { deviceId = 0; } return 1; } static void open() { if (deviceId != 0) { return; } usb_device_entry dev_entry[8]; u8 dev_count; if (USB_GetDeviceList(dev_entry, 8, USB_CLASS_HID, &dev_count) < 0) { return; } // Retrode has two entries in USB_GetDeviceList(), one for gamepads and one for SNES mouse for (int i = 0; i < dev_count; ++i) { if (!isRetrode(dev_entry[i])) { continue; } s32 fd; if (USB_OpenDevice(dev_entry[i].device_id, dev_entry[i].vid, dev_entry[i].pid, &fd) < 0) { continue; } usb_devdesc devdesc; if (USB_GetDescriptors(fd, &devdesc) < 0) { // You have to replug the Retrode controller! replugRequired = true; USB_CloseDevice(&fd); break; } if (isRetrodeGamepad(devdesc)) { deviceId = fd; replugRequired = false; endpoint = getEndpoint(devdesc); bMaxPacketSize = devdesc.bMaxPacketSize0; USB_DeviceRemovalNotifyAsync(fd, &removal_cb, (void*) fd); break; } else { USB_CloseDevice(&fd); } } setup = true; } void Retrode_ScanPads() { if (deviceId == 0) { return; } uint8_t ATTRIBUTE_ALIGN(32) buf[bMaxPacketSize]; // Retrode gamepad endpoint returns 5 bytes with gamepad events if (USB_ReadIntrMsg(deviceId, endpoint, sizeof(buf), buf) != 5) { return; } // buf[0] contains the port returned // you have to make 4 calls to get the status, even if you are only interested in one port // because it is not sure which port is returned first // 1 = left SNES // 2 = right SNES // 3 = left Genesis/MD // 4 = right Genesis/MD // Button layout // A=3,10 // B=3,01 // X=3,20 // Y=3,02 // L=3,40 // R=3,80 // Up=2,9C // Down=2,64 // Left=1,9C // Right=1,64 // Start=3,08 // Select=3,04 u32 jp = 0; jp |= ((buf[2] & 0x9C) == 0x9C) ? PAD_BUTTON_UP : 0; jp |= ((buf[2] & 0x64) == 0x64) ? PAD_BUTTON_DOWN : 0; jp |= ((buf[1] & 0x9C) == 0x9C) ? PAD_BUTTON_LEFT : 0; jp |= ((buf[1] & 0x64) == 0x64) ? PAD_BUTTON_RIGHT : 0; jp |= (buf[3] & 0x10) ? PAD_BUTTON_A : 0; jp |= (buf[3] & 0x01) ? PAD_BUTTON_B : 0; jp |= (buf[3] & 0x20) ? PAD_BUTTON_X : 0; jp |= (buf[3] & 0x02) ? PAD_BUTTON_Y : 0; jp |= (buf[3] & 0x40) ? PAD_TRIGGER_L : 0; jp |= (buf[3] & 0x80) ? PAD_TRIGGER_R : 0; jp |= (buf[3] & 0x08) ? PAD_BUTTON_START : 0; jp |= (buf[3] & 0x04) ? PAD_TRIGGER_Z : 0; // SNES select button maps to Z // Required, otherwise if the returned port isn't the one we are looking for, jp will be set to zero, // and held buttons are not possible w/o saving the state. jpRetrode[buf[0] - 1] = jp; } u32 Retrode_ButtonsHeld(int chan) { if(!setup) { open(); } if (deviceId == 0) { return 0; } return jpRetrode[chan]; } char* Retrode_Status() { open(); if (replugRequired) return "please replug"; return deviceId ? "connected" : "not found"; } #endif
the_stack_data/114801.c
#include <stdio.h> int deletion(); int main() { int arr[40], a, n, i; printf(" Enter the size of array- "); scanf("%d", &n); printf(" Enter the array elements:- "); for (i = 0; i < n; i++) { scanf("%d", &arr[i]); } printf("\n"); printf("enter the number to be deleted:- "); scanf("%d", &a); deletion(arr, n, a); printf("array is:- "); for (i = 0; i < n; i++) { printf("%d\t", arr[i]); } } int deletion(int arr[], int n, int a) { for (int i = 0; i < n; i++) { if (arr[i] == a) break; if (i == n) return n; for (int j = i; j < n+1; j++) arr[i] = arr[j + 1]; return (n - 1); } }
the_stack_data/59513897.c
#include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { // check if the namefile was specified if (argc != 2) { fprintf(stderr, "Usage: ./recover image\n"); return 1; } // check if memory card is successfully opened FILE *file = fopen(argv[1], "r"); if (file == NULL) { fprintf(stderr, "Could not open file %s.\n", argv[1]); return 1; } //create vars that we gonna use and allocate memory for them FILE *img; char filename[7]; unsigned char *bf = malloc(512); int end = 1000; int counter = 0; while (fread(bf, 512, 1, file)) { // new jpg file found if (bf[0] == 0xff && bf[1] == 0xd8 && bf[2] == 0xff && (bf[3] & 0xf0) == 0xe0) { // close previous jpg file if it exists if (counter > 0) { fclose(img); } // create filename sprintf(filename, "%03d.jpg", counter); // open new image file img = fopen(filename, "w"); // check if jpg file is successfully created if (img == NULL) { fclose(file); free(bf); fprintf(stderr, "Could not create output JPG %s", filename); return 3; } counter++; } //if any jpg file exists writes on the file currently opened if (counter > 0) { fwrite(bf, 512, 1, img); } } //frees memory and closes files fclose(img); fclose(file); free(bf); return 0; }
the_stack_data/868117.c
/* "$Id: conf.c 2866 2002-12-09 04:52:32Z spitzak $" Configuration file routines for the Fast Light Tool Kit (FLTK). Carl Thompson's config file routines version 0.5 Copyright 1995-2000 Carl Everard Thompson ([email protected]) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ /* file: conf.c author: Carl Thompson ([email protected]) start date: 16 Dec 1995 Typical config file format: ------- test.conf -------------------------------------------------------------------------------------------------------- key1 = value1 # this key is not in a section key2 # this key has no value associated [section1] # Three standard key/value pairs key1 = value1 key2 = value2 key3 = value3 [section1/subsection] # this is how a subsection is defined key1 = value1 key2 = value2 [section2] key1 = value1 key2 = value2 -------------------------------------------------------------------------------------------------------------------------- Notes: - comments may be on a line by themselves or at the end of a line - for comments at the end of the line, the comment separator character must followed by whitespace - indentation/formatting is handled automatically (sorry!) */ /* global variables */ char conf_sep = '='; /* this seperates keys from values */ char conf_level_sep = '/'; /* this denotes nested sections */ char conf_comment_sep = '#'; /* this denotes comments */ int conf_comment_column = 51; /* what column comments start in */ /* End of "$Id: conf.c 2866 2002-12-09 04:52:32Z spitzak $". */
the_stack_data/156392336.c
#include <stdio.h> int main(){ int n, i; float s; printf("Digite um numero inteiro e positivo: "); scanf("%d", &n); for(i = 1; i <= n; i ++){ s+= 1/(float)i; } printf("Soma total: %.2f", s); return 0; }
the_stack_data/68888438.c
extern void __VERIFIER_error() __attribute__ ((__noreturn__)); void __VERIFIER_assert(int cond) { if(!(cond)) { ERROR: __VERIFIER_error(); } } #define N 150 int main( ) { int a[ N ]; int swapped = 1; while ( swapped ) { swapped = 0; int i = 1; while ( i < N ) { if ( a[i] > a[i-1] ) { int t = a[i]; a[i] = a[i - 1]; a[i-1] = t; swapped = 1; } i = i + 1; } } int x; int y; for ( x = 0 ; x < N ; x++ ) { for ( y = x+1 ; y < N ; y++ ) { __VERIFIER_assert( a[x] <= a[y] ); } } return 0; }
the_stack_data/12638235.c
// RUN: %clang_builtins %s %librt -o %t && %run %t //===------------ eqtf2_test.c - Test __eqtf2------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This file tests __eqtf2 for the compiler_rt library. // //===----------------------------------------------------------------------===// #include <stdio.h> #if __LP64__ && __LDBL_MANT_DIG__ == 113 #include "fp_test.h" int __eqtf2(long double a, long double b); int test__eqtf2(long double a, long double b, enum EXPECTED_RESULT expected) { int x = __eqtf2(a, b); int ret = compareResultCMP(x, expected); if (ret){ printf("error in test__eqtf2(%.20Lf, %.20Lf) = %d, " "expected %s\n", a, b, x, expectedStr(expected)); } return ret; } char assumption_1[sizeof(long double) * CHAR_BIT == 128] = {0}; #endif int main() { #if __LP64__ && __LDBL_MANT_DIG__ == 113 // NaN if (test__eqtf2(makeQNaN128(), 0x1.234567890abcdef1234567890abcp+3L, NEQUAL_0)) return 1; // < // exp if (test__eqtf2(0x1.234567890abcdef1234567890abcp-3L, 0x1.234567890abcdef1234567890abcp+3L, NEQUAL_0)) return 1; // mantissa if (test__eqtf2(0x1.234567890abcdef1234567890abcp+3L, 0x1.334567890abcdef1234567890abcp+3L, NEQUAL_0)) return 1; // sign if (test__eqtf2(-0x1.234567890abcdef1234567890abcp+3L, 0x1.234567890abcdef1234567890abcp+3L, NEQUAL_0)) return 1; // == if (test__eqtf2(0x1.234567890abcdef1234567890abcp+3L, 0x1.234567890abcdef1234567890abcp+3L, EQUAL_0)) return 1; // > // exp if (test__eqtf2(0x1.234567890abcdef1234567890abcp+3L, 0x1.234567890abcdef1234567890abcp-3L, NEQUAL_0)) return 1; // mantissa if (test__eqtf2(0x1.334567890abcdef1234567890abcp+3L, 0x1.234567890abcdef1234567890abcp+3L, NEQUAL_0)) return 1; // sign if (test__eqtf2(0x1.234567890abcdef1234567890abcp+3L, -0x1.234567890abcdef1234567890abcp+3L, NEQUAL_0)) return 1; #else printf("skipped\n"); #endif return 0; }
the_stack_data/15801.c
/* { dg-options "-O1 -fstrict-overflow -fgraphite-identity" } */ void foo(int x[]) { int i, j; for (i = 0; i < 2; i++) for (j = 0; j < 2; j++) x[i] = x[i*j]; }
the_stack_data/532156.c
#include <stdio.h> #include <stdlib.h> #include <string.h> void ans (int n,char* S) { int count[26]; // notice sizeof here, // memset set first n bytes to the given value memset(count,0,sizeof(count)); if (n<26) { printf("NO"); return; } for (int i=0; i<26; i++) { printf("%d", count[i]); } for (int i=0; i<n; i++) { if(((int)*(S+i)>=97)&&((int)*(S+i)<=122)){ *(S+i)=*(S+i)-32; } count[(int)*(S+i)-65] +=1; printf("%d: %d\n", i, count[i]); } for (int i=0; i<26; i++) { if(count[i]==0) { printf("NO, i:%d, count: %d", i, count[i]); return; } } printf("YES"); return ; } int main() { int n; char s[100]; scanf("%d", &n); scanf("%s", s); ans(n,s); }
the_stack_data/193892309.c
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. #include <assert.h> #include <stdint.h> struct Rect { int32_t a; int32_t b; int32_t c; int32_t d; }; struct BiggerRect { struct Rect s; int32_t a; int32_t b; }; struct FloatRect { int32_t a; int32_t b; double c; }; struct Huge { int32_t a; int32_t b; int32_t c; int32_t d; int32_t e; }; struct FloatPoint { double x; double y; }; struct FloatOne { double x; }; struct IntOdd { int8_t a; int8_t b; int8_t c; }; // System V x86_64 ABI: // a, b, c, d, e should be in registers // s should be byval pointer // // Win64 ABI: // a, b, c, d should be in registers // e should be on the stack // s should be byval pointer void byval_rect(int32_t a, int32_t b, int32_t c, int32_t d, int32_t e, struct Rect s) { assert(a == 1); assert(b == 2); assert(c == 3); assert(d == 4); assert(e == 5); assert(s.a == 553); assert(s.b == 554); assert(s.c == 555); assert(s.d == 556); } // System V x86_64 ABI: // a, b, c, d, e, f should be in registers // s should be byval pointer on the stack // // Win64 ABI: // a, b, c, d should be in registers // e, f should be on the stack // s should be byval pointer on the stack void byval_many_rect(int32_t a, int32_t b, int32_t c, int32_t d, int32_t e, int32_t f, struct Rect s) { assert(a == 1); assert(b == 2); assert(c == 3); assert(d == 4); assert(e == 5); assert(f == 6); assert(s.a == 553); assert(s.b == 554); assert(s.c == 555); assert(s.d == 556); } // System V x86_64 ABI: // a, b, c, d, e, f, g should be in sse registers // s should be split across 2 registers // t should be byval pointer // // Win64 ABI: // a, b, c, d should be in sse registers // e, f, g should be on the stack // s should be on the stack (treated as 2 i64's) // t should be on the stack (treated as an i64 and a double) void byval_rect_floats(float a, float b, double c, float d, float e, float f, double g, struct Rect s, struct FloatRect t) { assert(a == 1.); assert(b == 2.); assert(c == 3.); assert(d == 4.); assert(e == 5.); assert(f == 6.); assert(g == 7.); assert(s.a == 553); assert(s.b == 554); assert(s.c == 555); assert(s.d == 556); assert(t.a == 3489); assert(t.b == 3490); assert(t.c == 8.); } // System V x86_64 ABI: // a, b, d, e, f should be in registers // c passed via sse registers // s should be byval pointer // // Win64 ABI: // a, b, d should be in registers // c passed via sse registers // e, f should be on the stack // s should be byval pointer void byval_rect_with_float(int32_t a, int32_t b, float c, int32_t d, int32_t e, int32_t f, struct Rect s) { assert(a == 1); assert(b == 2); assert(c == 3.); assert(d == 4); assert(e == 5); assert(f == 6); assert(s.a == 553); assert(s.b == 554); assert(s.c == 555); assert(s.d == 556); } // System V x86_64 ABI: // a, b, d, e, f should be byval pointer (on the stack) // g passed via register (fixes #41375) // // Win64 ABI: // a, b, d, e, f, g should be byval pointer void byval_rect_with_many_huge(struct Huge a, struct Huge b, struct Huge c, struct Huge d, struct Huge e, struct Huge f, struct Rect g) { assert(g.a == 123); assert(g.b == 456); assert(g.c == 789); assert(g.d == 420); } // System V x86_64 & Win64 ABI: // a, b should be in registers // s should be split across 2 integer registers void split_rect(int32_t a, int32_t b, struct Rect s) { assert(a == 1); assert(b == 2); assert(s.a == 553); assert(s.b == 554); assert(s.c == 555); assert(s.d == 556); } // System V x86_64 & Win64 ABI: // a, b should be in sse registers // s should be split across integer & sse registers void split_rect_floats(float a, float b, struct FloatRect s) { assert(a == 1.); assert(b == 2.); assert(s.a == 3489); assert(s.b == 3490); assert(s.c == 8.); } // System V x86_64 ABI: // a, b, d, f should be in registers // c, e passed via sse registers // s should be split across 2 registers // // Win64 ABI: // a, b, d should be in registers // c passed via sse registers // e, f should be on the stack // s should be on the stack (treated as 2 i64's) void split_rect_with_floats(int32_t a, int32_t b, float c, int32_t d, float e, int32_t f, struct Rect s) { assert(a == 1); assert(b == 2); assert(c == 3.); assert(d == 4); assert(e == 5.); assert(f == 6); assert(s.a == 553); assert(s.b == 554); assert(s.c == 555); assert(s.d == 556); } // System V x86_64 & Win64 ABI: // a, b, c should be in registers // s should be split across 2 registers // t should be a byval pointer void split_and_byval_rect(int32_t a, int32_t b, int32_t c, struct Rect s, struct Rect t) { assert(a == 1); assert(b == 2); assert(c == 3); assert(s.a == 553); assert(s.b == 554); assert(s.c == 555); assert(s.d == 556); assert(t.a == 553); assert(t.b == 554); assert(t.c == 555); assert(t.d == 556); } // System V x86_64 & Win64 ABI: // a, b should in registers // s and return should be split across 2 registers struct Rect split_ret_byval_struct(int32_t a, int32_t b, struct Rect s) { assert(a == 1); assert(b == 2); assert(s.a == 553); assert(s.b == 554); assert(s.c == 555); assert(s.d == 556); return s; } // System V x86_64 & Win64 ABI: // a, b, c, d should be in registers // return should be in a hidden sret pointer // s should be a byval pointer struct BiggerRect sret_byval_struct(int32_t a, int32_t b, int32_t c, int32_t d, struct Rect s) { assert(a == 1); assert(b == 2); assert(c == 3); assert(d == 4); assert(s.a == 553); assert(s.b == 554); assert(s.c == 555); assert(s.d == 556); struct BiggerRect t; t.s = s; t.a = 27834; t.b = 7657; return t; } // System V x86_64 & Win64 ABI: // a, b should be in registers // return should be in a hidden sret pointer // s should be split across 2 registers struct BiggerRect sret_split_struct(int32_t a, int32_t b, struct Rect s) { assert(a == 1); assert(b == 2); assert(s.a == 553); assert(s.b == 554); assert(s.c == 555); assert(s.d == 556); struct BiggerRect t; t.s = s; t.a = 27834; t.b = 7657; return t; } // System V x86_64 & Win64 ABI: // s should be byval pointer (since sizeof(s) > 16) // return should in a hidden sret pointer struct Huge huge_struct(struct Huge s) { assert(s.a == 5647); assert(s.b == 5648); assert(s.c == 5649); assert(s.d == 5650); assert(s.e == 5651); return s; } // System V x86_64 ABI: // p should be in registers // return should be in registers // // Win64 ABI and 64-bit PowerPC ELFv1 ABI: // p should be a byval pointer // return should be in a hidden sret pointer struct FloatPoint float_point(struct FloatPoint p) { assert(p.x == 5.); assert(p.y == -3.); return p; } // 64-bit PowerPC ELFv1 ABI: // f1 should be in a register // return should be in a hidden sret pointer struct FloatOne float_one(struct FloatOne f1) { assert(f1.x == 7.); return f1; } // 64-bit PowerPC ELFv1 ABI: // i should be in the least-significant bits of a register // return should be in a hidden sret pointer struct IntOdd int_odd(struct IntOdd i) { assert(i.a == 1); assert(i.b == 2); assert(i.c == 3); return i; }
the_stack_data/772304.c
/* ** my_strcpy.c for my_strcpy in /home/arbona/CPool/CPool_Day06 ** ** Made by Thomas Arbona ** Login <[email protected]> ** ** Started on Mon Oct 10 08:13:34 2016 Thomas Arbona ** Last update Wed Oct 12 10:55:24 2016 Thomas Arbona */ char *my_strcpy(char *dest, char *src) { int iterator; iterator = 0; while (src[iterator] != '\0') { dest[iterator] = src[iterator]; iterator += 1; } dest[iterator] = '\0'; return (dest); }
the_stack_data/988195.c
#include <stdio.h> int main() { int t; scanf("%d", &t); while(t!=0){ long long int k, mid; scanf("%lld", &k); mid =k/(long long int)2; if(k%(long long int)2 == 0)printf("%lld\n", mid*mid); else printf("%lld\n", mid*(mid+1)); t--; } return 0; }
the_stack_data/2402.c
#include <stdlib.h> #include <string.h> #include <strings.h> #include <errno.h> char *gettext(const char *msgid) { return (char *) msgid; } char *dgettext(const char *domainname, const char *msgid) { return (char *) msgid; } char *dcgettext(const char *domainname, const char *msgid, int category) { return (char *) msgid; } char *ngettext(const char *msgid1, const char *msgid2, unsigned long int n) { return (char *) ((n == 1) ? msgid1 : msgid2); } char *dngettext(const char *domainname, const char *msgid1, const char *msgid2, unsigned long int n) { return (char *) ((n == 1) ? msgid1 : msgid2); } char *dcngettext(const char *domainname, const char *msgid1, const char *msgid2, unsigned long int n, int category) { return (char *) ((n == 1) ? msgid1 : msgid2); } char *textdomain(const char *domainname) { static const char default_str[] = "messages"; if (domainname && *domainname && strcmp(domainname, default_str)) { errno = EINVAL; return NULL; } return (char *) default_str; } char *bindtextdomain(const char *domainname, const char *dirname) { static const char dir[] = "/"; if (!domainname || !*domainname || (dirname && ((dirname[0] != '/') || dirname[1])) ) { errno = EINVAL; return NULL; } return (char *) dir; } char *bind_textdomain_codeset(const char *domainname, const char *codeset) { if (!domainname || !*domainname || (codeset && strcasecmp(codeset, "UTF-8"))) { errno = EINVAL; } return NULL; }
the_stack_data/193893081.c
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdint.h> #include <errno.h> typedef struct { uint16_t numpolys; uint16_t numverts; /* everything below is unused */ uint16_t bogusrot; uint16_t bogusframe; uint32_t bogusnorm[3]; uint32_t fixscale; uint32_t unused[3]; uint8_t padding[12]; } __attribute__((packed)) dataheader_t; typedef struct { uint16_t vertices[3]; uint8_t type; uint8_t color; /* unused */ uint8_t uv[3][2]; uint8_t texnum; uint8_t flags; /* unused */ } __attribute__((packed)) datapoly_t; uint16_t *polylist = 0; int npolys = 0; uint8_t typeset = 0, unset = 0; void set_flag( datapoly_t *p ) { if ( unset ) p->type &= ~typeset; else p->type |= typeset; } int main( int argc, char **argv ) { FILE *datafile, *ndatafile; if ( argc < 4 ) { fprintf(stderr,"usage: setumeshflag <infile> <outfile>" " [-]<type> <index[-index]> [index[-index] [...]]\n"); return 1; } if ( argv[3][0] == '-' ) { unset = 1; argv[3]++; } sscanf(argv[3],"%hhx",&typeset); // obtain lists for ( int i=4; i<argc; i++ ) { // check for "all" wildcard if ( !strcmp(argv[i],"all") ) { npolys = -1; // means "all" break; } // check for range if ( !strchr(argv[i],'-') ) { npolys++; if ( !polylist ) polylist = malloc(npolys*2); else polylist = realloc(polylist,npolys*2); sscanf(argv[i],"%hu",&polylist[npolys-1]); continue; } uint16_t min, max; sscanf(argv[i],"%hu-%hu",&min,&max); uint16_t num = (max-min)+1; int oldpos = npolys; npolys += num; if ( !polylist ) polylist = malloc(npolys*2); else polylist = realloc(polylist,npolys*2); uint16_t k = min; for ( int j=oldpos; j<npolys; j++ ) polylist[j] = k++; } if ( !(datafile = fopen(argv[1],"rb")) ) { fprintf(stderr,"Couldn't open input: %s\n",strerror(errno)); return 2; } dataheader_t dhead; fread(&dhead,sizeof(dataheader_t),1,datafile); if ( feof(datafile) ) { fprintf(stderr,"--Premature end of file reached at %lu--\n", ftell(datafile)); fclose(datafile); return 8; } datapoly_t *dpoly = calloc(dhead.numpolys,sizeof(datapoly_t)); fread(dpoly,sizeof(datapoly_t),dhead.numpolys,datafile); if ( feof(datafile) ) { fprintf(stderr,"--Premature end of file reached at %lu--\n", ftell(datafile)); fclose(datafile); free(dpoly); return 8; } fclose(datafile); if ( npolys == -1 ) { for ( int i=0; i<dhead.numpolys; i++ ) { printf("Processing poly %d\n",i); set_flag(&dpoly[i]); } } else { for ( int i=0; i<npolys; i++ ) { printf("Processing poly %d\n",polylist[i]); set_flag(&dpoly[polylist[i]]); } } if ( !(ndatafile = fopen(argv[2],"wb")) ) { fprintf(stderr,"Couldn't open output: %s\n",strerror(errno)); free(dpoly); return 4; } fwrite(&dhead,sizeof(dataheader_t),1,ndatafile); fwrite(dpoly,sizeof(datapoly_t),dhead.numpolys,ndatafile); fclose(ndatafile); free(dpoly); return 0; }
the_stack_data/29825157.c
/*===-- X86DisassemblerDecoder.c - Disassembler decoder ------------*- C -*-===* * * The LLVM Compiler Infrastructure * * This file is distributed under the University of Illinois Open Source * License. See LICENSE.TXT for details. * *===----------------------------------------------------------------------===* * * This file is part of the X86 Disassembler. * It contains the implementation of the instruction decoder. * Documentation for the disassembler can be found in X86Disassembler.h. * *===----------------------------------------------------------------------===*/ /* Capstone Disassembly Engine */ /* By Nguyen Anh Quynh <[email protected]>, 2013-2015 */ #ifdef CAPSTONE_HAS_X86 #include <stdarg.h> /* for va_*() */ #if defined(CAPSTONE_HAS_OSXKERNEL) #include <libkern/libkern.h> #else #include <stdlib.h> /* for exit() */ #endif #include "../../cs_priv.h" #include "../../utils.h" #include "X86DisassemblerDecoder.h" /// Specifies whether a ModR/M byte is needed and (if so) which /// instruction each possible value of the ModR/M byte corresponds to. Once /// this information is known, we have narrowed down to a single instruction. struct ModRMDecision { uint8_t modrm_type; uint16_t instructionIDs; }; /// Specifies which set of ModR/M->instruction tables to look at /// given a particular opcode. struct OpcodeDecision { struct ModRMDecision modRMDecisions[256]; }; /// Specifies which opcode->instruction tables to look at given /// a particular context (set of attributes). Since there are many possible /// contexts, the decoder first uses CONTEXTS_SYM to determine which context /// applies given a specific set of attributes. Hence there are only IC_max /// entries in this table, rather than 2^(ATTR_max). struct ContextDecision { struct OpcodeDecision opcodeDecisions[IC_max]; }; #ifdef CAPSTONE_X86_REDUCE #include "X86GenDisassemblerTables_reduce.inc" #else #include "X86GenDisassemblerTables.inc" #endif //#define GET_INSTRINFO_ENUM #define GET_INSTRINFO_MC_DESC #ifdef CAPSTONE_X86_REDUCE #include "X86GenInstrInfo_reduce.inc" #else #include "X86GenInstrInfo.inc" #endif /* * contextForAttrs - Client for the instruction context table. Takes a set of * attributes and returns the appropriate decode context. * * @param attrMask - Attributes, from the enumeration attributeBits. * @return - The InstructionContext to use when looking up an * an instruction with these attributes. */ static InstructionContext contextForAttrs(uint16_t attrMask) { return CONTEXTS_SYM[attrMask]; } /* * modRMRequired - Reads the appropriate instruction table to determine whether * the ModR/M byte is required to decode a particular instruction. * * @param type - The opcode type (i.e., how many bytes it has). * @param insnContext - The context for the instruction, as returned by * contextForAttrs. * @param opcode - The last byte of the instruction's opcode, not counting * ModR/M extensions and escapes. * @return - true if the ModR/M byte is required, false otherwise. */ static int modRMRequired(OpcodeType type, InstructionContext insnContext, uint16_t opcode) { const struct OpcodeDecision *decision = NULL; const uint8_t *indextable = NULL; uint8_t index; switch (type) { default: case ONEBYTE: decision = ONEBYTE_SYM; indextable = index_x86DisassemblerOneByteOpcodes; break; case TWOBYTE: decision = TWOBYTE_SYM; indextable = index_x86DisassemblerTwoByteOpcodes; break; case THREEBYTE_38: decision = THREEBYTE38_SYM; indextable = index_x86DisassemblerThreeByte38Opcodes; break; case THREEBYTE_3A: decision = THREEBYTE3A_SYM; indextable = index_x86DisassemblerThreeByte3AOpcodes; break; #ifndef CAPSTONE_X86_REDUCE case XOP8_MAP: decision = XOP8_MAP_SYM; indextable = index_x86DisassemblerXOP8Opcodes; break; case XOP9_MAP: decision = XOP9_MAP_SYM; indextable = index_x86DisassemblerXOP9Opcodes; break; case XOPA_MAP: decision = XOPA_MAP_SYM; indextable = index_x86DisassemblerXOPAOpcodes; break; case T3DNOW_MAP: // 3DNow instructions always have ModRM byte return true; #endif } index = indextable[insnContext]; if (index) return decision[index - 1].modRMDecisions[opcode].modrm_type != MODRM_ONEENTRY; else return false; } // Hacky for FEMMS, RDPKRU, WRPKRU #define GET_INSTRINFO_ENUM #ifndef CAPSTONE_X86_REDUCE #include "X86GenInstrInfo.inc" #else #include "X86GenInstrInfo_reduce.inc" #endif /* * decode - Reads the appropriate instruction table to obtain the unique ID of * an instruction. * * @param type - See modRMRequired(). * @param insnContext - See modRMRequired(). * @param opcode - See modRMRequired(). * @param modRM - The ModR/M byte if required, or any value if not. * @return - The UID of the instruction, or 0 on failure. */ static InstrUID decode(OpcodeType type, InstructionContext insnContext, uint8_t opcode, uint8_t modRM) { const struct ModRMDecision *dec = NULL; const uint8_t *indextable = NULL; uint8_t index; #if 1 //printf("inside decode with type=%d (TWOBYTE=%d), opcode=%x, modRM=%x\n", type, TWOBYTE, opcode, modRM); if(type == TWOBYTE && opcode == 0x01 && modRM == 0xee) { return X86_RDPKRU; } else if(type == TWOBYTE && opcode == 0x01 && modRM == 0xef) { return X86_WRPKRU; } else if(type == TWOBYTE && opcode == 0x01 && modRM == 0xfa) { return X86_MONITORrrr; // MONITORX } else if(type == TWOBYTE && opcode == 0x01 && modRM == 0xfb) { return X86_MWAITrr; // MWAITX } #endif switch (type) { default: case ONEBYTE: indextable = index_x86DisassemblerOneByteOpcodes; index = indextable[insnContext]; if (index) dec = &ONEBYTE_SYM[index - 1].modRMDecisions[opcode]; else dec = &emptyTable.modRMDecisions[opcode]; break; case TWOBYTE: indextable = index_x86DisassemblerTwoByteOpcodes; index = indextable[insnContext]; if (index) dec = &TWOBYTE_SYM[index - 1].modRMDecisions[opcode]; else dec = &emptyTable.modRMDecisions[opcode]; break; case THREEBYTE_38: indextable = index_x86DisassemblerThreeByte38Opcodes; index = indextable[insnContext]; if (index) dec = &THREEBYTE38_SYM[index - 1].modRMDecisions[opcode]; else dec = &emptyTable.modRMDecisions[opcode]; break; case THREEBYTE_3A: indextable = index_x86DisassemblerThreeByte3AOpcodes; index = indextable[insnContext]; if (index) dec = &THREEBYTE3A_SYM[index - 1].modRMDecisions[opcode]; else dec = &emptyTable.modRMDecisions[opcode]; break; #ifndef CAPSTONE_X86_REDUCE case XOP8_MAP: indextable = index_x86DisassemblerXOP8Opcodes; index = indextable[insnContext]; if (index) dec = &XOP8_MAP_SYM[index - 1].modRMDecisions[opcode]; else dec = &emptyTable.modRMDecisions[opcode]; break; case XOP9_MAP: indextable = index_x86DisassemblerXOP9Opcodes; index = indextable[insnContext]; if (index) dec = &XOP9_MAP_SYM[index - 1].modRMDecisions[opcode]; else dec = &emptyTable.modRMDecisions[opcode]; break; case XOPA_MAP: indextable = index_x86DisassemblerXOPAOpcodes; index = indextable[insnContext]; if (index) dec = &XOPA_MAP_SYM[index - 1].modRMDecisions[opcode]; else dec = &emptyTable.modRMDecisions[opcode]; break; case T3DNOW_MAP: indextable = index_x86DisassemblerT3DNOWOpcodes; index = indextable[insnContext]; if (index) dec = &T3DNOW_MAP_SYM[index - 1].modRMDecisions[opcode]; else dec = &emptyTable.modRMDecisions[opcode]; break; #endif } switch (dec->modrm_type) { default: //debug("Corrupt table! Unknown modrm_type"); return 0; case MODRM_ONEENTRY: return modRMTable[dec->instructionIDs]; case MODRM_SPLITRM: if (modFromModRM(modRM) == 0x3) return modRMTable[dec->instructionIDs+1]; return modRMTable[dec->instructionIDs]; case MODRM_SPLITREG: if (modFromModRM(modRM) == 0x3) return modRMTable[dec->instructionIDs+((modRM & 0x38) >> 3)+8]; return modRMTable[dec->instructionIDs+((modRM & 0x38) >> 3)]; case MODRM_SPLITMISC: if (modFromModRM(modRM) == 0x3) return modRMTable[dec->instructionIDs+(modRM & 0x3f)+8]; return modRMTable[dec->instructionIDs+((modRM & 0x38) >> 3)]; case MODRM_FULL: return modRMTable[dec->instructionIDs+modRM]; } } /* * specifierForUID - Given a UID, returns the name and operand specification for * that instruction. * * @param uid - The unique ID for the instruction. This should be returned by * decode(); specifierForUID will not check bounds. * @return - A pointer to the specification for that instruction. */ static const struct InstructionSpecifier *specifierForUID(InstrUID uid) { return &INSTRUCTIONS_SYM[uid]; } /* * consumeByte - Uses the reader function provided by the user to consume one * byte from the instruction's memory and advance the cursor. * * @param insn - The instruction with the reader function to use. The cursor * for this instruction is advanced. * @param byte - A pointer to a pre-allocated memory buffer to be populated * with the data read. * @return - 0 if the read was successful; nonzero otherwise. */ static int consumeByte(struct InternalInstruction *insn, uint8_t *byte) { int ret = insn->reader(insn->readerArg, byte, insn->readerCursor); if (!ret) ++(insn->readerCursor); return ret; } /* * lookAtByte - Like consumeByte, but does not advance the cursor. * * @param insn - See consumeByte(). * @param byte - See consumeByte(). * @return - See consumeByte(). */ static int lookAtByte(struct InternalInstruction *insn, uint8_t *byte) { return insn->reader(insn->readerArg, byte, insn->readerCursor); } static void unconsumeByte(struct InternalInstruction *insn) { insn->readerCursor--; } #define CONSUME_FUNC(name, type) \ static int name(struct InternalInstruction *insn, type *ptr) { \ type combined = 0; \ unsigned offset; \ for (offset = 0; offset < sizeof(type); ++offset) { \ uint8_t byte; \ int ret = insn->reader(insn->readerArg, \ &byte, \ insn->readerCursor + offset); \ if (ret) \ return ret; \ combined = combined | (type)((uint64_t)byte << (offset * 8)); \ } \ *ptr = combined; \ insn->readerCursor += sizeof(type); \ return 0; \ } /* * consume* - Use the reader function provided by the user to consume data * values of various sizes from the instruction's memory and advance the * cursor appropriately. These readers perform endian conversion. * * @param insn - See consumeByte(). * @param ptr - A pointer to a pre-allocated memory of appropriate size to * be populated with the data read. * @return - See consumeByte(). */ CONSUME_FUNC(consumeInt8, int8_t) CONSUME_FUNC(consumeInt16, int16_t) CONSUME_FUNC(consumeInt32, int32_t) CONSUME_FUNC(consumeUInt16, uint16_t) CONSUME_FUNC(consumeUInt32, uint32_t) CONSUME_FUNC(consumeUInt64, uint64_t) /* * setPrefixPresent - Marks that a particular prefix is present at a particular * location. * * @param insn - The instruction to be marked as having the prefix. * @param prefix - The prefix that is present. * @param location - The location where the prefix is located (in the address * space of the instruction's reader). */ static void setPrefixPresent(struct InternalInstruction *insn, uint8_t prefix, uint64_t location) { switch (prefix) { case 0x26: insn->isPrefix26 = true; insn->prefix26 = location; break; case 0x2e: insn->isPrefix2e = true; insn->prefix2e = location; break; case 0x36: insn->isPrefix36 = true; insn->prefix36 = location; break; case 0x3e: insn->isPrefix3e = true; insn->prefix3e = location; break; case 0x64: insn->isPrefix64 = true; insn->prefix64 = location; break; case 0x65: insn->isPrefix65 = true; insn->prefix65 = location; break; case 0x66: insn->isPrefix66 = true; insn->prefix66 = location; break; case 0x67: insn->isPrefix67 = true; insn->prefix67 = location; break; case 0xf0: insn->isPrefixf0 = true; insn->prefixf0 = location; break; case 0xf2: insn->isPrefixf2 = true; insn->prefixf2 = location; break; case 0xf3: insn->isPrefixf3 = true; insn->prefixf3 = location; break; default: break; } } /* * isPrefixAtLocation - Queries an instruction to determine whether a prefix is * present at a given location. * * @param insn - The instruction to be queried. * @param prefix - The prefix. * @param location - The location to query. * @return - Whether the prefix is at that location. */ static bool isPrefixAtLocation(struct InternalInstruction *insn, uint8_t prefix, uint64_t location) { switch (prefix) { case 0x26: if (insn->isPrefix26 && insn->prefix26 == location) return true; break; case 0x2e: if (insn->isPrefix2e && insn->prefix2e == location) return true; break; case 0x36: if (insn->isPrefix36 && insn->prefix36 == location) return true; break; case 0x3e: if (insn->isPrefix3e && insn->prefix3e == location) return true; break; case 0x64: if (insn->isPrefix64 && insn->prefix64 == location) return true; break; case 0x65: if (insn->isPrefix65 && insn->prefix65 == location) return true; break; case 0x66: if (insn->isPrefix66 && insn->prefix66 == location) return true; break; case 0x67: if (insn->isPrefix67 && insn->prefix67 == location) return true; break; case 0xf0: if (insn->isPrefixf0 && insn->prefixf0 == location) return true; break; case 0xf2: if (insn->isPrefixf2 && insn->prefixf2 == location) return true; break; case 0xf3: if (insn->isPrefixf3 && insn->prefixf3 == location) return true; break; default: break; } return false; } /* * readPrefixes - Consumes all of an instruction's prefix bytes, and marks the * instruction as having them. Also sets the instruction's default operand, * address, and other relevant data sizes to report operands correctly. * * @param insn - The instruction whose prefixes are to be read. * @return - 0 if the instruction could be read until the end of the prefix * bytes, and no prefixes conflicted; nonzero otherwise. */ static int readPrefixes(struct InternalInstruction *insn) { bool isPrefix = true; uint64_t prefixLocation; uint8_t byte = 0, nextByte; bool hasAdSize = false; bool hasOpSize = false; while (isPrefix) { if (insn->mode == MODE_64BIT) { // eliminate consecutive redundant REX bytes in front if (consumeByte(insn, &byte)) return -1; if ((byte & 0xf0) == 0x40) { while(true) { if (lookAtByte(insn, &byte)) // out of input code return -1; if ((byte & 0xf0) == 0x40) { // another REX prefix, but we only remember the last one if (consumeByte(insn, &byte)) return -1; } else break; } // recover the last REX byte if next byte is not a legacy prefix switch (byte) { case 0xf2: /* REPNE/REPNZ */ case 0xf3: /* REP or REPE/REPZ */ case 0xf0: /* LOCK */ case 0x2e: /* CS segment override -OR- Branch not taken */ case 0x36: /* SS segment override -OR- Branch taken */ case 0x3e: /* DS segment override */ case 0x26: /* ES segment override */ case 0x64: /* FS segment override */ case 0x65: /* GS segment override */ case 0x66: /* Operand-size override */ case 0x67: /* Address-size override */ break; default: /* Not a prefix byte */ unconsumeByte(insn); break; } } else { unconsumeByte(insn); } } prefixLocation = insn->readerCursor; /* If we fail reading prefixes, just stop here and let the opcode reader deal with it */ if (consumeByte(insn, &byte)) return -1; if (insn->readerCursor - 1 == insn->startLocation && (byte == 0xf2 || byte == 0xf3)) { if (lookAtByte(insn, &nextByte)) return -1; /* * If the byte is 0xf2 or 0xf3, and any of the following conditions are * met: * - it is followed by a LOCK (0xf0) prefix * - it is followed by an xchg instruction * then it should be disassembled as a xacquire/xrelease not repne/rep. */ if ((byte == 0xf2 || byte == 0xf3) && ((nextByte == 0xf0) | ((nextByte & 0xfe) == 0x86 || (nextByte & 0xf8) == 0x90))) insn->xAcquireRelease = true; /* * Also if the byte is 0xf3, and the following condition is met: * - it is followed by a "mov mem, reg" (opcode 0x88/0x89) or * "mov mem, imm" (opcode 0xc6/0xc7) instructions. * then it should be disassembled as an xrelease not rep. */ if (byte == 0xf3 && (nextByte == 0x88 || nextByte == 0x89 || nextByte == 0xc6 || nextByte == 0xc7)) insn->xAcquireRelease = true; if (insn->mode == MODE_64BIT && (nextByte & 0xf0) == 0x40) { if (consumeByte(insn, &nextByte)) return -1; if (lookAtByte(insn, &nextByte)) return -1; unconsumeByte(insn); } } switch (byte) { case 0xf2: /* REPNE/REPNZ */ case 0xf3: /* REP or REPE/REPZ */ case 0xf0: /* LOCK */ // only accept the last prefix insn->isPrefixf2 = false; insn->isPrefixf3 = false; insn->isPrefixf0 = false; setPrefixPresent(insn, byte, prefixLocation); insn->prefix0 = byte; break; case 0x2e: /* CS segment override -OR- Branch not taken */ insn->segmentOverride = SEG_OVERRIDE_CS; // only accept the last prefix insn->isPrefix2e = false; insn->isPrefix36 = false; insn->isPrefix3e = false; insn->isPrefix26 = false; insn->isPrefix64 = false; insn->isPrefix65 = false; setPrefixPresent(insn, byte, prefixLocation); insn->prefix1 = byte; break; case 0x36: /* SS segment override -OR- Branch taken */ insn->segmentOverride = SEG_OVERRIDE_SS; // only accept the last prefix insn->isPrefix2e = false; insn->isPrefix36 = false; insn->isPrefix3e = false; insn->isPrefix26 = false; insn->isPrefix64 = false; insn->isPrefix65 = false; setPrefixPresent(insn, byte, prefixLocation); insn->prefix1 = byte; break; case 0x3e: /* DS segment override */ insn->segmentOverride = SEG_OVERRIDE_DS; // only accept the last prefix insn->isPrefix2e = false; insn->isPrefix36 = false; insn->isPrefix3e = false; insn->isPrefix26 = false; insn->isPrefix64 = false; insn->isPrefix65 = false; setPrefixPresent(insn, byte, prefixLocation); insn->prefix1 = byte; break; case 0x26: /* ES segment override */ insn->segmentOverride = SEG_OVERRIDE_ES; // only accept the last prefix insn->isPrefix2e = false; insn->isPrefix36 = false; insn->isPrefix3e = false; insn->isPrefix26 = false; insn->isPrefix64 = false; insn->isPrefix65 = false; setPrefixPresent(insn, byte, prefixLocation); insn->prefix1 = byte; break; case 0x64: /* FS segment override */ insn->segmentOverride = SEG_OVERRIDE_FS; // only accept the last prefix insn->isPrefix2e = false; insn->isPrefix36 = false; insn->isPrefix3e = false; insn->isPrefix26 = false; insn->isPrefix64 = false; insn->isPrefix65 = false; setPrefixPresent(insn, byte, prefixLocation); insn->prefix1 = byte; break; case 0x65: /* GS segment override */ insn->segmentOverride = SEG_OVERRIDE_GS; // only accept the last prefix insn->isPrefix2e = false; insn->isPrefix36 = false; insn->isPrefix3e = false; insn->isPrefix26 = false; insn->isPrefix64 = false; insn->isPrefix65 = false; setPrefixPresent(insn, byte, prefixLocation); insn->prefix1 = byte; break; case 0x66: /* Operand-size override */ hasOpSize = true; setPrefixPresent(insn, byte, prefixLocation); insn->prefix2 = byte; break; case 0x67: /* Address-size override */ hasAdSize = true; setPrefixPresent(insn, byte, prefixLocation); insn->prefix3 = byte; break; default: /* Not a prefix byte */ isPrefix = false; break; } //if (isPrefix) // dbgprintf(insn, "Found prefix 0x%hhx", byte); } insn->vectorExtensionType = TYPE_NO_VEX_XOP; if (byte == 0x62) { uint8_t byte1, byte2; if (consumeByte(insn, &byte1)) { //dbgprintf(insn, "Couldn't read second byte of EVEX prefix"); return -1; } if ((insn->mode == MODE_64BIT || (byte1 & 0xc0) == 0xc0) && ((~byte1 & 0xc) == 0xc)) { if (lookAtByte(insn, &byte2)) { //dbgprintf(insn, "Couldn't read third byte of EVEX prefix"); return -1; } if ((byte2 & 0x4) == 0x4) { insn->vectorExtensionType = TYPE_EVEX; } else { unconsumeByte(insn); /* unconsume byte1 */ unconsumeByte(insn); /* unconsume byte */ insn->necessaryPrefixLocation = insn->readerCursor - 2; } if (insn->vectorExtensionType == TYPE_EVEX) { insn->vectorExtensionPrefix[0] = byte; insn->vectorExtensionPrefix[1] = byte1; if (consumeByte(insn, &insn->vectorExtensionPrefix[2])) { //dbgprintf(insn, "Couldn't read third byte of EVEX prefix"); return -1; } if (consumeByte(insn, &insn->vectorExtensionPrefix[3])) { //dbgprintf(insn, "Couldn't read fourth byte of EVEX prefix"); return -1; } /* We simulate the REX prefix for simplicity's sake */ if (insn->mode == MODE_64BIT) { insn->rexPrefix = 0x40 | (wFromEVEX3of4(insn->vectorExtensionPrefix[2]) << 3) | (rFromEVEX2of4(insn->vectorExtensionPrefix[1]) << 2) | (xFromEVEX2of4(insn->vectorExtensionPrefix[1]) << 1) | (bFromEVEX2of4(insn->vectorExtensionPrefix[1]) << 0); } switch (ppFromEVEX3of4(insn->vectorExtensionPrefix[2])) { default: break; case VEX_PREFIX_66: hasOpSize = true; break; } //dbgprintf(insn, "Found EVEX prefix 0x%hhx 0x%hhx 0x%hhx 0x%hhx", // insn->vectorExtensionPrefix[0], insn->vectorExtensionPrefix[1], // insn->vectorExtensionPrefix[2], insn->vectorExtensionPrefix[3]); } } else { // BOUND instruction unconsumeByte(insn); /* unconsume byte1 */ unconsumeByte(insn); /* unconsume byte */ } } else if (byte == 0xc4) { uint8_t byte1; if (lookAtByte(insn, &byte1)) { //dbgprintf(insn, "Couldn't read second byte of VEX"); return -1; } if (insn->mode == MODE_64BIT || (byte1 & 0xc0) == 0xc0) { insn->vectorExtensionType = TYPE_VEX_3B; insn->necessaryPrefixLocation = insn->readerCursor - 1; } else { unconsumeByte(insn); insn->necessaryPrefixLocation = insn->readerCursor - 1; } if (insn->vectorExtensionType == TYPE_VEX_3B) { insn->vectorExtensionPrefix[0] = byte; if (consumeByte(insn, &insn->vectorExtensionPrefix[1])) return -1; if (consumeByte(insn, &insn->vectorExtensionPrefix[2])) return -1; /* We simulate the REX prefix for simplicity's sake */ if (insn->mode == MODE_64BIT) { insn->rexPrefix = 0x40 | (wFromVEX3of3(insn->vectorExtensionPrefix[2]) << 3) | (rFromVEX2of3(insn->vectorExtensionPrefix[1]) << 2) | (xFromVEX2of3(insn->vectorExtensionPrefix[1]) << 1) | (bFromVEX2of3(insn->vectorExtensionPrefix[1]) << 0); } switch (ppFromVEX3of3(insn->vectorExtensionPrefix[2])) { default: break; case VEX_PREFIX_66: hasOpSize = true; break; } } } else if (byte == 0xc5) { uint8_t byte1; if (lookAtByte(insn, &byte1)) { //dbgprintf(insn, "Couldn't read second byte of VEX"); return -1; } if (insn->mode == MODE_64BIT || (byte1 & 0xc0) == 0xc0) { insn->vectorExtensionType = TYPE_VEX_2B; } else { unconsumeByte(insn); } if (insn->vectorExtensionType == TYPE_VEX_2B) { insn->vectorExtensionPrefix[0] = byte; if (consumeByte(insn, &insn->vectorExtensionPrefix[1])) return -1; if (insn->mode == MODE_64BIT) { insn->rexPrefix = 0x40 | (rFromVEX2of2(insn->vectorExtensionPrefix[1]) << 2); } switch (ppFromVEX2of2(insn->vectorExtensionPrefix[1])) { default: break; case VEX_PREFIX_66: hasOpSize = true; break; } } } else if (byte == 0x8f) { uint8_t byte1; if (lookAtByte(insn, &byte1)) { // dbgprintf(insn, "Couldn't read second byte of XOP"); return -1; } if ((byte1 & 0x38) != 0x0) { /* 0 in these 3 bits is a POP instruction. */ insn->vectorExtensionType = TYPE_XOP; insn->necessaryPrefixLocation = insn->readerCursor - 1; } else { unconsumeByte(insn); insn->necessaryPrefixLocation = insn->readerCursor - 1; } if (insn->vectorExtensionType == TYPE_XOP) { insn->vectorExtensionPrefix[0] = byte; if (consumeByte(insn, &insn->vectorExtensionPrefix[1])) return -1; if (consumeByte(insn, &insn->vectorExtensionPrefix[2])) return -1; /* We simulate the REX prefix for simplicity's sake */ if (insn->mode == MODE_64BIT) { insn->rexPrefix = 0x40 | (wFromXOP3of3(insn->vectorExtensionPrefix[2]) << 3) | (rFromXOP2of3(insn->vectorExtensionPrefix[1]) << 2) | (xFromXOP2of3(insn->vectorExtensionPrefix[1]) << 1) | (bFromXOP2of3(insn->vectorExtensionPrefix[1]) << 0); } switch (ppFromXOP3of3(insn->vectorExtensionPrefix[2])) { default: break; case VEX_PREFIX_66: hasOpSize = true; break; } } } else { if (insn->mode == MODE_64BIT) { if ((byte & 0xf0) == 0x40) { uint8_t opcodeByte; while(true) { if (lookAtByte(insn, &opcodeByte)) // out of input code return -1; if ((opcodeByte & 0xf0) == 0x40) { // another REX prefix, but we only remember the last one if (consumeByte(insn, &byte)) return -1; } else break; } insn->rexPrefix = byte; insn->necessaryPrefixLocation = insn->readerCursor - 2; // dbgprintf(insn, "Found REX prefix 0x%hhx", byte); } else { unconsumeByte(insn); insn->necessaryPrefixLocation = insn->readerCursor - 1; } } else { unconsumeByte(insn); insn->necessaryPrefixLocation = insn->readerCursor - 1; } } if (insn->mode == MODE_16BIT) { insn->registerSize = (hasOpSize ? 4 : 2); insn->addressSize = (hasAdSize ? 4 : 2); insn->displacementSize = (hasAdSize ? 4 : 2); insn->immediateSize = (hasOpSize ? 4 : 2); insn->immSize = (hasOpSize ? 4 : 2); } else if (insn->mode == MODE_32BIT) { insn->registerSize = (hasOpSize ? 2 : 4); insn->addressSize = (hasAdSize ? 2 : 4); insn->displacementSize = (hasAdSize ? 2 : 4); insn->immediateSize = (hasOpSize ? 2 : 4); insn->immSize = (hasOpSize ? 2 : 4); } else if (insn->mode == MODE_64BIT) { if (insn->rexPrefix && wFromREX(insn->rexPrefix)) { insn->registerSize = 8; insn->addressSize = (hasAdSize ? 4 : 8); insn->displacementSize = 4; insn->immediateSize = 4; insn->immSize = 4; } else if (insn->rexPrefix) { insn->registerSize = (hasOpSize ? 2 : 4); insn->addressSize = (hasAdSize ? 4 : 8); insn->displacementSize = (hasOpSize ? 2 : 4); insn->immediateSize = (hasOpSize ? 2 : 4); insn->immSize = (hasOpSize ? 2 : 4); } else { insn->registerSize = (hasOpSize ? 2 : 4); insn->addressSize = (hasAdSize ? 4 : 8); insn->displacementSize = (hasOpSize ? 2 : 4); insn->immediateSize = (hasOpSize ? 2 : 4); insn->immSize = (hasOpSize ? 4 : 8); } } return 0; } static int readModRM(struct InternalInstruction *insn); /* * readOpcode - Reads the opcode (excepting the ModR/M byte in the case of * extended or escape opcodes). * * @param insn - The instruction whose opcode is to be read. * @return - 0 if the opcode could be read successfully; nonzero otherwise. */ static int readOpcode(struct InternalInstruction *insn) { /* Determine the length of the primary opcode */ uint8_t current; // printf(">>> readOpcode() = %x\n", insn->readerCursor); insn->opcodeType = ONEBYTE; insn->firstByte = 0x00; if (insn->vectorExtensionType == TYPE_EVEX) { switch (mmFromEVEX2of4(insn->vectorExtensionPrefix[1])) { default: // dbgprintf(insn, "Unhandled mm field for instruction (0x%hhx)", // mmFromEVEX2of4(insn->vectorExtensionPrefix[1])); return -1; case VEX_LOB_0F: insn->opcodeType = TWOBYTE; return consumeByte(insn, &insn->opcode); case VEX_LOB_0F38: insn->opcodeType = THREEBYTE_38; return consumeByte(insn, &insn->opcode); case VEX_LOB_0F3A: insn->opcodeType = THREEBYTE_3A; return consumeByte(insn, &insn->opcode); } } else if (insn->vectorExtensionType == TYPE_VEX_3B) { switch (mmmmmFromVEX2of3(insn->vectorExtensionPrefix[1])) { default: // dbgprintf(insn, "Unhandled m-mmmm field for instruction (0x%hhx)", // mmmmmFromVEX2of3(insn->vectorExtensionPrefix[1])); return -1; case VEX_LOB_0F: insn->twoByteEscape = 0x0f; insn->opcodeType = TWOBYTE; return consumeByte(insn, &insn->opcode); case VEX_LOB_0F38: insn->twoByteEscape = 0x0f; insn->threeByteEscape = 0x38; insn->opcodeType = THREEBYTE_38; return consumeByte(insn, &insn->opcode); case VEX_LOB_0F3A: insn->twoByteEscape = 0x0f; insn->threeByteEscape = 0x3a; insn->opcodeType = THREEBYTE_3A; return consumeByte(insn, &insn->opcode); } } else if (insn->vectorExtensionType == TYPE_VEX_2B) { insn->twoByteEscape = 0x0f; insn->opcodeType = TWOBYTE; return consumeByte(insn, &insn->opcode); } else if (insn->vectorExtensionType == TYPE_XOP) { switch (mmmmmFromXOP2of3(insn->vectorExtensionPrefix[1])) { default: // dbgprintf(insn, "Unhandled m-mmmm field for instruction (0x%hhx)", // mmmmmFromVEX2of3(insn->vectorExtensionPrefix[1])); return -1; case XOP_MAP_SELECT_8: // FIXME: twoByteEscape? insn->opcodeType = XOP8_MAP; return consumeByte(insn, &insn->opcode); case XOP_MAP_SELECT_9: // FIXME: twoByteEscape? insn->opcodeType = XOP9_MAP; return consumeByte(insn, &insn->opcode); case XOP_MAP_SELECT_A: // FIXME: twoByteEscape? insn->opcodeType = XOPA_MAP; return consumeByte(insn, &insn->opcode); } } if (consumeByte(insn, &current)) return -1; // save this first byte for MOVcr, MOVdr, MOVrc, MOVrd insn->firstByte = current; if (current == 0x0f) { // dbgprintf(insn, "Found a two-byte escape prefix (0x%hhx)", current); insn->twoByteEscape = current; if (consumeByte(insn, &current)) return -1; if (current == 0x38) { // dbgprintf(insn, "Found a three-byte escape prefix (0x%hhx)", current); insn->threeByteEscape = current; if (consumeByte(insn, &current)) return -1; insn->opcodeType = THREEBYTE_38; } else if (current == 0x3a) { // dbgprintf(insn, "Found a three-byte escape prefix (0x%hhx)", current); insn->threeByteEscape = current; if (consumeByte(insn, &current)) return -1; insn->opcodeType = THREEBYTE_3A; } else { #ifndef CAPSTONE_X86_REDUCE switch(current) { default: // dbgprintf(insn, "Didn't find a three-byte escape prefix"); insn->opcodeType = TWOBYTE; break; case 0x0e: // HACK for femms. to be handled properly in next version 3.x insn->opcodeType = T3DNOW_MAP; // this encode does not have ModRM insn->consumedModRM = true; break; case 0x0f: // 3DNow instruction has weird format: ModRM/SIB/displacement + opcode if (readModRM(insn)) return -1; // next is 3DNow opcode if (consumeByte(insn, &current)) return -1; insn->opcodeType = T3DNOW_MAP; break; } #endif } } /* * At this point we have consumed the full opcode. * Anything we consume from here on must be unconsumed. */ insn->opcode = current; return 0; } /* * getIDWithAttrMask - Determines the ID of an instruction, consuming * the ModR/M byte as appropriate for extended and escape opcodes, * and using a supplied attribute mask. * * @param instructionID - A pointer whose target is filled in with the ID of the * instruction. * @param insn - The instruction whose ID is to be determined. * @param attrMask - The attribute mask to search. * @return - 0 if the ModR/M could be read when needed or was not * needed; nonzero otherwise. */ static int getIDWithAttrMask(uint16_t *instructionID, struct InternalInstruction *insn, uint16_t attrMask) { bool hasModRMExtension; InstructionContext instructionClass; #ifndef CAPSTONE_X86_REDUCE // HACK for femms. to be handled properly in next version 3.x if (insn->opcode == 0x0e && insn->opcodeType == T3DNOW_MAP) { *instructionID = X86_FEMMS; return 0; } #endif if (insn->opcodeType == T3DNOW_MAP) instructionClass = IC_OF; else instructionClass = contextForAttrs(attrMask); hasModRMExtension = modRMRequired(insn->opcodeType, instructionClass, insn->opcode) != 0; if (hasModRMExtension) { if (readModRM(insn)) return -1; *instructionID = decode(insn->opcodeType, instructionClass, insn->opcode, insn->modRM); } else { *instructionID = decode(insn->opcodeType, instructionClass, insn->opcode, 0); } return 0; } /* * is16BitEquivalent - Determines whether two instruction names refer to * equivalent instructions but one is 16-bit whereas the other is not. * * @param orig - The instruction ID that is not 16-bit * @param equiv - The instruction ID that is 16-bit */ static bool is16BitEquivalent(unsigned orig, unsigned equiv) { size_t i; uint16_t idx; if ((idx = x86_16_bit_eq_lookup[orig]) != 0) { for (i = idx - 1; i < ARR_SIZE(x86_16_bit_eq_tbl) && x86_16_bit_eq_tbl[i].first == orig; i++) { if (x86_16_bit_eq_tbl[i].second == equiv) return true; } } return false; } /* * is64Bit - Determines whether this instruction is a 64-bit instruction. * * @param name - The instruction that is not 16-bit */ static bool is64Bit(uint16_t id) { return is_64bit_insn[id]; } /* * getID - Determines the ID of an instruction, consuming the ModR/M byte as * appropriate for extended and escape opcodes. Determines the attributes and * context for the instruction before doing so. * * @param insn - The instruction whose ID is to be determined. * @return - 0 if the ModR/M could be read when needed or was not needed; * nonzero otherwise. */ static int getID(struct InternalInstruction *insn) { uint16_t attrMask; uint16_t instructionID; // printf(">>> getID()\n"); attrMask = ATTR_NONE; if (insn->mode == MODE_64BIT) attrMask |= ATTR_64BIT; if (insn->vectorExtensionType != TYPE_NO_VEX_XOP) { attrMask |= (insn->vectorExtensionType == TYPE_EVEX) ? ATTR_EVEX : ATTR_VEX; if (insn->vectorExtensionType == TYPE_EVEX) { switch (ppFromEVEX3of4(insn->vectorExtensionPrefix[2])) { case VEX_PREFIX_66: attrMask |= ATTR_OPSIZE; break; case VEX_PREFIX_F3: attrMask |= ATTR_XS; break; case VEX_PREFIX_F2: attrMask |= ATTR_XD; break; } if (zFromEVEX4of4(insn->vectorExtensionPrefix[3])) attrMask |= ATTR_EVEXKZ; if (bFromEVEX4of4(insn->vectorExtensionPrefix[3])) attrMask |= ATTR_EVEXB; if (aaaFromEVEX4of4(insn->vectorExtensionPrefix[3])) attrMask |= ATTR_EVEXK; if (lFromEVEX4of4(insn->vectorExtensionPrefix[3])) attrMask |= ATTR_EVEXL; if (l2FromEVEX4of4(insn->vectorExtensionPrefix[3])) attrMask |= ATTR_EVEXL2; } else if (insn->vectorExtensionType == TYPE_VEX_3B) { switch (ppFromVEX3of3(insn->vectorExtensionPrefix[2])) { case VEX_PREFIX_66: attrMask |= ATTR_OPSIZE; break; case VEX_PREFIX_F3: attrMask |= ATTR_XS; break; case VEX_PREFIX_F2: attrMask |= ATTR_XD; break; } if (lFromVEX3of3(insn->vectorExtensionPrefix[2])) attrMask |= ATTR_VEXL; } else if (insn->vectorExtensionType == TYPE_VEX_2B) { switch (ppFromVEX2of2(insn->vectorExtensionPrefix[1])) { case VEX_PREFIX_66: attrMask |= ATTR_OPSIZE; break; case VEX_PREFIX_F3: attrMask |= ATTR_XS; break; case VEX_PREFIX_F2: attrMask |= ATTR_XD; break; } if (lFromVEX2of2(insn->vectorExtensionPrefix[1])) attrMask |= ATTR_VEXL; } else if (insn->vectorExtensionType == TYPE_XOP) { switch (ppFromXOP3of3(insn->vectorExtensionPrefix[2])) { case VEX_PREFIX_66: attrMask |= ATTR_OPSIZE; break; case VEX_PREFIX_F3: attrMask |= ATTR_XS; break; case VEX_PREFIX_F2: attrMask |= ATTR_XD; break; } if (lFromXOP3of3(insn->vectorExtensionPrefix[2])) attrMask |= ATTR_VEXL; } else { return -1; } } else { if (insn->mode != MODE_16BIT && isPrefixAtLocation(insn, 0x66, insn->necessaryPrefixLocation)) { attrMask |= ATTR_OPSIZE; } else if (isPrefixAtLocation(insn, 0x67, insn->necessaryPrefixLocation)) { attrMask |= ATTR_ADSIZE; } else if (insn->mode != MODE_16BIT && isPrefixAtLocation(insn, 0xf3, insn->necessaryPrefixLocation)) { attrMask |= ATTR_XS; } else if (insn->mode != MODE_16BIT && isPrefixAtLocation(insn, 0xf2, insn->necessaryPrefixLocation)) { attrMask |= ATTR_XD; } } if (insn->rexPrefix & 0x08) attrMask |= ATTR_REXW; /* * JCXZ/JECXZ need special handling for 16-bit mode because the meaning * of the AdSize prefix is inverted w.r.t. 32-bit mode. */ if (insn->mode == MODE_16BIT && insn->opcodeType == ONEBYTE && insn->opcode == 0xE3) attrMask ^= ATTR_ADSIZE; if (getIDWithAttrMask(&instructionID, insn, attrMask)) return -1; /* The following clauses compensate for limitations of the tables. */ if (insn->mode != MODE_64BIT && insn->vectorExtensionType != TYPE_NO_VEX_XOP) { /* * The tables can't distinquish between cases where the W-bit is used to * select register size and cases where its a required part of the opcode. */ if ((insn->vectorExtensionType == TYPE_EVEX && wFromEVEX3of4(insn->vectorExtensionPrefix[2])) || (insn->vectorExtensionType == TYPE_VEX_3B && wFromVEX3of3(insn->vectorExtensionPrefix[2])) || (insn->vectorExtensionType == TYPE_XOP && wFromXOP3of3(insn->vectorExtensionPrefix[2]))) { uint16_t instructionIDWithREXW; if (getIDWithAttrMask(&instructionIDWithREXW, insn, attrMask | ATTR_REXW)) { insn->instructionID = instructionID; insn->spec = specifierForUID(instructionID); return 0; } // If not a 64-bit instruction. Switch the opcode. if (!is64Bit(instructionIDWithREXW)) { insn->instructionID = instructionIDWithREXW; insn->spec = specifierForUID(instructionIDWithREXW); return 0; } } } /* * Absolute moves need special handling. * -For 16-bit mode because the meaning of the AdSize and OpSize prefixes are * inverted w.r.t. * -For 32-bit mode we need to ensure the ADSIZE prefix is observed in * any position. */ if (insn->opcodeType == ONEBYTE && ((insn->opcode & 0xFC) == 0xA0)) { /* Make sure we observed the prefixes in any position. */ if (insn->isPrefix67) attrMask |= ATTR_ADSIZE; if (insn->isPrefix66) attrMask |= ATTR_OPSIZE; /* In 16-bit, invert the attributes. */ if (insn->mode == MODE_16BIT) attrMask ^= ATTR_ADSIZE | ATTR_OPSIZE; if (getIDWithAttrMask(&instructionID, insn, attrMask)) return -1; insn->instructionID = instructionID; insn->spec = specifierForUID(instructionID); return 0; } if ((insn->mode == MODE_16BIT || insn->isPrefix66) && !(attrMask & ATTR_OPSIZE)) { /* * The instruction tables make no distinction between instructions that * allow OpSize anywhere (i.e., 16-bit operations) and that need it in a * particular spot (i.e., many MMX operations). In general we're * conservative, but in the specific case where OpSize is present but not * in the right place we check if there's a 16-bit operation. */ const struct InstructionSpecifier *spec; uint16_t instructionIDWithOpsize; spec = specifierForUID(instructionID); if (getIDWithAttrMask(&instructionIDWithOpsize, insn, attrMask | ATTR_OPSIZE)) { /* * ModRM required with OpSize but not present; give up and return version * without OpSize set */ insn->instructionID = instructionID; insn->spec = spec; return 0; } if (is16BitEquivalent(instructionID, instructionIDWithOpsize) && (insn->mode == MODE_16BIT) ^ insn->isPrefix66) { insn->instructionID = instructionIDWithOpsize; insn->spec = specifierForUID(instructionIDWithOpsize); } else { insn->instructionID = instructionID; insn->spec = spec; } return 0; } if (insn->opcodeType == ONEBYTE && insn->opcode == 0x90 && insn->rexPrefix & 0x01) { /* * NOOP shouldn't decode as NOOP if REX.b is set. Instead * it should decode as XCHG %r8, %eax. */ const struct InstructionSpecifier *spec; uint16_t instructionIDWithNewOpcode; const struct InstructionSpecifier *specWithNewOpcode; spec = specifierForUID(instructionID); /* Borrow opcode from one of the other XCHGar opcodes */ insn->opcode = 0x91; if (getIDWithAttrMask(&instructionIDWithNewOpcode, insn, attrMask)) { insn->opcode = 0x90; insn->instructionID = instructionID; insn->spec = spec; return 0; } specWithNewOpcode = specifierForUID(instructionIDWithNewOpcode); /* Change back */ insn->opcode = 0x90; insn->instructionID = instructionIDWithNewOpcode; insn->spec = specWithNewOpcode; return 0; } insn->instructionID = instructionID; insn->spec = specifierForUID(insn->instructionID); return 0; } /* * readSIB - Consumes the SIB byte to determine addressing information for an * instruction. * * @param insn - The instruction whose SIB byte is to be read. * @return - 0 if the SIB byte was successfully read; nonzero otherwise. */ static int readSIB(struct InternalInstruction *insn) { SIBIndex sibIndexBase = SIB_INDEX_NONE; SIBBase sibBaseBase = SIB_BASE_NONE; uint8_t index, base; // dbgprintf(insn, "readSIB()"); if (insn->consumedSIB) return 0; insn->consumedSIB = true; switch (insn->addressSize) { case 2: // dbgprintf(insn, "SIB-based addressing doesn't work in 16-bit mode"); return -1; case 4: sibIndexBase = SIB_INDEX_EAX; sibBaseBase = SIB_BASE_EAX; break; case 8: sibIndexBase = SIB_INDEX_RAX; sibBaseBase = SIB_BASE_RAX; break; } if (consumeByte(insn, &insn->sib)) return -1; index = indexFromSIB(insn->sib) | (xFromREX(insn->rexPrefix) << 3); if (insn->vectorExtensionType == TYPE_EVEX) index |= v2FromEVEX4of4(insn->vectorExtensionPrefix[3]) << 4; switch (index) { case 0x4: insn->sibIndex = SIB_INDEX_NONE; break; default: insn->sibIndex = (SIBIndex)(sibIndexBase + index); if (insn->sibIndex == SIB_INDEX_sib || insn->sibIndex == SIB_INDEX_sib64) insn->sibIndex = SIB_INDEX_NONE; break; } switch (scaleFromSIB(insn->sib)) { case 0: insn->sibScale = 1; break; case 1: insn->sibScale = 2; break; case 2: insn->sibScale = 4; break; case 3: insn->sibScale = 8; break; } base = baseFromSIB(insn->sib) | (bFromREX(insn->rexPrefix) << 3); switch (base) { case 0x5: case 0xd: switch (modFromModRM(insn->modRM)) { case 0x0: insn->eaDisplacement = EA_DISP_32; insn->sibBase = SIB_BASE_NONE; break; case 0x1: insn->eaDisplacement = EA_DISP_8; insn->sibBase = (SIBBase)(sibBaseBase + base); break; case 0x2: insn->eaDisplacement = EA_DISP_32; insn->sibBase = (SIBBase)(sibBaseBase + base); break; case 0x3: //debug("Cannot have Mod = 0b11 and a SIB byte"); return -1; } break; default: insn->sibBase = (SIBBase)(sibBaseBase + base); break; } return 0; } /* * readDisplacement - Consumes the displacement of an instruction. * * @param insn - The instruction whose displacement is to be read. * @return - 0 if the displacement byte was successfully read; nonzero * otherwise. */ static int readDisplacement(struct InternalInstruction *insn) { int8_t d8; int16_t d16; int32_t d32; // dbgprintf(insn, "readDisplacement()"); if (insn->consumedDisplacement) return 0; insn->consumedDisplacement = true; insn->displacementOffset = (uint8_t)(insn->readerCursor - insn->startLocation); switch (insn->eaDisplacement) { case EA_DISP_NONE: insn->consumedDisplacement = false; break; case EA_DISP_8: if (consumeInt8(insn, &d8)) return -1; insn->displacement = d8; break; case EA_DISP_16: if (consumeInt16(insn, &d16)) return -1; insn->displacement = d16; break; case EA_DISP_32: if (consumeInt32(insn, &d32)) return -1; insn->displacement = d32; break; } insn->consumedDisplacement = true; return 0; } /* * readModRM - Consumes all addressing information (ModR/M byte, SIB byte, and * displacement) for an instruction and interprets it. * * @param insn - The instruction whose addressing information is to be read. * @return - 0 if the information was successfully read; nonzero otherwise. */ static int readModRM(struct InternalInstruction *insn) { uint8_t mod, rm, reg; // dbgprintf(insn, "readModRM()"); // already got ModRM byte? if (insn->consumedModRM) return 0; if (consumeByte(insn, &insn->modRM)) return -1; // mark that we already got ModRM insn->consumedModRM = true; // save original ModRM for later reference insn->orgModRM = insn->modRM; // handle MOVcr, MOVdr, MOVrc, MOVrd by pretending they have MRM.mod = 3 if ((insn->firstByte == 0x0f && insn->opcodeType == TWOBYTE) && (insn->opcode >= 0x20 && insn->opcode <= 0x23 )) insn->modRM |= 0xC0; mod = modFromModRM(insn->modRM); rm = rmFromModRM(insn->modRM); reg = regFromModRM(insn->modRM); /* * This goes by insn->registerSize to pick the correct register, which messes * up if we're using (say) XMM or 8-bit register operands. That gets fixed in * fixupReg(). */ switch (insn->registerSize) { case 2: insn->regBase = MODRM_REG_AX; insn->eaRegBase = EA_REG_AX; break; case 4: insn->regBase = MODRM_REG_EAX; insn->eaRegBase = EA_REG_EAX; break; case 8: insn->regBase = MODRM_REG_RAX; insn->eaRegBase = EA_REG_RAX; break; } reg |= rFromREX(insn->rexPrefix) << 3; rm |= bFromREX(insn->rexPrefix) << 3; if (insn->vectorExtensionType == TYPE_EVEX) { reg |= r2FromEVEX2of4(insn->vectorExtensionPrefix[1]) << 4; rm |= xFromEVEX2of4(insn->vectorExtensionPrefix[1]) << 4; } insn->reg = (Reg)(insn->regBase + reg); switch (insn->addressSize) { case 2: insn->eaBaseBase = EA_BASE_BX_SI; switch (mod) { case 0x0: if (rm == 0x6) { insn->eaBase = EA_BASE_NONE; insn->eaDisplacement = EA_DISP_16; if (readDisplacement(insn)) return -1; } else { insn->eaBase = (EABase)(insn->eaBaseBase + rm); insn->eaDisplacement = EA_DISP_NONE; } break; case 0x1: insn->eaBase = (EABase)(insn->eaBaseBase + rm); insn->eaDisplacement = EA_DISP_8; insn->displacementSize = 1; if (readDisplacement(insn)) return -1; break; case 0x2: insn->eaBase = (EABase)(insn->eaBaseBase + rm); insn->eaDisplacement = EA_DISP_16; if (readDisplacement(insn)) return -1; break; case 0x3: insn->eaBase = (EABase)(insn->eaRegBase + rm); insn->eaDisplacement = EA_DISP_NONE; if (readDisplacement(insn)) return -1; break; } break; case 4: case 8: insn->eaBaseBase = (insn->addressSize == 4 ? EA_BASE_EAX : EA_BASE_RAX); switch (mod) { case 0x0: insn->eaDisplacement = EA_DISP_NONE; /* readSIB may override this */ switch (rm) { case 0x14: case 0x4: case 0xc: /* in case REXW.b is set */ insn->eaBase = (insn->addressSize == 4 ? EA_BASE_sib : EA_BASE_sib64); if (readSIB(insn) || readDisplacement(insn)) return -1; break; case 0x5: case 0xd: insn->eaBase = EA_BASE_NONE; insn->eaDisplacement = EA_DISP_32; if (readDisplacement(insn)) return -1; break; default: insn->eaBase = (EABase)(insn->eaBaseBase + rm); break; } break; case 0x1: insn->displacementSize = 1; /* FALLTHROUGH */ case 0x2: insn->eaDisplacement = (mod == 0x1 ? EA_DISP_8 : EA_DISP_32); switch (rm) { case 0x14: case 0x4: case 0xc: /* in case REXW.b is set */ insn->eaBase = EA_BASE_sib; if (readSIB(insn) || readDisplacement(insn)) return -1; break; default: insn->eaBase = (EABase)(insn->eaBaseBase + rm); if (readDisplacement(insn)) return -1; break; } break; case 0x3: insn->eaDisplacement = EA_DISP_NONE; insn->eaBase = (EABase)(insn->eaRegBase + rm); break; } break; } /* switch (insn->addressSize) */ return 0; } #define GENERIC_FIXUP_FUNC(name, base, prefix) \ static uint8_t name(struct InternalInstruction *insn, \ OperandType type, \ uint8_t index, \ uint8_t *valid) { \ *valid = 1; \ switch (type) { \ default: \ *valid = 0; \ return 0; \ case TYPE_Rv: \ return base + index; \ case TYPE_R8: \ if (insn->rexPrefix && \ index >= 4 && index <= 7) { \ return prefix##_SPL + (index - 4); \ } else { \ return prefix##_AL + index; \ } \ case TYPE_R16: \ return prefix##_AX + index; \ case TYPE_R32: \ return prefix##_EAX + index; \ case TYPE_R64: \ return prefix##_RAX + index; \ case TYPE_XMM512: \ return prefix##_ZMM0 + index; \ case TYPE_XMM256: \ return prefix##_YMM0 + index; \ case TYPE_XMM128: \ case TYPE_XMM64: \ case TYPE_XMM32: \ case TYPE_XMM: \ return prefix##_XMM0 + index; \ case TYPE_VK1: \ case TYPE_VK8: \ case TYPE_VK16: \ if (index > 7) \ *valid = 0; \ return prefix##_K0 + index; \ case TYPE_MM64: \ return prefix##_MM0 + (index & 0x7); \ case TYPE_SEGMENTREG: \ if (index > 5) \ *valid = 0; \ return prefix##_ES + index; \ case TYPE_DEBUGREG: \ return prefix##_DR0 + index; \ case TYPE_CONTROLREG: \ return prefix##_CR0 + index; \ } \ } /* * fixup*Value - Consults an operand type to determine the meaning of the * reg or R/M field. If the operand is an XMM operand, for example, an * operand would be XMM0 instead of AX, which readModRM() would otherwise * misinterpret it as. * * @param insn - The instruction containing the operand. * @param type - The operand type. * @param index - The existing value of the field as reported by readModRM(). * @param valid - The address of a uint8_t. The target is set to 1 if the * field is valid for the register class; 0 if not. * @return - The proper value. */ GENERIC_FIXUP_FUNC(fixupRegValue, insn->regBase, MODRM_REG) GENERIC_FIXUP_FUNC(fixupRMValue, insn->eaRegBase, EA_REG) /* * fixupReg - Consults an operand specifier to determine which of the * fixup*Value functions to use in correcting readModRM()'ss interpretation. * * @param insn - See fixup*Value(). * @param op - The operand specifier. * @return - 0 if fixup was successful; -1 if the register returned was * invalid for its class. */ static int fixupReg(struct InternalInstruction *insn, const struct OperandSpecifier *op) { uint8_t valid; // dbgprintf(insn, "fixupReg()"); switch ((OperandEncoding)op->encoding) { default: //debug("Expected a REG or R/M encoding in fixupReg"); return -1; case ENCODING_VVVV: insn->vvvv = (Reg)fixupRegValue(insn, (OperandType)op->type, insn->vvvv, &valid); if (!valid) return -1; break; case ENCODING_REG: insn->reg = (Reg)fixupRegValue(insn, (OperandType)op->type, (uint8_t)(insn->reg - insn->regBase), &valid); if (!valid) return -1; break; CASE_ENCODING_RM: if (insn->eaBase >= insn->eaRegBase) { insn->eaBase = (EABase)fixupRMValue(insn, (OperandType)op->type, (uint8_t)(insn->eaBase - insn->eaRegBase), &valid); if (!valid) return -1; } break; } return 0; } /* * readOpcodeRegister - Reads an operand from the opcode field of an * instruction and interprets it appropriately given the operand width. * Handles AddRegFrm instructions. * * @param insn - the instruction whose opcode field is to be read. * @param size - The width (in bytes) of the register being specified. * 1 means AL and friends, 2 means AX, 4 means EAX, and 8 means * RAX. * @return - 0 on success; nonzero otherwise. */ static int readOpcodeRegister(struct InternalInstruction *insn, uint8_t size) { // dbgprintf(insn, "readOpcodeRegister()"); if (size == 0) size = insn->registerSize; insn->operandSize = size; switch (size) { case 1: insn->opcodeRegister = (Reg)(MODRM_REG_AL + ((bFromREX(insn->rexPrefix) << 3) | (insn->opcode & 7))); if (insn->rexPrefix && insn->opcodeRegister >= MODRM_REG_AL + 0x4 && insn->opcodeRegister < MODRM_REG_AL + 0x8) { insn->opcodeRegister = (Reg)(MODRM_REG_SPL + (insn->opcodeRegister - MODRM_REG_AL - 4)); } break; case 2: insn->opcodeRegister = (Reg)(MODRM_REG_AX + ((bFromREX(insn->rexPrefix) << 3) | (insn->opcode & 7))); break; case 4: insn->opcodeRegister = (Reg)(MODRM_REG_EAX + ((bFromREX(insn->rexPrefix) << 3) | (insn->opcode & 7))); break; case 8: insn->opcodeRegister = (Reg)(MODRM_REG_RAX + ((bFromREX(insn->rexPrefix) << 3) | (insn->opcode & 7))); break; } return 0; } /* * readImmediate - Consumes an immediate operand from an instruction, given the * desired operand size. * * @param insn - The instruction whose operand is to be read. * @param size - The width (in bytes) of the operand. * @return - 0 if the immediate was successfully consumed; nonzero * otherwise. */ static int readImmediate(struct InternalInstruction *insn, uint8_t size) { uint8_t imm8; uint16_t imm16; uint32_t imm32; uint64_t imm64; // dbgprintf(insn, "readImmediate()"); if (insn->numImmediatesConsumed == 2) { //debug("Already consumed two immediates"); return -1; } if (size == 0) size = insn->immediateSize; else insn->immediateSize = size; insn->immediateOffset = (uint8_t)(insn->readerCursor - insn->startLocation); switch (size) { case 1: if (consumeByte(insn, &imm8)) return -1; insn->immediates[insn->numImmediatesConsumed] = imm8; break; case 2: if (consumeUInt16(insn, &imm16)) return -1; insn->immediates[insn->numImmediatesConsumed] = imm16; break; case 4: if (consumeUInt32(insn, &imm32)) return -1; insn->immediates[insn->numImmediatesConsumed] = imm32; break; case 8: if (consumeUInt64(insn, &imm64)) return -1; insn->immediates[insn->numImmediatesConsumed] = imm64; break; } insn->numImmediatesConsumed++; return 0; } /* * readVVVV - Consumes vvvv from an instruction if it has a VEX prefix. * * @param insn - The instruction whose operand is to be read. * @return - 0 if the vvvv was successfully consumed; nonzero * otherwise. */ static int readVVVV(struct InternalInstruction *insn) { int vvvv; // dbgprintf(insn, "readVVVV()"); if (insn->vectorExtensionType == TYPE_EVEX) vvvv = (v2FromEVEX4of4(insn->vectorExtensionPrefix[3]) << 4 | vvvvFromEVEX3of4(insn->vectorExtensionPrefix[2])); else if (insn->vectorExtensionType == TYPE_VEX_3B) vvvv = vvvvFromVEX3of3(insn->vectorExtensionPrefix[2]); else if (insn->vectorExtensionType == TYPE_VEX_2B) vvvv = vvvvFromVEX2of2(insn->vectorExtensionPrefix[1]); else if (insn->vectorExtensionType == TYPE_XOP) vvvv = vvvvFromXOP3of3(insn->vectorExtensionPrefix[2]); else return -1; if (insn->mode != MODE_64BIT) vvvv &= 0x7; insn->vvvv = vvvv; return 0; } /* * readMaskRegister - Reads an mask register from the opcode field of an * instruction. * * @param insn - The instruction whose opcode field is to be read. * @return - 0 on success; nonzero otherwise. */ static int readMaskRegister(struct InternalInstruction *insn) { // dbgprintf(insn, "readMaskRegister()"); if (insn->vectorExtensionType != TYPE_EVEX) return -1; insn->writemask = aaaFromEVEX4of4(insn->vectorExtensionPrefix[3]); return 0; } /* * readOperands - Consults the specifier for an instruction and consumes all * operands for that instruction, interpreting them as it goes. * * @param insn - The instruction whose operands are to be read and interpreted. * @return - 0 if all operands could be read; nonzero otherwise. */ static int readOperands(struct InternalInstruction *insn) { int index; int hasVVVV, needVVVV; int sawRegImm = 0; // printf(">>> readOperands(): ID = %u\n", insn->instructionID); /* If non-zero vvvv specified, need to make sure one of the operands uses it. */ hasVVVV = !readVVVV(insn); needVVVV = hasVVVV && (insn->vvvv != 0); for (index = 0; index < X86_MAX_OPERANDS; ++index) { //printf(">>> encoding[%u] = %u\n", index, x86OperandSets[insn->spec->operands][index].encoding); switch (x86OperandSets[insn->spec->operands][index].encoding) { case ENCODING_NONE: case ENCODING_SI: case ENCODING_DI: break; case ENCODING_REG: CASE_ENCODING_RM: if (readModRM(insn)) return -1; if (fixupReg(insn, &x86OperandSets[insn->spec->operands][index])) return -1; // Apply the AVX512 compressed displacement scaling factor. if (x86OperandSets[insn->spec->operands][index].encoding != ENCODING_REG && insn->eaDisplacement == EA_DISP_8) insn->displacement *= 1 << (x86OperandSets[insn->spec->operands][index].encoding - ENCODING_RM); break; case ENCODING_CB: case ENCODING_CW: case ENCODING_CD: case ENCODING_CP: case ENCODING_CO: case ENCODING_CT: // dbgprintf(insn, "We currently don't hande code-offset encodings"); return -1; case ENCODING_IB: if (sawRegImm) { /* Saw a register immediate so don't read again and instead split the previous immediate. FIXME: This is a hack. */ insn->immediates[insn->numImmediatesConsumed] = insn->immediates[insn->numImmediatesConsumed - 1] & 0xf; ++insn->numImmediatesConsumed; break; } if (readImmediate(insn, 1)) return -1; if (x86OperandSets[insn->spec->operands][index].type == TYPE_XMM128 || x86OperandSets[insn->spec->operands][index].type == TYPE_XMM256) sawRegImm = 1; break; case ENCODING_IW: if (readImmediate(insn, 2)) return -1; break; case ENCODING_ID: if (readImmediate(insn, 4)) return -1; break; case ENCODING_IO: if (readImmediate(insn, 8)) return -1; break; case ENCODING_Iv: if (readImmediate(insn, insn->immediateSize)) return -1; break; case ENCODING_Ia: if (readImmediate(insn, insn->addressSize)) return -1; break; case ENCODING_RB: if (readOpcodeRegister(insn, 1)) return -1; break; case ENCODING_RW: if (readOpcodeRegister(insn, 2)) return -1; break; case ENCODING_RD: if (readOpcodeRegister(insn, 4)) return -1; break; case ENCODING_RO: if (readOpcodeRegister(insn, 8)) return -1; break; case ENCODING_Rv: if (readOpcodeRegister(insn, 0)) return -1; break; case ENCODING_FP: break; case ENCODING_VVVV: needVVVV = 0; /* Mark that we have found a VVVV operand. */ if (!hasVVVV) return -1; if (fixupReg(insn, &x86OperandSets[insn->spec->operands][index])) return -1; break; case ENCODING_WRITEMASK: if (readMaskRegister(insn)) return -1; break; case ENCODING_DUP: break; default: // dbgprintf(insn, "Encountered an operand with an unknown encoding."); return -1; } } /* If we didn't find ENCODING_VVVV operand, but non-zero vvvv present, fail */ if (needVVVV) return -1; return 0; } // return True if instruction is illegal to use with prefixes // This also check & fix the isPrefixNN when a prefix is irrelevant. static bool checkPrefix(struct InternalInstruction *insn) { // LOCK prefix if (insn->isPrefixf0) { switch(insn->instructionID) { default: // invalid LOCK return true; // nop dword [rax] case X86_NOOPL: // DEC case X86_DEC16m: case X86_DEC32m: case X86_DEC64m: case X86_DEC8m: // ADC case X86_ADC16mi: case X86_ADC16mi8: case X86_ADC16mr: case X86_ADC32mi: case X86_ADC32mi8: case X86_ADC32mr: case X86_ADC64mi32: case X86_ADC64mi8: case X86_ADC64mr: case X86_ADC8mi: case X86_ADC8mi8: case X86_ADC8mr: // ADD case X86_ADD16mi: case X86_ADD16mi8: case X86_ADD16mr: case X86_ADD32mi: case X86_ADD32mi8: case X86_ADD32mr: case X86_ADD64mi32: case X86_ADD64mi8: case X86_ADD64mr: case X86_ADD8mi: case X86_ADD8mi8: case X86_ADD8mr: // AND case X86_AND16mi: case X86_AND16mi8: case X86_AND16mr: case X86_AND32mi: case X86_AND32mi8: case X86_AND32mr: case X86_AND64mi32: case X86_AND64mi8: case X86_AND64mr: case X86_AND8mi: case X86_AND8mi8: case X86_AND8mr: // BTC case X86_BTC16mi8: case X86_BTC16mr: case X86_BTC32mi8: case X86_BTC32mr: case X86_BTC64mi8: case X86_BTC64mr: // BTR case X86_BTR16mi8: case X86_BTR16mr: case X86_BTR32mi8: case X86_BTR32mr: case X86_BTR64mi8: case X86_BTR64mr: // BTS case X86_BTS16mi8: case X86_BTS16mr: case X86_BTS32mi8: case X86_BTS32mr: case X86_BTS64mi8: case X86_BTS64mr: // CMPXCHG case X86_CMPXCHG16B: case X86_CMPXCHG16rm: case X86_CMPXCHG32rm: case X86_CMPXCHG64rm: case X86_CMPXCHG8rm: case X86_CMPXCHG8B: // INC case X86_INC16m: case X86_INC32m: case X86_INC64m: case X86_INC8m: // NEG case X86_NEG16m: case X86_NEG32m: case X86_NEG64m: case X86_NEG8m: // NOT case X86_NOT16m: case X86_NOT32m: case X86_NOT64m: case X86_NOT8m: // OR case X86_OR16mi: case X86_OR16mi8: case X86_OR16mr: case X86_OR32mi: case X86_OR32mi8: case X86_OR32mr: case X86_OR32mrLocked: case X86_OR64mi32: case X86_OR64mi8: case X86_OR64mr: case X86_OR8mi8: case X86_OR8mi: case X86_OR8mr: // SBB case X86_SBB16mi: case X86_SBB16mi8: case X86_SBB16mr: case X86_SBB32mi: case X86_SBB32mi8: case X86_SBB32mr: case X86_SBB64mi32: case X86_SBB64mi8: case X86_SBB64mr: case X86_SBB8mi: case X86_SBB8mi8: case X86_SBB8mr: // SUB case X86_SUB16mi: case X86_SUB16mi8: case X86_SUB16mr: case X86_SUB32mi: case X86_SUB32mi8: case X86_SUB32mr: case X86_SUB64mi32: case X86_SUB64mi8: case X86_SUB64mr: case X86_SUB8mi8: case X86_SUB8mi: case X86_SUB8mr: // XADD case X86_XADD16rm: case X86_XADD32rm: case X86_XADD64rm: case X86_XADD8rm: // XCHG case X86_XCHG16rm: case X86_XCHG32rm: case X86_XCHG64rm: case X86_XCHG8rm: // XOR case X86_XOR16mi: case X86_XOR16mi8: case X86_XOR16mr: case X86_XOR32mi: case X86_XOR32mi8: case X86_XOR32mr: case X86_XOR64mi32: case X86_XOR64mi8: case X86_XOR64mr: case X86_XOR8mi8: case X86_XOR8mi: case X86_XOR8mr: // this instruction can be used with LOCK prefix return false; } } // REPNE prefix if (insn->isPrefixf2) { // 0xf2 can be a part of instruction encoding, but not really a prefix. // In such a case, clear it. if (insn->twoByteEscape == 0x0f) { insn->prefix0 = 0; } } // no invalid prefixes return false; } /* * decodeInstruction - Reads and interprets a full instruction provided by the * user. * * @param insn - A pointer to the instruction to be populated. Must be * pre-allocated. * @param reader - The function to be used to read the instruction's bytes. * @param readerArg - A generic argument to be passed to the reader to store * any internal state. * @param startLoc - The address (in the reader's address space) of the first * byte in the instruction. * @param mode - The mode (real mode, IA-32e, or IA-32e in 64-bit mode) to * decode the instruction in. * @return - 0 if instruction is valid; nonzero if not. */ int decodeInstruction(struct InternalInstruction *insn, byteReader_t reader, const void *readerArg, uint64_t startLoc, DisassemblerMode mode) { insn->reader = reader; insn->readerArg = readerArg; insn->startLocation = startLoc; insn->readerCursor = startLoc; insn->mode = mode; if (readPrefixes(insn) || readOpcode(insn) || getID(insn) || insn->instructionID == 0 || checkPrefix(insn) || readOperands(insn)) return -1; insn->length = (size_t)(insn->readerCursor - insn->startLocation); // instruction length must be <= 15 to be valid if (insn->length > 15) return -1; if (insn->operandSize == 0) insn->operandSize = insn->registerSize; insn->operands = &x86OperandSets[insn->spec->operands][0]; // dbgprintf(insn, "Read from 0x%llx to 0x%llx: length %zu", // startLoc, insn->readerCursor, insn->length); //if (insn->length > 15) // dbgprintf(insn, "Instruction exceeds 15-byte limit"); #if 0 printf("\n>>> x86OperandSets = %lu\n", sizeof(x86OperandSets)); printf(">>> x86DisassemblerInstrSpecifiers = %lu\n", sizeof(x86DisassemblerInstrSpecifiers)); printf(">>> x86DisassemblerContexts = %lu\n", sizeof(x86DisassemblerContexts)); printf(">>> modRMTable = %lu\n", sizeof(modRMTable)); printf(">>> x86DisassemblerOneByteOpcodes = %lu\n", sizeof(x86DisassemblerOneByteOpcodes)); printf(">>> x86DisassemblerTwoByteOpcodes = %lu\n", sizeof(x86DisassemblerTwoByteOpcodes)); printf(">>> x86DisassemblerThreeByte38Opcodes = %lu\n", sizeof(x86DisassemblerThreeByte38Opcodes)); printf(">>> x86DisassemblerThreeByte3AOpcodes = %lu\n", sizeof(x86DisassemblerThreeByte3AOpcodes)); printf(">>> x86DisassemblerThreeByteA6Opcodes = %lu\n", sizeof(x86DisassemblerThreeByteA6Opcodes)); printf(">>> x86DisassemblerThreeByteA7Opcodes= %lu\n", sizeof(x86DisassemblerThreeByteA7Opcodes)); printf(">>> x86DisassemblerXOP8Opcodes = %lu\n", sizeof(x86DisassemblerXOP8Opcodes)); printf(">>> x86DisassemblerXOP9Opcodes = %lu\n", sizeof(x86DisassemblerXOP9Opcodes)); printf(">>> x86DisassemblerXOPAOpcodes = %lu\n\n", sizeof(x86DisassemblerXOPAOpcodes)); #endif return 0; } #endif
the_stack_data/1024098.c
#include <stdio.h> #include <sys/types.h> #include <sys/ipc.h> #include <sys/shm.h> #include <stdlib.h> #include <values.h> #include <sys/sem.h> #define MS_SIZ 5 #define BUF_SIZ 30 #define POSTAVI 1 #define ISPITAJ -1 #define PUN 0 #define PISI 1 #define PRAZAN 2 #define UPIS1 3 #define UPIS2 4 void proizvodjac(int); char *m; int *ulaz, *izlaz; int semId, memId, ulazId, izlazId; /*----------------------------------------------------*/ void SemGet(int n) { semId = semget(IPC_PRIVATE, n, 0600); if(semId == -1){ printf("Nema semafora!\n"); exit(1); } } /*----------------------------------------------------*/ int SemSetVal(int SemNum, int SemVal) { return !semctl(semId, SemNum, SETVAL, SemVal); } /*----------------------------------------------------*/ int SemOp(int SemNum, int SemOp) { struct sembuf SemBuf; SemBuf.sem_num = SemNum; SemBuf.sem_op = SemOp; SemBuf.sem_flg = 0; return semop(semId, &SemBuf, 1); } /*---------------------------------------------------*/ void brisi() { int i; shmdt((char *)ulaz); shmdt((char *)izlaz); shmdt(m); shmctl(memId, IPC_RMID, NULL); shmctl(ulazId, IPC_RMID, NULL); shmctl(izlazId, IPC_RMID, NULL); for(i = 0; i < 5; i++){ semctl(semId, i, IPC_RMID, 0); } printf("Ocistio memoriju i semafore.\n"); } /*--------------------------------------------------*/ void stvori_proizvodjace() { switch(fork()){ case 0: proizvodjac(2); break; default: proizvodjac(1); break; } } /*---------------------------------------------------*/ void proizvodjac(int proId) { int i = 0; char niz[BUF_SIZ+1]; SemOp(UPIS1, ISPITAJ); printf("Unesti znakove za proizvodjaca %d\n", proId); fgets(niz, 50, stdin); SemOp(UPIS1, POSTAVI); if(proId == 1) SemOp(UPIS2, ISPITAJ); if(proId == 2) SemOp(UPIS2, POSTAVI); while(niz[i]){ SemOp(PUN, ISPITAJ); SemOp(PISI, ISPITAJ); sleep(1); printf("PROIZVODJAC%d -> %c\n", proId, niz[i]); m[*ulaz] = niz[i]; *ulaz = ((*ulaz)+1) % MS_SIZ; SemOp(PISI, POSTAVI); SemOp(PRAZAN, POSTAVI); if(niz[i] == 10) break; i++; } exit(0); } /*----------------------------------------------------*/ void potrosac(void) { int i = 0; int kraj = 2; char niz[2*BUF_SIZ+1]; while(kraj){ SemOp(PRAZAN, ISPITAJ); printf("POTROSAC <- %c\n", m[*izlaz]); if(m[*izlaz] != 10){ niz[i] = m[*izlaz]; i++; } else{ kraj--; } *izlaz = ((*izlaz+1)) % 5; SemOp(PUN, POSTAVI); } niz[i] = 0; printf("Primljeno je: %s\n", niz); brisi(); exit(0); } /*----------------------------------------------------*/ /*----------------------------------------------------*/ int main() { memId = shmget(IPC_PRIVATE, sizeof(char)*MS_SIZ, 0600); m = (char*) shmat(memId, NULL, 0); ulazId = shmget(IPC_PRIVATE, sizeof(int), 0600); ulaz = (int *) shmat(ulazId, NULL, 0); izlazId = shmget(IPC_PRIVATE, sizeof(int), 0600); izlaz = (int *) shmat(izlazId, NULL, 0); semId = semget(IPC_PRIVATE, 5, 0600); (*ulaz) = (*izlaz) = 0; if(!SemSetVal(PUN, 1) || !SemSetVal(PRAZAN, 0) || !SemSetVal(PISI, 1) || !SemSetVal(UPIS1, 1) || !SemSetVal(UPIS2, 0)){ printf("Ne mogu inicijalizirati semafor!\n"); exit(1); } switch(fork()){ case 0: potrosac(); break; default: stvori_proizvodjace(); break; } exit(0); }
the_stack_data/63087.c
int firstMissingPositive(int* nums, int numsSize) { int i = 0; while(i < numsSize){ if(nums[i] <= 0 || nums[i] >= numsSize || nums[i] == i + 1 || nums[i] == nums[nums[i] - 1]){ ++i; }else{ int tmp = nums[i]; nums[i] = nums[nums[i] - 1]; nums[tmp-1] = tmp; } } for(i = 0; i < numsSize; ++i) if(nums[i] != i + 1) break; return i + 1; }
the_stack_data/92326850.c
int foo(void); int foo(void) { int i = 5 ^ 3; return i; }
the_stack_data/403729.c
#include <stdio.h> int main() { int n; printf("Enter number: "); scanf("%d",&n); if(n>0) printf("Number is positive"); else if(n<0) printf("Number is negative"); else printf("Number is Zero"); return 0; } /*program to find weather number is positive or negative or zero if else DAY_9*/
the_stack_data/82649.c
//@ ltl invariant negative: (AP(x_21 - x_27 >= 2) || (X ([] AP(x_22 - x_5 > 0)))); float x_0; float x_1; float x_2; float x_3; float x_4; float x_5; float x_6; float x_7; float x_8; float x_9; float x_10; float x_11; float x_12; float x_13; float x_14; float x_15; float x_16; float x_17; float x_18; float x_19; float x_20; float x_21; float x_22; float x_23; float x_24; float x_25; float x_26; float x_27; 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_; float x_8_; float x_9_; float x_10_; float x_11_; float x_12_; float x_13_; float x_14_; float x_15_; float x_16_; float x_17_; float x_18_; float x_19_; float x_20_; float x_21_; float x_22_; float x_23_; float x_24_; float x_25_; float x_26_; float x_27_; while(1) { x_0_ = ((((20.0 + x_0) > ((14.0 + x_3) > (17.0 + x_4)? (14.0 + x_3) : (17.0 + x_4))? (20.0 + x_0) : ((14.0 + x_3) > (17.0 + x_4)? (14.0 + x_3) : (17.0 + x_4))) > (((8.0 + x_6) > (7.0 + x_11)? (8.0 + x_6) : (7.0 + x_11)) > ((9.0 + x_12) > (11.0 + x_13)? (9.0 + x_12) : (11.0 + x_13))? ((8.0 + x_6) > (7.0 + x_11)? (8.0 + x_6) : (7.0 + x_11)) : ((9.0 + x_12) > (11.0 + x_13)? (9.0 + x_12) : (11.0 + x_13)))? ((20.0 + x_0) > ((14.0 + x_3) > (17.0 + x_4)? (14.0 + x_3) : (17.0 + x_4))? (20.0 + x_0) : ((14.0 + x_3) > (17.0 + x_4)? (14.0 + x_3) : (17.0 + x_4))) : (((8.0 + x_6) > (7.0 + x_11)? (8.0 + x_6) : (7.0 + x_11)) > ((9.0 + x_12) > (11.0 + x_13)? (9.0 + x_12) : (11.0 + x_13))? ((8.0 + x_6) > (7.0 + x_11)? (8.0 + x_6) : (7.0 + x_11)) : ((9.0 + x_12) > (11.0 + x_13)? (9.0 + x_12) : (11.0 + x_13)))) > (((1.0 + x_15) > ((15.0 + x_18) > (3.0 + x_20)? (15.0 + x_18) : (3.0 + x_20))? (1.0 + x_15) : ((15.0 + x_18) > (3.0 + x_20)? (15.0 + x_18) : (3.0 + x_20))) > (((18.0 + x_22) > (10.0 + x_23)? (18.0 + x_22) : (10.0 + x_23)) > ((16.0 + x_26) > (7.0 + x_27)? (16.0 + x_26) : (7.0 + x_27))? ((18.0 + x_22) > (10.0 + x_23)? (18.0 + x_22) : (10.0 + x_23)) : ((16.0 + x_26) > (7.0 + x_27)? (16.0 + x_26) : (7.0 + x_27)))? ((1.0 + x_15) > ((15.0 + x_18) > (3.0 + x_20)? (15.0 + x_18) : (3.0 + x_20))? (1.0 + x_15) : ((15.0 + x_18) > (3.0 + x_20)? (15.0 + x_18) : (3.0 + x_20))) : (((18.0 + x_22) > (10.0 + x_23)? (18.0 + x_22) : (10.0 + x_23)) > ((16.0 + x_26) > (7.0 + x_27)? (16.0 + x_26) : (7.0 + x_27))? ((18.0 + x_22) > (10.0 + x_23)? (18.0 + x_22) : (10.0 + x_23)) : ((16.0 + x_26) > (7.0 + x_27)? (16.0 + x_26) : (7.0 + x_27))))? (((20.0 + x_0) > ((14.0 + x_3) > (17.0 + x_4)? (14.0 + x_3) : (17.0 + x_4))? (20.0 + x_0) : ((14.0 + x_3) > (17.0 + x_4)? (14.0 + x_3) : (17.0 + x_4))) > (((8.0 + x_6) > (7.0 + x_11)? (8.0 + x_6) : (7.0 + x_11)) > ((9.0 + x_12) > (11.0 + x_13)? (9.0 + x_12) : (11.0 + x_13))? ((8.0 + x_6) > (7.0 + x_11)? (8.0 + x_6) : (7.0 + x_11)) : ((9.0 + x_12) > (11.0 + x_13)? (9.0 + x_12) : (11.0 + x_13)))? ((20.0 + x_0) > ((14.0 + x_3) > (17.0 + x_4)? (14.0 + x_3) : (17.0 + x_4))? (20.0 + x_0) : ((14.0 + x_3) > (17.0 + x_4)? (14.0 + x_3) : (17.0 + x_4))) : (((8.0 + x_6) > (7.0 + x_11)? (8.0 + x_6) : (7.0 + x_11)) > ((9.0 + x_12) > (11.0 + x_13)? (9.0 + x_12) : (11.0 + x_13))? ((8.0 + x_6) > (7.0 + x_11)? (8.0 + x_6) : (7.0 + x_11)) : ((9.0 + x_12) > (11.0 + x_13)? (9.0 + x_12) : (11.0 + x_13)))) : (((1.0 + x_15) > ((15.0 + x_18) > (3.0 + x_20)? (15.0 + x_18) : (3.0 + x_20))? (1.0 + x_15) : ((15.0 + x_18) > (3.0 + x_20)? (15.0 + x_18) : (3.0 + x_20))) > (((18.0 + x_22) > (10.0 + x_23)? (18.0 + x_22) : (10.0 + x_23)) > ((16.0 + x_26) > (7.0 + x_27)? (16.0 + x_26) : (7.0 + x_27))? ((18.0 + x_22) > (10.0 + x_23)? (18.0 + x_22) : (10.0 + x_23)) : ((16.0 + x_26) > (7.0 + x_27)? (16.0 + x_26) : (7.0 + x_27)))? ((1.0 + x_15) > ((15.0 + x_18) > (3.0 + x_20)? (15.0 + x_18) : (3.0 + x_20))? (1.0 + x_15) : ((15.0 + x_18) > (3.0 + x_20)? (15.0 + x_18) : (3.0 + x_20))) : (((18.0 + x_22) > (10.0 + x_23)? (18.0 + x_22) : (10.0 + x_23)) > ((16.0 + x_26) > (7.0 + x_27)? (16.0 + x_26) : (7.0 + x_27))? ((18.0 + x_22) > (10.0 + x_23)? (18.0 + x_22) : (10.0 + x_23)) : ((16.0 + x_26) > (7.0 + x_27)? (16.0 + x_26) : (7.0 + x_27))))); x_1_ = ((((14.0 + x_0) > ((6.0 + x_2) > (11.0 + x_5)? (6.0 + x_2) : (11.0 + x_5))? (14.0 + x_0) : ((6.0 + x_2) > (11.0 + x_5)? (6.0 + x_2) : (11.0 + x_5))) > (((7.0 + x_7) > (3.0 + x_8)? (7.0 + x_7) : (3.0 + x_8)) > ((2.0 + x_9) > (17.0 + x_10)? (2.0 + x_9) : (17.0 + x_10))? ((7.0 + x_7) > (3.0 + x_8)? (7.0 + x_7) : (3.0 + x_8)) : ((2.0 + x_9) > (17.0 + x_10)? (2.0 + x_9) : (17.0 + x_10)))? ((14.0 + x_0) > ((6.0 + x_2) > (11.0 + x_5)? (6.0 + x_2) : (11.0 + x_5))? (14.0 + x_0) : ((6.0 + x_2) > (11.0 + x_5)? (6.0 + x_2) : (11.0 + x_5))) : (((7.0 + x_7) > (3.0 + x_8)? (7.0 + x_7) : (3.0 + x_8)) > ((2.0 + x_9) > (17.0 + x_10)? (2.0 + x_9) : (17.0 + x_10))? ((7.0 + x_7) > (3.0 + x_8)? (7.0 + x_7) : (3.0 + x_8)) : ((2.0 + x_9) > (17.0 + x_10)? (2.0 + x_9) : (17.0 + x_10)))) > (((5.0 + x_15) > ((17.0 + x_17) > (17.0 + x_18)? (17.0 + x_17) : (17.0 + x_18))? (5.0 + x_15) : ((17.0 + x_17) > (17.0 + x_18)? (17.0 + x_17) : (17.0 + x_18))) > (((8.0 + x_21) > (17.0 + x_23)? (8.0 + x_21) : (17.0 + x_23)) > ((18.0 + x_25) > (5.0 + x_26)? (18.0 + x_25) : (5.0 + x_26))? ((8.0 + x_21) > (17.0 + x_23)? (8.0 + x_21) : (17.0 + x_23)) : ((18.0 + x_25) > (5.0 + x_26)? (18.0 + x_25) : (5.0 + x_26)))? ((5.0 + x_15) > ((17.0 + x_17) > (17.0 + x_18)? (17.0 + x_17) : (17.0 + x_18))? (5.0 + x_15) : ((17.0 + x_17) > (17.0 + x_18)? (17.0 + x_17) : (17.0 + x_18))) : (((8.0 + x_21) > (17.0 + x_23)? (8.0 + x_21) : (17.0 + x_23)) > ((18.0 + x_25) > (5.0 + x_26)? (18.0 + x_25) : (5.0 + x_26))? ((8.0 + x_21) > (17.0 + x_23)? (8.0 + x_21) : (17.0 + x_23)) : ((18.0 + x_25) > (5.0 + x_26)? (18.0 + x_25) : (5.0 + x_26))))? (((14.0 + x_0) > ((6.0 + x_2) > (11.0 + x_5)? (6.0 + x_2) : (11.0 + x_5))? (14.0 + x_0) : ((6.0 + x_2) > (11.0 + x_5)? (6.0 + x_2) : (11.0 + x_5))) > (((7.0 + x_7) > (3.0 + x_8)? (7.0 + x_7) : (3.0 + x_8)) > ((2.0 + x_9) > (17.0 + x_10)? (2.0 + x_9) : (17.0 + x_10))? ((7.0 + x_7) > (3.0 + x_8)? (7.0 + x_7) : (3.0 + x_8)) : ((2.0 + x_9) > (17.0 + x_10)? (2.0 + x_9) : (17.0 + x_10)))? ((14.0 + x_0) > ((6.0 + x_2) > (11.0 + x_5)? (6.0 + x_2) : (11.0 + x_5))? (14.0 + x_0) : ((6.0 + x_2) > (11.0 + x_5)? (6.0 + x_2) : (11.0 + x_5))) : (((7.0 + x_7) > (3.0 + x_8)? (7.0 + x_7) : (3.0 + x_8)) > ((2.0 + x_9) > (17.0 + x_10)? (2.0 + x_9) : (17.0 + x_10))? ((7.0 + x_7) > (3.0 + x_8)? (7.0 + x_7) : (3.0 + x_8)) : ((2.0 + x_9) > (17.0 + x_10)? (2.0 + x_9) : (17.0 + x_10)))) : (((5.0 + x_15) > ((17.0 + x_17) > (17.0 + x_18)? (17.0 + x_17) : (17.0 + x_18))? (5.0 + x_15) : ((17.0 + x_17) > (17.0 + x_18)? (17.0 + x_17) : (17.0 + x_18))) > (((8.0 + x_21) > (17.0 + x_23)? (8.0 + x_21) : (17.0 + x_23)) > ((18.0 + x_25) > (5.0 + x_26)? (18.0 + x_25) : (5.0 + x_26))? ((8.0 + x_21) > (17.0 + x_23)? (8.0 + x_21) : (17.0 + x_23)) : ((18.0 + x_25) > (5.0 + x_26)? (18.0 + x_25) : (5.0 + x_26)))? ((5.0 + x_15) > ((17.0 + x_17) > (17.0 + x_18)? (17.0 + x_17) : (17.0 + x_18))? (5.0 + x_15) : ((17.0 + x_17) > (17.0 + x_18)? (17.0 + x_17) : (17.0 + x_18))) : (((8.0 + x_21) > (17.0 + x_23)? (8.0 + x_21) : (17.0 + x_23)) > ((18.0 + x_25) > (5.0 + x_26)? (18.0 + x_25) : (5.0 + x_26))? ((8.0 + x_21) > (17.0 + x_23)? (8.0 + x_21) : (17.0 + x_23)) : ((18.0 + x_25) > (5.0 + x_26)? (18.0 + x_25) : (5.0 + x_26))))); x_2_ = ((((8.0 + x_1) > ((11.0 + x_4) > (11.0 + x_10)? (11.0 + x_4) : (11.0 + x_10))? (8.0 + x_1) : ((11.0 + x_4) > (11.0 + x_10)? (11.0 + x_4) : (11.0 + x_10))) > (((5.0 + x_11) > (19.0 + x_12)? (5.0 + x_11) : (19.0 + x_12)) > ((2.0 + x_14) > (9.0 + x_15)? (2.0 + x_14) : (9.0 + x_15))? ((5.0 + x_11) > (19.0 + x_12)? (5.0 + x_11) : (19.0 + x_12)) : ((2.0 + x_14) > (9.0 + x_15)? (2.0 + x_14) : (9.0 + x_15)))? ((8.0 + x_1) > ((11.0 + x_4) > (11.0 + x_10)? (11.0 + x_4) : (11.0 + x_10))? (8.0 + x_1) : ((11.0 + x_4) > (11.0 + x_10)? (11.0 + x_4) : (11.0 + x_10))) : (((5.0 + x_11) > (19.0 + x_12)? (5.0 + x_11) : (19.0 + x_12)) > ((2.0 + x_14) > (9.0 + x_15)? (2.0 + x_14) : (9.0 + x_15))? ((5.0 + x_11) > (19.0 + x_12)? (5.0 + x_11) : (19.0 + x_12)) : ((2.0 + x_14) > (9.0 + x_15)? (2.0 + x_14) : (9.0 + x_15)))) > (((2.0 + x_17) > ((1.0 + x_18) > (14.0 + x_19)? (1.0 + x_18) : (14.0 + x_19))? (2.0 + x_17) : ((1.0 + x_18) > (14.0 + x_19)? (1.0 + x_18) : (14.0 + x_19))) > (((17.0 + x_20) > (1.0 + x_22)? (17.0 + x_20) : (1.0 + x_22)) > ((7.0 + x_26) > (18.0 + x_27)? (7.0 + x_26) : (18.0 + x_27))? ((17.0 + x_20) > (1.0 + x_22)? (17.0 + x_20) : (1.0 + x_22)) : ((7.0 + x_26) > (18.0 + x_27)? (7.0 + x_26) : (18.0 + x_27)))? ((2.0 + x_17) > ((1.0 + x_18) > (14.0 + x_19)? (1.0 + x_18) : (14.0 + x_19))? (2.0 + x_17) : ((1.0 + x_18) > (14.0 + x_19)? (1.0 + x_18) : (14.0 + x_19))) : (((17.0 + x_20) > (1.0 + x_22)? (17.0 + x_20) : (1.0 + x_22)) > ((7.0 + x_26) > (18.0 + x_27)? (7.0 + x_26) : (18.0 + x_27))? ((17.0 + x_20) > (1.0 + x_22)? (17.0 + x_20) : (1.0 + x_22)) : ((7.0 + x_26) > (18.0 + x_27)? (7.0 + x_26) : (18.0 + x_27))))? (((8.0 + x_1) > ((11.0 + x_4) > (11.0 + x_10)? (11.0 + x_4) : (11.0 + x_10))? (8.0 + x_1) : ((11.0 + x_4) > (11.0 + x_10)? (11.0 + x_4) : (11.0 + x_10))) > (((5.0 + x_11) > (19.0 + x_12)? (5.0 + x_11) : (19.0 + x_12)) > ((2.0 + x_14) > (9.0 + x_15)? (2.0 + x_14) : (9.0 + x_15))? ((5.0 + x_11) > (19.0 + x_12)? (5.0 + x_11) : (19.0 + x_12)) : ((2.0 + x_14) > (9.0 + x_15)? (2.0 + x_14) : (9.0 + x_15)))? ((8.0 + x_1) > ((11.0 + x_4) > (11.0 + x_10)? (11.0 + x_4) : (11.0 + x_10))? (8.0 + x_1) : ((11.0 + x_4) > (11.0 + x_10)? (11.0 + x_4) : (11.0 + x_10))) : (((5.0 + x_11) > (19.0 + x_12)? (5.0 + x_11) : (19.0 + x_12)) > ((2.0 + x_14) > (9.0 + x_15)? (2.0 + x_14) : (9.0 + x_15))? ((5.0 + x_11) > (19.0 + x_12)? (5.0 + x_11) : (19.0 + x_12)) : ((2.0 + x_14) > (9.0 + x_15)? (2.0 + x_14) : (9.0 + x_15)))) : (((2.0 + x_17) > ((1.0 + x_18) > (14.0 + x_19)? (1.0 + x_18) : (14.0 + x_19))? (2.0 + x_17) : ((1.0 + x_18) > (14.0 + x_19)? (1.0 + x_18) : (14.0 + x_19))) > (((17.0 + x_20) > (1.0 + x_22)? (17.0 + x_20) : (1.0 + x_22)) > ((7.0 + x_26) > (18.0 + x_27)? (7.0 + x_26) : (18.0 + x_27))? ((17.0 + x_20) > (1.0 + x_22)? (17.0 + x_20) : (1.0 + x_22)) : ((7.0 + x_26) > (18.0 + x_27)? (7.0 + x_26) : (18.0 + x_27)))? ((2.0 + x_17) > ((1.0 + x_18) > (14.0 + x_19)? (1.0 + x_18) : (14.0 + x_19))? (2.0 + x_17) : ((1.0 + x_18) > (14.0 + x_19)? (1.0 + x_18) : (14.0 + x_19))) : (((17.0 + x_20) > (1.0 + x_22)? (17.0 + x_20) : (1.0 + x_22)) > ((7.0 + x_26) > (18.0 + x_27)? (7.0 + x_26) : (18.0 + x_27))? ((17.0 + x_20) > (1.0 + x_22)? (17.0 + x_20) : (1.0 + x_22)) : ((7.0 + x_26) > (18.0 + x_27)? (7.0 + x_26) : (18.0 + x_27))))); x_3_ = ((((16.0 + x_0) > ((18.0 + x_5) > (3.0 + x_6)? (18.0 + x_5) : (3.0 + x_6))? (16.0 + x_0) : ((18.0 + x_5) > (3.0 + x_6)? (18.0 + x_5) : (3.0 + x_6))) > (((11.0 + x_7) > (4.0 + x_8)? (11.0 + x_7) : (4.0 + x_8)) > ((9.0 + x_11) > (10.0 + x_14)? (9.0 + x_11) : (10.0 + x_14))? ((11.0 + x_7) > (4.0 + x_8)? (11.0 + x_7) : (4.0 + x_8)) : ((9.0 + x_11) > (10.0 + x_14)? (9.0 + x_11) : (10.0 + x_14)))? ((16.0 + x_0) > ((18.0 + x_5) > (3.0 + x_6)? (18.0 + x_5) : (3.0 + x_6))? (16.0 + x_0) : ((18.0 + x_5) > (3.0 + x_6)? (18.0 + x_5) : (3.0 + x_6))) : (((11.0 + x_7) > (4.0 + x_8)? (11.0 + x_7) : (4.0 + x_8)) > ((9.0 + x_11) > (10.0 + x_14)? (9.0 + x_11) : (10.0 + x_14))? ((11.0 + x_7) > (4.0 + x_8)? (11.0 + x_7) : (4.0 + x_8)) : ((9.0 + x_11) > (10.0 + x_14)? (9.0 + x_11) : (10.0 + x_14)))) > (((3.0 + x_15) > ((16.0 + x_17) > (16.0 + x_20)? (16.0 + x_17) : (16.0 + x_20))? (3.0 + x_15) : ((16.0 + x_17) > (16.0 + x_20)? (16.0 + x_17) : (16.0 + x_20))) > (((5.0 + x_21) > (8.0 + x_22)? (5.0 + x_21) : (8.0 + x_22)) > ((9.0 + x_24) > (18.0 + x_26)? (9.0 + x_24) : (18.0 + x_26))? ((5.0 + x_21) > (8.0 + x_22)? (5.0 + x_21) : (8.0 + x_22)) : ((9.0 + x_24) > (18.0 + x_26)? (9.0 + x_24) : (18.0 + x_26)))? ((3.0 + x_15) > ((16.0 + x_17) > (16.0 + x_20)? (16.0 + x_17) : (16.0 + x_20))? (3.0 + x_15) : ((16.0 + x_17) > (16.0 + x_20)? (16.0 + x_17) : (16.0 + x_20))) : (((5.0 + x_21) > (8.0 + x_22)? (5.0 + x_21) : (8.0 + x_22)) > ((9.0 + x_24) > (18.0 + x_26)? (9.0 + x_24) : (18.0 + x_26))? ((5.0 + x_21) > (8.0 + x_22)? (5.0 + x_21) : (8.0 + x_22)) : ((9.0 + x_24) > (18.0 + x_26)? (9.0 + x_24) : (18.0 + x_26))))? (((16.0 + x_0) > ((18.0 + x_5) > (3.0 + x_6)? (18.0 + x_5) : (3.0 + x_6))? (16.0 + x_0) : ((18.0 + x_5) > (3.0 + x_6)? (18.0 + x_5) : (3.0 + x_6))) > (((11.0 + x_7) > (4.0 + x_8)? (11.0 + x_7) : (4.0 + x_8)) > ((9.0 + x_11) > (10.0 + x_14)? (9.0 + x_11) : (10.0 + x_14))? ((11.0 + x_7) > (4.0 + x_8)? (11.0 + x_7) : (4.0 + x_8)) : ((9.0 + x_11) > (10.0 + x_14)? (9.0 + x_11) : (10.0 + x_14)))? ((16.0 + x_0) > ((18.0 + x_5) > (3.0 + x_6)? (18.0 + x_5) : (3.0 + x_6))? (16.0 + x_0) : ((18.0 + x_5) > (3.0 + x_6)? (18.0 + x_5) : (3.0 + x_6))) : (((11.0 + x_7) > (4.0 + x_8)? (11.0 + x_7) : (4.0 + x_8)) > ((9.0 + x_11) > (10.0 + x_14)? (9.0 + x_11) : (10.0 + x_14))? ((11.0 + x_7) > (4.0 + x_8)? (11.0 + x_7) : (4.0 + x_8)) : ((9.0 + x_11) > (10.0 + x_14)? (9.0 + x_11) : (10.0 + x_14)))) : (((3.0 + x_15) > ((16.0 + x_17) > (16.0 + x_20)? (16.0 + x_17) : (16.0 + x_20))? (3.0 + x_15) : ((16.0 + x_17) > (16.0 + x_20)? (16.0 + x_17) : (16.0 + x_20))) > (((5.0 + x_21) > (8.0 + x_22)? (5.0 + x_21) : (8.0 + x_22)) > ((9.0 + x_24) > (18.0 + x_26)? (9.0 + x_24) : (18.0 + x_26))? ((5.0 + x_21) > (8.0 + x_22)? (5.0 + x_21) : (8.0 + x_22)) : ((9.0 + x_24) > (18.0 + x_26)? (9.0 + x_24) : (18.0 + x_26)))? ((3.0 + x_15) > ((16.0 + x_17) > (16.0 + x_20)? (16.0 + x_17) : (16.0 + x_20))? (3.0 + x_15) : ((16.0 + x_17) > (16.0 + x_20)? (16.0 + x_17) : (16.0 + x_20))) : (((5.0 + x_21) > (8.0 + x_22)? (5.0 + x_21) : (8.0 + x_22)) > ((9.0 + x_24) > (18.0 + x_26)? (9.0 + x_24) : (18.0 + x_26))? ((5.0 + x_21) > (8.0 + x_22)? (5.0 + x_21) : (8.0 + x_22)) : ((9.0 + x_24) > (18.0 + x_26)? (9.0 + x_24) : (18.0 + x_26))))); x_4_ = ((((14.0 + x_2) > ((4.0 + x_3) > (20.0 + x_5)? (4.0 + x_3) : (20.0 + x_5))? (14.0 + x_2) : ((4.0 + x_3) > (20.0 + x_5)? (4.0 + x_3) : (20.0 + x_5))) > (((2.0 + x_7) > (13.0 + x_9)? (2.0 + x_7) : (13.0 + x_9)) > ((10.0 + x_14) > (17.0 + x_15)? (10.0 + x_14) : (17.0 + x_15))? ((2.0 + x_7) > (13.0 + x_9)? (2.0 + x_7) : (13.0 + x_9)) : ((10.0 + x_14) > (17.0 + x_15)? (10.0 + x_14) : (17.0 + x_15)))? ((14.0 + x_2) > ((4.0 + x_3) > (20.0 + x_5)? (4.0 + x_3) : (20.0 + x_5))? (14.0 + x_2) : ((4.0 + x_3) > (20.0 + x_5)? (4.0 + x_3) : (20.0 + x_5))) : (((2.0 + x_7) > (13.0 + x_9)? (2.0 + x_7) : (13.0 + x_9)) > ((10.0 + x_14) > (17.0 + x_15)? (10.0 + x_14) : (17.0 + x_15))? ((2.0 + x_7) > (13.0 + x_9)? (2.0 + x_7) : (13.0 + x_9)) : ((10.0 + x_14) > (17.0 + x_15)? (10.0 + x_14) : (17.0 + x_15)))) > (((8.0 + x_18) > ((2.0 + x_19) > (10.0 + x_20)? (2.0 + x_19) : (10.0 + x_20))? (8.0 + x_18) : ((2.0 + x_19) > (10.0 + x_20)? (2.0 + x_19) : (10.0 + x_20))) > (((18.0 + x_21) > (19.0 + x_22)? (18.0 + x_21) : (19.0 + x_22)) > ((14.0 + x_23) > (12.0 + x_25)? (14.0 + x_23) : (12.0 + x_25))? ((18.0 + x_21) > (19.0 + x_22)? (18.0 + x_21) : (19.0 + x_22)) : ((14.0 + x_23) > (12.0 + x_25)? (14.0 + x_23) : (12.0 + x_25)))? ((8.0 + x_18) > ((2.0 + x_19) > (10.0 + x_20)? (2.0 + x_19) : (10.0 + x_20))? (8.0 + x_18) : ((2.0 + x_19) > (10.0 + x_20)? (2.0 + x_19) : (10.0 + x_20))) : (((18.0 + x_21) > (19.0 + x_22)? (18.0 + x_21) : (19.0 + x_22)) > ((14.0 + x_23) > (12.0 + x_25)? (14.0 + x_23) : (12.0 + x_25))? ((18.0 + x_21) > (19.0 + x_22)? (18.0 + x_21) : (19.0 + x_22)) : ((14.0 + x_23) > (12.0 + x_25)? (14.0 + x_23) : (12.0 + x_25))))? (((14.0 + x_2) > ((4.0 + x_3) > (20.0 + x_5)? (4.0 + x_3) : (20.0 + x_5))? (14.0 + x_2) : ((4.0 + x_3) > (20.0 + x_5)? (4.0 + x_3) : (20.0 + x_5))) > (((2.0 + x_7) > (13.0 + x_9)? (2.0 + x_7) : (13.0 + x_9)) > ((10.0 + x_14) > (17.0 + x_15)? (10.0 + x_14) : (17.0 + x_15))? ((2.0 + x_7) > (13.0 + x_9)? (2.0 + x_7) : (13.0 + x_9)) : ((10.0 + x_14) > (17.0 + x_15)? (10.0 + x_14) : (17.0 + x_15)))? ((14.0 + x_2) > ((4.0 + x_3) > (20.0 + x_5)? (4.0 + x_3) : (20.0 + x_5))? (14.0 + x_2) : ((4.0 + x_3) > (20.0 + x_5)? (4.0 + x_3) : (20.0 + x_5))) : (((2.0 + x_7) > (13.0 + x_9)? (2.0 + x_7) : (13.0 + x_9)) > ((10.0 + x_14) > (17.0 + x_15)? (10.0 + x_14) : (17.0 + x_15))? ((2.0 + x_7) > (13.0 + x_9)? (2.0 + x_7) : (13.0 + x_9)) : ((10.0 + x_14) > (17.0 + x_15)? (10.0 + x_14) : (17.0 + x_15)))) : (((8.0 + x_18) > ((2.0 + x_19) > (10.0 + x_20)? (2.0 + x_19) : (10.0 + x_20))? (8.0 + x_18) : ((2.0 + x_19) > (10.0 + x_20)? (2.0 + x_19) : (10.0 + x_20))) > (((18.0 + x_21) > (19.0 + x_22)? (18.0 + x_21) : (19.0 + x_22)) > ((14.0 + x_23) > (12.0 + x_25)? (14.0 + x_23) : (12.0 + x_25))? ((18.0 + x_21) > (19.0 + x_22)? (18.0 + x_21) : (19.0 + x_22)) : ((14.0 + x_23) > (12.0 + x_25)? (14.0 + x_23) : (12.0 + x_25)))? ((8.0 + x_18) > ((2.0 + x_19) > (10.0 + x_20)? (2.0 + x_19) : (10.0 + x_20))? (8.0 + x_18) : ((2.0 + x_19) > (10.0 + x_20)? (2.0 + x_19) : (10.0 + x_20))) : (((18.0 + x_21) > (19.0 + x_22)? (18.0 + x_21) : (19.0 + x_22)) > ((14.0 + x_23) > (12.0 + x_25)? (14.0 + x_23) : (12.0 + x_25))? ((18.0 + x_21) > (19.0 + x_22)? (18.0 + x_21) : (19.0 + x_22)) : ((14.0 + x_23) > (12.0 + x_25)? (14.0 + x_23) : (12.0 + x_25))))); x_5_ = ((((2.0 + x_1) > ((2.0 + x_6) > (5.0 + x_8)? (2.0 + x_6) : (5.0 + x_8))? (2.0 + x_1) : ((2.0 + x_6) > (5.0 + x_8)? (2.0 + x_6) : (5.0 + x_8))) > (((17.0 + x_9) > (5.0 + x_11)? (17.0 + x_9) : (5.0 + x_11)) > ((1.0 + x_13) > (17.0 + x_15)? (1.0 + x_13) : (17.0 + x_15))? ((17.0 + x_9) > (5.0 + x_11)? (17.0 + x_9) : (5.0 + x_11)) : ((1.0 + x_13) > (17.0 + x_15)? (1.0 + x_13) : (17.0 + x_15)))? ((2.0 + x_1) > ((2.0 + x_6) > (5.0 + x_8)? (2.0 + x_6) : (5.0 + x_8))? (2.0 + x_1) : ((2.0 + x_6) > (5.0 + x_8)? (2.0 + x_6) : (5.0 + x_8))) : (((17.0 + x_9) > (5.0 + x_11)? (17.0 + x_9) : (5.0 + x_11)) > ((1.0 + x_13) > (17.0 + x_15)? (1.0 + x_13) : (17.0 + x_15))? ((17.0 + x_9) > (5.0 + x_11)? (17.0 + x_9) : (5.0 + x_11)) : ((1.0 + x_13) > (17.0 + x_15)? (1.0 + x_13) : (17.0 + x_15)))) > (((16.0 + x_17) > ((1.0 + x_18) > (3.0 + x_19)? (1.0 + x_18) : (3.0 + x_19))? (16.0 + x_17) : ((1.0 + x_18) > (3.0 + x_19)? (1.0 + x_18) : (3.0 + x_19))) > (((9.0 + x_20) > (16.0 + x_23)? (9.0 + x_20) : (16.0 + x_23)) > ((5.0 + x_24) > (8.0 + x_25)? (5.0 + x_24) : (8.0 + x_25))? ((9.0 + x_20) > (16.0 + x_23)? (9.0 + x_20) : (16.0 + x_23)) : ((5.0 + x_24) > (8.0 + x_25)? (5.0 + x_24) : (8.0 + x_25)))? ((16.0 + x_17) > ((1.0 + x_18) > (3.0 + x_19)? (1.0 + x_18) : (3.0 + x_19))? (16.0 + x_17) : ((1.0 + x_18) > (3.0 + x_19)? (1.0 + x_18) : (3.0 + x_19))) : (((9.0 + x_20) > (16.0 + x_23)? (9.0 + x_20) : (16.0 + x_23)) > ((5.0 + x_24) > (8.0 + x_25)? (5.0 + x_24) : (8.0 + x_25))? ((9.0 + x_20) > (16.0 + x_23)? (9.0 + x_20) : (16.0 + x_23)) : ((5.0 + x_24) > (8.0 + x_25)? (5.0 + x_24) : (8.0 + x_25))))? (((2.0 + x_1) > ((2.0 + x_6) > (5.0 + x_8)? (2.0 + x_6) : (5.0 + x_8))? (2.0 + x_1) : ((2.0 + x_6) > (5.0 + x_8)? (2.0 + x_6) : (5.0 + x_8))) > (((17.0 + x_9) > (5.0 + x_11)? (17.0 + x_9) : (5.0 + x_11)) > ((1.0 + x_13) > (17.0 + x_15)? (1.0 + x_13) : (17.0 + x_15))? ((17.0 + x_9) > (5.0 + x_11)? (17.0 + x_9) : (5.0 + x_11)) : ((1.0 + x_13) > (17.0 + x_15)? (1.0 + x_13) : (17.0 + x_15)))? ((2.0 + x_1) > ((2.0 + x_6) > (5.0 + x_8)? (2.0 + x_6) : (5.0 + x_8))? (2.0 + x_1) : ((2.0 + x_6) > (5.0 + x_8)? (2.0 + x_6) : (5.0 + x_8))) : (((17.0 + x_9) > (5.0 + x_11)? (17.0 + x_9) : (5.0 + x_11)) > ((1.0 + x_13) > (17.0 + x_15)? (1.0 + x_13) : (17.0 + x_15))? ((17.0 + x_9) > (5.0 + x_11)? (17.0 + x_9) : (5.0 + x_11)) : ((1.0 + x_13) > (17.0 + x_15)? (1.0 + x_13) : (17.0 + x_15)))) : (((16.0 + x_17) > ((1.0 + x_18) > (3.0 + x_19)? (1.0 + x_18) : (3.0 + x_19))? (16.0 + x_17) : ((1.0 + x_18) > (3.0 + x_19)? (1.0 + x_18) : (3.0 + x_19))) > (((9.0 + x_20) > (16.0 + x_23)? (9.0 + x_20) : (16.0 + x_23)) > ((5.0 + x_24) > (8.0 + x_25)? (5.0 + x_24) : (8.0 + x_25))? ((9.0 + x_20) > (16.0 + x_23)? (9.0 + x_20) : (16.0 + x_23)) : ((5.0 + x_24) > (8.0 + x_25)? (5.0 + x_24) : (8.0 + x_25)))? ((16.0 + x_17) > ((1.0 + x_18) > (3.0 + x_19)? (1.0 + x_18) : (3.0 + x_19))? (16.0 + x_17) : ((1.0 + x_18) > (3.0 + x_19)? (1.0 + x_18) : (3.0 + x_19))) : (((9.0 + x_20) > (16.0 + x_23)? (9.0 + x_20) : (16.0 + x_23)) > ((5.0 + x_24) > (8.0 + x_25)? (5.0 + x_24) : (8.0 + x_25))? ((9.0 + x_20) > (16.0 + x_23)? (9.0 + x_20) : (16.0 + x_23)) : ((5.0 + x_24) > (8.0 + x_25)? (5.0 + x_24) : (8.0 + x_25))))); x_6_ = ((((5.0 + x_0) > ((4.0 + x_1) > (6.0 + x_3)? (4.0 + x_1) : (6.0 + x_3))? (5.0 + x_0) : ((4.0 + x_1) > (6.0 + x_3)? (4.0 + x_1) : (6.0 + x_3))) > (((20.0 + x_4) > (9.0 + x_6)? (20.0 + x_4) : (9.0 + x_6)) > ((3.0 + x_10) > (20.0 + x_12)? (3.0 + x_10) : (20.0 + x_12))? ((20.0 + x_4) > (9.0 + x_6)? (20.0 + x_4) : (9.0 + x_6)) : ((3.0 + x_10) > (20.0 + x_12)? (3.0 + x_10) : (20.0 + x_12)))? ((5.0 + x_0) > ((4.0 + x_1) > (6.0 + x_3)? (4.0 + x_1) : (6.0 + x_3))? (5.0 + x_0) : ((4.0 + x_1) > (6.0 + x_3)? (4.0 + x_1) : (6.0 + x_3))) : (((20.0 + x_4) > (9.0 + x_6)? (20.0 + x_4) : (9.0 + x_6)) > ((3.0 + x_10) > (20.0 + x_12)? (3.0 + x_10) : (20.0 + x_12))? ((20.0 + x_4) > (9.0 + x_6)? (20.0 + x_4) : (9.0 + x_6)) : ((3.0 + x_10) > (20.0 + x_12)? (3.0 + x_10) : (20.0 + x_12)))) > (((8.0 + x_14) > ((4.0 + x_18) > (18.0 + x_21)? (4.0 + x_18) : (18.0 + x_21))? (8.0 + x_14) : ((4.0 + x_18) > (18.0 + x_21)? (4.0 + x_18) : (18.0 + x_21))) > (((19.0 + x_24) > (2.0 + x_25)? (19.0 + x_24) : (2.0 + x_25)) > ((13.0 + x_26) > (8.0 + x_27)? (13.0 + x_26) : (8.0 + x_27))? ((19.0 + x_24) > (2.0 + x_25)? (19.0 + x_24) : (2.0 + x_25)) : ((13.0 + x_26) > (8.0 + x_27)? (13.0 + x_26) : (8.0 + x_27)))? ((8.0 + x_14) > ((4.0 + x_18) > (18.0 + x_21)? (4.0 + x_18) : (18.0 + x_21))? (8.0 + x_14) : ((4.0 + x_18) > (18.0 + x_21)? (4.0 + x_18) : (18.0 + x_21))) : (((19.0 + x_24) > (2.0 + x_25)? (19.0 + x_24) : (2.0 + x_25)) > ((13.0 + x_26) > (8.0 + x_27)? (13.0 + x_26) : (8.0 + x_27))? ((19.0 + x_24) > (2.0 + x_25)? (19.0 + x_24) : (2.0 + x_25)) : ((13.0 + x_26) > (8.0 + x_27)? (13.0 + x_26) : (8.0 + x_27))))? (((5.0 + x_0) > ((4.0 + x_1) > (6.0 + x_3)? (4.0 + x_1) : (6.0 + x_3))? (5.0 + x_0) : ((4.0 + x_1) > (6.0 + x_3)? (4.0 + x_1) : (6.0 + x_3))) > (((20.0 + x_4) > (9.0 + x_6)? (20.0 + x_4) : (9.0 + x_6)) > ((3.0 + x_10) > (20.0 + x_12)? (3.0 + x_10) : (20.0 + x_12))? ((20.0 + x_4) > (9.0 + x_6)? (20.0 + x_4) : (9.0 + x_6)) : ((3.0 + x_10) > (20.0 + x_12)? (3.0 + x_10) : (20.0 + x_12)))? ((5.0 + x_0) > ((4.0 + x_1) > (6.0 + x_3)? (4.0 + x_1) : (6.0 + x_3))? (5.0 + x_0) : ((4.0 + x_1) > (6.0 + x_3)? (4.0 + x_1) : (6.0 + x_3))) : (((20.0 + x_4) > (9.0 + x_6)? (20.0 + x_4) : (9.0 + x_6)) > ((3.0 + x_10) > (20.0 + x_12)? (3.0 + x_10) : (20.0 + x_12))? ((20.0 + x_4) > (9.0 + x_6)? (20.0 + x_4) : (9.0 + x_6)) : ((3.0 + x_10) > (20.0 + x_12)? (3.0 + x_10) : (20.0 + x_12)))) : (((8.0 + x_14) > ((4.0 + x_18) > (18.0 + x_21)? (4.0 + x_18) : (18.0 + x_21))? (8.0 + x_14) : ((4.0 + x_18) > (18.0 + x_21)? (4.0 + x_18) : (18.0 + x_21))) > (((19.0 + x_24) > (2.0 + x_25)? (19.0 + x_24) : (2.0 + x_25)) > ((13.0 + x_26) > (8.0 + x_27)? (13.0 + x_26) : (8.0 + x_27))? ((19.0 + x_24) > (2.0 + x_25)? (19.0 + x_24) : (2.0 + x_25)) : ((13.0 + x_26) > (8.0 + x_27)? (13.0 + x_26) : (8.0 + x_27)))? ((8.0 + x_14) > ((4.0 + x_18) > (18.0 + x_21)? (4.0 + x_18) : (18.0 + x_21))? (8.0 + x_14) : ((4.0 + x_18) > (18.0 + x_21)? (4.0 + x_18) : (18.0 + x_21))) : (((19.0 + x_24) > (2.0 + x_25)? (19.0 + x_24) : (2.0 + x_25)) > ((13.0 + x_26) > (8.0 + x_27)? (13.0 + x_26) : (8.0 + x_27))? ((19.0 + x_24) > (2.0 + x_25)? (19.0 + x_24) : (2.0 + x_25)) : ((13.0 + x_26) > (8.0 + x_27)? (13.0 + x_26) : (8.0 + x_27))))); x_7_ = ((((6.0 + x_1) > ((17.0 + x_3) > (4.0 + x_4)? (17.0 + x_3) : (4.0 + x_4))? (6.0 + x_1) : ((17.0 + x_3) > (4.0 + x_4)? (17.0 + x_3) : (4.0 + x_4))) > (((20.0 + x_5) > (20.0 + x_6)? (20.0 + x_5) : (20.0 + x_6)) > ((12.0 + x_10) > (19.0 + x_11)? (12.0 + x_10) : (19.0 + x_11))? ((20.0 + x_5) > (20.0 + x_6)? (20.0 + x_5) : (20.0 + x_6)) : ((12.0 + x_10) > (19.0 + x_11)? (12.0 + x_10) : (19.0 + x_11)))? ((6.0 + x_1) > ((17.0 + x_3) > (4.0 + x_4)? (17.0 + x_3) : (4.0 + x_4))? (6.0 + x_1) : ((17.0 + x_3) > (4.0 + x_4)? (17.0 + x_3) : (4.0 + x_4))) : (((20.0 + x_5) > (20.0 + x_6)? (20.0 + x_5) : (20.0 + x_6)) > ((12.0 + x_10) > (19.0 + x_11)? (12.0 + x_10) : (19.0 + x_11))? ((20.0 + x_5) > (20.0 + x_6)? (20.0 + x_5) : (20.0 + x_6)) : ((12.0 + x_10) > (19.0 + x_11)? (12.0 + x_10) : (19.0 + x_11)))) > (((13.0 + x_12) > ((3.0 + x_14) > (14.0 + x_16)? (3.0 + x_14) : (14.0 + x_16))? (13.0 + x_12) : ((3.0 + x_14) > (14.0 + x_16)? (3.0 + x_14) : (14.0 + x_16))) > (((12.0 + x_21) > (14.0 + x_22)? (12.0 + x_21) : (14.0 + x_22)) > ((10.0 + x_24) > (10.0 + x_26)? (10.0 + x_24) : (10.0 + x_26))? ((12.0 + x_21) > (14.0 + x_22)? (12.0 + x_21) : (14.0 + x_22)) : ((10.0 + x_24) > (10.0 + x_26)? (10.0 + x_24) : (10.0 + x_26)))? ((13.0 + x_12) > ((3.0 + x_14) > (14.0 + x_16)? (3.0 + x_14) : (14.0 + x_16))? (13.0 + x_12) : ((3.0 + x_14) > (14.0 + x_16)? (3.0 + x_14) : (14.0 + x_16))) : (((12.0 + x_21) > (14.0 + x_22)? (12.0 + x_21) : (14.0 + x_22)) > ((10.0 + x_24) > (10.0 + x_26)? (10.0 + x_24) : (10.0 + x_26))? ((12.0 + x_21) > (14.0 + x_22)? (12.0 + x_21) : (14.0 + x_22)) : ((10.0 + x_24) > (10.0 + x_26)? (10.0 + x_24) : (10.0 + x_26))))? (((6.0 + x_1) > ((17.0 + x_3) > (4.0 + x_4)? (17.0 + x_3) : (4.0 + x_4))? (6.0 + x_1) : ((17.0 + x_3) > (4.0 + x_4)? (17.0 + x_3) : (4.0 + x_4))) > (((20.0 + x_5) > (20.0 + x_6)? (20.0 + x_5) : (20.0 + x_6)) > ((12.0 + x_10) > (19.0 + x_11)? (12.0 + x_10) : (19.0 + x_11))? ((20.0 + x_5) > (20.0 + x_6)? (20.0 + x_5) : (20.0 + x_6)) : ((12.0 + x_10) > (19.0 + x_11)? (12.0 + x_10) : (19.0 + x_11)))? ((6.0 + x_1) > ((17.0 + x_3) > (4.0 + x_4)? (17.0 + x_3) : (4.0 + x_4))? (6.0 + x_1) : ((17.0 + x_3) > (4.0 + x_4)? (17.0 + x_3) : (4.0 + x_4))) : (((20.0 + x_5) > (20.0 + x_6)? (20.0 + x_5) : (20.0 + x_6)) > ((12.0 + x_10) > (19.0 + x_11)? (12.0 + x_10) : (19.0 + x_11))? ((20.0 + x_5) > (20.0 + x_6)? (20.0 + x_5) : (20.0 + x_6)) : ((12.0 + x_10) > (19.0 + x_11)? (12.0 + x_10) : (19.0 + x_11)))) : (((13.0 + x_12) > ((3.0 + x_14) > (14.0 + x_16)? (3.0 + x_14) : (14.0 + x_16))? (13.0 + x_12) : ((3.0 + x_14) > (14.0 + x_16)? (3.0 + x_14) : (14.0 + x_16))) > (((12.0 + x_21) > (14.0 + x_22)? (12.0 + x_21) : (14.0 + x_22)) > ((10.0 + x_24) > (10.0 + x_26)? (10.0 + x_24) : (10.0 + x_26))? ((12.0 + x_21) > (14.0 + x_22)? (12.0 + x_21) : (14.0 + x_22)) : ((10.0 + x_24) > (10.0 + x_26)? (10.0 + x_24) : (10.0 + x_26)))? ((13.0 + x_12) > ((3.0 + x_14) > (14.0 + x_16)? (3.0 + x_14) : (14.0 + x_16))? (13.0 + x_12) : ((3.0 + x_14) > (14.0 + x_16)? (3.0 + x_14) : (14.0 + x_16))) : (((12.0 + x_21) > (14.0 + x_22)? (12.0 + x_21) : (14.0 + x_22)) > ((10.0 + x_24) > (10.0 + x_26)? (10.0 + x_24) : (10.0 + x_26))? ((12.0 + x_21) > (14.0 + x_22)? (12.0 + x_21) : (14.0 + x_22)) : ((10.0 + x_24) > (10.0 + x_26)? (10.0 + x_24) : (10.0 + x_26))))); x_8_ = ((((6.0 + x_1) > ((12.0 + x_2) > (19.0 + x_5)? (12.0 + x_2) : (19.0 + x_5))? (6.0 + x_1) : ((12.0 + x_2) > (19.0 + x_5)? (12.0 + x_2) : (19.0 + x_5))) > (((19.0 + x_6) > (14.0 + x_11)? (19.0 + x_6) : (14.0 + x_11)) > ((14.0 + x_14) > (12.0 + x_16)? (14.0 + x_14) : (12.0 + x_16))? ((19.0 + x_6) > (14.0 + x_11)? (19.0 + x_6) : (14.0 + x_11)) : ((14.0 + x_14) > (12.0 + x_16)? (14.0 + x_14) : (12.0 + x_16)))? ((6.0 + x_1) > ((12.0 + x_2) > (19.0 + x_5)? (12.0 + x_2) : (19.0 + x_5))? (6.0 + x_1) : ((12.0 + x_2) > (19.0 + x_5)? (12.0 + x_2) : (19.0 + x_5))) : (((19.0 + x_6) > (14.0 + x_11)? (19.0 + x_6) : (14.0 + x_11)) > ((14.0 + x_14) > (12.0 + x_16)? (14.0 + x_14) : (12.0 + x_16))? ((19.0 + x_6) > (14.0 + x_11)? (19.0 + x_6) : (14.0 + x_11)) : ((14.0 + x_14) > (12.0 + x_16)? (14.0 + x_14) : (12.0 + x_16)))) > (((8.0 + x_17) > ((13.0 + x_18) > (4.0 + x_19)? (13.0 + x_18) : (4.0 + x_19))? (8.0 + x_17) : ((13.0 + x_18) > (4.0 + x_19)? (13.0 + x_18) : (4.0 + x_19))) > (((15.0 + x_22) > (18.0 + x_23)? (15.0 + x_22) : (18.0 + x_23)) > ((5.0 + x_25) > (1.0 + x_27)? (5.0 + x_25) : (1.0 + x_27))? ((15.0 + x_22) > (18.0 + x_23)? (15.0 + x_22) : (18.0 + x_23)) : ((5.0 + x_25) > (1.0 + x_27)? (5.0 + x_25) : (1.0 + x_27)))? ((8.0 + x_17) > ((13.0 + x_18) > (4.0 + x_19)? (13.0 + x_18) : (4.0 + x_19))? (8.0 + x_17) : ((13.0 + x_18) > (4.0 + x_19)? (13.0 + x_18) : (4.0 + x_19))) : (((15.0 + x_22) > (18.0 + x_23)? (15.0 + x_22) : (18.0 + x_23)) > ((5.0 + x_25) > (1.0 + x_27)? (5.0 + x_25) : (1.0 + x_27))? ((15.0 + x_22) > (18.0 + x_23)? (15.0 + x_22) : (18.0 + x_23)) : ((5.0 + x_25) > (1.0 + x_27)? (5.0 + x_25) : (1.0 + x_27))))? (((6.0 + x_1) > ((12.0 + x_2) > (19.0 + x_5)? (12.0 + x_2) : (19.0 + x_5))? (6.0 + x_1) : ((12.0 + x_2) > (19.0 + x_5)? (12.0 + x_2) : (19.0 + x_5))) > (((19.0 + x_6) > (14.0 + x_11)? (19.0 + x_6) : (14.0 + x_11)) > ((14.0 + x_14) > (12.0 + x_16)? (14.0 + x_14) : (12.0 + x_16))? ((19.0 + x_6) > (14.0 + x_11)? (19.0 + x_6) : (14.0 + x_11)) : ((14.0 + x_14) > (12.0 + x_16)? (14.0 + x_14) : (12.0 + x_16)))? ((6.0 + x_1) > ((12.0 + x_2) > (19.0 + x_5)? (12.0 + x_2) : (19.0 + x_5))? (6.0 + x_1) : ((12.0 + x_2) > (19.0 + x_5)? (12.0 + x_2) : (19.0 + x_5))) : (((19.0 + x_6) > (14.0 + x_11)? (19.0 + x_6) : (14.0 + x_11)) > ((14.0 + x_14) > (12.0 + x_16)? (14.0 + x_14) : (12.0 + x_16))? ((19.0 + x_6) > (14.0 + x_11)? (19.0 + x_6) : (14.0 + x_11)) : ((14.0 + x_14) > (12.0 + x_16)? (14.0 + x_14) : (12.0 + x_16)))) : (((8.0 + x_17) > ((13.0 + x_18) > (4.0 + x_19)? (13.0 + x_18) : (4.0 + x_19))? (8.0 + x_17) : ((13.0 + x_18) > (4.0 + x_19)? (13.0 + x_18) : (4.0 + x_19))) > (((15.0 + x_22) > (18.0 + x_23)? (15.0 + x_22) : (18.0 + x_23)) > ((5.0 + x_25) > (1.0 + x_27)? (5.0 + x_25) : (1.0 + x_27))? ((15.0 + x_22) > (18.0 + x_23)? (15.0 + x_22) : (18.0 + x_23)) : ((5.0 + x_25) > (1.0 + x_27)? (5.0 + x_25) : (1.0 + x_27)))? ((8.0 + x_17) > ((13.0 + x_18) > (4.0 + x_19)? (13.0 + x_18) : (4.0 + x_19))? (8.0 + x_17) : ((13.0 + x_18) > (4.0 + x_19)? (13.0 + x_18) : (4.0 + x_19))) : (((15.0 + x_22) > (18.0 + x_23)? (15.0 + x_22) : (18.0 + x_23)) > ((5.0 + x_25) > (1.0 + x_27)? (5.0 + x_25) : (1.0 + x_27))? ((15.0 + x_22) > (18.0 + x_23)? (15.0 + x_22) : (18.0 + x_23)) : ((5.0 + x_25) > (1.0 + x_27)? (5.0 + x_25) : (1.0 + x_27))))); x_9_ = ((((8.0 + x_4) > ((20.0 + x_5) > (17.0 + x_6)? (20.0 + x_5) : (17.0 + x_6))? (8.0 + x_4) : ((20.0 + x_5) > (17.0 + x_6)? (20.0 + x_5) : (17.0 + x_6))) > (((19.0 + x_11) > (2.0 + x_12)? (19.0 + x_11) : (2.0 + x_12)) > ((15.0 + x_13) > (8.0 + x_17)? (15.0 + x_13) : (8.0 + x_17))? ((19.0 + x_11) > (2.0 + x_12)? (19.0 + x_11) : (2.0 + x_12)) : ((15.0 + x_13) > (8.0 + x_17)? (15.0 + x_13) : (8.0 + x_17)))? ((8.0 + x_4) > ((20.0 + x_5) > (17.0 + x_6)? (20.0 + x_5) : (17.0 + x_6))? (8.0 + x_4) : ((20.0 + x_5) > (17.0 + x_6)? (20.0 + x_5) : (17.0 + x_6))) : (((19.0 + x_11) > (2.0 + x_12)? (19.0 + x_11) : (2.0 + x_12)) > ((15.0 + x_13) > (8.0 + x_17)? (15.0 + x_13) : (8.0 + x_17))? ((19.0 + x_11) > (2.0 + x_12)? (19.0 + x_11) : (2.0 + x_12)) : ((15.0 + x_13) > (8.0 + x_17)? (15.0 + x_13) : (8.0 + x_17)))) > (((8.0 + x_18) > ((18.0 + x_20) > (17.0 + x_21)? (18.0 + x_20) : (17.0 + x_21))? (8.0 + x_18) : ((18.0 + x_20) > (17.0 + x_21)? (18.0 + x_20) : (17.0 + x_21))) > (((9.0 + x_22) > (4.0 + x_23)? (9.0 + x_22) : (4.0 + x_23)) > ((19.0 + x_24) > (13.0 + x_27)? (19.0 + x_24) : (13.0 + x_27))? ((9.0 + x_22) > (4.0 + x_23)? (9.0 + x_22) : (4.0 + x_23)) : ((19.0 + x_24) > (13.0 + x_27)? (19.0 + x_24) : (13.0 + x_27)))? ((8.0 + x_18) > ((18.0 + x_20) > (17.0 + x_21)? (18.0 + x_20) : (17.0 + x_21))? (8.0 + x_18) : ((18.0 + x_20) > (17.0 + x_21)? (18.0 + x_20) : (17.0 + x_21))) : (((9.0 + x_22) > (4.0 + x_23)? (9.0 + x_22) : (4.0 + x_23)) > ((19.0 + x_24) > (13.0 + x_27)? (19.0 + x_24) : (13.0 + x_27))? ((9.0 + x_22) > (4.0 + x_23)? (9.0 + x_22) : (4.0 + x_23)) : ((19.0 + x_24) > (13.0 + x_27)? (19.0 + x_24) : (13.0 + x_27))))? (((8.0 + x_4) > ((20.0 + x_5) > (17.0 + x_6)? (20.0 + x_5) : (17.0 + x_6))? (8.0 + x_4) : ((20.0 + x_5) > (17.0 + x_6)? (20.0 + x_5) : (17.0 + x_6))) > (((19.0 + x_11) > (2.0 + x_12)? (19.0 + x_11) : (2.0 + x_12)) > ((15.0 + x_13) > (8.0 + x_17)? (15.0 + x_13) : (8.0 + x_17))? ((19.0 + x_11) > (2.0 + x_12)? (19.0 + x_11) : (2.0 + x_12)) : ((15.0 + x_13) > (8.0 + x_17)? (15.0 + x_13) : (8.0 + x_17)))? ((8.0 + x_4) > ((20.0 + x_5) > (17.0 + x_6)? (20.0 + x_5) : (17.0 + x_6))? (8.0 + x_4) : ((20.0 + x_5) > (17.0 + x_6)? (20.0 + x_5) : (17.0 + x_6))) : (((19.0 + x_11) > (2.0 + x_12)? (19.0 + x_11) : (2.0 + x_12)) > ((15.0 + x_13) > (8.0 + x_17)? (15.0 + x_13) : (8.0 + x_17))? ((19.0 + x_11) > (2.0 + x_12)? (19.0 + x_11) : (2.0 + x_12)) : ((15.0 + x_13) > (8.0 + x_17)? (15.0 + x_13) : (8.0 + x_17)))) : (((8.0 + x_18) > ((18.0 + x_20) > (17.0 + x_21)? (18.0 + x_20) : (17.0 + x_21))? (8.0 + x_18) : ((18.0 + x_20) > (17.0 + x_21)? (18.0 + x_20) : (17.0 + x_21))) > (((9.0 + x_22) > (4.0 + x_23)? (9.0 + x_22) : (4.0 + x_23)) > ((19.0 + x_24) > (13.0 + x_27)? (19.0 + x_24) : (13.0 + x_27))? ((9.0 + x_22) > (4.0 + x_23)? (9.0 + x_22) : (4.0 + x_23)) : ((19.0 + x_24) > (13.0 + x_27)? (19.0 + x_24) : (13.0 + x_27)))? ((8.0 + x_18) > ((18.0 + x_20) > (17.0 + x_21)? (18.0 + x_20) : (17.0 + x_21))? (8.0 + x_18) : ((18.0 + x_20) > (17.0 + x_21)? (18.0 + x_20) : (17.0 + x_21))) : (((9.0 + x_22) > (4.0 + x_23)? (9.0 + x_22) : (4.0 + x_23)) > ((19.0 + x_24) > (13.0 + x_27)? (19.0 + x_24) : (13.0 + x_27))? ((9.0 + x_22) > (4.0 + x_23)? (9.0 + x_22) : (4.0 + x_23)) : ((19.0 + x_24) > (13.0 + x_27)? (19.0 + x_24) : (13.0 + x_27))))); x_10_ = ((((3.0 + x_0) > ((3.0 + x_4) > (3.0 + x_5)? (3.0 + x_4) : (3.0 + x_5))? (3.0 + x_0) : ((3.0 + x_4) > (3.0 + x_5)? (3.0 + x_4) : (3.0 + x_5))) > (((9.0 + x_10) > (19.0 + x_11)? (9.0 + x_10) : (19.0 + x_11)) > ((3.0 + x_16) > (3.0 + x_17)? (3.0 + x_16) : (3.0 + x_17))? ((9.0 + x_10) > (19.0 + x_11)? (9.0 + x_10) : (19.0 + x_11)) : ((3.0 + x_16) > (3.0 + x_17)? (3.0 + x_16) : (3.0 + x_17)))? ((3.0 + x_0) > ((3.0 + x_4) > (3.0 + x_5)? (3.0 + x_4) : (3.0 + x_5))? (3.0 + x_0) : ((3.0 + x_4) > (3.0 + x_5)? (3.0 + x_4) : (3.0 + x_5))) : (((9.0 + x_10) > (19.0 + x_11)? (9.0 + x_10) : (19.0 + x_11)) > ((3.0 + x_16) > (3.0 + x_17)? (3.0 + x_16) : (3.0 + x_17))? ((9.0 + x_10) > (19.0 + x_11)? (9.0 + x_10) : (19.0 + x_11)) : ((3.0 + x_16) > (3.0 + x_17)? (3.0 + x_16) : (3.0 + x_17)))) > (((3.0 + x_18) > ((14.0 + x_22) > (16.0 + x_23)? (14.0 + x_22) : (16.0 + x_23))? (3.0 + x_18) : ((14.0 + x_22) > (16.0 + x_23)? (14.0 + x_22) : (16.0 + x_23))) > (((12.0 + x_24) > (5.0 + x_25)? (12.0 + x_24) : (5.0 + x_25)) > ((6.0 + x_26) > (11.0 + x_27)? (6.0 + x_26) : (11.0 + x_27))? ((12.0 + x_24) > (5.0 + x_25)? (12.0 + x_24) : (5.0 + x_25)) : ((6.0 + x_26) > (11.0 + x_27)? (6.0 + x_26) : (11.0 + x_27)))? ((3.0 + x_18) > ((14.0 + x_22) > (16.0 + x_23)? (14.0 + x_22) : (16.0 + x_23))? (3.0 + x_18) : ((14.0 + x_22) > (16.0 + x_23)? (14.0 + x_22) : (16.0 + x_23))) : (((12.0 + x_24) > (5.0 + x_25)? (12.0 + x_24) : (5.0 + x_25)) > ((6.0 + x_26) > (11.0 + x_27)? (6.0 + x_26) : (11.0 + x_27))? ((12.0 + x_24) > (5.0 + x_25)? (12.0 + x_24) : (5.0 + x_25)) : ((6.0 + x_26) > (11.0 + x_27)? (6.0 + x_26) : (11.0 + x_27))))? (((3.0 + x_0) > ((3.0 + x_4) > (3.0 + x_5)? (3.0 + x_4) : (3.0 + x_5))? (3.0 + x_0) : ((3.0 + x_4) > (3.0 + x_5)? (3.0 + x_4) : (3.0 + x_5))) > (((9.0 + x_10) > (19.0 + x_11)? (9.0 + x_10) : (19.0 + x_11)) > ((3.0 + x_16) > (3.0 + x_17)? (3.0 + x_16) : (3.0 + x_17))? ((9.0 + x_10) > (19.0 + x_11)? (9.0 + x_10) : (19.0 + x_11)) : ((3.0 + x_16) > (3.0 + x_17)? (3.0 + x_16) : (3.0 + x_17)))? ((3.0 + x_0) > ((3.0 + x_4) > (3.0 + x_5)? (3.0 + x_4) : (3.0 + x_5))? (3.0 + x_0) : ((3.0 + x_4) > (3.0 + x_5)? (3.0 + x_4) : (3.0 + x_5))) : (((9.0 + x_10) > (19.0 + x_11)? (9.0 + x_10) : (19.0 + x_11)) > ((3.0 + x_16) > (3.0 + x_17)? (3.0 + x_16) : (3.0 + x_17))? ((9.0 + x_10) > (19.0 + x_11)? (9.0 + x_10) : (19.0 + x_11)) : ((3.0 + x_16) > (3.0 + x_17)? (3.0 + x_16) : (3.0 + x_17)))) : (((3.0 + x_18) > ((14.0 + x_22) > (16.0 + x_23)? (14.0 + x_22) : (16.0 + x_23))? (3.0 + x_18) : ((14.0 + x_22) > (16.0 + x_23)? (14.0 + x_22) : (16.0 + x_23))) > (((12.0 + x_24) > (5.0 + x_25)? (12.0 + x_24) : (5.0 + x_25)) > ((6.0 + x_26) > (11.0 + x_27)? (6.0 + x_26) : (11.0 + x_27))? ((12.0 + x_24) > (5.0 + x_25)? (12.0 + x_24) : (5.0 + x_25)) : ((6.0 + x_26) > (11.0 + x_27)? (6.0 + x_26) : (11.0 + x_27)))? ((3.0 + x_18) > ((14.0 + x_22) > (16.0 + x_23)? (14.0 + x_22) : (16.0 + x_23))? (3.0 + x_18) : ((14.0 + x_22) > (16.0 + x_23)? (14.0 + x_22) : (16.0 + x_23))) : (((12.0 + x_24) > (5.0 + x_25)? (12.0 + x_24) : (5.0 + x_25)) > ((6.0 + x_26) > (11.0 + x_27)? (6.0 + x_26) : (11.0 + x_27))? ((12.0 + x_24) > (5.0 + x_25)? (12.0 + x_24) : (5.0 + x_25)) : ((6.0 + x_26) > (11.0 + x_27)? (6.0 + x_26) : (11.0 + x_27))))); x_11_ = ((((2.0 + x_1) > ((6.0 + x_2) > (12.0 + x_3)? (6.0 + x_2) : (12.0 + x_3))? (2.0 + x_1) : ((6.0 + x_2) > (12.0 + x_3)? (6.0 + x_2) : (12.0 + x_3))) > (((14.0 + x_4) > (8.0 + x_6)? (14.0 + x_4) : (8.0 + x_6)) > ((1.0 + x_8) > (18.0 + x_11)? (1.0 + x_8) : (18.0 + x_11))? ((14.0 + x_4) > (8.0 + x_6)? (14.0 + x_4) : (8.0 + x_6)) : ((1.0 + x_8) > (18.0 + x_11)? (1.0 + x_8) : (18.0 + x_11)))? ((2.0 + x_1) > ((6.0 + x_2) > (12.0 + x_3)? (6.0 + x_2) : (12.0 + x_3))? (2.0 + x_1) : ((6.0 + x_2) > (12.0 + x_3)? (6.0 + x_2) : (12.0 + x_3))) : (((14.0 + x_4) > (8.0 + x_6)? (14.0 + x_4) : (8.0 + x_6)) > ((1.0 + x_8) > (18.0 + x_11)? (1.0 + x_8) : (18.0 + x_11))? ((14.0 + x_4) > (8.0 + x_6)? (14.0 + x_4) : (8.0 + x_6)) : ((1.0 + x_8) > (18.0 + x_11)? (1.0 + x_8) : (18.0 + x_11)))) > (((7.0 + x_14) > ((16.0 + x_18) > (6.0 + x_20)? (16.0 + x_18) : (6.0 + x_20))? (7.0 + x_14) : ((16.0 + x_18) > (6.0 + x_20)? (16.0 + x_18) : (6.0 + x_20))) > (((16.0 + x_21) > (13.0 + x_22)? (16.0 + x_21) : (13.0 + x_22)) > ((4.0 + x_23) > (12.0 + x_25)? (4.0 + x_23) : (12.0 + x_25))? ((16.0 + x_21) > (13.0 + x_22)? (16.0 + x_21) : (13.0 + x_22)) : ((4.0 + x_23) > (12.0 + x_25)? (4.0 + x_23) : (12.0 + x_25)))? ((7.0 + x_14) > ((16.0 + x_18) > (6.0 + x_20)? (16.0 + x_18) : (6.0 + x_20))? (7.0 + x_14) : ((16.0 + x_18) > (6.0 + x_20)? (16.0 + x_18) : (6.0 + x_20))) : (((16.0 + x_21) > (13.0 + x_22)? (16.0 + x_21) : (13.0 + x_22)) > ((4.0 + x_23) > (12.0 + x_25)? (4.0 + x_23) : (12.0 + x_25))? ((16.0 + x_21) > (13.0 + x_22)? (16.0 + x_21) : (13.0 + x_22)) : ((4.0 + x_23) > (12.0 + x_25)? (4.0 + x_23) : (12.0 + x_25))))? (((2.0 + x_1) > ((6.0 + x_2) > (12.0 + x_3)? (6.0 + x_2) : (12.0 + x_3))? (2.0 + x_1) : ((6.0 + x_2) > (12.0 + x_3)? (6.0 + x_2) : (12.0 + x_3))) > (((14.0 + x_4) > (8.0 + x_6)? (14.0 + x_4) : (8.0 + x_6)) > ((1.0 + x_8) > (18.0 + x_11)? (1.0 + x_8) : (18.0 + x_11))? ((14.0 + x_4) > (8.0 + x_6)? (14.0 + x_4) : (8.0 + x_6)) : ((1.0 + x_8) > (18.0 + x_11)? (1.0 + x_8) : (18.0 + x_11)))? ((2.0 + x_1) > ((6.0 + x_2) > (12.0 + x_3)? (6.0 + x_2) : (12.0 + x_3))? (2.0 + x_1) : ((6.0 + x_2) > (12.0 + x_3)? (6.0 + x_2) : (12.0 + x_3))) : (((14.0 + x_4) > (8.0 + x_6)? (14.0 + x_4) : (8.0 + x_6)) > ((1.0 + x_8) > (18.0 + x_11)? (1.0 + x_8) : (18.0 + x_11))? ((14.0 + x_4) > (8.0 + x_6)? (14.0 + x_4) : (8.0 + x_6)) : ((1.0 + x_8) > (18.0 + x_11)? (1.0 + x_8) : (18.0 + x_11)))) : (((7.0 + x_14) > ((16.0 + x_18) > (6.0 + x_20)? (16.0 + x_18) : (6.0 + x_20))? (7.0 + x_14) : ((16.0 + x_18) > (6.0 + x_20)? (16.0 + x_18) : (6.0 + x_20))) > (((16.0 + x_21) > (13.0 + x_22)? (16.0 + x_21) : (13.0 + x_22)) > ((4.0 + x_23) > (12.0 + x_25)? (4.0 + x_23) : (12.0 + x_25))? ((16.0 + x_21) > (13.0 + x_22)? (16.0 + x_21) : (13.0 + x_22)) : ((4.0 + x_23) > (12.0 + x_25)? (4.0 + x_23) : (12.0 + x_25)))? ((7.0 + x_14) > ((16.0 + x_18) > (6.0 + x_20)? (16.0 + x_18) : (6.0 + x_20))? (7.0 + x_14) : ((16.0 + x_18) > (6.0 + x_20)? (16.0 + x_18) : (6.0 + x_20))) : (((16.0 + x_21) > (13.0 + x_22)? (16.0 + x_21) : (13.0 + x_22)) > ((4.0 + x_23) > (12.0 + x_25)? (4.0 + x_23) : (12.0 + x_25))? ((16.0 + x_21) > (13.0 + x_22)? (16.0 + x_21) : (13.0 + x_22)) : ((4.0 + x_23) > (12.0 + x_25)? (4.0 + x_23) : (12.0 + x_25))))); x_12_ = ((((10.0 + x_1) > ((19.0 + x_2) > (19.0 + x_4)? (19.0 + x_2) : (19.0 + x_4))? (10.0 + x_1) : ((19.0 + x_2) > (19.0 + x_4)? (19.0 + x_2) : (19.0 + x_4))) > (((2.0 + x_5) > (7.0 + x_6)? (2.0 + x_5) : (7.0 + x_6)) > ((10.0 + x_7) > (4.0 + x_13)? (10.0 + x_7) : (4.0 + x_13))? ((2.0 + x_5) > (7.0 + x_6)? (2.0 + x_5) : (7.0 + x_6)) : ((10.0 + x_7) > (4.0 + x_13)? (10.0 + x_7) : (4.0 + x_13)))? ((10.0 + x_1) > ((19.0 + x_2) > (19.0 + x_4)? (19.0 + x_2) : (19.0 + x_4))? (10.0 + x_1) : ((19.0 + x_2) > (19.0 + x_4)? (19.0 + x_2) : (19.0 + x_4))) : (((2.0 + x_5) > (7.0 + x_6)? (2.0 + x_5) : (7.0 + x_6)) > ((10.0 + x_7) > (4.0 + x_13)? (10.0 + x_7) : (4.0 + x_13))? ((2.0 + x_5) > (7.0 + x_6)? (2.0 + x_5) : (7.0 + x_6)) : ((10.0 + x_7) > (4.0 + x_13)? (10.0 + x_7) : (4.0 + x_13)))) > (((1.0 + x_16) > ((11.0 + x_18) > (7.0 + x_19)? (11.0 + x_18) : (7.0 + x_19))? (1.0 + x_16) : ((11.0 + x_18) > (7.0 + x_19)? (11.0 + x_18) : (7.0 + x_19))) > (((17.0 + x_21) > (14.0 + x_22)? (17.0 + x_21) : (14.0 + x_22)) > ((11.0 + x_25) > (15.0 + x_26)? (11.0 + x_25) : (15.0 + x_26))? ((17.0 + x_21) > (14.0 + x_22)? (17.0 + x_21) : (14.0 + x_22)) : ((11.0 + x_25) > (15.0 + x_26)? (11.0 + x_25) : (15.0 + x_26)))? ((1.0 + x_16) > ((11.0 + x_18) > (7.0 + x_19)? (11.0 + x_18) : (7.0 + x_19))? (1.0 + x_16) : ((11.0 + x_18) > (7.0 + x_19)? (11.0 + x_18) : (7.0 + x_19))) : (((17.0 + x_21) > (14.0 + x_22)? (17.0 + x_21) : (14.0 + x_22)) > ((11.0 + x_25) > (15.0 + x_26)? (11.0 + x_25) : (15.0 + x_26))? ((17.0 + x_21) > (14.0 + x_22)? (17.0 + x_21) : (14.0 + x_22)) : ((11.0 + x_25) > (15.0 + x_26)? (11.0 + x_25) : (15.0 + x_26))))? (((10.0 + x_1) > ((19.0 + x_2) > (19.0 + x_4)? (19.0 + x_2) : (19.0 + x_4))? (10.0 + x_1) : ((19.0 + x_2) > (19.0 + x_4)? (19.0 + x_2) : (19.0 + x_4))) > (((2.0 + x_5) > (7.0 + x_6)? (2.0 + x_5) : (7.0 + x_6)) > ((10.0 + x_7) > (4.0 + x_13)? (10.0 + x_7) : (4.0 + x_13))? ((2.0 + x_5) > (7.0 + x_6)? (2.0 + x_5) : (7.0 + x_6)) : ((10.0 + x_7) > (4.0 + x_13)? (10.0 + x_7) : (4.0 + x_13)))? ((10.0 + x_1) > ((19.0 + x_2) > (19.0 + x_4)? (19.0 + x_2) : (19.0 + x_4))? (10.0 + x_1) : ((19.0 + x_2) > (19.0 + x_4)? (19.0 + x_2) : (19.0 + x_4))) : (((2.0 + x_5) > (7.0 + x_6)? (2.0 + x_5) : (7.0 + x_6)) > ((10.0 + x_7) > (4.0 + x_13)? (10.0 + x_7) : (4.0 + x_13))? ((2.0 + x_5) > (7.0 + x_6)? (2.0 + x_5) : (7.0 + x_6)) : ((10.0 + x_7) > (4.0 + x_13)? (10.0 + x_7) : (4.0 + x_13)))) : (((1.0 + x_16) > ((11.0 + x_18) > (7.0 + x_19)? (11.0 + x_18) : (7.0 + x_19))? (1.0 + x_16) : ((11.0 + x_18) > (7.0 + x_19)? (11.0 + x_18) : (7.0 + x_19))) > (((17.0 + x_21) > (14.0 + x_22)? (17.0 + x_21) : (14.0 + x_22)) > ((11.0 + x_25) > (15.0 + x_26)? (11.0 + x_25) : (15.0 + x_26))? ((17.0 + x_21) > (14.0 + x_22)? (17.0 + x_21) : (14.0 + x_22)) : ((11.0 + x_25) > (15.0 + x_26)? (11.0 + x_25) : (15.0 + x_26)))? ((1.0 + x_16) > ((11.0 + x_18) > (7.0 + x_19)? (11.0 + x_18) : (7.0 + x_19))? (1.0 + x_16) : ((11.0 + x_18) > (7.0 + x_19)? (11.0 + x_18) : (7.0 + x_19))) : (((17.0 + x_21) > (14.0 + x_22)? (17.0 + x_21) : (14.0 + x_22)) > ((11.0 + x_25) > (15.0 + x_26)? (11.0 + x_25) : (15.0 + x_26))? ((17.0 + x_21) > (14.0 + x_22)? (17.0 + x_21) : (14.0 + x_22)) : ((11.0 + x_25) > (15.0 + x_26)? (11.0 + x_25) : (15.0 + x_26))))); x_13_ = ((((8.0 + x_0) > ((6.0 + x_5) > (15.0 + x_6)? (6.0 + x_5) : (15.0 + x_6))? (8.0 + x_0) : ((6.0 + x_5) > (15.0 + x_6)? (6.0 + x_5) : (15.0 + x_6))) > (((8.0 + x_7) > (4.0 + x_10)? (8.0 + x_7) : (4.0 + x_10)) > ((1.0 + x_11) > (3.0 + x_13)? (1.0 + x_11) : (3.0 + x_13))? ((8.0 + x_7) > (4.0 + x_10)? (8.0 + x_7) : (4.0 + x_10)) : ((1.0 + x_11) > (3.0 + x_13)? (1.0 + x_11) : (3.0 + x_13)))? ((8.0 + x_0) > ((6.0 + x_5) > (15.0 + x_6)? (6.0 + x_5) : (15.0 + x_6))? (8.0 + x_0) : ((6.0 + x_5) > (15.0 + x_6)? (6.0 + x_5) : (15.0 + x_6))) : (((8.0 + x_7) > (4.0 + x_10)? (8.0 + x_7) : (4.0 + x_10)) > ((1.0 + x_11) > (3.0 + x_13)? (1.0 + x_11) : (3.0 + x_13))? ((8.0 + x_7) > (4.0 + x_10)? (8.0 + x_7) : (4.0 + x_10)) : ((1.0 + x_11) > (3.0 + x_13)? (1.0 + x_11) : (3.0 + x_13)))) > (((13.0 + x_15) > ((1.0 + x_17) > (16.0 + x_19)? (1.0 + x_17) : (16.0 + x_19))? (13.0 + x_15) : ((1.0 + x_17) > (16.0 + x_19)? (1.0 + x_17) : (16.0 + x_19))) > (((1.0 + x_20) > (7.0 + x_21)? (1.0 + x_20) : (7.0 + x_21)) > ((14.0 + x_22) > (10.0 + x_25)? (14.0 + x_22) : (10.0 + x_25))? ((1.0 + x_20) > (7.0 + x_21)? (1.0 + x_20) : (7.0 + x_21)) : ((14.0 + x_22) > (10.0 + x_25)? (14.0 + x_22) : (10.0 + x_25)))? ((13.0 + x_15) > ((1.0 + x_17) > (16.0 + x_19)? (1.0 + x_17) : (16.0 + x_19))? (13.0 + x_15) : ((1.0 + x_17) > (16.0 + x_19)? (1.0 + x_17) : (16.0 + x_19))) : (((1.0 + x_20) > (7.0 + x_21)? (1.0 + x_20) : (7.0 + x_21)) > ((14.0 + x_22) > (10.0 + x_25)? (14.0 + x_22) : (10.0 + x_25))? ((1.0 + x_20) > (7.0 + x_21)? (1.0 + x_20) : (7.0 + x_21)) : ((14.0 + x_22) > (10.0 + x_25)? (14.0 + x_22) : (10.0 + x_25))))? (((8.0 + x_0) > ((6.0 + x_5) > (15.0 + x_6)? (6.0 + x_5) : (15.0 + x_6))? (8.0 + x_0) : ((6.0 + x_5) > (15.0 + x_6)? (6.0 + x_5) : (15.0 + x_6))) > (((8.0 + x_7) > (4.0 + x_10)? (8.0 + x_7) : (4.0 + x_10)) > ((1.0 + x_11) > (3.0 + x_13)? (1.0 + x_11) : (3.0 + x_13))? ((8.0 + x_7) > (4.0 + x_10)? (8.0 + x_7) : (4.0 + x_10)) : ((1.0 + x_11) > (3.0 + x_13)? (1.0 + x_11) : (3.0 + x_13)))? ((8.0 + x_0) > ((6.0 + x_5) > (15.0 + x_6)? (6.0 + x_5) : (15.0 + x_6))? (8.0 + x_0) : ((6.0 + x_5) > (15.0 + x_6)? (6.0 + x_5) : (15.0 + x_6))) : (((8.0 + x_7) > (4.0 + x_10)? (8.0 + x_7) : (4.0 + x_10)) > ((1.0 + x_11) > (3.0 + x_13)? (1.0 + x_11) : (3.0 + x_13))? ((8.0 + x_7) > (4.0 + x_10)? (8.0 + x_7) : (4.0 + x_10)) : ((1.0 + x_11) > (3.0 + x_13)? (1.0 + x_11) : (3.0 + x_13)))) : (((13.0 + x_15) > ((1.0 + x_17) > (16.0 + x_19)? (1.0 + x_17) : (16.0 + x_19))? (13.0 + x_15) : ((1.0 + x_17) > (16.0 + x_19)? (1.0 + x_17) : (16.0 + x_19))) > (((1.0 + x_20) > (7.0 + x_21)? (1.0 + x_20) : (7.0 + x_21)) > ((14.0 + x_22) > (10.0 + x_25)? (14.0 + x_22) : (10.0 + x_25))? ((1.0 + x_20) > (7.0 + x_21)? (1.0 + x_20) : (7.0 + x_21)) : ((14.0 + x_22) > (10.0 + x_25)? (14.0 + x_22) : (10.0 + x_25)))? ((13.0 + x_15) > ((1.0 + x_17) > (16.0 + x_19)? (1.0 + x_17) : (16.0 + x_19))? (13.0 + x_15) : ((1.0 + x_17) > (16.0 + x_19)? (1.0 + x_17) : (16.0 + x_19))) : (((1.0 + x_20) > (7.0 + x_21)? (1.0 + x_20) : (7.0 + x_21)) > ((14.0 + x_22) > (10.0 + x_25)? (14.0 + x_22) : (10.0 + x_25))? ((1.0 + x_20) > (7.0 + x_21)? (1.0 + x_20) : (7.0 + x_21)) : ((14.0 + x_22) > (10.0 + x_25)? (14.0 + x_22) : (10.0 + x_25))))); x_14_ = ((((15.0 + x_0) > ((19.0 + x_2) > (14.0 + x_4)? (19.0 + x_2) : (14.0 + x_4))? (15.0 + x_0) : ((19.0 + x_2) > (14.0 + x_4)? (19.0 + x_2) : (14.0 + x_4))) > (((5.0 + x_5) > (18.0 + x_8)? (5.0 + x_5) : (18.0 + x_8)) > ((15.0 + x_9) > (19.0 + x_13)? (15.0 + x_9) : (19.0 + x_13))? ((5.0 + x_5) > (18.0 + x_8)? (5.0 + x_5) : (18.0 + x_8)) : ((15.0 + x_9) > (19.0 + x_13)? (15.0 + x_9) : (19.0 + x_13)))? ((15.0 + x_0) > ((19.0 + x_2) > (14.0 + x_4)? (19.0 + x_2) : (14.0 + x_4))? (15.0 + x_0) : ((19.0 + x_2) > (14.0 + x_4)? (19.0 + x_2) : (14.0 + x_4))) : (((5.0 + x_5) > (18.0 + x_8)? (5.0 + x_5) : (18.0 + x_8)) > ((15.0 + x_9) > (19.0 + x_13)? (15.0 + x_9) : (19.0 + x_13))? ((5.0 + x_5) > (18.0 + x_8)? (5.0 + x_5) : (18.0 + x_8)) : ((15.0 + x_9) > (19.0 + x_13)? (15.0 + x_9) : (19.0 + x_13)))) > (((1.0 + x_14) > ((19.0 + x_17) > (16.0 + x_20)? (19.0 + x_17) : (16.0 + x_20))? (1.0 + x_14) : ((19.0 + x_17) > (16.0 + x_20)? (19.0 + x_17) : (16.0 + x_20))) > (((1.0 + x_22) > (5.0 + x_23)? (1.0 + x_22) : (5.0 + x_23)) > ((6.0 + x_25) > (16.0 + x_27)? (6.0 + x_25) : (16.0 + x_27))? ((1.0 + x_22) > (5.0 + x_23)? (1.0 + x_22) : (5.0 + x_23)) : ((6.0 + x_25) > (16.0 + x_27)? (6.0 + x_25) : (16.0 + x_27)))? ((1.0 + x_14) > ((19.0 + x_17) > (16.0 + x_20)? (19.0 + x_17) : (16.0 + x_20))? (1.0 + x_14) : ((19.0 + x_17) > (16.0 + x_20)? (19.0 + x_17) : (16.0 + x_20))) : (((1.0 + x_22) > (5.0 + x_23)? (1.0 + x_22) : (5.0 + x_23)) > ((6.0 + x_25) > (16.0 + x_27)? (6.0 + x_25) : (16.0 + x_27))? ((1.0 + x_22) > (5.0 + x_23)? (1.0 + x_22) : (5.0 + x_23)) : ((6.0 + x_25) > (16.0 + x_27)? (6.0 + x_25) : (16.0 + x_27))))? (((15.0 + x_0) > ((19.0 + x_2) > (14.0 + x_4)? (19.0 + x_2) : (14.0 + x_4))? (15.0 + x_0) : ((19.0 + x_2) > (14.0 + x_4)? (19.0 + x_2) : (14.0 + x_4))) > (((5.0 + x_5) > (18.0 + x_8)? (5.0 + x_5) : (18.0 + x_8)) > ((15.0 + x_9) > (19.0 + x_13)? (15.0 + x_9) : (19.0 + x_13))? ((5.0 + x_5) > (18.0 + x_8)? (5.0 + x_5) : (18.0 + x_8)) : ((15.0 + x_9) > (19.0 + x_13)? (15.0 + x_9) : (19.0 + x_13)))? ((15.0 + x_0) > ((19.0 + x_2) > (14.0 + x_4)? (19.0 + x_2) : (14.0 + x_4))? (15.0 + x_0) : ((19.0 + x_2) > (14.0 + x_4)? (19.0 + x_2) : (14.0 + x_4))) : (((5.0 + x_5) > (18.0 + x_8)? (5.0 + x_5) : (18.0 + x_8)) > ((15.0 + x_9) > (19.0 + x_13)? (15.0 + x_9) : (19.0 + x_13))? ((5.0 + x_5) > (18.0 + x_8)? (5.0 + x_5) : (18.0 + x_8)) : ((15.0 + x_9) > (19.0 + x_13)? (15.0 + x_9) : (19.0 + x_13)))) : (((1.0 + x_14) > ((19.0 + x_17) > (16.0 + x_20)? (19.0 + x_17) : (16.0 + x_20))? (1.0 + x_14) : ((19.0 + x_17) > (16.0 + x_20)? (19.0 + x_17) : (16.0 + x_20))) > (((1.0 + x_22) > (5.0 + x_23)? (1.0 + x_22) : (5.0 + x_23)) > ((6.0 + x_25) > (16.0 + x_27)? (6.0 + x_25) : (16.0 + x_27))? ((1.0 + x_22) > (5.0 + x_23)? (1.0 + x_22) : (5.0 + x_23)) : ((6.0 + x_25) > (16.0 + x_27)? (6.0 + x_25) : (16.0 + x_27)))? ((1.0 + x_14) > ((19.0 + x_17) > (16.0 + x_20)? (19.0 + x_17) : (16.0 + x_20))? (1.0 + x_14) : ((19.0 + x_17) > (16.0 + x_20)? (19.0 + x_17) : (16.0 + x_20))) : (((1.0 + x_22) > (5.0 + x_23)? (1.0 + x_22) : (5.0 + x_23)) > ((6.0 + x_25) > (16.0 + x_27)? (6.0 + x_25) : (16.0 + x_27))? ((1.0 + x_22) > (5.0 + x_23)? (1.0 + x_22) : (5.0 + x_23)) : ((6.0 + x_25) > (16.0 + x_27)? (6.0 + x_25) : (16.0 + x_27))))); x_15_ = ((((20.0 + x_0) > ((15.0 + x_3) > (19.0 + x_4)? (15.0 + x_3) : (19.0 + x_4))? (20.0 + x_0) : ((15.0 + x_3) > (19.0 + x_4)? (15.0 + x_3) : (19.0 + x_4))) > (((6.0 + x_5) > (4.0 + x_8)? (6.0 + x_5) : (4.0 + x_8)) > ((16.0 + x_9) > (16.0 + x_11)? (16.0 + x_9) : (16.0 + x_11))? ((6.0 + x_5) > (4.0 + x_8)? (6.0 + x_5) : (4.0 + x_8)) : ((16.0 + x_9) > (16.0 + x_11)? (16.0 + x_9) : (16.0 + x_11)))? ((20.0 + x_0) > ((15.0 + x_3) > (19.0 + x_4)? (15.0 + x_3) : (19.0 + x_4))? (20.0 + x_0) : ((15.0 + x_3) > (19.0 + x_4)? (15.0 + x_3) : (19.0 + x_4))) : (((6.0 + x_5) > (4.0 + x_8)? (6.0 + x_5) : (4.0 + x_8)) > ((16.0 + x_9) > (16.0 + x_11)? (16.0 + x_9) : (16.0 + x_11))? ((6.0 + x_5) > (4.0 + x_8)? (6.0 + x_5) : (4.0 + x_8)) : ((16.0 + x_9) > (16.0 + x_11)? (16.0 + x_9) : (16.0 + x_11)))) > (((12.0 + x_15) > ((8.0 + x_16) > (12.0 + x_17)? (8.0 + x_16) : (12.0 + x_17))? (12.0 + x_15) : ((8.0 + x_16) > (12.0 + x_17)? (8.0 + x_16) : (12.0 + x_17))) > (((19.0 + x_22) > (16.0 + x_23)? (19.0 + x_22) : (16.0 + x_23)) > ((7.0 + x_24) > (18.0 + x_25)? (7.0 + x_24) : (18.0 + x_25))? ((19.0 + x_22) > (16.0 + x_23)? (19.0 + x_22) : (16.0 + x_23)) : ((7.0 + x_24) > (18.0 + x_25)? (7.0 + x_24) : (18.0 + x_25)))? ((12.0 + x_15) > ((8.0 + x_16) > (12.0 + x_17)? (8.0 + x_16) : (12.0 + x_17))? (12.0 + x_15) : ((8.0 + x_16) > (12.0 + x_17)? (8.0 + x_16) : (12.0 + x_17))) : (((19.0 + x_22) > (16.0 + x_23)? (19.0 + x_22) : (16.0 + x_23)) > ((7.0 + x_24) > (18.0 + x_25)? (7.0 + x_24) : (18.0 + x_25))? ((19.0 + x_22) > (16.0 + x_23)? (19.0 + x_22) : (16.0 + x_23)) : ((7.0 + x_24) > (18.0 + x_25)? (7.0 + x_24) : (18.0 + x_25))))? (((20.0 + x_0) > ((15.0 + x_3) > (19.0 + x_4)? (15.0 + x_3) : (19.0 + x_4))? (20.0 + x_0) : ((15.0 + x_3) > (19.0 + x_4)? (15.0 + x_3) : (19.0 + x_4))) > (((6.0 + x_5) > (4.0 + x_8)? (6.0 + x_5) : (4.0 + x_8)) > ((16.0 + x_9) > (16.0 + x_11)? (16.0 + x_9) : (16.0 + x_11))? ((6.0 + x_5) > (4.0 + x_8)? (6.0 + x_5) : (4.0 + x_8)) : ((16.0 + x_9) > (16.0 + x_11)? (16.0 + x_9) : (16.0 + x_11)))? ((20.0 + x_0) > ((15.0 + x_3) > (19.0 + x_4)? (15.0 + x_3) : (19.0 + x_4))? (20.0 + x_0) : ((15.0 + x_3) > (19.0 + x_4)? (15.0 + x_3) : (19.0 + x_4))) : (((6.0 + x_5) > (4.0 + x_8)? (6.0 + x_5) : (4.0 + x_8)) > ((16.0 + x_9) > (16.0 + x_11)? (16.0 + x_9) : (16.0 + x_11))? ((6.0 + x_5) > (4.0 + x_8)? (6.0 + x_5) : (4.0 + x_8)) : ((16.0 + x_9) > (16.0 + x_11)? (16.0 + x_9) : (16.0 + x_11)))) : (((12.0 + x_15) > ((8.0 + x_16) > (12.0 + x_17)? (8.0 + x_16) : (12.0 + x_17))? (12.0 + x_15) : ((8.0 + x_16) > (12.0 + x_17)? (8.0 + x_16) : (12.0 + x_17))) > (((19.0 + x_22) > (16.0 + x_23)? (19.0 + x_22) : (16.0 + x_23)) > ((7.0 + x_24) > (18.0 + x_25)? (7.0 + x_24) : (18.0 + x_25))? ((19.0 + x_22) > (16.0 + x_23)? (19.0 + x_22) : (16.0 + x_23)) : ((7.0 + x_24) > (18.0 + x_25)? (7.0 + x_24) : (18.0 + x_25)))? ((12.0 + x_15) > ((8.0 + x_16) > (12.0 + x_17)? (8.0 + x_16) : (12.0 + x_17))? (12.0 + x_15) : ((8.0 + x_16) > (12.0 + x_17)? (8.0 + x_16) : (12.0 + x_17))) : (((19.0 + x_22) > (16.0 + x_23)? (19.0 + x_22) : (16.0 + x_23)) > ((7.0 + x_24) > (18.0 + x_25)? (7.0 + x_24) : (18.0 + x_25))? ((19.0 + x_22) > (16.0 + x_23)? (19.0 + x_22) : (16.0 + x_23)) : ((7.0 + x_24) > (18.0 + x_25)? (7.0 + x_24) : (18.0 + x_25))))); x_16_ = ((((6.0 + x_0) > ((2.0 + x_1) > (2.0 + x_3)? (2.0 + x_1) : (2.0 + x_3))? (6.0 + x_0) : ((2.0 + x_1) > (2.0 + x_3)? (2.0 + x_1) : (2.0 + x_3))) > (((10.0 + x_4) > (12.0 + x_5)? (10.0 + x_4) : (12.0 + x_5)) > ((8.0 + x_6) > (15.0 + x_8)? (8.0 + x_6) : (15.0 + x_8))? ((10.0 + x_4) > (12.0 + x_5)? (10.0 + x_4) : (12.0 + x_5)) : ((8.0 + x_6) > (15.0 + x_8)? (8.0 + x_6) : (15.0 + x_8)))? ((6.0 + x_0) > ((2.0 + x_1) > (2.0 + x_3)? (2.0 + x_1) : (2.0 + x_3))? (6.0 + x_0) : ((2.0 + x_1) > (2.0 + x_3)? (2.0 + x_1) : (2.0 + x_3))) : (((10.0 + x_4) > (12.0 + x_5)? (10.0 + x_4) : (12.0 + x_5)) > ((8.0 + x_6) > (15.0 + x_8)? (8.0 + x_6) : (15.0 + x_8))? ((10.0 + x_4) > (12.0 + x_5)? (10.0 + x_4) : (12.0 + x_5)) : ((8.0 + x_6) > (15.0 + x_8)? (8.0 + x_6) : (15.0 + x_8)))) > (((4.0 + x_10) > ((9.0 + x_13) > (14.0 + x_14)? (9.0 + x_13) : (14.0 + x_14))? (4.0 + x_10) : ((9.0 + x_13) > (14.0 + x_14)? (9.0 + x_13) : (14.0 + x_14))) > (((4.0 + x_15) > (3.0 + x_18)? (4.0 + x_15) : (3.0 + x_18)) > ((16.0 + x_20) > (20.0 + x_27)? (16.0 + x_20) : (20.0 + x_27))? ((4.0 + x_15) > (3.0 + x_18)? (4.0 + x_15) : (3.0 + x_18)) : ((16.0 + x_20) > (20.0 + x_27)? (16.0 + x_20) : (20.0 + x_27)))? ((4.0 + x_10) > ((9.0 + x_13) > (14.0 + x_14)? (9.0 + x_13) : (14.0 + x_14))? (4.0 + x_10) : ((9.0 + x_13) > (14.0 + x_14)? (9.0 + x_13) : (14.0 + x_14))) : (((4.0 + x_15) > (3.0 + x_18)? (4.0 + x_15) : (3.0 + x_18)) > ((16.0 + x_20) > (20.0 + x_27)? (16.0 + x_20) : (20.0 + x_27))? ((4.0 + x_15) > (3.0 + x_18)? (4.0 + x_15) : (3.0 + x_18)) : ((16.0 + x_20) > (20.0 + x_27)? (16.0 + x_20) : (20.0 + x_27))))? (((6.0 + x_0) > ((2.0 + x_1) > (2.0 + x_3)? (2.0 + x_1) : (2.0 + x_3))? (6.0 + x_0) : ((2.0 + x_1) > (2.0 + x_3)? (2.0 + x_1) : (2.0 + x_3))) > (((10.0 + x_4) > (12.0 + x_5)? (10.0 + x_4) : (12.0 + x_5)) > ((8.0 + x_6) > (15.0 + x_8)? (8.0 + x_6) : (15.0 + x_8))? ((10.0 + x_4) > (12.0 + x_5)? (10.0 + x_4) : (12.0 + x_5)) : ((8.0 + x_6) > (15.0 + x_8)? (8.0 + x_6) : (15.0 + x_8)))? ((6.0 + x_0) > ((2.0 + x_1) > (2.0 + x_3)? (2.0 + x_1) : (2.0 + x_3))? (6.0 + x_0) : ((2.0 + x_1) > (2.0 + x_3)? (2.0 + x_1) : (2.0 + x_3))) : (((10.0 + x_4) > (12.0 + x_5)? (10.0 + x_4) : (12.0 + x_5)) > ((8.0 + x_6) > (15.0 + x_8)? (8.0 + x_6) : (15.0 + x_8))? ((10.0 + x_4) > (12.0 + x_5)? (10.0 + x_4) : (12.0 + x_5)) : ((8.0 + x_6) > (15.0 + x_8)? (8.0 + x_6) : (15.0 + x_8)))) : (((4.0 + x_10) > ((9.0 + x_13) > (14.0 + x_14)? (9.0 + x_13) : (14.0 + x_14))? (4.0 + x_10) : ((9.0 + x_13) > (14.0 + x_14)? (9.0 + x_13) : (14.0 + x_14))) > (((4.0 + x_15) > (3.0 + x_18)? (4.0 + x_15) : (3.0 + x_18)) > ((16.0 + x_20) > (20.0 + x_27)? (16.0 + x_20) : (20.0 + x_27))? ((4.0 + x_15) > (3.0 + x_18)? (4.0 + x_15) : (3.0 + x_18)) : ((16.0 + x_20) > (20.0 + x_27)? (16.0 + x_20) : (20.0 + x_27)))? ((4.0 + x_10) > ((9.0 + x_13) > (14.0 + x_14)? (9.0 + x_13) : (14.0 + x_14))? (4.0 + x_10) : ((9.0 + x_13) > (14.0 + x_14)? (9.0 + x_13) : (14.0 + x_14))) : (((4.0 + x_15) > (3.0 + x_18)? (4.0 + x_15) : (3.0 + x_18)) > ((16.0 + x_20) > (20.0 + x_27)? (16.0 + x_20) : (20.0 + x_27))? ((4.0 + x_15) > (3.0 + x_18)? (4.0 + x_15) : (3.0 + x_18)) : ((16.0 + x_20) > (20.0 + x_27)? (16.0 + x_20) : (20.0 + x_27))))); x_17_ = ((((17.0 + x_0) > ((13.0 + x_2) > (8.0 + x_3)? (13.0 + x_2) : (8.0 + x_3))? (17.0 + x_0) : ((13.0 + x_2) > (8.0 + x_3)? (13.0 + x_2) : (8.0 + x_3))) > (((6.0 + x_4) > (2.0 + x_6)? (6.0 + x_4) : (2.0 + x_6)) > ((19.0 + x_8) > (15.0 + x_10)? (19.0 + x_8) : (15.0 + x_10))? ((6.0 + x_4) > (2.0 + x_6)? (6.0 + x_4) : (2.0 + x_6)) : ((19.0 + x_8) > (15.0 + x_10)? (19.0 + x_8) : (15.0 + x_10)))? ((17.0 + x_0) > ((13.0 + x_2) > (8.0 + x_3)? (13.0 + x_2) : (8.0 + x_3))? (17.0 + x_0) : ((13.0 + x_2) > (8.0 + x_3)? (13.0 + x_2) : (8.0 + x_3))) : (((6.0 + x_4) > (2.0 + x_6)? (6.0 + x_4) : (2.0 + x_6)) > ((19.0 + x_8) > (15.0 + x_10)? (19.0 + x_8) : (15.0 + x_10))? ((6.0 + x_4) > (2.0 + x_6)? (6.0 + x_4) : (2.0 + x_6)) : ((19.0 + x_8) > (15.0 + x_10)? (19.0 + x_8) : (15.0 + x_10)))) > (((1.0 + x_11) > ((10.0 + x_12) > (10.0 + x_13)? (10.0 + x_12) : (10.0 + x_13))? (1.0 + x_11) : ((10.0 + x_12) > (10.0 + x_13)? (10.0 + x_12) : (10.0 + x_13))) > (((10.0 + x_20) > (6.0 + x_21)? (10.0 + x_20) : (6.0 + x_21)) > ((17.0 + x_24) > (13.0 + x_25)? (17.0 + x_24) : (13.0 + x_25))? ((10.0 + x_20) > (6.0 + x_21)? (10.0 + x_20) : (6.0 + x_21)) : ((17.0 + x_24) > (13.0 + x_25)? (17.0 + x_24) : (13.0 + x_25)))? ((1.0 + x_11) > ((10.0 + x_12) > (10.0 + x_13)? (10.0 + x_12) : (10.0 + x_13))? (1.0 + x_11) : ((10.0 + x_12) > (10.0 + x_13)? (10.0 + x_12) : (10.0 + x_13))) : (((10.0 + x_20) > (6.0 + x_21)? (10.0 + x_20) : (6.0 + x_21)) > ((17.0 + x_24) > (13.0 + x_25)? (17.0 + x_24) : (13.0 + x_25))? ((10.0 + x_20) > (6.0 + x_21)? (10.0 + x_20) : (6.0 + x_21)) : ((17.0 + x_24) > (13.0 + x_25)? (17.0 + x_24) : (13.0 + x_25))))? (((17.0 + x_0) > ((13.0 + x_2) > (8.0 + x_3)? (13.0 + x_2) : (8.0 + x_3))? (17.0 + x_0) : ((13.0 + x_2) > (8.0 + x_3)? (13.0 + x_2) : (8.0 + x_3))) > (((6.0 + x_4) > (2.0 + x_6)? (6.0 + x_4) : (2.0 + x_6)) > ((19.0 + x_8) > (15.0 + x_10)? (19.0 + x_8) : (15.0 + x_10))? ((6.0 + x_4) > (2.0 + x_6)? (6.0 + x_4) : (2.0 + x_6)) : ((19.0 + x_8) > (15.0 + x_10)? (19.0 + x_8) : (15.0 + x_10)))? ((17.0 + x_0) > ((13.0 + x_2) > (8.0 + x_3)? (13.0 + x_2) : (8.0 + x_3))? (17.0 + x_0) : ((13.0 + x_2) > (8.0 + x_3)? (13.0 + x_2) : (8.0 + x_3))) : (((6.0 + x_4) > (2.0 + x_6)? (6.0 + x_4) : (2.0 + x_6)) > ((19.0 + x_8) > (15.0 + x_10)? (19.0 + x_8) : (15.0 + x_10))? ((6.0 + x_4) > (2.0 + x_6)? (6.0 + x_4) : (2.0 + x_6)) : ((19.0 + x_8) > (15.0 + x_10)? (19.0 + x_8) : (15.0 + x_10)))) : (((1.0 + x_11) > ((10.0 + x_12) > (10.0 + x_13)? (10.0 + x_12) : (10.0 + x_13))? (1.0 + x_11) : ((10.0 + x_12) > (10.0 + x_13)? (10.0 + x_12) : (10.0 + x_13))) > (((10.0 + x_20) > (6.0 + x_21)? (10.0 + x_20) : (6.0 + x_21)) > ((17.0 + x_24) > (13.0 + x_25)? (17.0 + x_24) : (13.0 + x_25))? ((10.0 + x_20) > (6.0 + x_21)? (10.0 + x_20) : (6.0 + x_21)) : ((17.0 + x_24) > (13.0 + x_25)? (17.0 + x_24) : (13.0 + x_25)))? ((1.0 + x_11) > ((10.0 + x_12) > (10.0 + x_13)? (10.0 + x_12) : (10.0 + x_13))? (1.0 + x_11) : ((10.0 + x_12) > (10.0 + x_13)? (10.0 + x_12) : (10.0 + x_13))) : (((10.0 + x_20) > (6.0 + x_21)? (10.0 + x_20) : (6.0 + x_21)) > ((17.0 + x_24) > (13.0 + x_25)? (17.0 + x_24) : (13.0 + x_25))? ((10.0 + x_20) > (6.0 + x_21)? (10.0 + x_20) : (6.0 + x_21)) : ((17.0 + x_24) > (13.0 + x_25)? (17.0 + x_24) : (13.0 + x_25))))); x_18_ = ((((7.0 + x_1) > ((5.0 + x_2) > (7.0 + x_3)? (5.0 + x_2) : (7.0 + x_3))? (7.0 + x_1) : ((5.0 + x_2) > (7.0 + x_3)? (5.0 + x_2) : (7.0 + x_3))) > (((3.0 + x_5) > (15.0 + x_10)? (3.0 + x_5) : (15.0 + x_10)) > ((11.0 + x_12) > (10.0 + x_13)? (11.0 + x_12) : (10.0 + x_13))? ((3.0 + x_5) > (15.0 + x_10)? (3.0 + x_5) : (15.0 + x_10)) : ((11.0 + x_12) > (10.0 + x_13)? (11.0 + x_12) : (10.0 + x_13)))? ((7.0 + x_1) > ((5.0 + x_2) > (7.0 + x_3)? (5.0 + x_2) : (7.0 + x_3))? (7.0 + x_1) : ((5.0 + x_2) > (7.0 + x_3)? (5.0 + x_2) : (7.0 + x_3))) : (((3.0 + x_5) > (15.0 + x_10)? (3.0 + x_5) : (15.0 + x_10)) > ((11.0 + x_12) > (10.0 + x_13)? (11.0 + x_12) : (10.0 + x_13))? ((3.0 + x_5) > (15.0 + x_10)? (3.0 + x_5) : (15.0 + x_10)) : ((11.0 + x_12) > (10.0 + x_13)? (11.0 + x_12) : (10.0 + x_13)))) > (((2.0 + x_17) > ((18.0 + x_18) > (1.0 + x_20)? (18.0 + x_18) : (1.0 + x_20))? (2.0 + x_17) : ((18.0 + x_18) > (1.0 + x_20)? (18.0 + x_18) : (1.0 + x_20))) > (((6.0 + x_22) > (19.0 + x_24)? (6.0 + x_22) : (19.0 + x_24)) > ((16.0 + x_26) > (13.0 + x_27)? (16.0 + x_26) : (13.0 + x_27))? ((6.0 + x_22) > (19.0 + x_24)? (6.0 + x_22) : (19.0 + x_24)) : ((16.0 + x_26) > (13.0 + x_27)? (16.0 + x_26) : (13.0 + x_27)))? ((2.0 + x_17) > ((18.0 + x_18) > (1.0 + x_20)? (18.0 + x_18) : (1.0 + x_20))? (2.0 + x_17) : ((18.0 + x_18) > (1.0 + x_20)? (18.0 + x_18) : (1.0 + x_20))) : (((6.0 + x_22) > (19.0 + x_24)? (6.0 + x_22) : (19.0 + x_24)) > ((16.0 + x_26) > (13.0 + x_27)? (16.0 + x_26) : (13.0 + x_27))? ((6.0 + x_22) > (19.0 + x_24)? (6.0 + x_22) : (19.0 + x_24)) : ((16.0 + x_26) > (13.0 + x_27)? (16.0 + x_26) : (13.0 + x_27))))? (((7.0 + x_1) > ((5.0 + x_2) > (7.0 + x_3)? (5.0 + x_2) : (7.0 + x_3))? (7.0 + x_1) : ((5.0 + x_2) > (7.0 + x_3)? (5.0 + x_2) : (7.0 + x_3))) > (((3.0 + x_5) > (15.0 + x_10)? (3.0 + x_5) : (15.0 + x_10)) > ((11.0 + x_12) > (10.0 + x_13)? (11.0 + x_12) : (10.0 + x_13))? ((3.0 + x_5) > (15.0 + x_10)? (3.0 + x_5) : (15.0 + x_10)) : ((11.0 + x_12) > (10.0 + x_13)? (11.0 + x_12) : (10.0 + x_13)))? ((7.0 + x_1) > ((5.0 + x_2) > (7.0 + x_3)? (5.0 + x_2) : (7.0 + x_3))? (7.0 + x_1) : ((5.0 + x_2) > (7.0 + x_3)? (5.0 + x_2) : (7.0 + x_3))) : (((3.0 + x_5) > (15.0 + x_10)? (3.0 + x_5) : (15.0 + x_10)) > ((11.0 + x_12) > (10.0 + x_13)? (11.0 + x_12) : (10.0 + x_13))? ((3.0 + x_5) > (15.0 + x_10)? (3.0 + x_5) : (15.0 + x_10)) : ((11.0 + x_12) > (10.0 + x_13)? (11.0 + x_12) : (10.0 + x_13)))) : (((2.0 + x_17) > ((18.0 + x_18) > (1.0 + x_20)? (18.0 + x_18) : (1.0 + x_20))? (2.0 + x_17) : ((18.0 + x_18) > (1.0 + x_20)? (18.0 + x_18) : (1.0 + x_20))) > (((6.0 + x_22) > (19.0 + x_24)? (6.0 + x_22) : (19.0 + x_24)) > ((16.0 + x_26) > (13.0 + x_27)? (16.0 + x_26) : (13.0 + x_27))? ((6.0 + x_22) > (19.0 + x_24)? (6.0 + x_22) : (19.0 + x_24)) : ((16.0 + x_26) > (13.0 + x_27)? (16.0 + x_26) : (13.0 + x_27)))? ((2.0 + x_17) > ((18.0 + x_18) > (1.0 + x_20)? (18.0 + x_18) : (1.0 + x_20))? (2.0 + x_17) : ((18.0 + x_18) > (1.0 + x_20)? (18.0 + x_18) : (1.0 + x_20))) : (((6.0 + x_22) > (19.0 + x_24)? (6.0 + x_22) : (19.0 + x_24)) > ((16.0 + x_26) > (13.0 + x_27)? (16.0 + x_26) : (13.0 + x_27))? ((6.0 + x_22) > (19.0 + x_24)? (6.0 + x_22) : (19.0 + x_24)) : ((16.0 + x_26) > (13.0 + x_27)? (16.0 + x_26) : (13.0 + x_27))))); x_19_ = ((((9.0 + x_1) > ((11.0 + x_4) > (3.0 + x_5)? (11.0 + x_4) : (3.0 + x_5))? (9.0 + x_1) : ((11.0 + x_4) > (3.0 + x_5)? (11.0 + x_4) : (3.0 + x_5))) > (((16.0 + x_8) > (10.0 + x_11)? (16.0 + x_8) : (10.0 + x_11)) > ((2.0 + x_17) > (13.0 + x_18)? (2.0 + x_17) : (13.0 + x_18))? ((16.0 + x_8) > (10.0 + x_11)? (16.0 + x_8) : (10.0 + x_11)) : ((2.0 + x_17) > (13.0 + x_18)? (2.0 + x_17) : (13.0 + x_18)))? ((9.0 + x_1) > ((11.0 + x_4) > (3.0 + x_5)? (11.0 + x_4) : (3.0 + x_5))? (9.0 + x_1) : ((11.0 + x_4) > (3.0 + x_5)? (11.0 + x_4) : (3.0 + x_5))) : (((16.0 + x_8) > (10.0 + x_11)? (16.0 + x_8) : (10.0 + x_11)) > ((2.0 + x_17) > (13.0 + x_18)? (2.0 + x_17) : (13.0 + x_18))? ((16.0 + x_8) > (10.0 + x_11)? (16.0 + x_8) : (10.0 + x_11)) : ((2.0 + x_17) > (13.0 + x_18)? (2.0 + x_17) : (13.0 + x_18)))) > (((16.0 + x_19) > ((7.0 + x_21) > (18.0 + x_22)? (7.0 + x_21) : (18.0 + x_22))? (16.0 + x_19) : ((7.0 + x_21) > (18.0 + x_22)? (7.0 + x_21) : (18.0 + x_22))) > (((6.0 + x_23) > (11.0 + x_24)? (6.0 + x_23) : (11.0 + x_24)) > ((15.0 + x_26) > (18.0 + x_27)? (15.0 + x_26) : (18.0 + x_27))? ((6.0 + x_23) > (11.0 + x_24)? (6.0 + x_23) : (11.0 + x_24)) : ((15.0 + x_26) > (18.0 + x_27)? (15.0 + x_26) : (18.0 + x_27)))? ((16.0 + x_19) > ((7.0 + x_21) > (18.0 + x_22)? (7.0 + x_21) : (18.0 + x_22))? (16.0 + x_19) : ((7.0 + x_21) > (18.0 + x_22)? (7.0 + x_21) : (18.0 + x_22))) : (((6.0 + x_23) > (11.0 + x_24)? (6.0 + x_23) : (11.0 + x_24)) > ((15.0 + x_26) > (18.0 + x_27)? (15.0 + x_26) : (18.0 + x_27))? ((6.0 + x_23) > (11.0 + x_24)? (6.0 + x_23) : (11.0 + x_24)) : ((15.0 + x_26) > (18.0 + x_27)? (15.0 + x_26) : (18.0 + x_27))))? (((9.0 + x_1) > ((11.0 + x_4) > (3.0 + x_5)? (11.0 + x_4) : (3.0 + x_5))? (9.0 + x_1) : ((11.0 + x_4) > (3.0 + x_5)? (11.0 + x_4) : (3.0 + x_5))) > (((16.0 + x_8) > (10.0 + x_11)? (16.0 + x_8) : (10.0 + x_11)) > ((2.0 + x_17) > (13.0 + x_18)? (2.0 + x_17) : (13.0 + x_18))? ((16.0 + x_8) > (10.0 + x_11)? (16.0 + x_8) : (10.0 + x_11)) : ((2.0 + x_17) > (13.0 + x_18)? (2.0 + x_17) : (13.0 + x_18)))? ((9.0 + x_1) > ((11.0 + x_4) > (3.0 + x_5)? (11.0 + x_4) : (3.0 + x_5))? (9.0 + x_1) : ((11.0 + x_4) > (3.0 + x_5)? (11.0 + x_4) : (3.0 + x_5))) : (((16.0 + x_8) > (10.0 + x_11)? (16.0 + x_8) : (10.0 + x_11)) > ((2.0 + x_17) > (13.0 + x_18)? (2.0 + x_17) : (13.0 + x_18))? ((16.0 + x_8) > (10.0 + x_11)? (16.0 + x_8) : (10.0 + x_11)) : ((2.0 + x_17) > (13.0 + x_18)? (2.0 + x_17) : (13.0 + x_18)))) : (((16.0 + x_19) > ((7.0 + x_21) > (18.0 + x_22)? (7.0 + x_21) : (18.0 + x_22))? (16.0 + x_19) : ((7.0 + x_21) > (18.0 + x_22)? (7.0 + x_21) : (18.0 + x_22))) > (((6.0 + x_23) > (11.0 + x_24)? (6.0 + x_23) : (11.0 + x_24)) > ((15.0 + x_26) > (18.0 + x_27)? (15.0 + x_26) : (18.0 + x_27))? ((6.0 + x_23) > (11.0 + x_24)? (6.0 + x_23) : (11.0 + x_24)) : ((15.0 + x_26) > (18.0 + x_27)? (15.0 + x_26) : (18.0 + x_27)))? ((16.0 + x_19) > ((7.0 + x_21) > (18.0 + x_22)? (7.0 + x_21) : (18.0 + x_22))? (16.0 + x_19) : ((7.0 + x_21) > (18.0 + x_22)? (7.0 + x_21) : (18.0 + x_22))) : (((6.0 + x_23) > (11.0 + x_24)? (6.0 + x_23) : (11.0 + x_24)) > ((15.0 + x_26) > (18.0 + x_27)? (15.0 + x_26) : (18.0 + x_27))? ((6.0 + x_23) > (11.0 + x_24)? (6.0 + x_23) : (11.0 + x_24)) : ((15.0 + x_26) > (18.0 + x_27)? (15.0 + x_26) : (18.0 + x_27))))); x_20_ = ((((20.0 + x_1) > ((7.0 + x_3) > (19.0 + x_6)? (7.0 + x_3) : (19.0 + x_6))? (20.0 + x_1) : ((7.0 + x_3) > (19.0 + x_6)? (7.0 + x_3) : (19.0 + x_6))) > (((20.0 + x_7) > (5.0 + x_9)? (20.0 + x_7) : (5.0 + x_9)) > ((12.0 + x_10) > (18.0 + x_12)? (12.0 + x_10) : (18.0 + x_12))? ((20.0 + x_7) > (5.0 + x_9)? (20.0 + x_7) : (5.0 + x_9)) : ((12.0 + x_10) > (18.0 + x_12)? (12.0 + x_10) : (18.0 + x_12)))? ((20.0 + x_1) > ((7.0 + x_3) > (19.0 + x_6)? (7.0 + x_3) : (19.0 + x_6))? (20.0 + x_1) : ((7.0 + x_3) > (19.0 + x_6)? (7.0 + x_3) : (19.0 + x_6))) : (((20.0 + x_7) > (5.0 + x_9)? (20.0 + x_7) : (5.0 + x_9)) > ((12.0 + x_10) > (18.0 + x_12)? (12.0 + x_10) : (18.0 + x_12))? ((20.0 + x_7) > (5.0 + x_9)? (20.0 + x_7) : (5.0 + x_9)) : ((12.0 + x_10) > (18.0 + x_12)? (12.0 + x_10) : (18.0 + x_12)))) > (((10.0 + x_13) > ((6.0 + x_14) > (11.0 + x_16)? (6.0 + x_14) : (11.0 + x_16))? (10.0 + x_13) : ((6.0 + x_14) > (11.0 + x_16)? (6.0 + x_14) : (11.0 + x_16))) > (((19.0 + x_17) > (10.0 + x_18)? (19.0 + x_17) : (10.0 + x_18)) > ((17.0 + x_25) > (20.0 + x_26)? (17.0 + x_25) : (20.0 + x_26))? ((19.0 + x_17) > (10.0 + x_18)? (19.0 + x_17) : (10.0 + x_18)) : ((17.0 + x_25) > (20.0 + x_26)? (17.0 + x_25) : (20.0 + x_26)))? ((10.0 + x_13) > ((6.0 + x_14) > (11.0 + x_16)? (6.0 + x_14) : (11.0 + x_16))? (10.0 + x_13) : ((6.0 + x_14) > (11.0 + x_16)? (6.0 + x_14) : (11.0 + x_16))) : (((19.0 + x_17) > (10.0 + x_18)? (19.0 + x_17) : (10.0 + x_18)) > ((17.0 + x_25) > (20.0 + x_26)? (17.0 + x_25) : (20.0 + x_26))? ((19.0 + x_17) > (10.0 + x_18)? (19.0 + x_17) : (10.0 + x_18)) : ((17.0 + x_25) > (20.0 + x_26)? (17.0 + x_25) : (20.0 + x_26))))? (((20.0 + x_1) > ((7.0 + x_3) > (19.0 + x_6)? (7.0 + x_3) : (19.0 + x_6))? (20.0 + x_1) : ((7.0 + x_3) > (19.0 + x_6)? (7.0 + x_3) : (19.0 + x_6))) > (((20.0 + x_7) > (5.0 + x_9)? (20.0 + x_7) : (5.0 + x_9)) > ((12.0 + x_10) > (18.0 + x_12)? (12.0 + x_10) : (18.0 + x_12))? ((20.0 + x_7) > (5.0 + x_9)? (20.0 + x_7) : (5.0 + x_9)) : ((12.0 + x_10) > (18.0 + x_12)? (12.0 + x_10) : (18.0 + x_12)))? ((20.0 + x_1) > ((7.0 + x_3) > (19.0 + x_6)? (7.0 + x_3) : (19.0 + x_6))? (20.0 + x_1) : ((7.0 + x_3) > (19.0 + x_6)? (7.0 + x_3) : (19.0 + x_6))) : (((20.0 + x_7) > (5.0 + x_9)? (20.0 + x_7) : (5.0 + x_9)) > ((12.0 + x_10) > (18.0 + x_12)? (12.0 + x_10) : (18.0 + x_12))? ((20.0 + x_7) > (5.0 + x_9)? (20.0 + x_7) : (5.0 + x_9)) : ((12.0 + x_10) > (18.0 + x_12)? (12.0 + x_10) : (18.0 + x_12)))) : (((10.0 + x_13) > ((6.0 + x_14) > (11.0 + x_16)? (6.0 + x_14) : (11.0 + x_16))? (10.0 + x_13) : ((6.0 + x_14) > (11.0 + x_16)? (6.0 + x_14) : (11.0 + x_16))) > (((19.0 + x_17) > (10.0 + x_18)? (19.0 + x_17) : (10.0 + x_18)) > ((17.0 + x_25) > (20.0 + x_26)? (17.0 + x_25) : (20.0 + x_26))? ((19.0 + x_17) > (10.0 + x_18)? (19.0 + x_17) : (10.0 + x_18)) : ((17.0 + x_25) > (20.0 + x_26)? (17.0 + x_25) : (20.0 + x_26)))? ((10.0 + x_13) > ((6.0 + x_14) > (11.0 + x_16)? (6.0 + x_14) : (11.0 + x_16))? (10.0 + x_13) : ((6.0 + x_14) > (11.0 + x_16)? (6.0 + x_14) : (11.0 + x_16))) : (((19.0 + x_17) > (10.0 + x_18)? (19.0 + x_17) : (10.0 + x_18)) > ((17.0 + x_25) > (20.0 + x_26)? (17.0 + x_25) : (20.0 + x_26))? ((19.0 + x_17) > (10.0 + x_18)? (19.0 + x_17) : (10.0 + x_18)) : ((17.0 + x_25) > (20.0 + x_26)? (17.0 + x_25) : (20.0 + x_26))))); x_21_ = ((((7.0 + x_0) > ((4.0 + x_2) > (8.0 + x_6)? (4.0 + x_2) : (8.0 + x_6))? (7.0 + x_0) : ((4.0 + x_2) > (8.0 + x_6)? (4.0 + x_2) : (8.0 + x_6))) > (((7.0 + x_8) > (11.0 + x_9)? (7.0 + x_8) : (11.0 + x_9)) > ((8.0 + x_10) > (8.0 + x_13)? (8.0 + x_10) : (8.0 + x_13))? ((7.0 + x_8) > (11.0 + x_9)? (7.0 + x_8) : (11.0 + x_9)) : ((8.0 + x_10) > (8.0 + x_13)? (8.0 + x_10) : (8.0 + x_13)))? ((7.0 + x_0) > ((4.0 + x_2) > (8.0 + x_6)? (4.0 + x_2) : (8.0 + x_6))? (7.0 + x_0) : ((4.0 + x_2) > (8.0 + x_6)? (4.0 + x_2) : (8.0 + x_6))) : (((7.0 + x_8) > (11.0 + x_9)? (7.0 + x_8) : (11.0 + x_9)) > ((8.0 + x_10) > (8.0 + x_13)? (8.0 + x_10) : (8.0 + x_13))? ((7.0 + x_8) > (11.0 + x_9)? (7.0 + x_8) : (11.0 + x_9)) : ((8.0 + x_10) > (8.0 + x_13)? (8.0 + x_10) : (8.0 + x_13)))) > (((4.0 + x_15) > ((4.0 + x_18) > (6.0 + x_20)? (4.0 + x_18) : (6.0 + x_20))? (4.0 + x_15) : ((4.0 + x_18) > (6.0 + x_20)? (4.0 + x_18) : (6.0 + x_20))) > (((4.0 + x_21) > (17.0 + x_24)? (4.0 + x_21) : (17.0 + x_24)) > ((5.0 + x_25) > (17.0 + x_27)? (5.0 + x_25) : (17.0 + x_27))? ((4.0 + x_21) > (17.0 + x_24)? (4.0 + x_21) : (17.0 + x_24)) : ((5.0 + x_25) > (17.0 + x_27)? (5.0 + x_25) : (17.0 + x_27)))? ((4.0 + x_15) > ((4.0 + x_18) > (6.0 + x_20)? (4.0 + x_18) : (6.0 + x_20))? (4.0 + x_15) : ((4.0 + x_18) > (6.0 + x_20)? (4.0 + x_18) : (6.0 + x_20))) : (((4.0 + x_21) > (17.0 + x_24)? (4.0 + x_21) : (17.0 + x_24)) > ((5.0 + x_25) > (17.0 + x_27)? (5.0 + x_25) : (17.0 + x_27))? ((4.0 + x_21) > (17.0 + x_24)? (4.0 + x_21) : (17.0 + x_24)) : ((5.0 + x_25) > (17.0 + x_27)? (5.0 + x_25) : (17.0 + x_27))))? (((7.0 + x_0) > ((4.0 + x_2) > (8.0 + x_6)? (4.0 + x_2) : (8.0 + x_6))? (7.0 + x_0) : ((4.0 + x_2) > (8.0 + x_6)? (4.0 + x_2) : (8.0 + x_6))) > (((7.0 + x_8) > (11.0 + x_9)? (7.0 + x_8) : (11.0 + x_9)) > ((8.0 + x_10) > (8.0 + x_13)? (8.0 + x_10) : (8.0 + x_13))? ((7.0 + x_8) > (11.0 + x_9)? (7.0 + x_8) : (11.0 + x_9)) : ((8.0 + x_10) > (8.0 + x_13)? (8.0 + x_10) : (8.0 + x_13)))? ((7.0 + x_0) > ((4.0 + x_2) > (8.0 + x_6)? (4.0 + x_2) : (8.0 + x_6))? (7.0 + x_0) : ((4.0 + x_2) > (8.0 + x_6)? (4.0 + x_2) : (8.0 + x_6))) : (((7.0 + x_8) > (11.0 + x_9)? (7.0 + x_8) : (11.0 + x_9)) > ((8.0 + x_10) > (8.0 + x_13)? (8.0 + x_10) : (8.0 + x_13))? ((7.0 + x_8) > (11.0 + x_9)? (7.0 + x_8) : (11.0 + x_9)) : ((8.0 + x_10) > (8.0 + x_13)? (8.0 + x_10) : (8.0 + x_13)))) : (((4.0 + x_15) > ((4.0 + x_18) > (6.0 + x_20)? (4.0 + x_18) : (6.0 + x_20))? (4.0 + x_15) : ((4.0 + x_18) > (6.0 + x_20)? (4.0 + x_18) : (6.0 + x_20))) > (((4.0 + x_21) > (17.0 + x_24)? (4.0 + x_21) : (17.0 + x_24)) > ((5.0 + x_25) > (17.0 + x_27)? (5.0 + x_25) : (17.0 + x_27))? ((4.0 + x_21) > (17.0 + x_24)? (4.0 + x_21) : (17.0 + x_24)) : ((5.0 + x_25) > (17.0 + x_27)? (5.0 + x_25) : (17.0 + x_27)))? ((4.0 + x_15) > ((4.0 + x_18) > (6.0 + x_20)? (4.0 + x_18) : (6.0 + x_20))? (4.0 + x_15) : ((4.0 + x_18) > (6.0 + x_20)? (4.0 + x_18) : (6.0 + x_20))) : (((4.0 + x_21) > (17.0 + x_24)? (4.0 + x_21) : (17.0 + x_24)) > ((5.0 + x_25) > (17.0 + x_27)? (5.0 + x_25) : (17.0 + x_27))? ((4.0 + x_21) > (17.0 + x_24)? (4.0 + x_21) : (17.0 + x_24)) : ((5.0 + x_25) > (17.0 + x_27)? (5.0 + x_25) : (17.0 + x_27))))); x_22_ = ((((16.0 + x_0) > ((9.0 + x_3) > (10.0 + x_4)? (9.0 + x_3) : (10.0 + x_4))? (16.0 + x_0) : ((9.0 + x_3) > (10.0 + x_4)? (9.0 + x_3) : (10.0 + x_4))) > (((13.0 + x_6) > (3.0 + x_7)? (13.0 + x_6) : (3.0 + x_7)) > ((7.0 + x_11) > (14.0 + x_14)? (7.0 + x_11) : (14.0 + x_14))? ((13.0 + x_6) > (3.0 + x_7)? (13.0 + x_6) : (3.0 + x_7)) : ((7.0 + x_11) > (14.0 + x_14)? (7.0 + x_11) : (14.0 + x_14)))? ((16.0 + x_0) > ((9.0 + x_3) > (10.0 + x_4)? (9.0 + x_3) : (10.0 + x_4))? (16.0 + x_0) : ((9.0 + x_3) > (10.0 + x_4)? (9.0 + x_3) : (10.0 + x_4))) : (((13.0 + x_6) > (3.0 + x_7)? (13.0 + x_6) : (3.0 + x_7)) > ((7.0 + x_11) > (14.0 + x_14)? (7.0 + x_11) : (14.0 + x_14))? ((13.0 + x_6) > (3.0 + x_7)? (13.0 + x_6) : (3.0 + x_7)) : ((7.0 + x_11) > (14.0 + x_14)? (7.0 + x_11) : (14.0 + x_14)))) > (((8.0 + x_15) > ((20.0 + x_17) > (12.0 + x_20)? (20.0 + x_17) : (12.0 + x_20))? (8.0 + x_15) : ((20.0 + x_17) > (12.0 + x_20)? (20.0 + x_17) : (12.0 + x_20))) > (((3.0 + x_22) > (9.0 + x_24)? (3.0 + x_22) : (9.0 + x_24)) > ((7.0 + x_25) > (13.0 + x_26)? (7.0 + x_25) : (13.0 + x_26))? ((3.0 + x_22) > (9.0 + x_24)? (3.0 + x_22) : (9.0 + x_24)) : ((7.0 + x_25) > (13.0 + x_26)? (7.0 + x_25) : (13.0 + x_26)))? ((8.0 + x_15) > ((20.0 + x_17) > (12.0 + x_20)? (20.0 + x_17) : (12.0 + x_20))? (8.0 + x_15) : ((20.0 + x_17) > (12.0 + x_20)? (20.0 + x_17) : (12.0 + x_20))) : (((3.0 + x_22) > (9.0 + x_24)? (3.0 + x_22) : (9.0 + x_24)) > ((7.0 + x_25) > (13.0 + x_26)? (7.0 + x_25) : (13.0 + x_26))? ((3.0 + x_22) > (9.0 + x_24)? (3.0 + x_22) : (9.0 + x_24)) : ((7.0 + x_25) > (13.0 + x_26)? (7.0 + x_25) : (13.0 + x_26))))? (((16.0 + x_0) > ((9.0 + x_3) > (10.0 + x_4)? (9.0 + x_3) : (10.0 + x_4))? (16.0 + x_0) : ((9.0 + x_3) > (10.0 + x_4)? (9.0 + x_3) : (10.0 + x_4))) > (((13.0 + x_6) > (3.0 + x_7)? (13.0 + x_6) : (3.0 + x_7)) > ((7.0 + x_11) > (14.0 + x_14)? (7.0 + x_11) : (14.0 + x_14))? ((13.0 + x_6) > (3.0 + x_7)? (13.0 + x_6) : (3.0 + x_7)) : ((7.0 + x_11) > (14.0 + x_14)? (7.0 + x_11) : (14.0 + x_14)))? ((16.0 + x_0) > ((9.0 + x_3) > (10.0 + x_4)? (9.0 + x_3) : (10.0 + x_4))? (16.0 + x_0) : ((9.0 + x_3) > (10.0 + x_4)? (9.0 + x_3) : (10.0 + x_4))) : (((13.0 + x_6) > (3.0 + x_7)? (13.0 + x_6) : (3.0 + x_7)) > ((7.0 + x_11) > (14.0 + x_14)? (7.0 + x_11) : (14.0 + x_14))? ((13.0 + x_6) > (3.0 + x_7)? (13.0 + x_6) : (3.0 + x_7)) : ((7.0 + x_11) > (14.0 + x_14)? (7.0 + x_11) : (14.0 + x_14)))) : (((8.0 + x_15) > ((20.0 + x_17) > (12.0 + x_20)? (20.0 + x_17) : (12.0 + x_20))? (8.0 + x_15) : ((20.0 + x_17) > (12.0 + x_20)? (20.0 + x_17) : (12.0 + x_20))) > (((3.0 + x_22) > (9.0 + x_24)? (3.0 + x_22) : (9.0 + x_24)) > ((7.0 + x_25) > (13.0 + x_26)? (7.0 + x_25) : (13.0 + x_26))? ((3.0 + x_22) > (9.0 + x_24)? (3.0 + x_22) : (9.0 + x_24)) : ((7.0 + x_25) > (13.0 + x_26)? (7.0 + x_25) : (13.0 + x_26)))? ((8.0 + x_15) > ((20.0 + x_17) > (12.0 + x_20)? (20.0 + x_17) : (12.0 + x_20))? (8.0 + x_15) : ((20.0 + x_17) > (12.0 + x_20)? (20.0 + x_17) : (12.0 + x_20))) : (((3.0 + x_22) > (9.0 + x_24)? (3.0 + x_22) : (9.0 + x_24)) > ((7.0 + x_25) > (13.0 + x_26)? (7.0 + x_25) : (13.0 + x_26))? ((3.0 + x_22) > (9.0 + x_24)? (3.0 + x_22) : (9.0 + x_24)) : ((7.0 + x_25) > (13.0 + x_26)? (7.0 + x_25) : (13.0 + x_26))))); x_23_ = ((((12.0 + x_0) > ((8.0 + x_2) > (18.0 + x_3)? (8.0 + x_2) : (18.0 + x_3))? (12.0 + x_0) : ((8.0 + x_2) > (18.0 + x_3)? (8.0 + x_2) : (18.0 + x_3))) > (((17.0 + x_4) > (4.0 + x_6)? (17.0 + x_4) : (4.0 + x_6)) > ((6.0 + x_8) > (13.0 + x_11)? (6.0 + x_8) : (13.0 + x_11))? ((17.0 + x_4) > (4.0 + x_6)? (17.0 + x_4) : (4.0 + x_6)) : ((6.0 + x_8) > (13.0 + x_11)? (6.0 + x_8) : (13.0 + x_11)))? ((12.0 + x_0) > ((8.0 + x_2) > (18.0 + x_3)? (8.0 + x_2) : (18.0 + x_3))? (12.0 + x_0) : ((8.0 + x_2) > (18.0 + x_3)? (8.0 + x_2) : (18.0 + x_3))) : (((17.0 + x_4) > (4.0 + x_6)? (17.0 + x_4) : (4.0 + x_6)) > ((6.0 + x_8) > (13.0 + x_11)? (6.0 + x_8) : (13.0 + x_11))? ((17.0 + x_4) > (4.0 + x_6)? (17.0 + x_4) : (4.0 + x_6)) : ((6.0 + x_8) > (13.0 + x_11)? (6.0 + x_8) : (13.0 + x_11)))) > (((6.0 + x_12) > ((12.0 + x_14) > (11.0 + x_19)? (12.0 + x_14) : (11.0 + x_19))? (6.0 + x_12) : ((12.0 + x_14) > (11.0 + x_19)? (12.0 + x_14) : (11.0 + x_19))) > (((17.0 + x_20) > (7.0 + x_22)? (17.0 + x_20) : (7.0 + x_22)) > ((18.0 + x_25) > (20.0 + x_26)? (18.0 + x_25) : (20.0 + x_26))? ((17.0 + x_20) > (7.0 + x_22)? (17.0 + x_20) : (7.0 + x_22)) : ((18.0 + x_25) > (20.0 + x_26)? (18.0 + x_25) : (20.0 + x_26)))? ((6.0 + x_12) > ((12.0 + x_14) > (11.0 + x_19)? (12.0 + x_14) : (11.0 + x_19))? (6.0 + x_12) : ((12.0 + x_14) > (11.0 + x_19)? (12.0 + x_14) : (11.0 + x_19))) : (((17.0 + x_20) > (7.0 + x_22)? (17.0 + x_20) : (7.0 + x_22)) > ((18.0 + x_25) > (20.0 + x_26)? (18.0 + x_25) : (20.0 + x_26))? ((17.0 + x_20) > (7.0 + x_22)? (17.0 + x_20) : (7.0 + x_22)) : ((18.0 + x_25) > (20.0 + x_26)? (18.0 + x_25) : (20.0 + x_26))))? (((12.0 + x_0) > ((8.0 + x_2) > (18.0 + x_3)? (8.0 + x_2) : (18.0 + x_3))? (12.0 + x_0) : ((8.0 + x_2) > (18.0 + x_3)? (8.0 + x_2) : (18.0 + x_3))) > (((17.0 + x_4) > (4.0 + x_6)? (17.0 + x_4) : (4.0 + x_6)) > ((6.0 + x_8) > (13.0 + x_11)? (6.0 + x_8) : (13.0 + x_11))? ((17.0 + x_4) > (4.0 + x_6)? (17.0 + x_4) : (4.0 + x_6)) : ((6.0 + x_8) > (13.0 + x_11)? (6.0 + x_8) : (13.0 + x_11)))? ((12.0 + x_0) > ((8.0 + x_2) > (18.0 + x_3)? (8.0 + x_2) : (18.0 + x_3))? (12.0 + x_0) : ((8.0 + x_2) > (18.0 + x_3)? (8.0 + x_2) : (18.0 + x_3))) : (((17.0 + x_4) > (4.0 + x_6)? (17.0 + x_4) : (4.0 + x_6)) > ((6.0 + x_8) > (13.0 + x_11)? (6.0 + x_8) : (13.0 + x_11))? ((17.0 + x_4) > (4.0 + x_6)? (17.0 + x_4) : (4.0 + x_6)) : ((6.0 + x_8) > (13.0 + x_11)? (6.0 + x_8) : (13.0 + x_11)))) : (((6.0 + x_12) > ((12.0 + x_14) > (11.0 + x_19)? (12.0 + x_14) : (11.0 + x_19))? (6.0 + x_12) : ((12.0 + x_14) > (11.0 + x_19)? (12.0 + x_14) : (11.0 + x_19))) > (((17.0 + x_20) > (7.0 + x_22)? (17.0 + x_20) : (7.0 + x_22)) > ((18.0 + x_25) > (20.0 + x_26)? (18.0 + x_25) : (20.0 + x_26))? ((17.0 + x_20) > (7.0 + x_22)? (17.0 + x_20) : (7.0 + x_22)) : ((18.0 + x_25) > (20.0 + x_26)? (18.0 + x_25) : (20.0 + x_26)))? ((6.0 + x_12) > ((12.0 + x_14) > (11.0 + x_19)? (12.0 + x_14) : (11.0 + x_19))? (6.0 + x_12) : ((12.0 + x_14) > (11.0 + x_19)? (12.0 + x_14) : (11.0 + x_19))) : (((17.0 + x_20) > (7.0 + x_22)? (17.0 + x_20) : (7.0 + x_22)) > ((18.0 + x_25) > (20.0 + x_26)? (18.0 + x_25) : (20.0 + x_26))? ((17.0 + x_20) > (7.0 + x_22)? (17.0 + x_20) : (7.0 + x_22)) : ((18.0 + x_25) > (20.0 + x_26)? (18.0 + x_25) : (20.0 + x_26))))); x_24_ = ((((6.0 + x_2) > ((8.0 + x_3) > (3.0 + x_4)? (8.0 + x_3) : (3.0 + x_4))? (6.0 + x_2) : ((8.0 + x_3) > (3.0 + x_4)? (8.0 + x_3) : (3.0 + x_4))) > (((8.0 + x_8) > (18.0 + x_10)? (8.0 + x_8) : (18.0 + x_10)) > ((18.0 + x_12) > (13.0 + x_14)? (18.0 + x_12) : (13.0 + x_14))? ((8.0 + x_8) > (18.0 + x_10)? (8.0 + x_8) : (18.0 + x_10)) : ((18.0 + x_12) > (13.0 + x_14)? (18.0 + x_12) : (13.0 + x_14)))? ((6.0 + x_2) > ((8.0 + x_3) > (3.0 + x_4)? (8.0 + x_3) : (3.0 + x_4))? (6.0 + x_2) : ((8.0 + x_3) > (3.0 + x_4)? (8.0 + x_3) : (3.0 + x_4))) : (((8.0 + x_8) > (18.0 + x_10)? (8.0 + x_8) : (18.0 + x_10)) > ((18.0 + x_12) > (13.0 + x_14)? (18.0 + x_12) : (13.0 + x_14))? ((8.0 + x_8) > (18.0 + x_10)? (8.0 + x_8) : (18.0 + x_10)) : ((18.0 + x_12) > (13.0 + x_14)? (18.0 + x_12) : (13.0 + x_14)))) > (((5.0 + x_15) > ((12.0 + x_17) > (2.0 + x_18)? (12.0 + x_17) : (2.0 + x_18))? (5.0 + x_15) : ((12.0 + x_17) > (2.0 + x_18)? (12.0 + x_17) : (2.0 + x_18))) > (((3.0 + x_22) > (7.0 + x_23)? (3.0 + x_22) : (7.0 + x_23)) > ((16.0 + x_25) > (18.0 + x_27)? (16.0 + x_25) : (18.0 + x_27))? ((3.0 + x_22) > (7.0 + x_23)? (3.0 + x_22) : (7.0 + x_23)) : ((16.0 + x_25) > (18.0 + x_27)? (16.0 + x_25) : (18.0 + x_27)))? ((5.0 + x_15) > ((12.0 + x_17) > (2.0 + x_18)? (12.0 + x_17) : (2.0 + x_18))? (5.0 + x_15) : ((12.0 + x_17) > (2.0 + x_18)? (12.0 + x_17) : (2.0 + x_18))) : (((3.0 + x_22) > (7.0 + x_23)? (3.0 + x_22) : (7.0 + x_23)) > ((16.0 + x_25) > (18.0 + x_27)? (16.0 + x_25) : (18.0 + x_27))? ((3.0 + x_22) > (7.0 + x_23)? (3.0 + x_22) : (7.0 + x_23)) : ((16.0 + x_25) > (18.0 + x_27)? (16.0 + x_25) : (18.0 + x_27))))? (((6.0 + x_2) > ((8.0 + x_3) > (3.0 + x_4)? (8.0 + x_3) : (3.0 + x_4))? (6.0 + x_2) : ((8.0 + x_3) > (3.0 + x_4)? (8.0 + x_3) : (3.0 + x_4))) > (((8.0 + x_8) > (18.0 + x_10)? (8.0 + x_8) : (18.0 + x_10)) > ((18.0 + x_12) > (13.0 + x_14)? (18.0 + x_12) : (13.0 + x_14))? ((8.0 + x_8) > (18.0 + x_10)? (8.0 + x_8) : (18.0 + x_10)) : ((18.0 + x_12) > (13.0 + x_14)? (18.0 + x_12) : (13.0 + x_14)))? ((6.0 + x_2) > ((8.0 + x_3) > (3.0 + x_4)? (8.0 + x_3) : (3.0 + x_4))? (6.0 + x_2) : ((8.0 + x_3) > (3.0 + x_4)? (8.0 + x_3) : (3.0 + x_4))) : (((8.0 + x_8) > (18.0 + x_10)? (8.0 + x_8) : (18.0 + x_10)) > ((18.0 + x_12) > (13.0 + x_14)? (18.0 + x_12) : (13.0 + x_14))? ((8.0 + x_8) > (18.0 + x_10)? (8.0 + x_8) : (18.0 + x_10)) : ((18.0 + x_12) > (13.0 + x_14)? (18.0 + x_12) : (13.0 + x_14)))) : (((5.0 + x_15) > ((12.0 + x_17) > (2.0 + x_18)? (12.0 + x_17) : (2.0 + x_18))? (5.0 + x_15) : ((12.0 + x_17) > (2.0 + x_18)? (12.0 + x_17) : (2.0 + x_18))) > (((3.0 + x_22) > (7.0 + x_23)? (3.0 + x_22) : (7.0 + x_23)) > ((16.0 + x_25) > (18.0 + x_27)? (16.0 + x_25) : (18.0 + x_27))? ((3.0 + x_22) > (7.0 + x_23)? (3.0 + x_22) : (7.0 + x_23)) : ((16.0 + x_25) > (18.0 + x_27)? (16.0 + x_25) : (18.0 + x_27)))? ((5.0 + x_15) > ((12.0 + x_17) > (2.0 + x_18)? (12.0 + x_17) : (2.0 + x_18))? (5.0 + x_15) : ((12.0 + x_17) > (2.0 + x_18)? (12.0 + x_17) : (2.0 + x_18))) : (((3.0 + x_22) > (7.0 + x_23)? (3.0 + x_22) : (7.0 + x_23)) > ((16.0 + x_25) > (18.0 + x_27)? (16.0 + x_25) : (18.0 + x_27))? ((3.0 + x_22) > (7.0 + x_23)? (3.0 + x_22) : (7.0 + x_23)) : ((16.0 + x_25) > (18.0 + x_27)? (16.0 + x_25) : (18.0 + x_27))))); x_25_ = ((((20.0 + x_0) > ((8.0 + x_5) > (13.0 + x_7)? (8.0 + x_5) : (13.0 + x_7))? (20.0 + x_0) : ((8.0 + x_5) > (13.0 + x_7)? (8.0 + x_5) : (13.0 + x_7))) > (((14.0 + x_10) > (10.0 + x_11)? (14.0 + x_10) : (10.0 + x_11)) > ((8.0 + x_13) > (9.0 + x_15)? (8.0 + x_13) : (9.0 + x_15))? ((14.0 + x_10) > (10.0 + x_11)? (14.0 + x_10) : (10.0 + x_11)) : ((8.0 + x_13) > (9.0 + x_15)? (8.0 + x_13) : (9.0 + x_15)))? ((20.0 + x_0) > ((8.0 + x_5) > (13.0 + x_7)? (8.0 + x_5) : (13.0 + x_7))? (20.0 + x_0) : ((8.0 + x_5) > (13.0 + x_7)? (8.0 + x_5) : (13.0 + x_7))) : (((14.0 + x_10) > (10.0 + x_11)? (14.0 + x_10) : (10.0 + x_11)) > ((8.0 + x_13) > (9.0 + x_15)? (8.0 + x_13) : (9.0 + x_15))? ((14.0 + x_10) > (10.0 + x_11)? (14.0 + x_10) : (10.0 + x_11)) : ((8.0 + x_13) > (9.0 + x_15)? (8.0 + x_13) : (9.0 + x_15)))) > (((1.0 + x_17) > ((13.0 + x_18) > (18.0 + x_19)? (13.0 + x_18) : (18.0 + x_19))? (1.0 + x_17) : ((13.0 + x_18) > (18.0 + x_19)? (13.0 + x_18) : (18.0 + x_19))) > (((3.0 + x_20) > (6.0 + x_23)? (3.0 + x_20) : (6.0 + x_23)) > ((9.0 + x_26) > (8.0 + x_27)? (9.0 + x_26) : (8.0 + x_27))? ((3.0 + x_20) > (6.0 + x_23)? (3.0 + x_20) : (6.0 + x_23)) : ((9.0 + x_26) > (8.0 + x_27)? (9.0 + x_26) : (8.0 + x_27)))? ((1.0 + x_17) > ((13.0 + x_18) > (18.0 + x_19)? (13.0 + x_18) : (18.0 + x_19))? (1.0 + x_17) : ((13.0 + x_18) > (18.0 + x_19)? (13.0 + x_18) : (18.0 + x_19))) : (((3.0 + x_20) > (6.0 + x_23)? (3.0 + x_20) : (6.0 + x_23)) > ((9.0 + x_26) > (8.0 + x_27)? (9.0 + x_26) : (8.0 + x_27))? ((3.0 + x_20) > (6.0 + x_23)? (3.0 + x_20) : (6.0 + x_23)) : ((9.0 + x_26) > (8.0 + x_27)? (9.0 + x_26) : (8.0 + x_27))))? (((20.0 + x_0) > ((8.0 + x_5) > (13.0 + x_7)? (8.0 + x_5) : (13.0 + x_7))? (20.0 + x_0) : ((8.0 + x_5) > (13.0 + x_7)? (8.0 + x_5) : (13.0 + x_7))) > (((14.0 + x_10) > (10.0 + x_11)? (14.0 + x_10) : (10.0 + x_11)) > ((8.0 + x_13) > (9.0 + x_15)? (8.0 + x_13) : (9.0 + x_15))? ((14.0 + x_10) > (10.0 + x_11)? (14.0 + x_10) : (10.0 + x_11)) : ((8.0 + x_13) > (9.0 + x_15)? (8.0 + x_13) : (9.0 + x_15)))? ((20.0 + x_0) > ((8.0 + x_5) > (13.0 + x_7)? (8.0 + x_5) : (13.0 + x_7))? (20.0 + x_0) : ((8.0 + x_5) > (13.0 + x_7)? (8.0 + x_5) : (13.0 + x_7))) : (((14.0 + x_10) > (10.0 + x_11)? (14.0 + x_10) : (10.0 + x_11)) > ((8.0 + x_13) > (9.0 + x_15)? (8.0 + x_13) : (9.0 + x_15))? ((14.0 + x_10) > (10.0 + x_11)? (14.0 + x_10) : (10.0 + x_11)) : ((8.0 + x_13) > (9.0 + x_15)? (8.0 + x_13) : (9.0 + x_15)))) : (((1.0 + x_17) > ((13.0 + x_18) > (18.0 + x_19)? (13.0 + x_18) : (18.0 + x_19))? (1.0 + x_17) : ((13.0 + x_18) > (18.0 + x_19)? (13.0 + x_18) : (18.0 + x_19))) > (((3.0 + x_20) > (6.0 + x_23)? (3.0 + x_20) : (6.0 + x_23)) > ((9.0 + x_26) > (8.0 + x_27)? (9.0 + x_26) : (8.0 + x_27))? ((3.0 + x_20) > (6.0 + x_23)? (3.0 + x_20) : (6.0 + x_23)) : ((9.0 + x_26) > (8.0 + x_27)? (9.0 + x_26) : (8.0 + x_27)))? ((1.0 + x_17) > ((13.0 + x_18) > (18.0 + x_19)? (13.0 + x_18) : (18.0 + x_19))? (1.0 + x_17) : ((13.0 + x_18) > (18.0 + x_19)? (13.0 + x_18) : (18.0 + x_19))) : (((3.0 + x_20) > (6.0 + x_23)? (3.0 + x_20) : (6.0 + x_23)) > ((9.0 + x_26) > (8.0 + x_27)? (9.0 + x_26) : (8.0 + x_27))? ((3.0 + x_20) > (6.0 + x_23)? (3.0 + x_20) : (6.0 + x_23)) : ((9.0 + x_26) > (8.0 + x_27)? (9.0 + x_26) : (8.0 + x_27))))); x_26_ = ((((1.0 + x_0) > ((9.0 + x_3) > (14.0 + x_5)? (9.0 + x_3) : (14.0 + x_5))? (1.0 + x_0) : ((9.0 + x_3) > (14.0 + x_5)? (9.0 + x_3) : (14.0 + x_5))) > (((10.0 + x_8) > (2.0 + x_10)? (10.0 + x_8) : (2.0 + x_10)) > ((12.0 + x_12) > (11.0 + x_15)? (12.0 + x_12) : (11.0 + x_15))? ((10.0 + x_8) > (2.0 + x_10)? (10.0 + x_8) : (2.0 + x_10)) : ((12.0 + x_12) > (11.0 + x_15)? (12.0 + x_12) : (11.0 + x_15)))? ((1.0 + x_0) > ((9.0 + x_3) > (14.0 + x_5)? (9.0 + x_3) : (14.0 + x_5))? (1.0 + x_0) : ((9.0 + x_3) > (14.0 + x_5)? (9.0 + x_3) : (14.0 + x_5))) : (((10.0 + x_8) > (2.0 + x_10)? (10.0 + x_8) : (2.0 + x_10)) > ((12.0 + x_12) > (11.0 + x_15)? (12.0 + x_12) : (11.0 + x_15))? ((10.0 + x_8) > (2.0 + x_10)? (10.0 + x_8) : (2.0 + x_10)) : ((12.0 + x_12) > (11.0 + x_15)? (12.0 + x_12) : (11.0 + x_15)))) > (((8.0 + x_16) > ((10.0 + x_17) > (9.0 + x_19)? (10.0 + x_17) : (9.0 + x_19))? (8.0 + x_16) : ((10.0 + x_17) > (9.0 + x_19)? (10.0 + x_17) : (9.0 + x_19))) > (((16.0 + x_22) > (8.0 + x_23)? (16.0 + x_22) : (8.0 + x_23)) > ((19.0 + x_24) > (12.0 + x_26)? (19.0 + x_24) : (12.0 + x_26))? ((16.0 + x_22) > (8.0 + x_23)? (16.0 + x_22) : (8.0 + x_23)) : ((19.0 + x_24) > (12.0 + x_26)? (19.0 + x_24) : (12.0 + x_26)))? ((8.0 + x_16) > ((10.0 + x_17) > (9.0 + x_19)? (10.0 + x_17) : (9.0 + x_19))? (8.0 + x_16) : ((10.0 + x_17) > (9.0 + x_19)? (10.0 + x_17) : (9.0 + x_19))) : (((16.0 + x_22) > (8.0 + x_23)? (16.0 + x_22) : (8.0 + x_23)) > ((19.0 + x_24) > (12.0 + x_26)? (19.0 + x_24) : (12.0 + x_26))? ((16.0 + x_22) > (8.0 + x_23)? (16.0 + x_22) : (8.0 + x_23)) : ((19.0 + x_24) > (12.0 + x_26)? (19.0 + x_24) : (12.0 + x_26))))? (((1.0 + x_0) > ((9.0 + x_3) > (14.0 + x_5)? (9.0 + x_3) : (14.0 + x_5))? (1.0 + x_0) : ((9.0 + x_3) > (14.0 + x_5)? (9.0 + x_3) : (14.0 + x_5))) > (((10.0 + x_8) > (2.0 + x_10)? (10.0 + x_8) : (2.0 + x_10)) > ((12.0 + x_12) > (11.0 + x_15)? (12.0 + x_12) : (11.0 + x_15))? ((10.0 + x_8) > (2.0 + x_10)? (10.0 + x_8) : (2.0 + x_10)) : ((12.0 + x_12) > (11.0 + x_15)? (12.0 + x_12) : (11.0 + x_15)))? ((1.0 + x_0) > ((9.0 + x_3) > (14.0 + x_5)? (9.0 + x_3) : (14.0 + x_5))? (1.0 + x_0) : ((9.0 + x_3) > (14.0 + x_5)? (9.0 + x_3) : (14.0 + x_5))) : (((10.0 + x_8) > (2.0 + x_10)? (10.0 + x_8) : (2.0 + x_10)) > ((12.0 + x_12) > (11.0 + x_15)? (12.0 + x_12) : (11.0 + x_15))? ((10.0 + x_8) > (2.0 + x_10)? (10.0 + x_8) : (2.0 + x_10)) : ((12.0 + x_12) > (11.0 + x_15)? (12.0 + x_12) : (11.0 + x_15)))) : (((8.0 + x_16) > ((10.0 + x_17) > (9.0 + x_19)? (10.0 + x_17) : (9.0 + x_19))? (8.0 + x_16) : ((10.0 + x_17) > (9.0 + x_19)? (10.0 + x_17) : (9.0 + x_19))) > (((16.0 + x_22) > (8.0 + x_23)? (16.0 + x_22) : (8.0 + x_23)) > ((19.0 + x_24) > (12.0 + x_26)? (19.0 + x_24) : (12.0 + x_26))? ((16.0 + x_22) > (8.0 + x_23)? (16.0 + x_22) : (8.0 + x_23)) : ((19.0 + x_24) > (12.0 + x_26)? (19.0 + x_24) : (12.0 + x_26)))? ((8.0 + x_16) > ((10.0 + x_17) > (9.0 + x_19)? (10.0 + x_17) : (9.0 + x_19))? (8.0 + x_16) : ((10.0 + x_17) > (9.0 + x_19)? (10.0 + x_17) : (9.0 + x_19))) : (((16.0 + x_22) > (8.0 + x_23)? (16.0 + x_22) : (8.0 + x_23)) > ((19.0 + x_24) > (12.0 + x_26)? (19.0 + x_24) : (12.0 + x_26))? ((16.0 + x_22) > (8.0 + x_23)? (16.0 + x_22) : (8.0 + x_23)) : ((19.0 + x_24) > (12.0 + x_26)? (19.0 + x_24) : (12.0 + x_26))))); x_27_ = ((((4.0 + x_2) > ((1.0 + x_3) > (16.0 + x_5)? (1.0 + x_3) : (16.0 + x_5))? (4.0 + x_2) : ((1.0 + x_3) > (16.0 + x_5)? (1.0 + x_3) : (16.0 + x_5))) > (((19.0 + x_7) > (6.0 + x_11)? (19.0 + x_7) : (6.0 + x_11)) > ((18.0 + x_13) > (11.0 + x_15)? (18.0 + x_13) : (11.0 + x_15))? ((19.0 + x_7) > (6.0 + x_11)? (19.0 + x_7) : (6.0 + x_11)) : ((18.0 + x_13) > (11.0 + x_15)? (18.0 + x_13) : (11.0 + x_15)))? ((4.0 + x_2) > ((1.0 + x_3) > (16.0 + x_5)? (1.0 + x_3) : (16.0 + x_5))? (4.0 + x_2) : ((1.0 + x_3) > (16.0 + x_5)? (1.0 + x_3) : (16.0 + x_5))) : (((19.0 + x_7) > (6.0 + x_11)? (19.0 + x_7) : (6.0 + x_11)) > ((18.0 + x_13) > (11.0 + x_15)? (18.0 + x_13) : (11.0 + x_15))? ((19.0 + x_7) > (6.0 + x_11)? (19.0 + x_7) : (6.0 + x_11)) : ((18.0 + x_13) > (11.0 + x_15)? (18.0 + x_13) : (11.0 + x_15)))) > (((15.0 + x_16) > ((6.0 + x_17) > (2.0 + x_18)? (6.0 + x_17) : (2.0 + x_18))? (15.0 + x_16) : ((6.0 + x_17) > (2.0 + x_18)? (6.0 + x_17) : (2.0 + x_18))) > (((5.0 + x_19) > (7.0 + x_20)? (5.0 + x_19) : (7.0 + x_20)) > ((16.0 + x_22) > (3.0 + x_26)? (16.0 + x_22) : (3.0 + x_26))? ((5.0 + x_19) > (7.0 + x_20)? (5.0 + x_19) : (7.0 + x_20)) : ((16.0 + x_22) > (3.0 + x_26)? (16.0 + x_22) : (3.0 + x_26)))? ((15.0 + x_16) > ((6.0 + x_17) > (2.0 + x_18)? (6.0 + x_17) : (2.0 + x_18))? (15.0 + x_16) : ((6.0 + x_17) > (2.0 + x_18)? (6.0 + x_17) : (2.0 + x_18))) : (((5.0 + x_19) > (7.0 + x_20)? (5.0 + x_19) : (7.0 + x_20)) > ((16.0 + x_22) > (3.0 + x_26)? (16.0 + x_22) : (3.0 + x_26))? ((5.0 + x_19) > (7.0 + x_20)? (5.0 + x_19) : (7.0 + x_20)) : ((16.0 + x_22) > (3.0 + x_26)? (16.0 + x_22) : (3.0 + x_26))))? (((4.0 + x_2) > ((1.0 + x_3) > (16.0 + x_5)? (1.0 + x_3) : (16.0 + x_5))? (4.0 + x_2) : ((1.0 + x_3) > (16.0 + x_5)? (1.0 + x_3) : (16.0 + x_5))) > (((19.0 + x_7) > (6.0 + x_11)? (19.0 + x_7) : (6.0 + x_11)) > ((18.0 + x_13) > (11.0 + x_15)? (18.0 + x_13) : (11.0 + x_15))? ((19.0 + x_7) > (6.0 + x_11)? (19.0 + x_7) : (6.0 + x_11)) : ((18.0 + x_13) > (11.0 + x_15)? (18.0 + x_13) : (11.0 + x_15)))? ((4.0 + x_2) > ((1.0 + x_3) > (16.0 + x_5)? (1.0 + x_3) : (16.0 + x_5))? (4.0 + x_2) : ((1.0 + x_3) > (16.0 + x_5)? (1.0 + x_3) : (16.0 + x_5))) : (((19.0 + x_7) > (6.0 + x_11)? (19.0 + x_7) : (6.0 + x_11)) > ((18.0 + x_13) > (11.0 + x_15)? (18.0 + x_13) : (11.0 + x_15))? ((19.0 + x_7) > (6.0 + x_11)? (19.0 + x_7) : (6.0 + x_11)) : ((18.0 + x_13) > (11.0 + x_15)? (18.0 + x_13) : (11.0 + x_15)))) : (((15.0 + x_16) > ((6.0 + x_17) > (2.0 + x_18)? (6.0 + x_17) : (2.0 + x_18))? (15.0 + x_16) : ((6.0 + x_17) > (2.0 + x_18)? (6.0 + x_17) : (2.0 + x_18))) > (((5.0 + x_19) > (7.0 + x_20)? (5.0 + x_19) : (7.0 + x_20)) > ((16.0 + x_22) > (3.0 + x_26)? (16.0 + x_22) : (3.0 + x_26))? ((5.0 + x_19) > (7.0 + x_20)? (5.0 + x_19) : (7.0 + x_20)) : ((16.0 + x_22) > (3.0 + x_26)? (16.0 + x_22) : (3.0 + x_26)))? ((15.0 + x_16) > ((6.0 + x_17) > (2.0 + x_18)? (6.0 + x_17) : (2.0 + x_18))? (15.0 + x_16) : ((6.0 + x_17) > (2.0 + x_18)? (6.0 + x_17) : (2.0 + x_18))) : (((5.0 + x_19) > (7.0 + x_20)? (5.0 + x_19) : (7.0 + x_20)) > ((16.0 + x_22) > (3.0 + x_26)? (16.0 + x_22) : (3.0 + x_26))? ((5.0 + x_19) > (7.0 + x_20)? (5.0 + x_19) : (7.0 + x_20)) : ((16.0 + x_22) > (3.0 + x_26)? (16.0 + x_22) : (3.0 + x_26))))); 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_; x_8 = x_8_; x_9 = x_9_; x_10 = x_10_; x_11 = x_11_; x_12 = x_12_; x_13 = x_13_; x_14 = x_14_; x_15 = x_15_; x_16 = x_16_; x_17 = x_17_; x_18 = x_18_; x_19 = x_19_; x_20 = x_20_; x_21 = x_21_; x_22 = x_22_; x_23 = x_23_; x_24 = x_24_; x_25 = x_25_; x_26 = x_26_; x_27 = x_27_; } return 0; }
the_stack_data/115765269.c
struct S1 { int x; int a; int arr[20]; }; struct S2 { struct S1 as[10]; }; void testStructValue(int i) { struct S1 s1; s1.a += 10; s1.a += s1.a; s1.arr[i++] -= 20; s1.arr[s1.a] *= s1.a; struct S2 s2; s2.as[i++].a += 30; s2.as[i++].a += s2.as[s1.a].a; s2.as[i++].arr[i++] -= 40; s2.as[s1.a].arr[i++] *= s2.as[i].arr[s2.as[s1.a].a]; } void testStructPtr(struct S1 *s1, struct S2 *s2, int i) { s1->a += 10; s1->a += s1->a; s1->arr[i++] -= 20; s1->arr[s1->a] *= s1->a; s2->as[i++].a += 30; s2->as[i++].a += s2->as[s1->a].a; s2->as[i++].arr[i++] -= 40; s2->as[s1->a].arr[i++] *= s2->as[i].arr[s2->as[s1->a].a]; } struct S3 { double d; unsigned f1: 10; unsigned f2: 15; }; struct S4 { struct S3 as3[10]; }; void testStructBitField(struct S4 *s4, int x) { s4->as3[x++].f1 = 10; s4->as3[x++].f2 = s4->as3[--x].f1; } void testArrayAsgn(int *ptr, int i) { ptr[i++] += 10; ptr[10] += --i; }
the_stack_data/162642832.c
/* ** EPITECH PROJECT, 2022 ** LIBMY ** File description: ** free word array */ #include <stdlib.h> /** ** @brief free a word array null terminated ** @param arr **/ void my_wordarray_free(char **arr) { if (arr == NULL) { return; } for (int i = 0; arr[i] != NULL; i++) { free(arr[i]); } free(arr); }
the_stack_data/107953630.c
#include<stdio.h> #define SIZE 10000 #pragma warning(disable : 4996) int main() { char buffer[SIZE]; fgets(buffer, SIZE, stdin); fgets(buffer, SIZE, stdin); fgets(buffer, SIZE, stdin); fgets(buffer, SIZE, stdin); fgets(buffer, SIZE, stdin); fgets(buffer, SIZE, stdin); fgets(buffer, SIZE, stdin); fgets(buffer, SIZE, stdin); fgets(buffer, SIZE, stdin); fgets(buffer, SIZE, stdin); fgets(buffer, SIZE, stdin); fgets(buffer, SIZE, stdin); fgets(buffer, SIZE, stdin); fgets(buffer, SIZE, stdin); fgets(buffer, SIZE, stdin); fgets(buffer, SIZE, stdin); fgets(buffer, SIZE, stdin); fgets(buffer, SIZE, stdin); fgets(buffer, SIZE, stdin); fputs(buffer, stdout); return 0; }
the_stack_data/124832.c
#include<stdio.h> #define TAMVETOR 9 /* quando estava fazendo o código, ele dava problema quando TAMVETOR=10, queria que me explicasse se possível */ int main() { int vetor[TAMVETOR],i,j,x; for ( i = 0; i <= TAMVETOR; i++) { puts("digite os numeros do vetor"); scanf("%d",&x); vetor[i]=x; } for ( i = 0; i <= TAMVETOR; i++ ) { for ( j = TAMVETOR; j > 0; j-- ) { if (vetor[j] > vetor[j-1]) { x=vetor[j]; vetor[j]=vetor[j-1]; vetor[j-1]=x; } } } for ( i = 0; i <= TAMVETOR; i++) { printf("%d,",vetor[i]); } printf("\n"); }
the_stack_data/45449.c
#include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <fcntl.h> void bubble_sort(int filedescr); int main(int argc,char *argv[]) { int fd; if(argc < 2) { printf("Usage: %s datafile\n", argv[0]); exit(1); } if(-1 == (fd = open(argv[1],O_RDWR))) { perror("Eroare la deschiderea fisierului de date"); exit(2); } bubble_sort(fd); close(fd); return 0; } void bubble_sort(int filedescr) { int rcod1,rcod2; int numar1,numar2; int modificare = 1; /* bucla in care facem parcurgeri repetate */ while(modificare) { modificare = 0; /* va fi setat daca se face macar o inversiune la parcurgerea curenta */ /* bucla pentru o singura parcurgere a fisierului */ while(1) { rcod1 = read(filedescr, &numar1, sizeof(int)); if(rcod1 == 0) break; /* am ajuns la EOF */ if(rcod1 ==-1) { perror("Eroare la citirea primului numar dintr-o pereche"); exit(3); } rcod2 = read(filedescr, &numar2, sizeof(int)); if(rcod2 == 0) break; /* am ajuns la EOF */ if(rcod2 ==-1) { perror("Eroare la citirea celui de-al doilea numar dintr-o pereche"); exit(4); } /* daca este inversiune, le schimbam in fisier */ if(numar1 > numar2) { modificare = 1; /* ne intoarcem inapoi cu 2 intregi pentru a face rescrierea */ if(-1 == lseek(filedescr, -2*sizeof(int), SEEK_CUR)) { perror("Eroare (1) la repozitionarea inapoi in fisier"); exit(5); } if(-1 == write(filedescr, &numar2, sizeof(int))) { perror("Eroare la rescrierea primului numar dintr-o pereche"); exit(6); } if(-1 == write(filedescr, &numar1, sizeof(int))) { perror("Eroare la rescrierea celui de-al doilea numar dintr-o pereche"); exit(7); } } /* pregatim urmatoarea iteratie: primul numar din noua pereche este ce-al doilea numar din perechea precedenta */ if(-1 == lseek(filedescr, -sizeof(int), SEEK_CUR)) { perror("Eroare (2) la repozitionarea inapoi in fisier"); exit(8); } }/* sfarsitul buclei pentru o singura parcurgere a fisierului */ /* pregatim urmatoarea parcurgere: ne repozitionam la inceputul fisierului */ if(-1 == lseek(filedescr, 0L, SEEK_SET)) { perror("Eroare (3) la repozitionarea inapoi in fisier"); exit(9); } }/* sfarsitul buclei de parcurgeri repetate */ }
the_stack_data/73575912.c
#include <stdio.h> #define MAX 100 /*Bubble sort is an algorithm that compares the adjacent elements and swaps their positions if they are not in the intended order. The order can be ascending or descending. */ //prototyping the bubble sort function void bubble_sort(int a[], int len); //utility function to sort void print_array(int a[], int n); //utility function for printiong an array //initializing main function int main(int argc, char const *argv[]) { //initial array to store elements for sorting. int A[MAX]; //size element to define the size of the array. int size, i, j; printf("enter the size of array you want:"); scanf("%d", &size); //taking the elements in the array for (i = 0; i < size; i++) { /* take the elements from user */ printf("\n"); printf("enter the element of the array:"); scanf("%d", &A[i]); } printf("\n"); printf("the initial unsorted array:"); print_array(A, size); bubble_sort(A, size); printf("\n\n"); printf("The final sorted array:"); print_array(A, size); return 0; } void bubble_sort(int a[], int n) { int i, j; for (i = 0; i < n - 1; i++) { j = i; for (j = 0; j < n - i - 1; j++) { if (a[j] > a[j + 1]) { /* code */ int temp = a[j]; a[j] = a[j + 1]; a[j + 1] = temp; } } } } void print_array(int a[], int n) { for (int i = 0; i < n; i++) { /* code */ printf(" %d ", a[i]); } }
the_stack_data/154832053.c
#include <stdio.h> #include <string.h> static size_t GetIndex(char *str, int chr) { int index; for(index = 0; ; index++) if(str[index] == chr) break; return index; } static void TIdxToXY(int index, int *px, int *py) { *px = index % 5; *py = index / 5; } static int XYToTIdx(int x, int y) { return x + y * 5; } static void CenterToRotPos(int *px, int *py, int rot) { int x = *px; int y = *py; switch(rot % 8) { case 0: x--; y--; break; case 1: y--; break; case 2: x++; y--; break; case 3: x++; break; case 4: x++; y++; break; case 5: y++; break; case 6: x--; y++; break; case 7: x--; break; } *px = x; *py = y; } int main() { char table[20]; char operations[11]; char *op; scanf("%s %s", table, operations); for(op = operations; *op; op++) { int carry = '\0'; int rot; int x; int y; TIdxToXY(GetIndex(table, *op), &x, &y); for(rot = 0; rot < 8 || carry; rot++) { int rx = x; int ry = y; CenterToRotPos(&rx, &ry, rot); if( 0 <= rx && rx < 4 && 0 <= ry && ry < 4 ) { int ri = XYToTIdx(rx, ry); if(table[ri] != '-') { int next = table[ri]; table[ri] = carry; carry = next; } } } } printf("%s\n", table); }
the_stack_data/386275.c
#include<stdio.h> #include<math.h> int main(){ float area,la,lb,lc,p; scanf("%f\n%f\n%f",&la,&lb,&lc); p = (la+lb+lc)/2; area = sqrt((p*(p-la)*(p-lb)*(p-lc))); printf("%.2f\n",area); }
the_stack_data/92324503.c
#include<stdio.h> int main() { int a,count=0,j=0,i,d,c,h[100],n; scanf("%d",&a); d=a; while(d!=0) { d=d/10; count++; } while(a!=0) { c=a%10; j=j+1; for(i=j;i<=count;i++) { n=c+n; break; } a=a/10; } printf("%d",n); return 0; }
the_stack_data/100140561.c
#include <sched.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <errno.h> int main() { int rc,current_scheduler_policy; struct sched_param my_params; //将要设置的调度参数 current_scheduler_policy=sched_getscheduler(0); printf("SCHED_OTHER = %d SCHED_FIFO =%d SCHED_RR=%d \n", SCHED_OTHER, SCHED_FIFO,SCHED_RR); printf("the current scheduler = %d \n", current_scheduler_policy); printf("press any key to change the current scheduler and priority to SCHED_RR\n"); getchar(); //checkpoint 1 my_params.sched_priority=sched_get_priority_max(SCHED_RR); // 最高的 RR 实时优先级 rc=sched_setscheduler(0,SCHED_RR,&my_params); //设置为 RR 实时进程 if(rc<0) { perror("sched_setscheduler to SCHED_RR error"); exit(0); } current_scheduler_policy=sched_getscheduler(0); printf("the current scheduler = %d \n", current_scheduler_policy); printf("press any key to change the current scheduler and priority to SCHED_FIFO\n"); getchar(); //checkpoint 2 my_params.sched_priority=sched_get_priority_min(SCHED_FIFO); // 最低 FIFO 实时优先级 rc=sched_setscheduler(0,SCHED_FIFO,&my_params); //设置为 FIFO 实时进程 if(rc<0) { perror("sched_setscheduler to SCHED_FIFO error"); exit(0); } current_scheduler_policy=sched_getscheduler(0); printf("the current scheduler = %d \n", current_scheduler_policy); printf("press any key to ange the current scheduler and priority to SCHED_OTHER(CFS)\n"); getchar(); //checkpoint 3 rc=sched_setscheduler(0,SCHED_OTHER,&my_params); //设置为普通进程 3 if(rc<0) { perror("sched_setscheduler to SCHED_OTHER error"); exit(0); } current_scheduler_policy=sched_getscheduler(0); printf("the current scheduler = %d \n", current_scheduler_policy); printf("press any key to exit\n"); getchar(); //checkpoint 4 return 0; }
the_stack_data/122015890.c
/* * POK header * * The following file is a part of the POK project. Any modification should * made according to the POK licence. You CANNOT use this file or a part of * this file is this part of a file for your own project * * For more information on the POK licence, please see our LICENCE FILE * * Please follow the coding guidelines described in doc/CODING_GUIDELINES * * Copyright (c) 2007-2009 POK team * * Created by julien on Fri Jan 30 14:41:34 2009 */ /* e_powf.c -- float version of e_pow.c. * Conversion to float by Ian Lance Taylor, Cygnus Support, [email protected]. */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. * * Developed at SunPro, a Sun Microsystems, Inc. business. * Permission to use, copy, modify, and distribute this * software is freely granted, provided that this notice * is preserved. * ==================================================== */ #ifdef POK_NEEDS_LIBMATH #include <libm.h> #include "math_private.h" static const float huge = 1.0e+30, tiny = 1.0e-30; static const float bp[] = { 1.0, 1.5, }, dp_h[] = { 0.0, 5.84960938e-01, }, /* 0x3f15c000 */ dp_l[] = { 0.0, 1.56322085e-06, }, /* 0x35d1cfdc */ zero = 0.0, one = 1.0, two = 2.0, two24 = 16777216.0, /* 0x4b800000 */ /* poly coefs for (3/2)*(log(x)-2s-2/3*s**3 */ L1 = 6.0000002384e-01, /* 0x3f19999a */ L2 = 4.2857143283e-01, /* 0x3edb6db7 */ L3 = 3.3333334327e-01, /* 0x3eaaaaab */ L4 = 2.7272811532e-01, /* 0x3e8ba305 */ L5 = 2.3066075146e-01, /* 0x3e6c3255 */ L6 = 2.0697501302e-01, /* 0x3e53f142 */ P1 = 1.6666667163e-01, /* 0x3e2aaaab */ P2 = -2.7777778450e-03, /* 0xbb360b61 */ P3 = 6.6137559770e-05, /* 0x388ab355 */ P4 = -1.6533901999e-06, /* 0xb5ddea0e */ P5 = 4.1381369442e-08, /* 0x3331bb4c */ lg2 = 6.9314718246e-01, /* 0x3f317218 */ lg2_h = 6.93145752e-01, /* 0x3f317200 */ lg2_l = 1.42860654e-06, /* 0x35bfbe8c */ ovt = 4.2995665694e-08, /* -(128-log2(ovfl+.5ulp)) */ cp = 9.6179670095e-01, /* 0x3f76384f =2/(3ln2) */ cp_h = 9.6179199219e-01, /* 0x3f763800 =head of cp */ cp_l = 4.7017383622e-06, /* 0x369dc3a0 =tail of cp_h */ ivln2 = 1.4426950216e+00, /* 0x3fb8aa3b =1/ln2 */ ivln2_h = 1.4426879883e+00, /* 0x3fb8aa00 =16b 1/ln2*/ ivln2_l = 7.0526075433e-06; /* 0x36eca570 =1/ln2 tail*/ float __ieee754_powf(float x, float y) { float z, ax, z_h, z_l, p_h, p_l; float yy1, t1, t2, r, s, t, u, v, w; int32_t i, j, k, yisint, n; int32_t hx, hy, ix, iy, is; GET_FLOAT_WORD(hx, x); GET_FLOAT_WORD(hy, y); ix = hx & 0x7fffffff; iy = hy & 0x7fffffff; /* y==zero: x**0 = 1 */ if (iy == 0) return one; /* +-NaN return x+y */ if (ix > 0x7f800000 || iy > 0x7f800000) return x + y; /* determine if y is an odd int when x < 0 * yisint = 0 ... y is not an integer * yisint = 1 ... y is an odd int * yisint = 2 ... y is an even int */ yisint = 0; if (hx < 0) { if (iy >= 0x4b800000) yisint = 2; /* even integer y */ else if (iy >= 0x3f800000) { k = (iy >> 23) - 0x7f; /* exponent */ j = iy >> (23 - k); if ((j << (23 - k)) == iy) yisint = 2 - (j & 1); } } /* special value of y */ if (iy == 0x7f800000) { /* y is +-inf */ if (ix == 0x3f800000) return y - y; /* inf**+-1 is NaN */ else if (ix > 0x3f800000) /* (|x|>1)**+-inf = inf,0 */ return (hy >= 0) ? y : zero; else /* (|x|<1)**-,+inf = inf,0 */ return (hy < 0) ? -y : zero; } if (iy == 0x3f800000) { /* y is +-1 */ if (hy < 0) return one / x; else return x; } if (hy == 0x40000000) return x * x; /* y is 2 */ if (hy == 0x3f000000) { /* y is 0.5 */ if (hx >= 0) /* x >= +0 */ return __ieee754_sqrtf(x); } ax = fabsf(x); /* special value of x */ if (ix == 0x7f800000 || ix == 0 || ix == 0x3f800000) { z = ax; /*x is +-0,+-inf,+-1*/ if (hy < 0) z = one / z; /* z = (1/|x|) */ if (hx < 0) { if (((ix - 0x3f800000) | yisint) == 0) { z = (z - z) / (z - z); /* (-1)**non-int is NaN */ } else if (yisint == 1) z = -z; /* (x<0)**odd = -(|x|**odd) */ } return z; } /* (x<0)**(non-int) is NaN */ if (((((uint32_t)hx >> 31) - 1) | yisint) == 0) return (x - x) / (x - x); /* |y| is huge */ if (iy > 0x4d000000) { /* if |y| > 2**27 */ /* over/underflow if x is not close to one */ if (ix < 0x3f7ffff8) return (hy < 0) ? huge * huge : tiny * tiny; if (ix > 0x3f800007) return (hy > 0) ? huge * huge : tiny * tiny; /* now |1-x| is tiny <= 2**-20, suffice to compute log(x) by x-x^2/2+x^3/3-x^4/4 */ t = ax - one; /* t has 20 trailing zeros */ w = (t * t) * ((float)0.5 - t * ((float)0.333333333333 - t * (float)0.25)); u = ivln2_h * t; /* ivln2_h has 16 sig. bits */ v = t * ivln2_l - w * ivln2; t1 = u + v; GET_FLOAT_WORD(is, t1); SET_FLOAT_WORD(t1, is & 0xfffff000); t2 = v - (t1 - u); } else { float s2, s_h, s_l, t_h, t_l; n = 0; /* take care subnormal number */ if (ix < 0x00800000) { ax *= two24; n -= 24; GET_FLOAT_WORD(ix, ax); } n += ((ix) >> 23) - 0x7f; j = ix & 0x007fffff; /* determine interval */ ix = j | 0x3f800000; /* normalize ix */ if (j <= 0x1cc471) k = 0; /* |x|<sqrt(3/2) */ else if (j < 0x5db3d7) k = 1; /* |x|<sqrt(3) */ else { k = 0; n += 1; ix -= 0x00800000; } SET_FLOAT_WORD(ax, ix); /* compute s = s_h+s_l = (x-1)/(x+1) or (x-1.5)/(x+1.5) */ u = ax - bp[k]; /* bp[0]=1.0, bp[1]=1.5 */ v = one / (ax + bp[k]); s = u * v; s_h = s; GET_FLOAT_WORD(is, s_h); SET_FLOAT_WORD(s_h, is & 0xfffff000); /* t_h=ax+bp[k] High */ SET_FLOAT_WORD(t_h, ((ix >> 1) | 0x20000000) + 0x0040000 + (k << 21)); t_l = ax - (t_h - bp[k]); s_l = v * ((u - s_h * t_h) - s_h * t_l); /* compute log(ax) */ s2 = s * s; r = s2 * s2 * (L1 + s2 * (L2 + s2 * (L3 + s2 * (L4 + s2 * (L5 + s2 * L6))))); r += s_l * (s_h + s); s2 = s_h * s_h; t_h = (float)3.0 + s2 + r; GET_FLOAT_WORD(is, t_h); SET_FLOAT_WORD(t_h, is & 0xfffff000); t_l = r - ((t_h - (float)3.0) - s2); /* u+v = s*(1+...) */ u = s_h * t_h; v = s_l * t_h + t_l * s; /* 2/(3log2)*(s+...) */ p_h = u + v; GET_FLOAT_WORD(is, p_h); SET_FLOAT_WORD(p_h, is & 0xfffff000); p_l = v - (p_h - u); z_h = cp_h * p_h; /* cp_h+cp_l = 2/(3*log2) */ z_l = cp_l * p_h + p_l * cp + dp_l[k]; /* log2(ax) = (s+..)*2/(3*log2) = n + dp_h + z_h + z_l */ t = (float)n; t1 = (((z_h + z_l) + dp_h[k]) + t); GET_FLOAT_WORD(is, t1); SET_FLOAT_WORD(t1, is & 0xfffff000); t2 = z_l - (((t1 - t) - dp_h[k]) - z_h); } s = one; /* s (sign of result -ve**odd) = -1 else = 1 */ if (((((uint32_t)hx >> 31) - 1) | (yisint - 1)) == 0) s = -one; /* (-ve)**(odd int) */ /* split up y into yy1+y2 and compute (yy1+y2)*(t1+t2) */ GET_FLOAT_WORD(is, y); SET_FLOAT_WORD(yy1, is & 0xfffff000); p_l = (y - yy1) * t1 + y * t2; p_h = yy1 * t1; z = p_l + p_h; GET_FLOAT_WORD(j, z); if (j > 0x43000000) /* if z > 128 */ return s * huge * huge; /* overflow */ else if (j == 0x43000000) { /* if z == 128 */ if (p_l + ovt > z - p_h) return s * huge * huge; /* overflow */ } else if ((uint32_t)j == 0xc3160000) { /* z == -150 */ if (p_l <= z - p_h) return s * tiny * tiny; /* underflow */ } else if ((j & 0x7fffffff) > 0x43160000) /* z <= -150 */ return s * tiny * tiny; /* underflow */ /* * compute 2**(p_h+p_l) */ i = j & 0x7fffffff; k = (i >> 23) - 0x7f; n = 0; if (i > 0x3f000000) { /* if |z| > 0.5, set n = [z+0.5] */ n = j + (0x00800000 >> (k + 1)); k = ((n & 0x7fffffff) >> 23) - 0x7f; /* new k for n */ SET_FLOAT_WORD(t, n & ~(0x007fffff >> k)); n = ((n & 0x007fffff) | 0x00800000) >> (23 - k); if (j < 0) n = -n; p_h -= t; } t = p_l + p_h; GET_FLOAT_WORD(is, t); SET_FLOAT_WORD(t, is & 0xfffff000); u = t * lg2_h; v = (p_l - (t - p_h)) * lg2 + t * lg2_l; z = u + v; w = v - (z - u); t = z * z; t1 = z - t * (P1 + t * (P2 + t * (P3 + t * (P4 + t * P5)))); r = (z * t1) / (t1 - two) - (w + z * w); z = one - (r - z); GET_FLOAT_WORD(j, z); j += (n << 23); if ((j >> 23) <= 0) z = scalbnf(z, n); /* subnormal output */ else SET_FLOAT_WORD(z, j); return s * z; } #endif
the_stack_data/101227.c
#include<stdio.h> #include<stdlib.h> int main() { int secretNumber = 50; int guess = 0; int guessLimit = 5; int geuessCont = 1; while (guess != secretNumber && guessLimit > 0) { printf("\nEnter your guees: "); scanf("%d", &guess); if (guess < secretNumber) { printf("\nLow guess"); }else{ printf("\nhigh guess"); } guessLimit--; } if (guess == secretNumber) { printf("\nYOU WIN"); }else{ printf("\nYOU LOSE"); } return 0; }
the_stack_data/81892.c
#include<stdio.h> int fahr2cel(int); int main() { int fahr, cels; int steps = 20; int lower = 0; int upper = 300; for(fahr = lower; fahr <= upper; fahr += steps) { cels = fahr2cel(fahr); printf("%d\t%d\n", fahr, cels); } return 0; } int fahr2cel(int fahr) { return 5 * (fahr - 32) / 9; }
the_stack_data/126561.c
#define NULL ((void*)0) typedef unsigned long size_t; // Customize by platform. typedef long intptr_t; typedef unsigned long uintptr_t; typedef long scalar_t__; // Either arithmetic or pointer type. /* By default, we understand bool (as a convenience). */ typedef int bool; #define false 0 #define true 1 /* Forward declarations */ typedef struct TYPE_8__ TYPE_4__ ; typedef struct TYPE_7__ TYPE_3__ ; typedef struct TYPE_6__ TYPE_2__ ; typedef struct TYPE_5__ TYPE_1__ ; /* Type definitions */ struct usb_interface {struct usb_host_interface* altsetting; scalar_t__ resetting_device; } ; struct TYPE_7__ {int bInterfaceNumber; int bNumEndpoints; } ; struct usb_host_interface {struct usb_host_endpoint* endpoint; TYPE_3__ desc; } ; struct usb_host_endpoint {int dummy; } ; struct TYPE_5__ {int bNumInterfaces; } ; struct usb_host_config {TYPE_2__** intf_cache; TYPE_1__ desc; } ; struct usb_hcd {TYPE_4__* driver; } ; struct usb_device {struct usb_host_endpoint** ep_in; struct usb_host_endpoint** ep_out; int /*<<< orphan*/ bus; } ; struct TYPE_8__ {int (* check_bandwidth ) (struct usb_hcd*,struct usb_device*) ;int (* drop_endpoint ) (struct usb_hcd*,struct usb_device*,struct usb_host_endpoint*) ;int (* add_endpoint ) (struct usb_hcd*,struct usb_device*,struct usb_host_endpoint*) ;int /*<<< orphan*/ (* reset_bandwidth ) (struct usb_hcd*,struct usb_device*) ;} ; struct TYPE_6__ {struct usb_host_interface* altsetting; } ; /* Variables and functions */ struct usb_hcd* bus_to_hcd (int /*<<< orphan*/ ) ; int stub1 (struct usb_hcd*,struct usb_device*,struct usb_host_endpoint*) ; int /*<<< orphan*/ stub10 (struct usb_hcd*,struct usb_device*) ; int stub2 (struct usb_hcd*,struct usb_device*,struct usb_host_endpoint*) ; int stub3 (struct usb_hcd*,struct usb_device*) ; int stub4 (struct usb_hcd*,struct usb_device*,struct usb_host_endpoint*) ; int stub5 (struct usb_hcd*,struct usb_device*,struct usb_host_endpoint*) ; int stub6 (struct usb_hcd*,struct usb_device*,struct usb_host_endpoint*) ; int stub7 (struct usb_hcd*,struct usb_device*,struct usb_host_endpoint*) ; int stub8 (struct usb_hcd*,struct usb_device*,struct usb_host_endpoint*) ; int stub9 (struct usb_hcd*,struct usb_device*) ; struct usb_host_interface* usb_altnum_to_altsetting (struct usb_interface*,int /*<<< orphan*/ ) ; struct usb_host_interface* usb_find_alt_setting (struct usb_host_config*,int,int /*<<< orphan*/ ) ; struct usb_interface* usb_ifnum_to_if (struct usb_device*,int) ; int usb_hcd_alloc_bandwidth(struct usb_device *udev, struct usb_host_config *new_config, struct usb_host_interface *cur_alt, struct usb_host_interface *new_alt) { int num_intfs, i, j; struct usb_host_interface *alt = 0; int ret = 0; struct usb_hcd *hcd; struct usb_host_endpoint *ep; hcd = bus_to_hcd(udev->bus); if (!hcd->driver->check_bandwidth) return 0; /* Configuration is being removed - set configuration 0 */ if (!new_config && !cur_alt) { for (i = 1; i < 16; ++i) { ep = udev->ep_out[i]; if (ep) hcd->driver->drop_endpoint(hcd, udev, ep); ep = udev->ep_in[i]; if (ep) hcd->driver->drop_endpoint(hcd, udev, ep); } hcd->driver->check_bandwidth(hcd, udev); return 0; } /* Check if the HCD says there's enough bandwidth. Enable all endpoints * each interface's alt setting 0 and ask the HCD to check the bandwidth * of the bus. There will always be bandwidth for endpoint 0, so it's * ok to exclude it. */ if (new_config) { num_intfs = new_config->desc.bNumInterfaces; /* Remove endpoints (except endpoint 0, which is always on the * schedule) from the old config from the schedule */ for (i = 1; i < 16; ++i) { ep = udev->ep_out[i]; if (ep) { ret = hcd->driver->drop_endpoint(hcd, udev, ep); if (ret < 0) goto reset; } ep = udev->ep_in[i]; if (ep) { ret = hcd->driver->drop_endpoint(hcd, udev, ep); if (ret < 0) goto reset; } } for (i = 0; i < num_intfs; ++i) { struct usb_host_interface *first_alt; int iface_num; first_alt = &new_config->intf_cache[i]->altsetting[0]; iface_num = first_alt->desc.bInterfaceNumber; /* Set up endpoints for alternate interface setting 0 */ alt = usb_find_alt_setting(new_config, iface_num, 0); if (!alt) /* No alt setting 0? Pick the first setting. */ alt = first_alt; for (j = 0; j < alt->desc.bNumEndpoints; j++) { ret = hcd->driver->add_endpoint(hcd, udev, &alt->endpoint[j]); if (ret < 0) goto reset; } } } if (cur_alt && new_alt) { struct usb_interface *iface = usb_ifnum_to_if(udev, cur_alt->desc.bInterfaceNumber); if (iface->resetting_device) { /* * The USB core just reset the device, so the xHCI host * and the device will think alt setting 0 is installed. * However, the USB core will pass in the alternate * setting installed before the reset as cur_alt. Dig * out the alternate setting 0 structure, or the first * alternate setting if a broken device doesn't have alt * setting 0. */ cur_alt = usb_altnum_to_altsetting(iface, 0); if (!cur_alt) cur_alt = &iface->altsetting[0]; } /* Drop all the endpoints in the current alt setting */ for (i = 0; i < cur_alt->desc.bNumEndpoints; i++) { ret = hcd->driver->drop_endpoint(hcd, udev, &cur_alt->endpoint[i]); if (ret < 0) goto reset; } /* Add all the endpoints in the new alt setting */ for (i = 0; i < new_alt->desc.bNumEndpoints; i++) { ret = hcd->driver->add_endpoint(hcd, udev, &new_alt->endpoint[i]); if (ret < 0) goto reset; } } ret = hcd->driver->check_bandwidth(hcd, udev); reset: if (ret < 0) hcd->driver->reset_bandwidth(hcd, udev); return ret; }