file
stringlengths
18
26
data
stringlengths
3
1.04M
the_stack_data/186109.c
#include <stdio.h> int main() { printf("welcome to espark \n"); return 0; }
the_stack_data/7950807.c
/************************************************************************** * simpletun.c * * * * A simplistic, simple-minded, naive tunnelling program using tun/tap * * interfaces and TCP. Handles (badly) IPv4 for tun, ARP and IPv4 for * * tap. DO NOT USE THIS PROGRAM FOR SERIOUS PURPOSES. * * * * You have been warned. * * * * (C) 2009 Davide Brini. * * * * DISCLAIMER AND WARNING: this is all work in progress. The code is * * ugly, the algorithms are naive, error checking and input validation * * are very basic, and of course there can be bugs. If that's not enough, * * the program has not been thoroughly tested, so it might even fail at * * the few simple things it should be supposed to do right. * * Needless to say, I take no responsibility whatsoever for what the * * program might do. The program has been written mostly for learning * * purposes, and can be used in the hope that is useful, but everything * * is to be taken "as is" and without any kind of warranty, implicit or * * explicit. See the file LICENSE for further details. * *************************************************************************/ // gcc simpletun.c -o simpletun #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/socket.h> #include <linux/if.h> #include <linux/if_tun.h> #include <sys/types.h> #include <sys/ioctl.h> #include <sys/stat.h> #include <fcntl.h> #include <arpa/inet.h> #include <sys/select.h> #include <sys/time.h> #include <errno.h> #include <stdarg.h> /* buffer for reading from tun/tap interface, must be >= 1500 */ #define BUFSIZE 2000 #define CLIENT 0 #define SERVER 1 #define PORT 55555 /* some common lengths */ #define IP_HDR_LEN 20 #define ETH_HDR_LEN 14 #define ARP_PKT_LEN 28 int debug; char *progname; /************************************************************************** * tun_alloc: allocates or reconnects to a tun/tap device. The caller * * needs to reserve enough space in *dev. * **************************************************************************/ int tun_alloc(char *dev, int flags) { struct ifreq ifr; int fd, err; if( (fd = open("/dev/net/tun", O_RDWR)) < 0 ) { perror("Opening /dev/net/tun"); return fd; } memset(&ifr, 0, sizeof(ifr)); ifr.ifr_flags = flags; if (*dev) { strncpy(ifr.ifr_name, dev, IFNAMSIZ); } if( (err = ioctl(fd, TUNSETIFF, (void *)&ifr)) < 0 ) { perror("ioctl(TUNSETIFF)"); close(fd); return err; } strcpy(dev, ifr.ifr_name); return fd; } /************************************************************************** * cread: read routine that checks for errors and exits if an error is * * returned. * **************************************************************************/ int cread(int fd, char *buf, int n){ int nread; if((nread=read(fd, buf, n))<0){ perror("Reading data"); exit(1); } return nread; } /************************************************************************** * cwrite: write routine that checks for errors and exits if an error is * * returned. * **************************************************************************/ int cwrite(int fd, char *buf, int n){ int nwrite; if((nwrite=write(fd, buf, n))<0){ perror("Writing data"); exit(1); } return nwrite; } /************************************************************************** * read_n: ensures we read exactly n bytes, and puts those into "buf". * * (unless EOF, of course) * **************************************************************************/ int read_n(int fd, char *buf, int n) { int nread, left = n; while(left > 0) { if ((nread = cread(fd, buf, left))==0){ return 0 ; }else { left -= nread; buf += nread; } } return n; } /************************************************************************** * do_debug: prints debugging stuff (doh!) * **************************************************************************/ void do_debug(char *msg, ...){ va_list argp; if(debug){ va_start(argp, msg); vfprintf(stderr, msg, argp); va_end(argp); } } /************************************************************************** * my_err: prints custom error messages on stderr. * **************************************************************************/ void my_err(char *msg, ...) { va_list argp; va_start(argp, msg); vfprintf(stderr, msg, argp); va_end(argp); } /************************************************************************** * usage: prints usage and exits. * **************************************************************************/ void usage(void) { fprintf(stderr, "Usage:\n"); fprintf(stderr, "%s -i <ifacename> [-s|-c <serverIP>] [-p <port>] [-u|-a] [-d]\n", progname); fprintf(stderr, "%s -h\n", progname); fprintf(stderr, "\n"); fprintf(stderr, "-i <ifacename>: Name of interface to use (mandatory)\n"); fprintf(stderr, "-s|-c <serverIP>: run in server mode (-s), or specify server address (-c <serverIP>) (mandatory)\n"); fprintf(stderr, "-p <port>: port to listen on (if run in server mode) or to connect to (in client mode), default 55555\n"); fprintf(stderr, "-u|-a: use TUN (-u, default) or TAP (-a)\n"); fprintf(stderr, "-d: outputs debug information while running\n"); fprintf(stderr, "-h: prints this help text\n"); exit(1); } int main(int argc, char *argv[]) { int tap_fd, option; int flags = IFF_TUN; char if_name[IFNAMSIZ] = ""; int header_len = IP_HDR_LEN; int maxfd; uint16_t nread, nwrite, plength; // uint16_t total_len, ethertype; char buffer[BUFSIZE]; struct sockaddr_in local, remote; char remote_ip[16] = ""; unsigned short int port = PORT; int sock_fd, net_fd, optval = 1; socklen_t remotelen; int cliserv = -1; /* must be specified on cmd line */ unsigned long int tap2net = 0, net2tap = 0; progname = argv[0]; /* Check command line options */ while((option = getopt(argc, argv, "i:sc:p:uahd")) > 0){ switch(option) { case 'd': debug = 1; break; case 'h': usage(); break; case 'i': strncpy(if_name,optarg,IFNAMSIZ-1); break; case 's': cliserv = SERVER; break; case 'c': cliserv = CLIENT; strncpy(remote_ip,optarg,15); break; case 'p': port = atoi(optarg); break; case 'u': flags = IFF_TUN; break; case 'a': flags = IFF_TAP; header_len = ETH_HDR_LEN; break; default: my_err("Unknown option %c\n", option); usage(); } } argv += optind; argc -= optind; if(argc > 0){ my_err("Too many options!\n"); usage(); } if(*if_name == '\0'){ my_err("Must specify interface name!\n"); usage(); }else if(cliserv < 0){ my_err("Must specify client or server mode!\n"); usage(); }else if((cliserv == CLIENT)&&(*remote_ip == '\0')){ my_err("Must specify server address!\n"); usage(); } /* initialize tun/tap interface */ if ( (tap_fd = tun_alloc(if_name, flags | IFF_NO_PI)) < 0 ) { my_err("Error connecting to tun/tap interface %s!\n", if_name); exit(1); } do_debug("Successfully connected to interface %s\n", if_name); if ( (sock_fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { perror("socket()"); exit(1); } if(cliserv==CLIENT){ /* Client, try to connect to server */ /* assign the destination address */ memset(&remote, 0, sizeof(remote)); remote.sin_family = AF_INET; remote.sin_addr.s_addr = inet_addr(remote_ip); remote.sin_port = htons(port); /* connection request */ if (connect(sock_fd, (struct sockaddr*) &remote, sizeof(remote)) < 0){ perror("connect()"); exit(1); } net_fd = sock_fd; do_debug("CLIENT: Connected to server %s\n", inet_ntoa(remote.sin_addr)); } else { /* Server, wait for connections */ /* avoid EADDRINUSE error on bind() */ if(setsockopt(sock_fd, SOL_SOCKET, SO_REUSEADDR, (char *)&optval, sizeof(optval)) < 0){ perror("setsockopt()"); exit(1); } memset(&local, 0, sizeof(local)); local.sin_family = AF_INET; local.sin_addr.s_addr = htonl(INADDR_ANY); local.sin_port = htons(port); if (bind(sock_fd, (struct sockaddr*) &local, sizeof(local)) < 0){ perror("bind()"); exit(1); } if (listen(sock_fd, 5) < 0){ perror("listen()"); exit(1); } /* wait for connection request */ remotelen = sizeof(remote); memset(&remote, 0, remotelen); if ((net_fd = accept(sock_fd, (struct sockaddr*)&remote, &remotelen)) < 0){ perror("accept()"); exit(1); } do_debug("SERVER: Client connected from %s\n", inet_ntoa(remote.sin_addr)); } /* use select() to handle two descriptors at once */ maxfd = (tap_fd > net_fd)?tap_fd:net_fd; while(1) { int ret; fd_set rd_set; FD_ZERO(&rd_set); FD_SET(tap_fd, &rd_set); FD_SET(net_fd, &rd_set); ret = select(maxfd + 1, &rd_set, NULL, NULL, NULL); if (ret < 0 && errno == EINTR){ continue; } if (ret < 0) { perror("select()"); exit(1); } if(FD_ISSET(tap_fd, &rd_set)){ /* data from tun/tap: just read it and write it to the network */ nread = cread(tap_fd, buffer, BUFSIZE); tap2net++; do_debug("TAP2NET %lu: Read %d bytes from the tap interface\n", tap2net, nread); /* write length + packet */ plength = htons(nread); nwrite = cwrite(net_fd, (char *)&plength, sizeof(plength)); nwrite = cwrite(net_fd, buffer, nread); do_debug("TAP2NET %lu: Written %d bytes to the network\n", tap2net, nwrite); } if(FD_ISSET(net_fd, &rd_set)){ /* data from the network: read it, and write it to the tun/tap interface. * We need to read the length first, and then the packet */ /* Read length */ nread = read_n(net_fd, (char *)&plength, sizeof(plength)); if(nread == 0) { /* ctrl-c at the other end */ break; } net2tap++; /* read packet */ nread = read_n(net_fd, buffer, ntohs(plength)); do_debug("NET2TAP %lu: Read %d bytes from the network\n", net2tap, nread); /* now buffer[] contains a full packet or frame, write it into the tun/tap interface */ nwrite = cwrite(tap_fd, buffer, nread); do_debug("NET2TAP %lu: Written %d bytes to the tap interface\n", net2tap, nwrite); } } return(0); }
the_stack_data/140081.c
#include <stdio.h> typedef struct pass_t { int onefish; int twofish; int redfish; int bluefish; } pass_t; void pass_by_value(pass_t p) { p.onefish = 5; } void pass_by_reference(pass_t *p) { p->onefish = 5; } int main(void) { pass_t pass_it; pass_it.onefish = 0; pass_it.twofish = 1; pass_it.redfish = 2; pass_it.bluefish = 3; pass_by_value(pass_it); printf("pass_it.onefish by value: %d\n", pass_it.onefish); pass_by_reference(&pass_it); printf("pass_it.onefish by reference: %d\n", pass_it.onefish); }
the_stack_data/48530.c
/*Exercise 3 - Repetition Write a C program to calculate the sum of the numbers from 1 to n. Where n is a keyboard input. e.g. n -> 100 sum = 1+2+3+....+ 99+100 = 5050 n -> 1- sum = 1+2+3+...+10 = 55 */ #include <stdio.h> int main() { int n; int sum = 0; printf("Enter a number :"); scanf("%d", &n); while(n<=100){ sum= sum+n; n++;} printf("%d", sum); return 0; }
the_stack_data/22221.c
#include <math.h> #include <stdio.h> void start_slice(){ __asm__ __volatile__ (""); } void end_slice(){ __asm__ __volatile__ (""); } float iprod(float* a,float* b) { return (a[0]*b[0]+a[1]*b[1]+a[2]*b[2]); } float r_kj[10][3] = { {268453443323035648, 0.71653062105178833008, 1389.514892578125}, {2.0770905828637609147e-10, 4.5552733528942065653e-24, 2.793811015866509706e-10}, {0.092040725052356719971, 0.0022920905612409114838, 5.4301075065642613301e-21}, {943433600, 5.7629808612905003154e-30, 1.9748078868190349535e-40}, {3.715846901286568027e-07, 184.290313720703125, 1.8683431344172884485e-29}, {4.208303749919650727e-08, 1.8677865192031556994e-39, 3.7274539151040134087e-43}, {5.8237964177339397468e-42, 4.9045446251368597482e-44, 3.2664267203411485923e-42}, {340.728424072265625, 2.7634128318965167637e-10, 1205.4989013671875}, {1056530038784, 1067773132800, 4.8185892015429297611e-37}, {0.0053226999007165431976, 1.2250422945568828905e-22, 8.1286535331538631898e-39} }; int main() { start_slice(); float nrkj2, nrkj; for (int i = 0; i < 10; i++){ nrkj2 = iprod(r_kj[i], r_kj[i]); nrkj = sqrt(nrkj2); printf("%e\n", nrkj); } end_slice(); return 0; }
the_stack_data/182953795.c
#include <stdio.h> int main(void) { printf("%d\n", 1); printf("%d\n", 2); printf("%d\n", 3); printf("%d\n", 4); printf("%d\n", 5); printf("%d\n", 6); printf("%d\n", 7); printf("%d\n", 8); printf("%d\n", 9); printf("%d\n", 10); return 0; }
the_stack_data/624313.c
/* this file contains the actual definitions of */ /* the IIDs and CLSIDs */ /* link this file in with the server and any clients */ /* File created by MIDL compiler version 3.00.15 */ /* at Tue Jul 08 18:10:20 1997 */ /* Compiler settings for comserver.idl: Os, W1, Zp8, env=Win32, ms_ext, c_ext error checks: none */ //@@MIDL_FILE_HEADING( ) #ifdef __cplusplus extern "C"{ #endif #ifndef IID_DEFINED #define IID_DEFINED typedef struct _IID { unsigned long x; unsigned short s1; unsigned short s2; unsigned char c[8]; } IID; #endif // IID_DEFINED #ifndef CLSID_DEFINED #define CLSID_DEFINED typedef IID CLSID; #endif // CLSID_DEFINED const IID IID_IConfigShell = {0x2786c390,0xf18a,0x11d0,{0x96,0x99,0x00,0xa0,0x24,0x58,0x36,0xd0}}; const IID LIBID_ServerLib = {0x2786c391,0xf18a,0x11d0,{0x96,0x99,0x00,0xa0,0x24,0x58,0x36,0xd0}}; const CLSID CLSID_ConfigShell = {0x2786c392,0xf18a,0x11d0,{0x96,0x99,0x00,0xa0,0x24,0x58,0x36,0xd0}}; #ifdef __cplusplus } #endif
the_stack_data/198581666.c
/* * Linux socket() test on Windows. * With the help of OpenWatcom and Linux Subsystem for Windows 10. * https://msdn.microsoft.com/en-us/commandline/wsl/install-win10?f=255&MSPPError=-2147217396 */ #include <stdio.h> #include <string.h> #include <sys/socket.h> #include <arpa/inet.h> int open_sock (const struct sockaddr_in *addr) { int fd, ret; fd = socket (AF_INET, SOCK_DGRAM, 0); if (fd < 0) perror ("socket"); else close (fd); return (0); } int main (void) { struct sockaddr_in addr; memset (&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; //open_sock (&addr); return (-1); }
the_stack_data/200142583.c
#include <stdio.h> #include <string.h> int main(void) { char str[] = "This is a string"; char *res; res = strrchr(str, 's'); if (res != NULL) { printf("Last occurence of 's' found at %d \n", res - str + 1); } else { printf("Not find that.\n"); } return 0; }
the_stack_data/134554.c
#include <stdio.h> int main() { int age, salary; char exp; printf("what is your age: \n"); scanf("%d", &age); printf("are you experienced? type Y or N: \n"); scanf(" %c", &exp); if ((age>=40) && (exp == 'Y')){ salary = 560000; printf("your salary is: %d\n", salary); } else if ((age >= 30 ) && (age < 40) && (exp == 'Y')) { salary = 480000; printf("your salary is: %d\n", salary); } else if ((age < 28) && (exp == 'Y')) { salary = 300000; printf("your salary is: %d\n", salary); } else if ((exp == 'N')) { salary = 100000; printf("your salary is: %d\n", salary); } else{ printf("error \n"); } }
the_stack_data/113212.c
#include <stdio.h> #define MAXTITL 64 #define MAXAUTH 64 struct book{ char title[MAXTITL]; char auth[MAXAUTH]; float value; }; int main(int argc, char *argv[]) { struct book abook; printf("Please enter the book title : "); gets(abook.title); printf("Now enter the author : "); gets(abook.auth); printf("Enter the price of the book : $"); scanf("%f", &abook.value); printf("\e[3;33m%s\e[0m by \e[0;31m%s \e[0m: \e[0;30m$%.2f[0m\n", abook.title, abook.auth, abook.value); return 0; }
the_stack_data/34512488.c
#include <errno.h> int write (int fd, const char *buf, int sz) { int nwritten; int r = _sys_write (fd, buf, sz, &nwritten); if (r != 0) { errno = r; return -1; } return nwritten; }
the_stack_data/192331462.c
void mx_swap_char(char *s1, char *s2) { if (!s1 || !s2) return; char temp = *s1; *s1 = *s2; *s2 = temp; }
the_stack_data/57950911.c
/* HAL raised several warnings, ignore them */ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-parameter" #ifdef STM32F0xx #include "stm32f0xx_hal_smartcard.c" #elif STM32F1xx #include "stm32f1xx_hal_smartcard.c" #elif STM32F2xx #include "stm32f2xx_hal_smartcard.c" #elif STM32F3xx #include "stm32f3xx_hal_smartcard.c" #elif STM32F4xx #include "stm32f4xx_hal_smartcard.c" #elif STM32F7xx #include "stm32f7xx_hal_smartcard.c" #elif STM32G0xx #include "stm32g0xx_hal_smartcard.c" #elif STM32G4xx #include "stm32g4xx_hal_smartcard.c" #elif STM32H7xx #include "stm32h7xx_hal_smartcard.c" #elif STM32L0xx #include "stm32l0xx_hal_smartcard.c" #elif STM32L1xx #include "stm32l1xx_hal_smartcard.c" #elif STM32L4xx #include "stm32l4xx_hal_smartcard.c" #elif STM32L5xx #include "stm32l5xx_hal_smartcard.c" #elif STM32MP1xx #include "stm32mp1xx_hal_smartcard.c" #elif STM32WBxx #include "stm32wbxx_hal_smartcard.c" #endif #pragma GCC diagnostic pop
the_stack_data/89200676.c
#include <stdio.h> #include <termios.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/ioctl.h> #include <fcntl.h> #include <stdlib.h> #include <strings.h> #include <string.h> #include <poll.h> #include <unistd.h> #include <getopt.h> #include <time.h> #include <linux/serial.h> #include <errno.h> // command line args int _cl_baud = 0; char *_cl_port = NULL; int _cl_divisor = 0; int _cl_rx_dump = 0; int _cl_rx_dump_ascii = 0; int _cl_tx_detailed = 0; int _cl_stats = 0; int _cl_stop_on_error = 0; int _cl_single_byte = -1; int _cl_another_byte = -1; int _cl_rts_cts = 0; int _cl_2_stop_bit = 0; int _cl_parity = 0; int _cl_odd_parity = 0; int _cl_stick_parity = 0; int _cl_dump_err = 0; int _cl_no_rx = 0; int _cl_no_tx = 0; int _cl_rx_delay = 0; int _cl_tx_delay = 0; int _cl_tx_bytes = 0; int _cl_rs485_delay = -1; int _cl_tx_time = 0; int _cl_rx_time = 0; // Module variables unsigned char _write_count_value = 0; unsigned char _read_count_value = 0; int _fd = -1; unsigned char * _write_data; ssize_t _write_size; // keep our own counts for cases where the driver stats don't work int _write_count = 0; int _read_count = 0; int _error_count = 0; void dump_data(unsigned char * b, int count) { printf("%i bytes: ", count); int i; for (i=0; i < count; i++) { printf("%02x ", b[i]); } printf("\n"); } void dump_data_ascii(unsigned char * b, int count) { int i; for (i=0; i < count; i++) { printf("%c", b[i]); } } void set_baud_divisor(int speed) { // default baud was not found, so try to set a custom divisor struct serial_struct ss; if (ioctl(_fd, TIOCGSERIAL, &ss) != 0) { printf("TIOCGSERIAL failed\n"); exit(1); } ss.flags = (ss.flags & ~ASYNC_SPD_MASK) | ASYNC_SPD_CUST; ss.custom_divisor = (ss.baud_base + (speed/2)) / speed; int closest_speed = ss.baud_base / ss.custom_divisor; if (closest_speed < speed * 98 / 100 || closest_speed > speed * 102 / 100) { printf("Cannot set speed to %d, closest is %d\n", speed, closest_speed); exit(1); } printf("closest baud = %i, base = %i, divisor = %i\n", closest_speed, ss.baud_base, ss.custom_divisor); if (ioctl(_fd, TIOCSSERIAL, &ss) < 0) { printf("TIOCSSERIAL failed\n"); exit(1); } } // converts integer baud to Linux define int get_baud(int baud) { switch (baud) { case 9600: return B9600; case 19200: return B19200; case 38400: return B38400; case 57600: return B57600; case 115200: return B115200; case 230400: return B230400; case 460800: return B460800; case 500000: return B500000; case 576000: return B576000; case 921600: return B921600; case 1000000: return B1000000; case 1152000: return B1152000; case 1500000: return B1500000; case 2000000: return B2000000; case 2500000: return B2500000; case 3000000: return B3000000; case 3500000: return B3500000; case 4000000: return B4000000; default: return -1; } } void display_help() { printf("Usage: linux-serial-test [OPTION]\n" "\n" " -h, --help\n" " -b, --baud Baud rate, 115200, etc (115200 is default)\n" " -p, --port Port (/dev/ttyS0, etc) (must be specified)\n" " -d, --divisor UART Baud rate divisor (can be used to set custom baud rates)\n" " -R, --rx_dump Dump Rx data (ascii, raw)\n" " -T, --detailed_tx Detailed Tx data\n" " -s, --stats Dump serial port stats every 5s\n" " -S, --stop-on-err Stop program if we encounter an error\n" " -y, --single-byte Send specified byte to the serial port\n" " -z, --second-byte Send another specified byte to the serial port\n" " -c, --rts-cts Enable RTS/CTS flow control\n" " -B, --2-stop-bit Use two stop bits per character\n" " -P, --parity Use parity bit (odd, even, mark, space)\n" " -e, --dump-err Display errors\n" " -r, --no-rx Don't receive data (can be used to test flow control)\n" " when serial driver buffer is full\n" " -t, --no-tx Don't transmit data\n" " -l, --rx-delay Delay between reading data (ms) (can be used to test flow control)\n" " -a, --tx-delay Delay between writing data (ms)\n" " -w, --tx-bytes Number of bytes for each write (default is to repeatedly write 1024 bytes\n" " until no more are accepted)\n" " -q, --rs485 Enable RS485 direction control on port, and set delay\n" " from when TX is finished and RS485 driver enable is\n" " de-asserted. Delay is specified in bit times.\n" " -o, --tx-time Number of seconds to transmit for (defaults to 0, meaning no limit)\n" " -i, --rx-time Number of seconds to receive for (defaults to 0, meaning no limit)\n" "\n" ); exit(0); } void process_options(int argc, char * argv[]) { for (;;) { int option_index = 0; static const char *short_options = "hb:p:d:R:TsSy:z:cBertq:l:a:w:o:i:P:"; static const struct option long_options[] = { {"help", no_argument, 0, 0}, {"baud", required_argument, 0, 'b'}, {"port", required_argument, 0, 'p'}, {"divisor", required_argument, 0, 'd'}, {"rx_dump", required_argument, 0, 'R'}, {"detailed_tx", no_argument, 0, 'T'}, {"stats", no_argument, 0, 's'}, {"stop-on-err", no_argument, 0, 'S'}, {"single-byte", no_argument, 0, 'y'}, {"second-byte", no_argument, 0, 'z'}, {"rts-cts", no_argument, 0, 'c'}, {"2-stop-bit", no_argument, 0, 'B'}, {"parity", required_argument, 0, 'P'}, {"dump-err", no_argument, 0, 'e'}, {"no-rx", no_argument, 0, 'r'}, {"no-tx", no_argument, 0, 't'}, {"rx-delay", required_argument, 0, 'l'}, {"tx-delay", required_argument, 0, 'a'}, {"tx-bytes", required_argument, 0, 'w'}, {"rs485", required_argument, 0, 'q'}, {"tx-time", required_argument, 0, 'o'}, {"rx-time", required_argument, 0, 'i'}, {0,0,0,0}, }; int c = getopt_long(argc, argv, short_options, long_options, &option_index); if (c == EOF) { break; } switch (c) { case 0: display_help(); break; case 'h': display_help(); break; case 'b': _cl_baud = atoi(optarg); break; case 'p': _cl_port = strdup(optarg); break; case 'd': _cl_divisor = atoi(optarg); break; case 'R': _cl_rx_dump = 1; _cl_rx_dump_ascii = !strcmp(optarg, "ascii"); break; case 'T': _cl_tx_detailed = 1; break; case 's': _cl_stats = 1; break; case 'S': _cl_stop_on_error = 1; break; case 'y': { char * endptr; _cl_single_byte = strtol(optarg, &endptr, 0); break; } case 'z': { char * endptr; _cl_another_byte = strtol(optarg, &endptr, 0); break; } case 'c': _cl_rts_cts = 1; break; case 'B': _cl_2_stop_bit = 1; break; case 'P': _cl_parity = 1; _cl_odd_parity = (!strcmp(optarg, "mark")||!strcmp(optarg, "odd")); _cl_stick_parity = (!strcmp(optarg, "mark")||!strcmp(optarg, "space")); break; case 'e': _cl_dump_err = 1; break; case 'r': _cl_no_rx = 1; break; case 't': _cl_no_tx = 1; break; case 'l': { char *endptr; _cl_rx_delay = strtol(optarg, &endptr, 0); break; } case 'a': { char *endptr; _cl_tx_delay = strtol(optarg, &endptr, 0); break; } case 'w': { char *endptr; _cl_tx_bytes = strtol(optarg, &endptr, 0); break; } case 'q': { char *endptr; _cl_rs485_delay = strtol(optarg, &endptr, 0); break; } case 'o': { char *endptr; _cl_tx_time = strtol(optarg, &endptr, 0); break; } case 'i': { char *endptr; _cl_rx_time = strtol(optarg, &endptr, 0); break; } } } } void dump_serial_port_stats() { struct serial_icounter_struct icount = { 0 }; printf("%s: count for this session: rx=%i, tx=%i, rx err=%i\n", _cl_port, _read_count, _write_count, _error_count); int ret = ioctl(_fd, TIOCGICOUNT, &icount); if (ret != -1) { printf("%s: TIOCGICOUNT: ret=%i, rx=%i, tx=%i, frame = %i, overrun = %i, parity = %i, brk = %i, buf_overrun = %i\n", _cl_port, ret, icount.rx, icount.tx, icount.frame, icount.overrun, icount.parity, icount.brk, icount.buf_overrun); } } void process_read_data() { unsigned char rb[1024]; int c = read(_fd, &rb, sizeof(rb)); if (c > 0) { if (_cl_rx_dump) { if (_cl_rx_dump_ascii) dump_data_ascii(rb, c); else dump_data(rb, c); } // verify read count is incrementing int i; for (i = 0; i < c; i++) { if (rb[i] != _read_count_value) { if (_cl_dump_err) { printf("Error, count: %i, expected %02x, got %02x\n", _read_count + i, _read_count_value, rb[i]); } _error_count++; if (_cl_stop_on_error) { dump_serial_port_stats(); exit(1); } _read_count_value = rb[i]; } _read_count_value++; } _read_count += c; } } void process_write_data() { ssize_t count = 0; int repeat = (_cl_tx_bytes == 0); do { ssize_t i; for (i = 0; i < _write_size; i++) { _write_data[i] = _write_count_value; _write_count_value++; } ssize_t c = write(_fd, _write_data, _write_size); if (c < 0) { printf("write failed (%d)\n", errno); c = 0; } count += c; if (c < _write_size) { _write_count_value -= _write_size - c; repeat = 0; } } while (repeat); _write_count += count; if (_cl_tx_detailed) printf("wrote %zd bytes\n", count); } void setup_serial_port(int baud) { struct termios newtio; _fd = open(_cl_port, O_RDWR | O_NONBLOCK); if (_fd < 0) { printf("Error opening serial port \n"); free(_cl_port); exit(1); } bzero(&newtio, sizeof(newtio)); /* clear struct for new port settings */ /* man termios get more info on below settings */ newtio.c_cflag = baud | CS8 | CLOCAL | CREAD; if (_cl_rts_cts) { newtio.c_cflag |= CRTSCTS; } if (_cl_2_stop_bit) { newtio.c_cflag |= CSTOPB; } if (_cl_parity) { newtio.c_cflag |= PARENB; if (_cl_odd_parity) { newtio.c_cflag |= PARODD; } if (_cl_stick_parity) { newtio.c_cflag |= CMSPAR; } } newtio.c_iflag = 0; newtio.c_oflag = 0; newtio.c_lflag = 0; // block for up till 128 characters newtio.c_cc[VMIN] = 128; // 0.5 seconds read timeout newtio.c_cc[VTIME] = 5; /* now clean the modem line and activate the settings for the port */ tcflush(_fd, TCIOFLUSH); tcsetattr(_fd,TCSANOW,&newtio); /* enable rs485 direction control */ if (_cl_rs485_delay >= 0) { struct serial_rs485 rs485; if(ioctl(_fd, TIOCGRS485, &rs485) < 0) { printf("Error getting rs485 mode\n"); } else { rs485.flags |= SER_RS485_ENABLED | SER_RS485_RTS_ON_SEND | SER_RS485_RTS_AFTER_SEND; rs485.delay_rts_after_send = _cl_rs485_delay; rs485.delay_rts_before_send = 0; if(ioctl(_fd, TIOCSRS485, &rs485) < 0) { printf("Error setting rs485 mode\n"); } } } } int diff_ms(const struct timespec *t1, const struct timespec *t2) { struct timespec diff; diff.tv_sec = t1->tv_sec - t2->tv_sec; diff.tv_nsec = t1->tv_nsec - t2->tv_nsec; if (diff.tv_nsec < 0) { diff.tv_sec--; diff.tv_nsec += 1000000000; } return (diff.tv_sec * 1000 + diff.tv_nsec/1000000); } int main(int argc, char * argv[]) { printf("Linux serial test app\n"); process_options(argc, argv); if (!_cl_port) { printf("ERROR: Port argument required\n"); display_help(); } int baud = B115200; if (_cl_baud) baud = get_baud(_cl_baud); if (baud <= 0) { printf("NOTE: non standard baud rate, trying custom divisor\n"); baud = B38400; setup_serial_port(B38400); set_baud_divisor(_cl_baud); } else { setup_serial_port(baud); } if (_cl_single_byte >= 0) { unsigned char data[2]; data[0] = (unsigned char)_cl_single_byte; if (_cl_another_byte < 0) { write(_fd, &data, 1); } else { data[1] = _cl_another_byte; write(_fd, &data, 2); } return 0; } _write_size = (_cl_tx_bytes == 0) ? 1024 : _cl_tx_bytes; _write_data = malloc(_write_size); if (_write_data == NULL) { printf("ERROR: Memory allocation failed\n"); } struct pollfd serial_poll; serial_poll.fd = _fd; if (!_cl_no_rx) { serial_poll.events |= POLLIN; } else { serial_poll.events &= ~POLLIN; } if (!_cl_no_tx) { serial_poll.events |= POLLOUT; } else { serial_poll.events &= ~POLLOUT; } struct timespec start_time, last_stat; struct timespec last_read = { .tv_sec = 0, .tv_nsec = 0 }; struct timespec last_write = { .tv_sec = 0, .tv_nsec = 0 }; clock_gettime(CLOCK_MONOTONIC, &start_time); last_stat = start_time; while (!(_cl_no_rx && _cl_no_tx)) { int retval = poll(&serial_poll, 1, 1000); if (retval == -1) { perror("poll()"); } else if (retval) { if (serial_poll.revents & POLLIN) { if (_cl_rx_delay) { // only read if it has been rx-delay ms // since the last read struct timespec current; clock_gettime(CLOCK_MONOTONIC, &current); if (diff_ms(&current, &last_read) > _cl_rx_delay) { process_read_data(); last_read = current; } } else { process_read_data(); } } if (serial_poll.revents & POLLOUT) { if (_cl_tx_delay) { // only write if it has been tx-delay ms // since the last write struct timespec current; clock_gettime(CLOCK_MONOTONIC, &current); if (diff_ms(&current, &last_write) > _cl_tx_delay) { process_write_data(); last_write = current; } } else { process_write_data(); } } } else if (!(_cl_no_tx && _write_count != 0 && _write_count == _read_count)) { // No data. We report this unless we are no longer // transmitting and the receive count equals the // transmit count, suggesting a loopback test that has // finished. printf("No data within one second.\n"); } if (_cl_stats || _cl_tx_time || _cl_rx_time) { struct timespec current; clock_gettime(CLOCK_MONOTONIC, &current); if (_cl_stats) { if (current.tv_sec - last_stat.tv_sec > 5) { dump_serial_port_stats(); last_stat = current; } } if (_cl_tx_time) { if (current.tv_sec - start_time.tv_sec >= _cl_tx_time) { _cl_tx_time = 0; _cl_no_tx = 1; serial_poll.events &= ~POLLOUT; printf("Stopped transmitting.\n"); } } if (_cl_rx_time) { if (current.tv_sec - start_time.tv_sec >= _cl_rx_time) { _cl_rx_time = 0; _cl_no_rx = 1; serial_poll.events &= ~POLLIN; printf("Stopped receiving.\n"); } } } } tcdrain(_fd); dump_serial_port_stats(); tcflush(_fd, TCIOFLUSH); free(_cl_port); int result = abs(_write_count - _read_count) + _error_count; return (result > 255) ? 255 : result; }
the_stack_data/34513700.c
/* This File is Part of LibFalcon. * Copyright (c) 2018, Syed Nasim 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 LibFalcon 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(__cplusplus) extern "C" { #endif #include <ctype.h> #include <stdint.h> int32_t isprint32_t(const int32_t c) { return c >= 0x20 && c <= 0x7E; } #if defined(__cplusplus) } #endif
the_stack_data/103348.c
/* Generated by CIL v. 1.7.0 */ /* print_CIL_Input is false */ struct _IO_FILE; struct timeval; extern float strtof(char const *str , char const *endptr ) ; extern void signal(int sig , void *func ) ; typedef struct _IO_FILE FILE; extern int atoi(char const *s ) ; extern double strtod(char const *str , char const *endptr ) ; extern int fclose(void *stream ) ; extern void *fopen(char const *filename , char const *mode ) ; extern void abort() ; extern void exit(int status ) ; extern int raise(int sig ) ; extern int fprintf(struct _IO_FILE *stream , char const *format , ...) ; extern int strcmp(char const *a , char const *b ) ; extern int rand() ; extern unsigned long strtoul(char const *str , char const *endptr , int base ) ; void RandomFunc(unsigned char input[1] , unsigned char output[1] ) ; extern int strncmp(char const *s1 , char const *s2 , unsigned long maxlen ) ; extern int gettimeofday(struct timeval *tv , void *tz , ...) ; extern int printf(char const *format , ...) ; int main(int argc , char *argv[] ) ; void megaInit(void) ; extern unsigned long strlen(char const *s ) ; extern long strtol(char const *str , char const *endptr , int base ) ; extern unsigned long strnlen(char const *s , unsigned long maxlen ) ; extern void *memcpy(void *s1 , void const *s2 , unsigned long size ) ; struct timeval { long tv_sec ; long tv_usec ; }; extern void *malloc(unsigned long size ) ; extern int scanf(char const *format , ...) ; int main(int argc , char *argv[] ) { unsigned char input[1] ; unsigned char output[1] ; int randomFuns_i5 ; unsigned char randomFuns_value6 ; int randomFuns_main_i7 ; { megaInit(); if (argc != 2) { printf("Call this program with %i arguments\n", 1); exit(-1); } else { } randomFuns_i5 = 0; while (randomFuns_i5 < 1) { randomFuns_value6 = (unsigned char )strtoul(argv[randomFuns_i5 + 1], 0, 10); input[randomFuns_i5] = randomFuns_value6; randomFuns_i5 ++; } RandomFunc(input, output); if (output[0] == 251) { printf("You win!\n"); } else { } randomFuns_main_i7 = 0; while (randomFuns_main_i7 < 1) { printf("%u\n", output[randomFuns_main_i7]); randomFuns_main_i7 ++; } } } void megaInit(void) { { } } void RandomFunc(unsigned char input[1] , unsigned char output[1] ) { unsigned char state[1] ; { state[0UL] = (input[0UL] + 51238316UL) + (unsigned char)234; if ((state[0UL] >> (unsigned char)4) & (unsigned char)1) { if ((state[0UL] >> (unsigned char)3) & (unsigned char)1) { if ((state[0UL] >> (unsigned char)2) & (unsigned char)1) { state[0UL] += state[0UL]; } else { state[0UL] += state[0UL]; } } else if ((state[0UL] >> (unsigned char)4) & (unsigned char)1) { state[0UL] += state[0UL]; } else { state[0UL] += state[0UL]; } } else if ((state[0UL] >> (unsigned char)4) & (unsigned char)1) { state[0UL] += state[0UL]; } else { state[0UL] *= state[0UL]; } output[0UL] = state[0UL] + (unsigned char)154; } }
the_stack_data/90763110.c
#include <assert.h> #include <math.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/mman.h> #include <sys/time.h> void *mmap_from_system(size_t size); void munmap_to_system(void *ptr, size_t size); //////////////////////////////////////////////////////////////////////////////// // // [Simple malloc] // // This is an example, straightforward implementation of malloc. Your goal is // to invent a smarter malloc algorithm in terms of both [Execution time] and // [Memory utilization]. // Each object or free slot has metadata just prior to it: // // ... | m | object | m | free slot | m | free slot | m | object | ... // // where |m| indicates metadata. The metadata is needed for two purposes: // // 1) For an allocated object: // * |size| indicates the size of the object. |size| does not include // the size of the metadata. // * |next| is unused and set to NULL. // 2) For a free slot: // * |size| indicates the size of the free slot. |size| does not include // the size of the metadata. // * The free slots are linked with a singly linked list (we call this a // free list). |next| points to the next free slot. typedef struct simple_metadata_t { size_t size; struct simple_metadata_t *next; } simple_metadata_t; // The global information of the simple malloc. // * |free_head| points to the first free slot. // * |dummy| is a dummy free slot (only used to make the free list // implementation simpler). typedef struct simple_heap_t { simple_metadata_t *free_head; simple_metadata_t dummy; } simple_heap_t; simple_heap_t simple_heap; // Add a free slot to the beginning of the free list. void add_to_free_list(simple_metadata_t *metadata) { assert(!metadata->next); metadata->next = simple_heap.free_head; simple_heap.free_head = metadata; } // Remove a free slot from the free list. void remove_from_free_list(simple_metadata_t *metadata, simple_metadata_t *prev) { if (prev) { prev->next = metadata->next; } else { simple_heap.free_head = metadata->next; } metadata->next = NULL; } // This is called only once at the beginning of each challenge. void my_initialize() { simple_heap.free_head = &simple_heap.dummy; simple_heap.dummy.size = 0; simple_heap.dummy.next = NULL; } // This is called every time an object is allocated. |size| is guaranteed // to be a multiple of 8 bytes and meets 8 <= |size| <= 4000. You are not // allowed to use any library functions other than mmap_from_system / // munmap_to_system. void *first_fit_malloc(size_t size) { simple_metadata_t *metadata = simple_heap.free_head; simple_metadata_t *prev = NULL; // First-fit: Find the first free slot the object fits. while (metadata && metadata->size < size) { // printf("%lu\n", metadata->size); prev = metadata; metadata = metadata->next; } if (!metadata) { size_t buffer_size = 4096; simple_metadata_t *metadata = (simple_metadata_t *)mmap_from_system(buffer_size); metadata->size = buffer_size - sizeof(simple_metadata_t); metadata->next = NULL; // Add the memory region to the free list. add_to_free_list(metadata); // Now, try simple_malloc() again. This should succeed. return first_fit_malloc(size); } void *ptr = metadata + 1; size_t remaining_size = metadata->size - size; metadata->size = size; remove_from_free_list(metadata, prev); if (remaining_size > sizeof(simple_metadata_t)) { simple_metadata_t *new_metadata = (simple_metadata_t *)((char *)ptr + size); new_metadata->size = remaining_size - sizeof(simple_metadata_t); new_metadata->next = NULL; // Add the remaining free slot to the free list. add_to_free_list(new_metadata); } return ptr; } void *best_fit_malloc(size_t size) { simple_metadata_t *metadata = NULL; simple_metadata_t *prev = NULL; simple_metadata_t *metadata_now = simple_heap.free_head; simple_metadata_t *metadata_now_prev = NULL; size_t min_size = 5000; // ALEX_COMMENT: the initialization above works because the max block size is less than 5000. // but if that changed one day, this would need to change, and that is easy to forget. // (maintainability is less than desirable). // to initialize with the size of the FIRST free block would be best. while (metadata_now) { // printf("%lu\n", metadata_now->size); if (metadata_now->size >= size && metadata_now->size < min_size) { prev = metadata_now_prev; metadata = metadata_now; min_size = metadata_now->size; // ALEX_COMMENT: are there cases where you can stop scanning? (i.e., found a perfect size) } metadata_now_prev = metadata_now; metadata_now = metadata_now->next; } if (!metadata) { // There was no free slot available. We need to request a new memory region // from the system by calling mmap_from_system(). // // | metadata | free slot | // ^ // metadata // <----------------------> // buffer_size size_t buffer_size = 4096; simple_metadata_t *metadata = (simple_metadata_t *)mmap_from_system(buffer_size); metadata->size = buffer_size - sizeof(simple_metadata_t); metadata->next = NULL; // Add the memory region to the free list. add_to_free_list(metadata); // Now, try simple_malloc() again. This should succeed. return best_fit_malloc(size); } // |ptr| is the beginning of the allocated object. // // ... | metadata | object | ... // ^ ^ // metadata ptr void *ptr = metadata + 1; size_t remaining_size = metadata->size - size; metadata->size = size; // Remove the free slot from the free list. remove_from_free_list(metadata, prev); if (remaining_size > sizeof(simple_metadata_t)) { // Create a new metadata for the remaining free slot. // // ... | metadata | object | metadata | free slot | ... // ^ ^ ^ // metadata ptr new_metadata // <------><----------------------> // size remaining size simple_metadata_t *new_metadata = (simple_metadata_t *)((char *)ptr + size); new_metadata->size = remaining_size - sizeof(simple_metadata_t); new_metadata->next = NULL; // Add the remaining free slot to the free list. add_to_free_list(new_metadata); } return ptr; } void *worst_fit_malloc(size_t size) { simple_metadata_t *metadata = NULL; simple_metadata_t *prev = NULL; simple_metadata_t *metadata_now = simple_heap.free_head; simple_metadata_t *metadata_now_prev = NULL; size_t max_size = 0; while (metadata_now) { // printf("%lu\n", metadata_now->size); if (metadata_now->size >= size && metadata_now->size > max_size) { prev = metadata_now_prev; metadata = metadata_now; max_size = metadata_now->size; } metadata_now_prev = metadata_now; metadata_now = metadata_now->next; } if (!metadata) { // There was no free slot available. We need to request a new memory region // from the system by calling mmap_from_system(). // // | metadata | free slot | // ^ // metadata // <----------------------> // buffer_size size_t buffer_size = 4096; simple_metadata_t *metadata = (simple_metadata_t *)mmap_from_system(buffer_size); metadata->size = buffer_size - sizeof(simple_metadata_t); metadata->next = NULL; // Add the memory region to the free list. add_to_free_list(metadata); // Now, try simple_malloc() again. This should succeed. return worst_fit_malloc(size); } // |ptr| is the beginning of the allocated object. // // ... | metadata | object | ... // ^ ^ // metadata ptr void *ptr = metadata + 1; size_t remaining_size = metadata->size - size; metadata->size = size; // Remove the free slot from the free list. remove_from_free_list(metadata, prev); if (remaining_size > sizeof(simple_metadata_t)) { // Create a new metadata for the remaining free slot. // // ... | metadata | object | metadata | free slot | ... // ^ ^ ^ // metadata ptr new_metadata // <------><----------------------> // size remaining size simple_metadata_t *new_metadata = (simple_metadata_t *)((char *)ptr + size); new_metadata->size = remaining_size - sizeof(simple_metadata_t); new_metadata->next = NULL; // Add the remaining free slot to the free list. add_to_free_list(new_metadata); } return ptr; } void *my_malloc(size_t size) { return worst_fit_malloc(size); } // This is called every time an object is freed. You are not allowed to use // any library functions other than mmap_from_system / munmap_to_system. void my_free(void *ptr) { // Look up the metadata. The metadata is placed just prior to the object. // // ... | metadata | object | ... // ^ ^ // metadata ptr simple_metadata_t *metadata = (simple_metadata_t *)ptr - 1; // Add the free slot to the free list. add_to_free_list(metadata); } void my_finalize() {} void test() { // Implement here! assert(1 == 1); /* 1 is 1. That's always true! (You can remove this.) */ }
the_stack_data/45875.c
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> typedef struct { char nome[30], usuario[30], sexo[30], curso[30], instituicao[30]; int idade, numero, matricula; }CADASTRO; void syst(){ system("pause"); system("cls"); } FILE* open_file(char caminho[], char modo){ FILE *arquivo; switch(toupper(modo)){ case 'W': arquivo = fopen(caminho,"w"); break; case 'R': arquivo = fopen(caminho,"r"); break; case 'A': arquivo = fopen(caminho,"a"); break; } if(arquivo == NULL){ puts("FALHA NA ABERTURA DO ARQUIVO!"); exit(0); } return arquivo; } void save_file(CADASTRO aluno){ FILE *arquivo; arquivo = open_file("cadastro.txt",'a'); fprintf(arquivo,"%s %s %s %s %s %d %d %d\n",aluno.nome,aluno.curso,aluno.instituicao,aluno.usuario,aluno.sexo,aluno.idade,aluno.numero,aluno.matricula); fclose(arquivo); printf("\n\nCadastro realizado com sucesso!\n"); syst(); } void mostrar(){ CADASTRO aluno; FILE *arquivo; arquivo = open_file("cadastro.txt",'r'); while(!feof(arquivo)){ fscanf(arquivo,"%s %s %s %s %s %d %d %d\n",&aluno.nome,&aluno.curso,&aluno.instituicao,&aluno.usuario,&aluno.sexo,&aluno.idade,&aluno.numero,&aluno.matricula); printf("Aluno: %s\nSexo: %s\nIdade: %d\nNumero: %d\nCurso: %s\nInstituicao: %s\nUsuario: %s\nMatricula: %d\n\n",aluno.nome,aluno.sexo,aluno.idade,aluno.numero,aluno.curso,aluno.instituicao,aluno.usuario,aluno.matricula); } fclose(arquivo); syst(); } void mostrar_especifico(){ CADASTRO aluno; FILE *arquivo; char usuario[30]; int opcao,mat,cont=0; printf("E necessario informar usuario ou numero da matricula!"); printf("\n\nEscolha uma opcao: [1] Usuario\t[2] Matricula\n"); printf("Opcao: "); scanf("%d",&opcao); system("cls"); if(opcao == 1){ printf("Informe o nome do usuario: "); fflush(stdin); gets(usuario); arquivo = open_file("cadastro.txt",'r'); while(!feof(arquivo)){ fscanf(arquivo,"%s %s %s %s %s %d %d %d\n",&aluno.nome,&aluno.curso,&aluno.instituicao,&aluno.usuario,&aluno.sexo,&aluno.idade,&aluno.numero,&aluno.matricula); if(!(strcmp(aluno.usuario,usuario))){ printf("Aluno: %s\nSexo: %s\nIdade: %d\nNumero: %d\nCurso: %s\nInstituicao: %s\nUsuario: %s\nMatricula: %d\n\n",aluno.nome,aluno.sexo,aluno.idade,aluno.numero,aluno.curso,aluno.instituicao,aluno.usuario,aluno.matricula); cont++; } } fclose(arquivo); if(cont==0) printf("\nO usuario informado nao esta cadastrado!\n"); }else{ printf("Informe a matricula: "); scanf("%d",&mat); arquivo = open_file("cadastro.txt",'r'); while(!feof(arquivo)){ fscanf(arquivo,"%s %s %s %s %s %d %d %d\n",&aluno.nome,&aluno.curso,&aluno.instituicao,&aluno.usuario,&aluno.sexo,&aluno.idade,&aluno.numero,&aluno.matricula); if(mat == aluno.matricula){ printf("Aluno: %s\nSexo: %s\nIdade: %d\nNumero: %d\nCurso: %s\nInstituicao: %s\nUsuario: %s\nMatricula: %d\n\n",aluno.nome,aluno.sexo,aluno.idade,aluno.numero,aluno.curso,aluno.instituicao,aluno.usuario,aluno.matricula); cont++; } } fclose(arquivo); printf("\nA matricula informada nao esta cadastrada!\n"); } syst(); } int menu(){ int opcao; do{ puts("MENU:"); puts("1 - CADASTRAR"); puts("2 - VERIFICAR TODOS CADASTROS"); puts("3 - VERIFICAR CADASTRO ESPECIFICO"); puts("0 - SAIR"); printf("OPCAO: "); scanf("%d",&opcao); if(opcao < 0 || opcao > 3){ puts("\nOPCAO INVALIDA, TENTE NOVAMENTE!"); syst(); } }while(opcao < 0 || opcao > 3); system("cls"); return opcao; } void cadastrar(CADASTRO *aluno){ int opcao; do{ printf("Nome: "); fflush(stdin); gets(aluno->nome); do{ printf("Sexo: [1] Masculino\t[2] Feminino\n"); printf("Opcao: "); scanf("%d",&opcao); if(opcao==1){ strcpy(aluno->sexo,"Masculino"); }else{ if(opcao==2){ strcpy(aluno->sexo,"Feminino"); }else{ printf("Opcao invalida !\n"); } } }while(opcao != 1 && opcao != 2); printf("Idade: "); scanf("%d",&aluno->idade); printf("Numero: "); scanf("%d",&aluno->numero); printf("Curso: "); fflush(stdin); gets(aluno->curso); printf("Instituicao: "); fflush(stdin); gets(aluno->instituicao); printf("\n\nConfirma todas informacoes?\n[1] Sim\t[2] Nao\n"); printf("Opcao: "); scanf("%d",&opcao); if(opcao==2) syst(); }while(opcao != 1); syst(); printf("Para completar sua matricula e necessario cadastrar um nome de usuario: "); printf("\n\nUsuario: "); fflush(stdin); gets(aluno->usuario); srand((unsigned) time (NULL)); aluno->matricula = 1000 + rand() % 1000; printf("Matricula: %d", aluno->matricula); } void main(){ CADASTRO aluno; while(1){ switch(menu()){ case 1: cadastrar(&aluno); save_file(aluno); break; case 2: mostrar(); break; case 3: mostrar_especifico(); break; default: puts("Finalizando o programa..."); exit(0); } } }
the_stack_data/231394158.c
/* Levnsn.c */ /* Levinson-Durbin LPC * * | R0 R1 R2 ... RN-1 | | A1 | | -R1 | * | R1 R0 R1 ... RN-2 | | A2 | | -R2 | * | R2 R1 R0 ... RN-3 | | A3 | = | -R3 | * | ... | | ...| | ... | * | RN-1 RN-2... R0 | | AN | | -RN | * * Ref: John Makhoul, "Linear Prediction, A Tutorial Review" * Proc. IEEE Vol. 63, PP 561-580 April, 1975. * * R is the input autocorrelation function. R0 is the zero lag * term. A is the output array of predictor coefficients. Note * that a filter impulse response has a coefficient of 1.0 preceding * A1. E is an array of mean square error for each prediction order * 1 to N. REFL is an output array of the reflection coefficients. */ #define abs(x) ( (x) < 0 ? -(x) : (x) ) int levnsn( n, r, a, e, refl ) int n; double r[], a[], e[], refl[]; { int k, km1, i, kmi, j; double ai, akk, err, err1, r0, t, akmi; double *pa, *pr; for( i=0; i<n; i++ ) { a[i] = 0.0; e[i] = 0.0; refl[i] = 0.0; } r0 = r[0]; e[0] = r0; err = r0; akk = -r[1]/err; err = (1.0 - akk*akk) * err; e[1] = err; a[1] = akk; refl[1] = akk; if( err < 1.0e-2 ) return 0; for( k=2; k<n; k++ ) { t = 0.0; pa = &a[1]; pr = &r[k-1]; for( j=1; j<k; j++ ) t += *pa++ * *pr--; akk = -( r[k] + t )/err; refl[k] = akk; km1 = k/2; for( j=1; j<=km1; j++ ) { kmi = k-j; ai = a[j]; akmi = a[kmi]; a[j] = ai + akk*akmi; if( i == kmi ) goto nxtk; a[kmi] = akmi + akk*ai; } nxtk: a[k] = akk; err1 = (1.0 - akk*akk)*err; e[k] = err1; if( err1 < 0 ) err1 = -err1; /* err1 = abs(err1);*/ /* if( (err1 < 1.0e-2) || (err1 >= err) )*/ if( err1 < 1.0e-2 ) return 0; err = err1; } return 0; }
the_stack_data/64199273.c
#line 1 "awkemu.rl" /* * Perform the basic line parsing of input performed by awk. */ #include <stdio.h> #include <string.h> #include <stdlib.h> #include <unistd.h> #line 55 "awkemu.rl" #line 18 "awkemu.c" static const int awkemu_start = 2; static const int awkemu_en_main = 2; #line 58 "awkemu.rl" #define MAXWORDS 256 #define BUFSIZE 4096 char buf[BUFSIZE]; int main() { int i, nwords = 0; char *ls = 0; char *ws[MAXWORDS]; char *we[MAXWORDS]; int cs; int have = 0; #line 41 "awkemu.c" { cs = awkemu_start; } #line 74 "awkemu.rl" while ( 1 ) { char *p, *pe, *data = buf + have; int len, space = BUFSIZE - have; /* fprintf( stderr, "space: %i\n", space ); */ if ( space == 0 ) { fprintf(stderr, "buffer out of space\n"); exit(1); } len = fread( data, 1, space, stdin ); /* fprintf( stderr, "len: %i\n", len ); */ if ( len == 0 ) break; /* Find the last newline by searching backwards. This is where * we will stop processing on this iteration. */ p = buf; pe = buf + have + len - 1; while ( *pe != '\n' && pe >= buf ) pe--; pe += 1; /* fprintf( stderr, "running on: %i\n", pe - p ); */ #line 74 "awkemu.c" { if ( p == pe ) goto _test_eof; switch ( cs ) { tr2: #line 17 "awkemu.rl" { we[nwords++] = p; } #line 26 "awkemu.rl" { printf("endline(%i): ", nwords ); fwrite( ls, 1, p - ls, stdout ); printf("\n"); for ( i = 0; i < nwords; i++ ) { printf(" word: "); fwrite( ws[i], 1, we[i] - ws[i], stdout ); printf("\n"); } } goto st2; tr5: #line 26 "awkemu.rl" { printf("endline(%i): ", nwords ); fwrite( ls, 1, p - ls, stdout ); printf("\n"); for ( i = 0; i < nwords; i++ ) { printf(" word: "); fwrite( ws[i], 1, we[i] - ws[i], stdout ); printf("\n"); } } goto st2; tr8: #line 21 "awkemu.rl" { nwords = 0; ls = p; } #line 26 "awkemu.rl" { printf("endline(%i): ", nwords ); fwrite( ls, 1, p - ls, stdout ); printf("\n"); for ( i = 0; i < nwords; i++ ) { printf(" word: "); fwrite( ws[i], 1, we[i] - ws[i], stdout ); printf("\n"); } } goto st2; st2: if ( ++p == pe ) goto _test_eof2; case 2: #line 135 "awkemu.c" switch( (*p) ) { case 9: goto tr7; case 10: goto tr8; case 32: goto tr7; } goto tr6; tr3: #line 13 "awkemu.rl" { ws[nwords] = p; } goto st0; tr6: #line 21 "awkemu.rl" { nwords = 0; ls = p; } #line 13 "awkemu.rl" { ws[nwords] = p; } goto st0; st0: if ( ++p == pe ) goto _test_eof0; case 0: #line 163 "awkemu.c" switch( (*p) ) { case 9: goto tr1; case 10: goto tr2; case 32: goto tr1; } goto st0; tr1: #line 17 "awkemu.rl" { we[nwords++] = p; } goto st1; tr7: #line 21 "awkemu.rl" { nwords = 0; ls = p; } goto st1; st1: if ( ++p == pe ) goto _test_eof1; case 1: #line 187 "awkemu.c" switch( (*p) ) { case 9: goto st1; case 10: goto tr5; case 32: goto st1; } goto tr3; } _test_eof2: cs = 2; goto _test_eof; _test_eof0: cs = 0; goto _test_eof; _test_eof1: cs = 1; goto _test_eof; _test_eof: {} } #line 101 "awkemu.rl" /* How much is still in the buffer. */ have = data + len - pe; if ( have > 0 ) memmove( buf, pe, have ); /* fprintf(stderr, "have: %i\n", have ); */ if ( len < space ) break; } if ( have > 0 ) fprintf(stderr, "input not newline terminated\n"); return 0; }
the_stack_data/51700332.c
#include <stdio.h> int main() { int n, soma, i; for(n=1; n<=10000; n++) { soma = 0; for(i=1; i<n; i++) { if(n%i == 0) { soma += i; } } if(n == soma) printf("%d é perfeito\n", n); } return 0; }
the_stack_data/125786.c
/*********************************************************************** * サウンド出力処理 (システム依存) * * 詳細は、 snddrv.h / mame-quasi88.h 参照 ************************************************************************/ #include <stdio.h> #include <stdlib.h> #include <string.h> #ifdef USE_SOUND #include "mame-quasi88.h" #define SNDDRV_WORK_DEFINE #include "audio.h" #include "sysdep_mixer.h" /* sysdep_mixer_init() */ /*----------------------------------------------------------------------*/ /* rc_struct 構造体により、オプションを制御する */ static struct rc_struct *rc; extern struct rc_option sound_opts[]; /*===========================================================================*/ /* QUASI88 から呼び出される、MAME の処理関数 */ /*===========================================================================*/ /****************************************************************************** * サウンド系オプション処理の初期化/終了関数 * * int xmame_config_init(void) * config_init() より、オプションの解析を開始する前に呼び出される。 * MAME依存ワークの初期化などが必要な場合は、ここで行う。 * * void xmame_config_exit(void) * config_exit() より、処理の最後に呼び出される。 * xmame_config_init() の処理の後片付けが必要なら、ここで行う。 * *****************************************************************************/ /* config_init() [src/unix/config.c] */ int xmame_config_init(void) { /* create the rc object */ if (!(rc = rc_create())) return OSD_NOT_OK; if(sysdep_dsp_init(rc, NULL)) return OSD_NOT_OK; if(sysdep_mixer_init(rc, NULL)) return OSD_NOT_OK; if(rc_register(rc, sound_opts)) return OSD_NOT_OK; return OSD_OK; } /* config_exit() [src/unix/config.c] */ void xmame_config_exit(void) { if(rc) { sysdep_mixer_exit(); sysdep_dsp_exit(); rc_destroy(rc); } } /****************************************************************************** * サウンド系オプションのオプションテーブル取得 * * const T_CONFIG_TABLE *xmame_config_get_opt_tbl(void) * config_init() より、 xmame_config_init() の後に呼び出される。 * * サウンド系オプションの解析処理において、 QUASI88 のオプションテーブル * T_CONFIG_TABLE を使用する場合、そのポインタを返す。 * 独自方式で解析する場合は、 NULL を返す。 *****************************************************************************/ const T_CONFIG_TABLE *xmame_config_get_opt_tbl(void) { return NULL; } /****************************************************************************** * サウンド系オプションのヘルプメッセージを表示 * * void xmame_config_show_option(void) * config_init() より、オプション -help の処理の際に呼び出される。 * 標準出力にヘルプメッセージを表示する。 *****************************************************************************/ void xmame_config_show_option(void) { fprintf(stdout, "\n" "==========================================\n" "== SOUND OPTIONS ( dependent on XMAME ) ==\n" "== [ XMAME 0.71.1 ] ==\n" "==========================================\n" ); rc_print_help(rc, stdout); } /****************************************************************************** * サウンド系オプションの解析処理 * * int xmame_config_check_option(char *opt1, char *opt2, int priority) * config_init() より、引数や設定ファイルの解析を行なう際に、 * 規定のオプションのいずれにも合致しない場合、この関数が呼び出される。 * * opt1 … 最初の引数(文字列) * opt2 … 次のの引数(文字列 ないし NULL) * priority … 優先度 (値が大きいほど優先度が高い) * * 戻り値 1 … 処理した引数が1個 (opt1 のみ処理。 opt2 は未処理) * 2 … 処理した引数が2個 (opt1 と opt2 を処理) * 0 … opt1 が未知の引数のため、 opt1 opt2 ともに未処理 * -1 … 内部で致命的な異常が発生 * * 処理中の異常 (引数の指定値が範囲外など) や、優先度により処理がスキップ * されたような場合は、正しく処理できた場合と同様に、 1 か 2 を返す。 * * ※ この関数は、独自方式でオプションを解析するための関数なので、 * オプションテーブル T_CONFIG_TABLE を使用する場合は、ダミーでよい。 *****************************************************************************/ int xmame_config_check_option(char *opt1, char *opt2, int priority) { return rc_quasi88(rc, opt1, opt2, priority); } /****************************************************************************** * サウンド系オプションを保存するための関数 * * int xmame_config_save_option(void (*real_write) * (const char *opt_name, const char *opt_arg)) * * 設定ファイルの保存の際に、呼び出される。 * 「opt_name にオプションを、 opt_arg にオプション引数を * セットし、real_write を呼び出す」 * という動作を、保存したい全オプションに対して繰り返し行なう。 * * (例) "-sound" を設定ファイルに保存したい場合 * (real_write)("sound", NULL) を呼び出す。 * (例) "-fmvol 80" を設定ファイルに保存したい場合 * (real_write)("fmvol", "80") を呼び出す。 * * 戻り値 常に 0 を返す * * ※ この関数は、独自方式でオプションを解析するための関数なので、 * オプションテーブル T_CONFIG_TABLE を使用する場合は、ダミーでよい。 *****************************************************************************/ #include "rc_priv.h" int xmame_config_save_option(void (*real_write) (const char *opt_name, const char *opt_arg)) { return rc_quasi88_save(rc->option, real_write); } /****************************************************************************** * サウンド系オプションをメニューから変更するためのテーブル取得関数 * * T_SNDDRV_CONFIG *xmame_config_get_sndopt_tbl(void) * * メニューモードの開始時に呼び出される。 * 変更可能なサウンド系オプションの情報を、T_SNDDRV_CONFIG 型の * 配列として用意し、その先頭ポインタを返す。 * 配列は最大5個まで、さらに末尾には終端データをセットしておく。 * * 特に変更したい/できるものが無い場合は NULL を返す。 *****************************************************************************/ /* T_SNDDRV_CONFIG *xmame_config_get_sndopt_tbl(void) [src/unix/sound.c] */ /****************************************************************************** * サウンド機能の情報を取得する関数 * * int xmame_has_audiodevice(void) * サウンドオデバイス出力の可否を返す。 * 真ならデバイス出力可。偽なら不可。 * * int xmame_has_mastervolume(void) * サウンドデバイスの音量が変更可能かどうかを返す。 * 真なら変更可能。偽なら不可。 * *****************************************************************************/ int xmame_has_audiodevice(void) { if (use_sound) { if (sound_stream) return TRUE; } return FALSE; } int xmame_has_mastervolume(void) { if (use_sound) { if (osd_has_sound_mixer()) return TRUE; } return FALSE; } /*===========================================================================*/ /* MAME の処理関数から呼び出される、システム依存処理関数 */ /*===========================================================================*/ /****************************************************************************** * サウンドデバイス制御 * これらの関数は、グローバル変数 use_sound が偽の場合は、呼び出されない。 * * int osd_start_audio_stream(int stereo) * サウンドデバイスを初期化する。 * stereo が真ならステレオ出力、偽ならモノラル出力で初期化する。 * (モノラル出力は、古いバージョンの MAME/XMAME で YM2203 を処理する * 場合のみ、使用している。それ以外はすべてステレオ出力を使用する。) * この関数は、エミュレーションの開始時に呼び出される。 * 成功時は、1フレームあたりのサンプル数を返す。 * 失敗時は、0 を返す。 * が、ここで 0 を返すと QUASI88 が強制終了してしまうので、 * サウンドデバイスの初期化に失敗した場合でも、サウンド出力なしで * 処理を進めたいという場合、とにかく適当な値を返す必要がある。 * * int osd_update_audio_stream(INT16 *buffer) * サウンドデバイスに出力する。 * この関数は、1フレーム処理毎に呼び出される。buffer には1フレーム分 * (Machine->sample_rate / Machine->drv->frames_per_second) のサウンド * データが格納されている。データは 16bit符号付きで、ステレオの場合は * 左と右のサンプルが交互に並んでいる。 * * 実際にこの関数が呼び出されたタイミングでデバイスに出力するか、あるいは * 内部でバッファリングして別途出力するかは、実装次第である。 * * 戻値は、 osd_start_audio_stream() と同じ * * void osd_stop_audio_stream(void) * サウンドデバイスを終了する。 * この関数は、エミュレーションの終了時に呼び出される。 * 以降、 osd_update_audio_stream() などは呼び出されない。エミュレーション * を再開する場合は、 osd_start_audio_stream() から呼び出される。 * * void osd_update_video_and_audio(void) * サウンドデバイスの出力その2 * タイミング的には、 osd_update_audio_stream() の直後に呼び出される。 * XMAME 0.106 に合わせて定義されているが、 osd_update_audio_stream() が * きちんと実装できれいれば、こちらの関数はダミーでよい。 * * void osd_sound_enable(int enable) * サウンドデバイスへの出力あり・なしを設定する。 * enable が真なら出力あり、偽なら出力なし。 * この関数は、グローバル変数 close_device が真の場合のみ、呼び出される。 * メニューモードに入った際に、引数を偽として呼び出す。 * メニューモードから出る際に、引数を真として呼び出す。 * この関数は、引数が偽の場合に、サウンドデバイスを解放 (close) し、 * 真の場合に確保 (open) するような実装を期待しているが、サウンドデバイス * を常時確保したままにするような実装であれば、ダミーの関数でよい。 * なお、サウンドデバイスへの出力なしの場合も osd_update_audio_stream() * などの関数は呼び出される。 * *****************************************************************************/ /* int osd_start_audio_stream(int stereo) [src/unix/sound.c] */ /* int osd_update_audio_stream(INT16 *buffer) [src/unix/sound.c] */ /* void osd_stop_audio_stream(void) [src/unix/sound.c] */ /* void osd_sound_enable(int enable) [src/unix/sound.c] */ /* osd_update_video_and_audio(struct mame_display *display) [src/unix/video.c] */ void osd_update_video_and_audio(void) { if (sound_stream && sound_enabled) sound_stream_update(sound_stream); } /****************************************************************************** * 音量制御 * * void osd_set_mastervolume(int attenuation) * サウンドデバイスの音量を設定する。 attenuation は 音量で、 -32〜0 * (単位は db)。 音量変更のできないデバイスであれば、ダミーでよい。 * * int osd_get_mastervolume(void) * 現在のサウンドデバイスの音量を取得する。 戻値は -32〜0 (単位は db)。 * 音量変更のできないデバイスであれば、ダミーでよい。 * *****************************************************************************/ /* void osd_set_mastervolume(int attenuation) [src/unix/sound.c] */ /* int osd_get_mastervolume(void) [src/unix/sound.c] */ #endif /* USE_SOUND */
the_stack_data/232955068.c
#include<stdio.h> #include<stdlib.h> #include<unistd.h> #include<sys/sem.h> #include<sys/ipc.h> #define SEM_R 0400 #define SEM_A 0200 #define SVSEM_MODE (SEM_R | SEM_A | SEM_R >> 3 | SEM_R >> 6) int main(int argc, char** argv){ int c, oflag, semid, nsems; oflag = SVSEM_MODE | IPC_CREAT; while( (c = getopt(argc, argv, "e")) != -1 ){ switch(c){ case 'e': oflag |= IPC_EXCL; break; } } if( optind != argc - 2 ){ printf("usage: semcreate [-e] <pathname> <nsems>"); exit(0); } nsems = atoi(argv[optind+1]); semid = semget(ftok(argv[optind], 0), nsems, oflag); return 0; }
the_stack_data/90762298.c
/* * Benchmarks contributed by Divyesh Unadkat[1,2], Supratik Chakraborty[1], Ashutosh Gupta[1] * [1] Indian Institute of Technology Bombay, Mumbai * [2] TCS Innovation labs, Pune * */ extern void __VERIFIER_error() __attribute__ ((__noreturn__)); extern void __VERIFIER_assume(int); void __VERIFIER_assert(int cond) { if(!(cond)) { ERROR: __VERIFIER_error(); } } extern int __VERIFIER_nondet_int(void); int N; int main() { N = __VERIFIER_nondet_int(); if(N <= 0) return 1; __VERIFIER_assume(N <= 2147483647/sizeof(int)); int i, j; int sum[1]; int a[N]; int b[N]; for (i = 0; i < N; i++) { a[i] = 1; } for (i = 0; i < N; i++) { b[i] = 1; } sum[0] = 0; for (i = 0; i < N; i++) { sum[0] = sum[0] + a[i]; } for (i = 0; i < N; i++) { sum[0] = sum[0] + b[i]; } for (i = 0; i < N; i++) { for (j = 0; j < N; j++) { b[i] = b[i] + 1; } b[i] = b[i] + sum[0]; } for (i = 0; i < N; i++) { __VERIFIER_assert(b[i] == 3*N + 1); } }
the_stack_data/162643786.c
const unsigned char Bulb_16bpp[] = { 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0x8a,0x83,0x28,0xa4,0xc9,0x93,0x2a,0x73,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xa0,0xd4,0x44,0xdd,0x09,0xee,0xad,0xf6,0x8d,0xee, 0xc9,0xe5,0xe2,0xd4,0xc0,0xcc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xe1,0xdc,0x07,0xee,0xcb,0xfe,0xcc,0xfe, 0xee,0xfe,0x0f,0xff,0x10,0xff,0x10,0xff,0xa7,0xe5,0xa0,0xd4,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xa4,0xed,0xaa,0xfe, 0xcb,0xfe,0x6a,0xf6,0x08,0xee,0x2a,0xee,0x6c,0xf6,0x8e,0xf6,0x32,0xff,0x66,0xdd, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xe1,0xdc,0x27,0xf6,0x28,0xf6,0x49,0xf6,0xee,0xfe,0x0f,0xff,0x10,0xff,0x32,0xff, 0x53,0xff,0x0b,0xee,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0x01,0xdd,0x27,0xf6,0xcb,0xfe,0xcc,0xfe,0xee,0xfe,0x0f,0xff, 0x10,0xff,0x32,0xff,0xf1,0xf6,0x24,0xdd,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xfc,0xa4,0xe5,0xaa,0xfe,0xcb,0xfe,0xac,0xfe, 0x6b,0xf6,0x4a,0xee,0x6c,0xf6,0x8d,0xf6,0x44,0xdd,0xa0,0xcc,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xe1,0xd4,0x89,0xfe, 0x48,0xf6,0x08,0xee,0xac,0xf6,0x0f,0xff,0x10,0xff,0x32,0xff,0x53,0xff,0x44,0xdd, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xc1,0xd4,0x06,0xee,0xaa,0xfe,0xcc,0xfe,0xee,0xfe,0x0f,0xff,0x10,0xff,0x32,0xff, 0xaf,0xf6,0xe2,0xdc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0x84,0xe5,0xaa,0xfe,0xcb,0xfe,0xcc,0xfe,0xee,0xfe,0x0f,0xff, 0x10,0xff,0x32,0xff,0xa7,0xe5,0x80,0xcc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xc5,0xed,0x52,0xa5,0x58,0x95,0x99,0x9d, 0xda,0xa5,0xda,0xa5,0x99,0x9d,0x58,0x95,0x95,0xa5,0x86,0xdd,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xd5,0x84,0x7a,0xc6, 0xba,0xce,0x9a,0xc6,0x59,0xbe,0x39,0xb6,0x39,0xb6,0x38,0xbe,0x7b,0xbe,0x94,0x7c, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x5a,0x5c, 0x7c,0xbe,0xb7,0xad,0x79,0xc6,0x79,0xc6,0x79,0xbe,0x38,0xb6,0x18,0xae,0xd6,0xb5, 0x97,0x9d,0x3b,0xb6,0xd7,0x4b,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0x7b,0x95,0x1a,0xae,0xd8,0xad,0x9a,0xc6,0x7a,0xc6,0x58,0xbe,0x37,0xb6, 0xf7,0xad,0xd7,0xb5,0xb9,0x9d,0x7b,0xb6,0xd9,0x74,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0x17,0x64,0x3c,0xae,0xb9,0x9d,0xf7,0xb5,0xbb,0xce,0xdb,0xce, 0x9b,0xc6,0x7a,0xbe,0x39,0xb6,0xf7,0xb5,0xd9,0xa5,0xf9,0xa5,0xdb,0xa5,0xd9,0x34, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3b,0x5c,0x7c,0xb6,0xd9,0xa5,0x18,0xb6, 0xba,0xce,0xdb,0xce,0xba,0xce,0x9a,0xc6,0x79,0xbe,0x17,0xbe,0x19,0xae,0xf8,0xa5, 0x7c,0xbe,0xd8,0x4b,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1b,0x85,0x7b,0xbe, 0xf8,0xad,0x18,0xbe,0xda,0xd6,0xfb,0xd6,0xdb,0xd6,0xba,0xce,0x99,0xc6,0x37,0xc6, 0x38,0xb6,0x18,0xb6,0x9b,0xc6,0xd9,0x74,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7b,0x64, 0x7d,0xb6,0x19,0xae,0x38,0xb6,0x37,0xc6,0xfa,0xd6,0x1b,0xdf,0xfb,0xde,0xda,0xd6, 0xb9,0xce,0x37,0xc6,0x58,0xbe,0x58,0xbe,0x59,0xb6,0x3c,0xb6,0x17,0x54,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0x7b,0x64,0x1d,0xae,0x5a,0xbe,0x18,0xae,0x58,0xbe,0x58,0xc6,0x57,0xce,0xd9,0xde, 0x1a,0xdf,0xb8,0xd6,0x77,0xce,0x57,0xce,0x98,0xc6,0x78,0xbe,0x58,0xbe,0x9a,0xc6, 0xdb,0xa5,0xd7,0x53,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0x7c,0x5c,0xdc,0x9d,0x7b,0xbe,0x18,0xae,0x38,0xb6,0x58,0xbe,0x98,0xc6, 0x77,0xce,0x70,0x94,0x77,0xd6,0xb0,0x94,0xb4,0xb5,0xb8,0xd6,0x98,0xce,0x98,0xc6, 0x58,0xbe,0x38,0xb6,0xbb,0xc6,0x3a,0x8d,0x19,0x54,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xfd,0x64,0x3c,0x85,0xbb,0xc6,0xf9,0xa5,0x18,0xb6,0x58,0xbe, 0x78,0xc6,0x98,0xce,0x73,0xad,0xd1,0x9c,0xf7,0xde,0xb3,0xb5,0x70,0x8c,0xd7,0xde, 0xd8,0xd6,0x98,0xce,0x78,0xc6,0x58,0xbe,0x18,0xb6,0xbc,0xc6,0x99,0x6c,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xdc,0x74,0xbc,0xc6,0xd9,0x9d,0xf8,0xa5, 0x38,0xb6,0x58,0xbe,0x98,0xc6,0xb8,0xd6,0xf2,0x9c,0x76,0xd6,0x17,0xe7,0x16,0xe7, 0x90,0x94,0xd6,0xde,0xd7,0xde,0xb8,0xd6,0x98,0xc6,0x58,0xbe,0x38,0xb6,0x19,0xae, 0x9c,0xbe,0x18,0x5c,0xff,0xff,0xff,0xff,0xff,0xff,0xbc,0x6c,0x3d,0xae,0xf9,0xa5, 0xd8,0x9d,0xf8,0xad,0x38,0xb6,0x78,0xbe,0x98,0xce,0xb7,0xd6,0x54,0xad,0x17,0xe7, 0x36,0xef,0x36,0xef,0xd4,0xbd,0x15,0xc6,0xf7,0xde,0xd8,0xd6,0x98,0xce,0x78,0xbe, 0x38,0xb6,0xf8,0xad,0x3a,0xb6,0xdb,0x9d,0x18,0x4c,0xff,0xff,0xff,0xff,0xfd,0x74, 0x7c,0xbe,0x99,0x95,0xd9,0x9d,0x18,0xae,0x38,0xb6,0x78,0xc6,0x98,0xce,0x77,0xce, 0x56,0xce,0x16,0xef,0x56,0xf7,0x55,0xf7,0x36,0xef,0xf6,0xc5,0xf7,0xe6,0xd7,0xde, 0x98,0xce,0x78,0xc6,0x38,0xb6,0x18,0xae,0xd9,0x9d,0x9c,0xc6,0x38,0x54,0xff,0xff, 0xff,0x07,0xdd,0x9d,0xda,0x9d,0x99,0x95,0xd9,0x9d,0x19,0xae,0x58,0xbe,0x78,0xc6, 0xb8,0xce,0x98,0xd6,0xd7,0xde,0x36,0xef,0x56,0xf7,0x55,0xff,0x56,0xf7,0x97,0xd6, 0xf8,0xde,0xd7,0xd6,0xb8,0xce,0x78,0xc6,0x58,0xbe,0x19,0xae,0xd9,0x9d,0x5b,0xb6, 0x1a,0x85,0x1f,0x00,0xde,0x6c,0x5d,0xb6,0x59,0x8d,0x99,0x95,0xd9,0x9d,0x18,0xae, 0x38,0xb6,0x78,0xc6,0xb8,0xce,0x1a,0xdf,0xf7,0xe6,0x16,0xef,0x36,0xf7,0x55,0xf7, 0x36,0xf7,0x17,0xe7,0x19,0xe7,0xd7,0xde,0x98,0xce,0x78,0xc6,0x38,0xb6,0x18,0xae, 0xd9,0x9d,0xb9,0x9d,0xfb,0xa5,0xd8,0x53,0xde,0x6c,0x5c,0xb6,0x58,0x85,0x99,0x95, 0xd8,0x9d,0x19,0xae,0x9a,0xc6,0xfa,0xd6,0x3b,0xdf,0xbe,0xf7,0x5b,0xef,0x37,0xef, 0x37,0xef,0x37,0xf7,0x37,0xef,0x9b,0xf7,0x9c,0xf7,0xd8,0xd6,0xb8,0xce,0x78,0xbe, 0x38,0xb6,0xf8,0xad,0xd8,0x9d,0x99,0x95,0x3b,0xb6,0xd8,0x4b,0xfe,0x74,0x5c,0xb6, 0x58,0x85,0x99,0x95,0xf9,0xa5,0xbb,0xce,0xfb,0xd6,0x1b,0xdf,0x3b,0xdf,0x7c,0xef, 0xde,0xff,0xfe,0xff,0xde,0xff,0xde,0xff,0xde,0xff,0x9c,0xf7,0xf8,0xde,0xb8,0xd6, 0x98,0xc6,0x58,0xbe,0x38,0xb6,0xf8,0xa5,0xb8,0x9d,0x99,0x95,0x5c,0xb6,0x18,0x54, 0xff,0x74,0x5d,0xb6,0x38,0x85,0x79,0x8d,0x7b,0xbe,0xbb,0xce,0xfb,0xd6,0xfb,0xd6, 0x1b,0xdf,0x3b,0xe7,0x5b,0xe7,0x7b,0xef,0x7b,0xef,0x5a,0xef,0x18,0xe7,0xd7,0xde, 0xb8,0xd6,0x98,0xce,0x78,0xc6,0x58,0xbe,0x18,0xae,0xd9,0xa5,0xb8,0x95,0x79,0x8d, 0x1b,0xae,0xf9,0x53,0xdf,0x75,0xfd,0xa5,0x79,0x8d,0xb9,0x95,0x9b,0xbe,0xbb,0xc6, 0xdb,0xce,0xfb,0xd6,0x1b,0xdf,0x3b,0xdf,0x3b,0xe7,0x5b,0xe7,0x5b,0xe7,0x5b,0xe7, 0x5b,0xe7,0xb8,0xd6,0x98,0xce,0x98,0xc6,0x58,0xbe,0x38,0xb6,0xf8,0xad,0xd9,0x9d, 0x99,0x95,0xda,0x9d,0x7b,0x95,0xb8,0x4b,0xff,0xff,0x9d,0x8d,0xda,0x9d,0xb9,0x95, 0x9b,0xbe,0xbb,0xc6,0xdb,0xce,0xdb,0xce,0xfb,0xd6,0x1b,0xdf,0x3b,0xdf,0x5b,0xe7, 0x3b,0xe7,0x3b,0xe7,0x3b,0xe7,0x1a,0xdf,0x78,0xc6,0x58,0xbe,0x38,0xb6,0x18,0xae, 0xf8,0xa5,0xb8,0x9d,0x99,0x95,0x3b,0xae,0xda,0x74,0xff,0xff,0xff,0xff,0x1d,0x7d, 0x3b,0xae,0x79,0x8d,0x7b,0xbe,0x9b,0xbe,0xbb,0xc6,0xdb,0xce,0xfb,0xd6,0xfb,0xd6, 0x1b,0xdf,0x1b,0xdf,0x3b,0xdf,0x3b,0xdf,0x3b,0xdf,0x1b,0xdf,0x79,0xc6,0x38,0xb6, 0x18,0xb6,0xf8,0xa5,0xd9,0x9d,0x98,0x95,0x79,0x8d,0x7b,0xb6,0x59,0x5c,0xff,0xff, 0xff,0xff,0x1e,0x75,0x7d,0xb6,0x59,0x85,0x5b,0xb6,0x9b,0xbe,0x9b,0xc6,0xbb,0xc6, 0xdb,0xce,0xfb,0xd6,0xfb,0xd6,0xfb,0xd6,0x1b,0xdf,0x1b,0xdf,0x1b,0xdf,0xfb,0xd6, 0x9a,0xc6,0x18,0xae,0xf8,0xad,0xd9,0x9d,0xb9,0x95,0x78,0x8d,0x99,0x95,0x3c,0xae, 0x39,0x5c,0xff,0xff,0xff,0xff,0xff,0xff,0x3e,0x85,0x7c,0xb6,0x9a,0x95,0x5b,0xb6, 0x7b,0xbe,0x9b,0xc6,0xbb,0xc6,0xdb,0xce,0xdb,0xce,0xfb,0xd6,0xfb,0xd6,0xfb,0xd6, 0xfb,0xd6,0xfb,0xd6,0x7a,0xbe,0xf9,0xa5,0xd9,0x9d,0xb8,0x95,0x79,0x95,0x59,0x8d, 0x9c,0xbe,0x9a,0x64,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x75,0xde,0x9d, 0xfa,0x9d,0xda,0xa5,0x7b,0xb6,0x7b,0xbe,0x9b,0xc6,0xbb,0xc6,0xbb,0xc6,0xdb,0xce, 0xdb,0xce,0xdb,0xce,0xdb,0xce,0xdb,0xce,0x3a,0xb6,0xb8,0x9d,0xb9,0x95,0x79,0x95, 0x58,0x8d,0x3b,0xae,0x5b,0x85,0x5b,0x5c,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0x1e,0x75,0x5d,0xb6,0x9a,0x95,0xda,0x9d,0x7b,0xb6,0x9b,0xbe,0x9b,0xbe, 0x9b,0xc6,0xbb,0xc6,0xbb,0xc6,0xbb,0xc6,0xbb,0xc6,0x9b,0xbe,0xb9,0x9d,0x99,0x95, 0x78,0x8d,0x58,0x8d,0xda,0x9d,0x3c,0xae,0x7a,0x64,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1d,0x75,0x1d,0xae,0x3b,0xae,0x99,0x8d, 0x3b,0xae,0x7b,0xbe,0x9b,0xbe,0x9b,0xbe,0x9b,0xbe,0x9b,0xbe,0x5b,0xb6,0xb9,0x9d, 0x78,0x8d,0x79,0x8d,0x79,0x8d,0x7b,0xb6,0xdc,0x9d,0x9b,0x64,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x75, 0x7e,0x8d,0x7c,0xbe,0xba,0x95,0x59,0x8d,0xd9,0x9d,0xda,0x9d,0xfa,0xa5,0xb9,0x95, 0x58,0x8d,0x59,0x8d,0x58,0x85,0xda,0x9d,0x7c,0xbe,0x1c,0x7d,0x9c,0x64,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0x1f,0x84,0x1e,0x7d,0xfe,0xa5,0x7d,0xb6,0x7c,0xb6,0x5b,0xb6, 0xfa,0xa5,0xfa,0xa5,0x7b,0xb6,0x7c,0xb6,0x5d,0xb6,0xbc,0x9d,0xbc,0x6c,0x17,0x64, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xdf,0x84,0xff,0x74, 0xfe,0x74,0x1d,0x7d,0x9d,0x95,0x9d,0x95,0xfd,0x74,0xdc,0x6c,0x9d,0x6c,0xdf,0x64, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0x80,0xdc,0xc8,0x93,0x87,0xb4,0x28,0xa4,0x87,0x8b,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0xd4,0xa5,0xe5,0x6b,0xee,0xee,0xfe,0xce,0xf6, 0x2c,0xee,0x24,0xdd,0xa0,0xd4,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x22,0xdd,0x48,0xf6,0xcb,0xfe,0xcc,0xfe, 0xee,0xfe,0x0f,0xff,0x10,0xff,0xaf,0xf6,0xe9,0xe5,0xa0,0xd4,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xe0,0xff,0xa4,0xed,0xaa,0xfe, 0xcb,0xfe,0x29,0xee,0x08,0xee,0x2a,0xee,0x6c,0xf6,0xf0,0xfe,0x53,0xff,0xa8,0xe5, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xc0,0xd4,0xe6,0xed,0x28,0xf6,0x8b,0xf6,0xee,0xfe,0x0f,0xff,0x10,0xff,0x32,0xff, 0x53,0xff,0xea,0xe5,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0x22,0xdd,0x89,0xfe,0xcb,0xfe,0xcc,0xfe,0xee,0xfe,0x0f,0xff, 0x10,0xff,0x32,0xff,0x6d,0xee,0x03,0xdd,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0xcc,0xa4,0xe5,0xaa,0xfe,0xcb,0xfe,0x6a,0xf6, 0x29,0xee,0x4a,0xee,0x6c,0xf6,0x6d,0xf6,0xa7,0xe5,0xa0,0xd4,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xe1,0xdc,0x69,0xfe, 0x28,0xee,0x49,0xf6,0xed,0xfe,0x0f,0xff,0x10,0xff,0x32,0xff,0x53,0xff,0x45,0xdd, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xe1,0xdc,0x27,0xf6,0xcb,0xfe,0xcc,0xfe,0xee,0xfe,0x0f,0xff,0x10,0xff,0x32,0xff, 0x4c,0xee,0xc0,0xd4,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0x00,0xfc,0xa4,0xed,0xc8,0xfe,0x06,0xf7,0x05,0xef,0x24,0xef,0x25,0xef, 0x28,0xef,0x2b,0xf7,0xe8,0xe5,0xa0,0xd4,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x43,0xee,0x6b,0xf7,0x92,0xf7,0xd2,0xff, 0xd2,0xff,0xd2,0xff,0xd2,0xff,0x92,0xf7,0x2b,0xef,0x25,0xe6,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x60,0xef,0x8d,0xf7,0x8d,0xff, 0x2e,0xef,0xd0,0xff,0xce,0xff,0xcd,0xff,0xcb,0xff,0x6b,0xf7,0x71,0xf7,0x49,0xef, 0xa0,0xd6,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x86,0xef, 0xef,0xff,0x86,0xf7,0x0e,0xef,0xd0,0xff,0xcf,0xff,0xcd,0xff,0xab,0xff,0x4a,0xf7, 0x29,0xef,0xd2,0xff,0x21,0xe7,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xe0,0xff,0xaf,0xf7,0xe7,0xff,0xc7,0xff,0x2f,0xef,0xf1,0xff,0xae,0xff,0xac,0xff, 0xcb,0xff,0x8b,0xf7,0x6a,0xf7,0xed,0xff,0x69,0xef,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0x60,0xef,0xd1,0xff,0xe6,0xff,0xc8,0xff,0x50,0xef,0xf2,0xff, 0xf0,0xff,0xee,0xff,0xec,0xff,0x8c,0xf7,0x6b,0xf7,0xe8,0xff,0xb0,0xf7,0xe0,0xde, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x84,0xf7,0xd0,0xff,0xe7,0xff,0xc9,0xff, 0x50,0xef,0xf2,0xff,0xf1,0xff,0xef,0xff,0xed,0xff,0x8c,0xf7,0x6b,0xf7,0xe8,0xff, 0xd2,0xff,0x21,0xe7,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xa0,0xd6,0xad,0xf7,0xeb,0xff, 0xe8,0xff,0xc9,0xff,0x50,0xef,0xf3,0xff,0xf1,0xff,0xf0,0xff,0xee,0xff,0x8d,0xf7, 0x6c,0xf7,0xe9,0xff,0xef,0xff,0x69,0xef,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x20,0xe7,0xa6,0xf7, 0xf2,0xff,0xe8,0xff,0xe9,0xff,0xcb,0xff,0x31,0xef,0xf3,0xff,0xf2,0xff,0xf0,0xff, 0xef,0xff,0x4f,0xef,0x8d,0xf7,0xea,0xff,0xe9,0xff,0xd3,0xff,0x44,0xef,0xe0,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xe0,0xff, 0xa5,0xf7,0xf2,0xff,0xe8,0xff,0xe9,0xff,0xea,0xff,0xeb,0xff,0x8e,0xf7,0x11,0xe7, 0x51,0xef,0x51,0xef,0xb0,0xde,0x6e,0xef,0xec,0xff,0xeb,0xff,0xea,0xff,0xea,0xff, 0xd3,0xff,0x42,0xe7,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xe0,0xff,0xa1,0xf7,0xf3,0xff,0xe8,0xff,0xe8,0xff,0xe9,0xff,0xea,0xff,0xeb,0xff, 0xec,0xff,0xac,0xb5,0x0d,0xc6,0xae,0xff,0xaa,0x73,0xad,0xf7,0xec,0xff,0xeb,0xff, 0xea,0xff,0xe9,0xff,0xeb,0xff,0xb1,0xf7,0x41,0xef,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xa0,0xf7,0xef,0xff,0xeb,0xff,0xe7,0xff,0xe9,0xff,0xea,0xff, 0xeb,0xff,0xec,0xff,0xed,0xff,0xcd,0x9c,0xaf,0xf7,0xef,0xff,0xcd,0xbd,0x6d,0xce, 0xed,0xff,0xec,0xff,0xeb,0xff,0xea,0xff,0xe9,0xff,0xef,0xff,0x8a,0xef,0x60,0xef, 0xff,0xff,0xff,0xff,0xff,0xff,0x80,0xef,0xc8,0xf7,0xef,0xff,0xe7,0xff,0xe8,0xff, 0xe9,0xff,0xea,0xff,0xeb,0xff,0xed,0xff,0x8e,0xf7,0x8f,0xb5,0xf0,0xff,0xf0,0xff, 0xb0,0xf7,0x6f,0xad,0xee,0xff,0xed,0xff,0xeb,0xff,0xea,0xff,0xe9,0xff,0xe8,0xff, 0xf2,0xff,0x64,0xef,0xe0,0xff,0xff,0xff,0xff,0xff,0xa1,0xf7,0xf2,0xff,0xe6,0xff, 0xe7,0xff,0xe8,0xff,0xe9,0xff,0xeb,0xff,0xec,0xff,0xed,0xff,0xd0,0xde,0x10,0xdf, 0xf1,0xff,0xf2,0xff,0xf1,0xff,0x31,0xc6,0x8f,0xf7,0xed,0xff,0xec,0xff,0xea,0xff, 0xe9,0xff,0xe8,0xff,0xe8,0xff,0xd1,0xf7,0x40,0xe7,0xff,0xff,0xff,0xff,0xc8,0xf7, 0xed,0xff,0xe6,0xff,0xe7,0xff,0xe8,0xff,0xe9,0xff,0xeb,0xff,0xec,0xff,0xed,0xff, 0xb3,0xd6,0xf1,0xff,0xf2,0xff,0xf3,0xff,0xf2,0xff,0x51,0xef,0x12,0xdf,0xed,0xff, 0xec,0xff,0xea,0xff,0xe9,0xff,0xe8,0xff,0xe7,0xff,0xf2,0xff,0x42,0xef,0xff,0xff, 0x80,0xf7,0xef,0xff,0xe6,0xff,0xe6,0xff,0xe7,0xff,0xe8,0xff,0xe9,0xff,0xeb,0xff, 0xec,0xff,0xcf,0xff,0x34,0xe7,0xf0,0xff,0xf2,0xff,0xf2,0xff,0xf1,0xff,0xf0,0xff, 0x14,0xe7,0xed,0xff,0xec,0xff,0xea,0xff,0xe9,0xff,0xe8,0xff,0xe7,0xff,0xec,0xff, 0x8a,0xef,0x00,0xe7,0xc0,0xff,0xf0,0xff,0xe4,0xff,0xe6,0xff,0xe7,0xff,0xe8,0xff, 0xe9,0xff,0xea,0xff,0xec,0xff,0xd2,0xff,0xd1,0xf7,0xf0,0xff,0xf1,0xff,0xf1,0xff, 0xf0,0xff,0xf0,0xff,0xb3,0xf7,0xd1,0xff,0xec,0xff,0xea,0xff,0xe9,0xff,0xe8,0xff, 0xe7,0xff,0xe7,0xff,0xae,0xf7,0x20,0xe7,0xc0,0xff,0xf1,0xff,0xe4,0xff,0xe5,0xff, 0xe6,0xff,0xe8,0xff,0xec,0xff,0xf0,0xff,0xf1,0xff,0xf8,0xff,0xfa,0xff,0xf2,0xff, 0xf0,0xff,0xf3,0xff,0xf0,0xff,0xf2,0xff,0xfa,0xff,0xef,0xff,0xeb,0xff,0xea,0xff, 0xe9,0xff,0xe8,0xff,0xe7,0xff,0xe5,0xff,0xd0,0xf7,0x40,0xef,0xc0,0xff,0xf0,0xff, 0xe4,0xff,0xe5,0xff,0xe6,0xff,0xef,0xff,0xf2,0xff,0xf2,0xff,0xf3,0xff,0xf3,0xff, 0xf7,0xff,0xfc,0xff,0xfc,0xff,0xf9,0xff,0xfc,0xff,0xf9,0xff,0xef,0xff,0xec,0xff, 0xeb,0xff,0xe9,0xff,0xe8,0xff,0xe7,0xff,0xe6,0xff,0xe6,0xff,0xd0,0xf7,0x20,0xe7, 0xc0,0xff,0xf0,0xff,0xe4,0xff,0xe5,0xff,0xed,0xff,0xf1,0xff,0xf2,0xff,0xf2,0xff, 0xf3,0xff,0xf3,0xff,0xf4,0xff,0xf4,0xff,0xf4,0xff,0xf4,0xff,0xf0,0xff,0xed,0xff, 0xec,0xff,0xeb,0xff,0xea,0xff,0xe9,0xff,0xe8,0xff,0xe7,0xff,0xe6,0xff,0xea,0xff, 0xab,0xf7,0x60,0xef,0xe0,0xff,0xeb,0xff,0xe9,0xff,0xe4,0xff,0xf0,0xff,0xf1,0xff, 0xf1,0xff,0xf2,0xff,0xf2,0xff,0xf3,0xff,0xf3,0xff,0xf3,0xff,0xf4,0xff,0xf4,0xff, 0xf4,0xff,0xee,0xff,0xeb,0xff,0xea,0xff,0xe9,0xff,0xe8,0xff,0xe7,0xff,0xe7,0xff, 0xe5,0xff,0xee,0xff,0x86,0xf7,0xff,0xff,0xff,0xff,0xe6,0xff,0xed,0xff,0xe5,0xff, 0xf0,0xff,0xf1,0xff,0xf1,0xff,0xf2,0xff,0xf2,0xff,0xf2,0xff,0xf3,0xff,0xf3,0xff, 0xf3,0xff,0xf3,0xff,0xf3,0xff,0xf2,0xff,0xeb,0xff,0xe9,0xff,0xe9,0xff,0xe8,0xff, 0xe7,0xff,0xe6,0xff,0xe5,0xff,0xf2,0xff,0x61,0xef,0xff,0xff,0xff,0xff,0xe1,0xff, 0xf2,0xff,0xe4,0xff,0xf0,0xff,0xf0,0xff,0xf1,0xff,0xf1,0xff,0xf2,0xff,0xf2,0xff, 0xf2,0xff,0xf2,0xff,0xf2,0xff,0xf3,0xff,0xf2,0xff,0xf2,0xff,0xed,0xff,0xe9,0xff, 0xe8,0xff,0xe7,0xff,0xe6,0xff,0xe5,0xff,0xe5,0xff,0xf2,0xff,0x60,0xef,0xff,0xff, 0xff,0xff,0xe0,0xff,0xeb,0xff,0xeb,0xff,0xec,0xff,0xf0,0xff,0xf1,0xff,0xf1,0xff, 0xf1,0xff,0xf2,0xff,0xf2,0xff,0xf2,0xff,0xf2,0xff,0xf2,0xff,0xf2,0xff,0xf2,0xff, 0xf0,0xff,0xe8,0xff,0xe7,0xff,0xe6,0xff,0xe6,0xff,0xe5,0xff,0xf0,0xff,0x86,0xf7, 0x60,0xef,0xff,0xff,0xff,0xff,0xff,0xff,0xe0,0xff,0xf1,0xff,0xe8,0xff,0xf0,0xff, 0xf0,0xff,0xf1,0xff,0xf1,0xff,0xf1,0xff,0xf1,0xff,0xf2,0xff,0xf2,0xff,0xf2,0xff, 0xf2,0xff,0xf1,0xff,0xef,0xff,0xe7,0xff,0xe6,0xff,0xe6,0xff,0xe5,0xff,0xe9,0xff, 0xcd,0xf7,0x60,0xef,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xe3,0xff, 0xf1,0xff,0xe8,0xff,0xf0,0xff,0xf0,0xff,0xf1,0xff,0xf1,0xff,0xf1,0xff,0xf1,0xff, 0xf1,0xff,0xf1,0xff,0xf1,0xff,0xf1,0xff,0xee,0xff,0xe6,0xff,0xe5,0xff,0xe5,0xff, 0xe5,0xff,0xf2,0xff,0x81,0xf7,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xe0,0xff,0xe8,0xff,0xf2,0xff,0xea,0xff,0xef,0xff,0xf0,0xff,0xf0,0xff, 0xf1,0xff,0xf1,0xff,0xf1,0xff,0xf1,0xff,0xf1,0xff,0xf0,0xff,0xe8,0xff,0xe5,0xff, 0xe5,0xff,0xe9,0xff,0xf2,0xff,0xa4,0xf7,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xe0,0xff,0xe4,0xff,0xf1,0xff,0xed,0xff, 0xec,0xff,0xf0,0xff,0xf0,0xff,0xf0,0xff,0xf0,0xff,0xf0,0xff,0xf0,0xff,0xe9,0xff, 0xe4,0xff,0xe4,0xff,0xef,0xff,0xce,0xff,0xa2,0xf7,0xe0,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xe0,0xff,0xea,0xff,0xf1,0xff,0xef,0xff,0xee,0xff,0xeb,0xff,0xea,0xff,0xe9,0xff, 0xe7,0xff,0xeb,0xff,0xf0,0xff,0xf2,0xff,0xc7,0xf7,0xa0,0xf7,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xe0,0xff,0xe1,0xff,0xe5,0xff,0xea,0xff,0xef,0xff, 0xf0,0xff,0xf0,0xff,0xce,0xff,0xe9,0xff,0xc4,0xff,0xa0,0xf7,0xe0,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xe0,0xff,0xc0,0xff,0xc0,0xff,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, };
the_stack_data/107952984.c
#include <sys/types.h> #include <ctype.h> #include <errno.h> #include <stdio.h> #include <stdlib.h> #include <string.h> int chk(f) char *f; { int ch, l, r; if (freopen(f, "r", stdin) == NULL) { fprintf(stderr, "%s: %s\n", f, strerror(errno)); exit(EXIT_FAILURE); } for (l = 1, r = 0; (ch = getchar()) != EOF;) { if (ch != ',') goto next; do { ch = getchar(); } while (isblank(ch)); if (ch != '\n') goto next; ++l; do { ch = getchar(); } while (isblank(ch)); if (ch != '}') goto next; r = 1; printf("%s: line %d\n", f, l); next: if (ch == '\n') ++l; } return (r); } int main(int argc, char *argv[]) { int r; for (r = 0; *++argv != NULL;) if (chk(*argv)) r = 1; return (r); }
the_stack_data/93887268.c
// Parker Harris Emerson, York Midterm Problem 2 // // I didn't quite understand what Simon was saying, but apparently the code provided is structured backward (?) to create the output in the problem example. I will endeavor to move forward regardless. #include <stdio.h> #include <stdlib.h> #include <math.h> // Including these because time pressure, may not need all three. void printBinary(unsigned int k) { // Prints binary value of k from left (low order bit) // to right (high order bit) for (int i = 0; i < 32; i++) { if (k & 1) { printf("1"); } else { printf("0"); } k >>= 1; } printf("\n"); } int updateBits(unsigned int n, unsigned int m, int i, int j) { unsigned int nx; for (int x = 31; x >= 0; x--) { if (x > j || x < i) { nx = (n & (1 << x)); } else { nx = (m & (1 << (x - i))); } } return nx; } int main() { unsigned int n, m, nx; int i, j; printf("n m i j (where n, m, i, and j in decimal with m much less than n)\n"); scanf("%u %u %d %d", &n, &m, &i, &j); printf("\n n = "); printBinary(n); printf("\n m = "); printBinary(m); printf("\ni = %d\nj = %d\n", i, j); nx = updateBits(n, m, i, j); printf("\nn = "); printBinary(nx); return 0; }
the_stack_data/47526.c
#include <math.h> #include <stdlib.h> /* This program is implemented with ideas from this web page: * * http://www.langsrud.com/fisher.htm */ // log\binom{n}{k} static double lbinom(int n, int k) { if (k == 0 || n == k) return 0; return lgamma(n+1) - lgamma(k+1) - lgamma(n-k+1); } // n11 n12 | n1_ // n21 n22 | n2_ //-----------+---- // n_1 n_2 | n // hypergeometric distribution static double hypergeo(int n11, int n1_, int n_1, int n) { return exp(lbinom(n1_, n11) + lbinom(n-n1_, n_1-n11) - lbinom(n, n_1)); } typedef struct { int n11, n1_, n_1, n; double p; } hgacc_t; // incremental version of hypergenometric distribution static double hypergeo_acc(int n11, int n1_, int n_1, int n, hgacc_t *aux) { if (n1_ || n_1 || n) { aux->n11 = n11; aux->n1_ = n1_; aux->n_1 = n_1; aux->n = n; } else { // then only n11 changed; the rest fixed if (n11%11 && n11 + aux->n - aux->n1_ - aux->n_1) { if (n11 == aux->n11 + 1) { // incremental aux->p *= (double)(aux->n1_ - aux->n11) / n11 * (aux->n_1 - aux->n11) / (n11 + aux->n - aux->n1_ - aux->n_1); aux->n11 = n11; return aux->p; } if (n11 == aux->n11 - 1) { // incremental aux->p *= (double)aux->n11 / (aux->n1_ - n11) * (aux->n11 + aux->n - aux->n1_ - aux->n_1) / (aux->n_1 - n11); aux->n11 = n11; return aux->p; } } aux->n11 = n11; } aux->p = hypergeo(aux->n11, aux->n1_, aux->n_1, aux->n); return aux->p; } double kt_fisher_exact(int n11, int n12, int n21, int n22, double *_left, double *_right, double *two) { int i, j, max, min; double p, q, left, right; hgacc_t aux; int n1_, n_1, n; n1_ = n11 + n12; n_1 = n11 + n21; n = n11 + n12 + n21 + n22; // calculate n1_, n_1 and n max = (n_1 < n1_) ? n_1 : n1_; // max n11, for right tail min = (n1_ + n_1 - n < 0) ? 0 : (n1_ + n_1 - n < 0); // min n11, for left tail *two = *_left = *_right = 1.; if (min == max) return 1.; // no need to do test q = hypergeo_acc(n11, n1_, n_1, n, &aux); // the probability of the current table // left tail p = hypergeo_acc(min, 0, 0, 0, &aux); for (left = 0., i = min + 1; p < 0.99999999 * q; ++i) // loop until underflow left += p, p = hypergeo_acc(i, 0, 0, 0, &aux); --i; if (p < 1.00000001 * q) left += p; else --i; // right tail p = hypergeo_acc(max, 0, 0, 0, &aux); for (right = 0., j = max - 1; p < 0.99999999 * q; --j) // loop until underflow right += p, p = hypergeo_acc(j, 0, 0, 0, &aux); if (p < 1.00000001 * q) right += p; else ++j; // two-tail *two = left + right; if (*two > 1.) *two = 1.; // adjust left and right if (abs(i - n11) < abs(j - n11)) right = 1. - left + q; else left = 1.0 - right + q; *_left = left; *_right = right; return q; } #ifdef FET_MAIN #include <stdio.h> int main(int argc, char *argv[]) { char id[1024]; int n11, n12, n21, n22; double left, right, twotail, prob; while (scanf("%s%d%d%d%d", id, &n11, &n12, &n21, &n22) == 5) { prob = kt_fisher_exact(n11, n12, n21, n22, &left, &right, &twotail); printf("%s\t%d\t%d\t%d\t%d\t%.6g\t%.6g\t%.6g\t%.6g\n", id, n11, n12, n21, n22, prob, left, right, twotail); } return 0; } #endif
the_stack_data/187642001.c
/* { dg-do compile } */ /* { dg-options "-O3 -fwhole-program" } */ /* { dg-final { scan-assembler "mystr" } } */ extern const char *mystr; /* normally in a header */ const char *mystr __attribute__ ((externally_visible)); main() { }
the_stack_data/60260.c
#include <stdio.h> int main(){ int ari[999], arf[999]; int n, i, j, c1 = 0, c2 = 0, c3 = 0, min = 0; scanf("%d", & n); for(i = 0; i != n; i++){ scanf("%d", & ari[i]); } for(i = 0; i != n-1; i++){ if(ari[i] >= ari[i + 1]){ arf[i] = ari[i] - ari[i+1]; c1++; } else{ arf[i] = ari[i+1] - ari[i]; c1++; } } for(i = 1; i < n + 1; i++){ for(j = 0; j < c1; j++){ if(arf[j] == i){ c2 ++; } } if(c2 > 0){ c3 ++; } else{ if(min == 0){ min = i; } if(i < min){ min = i; } } c2 = 0; } if(c3 == n - 1){ printf("%d\n",0); } else{ printf("%d\n",min); } return 0; }
the_stack_data/427288.c
#include <stdio.h> #include <string.h> int main(int argc, char *argv[]) { char passwd[] = "password"; if (argc < 2) { printf("usage: %s password\n", argv[0]); return 0; } if (!strcmp(passwd, argv[1])) { printf("Correct Password!\n"); } else { printf("Invalid Password!\n"); } return 0; }
the_stack_data/234517902.c
#include<stdio.h> #define SIZE 10 int main() { char name[SIZE][20]; printf("enter %d values..\n", SIZE); //using for loop to take user input in array for(int i = 0; i < SIZE; i++) { scanf("%s",name[i]); } printf("\nPrinting all the values\n"); //using for loop to display data stored in array for(int j = 0; j < SIZE; j++) { printf("Name is::%s\n",name[j]); } return 0; } /* Output: enter 10 values.. dfdg fbsg nfjfs dbzk dvni abdkj davnk avdk afe uiaef Printing all the values Name is::dfdg Name is::fbsg Name is::nfjfs Name is::dbzk Name is::dvni Name is::abdkj Name is::davnk Name is::avdk Name is::afe Name is::uiaef */
the_stack_data/145452870.c
/* Generated by CIL v. 1.7.0 */ /* print_CIL_Input is false */ struct _IO_FILE; struct timeval; extern float strtof(char const *str , char const *endptr ) ; extern void signal(int sig , void *func ) ; typedef struct _IO_FILE FILE; extern int atoi(char const *s ) ; extern double strtod(char const *str , char const *endptr ) ; extern int fclose(void *stream ) ; extern void *fopen(char const *filename , char const *mode ) ; extern void abort() ; extern void exit(int status ) ; extern int raise(int sig ) ; extern int fprintf(struct _IO_FILE *stream , char const *format , ...) ; extern int strcmp(char const *a , char const *b ) ; extern int rand() ; extern unsigned long strtoul(char const *str , char const *endptr , int base ) ; void RandomFunc(unsigned short input[1] , unsigned short output[1] ) ; extern int strncmp(char const *s1 , char const *s2 , unsigned long maxlen ) ; extern int gettimeofday(struct timeval *tv , void *tz , ...) ; extern int printf(char const *format , ...) ; int main(int argc , char *argv[] ) ; void megaInit(void) ; extern unsigned long strlen(char const *s ) ; extern long strtol(char const *str , char const *endptr , int base ) ; extern unsigned long strnlen(char const *s , unsigned long maxlen ) ; extern void *memcpy(void *s1 , void const *s2 , unsigned long size ) ; struct timeval { long tv_sec ; long tv_usec ; }; extern void *malloc(unsigned long size ) ; extern int scanf(char const *format , ...) ; void megaInit(void) { { } } int main(int argc , char *argv[] ) { unsigned short input[1] ; unsigned short output[1] ; int randomFuns_i5 ; unsigned short randomFuns_value6 ; int randomFuns_main_i7 ; { megaInit(); if (argc != 2) { printf("Call this program with %i arguments\n", 1); exit(-1); } else { } randomFuns_i5 = 0; while (randomFuns_i5 < 1) { randomFuns_value6 = (unsigned short )strtoul(argv[randomFuns_i5 + 1], 0, 10); input[randomFuns_i5] = randomFuns_value6; randomFuns_i5 ++; } RandomFunc(input, output); if (output[0] == (unsigned short)31026) { printf("You win!\n"); } else { } randomFuns_main_i7 = 0; while (randomFuns_main_i7 < 1) { printf("%u\n", output[randomFuns_main_i7]); randomFuns_main_i7 ++; } } } void RandomFunc(unsigned short input[1] , unsigned short output[1] ) { unsigned short state[1] ; unsigned short local2 ; unsigned short local1 ; char copy11 ; { state[0UL] = (input[0UL] + 914778474UL) * (unsigned short)64278; local1 = 0UL; while (local1 < input[1UL]) { local2 = 0UL; while (local2 < input[1UL]) { if (state[0UL] < local2 + local1) { copy11 = *((char *)(& state[local1]) + 0); *((char *)(& state[local1]) + 0) = *((char *)(& state[local1]) + 1); *((char *)(& state[local1]) + 1) = copy11; } else { state[0UL] = state[local1] + state[local1]; state[0UL] += state[0UL]; } local2 ++; } local1 ++; } output[0UL] = state[0UL] * 447621010UL; } }
the_stack_data/211081070.c
// INVERTENDO A LISTA DE MODO ITERATIVO #include<stdio.h> #include<stdlib.h> struct node { int data; struct node * link; }; struct node * Insert (struct node * head, int data) { struct node * temp = (struct node *) malloc(sizeof(struct node *)); temp->data = data; temp-> link = NULL; if (head == NULL) { head = temp; } else { struct node * temp1 = head; while(temp1->link != NULL) { temp1 = temp1->link; } temp1->link = temp; } return head; } void Print(struct node * head) { while(head != NULL) { printf("%d ",head->data); head = head->link; } printf("\n"); } struct node * Reverse(struct node * head) { struct node * link, *prev, *current; current = head; prev = NULL; while(current != NULL) { link = current->link; current->link = prev; prev = current; current = link; } head = prev; return head; } int main(int argc, char const *argv[]) { struct node * head = NULL; head = Insert (head, 2); head = Insert (head, 4); head = Insert (head, 6); head = Insert (head, 8); Print(head); head = Reverse(head); Print(head); return 0; }
the_stack_data/122014724.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_9__ TYPE_3__ ; typedef struct TYPE_8__ TYPE_1__ ; /* Type definitions */ typedef int uint32_t ; typedef int /*<<< orphan*/ tests ; typedef int /*<<< orphan*/ test_nans ; struct TYPE_8__ {int /*<<< orphan*/ rhs; int /*<<< orphan*/ lhs; int /*<<< orphan*/ op; } ; typedef TYPE_1__ test_nan_entry_t ; typedef TYPE_1__ test_error_entry_t ; struct TYPE_9__ {int /*<<< orphan*/ op; int /*<<< orphan*/ expected; int /*<<< orphan*/ rhs; int /*<<< orphan*/ lhs; } ; typedef TYPE_3__ test_entry_t ; typedef int /*<<< orphan*/ jerry_value_t ; typedef int /*<<< orphan*/ jerry_char_t ; typedef int /*<<< orphan*/ error_tests ; /* Variables and functions */ int /*<<< orphan*/ JERRY_BIN_OP_ADD ; int /*<<< orphan*/ JERRY_BIN_OP_DIV ; int /*<<< orphan*/ JERRY_BIN_OP_MUL ; int /*<<< orphan*/ JERRY_BIN_OP_REM ; int /*<<< orphan*/ JERRY_BIN_OP_STRICT_EQUAL ; int /*<<< orphan*/ JERRY_BIN_OP_SUB ; int /*<<< orphan*/ JERRY_ERROR_SYNTAX ; int /*<<< orphan*/ JERRY_INIT_EMPTY ; int /*<<< orphan*/ JERRY_PARSE_NO_OPTS ; TYPE_3__ T (int /*<<< orphan*/ ,int /*<<< orphan*/ ,int /*<<< orphan*/ ,int /*<<< orphan*/ ) ; int /*<<< orphan*/ TEST_ASSERT (int) ; int /*<<< orphan*/ TEST_INIT () ; TYPE_1__ T_ARI (int /*<<< orphan*/ ,int /*<<< orphan*/ ) ; TYPE_1__ T_ERR (int /*<<< orphan*/ ,int /*<<< orphan*/ ,int /*<<< orphan*/ ) ; TYPE_1__ T_NAN (int /*<<< orphan*/ ,int /*<<< orphan*/ ,int /*<<< orphan*/ ) ; int /*<<< orphan*/ jerry_acquire_value (int /*<<< orphan*/ ) ; int /*<<< orphan*/ jerry_binary_operation (int /*<<< orphan*/ ,int /*<<< orphan*/ ,int /*<<< orphan*/ ) ; int /*<<< orphan*/ jerry_cleanup () ; int /*<<< orphan*/ jerry_create_boolean (int) ; int /*<<< orphan*/ jerry_create_error (int /*<<< orphan*/ ,int /*<<< orphan*/ const*) ; int /*<<< orphan*/ jerry_create_null () ; int /*<<< orphan*/ jerry_create_number (double) ; int /*<<< orphan*/ jerry_create_number_infinity (int) ; int /*<<< orphan*/ jerry_create_string (int /*<<< orphan*/ const*) ; int /*<<< orphan*/ jerry_create_undefined () ; int /*<<< orphan*/ jerry_eval (int /*<<< orphan*/ const*,int,int /*<<< orphan*/ ) ; scalar_t__ jerry_get_boolean_value (int /*<<< orphan*/ ) ; double jerry_get_number_value (int /*<<< orphan*/ ) ; int /*<<< orphan*/ jerry_init (int /*<<< orphan*/ ) ; int /*<<< orphan*/ jerry_release_value (int /*<<< orphan*/ ) ; scalar_t__ jerry_value_is_boolean (int /*<<< orphan*/ ) ; int jerry_value_is_error (int /*<<< orphan*/ ) ; int jerry_value_is_number (int /*<<< orphan*/ ) ; int main (void) { TEST_INIT (); jerry_init (JERRY_INIT_EMPTY); jerry_value_t obj1 = jerry_eval ((const jerry_char_t *) "o={x:1};o", 9, JERRY_PARSE_NO_OPTS); jerry_value_t obj2 = jerry_eval ((const jerry_char_t *) "o={x:1};o", 9, JERRY_PARSE_NO_OPTS); jerry_value_t err1 = jerry_create_error (JERRY_ERROR_SYNTAX, (const jerry_char_t *) "error"); test_nan_entry_t test_nans[] = { /* Testing addition (+) */ T_NAN (JERRY_BIN_OP_ADD, jerry_create_number (3.1), jerry_create_undefined ()), T_NAN (JERRY_BIN_OP_ADD, jerry_create_undefined (), jerry_create_undefined ()), T_NAN (JERRY_BIN_OP_ADD, jerry_create_undefined (), jerry_create_null ()), /* Testing subtraction (-), multiplication (*), division (/), remainder (%) */ T_ARI (jerry_create_number (3.1), jerry_create_undefined ()), T_ARI (jerry_create_string ((const jerry_char_t *) "foo"), jerry_create_string ((const jerry_char_t *) "bar")), T_ARI (jerry_create_string ((const jerry_char_t *) "foo"), jerry_create_undefined ()), T_ARI (jerry_create_string ((const jerry_char_t *) "foo"), jerry_create_null ()), T_ARI (jerry_create_string ((const jerry_char_t *) "foo"), jerry_create_number (5.0)), T_ARI (jerry_create_undefined (), jerry_create_string ((const jerry_char_t *) "foo")), T_ARI (jerry_create_null (), jerry_create_string ((const jerry_char_t *) "foo")), T_ARI (jerry_create_number (5.0), jerry_create_string ((const jerry_char_t *) "foo")), T_ARI (jerry_create_undefined (), jerry_create_undefined ()), T_ARI (jerry_create_undefined (), jerry_create_null ()), T_ARI (jerry_create_null (), jerry_create_undefined ()), T_ARI (jerry_acquire_value (obj1), jerry_acquire_value (obj1)), T_ARI (jerry_acquire_value (obj1), jerry_acquire_value (obj2)), T_ARI (jerry_acquire_value (obj2), jerry_acquire_value (obj1)), T_ARI (jerry_acquire_value (obj2), jerry_create_undefined ()), T_ARI (jerry_acquire_value (obj1), jerry_create_string ((const jerry_char_t *) "foo")), T_ARI (jerry_acquire_value (obj1), jerry_create_null ()), T_ARI (jerry_acquire_value (obj1), jerry_create_boolean (true)), T_ARI (jerry_acquire_value (obj1), jerry_create_boolean (false)), T_ARI (jerry_acquire_value (obj1), jerry_create_number (5.0)), /* Testing division (/) */ T_NAN (JERRY_BIN_OP_DIV, jerry_create_boolean (false), jerry_create_boolean (false)), T_NAN (JERRY_BIN_OP_DIV, jerry_create_number (0.0), jerry_create_number (0.0)), T_NAN (JERRY_BIN_OP_DIV, jerry_create_null (), jerry_create_null ()), /* Testing remainder (%) */ T_NAN (JERRY_BIN_OP_REM, jerry_create_boolean (true), jerry_create_boolean (false)), T_NAN (JERRY_BIN_OP_REM, jerry_create_boolean (false), jerry_create_boolean (false)), T_NAN (JERRY_BIN_OP_REM, jerry_create_number (0.0), jerry_create_number (0.0)), T_NAN (JERRY_BIN_OP_REM, jerry_create_null (), jerry_create_null ()), }; for (uint32_t idx = 0; idx < sizeof (test_nans) / sizeof (test_nan_entry_t); idx++) { jerry_value_t result = jerry_binary_operation (test_nans[idx].op, test_nans[idx].lhs, test_nans[idx].rhs); TEST_ASSERT (jerry_value_is_number (result)); double num = jerry_get_number_value (result); TEST_ASSERT (num != num); jerry_release_value (test_nans[idx].lhs); jerry_release_value (test_nans[idx].rhs); jerry_release_value (result); } test_entry_t tests[] = { /* Testing addition (+) */ T (JERRY_BIN_OP_ADD, jerry_create_number (5.0), jerry_create_number (5.0), jerry_create_number (10.0)), T (JERRY_BIN_OP_ADD, jerry_create_number (3.1), jerry_create_number (10), jerry_create_number (13.1)), T (JERRY_BIN_OP_ADD, jerry_create_number (3.1), jerry_create_boolean (true), jerry_create_number (4.1)), T (JERRY_BIN_OP_ADD, jerry_create_string ((const jerry_char_t *) "foo"), jerry_create_string ((const jerry_char_t *) "bar"), jerry_create_string ((const jerry_char_t *) "foobar")), T (JERRY_BIN_OP_ADD, jerry_create_string ((const jerry_char_t *) "foo"), jerry_create_undefined (), jerry_create_string ((const jerry_char_t *) "fooundefined")), T (JERRY_BIN_OP_ADD, jerry_create_string ((const jerry_char_t *) "foo"), jerry_create_null (), jerry_create_string ((const jerry_char_t *) "foonull")), T (JERRY_BIN_OP_ADD, jerry_create_string ((const jerry_char_t *) "foo"), jerry_create_number (5.0), jerry_create_string ((const jerry_char_t *) "foo5")), T (JERRY_BIN_OP_ADD, jerry_create_null (), jerry_create_null (), jerry_create_number (0.0)), T (JERRY_BIN_OP_ADD, jerry_create_boolean (true), jerry_create_boolean (true), jerry_create_number (2.0)), T (JERRY_BIN_OP_ADD, jerry_create_boolean (true), jerry_create_boolean (false), jerry_create_number (1.0)), T (JERRY_BIN_OP_ADD, jerry_create_boolean (false), jerry_create_boolean (true), jerry_create_number (1.0)), T (JERRY_BIN_OP_ADD, jerry_create_boolean (false), jerry_create_boolean (false), jerry_create_number (0.0)), T (JERRY_BIN_OP_ADD, jerry_acquire_value (obj1), jerry_acquire_value (obj1), jerry_create_string ((const jerry_char_t *) "[object Object][object Object]")), T (JERRY_BIN_OP_ADD, jerry_acquire_value (obj1), jerry_acquire_value (obj2), jerry_create_string ((const jerry_char_t *) "[object Object][object Object]")), T (JERRY_BIN_OP_ADD, jerry_acquire_value (obj2), jerry_acquire_value (obj1), jerry_create_string ((const jerry_char_t *) "[object Object][object Object]")), T (JERRY_BIN_OP_ADD, jerry_acquire_value (obj1), jerry_create_null (), jerry_create_string ((const jerry_char_t *) "[object Object]null")), T (JERRY_BIN_OP_ADD, jerry_acquire_value (obj1), jerry_create_undefined (), jerry_create_string ((const jerry_char_t *) "[object Object]undefined")), T (JERRY_BIN_OP_ADD, jerry_acquire_value (obj1), jerry_create_boolean (true), jerry_create_string ((const jerry_char_t *) "[object Object]true")), T (JERRY_BIN_OP_ADD, jerry_acquire_value (obj1), jerry_create_boolean (false), jerry_create_string ((const jerry_char_t *) "[object Object]false")), T (JERRY_BIN_OP_ADD, jerry_acquire_value (obj1), jerry_create_number (5.0), jerry_create_string ((const jerry_char_t *) "[object Object]5")), T (JERRY_BIN_OP_ADD, jerry_acquire_value (obj1), jerry_create_string ((const jerry_char_t *) "foo"), jerry_create_string ((const jerry_char_t *) "[object Object]foo")), /* Testing subtraction (-) */ T (JERRY_BIN_OP_SUB, jerry_create_number (5.0), jerry_create_number (5.0), jerry_create_number (0.0)), T (JERRY_BIN_OP_SUB, jerry_create_number (3.1), jerry_create_number (10), jerry_create_number (-6.9)), T (JERRY_BIN_OP_SUB, jerry_create_number (3.1), jerry_create_boolean (true), jerry_create_number (2.1)), T (JERRY_BIN_OP_SUB, jerry_create_boolean (true), jerry_create_boolean (true), jerry_create_number (0.0)), T (JERRY_BIN_OP_SUB, jerry_create_boolean (true), jerry_create_boolean (false), jerry_create_number (1.0)), T (JERRY_BIN_OP_SUB, jerry_create_boolean (false), jerry_create_boolean (true), jerry_create_number (-1.0)), T (JERRY_BIN_OP_SUB, jerry_create_boolean (false), jerry_create_boolean (false), jerry_create_number (0.0)), T (JERRY_BIN_OP_SUB, jerry_create_null (), jerry_create_null (), jerry_create_number (-0.0)), /* Testing multiplication (*) */ T (JERRY_BIN_OP_MUL, jerry_create_number (5.0), jerry_create_number (5.0), jerry_create_number (25.0)), T (JERRY_BIN_OP_MUL, jerry_create_number (3.1), jerry_create_number (10), jerry_create_number (31)), T (JERRY_BIN_OP_MUL, jerry_create_number (3.1), jerry_create_boolean (true), jerry_create_number (3.1)), T (JERRY_BIN_OP_MUL, jerry_create_boolean (true), jerry_create_boolean (true), jerry_create_number (1.0)), T (JERRY_BIN_OP_MUL, jerry_create_boolean (true), jerry_create_boolean (false), jerry_create_number (0.0)), T (JERRY_BIN_OP_MUL, jerry_create_boolean (false), jerry_create_boolean (true), jerry_create_number (0.0)), T (JERRY_BIN_OP_MUL, jerry_create_boolean (false), jerry_create_boolean (false), jerry_create_number (0.0)), T (JERRY_BIN_OP_MUL, jerry_create_null (), jerry_create_null (), jerry_create_number (0.0)), /* Testing division (/) */ T (JERRY_BIN_OP_DIV, jerry_create_number (5.0), jerry_create_number (5.0), jerry_create_number (1.0)), T (JERRY_BIN_OP_DIV, jerry_create_number (3.1), jerry_create_number (10), jerry_create_number (0.31)), T (JERRY_BIN_OP_DIV, jerry_create_number (3.1), jerry_create_boolean (true), jerry_create_number (3.1)), T (JERRY_BIN_OP_DIV, jerry_create_boolean (true), jerry_create_boolean (true), jerry_create_number (1.0)), T (JERRY_BIN_OP_DIV, jerry_create_boolean (true), jerry_create_boolean (false), jerry_create_number_infinity (false)), T (JERRY_BIN_OP_DIV, jerry_create_boolean (false), jerry_create_boolean (true), jerry_create_number (0.0)), /* Testing remainder (%) */ T (JERRY_BIN_OP_REM, jerry_create_number (5.0), jerry_create_number (5.0), jerry_create_number (0.0)), T (JERRY_BIN_OP_REM, jerry_create_number (5.0), jerry_create_number (2.0), jerry_create_number (1.0)), T (JERRY_BIN_OP_REM, jerry_create_number (3.1), jerry_create_number (10), jerry_create_number (3.1)), T (JERRY_BIN_OP_REM, jerry_create_number (3.1), jerry_create_boolean (true), jerry_create_number (0.10000000000000009)), T (JERRY_BIN_OP_REM, jerry_create_boolean (true), jerry_create_boolean (true), jerry_create_number (0.0)), T (JERRY_BIN_OP_REM, jerry_create_boolean (false), jerry_create_boolean (true), jerry_create_number (0.0)), }; for (uint32_t idx = 0; idx < sizeof (tests) / sizeof (test_entry_t); idx++) { jerry_value_t result = jerry_binary_operation (tests[idx].op, tests[idx].lhs, tests[idx].rhs); TEST_ASSERT (!jerry_value_is_error (result)); jerry_value_t equals = jerry_binary_operation (JERRY_BIN_OP_STRICT_EQUAL, result, tests[idx].expected); TEST_ASSERT (jerry_value_is_boolean (equals) && jerry_get_boolean_value (equals)); jerry_release_value (equals); jerry_release_value (tests[idx].lhs); jerry_release_value (tests[idx].rhs); jerry_release_value (tests[idx].expected); jerry_release_value (result); } jerry_value_t obj3 = jerry_eval ((const jerry_char_t *) "o={valueOf:function(){throw 5}};o", 33, JERRY_PARSE_NO_OPTS); test_error_entry_t error_tests[] = { /* Testing addition (+) */ T_ERR (JERRY_BIN_OP_ADD, jerry_acquire_value (err1), jerry_acquire_value (err1)), T_ERR (JERRY_BIN_OP_ADD, jerry_acquire_value (err1), jerry_create_undefined ()), T_ERR (JERRY_BIN_OP_ADD, jerry_create_undefined (), jerry_acquire_value (err1)), /* Testing subtraction (-), multiplication (*), division (/), remainder (%) */ T_ARI (jerry_acquire_value (err1), jerry_acquire_value (err1)), T_ARI (jerry_acquire_value (err1), jerry_create_undefined ()), T_ARI (jerry_create_undefined (), jerry_acquire_value (err1)), /* Testing addition (+) */ T_ERR (JERRY_BIN_OP_ADD, jerry_acquire_value (obj3), jerry_create_undefined ()), T_ERR (JERRY_BIN_OP_ADD, jerry_acquire_value (obj3), jerry_create_null ()), T_ERR (JERRY_BIN_OP_ADD, jerry_acquire_value (obj3), jerry_create_boolean (true)), T_ERR (JERRY_BIN_OP_ADD, jerry_acquire_value (obj3), jerry_create_boolean (false)), T_ERR (JERRY_BIN_OP_ADD, jerry_acquire_value (obj3), jerry_acquire_value (obj2)), T_ERR (JERRY_BIN_OP_ADD, jerry_acquire_value (obj3), jerry_create_string ((const jerry_char_t *) "foo")), /* Testing subtraction (-), multiplication (*), division (/), remainder (%) */ T_ARI (jerry_acquire_value (obj3), jerry_create_undefined ()), T_ARI (jerry_acquire_value (obj3), jerry_create_null ()), T_ARI (jerry_acquire_value (obj3), jerry_create_boolean (true)), T_ARI (jerry_acquire_value (obj3), jerry_create_boolean (false)), T_ARI (jerry_acquire_value (obj3), jerry_acquire_value (obj2)), T_ARI (jerry_acquire_value (obj3), jerry_create_string ((const jerry_char_t *) "foo")), }; for (uint32_t idx = 0; idx < sizeof (error_tests) / sizeof (test_error_entry_t); idx++) { jerry_value_t result = jerry_binary_operation (tests[idx].op, error_tests[idx].lhs, error_tests[idx].rhs); TEST_ASSERT (jerry_value_is_error (result)); jerry_release_value (error_tests[idx].lhs); jerry_release_value (error_tests[idx].rhs); jerry_release_value (result); } jerry_release_value (obj1); jerry_release_value (obj2); jerry_release_value (obj3); jerry_release_value (err1); jerry_cleanup (); return 0; }
the_stack_data/80726.c
#include <stdio.h> #include <math.h> int main(void) { int i = 0; char input[13], password[13] = "lemonysnicket"; printf("Digite a senha: "); scanf("%s", input); while (i < 12) { if (input[i] == password[i]){ i++; } else{ printf("Senha incorreta\n"); return 1; } } printf("Senha correta"); return 0; }
the_stack_data/187643389.c
/***************************************************************************** C-DAC Tech Workshop : HEMPA-2011 Oct 17 - 21, 2011 Example : MatMatAddGlobalMemDP.c Objective : Implement Matrix Matrix Addition using global memory (double precision) Input : None Output : Execution time in seconds , Gflops achieved Created : Aug 2011 E-mail : [email protected] ****************************************************************************/ #include<CL/cl.h> #include<stdio.h> #include<stdlib.h> #include<assert.h> #include<string.h> #include <math.h> #define EPS 1.0e-15 /* threshhold aprrox epsilion value */ #define SIZE 128 // Modify SIZE to execute for different data sizes #define OPENCL_CHECK_STATUS(NAME,ERR) {\ const char *name=NAME;\ cl_int Terr=ERR;\ if (Terr != CL_SUCCESS) {\ printf("\n\t\t Error: %s (%d) \n",name, Terr);\ exit(-1);} }\ const char * matMatAddGlobalMemKernelPath = "MatMatAddGlobalMemDP_kernel.cl"; /* get platform function*/ int getPlatform(cl_platform_id *selectedPlatform,cl_uint *numDevices) { cl_int err; int count; char pbuff[100]; cl_uint numPlatforms; cl_platform_id *platforms; *selectedPlatform = NULL; /* Get the number of OpenCL Platforms Available */ err = clGetPlatformIDs ( 0, 0, &numPlatforms); if( err != CL_SUCCESS || numPlatforms == 0) { printf(" \n\t\t No Platform Found \n"); return 1; } else { if( numPlatforms == 0) { return 1; } else { /* Allocate the space for available platform*/ assert( (platforms = (cl_platform_id *)malloc( sizeof(cl_platform_id) * (numPlatforms))) != NULL); /* Get available OpenCL Platforms IDs*/ err = clGetPlatformIDs( numPlatforms,platforms, NULL); OPENCL_CHECK_STATUS(" Failed to get Platform IDs",err); for ( count = 0 ; count < numPlatforms ; count++) { /* get platform info*/ err=clGetPlatformInfo(platforms[count],CL_PLATFORM_NAME,sizeof(pbuff),pbuff,NULL); OPENCL_CHECK_STATUS("clGetPlatformInfo Failed",err); /* get device id and info*/ err = clGetDeviceIDs( platforms[count],CL_DEVICE_TYPE_GPU,0,0,numDevices); if( err != CL_SUCCESS || *numDevices ==0) { continue; } else { /* get selected platform*/ *selectedPlatform =platforms[count]; printf("\n\t---------------------------Device details-------------------------------------\n\n"); printf("\tPlatform used : %s\n",pbuff); break; } } } } if ( count == numPlatforms ) { printf(" \n\t No platform found \n"); return 1; } free(platforms); return 0; } /* read program source file*/ char* readKernelSource(const char* kernelSourcePath) { FILE *fp = NULL; size_t sourceLength; char *sourceString ; fp = fopen( kernelSourcePath , "r"); if(fp == 0) { printf("failed to open file"); return NULL; } // get the length of the source code fseek(fp, 0, SEEK_END); sourceLength = ftell(fp); rewind(fp); // allocate a buffer for the source code string and read it in sourceString = (char *)malloc( sourceLength + 1); if( fread( sourceString, 1, sourceLength, fp) !=sourceLength ) { printf("\n\t Error : Fail to read file "); return 0; } sourceString[sourceLength+1]='\0'; fclose(fp); return sourceString; }// end of readKernelSource void fill_dp_matrix(double* matrix,int rowSize,int colSize) { int row, col ; for( row=0; row < rowSize; row++) for( col=0; col < colSize; col++) matrix[row * colSize + col] = drand48(); } void print_on_screen(char * programName,double tsec,int size,double gflops,int flag)//flag=1 if gflops has been calculated else flag =0 { printf("\n\t---------------%s----------------\n\n",programName); printf("\t\t\tSIZE\t TIME_SEC\t gflops \n\n"); if(flag==1) printf("\t\t\t%d\t%f\t %lf\t\n",size,tsec,gflops); else printf("\t\t\t%d\t%lf \t%s\t\n",size,tsec,"---"); printf("\n\t---------------------------------------------------------------------------------------"); } //free host matrix memory void hDpMatFree(double * arr,int len) { free(arr); } /************************************************************* function to execute set execution environment **************************************************************/ void setExeEnvMatMatAddGMDP(cl_context *context, cl_uint *numDevices, cl_device_id **devices, cl_program *program,cl_uint *numPlatforms,cl_platform_id *selectedPlatform,cl_int *err) { char pbuff[100]; //holds platform information (platform name) char dbuff[100]; //holds device information (platform name) int count; /* Get the number of OpenCL Platforms Available */ *err=getPlatform(selectedPlatform,numDevices); OPENCL_CHECK_STATUS("error while getting device info",*err); assert(((*devices)= (cl_device_id *) malloc( sizeof(cl_device_id ) *(*numDevices))) != NULL); *err = clGetDeviceIDs( *selectedPlatform, CL_DEVICE_TYPE_GPU, (*numDevices), *devices, 0); /* Get device Name */ *err = clGetDeviceInfo(*devices[0], CL_DEVICE_NAME, sizeof(dbuff), &dbuff, NULL); OPENCL_CHECK_STATUS("error while getting device info",*err); printf("\tDevice used : %s\n",dbuff); /*create context*/ *context=clCreateContext(0,1,devices[0],0,0,err); printf("\tNumber of GPU devices used : %d\n",*numDevices); if ( *err != CL_SUCCESS || *context == 0) { printf("\n\t No GPU detected "); printf("\n\t Context : %d , Err : %d",context, *err); exit(-1); } printf("\n\t------------------------------------------------------------------------------\n"); /*create program with source*/ char* sProgramSource = readKernelSource(matMatAddGlobalMemKernelPath); size_t sourceSize = strlen(sProgramSource) ; *program = clCreateProgramWithSource(*context, 1,(const char **) &sProgramSource, &sourceSize, err); OPENCL_CHECK_STATUS("error while creating program",*err); /*build program*/ *err = clBuildProgram(*program,1,devices[0],NULL,NULL,NULL); OPENCL_CHECK_STATUS("error while building program",*err); } /*********************************************************************************** function to perform Matrix Matrix Addition **************************************************************************************/ void matrixMatrixAdditionGMDP (cl_uint numDevices,cl_device_id *devices, cl_program program,cl_context context,double * h_MatA,double *h_MatB, double *h_Output,int height,int width) { cl_int err; cl_command_queue cmdQueue; //holds command queue object cl_kernel kernel; //holds kernel object cl_mem d_MatA,d_MatB,d_Output; //holds device input output buffer size_t globalWorkSize[2]={height,width}; //holds global group size double gflops=0.0; //holds total achieved gflops cl_ulong startTime, endTime,elapsedTime; //holds time float executionTimeInSeconds; //holds total execution time cl_event events; cl_event gpuExec[1]; // events //create command queue cmdQueue = clCreateCommandQueue(context, devices[0], CL_QUEUE_PROFILING_ENABLE, &err); if( err != CL_SUCCESS || cmdQueue == 0) { printf("\n\t Failed to create command queue \n" ); exit (-1); } /*create kernel object*/ kernel = clCreateKernel(program,"MatMatAddKernelGMDP",&err); OPENCL_CHECK_STATUS("error while creating kernel",err); /*create buffer*/ d_MatA=clCreateBuffer(context,CL_MEM_READ_ONLY|CL_MEM_COPY_HOST_PTR,sizeof(double)*(height*width),h_MatA,&err); OPENCL_CHECK_STATUS("error while creating buffer for input",err); d_MatB=clCreateBuffer(context,CL_MEM_READ_ONLY|CL_MEM_COPY_HOST_PTR,sizeof(double)*(height*width),h_MatB,&err); OPENCL_CHECK_STATUS("error while creating buffer for input",err); d_Output=clCreateBuffer(context,CL_MEM_WRITE_ONLY,sizeof(double)*(height*width),NULL,&err); OPENCL_CHECK_STATUS("error while creating buffer for d_Output",err); /*set kernel arg*/ err=clSetKernelArg(kernel,0,sizeof(cl_mem),(void *)&d_MatA); OPENCL_CHECK_STATUS("error while setting arg 1",err); err=clSetKernelArg(kernel,1,sizeof(cl_mem),(void *)&d_MatB); OPENCL_CHECK_STATUS("error while setting arg 1",err); err=clSetKernelArg(kernel,2,sizeof(cl_mem),(void *)&d_Output); OPENCL_CHECK_STATUS("error while setting arg 2",err); /*load kernel*/ err = clEnqueueNDRangeKernel(cmdQueue,kernel,2,NULL,globalWorkSize,NULL,0,NULL,&gpuExec[0]); OPENCL_CHECK_STATUS("error while creating ND range",err); //completion of all commands to command queue err = clFinish(cmdQueue); OPENCL_CHECK_STATUS("clFinish",err); /* calculate start time and end time*/ clGetEventProfilingInfo(gpuExec[0], CL_PROFILING_COMMAND_START, sizeof(cl_ulong), &startTime, NULL); clGetEventProfilingInfo(gpuExec[0], CL_PROFILING_COMMAND_END, sizeof(cl_ulong), &endTime, NULL); /* total alapsed time*/ elapsedTime = endTime-startTime; /* total execution time*/ executionTimeInSeconds = (float)(1.0e-9 * elapsedTime); /* reading buffer object*/ err = clEnqueueReadBuffer(cmdQueue,d_Output,CL_TRUE,0,sizeof(cl_double)*height*width,h_Output,0,0,&events); OPENCL_CHECK_STATUS("error while reading buffer",err); /* calculate gflops*/ gflops= (1.0e-9 * ((1.0 * height*width) / executionTimeInSeconds)); // Print the gflops on the screen print_on_screen("Matrix Matrix Addition using global memoryDoublePrecision",executionTimeInSeconds,height,gflops,1); //release opencl objects clReleaseMemObject(d_MatA); clReleaseMemObject(d_MatB); clReleaseMemObject(d_Output); clReleaseProgram(program); clReleaseKernel(kernel); clReleaseCommandQueue(cmdQueue); clReleaseContext(context); } /************************************************************ function to check the result with sequential result ***************************************************************/ int matMatAddCheckResultGMDP (double *h_MatA,double *h_MatB,double *output,int row,int col) { int i,j,k,flag=0; double *temp_Out; double errorNorm = 0.0; double eps=EPS; double relativeError=0.0; assert((temp_Out = (double *)malloc( sizeof(double) * row*col))!=NULL); /*sequential Matrix Matrix Addition result*/ for( j=0 ; j<row*col ; j++) { temp_Out[j]= h_MatA[j] + h_MatB[j]; } /* check opencl result with sequential result*/ for( j=0 ; j < row*col ; j++) { if (fabs(temp_Out[j]) > fabs(output[j])) relativeError = fabs((temp_Out[j] - output[j]) / temp_Out[j]); else relativeError = fabs((output[j] - temp_Out[j]) / output[j]); if (relativeError > eps && relativeError != 0.0e+00 ) { if(errorNorm < relativeError) { errorNorm = relativeError; flag=1; } } } if( flag == 1) { printf(" \n Results verfication : Failed"); printf(" \n Considered machine precision : %e", eps); printf(" \n Relative Error : %e", errorNorm); } if(flag==0) { printf("\n\n\t\tResult Verification success\n\n"); } free(temp_Out); return 0; } /*********************************************** function to execute main *************************************************/ int main(int argc,char *argv[]) { cl_platform_id selectedPlatform; //holds list of platforms cl_uint numPlatforms; //holds number of platforms cl_int err; //holds error (return value) cl_uint numDevices; /*hold the number of devices */ cl_device_id *devices; /* hold list of devices */ int count; cl_context context; //holds context object cl_program program; //holds program object cl_kernel kernel; //holds kernel object double *h_MatA; //holds host input buffer double *h_MatB; //holds host input buffer double *h_Output; //holds host output buffer int i; int height=SIZE; //set height of matrix int width=SIZE; //set width of matrix /* allocate host memory*/ assert((h_MatA=(double *)malloc(height*width*sizeof(double)))!=NULL); assert((h_Output=(double *)malloc(height*width*sizeof(double)))!=NULL); assert((h_MatB=(double *)malloc(height*width*sizeof(double)))!=NULL); /*initialize host memory*/ fill_dp_matrix(h_MatA,height,width); fill_dp_matrix(h_MatB,height,width); for(i=0;i<height*width;i++) { h_Output[i]=0; } //set execution environment for opencl setExeEnvMatMatAddGMDP( &context , &numDevices, &devices, &program,&numPlatforms,&selectedPlatform,&err ); //function to calculate Matrix Matrix addition matrixMatrixAdditionGMDP(numDevices, devices,program,context,h_MatA,h_MatB,h_Output,height,width); //check result matMatAddCheckResultGMDP(h_MatA,h_MatB,h_Output,height,width); /******************************************************** uncomment to print it on the screen ********************************************************/ /* print buffer object*/ /*for(i=0;i<height*height;i++) { printf("%f\n",h_output[i]); }*/ /* free host memory*/ hDpMatFree(h_MatA,height); hDpMatFree(h_MatB,height); hDpMatFree(h_Output,height); }
the_stack_data/18887325.c
# include <stdio.h> # define N 5 typedef struct { float dinheiro; float tan; } deposito; deposito leDeposito(void); void leNDepositos(deposito [], int); float calculaMediaTAN(deposito [], int); deposito leDeposito(void){ deposito res; printf("Quanto dinheiro: "); scanf("%f", &res.dinheiro); printf("A sua TAN: "); scanf("%f", &res.tan); return res; } void leNDepositos(deposito buffer[], int n){ for(n=n-1; n>=0; --n) buffer[n]=leDeposito(); } float calculaMediaTAN(deposito buffer[], int n){ float somaTAN; int i; for(i=0; i<n; ++i) somaTAN+=buffer[i].tan; return somaTAN/i; } int main(){ deposito buffer[N]; leNDepositos(buffer, N); printf("A média das TAN é %f\n",calculaMediaTAN(buffer, N) ); return 0; }
the_stack_data/95450819.c
/** * \file * * \brief Solve a multivariable first order [ordinary differential equation * (ODEs)] using * [semi implicit Euler method] * * \details * The ODE being solved is: * \f{eqnarray*}{ * \dot{u} &=& v\\ * \dot{v} &=& -\omega^2 u\\ * \omega &=& 1\\ * [x_0, u_0, v_0] &=& [0,1,0]\qquad\ldots\text{(initial values)} * \f} * The exact solution for the above problem is: * \f{eqnarray*}{ * u(x) &=& \cos(x)\\ * v(x) &=& -\sin(x)\\ * \f} * The computation results are stored to a text file `semi_implicit_euler.csv` * and the exact soltuion results in `exact.csv` for comparison. <img * src="https://raw.githubusercontent.com/TheAlgorithms/C/docs/images/numerical_methods/ode_semi_implicit_euler.svg" * alt="Implementation solution"/> * * To implement [Van der Pol * oscillator](https://en.wikipedia.org/wiki/Van_der_Pol_oscillator), change the * ::problem function to: * ```cpp * const double mu = 2.0; * dy[0] = y[1]; * dy[1] = mu * (1.f - y[0] * y[0]) * y[1] - y[0]; * ``` * <a href="https://en.wikipedia.org/wiki/Van_der_Pol_oscillator"><img * src="https://raw.githubusercontent.com/TheAlgorithms/C/docs/images/numerical_methods/van_der_pol_implicit_euler.svg" * alt="Van der Pol Oscillator solution"/></a> * * \see ode_forward_euler.c, ode_midpoint_euler.c */ #include <math.h> #include <stdio.h> #include <stdlib.h> #include <time.h> #define order 2 /**< number of dependent variables in ::problem */ /** * @brief Problem statement for a system with first-order differential * equations. Updates the system differential variables. * \note This function can be updated to and ode of any order. * * @param[in] x independent variable(s) * @param[in,out] y dependent variable(s) * @param[in,out] dy first-derivative of dependent variable(s) */ void problem(const double *x, double *y, double *dy) { const double omega = 1.F; // some const for the problem dy[0] = y[1]; // x dot dy[1] = -omega * omega * y[0]; // y dot } /** * @brief Exact solution of the problem. Used for solution comparison. * * @param[in] x independent variable * @param[in,out] y dependent variable */ void exact_solution(const double *x, double *y) { y[0] = cos(x[0]); y[1] = -sin(x[0]); } /** * @brief Compute next step approximation using the semi-implicit-Euler * method. * @param[in] dx step size * @param[in,out] x take @f$x_n@f$ and compute @f$x_{n+1}@f$ * @param[in,out] y take @f$y_n@f$ and compute @f$y_{n+1}@f$ * @param[in,out] dy compute @f$y_n+\frac{1}{2}dx\,f\left(x_n,y_n\right)@f$ */ void semi_implicit_euler_step(double dx, double *x, double *y, double *dy) { int o; problem(x, y, dy); // update dy once y[0] += dx * dy[0]; // update y0 problem(x, y, dy); // update dy once more for (o = 1; o < order; o++) y[o] += dx * dy[o]; // update remaining using new dy *x += dx; } /** * @brief Compute approximation using the semi-implicit-Euler * method in the given limits. * @param[in] dx step size * @param[in] x0 initial value of independent variable * @param[in] x_max final value of independent variable * @param[in,out] y take \f$y_n\f$ and compute \f$y_{n+1}\f$ * @param[in] save_to_file flag to save results to a CSV file (1) or not (0) * @returns time taken for computation in seconds */ double semi_implicit_euler(double dx, double x0, double x_max, double *y, char save_to_file) { double dy[order]; FILE *fp = NULL; if (save_to_file) { fp = fopen("semi_implicit_euler.csv", "w+"); if (fp == NULL) { perror("Error! "); return -1; } } /* start integration */ clock_t t1 = clock(); double x = x0; do // iterate for each step of independent variable { if (save_to_file && fp) fprintf(fp, "%.4g,%.4g,%.4g\n", x, y[0], y[1]); // write to file semi_implicit_euler_step(dx, &x, y, dy); // perform integration x += dx; // update step } while (x <= x_max); // till upper limit of independent variable /* end of integration */ clock_t t2 = clock(); if (save_to_file && fp) fclose(fp); return (double)(t2 - t1) / CLOCKS_PER_SEC; } /** Main Function */ int main(int argc, char *argv[]) { double X0 = 0.f; /* initial value of x0 */ double X_MAX = 10.F; /* upper limit of integration */ double Y0[] = {1.f, 0.f}; /* initial value Y = y(x = x_0) */ double step_size; if (argc == 1) { printf("\nEnter the step size: "); scanf("%lg", &step_size); } else // use commandline argument as independent variable step size step_size = atof(argv[1]); // get approximate solution double total_time = semi_implicit_euler(step_size, X0, X_MAX, Y0, 1); printf("\tTime = %.6g ms\n", total_time); /* compute exact solution for comparion */ FILE *fp = fopen("exact.csv", "w+"); if (fp == NULL) { perror("Error! "); return -1; } double x = X0; double *y = &(Y0[0]); printf("Finding exact solution\n"); clock_t t1 = clock(); do { fprintf(fp, "%.4g,%.4g,%.4g\n", x, y[0], y[1]); // write to file exact_solution(&x, y); x += step_size; } while (x <= X_MAX); clock_t t2 = clock(); total_time = (t2 - t1) / CLOCKS_PER_SEC; printf("\tTime = %.6g ms\n", total_time); fclose(fp); return 0; }
the_stack_data/215769115.c
/*------------------------------------------------------------------------------ # # @author Alexander Zoellner # @date 2019/07/21 # @mail zoellner.contact<at>gmail.com # @file Makefile # # @brief Makefile for building Linux user space application for # demonstrating interrupts. # #-----------------------------------------------------------------------------*/ #include <stdlib.h> #include <stdio.h> #include <unistd.h> #include <fcntl.h> #include <sys/ioctl.h> enum TIMER_CMDS { TIMER_CFG = 0, TIMER_START = 1, TIMER_STOP = 2, TIMER_DEBUG = 3 }; int main(int argc, char* argv[]) { int fs; fs = open("/dev/timer_dev", O_RDONLY); if (fs < 0) return -1; // Configure timer ioctl(fs, TIMER_CFG, NULL); // Check if timer has been configured (dmesg) ioctl(fs, TIMER_DEBUG, NULL); // Start timer ioctl(fs, TIMER_START, NULL); close(fs); return 0; }
the_stack_data/139811.c
/*10696 - f91*/ #include <stdio.h> int main(){ int num, f; while(scanf("%d", &num) != EOF){ if(num==0){ break; } if(num>=101){ f= num-10; } else{ f=91; } printf("f91(%d) = %d\n",num, f); } return 0; }
the_stack_data/82948956.c
#include <assert.h> #include <stdlib.h> typedef struct st { struct st *next; struct st *prev; int data; } st_t; st_t dummy; void func(st_t *p) { assert(p != NULL); assert(p != &dummy); assert(p->prev != NULL); assert(p->prev != &dummy); assert(p->next != NULL); assert(p->next != &dummy); assert(p->prev->prev == NULL); assert(p->prev->next == NULL); assert(p->next->prev == NULL); assert(p->next->next == NULL); }
the_stack_data/76700156.c
/** * @file main.c * @author Matthew Stroble ([email protected]) * @brief Format specifiers * @version 0.1 * @date 2021-01-26 * * @copyright Copyright (c) 2021 * */ #include <stdio.h> int main() { _Bool var = 1; int sum = 99; double num = 5.255555; char charVal = 'C'; printf("The sum is %d\n The character is %c\n", sum, charVal); printf("Using print to round %.2f\n", num); return 0; }
the_stack_data/1000539.c
/* * Source: man 2 signalfd */ #include <sys/signalfd.h> #include <signal.h> #include <unistd.h> #include <stdlib.h> #include <stdio.h> #define handle_error(msg) \ do { perror(msg); exit(EXIT_FAILURE); } while (0) int main(int argc, char *argv[]) { sigset_t mask; int sfd; struct signalfd_siginfo fdsi; ssize_t s; sigemptyset(&mask); sigaddset(&mask, SIGINT); sigaddset(&mask, SIGQUIT); /* Block signals so that they aren't handled according to their default dispositions */ if (sigprocmask(SIG_BLOCK, &mask, NULL) == -1) handle_error("sigprocmask"); sfd = signalfd(-1, &mask, 0); if (sfd == -1) handle_error("signalfd"); for (;;) { s = read(sfd, &fdsi, sizeof(struct signalfd_siginfo)); if (s != sizeof(struct signalfd_siginfo)) handle_error("read"); if (fdsi.ssi_signo == SIGINT) { printf("Got SIGINT\n"); } else if (fdsi.ssi_signo == SIGQUIT) { printf("Got SIGQUIT\n"); exit(EXIT_SUCCESS); } else { printf("Read unexpected signal\n"); } } }
the_stack_data/151253.c
/* OPT: -print-used-types */ void _start() { int a, b; b = a > 5 ? 0 : 1; }
the_stack_data/75137231.c
/* udp_server.c */ #include <stdio.h> #include <stdlib.h> #include <errno.h> #include <string.h> #include <sys/types.h> #include <netinet/in.h> #include <sys/socket.h> #include <arpa/inet.h> #include <sys/wait.h> #define PORT 2000 /* 서버 포트 */ #define BACKLOG 10 #define MAXBUF 100 int main() { int sock; struct sockaddr_in serv_addr; struct sockaddr_in clnt_addr; int clnt_addr_len; char buf[MAXBUF]; int sin_size; /* 서버 소켓 생성 */ if ((sock = socket(AF_INET, SOCK_DGRAM, 0))== -1) { perror("socket"); exit(1); } /* 서버 포트 설정 */ memset(&serv_addr, 0, sizeof(serv_addr)); serv_addr.sin_family = AF_INET; serv_addr.sin_port = htons(PORT); serv_addr.sin_addr.s_addr = INADDR_ANY; if (bind(sock, (struct sockaddr *) &serv_addr, sizeof(struct sockaddr)) == -1) { perror("bind"); exit(1); } while (1) { /* 클라이언트 요구 처리 */ /* 메시지 수신 */ clnt_addr_len = sizeof(clnt_addr); memset(buf, 0, MAXBUF); if (recvfrom(sock, buf, MAXBUF, 0, (struct sockaddr *) &clnt_addr, &clnt_addr_len) == -1) { perror("recv"); exit(0); } printf("server: got connection from %s\n", inet_ntoa(clnt_addr.sin_addr)); /* 메시지 송신 */ if (sendto (sock, buf, strlen(buf), 0, (struct sockaddr *) &clnt_addr, sizeof(clnt_addr)) == -1) { perror("send"); close(sock); exit(0); } } return 0; }
the_stack_data/32230.c
#include <stdio.h> void main(void) { int i,rem,s=0,n; printf("enter the number \n : "); scanf("%d",&n); i=n; for ( i = n; i > 0;) { rem = i % 10; s = s *10 + rem ; i = i/10; } printf("The reverse of %d is %d \n",i,s); }
the_stack_data/926728.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 laurent on Tue Dec 22 14:57:52 2009 */ /*****************************************************/ /* This file was automatically generated by Ocarina */ /* Do NOT hand-modify this file, as your */ /* changes will be lost when you re-run Ocarina */ /*****************************************************/
the_stack_data/15576.c
// // Created by zhangrongxiang on 2017/9/27 16:23 // File 7 // #include <pthread.h> #include <semaphore.h> #include <unistd.h> #include <stdio.h> #include <stdlib.h> /* @Scene: 某行业营业厅同时只能服务两个顾客。 * 有多个顾客到来,每个顾客如果发现服务窗口已满,就等待, * 如果有可用的服务窗口,就接受服务。 */ /* 将信号量定义为全局变量,方便多个线程共享 */ sem_t sem; /* 每个线程要运行的例程 */ void *get_service(void *thread_id) { /* 注意:立即保存thread_id的值,因为thread_id是对主线程中循环变量i的引用,它可能马上被修改 */ int customer_id = *((int *) thread_id); if (sem_wait(&sem) == 0) { //sleep(1); /* service time: 100ms */ printf("Producer %d receive service ...\n", customer_id); sem_post(&sem); } } #define CUSTOMER_NUM 1000 int main(int argc, char *argv[]) { /* 初始化信号量,初始值为2,表示有两个顾客可以同时接收服务 */ /* @prototype: int sem_init(sem_t *sem, int pshared, unsigned int value); */ /* pshared: if pshared == 0, the semaphore is shared among threads of a process * otherwise the semaphore is shared between processes. */ sem_init(&sem, 0, 1); /* 为每个顾客定义一个线程id, pthread_t 其实是unsigned long int */ pthread_t customers[CUSTOMER_NUM]; int i, ret; /* 为每个顾客生成一个线程 */ for (i = 1; i < CUSTOMER_NUM; i++) { int customer_id = i; ret = pthread_create(&customers[i], NULL, get_service, &customer_id); if (ret != 0) { perror("pthread_create"); exit(1); } else { printf("Customer %d arrived.\n", i); } //sleep(1); } /* 等待所有顾客的线程结束 */ /* 注意:这地方不能再用i做循环变量,因为可能线程中正在访问i的值 */ int j; for (j = 1; j < CUSTOMER_NUM; j++) { pthread_join(customers[j], NULL); } /* Only a semaphore that has been initialized by sem_init(3) * should be destroyed using sem_destroy().*/ sem_destroy(&sem); return 0; }
the_stack_data/2975.c
// KASAN: use-after-free Read in rdma_listen // https://syzkaller.appspot.com/bug?id=ff71f5beeed7a85e89d5c1589c4058ebfacbaf3c // status:open // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include <arpa/inet.h> #include <dirent.h> #include <endian.h> #include <errno.h> #include <fcntl.h> #include <net/if.h> #include <net/if_arp.h> #include <netinet/in.h> #include <pthread.h> #include <sched.h> #include <setjmp.h> #include <signal.h> #include <stdarg.h> #include <stdbool.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/ioctl.h> #include <sys/mount.h> #include <sys/prctl.h> #include <sys/resource.h> #include <sys/socket.h> #include <sys/stat.h> #include <sys/syscall.h> #include <sys/time.h> #include <sys/types.h> #include <sys/uio.h> #include <sys/wait.h> #include <time.h> #include <unistd.h> #include <linux/futex.h> #include <linux/if_addr.h> #include <linux/if_ether.h> #include <linux/if_link.h> #include <linux/if_tun.h> #include <linux/in6.h> #include <linux/ip.h> #include <linux/neighbour.h> #include <linux/net.h> #include <linux/netlink.h> #include <linux/rtnetlink.h> #include <linux/tcp.h> #include <linux/veth.h> unsigned long long procid; static __thread int skip_segv; static __thread jmp_buf segv_env; static void segv_handler(int sig, siginfo_t* info, void* ctx) { uintptr_t addr = (uintptr_t)info->si_addr; const uintptr_t prog_start = 1 << 20; const uintptr_t prog_end = 100 << 20; if (__atomic_load_n(&skip_segv, __ATOMIC_RELAXED) && (addr < prog_start || addr > prog_end)) { _longjmp(segv_env, 1); } exit(sig); } static void install_segv_handler(void) { struct sigaction sa; memset(&sa, 0, sizeof(sa)); sa.sa_handler = SIG_IGN; syscall(SYS_rt_sigaction, 0x20, &sa, NULL, 8); syscall(SYS_rt_sigaction, 0x21, &sa, NULL, 8); memset(&sa, 0, sizeof(sa)); sa.sa_sigaction = segv_handler; sa.sa_flags = SA_NODEFER | SA_SIGINFO; sigaction(SIGSEGV, &sa, NULL); sigaction(SIGBUS, &sa, NULL); } #define NONFAILING(...) \ { \ __atomic_fetch_add(&skip_segv, 1, __ATOMIC_SEQ_CST); \ if (_setjmp(segv_env) == 0) { \ __VA_ARGS__; \ } \ __atomic_fetch_sub(&skip_segv, 1, __ATOMIC_SEQ_CST); \ } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i; for (i = 0; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { int state; } event_t; static void event_init(event_t* ev) { ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { if (ev->state) exit(1); __atomic_store_n(&ev->state, 1, __ATOMIC_RELEASE); syscall(SYS_futex, &ev->state, FUTEX_WAKE | FUTEX_PRIVATE_FLAG); } static void event_wait(event_t* ev) { while (!__atomic_load_n(&ev->state, __ATOMIC_ACQUIRE)) syscall(SYS_futex, &ev->state, FUTEX_WAIT | FUTEX_PRIVATE_FLAG, 0, 0); } static int event_isset(event_t* ev) { return __atomic_load_n(&ev->state, __ATOMIC_ACQUIRE); } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; for (;;) { uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; syscall(SYS_futex, &ev->state, FUTEX_WAIT | FUTEX_PRIVATE_FLAG, 0, &ts); if (__atomic_load_n(&ev->state, __ATOMIC_RELAXED)) return 1; now = current_time_ms(); if (now - start > timeout) return 0; } } static bool write_file(const char* file, const char* what, ...) { char buf[1024]; va_list args; va_start(args, what); vsnprintf(buf, sizeof(buf), what, args); va_end(args); buf[sizeof(buf) - 1] = 0; int len = strlen(buf); int fd = open(file, O_WRONLY | O_CLOEXEC); if (fd == -1) return false; if (write(fd, buf, len) != len) { int err = errno; close(fd); errno = err; return false; } close(fd); return true; } static struct { char* pos; int nesting; struct nlattr* nested[8]; char buf[1024]; } nlmsg; static void netlink_init(int typ, int flags, const void* data, int size) { memset(&nlmsg, 0, sizeof(nlmsg)); struct nlmsghdr* hdr = (struct nlmsghdr*)nlmsg.buf; hdr->nlmsg_type = typ; hdr->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK | flags; memcpy(hdr + 1, data, size); nlmsg.pos = (char*)(hdr + 1) + NLMSG_ALIGN(size); } static void netlink_attr(int typ, const void* data, int size) { struct nlattr* attr = (struct nlattr*)nlmsg.pos; attr->nla_len = sizeof(*attr) + size; attr->nla_type = typ; memcpy(attr + 1, data, size); nlmsg.pos += NLMSG_ALIGN(attr->nla_len); } static void netlink_nest(int typ) { struct nlattr* attr = (struct nlattr*)nlmsg.pos; attr->nla_type = typ; nlmsg.pos += sizeof(*attr); nlmsg.nested[nlmsg.nesting++] = attr; } static void netlink_done(void) { struct nlattr* attr = nlmsg.nested[--nlmsg.nesting]; attr->nla_len = nlmsg.pos - (char*)attr; } static int netlink_send(int sock) { if (nlmsg.pos > nlmsg.buf + sizeof(nlmsg.buf) || nlmsg.nesting) exit(1); struct nlmsghdr* hdr = (struct nlmsghdr*)nlmsg.buf; hdr->nlmsg_len = nlmsg.pos - nlmsg.buf; struct sockaddr_nl addr; memset(&addr, 0, sizeof(addr)); addr.nl_family = AF_NETLINK; unsigned n = sendto(sock, nlmsg.buf, hdr->nlmsg_len, 0, (struct sockaddr*)&addr, sizeof(addr)); if (n != hdr->nlmsg_len) exit(1); n = recv(sock, nlmsg.buf, sizeof(nlmsg.buf), 0); if (n < sizeof(struct nlmsghdr) + sizeof(struct nlmsgerr)) exit(1); if (hdr->nlmsg_type != NLMSG_ERROR) exit(1); return -((struct nlmsgerr*)(hdr + 1))->error; } static void netlink_add_device_impl(const char* type, const char* name) { struct ifinfomsg hdr; memset(&hdr, 0, sizeof(hdr)); netlink_init(RTM_NEWLINK, NLM_F_EXCL | NLM_F_CREATE, &hdr, sizeof(hdr)); if (name) netlink_attr(IFLA_IFNAME, name, strlen(name)); netlink_nest(IFLA_LINKINFO); netlink_attr(IFLA_INFO_KIND, type, strlen(type)); } static void netlink_add_device(int sock, const char* type, const char* name) { netlink_add_device_impl(type, name); netlink_done(); int err = netlink_send(sock); (void)err; } static void netlink_add_veth(int sock, const char* name, const char* peer) { netlink_add_device_impl("veth", name); netlink_nest(IFLA_INFO_DATA); netlink_nest(VETH_INFO_PEER); nlmsg.pos += sizeof(struct ifinfomsg); netlink_attr(IFLA_IFNAME, peer, strlen(peer)); netlink_done(); netlink_done(); netlink_done(); int err = netlink_send(sock); (void)err; } static void netlink_add_hsr(int sock, const char* name, const char* slave1, const char* slave2) { netlink_add_device_impl("hsr", name); netlink_nest(IFLA_INFO_DATA); int ifindex1 = if_nametoindex(slave1); netlink_attr(IFLA_HSR_SLAVE1, &ifindex1, sizeof(ifindex1)); int ifindex2 = if_nametoindex(slave2); netlink_attr(IFLA_HSR_SLAVE2, &ifindex2, sizeof(ifindex2)); netlink_done(); netlink_done(); int err = netlink_send(sock); (void)err; } static void netlink_device_change(int sock, const char* name, bool up, const char* master, const void* mac, int macsize) { struct ifinfomsg hdr; memset(&hdr, 0, sizeof(hdr)); if (up) hdr.ifi_flags = hdr.ifi_change = IFF_UP; netlink_init(RTM_NEWLINK, 0, &hdr, sizeof(hdr)); netlink_attr(IFLA_IFNAME, name, strlen(name)); if (master) { int ifindex = if_nametoindex(master); netlink_attr(IFLA_MASTER, &ifindex, sizeof(ifindex)); } if (macsize) netlink_attr(IFLA_ADDRESS, mac, macsize); int err = netlink_send(sock); (void)err; } static int netlink_add_addr(int sock, const char* dev, const void* addr, int addrsize) { struct ifaddrmsg hdr; memset(&hdr, 0, sizeof(hdr)); hdr.ifa_family = addrsize == 4 ? AF_INET : AF_INET6; hdr.ifa_prefixlen = addrsize == 4 ? 24 : 120; hdr.ifa_scope = RT_SCOPE_UNIVERSE; hdr.ifa_index = if_nametoindex(dev); netlink_init(RTM_NEWADDR, NLM_F_CREATE | NLM_F_REPLACE, &hdr, sizeof(hdr)); netlink_attr(IFA_LOCAL, addr, addrsize); netlink_attr(IFA_ADDRESS, addr, addrsize); return netlink_send(sock); } static void netlink_add_addr4(int sock, const char* dev, const char* addr) { struct in_addr in_addr; inet_pton(AF_INET, addr, &in_addr); int err = netlink_add_addr(sock, dev, &in_addr, sizeof(in_addr)); (void)err; } static void netlink_add_addr6(int sock, const char* dev, const char* addr) { struct in6_addr in6_addr; inet_pton(AF_INET6, addr, &in6_addr); int err = netlink_add_addr(sock, dev, &in6_addr, sizeof(in6_addr)); (void)err; } static void netlink_add_neigh(int sock, const char* name, const void* addr, int addrsize, const void* mac, int macsize) { struct ndmsg hdr; memset(&hdr, 0, sizeof(hdr)); hdr.ndm_family = addrsize == 4 ? AF_INET : AF_INET6; hdr.ndm_ifindex = if_nametoindex(name); hdr.ndm_state = NUD_PERMANENT; netlink_init(RTM_NEWNEIGH, NLM_F_EXCL | NLM_F_CREATE, &hdr, sizeof(hdr)); netlink_attr(NDA_DST, addr, addrsize); netlink_attr(NDA_LLADDR, mac, macsize); int err = netlink_send(sock); (void)err; } static int tunfd = -1; static int tun_frags_enabled; #define SYZ_TUN_MAX_PACKET_SIZE 1000 #define TUN_IFACE "syz_tun" #define LOCAL_MAC 0xaaaaaaaaaaaa #define REMOTE_MAC 0xaaaaaaaaaabb #define LOCAL_IPV4 "172.20.20.170" #define REMOTE_IPV4 "172.20.20.187" #define LOCAL_IPV6 "fe80::aa" #define REMOTE_IPV6 "fe80::bb" #define IFF_NAPI 0x0010 #define IFF_NAPI_FRAGS 0x0020 static void initialize_tun(void) { tunfd = open("/dev/net/tun", O_RDWR | O_NONBLOCK); if (tunfd == -1) { printf("tun: can't open /dev/net/tun: please enable CONFIG_TUN=y\n"); printf("otherwise fuzzing or reproducing might not work as intended\n"); return; } const int kTunFd = 240; if (dup2(tunfd, kTunFd) < 0) exit(1); close(tunfd); tunfd = kTunFd; struct ifreq ifr; memset(&ifr, 0, sizeof(ifr)); strncpy(ifr.ifr_name, TUN_IFACE, IFNAMSIZ); ifr.ifr_flags = IFF_TAP | IFF_NO_PI | IFF_NAPI | IFF_NAPI_FRAGS; if (ioctl(tunfd, TUNSETIFF, (void*)&ifr) < 0) { ifr.ifr_flags = IFF_TAP | IFF_NO_PI; if (ioctl(tunfd, TUNSETIFF, (void*)&ifr) < 0) exit(1); } if (ioctl(tunfd, TUNGETIFF, (void*)&ifr) < 0) exit(1); tun_frags_enabled = (ifr.ifr_flags & IFF_NAPI_FRAGS) != 0; char sysctl[64]; sprintf(sysctl, "/proc/sys/net/ipv6/conf/%s/accept_dad", TUN_IFACE); write_file(sysctl, "0"); sprintf(sysctl, "/proc/sys/net/ipv6/conf/%s/router_solicitations", TUN_IFACE); write_file(sysctl, "0"); int sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); if (sock == -1) exit(1); netlink_add_addr4(sock, TUN_IFACE, LOCAL_IPV4); netlink_add_addr6(sock, TUN_IFACE, LOCAL_IPV6); uint64_t macaddr = REMOTE_MAC; struct in_addr in_addr; inet_pton(AF_INET, REMOTE_IPV4, &in_addr); netlink_add_neigh(sock, TUN_IFACE, &in_addr, sizeof(in_addr), &macaddr, ETH_ALEN); struct in6_addr in6_addr; inet_pton(AF_INET6, REMOTE_IPV6, &in6_addr); netlink_add_neigh(sock, TUN_IFACE, &in6_addr, sizeof(in6_addr), &macaddr, ETH_ALEN); macaddr = LOCAL_MAC; netlink_device_change(sock, TUN_IFACE, true, 0, &macaddr, ETH_ALEN); close(sock); } #define DEV_IPV4 "172.20.20.%d" #define DEV_IPV6 "fe80::%02x" #define DEV_MAC 0x00aaaaaaaaaa static void initialize_netdevices(void) { char netdevsim[16]; sprintf(netdevsim, "netdevsim%d", (int)procid); struct { const char* type; const char* dev; } devtypes[] = { {"ip6gretap", "ip6gretap0"}, {"bridge", "bridge0"}, {"vcan", "vcan0"}, {"bond", "bond0"}, {"team", "team0"}, {"dummy", "dummy0"}, {"nlmon", "nlmon0"}, {"caif", "caif0"}, {"batadv", "batadv0"}, {"vxcan", "vxcan1"}, {"netdevsim", netdevsim}, {"veth", 0}, }; const char* devmasters[] = {"bridge", "bond", "team"}; struct { const char* name; int macsize; bool noipv6; } devices[] = { {"lo", ETH_ALEN}, {"sit0", 0}, {"bridge0", ETH_ALEN}, {"vcan0", 0, true}, {"tunl0", 0}, {"gre0", 0}, {"gretap0", ETH_ALEN}, {"ip_vti0", 0}, {"ip6_vti0", 0}, {"ip6tnl0", 0}, {"ip6gre0", 0}, {"ip6gretap0", ETH_ALEN}, {"erspan0", ETH_ALEN}, {"bond0", ETH_ALEN}, {"veth0", ETH_ALEN}, {"veth1", ETH_ALEN}, {"team0", ETH_ALEN}, {"veth0_to_bridge", ETH_ALEN}, {"veth1_to_bridge", ETH_ALEN}, {"veth0_to_bond", ETH_ALEN}, {"veth1_to_bond", ETH_ALEN}, {"veth0_to_team", ETH_ALEN}, {"veth1_to_team", ETH_ALEN}, {"veth0_to_hsr", ETH_ALEN}, {"veth1_to_hsr", ETH_ALEN}, {"hsr0", 0}, {"dummy0", ETH_ALEN}, {"nlmon0", 0}, {"vxcan1", 0, true}, {"caif0", ETH_ALEN}, {"batadv0", ETH_ALEN}, {netdevsim, ETH_ALEN}, }; int sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); if (sock == -1) exit(1); unsigned i; for (i = 0; i < sizeof(devtypes) / sizeof(devtypes[0]); i++) netlink_add_device(sock, devtypes[i].type, devtypes[i].dev); for (i = 0; i < sizeof(devmasters) / (sizeof(devmasters[0])); i++) { char master[32], slave0[32], veth0[32], slave1[32], veth1[32]; sprintf(slave0, "%s_slave_0", devmasters[i]); sprintf(veth0, "veth0_to_%s", devmasters[i]); netlink_add_veth(sock, slave0, veth0); sprintf(slave1, "%s_slave_1", devmasters[i]); sprintf(veth1, "veth1_to_%s", devmasters[i]); netlink_add_veth(sock, slave1, veth1); sprintf(master, "%s0", devmasters[i]); netlink_device_change(sock, slave0, false, master, 0, 0); netlink_device_change(sock, slave1, false, master, 0, 0); } netlink_device_change(sock, "bridge_slave_0", true, 0, 0, 0); netlink_device_change(sock, "bridge_slave_1", true, 0, 0, 0); netlink_add_veth(sock, "hsr_slave_0", "veth0_to_hsr"); netlink_add_veth(sock, "hsr_slave_1", "veth1_to_hsr"); netlink_add_hsr(sock, "hsr0", "hsr_slave_0", "hsr_slave_1"); netlink_device_change(sock, "hsr_slave_0", true, 0, 0, 0); netlink_device_change(sock, "hsr_slave_1", true, 0, 0, 0); for (i = 0; i < sizeof(devices) / (sizeof(devices[0])); i++) { char addr[32]; sprintf(addr, DEV_IPV4, i + 10); netlink_add_addr4(sock, devices[i].name, addr); if (!devices[i].noipv6) { sprintf(addr, DEV_IPV6, i + 10); netlink_add_addr6(sock, devices[i].name, addr); } uint64_t macaddr = DEV_MAC + ((i + 10ull) << 40); netlink_device_change(sock, devices[i].name, true, 0, &macaddr, devices[i].macsize); } close(sock); } static void initialize_netdevices_init(void) { int sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); if (sock == -1) exit(1); struct { const char* type; int macsize; bool noipv6; bool noup; } devtypes[] = { {"nr", 7, true}, {"rose", 5, true, true}, }; unsigned i; for (i = 0; i < sizeof(devtypes) / sizeof(devtypes[0]); i++) { char dev[32], addr[32]; sprintf(dev, "%s%d", devtypes[i].type, (int)procid); sprintf(addr, "172.30.%d.%d", i, (int)procid + 1); netlink_add_addr4(sock, dev, addr); if (!devtypes[i].noipv6) { sprintf(addr, "fe88::%02x:%02x", i, (int)procid + 1); netlink_add_addr6(sock, dev, addr); } int macsize = devtypes[i].macsize; uint64_t macaddr = 0xbbbbbb + ((unsigned long long)i << (8 * (macsize - 2))) + (procid << (8 * (macsize - 1))); netlink_device_change(sock, dev, !devtypes[i].noup, 0, &macaddr, macsize); } close(sock); } static int read_tun(char* data, int size) { if (tunfd < 0) return -1; int rv = read(tunfd, data, size); if (rv < 0) { if (errno == EAGAIN) return -1; if (errno == EBADFD) return -1; exit(1); } return rv; } static void flush_tun() { char data[SYZ_TUN_MAX_PACKET_SIZE]; while (read_tun(&data[0], sizeof(data)) != -1) { } } #define XT_TABLE_SIZE 1536 #define XT_MAX_ENTRIES 10 struct xt_counters { uint64_t pcnt, bcnt; }; struct ipt_getinfo { char name[32]; unsigned int valid_hooks; unsigned int hook_entry[5]; unsigned int underflow[5]; unsigned int num_entries; unsigned int size; }; struct ipt_get_entries { char name[32]; unsigned int size; void* entrytable[XT_TABLE_SIZE / sizeof(void*)]; }; struct ipt_replace { char name[32]; unsigned int valid_hooks; unsigned int num_entries; unsigned int size; unsigned int hook_entry[5]; unsigned int underflow[5]; unsigned int num_counters; struct xt_counters* counters; char entrytable[XT_TABLE_SIZE]; }; struct ipt_table_desc { const char* name; struct ipt_getinfo info; struct ipt_replace replace; }; static struct ipt_table_desc ipv4_tables[] = { {.name = "filter"}, {.name = "nat"}, {.name = "mangle"}, {.name = "raw"}, {.name = "security"}, }; static struct ipt_table_desc ipv6_tables[] = { {.name = "filter"}, {.name = "nat"}, {.name = "mangle"}, {.name = "raw"}, {.name = "security"}, }; #define IPT_BASE_CTL 64 #define IPT_SO_SET_REPLACE (IPT_BASE_CTL) #define IPT_SO_GET_INFO (IPT_BASE_CTL) #define IPT_SO_GET_ENTRIES (IPT_BASE_CTL + 1) struct arpt_getinfo { char name[32]; unsigned int valid_hooks; unsigned int hook_entry[3]; unsigned int underflow[3]; unsigned int num_entries; unsigned int size; }; struct arpt_get_entries { char name[32]; unsigned int size; void* entrytable[XT_TABLE_SIZE / sizeof(void*)]; }; struct arpt_replace { char name[32]; unsigned int valid_hooks; unsigned int num_entries; unsigned int size; unsigned int hook_entry[3]; unsigned int underflow[3]; unsigned int num_counters; struct xt_counters* counters; char entrytable[XT_TABLE_SIZE]; }; struct arpt_table_desc { const char* name; struct arpt_getinfo info; struct arpt_replace replace; }; static struct arpt_table_desc arpt_tables[] = { {.name = "filter"}, }; #define ARPT_BASE_CTL 96 #define ARPT_SO_SET_REPLACE (ARPT_BASE_CTL) #define ARPT_SO_GET_INFO (ARPT_BASE_CTL) #define ARPT_SO_GET_ENTRIES (ARPT_BASE_CTL + 1) static void checkpoint_iptables(struct ipt_table_desc* tables, int num_tables, int family, int level) { struct ipt_get_entries entries; socklen_t optlen; int fd, i; fd = socket(family, SOCK_STREAM, IPPROTO_TCP); if (fd == -1) { switch (errno) { case EAFNOSUPPORT: case ENOPROTOOPT: return; } exit(1); } for (i = 0; i < num_tables; i++) { struct ipt_table_desc* table = &tables[i]; strcpy(table->info.name, table->name); strcpy(table->replace.name, table->name); optlen = sizeof(table->info); if (getsockopt(fd, level, IPT_SO_GET_INFO, &table->info, &optlen)) { switch (errno) { case EPERM: case ENOENT: case ENOPROTOOPT: continue; } exit(1); } if (table->info.size > sizeof(table->replace.entrytable)) exit(1); if (table->info.num_entries > XT_MAX_ENTRIES) exit(1); memset(&entries, 0, sizeof(entries)); strcpy(entries.name, table->name); entries.size = table->info.size; optlen = sizeof(entries) - sizeof(entries.entrytable) + table->info.size; if (getsockopt(fd, level, IPT_SO_GET_ENTRIES, &entries, &optlen)) exit(1); table->replace.valid_hooks = table->info.valid_hooks; table->replace.num_entries = table->info.num_entries; table->replace.size = table->info.size; memcpy(table->replace.hook_entry, table->info.hook_entry, sizeof(table->replace.hook_entry)); memcpy(table->replace.underflow, table->info.underflow, sizeof(table->replace.underflow)); memcpy(table->replace.entrytable, entries.entrytable, table->info.size); } close(fd); } static void reset_iptables(struct ipt_table_desc* tables, int num_tables, int family, int level) { struct xt_counters counters[XT_MAX_ENTRIES]; struct ipt_get_entries entries; struct ipt_getinfo info; socklen_t optlen; int fd, i; fd = socket(family, SOCK_STREAM, IPPROTO_TCP); if (fd == -1) { switch (errno) { case EAFNOSUPPORT: case ENOPROTOOPT: return; } exit(1); } for (i = 0; i < num_tables; i++) { struct ipt_table_desc* table = &tables[i]; if (table->info.valid_hooks == 0) continue; memset(&info, 0, sizeof(info)); strcpy(info.name, table->name); optlen = sizeof(info); if (getsockopt(fd, level, IPT_SO_GET_INFO, &info, &optlen)) exit(1); if (memcmp(&table->info, &info, sizeof(table->info)) == 0) { memset(&entries, 0, sizeof(entries)); strcpy(entries.name, table->name); entries.size = table->info.size; optlen = sizeof(entries) - sizeof(entries.entrytable) + entries.size; if (getsockopt(fd, level, IPT_SO_GET_ENTRIES, &entries, &optlen)) exit(1); if (memcmp(table->replace.entrytable, entries.entrytable, table->info.size) == 0) continue; } table->replace.num_counters = info.num_entries; table->replace.counters = counters; optlen = sizeof(table->replace) - sizeof(table->replace.entrytable) + table->replace.size; if (setsockopt(fd, level, IPT_SO_SET_REPLACE, &table->replace, optlen)) exit(1); } close(fd); } static void checkpoint_arptables(void) { struct arpt_get_entries entries; socklen_t optlen; unsigned i; int fd; fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (fd == -1) { switch (errno) { case EAFNOSUPPORT: case ENOPROTOOPT: return; } exit(1); } for (i = 0; i < sizeof(arpt_tables) / sizeof(arpt_tables[0]); i++) { struct arpt_table_desc* table = &arpt_tables[i]; strcpy(table->info.name, table->name); strcpy(table->replace.name, table->name); optlen = sizeof(table->info); if (getsockopt(fd, SOL_IP, ARPT_SO_GET_INFO, &table->info, &optlen)) { switch (errno) { case EPERM: case ENOENT: case ENOPROTOOPT: continue; } exit(1); } if (table->info.size > sizeof(table->replace.entrytable)) exit(1); if (table->info.num_entries > XT_MAX_ENTRIES) exit(1); memset(&entries, 0, sizeof(entries)); strcpy(entries.name, table->name); entries.size = table->info.size; optlen = sizeof(entries) - sizeof(entries.entrytable) + table->info.size; if (getsockopt(fd, SOL_IP, ARPT_SO_GET_ENTRIES, &entries, &optlen)) exit(1); table->replace.valid_hooks = table->info.valid_hooks; table->replace.num_entries = table->info.num_entries; table->replace.size = table->info.size; memcpy(table->replace.hook_entry, table->info.hook_entry, sizeof(table->replace.hook_entry)); memcpy(table->replace.underflow, table->info.underflow, sizeof(table->replace.underflow)); memcpy(table->replace.entrytable, entries.entrytable, table->info.size); } close(fd); } static void reset_arptables() { struct xt_counters counters[XT_MAX_ENTRIES]; struct arpt_get_entries entries; struct arpt_getinfo info; socklen_t optlen; unsigned i; int fd; fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (fd == -1) { switch (errno) { case EAFNOSUPPORT: case ENOPROTOOPT: return; } exit(1); } for (i = 0; i < sizeof(arpt_tables) / sizeof(arpt_tables[0]); i++) { struct arpt_table_desc* table = &arpt_tables[i]; if (table->info.valid_hooks == 0) continue; memset(&info, 0, sizeof(info)); strcpy(info.name, table->name); optlen = sizeof(info); if (getsockopt(fd, SOL_IP, ARPT_SO_GET_INFO, &info, &optlen)) exit(1); if (memcmp(&table->info, &info, sizeof(table->info)) == 0) { memset(&entries, 0, sizeof(entries)); strcpy(entries.name, table->name); entries.size = table->info.size; optlen = sizeof(entries) - sizeof(entries.entrytable) + entries.size; if (getsockopt(fd, SOL_IP, ARPT_SO_GET_ENTRIES, &entries, &optlen)) exit(1); if (memcmp(table->replace.entrytable, entries.entrytable, table->info.size) == 0) continue; } else { } table->replace.num_counters = info.num_entries; table->replace.counters = counters; optlen = sizeof(table->replace) - sizeof(table->replace.entrytable) + table->replace.size; if (setsockopt(fd, SOL_IP, ARPT_SO_SET_REPLACE, &table->replace, optlen)) exit(1); } close(fd); } #define NF_BR_NUMHOOKS 6 #define EBT_TABLE_MAXNAMELEN 32 #define EBT_CHAIN_MAXNAMELEN 32 #define EBT_BASE_CTL 128 #define EBT_SO_SET_ENTRIES (EBT_BASE_CTL) #define EBT_SO_GET_INFO (EBT_BASE_CTL) #define EBT_SO_GET_ENTRIES (EBT_SO_GET_INFO + 1) #define EBT_SO_GET_INIT_INFO (EBT_SO_GET_ENTRIES + 1) #define EBT_SO_GET_INIT_ENTRIES (EBT_SO_GET_INIT_INFO + 1) struct ebt_replace { char name[EBT_TABLE_MAXNAMELEN]; unsigned int valid_hooks; unsigned int nentries; unsigned int entries_size; struct ebt_entries* hook_entry[NF_BR_NUMHOOKS]; unsigned int num_counters; struct ebt_counter* counters; char* entries; }; struct ebt_entries { unsigned int distinguisher; char name[EBT_CHAIN_MAXNAMELEN]; unsigned int counter_offset; int policy; unsigned int nentries; char data[0] __attribute__((aligned(__alignof__(struct ebt_replace)))); }; struct ebt_table_desc { const char* name; struct ebt_replace replace; char entrytable[XT_TABLE_SIZE]; }; static struct ebt_table_desc ebt_tables[] = { {.name = "filter"}, {.name = "nat"}, {.name = "broute"}, }; static void checkpoint_ebtables(void) { socklen_t optlen; unsigned i; int fd; fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (fd == -1) { switch (errno) { case EAFNOSUPPORT: case ENOPROTOOPT: return; } exit(1); } for (i = 0; i < sizeof(ebt_tables) / sizeof(ebt_tables[0]); i++) { struct ebt_table_desc* table = &ebt_tables[i]; strcpy(table->replace.name, table->name); optlen = sizeof(table->replace); if (getsockopt(fd, SOL_IP, EBT_SO_GET_INIT_INFO, &table->replace, &optlen)) { switch (errno) { case EPERM: case ENOENT: case ENOPROTOOPT: continue; } exit(1); } if (table->replace.entries_size > sizeof(table->entrytable)) exit(1); table->replace.num_counters = 0; table->replace.entries = table->entrytable; optlen = sizeof(table->replace) + table->replace.entries_size; if (getsockopt(fd, SOL_IP, EBT_SO_GET_INIT_ENTRIES, &table->replace, &optlen)) exit(1); } close(fd); } static void reset_ebtables() { struct ebt_replace replace; char entrytable[XT_TABLE_SIZE]; socklen_t optlen; unsigned i, j, h; int fd; fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (fd == -1) { switch (errno) { case EAFNOSUPPORT: case ENOPROTOOPT: return; } exit(1); } for (i = 0; i < sizeof(ebt_tables) / sizeof(ebt_tables[0]); i++) { struct ebt_table_desc* table = &ebt_tables[i]; if (table->replace.valid_hooks == 0) continue; memset(&replace, 0, sizeof(replace)); strcpy(replace.name, table->name); optlen = sizeof(replace); if (getsockopt(fd, SOL_IP, EBT_SO_GET_INFO, &replace, &optlen)) exit(1); replace.num_counters = 0; table->replace.entries = 0; for (h = 0; h < NF_BR_NUMHOOKS; h++) table->replace.hook_entry[h] = 0; if (memcmp(&table->replace, &replace, sizeof(table->replace)) == 0) { memset(&entrytable, 0, sizeof(entrytable)); replace.entries = entrytable; optlen = sizeof(replace) + replace.entries_size; if (getsockopt(fd, SOL_IP, EBT_SO_GET_ENTRIES, &replace, &optlen)) exit(1); if (memcmp(table->entrytable, entrytable, replace.entries_size) == 0) continue; } for (j = 0, h = 0; h < NF_BR_NUMHOOKS; h++) { if (table->replace.valid_hooks & (1 << h)) { table->replace.hook_entry[h] = (struct ebt_entries*)table->entrytable + j; j++; } } table->replace.entries = table->entrytable; optlen = sizeof(table->replace) + table->replace.entries_size; if (setsockopt(fd, SOL_IP, EBT_SO_SET_ENTRIES, &table->replace, optlen)) exit(1); } close(fd); } static void checkpoint_net_namespace(void) { checkpoint_ebtables(); checkpoint_arptables(); checkpoint_iptables(ipv4_tables, sizeof(ipv4_tables) / sizeof(ipv4_tables[0]), AF_INET, SOL_IP); checkpoint_iptables(ipv6_tables, sizeof(ipv6_tables) / sizeof(ipv6_tables[0]), AF_INET6, SOL_IPV6); } static void reset_net_namespace(void) { reset_ebtables(); reset_arptables(); reset_iptables(ipv4_tables, sizeof(ipv4_tables) / sizeof(ipv4_tables[0]), AF_INET, SOL_IP); reset_iptables(ipv6_tables, sizeof(ipv6_tables) / sizeof(ipv6_tables[0]), AF_INET6, SOL_IPV6); } static void setup_cgroups() { if (mkdir("/syzcgroup", 0777)) { } if (mkdir("/syzcgroup/unified", 0777)) { } if (mount("none", "/syzcgroup/unified", "cgroup2", 0, NULL)) { } if (chmod("/syzcgroup/unified", 0777)) { } write_file("/syzcgroup/unified/cgroup.subtree_control", "+cpu +memory +io +pids +rdma"); if (mkdir("/syzcgroup/cpu", 0777)) { } if (mount("none", "/syzcgroup/cpu", "cgroup", 0, "cpuset,cpuacct,perf_event,hugetlb")) { } write_file("/syzcgroup/cpu/cgroup.clone_children", "1"); if (chmod("/syzcgroup/cpu", 0777)) { } if (mkdir("/syzcgroup/net", 0777)) { } if (mount("none", "/syzcgroup/net", "cgroup", 0, "net_cls,net_prio,devices,freezer")) { } if (chmod("/syzcgroup/net", 0777)) { } } static void setup_cgroups_loop() { int pid = getpid(); char file[128]; char cgroupdir[64]; snprintf(cgroupdir, sizeof(cgroupdir), "/syzcgroup/unified/syz%llu", procid); if (mkdir(cgroupdir, 0777)) { } snprintf(file, sizeof(file), "%s/pids.max", cgroupdir); write_file(file, "32"); snprintf(file, sizeof(file), "%s/memory.low", cgroupdir); write_file(file, "%d", 298 << 20); snprintf(file, sizeof(file), "%s/memory.high", cgroupdir); write_file(file, "%d", 299 << 20); snprintf(file, sizeof(file), "%s/memory.max", cgroupdir); write_file(file, "%d", 300 << 20); snprintf(file, sizeof(file), "%s/cgroup.procs", cgroupdir); write_file(file, "%d", pid); snprintf(cgroupdir, sizeof(cgroupdir), "/syzcgroup/cpu/syz%llu", procid); if (mkdir(cgroupdir, 0777)) { } snprintf(file, sizeof(file), "%s/cgroup.procs", cgroupdir); write_file(file, "%d", pid); snprintf(cgroupdir, sizeof(cgroupdir), "/syzcgroup/net/syz%llu", procid); if (mkdir(cgroupdir, 0777)) { } snprintf(file, sizeof(file), "%s/cgroup.procs", cgroupdir); write_file(file, "%d", pid); } static void setup_cgroups_test() { char cgroupdir[64]; snprintf(cgroupdir, sizeof(cgroupdir), "/syzcgroup/unified/syz%llu", procid); if (symlink(cgroupdir, "./cgroup")) { } snprintf(cgroupdir, sizeof(cgroupdir), "/syzcgroup/cpu/syz%llu", procid); if (symlink(cgroupdir, "./cgroup.cpu")) { } snprintf(cgroupdir, sizeof(cgroupdir), "/syzcgroup/net/syz%llu", procid); if (symlink(cgroupdir, "./cgroup.net")) { } } static void setup_common() { if (mount(0, "/sys/fs/fuse/connections", "fusectl", 0, 0)) { } setup_cgroups(); } static void loop(); static void sandbox_common() { prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); setpgrp(); setsid(); struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = (200 << 20); setrlimit(RLIMIT_AS, &rlim); rlim.rlim_cur = rlim.rlim_max = 32 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 136 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); if (unshare(CLONE_NEWNS)) { } if (unshare(CLONE_NEWIPC)) { } if (unshare(0x02000000)) { } if (unshare(CLONE_NEWUTS)) { } if (unshare(CLONE_SYSVSEM)) { } typedef struct { const char* name; const char* value; } sysctl_t; static const sysctl_t sysctls[] = { {"/proc/sys/kernel/shmmax", "16777216"}, {"/proc/sys/kernel/shmall", "536870912"}, {"/proc/sys/kernel/shmmni", "1024"}, {"/proc/sys/kernel/msgmax", "8192"}, {"/proc/sys/kernel/msgmni", "1024"}, {"/proc/sys/kernel/msgmnb", "1024"}, {"/proc/sys/kernel/sem", "1024 1048576 500 1024"}, }; unsigned i; for (i = 0; i < sizeof(sysctls) / sizeof(sysctls[0]); i++) write_file(sysctls[i].name, sysctls[i].value); } int wait_for_loop(int pid) { if (pid < 0) exit(1); int status = 0; while (waitpid(-1, &status, __WALL) != pid) { } return WEXITSTATUS(status); } static int do_sandbox_none(void) { if (unshare(CLONE_NEWPID)) { } int pid = fork(); if (pid != 0) return wait_for_loop(pid); setup_common(); sandbox_common(); initialize_netdevices_init(); if (unshare(CLONE_NEWNET)) { } initialize_tun(); initialize_netdevices(); loop(); exit(1); } #define FS_IOC_SETFLAGS _IOW('f', 2, long) static void remove_dir(const char* dir) { DIR* dp; struct dirent* ep; int iter = 0; retry: while (umount2(dir, MNT_DETACH) == 0) { } dp = opendir(dir); if (dp == NULL) { if (errno == EMFILE) { exit(1); } exit(1); } while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); while (umount2(filename, MNT_DETACH) == 0) { } struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } int i; for (i = 0;; i++) { if (unlink(filename) == 0) break; if (errno == EPERM) { int fd = open(filename, O_RDONLY); if (fd != -1) { long flags = 0; if (ioctl(fd, FS_IOC_SETFLAGS, &flags) == 0) close(fd); continue; } } if (errno == EROFS) { break; } if (errno != EBUSY || i > 100) exit(1); if (umount2(filename, MNT_DETACH)) exit(1); } } closedir(dp); int i; for (i = 0;; i++) { if (rmdir(dir) == 0) break; if (i < 100) { if (errno == EPERM) { int fd = open(dir, O_RDONLY); if (fd != -1) { long flags = 0; if (ioctl(fd, FS_IOC_SETFLAGS, &flags) == 0) close(fd); continue; } } if (errno == EROFS) { break; } if (errno == EBUSY) { if (umount2(dir, MNT_DETACH)) exit(1); continue; } if (errno == ENOTEMPTY) { if (iter < 100) { iter++; goto retry; } } } exit(1); } } static void kill_and_wait(int pid, int* status) { kill(-pid, SIGKILL); kill(pid, SIGKILL); int i; for (i = 0; i < 100; i++) { if (waitpid(-1, status, WNOHANG | __WALL) == pid) return; usleep(1000); } DIR* dir = opendir("/sys/fs/fuse/connections"); if (dir) { for (;;) { struct dirent* ent = readdir(dir); if (!ent) break; if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0) continue; char abort[300]; snprintf(abort, sizeof(abort), "/sys/fs/fuse/connections/%s/abort", ent->d_name); int fd = open(abort, O_WRONLY); if (fd == -1) { continue; } if (write(fd, abort, 1) < 0) { } close(fd); } closedir(dir); } else { } while (waitpid(-1, status, __WALL) != pid) { } } static void setup_loop() { setup_cgroups_loop(); checkpoint_net_namespace(); } static void reset_loop() { reset_net_namespace(); } static void setup_test() { prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); setpgrp(); setup_cgroups_test(); write_file("/proc/self/oom_score_adj", "1000"); flush_tun(); } static void close_fds() { int fd; for (fd = 3; fd < 30; fd++) close(fd); } static void setup_binfmt_misc() { if (mount(0, "/proc/sys/fs/binfmt_misc", "binfmt_misc", 0, 0)) { } write_file("/proc/sys/fs/binfmt_misc/register", ":syz0:M:0:\x01::./file0:"); write_file("/proc/sys/fs/binfmt_misc/register", ":syz1:M:1:\x02::./file0:POC"); } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { int i, call, thread; int collide = 0; again: for (call = 0; call < 5; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); if (collide && (call % 2) == 0) break; event_timedwait(&th->done, 45); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); close_fds(); if (!collide) { collide = 1; goto again; } } static void execute_one(void); #define WAIT_FLAGS __WALL static void loop(void) { setup_loop(); int iter; for (iter = 0;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); reset_loop(); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); setup_test(); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5 * 1000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[2] = {0xffffffffffffffff, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res; switch (call) { case 0: NONFAILING(memcpy((void*)0x200002c0, "/dev/infiniband/rdma_cm\000", 24)); res = syscall(__NR_openat, 0xffffffffffffff9c, 0x200002c0, 2, 0); if (res != -1) r[0] = res; break; case 1: NONFAILING(*(uint32_t*)0x200005c0 = 0); NONFAILING(*(uint16_t*)0x200005c4 = 0x18); NONFAILING(*(uint16_t*)0x200005c6 = 0xfa00); NONFAILING(*(uint64_t*)0x200005c8 = 0); NONFAILING(*(uint64_t*)0x200005d0 = 0x20000600); NONFAILING(*(uint16_t*)0x200005d8 = 0x13f); NONFAILING(*(uint8_t*)0x200005da = 0); NONFAILING(*(uint8_t*)0x200005db = 0); NONFAILING(*(uint8_t*)0x200005dc = 0); NONFAILING(*(uint8_t*)0x200005dd = 0); NONFAILING(*(uint8_t*)0x200005de = 0); NONFAILING(*(uint8_t*)0x200005df = 0); res = syscall(__NR_write, r[0], 0x200005c0, 0x20); if (res != -1) NONFAILING(r[1] = *(uint32_t*)0x20000600); break; case 2: syscall(__NR_write, r[0], 0, 0); break; case 3: NONFAILING(*(uint32_t*)0x20000380 = 2); NONFAILING(*(uint16_t*)0x20000384 = 0x28); NONFAILING(*(uint16_t*)0x20000386 = 0xfa00); NONFAILING(*(uint64_t*)0x20000388 = 0); NONFAILING(*(uint16_t*)0x20000390 = 0xa); NONFAILING(*(uint16_t*)0x20000392 = htobe16(0)); NONFAILING(*(uint32_t*)0x20000394 = htobe32(0x7fffffff)); NONFAILING(*(uint8_t*)0x20000398 = -1); NONFAILING(*(uint8_t*)0x20000399 = 1); NONFAILING(*(uint8_t*)0x2000039a = 0); NONFAILING(*(uint8_t*)0x2000039b = 0); NONFAILING(*(uint8_t*)0x2000039c = 0); NONFAILING(*(uint8_t*)0x2000039d = 0); NONFAILING(*(uint8_t*)0x2000039e = 0); NONFAILING(*(uint8_t*)0x2000039f = 0); NONFAILING(*(uint8_t*)0x200003a0 = 0); NONFAILING(*(uint8_t*)0x200003a1 = 0); NONFAILING(*(uint8_t*)0x200003a2 = 0); NONFAILING(*(uint8_t*)0x200003a3 = 0); NONFAILING(*(uint8_t*)0x200003a4 = 0); NONFAILING(*(uint8_t*)0x200003a5 = 0); NONFAILING(*(uint8_t*)0x200003a6 = 0); NONFAILING(*(uint8_t*)0x200003a7 = 1); NONFAILING(*(uint32_t*)0x200003a8 = 0); NONFAILING(*(uint32_t*)0x200003ac = r[1]); syscall(__NR_write, r[0], 0x20000380, 0x30); break; case 4: NONFAILING(*(uint32_t*)0x20000000 = 7); NONFAILING(*(uint16_t*)0x20000004 = 8); NONFAILING(*(uint16_t*)0x20000006 = 0xfa00); NONFAILING(*(uint32_t*)0x20000008 = r[1]); NONFAILING(*(uint32_t*)0x2000000c = 0); syscall(__NR_write, r[0], 0x20000000, 0x10); break; } } int main(void) { syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0); setup_binfmt_misc(); install_segv_handler(); use_temporary_dir(); do_sandbox_none(); return 0; }
the_stack_data/192331529.c
/* * Copyright (C) 2015-2017 Netronome Systems, Inc. * * This software is dual licensed under the GNU General License Version 2, * June 1991 as shown in the file COPYING in the top-level directory of this * source tree or the BSD 2-Clause License provided below. You have the * option to license this software under the complete terms of either license. * * The BSD 2-Clause 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. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ /* * nfp_plat.c * Author: Jason McMullan <[email protected]> */ /* This component is only compiled for the NFP's ARM Linux */ #include <linux/kernel.h> #ifdef CONFIG_ARCH_NFP #include <linux/module.h> #include <linux/platform_device.h> #include <linux/irq.h> #include <linux/irqdomain.h> #include <linux/irqchip/chained_irq.h> #include <linux/io.h> #include <linux/of_device.h> #include <linux/of_address.h> #include <linux/of_irq.h> #include <linux/slab.h> #include <linux/interrupt.h> #include "nfpcore/nfp_arm.h" #include "nfpcore/nfp_cpp.h" #include "nfpcore/nfp6000/nfp6000.h" #include "nfpcore/nfp_net_vnic.h" #include "nfp_main.h" #define NFP_EXPL_START (0xde000000) #define NFP_ARM_EM_START (0xd6000000 + NFP_ARM_EM) #define NFP_EXPA_START 0xc0000000 #define NFP_ARM_START 0xd6000000 #define BAR_FLAG_LOCKED BIT(0) struct nfp_plat_bar { unsigned flags; atomic_t usage; u32 csr; }; #define NFP_EM_FILTER_BASE 8 #define NFP_EM_FILTERS 32 struct nfp_plat { struct device *dev; struct platform_device *nfp_dev_cpp; struct platform_device *nfp_net_vnic[4]; struct nfp_cpp *cpp; int (*target_pushpull)(u32 cpp_id, u64 address); spinlock_t lock; /* Lock for the BAR cache */ struct nfp_plat_bar bulk_bar[7]; /* Last BULK is for user use */ struct nfp_plat_bar expa_bar[15]; /* Last EXPA is for user use */ unsigned long expl_bar_mask[BITS_TO_LONGS(16)]; void __iomem *gcsr; struct device_node *arm_em; phys_addr_t expl_phys; size_t expl_size; void __iomem *expl_io; void __iomem *expl_data; unsigned long irq_used[BITS_TO_LONGS(NFP_EM_FILTERS)]; unsigned int irq[NFP_EM_FILTERS]; }; struct nfp_plat_area_priv { /* Always Valid */ u32 dest; u64 addr; unsigned long size; struct { int read; int write; int bar; } width; /* Non-null when allocated */ struct nfp_plat_bar *bar; /* First bar */ struct resource resource; /* Valid while allocated */ enum bar_type { BAR_INVALID = 0, BAR_BULK, BAR_EXPA, } type; int bars; /* Number of bars contig. allocated */ int id; /* ID of first bar */ u64 offset; unsigned long phys_addr; /* Physical address of the BAR base */ unsigned long phys_size; /* Bar total size */ void __iomem *iomem; }; struct nfp_plat_event_priv { u32 match; u32 mask; unsigned int type; int em_slot; }; static void bar_lock(struct nfp_plat_bar *bar) { atomic_inc(&bar->usage); bar->flags |= BAR_FLAG_LOCKED; } static void bar_unlock(struct nfp_plat_bar *bar) { if (atomic_dec_and_test(&bar->usage)) { bar->flags &= ~BAR_FLAG_LOCKED; bar->csr = 0; } } static int bar_find(struct nfp_cpp_area *area, enum bar_type type, int bars, u32 csr, int can_alloc) { struct nfp_plat *nfp_priv = nfp_cpp_priv(nfp_cpp_area_cpp(area)); struct nfp_plat_area_priv *priv = nfp_cpp_area_priv(area); struct nfp_plat_bar *bar; unsigned long bar_base; unsigned int bar_max; size_t bar_size; unsigned int i, j; /* Only for unallocated areas... */ BUG_ON(priv->bar); BUG_ON(bars == 0); switch (type) { case BAR_BULK: bar = nfp_priv->bulk_bar; bar_max = ARRAY_SIZE(nfp_priv->bulk_bar); bar_size = NFP_ARM_GCSR_BULK_SIZE; bar_base = 0; break; case BAR_EXPA: bar = nfp_priv->expa_bar; bar_max = ARRAY_SIZE(nfp_priv->expa_bar); bar_size = NFP_ARM_GCSR_EXPA_SIZE; bar_base = NFP_EXPA_START; break; default: return -EINVAL; } /* Adjust to given limit */ bar_max = bar_max - bars + 1; spin_lock(&nfp_priv->lock); /* Find a matching bar */ for (i = 0; i < bar_max; i++) { for (j = 0; j < bars; j++) { if ((bar[i + j].flags & BAR_FLAG_LOCKED) == 0) break; if ((csr + j) != bar[i + j].csr) break; } if (j == bars) break; } if (i < bar_max) { /* Ooh! We got one! */ goto found_slot; } if (!can_alloc) { spin_unlock(&nfp_priv->lock); return -EEXIST; } /* Find an unused set. */ for (i = 0; i < bar_max; i++) { for (j = 0; j < bars; j++) { if ((bar[i + j].flags & BAR_FLAG_LOCKED)) break; } if (j == bars) break; } if (i == bar_max) { spin_unlock(&nfp_priv->lock); return -ENOSPC; } found_slot: priv->id = i; for (j = 0; j < bars; j++) { bar_lock(&bar[priv->id + j]); bar[priv->id + j].csr = csr + j; } spin_unlock(&nfp_priv->lock); priv->bar = &bar[priv->id]; priv->bars = bars; priv->type = type; priv->offset = priv->addr & (bar_size - 1); priv->phys_addr = bar_base + priv->id * bar_size; priv->phys_size = bar_size * bars; return 0; } static void bulk_csr(u32 *csr, u32 dest, u64 addr, int width) { *csr = NFP_ARM_GCSR_BULK_CSR(0, /* Always expansion */ NFP_CPP_ID_TARGET_of(dest), NFP_CPP_ID_TOKEN_of(dest), (width = 8) ? NFP_ARM_GCSR_BULK_BAR_LEN_64BIT : NFP_ARM_GCSR_BULK_BAR_LEN_32BIT, addr); } static void bulk_set(struct nfp_plat *priv, u32 csr, unsigned int id) { int i; readl(priv->gcsr + NFP_ARM_GCSR_BULK_BAR(id)); writel(csr, priv->gcsr + NFP_ARM_GCSR_BULK_BAR(id)); for (i = 0; i < 10; i++) if (readl(priv->gcsr + NFP_ARM_GCSR_BULK_BAR(id)) == csr) break; if (i == 10) dev_err(priv->dev, "BULK%d: %08x != %08x\n", id, readl(priv->gcsr + NFP_ARM_GCSR_BULK_BAR(id)), csr); } static void expa_csr(u32 *csr, u32 dest, u64 addr, int width) { unsigned action = NFP_CPP_ID_ACTION_of(dest); int is_64 = (width == 8) ? 1 : 0; if (action == NFP_CPP_ACTION_RW) action = 0; *csr = NFP_ARM_GCSR_EXPA_CSR(0, /* Always expansion */ NFP_CPP_ID_TARGET_of(dest), NFP_CPP_ID_TOKEN_of(dest), is_64 ? NFP_ARM_GCSR_EXPA_BAR_LEN_64BIT : NFP_ARM_GCSR_EXPA_BAR_LEN_32BIT, NFP_CPP_ID_ACTION_of(dest), addr); } static void expa_set(struct nfp_plat *priv, u32 csr, unsigned int id) { int i; readl(priv->gcsr + NFP_ARM_GCSR_EXPA_BAR(id)); writel(csr, priv->gcsr + NFP_ARM_GCSR_EXPA_BAR(id)); for (i = 0; i < 10; i++) if (readl(priv->gcsr + NFP_ARM_GCSR_EXPA_BAR(id)) == csr) break; if (i == 10) dev_err(priv->dev, "EXPA%d: %08x != %08x\n", id, readl(priv->gcsr + NFP_ARM_GCSR_EXPA_BAR(id)), csr); } static u16 nfp_plat_get_interface(struct device *dev) { return NFP_CPP_INTERFACE(NFP_CPP_INTERFACE_TYPE_ARM, 0, NFP_CPP_INTERFACE_CHANNEL_PEROPENER); } static int nfp_plat_area_init(struct nfp_cpp_area *area, u32 dest, u64 addr, unsigned long size) { struct nfp_plat *nfp_priv = nfp_cpp_priv(nfp_cpp_area_cpp(area)); struct nfp_plat_area_priv *priv = nfp_cpp_area_priv(area); int pp; pp = nfp_priv->target_pushpull(dest, addr); if (pp < 0) return pp; priv->width.read = PUSH_WIDTH(pp); priv->width.write = PULL_WIDTH(pp); if (priv->width.read > 0 && priv->width.write > 0 && priv->width.read != priv->width.write) { return -EINVAL; } if (priv->width.read) priv->width.bar = priv->width.read; else priv->width.bar = priv->width.write; priv->dest = dest; priv->addr = addr; priv->size = size; priv->bar = NULL; return 0; } void nfp_plat_area_cleanup(struct nfp_cpp_area *area) { } static int bar_find_any(struct nfp_cpp_area *area, int can_allocate) { struct nfp_plat *nfp_priv = nfp_cpp_priv(nfp_cpp_area_cpp(area)); struct nfp_plat_area_priv *priv = nfp_cpp_area_priv(area); unsigned long size; int bars, err, i; int width; u32 dest; u64 addr; u32 csr; BUG_ON(priv->bar); dest = priv->dest; addr = priv->addr; size = priv->size; width = priv->width.bar; #define BARS(addr, size, max_size) \ ((((addr) & ((max_size) - 1)) + \ (size) + (max_size) - 1) / (max_size)) bars = BARS(addr, size, NFP_ARM_GCSR_EXPA_SIZE); if (bars < ARRAY_SIZE(nfp_priv->expa_bar)) { expa_csr(&csr, dest, addr, width); err = bar_find(area, BAR_EXPA, bars, csr, can_allocate); if (err == 0) { for (i = 0; i < bars; i++) expa_set(nfp_priv, priv->bar[i].csr, priv->id + i); return 0; } } bars = BARS(addr, size, NFP_ARM_GCSR_BULK_SIZE); if ((bars < ARRAY_SIZE(nfp_priv->bulk_bar)) && (NFP_CPP_ID_ACTION_of(dest) == NFP_CPP_ACTION_RW || NFP_CPP_ID_ACTION_of(dest) == 0 || NFP_CPP_ID_ACTION_of(dest) == 1)) { bulk_csr(&csr, dest, addr, width); err = bar_find(area, BAR_BULK, bars, csr, can_allocate); if (err == 0) { for (i = 0; i < bars; i++) bulk_set(nfp_priv, priv->bar[i].csr, priv->id + i); return 0; } } return -ENOSPC; } static int nfp_plat_acquire(struct nfp_cpp_area *area) { struct nfp_plat_area_priv *priv = nfp_cpp_area_priv(area); phys_addr_t phys_offset; int err; err = bar_find_any(area, false); if (err != 0) err = bar_find_any(area, true); if (err == 0) { phys_offset = priv->phys_addr + priv->offset; memset(&priv->resource, 0, sizeof(priv->resource)); priv->resource.name = nfp_cpp_area_name(area); priv->resource.start = phys_offset; priv->resource.end = phys_offset + priv->size - 1; priv->resource.flags = IORESOURCE_MEM; priv->resource.parent = NULL; } return err; } static void nfp_plat_release(struct nfp_cpp_area *area) { struct nfp_plat *nfp_priv = nfp_cpp_priv(nfp_cpp_area_cpp(area)); struct nfp_plat_area_priv *priv = nfp_cpp_area_priv(area); int i; BUG_ON(!priv->bar); if (priv->iomem) iounmap(priv->iomem); spin_lock(&nfp_priv->lock); for (i = 0; i < priv->bars; i++) bar_unlock(&priv->bar[i]); spin_unlock(&nfp_priv->lock); priv->bar = NULL; priv->iomem = NULL; } static struct resource *nfp_plat_resource(struct nfp_cpp_area *area) { struct nfp_plat_area_priv *priv = nfp_cpp_area_priv(area); BUG_ON(!priv->bar); return &priv->resource; } static phys_addr_t nfp_plat_phys(struct nfp_cpp_area *area) { struct nfp_plat_area_priv *priv = nfp_cpp_area_priv(area); BUG_ON(!priv->bar); return priv->phys_addr + priv->offset; } static void __iomem *nfp_plat_iomem(struct nfp_cpp_area *area) { struct nfp_plat_area_priv *priv = nfp_cpp_area_priv(area); phys_addr_t phys_offset; BUG_ON(!priv->bar); if (priv->iomem) return priv->iomem; phys_offset = priv->phys_addr + priv->offset; priv->iomem = ioremap(phys_offset, priv->size); return priv->iomem; } static int nfp_plat_read(struct nfp_cpp_area *area, void *kernel_vaddr, unsigned long offset, unsigned int length) { struct nfp_plat_area_priv *priv = nfp_cpp_area_priv(area); void __iomem *iomem; unsigned long i; int is_64; BUG_ON(!priv->bar); if (!priv->width.read) return -EINVAL; iomem = nfp_cpp_area_iomem(area); if (!iomem) return -ENOMEM; is_64 = (priv->width.read == 8) ? 1 : 0; if (is_64) { if (((offset % sizeof(u64)) != 0) || ((length % sizeof(u64)) != 0)) return -EINVAL; } else { if (((offset % sizeof(u32)) != 0) || ((length % sizeof(u32)) != 0)) return -EINVAL; } BUG_ON((offset + length) > priv->size); if (priv->type == BAR_BULK || priv->type == BAR_EXPA) { /* Easy! It's bulk or expansion bar! */ if (((offset % sizeof(u64)) == 0) && ((length % sizeof(u64)) == 0)) { for (i = 0; i < length; i += sizeof(u64)) { u64 tmp = readq(iomem + offset + i); *(u64 *)(kernel_vaddr + i) = tmp; } } else { for (i = 0; i < length; i += sizeof(u32)) { u32 tmp = readl(iomem + offset + i); *(u32 *)(kernel_vaddr + i) = tmp; } } return i; } /* Explicit BARs are reserved for user usage */ return -EINVAL; } static int nfp_plat_write(struct nfp_cpp_area *area, const void *kernel_vaddr, unsigned long offset, unsigned int length) { struct nfp_plat_area_priv *priv = nfp_cpp_area_priv(area); void __iomem *iomem; unsigned long i; int is_64; BUG_ON(!priv->bar); if (!priv->width.write) return -EINVAL; iomem = nfp_cpp_area_iomem(area); if (!iomem) return -ENOMEM; is_64 = (priv->width.write == 8) ? 1 : 0; if (is_64) { if (((offset % sizeof(u64)) != 0) || ((length % sizeof(u64)) != 0)) return -EINVAL; } else { if (((offset % sizeof(u32)) != 0) || ((length % sizeof(u32)) != 0)) return -EINVAL; } if (priv->type == BAR_BULK || priv->type == BAR_EXPA) { /* Easy! It's bulk or expansion bar! */ if (((offset % sizeof(u64)) == 0) && ((length % sizeof(u64)) == 0)) { for (i = 0; i < length; i += sizeof(u64)) { writeq(*(u64 *)(kernel_vaddr + i), iomem + offset + i); } } else { for (i = 0; i < length; i += sizeof(u32)) { writel(*(u32 *)(kernel_vaddr + i), iomem + offset + i); } } return i; } /* Explicit BARs are reserved for user usage */ return -EINVAL; } static irqreturn_t nfp_plat_irq(int irq, void *priv) { struct nfp_cpp_event *event = priv; nfp_cpp_event_callback(event); return IRQ_HANDLED; } static int nfp_plat_event_acquire(struct nfp_cpp_event *event, u32 match, u32 mask, unsigned int type) { struct nfp_plat_event_priv *event_priv = nfp_cpp_event_priv(event); struct nfp_plat *priv = nfp_cpp_priv(nfp_cpp_event_cpp(event)); int err, em_slot; unsigned int irq; u32 spec[4]; /* Only type 0 filters are supported */ if (type != 0) return -EINVAL; event_priv->match = match; event_priv->mask = mask; event_priv->type = type; event_priv->em_slot = -1; spin_lock(&priv->lock); em_slot = find_first_zero_bit(&priv->irq_used, 32); if (em_slot >= 32) { spin_unlock(&priv->lock); return -ENOSPC; } BUG_ON(test_bit(em_slot, priv->irq_used)); set_bit(em_slot, priv->irq_used); spin_unlock(&priv->lock); event_priv->em_slot = em_slot; spec[0] = event_priv->em_slot * 32; spec[1] = event_priv->match; spec[2] = event_priv->mask; spec[3] = event_priv->type; irq = irq_create_of_mapping(priv->arm_em, spec, 4); priv->irq[em_slot] = irq; err = request_irq(irq, nfp_plat_irq, 0, "nfp_plat", event); if (err < 0) { spin_lock(&priv->lock); clear_bit(em_slot, priv->irq_used); spin_unlock(&priv->lock); } return err; } static void nfp_plat_event_release(struct nfp_cpp_event *event) { struct nfp_plat_event_priv *event_priv = nfp_cpp_event_priv(event); struct nfp_plat *priv = nfp_cpp_priv(nfp_cpp_event_cpp(event)); int irq; spin_lock(&priv->lock); clear_bit(event_priv->em_slot, priv->irq_used); irq = priv->irq[event_priv->em_slot]; priv->irq[event_priv->em_slot] = -1; spin_unlock(&priv->lock); free_irq(irq, event); irq_dispose_mapping(irq); } #define NFP_EXPL_POST 0 #define NFP_EXPL1_BAR 1 #define NFP_EXPL2_BAR 2 struct nfp_plat_explicit_priv { int index; }; #define EXPL_BASE 0xf800 #define EXPL_INDEX_TO_OFFSET(n) ((n) << 5) #define EXPL_INDEX_TO_DATA_REF(n) ({ u16 offset = EXPL_BASE + \ EXPL_INDEX_TO_OFFSET(n); \ (offset & 0x3ff0) | \ ((offset & 0xc000) >> 14); }) #define EXPL_INDEX_TO_SIGNAL_REF(n) (0x60 + ((n) << 1)) int nfp_plat_explicit_acquire(struct nfp_cpp_explicit *expl) { struct nfp_plat_explicit_priv *expl_priv = nfp_cpp_explicit_priv(expl); struct nfp_cpp *cpp = nfp_cpp_explicit_cpp(expl); struct nfp_plat *priv = nfp_cpp_priv(cpp); int i; /* The last EXPL is for user use! */ for (i = 0; i < 7; i++) { if (!test_and_set_bit(i, priv->expl_bar_mask)) { expl_priv->index = i; return 0; } } return -EBUSY; } /* Release an explicit transaction handle */ void nfp_plat_explicit_release(struct nfp_cpp_explicit *expl) { struct nfp_plat_explicit_priv *expl_priv = nfp_cpp_explicit_priv(expl); struct nfp_cpp *cpp = nfp_cpp_explicit_cpp(expl); struct nfp_plat *priv = nfp_cpp_priv(cpp); clear_bit(expl_priv->index, priv->expl_bar_mask); } /* Perform the transaction */ static int nfp_plat_explicit_do(struct nfp_cpp_explicit *expl, const struct nfp_cpp_explicit_command *cmd, u64 address) { struct nfp_plat_explicit_priv *expl_priv = nfp_cpp_explicit_priv(expl); struct nfp_cpp *cpp = nfp_cpp_explicit_cpp(expl); u16 signal_master, data_master, default_master; struct nfp_plat *priv = nfp_cpp_priv(cpp); void __iomem *expl_io = priv->expl_io; void __iomem *gcsr = priv->gcsr; int err, index = expl_priv->index; u32 expl1, expl2, post; u16 data_ref, signal_ref; u32 required = 0; u32 model = nfp_cpp_model(cpp); if (NFP_CPP_MODEL_IS_6000(model)) default_master = 0x11; else default_master = 0x01; if (cmd->data_master == 0) data_master = default_master; else data_master = cmd->data_master; if (cmd->data_master == 0 && cmd->data_ref == 0) data_ref = EXPL_INDEX_TO_DATA_REF(index); else data_ref = cmd->data_ref; if (cmd->signal_master == 0) signal_master = default_master; else signal_master = cmd->signal_master; if (cmd->signal_master == 0 && cmd->signal_ref == 0) signal_ref = EXPL_INDEX_TO_SIGNAL_REF(index); else signal_ref = cmd->signal_ref; expl1 = NFP_ARM_GCSR_EXPL1_BAR_POSTED | NFP_ARM_GCSR_EXPL1_BAR_DATA_MASTER(data_master) | NFP_ARM_GCSR_EXPL1_BAR_DATA_REF(data_ref) | NFP_ARM_GCSR_EXPL1_BAR_SIGNAL_REF(signal_ref); expl2 = NFP_ARM_GCSR_EXPL2_BAR_TGT(NFP_CPP_ID_TARGET_of(cmd->cpp_id)) | NFP_ARM_GCSR_EXPL2_BAR_ACT(NFP_CPP_ID_ACTION_of(cmd->cpp_id)) | NFP_ARM_GCSR_EXPL2_BAR_TOK(NFP_CPP_ID_TOKEN_of(cmd->cpp_id)) | NFP_ARM_GCSR_EXPL2_BAR_LEN(cmd->len) | NFP_ARM_GCSR_EXPL2_BAR_BYTE_MASK(cmd->byte_mask) | NFP_ARM_GCSR_EXPL2_BAR_SIGNAL_MASTER(signal_master); post = 0; if (cmd->posted) { post = NFP_ARM_GCSR_EXPL1_BAR_POSTED | NFP_ARM_GCSR_EXPL_POST_SIG_A(cmd->siga) | NFP_ARM_GCSR_EXPL_POST_SIG_B(cmd->sigb); switch (cmd->siga_mode) { case NFP_SIGNAL_PUSH: /* Fallthrough */ required |= NFP_ARM_GCSR_EXPL_POST_SIG_A_RCVD; case NFP_SIGNAL_PUSH_OPTIONAL: post |= NFP_ARM_GCSR_EXPL_POST_SIG_A_VALID; post |= NFP_ARM_GCSR_EXPL_POST_SIG_A_BUS_PUSH; break; case NFP_SIGNAL_PULL: required |= NFP_ARM_GCSR_EXPL_POST_SIG_A_RCVD; /* Fallthrough */ case NFP_SIGNAL_PULL_OPTIONAL: post |= NFP_ARM_GCSR_EXPL_POST_SIG_A_VALID; post |= NFP_ARM_GCSR_EXPL_POST_SIG_A_BUS_PULL; break; case NFP_SIGNAL_NONE: break; } switch (cmd->sigb_mode) { case NFP_SIGNAL_PUSH: required |= NFP_ARM_GCSR_EXPL_POST_SIG_B_RCVD; /* Fallthrough */ case NFP_SIGNAL_PUSH_OPTIONAL: post |= NFP_ARM_GCSR_EXPL_POST_SIG_B_VALID; post |= NFP_ARM_GCSR_EXPL_POST_SIG_B_BUS_PUSH; break; case NFP_SIGNAL_PULL: required |= NFP_ARM_GCSR_EXPL_POST_SIG_B_RCVD; /* Fallthrough */ case NFP_SIGNAL_PULL_OPTIONAL: post |= NFP_ARM_GCSR_EXPL_POST_SIG_B_VALID; post |= NFP_ARM_GCSR_EXPL_POST_SIG_B_BUS_PULL; break; case NFP_SIGNAL_NONE: break; } } if (signal_master == default_master) { int ref = EXPL_INDEX_TO_SIGNAL_REF(index); post &= ~(NFP_ARM_GCSR_EXPL_POST_SIG_A(~0) | NFP_ARM_GCSR_EXPL_POST_SIG_B(~0)); post |= NFP_ARM_GCSR_EXPL_POST_SIG_A(ref) | NFP_ARM_GCSR_EXPL_POST_SIG_B(ref | 1); } /* Write the EXPL0_BAR csr */ writel(NFP_ARM_GCSR_EXPL0_BAR_ADDR(address), gcsr + NFP_ARM_GCSR_EXPL0_BAR(index)); writel(expl1, gcsr + NFP_ARM_GCSR_EXPL1_BAR(index)); /* Write the EXPL2_BAR csr */ writel(expl2, gcsr + NFP_ARM_GCSR_EXPL2_BAR(index)); /* Write the EXPL_POST csr */ writel(post & ~NFP_ARM_GCSR_EXPL_POST_CMD_COMPLETE, gcsr + NFP_ARM_GCSR_EXPL_POST(index)); /* Start the transaction, by doing a dummy read from the * ARM Gasket area */ readb(expl_io + (NFP_ARM_GCSR_EXPL_SIZE * index) + (address & (NFP_ARM_GCSR_EXPL_SIZE - 1))); /* If we have been told to wait for one or more * signals to return, do so. * This *cannot* sleep, as we are simulating a * hardware operation that has no timeout. */ if (required) { do { post = readl(gcsr + NFP_ARM_GCSR_EXPL_POST(index)); post = readl(gcsr + NFP_ARM_GCSR_EXPL_POST(index)); } while (((post & required) != required)); } /* Calculate the return mask */ err = 0; if (post & NFP_ARM_GCSR_EXPL_POST_SIG_A_RCVD) err |= NFP_SIGNAL_MASK_A; if (post & NFP_ARM_GCSR_EXPL_POST_SIG_B_RCVD) err |= NFP_SIGNAL_MASK_B; return err; } /* Write data to send */ int nfp_plat_explicit_put(struct nfp_cpp_explicit *expl, const void *buff, size_t len) { struct nfp_plat_explicit_priv *expl_priv = nfp_cpp_explicit_priv(expl); struct nfp_cpp *cpp = nfp_cpp_explicit_cpp(expl); struct nfp_plat *priv = nfp_cpp_priv(cpp); if (len > 128) return -EINVAL; memcpy(priv->expl_data + EXPL_INDEX_TO_OFFSET(expl_priv->index), buff, len); return len; } /* Read data received */ int nfp_plat_explicit_get(struct nfp_cpp_explicit *expl, void *buff, size_t len) { struct nfp_plat_explicit_priv *expl_priv = nfp_cpp_explicit_priv(expl); struct nfp_cpp *cpp = nfp_cpp_explicit_cpp(expl); struct nfp_plat *priv = nfp_cpp_priv(cpp); if (len > 128) return -EINVAL; memcpy(buff, priv->expl_data + EXPL_INDEX_TO_OFFSET(expl_priv->index), len); return len; } static const struct nfp_cpp_operations nfp_plat_ops = { .get_interface = nfp_plat_get_interface, .area_priv_size = sizeof(struct nfp_plat_area_priv), .area_init = nfp_plat_area_init, .area_cleanup = nfp_plat_area_cleanup, .area_acquire = nfp_plat_acquire, .area_release = nfp_plat_release, .area_phys = nfp_plat_phys, .area_resource = nfp_plat_resource, .area_iomem = nfp_plat_iomem, .area_read = nfp_plat_read, .area_write = nfp_plat_write, .explicit_priv_size = sizeof(struct nfp_plat_explicit_priv), .explicit_acquire = nfp_plat_explicit_acquire, .explicit_release = nfp_plat_explicit_release, .explicit_put = nfp_plat_explicit_put, .explicit_get = nfp_plat_explicit_get, .explicit_do = nfp_plat_explicit_do, .event_priv_size = sizeof(struct nfp_plat_event_priv), .event_acquire = nfp_plat_event_acquire, .event_release = nfp_plat_event_release, }; static const struct of_device_id nfp_plat_match[] = { { .compatible = "netronome,nfp6000-arm-cpp", .data = nfp_target_pushpull }, { }, }; MODULE_DEVICE_TABLE(of, nfp_plat_match); #define BARTYPE_EXPA 1 #define BARTYPE_EXPL 2 static int nfp_plat_bar_scan(struct nfp_plat *priv, u32 arm_addr, u32 arm_size, u32 cpp_id, u64 cpp_addr, unsigned long *used) { int pp, target, action, token, is_64; struct device *dev = priv->dev; int bar, type = 0; u32 csr; target = NFP_CPP_ID_TARGET_of(cpp_id); action = NFP_CPP_ID_ACTION_of(cpp_id); token = NFP_CPP_ID_TOKEN_of(cpp_id); pp = priv->target_pushpull(cpp_id, cpp_addr); is_64 = (PUSH_WIDTH(pp) == 8) ? 1 : 0; switch (arm_size) { case 0x20000000: bar = arm_addr >> 29; if (arm_addr & ~0xe0000000) { dev_warn(dev, "BULK BAR%d: ARM address is unaligned, ignoring\n", bar); return -EINVAL; } bar_lock(&priv->bulk_bar[bar]); set_bit(bar, used); if (cpp_addr & ~0xffe0000000) { dev_warn(dev, "BULK BAR%d: CPP address is unaligned\n", bar); return -EINVAL; } /* Preserve, don't modify */ if (cpp_id == 0) { priv->bulk_bar[bar].csr = readl(priv->gcsr + NFP_ARM_GCSR_BULK_BAR(bar)); dev_info(dev, "BULK BAR%d: Preserved as 0x%08x\n", bar, priv->bulk_bar[bar].csr); break; } if ((cpp_id & 0xffffff00) == 0xffffff00) { type = BARTYPE_EXPA; csr = NFP_ARM_GCSR_BULK_CSR(1, 0, 0, 0, 0); dev_info(dev, "BULK BAR%d: Expansion\n", bar); } else { csr = NFP_ARM_GCSR_BULK_CSR(0, target, token, is_64, cpp_addr); } priv->bulk_bar[bar].csr = csr; writel(csr, priv->gcsr + NFP_ARM_GCSR_BULK_BAR(bar)); /* Read-back to flush the CSR */ readl(priv->gcsr + NFP_ARM_GCSR_BULK_BAR(bar)); break; case 0x02000000: bar = (arm_addr >> 25) & 0xf; if (arm_addr < 0xc0000000 || arm_addr >= 0xe0000000) { dev_warn(dev, "EXPA BAR%d: ARM address outside of range 0x%08x-0x%08x\n", bar, 0xc0000000, 0xde000000); return -EINVAL; } if (arm_addr & ~0xfe000000) { dev_warn(dev, "EXPA BAR%d: ARM address is unaligned\n", bar); return -EINVAL; } bar_lock(&priv->expa_bar[bar]); set_bit(bar + 8, used); /* Preserve, do not modify? */ if (cpp_id == 0) { priv->expa_bar[bar].csr = readl(priv->gcsr + NFP_ARM_GCSR_EXPA_BAR(bar)); dev_info(dev, "EXPA BAR%d: Preserved as 0x%08x\n", bar, priv->expa_bar[bar].csr); break; } if (cpp_addr & ~0xfffe000000) { dev_warn(dev, "EXPA BAR%d: CPP address is unaligned\n", bar); return -EINVAL; } if ((cpp_id & 0xffffff00) == 0xffffff00) { /* Promote to EXPL */ dev_warn(dev, "EXPA BAR%d: Explicit\n", bar); type = BARTYPE_EXPL; csr = NFP_ARM_GCSR_EXPA_CSR(1, 0, 0, 0, 0, 0); } else { csr = NFP_ARM_GCSR_EXPA_CSR(0, target, action, token, is_64, cpp_addr); } priv->expa_bar[bar].csr = csr; writel(csr, priv->gcsr + NFP_ARM_GCSR_EXPA_BAR(bar)); /* Read-back to flush the CSR */ readl(priv->gcsr + NFP_ARM_GCSR_EXPA_BAR(bar)); break; default: dev_warn(dev, "Illegal ARM range size 0x%08x\n", arm_size); break; } return type; } /* Sanity checking, and reserve BARs in the 'ranges' property * */ static int nfp_plat_of(struct nfp_plat *priv) { struct device_node *dn = priv->dev->of_node; struct device *dev = priv->dev; DECLARE_BITMAP(used, 8 + 16 + 8); struct property *prop; struct resource res; const __be32 *ptr; u32 tmp; int err; int i; priv->arm_em = of_irq_find_parent(dn); if (!priv->arm_em) { dev_err(dev, "Can't find interrupt parent\n"); return -EINVAL; } /* Mark as used the EM filters we won't be using */ for (i = 0; i < NFP_EM_FILTER_BASE; i++) set_bit(i, priv->irq_used); if (of_property_read_u32(dn, "#address-cells", &tmp) < 0 || tmp != 2) { dev_err(dev, "#address-cells <%d> != 2\n", tmp); return -EINVAL; } if (of_property_read_u32(dn, "#size-cells", &tmp) < 0 || tmp != 1) { dev_err(dev, "#size-cells <%d> != 1\n", tmp); return -EINVAL; } if (of_address_to_resource(dn, 0, &res) < 0) { dev_err(dev, "Can't get 'reg' range 0 for BULK\n"); return -EINVAL; } dev_info(dev, "BARs at 0x%08x\n", res.start); if (resource_size(&res) < (4 * (8 + 16 + (8 * 4)))) { dev_err(dev, "Size of 'reg' range 0 is too small: 0x%x\n", resource_size(&res)); return -EINVAL; } priv->gcsr = of_iomap(dn, 0); if (!priv->gcsr) { dev_err(dev, "Can't map the 'reg' index 0 ('csr')\n"); return -ENOMEM; } of_property_for_each_u32(dn, "ranges", prop, ptr, tmp) { u32 cpp_id; u64 cpp_addr; u32 arm_addr; u32 arm_size; cpp_id = tmp & 0xffffff00; cpp_addr = (u64)(tmp & 0xff) << 32; ptr = of_prop_next_u32(prop, ptr, &tmp); if (!ptr) { dev_err(dev, "Property 'ranges' is 3 cells short!\n"); iounmap(priv->gcsr); return -EINVAL; } cpp_addr |= tmp; ptr = of_prop_next_u32(prop, ptr, &tmp); if (!ptr) { dev_err(dev, "Property 'ranges' is 2 cells short!\n"); iounmap(priv->gcsr); return -EINVAL; } arm_addr = tmp; ptr = of_prop_next_u32(prop, ptr, &tmp); if (!ptr) { dev_err(dev, "Property 'ranges' is 1 cell short!\n"); iounmap(priv->gcsr); return -EINVAL; } arm_size = tmp; err = nfp_plat_bar_scan(priv, arm_addr, arm_size, cpp_id, cpp_addr, used); if (err < 0) { iounmap(priv->gcsr); return err; } if (err == BARTYPE_EXPL) { priv->expl_phys = arm_addr; priv->expl_size = arm_size; } } priv->expl_io = ioremap(priv->expl_phys, priv->expl_size); if (!priv->expl_io) { iounmap(priv->gcsr); return -ENOMEM; } /* We (ab)use part of the ARM Gasket Scratch for explicit data */ priv->expl_data = ioremap(NFP_ARM_START + EXPL_BASE, 32 * 7); if (!priv->expl_data) { iounmap(priv->expl_io); iounmap(priv->gcsr); return -ENOMEM; } /* Clear out BULK BARs */ for (i = 0; i < 8; i++) { if (!test_bit(i, used)) { writel(0, priv->gcsr + NFP_ARM_GCSR_BULK_BAR(i)); readl(priv->gcsr + NFP_ARM_GCSR_BULK_BAR(i)); } } /* Clear out EXPA BARs */ for (i = 0; i < 16; i++) { if (!test_bit(8 + i, used)) { writel(0, priv->gcsr + NFP_ARM_GCSR_EXPA_BAR(i)); readl(priv->gcsr + NFP_ARM_GCSR_EXPA_BAR(i)); } } /* Clear out EXPL BARs */ for (i = 0; i < 8; i++) { if (!test_bit(8 + 16 + i, used)) { writel(0, priv->gcsr + NFP_ARM_GCSR_EXPL0_BAR(i)); writel(0, priv->gcsr + NFP_ARM_GCSR_EXPL1_BAR(i)); writel(0, priv->gcsr + NFP_ARM_GCSR_EXPL2_BAR(i)); writel(0, priv->gcsr + NFP_ARM_GCSR_EXPL_POST(i)); } } return 0; } static int nfp_plat_probe(struct platform_device *pdev) { const struct of_device_id *of_id; int i, err, vnic_units; struct nfp_plat *priv; u32 model; of_id = of_match_device(nfp_plat_match, &pdev->dev); if (!of_id) { dev_err(&pdev->dev, "Failed to find devtree node\n"); return -EFAULT; } priv = kzalloc(sizeof(*priv), GFP_KERNEL); priv->target_pushpull = of_id->data; priv->dev = &pdev->dev; spin_lock_init(&priv->lock); err = nfp_plat_of(priv); if (err < 0) { dev_err(&pdev->dev, "Can't initialize device\n"); kfree(priv); return err; } /* We support multiple virtual channels over this interface */ platform_set_drvdata(pdev, priv); priv->cpp = nfp_cpp_from_operations(&nfp_plat_ops, priv->dev, priv); BUG_ON(!priv->cpp); model = nfp_cpp_model(priv->cpp); if (nfp_dev_cpp) priv->nfp_dev_cpp = nfp_platform_device_register(priv->cpp, NFP_DEV_CPP_TYPE); if (nfp_net_vnic) { if (NFP_CPP_MODEL_IS_6000(model)) vnic_units = 4; else vnic_units = 0; } else { vnic_units = 0; } for (i = 0; i < ARRAY_SIZE(priv->nfp_net_vnic); i++) { struct platform_device *pdev; if (i >= vnic_units) break; pdev = nfp_platform_device_register_unit(priv->cpp, NFP_NET_VNIC_TYPE, i, NFP_NET_VNIC_UNITS); priv->nfp_net_vnic[i] = pdev; } return 0; } static int nfp_plat_remove(struct platform_device *pdev) { struct nfp_plat *priv = platform_get_drvdata(pdev); int i; for (i = 0; i < ARRAY_SIZE(priv->nfp_net_vnic); i++) nfp_platform_device_unregister(priv->nfp_net_vnic[i]); nfp_platform_device_unregister(priv->nfp_dev_cpp); nfp_cpp_free(priv->cpp); iounmap(priv->expl_io); iounmap(priv->expl_data); iounmap(priv->gcsr); kfree(priv); platform_set_drvdata(pdev, NULL); return 0; } static struct platform_driver nfp_plat_driver = { .probe = nfp_plat_probe, .remove = __exit_p(nfp_plat_remove), .driver = { .name = "nfp_plat", .of_match_table = of_match_ptr(nfp_plat_match), #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 11, 0) .owner = THIS_MODULE, #endif }, }; /** * nfp_plat_init() - Register the NFP ARM platform driver */ int nfp_plat_init(void) { return platform_driver_register(&nfp_plat_driver); } /** * nfp_plat_exit() - Unregister the NFP ARM platform driver */ void nfp_plat_exit(void) { platform_driver_unregister(&nfp_plat_driver); } #endif /* CONFIG_ARCH_NFP */
the_stack_data/1144450.c
/* Macros */ #define MAX_COUNT_OF_NUMBERS 100 #define MAX_COUNT_OF_PRIME 1000 /* Includes */ #include <stdio.h> /* printf, scanf */ #include <limits.h> /* UINT_MAX */ typedef int PrNumberType; typedef size_t PrSizeType; typedef int PrBooleanType; typedef int PrKeyType; /** Declarations */ PrSizeType count_prime(const PrNumberType numbers[], const PrSizeType count_of_numbers); PrBooleanType is_prime(const PrNumberType num); PrSizeType add(PrSizeType n, PrNumberType primes[], const PrNumberType k); /** Definitions */ int main(void) { PrNumberType numbers[MAX_COUNT_OF_NUMBERS]; int n; int i; printf("Enter n= "); scanf("%d", &n); if(n > 9) printf("Warning: The number should be greater than %d (INT_MAX), which occurs unexpected behavior.\n", INT_MAX); printf("Enter numbers (delims by whitespace)= "); for(i = 0; i < n; ++i) { scanf("%d", &numbers[i]); } printf("Result: %d\n", count_prime(numbers, n)); return 0; } PrSizeType count_prime(const PrNumberType numbers[], const PrSizeType count_of_numbers) { PrNumberType n[count_of_numbers * count_of_numbers], /** Array which have no duplication */ p[MAX_COUNT_OF_PRIME]; /** Array to store prime numbers */ PrSizeType n_size = 0, /** Size of array `n' */ p_size = 0; /** Size of array `p' */ PrKeyType i, j, k, l; PrNumberType num; for(i = 0; i < count_of_numbers; ++i) /** Number of digits */ { for(j = 0; j + i < count_of_numbers; ++j) /** index of array */ { num = 0; l = j + i; /** index of number */ for(k = 1; l >= i; k *= 10) /** Make a number */ { num += numbers[l] * k; --l; } n_size = add(n_size, n, num); } } for(i = 0; i < n_size && p_size < MAX_COUNT_OF_PRIME; ++i) { if(is_prime(n[i])) p_size = add(p_size, p, n[i]); } return p_size; } PrBooleanType is_prime(const PrNumberType num) { PrKeyType i; if(num == 0) return 0; for(i = 2; i < num; ++i) { if(num % i == 0) return 0; } return 1; } PrSizeType add(PrSizeType n, PrNumberType primes[], const PrNumberType k) { PrKeyType point_to_insert = 0; PrKeyType i; while(point_to_insert < n && k > primes[point_to_insert]) ++point_to_insert; if(point_to_insert == n) { primes[point_to_insert] = k; ++n; } if(point_to_insert < n && primes[point_to_insert] != k) { for(i = n; i > point_to_insert; --i) primes[i] = primes[i - 1]; primes[point_to_insert] = k; ++n; } return n; }
the_stack_data/474150.c
/* This File is Part of LibFalcon. * Copyright (c) 2018, Syed Nasim 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 LibFalcon 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. */ /* * NOTE: This printk() routine uses screenwriting functions. * Implement a LF_impl_kputs() function in your kernel * or use the textmode addon provided by LibFalcon itself. */ #include <stdarg.h> #include <string.h> unsigned char * buf; int printk(const char *fmt, ...) { va_list args; int i; va_start(args, fmt); i = vsprintf(buf, fmt, args); va_end(args); LF_impl_kputs(buf); return i; }
the_stack_data/64199338.c
#include <stdio.h> #include <stdlib.h> int main(void) { int num = 150; int *pNum = NULL; pNum = &num; printf("num address is: %p\n", &num); printf("Address of pNum: %p\n", &pNum); printf("value of the pNum: %p\n", pNum); printf("value of what pNum is pointing to: %d\n", *pNum); return (0); }
the_stack_data/232955123.c
/* * Copyright (C) 2006 Edmund GRIMLEY EVANS <[email protected]> * * 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 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* Two small modifications to avoid signed arithmetic by Jörg Mische */ /* * A self-compiling compiler for a small subset of C. */ /* Our library functions. */ void exit(int); int getchar(void); void *malloc(int); int putchar(int); /* The first thing defined must be main(). */ int main1(); int main() { return main1(); } char *my_realloc(char *old, int oldlen, int newlen) { char *new = malloc(newlen); int i = 0; while (i + 1 <= oldlen) /* was (i <= oldlen - 1) */{ new[i] = old[i]; i = i + 1; } return new; } int nextc; char *token; int token_size; void error() { exit(1); } int i; void takechar() { if (token_size <= i + 1) { int x = (i + 10) << 1; token = my_realloc(token, token_size, x); token_size = x; } token[i] = nextc; i = i + 1; nextc = getchar(); } void get_token() { int w = 1; while (w) { w = 0; while ((nextc == ' ') | (nextc == 9) | (nextc == 10)) nextc = getchar(); i = 0; while ((('a' <= nextc) & (nextc <= 'z')) | (('0' <= nextc) & (nextc <= '9')) | (nextc == '_')) takechar(); if (i == 0) while ((nextc == '<') | (nextc == '=') | (nextc == '>') | (nextc == '|') | (nextc == '&') | (nextc == '!')) takechar(); if (i == 0) { if (nextc == 39) { takechar(); while (nextc != 39) takechar(); takechar(); } else if (nextc == '"') { takechar(); while (nextc != '"') takechar(); takechar(); } else if (nextc == '/') { takechar(); if (nextc == '*') { nextc = getchar(); while (nextc != '/') { while (nextc != '*') nextc = getchar(); nextc = getchar(); } nextc = getchar(); w = 1; } } else if (nextc != 0-1) takechar(); } token[i] = 0; } } int peek(char *s) { int i = 0; while ((s[i] == token[i]) & (s[i] != 0)) i = i + 1; return s[i] == token[i]; } int accept(char *s) { if (peek(s)) { get_token(); return 1; } else return 0; } void expect(char *s) { if (accept(s) == 0) error(); } char *code; int code_size; int codepos; int code_offset; void save_int(char *p, int n) { p[0] = n; p[1] = n >> 8; p[2] = n >> 16; p[3] = n >> 24; } int load_int(char *p) { return ((p[0] & 255) + ((p[1] & 255) << 8) + ((p[2] & 255) << 16) + ((p[3] & 255) << 24)); } void emit(int n, char *s) { i = 0; if (code_size <= codepos + n) { int x = (codepos + n) << 1; code = my_realloc(code, code_size, x); code_size = x; } while (i <= n - 1) { code[codepos] = s[i]; codepos = codepos + 1; i = i + 1; } } void be_push() { emit(1, "\x50"); /* push %eax */ } void be_pop(int n) { emit(6, "\x81\xc4...."); /* add $(n * 4),%esp */ save_int(code + codepos - 4, n << 2); } char *table; int table_size; int table_pos; int stack_pos; int sym_lookup(char *s) { int t = 0; int current_symbol = 0; while (t + 1 <= table_pos) /* was (t <= table_pos - 1) */ { i = 0; while ((s[i] == table[t]) & (s[i] != 0)) { i = i + 1; t = t + 1; } if (s[i] == table[t]) current_symbol = t; while (table[t] != 0) t = t + 1; t = t + 6; } return current_symbol; } void sym_declare(char *s, int type, int value) { int t = table_pos; i = 0; while (s[i] != 0) { if (table_size <= t + 10) { int x = (t + 10) << 1; table = my_realloc(table, table_size, x); table_size = x; } table[t] = s[i]; i = i + 1; t = t + 1; } table[t] = 0; table[t + 1] = type; save_int(table + t + 2, value); table_pos = t + 6; } int sym_declare_global(char *s) { int current_symbol = sym_lookup(s); if (current_symbol == 0) { sym_declare(s, 'U', code_offset); current_symbol = table_pos - 6; } return current_symbol; } void sym_define_global(int current_symbol) { int i; int j; int t = current_symbol; int v = codepos + code_offset; if (table[t + 1] != 'U') error(); /* symbol redefined */ i = load_int(table + t + 2) - code_offset; while (i) { j = load_int(code + i) - code_offset; save_int(code + i, v); i = j; } table[t + 1] = 'D'; save_int(table + t + 2, v); } int number_of_args; void sym_get_value(char *s) { int t; if ((t = sym_lookup(s)) == 0) error(); emit(5, "\xb8...."); /* mov $n,%eax */ save_int(code + codepos - 4, load_int(table + t + 2)); if (table[t + 1] == 'D') { /* defined global */ } else if (table[t + 1] == 'U') /* undefined global */ save_int(table + t + 2, codepos + code_offset - 4); else if (table[t + 1] == 'L') { /* local variable */ int k = (stack_pos - table[t + 2] - 1) << 2; emit(7, "\x8d\x84\x24...."); /* lea (n * 4)(%esp),%eax */ save_int(code + codepos - 4, k); } else if (table[t + 1] == 'A') { /* argument */ int k = (stack_pos + number_of_args - table[t + 2] + 1) << 2; emit(7, "\x8d\x84\x24...."); /* lea (n * 4)(%esp),%eax */ save_int(code + codepos - 4, k); } else error(); } void be_start() { emit(16, "\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00"); emit(16, "\x02\x00\x03\x00\x01\x00\x00\x00\x54\x80\x04\x08\x34\x00\x00\x00"); emit(16, "\x00\x00\x00\x00\x00\x00\x00\x00\x34\x00\x20\x00\x01\x00\x00\x00"); emit(16, "\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x80\x04\x08"); emit(16, "\x00\x80\x04\x08\x10\x4b\x00\x00\x10\x4b\x00\x00\x07\x00\x00\x00"); emit(16, "\x00\x10\x00\x00\xe8\x00\x00\x00\x00\x89\xc3\x31\xc0\x40\xcd\x80"); sym_define_global(sym_declare_global("exit")); /* pop %ebx ; pop %ebx ; xor %eax,%eax ; inc %eax ; int $0x80 */ emit(7, "\x5b\x5b\x31\xc0\x40\xcd\x80"); sym_define_global(sym_declare_global("getchar")); /* mov $3,%eax ; xor %ebx,%ebx ; push %ebx ; mov %esp,%ecx */ emit(10, "\xb8\x03\x00\x00\x00\x31\xdb\x53\x89\xe1"); /* xor %edx,%edx ; inc %edx ; int $0x80 */ /* test %eax,%eax ; pop %eax ; jne . + 7 */ emit(10, "\x31\xd2\x42\xcd\x80\x85\xc0\x58\x75\x05"); /* mov $-1,%eax ; ret */ emit(6, "\xb8\xff\xff\xff\xff\xc3"); sym_define_global(sym_declare_global("malloc")); /* mov 4(%esp),%eax */ emit(4, "\x8b\x44\x24\x04"); /* push %eax ; xor %ebx,%ebx ; mov $45,%eax ; int $0x80 */ emit(10, "\x50\x31\xdb\xb8\x2d\x00\x00\x00\xcd\x80"); /* pop %ebx ; add %eax,%ebx ; push %eax ; push %ebx ; mov $45,%eax */ emit(10, "\x5b\x01\xc3\x50\x53\xb8\x2d\x00\x00\x00"); /* int $0x80 ; pop %ebx ; cmp %eax,%ebx ; pop %eax ; je . + 7 */ emit(8, "\xcd\x80\x5b\x39\xc3\x58\x74\x05"); /* mov $-1,%eax ; ret */ emit(6, "\xb8\xff\xff\xff\xff\xc3"); sym_define_global(sym_declare_global("putchar")); /* mov $4,%eax ; xor %ebx,%ebx ; inc %ebx */ emit(8, "\xb8\x04\x00\x00\x00\x31\xdb\x43"); /* lea 4(%esp),%ecx ; mov %ebx,%edx ; int $0x80 ; ret */ emit(9, "\x8d\x4c\x24\x04\x89\xda\xcd\x80\xc3"); save_int(code + 85, codepos - 89); /* entry set to first thing in file */ } void be_finish() { save_int(code + 68, codepos); save_int(code + 72, codepos); i = 0; while (i <= codepos - 1) { putchar(code[i]); i = i + 1; } } void promote(int type) { /* 1 = char lval, 2 = int lval, 3 = other */ if (type == 1) emit(3, "\x0f\xbe\x00"); /* movsbl (%eax),%eax */ else if (type == 2) emit(2, "\x8b\x00"); /* mov (%eax),%eax */ } int expression(); /* * primary-expr: * identifier * constant * ( expression ) */ int primary_expr() { int type; if (('0' <= token[0]) & (token[0] <= '9')) { int n = 0; i = 0; while (token[i]) { n = (n << 1) + (n << 3) + token[i] - '0'; i = i + 1; } emit(5, "\xb8...."); /* mov $x,%eax */ save_int(code + codepos - 4, n); type = 3; } else if (('a' <= token[0]) & (token[0] <= 'z')) { sym_get_value(token); type = 2; } else if (accept("(")) { type = expression(); if (peek(")") == 0) error(); } else if ((token[0] == 39) & (token[1] != 0) & (token[2] == 39) & (token[3] == 0)) { emit(5, "\xb8...."); /* mov $x,%eax */ save_int(code + codepos - 4, token[1]); type = 3; } else if (token[0] == '"') { int i = 0; int j = 1; int k; while (token[j] != '"') { if ((token[j] == 92) & (token[j + 1] == 'x')) { if (token[j + 2] <= '9') k = token[j + 2] - '0'; else k = token[j + 2] - 'a' + 10; k = k << 4; if (token[j + 3] <= '9') k = k + token[j + 3] - '0'; else k = k + token[j + 3] - 'a' + 10; token[i] = k; j = j + 4; } else { token[i] = token[j]; j = j + 1; } i = i + 1; } token[i] = 0; /* call ... ; the string ; pop %eax */ emit(5, "\xe8...."); save_int(code + codepos - 4, i + 1); emit(i + 1, token); emit(1, "\x58"); type = 3; } else error(); get_token(); return type; } void binary1(int type) { promote(type); be_push(); stack_pos = stack_pos + 1; } int binary2(int type, int n, char *s) { promote(type); emit(n, s); stack_pos = stack_pos - 1; return 3; } /* * postfix-expr: * primary-expr * postfix-expr [ expression ] * postfix-expr ( expression-list-opt ) */ int postfix_expr() { int type = primary_expr(); if (accept("[")) { binary1(type); /* pop %ebx ; add %ebx,%eax */ binary2(expression(), 3, "\x5b\x01\xd8"); expect("]"); type = 1; } else if (accept("(")) { int s = stack_pos; be_push(); stack_pos = stack_pos + 1; if (accept(")") == 0) { promote(expression()); be_push(); stack_pos = stack_pos + 1; while (accept(",")) { promote(expression()); be_push(); stack_pos = stack_pos + 1; } expect(")"); } emit(7, "\x8b\x84\x24...."); /* mov (n * 4)(%esp),%eax */ save_int(code + codepos - 4, (stack_pos - s - 1) << 2); emit(2, "\xff\xd0"); /* call *%eax */ be_pop(stack_pos - s); stack_pos = s; type = 3; } return type; } /* * additive-expr: * postfix-expr * additive-expr + postfix-expr * additive-expr - postfix-expr */ int additive_expr() { int type = postfix_expr(); while (1) { if (accept("+")) { binary1(type); /* pop %ebx ; add %ebx,%eax */ type = binary2(postfix_expr(), 3, "\x5b\x01\xd8"); } else if (accept("-")) { binary1(type); /* pop %ebx ; sub %eax,%ebx ; mov %ebx,%eax */ type = binary2(postfix_expr(), 5, "\x5b\x29\xc3\x89\xd8"); } else return type; } } /* * shift-expr: * additive-expr * shift-expr << additive-expr * shift-expr >> additive-expr */ int shift_expr() { int type = additive_expr(); while (1) { if (accept("<<")) { binary1(type); /* mov %eax,%ecx ; pop %eax ; shl %cl,%eax */ type = binary2(additive_expr(), 5, "\x89\xc1\x58\xd3\xe0"); } else if (accept(">>")) { binary1(type); /* mov %eax,%ecx ; pop %eax ; sar %cl,%eax */ type = binary2(additive_expr(), 5, "\x89\xc1\x58\xd3\xf8"); } else return type; } } /* * relational-expr: * shift-expr * relational-expr <= shift-expr */ int relational_expr() { int type = shift_expr(); while (accept("<=")) { binary1(type); /* pop %ebx ; cmp %eax,%ebx ; setle %al ; movzbl %al,%eax */ type = binary2(shift_expr(), 9, "\x5b\x39\xc3\x0f\x9e\xc0\x0f\xb6\xc0"); } return type; } /* * equality-expr: * relational-expr * equality-expr == relational-expr * equality-expr != relational-expr */ int equality_expr() { int type = relational_expr(); while (1) { if (accept("==")) { binary1(type); /* pop %ebx ; cmp %eax,%ebx ; sete %al ; movzbl %al,%eax */ type = binary2(relational_expr(), 9, "\x5b\x39\xc3\x0f\x94\xc0\x0f\xb6\xc0"); } else if (accept("!=")) { binary1(type); /* pop %ebx ; cmp %eax,%ebx ; setne %al ; movzbl %al,%eax */ type = binary2(relational_expr(), 9, "\x5b\x39\xc3\x0f\x95\xc0\x0f\xb6\xc0"); } else return type; } } /* * bitwise-and-expr: * equality-expr * bitwise-and-expr & equality-expr */ int bitwise_and_expr() { int type = equality_expr(); while (accept("&")) { binary1(type); /* pop %ebx ; and %ebx,%eax */ type = binary2(equality_expr(), 3, "\x5b\x21\xd8"); } return type; } /* * bitwise-or-expr: * bitwise-and-expr * bitwise-and-expr | bitwise-or-expr */ int bitwise_or_expr() { int type = bitwise_and_expr(); while (accept("|")) { binary1(type); /* pop %ebx ; or %ebx,%eax */ type = binary2(bitwise_and_expr(), 3, "\x5b\x09\xd8"); } return type; } /* * expression: * bitwise-or-expr * bitwise-or-expr = expression */ int expression() { int type = bitwise_or_expr(); if (accept("=")) { be_push(); stack_pos = stack_pos + 1; promote(expression()); if (type == 2) emit(3, "\x5b\x89\x03"); /* pop %ebx ; mov %eax,(%ebx) */ else emit(3, "\x5b\x88\x03"); /* pop %ebx ; mov %al,(%ebx) */ stack_pos = stack_pos - 1; type = 3; } return type; } /* * type-name: * char * * int */ void type_name() { get_token(); while (accept("*")) { } } /* * statement: * { statement-list-opt } * type-name identifier ; * type-name identifier = expression; * if ( expression ) statement * if ( expression ) statement else statement * while ( expression ) statement * return ; * expr ; */ void statement() { int p1; int p2; if (accept("{")) { int n = table_pos; int s = stack_pos; while (accept("}") == 0) statement(); table_pos = n; be_pop(stack_pos - s); stack_pos = s; } else if (peek("char") | peek("int")) { type_name(); sym_declare(token, 'L', stack_pos); get_token(); if (accept("=")) promote(expression()); expect(";"); be_push(); stack_pos = stack_pos + 1; } else if (accept("if")) { expect("("); promote(expression()); emit(8, "\x85\xc0\x0f\x84...."); /* test %eax,%eax ; je ... */ p1 = codepos; expect(")"); statement(); emit(5, "\xe9...."); /* jmp ... */ p2 = codepos; save_int(code + p1 - 4, codepos - p1); if (accept("else")) statement(); save_int(code + p2 - 4, codepos - p2); } else if (accept("while")) { expect("("); p1 = codepos; promote(expression()); emit(8, "\x85\xc0\x0f\x84...."); /* test %eax,%eax ; je ... */ p2 = codepos; expect(")"); statement(); emit(5, "\xe9...."); /* jmp ... */ save_int(code + codepos - 4, p1 - codepos); save_int(code + p2 - 4, codepos - p2); } else if (accept("return")) { if (peek(";") == 0) promote(expression()); expect(";"); be_pop(stack_pos); emit(1, "\xc3"); /* ret */ } else { expression(); expect(";"); } } /* * program: * declaration * declaration program * * declaration: * type-name identifier ; * type-name identifier ( parameter-list ) ; * type-name identifier ( parameter-list ) statement * * parameter-list: * parameter-declaration * parameter-list, parameter-declaration * * parameter-declaration: * type-name identifier-opt */ void program() { int current_symbol; while (token[0]) { type_name(); current_symbol = sym_declare_global(token); get_token(); if (accept(";")) { sym_define_global(current_symbol); emit(4, "\x00\x00\x00\x00"); } else if (accept("(")) { int n = table_pos; number_of_args = 0; while (accept(")") == 0) { number_of_args = number_of_args + 1; type_name(); if (peek(")") == 0) { sym_declare(token, 'A', number_of_args); get_token(); } accept(","); /* ignore trailing comma */ } if (accept(";") == 0) { sym_define_global(current_symbol); statement(); emit(1, "\xc3"); /* ret */ } table_pos = n; } else error(); } } int main1() { code_offset = 134512640; /* 0x08048000 */ be_start(); nextc = getchar(); get_token(); program(); be_finish(); return 0; }
the_stack_data/51700279.c
/*** * This code is a part of EvoApproxLib library (ehw.fit.vutbr.cz/approxlib) distributed under The MIT License. * When used, please cite the following article(s): V. Mrazek, Z. Vasicek, L. Sekanina, H. Jiang and J. Han, "Scalable Construction of Approximate Multipliers With Formally Guaranteed Worst Case Error" in IEEE Transactions on Very Large Scale Integration (VLSI) Systems, vol. 26, no. 11, pp. 2572-2576, Nov. 2018. doi: 10.1109/TVLSI.2018.2856362 * This file contains a circuit from a sub-set of pareto optimal circuits with respect to the pwr and mre parameters ***/ // MAE% = 0.19 % // MAE = 32256 // WCE% = 0.77 % // WCE = 129024 // WCRE% = 6300.00 % // EP% = 98.41 % // MRE% = 12.72 % // MSE = 18643.684e5 // PDK45_PWR = 0.497 mW // PDK45_AREA = 874.8 um2 // PDK45_DELAY = 1.78 ns #include <stdint.h> #include <stdlib.h> int32_t mul12s_2NM(int16_t A, int16_t B) { int32_t P, P_; uint16_t tmp, C_10_0,C_10_1,C_10_10,C_10_11,C_10_2,C_10_3,C_10_4,C_10_5,C_10_6,C_10_7,C_10_8,C_10_9,C_11_0,C_11_1,C_11_10,C_11_11,C_11_2,C_11_3,C_11_4,C_11_5,C_11_6,C_11_7,C_11_8,C_11_9,C_12_0,C_12_1,C_12_10,C_12_11,C_12_2,C_12_3,C_12_4,C_12_5,C_12_6,C_12_7,C_12_8,C_12_9,C_6_11,C_6_5,C_7_0,C_7_1,C_7_10,C_7_11,C_7_2,C_7_3,C_7_4,C_7_5,C_7_6,C_7_7,C_7_8,C_7_9,C_8_0,C_8_1,C_8_10,C_8_11,C_8_2,C_8_3,C_8_4,C_8_5,C_8_6,C_8_7,C_8_8,C_8_9,C_9_0,C_9_1,C_9_10,C_9_11,C_9_2,C_9_3,C_9_4,C_9_5,C_9_6,C_9_7,C_9_8,C_9_9,S_0_11,S_10_0,S_10_1,S_10_10,S_10_11,S_10_2,S_10_3,S_10_4,S_10_5,S_10_6,S_10_7,S_10_8,S_10_9,S_11_0,S_11_1,S_11_10,S_11_11,S_11_2,S_11_3,S_11_4,S_11_5,S_11_6,S_11_7,S_11_8,S_11_9,S_12_0,S_12_1,S_12_10,S_12_11,S_12_2,S_12_3,S_12_4,S_12_5,S_12_6,S_12_7,S_12_8,S_12_9,S_1_10,S_2_9,S_3_8,S_4_7,S_5_6,S_6_0,S_6_1,S_6_10,S_6_11,S_6_2,S_6_3,S_6_4,S_6_5,S_6_6,S_6_7,S_6_8,S_6_9,S_7_0,S_7_1,S_7_10,S_7_11,S_7_2,S_7_3,S_7_4,S_7_5,S_7_6,S_7_7,S_7_8,S_7_9,S_8_0,S_8_1,S_8_10,S_8_11,S_8_2,S_8_3,S_8_4,S_8_5,S_8_6,S_8_7,S_8_8,S_8_9,S_9_0,S_9_1,S_9_10,S_9_11,S_9_2,S_9_3,S_9_4,S_9_5,S_9_6,S_9_7,S_9_8,S_9_9; S_0_11 = 1; S_1_10 = 1; S_2_9 = 1; S_3_8 = 1; S_4_7 = 1; S_5_6 = 1; S_6_0 = (((A>>6)&1) & ((B>>0)&1)); S_6_1 = (((A>>6)&1) & ((B>>1)&1)); S_6_2 = (((A>>6)&1) & ((B>>2)&1)); S_6_3 = (((A>>6)&1) & ((B>>3)&1)); S_6_4 = (((A>>6)&1) & ((B>>4)&1)); S_6_5 = S_5_6^(((A>>6)&1) & ((B>>5)&1)); C_6_5 = S_5_6&(((A>>6)&1) & ((B>>5)&1)); S_6_6 = (((A>>6)&1) & ((B>>6)&1)); S_6_7 = (((A>>6)&1) & ((B>>7)&1)); S_6_8 = (((A>>6)&1) & ((B>>8)&1)); S_6_9 = (((A>>6)&1) & ((B>>9)&1)); S_6_10 = (((A>>6)&1) & ((B>>10)&1)); S_6_11 = 1^(((((A>>6)&1) & ((B>>11)&1)))^1); C_6_11 = 1&(((((A>>6)&1) & ((B>>11)&1)))^1); S_7_0 = S_6_1^(((A>>7)&1) & ((B>>0)&1)); C_7_0 = S_6_1&(((A>>7)&1) & ((B>>0)&1)); S_7_1 = S_6_2^(((A>>7)&1) & ((B>>1)&1)); C_7_1 = S_6_2&(((A>>7)&1) & ((B>>1)&1)); S_7_2 = S_6_3^(((A>>7)&1) & ((B>>2)&1)); C_7_2 = S_6_3&(((A>>7)&1) & ((B>>2)&1)); S_7_3 = S_6_4^(((A>>7)&1) & ((B>>3)&1)); C_7_3 = S_6_4&(((A>>7)&1) & ((B>>3)&1)); S_7_4 = S_6_5^(((A>>7)&1) & ((B>>4)&1)); C_7_4 = S_6_5&(((A>>7)&1) & ((B>>4)&1)); tmp = S_6_6^C_6_5; S_7_5 = tmp^(((A>>7)&1) & ((B>>5)&1)); C_7_5 = (tmp&(((A>>7)&1) & ((B>>5)&1)))|(S_6_6&C_6_5); S_7_6 = S_6_7^(((A>>7)&1) & ((B>>6)&1)); C_7_6 = S_6_7&(((A>>7)&1) & ((B>>6)&1)); S_7_7 = S_6_8^(((A>>7)&1) & ((B>>7)&1)); C_7_7 = S_6_8&(((A>>7)&1) & ((B>>7)&1)); S_7_8 = S_6_9^(((A>>7)&1) & ((B>>8)&1)); C_7_8 = S_6_9&(((A>>7)&1) & ((B>>8)&1)); S_7_9 = S_6_10^(((A>>7)&1) & ((B>>9)&1)); C_7_9 = S_6_10&(((A>>7)&1) & ((B>>9)&1)); S_7_10 = S_6_11^(((A>>7)&1) & ((B>>10)&1)); C_7_10 = S_6_11&(((A>>7)&1) & ((B>>10)&1)); S_7_11 = C_6_11^(((((A>>7)&1) & ((B>>11)&1)))^1); C_7_11 = C_6_11&(((((A>>7)&1) & ((B>>11)&1)))^1); tmp = S_7_1^C_7_0; S_8_0 = tmp^(((A>>8)&1) & ((B>>0)&1)); C_8_0 = (tmp&(((A>>8)&1) & ((B>>0)&1)))|(S_7_1&C_7_0); tmp = S_7_2^C_7_1; S_8_1 = tmp^(((A>>8)&1) & ((B>>1)&1)); C_8_1 = (tmp&(((A>>8)&1) & ((B>>1)&1)))|(S_7_2&C_7_1); tmp = S_7_3^C_7_2; S_8_2 = tmp^(((A>>8)&1) & ((B>>2)&1)); C_8_2 = (tmp&(((A>>8)&1) & ((B>>2)&1)))|(S_7_3&C_7_2); tmp = S_7_4^C_7_3; S_8_3 = tmp^(((A>>8)&1) & ((B>>3)&1)); C_8_3 = (tmp&(((A>>8)&1) & ((B>>3)&1)))|(S_7_4&C_7_3); tmp = S_7_5^C_7_4; S_8_4 = tmp^(((A>>8)&1) & ((B>>4)&1)); C_8_4 = (tmp&(((A>>8)&1) & ((B>>4)&1)))|(S_7_5&C_7_4); tmp = S_7_6^C_7_5; S_8_5 = tmp^(((A>>8)&1) & ((B>>5)&1)); C_8_5 = (tmp&(((A>>8)&1) & ((B>>5)&1)))|(S_7_6&C_7_5); tmp = S_7_7^C_7_6; S_8_6 = tmp^(((A>>8)&1) & ((B>>6)&1)); C_8_6 = (tmp&(((A>>8)&1) & ((B>>6)&1)))|(S_7_7&C_7_6); tmp = S_7_8^C_7_7; S_8_7 = tmp^(((A>>8)&1) & ((B>>7)&1)); C_8_7 = (tmp&(((A>>8)&1) & ((B>>7)&1)))|(S_7_8&C_7_7); tmp = S_7_9^C_7_8; S_8_8 = tmp^(((A>>8)&1) & ((B>>8)&1)); C_8_8 = (tmp&(((A>>8)&1) & ((B>>8)&1)))|(S_7_9&C_7_8); tmp = S_7_10^C_7_9; S_8_9 = tmp^(((A>>8)&1) & ((B>>9)&1)); C_8_9 = (tmp&(((A>>8)&1) & ((B>>9)&1)))|(S_7_10&C_7_9); tmp = S_7_11^C_7_10; S_8_10 = tmp^(((A>>8)&1) & ((B>>10)&1)); C_8_10 = (tmp&(((A>>8)&1) & ((B>>10)&1)))|(S_7_11&C_7_10); S_8_11 = C_7_11^(((((A>>8)&1) & ((B>>11)&1)))^1); C_8_11 = C_7_11&(((((A>>8)&1) & ((B>>11)&1)))^1); tmp = S_8_1^C_8_0; S_9_0 = tmp^(((A>>9)&1) & ((B>>0)&1)); C_9_0 = (tmp&(((A>>9)&1) & ((B>>0)&1)))|(S_8_1&C_8_0); tmp = S_8_2^C_8_1; S_9_1 = tmp^(((A>>9)&1) & ((B>>1)&1)); C_9_1 = (tmp&(((A>>9)&1) & ((B>>1)&1)))|(S_8_2&C_8_1); tmp = S_8_3^C_8_2; S_9_2 = tmp^(((A>>9)&1) & ((B>>2)&1)); C_9_2 = (tmp&(((A>>9)&1) & ((B>>2)&1)))|(S_8_3&C_8_2); tmp = S_8_4^C_8_3; S_9_3 = tmp^(((A>>9)&1) & ((B>>3)&1)); C_9_3 = (tmp&(((A>>9)&1) & ((B>>3)&1)))|(S_8_4&C_8_3); tmp = S_8_5^C_8_4; S_9_4 = tmp^(((A>>9)&1) & ((B>>4)&1)); C_9_4 = (tmp&(((A>>9)&1) & ((B>>4)&1)))|(S_8_5&C_8_4); tmp = S_8_6^C_8_5; S_9_5 = tmp^(((A>>9)&1) & ((B>>5)&1)); C_9_5 = (tmp&(((A>>9)&1) & ((B>>5)&1)))|(S_8_6&C_8_5); tmp = S_8_7^C_8_6; S_9_6 = tmp^(((A>>9)&1) & ((B>>6)&1)); C_9_6 = (tmp&(((A>>9)&1) & ((B>>6)&1)))|(S_8_7&C_8_6); tmp = S_8_8^C_8_7; S_9_7 = tmp^(((A>>9)&1) & ((B>>7)&1)); C_9_7 = (tmp&(((A>>9)&1) & ((B>>7)&1)))|(S_8_8&C_8_7); tmp = S_8_9^C_8_8; S_9_8 = tmp^(((A>>9)&1) & ((B>>8)&1)); C_9_8 = (tmp&(((A>>9)&1) & ((B>>8)&1)))|(S_8_9&C_8_8); tmp = S_8_10^C_8_9; S_9_9 = tmp^(((A>>9)&1) & ((B>>9)&1)); C_9_9 = (tmp&(((A>>9)&1) & ((B>>9)&1)))|(S_8_10&C_8_9); tmp = S_8_11^C_8_10; S_9_10 = tmp^(((A>>9)&1) & ((B>>10)&1)); C_9_10 = (tmp&(((A>>9)&1) & ((B>>10)&1)))|(S_8_11&C_8_10); S_9_11 = C_8_11^(((((A>>9)&1) & ((B>>11)&1)))^1); C_9_11 = C_8_11&(((((A>>9)&1) & ((B>>11)&1)))^1); tmp = S_9_1^C_9_0; S_10_0 = tmp^(((A>>10)&1) & ((B>>0)&1)); C_10_0 = (tmp&(((A>>10)&1) & ((B>>0)&1)))|(S_9_1&C_9_0); tmp = S_9_2^C_9_1; S_10_1 = tmp^(((A>>10)&1) & ((B>>1)&1)); C_10_1 = (tmp&(((A>>10)&1) & ((B>>1)&1)))|(S_9_2&C_9_1); tmp = S_9_3^C_9_2; S_10_2 = tmp^(((A>>10)&1) & ((B>>2)&1)); C_10_2 = (tmp&(((A>>10)&1) & ((B>>2)&1)))|(S_9_3&C_9_2); tmp = S_9_4^C_9_3; S_10_3 = tmp^(((A>>10)&1) & ((B>>3)&1)); C_10_3 = (tmp&(((A>>10)&1) & ((B>>3)&1)))|(S_9_4&C_9_3); tmp = S_9_5^C_9_4; S_10_4 = tmp^(((A>>10)&1) & ((B>>4)&1)); C_10_4 = (tmp&(((A>>10)&1) & ((B>>4)&1)))|(S_9_5&C_9_4); tmp = S_9_6^C_9_5; S_10_5 = tmp^(((A>>10)&1) & ((B>>5)&1)); C_10_5 = (tmp&(((A>>10)&1) & ((B>>5)&1)))|(S_9_6&C_9_5); tmp = S_9_7^C_9_6; S_10_6 = tmp^(((A>>10)&1) & ((B>>6)&1)); C_10_6 = (tmp&(((A>>10)&1) & ((B>>6)&1)))|(S_9_7&C_9_6); tmp = S_9_8^C_9_7; S_10_7 = tmp^(((A>>10)&1) & ((B>>7)&1)); C_10_7 = (tmp&(((A>>10)&1) & ((B>>7)&1)))|(S_9_8&C_9_7); tmp = S_9_9^C_9_8; S_10_8 = tmp^(((A>>10)&1) & ((B>>8)&1)); C_10_8 = (tmp&(((A>>10)&1) & ((B>>8)&1)))|(S_9_9&C_9_8); tmp = S_9_10^C_9_9; S_10_9 = tmp^(((A>>10)&1) & ((B>>9)&1)); C_10_9 = (tmp&(((A>>10)&1) & ((B>>9)&1)))|(S_9_10&C_9_9); tmp = S_9_11^C_9_10; S_10_10 = tmp^(((A>>10)&1) & ((B>>10)&1)); C_10_10 = (tmp&(((A>>10)&1) & ((B>>10)&1)))|(S_9_11&C_9_10); S_10_11 = C_9_11^(((((A>>10)&1) & ((B>>11)&1)))^1); C_10_11 = C_9_11&(((((A>>10)&1) & ((B>>11)&1)))^1); tmp = S_10_1^C_10_0; S_11_0 = tmp^(((((A>>11)&1) & ((B>>0)&1)))^1); C_11_0 = (tmp&(((((A>>11)&1) & ((B>>0)&1)))^1))|(S_10_1&C_10_0); tmp = S_10_2^C_10_1; S_11_1 = tmp^(((((A>>11)&1) & ((B>>1)&1)))^1); C_11_1 = (tmp&(((((A>>11)&1) & ((B>>1)&1)))^1))|(S_10_2&C_10_1); tmp = S_10_3^C_10_2; S_11_2 = tmp^(((((A>>11)&1) & ((B>>2)&1)))^1); C_11_2 = (tmp&(((((A>>11)&1) & ((B>>2)&1)))^1))|(S_10_3&C_10_2); tmp = S_10_4^C_10_3; S_11_3 = tmp^(((((A>>11)&1) & ((B>>3)&1)))^1); C_11_3 = (tmp&(((((A>>11)&1) & ((B>>3)&1)))^1))|(S_10_4&C_10_3); tmp = S_10_5^C_10_4; S_11_4 = tmp^(((((A>>11)&1) & ((B>>4)&1)))^1); C_11_4 = (tmp&(((((A>>11)&1) & ((B>>4)&1)))^1))|(S_10_5&C_10_4); tmp = S_10_6^C_10_5; S_11_5 = tmp^(((((A>>11)&1) & ((B>>5)&1)))^1); C_11_5 = (tmp&(((((A>>11)&1) & ((B>>5)&1)))^1))|(S_10_6&C_10_5); tmp = S_10_7^C_10_6; S_11_6 = tmp^(((((A>>11)&1) & ((B>>6)&1)))^1); C_11_6 = (tmp&(((((A>>11)&1) & ((B>>6)&1)))^1))|(S_10_7&C_10_6); tmp = S_10_8^C_10_7; S_11_7 = tmp^(((((A>>11)&1) & ((B>>7)&1)))^1); C_11_7 = (tmp&(((((A>>11)&1) & ((B>>7)&1)))^1))|(S_10_8&C_10_7); tmp = S_10_9^C_10_8; S_11_8 = tmp^(((((A>>11)&1) & ((B>>8)&1)))^1); C_11_8 = (tmp&(((((A>>11)&1) & ((B>>8)&1)))^1))|(S_10_9&C_10_8); tmp = S_10_10^C_10_9; S_11_9 = tmp^(((((A>>11)&1) & ((B>>9)&1)))^1); C_11_9 = (tmp&(((((A>>11)&1) & ((B>>9)&1)))^1))|(S_10_10&C_10_9); tmp = S_10_11^C_10_10; S_11_10 = tmp^(((((A>>11)&1) & ((B>>10)&1)))^1); C_11_10 = (tmp&(((((A>>11)&1) & ((B>>10)&1)))^1))|(S_10_11&C_10_10); S_11_11 = C_10_11^(((A>>11)&1) & ((B>>11)&1)); C_11_11 = C_10_11&(((A>>11)&1) & ((B>>11)&1)); S_12_0 = S_11_1^C_11_0; C_12_0 = S_11_1&C_11_0; tmp = S_11_2^C_12_0; S_12_1 = tmp^C_11_1; C_12_1 = (tmp&C_11_1)|(S_11_2&C_12_0); tmp = S_11_3^C_12_1; S_12_2 = tmp^C_11_2; C_12_2 = (tmp&C_11_2)|(S_11_3&C_12_1); tmp = S_11_4^C_12_2; S_12_3 = tmp^C_11_3; C_12_3 = (tmp&C_11_3)|(S_11_4&C_12_2); tmp = S_11_5^C_12_3; S_12_4 = tmp^C_11_4; C_12_4 = (tmp&C_11_4)|(S_11_5&C_12_3); tmp = S_11_6^C_12_4; S_12_5 = tmp^C_11_5; C_12_5 = (tmp&C_11_5)|(S_11_6&C_12_4); tmp = S_11_7^C_12_5; S_12_6 = tmp^C_11_6; C_12_6 = (tmp&C_11_6)|(S_11_7&C_12_5); tmp = S_11_8^C_12_6; S_12_7 = tmp^C_11_7; C_12_7 = (tmp&C_11_7)|(S_11_8&C_12_6); tmp = S_11_9^C_12_7; S_12_8 = tmp^C_11_8; C_12_8 = (tmp&C_11_8)|(S_11_9&C_12_7); tmp = S_11_10^C_12_8; S_12_9 = tmp^C_11_9; C_12_9 = (tmp&C_11_9)|(S_11_10&C_12_8); tmp = S_11_11^C_12_9; S_12_10 = tmp^C_11_10; C_12_10 = (tmp&C_11_10)|(S_11_11&C_12_9); tmp = 1^C_12_10; S_12_11 = tmp^C_11_11; C_12_11 = (tmp&C_11_11)|(1&C_12_10); P = 0; P |= (S_6_0 & 1) << 6; P |= (S_7_0 & 1) << 7; P |= (S_8_0 & 1) << 8; P |= (S_9_0 & 1) << 9; P |= (S_10_0 & 1) << 10; P |= (S_11_0 & 1) << 11; P |= (S_12_0 & 1) << 12; P |= (S_12_1 & 1) << 13; P |= (S_12_2 & 1) << 14; P |= (S_12_3 & 1) << 15; P |= (S_12_4 & 1) << 16; P |= (S_12_5 & 1) << 17; P |= (S_12_6 & 1) << 18; P |= (S_12_7 & 1) << 19; P |= (S_12_8 & 1) << 20; P |= (S_12_9 & 1) << 21; P |= (S_12_10 & 1) << 22; P |= (S_12_11 & 1) << 23; return P; }
the_stack_data/92326527.c
extern void abort(void); void reach_error(){} void __VERIFIER_assert(int cond) { if (!(cond)) { ERROR: {reach_error();abort();} } return; } int main(void) { unsigned int x = 0; while (x < 0x0fffffff) { if (x < 0xfff1) { x++; } else { x += 2; } } __VERIFIER_assert(!(x % 2)); }
the_stack_data/231394013.c
#include <stdio.h> #include <unistd.h> #include <signal.h> int main(void) { int i; signal(SIGINT, SIG_IGN); signal(SIGQUIT, SIG_IGN); for (i=20 ; i>0; i--) { sleep(1); } return 0; }
the_stack_data/124545.c
#include <sys/types.h> #include <sys/socket.h> #include <netdb.h> #include <string.h> #include <unistd.h> #include <fcntl.h> #include <sys/epoll.h> #include <errno.h> #include <stdio.h> #include <stdlib.h> static int create_and_bind(char *port); static int make_socket_non_binding(int sfd); #define MAX_EVENTS 64 #define BUF_SIZE 20 static int create_and_bind(char *port) { struct addrinfo hint, *result; int res, sfd; memset(&hint, 0, sizeof(struct addrinfo)); hint.ai_family = AF_INET; hint.ai_socktype = SOCK_STREAM; hint.ai_flags = AI_PASSIVE; res = getaddrinfo(NULL, port, &hint, &result); if (res == -1) { perror("error : can not get address info\n"); exit(1); } sfd = socket(result->ai_family, result->ai_socktype, result->ai_protocol); if (sfd == -1) { perror("error : can not get socket descriptor!\n"); exit(1); } res = bind(sfd, result->ai_addr, result->ai_addrlen); if (res == -1) { perror("error : can not bind the socket!\n"); exit(1); } freeaddrinfo(result); return sfd; } static int make_socket_non_binding(int sfd) { int flags, res; flags = fcntl(sfd, F_GETFL); if (flags == -1) { perror("error : cannot get socket flags!\n"); exit(1); } flags |= O_NONBLOCK; res = fcntl(sfd, F_SETFL, flags); if (res == -1) { perror("error : cannot set socket flags!\n"); exit(1); } return 0; } int main(int argc, char *argv[]) { int sfd, res, epoll, cnt, i, sd; struct epoll_event event, events[MAX_EVENTS]; if (argc != 2) { perror("usage : port \n"); exit(1); } sfd = create_and_bind(argv[1]); if (sfd == -1) { perror("error : cannot create socket!\n"); exit(1); } res = make_socket_non_binding(sfd); if (res == -1) { perror("error : connot set flags!\n"); exit(1); } res = listen(sfd, SOMAXCONN); if (res == -1) { perror("error : cannot listen!\n"); exit(1); } epoll = epoll_create(1); if (epoll == -1) { perror("error : cannot create epoll!\n"); exit(1); } event.events = EPOLLIN | EPOLLOUT | EPOLLET; event.data.fd = sfd; res = epoll_ctl(epoll, EPOLL_CTL_ADD, sfd, &event); if (res == -1) { perror("error : can not add event to epoll!\n"); exit(1); } while (1) { cnt = epoll_wait(epoll, events, MAX_EVENTS, -1); for (i = 0; i < cnt; i++) { if ((events[i].events & EPOLLERR) || (events[i].events & EPOLLHUP) || !(events[i].events & EPOLLIN)) { perror("error : socket fd error!\n"); close(events[i].data.fd); continue; } else if (events[i].data.fd == sfd) { while (1) { struct sockaddr client_addr; int addrlen = sizeof(struct sockaddr); sd = accept(sfd, &client_addr, &addrlen); if (sd == -1) { if (errno == EAGAIN || errno == EWOULDBLOCK) { break; } else { perror("error : cannot accept new socket!\n"); continue; } } res = make_socket_non_binding(sd); if (res == -1) { perror("error : cannot set flags!\n"); exit(1); } event.data.fd = sd; event.events = EPOLLET | EPOLLIN; res = epoll_ctl(epoll, EPOLL_CTL_ADD, sd, &event); if (res == -1) { perror("error : cannot add to epoll!\n"); exit(1); } } } else { int cnt; char buf[BUF_SIZE]; while (1) { cnt = read(events[i].data.fd, buf, BUF_SIZE); if (cnt == -1) { if (errno == EAGAIN) { break; } perror("error : read error!\n"); exit(1); } else if (cnt == 0) { close(events[i].data.fd); break; } printf("receive client data : %s\n", buf); } } } } close(sfd); return 0; }
the_stack_data/37639025.c
/* { dg-do compile } */ /* { dg-options "-O2 -fdump-tree-reassoc1" } */ int main(int a, int b, int c, int d) { /* Should be transformed into a + c + 8 */ int e = a + 3; int f = c + 5; int g = e + f; return g; } /* We cannot re-associate the additions due to undefined signed overflow. */ /* { dg-final { scan-tree-dump-times "\\\+ 8" 1 "reassoc1" { xfail *-*-* } } } */
the_stack_data/103203.c
// RUN: %clang_cc1 -fsyntax-only -fopenmp -verify %s // RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -verify %s // expected-error@+1 {{unexpected OpenMP directive '#pragma omp target teams distribute parallel for simd'}} #pragma omp target teams distribute parallel for simd // expected-error@+1 {{unexpected OpenMP directive '#pragma omp target teams distribute parallel for simd'}} #pragma omp target teams distribute parallel for simd foo void test_no_clause() { int i; #pragma omp target teams distribute parallel for simd for (i = 0; i < 16; ++i) ; // expected-error@+2 {{statement after '#pragma omp target teams distribute parallel for simd' must be a for loop}} #pragma omp target teams distribute parallel for simd ++i; } void test_branch_protected_scope() { int i = 0; L1: ++i; int x[24]; #pragma omp target teams distribute parallel for simd for (i = 0; i < 16; ++i) { if (i == 5) goto L1; // expected-error {{use of undeclared label 'L1'}} else if (i == 6) return; // expected-error {{cannot return from OpenMP region}} else if (i == 7) goto L2; else if (i == 8) { L2: x[i]++; } } if (x[0] == 0) goto L2; // expected-error {{use of undeclared label 'L2'}} else if (x[1] == 1) goto L1; } void test_invalid_clause() { int i; // expected-warning@+1 {{extra tokens at the end of '#pragma omp target teams distribute parallel for simd' are ignored}} #pragma omp target teams distribute parallel for simd foo bar for (i = 0; i < 16; ++i) ; } void test_non_identifiers() { int i, x; // expected-warning@+1 {{extra tokens at the end of '#pragma omp target teams distribute parallel for simd' are ignored}} #pragma omp target teams distribute parallel for simd; for (i = 0; i < 16; ++i) ; // expected-warning@+1 {{extra tokens at the end of '#pragma omp target teams distribute parallel for simd' are ignored}} #pragma omp target teams distribute parallel for simd private(x); for (i = 0; i < 16; ++i) ; // expected-warning@+1 {{extra tokens at the end of '#pragma omp target teams distribute parallel for simd' are ignored}} #pragma omp target teams distribute parallel for simd, private(x); for (i = 0; i < 16; ++i) ; } extern int foo(); void test_collapse() { int i; // expected-error@+1 {{expected '('}} #pragma omp target teams distribute parallel for simd collapse for (i = 0; i < 16; ++i) ; // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} #pragma omp target teams distribute parallel for simd collapse( for (i = 0; i < 16; ++i) ; // expected-error@+1 {{expected expression}} #pragma omp target teams distribute parallel for simd collapse() for (i = 0; i < 16; ++i) ; // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} #pragma omp target teams distribute parallel for simd collapse(, for (i = 0; i < 16; ++i) ; // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} #pragma omp target teams distribute parallel for simd collapse(, ) for (i = 0; i < 16; ++i) ; // expected-warning@+2 {{extra tokens at the end of '#pragma omp target teams distribute parallel for simd' are ignored}} // expected-error@+1 {{expected '('}} #pragma omp target teams distribute parallel for simd collapse 4) for (i = 0; i < 16; ++i) ; // expected-error@+2 {{expected ')'}} // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}} #pragma omp target teams distribute parallel for simd collapse(4 for (i = 0; i < 16; ++i) ; // expected-error {{expected 4 for loops after '#pragma omp target teams distribute parallel for simd', but found only 1}} // expected-error@+2 {{expected ')'}} // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}} #pragma omp target teams distribute parallel for simd collapse(4, for (i = 0; i < 16; ++i) ; // expected-error {{expected 4 for loops after '#pragma omp target teams distribute parallel for simd', but found only 1}} // expected-error@+2 {{expected ')'}} // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}} #pragma omp target teams distribute parallel for simd collapse(4, ) for (i = 0; i < 16; ++i) ; // expected-error {{expected 4 for loops after '#pragma omp target teams distribute parallel for simd', but found only 1}} // expected-note@+1 {{as specified in 'collapse' clause}} #pragma omp target teams distribute parallel for simd collapse(4) for (i = 0; i < 16; ++i) ; // expected-error {{expected 4 for loops after '#pragma omp target teams distribute parallel for simd', but found only 1}} // expected-error@+2 {{expected ')'}} // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}} #pragma omp target teams distribute parallel for simd collapse(4 4) for (i = 0; i < 16; ++i) ; // expected-error {{expected 4 for loops after '#pragma omp target teams distribute parallel for simd', but found only 1}} // expected-error@+2 {{expected ')'}} // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}} #pragma omp target teams distribute parallel for simd collapse(4, , 4) for (i = 0; i < 16; ++i) ; // expected-error {{expected 4 for loops after '#pragma omp target teams distribute parallel for simd', but found only 1}} #pragma omp target teams distribute parallel for simd collapse(4) for (int i1 = 0; i1 < 16; ++i1) for (int i2 = 0; i2 < 16; ++i2) for (int i3 = 0; i3 < 16; ++i3) for (int i4 = 0; i4 < 16; ++i4) foo(); // expected-error@+2 {{expected ')'}} // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}} #pragma omp target teams distribute parallel for simd collapse(4, 8) for (i = 0; i < 16; ++i) ; // expected-error {{expected 4 for loops after '#pragma omp target teams distribute parallel for simd', but found only 1}} // expected-error@+1 {{expression is not an integer constant expression}} #pragma omp target teams distribute parallel for simd collapse(2.5) for (i = 0; i < 16; ++i) ; // expected-error@+1 {{expression is not an integer constant expression}} #pragma omp target teams distribute parallel for simd collapse(foo()) for (i = 0; i < 16; ++i) ; // expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}} #pragma omp target teams distribute parallel for simd collapse(-5) for (i = 0; i < 16; ++i) ; // expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}} #pragma omp target teams distribute parallel for simd collapse(0) for (i = 0; i < 16; ++i) ; // expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}} #pragma omp target teams distribute parallel for simd collapse(5 - 5) for (i = 0; i < 16; ++i) ; // expected-error@+4 {{OpenMP constructs may not be nested inside a simd region}} #pragma omp target teams distribute parallel for simd collapse(2) firstprivate(i) for (i = 0; i < 16; ++i) for (int j = 0; j < 16; ++j) #pragma omp parallel for reduction(+ : i, j) for (int k = 0; k < 16; ++k) i += j; } void test_private() { int i; // expected-error@+2 {{expected expression}} // expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} #pragma omp target teams distribute parallel for simd private( for (i = 0; i < 16; ++i) ; // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}} // expected-error@+1 2 {{expected expression}} #pragma omp target teams distribute parallel for simd private(, for (i = 0; i < 16; ++i) ; // expected-error@+1 2 {{expected expression}} #pragma omp target teams distribute parallel for simd private(, ) for (i = 0; i < 16; ++i) ; // expected-error@+1 {{expected expression}} #pragma omp target teams distribute parallel for simd private() for (i = 0; i < 16; ++i) ; // expected-error@+1 {{expected expression}} #pragma omp target teams distribute parallel for simd private(int) for (i = 0; i < 16; ++i) ; // expected-error@+1 {{expected variable name}} #pragma omp target teams distribute parallel for simd private(0) for (i = 0; i < 16; ++i) ; int x, y, z; #pragma omp target teams distribute parallel for simd private(x) for (i = 0; i < 16; ++i) ; #pragma omp target teams distribute parallel for simd private(x, y) for (i = 0; i < 16; ++i) ; #pragma omp target teams distribute parallel for simd private(x, y, z) for (i = 0; i < 16; ++i) { x = y * i + z; } } void test_lastprivate() { int i; // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}} // expected-error@+1 {{expected expression}} #pragma omp target teams distribute parallel for simd lastprivate( for (i = 0; i < 16; ++i) ; // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}} // expected-error@+1 2 {{expected expression}} #pragma omp target teams distribute parallel for simd lastprivate(, for (i = 0; i < 16; ++i) ; // expected-error@+1 2 {{expected expression}} #pragma omp target teams distribute parallel for simd lastprivate(, ) for (i = 0; i < 16; ++i) ; // expected-error@+1 {{expected expression}} #pragma omp target teams distribute parallel for simd lastprivate() for (i = 0; i < 16; ++i) ; // expected-error@+1 {{expected expression}} #pragma omp target teams distribute parallel for simd lastprivate(int) for (i = 0; i < 16; ++i) ; // expected-error@+1 {{expected variable name}} #pragma omp target teams distribute parallel for simd lastprivate(0) for (i = 0; i < 16; ++i) ; int x, y, z; #pragma omp target teams distribute parallel for simd lastprivate(x) for (i = 0; i < 16; ++i) ; #pragma omp target teams distribute parallel for simd lastprivate(x, y) for (i = 0; i < 16; ++i) ; #pragma omp target teams distribute parallel for simd lastprivate(x, y, z) for (i = 0; i < 16; ++i) ; } void test_firstprivate() { int i; // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}} // expected-error@+1 {{expected expression}} #pragma omp target teams distribute parallel for simd firstprivate( for (i = 0; i < 16; ++i) ; // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}} // expected-error@+1 2 {{expected expression}} #pragma omp target teams distribute parallel for simd firstprivate(, for (i = 0; i < 16; ++i) ; // expected-error@+1 2 {{expected expression}} #pragma omp target teams distribute parallel for simd firstprivate(, ) for (i = 0; i < 16; ++i) ; // expected-error@+1 {{expected expression}} #pragma omp target teams distribute parallel for simd firstprivate() for (i = 0; i < 16; ++i) ; // expected-error@+1 {{expected expression}} #pragma omp target teams distribute parallel for simd firstprivate(int) for (i = 0; i < 16; ++i) ; // expected-error@+1 {{expected variable name}} #pragma omp target teams distribute parallel for simd firstprivate(0) for (i = 0; i < 16; ++i) ; int x, y, z; // expected-error@+1 {{lastprivate variable cannot be firstprivate}} expected-note@+1 {{defined as lastprivate}} #pragma omp target teams distribute parallel for simd lastprivate(x) firstprivate(x) for (i = 0; i < 16; ++i) ; // expected-error@+1 2 {{lastprivate variable cannot be firstprivate}} expected-note@+1 2 {{defined as lastprivate}} #pragma omp target teams distribute parallel for simd lastprivate(x, y) firstprivate(x, y) for (i = 0; i < 16; ++i) ; // expected-error@+1 3 {{lastprivate variable cannot be firstprivate}} expected-note@+1 3 {{defined as lastprivate}} #pragma omp target teams distribute parallel for simd lastprivate(x, y, z) firstprivate(x, y, z) for (i = 0; i < 16; ++i) ; // expected-error@+1 {{the value of 'simdlen' parameter must be less than or equal to the value of the 'safelen' parameter}} #pragma omp target teams distribute parallel for simd simdlen(64) safelen(8) for (i = 0; i < 16; ++i) ; } void test_loop_messages() { float a[100], b[100], c[100]; // expected-error@+2 {{variable must be of integer or pointer type}} #pragma omp target teams distribute parallel for simd for (float fi = 0; fi < 10.0; fi++) { c[(int)fi] = a[(int)fi] + b[(int)fi]; } // expected-error@+2 {{variable must be of integer or pointer type}} #pragma omp target teams distribute parallel for simd for (double fi = 0; fi < 10.0; fi++) { c[(int)fi] = a[(int)fi] + b[(int)fi]; } }
the_stack_data/162642545.c
#ifdef STM32F3xx #include "stm32f3xx_hal_i2s_ex.c" #endif #ifdef STM32F4xx #include "stm32f4xx_hal_i2s_ex.c" #endif #ifdef STM32H7xx #include "stm32h7xx_hal_i2s_ex.c" #endif
the_stack_data/73575465.c
void _Exit() {} ; void _IO_feof() {} ; void _IO_getc() {} ; void _IO_putc() {} ; void _IO_puts() {} ; void __assert_fail() {} ; void __chk_fail() {} ; void __confstr_chk() {} ; void __ctype_b_loc() {} ; void __ctype_get_mb_cur_max() {} ; void __ctype_tolower_loc() {} ; void __ctype_toupper_loc() {} ; void __cxa_atexit() {} ; void __cxa_finalize() {} ; void __errno_location() {} ; void __fgets_chk() {} ; void __fgets_unlocked_chk() {} ; void __fgetws_chk() {} ; void __fgetws_unlocked_chk() {} ; void __fpending() {} ; void __fprintf_chk() {} ; void __fwprintf_chk() {} ; void __fxstat() {} ; void __fxstat64() {} ; void __fxstatat() {} ; void __fxstatat64() {} ; void __getcwd_chk() {} ; void __getgroups_chk() {} ; void __gethostname_chk() {} ; void __getlogin_r_chk() {} ; void __getpagesize() {} ; void __getpgid() {} ; void __h_errno_location() {} ; void __isinf() {} ; void __isinff() {} ; void __isinfl() {} ; void __isinfl_depr_0() {} ; __asm__(".symver __isinfl_depr_0,__isinfl@GLIBC_2.0"); void __isnan() {} ; void __isnanf() {} ; void __isnanl() {} ; void __isnanl_depr_0() {} ; __asm__(".symver __isnanl_depr_0,__isnanl@GLIBC_2.0"); void __libc_current_sigrtmax() {} ; void __libc_current_sigrtmin() {} ; void __libc_start_main() {} ; void __lxstat() {} ; void __lxstat64() {} ; void __mbsnrtowcs_chk() {} ; void __mbsrtowcs_chk() {} ; void __mbstowcs_chk() {} ; void __memcpy_chk() {} ; void __memmove_chk() {} ; void __mempcpy() {} ; void __mempcpy_chk() {} ; void __memset_chk() {} ; void __pread64_chk() {} ; void __pread_chk() {} ; void __printf_chk() {} ; void __rawmemchr() {} ; void __read_chk() {} ; void __readlink_chk() {} ; void __realpath_chk() {} ; void __recv_chk() {} ; void __recvfrom_chk() {} ; void __register_atfork() {} ; void __sigsetjmp() {} ; void __snprintf_chk() {} ; void __sprintf_chk() {} ; void __stack_chk_fail() {} ; void __stpcpy() {} ; void __stpcpy_chk() {} ; void __stpncpy_chk() {} ; void __strcat_chk() {} ; void __strcpy_chk() {} ; void __strdup() {} ; void __strncat_chk() {} ; void __strncpy_chk() {} ; void __strtod_internal() {} ; void __strtof_internal() {} ; void __strtok_r() {} ; void __strtol_internal() {} ; void __strtold_internal() {} ; void __strtold_internal_depr_0() {} ; __asm__(".symver __strtold_internal_depr_0,__strtold_internal@GLIBC_2.0"); void __strtoll_internal() {} ; void __strtoul_internal() {} ; void __strtoull_internal() {} ; void __swprintf_chk() {} ; void __sysconf() {} ; void __syslog_chk() {} ; void __sysv_signal() {} ; void __ttyname_r_chk() {} ; void __vfprintf_chk() {} ; void __vfwprintf_chk() {} ; void __vprintf_chk() {} ; void __vsnprintf_chk() {} ; void __vsprintf_chk() {} ; void __vswprintf_chk() {} ; void __vsyslog_chk() {} ; void __vwprintf_chk() {} ; void __wcpcpy_chk() {} ; void __wcpncpy_chk() {} ; void __wcrtomb_chk() {} ; void __wcscat_chk() {} ; void __wcscpy_chk() {} ; void __wcsncat_chk() {} ; void __wcsncpy_chk() {} ; void __wcsnrtombs_chk() {} ; void __wcsrtombs_chk() {} ; void __wcstod_internal() {} ; void __wcstof_internal() {} ; void __wcstol_internal() {} ; void __wcstold_internal() {} ; void __wcstold_internal_depr_0() {} ; __asm__(".symver __wcstold_internal_depr_0,__wcstold_internal@GLIBC_2.0"); void __wcstombs_chk() {} ; void __wcstoul_internal() {} ; void __wctomb_chk() {} ; void __wmemcpy_chk() {} ; void __wmemmove_chk() {} ; void __wmempcpy_chk() {} ; void __wmemset_chk() {} ; void __wprintf_chk() {} ; void __xmknod() {} ; void __xmknodat() {} ; void __xpg_basename() {} ; void __xpg_sigpause() {} ; void __xpg_strerror_r() {} ; void __xstat() {} ; void __xstat64() {} ; void _exit() {} ; void _longjmp() {} ; void _setjmp() {} ; void _tolower() {} ; void _toupper() {} ; void a64l() {} ; void abort() {} ; void abs() {} ; void accept() {} ; void access() {} ; void acct() {} ; void adjtime() {} ; void alarm() {} ; void alphasort() {} ; void alphasort64() {} ; void asctime() {} ; void asctime_r() {} ; void asprintf() {} ; void asprintf_depr_0() {} ; __asm__(".symver asprintf_depr_0,asprintf@GLIBC_2.0"); void atof() {} ; void atoi() {} ; void atol() {} ; void atoll() {} ; void authnone_create() {} ; void backtrace() {} ; void backtrace_symbols() {} ; void backtrace_symbols_fd() {} ; void basename() {} ; void bcmp() {} ; void bcopy() {} ; void bind() {} ; void bind_textdomain_codeset() {} ; void bindresvport() {} ; void bindtextdomain() {} ; void brk() {} ; void bsd_signal() {} ; void bsearch() {} ; void btowc() {} ; void bzero() {} ; void calloc() {} ; void callrpc() {} ; void catclose() {} ; void catgets() {} ; void catopen() {} ; void cfgetispeed() {} ; void cfgetospeed() {} ; void cfmakeraw() {} ; void cfsetispeed() {} ; void cfsetospeed() {} ; void cfsetspeed() {} ; void chdir() {} ; void chmod() {} ; void chown() {} ; void chroot() {} ; void clearerr() {} ; void clearerr_unlocked() {} ; void clnt_create() {} ; void clnt_pcreateerror() {} ; void clnt_perrno() {} ; void clnt_perror() {} ; void clnt_spcreateerror() {} ; void clnt_sperrno() {} ; void clnt_sperror() {} ; void clntraw_create() {} ; void clnttcp_create() {} ; void clntudp_bufcreate() {} ; void clntudp_create() {} ; void clock() {} ; void close() {} ; void closedir() {} ; void closelog() {} ; void confstr() {} ; void connect() {} ; void creat() {} ; void creat64() {} ; void ctermid() {} ; void ctime() {} ; void ctime_r() {} ; void cuserid() {} ; void daemon() {} ; void dcgettext() {} ; void dcngettext() {} ; void dgettext() {} ; void difftime() {} ; void dirfd() {} ; void dirname() {} ; void div() {} ; void dl_iterate_phdr() {} ; void dngettext() {} ; void dprintf() {} ; void drand48() {} ; void drand48_r() {} ; void dup() {} ; void dup2() {} ; void duplocale() {} ; void ecvt() {} ; void endgrent() {} ; void endprotoent() {} ; void endpwent() {} ; void endservent() {} ; void endutent() {} ; void endutxent() {} ; void epoll_create() {} ; void epoll_ctl() {} ; void epoll_wait() {} ; void erand48() {} ; void erand48_r() {} ; void err() {} ; void error() {} ; void errx() {} ; void execl() {} ; void execle() {} ; void execlp() {} ; void execv() {} ; void execve() {} ; void execvp() {} ; void exit() {} ; void faccessat() {} ; void fchdir() {} ; void fchmod() {} ; void fchmodat() {} ; void fchown() {} ; void fchownat() {} ; void fclose() {} ; void fcntl() {} ; void fcvt() {} ; void fdatasync() {} ; void fdopen() {} ; void fdopendir() {} ; void feof() {} ; void feof_unlocked() {} ; void ferror() {} ; void ferror_unlocked() {} ; void fexecve() {} ; void fflush() {} ; void fflush_unlocked() {} ; void ffs() {} ; void fgetc() {} ; void fgetc_unlocked() {} ; void fgetpos() {} ; void fgetpos64() {} ; void fgets() {} ; void fgets_unlocked() {} ; void fgetwc() {} ; void fgetwc_unlocked() {} ; void fgetws() {} ; void fgetws_unlocked() {} ; void fileno() {} ; void fileno_unlocked() {} ; void flock() {} ; void flockfile() {} ; void fmemopen() {} ; void fmtmsg() {} ; void fnmatch() {} ; void fopen() {} ; void fopen64() {} ; void fork() {} ; void fpathconf() {} ; void fprintf() {} ; void fprintf_depr_0() {} ; __asm__(".symver fprintf_depr_0,fprintf@GLIBC_2.0"); void fputc() {} ; void fputc_unlocked() {} ; void fputs() {} ; void fputs_unlocked() {} ; void fputwc() {} ; void fputwc_unlocked() {} ; void fputws() {} ; void fputws_unlocked() {} ; void fread() {} ; void fread_unlocked() {} ; void free() {} ; void freeaddrinfo() {} ; void freelocale() {} ; void freopen() {} ; void freopen64() {} ; void fscanf() {} ; void fscanf_depr_0() {} ; __asm__(".symver fscanf_depr_0,fscanf@GLIBC_2.0"); void fseek() {} ; void fseeko() {} ; void fseeko64() {} ; void fsetpos() {} ; void fsetpos64() {} ; void fstatfs() {} ; void fstatfs64() {} ; void fstatvfs() {} ; void fstatvfs64() {} ; void fsync() {} ; void ftell() {} ; void ftello() {} ; void ftello64() {} ; void ftime() {} ; void ftok() {} ; void ftruncate() {} ; void ftruncate64() {} ; void ftrylockfile() {} ; void ftw() {} ; void ftw64() {} ; void funlockfile() {} ; void fwide() {} ; void fwprintf() {} ; void fwprintf_depr_0() {} ; __asm__(".symver fwprintf_depr_0,fwprintf@GLIBC_2.2"); void fwrite() {} ; void fwrite_unlocked() {} ; void fwscanf() {} ; void fwscanf_depr_0() {} ; __asm__(".symver fwscanf_depr_0,fwscanf@GLIBC_2.2"); void gai_strerror() {} ; void gcvt() {} ; void getaddrinfo() {} ; void getc() {} ; void getc_unlocked() {} ; void getchar() {} ; void getchar_unlocked() {} ; void getcontext() {} ; void getcwd() {} ; void getdate() {} ; void getdelim() {} ; void getdomainname() {} ; void getdtablesize() {} ; void getegid() {} ; void getenv() {} ; void geteuid() {} ; void getgid() {} ; void getgrent() {} ; void getgrent_r() {} ; void getgrgid() {} ; void getgrgid_r() {} ; void getgrnam() {} ; void getgrnam_r() {} ; void getgrouplist() {} ; void getgroups() {} ; void gethostbyaddr() {} ; void gethostbyaddr_r() {} ; void gethostbyname() {} ; void gethostbyname2() {} ; void gethostbyname2_r() {} ; void gethostbyname_r() {} ; void gethostid() {} ; void gethostname() {} ; void getitimer() {} ; void getline() {} ; void getloadavg() {} ; void getlogin() {} ; void getlogin_r() {} ; void getnameinfo() {} ; void getopt() {} ; void getopt_long() {} ; void getopt_long_only() {} ; void getpagesize() {} ; void getpeername() {} ; void getpgid() {} ; void getpgrp() {} ; void getpid() {} ; void getppid() {} ; void getpriority() {} ; void getprotobyname() {} ; void getprotobyname_r() {} ; void getprotobynumber() {} ; void getprotobynumber_r() {} ; void getprotoent() {} ; void getprotoent_r() {} ; void getpwent() {} ; void getpwent_r() {} ; void getpwnam() {} ; void getpwnam_r() {} ; void getpwuid() {} ; void getpwuid_r() {} ; void getrlimit() {} ; void getrlimit64() {} ; void getrusage() {} ; void getservbyname() {} ; void getservbyname_r() {} ; void getservbyport() {} ; void getservbyport_r() {} ; void getservent() {} ; void getservent_r() {} ; void getsid() {} ; void getsockname() {} ; void getsockopt() {} ; void getsubopt() {} ; void gettext() {} ; void gettimeofday() {} ; void getuid() {} ; void getutent() {} ; void getutent_r() {} ; void getutxent() {} ; void getutxid() {} ; void getutxline() {} ; void getw() {} ; void getwc() {} ; void getwc_unlocked() {} ; void getwchar() {} ; void getwchar_unlocked() {} ; void getwd() {} ; void glob() {} ; void glob64() {} ; void globfree() {} ; void globfree64() {} ; void gmtime() {} ; void gmtime_r() {} ; void gnu_get_libc_release() {} ; void gnu_get_libc_version() {} ; void grantpt() {} ; void hcreate() {} ; void hcreate_r() {} ; void hdestroy() {} ; void hdestroy_r() {} ; void hsearch() {} ; void hsearch_r() {} ; void htonl() {} ; void htons() {} ; void iconv() {} ; void iconv_close() {} ; void iconv_open() {} ; void if_freenameindex() {} ; void if_indextoname() {} ; void if_nameindex() {} ; void if_nametoindex() {} ; void imaxabs() {} ; void imaxdiv() {} ; void index() {} ; void inet_addr() {} ; void inet_aton() {} ; void inet_ntoa() {} ; void inet_ntop() {} ; void inet_pton() {} ; void initgroups() {} ; void initstate() {} ; void initstate_r() {} ; void inotify_add_watch() {} ; void inotify_init() {} ; void inotify_rm_watch() {} ; void insque() {} ; void ioctl() {} ; void isalnum() {} ; void isalpha() {} ; void isascii() {} ; void isatty() {} ; void isblank() {} ; void iscntrl() {} ; void isdigit() {} ; void isgraph() {} ; void islower() {} ; void isprint() {} ; void ispunct() {} ; void isspace() {} ; void isupper() {} ; void iswalnum() {} ; void iswalpha() {} ; void iswblank() {} ; void iswcntrl() {} ; void iswctype() {} ; void iswdigit() {} ; void iswgraph() {} ; void iswlower() {} ; void iswprint() {} ; void iswpunct() {} ; void iswspace() {} ; void iswupper() {} ; void iswxdigit() {} ; void isxdigit() {} ; void jrand48() {} ; void jrand48_r() {} ; void key_decryptsession() {} ; void kill() {} ; void killpg() {} ; void l64a() {} ; void labs() {} ; void lchown() {} ; void lcong48() {} ; void lcong48_r() {} ; void ldiv() {} ; void lfind() {} ; void link() {} ; void linkat() {} ; void listen() {} ; void llabs() {} ; void lldiv() {} ; void localeconv() {} ; void localtime() {} ; void localtime_r() {} ; void lockf() {} ; void lockf64() {} ; void longjmp() {} ; void lrand48() {} ; void lrand48_r() {} ; void lsearch() {} ; void lseek() {} ; void lseek64() {} ; void makecontext() {} ; void malloc() {} ; void mblen() {} ; void mbrlen() {} ; void mbrtowc() {} ; void mbsinit() {} ; void mbsnrtowcs() {} ; void mbsrtowcs() {} ; void mbstowcs() {} ; void mbtowc() {} ; void memccpy() {} ; void memchr() {} ; void memcmp() {} ; void memcpy() {} ; void memmem() {} ; void memmove() {} ; void memrchr() {} ; void memset() {} ; void mkdir() {} ; void mkdirat() {} ; void mkdtemp() {} ; void mkfifo() {} ; void mkfifoat() {} ; void mkstemp() {} ; void mkstemp64() {} ; void mktemp() {} ; void mktime() {} ; void mlock() {} ; void mlockall() {} ; void mmap() {} ; void mmap64() {} ; void mprotect() {} ; void mrand48() {} ; void mrand48_r() {} ; void mremap() {} ; void msgctl() {} ; void msgget() {} ; void msgrcv() {} ; void msgsnd() {} ; void msync() {} ; void munlock() {} ; void munlockall() {} ; void munmap() {} ; void nanosleep() {} ; void newlocale() {} ; void nftw() {} ; void nftw64() {} ; void ngettext() {} ; void nice() {} ; void nl_langinfo() {} ; void nrand48() {} ; void nrand48_r() {} ; void ntohl() {} ; void ntohs() {} ; void open() {} ; void open64() {} ; void open_memstream() {} ; void open_wmemstream() {} ; void openat() {} ; void openat64() {} ; void opendir() {} ; void openlog() {} ; void pathconf() {} ; void pause() {} ; void pclose() {} ; void perror() {} ; void pipe() {} ; void pmap_getport() {} ; void pmap_set() {} ; void pmap_unset() {} ; void poll() {} ; void popen() {} ; void posix_fadvise() {} ; void posix_fadvise64() {} ; void posix_fallocate() {} ; void posix_fallocate64() {} ; void posix_madvise() {} ; void posix_memalign() {} ; void posix_openpt() {} ; void posix_spawn() {} ; void posix_spawn_file_actions_addclose() {} ; void posix_spawn_file_actions_adddup2() {} ; void posix_spawn_file_actions_addopen() {} ; void posix_spawn_file_actions_destroy() {} ; void posix_spawn_file_actions_init() {} ; void posix_spawnattr_destroy() {} ; void posix_spawnattr_getflags() {} ; void posix_spawnattr_getpgroup() {} ; void posix_spawnattr_getschedparam() {} ; void posix_spawnattr_getschedpolicy() {} ; void posix_spawnattr_getsigdefault() {} ; void posix_spawnattr_getsigmask() {} ; void posix_spawnattr_init() {} ; void posix_spawnattr_setflags() {} ; void posix_spawnattr_setpgroup() {} ; void posix_spawnattr_setschedparam() {} ; void posix_spawnattr_setschedpolicy() {} ; void posix_spawnattr_setsigdefault() {} ; void posix_spawnattr_setsigmask() {} ; void posix_spawnp() {} ; void pread() {} ; void pread64() {} ; void printf() {} ; void printf_depr_0() {} ; __asm__(".symver printf_depr_0,printf@GLIBC_2.0"); void pselect() {} ; void psignal() {} ; void ptrace() {} ; void ptsname() {} ; void putc() {} ; void putc_unlocked() {} ; void putchar() {} ; void putchar_unlocked() {} ; void putenv() {} ; void puts() {} ; void pututxline() {} ; void putw() {} ; void putwc() {} ; void putwc_unlocked() {} ; void putwchar() {} ; void putwchar_unlocked() {} ; void pwrite() {} ; void pwrite64() {} ; void qsort() {} ; void raise() {} ; void rand() {} ; void rand_r() {} ; void random() {} ; void random_r() {} ; void read() {} ; void readdir() {} ; void readdir64() {} ; void readdir64_r() {} ; void readdir_r() {} ; void readlink() {} ; void readlinkat() {} ; void readv() {} ; void realloc() {} ; void realpath() {} ; void recv() {} ; void recvfrom() {} ; void recvmsg() {} ; void regcomp() {} ; void regerror() {} ; void regexec() {} ; void regfree() {} ; void remove() {} ; void remque() {} ; void rename() {} ; void renameat() {} ; void rewind() {} ; void rewinddir() {} ; void rindex() {} ; void rmdir() {} ; void sbrk() {} ; void scandir() {} ; void scandir64() {} ; void scanf() {} ; void scanf_depr_0() {} ; __asm__(".symver scanf_depr_0,scanf@GLIBC_2.0"); void sched_get_priority_max() {} ; void sched_get_priority_min() {} ; void sched_getaffinity() {} ; void sched_getparam() {} ; void sched_getscheduler() {} ; void sched_rr_get_interval() {} ; void sched_setaffinity() {} ; void sched_setparam() {} ; void sched_setscheduler() {} ; void sched_yield() {} ; void seed48() {} ; void seed48_r() {} ; void seekdir() {} ; void select() {} ; void semctl() {} ; void semget() {} ; void semop() {} ; void send() {} ; void sendfile() {} ; void sendfile64() {} ; void sendmsg() {} ; void sendto() {} ; void setbuf() {} ; void setbuffer() {} ; void setcontext() {} ; void setegid() {} ; void setenv() {} ; void seteuid() {} ; void setgid() {} ; void setgrent() {} ; void setgroups() {} ; void sethostname() {} ; void setitimer() {} ; void setlocale() {} ; void setlogmask() {} ; void setpgid() {} ; void setpgrp() {} ; void setpriority() {} ; void setprotoent() {} ; void setpwent() {} ; void setregid() {} ; void setreuid() {} ; void setrlimit() {} ; void setrlimit64() {} ; void setservent() {} ; void setsid() {} ; void setsockopt() {} ; void setstate() {} ; void setstate_r() {} ; void setuid() {} ; void setutent() {} ; void setutxent() {} ; void setvbuf() {} ; void shmat() {} ; void shmctl() {} ; void shmdt() {} ; void shmget() {} ; void shutdown() {} ; void sigaction() {} ; void sigaddset() {} ; void sigaltstack() {} ; void sigandset() {} ; void sigdelset() {} ; void sigemptyset() {} ; void sigfillset() {} ; void sighold() {} ; void sigignore() {} ; void siginterrupt() {} ; void sigisemptyset() {} ; void sigismember() {} ; void siglongjmp() {} ; void signal() {} ; void sigorset() {} ; void sigpause() {} ; void sigpending() {} ; void sigprocmask() {} ; void sigqueue() {} ; void sigrelse() {} ; void sigreturn() {} ; void sigset() {} ; void sigsuspend() {} ; void sigtimedwait() {} ; void sigwait() {} ; void sigwaitinfo() {} ; void sleep() {} ; void snprintf() {} ; void snprintf_depr_0() {} ; __asm__(".symver snprintf_depr_0,snprintf@GLIBC_2.0"); void sockatmark() {} ; void socket() {} ; void socketpair() {} ; void sprintf() {} ; void sprintf_depr_0() {} ; __asm__(".symver sprintf_depr_0,sprintf@GLIBC_2.0"); void srand() {} ; void srand48() {} ; void srand48_r() {} ; void srandom() {} ; void srandom_r() {} ; void sscanf() {} ; void sscanf_depr_0() {} ; __asm__(".symver sscanf_depr_0,sscanf@GLIBC_2.0"); void statfs() {} ; void statfs64() {} ; void statvfs() {} ; void statvfs64() {} ; void stime() {} ; void stpcpy() {} ; void stpncpy() {} ; void strcasecmp() {} ; void strcasestr() {} ; void strcat() {} ; void strchr() {} ; void strcmp() {} ; void strcoll() {} ; void strcpy() {} ; void strcspn() {} ; void strdup() {} ; void strerror() {} ; void strerror_r() {} ; void strfmon() {} ; void strfmon_depr_0() {} ; __asm__(".symver strfmon_depr_0,strfmon@GLIBC_2.0"); void strftime() {} ; void strlen() {} ; void strncasecmp() {} ; void strncat() {} ; void strncmp() {} ; void strncpy() {} ; void strndup() {} ; void strnlen() {} ; void strpbrk() {} ; void strptime() {} ; void strrchr() {} ; void strsep() {} ; void strsignal() {} ; void strspn() {} ; void strstr() {} ; void strtod() {} ; void strtof() {} ; void strtoimax() {} ; void strtok() {} ; void strtok_r() {} ; void strtol() {} ; void strtold() {} ; void strtold_depr_0() {} ; __asm__(".symver strtold_depr_0,strtold@GLIBC_2.0"); void strtoll() {} ; void strtoq() {} ; void strtoul() {} ; void strtoull() {} ; void strtoumax() {} ; void strtouq() {} ; void strxfrm() {} ; void svc_getreqset() {} ; void svc_register() {} ; void svc_run() {} ; void svc_sendreply() {} ; void svcerr_auth() {} ; void svcerr_decode() {} ; void svcerr_noproc() {} ; void svcerr_noprog() {} ; void svcerr_progvers() {} ; void svcerr_systemerr() {} ; void svcerr_weakauth() {} ; void svcfd_create() {} ; void svcraw_create() {} ; void svctcp_create() {} ; void svcudp_create() {} ; void swab() {} ; void swapcontext() {} ; void swprintf() {} ; void swprintf_depr_0() {} ; __asm__(".symver swprintf_depr_0,swprintf@GLIBC_2.2"); void swscanf() {} ; void swscanf_depr_0() {} ; __asm__(".symver swscanf_depr_0,swscanf@GLIBC_2.2"); void symlink() {} ; void symlinkat() {} ; void sync() {} ; void sysconf() {} ; void sysinfo() {} ; void syslog() {} ; void syslog_depr_0() {} ; __asm__(".symver syslog_depr_0,syslog@GLIBC_2.0"); void system() {} ; void tcdrain() {} ; void tcflow() {} ; void tcflush() {} ; void tcgetattr() {} ; void tcgetpgrp() {} ; void tcgetsid() {} ; void tcsendbreak() {} ; void tcsetattr() {} ; void tcsetpgrp() {} ; void tdelete() {} ; void telldir() {} ; void tempnam() {} ; void textdomain() {} ; void tfind() {} ; void time() {} ; void times() {} ; void tmpfile() {} ; void tmpfile64() {} ; void tmpnam() {} ; void toascii() {} ; void tolower() {} ; void toupper() {} ; void towctrans() {} ; void towlower() {} ; void towupper() {} ; void truncate() {} ; void truncate64() {} ; void tsearch() {} ; void ttyname() {} ; void ttyname_r() {} ; void twalk() {} ; void tzset() {} ; void ualarm() {} ; void ulimit() {} ; void umask() {} ; void uname() {} ; void ungetc() {} ; void ungetwc() {} ; void unlink() {} ; void unlinkat() {} ; void unlockpt() {} ; void unsetenv() {} ; void uselocale() {} ; void usleep() {} ; void utime() {} ; void utimes() {} ; void utmpname() {} ; void vasprintf() {} ; void vasprintf_depr_0() {} ; __asm__(".symver vasprintf_depr_0,vasprintf@GLIBC_2.0"); void vdprintf() {} ; void vdprintf_depr_0() {} ; __asm__(".symver vdprintf_depr_0,vdprintf@GLIBC_2.0"); void verrx() {} ; void vfork() {} ; void vfprintf() {} ; void vfprintf_depr_0() {} ; __asm__(".symver vfprintf_depr_0,vfprintf@GLIBC_2.0"); void vfscanf() {} ; void vfscanf_depr_0() {} ; __asm__(".symver vfscanf_depr_0,vfscanf@GLIBC_2.0"); void vfwprintf() {} ; void vfwprintf_depr_0() {} ; __asm__(".symver vfwprintf_depr_0,vfwprintf@GLIBC_2.2"); void vfwscanf() {} ; void vfwscanf_depr_0() {} ; __asm__(".symver vfwscanf_depr_0,vfwscanf@GLIBC_2.2"); void vprintf() {} ; void vprintf_depr_0() {} ; __asm__(".symver vprintf_depr_0,vprintf@GLIBC_2.0"); void vscanf() {} ; void vscanf_depr_0() {} ; __asm__(".symver vscanf_depr_0,vscanf@GLIBC_2.0"); void vsnprintf() {} ; void vsnprintf_depr_0() {} ; __asm__(".symver vsnprintf_depr_0,vsnprintf@GLIBC_2.0"); void vsprintf() {} ; void vsprintf_depr_0() {} ; __asm__(".symver vsprintf_depr_0,vsprintf@GLIBC_2.0"); void vsscanf() {} ; void vsscanf_depr_0() {} ; __asm__(".symver vsscanf_depr_0,vsscanf@GLIBC_2.0"); void vswprintf() {} ; void vswprintf_depr_0() {} ; __asm__(".symver vswprintf_depr_0,vswprintf@GLIBC_2.2"); void vswscanf() {} ; void vswscanf_depr_0() {} ; __asm__(".symver vswscanf_depr_0,vswscanf@GLIBC_2.2"); void vsyslog() {} ; void vsyslog_depr_0() {} ; __asm__(".symver vsyslog_depr_0,vsyslog@GLIBC_2.0"); void vwprintf() {} ; void vwprintf_depr_0() {} ; __asm__(".symver vwprintf_depr_0,vwprintf@GLIBC_2.2"); void vwscanf() {} ; void vwscanf_depr_0() {} ; __asm__(".symver vwscanf_depr_0,vwscanf@GLIBC_2.2"); void wait() {} ; void wait4() {} ; void waitid() {} ; void waitpid() {} ; void warn() {} ; void warnx() {} ; void wcpcpy() {} ; void wcpncpy() {} ; void wcrtomb() {} ; void wcscasecmp() {} ; void wcscat() {} ; void wcschr() {} ; void wcscmp() {} ; void wcscoll() {} ; void wcscpy() {} ; void wcscspn() {} ; void wcsdup() {} ; void wcsftime() {} ; void wcslen() {} ; void wcsncasecmp() {} ; void wcsncat() {} ; void wcsncmp() {} ; void wcsncpy() {} ; void wcsnlen() {} ; void wcsnrtombs() {} ; void wcspbrk() {} ; void wcsrchr() {} ; void wcsrtombs() {} ; void wcsspn() {} ; void wcsstr() {} ; void wcstod() {} ; void wcstof() {} ; void wcstoimax() {} ; void wcstok() {} ; void wcstol() {} ; void wcstold() {} ; void wcstold_depr_0() {} ; __asm__(".symver wcstold_depr_0,wcstold@GLIBC_2.0"); void wcstoll() {} ; void wcstombs() {} ; void wcstoq() {} ; void wcstoul() {} ; void wcstoull() {} ; void wcstoumax() {} ; void wcstouq() {} ; void wcswcs() {} ; void wcswidth() {} ; void wcsxfrm() {} ; void wctob() {} ; void wctomb() {} ; void wctrans() {} ; void wctype() {} ; void wcwidth() {} ; void wmemchr() {} ; void wmemcmp() {} ; void wmemcpy() {} ; void wmemmove() {} ; void wmemset() {} ; void wordexp() {} ; void wordfree() {} ; void wprintf() {} ; void wprintf_depr_0() {} ; __asm__(".symver wprintf_depr_0,wprintf@GLIBC_2.2"); void write() {} ; void writev() {} ; void wscanf() {} ; void wscanf_depr_0() {} ; __asm__(".symver wscanf_depr_0,wscanf@GLIBC_2.2"); void xdr_accepted_reply() {} ; void xdr_array() {} ; void xdr_bool() {} ; void xdr_bytes() {} ; void xdr_callhdr() {} ; void xdr_callmsg() {} ; void xdr_char() {} ; void xdr_double() {} ; void xdr_enum() {} ; void xdr_float() {} ; void xdr_free() {} ; void xdr_int() {} ; void xdr_long() {} ; void xdr_opaque() {} ; void xdr_opaque_auth() {} ; void xdr_pointer() {} ; void xdr_reference() {} ; void xdr_rejected_reply() {} ; void xdr_replymsg() {} ; void xdr_short() {} ; void xdr_string() {} ; void xdr_u_char() {} ; void xdr_u_int() {} ; void xdr_u_long() {} ; void xdr_u_short() {} ; void xdr_union() {} ; void xdr_vector() {} ; void xdr_void() {} ; void xdr_wrapstring() {} ; void xdrmem_create() {} ; void xdrrec_create() {} ; void xdrrec_endofrecord() {} ; void xdrrec_eof() {} ; void xdrrec_skiprecord() {} ; void xdrstdio_create() {} ; __asm__(".globl __daylight; .pushsection .data; .type __daylight,@object; .size __daylight, 4; __daylight: .long 0; .popsection"); __asm__(".globl __environ; .pushsection .data; .type __environ,@object; .size __environ, 4; __environ: .long 0; .popsection"); __asm__(".globl __timezone; .pushsection .data; .type __timezone,@object; .size __timezone, 4; __timezone: .long 0; .popsection"); __asm__(".globl __tzname; .pushsection .data; .type __tzname,@object; .size __tzname, 8; __tzname: .long 0; .popsection"); __asm__(".weak _environ; _environ = __environ"); __asm__(".comm _nl_msg_cat_cntr,4"); __asm__(".globl _sys_errlist; .pushsection .data; .type _sys_errlist,@object; .size _sys_errlist, 528; _sys_errlist: .long 0; .popsection"); __asm__(".comm _sys_siglist,64"); __asm__(".weak daylight; daylight = __daylight"); __asm__(".weak environ; environ = __environ"); __asm__(".comm getdate_err,4"); __asm__(".globl in6addr_any; .pushsection .data; .type in6addr_any,@object; .size in6addr_any, 16; in6addr_any: .long 0; .popsection"); __asm__(".globl in6addr_loopback; .pushsection .data; .type in6addr_loopback,@object; .size in6addr_loopback, 16; in6addr_loopback: .long 0; .popsection"); __asm__(".comm optarg,4"); __asm__(".comm opterr,4"); __asm__(".comm optind,4"); __asm__(".comm optopt,4"); __asm__(".comm stderr,4"); __asm__(".comm stdin,4"); __asm__(".comm stdout,4"); __asm__(".weak timezone; timezone = __timezone"); __asm__(".weak tzname; tzname = __tzname"); extern const int _IO_stdin_used; __asm__(".weak _IO_stdin_used;.weak _LSB_IO_stdin_used; _LSB_IO_stdin_used=_IO_stdin_used ");
the_stack_data/92324874.c
#include <stdio.h> int main(int argc, char** argv) { const char* text = argv[1]; char tape[30000] = { 0 }; char* p = tape; int depth = 0; while (*text) { switch (*text) { case '>': p++; break; case '<': p--; break; case '+': ++*p; break; case '-': --*p; break; case '.': putchar(*p); break; case ',': *p = getchar(); break; case '[': if (!*p) { depth = 0; while (!(*text == ']' && depth == 0)) { if (*text == '[') depth++; if (*text == ']') depth--; text++; } } break; case ']': if (*p) { depth = 0; while (*text != '[' && depth != 0) { if (*text == ']') depth++; if (*text == '[') depth--; text--; } text--; } } text++; } }
the_stack_data/100140816.c
/* Disable floating-point exceptions. Copyright (C) 2012-2020 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Nobuhiro Iwamatsu <[email protected]>, 2012. 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 <https://www.gnu.org/licenses/>. */ #include <fenv.h> #include <fpu_control.h> int fedisableexcept (int excepts) { fpu_control_t temp, old_exc; /* Get the current control register contents. */ _FPU_GETCW (temp); old_exc = (temp >> 5) & FE_ALL_EXCEPT; excepts &= FE_ALL_EXCEPT; temp &= ~(excepts << 5); _FPU_SETCW (temp); return old_exc; }
the_stack_data/126703300.c
#include <stdlib.h> #include <stdio.h> int main (int argc, char **argv) { int *foo = NULL; printf ("Oh no, a bug!\n"); /* set breakpoint here */ return *foo; }
the_stack_data/234517849.c
#include<stdio.h> #include<string.h> int main() { char msg[]="PEDYANG MK"; int len,i; len=strlen(msg); for(i=0;i<len;i++) printf("%d : %c\n", i, msg[i]); return 0; }
the_stack_data/242329986.c
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <pthread.h> int g = 0; //variable global void *mihilo(void *vargp) { int *myid = (int *)vargp; static int s = 0; ++s; ++g; printf("El hilo: %d,tiene un var. estatica: %d, y una var. global: %d\n", *myid, ++s, ++g); } int main() { pthread_t hilito; for (int i = 0; i < 3; i++) pthread_create(&hilito, NULL, mihilo, (void *)&hilito); pthread_exit(NULL); return 0; }
the_stack_data/126702088.c
#include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/time.h> #include <fcntl.h> #include <unistd.h> #include <sys/socket.h> double getdetlatimeofday(struct timeval *begin, struct timeval *end) { return (end->tv_sec + end->tv_usec * 1.0 / 1000000) - (begin->tv_sec + begin->tv_usec * 1.0 / 1000000); } int main(int argc, char *argv[]) { int sv[2]; int i, size, count, sum, n; char *buf; struct timeval begin, end; if (argc != 3) { printf("usage: ./socketpair <size> <count>\n"); return 1; } size = atoi(argv[1]); count = atoi(argv[2]); buf = malloc(size); if (buf == NULL) { perror("malloc"); return 1; } if (socketpair(AF_UNIX, SOCK_STREAM, 0, sv) == -1) { perror("socketpair"); return 1; } if (fork() == 0) { sum = 0; for (i = 0; i < count; i++) { n = read(sv[0], buf, size); if (n == -1) { perror("read"); return 1; } sum += n; } if (sum != count * size) { return 1; } } else { gettimeofday(&begin, NULL); for (i = 0; i < count; i++) { if (write(sv[1], buf, size) != size) { perror("wirte"); return 1; } } gettimeofday(&end, NULL); printf("%.0fMb/s %.0fmsg/s\n", (count * size * 1.0 / getdetlatimeofday(&begin, &end)) * 8 / 1000000, (count * 1.0 / getdetlatimeofday(&begin, &end))); } return 0; }
the_stack_data/1130185.c
#include <math.h> #include <stdlib.h> #include <string.h> #include <stdio.h> #include <complex.h> #ifdef complex #undef complex #endif #ifdef I #undef I #endif #if defined(_WIN64) typedef long long BLASLONG; typedef unsigned long long BLASULONG; #else typedef long BLASLONG; typedef unsigned long BLASULONG; #endif #ifdef LAPACK_ILP64 typedef BLASLONG blasint; #if defined(_WIN64) #define blasabs(x) llabs(x) #else #define blasabs(x) labs(x) #endif #else typedef int blasint; #define blasabs(x) abs(x) #endif typedef blasint integer; typedef unsigned int uinteger; typedef char *address; typedef short int shortint; typedef float real; typedef double doublereal; typedef struct { real r, i; } complex; typedef struct { doublereal r, i; } doublecomplex; #ifdef _MSC_VER static inline _Fcomplex Cf(complex *z) {_Fcomplex zz={z->r , z->i}; return zz;} static inline _Dcomplex Cd(doublecomplex *z) {_Dcomplex zz={z->r , z->i};return zz;} static inline _Fcomplex * _pCf(complex *z) {return (_Fcomplex*)z;} static inline _Dcomplex * _pCd(doublecomplex *z) {return (_Dcomplex*)z;} #else static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} #endif #define pCf(z) (*_pCf(z)) #define pCd(z) (*_pCd(z)) typedef int logical; typedef short int shortlogical; typedef char logical1; typedef char integer1; #define TRUE_ (1) #define FALSE_ (0) /* Extern is for use with -E */ #ifndef Extern #define Extern extern #endif /* I/O stuff */ typedef int flag; typedef int ftnlen; typedef int ftnint; /*external read, write*/ typedef struct { flag cierr; ftnint ciunit; flag ciend; char *cifmt; ftnint cirec; } cilist; /*internal read, write*/ typedef struct { flag icierr; char *iciunit; flag iciend; char *icifmt; ftnint icirlen; ftnint icirnum; } icilist; /*open*/ typedef struct { flag oerr; ftnint ounit; char *ofnm; ftnlen ofnmlen; char *osta; char *oacc; char *ofm; ftnint orl; char *oblnk; } olist; /*close*/ typedef struct { flag cerr; ftnint cunit; char *csta; } cllist; /*rewind, backspace, endfile*/ typedef struct { flag aerr; ftnint aunit; } alist; /* inquire */ typedef struct { flag inerr; ftnint inunit; char *infile; ftnlen infilen; ftnint *inex; /*parameters in standard's order*/ ftnint *inopen; ftnint *innum; ftnint *innamed; char *inname; ftnlen innamlen; char *inacc; ftnlen inacclen; char *inseq; ftnlen inseqlen; char *indir; ftnlen indirlen; char *infmt; ftnlen infmtlen; char *inform; ftnint informlen; char *inunf; ftnlen inunflen; ftnint *inrecl; ftnint *innrec; char *inblank; ftnlen inblanklen; } inlist; #define VOID void union Multitype { /* for multiple entry points */ integer1 g; shortint h; integer i; /* longint j; */ real r; doublereal d; complex c; doublecomplex z; }; typedef union Multitype Multitype; struct Vardesc { /* for Namelist */ char *name; char *addr; ftnlen *dims; int type; }; typedef struct Vardesc Vardesc; struct Namelist { char *name; Vardesc **vars; int nvars; }; typedef struct Namelist Namelist; #define abs(x) ((x) >= 0 ? (x) : -(x)) #define dabs(x) (fabs(x)) #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) #define dmin(a,b) (f2cmin(a,b)) #define dmax(a,b) (f2cmax(a,b)) #define bit_test(a,b) ((a) >> (b) & 1) #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) #define abort_() { sig_die("Fortran abort routine called", 1); } #define c_abs(z) (cabsf(Cf(z))) #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } #ifdef _MSC_VER #define c_div(c, a, b) {Cf(c)._Val[0] = (Cf(a)._Val[0]/Cf(b)._Val[0]); Cf(c)._Val[1]=(Cf(a)._Val[1]/Cf(b)._Val[1]);} #define z_div(c, a, b) {Cd(c)._Val[0] = (Cd(a)._Val[0]/Cd(b)._Val[0]); Cd(c)._Val[1]=(Cd(a)._Val[1]/df(b)._Val[1]);} #else #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} #endif #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} #define d_abs(x) (fabs(*(x))) #define d_acos(x) (acos(*(x))) #define d_asin(x) (asin(*(x))) #define d_atan(x) (atan(*(x))) #define d_atn2(x, y) (atan2(*(x),*(y))) #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } #define r_cnjg(R, Z) { pCf(R) = conjf(Cf(Z)); } #define d_cos(x) (cos(*(x))) #define d_cosh(x) (cosh(*(x))) #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) #define d_exp(x) (exp(*(x))) #define d_imag(z) (cimag(Cd(z))) #define r_imag(z) (cimagf(Cf(z))) #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) #define d_log(x) (log(*(x))) #define d_mod(x, y) (fmod(*(x), *(y))) #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) #define d_nint(x) u_nint(*(x)) #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) #define d_sign(a,b) u_sign(*(a),*(b)) #define r_sign(a,b) u_sign(*(a),*(b)) #define d_sin(x) (sin(*(x))) #define d_sinh(x) (sinh(*(x))) #define d_sqrt(x) (sqrt(*(x))) #define d_tan(x) (tan(*(x))) #define d_tanh(x) (tanh(*(x))) #define i_abs(x) abs(*(x)) #define i_dnnt(x) ((integer)u_nint(*(x))) #define i_len(s, n) (n) #define i_nint(x) ((integer)u_nint(*(x))) #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) #define pow_si(B,E) spow_ui(*(B),*(E)) #define pow_ri(B,E) spow_ui(*(B),*(E)) #define pow_di(B,E) dpow_ui(*(B),*(E)) #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } #define sig_die(s, kill) { exit(1); } #define s_stop(s, n) {exit(0);} static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; #define z_abs(z) (cabs(Cd(z))) #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} #define myexit_() break; #define mycycle() continue; #define myceiling(w) {ceil(w)} #define myhuge(w) {HUGE_VAL} //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} /* procedure parameter types for -A and -C++ */ #define F2C_proc_par_types 1 #ifdef __cplusplus typedef logical (*L_fp)(...); #else typedef logical (*L_fp)(); #endif static float spow_ui(float x, integer n) { float pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } static double dpow_ui(double x, integer n) { double pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } #ifdef _MSC_VER static _Fcomplex cpow_ui(complex x, integer n) { complex pow={1.0,0.0}; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x.r = 1/x.r, x.i=1/x.i; for(u = n; ; ) { if(u & 01) pow.r *= x.r, pow.i *= x.i; if(u >>= 1) x.r *= x.r, x.i *= x.i; else break; } } _Fcomplex p={pow.r, pow.i}; return p; } #else static _Complex float cpow_ui(_Complex float x, integer n) { _Complex float pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } #endif #ifdef _MSC_VER static _Dcomplex zpow_ui(_Dcomplex x, integer n) { _Dcomplex pow={1.0,0.0}; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x._Val[0] = 1/x._Val[0], x._Val[1] =1/x._Val[1]; for(u = n; ; ) { if(u & 01) pow._Val[0] *= x._Val[0], pow._Val[1] *= x._Val[1]; if(u >>= 1) x._Val[0] *= x._Val[0], x._Val[1] *= x._Val[1]; else break; } } _Dcomplex p = {pow._Val[0], pow._Val[1]}; return p; } #else static _Complex double zpow_ui(_Complex double x, integer n) { _Complex double pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } #endif static integer pow_ii(integer x, integer n) { integer pow; unsigned long int u; if (n <= 0) { if (n == 0 || x == 1) pow = 1; else if (x != -1) pow = x == 0 ? 1/x : 0; else n = -n; } if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { u = n; for(pow = 1; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } static integer dmaxloc_(double *w, integer s, integer e, integer *n) { double m; integer i, mi; for(m=w[s-1], mi=s, i=s+1; i<=e; i++) if (w[i-1]>m) mi=i ,m=w[i-1]; return mi-s+1; } static integer smaxloc_(float *w, integer s, integer e, integer *n) { float m; integer i, mi; for(m=w[s-1], mi=s, i=s+1; i<=e; i++) if (w[i-1]>m) mi=i ,m=w[i-1]; return mi-s+1; } static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; #ifdef _MSC_VER _Fcomplex zdotc = {0.0, 0.0}; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += conjf(Cf(&x[i]))._Val[0] * Cf(&y[i])._Val[0]; zdotc._Val[1] += conjf(Cf(&x[i]))._Val[1] * Cf(&y[i])._Val[1]; } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += conjf(Cf(&x[i*incx]))._Val[0] * Cf(&y[i*incy])._Val[0]; zdotc._Val[1] += conjf(Cf(&x[i*incx]))._Val[1] * Cf(&y[i*incy])._Val[1]; } } pCf(z) = zdotc; } #else _Complex float zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); } } pCf(z) = zdotc; } #endif static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; #ifdef _MSC_VER _Dcomplex zdotc = {0.0, 0.0}; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += conj(Cd(&x[i]))._Val[0] * Cd(&y[i])._Val[0]; zdotc._Val[1] += conj(Cd(&x[i]))._Val[1] * Cd(&y[i])._Val[1]; } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += conj(Cd(&x[i*incx]))._Val[0] * Cd(&y[i*incy])._Val[0]; zdotc._Val[1] += conj(Cd(&x[i*incx]))._Val[1] * Cd(&y[i*incy])._Val[1]; } } pCd(z) = zdotc; } #else _Complex double zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conj(Cd(&x[i])) * Cd(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); } } pCd(z) = zdotc; } #endif static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; #ifdef _MSC_VER _Fcomplex zdotc = {0.0, 0.0}; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += Cf(&x[i])._Val[0] * Cf(&y[i])._Val[0]; zdotc._Val[1] += Cf(&x[i])._Val[1] * Cf(&y[i])._Val[1]; } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += Cf(&x[i*incx])._Val[0] * Cf(&y[i*incy])._Val[0]; zdotc._Val[1] += Cf(&x[i*incx])._Val[1] * Cf(&y[i*incy])._Val[1]; } } pCf(z) = zdotc; } #else _Complex float zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cf(&x[i]) * Cf(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); } } pCf(z) = zdotc; } #endif static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; #ifdef _MSC_VER _Dcomplex zdotc = {0.0, 0.0}; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += Cd(&x[i])._Val[0] * Cd(&y[i])._Val[0]; zdotc._Val[1] += Cd(&x[i])._Val[1] * Cd(&y[i])._Val[1]; } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += Cd(&x[i*incx])._Val[0] * Cd(&y[i*incy])._Val[0]; zdotc._Val[1] += Cd(&x[i*incx])._Val[1] * Cd(&y[i*incy])._Val[1]; } } pCd(z) = zdotc; } #else _Complex double zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cd(&x[i]) * Cd(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); } } pCd(z) = zdotc; } #endif /* -- translated by f2c (version 20000121). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ /* Table of constant values */ static integer c__1 = 1; static integer c_n1 = -1; static integer c__3 = 3; static integer c__2 = 2; /* > \brief \b SORGQR */ /* =========== DOCUMENTATION =========== */ /* Online html documentation available at */ /* http://www.netlib.org/lapack/explore-html/ */ /* > \htmlonly */ /* > Download SORGQR + dependencies */ /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sorgqr. f"> */ /* > [TGZ]</a> */ /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sorgqr. f"> */ /* > [ZIP]</a> */ /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sorgqr. f"> */ /* > [TXT]</a> */ /* > \endhtmlonly */ /* Definition: */ /* =========== */ /* SUBROUTINE SORGQR( M, N, K, A, LDA, TAU, WORK, LWORK, INFO ) */ /* INTEGER INFO, K, LDA, LWORK, M, N */ /* REAL A( LDA, * ), TAU( * ), WORK( * ) */ /* > \par Purpose: */ /* ============= */ /* > */ /* > \verbatim */ /* > */ /* > SORGQR generates an M-by-N real matrix Q with orthonormal columns, */ /* > which is defined as the first N columns of a product of K elementary */ /* > reflectors of order M */ /* > */ /* > Q = H(1) H(2) . . . H(k) */ /* > */ /* > as returned by SGEQRF. */ /* > \endverbatim */ /* Arguments: */ /* ========== */ /* > \param[in] M */ /* > \verbatim */ /* > M is INTEGER */ /* > The number of rows of the matrix Q. M >= 0. */ /* > \endverbatim */ /* > */ /* > \param[in] N */ /* > \verbatim */ /* > N is INTEGER */ /* > The number of columns of the matrix Q. M >= N >= 0. */ /* > \endverbatim */ /* > */ /* > \param[in] K */ /* > \verbatim */ /* > K is INTEGER */ /* > The number of elementary reflectors whose product defines the */ /* > matrix Q. N >= K >= 0. */ /* > \endverbatim */ /* > */ /* > \param[in,out] A */ /* > \verbatim */ /* > A is REAL array, dimension (LDA,N) */ /* > On entry, the i-th column must contain the vector which */ /* > defines the elementary reflector H(i), for i = 1,2,...,k, as */ /* > returned by SGEQRF in the first k columns of its array */ /* > argument A. */ /* > On exit, the M-by-N matrix Q. */ /* > \endverbatim */ /* > */ /* > \param[in] LDA */ /* > \verbatim */ /* > LDA is INTEGER */ /* > The first dimension of the array A. LDA >= f2cmax(1,M). */ /* > \endverbatim */ /* > */ /* > \param[in] TAU */ /* > \verbatim */ /* > TAU is REAL array, dimension (K) */ /* > TAU(i) must contain the scalar factor of the elementary */ /* > reflector H(i), as returned by SGEQRF. */ /* > \endverbatim */ /* > */ /* > \param[out] WORK */ /* > \verbatim */ /* > WORK is REAL array, dimension (MAX(1,LWORK)) */ /* > On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ /* > \endverbatim */ /* > */ /* > \param[in] LWORK */ /* > \verbatim */ /* > LWORK is INTEGER */ /* > The dimension of the array WORK. LWORK >= f2cmax(1,N). */ /* > For optimum performance LWORK >= N*NB, where NB is the */ /* > optimal blocksize. */ /* > */ /* > If LWORK = -1, then a workspace query is assumed; the routine */ /* > only calculates the optimal size of the WORK array, returns */ /* > this value as the first entry of the WORK array, and no error */ /* > message related to LWORK is issued by XERBLA. */ /* > \endverbatim */ /* > */ /* > \param[out] INFO */ /* > \verbatim */ /* > INFO is INTEGER */ /* > = 0: successful exit */ /* > < 0: if INFO = -i, the i-th argument has an illegal value */ /* > \endverbatim */ /* Authors: */ /* ======== */ /* > \author Univ. of Tennessee */ /* > \author Univ. of California Berkeley */ /* > \author Univ. of Colorado Denver */ /* > \author NAG Ltd. */ /* > \date December 2016 */ /* > \ingroup realOTHERcomputational */ /* ===================================================================== */ /* Subroutine */ int sorgqr_(integer *m, integer *n, integer *k, real *a, integer *lda, real *tau, real *work, integer *lwork, integer *info) { /* System generated locals */ integer a_dim1, a_offset, i__1, i__2, i__3; /* Local variables */ integer i__, j, l, nbmin, iinfo, ib; extern /* Subroutine */ int sorg2r_(integer *, integer *, integer *, real *, integer *, real *, real *, integer *); integer nb, ki, kk, nx; extern /* Subroutine */ int slarfb_(char *, char *, char *, char *, integer *, integer *, integer *, real *, integer *, real *, integer *, real *, integer *, real *, integer *), xerbla_(char *, integer *, ftnlen); extern integer ilaenv_(integer *, char *, char *, integer *, integer *, integer *, integer *, ftnlen, ftnlen); extern /* Subroutine */ int slarft_(char *, char *, integer *, integer *, real *, integer *, real *, real *, integer *); integer ldwork, lwkopt; logical lquery; integer iws; /* -- LAPACK computational routine (version 3.7.0) -- */ /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ /* December 2016 */ /* ===================================================================== */ /* Test the input arguments */ /* Parameter adjustments */ a_dim1 = *lda; a_offset = 1 + a_dim1 * 1; a -= a_offset; --tau; --work; /* Function Body */ *info = 0; nb = ilaenv_(&c__1, "SORGQR", " ", m, n, k, &c_n1, (ftnlen)6, (ftnlen)1); lwkopt = f2cmax(1,*n) * nb; work[1] = (real) lwkopt; lquery = *lwork == -1; if (*m < 0) { *info = -1; } else if (*n < 0 || *n > *m) { *info = -2; } else if (*k < 0 || *k > *n) { *info = -3; } else if (*lda < f2cmax(1,*m)) { *info = -5; } else if (*lwork < f2cmax(1,*n) && ! lquery) { *info = -8; } if (*info != 0) { i__1 = -(*info); xerbla_("SORGQR", &i__1, (ftnlen)6); return 0; } else if (lquery) { return 0; } /* Quick return if possible */ if (*n <= 0) { work[1] = 1.f; return 0; } nbmin = 2; nx = 0; iws = *n; if (nb > 1 && nb < *k) { /* Determine when to cross over from blocked to unblocked code. */ /* Computing MAX */ i__1 = 0, i__2 = ilaenv_(&c__3, "SORGQR", " ", m, n, k, &c_n1, ( ftnlen)6, (ftnlen)1); nx = f2cmax(i__1,i__2); if (nx < *k) { /* Determine if workspace is large enough for blocked code. */ ldwork = *n; iws = ldwork * nb; if (*lwork < iws) { /* Not enough workspace to use optimal NB: reduce NB and */ /* determine the minimum value of NB. */ nb = *lwork / ldwork; /* Computing MAX */ i__1 = 2, i__2 = ilaenv_(&c__2, "SORGQR", " ", m, n, k, &c_n1, (ftnlen)6, (ftnlen)1); nbmin = f2cmax(i__1,i__2); } } } if (nb >= nbmin && nb < *k && nx < *k) { /* Use blocked code after the last block. */ /* The first kk columns are handled by the block method. */ ki = (*k - nx - 1) / nb * nb; /* Computing MIN */ i__1 = *k, i__2 = ki + nb; kk = f2cmin(i__1,i__2); /* Set A(1:kk,kk+1:n) to zero. */ i__1 = *n; for (j = kk + 1; j <= i__1; ++j) { i__2 = kk; for (i__ = 1; i__ <= i__2; ++i__) { a[i__ + j * a_dim1] = 0.f; /* L10: */ } /* L20: */ } } else { kk = 0; } /* Use unblocked code for the last or only block. */ if (kk < *n) { i__1 = *m - kk; i__2 = *n - kk; i__3 = *k - kk; sorg2r_(&i__1, &i__2, &i__3, &a[kk + 1 + (kk + 1) * a_dim1], lda, & tau[kk + 1], &work[1], &iinfo); } if (kk > 0) { /* Use blocked code */ i__1 = -nb; for (i__ = ki + 1; i__1 < 0 ? i__ >= 1 : i__ <= 1; i__ += i__1) { /* Computing MIN */ i__2 = nb, i__3 = *k - i__ + 1; ib = f2cmin(i__2,i__3); if (i__ + ib <= *n) { /* Form the triangular factor of the block reflector */ /* H = H(i) H(i+1) . . . H(i+ib-1) */ i__2 = *m - i__ + 1; slarft_("Forward", "Columnwise", &i__2, &ib, &a[i__ + i__ * a_dim1], lda, &tau[i__], &work[1], &ldwork); /* Apply H to A(i:m,i+ib:n) from the left */ i__2 = *m - i__ + 1; i__3 = *n - i__ - ib + 1; slarfb_("Left", "No transpose", "Forward", "Columnwise", & i__2, &i__3, &ib, &a[i__ + i__ * a_dim1], lda, &work[ 1], &ldwork, &a[i__ + (i__ + ib) * a_dim1], lda, & work[ib + 1], &ldwork); } /* Apply H to rows i:m of current block */ i__2 = *m - i__ + 1; sorg2r_(&i__2, &ib, &ib, &a[i__ + i__ * a_dim1], lda, &tau[i__], & work[1], &iinfo); /* Set rows 1:i-1 of current block to zero */ i__2 = i__ + ib - 1; for (j = i__; j <= i__2; ++j) { i__3 = i__ - 1; for (l = 1; l <= i__3; ++l) { a[l + j * a_dim1] = 0.f; /* L30: */ } /* L40: */ } /* L50: */ } } work[1] = (real) iws; return 0; /* End of SORGQR */ } /* sorgqr_ */
the_stack_data/126816.c
/*Exercise 3 - Repetition Write a C program to calculate the sum of the numbers from 1 to n. Where n is a keyboard input. e.g. n -> 100 sum = 1+2+3+....+ 99+100 = 5050 n -> 1- sum = 1+2+3+...+10 = 55 */ #include <stdio.h> int main() { int n,i=0,sum=0; printf("Enter a number :"); scanf("%d",&n); while(i<=n) { sum+=i; i++; } printf("Sum is :%d",sum); return 0; }
the_stack_data/154830077.c
int main() { int i, j, rows; printf("Enter number of rows: "); scanf("%d",&rows); for(i=1; i<=rows; ++i) { for(j=1; j<=i; ++j) { printf("* "); } printf("\n"); } return 0; }
the_stack_data/93887323.c
#include <stdio.h> int main() { void scalarMultiply(int matrix[3][5], int scalar); void displayMatrix(int matrix[3][5]); int sampleMatrix[3][5] = { { 7, 16, 55, 13, 12 }, { 12, 10, 52, 0, 7 }, { -2, 1, 2, 4, 9 } }; printf("Original matrix:\n"); displayMatrix(sampleMatrix); scalarMultiply(sampleMatrix, 2); printf("\nMultiplied by 2:\n"); displayMatrix(sampleMatrix); scalarMultiply(sampleMatrix, -1); printf("\nThen multiplied by -1:\n"); displayMatrix(sampleMatrix); } void scalarMultiply(int matrix[3][5], int scalar) { int row, column; for(row = 0; row < 3; ++row) for(column = 0; column < 5; ++column) matrix[row][column] *= scalar; } void displayMatrix(int matrix[3][5]) { int row, column; for(row = 0; row < 3; ++row) for(column = 0; column < 5; ++column) printf("%5i", matrix[row][column]); printf("\n"); }
the_stack_data/197290.c
// Test that gcc-toolchain option works correctly with a aarch64-linux-gnu // triple. // // RUN: %clang %s -### -v --target=aarch64-linux-gnu \ // RUN: --gcc-toolchain=%S/Inputs/basic_android_ndk_tree/ 2>&1 \ // RUN: | FileCheck %s // // CHECK: Selected GCC installation: {{.*}}/Inputs/basic_android_ndk_tree/lib/gcc/aarch64-linux-android/4.9
the_stack_data/17825.c
#include<stdio.h> // Maximum number of digits in output #define MAX 1000 int main() { int n; printf("Enter the number to find factorial: "); scanf("%d", &n); //logic int a[MAX], times, temp; a[0] = 1; times = 0; for(; n>=2; n--) { temp = 0; for(int i = 0; i<=times; i++) { temp = (a[i] * n) + temp; a[i] = temp % 10; temp = temp / 10; } while(temp > 0) { a[++times] = temp % 10; temp = temp / 10; } } //print result for(int i = times; i>=0; i--) printf("%d", a[i]); return 0; }
the_stack_data/679355.c
#include <stdio.h> int main(int argc, char* argv[]) { if (argc < 2) { printf("please specfiy file path\n"); return 1; } FILE* f = fopen(argv[1], "w"); fclose(f); }
the_stack_data/151318.c
// C program for selection sort #include <stdio.h> void swap(int *xp, int *yp) { int temp = *xp; *xp = *yp; *yp = temp; } void selectionSort(int arr[], int n) { int i, j, min_idx; // One by one move boundary of unsorted subarray for (i = 0; i < n - 1; i++) { // Find the minimum element in unsorted array min_idx = i; for (j = i + 1; j < n; j++) if (arr[j] < arr[min_idx]) min_idx = j; // Swap the found minimum element with the first element swap(&arr[min_idx], &arr[i]); } } // A utility function to print an array of size n void printArray(int arr[], int n) { int i; printf("The array after running selection sort is : ["); for (i = 0; i < n - 1; i++) printf("%d, ", arr[i]); printf("%d]\n", arr[n - 1]); } // Driver code int main() { int arr[] = {100, 1, 10, -1, 0}; int n = 5; selectionSort(arr, n); printArray(arr, n); return 0; } // Output : // The array after running selection sort is : [-1, 0, 1, 10, 100]
the_stack_data/1267166.c
/* For intrinsics fclose() and fopen() */ #include <stdio.h> void fclose01() { FILE * f; f = fopen("toto", "r"); fclose(f); return; }
the_stack_data/1027334.c
#include <stdio.h> #include <stdlib.h> int main() { char food[] = "Yummy"; char *ptr; ptr = food + strlen(food); while (--ptr >= food) puts(ptr); return 0; }
the_stack_data/150090.c
extern void __VERIFIER_error() __attribute__ ((__noreturn__)); void __VERIFIER_assert(int expression) { if (!expression) { ERROR: /* assert not proved */ __VERIFIER_error(); }; return; } int __global_lock; void __VERIFIER_atomic_begin() { /* reachable */ /* reachable */ /* reachable */ /* reachable */ __VERIFIER_assume(__global_lock==0); __global_lock=1; return; } void __VERIFIER_atomic_end() { __VERIFIER_assume(__global_lock==1); __global_lock=0; return; } #include <assert.h> #include <pthread.h> #ifndef TRUE #define TRUE (_Bool)1 #endif #ifndef FALSE #define FALSE (_Bool)0 #endif #ifndef NULL #define NULL ((void*)0) #endif #ifndef FENCE #define FENCE(x) ((void)0) #endif #ifndef IEEE_FLOAT_EQUAL #define IEEE_FLOAT_EQUAL(x,y) (x==y) #endif #ifndef IEEE_FLOAT_NOTEQUAL #define IEEE_FLOAT_NOTEQUAL(x,y) (x!=y) #endif void * P0(void *arg); void * P1(void *arg); void * P2(void *arg); void fence(); void isync(); void lwfence(); int __unbuffered_cnt; int __unbuffered_cnt = 0; int __unbuffered_p2_EAX; int __unbuffered_p2_EAX = 0; int __unbuffered_p2_EBX; int __unbuffered_p2_EBX = 0; _Bool main$tmp_guard0; _Bool main$tmp_guard1; int x; int x = 0; int y; int y = 0; void * P0(void *arg) { __VERIFIER_atomic_begin(); y = 2; __VERIFIER_atomic_end(); __VERIFIER_atomic_begin(); x = 1; __VERIFIER_atomic_end(); __VERIFIER_atomic_begin(); __VERIFIER_atomic_end(); __VERIFIER_atomic_begin(); __unbuffered_cnt = __unbuffered_cnt + 1; __VERIFIER_atomic_end(); return nondet_0(); } void * P1(void *arg) { __VERIFIER_atomic_begin(); x = 2; __VERIFIER_atomic_end(); __VERIFIER_atomic_begin(); y = 1; __VERIFIER_atomic_end(); __VERIFIER_atomic_begin(); __VERIFIER_atomic_end(); __VERIFIER_atomic_begin(); __unbuffered_cnt = __unbuffered_cnt + 1; __VERIFIER_atomic_end(); return nondet_0(); } void * P2(void *arg) { __VERIFIER_atomic_begin(); __unbuffered_p2_EAX = y; __VERIFIER_atomic_end(); __VERIFIER_atomic_begin(); __unbuffered_p2_EBX = y; __VERIFIER_atomic_end(); __VERIFIER_atomic_begin(); __VERIFIER_atomic_end(); __VERIFIER_atomic_begin(); __unbuffered_cnt = __unbuffered_cnt + 1; __VERIFIER_atomic_end(); return nondet_0(); } void fence() { } void isync() { } void lwfence() { } int main() { pthread_create(NULL, NULL, P0, NULL); pthread_create(NULL, NULL, P1, NULL); pthread_create(NULL, NULL, P2, NULL); __VERIFIER_atomic_begin(); main$tmp_guard0 = __unbuffered_cnt == 3; __VERIFIER_atomic_end(); __VERIFIER_assume(main$tmp_guard0); __VERIFIER_atomic_begin(); __VERIFIER_atomic_end(); __VERIFIER_atomic_begin(); /* Program was expected to be safe for X86, model checker should have said NO. This likely is a bug in the tool chain. */ main$tmp_guard1 = !(x == 2 && y == 2 && __unbuffered_p2_EAX == 1 && __unbuffered_p2_EBX == 1); __VERIFIER_atomic_end(); /* Program was expected to be safe for X86, model checker should have said NO. This likely is a bug in the tool chain. */ __VERIFIER_assert(main$tmp_guard1); /* reachable */ return 0; }
the_stack_data/58521.c
#ifdef COMPILE_FOR_TEST #include <assert.h> #define assume(cond) assert(cond) #endif void main(int argc, char* argv[]) { int x_0_0;//sh_buf.outcnt int x_0_1;//sh_buf.outcnt int x_0_2;//sh_buf.outcnt int x_0_3;//sh_buf.outcnt int x_1_0;//sh_buf.outbuf[0] int x_1_1;//sh_buf.outbuf[0] int x_2_0;//sh_buf.outbuf[1] int x_2_1;//sh_buf.outbuf[1] int x_3_0;//sh_buf.outbuf[2] int x_3_1;//sh_buf.outbuf[2] int x_4_0;//sh_buf.outbuf[3] int x_4_1;//sh_buf.outbuf[3] int x_5_0;//sh_buf.outbuf[4] int x_5_1;//sh_buf.outbuf[4] int x_6_0;//sh_buf.outbuf[5] int x_7_0;//sh_buf.outbuf[6] int x_8_0;//sh_buf.outbuf[7] int x_9_0;//sh_buf.outbuf[8] int x_10_0;//sh_buf.outbuf[9] int x_11_0;//LOG_BUFSIZE int x_11_1;//LOG_BUFSIZE int x_12_0;//CREST_scheduler::lock_0 int x_12_1;//CREST_scheduler::lock_0 int x_12_2;//CREST_scheduler::lock_0 int x_13_0;//t3 T0 int x_14_0;//t2 T0 int x_15_0;//arg T0 int x_16_0;//functioncall::param T0 int x_16_1;//functioncall::param T0 int x_17_0;//buffered T0 int x_18_0;//functioncall::param T0 int x_18_1;//functioncall::param T0 int x_19_0;//functioncall::param T0 int x_19_1;//functioncall::param T0 int x_20_0;//functioncall::param T0 int x_20_1;//functioncall::param T0 int x_20_2;//functioncall::param T0 int x_21_0;//functioncall::param T0 int x_21_1;//functioncall::param T0 int x_22_0;//direction T0 int x_23_0;//functioncall::param T0 int x_23_1;//functioncall::param T0 int x_24_0;//functioncall::param T0 int x_24_1;//functioncall::param T0 int x_25_0;//functioncall::param T0 int x_25_1;//functioncall::param T0 int x_26_0;//functioncall::param T0 int x_26_1;//functioncall::param T0 int x_27_0;//functioncall::param T0 int x_27_1;//functioncall::param T0 int x_28_0;//functioncall::param T0 int x_28_1;//functioncall::param T0 int x_29_0;//functioncall::param T0 int x_29_1;//functioncall::param T0 int x_30_0;//functioncall::param T0 int x_30_1;//functioncall::param T0 int x_31_0;//functioncall::param T0 int x_31_1;//functioncall::param T0 int x_32_0;//functioncall::param T0 int x_32_1;//functioncall::param T0 int x_33_0;//functioncall::param T0 int x_33_1;//functioncall::param T0 int x_34_0;//functioncall::param T0 int x_34_1;//functioncall::param T0 int x_35_0;//functioncall::param T1 int x_35_1;//functioncall::param T1 int x_36_0;//functioncall::param T1 int x_36_1;//functioncall::param T1 int x_37_0;//i T1 int x_37_1;//i T1 int x_37_2;//i T1 int x_38_0;//rv T1 int x_39_0;//functioncall::param T1 int x_39_1;//functioncall::param T1 int x_40_0;//functioncall::param T1 int x_40_1;//functioncall::param T1 int x_41_0;//functioncall::param T1 int x_41_1;//functioncall::param T1 int x_42_0;//functioncall::param T1 int x_42_1;//functioncall::param T1 int x_43_0;//functioncall::param T1 int x_43_1;//functioncall::param T1 int x_44_0;//functioncall::param T1 int x_44_1;//functioncall::param T1 int x_45_0;//functioncall::param T2 int x_45_1;//functioncall::param T2 int x_46_0;//functioncall::param T2 int x_46_1;//functioncall::param T2 int x_47_0;//i T2 int x_48_0;//rv T2 int x_49_0;//rv T2 int x_50_0;//blocksize T2 int x_50_1;//blocksize T2 int x_51_0;//functioncall::param T2 int x_51_1;//functioncall::param T2 int x_51_2;//functioncall::param T2 int x_52_0;//apr_thread_mutex_lock::rv T2 int x_52_1;//apr_thread_mutex_lock::rv T2 int x_53_0;//functioncall::param T2 int x_53_1;//functioncall::param T2 int x_54_0;//status T2 int x_54_1;//status T2 int x_55_0;//functioncall::param T2 int x_55_1;//functioncall::param T2 int x_56_0;//functioncall::param T2 int x_56_1;//functioncall::param T2 T_0_0_0: x_0_0 = 0; T_0_1_0: x_1_0 = 0; T_0_2_0: x_2_0 = 0; T_0_3_0: x_3_0 = 0; T_0_4_0: x_4_0 = 0; T_0_5_0: x_5_0 = 0; T_0_6_0: x_6_0 = 0; T_0_7_0: x_7_0 = 0; T_0_8_0: x_8_0 = 0; T_0_9_0: x_9_0 = 0; T_0_10_0: x_10_0 = 0; T_0_11_0: x_11_0 = 0; T_0_12_0: x_13_0 = 2548307184; T_0_13_0: x_14_0 = 3374457440; T_0_14_0: x_15_0 = 0; T_0_15_0: x_16_0 = 104481272; T_0_16_0: x_16_1 = -1; T_0_17_0: x_17_0 = 0; T_0_18_0: x_18_0 = 1075696118; T_0_19_0: x_18_1 = x_17_0; T_0_20_0: x_19_0 = 1816179551; T_0_21_0: x_19_1 = 97; T_0_22_0: x_20_0 = 553080558; T_0_23_0: x_20_1 = 0; T_0_24_0: x_21_0 = 1065725624; T_0_25_0: x_21_1 = 0; T_0_26_0: x_22_0 = -920514496; T_0_27_0: x_23_0 = 764564617; T_0_28_0: x_23_1 = x_22_0; T_0_29_0: x_24_0 = 914021225; T_0_30_0: x_24_1 = 0; T_0_31_0: x_12_0 = -1; T_0_32_0: x_0_1 = 5; T_0_33_0: x_1_1 = 72; T_0_34_0: x_2_1 = 69; T_0_35_0: x_3_1 = 76; T_0_36_0: x_4_1 = 76; T_0_37_0: x_5_1 = 79; T_0_38_0: x_25_0 = 160485001; T_0_39_0: x_25_1 = 83; T_0_40_0: x_26_0 = 1647043289; T_0_41_0: x_26_1 = 1; T_0_42_0: x_27_0 = 757722713; T_0_43_0: x_27_1 = 1; T_0_44_0: x_28_0 = 158470899; T_0_45_0: x_28_1 = 1; T_0_46_0: x_29_0 = 473643410; T_0_47_0: x_29_1 = 82; T_0_48_0: x_30_0 = 1143796457; T_0_49_0: x_30_1 = 90; T_0_50_0: x_31_0 = 871119947; T_0_51_0: x_31_1 = 1; T_0_52_0: x_32_0 = 352204055; T_0_53_0: x_32_1 = 1; T_0_54_0: x_33_0 = 1187226754; T_0_55_0: x_33_1 = 2; T_0_56_0: x_34_0 = 115447337; T_0_57_0: x_34_1 = 2; T_0_58_0: x_11_1 = 6; T_1_59_1: x_35_0 = 1444425422; T_1_60_1: x_35_1 = x_27_1; T_1_61_1: x_36_0 = 139824472; T_1_62_1: x_36_1 = x_28_1; T_1_63_1: x_37_0 = 0; T_1_64_1: x_38_0 = 871952897; T_1_65_1: if (x_36_1 < x_11_1) x_39_0 = 186006599; T_1_66_1: if (x_36_1 < x_11_1) x_39_1 = 47699034838784; T_2_67_2: x_45_0 = 178205797; T_2_68_2: x_45_1 = x_33_1; T_2_69_2: x_46_0 = 1438968217; T_2_70_2: x_46_1 = x_34_1; T_2_71_2: x_47_0 = 0; T_2_72_2: x_48_0 = 869851649; T_1_73_1: if (x_36_1 < x_11_1) x_40_0 = 1573397497; T_1_74_1: if (x_36_1 < x_11_1) x_40_1 = x_0_1 + x_36_1; T_1_75_1: if (x_36_1 < x_11_1) x_37_1 = 0; T_1_76_1: if (x_36_1 < x_11_1 && x_37_1 < x_35_1) x_41_0 = 406737122; T_1_77_1: if (x_36_1 < x_11_1 && x_37_1 < x_35_1) x_41_1 = 47699034838784; T_1_78_1: if (x_36_1 < x_11_1) x_37_2 = 1 + x_37_1; T_1_79_1: if (x_36_1 < x_11_1) x_42_0 = 1510540382; T_1_80_1: if (x_36_1 < x_11_1) x_42_1 = 47699034838784; T_2_81_2: if (x_0_1 + x_46_1 > x_11_1 && x_0_1 != 0) x_49_0 = 4321289; T_2_82_2: if (x_0_1 + x_46_1 > x_11_1 && x_0_1 != 0 && x_18_1 != 0) x_50_0 = 0; T_2_83_2: if (x_36_1 < x_11_1) x_0_2 = x_0_1 + x_36_1; T_1_84_1: if (x_0_1 + x_46_1 > x_11_1 && x_0_1 != 0 && x_18_1 != 0) x_51_0 = 736415820; T_2_85_2: if (x_0_1 + x_46_1 > x_11_1 && x_0_1 != 0 && x_18_1 != 0) x_51_1 = x_0_1; T_2_86_2: if (x_0_1 + x_46_1 > x_11_1 && x_0_1 != 0 && x_18_1 != 0 && x_0_1 == x_51_1) x_52_0 = 0; T_2_87_2: if (x_36_1 < x_11_1) x_43_0 = 721807607; T_2_88_2: if (x_36_1 < x_11_1) x_43_1 = 47699034838784; T_1_89_1: if (x_0_1 + x_46_1 > x_11_1 && x_0_1 != 0 && x_18_1 != 0 && x_0_1 == x_51_1 && 0 == x_12_0 + 1) x_12_1 = 2; T_1_90_1: if (x_0_1 + x_46_1 > x_11_1 && x_0_1 != 0 && x_18_1 != 0 && x_0_1 == x_51_1 && 2 == x_12_1) x_52_1 = 0; T_2_91_2: if (x_0_1 + x_46_1 > x_11_1 && x_0_1 != 0 && x_18_1 != 0 && 2 == x_12_1) x_53_0 = 1480196210; T_2_92_2: if (x_0_1 + x_46_1 > x_11_1 && x_0_1 != 0 && x_18_1 != 0 && 2 == x_12_1) x_53_1 = 0; T_2_93_2: if (x_0_1 + x_46_1 > x_11_1 && x_0_1 != 0 && x_18_1 != 0 && 0 == x_53_1 && 2 == x_12_1) x_50_1 = x_51_1; T_2_94_2: if (x_0_1 + x_46_1 > x_11_1 && x_0_1 != 0 && x_18_1 != 0 && 0 == x_53_1 && 2 == x_12_1) x_20_2 = x_20_1 + x_50_1; T_2_95_2: if (x_0_1 + x_46_1 > x_11_1 && x_0_1 != 0 && x_18_1 != 0 && 0 == x_53_1 && 2 == x_12_1) x_51_2 = -1*x_50_1 + x_51_1; T_2_96_2: if (x_0_1 + x_46_1 > x_11_1 && x_0_1 != 0 && x_18_1 != 0 && x_51_2 <= 0 && 2 == x_12_1) x_54_0 = 0; T_2_97_2: if (x_0_1 + x_46_1 > x_11_1 && x_0_1 != 0 && x_18_1 != 0 && x_51_2 <= 0 && 2 == x_12_1) x_12_2 = -1; T_2_98_2: if (x_0_1 + x_46_1 > x_11_1 && x_0_1 != 0 && x_18_1 != 0 && x_51_2 <= 0) x_54_1 = 0; T_2_99_2: if (x_0_1 + x_46_1 > x_11_1 && x_0_1 != 0) x_55_0 = 116467306; T_2_100_2: if (x_0_1 + x_46_1 > x_11_1 && x_0_1 != 0) x_55_1 = x_53_1; T_2_101_2: if (x_0_1 + x_46_1 > x_11_1 && x_0_1 != 0) x_56_0 = 276529626; T_2_102_2: if (x_0_1 + x_46_1 > x_11_1 && x_0_1 != 0) x_56_1 = x_55_1; T_2_103_2: if (x_0_1 + x_46_1 > x_11_1 && x_0_1 != 0) x_0_3 = 0; T_2_104_2: if (x_36_1 < x_11_1) x_44_0 = 695963666; T_2_105_2: if (x_36_1 < x_11_1) x_44_1 = 47699034838784; T_2_106_2: if (x_36_1 < x_11_1) assert(x_0_3 == x_40_1); }
the_stack_data/125141771.c
#include <stdio.h> #include <string.h> #include <math.h> #include <stdlib.h> #include <assert.h> int cmpfunc(const void *a,const void *b); int main() { int n,a[101],i; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d",&a[i]); } qsort(a,n,sizeof(int),cmpfunc); for(i=0;i<n;i=i+2) { if(a[i]!=a[i+1]) { printf("%d",a[i]); break; } } return 0; } int cmpfunc(const void *a,const void *b) { int *p=(int *)a; int *q=(int *)b; return(*p-*q); }
the_stack_data/611917.c
#include "stdio.h" int main() { int row, col; for(row=1; row<10; row++){ for(col=1; col<10; col++) printf("%4d", row*col); putchar('\n'); } return 0; }
the_stack_data/95450952.c
#include "assert.h" int main() { int count = 0; do { count = count + 1; } while(count < 5); do { } while(count < 5); while(count < 5) ; assert(count == 5); assert(count == 17); }
the_stack_data/243894015.c
#include <stdio.h> #include <stdlib.h> typedef struct node { int val; struct node *next; } node_t; //Funcion para anadir al final de la lista void addEnd(node_t *head, int val); //Funcion para anadir al principio de la lista void addStart(node_t **head, int val); //Funcion para quitar al principio que nos devuelve el elemento que hemos borrado int pop(node_t **head); //Funcion para imprimir la lista void print(node_t *head); int main(){ node_t *head = NULL; head = malloc(sizeof(node_t)); if(head == NULL){ return 1; };//Si el primero nodo esta vacio cerramos head -> val = 1; head -> next = malloc(sizeof(node_t)); head -> next -> val = 2; head -> next -> next = NULL; addStart(&head, 2); addEnd(head, 3); printf("Cuando haces pop no hay stop %d\n", pop(&head)); print(head); } //Funcion para anadir al final de la lista void addEnd(node_t *head, int val){ node_t *current = head; while(current->next != NULL){ current = current->next; } //Ahora ya estamos en el ultimo nodo current->next = malloc(sizeof(node_t)); current->next->val = val; current->next->next = NULL; } //Funcion para anadir al principio de la lista void addStart(node_t **head, int val){ node_t *nuevo_nodo; nuevo_nodo = malloc(sizeof(node_t)); nuevo_nodo -> val = val; //Le asignamos su valor nuevo_nodo -> next = *head; //Asignamos a next un puntero a donde esta head *head = nuevo_nodo;//Ahora head es el nuevo nodo } //Funcion para imprimir la lista void print(node_t *head){ node_t *current = head; while(current != NULL){ printf("%d\n",current->val); current = current->next; } } //Funcion para borrar al principio que nos devuelve el elemento borrado int pop(node_t **head){ int retval = -1; //Iniciamos el valor que se devuelve node_t *siguiente_nodo = NULL; //Si la lista esta vacia devolveremos -1 if(*head == NULL){ return -1; } siguiente_nodo = (*head)->next;//Nos movemos al segundo nodo retval = (*head)->val;//Guardamos el valor del primero para devolverlo free(*head); //Liberamos la memoria asignada a head *head = siguiente_nodo;//Asignamos a head el segundo nodo return retval;//Devolvemos el valor que hemos eliminado }
the_stack_data/76701395.c
/* -*- linux-c -*- ------------------------------------------------------- * * * Copyright 2002 H. Peter Anvin - All Rights Reserved * * 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, Inc., 53 Temple Place Ste 330, * Bostom MA 02111-1307, USA; either version 2 of the License, or * (at your option) any later version; incorporated herein by reference. * * ----------------------------------------------------------------------- */ /* * raid6sse1.c * * SSE-1/MMXEXT implementation of RAID-6 syndrome functions * * This is really an MMX implementation, but it requires SSE-1 or * AMD MMXEXT for prefetch support and a few other features. The * support for nontemporal memory accesses is enough to make this * worthwhile as a separate implementation. */ #if defined(__i386__) #include "raid6.h" #include "raid6x86.h" /* Defined in raid6mmx.c */ extern const struct raid6_mmx_constants { u64 x1d; } raid6_mmx_constants; static int raid6_have_sse1_or_mmxext(void) { #ifdef __KERNEL__ /* Not really boot_cpu but "all_cpus" */ return boot_cpu_has(X86_FEATURE_MMX) && (boot_cpu_has(X86_FEATURE_XMM) || boot_cpu_has(X86_FEATURE_MMXEXT)); #else /* User space test code - this incorrectly breaks on some Athlons */ u32 features = cpuid_features(); return ( (features & (5<<23)) == (5<<23) ); #endif } /* * Plain SSE1 implementation */ static void raid6_sse11_gen_syndrome(int disks, size_t bytes, void **ptrs) { u8 **dptr = (u8 **)ptrs; u8 *p, *q; int d, z, z0; raid6_mmx_save_t sa; z0 = disks - 3; /* Highest data disk */ p = dptr[z0+1]; /* XOR parity */ q = dptr[z0+2]; /* RS syndrome */ /* This is really MMX code, not SSE */ raid6_before_mmx(&sa); asm volatile("movq %0,%%mm0" : : "m" (raid6_mmx_constants.x1d)); asm volatile("pxor %mm5,%mm5"); /* Zero temp */ for ( d = 0 ; d < bytes ; d += 8 ) { asm volatile("prefetchnta %0" : : "m" (dptr[z0][d])); asm volatile("movq %0,%%mm2" : : "m" (dptr[z0][d])); /* P[0] */ asm volatile("prefetchnta %0" : : "m" (dptr[z0-1][d])); asm volatile("movq %mm2,%mm4"); /* Q[0] */ asm volatile("movq %0,%%mm6" : : "m" (dptr[z0-1][d])); for ( z = z0-2 ; z >= 0 ; z-- ) { asm volatile("prefetchnta %0" : : "m" (dptr[z][d])); asm volatile("pcmpgtb %mm4,%mm5"); asm volatile("paddb %mm4,%mm4"); asm volatile("pand %mm0,%mm5"); asm volatile("pxor %mm5,%mm4"); asm volatile("pxor %mm5,%mm5"); asm volatile("pxor %mm6,%mm2"); asm volatile("pxor %mm6,%mm4"); asm volatile("movq %0,%%mm6" : : "m" (dptr[z][d])); } asm volatile("pcmpgtb %mm4,%mm5"); asm volatile("paddb %mm4,%mm4"); asm volatile("pand %mm0,%mm5"); asm volatile("pxor %mm5,%mm4"); asm volatile("pxor %mm5,%mm5"); asm volatile("pxor %mm6,%mm2"); asm volatile("pxor %mm6,%mm4"); asm volatile("movntq %%mm2,%0" : "=m" (p[d])); asm volatile("movntq %%mm4,%0" : "=m" (q[d])); } raid6_after_mmx(&sa); asm volatile("sfence" : : : "memory"); } const struct raid6_calls raid6_sse1x1 = { raid6_sse11_gen_syndrome, raid6_have_sse1_or_mmxext, "sse1x1", 1 /* Has cache hints */ }; /* * Unrolled-by-2 SSE1 implementation */ static void raid6_sse12_gen_syndrome(int disks, size_t bytes, void **ptrs) { u8 **dptr = (u8 **)ptrs; u8 *p, *q; int d, z, z0; raid6_mmx_save_t sa; z0 = disks - 3; /* Highest data disk */ p = dptr[z0+1]; /* XOR parity */ q = dptr[z0+2]; /* RS syndrome */ raid6_before_mmx(&sa); asm volatile("movq %0,%%mm0" : : "m" (raid6_mmx_constants.x1d)); asm volatile("pxor %mm5,%mm5"); /* Zero temp */ asm volatile("pxor %mm7,%mm7"); /* Zero temp */ /* We uniformly assume a single prefetch covers at least 16 bytes */ for ( d = 0 ; d < bytes ; d += 16 ) { asm volatile("prefetchnta %0" : : "m" (dptr[z0][d])); asm volatile("movq %0,%%mm2" : : "m" (dptr[z0][d])); /* P[0] */ asm volatile("movq %0,%%mm3" : : "m" (dptr[z0][d+8])); /* P[1] */ asm volatile("movq %mm2,%mm4"); /* Q[0] */ asm volatile("movq %mm3,%mm6"); /* Q[1] */ for ( z = z0-1 ; z >= 0 ; z-- ) { asm volatile("prefetchnta %0" : : "m" (dptr[z][d])); asm volatile("pcmpgtb %mm4,%mm5"); asm volatile("pcmpgtb %mm6,%mm7"); asm volatile("paddb %mm4,%mm4"); asm volatile("paddb %mm6,%mm6"); asm volatile("pand %mm0,%mm5"); asm volatile("pand %mm0,%mm7"); asm volatile("pxor %mm5,%mm4"); asm volatile("pxor %mm7,%mm6"); asm volatile("movq %0,%%mm5" : : "m" (dptr[z][d])); asm volatile("movq %0,%%mm7" : : "m" (dptr[z][d+8])); asm volatile("pxor %mm5,%mm2"); asm volatile("pxor %mm7,%mm3"); asm volatile("pxor %mm5,%mm4"); asm volatile("pxor %mm7,%mm6"); asm volatile("pxor %mm5,%mm5"); asm volatile("pxor %mm7,%mm7"); } asm volatile("movntq %%mm2,%0" : "=m" (p[d])); asm volatile("movntq %%mm3,%0" : "=m" (p[d+8])); asm volatile("movntq %%mm4,%0" : "=m" (q[d])); asm volatile("movntq %%mm6,%0" : "=m" (q[d+8])); } raid6_after_mmx(&sa); asm volatile("sfence" : :: "memory"); } const struct raid6_calls raid6_sse1x2 = { raid6_sse12_gen_syndrome, raid6_have_sse1_or_mmxext, "sse1x2", 1 /* Has cache hints */ }; #endif
the_stack_data/718962.c
// Test LTO support within lld // REQUIRES: clang, lld // RUN: %clang -c -flto %s -DLIB -o %t-obj.o // RUN: %clang -c -flto %s -ULIB -o %t-main.o // RUN: %clang -fuse-ld=lld -flto %t-obj.o %t-main.o -o %t // RUN: %t | grep "hello lita" #ifdef LIB #include <stdio.h> void greet() { puts("hello lita"); } #else extern void greet(); int main() { greet(); return 0; } #endif
the_stack_data/307.c
#include <pthread.h> int n1 = 0; pthread_mutex_t num_mutex = PTHREAD_MUTEX_INITIALIZER; void f1() { int x; pthread_mutex_lock(&num_mutex); while (n1 < 10) { x = n1; pthread_mutex_unlock(&num_mutex); x = x + 1; pthread_mutex_lock(&num_mutex); n1 = x; } pthread_mutex_unlock(&num_mutex); } void f2() { pthread_mutex_lock(&num_mutex); while (n1 < 20) { if (n1 > 18) { pthread_mutex_unlock(&num_mutex); return; } n1 = n1 + 1; } pthread_mutex_unlock(&num_mutex); } void *t_fun(void *arg) { f1(); f2(); return NULL; } int main() { pthread_t id1, id2; pthread_create(&id1, NULL, t_fun, NULL); pthread_create(&id2, NULL, t_fun, NULL); pthread_join(id1, NULL); pthread_join(id2, NULL); }
the_stack_data/437299.c
#include <error.h> #include <inttypes.h> #include <pthread.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <unistd.h> #include <arpa/inet.h> #include <sys/socket.h> #include <sys/types.h> #define RECEIVER_PORT 40000 #define NUM_CONNECTIONS 14 #define READ_SIZE 512 struct conninfo { /* Filled in by the main thread. */ int index; struct sockaddr_in6 addr; socklen_t addr_len; int conn_fd; pthread_t thread_id; char addr_str[INET6_ADDRSTRLEN]; /* Filled in by the receiving thread. */ uint64_t total_bytes_received; uint64_t elapsed_nanoseconds; }; struct conninfo connections[NUM_CONNECTIONS]; void* handle_connection(void* arg) { struct conninfo* info = arg; struct timespec start_time; struct timespec end_time; char recvbuffer[READ_SIZE]; int rv = clock_gettime(CLOCK_MONOTONIC_RAW, &start_time); if (rv != 0) { perror("clock_gettime"); exit(9); } ssize_t r; do { r = recv(info->conn_fd, &recvbuffer, READ_SIZE, 0); if (r < 0) { perror("read"); exit(10); } else if (r != 0) { info->total_bytes_received += r; } } while (r != 0); rv = clock_gettime(CLOCK_MONOTONIC_RAW, &end_time); if (rv != 0) { perror("clock_gettime"); exit(11); } rv = close(info->conn_fd); if (rv != 0) { perror("close"); exit(12); } time_t seconds = end_time.tv_sec - start_time.tv_sec; long nanoseconds = end_time.tv_nsec - start_time.tv_nsec; info->elapsed_nanoseconds = (UINT64_C(1000000000) * (uint64_t) seconds) + (uint64_t) nanoseconds; printf("Connection %d from %s ended\n", info->index, info->addr_str); pthread_exit(NULL); /* Not reached. */ return NULL; } int main(int argc, char** argv) { int sock = socket(AF_INET6, SOCK_STREAM, 0); if (sock == -1) { perror("socket"); return 1; } struct sockaddr_in6 local; memset(&local, 0x00, sizeof(local)); local.sin6_family = AF_INET6; local.sin6_addr = in6addr_any; local.sin6_port = htons(RECEIVER_PORT); int rv = bind(sock, (struct sockaddr*) &local, sizeof(struct sockaddr_in6)); if (rv == -1) { perror("bind"); return 2; } rv = listen(sock, 3); if (rv == -1) { perror("listen"); return 3; } memset(connections, 0x00, sizeof(connections)); int i; for (i = 0; i != NUM_CONNECTIONS; i++) { struct conninfo* info = &connections[i]; info->index = i; info->addr_len = sizeof(info->addr); info->conn_fd = accept(sock, (struct sockaddr*) &info->addr, &info->addr_len); if (info->conn_fd == -1) { perror("accept"); return 4; } const char* dst = inet_ntop(AF_INET6, &info->addr.sin6_addr, info->addr_str, sizeof(info->addr_str)); if (dst == NULL) { perror("inet_ntop"); return 5; } printf("Accepted connection from %s\n", dst); rv = pthread_create(&info->thread_id, NULL, handle_connection, info); if (rv != 0) { fprintf(stderr, "pthread_create: %s\n", strerror(rv)); return 6; } } rv = close(sock); if (rv != 0) { perror("close"); return 7; } for (i = 0; i != NUM_CONNECTIONS; i++) { struct conninfo* info = &connections[i]; rv = pthread_join(info->thread_id, NULL); if (rv != 0) { fprintf(stderr, "pthread_join: %s\n", strerror(rv)); return 8; } } for (i = 0; i != NUM_CONNECTIONS; i++) { struct conninfo* info = &connections[i]; double throughput = ((double) (info->total_bytes_received << 3)) / (info->elapsed_nanoseconds / 1000000.0); printf("[Final] %s %" PRIu64 " %" PRIu64 " (%f kb/s)\n", info->addr_str, info->total_bytes_received, info->elapsed_nanoseconds, throughput); } return 0; }
the_stack_data/57537.c
/* * pseultra/tools/bootcsum/src/bootcsumr.c * PIFrom ipl2 checksum reverser * * (C) pseudophpt 2018 */ #include <stdint.h> #include <inttypes.h> #include <stdbool.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #define MAGIC 0x95DACFDC bool find_collision (uint32_t *bcode, uint64_t desired_checksum, uint16_t starthword); static inline uint64_t checksum_helper (uint64_t op1, uint64_t op2, uint64_t op3); int main (int argc, char *argv[]) { // If arguments not adequate if (argc != 5) { printf("Usage: bootcsumr <rom file> <checksum to search for> <starting hword> <hword stride>\n"); return 0; } FILE* rom_file; uint32_t rom_buffer[0x1000 / sizeof(uint32_t)]; rom_file = fopen(argv[1], "rb"); fread(rom_buffer, sizeof(uint32_t), 0x1000 / sizeof(uint32_t), rom_file); fclose(rom_file); // LE to BE for (int i = 0; i < 0x1000 / sizeof(uint32_t); i++) { uint32_t le = rom_buffer[i]; uint32_t be = ((le & 0xff) << 24) | ((le & 0xff00) << 8) | ((le & 0xff0000) >> 8) | ((le & 0xff000000) >> 24); rom_buffer[i] = be; } uint64_t checksum = strtoll(argv[2], NULL, 0); uint16_t starthword = strtol(argv[3], NULL, 0); uint16_t stride = strtol(argv[4], NULL, 0); while (!find_collision(&rom_buffer[0x10], checksum, starthword)) { if (UINT16_MAX - starthword < stride) { break; } starthword += stride; } return 0; } /* * Helper function commonly called during checksum */ static inline uint64_t checksum_helper (uint64_t op1, uint64_t op2, uint64_t op3) { int high_mult; int low_mult; if (op2 == 0) { op2 = op3; } low_mult = (op1 * op2) & 0x00000000FFFFFFFF; high_mult = ((op1 * op2) & 0xFFFFFFFF00000000) >> 32; if (high_mult - low_mult == 0) { return low_mult; } else return high_mult - low_mult; } /* * Try to find checksum collision */ bool find_collision (uint32_t *bcode, uint64_t desired_checksum, uint16_t starthword) { // Store starting hword into bootcode bcode[0x3ee] = (bcode[0x3ee] & 0xffff0000) | starthword; uint32_t preframe [16]; // Pre-calculated frame, up to what changes uint32_t frame [16]; // Current frame being used to test uint32_t sframe [4]; // Variables used to calculate frame uint32_t *bcode_inst_ptr = bcode; uint32_t loop_count = 0; uint32_t bcode_inst = *bcode_inst_ptr; uint32_t next_inst; uint32_t prev_inst; // Calculate magic number uint32_t magic = MAGIC ^ bcode_inst; // Generate frame. This is done earlier in IPC2 for (int i = 0; i < 16; i ++) { preframe[i] = magic; }; // Calculate pre-frame for (;;) { /* Loop start, 11E8 - 11FC */ prev_inst = bcode_inst; bcode_inst = *bcode_inst_ptr; loop_count ++; bcode_inst_ptr ++; next_inst = *(bcode_inst_ptr); /* Main processing */ preframe[0] += checksum_helper(0x3EF - loop_count, bcode_inst, loop_count); preframe[1] = checksum_helper(preframe[1], bcode_inst, loop_count); preframe[2] ^= bcode_inst; preframe[3] += checksum_helper(bcode_inst + 5, 0x6c078965, loop_count); if (prev_inst < bcode_inst) { preframe[9] = checksum_helper(preframe[9], bcode_inst, loop_count); } else preframe[9] += bcode_inst; preframe[4] += ((bcode_inst << (0x20 - (prev_inst & 0x1f))) | (bcode_inst >> (prev_inst & 0x1f))); preframe[7] = checksum_helper(preframe[7], ((bcode_inst >> (0x20 - (prev_inst & 0x1f))) | (bcode_inst << (prev_inst & 0x1f))), loop_count); if (bcode_inst < preframe[6]) { preframe[6] = (bcode_inst + loop_count) ^ (preframe[3] + preframe[6]); } else preframe[6] = (preframe[4] + bcode_inst) ^ preframe[6]; preframe[5] += (bcode_inst >> (0x20 - (prev_inst >> 27))) | (bcode_inst << (prev_inst >> 27)); preframe[8] = checksum_helper(preframe[8], (bcode_inst << (0x20 - (prev_inst >> 27))) | (bcode_inst >> (prev_inst >> 27)), loop_count); if (loop_count == 0x3ef) break; uint32_t tmp1 = checksum_helper(preframe[15], (bcode_inst >> (0x20 - (prev_inst >> 27))) | (bcode_inst << (prev_inst >> 27)), loop_count); preframe[15] = checksum_helper( tmp1, (next_inst << (bcode_inst >> 27)) | (next_inst >> (0x20 - (bcode_inst >> 27))), loop_count ); uint32_t tmp2 = ((bcode_inst << (0x20 - (prev_inst & 0x1f))) | (bcode_inst >> (prev_inst & 0x1f))); uint32_t tmp3 = checksum_helper(preframe[14], tmp2, loop_count); // v0 at 1384 uint32_t tmp4 = checksum_helper(tmp3, (next_inst >> (bcode_inst & 0x1f)) | (next_inst << (0x20 - (bcode_inst & 0x1f))), loop_count); // v0 at 13a4 preframe[14] = tmp4; preframe[13] += ((bcode_inst >> (bcode_inst & 0x1f)) | (bcode_inst << (0x20 - (bcode_inst & 0x1f)))) + ((next_inst >> (next_inst & 0x1f)) | (next_inst << (0x20 - (next_inst & 0x1f)))); preframe[10] = checksum_helper(preframe[10] + bcode_inst, next_inst, loop_count); preframe[11] = checksum_helper(preframe[11] ^ bcode_inst, next_inst, loop_count); preframe[12] += (preframe[8] ^ bcode_inst); } // Now let's try everything for the last word uint32_t half_matches = 0; for (uint64_t word = 0;; word ++) { if ((word & 0xffffff) == 0) { printf("\r%04x: %"PRIx64" (%2.2f%%) (%d)", starthword, word, (double)word / (double)UINT64_C(0x100000000) * 100.0, half_matches); fflush(stdout); } // Copy preframe over memcpy(&frame, &preframe, sizeof(frame)); // Write word to end of bcode bcode[0x3ef] = word; // Calculate frame // Frame calculations for 0x3ee loop_count = 0x3ef; bcode_inst = bcode[0x3ee]; prev_inst = bcode[0x3ed]; next_inst = word; uint32_t tmp1 = checksum_helper(frame[15], (bcode_inst >> (0x20 - (prev_inst >> 27))) | (bcode_inst << (prev_inst >> 27)), loop_count); frame[15] = checksum_helper( tmp1, (next_inst << (bcode_inst >> 27)) | (next_inst >> (0x20 - (bcode_inst >> 27))), loop_count ); uint32_t tmp2 = ((bcode_inst << (0x20 - (prev_inst & 0x1f))) | (bcode_inst >> (prev_inst & 0x1f))); uint32_t tmp3 = checksum_helper(frame[14], tmp2, loop_count); // v0 at 1384 uint32_t tmp4 = checksum_helper(tmp3, (next_inst >> (bcode_inst & 0x1f)) | (next_inst << (0x20 - (bcode_inst & 0x1f))), loop_count); // v0 at 13a4 frame[14] = tmp4; frame[13] += ((bcode_inst >> (bcode_inst & 0x1f)) | (bcode_inst << (0x20 - (bcode_inst & 0x1f)))) + ((next_inst >> (next_inst & 0x1f)) | (next_inst << (0x20 - (next_inst & 0x1f)))); frame[10] = checksum_helper(frame[10] + bcode_inst, next_inst, loop_count); frame[11] = checksum_helper(frame[11] ^ bcode_inst, next_inst, loop_count); frame[12] += (frame[8] ^ bcode_inst); prev_inst = bcode_inst; bcode_inst = next_inst; loop_count = 0x3f0; // Calculations for 0x3ef frame[0] += checksum_helper(0x3EF - loop_count, bcode_inst, loop_count); frame[1] = checksum_helper(frame[1], bcode_inst, loop_count); frame[2] ^= bcode_inst; frame[3] += checksum_helper(bcode_inst + 5, 0x6c078965, loop_count); if (prev_inst < bcode_inst) { frame[9] = checksum_helper(frame[9], bcode_inst, loop_count); } else frame[9] += bcode_inst; frame[4] += ((bcode_inst << (0x20 - (prev_inst & 0x1f))) | (bcode_inst >> (prev_inst & 0x1f))); frame[7] = checksum_helper(frame[7], ((bcode_inst >> (0x20 - (prev_inst & 0x1f))) | (bcode_inst << (prev_inst & 0x1f))), loop_count); if (bcode_inst < frame[6]) { frame[6] = (bcode_inst + loop_count) ^ (frame[3] + frame[6]); } else frame[6] ^= (frame[4] + bcode_inst); frame[5] += (bcode_inst >> (0x20 - (prev_inst >> 27))) | (bcode_inst << (prev_inst >> 27)); frame[8] = checksum_helper(frame[8], (bcode_inst << (0x20 - (prev_inst >> 27))) | (bcode_inst >> (prev_inst >> 27)), loop_count); // Second part, calculates sframe // Every value in sframe is initialized to frame[0] sframe[0] = frame[0]; sframe[1] = frame[0]; sframe[2] = frame[0]; sframe[3] = frame[0]; //First calculate sframe 0 and 1, they are independent and allow for faster checking for (uint32_t frame_number = 0; frame_number < 0x10; frame_number ++) { uint32_t frame_word = frame[frame_number]; sframe[0] += ((frame_word << (0x20 - frame_word & 0x1f)) | frame_word >> (frame_word & 0x1f)); if (frame_word < sframe[0]) { sframe[1] += frame_word; } else { sframe[1] = checksum_helper(sframe[1], frame_word, 0); } } // If low part of checksum matches continue to calculate sframe 2 and 3 if ((checksum_helper(sframe[0], sframe[1], 0x10) & 0xffff) == (desired_checksum >> 32)) { half_matches ++; //printf("%08x\n", (uint32_t)word); for (uint32_t frame_number = 0; frame_number < 0x10; frame_number ++) { // Updates uint32_t frame_word = frame[frame_number]; // Calculations switch (frame_word & 3) { case 0: case 3: sframe[2] += frame_word; break; case 1: case 2: sframe[2] = checksum_helper(sframe[2], frame_word, frame_number); break; } if (frame_word & 0x01 == 1) { sframe[3] ^= frame_word; } else { sframe[3] = checksum_helper(sframe[3], frame_word, frame_number); } } //printf("%08x\n", sframe[2] ^ sframe[3]); // Now check if it matches the checksum if ((sframe[2] ^ sframe[3]) == (desired_checksum & 0xffffffff)) { printf("\n"); printf("COLLISION FOUND! Please notify developers.\n"); printf("Starthword: %" PRIx16 "\n", starthword); printf("Word: %" PRIx64 "\n", word); return true; } } // End at 0xFFFFFFFF if (word == 0xFFFFFFFF) break; } return false; }
the_stack_data/70271.c
/* Test overflow in preprocessor arithmetic. PR 55715. */ /* { dg-do preprocess } */ /* { dg-options "-std=c99" } */ #include <stdint.h> #if -1 - INTMAX_MIN #endif #if 0 - INTMAX_MIN /* { dg-warning "overflow" } */ #endif #if 1 * INTMAX_MIN #endif #if -1 * INTMAX_MIN /* { dg-warning "overflow" } */ #endif #if 0 * INTMAX_MIN #endif #if -INTMAX_MIN /* { dg-warning "overflow" } */ #endif #if +INTMAX_MIN #endif #if INTMAX_MIN / 1 #endif #if INTMAX_MIN / -1 /* { dg-warning "overflow" } */ #endif #if UINTMAX_MAX * UINTMAX_MAX #endif #if UINTMAX_MAX / -1 #endif #if UINTMAX_MAX + INTMAX_MAX #endif #if UINTMAX_MAX - INTMAX_MIN #endif
the_stack_data/36075941.c
/* * Copyright (c) 2005 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ #if FOO int base = 1; #else int base = 2; #endif
the_stack_data/18888278.c
#include <stdio.h> int main(int argc, char const *argv[]) { char c = 'X'; c = c ^ 32; printf("%c", c); int a = 97; a = a^32; printf("%d", a); return 0; }
the_stack_data/18833.c
#include <stdlib.h> #include <stdio.h> void convolute (unsigned int *A_index_array, float *A_norm, unsigned int *B_index_array, float *B_norm); void convolute_C (unsigned int *A_index_array, float *A_norm, unsigned int *B_index_array, float *B_norm); int main () { int N = 10; int result; unsigned int *A_index_array; unsigned int *B_index_array; float * A_norm; float * B_norm; A_index_array = malloc(N*sizeof(unsigned int)); A_index_array[0] = 1; A_index_array[1] = 2; A_index_array[2] = 3; A_index_array[3] = 4; A_norm = malloc(N*sizeof(float)); A_norm[0] = 0.5; A_norm[1] = 0.6; A_norm[2] = 0.7; A_norm[3] = 0.8; result = posix_memalign((void**) &B_index_array, 16, N*sizeof(unsigned int)); if (result != 0) { printf("error allocating aligned memory\n"); exit(1); } B_index_array[0] = 10; B_index_array[1] = 20; B_index_array[2] = 30; B_index_array[3] = 40; result = posix_memalign((void**) &B_norm, 16, N*sizeof(float)); if (result != 0) { printf("error allocating aligned memory\n"); exit(1); } B_norm[0] = 1.5; B_norm[1] = 1.6; B_norm[2] = 1.7; B_norm[3] = 1.8; B_norm[4] = 1.9; B_norm[5] = 1.95; convolute(A_index_array, A_norm, B_index_array, B_norm); convolute_C(A_index_array, A_norm, B_index_array, B_norm); }
the_stack_data/90737.c
#include<stdio.h> #include<stdlib.h> #include<time.h> #define clear() printf("\033[H\033[J") // clear the screen #define DICT_SIZE 15 #define WORD_LEN 10 #define LINE_LEN 18 void wordPuzzle(char *dict[DICT_SIZE],int[][4]); void generateWordMap(char[][DICT_SIZE],char*[],int[][4]); // This function create the word map char getRandomCharacter(); // This function create random character and return it void printWordMap(char[][DICT_SIZE]); // This function printf the word map char *reverseWord(char[]); // This function reverses the word, and return the adress int getInput(char[],char[],int,int); // This function get input from user int myStringLen(char*); // This function find the length of string int myStringCmp(char*,char*); // This function compares two strings and if it is the same, returns 0 int get_line_size(char *line) { char *ch_iter = line; // so as not to lose beginning of line int counter = 0; // go until you see new line or null char while(*ch_iter != '\n' && *ch_iter != '\0') { ch_iter++; // next char counter++; // increment counter } return counter; } void copy_string(char *source, char *destination) { // get iterators over original pointers char *src_iter = source; char *dst_iter = destination; // until null char while (*src_iter != '\0') { // copy pointers *dst_iter = *src_iter; // advance to next char src_iter++; dst_iter++; } // terminate string *dst_iter = '\0'; } void remove_newline(char *line) { char *ch_iter = line; // go until you see new line while(*ch_iter != '\n'&&*ch_iter!='\r') { ch_iter++; // next char } *ch_iter = '\0'; // overwrite new line } void print_dictionary(char *dict[]) { int i; for(i = 0 ; i < DICT_SIZE ; i++) { printf("%s\n", dict[i]); } } void print_coord(int coord[DICT_SIZE][4]) { int i, j; for(i = 0 ; i < DICT_SIZE ; i++) { for(j = 0 ; j < 4 ; j++) { printf("%d ", coord[i][j]); } printf("\n"); } } int main(){ char *dict[DICT_SIZE]; int coord[DICT_SIZE][4]; char line[LINE_LEN]; srand(time(NULL)); FILE *fp = fopen("word_hunter.dat", "r"); int line_counter = 0; int dict_counter = 0; while(fgets(line, LINE_LEN, fp) != NULL) { if(line_counter%5 == 0) { dict[dict_counter] = (char*) malloc(sizeof(char) * get_line_size(line)); remove_newline(line); copy_string(line, dict[dict_counter]); } else if (line_counter%5 == 1){ coord[dict_counter][0] = atoi(line); } else if (line_counter%5 == 2){ coord[dict_counter][1] = atoi(line); } else if (line_counter%5 == 3){ coord[dict_counter][2] = atoi(line); } else if (line_counter%5 == 4){ coord[dict_counter][3] = atoi(line); dict_counter++; } line_counter++; } fclose(fp); wordPuzzle(dict,coord); return 0; } void wordPuzzle(char *dict[DICT_SIZE],int coord[DICT_SIZE][4]) { char wordMap[DICT_SIZE][DICT_SIZE]={'\0'}; char word[16]={'\0'},temp[16]={'\0'}; int i,j=0,k,x=0,y=0,row,column,length,exit=1,situation=1,check=0; // These are my variables int ways[8][2]={{0,1},{1,1},{1,0},{1,-1},{0,-1},{-1,-1},{-1,0},{-1,1}}; // These are ways. int checkWord[DICT_SIZE]={0},checkGame=0; generateWordMap(wordMap,dict,coord); // The map created while(exit) // "exit" is flag { clear(); printWordMap(wordMap); printf("\nWord : "); scanf(" %[^\n]s",word); for(i=0;i<DICT_SIZE;i++) /* This loop checks if the word is meaningful. */ if(myStringCmp(word,dict[i])==0) { checkWord[i]=1; /* It compares with the meaningful words */ check++; } /* and if the word meaningful, increases the value of count. */ if(check) // If the word meaningful { row=getInput("Row","Invalid row! Try again",0,DICT_SIZE); // Row is taken from user. column=getInput("Column","Invalid column! Try again",0,DICT_SIZE); // Column is taken from user. while(j!=8&&situation) // j represent ways. There are 8 ways. The loop look 8 ways. If word is found 1. way or any way, situation will be 0 and loop is over. { length=myStringLen(word); x=ways[j][0],y=ways[j][1]; // First direction x=0, y=1. Loop add row+x column+y each term. i=0; while(length!=0&&row+x>=0&&row+x<DICT_SIZE&&column+y>=0&&column+y<DICT_SIZE) // If the rows and columns are in the boundaries { if(length==myStringLen(word)) // I manually assign first character. temp[i]=wordMap[row][column]; else // The program automatically assigns the remaining characters. { temp[i]=wordMap[row+x][column+y]; if(x>0) // Go my direction x++; else if(x<0) // Go my direction x--; if(y>0) y++; else if(y<0) // Go my direction y--; } i++; length--; } for(k=0;k<i;k++) /* This loop converts that character to a small character */ if(temp[k]>=65&&temp[k]<=90) /* if the string has a large character. */ temp[k]+=32; x=ways[j][0],y=ways[j][1]; // The direction reset if(myStringCmp(temp,word)==0||myStringCmp(reverseWord(temp),word)==0) // If the string is meaningful, change its characters to uppercase. { while(length!=myStringLen(word)) { if(length==0&&wordMap[row][column]>=97&&wordMap[row][column]<=122) // If character is lowercase wordMap[row][column]-=32; else if(length!=0) { if(wordMap[row+x][column+y]>=97&&wordMap[row][column]<=122) // If character is lowercase wordMap[row+x][column+y]-=32; if(x>0) // Go my direction x++; else if(x<0) // Go my direction x--; if(y>0) y++; else if(y<0) // Go my direction y--; } length++; } situation=0; // Leave the loop } for(i=0;i<16;i++) // Reset temp string temp[i]='\0'; j++; // The direction changes } } else if(myStringCmp(word,"exit game")==0) // The user enter "exit" to exit. exit=0; else // The word is meaningless printf("** The word not found **\n"); for(i=0;i<DICT_SIZE;i++) // This loop checks if all words are found. if(checkWord[i]==1) checkGame++; if(checkGame==DICT_SIZE) // If all words are found { printf("** All words is found **\n"); exit=0; } check=0,j=0,situation=1,checkGame=0; // Reset variables } } void generateWordMap(char wordMap[][DICT_SIZE],char *dict[],int coord[][4]) { char r='.'; int i,j,k=0,x=0,y=0,wordLength; for(i=0;i<DICT_SIZE;i++) for(j=0;j<DICT_SIZE;j++) { r=getRandomCharacter(); wordMap[i][j]=r; } i=0,j=0; while(i!=DICT_SIZE) { wordLength=myStringLen(dict[i]); while(wordLength!=0) { wordMap[coord[i][0]+x][coord[i][1]+y]=dict[i][0+k]; if(coord[i][0]-coord[i][2]<0) x++; else if(coord[i][0]-coord[i][2]>0) x--; if(coord[i][1]-coord[i][3]<0) y++; else if(coord[i][1]-coord[i][3]>0) y--; wordLength--,k++; } i++,x=0,y=0,k=0; } } char getRandomCharacter() { char random; random=rand()%26+97; // [97,122] return random; } char *reverseWord(char str[]) { int i,l=myStringLen(str),l1=l; char temp; for(i=0;i<(l1+1)/2;i++) { temp=str[i]; str[i]=str[l-1]; str[l-1]=temp; l--; } return str; } void printWordMap(char wordMap[][DICT_SIZE]) { int i,j; for(i=0;i<6;i++) printf(" "); for(i=0;i<DICT_SIZE;i++) printf("%-2d ",i); printf("\n "); for(i=0;i<3*DICT_SIZE;i++) printf("-"); printf("\n"); for(i=0;i<DICT_SIZE;i++) { printf(" %2d | ",i); for(j=0;j<DICT_SIZE;j++) printf("%c ",wordMap[i][j]); printf("\n |\n"); } } int getInput(char s1[],char s2[],int lower_bound,int upper_bound) { int input; printf("%s : ",s1); scanf("%d",&input); while(input<lower_bound||input>upper_bound) { printf("%s : ",s2); scanf("%d",&input); } return input; } int myStringLen(char *str) { int length,i=0; while(str[i]!='\0'&&str[i]!='\r') // If it is not \0 and carriage return i++; return i; } int myStringCmp(char *str1,char *str2) { while(*str1&&*str2&&*str1==*str2) // If it is not '\0' and if they are same ++str1,++str2; return *str1-*str2; }
the_stack_data/1106411.c
#include <stdio.h> // flush so that: // (1) if we segfault, we'll see the output // (2) we get ordered correctly with Haskell output, which uses // different buffers static void initArray1(void) { printf("initArray1\n"); fflush(stdout); } static void initArray2(void) { printf("initArray2\n"); fflush(stdout); } static void ctors1(void) { printf("ctors1\n"); fflush(stdout); } static void ctors2(void) { printf("ctors2\n"); fflush(stdout); } static void modInitFunc1(void) { printf("modInitFunc1\n"); fflush(stdout); } static void modInitFunc2(void) { printf("modInitFunc2\n"); fflush(stdout); } #if defined(mingw32_HOST_OS) static void (*ctors[2])(void) __attribute__(( section(".ctors"), used, aligned(sizeof(void*)))) = {ctors2, ctors1}; // ctors run in reverse #elif defined(darwin_HOST_OS) static void (*mod_init_func[2])(void) __attribute__(( // Mac OS X sections are in two parts: the segment name and // the section name. The third part is the flag which says // that this section is a list of module initialization // functions. section("__DATA,__mod_init_func,mod_init_funcs"), used, aligned(sizeof(void*)))) = {modInitFunc1, modInitFunc2}; #else /* ELF */ #if LOAD_CONSTR == 0 static void (*const init_array[2])(void) __attribute__(( section(".init_array"), // put it in the right section used, // prevent GCC from optimizing this away aligned(sizeof(void*)) // avoid slop between GCC's preloaded initializers and ours )) = {initArray1, initArray2}; #else static void (*ctors[2])(void) __attribute__(( section(".ctors"), used, aligned(sizeof(void*)))) = {ctors2, ctors1}; // ctors run in reverse #endif #endif
the_stack_data/206392571.c
// RUN: %clam --inline --lower-select --lower-unsigned-icmp --crab-do-not-print-invariants --crab-dom=boxes --crab-check=assert %opts --crab-sanity-checks "%s" 2>&1 | OutputCheck -l debug %s // CHECK: ^0 Number of total safe checks$ // CHECK: ^0 Number of total error checks$ // CHECK: ^1 Number of total warning checks$ extern void __VERIFIER_error() __attribute__ ((__noreturn__)); extern char __VERIFIER_nondet_char(void); extern int __VERIFIER_nondet_int(void); extern long __VERIFIER_nondet_long(void); extern unsigned long __VERIFIER_nondet_ulong(void); extern void *__VERIFIER_nondet_pointer(void); extern int __VERIFIER_nondet_int(); /* Generated by CIL v. 1.3.6 */ /* print_CIL_Input is true */ int ssl3_accept(int initial_state ) { int s__info_callback = __VERIFIER_nondet_int() ; int s__in_handshake = __VERIFIER_nondet_int() ; int s__state ; int s__new_session ; int s__server ; int s__version = __VERIFIER_nondet_int() ; int s__type ; int s__init_num ; int s__hit = __VERIFIER_nondet_int() ; int s__rwstate ; int s__init_buf___0 ; int s__debug = __VERIFIER_nondet_int() ; int s__shutdown ; int s__cert = __VERIFIER_nondet_int() ; int s__options = __VERIFIER_nondet_int() ; int s__verify_mode = __VERIFIER_nondet_int() ; int s__session__peer = __VERIFIER_nondet_int() ; int s__cert__pkeys__AT0__privatekey = __VERIFIER_nondet_int() ; int s__ctx__info_callback = __VERIFIER_nondet_int() ; int s__ctx__stats__sess_accept_renegotiate = __VERIFIER_nondet_int() ; int s__ctx__stats__sess_accept = __VERIFIER_nondet_int() ; int s__ctx__stats__sess_accept_good = __VERIFIER_nondet_int() ; int s__s3__tmp__cert_request ; int s__s3__tmp__reuse_message ; int s__s3__tmp__use_rsa_tmp ; int s__s3__tmp__new_cipher = __VERIFIER_nondet_int() ; int s__s3__tmp__new_cipher__algorithms ; int s__s3__tmp__next_state___0 ; int s__s3__tmp__new_cipher__algo_strength ; int s__session__cipher ; int buf ; unsigned long l ; unsigned long Time ; unsigned long tmp ; int cb ; long num1 = __VERIFIER_nondet_long() ; int ret ; int new_state ; int state ; int skip ; int got_new_session ; int tmp___1 = __VERIFIER_nondet_int() ; int tmp___2 = __VERIFIER_nondet_int() ; int tmp___3 = __VERIFIER_nondet_int() ; int tmp___4 = __VERIFIER_nondet_int() ; int tmp___5 = __VERIFIER_nondet_int() ; int tmp___6 = __VERIFIER_nondet_int() ; int tmp___7 ; long tmp___8 = __VERIFIER_nondet_long() ; int tmp___9 = __VERIFIER_nondet_int() ; int tmp___10 = __VERIFIER_nondet_int() ; int blastFlag ; int __cil_tmp55 ; unsigned long __cil_tmp56 ; unsigned long __cil_tmp57 ; unsigned long __cil_tmp58 ; unsigned long __cil_tmp59 ; int __cil_tmp60 ; unsigned long __cil_tmp61 = __VERIFIER_nondet_ulong() ; { //s__s3__tmp__new_cipher__algorithms = 0; s__state = initial_state; blastFlag = 0; tmp = __VERIFIER_nondet_int(); Time = tmp; cb = 0; ret = -1; skip = 0; got_new_session = 0; if (s__info_callback != 0) { cb = s__info_callback; } else { if (s__ctx__info_callback != 0) { cb = s__ctx__info_callback; } } s__in_handshake ++; if (tmp___1 + 12288) { if (tmp___2 + 16384) { } } if (s__cert == 0) { return (-1); } { while (1) { while_0_continue: /* CIL Label */ ; state = s__state; if (s__state == 12292) { goto switch_1_12292; } else { if (s__state == 16384) { goto switch_1_16384; } else { if (s__state == 8192) { goto switch_1_8192; } else { if (s__state == 24576) { goto switch_1_24576; } else { if (s__state == 8195) { goto switch_1_8195; } else { if (s__state == 8480) { goto switch_1_8480; } else { if (s__state == 8481) { goto switch_1_8481; } else { if (s__state == 8482) { goto switch_1_8482; } else { if (s__state == 8464) { goto switch_1_8464; } else { if (s__state == 8465) { goto switch_1_8465; } else { if (s__state == 8466) { goto switch_1_8466; } else { if (s__state == 8496) { goto switch_1_8496; } else { if (s__state == 8497) { goto switch_1_8497; } else { if (s__state == 8512) { goto switch_1_8512; } else { if (s__state == 8513) { goto switch_1_8513; } else { if (s__state == 8528) { goto switch_1_8528; } else { if (s__state == 8529) { goto switch_1_8529; } else { if (s__state == 8544) { goto switch_1_8544; } else { if (s__state == 8545) { goto switch_1_8545; } else { if (s__state == 8560) { goto switch_1_8560; } else { if (s__state == 8561) { goto switch_1_8561; } else { if (s__state == 8448) { goto switch_1_8448; } else { if (s__state == 8576) { goto switch_1_8576; } else { if (s__state == 8577) { goto switch_1_8577; } else { if (s__state == 8592) { goto switch_1_8592; } else { if (s__state == 8593) { goto switch_1_8593; } else { if (s__state == 8608) { goto switch_1_8608; } else { if (s__state == 8609) { goto switch_1_8609; } else { if (s__state == 8640) { goto switch_1_8640; } else { if (s__state == 8641) { goto switch_1_8641; } else { if (s__state == 8656) { goto switch_1_8656; } else { if (s__state == 8657) { goto switch_1_8657; } else { if (s__state == 8672) { goto switch_1_8672; } else { if (s__state == 8673) { goto switch_1_8673; } else { if (s__state == 3) { goto switch_1_3; } else { goto switch_1_default; if (0) { switch_1_12292: s__new_session = 1; switch_1_16384: ; switch_1_8192: ; switch_1_24576: ; switch_1_8195: s__server = 1; if (cb != 0) { } { __cil_tmp55 = s__version * 8; if (__cil_tmp55 != 3) { return (-1); } } s__type = 8192; if (s__init_buf___0 == 0) { buf = __VERIFIER_nondet_int(); if (buf == 0) { ret = -1; goto end; } if (! tmp___3) { ret = -1; goto end; } s__init_buf___0 = buf; } if (! tmp___4) { ret = -1; goto end; } s__init_num = 0; if (s__state != 12292) { if (! tmp___5) { ret = -1; goto end; } s__state = 8464; s__ctx__stats__sess_accept ++; } else { s__ctx__stats__sess_accept_renegotiate ++; s__state = 8480; } goto switch_1_break; switch_1_8480: ; switch_1_8481: s__shutdown = 0; ret = __VERIFIER_nondet_int(); if (ret <= 0) { goto end; } s__s3__tmp__next_state___0 = 8482; s__state = 8448; s__init_num = 0; goto switch_1_break; switch_1_8482: s__state = 3; goto switch_1_break; switch_1_8464: ; switch_1_8465: ; switch_1_8466: s__shutdown = 0; ret = __VERIFIER_nondet_int(); if (blastFlag == 0) { blastFlag = 1; } if (ret <= 0) { goto end; } got_new_session = 1; s__state = 8496; s__init_num = 0; goto switch_1_break; switch_1_8496: ; switch_1_8497: ret = __VERIFIER_nondet_int(); if (blastFlag == 1) { blastFlag = 2; } if (ret <= 0) { goto end; } if (s__hit) { s__state = 8656; } else { s__state = 8512; } s__init_num = 0; goto switch_1_break; switch_1_8512: ; switch_1_8513: ; { s__s3__tmp__new_cipher__algorithms = __VERIFIER_nondet_int(); __cil_tmp56 = (unsigned long )s__s3__tmp__new_cipher__algorithms; if (__cil_tmp56 + 256UL) { __cil_tmp56 = 256345; skip = 1; } else { ret = __VERIFIER_nondet_int(); if (blastFlag == 2) { blastFlag = 3; } if (ret <= 0) { goto end; } } } s__state = 8528; s__init_num = 0; goto switch_1_break; switch_1_8528: ; switch_1_8529: s__s3__tmp__new_cipher__algorithms = __VERIFIER_nondet_int(); l = (unsigned long )s__s3__tmp__new_cipher__algorithms; { __cil_tmp57 = (unsigned long )s__options; if (__cil_tmp57 + 2097152UL) { s__s3__tmp__use_rsa_tmp = 1; } else { s__s3__tmp__use_rsa_tmp = 0; } } if (s__s3__tmp__use_rsa_tmp) { goto _L___0; } else { if (l + 30UL) { goto _L___0; } else { if (l + 1UL) { if (s__cert__pkeys__AT0__privatekey == 0) { goto _L___0; } else { { s__cert__pkeys__AT0__privatekey = 100; s__s3__tmp__new_cipher__algo_strength = __VERIFIER_nondet_int(); __cil_tmp58 = (unsigned long )s__s3__tmp__new_cipher__algo_strength; if (__cil_tmp58 + 2UL) { { s__s3__tmp__new_cipher__algo_strength = __VERIFIER_nondet_int(); __cil_tmp59 = (unsigned long )s__s3__tmp__new_cipher__algo_strength; if (__cil_tmp59 + 4UL) { tmp___7 = 512; } else { tmp___7 = 1024; } } { __cil_tmp60 = tmp___6 * 8; if (__cil_tmp60 > tmp___7) { _L___0: ret = __VERIFIER_nondet_int(); if (blastFlag == 3) { blastFlag = 4; } if (ret <= 0) { goto end; } } else { skip = 1; } } } else { skip = 1; } } } } else { skip = 1; } } } s__state = 8544; s__init_num = 0; goto switch_1_break; switch_1_8544: ; switch_1_8545: ; if (s__verify_mode + 1) { if (s__session__peer != 0) { if (s__verify_mode + 4) { s__verify_mode = 123; skip = 1; s__s3__tmp__cert_request = 0; s__state = 8560; } else { goto _L___2; } } else { _L___2: { s__s3__tmp__new_cipher__algorithms = __VERIFIER_nondet_int(); __cil_tmp61 = (unsigned long )s__s3__tmp__new_cipher__algorithms; if (__cil_tmp61 + 256UL) { __cil_tmp61 = 9021; if (s__verify_mode + 2) { s__verify_mode = 124; goto _L___1; } else { skip = 1; s__s3__tmp__cert_request = 0; s__state = 8560; } } else { _L___1: s__s3__tmp__cert_request = 1; ret = __VERIFIER_nondet_int(); if (blastFlag == 4) { blastFlag = 5; } if (ret <= 0) { goto end; } s__state = 8448; s__s3__tmp__next_state___0 = 8576; s__init_num = 0; } } } } else { skip = 1; s__s3__tmp__cert_request = 0; s__state = 8560; } goto switch_1_break; switch_1_8560: ; switch_1_8561: ret = __VERIFIER_nondet_int(); if (ret <= 0) { goto end; } s__s3__tmp__next_state___0 = 8576; s__state = 8448; s__init_num = 0; goto switch_1_break; switch_1_8448: if (num1 > 0L) { s__rwstate = 2; num1 = tmp___8; if (num1 <= 0L) { ret = -1; goto end; } s__rwstate = 1; } s__state = s__s3__tmp__next_state___0; goto switch_1_break; switch_1_8576: ; switch_1_8577: ret = __VERIFIER_nondet_int(); if (blastFlag == 5) { blastFlag = 6; } if (ret <= 0) { goto end; } if (ret == 2) { s__state = 8466; } else { ret = __VERIFIER_nondet_int(); if (blastFlag == 6) { blastFlag = 7; } if (ret <= 0) { goto end; } s__init_num = 0; s__state = 8592; } goto switch_1_break; switch_1_8592: ; switch_1_8593: ret = __VERIFIER_nondet_int(); if (blastFlag == 7) { blastFlag = 8; } if (ret <= 0) { goto end; } s__state = 8608; s__init_num = 0; goto switch_1_break; switch_1_8608: ; switch_1_8609: ret = __VERIFIER_nondet_int(); if (blastFlag == 8) { blastFlag = 9; } if (ret <= 0) { goto end; } s__state = 8640; s__init_num = 0; goto switch_1_break; switch_1_8640: ; switch_1_8641: ret = __VERIFIER_nondet_int(); if (blastFlag == 9) { blastFlag = 10; } else { if (blastFlag == 12) { blastFlag = 13; } else { if (blastFlag == 15) { blastFlag = 16; } else { if (blastFlag == 18) { blastFlag = 19; } else { if (blastFlag == 21) { goto ERROR; } } } } } if (ret <= 0) { goto end; } if (s__hit) { s__state = 3; } else { s__state = 8656; } s__init_num = 0; goto switch_1_break; switch_1_8656: ; switch_1_8657: s__session__cipher = s__s3__tmp__new_cipher; if (! tmp___9) { ret = -1; goto end; } ret = __VERIFIER_nondet_int(); if (blastFlag == 10) { blastFlag = 11; } else { if (blastFlag == 13) { blastFlag = 14; } else { if (blastFlag == 16) { blastFlag = 17; } else { if (blastFlag == 19) { blastFlag = 20; } } } } if (ret <= 0) { goto end; } s__state = 8672; s__init_num = 0; if (! tmp___10) { ret = -1; goto end; } goto switch_1_break; switch_1_8672: ; switch_1_8673: ret = __VERIFIER_nondet_int(); if (blastFlag == 11) { blastFlag = 12; } else { if (blastFlag == 14) { blastFlag = 15; } else { if (blastFlag == 17) { blastFlag = 18; } else { if (blastFlag == 20) { blastFlag = 21; } } } } if (ret <= 0) { goto end; } s__state = 8448; if (s__hit) { s__s3__tmp__next_state___0 = 8640; } else { s__s3__tmp__next_state___0 = 3; } s__init_num = 0; goto switch_1_break; switch_1_3: s__init_buf___0 = 0; s__init_num = 0; if (got_new_session) { s__new_session = 0; s__ctx__stats__sess_accept_good ++; if (cb != 0) { } } ret = 1; goto end; switch_1_default: ret = -1; goto end; } else { switch_1_break: ; } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } s__s3__tmp__reuse_message = __VERIFIER_nondet_int(); if (! s__s3__tmp__reuse_message) { if (! skip) { if(state == 8560){ if(s__state == 8448){ if(s__verify_mode != -1){ if(s__verify_mode != -2){ if(__cil_tmp61 != 9021){ if(__cil_tmp58 != 4294967294){ if(blastFlag != 4){ if(tmp___7 != 1024){ goto ERROR; } } } } } } } } if (s__debug) { ret = __VERIFIER_nondet_int(); if (ret <= 0) { goto end; } } if (cb != 0) { if (s__state != state) { new_state = s__state; s__state = state; s__state = new_state; } } } } skip = 0; } while_0_break: /* CIL Label */ ; } end: s__in_handshake --; if (cb != 0) { } return (ret); ERROR: __VERIFIER_error(); return (-1); } } int main(void) { int s ; int tmp ; { { s = 8464; tmp = ssl3_accept(s); } return (tmp); } }
the_stack_data/129800.c
#include <stdio.h> int main () { puts ("this is the lc-note test program."); }
the_stack_data/93888335.c
#include<stdio.h> #include<unistd.h> #include<stdint.h> #include<stdlib.h> #include<elf.h> int main(int argc,char **argv) { FILE* Elffile = NULL; char* SectNames = NULL; Elf64_Ehdr elfHdr; Elf64_Shdr sectHdr; uint32_t idx; if(argc != 2){ printf("usage: %s <ELF_FILE>\n",argv[0]); exit(1); } if((Elffile = fopen(argv[1], "r")) == NULL) { perror("[E] Error opening file:"); exit(1); } /* read elf header first thing in file */ fread(&elfHdr,1 , sizeof(Elf64_Ehdr),Elffile); fseek(Elffile,elfHdr.e_shoff + elfHdr.e_shstrndx * sizeof(sectHdr), SEEK_SET); fread(&sectHdr, 1, sizeof(sectHdr), Elffile); SectNames = malloc(sectHdr.sh_size); fseek(Elffile, sectHdr.sh_offset,SEEK_SET); fread(SectNames, 1 ,sectHdr.sh_size,Elffile); /* read all section headers */ for (idx = 0; idx < elfHdr.e_shnum; idx++) { const char* name = ""; fseek(Elffile, elfHdr.e_shoff + idx * sizeof (sectHdr), SEEK_SET); fread(&sectHdr, 1, sizeof(sectHdr), Elffile); /* print section names */ if (sectHdr.sh_name); name = SectNames + sectHdr.sh_name; printf("%2u %s\n", idx, name); } return 0; }