file
stringlengths
18
26
data
stringlengths
3
1.04M
the_stack_data/40763607.c
extern const unsigned char DDCommonsVersionString[]; extern const double DDCommonsVersionNumber; const unsigned char DDCommonsVersionString[] __attribute__ ((used)) = "@(#)PROGRAM:DDCommons PROJECT:Pods-1" "\n"; const double DDCommonsVersionNumber __attribute__ ((used)) = (double)1.;
the_stack_data/550114.c
/* Algoritmo de Metropolis para modelo de Ising 2D. Implementação sem otimizações. */ #include <stdio.h> #include <stdlib.h> #include <math.h> #include <time.h> #define SEED 22171245 #define L 300 #define L2 (L*L) #define N L2 #define temperatura 1.5 //Tc~2.27 #define tmax 1000 clock_t start, stop; int right[N], left[N], up[N], down[N]; /*---------------------------------------------------------------------*/ /*----------P. Random Number Generator by Parisi & Rapuano-------------*/ /*---------------------------------------------------------------------*/ #define FNORM (2.3283064365e-10) #define RANDOM ((ira[ip++] = ira[ip1++] + ira[ip2++]) ^ ira[ip3++]) #define FRANDOM (FNORM * RANDOM) #define pm1 ((FRANDOM > 0.5) ? 1 : -1) unsigned myrand, ira[256]; unsigned char ip, ip1, ip2, ip3; unsigned rand4init(void) { unsigned long long y; y = (myrand*16807LL); myrand = (y&0x7fffffff) + (y>>31); if (myrand&0x80000000) myrand = (myrand&0x7fffffff) + 1; return myrand; } void Init_Random(void) { unsigned i; ip=128; ip1=ip-24; ip2=ip-55; ip3=ip-61; for (i=ip3; i<ip; i++) ira[i] = rand4init(); } /*---------------------------------------------------------------------*/ /*---------------------------------------------------------------------*/ /*---------------------------------------------------------------------*/ void vizinhos_ccp2d(void) { int i; for (i=0; i<L2; i++){ if (i % L==L-1) /* ultima coluna */ right[i] = i-L+1; else right[i] = i+1; if (i % L==0) /* primeira coluna */ left[i] = i+L-1; else left[i] = i-1; if (i<L) /* primeira linha */ up[i] = L2-L+i; else up[i] = i - L; if (i>=L2-L) /* ultima linha */ down[i] = (i % L); else down[i] = i + L; } return; } void oneSweep2D(int *s) { int i, site, soma; for (i = 0; i < N; i++) { site = FRANDOM * N; soma = s[site] * (s[right[site]] + s[left[site]] + s[up[site]] + s[down[site]]); if (soma <= 0) s[site] = -s[site]; else if(FRANDOM < exp(-2.0 * soma / temperatura)) s[site] = -s[site]; } return; } void measures(int *s, int *ene, int *mag){ int ix,iy,site; *ene=0; *mag=0; site=0; for (iy = 0; iy < L; iy++) { for (ix = 0; ix < L; ix++) { *ene -= s[site] * (s[right[site]] + s[left[site]] + s[up[site]] + s[down[site]]); *mag += s[site]; site++; } } return; } int main(int argc, char *argv[]) { int i,t,ene,mag,ix,iy; int s[N]; float norm = 1.0/N; // inicializa PRNG myrand = SEED; Init_Random(); // inicializa/calcula vizinhos vizinhos_ccp2d(); // inicializa spins for(i=0;i<N;i++) s[i] = pm1; start = clock(); for(t=0;t<tmax;t++){ oneSweep2D(s); //measures(s,&ene,&mag); //printf("%i %f %f\n",t,ene*norm, mag*norm); // fflush(stdout); for(ix=0;ix<L;ix++) for(iy=0;iy<L;iy++) printf("%d %d %d\n",ix,iy,s[iy+L*ix]); printf("#draw\n"); } stop = clock(); // printf("%d %d %f\n",NmaxMCS, N, (float) (stop-start)/ ( CLOCKS_PER_SEC )); //printf("%f\n",x); return 0; }
the_stack_data/77843.c
#include <stdio.h> //Print Farenheit to Celcius table backwards main(){ int lower,upper,step; float fahr,cel; fahr=lower=0; upper=300; printf("Celcius to Farenheit Table\n"); printf("Celcius Fahr\n"); for(fahr=300;fahr>=lower;fahr-=30){ cel=(5*(fahr-32))/9; printf("%3.2f\t%3.2f\n",cel,fahr); } }
the_stack_data/116438.c
/* ************************************************ username : smmehrab fullname : s.m.mehrabul islam email : [email protected] institute : university of dhaka, bangladesh session : 2017-2018 ************************************************ */ #include<stdio.h> int main() { int n,x[300]={0},i,a,b,max=0,r=0; scanf("%d",&n); while(n--) { scanf("%d %d",&a,&b); for(i=a;i<b;i++) x[i]++; } for(i=0;i<24;i++) { //printf("%d\n",x[i]); if(x[i]>max) max=x[i];//{r=0;max=x[i];} //else if(x[i]==max && max!=0) r++; } //printf("%d\n",r); printf("%d\n",max); return 0; }
the_stack_data/154826897.c
#include <stdio.h> #include <stdlib.h> #include <fcntl.h> #include <unistd.h> #include <string.h> #include <errno.h> #define BUF_SIZE 128 /* Il programma riceve delle stringhe in input, dopodiche' sono copiate nel file filename. */ void ins_str_to_file(char b[], int fdw); int main(int argc, char* argv[], char* envp[]) { char buf[BUF_SIZE]; int fd1; char* filename = "test.txt"; if ((fd1 = open(filename, O_WRONLY | O_CREAT, 0755)) < 0) { fprintf(stderr, "Err: (%d) - '%s'\n", errno, strerror(errno)); exit(errno); } ins_str_to_file(buf, fd1); close(fd1); return (EXIT_SUCCESS); } void ins_str_to_file(char b[], int fdw) { int i; int n_read; printf("Immettere il testo (digitare X per uscire)\n"); /* Pulizia del buffer */ for (i = 0; i < BUF_SIZE; i++) { b[i] = 0; } while ((n_read = read(STDIN_FILENO, b, BUF_SIZE)) > 0) { if (b[n_read - 2] == 'X') { break; } if (write(fdw, b, n_read) != n_read) { fprintf(stderr, "Err: (%d) - %s\n", errno, strerror(errno)); exit(errno); } } }
the_stack_data/38547.c
/* Use conditional compare */ /* { dg-options "-O2" } */ /* { dg-skip-if "" { arm_thumb1_ok } } */ /* { dg-final { scan-assembler "cmpgt" } } */ int f(int i, int j) { if ( (i >= '+') ? (j > '-') : 0) return 1; else return 0; }
the_stack_data/945995.c
// RUN: %clang_cc1 -E -dM -ffreestanding -triple=s390x-none-none -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X %s // RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=s390x-none-none -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X -check-prefix S390X-CXX %s // S390X:#define __BIGGEST_ALIGNMENT__ 8 // S390X:#define __CHAR16_TYPE__ unsigned short // S390X:#define __CHAR32_TYPE__ unsigned int // S390X:#define __CHAR_BIT__ 8 // S390X:#define __CHAR_UNSIGNED__ 1 // S390X:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324 // S390X:#define __DBL_DIG__ 15 // S390X:#define __DBL_EPSILON__ 2.2204460492503131e-16 // S390X:#define __DBL_HAS_DENORM__ 1 // S390X:#define __DBL_HAS_INFINITY__ 1 // S390X:#define __DBL_HAS_QUIET_NAN__ 1 // S390X:#define __DBL_MANT_DIG__ 53 // S390X:#define __DBL_MAX_10_EXP__ 308 // S390X:#define __DBL_MAX_EXP__ 1024 // S390X:#define __DBL_MAX__ 1.7976931348623157e+308 // S390X:#define __DBL_MIN_10_EXP__ (-307) // S390X:#define __DBL_MIN_EXP__ (-1021) // S390X:#define __DBL_MIN__ 2.2250738585072014e-308 // S390X:#define __DECIMAL_DIG__ __LDBL_DECIMAL_DIG__ // S390X:#define __FLT_DENORM_MIN__ 1.40129846e-45F // S390X:#define __FLT_DIG__ 6 // S390X:#define __FLT_EPSILON__ 1.19209290e-7F // S390X:#define __FLT_EVAL_METHOD__ 0 // S390X:#define __FLT_HAS_DENORM__ 1 // S390X:#define __FLT_HAS_INFINITY__ 1 // S390X:#define __FLT_HAS_QUIET_NAN__ 1 // S390X:#define __FLT_MANT_DIG__ 24 // S390X:#define __FLT_MAX_10_EXP__ 38 // S390X:#define __FLT_MAX_EXP__ 128 // S390X:#define __FLT_MAX__ 3.40282347e+38F // S390X:#define __FLT_MIN_10_EXP__ (-37) // S390X:#define __FLT_MIN_EXP__ (-125) // S390X:#define __FLT_MIN__ 1.17549435e-38F // S390X:#define __FLT_RADIX__ 2 // S390X:#define __INT16_C_SUFFIX__ // S390X:#define __INT16_FMTd__ "hd" // S390X:#define __INT16_FMTi__ "hi" // S390X:#define __INT16_MAX__ 32767 // S390X:#define __INT16_TYPE__ short // S390X:#define __INT32_C_SUFFIX__ // S390X:#define __INT32_FMTd__ "d" // S390X:#define __INT32_FMTi__ "i" // S390X:#define __INT32_MAX__ 2147483647 // S390X:#define __INT32_TYPE__ int // S390X:#define __INT64_C_SUFFIX__ L // S390X:#define __INT64_FMTd__ "ld" // S390X:#define __INT64_FMTi__ "li" // S390X:#define __INT64_MAX__ 9223372036854775807L // S390X:#define __INT64_TYPE__ long int // S390X:#define __INT8_C_SUFFIX__ // S390X:#define __INT8_FMTd__ "hhd" // S390X:#define __INT8_FMTi__ "hhi" // S390X:#define __INT8_MAX__ 127 // S390X:#define __INT8_TYPE__ signed char // S390X:#define __INTMAX_C_SUFFIX__ L // S390X:#define __INTMAX_FMTd__ "ld" // S390X:#define __INTMAX_FMTi__ "li" // S390X:#define __INTMAX_MAX__ 9223372036854775807L // S390X:#define __INTMAX_TYPE__ long int // S390X:#define __INTMAX_WIDTH__ 64 // S390X:#define __INTPTR_FMTd__ "ld" // S390X:#define __INTPTR_FMTi__ "li" // S390X:#define __INTPTR_MAX__ 9223372036854775807L // S390X:#define __INTPTR_TYPE__ long int // S390X:#define __INTPTR_WIDTH__ 64 // S390X:#define __INT_FAST16_FMTd__ "hd" // S390X:#define __INT_FAST16_FMTi__ "hi" // S390X:#define __INT_FAST16_MAX__ 32767 // S390X:#define __INT_FAST16_TYPE__ short // S390X:#define __INT_FAST32_FMTd__ "d" // S390X:#define __INT_FAST32_FMTi__ "i" // S390X:#define __INT_FAST32_MAX__ 2147483647 // S390X:#define __INT_FAST32_TYPE__ int // S390X:#define __INT_FAST64_FMTd__ "ld" // S390X:#define __INT_FAST64_FMTi__ "li" // S390X:#define __INT_FAST64_MAX__ 9223372036854775807L // S390X:#define __INT_FAST64_TYPE__ long int // S390X:#define __INT_FAST8_FMTd__ "hhd" // S390X:#define __INT_FAST8_FMTi__ "hhi" // S390X:#define __INT_FAST8_MAX__ 127 // S390X:#define __INT_FAST8_TYPE__ signed char // S390X:#define __INT_LEAST16_FMTd__ "hd" // S390X:#define __INT_LEAST16_FMTi__ "hi" // S390X:#define __INT_LEAST16_MAX__ 32767 // S390X:#define __INT_LEAST16_TYPE__ short // S390X:#define __INT_LEAST32_FMTd__ "d" // S390X:#define __INT_LEAST32_FMTi__ "i" // S390X:#define __INT_LEAST32_MAX__ 2147483647 // S390X:#define __INT_LEAST32_TYPE__ int // S390X:#define __INT_LEAST64_FMTd__ "ld" // S390X:#define __INT_LEAST64_FMTi__ "li" // S390X:#define __INT_LEAST64_MAX__ 9223372036854775807L // S390X:#define __INT_LEAST64_TYPE__ long int // S390X:#define __INT_LEAST8_FMTd__ "hhd" // S390X:#define __INT_LEAST8_FMTi__ "hhi" // S390X:#define __INT_LEAST8_MAX__ 127 // S390X:#define __INT_LEAST8_TYPE__ signed char // S390X:#define __INT_MAX__ 2147483647 // S390X:#define __LDBL_DENORM_MIN__ 6.47517511943802511092443895822764655e-4966L // S390X:#define __LDBL_DIG__ 33 // S390X:#define __LDBL_EPSILON__ 1.92592994438723585305597794258492732e-34L // S390X:#define __LDBL_HAS_DENORM__ 1 // S390X:#define __LDBL_HAS_INFINITY__ 1 // S390X:#define __LDBL_HAS_QUIET_NAN__ 1 // S390X:#define __LDBL_MANT_DIG__ 113 // S390X:#define __LDBL_MAX_10_EXP__ 4932 // S390X:#define __LDBL_MAX_EXP__ 16384 // S390X:#define __LDBL_MAX__ 1.18973149535723176508575932662800702e+4932L // S390X:#define __LDBL_MIN_10_EXP__ (-4931) // S390X:#define __LDBL_MIN_EXP__ (-16381) // S390X:#define __LDBL_MIN__ 3.36210314311209350626267781732175260e-4932L // S390X:#define __LONG_LONG_MAX__ 9223372036854775807LL // S390X:#define __LONG_MAX__ 9223372036854775807L // S390X:#define __NO_INLINE__ 1 // S390X:#define __POINTER_WIDTH__ 64 // S390X:#define __PTRDIFF_TYPE__ long int // S390X:#define __PTRDIFF_WIDTH__ 64 // S390X:#define __SCHAR_MAX__ 127 // S390X:#define __SHRT_MAX__ 32767 // S390X:#define __SIG_ATOMIC_MAX__ 2147483647 // S390X:#define __SIG_ATOMIC_WIDTH__ 32 // S390X:#define __SIZEOF_DOUBLE__ 8 // S390X:#define __SIZEOF_FLOAT__ 4 // S390X:#define __SIZEOF_INT__ 4 // S390X:#define __SIZEOF_LONG_DOUBLE__ 16 // S390X:#define __SIZEOF_LONG_LONG__ 8 // S390X:#define __SIZEOF_LONG__ 8 // S390X:#define __SIZEOF_POINTER__ 8 // S390X:#define __SIZEOF_PTRDIFF_T__ 8 // S390X:#define __SIZEOF_SHORT__ 2 // S390X:#define __SIZEOF_SIZE_T__ 8 // S390X:#define __SIZEOF_WCHAR_T__ 4 // S390X:#define __SIZEOF_WINT_T__ 4 // S390X:#define __SIZE_TYPE__ long unsigned int // S390X:#define __SIZE_WIDTH__ 64 // S390X-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 8UL // S390X:#define __UINT16_C_SUFFIX__ // S390X:#define __UINT16_MAX__ 65535 // S390X:#define __UINT16_TYPE__ unsigned short // S390X:#define __UINT32_C_SUFFIX__ U // S390X:#define __UINT32_MAX__ 4294967295U // S390X:#define __UINT32_TYPE__ unsigned int // S390X:#define __UINT64_C_SUFFIX__ UL // S390X:#define __UINT64_MAX__ 18446744073709551615UL // S390X:#define __UINT64_TYPE__ long unsigned int // S390X:#define __UINT8_C_SUFFIX__ // S390X:#define __UINT8_MAX__ 255 // S390X:#define __UINT8_TYPE__ unsigned char // S390X:#define __UINTMAX_C_SUFFIX__ UL // S390X:#define __UINTMAX_MAX__ 18446744073709551615UL // S390X:#define __UINTMAX_TYPE__ long unsigned int // S390X:#define __UINTMAX_WIDTH__ 64 // S390X:#define __UINTPTR_MAX__ 18446744073709551615UL // S390X:#define __UINTPTR_TYPE__ long unsigned int // S390X:#define __UINTPTR_WIDTH__ 64 // S390X:#define __UINT_FAST16_MAX__ 65535 // S390X:#define __UINT_FAST16_TYPE__ unsigned short // S390X:#define __UINT_FAST32_MAX__ 4294967295U // S390X:#define __UINT_FAST32_TYPE__ unsigned int // S390X:#define __UINT_FAST64_MAX__ 18446744073709551615UL // S390X:#define __UINT_FAST64_TYPE__ long unsigned int // S390X:#define __UINT_FAST8_MAX__ 255 // S390X:#define __UINT_FAST8_TYPE__ unsigned char // S390X:#define __UINT_LEAST16_MAX__ 65535 // S390X:#define __UINT_LEAST16_TYPE__ unsigned short // S390X:#define __UINT_LEAST32_MAX__ 4294967295U // S390X:#define __UINT_LEAST32_TYPE__ unsigned int // S390X:#define __UINT_LEAST64_MAX__ 18446744073709551615UL // S390X:#define __UINT_LEAST64_TYPE__ long unsigned int // S390X:#define __UINT_LEAST8_MAX__ 255 // S390X:#define __UINT_LEAST8_TYPE__ unsigned char // S390X:#define __USER_LABEL_PREFIX__ // S390X:#define __WCHAR_MAX__ 2147483647 // S390X:#define __WCHAR_TYPE__ int // S390X:#define __WCHAR_WIDTH__ 32 // S390X:#define __WINT_TYPE__ int // S390X:#define __WINT_WIDTH__ 32 // S390X:#define __s390__ 1 // S390X:#define __s390x__ 1 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=s390x-none-zos -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X-ZOS %s // RUN: %clang_cc1 -x c++ -std=gnu++14 -E -dM -ffreestanding -triple=s390x-none-zos -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X-ZOS -check-prefix S390X-ZOS-GNUXX %s // S390X-ZOS-GNUXX: #define _EXT 1 // S390X-ZOS: #define _LONG_LONG 1 // S390X-ZOS-GNUXX: #define _MI_BUILTIN 1 // S390X-ZOS: #define _OPEN_DEFAULT 1 // S390X-ZOS: #define _UNIX03_WITHDRAWN 1 // S390X-ZOS-GNUXX: #define _XOPEN_SOURCE 600 // S390X-ZOS: #define __370__ 1 // S390X-ZOS: #define __64BIT__ 1 // S390X-ZOS: #define __BFP__ 1 // S390X-ZOS: #define __BOOL__ 1 // S390X-ZOS-GNUXX: #define __DLL__ 1 // S390X-ZOS: #define __LONGNAME__ 1 // S390X-ZOS: #define __MVS__ 1 // S390X-ZOS: #define __THW_370__ 1 // S390X-ZOS: #define __THW_BIG_ENDIAN__ 1 // S390X-ZOS: #define __TOS_390__ 1 // S390X-ZOS: #define __TOS_MVS__ 1 // S390X-ZOS: #define __XPLINK__ 1 // S390X-ZOS-GNUXX: #define __wchar_t 1
the_stack_data/86074503.c
void io_hlt(void); void HariMain(void) { fin: // naskfunc.nas の _io_hlt() を実行 io_hlt(); goto fin; }
the_stack_data/25136719.c
int main() { expect(1, 0x1); expect(17, 0x11); expect(511, 0777); }
the_stack_data/621539.c
/* Questão 4 (Peso 2.5). Crie uma estrutura para armazenar dados de funcionários: o nome e o ano de ingresso em uma empresa. Desenvolver um algoritmo que leia o ano atual,calcule e exiba o nome e o tempo de serviço de cada funcionário cadastrado (em anos), o nome do funcionário mais antigo da empresa e o nome do funcionário mais novo da empresa. Considere que a empresa tem 1000 funcionários. */ #include <stdio.h> #define numero_funcionarios 1000 typedef struct dados { char nome[20]; int ano_ingresso; } dado; int main(void) { dado ufsm[numero_funcionarios]; int i; int ano_atual, tempo_servico[numero_funcionarios]; int maior_tempo = 0, menor_tempo = 1000; printf("Digite o ano atual: "); scanf("%d", &ano_atual); for (i = 0; i < numero_funcionarios; i++) { printf("\nDigite o nome do funcionario %d: ", i + 1); scanf("%s", &ufsm[i].nome); printf("\nDigite o ano de ingresso do funcionario %d: ", i + 1); scanf("%d", &ufsm[i].ano_ingresso); tempo_servico[i] = ano_atual - ufsm[i].ano_ingresso; } for (i = 0; i < numero_funcionarios; i++) { printf("\nFuncionario %d: Nome: %s - Tempo de servico: %d anos", i+1, ufsm[i].nome, tempo_servico[i]); }; // Bloco de Codigo para o mais antigo for (i = 0; i < numero_funcionarios; i++) { if (tempo_servico[i] > maior_tempo) { maior_tempo = tempo_servico[i]; } }; for (i = 0; i < numero_funcionarios; i++) { if (tempo_servico[i] == maior_tempo) { printf("\nO(A) funcionario(a) mais antigo(a) da empresa e: %s !\n", ufsm[i].nome); } }; // Bloco de Codigo Para o Mais novo for (i = 0; i < numero_funcionarios; i++) { if (tempo_servico[i] < menor_tempo) { menor_tempo = tempo_servico[i]; } }; for (i = 0; i < numero_funcionarios; i++) { if (tempo_servico[i] == menor_tempo) { printf("\nO(A) funcionario(a) mais novo(a) da empresa e: %s !\n", ufsm[i].nome); } }; return 0; }
the_stack_data/31387579.c
int maxSubArray(int* nums, int numsSize){ int r = -101; int c = 0; for (int i = 0; i < numsSize; i++) { c += nums[i]; if (c > r) { r = c; } if (c < 0) { c = 0; } } return r; }
the_stack_data/26783.c
#include <stdio.h> int main() { int a,b; scanf("%d%d",&a,&b); if(b>a) { if(b%a==0) printf("Sao Multiplos\n"); else printf("Nao sao Multiplos\n"); } else { if(a%b==0) printf("Sao Multiplos\n"); else printf("Nao sao Multiplos\n"); } return 0; }
the_stack_data/109574.c
#include <stdio.h> #include <stdlib.h> #include <locale.h> #include <curses.h> #include <math.h> #include <sys/ioctl.h> #include <string.h> #include <ctype.h> #include <time.h> #include <libgen.h> #define DEBUG 1 #define RD_WIDTH 70 #define RD_HEIGHT 28 /*turnPage reads enough characters to fit within the confines of the reader window, and puts them inside currentPage*/ int turnPage(FILE *book); /*clearBackground writes an empty space over all characters*/ void clearBackground(); /*drawBackground writes a tilde `~` periodically over the background*/ void drawBackground(); /*drawBorder creates a border around the reader*/ void drawBorder(); /*drawReader creates an empty box of size WIDTH x HEIGHT to display text in*/ void drawReader(); /*drawText writes the text of the file into the reader box. it has optional arguments to highlight *certain text at a certain offset. Passing NULL or -1 into it will cause it to not highlight any text*/ void drawText(char *highlighted, int offset); /*drawAll is a catch-all to call clearBackground, drawBackground, drawBorder, drawReader, and drawText. It takes *the same parameters as drawText and passes them through to drawText*/ void drawAll(char *highlighted, int offset); /*find searches all pages of the book for the phrase requested and returns the offset of that phrase within that page *the parameter "original" is to save the location of the reader's page in case the phrase is not found*/ int find(char *phrase, FILE *book, int original); /*saveBookmark will save a bookmark in ~/.books/bookmarks*/ void saveBookmark(char *bookName); /*readBookmark will open the book to the page defined in ~/.books/bookmarks*/ int readBookmark(char *bookName, int markNum); /*scr_width and scr_height are the dimensions of the terminal*/ int scr_width = -1; int scr_height = -1; /*currentPageNum is the current page number. a single page is defined by how many characters can *fit in a given window, so a page is different from screen size to screen size*/ int currentPageNum = 0; /*WIDTH and HEIGHT are the dimensions of the reader*/ int WIDTH = RD_WIDTH; int HEIGHT = RD_HEIGHT; /*currentPage is all the characters which can were read from the file and fit inside the reader*/ char *currentPage; int fileOffset = -1; int bookmarksOpen = 0; int bookmarkSelect = 0; /*getOption is used to get the value associated with some command line argument*/ char *getOption(int argc, char *argv[], char *desired_arg); /*returns the number of digits in some integer. Helper*/ unsigned int GetNumberOfDigits(unsigned int i); char *getFileContents(FILE *file); void showBookMarks(FILE *bookmarkFile, int index); int main(int argc, char **argv){ /*Initialization; check for file*/ if(argc < 2){ fprintf(stderr, "Error:\n\tUsage: books [FILE] (OPTIONAL: -w [WIDTH] -h [HEIGHT] -p [PAGENUM] -b, --help for more explanation)\n"); exit(1); } /*get options and deal with them*/ char *configPath = malloc(strlen(getenv("HOME")) + strlen("/.books/config/config.cfg")); strcat(configPath, getenv("HOME")); strcat(configPath, "/.books/config/config.cfg"); FILE *cfg = fopen(configPath, "r"); char *value; /*-w defines the width of the reader*/ if((value = getOption(argc, argv, "-w")) != NULL){ WIDTH = atoi(value); }else if(cfg != NULL){ fscanf(cfg, "width=%d", &WIDTH); } /*-h defines the height of the reader*/ if((value = getOption(argc, argv, "-h")) != NULL){ HEIGHT = atoi(value); }else if(cfg != NULL){ fscanf(cfg, "height=%d", &HEIGHT); } /*if -b is present, then the reader will look for a bookmark*/ if((value = getOption(argc, argv, "-b")) != NULL){ fileOffset = readBookmark(basename(argv[1]), -1); } /*the max size of currentpage is the area of the reader*/ currentPage = malloc(WIDTH * HEIGHT); /*-p is used to jump to a specific page*/ if((value = getOption(argc, argv, "-p")) != NULL){ currentPageNum = atoi(value); } FILE *book = fopen(argv[1], "r"); if(book == NULL){ fprintf(stderr, "Error: Couldn't open book\n"); exit(1); } /*get terminal size*/ struct winsize size; if(ioctl(0, TIOCGWINSZ, (char *)&size) < 0){ fprintf(stderr, "Error getting winsize!\n"); exit(1); } scr_height = size.ws_row; scr_width = size.ws_col; /*deal with UTF-8*/ setlocale(LC_CTYPE, ""); initscr(); if(has_colors()){ start_color(); init_pair(1, COLOR_BLACK, COLOR_BLUE); } /*turn to page if -p is set*/ if(fileOffset > -1){ int toPage = currentPageNum; int toOffset = fileOffset; currentPageNum = 0; fileOffset = -1; while(1){ turnPage(book); toPage = currentPageNum; if(fileOffset >= toOffset){ break; } } rewind(book); currentPageNum = 0; for(int i = 0; i < toPage; i++){ turnPage(book); } }else{ /*if -p is not set, then just go to page 1*/ turnPage(book); } /*no highlighting to be done, so pass NULL and -1*/ drawAll(NULL, -1); refresh(); while(1){ /*a single character command like n or b will execute without a carriage return*/ char command = getch(); /*n for "next page"*/ if(command == 'n'){ if(!bookmarksOpen){ turnPage(book); drawAll(NULL, -1); }else{ bookmarkSelect++; drawAll(NULL, -1); char *bookmarkPath = calloc(strlen(getenv("HOME")) + strlen("/.books/bookmarks/") + strlen(basename(argv[1])) + strlen(".bookmark"), 1); strcat(bookmarkPath, getenv("HOME")); strcat(bookmarkPath, "/.books/bookmarks/"); strcat(bookmarkPath, basename(argv[1])); strcat(bookmarkPath, ".bookmark"); FILE *bookmarkFile = fopen(bookmarkPath, "r"); if(bookmarkFile != NULL){ showBookMarks(bookmarkFile, bookmarkSelect); fclose(bookmarkFile); mvprintw(scr_height - 1, scr_width -1, " "); } } refresh(); }else if(command == 'b'){ /*b for "back"*/ if(!bookmarksOpen){ rewind(book); int tmpPageNum = currentPageNum - 1; currentPageNum = 0; for(int i = 0; i < tmpPageNum; i++){ if(turnPage(book) == 0) break; } drawAll(NULL, -1); }else{ bookmarkSelect--; drawAll(NULL, -1); char *bookmarkPath = calloc(strlen(getenv("HOME")) + strlen("/.books/bookmarks/") + strlen(basename(argv[1])) + strlen(".bookmark"), 1); strcat(bookmarkPath, getenv("HOME")); strcat(bookmarkPath, "/.books/bookmarks/"); strcat(bookmarkPath, basename(argv[1])); strcat(bookmarkPath, ".bookmark"); FILE *bookmarkFile = fopen(bookmarkPath, "r"); if(bookmarkFile != NULL){ showBookMarks(bookmarkFile, bookmarkSelect); fclose(bookmarkFile); mvprintw(scr_height - 1, scr_width -1, " "); } } refresh(); }else if(command == 'g'){ if(bookmarksOpen){ fileOffset = readBookmark(basename(argv[1]), bookmarkSelect); int toPage = 0; rewind(book); int toOffset = fileOffset; currentPageNum = 0; fileOffset = -1; while(1){ turnPage(book); toPage = currentPageNum; if(fileOffset >= toOffset){ break; } } rewind(book); currentPageNum = 0; for(int i = 0; i < toPage; i++){ turnPage(book); } drawAll(NULL, -1); refresh(); bookmarksOpen = 0; } }else if(command == ':'){ /*a semicolon or forward slash is used to execute more *complicated commands, like searching or navigation *and requires a full string plus a carriage return*/ char *options = malloc(80); mvprintw(scr_height-1, 2, ":"); getstr(options); /*g for "goto page#"*/ if(options[0] == 'g' && strlen(options) > 1){ options++; rewind(book); int tmpPageNum = atoi(options); if(tmpPageNum != 0){ currentPageNum = 0; for(int i = 1; i <= tmpPageNum; i++){ if(turnPage(book) == 0) break; } } drawAll(NULL, -1); refresh(); options--; bookmarksOpen = 0; free(options); }else if(options[0] == 'q'){ /*q for quit*/ free(options); break; }else if(options[0] == 's'){ /*s for saving a bookmark*/ saveBookmark(basename(argv[1])); bookmarksOpen = 0; drawAll(NULL, -1); refresh(); free(options); }else if(options[0] == 'b'){ if(!bookmarksOpen){ drawAll(NULL, -1); bookmarkSelect = 0; char *bookmarkPath = calloc(strlen(getenv("HOME")) + strlen("/.books/bookmarks/") + strlen(basename(argv[1])) + strlen(".bookmark"), 1); strcat(bookmarkPath, getenv("HOME")); strcat(bookmarkPath, "/.books/bookmarks/"); strcat(bookmarkPath, basename(argv[1])); strcat(bookmarkPath, ".bookmark"); FILE *bookmarkFile = fopen(bookmarkPath, "r"); if(bookmarkFile != NULL){ showBookMarks(bookmarkFile, bookmarkSelect); fclose(bookmarkFile); bookmarksOpen = 1; mvprintw(scr_height - 1, scr_width -1, " "); }else{ mvprintw(2, scr_width - 32, "*============================*"); mvprintw(3, scr_width - 32, "| Error: no bookmarks found |"); mvprintw(4, scr_width - 32, "*============================*"); mvprintw(scr_height-1, scr_width-1, " "); } }else{ drawAll(NULL, -1); bookmarksOpen = 0; } refresh(); }else{ /*else, just go back to what we were doing*/ bookmarksOpen = 0; drawAll(NULL, -1); refresh(); free(options); } }else if(command == '/'){ bookmarksOpen = 0; /*forward slash is used for searching*/ char *options = malloc(80); mvprintw(scr_height-1, 2, "/"); getstr(options); if(strlen(options) == 0){ drawAll(NULL, -1); refresh(); free(options); }else{ int off = find(options, book, currentPageNum); drawAll(options, off); refresh(); free(options); } } } endwin(); } int find(char *phrase, FILE *book, int originalPage){ /*-1 by default so that if nothing is found, no highlighting is done*/ int j = -1; while(1){ /*j is assigned to the return value of turnPage, *which returns 0 when it reaches EOF, meaning the phrase *was not found from this location onwards*/ if(j == 0){ /*check from beginning of the book?*/ mvprintw((scr_height - 8)/2, (scr_width - 20)/2, "*==================*"); mvprintw((scr_height - 8)/2 + 1, (scr_width - 20)/2, "| Could not find |"); mvprintw((scr_height - 8)/2 + 2, (scr_width - 20)/2, "| phrase entered. |"); mvprintw((scr_height - 8)/2 + 3, (scr_width - 20)/2, "| restart from |"); mvprintw((scr_height - 8)/2 + 4, (scr_width - 20)/2, "| beginning? |"); mvprintw((scr_height - 8)/2 + 5, (scr_width - 20)/2, "| |"); mvprintw((scr_height - 8)/2 + 6, (scr_width - 20)/2, "| (Y/N) |"); mvprintw((scr_height - 8)/2 + 7, (scr_width - 20)/2, "*==================*"); char choice = getch(); if(tolower(choice) == 'y'){ rewind(book); currentPageNum = 0; /*recursively search until user says no, which returns -1, meaning no highlighting needs to be done*/ return find(phrase, book, originalPage); }else{ /*if no, then just return -1*/ rewind(book); currentPageNum = 0; for(int i = 0; i < originalPage; i++){ if(turnPage(book) == 0) break; } return -1; } return -1; } j = turnPage(book); char *location = strstr(currentPage, phrase); /*non-NULL means the phrase was found on this page. *Return the starting address of the substring minus the *starting address of the search phrase, to get the offset *of the substring in the search phrase*/ if(location != NULL){ return (int)(location - currentPage); } } } void clearBackground(){ for(int i = 0; i < scr_height; i++){ for(int j = 0; j < scr_width; j++){ mvprintw(i, j, " "); } } } void saveBookmark(char *bookname){ /*save page # to ~/.books/bookmarks*/ char *filePathSave = calloc(strlen(getenv("HOME")) + strlen("/.books/bookmarks/") + strlen(bookname) + strlen(".bookmark"), 1); strcat(filePathSave, getenv("HOME")); strcat(filePathSave, "/.books/bookmarks/"); strcat(filePathSave, bookname); strcat(filePathSave, ".bookmark"); /*Preserve history*/ FILE *bookmark; bookmark = fopen(filePathSave, "r"); char *oldBookmarks = ""; if(bookmark !=NULL){ oldBookmarks = getFileContents(bookmark); fclose(bookmark); } /*Delete contents*/ bookmark = fopen(filePathSave, "w"); if(bookmark == NULL){ mvprintw(scr_height -1, 2, "ERROR: Couldn't save bookmark"); exit(1); return; } fprintf(bookmark, "time=%d\nlocation=%d\n%s", (int)time(NULL), fileOffset, oldBookmarks); fclose(bookmark); free(filePathSave); } int readBookmark(char *bookname, int markNum){ /*get Page # from ~/.books/bookmarks*/ char *filePathSave = calloc(strlen(getenv("HOME")) + strlen("/.books/bookmarks/") + strlen(bookname) + strlen(".bookmark"), 1); strcat(filePathSave, getenv("HOME")); strcat(filePathSave, "/.books/bookmarks/"); strcat(filePathSave, bookname); strcat(filePathSave, ".bookmark"); FILE *bookmark = fopen(filePathSave, "r"); if(bookmark == NULL){ mvprintw(scr_height -1, 2, "ERROR: Couldn't open bookmark"); return 1; } int location = -1; int time = -1; if(markNum == -1){ fscanf(bookmark, "time=%d\n", &time); fscanf(bookmark, "location=%d\n", &location); }else{ for(int i = 0; i <= markNum; i++){ fscanf(bookmark, "time=%d\n", &time); fscanf(bookmark, "location=%d\n", &location); } } free(filePathSave); return location; } void drawBackground(){ for(int i = 0; i < scr_height; i++){ for(int j = 0; j < scr_width; j++){ if((j + ((i % 2) * 4)) % 8 == 0){ mvprintw(i, j, "~"); } } } } void drawBorder(){ mvprintw((scr_height - HEIGHT)/2 - 2, (scr_width - WIDTH)/2 - 2, "#"); mvprintw((scr_height - HEIGHT)/2 - 2, (scr_width - WIDTH)/2 + WIDTH + 1, "#"); mvprintw((scr_height - HEIGHT)/2 + HEIGHT + 1, (scr_width - WIDTH)/2 - 2, "#"); mvprintw((scr_height - HEIGHT)/2 + HEIGHT + 1, (scr_width - WIDTH)/2 + WIDTH + 1, "#"); for(int i = 0; i < HEIGHT + 2; i++){ mvprintw((scr_height - HEIGHT)/2 + i-1, (scr_width - WIDTH)/2 - 2, "|"); mvprintw((scr_height - HEIGHT)/2 + i-1, (scr_width - WIDTH)/2 + WIDTH + 1, "|"); } for(int i = 0; i < WIDTH+2; i++){ mvprintw((scr_height - HEIGHT)/2 -2, (scr_width - WIDTH)/2 + i - 1, "="); mvprintw((scr_height - HEIGHT)/2 + HEIGHT + 1, (scr_width - WIDTH)/2 + i - 1, "="); } } void drawReader(){ for(int i = 0; i < HEIGHT+2; i++){ for(int j = 0; j < WIDTH+2; j++){ mvprintw((scr_height - HEIGHT)/2 + i-1, (scr_width - WIDTH)/2 + j-1, " "); } } } void drawText(char *highlighted, int offset){ int currentLine = 0; int currentChar = 0; for(int i = 0; i < WIDTH * HEIGHT; i++){ /*if we've hit a newline, if we've hit the width of the reader, or if we've hit the end of the string, *go to a new line*/ if(currentPage[i] == '\n' || currentChar == WIDTH || currentPage[i] == '\0'){ currentLine++; currentChar = 0; } /*write any character that's not a newline. newlines are just dealt with by incrementing currentLine*/ if(currentPage[i] != '\n'){ /*highlight when offset is not negative, AND when highlighted is provided. If find returns -1, nothing *will be highlighted even if a search term was provided*/ if(highlighted != NULL && offset > -1 && has_colors()){ if(i >= offset && i < offset + strlen(highlighted)) /*highlight color is blue*/ attron(COLOR_PAIR(1)); } mvprintw((scr_height - HEIGHT)/2 + currentLine, (scr_width - WIDTH)/2 + currentChar, "%c", currentPage[i]); currentChar++; /*reset color*/ attroff(COLOR_PAIR(1)); } /*once we've hit the end of the reader, return*/ if((((scr_height - HEIGHT)/2) + currentLine) >= ((scr_height - HEIGHT)/2 + HEIGHT)){ return; } } } void drawAll(char *highlighted, int offset){ clearBackground(); drawBackground(); drawReader(); drawBorder(); drawText(highlighted, offset); /*print the page #*/ mvprintw(2, 1, ":"); for(int i = 0; i < strlen("Page #") + GetNumberOfDigits(currentPageNum) + 4; i++){ mvprintw(1, i+1, "="); mvprintw(3, i+1, "="); } mvprintw(2, strlen("Page #") + GetNumberOfDigits(currentPageNum) + 4, ":"); mvprintw(2,3, "Page #%d", currentPageNum); mvprintw(scr_height - 1, scr_width - 1, " "); } int turnPage(FILE *book){ /*increment the apge*/ fileOffset = ftell(book) + 1; currentPageNum++; int currentChar = 0; int currentLine = 0; /*empty out the page*/ memset(currentPage, 0, WIDTH * HEIGHT); char c; /*read a MAX of the area of the reader*/ for(int i = 0; i < WIDTH * HEIGHT; i++){ c = fgetc(book); /*returning 0 will signal to find() that we need to start our search over again*/ if(c == EOF){ return 0; } /*increment line on newline and when we've hit the edge of the reader*/ if(c == '\n' || (currentChar + 1) % WIDTH == 0){ currentLine++; currentChar = 0; } currentChar++; currentPage[i] = c; /*once we've hit the end, return 1, indicating the book is not over*/ if(currentLine == HEIGHT) return 1; } } char *getOption(int argc, char **argv, char *desired_arg){ for(int i = 0; i < argc; i++){ if(strcmp(desired_arg, argv[i]) == 0){ if(argc == i + 1){ return "1"; }else{ return argv[i+1]; } } } return NULL; } unsigned int GetNumberOfDigits (unsigned int i){ return i > 0 ? (int) log10 ((double) i) + 1 : 1; } char *getFileContents(FILE *file){ rewind(file); char c; fseek(file, 0, SEEK_END); int size = ftell(file); char *contents = calloc(size + 1, 1); int i = 0; rewind(file); while((c = fgetc(file)) != EOF){ contents[i++] = c; } rewind(file); return contents; } void showBookMarks(FILE *bookmarkFile, int index){ rewind(bookmarkFile); int time = 0; int location = 0; int i = 0; mvprintw(i++, scr_width - 30, "*============================*"); mvprintw(i++, scr_width - 30, "| Bookmarks "); mvprintw(i++, scr_width - 30, "*============================*"); while(fscanf(bookmarkFile, "time=%d\nlocation=%d\n", &time, &location) != EOF && i != 10){ if(index == i - 3){ attron(COLOR_PAIR(1)); } mvprintw(i, scr_width - 30, "| "); mvprintw(i, scr_width - 28, "@ %d", location); for(int j = 0; j < 26 - GetNumberOfDigits(location); j++){ mvprintw(i, scr_width - (26 - GetNumberOfDigits(location)) + j, " "); } i++; attroff(COLOR_PAIR(1)); } mvprintw(i++, scr_width - 30, "*============================*"); mvprintw(scr_height - 1, scr_width -1, " "); refresh(); }
the_stack_data/588258.c
#include <stdio.h> #include <math.h> int main() { int T; double D, K, X, r0, r1, black_circle, pi = (double)acos(-1); // printf("%lf", (double)M_PI); scanf("%d", &T); for (size_t i = 0; i < T; i++) { scanf("%lf %lf", &D, &K); getchar(); X = (double)(D / (2 * pi)); r1 = (double)(X / (K - 1)); r0 = (double)(X + r1); black_circle = (double)((pi * (r0 * r0)) - (pi * (r1 * r1))); printf("%.6lf\n", black_circle); } return 0; }
the_stack_data/248580374.c
/* write a program that prints its input one word per line */ #include <stdio.h> #define IN 1 #define OUT 0 int main() { int c, state; state = OUT; while ((c = getchar()) != EOF) { if (c != ' ' && c != '\t' && c != '\n') { putchar(c); state = IN; } else { state = OUT; putchar('\n'); } } return 0; }
the_stack_data/25137491.c
/* { dg-do compile } */ /* { dg-require-effective-target vect_float } */ void vector_fmul_reverse_c(float *dst, const float *src0, const float *src1, int len){ int i; src1 += len-1; for(i=0; i<len; i++) dst[i] = src0[i] * src1[-i]; } /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { vect_perm && vect_hw_misalign } } } } */
the_stack_data/173577250.c
#include <stdio.h> #include <stdlib.h> main() { system("whoami"); }
the_stack_data/146870.c
// RUN: 3c -addcr -alltypes %s -- | FileCheck -match-full-lines -check-prefixes="CHECK_ALL","CHECK" %s // RUN: 3c -addcr %s -- | FileCheck -match-full-lines -check-prefixes="CHECK_NOALL","CHECK" %s // RUN: 3c -addcr %s -- | %clang -c -fcheckedc-extension -x c -o /dev/null - // RUN: 3c -alltypes -output-postfix=checked %s // RUN: 3c -alltypes %S/macroConcat.checked.c -- | count 0 // RUN: rm %S/macroConcat.checked.c #define c(g) void FOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO##g () c(BAR0); c(BAR1); c(BAR2); c(BAR3); c(BAR4); c(BAR5); c(BAR6); c(BAR7); c(BAR8); c(BAR9); c(BAR10); c(BAR11); c(BAR12); c(BAR13); c(BAR14); c(BAR15); c(BAR16); c(BAR17); c(BAR18); c(BAR19); c(BAR20); c(BAR21); c(BAR22); c(BAR23); c(BAR24); c(BAR25); c(BAR26); c(BAR27); c(BAR28); c(BAR29); c(BAR30); c(BAR31); c(BAR32); c(BAR33); c(BAR34); c(BAR35); c(BAR36); c(BAR37); c(BAR38); #define u(d) void add##d(g) {} // CHECK: #define u(d) void add##d(g) {} u(2); // CHECK: u(2); int *a = 0; // CHECK: _Ptr<int> a = 0;
the_stack_data/502144.c
static const unsigned char updownarrow_bmp_data[] = { 0x42, 0x4d, 0x38, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0xc3, 0x0e, 0x00, 0x00, 0xc3, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x21, 0x08, 0x21, 0x08, 0x21, 0x08, 0x21, 0x08, 0x21, 0x08, 0x21, 0x08, 0x21, 0x08, 0x21, 0x08, 0x21, 0x08, 0x21, 0x08, 0x21, 0x08, 0x21, 0x08, 0x21, 0x08, 0x21, 0x08, 0x21, 0x00, 0x00, 0x59, 0x6b, 0x10, 0x42, 0x10, 0x42, 0x10, 0x42, 0x10, 0x42, 0x10, 0x42, 0x10, 0x42, 0x10, 0x42, 0x10, 0x42, 0x10, 0x42, 0x10, 0x42, 0x10, 0x42, 0x10, 0x42, 0x10, 0x42, 0x08, 0x21, 0x00, 0x00, 0x59, 0x6b, 0xff, 0x7f, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x10, 0x42, 0x08, 0x21, 0x00, 0x00, 0x59, 0x6b, 0xff, 0x7f, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x00, 0x00, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x10, 0x42, 0x08, 0x21, 0x00, 0x00, 0x59, 0x6b, 0xff, 0x7f, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x10, 0x42, 0x08, 0x21, 0x00, 0x00, 0x59, 0x6b, 0xff, 0x7f, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x10, 0x42, 0x08, 0x21, 0x00, 0x00, 0x59, 0x6b, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0x10, 0x42, 0x08, 0x21, 0x00, 0x00, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x08, 0x21, 0x00, 0x00, 0x08, 0x21, 0x08, 0x21, 0x08, 0x21, 0x08, 0x21, 0x08, 0x21, 0x08, 0x21, 0x08, 0x21, 0x08, 0x21, 0x08, 0x21, 0x08, 0x21, 0x08, 0x21, 0x08, 0x21, 0x08, 0x21, 0x08, 0x21, 0x08, 0x21, 0x00, 0x00, 0x59, 0x6b, 0x10, 0x42, 0x10, 0x42, 0x10, 0x42, 0x10, 0x42, 0x10, 0x42, 0x10, 0x42, 0x10, 0x42, 0x10, 0x42, 0x10, 0x42, 0x10, 0x42, 0x10, 0x42, 0x10, 0x42, 0x10, 0x42, 0x08, 0x21, 0x00, 0x00, 0x59, 0x6b, 0xff, 0x7f, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x10, 0x42, 0x08, 0x21, 0x00, 0x00, 0x59, 0x6b, 0xff, 0x7f, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x10, 0x42, 0x08, 0x21, 0x00, 0x00, 0x59, 0x6b, 0xff, 0x7f, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x00, 0x00, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x10, 0x42, 0x08, 0x21, 0x00, 0x00, 0x59, 0x6b, 0xff, 0x7f, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x10, 0x42, 0x08, 0x21, 0x00, 0x00, 0x59, 0x6b, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0x10, 0x42, 0x08, 0x21, 0x00, 0x00, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x59, 0x6b, 0x08, 0x21, 0x00, 0x00, 0x00, 0x00 };
the_stack_data/117329285.c
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> int main(int argc, char * argv[]){ char payload[100]; char filename[100]; setuid(0); if(argc < 2){ printf("%s\n", "Usage ./wrapper <username>."); exit(1); } for (int i = 0; i < strlen(argv[1]); ++i){ if(argv[1][i] == '!' || argv[1][i] == '@' || argv[1][i] == '#' || argv[1][i] == '$' || argv[1][i] == '%' || argv[1][i] == '^' || argv[1][i] == '&' || argv[1][i] == '*' || argv[1][i] == '(' || argv[1][i] == ')' || argv[1][i] == '{' || argv[1][i] == '}' || argv[1][i] == '[' || argv[1][i] == ']' || argv[1][i] == ':' || argv[1][i] == ';' || argv[1][i] == '"' || argv[1][i] == '\'' || argv[1][i] == '<' || argv[1][i] == '>' || argv[1][i] == '.' || argv[1][i] == '/' || argv[1][i] == '?' || argv[1][i] == '~' || argv[1][i] == '`' ){ printf("Illegal string\n"); exit(1); } } if( strlen(argv[1]) > 25){ printf("%s\n", "username length should be less than 26"); exit(1); } strcat(filename, "/opt/openvpn/client/"); strcat(filename, argv[1]); strcat(filename, ".ovpn"); if( access( filename, F_OK) == 0 ){ printf("%s\n" ,"File already exists."); exit(1); } strcpy(payload, "/usr/bin/echo '1\n"); strcat(payload,argv[1]); strcat(payload,"\n1\n' | /opt/openvpn/openvpn-install.sh"); system(payload); }
the_stack_data/144468.c
#include <stdio.h> int main () { return 0; }
the_stack_data/25813.c
#include<stdio.h> void passbyrefrence(int *x); void callbyvalue(int x); main() { int shivam=10; int shubham=8; callbyvalue(shivam); passbyrefrence(&shubham); printf("Debashish is now=%d \nhis brother is now =%d \n",shivam,shubham); } void callbyvalue(int x) { x=99; } void passbyrefrence(int *x) { *x=66; } //printf("%d%d",*x,x);
the_stack_data/67325004.c
int numDecodings(char * s){ if(s[0] == '0') return 0; // memo[0] stores number of ways to decode string ending at i-2 // memo[1] stores number of ways to decode string ending at i-1 int memo[2]={1, 1}; int numDecoding; int i=1; while(s[i]){ numDecoding=0; // if current character can be decoded on its own, then the number // of ways to decode the current string ending at i is the same as the number // of ways to decode the string ending at i-1 if(s[i] != '0') numDecoding = memo[1]; // if current character and the previous character can be decoded together into a letter // then we add number of ways to decode string ending at i-2 to the total if(s[i-1] == '1' || (s[i-1] == '2' && s[i] <= '6')) numDecoding += memo[0]; i++; // update number of ways for previous two positions memo[0] = memo[1]; memo[1] = numDecoding; } return memo[1]; }
the_stack_data/68888419.c
/* * Copyright (C) 1997 Massachusetts Institute of Technology * * This software is being provided by the copyright holders under the * following license. By obtaining, using and/or copying this software, * you agree that you have read, understood, and will comply with the * following terms and conditions: * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose and without fee or royalty is * hereby granted, provided that the full text of this NOTICE appears on * ALL copies of the software and documentation or portions thereof, * including modifications, that you make. * * THIS SOFTWARE IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO * REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. BY WAY OF EXAMPLE, * BUT NOT LIMITATION, COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR * WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR * THAT THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY * THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. COPYRIGHT * HOLDERS WILL BEAR NO LIABILITY FOR ANY USE OF THIS SOFTWARE OR * DOCUMENTATION. * * The name and trademarks of copyright holders may NOT be used in * advertising or publicity pertaining to the software without specific, * written prior permission. Title to copyright in this software and any * associated documentation will at all times remain with copyright * holders. See the file AUTHORS which should have accompanied this software * for a list of all copyright holders. * * This file may be derived from previously copyrighted software. This * copyright applies only to those changes made by the copyright * holders listed in the AUTHORS file. The rest of this file is covered by * the copyright notices, if any, listed below. */ #include <stdio.h> #include <assert.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> #include <sys/stat.h> #ifdef EXOPC #include <fd/cffs/cffs.h> #include <xok/sysinfo.h> extern int cffs_diskreads, cffs_diskwrites; #define ae_getrate() __sysinfo.si_rate #define ae_gettick() __sysinfo.si_system_ticks #else #include <time.h> int cffs_diskreads = 0, cffs_diskwrites = 0; #define ae_getrate() 1000 static inline int ae_gettick() { struct timeval t; gettimeofday(&t,(struct timezone *)0); // printf("time %ld %ld\n",t.tv_sec,(t.tv_sec - 847910277)*10000 + t.tv_usec/100); return (t.tv_sec - 847910277)*(1000000/ae_getrate()) + t.tv_usec/ae_getrate(); } #endif #define MB (1024 * 1024) #define NUM_FILES 1000 #define FILES_PER_DIR 100 #define NUM_DIRS ((NUM_FILES + FILES_PER_DIR - 1) / FILES_PER_DIR) #define BUF_SIZE 4096 #define FILE_SIZE (64 * MB) int phase1ticks = 0; int phase2ticks = 0; int phase3ticks = 0; int phase4ticks = 0; char buf[BUF_SIZE]; static inline void empty_buffer_cache () { #ifdef EXOPC cffs_flush (); #endif } static inline void sync_buffer_cache () { sync(); } int main (int argc, char **argv) { int j; char name[200]; int starttick; double tmpval; int ret; int fd; int startdiskreads; int startdiskwrites; #ifdef EXOPC int iterno = 1; #endif if (argc != 1) { printf ("Usage: %s\n", argv[0]); exit (0); } assert (NUM_FILES == (FILES_PER_DIR * NUM_DIRS)); #ifdef EXOPC cffs_softupdates = 0; cffs_embedinodes = 1; cffs_usegrouping = 1; main_repeat: #endif #ifdef EXOPC printf ("Large benchmark starting: %d MB file\n(embedinodes %d, usegrouping %d, softupdates %d)\n", (FILE_SIZE/MB), cffs_embedinodes, cffs_usegrouping, cffs_softupdates); #else printf ("Large benchmark starting: %d MB file (on UNIX)\n", (FILE_SIZE/MB)); #endif /* Phase 1 -- allocate and write */ empty_buffer_cache (); startdiskreads = cffs_diskreads; startdiskwrites = cffs_diskwrites; starttick = ae_gettick (); sprintf (name, "largefile"); fd = open (name, (O_CREAT|O_RDWR), 0777); assert (fd > 0); for (j=0; j<FILE_SIZE; j += BUF_SIZE) { ret = write (fd, buf, BUF_SIZE); if (ret != BUF_SIZE) { printf ("bad return from write: %d\n", ret); } assert (ret == BUF_SIZE); } ret = fsync (fd); assert (ret == 0); ret = close (fd); assert (ret == 0); phase1ticks = ae_gettick() - starttick; assert (phase1ticks != 0); tmpval = (double) phase1ticks * (double) ae_getrate() / (double) 1000000.0; printf ("Phase 1 (create/write): disk reads %d, writes %d, secs %.2f, MB/sec %.2f\n", (cffs_diskreads - startdiskreads), (cffs_diskwrites - startdiskwrites), tmpval, ((double) FILE_SIZE / (double) MB / tmpval)); /* Phase 2 -- read */ empty_buffer_cache (); startdiskreads = cffs_diskreads; startdiskwrites = cffs_diskwrites; starttick = ae_gettick (); fd = open (name, (O_RDONLY), 0777); if (fd < 0) { printf ("bad return from open %s: %d\n", name, fd); } assert (fd > 0); for (j=0; j<FILE_SIZE; j += BUF_SIZE) { ret = read (fd, buf, BUF_SIZE); assert (ret == BUF_SIZE); } ret = close (fd); assert (ret == 0); phase2ticks = ae_gettick() - starttick; assert (phase2ticks != 0); tmpval = (double) phase2ticks * (double) ae_getrate() / (double) 1000000.0; printf ("Phase 2 (read): disk reads %d, writes %d, secs %.2f, MB/sec %.2f\n", (cffs_diskreads - startdiskreads), (cffs_diskwrites - startdiskwrites), tmpval, ((double) FILE_SIZE / (double) MB / tmpval)); /* Phase 3 -- overwrite */ empty_buffer_cache (); startdiskreads = cffs_diskreads; startdiskwrites = cffs_diskwrites; starttick = ae_gettick (); fd = open (name, (O_RDWR), 0777); assert (fd > 0); for (j=0; j<FILE_SIZE; j += BUF_SIZE) { ret = write (fd, buf, BUF_SIZE); assert (ret == BUF_SIZE); } ret = fsync (fd); assert (ret == 0); ret = close (fd); assert (ret == 0); phase3ticks = ae_gettick() - starttick; assert (phase3ticks != 0); tmpval = (double) phase3ticks * (double) ae_getrate() / (double) 1000000.0; printf ("Phase 3 (overwrite): disk reads %d, writes %d, secs %.2f, MB/sec %.2f\n", (cffs_diskreads - startdiskreads), (cffs_diskwrites - startdiskwrites), tmpval, ((double) FILE_SIZE / (double) MB / tmpval)); ret = unlink (name); assert (ret == 0); #ifdef EXOPC if (iterno == 1) { cffs_softupdates = 0; cffs_embedinodes = 0; cffs_usegrouping = 0; iterno++; printf ("\n"); goto main_repeat; } #endif exit (0); }
the_stack_data/156392317.c
// To implement union opertaions on sets #include <stdio.h> struct sets { int value; struct sets * next; }; typedef struct sets list; typedef list*listptr; void insert(listptr*sptr,int e) { listptr newptr; listptr previousptr; listptr currentptr; newptr=malloc(sizeof(struct sets)); if(newptr!=NULL) { newptr->value=e; newptr->next=NULL; previousptr=NULL; currentptr=*sptr; while(currentptr!=NULL) { previousptr=currentptr; currentptr=currentptr->next; } if(previousptr==NULL) { newptr->next=NULL; *sptr=newptr; } else { previousptr->next=newptr; newptr->next=NULL; } } } void print(listptr currentptr) { while(currentptr!=NULL) { printf("%d",currentptr->value); currentptr=currentptr->next; } } void uni(listptr cstr1, listptr cstr2) { listptr startptr=NULL; listptr newptr = NULL; listptr ctr = cstr1; while(ctr != NULL) { insert(&startptr,ctr->value); ctr = ctr->next; } ctr = cstr2; listptr cctr=cstr1; while(ctr != NULL) { while(cctr != NULL) { if(cctr->value == ctr->value) {break;} cctr=cctr->next; } if(cctr==NULL) insert(&startptr,ctr->value); cctr=cstr1; ctr=ctr->next; } print(startptr); } int main() { listptr startptr1= NULL; listptr startptr2= NULL; char op='y'; int ch; int e; while(op=='y') { printf("\nMenu:\n1.Insert s1\n2.Insert s2\n3.print\n4.union\n5.exit\n"); printf("Enter option:"); scanf("%d",&ch); switch(ch) { case 1:{printf("Value?");scanf("%d",&e);insert(&startptr1,e);break;} case 2:{printf("Value?");scanf("%d",&e);insert(&startptr2,e);break;} case 3:{print(startptr1);print(startptr2);break;} case 4:{uni(startptr1,startptr2);break;} default:{return(0);} } } return 0; }
the_stack_data/179830696.c
/* * Program Argument is the game list for lr-fbalpha. Nur Spiele, die sich auf diese Liste befinden * werden in die games.conf für lemonlauncher übernommen * * Ausgabe ist die Datei games.conf_part * Ausgabe für ADVMAME ist die Datei advmame_games.conf * * Funktionsweise * Alle Verzeichnisse unter dem Verzeichnis roms werden durchgegangen und alle Dateien als Spiele angenommen * * Beispiel roms/advmame/dkong.zip * * Dann ist der Emulator advmame und das rom dkong.zip * * Die roms werden in Semikolons eingepackt, damit im autostart die roms besser vom emulator im ll_result.txt getrennt werden können * * Die Titel werden gleich dem Rom Namen gesetzt. Das ist für die Konsolen Emulatoren in Ordnung. * * Für die Arcade Emulatoren aber nicht. Für lr-fbalpha wird an Hand der Datei lr-fbalpha.csv die Titel über die rom Namen gesucht. * Die csv Datei wird in ein Array gepackt. * * Beispiel: Rom Name dkong.zip gefunden: * * Dann wird im Array über dkong.zip der Titel Donkey Kong gefunden. * * Leere Folder werden nicht mehr in games.conf übernommen. * * Vor dem Release für Linux muss der Zeilenende Trenner von \n auf \r gesetzt werden. Suche nach Linux * * * Beispiel Ausführung * * gamelister lr_fbalpha.csv advmame.csv roms/ * * TODO * * - Filter für Cabs : H, V, Anzahl Buttons, Anzahl Sticks etc * * */ #include <sys/types.h> #include <dirent.h> #include <string.h> #include <stdio.h> #include <stdlib.h> #include <stddef.h> //diff between console and arcade because vertical screen FILE *console_games; FILE *arcade_games; //FILE *not_found; int system(const char *command); struct dirent *dirzeiger; char fba_csv[255] = "\0"; char mame_csv[255] = "\0"; struct game { char rom[255]; char title[255]; char orient[255]; }; struct game gListMame[5080]; struct game gListFBA[4400]; int maxFba = 0; int maxMame = 0; int main(int argc, char **argv) { DIR *dir; char strRomDir[255] = "\0"; char strRomDirM4all [255] = "\0"; char strRomDirPiFBA[255] = "\0"; //printf("Filterdatei fuer lr-fbalpha : %s\n", argv[1]); strcpy(fba_csv, argv[1]); strcpy(mame_csv, argv[2]); strcpy(strRomDir, argv[3]); //strcat(strRomDir, "\\roms\\"); //Linux strcat(strRomDir, "/roms/"); console_games = fopen ("console_games.conf", "w"); arcade_games = fopen ("arcade_games.conf", "w"); //not_found = fopen ("not_found.txt", "w"); //baue Array für die Suche nach Titel //Sonderbehandlung m4all //Sonderbehandlung piFBA maxMame = buildGameFilterArray (mame_csv, gListMame); maxFba = buildGameFilterArray (fba_csv, gListFBA); if((dir=opendir(strRomDir)) == NULL) { printf("\nFehler beim oeffnen des Verzeichnisses: %s " , strRomDir); return 1; } else { //printf("\nVerzeichnis : %s " , strRomDir); //readdir(dir); //readdir(dir); while((dirzeiger=readdir(dir)) != NULL) { readGames(strRomDir, dirzeiger->d_name); } } closedir(dir); fclose (console_games); fclose (arcade_games); //fclose (not_found); return 0; } int buildGameFilterArray(char game_list[], struct game gList[]) { int i=0; int max_fba_games=0; char title_fba[255] = "\0"; char rom_fba[255] = "\0"; char orient_fba[255] = "\0"; char *ptr; FILE *fGamelist; fGamelist=fopen(game_list, "r"); char puffer[255]; if(NULL == fGamelist) { fprintf(stderr, "Fehler beim Oeffnen ...\n"); return 0; } while(fgets(puffer,255,fGamelist)) { if(strrchr(puffer, ';') != 0) { //Zeilenumbruch raus //printf("\npuffer %s", puffer); //ptr = strrchr(puffer, '\r'); //Use N for win ptr = strrchr(puffer, '\n'); *ptr = '\0'; //Orientation ptr = strrchr(puffer, ';')+1; strcpy(orient_fba,ptr); //printf("Orient: *%s*\n", orient_fba); //Titel Name //; raus aus Titel //suche position vom ; und gehe auf das nächste Zeichen über Pointer ptr = strchr(puffer, ';')+1; strcpy(title_fba,ptr); ptr = strchr(title_fba, ';'); *ptr = '\0'; //printf("Titel : *%s*\n", title_fba); //Rom Name // Suche ; als Ende des Puffers und schneide ab // und kopiere den Puffer vom Anfang bis zum ; ptr = strchr(puffer, ';'); *ptr = '\0'; strcpy(rom_fba,puffer); //printf("\nRom : *%s*\n", rom_fba); //baue array strcpy(gList[i].rom, rom_fba); strcpy(gList[i].title, title_fba); strcpy(gList[i].orient, orient_fba); //if (strcmp("donpachi", rom_fba) == 0) //{ // printf("\nRom : *%s*\n", &gList[i].rom); // printf("Titel : *%s*\n", &gList[i].title); // printf("Orient: *%s*\n", &gList[i].orient); //} // getchar(); i++; } } max_fba_games = i - 1; //printf("\n%d Spiele gefunden.\n", max_fba_games); //printf("Letzter Titel : *%s*\n", &gList[max_fba_games].title); return max_fba_games; } int writeGameUseFilter (char strSubDir[], char title[], int max_games, struct game gList[]) { int i=0; char rom[255] = "\0"; //printf("Titel : *%s*\n", title); while(i <= max_games ) { // falls in Liste, dann in die games.conf übernehmen // title und rom Vergleich, da title die Dateiendung nicht enthält if (strcmp(title, gList[i].rom) == 0) { fprintf (arcade_games, "\ngame { rom = \"%s" , gList[i].rom); fprintf (arcade_games, "\" title = \"%s" , gList[i].title); fprintf (arcade_games, "\" params = \";%s\" ", strSubDir); if (strcmp("a", gList[i].orient) == 0) fprintf (arcade_games, "orientation = %s", gList[i].orient); fprintf (arcade_games, "}", strSubDir); //printf("Titel_FOUND : *%s*\n", gList[i].title); return; } else { //game not found } i++; } //fprintf (not_found, "\n %s" , title); //printf("Titel_NOT_FOUND : *%s*\n", title); } //returns 0 if not int EndsWith(const char *str, const char *suffix) { if (!str || !suffix) return 0; size_t lenstr = strlen(str); size_t lensuffix = strlen(suffix); if (lensuffix > lenstr) return 0; return strncmp(str + lenstr - lensuffix, suffix, lensuffix) == 0; } int readGames(char strRomDir[], char strSubDir[]) { if (strcmp(strSubDir, ".") == 0 || strcmp(strSubDir, "..") == 0 ) { //printf(" dont process . or .."); } else { DIR *dir; char title[255] = "\0"; char rom[255] = "\0"; char *ptr; char path[255] = "\0"; //printf("\nstrRomDir: %s", strRomDir); //printf("\nstrSubDir: %s", strSubDir); strcat(path, strRomDir); strcat(path,strSubDir); //printf("\npath: %s", path); int max_games=0; int boolShowMenu=0; // Baue games.conf_part // hier werden die Rom Listen gebaut if((dir=opendir(path)) == NULL) { printf("\n1: Fehler beim Oeffnen des SubVerzeichnisses: %s " , path); return 1; } else { //printf("\nOeffnen des Verzeichnisses: %s", path); //. und .. überlesen //readdir(dir); //readdir(dir); if (strcmp(strSubDir, ".") == 0 || strcmp(strSubDir, "..") == 0 ) { //printf(" dont process . or .."); } else { // komplettes Verzeichnis Eintrag fuer Eintrag auslesen while((dirzeiger=readdir(dir)) != NULL) { //Spielsystem nur aufführen, wenn mind. ein Spiel vorhanden ist. //Alle Spiele schreiben strcpy(rom,(*dirzeiger).d_name); strcpy(title,(*dirzeiger).d_name); //Falls Ende rom nirgendwas mit state oder so ist, dann ist es // eine temporär angelegte Datei und kein Spiel if (EndsWith(rom, ".state") == 0) { //Dateiendung aus Titel raus if(strrchr(title, '.') != 0) { ptr = strrchr(title, '.'); *ptr = '\0'; } // Es sollen nur die lf-fbalpha Spiele aus der Liste angezeigt werden. // Sonst alle. if (strcmp(strSubDir, "lr-fbalpha") == 0 || strcmp(strSubDir, "neogeo") == 0 || strcmp(strSubDir, "pifba") == 0 ) { if (boolShowMenu==0) { boolShowMenu = 1; fprintf (arcade_games, "\nmenu \"%s\" {" , strSubDir); } writeGameUseFilter(strSubDir, title, maxFba, gListFBA); } else if (strcmp(strSubDir, "advmame") == 0 || strcmp(strSubDir, "mame2003") == 0 || strcmp(strSubDir, "neogeo") == 0 || strcmp(strSubDir, "arcade") == 0 || strcmp(strSubDir, "mame2003plus") == 0 || strcmp(strSubDir, "m4all") == 0 || strcmp(strSubDir, "mame2010") == 0 || strcmp(strSubDir, "mame2000") == 0 || strcmp(strSubDir, "lr-fbalpha") == 0 || strcmp(strSubDir, "pifba") == 0 ) { if (boolShowMenu==0) { boolShowMenu = 1; fprintf (arcade_games, "\nmenu \"%s\" {" , strSubDir); } writeGameUseFilter(strSubDir, title, maxMame, gListMame); } else { //die Semikolons sind eine Hilfe für das Autostart.sh Skript if (boolShowMenu==0) { boolShowMenu = 1; //printf ("\nmenu %s", strSubDir); fprintf (console_games, "\nmenu \"%s\" {" , strSubDir); } if (strcmp(rom, ".") == 0 || strcmp(rom, "..") == 0 ) { //again dont proess . or .. } else { fprintf (console_games, "\ngame { rom = \"%s" , rom); fprintf (console_games, "\" title = \"%s" , title); fprintf (console_games, "\" params = \";%s\" }", strSubDir); } } } }} if (boolShowMenu == 1) { //es wurde mind. 1 Spiel gefunden, also ein Systemmenü geschrieben //Klammer zu if (strcmp(strSubDir, "advmame") == 0 || strcmp(strSubDir, "mame2003") == 0 || strcmp(strSubDir, "arcade") == 0 || strcmp(strSubDir, "neogeo") == 0 || strcmp(strSubDir, "mame2003plus") == 0 || strcmp(strSubDir, "m4all") == 0 || strcmp(strSubDir, "mame2010") == 0 || strcmp(strSubDir, "mame2000") == 0 || strcmp(strSubDir, "lr-fbalpha") == 0 || strcmp(strSubDir, "pifba") == 0 ) { fprintf (arcade_games, "\n}"); } else { fprintf (console_games, "\n}"); //printf ("\nmenu close %s", strSubDir); } } boolShowMenu = 0; } return 0; } }
the_stack_data/673569.c
#include <stdio.h> int main() { int s,t,f,x; scanf("%d%d%d",&s,&t,&f); x=s+t+f; if(x<0) { x+=24; } printf("%d\n",x%24); return 0; }
the_stack_data/53095.c
#include <stdio.h> #include <stdlib.h> #include <sys/time.h> #include <stdint.h> #define NNN 2048 void copyij(); void copyji(); void init_mat(); double time_diff(); int src[NNN][NNN], dst[NNN][NNN]; int main(int argc,char **argv) { double elapsed_time; struct timeval tv_s,tv_e; init_mat(); gettimeofday(&tv_s, NULL); copyij(); gettimeofday(&tv_e, NULL); /* fill here to compute elapsed time */ elapsed_time = time_diff(tv_s, tv_e); printf("copyji(): dim=%d: elapsed=%03f secs\n",NNN, elapsed_time); init_mat(); gettimeofday(&tv_s, NULL); copyji(); gettimeofday(&tv_e, NULL); elapsed_time = time_diff(tv_s, tv_e); /* fill here to compute elapsed time */ printf("copyji(): dim=%d: elapsed=%03f secs\n",NNN, elapsed_time); return 0; } void copyij(){ int i,j; for (int i = 0; i < NNN; i++) { for (int j = 0; j < NNN; j++) { dst[i][j] = src[i][j]; } } } void copyji(){ int i,j; for (int j = 0; j < NNN; j++) { for (int i = 0; i < NNN; i++) { dst[i][j] = src[i][j]; } } } void init_mat(){ int i,j; for (i=0;i<NNN;i++) for (j=0;j<NNN;j++) src[i][j] = dst[i][j] = 1; } double time_diff(struct timeval start, struct timeval end) { double elapsed_time = end.tv_sec - start.tv_sec + (end.tv_usec - start.tv_usec) * 1e-6; return elapsed_time; }
the_stack_data/981405.c
#define _GNU_SOURCE #include <dirent.h> #include <endian.h> #include <errno.h> #include <fcntl.h> #include <signal.h> #include <stdarg.h> #include <stdbool.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/ioctl.h> #include <sys/mount.h> #include <sys/prctl.h> #include <sys/stat.h> #include <sys/syscall.h> #include <sys/types.h> #include <sys/wait.h> #include <time.h> #include <unistd.h> static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static bool write_file(const char* file, const char* what, ...) { char buf[1024]; va_list args; va_start(args, what); vsnprintf(buf, sizeof(buf), what, args); va_end(args); buf[sizeof(buf) - 1] = 0; int len = strlen(buf); int fd = open(file, O_WRONLY | O_CLOEXEC); if (fd == -1) return false; if (write(fd, buf, len) != len) { int err = errno; close(fd); errno = err; return false; } close(fd); return true; } #define FS_IOC_SETFLAGS _IOW('f', 2, long) static void remove_dir(const char* dir) { int iter = 0; DIR* dp = 0; retry: while (umount2(dir, MNT_DETACH) == 0) { } dp = opendir(dir); if (dp == NULL) { if (errno == EMFILE) { exit(1); } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); while (umount2(filename, MNT_DETACH) == 0) { } struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } int i; for (i = 0;; i++) { if (unlink(filename) == 0) break; if (errno == EPERM) { int fd = open(filename, O_RDONLY); if (fd != -1) { long flags = 0; if (ioctl(fd, FS_IOC_SETFLAGS, &flags) == 0) { } close(fd); continue; } } if (errno == EROFS) { break; } if (errno != EBUSY || i > 100) exit(1); if (umount2(filename, MNT_DETACH)) exit(1); } } closedir(dp); for (int i = 0;; i++) { if (rmdir(dir) == 0) break; if (i < 100) { if (errno == EPERM) { int fd = open(dir, O_RDONLY); if (fd != -1) { long flags = 0; if (ioctl(fd, FS_IOC_SETFLAGS, &flags) == 0) { } close(fd); continue; } } if (errno == EROFS) { break; } if (errno == EBUSY) { if (umount2(dir, MNT_DETACH)) exit(1); continue; } if (errno == ENOTEMPTY) { if (iter < 100) { iter++; goto retry; } } } exit(1); } } static int inject_fault(int nth) { int fd; fd = open("/proc/thread-self/fail-nth", O_RDWR); if (fd == -1) exit(1); char buf[16]; sprintf(buf, "%d", nth + 1); if (write(fd, buf, strlen(buf)) != (ssize_t)strlen(buf)) exit(1); return fd; } static void kill_and_wait(int pid, int* status) { kill(-pid, SIGKILL); kill(pid, SIGKILL); for (int i = 0; i < 100; i++) { if (waitpid(-1, status, WNOHANG | __WALL) == pid) return; usleep(1000); } DIR* dir = opendir("/sys/fs/fuse/connections"); if (dir) { for (;;) { struct dirent* ent = readdir(dir); if (!ent) break; if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0) continue; char abort[300]; snprintf(abort, sizeof(abort), "/sys/fs/fuse/connections/%s/abort", ent->d_name); int fd = open(abort, O_WRONLY); if (fd == -1) { continue; } if (write(fd, abort, 1) < 0) { } close(fd); } closedir(dir); } else { } while (waitpid(-1, status, __WALL) != pid) { } } static void setup_test() { prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); setpgrp(); write_file("/proc/self/oom_score_adj", "1000"); } static void setup_fault() { static struct { const char* file; const char* val; bool fatal; } files[] = { {"/sys/kernel/debug/failslab/ignore-gfp-wait", "N", true}, {"/sys/kernel/debug/fail_futex/ignore-private", "N", false}, {"/sys/kernel/debug/fail_page_alloc/ignore-gfp-highmem", "N", false}, {"/sys/kernel/debug/fail_page_alloc/ignore-gfp-wait", "N", false}, {"/sys/kernel/debug/fail_page_alloc/min-order", "0", false}, }; unsigned i; for (i = 0; i < sizeof(files) / sizeof(files[0]); i++) { if (!write_file(files[i].file, files[i].val)) { if (files[i].fatal) exit(1); } } } static void execute_one(void); #define WAIT_FLAGS __WALL static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); setup_test(); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5000) { continue; } kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[2] = {0xffffffffffffffff, 0xffffffffffffffff}; void execute_one(void) { intptr_t res = 0; memcpy((void*)0x20000740, "/dev/kvm\000", 9); res = syscall(__NR_openat, 0xffffffffffffff9cul, 0x20000740ul, 0x481001a000001409ul, 0ul); if (res != -1) r[0] = res; res = syscall(__NR_ioctl, r[0], 0xae01, 0ul); if (res != -1) r[1] = res; *(uint64_t*)0x20000240 = 0; *(uint32_t*)0x20000248 = 0x8000; *(uint32_t*)0x2000024c = 0; syscall(__NR_ioctl, r[1], 0x4010ae67, 0x20000240ul); *(uint64_t*)0x20000040 = 0; *(uint32_t*)0x20000048 = 0x3000; *(uint32_t*)0x2000004c = 0; syscall(__NR_ioctl, r[1], 0x4010ae67, 0x20000040ul); *(uint64_t*)0x20000380 = 0; *(uint32_t*)0x20000388 = 0x4000; *(uint32_t*)0x2000038c = 0; inject_fault(3); syscall(__NR_ioctl, r[1], 0x4010ae68, 0x20000380ul); } int main(void) { syscall(__NR_mmap, 0x1ffff000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul); syscall(__NR_mmap, 0x20000000ul, 0x1000000ul, 7ul, 0x32ul, -1, 0ul); syscall(__NR_mmap, 0x21000000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul); setup_fault(); use_temporary_dir(); loop(); return 0; }
the_stack_data/114820.c
/* This file is part of The Firekylin Operating System. * * Copyright 2016 Liuxiaofeng * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <string.h> int strncmp(const char *s1, const char *s2, size_t n) { char *ts1=(char *)s1; char *ts2=(char *)s2; while (n--) { if (*ts1 && (*ts1 == *ts2)) { ts1++; ts2++; } else { return (*ts1 - *ts2); } } return 0; }
the_stack_data/94295.c
/* ----------------------------------------------------------------------------- * * (c) The GHC Team, 2001,2019 * Author: Sungwoo Park, Daniel Gröber * * Generalised profiling heap traversal. * * ---------------------------------------------------------------------------*/ #if defined(PROFILING) #include <string.h> #include "PosixSource.h" #include "Rts.h" #include "sm/Storage.h" #include "TraverseHeap.h" const stackData nullStackData; StgWord getTravData(const StgClosure *c) { const StgWord hp_hdr = c->header.prof.hp.trav; return hp_hdr & (STG_WORD_MAX ^ 1); } void setTravData(const traverseState *ts, StgClosure *c, StgWord w) { c->header.prof.hp.trav = w | ts->flip; } bool isTravDataValid(const traverseState *ts, const StgClosure *c) { return (c->header.prof.hp.trav & 1) == ts->flip; } #if defined(DEBUG) unsigned int g_traversalDebugLevel = 0; static void debug(const char *s, ...) { va_list ap; if(g_traversalDebugLevel == 0) return; va_start(ap,s); vdebugBelch(s, ap); va_end(ap); } #else #define debug(...) #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( traverseState *ts, bdescr *bd ) { ts->currentStack = bd; ts->stackTop = (stackElement *)(bd->start + BLOCK_SIZE_W * bd->blocks); ts->stackBottom = (stackElement *)bd->start; ts->stackLimit = (stackElement *)ts->stackTop; bd->free = (StgPtr)ts->stackLimit; } /* ----------------------------------------------------------------------------- * Return to the previous block group. * Invariants: * s->link == currentStack. * -------------------------------------------------------------------------- */ STATIC_INLINE void returnToOldStack( traverseState *ts, bdescr *bd ) { ts->currentStack = bd; ts->stackTop = (stackElement *)bd->free; ts->stackBottom = (stackElement *)bd->start; ts->stackLimit = (stackElement *)(bd->start + BLOCK_SIZE_W * bd->blocks); bd->free = (StgPtr)ts->stackLimit; } /** * Initializes the traversal work-stack. */ void initializeTraverseStack( traverseState *ts ) { if (ts->firstStack != NULL) { freeChain(ts->firstStack); } ts->firstStack = allocGroup(BLOCKS_IN_STACK); ts->firstStack->link = NULL; ts->firstStack->u.back = NULL; ts->stackSize = 0; ts->maxStackSize = 0; newStackBlock(ts, ts->firstStack); } /** * Frees all the block groups in the traversal works-stack. * * Invariants: * firstStack != NULL */ void closeTraverseStack( traverseState *ts ) { freeChain(ts->firstStack); ts->firstStack = NULL; } /** * Returns the largest stack size encountered during the traversal. */ int getTraverseStackMaxSize(traverseState *ts) { return ts->maxStackSize; } /** * Returns true if the whole stack is empty. **/ STATIC_INLINE bool isEmptyWorkStack( traverseState *ts ) { return (ts->firstStack == ts->currentStack) && ts->stackTop == ts->stackLimit; } /** * Returns size of stack */ W_ traverseWorkStackBlocks(traverseState *ts) { bdescr* bd; W_ res = 0; for (bd = ts->firstStack; bd != NULL; bd = bd->link) res += bd->blocks; return res; } /** * Initializes *info from ptrs and payload. * * Invariants: * * payload[] begins with ptrs pointers followed by non-pointers. */ STATIC_INLINE void init_ptrs( stackPos *info, uint32_t 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, const StgFunInfoTable *infoTable ) { info->type = posTypeSRT; if (infoTable->i.srt) { info->next.srt.srt = (StgClosure*)GET_FUN_SRT(infoTable); } else { info->next.srt.srt = NULL; } } STATIC_INLINE void init_srt_thunk( stackPos *info, const StgThunkInfoTable *infoTable ) { info->type = posTypeSRT; if (infoTable->i.srt) { info->next.srt.srt = (StgClosure*)GET_SRT(infoTable); } else { info->next.srt.srt = NULL; } } /** * Find the next object from *info. */ STATIC_INLINE StgClosure * find_srt( stackPos *info ) { StgClosure *c; if (info->type == posTypeSRT) { c = info->next.srt.srt; info->next.srt.srt = NULL; return c; } return NULL; } /** * Push a set of closures, represented by a single 'stackElement', onto the * traversal work-stack. */ static stackElement* pushStackElement(traverseState *ts, const stackElement se) { bdescr *nbd; // Next Block Descriptor if (ts->stackTop - 1 < ts->stackBottom) { debug("pushStackElement() to the next stack.\n"); // currentStack->free is updated when the active stack is switched // to the next stack. ts->currentStack->free = (StgPtr)ts->stackTop; if (ts->currentStack->link == NULL) { nbd = allocGroup(BLOCKS_IN_STACK); nbd->link = NULL; nbd->u.back = ts->currentStack; ts->currentStack->link = nbd; } else nbd = ts->currentStack->link; newStackBlock(ts, nbd); } // adjust stackTop (actual push) ts->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. *ts->stackTop = se; ts->stackSize++; if (ts->stackSize > ts->maxStackSize) ts->maxStackSize = ts->stackSize; ASSERT(ts->stackSize >= 0); debug("stackSize = %d\n", ts->stackSize); return ts->stackTop; } /** * Push a single closure onto the traversal work-stack. * * cp - object's parent * c - closure * data - data associated with closure. */ inline void traversePushClosure(traverseState *ts, StgClosure *c, StgClosure *cp, stackElement *sep, stackData data) { stackElement se; se.c = c; se.info.next.cp = cp; se.sep = sep; se.data = data; se.accum = (stackAccum)(StgWord)0; se.info.type = posTypeFresh; pushStackElement(ts, se); }; void traversePushRoot(traverseState *ts, StgClosure *c, StgClosure *cp, stackData data) { traversePushClosure(ts, c, cp, NULL, data); }; /** * Push an empty stackElement onto the traversal work-stack for the sole purpose * of triggering the return callback 'traversalState.return_cb' for the closure * '*c' when traversing of it's children is complete. * * This is needed for code-paths which don't inherently have to push a * stackElement. c.f. traverseWorkStack. * * When return_cb is NULL this function does nothing. */ STATIC_INLINE stackElement * traversePushReturn(traverseState *ts, StgClosure *c, stackAccum acc, stackElement *sep) { if(!ts->return_cb) return sep; stackElement se; se.c = c; se.info.next.cp = NULL; se.accum = acc; se.sep = sep; memset(&se.data, 0, sizeof(se.data)); // return frames never emit closures, traversePop just skips over them. So // the data field is simply never used. se.info.type = posTypeEmpty; return pushStackElement(ts, se); }; /** * traverseGetChildren() extracts the first child of 'c' in 'first_child' and if * 'other_children' is true returns a stackElement in 'se' which * conceptually contains all remaining children of 'c'. * * If 'c' has no children, 'first_child' is set to NULL, other_children is set * to false and nothing is returned in 'se'. * * If 'c' has only one child, 'first_child' is set to that child, other_children * is set to false and nothing is returned in 'se'. * * Otherwise 'other_children' is set to true and a stackElement representing the * other children is returned in 'se'. * * Note that when 'se' is set only the fields fields 'se.c' and 'se.info' * are initialized. It is the caller's responsibility to initialize the rest. * * Invariants: * * - '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 traverseGetChildren(StgClosure *c, StgClosure **first_child, bool *other_children, stackElement *se) { ASSERT(get_itbl(c)->type != TSO); ASSERT(get_itbl(c)->type != AP_STACK); // // fill in se // se->c = c; *other_children = false; // fill in se->info switch (get_itbl(c)->type) { // no child, no SRT case CONSTR_0_1: case CONSTR_0_2: case ARR_WORDS: case COMPACT_NFDATA: *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 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 CONSTR_NOCAF: case PRIM: case MUT_PRIM: case BCO: 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_CLEAN: case MUT_ARR_PTRS_FROZEN_DIRTY: 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_CLEAN: case SMALL_MUT_ARR_PTRS_FROZEN_DIRTY: 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_STATIC: 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_0_1: // *c is a heap object. 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 != 0); /* fall-thru */ 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.type = posTypeStep; se->info.next.step = 0; // entry no. break; // cannot appear case PAP: case AP: case AP_STACK: case TSO: case STACK: case IND_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(): %d", get_itbl(c)->type); return; } // se->info.next.cp has to be initialized when type==posTypeFresh. We don't // do that here though. So type must be !=posTypeFresh. ASSERT(se->info.type != posTypeFresh); *other_children = true; } STATIC_INLINE void popStackElement(traverseState *ts) { debug("popStackElement(): stackTop = 0x%x\n", ts->stackTop); ASSERT(ts->stackTop != ts->stackLimit); ASSERT(!isEmptyWorkStack(ts)); // <= (instead of <) is wrong! if (ts->stackTop + 1 < ts->stackLimit) { ts->stackTop++; ts->stackSize--; if (ts->stackSize > ts->maxStackSize) ts->maxStackSize = ts->stackSize; ASSERT(ts->stackSize >= 0); debug("stackSize = (--) %d\n", ts->stackSize); return; } bdescr *pbd; // Previous Block Descriptor debug("popStackElement() to the previous stack.\n"); ASSERT(ts->stackTop + 1 == ts->stackLimit); ASSERT(ts->stackBottom == (stackElement *)ts->currentStack->start); if (ts->firstStack == ts->currentStack) { // The stack is completely empty. ts->stackTop++; ASSERT(ts->stackTop == ts->stackLimit); ts->stackSize--; if (ts->stackSize > ts->maxStackSize) ts->maxStackSize = ts->stackSize; ASSERT(ts->stackSize >= 0); debug("stackSize = %d\n", ts->stackSize); return; } // currentStack->free is updated when the active stack is switched back // to the previous stack. ts->currentStack->free = (StgPtr)ts->stackLimit; // find the previous block descriptor pbd = ts->currentStack->u.back; ASSERT(pbd != NULL); returnToOldStack(ts, pbd); ts->stackSize--; if (ts->stackSize > ts->maxStackSize) ts->maxStackSize = ts->stackSize; ASSERT(ts->stackSize >= 0); debug("stackSize = %d\n", ts->stackSize); } /** * callReturnAndPopStackElement(): Call 'traversalState.return_cb' and remove a * depleted stackElement from the top of the traversal work-stack. * * Invariants: * stackTop cannot be equal to stackLimit unless the whole stack is * empty, in which case popStackElement() is not allowed. */ static void callReturnAndPopStackElement(traverseState *ts) { stackElement *se = ts->stackTop; if(ts->return_cb) ts->return_cb(se->c, se->accum, se->sep->c, &se->sep->accum); popStackElement(ts); } /** * Finds the next object to be considered for retainer profiling and store * its pointer to *c. * * If the unprocessed object was stored in the stack (posTypeFresh), the * this object is returned as-is. Otherwise Test if the topmost stack * element indicates that more objects are left, * and if so, retrieve the next object and store its pointer to *c. Also, * set *cp and *data appropriately, both of which are stored in the stack * element. The topmost stack element is then overwritten so it denotes 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 work-stack becomes empty, indicated by true returned by * isEmptyWorkStack(), in which case *c is set to NULL. * * Note: * * It is okay to call this function even when the work-stack is empty. */ STATIC_INLINE void traversePop(traverseState *ts, StgClosure **c, StgClosure **cp, stackData *data, stackElement **sep) { stackElement *se; debug("traversePop(): stackTop = 0x%x\n", ts->stackTop); // Is this the last internal sub-element? bool last = false; *c = NULL; do { if (isEmptyWorkStack(ts)) { *c = NULL; return; } // Note: Below every `break`, where the loop condition is true, must be // accompanied by a popStackElement()/callReturnAndPopStackElement() // call otherwise this is an infinite loop. se = ts->stackTop; *sep = se->sep; // If this is a top-level element, you should pop that out. if (se->info.type == posTypeFresh) { *cp = se->info.next.cp; *c = se->c; *data = se->data; popStackElement(ts); return; } else if (se->info.type == posTypeEmpty) { callReturnAndPopStackElement(ts); continue; } // Note: The first ptr of all of these was already returned as // *fist_child in push(), so we always start with the second field. switch (get_itbl(se->c)->type) { // two children (fixed), no SRT // nothing in se.info case CONSTR_2_0: *c = se->c->payload[1]; last = true; goto out; // 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 popStackElement } else { *c = ((StgMVar *)se->c)->value; last = true; } goto out; // three children (fixed), no SRT case WEAK: if (se->info.next.step == 2) { *c = ((StgWeak *)se->c)->value; se->info.next.step++; // no popStackElement } else { *c = ((StgWeak *)se->c)->finalizer; last = true; } goto out; 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; StgWord step = se->info.next.step; uint32_t entry_no = step >> 2; uint32_t field_no = step & 3; 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; } se->info.next.step = ++step; entry_no = step >> 2; if (entry_no == ((StgTRecChunk *)se->c)->next_entry_idx) { se->info.type = posTypeEmpty; continue; } goto out; } case TVAR: case CONSTR: case PRIM: case MUT_PRIM: case BCO: // StgMutArrPtr.ptrs, no SRT case MUT_ARR_PTRS_CLEAN: case MUT_ARR_PTRS_DIRTY: case MUT_ARR_PTRS_FROZEN_CLEAN: case MUT_ARR_PTRS_FROZEN_DIRTY: case SMALL_MUT_ARR_PTRS_CLEAN: case SMALL_MUT_ARR_PTRS_DIRTY: case SMALL_MUT_ARR_PTRS_FROZEN_CLEAN: case SMALL_MUT_ARR_PTRS_FROZEN_DIRTY: *c = find_ptrs(&se->info); if (*c == NULL) { se->info.type = posTypeEmpty; continue; } goto out; // layout.payload.ptrs, SRT case FUN: // always a heap object case FUN_STATIC: case FUN_2_0: if (se->info.type == posTypePtrs) { *c = find_ptrs(&se->info); if (*c != NULL) { goto out; } 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) { goto out; } init_srt_thunk(&se->info, get_thunk_itbl(se->c)); } goto do_srt; // SRT do_srt: case THUNK_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) { se->info.type = posTypeEmpty; continue; } goto out; // 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 CONSTR_1_1: // cannot appear case PAP: case AP: case AP_STACK: case TSO: case STACK: case IND_STATIC: case CONSTR_NOCAF: // 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 traversePop(): %d", get_itbl(se->c)->type); return; } } while (*c == NULL); out: ASSERT(*c != NULL); *cp = se->c; *data = se->data; *sep = se; if(last && ts->return_cb) se->info.type = posTypeEmpty; else if(last) popStackElement(ts); return; } /** * Make sure a closure's profiling data is initialized to zero if it does not * conform to the current value of the flip bit, returns true in this case. * * See Note [Profiling heap traversal visited bit]. */ bool traverseMaybeInitClosureData(const traverseState* ts, StgClosure *c) { if (!isTravDataValid(ts, c)) { setTravData(ts, c, 0); return true; } return false; } /** * Call traversePushClosure for each of the closures covered by a large bitmap. */ static void traverseLargeBitmap(traverseState *ts, StgPtr p, StgLargeBitmap *large_bitmap, uint32_t size, StgClosure *c, stackElement *sep, stackData data) { uint32_t i, b; StgWord bitmap; b = 0; bitmap = large_bitmap->bitmap[b]; for (i = 0; i < size; ) { if ((bitmap & 1) == 0) { traversePushClosure(ts, (StgClosure *)*p, c, sep, data); } i++; p++; if (i % BITS_IN(W_) == 0) { b++; bitmap = large_bitmap->bitmap[b]; } else { bitmap = bitmap >> 1; } } } STATIC_INLINE StgPtr traverseSmallBitmap (traverseState *ts, StgPtr p, uint32_t size, StgWord bitmap, StgClosure *c, stackElement *sep, stackData data) { while (size > 0) { if ((bitmap & 1) == 0) { traversePushClosure(ts, (StgClosure *)*p, c, sep, data); } p++; bitmap = bitmap >> 1; size--; } return p; } /** * traversePushStack(ts, cp, data, stackStart, stackEnd) pushes all the objects * in the STG stack-chunk from stackStart to stackEnd onto the traversal * work-stack with 'c' and 'data' being their parent and associated data, * respectively. * * Invariants: * * *cp is one of the following: TSO, AP_STACK. * * stackStart < stackEnd. * * 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, * traversePushClosure() is invoked instead of evacuate(). */ static void traversePushStack(traverseState *ts, StgClosure *cp, stackElement *sep, stackData data, StgPtr stackStart, StgPtr stackEnd) { StgPtr p; const StgRetInfoTable *info; StgWord bitmap; uint32_t size; ASSERT(get_itbl(cp)->type == STACK); p = stackStart; while (p < stackEnd) { info = get_ret_itbl((StgClosure *)p); switch(info->i.type) { case UPDATE_FRAME: traversePushClosure(ts, ((StgUpdateFrame *)p)->updatee, cp, sep, data); 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 = traverseSmallBitmap(ts, p, size, bitmap, cp, sep, data); follow_srt: if (info->i.srt) { traversePushClosure(ts, GET_SRT(info), cp, sep, data); } continue; case RET_BCO: { StgBCO *bco; p++; traversePushClosure(ts, (StgClosure*)*p, cp, sep, data); bco = (StgBCO *)*p; p++; size = BCO_BITMAP_SIZE(bco); traverseLargeBitmap(ts, p, BCO_BITMAP(bco), size, cp, sep, data); 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++; traverseLargeBitmap(ts, p, GET_LARGE_BITMAP(&info->i), size, cp, sep, data); p += size; // and don't forget to follow the SRT goto follow_srt; case RET_FUN: { StgRetFun *ret_fun = (StgRetFun *)p; const StgFunInfoTable *fun_info; traversePushClosure(ts, ret_fun->fun, cp, sep, data); fun_info = get_fun_itbl(UNTAG_CONST_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 = traverseSmallBitmap(ts, p, size, bitmap, cp, sep, data); break; case ARG_GEN_BIG: size = GET_FUN_LARGE_BITMAP(fun_info)->size; traverseLargeBitmap(ts, p, GET_FUN_LARGE_BITMAP(fun_info), size, cp, sep, data); 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 = traverseSmallBitmap(ts, p, size, bitmap, cp, sep, data); break; } goto follow_srt; } default: barf("Invalid object found in traversePushStack(): %d", (int)(info->i.type)); } } } /** * Call traversePushClosure for each of the children of a PAP/AP */ STATIC_INLINE StgPtr traversePAP (traverseState *ts, StgClosure *pap, /* NOT tagged */ stackElement *sep, stackData data, StgClosure *fun, /* tagged */ StgClosure** payload, StgWord n_args) { StgPtr p; StgWord bitmap; const StgFunInfoTable *fun_info; traversePushClosure(ts, fun, pap, sep, data); 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 = traverseSmallBitmap(ts, p, n_args, bitmap, pap, sep, data); break; case ARG_GEN_BIG: traverseLargeBitmap(ts, p, GET_FUN_LARGE_BITMAP(fun_info), n_args, pap, sep, data); p += n_args; break; case ARG_BCO: traverseLargeBitmap(ts, (StgPtr)payload, BCO_BITMAP(fun), n_args, pap, sep, data); p += n_args; break; default: bitmap = BITMAP_BITS(stg_arg_bitmaps[fun_info->f.fun_type]); p = traverseSmallBitmap(ts, p, n_args, bitmap, pap, sep, data); break; } return p; } static void resetMutableObjects(traverseState* ts) { uint32_t g, n; bdescr *bd; StgPtr ml; // The following code resets the 'trav' field of each unvisited mutable // object. 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 heap traversal. 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++) { traverseMaybeInitClosureData(ts, (StgClosure *)*ml); } } } } } /** * Traverse all closures on the traversal work-stack, calling 'visit_cb' on each * closure. See 'visitClosure_cb' for details. */ void traverseWorkStack(traverseState *ts, visitClosure_cb visit_cb) { // first_child = first child of c StgClosure *c, *cp, *first_child; stackData data, child_data; StgWord typeOfc; stackElement *sep; bool other_children; // c = Current closure (possibly tagged) // cp = Current closure's Parent (NOT tagged) // data = current closures' associated data (NOT tagged) // child_data = data to associate with current closure's children loop: traversePop(ts, &c, &cp, &data, &sep); if (c == NULL) { debug("maxStackSize= %d\n", ts->maxStackSize); return; } inner_loop: c = UNTAG_CLOSURE(c); typeOfc = get_itbl(c)->type; // special cases switch (typeOfc) { case TSO: if (((StgTSO *)c)->what_next == ThreadComplete || ((StgTSO *)c)->what_next == ThreadKilled) { debug("ThreadComplete or ThreadKilled encountered in traverseWorkStack()\n"); goto loop; } break; case IND_STATIC: // We just skip IND_STATIC, so it's never visited. c = ((StgIndStatic *)c)->indirectee; goto inner_loop; case CONSTR_NOCAF: // static objects with no pointers out, so goto loop. // It is not just enough not to visit *c; it is // mandatory because CONSTR_NOCAF 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: if (get_itbl(c)->srt == 0) { // No need to visit *c; no dynamic objects are reachable from it. // // 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? Surely these may be able // to appear, and they don't have SRTs, so we can't // check. So for now, we're calling // resetStaticObjectForProfiling() from the // garbage collector to reset the retainer sets in all the // reachable static objects. goto loop; } /* fall-thru */ case FUN_STATIC: { const StgInfoTable *info = get_itbl(c); if (info->srt == 0 && info->layout.payload.ptrs == 0) { goto loop; } else { break; } } default: break; } stackAccum accum = {}; // If this is the first visit to c, initialize its data. bool first_visit = traverseMaybeInitClosureData(ts, c); bool traverse_children = first_visit; if(visit_cb) traverse_children = visit_cb(c, cp, data, first_visit, &accum, &child_data); if(!traverse_children) goto loop; // 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: sep = traversePushReturn(ts, c, accum, sep); traversePushStack(ts, c, sep, child_data, ((StgStack *)c)->sp, ((StgStack *)c)->stack + ((StgStack *)c)->stack_size); goto loop; case TSO: { StgTSO *tso = (StgTSO *)c; sep = traversePushReturn(ts, c, accum, sep); traversePushClosure(ts, (StgClosure *) tso->stackobj, c, sep, child_data); traversePushClosure(ts, (StgClosure *) tso->blocked_exceptions, c, sep, child_data); traversePushClosure(ts, (StgClosure *) tso->bq, c, sep, child_data); traversePushClosure(ts, (StgClosure *) tso->trec, c, sep, child_data); if ( tso->why_blocked == BlockedOnMVar || tso->why_blocked == BlockedOnMVarRead || tso->why_blocked == BlockedOnIOCompletion || tso->why_blocked == BlockedOnBlackHole || tso->why_blocked == BlockedOnMsgThrowTo ) { traversePushClosure(ts, tso->block_info.closure, c, sep, child_data); } goto loop; } case BLOCKING_QUEUE: { StgBlockingQueue *bq = (StgBlockingQueue *)c; sep = traversePushReturn(ts, c, accum, sep); traversePushClosure(ts, (StgClosure *) bq->link, c, sep, child_data); traversePushClosure(ts, (StgClosure *) bq->bh, c, sep, child_data); traversePushClosure(ts, (StgClosure *) bq->owner, c, sep, child_data); goto loop; } case PAP: { StgPAP *pap = (StgPAP *)c; sep = traversePushReturn(ts, c, accum, sep); traversePAP(ts, c, sep, child_data, pap->fun, pap->payload, pap->n_args); goto loop; } case AP: { StgAP *ap = (StgAP *)c; sep = traversePushReturn(ts, c, accum, sep); traversePAP(ts, c, sep, child_data, ap->fun, ap->payload, ap->n_args); goto loop; } case AP_STACK: sep = traversePushReturn(ts, c, accum, sep); traversePushClosure(ts, ((StgAP_STACK *)c)->fun, c, sep, child_data); traversePushStack(ts, c, sep, child_data, (StgPtr)((StgAP_STACK *)c)->payload, (StgPtr)((StgAP_STACK *)c)->payload + ((StgAP_STACK *)c)->size); goto loop; } stackElement se; traverseGetChildren(c, &first_child, &other_children, &se); // If first_child is null, c has no child. // If first_child is not null, the top stack element points to the next // object. if(first_child == NULL && ts->return_cb) { // no children // This is only true when we're pushing additional return frames onto // the stack due to return_cb, so don't get any funny ideas about // replacing 'cp' by sep. ASSERT(sep->c == cp); ts->return_cb(c, accum, cp, &sep->accum); goto loop; } else if (first_child == NULL) { // no children goto loop; } else if(!other_children) { // one child // Pushing a return frame for one child is pretty inefficent. We could // optimize this by storing a pointer to cp in c's profiling header // instead. I tested this out in a Haskell prototype of this code and it // works out but is rather fiddly. // // See Haskell model code here: // // https://gitlab.haskell.org/ghc/ghc/snippets/1461 sep = traversePushReturn(ts, c, accum, sep); } else { // many children se.sep = sep; se.data = child_data; se.accum = accum; sep = pushStackElement(ts, se); } // (c, cp, data) = (first_child, c, child_data) data = child_data; cp = c; c = first_child; goto inner_loop; } /** * This function flips the 'flip' bit and hence every closure's profiling data * will be reset to zero upon visiting. See Note [Profiling heap traversal * visited bit]. */ void traverseInvalidateClosureData(traverseState* ts) { // First make sure any unvisited mutable objects are valid so they're // invalidated by the flip below resetMutableObjects(ts); // Then flip the flip bit, invalidating all closures. ts->flip = ts->flip ^ 1; } /** * Traverse all static objects and invalidate their traversal-data. This ensures * that when doing the actual traversal no static closures will seem to have * been visited already because they weren't visited in the last run. * * This function must be called before zeroing all objects reachable from * scavenged_static_objects in the case of major garbage 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 * never visited during traversal. */ void resetStaticObjectForProfiling( const traverseState *ts, StgClosure *static_objects ) { uint32_t count = 0; StgClosure *p; p = static_objects; while (p != END_OF_STATIC_OBJECT_LIST) { p = UNTAG_STATIC_LIST_PTR(p); count++; 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: traverseMaybeInitClosureData(ts, p); p = (StgClosure*)*THUNK_STATIC_LINK(p); break; case FUN_STATIC: case CONSTR: case CONSTR_1_0: case CONSTR_2_0: case CONSTR_1_1: case CONSTR_NOCAF: traverseMaybeInitClosureData(ts, p); p = (StgClosure*)*STATIC_LINK(get_itbl(p), p); break; default: barf("resetStaticObjectForProfiling: %p (%lu)", p, (unsigned long)get_itbl(p)->type); break; } } debug("count in scavenged_static_objects = %d\n", count); } #endif /* PROFILING */
the_stack_data/43887434.c
#include<stdio.h> #include<stdlib.h> //Insertion of nodes at the beginning of a Circular linked list typedef struct node { int data; struct node *link; }node; node *head = NULL; node *tail = NULL; node *add_at_end(node *tail,int d) { node *temp=malloc(sizeof(node)); temp->data=d; temp->link=head; tail->link=temp; tail=temp; return temp; } void display(int m) { node*ptr=head; if(m==1) printf("\nOur Circular linked list is : "); else printf("\nAfter insertion our list is : "); while(ptr!=tail) { printf("%d -> ",ptr->data); ptr=ptr->link; } printf("%d -> %d",ptr->data,head->data); } void add_beg() { int d,m=2; char ch; node *temp=malloc(sizeof(node)); printf("\nEnter data you want to insert at the beginning of the list : "); scanf("%d",&d); temp->data=d; temp->link=head; head=temp; display(m); printf("\nDo you want to insert some more node at the beginning of the list (y/n) : "); ch = getch(); if(ch=='y'||ch=='Y') { add_beg(); } else return; } void create(int n) { int i,d; head=malloc(sizeof(node)); tail=malloc(sizeof(node)); printf("\nEnter data fo node 1 : "); scanf("%d",&d); head->data=d; head->link=NULL; tail = head; for(i=2;i<=n;i++) { printf("\nEnter data for node %d : ",i); scanf("%d",&d); tail=add_at_end(tail,d); } } int main() { int n,m=1; char ch; printf("Enter the number of nodes you want in your list : "); scanf("%d",&n); create(n); display(m); printf("\nDo you want to insert a node at the beginning of the list (y/n) : "); ch = getch(); if(ch=='y'||ch=='Y') { add_beg(); } else printf("\nNo updation in the list."); return 0; }
the_stack_data/159877.c
#include <stdio.h> int main() { int h, age; printf("enter your height (cm): "); scanf("%d", &h); printf("enter your age (year) : "); scanf("%d", &age); if (h > 160 && age > 20 && age < 25) { printf("you pass\n"); printf("congratulations\n"); } else { printf("sorry"); } }
the_stack_data/23574006.c
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h> #include <math.h> double scaleFootrule = 100; int optimumPos[100]; void sort(int *pr, int length); void positions(int *pos, int *unranked, int *ranked, int length, int lengthAll); void swap(int *pos, int i, int j); void permute(int *array,int i,int length, int pos[100][100], int *numUrls, int argc); int main(int argc, char **argv) { //Error when no file in given in commandline if(argc < 2) { fprintf(stderr, "Usage: %s rankA.txt rankD.txt", argv[0]); exit(1); } //Declaration of variables int i; //mainMatrix contains the url suffix no. of each file (e.g. array[0][] would be urls from first file) int mainMatrix[1000][1000]; int mainMatrixS[1000][1000]; //numbers from mainMatrix sorted in increasing order //Number of urls in each file (e.g. array[0] would be the no. of urls from first file) int numUrls[1000] = {0}; char string[3000]; //Max no. of urls given among all files (e.g. rankA.txt has 5 urls and rankB.txt has 4 urls, this variable stores 5) int numUrlsMax = 0; int pos[100][100]; //int maxUrlsLocation = 0; int numAllUrls = 0; int allUrls[100] = {0}; //Opening the files and storing the no. suffix of url into the matrix for(i = 0; i < argc-1; i++) { FILE *fp; fp = fopen(argv[i+1], "r"); int j = 0; int k; while(fscanf(fp, "%s", string) != EOF) { char *token = strtok(string, "url"); mainMatrix[i][j] = mainMatrixS[i][j] = atoi(token); int check = 0; for(k = 0; k < numAllUrls; k++) { if(allUrls[k] == atoi(token)) { check = 1; break; } } if(!check) { allUrls[numAllUrls] = atoi(token); numAllUrls++; } j++; numUrls[i]++; } fclose(fp); } sort(allUrls, numAllUrls); //Storing the max urls among all files within numUrlsMax for(i = 0; i < argc-1; i++) { if(numUrls[i]>numUrlsMax) { numUrlsMax = numUrls[i]; //maxUrlsLocation = i; } } //Sorting array using the function sort() for(i = 0; i < argc-1; i++) { sort(mainMatrixS[i], numUrls[i]); } //position function makes an array with the position of the urls //e.g. /* url3 url2 url4 url1 the postion inputs the postions of these into the given array pos1[4,2,1,3] As url1 has 4th position, url2 has 2nd position, url3 has 1st position and url4 has 3rd position */ for(i = 0; i < argc-1; i++) { positions(pos[i], mainMatrix[i], allUrls, numUrls[i], numAllUrls); } //orderedPosArray creates an array with ordered numbers upto the the max no. of items in the biggest array. //e.g. rankA.txt has 5 items rankB.txt has 4 items, therefore orderedPosArray would contain [1,2,3,4,5] //Purpose - to pass into permute function and change the order to find the smallest scale foot distance. int orderedPosArray[100]; for(i = 0; i < numAllUrls; i++) { orderedPosArray[i] = i+1; } //Passing values into the permute() function //permute(orderedPosArray, 0, numAllUrls, pos, numUrls, argc); permute(orderedPosArray, 0, numAllUrls, pos, numUrls, argc); printf("%lf\n", scaleFootrule); for(i = 0; i < numAllUrls; i++) { char placeholder[20]; sprintf(placeholder,"url%d",allUrls[optimumPos[i]-1]); printf("%s\n", placeholder); } return 0; } //Sort function sorts the given array in increasing order void sort(int *pr, int length){ int i, j; int temp; for(i=0; i<length; i++){ for(j=i+1; j<length; j++){ if(pr[i]>pr[j]){ //swap values if pr[i] > pr[j] temp = pr[i]; pr[i] = pr[j]; pr[j] = temp; } } } } void positions(int *pos, int *unsorted, int *sortedAll, int length, int lengthAll) { int posNum = 0; int i, j; for(i = 0; i < lengthAll; i++) { for(j = 0; j < lengthAll; j++) { if(sortedAll[i] == unsorted[j]) { pos[posNum++] = j+1; break; } } } } //Used as part of the permute function. It is used to swap the values in the array to permute the order void swap(int *pos, int i, int j) { int temp = pos[i]; pos[i] = pos[j]; pos[j] = temp; } //Permutes the order the positions and calculates the smallest scaled foot rule void permute(int *array,int i,int length, int pos[100][100], int *numUrls, int argc) { double temp = 0; int j, k, l; //printf("length:%d\n", length); if (i == length){ for(l = 0; l < argc-1; l++) { for(j = 0; j < numUrls[l]; j++) { temp += fabs(((double)pos[l][j]/(double)numUrls[l]) - ((double)array[j]/(double)length)); } } if(temp < scaleFootrule) { scaleFootrule = temp; for(k = 0; k < length; k++) { optimumPos[k] = array[k]; } } return; } for (j = i; j < length; j++) { swap(array,i,j); permute(array,i+1, length, pos, numUrls, argc); } return; }
the_stack_data/62637935.c
/** * This program forks a separate process using the fork()/exec() system calls. * * Figure 3.09 * * @author Silberschatz, Galvin, and Gagne * Operating System Concepts - Ninth Edition * Copyright John Wiley & Sons - 2013 */ #include <stdio.h> #include <unistd.h> #include <sys/types.h> int main() { pid_t pid; /* fork a child process */ pid = fork(); if (pid < 0) { /* error occurred */ fprintf(stderr, "Fork Failed\n"); return 1; } else if (pid == 0) { /* child process */ printf("I am the child %d\n",pid); execlp("/bin/ls","ls",NULL); } else { /* parent process */ /* parent will wait for the child to complete */ printf("I am the parent %d\n",pid); wait(NULL); printf("Child Complete\n"); } return 0; }
the_stack_data/77908.c
/* * This file: image_f_io.c (part of the WSCRAWL program) * * This file contains the "Image File I/O" package for wscrawl (or anything * for that matter.) The format used is the standard X-Window Dump form * that the MIT client "xwd" uses. This File I/O was made possible by the * help and extensive source code of Mark Cook of Hewlett-Packard, who I * bothered endlessly to get this working. * * I tried to make this file of routines as self-contained and portable as * possible. Please feel free to use this file as is, or with modifications, * for any and all applications. -- Brian Wilson * * This file was last modified: 10/7/91 (initial port to wscrawl 2.0) */ #define TRUE 1 #define FALSE 0 #define BAD_CHOICE -1 #define NO_DUPLICATE -1 #define UNALLOCATED -1 #include <X11/Xos.h> #include <X11/XWDFile.h> #include <X11/Xlib.h> #include <stdio.h> extern char *malloc(); XImage *read_image_from_disk(); /* */ get_xwd_image(disp, info_win_id, win_id, x, y, width, height, name_of_file, the_colormap) Display *disp; Window info_win_id; Pixmap win_id; int x, y, width, height; char *name_of_file; Colormap the_colormap; { unsigned long swaptest = TRUE; XRectangle box2; XRectangle *box; FILE *out_file_ptr; XColor *colors; unsigned buffer_size; int win_name_size; int header_size; int format=ZPixmap; int ncolors, i; XWindowAttributes win_info; XImage *ImagePix; XWDFileHeader header; /* * convert to form this code understands (I got code from Mark Cook) */ box = &box2; box->x = x; box->y = y; box->width = width; box->height = height; /* * Open the file in which the image is to be stored */ if ((out_file_ptr = fopen(name_of_file, "w")) == NULL) { printf("ERROR: Could not open file %s.\n", name_of_file); return(0); } else { /* Dump the image to the specified file */ if (the_colormap == NULL) { the_colormap = XDefaultColormapOfScreen(XDefaultScreenOfDisplay(disp)); } if (!XGetWindowAttributes(disp, info_win_id, &win_info)) { printf("Can't get window attributes.\n"); return(0); } /* * sizeof(char) is included for the null string terminator. */ win_name_size = strlen(name_of_file) + sizeof(char); ImagePix = XGetImage(disp, win_id, box->x, box->y, box->width, box->height, AllPlanes, format); XFlush(disp); if (ImagePix == NULL) { printf("GetImage failed.\n"); return(0); } buffer_size = Image_Size(ImagePix,format);/*determines size of pixmap*/ /* * Get the RGB values for the current color cells */ if ((ncolors = Get_Colors(&colors, disp, the_colormap)) == 0) { printf("Cannot alloc memory for color structs.\n"); return(0); } XFlush(disp); header_size = sizeof(header) +win_name_size; /*Calculates header size*/ /* * Assemble the file header information */ header.header_size = (xwdval) header_size; header.file_version = (xwdval) XWD_FILE_VERSION; header.pixmap_format = (xwdval) format; header.pixmap_depth = (xwdval) ImagePix->depth; header.pixmap_width = (xwdval) ImagePix->width; header.pixmap_height = (xwdval) ImagePix->height; header.xoffset = (xwdval) ImagePix->xoffset; header.byte_order = (xwdval) ImagePix->byte_order; header.bitmap_unit = (xwdval) ImagePix->bitmap_unit; header.bitmap_bit_order = (xwdval) ImagePix->bitmap_bit_order; header.bitmap_pad = (xwdval) ImagePix->bitmap_pad; header.bits_per_pixel = (xwdval) ImagePix->bits_per_pixel; header.bytes_per_line = (xwdval) ImagePix->bytes_per_line; header.visual_class = (xwdval) win_info.visual->class; header.red_mask = (xwdval) win_info.visual->red_mask; header.green_mask = (xwdval) win_info.visual->green_mask; header.blue_mask = (xwdval) win_info.visual->blue_mask; header.bits_per_rgb = (xwdval) win_info.visual->bits_per_rgb; header.colormap_entries = (xwdval) win_info.visual->map_entries; header.ncolors = ncolors; header.window_width = (xwdval) ImagePix->width; header.window_height = (xwdval) ImagePix->height; header.window_x = (xwdval) 0; header.window_y = (xwdval) 0; header.window_bdrwidth = (xwdval) 0; if (*(char *) &swaptest) { _swaplong((char *) &header, sizeof(header)); for (i = 0; i < ncolors; i++) { _swaplong((char *) &colors[i].pixel, sizeof(long)); _swapshort((char *) &colors[i].red, 3 * sizeof(short)); } } /* * Write out the file header information */ (void) fwrite((char *)&header, sizeof(header), 1, out_file_ptr); (void) fwrite(name_of_file, win_name_size, 1, out_file_ptr); /* * Write out the color cell RGB values */ (void) fwrite((char *) colors, sizeof(XColor), ncolors, out_file_ptr); /* * Write out the buffer */ (void) fwrite(ImagePix->data, (int) buffer_size, 1, out_file_ptr); if(ncolors > 0) free(colors); /*free the color buffer*/ fclose(out_file_ptr); XFlush(disp); XDestroyImage(ImagePix); } }
the_stack_data/116573.c
#if defined(VARIANT_SHA2_SIMPLE) || defined(VARIANT_SHA2_ROBUST) /* Based on the public domain implementation in * crypto_hash/sha512/ref/ from http://bench.cr.yp.to/supercop.html * by D. J. Bernstein */ #include <stddef.h> #include <stdint.h> #include <string.h> #include "utils.h" #include "sha256.h" static uint32_t load_bigendian_32(const uint8_t *x) { return (uint32_t)(x[3]) | (((uint32_t)(x[2])) << 8) | (((uint32_t)(x[1])) << 16) | (((uint32_t)(x[0])) << 24); } static uint64_t load_bigendian_64(const uint8_t *x) { return (uint64_t)(x[7]) | (((uint64_t)(x[6])) << 8) | (((uint64_t)(x[5])) << 16) | (((uint64_t)(x[4])) << 24) | (((uint64_t)(x[3])) << 32) | (((uint64_t)(x[2])) << 40) | (((uint64_t)(x[1])) << 48) | (((uint64_t)(x[0])) << 56); } static void store_bigendian_32(uint8_t *x, uint64_t u) { x[3] = (uint8_t) u; u >>= 8; x[2] = (uint8_t) u; u >>= 8; x[1] = (uint8_t) u; u >>= 8; x[0] = (uint8_t) u; } static void store_bigendian_64(uint8_t *x, uint64_t u) { x[7] = (uint8_t) u; u >>= 8; x[6] = (uint8_t) u; u >>= 8; x[5] = (uint8_t) u; u >>= 8; x[4] = (uint8_t) u; u >>= 8; x[3] = (uint8_t) u; u >>= 8; x[2] = (uint8_t) u; u >>= 8; x[1] = (uint8_t) u; u >>= 8; x[0] = (uint8_t) u; } #define SHR(x, c) ((x) >> (c)) #define ROTR_32(x, c) (((x) >> (c)) | ((x) << (32 - (c)))) #define ROTR_64(x,c) (((x) >> (c)) | ((x) << (64 - (c)))) #define Ch(x, y, z) (((x) & (y)) ^ (~(x) & (z))) #define Maj(x, y, z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z))) #define Sigma0_32(x) (ROTR_32(x, 2) ^ ROTR_32(x,13) ^ ROTR_32(x,22)) #define Sigma1_32(x) (ROTR_32(x, 6) ^ ROTR_32(x,11) ^ ROTR_32(x,25)) #define sigma0_32(x) (ROTR_32(x, 7) ^ ROTR_32(x,18) ^ SHR(x, 3)) #define sigma1_32(x) (ROTR_32(x,17) ^ ROTR_32(x,19) ^ SHR(x,10)) #define Sigma0_64(x) (ROTR_64(x,28) ^ ROTR_64(x,34) ^ ROTR_64(x,39)) #define Sigma1_64(x) (ROTR_64(x,14) ^ ROTR_64(x,18) ^ ROTR_64(x,41)) #define sigma0_64(x) (ROTR_64(x, 1) ^ ROTR_64(x, 8) ^ SHR(x,7)) #define sigma1_64(x) (ROTR_64(x,19) ^ ROTR_64(x,61) ^ SHR(x,6)) #define M_32(w0, w14, w9, w1) w0 = sigma1_32(w14) + (w9) + sigma0_32(w1) + (w0); #define M_64(w0, w14, w9, w1) w0 = sigma1_64(w14) + (w9) + sigma0_64(w1) + (w0); #define EXPAND_32 \ M_32(w0, w14, w9, w1) \ M_32(w1, w15, w10, w2) \ M_32(w2, w0, w11, w3) \ M_32(w3, w1, w12, w4) \ M_32(w4, w2, w13, w5) \ M_32(w5, w3, w14, w6) \ M_32(w6, w4, w15, w7) \ M_32(w7, w5, w0, w8) \ M_32(w8, w6, w1, w9) \ M_32(w9, w7, w2, w10) \ M_32(w10, w8, w3, w11) \ M_32(w11, w9, w4, w12) \ M_32(w12, w10, w5, w13) \ M_32(w13, w11, w6, w14) \ M_32(w14, w12, w7, w15) \ M_32(w15, w13, w8, w0) #define EXPAND_64 \ M_64(w0 ,w14,w9 ,w1 ) \ M_64(w1 ,w15,w10,w2 ) \ M_64(w2 ,w0 ,w11,w3 ) \ M_64(w3 ,w1 ,w12,w4 ) \ M_64(w4 ,w2 ,w13,w5 ) \ M_64(w5 ,w3 ,w14,w6 ) \ M_64(w6 ,w4 ,w15,w7 ) \ M_64(w7 ,w5 ,w0 ,w8 ) \ M_64(w8 ,w6 ,w1 ,w9 ) \ M_64(w9 ,w7 ,w2 ,w10) \ M_64(w10,w8 ,w3 ,w11) \ M_64(w11,w9 ,w4 ,w12) \ M_64(w12,w10,w5 ,w13) \ M_64(w13,w11,w6 ,w14) \ M_64(w14,w12,w7 ,w15) \ M_64(w15,w13,w8 ,w0 ) #define F_32(w, k) \ T1 = h + Sigma1_32(e) + Ch(e, f, g) + (k) + (w); \ T2 = Sigma0_32(a) + Maj(a, b, c); \ h = g; \ g = f; \ f = e; \ e = d + T1; \ d = c; \ c = b; \ b = a; \ a = T1 + T2; #define F_64(w,k) \ T1 = h + Sigma1_64(e) + Ch(e,f,g) + k + w; \ T2 = Sigma0_64(a) + Maj(a,b,c); \ h = g; \ g = f; \ f = e; \ e = d + T1; \ d = c; \ c = b; \ b = a; \ a = T1 + T2; static size_t crypto_hashblocks_sha256(uint8_t *statebytes, const uint8_t *in, size_t inlen) { uint32_t state[8]; uint32_t a; uint32_t b; uint32_t c; uint32_t d; uint32_t e; uint32_t f; uint32_t g; uint32_t h; uint32_t T1; uint32_t T2; a = load_bigendian_32(statebytes + 0); state[0] = a; b = load_bigendian_32(statebytes + 4); state[1] = b; c = load_bigendian_32(statebytes + 8); state[2] = c; d = load_bigendian_32(statebytes + 12); state[3] = d; e = load_bigendian_32(statebytes + 16); state[4] = e; f = load_bigendian_32(statebytes + 20); state[5] = f; g = load_bigendian_32(statebytes + 24); state[6] = g; h = load_bigendian_32(statebytes + 28); state[7] = h; while (inlen >= 64) { uint32_t w0 = load_bigendian_32(in + 0); uint32_t w1 = load_bigendian_32(in + 4); uint32_t w2 = load_bigendian_32(in + 8); uint32_t w3 = load_bigendian_32(in + 12); uint32_t w4 = load_bigendian_32(in + 16); uint32_t w5 = load_bigendian_32(in + 20); uint32_t w6 = load_bigendian_32(in + 24); uint32_t w7 = load_bigendian_32(in + 28); uint32_t w8 = load_bigendian_32(in + 32); uint32_t w9 = load_bigendian_32(in + 36); uint32_t w10 = load_bigendian_32(in + 40); uint32_t w11 = load_bigendian_32(in + 44); uint32_t w12 = load_bigendian_32(in + 48); uint32_t w13 = load_bigendian_32(in + 52); uint32_t w14 = load_bigendian_32(in + 56); uint32_t w15 = load_bigendian_32(in + 60); F_32(w0, 0x428a2f98) F_32(w1, 0x71374491) F_32(w2, 0xb5c0fbcf) F_32(w3, 0xe9b5dba5) F_32(w4, 0x3956c25b) F_32(w5, 0x59f111f1) F_32(w6, 0x923f82a4) F_32(w7, 0xab1c5ed5) F_32(w8, 0xd807aa98) F_32(w9, 0x12835b01) F_32(w10, 0x243185be) F_32(w11, 0x550c7dc3) F_32(w12, 0x72be5d74) F_32(w13, 0x80deb1fe) F_32(w14, 0x9bdc06a7) F_32(w15, 0xc19bf174) EXPAND_32 F_32(w0, 0xe49b69c1) F_32(w1, 0xefbe4786) F_32(w2, 0x0fc19dc6) F_32(w3, 0x240ca1cc) F_32(w4, 0x2de92c6f) F_32(w5, 0x4a7484aa) F_32(w6, 0x5cb0a9dc) F_32(w7, 0x76f988da) F_32(w8, 0x983e5152) F_32(w9, 0xa831c66d) F_32(w10, 0xb00327c8) F_32(w11, 0xbf597fc7) F_32(w12, 0xc6e00bf3) F_32(w13, 0xd5a79147) F_32(w14, 0x06ca6351) F_32(w15, 0x14292967) EXPAND_32 F_32(w0, 0x27b70a85) F_32(w1, 0x2e1b2138) F_32(w2, 0x4d2c6dfc) F_32(w3, 0x53380d13) F_32(w4, 0x650a7354) F_32(w5, 0x766a0abb) F_32(w6, 0x81c2c92e) F_32(w7, 0x92722c85) F_32(w8, 0xa2bfe8a1) F_32(w9, 0xa81a664b) F_32(w10, 0xc24b8b70) F_32(w11, 0xc76c51a3) F_32(w12, 0xd192e819) F_32(w13, 0xd6990624) F_32(w14, 0xf40e3585) F_32(w15, 0x106aa070) EXPAND_32 F_32(w0, 0x19a4c116) F_32(w1, 0x1e376c08) F_32(w2, 0x2748774c) F_32(w3, 0x34b0bcb5) F_32(w4, 0x391c0cb3) F_32(w5, 0x4ed8aa4a) F_32(w6, 0x5b9cca4f) F_32(w7, 0x682e6ff3) F_32(w8, 0x748f82ee) F_32(w9, 0x78a5636f) F_32(w10, 0x84c87814) F_32(w11, 0x8cc70208) F_32(w12, 0x90befffa) F_32(w13, 0xa4506ceb) F_32(w14, 0xbef9a3f7) F_32(w15, 0xc67178f2) a += state[0]; b += state[1]; c += state[2]; d += state[3]; e += state[4]; f += state[5]; g += state[6]; h += state[7]; state[0] = a; state[1] = b; state[2] = c; state[3] = d; state[4] = e; state[5] = f; state[6] = g; state[7] = h; in += 64; inlen -= 64; } store_bigendian_32(statebytes + 0, state[0]); store_bigendian_32(statebytes + 4, state[1]); store_bigendian_32(statebytes + 8, state[2]); store_bigendian_32(statebytes + 12, state[3]); store_bigendian_32(statebytes + 16, state[4]); store_bigendian_32(statebytes + 20, state[5]); store_bigendian_32(statebytes + 24, state[6]); store_bigendian_32(statebytes + 28, state[7]); return inlen; } int crypto_hashblocks_sha512(unsigned char *statebytes,const unsigned char *in,unsigned long long inlen) { uint64_t state[8]; uint64_t a; uint64_t b; uint64_t c; uint64_t d; uint64_t e; uint64_t f; uint64_t g; uint64_t h; uint64_t T1; uint64_t T2; a = load_bigendian_64(statebytes + 0); state[0] = a; b = load_bigendian_64(statebytes + 8); state[1] = b; c = load_bigendian_64(statebytes + 16); state[2] = c; d = load_bigendian_64(statebytes + 24); state[3] = d; e = load_bigendian_64(statebytes + 32); state[4] = e; f = load_bigendian_64(statebytes + 40); state[5] = f; g = load_bigendian_64(statebytes + 48); state[6] = g; h = load_bigendian_64(statebytes + 56); state[7] = h; while (inlen >= 128) { uint64_t w0 = load_bigendian_64(in + 0); uint64_t w1 = load_bigendian_64(in + 8); uint64_t w2 = load_bigendian_64(in + 16); uint64_t w3 = load_bigendian_64(in + 24); uint64_t w4 = load_bigendian_64(in + 32); uint64_t w5 = load_bigendian_64(in + 40); uint64_t w6 = load_bigendian_64(in + 48); uint64_t w7 = load_bigendian_64(in + 56); uint64_t w8 = load_bigendian_64(in + 64); uint64_t w9 = load_bigendian_64(in + 72); uint64_t w10 = load_bigendian_64(in + 80); uint64_t w11 = load_bigendian_64(in + 88); uint64_t w12 = load_bigendian_64(in + 96); uint64_t w13 = load_bigendian_64(in + 104); uint64_t w14 = load_bigendian_64(in + 112); uint64_t w15 = load_bigendian_64(in + 120); F_64(w0 ,0x428a2f98d728ae22ULL) F_64(w1 ,0x7137449123ef65cdULL) F_64(w2 ,0xb5c0fbcfec4d3b2fULL) F_64(w3 ,0xe9b5dba58189dbbcULL) F_64(w4 ,0x3956c25bf348b538ULL) F_64(w5 ,0x59f111f1b605d019ULL) F_64(w6 ,0x923f82a4af194f9bULL) F_64(w7 ,0xab1c5ed5da6d8118ULL) F_64(w8 ,0xd807aa98a3030242ULL) F_64(w9 ,0x12835b0145706fbeULL) F_64(w10,0x243185be4ee4b28cULL) F_64(w11,0x550c7dc3d5ffb4e2ULL) F_64(w12,0x72be5d74f27b896fULL) F_64(w13,0x80deb1fe3b1696b1ULL) F_64(w14,0x9bdc06a725c71235ULL) F_64(w15,0xc19bf174cf692694ULL) EXPAND_64 F_64(w0 ,0xe49b69c19ef14ad2ULL) F_64(w1 ,0xefbe4786384f25e3ULL) F_64(w2 ,0x0fc19dc68b8cd5b5ULL) F_64(w3 ,0x240ca1cc77ac9c65ULL) F_64(w4 ,0x2de92c6f592b0275ULL) F_64(w5 ,0x4a7484aa6ea6e483ULL) F_64(w6 ,0x5cb0a9dcbd41fbd4ULL) F_64(w7 ,0x76f988da831153b5ULL) F_64(w8 ,0x983e5152ee66dfabULL) F_64(w9 ,0xa831c66d2db43210ULL) F_64(w10,0xb00327c898fb213fULL) F_64(w11,0xbf597fc7beef0ee4ULL) F_64(w12,0xc6e00bf33da88fc2ULL) F_64(w13,0xd5a79147930aa725ULL) F_64(w14,0x06ca6351e003826fULL) F_64(w15,0x142929670a0e6e70ULL) EXPAND_64 F_64(w0 ,0x27b70a8546d22ffcULL) F_64(w1 ,0x2e1b21385c26c926ULL) F_64(w2 ,0x4d2c6dfc5ac42aedULL) F_64(w3 ,0x53380d139d95b3dfULL) F_64(w4 ,0x650a73548baf63deULL) F_64(w5 ,0x766a0abb3c77b2a8ULL) F_64(w6 ,0x81c2c92e47edaee6ULL) F_64(w7 ,0x92722c851482353bULL) F_64(w8 ,0xa2bfe8a14cf10364ULL) F_64(w9 ,0xa81a664bbc423001ULL) F_64(w10,0xc24b8b70d0f89791ULL) F_64(w11,0xc76c51a30654be30ULL) F_64(w12,0xd192e819d6ef5218ULL) F_64(w13,0xd69906245565a910ULL) F_64(w14,0xf40e35855771202aULL) F_64(w15,0x106aa07032bbd1b8ULL) EXPAND_64 F_64(w0 ,0x19a4c116b8d2d0c8ULL) F_64(w1 ,0x1e376c085141ab53ULL) F_64(w2 ,0x2748774cdf8eeb99ULL) F_64(w3 ,0x34b0bcb5e19b48a8ULL) F_64(w4 ,0x391c0cb3c5c95a63ULL) F_64(w5 ,0x4ed8aa4ae3418acbULL) F_64(w6 ,0x5b9cca4f7763e373ULL) F_64(w7 ,0x682e6ff3d6b2b8a3ULL) F_64(w8 ,0x748f82ee5defb2fcULL) F_64(w9 ,0x78a5636f43172f60ULL) F_64(w10,0x84c87814a1f0ab72ULL) F_64(w11,0x8cc702081a6439ecULL) F_64(w12,0x90befffa23631e28ULL) F_64(w13,0xa4506cebde82bde9ULL) F_64(w14,0xbef9a3f7b2c67915ULL) F_64(w15,0xc67178f2e372532bULL) EXPAND_64 F_64(w0 ,0xca273eceea26619cULL) F_64(w1 ,0xd186b8c721c0c207ULL) F_64(w2 ,0xeada7dd6cde0eb1eULL) F_64(w3 ,0xf57d4f7fee6ed178ULL) F_64(w4 ,0x06f067aa72176fbaULL) F_64(w5 ,0x0a637dc5a2c898a6ULL) F_64(w6 ,0x113f9804bef90daeULL) F_64(w7 ,0x1b710b35131c471bULL) F_64(w8 ,0x28db77f523047d84ULL) F_64(w9 ,0x32caab7b40c72493ULL) F_64(w10,0x3c9ebe0a15c9bebcULL) F_64(w11,0x431d67c49c100d4cULL) F_64(w12,0x4cc5d4becb3e42b6ULL) F_64(w13,0x597f299cfc657e2aULL) F_64(w14,0x5fcb6fab3ad6faecULL) F_64(w15,0x6c44198c4a475817ULL) a += state[0]; b += state[1]; c += state[2]; d += state[3]; e += state[4]; f += state[5]; g += state[6]; h += state[7]; state[0] = a; state[1] = b; state[2] = c; state[3] = d; state[4] = e; state[5] = f; state[6] = g; state[7] = h; in += 128; inlen -= 128; } store_bigendian_64(statebytes + 0,state[0]); store_bigendian_64(statebytes + 8,state[1]); store_bigendian_64(statebytes + 16,state[2]); store_bigendian_64(statebytes + 24,state[3]); store_bigendian_64(statebytes + 32,state[4]); store_bigendian_64(statebytes + 40,state[5]); store_bigendian_64(statebytes + 48,state[6]); store_bigendian_64(statebytes + 56,state[7]); return inlen; } static const uint8_t iv_256[32] = { 0x6a, 0x09, 0xe6, 0x67, 0xbb, 0x67, 0xae, 0x85, 0x3c, 0x6e, 0xf3, 0x72, 0xa5, 0x4f, 0xf5, 0x3a, 0x51, 0x0e, 0x52, 0x7f, 0x9b, 0x05, 0x68, 0x8c, 0x1f, 0x83, 0xd9, 0xab, 0x5b, 0xe0, 0xcd, 0x19 }; static const uint8_t iv_512[64] = { 0x6a, 0x09, 0xe6, 0x67, 0xf3, 0xbc, 0xc9, 0x08, 0xbb, 0x67, 0xae, 0x85, 0x84, 0xca, 0xa7, 0x3b, 0x3c, 0x6e, 0xf3, 0x72, 0xfe, 0x94, 0xf8, 0x2b, 0xa5, 0x4f, 0xf5, 0x3a, 0x5f, 0x1d, 0x36, 0xf1, 0x51, 0x0e, 0x52, 0x7f, 0xad, 0xe6, 0x82, 0xd1, 0x9b, 0x05, 0x68, 0x8c, 0x2b, 0x3e, 0x6c, 0x1f, 0x1f, 0x83, 0xd9, 0xab, 0xfb, 0x41, 0xbd, 0x6b, 0x5b, 0xe0, 0xcd, 0x19, 0x13, 0x7e, 0x21, 0x79 }; void sha256_inc_init(uint8_t *state) { for (size_t i = 0; i < 32; ++i) { state[i] = iv_256[i]; } for (size_t i = 32; i < 40; ++i) { state[i] = 0; } } void sha512_inc_init(uint8_t *state) { for (size_t i = 0; i < 64; ++i) { state[i] = iv_512[i]; } for (size_t i = 64; i < 72; ++i) { state[i] = 0; } } void sha256_inc_blocks(uint8_t *state, const uint8_t *in, size_t inblocks) { uint64_t bytes = load_bigendian_64(state + 32); crypto_hashblocks_sha256(state, in, 64 * inblocks); bytes += 64 * inblocks; store_bigendian_64(state + 32, bytes); } void sha512_inc_blocks(uint8_t *state, const uint8_t *in, size_t inblocks) { uint64_t bytes = load_bigendian_64(state + 64); crypto_hashblocks_sha512(state, in, 128 * inblocks); bytes += 128 * inblocks; store_bigendian_64(state + 64, bytes); } void sha256_inc_finalize(uint8_t *out, uint8_t *state, const uint8_t *in, size_t inlen) { uint8_t padded[128]; uint64_t bytes = load_bigendian_64(state + 32) + inlen; crypto_hashblocks_sha256(state, in, inlen); in += inlen; inlen &= 63; in -= inlen; for (size_t i = 0; i < inlen; ++i) { padded[i] = in[i]; } padded[inlen] = 0x80; if (inlen < 56) { for (size_t i = inlen + 1; i < 56; ++i) { padded[i] = 0; } padded[56] = (uint8_t) (bytes >> 53); padded[57] = (uint8_t) (bytes >> 45); padded[58] = (uint8_t) (bytes >> 37); padded[59] = (uint8_t) (bytes >> 29); padded[60] = (uint8_t) (bytes >> 21); padded[61] = (uint8_t) (bytes >> 13); padded[62] = (uint8_t) (bytes >> 5); padded[63] = (uint8_t) (bytes << 3); crypto_hashblocks_sha256(state, padded, 64); } else { for (size_t i = inlen + 1; i < 120; ++i) { padded[i] = 0; } padded[120] = (uint8_t) (bytes >> 53); padded[121] = (uint8_t) (bytes >> 45); padded[122] = (uint8_t) (bytes >> 37); padded[123] = (uint8_t) (bytes >> 29); padded[124] = (uint8_t) (bytes >> 21); padded[125] = (uint8_t) (bytes >> 13); padded[126] = (uint8_t) (bytes >> 5); padded[127] = (uint8_t) (bytes << 3); crypto_hashblocks_sha256(state, padded, 128); } for (size_t i = 0; i < 32; ++i) { out[i] = state[i]; } } void sha512_inc_finalize(uint8_t *out, uint8_t *state, const uint8_t *in, size_t inlen) { uint8_t padded[256]; uint64_t bytes = load_bigendian_64(state + 64) + inlen; crypto_hashblocks_sha512(state, in, inlen); in += inlen; inlen &= 127; in -= inlen; for (size_t i = 0; i < inlen; ++i) { padded[i] = in[i]; } padded[inlen] = 0x80; if (inlen < 112) { for (size_t i = inlen + 1; i < 119; ++i) { padded[i] = 0; } padded[119] = (uint8_t) (bytes >> 61); padded[120] = (uint8_t) (bytes >> 53); padded[121] = (uint8_t) (bytes >> 45); padded[122] = (uint8_t) (bytes >> 37); padded[123] = (uint8_t) (bytes >> 29); padded[124] = (uint8_t) (bytes >> 21); padded[125] = (uint8_t) (bytes >> 13); padded[126] = (uint8_t) (bytes >> 5); padded[127] = (uint8_t) (bytes << 3); crypto_hashblocks_sha512(state, padded, 128); } else { for (size_t i = inlen + 1; i < 247; ++i) { padded[i] = 0; } padded[247] = (uint8_t) (bytes >> 61); padded[248] = (uint8_t) (bytes >> 53); padded[249] = (uint8_t) (bytes >> 45); padded[250] = (uint8_t) (bytes >> 37); padded[251] = (uint8_t) (bytes >> 29); padded[252] = (uint8_t) (bytes >> 21); padded[253] = (uint8_t) (bytes >> 13); padded[254] = (uint8_t) (bytes >> 5); padded[255] = (uint8_t) (bytes << 3); crypto_hashblocks_sha512(state, padded, 256); } for (size_t i = 0; i < 64; ++i) { out[i] = state[i]; } } void sha256(uint8_t *out, const uint8_t *in, size_t inlen) { uint8_t state[40]; sha256_inc_init(state); sha256_inc_finalize(out, state, in, inlen); } void sha512(uint8_t *out, const uint8_t *in, size_t inlen) { uint8_t state[72]; sha512_inc_init(state); sha512_inc_finalize(out, state, in, inlen); } /** * Note that inlen should be sufficiently small that it still allows for * an array to be allocated on the stack. Typically 'in' is merely a seed. * Outputs outlen number of bytes */ void mgf1_sha256(unsigned char *out, unsigned long outlen, const unsigned char *in, unsigned long inlen) { unsigned char inbuf[inlen + 4]; unsigned char outbuf[SPX_SHA256_OUTPUT_BYTES]; unsigned long i; memcpy(inbuf, in, inlen); /* While we can fit in at least another full block of SHA256 output.. */ for (i = 0; (i+1)*SPX_SHA256_OUTPUT_BYTES <= outlen; i++) { u32_to_bytes(inbuf + inlen, i); sha256(out, inbuf, inlen + 4); out += SPX_SHA256_OUTPUT_BYTES; } /* Until we cannot anymore, and we fill the remainder. */ if (outlen > i*SPX_SHA256_OUTPUT_BYTES) { u32_to_bytes(inbuf + inlen, i); sha256(outbuf, inbuf, inlen + 4); memcpy(out, outbuf, outlen - i*SPX_SHA256_OUTPUT_BYTES); } } void mgf1_sha512(unsigned char *out, unsigned long outlen, const unsigned char *in, unsigned long inlen) { unsigned char inbuf[inlen + 4]; unsigned char outbuf[SPX_SHA512_OUTPUT_BYTES]; unsigned long i; memcpy(inbuf, in, inlen); /* While we can fit in at least another full block of SHA512 output.. */ for (i = 0; (i+1)*SPX_SHA512_OUTPUT_BYTES <= outlen; i++) { u32_to_bytes(inbuf + inlen, i); sha512(out, inbuf, inlen + 4); out += SPX_SHA512_OUTPUT_BYTES; } /* Until we cannot anymore, and we fill the remainder. */ if (outlen > i*SPX_SHA512_OUTPUT_BYTES) { u32_to_bytes(inbuf + inlen, i); sha512(outbuf, inbuf, inlen + 4); memcpy(out, outbuf, outlen - i*SPX_SHA512_OUTPUT_BYTES); } } void mgf1_sha256_state_init(mgf1_sha256_state_t *state, const unsigned char *pub_seed, const uint32_t addr[8]) { state->i = 0; memcpy(state->inbuf, pub_seed, SPX_N); memcpy(state->inbuf + SPX_N, addr, SPX_SHA256_ADDR_BYTES); state->used_tmp_bytes = 0; } /* assumes SPX_N = {16, 24, 32} */ void mgf1_sha256_update(unsigned char *out, mgf1_sha256_state_t* state) { if(SPX_N == SPX_SHA256_OUTPUT_BYTES) { u32_to_bytes(state->inbuf + SPX_N + SPX_SHA256_ADDR_BYTES, state->i); sha256(out, state->inbuf, SPX_N + SPX_SHA256_ADDR_BYTES + 4); state->i++; } else { if(state->used_tmp_bytes == SPX_N) { memcpy(out, state->tmp, SPX_N); state->used_tmp_bytes = 0; } else { unsigned char tmp[state->used_tmp_bytes + SPX_SHA256_OUTPUT_BYTES]; memcpy(tmp, state->tmp, state->used_tmp_bytes); u32_to_bytes(state->inbuf + SPX_N + SPX_SHA256_ADDR_BYTES, state->i); sha256(tmp + state->used_tmp_bytes, state->inbuf, SPX_N + SPX_SHA256_ADDR_BYTES + 4); state->i++; memcpy(out, tmp, SPX_N); state->used_tmp_bytes = sizeof(tmp) - SPX_N; memcpy(state->tmp, tmp + SPX_N, state->used_tmp_bytes); } } } uint8_t state_seeded[40]; /** * Absorb the constant pub_seed using one round of the compression function * This initializes state_seeded, which can then be reused in thash **/ void seed_state(const unsigned char *pub_seed) { uint8_t block[SPX_SHA256_BLOCK_BYTES]; size_t i; for (i = 0; i < SPX_N; ++i) { block[i] = pub_seed[i]; } for (i = SPX_N; i < SPX_SHA256_BLOCK_BYTES; ++i) { block[i] = 0; } sha256_inc_init(state_seeded); sha256_inc_blocks(state_seeded, block, 1); } /* * streaming */ void sha256_inc_state_init(sha256_inc_state_t *sha256_state) { sha256_inc_init(sha256_state->state); sha256_state->used_tmp_bytes = 0; } void sha256_inc_state_update(sha256_inc_state_t *sha256_state, const unsigned char *data, size_t data_len) { unsigned processed = 0; /* * first try to fill and empty buffer */ if(sha256_state->used_tmp_bytes) { // try to fill it if(sha256_state->used_tmp_bytes + data_len >= 64) { processed = 64 - sha256_state->used_tmp_bytes; memcpy(sha256_state->tmp + sha256_state->used_tmp_bytes, data, processed); sha256_inc_blocks(sha256_state->state, sha256_state->tmp, 1); sha256_state->used_tmp_bytes = 0; } else { // not enough data to fill it memcpy(sha256_state->tmp + sha256_state->used_tmp_bytes, data, data_len); sha256_state->used_tmp_bytes += data_len; return; } } // now update all remaining data unsigned num_blocks = (data_len-processed)/64; if(num_blocks) { sha256_inc_blocks(sha256_state->state, data+processed, num_blocks); processed += 64*num_blocks; } // put remaining data in tmp buffer sha256_state->used_tmp_bytes = data_len - processed; memcpy(sha256_state->tmp, data+processed, sha256_state->used_tmp_bytes); } void sha256_inc_state_finalize(sha256_inc_state_t *sha256_state, unsigned char *out) { if(SPX_N < SPX_SHA256_OUTPUT_BYTES) { unsigned char tmp[SPX_SHA256_OUTPUT_BYTES]; sha256_inc_finalize(tmp, sha256_state->state, sha256_state->tmp, sha256_state->used_tmp_bytes); memcpy(out, tmp, SPX_N); } else { sha256_inc_finalize(out, sha256_state->state, sha256_state->tmp, sha256_state->used_tmp_bytes); } } #endif
the_stack_data/39784.c
#include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> int main() { mode_t prev = umask(027); // 027 int cfopen = open("ej6.txt", O_CREAT | O_RDONLY, 0777); mode_t last = umask(prev); printf("Last: %i\n", last); return 0; }
the_stack_data/131235.c
volatile long long test() { volatile long long y = 6; volatile long long p = 7; return y + p; }
the_stack_data/150143126.c
/* * * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. * * Copyright 2007-2020 Broadcom Inc. All rights reserved. * All Rights Reserved.$ * * WLAN initializers */ #if defined(INCLUDE_L3) #include <sal/core/libc.h> #include <soc/drv.h> #include <soc/mem.h> #include <soc/l2u.h> #include <soc/util.h> #include <soc/debug.h> #include <bcm/port.h> #include <bcm/error.h> #include <bcm/wlan.h> /* * Function: * bcm_wlan_client_t_init * Purpose: * Initialize the WLAN client struct * Parameters: * wlan_vpn_config - Pointer to the struct to be init'ed */ void bcm_wlan_client_t_init(bcm_wlan_client_t *wlan_client) { if (wlan_client != NULL) { sal_memset(wlan_client, 0, sizeof(*wlan_client)); } return; } /* * Function: * bcm_wlan_port_t_init * Purpose: * Initialize the WLAN port struct * Parameters: * port_info - Pointer to the struct to be init'ed */ void bcm_wlan_port_t_init(bcm_wlan_port_t *port_info) { if (port_info != NULL) { sal_memset(port_info, 0, sizeof(*port_info)); } return; } #else typedef int _bcm_wlan_not_empty; /* Make ISO compilers happy. */ #endif /* INCLUDE_L3 */
the_stack_data/212643121.c
int main() { typedef void (*funcptr)(); (* (funcptr) (void *) 0)(); }
the_stack_data/27540.c
#include <stdio.h> #include <stdlib.h> struct Attribute { char* name; char* value; }; struct XMLNode { int child_count; struct XMLNode** children; char* tag; char* data; int attrs_count; struct Attribute** attrs; }; struct XMLNode* createNode(char* tag, char* data) { struct XMLNode* node = malloc(sizeof(struct XMLNode)); node->data = malloc(sizeof(data)); node->data = data; node->tag = malloc(sizeof(tag)); node->tag = tag; node->child_count = 0; node->children = NULL; node->attrs_count = 0; node->attrs = NULL; return node; } void addChildnode(struct XMLNode* parent, struct XMLNode* child) { parent->child_count++; parent->children = realloc(parent->children, parent->child_count * sizeof(struct XMLNode*)); parent->children[parent->child_count-1] = child; }; void generateXML(struct XMLNode* node, int nesting_level) { printf("<%s", node->tag); for (int i = 0; i < node->attrs_count; i++) { struct Attribute* attr = node->attrs[i]; printf("1"); printf(" %s=\"%s\"", attr->name, attr->value); } printf(">"); if (node->data) printf("%s", node->data); for (int i = 0; i < node->child_count; i++) { generateXML(node->children[i], nesting_level+1); } printf("</%s>", node->tag); }; void freeTree(struct XMLNode* root) { for (int i = 0; i < root->child_count; i++) freeTree(root->children[i]); for (int i = 0; i < root->attrs_count; i++) free(root->attrs[i]); free(root); } void addAttribute(struct XMLNode* node, struct Attribute* attr) { node->attrs_count++; node->attrs = realloc(node->attrs, node->attrs_count * sizeof(struct Attribute*)); node->attrs[node->attrs_count-1] = attr; }; struct Attribute* createAttribute(char* name, char* value) { struct Attribute* attr = malloc(sizeof(struct Attribute)); attr->name = malloc(sizeof(name)); attr->name = name; attr->value = malloc(sizeof(value)); attr->value = value; return attr; };
the_stack_data/25136652.c
// RUN: rm -rf %t* // RUN: 3c -base-dir=%S -addcr -alltypes -output-dir=%t.checkedALL2 %S/arrstructcalleemulti1.c %s -- // RUN: 3c -base-dir=%S -addcr -output-dir=%t.checkedNOALL2 %S/arrstructcalleemulti1.c %s -- // RUN: %clang -working-directory=%t.checkedNOALL2 -c arrstructcalleemulti1.c arrstructcalleemulti2.c // RUN: FileCheck -match-full-lines -check-prefixes="CHECK_NOALL","CHECK" --input-file %t.checkedNOALL2/arrstructcalleemulti2.c %s // RUN: FileCheck -match-full-lines -check-prefixes="CHECK_ALL","CHECK" --input-file %t.checkedALL2/arrstructcalleemulti2.c %s // RUN: 3c -base-dir=%S -alltypes -output-dir=%t.checked %S/arrstructcalleemulti1.c %s -- // RUN: 3c -base-dir=%t.checked -alltypes -output-dir=%t.convert_again %t.checked/arrstructcalleemulti1.c %t.checked/arrstructcalleemulti2.c -- // RUN: test ! -f %t.convert_again/arrstructcalleemulti1.c // RUN: test ! -f %t.convert_again/arrstructcalleemulti2.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 arrstructprotocallee.c and arrstructcallee.c except in that the callee and callers are split amongst two files to see how the tool performs conversions*/ /*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]; }; static int add1(int x) { //CHECK: static int add1(int x) _Checked { return x + 1; } static int sub1(int x) { //CHECK: static int sub1(int x) _Checked { return x - 1; } static int fact(int n) { //CHECK: static int fact(int n) _Checked { if (n == 0) { return 1; } return n * fact(n - 1); } static int fib(int n) { //CHECK: static int fib(int n) _Checked { if (n == 0) { return 0; } if (n == 1) { return 1; } return fib(n - 1) + fib(n - 2); } static int zerohuh(int n) { //CHECK: static int zerohuh(int n) _Checked { return !n; } static int *mul2(int *x) { //CHECK: static _Ptr<int> mul2(_Ptr<int> x) _Checked { *x *= 2; return x; } 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> __3c_lower_bound_z : count(5) = calloc<int>(5, sizeof(int)); //CHECK_ALL: _Array_ptr<int> z : bounds(__3c_lower_bound_z, __3c_lower_bound_z + 5) = __3c_lower_bound_z; 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/1176466.c
// Test that target feature mops is implemented and available correctly // RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.7-a+mops %s 2>&1 | FileCheck %s // RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.8-a %s 2>&1 | FileCheck %s // RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.8-a+mops %s 2>&1 | FileCheck %s // RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.8-a+nomops %s 2>&1 | FileCheck %s --check-prefix=NO_MOPS // RUN: %clang -### -target aarch64-none-none-eabi -march=armv9.2-a+mops %s 2>&1 | FileCheck %s // RUN: %clang -### -target aarch64-none-none-eabi -march=armv9.3-a %s 2>&1 | FileCheck %s // RUN: %clang -### -target aarch64-none-none-eabi -march=armv9.3-a+mops %s 2>&1 | FileCheck %s // RUN: %clang -### -target aarch64-none-none-eabi -march=armv9.3-a+nomops %s 2>&1 | FileCheck %s --check-prefix=NO_MOPS // CHECK: "-target-feature" "+mops" // NO_MOPS: "-target-feature" "-mops"
the_stack_data/178266765.c
#include <errno.h> #include <sys/mman.h> int msync(void* start, size_t len, int flags) { errno = ENOSYS; return -1; }
the_stack_data/68844.c
#include<stdio.h> #include<stdbool.h> #include<limits.h> #define max(a,b) (a>b?a:b) #define min(a,b) (a<b?a:b) void swap(int *a,int *b) { int temp; temp = *a; *a = *b; *b = temp; //xor swapping isn't working in this case. why? } int main() { #ifndef ONLINE_JUDGE //for getting input from input.txt freopen("input.txt","r",stdin); //for writing output to output.txt freopen("output.txt","w",stdout); #endif int n; scanf("%d",&n); int arr[n][n]; for(int i=0;i<n;i++) { for(int j=0;j<n;j++) scanf("%d",&arr[i][j]); } /*for(int i=0;i<n;i++) { for(int j=0;j<n;j++) printf("%d ",arr[i][j]); printf("\n"); }*/ int answer=0; for(int i=0;i<n;i++) for(int j=0;j<n;j++) for(int r=i;r<n;r++) for(int c=j;c<n;c++) { //one sub matrix ready int oneCount=0; for(int l1=i;l1<=r;l1++) for(int l2=j;l2<=c;l2++) //printf("%d ",arr[l1][l2]); printf("\n"); if(arr[l1][l2]==1) oneCount++; if(oneCount==1) answer++; } printf("%d \n",answer); return 0; }
the_stack_data/446166.c
#include<stdio.h> #include<math.h> /* TASK: intro01 AUTHOR: Ice SCHOOL: RYW LANG: C */ int main () { double a,b; scanf("%lf %lf",&a,&b); printf("Plus: %.2lf\n",a+b); printf("Minus: %.2lf\n",a-b); printf("Multiply: %.2lf\n",a*b); printf("Divide: %.2lf\n",a/b); printf("Modulo: %.2lf\n",fmod(a,b)); printf("Power: %.2lf\n",pow(a,b)); printf("Root: %.2lf\n",pow(a,1/b)); }
the_stack_data/606334.c
#include <stdio.h> int main(){ int num, soma,media; soma = 0; for (int i = 0; i < 10; i++){ printf("Digite um numero\n"); scanf("%d%*c",&num); soma=soma+num; } media=soma/10; printf("A soma dos 10 numeros é:%d\n",soma); printf("A media dos 10 numeros é:%d\n", media); }
the_stack_data/31387432.c
#include <stdio.h> #include <string.h> #include <unistd.h> #include <termios.h> int main(void) { char mypass[] = "super-secret"; char buffer[80]; struct termios term; /* get the current settings */ tcgetattr(STDIN_FILENO, &term); /* disable echoing */ term.c_lflag = term.c_lflag & ~ECHO; tcsetattr(STDIN_FILENO, TCSAFLUSH, &term); printf("Enter password: "); scanf("%s", buffer); if ( (strcmp(mypass, buffer) == 0) ) { printf("\nCorrect password, welcome!\n"); } else { printf("\nIncorrect password, go away!\n");; } /* re-enable echoing */ term.c_lflag = term.c_lflag | ECHO; tcsetattr(STDIN_FILENO, TCSAFLUSH, &term); return 0; }
the_stack_data/184517745.c
/* FIXME: This function requires that the <f> array contain exactly 1024 elements. It means a score creating this array with a makegen would have to size it as 1024. (E.g., IIR's BUZZ inst.) Should add another arg that gives size of array. -JGG */ #define ABS(x) ((x < 0) ? (-x) : (x)) #define EPS .1e-06 float buzz(float amp, float si, float hn, double *f, float *phs) { register int j; long k; float q,d,h2n,h2np1; j = *phs; k = (j+1) % 1024; h2n = 2. * hn; h2np1 = h2n + 1.; q = (int)((*phs - (float)j) * h2np1)/h2np1; d = *(f+j); d += (*(f+k)-d)*q; if(ABS(d) < EPS) q = amp; else { k = (long)(h2np1 * *phs) % 1024; q = amp * (*(f+k)/d - 1.)/h2n; } *phs += si; while(*phs >= 1024.) *phs -= 1024.; return(q); }
the_stack_data/86074448.c
/* OpenCoarrays is distributed under the OSI-approved BSD 3-clause License: OpenCoarrays -- ISO_Fortran_binding standard-compliant interoperability with C. Copyright (c) 2018, Sourcery, Inc. Copyright (c) 2018, Sourcery Institute 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 names of the copyright holders nor the names of their 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 HOLDERS 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 "ISO_Fortran_binding.h" #include <stdio.h> #include <stdlib.h> int CFI_deallocate (CFI_cdesc_t *dv) { /* C Descriptor must not be NULL */ if (dv == NULL) { fprintf (stderr, "ISO_Fortran_binding.c: CFI_deallocate: C Descriptor. " "is NULL. (Error No. %d).\n", CFI_INVALID_DESCRIPTOR); return CFI_INVALID_DESCRIPTOR; } /* Base address must not be NULL. */ if (dv->base_addr == NULL) { fprintf (stderr, "ISO_Fortran_binding.c: CFI_deallocate: Base address is " "NULL already. (Error No. %d).\n", CFI_ERROR_BASE_ADDR_NULL); return CFI_ERROR_BASE_ADDR_NULL; } /* C Descriptor must be for an allocatable or pointer variable. */ if (dv->attribute == CFI_attribute_other) { fprintf (stderr, "ISO_Fortran_binding.c: CFI_deallocate: C Descriptor " "must describe a pointer or allocatabale object. (Error " "No. %d).\n", CFI_INVALID_ATTRIBUTE); return CFI_INVALID_ATTRIBUTE; } /* Free and nullify memory. */ free (dv->base_addr); dv->base_addr = NULL; return CFI_SUCCESS; }
the_stack_data/48576572.c
#include <stdio.h> #include <stdlib.h> #include <string.h> #define BYTES 256 struct huffcode { int nbits; int code; }; typedef struct huffcode huffcode_t; struct huffheap { int *h; int n, s, cs; long *f; }; typedef struct huffheap heap_t; /* heap handling funcs */ static heap_t *_heap_create(int s, long *f) { heap_t *h; h = malloc(sizeof(heap_t)); h->h = malloc(sizeof(int)*s); h->s = h->cs = s; h->n = 0; h->f = f; return h; } static void _heap_destroy(heap_t *heap) { free(heap->h); free(heap); } #define swap_(I,J) do { int t_; t_ = a[(I)]; \ a[(I)] = a[(J)]; a[(J)] = t_; } while(0) static void _heap_sort(heap_t *heap) { int i=1, j=2; /* gnome sort */ int *a = heap->h; while(i < heap->n) { /* smaller values are kept at the end */ if ( heap->f[a[i-1]] >= heap->f[a[i]] ) { i = j; j++; } else { swap_(i-1, i); i--; i = (i==0) ? j++ : i; } } } #undef swap_ static void _heap_add(heap_t *heap, int c) { if ( (heap->n + 1) > heap->s ) { heap->h = realloc(heap->h, heap->s + heap->cs); heap->s += heap->cs; } heap->h[heap->n] = c; heap->n++; _heap_sort(heap); } static int _heap_remove(heap_t *heap) { if ( heap->n > 0 ) { heap->n--; return heap->h[heap->n]; } return -1; } /* huffmann code generator */ huffcode_t **create_huffman_codes(long *freqs) { huffcode_t **codes; heap_t *heap; long efreqs[BYTES*2]; int preds[BYTES*2]; int i, extf=BYTES; int r1, r2; memcpy(efreqs, freqs, sizeof(long)*BYTES); memset(&efreqs[BYTES], 0, sizeof(long)*BYTES); heap = _heap_create(BYTES*2, efreqs); if ( heap == NULL ) return NULL; for(i=0; i < BYTES; i++) if ( efreqs[i] > 0 ) _heap_add(heap, i); while( heap->n > 1 ) { r1 = _heap_remove(heap); r2 = _heap_remove(heap); efreqs[extf] = efreqs[r1] + efreqs[r2]; _heap_add(heap, extf); preds[r1] = extf; preds[r2] = -extf; extf++; } r1 = _heap_remove(heap); preds[r1] = r1; _heap_destroy(heap); codes = malloc(sizeof(huffcode_t *)*BYTES); int bc, bn, ix; for(i=0; i < BYTES; i++) { bc=0; bn=0; if ( efreqs[i] == 0 ) { codes[i] = NULL; continue; } ix = i; while( abs(preds[ix]) != ix ) { bc |= ((preds[ix] >= 0) ? 1 : 0 ) << bn; ix = abs(preds[ix]); bn++; } codes[i] = malloc(sizeof(huffcode_t)); codes[i]->nbits = bn; codes[i]->code = bc; } return codes; } void free_huffman_codes(huffcode_t **c) { int i; for(i=0; i < BYTES; i++) free(c[i]); free(c); } #define MAXBITSPERCODE 100 void inttobits(int c, int n, char *s) { s[n] = 0; while(n > 0) { s[n-1] = (c%2) + '0'; c >>= 1; n--; } } const char *test = "this is an example for huffman encoding"; int main() { huffcode_t **r; int i; char strbit[MAXBITSPERCODE]; const char *p; long freqs[BYTES]; memset(freqs, 0, sizeof freqs); p = test; while(*p != '\0') freqs[*p++]++; r = create_huffman_codes(freqs); for(i=0; i < BYTES; i++) { if ( r[i] != NULL ) { inttobits(r[i]->code, r[i]->nbits, strbit); printf("%c (%d) %s\n", i, r[i]->code, strbit); } } free_huffman_codes(r); return 0; }
the_stack_data/184518753.c
// RUN: %layout_check %s int ent1[][2] = { {1}, 2, 3, {4}, 5, {6}, {7} };
the_stack_data/90766671.c
#include <malloc.h> char *xalloc (int nb) { return (char*) galloc ( nb ); } void xfree (char *ap) { gfree ( ap ); return; }
the_stack_data/31388424.c
/* @(#)fgetc.c 1.2 */ /* 3.0 SID # 1.2 */ /*LINTLIBRARY*/ #include "stdio.h" int fgetc(fp) register FILE *fp; { return(getc(fp)); }
the_stack_data/106429.c
// Write a declaration of an array called "weekend" // which will contain 7 bools, first and last should be true, the rest false. // kind of exercise 4 tbh. #include<stdio.h> #include<stdlib.h> #include<stdbool.h> int main(void) { bool weekend[7] = {[0] = 1, [6] = 1}; printf("Here are the values of the array: \n"); for (int i = 0; i < 7; i++) printf("%d",weekend[i]); printf("\n"); return 0; }
the_stack_data/67852.c
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <sys/wait.h> int main() { int i, child, sum=0; for(i=0; i<20; i++) { child = fork(); if(child == 0) { sum += 1; printf("Child %d sum %d\n", i, sum); exit(0); } } for(i=0; i<20; i++) { wait(0); } printf("Parent sum %d\n", sum); return 0; }
the_stack_data/14199559.c
#include <stdio.h> unsigned ojler(unsigned a); int main(){ unsigned a; scanf("%u", &a); printf("%u\n", ojler(a)); return 0; }
the_stack_data/173579085.c
#include <stdio.h> #include <stdlib.h> int main(){ int *ip = (int *)malloc(sizeof(int)*10); int *ap; int a = 12; *(ip+0) = a; ap = &a; printf("%d->%d, %d, %X", *ip, a, *ap, ap); *ap = 21; printf("\n%d", a); return 0; }
the_stack_data/168892952.c
#include <stdio.h> #include <stdlib.h> // For exit() function int main() { char c; FILE *fptr; char path[100]; int lineNum = 1; printf("Enter the path of the file: "); scanf("%s", path); if ((fptr = fopen(path, "r")) == NULL) { printf("Error! opening file"); // Program exits if file pointer returns NULL. exit(1); } printf("Line %d: ", lineNum++); while ((c = fgetc(fptr)) != EOF) { printf("%c", c); if (c == '\n') printf("Line %d: ", lineNum++); } fclose(fptr); return 0; }
the_stack_data/201882.c
// Solved 2020-12-28 10:19 // Runtime: 200 ms (96.15%) // Memory Usage: 34.7 MB (84.62%) /** * Note: The returned array must be malloced, assume caller calls free(). */ int* circularPermutation(int n, int start, int* returnSize) { int* ans = (int*)malloc((*returnSize = (1 << n)) * sizeof(int)); for (unsigned i = 0; i < (1 << n); i++) { ans[i] = start ^ (i ^ (i >> 1)); // modified gray code // https://en.wikipedia.org/wiki/Gray_code#Converting_to_and_from_Gray_code } return ans; }
the_stack_data/28556.c
/* bibliotecas */ #include <stdio.h> /* variaveis */ int i = 0; /* corpo do programa */ int main(){ printf("\n\n Multiplos de 3 entre 0 e 100: "); for ( i ; i <= 100 ; i++ ) { if ( i % 3 == 0 ){ printf(" -> %i", i); } } getch(); return (0); }
the_stack_data/76699559.c
#include <stdio.h> int maximum(int A[], int n){ int mx = A[0]; for (int i = 1; i < n; i++) { if(mx < A[i]){ mx = A[i]; } } return mx; } int minimum(int A[], int n){ int mn = A[0]; for (int i = 1; i < n; i++) { if(mn > A[i]){ mn = A[i]; } } return mn; } // Main function (execute first) int main(){ int A[] = {1, 3, 4, 1}; int size = (sizeof(A)/sizeof(int)); // below line print the sum printf("%d",minimum(A, size) + maximum(A, size) ); return 0; }
the_stack_data/32949514.c
// (C) 2021 Quenio. Licensed under CC0 1.0: https://creativecommons.org/publicdomain/zero/1.0 #include <stdio.h> int main() { float fahrenheit = 0; float celsius = (fahrenheit - 32) * 0.55; printf("%fF -> %fC\n", fahrenheit, celsius); }
the_stack_data/82950228.c
#include <stdio.h> #include <math.h> int main() { double A, B, C, R1, R2, delta; A = B = C = R1 = R2 = 0; scanf("%lf %lf %lf", &A, &B, &C); delta = pow(B, 2) - (4 * A * C); if(delta < 1 || A < 1) { printf("Impossivel calcular\n"); } else { R1 = ((B * -1) + sqrt(delta))/(2*A); R2 = ((B * -1) - sqrt(delta))/(2*A); printf("R1 = %0.5lf\n", R1); printf("R2 = %0.5lf\n", R2); } }
the_stack_data/36792.c
int main() { int a, b; switch (1) { case 0: return 3; case 2: a = 2; return 4; case 1: a = 4; b = 9; return 5; default: a = 3; b = 5; return 6; } return 7; }
the_stack_data/119565.c
/* Author: Amitrajit Bose CSE 3A (13) Floyd Warshall Algorithm */ #include <stdlib.h> #include <stdio.h> #define MAX 10 #define INF 9999 #define for(i,a,b) for(i=a;i<=b;i++) int min(int x,int y){ return (x>y)?y:x; } int main() { int D[MAX][MAX],P[MAX][MAX]; int n,i,j,k; printf("Enter Total Vertices: "); scanf("%d ",&n); //initialising W and D for(i,1,n){ for(j,1,n){ D[i][j]=INF; P[i][j]=INF; if(i==j){ D[i][j]=0; P[i][j]=0; } } } //taking input in the array D printf("**VERTEX INDEX STARTS FROM 1**\n**PRESS 0 0 TO STOP**\n"); printf("**ENTER START INDEX, END INDEX**\n"); printf("**EDGE WEIGHT**\n"); while(1) { scanf("%d %d",&i,&j); scanf("%d ",&D[i][j]); P[i][j]=D[i][j]; if(i==0 || j==0) break; } /* PRINT WEIGHTED MATRIX for(i,1,n){ for(j,1,n){ printf("%d ",D[i][j]); } printf("\n"); } */ for(k,1,n){ for(i,1,n){ for(j,1,n){ if(i!=k || j!=k) P[i][j]=min(D[i][j],(D[i][k]+D[k][j])); } } for(i,1,n){ for(j,1,n){ D[i][j]=P[i][j]; } } } printf("\nDISTANCE MATRIX\n"); for(i,1,n){ for(j,1,n){ printf("%d ",D[i][j]); } printf("\n"); } return 0; }
the_stack_data/62638923.c
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <sys/wait.h> void system_command(const char *command) { pid_t pid = fork(); if (pid == 0) execl ("/bin/bash", "bash", "-c", command, NULL); else waitpid (pid, NULL, 0); } int main(int argc, char **argv) { int i; for (i = 1; i < argc; i++) { system_command (argv[i]); printf ("\n"); } return 0; }
the_stack_data/359737.c
/* ACM 10161 Ant on a Chessboard * mythnc * 2011/11/26 16:49:42 * run time: 0.004 */ #include <stdio.h> #include <math.h> void output(int); int main(void) { int x; while (scanf("%d", &x) && x != 0) output(x); return 0; } /* output: output answer */ void output(int x) { int n, value; if (x == 1) { printf("1 1\n"); return; } n = sqrt(x); /* if x is a square number */ if (n * n == x) { if (n % 2 == 1) printf("%d %d\n", 1, n); else printf("%d %d\n", n, 1); return; } /* if x bigger than a square number n */ value = x - n * n; if (value == n + 1) printf("%d %d\n", n + 1, n + 1); else if (value < n + 1) if (n % 2 == 1) printf("%d %d\n", value, n + 1); else printf("%d %d\n", n + 1, value); else if (n % 2 == 1) printf("%d %d\n", n + 1, 2 * n - value + 2); else printf("%d %d\n", 2 * n - value + 2, n + 1); }
the_stack_data/140765590.c
extern void abort(void); void test(int *ptr) { int i = 1; goto useless; if (0) { useless: i = 0; } else i = 1; *ptr = i; } int main() { int i = 1; test(&i); if (i) abort (); return 0; }
the_stack_data/97012757.c
#include <stdio.h> int main(){ int n, i, a; float m = 0; i=0; scanf("%d", &n); while(n != 0){ a=n%10; m+=a; n=n/10; i++; } m = m/i; if(m > 7){ printf(" heavy\n"); }else{ printf(" light\n"); } return 0; }
the_stack_data/1129838.c
// possible deadlock in xfrm_policy_lookup_bytype // https://syzkaller.appspot.com/bug?id=4cbd5e3669aee5ac5149 // status:3 // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include <arpa/inet.h> #include <endian.h> #include <errno.h> #include <fcntl.h> #include <net/if.h> #include <net/if_arp.h> #include <netinet/in.h> #include <sched.h> #include <setjmp.h> #include <signal.h> #include <stdarg.h> #include <stdbool.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/ioctl.h> #include <sys/mount.h> #include <sys/prctl.h> #include <sys/resource.h> #include <sys/socket.h> #include <sys/stat.h> #include <sys/syscall.h> #include <sys/time.h> #include <sys/types.h> #include <sys/wait.h> #include <unistd.h> #include <linux/capability.h> #include <linux/if_addr.h> #include <linux/if_ether.h> #include <linux/if_link.h> #include <linux/if_tun.h> #include <linux/in6.h> #include <linux/ip.h> #include <linux/neighbour.h> #include <linux/net.h> #include <linux/netlink.h> #include <linux/rtnetlink.h> #include <linux/tcp.h> #include <linux/veth.h> static __thread int skip_segv; static __thread jmp_buf segv_env; static void segv_handler(int sig, siginfo_t* info, void* ctx) { uintptr_t addr = (uintptr_t)info->si_addr; const uintptr_t prog_start = 1 << 20; const uintptr_t prog_end = 100 << 20; int skip = __atomic_load_n(&skip_segv, __ATOMIC_RELAXED) != 0; int valid = addr < prog_start || addr > prog_end; if (skip && valid) { _longjmp(segv_env, 1); } exit(sig); } static void install_segv_handler(void) { struct sigaction sa; memset(&sa, 0, sizeof(sa)); sa.sa_handler = SIG_IGN; syscall(SYS_rt_sigaction, 0x20, &sa, NULL, 8); syscall(SYS_rt_sigaction, 0x21, &sa, NULL, 8); memset(&sa, 0, sizeof(sa)); sa.sa_sigaction = segv_handler; sa.sa_flags = SA_NODEFER | SA_SIGINFO; sigaction(SIGSEGV, &sa, NULL); sigaction(SIGBUS, &sa, NULL); } #define NONFAILING(...) \ { \ __atomic_fetch_add(&skip_segv, 1, __ATOMIC_SEQ_CST); \ if (_setjmp(segv_env) == 0) { \ __VA_ARGS__; \ } \ __atomic_fetch_sub(&skip_segv, 1, __ATOMIC_SEQ_CST); \ } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static bool write_file(const char* file, const char* what, ...) { char buf[1024]; va_list args; va_start(args, what); vsnprintf(buf, sizeof(buf), what, args); va_end(args); buf[sizeof(buf) - 1] = 0; int len = strlen(buf); int fd = open(file, O_WRONLY | O_CLOEXEC); if (fd == -1) return false; if (write(fd, buf, len) != len) { int err = errno; close(fd); errno = err; return false; } close(fd); return true; } struct nlmsg { char* pos; int nesting; struct nlattr* nested[8]; char buf[1024]; }; static struct nlmsg nlmsg; static void netlink_init(struct nlmsg* nlmsg, int typ, int flags, const void* data, int size) { memset(nlmsg, 0, sizeof(*nlmsg)); struct nlmsghdr* hdr = (struct nlmsghdr*)nlmsg->buf; hdr->nlmsg_type = typ; hdr->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK | flags; memcpy(hdr + 1, data, size); nlmsg->pos = (char*)(hdr + 1) + NLMSG_ALIGN(size); } static void netlink_attr(struct nlmsg* nlmsg, int typ, const void* data, int size) { struct nlattr* attr = (struct nlattr*)nlmsg->pos; attr->nla_len = sizeof(*attr) + size; attr->nla_type = typ; memcpy(attr + 1, data, size); nlmsg->pos += NLMSG_ALIGN(attr->nla_len); } static int netlink_send_ext(struct nlmsg* nlmsg, int sock, uint16_t reply_type, int* reply_len) { if (nlmsg->pos > nlmsg->buf + sizeof(nlmsg->buf) || nlmsg->nesting) exit(1); struct nlmsghdr* hdr = (struct nlmsghdr*)nlmsg->buf; hdr->nlmsg_len = nlmsg->pos - nlmsg->buf; struct sockaddr_nl addr; memset(&addr, 0, sizeof(addr)); addr.nl_family = AF_NETLINK; unsigned n = sendto(sock, nlmsg->buf, hdr->nlmsg_len, 0, (struct sockaddr*)&addr, sizeof(addr)); if (n != hdr->nlmsg_len) exit(1); n = recv(sock, nlmsg->buf, sizeof(nlmsg->buf), 0); if (reply_len) *reply_len = 0; if (hdr->nlmsg_type == NLMSG_DONE) return 0; if (n < sizeof(struct nlmsghdr)) exit(1); if (reply_len && hdr->nlmsg_type == reply_type) { *reply_len = n; return 0; } if (n < sizeof(struct nlmsghdr) + sizeof(struct nlmsgerr)) exit(1); if (hdr->nlmsg_type != NLMSG_ERROR) exit(1); return -((struct nlmsgerr*)(hdr + 1))->error; } static int netlink_send(struct nlmsg* nlmsg, int sock) { return netlink_send_ext(nlmsg, sock, 0, NULL); } static void netlink_device_change(struct nlmsg* nlmsg, int sock, const char* name, bool up, const char* master, const void* mac, int macsize, const char* new_name) { struct ifinfomsg hdr; memset(&hdr, 0, sizeof(hdr)); if (up) hdr.ifi_flags = hdr.ifi_change = IFF_UP; hdr.ifi_index = if_nametoindex(name); netlink_init(nlmsg, RTM_NEWLINK, 0, &hdr, sizeof(hdr)); if (new_name) netlink_attr(nlmsg, IFLA_IFNAME, new_name, strlen(new_name)); if (master) { int ifindex = if_nametoindex(master); netlink_attr(nlmsg, IFLA_MASTER, &ifindex, sizeof(ifindex)); } if (macsize) netlink_attr(nlmsg, IFLA_ADDRESS, mac, macsize); int err = netlink_send(nlmsg, sock); (void)err; } static int netlink_add_addr(struct nlmsg* nlmsg, int sock, const char* dev, const void* addr, int addrsize) { struct ifaddrmsg hdr; memset(&hdr, 0, sizeof(hdr)); hdr.ifa_family = addrsize == 4 ? AF_INET : AF_INET6; hdr.ifa_prefixlen = addrsize == 4 ? 24 : 120; hdr.ifa_scope = RT_SCOPE_UNIVERSE; hdr.ifa_index = if_nametoindex(dev); netlink_init(nlmsg, RTM_NEWADDR, NLM_F_CREATE | NLM_F_REPLACE, &hdr, sizeof(hdr)); netlink_attr(nlmsg, IFA_LOCAL, addr, addrsize); netlink_attr(nlmsg, IFA_ADDRESS, addr, addrsize); return netlink_send(nlmsg, sock); } static void netlink_add_addr4(struct nlmsg* nlmsg, int sock, const char* dev, const char* addr) { struct in_addr in_addr; inet_pton(AF_INET, addr, &in_addr); int err = netlink_add_addr(nlmsg, sock, dev, &in_addr, sizeof(in_addr)); (void)err; } static void netlink_add_addr6(struct nlmsg* nlmsg, int sock, const char* dev, const char* addr) { struct in6_addr in6_addr; inet_pton(AF_INET6, addr, &in6_addr); int err = netlink_add_addr(nlmsg, sock, dev, &in6_addr, sizeof(in6_addr)); (void)err; } static void netlink_add_neigh(struct nlmsg* nlmsg, int sock, const char* name, const void* addr, int addrsize, const void* mac, int macsize) { struct ndmsg hdr; memset(&hdr, 0, sizeof(hdr)); hdr.ndm_family = addrsize == 4 ? AF_INET : AF_INET6; hdr.ndm_ifindex = if_nametoindex(name); hdr.ndm_state = NUD_PERMANENT; netlink_init(nlmsg, RTM_NEWNEIGH, NLM_F_EXCL | NLM_F_CREATE, &hdr, sizeof(hdr)); netlink_attr(nlmsg, NDA_DST, addr, addrsize); netlink_attr(nlmsg, NDA_LLADDR, mac, macsize); int err = netlink_send(nlmsg, sock); (void)err; } static int tunfd = -1; #define TUN_IFACE "syz_tun" #define LOCAL_MAC 0xaaaaaaaaaaaa #define REMOTE_MAC 0xaaaaaaaaaabb #define LOCAL_IPV4 "172.20.20.170" #define REMOTE_IPV4 "172.20.20.187" #define LOCAL_IPV6 "fe80::aa" #define REMOTE_IPV6 "fe80::bb" #define IFF_NAPI 0x0010 static void initialize_tun(void) { tunfd = open("/dev/net/tun", O_RDWR | O_NONBLOCK); if (tunfd == -1) { printf("tun: can't open /dev/net/tun: please enable CONFIG_TUN=y\n"); printf("otherwise fuzzing or reproducing might not work as intended\n"); return; } const int kTunFd = 240; if (dup2(tunfd, kTunFd) < 0) exit(1); close(tunfd); tunfd = kTunFd; struct ifreq ifr; memset(&ifr, 0, sizeof(ifr)); strncpy(ifr.ifr_name, TUN_IFACE, IFNAMSIZ); ifr.ifr_flags = IFF_TAP | IFF_NO_PI; if (ioctl(tunfd, TUNSETIFF, (void*)&ifr) < 0) { exit(1); } char sysctl[64]; sprintf(sysctl, "/proc/sys/net/ipv6/conf/%s/accept_dad", TUN_IFACE); write_file(sysctl, "0"); sprintf(sysctl, "/proc/sys/net/ipv6/conf/%s/router_solicitations", TUN_IFACE); write_file(sysctl, "0"); int sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); if (sock == -1) exit(1); netlink_add_addr4(&nlmsg, sock, TUN_IFACE, LOCAL_IPV4); netlink_add_addr6(&nlmsg, sock, TUN_IFACE, LOCAL_IPV6); uint64_t macaddr = REMOTE_MAC; struct in_addr in_addr; inet_pton(AF_INET, REMOTE_IPV4, &in_addr); netlink_add_neigh(&nlmsg, sock, TUN_IFACE, &in_addr, sizeof(in_addr), &macaddr, ETH_ALEN); struct in6_addr in6_addr; inet_pton(AF_INET6, REMOTE_IPV6, &in6_addr); netlink_add_neigh(&nlmsg, sock, TUN_IFACE, &in6_addr, sizeof(in6_addr), &macaddr, ETH_ALEN); macaddr = LOCAL_MAC; netlink_device_change(&nlmsg, sock, TUN_IFACE, true, 0, &macaddr, ETH_ALEN, NULL); close(sock); } static void setup_common() { if (mount(0, "/sys/fs/fuse/connections", "fusectl", 0, 0)) { } } static void loop(); static void sandbox_common() { prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); setpgrp(); setsid(); struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = (200 << 20); setrlimit(RLIMIT_AS, &rlim); rlim.rlim_cur = rlim.rlim_max = 32 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 136 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); if (unshare(CLONE_NEWNS)) { } if (mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, NULL)) { } if (unshare(CLONE_NEWIPC)) { } if (unshare(0x02000000)) { } if (unshare(CLONE_NEWUTS)) { } if (unshare(CLONE_SYSVSEM)) { } typedef struct { const char* name; const char* value; } sysctl_t; static const sysctl_t sysctls[] = { {"/proc/sys/kernel/shmmax", "16777216"}, {"/proc/sys/kernel/shmall", "536870912"}, {"/proc/sys/kernel/shmmni", "1024"}, {"/proc/sys/kernel/msgmax", "8192"}, {"/proc/sys/kernel/msgmni", "1024"}, {"/proc/sys/kernel/msgmnb", "1024"}, {"/proc/sys/kernel/sem", "1024 1048576 500 1024"}, }; unsigned i; for (i = 0; i < sizeof(sysctls) / sizeof(sysctls[0]); i++) write_file(sysctls[i].name, sysctls[i].value); } static int wait_for_loop(int pid) { if (pid < 0) exit(1); int status = 0; while (waitpid(-1, &status, __WALL) != pid) { } return WEXITSTATUS(status); } static void drop_caps(void) { struct __user_cap_header_struct cap_hdr = {}; struct __user_cap_data_struct cap_data[2] = {}; cap_hdr.version = _LINUX_CAPABILITY_VERSION_3; cap_hdr.pid = getpid(); if (syscall(SYS_capget, &cap_hdr, &cap_data)) exit(1); const int drop = (1 << CAP_SYS_PTRACE) | (1 << CAP_SYS_NICE); cap_data[0].effective &= ~drop; cap_data[0].permitted &= ~drop; cap_data[0].inheritable &= ~drop; if (syscall(SYS_capset, &cap_hdr, &cap_data)) exit(1); } static int do_sandbox_none(void) { if (unshare(CLONE_NEWPID)) { } int pid = fork(); if (pid != 0) return wait_for_loop(pid); setup_common(); sandbox_common(); drop_caps(); if (unshare(CLONE_NEWNET)) { } initialize_tun(); loop(); exit(1); } uint64_t r[2] = {0xffffffffffffffff, 0xffffffffffffffff}; void loop(void) { intptr_t res = 0; res = syscall(__NR_socket, 0xful, 3ul, 2); if (res != -1) r[0] = res; NONFAILING(*(uint64_t*)0x205f5000 = 0); NONFAILING(*(uint32_t*)0x205f5008 = 0); NONFAILING(*(uint64_t*)0x205f5010 = 0x208feff0); NONFAILING(*(uint64_t*)0x208feff0 = 0x2080e000); NONFAILING(*(uint8_t*)0x2080e000 = 2); NONFAILING(*(uint8_t*)0x2080e001 = 0xe); NONFAILING(*(uint8_t*)0x2080e002 = 0); NONFAILING(*(uint8_t*)0x2080e003 = 0); NONFAILING(*(uint16_t*)0x2080e004 = 0x14); NONFAILING(*(uint16_t*)0x2080e006 = 0); NONFAILING(*(uint32_t*)0x2080e008 = 0); NONFAILING(*(uint32_t*)0x2080e00c = 0); NONFAILING(*(uint16_t*)0x2080e010 = 5); NONFAILING(*(uint16_t*)0x2080e012 = 6); NONFAILING(*(uint8_t*)0x2080e014 = 0); NONFAILING(*(uint8_t*)0x2080e015 = 0); NONFAILING(*(uint16_t*)0x2080e016 = 0); NONFAILING(*(uint16_t*)0x2080e018 = 0xa); NONFAILING(*(uint16_t*)0x2080e01a = htobe16(0)); NONFAILING(*(uint32_t*)0x2080e01c = htobe32(0)); NONFAILING(memcpy( (void*)0x2080e020, "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000", 16)); NONFAILING(*(uint32_t*)0x2080e030 = 0); NONFAILING(*(uint16_t*)0x2080e038 = 8); NONFAILING(*(uint16_t*)0x2080e03a = 0x12); NONFAILING(*(uint16_t*)0x2080e03c = 0); NONFAILING(*(uint8_t*)0x2080e03e = 2); NONFAILING(*(uint8_t*)0x2080e03f = 0); NONFAILING(*(uint32_t*)0x2080e040 = 0); NONFAILING(*(uint32_t*)0x2080e044 = 0); NONFAILING(*(uint16_t*)0x2080e048 = 6); NONFAILING(*(uint16_t*)0x2080e04a = 0); NONFAILING(*(uint8_t*)0x2080e04c = 0); NONFAILING(*(uint8_t*)0x2080e04d = 0); NONFAILING(*(uint16_t*)0x2080e04e = 0); NONFAILING(*(uint32_t*)0x2080e050 = 0); NONFAILING(*(uint32_t*)0x2080e054 = 0); NONFAILING(*(uint8_t*)0x2080e058 = 0xac); NONFAILING(*(uint8_t*)0x2080e059 = 0x14); NONFAILING(*(uint8_t*)0x2080e05a = -1); NONFAILING(*(uint8_t*)0x2080e05b = 0xbb); NONFAILING(*(uint8_t*)0x2080e068 = 0xac); NONFAILING(*(uint8_t*)0x2080e069 = 0x14); NONFAILING(*(uint8_t*)0x2080e06a = 0x14); NONFAILING(*(uint8_t*)0x2080e06b = 0); NONFAILING(*(uint16_t*)0x2080e078 = 5); NONFAILING(*(uint16_t*)0x2080e07a = 5); NONFAILING(*(uint8_t*)0x2080e07c = 0); NONFAILING(*(uint8_t*)0x2080e07d = 0); NONFAILING(*(uint16_t*)0x2080e07e = 0); NONFAILING(*(uint16_t*)0x2080e080 = 0xa); NONFAILING(*(uint16_t*)0x2080e082 = htobe16(0)); NONFAILING(*(uint32_t*)0x2080e084 = htobe32(0)); NONFAILING(*(uint8_t*)0x2080e088 = 0xfe); NONFAILING(*(uint8_t*)0x2080e089 = 0x80); NONFAILING(*(uint8_t*)0x2080e08a = 0); NONFAILING(*(uint8_t*)0x2080e08b = 0); NONFAILING(*(uint8_t*)0x2080e08c = 0); NONFAILING(*(uint8_t*)0x2080e08d = 0); NONFAILING(*(uint8_t*)0x2080e08e = 0); NONFAILING(*(uint8_t*)0x2080e08f = 0); NONFAILING(*(uint8_t*)0x2080e090 = 0); NONFAILING(*(uint8_t*)0x2080e091 = 0); NONFAILING(*(uint8_t*)0x2080e092 = 0); NONFAILING(*(uint8_t*)0x2080e093 = 0); NONFAILING(*(uint8_t*)0x2080e094 = 0); NONFAILING(*(uint8_t*)0x2080e095 = 0); NONFAILING(*(uint8_t*)0x2080e096 = 0); NONFAILING(*(uint8_t*)0x2080e097 = -1); NONFAILING(*(uint32_t*)0x2080e098 = 0); NONFAILING(*(uint64_t*)0x208feff8 = 0xa0); NONFAILING(*(uint64_t*)0x205f5018 = 1); NONFAILING(*(uint64_t*)0x205f5020 = 0); NONFAILING(*(uint64_t*)0x205f5028 = 0); NONFAILING(*(uint32_t*)0x205f5030 = 0); syscall(__NR_sendmsg, r[0], 0x205f5000ul, 0ul); res = syscall(__NR_socket, 0x10ul, 3ul, 6); if (res != -1) r[1] = res; NONFAILING(*(uint64_t*)0x200001c0 = 0); NONFAILING(*(uint32_t*)0x200001c8 = 0); NONFAILING(*(uint64_t*)0x200001d0 = 0x20000180); NONFAILING(*(uint64_t*)0x20000180 = 0x20000040); NONFAILING(*(uint32_t*)0x20000040 = 0x1c); NONFAILING(*(uint16_t*)0x20000044 = 0x24); NONFAILING(*(uint16_t*)0x20000046 = 1); NONFAILING(*(uint32_t*)0x20000048 = 0); NONFAILING(*(uint32_t*)0x2000004c = 0); NONFAILING(*(uint32_t*)0x20000050 = 0); NONFAILING(*(uint16_t*)0x20000054 = 6); NONFAILING(*(uint16_t*)0x20000056 = 3); NONFAILING(*(uint8_t*)0x20000058 = 0); NONFAILING(*(uint8_t*)0x20000059 = 0); NONFAILING(*(uint64_t*)0x20000188 = 0x1c); NONFAILING(*(uint64_t*)0x200001d8 = 1); NONFAILING(*(uint64_t*)0x200001e0 = 0); NONFAILING(*(uint64_t*)0x200001e8 = 0); NONFAILING(*(uint32_t*)0x200001f0 = 0); syscall(__NR_sendmsg, r[1], 0x200001c0ul, 0ul); } int main(void) { syscall(__NR_mmap, 0x1ffff000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul); syscall(__NR_mmap, 0x20000000ul, 0x1000000ul, 7ul, 0x32ul, -1, 0ul); syscall(__NR_mmap, 0x21000000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul); install_segv_handler(); use_temporary_dir(); do_sandbox_none(); return 0; }
the_stack_data/140764618.c
//{{BLOCK(FrontWalkingPlayer) //====================================================================== // // FrontWalkingPlayer, 16x16@8, // + 4 tiles not compressed // Total size: 256 = 256 // // Time-stamp: 2020-12-21, 15:07:25 // Exported by Cearn's GBA Image Transmogrifier, v0.8.6 // ( http://www.coranac.com/projects/#grit ) // //====================================================================== const unsigned int FrontWalkingPlayerTiles[64] __attribute__((aligned(4)))= { 0x03030000,0x03030303,0x01010300,0x01010101,0x01010103,0x01010101,0x01010103,0x01010101, 0x01010103,0x01010303,0x01010103,0x01010101,0x01010103,0x01010303,0x01010103,0x01010303, 0x03030303,0x00000303,0x01010101,0x00030101,0x01010101,0x03010101,0x01010101,0x03010101, 0x03030101,0x03010101,0x01010101,0x03010101,0x03030101,0x03010101,0x03030101,0x03010101, 0x01010300,0x01010303,0x01030000,0x01010101,0x02010300,0x01010101,0x02010103,0x02020202, 0x02010103,0x02020202,0x03010103,0x03040404,0x03030300,0x00030404,0x00000000,0x00000000, 0x03030101,0x00030101,0x01010101,0x00000301,0x01010101,0x00030102,0x02020202,0x03010103, 0x03020202,0x03010101,0x03040403,0x03010101,0x04040300,0x00030303,0x04040300,0x00000003, }; //}}BLOCK(FrontWalkingPlayer)
the_stack_data/1049187.c
/* * Challenge 701 * Insert into BST */ #include <stdio.h> int main(int argc, char const *argv[]) { /*Solution*/ /* Definition for a binary tree node.*/ struct TreeNode { int val; struct TreeNode *left; struct TreeNode *right; }; struct TreeNode* insertIntoBST(struct TreeNode* root, int val){ if (root == NULL) { struct TreeNode* newnode = (struct TreeNode*)malloc(sizeof(struct TreeNode)); newnode->left = NULL; newnode->right = NULL; newnode->val = val; return newnode; } // if (root->val == val) //No action if (root->val < val){ root->right = insertIntoBST(root->right,val); } if (root->val > val){ root->left = insertIntoBST(root->left,val); } return root; } return 0; }
the_stack_data/68886787.c
#include <stdio.h> // for linux / mac the cursor movement can produce unwanted exceptions #include <stdlib.h> // #include <editline/readline.h> // #include <editline/history.h> // declare buffer for user input static char input[2048]; // global var declared outside of the main method int main(int argc, char** argv){ // print the version and exit info puts("lispy version 0.0.0.0.1"); puts("Press Ctrl+C to Exit\n"); // never ending loop while (1) { // output our prompt // DISABLE FOR *NIX fputs("lispy> ", stdout); // read a line of user input, max size 2048 // DISABLE FOR *NIX fgets(input, 2048, stdin); // take the input and store in the global var // *nix , output and get input // char* input = readline("lispy> "); // from editline // *nix , add to history // add_history(input); // from editline // echo input back to user printf("> %s", input); // printf("> %s\n", input); // NIX, the trailing new line is stripped // *nix , free the input free(input); // from - stdlib.h } return 0; } /* // --------------- Whats happening (Non *nix)--------------- // Let's go over this program in a little more depth. The line static char input[2048]; declares a global array of 2048 characters. This is a reserved block of data we can access anywhere from our program. In it we are going to store the user input which is typed into the command line. The static keyword makes this variable local to this file, and the [2048] section is what declares the size. We write an infinite loop using while (1). In a conditional block 1 always evaluates to true. Therefore commands inside this loop will run forever. To output our prompt we use the function fputs. This is a slight variation on puts which does not append a newline character. We use the fgets function for getting user input from the command line. Both of these functions require some file to write to, or read from. For this we supply the special variables stdin and stdout. These are declared in <stdio.h> and are special file variables representing input to, and output from, the command line. When passed this variable the fgets function will wait for a user to input a line of text, and when it has it will store it into the input buffer, including the newline character. So that fgets does not read in too much data we also must also supply the size of the buffer 2048. To echo the message back to the user we use the function printf. This is a function that provides a way of printing messages consisting of several elements. It matches arguments to patterns in the given string. For example in our case we can see the %s pattern in the given string. This means that it will be replaced by whatever argument is passed in next, interpreted as a string. For more information on these different patterns please see the documentation on printf. */ /* // --------------- Whats happening (*nix)--------------- // We have included a few new headers. There is #include <stdlib.h>, which gives us access to the free function used later on in the code. We have also added #include <editline/readline.h> and #include <editline/history.h> which give us access to the editline functions, readline and add_history. Instead of prompting, and getting input with fgets, we do it in one go using readline. The result of this we pass to add_history to record it. Finally we print it out as before using printf. Unlike fgets, the readline function strips the trailing newline character from the input, so we need to add this to our printf function. We also need to delete the input given to us by the readline function using free. This is because unlike fgets, which writes to some existing buffer, the readline function allocates new memory when it is called. When to free memory is something we cover in depth in later chapters. */ /* NIX COMPILATION ISSUES On Mac the editline library comes with Command Line Tools. Instructions for installing these can be found in Chapter 2. You may still get an error about the history header not being found. In this case remove the line #include <editline/history.h>, as this header may not be required. On Linux you can install editline with sudo apt-get install libedit-dev. On Fedora you can use the command su -c "yum install libedit-dev*" Once you have installed editline you can try to compile it again. This time you'll get a different error. undefined reference to `readline' undefined reference to `add_history' This means that you haven't linked your program to editline. This linking process allows the compiler to directly embed calls to editline in your program. You can make it link by adding the flag -ledit to your compile command, just before the output flag. cc -std=c99 -Wall prompt.c -ledit -o prompt Run it and check that now you can edit inputs as you type them in. */
the_stack_data/43888422.c
/* Test type qualifiers. These should as equal types. */ extern volatile unsigned long foo; typedef unsigned long ulong; extern volatile ulong foo; volatile ulong foo;
the_stack_data/4184.c
#include <assert.h> #include <limits.h> #include <math.h> #include <stdbool.h> #include <stddef.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> int main() { int i, n, arr[10000]; scanf("%d", &n); for(i=0; i<n; i++) scanf("%d", &arr[i]); for(i=n-1; i>=0; i--) printf("%d ", arr[i]); return 0; }
the_stack_data/35949.c
#include "syscall.h" void AssertEq(int a,int b,int line){ if (a!=b){ printf("assert fail in line %d in child_1 %d!=%d\n",line,a,b); } } int main() { int process_id = exec("child_2.coff", 0, ""); int status; int exit_status = join(process_id, &status); AssertEq(status, 1, __LINE__); int i; for(i = 0; i < 10; i ++) printf("from child_1, %d\n",i); process_id = exec("child_3.coff", 0, ""); exit(process_id); }
the_stack_data/154532.c
#include <stdio.h> void Printer(int arr[],int *size) { for (int i = 0 ; i < *size ; i++) { printf("element %d = %d\n",i,arr[i]); } } int main() { int arr[] = {9,4,8,6,5,4}; int size = sizeof(arr)/sizeof(arr[0]); for (int i = 1; i < size; i++) { int value = arr[i]; int hole = i; // index while (hole > 0 && arr[hole -1 ] > value) { arr[hole] = arr[hole - 1]; hole -= 1; } arr[hole] = value; } // printing the array Printer(arr,&size); return 0; }
the_stack_data/72012358.c
#include <stdio.h> double *print1DimFeld(double feld[], int anzahl) { printf("print1DimFeld:\n"); for (int i = 0; i < anzahl; i++) { printf("feld[%d] %p => %f\n", i, &feld[i], feld[i]); } printf("\n\n"); return &feld[0]; } void eindimensionalesFeld() { char text1[] = "Hi"; printf("%s\n", text1); printf("text1: sizeof(text1) = %d Bytes\n", (int)sizeof(text1)); for (int i = 0; i < sizeof(text1); i++) { printf(" %d", (int)text1[i]); } printf("\n\n"); char text2[] = { 'H', 'i', 0}; printf("text2: %s\n", text2); printf("sizeof(text2) = %d Bytes\n", (int)sizeof(text2)); for (int i = 0; i < sizeof(text2); i++) { printf(" %d", (int)text2[i]); } printf("\n\n"); char text3[10] = { 'H', 'i', 0}; printf("text3: %s\n", text3); printf("text3: %s\n", text3); printf("sizeof(text3) = %d Bytes\n", (int)sizeof(text3)); for (int i = 0; i < sizeof(text3); i++) { printf(" %d", (int)text3[i]); } printf("\n\n"); double df1[] = { 1.0, 2.0, 3.0}; printf("sizeof(df1) = %d Bytes\n", (int)sizeof(df1)); for (int i = 0; i < sizeof(df1) / sizeof(double); i++) { printf(" %f", df1[i]); } printf("\n\n"); double df2[5] = { 1.0, 2.0, 3.0, 4.0 }; printf("sizeof(df2) = %d Bytes\n", (int)sizeof(df2)); for (int i = 0; i < sizeof(df2) / sizeof(df2[0]); i++) { printf(" %f", df2[i]); } printf("\n\n"); text1[0] = 'H'; text1[1] = 'a'; text1[2] = 0; printf("%s\n", text1); double *df3 = print1DimFeld(df2, sizeof(df2) / sizeof(double)); printf("sizeof(df3) = %d Bytes\n", (int)sizeof(df3)); for (int i = 0; i < 5; i++) { printf(" %f", df3[i]); } printf("\n\n"); } void printf2DimFeld(double f[][3], int anzahl) { printf("printf2DimFeld:\n"); for (int i = 0; i < anzahl; i++) { for (int j = 0; j < 3; j++) { printf("feld[%d][%d] %p => %f\n", i, j, &f[i][j], f[i][j]); } } printf("\n\n"); } void zweidimensionaleFelder() { // xx-Achse & y-Achse // 4 * 3 = 12 Elemente -> 12 * 8 = 96 double f[4][3] = { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }, { 10, 11, 12 } }; printf("\n\n2 Dimensionen:\n"); printf("sizeof(f) = %d Bytes\n", (int)sizeof(f)); printf("f[0][0] %p => %f\n", &f[0][0], f[0][0]); printf("f[0][1] %p => %f\n", &f[0][1], f[0][1]); printf("f[0][2] %p => %f\n", &f[0][2], f[0][2]); printf("f[1][0] %p => %f\n", &f[1][0], f[1][0]); printf("f[1][1] %p => %f\n", &f[1][1], f[1][1]); printf("f[1][2] %p => %f\n", &f[1][2], f[1][2]); printf("f[2][0] %p => %f\n", &f[2][0], f[2][0]); printf("f[2][1] %p => %f\n", &f[2][1], f[2][1]); printf("f[2][2] %p => %f\n", &f[2][2], f[2][2]); printf("f[3][0] %p => %f\n", &f[3][0], f[3][0]); printf("f[3][1] %p => %f\n", &f[3][1], f[3][1]); printf("f[3][2] %p => %f\n", &f[3][2], f[3][2]); // f = { { 1, 2, 3 } }; // nicht moeglich, nur bei Initialisierung erlaubt f[2][0] = 7; f[2][1] = 8; f[2][2] = 9; f[2][3] = 10; printf2DimFeld(f, 4); } void print3DimFeld(double x[][3][4], int anzahl) { printf("print3DimFeld:\n"); for (int i = 0; i < anzahl; i++) { for (int j = 0; j < 3; j++) { for (int k = 0; k < 4; k++) { printf("x[%d][%d][%d] %p => %f\n", i, j, k, &x[i][j][k], x[i][j][k]); } } } printf("\n\n"); } void dreidimensionalesFeld() { double f[2][3][4] = { { { 1, 2, 3, 4 }, { 5, 6, 7, 8 }, { 9, 10, 11, 12 } }, { { 13, 14, 15, 16 }, { 17, 18, 19, 20 }, { 21, 22, 23, 24 } } }; printf("\n\n3 Dimensionen:\n"); printf("sizeof(f) = %d Bytes\n", (int)sizeof(f)); for (int i = 0; i < 2; i++) { for (int j = 0; j < 3; j++) { for (int k = 0; k < 4; k++) { printf("feld[%d][%d] %d => %f\n", i, j, k, &f[i][j][k], f[i][j][k]); } } } printf("\n\n"); print3DimFeld(f, 2); } int main() { eindimensionalesFeld(); zweidimensionaleFelder(); return 0; }
the_stack_data/65501.c
#include <stdio.h> #include <math.h> double f(double u, double beta, double N, double gamma){ return (beta*N-gamma)*u-beta*pow(u,2); } double F1(double U1, double U2, double un, double delt, double a11, double a12, double alpha, double beta){ return U1 - un - delt*(a11*(alpha*U1-beta*pow(U1,2)) + a12*(alpha*U2-beta*pow(U2,2))); } double F2(double U1, double U2, double un, double delt, double a21, double a22, double alpha, double beta){ return U2 - un - delt*(a21*(alpha*U1-beta*pow(U1,2)) + a22*(alpha*U2-beta*pow(U2,2))); } int main(){ FILE *fPicard_ut, *fNewton_ut, *fRK_ut; fPicard_ut = fopen("Picard_ut.dat","w"); fNewton_ut = fopen("Newton_ut.dat","w"); fRK_ut = fopen("RK_ut.dat","w"); double N = 500.; //liczba osob, u + z = N double beta = 0.001; //czestosc kontaktow double gamma = 0.1; //czas trawania choroby double tMax = 100; double tDel = 0.1; double u0 = 1.; //jedna osoba zarazona na starcie double TOL = pow(10,-6); double mikroMax = 20.; double alpha = beta*N-gamma; //wspolne dla Picarda i Newtona double u_mikro, u_mikro1, u_n; //Metoda Picarda u_n = u0; for(double t = 0.; t <= tMax; t += tDel){ u_mikro = u_n; for(double mikro = 0.; mikro < mikroMax; mikro += 1){ u_mikro1 = u_n; u_mikro1 = u_mikro1 + (tDel/2.) * ((alpha*u_n - beta*pow(u_n,2)) + (alpha*u_mikro - beta*pow(u_mikro,2))); u_mikro = u_mikro1; if(fabs(u_mikro1 - u_mikro) < TOL){ break; } } u_n = u_mikro; fprintf(fPicard_ut, "%f %f %f\n", t, u_n, N-u_n); } //Metoda Newtona u_n = u0; for(double t = 0.; t <= tMax; t += tDel){ u_mikro = u_n; u_mikro1 = u_mikro; for(double mikro = 0.; mikro < mikroMax; mikro += 1){ u_mikro1 = u_mikro - (u_mikro-u_n - tDel/2.*((alpha*u_n-beta*pow(u_n,2)) + alpha*u_mikro - beta*pow(u_mikro,2)))/(1.0 - tDel/2. * (alpha - 2*beta*u_mikro)); u_mikro = u_mikro1; if(fabs(u_mikro1 - u_mikro) < TOL){ break; } } u_n = u_mikro; fprintf(fNewton_ut, "%f %f %f\n", t, u_n, N-u_n); } //Metoda RK double c1 = 1./2. - sqrt(3.)/6.; double c2 = 1./2. + sqrt(3.)/6.; double b1 = 1./2.; double b2 = 1./2.; double a11 = 1./4.; double a12 = 1./4. - sqrt(3.)/6.; double a22 = 1./4.; double a21 = 1./4. + sqrt(3.)/6.; double m11 = 0; double m12 = 0; double m21 = 0; double m22 = 0; u_n = u0; double u_np = 0; double U1 = 0; double U2 = 0; double U1p = 0; double U2p = 0; double delU1 = 0; double delU2 = 0; for(double t = 0.; t <= tMax; t += tDel){ u_np = u_n; U1 = u_np; U2 = u_np; for(double mikro = 0.; mikro < mikroMax; mikro += 1){ U1p = U1; U2p = U2; m11 = 1 - tDel*a11*(alpha-2*beta*U1); m12 = -tDel*a12*(alpha-2*beta*U2); m21 = -tDel*a21*(alpha-2*beta*U1); m22 = 1 - tDel*a22*(alpha-2*beta*U2); delU1 = (F2(U1, U2, u_n, tDel, a21, a22, alpha, beta)*m12 - F1(U1, U2, u_n, tDel, a11, a12, alpha, beta)*m22)/(m11*m22-m12*m21); delU1 = (F1(U1, U2, u_n, tDel, a11, a12, alpha, beta)*m21 - F2(U1, U2, u_n, tDel, a21, a22, alpha, beta)*m11)/(m11*m22-m12*m21); U1 = U1p + delU1; U2 = U2p + delU2; if(fabs(U1 - U1p) < TOL && fabs(U2 - U2p)< TOL){ break; } } u_n = u_np + tDel*(b1*f(U1,beta,N,gamma) + b2*f(U2,beta,N,gamma)); fprintf(fRK_ut, "%f %f %f\n", t, u_n, N-u_n); } fclose(fPicard_ut), fclose(fNewton_ut), fclose(fRK_ut); }
the_stack_data/42247.c
/****************************************************************************/ /** * @file System_LibcStubs.c * XMC4000 Device Series * @version V1.3 * @date Jan 2014 * * Copyright (C) 2012-2014 Infineon Technologies AG. All rights reserved. * * * @par * Infineon Technologies AG (Infineon) is supplying this software for use with * Infineon's microcontrollers. This file can be freely distributed within * development tools that are supporting such microcontrollers. * * @par * THIS SOFTWARE IS PROVIDED AS IS. NO WARRANTIES, WHETHER EXPRESS, IMPLIED * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. * ******************************************************************************/ /* ============================ REVISION HISTORY ============================== 1. Prakash Kalanjeri Balasubramanian , V0.1 , Initial draft 2. Prakash Kalanjeri Balasubramanian , V0.2 , Label updates 3. Prakash Kalanjeri Balasubramanian , V1.0 , Made _Sbrk device agnostic 3. Prakash Kalanjeri Balasubramanian , V1.1 , C++ support 3. Prakash Kalanjeri Balasubramanian , V1.2 , Restored compatibilty with old project files 4. Prakash Kalanjeri Balasubramanian, V1.3 , Encapsulating everything in this file for use only with GCC ========================================================================= */ /* * This file contains stubs for standard C library functionality that must * typically be provided for the underlying platform. * * All routines are WEAKLY defined. This creates an opportunity for application * developers to override the provided implementation and define a final * implementation for their platforms. */ #if defined ( __GNUC__ ) #include <sys/stat.h> #include <sys/times.h> #include <unistd.h> #ifdef __cplusplus extern "C" { #endif /* ========================================================================= */ /* =========================== File I/O related ============================ */ /* ========================================================================= */ /* * File open */ __attribute__((weak)) int _open(const char *name, int flags, int mode) { (void)flags; (void)mode; return -1; } /* * File position seek */ __attribute__((weak)) int _lseek(int file, int offset, int whence) { (void)file; (void)offset; (void)whence; return -1; } /* * File read */ __attribute__((weak)) int _read(int file, char *ptr, int len) { (void)file; (void)len; return 0; } /* * File write */ __attribute__((weak)) int _write(int file, char *buf, int nbytes) { return -1; } /* * File close */ __attribute__((weak)) int _close(void) { return -1; } /* * File status */ __attribute__((weak)) int _fstat(int file, struct stat *st) { (void)file; if(st) return -1; else return -2; } /* * File linking */ __attribute__((weak)) int _link(char *oldname, char *newname) { if (oldname == newname) return -1; else return -2; } /* * Unlinking directory entry */ __attribute__((weak)) int _unlink(char *name) { return -1; } /* ========================================================================= */ /* ====================== Process related ================================== */ /* ========================================================================= */ /* * Process timing information */ __attribute__((weak)) int _times(struct tms *buf) { return -1; } /* * Waiting for a child process to complete */ __attribute__((weak)) int _wait(int *status) { return -1; } /* * Kill a process */ __attribute__((weak)) int _kill(int pid,int sig) { (void)pid; (void)sig; return -1; } /* * Forking a child process */ __attribute__((weak)) int _fork(void) { return -1; } /* * Process ID */ __attribute__((weak)) int _getpid(void) { return -1; } /* * Program/process exit */ __attribute__((weak)) void _exit(int rc) { (void)rc; while(1){} } /* Init */ __attribute__((weak)) void _init(void) {} /* ========================================================================= */ /* ======================= TERMIO related ================================== */ /* ========================================================================= */ /* * Terminal type evaluation */ __attribute__((weak)) int _isatty(int file) { (void)file; return -1; } /* ========================================================================= */ /* ================================= C++ =================================== */ /* ========================================================================= */ //void *__dso_handle = (void *)0; #ifdef __cplusplus } #endif #endif /* __GNUC__ */
the_stack_data/48574821.c
#define _BSD_SOURCE #include <errno.h> #include <sys/time.h> int settimeofday(const struct timeval* tv, const struct timezone* tz) { errno = ENOSYS; return -1; }
the_stack_data/85047.c
/* Copyright 2014-2018 The PySCF Developers. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* #include "elapse.h" */ #include <sys/time.h> #ifdef _AIX void cputime(double *val) #else void cputime_(double *val) #endif { struct timeval time; gettimeofday(&time,(struct timezone *)0); *val=time.tv_sec+time.tv_usec*1.e-6; } #include <unistd.h> #ifdef _AIX void getpid(int *val) #else void getpid_(int *val) #endif { *val = getpid(); }
the_stack_data/404127.c
// EXPECT: 1 int main() { return 1 || 1; }
the_stack_data/1134427.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 ZLANTP returns the value of the 1-norm, or the Frobenius norm, or the infinity norm, or the ele ment of largest absolute value of a triangular matrix supplied in packed form. */ /* =========== DOCUMENTATION =========== */ /* Online html documentation available at */ /* http://www.netlib.org/lapack/explore-html/ */ /* > \htmlonly */ /* > Download ZLANTP + dependencies */ /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlantp. f"> */ /* > [TGZ]</a> */ /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlantp. f"> */ /* > [ZIP]</a> */ /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlantp. f"> */ /* > [TXT]</a> */ /* > \endhtmlonly */ /* Definition: */ /* =========== */ /* DOUBLE PRECISION FUNCTION ZLANTP( NORM, UPLO, DIAG, N, AP, WORK ) */ /* CHARACTER DIAG, NORM, UPLO */ /* INTEGER N */ /* DOUBLE PRECISION WORK( * ) */ /* COMPLEX*16 AP( * ) */ /* > \par Purpose: */ /* ============= */ /* > */ /* > \verbatim */ /* > */ /* > ZLANTP returns the value of the one norm, or the Frobenius norm, or */ /* > the infinity norm, or the element of largest absolute value of a */ /* > triangular matrix A, supplied in packed form. */ /* > \endverbatim */ /* > */ /* > \return ZLANTP */ /* > \verbatim */ /* > */ /* > ZLANTP = ( f2cmax(abs(A(i,j))), NORM = 'M' or 'm' */ /* > ( */ /* > ( norm1(A), NORM = '1', 'O' or 'o' */ /* > ( */ /* > ( normI(A), NORM = 'I' or 'i' */ /* > ( */ /* > ( normF(A), NORM = 'F', 'f', 'E' or 'e' */ /* > */ /* > where norm1 denotes the one norm of a matrix (maximum column sum), */ /* > normI denotes the infinity norm of a matrix (maximum row sum) and */ /* > normF denotes the Frobenius norm of a matrix (square root of sum of */ /* > squares). Note that f2cmax(abs(A(i,j))) is not a consistent matrix norm. */ /* > \endverbatim */ /* Arguments: */ /* ========== */ /* > \param[in] NORM */ /* > \verbatim */ /* > NORM is CHARACTER*1 */ /* > Specifies the value to be returned in ZLANTP as described */ /* > above. */ /* > \endverbatim */ /* > */ /* > \param[in] UPLO */ /* > \verbatim */ /* > UPLO is CHARACTER*1 */ /* > Specifies whether the matrix A is upper or lower triangular. */ /* > = 'U': Upper triangular */ /* > = 'L': Lower triangular */ /* > \endverbatim */ /* > */ /* > \param[in] DIAG */ /* > \verbatim */ /* > DIAG is CHARACTER*1 */ /* > Specifies whether or not the matrix A is unit triangular. */ /* > = 'N': Non-unit triangular */ /* > = 'U': Unit triangular */ /* > \endverbatim */ /* > */ /* > \param[in] N */ /* > \verbatim */ /* > N is INTEGER */ /* > The order of the matrix A. N >= 0. When N = 0, ZLANTP is */ /* > set to zero. */ /* > \endverbatim */ /* > */ /* > \param[in] AP */ /* > \verbatim */ /* > AP is COMPLEX*16 array, dimension (N*(N+1)/2) */ /* > The upper or lower triangular matrix A, packed columnwise in */ /* > a linear array. The j-th column of A is stored in the array */ /* > AP as follows: */ /* > if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; */ /* > if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n. */ /* > Note that when DIAG = 'U', the elements of the array AP */ /* > corresponding to the diagonal elements of the matrix A are */ /* > not referenced, but are assumed to be one. */ /* > \endverbatim */ /* > */ /* > \param[out] WORK */ /* > \verbatim */ /* > WORK is DOUBLE PRECISION array, dimension (MAX(1,LWORK)), */ /* > where LWORK >= N when NORM = 'I'; otherwise, WORK is not */ /* > referenced. */ /* > \endverbatim */ /* Authors: */ /* ======== */ /* > \author Univ. of Tennessee */ /* > \author Univ. of California Berkeley */ /* > \author Univ. of Colorado Denver */ /* > \author NAG Ltd. */ /* > \date December 2016 */ /* > \ingroup complex16OTHERauxiliary */ /* ===================================================================== */ doublereal zlantp_(char *norm, char *uplo, char *diag, integer *n, doublecomplex *ap, doublereal *work) { /* System generated locals */ integer i__1, i__2; doublereal ret_val; /* Local variables */ extern /* Subroutine */ int dcombssq_(doublereal *, doublereal *); integer i__, j, k; logical udiag; extern logical lsame_(char *, char *); doublereal value; extern logical disnan_(doublereal *); doublereal colssq[2]; extern /* Subroutine */ int zlassq_(integer *, doublecomplex *, integer *, doublereal *, doublereal *); doublereal sum, ssq[2]; /* -- 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 */ --work; --ap; /* Function Body */ if (*n == 0) { value = 0.; } else if (lsame_(norm, "M")) { /* Find f2cmax(abs(A(i,j))). */ k = 1; if (lsame_(diag, "U")) { value = 1.; if (lsame_(uplo, "U")) { i__1 = *n; for (j = 1; j <= i__1; ++j) { i__2 = k + j - 2; for (i__ = k; i__ <= i__2; ++i__) { sum = z_abs(&ap[i__]); if (value < sum || disnan_(&sum)) { value = sum; } /* L10: */ } k += j; /* L20: */ } } else { i__1 = *n; for (j = 1; j <= i__1; ++j) { i__2 = k + *n - j; for (i__ = k + 1; i__ <= i__2; ++i__) { sum = z_abs(&ap[i__]); if (value < sum || disnan_(&sum)) { value = sum; } /* L30: */ } k = k + *n - j + 1; /* L40: */ } } } else { value = 0.; if (lsame_(uplo, "U")) { i__1 = *n; for (j = 1; j <= i__1; ++j) { i__2 = k + j - 1; for (i__ = k; i__ <= i__2; ++i__) { sum = z_abs(&ap[i__]); if (value < sum || disnan_(&sum)) { value = sum; } /* L50: */ } k += j; /* L60: */ } } else { i__1 = *n; for (j = 1; j <= i__1; ++j) { i__2 = k + *n - j; for (i__ = k; i__ <= i__2; ++i__) { sum = z_abs(&ap[i__]); if (value < sum || disnan_(&sum)) { value = sum; } /* L70: */ } k = k + *n - j + 1; /* L80: */ } } } } else if (lsame_(norm, "O") || *(unsigned char *) norm == '1') { /* Find norm1(A). */ value = 0.; k = 1; udiag = lsame_(diag, "U"); if (lsame_(uplo, "U")) { i__1 = *n; for (j = 1; j <= i__1; ++j) { if (udiag) { sum = 1.; i__2 = k + j - 2; for (i__ = k; i__ <= i__2; ++i__) { sum += z_abs(&ap[i__]); /* L90: */ } } else { sum = 0.; i__2 = k + j - 1; for (i__ = k; i__ <= i__2; ++i__) { sum += z_abs(&ap[i__]); /* L100: */ } } k += j; if (value < sum || disnan_(&sum)) { value = sum; } /* L110: */ } } else { i__1 = *n; for (j = 1; j <= i__1; ++j) { if (udiag) { sum = 1.; i__2 = k + *n - j; for (i__ = k + 1; i__ <= i__2; ++i__) { sum += z_abs(&ap[i__]); /* L120: */ } } else { sum = 0.; i__2 = k + *n - j; for (i__ = k; i__ <= i__2; ++i__) { sum += z_abs(&ap[i__]); /* L130: */ } } k = k + *n - j + 1; if (value < sum || disnan_(&sum)) { value = sum; } /* L140: */ } } } else if (lsame_(norm, "I")) { /* Find normI(A). */ k = 1; if (lsame_(uplo, "U")) { if (lsame_(diag, "U")) { i__1 = *n; for (i__ = 1; i__ <= i__1; ++i__) { work[i__] = 1.; /* L150: */ } i__1 = *n; for (j = 1; j <= i__1; ++j) { i__2 = j - 1; for (i__ = 1; i__ <= i__2; ++i__) { work[i__] += z_abs(&ap[k]); ++k; /* L160: */ } ++k; /* L170: */ } } else { i__1 = *n; for (i__ = 1; i__ <= i__1; ++i__) { work[i__] = 0.; /* L180: */ } i__1 = *n; for (j = 1; j <= i__1; ++j) { i__2 = j; for (i__ = 1; i__ <= i__2; ++i__) { work[i__] += z_abs(&ap[k]); ++k; /* L190: */ } /* L200: */ } } } else { if (lsame_(diag, "U")) { i__1 = *n; for (i__ = 1; i__ <= i__1; ++i__) { work[i__] = 1.; /* L210: */ } i__1 = *n; for (j = 1; j <= i__1; ++j) { ++k; i__2 = *n; for (i__ = j + 1; i__ <= i__2; ++i__) { work[i__] += z_abs(&ap[k]); ++k; /* L220: */ } /* L230: */ } } else { i__1 = *n; for (i__ = 1; i__ <= i__1; ++i__) { work[i__] = 0.; /* L240: */ } i__1 = *n; for (j = 1; j <= i__1; ++j) { i__2 = *n; for (i__ = j; i__ <= i__2; ++i__) { work[i__] += z_abs(&ap[k]); ++k; /* L250: */ } /* L260: */ } } } value = 0.; i__1 = *n; for (i__ = 1; i__ <= i__1; ++i__) { sum = work[i__]; if (value < sum || disnan_(&sum)) { value = sum; } /* L270: */ } } else if (lsame_(norm, "F") || lsame_(norm, "E")) { /* Find normF(A). */ /* SSQ(1) is scale */ /* SSQ(2) is sum-of-squares */ /* For better accuracy, sum each column separately. */ if (lsame_(uplo, "U")) { if (lsame_(diag, "U")) { ssq[0] = 1.; ssq[1] = (doublereal) (*n); k = 2; i__1 = *n; for (j = 2; j <= i__1; ++j) { colssq[0] = 0.; colssq[1] = 1.; i__2 = j - 1; zlassq_(&i__2, &ap[k], &c__1, colssq, &colssq[1]); dcombssq_(ssq, colssq); k += j; /* L280: */ } } else { ssq[0] = 0.; ssq[1] = 1.; k = 1; i__1 = *n; for (j = 1; j <= i__1; ++j) { colssq[0] = 0.; colssq[1] = 1.; zlassq_(&j, &ap[k], &c__1, colssq, &colssq[1]); dcombssq_(ssq, colssq); k += j; /* L290: */ } } } else { if (lsame_(diag, "U")) { ssq[0] = 1.; ssq[1] = (doublereal) (*n); k = 2; i__1 = *n - 1; for (j = 1; j <= i__1; ++j) { colssq[0] = 0.; colssq[1] = 1.; i__2 = *n - j; zlassq_(&i__2, &ap[k], &c__1, colssq, &colssq[1]); dcombssq_(ssq, colssq); k = k + *n - j + 1; /* L300: */ } } else { ssq[0] = 0.; ssq[1] = 1.; k = 1; i__1 = *n; for (j = 1; j <= i__1; ++j) { colssq[0] = 0.; colssq[1] = 1.; i__2 = *n - j + 1; zlassq_(&i__2, &ap[k], &c__1, colssq, &colssq[1]); dcombssq_(ssq, colssq); k = k + *n - j + 1; /* L310: */ } } } value = ssq[0] * sqrt(ssq[1]); } ret_val = value; return ret_val; /* End of ZLANTP */ } /* zlantp_ */
the_stack_data/64689.c
#include<stdio.h> int main() { int i = 1; printf("%d %d %d\n", ++i, i++, i); return 0; }
the_stack_data/20449240.c
/* Autogenerated: src/ExtractionOCaml/bedrock2_word_by_word_montgomery --lang bedrock2 --static --no-wide-int --widen-carry --widen-bytes --split-multiret --no-select p256 64 '2^256 - 2^224 + 2^192 + 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: p256 */ /* machine_wordsize = 64 (from "64") */ /* requested operations: mul, square, add, sub, opp, from_montgomery, to_montgomery, nonzero, selectznz, to_bytes, from_bytes, one, msat, divstep, divstep_precomp */ /* m = 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff (from "2^256 - 2^224 + 2^192 + 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] << 64) + (z[2] << 128) + (z[3] << 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) + (z[28] << 224) + (z[29] << 232) + (z[30] << 240) + (z[31] << 248) */ #include <stdint.h> #include <memory.h> // LITTLE-ENDIAN memory access is REQUIRED // the following two functions are required to work around -fstrict-aliasing static inline uintptr_t _br2_load(uintptr_t a, size_t sz) { uintptr_t r = 0; memcpy(&r, (void*)a, sz); return r; } static inline void _br2_store(uintptr_t a, uintptr_t v, size_t sz) { memcpy((void*)a, &v, sz); } /* * Input Bounds: * in0: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] * in1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] * Output Bounds: * out0: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] */ static void internal_fiat_p256_mul(uintptr_t out0, uintptr_t in0, uintptr_t in1) { uintptr_t x1, x2, x3, x0, x11, x16, x19, x21, x17, x22, x14, x23, x25, x26, x15, x27, x12, x28, x30, x31, x13, x35, x38, x40, x36, x37, x42, x18, x43, x20, x44, x39, x45, x47, x48, x24, x49, x41, x50, x52, x53, x29, x54, x33, x55, x57, x58, x32, x59, x34, x60, x62, x8, x68, x71, x73, x69, x74, x66, x75, x77, x78, x67, x79, x64, x80, x82, x83, x65, x70, x46, x86, x51, x87, x72, x88, x90, x91, x56, x92, x76, x93, x95, x96, x61, x97, x81, x98, x100, x101, x63, x102, x84, x103, x105, x109, x112, x114, x110, x111, x116, x85, x117, x89, x118, x113, x119, x121, x122, x94, x123, x115, x124, x126, x127, x99, x128, x107, x129, x131, x132, x104, x133, x108, x134, x136, x137, x106, x9, x143, x146, x148, x144, x149, x141, x150, x152, x153, x142, x154, x139, x155, x157, x158, x140, x145, x120, x161, x125, x162, x147, x163, x165, x166, x130, x167, x151, x168, x170, x171, x135, x172, x156, x173, x175, x176, x138, x177, x159, x178, x180, x184, x187, x189, x185, x186, x191, x160, x192, x164, x193, x188, x194, x196, x197, x169, x198, x190, x199, x201, x202, x174, x203, x182, x204, x206, x207, x179, x208, x183, x209, x211, x212, x181, x7, x6, x5, x10, x4, x218, x221, x223, x219, x224, x216, x225, x227, x228, x217, x229, x214, x230, x232, x233, x215, x220, x195, x236, x200, x237, x222, x238, x240, x241, x205, x242, x226, x243, x245, x246, x210, x247, x231, x248, x250, x251, x213, x252, x234, x253, x255, x259, x262, x264, x260, x261, x266, x235, x267, x239, x268, x263, x269, x271, x272, x244, x273, x265, x274, x276, x277, x249, x278, x257, x279, x281, x282, x254, x283, x258, x284, x286, x287, x256, x290, x291, x292, x294, x295, x297, x298, x299, x301, x302, x288, x303, x270, x305, x289, x306, x275, x308, x293, x309, x280, x311, x296, x312, x304, x285, x314, x300, x315, x307, x310, x313, x316, x317, x318, x319, x320; x0 = _br2_load((in0)+((uintptr_t)0ULL), sizeof(uintptr_t)); x1 = _br2_load((in0)+((uintptr_t)8ULL), sizeof(uintptr_t)); x2 = _br2_load((in0)+((uintptr_t)16ULL), sizeof(uintptr_t)); x3 = _br2_load((in0)+((uintptr_t)24ULL), sizeof(uintptr_t)); /*skip*/ x4 = _br2_load((in1)+((uintptr_t)0ULL), sizeof(uintptr_t)); x5 = _br2_load((in1)+((uintptr_t)8ULL), sizeof(uintptr_t)); x6 = _br2_load((in1)+((uintptr_t)16ULL), sizeof(uintptr_t)); x7 = _br2_load((in1)+((uintptr_t)24ULL), sizeof(uintptr_t)); /*skip*/ /*skip*/ x8 = x1; x9 = x2; x10 = x3; x11 = x0; x12 = (x11)*(x7); x13 = sizeof(intptr_t) == 4 ? ((uint64_t)(x11)*(x7))>>32 : ((__uint128_t)(x11)*(x7))>>64; x14 = (x11)*(x6); x15 = sizeof(intptr_t) == 4 ? ((uint64_t)(x11)*(x6))>>32 : ((__uint128_t)(x11)*(x6))>>64; x16 = (x11)*(x5); x17 = sizeof(intptr_t) == 4 ? ((uint64_t)(x11)*(x5))>>32 : ((__uint128_t)(x11)*(x5))>>64; x18 = (x11)*(x4); x19 = sizeof(intptr_t) == 4 ? ((uint64_t)(x11)*(x4))>>32 : ((__uint128_t)(x11)*(x4))>>64; x20 = (x19)+(x16); x21 = (x20)<(x19); x22 = (x21)+(x17); x23 = (x22)<(x17); x24 = (x22)+(x14); x25 = (x24)<(x14); x26 = (x23)+(x25); x27 = (x26)+(x15); x28 = (x27)<(x15); x29 = (x27)+(x12); x30 = (x29)<(x12); x31 = (x28)+(x30); x32 = (x31)+(x13); x33 = (x18)*((uintptr_t)18446744069414584321ULL); x34 = sizeof(intptr_t) == 4 ? ((uint64_t)(x18)*((uintptr_t)18446744069414584321ULL))>>32 : ((__uint128_t)(x18)*((uintptr_t)18446744069414584321ULL))>>64; x35 = (x18)*((uintptr_t)4294967295ULL); x36 = sizeof(intptr_t) == 4 ? ((uint64_t)(x18)*((uintptr_t)4294967295ULL))>>32 : ((__uint128_t)(x18)*((uintptr_t)4294967295ULL))>>64; x37 = (x18)*((uintptr_t)18446744073709551615ULL); x38 = sizeof(intptr_t) == 4 ? ((uint64_t)(x18)*((uintptr_t)18446744073709551615ULL))>>32 : ((__uint128_t)(x18)*((uintptr_t)18446744073709551615ULL))>>64; x39 = (x38)+(x35); x40 = (x39)<(x38); x41 = (x40)+(x36); x42 = (x18)+(x37); x43 = (x42)<(x18); x44 = (x43)+(x20); x45 = (x44)<(x20); x46 = (x44)+(x39); x47 = (x46)<(x39); x48 = (x45)+(x47); x49 = (x48)+(x24); x50 = (x49)<(x24); x51 = (x49)+(x41); x52 = (x51)<(x41); x53 = (x50)+(x52); x54 = (x53)+(x29); x55 = (x54)<(x29); x56 = (x54)+(x33); x57 = (x56)<(x33); x58 = (x55)+(x57); x59 = (x58)+(x32); x60 = (x59)<(x32); x61 = (x59)+(x34); x62 = (x61)<(x34); x63 = (x60)+(x62); x64 = (x8)*(x7); x65 = sizeof(intptr_t) == 4 ? ((uint64_t)(x8)*(x7))>>32 : ((__uint128_t)(x8)*(x7))>>64; x66 = (x8)*(x6); x67 = sizeof(intptr_t) == 4 ? ((uint64_t)(x8)*(x6))>>32 : ((__uint128_t)(x8)*(x6))>>64; x68 = (x8)*(x5); x69 = sizeof(intptr_t) == 4 ? ((uint64_t)(x8)*(x5))>>32 : ((__uint128_t)(x8)*(x5))>>64; x70 = (x8)*(x4); x71 = sizeof(intptr_t) == 4 ? ((uint64_t)(x8)*(x4))>>32 : ((__uint128_t)(x8)*(x4))>>64; x72 = (x71)+(x68); x73 = (x72)<(x71); x74 = (x73)+(x69); x75 = (x74)<(x69); x76 = (x74)+(x66); x77 = (x76)<(x66); x78 = (x75)+(x77); x79 = (x78)+(x67); x80 = (x79)<(x67); x81 = (x79)+(x64); x82 = (x81)<(x64); x83 = (x80)+(x82); x84 = (x83)+(x65); x85 = (x46)+(x70); x86 = (x85)<(x46); x87 = (x86)+(x51); x88 = (x87)<(x51); x89 = (x87)+(x72); x90 = (x89)<(x72); x91 = (x88)+(x90); x92 = (x91)+(x56); x93 = (x92)<(x56); x94 = (x92)+(x76); x95 = (x94)<(x76); x96 = (x93)+(x95); x97 = (x96)+(x61); x98 = (x97)<(x61); x99 = (x97)+(x81); x100 = (x99)<(x81); x101 = (x98)+(x100); x102 = (x101)+(x63); x103 = (x102)<(x63); x104 = (x102)+(x84); x105 = (x104)<(x84); x106 = (x103)+(x105); x107 = (x85)*((uintptr_t)18446744069414584321ULL); x108 = sizeof(intptr_t) == 4 ? ((uint64_t)(x85)*((uintptr_t)18446744069414584321ULL))>>32 : ((__uint128_t)(x85)*((uintptr_t)18446744069414584321ULL))>>64; x109 = (x85)*((uintptr_t)4294967295ULL); x110 = sizeof(intptr_t) == 4 ? ((uint64_t)(x85)*((uintptr_t)4294967295ULL))>>32 : ((__uint128_t)(x85)*((uintptr_t)4294967295ULL))>>64; x111 = (x85)*((uintptr_t)18446744073709551615ULL); x112 = sizeof(intptr_t) == 4 ? ((uint64_t)(x85)*((uintptr_t)18446744073709551615ULL))>>32 : ((__uint128_t)(x85)*((uintptr_t)18446744073709551615ULL))>>64; x113 = (x112)+(x109); x114 = (x113)<(x112); x115 = (x114)+(x110); x116 = (x85)+(x111); x117 = (x116)<(x85); x118 = (x117)+(x89); x119 = (x118)<(x89); x120 = (x118)+(x113); x121 = (x120)<(x113); x122 = (x119)+(x121); x123 = (x122)+(x94); x124 = (x123)<(x94); x125 = (x123)+(x115); x126 = (x125)<(x115); x127 = (x124)+(x126); x128 = (x127)+(x99); x129 = (x128)<(x99); x130 = (x128)+(x107); x131 = (x130)<(x107); x132 = (x129)+(x131); x133 = (x132)+(x104); x134 = (x133)<(x104); x135 = (x133)+(x108); x136 = (x135)<(x108); x137 = (x134)+(x136); x138 = (x137)+(x106); x139 = (x9)*(x7); x140 = sizeof(intptr_t) == 4 ? ((uint64_t)(x9)*(x7))>>32 : ((__uint128_t)(x9)*(x7))>>64; x141 = (x9)*(x6); x142 = sizeof(intptr_t) == 4 ? ((uint64_t)(x9)*(x6))>>32 : ((__uint128_t)(x9)*(x6))>>64; x143 = (x9)*(x5); x144 = sizeof(intptr_t) == 4 ? ((uint64_t)(x9)*(x5))>>32 : ((__uint128_t)(x9)*(x5))>>64; x145 = (x9)*(x4); x146 = sizeof(intptr_t) == 4 ? ((uint64_t)(x9)*(x4))>>32 : ((__uint128_t)(x9)*(x4))>>64; x147 = (x146)+(x143); x148 = (x147)<(x146); x149 = (x148)+(x144); x150 = (x149)<(x144); x151 = (x149)+(x141); x152 = (x151)<(x141); x153 = (x150)+(x152); x154 = (x153)+(x142); x155 = (x154)<(x142); x156 = (x154)+(x139); x157 = (x156)<(x139); x158 = (x155)+(x157); x159 = (x158)+(x140); x160 = (x120)+(x145); x161 = (x160)<(x120); x162 = (x161)+(x125); x163 = (x162)<(x125); x164 = (x162)+(x147); x165 = (x164)<(x147); x166 = (x163)+(x165); x167 = (x166)+(x130); x168 = (x167)<(x130); x169 = (x167)+(x151); x170 = (x169)<(x151); x171 = (x168)+(x170); x172 = (x171)+(x135); x173 = (x172)<(x135); x174 = (x172)+(x156); x175 = (x174)<(x156); x176 = (x173)+(x175); x177 = (x176)+(x138); x178 = (x177)<(x138); x179 = (x177)+(x159); x180 = (x179)<(x159); x181 = (x178)+(x180); x182 = (x160)*((uintptr_t)18446744069414584321ULL); x183 = sizeof(intptr_t) == 4 ? ((uint64_t)(x160)*((uintptr_t)18446744069414584321ULL))>>32 : ((__uint128_t)(x160)*((uintptr_t)18446744069414584321ULL))>>64; x184 = (x160)*((uintptr_t)4294967295ULL); x185 = sizeof(intptr_t) == 4 ? ((uint64_t)(x160)*((uintptr_t)4294967295ULL))>>32 : ((__uint128_t)(x160)*((uintptr_t)4294967295ULL))>>64; x186 = (x160)*((uintptr_t)18446744073709551615ULL); x187 = sizeof(intptr_t) == 4 ? ((uint64_t)(x160)*((uintptr_t)18446744073709551615ULL))>>32 : ((__uint128_t)(x160)*((uintptr_t)18446744073709551615ULL))>>64; x188 = (x187)+(x184); x189 = (x188)<(x187); x190 = (x189)+(x185); x191 = (x160)+(x186); x192 = (x191)<(x160); x193 = (x192)+(x164); x194 = (x193)<(x164); x195 = (x193)+(x188); x196 = (x195)<(x188); x197 = (x194)+(x196); x198 = (x197)+(x169); x199 = (x198)<(x169); x200 = (x198)+(x190); x201 = (x200)<(x190); x202 = (x199)+(x201); x203 = (x202)+(x174); x204 = (x203)<(x174); x205 = (x203)+(x182); x206 = (x205)<(x182); x207 = (x204)+(x206); x208 = (x207)+(x179); x209 = (x208)<(x179); x210 = (x208)+(x183); x211 = (x210)<(x183); x212 = (x209)+(x211); x213 = (x212)+(x181); x214 = (x10)*(x7); x215 = sizeof(intptr_t) == 4 ? ((uint64_t)(x10)*(x7))>>32 : ((__uint128_t)(x10)*(x7))>>64; x216 = (x10)*(x6); x217 = sizeof(intptr_t) == 4 ? ((uint64_t)(x10)*(x6))>>32 : ((__uint128_t)(x10)*(x6))>>64; x218 = (x10)*(x5); x219 = sizeof(intptr_t) == 4 ? ((uint64_t)(x10)*(x5))>>32 : ((__uint128_t)(x10)*(x5))>>64; x220 = (x10)*(x4); x221 = sizeof(intptr_t) == 4 ? ((uint64_t)(x10)*(x4))>>32 : ((__uint128_t)(x10)*(x4))>>64; x222 = (x221)+(x218); x223 = (x222)<(x221); x224 = (x223)+(x219); x225 = (x224)<(x219); x226 = (x224)+(x216); x227 = (x226)<(x216); x228 = (x225)+(x227); x229 = (x228)+(x217); x230 = (x229)<(x217); x231 = (x229)+(x214); x232 = (x231)<(x214); x233 = (x230)+(x232); x234 = (x233)+(x215); x235 = (x195)+(x220); x236 = (x235)<(x195); x237 = (x236)+(x200); x238 = (x237)<(x200); x239 = (x237)+(x222); x240 = (x239)<(x222); x241 = (x238)+(x240); x242 = (x241)+(x205); x243 = (x242)<(x205); x244 = (x242)+(x226); x245 = (x244)<(x226); x246 = (x243)+(x245); x247 = (x246)+(x210); x248 = (x247)<(x210); x249 = (x247)+(x231); x250 = (x249)<(x231); x251 = (x248)+(x250); x252 = (x251)+(x213); x253 = (x252)<(x213); x254 = (x252)+(x234); x255 = (x254)<(x234); x256 = (x253)+(x255); x257 = (x235)*((uintptr_t)18446744069414584321ULL); x258 = sizeof(intptr_t) == 4 ? ((uint64_t)(x235)*((uintptr_t)18446744069414584321ULL))>>32 : ((__uint128_t)(x235)*((uintptr_t)18446744069414584321ULL))>>64; x259 = (x235)*((uintptr_t)4294967295ULL); x260 = sizeof(intptr_t) == 4 ? ((uint64_t)(x235)*((uintptr_t)4294967295ULL))>>32 : ((__uint128_t)(x235)*((uintptr_t)4294967295ULL))>>64; x261 = (x235)*((uintptr_t)18446744073709551615ULL); x262 = sizeof(intptr_t) == 4 ? ((uint64_t)(x235)*((uintptr_t)18446744073709551615ULL))>>32 : ((__uint128_t)(x235)*((uintptr_t)18446744073709551615ULL))>>64; x263 = (x262)+(x259); x264 = (x263)<(x262); x265 = (x264)+(x260); x266 = (x235)+(x261); x267 = (x266)<(x235); x268 = (x267)+(x239); x269 = (x268)<(x239); x270 = (x268)+(x263); x271 = (x270)<(x263); x272 = (x269)+(x271); x273 = (x272)+(x244); x274 = (x273)<(x244); x275 = (x273)+(x265); x276 = (x275)<(x265); x277 = (x274)+(x276); x278 = (x277)+(x249); x279 = (x278)<(x249); x280 = (x278)+(x257); x281 = (x280)<(x257); x282 = (x279)+(x281); x283 = (x282)+(x254); x284 = (x283)<(x254); x285 = (x283)+(x258); x286 = (x285)<(x258); x287 = (x284)+(x286); x288 = (x287)+(x256); x289 = (x270)-((uintptr_t)18446744073709551615ULL); x290 = (x270)<(x289); x291 = (x275)-((uintptr_t)4294967295ULL); x292 = (x275)<(x291); x293 = (x291)-(x290); x294 = (x291)<(x293); x295 = (x292)+(x294); x296 = (x280)-(x295); x297 = (x280)<(x296); x298 = (x285)-((uintptr_t)18446744069414584321ULL); x299 = (x285)<(x298); x300 = (x298)-(x297); x301 = (x298)<(x300); x302 = (x299)+(x301); x303 = (x288)-(x302); x304 = (x288)<(x303); x305 = ((uintptr_t)-1ULL)+((x304)==((uintptr_t)0ULL)); x306 = (x305)^((uintptr_t)18446744073709551615ULL); x307 = ((x270)&(x305))|((x289)&(x306)); x308 = ((uintptr_t)-1ULL)+((x304)==((uintptr_t)0ULL)); x309 = (x308)^((uintptr_t)18446744073709551615ULL); x310 = ((x275)&(x308))|((x293)&(x309)); x311 = ((uintptr_t)-1ULL)+((x304)==((uintptr_t)0ULL)); x312 = (x311)^((uintptr_t)18446744073709551615ULL); x313 = ((x280)&(x311))|((x296)&(x312)); x314 = ((uintptr_t)-1ULL)+((x304)==((uintptr_t)0ULL)); x315 = (x314)^((uintptr_t)18446744073709551615ULL); x316 = ((x285)&(x314))|((x300)&(x315)); x317 = x307; x318 = x310; x319 = x313; x320 = x316; /*skip*/ _br2_store((out0)+((uintptr_t)0ULL), x317, sizeof(uintptr_t)); _br2_store((out0)+((uintptr_t)8ULL), x318, sizeof(uintptr_t)); _br2_store((out0)+((uintptr_t)16ULL), x319, sizeof(uintptr_t)); _br2_store((out0)+((uintptr_t)24ULL), x320, sizeof(uintptr_t)); /*skip*/ return; } /* NOTE: The following wrapper function is not covered by Coq proofs */ static void fiat_p256_mul(uint64_t out1[4], const uint64_t arg1[4], const uint64_t arg2[4]) { internal_fiat_p256_mul((uintptr_t)out1, (uintptr_t)arg1, (uintptr_t)arg2); } /* * Input Bounds: * in0: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] * Output Bounds: * out0: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] */ static void internal_fiat_p256_square(uintptr_t out0, uintptr_t in0) { uintptr_t x7, x12, x15, x17, x13, x18, x10, x19, x21, x22, x11, x23, x8, x24, x26, x27, x9, x31, x34, x36, x32, x33, x38, x14, x39, x16, x40, x35, x41, x43, x44, x20, x45, x37, x46, x48, x49, x25, x50, x29, x51, x53, x54, x28, x55, x30, x56, x58, x4, x64, x67, x69, x65, x70, x62, x71, x73, x74, x63, x75, x60, x76, x78, x79, x61, x66, x42, x82, x47, x83, x68, x84, x86, x87, x52, x88, x72, x89, x91, x92, x57, x93, x77, x94, x96, x97, x59, x98, x80, x99, x101, x105, x108, x110, x106, x107, x112, x81, x113, x85, x114, x109, x115, x117, x118, x90, x119, x111, x120, x122, x123, x95, x124, x103, x125, x127, x128, x100, x129, x104, x130, x132, x133, x102, x5, x139, x142, x144, x140, x145, x137, x146, x148, x149, x138, x150, x135, x151, x153, x154, x136, x141, x116, x157, x121, x158, x143, x159, x161, x162, x126, x163, x147, x164, x166, x167, x131, x168, x152, x169, x171, x172, x134, x173, x155, x174, x176, x180, x183, x185, x181, x182, x187, x156, x188, x160, x189, x184, x190, x192, x193, x165, x194, x186, x195, x197, x198, x170, x199, x178, x200, x202, x203, x175, x204, x179, x205, x207, x208, x177, x3, x2, x1, x6, x0, x214, x217, x219, x215, x220, x212, x221, x223, x224, x213, x225, x210, x226, x228, x229, x211, x216, x191, x232, x196, x233, x218, x234, x236, x237, x201, x238, x222, x239, x241, x242, x206, x243, x227, x244, x246, x247, x209, x248, x230, x249, x251, x255, x258, x260, x256, x257, x262, x231, x263, x235, x264, x259, x265, x267, x268, x240, x269, x261, x270, x272, x273, x245, x274, x253, x275, x277, x278, x250, x279, x254, x280, x282, x283, x252, x286, x287, x288, x290, x291, x293, x294, x295, x297, x298, x284, x299, x266, x301, x285, x302, x271, x304, x289, x305, x276, x307, x292, x308, x300, x281, x310, x296, x311, x303, x306, x309, x312, x313, x314, x315, x316; x0 = _br2_load((in0)+((uintptr_t)0ULL), sizeof(uintptr_t)); x1 = _br2_load((in0)+((uintptr_t)8ULL), sizeof(uintptr_t)); x2 = _br2_load((in0)+((uintptr_t)16ULL), sizeof(uintptr_t)); x3 = _br2_load((in0)+((uintptr_t)24ULL), sizeof(uintptr_t)); /*skip*/ /*skip*/ x4 = x1; x5 = x2; x6 = x3; x7 = x0; x8 = (x7)*(x3); x9 = sizeof(intptr_t) == 4 ? ((uint64_t)(x7)*(x3))>>32 : ((__uint128_t)(x7)*(x3))>>64; x10 = (x7)*(x2); x11 = sizeof(intptr_t) == 4 ? ((uint64_t)(x7)*(x2))>>32 : ((__uint128_t)(x7)*(x2))>>64; x12 = (x7)*(x1); x13 = sizeof(intptr_t) == 4 ? ((uint64_t)(x7)*(x1))>>32 : ((__uint128_t)(x7)*(x1))>>64; x14 = (x7)*(x0); x15 = sizeof(intptr_t) == 4 ? ((uint64_t)(x7)*(x0))>>32 : ((__uint128_t)(x7)*(x0))>>64; x16 = (x15)+(x12); x17 = (x16)<(x15); x18 = (x17)+(x13); x19 = (x18)<(x13); x20 = (x18)+(x10); x21 = (x20)<(x10); x22 = (x19)+(x21); x23 = (x22)+(x11); x24 = (x23)<(x11); x25 = (x23)+(x8); x26 = (x25)<(x8); x27 = (x24)+(x26); x28 = (x27)+(x9); x29 = (x14)*((uintptr_t)18446744069414584321ULL); x30 = sizeof(intptr_t) == 4 ? ((uint64_t)(x14)*((uintptr_t)18446744069414584321ULL))>>32 : ((__uint128_t)(x14)*((uintptr_t)18446744069414584321ULL))>>64; x31 = (x14)*((uintptr_t)4294967295ULL); x32 = sizeof(intptr_t) == 4 ? ((uint64_t)(x14)*((uintptr_t)4294967295ULL))>>32 : ((__uint128_t)(x14)*((uintptr_t)4294967295ULL))>>64; x33 = (x14)*((uintptr_t)18446744073709551615ULL); x34 = sizeof(intptr_t) == 4 ? ((uint64_t)(x14)*((uintptr_t)18446744073709551615ULL))>>32 : ((__uint128_t)(x14)*((uintptr_t)18446744073709551615ULL))>>64; x35 = (x34)+(x31); x36 = (x35)<(x34); x37 = (x36)+(x32); x38 = (x14)+(x33); x39 = (x38)<(x14); x40 = (x39)+(x16); x41 = (x40)<(x16); x42 = (x40)+(x35); x43 = (x42)<(x35); x44 = (x41)+(x43); x45 = (x44)+(x20); x46 = (x45)<(x20); x47 = (x45)+(x37); x48 = (x47)<(x37); x49 = (x46)+(x48); x50 = (x49)+(x25); x51 = (x50)<(x25); x52 = (x50)+(x29); x53 = (x52)<(x29); x54 = (x51)+(x53); x55 = (x54)+(x28); x56 = (x55)<(x28); x57 = (x55)+(x30); x58 = (x57)<(x30); x59 = (x56)+(x58); x60 = (x4)*(x3); x61 = sizeof(intptr_t) == 4 ? ((uint64_t)(x4)*(x3))>>32 : ((__uint128_t)(x4)*(x3))>>64; x62 = (x4)*(x2); x63 = sizeof(intptr_t) == 4 ? ((uint64_t)(x4)*(x2))>>32 : ((__uint128_t)(x4)*(x2))>>64; x64 = (x4)*(x1); x65 = sizeof(intptr_t) == 4 ? ((uint64_t)(x4)*(x1))>>32 : ((__uint128_t)(x4)*(x1))>>64; x66 = (x4)*(x0); x67 = sizeof(intptr_t) == 4 ? ((uint64_t)(x4)*(x0))>>32 : ((__uint128_t)(x4)*(x0))>>64; x68 = (x67)+(x64); x69 = (x68)<(x67); x70 = (x69)+(x65); x71 = (x70)<(x65); x72 = (x70)+(x62); x73 = (x72)<(x62); x74 = (x71)+(x73); x75 = (x74)+(x63); x76 = (x75)<(x63); x77 = (x75)+(x60); x78 = (x77)<(x60); x79 = (x76)+(x78); x80 = (x79)+(x61); x81 = (x42)+(x66); x82 = (x81)<(x42); x83 = (x82)+(x47); x84 = (x83)<(x47); x85 = (x83)+(x68); x86 = (x85)<(x68); x87 = (x84)+(x86); x88 = (x87)+(x52); x89 = (x88)<(x52); x90 = (x88)+(x72); x91 = (x90)<(x72); x92 = (x89)+(x91); x93 = (x92)+(x57); x94 = (x93)<(x57); x95 = (x93)+(x77); x96 = (x95)<(x77); x97 = (x94)+(x96); x98 = (x97)+(x59); x99 = (x98)<(x59); x100 = (x98)+(x80); x101 = (x100)<(x80); x102 = (x99)+(x101); x103 = (x81)*((uintptr_t)18446744069414584321ULL); x104 = sizeof(intptr_t) == 4 ? ((uint64_t)(x81)*((uintptr_t)18446744069414584321ULL))>>32 : ((__uint128_t)(x81)*((uintptr_t)18446744069414584321ULL))>>64; x105 = (x81)*((uintptr_t)4294967295ULL); x106 = sizeof(intptr_t) == 4 ? ((uint64_t)(x81)*((uintptr_t)4294967295ULL))>>32 : ((__uint128_t)(x81)*((uintptr_t)4294967295ULL))>>64; x107 = (x81)*((uintptr_t)18446744073709551615ULL); x108 = sizeof(intptr_t) == 4 ? ((uint64_t)(x81)*((uintptr_t)18446744073709551615ULL))>>32 : ((__uint128_t)(x81)*((uintptr_t)18446744073709551615ULL))>>64; x109 = (x108)+(x105); x110 = (x109)<(x108); x111 = (x110)+(x106); x112 = (x81)+(x107); x113 = (x112)<(x81); x114 = (x113)+(x85); x115 = (x114)<(x85); x116 = (x114)+(x109); x117 = (x116)<(x109); x118 = (x115)+(x117); x119 = (x118)+(x90); x120 = (x119)<(x90); x121 = (x119)+(x111); x122 = (x121)<(x111); x123 = (x120)+(x122); x124 = (x123)+(x95); x125 = (x124)<(x95); x126 = (x124)+(x103); x127 = (x126)<(x103); x128 = (x125)+(x127); x129 = (x128)+(x100); x130 = (x129)<(x100); x131 = (x129)+(x104); x132 = (x131)<(x104); x133 = (x130)+(x132); x134 = (x133)+(x102); x135 = (x5)*(x3); x136 = sizeof(intptr_t) == 4 ? ((uint64_t)(x5)*(x3))>>32 : ((__uint128_t)(x5)*(x3))>>64; x137 = (x5)*(x2); x138 = sizeof(intptr_t) == 4 ? ((uint64_t)(x5)*(x2))>>32 : ((__uint128_t)(x5)*(x2))>>64; x139 = (x5)*(x1); x140 = sizeof(intptr_t) == 4 ? ((uint64_t)(x5)*(x1))>>32 : ((__uint128_t)(x5)*(x1))>>64; x141 = (x5)*(x0); x142 = sizeof(intptr_t) == 4 ? ((uint64_t)(x5)*(x0))>>32 : ((__uint128_t)(x5)*(x0))>>64; x143 = (x142)+(x139); x144 = (x143)<(x142); x145 = (x144)+(x140); x146 = (x145)<(x140); x147 = (x145)+(x137); x148 = (x147)<(x137); x149 = (x146)+(x148); x150 = (x149)+(x138); x151 = (x150)<(x138); x152 = (x150)+(x135); x153 = (x152)<(x135); x154 = (x151)+(x153); x155 = (x154)+(x136); x156 = (x116)+(x141); x157 = (x156)<(x116); x158 = (x157)+(x121); x159 = (x158)<(x121); x160 = (x158)+(x143); x161 = (x160)<(x143); x162 = (x159)+(x161); x163 = (x162)+(x126); x164 = (x163)<(x126); x165 = (x163)+(x147); x166 = (x165)<(x147); x167 = (x164)+(x166); x168 = (x167)+(x131); x169 = (x168)<(x131); x170 = (x168)+(x152); x171 = (x170)<(x152); x172 = (x169)+(x171); x173 = (x172)+(x134); x174 = (x173)<(x134); x175 = (x173)+(x155); x176 = (x175)<(x155); x177 = (x174)+(x176); x178 = (x156)*((uintptr_t)18446744069414584321ULL); x179 = sizeof(intptr_t) == 4 ? ((uint64_t)(x156)*((uintptr_t)18446744069414584321ULL))>>32 : ((__uint128_t)(x156)*((uintptr_t)18446744069414584321ULL))>>64; x180 = (x156)*((uintptr_t)4294967295ULL); x181 = sizeof(intptr_t) == 4 ? ((uint64_t)(x156)*((uintptr_t)4294967295ULL))>>32 : ((__uint128_t)(x156)*((uintptr_t)4294967295ULL))>>64; x182 = (x156)*((uintptr_t)18446744073709551615ULL); x183 = sizeof(intptr_t) == 4 ? ((uint64_t)(x156)*((uintptr_t)18446744073709551615ULL))>>32 : ((__uint128_t)(x156)*((uintptr_t)18446744073709551615ULL))>>64; x184 = (x183)+(x180); x185 = (x184)<(x183); x186 = (x185)+(x181); x187 = (x156)+(x182); x188 = (x187)<(x156); x189 = (x188)+(x160); x190 = (x189)<(x160); x191 = (x189)+(x184); x192 = (x191)<(x184); x193 = (x190)+(x192); x194 = (x193)+(x165); x195 = (x194)<(x165); x196 = (x194)+(x186); x197 = (x196)<(x186); x198 = (x195)+(x197); x199 = (x198)+(x170); x200 = (x199)<(x170); x201 = (x199)+(x178); x202 = (x201)<(x178); x203 = (x200)+(x202); x204 = (x203)+(x175); x205 = (x204)<(x175); x206 = (x204)+(x179); x207 = (x206)<(x179); x208 = (x205)+(x207); x209 = (x208)+(x177); x210 = (x6)*(x3); x211 = sizeof(intptr_t) == 4 ? ((uint64_t)(x6)*(x3))>>32 : ((__uint128_t)(x6)*(x3))>>64; x212 = (x6)*(x2); x213 = sizeof(intptr_t) == 4 ? ((uint64_t)(x6)*(x2))>>32 : ((__uint128_t)(x6)*(x2))>>64; x214 = (x6)*(x1); x215 = sizeof(intptr_t) == 4 ? ((uint64_t)(x6)*(x1))>>32 : ((__uint128_t)(x6)*(x1))>>64; x216 = (x6)*(x0); x217 = sizeof(intptr_t) == 4 ? ((uint64_t)(x6)*(x0))>>32 : ((__uint128_t)(x6)*(x0))>>64; x218 = (x217)+(x214); x219 = (x218)<(x217); x220 = (x219)+(x215); x221 = (x220)<(x215); x222 = (x220)+(x212); x223 = (x222)<(x212); x224 = (x221)+(x223); x225 = (x224)+(x213); x226 = (x225)<(x213); x227 = (x225)+(x210); x228 = (x227)<(x210); x229 = (x226)+(x228); x230 = (x229)+(x211); x231 = (x191)+(x216); x232 = (x231)<(x191); x233 = (x232)+(x196); x234 = (x233)<(x196); x235 = (x233)+(x218); x236 = (x235)<(x218); x237 = (x234)+(x236); x238 = (x237)+(x201); x239 = (x238)<(x201); x240 = (x238)+(x222); x241 = (x240)<(x222); x242 = (x239)+(x241); x243 = (x242)+(x206); x244 = (x243)<(x206); x245 = (x243)+(x227); x246 = (x245)<(x227); x247 = (x244)+(x246); x248 = (x247)+(x209); x249 = (x248)<(x209); x250 = (x248)+(x230); x251 = (x250)<(x230); x252 = (x249)+(x251); x253 = (x231)*((uintptr_t)18446744069414584321ULL); x254 = sizeof(intptr_t) == 4 ? ((uint64_t)(x231)*((uintptr_t)18446744069414584321ULL))>>32 : ((__uint128_t)(x231)*((uintptr_t)18446744069414584321ULL))>>64; x255 = (x231)*((uintptr_t)4294967295ULL); x256 = sizeof(intptr_t) == 4 ? ((uint64_t)(x231)*((uintptr_t)4294967295ULL))>>32 : ((__uint128_t)(x231)*((uintptr_t)4294967295ULL))>>64; x257 = (x231)*((uintptr_t)18446744073709551615ULL); x258 = sizeof(intptr_t) == 4 ? ((uint64_t)(x231)*((uintptr_t)18446744073709551615ULL))>>32 : ((__uint128_t)(x231)*((uintptr_t)18446744073709551615ULL))>>64; x259 = (x258)+(x255); x260 = (x259)<(x258); x261 = (x260)+(x256); x262 = (x231)+(x257); x263 = (x262)<(x231); x264 = (x263)+(x235); x265 = (x264)<(x235); x266 = (x264)+(x259); x267 = (x266)<(x259); x268 = (x265)+(x267); x269 = (x268)+(x240); x270 = (x269)<(x240); x271 = (x269)+(x261); x272 = (x271)<(x261); x273 = (x270)+(x272); x274 = (x273)+(x245); x275 = (x274)<(x245); x276 = (x274)+(x253); x277 = (x276)<(x253); x278 = (x275)+(x277); x279 = (x278)+(x250); x280 = (x279)<(x250); x281 = (x279)+(x254); x282 = (x281)<(x254); x283 = (x280)+(x282); x284 = (x283)+(x252); x285 = (x266)-((uintptr_t)18446744073709551615ULL); x286 = (x266)<(x285); x287 = (x271)-((uintptr_t)4294967295ULL); x288 = (x271)<(x287); x289 = (x287)-(x286); x290 = (x287)<(x289); x291 = (x288)+(x290); x292 = (x276)-(x291); x293 = (x276)<(x292); x294 = (x281)-((uintptr_t)18446744069414584321ULL); x295 = (x281)<(x294); x296 = (x294)-(x293); x297 = (x294)<(x296); x298 = (x295)+(x297); x299 = (x284)-(x298); x300 = (x284)<(x299); x301 = ((uintptr_t)-1ULL)+((x300)==((uintptr_t)0ULL)); x302 = (x301)^((uintptr_t)18446744073709551615ULL); x303 = ((x266)&(x301))|((x285)&(x302)); x304 = ((uintptr_t)-1ULL)+((x300)==((uintptr_t)0ULL)); x305 = (x304)^((uintptr_t)18446744073709551615ULL); x306 = ((x271)&(x304))|((x289)&(x305)); x307 = ((uintptr_t)-1ULL)+((x300)==((uintptr_t)0ULL)); x308 = (x307)^((uintptr_t)18446744073709551615ULL); x309 = ((x276)&(x307))|((x292)&(x308)); x310 = ((uintptr_t)-1ULL)+((x300)==((uintptr_t)0ULL)); x311 = (x310)^((uintptr_t)18446744073709551615ULL); x312 = ((x281)&(x310))|((x296)&(x311)); x313 = x303; x314 = x306; x315 = x309; x316 = x312; /*skip*/ _br2_store((out0)+((uintptr_t)0ULL), x313, sizeof(uintptr_t)); _br2_store((out0)+((uintptr_t)8ULL), x314, sizeof(uintptr_t)); _br2_store((out0)+((uintptr_t)16ULL), x315, sizeof(uintptr_t)); _br2_store((out0)+((uintptr_t)24ULL), x316, sizeof(uintptr_t)); /*skip*/ return; } /* NOTE: The following wrapper function is not covered by Coq proofs */ static void fiat_p256_square(uint64_t out1[4], const uint64_t arg1[4]) { internal_fiat_p256_square((uintptr_t)out1, (uintptr_t)arg1); } /* * Input Bounds: * in0: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] * in1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] * Output Bounds: * out0: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] */ static void internal_fiat_p256_add(uintptr_t out0, uintptr_t in0, uintptr_t in1) { uintptr_t x4, x0, x9, x1, x5, x11, x2, x6, x13, x3, x7, x17, x15, x20, x8, x23, x16, x24, x10, x26, x18, x27, x12, x29, x19, x30, x22, x14, x32, x21, x33, x25, x28, x31, x34, x35, x36, x37, x38; x0 = _br2_load((in0)+((uintptr_t)0ULL), sizeof(uintptr_t)); x1 = _br2_load((in0)+((uintptr_t)8ULL), sizeof(uintptr_t)); x2 = _br2_load((in0)+((uintptr_t)16ULL), sizeof(uintptr_t)); x3 = _br2_load((in0)+((uintptr_t)24ULL), sizeof(uintptr_t)); /*skip*/ x4 = _br2_load((in1)+((uintptr_t)0ULL), sizeof(uintptr_t)); x5 = _br2_load((in1)+((uintptr_t)8ULL), sizeof(uintptr_t)); x6 = _br2_load((in1)+((uintptr_t)16ULL), sizeof(uintptr_t)); x7 = _br2_load((in1)+((uintptr_t)24ULL), sizeof(uintptr_t)); /*skip*/ /*skip*/ x8 = (x0)+(x4); x9 = ((x8)<(x0))+(x1); x10 = (x9)+(x5); x11 = (((x9)<(x1))+((x10)<(x5)))+(x2); x12 = (x11)+(x6); x13 = (((x11)<(x2))+((x12)<(x6)))+(x3); x14 = (x13)+(x7); x15 = ((x13)<(x3))+((x14)<(x7)); x16 = (x8)-((uintptr_t)18446744073709551615ULL); x17 = (x10)-((uintptr_t)4294967295ULL); x18 = (x17)-((x8)<(x16)); x19 = (x12)-(((x10)<(x17))+((x17)<(x18))); x20 = (x14)-((uintptr_t)18446744069414584321ULL); x21 = (x20)-((x12)<(x19)); x22 = (x15)<((x15)-(((x14)<(x20))+((x20)<(x21)))); x23 = ((uintptr_t)-1ULL)+((x22)==((uintptr_t)0ULL)); x24 = (x23)^((uintptr_t)18446744073709551615ULL); x25 = ((x8)&(x23))|((x16)&(x24)); x26 = ((uintptr_t)-1ULL)+((x22)==((uintptr_t)0ULL)); x27 = (x26)^((uintptr_t)18446744073709551615ULL); x28 = ((x10)&(x26))|((x18)&(x27)); x29 = ((uintptr_t)-1ULL)+((x22)==((uintptr_t)0ULL)); x30 = (x29)^((uintptr_t)18446744073709551615ULL); x31 = ((x12)&(x29))|((x19)&(x30)); x32 = ((uintptr_t)-1ULL)+((x22)==((uintptr_t)0ULL)); x33 = (x32)^((uintptr_t)18446744073709551615ULL); x34 = ((x14)&(x32))|((x21)&(x33)); x35 = x25; x36 = x28; x37 = x31; x38 = x34; /*skip*/ _br2_store((out0)+((uintptr_t)0ULL), x35, sizeof(uintptr_t)); _br2_store((out0)+((uintptr_t)8ULL), x36, sizeof(uintptr_t)); _br2_store((out0)+((uintptr_t)16ULL), x37, sizeof(uintptr_t)); _br2_store((out0)+((uintptr_t)24ULL), x38, sizeof(uintptr_t)); /*skip*/ return; } /* NOTE: The following wrapper function is not covered by Coq proofs */ static void fiat_p256_add(uint64_t out1[4], const uint64_t arg1[4], const uint64_t arg2[4]) { internal_fiat_p256_add((uintptr_t)out1, (uintptr_t)arg1, (uintptr_t)arg2); } /* * Input Bounds: * in0: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] * in1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] * Output Bounds: * out0: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] */ static void internal_fiat_p256_sub(uintptr_t out0, uintptr_t in0, uintptr_t in1) { uintptr_t x4, x5, x0, x6, x1, x9, x7, x2, x11, x3, x13, x8, x17, x10, x12, x14, x15, x16, x18, x19, x20, x21, x22, x23, x24; x0 = _br2_load((in0)+((uintptr_t)0ULL), sizeof(uintptr_t)); x1 = _br2_load((in0)+((uintptr_t)8ULL), sizeof(uintptr_t)); x2 = _br2_load((in0)+((uintptr_t)16ULL), sizeof(uintptr_t)); x3 = _br2_load((in0)+((uintptr_t)24ULL), sizeof(uintptr_t)); /*skip*/ x4 = _br2_load((in1)+((uintptr_t)0ULL), sizeof(uintptr_t)); x5 = _br2_load((in1)+((uintptr_t)8ULL), sizeof(uintptr_t)); x6 = _br2_load((in1)+((uintptr_t)16ULL), sizeof(uintptr_t)); x7 = _br2_load((in1)+((uintptr_t)24ULL), sizeof(uintptr_t)); /*skip*/ /*skip*/ x8 = (x0)-(x4); x9 = (x1)-(x5); x10 = (x9)-((x0)<(x8)); x11 = (x2)-(x6); x12 = (x11)-(((x1)<(x9))+((x9)<(x10))); x13 = (x3)-(x7); x14 = (x13)-(((x2)<(x11))+((x11)<(x12))); x15 = ((uintptr_t)-1ULL)+((((x3)<(x13))+((x13)<(x14)))==((uintptr_t)0ULL)); x16 = (x8)+(x15); x17 = ((x16)<(x8))+(x10); x18 = (x17)+((x15)&((uintptr_t)4294967295ULL)); x19 = (((x17)<(x10))+((x18)<((x15)&((uintptr_t)4294967295ULL))))+(x12); x20 = (((x19)<(x12))+(x14))+((x15)&((uintptr_t)18446744069414584321ULL)); x21 = x16; x22 = x18; x23 = x19; x24 = x20; /*skip*/ _br2_store((out0)+((uintptr_t)0ULL), x21, sizeof(uintptr_t)); _br2_store((out0)+((uintptr_t)8ULL), x22, sizeof(uintptr_t)); _br2_store((out0)+((uintptr_t)16ULL), x23, sizeof(uintptr_t)); _br2_store((out0)+((uintptr_t)24ULL), x24, sizeof(uintptr_t)); /*skip*/ return; } /* NOTE: The following wrapper function is not covered by Coq proofs */ static void fiat_p256_sub(uint64_t out1[4], const uint64_t arg1[4], const uint64_t arg2[4]) { internal_fiat_p256_sub((uintptr_t)out1, (uintptr_t)arg1, (uintptr_t)arg2); } /* * Input Bounds: * in0: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] * Output Bounds: * out0: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] */ static void internal_fiat_p256_opp(uintptr_t out0, uintptr_t in0) { uintptr_t x0, x1, x2, x5, x3, x7, x9, x4, x13, x6, x8, x10, x11, x12, x14, x15, x16, x17, x18, x19, x20; x0 = _br2_load((in0)+((uintptr_t)0ULL), sizeof(uintptr_t)); x1 = _br2_load((in0)+((uintptr_t)8ULL), sizeof(uintptr_t)); x2 = _br2_load((in0)+((uintptr_t)16ULL), sizeof(uintptr_t)); x3 = _br2_load((in0)+((uintptr_t)24ULL), sizeof(uintptr_t)); /*skip*/ /*skip*/ x4 = ((uintptr_t)0ULL)-(x0); x5 = ((uintptr_t)0ULL)-(x1); x6 = (x5)-(((uintptr_t)0ULL)<(x4)); x7 = ((uintptr_t)0ULL)-(x2); x8 = (x7)-((((uintptr_t)0ULL)<(x5))+((x5)<(x6))); x9 = ((uintptr_t)0ULL)-(x3); x10 = (x9)-((((uintptr_t)0ULL)<(x7))+((x7)<(x8))); x11 = ((uintptr_t)-1ULL)+(((((uintptr_t)0ULL)<(x9))+((x9)<(x10)))==((uintptr_t)0ULL)); x12 = (x4)+(x11); x13 = ((x12)<(x4))+(x6); x14 = (x13)+((x11)&((uintptr_t)4294967295ULL)); x15 = (((x13)<(x6))+((x14)<((x11)&((uintptr_t)4294967295ULL))))+(x8); x16 = (((x15)<(x8))+(x10))+((x11)&((uintptr_t)18446744069414584321ULL)); x17 = x12; x18 = x14; x19 = x15; x20 = x16; /*skip*/ _br2_store((out0)+((uintptr_t)0ULL), x17, sizeof(uintptr_t)); _br2_store((out0)+((uintptr_t)8ULL), x18, sizeof(uintptr_t)); _br2_store((out0)+((uintptr_t)16ULL), x19, sizeof(uintptr_t)); _br2_store((out0)+((uintptr_t)24ULL), x20, sizeof(uintptr_t)); /*skip*/ return; } /* NOTE: The following wrapper function is not covered by Coq proofs */ static void fiat_p256_opp(uint64_t out1[4], const uint64_t arg1[4]) { internal_fiat_p256_opp((uintptr_t)out1, (uintptr_t)arg1); } /* * Input Bounds: * in0: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] * Output Bounds: * out0: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] */ static void internal_fiat_p256_from_montgomery(uintptr_t out0, uintptr_t in0) { uintptr_t x0, x8, x4, x9, x1, x11, x18, x13, x21, x14, x12, x10, x7, x19, x23, x5, x20, x17, x25, x6, x15, x2, x22, x24, x26, x35, x28, x38, x29, x36, x40, x30, x37, x34, x42, x31, x27, x16, x32, x3, x39, x41, x43, x51, x54, x46, x52, x56, x47, x53, x50, x58, x48, x44, x33, x49, x45, x62, x65, x55, x68, x61, x69, x57, x71, x63, x72, x59, x74, x64, x75, x67, x60, x77, x66, x78, x70, x73, x76, x79, x80, x81, x82, x83; x0 = _br2_load((in0)+((uintptr_t)0ULL), sizeof(uintptr_t)); x1 = _br2_load((in0)+((uintptr_t)8ULL), sizeof(uintptr_t)); x2 = _br2_load((in0)+((uintptr_t)16ULL), sizeof(uintptr_t)); x3 = _br2_load((in0)+((uintptr_t)24ULL), sizeof(uintptr_t)); /*skip*/ /*skip*/ x4 = x0; x5 = (x4)*((uintptr_t)18446744069414584321ULL); x6 = sizeof(intptr_t) == 4 ? ((uint64_t)(x4)*((uintptr_t)18446744069414584321ULL))>>32 : ((__uint128_t)(x4)*((uintptr_t)18446744069414584321ULL))>>64; x7 = sizeof(intptr_t) == 4 ? ((uint64_t)(x4)*((uintptr_t)4294967295ULL))>>32 : ((__uint128_t)(x4)*((uintptr_t)4294967295ULL))>>64; x8 = sizeof(intptr_t) == 4 ? ((uint64_t)(x4)*((uintptr_t)18446744073709551615ULL))>>32 : ((__uint128_t)(x4)*((uintptr_t)18446744073709551615ULL))>>64; x9 = (x8)+((x4)*((uintptr_t)4294967295ULL)); x10 = (x9)<(x8); x11 = (((x4)+((x4)*((uintptr_t)18446744073709551615ULL)))<(x4))+(x9); x12 = (x11)<(x9); x13 = (x11)+(x1); x14 = (x13)<(x11); x15 = (x13)*((uintptr_t)18446744069414584321ULL); x16 = sizeof(intptr_t) == 4 ? ((uint64_t)(x13)*((uintptr_t)18446744069414584321ULL))>>32 : ((__uint128_t)(x13)*((uintptr_t)18446744069414584321ULL))>>64; x17 = sizeof(intptr_t) == 4 ? ((uint64_t)(x13)*((uintptr_t)4294967295ULL))>>32 : ((__uint128_t)(x13)*((uintptr_t)4294967295ULL))>>64; x18 = sizeof(intptr_t) == 4 ? ((uint64_t)(x13)*((uintptr_t)18446744073709551615ULL))>>32 : ((__uint128_t)(x13)*((uintptr_t)18446744073709551615ULL))>>64; x19 = (x18)+((x13)*((uintptr_t)4294967295ULL)); x20 = (x19)<(x18); x21 = (((x13)+((x13)*((uintptr_t)18446744073709551615ULL)))<(x13))+((x14)+((x12)+((x10)+(x7)))); x22 = (x21)+(x19); x23 = (((x21)<((x14)+((x12)+((x10)+(x7)))))+((x22)<(x19)))+(x5); x24 = (x23)+((x20)+(x17)); x25 = (((x23)<(x5))+((x24)<((x20)+(x17))))+(x6); x26 = (x25)+(x15); x27 = ((x25)<(x6))+((x26)<(x15)); x28 = (x22)+(x2); x29 = ((x28)<(x22))+(x24); x30 = ((x29)<(x24))+(x26); x31 = (x30)<(x26); x32 = (x28)*((uintptr_t)18446744069414584321ULL); x33 = sizeof(intptr_t) == 4 ? ((uint64_t)(x28)*((uintptr_t)18446744069414584321ULL))>>32 : ((__uint128_t)(x28)*((uintptr_t)18446744069414584321ULL))>>64; x34 = sizeof(intptr_t) == 4 ? ((uint64_t)(x28)*((uintptr_t)4294967295ULL))>>32 : ((__uint128_t)(x28)*((uintptr_t)4294967295ULL))>>64; x35 = sizeof(intptr_t) == 4 ? ((uint64_t)(x28)*((uintptr_t)18446744073709551615ULL))>>32 : ((__uint128_t)(x28)*((uintptr_t)18446744073709551615ULL))>>64; x36 = (x35)+((x28)*((uintptr_t)4294967295ULL)); x37 = (x36)<(x35); x38 = (((x28)+((x28)*((uintptr_t)18446744073709551615ULL)))<(x28))+(x29); x39 = (x38)+(x36); x40 = (((x38)<(x29))+((x39)<(x36)))+(x30); x41 = (x40)+((x37)+(x34)); x42 = (((x40)<(x30))+((x41)<((x37)+(x34))))+((x31)+((x27)+(x16))); x43 = (x42)+(x32); x44 = ((x42)<((x31)+((x27)+(x16))))+((x43)<(x32)); x45 = (x39)+(x3); x46 = ((x45)<(x39))+(x41); x47 = ((x46)<(x41))+(x43); x48 = (x47)<(x43); x49 = (x45)*((uintptr_t)18446744069414584321ULL); x50 = sizeof(intptr_t) == 4 ? ((uint64_t)(x45)*((uintptr_t)4294967295ULL))>>32 : ((__uint128_t)(x45)*((uintptr_t)4294967295ULL))>>64; x51 = sizeof(intptr_t) == 4 ? ((uint64_t)(x45)*((uintptr_t)18446744073709551615ULL))>>32 : ((__uint128_t)(x45)*((uintptr_t)18446744073709551615ULL))>>64; x52 = (x51)+((x45)*((uintptr_t)4294967295ULL)); x53 = (x52)<(x51); x54 = (((x45)+((x45)*((uintptr_t)18446744073709551615ULL)))<(x45))+(x46); x55 = (x54)+(x52); x56 = (((x54)<(x46))+((x55)<(x52)))+(x47); x57 = (x56)+((x53)+(x50)); x58 = (((x56)<(x47))+((x57)<((x53)+(x50))))+((x48)+((x44)+(x33))); x59 = (x58)+(x49); x60 = (((x58)<((x48)+((x44)+(x33))))+((x59)<(x49)))+(sizeof(intptr_t) == 4 ? ((uint64_t)(x45)*((uintptr_t)18446744069414584321ULL))>>32 : ((__uint128_t)(x45)*((uintptr_t)18446744069414584321ULL))>>64); x61 = (x55)-((uintptr_t)18446744073709551615ULL); x62 = (x57)-((uintptr_t)4294967295ULL); x63 = (x62)-((x55)<(x61)); x64 = (x59)-(((x57)<(x62))+((x62)<(x63))); x65 = (x60)-((uintptr_t)18446744069414584321ULL); x66 = (x65)-((x59)<(x64)); x67 = ((uintptr_t)0ULL)<(((uintptr_t)0ULL)-(((x60)<(x65))+((x65)<(x66)))); x68 = ((uintptr_t)-1ULL)+((x67)==((uintptr_t)0ULL)); x69 = (x68)^((uintptr_t)18446744073709551615ULL); x70 = ((x55)&(x68))|((x61)&(x69)); x71 = ((uintptr_t)-1ULL)+((x67)==((uintptr_t)0ULL)); x72 = (x71)^((uintptr_t)18446744073709551615ULL); x73 = ((x57)&(x71))|((x63)&(x72)); x74 = ((uintptr_t)-1ULL)+((x67)==((uintptr_t)0ULL)); x75 = (x74)^((uintptr_t)18446744073709551615ULL); x76 = ((x59)&(x74))|((x64)&(x75)); x77 = ((uintptr_t)-1ULL)+((x67)==((uintptr_t)0ULL)); x78 = (x77)^((uintptr_t)18446744073709551615ULL); x79 = ((x60)&(x77))|((x66)&(x78)); x80 = x70; x81 = x73; x82 = x76; x83 = x79; /*skip*/ _br2_store((out0)+((uintptr_t)0ULL), x80, sizeof(uintptr_t)); _br2_store((out0)+((uintptr_t)8ULL), x81, sizeof(uintptr_t)); _br2_store((out0)+((uintptr_t)16ULL), x82, sizeof(uintptr_t)); _br2_store((out0)+((uintptr_t)24ULL), x83, sizeof(uintptr_t)); /*skip*/ return; } /* NOTE: The following wrapper function is not covered by Coq proofs */ static void fiat_p256_from_montgomery(uint64_t out1[4], const uint64_t arg1[4]) { internal_fiat_p256_from_montgomery((uintptr_t)out1, (uintptr_t)arg1); } /* * Input Bounds: * in0: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] * Output Bounds: * out0: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] */ static void internal_fiat_p256_to_montgomery(uintptr_t out0, uintptr_t in0) { uintptr_t x1, x2, x3, x0, x7, x14, x16, x12, x10, x18, x11, x8, x24, x13, x27, x15, x25, x29, x17, x26, x23, x31, x19, x21, x33, x20, x9, x22, x41, x43, x40, x38, x45, x39, x36, x4, x28, x49, x30, x42, x51, x32, x44, x53, x34, x46, x59, x48, x62, x50, x60, x64, x52, x61, x58, x66, x54, x56, x68, x55, x35, x47, x37, x57, x76, x78, x75, x73, x80, x74, x71, x5, x63, x84, x65, x77, x86, x67, x79, x88, x69, x81, x94, x83, x97, x85, x95, x99, x87, x96, x93, x101, x89, x91, x103, x90, x70, x82, x72, x92, x111, x113, x110, x108, x115, x109, x106, x6, x98, x119, x100, x112, x121, x102, x114, x123, x104, x116, x129, x118, x132, x120, x130, x134, x122, x131, x128, x136, x124, x126, x138, x125, x105, x117, x107, x127, x142, x140, x145, x133, x148, x141, x149, x135, x151, x143, x152, x137, x154, x144, x155, x147, x139, x157, x146, x158, x150, x153, x156, x159, x160, x161, x162, x163; x0 = _br2_load((in0)+((uintptr_t)0ULL), sizeof(uintptr_t)); x1 = _br2_load((in0)+((uintptr_t)8ULL), sizeof(uintptr_t)); x2 = _br2_load((in0)+((uintptr_t)16ULL), sizeof(uintptr_t)); x3 = _br2_load((in0)+((uintptr_t)24ULL), sizeof(uintptr_t)); /*skip*/ /*skip*/ x4 = x1; x5 = x2; x6 = x3; x7 = x0; x8 = (x7)*((uintptr_t)21474836477ULL); x9 = sizeof(intptr_t) == 4 ? ((uint64_t)(x7)*((uintptr_t)21474836477ULL))>>32 : ((__uint128_t)(x7)*((uintptr_t)21474836477ULL))>>64; x10 = (x7)*((uintptr_t)18446744073709551614ULL); x11 = sizeof(intptr_t) == 4 ? ((uint64_t)(x7)*((uintptr_t)18446744073709551614ULL))>>32 : ((__uint128_t)(x7)*((uintptr_t)18446744073709551614ULL))>>64; x12 = sizeof(intptr_t) == 4 ? ((uint64_t)(x7)*((uintptr_t)18446744056529682431ULL))>>32 : ((__uint128_t)(x7)*((uintptr_t)18446744056529682431ULL))>>64; x13 = (x7)*((uintptr_t)3ULL); x14 = sizeof(intptr_t) == 4 ? ((uint64_t)(x7)*((uintptr_t)3ULL))>>32 : ((__uint128_t)(x7)*((uintptr_t)3ULL))>>64; x15 = (x14)+((x7)*((uintptr_t)18446744056529682431ULL)); x16 = ((x15)<(x14))+(x12); x17 = (x16)+(x10); x18 = (((x16)<(x12))+((x17)<(x10)))+(x11); x19 = (x18)+(x8); x20 = ((x18)<(x11))+((x19)<(x8)); x21 = (x13)*((uintptr_t)18446744069414584321ULL); x22 = sizeof(intptr_t) == 4 ? ((uint64_t)(x13)*((uintptr_t)18446744069414584321ULL))>>32 : ((__uint128_t)(x13)*((uintptr_t)18446744069414584321ULL))>>64; x23 = sizeof(intptr_t) == 4 ? ((uint64_t)(x13)*((uintptr_t)4294967295ULL))>>32 : ((__uint128_t)(x13)*((uintptr_t)4294967295ULL))>>64; x24 = sizeof(intptr_t) == 4 ? ((uint64_t)(x13)*((uintptr_t)18446744073709551615ULL))>>32 : ((__uint128_t)(x13)*((uintptr_t)18446744073709551615ULL))>>64; x25 = (x24)+((x13)*((uintptr_t)4294967295ULL)); x26 = (x25)<(x24); x27 = (((x13)+((x13)*((uintptr_t)18446744073709551615ULL)))<(x13))+(x15); x28 = (x27)+(x25); x29 = (((x27)<(x15))+((x28)<(x25)))+(x17); x30 = (x29)+((x26)+(x23)); x31 = (((x29)<(x17))+((x30)<((x26)+(x23))))+(x19); x32 = (x31)+(x21); x33 = (((x31)<(x19))+((x32)<(x21)))+((x20)+(x9)); x34 = (x33)+(x22); x35 = ((x33)<((x20)+(x9)))+((x34)<(x22)); x36 = (x4)*((uintptr_t)21474836477ULL); x37 = sizeof(intptr_t) == 4 ? ((uint64_t)(x4)*((uintptr_t)21474836477ULL))>>32 : ((__uint128_t)(x4)*((uintptr_t)21474836477ULL))>>64; x38 = (x4)*((uintptr_t)18446744073709551614ULL); x39 = sizeof(intptr_t) == 4 ? ((uint64_t)(x4)*((uintptr_t)18446744073709551614ULL))>>32 : ((__uint128_t)(x4)*((uintptr_t)18446744073709551614ULL))>>64; x40 = sizeof(intptr_t) == 4 ? ((uint64_t)(x4)*((uintptr_t)18446744056529682431ULL))>>32 : ((__uint128_t)(x4)*((uintptr_t)18446744056529682431ULL))>>64; x41 = sizeof(intptr_t) == 4 ? ((uint64_t)(x4)*((uintptr_t)3ULL))>>32 : ((__uint128_t)(x4)*((uintptr_t)3ULL))>>64; x42 = (x41)+((x4)*((uintptr_t)18446744056529682431ULL)); x43 = ((x42)<(x41))+(x40); x44 = (x43)+(x38); x45 = (((x43)<(x40))+((x44)<(x38)))+(x39); x46 = (x45)+(x36); x47 = ((x45)<(x39))+((x46)<(x36)); x48 = (x28)+((x4)*((uintptr_t)3ULL)); x49 = ((x48)<(x28))+(x30); x50 = (x49)+(x42); x51 = (((x49)<(x30))+((x50)<(x42)))+(x32); x52 = (x51)+(x44); x53 = (((x51)<(x32))+((x52)<(x44)))+(x34); x54 = (x53)+(x46); x55 = ((x53)<(x34))+((x54)<(x46)); x56 = (x48)*((uintptr_t)18446744069414584321ULL); x57 = sizeof(intptr_t) == 4 ? ((uint64_t)(x48)*((uintptr_t)18446744069414584321ULL))>>32 : ((__uint128_t)(x48)*((uintptr_t)18446744069414584321ULL))>>64; x58 = sizeof(intptr_t) == 4 ? ((uint64_t)(x48)*((uintptr_t)4294967295ULL))>>32 : ((__uint128_t)(x48)*((uintptr_t)4294967295ULL))>>64; x59 = sizeof(intptr_t) == 4 ? ((uint64_t)(x48)*((uintptr_t)18446744073709551615ULL))>>32 : ((__uint128_t)(x48)*((uintptr_t)18446744073709551615ULL))>>64; x60 = (x59)+((x48)*((uintptr_t)4294967295ULL)); x61 = (x60)<(x59); x62 = (((x48)+((x48)*((uintptr_t)18446744073709551615ULL)))<(x48))+(x50); x63 = (x62)+(x60); x64 = (((x62)<(x50))+((x63)<(x60)))+(x52); x65 = (x64)+((x61)+(x58)); x66 = (((x64)<(x52))+((x65)<((x61)+(x58))))+(x54); x67 = (x66)+(x56); x68 = (((x66)<(x54))+((x67)<(x56)))+(((x55)+(x35))+((x47)+(x37))); x69 = (x68)+(x57); x70 = ((x68)<(((x55)+(x35))+((x47)+(x37))))+((x69)<(x57)); x71 = (x5)*((uintptr_t)21474836477ULL); x72 = sizeof(intptr_t) == 4 ? ((uint64_t)(x5)*((uintptr_t)21474836477ULL))>>32 : ((__uint128_t)(x5)*((uintptr_t)21474836477ULL))>>64; x73 = (x5)*((uintptr_t)18446744073709551614ULL); x74 = sizeof(intptr_t) == 4 ? ((uint64_t)(x5)*((uintptr_t)18446744073709551614ULL))>>32 : ((__uint128_t)(x5)*((uintptr_t)18446744073709551614ULL))>>64; x75 = sizeof(intptr_t) == 4 ? ((uint64_t)(x5)*((uintptr_t)18446744056529682431ULL))>>32 : ((__uint128_t)(x5)*((uintptr_t)18446744056529682431ULL))>>64; x76 = sizeof(intptr_t) == 4 ? ((uint64_t)(x5)*((uintptr_t)3ULL))>>32 : ((__uint128_t)(x5)*((uintptr_t)3ULL))>>64; x77 = (x76)+((x5)*((uintptr_t)18446744056529682431ULL)); x78 = ((x77)<(x76))+(x75); x79 = (x78)+(x73); x80 = (((x78)<(x75))+((x79)<(x73)))+(x74); x81 = (x80)+(x71); x82 = ((x80)<(x74))+((x81)<(x71)); x83 = (x63)+((x5)*((uintptr_t)3ULL)); x84 = ((x83)<(x63))+(x65); x85 = (x84)+(x77); x86 = (((x84)<(x65))+((x85)<(x77)))+(x67); x87 = (x86)+(x79); x88 = (((x86)<(x67))+((x87)<(x79)))+(x69); x89 = (x88)+(x81); x90 = ((x88)<(x69))+((x89)<(x81)); x91 = (x83)*((uintptr_t)18446744069414584321ULL); x92 = sizeof(intptr_t) == 4 ? ((uint64_t)(x83)*((uintptr_t)18446744069414584321ULL))>>32 : ((__uint128_t)(x83)*((uintptr_t)18446744069414584321ULL))>>64; x93 = sizeof(intptr_t) == 4 ? ((uint64_t)(x83)*((uintptr_t)4294967295ULL))>>32 : ((__uint128_t)(x83)*((uintptr_t)4294967295ULL))>>64; x94 = sizeof(intptr_t) == 4 ? ((uint64_t)(x83)*((uintptr_t)18446744073709551615ULL))>>32 : ((__uint128_t)(x83)*((uintptr_t)18446744073709551615ULL))>>64; x95 = (x94)+((x83)*((uintptr_t)4294967295ULL)); x96 = (x95)<(x94); x97 = (((x83)+((x83)*((uintptr_t)18446744073709551615ULL)))<(x83))+(x85); x98 = (x97)+(x95); x99 = (((x97)<(x85))+((x98)<(x95)))+(x87); x100 = (x99)+((x96)+(x93)); x101 = (((x99)<(x87))+((x100)<((x96)+(x93))))+(x89); x102 = (x101)+(x91); x103 = (((x101)<(x89))+((x102)<(x91)))+(((x90)+(x70))+((x82)+(x72))); x104 = (x103)+(x92); x105 = ((x103)<(((x90)+(x70))+((x82)+(x72))))+((x104)<(x92)); x106 = (x6)*((uintptr_t)21474836477ULL); x107 = sizeof(intptr_t) == 4 ? ((uint64_t)(x6)*((uintptr_t)21474836477ULL))>>32 : ((__uint128_t)(x6)*((uintptr_t)21474836477ULL))>>64; x108 = (x6)*((uintptr_t)18446744073709551614ULL); x109 = sizeof(intptr_t) == 4 ? ((uint64_t)(x6)*((uintptr_t)18446744073709551614ULL))>>32 : ((__uint128_t)(x6)*((uintptr_t)18446744073709551614ULL))>>64; x110 = sizeof(intptr_t) == 4 ? ((uint64_t)(x6)*((uintptr_t)18446744056529682431ULL))>>32 : ((__uint128_t)(x6)*((uintptr_t)18446744056529682431ULL))>>64; x111 = sizeof(intptr_t) == 4 ? ((uint64_t)(x6)*((uintptr_t)3ULL))>>32 : ((__uint128_t)(x6)*((uintptr_t)3ULL))>>64; x112 = (x111)+((x6)*((uintptr_t)18446744056529682431ULL)); x113 = ((x112)<(x111))+(x110); x114 = (x113)+(x108); x115 = (((x113)<(x110))+((x114)<(x108)))+(x109); x116 = (x115)+(x106); x117 = ((x115)<(x109))+((x116)<(x106)); x118 = (x98)+((x6)*((uintptr_t)3ULL)); x119 = ((x118)<(x98))+(x100); x120 = (x119)+(x112); x121 = (((x119)<(x100))+((x120)<(x112)))+(x102); x122 = (x121)+(x114); x123 = (((x121)<(x102))+((x122)<(x114)))+(x104); x124 = (x123)+(x116); x125 = ((x123)<(x104))+((x124)<(x116)); x126 = (x118)*((uintptr_t)18446744069414584321ULL); x127 = sizeof(intptr_t) == 4 ? ((uint64_t)(x118)*((uintptr_t)18446744069414584321ULL))>>32 : ((__uint128_t)(x118)*((uintptr_t)18446744069414584321ULL))>>64; x128 = sizeof(intptr_t) == 4 ? ((uint64_t)(x118)*((uintptr_t)4294967295ULL))>>32 : ((__uint128_t)(x118)*((uintptr_t)4294967295ULL))>>64; x129 = sizeof(intptr_t) == 4 ? ((uint64_t)(x118)*((uintptr_t)18446744073709551615ULL))>>32 : ((__uint128_t)(x118)*((uintptr_t)18446744073709551615ULL))>>64; x130 = (x129)+((x118)*((uintptr_t)4294967295ULL)); x131 = (x130)<(x129); x132 = (((x118)+((x118)*((uintptr_t)18446744073709551615ULL)))<(x118))+(x120); x133 = (x132)+(x130); x134 = (((x132)<(x120))+((x133)<(x130)))+(x122); x135 = (x134)+((x131)+(x128)); x136 = (((x134)<(x122))+((x135)<((x131)+(x128))))+(x124); x137 = (x136)+(x126); x138 = (((x136)<(x124))+((x137)<(x126)))+(((x125)+(x105))+((x117)+(x107))); x139 = (x138)+(x127); x140 = ((x138)<(((x125)+(x105))+((x117)+(x107))))+((x139)<(x127)); x141 = (x133)-((uintptr_t)18446744073709551615ULL); x142 = (x135)-((uintptr_t)4294967295ULL); x143 = (x142)-((x133)<(x141)); x144 = (x137)-(((x135)<(x142))+((x142)<(x143))); x145 = (x139)-((uintptr_t)18446744069414584321ULL); x146 = (x145)-((x137)<(x144)); x147 = (x140)<((x140)-(((x139)<(x145))+((x145)<(x146)))); x148 = ((uintptr_t)-1ULL)+((x147)==((uintptr_t)0ULL)); x149 = (x148)^((uintptr_t)18446744073709551615ULL); x150 = ((x133)&(x148))|((x141)&(x149)); x151 = ((uintptr_t)-1ULL)+((x147)==((uintptr_t)0ULL)); x152 = (x151)^((uintptr_t)18446744073709551615ULL); x153 = ((x135)&(x151))|((x143)&(x152)); x154 = ((uintptr_t)-1ULL)+((x147)==((uintptr_t)0ULL)); x155 = (x154)^((uintptr_t)18446744073709551615ULL); x156 = ((x137)&(x154))|((x144)&(x155)); x157 = ((uintptr_t)-1ULL)+((x147)==((uintptr_t)0ULL)); x158 = (x157)^((uintptr_t)18446744073709551615ULL); x159 = ((x139)&(x157))|((x146)&(x158)); x160 = x150; x161 = x153; x162 = x156; x163 = x159; /*skip*/ _br2_store((out0)+((uintptr_t)0ULL), x160, sizeof(uintptr_t)); _br2_store((out0)+((uintptr_t)8ULL), x161, sizeof(uintptr_t)); _br2_store((out0)+((uintptr_t)16ULL), x162, sizeof(uintptr_t)); _br2_store((out0)+((uintptr_t)24ULL), x163, sizeof(uintptr_t)); /*skip*/ return; } /* NOTE: The following wrapper function is not covered by Coq proofs */ static void fiat_p256_to_montgomery(uint64_t out1[4], const uint64_t arg1[4]) { internal_fiat_p256_to_montgomery((uintptr_t)out1, (uintptr_t)arg1); } /* * Input Bounds: * in0: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] * Output Bounds: * out0: [0x0 ~> 0xffffffffffffffff] */ static uintptr_t internal_fiat_p256_nonzero(uintptr_t in0) { uintptr_t x0, x1, x2, x3, x4, out0, x5; x0 = _br2_load((in0)+((uintptr_t)0ULL), sizeof(uintptr_t)); x1 = _br2_load((in0)+((uintptr_t)8ULL), sizeof(uintptr_t)); x2 = _br2_load((in0)+((uintptr_t)16ULL), sizeof(uintptr_t)); x3 = _br2_load((in0)+((uintptr_t)24ULL), sizeof(uintptr_t)); /*skip*/ /*skip*/ x4 = (x0)|((x1)|((x2)|(x3))); x5 = x4; out0 = x5; return out0; } /* NOTE: The following wrapper function is not covered by Coq proofs */ static void fiat_p256_nonzero(uint64_t* out1, const uint64_t arg1[4]) { *out1 = (uint64_t)internal_fiat_p256_nonzero((uintptr_t)arg1); } /* * Input Bounds: * in0: [0x0 ~> 0x1] * in1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] * in2: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] * Output Bounds: * out0: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] */ static void internal_fiat_p256_selectznz(uintptr_t out0, uintptr_t in0, uintptr_t in1, uintptr_t in2) { uintptr_t x4, x8, x0, x9, x5, x11, x1, x12, x6, x14, x2, x15, x7, x17, x3, x18, x10, x13, x16, x19, x20, x21, x22, x23; /*skip*/ x0 = _br2_load((in1)+((uintptr_t)0ULL), sizeof(uintptr_t)); x1 = _br2_load((in1)+((uintptr_t)8ULL), sizeof(uintptr_t)); x2 = _br2_load((in1)+((uintptr_t)16ULL), sizeof(uintptr_t)); x3 = _br2_load((in1)+((uintptr_t)24ULL), sizeof(uintptr_t)); /*skip*/ x4 = _br2_load((in2)+((uintptr_t)0ULL), sizeof(uintptr_t)); x5 = _br2_load((in2)+((uintptr_t)8ULL), sizeof(uintptr_t)); x6 = _br2_load((in2)+((uintptr_t)16ULL), sizeof(uintptr_t)); x7 = _br2_load((in2)+((uintptr_t)24ULL), sizeof(uintptr_t)); /*skip*/ /*skip*/ x8 = ((uintptr_t)-1ULL)+((in0)==((uintptr_t)0ULL)); x9 = (x8)^((uintptr_t)18446744073709551615ULL); x10 = ((x4)&(x8))|((x0)&(x9)); x11 = ((uintptr_t)-1ULL)+((in0)==((uintptr_t)0ULL)); x12 = (x11)^((uintptr_t)18446744073709551615ULL); x13 = ((x5)&(x11))|((x1)&(x12)); x14 = ((uintptr_t)-1ULL)+((in0)==((uintptr_t)0ULL)); x15 = (x14)^((uintptr_t)18446744073709551615ULL); x16 = ((x6)&(x14))|((x2)&(x15)); x17 = ((uintptr_t)-1ULL)+((in0)==((uintptr_t)0ULL)); x18 = (x17)^((uintptr_t)18446744073709551615ULL); x19 = ((x7)&(x17))|((x3)&(x18)); x20 = x10; x21 = x13; x22 = x16; x23 = x19; /*skip*/ _br2_store((out0)+((uintptr_t)0ULL), x20, sizeof(uintptr_t)); _br2_store((out0)+((uintptr_t)8ULL), x21, sizeof(uintptr_t)); _br2_store((out0)+((uintptr_t)16ULL), x22, sizeof(uintptr_t)); _br2_store((out0)+((uintptr_t)24ULL), x23, sizeof(uintptr_t)); /*skip*/ return; } /* NOTE: The following wrapper function is not covered by Coq proofs */ static void fiat_p256_selectznz(uint64_t out1[4], uint8_t arg1, const uint64_t arg2[4], const uint64_t arg3[4]) { internal_fiat_p256_selectznz((uintptr_t)out1, (uintptr_t)arg1, (uintptr_t)arg2, (uintptr_t)arg3); } /* * Input Bounds: * in0: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] * Output Bounds: * out0: [[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], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff]] */ static void internal_fiat_p256_to_bytes(uintptr_t out0, uintptr_t in0) { uintptr_t x3, x2, x1, x0, x7, x9, x11, x13, x15, x17, x19, x6, x23, x25, x27, x29, x31, x33, x5, x37, x39, x41, x43, x45, x47, x4, x51, x53, x55, x57, x59, x61, x8, x10, x12, x14, x16, x18, x20, x21, x22, x24, x26, x28, x30, x32, x34, x35, x36, x38, x40, x42, x44, x46, x48, x49, x50, x52, x54, x56, x58, x60, x62, x63, x64, x65, x66, x67, x68, x69, x70, x71, x72, x73, x74, x75, x76, x77, x78, x79, x80, x81, x82, x83, x84, x85, x86, x87, x88, x89, x90, x91, x92, x93, x94, x95; x0 = _br2_load((in0)+((uintptr_t)0ULL), sizeof(uintptr_t)); x1 = _br2_load((in0)+((uintptr_t)8ULL), sizeof(uintptr_t)); x2 = _br2_load((in0)+((uintptr_t)16ULL), sizeof(uintptr_t)); x3 = _br2_load((in0)+((uintptr_t)24ULL), sizeof(uintptr_t)); /*skip*/ /*skip*/ x4 = x3; x5 = x2; x6 = x1; x7 = x0; x8 = (x7)&((uintptr_t)255ULL); x9 = (x7)>>((uintptr_t)8ULL); x10 = (x9)&((uintptr_t)255ULL); x11 = (x9)>>((uintptr_t)8ULL); x12 = (x11)&((uintptr_t)255ULL); x13 = (x11)>>((uintptr_t)8ULL); x14 = (x13)&((uintptr_t)255ULL); x15 = (x13)>>((uintptr_t)8ULL); x16 = (x15)&((uintptr_t)255ULL); x17 = (x15)>>((uintptr_t)8ULL); x18 = (x17)&((uintptr_t)255ULL); x19 = (x17)>>((uintptr_t)8ULL); x20 = (x19)&((uintptr_t)255ULL); x21 = (x19)>>((uintptr_t)8ULL); x22 = (x6)&((uintptr_t)255ULL); x23 = (x6)>>((uintptr_t)8ULL); x24 = (x23)&((uintptr_t)255ULL); x25 = (x23)>>((uintptr_t)8ULL); x26 = (x25)&((uintptr_t)255ULL); x27 = (x25)>>((uintptr_t)8ULL); x28 = (x27)&((uintptr_t)255ULL); x29 = (x27)>>((uintptr_t)8ULL); x30 = (x29)&((uintptr_t)255ULL); x31 = (x29)>>((uintptr_t)8ULL); x32 = (x31)&((uintptr_t)255ULL); x33 = (x31)>>((uintptr_t)8ULL); x34 = (x33)&((uintptr_t)255ULL); x35 = (x33)>>((uintptr_t)8ULL); x36 = (x5)&((uintptr_t)255ULL); x37 = (x5)>>((uintptr_t)8ULL); x38 = (x37)&((uintptr_t)255ULL); x39 = (x37)>>((uintptr_t)8ULL); x40 = (x39)&((uintptr_t)255ULL); x41 = (x39)>>((uintptr_t)8ULL); x42 = (x41)&((uintptr_t)255ULL); x43 = (x41)>>((uintptr_t)8ULL); x44 = (x43)&((uintptr_t)255ULL); x45 = (x43)>>((uintptr_t)8ULL); x46 = (x45)&((uintptr_t)255ULL); x47 = (x45)>>((uintptr_t)8ULL); x48 = (x47)&((uintptr_t)255ULL); x49 = (x47)>>((uintptr_t)8ULL); x50 = (x4)&((uintptr_t)255ULL); x51 = (x4)>>((uintptr_t)8ULL); x52 = (x51)&((uintptr_t)255ULL); x53 = (x51)>>((uintptr_t)8ULL); x54 = (x53)&((uintptr_t)255ULL); x55 = (x53)>>((uintptr_t)8ULL); x56 = (x55)&((uintptr_t)255ULL); x57 = (x55)>>((uintptr_t)8ULL); x58 = (x57)&((uintptr_t)255ULL); x59 = (x57)>>((uintptr_t)8ULL); x60 = (x59)&((uintptr_t)255ULL); x61 = (x59)>>((uintptr_t)8ULL); x62 = (x61)&((uintptr_t)255ULL); x63 = (x61)>>((uintptr_t)8ULL); x64 = x8; x65 = x10; x66 = x12; x67 = x14; x68 = x16; x69 = x18; x70 = x20; x71 = x21; x72 = x22; x73 = x24; x74 = x26; x75 = x28; x76 = x30; x77 = x32; x78 = x34; x79 = x35; x80 = x36; x81 = x38; x82 = x40; x83 = x42; x84 = x44; x85 = x46; x86 = x48; x87 = x49; x88 = x50; x89 = x52; x90 = x54; x91 = x56; x92 = x58; x93 = x60; x94 = x62; x95 = x63; /*skip*/ _br2_store((out0)+((uintptr_t)0ULL), x64, 1); _br2_store((out0)+((uintptr_t)1ULL), x65, 1); _br2_store((out0)+((uintptr_t)2ULL), x66, 1); _br2_store((out0)+((uintptr_t)3ULL), x67, 1); _br2_store((out0)+((uintptr_t)4ULL), x68, 1); _br2_store((out0)+((uintptr_t)5ULL), x69, 1); _br2_store((out0)+((uintptr_t)6ULL), x70, 1); _br2_store((out0)+((uintptr_t)7ULL), x71, 1); _br2_store((out0)+((uintptr_t)8ULL), x72, 1); _br2_store((out0)+((uintptr_t)9ULL), x73, 1); _br2_store((out0)+((uintptr_t)10ULL), x74, 1); _br2_store((out0)+((uintptr_t)11ULL), x75, 1); _br2_store((out0)+((uintptr_t)12ULL), x76, 1); _br2_store((out0)+((uintptr_t)13ULL), x77, 1); _br2_store((out0)+((uintptr_t)14ULL), x78, 1); _br2_store((out0)+((uintptr_t)15ULL), x79, 1); _br2_store((out0)+((uintptr_t)16ULL), x80, 1); _br2_store((out0)+((uintptr_t)17ULL), x81, 1); _br2_store((out0)+((uintptr_t)18ULL), x82, 1); _br2_store((out0)+((uintptr_t)19ULL), x83, 1); _br2_store((out0)+((uintptr_t)20ULL), x84, 1); _br2_store((out0)+((uintptr_t)21ULL), x85, 1); _br2_store((out0)+((uintptr_t)22ULL), x86, 1); _br2_store((out0)+((uintptr_t)23ULL), x87, 1); _br2_store((out0)+((uintptr_t)24ULL), x88, 1); _br2_store((out0)+((uintptr_t)25ULL), x89, 1); _br2_store((out0)+((uintptr_t)26ULL), x90, 1); _br2_store((out0)+((uintptr_t)27ULL), x91, 1); _br2_store((out0)+((uintptr_t)28ULL), x92, 1); _br2_store((out0)+((uintptr_t)29ULL), x93, 1); _br2_store((out0)+((uintptr_t)30ULL), x94, 1); _br2_store((out0)+((uintptr_t)31ULL), x95, 1); /*skip*/ return; } /* NOTE: The following wrapper function is not covered by Coq proofs */ static void fiat_p256_to_bytes(uint8_t out1[32], const uint64_t arg1[4]) { internal_fiat_p256_to_bytes((uintptr_t)out1, (uintptr_t)arg1); } /* * Input Bounds: * in0: [[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], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff]] * Output Bounds: * out0: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] */ static void internal_fiat_p256_from_bytes(uintptr_t out0, uintptr_t in0) { uintptr_t x31, x30, x29, x28, x27, x26, x25, x24, x23, x22, x21, x20, x19, x18, x17, x16, x15, x14, x13, x12, x11, x10, x9, x8, x7, x6, x5, x4, x3, x2, x1, x0, x62, x63, x61, x64, x60, x65, x59, x66, x58, x67, x57, x68, x56, x69, x54, x55, x53, x71, x52, x72, x51, x73, x50, x74, x49, x75, x48, x76, x46, x47, x45, x78, x44, x79, x43, x80, x42, x81, x41, x82, x40, x83, x38, x39, x37, x85, x36, x86, x35, x87, x34, x88, x33, x89, x32, x90, x70, x77, x84, x91, x92, x93, x94, x95; x0 = _br2_load((in0)+((uintptr_t)0ULL), 1); x1 = _br2_load((in0)+((uintptr_t)1ULL), 1); x2 = _br2_load((in0)+((uintptr_t)2ULL), 1); x3 = _br2_load((in0)+((uintptr_t)3ULL), 1); x4 = _br2_load((in0)+((uintptr_t)4ULL), 1); x5 = _br2_load((in0)+((uintptr_t)5ULL), 1); x6 = _br2_load((in0)+((uintptr_t)6ULL), 1); x7 = _br2_load((in0)+((uintptr_t)7ULL), 1); x8 = _br2_load((in0)+((uintptr_t)8ULL), 1); x9 = _br2_load((in0)+((uintptr_t)9ULL), 1); x10 = _br2_load((in0)+((uintptr_t)10ULL), 1); x11 = _br2_load((in0)+((uintptr_t)11ULL), 1); x12 = _br2_load((in0)+((uintptr_t)12ULL), 1); x13 = _br2_load((in0)+((uintptr_t)13ULL), 1); x14 = _br2_load((in0)+((uintptr_t)14ULL), 1); x15 = _br2_load((in0)+((uintptr_t)15ULL), 1); x16 = _br2_load((in0)+((uintptr_t)16ULL), 1); x17 = _br2_load((in0)+((uintptr_t)17ULL), 1); x18 = _br2_load((in0)+((uintptr_t)18ULL), 1); x19 = _br2_load((in0)+((uintptr_t)19ULL), 1); x20 = _br2_load((in0)+((uintptr_t)20ULL), 1); x21 = _br2_load((in0)+((uintptr_t)21ULL), 1); x22 = _br2_load((in0)+((uintptr_t)22ULL), 1); x23 = _br2_load((in0)+((uintptr_t)23ULL), 1); x24 = _br2_load((in0)+((uintptr_t)24ULL), 1); x25 = _br2_load((in0)+((uintptr_t)25ULL), 1); x26 = _br2_load((in0)+((uintptr_t)26ULL), 1); x27 = _br2_load((in0)+((uintptr_t)27ULL), 1); x28 = _br2_load((in0)+((uintptr_t)28ULL), 1); x29 = _br2_load((in0)+((uintptr_t)29ULL), 1); x30 = _br2_load((in0)+((uintptr_t)30ULL), 1); x31 = _br2_load((in0)+((uintptr_t)31ULL), 1); /*skip*/ /*skip*/ x32 = (x31)<<((uintptr_t)56ULL); x33 = (x30)<<((uintptr_t)48ULL); x34 = (x29)<<((uintptr_t)40ULL); x35 = (x28)<<((uintptr_t)32ULL); x36 = (x27)<<((uintptr_t)24ULL); x37 = (x26)<<((uintptr_t)16ULL); x38 = (x25)<<((uintptr_t)8ULL); x39 = x24; x40 = (x23)<<((uintptr_t)56ULL); x41 = (x22)<<((uintptr_t)48ULL); x42 = (x21)<<((uintptr_t)40ULL); x43 = (x20)<<((uintptr_t)32ULL); x44 = (x19)<<((uintptr_t)24ULL); x45 = (x18)<<((uintptr_t)16ULL); x46 = (x17)<<((uintptr_t)8ULL); x47 = x16; x48 = (x15)<<((uintptr_t)56ULL); x49 = (x14)<<((uintptr_t)48ULL); x50 = (x13)<<((uintptr_t)40ULL); x51 = (x12)<<((uintptr_t)32ULL); x52 = (x11)<<((uintptr_t)24ULL); x53 = (x10)<<((uintptr_t)16ULL); x54 = (x9)<<((uintptr_t)8ULL); x55 = x8; x56 = (x7)<<((uintptr_t)56ULL); x57 = (x6)<<((uintptr_t)48ULL); x58 = (x5)<<((uintptr_t)40ULL); x59 = (x4)<<((uintptr_t)32ULL); x60 = (x3)<<((uintptr_t)24ULL); x61 = (x2)<<((uintptr_t)16ULL); x62 = (x1)<<((uintptr_t)8ULL); x63 = x0; x64 = (x62)+(x63); x65 = (x61)+(x64); x66 = (x60)+(x65); x67 = (x59)+(x66); x68 = (x58)+(x67); x69 = (x57)+(x68); x70 = (x56)+(x69); x71 = (x54)+(x55); x72 = (x53)+(x71); x73 = (x52)+(x72); x74 = (x51)+(x73); x75 = (x50)+(x74); x76 = (x49)+(x75); x77 = (x48)+(x76); x78 = (x46)+(x47); x79 = (x45)+(x78); x80 = (x44)+(x79); x81 = (x43)+(x80); x82 = (x42)+(x81); x83 = (x41)+(x82); x84 = (x40)+(x83); x85 = (x38)+(x39); x86 = (x37)+(x85); x87 = (x36)+(x86); x88 = (x35)+(x87); x89 = (x34)+(x88); x90 = (x33)+(x89); x91 = (x32)+(x90); x92 = x70; x93 = x77; x94 = x84; x95 = x91; /*skip*/ _br2_store((out0)+((uintptr_t)0ULL), x92, sizeof(uintptr_t)); _br2_store((out0)+((uintptr_t)8ULL), x93, sizeof(uintptr_t)); _br2_store((out0)+((uintptr_t)16ULL), x94, sizeof(uintptr_t)); _br2_store((out0)+((uintptr_t)24ULL), x95, sizeof(uintptr_t)); /*skip*/ return; } /* NOTE: The following wrapper function is not covered by Coq proofs */ static void fiat_p256_from_bytes(uint64_t out1[4], const uint8_t arg1[32]) { internal_fiat_p256_from_bytes((uintptr_t)out1, (uintptr_t)arg1); } /* * Input Bounds: * Output Bounds: * out0: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] */ static void internal_fiat_p256_set_one(uintptr_t out0) { uintptr_t x0, x1, x2, x3; /*skip*/ x0 = (uintptr_t)1ULL; x1 = (uintptr_t)18446744069414584320ULL; x2 = (uintptr_t)18446744073709551615ULL; x3 = (uintptr_t)4294967294ULL; /*skip*/ _br2_store((out0)+((uintptr_t)0ULL), x0, sizeof(uintptr_t)); _br2_store((out0)+((uintptr_t)8ULL), x1, sizeof(uintptr_t)); _br2_store((out0)+((uintptr_t)16ULL), x2, sizeof(uintptr_t)); _br2_store((out0)+((uintptr_t)24ULL), x3, sizeof(uintptr_t)); /*skip*/ return; } /* NOTE: The following wrapper function is not covered by Coq proofs */ static void fiat_p256_set_one(uint64_t out1[4]) { internal_fiat_p256_set_one((uintptr_t)out1); } /* * Input Bounds: * Output Bounds: * out0: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] */ static void internal_fiat_p256_msat(uintptr_t out0) { uintptr_t x0, x1, x2, x3, x4; /*skip*/ x0 = (uintptr_t)18446744073709551615ULL; x1 = (uintptr_t)4294967295ULL; x2 = (uintptr_t)0ULL; x3 = (uintptr_t)18446744069414584321ULL; x4 = (uintptr_t)0ULL; /*skip*/ _br2_store((out0)+((uintptr_t)0ULL), x0, sizeof(uintptr_t)); _br2_store((out0)+((uintptr_t)8ULL), x1, sizeof(uintptr_t)); _br2_store((out0)+((uintptr_t)16ULL), x2, sizeof(uintptr_t)); _br2_store((out0)+((uintptr_t)24ULL), x3, sizeof(uintptr_t)); _br2_store((out0)+((uintptr_t)32ULL), x4, sizeof(uintptr_t)); /*skip*/ return; } /* NOTE: The following wrapper function is not covered by Coq proofs */ static void fiat_p256_msat(uint64_t out1[5]) { internal_fiat_p256_msat((uintptr_t)out1); } /* * Input Bounds: * in0: [0x0 ~> 0xffffffffffffffff] * in1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] * in2: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] * in3: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] * in4: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] * Output Bounds: * out0: [0x0 ~> 0xffffffffffffffff] * out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] * out2: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] * out3: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] * out4: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] */ static uintptr_t internal_fiat_p256_divstep(uintptr_t out1, uintptr_t out2, uintptr_t out3, uintptr_t out4, uintptr_t in0, uintptr_t in1, uintptr_t in2, uintptr_t in3, uintptr_t in4) { uintptr_t x18, x20, x21, x22, x24, x25, x27, x28, x30, x31, x33, x34, x36, x37, x0, x40, x1, x42, x2, x44, x3, x46, x4, x39, x48, x5, x49, x41, x51, x6, x52, x43, x54, x7, x55, x45, x57, x8, x58, x47, x60, x9, x61, x63, x64, x66, x67, x69, x70, x72, x73, x76, x77, x78, x80, x81, x82, x83, x85, x86, x87, x88, x90, x93, x94, x95, x97, x98, x100, x101, x102, x104, x105, x91, x106, x13, x12, x11, x10, x112, x110, x113, x115, x116, x109, x117, x119, x120, x108, x121, x123, x124, x111, x127, x114, x128, x129, x131, x132, x118, x134, x122, x135, x125, x126, x137, x14, x138, x130, x140, x15, x141, x133, x143, x16, x144, x19, x136, x146, x17, x147, x150, x151, x153, x154, x156, x157, x159, x160, x162, x163, x152, x50, x166, x53, x167, x155, x168, x170, x171, x56, x172, x158, x173, x175, x176, x59, x177, x161, x178, x180, x181, x62, x182, x164, x65, x184, x185, x68, x187, x188, x71, x190, x191, x149, x74, x193, x194, x186, x139, x197, x142, x198, x189, x199, x201, x202, x145, x203, x192, x204, x206, x207, x148, x208, x195, x209, x211, x214, x215, x216, x218, x219, x221, x222, x223, x225, x226, x212, x227, x23, x165, x169, x174, x179, x183, x75, x235, x92, x236, x79, x238, x96, x239, x84, x241, x99, x242, x107, x89, x244, x103, x245, x196, x247, x213, x248, x200, x250, x217, x251, x205, x253, x220, x254, x228, x210, x256, x224, x257, x229, x26, x29, x32, x35, x38, x230, x231, x232, x233, x234, x237, x240, x243, x246, x249, x252, x255, x258, out0, x259, x260, x261, x262, x263, x264, x265, x266, x267, x268, x269, x270, x271, x272, x273, x274, x275, x276, x277; /*skip*/ x0 = _br2_load((in1)+((uintptr_t)0ULL), sizeof(uintptr_t)); x1 = _br2_load((in1)+((uintptr_t)8ULL), sizeof(uintptr_t)); x2 = _br2_load((in1)+((uintptr_t)16ULL), sizeof(uintptr_t)); x3 = _br2_load((in1)+((uintptr_t)24ULL), sizeof(uintptr_t)); x4 = _br2_load((in1)+((uintptr_t)32ULL), sizeof(uintptr_t)); /*skip*/ x5 = _br2_load((in2)+((uintptr_t)0ULL), sizeof(uintptr_t)); x6 = _br2_load((in2)+((uintptr_t)8ULL), sizeof(uintptr_t)); x7 = _br2_load((in2)+((uintptr_t)16ULL), sizeof(uintptr_t)); x8 = _br2_load((in2)+((uintptr_t)24ULL), sizeof(uintptr_t)); x9 = _br2_load((in2)+((uintptr_t)32ULL), sizeof(uintptr_t)); /*skip*/ x10 = _br2_load((in3)+((uintptr_t)0ULL), sizeof(uintptr_t)); x11 = _br2_load((in3)+((uintptr_t)8ULL), sizeof(uintptr_t)); x12 = _br2_load((in3)+((uintptr_t)16ULL), sizeof(uintptr_t)); x13 = _br2_load((in3)+((uintptr_t)24ULL), sizeof(uintptr_t)); /*skip*/ x14 = _br2_load((in4)+((uintptr_t)0ULL), sizeof(uintptr_t)); x15 = _br2_load((in4)+((uintptr_t)8ULL), sizeof(uintptr_t)); x16 = _br2_load((in4)+((uintptr_t)16ULL), sizeof(uintptr_t)); x17 = _br2_load((in4)+((uintptr_t)24ULL), sizeof(uintptr_t)); /*skip*/ /*skip*/ x18 = ((in0)^((uintptr_t)18446744073709551615ULL))+((uintptr_t)1ULL); x19 = ((x18)>>((uintptr_t)63ULL))&((x5)&((uintptr_t)1ULL)); x20 = ((in0)^((uintptr_t)18446744073709551615ULL))+((uintptr_t)1ULL); x21 = ((uintptr_t)-1ULL)+((x19)==((uintptr_t)0ULL)); x22 = (x21)^((uintptr_t)18446744073709551615ULL); x23 = ((x20)&(x21))|((in0)&(x22)); x24 = ((uintptr_t)-1ULL)+((x19)==((uintptr_t)0ULL)); x25 = (x24)^((uintptr_t)18446744073709551615ULL); x26 = ((x5)&(x24))|((x0)&(x25)); x27 = ((uintptr_t)-1ULL)+((x19)==((uintptr_t)0ULL)); x28 = (x27)^((uintptr_t)18446744073709551615ULL); x29 = ((x6)&(x27))|((x1)&(x28)); x30 = ((uintptr_t)-1ULL)+((x19)==((uintptr_t)0ULL)); x31 = (x30)^((uintptr_t)18446744073709551615ULL); x32 = ((x7)&(x30))|((x2)&(x31)); x33 = ((uintptr_t)-1ULL)+((x19)==((uintptr_t)0ULL)); x34 = (x33)^((uintptr_t)18446744073709551615ULL); x35 = ((x8)&(x33))|((x3)&(x34)); x36 = ((uintptr_t)-1ULL)+((x19)==((uintptr_t)0ULL)); x37 = (x36)^((uintptr_t)18446744073709551615ULL); x38 = ((x9)&(x36))|((x4)&(x37)); x39 = ((uintptr_t)1ULL)+((x0)^((uintptr_t)18446744073709551615ULL)); x40 = (x39)<((uintptr_t)1ULL); x41 = (x40)+((x1)^((uintptr_t)18446744073709551615ULL)); x42 = (x41)<((x1)^((uintptr_t)18446744073709551615ULL)); x43 = (x42)+((x2)^((uintptr_t)18446744073709551615ULL)); x44 = (x43)<((x2)^((uintptr_t)18446744073709551615ULL)); x45 = (x44)+((x3)^((uintptr_t)18446744073709551615ULL)); x46 = (x45)<((x3)^((uintptr_t)18446744073709551615ULL)); x47 = (x46)+((x4)^((uintptr_t)18446744073709551615ULL)); x48 = ((uintptr_t)-1ULL)+((x19)==((uintptr_t)0ULL)); x49 = (x48)^((uintptr_t)18446744073709551615ULL); x50 = ((x39)&(x48))|((x5)&(x49)); x51 = ((uintptr_t)-1ULL)+((x19)==((uintptr_t)0ULL)); x52 = (x51)^((uintptr_t)18446744073709551615ULL); x53 = ((x41)&(x51))|((x6)&(x52)); x54 = ((uintptr_t)-1ULL)+((x19)==((uintptr_t)0ULL)); x55 = (x54)^((uintptr_t)18446744073709551615ULL); x56 = ((x43)&(x54))|((x7)&(x55)); x57 = ((uintptr_t)-1ULL)+((x19)==((uintptr_t)0ULL)); x58 = (x57)^((uintptr_t)18446744073709551615ULL); x59 = ((x45)&(x57))|((x8)&(x58)); x60 = ((uintptr_t)-1ULL)+((x19)==((uintptr_t)0ULL)); x61 = (x60)^((uintptr_t)18446744073709551615ULL); x62 = ((x47)&(x60))|((x9)&(x61)); x63 = ((uintptr_t)-1ULL)+((x19)==((uintptr_t)0ULL)); x64 = (x63)^((uintptr_t)18446744073709551615ULL); x65 = ((x14)&(x63))|((x10)&(x64)); x66 = ((uintptr_t)-1ULL)+((x19)==((uintptr_t)0ULL)); x67 = (x66)^((uintptr_t)18446744073709551615ULL); x68 = ((x15)&(x66))|((x11)&(x67)); x69 = ((uintptr_t)-1ULL)+((x19)==((uintptr_t)0ULL)); x70 = (x69)^((uintptr_t)18446744073709551615ULL); x71 = ((x16)&(x69))|((x12)&(x70)); x72 = ((uintptr_t)-1ULL)+((x19)==((uintptr_t)0ULL)); x73 = (x72)^((uintptr_t)18446744073709551615ULL); x74 = ((x17)&(x72))|((x13)&(x73)); x75 = (x65)+(x65); x76 = (x75)<(x65); x77 = (x76)+(x68); x78 = (x77)<(x68); x79 = (x77)+(x68); x80 = (x79)<(x68); x81 = (x78)+(x80); x82 = (x81)+(x71); x83 = (x82)<(x71); x84 = (x82)+(x71); x85 = (x84)<(x71); x86 = (x83)+(x85); x87 = (x86)+(x74); x88 = (x87)<(x74); x89 = (x87)+(x74); x90 = (x89)<(x74); x91 = (x88)+(x90); x92 = (x75)-((uintptr_t)18446744073709551615ULL); x93 = (x75)<(x92); x94 = (x79)-((uintptr_t)4294967295ULL); x95 = (x79)<(x94); x96 = (x94)-(x93); x97 = (x94)<(x96); x98 = (x95)+(x97); x99 = (x84)-(x98); x100 = (x84)<(x99); x101 = (x89)-((uintptr_t)18446744069414584321ULL); x102 = (x89)<(x101); x103 = (x101)-(x100); x104 = (x101)<(x103); x105 = (x102)+(x104); x106 = (x91)-(x105); x107 = (x91)<(x106); x108 = x13; x109 = x12; x110 = x11; x111 = x10; x112 = ((uintptr_t)0ULL)<(((uintptr_t)0ULL)-(x111)); x113 = ((uintptr_t)0ULL)<(((uintptr_t)0ULL)-(x110)); x114 = (((uintptr_t)0ULL)-(x110))-(x112); x115 = (((uintptr_t)0ULL)-(x110))<(x114); x116 = (x113)+(x115); x117 = ((uintptr_t)0ULL)<(((uintptr_t)0ULL)-(x109)); x118 = (((uintptr_t)0ULL)-(x109))-(x116); x119 = (((uintptr_t)0ULL)-(x109))<(x118); x120 = (x117)+(x119); x121 = ((uintptr_t)0ULL)<(((uintptr_t)0ULL)-(x108)); x122 = (((uintptr_t)0ULL)-(x108))-(x120); x123 = (((uintptr_t)0ULL)-(x108))<(x122); x124 = (x121)+(x123); x125 = ((uintptr_t)-1ULL)+((x124)==((uintptr_t)0ULL)); x126 = (((uintptr_t)0ULL)-(x111))+(x125); x127 = (x126)<(((uintptr_t)0ULL)-(x111)); x128 = (x127)+(x114); x129 = (x128)<(x114); x130 = (x128)+((x125)&((uintptr_t)4294967295ULL)); x131 = (x130)<((x125)&((uintptr_t)4294967295ULL)); x132 = (x129)+(x131); x133 = (x132)+(x118); x134 = (x133)<(x118); x135 = (x134)+(x122); x136 = (x135)+((x125)&((uintptr_t)18446744069414584321ULL)); x137 = ((uintptr_t)-1ULL)+((x19)==((uintptr_t)0ULL)); x138 = (x137)^((uintptr_t)18446744073709551615ULL); x139 = ((x126)&(x137))|((x14)&(x138)); x140 = ((uintptr_t)-1ULL)+((x19)==((uintptr_t)0ULL)); x141 = (x140)^((uintptr_t)18446744073709551615ULL); x142 = ((x130)&(x140))|((x15)&(x141)); x143 = ((uintptr_t)-1ULL)+((x19)==((uintptr_t)0ULL)); x144 = (x143)^((uintptr_t)18446744073709551615ULL); x145 = ((x133)&(x143))|((x16)&(x144)); x146 = ((uintptr_t)-1ULL)+((x19)==((uintptr_t)0ULL)); x147 = (x146)^((uintptr_t)18446744073709551615ULL); x148 = ((x136)&(x146))|((x17)&(x147)); x149 = (x50)&((uintptr_t)1ULL); x150 = ((uintptr_t)-1ULL)+((x149)==((uintptr_t)0ULL)); x151 = (x150)^((uintptr_t)18446744073709551615ULL); x152 = ((x26)&(x150))|(((uintptr_t)0ULL)&(x151)); x153 = ((uintptr_t)-1ULL)+((x149)==((uintptr_t)0ULL)); x154 = (x153)^((uintptr_t)18446744073709551615ULL); x155 = ((x29)&(x153))|(((uintptr_t)0ULL)&(x154)); x156 = ((uintptr_t)-1ULL)+((x149)==((uintptr_t)0ULL)); x157 = (x156)^((uintptr_t)18446744073709551615ULL); x158 = ((x32)&(x156))|(((uintptr_t)0ULL)&(x157)); x159 = ((uintptr_t)-1ULL)+((x149)==((uintptr_t)0ULL)); x160 = (x159)^((uintptr_t)18446744073709551615ULL); x161 = ((x35)&(x159))|(((uintptr_t)0ULL)&(x160)); x162 = ((uintptr_t)-1ULL)+((x149)==((uintptr_t)0ULL)); x163 = (x162)^((uintptr_t)18446744073709551615ULL); x164 = ((x38)&(x162))|(((uintptr_t)0ULL)&(x163)); x165 = (x50)+(x152); x166 = (x165)<(x50); x167 = (x166)+(x53); x168 = (x167)<(x53); x169 = (x167)+(x155); x170 = (x169)<(x155); x171 = (x168)+(x170); x172 = (x171)+(x56); x173 = (x172)<(x56); x174 = (x172)+(x158); x175 = (x174)<(x158); x176 = (x173)+(x175); x177 = (x176)+(x59); x178 = (x177)<(x59); x179 = (x177)+(x161); x180 = (x179)<(x161); x181 = (x178)+(x180); x182 = (x181)+(x62); x183 = (x182)+(x164); x184 = ((uintptr_t)-1ULL)+((x149)==((uintptr_t)0ULL)); x185 = (x184)^((uintptr_t)18446744073709551615ULL); x186 = ((x65)&(x184))|(((uintptr_t)0ULL)&(x185)); x187 = ((uintptr_t)-1ULL)+((x149)==((uintptr_t)0ULL)); x188 = (x187)^((uintptr_t)18446744073709551615ULL); x189 = ((x68)&(x187))|(((uintptr_t)0ULL)&(x188)); x190 = ((uintptr_t)-1ULL)+((x149)==((uintptr_t)0ULL)); x191 = (x190)^((uintptr_t)18446744073709551615ULL); x192 = ((x71)&(x190))|(((uintptr_t)0ULL)&(x191)); x193 = ((uintptr_t)-1ULL)+((x149)==((uintptr_t)0ULL)); x194 = (x193)^((uintptr_t)18446744073709551615ULL); x195 = ((x74)&(x193))|(((uintptr_t)0ULL)&(x194)); x196 = (x139)+(x186); x197 = (x196)<(x139); x198 = (x197)+(x142); x199 = (x198)<(x142); x200 = (x198)+(x189); x201 = (x200)<(x189); x202 = (x199)+(x201); x203 = (x202)+(x145); x204 = (x203)<(x145); x205 = (x203)+(x192); x206 = (x205)<(x192); x207 = (x204)+(x206); x208 = (x207)+(x148); x209 = (x208)<(x148); x210 = (x208)+(x195); x211 = (x210)<(x195); x212 = (x209)+(x211); x213 = (x196)-((uintptr_t)18446744073709551615ULL); x214 = (x196)<(x213); x215 = (x200)-((uintptr_t)4294967295ULL); x216 = (x200)<(x215); x217 = (x215)-(x214); x218 = (x215)<(x217); x219 = (x216)+(x218); x220 = (x205)-(x219); x221 = (x205)<(x220); x222 = (x210)-((uintptr_t)18446744069414584321ULL); x223 = (x210)<(x222); x224 = (x222)-(x221); x225 = (x222)<(x224); x226 = (x223)+(x225); x227 = (x212)-(x226); x228 = (x212)<(x227); x229 = (x23)+((uintptr_t)1ULL); x230 = ((x165)>>((uintptr_t)1ULL))|((x169)<<((uintptr_t)63ULL)); x231 = ((x169)>>((uintptr_t)1ULL))|((x174)<<((uintptr_t)63ULL)); x232 = ((x174)>>((uintptr_t)1ULL))|((x179)<<((uintptr_t)63ULL)); x233 = ((x179)>>((uintptr_t)1ULL))|((x183)<<((uintptr_t)63ULL)); x234 = ((x183)&((uintptr_t)9223372036854775808ULL))|((x183)>>((uintptr_t)1ULL)); x235 = ((uintptr_t)-1ULL)+((x107)==((uintptr_t)0ULL)); x236 = (x235)^((uintptr_t)18446744073709551615ULL); x237 = ((x75)&(x235))|((x92)&(x236)); x238 = ((uintptr_t)-1ULL)+((x107)==((uintptr_t)0ULL)); x239 = (x238)^((uintptr_t)18446744073709551615ULL); x240 = ((x79)&(x238))|((x96)&(x239)); x241 = ((uintptr_t)-1ULL)+((x107)==((uintptr_t)0ULL)); x242 = (x241)^((uintptr_t)18446744073709551615ULL); x243 = ((x84)&(x241))|((x99)&(x242)); x244 = ((uintptr_t)-1ULL)+((x107)==((uintptr_t)0ULL)); x245 = (x244)^((uintptr_t)18446744073709551615ULL); x246 = ((x89)&(x244))|((x103)&(x245)); x247 = ((uintptr_t)-1ULL)+((x228)==((uintptr_t)0ULL)); x248 = (x247)^((uintptr_t)18446744073709551615ULL); x249 = ((x196)&(x247))|((x213)&(x248)); x250 = ((uintptr_t)-1ULL)+((x228)==((uintptr_t)0ULL)); x251 = (x250)^((uintptr_t)18446744073709551615ULL); x252 = ((x200)&(x250))|((x217)&(x251)); x253 = ((uintptr_t)-1ULL)+((x228)==((uintptr_t)0ULL)); x254 = (x253)^((uintptr_t)18446744073709551615ULL); x255 = ((x205)&(x253))|((x220)&(x254)); x256 = ((uintptr_t)-1ULL)+((x228)==((uintptr_t)0ULL)); x257 = (x256)^((uintptr_t)18446744073709551615ULL); x258 = ((x210)&(x256))|((x224)&(x257)); x259 = x229; x260 = x26; x261 = x29; x262 = x32; x263 = x35; x264 = x38; /*skip*/ x265 = x230; x266 = x231; x267 = x232; x268 = x233; x269 = x234; /*skip*/ x270 = x237; x271 = x240; x272 = x243; x273 = x246; /*skip*/ x274 = x249; x275 = x252; x276 = x255; x277 = x258; /*skip*/ out0 = x259; _br2_store((out1)+((uintptr_t)0ULL), x260, sizeof(uintptr_t)); _br2_store((out1)+((uintptr_t)8ULL), x261, sizeof(uintptr_t)); _br2_store((out1)+((uintptr_t)16ULL), x262, sizeof(uintptr_t)); _br2_store((out1)+((uintptr_t)24ULL), x263, sizeof(uintptr_t)); _br2_store((out1)+((uintptr_t)32ULL), x264, sizeof(uintptr_t)); /*skip*/ _br2_store((out2)+((uintptr_t)0ULL), x265, sizeof(uintptr_t)); _br2_store((out2)+((uintptr_t)8ULL), x266, sizeof(uintptr_t)); _br2_store((out2)+((uintptr_t)16ULL), x267, sizeof(uintptr_t)); _br2_store((out2)+((uintptr_t)24ULL), x268, sizeof(uintptr_t)); _br2_store((out2)+((uintptr_t)32ULL), x269, sizeof(uintptr_t)); /*skip*/ _br2_store((out3)+((uintptr_t)0ULL), x270, sizeof(uintptr_t)); _br2_store((out3)+((uintptr_t)8ULL), x271, sizeof(uintptr_t)); _br2_store((out3)+((uintptr_t)16ULL), x272, sizeof(uintptr_t)); _br2_store((out3)+((uintptr_t)24ULL), x273, sizeof(uintptr_t)); /*skip*/ _br2_store((out4)+((uintptr_t)0ULL), x274, sizeof(uintptr_t)); _br2_store((out4)+((uintptr_t)8ULL), x275, sizeof(uintptr_t)); _br2_store((out4)+((uintptr_t)16ULL), x276, sizeof(uintptr_t)); _br2_store((out4)+((uintptr_t)24ULL), x277, sizeof(uintptr_t)); /*skip*/ return out0; } /* NOTE: The following wrapper function is not covered by Coq proofs */ static void fiat_p256_divstep(uint64_t* out1, uint64_t out2[5], uint64_t out3[5], uint64_t out4[4], uint64_t out5[4], uint64_t arg1, const uint64_t arg2[5], const uint64_t arg3[5], const uint64_t arg4[4], const uint64_t arg5[4]) { *out1 = (uint64_t)internal_fiat_p256_divstep((uintptr_t)out2, (uintptr_t)out3, (uintptr_t)out4, (uintptr_t)out5, (uintptr_t)arg1, (uintptr_t)arg2, (uintptr_t)arg3, (uintptr_t)arg4, (uintptr_t)arg5); } /* * Input Bounds: * Output Bounds: * out0: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] */ static void internal_fiat_p256_divstep_precomp(uintptr_t out0) { uintptr_t x0, x1, x2, x3; /*skip*/ x0 = (uintptr_t)7493989778736545792ULL; x1 = (uintptr_t)13835058056221687808ULL; x2 = (uintptr_t)15564440314339917823ULL; x3 = (uintptr_t)3458764513820540927ULL; /*skip*/ _br2_store((out0)+((uintptr_t)0ULL), x0, sizeof(uintptr_t)); _br2_store((out0)+((uintptr_t)8ULL), x1, sizeof(uintptr_t)); _br2_store((out0)+((uintptr_t)16ULL), x2, sizeof(uintptr_t)); _br2_store((out0)+((uintptr_t)24ULL), x3, sizeof(uintptr_t)); /*skip*/ return; } /* NOTE: The following wrapper function is not covered by Coq proofs */ static void fiat_p256_divstep_precomp(uint64_t out1[4]) { internal_fiat_p256_divstep_precomp((uintptr_t)out1); }
the_stack_data/1028269.c
/*Exercise 2 - Selection Write a program to calculate the amount to be paid for a rented vehicle. • Input the distance the van has travelled • The first 30 km is at a rate of 50/= per km. • The remaining distance is calculated at the rate of 40/= per km. e.g. Distance -> 20 Amount = 20 x 50 = 1000 Distance -> 50 Amount = 30 x 50 + (50-30) x 40 = 2300*/ #include <stdio.h> int main() { float dis; printf("Enter total distance: "); scanf("%f", &dis); if(dis<=30) { printf("Your total amount= %2.f", (50*dis)); } else printf("Your total amount= %2.f",((30*50) + ((dis-30)*40))); return 0; }
the_stack_data/18978.c
#include<stdio.h> void main(){ int n, imp=0, pr=0;//impar e par int par[5], impar[5]; for(int i=0; i<30; i++){ printf("Informe a posicao %d: ", i+1); scanf("%d", &n); if(n%2 == 0){ par[pr] = n; ++pr; if(pr > 4){ pr = 0; printf("Tamanho Par excedido.\nPares do vetor: "); for(int j=0;j<5; j++){ printf("%d ", par[j]); } printf("\n"); } }else{ impar[imp] = n; ++imp; if(imp > 4){ imp = 0; printf("Tamanho Impar excedido.\nImpares do vetor: "); for(int j=0;j<5;j++){ printf("%d ", impar[j]); } printf("\n"); } } } }
the_stack_data/176707002.c
/**************************************************************/ /* Examins key codes */ /* Compile with: cc key.c -lcurses -o key */ /**************************************************************/ #define M_TERMINFO #include <curses.h> WINDOW *Wkur; int main() { void InitEkran(), TermEkran(); int TakeSymbol(), evKey_pressed(); InitEkran(); clear(); refresh(); mvprintw(17, 20, "For exit press CTRL-x (24)"); refresh(); for (;;) if (evKey_pressed() == 24) /* CTRL-X - exit */ break; TermEkran(); return 0; } /***********************************************************/ int evKey_pressed() { int TakeSymbol(); int Symbol; Symbol = TakeSymbol(); mvprintw(19, 20, "Input = [%3.0d]", Symbol); refresh(); if (Symbol == 91) { Symbol = TakeSymbol(); Symbol += 300; if (Symbol == 384) /* F8 on console; same as CTRL-X */ Symbol = 24; } /* Specific for terminals */ if (Symbol == 349 || Symbol == 350 || Symbol == 351) { Symbol = TakeSymbol(); if (Symbol > 47 && Symbol < 58) Symbol += 400; if (Symbol == 455) Symbol = 382; /* i.e. F6 on konsole */ else if (Symbol == 456) Symbol = 383; /* i.e. F7 on konsole */ else if (Symbol == 457) Symbol = 24; /* F8 same as CTRL-X */ else if (Symbol == 449) Symbol = 372; /* F17 i.e. Home on konsole */ else if (Symbol == 450) Symbol = 370; /* F18 i.e. End on konsole */ else if (Symbol == 451) Symbol = 373; /* F19 i.e PgUp on koneole */ else if (Symbol == 452) Symbol = 371; /* F20 i.e. pgDn on konsole */ TakeSymbol(); } /************ end specific for Unisis terminals *********/ mvprintw(20, 20, "Exit = [%3.0d]", Symbol); refresh(); return (Symbol); } /******************************************************/ int TakeSymbol() { char Symbol; Symbol = wgetch(Wkur); if (Symbol == 27) { nodelay(Wkur, TRUE); Symbol = wgetch(Wkur); nodelay(Wkur, FALSE); if (Symbol == -1) return (27); } return ((int)Symbol); } /********************************************************/ void InitEkran() { initscr(); crmode(); noecho(); raw(); nonl(); Wkur = newwin(1, 1, 23, 0); wclear(Wkur); } /*********************************************************/ void TermEkran() { clear(); refresh(); endwin(); } /**********************************************************/
the_stack_data/18888333.c
#include <stdio.h> #include <stdlib.h> #include <string.h> int diffStr(char *ps1, char *ps2) { int i = 1; int count = 0; int minLen; minLen = (strlen(ps1) > strlen(ps2)) ? strlen(ps2) : strlen(ps1); for(i; i < minLen; i++) if(strncmp(ps1 + strlen(ps1) - i, ps2, i) == 0) count = i; return count; } void buildMatr(char **ps, int pn, int **pa) { int i = 0; int j; for (i; i < pn; i++) for (j = 0; j < pn; j++) if (i != j) *(*(pa + i) + j) = diffStr(*(ps + i), *(ps + j)); else *(*(pa + i) + j) = 0; } int getMax(int **pa, int pn, int *pc1, int *pc2) { int max = **pa; int i = 0; int j; for (i; i < pn; i++) for (j = 0; j < pn; j++) if(*(*(pa + i) + j) > max) { *pc1 = i; *pc2 = j; max = *(*(pa + i) + j); } return max; } int matr(int **pa, int pn) { int i; int j = 0; int ch1; int ch2; int max; int len = 0; max = getMax(pa, pn, &ch1, &ch2); while (max && (j < pn - 1)) { j++; len += max; for (i = 0; i < pn; i++) { *(*(pa + ch1) + i) = 0; *(*(pa + i) + ch2) = 0; } max = getMax(pa, pn, &ch1, &ch2); } return len; } int main() { char **s; int **a; int n; int i = 0; int j = 0; int len; scanf("%d\n", &n); a = (int**)malloc(sizeof(int*) * n); s = (char**)malloc(sizeof(char*) * n); for (i; i < n; i++) { *(a + i) = (int *)calloc(n, sizeof(int)); *(s + i) = (char *)calloc(255, sizeof(char)); } for (i = 0; i < n; i++) { gets(s[i]); j += strlen(s[i]); } buildMatr(s, n, a); len = matr(a, n); j -= len; printf("%d", j); for (i = 0; i < n; i++) { free(a[i]); free(s[i]); } free(a); free(s); return 0; }
the_stack_data/136807.c
// RUN: %clang_cc1 -triple aarch64_be-linux-gnu -ffreestanding -emit-llvm -O0 -o - %s | FileCheck --check-prefix IR %s struct bt3 { signed b2:10; signed b3:10; } b16; // Get the high 32-bits and then shift appropriately for big-endian. signed callee_b0f(struct bt3 bp11) { // IR: callee_b0f(i64 [[ARG:%.*]]) // IR: store i64 [[ARG]], i64* [[PTR:%.*]], align 8 // IR: [[BITCAST:%.*]] = bitcast i64* [[PTR]] to i8* // IR: call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.*}}, i8* [[BITCAST]], i64 4 return bp11.b2; }
the_stack_data/410494.c
/* * Copyright (C) 2003, 2004, 2006, 2007 * Robert Lougher <[email protected]>. * * This file is part of JamVM. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2, * or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ void initialisePlatform() { /* Nothing to do for ARM */ }
the_stack_data/234518914.c
#pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunknown-pragmas" #pragma ide diagnostic ignored "UnusedValue" #pragma ide diagnostic ignored "UnusedLocalVariable" #pragma ide diagnostic ignored "OCUnusedGlobalDeclarationInspection" /* * indirect_result.c (c) 2018-20 Christopher A. Bohn */ typedef struct { int a; long b; long c; long d; } foo; foo bar(int a, long b, long c, long d) { foo baz; baz.a = a; baz.b = b; baz.c = c; baz.d = d; return baz; // since baz itself can't fit in a register, baz is indirectly returned by returning a pointer to baz } void quux() { foo x = bar(2,3,4,5); } #pragma clang diagnostic pop
the_stack_data/141309.c
#include <stdio.h> #include <stdlib.h> #include <semaphore.h> #include <pthread.h> #include <string.h> #define N 2 int counter[256]; sem_t sem; void err_exit(char *msg) { perror(msg); exit(EXIT_FAILURE); } void *analyze_even(void *arg) { char *str = (char *) arg; for (int i = 0; i < strlen(arg); i += 2) { if (sem_wait(&sem)) err_exit("sem_wait() error"); counter[(int) str[i]]++; if (sem_post(&sem)) err_exit("sem_post() error"); } return NULL; } void *analyze_odd(void *arg) { char *str = (char *) arg; for (int i = 1; i < strlen(arg); i += 2) { if (sem_wait(&sem)) err_exit("sem_wait() error"); counter[(int) str[i]]++; if (sem_post(&sem)) err_exit("sem_post() error"); } return NULL; } int main() { char *content = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. " "Mattis rhoncus urna neque viverra justo nec ultrices. Pretium quam vulputate dignissim suspendisse in est ante. " "Vitae congue mauris rhoncus aenean. Blandit cursus risus at ultrices mi. Ut lectus arcu bibendum at varius vel pharetra vel. " "Etiam non quam lacus suspendisse faucibus interdum posuere. Eget sit amet tellus cras adipiscing enim eu turpis egestas. " "Lectus magna fringilla urna porttitor rhoncus dolor purus non. Sit amet consectetur adipiscing elit duis tristique sollicitudin nibh. " "Nec tincidunt praesent semper feugiat nibh. Sapien pellentesque habitant morbi tristique senectus et netus et malesuada."; if (sem_init(&sem, 0, 1)) err_exit("sem_open() error"); pthread_t threads[N]; void *(*thread_funcs[N])(void *arg); thread_funcs[0] = analyze_even; thread_funcs[1] = analyze_odd; for (int i = 0; i < N; i++) { if (pthread_create(&threads[i], NULL, &(*thread_funcs[i]), content)) err_exit("pthread_create() error"); } for (int i = 0; i < N; i++) { if (pthread_join(threads[i], NULL)) err_exit("pthread_join() error"); } for (int i = 0; i < 256; i++) printf("frequenza di %d = %d \n", i, counter[i]); return 0; }
the_stack_data/1119416.c
// RUN: %clang_cc1 -Werror -triple i386-unknown-unknown -emit-llvm -O1 -disable-llvm-optzns -o - %s | FileCheck %s // RUN: %clang_cc1 -Werror -triple i386-unknown-unknown -emit-llvm -O1 -struct-path-tbaa -disable-llvm-optzns -o - %s | FileCheck %s -check-prefix=PATH // Types with the may_alias attribute should be considered equivalent // to char for aliasing. typedef int __attribute__((may_alias)) aliasing_int; void test0(aliasing_int *ai, int *i) { // CHECK: store i32 0, i32* %{{.*}}, !tbaa !1 // PATH: store i32 0, i32* %{{.*}}, !tbaa [[TAG_CHAR:!.*]] *ai = 0; // CHECK: store i32 1, i32* %{{.*}}, !tbaa !3 // PATH: store i32 1, i32* %{{.*}}, !tbaa [[TAG_INT:!.*]] *i = 1; } // PR9307 struct Test1 { int x; }; struct Test1MA { int x; } __attribute__((may_alias)); void test1(struct Test1MA *p1, struct Test1 *p2) { // CHECK: store i32 2, i32* {{%.*}}, !tbaa !1 // PATH: store i32 2, i32* {{%.*}}, !tbaa [[TAG_CHAR]] p1->x = 2; // CHECK: store i32 3, i32* {{%.*}}, !tbaa !3 // PATH: store i32 3, i32* {{%.*}}, !tbaa [[TAG_test1_x:!.*]] p2->x = 3; } // CHECK: !0 = metadata !{metadata !"any pointer", metadata !1} // CHECK: !1 = metadata !{metadata !"omnipotent char", metadata !2} // CHECK: !2 = metadata !{metadata !"Simple C/C++ TBAA"} // CHECK: !3 = metadata !{metadata !"int", metadata !1} // PATH: [[TYPE_CHAR:!.*]] = metadata !{metadata !"omnipotent char", metadata !{{.*}} // PATH: [[TAG_CHAR]] = metadata !{metadata [[TYPE_CHAR]], metadata [[TYPE_CHAR]], i64 0} // PATH: [[TAG_INT]] = metadata !{metadata [[TYPE_INT:!.*]], metadata [[TYPE_INT]], i64 0} // PATH: [[TYPE_INT]] = metadata !{metadata !"int", metadata [[TYPE_CHAR]] // PATH: [[TAG_test1_x]] = metadata !{metadata [[TYPE_test1:!.*]], metadata [[TYPE_INT]], i64 0} // PATH: [[TYPE_test1]] = metadata !{metadata !"_ZTS5Test1", metadata [[TYPE_INT]], i64 0}
the_stack_data/187281.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. */ int main() { int a = 5; int b; b = a; return b; }
the_stack_data/486954.c
/* 7. Para ler um número inteiro e dizer se ele é impar ou par. solucao em: https://repl.it/@ViniciusB1/LDA-AT1-ex07#main.c */ /* planejamento: declar variavel para numero inteiro; leitura do numero fornecido; verificar se é par (divisivel por dois): resto da divisao por 2 deve ser zero caso afirmativo: par caso negativo: impar exibir mensagem */ #include <stdio.h> int main(void) { int numero; scanf ("%d", &numero); if (numero%2==0) { printf ("Numero %d e par", numero); } else { printf ("Numero %d e impar", numero); } return 0; }
the_stack_data/22013670.c
#include <term.h> #define cursor_invisible tigetstr("civis") /** make cursor invisible **/ /* TERMINFO_NAME(civis) TERMCAP_NAME(vi) XOPEN(400) */