file
stringlengths
18
26
data
stringlengths
3
1.04M
the_stack_data/190766848.c
// @klee[inArraySize=6,outArraySize=6](sym,6) int* sort(int a[], int n) { int i, j, t; for (i = 1; i < n; i++) { t = a[i]; for (j = i; j > 0 && t < a[j - 1]; j--) { // Ascending with < a[j] = a[j - 1]; } a[j] = t; } return a; }
the_stack_data/141656.c
/* Implemente um programa que, através da passagem de parâmetros, realize as funções para o seguinte menu: << CALCULADORA GERAL >> 1. Calculo da Hipotenusa 2. Área do Cilindro (área total) 3. Distância > R$ 4. Sair Requisitos: * O sistema só deverá ser encerrado ao digitar a opção 4. * Para cada opção o sistema deverá passar parâmetros para uma função específica. * Os resultados deverão ser apresentados ao usuário através de Procedimentos específicos para isso. * Não devem ser utilizadas variáveis globais. * No item 3 a resposta deverá ser o custo em reais para se realizar um determinado trajeto de carro, conhecendo-se a distância, consumo do veículo e valor do combustível. */ #include <stdio.h> #include <stdlib.h> #include <math.h> float hipotenusa(float a, float b) { float x; x=sqrt(pow(a, 2) + pow(b, 2)); return x; } float cilindro(float r, float h) { float Ab, Al, At, pi=3.14; Ab=pi*pow(r, 2); Al=pi*r*h; At=2*Ab+2*Al; return At; } float trajeto(float distancia, float consumo, float combustivel) { float x; x=(distancia/consumo)*combustivel; return x; } int main() { int opcao; float a, b, hipot; //variaveis da hipotenusa float r, h, At; //variaveis do cilindro float distancia, consumo, combustivel, valor; //variaveis da viagem while (opcao != 4) { printf("\n\n<< CALCULADORA GERAL >>\n"); printf("1. Calculo da Hipotenusa\n"); printf("2. Area do Cilindro (area total)\n"); printf("3. Distancia > R$\n"); printf("4. Sair\n"); printf("-----------<<>>------------\n"); printf("Escolha uma opcao: "); scanf("%i", &opcao); switch (opcao) { case 1: printf("\n<< Calculo da Hipotenusa >>\n"); printf("Digite o tamanho de um dos lados de um triangulo: "); scanf("%f", &a); printf("Digite o tamanho do outro lado: "); scanf("%f", &b); hipot=hipotenusa(a, b); printf("\nValor da hipotenusa: %.1f\n", hipot); break; case 2: printf("\n<< Area do Cilindro >>\n"); printf("Digite o raio do cilindro: "); scanf("%f", &r); printf("Digite a altura do cilindro: "); scanf("%f", &h); At=cilindro(r, h); printf("\nValor da Area Total do Cilindro: %.1f\n", At); break; case 3: printf("\n<< Custo da viagem >>\n"); printf("Informe o valor do combustivel: "); scanf("%f", &combustivel); printf("Qual o consumo do veiculo: "); scanf("%f", &consumo); printf("Digite a distancia do trajeto: "); scanf("%f", &distancia); valor = trajeto(distancia, consumo, combustivel); printf("\nValor em reais para a viagem: %.1f\n", valor); break; case 4: break; default: break; } } printf("\nFinalizando o programa...\n"); system("pause"); return 0; }
the_stack_data/198581339.c
/* * mkstemp.c -- * * Source code for the "mkstemp" library routine. * * Copyright (c) 2009 Donal K. Fellows * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include <errno.h> #include <fcntl.h> #include <stdlib.h> #include <unistd.h> /* *---------------------------------------------------------------------- * * mkstemp -- * * Create an open temporary file from a template. * * Results: * A file descriptor, or -1 (with errno set) in the case of an error. * * Side effects: * The template is updated to contain the real filename. * *---------------------------------------------------------------------- */ int mkstemp( char *template) /* Template for filename. */ { static const char alphanumerics[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; char *a, *b; int fd, count, alphanumericsLen = strlen(alphanumerics); /* == 62 */ a = template + strlen(template); while (a > template && *(a-1) == 'X') { a--; } if (a == template) { errno = ENOENT; return -1; } /* * We'll only try up to 10 times; after that, we're suffering from enemy * action and should let the caller know. */ count = 10; do { /* * Replace the X's in the original template with random alphanumeric * digits. */ for (b=a ; *b ; b++) { float r = rand() / ((float) RAND_MAX); *b = alphanumerics[(int)(r * alphanumericsLen)]; } /* * Template is now realized; try to open (with correct options). */ fd = open(template, O_RDWR|O_CREAT|O_EXCL, 0600); } while (fd == -1 && errno == EEXIST && --count > 0); return fd; }
the_stack_data/182952142.c
#include <stdio.h> int main() { int a; int b; int product; scanf("%d %d", &a, &b); product = a * b; if((product%2) == 0) { printf("Even\n"); } else { printf("Odd\n"); } return 0; }
the_stack_data/92329125.c
// This file is part of CPAchecker, // a tool for configurable software verification: // https://cpachecker.sosy-lab.org // // SPDX-FileCopyrightText: 2007-2020 Dirk Beyer <https://www.sosy-lab.org> // // SPDX-License-Identifier: Apache-2.0 #include <stdlib.h> typedef struct node { struct node *next; struct node *prev; int data; } *DLL; DLL node_create(int data) { DLL temp = (DLL) malloc(sizeof(struct node)); temp->next = NULL; temp->prev = NULL; temp->data = data; return temp; } DLL dll_circular_remove_last(DLL head) { if(NULL == head) { return NULL; } else { DLL last = head->prev; DLL second_to_last = last->prev; if(last == second_to_last) { head = NULL; } else { second_to_last->next = head; head->prev = second_to_last; } free(last); return head; } } int main(void) { const int data = 5; DLL a = node_create(data); DLL b = node_create(data); a->next = b; b->prev = a; // add circular links a->prev = b; b->next = a; b = NULL; while(NULL != a) { a = dll_circular_remove_last(a); } return 0; }
the_stack_data/181393072.c
#include <stdio.h> #include <stdlib.h> struct node { int data; struct node* left; struct node* right; }; unsigned int countLeaf(struct node* node) { if(node == NULL) return 0; if(node->left == NULL && node->right==NULL) return 1; else return countLeaf(node->left) + countLeaf(node->right); } struct node* newNode(int data) { struct node* node = (struct node*)malloc(sizeof(struct node)); node->data = data; node->left = NULL; node->right = NULL; return(node); } int main() { /*constructing our binary tree 1 / \ 2 3 / \ 4 5 */ struct node *root = newNode(1); root->left = newNode(2); root->right = newNode(3); root->right->left = newNode(4); root->right->right = newNode(5); printf("%d", countLeaf(root)); }
the_stack_data/218893922.c
/* { dg-do compile { target { powerpc64le-*-* } } } */ /* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power8" } } */ /* { dg-options "-mcpu=power8 -O3" } */ /* { dg-final { scan-assembler "lxvd2x" } } */ /* { dg-final { scan-assembler "stxvd2x" } } */ /* { dg-final { scan-assembler-not "xxpermdi" } } */ void abort (); #define N 4096 signed char ca[N] __attribute__((aligned(16))); signed char cb[N] __attribute__((aligned(16))); signed char cc[N] __attribute__((aligned(16))); __attribute__((noinline)) void foo () { int i; for (i = 0; i < N; i++) { ca[i] = cb[i] - cc[i]; } } __attribute__((noinline)) void init () { int i, ii; for (i = 0, ii = 0; i < N; ++i, ii = (ii + 1) % 128) { cb[i] = ii - 128; cc[i] = ii/2 - 64; } } int main () { int i, ii; init (); foo (); for (i = 0; i < N; ++i) { ii = i % 128; if (ca[i] != ii - ii/2 - 64) abort (); } return 0; }
the_stack_data/200143354.c
#include <ctype.h> #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { FILE *fp; int ch, count = 0; if(argc != 2) { printf("usage: main filename\n"); exit(EXIT_FAILURE); } if((fp = fopen(argv[1], "r")) == NULL) { printf("%s can't be opened\n", argv[1]); exit(EXIT_FAILURE); } while((ch = getc(fp)) != EOF) { count++; } fclose(fp); printf("count: %d\n", count); return 0; }
the_stack_data/352697.c
// // Stack using queues in C // // By Aron R, 6 Oct 2021 // To implement stack data structure usnig C #include <stdio.h> #include <stdlib.h> int MAXSIZE = 8; int stack[8]; int top = -1; int isempty(void) { if(top == -1) return 1; else return 0; } int isfull(void) { if(top == MAXSIZE) return 1; else return 0; } int peek(void) { return stack[top]; } int pop(void) { int data; if(!isempty()) { data = stack[top]; top = top - 1; return data; } else { printf("Could not retrieve data, Stack is empty.\n"); exit(0); } } void push(int data) { if(!isfull()) { top = top + 1; stack[top] = data; } else { printf("Could not insert data, Stack is full.\n"); } } int main() { // Example implementation // push items on to the stack push(3); push(5); push(9); push(1); push(12); push(15); printf("Element at top of the stack: %d\n" ,peek()); printf("Elements: \n"); // print stack data while(!isempty()) { int data = pop(); printf("%d\n",data); } printf("Stack full: %s\n" , isfull()?"true":"false"); printf("Stack empty: %s\n" , isempty()?"true":"false"); return 0; }
the_stack_data/135383.c
#include <stdio.h> #include <stdlib.h> double getMedian(int *arr, int n) { if ( n%2 ) return arr[n/2]; else return (arr[n/2]+arr[n/2-1])/2.0; } double merge(int *arr1, int len1, int *arr2, int len2) { int *arr = (int *)malloc(sizeof(int)*(len1+len2)); int index1 = 0, index2 = 0; int index = 0; while ( index1 < len1 && index2 < len2 ) { if ( arr1[index1] < arr2[index2] ) arr[index++] = arr1[index1++]; else arr[index++] = arr2[index2++]; } while ( index1 < len1 ) arr[index++] = arr1[index1++]; while ( index2 < len2 ) arr[index++] = arr2[index2++]; double result = getMedian(arr, index); free(arr); return result; } double binary(int *arr1, int len1, int *arr2, int len2) { if ( len1 > len2 ) { int *ptmp = arr1; arr1 = arr2; arr2 = ptmp; int tmp = len1; len1 = len2; len2 = tmp; } if ( len1 == 1 && len2 == 1 ) return (arr1[0]+arr2[0])/2.0; else if ( len1 == 1 ) { if ( len2%2 ) { if ( arr1[0] <= arr2[len2/2-1] ) return (arr2[len2/2-1]+arr2[len2/2])/2.0; else if ( arr1[0] >= arr2[len2/2+1] ) return (arr2[len2/2]+arr2[len2/2+1])/2.0; else return (arr1[0]+arr2[len2/2])/2.0; } else { if ( arr1[0] >= arr2[len2/2] ) return arr2[len2/2]; else if ( arr1[0] <= arr2[len2/2-1] ) return arr2[len2/2-1]; else return arr1[0]; } } else if ( len1 == 2 ) { return merge(arr1, len1, arr2, len2); } double m1 = getMedian(arr1, len1); double m2 = getMedian(arr2, len2); int l = (len1-1)/2; if ( m1 == m2 ) return m1; else if ( m1 < m2 ) return binary(arr1+l, len1-l, arr2, len2-l); else return binary(arr1, len1-l, arr2+l, len2-l); } double findMedianSortedArrays(int* nums1, int nums1Size, int* nums2, int nums2Size) { if ( nums1Size == 0 ) return getMedian(nums2, nums2Size); if ( nums2Size == 0 ) return getMedian(nums1, nums1Size); return binary(nums1, nums1Size, nums2, nums2Size); } int main() { int a[]={1,2,6,7}; int b[]={3,4,5,8}; printf("%lf\n", findMedianSortedArrays(a, sizeof(a)/sizeof(a[0]), b, sizeof(b)/sizeof(b[0]))); return 0; }
the_stack_data/75138633.c
// BUG: unable to handle kernel NULL pointer dereference in vhci_shutdown_connection // https://syzkaller.appspot.com/bug?id=635417e3213fd6ab42dd // status:6 // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include <arpa/inet.h> #include <dirent.h> #include <endian.h> #include <errno.h> #include <fcntl.h> #include <net/if.h> #include <net/if_arp.h> #include <netinet/in.h> #include <pthread.h> #include <sched.h> #include <setjmp.h> #include <signal.h> #include <stdarg.h> #include <stdbool.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/epoll.h> #include <sys/ioctl.h> #include <sys/mount.h> #include <sys/prctl.h> #include <sys/resource.h> #include <sys/socket.h> #include <sys/stat.h> #include <sys/syscall.h> #include <sys/time.h> #include <sys/types.h> #include <sys/uio.h> #include <sys/wait.h> #include <time.h> #include <unistd.h> #include <linux/capability.h> #include <linux/futex.h> #include <linux/genetlink.h> #include <linux/if_addr.h> #include <linux/if_ether.h> #include <linux/if_link.h> #include <linux/if_tun.h> #include <linux/in6.h> #include <linux/ip.h> #include <linux/neighbour.h> #include <linux/net.h> #include <linux/netlink.h> #include <linux/rfkill.h> #include <linux/rtnetlink.h> #include <linux/tcp.h> #include <linux/usb/ch9.h> #include <linux/veth.h> static unsigned long long procid; static __thread int skip_segv; static __thread jmp_buf segv_env; static void segv_handler(int sig, siginfo_t* info, void* ctx) { uintptr_t addr = (uintptr_t)info->si_addr; const uintptr_t prog_start = 1 << 20; const uintptr_t prog_end = 100 << 20; int skip = __atomic_load_n(&skip_segv, __ATOMIC_RELAXED) != 0; int valid = addr < prog_start || addr > prog_end; if (skip && valid) { _longjmp(segv_env, 1); } exit(sig); } static void install_segv_handler(void) { struct sigaction sa; memset(&sa, 0, sizeof(sa)); sa.sa_handler = SIG_IGN; syscall(SYS_rt_sigaction, 0x20, &sa, NULL, 8); syscall(SYS_rt_sigaction, 0x21, &sa, NULL, 8); memset(&sa, 0, sizeof(sa)); sa.sa_sigaction = segv_handler; sa.sa_flags = SA_NODEFER | SA_SIGINFO; sigaction(SIGSEGV, &sa, NULL); sigaction(SIGBUS, &sa, NULL); } #define NONFAILING(...) \ ({ \ int ok = 1; \ __atomic_fetch_add(&skip_segv, 1, __ATOMIC_SEQ_CST); \ if (_setjmp(segv_env) == 0) { \ __VA_ARGS__; \ } else \ ok = 0; \ __atomic_fetch_sub(&skip_segv, 1, __ATOMIC_SEQ_CST); \ ok; \ }) static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 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); } #define BITMASK(bf_off, bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type, htobe, addr, val, bf_off, bf_len) \ *(type*)(addr) = \ htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | \ (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) 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; } struct nlmsg { char* pos; int nesting; struct nlattr* nested[8]; char buf[4096]; }; static void netlink_init(struct nlmsg* nlmsg, int typ, int flags, const void* data, int size) { memset(nlmsg, 0, sizeof(*nlmsg)); struct nlmsghdr* hdr = (struct nlmsghdr*)nlmsg->buf; hdr->nlmsg_type = typ; hdr->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK | flags; memcpy(hdr + 1, data, size); nlmsg->pos = (char*)(hdr + 1) + NLMSG_ALIGN(size); } static void netlink_attr(struct nlmsg* nlmsg, int typ, const void* data, int size) { struct nlattr* attr = (struct nlattr*)nlmsg->pos; attr->nla_len = sizeof(*attr) + size; attr->nla_type = typ; if (size > 0) memcpy(attr + 1, data, size); nlmsg->pos += NLMSG_ALIGN(attr->nla_len); } static void netlink_nest(struct nlmsg* nlmsg, int typ) { struct nlattr* attr = (struct nlattr*)nlmsg->pos; attr->nla_type = typ; nlmsg->pos += sizeof(*attr); nlmsg->nested[nlmsg->nesting++] = attr; } static void netlink_done(struct nlmsg* nlmsg) { struct nlattr* attr = nlmsg->nested[--nlmsg->nesting]; attr->nla_len = nlmsg->pos - (char*)attr; } static int netlink_send_ext(struct nlmsg* nlmsg, int sock, uint16_t reply_type, int* reply_len, bool dofail) { if (nlmsg->pos > nlmsg->buf + sizeof(nlmsg->buf) || nlmsg->nesting) exit(1); struct nlmsghdr* hdr = (struct nlmsghdr*)nlmsg->buf; hdr->nlmsg_len = nlmsg->pos - nlmsg->buf; struct sockaddr_nl addr; memset(&addr, 0, sizeof(addr)); addr.nl_family = AF_NETLINK; ssize_t n = sendto(sock, nlmsg->buf, hdr->nlmsg_len, 0, (struct sockaddr*)&addr, sizeof(addr)); if (n != (ssize_t)hdr->nlmsg_len) { if (dofail) exit(1); return -1; } n = recv(sock, nlmsg->buf, sizeof(nlmsg->buf), 0); if (reply_len) *reply_len = 0; if (n < 0) { if (dofail) exit(1); return -1; } if (n < (ssize_t)sizeof(struct nlmsghdr)) { errno = EINVAL; if (dofail) exit(1); return -1; } if (hdr->nlmsg_type == NLMSG_DONE) return 0; if (reply_len && hdr->nlmsg_type == reply_type) { *reply_len = n; return 0; } if (n < (ssize_t)(sizeof(struct nlmsghdr) + sizeof(struct nlmsgerr))) { errno = EINVAL; if (dofail) exit(1); return -1; } if (hdr->nlmsg_type != NLMSG_ERROR) { errno = EINVAL; if (dofail) exit(1); return -1; } errno = -((struct nlmsgerr*)(hdr + 1))->error; return -errno; } static int netlink_send(struct nlmsg* nlmsg, int sock) { return netlink_send_ext(nlmsg, sock, 0, NULL, true); } static int netlink_query_family_id(struct nlmsg* nlmsg, int sock, const char* family_name, bool dofail) { struct genlmsghdr genlhdr; memset(&genlhdr, 0, sizeof(genlhdr)); genlhdr.cmd = CTRL_CMD_GETFAMILY; netlink_init(nlmsg, GENL_ID_CTRL, 0, &genlhdr, sizeof(genlhdr)); netlink_attr(nlmsg, CTRL_ATTR_FAMILY_NAME, family_name, strnlen(family_name, GENL_NAMSIZ - 1) + 1); int n = 0; int err = netlink_send_ext(nlmsg, sock, GENL_ID_CTRL, &n, dofail); if (err < 0) { return -1; } uint16_t id = 0; struct nlattr* attr = (struct nlattr*)(nlmsg->buf + NLMSG_HDRLEN + NLMSG_ALIGN(sizeof(genlhdr))); for (; (char*)attr < nlmsg->buf + n; attr = (struct nlattr*)((char*)attr + NLMSG_ALIGN(attr->nla_len))) { if (attr->nla_type == CTRL_ATTR_FAMILY_ID) { id = *(uint16_t*)(attr + 1); break; } } if (!id) { errno = EINVAL; return -1; } recv(sock, nlmsg->buf, sizeof(nlmsg->buf), 0); return id; } static int netlink_next_msg(struct nlmsg* nlmsg, unsigned int offset, unsigned int total_len) { struct nlmsghdr* hdr = (struct nlmsghdr*)(nlmsg->buf + offset); if (offset == total_len || offset + hdr->nlmsg_len > total_len) return -1; return hdr->nlmsg_len; } static void netlink_add_device_impl(struct nlmsg* nlmsg, const char* type, const char* name) { struct ifinfomsg hdr; memset(&hdr, 0, sizeof(hdr)); netlink_init(nlmsg, RTM_NEWLINK, NLM_F_EXCL | NLM_F_CREATE, &hdr, sizeof(hdr)); if (name) netlink_attr(nlmsg, IFLA_IFNAME, name, strlen(name)); netlink_nest(nlmsg, IFLA_LINKINFO); netlink_attr(nlmsg, IFLA_INFO_KIND, type, strlen(type)); } static void netlink_add_device(struct nlmsg* nlmsg, int sock, const char* type, const char* name) { netlink_add_device_impl(nlmsg, type, name); netlink_done(nlmsg); int err = netlink_send(nlmsg, sock); if (err < 0) { } } static void netlink_add_veth(struct nlmsg* nlmsg, int sock, const char* name, const char* peer) { netlink_add_device_impl(nlmsg, "veth", name); netlink_nest(nlmsg, IFLA_INFO_DATA); netlink_nest(nlmsg, VETH_INFO_PEER); nlmsg->pos += sizeof(struct ifinfomsg); netlink_attr(nlmsg, IFLA_IFNAME, peer, strlen(peer)); netlink_done(nlmsg); netlink_done(nlmsg); netlink_done(nlmsg); int err = netlink_send(nlmsg, sock); if (err < 0) { } } static void netlink_add_hsr(struct nlmsg* nlmsg, int sock, const char* name, const char* slave1, const char* slave2) { netlink_add_device_impl(nlmsg, "hsr", name); netlink_nest(nlmsg, IFLA_INFO_DATA); int ifindex1 = if_nametoindex(slave1); netlink_attr(nlmsg, IFLA_HSR_SLAVE1, &ifindex1, sizeof(ifindex1)); int ifindex2 = if_nametoindex(slave2); netlink_attr(nlmsg, IFLA_HSR_SLAVE2, &ifindex2, sizeof(ifindex2)); netlink_done(nlmsg); netlink_done(nlmsg); int err = netlink_send(nlmsg, sock); if (err < 0) { } } static void netlink_add_linked(struct nlmsg* nlmsg, int sock, const char* type, const char* name, const char* link) { netlink_add_device_impl(nlmsg, type, name); netlink_done(nlmsg); int ifindex = if_nametoindex(link); netlink_attr(nlmsg, IFLA_LINK, &ifindex, sizeof(ifindex)); int err = netlink_send(nlmsg, sock); if (err < 0) { } } static void netlink_add_vlan(struct nlmsg* nlmsg, int sock, const char* name, const char* link, uint16_t id, uint16_t proto) { netlink_add_device_impl(nlmsg, "vlan", name); netlink_nest(nlmsg, IFLA_INFO_DATA); netlink_attr(nlmsg, IFLA_VLAN_ID, &id, sizeof(id)); netlink_attr(nlmsg, IFLA_VLAN_PROTOCOL, &proto, sizeof(proto)); netlink_done(nlmsg); netlink_done(nlmsg); int ifindex = if_nametoindex(link); netlink_attr(nlmsg, IFLA_LINK, &ifindex, sizeof(ifindex)); int err = netlink_send(nlmsg, sock); if (err < 0) { } } static void netlink_add_macvlan(struct nlmsg* nlmsg, int sock, const char* name, const char* link) { netlink_add_device_impl(nlmsg, "macvlan", name); netlink_nest(nlmsg, IFLA_INFO_DATA); uint32_t mode = MACVLAN_MODE_BRIDGE; netlink_attr(nlmsg, IFLA_MACVLAN_MODE, &mode, sizeof(mode)); netlink_done(nlmsg); netlink_done(nlmsg); int ifindex = if_nametoindex(link); netlink_attr(nlmsg, IFLA_LINK, &ifindex, sizeof(ifindex)); int err = netlink_send(nlmsg, sock); if (err < 0) { } } static void netlink_add_geneve(struct nlmsg* nlmsg, int sock, const char* name, uint32_t vni, struct in_addr* addr4, struct in6_addr* addr6) { netlink_add_device_impl(nlmsg, "geneve", name); netlink_nest(nlmsg, IFLA_INFO_DATA); netlink_attr(nlmsg, IFLA_GENEVE_ID, &vni, sizeof(vni)); if (addr4) netlink_attr(nlmsg, IFLA_GENEVE_REMOTE, addr4, sizeof(*addr4)); if (addr6) netlink_attr(nlmsg, IFLA_GENEVE_REMOTE6, addr6, sizeof(*addr6)); netlink_done(nlmsg); netlink_done(nlmsg); int err = netlink_send(nlmsg, sock); if (err < 0) { } } #define IFLA_IPVLAN_FLAGS 2 #define IPVLAN_MODE_L3S 2 #undef IPVLAN_F_VEPA #define IPVLAN_F_VEPA 2 static void netlink_add_ipvlan(struct nlmsg* nlmsg, int sock, const char* name, const char* link, uint16_t mode, uint16_t flags) { netlink_add_device_impl(nlmsg, "ipvlan", name); netlink_nest(nlmsg, IFLA_INFO_DATA); netlink_attr(nlmsg, IFLA_IPVLAN_MODE, &mode, sizeof(mode)); netlink_attr(nlmsg, IFLA_IPVLAN_FLAGS, &flags, sizeof(flags)); netlink_done(nlmsg); netlink_done(nlmsg); int ifindex = if_nametoindex(link); netlink_attr(nlmsg, IFLA_LINK, &ifindex, sizeof(ifindex)); int err = netlink_send(nlmsg, sock); if (err < 0) { } } static void netlink_device_change(struct nlmsg* nlmsg, int sock, const char* name, bool up, const char* master, const void* mac, int macsize, const char* new_name) { struct ifinfomsg hdr; memset(&hdr, 0, sizeof(hdr)); if (up) hdr.ifi_flags = hdr.ifi_change = IFF_UP; hdr.ifi_index = if_nametoindex(name); netlink_init(nlmsg, RTM_NEWLINK, 0, &hdr, sizeof(hdr)); if (new_name) netlink_attr(nlmsg, IFLA_IFNAME, new_name, strlen(new_name)); if (master) { int ifindex = if_nametoindex(master); netlink_attr(nlmsg, IFLA_MASTER, &ifindex, sizeof(ifindex)); } if (macsize) netlink_attr(nlmsg, IFLA_ADDRESS, mac, macsize); int err = netlink_send(nlmsg, sock); if (err < 0) { } } static int netlink_add_addr(struct nlmsg* nlmsg, int sock, const char* dev, const void* addr, int addrsize) { struct ifaddrmsg hdr; memset(&hdr, 0, sizeof(hdr)); hdr.ifa_family = addrsize == 4 ? AF_INET : AF_INET6; hdr.ifa_prefixlen = addrsize == 4 ? 24 : 120; hdr.ifa_scope = RT_SCOPE_UNIVERSE; hdr.ifa_index = if_nametoindex(dev); netlink_init(nlmsg, RTM_NEWADDR, NLM_F_CREATE | NLM_F_REPLACE, &hdr, sizeof(hdr)); netlink_attr(nlmsg, IFA_LOCAL, addr, addrsize); netlink_attr(nlmsg, IFA_ADDRESS, addr, addrsize); return netlink_send(nlmsg, sock); } static void netlink_add_addr4(struct nlmsg* nlmsg, int sock, const char* dev, const char* addr) { struct in_addr in_addr; inet_pton(AF_INET, addr, &in_addr); int err = netlink_add_addr(nlmsg, sock, dev, &in_addr, sizeof(in_addr)); if (err < 0) { } } static void netlink_add_addr6(struct nlmsg* nlmsg, int sock, const char* dev, const char* addr) { struct in6_addr in6_addr; inet_pton(AF_INET6, addr, &in6_addr); int err = netlink_add_addr(nlmsg, sock, dev, &in6_addr, sizeof(in6_addr)); if (err < 0) { } } static void netlink_add_neigh(struct nlmsg* nlmsg, int sock, const char* name, const void* addr, int addrsize, const void* mac, int macsize) { struct ndmsg hdr; memset(&hdr, 0, sizeof(hdr)); hdr.ndm_family = addrsize == 4 ? AF_INET : AF_INET6; hdr.ndm_ifindex = if_nametoindex(name); hdr.ndm_state = NUD_PERMANENT; netlink_init(nlmsg, RTM_NEWNEIGH, NLM_F_EXCL | NLM_F_CREATE, &hdr, sizeof(hdr)); netlink_attr(nlmsg, NDA_DST, addr, addrsize); netlink_attr(nlmsg, NDA_LLADDR, mac, macsize); int err = netlink_send(nlmsg, sock); if (err < 0) { } } static struct nlmsg nlmsg; static int tunfd = -1; #define TUN_IFACE "syz_tun" #define LOCAL_MAC 0xaaaaaaaaaaaa #define REMOTE_MAC 0xaaaaaaaaaabb #define LOCAL_IPV4 "172.20.20.170" #define REMOTE_IPV4 "172.20.20.187" #define LOCAL_IPV6 "fe80::aa" #define REMOTE_IPV6 "fe80::bb" #define IFF_NAPI 0x0010 static void initialize_tun(void) { tunfd = open("/dev/net/tun", O_RDWR | O_NONBLOCK); if (tunfd == -1) { printf("tun: can't open /dev/net/tun: please enable CONFIG_TUN=y\n"); printf("otherwise fuzzing or reproducing might not work as intended\n"); return; } const int kTunFd = 240; if (dup2(tunfd, kTunFd) < 0) exit(1); close(tunfd); tunfd = kTunFd; struct ifreq ifr; memset(&ifr, 0, sizeof(ifr)); strncpy(ifr.ifr_name, TUN_IFACE, IFNAMSIZ); ifr.ifr_flags = IFF_TAP | IFF_NO_PI; if (ioctl(tunfd, TUNSETIFF, (void*)&ifr) < 0) { exit(1); } char sysctl[64]; sprintf(sysctl, "/proc/sys/net/ipv6/conf/%s/accept_dad", TUN_IFACE); write_file(sysctl, "0"); sprintf(sysctl, "/proc/sys/net/ipv6/conf/%s/router_solicitations", TUN_IFACE); write_file(sysctl, "0"); int sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); if (sock == -1) exit(1); netlink_add_addr4(&nlmsg, sock, TUN_IFACE, LOCAL_IPV4); netlink_add_addr6(&nlmsg, sock, TUN_IFACE, LOCAL_IPV6); uint64_t macaddr = REMOTE_MAC; struct in_addr in_addr; inet_pton(AF_INET, REMOTE_IPV4, &in_addr); netlink_add_neigh(&nlmsg, sock, TUN_IFACE, &in_addr, sizeof(in_addr), &macaddr, ETH_ALEN); struct in6_addr in6_addr; inet_pton(AF_INET6, REMOTE_IPV6, &in6_addr); netlink_add_neigh(&nlmsg, sock, TUN_IFACE, &in6_addr, sizeof(in6_addr), &macaddr, ETH_ALEN); macaddr = LOCAL_MAC; netlink_device_change(&nlmsg, sock, TUN_IFACE, true, 0, &macaddr, ETH_ALEN, NULL); close(sock); } #define DEVLINK_FAMILY_NAME "devlink" #define DEVLINK_CMD_PORT_GET 5 #define DEVLINK_ATTR_BUS_NAME 1 #define DEVLINK_ATTR_DEV_NAME 2 #define DEVLINK_ATTR_NETDEV_NAME 7 static struct nlmsg nlmsg2; static void initialize_devlink_ports(const char* bus_name, const char* dev_name, const char* netdev_prefix) { struct genlmsghdr genlhdr; int len, total_len, id, err, offset; uint16_t netdev_index; int sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_GENERIC); if (sock == -1) exit(1); int rtsock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); if (rtsock == -1) exit(1); id = netlink_query_family_id(&nlmsg, sock, DEVLINK_FAMILY_NAME, true); if (id == -1) goto error; memset(&genlhdr, 0, sizeof(genlhdr)); genlhdr.cmd = DEVLINK_CMD_PORT_GET; netlink_init(&nlmsg, id, NLM_F_DUMP, &genlhdr, sizeof(genlhdr)); netlink_attr(&nlmsg, DEVLINK_ATTR_BUS_NAME, bus_name, strlen(bus_name) + 1); netlink_attr(&nlmsg, DEVLINK_ATTR_DEV_NAME, dev_name, strlen(dev_name) + 1); err = netlink_send_ext(&nlmsg, sock, id, &total_len, true); if (err < 0) { goto error; } offset = 0; netdev_index = 0; while ((len = netlink_next_msg(&nlmsg, offset, total_len)) != -1) { struct nlattr* attr = (struct nlattr*)(nlmsg.buf + offset + NLMSG_HDRLEN + NLMSG_ALIGN(sizeof(genlhdr))); for (; (char*)attr < nlmsg.buf + offset + len; attr = (struct nlattr*)((char*)attr + NLMSG_ALIGN(attr->nla_len))) { if (attr->nla_type == DEVLINK_ATTR_NETDEV_NAME) { char* port_name; char netdev_name[IFNAMSIZ]; port_name = (char*)(attr + 1); snprintf(netdev_name, sizeof(netdev_name), "%s%d", netdev_prefix, netdev_index); netlink_device_change(&nlmsg2, rtsock, port_name, true, 0, 0, 0, netdev_name); break; } } offset += len; netdev_index++; } error: close(rtsock); close(sock); } #define DEV_IPV4 "172.20.20.%d" #define DEV_IPV6 "fe80::%02x" #define DEV_MAC 0x00aaaaaaaaaa static void netdevsim_add(unsigned int addr, unsigned int port_count) { char buf[16]; sprintf(buf, "%u %u", addr, port_count); if (write_file("/sys/bus/netdevsim/new_device", buf)) { snprintf(buf, sizeof(buf), "netdevsim%d", addr); initialize_devlink_ports("netdevsim", buf, "netdevsim"); } } #define WG_GENL_NAME "wireguard" enum wg_cmd { WG_CMD_GET_DEVICE, WG_CMD_SET_DEVICE, }; enum wgdevice_attribute { WGDEVICE_A_UNSPEC, WGDEVICE_A_IFINDEX, WGDEVICE_A_IFNAME, WGDEVICE_A_PRIVATE_KEY, WGDEVICE_A_PUBLIC_KEY, WGDEVICE_A_FLAGS, WGDEVICE_A_LISTEN_PORT, WGDEVICE_A_FWMARK, WGDEVICE_A_PEERS, }; enum wgpeer_attribute { WGPEER_A_UNSPEC, WGPEER_A_PUBLIC_KEY, WGPEER_A_PRESHARED_KEY, WGPEER_A_FLAGS, WGPEER_A_ENDPOINT, WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL, WGPEER_A_LAST_HANDSHAKE_TIME, WGPEER_A_RX_BYTES, WGPEER_A_TX_BYTES, WGPEER_A_ALLOWEDIPS, WGPEER_A_PROTOCOL_VERSION, }; enum wgallowedip_attribute { WGALLOWEDIP_A_UNSPEC, WGALLOWEDIP_A_FAMILY, WGALLOWEDIP_A_IPADDR, WGALLOWEDIP_A_CIDR_MASK, }; static void netlink_wireguard_setup(void) { const char ifname_a[] = "wg0"; const char ifname_b[] = "wg1"; const char ifname_c[] = "wg2"; const char private_a[] = "\xa0\x5c\xa8\x4f\x6c\x9c\x8e\x38\x53\xe2\xfd\x7a\x70\xae\x0f\xb2\x0f\xa1" "\x52\x60\x0c\xb0\x08\x45\x17\x4f\x08\x07\x6f\x8d\x78\x43"; const char private_b[] = "\xb0\x80\x73\xe8\xd4\x4e\x91\xe3\xda\x92\x2c\x22\x43\x82\x44\xbb\x88\x5c" "\x69\xe2\x69\xc8\xe9\xd8\x35\xb1\x14\x29\x3a\x4d\xdc\x6e"; const char private_c[] = "\xa0\xcb\x87\x9a\x47\xf5\xbc\x64\x4c\x0e\x69\x3f\xa6\xd0\x31\xc7\x4a\x15" "\x53\xb6\xe9\x01\xb9\xff\x2f\x51\x8c\x78\x04\x2f\xb5\x42"; const char public_a[] = "\x97\x5c\x9d\x81\xc9\x83\xc8\x20\x9e\xe7\x81\x25\x4b\x89\x9f\x8e\xd9\x25" "\xae\x9f\x09\x23\xc2\x3c\x62\xf5\x3c\x57\xcd\xbf\x69\x1c"; const char public_b[] = "\xd1\x73\x28\x99\xf6\x11\xcd\x89\x94\x03\x4d\x7f\x41\x3d\xc9\x57\x63\x0e" "\x54\x93\xc2\x85\xac\xa4\x00\x65\xcb\x63\x11\xbe\x69\x6b"; const char public_c[] = "\xf4\x4d\xa3\x67\xa8\x8e\xe6\x56\x4f\x02\x02\x11\x45\x67\x27\x08\x2f\x5c" "\xeb\xee\x8b\x1b\xf5\xeb\x73\x37\x34\x1b\x45\x9b\x39\x22"; const uint16_t listen_a = 20001; const uint16_t listen_b = 20002; const uint16_t listen_c = 20003; const uint16_t af_inet = AF_INET; const uint16_t af_inet6 = AF_INET6; const struct sockaddr_in endpoint_b_v4 = { .sin_family = AF_INET, .sin_port = htons(listen_b), .sin_addr = {htonl(INADDR_LOOPBACK)}}; const struct sockaddr_in endpoint_c_v4 = { .sin_family = AF_INET, .sin_port = htons(listen_c), .sin_addr = {htonl(INADDR_LOOPBACK)}}; struct sockaddr_in6 endpoint_a_v6 = {.sin6_family = AF_INET6, .sin6_port = htons(listen_a)}; endpoint_a_v6.sin6_addr = in6addr_loopback; struct sockaddr_in6 endpoint_c_v6 = {.sin6_family = AF_INET6, .sin6_port = htons(listen_c)}; endpoint_c_v6.sin6_addr = in6addr_loopback; const struct in_addr first_half_v4 = {0}; const struct in_addr second_half_v4 = {(uint32_t)htonl(128 << 24)}; const struct in6_addr first_half_v6 = {{{0}}}; const struct in6_addr second_half_v6 = {{{0x80}}}; const uint8_t half_cidr = 1; const uint16_t persistent_keepalives[] = {1, 3, 7, 9, 14, 19}; struct genlmsghdr genlhdr = {.cmd = WG_CMD_SET_DEVICE, .version = 1}; int sock; int id, err; sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_GENERIC); if (sock == -1) { return; } id = netlink_query_family_id(&nlmsg, sock, WG_GENL_NAME, true); if (id == -1) goto error; netlink_init(&nlmsg, id, 0, &genlhdr, sizeof(genlhdr)); netlink_attr(&nlmsg, WGDEVICE_A_IFNAME, ifname_a, strlen(ifname_a) + 1); netlink_attr(&nlmsg, WGDEVICE_A_PRIVATE_KEY, private_a, 32); netlink_attr(&nlmsg, WGDEVICE_A_LISTEN_PORT, &listen_a, 2); netlink_nest(&nlmsg, NLA_F_NESTED | WGDEVICE_A_PEERS); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGPEER_A_PUBLIC_KEY, public_b, 32); netlink_attr(&nlmsg, WGPEER_A_ENDPOINT, &endpoint_b_v4, sizeof(endpoint_b_v4)); netlink_attr(&nlmsg, WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL, &persistent_keepalives[0], 2); netlink_nest(&nlmsg, NLA_F_NESTED | WGPEER_A_ALLOWEDIPS); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &first_half_v4, sizeof(first_half_v4)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet6, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &first_half_v6, sizeof(first_half_v6)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGPEER_A_PUBLIC_KEY, public_c, 32); netlink_attr(&nlmsg, WGPEER_A_ENDPOINT, &endpoint_c_v6, sizeof(endpoint_c_v6)); netlink_attr(&nlmsg, WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL, &persistent_keepalives[1], 2); netlink_nest(&nlmsg, NLA_F_NESTED | WGPEER_A_ALLOWEDIPS); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &second_half_v4, sizeof(second_half_v4)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet6, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &second_half_v6, sizeof(second_half_v6)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_done(&nlmsg); err = netlink_send(&nlmsg, sock); if (err < 0) { } netlink_init(&nlmsg, id, 0, &genlhdr, sizeof(genlhdr)); netlink_attr(&nlmsg, WGDEVICE_A_IFNAME, ifname_b, strlen(ifname_b) + 1); netlink_attr(&nlmsg, WGDEVICE_A_PRIVATE_KEY, private_b, 32); netlink_attr(&nlmsg, WGDEVICE_A_LISTEN_PORT, &listen_b, 2); netlink_nest(&nlmsg, NLA_F_NESTED | WGDEVICE_A_PEERS); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGPEER_A_PUBLIC_KEY, public_a, 32); netlink_attr(&nlmsg, WGPEER_A_ENDPOINT, &endpoint_a_v6, sizeof(endpoint_a_v6)); netlink_attr(&nlmsg, WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL, &persistent_keepalives[2], 2); netlink_nest(&nlmsg, NLA_F_NESTED | WGPEER_A_ALLOWEDIPS); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &first_half_v4, sizeof(first_half_v4)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet6, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &first_half_v6, sizeof(first_half_v6)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGPEER_A_PUBLIC_KEY, public_c, 32); netlink_attr(&nlmsg, WGPEER_A_ENDPOINT, &endpoint_c_v4, sizeof(endpoint_c_v4)); netlink_attr(&nlmsg, WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL, &persistent_keepalives[3], 2); netlink_nest(&nlmsg, NLA_F_NESTED | WGPEER_A_ALLOWEDIPS); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &second_half_v4, sizeof(second_half_v4)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet6, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &second_half_v6, sizeof(second_half_v6)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_done(&nlmsg); err = netlink_send(&nlmsg, sock); if (err < 0) { } netlink_init(&nlmsg, id, 0, &genlhdr, sizeof(genlhdr)); netlink_attr(&nlmsg, WGDEVICE_A_IFNAME, ifname_c, strlen(ifname_c) + 1); netlink_attr(&nlmsg, WGDEVICE_A_PRIVATE_KEY, private_c, 32); netlink_attr(&nlmsg, WGDEVICE_A_LISTEN_PORT, &listen_c, 2); netlink_nest(&nlmsg, NLA_F_NESTED | WGDEVICE_A_PEERS); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGPEER_A_PUBLIC_KEY, public_a, 32); netlink_attr(&nlmsg, WGPEER_A_ENDPOINT, &endpoint_a_v6, sizeof(endpoint_a_v6)); netlink_attr(&nlmsg, WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL, &persistent_keepalives[4], 2); netlink_nest(&nlmsg, NLA_F_NESTED | WGPEER_A_ALLOWEDIPS); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &first_half_v4, sizeof(first_half_v4)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet6, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &first_half_v6, sizeof(first_half_v6)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGPEER_A_PUBLIC_KEY, public_b, 32); netlink_attr(&nlmsg, WGPEER_A_ENDPOINT, &endpoint_b_v4, sizeof(endpoint_b_v4)); netlink_attr(&nlmsg, WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL, &persistent_keepalives[5], 2); netlink_nest(&nlmsg, NLA_F_NESTED | WGPEER_A_ALLOWEDIPS); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &second_half_v4, sizeof(second_half_v4)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet6, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &second_half_v6, sizeof(second_half_v6)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_done(&nlmsg); err = netlink_send(&nlmsg, sock); if (err < 0) { } error: close(sock); } static void initialize_netdevices(void) { char netdevsim[16]; sprintf(netdevsim, "netdevsim%d", (int)procid); struct { const char* type; const char* dev; } devtypes[] = { {"ip6gretap", "ip6gretap0"}, {"bridge", "bridge0"}, {"vcan", "vcan0"}, {"bond", "bond0"}, {"team", "team0"}, {"dummy", "dummy0"}, {"nlmon", "nlmon0"}, {"caif", "caif0"}, {"batadv", "batadv0"}, {"vxcan", "vxcan1"}, {"netdevsim", netdevsim}, {"veth", 0}, {"xfrm", "xfrm0"}, {"wireguard", "wg0"}, {"wireguard", "wg1"}, {"wireguard", "wg2"}, }; const char* devmasters[] = {"bridge", "bond", "team", "batadv"}; struct { const char* name; int macsize; bool noipv6; } devices[] = { {"lo", ETH_ALEN}, {"sit0", 0}, {"bridge0", ETH_ALEN}, {"vcan0", 0, true}, {"tunl0", 0}, {"gre0", 0}, {"gretap0", ETH_ALEN}, {"ip_vti0", 0}, {"ip6_vti0", 0}, {"ip6tnl0", 0}, {"ip6gre0", 0}, {"ip6gretap0", ETH_ALEN}, {"erspan0", ETH_ALEN}, {"bond0", ETH_ALEN}, {"veth0", ETH_ALEN}, {"veth1", ETH_ALEN}, {"team0", ETH_ALEN}, {"veth0_to_bridge", ETH_ALEN}, {"veth1_to_bridge", ETH_ALEN}, {"veth0_to_bond", ETH_ALEN}, {"veth1_to_bond", ETH_ALEN}, {"veth0_to_team", ETH_ALEN}, {"veth1_to_team", ETH_ALEN}, {"veth0_to_hsr", ETH_ALEN}, {"veth1_to_hsr", ETH_ALEN}, {"hsr0", 0}, {"dummy0", ETH_ALEN}, {"nlmon0", 0}, {"vxcan0", 0, true}, {"vxcan1", 0, true}, {"caif0", ETH_ALEN}, {"batadv0", ETH_ALEN}, {netdevsim, ETH_ALEN}, {"xfrm0", ETH_ALEN}, {"veth0_virt_wifi", ETH_ALEN}, {"veth1_virt_wifi", ETH_ALEN}, {"virt_wifi0", ETH_ALEN}, {"veth0_vlan", ETH_ALEN}, {"veth1_vlan", ETH_ALEN}, {"vlan0", ETH_ALEN}, {"vlan1", ETH_ALEN}, {"macvlan0", ETH_ALEN}, {"macvlan1", ETH_ALEN}, {"ipvlan0", ETH_ALEN}, {"ipvlan1", ETH_ALEN}, {"veth0_macvtap", ETH_ALEN}, {"veth1_macvtap", ETH_ALEN}, {"macvtap0", ETH_ALEN}, {"macsec0", ETH_ALEN}, {"veth0_to_batadv", ETH_ALEN}, {"veth1_to_batadv", ETH_ALEN}, {"batadv_slave_0", ETH_ALEN}, {"batadv_slave_1", ETH_ALEN}, {"geneve0", ETH_ALEN}, {"geneve1", ETH_ALEN}, {"wg0", 0}, {"wg1", 0}, {"wg2", 0}, }; int sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); if (sock == -1) exit(1); unsigned i; for (i = 0; i < sizeof(devtypes) / sizeof(devtypes[0]); i++) netlink_add_device(&nlmsg, sock, devtypes[i].type, devtypes[i].dev); for (i = 0; i < sizeof(devmasters) / (sizeof(devmasters[0])); i++) { char master[32], slave0[32], veth0[32], slave1[32], veth1[32]; sprintf(slave0, "%s_slave_0", devmasters[i]); sprintf(veth0, "veth0_to_%s", devmasters[i]); netlink_add_veth(&nlmsg, sock, slave0, veth0); sprintf(slave1, "%s_slave_1", devmasters[i]); sprintf(veth1, "veth1_to_%s", devmasters[i]); netlink_add_veth(&nlmsg, sock, slave1, veth1); sprintf(master, "%s0", devmasters[i]); netlink_device_change(&nlmsg, sock, slave0, false, master, 0, 0, NULL); netlink_device_change(&nlmsg, sock, slave1, false, master, 0, 0, NULL); } netlink_device_change(&nlmsg, sock, "bridge_slave_0", true, 0, 0, 0, NULL); netlink_device_change(&nlmsg, sock, "bridge_slave_1", true, 0, 0, 0, NULL); netlink_add_veth(&nlmsg, sock, "hsr_slave_0", "veth0_to_hsr"); netlink_add_veth(&nlmsg, sock, "hsr_slave_1", "veth1_to_hsr"); netlink_add_hsr(&nlmsg, sock, "hsr0", "hsr_slave_0", "hsr_slave_1"); netlink_device_change(&nlmsg, sock, "hsr_slave_0", true, 0, 0, 0, NULL); netlink_device_change(&nlmsg, sock, "hsr_slave_1", true, 0, 0, 0, NULL); netlink_add_veth(&nlmsg, sock, "veth0_virt_wifi", "veth1_virt_wifi"); netlink_add_linked(&nlmsg, sock, "virt_wifi", "virt_wifi0", "veth1_virt_wifi"); netlink_add_veth(&nlmsg, sock, "veth0_vlan", "veth1_vlan"); netlink_add_vlan(&nlmsg, sock, "vlan0", "veth0_vlan", 0, htons(ETH_P_8021Q)); netlink_add_vlan(&nlmsg, sock, "vlan1", "veth0_vlan", 1, htons(ETH_P_8021AD)); netlink_add_macvlan(&nlmsg, sock, "macvlan0", "veth1_vlan"); netlink_add_macvlan(&nlmsg, sock, "macvlan1", "veth1_vlan"); netlink_add_ipvlan(&nlmsg, sock, "ipvlan0", "veth0_vlan", IPVLAN_MODE_L2, 0); netlink_add_ipvlan(&nlmsg, sock, "ipvlan1", "veth0_vlan", IPVLAN_MODE_L3S, IPVLAN_F_VEPA); netlink_add_veth(&nlmsg, sock, "veth0_macvtap", "veth1_macvtap"); netlink_add_linked(&nlmsg, sock, "macvtap", "macvtap0", "veth0_macvtap"); netlink_add_linked(&nlmsg, sock, "macsec", "macsec0", "veth1_macvtap"); char addr[32]; sprintf(addr, DEV_IPV4, 14 + 10); struct in_addr geneve_addr4; if (inet_pton(AF_INET, addr, &geneve_addr4) <= 0) exit(1); struct in6_addr geneve_addr6; if (inet_pton(AF_INET6, "fc00::01", &geneve_addr6) <= 0) exit(1); netlink_add_geneve(&nlmsg, sock, "geneve0", 0, &geneve_addr4, 0); netlink_add_geneve(&nlmsg, sock, "geneve1", 1, 0, &geneve_addr6); netdevsim_add((int)procid, 4); netlink_wireguard_setup(); for (i = 0; i < sizeof(devices) / (sizeof(devices[0])); i++) { char addr[32]; sprintf(addr, DEV_IPV4, i + 10); netlink_add_addr4(&nlmsg, sock, devices[i].name, addr); if (!devices[i].noipv6) { sprintf(addr, DEV_IPV6, i + 10); netlink_add_addr6(&nlmsg, sock, devices[i].name, addr); } uint64_t macaddr = DEV_MAC + ((i + 10ull) << 40); netlink_device_change(&nlmsg, sock, devices[i].name, true, 0, &macaddr, devices[i].macsize, NULL); } close(sock); } static void initialize_netdevices_init(void) { int sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); if (sock == -1) exit(1); struct { const char* type; int macsize; bool noipv6; bool noup; } devtypes[] = { {"nr", 7, true}, {"rose", 5, true, true}, }; unsigned i; for (i = 0; i < sizeof(devtypes) / sizeof(devtypes[0]); i++) { char dev[32], addr[32]; sprintf(dev, "%s%d", devtypes[i].type, (int)procid); sprintf(addr, "172.30.%d.%d", i, (int)procid + 1); netlink_add_addr4(&nlmsg, sock, dev, addr); if (!devtypes[i].noipv6) { sprintf(addr, "fe88::%02x:%02x", i, (int)procid + 1); netlink_add_addr6(&nlmsg, sock, dev, addr); } int macsize = devtypes[i].macsize; uint64_t macaddr = 0xbbbbbb + ((unsigned long long)i << (8 * (macsize - 2))) + (procid << (8 * (macsize - 1))); netlink_device_change(&nlmsg, sock, dev, !devtypes[i].noup, 0, &macaddr, macsize, NULL); } close(sock); } static int read_tun(char* data, int size) { if (tunfd < 0) return -1; int rv = read(tunfd, data, size); if (rv < 0) { if (errno == EAGAIN || errno == EBADFD) return -1; exit(1); } return rv; } #define VHCI_HC_PORTS 8 #define VHCI_PORTS (VHCI_HC_PORTS * 2) static long syz_usbip_server_init(volatile long a0) { static int port_alloc[2]; int speed = (int)a0; bool usb3 = (speed == USB_SPEED_SUPER); int socket_pair[2]; if (socketpair(AF_UNIX, SOCK_STREAM, 0, socket_pair)) exit(1); int client_fd = socket_pair[0]; int server_fd = socket_pair[1]; int available_port_num = __atomic_fetch_add(&port_alloc[usb3], 1, __ATOMIC_RELAXED); if (available_port_num > VHCI_HC_PORTS) { return -1; } int port_num = procid * VHCI_PORTS + usb3 * VHCI_HC_PORTS + available_port_num; char buffer[100]; sprintf(buffer, "%d %d %s %d", port_num, client_fd, "0", speed); write_file("/sys/devices/platform/vhci_hcd.0/attach", buffer); return server_fd; } static void flush_tun() { char data[1000]; while (read_tun(&data[0], sizeof(data)) != -1) { } } #define MAX_FDS 30 #define BTPROTO_HCI 1 #define ACL_LINK 1 #define SCAN_PAGE 2 typedef struct { uint8_t b[6]; } __attribute__((packed)) bdaddr_t; #define HCI_COMMAND_PKT 1 #define HCI_EVENT_PKT 4 #define HCI_VENDOR_PKT 0xff struct hci_command_hdr { uint16_t opcode; uint8_t plen; } __attribute__((packed)); struct hci_event_hdr { uint8_t evt; uint8_t plen; } __attribute__((packed)); #define HCI_EV_CONN_COMPLETE 0x03 struct hci_ev_conn_complete { uint8_t status; uint16_t handle; bdaddr_t bdaddr; uint8_t link_type; uint8_t encr_mode; } __attribute__((packed)); #define HCI_EV_CONN_REQUEST 0x04 struct hci_ev_conn_request { bdaddr_t bdaddr; uint8_t dev_class[3]; uint8_t link_type; } __attribute__((packed)); #define HCI_EV_REMOTE_FEATURES 0x0b struct hci_ev_remote_features { uint8_t status; uint16_t handle; uint8_t features[8]; } __attribute__((packed)); #define HCI_EV_CMD_COMPLETE 0x0e struct hci_ev_cmd_complete { uint8_t ncmd; uint16_t opcode; } __attribute__((packed)); #define HCI_OP_WRITE_SCAN_ENABLE 0x0c1a #define HCI_OP_READ_BUFFER_SIZE 0x1005 struct hci_rp_read_buffer_size { uint8_t status; uint16_t acl_mtu; uint8_t sco_mtu; uint16_t acl_max_pkt; uint16_t sco_max_pkt; } __attribute__((packed)); #define HCI_OP_READ_BD_ADDR 0x1009 struct hci_rp_read_bd_addr { uint8_t status; bdaddr_t bdaddr; } __attribute__((packed)); #define HCI_EV_LE_META 0x3e struct hci_ev_le_meta { uint8_t subevent; } __attribute__((packed)); #define HCI_EV_LE_CONN_COMPLETE 0x01 struct hci_ev_le_conn_complete { uint8_t status; uint16_t handle; uint8_t role; uint8_t bdaddr_type; bdaddr_t bdaddr; uint16_t interval; uint16_t latency; uint16_t supervision_timeout; uint8_t clk_accurancy; } __attribute__((packed)); struct hci_dev_req { uint16_t dev_id; uint32_t dev_opt; }; struct vhci_vendor_pkt { uint8_t type; uint8_t opcode; uint16_t id; }; #define HCIDEVUP _IOW('H', 201, int) #define HCISETSCAN _IOW('H', 221, int) static int vhci_fd = -1; static void rfkill_unblock_all() { int fd = open("/dev/rfkill", O_WRONLY); if (fd < 0) exit(1); struct rfkill_event event = {0}; event.idx = 0; event.type = RFKILL_TYPE_ALL; event.op = RFKILL_OP_CHANGE_ALL; event.soft = 0; event.hard = 0; if (write(fd, &event, sizeof(event)) < 0) exit(1); close(fd); } static void hci_send_event_packet(int fd, uint8_t evt, void* data, size_t data_len) { struct iovec iv[3]; struct hci_event_hdr hdr; hdr.evt = evt; hdr.plen = data_len; uint8_t type = HCI_EVENT_PKT; iv[0].iov_base = &type; iv[0].iov_len = sizeof(type); iv[1].iov_base = &hdr; iv[1].iov_len = sizeof(hdr); iv[2].iov_base = data; iv[2].iov_len = data_len; if (writev(fd, iv, sizeof(iv) / sizeof(struct iovec)) < 0) exit(1); } static void hci_send_event_cmd_complete(int fd, uint16_t opcode, void* data, size_t data_len) { struct iovec iv[4]; struct hci_event_hdr hdr; hdr.evt = HCI_EV_CMD_COMPLETE; hdr.plen = sizeof(struct hci_ev_cmd_complete) + data_len; struct hci_ev_cmd_complete evt_hdr; evt_hdr.ncmd = 1; evt_hdr.opcode = opcode; uint8_t type = HCI_EVENT_PKT; iv[0].iov_base = &type; iv[0].iov_len = sizeof(type); iv[1].iov_base = &hdr; iv[1].iov_len = sizeof(hdr); iv[2].iov_base = &evt_hdr; iv[2].iov_len = sizeof(evt_hdr); iv[3].iov_base = data; iv[3].iov_len = data_len; if (writev(fd, iv, sizeof(iv) / sizeof(struct iovec)) < 0) exit(1); } static bool process_command_pkt(int fd, char* buf, ssize_t buf_size) { struct hci_command_hdr* hdr = (struct hci_command_hdr*)buf; if (buf_size < (ssize_t)sizeof(struct hci_command_hdr) || hdr->plen != buf_size - sizeof(struct hci_command_hdr)) { exit(1); } switch (hdr->opcode) { case HCI_OP_WRITE_SCAN_ENABLE: { uint8_t status = 0; hci_send_event_cmd_complete(fd, hdr->opcode, &status, sizeof(status)); return true; } case HCI_OP_READ_BD_ADDR: { struct hci_rp_read_bd_addr rp = {0}; rp.status = 0; memset(&rp.bdaddr, 0xaa, 6); hci_send_event_cmd_complete(fd, hdr->opcode, &rp, sizeof(rp)); return false; } case HCI_OP_READ_BUFFER_SIZE: { struct hci_rp_read_buffer_size rp = {0}; rp.status = 0; rp.acl_mtu = 1021; rp.sco_mtu = 96; rp.acl_max_pkt = 4; rp.sco_max_pkt = 6; hci_send_event_cmd_complete(fd, hdr->opcode, &rp, sizeof(rp)); return false; } } char dummy[0xf9] = {0}; hci_send_event_cmd_complete(fd, hdr->opcode, dummy, sizeof(dummy)); return false; } static void* event_thread(void* arg) { while (1) { char buf[1024] = {0}; ssize_t buf_size = read(vhci_fd, buf, sizeof(buf)); if (buf_size < 0) exit(1); if (buf_size > 0 && buf[0] == HCI_COMMAND_PKT) { if (process_command_pkt(vhci_fd, buf + 1, buf_size - 1)) break; } } return NULL; } #define HCI_HANDLE_1 200 #define HCI_HANDLE_2 201 static void initialize_vhci() { int hci_sock = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI); if (hci_sock < 0) exit(1); vhci_fd = open("/dev/vhci", O_RDWR); if (vhci_fd == -1) exit(1); const int kVhciFd = 241; if (dup2(vhci_fd, kVhciFd) < 0) exit(1); close(vhci_fd); vhci_fd = kVhciFd; struct vhci_vendor_pkt vendor_pkt; if (read(vhci_fd, &vendor_pkt, sizeof(vendor_pkt)) != sizeof(vendor_pkt)) exit(1); if (vendor_pkt.type != HCI_VENDOR_PKT) exit(1); pthread_t th; if (pthread_create(&th, NULL, event_thread, NULL)) exit(1); int ret = ioctl(hci_sock, HCIDEVUP, vendor_pkt.id); if (ret) { if (errno == ERFKILL) { rfkill_unblock_all(); ret = ioctl(hci_sock, HCIDEVUP, vendor_pkt.id); } if (ret && errno != EALREADY) exit(1); } struct hci_dev_req dr = {0}; dr.dev_id = vendor_pkt.id; dr.dev_opt = SCAN_PAGE; if (ioctl(hci_sock, HCISETSCAN, &dr)) exit(1); struct hci_ev_conn_request request; memset(&request, 0, sizeof(request)); memset(&request.bdaddr, 0xaa, 6); *(uint8_t*)&request.bdaddr.b[5] = 0x10; request.link_type = ACL_LINK; hci_send_event_packet(vhci_fd, HCI_EV_CONN_REQUEST, &request, sizeof(request)); struct hci_ev_conn_complete complete; memset(&complete, 0, sizeof(complete)); complete.status = 0; complete.handle = HCI_HANDLE_1; memset(&complete.bdaddr, 0xaa, 6); *(uint8_t*)&complete.bdaddr.b[5] = 0x10; complete.link_type = ACL_LINK; complete.encr_mode = 0; hci_send_event_packet(vhci_fd, HCI_EV_CONN_COMPLETE, &complete, sizeof(complete)); struct hci_ev_remote_features features; memset(&features, 0, sizeof(features)); features.status = 0; features.handle = HCI_HANDLE_1; hci_send_event_packet(vhci_fd, HCI_EV_REMOTE_FEATURES, &features, sizeof(features)); struct { struct hci_ev_le_meta le_meta; struct hci_ev_le_conn_complete le_conn; } le_conn; memset(&le_conn, 0, sizeof(le_conn)); le_conn.le_meta.subevent = HCI_EV_LE_CONN_COMPLETE; memset(&le_conn.le_conn.bdaddr, 0xaa, 6); *(uint8_t*)&le_conn.le_conn.bdaddr.b[5] = 0x11; le_conn.le_conn.role = 1; le_conn.le_conn.handle = HCI_HANDLE_2; hci_send_event_packet(vhci_fd, HCI_EV_LE_META, &le_conn, sizeof(le_conn)); pthread_join(th, NULL); close(hci_sock); } #define XT_TABLE_SIZE 1536 #define XT_MAX_ENTRIES 10 struct xt_counters { uint64_t pcnt, bcnt; }; struct ipt_getinfo { char name[32]; unsigned int valid_hooks; unsigned int hook_entry[5]; unsigned int underflow[5]; unsigned int num_entries; unsigned int size; }; struct ipt_get_entries { char name[32]; unsigned int size; uint64_t entrytable[XT_TABLE_SIZE / sizeof(uint64_t)]; }; struct ipt_replace { char name[32]; unsigned int valid_hooks; unsigned int num_entries; unsigned int size; unsigned int hook_entry[5]; unsigned int underflow[5]; unsigned int num_counters; struct xt_counters* counters; uint64_t entrytable[XT_TABLE_SIZE / sizeof(uint64_t)]; }; struct ipt_table_desc { const char* name; struct ipt_getinfo info; struct ipt_replace replace; }; static struct ipt_table_desc ipv4_tables[] = { {.name = "filter"}, {.name = "nat"}, {.name = "mangle"}, {.name = "raw"}, {.name = "security"}, }; static struct ipt_table_desc ipv6_tables[] = { {.name = "filter"}, {.name = "nat"}, {.name = "mangle"}, {.name = "raw"}, {.name = "security"}, }; #define IPT_BASE_CTL 64 #define IPT_SO_SET_REPLACE (IPT_BASE_CTL) #define IPT_SO_GET_INFO (IPT_BASE_CTL) #define IPT_SO_GET_ENTRIES (IPT_BASE_CTL + 1) struct arpt_getinfo { char name[32]; unsigned int valid_hooks; unsigned int hook_entry[3]; unsigned int underflow[3]; unsigned int num_entries; unsigned int size; }; struct arpt_get_entries { char name[32]; unsigned int size; uint64_t entrytable[XT_TABLE_SIZE / sizeof(uint64_t)]; }; struct arpt_replace { char name[32]; unsigned int valid_hooks; unsigned int num_entries; unsigned int size; unsigned int hook_entry[3]; unsigned int underflow[3]; unsigned int num_counters; struct xt_counters* counters; uint64_t entrytable[XT_TABLE_SIZE / sizeof(uint64_t)]; }; struct arpt_table_desc { const char* name; struct arpt_getinfo info; struct arpt_replace replace; }; static struct arpt_table_desc arpt_tables[] = { {.name = "filter"}, }; #define ARPT_BASE_CTL 96 #define ARPT_SO_SET_REPLACE (ARPT_BASE_CTL) #define ARPT_SO_GET_INFO (ARPT_BASE_CTL) #define ARPT_SO_GET_ENTRIES (ARPT_BASE_CTL + 1) static void checkpoint_iptables(struct ipt_table_desc* tables, int num_tables, int family, int level) { int fd = socket(family, SOCK_STREAM, IPPROTO_TCP); if (fd == -1) { switch (errno) { case EAFNOSUPPORT: case ENOPROTOOPT: return; } exit(1); } for (int i = 0; i < num_tables; i++) { struct ipt_table_desc* table = &tables[i]; strcpy(table->info.name, table->name); strcpy(table->replace.name, table->name); socklen_t optlen = sizeof(table->info); if (getsockopt(fd, level, IPT_SO_GET_INFO, &table->info, &optlen)) { switch (errno) { case EPERM: case ENOENT: case ENOPROTOOPT: continue; } exit(1); } if (table->info.size > sizeof(table->replace.entrytable)) exit(1); if (table->info.num_entries > XT_MAX_ENTRIES) exit(1); struct ipt_get_entries entries; memset(&entries, 0, sizeof(entries)); strcpy(entries.name, table->name); entries.size = table->info.size; optlen = sizeof(entries) - sizeof(entries.entrytable) + table->info.size; if (getsockopt(fd, level, IPT_SO_GET_ENTRIES, &entries, &optlen)) exit(1); table->replace.valid_hooks = table->info.valid_hooks; table->replace.num_entries = table->info.num_entries; table->replace.size = table->info.size; memcpy(table->replace.hook_entry, table->info.hook_entry, sizeof(table->replace.hook_entry)); memcpy(table->replace.underflow, table->info.underflow, sizeof(table->replace.underflow)); memcpy(table->replace.entrytable, entries.entrytable, table->info.size); } close(fd); } static void reset_iptables(struct ipt_table_desc* tables, int num_tables, int family, int level) { int fd = socket(family, SOCK_STREAM, IPPROTO_TCP); if (fd == -1) { switch (errno) { case EAFNOSUPPORT: case ENOPROTOOPT: return; } exit(1); } for (int i = 0; i < num_tables; i++) { struct ipt_table_desc* table = &tables[i]; if (table->info.valid_hooks == 0) continue; struct ipt_getinfo info; memset(&info, 0, sizeof(info)); strcpy(info.name, table->name); socklen_t optlen = sizeof(info); if (getsockopt(fd, level, IPT_SO_GET_INFO, &info, &optlen)) exit(1); if (memcmp(&table->info, &info, sizeof(table->info)) == 0) { struct ipt_get_entries entries; memset(&entries, 0, sizeof(entries)); strcpy(entries.name, table->name); entries.size = table->info.size; optlen = sizeof(entries) - sizeof(entries.entrytable) + entries.size; if (getsockopt(fd, level, IPT_SO_GET_ENTRIES, &entries, &optlen)) exit(1); if (memcmp(table->replace.entrytable, entries.entrytable, table->info.size) == 0) continue; } struct xt_counters counters[XT_MAX_ENTRIES]; table->replace.num_counters = info.num_entries; table->replace.counters = counters; optlen = sizeof(table->replace) - sizeof(table->replace.entrytable) + table->replace.size; if (setsockopt(fd, level, IPT_SO_SET_REPLACE, &table->replace, optlen)) exit(1); } close(fd); } static void checkpoint_arptables(void) { int fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (fd == -1) { switch (errno) { case EAFNOSUPPORT: case ENOPROTOOPT: return; } exit(1); } for (unsigned i = 0; i < sizeof(arpt_tables) / sizeof(arpt_tables[0]); i++) { struct arpt_table_desc* table = &arpt_tables[i]; strcpy(table->info.name, table->name); strcpy(table->replace.name, table->name); socklen_t optlen = sizeof(table->info); if (getsockopt(fd, SOL_IP, ARPT_SO_GET_INFO, &table->info, &optlen)) { switch (errno) { case EPERM: case ENOENT: case ENOPROTOOPT: continue; } exit(1); } if (table->info.size > sizeof(table->replace.entrytable)) exit(1); if (table->info.num_entries > XT_MAX_ENTRIES) exit(1); struct arpt_get_entries entries; memset(&entries, 0, sizeof(entries)); strcpy(entries.name, table->name); entries.size = table->info.size; optlen = sizeof(entries) - sizeof(entries.entrytable) + table->info.size; if (getsockopt(fd, SOL_IP, ARPT_SO_GET_ENTRIES, &entries, &optlen)) exit(1); table->replace.valid_hooks = table->info.valid_hooks; table->replace.num_entries = table->info.num_entries; table->replace.size = table->info.size; memcpy(table->replace.hook_entry, table->info.hook_entry, sizeof(table->replace.hook_entry)); memcpy(table->replace.underflow, table->info.underflow, sizeof(table->replace.underflow)); memcpy(table->replace.entrytable, entries.entrytable, table->info.size); } close(fd); } static void reset_arptables() { int fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (fd == -1) { switch (errno) { case EAFNOSUPPORT: case ENOPROTOOPT: return; } exit(1); } for (unsigned i = 0; i < sizeof(arpt_tables) / sizeof(arpt_tables[0]); i++) { struct arpt_table_desc* table = &arpt_tables[i]; if (table->info.valid_hooks == 0) continue; struct arpt_getinfo info; memset(&info, 0, sizeof(info)); strcpy(info.name, table->name); socklen_t optlen = sizeof(info); if (getsockopt(fd, SOL_IP, ARPT_SO_GET_INFO, &info, &optlen)) exit(1); if (memcmp(&table->info, &info, sizeof(table->info)) == 0) { struct arpt_get_entries entries; memset(&entries, 0, sizeof(entries)); strcpy(entries.name, table->name); entries.size = table->info.size; optlen = sizeof(entries) - sizeof(entries.entrytable) + entries.size; if (getsockopt(fd, SOL_IP, ARPT_SO_GET_ENTRIES, &entries, &optlen)) exit(1); if (memcmp(table->replace.entrytable, entries.entrytable, table->info.size) == 0) continue; } else { } struct xt_counters counters[XT_MAX_ENTRIES]; table->replace.num_counters = info.num_entries; table->replace.counters = counters; optlen = sizeof(table->replace) - sizeof(table->replace.entrytable) + table->replace.size; if (setsockopt(fd, SOL_IP, ARPT_SO_SET_REPLACE, &table->replace, optlen)) exit(1); } close(fd); } #define NF_BR_NUMHOOKS 6 #define EBT_TABLE_MAXNAMELEN 32 #define EBT_CHAIN_MAXNAMELEN 32 #define EBT_BASE_CTL 128 #define EBT_SO_SET_ENTRIES (EBT_BASE_CTL) #define EBT_SO_GET_INFO (EBT_BASE_CTL) #define EBT_SO_GET_ENTRIES (EBT_SO_GET_INFO + 1) #define EBT_SO_GET_INIT_INFO (EBT_SO_GET_ENTRIES + 1) #define EBT_SO_GET_INIT_ENTRIES (EBT_SO_GET_INIT_INFO + 1) struct ebt_replace { char name[EBT_TABLE_MAXNAMELEN]; unsigned int valid_hooks; unsigned int nentries; unsigned int entries_size; struct ebt_entries* hook_entry[NF_BR_NUMHOOKS]; unsigned int num_counters; struct ebt_counter* counters; char* entries; }; struct ebt_entries { unsigned int distinguisher; char name[EBT_CHAIN_MAXNAMELEN]; unsigned int counter_offset; int policy; unsigned int nentries; char data[0] __attribute__((aligned(__alignof__(struct ebt_replace)))); }; struct ebt_table_desc { const char* name; struct ebt_replace replace; char entrytable[XT_TABLE_SIZE]; }; static struct ebt_table_desc ebt_tables[] = { {.name = "filter"}, {.name = "nat"}, {.name = "broute"}, }; static void checkpoint_ebtables(void) { int fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (fd == -1) { switch (errno) { case EAFNOSUPPORT: case ENOPROTOOPT: return; } exit(1); } for (size_t i = 0; i < sizeof(ebt_tables) / sizeof(ebt_tables[0]); i++) { struct ebt_table_desc* table = &ebt_tables[i]; strcpy(table->replace.name, table->name); socklen_t optlen = sizeof(table->replace); if (getsockopt(fd, SOL_IP, EBT_SO_GET_INIT_INFO, &table->replace, &optlen)) { switch (errno) { case EPERM: case ENOENT: case ENOPROTOOPT: continue; } exit(1); } if (table->replace.entries_size > sizeof(table->entrytable)) exit(1); table->replace.num_counters = 0; table->replace.entries = table->entrytable; optlen = sizeof(table->replace) + table->replace.entries_size; if (getsockopt(fd, SOL_IP, EBT_SO_GET_INIT_ENTRIES, &table->replace, &optlen)) exit(1); } close(fd); } static void reset_ebtables() { int fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (fd == -1) { switch (errno) { case EAFNOSUPPORT: case ENOPROTOOPT: return; } exit(1); } for (unsigned i = 0; i < sizeof(ebt_tables) / sizeof(ebt_tables[0]); i++) { struct ebt_table_desc* table = &ebt_tables[i]; if (table->replace.valid_hooks == 0) continue; struct ebt_replace replace; memset(&replace, 0, sizeof(replace)); strcpy(replace.name, table->name); socklen_t optlen = sizeof(replace); if (getsockopt(fd, SOL_IP, EBT_SO_GET_INFO, &replace, &optlen)) exit(1); replace.num_counters = 0; table->replace.entries = 0; for (unsigned h = 0; h < NF_BR_NUMHOOKS; h++) table->replace.hook_entry[h] = 0; if (memcmp(&table->replace, &replace, sizeof(table->replace)) == 0) { char entrytable[XT_TABLE_SIZE]; memset(&entrytable, 0, sizeof(entrytable)); replace.entries = entrytable; optlen = sizeof(replace) + replace.entries_size; if (getsockopt(fd, SOL_IP, EBT_SO_GET_ENTRIES, &replace, &optlen)) exit(1); if (memcmp(table->entrytable, entrytable, replace.entries_size) == 0) continue; } for (unsigned j = 0, h = 0; h < NF_BR_NUMHOOKS; h++) { if (table->replace.valid_hooks & (1 << h)) { table->replace.hook_entry[h] = (struct ebt_entries*)table->entrytable + j; j++; } } table->replace.entries = table->entrytable; optlen = sizeof(table->replace) + table->replace.entries_size; if (setsockopt(fd, SOL_IP, EBT_SO_SET_ENTRIES, &table->replace, optlen)) exit(1); } close(fd); } static void checkpoint_net_namespace(void) { checkpoint_ebtables(); checkpoint_arptables(); checkpoint_iptables(ipv4_tables, sizeof(ipv4_tables) / sizeof(ipv4_tables[0]), AF_INET, SOL_IP); checkpoint_iptables(ipv6_tables, sizeof(ipv6_tables) / sizeof(ipv6_tables[0]), AF_INET6, SOL_IPV6); } static void reset_net_namespace(void) { reset_ebtables(); reset_arptables(); reset_iptables(ipv4_tables, sizeof(ipv4_tables) / sizeof(ipv4_tables[0]), AF_INET, SOL_IP); reset_iptables(ipv6_tables, sizeof(ipv6_tables) / sizeof(ipv6_tables[0]), AF_INET6, SOL_IPV6); } static void setup_cgroups() { if (mkdir("/syzcgroup", 0777)) { } if (mkdir("/syzcgroup/unified", 0777)) { } if (mount("none", "/syzcgroup/unified", "cgroup2", 0, NULL)) { } if (chmod("/syzcgroup/unified", 0777)) { } write_file("/syzcgroup/unified/cgroup.subtree_control", "+cpu +memory +io +pids +rdma"); if (mkdir("/syzcgroup/cpu", 0777)) { } if (mount("none", "/syzcgroup/cpu", "cgroup", 0, "cpuset,cpuacct,perf_event,hugetlb")) { } write_file("/syzcgroup/cpu/cgroup.clone_children", "1"); write_file("/syzcgroup/cpu/cpuset.memory_pressure_enabled", "1"); if (chmod("/syzcgroup/cpu", 0777)) { } if (mkdir("/syzcgroup/net", 0777)) { } if (mount("none", "/syzcgroup/net", "cgroup", 0, "net_cls,net_prio,devices,freezer")) { } if (chmod("/syzcgroup/net", 0777)) { } } static void setup_cgroups_loop() { int pid = getpid(); char file[128]; char cgroupdir[64]; snprintf(cgroupdir, sizeof(cgroupdir), "/syzcgroup/unified/syz%llu", procid); if (mkdir(cgroupdir, 0777)) { } snprintf(file, sizeof(file), "%s/pids.max", cgroupdir); write_file(file, "32"); snprintf(file, sizeof(file), "%s/memory.low", cgroupdir); write_file(file, "%d", 298 << 20); snprintf(file, sizeof(file), "%s/memory.high", cgroupdir); write_file(file, "%d", 299 << 20); snprintf(file, sizeof(file), "%s/memory.max", cgroupdir); write_file(file, "%d", 300 << 20); snprintf(file, sizeof(file), "%s/cgroup.procs", cgroupdir); write_file(file, "%d", pid); snprintf(cgroupdir, sizeof(cgroupdir), "/syzcgroup/cpu/syz%llu", procid); if (mkdir(cgroupdir, 0777)) { } snprintf(file, sizeof(file), "%s/cgroup.procs", cgroupdir); write_file(file, "%d", pid); snprintf(cgroupdir, sizeof(cgroupdir), "/syzcgroup/net/syz%llu", procid); if (mkdir(cgroupdir, 0777)) { } snprintf(file, sizeof(file), "%s/cgroup.procs", cgroupdir); write_file(file, "%d", pid); } static void setup_cgroups_test() { char cgroupdir[64]; snprintf(cgroupdir, sizeof(cgroupdir), "/syzcgroup/unified/syz%llu", procid); if (symlink(cgroupdir, "./cgroup")) { } snprintf(cgroupdir, sizeof(cgroupdir), "/syzcgroup/cpu/syz%llu", procid); if (symlink(cgroupdir, "./cgroup.cpu")) { } snprintf(cgroupdir, sizeof(cgroupdir), "/syzcgroup/net/syz%llu", procid); if (symlink(cgroupdir, "./cgroup.net")) { } } static void setup_common() { if (mount(0, "/sys/fs/fuse/connections", "fusectl", 0, 0)) { } setup_cgroups(); } static void loop(); static void sandbox_common() { prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); setsid(); struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = (200 << 20); setrlimit(RLIMIT_AS, &rlim); rlim.rlim_cur = rlim.rlim_max = 32 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 136 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); if (unshare(CLONE_NEWNS)) { } if (mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, NULL)) { } if (unshare(CLONE_NEWIPC)) { } if (unshare(0x02000000)) { } if (unshare(CLONE_NEWUTS)) { } if (unshare(CLONE_SYSVSEM)) { } typedef struct { const char* name; const char* value; } sysctl_t; static const sysctl_t sysctls[] = { {"/proc/sys/kernel/shmmax", "16777216"}, {"/proc/sys/kernel/shmall", "536870912"}, {"/proc/sys/kernel/shmmni", "1024"}, {"/proc/sys/kernel/msgmax", "8192"}, {"/proc/sys/kernel/msgmni", "1024"}, {"/proc/sys/kernel/msgmnb", "1024"}, {"/proc/sys/kernel/sem", "1024 1048576 500 1024"}, }; unsigned i; for (i = 0; i < sizeof(sysctls) / sizeof(sysctls[0]); i++) write_file(sysctls[i].name, sysctls[i].value); } static int wait_for_loop(int pid) { if (pid < 0) exit(1); int status = 0; while (waitpid(-1, &status, __WALL) != pid) { } return WEXITSTATUS(status); } static void drop_caps(void) { struct __user_cap_header_struct cap_hdr = {}; struct __user_cap_data_struct cap_data[2] = {}; cap_hdr.version = _LINUX_CAPABILITY_VERSION_3; cap_hdr.pid = getpid(); if (syscall(SYS_capget, &cap_hdr, &cap_data)) exit(1); const int drop = (1 << CAP_SYS_PTRACE) | (1 << CAP_SYS_NICE); cap_data[0].effective &= ~drop; cap_data[0].permitted &= ~drop; cap_data[0].inheritable &= ~drop; if (syscall(SYS_capset, &cap_hdr, &cap_data)) exit(1); } static int do_sandbox_none(void) { if (unshare(CLONE_NEWPID)) { } int pid = fork(); if (pid != 0) return wait_for_loop(pid); setup_common(); initialize_vhci(); sandbox_common(); drop_caps(); initialize_netdevices_init(); if (unshare(CLONE_NEWNET)) { } initialize_tun(); initialize_netdevices(); loop(); exit(1); } #define FS_IOC_SETFLAGS _IOW('f', 2, long) static void remove_dir(const char* dir) { int iter = 0; DIR* dp = 0; retry: while (umount2(dir, MNT_DETACH) == 0) { } dp = opendir(dir); if (dp == NULL) { if (errno == EMFILE) { exit(1); } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); while (umount2(filename, MNT_DETACH) == 0) { } struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } int i; for (i = 0;; i++) { if (unlink(filename) == 0) break; if (errno == EPERM) { int fd = open(filename, O_RDONLY); if (fd != -1) { long flags = 0; if (ioctl(fd, FS_IOC_SETFLAGS, &flags) == 0) { } close(fd); continue; } } if (errno == EROFS) { break; } if (errno != EBUSY || i > 100) exit(1); if (umount2(filename, MNT_DETACH)) exit(1); } } closedir(dp); for (int i = 0;; i++) { if (rmdir(dir) == 0) break; if (i < 100) { if (errno == EPERM) { int fd = open(dir, O_RDONLY); if (fd != -1) { long flags = 0; if (ioctl(fd, FS_IOC_SETFLAGS, &flags) == 0) { } close(fd); continue; } } if (errno == EROFS) { break; } if (errno == EBUSY) { if (umount2(dir, MNT_DETACH)) exit(1); continue; } if (errno == ENOTEMPTY) { if (iter < 100) { iter++; goto retry; } } } exit(1); } } static 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_loop() { setup_cgroups_loop(); checkpoint_net_namespace(); } static void reset_loop() { reset_net_namespace(); } static void setup_test() { prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); setpgrp(); setup_cgroups_test(); write_file("/proc/self/oom_score_adj", "1000"); flush_tun(); } static void close_fds() { for (int fd = 3; fd < MAX_FDS; fd++) close(fd); } static void setup_binfmt_misc() { if (mount(0, "/proc/sys/fs/binfmt_misc", "binfmt_misc", 0, 0)) { } write_file("/proc/sys/fs/binfmt_misc/register", ":syz0:M:0:\x01::./file0:"); write_file("/proc/sys/fs/binfmt_misc/register", ":syz1:M:1:\x02::./file0:POC"); } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { int i, call, thread; int collide = 0; again: for (call = 0; call < 3; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); if (collide && (call % 2) == 0) break; event_timedwait(&th->done, 50); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); close_fds(); if (!collide) { collide = 1; goto again; } } static void execute_one(void); #define WAIT_FLAGS __WALL static void loop(void) { setup_loop(); int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); reset_loop(); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); setup_test(); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5000) { continue; } kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } void execute_call(int call) { switch (call) { case 0: NONFAILING(*(uint8_t*)0x20000000 = 3); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x20000001, 1, 0, 7)); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x20000001, 1, 7, 1)); NONFAILING(*(uint32_t*)0x20000004 = 0); NONFAILING(*(uint32_t*)0x20000008 = 0); NONFAILING(*(uint64_t*)0x20000010 = 0x200001c0); NONFAILING(memcpy((void*)0x200001c0, "\xcf", 1)); NONFAILING(*(uint32_t*)0x20000018 = 1); NONFAILING(*(uint32_t*)0x2000001c = 0); NONFAILING(*(uint32_t*)0x20000020 = 0); NONFAILING(*(uint32_t*)0x20000024 = 0); NONFAILING(*(uint32_t*)0x20000028 = 0); NONFAILING(*(uint32_t*)0x2000002c = 0); NONFAILING(*(uint64_t*)0x20000030 = 0); syscall(__NR_ioctl, -1, 0x8038550a, 0x20000000ul); break; case 1: syscall(__NR_pread64, -1, 0x20000b40ul, 0xb2ul, 8ul); break; case 2: NONFAILING(syz_usbip_server_init(3)); 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); setup_binfmt_misc(); install_segv_handler(); for (procid = 0; procid < 6; procid++) { if (fork() == 0) { use_temporary_dir(); do_sandbox_none(); } } sleep(1000000); return 0; }
the_stack_data/494002.c
// C program calculating the sunrise and sunset for // the current date and a fixed location(latitude,longitude) // Note, twilight calculation gives insufficient accuracy of results // Jarmo Lammi 1999 - 2001 // Last update July 21st, 2001 #include <stdio.h> #include <math.h> #include <stdlib.h> #include <time.h> double pi = 3.14159; double degs; double rads; double L,g,daylen; double SunDia = 0.53; // Sunradius degrees double AirRefr = 34.0/60.0; // athmospheric refraction degrees // // Get the days to J2000 // h is UT in decimal hours // FNday only works between 1901 to 2099 - see Meeus chapter 7 double FNday (int y, int m, int d, float h) { long int luku = - 7 * (y + (m + 9)/12)/4 + 275*m/9 + d; // type casting necessary on PC DOS and TClite to avoid overflow luku+= (long int)y*367; return (double)luku - 730531.5 + h/24.0; }; // the function below returns an angle in the range // 0 to 2*pi double FNrange (double x) { double b = 0.5*x / pi; double a = 2.0*pi * (b - (long)(b)); if (a < 0) a = 2.0*pi + a; return a; }; // Calculating the hourangle // double f0(double lat, double declin) { double fo,dfo; // Correction: different sign at S HS dfo = rads*(0.5*SunDia + AirRefr); if (lat < 0.0) dfo = -dfo; fo = tan(declin + dfo) * tan(lat*rads); if (fo>0.99999) fo=1.0; // to avoid overflow // fo = asin(fo) + pi/2.0; return fo; }; // Calculating the hourangle for twilight times // double f1(double lat, double declin) { double fi,df1; // Correction: different sign at S HS df1 = rads * 6.0; if (lat < 0.0) df1 = -df1; fi = tan(declin + df1) * tan(lat*rads); if (fi>0.99999) fi=1.0; // to avoid overflow // fi = asin(fi) + pi/2.0; return fi; }; // Find the ecliptic longitude of the Sun double FNsun (double d) { // mean longitude of the Sun L = FNrange(280.461 * rads + .9856474 * rads * d); // mean anomaly of the Sun g = FNrange(357.528 * rads + .9856003 * rads * d); // Ecliptic longitude of the Sun return FNrange(L + 1.915 * rads * sin(g) + .02 * rads * sin(2 * g)); }; // Display decimal hours in hours and minutes void showhrmn(double dhr) { int hr,mn; hr=(int) dhr; mn = (dhr - (double) hr)*60; printf("%0d:%0d",hr,mn); }; int main(void){ double y,m,day,h,latit,longit; float inlat,inlon,intz; double tzone,d,lambda; double obliq,alpha,delta,LL,equation,ha,hb,twx; double twam,altmax,noont,settm,riset,twpm; time_t sekunnit; struct tm *p; degs = 180.0/pi; rads = pi/180.0; // get the date and time from the user // read system date and extract the year /** First get time **/ time(&sekunnit); /** Next get localtime **/ p=localtime(&sekunnit); y = p->tm_year; // this is Y2K compliant method y+= 1900; m = p->tm_mon + 1; day = p->tm_mday; h = 12; printf("year %4d month %2d\n",(int)y,(int)m); printf("Input latitude, longitude and timezone\n"); scanf("%f", &inlat); scanf("%f", &inlon); scanf("%f", &intz); latit = (double)inlat; longit = (double)inlon; tzone = (double)intz; // testing // m=6; day=10; d = FNday(y, m, day, h); // Use FNsun to find the ecliptic longitude of the // Sun lambda = FNsun(d); // Obliquity of the ecliptic obliq = 23.439 * rads - .0000004 * rads * d; // Find the RA and DEC of the Sun alpha = atan2(cos(obliq) * sin(lambda), cos(lambda)); delta = asin(sin(obliq) * sin(lambda)); // Find the Equation of Time // in minutes // Correction suggested by David Smith LL = L - alpha; if (L < pi) LL += 2.0*pi; equation = 1440.0 * (1.0 - LL / pi/2.0); ha = f0(latit,delta); hb = f1(latit,delta); twx = hb - ha; // length of twilight in radians twx = 12.0*twx/pi; // length of twilight in hours printf("ha= %.2f hb= %.2f \n",ha,hb); // Conversion of angle to hours and minutes // daylen = degs*ha/7.5; if (daylen<0.0001) {daylen = 0.0;} // arctic winter // riset = 12.0 - 12.0 * ha/pi + tzone - longit/15.0 + equation/60.0; settm = 12.0 + 12.0 * ha/pi + tzone - longit/15.0 + equation/60.0; noont = riset + 12.0 * ha/pi; altmax = 90.0 + delta * degs - latit; // Correction for S HS suggested by David Smith // to express altitude as degrees from the N horizon if (latit < delta * degs) altmax = 180.0 - altmax; twam = riset - twx; // morning twilight begin twpm = settm + twx; // evening twilight end if (riset > 24.0) riset-= 24.0; if (settm > 24.0) settm-= 24.0; puts("\n Sunrise and set"); puts("==============="); printf(" year : %d \n",(int)y); printf(" month : %d \n",(int)m); printf(" day : %d \n\n",(int)day); printf("Days since Y2K : %d \n",(int)d); printf("Latitude : %3.1f, longitude: %3.1f, timezone: %3.1f \n",(float)latit,(float)longit,(float)tzone); printf("Declination : %.2f \n",delta * degs); printf("Daylength : "); showhrmn(daylen); puts(" hours \n"); printf("Civil twilight: "); showhrmn(twam); puts(""); printf("Sunrise : "); showhrmn(riset); puts(""); printf("Sun altitude "); // Amendment by D. Smith printf(" %.2f degr",altmax); printf(latit>=0.0 ? " South" : " North"); printf(" at noontime "); showhrmn(noont); puts(""); printf("Sunset : "); showhrmn(settm); puts(""); printf("Civil twilight: "); showhrmn(twpm); puts("\n"); return 0; }
the_stack_data/15162.c
/******************************************************************************* * Copyright (c) 2008, 2013 IBM Corp. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * and Eclipse Distribution License v1.0 which accompany this distribution. * * The Eclipse Public License is available at * http://www.eclipse.org/legal/epl-v10.html * and the Eclipse Distribution License is available at * http://www.eclipse.org/org/documents/edl-v10.php. * * Contributors: * Nicholas O'Leary, Ian Craggs - initial API and implementation and/or initial documentation *******************************************************************************/ #if defined(MQTTS) #include "MQTTSPacket.h" #include "Log.h" #include "Clients.h" #include "Messages.h" #include "Protocol.h" #include "Socket.h" #include "StackTrace.h" #include <stdlib.h> #include <string.h> #include "Heap.h" static char* packet_names[] = { "ADVERTISE", "SEARCHGW", "GWINFO", "RESERVED", "CONNECT", "CONNACK", "WILLTOPICREQ", "WILLTOPIC", "WILLMSGREQ", "WILLMSG", "REGISTER", "REGACK", "PUBLISH", "PUBACK", "PUBCOMP", "PUBREC", "PUBREL", "RESERVED", "SUBSCRIBE", "SUBACK", "UNSUBSCRIBE", "UNSUBACK", "PINGREQ", "PINGRESP", "DISCONNECT", "RESERVED", "WILLTOPICUPD", "WILLTOPICRESP", "WILLMSGUPD", "WILLMSGRESP" }; typedef void* (*mqtts_pf)(MQTTSHeader, char*); typedef void (*mqtts_fpf)(void *); static mqtts_pf new_mqtts_packets[] = { MQTTSPacket_advertise, /* ADVERTISE */ MQTTSPacket_searchGw, /* SEARCHGW */ MQTTSPacket_gwInfo, /* GWINFO */ NULL, /* RESERVED */ MQTTSPacket_connect, /* CONNECT */ MQTTSPacket_connack, /* CONNACK */ MQTTSPacket_header_only, /* WILLTOPICREQ */ MQTTSPacket_willTopic, /* WILLTOPIC */ MQTTSPacket_header_only, /* WILLMSGREQ */ MQTTSPacket_willMsg, /* WILLMSG */ MQTTSPacket_register, /* REGISTER */ MQTTSPacket_ack_with_reasoncode, /* REGACK */ MQTTSPacket_publish, /* PUBLISH */ MQTTSPacket_ack_with_reasoncode, /* PUBACK */ MQTTSPacket_header_with_msgId, /* PUBCOMP */ MQTTSPacket_header_with_msgId, /* PUBREC */ MQTTSPacket_header_with_msgId, /* PUBREL */ NULL, /* RESERVED */ MQTTSPacket_subscribe, /* SUBSCRIBE */ MQTTSPacket_suback, /* SUBACK */ MQTTSPacket_subscribe, /* UNSUBSCRIBE */ MQTTSPacket_header_with_msgId, /* UNSUBACK */ MQTTSPacket_pingreq, /* PINGREQ */ MQTTSPacket_header_only, /* PINGRESP */ MQTTSPacket_disconnect, /* DISCONNECT */ NULL, /* RESERVED */ MQTTSPacket_willTopicUpd, /* WILLTOPICUPD */ MQTTSPacket_header_only, /* WILLTOPICRESP */ MQTTSPacket_willMsgUpd, /* WILLMSGUPD */ MQTTSPacket_header_only /* WILLMSGRESP */ }; static mqtts_fpf free_mqtts_packets[] = { NULL, /* ADVERTISE */ NULL, /* SEARCHGW */ MQTTSPacket_free_gwInfo, /* GWINFO *** */ NULL, /* RESERVED */ MQTTSPacket_free_connect, /* CONNECT *** */ NULL, /* CONNACK */ NULL, /* WILLTOPICREQ */ MQTTSPacket_free_willTopic, /* WILLTOPIC *** */ NULL, /* WILLMSGREQ */ MQTTSPacket_free_willMsg, /* WILLMSG *** */ MQTTSPacket_free_register, /* REGISTER *** */ NULL, /* REGACK */ MQTTSPacket_free_publish, /* PUBLISH *** */ NULL, /* PUBACK */ NULL, /* PUBCOMP */ NULL, /* PUBREC */ NULL, /* PUBREL */ NULL, /* RESERVED */ MQTTSPacket_free_subscribe, /* SUBSCRIBE *** */ NULL, /* SUBACK */ MQTTSPacket_free_subscribe, /* UNSUBSCRIBE *** */ NULL, /* UNSUBACK */ MQTTSPacket_free_pingreq, /* PINGREQ *** */ NULL, /* PINGRESP */ NULL, /* DISCONNECT */ NULL, /* RESERVED */ MQTTSPacket_free_willTopicUpd, /* WILLTOPICUPD *** */ NULL, /* WILLTOPICRESP */ MQTTSPacket_free_willMsgUpd, /* WILLMSGUPD *** */ NULL /* WILLMSGRESP */ }; char* MQTTSPacket_name(int ptype) { return (ptype >= 0 && ptype <= MQTTS_WILLMSGRESP) ? packet_names[ptype] : "UNKNOWN"; } void* MQTTSPacket_Factory(int sock, char** clientAddr, int* error) { char* data = NULL; static MQTTSHeader header; int ptype; void* pack = NULL; struct sockaddr_in cliAddr; int n; char msg[512]; socklen_t len = sizeof(cliAddr); FUNC_ENTRY; /* #if !defined(NO_BRIDGE) client = Protocol_getoutboundclient(sock); FUNC_ENTRY; if (client!=NULL) n = recv(sock,msg,512,0); else #endif */ n = recvfrom(sock, msg, 512, 0, (struct sockaddr *)&cliAddr, &len ); if (n == SOCKET_ERROR) { int en = Socket_error("udp read error",sock); if (en == EINVAL) Log(LOG_WARNING, 0, "EINVAL"); *error = SOCKET_ERROR; goto exit; } *clientAddr = Socket_getaddrname((struct sockaddr *)&cliAddr, sock); /* printf("%d bytes of data on socket %d from %s\n",n,sock,*clientAddr); if (n>0) { for (i=0;i<n;i++) { printf("%d ",msg[i]); } printf("\n"); } */ *error = SOCKET_ERROR; // indicate whether an error occurred, or not if (n < 2) goto exit; header.len = msg[0]; header.type = msg[1]; data = &(msg[2]); if (header.len != n) { *error = UDPSOCKET_INCOMPLETE; goto exit; } else { ptype = header.type; if (ptype < MQTTS_ADVERTISE || ptype > MQTTS_WILLMSGRESP || new_mqtts_packets[ptype] == NULL) Log(TRACE_MAX, 17, NULL, ptype); else { if ((pack = (*new_mqtts_packets[ptype])(header, data)) == NULL) { *error = BAD_MQTTS_PACKET; } } } exit: FUNC_EXIT_RC(*error); return pack; } void* MQTTSPacket_header_only(MQTTSHeader header, char* data) { MQTTS_Header* pack = NULL; FUNC_ENTRY; if (header.len != 2) goto exit; pack = malloc(sizeof(MQTTS_Header)); pack->header = header; exit: FUNC_EXIT; return pack; } void* MQTTSPacket_header_with_msgId(MQTTSHeader header, char* data) { MQTTS_Header_MsgId* pack = NULL; char* curdata = data; FUNC_ENTRY; if (header.len != 4) goto exit; pack = malloc(sizeof(MQTTS_Header_MsgId)); pack->header = header; pack->msgId = readInt(&curdata); exit: FUNC_EXIT; return pack; } void* MQTTSPacket_ack_with_reasoncode(MQTTSHeader header, char* data) { MQTTS_Ack* pack = NULL; char* curdata = data; FUNC_ENTRY; if (header.len != 7) goto exit; pack = malloc(sizeof(MQTTS_Ack)); pack->header = header; pack->topicId = readInt(&curdata); pack->msgId = readInt(&curdata); pack->returnCode = readChar(&curdata); exit: FUNC_EXIT; return pack; } void* MQTTSPacket_advertise(MQTTSHeader header, char* data) { MQTTS_Advertise* pack = malloc(sizeof(MQTTS_Advertise)); char* curdata = data; FUNC_ENTRY; pack->header = header; pack->gwId = readChar(&curdata); pack->duration = readInt(&curdata); FUNC_EXIT; return pack; } void* MQTTSPacket_searchGw(MQTTSHeader header, char* data) { MQTTS_SearchGW* pack = malloc(sizeof(MQTTS_SearchGW)); char* curdata = data; FUNC_ENTRY; pack->header = header; pack->radius = readChar(&curdata); FUNC_EXIT; return pack; } void* MQTTSPacket_gwInfo(MQTTSHeader header, char* data) { MQTTS_GWInfo* pack = malloc(sizeof(MQTTS_GWInfo)); char* curdata = data; FUNC_ENTRY; pack->header = header; pack->gwId = readChar(&curdata); if (header.len > 3) { pack->gwAdd = malloc(header.len-2); memcpy(pack->gwAdd, curdata, header.len-3); pack->gwAdd[header.len-3] = '\0'; } else { pack->gwAdd = 0; } FUNC_EXIT; return pack; } void* MQTTSPacket_connect(MQTTSHeader header, char* data) { MQTTS_Connect* pack = malloc(sizeof(MQTTS_Connect)); char* curdata = data; FUNC_ENTRY; pack->header = header; pack->flags.all = readChar(&curdata); pack->protocolID = readChar(&curdata); pack->keepAlive = readInt(&curdata); pack->clientID = malloc(header.len-5); memcpy(pack->clientID, curdata, header.len-6); pack->clientID[header.len-6] = '\0'; FUNC_EXIT; return pack; } void* MQTTSPacket_connack(MQTTSHeader header, char* data) { MQTTS_Connack* pack = malloc(sizeof(MQTTS_Connack)); char* curdata = data; FUNC_ENTRY; pack->header = header; pack->returnCode = readChar(&curdata); FUNC_EXIT; return pack; } void* MQTTSPacket_willTopic(MQTTSHeader header, char* data) { MQTTS_WillTopic* pack = malloc(sizeof(MQTTS_WillTopic)); char* curdata = data; FUNC_ENTRY; pack->header = header; pack->flags.all = readChar(&curdata); pack->willTopic = malloc(header.len-2); memcpy(pack->willTopic, curdata, header.len-3); pack->willTopic[header.len-3] = '\0'; FUNC_EXIT; return pack; } void* MQTTSPacket_willMsg(MQTTSHeader header, char* data) { MQTTS_WillMsg* pack = malloc(sizeof(MQTTS_WillMsg)); char* curdata = data; FUNC_ENTRY; pack->header = header; pack->willMsg = malloc(header.len-1); memcpy(pack->willMsg, curdata, header.len-2); pack->willMsg[header.len-2] = '\0'; FUNC_EXIT; return pack; } void* MQTTSPacket_register(MQTTSHeader header, char* data) { MQTTS_Register* pack = malloc(sizeof(MQTTS_Register)); char* curdata = data; FUNC_ENTRY; pack->header = header; pack->topicId = readInt(&curdata); pack->msgId = readInt(&curdata); pack->topicName = malloc(header.len-5); memcpy(pack->topicName, curdata, header.len-6); pack->topicName[header.len-6] = '\0'; FUNC_EXIT; return pack; } void* MQTTSPacket_publish(MQTTSHeader header, char* data) { MQTTS_Publish* pack = malloc(sizeof(MQTTS_Publish)); char* curdata = data; FUNC_ENTRY; pack->header = header; pack->flags.all = readChar(&curdata); if (pack->flags.topicIdType == MQTTS_TOPIC_TYPE_SHORT) { char* st = malloc(3); st[0] = readChar(&curdata); st[1] = readChar(&curdata); st[2] = '\0'; pack->topicId = 0; pack->shortTopic = st; } else { pack->topicId = readInt(&curdata); pack->shortTopic = NULL; } pack->msgId = readInt(&curdata); pack->data = malloc(header.len - 7); memcpy(pack->data, curdata, header.len - 7); pack->dataLen = header.len - 7; FUNC_EXIT; return pack; } void* MQTTSPacket_subscribe(MQTTSHeader header, char* data) { MQTTS_Subscribe* pack = malloc(sizeof(MQTTS_Subscribe)); char* curdata = data; FUNC_ENTRY; pack->header = header; pack->flags.all = readChar(&curdata); pack->msgId = readInt(&curdata); if (pack->flags.topicIdType == 0x01) { pack->topicId = readInt(&curdata); pack->topicName = NULL; } else { pack->topicId = 0; pack->topicName = malloc(header.len-4); memcpy(pack->topicName, curdata, header.len-5); pack->topicName[header.len-5] = '\0'; } FUNC_EXIT; return pack; } void* MQTTSPacket_suback(MQTTSHeader header, char* data) { MQTTS_SubAck* pack = malloc(sizeof(MQTTS_SubAck)); char* curdata = data; FUNC_ENTRY; pack->header = header; pack->flags.all = readChar(&curdata); pack->topicId = readInt(&curdata); pack->msgId = readInt(&curdata); pack->returnCode = readChar(&curdata); FUNC_EXIT; return pack; } void* MQTTSPacket_pingreq(MQTTSHeader header, char* data) { MQTTS_PingReq* pack = malloc(sizeof(MQTTS_PingReq)); char* curdata = data; FUNC_ENTRY; pack->header = header; if (header.len > 2) { pack->clientId = malloc(header.len - 1); memcpy(pack->clientId, curdata, header.len - 2); pack->clientId[header.len-2] = '\0'; } else pack->clientId = NULL; FUNC_EXIT; return pack; } void* MQTTSPacket_disconnect(MQTTSHeader header, char* data) { MQTTS_Disconnect* pack = malloc(sizeof(MQTTS_Disconnect)); char* curdata = data; FUNC_ENTRY; pack->header = header; if (header.len > 2) pack->duration = readInt(&curdata); FUNC_EXIT; return pack; } void* MQTTSPacket_willTopicUpd(MQTTSHeader header, char* data) { MQTTS_WillTopicUpd* pack = malloc(sizeof(MQTTS_WillTopicUpd)); char* curdata = data; FUNC_ENTRY; pack->header = header; if (header.len > 2) { pack->flags.all = readChar(&curdata); pack->willTopic = malloc(header.len - 2); memcpy(pack->willTopic, curdata, header.len - 3); pack->willTopic[header.len-3] = '\0'; } else { pack->flags.all = 0; pack->willTopic = NULL; } FUNC_EXIT; return pack; } void* MQTTSPacket_willMsgUpd(MQTTSHeader header, char* data) { MQTTS_WillMsgUpd* pack = malloc(sizeof(MQTTS_WillMsgUpd)); char* curdata = data; FUNC_ENTRY; pack->header = header; pack->willMsg = malloc(header.len - 1); memcpy(pack->willMsg, curdata, header.len - 2); pack->willMsg[header.len-2] = '\0'; FUNC_EXIT; return pack; } void MQTTSPacket_free_packet(MQTTS_Header* pack) { FUNC_ENTRY; if (free_mqtts_packets[(int)pack->header.type] != NULL) (*free_mqtts_packets[(int)pack->header.type])(pack); free(pack); FUNC_EXIT; } void MQTTSPacket_free_gwInfo(void* pack) { MQTTS_GWInfo* gwi = (MQTTS_GWInfo*)pack; FUNC_ENTRY; if (gwi->gwAdd != NULL) free(gwi->gwAdd); FUNC_EXIT; } void MQTTSPacket_free_connect(void* pack) { MQTTS_Connect* con = (MQTTS_Connect*)pack; FUNC_ENTRY; if (con->clientID != NULL) free(con->clientID); FUNC_EXIT; } void MQTTSPacket_free_willTopic(void* pack) { MQTTS_WillTopic* wt = (MQTTS_WillTopic*)pack; FUNC_ENTRY; if (wt->willTopic != NULL) free(wt->willTopic); FUNC_EXIT; } void MQTTSPacket_free_willMsg(void* pack) { MQTTS_WillMsg* wm = (MQTTS_WillMsg*)pack; FUNC_ENTRY; if (wm->willMsg != NULL) free(wm->willMsg); FUNC_EXIT; } void MQTTSPacket_free_register(void* pack) { MQTTS_Register* reg = (MQTTS_Register*)pack; FUNC_ENTRY; if (reg->topicName != NULL) free(reg->topicName); FUNC_EXIT; } void MQTTSPacket_free_publish(void* pack) { MQTTS_Publish* pub = (MQTTS_Publish*)pack; FUNC_ENTRY; if (pub->data != NULL) free(pub->data); if (pub->shortTopic != NULL) free(pub->shortTopic); FUNC_EXIT; } void MQTTSPacket_free_subscribe(void* pack) { MQTTS_Subscribe* sub = (MQTTS_Subscribe*)pack; FUNC_ENTRY; if (sub->topicName != NULL) { free(sub->topicName); } FUNC_EXIT; } void MQTTSPacket_free_pingreq(void* pack) { MQTTS_PingReq* ping = (MQTTS_PingReq*)pack; FUNC_ENTRY; if (ping->clientId != NULL) free(ping->clientId); FUNC_EXIT; } void MQTTSPacket_free_willTopicUpd(void* pack) { MQTTS_WillTopicUpd* wtu = (MQTTS_WillTopicUpd*)pack; FUNC_ENTRY; if (wtu->willTopic != NULL) free(wtu->willTopic); FUNC_EXIT; } void MQTTSPacket_free_willMsgUpd(void* pack) { MQTTS_WillMsgUpd* wmu = (MQTTS_WillMsgUpd*)pack; FUNC_ENTRY; if (wmu->willMsg != NULL) free(wmu->willMsg); FUNC_EXIT; } int MQTTSPacket_send(int socket, char* addr, MQTTSHeader header, char* buffer, int buflen) { struct sockaddr_in cliaddr; int rc = 0; char *p; char *tmpAddr = malloc(strlen(addr)); char *data = malloc(buflen+2); FUNC_ENTRY; data[0] = header.len; data[1] = header.type; memcpy(&(data[2]),buffer,buflen); strcpy(tmpAddr,addr); p = strtok(tmpAddr,":"); memset(&cliaddr, 0, sizeof(cliaddr)); cliaddr.sin_family = AF_INET; cliaddr.sin_addr.s_addr = inet_addr(p); cliaddr.sin_port = htons(atoi(strtok(NULL,":"))); /* #if !defined(NO_BRIDGE) client = Protocol_getoutboundclient(socket); FUNC_ENTRY; if (client != NULL) { rc = send(socket,data,buflen+2,0); printf("send returned %d\n",rc); } else # endif */ rc = sendto(socket,data,buflen+2,0,(const struct sockaddr*)&cliaddr,sizeof(cliaddr)); if (rc == SOCKET_ERROR) { Socket_error("sendto", socket); /* if (err == EWOULDBLOCK || err == EAGAIN) rc = TCPSOCKET_INTERRUPTED; */ } else { rc = 0; } /* printf("Send to %s on socket %d\n",addr,socket); printf("%u:",header.len); printf("%u",header.type); if (buffer != NULL) { for (i=0;i<buflen;i++) { printf(":%u",buffer[i]); } } printf("\n"); */ free(tmpAddr); free(data); /* buf = malloc(10); buf[0] = header.byte; rc = 1 + MQTTPacket_encode(&buf[1], buflen); rc = Socket_putdatas(socket, buf, rc, 1, &buffer, &buflen); if (rc != TCPSOCKET_INTERRUPTED) free(buf); */ FUNC_EXIT_RC(rc); return rc; } int MQTTSPacket_send_ack(Clients* client, char type) { MQTTS_Header packet; int rc = 0; FUNC_ENTRY; packet.header.len = 2; packet.header.type = type; rc = MQTTSPacket_send(client->socket, client->addr, packet.header, NULL, 0); FUNC_EXIT_RC(rc); return rc; } int MQTTSPacket_send_ack_with_msgId(Clients* client, char type, int msgId) { int rc = 0; char *buf, *ptr; MQTTS_Header_MsgId packet; FUNC_ENTRY; packet.header.len = 4; packet.header.type = type; ptr = buf = malloc(2); writeInt(&ptr,msgId); rc = MQTTSPacket_send(client->socket,client->addr, packet.header, buf,2); free(buf); FUNC_EXIT_RC(rc); return rc; } int MQTTSPacket_send_connack(Clients* client, int returnCode) { int rc = 0; MQTTS_Connack packet; FUNC_ENTRY; packet.header.len = 3; packet.header.type = MQTTS_CONNACK; packet.returnCode = returnCode; rc = MQTTSPacket_send(client->socket, client->addr, packet.header, &(packet.returnCode), 1); FUNC_EXIT; return rc; } int MQTTSPacket_send_willTopicReq(Clients* client) { return MQTTSPacket_send_ack(client,MQTTS_WILLTOPICREQ); } int MQTTSPacket_send_willMsgReq(Clients* client) { return MQTTSPacket_send_ack(client,MQTTS_WILLMSGREQ); } int MQTTSPacket_send_pingResp(Clients* client) { return MQTTSPacket_send_ack(client,MQTTS_PINGRESP); } int MQTTSPacket_send_willTopicResp(Clients* client) { return MQTTSPacket_send_ack(client,MQTTS_WILLTOPICRESP); } int MQTTSPacket_send_willMsgResp(Clients* client) { return MQTTSPacket_send_ack(client,MQTTS_WILLMSGRESP); } int MQTTSPacket_send_regAck(Clients* client, int msgId, int topicId, char returnCode) { MQTTS_RegAck packet; int rc = 0; char *buf, *ptr; int datalen = 5; FUNC_ENTRY; packet.header.len = 7; packet.header.type = MQTTS_REGACK; ptr = buf = malloc(datalen); writeInt(&ptr, topicId); writeInt(&ptr, msgId); writeChar(&ptr, returnCode); rc = MQTTSPacket_send(client->socket, client->addr, packet.header, buf, datalen); free(buf); FUNC_EXIT_RC(rc); return rc; } int MQTTSPacket_send_subAck(Clients* client, MQTTS_Subscribe* sub, int topicId, int qos, char returnCode) { MQTTS_SubAck packet; int rc = 0; char *buf, *ptr; int datalen = 6; FUNC_ENTRY; packet.header.len = 8; packet.header.type = MQTTS_SUBACK; ptr = buf = malloc(datalen); packet.flags.QoS = qos; writeChar(&ptr,packet.flags.all); writeInt(&ptr,topicId); writeInt(&ptr,sub->msgId); writeChar(&ptr,returnCode); rc = MQTTSPacket_send(client->socket, client->addr, packet.header, buf, datalen); free(buf); FUNC_EXIT_RC(rc); return rc; } int MQTTSPacket_send_unsubAck(Clients* client, int msgId) { MQTTS_UnsubAck packet; int rc = 0; char *buf, *ptr; FUNC_ENTRY; packet.header.len = 4; packet.header.type = MQTTS_UNSUBACK; ptr = buf = malloc(2); writeInt(&ptr,msgId); rc = MQTTSPacket_send(client->socket, client->addr, packet.header, buf, 2); free(buf); FUNC_EXIT_RC(rc); return rc; } int MQTTSPacket_send_publish(Clients* client, MQTTS_Publish* pub) { int rc = 0; char *buf, *ptr; int datalen = 5 + pub->dataLen; FUNC_ENTRY; ptr = buf = malloc(datalen); writeChar(&ptr,pub->flags.all); if (pub->flags.topicIdType == MQTTS_TOPIC_TYPE_SHORT) { writeChar(&ptr,pub->shortTopic[0]); writeChar(&ptr,pub->shortTopic[1]); } else writeInt(&ptr,pub->topicId); writeInt(&ptr,pub->msgId); memcpy(ptr,pub->data,pub->dataLen); rc = MQTTSPacket_send(client->socket, client->addr, pub->header, buf, datalen); free(buf); FUNC_EXIT_RC(rc); return rc; } int MQTTSPacket_send_puback(Clients* client, MQTTS_Publish* publish, char returnCode) { MQTTS_PubAck packet; char *buf, *ptr; int rc = 0; int datalen = 5; FUNC_ENTRY; packet.header.len = 7; packet.header.type = MQTTS_PUBACK; ptr = buf = malloc(datalen); if ( publish->flags.topicIdType == MQTTS_TOPIC_TYPE_SHORT) { writeChar(&ptr,publish->shortTopic[0]); writeChar(&ptr,publish->shortTopic[1]); } else { writeInt(&ptr,publish->topicId); } writeInt(&ptr, publish->msgId); writeChar(&ptr, returnCode); rc = MQTTSPacket_send(client->socket, client->addr, packet.header, buf, datalen); free(buf); FUNC_EXIT_RC(rc); return rc; } int MQTTSPacket_send_pubrec(Clients* client, int msgId) { return MQTTSPacket_send_ack_with_msgId(client, MQTTS_PUBREC, msgId); } int MQTTSPacket_send_pubrel(Clients* client, int msgId) { return MQTTSPacket_send_ack_with_msgId(client, MQTTS_PUBREL, msgId); } int MQTTSPacket_send_pubcomp(Clients* client, int msgId) { return MQTTSPacket_send_ack_with_msgId(client, MQTTS_PUBCOMP, msgId); } int MQTTSPacket_send_register(Clients* client, int topicId, char* topicName, int msgId) { MQTTS_Register packet; int rc = 0; char *buf, *ptr; int datalen = 4 + strlen(topicName); FUNC_ENTRY; packet.header.len = datalen+2; packet.header.type = MQTTS_REGISTER; ptr = buf = malloc(datalen); writeInt(&ptr,topicId); writeInt(&ptr,msgId); memcpy(ptr,topicName,strlen(topicName)); rc = MQTTSPacket_send(client->socket, client->addr, packet.header, buf, datalen); free(buf); FUNC_EXIT_RC(rc); return rc; } /****************************************************************/ /* client/bridge specific sends */ /****************************************************************/ int MQTTSPacket_send_connect(Clients* client) { char *buf, *ptr; MQTTS_Connect packet; int rc, len; FUNC_ENTRY; len = 4 + strlen(client->clientID); ptr = buf = malloc(len); packet.header.type = MQTTS_CONNECT; packet.header.len = len+2; packet.flags.all = 0; packet.flags.cleanSession = client->cleansession; packet.flags.will = (client->will) ? 1 : 0; writeChar(&ptr, packet.flags.all); writeChar(&ptr, 0x01); writeInt(&ptr, client->keepAliveInterval); memcpy(ptr, client->clientID, len-4); rc = MQTTSPacket_send(client->socket, client->addr, packet.header, buf, len); free(buf); FUNC_EXIT_RC(rc); return rc; } int MQTTSPacket_send_willTopic(Clients* client) { char *buf, *ptr; MQTTS_WillTopic packet; int rc, len; FUNC_ENTRY; len = 1 + strlen(client->will->topic); ptr = buf = malloc(len); packet.header.type = MQTTS_WILLTOPIC; packet.header.len = len+2; packet.flags.all = 0; packet.flags.QoS = client->will->qos; packet.flags.retain = client->will->retained; writeChar(&ptr, packet.flags.all); memcpy(ptr, client->will->topic, len-1); rc = MQTTSPacket_send(client->socket, client->addr, packet.header, buf, len); free(buf); FUNC_EXIT_RC(rc); return rc; } int MQTTSPacket_send_willMsg(Clients* client) { char *buf, *ptr; MQTTS_WillMsg packet; int rc, len; FUNC_ENTRY; len = strlen(client->will->msg); ptr = buf = malloc(len); packet.header.type = MQTTS_WILLMSG; packet.header.len = len+2; memcpy(ptr, client->will->msg, len); rc = MQTTSPacket_send(client->socket, client->addr, packet.header, buf, len); free(buf); FUNC_EXIT_RC(rc); return rc; } int MQTTSPacket_send_pingReq(Clients* client) { return MQTTSPacket_send_ack(client,MQTTS_PINGREQ); } int MQTTSPacket_send_disconnect(Clients* client, int duration) { int rc = 0; FUNC_ENTRY; if (duration == 0) rc = MQTTSPacket_send_ack(client,MQTTS_DISCONNECT); /* TODO: when support for sleeping clients is added, need to handle duration > 0 */ FUNC_EXIT_RC(rc); return rc; } int MQTTSPacket_send_subscribe(Clients* client, char* topicName, int qos, int msgId) { MQTTS_Subscribe packet; int rc = 0; char *buf, *ptr; int datalen = 3 + strlen(topicName); FUNC_ENTRY; packet.header.len = datalen+2; packet.header.type = MQTTS_SUBSCRIBE; /* TODO: support TOPIC_TYPE_PREDEFINED/TOPIC_TYPE_SHORT */ packet.flags.all = 0; packet.flags.topicIdType = MQTTS_TOPIC_TYPE_NORMAL; packet.flags.QoS = qos; ptr = buf = malloc(datalen); writeChar(&ptr,packet.flags.all); writeInt(&ptr,msgId); memcpy(ptr,topicName,strlen(topicName)); rc = MQTTSPacket_send(client->socket, client->addr, packet.header, buf, datalen); free(buf); FUNC_EXIT_RC(rc); return rc; } #if defined(MQTTSPACKET_TEST) int main(int argc, char *argv[]) { HeapScan(); MQTTS_Publish* pack = malloc(sizeof(MQTTS_Publish)); pack->header.type = MQTTS_PUBLISH; pack->data = malloc(10); MQTTSPacket_free_packet((MQTTS_Header*)pack); Clients* client = malloc(sizeof(Clients)); client->cleansession = 1; client->clientID = "a"; client->keepAliveInterval = 15; /* MQTTSPacket_send_connect(client); */ /* 7:4:4:1:0:15:97 */ free(client); Heap_terminate(); return 0; } #endif #endif
the_stack_data/89200329.c
extern void __VERIFIER_error() __attribute__ ((__noreturn__)); void __VERIFIER_assert(int cond) { if(!(cond)) { ERROR: __VERIFIER_error(); } } #define N 25 int main ( ) { int a[N]; int b[N]; int i = 0; while ( i < N ) { if ( a[i] >= 0 ) b[i] = 1; else b[i] = 0; i = i + 1; } int f = 1; i = 0; while ( i < N ) { if ( a[i] >= 0 && !b[i] ) f = 0; if ( a[i] < 0 && !b[i] ) f = 0; i = i + 1; } __VERIFIER_assert ( f ); return 0; }
the_stack_data/32624.c
#include "unistd.h" #include "string.h" int main(void) { char buf1[] = "asdfasdf"; char buf2[9]; char *f; /* This should return a pointer to buf1[4] or 'a' */ f = memccpy(buf2, buf1, 'f', 4); return 0; }
the_stack_data/75137625.c
//@ ltl invariant negative: (X (<> ([] (X AP(x_14 - x_15 > 1))))); float x_0; float x_1; float x_2; float x_3; float x_4; float x_5; float x_6; float x_7; float x_8; float x_9; float x_10; float x_11; float x_12; float x_13; float x_14; float x_15; float x_16; float x_17; float x_18; float x_19; float x_20; float x_21; float x_22; float x_23; int main() { float x_0_; float x_1_; float x_2_; float x_3_; float x_4_; float x_5_; float x_6_; float x_7_; float x_8_; float x_9_; float x_10_; float x_11_; float x_12_; float x_13_; float x_14_; float x_15_; float x_16_; float x_17_; float x_18_; float x_19_; float x_20_; float x_21_; float x_22_; float x_23_; while(1) { x_0_ = ((((19.0 + x_0) > ((16.0 + x_1) > (13.0 + x_2)? (16.0 + x_1) : (13.0 + x_2))? (19.0 + x_0) : ((16.0 + x_1) > (13.0 + x_2)? (16.0 + x_1) : (13.0 + x_2))) > ((3.0 + x_5) > ((4.0 + x_12) > (10.0 + x_13)? (4.0 + x_12) : (10.0 + x_13))? (3.0 + x_5) : ((4.0 + x_12) > (10.0 + x_13)? (4.0 + x_12) : (10.0 + x_13)))? ((19.0 + x_0) > ((16.0 + x_1) > (13.0 + x_2)? (16.0 + x_1) : (13.0 + x_2))? (19.0 + x_0) : ((16.0 + x_1) > (13.0 + x_2)? (16.0 + x_1) : (13.0 + x_2))) : ((3.0 + x_5) > ((4.0 + x_12) > (10.0 + x_13)? (4.0 + x_12) : (10.0 + x_13))? (3.0 + x_5) : ((4.0 + x_12) > (10.0 + x_13)? (4.0 + x_12) : (10.0 + x_13)))) > (((17.0 + x_14) > ((2.0 + x_15) > (20.0 + x_17)? (2.0 + x_15) : (20.0 + x_17))? (17.0 + x_14) : ((2.0 + x_15) > (20.0 + x_17)? (2.0 + x_15) : (20.0 + x_17))) > ((10.0 + x_21) > ((18.0 + x_22) > (11.0 + x_23)? (18.0 + x_22) : (11.0 + x_23))? (10.0 + x_21) : ((18.0 + x_22) > (11.0 + x_23)? (18.0 + x_22) : (11.0 + x_23)))? ((17.0 + x_14) > ((2.0 + x_15) > (20.0 + x_17)? (2.0 + x_15) : (20.0 + x_17))? (17.0 + x_14) : ((2.0 + x_15) > (20.0 + x_17)? (2.0 + x_15) : (20.0 + x_17))) : ((10.0 + x_21) > ((18.0 + x_22) > (11.0 + x_23)? (18.0 + x_22) : (11.0 + x_23))? (10.0 + x_21) : ((18.0 + x_22) > (11.0 + x_23)? (18.0 + x_22) : (11.0 + x_23))))? (((19.0 + x_0) > ((16.0 + x_1) > (13.0 + x_2)? (16.0 + x_1) : (13.0 + x_2))? (19.0 + x_0) : ((16.0 + x_1) > (13.0 + x_2)? (16.0 + x_1) : (13.0 + x_2))) > ((3.0 + x_5) > ((4.0 + x_12) > (10.0 + x_13)? (4.0 + x_12) : (10.0 + x_13))? (3.0 + x_5) : ((4.0 + x_12) > (10.0 + x_13)? (4.0 + x_12) : (10.0 + x_13)))? ((19.0 + x_0) > ((16.0 + x_1) > (13.0 + x_2)? (16.0 + x_1) : (13.0 + x_2))? (19.0 + x_0) : ((16.0 + x_1) > (13.0 + x_2)? (16.0 + x_1) : (13.0 + x_2))) : ((3.0 + x_5) > ((4.0 + x_12) > (10.0 + x_13)? (4.0 + x_12) : (10.0 + x_13))? (3.0 + x_5) : ((4.0 + x_12) > (10.0 + x_13)? (4.0 + x_12) : (10.0 + x_13)))) : (((17.0 + x_14) > ((2.0 + x_15) > (20.0 + x_17)? (2.0 + x_15) : (20.0 + x_17))? (17.0 + x_14) : ((2.0 + x_15) > (20.0 + x_17)? (2.0 + x_15) : (20.0 + x_17))) > ((10.0 + x_21) > ((18.0 + x_22) > (11.0 + x_23)? (18.0 + x_22) : (11.0 + x_23))? (10.0 + x_21) : ((18.0 + x_22) > (11.0 + x_23)? (18.0 + x_22) : (11.0 + x_23)))? ((17.0 + x_14) > ((2.0 + x_15) > (20.0 + x_17)? (2.0 + x_15) : (20.0 + x_17))? (17.0 + x_14) : ((2.0 + x_15) > (20.0 + x_17)? (2.0 + x_15) : (20.0 + x_17))) : ((10.0 + x_21) > ((18.0 + x_22) > (11.0 + x_23)? (18.0 + x_22) : (11.0 + x_23))? (10.0 + x_21) : ((18.0 + x_22) > (11.0 + x_23)? (18.0 + x_22) : (11.0 + x_23))))); x_1_ = ((((10.0 + x_3) > ((12.0 + x_4) > (9.0 + x_5)? (12.0 + x_4) : (9.0 + x_5))? (10.0 + x_3) : ((12.0 + x_4) > (9.0 + x_5)? (12.0 + x_4) : (9.0 + x_5))) > ((13.0 + x_9) > ((14.0 + x_10) > (9.0 + x_11)? (14.0 + x_10) : (9.0 + x_11))? (13.0 + x_9) : ((14.0 + x_10) > (9.0 + x_11)? (14.0 + x_10) : (9.0 + x_11)))? ((10.0 + x_3) > ((12.0 + x_4) > (9.0 + x_5)? (12.0 + x_4) : (9.0 + x_5))? (10.0 + x_3) : ((12.0 + x_4) > (9.0 + x_5)? (12.0 + x_4) : (9.0 + x_5))) : ((13.0 + x_9) > ((14.0 + x_10) > (9.0 + x_11)? (14.0 + x_10) : (9.0 + x_11))? (13.0 + x_9) : ((14.0 + x_10) > (9.0 + x_11)? (14.0 + x_10) : (9.0 + x_11)))) > (((14.0 + x_12) > ((12.0 + x_13) > (14.0 + x_16)? (12.0 + x_13) : (14.0 + x_16))? (14.0 + x_12) : ((12.0 + x_13) > (14.0 + x_16)? (12.0 + x_13) : (14.0 + x_16))) > ((2.0 + x_18) > ((20.0 + x_20) > (18.0 + x_21)? (20.0 + x_20) : (18.0 + x_21))? (2.0 + x_18) : ((20.0 + x_20) > (18.0 + x_21)? (20.0 + x_20) : (18.0 + x_21)))? ((14.0 + x_12) > ((12.0 + x_13) > (14.0 + x_16)? (12.0 + x_13) : (14.0 + x_16))? (14.0 + x_12) : ((12.0 + x_13) > (14.0 + x_16)? (12.0 + x_13) : (14.0 + x_16))) : ((2.0 + x_18) > ((20.0 + x_20) > (18.0 + x_21)? (20.0 + x_20) : (18.0 + x_21))? (2.0 + x_18) : ((20.0 + x_20) > (18.0 + x_21)? (20.0 + x_20) : (18.0 + x_21))))? (((10.0 + x_3) > ((12.0 + x_4) > (9.0 + x_5)? (12.0 + x_4) : (9.0 + x_5))? (10.0 + x_3) : ((12.0 + x_4) > (9.0 + x_5)? (12.0 + x_4) : (9.0 + x_5))) > ((13.0 + x_9) > ((14.0 + x_10) > (9.0 + x_11)? (14.0 + x_10) : (9.0 + x_11))? (13.0 + x_9) : ((14.0 + x_10) > (9.0 + x_11)? (14.0 + x_10) : (9.0 + x_11)))? ((10.0 + x_3) > ((12.0 + x_4) > (9.0 + x_5)? (12.0 + x_4) : (9.0 + x_5))? (10.0 + x_3) : ((12.0 + x_4) > (9.0 + x_5)? (12.0 + x_4) : (9.0 + x_5))) : ((13.0 + x_9) > ((14.0 + x_10) > (9.0 + x_11)? (14.0 + x_10) : (9.0 + x_11))? (13.0 + x_9) : ((14.0 + x_10) > (9.0 + x_11)? (14.0 + x_10) : (9.0 + x_11)))) : (((14.0 + x_12) > ((12.0 + x_13) > (14.0 + x_16)? (12.0 + x_13) : (14.0 + x_16))? (14.0 + x_12) : ((12.0 + x_13) > (14.0 + x_16)? (12.0 + x_13) : (14.0 + x_16))) > ((2.0 + x_18) > ((20.0 + x_20) > (18.0 + x_21)? (20.0 + x_20) : (18.0 + x_21))? (2.0 + x_18) : ((20.0 + x_20) > (18.0 + x_21)? (20.0 + x_20) : (18.0 + x_21)))? ((14.0 + x_12) > ((12.0 + x_13) > (14.0 + x_16)? (12.0 + x_13) : (14.0 + x_16))? (14.0 + x_12) : ((12.0 + x_13) > (14.0 + x_16)? (12.0 + x_13) : (14.0 + x_16))) : ((2.0 + x_18) > ((20.0 + x_20) > (18.0 + x_21)? (20.0 + x_20) : (18.0 + x_21))? (2.0 + x_18) : ((20.0 + x_20) > (18.0 + x_21)? (20.0 + x_20) : (18.0 + x_21))))); x_2_ = ((((12.0 + x_1) > ((6.0 + x_3) > (6.0 + x_8)? (6.0 + x_3) : (6.0 + x_8))? (12.0 + x_1) : ((6.0 + x_3) > (6.0 + x_8)? (6.0 + x_3) : (6.0 + x_8))) > ((11.0 + x_10) > ((6.0 + x_12) > (20.0 + x_13)? (6.0 + x_12) : (20.0 + x_13))? (11.0 + x_10) : ((6.0 + x_12) > (20.0 + x_13)? (6.0 + x_12) : (20.0 + x_13)))? ((12.0 + x_1) > ((6.0 + x_3) > (6.0 + x_8)? (6.0 + x_3) : (6.0 + x_8))? (12.0 + x_1) : ((6.0 + x_3) > (6.0 + x_8)? (6.0 + x_3) : (6.0 + x_8))) : ((11.0 + x_10) > ((6.0 + x_12) > (20.0 + x_13)? (6.0 + x_12) : (20.0 + x_13))? (11.0 + x_10) : ((6.0 + x_12) > (20.0 + x_13)? (6.0 + x_12) : (20.0 + x_13)))) > (((6.0 + x_15) > ((19.0 + x_16) > (13.0 + x_17)? (19.0 + x_16) : (13.0 + x_17))? (6.0 + x_15) : ((19.0 + x_16) > (13.0 + x_17)? (19.0 + x_16) : (13.0 + x_17))) > ((3.0 + x_18) > ((10.0 + x_19) > (5.0 + x_21)? (10.0 + x_19) : (5.0 + x_21))? (3.0 + x_18) : ((10.0 + x_19) > (5.0 + x_21)? (10.0 + x_19) : (5.0 + x_21)))? ((6.0 + x_15) > ((19.0 + x_16) > (13.0 + x_17)? (19.0 + x_16) : (13.0 + x_17))? (6.0 + x_15) : ((19.0 + x_16) > (13.0 + x_17)? (19.0 + x_16) : (13.0 + x_17))) : ((3.0 + x_18) > ((10.0 + x_19) > (5.0 + x_21)? (10.0 + x_19) : (5.0 + x_21))? (3.0 + x_18) : ((10.0 + x_19) > (5.0 + x_21)? (10.0 + x_19) : (5.0 + x_21))))? (((12.0 + x_1) > ((6.0 + x_3) > (6.0 + x_8)? (6.0 + x_3) : (6.0 + x_8))? (12.0 + x_1) : ((6.0 + x_3) > (6.0 + x_8)? (6.0 + x_3) : (6.0 + x_8))) > ((11.0 + x_10) > ((6.0 + x_12) > (20.0 + x_13)? (6.0 + x_12) : (20.0 + x_13))? (11.0 + x_10) : ((6.0 + x_12) > (20.0 + x_13)? (6.0 + x_12) : (20.0 + x_13)))? ((12.0 + x_1) > ((6.0 + x_3) > (6.0 + x_8)? (6.0 + x_3) : (6.0 + x_8))? (12.0 + x_1) : ((6.0 + x_3) > (6.0 + x_8)? (6.0 + x_3) : (6.0 + x_8))) : ((11.0 + x_10) > ((6.0 + x_12) > (20.0 + x_13)? (6.0 + x_12) : (20.0 + x_13))? (11.0 + x_10) : ((6.0 + x_12) > (20.0 + x_13)? (6.0 + x_12) : (20.0 + x_13)))) : (((6.0 + x_15) > ((19.0 + x_16) > (13.0 + x_17)? (19.0 + x_16) : (13.0 + x_17))? (6.0 + x_15) : ((19.0 + x_16) > (13.0 + x_17)? (19.0 + x_16) : (13.0 + x_17))) > ((3.0 + x_18) > ((10.0 + x_19) > (5.0 + x_21)? (10.0 + x_19) : (5.0 + x_21))? (3.0 + x_18) : ((10.0 + x_19) > (5.0 + x_21)? (10.0 + x_19) : (5.0 + x_21)))? ((6.0 + x_15) > ((19.0 + x_16) > (13.0 + x_17)? (19.0 + x_16) : (13.0 + x_17))? (6.0 + x_15) : ((19.0 + x_16) > (13.0 + x_17)? (19.0 + x_16) : (13.0 + x_17))) : ((3.0 + x_18) > ((10.0 + x_19) > (5.0 + x_21)? (10.0 + x_19) : (5.0 + x_21))? (3.0 + x_18) : ((10.0 + x_19) > (5.0 + x_21)? (10.0 + x_19) : (5.0 + x_21))))); x_3_ = ((((19.0 + x_1) > ((2.0 + x_2) > (6.0 + x_7)? (2.0 + x_2) : (6.0 + x_7))? (19.0 + x_1) : ((2.0 + x_2) > (6.0 + x_7)? (2.0 + x_2) : (6.0 + x_7))) > ((19.0 + x_8) > ((10.0 + x_10) > (9.0 + x_13)? (10.0 + x_10) : (9.0 + x_13))? (19.0 + x_8) : ((10.0 + x_10) > (9.0 + x_13)? (10.0 + x_10) : (9.0 + x_13)))? ((19.0 + x_1) > ((2.0 + x_2) > (6.0 + x_7)? (2.0 + x_2) : (6.0 + x_7))? (19.0 + x_1) : ((2.0 + x_2) > (6.0 + x_7)? (2.0 + x_2) : (6.0 + x_7))) : ((19.0 + x_8) > ((10.0 + x_10) > (9.0 + x_13)? (10.0 + x_10) : (9.0 + x_13))? (19.0 + x_8) : ((10.0 + x_10) > (9.0 + x_13)? (10.0 + x_10) : (9.0 + x_13)))) > (((19.0 + x_14) > ((15.0 + x_15) > (1.0 + x_16)? (15.0 + x_15) : (1.0 + x_16))? (19.0 + x_14) : ((15.0 + x_15) > (1.0 + x_16)? (15.0 + x_15) : (1.0 + x_16))) > ((11.0 + x_17) > ((11.0 + x_20) > (12.0 + x_21)? (11.0 + x_20) : (12.0 + x_21))? (11.0 + x_17) : ((11.0 + x_20) > (12.0 + x_21)? (11.0 + x_20) : (12.0 + x_21)))? ((19.0 + x_14) > ((15.0 + x_15) > (1.0 + x_16)? (15.0 + x_15) : (1.0 + x_16))? (19.0 + x_14) : ((15.0 + x_15) > (1.0 + x_16)? (15.0 + x_15) : (1.0 + x_16))) : ((11.0 + x_17) > ((11.0 + x_20) > (12.0 + x_21)? (11.0 + x_20) : (12.0 + x_21))? (11.0 + x_17) : ((11.0 + x_20) > (12.0 + x_21)? (11.0 + x_20) : (12.0 + x_21))))? (((19.0 + x_1) > ((2.0 + x_2) > (6.0 + x_7)? (2.0 + x_2) : (6.0 + x_7))? (19.0 + x_1) : ((2.0 + x_2) > (6.0 + x_7)? (2.0 + x_2) : (6.0 + x_7))) > ((19.0 + x_8) > ((10.0 + x_10) > (9.0 + x_13)? (10.0 + x_10) : (9.0 + x_13))? (19.0 + x_8) : ((10.0 + x_10) > (9.0 + x_13)? (10.0 + x_10) : (9.0 + x_13)))? ((19.0 + x_1) > ((2.0 + x_2) > (6.0 + x_7)? (2.0 + x_2) : (6.0 + x_7))? (19.0 + x_1) : ((2.0 + x_2) > (6.0 + x_7)? (2.0 + x_2) : (6.0 + x_7))) : ((19.0 + x_8) > ((10.0 + x_10) > (9.0 + x_13)? (10.0 + x_10) : (9.0 + x_13))? (19.0 + x_8) : ((10.0 + x_10) > (9.0 + x_13)? (10.0 + x_10) : (9.0 + x_13)))) : (((19.0 + x_14) > ((15.0 + x_15) > (1.0 + x_16)? (15.0 + x_15) : (1.0 + x_16))? (19.0 + x_14) : ((15.0 + x_15) > (1.0 + x_16)? (15.0 + x_15) : (1.0 + x_16))) > ((11.0 + x_17) > ((11.0 + x_20) > (12.0 + x_21)? (11.0 + x_20) : (12.0 + x_21))? (11.0 + x_17) : ((11.0 + x_20) > (12.0 + x_21)? (11.0 + x_20) : (12.0 + x_21)))? ((19.0 + x_14) > ((15.0 + x_15) > (1.0 + x_16)? (15.0 + x_15) : (1.0 + x_16))? (19.0 + x_14) : ((15.0 + x_15) > (1.0 + x_16)? (15.0 + x_15) : (1.0 + x_16))) : ((11.0 + x_17) > ((11.0 + x_20) > (12.0 + x_21)? (11.0 + x_20) : (12.0 + x_21))? (11.0 + x_17) : ((11.0 + x_20) > (12.0 + x_21)? (11.0 + x_20) : (12.0 + x_21))))); x_4_ = ((((17.0 + x_3) > ((4.0 + x_7) > (6.0 + x_9)? (4.0 + x_7) : (6.0 + x_9))? (17.0 + x_3) : ((4.0 + x_7) > (6.0 + x_9)? (4.0 + x_7) : (6.0 + x_9))) > ((18.0 + x_11) > ((15.0 + x_12) > (17.0 + x_13)? (15.0 + x_12) : (17.0 + x_13))? (18.0 + x_11) : ((15.0 + x_12) > (17.0 + x_13)? (15.0 + x_12) : (17.0 + x_13)))? ((17.0 + x_3) > ((4.0 + x_7) > (6.0 + x_9)? (4.0 + x_7) : (6.0 + x_9))? (17.0 + x_3) : ((4.0 + x_7) > (6.0 + x_9)? (4.0 + x_7) : (6.0 + x_9))) : ((18.0 + x_11) > ((15.0 + x_12) > (17.0 + x_13)? (15.0 + x_12) : (17.0 + x_13))? (18.0 + x_11) : ((15.0 + x_12) > (17.0 + x_13)? (15.0 + x_12) : (17.0 + x_13)))) > (((13.0 + x_15) > ((19.0 + x_17) > (2.0 + x_18)? (19.0 + x_17) : (2.0 + x_18))? (13.0 + x_15) : ((19.0 + x_17) > (2.0 + x_18)? (19.0 + x_17) : (2.0 + x_18))) > ((16.0 + x_19) > ((8.0 + x_20) > (17.0 + x_22)? (8.0 + x_20) : (17.0 + x_22))? (16.0 + x_19) : ((8.0 + x_20) > (17.0 + x_22)? (8.0 + x_20) : (17.0 + x_22)))? ((13.0 + x_15) > ((19.0 + x_17) > (2.0 + x_18)? (19.0 + x_17) : (2.0 + x_18))? (13.0 + x_15) : ((19.0 + x_17) > (2.0 + x_18)? (19.0 + x_17) : (2.0 + x_18))) : ((16.0 + x_19) > ((8.0 + x_20) > (17.0 + x_22)? (8.0 + x_20) : (17.0 + x_22))? (16.0 + x_19) : ((8.0 + x_20) > (17.0 + x_22)? (8.0 + x_20) : (17.0 + x_22))))? (((17.0 + x_3) > ((4.0 + x_7) > (6.0 + x_9)? (4.0 + x_7) : (6.0 + x_9))? (17.0 + x_3) : ((4.0 + x_7) > (6.0 + x_9)? (4.0 + x_7) : (6.0 + x_9))) > ((18.0 + x_11) > ((15.0 + x_12) > (17.0 + x_13)? (15.0 + x_12) : (17.0 + x_13))? (18.0 + x_11) : ((15.0 + x_12) > (17.0 + x_13)? (15.0 + x_12) : (17.0 + x_13)))? ((17.0 + x_3) > ((4.0 + x_7) > (6.0 + x_9)? (4.0 + x_7) : (6.0 + x_9))? (17.0 + x_3) : ((4.0 + x_7) > (6.0 + x_9)? (4.0 + x_7) : (6.0 + x_9))) : ((18.0 + x_11) > ((15.0 + x_12) > (17.0 + x_13)? (15.0 + x_12) : (17.0 + x_13))? (18.0 + x_11) : ((15.0 + x_12) > (17.0 + x_13)? (15.0 + x_12) : (17.0 + x_13)))) : (((13.0 + x_15) > ((19.0 + x_17) > (2.0 + x_18)? (19.0 + x_17) : (2.0 + x_18))? (13.0 + x_15) : ((19.0 + x_17) > (2.0 + x_18)? (19.0 + x_17) : (2.0 + x_18))) > ((16.0 + x_19) > ((8.0 + x_20) > (17.0 + x_22)? (8.0 + x_20) : (17.0 + x_22))? (16.0 + x_19) : ((8.0 + x_20) > (17.0 + x_22)? (8.0 + x_20) : (17.0 + x_22)))? ((13.0 + x_15) > ((19.0 + x_17) > (2.0 + x_18)? (19.0 + x_17) : (2.0 + x_18))? (13.0 + x_15) : ((19.0 + x_17) > (2.0 + x_18)? (19.0 + x_17) : (2.0 + x_18))) : ((16.0 + x_19) > ((8.0 + x_20) > (17.0 + x_22)? (8.0 + x_20) : (17.0 + x_22))? (16.0 + x_19) : ((8.0 + x_20) > (17.0 + x_22)? (8.0 + x_20) : (17.0 + x_22))))); x_5_ = ((((7.0 + x_2) > ((10.0 + x_3) > (10.0 + x_5)? (10.0 + x_3) : (10.0 + x_5))? (7.0 + x_2) : ((10.0 + x_3) > (10.0 + x_5)? (10.0 + x_3) : (10.0 + x_5))) > ((1.0 + x_7) > ((13.0 + x_9) > (7.0 + x_10)? (13.0 + x_9) : (7.0 + x_10))? (1.0 + x_7) : ((13.0 + x_9) > (7.0 + x_10)? (13.0 + x_9) : (7.0 + x_10)))? ((7.0 + x_2) > ((10.0 + x_3) > (10.0 + x_5)? (10.0 + x_3) : (10.0 + x_5))? (7.0 + x_2) : ((10.0 + x_3) > (10.0 + x_5)? (10.0 + x_3) : (10.0 + x_5))) : ((1.0 + x_7) > ((13.0 + x_9) > (7.0 + x_10)? (13.0 + x_9) : (7.0 + x_10))? (1.0 + x_7) : ((13.0 + x_9) > (7.0 + x_10)? (13.0 + x_9) : (7.0 + x_10)))) > (((7.0 + x_12) > ((7.0 + x_13) > (16.0 + x_15)? (7.0 + x_13) : (16.0 + x_15))? (7.0 + x_12) : ((7.0 + x_13) > (16.0 + x_15)? (7.0 + x_13) : (16.0 + x_15))) > ((2.0 + x_16) > ((9.0 + x_17) > (16.0 + x_23)? (9.0 + x_17) : (16.0 + x_23))? (2.0 + x_16) : ((9.0 + x_17) > (16.0 + x_23)? (9.0 + x_17) : (16.0 + x_23)))? ((7.0 + x_12) > ((7.0 + x_13) > (16.0 + x_15)? (7.0 + x_13) : (16.0 + x_15))? (7.0 + x_12) : ((7.0 + x_13) > (16.0 + x_15)? (7.0 + x_13) : (16.0 + x_15))) : ((2.0 + x_16) > ((9.0 + x_17) > (16.0 + x_23)? (9.0 + x_17) : (16.0 + x_23))? (2.0 + x_16) : ((9.0 + x_17) > (16.0 + x_23)? (9.0 + x_17) : (16.0 + x_23))))? (((7.0 + x_2) > ((10.0 + x_3) > (10.0 + x_5)? (10.0 + x_3) : (10.0 + x_5))? (7.0 + x_2) : ((10.0 + x_3) > (10.0 + x_5)? (10.0 + x_3) : (10.0 + x_5))) > ((1.0 + x_7) > ((13.0 + x_9) > (7.0 + x_10)? (13.0 + x_9) : (7.0 + x_10))? (1.0 + x_7) : ((13.0 + x_9) > (7.0 + x_10)? (13.0 + x_9) : (7.0 + x_10)))? ((7.0 + x_2) > ((10.0 + x_3) > (10.0 + x_5)? (10.0 + x_3) : (10.0 + x_5))? (7.0 + x_2) : ((10.0 + x_3) > (10.0 + x_5)? (10.0 + x_3) : (10.0 + x_5))) : ((1.0 + x_7) > ((13.0 + x_9) > (7.0 + x_10)? (13.0 + x_9) : (7.0 + x_10))? (1.0 + x_7) : ((13.0 + x_9) > (7.0 + x_10)? (13.0 + x_9) : (7.0 + x_10)))) : (((7.0 + x_12) > ((7.0 + x_13) > (16.0 + x_15)? (7.0 + x_13) : (16.0 + x_15))? (7.0 + x_12) : ((7.0 + x_13) > (16.0 + x_15)? (7.0 + x_13) : (16.0 + x_15))) > ((2.0 + x_16) > ((9.0 + x_17) > (16.0 + x_23)? (9.0 + x_17) : (16.0 + x_23))? (2.0 + x_16) : ((9.0 + x_17) > (16.0 + x_23)? (9.0 + x_17) : (16.0 + x_23)))? ((7.0 + x_12) > ((7.0 + x_13) > (16.0 + x_15)? (7.0 + x_13) : (16.0 + x_15))? (7.0 + x_12) : ((7.0 + x_13) > (16.0 + x_15)? (7.0 + x_13) : (16.0 + x_15))) : ((2.0 + x_16) > ((9.0 + x_17) > (16.0 + x_23)? (9.0 + x_17) : (16.0 + x_23))? (2.0 + x_16) : ((9.0 + x_17) > (16.0 + x_23)? (9.0 + x_17) : (16.0 + x_23))))); x_6_ = ((((5.0 + x_2) > ((16.0 + x_6) > (17.0 + x_7)? (16.0 + x_6) : (17.0 + x_7))? (5.0 + x_2) : ((16.0 + x_6) > (17.0 + x_7)? (16.0 + x_6) : (17.0 + x_7))) > ((18.0 + x_9) > ((1.0 + x_10) > (15.0 + x_11)? (1.0 + x_10) : (15.0 + x_11))? (18.0 + x_9) : ((1.0 + x_10) > (15.0 + x_11)? (1.0 + x_10) : (15.0 + x_11)))? ((5.0 + x_2) > ((16.0 + x_6) > (17.0 + x_7)? (16.0 + x_6) : (17.0 + x_7))? (5.0 + x_2) : ((16.0 + x_6) > (17.0 + x_7)? (16.0 + x_6) : (17.0 + x_7))) : ((18.0 + x_9) > ((1.0 + x_10) > (15.0 + x_11)? (1.0 + x_10) : (15.0 + x_11))? (18.0 + x_9) : ((1.0 + x_10) > (15.0 + x_11)? (1.0 + x_10) : (15.0 + x_11)))) > (((14.0 + x_12) > ((18.0 + x_14) > (20.0 + x_20)? (18.0 + x_14) : (20.0 + x_20))? (14.0 + x_12) : ((18.0 + x_14) > (20.0 + x_20)? (18.0 + x_14) : (20.0 + x_20))) > ((6.0 + x_21) > ((1.0 + x_22) > (4.0 + x_23)? (1.0 + x_22) : (4.0 + x_23))? (6.0 + x_21) : ((1.0 + x_22) > (4.0 + x_23)? (1.0 + x_22) : (4.0 + x_23)))? ((14.0 + x_12) > ((18.0 + x_14) > (20.0 + x_20)? (18.0 + x_14) : (20.0 + x_20))? (14.0 + x_12) : ((18.0 + x_14) > (20.0 + x_20)? (18.0 + x_14) : (20.0 + x_20))) : ((6.0 + x_21) > ((1.0 + x_22) > (4.0 + x_23)? (1.0 + x_22) : (4.0 + x_23))? (6.0 + x_21) : ((1.0 + x_22) > (4.0 + x_23)? (1.0 + x_22) : (4.0 + x_23))))? (((5.0 + x_2) > ((16.0 + x_6) > (17.0 + x_7)? (16.0 + x_6) : (17.0 + x_7))? (5.0 + x_2) : ((16.0 + x_6) > (17.0 + x_7)? (16.0 + x_6) : (17.0 + x_7))) > ((18.0 + x_9) > ((1.0 + x_10) > (15.0 + x_11)? (1.0 + x_10) : (15.0 + x_11))? (18.0 + x_9) : ((1.0 + x_10) > (15.0 + x_11)? (1.0 + x_10) : (15.0 + x_11)))? ((5.0 + x_2) > ((16.0 + x_6) > (17.0 + x_7)? (16.0 + x_6) : (17.0 + x_7))? (5.0 + x_2) : ((16.0 + x_6) > (17.0 + x_7)? (16.0 + x_6) : (17.0 + x_7))) : ((18.0 + x_9) > ((1.0 + x_10) > (15.0 + x_11)? (1.0 + x_10) : (15.0 + x_11))? (18.0 + x_9) : ((1.0 + x_10) > (15.0 + x_11)? (1.0 + x_10) : (15.0 + x_11)))) : (((14.0 + x_12) > ((18.0 + x_14) > (20.0 + x_20)? (18.0 + x_14) : (20.0 + x_20))? (14.0 + x_12) : ((18.0 + x_14) > (20.0 + x_20)? (18.0 + x_14) : (20.0 + x_20))) > ((6.0 + x_21) > ((1.0 + x_22) > (4.0 + x_23)? (1.0 + x_22) : (4.0 + x_23))? (6.0 + x_21) : ((1.0 + x_22) > (4.0 + x_23)? (1.0 + x_22) : (4.0 + x_23)))? ((14.0 + x_12) > ((18.0 + x_14) > (20.0 + x_20)? (18.0 + x_14) : (20.0 + x_20))? (14.0 + x_12) : ((18.0 + x_14) > (20.0 + x_20)? (18.0 + x_14) : (20.0 + x_20))) : ((6.0 + x_21) > ((1.0 + x_22) > (4.0 + x_23)? (1.0 + x_22) : (4.0 + x_23))? (6.0 + x_21) : ((1.0 + x_22) > (4.0 + x_23)? (1.0 + x_22) : (4.0 + x_23))))); x_7_ = ((((17.0 + x_3) > ((15.0 + x_5) > (11.0 + x_6)? (15.0 + x_5) : (11.0 + x_6))? (17.0 + x_3) : ((15.0 + x_5) > (11.0 + x_6)? (15.0 + x_5) : (11.0 + x_6))) > ((19.0 + x_11) > ((8.0 + x_12) > (1.0 + x_13)? (8.0 + x_12) : (1.0 + x_13))? (19.0 + x_11) : ((8.0 + x_12) > (1.0 + x_13)? (8.0 + x_12) : (1.0 + x_13)))? ((17.0 + x_3) > ((15.0 + x_5) > (11.0 + x_6)? (15.0 + x_5) : (11.0 + x_6))? (17.0 + x_3) : ((15.0 + x_5) > (11.0 + x_6)? (15.0 + x_5) : (11.0 + x_6))) : ((19.0 + x_11) > ((8.0 + x_12) > (1.0 + x_13)? (8.0 + x_12) : (1.0 + x_13))? (19.0 + x_11) : ((8.0 + x_12) > (1.0 + x_13)? (8.0 + x_12) : (1.0 + x_13)))) > (((5.0 + x_15) > ((10.0 + x_16) > (20.0 + x_17)? (10.0 + x_16) : (20.0 + x_17))? (5.0 + x_15) : ((10.0 + x_16) > (20.0 + x_17)? (10.0 + x_16) : (20.0 + x_17))) > ((7.0 + x_19) > ((7.0 + x_20) > (1.0 + x_21)? (7.0 + x_20) : (1.0 + x_21))? (7.0 + x_19) : ((7.0 + x_20) > (1.0 + x_21)? (7.0 + x_20) : (1.0 + x_21)))? ((5.0 + x_15) > ((10.0 + x_16) > (20.0 + x_17)? (10.0 + x_16) : (20.0 + x_17))? (5.0 + x_15) : ((10.0 + x_16) > (20.0 + x_17)? (10.0 + x_16) : (20.0 + x_17))) : ((7.0 + x_19) > ((7.0 + x_20) > (1.0 + x_21)? (7.0 + x_20) : (1.0 + x_21))? (7.0 + x_19) : ((7.0 + x_20) > (1.0 + x_21)? (7.0 + x_20) : (1.0 + x_21))))? (((17.0 + x_3) > ((15.0 + x_5) > (11.0 + x_6)? (15.0 + x_5) : (11.0 + x_6))? (17.0 + x_3) : ((15.0 + x_5) > (11.0 + x_6)? (15.0 + x_5) : (11.0 + x_6))) > ((19.0 + x_11) > ((8.0 + x_12) > (1.0 + x_13)? (8.0 + x_12) : (1.0 + x_13))? (19.0 + x_11) : ((8.0 + x_12) > (1.0 + x_13)? (8.0 + x_12) : (1.0 + x_13)))? ((17.0 + x_3) > ((15.0 + x_5) > (11.0 + x_6)? (15.0 + x_5) : (11.0 + x_6))? (17.0 + x_3) : ((15.0 + x_5) > (11.0 + x_6)? (15.0 + x_5) : (11.0 + x_6))) : ((19.0 + x_11) > ((8.0 + x_12) > (1.0 + x_13)? (8.0 + x_12) : (1.0 + x_13))? (19.0 + x_11) : ((8.0 + x_12) > (1.0 + x_13)? (8.0 + x_12) : (1.0 + x_13)))) : (((5.0 + x_15) > ((10.0 + x_16) > (20.0 + x_17)? (10.0 + x_16) : (20.0 + x_17))? (5.0 + x_15) : ((10.0 + x_16) > (20.0 + x_17)? (10.0 + x_16) : (20.0 + x_17))) > ((7.0 + x_19) > ((7.0 + x_20) > (1.0 + x_21)? (7.0 + x_20) : (1.0 + x_21))? (7.0 + x_19) : ((7.0 + x_20) > (1.0 + x_21)? (7.0 + x_20) : (1.0 + x_21)))? ((5.0 + x_15) > ((10.0 + x_16) > (20.0 + x_17)? (10.0 + x_16) : (20.0 + x_17))? (5.0 + x_15) : ((10.0 + x_16) > (20.0 + x_17)? (10.0 + x_16) : (20.0 + x_17))) : ((7.0 + x_19) > ((7.0 + x_20) > (1.0 + x_21)? (7.0 + x_20) : (1.0 + x_21))? (7.0 + x_19) : ((7.0 + x_20) > (1.0 + x_21)? (7.0 + x_20) : (1.0 + x_21))))); x_8_ = ((((4.0 + x_0) > ((3.0 + x_2) > (12.0 + x_3)? (3.0 + x_2) : (12.0 + x_3))? (4.0 + x_0) : ((3.0 + x_2) > (12.0 + x_3)? (3.0 + x_2) : (12.0 + x_3))) > ((11.0 + x_4) > ((8.0 + x_5) > (2.0 + x_8)? (8.0 + x_5) : (2.0 + x_8))? (11.0 + x_4) : ((8.0 + x_5) > (2.0 + x_8)? (8.0 + x_5) : (2.0 + x_8)))? ((4.0 + x_0) > ((3.0 + x_2) > (12.0 + x_3)? (3.0 + x_2) : (12.0 + x_3))? (4.0 + x_0) : ((3.0 + x_2) > (12.0 + x_3)? (3.0 + x_2) : (12.0 + x_3))) : ((11.0 + x_4) > ((8.0 + x_5) > (2.0 + x_8)? (8.0 + x_5) : (2.0 + x_8))? (11.0 + x_4) : ((8.0 + x_5) > (2.0 + x_8)? (8.0 + x_5) : (2.0 + x_8)))) > (((13.0 + x_11) > ((9.0 + x_12) > (18.0 + x_13)? (9.0 + x_12) : (18.0 + x_13))? (13.0 + x_11) : ((9.0 + x_12) > (18.0 + x_13)? (9.0 + x_12) : (18.0 + x_13))) > ((14.0 + x_14) > ((4.0 + x_17) > (3.0 + x_19)? (4.0 + x_17) : (3.0 + x_19))? (14.0 + x_14) : ((4.0 + x_17) > (3.0 + x_19)? (4.0 + x_17) : (3.0 + x_19)))? ((13.0 + x_11) > ((9.0 + x_12) > (18.0 + x_13)? (9.0 + x_12) : (18.0 + x_13))? (13.0 + x_11) : ((9.0 + x_12) > (18.0 + x_13)? (9.0 + x_12) : (18.0 + x_13))) : ((14.0 + x_14) > ((4.0 + x_17) > (3.0 + x_19)? (4.0 + x_17) : (3.0 + x_19))? (14.0 + x_14) : ((4.0 + x_17) > (3.0 + x_19)? (4.0 + x_17) : (3.0 + x_19))))? (((4.0 + x_0) > ((3.0 + x_2) > (12.0 + x_3)? (3.0 + x_2) : (12.0 + x_3))? (4.0 + x_0) : ((3.0 + x_2) > (12.0 + x_3)? (3.0 + x_2) : (12.0 + x_3))) > ((11.0 + x_4) > ((8.0 + x_5) > (2.0 + x_8)? (8.0 + x_5) : (2.0 + x_8))? (11.0 + x_4) : ((8.0 + x_5) > (2.0 + x_8)? (8.0 + x_5) : (2.0 + x_8)))? ((4.0 + x_0) > ((3.0 + x_2) > (12.0 + x_3)? (3.0 + x_2) : (12.0 + x_3))? (4.0 + x_0) : ((3.0 + x_2) > (12.0 + x_3)? (3.0 + x_2) : (12.0 + x_3))) : ((11.0 + x_4) > ((8.0 + x_5) > (2.0 + x_8)? (8.0 + x_5) : (2.0 + x_8))? (11.0 + x_4) : ((8.0 + x_5) > (2.0 + x_8)? (8.0 + x_5) : (2.0 + x_8)))) : (((13.0 + x_11) > ((9.0 + x_12) > (18.0 + x_13)? (9.0 + x_12) : (18.0 + x_13))? (13.0 + x_11) : ((9.0 + x_12) > (18.0 + x_13)? (9.0 + x_12) : (18.0 + x_13))) > ((14.0 + x_14) > ((4.0 + x_17) > (3.0 + x_19)? (4.0 + x_17) : (3.0 + x_19))? (14.0 + x_14) : ((4.0 + x_17) > (3.0 + x_19)? (4.0 + x_17) : (3.0 + x_19)))? ((13.0 + x_11) > ((9.0 + x_12) > (18.0 + x_13)? (9.0 + x_12) : (18.0 + x_13))? (13.0 + x_11) : ((9.0 + x_12) > (18.0 + x_13)? (9.0 + x_12) : (18.0 + x_13))) : ((14.0 + x_14) > ((4.0 + x_17) > (3.0 + x_19)? (4.0 + x_17) : (3.0 + x_19))? (14.0 + x_14) : ((4.0 + x_17) > (3.0 + x_19)? (4.0 + x_17) : (3.0 + x_19))))); x_9_ = ((((13.0 + x_0) > ((13.0 + x_2) > (8.0 + x_5)? (13.0 + x_2) : (8.0 + x_5))? (13.0 + x_0) : ((13.0 + x_2) > (8.0 + x_5)? (13.0 + x_2) : (8.0 + x_5))) > ((12.0 + x_6) > ((6.0 + x_7) > (1.0 + x_8)? (6.0 + x_7) : (1.0 + x_8))? (12.0 + x_6) : ((6.0 + x_7) > (1.0 + x_8)? (6.0 + x_7) : (1.0 + x_8)))? ((13.0 + x_0) > ((13.0 + x_2) > (8.0 + x_5)? (13.0 + x_2) : (8.0 + x_5))? (13.0 + x_0) : ((13.0 + x_2) > (8.0 + x_5)? (13.0 + x_2) : (8.0 + x_5))) : ((12.0 + x_6) > ((6.0 + x_7) > (1.0 + x_8)? (6.0 + x_7) : (1.0 + x_8))? (12.0 + x_6) : ((6.0 + x_7) > (1.0 + x_8)? (6.0 + x_7) : (1.0 + x_8)))) > (((10.0 + x_9) > ((7.0 + x_13) > (7.0 + x_14)? (7.0 + x_13) : (7.0 + x_14))? (10.0 + x_9) : ((7.0 + x_13) > (7.0 + x_14)? (7.0 + x_13) : (7.0 + x_14))) > ((20.0 + x_16) > ((1.0 + x_20) > (16.0 + x_21)? (1.0 + x_20) : (16.0 + x_21))? (20.0 + x_16) : ((1.0 + x_20) > (16.0 + x_21)? (1.0 + x_20) : (16.0 + x_21)))? ((10.0 + x_9) > ((7.0 + x_13) > (7.0 + x_14)? (7.0 + x_13) : (7.0 + x_14))? (10.0 + x_9) : ((7.0 + x_13) > (7.0 + x_14)? (7.0 + x_13) : (7.0 + x_14))) : ((20.0 + x_16) > ((1.0 + x_20) > (16.0 + x_21)? (1.0 + x_20) : (16.0 + x_21))? (20.0 + x_16) : ((1.0 + x_20) > (16.0 + x_21)? (1.0 + x_20) : (16.0 + x_21))))? (((13.0 + x_0) > ((13.0 + x_2) > (8.0 + x_5)? (13.0 + x_2) : (8.0 + x_5))? (13.0 + x_0) : ((13.0 + x_2) > (8.0 + x_5)? (13.0 + x_2) : (8.0 + x_5))) > ((12.0 + x_6) > ((6.0 + x_7) > (1.0 + x_8)? (6.0 + x_7) : (1.0 + x_8))? (12.0 + x_6) : ((6.0 + x_7) > (1.0 + x_8)? (6.0 + x_7) : (1.0 + x_8)))? ((13.0 + x_0) > ((13.0 + x_2) > (8.0 + x_5)? (13.0 + x_2) : (8.0 + x_5))? (13.0 + x_0) : ((13.0 + x_2) > (8.0 + x_5)? (13.0 + x_2) : (8.0 + x_5))) : ((12.0 + x_6) > ((6.0 + x_7) > (1.0 + x_8)? (6.0 + x_7) : (1.0 + x_8))? (12.0 + x_6) : ((6.0 + x_7) > (1.0 + x_8)? (6.0 + x_7) : (1.0 + x_8)))) : (((10.0 + x_9) > ((7.0 + x_13) > (7.0 + x_14)? (7.0 + x_13) : (7.0 + x_14))? (10.0 + x_9) : ((7.0 + x_13) > (7.0 + x_14)? (7.0 + x_13) : (7.0 + x_14))) > ((20.0 + x_16) > ((1.0 + x_20) > (16.0 + x_21)? (1.0 + x_20) : (16.0 + x_21))? (20.0 + x_16) : ((1.0 + x_20) > (16.0 + x_21)? (1.0 + x_20) : (16.0 + x_21)))? ((10.0 + x_9) > ((7.0 + x_13) > (7.0 + x_14)? (7.0 + x_13) : (7.0 + x_14))? (10.0 + x_9) : ((7.0 + x_13) > (7.0 + x_14)? (7.0 + x_13) : (7.0 + x_14))) : ((20.0 + x_16) > ((1.0 + x_20) > (16.0 + x_21)? (1.0 + x_20) : (16.0 + x_21))? (20.0 + x_16) : ((1.0 + x_20) > (16.0 + x_21)? (1.0 + x_20) : (16.0 + x_21))))); x_10_ = ((((16.0 + x_1) > ((15.0 + x_3) > (1.0 + x_5)? (15.0 + x_3) : (1.0 + x_5))? (16.0 + x_1) : ((15.0 + x_3) > (1.0 + x_5)? (15.0 + x_3) : (1.0 + x_5))) > ((8.0 + x_6) > ((9.0 + x_7) > (3.0 + x_9)? (9.0 + x_7) : (3.0 + x_9))? (8.0 + x_6) : ((9.0 + x_7) > (3.0 + x_9)? (9.0 + x_7) : (3.0 + x_9)))? ((16.0 + x_1) > ((15.0 + x_3) > (1.0 + x_5)? (15.0 + x_3) : (1.0 + x_5))? (16.0 + x_1) : ((15.0 + x_3) > (1.0 + x_5)? (15.0 + x_3) : (1.0 + x_5))) : ((8.0 + x_6) > ((9.0 + x_7) > (3.0 + x_9)? (9.0 + x_7) : (3.0 + x_9))? (8.0 + x_6) : ((9.0 + x_7) > (3.0 + x_9)? (9.0 + x_7) : (3.0 + x_9)))) > (((10.0 + x_10) > ((13.0 + x_11) > (12.0 + x_13)? (13.0 + x_11) : (12.0 + x_13))? (10.0 + x_10) : ((13.0 + x_11) > (12.0 + x_13)? (13.0 + x_11) : (12.0 + x_13))) > ((3.0 + x_14) > ((12.0 + x_19) > (19.0 + x_20)? (12.0 + x_19) : (19.0 + x_20))? (3.0 + x_14) : ((12.0 + x_19) > (19.0 + x_20)? (12.0 + x_19) : (19.0 + x_20)))? ((10.0 + x_10) > ((13.0 + x_11) > (12.0 + x_13)? (13.0 + x_11) : (12.0 + x_13))? (10.0 + x_10) : ((13.0 + x_11) > (12.0 + x_13)? (13.0 + x_11) : (12.0 + x_13))) : ((3.0 + x_14) > ((12.0 + x_19) > (19.0 + x_20)? (12.0 + x_19) : (19.0 + x_20))? (3.0 + x_14) : ((12.0 + x_19) > (19.0 + x_20)? (12.0 + x_19) : (19.0 + x_20))))? (((16.0 + x_1) > ((15.0 + x_3) > (1.0 + x_5)? (15.0 + x_3) : (1.0 + x_5))? (16.0 + x_1) : ((15.0 + x_3) > (1.0 + x_5)? (15.0 + x_3) : (1.0 + x_5))) > ((8.0 + x_6) > ((9.0 + x_7) > (3.0 + x_9)? (9.0 + x_7) : (3.0 + x_9))? (8.0 + x_6) : ((9.0 + x_7) > (3.0 + x_9)? (9.0 + x_7) : (3.0 + x_9)))? ((16.0 + x_1) > ((15.0 + x_3) > (1.0 + x_5)? (15.0 + x_3) : (1.0 + x_5))? (16.0 + x_1) : ((15.0 + x_3) > (1.0 + x_5)? (15.0 + x_3) : (1.0 + x_5))) : ((8.0 + x_6) > ((9.0 + x_7) > (3.0 + x_9)? (9.0 + x_7) : (3.0 + x_9))? (8.0 + x_6) : ((9.0 + x_7) > (3.0 + x_9)? (9.0 + x_7) : (3.0 + x_9)))) : (((10.0 + x_10) > ((13.0 + x_11) > (12.0 + x_13)? (13.0 + x_11) : (12.0 + x_13))? (10.0 + x_10) : ((13.0 + x_11) > (12.0 + x_13)? (13.0 + x_11) : (12.0 + x_13))) > ((3.0 + x_14) > ((12.0 + x_19) > (19.0 + x_20)? (12.0 + x_19) : (19.0 + x_20))? (3.0 + x_14) : ((12.0 + x_19) > (19.0 + x_20)? (12.0 + x_19) : (19.0 + x_20)))? ((10.0 + x_10) > ((13.0 + x_11) > (12.0 + x_13)? (13.0 + x_11) : (12.0 + x_13))? (10.0 + x_10) : ((13.0 + x_11) > (12.0 + x_13)? (13.0 + x_11) : (12.0 + x_13))) : ((3.0 + x_14) > ((12.0 + x_19) > (19.0 + x_20)? (12.0 + x_19) : (19.0 + x_20))? (3.0 + x_14) : ((12.0 + x_19) > (19.0 + x_20)? (12.0 + x_19) : (19.0 + x_20))))); x_11_ = ((((17.0 + x_1) > ((12.0 + x_4) > (13.0 + x_5)? (12.0 + x_4) : (13.0 + x_5))? (17.0 + x_1) : ((12.0 + x_4) > (13.0 + x_5)? (12.0 + x_4) : (13.0 + x_5))) > ((7.0 + x_10) > ((6.0 + x_11) > (12.0 + x_12)? (6.0 + x_11) : (12.0 + x_12))? (7.0 + x_10) : ((6.0 + x_11) > (12.0 + x_12)? (6.0 + x_11) : (12.0 + x_12)))? ((17.0 + x_1) > ((12.0 + x_4) > (13.0 + x_5)? (12.0 + x_4) : (13.0 + x_5))? (17.0 + x_1) : ((12.0 + x_4) > (13.0 + x_5)? (12.0 + x_4) : (13.0 + x_5))) : ((7.0 + x_10) > ((6.0 + x_11) > (12.0 + x_12)? (6.0 + x_11) : (12.0 + x_12))? (7.0 + x_10) : ((6.0 + x_11) > (12.0 + x_12)? (6.0 + x_11) : (12.0 + x_12)))) > (((4.0 + x_13) > ((18.0 + x_14) > (3.0 + x_17)? (18.0 + x_14) : (3.0 + x_17))? (4.0 + x_13) : ((18.0 + x_14) > (3.0 + x_17)? (18.0 + x_14) : (3.0 + x_17))) > ((16.0 + x_18) > ((16.0 + x_19) > (11.0 + x_20)? (16.0 + x_19) : (11.0 + x_20))? (16.0 + x_18) : ((16.0 + x_19) > (11.0 + x_20)? (16.0 + x_19) : (11.0 + x_20)))? ((4.0 + x_13) > ((18.0 + x_14) > (3.0 + x_17)? (18.0 + x_14) : (3.0 + x_17))? (4.0 + x_13) : ((18.0 + x_14) > (3.0 + x_17)? (18.0 + x_14) : (3.0 + x_17))) : ((16.0 + x_18) > ((16.0 + x_19) > (11.0 + x_20)? (16.0 + x_19) : (11.0 + x_20))? (16.0 + x_18) : ((16.0 + x_19) > (11.0 + x_20)? (16.0 + x_19) : (11.0 + x_20))))? (((17.0 + x_1) > ((12.0 + x_4) > (13.0 + x_5)? (12.0 + x_4) : (13.0 + x_5))? (17.0 + x_1) : ((12.0 + x_4) > (13.0 + x_5)? (12.0 + x_4) : (13.0 + x_5))) > ((7.0 + x_10) > ((6.0 + x_11) > (12.0 + x_12)? (6.0 + x_11) : (12.0 + x_12))? (7.0 + x_10) : ((6.0 + x_11) > (12.0 + x_12)? (6.0 + x_11) : (12.0 + x_12)))? ((17.0 + x_1) > ((12.0 + x_4) > (13.0 + x_5)? (12.0 + x_4) : (13.0 + x_5))? (17.0 + x_1) : ((12.0 + x_4) > (13.0 + x_5)? (12.0 + x_4) : (13.0 + x_5))) : ((7.0 + x_10) > ((6.0 + x_11) > (12.0 + x_12)? (6.0 + x_11) : (12.0 + x_12))? (7.0 + x_10) : ((6.0 + x_11) > (12.0 + x_12)? (6.0 + x_11) : (12.0 + x_12)))) : (((4.0 + x_13) > ((18.0 + x_14) > (3.0 + x_17)? (18.0 + x_14) : (3.0 + x_17))? (4.0 + x_13) : ((18.0 + x_14) > (3.0 + x_17)? (18.0 + x_14) : (3.0 + x_17))) > ((16.0 + x_18) > ((16.0 + x_19) > (11.0 + x_20)? (16.0 + x_19) : (11.0 + x_20))? (16.0 + x_18) : ((16.0 + x_19) > (11.0 + x_20)? (16.0 + x_19) : (11.0 + x_20)))? ((4.0 + x_13) > ((18.0 + x_14) > (3.0 + x_17)? (18.0 + x_14) : (3.0 + x_17))? (4.0 + x_13) : ((18.0 + x_14) > (3.0 + x_17)? (18.0 + x_14) : (3.0 + x_17))) : ((16.0 + x_18) > ((16.0 + x_19) > (11.0 + x_20)? (16.0 + x_19) : (11.0 + x_20))? (16.0 + x_18) : ((16.0 + x_19) > (11.0 + x_20)? (16.0 + x_19) : (11.0 + x_20))))); x_12_ = ((((20.0 + x_1) > ((16.0 + x_4) > (11.0 + x_7)? (16.0 + x_4) : (11.0 + x_7))? (20.0 + x_1) : ((16.0 + x_4) > (11.0 + x_7)? (16.0 + x_4) : (11.0 + x_7))) > ((16.0 + x_8) > ((12.0 + x_11) > (20.0 + x_12)? (12.0 + x_11) : (20.0 + x_12))? (16.0 + x_8) : ((12.0 + x_11) > (20.0 + x_12)? (12.0 + x_11) : (20.0 + x_12)))? ((20.0 + x_1) > ((16.0 + x_4) > (11.0 + x_7)? (16.0 + x_4) : (11.0 + x_7))? (20.0 + x_1) : ((16.0 + x_4) > (11.0 + x_7)? (16.0 + x_4) : (11.0 + x_7))) : ((16.0 + x_8) > ((12.0 + x_11) > (20.0 + x_12)? (12.0 + x_11) : (20.0 + x_12))? (16.0 + x_8) : ((12.0 + x_11) > (20.0 + x_12)? (12.0 + x_11) : (20.0 + x_12)))) > (((5.0 + x_14) > ((17.0 + x_16) > (18.0 + x_17)? (17.0 + x_16) : (18.0 + x_17))? (5.0 + x_14) : ((17.0 + x_16) > (18.0 + x_17)? (17.0 + x_16) : (18.0 + x_17))) > ((12.0 + x_18) > ((9.0 + x_20) > (2.0 + x_21)? (9.0 + x_20) : (2.0 + x_21))? (12.0 + x_18) : ((9.0 + x_20) > (2.0 + x_21)? (9.0 + x_20) : (2.0 + x_21)))? ((5.0 + x_14) > ((17.0 + x_16) > (18.0 + x_17)? (17.0 + x_16) : (18.0 + x_17))? (5.0 + x_14) : ((17.0 + x_16) > (18.0 + x_17)? (17.0 + x_16) : (18.0 + x_17))) : ((12.0 + x_18) > ((9.0 + x_20) > (2.0 + x_21)? (9.0 + x_20) : (2.0 + x_21))? (12.0 + x_18) : ((9.0 + x_20) > (2.0 + x_21)? (9.0 + x_20) : (2.0 + x_21))))? (((20.0 + x_1) > ((16.0 + x_4) > (11.0 + x_7)? (16.0 + x_4) : (11.0 + x_7))? (20.0 + x_1) : ((16.0 + x_4) > (11.0 + x_7)? (16.0 + x_4) : (11.0 + x_7))) > ((16.0 + x_8) > ((12.0 + x_11) > (20.0 + x_12)? (12.0 + x_11) : (20.0 + x_12))? (16.0 + x_8) : ((12.0 + x_11) > (20.0 + x_12)? (12.0 + x_11) : (20.0 + x_12)))? ((20.0 + x_1) > ((16.0 + x_4) > (11.0 + x_7)? (16.0 + x_4) : (11.0 + x_7))? (20.0 + x_1) : ((16.0 + x_4) > (11.0 + x_7)? (16.0 + x_4) : (11.0 + x_7))) : ((16.0 + x_8) > ((12.0 + x_11) > (20.0 + x_12)? (12.0 + x_11) : (20.0 + x_12))? (16.0 + x_8) : ((12.0 + x_11) > (20.0 + x_12)? (12.0 + x_11) : (20.0 + x_12)))) : (((5.0 + x_14) > ((17.0 + x_16) > (18.0 + x_17)? (17.0 + x_16) : (18.0 + x_17))? (5.0 + x_14) : ((17.0 + x_16) > (18.0 + x_17)? (17.0 + x_16) : (18.0 + x_17))) > ((12.0 + x_18) > ((9.0 + x_20) > (2.0 + x_21)? (9.0 + x_20) : (2.0 + x_21))? (12.0 + x_18) : ((9.0 + x_20) > (2.0 + x_21)? (9.0 + x_20) : (2.0 + x_21)))? ((5.0 + x_14) > ((17.0 + x_16) > (18.0 + x_17)? (17.0 + x_16) : (18.0 + x_17))? (5.0 + x_14) : ((17.0 + x_16) > (18.0 + x_17)? (17.0 + x_16) : (18.0 + x_17))) : ((12.0 + x_18) > ((9.0 + x_20) > (2.0 + x_21)? (9.0 + x_20) : (2.0 + x_21))? (12.0 + x_18) : ((9.0 + x_20) > (2.0 + x_21)? (9.0 + x_20) : (2.0 + x_21))))); x_13_ = ((((19.0 + x_2) > ((3.0 + x_3) > (14.0 + x_4)? (3.0 + x_3) : (14.0 + x_4))? (19.0 + x_2) : ((3.0 + x_3) > (14.0 + x_4)? (3.0 + x_3) : (14.0 + x_4))) > ((19.0 + x_6) > ((9.0 + x_7) > (10.0 + x_8)? (9.0 + x_7) : (10.0 + x_8))? (19.0 + x_6) : ((9.0 + x_7) > (10.0 + x_8)? (9.0 + x_7) : (10.0 + x_8)))? ((19.0 + x_2) > ((3.0 + x_3) > (14.0 + x_4)? (3.0 + x_3) : (14.0 + x_4))? (19.0 + x_2) : ((3.0 + x_3) > (14.0 + x_4)? (3.0 + x_3) : (14.0 + x_4))) : ((19.0 + x_6) > ((9.0 + x_7) > (10.0 + x_8)? (9.0 + x_7) : (10.0 + x_8))? (19.0 + x_6) : ((9.0 + x_7) > (10.0 + x_8)? (9.0 + x_7) : (10.0 + x_8)))) > (((13.0 + x_11) > ((18.0 + x_12) > (9.0 + x_13)? (18.0 + x_12) : (9.0 + x_13))? (13.0 + x_11) : ((18.0 + x_12) > (9.0 + x_13)? (18.0 + x_12) : (9.0 + x_13))) > ((3.0 + x_14) > ((16.0 + x_18) > (15.0 + x_23)? (16.0 + x_18) : (15.0 + x_23))? (3.0 + x_14) : ((16.0 + x_18) > (15.0 + x_23)? (16.0 + x_18) : (15.0 + x_23)))? ((13.0 + x_11) > ((18.0 + x_12) > (9.0 + x_13)? (18.0 + x_12) : (9.0 + x_13))? (13.0 + x_11) : ((18.0 + x_12) > (9.0 + x_13)? (18.0 + x_12) : (9.0 + x_13))) : ((3.0 + x_14) > ((16.0 + x_18) > (15.0 + x_23)? (16.0 + x_18) : (15.0 + x_23))? (3.0 + x_14) : ((16.0 + x_18) > (15.0 + x_23)? (16.0 + x_18) : (15.0 + x_23))))? (((19.0 + x_2) > ((3.0 + x_3) > (14.0 + x_4)? (3.0 + x_3) : (14.0 + x_4))? (19.0 + x_2) : ((3.0 + x_3) > (14.0 + x_4)? (3.0 + x_3) : (14.0 + x_4))) > ((19.0 + x_6) > ((9.0 + x_7) > (10.0 + x_8)? (9.0 + x_7) : (10.0 + x_8))? (19.0 + x_6) : ((9.0 + x_7) > (10.0 + x_8)? (9.0 + x_7) : (10.0 + x_8)))? ((19.0 + x_2) > ((3.0 + x_3) > (14.0 + x_4)? (3.0 + x_3) : (14.0 + x_4))? (19.0 + x_2) : ((3.0 + x_3) > (14.0 + x_4)? (3.0 + x_3) : (14.0 + x_4))) : ((19.0 + x_6) > ((9.0 + x_7) > (10.0 + x_8)? (9.0 + x_7) : (10.0 + x_8))? (19.0 + x_6) : ((9.0 + x_7) > (10.0 + x_8)? (9.0 + x_7) : (10.0 + x_8)))) : (((13.0 + x_11) > ((18.0 + x_12) > (9.0 + x_13)? (18.0 + x_12) : (9.0 + x_13))? (13.0 + x_11) : ((18.0 + x_12) > (9.0 + x_13)? (18.0 + x_12) : (9.0 + x_13))) > ((3.0 + x_14) > ((16.0 + x_18) > (15.0 + x_23)? (16.0 + x_18) : (15.0 + x_23))? (3.0 + x_14) : ((16.0 + x_18) > (15.0 + x_23)? (16.0 + x_18) : (15.0 + x_23)))? ((13.0 + x_11) > ((18.0 + x_12) > (9.0 + x_13)? (18.0 + x_12) : (9.0 + x_13))? (13.0 + x_11) : ((18.0 + x_12) > (9.0 + x_13)? (18.0 + x_12) : (9.0 + x_13))) : ((3.0 + x_14) > ((16.0 + x_18) > (15.0 + x_23)? (16.0 + x_18) : (15.0 + x_23))? (3.0 + x_14) : ((16.0 + x_18) > (15.0 + x_23)? (16.0 + x_18) : (15.0 + x_23))))); x_14_ = ((((3.0 + x_0) > ((5.0 + x_1) > (6.0 + x_2)? (5.0 + x_1) : (6.0 + x_2))? (3.0 + x_0) : ((5.0 + x_1) > (6.0 + x_2)? (5.0 + x_1) : (6.0 + x_2))) > ((7.0 + x_5) > ((12.0 + x_9) > (10.0 + x_10)? (12.0 + x_9) : (10.0 + x_10))? (7.0 + x_5) : ((12.0 + x_9) > (10.0 + x_10)? (12.0 + x_9) : (10.0 + x_10)))? ((3.0 + x_0) > ((5.0 + x_1) > (6.0 + x_2)? (5.0 + x_1) : (6.0 + x_2))? (3.0 + x_0) : ((5.0 + x_1) > (6.0 + x_2)? (5.0 + x_1) : (6.0 + x_2))) : ((7.0 + x_5) > ((12.0 + x_9) > (10.0 + x_10)? (12.0 + x_9) : (10.0 + x_10))? (7.0 + x_5) : ((12.0 + x_9) > (10.0 + x_10)? (12.0 + x_9) : (10.0 + x_10)))) > (((4.0 + x_11) > ((8.0 + x_12) > (11.0 + x_15)? (8.0 + x_12) : (11.0 + x_15))? (4.0 + x_11) : ((8.0 + x_12) > (11.0 + x_15)? (8.0 + x_12) : (11.0 + x_15))) > ((1.0 + x_20) > ((7.0 + x_22) > (18.0 + x_23)? (7.0 + x_22) : (18.0 + x_23))? (1.0 + x_20) : ((7.0 + x_22) > (18.0 + x_23)? (7.0 + x_22) : (18.0 + x_23)))? ((4.0 + x_11) > ((8.0 + x_12) > (11.0 + x_15)? (8.0 + x_12) : (11.0 + x_15))? (4.0 + x_11) : ((8.0 + x_12) > (11.0 + x_15)? (8.0 + x_12) : (11.0 + x_15))) : ((1.0 + x_20) > ((7.0 + x_22) > (18.0 + x_23)? (7.0 + x_22) : (18.0 + x_23))? (1.0 + x_20) : ((7.0 + x_22) > (18.0 + x_23)? (7.0 + x_22) : (18.0 + x_23))))? (((3.0 + x_0) > ((5.0 + x_1) > (6.0 + x_2)? (5.0 + x_1) : (6.0 + x_2))? (3.0 + x_0) : ((5.0 + x_1) > (6.0 + x_2)? (5.0 + x_1) : (6.0 + x_2))) > ((7.0 + x_5) > ((12.0 + x_9) > (10.0 + x_10)? (12.0 + x_9) : (10.0 + x_10))? (7.0 + x_5) : ((12.0 + x_9) > (10.0 + x_10)? (12.0 + x_9) : (10.0 + x_10)))? ((3.0 + x_0) > ((5.0 + x_1) > (6.0 + x_2)? (5.0 + x_1) : (6.0 + x_2))? (3.0 + x_0) : ((5.0 + x_1) > (6.0 + x_2)? (5.0 + x_1) : (6.0 + x_2))) : ((7.0 + x_5) > ((12.0 + x_9) > (10.0 + x_10)? (12.0 + x_9) : (10.0 + x_10))? (7.0 + x_5) : ((12.0 + x_9) > (10.0 + x_10)? (12.0 + x_9) : (10.0 + x_10)))) : (((4.0 + x_11) > ((8.0 + x_12) > (11.0 + x_15)? (8.0 + x_12) : (11.0 + x_15))? (4.0 + x_11) : ((8.0 + x_12) > (11.0 + x_15)? (8.0 + x_12) : (11.0 + x_15))) > ((1.0 + x_20) > ((7.0 + x_22) > (18.0 + x_23)? (7.0 + x_22) : (18.0 + x_23))? (1.0 + x_20) : ((7.0 + x_22) > (18.0 + x_23)? (7.0 + x_22) : (18.0 + x_23)))? ((4.0 + x_11) > ((8.0 + x_12) > (11.0 + x_15)? (8.0 + x_12) : (11.0 + x_15))? (4.0 + x_11) : ((8.0 + x_12) > (11.0 + x_15)? (8.0 + x_12) : (11.0 + x_15))) : ((1.0 + x_20) > ((7.0 + x_22) > (18.0 + x_23)? (7.0 + x_22) : (18.0 + x_23))? (1.0 + x_20) : ((7.0 + x_22) > (18.0 + x_23)? (7.0 + x_22) : (18.0 + x_23))))); x_15_ = ((((6.0 + x_0) > ((14.0 + x_4) > (10.0 + x_6)? (14.0 + x_4) : (10.0 + x_6))? (6.0 + x_0) : ((14.0 + x_4) > (10.0 + x_6)? (14.0 + x_4) : (10.0 + x_6))) > ((14.0 + x_8) > ((1.0 + x_9) > (8.0 + x_12)? (1.0 + x_9) : (8.0 + x_12))? (14.0 + x_8) : ((1.0 + x_9) > (8.0 + x_12)? (1.0 + x_9) : (8.0 + x_12)))? ((6.0 + x_0) > ((14.0 + x_4) > (10.0 + x_6)? (14.0 + x_4) : (10.0 + x_6))? (6.0 + x_0) : ((14.0 + x_4) > (10.0 + x_6)? (14.0 + x_4) : (10.0 + x_6))) : ((14.0 + x_8) > ((1.0 + x_9) > (8.0 + x_12)? (1.0 + x_9) : (8.0 + x_12))? (14.0 + x_8) : ((1.0 + x_9) > (8.0 + x_12)? (1.0 + x_9) : (8.0 + x_12)))) > (((11.0 + x_13) > ((18.0 + x_19) > (2.0 + x_20)? (18.0 + x_19) : (2.0 + x_20))? (11.0 + x_13) : ((18.0 + x_19) > (2.0 + x_20)? (18.0 + x_19) : (2.0 + x_20))) > ((8.0 + x_21) > ((3.0 + x_22) > (17.0 + x_23)? (3.0 + x_22) : (17.0 + x_23))? (8.0 + x_21) : ((3.0 + x_22) > (17.0 + x_23)? (3.0 + x_22) : (17.0 + x_23)))? ((11.0 + x_13) > ((18.0 + x_19) > (2.0 + x_20)? (18.0 + x_19) : (2.0 + x_20))? (11.0 + x_13) : ((18.0 + x_19) > (2.0 + x_20)? (18.0 + x_19) : (2.0 + x_20))) : ((8.0 + x_21) > ((3.0 + x_22) > (17.0 + x_23)? (3.0 + x_22) : (17.0 + x_23))? (8.0 + x_21) : ((3.0 + x_22) > (17.0 + x_23)? (3.0 + x_22) : (17.0 + x_23))))? (((6.0 + x_0) > ((14.0 + x_4) > (10.0 + x_6)? (14.0 + x_4) : (10.0 + x_6))? (6.0 + x_0) : ((14.0 + x_4) > (10.0 + x_6)? (14.0 + x_4) : (10.0 + x_6))) > ((14.0 + x_8) > ((1.0 + x_9) > (8.0 + x_12)? (1.0 + x_9) : (8.0 + x_12))? (14.0 + x_8) : ((1.0 + x_9) > (8.0 + x_12)? (1.0 + x_9) : (8.0 + x_12)))? ((6.0 + x_0) > ((14.0 + x_4) > (10.0 + x_6)? (14.0 + x_4) : (10.0 + x_6))? (6.0 + x_0) : ((14.0 + x_4) > (10.0 + x_6)? (14.0 + x_4) : (10.0 + x_6))) : ((14.0 + x_8) > ((1.0 + x_9) > (8.0 + x_12)? (1.0 + x_9) : (8.0 + x_12))? (14.0 + x_8) : ((1.0 + x_9) > (8.0 + x_12)? (1.0 + x_9) : (8.0 + x_12)))) : (((11.0 + x_13) > ((18.0 + x_19) > (2.0 + x_20)? (18.0 + x_19) : (2.0 + x_20))? (11.0 + x_13) : ((18.0 + x_19) > (2.0 + x_20)? (18.0 + x_19) : (2.0 + x_20))) > ((8.0 + x_21) > ((3.0 + x_22) > (17.0 + x_23)? (3.0 + x_22) : (17.0 + x_23))? (8.0 + x_21) : ((3.0 + x_22) > (17.0 + x_23)? (3.0 + x_22) : (17.0 + x_23)))? ((11.0 + x_13) > ((18.0 + x_19) > (2.0 + x_20)? (18.0 + x_19) : (2.0 + x_20))? (11.0 + x_13) : ((18.0 + x_19) > (2.0 + x_20)? (18.0 + x_19) : (2.0 + x_20))) : ((8.0 + x_21) > ((3.0 + x_22) > (17.0 + x_23)? (3.0 + x_22) : (17.0 + x_23))? (8.0 + x_21) : ((3.0 + x_22) > (17.0 + x_23)? (3.0 + x_22) : (17.0 + x_23))))); x_16_ = ((((18.0 + x_0) > ((19.0 + x_2) > (14.0 + x_5)? (19.0 + x_2) : (14.0 + x_5))? (18.0 + x_0) : ((19.0 + x_2) > (14.0 + x_5)? (19.0 + x_2) : (14.0 + x_5))) > ((18.0 + x_6) > ((9.0 + x_7) > (4.0 + x_14)? (9.0 + x_7) : (4.0 + x_14))? (18.0 + x_6) : ((9.0 + x_7) > (4.0 + x_14)? (9.0 + x_7) : (4.0 + x_14)))? ((18.0 + x_0) > ((19.0 + x_2) > (14.0 + x_5)? (19.0 + x_2) : (14.0 + x_5))? (18.0 + x_0) : ((19.0 + x_2) > (14.0 + x_5)? (19.0 + x_2) : (14.0 + x_5))) : ((18.0 + x_6) > ((9.0 + x_7) > (4.0 + x_14)? (9.0 + x_7) : (4.0 + x_14))? (18.0 + x_6) : ((9.0 + x_7) > (4.0 + x_14)? (9.0 + x_7) : (4.0 + x_14)))) > (((19.0 + x_16) > ((9.0 + x_17) > (2.0 + x_19)? (9.0 + x_17) : (2.0 + x_19))? (19.0 + x_16) : ((9.0 + x_17) > (2.0 + x_19)? (9.0 + x_17) : (2.0 + x_19))) > ((5.0 + x_20) > ((10.0 + x_21) > (1.0 + x_23)? (10.0 + x_21) : (1.0 + x_23))? (5.0 + x_20) : ((10.0 + x_21) > (1.0 + x_23)? (10.0 + x_21) : (1.0 + x_23)))? ((19.0 + x_16) > ((9.0 + x_17) > (2.0 + x_19)? (9.0 + x_17) : (2.0 + x_19))? (19.0 + x_16) : ((9.0 + x_17) > (2.0 + x_19)? (9.0 + x_17) : (2.0 + x_19))) : ((5.0 + x_20) > ((10.0 + x_21) > (1.0 + x_23)? (10.0 + x_21) : (1.0 + x_23))? (5.0 + x_20) : ((10.0 + x_21) > (1.0 + x_23)? (10.0 + x_21) : (1.0 + x_23))))? (((18.0 + x_0) > ((19.0 + x_2) > (14.0 + x_5)? (19.0 + x_2) : (14.0 + x_5))? (18.0 + x_0) : ((19.0 + x_2) > (14.0 + x_5)? (19.0 + x_2) : (14.0 + x_5))) > ((18.0 + x_6) > ((9.0 + x_7) > (4.0 + x_14)? (9.0 + x_7) : (4.0 + x_14))? (18.0 + x_6) : ((9.0 + x_7) > (4.0 + x_14)? (9.0 + x_7) : (4.0 + x_14)))? ((18.0 + x_0) > ((19.0 + x_2) > (14.0 + x_5)? (19.0 + x_2) : (14.0 + x_5))? (18.0 + x_0) : ((19.0 + x_2) > (14.0 + x_5)? (19.0 + x_2) : (14.0 + x_5))) : ((18.0 + x_6) > ((9.0 + x_7) > (4.0 + x_14)? (9.0 + x_7) : (4.0 + x_14))? (18.0 + x_6) : ((9.0 + x_7) > (4.0 + x_14)? (9.0 + x_7) : (4.0 + x_14)))) : (((19.0 + x_16) > ((9.0 + x_17) > (2.0 + x_19)? (9.0 + x_17) : (2.0 + x_19))? (19.0 + x_16) : ((9.0 + x_17) > (2.0 + x_19)? (9.0 + x_17) : (2.0 + x_19))) > ((5.0 + x_20) > ((10.0 + x_21) > (1.0 + x_23)? (10.0 + x_21) : (1.0 + x_23))? (5.0 + x_20) : ((10.0 + x_21) > (1.0 + x_23)? (10.0 + x_21) : (1.0 + x_23)))? ((19.0 + x_16) > ((9.0 + x_17) > (2.0 + x_19)? (9.0 + x_17) : (2.0 + x_19))? (19.0 + x_16) : ((9.0 + x_17) > (2.0 + x_19)? (9.0 + x_17) : (2.0 + x_19))) : ((5.0 + x_20) > ((10.0 + x_21) > (1.0 + x_23)? (10.0 + x_21) : (1.0 + x_23))? (5.0 + x_20) : ((10.0 + x_21) > (1.0 + x_23)? (10.0 + x_21) : (1.0 + x_23))))); x_17_ = ((((6.0 + x_2) > ((10.0 + x_3) > (6.0 + x_5)? (10.0 + x_3) : (6.0 + x_5))? (6.0 + x_2) : ((10.0 + x_3) > (6.0 + x_5)? (10.0 + x_3) : (6.0 + x_5))) > ((9.0 + x_7) > ((18.0 + x_8) > (19.0 + x_11)? (18.0 + x_8) : (19.0 + x_11))? (9.0 + x_7) : ((18.0 + x_8) > (19.0 + x_11)? (18.0 + x_8) : (19.0 + x_11)))? ((6.0 + x_2) > ((10.0 + x_3) > (6.0 + x_5)? (10.0 + x_3) : (6.0 + x_5))? (6.0 + x_2) : ((10.0 + x_3) > (6.0 + x_5)? (10.0 + x_3) : (6.0 + x_5))) : ((9.0 + x_7) > ((18.0 + x_8) > (19.0 + x_11)? (18.0 + x_8) : (19.0 + x_11))? (9.0 + x_7) : ((18.0 + x_8) > (19.0 + x_11)? (18.0 + x_8) : (19.0 + x_11)))) > (((10.0 + x_12) > ((12.0 + x_16) > (14.0 + x_20)? (12.0 + x_16) : (14.0 + x_20))? (10.0 + x_12) : ((12.0 + x_16) > (14.0 + x_20)? (12.0 + x_16) : (14.0 + x_20))) > ((6.0 + x_21) > ((7.0 + x_22) > (12.0 + x_23)? (7.0 + x_22) : (12.0 + x_23))? (6.0 + x_21) : ((7.0 + x_22) > (12.0 + x_23)? (7.0 + x_22) : (12.0 + x_23)))? ((10.0 + x_12) > ((12.0 + x_16) > (14.0 + x_20)? (12.0 + x_16) : (14.0 + x_20))? (10.0 + x_12) : ((12.0 + x_16) > (14.0 + x_20)? (12.0 + x_16) : (14.0 + x_20))) : ((6.0 + x_21) > ((7.0 + x_22) > (12.0 + x_23)? (7.0 + x_22) : (12.0 + x_23))? (6.0 + x_21) : ((7.0 + x_22) > (12.0 + x_23)? (7.0 + x_22) : (12.0 + x_23))))? (((6.0 + x_2) > ((10.0 + x_3) > (6.0 + x_5)? (10.0 + x_3) : (6.0 + x_5))? (6.0 + x_2) : ((10.0 + x_3) > (6.0 + x_5)? (10.0 + x_3) : (6.0 + x_5))) > ((9.0 + x_7) > ((18.0 + x_8) > (19.0 + x_11)? (18.0 + x_8) : (19.0 + x_11))? (9.0 + x_7) : ((18.0 + x_8) > (19.0 + x_11)? (18.0 + x_8) : (19.0 + x_11)))? ((6.0 + x_2) > ((10.0 + x_3) > (6.0 + x_5)? (10.0 + x_3) : (6.0 + x_5))? (6.0 + x_2) : ((10.0 + x_3) > (6.0 + x_5)? (10.0 + x_3) : (6.0 + x_5))) : ((9.0 + x_7) > ((18.0 + x_8) > (19.0 + x_11)? (18.0 + x_8) : (19.0 + x_11))? (9.0 + x_7) : ((18.0 + x_8) > (19.0 + x_11)? (18.0 + x_8) : (19.0 + x_11)))) : (((10.0 + x_12) > ((12.0 + x_16) > (14.0 + x_20)? (12.0 + x_16) : (14.0 + x_20))? (10.0 + x_12) : ((12.0 + x_16) > (14.0 + x_20)? (12.0 + x_16) : (14.0 + x_20))) > ((6.0 + x_21) > ((7.0 + x_22) > (12.0 + x_23)? (7.0 + x_22) : (12.0 + x_23))? (6.0 + x_21) : ((7.0 + x_22) > (12.0 + x_23)? (7.0 + x_22) : (12.0 + x_23)))? ((10.0 + x_12) > ((12.0 + x_16) > (14.0 + x_20)? (12.0 + x_16) : (14.0 + x_20))? (10.0 + x_12) : ((12.0 + x_16) > (14.0 + x_20)? (12.0 + x_16) : (14.0 + x_20))) : ((6.0 + x_21) > ((7.0 + x_22) > (12.0 + x_23)? (7.0 + x_22) : (12.0 + x_23))? (6.0 + x_21) : ((7.0 + x_22) > (12.0 + x_23)? (7.0 + x_22) : (12.0 + x_23))))); x_18_ = ((((8.0 + x_1) > ((8.0 + x_2) > (11.0 + x_3)? (8.0 + x_2) : (11.0 + x_3))? (8.0 + x_1) : ((8.0 + x_2) > (11.0 + x_3)? (8.0 + x_2) : (11.0 + x_3))) > ((1.0 + x_4) > ((4.0 + x_5) > (4.0 + x_7)? (4.0 + x_5) : (4.0 + x_7))? (1.0 + x_4) : ((4.0 + x_5) > (4.0 + x_7)? (4.0 + x_5) : (4.0 + x_7)))? ((8.0 + x_1) > ((8.0 + x_2) > (11.0 + x_3)? (8.0 + x_2) : (11.0 + x_3))? (8.0 + x_1) : ((8.0 + x_2) > (11.0 + x_3)? (8.0 + x_2) : (11.0 + x_3))) : ((1.0 + x_4) > ((4.0 + x_5) > (4.0 + x_7)? (4.0 + x_5) : (4.0 + x_7))? (1.0 + x_4) : ((4.0 + x_5) > (4.0 + x_7)? (4.0 + x_5) : (4.0 + x_7)))) > (((19.0 + x_9) > ((20.0 + x_10) > (16.0 + x_14)? (20.0 + x_10) : (16.0 + x_14))? (19.0 + x_9) : ((20.0 + x_10) > (16.0 + x_14)? (20.0 + x_10) : (16.0 + x_14))) > ((4.0 + x_16) > ((3.0 + x_20) > (14.0 + x_23)? (3.0 + x_20) : (14.0 + x_23))? (4.0 + x_16) : ((3.0 + x_20) > (14.0 + x_23)? (3.0 + x_20) : (14.0 + x_23)))? ((19.0 + x_9) > ((20.0 + x_10) > (16.0 + x_14)? (20.0 + x_10) : (16.0 + x_14))? (19.0 + x_9) : ((20.0 + x_10) > (16.0 + x_14)? (20.0 + x_10) : (16.0 + x_14))) : ((4.0 + x_16) > ((3.0 + x_20) > (14.0 + x_23)? (3.0 + x_20) : (14.0 + x_23))? (4.0 + x_16) : ((3.0 + x_20) > (14.0 + x_23)? (3.0 + x_20) : (14.0 + x_23))))? (((8.0 + x_1) > ((8.0 + x_2) > (11.0 + x_3)? (8.0 + x_2) : (11.0 + x_3))? (8.0 + x_1) : ((8.0 + x_2) > (11.0 + x_3)? (8.0 + x_2) : (11.0 + x_3))) > ((1.0 + x_4) > ((4.0 + x_5) > (4.0 + x_7)? (4.0 + x_5) : (4.0 + x_7))? (1.0 + x_4) : ((4.0 + x_5) > (4.0 + x_7)? (4.0 + x_5) : (4.0 + x_7)))? ((8.0 + x_1) > ((8.0 + x_2) > (11.0 + x_3)? (8.0 + x_2) : (11.0 + x_3))? (8.0 + x_1) : ((8.0 + x_2) > (11.0 + x_3)? (8.0 + x_2) : (11.0 + x_3))) : ((1.0 + x_4) > ((4.0 + x_5) > (4.0 + x_7)? (4.0 + x_5) : (4.0 + x_7))? (1.0 + x_4) : ((4.0 + x_5) > (4.0 + x_7)? (4.0 + x_5) : (4.0 + x_7)))) : (((19.0 + x_9) > ((20.0 + x_10) > (16.0 + x_14)? (20.0 + x_10) : (16.0 + x_14))? (19.0 + x_9) : ((20.0 + x_10) > (16.0 + x_14)? (20.0 + x_10) : (16.0 + x_14))) > ((4.0 + x_16) > ((3.0 + x_20) > (14.0 + x_23)? (3.0 + x_20) : (14.0 + x_23))? (4.0 + x_16) : ((3.0 + x_20) > (14.0 + x_23)? (3.0 + x_20) : (14.0 + x_23)))? ((19.0 + x_9) > ((20.0 + x_10) > (16.0 + x_14)? (20.0 + x_10) : (16.0 + x_14))? (19.0 + x_9) : ((20.0 + x_10) > (16.0 + x_14)? (20.0 + x_10) : (16.0 + x_14))) : ((4.0 + x_16) > ((3.0 + x_20) > (14.0 + x_23)? (3.0 + x_20) : (14.0 + x_23))? (4.0 + x_16) : ((3.0 + x_20) > (14.0 + x_23)? (3.0 + x_20) : (14.0 + x_23))))); x_19_ = ((((16.0 + x_1) > ((10.0 + x_3) > (18.0 + x_5)? (10.0 + x_3) : (18.0 + x_5))? (16.0 + x_1) : ((10.0 + x_3) > (18.0 + x_5)? (10.0 + x_3) : (18.0 + x_5))) > ((14.0 + x_7) > ((8.0 + x_9) > (12.0 + x_11)? (8.0 + x_9) : (12.0 + x_11))? (14.0 + x_7) : ((8.0 + x_9) > (12.0 + x_11)? (8.0 + x_9) : (12.0 + x_11)))? ((16.0 + x_1) > ((10.0 + x_3) > (18.0 + x_5)? (10.0 + x_3) : (18.0 + x_5))? (16.0 + x_1) : ((10.0 + x_3) > (18.0 + x_5)? (10.0 + x_3) : (18.0 + x_5))) : ((14.0 + x_7) > ((8.0 + x_9) > (12.0 + x_11)? (8.0 + x_9) : (12.0 + x_11))? (14.0 + x_7) : ((8.0 + x_9) > (12.0 + x_11)? (8.0 + x_9) : (12.0 + x_11)))) > (((20.0 + x_12) > ((16.0 + x_13) > (10.0 + x_14)? (16.0 + x_13) : (10.0 + x_14))? (20.0 + x_12) : ((16.0 + x_13) > (10.0 + x_14)? (16.0 + x_13) : (10.0 + x_14))) > ((4.0 + x_15) > ((15.0 + x_19) > (20.0 + x_23)? (15.0 + x_19) : (20.0 + x_23))? (4.0 + x_15) : ((15.0 + x_19) > (20.0 + x_23)? (15.0 + x_19) : (20.0 + x_23)))? ((20.0 + x_12) > ((16.0 + x_13) > (10.0 + x_14)? (16.0 + x_13) : (10.0 + x_14))? (20.0 + x_12) : ((16.0 + x_13) > (10.0 + x_14)? (16.0 + x_13) : (10.0 + x_14))) : ((4.0 + x_15) > ((15.0 + x_19) > (20.0 + x_23)? (15.0 + x_19) : (20.0 + x_23))? (4.0 + x_15) : ((15.0 + x_19) > (20.0 + x_23)? (15.0 + x_19) : (20.0 + x_23))))? (((16.0 + x_1) > ((10.0 + x_3) > (18.0 + x_5)? (10.0 + x_3) : (18.0 + x_5))? (16.0 + x_1) : ((10.0 + x_3) > (18.0 + x_5)? (10.0 + x_3) : (18.0 + x_5))) > ((14.0 + x_7) > ((8.0 + x_9) > (12.0 + x_11)? (8.0 + x_9) : (12.0 + x_11))? (14.0 + x_7) : ((8.0 + x_9) > (12.0 + x_11)? (8.0 + x_9) : (12.0 + x_11)))? ((16.0 + x_1) > ((10.0 + x_3) > (18.0 + x_5)? (10.0 + x_3) : (18.0 + x_5))? (16.0 + x_1) : ((10.0 + x_3) > (18.0 + x_5)? (10.0 + x_3) : (18.0 + x_5))) : ((14.0 + x_7) > ((8.0 + x_9) > (12.0 + x_11)? (8.0 + x_9) : (12.0 + x_11))? (14.0 + x_7) : ((8.0 + x_9) > (12.0 + x_11)? (8.0 + x_9) : (12.0 + x_11)))) : (((20.0 + x_12) > ((16.0 + x_13) > (10.0 + x_14)? (16.0 + x_13) : (10.0 + x_14))? (20.0 + x_12) : ((16.0 + x_13) > (10.0 + x_14)? (16.0 + x_13) : (10.0 + x_14))) > ((4.0 + x_15) > ((15.0 + x_19) > (20.0 + x_23)? (15.0 + x_19) : (20.0 + x_23))? (4.0 + x_15) : ((15.0 + x_19) > (20.0 + x_23)? (15.0 + x_19) : (20.0 + x_23)))? ((20.0 + x_12) > ((16.0 + x_13) > (10.0 + x_14)? (16.0 + x_13) : (10.0 + x_14))? (20.0 + x_12) : ((16.0 + x_13) > (10.0 + x_14)? (16.0 + x_13) : (10.0 + x_14))) : ((4.0 + x_15) > ((15.0 + x_19) > (20.0 + x_23)? (15.0 + x_19) : (20.0 + x_23))? (4.0 + x_15) : ((15.0 + x_19) > (20.0 + x_23)? (15.0 + x_19) : (20.0 + x_23))))); x_20_ = ((((3.0 + x_0) > ((7.0 + x_1) > (12.0 + x_2)? (7.0 + x_1) : (12.0 + x_2))? (3.0 + x_0) : ((7.0 + x_1) > (12.0 + x_2)? (7.0 + x_1) : (12.0 + x_2))) > ((1.0 + x_3) > ((18.0 + x_6) > (15.0 + x_11)? (18.0 + x_6) : (15.0 + x_11))? (1.0 + x_3) : ((18.0 + x_6) > (15.0 + x_11)? (18.0 + x_6) : (15.0 + x_11)))? ((3.0 + x_0) > ((7.0 + x_1) > (12.0 + x_2)? (7.0 + x_1) : (12.0 + x_2))? (3.0 + x_0) : ((7.0 + x_1) > (12.0 + x_2)? (7.0 + x_1) : (12.0 + x_2))) : ((1.0 + x_3) > ((18.0 + x_6) > (15.0 + x_11)? (18.0 + x_6) : (15.0 + x_11))? (1.0 + x_3) : ((18.0 + x_6) > (15.0 + x_11)? (18.0 + x_6) : (15.0 + x_11)))) > (((19.0 + x_14) > ((5.0 + x_16) > (17.0 + x_17)? (5.0 + x_16) : (17.0 + x_17))? (19.0 + x_14) : ((5.0 + x_16) > (17.0 + x_17)? (5.0 + x_16) : (17.0 + x_17))) > ((3.0 + x_20) > ((15.0 + x_21) > (2.0 + x_23)? (15.0 + x_21) : (2.0 + x_23))? (3.0 + x_20) : ((15.0 + x_21) > (2.0 + x_23)? (15.0 + x_21) : (2.0 + x_23)))? ((19.0 + x_14) > ((5.0 + x_16) > (17.0 + x_17)? (5.0 + x_16) : (17.0 + x_17))? (19.0 + x_14) : ((5.0 + x_16) > (17.0 + x_17)? (5.0 + x_16) : (17.0 + x_17))) : ((3.0 + x_20) > ((15.0 + x_21) > (2.0 + x_23)? (15.0 + x_21) : (2.0 + x_23))? (3.0 + x_20) : ((15.0 + x_21) > (2.0 + x_23)? (15.0 + x_21) : (2.0 + x_23))))? (((3.0 + x_0) > ((7.0 + x_1) > (12.0 + x_2)? (7.0 + x_1) : (12.0 + x_2))? (3.0 + x_0) : ((7.0 + x_1) > (12.0 + x_2)? (7.0 + x_1) : (12.0 + x_2))) > ((1.0 + x_3) > ((18.0 + x_6) > (15.0 + x_11)? (18.0 + x_6) : (15.0 + x_11))? (1.0 + x_3) : ((18.0 + x_6) > (15.0 + x_11)? (18.0 + x_6) : (15.0 + x_11)))? ((3.0 + x_0) > ((7.0 + x_1) > (12.0 + x_2)? (7.0 + x_1) : (12.0 + x_2))? (3.0 + x_0) : ((7.0 + x_1) > (12.0 + x_2)? (7.0 + x_1) : (12.0 + x_2))) : ((1.0 + x_3) > ((18.0 + x_6) > (15.0 + x_11)? (18.0 + x_6) : (15.0 + x_11))? (1.0 + x_3) : ((18.0 + x_6) > (15.0 + x_11)? (18.0 + x_6) : (15.0 + x_11)))) : (((19.0 + x_14) > ((5.0 + x_16) > (17.0 + x_17)? (5.0 + x_16) : (17.0 + x_17))? (19.0 + x_14) : ((5.0 + x_16) > (17.0 + x_17)? (5.0 + x_16) : (17.0 + x_17))) > ((3.0 + x_20) > ((15.0 + x_21) > (2.0 + x_23)? (15.0 + x_21) : (2.0 + x_23))? (3.0 + x_20) : ((15.0 + x_21) > (2.0 + x_23)? (15.0 + x_21) : (2.0 + x_23)))? ((19.0 + x_14) > ((5.0 + x_16) > (17.0 + x_17)? (5.0 + x_16) : (17.0 + x_17))? (19.0 + x_14) : ((5.0 + x_16) > (17.0 + x_17)? (5.0 + x_16) : (17.0 + x_17))) : ((3.0 + x_20) > ((15.0 + x_21) > (2.0 + x_23)? (15.0 + x_21) : (2.0 + x_23))? (3.0 + x_20) : ((15.0 + x_21) > (2.0 + x_23)? (15.0 + x_21) : (2.0 + x_23))))); x_21_ = ((((11.0 + x_0) > ((20.0 + x_1) > (3.0 + x_2)? (20.0 + x_1) : (3.0 + x_2))? (11.0 + x_0) : ((20.0 + x_1) > (3.0 + x_2)? (20.0 + x_1) : (3.0 + x_2))) > ((3.0 + x_5) > ((20.0 + x_6) > (5.0 + x_8)? (20.0 + x_6) : (5.0 + x_8))? (3.0 + x_5) : ((20.0 + x_6) > (5.0 + x_8)? (20.0 + x_6) : (5.0 + x_8)))? ((11.0 + x_0) > ((20.0 + x_1) > (3.0 + x_2)? (20.0 + x_1) : (3.0 + x_2))? (11.0 + x_0) : ((20.0 + x_1) > (3.0 + x_2)? (20.0 + x_1) : (3.0 + x_2))) : ((3.0 + x_5) > ((20.0 + x_6) > (5.0 + x_8)? (20.0 + x_6) : (5.0 + x_8))? (3.0 + x_5) : ((20.0 + x_6) > (5.0 + x_8)? (20.0 + x_6) : (5.0 + x_8)))) > (((5.0 + x_10) > ((17.0 + x_14) > (2.0 + x_16)? (17.0 + x_14) : (2.0 + x_16))? (5.0 + x_10) : ((17.0 + x_14) > (2.0 + x_16)? (17.0 + x_14) : (2.0 + x_16))) > ((11.0 + x_17) > ((7.0 + x_18) > (9.0 + x_20)? (7.0 + x_18) : (9.0 + x_20))? (11.0 + x_17) : ((7.0 + x_18) > (9.0 + x_20)? (7.0 + x_18) : (9.0 + x_20)))? ((5.0 + x_10) > ((17.0 + x_14) > (2.0 + x_16)? (17.0 + x_14) : (2.0 + x_16))? (5.0 + x_10) : ((17.0 + x_14) > (2.0 + x_16)? (17.0 + x_14) : (2.0 + x_16))) : ((11.0 + x_17) > ((7.0 + x_18) > (9.0 + x_20)? (7.0 + x_18) : (9.0 + x_20))? (11.0 + x_17) : ((7.0 + x_18) > (9.0 + x_20)? (7.0 + x_18) : (9.0 + x_20))))? (((11.0 + x_0) > ((20.0 + x_1) > (3.0 + x_2)? (20.0 + x_1) : (3.0 + x_2))? (11.0 + x_0) : ((20.0 + x_1) > (3.0 + x_2)? (20.0 + x_1) : (3.0 + x_2))) > ((3.0 + x_5) > ((20.0 + x_6) > (5.0 + x_8)? (20.0 + x_6) : (5.0 + x_8))? (3.0 + x_5) : ((20.0 + x_6) > (5.0 + x_8)? (20.0 + x_6) : (5.0 + x_8)))? ((11.0 + x_0) > ((20.0 + x_1) > (3.0 + x_2)? (20.0 + x_1) : (3.0 + x_2))? (11.0 + x_0) : ((20.0 + x_1) > (3.0 + x_2)? (20.0 + x_1) : (3.0 + x_2))) : ((3.0 + x_5) > ((20.0 + x_6) > (5.0 + x_8)? (20.0 + x_6) : (5.0 + x_8))? (3.0 + x_5) : ((20.0 + x_6) > (5.0 + x_8)? (20.0 + x_6) : (5.0 + x_8)))) : (((5.0 + x_10) > ((17.0 + x_14) > (2.0 + x_16)? (17.0 + x_14) : (2.0 + x_16))? (5.0 + x_10) : ((17.0 + x_14) > (2.0 + x_16)? (17.0 + x_14) : (2.0 + x_16))) > ((11.0 + x_17) > ((7.0 + x_18) > (9.0 + x_20)? (7.0 + x_18) : (9.0 + x_20))? (11.0 + x_17) : ((7.0 + x_18) > (9.0 + x_20)? (7.0 + x_18) : (9.0 + x_20)))? ((5.0 + x_10) > ((17.0 + x_14) > (2.0 + x_16)? (17.0 + x_14) : (2.0 + x_16))? (5.0 + x_10) : ((17.0 + x_14) > (2.0 + x_16)? (17.0 + x_14) : (2.0 + x_16))) : ((11.0 + x_17) > ((7.0 + x_18) > (9.0 + x_20)? (7.0 + x_18) : (9.0 + x_20))? (11.0 + x_17) : ((7.0 + x_18) > (9.0 + x_20)? (7.0 + x_18) : (9.0 + x_20))))); x_22_ = ((((15.0 + x_1) > ((7.0 + x_2) > (12.0 + x_3)? (7.0 + x_2) : (12.0 + x_3))? (15.0 + x_1) : ((7.0 + x_2) > (12.0 + x_3)? (7.0 + x_2) : (12.0 + x_3))) > ((11.0 + x_4) > ((11.0 + x_6) > (18.0 + x_8)? (11.0 + x_6) : (18.0 + x_8))? (11.0 + x_4) : ((11.0 + x_6) > (18.0 + x_8)? (11.0 + x_6) : (18.0 + x_8)))? ((15.0 + x_1) > ((7.0 + x_2) > (12.0 + x_3)? (7.0 + x_2) : (12.0 + x_3))? (15.0 + x_1) : ((7.0 + x_2) > (12.0 + x_3)? (7.0 + x_2) : (12.0 + x_3))) : ((11.0 + x_4) > ((11.0 + x_6) > (18.0 + x_8)? (11.0 + x_6) : (18.0 + x_8))? (11.0 + x_4) : ((11.0 + x_6) > (18.0 + x_8)? (11.0 + x_6) : (18.0 + x_8)))) > (((9.0 + x_9) > ((10.0 + x_11) > (11.0 + x_12)? (10.0 + x_11) : (11.0 + x_12))? (9.0 + x_9) : ((10.0 + x_11) > (11.0 + x_12)? (10.0 + x_11) : (11.0 + x_12))) > ((1.0 + x_16) > ((1.0 + x_18) > (13.0 + x_19)? (1.0 + x_18) : (13.0 + x_19))? (1.0 + x_16) : ((1.0 + x_18) > (13.0 + x_19)? (1.0 + x_18) : (13.0 + x_19)))? ((9.0 + x_9) > ((10.0 + x_11) > (11.0 + x_12)? (10.0 + x_11) : (11.0 + x_12))? (9.0 + x_9) : ((10.0 + x_11) > (11.0 + x_12)? (10.0 + x_11) : (11.0 + x_12))) : ((1.0 + x_16) > ((1.0 + x_18) > (13.0 + x_19)? (1.0 + x_18) : (13.0 + x_19))? (1.0 + x_16) : ((1.0 + x_18) > (13.0 + x_19)? (1.0 + x_18) : (13.0 + x_19))))? (((15.0 + x_1) > ((7.0 + x_2) > (12.0 + x_3)? (7.0 + x_2) : (12.0 + x_3))? (15.0 + x_1) : ((7.0 + x_2) > (12.0 + x_3)? (7.0 + x_2) : (12.0 + x_3))) > ((11.0 + x_4) > ((11.0 + x_6) > (18.0 + x_8)? (11.0 + x_6) : (18.0 + x_8))? (11.0 + x_4) : ((11.0 + x_6) > (18.0 + x_8)? (11.0 + x_6) : (18.0 + x_8)))? ((15.0 + x_1) > ((7.0 + x_2) > (12.0 + x_3)? (7.0 + x_2) : (12.0 + x_3))? (15.0 + x_1) : ((7.0 + x_2) > (12.0 + x_3)? (7.0 + x_2) : (12.0 + x_3))) : ((11.0 + x_4) > ((11.0 + x_6) > (18.0 + x_8)? (11.0 + x_6) : (18.0 + x_8))? (11.0 + x_4) : ((11.0 + x_6) > (18.0 + x_8)? (11.0 + x_6) : (18.0 + x_8)))) : (((9.0 + x_9) > ((10.0 + x_11) > (11.0 + x_12)? (10.0 + x_11) : (11.0 + x_12))? (9.0 + x_9) : ((10.0 + x_11) > (11.0 + x_12)? (10.0 + x_11) : (11.0 + x_12))) > ((1.0 + x_16) > ((1.0 + x_18) > (13.0 + x_19)? (1.0 + x_18) : (13.0 + x_19))? (1.0 + x_16) : ((1.0 + x_18) > (13.0 + x_19)? (1.0 + x_18) : (13.0 + x_19)))? ((9.0 + x_9) > ((10.0 + x_11) > (11.0 + x_12)? (10.0 + x_11) : (11.0 + x_12))? (9.0 + x_9) : ((10.0 + x_11) > (11.0 + x_12)? (10.0 + x_11) : (11.0 + x_12))) : ((1.0 + x_16) > ((1.0 + x_18) > (13.0 + x_19)? (1.0 + x_18) : (13.0 + x_19))? (1.0 + x_16) : ((1.0 + x_18) > (13.0 + x_19)? (1.0 + x_18) : (13.0 + x_19))))); x_23_ = ((((18.0 + x_0) > ((15.0 + x_1) > (9.0 + x_3)? (15.0 + x_1) : (9.0 + x_3))? (18.0 + x_0) : ((15.0 + x_1) > (9.0 + x_3)? (15.0 + x_1) : (9.0 + x_3))) > ((16.0 + x_4) > ((6.0 + x_6) > (5.0 + x_7)? (6.0 + x_6) : (5.0 + x_7))? (16.0 + x_4) : ((6.0 + x_6) > (5.0 + x_7)? (6.0 + x_6) : (5.0 + x_7)))? ((18.0 + x_0) > ((15.0 + x_1) > (9.0 + x_3)? (15.0 + x_1) : (9.0 + x_3))? (18.0 + x_0) : ((15.0 + x_1) > (9.0 + x_3)? (15.0 + x_1) : (9.0 + x_3))) : ((16.0 + x_4) > ((6.0 + x_6) > (5.0 + x_7)? (6.0 + x_6) : (5.0 + x_7))? (16.0 + x_4) : ((6.0 + x_6) > (5.0 + x_7)? (6.0 + x_6) : (5.0 + x_7)))) > (((14.0 + x_8) > ((2.0 + x_10) > (3.0 + x_14)? (2.0 + x_10) : (3.0 + x_14))? (14.0 + x_8) : ((2.0 + x_10) > (3.0 + x_14)? (2.0 + x_10) : (3.0 + x_14))) > ((11.0 + x_15) > ((20.0 + x_18) > (12.0 + x_22)? (20.0 + x_18) : (12.0 + x_22))? (11.0 + x_15) : ((20.0 + x_18) > (12.0 + x_22)? (20.0 + x_18) : (12.0 + x_22)))? ((14.0 + x_8) > ((2.0 + x_10) > (3.0 + x_14)? (2.0 + x_10) : (3.0 + x_14))? (14.0 + x_8) : ((2.0 + x_10) > (3.0 + x_14)? (2.0 + x_10) : (3.0 + x_14))) : ((11.0 + x_15) > ((20.0 + x_18) > (12.0 + x_22)? (20.0 + x_18) : (12.0 + x_22))? (11.0 + x_15) : ((20.0 + x_18) > (12.0 + x_22)? (20.0 + x_18) : (12.0 + x_22))))? (((18.0 + x_0) > ((15.0 + x_1) > (9.0 + x_3)? (15.0 + x_1) : (9.0 + x_3))? (18.0 + x_0) : ((15.0 + x_1) > (9.0 + x_3)? (15.0 + x_1) : (9.0 + x_3))) > ((16.0 + x_4) > ((6.0 + x_6) > (5.0 + x_7)? (6.0 + x_6) : (5.0 + x_7))? (16.0 + x_4) : ((6.0 + x_6) > (5.0 + x_7)? (6.0 + x_6) : (5.0 + x_7)))? ((18.0 + x_0) > ((15.0 + x_1) > (9.0 + x_3)? (15.0 + x_1) : (9.0 + x_3))? (18.0 + x_0) : ((15.0 + x_1) > (9.0 + x_3)? (15.0 + x_1) : (9.0 + x_3))) : ((16.0 + x_4) > ((6.0 + x_6) > (5.0 + x_7)? (6.0 + x_6) : (5.0 + x_7))? (16.0 + x_4) : ((6.0 + x_6) > (5.0 + x_7)? (6.0 + x_6) : (5.0 + x_7)))) : (((14.0 + x_8) > ((2.0 + x_10) > (3.0 + x_14)? (2.0 + x_10) : (3.0 + x_14))? (14.0 + x_8) : ((2.0 + x_10) > (3.0 + x_14)? (2.0 + x_10) : (3.0 + x_14))) > ((11.0 + x_15) > ((20.0 + x_18) > (12.0 + x_22)? (20.0 + x_18) : (12.0 + x_22))? (11.0 + x_15) : ((20.0 + x_18) > (12.0 + x_22)? (20.0 + x_18) : (12.0 + x_22)))? ((14.0 + x_8) > ((2.0 + x_10) > (3.0 + x_14)? (2.0 + x_10) : (3.0 + x_14))? (14.0 + x_8) : ((2.0 + x_10) > (3.0 + x_14)? (2.0 + x_10) : (3.0 + x_14))) : ((11.0 + x_15) > ((20.0 + x_18) > (12.0 + x_22)? (20.0 + x_18) : (12.0 + x_22))? (11.0 + x_15) : ((20.0 + x_18) > (12.0 + x_22)? (20.0 + x_18) : (12.0 + x_22))))); x_0 = x_0_; x_1 = x_1_; x_2 = x_2_; x_3 = x_3_; x_4 = x_4_; x_5 = x_5_; x_6 = x_6_; x_7 = x_7_; x_8 = x_8_; x_9 = x_9_; x_10 = x_10_; x_11 = x_11_; x_12 = x_12_; x_13 = x_13_; x_14 = x_14_; x_15 = x_15_; x_16 = x_16_; x_17 = x_17_; x_18 = x_18_; x_19 = x_19_; x_20 = x_20_; x_21 = x_21_; x_22 = x_22_; x_23 = x_23_; } return 0; }
the_stack_data/70450949.c
#include <stdio.h> #include <stdlib.h> int total,*people,step,p=0; int length() { int ret=0; for(int i=0;i<total;i++) if(people[i]==0) ret++; return ret; } void go(int s) { int ss=s;//还需要走的步数 while(ss>0) { if(p>=total) p-=total; if(people[p]==0) { p++; ss--; } else if(people[p]==1) { p++; } } while(people[p]==1) { p++; if(p>=total) p-=total; } people[p]=1; for(int i=0;i<total;i++) { printf("\e[%dm%d ",32-people[i],people[i]); } printf("\e[33m\t%d\n", length()); } int main(int argc,char **argv) { total=atoi(argv[1]); people=calloc(total,sizeof(int)); step=atoi(argv[2]); while(length()>1) go(step); return 0; }
the_stack_data/453202.c
#include <stdio.h> #include <stdlib.h> extern unsigned int TOS_NODE_ID; unsigned long checksexecuted = 0; // #define IS_DEBUGGING 1 struct metadata_table_entry { long ptr; long size; }; long metadatatablecount = 0; struct metadata_table_entry** metadatatable = NULL; // TODO: replace with the other BST efficient implementation. struct metadata_table_entry* findMetadataTableEntry(long p) { struct metadata_table_entry* entry = NULL; int i; for (i = 0; i < metadatatablecount; i++) { if (metadatatable[i]->ptr == p) { entry = metadatatable[i]; break; } } return entry; } void setMetadataTableEntry(long p, long size, long addr) { struct metadata_table_entry* entry = findMetadataTableEntry(p); if (entry == NULL) { // not found, create it #ifdef IS_DEBUGGING printf("[%p] Creating entry for %p, size = %ld\n", (void*)addr, (void*)p, size); #endif entry = malloc(sizeof(struct metadata_table_entry)); entry->ptr = p; entry->size = size; metadatatablecount++; metadatatable = realloc(metadatatable, metadatatablecount * sizeof(struct metadata_table_entry *)); metadatatable[metadatatablecount - 1] = entry; } entry->size = size; } long lookupMetadataTableEntry(long p) { struct metadata_table_entry* entry = findMetadataTableEntry(p); if (entry == NULL) { #ifdef IS_DEBUGGING printf("\tNot found %p\n", (void*)p); #endif return 0; } else { #ifdef IS_DEBUGGING printf("\tFound %p, size = %ld\n", (void*)p, entry->size); #endif return entry->size; } } void printErrorLine(long l) { printf("Memory error near line %ld.\n", l); } void printCheck(/*long l, long r*/) { #ifdef IS_DEBUGGING // disable this or the output will be GigaBytes big for real programs! // if (l < r) printf("%ld <= %ld ?\n", r, l); printf("?"); #endif }
the_stack_data/634716.c
int main(){ int a = 5; int b = 6; int c; c = a + b; if(c == 11){ c = c -1; if(c == 10){ c = 172; //entra aqui } else{ c = 474; //nao entra } } return c; }
the_stack_data/29825834.c
#include<stdio.h> // typedef definision typedef unsigned char BYTE; //define definision //#define ONE 1 int main(void) { BYTE s1='A'; printf("%d \n", s1 ); }
the_stack_data/92326133.c
/* Author:Robert Wijntjes Code:C14356786 Program:C Assignment to create a security Authorization system. 1:Entering your pin 2:Encrypting your pin.Cannot do when already encrypted 3:decrypt your pin.Cannot be done when already decrypted and no code. 4:Shows incorrect and correct times 5:Exits Program. */ #include <stdio.h> #include <stdlib.h> #define SIZE 4 void entercode(int *,int *); void encrypt(int *,int *,int *,int *,int *); void decrypt(int *,int *); main() { int option,q,r,i,access; int pinori[SIZE]={4,5,2,3}; int newpin[SIZE]={}; option = 0; q = 0; r = 0; i = 0; access = 0; //DECLARE VARIABLES printf("\nSecurity Authorization Code"); printf("\n*******************************"); printf("\nDefault Code : 1234"); printf("\n*******************************"); //STARTUP BAR do { printf("\n1:Please Enter your Code."); printf("\n2:Encrypt Code!"); printf("\n3:Decrypt Code!"); printf("\n4:Display Success/Fail Rate"); printf("\n5:Exit\n"); scanf("%d",&option); fflush(stdin); //MENU BAR switch(option) { case 1 : { entercode(&newpin[i],&access); break; }//END CASE case 2 : { encrypt(&newpin[i],&pinori[i],&q,&r,&access); break; }//END CASE case 3 : { decrypt(&newpin[i],&access); break; }//END CASE case 4 : { printf("\n%d times correct! %d times incorrect!",q,r); break; }//END CASE case 5 : { return 0; break; }//END CASE }//END SWITCH //FUNCTION SLOTS }//END DO while(option != 5); getchar(); }//END MAIN void entercode(int *code,int *access_fxn) { int i; i=0; printf("\nPlease Enter your code now!\n"); for (i=0;i<SIZE;i++) { scanf("%d",&*(code+i)); }//END FOR (*access_fxn) = 0; (*access_fxn)++; }//END ENTERCODE void encrypt(int *code_enc,int *code_compare,int *q,int *r,int *access_fxn2) { int temp,i,failcount; temp = 0; i=0; failcount = 0; if(*(access_fxn2) == 1 ) { temp = *(code_enc); *(code_enc) = *(code_enc + 2); *(code_enc + 2) = temp; //first switch temp = *(code_enc + 1); *(code_enc + 1) = *(code_enc + 3); *(code_enc + 3) = temp; //second switch for(i=0;i<SIZE;i++) { *(code_enc + i)= *(code_enc + i)+1; }//END INCREMENT LUUP for(i=0;i<SIZE;i++) { if(*(code_enc + i) == 10 ) { *(code_enc + i) = 0; }//END CHANGE 10 --> 0 else { break; }//END ELSE }//END FOR if(*(code_enc) == *(code_compare)) { printf("\nCorrect!"); (*q)++; }//END IF else { printf("\nIncorrect!"); (*r)++; }//END ELSE for(i=0;i<SIZE;i++) { printf("%d",*(code_enc + i)); }//SHOWS MASK (*access_fxn2)++; }//END IF else { }//END ELSE }//END ENCRYPT void decrypt(int *code_dnc,int *access_fxn3) { int temp,i; temp = 0; i = 0; if(*(access_fxn3) == 2) { temp = *(code_dnc); *(code_dnc) = *(code_dnc + 2); *(code_dnc + 2) = temp; //first switch temp = *(code_dnc + 1); *(code_dnc + 1) = *(code_dnc + 3); *(code_dnc + 3) = temp; //second switch for(i=0;i<SIZE;i++) { *(code_dnc + i)= *(code_dnc + i)-1; }//END INCREMENT LUUP for(i=0;i<SIZE;i++) { if(*(code_dnc + i) == -1 ) { *(code_dnc + i) = 9; }//END CHANGE 10 --> 0 else { break; }//END ELSE }//END FOR for(i=0;i<SIZE;i++) { printf("%d",*(code_dnc + i)); }//SHOWS MASK (*access_fxn3)--; }//END IF else { } }//END DECRYPT
the_stack_data/232955537.c
#include <stdio.h> int main(void) { printf("hello world\n"); return 0; }
the_stack_data/73575071.c
void foo(void); void foo(void) { char p = 1; char c = p || 2; }
the_stack_data/162642151.c
/* pipe.c */ /* a pipe is means of interprocess communication (IPC) */ #include <stdio.h> #include <stdlib.h> #include <unistd.h> int main() { int p[2]; /* array to hold the two pipe (file) descriptors p[0] is the read end of the pipe p[1] is the write end of the pipe */ int rc = pipe( p ); if ( rc == -1 ) { perror( "pipe() failed" ); return EXIT_FAILURE; } /* fd table: 0: stdin 1: stdout 2: stderr 3: p[0] <=======READ============= (buffer) think of this as 4: p[1] ========WRITE===========> (buffer) a temporary file... */ /* write some data to the pipe */ int bytes_written = write( p[1], "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 26 ); printf( "Wrote %d bytes\n", bytes_written ); close( p[1] ); /* read data from the pipe */ char buffer[100]; int bytes_read = read( p[0], buffer, 10 ); /* BLOCKING */ buffer[bytes_read] = '\0'; printf( "Read %d bytes: %s\n", bytes_read, buffer ); bytes_read = read( p[0], buffer, 20 ); /* BLOCKING */ buffer[bytes_read] = '\0'; printf( "Read %d bytes: %s\n", bytes_read, buffer ); close( p[0] ); return EXIT_SUCCESS; }
the_stack_data/103617.c
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <errno.h> #include <sys/types.h> #include <sys/socket.h> #include <arpa/inet.h> #include <netinet/in.h> #include <fcntl.h> #include <sys/select.h> #include <sys/time.h> #include <string.h> #define SERV_PORT 8031 #define BUFSIZE 1024 #define FD_SET_SIZE 128 int main(void) { int lfd, cfd, maxfd, scokfd, retval; struct sockaddr_in serv_addr, clin_addr; socklen_t clin_len; // 地址信息结构体大小 char recvbuf[BUFSIZE]; int len; fd_set read_set, read_set_init; int client[FD_SET_SIZE]; int i; int maxi = -1; if ((lfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) { perror("套接字描述符创建失败"); exit(1); } int opt = 1; setsockopt(lfd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)); memset(&serv_addr, 0, sizeof(serv_addr)); serv_addr.sin_family = AF_INET; serv_addr.sin_addr.s_addr = htonl(INADDR_ANY); serv_addr.sin_port = htons(SERV_PORT); if (bind(lfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) == -1) { perror("绑定失败"); exit(1); } if (listen(lfd, FD_SET_SIZE) == -1) { perror("监听失败"); exit(1); } maxfd = lfd; for (i = 0; i < FD_SET_SIZE; ++i) { client[i] = -1; } FD_ZERO(&read_set_init); FD_SET(lfd, &read_set_init); while (1) { // 每次循环开始时,都初始化 read_set read_set = read_set_init; // 因为上一步 read_set 已经重置,所以需要已连接上的客户端 fd (由上次循环后产生)重新添加进 read_set for (i = 0; i < FD_SET_SIZE; ++i) { if (client[i] > 0) { FD_SET(client[i], &read_set); } } printf("select 等待\n"); // 这里会阻塞,直到 read_set 中某一个 fd 有数据可读才返回,注意 read_set 中除了客户端 fd 还有服务端监听的 fd retval = select(maxfd + 1, &read_set, NULL, NULL, NULL); if (retval == -1) { perror("select 错误\n"); } else if (retval == 0) { printf("超时\n"); continue; } printf("select 返回\n"); //------------------------------------------------------------------------------------------------ // 用 FD_ISSET 来判断 lfd (服务端监听的fd)是否可读。只有当新的客户端连接时,lfd 才可读 if (FD_ISSET(lfd, &read_set)) { clin_len = sizeof(clin_addr); if ((cfd = accept(lfd, (struct sockaddr *)&clin_addr, &clin_len)) == -1) { perror("接收错误\n"); continue; } for (i = 0; i < FD_SET_SIZE; ++i) { if (client[i] < 0) { // 把客户端 fd 放入 client 数组 client[i] = cfd; printf("接收client[%d]一个请求来自于: %s:%d\n", i, inet_ntoa(clin_addr.sin_addr), ntohs(clin_addr.sin_port)); break; } } // 最大的描述符值也要重新计算 maxfd = (cfd > maxfd) ? cfd : maxfd; // maxi 用于下面遍历所有有效客户端 fd 使用,以免遍历整个 client 数组 maxi = (i >= maxi) ? ++i : maxi; } //------------------------------------------------------------------------------------------------ for (i = 0; i < maxi; ++i) { if (client[i] < 0) { continue; } // 如果客户端 fd 中有数据可读,则进行读取 if (FD_ISSET(client[i], &read_set)) { // 注意:这里没有使用 while 循环读取,如果使用 while 循环读取,则有阻塞在一个客户端了。 // 可能你会想到如果一次读取不完怎么办? // 读取不完时,在循环到 select 时 由于未读完的 fd 还有数据可读,那么立即返回,然后到这里继续读取,原来的 while 循环读取直接提到最外层的 while(1) + select 来判断是否有数据继续可读 len = read(client[i], recvbuf, BUFSIZE); if (len > 0) { write(STDOUT_FILENO, recvbuf, len); } else if (len == 0) { // 如果在客户端 ctrl+z close(client[i]); printf("clinet[%d] 连接关闭\n", i); FD_CLR(client[i], &read_set); client[i] = -1; break; } } } } close(lfd); return 0; }
the_stack_data/124151.c
#include <stdio.h> int main(int argn, char** argc) { puts("Lispy Version 0.0.1"); puts("Author: Ranmal Dias\n"); static char buffer[2048]; //Ctrl + c to quit the interpretor while(1) { fputs("lispy> ", stdout); fgets(buffer, 2048, stdin); printf("You entered %s", buffer); } }
the_stack_data/858847.c
#include <stdio.h> #include <stdlib.h> #include <assert.h> void __VERIFIER_error(void){ assert(0); } int failure() { __VERIFIER_error(); return 1; } int main() { int a = 1; return a && failure(); }
the_stack_data/50136942.c
#include <stdio.h> #include <math.h> int main(void){ int n, fat; printf("Fatorial do numero: "); scanf("%d", &n); for(fat = 1; n > 1; n = n - 1) fat = fat * n; printf("Fatorial: %d\n", fat); return 0; }
the_stack_data/231394407.c
#if defined(STM8Sxx) #if !defined(STM8S903) || !defined(STM8AF622x) #include "stm8s_tim4.c" #endif /* (STM8S903) || (STM8AF622x) */ #endif #if defined(STM8Lxx) #include "stm8l15x_tim4.c" #endif
the_stack_data/115764882.c
/* Generated by CIL v. 1.7.0 */ /* print_CIL_Input is false */ struct _IO_FILE; struct timeval; extern float strtof(char const *str , char const *endptr ) ; extern void signal(int sig , void *func ) ; typedef struct _IO_FILE FILE; extern int atoi(char const *s ) ; extern double strtod(char const *str , char const *endptr ) ; extern int fclose(void *stream ) ; extern void *fopen(char const *filename , char const *mode ) ; extern void abort() ; extern void exit(int status ) ; extern int raise(int sig ) ; extern int fprintf(struct _IO_FILE *stream , char const *format , ...) ; extern int strcmp(char const *a , char const *b ) ; extern int rand() ; extern unsigned long strtoul(char const *str , char const *endptr , int base ) ; void RandomFunc(unsigned short input[1] , unsigned short output[1] ) ; extern int strncmp(char const *s1 , char const *s2 , unsigned long maxlen ) ; extern int gettimeofday(struct timeval *tv , void *tz , ...) ; extern int printf(char const *format , ...) ; int main(int argc , char *argv[] ) ; void megaInit(void) ; extern unsigned long strlen(char const *s ) ; extern long strtol(char const *str , char const *endptr , int base ) ; extern unsigned long strnlen(char const *s , unsigned long maxlen ) ; extern void *memcpy(void *s1 , void const *s2 , unsigned long size ) ; struct timeval { long tv_sec ; long tv_usec ; }; extern void *malloc(unsigned long size ) ; extern int scanf(char const *format , ...) ; int main(int argc , char *argv[] ) { unsigned short input[1] ; unsigned short output[1] ; int randomFuns_i5 ; unsigned short randomFuns_value6 ; int randomFuns_main_i7 ; { megaInit(); if (argc != 2) { printf("Call this program with %i arguments\n", 1); exit(-1); } else { } randomFuns_i5 = 0; while (randomFuns_i5 < 1) { randomFuns_value6 = (unsigned short )strtoul(argv[randomFuns_i5 + 1], 0, 10); input[randomFuns_i5] = randomFuns_value6; randomFuns_i5 ++; } RandomFunc(input, output); if (output[0] == 53909) { printf("You win!\n"); } else { } randomFuns_main_i7 = 0; while (randomFuns_main_i7 < 1) { printf("%u\n", output[randomFuns_main_i7]); randomFuns_main_i7 ++; } } } void RandomFunc(unsigned short input[1] , unsigned short output[1] ) { unsigned short state[1] ; unsigned short local1 ; { state[0UL] = input[0UL] + (unsigned short)2885; local1 = 0UL; while (local1 < 1UL) { if (! (state[0UL] > local1)) { state[0UL] = state[local1] + state[local1]; state[0UL] = state[local1] + state[local1]; } local1 += 2UL; } output[0UL] = (state[0UL] + 1039116836UL) + (unsigned short)60659; } } void megaInit(void) { { } }
the_stack_data/126703714.c
#include <stdlib.h> static int compare (const void * elem1, const void * elem2) { int f = *((int*)elem1); int s = *((int*)elem2); if (f > s) return 1; if (f < s) return -1; return 0; } void sort(const void* values, int numberOfValues) { qsort ((int*)values, numberOfValues, sizeof(int), compare); } void absoluteArray(const void* values, int numberOfValues) { for(int i =0; i<numberOfValues ; i++) ((int*)values)[i] = abs(((int*)values)[i]); }
the_stack_data/329354.c
#include <stdio.h> int main(void) { int n = 4; int m = 5; float f = 7.0f; float g = 8.0f; printf("%d\n", n, m); printf("%d %d %d\n", n); printf("%d %d\n", f, g); return 0; }
the_stack_data/80279.c
/* -*- mode: c -*- * $Id: matrix.c 36673 2007-05-03 16:55:46Z laurov $ * http://www.bagley.org/~doug/shootout/ */ #include <stdio.h> #include <stdlib.h> /*#define SIZE 30*/ #define SIZE 10 int **mkmatrix(int rows, int cols) { int i, j, count = 1; int **m = (int **) malloc(rows * sizeof(int *)); for (i=0; i<rows; i++) { m[i] = (int *) malloc(cols * sizeof(int)); for (j=0; j<cols; j++) { m[i][j] = count++; } } return(m); } void zeromatrix(int rows, int cols, int **m) { int i, j; for (i=0; i<rows; i++) for (j=0; j<cols; j++) m[i][j] = 0; } void freematrix(int rows, int **m) { while (--rows > -1) { free(m[rows]); } free(m); } int **mmult(int rows, int cols, int **m1, int **m2, int **m3) { int i, j, k, val; for (i=0; i<rows; i++) { for (j=0; j<cols; j++) { val = 0; for (k=0; k<cols; k++) { val += m1[i][k] * m2[k][j]; } m3[i][j] = val; } } return(m3); } int main(int argc, char *argv[]) { #ifdef SMALL_PROBLEM_SIZE #define LENGTH 300000 #else #define LENGTH 3000000 #endif int i, n = ((argc == 2) ? atoi(argv[1]) : LENGTH); int **m1 = mkmatrix(SIZE, SIZE); int **m2 = mkmatrix(SIZE, SIZE); int **mm = mkmatrix(SIZE, SIZE); for (i=0; i<n; i++) { mm = mmult(SIZE, SIZE, m1, m2, mm); } printf("%d %d %d %d\n", mm[0][0], mm[2][3], mm[3][2], mm[4][4]); freematrix(SIZE, m1); freematrix(SIZE, m2); freematrix(SIZE, mm); return(0); }
the_stack_data/93887737.c
#include <stdio.h> #include <math.h> int main() { double a, b, c; printf("Choisir une équation aX^2 + bX + c = 0:\n"); printf("a = "); scanf("%lf", &a); printf("b = "); scanf("%lf", &b); printf("c = "); scanf("%lf", &c); if (a = 0) if (b != 0) printf("La solution est: x = %lf\n", -c / b); else printf("Aucune solution.\n"); double delta = pow(b, 2) - 4 * a * c; printf("Delta = %lf\n", delta); if (delta < 0) printf("Aucune solution réelle.\n"); else if (delta == 0) printf("Une seule solution: x = %lf \n", -b / 2 / a); else if (delta > 0) printf("Deux solutions:\n- x1 = %lf\n- x2 = %lf\n", (-b - sqrt(delta)) / a / 2, (-b + sqrt(delta)) / a / 2); }
the_stack_data/154830463.c
#include <stdio.h> /* 打印 hello world */ char *GetMemory(void) { char *p = "hello world"; return p; } void Test(void) { char *str = NULL; str = GetMemory(); printf("%s\n", str); } int main(int argc, char *argv[]) { Test(); }
the_stack_data/1130591.c
/** * @brief chown - bad implementation thereof * * @copyright * This file is part of ToaruOS and is released under the terms * of the NCSA / University of Illinois License - see LICENSE.md * Copyright (C) 2018 K. Lange */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <errno.h> #include <pwd.h> static int usage(char * argv[]) { fprintf(stderr, "usage: %s [OWNER][:[GROUP]] FILE...\n", argv[0]); return 1; } static int invalid(char * argv[], char c) { fprintf(stderr, "%s: %c: unrecognized option\n", argv[0], c); return 1; } static int parse_user_group(char * argv[], char * arg, uid_t * user, gid_t * group) { /* Does this look like a number? */ if (*arg >= '0' && *arg <= '9') { /* Try to extract */ char * endptr; unsigned long int number = strtoul(arg, &endptr, 10); if (*endptr != ':' && *endptr != '\0') { fprintf(stderr, "%s: %s: Invalid user/group specification\n", argv[0], arg); } *user = number; arg = endptr; } else if (*arg == ':') { *user = -1; arg++; } else { char * colon = strstr(arg, ":"); if (colon) { *colon = '\0'; } /* Check name */ struct passwd * userEnt = getpwnam(arg); if (!userEnt) { fprintf(stderr, "%s: %s: Invalid user\n", argv[0], arg); return 1; } *user = userEnt->pw_uid; if (colon) { arg = colon + 1; } else { arg = NULL; } } if (arg && *arg) { if (*arg >= '0' && *arg <= '9') { char * endptr; unsigned long int number = strtoul(arg, &endptr, 10); if (*endptr != '\0') { fprintf(stderr, "%s: %s: Invalid group specification\n", argv[0], arg); } *group = number; arg = endptr; } else { struct passwd * userEnt = getpwnam(arg); if (!userEnt) { fprintf(stderr, "%s: %s: Invalid group\n", argv[0], arg); return 1; } *group = userEnt->pw_uid; } } return 0; } int main(int argc, char * argv[]) { int i = 1; for (; i < argc; i++) { if (argv[i][0] != '-') break; switch (argv[i][0]) { case 'h': return usage(argv); default: return invalid(argv,argv[i][0]); } } if (i + 1 >= argc) return usage(argv); uid_t user = -1; uid_t group = -1; if (parse_user_group(argv, argv[i++], &user, &group)) return 1; if (user == -1 && group == -1) return 0; int retval = 0; for (; i < argc; i++) { if (chown(argv[i], user, group)) { fprintf(stderr, "%s: %s: %s\n", argv[0], argv[i], strerror(errno)); retval = 1; } } return retval; }
the_stack_data/47079.c
/* // Copyright (c) 2019 Intel Corporation // // Li!censed 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. */ #ifdef OC_SECURITY #ifdef OC_PKI #ifndef OC_DYNAMIC_ALLOCATION #error "ERROR: Please rebuild with OC_DYNAMIC_ALLOCATION" #endif /* !OC_DYNAMIC_ALLOCATION */ #include "oc_core_res.h" #include "oc_obt.h" #include "security/oc_acl_internal.h" #include "security/oc_cred_internal.h" #include "security/oc_doxm.h" #include "security/oc_obt_internal.h" #include "security/oc_pstat.h" #include "security/oc_sdi.h" #include "security/oc_store.h" #include "security/oc_tls.h" /* Manufacturer certificate-based ownership transfer */ static void obt_cert_16(oc_client_response_t *data) { if (!oc_obt_is_otm_ctx_valid(data->user_data)) { return; } OC_DBG("In obt_cert_16"); oc_otm_ctx_t *o = (oc_otm_ctx_t *)data->user_data; if (data->code >= OC_STATUS_BAD_REQUEST) { oc_obt_free_otm_ctx(o, -1, OC_OBT_OTM_CERT); return; } /** 16) <close DTLS> */ oc_obt_free_otm_ctx(o, 0, OC_OBT_OTM_CERT); } static void obt_cert_15(oc_client_response_t *data) { if (!oc_obt_is_otm_ctx_valid(data->user_data)) { return; } OC_DBG("In obt_cert_15"); oc_otm_ctx_t *o = (oc_otm_ctx_t *)data->user_data; if (data->code >= OC_STATUS_BAD_REQUEST) { goto err_obt_cert_15; } /** 15) post pstat s=rfnop */ oc_device_t *device = o->device; oc_endpoint_t *ep = oc_obt_get_secure_endpoint(device->endpoint); if (oc_init_post("/oic/sec/pstat", ep, NULL, &obt_cert_16, HIGH_QOS, o)) { oc_rep_start_root_object(); oc_rep_set_object(root, dos); oc_rep_set_int(dos, s, OC_DOS_RFNOP); oc_rep_close_object(root, dos); oc_rep_end_root_object(); if (oc_do_post()) { return; } } err_obt_cert_15: oc_obt_free_otm_ctx(o, -1, OC_OBT_OTM_CERT); } static void obt_cert_14(oc_client_response_t *data) { if (!oc_obt_is_otm_ctx_valid(data->user_data)) { return; } OC_DBG("In obt_cert_14"); oc_otm_ctx_t *o = (oc_otm_ctx_t *)data->user_data; if (data->code >= OC_STATUS_BAD_REQUEST) { goto err_obt_cert_14; } /** 14) post acl2 with ACEs for res, p, d, csr, sp */ oc_device_t *device = o->device; oc_endpoint_t *ep = oc_obt_get_secure_endpoint(device->endpoint); if (oc_init_post("/oic/sec/acl2", ep, NULL, &obt_cert_15, HIGH_QOS, o)) { char uuid[OC_UUID_LEN]; oc_uuid_t *my_uuid = oc_core_get_device_id(0); oc_uuid_to_str(my_uuid, uuid, OC_UUID_LEN); oc_rep_start_root_object(); oc_rep_set_array(root, aclist2); /* Owner-subejct ACEs for (R-only) /oic/sec/csr and (RW) /oic/sec/sp */ oc_rep_object_array_start_item(aclist2); oc_rep_set_object(aclist2, subject); oc_rep_set_text_string(subject, uuid, uuid); oc_rep_close_object(aclist2, subject); oc_rep_set_array(aclist2, resources); oc_rep_object_array_start_item(resources); oc_rep_set_text_string(resources, href, "/oic/sec/sp"); oc_rep_object_array_end_item(resources); oc_rep_close_array(aclist2, resources); oc_rep_set_uint(aclist2, permission, 14); oc_rep_object_array_end_item(aclist2); /**/ oc_rep_object_array_start_item(aclist2); oc_rep_set_object(aclist2, subject); oc_rep_set_text_string(subject, uuid, uuid); oc_rep_close_object(aclist2, subject); oc_rep_set_array(aclist2, resources); oc_rep_object_array_start_item(resources); oc_rep_set_text_string(resources, href, "/oic/sec/csr"); oc_rep_object_array_end_item(resources); oc_rep_close_array(aclist2, resources); oc_rep_set_uint(aclist2, permission, 2); oc_rep_object_array_end_item(aclist2); /* anon-clear R-only ACE for res, d and p */ oc_rep_object_array_start_item(aclist2); oc_rep_set_object(aclist2, subject); oc_rep_set_text_string(subject, conntype, "anon-clear"); oc_rep_close_object(aclist2, subject); oc_rep_set_array(aclist2, resources); oc_rep_object_array_start_item(resources); oc_rep_set_text_string(resources, href, "/oic/d"); oc_rep_object_array_end_item(resources); oc_rep_object_array_start_item(resources); oc_rep_set_text_string(resources, href, "/oic/p"); oc_rep_object_array_end_item(resources); oc_rep_object_array_start_item(resources); oc_rep_set_text_string(resources, href, "/oic/res"); oc_rep_object_array_end_item(resources); if (o->sdi) { oc_rep_object_array_start_item(resources); oc_rep_set_text_string(resources, href, "/oic/sec/sdi"); oc_rep_object_array_end_item(resources); } oc_rep_close_array(aclist2, resources); oc_rep_set_uint(aclist2, permission, 0x02); oc_rep_object_array_end_item(aclist2); oc_rep_close_array(root, aclist2); oc_rep_end_root_object(); if (oc_do_post()) { return; } } err_obt_cert_14: oc_obt_free_otm_ctx(o, -1, OC_OBT_OTM_CERT); } static void obt_cert_13(oc_client_response_t *data) { if (!oc_obt_is_otm_ctx_valid(data->user_data)) { return; } OC_DBG("In obt_cert_13"); oc_otm_ctx_t *o = (oc_otm_ctx_t *)data->user_data; if (data->code >= OC_STATUS_BAD_REQUEST) { goto err_obt_cert_13; } /** 13) delete acl2 */ oc_device_t *device = o->device; oc_endpoint_t *ep = oc_obt_get_secure_endpoint(device->endpoint); if (oc_do_delete("/oic/sec/acl2", ep, NULL, &obt_cert_14, HIGH_QOS, o)) { return; } err_obt_cert_13: oc_obt_free_otm_ctx(o, -1, OC_OBT_OTM_CERT); } static void obt_cert_12(oc_client_response_t *data) { if (!oc_obt_is_otm_ctx_valid(data->user_data)) { return; } OC_DBG("In obt_cert_12"); oc_otm_ctx_t *o = (oc_otm_ctx_t *)data->user_data; if (data->code >= OC_STATUS_BAD_REQUEST) { goto err_obt_cert_12; } /** 12) <close DTLS>+<Open-TLS-PSK>+ post pstat s=rfpro */ oc_device_t *device = o->device; oc_endpoint_t *ep = oc_obt_get_secure_endpoint(device->endpoint); oc_tls_close_connection(ep); oc_tls_select_psk_ciphersuite(); if (oc_init_post("/oic/sec/pstat", ep, NULL, &obt_cert_13, HIGH_QOS, o)) { oc_rep_start_root_object(); oc_rep_set_object(root, dos); oc_rep_set_int(dos, s, OC_DOS_RFPRO); oc_rep_close_object(root, dos); oc_rep_end_root_object(); if (oc_do_post()) { return; } } err_obt_cert_12: oc_obt_free_otm_ctx(o, -1, OC_OBT_OTM_CERT); } static void obt_cert_11(oc_client_response_t *data) { if (!oc_obt_is_otm_ctx_valid(data->user_data)) { return; } OC_DBG("In obt_cert_11"); oc_otm_ctx_t *o = (oc_otm_ctx_t *)data->user_data; o->sdi = true; if (data->code >= OC_STATUS_BAD_REQUEST) { if (data->code != OC_STATUS_NOT_FOUND) { goto err_obt_cert_11; } else { o->sdi = false; } } oc_sec_dump_cred(0); /** 11) post doxm owned = true */ oc_device_t *device = o->device; oc_endpoint_t *ep = oc_obt_get_secure_endpoint(device->endpoint); if (oc_init_post("/oic/sec/doxm", ep, NULL, &obt_cert_12, HIGH_QOS, o)) { oc_rep_start_root_object(); oc_rep_set_boolean(root, owned, true); oc_rep_end_root_object(); if (oc_do_post()) { return; } } err_obt_cert_11: oc_obt_free_otm_ctx(o, -1, OC_OBT_OTM_CERT); } static void obt_cert_10(oc_client_response_t *data) { if (!oc_obt_is_otm_ctx_valid(data->user_data)) { return; } OC_DBG("In obt_cert_10"); oc_otm_ctx_t *o = (oc_otm_ctx_t *)data->user_data; if (data->code >= OC_STATUS_BAD_REQUEST) { goto err_obt_cert_10; } oc_sec_sdi_t *sdi = oc_sec_get_sdi(0); char sdi_uuid[OC_UUID_LEN]; oc_uuid_to_str(&sdi->uuid, sdi_uuid, OC_UUID_LEN); /** 10) post sdi */ oc_device_t *device = o->device; oc_endpoint_t *ep = oc_obt_get_secure_endpoint(device->endpoint); if (oc_init_post("/oic/sec/sdi", ep, NULL, &obt_cert_11, HIGH_QOS, o)) { oc_rep_start_root_object(); oc_rep_set_text_string(root, uuid, sdi_uuid); oc_rep_set_text_string(root, name, oc_string(sdi->name)); oc_rep_set_boolean(root, priv, sdi->priv); oc_rep_end_root_object(); if (oc_do_post()) { return; } } err_obt_cert_10: oc_obt_free_otm_ctx(o, -1, OC_OBT_OTM_CERT); } static void obt_cert_9(oc_client_response_t *data) { if (!oc_obt_is_otm_ctx_valid(data->user_data)) { return; } OC_DBG("In obt_cert_9"); oc_otm_ctx_t *o = (oc_otm_ctx_t *)data->user_data; if (data->code >= OC_STATUS_BAD_REQUEST) { goto err_obt_cert_9; } oc_device_t *device = o->device; oc_endpoint_t *ep = oc_obt_get_secure_endpoint(device->endpoint); oc_uuid_t *my_uuid = oc_core_get_device_id(0); char uuid[OC_UUID_LEN]; oc_uuid_to_str(my_uuid, uuid, OC_UUID_LEN); char suuid[OC_UUID_LEN]; oc_uuid_to_str(&device->uuid, suuid, OC_UUID_LEN); #define OXM_MFG_CERT "oic.sec.doxm.mfgcert" uint8_t key[16]; bool derived = oc_sec_derive_owner_psk(ep, (const uint8_t *)OXM_MFG_CERT, strlen(OXM_MFG_CERT), device->uuid.id, 16, my_uuid->id, 16, key, 16); #undef OXM_MFG_CERT if (!derived) { goto err_obt_cert_9; } int credid = oc_sec_add_new_cred(0, false, NULL, -1, OC_CREDTYPE_PSK, OC_CREDUSAGE_NULL, suuid, OC_ENCODING_RAW, 16, key, 0, 0, NULL, NULL, NULL); if (credid == -1) { goto err_obt_cert_9; } oc_sec_cred_t *oc = oc_sec_get_cred_by_credid(credid, 0); if (oc) { oc->owner_cred = true; } /** 9) post cred rowneruuid, cred */ if (oc_init_post("/oic/sec/cred", ep, NULL, &obt_cert_10, HIGH_QOS, o)) { oc_rep_start_root_object(); oc_rep_set_array(root, creds); oc_rep_object_array_start_item(creds); oc_rep_set_int(creds, credtype, 1); oc_rep_set_text_string(creds, subjectuuid, uuid); oc_rep_set_object(creds, privatedata); oc_rep_set_text_string(privatedata, encoding, "oic.sec.encoding.raw"); oc_rep_set_byte_string(privatedata, data, (const uint8_t *)"", 0); oc_rep_close_object(creds, privatedata); oc_rep_object_array_end_item(creds); oc_rep_close_array(root, creds); oc_rep_set_text_string(root, rowneruuid, uuid); oc_rep_end_root_object(); if (oc_do_post()) { return; } } err_obt_cert_9: oc_obt_free_otm_ctx(o, -1, OC_OBT_OTM_CERT); } static void obt_cert_8(oc_client_response_t *data) { if (!oc_obt_is_otm_ctx_valid(data->user_data)) { return; } OC_DBG("In obt_cert_8"); oc_otm_ctx_t *o = (oc_otm_ctx_t *)data->user_data; if (data->code >= OC_STATUS_BAD_REQUEST) { goto err_obt_cert_8; } /** 8) post pstat rowneruuid */ oc_device_t *device = o->device; oc_endpoint_t *ep = oc_obt_get_secure_endpoint(device->endpoint); if (oc_init_post("/oic/sec/pstat", ep, NULL, &obt_cert_9, HIGH_QOS, o)) { oc_uuid_t *my_uuid = oc_core_get_device_id(0); char uuid[OC_UUID_LEN]; oc_uuid_to_str(my_uuid, uuid, OC_UUID_LEN); oc_rep_start_root_object(); oc_rep_set_text_string(root, rowneruuid, uuid); oc_rep_end_root_object(); if (oc_do_post()) { return; } } err_obt_cert_8: oc_obt_free_otm_ctx(o, -1, OC_OBT_OTM_CERT); } static void obt_cert_7(oc_client_response_t *data) { if (!oc_obt_is_otm_ctx_valid(data->user_data)) { return; } OC_DBG("In obt_cert_7"); oc_otm_ctx_t *o = (oc_otm_ctx_t *)data->user_data; if (data->code >= OC_STATUS_BAD_REQUEST) { goto err_obt_cert_7; } /** 7) post acl rowneruuid */ oc_device_t *device = o->device; oc_endpoint_t *ep = oc_obt_get_secure_endpoint(device->endpoint); if (oc_init_post("/oic/sec/acl2", ep, NULL, &obt_cert_8, HIGH_QOS, o)) { oc_uuid_t *my_uuid = oc_core_get_device_id(0); char uuid[OC_UUID_LEN]; oc_uuid_to_str(my_uuid, uuid, OC_UUID_LEN); oc_rep_start_root_object(); oc_rep_set_text_string(root, rowneruuid, uuid); oc_rep_end_root_object(); if (oc_do_post()) { return; } } err_obt_cert_7: oc_obt_free_otm_ctx(o, -1, OC_OBT_OTM_CERT); } static void obt_cert_6(oc_client_response_t *data) { if (!oc_obt_is_otm_ctx_valid(data->user_data)) { return; } OC_DBG("In obt_cert_6"); oc_otm_ctx_t *o = (oc_otm_ctx_t *)data->user_data; if (data->code >= OC_STATUS_BAD_REQUEST) { goto err_obt_cert_6; } /** 6) post doxm rowneruuid */ oc_device_t *device = o->device; oc_endpoint_t *ep = oc_obt_get_secure_endpoint(device->endpoint); if (oc_init_post("/oic/sec/doxm", ep, NULL, &obt_cert_7, HIGH_QOS, o)) { oc_uuid_t *my_uuid = oc_core_get_device_id(0); char uuid[OC_UUID_LEN]; oc_uuid_to_str(my_uuid, uuid, OC_UUID_LEN); oc_rep_start_root_object(); /* Set OBT's uuid as rowneruuid */ oc_rep_set_text_string(root, rowneruuid, uuid); oc_rep_end_root_object(); if (oc_do_post()) { return; } } err_obt_cert_6: oc_obt_free_otm_ctx(o, -1, OC_OBT_OTM_CERT); } static void obt_cert_5(oc_client_response_t *data) { if (!oc_obt_is_otm_ctx_valid(data->user_data)) { return; } OC_DBG("In obt_cert_5"); oc_otm_ctx_t *o = (oc_otm_ctx_t *)data->user_data; if (data->code >= OC_STATUS_BAD_REQUEST) { goto err_obt_cert_5; } /** 5) generate random deviceuuid; <store new peer uuid>; post doxm deviceuuid */ oc_uuid_t dev_uuid = { { 0 } }; oc_gen_uuid(&dev_uuid); char uuid[OC_UUID_LEN]; oc_uuid_to_str(&dev_uuid, uuid, OC_UUID_LEN); OC_DBG("generated deviceuuid: %s", uuid); oc_device_t *device = o->device; /* Store peer device's random uuid in local device object */ memcpy(device->uuid.id, dev_uuid.id, 16); oc_endpoint_t *ep = device->endpoint; while (ep) { memcpy(ep->di.id, dev_uuid.id, 16); ep = ep->next; } ep = oc_obt_get_secure_endpoint(device->endpoint); if (oc_init_post("/oic/sec/doxm", ep, NULL, &obt_cert_6, HIGH_QOS, o)) { oc_rep_start_root_object(); /* Set random uuid as deviceuuid */ oc_rep_set_text_string(root, deviceuuid, uuid); oc_rep_end_root_object(); if (oc_do_post()) { return; } } err_obt_cert_5: oc_obt_free_otm_ctx(o, -1, OC_OBT_OTM_CERT); } static void obt_cert_4(oc_client_response_t *data) { if (!oc_obt_is_otm_ctx_valid(data->user_data)) { return; } OC_DBG("In obt_cert_4"); oc_otm_ctx_t *o = (oc_otm_ctx_t *)data->user_data; if (data->code >= OC_STATUS_BAD_REQUEST) { goto err_obt_cert_4; } /** 4) post doxm devowneruuid */ oc_device_t *device = o->device; oc_endpoint_t *ep = oc_obt_get_secure_endpoint(device->endpoint); if (oc_init_post("/oic/sec/doxm", ep, NULL, &obt_cert_5, HIGH_QOS, o)) { oc_uuid_t *my_uuid = oc_core_get_device_id(0); char uuid[OC_UUID_LEN]; oc_uuid_to_str(my_uuid, uuid, OC_UUID_LEN); oc_rep_start_root_object(); /* Set OBT's uuid as devowneruuid */ oc_rep_set_text_string(root, devowneruuid, uuid); oc_rep_end_root_object(); if (oc_do_post()) { return; } } err_obt_cert_4: oc_obt_free_otm_ctx(o, -1, OC_OBT_OTM_CERT); } static void obt_cert_3(oc_client_response_t *data) { if (!oc_obt_is_otm_ctx_valid(data->user_data)) { return; } OC_DBG("In obt_cert_3"); oc_otm_ctx_t *o = (oc_otm_ctx_t *)data->user_data; if (data->code >= OC_STATUS_BAD_REQUEST) { goto err_obt_cert_3; } /** 3) <Open-TLS_ECDSA_with_Mfg_Cert>+post pstat om=4 */ oc_device_t *device = o->device; oc_endpoint_t *ep = oc_obt_get_secure_endpoint(device->endpoint); oc_tls_close_connection(ep); oc_tls_select_cert_ciphersuite(); if (oc_init_post("/oic/sec/pstat", ep, NULL, &obt_cert_4, HIGH_QOS, o)) { oc_rep_start_root_object(); oc_rep_set_int(root, om, 4); oc_rep_end_root_object(); if (oc_do_post()) { return; } } err_obt_cert_3: oc_obt_free_otm_ctx(o, -1, OC_OBT_OTM_CERT); } static void obt_cert_2(oc_client_response_t *data) { if (!oc_obt_is_otm_ctx_valid(data->user_data)) { return; } OC_DBG("In obt_cert_2"); oc_otm_ctx_t *o = (oc_otm_ctx_t *)data->user_data; if (data->code >= OC_STATUS_BAD_REQUEST) { goto err_obt_cert_2; } int64_t *oxms = NULL; size_t oxms_len = 0; if (oc_rep_get_int_array(data->payload, "oxms", &oxms, &oxms_len)) { size_t i; for (i = 0; i < oxms_len; i++) { if (oxms[i] == OC_OXMTYPE_MFG_CERT) { break; } } if (i == oxms_len) { goto err_obt_cert_2; } /** 2) post doxm oxmsel=2 */ oc_device_t *device = o->device; oc_endpoint_t *ep = oc_obt_get_unsecure_endpoint(device->endpoint); if (oc_init_post("/oic/sec/doxm", ep, NULL, &obt_cert_3, HIGH_QOS, o)) { oc_rep_start_root_object(); oc_rep_set_int(root, oxmsel, OC_OXMTYPE_MFG_CERT); oc_rep_end_root_object(); if (oc_do_post()) { return; } } } err_obt_cert_2: oc_obt_free_otm_ctx(o, -1, OC_OBT_OTM_CERT); } /* OTM sequence: 1) get doxm 2) post doxm oxmsel=2 3) <Open-TLS_ECDSA_with_Mfg_Cert>+post pstat om=4 4) post doxm devowneruuid 5) generate random deviceuuid; <store new peer uuid>; post doxm deviceuuid 6) post doxm rowneruuid 7) post acl rowneruuid 8) post pstat rowneruuid 9) post cred rowneruuid, cred 10) post sdi 11) post doxm owned = true 12) <close DTLS>+<Open-TLS-PSK>+post pstat s=rfpro 13) delete acl2 14) post acl2 with ACEs for res, p, d, csr, sp 15) post pstat s=rfnop 16) <close DTLS> */ int oc_obt_perform_cert_otm(oc_uuid_t *uuid, oc_obt_device_status_cb_t cb, void *data) { OC_DBG("In oc_obt_perform_cert_otm"); oc_device_t *device = oc_obt_get_cached_device_handle(uuid); if (!device) { return -1; } if (oc_obt_is_owned_device(uuid)) { char subjectuuid[OC_UUID_LEN]; oc_uuid_to_str(uuid, subjectuuid, OC_UUID_LEN); oc_cred_remove_subject(subjectuuid, 0); } oc_otm_ctx_t *o = oc_obt_alloc_otm_ctx(); if (!o) { return -1; } o->cb.cb = cb; o->cb.data = data; o->device = device; /** 1) get doxm */ oc_endpoint_t *ep = oc_obt_get_unsecure_endpoint(device->endpoint); if (oc_do_get("/oic/sec/doxm", ep, NULL, &obt_cert_2, HIGH_QOS, o)) { return 0; } oc_obt_free_otm_ctx(o, -1, OC_OBT_OTM_CERT); return -1; } #else /* OC_PKI */ typedef int dummy_declaration; #endif /* !OC_PKI */ #endif /* OC_SECURITY */
the_stack_data/667585.c
/*Implemente um programa que recebe um vetor de inteiros e depois um outro número inteiro que será chamado de chave de busca. Deve-se procurar essa chave dentro do vetor. Se o vetor contém essa chave imprima o índice onde ele se encontra, caso contrário, imprima -1. O tamanho do vetor será o primeiro número informado, depois o vetor de inteiros e por fim a chave de busca.*/ #include <stdio.h> int main(){ int rod, ret = -1; scanf("%d", &rod); int vet[rod]; for(int cont = 0; cont < rod; cont++){ scanf("%d", &vet[cont]); }//fim for1 int busca; scanf("%d", &busca); for(int cont = 0; cont < rod; cont++){ if(vet[cont] == busca){ ret = cont; break; }//fim if }//fim for2 printf("%d", ret); return 0; }
the_stack_data/1027720.c
int dct_lock(int write) { return 0; } int dct_unlock(int write) { return 0; }
the_stack_data/76700409.c
#include <stdio.h> struct X_t { int x; } typedef X; main() { int a = 3; int *x = &a; X b; X *y = &b; struct X_t c; struct X_t *z = &c; c.x = 3; z->x = 3; printf("%d\n", z->x); }
the_stack_data/863096.c
#include <stdio.h> int main(void) { printf("%4.6d", 123); return 0; }
the_stack_data/770734.c
#include <stdio.h> typedef struct ponto_s { double x; double y; } ponto; typedef struct circulo_s { ponto centro; double raio; } circulo; double dist2 (ponto p1, ponto p2) { return (p1.x-p2.x)*(p1.x-p2.x) + (p1.y-p2.y)*(p1.y-p2.y); } int dentro (circulo c, ponto p) { if (dist2(c.centro, p)<= c.raio*c.raio) return 1; else return 0; } int main(void) { circulo c; ponto p; scanf("%lf %lf", &p.x, &p.y); scanf("%lf %lf %lf", &c.centro.x, &c.centro.y, &c.raio); if(dentro(c,p)) printf("DENTRO\n"); else printf("FORA\n"); return 0; }
the_stack_data/243894401.c
#include<stdio.h> void fun(int A[], int n) { int i; for(i=0; i<n; i++) printf("%d",A[i]); } int main() { int A[5] = {2,4,6,8,10}; fun(A,5); }
the_stack_data/125141365.c
/* Copyright (c) 2012, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials provided * with the distribution. * * Neither the name of The Linux Foundation 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 "AS IS" AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT * ARE 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 <string.h> #include <sys/types.h> void strrev(unsigned char *str) { int i; int j; unsigned char a; unsigned len = strlen((const char *)str); for (i = 0, j = len - 1; i < j; i++, j--) { a = str[i]; str[i] = str[j]; str[j] = a; } }
the_stack_data/58135.c
int test003(){return ((((123))));}
the_stack_data/150484.c
#include <stdio.h> void function( int nWidth, int nHeight, char array[nHeight][nWidth]) { for (int i = 0; i < nHeight; i++) for (int j = 0; j < nWidth; j++) array[i][j] = 0; } int main( int argc, char ** argv ) { int x = 666; int y = 123; char bigArray[ x * y ]; // big flat arrray char (*simpleArray)[y][x] = (char (*)[y][x]) bigArray; function( x, y, *((char (*)[y][x]) bigArray) //ok: *simpleArray ); return 0; }
the_stack_data/272371.c
int main(int argc, char **argv) { int a[10]; a[0] = 0; return a[10 + argc]; // maybe BOOM }
the_stack_data/70450802.c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_strdel.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: jwinthei <[email protected]> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2018/11/23 17:11:29 by jwinthei #+# #+# */ /* Updated: 2018/11/23 17:56:03 by jwinthei ### ########.fr */ /* */ /* ************************************************************************** */ #include <stdlib.h> void ft_strdel(char **as) { if (!(as && *as)) return ; free(*as); *as = NULL; }
the_stack_data/192331076.c
#include<stdio.h> #define MAXN 100 #define ORDER 4 main() { float ax[MAXN+1], ay [MAXN+1], diff[MAXN+1][ORDER+1], nr=1.0, dr=1.0,x,p,h,yp; int n,i,j,k; printf("\nEnter the value of n:\n"); scanf("%d",&n); printf("\nEnter the values in form x,y:\n"); for (i=0;i<=n;i++) scanf("%f %f",&ax[i],&ay[i]); printf("\nEnter the value of x for which the value of y is wanted: \n"); scanf("%f",&x); h=ax[1]-ax[0]; //now making the difference table //calculating the 1st order of differences for (i=0;i<=n-1;i++) diff[i][1] = ay[i+1]-ay[i]; //now calculating the second and higher order differences for (j=2;j<=ORDER;j++) for(i=0;i<=n-j;i++) diff[i][j] = diff[i+1][j-1] - diff[i][j-1]; //now finding x0 i=0; while (!(ax[i]>x)) i++; //now ax[i] is x0 and ay[i] is y0 i--; p = (x-ax[i])/h; yp = ay[i]; //now carrying out interpolation for (k=1;k<=ORDER;k++) { nr *=p-k+1; dr *=k; yp +=(nr/dr)*diff[i][k]; } printf("\nWhen x = %6.1f, corresponding y = %6.2f\n",x,yp); }
the_stack_data/54825875.c
#include <inttypes.h> struct x; /* incomplete type */ /* valid uses of the tag */ struct x *p, func(); void f1() { struct x { int32_t i; }; /* redeclaration! */ } /* full declaration now */ struct x { float f; } s_x; void f2() { /* valid statements */ p = &s_x; *p = func(); s_x = func(); } struct x func() { struct x tmp; tmp.f = 0; return tmp; }
the_stack_data/808544.c
#include <stdio.h> int main(void) { int n; int a, b, c; scanf("%d", &n); scanf("%d%d%d", &a, &b, &c); printf("%d %d %d\n", n / (a + b + c) * a, n / (a + b + c) * b, n / (a + b + c) * c); return 0; }
the_stack_data/34513314.c
#include<stdio.h> int main() { int broi,pari,namalenie,i; scanf("%d", &broi); scanf("%d", &pari); scanf("%d", &namalenie); float sum=0; i=0; float procent_otstupka =0.0; do { sum= sum + namalenie* pari * (1 - procent_otstupka); procent_otstupka= procent_otstupka + 0.02; i=i+namalenie; }while(i < broi); printf("%.f", sum); return 0; }
the_stack_data/89200262.c
#include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <time.h> uint64_t gcd(uint64_t a, uint64_t b) { if (a < b) { uint64_t t = a; a = b; b = t; } uint64_t r; while (r = a % b) { a = b; b = r; } return b; } uint64_t lcm(uint64_t a, uint64_t b) { return a * b / gcd(a, b); } __attribute__((always_inline)) inline uint64_t f() { uint64_t n = 2; uint64_t i; for (i = 3; i < 21; i++) n = lcm(n, i); return n; } int64_t to_ns(struct timespec ts) { return (uint64_t)ts.tv_sec * 1000000000lu + (uint64_t)ts.tv_nsec; } int main(int argc, char *argv[]) { if (argc == 1) { printf("%lu\n", f()); } else if (argc == 2) { struct timespec start = {0, 0}, end = {0, 0}; uint64_t i = 0; uint64_t iters = atol(argv[1]); clock_gettime(CLOCK_MONOTONIC, &start); for (; i < iters; i++) { f(); asm(""); } clock_gettime(CLOCK_MONOTONIC, &end); printf("%lu", to_ns(end) - to_ns(start)); } else { return EXIT_FAILURE; } return EXIT_SUCCESS; }
the_stack_data/15029.c
#include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <unistd.h> int main() { int mypid, myppid; printf("This is the main() program\n"); printf("I would like to know the PID and PPID's information\n"); mypid = getpid(); myppid = getppid(); printf("The process ID is %d\n", mypid); printf("The parent process ID is %d\n", myppid); return 0; }
the_stack_data/1145287.c
#include <stdio.h> int med[105],tim[105],dp[1005]; int max(int a,int b){ #ifdef DEBUG printf("max:%d,%d\n",a,b); #endif return a>b?a:b; } int main(void){ int T,M; scanf("%d%d",&T,&M); for(int i=0;i<M;i++) scanf("%d%d",tim+i,med+i); #ifdef DEBUG printf("T=%d,M=%d\n",T,M); #endif for(int i=0;i<M;i++){ for(int j=T;j>=0;j--){ if(j<tim[i]) dp[j]=dp[j]; else dp[j]=max(dp[j],dp[j-tim[i]]+med[i]); } } printf("%d\n",dp[T]); return 0; }
the_stack_data/1052036.c
/* ヘッダファイルのインクルード */ #include <stdio.h> /* 標準入出力 */ #include <string.h> /* 文字列処理 */ #include <stdlib.h> /* 標準ライブラリ */ #include <unistd.h> /* UNIX標準 */ #include <sys/types.h> /* 派生型 */ #include <sys/socket.h> /* ソケット */ #include <netinet/in.h> /* AF_INET, AF_INET6アドレス・ファミリー */ #include <arpa/inet.h> /* IPアドレス変換 */ #include <signal.h> /* シグナル */ #include <time.h> /* UNIX時間 */ /* モジュール変数の宣言 */ int server_soc; /* サーバソケットserver_soc */ /* 関数のプロトタイプ宣言 */ void quit_signal_handler(int sig); /* 終了シグナル */ int create_http_server_socket(int port, struct sockaddr_in *server_addr); /* HTTPサーバソケット作成. */ int accept_loop(int soc); /* アクセプトループ */ /* main関数の定義 */ int main(int argc, char *argv[]){ /* argcは引数の個数, argvは各引数文字列へのポインタを格納した配列. */ /* 変数の宣言 */ int port; /* 待ち受けポート番号. */ struct sockaddr_in server_addr; /* サーバアドレスserver_addr */ /* main関数の引数が2つの時以外は終了. */ if (argc != 2){ /* 2つではない. */ /* "Not enough input arguments."と出力. */ printf("Not enough input arguments.\n"); /* printfで"Not enough input arguments."と出力. */ return -1; /* -1を返して異常終了. */ } /* argv[1]をポート番号として受け取る. */ port = atoi(argv[1]); /* atoiで, argv[1]をint型に変換し, portに格納. */ /* シグナルハンドラのセット */ signal(SIGINT, quit_signal_handler); /* signalでquit_signal_handlerをセット. */ /* サーバソケット作成とリッスン. */ server_soc = create_http_server_socket(port, &server_addr); /* create_http_server_socketでサーバソケットを作成し, server_socに格納. */ if (server_soc < 0){ /* 0未満は失敗. */ printf("Create HTTP Server Socket failed!\n"); /* printfで"Create HTTP Server Socket failed!\n"と出力. */ return -2; /* -2を返して異常終了. */ } /* "Create Server Socket and Listen."と出力. */ printf("Create Server Socket and Listen.\n"); /* "Create Server Socket and Listen."と出力. */ /* アクセプトループ */ accept_loop(server_soc); /* accept_loopでアクセプト. */ /* サーバソケットを閉じる. */ close(server_soc); /* closeでserver_socを閉じる. */ /* 正常終了 */ return 0; /* 0を返して正常終了. */ } /* 終了シグナル */ void quit_signal_handler(int sig){ /* 受け取ったシグナルを出力. */ printf("sig = %d\n", sig); /* sigを出力. */ /* サーバソケットを閉じる. */ close(server_soc); /* closeでserver_socを閉じる. */ exit(-1); /* -1を返して強制終了. */ } /* HTTPサーバソケット作成 */ int create_http_server_socket(int port, struct sockaddr_in *server_addr){ /* 変数の初期化 */ int soc = -1; /* ソケットsocを-1で初期化. */ int yes = 1; /* アドレス再利用yesを1で初期化. */ /* ソケット作成 */ soc = socket(AF_INET, SOCK_STREAM, 0); /* socketでソケットを作成し, socに格納. */ if (soc < 0){ /* 0未満はエラー. */ perror("socket"); /* "socket"エラー. */ return -1; /* -1を返して異常終了. */ } /* ソケットオプション設定 */ setsockopt(soc, SOL_SOCKET, SO_REUSEADDR, (const char *)&yes, sizeof(yes)); /* アドレス再利用をyesでセット. */ /* バインド */ server_addr->sin_family = AF_INET; /* ファミリーはAF_INET. */ server_addr->sin_port = htons(port); /* ポートはport.(htonsで変換すること.) */ server_addr->sin_addr.s_addr = INADDR_ANY; /* 受け付けはどこでも可. */ if (bind(soc, (struct sockaddr *)server_addr, sizeof(struct sockaddr_in)) != 0){ /* 0以外なら失敗. */ perror("bind"); /* "bind"エラー. */ close(soc); /* closeでsocを閉じる. */ return -2; /* -2を返して異常終了. */ } /* リッスン */ if (listen(soc, 5) != 0){ /* 0以外なら失敗. */ perror("listen"); /* "listen"エラー. */ close(soc); /* closeでsocを閉じる. */ return -3; /* -3を返して異常終了. */ } /* 成功ならsocを返す. */ return soc; /* socを返す. */ } /* アクセプトループ */ int accept_loop(int soc){ /* 変数の宣言と初期化. */ struct sockaddr_in client_addr; /* クライアントアドレスclient_addr */ int client_addr_len; /* client_addrの長さclient_addr_len. */ int acc; /* アクセプトソケットacc */ char *client_ip_addr_str; /* クライアントのIPアドレス文字列へのポインタclient_ip_addr_str. */ u_short client_port; /* クライアントのポート番号client_port. */ int ret = 0; /* ループ抜ける時の理由ret. */ char recv_buf[4096] = {0}; /* recv_buf(長さ4096)を{0}で初期化. */ char send_buf[4096] = {0}; /* send_buf(長さ4096)を{0}で初期化. */ char response_header[4096] = {0}; /* response_header(長さ4096)を{0}で初期化. */ char response_body[4096] = {0}; /* response_body(長さ4096)を{0}で初期化. */ time_t t; /* 現在のUNIX時間t. */ struct tm *tm_ptr; /* tm構造体へのポインタtm_ptr. */ char time_str[128]; /* 時刻文字列time_str. */ int content_length = 0; /* Content-Lengthの値を0で初期化. */ char content_length_str[128]; /* Content-Lengthの値を文字列にしたものcontent_length_str. */ /* 終わるまでループ. */ while (1){ /* 無限ループ. */ /* アクセプト処理 */ client_addr_len = sizeof(client_addr); /* サイズ取得 */ acc = accept(soc, (struct sockaddr *)&client_addr, &client_addr_len); /* acceptでaccやclient_addrを取得. */ if (acc < 0){ /* 0未満は終了. */ perror("accept"); /* "accept"エラー. */ ret = -1; /* "accept"エラーはretが-1. */ break; /* ループから抜ける. */ } /* クライアント情報の表示 */ client_ip_addr_str = inet_ntoa(client_addr.sin_addr); /* inet_ntoaでクライアントのclient_addr.sin_addrをIPアドレス文字列に変換. */ client_port = ntohs(client_addr.sin_port); /* ntohsでクライアントのclient_addr.sin_portを符号なし10進整数のポート番号に変換. */ printf("accept!(IPAddress = %s, Port = %hu)\n", client_ip_addr_str, client_port); /* IPアドレスとポートを表示. */ /* 読み込み */ memset(recv_buf, 0, sizeof(char) * 4096); /* recv_bufをクリア. */ recv(acc, recv_buf, sizeof(recv_buf), 0); /* recvでaccから読み込み, recv_bufに格納. */ printf("----- recv begin -----\n"); /* recv beginフォームを出力. */ printf("%s\n", recv_buf); /* recv_bufを出力. */ printf("----- recv end -----\n"); /* recv endフォームを出力. */ /* 現在時刻文字列の作成. */ t = time(NULL); /* timeでtを取得. */ tm_ptr = gmtime(&t); /* gmtimeでtm_ptrを取得. */ strftime(time_str, sizeof(time_str), "%Y/%m/%d %H:%M:%S %Z", tm_ptr); /* strftimeでtime_str作成. */ /* レスポンスボディの作成. */ strcpy(response_body, "<html>\r\n"); /* response_bodyに"<hmtl>\r\n"をコピー. */ strcat(response_body, " <head>\r\n"); /* response_bodyに" <head>\r\n"を連結. */ strcat(response_body, " <title>Content-Type</title>\r\n"); /* response_bodyに" <title>Content-Type</title>\r\n"を連結. */ strcat(response_body, " </head>\r\n"); /* response_bodyに" </head>\r\n"を連結. */ strcat(response_body, " <body>\r\n"); /* response_bodyに" <body>\r\n"を連結. */ strcat(response_body, " "); /* response_bodyに" "を連結. */ strcat(response_body, time_str); /* response_bodyにtime_strを連結. */ strcat(response_body, "\r\n"); /* response_bodyに"\r\n"を連結. */ strcat(response_body, " </body>\r\n"); /* response_bodyに" </body>\r\n"を連結. */ strcat(response_body, "</html>\r\n"); /* response_bodyに"</html>\r\n"を連結. */ /* レスポンスヘッダの作成. */ strcpy(response_header, "HTTP/1.0 200 OK\r\n"); /* response_headerに"HTTP/1.0 200 OK\r\n"をコピー. */ strcat(response_header, "Content-Length: "); /* response_headerに"Content-Length: "を連結. */ content_length = strlen(response_body); /* response_bodyの長さをstrlenで取得し, content_lengthに格納. */ sprintf(content_length_str, "%d", content_length); /* sprintfでcontent_lengthを文字列content_length_strに変換. */ strcat(response_header, content_length_str); /* response_headerにcontent_length_strを連結. */ strcat(response_header, "\r\n"); /* response_headerに"\r\n"を連結. */ strcat(response_header, "Content-Type: text/html\r\n"); /* response_headerに"Content-Type: text/html\r\n"を連結. */ /*strcat(response_header, "Expires: Sat, 31 Dec 2022 12:00:00 GMT\r\n");*/ /* response_headerに"Expires: Sat, 31 Dec 2022 12:00:00 GMT\r\n"を連結. */ strcat(response_header, "Pragma: no-cache\r\n"); /* response_headerに"Pragma: no-cache\r\n"を連結. */ /* レスポンスの送信. */ strcpy(send_buf, response_header); /* send_bufにresponse_headerをコピー. */ strcat(send_buf, "\r\n"); /* send_bufに"\r\n"を連結. */ strcat(send_buf, response_body); /* send_bufにresponse_bodyを連結. */ send(acc, send_buf, strlen(send_buf), 0); /* send_bufを送信. */ /* アクセプトしたクライアントソケットファイルディスクリプタを閉じる. */ close(acc); /* closeでaccを閉じる. */ } /* retを返す. */ return ret; /* retを返して終了. */ }
the_stack_data/50136809.c
// cagconv.c // cagconv // // Created by Dr. Rolf Jansen on 2019-06-07. // Copyright © 2019-2021 Dr. Rolf Jansen. 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 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. // // Usage: // // 1. Compile this file on either of FreeBSD, Linux or macOS: // // cc -g0 -O3 cagconv.c -Wno-parentheses -lm -o cagconv // // 2. Download the monthly time series of the global surface temperature anomalies // from NOAA's site Climate at a Glance - https://www.ncdc.noaa.gov/cag/global/time-series // // curl -O https://www.ncdc.noaa.gov/cag/global/time-series/globe/land_ocean/all/12/1880-2021.csv // // 3. Convert the YYYYMM date literals to decimal years and write it // out together with the temperature anomalies to the TSV foutput file: // // ./cagconv 1880-2021.csv gta-1880-2021.tsv // // 4. Open the TSV file with your favorite graphing and/or data analysis application, // for example with CVA - https://cyclaero.com/en/downloads/CVA #include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <stdint.h> #include <math.h> // - 1 2 3 4 5 6 7 8 9 10 11 12 double commYearMids[13] = {182.5, 15.5, 45.0, 74.5, 105.0, 135.5, 166.0, 196.5, 227.5, 258.0, 288.5, 319.0, 349.5}; double leapYearMids[13] = {183.0, 15.5, 45.5, 75.5, 106.0, 136.5, 167.0, 197.5, 228.5, 259.0, 289.5, 320.0, 350.5}; static inline bool isLeapYear(int year) { return (year % 4) ? false : (year % 100) ? true : (year % 400) ? false : true; } static inline unsigned char *skip(unsigned char *s) { for (;;) switch (*s) { case '\t'...'\r': case ' ': s++; break; default: return s; } } int main(int argc, char *const argv[]) { FILE *csv, *tsv; if (csv = (*(uint16_t *)argv[1] == *(uint16_t *)"-") ? stdin : fopen(argv[1], "r")) { if (tsv = (*(uint16_t *)argv[2] == *(uint16_t *)"-") ? stdout : fopen(argv[2], "w")) { unsigned char *line; char data[256]; fprintf(tsv, "# Time base: 30.44\n" "# Time unit: d\n"); // Copy over blank and descriptive text lines to the output file. while ((line = (unsigned char *)fgets(data, 256, csv)) && (*(line = skip(line)) < '0' || '9' < *line)) fprintf(tsv, "# %s", line); if (line) { // Write the column header using SI formular symbols and units. // - the formular symbol of time is 't' // the unit symbol of year is 'a' // - formular symbol of celsius temperatures is '𝜗' (lower case theta) // in general, differences are designated by 'Δ' (greek capital letter delta) // the unit symbol of (Celsius) centigrade is '°C' fprintf(tsv, "t/a\tΔ𝜗/°C\n"); do if ('0' <= *line && *line <= '9' || *line == '-') { // Read the CSV data. // Convert the YYYYMM date literals to decimal years and write it // out together with the temperature anomalies to the TSV foutput file. char *p, *q; double ym = strtod((char *)line, &p); if (ym > 0.0) // missing values are designated by -999 { ym /= 100.0; int y = (int)lround(floor(ym)), m = (int)lround((ym - y)*100.0); double t = y + ((isLeapYear(y)) ? leapYearMids[m]/366.0 : commYearMids[m]/365.0); while (*p && *p++ != ','); double an = strtod(q = p, &p); if (an > -999.0) // missing values are designated by -999 if (p != q) fprintf(tsv, "%.5f\t%.3f\n", t, an); else break; } else if (ym == 0.0 && p == (char *)line) break; // a number conversion error occurred } while ((line = (unsigned char *)fgets(data, 256, csv)) && *(line = skip(line))); } if (tsv != stdout) fclose(tsv); } if (csv != stdin) fclose(csv); } return 0; }
the_stack_data/90763504.c
/* Copyright (C) 2000, 2001 Silicon Graphics, Inc. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of version 2.1 of the GNU Lesser General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Further, this software is distributed without any warranty that it is free of the rightful claim of any third person regarding infringement or the like. Any license provided herein, whether implied or otherwise, applies only to this software file. Patent licenses, if any, provided herein do not apply to combinations of this program with other software, or any other product whatsoever. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pky, Mountain View, CA 94043, or: http://www.sgi.com For further information regarding this notice, see: http://oss.sgi.com/projects/GenInfo/NoticeExplan */ #pragma ident "@(#) libu/clib/getpgrp.c 92.1 07/01/99 13:42:20" long GETPGRP() { return((long)getpgrp()); }
the_stack_data/162643392.c
#include <stdio.h> #include <stdlib.h> //linked list node (self referential structure) struct node { int data; struct node *next; }; void insertAtBeginning(struct node **head, int data) { // allocate new node struct node *temp = (struct node*) malloc(sizeof(struct node)); temp->data = data; temp->next = (*head); *head = temp; } int detectLoop(struct node *head) { struct node *fastPtr, *slowPtr; for(fastPtr=head, slowPtr=head; fastPtr&&slowPtr&&fastPtr->next;) { fastPtr = fastPtr->next->next; slowPtr = slowPtr->next; if (fastPtr == slowPtr) return 1; } return 0; } struct node *findStartNodeOfLoop(struct node *head) { struct node *fastPtr, *slowPtr; for(fastPtr=head, slowPtr=head; fastPtr&&slowPtr&&fastPtr->next;) { fastPtr = fastPtr->next->next; slowPtr = slowPtr->next; if (fastPtr == slowPtr) break; } slowPtr = head; while(slowPtr != fastPtr) { slowPtr = slowPtr->next; fastPtr = fastPtr->next; } return slowPtr; } int main() { struct node *head = NULL, *loopStartNode; int flag; insertAtBeginning(&head, 10); insertAtBeginning(&head, 20); insertAtBeginning(&head, 30); insertAtBeginning(&head, 40); insertAtBeginning(&head, 50); head->next->next->next->next = head->next->next; flag = detectLoop(head); printf(flag?"Loop Found": "Loop Not Found"); if(flag) loopStartNode = findStartNodeOfLoop(head); printf("\nstarting node of loop is = %d", loopStartNode->data); return 1; }
the_stack_data/424847.c
#include <stdio.h> #include <stdint.h> typedef struct NodeID { uint64_t plogID; uint16_t offset; } nodeId_T; #define INVALID_ID ((nodeId_T){-1, -1}) #define getPlogId(id) (id.plogID) #define getOffset(id) (id.offset) #define NODE_PTR_BIT 1UL #define NODE_MASK_BITS (3UL) #define NODE_PTR_MASK (((1UL) << NODE_MASK_BITS) - 1) #define NODE_TO_ID(node) ((nodeId_T){((uint64_t)node) | NODE_PTR_BIT, -1}) /** * c语言无法用==判断两个结构体变量是否相等 */ #define IS_NODE_DIRTY(node) (id.plogID == INVALID_ID.plogID && id.offset == INVALID_ID.offset) int main(){ nodeId_T id = NODE_TO_ID(8); printf("plogID:%llu offset:%u\n", getPlogId(id), getOffset(id)); id = (nodeId_T){(uint64_t)-1, -1}; printf("id == INVALID_ID: %d\n", IS_NODE_DIRTY(id)); printf("NODE_PTR_MASK: %lu\n", NODE_PTR_MASK); return 0; }
the_stack_data/92326078.c
#include <stdio.h> #include <stdlib.h> #include <fcntl.h> #include <unistd.h> #include <string.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/select.h> #define BUFSIZE 128 #define NAME "test_fifo" int main(int argc, char *argv[]) { int fd; char buf[BUFSIZE]; // 创建有名管道 if (access(NAME, 0) == -1) if ((mkfifo(NAME, 0666)) != 0) { perror("mkfifo"); exit(1); } // 读写方式打开管道 if ((fd = open(NAME, O_RDWR)) < 0){ perror("open"); exit(1); } // 往管道里写内容 while (1){ printf("Send msg: "); scanf("%s", buf); write(fd, buf, strlen(buf)); if (strcmp("quit", buf) == 0) break; } return 0; }
the_stack_data/51700726.c
#include<stdio.h> #include<math.h> float sineseries(int x,int n); void main() { int n,x; printf("Enter n \n"); scanf("%d",&n); printf("Enter the value of x \n"); scanf("%d",&x); float sum=sineseries(x,n); printf("The sum of the series is %f",sum); } float sineseries(int x,int n) { int fact(int k); float sum=0.0f; int i=1; for(int j=1;i<=n;j=j+2,i++) { if(i%2!=0) sum=sum+pow(x,j)/fact(j); else sum=sum-pow(x,j)/fact(j); } return sum; } int fact(int j) { int fact=1; for(int i=1;i<=j;i++) fact=fact*i; return fact; }
the_stack_data/125392.c
#include <stdio.h> #include <malloc.h> #include <stdlib.h> typedef struct node { int data; struct node *next; }NODE; int main() { NODE *head,*first,*temp=0; int c=0,ch=1; first=0; while(ch) { head = (NODE *)malloc(sizeof(NODE)); printf("Enter the data item\n"); scanf("%d", &head-> data); if (first != 0) { temp->next = head; temp = head; } else { first = temp = head; } fflush(stdin); printf("Do you want to continue(Type 0 or 1)?\n"); scanf("%d", &ch); } temp = first; printf("\n Data items of the linked list is\n"); while (temp != 0) { printf("%d=>", temp->data); c++; temp = temp -> next; } printf("NULL\n"); printf("No. of nodes in the list = %d\n", c); return 0; }
the_stack_data/64199667.c
#include <sys/types.h> #include <unistd.h> #include <stdio.h> int main() { int pid; pid = fork(); if (pid != 0) { printf("Soy el proceso padre.\n"); } else { printf("Soy el proceso hijo.\n"); } }
the_stack_data/90761857.c
/* / PROBLEMA 15: / /Conversii explicite. Se citeste un caracter a. /Sa se afiseze codul sau ASCII. /Se citeste un numar natural c din intervalul[32,127]. /Sa se afiseze caracterul cu codul ASCII c. / / (C) 2019 - OLARIU ALEXANDRU RAZVAN */ #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> void main(void) { for (int k = 0; k <= 255; k++) // for loop from 0-255 { printf("\nThe ascii value of %c is %d", k, k); } }
the_stack_data/60674.c
#include <stdio.h> #include <string.h> int main(int argc, char **argv) { if (argc < 2) { printf("String argument required \n"); return 1; } if (argc > 2) { printf("Too many arguments \n"); return 1; } char *s = argv[1]; size_t length = strlen(s); char stack[length]; char *p = stack; while (*s != '\0') { *p = *s; p++; s++; } while (p-- + 1 != stack) { printf("%c", *p); } printf("\n"); return 0; }
the_stack_data/187642415.c
/* command----------------------------------------------------------------lassen439_81565_tests_group_1_test_4.c $ /usr/tce/packages/xl/xl-2019.02.07/bin/xlc -o test_O0 -O0 test.c -lm $ ./test_O0 -1.6345E-315 +1.5539E305 -1.1615E98 +0.0 +0.0 +1.3777E61 -1.4301E-111 -1.0690E-306 -0.0 -1.8003E-307 -1.3774E305 -1.2654E-323 -1.2247E305 -0.0 +1.1950E-306 -0.0 -1.6139E306 +1.2291E-323 -1.1982E-322 +1.0388E-307 -1.1618E306 +1.5091E-306 +1.0140E-319 +1.2503E-307 -1.6344999998478317e-315 $ /usr/tce/packages/xl/xl-2019.02.07/bin/xlc -o test_O3 -O3 test.c -lm $ ./test_O3 -1.6345E-315 +1.5539E305 -1.1615E98 +0.0 +0.0 +1.3777E61 -1.4301E-111 -1.0690E-306 -0.0 -1.8003E-307 -1.3774E305 -1.2654E-323 -1.2247E305 -0.0 +1.1950E-306 -0.0 -1.6139E306 +1.2291E-323 -1.1982E-322 +1.0388E-307 -1.1618E306 +1.5091E-306 +1.0140E-319 +1.2503E-307 1.3776999999999999e+61 --------------------------------------------------------------------------*/ /* This is a automatically generated test. Do not modify */ #include <stdio.h> #include <stdlib.h> #include <math.h> void compute(double comp, double var_1,double var_2,double var_3,double var_4,double var_5,double var_6,double var_7,double var_8,double var_9,double var_10,double var_11,double var_12,double var_13,double var_14,double var_15,double var_16,double var_17,double var_18,double var_19,double var_20,double var_21,double var_22,double var_23) { if (comp >= -1.2482E-57 - var_1 * var_2 * -0.0) { if (comp <= var_3 - var_4) { comp = (+1.8155E-323 + var_5 + var_6 / var_7 * var_8); if (comp == var_9 * (+1.2906E-318 - (var_10 / var_11))) { comp += (var_12 + (var_13 / var_14 - (var_15 / var_16))); } if (comp > (-1.3331E-311 * tanh((var_17 + var_18 + var_19 / acos(atan((-1.0997E306 / fmod(-1.9139E-316 * -1.5128E-315, (var_20 / (+1.2580E-307 * atan(+1.1374E-72 - asin(var_21 - var_22 - log(+1.1744E-319 - fabs(+1.5959E305 + -1.0077E-307)))))))))))))) { comp += +1.0999E-311 / (+1.7373E-307 + (-1.0443E306 - var_23)); } } } printf("%.17g\n", comp); } double* initPointer(double v) { double *ret = (double*) malloc(sizeof(double)*10); for(int i=0; i < 10; ++i) ret[i] = v; return ret; } int main(int argc, char** argv) { /* Program variables */ double tmp_1 = atof(argv[1]); double tmp_2 = atof(argv[2]); double tmp_3 = atof(argv[3]); double tmp_4 = atof(argv[4]); double tmp_5 = atof(argv[5]); double tmp_6 = atof(argv[6]); double tmp_7 = atof(argv[7]); double tmp_8 = atof(argv[8]); double tmp_9 = atof(argv[9]); double tmp_10 = atof(argv[10]); double tmp_11 = atof(argv[11]); double tmp_12 = atof(argv[12]); double tmp_13 = atof(argv[13]); double tmp_14 = atof(argv[14]); double tmp_15 = atof(argv[15]); double tmp_16 = atof(argv[16]); double tmp_17 = atof(argv[17]); double tmp_18 = atof(argv[18]); double tmp_19 = atof(argv[19]); double tmp_20 = atof(argv[20]); double tmp_21 = atof(argv[21]); double tmp_22 = atof(argv[22]); double tmp_23 = atof(argv[23]); double tmp_24 = atof(argv[24]); compute(tmp_1,tmp_2,tmp_3,tmp_4,tmp_5,tmp_6,tmp_7,tmp_8,tmp_9,tmp_10,tmp_11,tmp_12,tmp_13,tmp_14,tmp_15,tmp_16,tmp_17,tmp_18,tmp_19,tmp_20,tmp_21,tmp_22,tmp_23,tmp_24); return 0; }
the_stack_data/47132.c
/* ** my_power_rec.c for my_power_rec in /home/thibrex/delivery/CPool_Day05_no_repo/tests ** ** Made by Cornolti Thibaut ** Login <[email protected]> ** ** Started on Fri Oct 7 11:41:06 2016 Cornolti Thibaut ** Last update Sun Nov 6 22:22:26 2016 yann probst */ int my_power_rec(int nb, int p) { if (p < 0) return (0); else if (p == 0) return (1); else return (nb*my_power_rec(nb, p-1)); }
the_stack_data/154830528.c
typedef int Item; #define key(A) A #define less(A, B) (key(A) < key(B)) #define exch(A, B) {Item t = A; A = B; B = t;} #define cmpexch(A, B) {if(less(B, A)) exch(A, B)} void insertionsortH(Item *v, int l, int r, int h){ for(int i = l+h; i <= r; i++){ int j = i; Item tmp = v[i]; while(j>= l+h && less(tmp, v[j-h])){ v[j] = v[j-h]; j -= h; } v[j] = tmp; } } void shellsort(Item *v, int l, int r){ // closed range [l, r] int h; for(h = 1; h < (r-l)/9; h = 3*h+1); for(; h > 0; h = h/3) insertionsortH(v, l, r, h); }
the_stack_data/100987.c
/** * Outra forma de abrir um arquivo */ #include <stdio.h> #include <stdlib.h> int main(void) { FILE *fPointer; char singleLine[150]; fPointer = fopen("teste.txt", "r"); while (!feof(fPointer)) { fgets(singleLine, 150, fPointer); puts(singleLine); } fclose(fPointer); return (0); }
the_stack_data/80332.c
#include <stdio.h> #include <string.h> struct BigNumber { int arr[501]; int sign; int length; }; static struct BigNumber multi[10]; void set_value(struct BigNumber *num, char buf[501]) { int len = strlen(buf); int i; num->length = strlen(buf); num->sign = 0; for (i = 0; i < len; i++) num->arr[i] = buf[len-i-1] - '0'; for ( ; i < 501; i++) num->arr[i] = 0; } void print_value(struct BigNumber num) { int i = num.length; if (num.sign && !(num.length==1 && num.arr[0]==0)) putchar('-'); while (--i>=0) printf("%d", num.arr[i]); putchar('\n'); } int compare(struct BigNumber *A, struct BigNumber *B) { int i; if (A->length > B->length) return 1; if (A->length < B->length) return -1; i = A->length; while (--i >=0) { if (A->arr[i] > B->arr[i]) return 1; if (A->arr[i] < B->arr[i]) return -1; } return 0; } struct BigNumber add(struct BigNumber *A, struct BigNumber *B) { struct BigNumber result; int i; set_value(&result, ""); result.length = A->length >= B->length ? A->length : B->length; for (i = 0; i < result.length; i++) { result.arr[i] = A->arr[i] + B->arr[i]; result.arr[i+1] = result.arr[i] / 10; result.arr[i] %= 10; } if (result.arr[i]) result.length++; return result; } struct BigNumber sub(struct BigNumber *A, struct BigNumber *B) { struct BigNumber result; struct BigNumber *ptr; int i = compare(A, B); set_value(&result, ""); if (i == 0) { result.length = 1; result.arr[0] = 0; return result; } if (i < 0) { ptr = A; A = B; B = ptr; result.sign = 1; } result.length = A->length; for (i = 0; i < result.length; i++) result.arr[i] = A->arr[i] - B->arr[i]; for (i = 0; i < result.length; i++) { if (result.arr[i] < 0) { result.arr[i] += 10; result.arr[i+1]--; } } if (!result.arr[result.length-1]) result.length--; return result; } void mul_10(struct BigNumber *num) { int i; if (num->length == 1 && num->arr[0] == 0) return; for (i = num->length; i > 0; i--) num->arr[i] = num->arr[i-1]; num->arr[0] = 0; num->length++; } void mul_scale(struct BigNumber *src, struct BigNumber *dst, int scale, int do_carry) { int i; if (dst->length) set_value(dst, ""); if (scale == 1) { for (i = 0; i < src->length; i++) dst->arr[i] = src->arr[i]; dst->length = src->length; return; } for (i = 0; i < src->length; i++) dst->arr[i] = src->arr[i] * scale; if (do_carry) { for (i = 0; i < src->length; i++) { dst->arr[i+1] += dst->arr[i] / 10; dst->arr[i] %= 10; } } dst->length = dst->arr[i] ? i+1 : i; } struct BigNumber mul(struct BigNumber *A, struct BigNumber *B) { struct BigNumber result; struct BigNumber *multi_ptr[10]; struct BigNumber *ptr; int i, j, k; if (A->length == 1 && A->arr[0] == 0) return *A; if (B->length == 1 && B->arr[0] == 0) return *B; if (A->length == 1 && A->arr[0] == 1) return *B; if (B->length == 1 && B->arr[0] == 1) return *A; set_value(&result, ""); if(compare(A, B) < 0) { ptr = A; A = B; B = ptr; } for (i=0; i<10; i++) multi_ptr[i] = 0; multi_ptr[1] = A; for (i = 0; i < B->length; i++) { if (k = B->arr[i]) { if (!multi_ptr[k]) { set_value(&multi[k], ""); mul_scale(A, &multi[k], k, 0); multi_ptr[k] = &multi[k]; } for (j=0; j<A->length; j++) result.arr[j+i] += multi_ptr[k]->arr[j]; } } result.length = A->length + B->length - 1; for (i = 0; i < result.length; i++) { result.arr[i+1] += result.arr[i] / 10; result.arr[i] %= 10; } result.length = result.arr[i] ? i+1 : i; return result; } struct BigNumber div(struct BigNumber *A, struct BigNumber *B) { struct BigNumber result; struct BigNumber dividend, tmp; int i, j; if (A->length == 1 && A->arr[0] == 0) return *A; if (B->length == 1 && B->arr[0] == 1) return *A; set_value(&result, ""); i = compare(A, B); if (i == 0) { result.length = 1; result.arr[0] = 1; return result; } else if (i < 0) { result.length = 1; return result; } set_value(&dividend, "0"); for (i = A->length - 1; i>=0; i--) { mul_10(&dividend); dividend.arr[0] = A->arr[i]; if (dividend.length < B->length) continue; for (j = 9; j > 0; j--) { mul_scale(B, &tmp, j, 1); if (compare(&dividend, &tmp) >= 0) { dividend = sub(&dividend, &tmp); result.arr[i] = j; break; } } } for (i = A->length - 1; !result.arr[i]; i--) { /* do nothing */ } result.length = i + 1; return result; } int main(void) { struct BigNumber A, B; char buffer[501]; char op; while (scanf("%s", buffer)!=EOF) { set_value(&A, buffer); scanf("%s", buffer); op = buffer[0]; scanf("%s", buffer); set_value(&B, buffer); switch(op) { case '+': print_value(add(&A, &B)); break; case '-': print_value(sub(&A, &B)); break; case '*': print_value(mul(&A, &B)); break; case '/': print_value(div(&A, &B)); break; } } return 0; }
the_stack_data/508227.c
/* This testcase is part of GDB, the GNU debugger. Copyright 2013-2017 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/>. */ #include <stdlib.h> volatile int v = 1; static __attribute__ ((noinline, noclone, noreturn)) void noret (int x, ...) { abort (); } static __attribute__ ((noinline, noclone)) void mayret (int x) { if (v) noret (x); } static __attribute__ ((noinline, noclone)) void tailcall (int x) { mayret (x); } int main (void) { tailcall (1); return 0; }
the_stack_data/122014330.c
/** * Exercise 5-2: write getfloat, the floating point analog of getint. * * buggy.... * */ #include <stdio.h> #include <ctype.h> #define SIZE 20 int getch(void); void ungetch(int); int getfloat(float *pn) { int c, sign; float power; while(isspace(c = getch())) // skip white space ; if (!isdigit(c) && c != EOF && c != '+' && c != '-' && c != '.') { ungetch(c); // not a number return 0; } sign = (c == '-') ? -1 : 1; if (c == '+' || c == '-') { c = getch(); if (!isdigit(c)) { int sign_check = sign == 1 ? '+' : '-'; ungetch(sign_check); return 0; } } for (*pn = 0.0; isdigit(c); c = getch()) { *pn = 10.0 * *pn + (c - '0'); } if (c == '.') { c = getch(); } for (power = 1.0; isdigit(c); c = getch()) { *pn = 10.0 * *pn + (c - '0'); power *= 10; } *pn *= sign/power; if (c != EOF) { ungetch(c); } return c; } int main() { int n, i, getfloat(float *); float array[SIZE]; for (i = 0; i < SIZE; i++) { array[i] = 0.0; } for (n = 0; i < SIZE && getfloat(&array[n]) != EOF; n++) ; array[++n] = '\0'; for (i = 0; array[i] != '\0'; i++) { printf("%g", array[i]); } printf("\n"); return 0; }
the_stack_data/211081464.c
/* Author: Pakkpon Phongthawee LANG: C Problem: loopticket */ #include<stdio.h> int main(){ double a,b; while(1){ scanf("%lf %lf",&a,&b); if(a<0){ break; } if(b>100||b<0){ printf("invalid\n"); }else{ printf("%.2f\n",a*((100-b)/100)); } } return 0; }
the_stack_data/215769501.c
#include <stdio.h> #define MAX_N 1005 long long a[MAX_N+1][MAX_N+1]; void C() { int i,j; for (i = 0;i<=MAX_N;i++) { a[i][0] = a[i][i] = 1; } for (i = 2;i<=MAX_N;i++) { for (j = 1;j<i;j++) { a[i][j] = a[i-1][j-1] + a[i-1][j]; } } } int main() { int m,n; C(); while(scanf("%d%d",&m,&n) != EOF) { //if (n > m)printf("1\n"); //else if (m < 0 || n < 0)printf("0\n"); printf("%lld\n",a[m][n]); } return 0; }
the_stack_data/678582.c
// 5 kyu // Double Cola #include <stddef.h> const char * who_is_next(long long n, size_t len, const char *const *a) { if (!n) return NULL; long int *m = malloc(len * sizeof(long int)), p = 0; for (int i = 0; i < len; i++) *(m + i) = 1; for (; n > 0; p++) { if (p >= len) p = 0; n -= *(m + p); *(m + p) *= 2; }; free(m); return (*(a + p - 1)); }
the_stack_data/247018883.c
#include <stdio.h> int main(void) { char str[1000000 + 1]; int charcount[26] = {0}; scanf("%s", str); for(int i = 0; i < 1000000; i++) { if(str[i] == '\0') break; else if(str[i] < 'a') charcount[str[i] - 'A'] += 1; else charcount[str[i] - 'a'] += 1; } int max_count = 0; for(int i = 0; i < 26; i++) { if(max_count < charcount[i]) max_count = charcount[i]; } char max_char = '?'; for(int i = 0; i < 26; i++) { if(charcount[i] == max_count) { if(max_char == '?') max_char = i + 'A'; else { max_char = '?'; break; } } } printf("%c\n", max_char); return 0; }
the_stack_data/18887731.c
void test(int sum){ sum = sum - 10; sum = sum % 64; }
the_stack_data/151647.c
/* * @Author: Zheng Qihang * @Date: 2018-11-16 17:06:20 * @Last Modified by: Zheng Qihang * @Last Modified time: 2018-11-16 17:10:58 */ #include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> struct PrograssBar_S { int len; int delta; int cnt; char background; char foreground; char label[200]; char *pbar; }; /* @brief 全局变量用于保存参数 * * */ static struct PrograssBar_S g_probar= {}; /* @brief 初始化 * @ len : 进度条长度 * @ delta : 进度条步进长度 * @ background : 进度条背景 * @ foreground : 进度条前景 * @ label : 进度条左侧图形 不可超过200! * */ void probar_init(int len, int delta, char backgroud, char foreground, const char *label) { g_probar.cnt= 0; g_probar.len= len; g_probar.delta= delta; g_probar.background= backgroud; g_probar.foreground= foreground; char *pg_label= g_probar.label; for (const char *p= label; *p != '\0'; ++p) { *pg_label++= *p; } *pg_label= '\0'; g_probar.pbar= (char *)malloc(sizeof(char) * g_probar.len); memset((void *)g_probar.pbar, 0x20, g_probar.len); printf("%s [%-*s] [%05.2f%%] %s\r", g_probar.label, g_probar.len, g_probar.pbar, g_probar.cnt * (100 / (float)g_probar.len), ""); fflush(stdout); g_probar.cnt++; } /* @brief 绘制进度条 * @ show_str : 用于描述进度 * * */ void probar_show(const char *show_str) { if (g_probar.cnt == g_probar.len) { /* end */ printf("%s [%-*s] [%05.2f%%] %s\r", g_probar.label, g_probar.len, g_probar.pbar, g_probar.cnt * (100 / (float)g_probar.len), show_str); g_probar.cnt++; return; } else if (g_probar.cnt > g_probar.len) { return; } printf("%*c\r", 80, ' '); fflush(stdout); printf("%s [%-*s] [%05.2f%%] %s\r", g_probar.label, g_probar.len, g_probar.pbar, g_probar.cnt * (100 / (float)g_probar.len), show_str); fflush(stdout); if (g_probar.cnt > 0) { g_probar.pbar[g_probar.cnt - 1]= g_probar.background; } g_probar.pbar[g_probar.cnt]= g_probar.foreground; g_probar.pbar[g_probar.cnt + 1]= '\0'; g_probar.cnt++; } /* @brief 清空变量 * * */ void probar_delete() { g_probar.cnt= 0; g_probar.len= 0; g_probar.delta= 0; g_probar.background= '='; g_probar.foreground= '>'; free(g_probar.pbar); printf("%*c\r", 80, ' '); fflush(stdout); }
the_stack_data/215768689.c
#include<stdio.h> #include <stdlib.h> struct student { int rn; char name[30]; int marks; }; int main() { FILE *fp; struct student s; int n; fp=fopen("STUDENT.dat","r"); fscanf(fp,"%d",&n); printf("Students Getting above 75 : "); for (int i = 0; i < n; ++i) { fscanf(fp,"%d %s %d",&s.rn,s.name,&s.marks); if(s.marks>75) printf("\n%s",s.name ); } fclose(fp); return 0; }
the_stack_data/76700542.c
#include <stdint.h> extern uint32_t GET32(uint32_t); extern void PUT32(uint32_t, uint32_t); #define CONTROL_STATUS (0x44E10000+0x40) //#################################################### //AM335x BeagleBlack GEL file (DDR3) //v1.0 Jan8,2013 First revision, derived from EVM REV 1.3 //#################################################### //**************************************************** //PRCM module definitions //**************************************************** #define PRCM_BASE_ADDR (0x44E00000) #define CM_PER_EMIF_CLKCTRL (PRCM_BASE_ADDR + 0x028) #define CM_PER_EMIF_FW_CLKCTRL (PRCM_BASE_ADDR + 0x0D0) #define CM_AUTOIDLE_DPLL_MPU (PRCM_BASE_ADDR + 0x41C) #define CM_IDLEST_DPLL_MPU (PRCM_BASE_ADDR + 0x420) #define CM_CLKSEL_DPLL_MPU (PRCM_BASE_ADDR + 0x42C) #define CM_AUTOIDLE_DPLL_DDR (PRCM_BASE_ADDR + 0x430) #define CM_IDLEST_DPLL_DDR (PRCM_BASE_ADDR + 0x434) #define CM_CLKSEL_DPLL_DDR (PRCM_BASE_ADDR + 0x440) #define CM_AUTOIDLE_DPLL_DISP (PRCM_BASE_ADDR + 0x444) #define CM_IDLEST_DPLL_DISP (PRCM_BASE_ADDR + 0x448) #define CM_CLKSEL_DPLL_DISP (PRCM_BASE_ADDR + 0x454) #define CM_AUTOIDLE_DPLL_CORE (PRCM_BASE_ADDR + 0x458) #define CM_IDLEST_DPLL_CORE (PRCM_BASE_ADDR + 0x45C) #define CM_CLKSEL_DPLL_CORE (PRCM_BASE_ADDR + 0x468) #define CM_AUTOIDLE_DPLL_PER (PRCM_BASE_ADDR + 0x46C) #define CM_IDLEST_DPLL_PER (PRCM_BASE_ADDR + 0x470) #define CM_CLKSEL_DPLL_PER (PRCM_BASE_ADDR + 0x49C) #define CM_DIV_M4_DPLL_CORE (PRCM_BASE_ADDR + 0x480) #define CM_DIV_M5_DPLL_CORE (PRCM_BASE_ADDR + 0x484) #define CM_CLKMODE_DPLL_MPU (PRCM_BASE_ADDR + 0x488) #define CM_CLKMODE_DPLL_PER (PRCM_BASE_ADDR + 0x48C) #define CM_CLKMODE_DPLL_CORE (PRCM_BASE_ADDR + 0x490) #define CM_CLKMODE_DPLL_DDR (PRCM_BASE_ADDR + 0x494) #define CM_CLKMODE_DPLL_DISP (PRCM_BASE_ADDR + 0x498) #define CM_DIV_M2_DPLL_DDR (PRCM_BASE_ADDR + 0x4A0) #define CM_DIV_M2_DPLL_DISP (PRCM_BASE_ADDR + 0x4A4) #define CM_DIV_M2_DPLL_MPU (PRCM_BASE_ADDR + 0x4A8) #define CM_DIV_M2_DPLL_PER (PRCM_BASE_ADDR + 0x4AC) #define CM_DIV_M6_DPLL_CORE (PRCM_BASE_ADDR + 0x4D8) #define CM_CLKOUT_CTRL (PRCM_BASE_ADDR + 0x700) //**************************************************** //Control module definitions //**************************************************** #define CONTROL_BASE_ADDR (0x44E10000) #define CONF_XDMA_EVENT_INTR1 (CONTROL_BASE_ADDR + 0x9b4) //DDR IO Control Registers #define DDR_IO_CTRL (CONTROL_BASE_ADDR + 0x0E04) #define VTP_CTRL_REG (CONTROL_BASE_ADDR + 0x0E0C) #define DDR_CKE_CTRL (CONTROL_BASE_ADDR + 0x131C) #define DDR_CMD0_IOCTRL (CONTROL_BASE_ADDR + 0x1404) #define DDR_CMD1_IOCTRL (CONTROL_BASE_ADDR + 0x1408) #define DDR_CMD2_IOCTRL (CONTROL_BASE_ADDR + 0x140C) #define DDR_DATA0_IOCTRL (CONTROL_BASE_ADDR + 0x1440) #define DDR_DATA1_IOCTRL (CONTROL_BASE_ADDR + 0x1444) //******************************************************************** //EMIF4DC module definitions //******************************************************************** #define EMIF_BASE_ADDR (0x4C000000) #define EMIF_STATUS_REG (EMIF_BASE_ADDR + 0x004) #define EMIF_SDRAM_CONFIG_REG (EMIF_BASE_ADDR + 0x008) #define EMIF_SDRAM_CONFIG_2_REG (EMIF_BASE_ADDR + 0x00C) #define EMIF_SDRAM_REF_CTRL_REG (EMIF_BASE_ADDR + 0x010) #define EMIF_SDRAM_REF_CTRL_SHDW_REG (EMIF_BASE_ADDR + 0x014) #define EMIF_SDRAM_TIM_1_REG (EMIF_BASE_ADDR + 0x018) #define EMIF_SDRAM_TIM_1_SHDW_REG (EMIF_BASE_ADDR + 0x01C) #define EMIF_SDRAM_TIM_2_REG (EMIF_BASE_ADDR + 0x020) #define EMIF_SDRAM_TIM_2_SHDW_REG (EMIF_BASE_ADDR + 0x024) #define EMIF_SDRAM_TIM_3_REG (EMIF_BASE_ADDR + 0x028) #define EMIF_SDRAM_TIM_3_SHDW_REG (EMIF_BASE_ADDR + 0x02C) #define EMIF_LPDDR2_NVM_TIM_REG (EMIF_BASE_ADDR + 0x030) #define EMIF_LPDDR2_NVM_TIM_SHDW_REG (EMIF_BASE_ADDR + 0x034) #define EMIF_PWR_MGMT_CTRL_REG (EMIF_BASE_ADDR + 0x038) #define EMIF_PWR_MGMT_CTRL_SHDW_REG (EMIF_BASE_ADDR + 0x03C) #define EMIF_LPDDR2_MODE_REG_DATA_REG (EMIF_BASE_ADDR + 0x040) #define EMIF_LPDDR2_MODE_REG_CFG_REG (EMIF_BASE_ADDR + 0x050) #define EMIF_OCP_CONFIG_REG (EMIF_BASE_ADDR + 0x054) #define EMIF_OCP_CFG_VAL_1_REG (EMIF_BASE_ADDR + 0x058) #define EMIF_OCP_CFG_VAL_2_REG (EMIF_BASE_ADDR + 0x05C) #define EMIF_IODFT_TLGC_REG (EMIF_BASE_ADDR + 0x060) #define EMIF_IODFT_CTRL_MISR_RSLT_REG (EMIF_BASE_ADDR + 0x064) #define EMIF_IODFT_ADDR_MISR_RSLT_REG (EMIF_BASE_ADDR + 0x068) #define EMIF_IODFT_DATA_MISR_RSLT_1_REG (EMIF_BASE_ADDR + 0x06C) #define EMIF_IODFT_DATA_MISR_RSLT_2_REG (EMIF_BASE_ADDR + 0x070) #define EMIF_IODFT_DATA_MISR_RSLT_3_REG (EMIF_BASE_ADDR + 0x074) #define EMIF_PERF_CNT_1_REG (EMIF_BASE_ADDR + 0x080) #define EMIF_PERF_CNT_2_REG (EMIF_BASE_ADDR + 0x084) #define EMIF_PERF_CNT_CFG_REG (EMIF_BASE_ADDR + 0x088) #define EMIF_PERF_CNT_SEL_REG (EMIF_BASE_ADDR + 0x08C) #define EMIF_PERF_CNT_TIM_REG (EMIF_BASE_ADDR + 0x090) #define EMIF_READ_IDLE_CTRL_REG (EMIF_BASE_ADDR + 0x098) #define EMIF_READ_IDLE_CTRL_SHDW_REG (EMIF_BASE_ADDR + 0x09C) #define EMIF_IRQ_EOI_REG (EMIF_BASE_ADDR + 0x0A0) #define EMIF_IRQSTATUS_RAW_SYS_REG (EMIF_BASE_ADDR + 0x0A4) #define EMIF_IRQSTATUS_SYS_REG (EMIF_BASE_ADDR + 0x0AC) #define EMIF_IRQENABLE_SET_SYS_REG (EMIF_BASE_ADDR + 0x0B4) #define EMIF_IRQENABLE_CLR_SYS_REG (EMIF_BASE_ADDR + 0x0BC) #define EMIF_ZQ_CONFIG_REG (EMIF_BASE_ADDR + 0x0C8) #define EMIF_TEMP_ALERT_CONFIG_REG (EMIF_BASE_ADDR + 0x0CC) #define EMIF_OCP_ERR_LOG_REG (EMIF_BASE_ADDR + 0x0D0) #define EMIF_RDWR_LVL_RMP_WIN_REG (EMIF_BASE_ADDR + 0x0D4) #define EMIF_RDWR_LVL_RMP_CTRL_REG (EMIF_BASE_ADDR + 0x0D8) #define EMIF_RDWR_LVL_CTRL_REG (EMIF_BASE_ADDR + 0x0DC) #define EMIF_DDR_PHY_CTRL_1_REG (EMIF_BASE_ADDR + 0x0E4) #define EMIF_DDR_PHY_CTRL_1_SHDW_REG (EMIF_BASE_ADDR + 0x0E8) #define EMIF_DDR_PHY_CTRL_2_REG (EMIF_BASE_ADDR + 0x0EC) #define EMIF_PRI_COS_MAP_REG (EMIF_BASE_ADDR + 0x100) #define EMIF_CONNID_COS_1_MAP_REG (EMIF_BASE_ADDR + 0x104) #define EMIF_CONNID_COS_2_MAP_REG (EMIF_BASE_ADDR + 0x108) #define EMIF_RD_WR_EXEC_THRSH_REG (EMIF_BASE_ADDR + 0x120) //******************************************************************* //DDR PHY registers //******************************************************************* #define DDR_PHY_BASE_ADDR (0x44E12000) //CMD0 #define CMD0_REG_PHY_CTRL_SLAVE_RATIO_0 (0x01C + DDR_PHY_BASE_ADDR) #define CMD0_REG_PHY_CTRL_SLAVE_FORCE_0 (0x020 + DDR_PHY_BASE_ADDR) #define CMD0_REG_PHY_CTRL_SLAVE_DELAY_0 (0x024 + DDR_PHY_BASE_ADDR) #define CMD0_REG_PHY_DLL_LOCK_DIFF_0 (0x028 + DDR_PHY_BASE_ADDR) #define CMD0_REG_PHY_INVERT_CLKOUT_0 (0x02C + DDR_PHY_BASE_ADDR) #define CMD0_PHY_REG_STATUS_PHY_CTRL_DLL_LOCK_0 (0x030 + DDR_PHY_BASE_ADDR) #define CMD0_PHY_REG_STATUS_PHY_CTRL_OF_IN_LOCK_STATE_0 (0x034 + DDR_PHY_BASE_ADDR) #define CMD0_PHY_REG_STATUS_PHY_CTRL_OF_IN_DELAY_VALUE_0 (0x038 + DDR_PHY_BASE_ADDR) #define CMD0_PHY_REG_STATUS_PHY_CTRL_OF_OUT_DELAY_VALUE_0 (0x03C + DDR_PHY_BASE_ADDR) //CMD1 #define CMD1_REG_PHY_CTRL_SLAVE_RATIO_0 (0x050 + DDR_PHY_BASE_ADDR) #define CMD1_REG_PHY_CTRL_SLAVE_FORCE_0 (0x054 + DDR_PHY_BASE_ADDR) #define CMD1_REG_PHY_CTRL_SLAVE_DELAY_0 (0x058 + DDR_PHY_BASE_ADDR) #define CMD1_REG_PHY_DLL_LOCK_DIFF_0 (0x05C + DDR_PHY_BASE_ADDR) #define CMD1_REG_PHY_INVERT_CLKOUT_0 (0x060 + DDR_PHY_BASE_ADDR) #define CMD1_PHY_REG_STATUS_PHY_CTRL_DLL_LOCK_0 (0x064 + DDR_PHY_BASE_ADDR) #define CMD1_PHY_REG_STATUS_PHY_CTRL_OF_IN_LOCK_STATE_0 (0x068 + DDR_PHY_BASE_ADDR) #define CMD1_PHY_REG_STATUS_PHY_CTRL_OF_IN_DELAY_VALUE_0 (0x06C + DDR_PHY_BASE_ADDR) #define CMD1_PHY_REG_STATUS_PHY_CTRL_OF_OUT_DELAY_VALUE_0 (0x070 + DDR_PHY_BASE_ADDR) //CMD2 #define CMD2_REG_PHY_CTRL_SLAVE_RATIO_0 (0x084 + DDR_PHY_BASE_ADDR) #define CMD2_REG_PHY_CTRL_SLAVE_FORCE_0 (0x088 + DDR_PHY_BASE_ADDR) #define CMD2_REG_PHY_CTRL_SLAVE_DELAY_0 (0x08C + DDR_PHY_BASE_ADDR) #define CMD2_REG_PHY_DLL_LOCK_DIFF_0 (0x090 + DDR_PHY_BASE_ADDR) #define CMD2_REG_PHY_INVERT_CLKOUT_0 (0x094 + DDR_PHY_BASE_ADDR) #define CMD2_PHY_REG_STATUS_PHY_CTRL_DLL_LOCK_0 (0x098 + DDR_PHY_BASE_ADDR) #define CMD2_PHY_REG_STATUS_PHY_CTRL_OF_IN_LOCK_STATE_0 (0x09C + DDR_PHY_BASE_ADDR) #define CMD2_PHY_REG_STATUS_PHY_CTRL_OF_IN_DELAY_VALUE_0 (0x0A0 + DDR_PHY_BASE_ADDR) #define CMD2_PHY_REG_STATUS_PHY_CTRL_OF_OUT_DELAY_VALUE_0 (0x0A4 + DDR_PHY_BASE_ADDR) //DATA0 #define DATA0_REG_PHY_DATA_SLICE_IN_USE_0 (0x0B8 + DDR_PHY_BASE_ADDR) #define DATA0_REG_PHY_DIS_CALIB_RST_0 (0x0BC + DDR_PHY_BASE_ADDR) #define DATA0_REG_PHY_RDC_FIFO_RST_ERR_CNT_CLR_0 (0x0C0 + DDR_PHY_BASE_ADDR) #define DATA0_PHY_RDC_FIFO_RST_ERR_CNT_0 (0x0C4 + DDR_PHY_BASE_ADDR) #define DATA0_REG_PHY_RD_DQS_SLAVE_RATIO_0 (0x0C8 + DDR_PHY_BASE_ADDR) #define DATA0_REG_PHY_RD_DQS_SLAVE_RATIO_1 (0x0CC + DDR_PHY_BASE_ADDR) #define DATA0_REG_PHY_RD_DQS_SLAVE_FORCE_0 (0x0D0 + DDR_PHY_BASE_ADDR) #define DATA0_REG_PHY_RD_DQS_SLAVE_DELAY_0 (0x0D4 + DDR_PHY_BASE_ADDR) #define DATA0_REG_PHY_RD_DQS_SLAVE_DELAY_1 (0x0D8 + DDR_PHY_BASE_ADDR) #define DATA0_REG_PHY_WR_DQS_SLAVE_RATIO_0 (0x0DC + DDR_PHY_BASE_ADDR) #define DATA0_REG_PHY_WR_DQS_SLAVE_RATIO_1 (0x0E0 + DDR_PHY_BASE_ADDR) #define DATA0_REG_PHY_WR_DQS_SLAVE_FORCE_0 (0x0E4 + DDR_PHY_BASE_ADDR) #define DATA0_REG_PHY_WR_DQS_SLAVE_DELAY_0 (0x0E8 + DDR_PHY_BASE_ADDR) #define DATA0_REG_PHY_WR_DQS_SLAVE_DELAY_1 (0x0EC + DDR_PHY_BASE_ADDR) #define DATA0_REG_PHY_WRLVL_INIT_RATIO_0 (0x0F0 + DDR_PHY_BASE_ADDR) #define DATA0_REG_PHY_WRLVL_INIT_RATIO_1 (0x0F4 + DDR_PHY_BASE_ADDR) #define DATA0_REG_PHY_WRLVL_INIT_MODE_0 (0x0F8 + DDR_PHY_BASE_ADDR) #define DATA0_REG_PHY_GATELVL_INIT_RATIO_0 (0x0FC + DDR_PHY_BASE_ADDR) #define DATA0_REG_PHY_GATELVL_INIT_RATIO_1 (0x100 + DDR_PHY_BASE_ADDR) #define DATA0_REG_PHY_GATELVL_INIT_MODE_0 (0x104 + DDR_PHY_BASE_ADDR) #define DATA0_REG_PHY_FIFO_WE_SLAVE_RATIO_0 (0x108 + DDR_PHY_BASE_ADDR) #define DATA0_REG_PHY_FIFO_WE_SLAVE_RATIO_1 (0x10C + DDR_PHY_BASE_ADDR) #define DATA0_REG_PHY_FIFO_WE_IN_FORCE_0 (0x110 + DDR_PHY_BASE_ADDR) #define DATA0_REG_PHY_FIFO_WE_IN_DELAY_0 (0x114 + DDR_PHY_BASE_ADDR) #define DATA0_REG_PHY_FIFO_WE_IN_DELAY_1 (0x118 + DDR_PHY_BASE_ADDR) #define DATA0_REG_PHY_DQ_OFFSET_0 (0x11C + DDR_PHY_BASE_ADDR) #define DATA0_REG_PHY_WR_DATA_SLAVE_RATIO_0 (0x120 + DDR_PHY_BASE_ADDR) #define DATA0_REG_PHY_WR_DATA_SLAVE_RATIO_1 (0x124 + DDR_PHY_BASE_ADDR) #define DATA0_REG_PHY_WR_DATA_SLAVE_FORCE_0 (0x128 + DDR_PHY_BASE_ADDR) #define DATA0_REG_PHY_WR_DATA_SLAVE_DELAY_0 (0x12C + DDR_PHY_BASE_ADDR) #define DATA0_REG_PHY_WR_DATA_SLAVE_DELAY_1 (0x130 + DDR_PHY_BASE_ADDR) #define DATA0_REG_PHY_USE_RANK0_DELAYS_0 (0x134 + DDR_PHY_BASE_ADDR) #define DATA0_REG_PHY_DLL_LOCK_DIFF_0 (0x138 + DDR_PHY_BASE_ADDR) #define DATA0_PHY_REG_STATUS_DLL_LOCK_0 (0x13C + DDR_PHY_BASE_ADDR) #define DATA0_PHY_REG_STATUS_OF_IN_LOCK_STATE_0 (0x140 + DDR_PHY_BASE_ADDR) #define DATA0_PHY_REG_STATUS_OF_IN_DELAY_VALUE_0 (0x144 + DDR_PHY_BASE_ADDR) #define DATA0_PHY_REG_STATUS_OF_OUT_DELAY_VALUE_0 (0x148 + DDR_PHY_BASE_ADDR) //DATA1 #define DATA1_REG_PHY_DATA_SLICE_IN_USE_0 (0x15C + DDR_PHY_BASE_ADDR) #define DATA1_REG_PHY_DIS_CALIB_RST_0 (0x160 + DDR_PHY_BASE_ADDR) #define DATA1_REG_PHY_RDC_FIFO_RST_ERR_CNT_CLR_0 (0x164 + DDR_PHY_BASE_ADDR) #define DATA1_PHY_RDC_FIFO_RST_ERR_CNT_0 (0x168 + DDR_PHY_BASE_ADDR) #define DATA1_REG_PHY_RD_DQS_SLAVE_RATIO_0 (0x16C + DDR_PHY_BASE_ADDR) #define DATA1_REG_PHY_RD_DQS_SLAVE_RATIO_1 (0x170 + DDR_PHY_BASE_ADDR) #define DATA1_REG_PHY_RD_DQS_SLAVE_FORCE_0 (0x174 + DDR_PHY_BASE_ADDR) #define DATA1_REG_PHY_RD_DQS_SLAVE_DELAY_0 (0x178 + DDR_PHY_BASE_ADDR) #define DATA1_REG_PHY_RD_DQS_SLAVE_DELAY_1 (0x17C + DDR_PHY_BASE_ADDR) #define DATA1_REG_PHY_WR_DQS_SLAVE_RATIO_0 (0x180 + DDR_PHY_BASE_ADDR) #define DATA1_REG_PHY_WR_DQS_SLAVE_RATIO_1 (0x184 + DDR_PHY_BASE_ADDR) #define DATA1_REG_PHY_WR_DQS_SLAVE_FORCE_0 (0x188 + DDR_PHY_BASE_ADDR) #define DATA1_REG_PHY_WR_DQS_SLAVE_DELAY_0 (0x18C + DDR_PHY_BASE_ADDR) #define DATA1_REG_PHY_WR_DQS_SLAVE_DELAY_1 (0x190 + DDR_PHY_BASE_ADDR) #define DATA1_REG_PHY_WRLVL_INIT_RATIO_0 (0x194 + DDR_PHY_BASE_ADDR) #define DATA1_REG_PHY_WRLVL_INIT_RATIO_1 (0x198 + DDR_PHY_BASE_ADDR) #define DATA1_REG_PHY_WRLVL_INIT_MODE_0 (0x19C + DDR_PHY_BASE_ADDR) #define DATA1_REG_PHY_GATELVL_INIT_RATIO_0 (0x1A0 + DDR_PHY_BASE_ADDR) #define DATA1_REG_PHY_GATELVL_INIT_RATIO_1 (0x1A4 + DDR_PHY_BASE_ADDR) #define DATA1_REG_PHY_GATELVL_INIT_MODE_0 (0x1A8 + DDR_PHY_BASE_ADDR) #define DATA1_REG_PHY_FIFO_WE_SLAVE_RATIO_0 (0x1AC + DDR_PHY_BASE_ADDR) #define DATA1_REG_PHY_FIFO_WE_SLAVE_RATIO_1 (0x1B0 + DDR_PHY_BASE_ADDR) #define DATA1_REG_PHY_FIFO_WE_IN_FORCE_0 (0x1B4 + DDR_PHY_BASE_ADDR) #define DATA1_REG_PHY_FIFO_WE_IN_DELAY_0 (0x1B8 + DDR_PHY_BASE_ADDR) #define DATA1_REG_PHY_FIFO_WE_IN_DELAY_1 (0x1BC + DDR_PHY_BASE_ADDR) #define DATA1_REG_PHY_DQ_OFFSET_0 (0x1C0 + DDR_PHY_BASE_ADDR) #define DATA1_REG_PHY_WR_DATA_SLAVE_RATIO_0 (0x1C4 + DDR_PHY_BASE_ADDR) #define DATA1_REG_PHY_WR_DATA_SLAVE_RATIO_1 (0x1C8 + DDR_PHY_BASE_ADDR) #define DATA1_REG_PHY_WR_DATA_SLAVE_FORCE_0 (0x1CC + DDR_PHY_BASE_ADDR) #define DATA1_REG_PHY_WR_DATA_SLAVE_DELAY_0 (0x1D0 + DDR_PHY_BASE_ADDR) #define DATA1_REG_PHY_WR_DATA_SLAVE_DELAY_1 (0x1D4 + DDR_PHY_BASE_ADDR) #define DATA1_REG_PHY_USE_RANK0_DELAYS_0 (0x1D8 + DDR_PHY_BASE_ADDR) #define DATA1_REG_PHY_DLL_LOCK_DIFF_0 (0x1DC + DDR_PHY_BASE_ADDR) #define DATA1_PHY_REG_STATUS_DLL_LOCK_0 (0x1E0 + DDR_PHY_BASE_ADDR) #define DATA1_PHY_REG_STATUS_OF_IN_LOCK_STATE_0 (0x1E4 + DDR_PHY_BASE_ADDR) #define DATA1_PHY_REG_STATUS_OF_IN_DELAY_VALUE_0 (0x1E8 + DDR_PHY_BASE_ADDR) #define DATA1_PHY_REG_STATUS_OF_OUT_DELAY_VALUE_0 (0x1EC + DDR_PHY_BASE_ADDR) //FIFO #define FIFO_WE_OUT0_IO_CONFIG_I_0 (0x338 + DDR_PHY_BASE_ADDR) #define FIFO_WE_OUT0_IO_CONFIG_SR_0 (0x33C + DDR_PHY_BASE_ADDR) #define FIFO_WE_OUT1_IO_CONFIG_I_0 (0x340 + DDR_PHY_BASE_ADDR) #define FIFO_WE_OUT1_IO_CONFIG_SR_0 (0x344 + DDR_PHY_BASE_ADDR) #define FIFO_WE_IN2_IO_CONFIG_I_0 (0x348 + DDR_PHY_BASE_ADDR) #define FIFO_WE_IN2_IO_CONFIG_SR_0 (0x34C + DDR_PHY_BASE_ADDR) #define FIFO_WE_IN3_IO_CONFIG_I_0 (0x350 + DDR_PHY_BASE_ADDR) #define FIFO_WE_IN3_IO_CONFIG_SR_0 (0x354 + DDR_PHY_BASE_ADDR) //Leveling #define DATA0_REG_PHY_WRLVL_NUM_OF_DQ0 (0x35C + DDR_PHY_BASE_ADDR) #define DATA0_REG_PHY_GATELVL_NUM_OF_DQ0 (0x360 + DDR_PHY_BASE_ADDR) #define DATA1_REG_PHY_WRLVL_NUM_OF_DQ0 (0x364 + DDR_PHY_BASE_ADDR) #define DATA1_REG_PHY_GATELVL_NUM_OF_DQ0 (0x368 + DDR_PHY_BASE_ADDR) //******************************************************************* //Watchdog Timer registers //******************************************************************* #define WDT1_BASE_ADDR (0x44E35000) #define WDT1_WSPR (WDT1_BASE_ADDR + 0x48) uint32_t GetInputClockFrequency() { uint32_t temp = GET32(CONTROL_STATUS) >> 22; temp &= 0x3; switch (temp) { case 0: return 19; break; // 19.2 MHz case 1: return 24; break; // 24 MHz case 2: return 25; break; // 25 MHz case 3: return 26; break; // 26 MHz // no default as x &= 0x3 -> x = [0:1:2:3] } return 0; // never happens, only to remove compilation warning } void MPU_PLL_Config(uint32_t clkin, uint32_t n, uint32_t m, uint32_t m2) { uint32_t clkmode, clksel, div_m2; // TODO: fix with CLK_module clkmode = GET32(CM_CLKMODE_DPLL_MPU); clksel = GET32(CM_CLKSEL_DPLL_MPU); div_m2 = GET32(CM_DIV_M2_DPLL_MPU); // put the DPLL in bypass mode PUT32(CM_CLKMODE_DPLL_MPU, 0x4); // wait for bypass status while ((GET32(CM_IDLEST_DPLL_MPU) & 0x101) != 0x100); // set multiply and divide values clksel &= ~0x7FFFF; clksel |= ((m << 0x8) | n); PUT32(CM_CLKSEL_DPLL_MPU, clksel); div_m2 &= ~0x1F; div_m2 |= m2; PUT32(CM_DIV_M2_DPLL_MPU, div_m2); // now lock the DPLL clkmode |= 0x07; PUT32(CM_CLKMODE_DPLL_MPU, clkmode); //wait for lock while ((GET32(CM_IDLEST_DPLL_MPU) & 0x101) != 0x001); } void CORE_PLL_Config(uint32_t clkin, uint32_t n, uint32_t m, uint32_t m4, uint32_t m5, uint32_t m6) { uint32_t clkmode, clksel, div_m4, div_m5, div_m6; clkmode = GET32(CM_CLKMODE_DPLL_CORE); clksel = GET32(CM_CLKSEL_DPLL_CORE); div_m4 = GET32(CM_DIV_M4_DPLL_CORE); div_m5 = GET32(CM_DIV_M5_DPLL_CORE); div_m6 = GET32(CM_DIV_M6_DPLL_CORE); // put DPLL in bypass mode clkmode &= ~0x7; clkmode |= 0x4; PUT32(CM_CLKMODE_DPLL_CORE, clkmode); // wait for bypass status while ((GET32(CM_IDLEST_DPLL_CORE) & 0x100) != 0x100); // set multiply and divide values clksel &= ~0x7FFFF; clksel |= (m << 8) | n; PUT32(CM_CLKSEL_DPLL_CORE, clksel); div_m4 = m4; // 200MHz div_m5 = m5; // 250MHz div_m6 = m6; // 500MHz PUT32(CM_DIV_M4_DPLL_CORE, div_m4); PUT32(CM_DIV_M5_DPLL_CORE, div_m5); PUT32(CM_DIV_M6_DPLL_CORE, div_m6); // now lock the PLL clkmode &= ~0x7; clkmode |= 0x7; PUT32(CM_CLKMODE_DPLL_CORE, clkmode); // wait for lock while ((GET32(CM_IDLEST_DPLL_CORE) & 0x1) != 0x1); } void DDR_PLL_Config(uint32_t clkin, uint32_t n, uint32_t m, uint32_t m2) { uint32_t clkmode, clksel, div_m2; clkmode = GET32(CM_CLKMODE_DPLL_DDR); clksel = GET32(CM_CLKSEL_DPLL_DDR); div_m2 = GET32(CM_DIV_M2_DPLL_DDR); clkmode &= ~0x7; clkmode |= 0x4; PUT32(CM_CLKMODE_DPLL_DDR, clkmode); while ((GET32(CM_IDLEST_DPLL_DDR) & 0x100) != 0x100); clksel &= ~0x7FFFF; clksel |= (m << 8) | n; PUT32(CM_CLKSEL_DPLL_DDR, clksel); div_m2 = GET32(CM_DIV_M2_DPLL_DDR); div_m2 &= ~0x1F; div_m2 |= m2; PUT32(CM_DIV_M2_DPLL_DDR, div_m2); clkmode &= ~0x7; clkmode |= 0x7; PUT32(CM_CLKMODE_DPLL_DDR, clkmode); while ((GET32(CM_IDLEST_DPLL_DDR) & 0x1) != 0x1); } void PER_PLL_Config(uint32_t clkin, uint32_t n, uint32_t m, uint32_t m2) { uint32_t clkmode, clksel, div_m2; clkmode = GET32(CM_CLKMODE_DPLL_PER); clksel = GET32(CM_CLKSEL_DPLL_PER); div_m2 = GET32(CM_DIV_M2_DPLL_PER); clkmode &= ~0x7; clkmode |= 0x4; PUT32(CM_CLKMODE_DPLL_PER, clkmode); while ((GET32(CM_IDLEST_DPLL_PER) & 0x100) != 0x100); clksel &= 0x00F00000; clksel |= 0x04000000; // SD divider = 4 for both OPP100 and OPP50 clksel |= (m << 8) | n; PUT32(CM_CLKSEL_DPLL_PER, clksel); div_m2 = 0xFFFFFF80 | m2; PUT32(CM_DIV_M2_DPLL_PER, div_m2); clkmode &= 0xFFFFFFF8; clkmode |= 0x7; PUT32(CM_CLKMODE_DPLL_PER, clkmode); while ((GET32(CM_IDLEST_DPLL_PER) & 0x1) != 0x1); } void DISP_PLL_Config(uint32_t clkin, uint32_t n, uint32_t m, uint32_t m2) { uint32_t ref_clk; uint32_t clkmode, clksel, div_m2; ref_clk = clkin / (n + 1); clkmode = (ref_clk * m) / m2; clkmode = GET32(CM_CLKMODE_DPLL_DISP); clksel = GET32(CM_CLKSEL_DPLL_DISP); clksel = GET32(CM_DIV_M2_DPLL_DISP); clkmode &= ~0x7; clkmode |= 0x4; PUT32(CM_CLKMODE_DPLL_DISP, clkmode); while ((GET32(CM_IDLEST_DPLL_DISP) & 0x100) != 0x100); clksel &= ~0x7FFFF; clksel |= (m << 8) | n; PUT32(CM_CLKSEL_DPLL_DISP, clksel); div_m2 = ~0x1F | m2; PUT32(CM_DIV_M2_DPLL_DISP, div_m2); clkmode &= ~0x7; clkmode |= 0x7; PUT32(CM_CLKMODE_DPLL_DISP, clkmode); while ((GET32(CM_IDLEST_DPLL_DISP) & 0x1) != 0x1); }
the_stack_data/339345.c
/* Generated by CIL v. 1.7.3 */ /* print_CIL_Input is true */ #line 213 "/usr/lib/gcc/x86_64-linux-gnu/4.7/include/stddef.h" typedef unsigned long size_t; #line 200 "/usr/include/x86_64-linux-gnu/sys/types.h" typedef unsigned char u_int8_t; #line 202 "/usr/include/x86_64-linux-gnu/sys/types.h" typedef unsigned int u_int32_t; #line 75 "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h" struct __pthread_internal_list { struct __pthread_internal_list *__prev ; struct __pthread_internal_list *__next ; }; #line 75 "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h" typedef struct __pthread_internal_list __pthread_list_t; #line 90 "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h" struct __pthread_mutex_s { int __lock ; unsigned int __count ; int __owner ; unsigned int __nusers ; int __kind ; int __spins ; __pthread_list_t __list ; }; #line 90 "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h" union __anonunion_pthread_mutex_t_14 { struct __pthread_mutex_s __data ; char __size[40] ; long __align ; }; #line 90 "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h" typedef union __anonunion_pthread_mutex_t_14 pthread_mutex_t; #line 28 "util_types.h" typedef u_int32_t status_t; #line 28 "queue.h" struct queue_ { void *head ; void *tail ; u_int32_t count ; u_int32_t limit ; pthread_mutex_t mutex ; char const *owner ; }; #line 28 "queue.h" typedef struct queue_ queue_t; #line 50 "queue.h" struct queue_link_ { void *queue_next ; void *queue_prev ; queue_t *owner_queue ; }; #line 50 "queue.h" typedef struct queue_link_ queue_link_t; #line 59 "queue.h" struct queue_test_ { queue_link_t link ; u_int32_t addr1 ; u_int32_t addr2 ; }; #line 59 "queue.h" typedef struct queue_test_ queue_test_t; #line 120 "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h" union __anonunion_pthread_mutexattr_t_15 { char __size[4] ; int __align ; }; #line 120 "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h" typedef union __anonunion_pthread_mutexattr_t_15 pthread_mutexattr_t; #line 201 "/usr/include/x86_64-linux-gnu/sys/types.h" typedef unsigned short u_int16_t; #line 25 "itable.h" struct itable_ { u_int16_t count ; u_int16_t length ; u_int32_t alloc ; void *itable_element[0] ; }; #line 25 "itable.h" typedef struct itable_ itable_t; #line 1 "cil-yH62dHiz.o" #pragma merger("0","/tmp/cil-6csJUFwG.i","-Wall,-Werror,-g") #line 362 "/usr/include/stdio.h" extern int printf(char const * __restrict __format , ...) ; #line 409 "/usr/include/string.h" extern __attribute__((__nothrow__)) char *( __attribute__((__leaf__)) strerror)(int __errnum ) ; #line 455 extern __attribute__((__nothrow__)) void ( __attribute__((__nonnull__(1), __leaf__)) bzero)(void *__s , size_t __n ) ; #line 465 "/usr/include/stdlib.h" extern __attribute__((__nothrow__)) void *( __attribute__((__leaf__)) malloc)(size_t __size ) __attribute__((__malloc__)) ; #line 482 extern __attribute__((__nothrow__)) void ( __attribute__((__leaf__)) free)(void *__ptr ) ; #line 542 extern __attribute__((__nothrow__, __noreturn__)) void ( __attribute__((__leaf__)) exit)(int __status ) ; #line 76 "queue.h" queue_t *queue_create(status_t *status , char const *owner , size_t limit ) ; #line 81 status_t queue_enqueue(queue_t *queue , queue_link_t *link ) ; #line 85 void *queue_dequeue(queue_t *queue , status_t *status ) ; #line 89 size_t queue_get_count(queue_t *queue ) ; #line 93 void *queue_get_next(queue_t *queue , queue_link_t *curr , status_t *status ) ; #line 103 "util_test.c" static status_t queue_test(void) { queue_t *q ; queue_test_t *qt ; status_t status ; u_int8_t count ; void *tmp ; void *tmp___0 ; { #line 111 q = (queue_t *)((void *)0); #line 112 qt = (queue_test_t *)((void *)0); #line 113 status = (status_t )0; #line 115 q = queue_create(& status, "queue_test", (size_t )255); #line 116 if ((unsigned long )q == (unsigned long )((void *)0)) { #line 118 return (status); } #line 121 count = (u_int8_t )0; #line 121 while ((int )count < 255) { #line 123 tmp = malloc(sizeof(queue_test_t )); #line 123 qt = (queue_test_t *)tmp; #line 124 if ((unsigned long )qt == (unsigned long )((void *)0)) { #line 126 return ((status_t )12); } #line 129 bzero((void *)qt, sizeof(queue_test_t )); #line 131 qt->addr1 = (u_int32_t )qt; #line 132 qt->addr2 = (u_int32_t )count; #line 134 status = queue_enqueue(q, & qt->link); #line 135 if (status != 0U) { #line 137 return (status); } #line 121 count = (u_int8_t )((int )count + 1); } #line 141 count = (u_int8_t )0; #line 141 while ((int )count < 255) { #line 143 tmp___0 = queue_dequeue(q, & status); #line 143 qt = (queue_test_t *)tmp___0; #line 144 if ((unsigned long )qt == (unsigned long )((void *)0)) { #line 146 return (status); } #line 149 if (qt->addr2 != (u_int32_t )count) { #line 151 return ((status_t )2); } else { #line 155 free((void *)qt); } #line 141 count = (u_int8_t )((int )count + 1); } #line 159 return ((status_t )0); } } #line 162 "util_test.c" static status_t queue_walk_test(void) { queue_t *q ; queue_test_t *qt ; queue_test_t *next_qt ; status_t status ; u_int8_t count ; size_t q_count ; void *tmp ; void *tmp___0 ; { #line 171 q = (queue_t *)((void *)0); #line 172 qt = (queue_test_t *)((void *)0); #line 173 status = (status_t )0; #line 175 q = queue_create(& status, "queue_test", (size_t )255); #line 176 if ((unsigned long )q == (unsigned long )((void *)0)) { #line 178 return (status); } #line 181 count = (u_int8_t )0; #line 181 while ((int )count < 33) { #line 183 tmp = malloc(sizeof(queue_test_t )); #line 183 qt = (queue_test_t *)tmp; #line 184 if ((unsigned long )qt == (unsigned long )((void *)0)) { #line 186 return ((status_t )12); } #line 189 bzero((void *)qt, sizeof(queue_test_t )); #line 191 qt->addr1 = (u_int32_t )qt; #line 192 qt->addr2 = (u_int32_t )count; #line 194 status = queue_enqueue(q, & qt->link); #line 195 if (status != 0U) { #line 197 return (status); } #line 181 count = (u_int8_t )((int )count + 1); } #line 201 qt = (queue_test_t *)((void *)0); #line 202 q_count = queue_get_count(q); #line 203 count = (u_int8_t )0; #line 203 while ((size_t )count < q_count * 2UL) { #line 205 tmp___0 = queue_get_next(q, & qt->link, & status); #line 205 next_qt = (queue_test_t *)tmp___0; #line 206 if ((unsigned long )next_qt == (unsigned long )((void *)0)) { #line 207 next_qt = qt; } #line 210 if ((unsigned long )qt != (unsigned long )((void *)0)) { #line 211 printf((char const * __restrict )"curr[0x%x][%d] next[0x%x][%d]\n", qt->addr1, qt->addr2, next_qt->addr1, next_qt->addr2); } #line 215 if (status == 16U) { #line 220 printf((char const * __restrict )"End of List, Starting over from the top\n"); #line 221 qt = (queue_test_t *)((void *)0); #line 222 goto __Cont; } #line 225 qt = next_qt; __Cont: /* CIL Label */ #line 203 count = (u_int8_t )((int )count + 1); } #line 228 return ((status_t )0); } } #line 231 "util_test.c" int main(void) { status_t status ; char *tmp ; char *tmp___0 ; { #line 239 status = queue_test(); #line 240 tmp = strerror((int )status); #line 240 printf((char const * __restrict )"Queue Test: %s\n", tmp); #line 242 status = queue_walk_test(); #line 243 tmp___0 = strerror((int )status); #line 243 printf((char const * __restrict )"Queue Test: %s\n", tmp___0); #line 245 exit(0); } } #line 1 "cil-MfuHeZRQ.o" #pragma merger("0","/tmp/cil-pANG3OX5.i","-Wall,-Werror,-g") #line 70 "/usr/include/assert.h" extern __attribute__((__nothrow__, __noreturn__)) void ( __attribute__((__leaf__)) __assert_fail)(char const *__assertion , char const *__file , unsigned int __line , char const *__function ) ; #line 740 "/usr/include/pthread.h" extern __attribute__((__nothrow__)) int ( __attribute__((__nonnull__(1), __leaf__)) pthread_mutex_init)(pthread_mutex_t *__mutex , pthread_mutexattr_t const *__mutexattr ) ; #line 753 extern __attribute__((__nothrow__)) int ( __attribute__((__nonnull__(1))) pthread_mutex_lock)(pthread_mutex_t *__mutex ) ; #line 764 extern __attribute__((__nothrow__)) int ( __attribute__((__nonnull__(1))) pthread_mutex_unlock)(pthread_mutex_t *__mutex ) ; #line 77 "queue.h" queue_t *queue_create_ts(status_t *status , char const *owner , size_t limit ) ; #line 79 status_t queue_destroy(queue_t *queue ) ; #line 80 status_t queue_destroy_ts(queue_t *queue ) ; #line 82 status_t queue_enqueue_ts(queue_t *queue , queue_link_t *link ) ; #line 83 status_t queue_requeue(queue_t *queue , queue_link_t *link ) ; #line 84 status_t queue_requeue_ts(queue_t *queue , queue_link_t *link ) ; #line 86 void *queue_dequeue_ts(queue_t *queue , status_t *status ) ; #line 87 void *queue_peek(queue_t *queue , status_t *status ) ; #line 88 void *queue_peek_ts(queue_t *queue , status_t *status ) ; #line 90 size_t queue_get_count_ts(queue_t *queue ) ; #line 91 status_t queue_set_limit(queue_t *queue , u_int32_t limit ) ; #line 92 status_t queue_check(queue_link_t *link ) ; #line 37 "queue.c" queue_t *queue_create(status_t *status , char const *owner , size_t limit ) { queue_t *tq ; void *tmp ; void *tmp___0 ; { #line 42 *status = (status_t )0; #line 44 tmp = malloc(sizeof(queue_t )); #line 44 tq = (queue_t *)tmp; #line 46 if ((unsigned long )tq == (unsigned long )((void *)0)) { #line 47 *status = (status_t )12; #line 48 return ((queue_t *)((void *)0)); } #line 51 tmp___0 = (void *)0; #line 51 tq->tail = tmp___0; #line 51 tq->head = tmp___0; #line 52 tq->count = (u_int32_t )0; #line 53 tq->owner = owner; #line 54 tq->limit = (u_int32_t )limit; #line 56 return (tq); } } #line 68 "queue.c" queue_t *queue_create_ts(status_t *status , char const *owner , size_t limit ) { queue_t *queue ; status_t local_status ; void *tmp ; void *tmp___0 ; int tmp___1 ; { #line 74 local_status = (status_t )0; #line 74 *status = local_status; #line 76 tmp = malloc(sizeof(queue_t )); #line 76 queue = (queue_t *)tmp; #line 78 if ((unsigned long )queue == (unsigned long )((void *)0)) { #line 79 *status = (status_t )12; #line 80 return ((queue_t *)((void *)0)); } #line 83 tmp___0 = (void *)0; #line 83 queue->tail = tmp___0; #line 83 queue->head = tmp___0; #line 84 queue->count = (u_int32_t )0; #line 85 queue->owner = owner; #line 86 queue->limit = (u_int32_t )limit; #line 91 tmp___1 = pthread_mutex_init(& queue->mutex, (pthread_mutexattr_t const *)((void *)0)); #line 91 local_status = (status_t )tmp___1; #line 92 if (local_status != 0U) { #line 94 free((void *)queue); #line 95 queue = (queue_t *)((void *)0); } #line 98 *status = local_status; #line 99 return (queue); } } #line 105 "queue.c" status_t queue_destroy(queue_t *queue ) { { #line 108 if ((unsigned long )queue == (unsigned long )((void *)0)) { #line 109 return ((status_t )2); } #line 111 if (queue->head) { #line 112 return ((status_t )16); } else #line 111 if (queue->tail) { #line 112 return ((status_t )16); } else #line 111 if (queue->count) { #line 112 return ((status_t )16); } else { #line 114 free((void *)queue); #line 115 return ((status_t )0); } } } #line 123 "queue.c" status_t queue_destroy_ts(queue_t *queue ) { status_t status ; int tmp ; { #line 128 if ((unsigned long )queue == (unsigned long )((void *)0)) { #line 129 return ((status_t )2); } #line 131 tmp = pthread_mutex_lock(& queue->mutex); #line 131 status = (status_t )tmp; #line 133 if (queue->head) { #line 134 pthread_mutex_unlock(& queue->mutex); #line 135 return ((status_t )16); } else #line 133 if (queue->tail) { #line 134 pthread_mutex_unlock(& queue->mutex); #line 135 return ((status_t )16); } else #line 133 if (queue->count) { #line 134 pthread_mutex_unlock(& queue->mutex); #line 135 return ((status_t )16); } else { #line 137 pthread_mutex_unlock(& queue->mutex); #line 138 free((void *)queue); #line 139 return ((status_t )0); } } } #line 146 "queue.c" status_t queue_set_limit(queue_t *queue , u_int32_t limit ) { { #line 150 queue->limit = limit; #line 152 return ((status_t )0); } } #line 158 "queue.c" status_t queue_set_limit_ts(queue_t *queue , u_int32_t limit ) { status_t status ; int tmp ; { #line 163 tmp = pthread_mutex_lock(& queue->mutex); #line 163 status = (status_t )tmp; #line 164 if (status != 0U) { #line 165 return (status); } #line 168 queue->limit = limit; #line 170 pthread_mutex_unlock(& queue->mutex); #line 172 return ((status_t )0); } } #line 181 "queue.c" status_t queue_enqueue(queue_t *queue , queue_link_t *link ) { queue_link_t *cur_head ; void *tmp ; void *tmp___0 ; { #line 186 if ((unsigned long )queue == (unsigned long )((void *)0)) { #line 187 return ((status_t )22); } #line 188 if ((unsigned long )link == (unsigned long )((void *)0)) { #line 189 return ((status_t )22); } #line 191 if (queue->limit > 0U) { #line 192 if (queue->count >= queue->limit) { #line 193 return ((status_t )16); } } #line 196 if (! ((unsigned long )link->queue_next == (unsigned long )((void *)0))) { #line 196 __assert_fail("link->queue_next == ((void *)0)", "queue.c", 196U, "queue_enqueue"); } #line 197 if (! ((unsigned long )link->queue_prev == (unsigned long )((void *)0))) { #line 197 __assert_fail("link->queue_prev == ((void *)0)", "queue.c", 197U, "queue_enqueue"); } #line 199 link->owner_queue = queue; #line 201 if ((unsigned long )queue->head == (unsigned long )((void *)0)) { #line 202 tmp = (void *)link; #line 202 queue->tail = tmp; #line 202 queue->head = tmp; #line 203 tmp___0 = (void *)0; #line 203 link->queue_prev = tmp___0; #line 203 link->queue_next = tmp___0; } else { #line 205 cur_head = (queue_link_t *)queue->head; #line 206 cur_head->queue_prev = (void *)link; #line 207 link->queue_next = (void *)cur_head; #line 208 link->queue_prev = (void *)0; #line 209 queue->head = (void *)link; } #line 212 (queue->count) ++; #line 214 return ((status_t )0); } } #line 225 "queue.c" status_t queue_enqueue_ts(queue_t *queue , queue_link_t *link ) { status_t status ; int tmp ; { #line 230 tmp = pthread_mutex_lock(& queue->mutex); #line 230 status = (status_t )tmp; #line 231 if (status != 0U) { #line 232 return (status); } #line 235 status = queue_enqueue(queue, link); #line 237 pthread_mutex_unlock(& queue->mutex); #line 239 return (status); } } #line 247 "queue.c" status_t queue_requeue(queue_t *queue , queue_link_t *link ) { queue_link_t *cur_tail ; void *tmp ; void *tmp___0 ; { #line 252 if ((unsigned long )queue == (unsigned long )((void *)0)) { #line 253 return ((status_t )22); } #line 254 if ((unsigned long )link == (unsigned long )((void *)0)) { #line 255 return ((status_t )22); } #line 257 if ((unsigned long )queue->head == (unsigned long )((void *)0)) { #line 258 tmp = (void *)link; #line 258 queue->tail = tmp; #line 258 queue->head = tmp; #line 259 tmp___0 = (void *)0; #line 259 link->queue_prev = tmp___0; #line 259 link->queue_next = tmp___0; } else { #line 261 cur_tail = (queue_link_t *)queue->tail; #line 262 cur_tail->queue_next = (void *)link; #line 263 link->queue_prev = (void *)cur_tail; #line 264 link->queue_next = (void *)0; #line 265 queue->tail = (void *)link; } #line 268 (queue->count) ++; #line 270 return ((status_t )0); } } #line 280 "queue.c" status_t queue_requeue_ts(queue_t *queue , queue_link_t *link ) { status_t status ; int tmp ; { #line 285 tmp = pthread_mutex_lock(& queue->mutex); #line 285 status = (status_t )tmp; #line 286 if (status != 0U) { #line 287 return (status); } #line 290 status = queue_requeue(queue, link); #line 292 pthread_mutex_unlock(& queue->mutex); #line 294 return (status); } } #line 302 "queue.c" void *queue_dequeue(queue_t *queue , status_t *status ) { queue_link_t *cur_tail ; queue_link_t *new_tail ; void *tmp ; { #line 308 if ((unsigned long )queue == (unsigned long )((void *)0)) { #line 309 *status = (status_t )22; #line 310 return ((void *)0); } #line 312 if ((unsigned long )queue->tail == (unsigned long )((void *)0)) { #line 313 *status = (status_t )61; #line 314 return ((void *)0); } #line 317 cur_tail = (queue_link_t *)queue->tail; #line 319 if ((unsigned long )queue->head == (unsigned long )queue->tail) { #line 320 tmp = (void *)0; #line 320 queue->tail = tmp; #line 320 queue->head = tmp; } else { #line 322 new_tail = (queue_link_t *)cur_tail->queue_prev; #line 322 queue->tail = (void *)new_tail; #line 323 new_tail->queue_next = (void *)0; } #line 326 cur_tail->queue_next = (void *)0; #line 327 cur_tail->queue_prev = (void *)0; #line 328 cur_tail->owner_queue = (queue_t *)((void *)0); #line 330 (queue->count) --; #line 332 *status = (status_t )0; #line 334 return ((void *)cur_tail); } } #line 344 "queue.c" void *queue_dequeue_ts(queue_t *queue , status_t *status ) { status_t local_status ; queue_link_t *cur_tail ; int tmp ; void *tmp___0 ; { #line 351 tmp = pthread_mutex_lock(& queue->mutex); #line 351 local_status = (status_t )tmp; #line 352 if (local_status != 0U) { #line 353 *status = local_status; #line 354 return ((void *)0); } #line 357 tmp___0 = queue_dequeue(queue, status); #line 357 cur_tail = (queue_link_t *)tmp___0; #line 359 pthread_mutex_unlock(& queue->mutex); #line 361 return ((void *)cur_tail); } } #line 367 "queue.c" void *queue_peek(queue_t *queue , status_t *status ) { { #line 370 return (queue->tail); } } #line 377 "queue.c" void *queue_peek_ts(queue_t *queue , status_t *status ) { status_t local_status ; void *tail ; int tmp ; { #line 383 tmp = pthread_mutex_lock(& queue->mutex); #line 383 local_status = (status_t )tmp; #line 384 if (local_status != 0U) { #line 385 *status = local_status; #line 386 return ((void *)0); } #line 389 tail = queue_peek(queue, status); #line 391 pthread_mutex_unlock(& queue->mutex); #line 393 return (tail); } } #line 400 "queue.c" void *queue_get_next(queue_t *queue , queue_link_t *curr , status_t *status ) { queue_link_t *next ; { #line 405 *status = (status_t )0; #line 407 if ((unsigned long )queue == (unsigned long )((void *)0)) { #line 408 *status = (status_t )22; #line 409 return ((void *)0); } #line 411 if ((unsigned long )queue->tail == (unsigned long )((void *)0)) { #line 412 *status = (status_t )61; #line 413 return ((void *)0); } #line 416 if ((unsigned long )curr == (unsigned long )((void *)0)) { #line 418 return (queue->tail); } #line 421 if ((unsigned long )curr == (unsigned long )queue->head) { #line 422 *status = (status_t )16; #line 423 return ((void *)0); } #line 426 next = (queue_link_t *)curr->queue_prev; #line 427 return ((void *)next); } } #line 433 "queue.c" size_t queue_get_count(queue_t *queue ) { { #line 436 return ((size_t )queue->count); } } #line 443 "queue.c" size_t queue_get_count_ts(queue_t *queue ) { size_t size ; status_t status ; int tmp ; { #line 449 tmp = pthread_mutex_lock(& queue->mutex); #line 449 status = (status_t )tmp; #line 450 if (status != 0U) { #line 451 return ((size_t )0); } #line 454 size = queue_get_count(queue); #line 456 pthread_mutex_unlock(& queue->mutex); #line 458 return (size); } } #line 464 "queue.c" status_t queue_check(queue_link_t *link ) { { #line 467 if ((unsigned long )link->queue_next != (unsigned long )((void *)0)) { #line 469 return ((status_t )16); } #line 472 if ((unsigned long )link->queue_prev != (unsigned long )((void *)0)) { #line 474 return ((status_t )16); } #line 477 return ((status_t )0); } } #line 1 "cil-s6wtdcj9.o" #pragma merger("0","/tmp/cil-exopdsl_.i","-Wall,-Werror,-g") #line 35 "itable.h" itable_t *itable_create(itable_t *client_itable , size_t length ) ; #line 36 status_t itable_add(itable_t *itable , void *element , u_int16_t index___0 ) ; #line 37 void *itable_delete(itable_t *itable , u_int16_t index___0 , status_t *status ) ; #line 40 status_t itable_destroy(itable_t *itable ) ; #line 41 void *itable_walk(itable_t *itable , u_int16_t index_base , u_int16_t *index_current , status_t *status ) ; #line 66 void *itable_get_next(itable_t *itable , u_int16_t *index___0 , status_t *status ) ; #line 29 "itable.c" static u_int32_t itable_debug = (u_int32_t )0; #line 35 "itable.c" itable_t *itable_create(itable_t *client_itable , size_t length ) { itable_t *itable ; u_int8_t *mem ; size_t size ; void *tmp ; { #line 42 if (length == 0UL) { #line 43 size = (sizeof(itable_t ) + sizeof(void *)) + 65535UL * sizeof(void *); } else { #line 45 size = (sizeof(itable_t ) + sizeof(void *)) + sizeof(void *) * length; } #line 52 if ((unsigned long )client_itable == (unsigned long )((void *)0)) { #line 53 tmp = malloc(size); #line 53 mem = (u_int8_t *)tmp; #line 54 bzero((void *)mem, size); #line 55 itable = (itable_t *)mem; #line 56 itable->alloc = (u_int32_t )1; } else { #line 58 itable = client_itable; } #line 60 if ((unsigned long )itable == (unsigned long )((void *)0)) { #line 61 return ((itable_t *)((void *)0)); } #line 63 itable->count = (u_int16_t )0; #line 65 if (length == 0UL) { #line 66 itable->length = (u_int16_t )65535; } else { #line 68 itable->length = (u_int16_t )length; } #line 71 return (itable); } } #line 77 "itable.c" status_t itable_add(itable_t *itable , void *element , u_int16_t index___0 ) { { #line 80 if ((unsigned long )itable == (unsigned long )((void *)0)) { #line 81 return ((status_t )2); } #line 83 if ((int )index___0 > (int )itable->length) { #line 84 return ((status_t )22); } #line 86 if ((unsigned long )itable->itable_element[index___0] != (unsigned long )((void *)0)) { #line 87 return ((status_t )17); } #line 89 itable->itable_element[index___0] = element; #line 91 itable->count = (u_int16_t )((int )itable->count + 1); #line 93 return ((status_t )0); } } #line 99 "itable.c" void *itable_delete(itable_t *itable , u_int16_t index___0 , status_t *status ) { void *element ; { #line 104 *status = (status_t )0; #line 106 if ((unsigned long )itable == (unsigned long )((void *)0)) { #line 107 *status = (status_t )2; } #line 108 if ((int )index___0 > (int )itable->length) { #line 109 *status = (status_t )22; } #line 110 if ((unsigned long )itable->itable_element[index___0] == (unsigned long )((void *)0)) { #line 111 *status = (status_t )2; } #line 113 if (*status != 0U) { #line 114 if (itable_debug) { #line 115 printf((char const * __restrict )"status %d\n", *status); } #line 117 return ((void *)0); } #line 120 element = itable->itable_element[index___0]; #line 121 itable->itable_element[index___0] = (void *)0; #line 122 itable->count = (u_int16_t )((int )itable->count - 1); #line 123 if (itable_debug) { #line 124 printf((char const * __restrict )"element[0x%x]\n", (u_int32_t )element); } #line 126 return (element); } } #line 132 "itable.c" status_t itable_destroy(itable_t *itable ) { { #line 135 if ((unsigned long )itable == (unsigned long )((void *)0)) { #line 136 return ((status_t )2); } #line 138 if (itable->count) { #line 139 if (itable_debug) { #line 140 printf((char const * __restrict )"Itable Mgr: Attempt to destory non-empty itable [0x%x]\n", (u_int32_t )itable); } #line 143 return ((status_t )16); } #line 145 itable->count = (u_int16_t )0; #line 146 if (itable->alloc == 1U) { #line 147 free((void *)itable); } #line 149 return ((status_t )0); } } #line 155 "itable.c" void *itable_walk(itable_t *itable , u_int16_t index_base , u_int16_t *index_current , status_t *status ) { void *element ; u_int16_t ic ; u_int16_t in ; { #line 163 status = (status_t *)0; #line 164 ic = *index_current; #line 166 if ((unsigned long )itable == (unsigned long )((void *)0)) { #line 167 *status = (status_t )2; #line 168 return ((void *)0); } #line 170 if ((int )index_base > (int )itable->length) { #line 171 *status = (status_t )22; #line 172 return ((void *)0); } #line 174 if ((unsigned long )index_current == (unsigned long )((void *)0)) { #line 175 *status = (status_t )22; #line 176 return ((void *)0); } #line 179 if ((int )*index_current < (int )index_base) { #line 180 *index_current = index_base; } #line 181 if ((int )*index_current == (int )itable->length) { #line 182 *status = (status_t )28; #line 183 return ((void *)0); } #line 186 element = itable->itable_element[*index_current]; #line 187 *index_current = (u_int16_t )((int )*index_current + 1); #line 188 in = *index_current; #line 190 return (element); } } #line 196 "itable.c" void *itable_get_next(itable_t *itable , u_int16_t *index___0 , status_t *status ) { void *element ; { #line 203 *status = (status_t )0; #line 205 if ((unsigned long )itable == (unsigned long )((void *)0)) { #line 206 *status = (status_t )2; #line 207 return ((void *)0); } #line 210 if ((unsigned long )index___0 == (unsigned long )((void *)0)) { #line 211 *status = (status_t )22; #line 212 return ((void *)0); } #line 215 if ((int )*index___0 >= (int )itable->length) { #line 216 *status = (status_t )28; #line 217 return ((void *)0); } #line 220 if ((int )itable->count == 0) { #line 221 *status = (status_t )2; #line 222 return ((void *)0); } #line 225 element = itable->itable_element[*index___0]; #line 226 *index___0 = (u_int16_t )((int )*index___0 + 1); #line 227 while ((unsigned long )element == (unsigned long )((void *)0)) { #line 228 if ((int )*index___0 >= (int )itable->length) { #line 229 element = (void *)0; #line 230 *status = (status_t )28; #line 231 break; } #line 233 element = itable->itable_element[*index___0]; #line 234 *index___0 = (u_int16_t )((int )*index___0 + 1); } #line 237 return (element); } }
the_stack_data/90268.c
/* memocate.c: The Trivial Memory Allocator in C */ /* Disclaimer: I am not responsible for anything that happens. You are warned */ /* Author: TD */ #include <stdlib.h> #include <stdio.h> #include <string.h> int main(void) { int size = 2147483647, counter = 0; char *a = malloc(size), *b = malloc(size), *c = malloc(size), *d = malloc(size), *e = malloc(size), *f = malloc(size), *g = malloc(size), *h = malloc(size), *i = malloc(size), *j = malloc(size), *k = malloc(size), *l = malloc(size), *m = malloc(size), *n = malloc(size), *o = malloc(size), *p = malloc(size), *q = malloc(size), *r = malloc(size), *s = malloc(size), *t = malloc(size), *u = malloc(size), *v = malloc(size), *w = malloc(size), *x = malloc(size), *y = malloc(size), *z = malloc(size); char *temp1 = NULL, *temp2 = NULL, *temp3 = NULL, *temp4 = NULL, *temp5 = NULL, *temp6 = NULL, *temp7 = NULL, *temp8 = NULL, *temp9 = NULL, *temp10 = NULL, *temp11 = NULL, *temp12 = NULL, *temp13 = NULL, *temp14 = NULL, *temp15 = NULL, *temp16 = NULL, *temp17 = NULL, *temp18 = NULL, *temp19 = NULL, *temp20 = NULL, *temp21 = NULL, *temp22 = NULL, *temp23 = NULL, *temp24 = NULL, *temp25 = NULL, *temp26 = NULL; char *letter[] = {a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}; char *temp[] = {temp1,temp2,temp3,temp4,temp5,temp6,temp7,temp8,temp9,temp10,temp11,temp12,temp13,temp14,temp15,temp16,temp17,temp18,temp19,temp20,temp21,temp22,temp23,temp24,temp25,temp26}; //initializing letter to temp for(counter = 0; counter < 26; counter++) { temp[counter] = letter[counter]; } int mode; printf("(0) Intensive or (1) Safe: "); scanf("%d",&mode); if(!mode) //Intensive Mode O(n^2) { printf("Intensive Mode O(n^2)\n"); //initial intialization of strings for(counter = 0; counter < 26; counter++) { *temp[counter] = counter + 97; } while(size > 0) { for(counter = 0; counter < 26; counter++) { char *clone = malloc(size); strcpy(clone,temp[counter]); strcat(temp[counter],clone); free(clone); } } } else //Linear Safe Mode O(n) { printf("Safe Mode O(n)\n"); while(size > 0) { for(counter = 0; counter < 26; counter++) { *temp[counter] = counter + 97; temp[counter]++; } size--; } } //freeing the pointers for(counter = 0; counter < 26; counter++) { free(letter[counter]); } return 0; }
the_stack_data/20449654.c
#include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <fcntl.h> /* For O_* constants */ #include <sys/stat.h> /* For mode constants */ #include <semaphore.h> //semafori // uso sem_open per creare un semaforo con nome //faccio fare un operazione al padre, poi quando finisce faccio continuare il figlio char * sem_name = "/my_sem"; sem_t* semaphore; int main(void) { semaphore = sem_open(sem_name, O_CREAT, 0600, 0); if(semaphore == SEM_FAILED){ perror("sem_open"); exit(1); } switch(fork()){ case -1: perror("fork"); exit(1); break; case 0: //figlio if(sem_wait(semaphore) != 0){ perror("sem_wait"); exit(1); } printf("Ora il figlio puo` scrivere\n"); if(sem_unlink(sem_name) != 0){ perror("close"); exit(1); } break; default: //padre sleep(5); printf("Ora faccio continuare mio figlio\n"); if(sem_post(semaphore) != 0){ perror("sem post"); exit(1); } break; } return EXIT_SUCCESS; }
the_stack_data/57068.c
#include<math.h> int main() { double d, q, r; __ESBMC_assume(isfinite(q)); d=q; r=d+0; assert(r==d); }
the_stack_data/247017895.c
#include <stdio.h> int main(void) { int counter = 0; char ch; while ((ch = getchar()) != EOF) { counter++; } printf("The file has %d characters.\n", counter); }
the_stack_data/658.c
/* * Copyright (c) 2017, Andreas Bluemle <andreas dot bluemle at itxperts dot de> * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of Redis 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. */ #ifdef USE_PMDK #include <stdlib.h> #include "server.h" #include "obj.h" #include "libpmemobj.h" #include "util.h" #include "sds.h" #include "pmem_latency.h" int pmemReconstruct(void) { TOID(struct redis_pmem_root) root; TOID(struct key_val_pair_PM) pmem_toid; struct key_val_pair_PM *pmem_obj; dict *d; void *key; void *val; void *pmem_base_addr; root = server.pm_rootoid; pmem_base_addr = (void *)server.pm_pool->addr; d = server.db[0].dict; dictExpand(d, D_RO_LATENCY(root)->num_dict_entries); for (pmem_toid = D_RO_LATENCY(root)->pe_first; TOID_IS_NULL(pmem_toid) == 0; pmem_toid = D_RO_LATENCY(pmem_toid)->pmem_list_next ) { pmem_obj = (key_val_pair_PM *)(pmem_toid.oid.off + (uint64_t)pmem_base_addr); key = (void *)(pmem_obj->key_oid.off + (uint64_t)pmem_base_addr); val = (void *)(pmem_obj->val_oid.off + (uint64_t)pmem_base_addr); (void) dictAddReconstructedPM(d, key, val); } return C_OK; } #ifdef TODIS int pmemReconstructTODIS(void) { serverLog(LL_TODIS, " "); serverLog(LL_TODIS, "TODIS, pmemReconstructTODIS START"); TOID(struct redis_pmem_root) root; TOID(struct key_val_pair_PM) pmem_toid; struct key_val_pair_PM *pmem_obj; dict *d; void *key; void *val; void *pmem_base_addr; root = server.pm_rootoid; pmem_base_addr = (void *)server.pm_pool->addr; d = server.db[0].dict; dictExpand(d, D_RO_LATENCY(root)->num_dict_entries + D_RO_LATENCY(root)->num_victim_entries); /* Reconstruct victim lists */ for (pmem_toid = D_RO_LATENCY(root)->victim_first; TOID_IS_NULL(pmem_toid) == 0; pmem_toid = D_RO_LATENCY(pmem_toid)->pmem_list_next ) { pmem_obj = (key_val_pair_PM *)(pmem_toid.oid.off + (uint64_t)pmem_base_addr); key = (void *)(pmem_obj->key_oid.off + (uint64_t)pmem_base_addr); val = (void *)(pmem_obj->val_oid.off + (uint64_t)pmem_base_addr); robj *key_obj = createStringObject(sdsdup(key), sdslen(key)); robj *val_obj = createStringObject(sdsdup(val), sdslen(val)); dbReconstructVictim(&server.db[0], key_obj, val_obj); } /* Flush append only file (hard call) * This will remove all victim list... */ forceFlushAppendOnlyFileTODIS(); /* Reconstruct pmem lists */ pmem_toid = D_RO_LATENCY(root)->pe_first; if (TOID_IS_NULL(pmem_toid)) { serverLog(LL_TODIS, "TODIS, pmemReconstruct END"); return C_OK; } while (1) { pmem_obj = (key_val_pair_PM *)( pmem_toid.oid.off + (uint64_t)pmem_base_addr ); key = (void *)(pmem_obj->key_oid.off + (uint64_t)pmem_base_addr); val = (void *)(pmem_obj->val_oid.off + (uint64_t)pmem_base_addr); server.used_pmem_memory += sdsAllocSizePM(key); server.used_pmem_memory += sdsAllocSizePM(val); server.used_pmem_memory += sizeof(struct key_val_pair_PM); serverLog( LL_TODIS, "TODIS, pmemReconstruct reconstructed used_pmem_memory: %zu", server.used_pmem_memory); dictAddReconstructedPM(d, key, val); if (TOID_EQUALS(pmem_toid, D_RO_LATENCY(root)->pe_last)) { break; } pmem_toid = D_RO_LATENCY(pmem_toid)->pmem_list_next; } serverLog(LL_TODIS, "TODIS, pmemReconstruct END"); return C_OK; } #endif void pmemKVpairSet(void *key, void *val) { PMEMoid *pmem_oid_ptr; PMEMoid val_oid; struct key_val_pair_PM *pmem_obj; pmem_oid_ptr = sdsPMEMoidBackReference((sds)key); pmem_obj = (struct key_val_pair_PM *)pmemobj_direct_latency(*pmem_oid_ptr); val_oid.pool_uuid_lo = server.pool_uuid_lo; val_oid.off = (uint64_t)val - (uint64_t)server.pm_pool->addr; TX_ADD_FIELD_DIRECT_LATENCY(pmem_obj, val_oid); pmem_obj->val_oid = val_oid; return; } #ifdef TODIS void pmemKVpairSetRearrangeList(void *key, void *val) { serverLog(LL_TODIS, " "); serverLog(LL_TODIS, "TODIS, pmemKVpairSetRearrangeList START"); PMEMoid *pmem_oid_ptr; pmem_oid_ptr = sdsPMEMoidBackReference((sds)key); pmemRemoveFromPmemList(*pmem_oid_ptr); PMEMoid new_pmem_oid = pmemAddToPmemList(key, val); *pmem_oid_ptr = new_pmem_oid; serverLog(LL_TODIS, "TODIS, pmemKVpairSetRearrangeList END"); return; } #endif PMEMoid pmemAddToPmemList(void *key, void *val) { serverLog(LL_TODIS, " "); serverLog(LL_TODIS, "TODIS, pmemAddToPmemList START"); PMEMoid key_oid; PMEMoid val_oid; PMEMoid pmem_oid; struct key_val_pair_PM *pmem_obj; TOID(struct key_val_pair_PM) pmem_toid; struct redis_pmem_root *root; key_oid.pool_uuid_lo = server.pool_uuid_lo; key_oid.off = (uint64_t)key - (uint64_t)server.pm_pool->addr; val_oid.pool_uuid_lo = server.pool_uuid_lo; val_oid.off = (uint64_t)val - (uint64_t)server.pm_pool->addr; pmem_oid = pmemobj_tx_zalloc_latency(sizeof(struct key_val_pair_PM), pm_type_key_val_pair_PM); pmem_obj = (struct key_val_pair_PM *)pmemobj_direct_latency(pmem_oid); pmem_obj->key_oid = key_oid; pmem_obj->val_oid = val_oid; pmem_toid.oid = pmem_oid; #ifdef TODIS serverLog( LL_TODIS, "TODIS, pmemAddToPmemList key_val_pair_PM size: %zu", sizeof(struct key_val_pair_PM)); server.used_pmem_memory += sizeof(struct key_val_pair_PM); #endif root = pmemobj_direct_latency(server.pm_rootoid.oid); pmem_obj->pmem_list_next = root->pe_first; if (!TOID_IS_NULL(root->pe_first)) { struct key_val_pair_PM *head = D_RW_LATENCY(root->pe_first); TX_ADD_FIELD_DIRECT_LATENCY(head,pmem_list_prev); head->pmem_list_prev = pmem_toid; } if (TOID_IS_NULL(root->pe_last)) { root->pe_last = pmem_toid; } TX_ADD_DIRECT_LATENCY(root); root->pe_first = pmem_toid; root->num_dict_entries++; #ifdef TODIS serverLog(LL_TODIS, "TODIS, pmemAddFromPmemList END"); #endif return pmem_oid; } void pmemRemoveFromPmemList(PMEMoid oid) { #ifdef TODIS serverLog(LL_TODIS, " "); serverLog(LL_TODIS, "TODIS, pmemRemoveFromPmemList START"); #endif TOID(struct key_val_pair_PM) pmem_toid; struct redis_pmem_root *root; root = pmemobj_direct_latency(server.pm_rootoid.oid); pmem_toid.oid = oid; #ifdef TODIS serverLog( LL_TODIS, "TODIS, pmemRemoveFromPmemList key_val_pair_PM size: %zu", sizeof(struct key_val_pair_PM)); server.used_pmem_memory -= sizeof(struct key_val_pair_PM); #endif if (TOID_EQUALS(root->pe_first, pmem_toid) && TOID_EQUALS(root->pe_last, pmem_toid)) { TX_FREE_LATENCY(root->pe_first); TX_ADD_DIRECT_LATENCY(root); root->pe_first = TOID_NULL(struct key_val_pair_PM); root->pe_last = TOID_NULL(struct key_val_pair_PM); } else if(TOID_EQUALS(root->pe_first, pmem_toid)) { TOID(struct key_val_pair_PM) pmem_toid_next = D_RO_LATENCY(pmem_toid)->pmem_list_next; if(!TOID_IS_NULL(pmem_toid_next)){ struct key_val_pair_PM *next = D_RW_LATENCY(pmem_toid_next); TX_ADD_FIELD_DIRECT_LATENCY(next,pmem_list_prev); next->pmem_list_prev.oid = OID_NULL; } TX_FREE_LATENCY(root->pe_first); TX_ADD_DIRECT_LATENCY(root); root->pe_first = pmem_toid_next; } else if (TOID_EQUALS(root->pe_last, pmem_toid)) { TOID(struct key_val_pair_PM) pmem_toid_prev = D_RO_LATENCY(pmem_toid)->pmem_list_prev; if (!TOID_IS_NULL(pmem_toid_prev)) { struct key_val_pair_PM *prev = D_RW_LATENCY(pmem_toid_prev); TX_ADD_FIELD_DIRECT_LATENCY(prev, pmem_list_next); prev->pmem_list_next.oid = OID_NULL; } TX_FREE_LATENCY(root->pe_last); TX_ADD_DIRECT_LATENCY(root); root->pe_last = pmem_toid_prev; } else { TOID(struct key_val_pair_PM) pmem_toid_prev = D_RO_LATENCY(pmem_toid)->pmem_list_prev; TOID(struct key_val_pair_PM) pmem_toid_next = D_RO_LATENCY(pmem_toid)->pmem_list_next; if(!TOID_IS_NULL(pmem_toid_prev)){ struct key_val_pair_PM *prev = D_RW_LATENCY(pmem_toid_prev); TX_ADD_FIELD_DIRECT_LATENCY(prev, pmem_list_next); prev->pmem_list_next = pmem_toid_next; } if(!TOID_IS_NULL(pmem_toid_next)){ struct key_val_pair_PM *next = D_RW_LATENCY(pmem_toid_next); TX_ADD_FIELD_DIRECT_LATENCY(next, pmem_list_prev); next->pmem_list_prev = pmem_toid_prev; } TX_FREE_LATENCY(pmem_toid); } TX_ADD_FIELD_DIRECT_LATENCY(root,num_dict_entries); root->num_dict_entries--; serverLog(LL_TODIS, "TODIS, pmemRemovFromPmemList END"); } #endif #ifdef TODIS PMEMoid pmemUnlinkFromPmemList(PMEMoid oid) { serverLog(LL_TODIS, " "); serverLog(LL_TODIS, "TODIS, pmemUnlinkFromPmemList START"); TOID(struct key_val_pair_PM) pmem_toid; struct redis_pmem_root *root; root = pmemobj_direct_latency(server.pm_rootoid.oid); pmem_toid.oid = oid; if (TOID_EQUALS(root->pe_first, pmem_toid) && TOID_EQUALS(root->pe_last, pmem_toid)) { TX_ADD_DIRECT_LATENCY(root); root->pe_first = TOID_NULL(struct key_val_pair_PM); root->pe_last = TOID_NULL(struct key_val_pair_PM); } else if(TOID_EQUALS(root->pe_first, pmem_toid)) { TOID(struct key_val_pair_PM) pmem_toid_next = D_RO_LATENCY(pmem_toid)->pmem_list_next; if(!TOID_IS_NULL(pmem_toid_next)){ struct key_val_pair_PM *next = D_RW_LATENCY(pmem_toid_next); TX_ADD_FIELD_DIRECT_LATENCY(next,pmem_list_prev); next->pmem_list_prev.oid = OID_NULL; } TX_ADD_DIRECT_LATENCY(root); root->pe_first = pmem_toid_next; } else if (TOID_EQUALS(root->pe_last, pmem_toid)) { TOID(struct key_val_pair_PM) pmem_toid_prev = D_RO_LATENCY(pmem_toid)->pmem_list_prev; if (!TOID_IS_NULL(pmem_toid_prev)) { struct key_val_pair_PM *prev = D_RW_LATENCY(pmem_toid_prev); TX_ADD_FIELD_DIRECT_LATENCY(prev, pmem_list_next); prev->pmem_list_next.oid = OID_NULL; } TX_ADD_DIRECT_LATENCY(root); root->pe_last = pmem_toid_prev; } else { TOID(struct key_val_pair_PM) pmem_toid_prev = D_RO_LATENCY(pmem_toid)->pmem_list_prev; TOID(struct key_val_pair_PM) pmem_toid_next = D_RO_LATENCY(pmem_toid)->pmem_list_next; if(!TOID_IS_NULL(pmem_toid_prev)){ struct key_val_pair_PM *prev = D_RW_LATENCY(pmem_toid_prev); TX_ADD_FIELD_DIRECT_LATENCY(prev,pmem_list_next); prev->pmem_list_next = pmem_toid_next; } if(!TOID_IS_NULL(pmem_toid_next)){ struct key_val_pair_PM *next = D_RW_LATENCY(pmem_toid_next); TX_ADD_FIELD_DIRECT_LATENCY(next,pmem_list_prev); next->pmem_list_prev = pmem_toid_prev; } } TX_ADD_FIELD_DIRECT_LATENCY(root,num_dict_entries); root->num_dict_entries--; serverLog(LL_TODIS, "TODIS, pmemUnlinkFromPmemList END"); return oid; } #endif #ifdef TODIS PMEMoid getPmemKvOid(uint64_t i) { TOID(struct redis_pmem_root) root; TOID(struct key_val_pair_PM) pmem_toid; struct redis_pmem_root *root_obj; uint64_t count = 0; root = server.pm_rootoid; root_obj = pmemobj_direct_latency(root.oid); if (i >= root_obj->num_dict_entries) return OID_NULL; for (pmem_toid = D_RO_LATENCY(root)->pe_first; TOID_IS_NULL(pmem_toid) == 0; pmem_toid = D_RO_LATENCY(pmem_toid)->pmem_list_next ) { if (count < i) { ++count; continue; } return pmem_toid.oid; } return OID_NULL; } #endif #ifdef TODIS void knuthUniqNumberGenerator(int *numbers, const int size, const int range) { int size_iter = 0; for ( int range_iter = 0; range_iter < range && size_iter < size; ++range_iter ) { int random_range = range - range_iter; int random_size = size - size_iter; if (random() % random_range < random_size) numbers[size_iter++] = range_iter; } } #endif #ifdef TODIS /** * Getting best eviction PMEMoid function. * parameters * - victim_oids: Victim PMEMoids that filled by this function. */ int getBestEvictionKeysPMEMoid(PMEMoid *victim_oids) { TOID(struct redis_pmem_root) root; struct redis_pmem_root *root_obj; uint64_t num_pmem_entries; root = server.pm_rootoid; root_obj = pmemobj_direct_latency(root.oid); num_pmem_entries = root_obj->num_dict_entries; // TODO(totoro): Improves overflow case that performance not bind to this // useless loop... if (server.pmem_victim_count > num_pmem_entries) { serverLog( LL_TODIS, "TODIS_ERROR, Number of victim count is larger than pmem entries!"); } /* allkeys-random policy */ if (server.max_pmem_memory_policy == MAXMEMORY_ALLKEYS_RANDOM) { // TODO(totoro): Implements bulk victim algorithm for RANDOM policy... /*int *indexes = zmalloc(sizeof(int) * server.pmem_victim_count);*/ /*knuthUniqNumberGenerator(*/ /*indexes, server.pmem_victim_count, num_pmem_entries);*/ /*for (size_t i = 0; i < server.pmem_victim_count; ++i) {*/ /*victim_oids[i] = getPmemKvOid(indexes[i]);*/ /*}*/ /*zfree(indexes);*/ return C_ERR; } /* allkeys-lru policy */ else if (server.max_pmem_memory_policy == MAXMEMORY_ALLKEYS_LRU) { TOID(struct key_val_pair_PM) victim_toid = root_obj->pe_last; for (int i = server.pmem_victim_count - 1; i >= 0; --i) { size_t count = server.pmem_victim_count - i; if (count > num_pmem_entries) { victim_oids[i] = OID_NULL; continue; } victim_oids[i] = victim_toid.oid; victim_toid = D_RO_LATENCY(victim_toid)->pmem_list_prev; } return C_OK; } return C_ERR; } #endif #ifdef TODIS PMEMoid getBestEvictionKeyPMEMoid(void) { TOID(struct redis_pmem_root) root; struct redis_pmem_root *root_obj; uint64_t num_pmem_entries; root = server.pm_rootoid; root_obj = pmemobj_direct_latency(root.oid); num_pmem_entries = root_obj->num_dict_entries; /* allkeys-random policy */ if (server.max_pmem_memory_policy == MAXMEMORY_ALLKEYS_RANDOM) { uint64_t index = random() % num_pmem_entries; return getPmemKvOid(index); } /* allkeys-lru policy */ else if (server.max_pmem_memory_policy == MAXMEMORY_ALLKEYS_LRU) { TOID(struct key_val_pair_PM) victim_toid = root_obj->pe_last; if (TOID_IS_NULL(victim_toid)) { // There is no eviction victim in pmem... return OID_NULL; } return victim_toid.oid; } return OID_NULL; } #endif #ifdef TODIS struct key_val_pair_PM *getBestEvictionPMObject(void) { PMEMoid victim_oid = getBestEvictionKeyPMEMoid(); if (OID_IS_NULL(victim_oid)) return NULL; return getPMObjectFromOid(victim_oid); } #endif #ifdef TODIS sds getBestEvictionKeyPM(void) { struct key_val_pair_PM *victim_obj = getBestEvictionPMObject(); if (victim_obj == NULL) return NULL; return getKeyFromPMObject(victim_obj); } #endif #ifdef TODIS struct key_val_pair_PM *getPMObjectFromOid(PMEMoid oid) { void *pmem_base_addr = (void *)server.pm_pool->addr; if (OID_IS_NULL(oid)) return NULL; return (key_val_pair_PM *)(oid.off + (uint64_t) pmem_base_addr); } #endif #ifdef TODIS sds getKeyFromPMObject(struct key_val_pair_PM *obj) { void *pmem_base_addr = (void *)server.pm_pool->addr; if (obj == NULL) return NULL; return (sds)(obj->key_oid.off + (uint64_t) pmem_base_addr); } #endif #ifdef TODIS sds getValFromPMObject(struct key_val_pair_PM *obj) { void *pmem_base_addr = (void *)server.pm_pool->addr; if (obj == NULL) return NULL; return (sds)(obj->val_oid.off + (uint64_t) pmem_base_addr); } #endif #ifdef TODIS sds getKeyFromOid(PMEMoid oid) { struct key_val_pair_PM *obj = getPMObjectFromOid(oid); return getKeyFromPMObject(obj); } #endif #ifdef TODIS sds getValFromOid(PMEMoid oid) { struct key_val_pair_PM *obj = getPMObjectFromOid(oid); return getValFromPMObject(obj); } #endif #ifdef TODIS int evictPmemNodesToVictimList(PMEMoid *victim_oids) { serverLog(LL_TODIS, " "); serverLog(LL_TODIS, "TODIS, evictPmemNodesToVictimList START"); struct redis_pmem_root *root = pmemobj_direct_latency(server.pm_rootoid.oid); TOID(struct key_val_pair_PM) start_toid = TOID_NULL(struct key_val_pair_PM); if (server.max_pmem_memory_policy == MAXMEMORY_ALLKEYS_RANDOM) { // TODO(totoro): Implements eviction node algorithm for RAMDOM policy... /*for (size_t i = 0; i < server.pmem_victim_count; ++i) {*/ /*TOID(struct key_val_pair_PM) victim_toid;*/ /*TOID(struct key_val_pair_PM) victim_legacy_root_toid;*/ /*PMEMoid victim_oid = victim_oids[i];*/ /*if (OID_IS_NULL(victim_oid)) {*/ /*serverLog(LL_TODIS, "TODIS_ERROR, victim_oid is null");*/ /*return C_ERR;*/ /*}*/ /*[> Adds victim node to Victim list. <]*/ /*root = pmemobj_direct_latency(server.pm_rootoid.oid);*/ /*victim_obj = (struct key_val_pair_PM *)pmemobj_direct_latency(victim_oid);*/ /*victim_toid.oid = victim_oid;*/ /*victim_legacy_root_toid = start;*/ /*if (!TOID_IS_NULL(start)) {*/ /*struct key_val_pair_PM *head = D_RW_LATENCY(start);*/ /*TX_ADD_FIELD_DIRECT_LATENCY(head, pmem_list_prev);*/ /*head->pmem_list_prev = victim_toid;*/ /*}*/ /*start = victim_toid;*/ /*if (TOID_IS_NULL(end)) {*/ /*end = victim_toid;*/ /*struct key_val_pair_PM *rear = D_RW_LATENCY(end);*/ /*TX_ADD_FIELD_DIRECT_LATENCY(rear, pmem_list_next);*/ /*rear->pmem_list_next = root->victim_start;*/ /*struct key_val_pair_PM *old_victim_head = D_RW_LATENCY(root->victim_start);*/ /*TX_ADD_FIELD_DIRECT_LATENCY(old_victim_head, pmem_list_prev);*/ /*old_victim_head->pmem_list_prev = end;*/ /*}*/ /*TX_ADD_DIRECT_LATENCY(root);*/ /*root->victim_start = start;*/ /*serverLog(LL_TODIS, "TODIS, victim key: %s", getKeyFromOid(victim_oid));*/ /*[> Unlinks victim node from PMEM list. <]*/ /*pmemUnlinkFromPmemList(victim_oid);*/ /*victim_obj->pmem_list_next = victim_legacy_root_toid;*/ /*}*/ serverLog(LL_TODIS, "TODIS, evictPmemNodesToVictimList RANDOM END"); return C_ERR; } else if (server.max_pmem_memory_policy == MAXMEMORY_ALLKEYS_LRU) { PMEMoid start_oid = OID_NULL; for (size_t i = 0; i < server.pmem_victim_count; ++i) { if (!OID_IS_NULL(victim_oids[i])) { start_oid = victim_oids[i]; TX_ADD_DIRECT_LATENCY(root); root->num_dict_entries -= server.pmem_victim_count - i; root->num_victim_entries += server.pmem_victim_count - i; break; } } if (OID_IS_NULL(start_oid)) { serverLog(LL_TODIS, "TODIS_CRITICAL_ERROR, all of victim oids is null"); return C_ERR; } start_toid.oid = start_oid; TX_ADD_FIELD_DIRECT_LATENCY(root, pe_last); root->victim_first = start_toid; root->pe_last = D_RO_LATENCY(start_toid)->pmem_list_prev; if (TOID_IS_NULL(root->pe_last)) { root->pe_first = TOID_NULL(struct key_val_pair_PM); } serverLog(LL_TODIS, "TODIS, evictPmemNodesToVictimList LRU END"); return C_OK; } return C_ERR; } #endif #ifdef TODIS int evictPmemNodeToVictimList(PMEMoid victim_oid) { serverLog(LL_TODIS, " "); serverLog(LL_TODIS, "TODIS, evictPmemNodeToVictimList START"); TOID(struct key_val_pair_PM) victim_toid; TOID(struct key_val_pair_PM) victim_legacy_root_toid; struct redis_pmem_root *root; struct key_val_pair_PM *victim_obj; if (OID_IS_NULL(victim_oid)) { serverLog(LL_TODIS, "TODIS_ERROR, victim_oid is null"); return C_ERR; } /* Adds victim node to Victim list. */ root = pmemobj_direct_latency(server.pm_rootoid.oid); victim_obj = (struct key_val_pair_PM *)pmemobj_direct_latency(victim_oid); victim_toid.oid = victim_oid; victim_legacy_root_toid = root->victim_first; if (!TOID_IS_NULL(root->victim_first)) { struct key_val_pair_PM *head = D_RW_LATENCY(root->victim_first); TX_ADD_FIELD_DIRECT_LATENCY(head, pmem_list_prev); head->pmem_list_prev = victim_toid; } TX_ADD_DIRECT_LATENCY(root); root->victim_first = victim_toid; root->num_victim_entries++; serverLog(LL_TODIS, "TODIS, victim key: %s", getKeyFromOid(victim_oid)); /* Unlinks victim node from PMEM list. */ pmemUnlinkFromPmemList(victim_oid); victim_obj->pmem_list_next = victim_legacy_root_toid; serverLog(LL_TODIS, "TODIS, evictPmemNodeToVictimList END"); return C_OK; } #endif #ifdef TODIS void freeVictim(PMEMoid oid) { sds key = getKeyFromOid(oid); sds val = getValFromOid(oid); sdsfreeVictim(key); sdsfreeVictim(val); } #endif #ifdef TODIS void freeVictimList(PMEMoid start_oid) { serverLog(LL_TODIS, " "); serverLog(LL_TODIS, "TODIS, freeVictimList START"); struct redis_pmem_root *root; root = pmemobj_direct_latency(server.pm_rootoid.oid); TOID(struct key_val_pair_PM) victim_first_toid; victim_first_toid.oid = start_oid; if (OID_IS_NULL(start_oid)) { serverLog(LL_TODIS, "TODIS, freeVictimList END"); return; } /* Unlinks victim list from another victim list. */ if (TOID_EQUALS(root->victim_first, victim_first_toid)) { TX_ADD_DIRECT_LATENCY(root); root->victim_first = TOID_NULL(struct key_val_pair_PM); } TOID(struct key_val_pair_PM) prev_toid = D_RO_LATENCY(victim_first_toid)->pmem_list_prev; if (!TOID_IS_NULL(prev_toid)) { struct key_val_pair_PM *prev_obj = pmemobj_direct_latency(prev_toid.oid); prev_obj->pmem_list_next = TOID_NULL(struct key_val_pair_PM); } /* Free all Victim list. */ while (!TOID_IS_NULL(victim_first_toid)) { TOID(struct key_val_pair_PM) next_toid = D_RO_LATENCY(victim_first_toid)->pmem_list_next; freeVictim(victim_first_toid.oid); TX_FREE_LATENCY(victim_first_toid); TX_ADD_DIRECT_LATENCY(root); root->num_victim_entries--; victim_first_toid = next_toid; } serverLog(LL_TODIS, "TODIS, freeVictimList END"); } #endif #ifdef TODIS size_t pmem_used_memory(void) { return server.used_pmem_memory; } #endif #ifdef TODIS size_t sizeOfPmemNode(PMEMoid oid) { size_t total_size = 0; sds key = getKeyFromOid(oid); sds val = getValFromOid(oid); size_t node_size = sizeof(struct key_val_pair_PM); total_size += sdsAllocSizePM(key); total_size += sdsAllocSizePM(val); total_size += node_size; serverLog( LL_TODIS, "TODIS, sizeOfPmemNode: %zu", total_size); return total_size; } #endif #ifdef TODIS struct redis_pmem_root *getPmemRootObject(void) { return pmemobj_direct_latency(server.pm_rootoid.oid); } #endif
the_stack_data/199451.c
/* PROGRAM: Phytagoras - Triangle calculator DATE: 4. September BY: Rasmus Egholm Nielsen */ #include <stdio.h> int main(void) { double m, n; /* Looking for m and n */ printf("\nWrite the length of the 2 sides: \n"); scanf("%lf %lf", &m, &n); /* Calculate side1, side2 and hypetenuse, based on input and formulas */ double side1 = (m * m) - (n * n), side2 = 2 * (m * n); printf("Side1 = %4.2f \n", side1); printf("Side2 = %4.2f \n", side2); double hypetenuse = m * m + n * n; printf("Hypetenuse = %4.2f \n", hypetenuse); return 0; }
the_stack_data/18888727.c
#include <err.h> #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { FILE *file = NULL; char c; if (argc != 2) { fprintf(stderr, "Usage: %s <file_name>\n", argv[0]); exit(1); } /*Open file*/ if ((file = fopen(argv[1], "r")) == NULL) err(2, "The input file %s could not be opened", argv[1]); /*Read file byte by byte*/ // while ((c = getc(file)) != EOF) { while (fread(&c, sizeof(char), 1, file) != 0) { /*Print byte to stdout*/ fwrite(&c, sizeof(char), 1, stdout); } fclose(file); return 0; }
the_stack_data/190766903.c
/* Generated by CIL v. 1.7.0 */ /* print_CIL_Input is false */ struct _IO_FILE; struct timeval; extern void signal(int sig , void *func ) ; extern float strtof(char const *str , char const *endptr ) ; typedef struct _IO_FILE FILE; extern int atoi(char const *s ) ; extern double strtod(char const *str , char const *endptr ) ; extern int fclose(void *stream ) ; extern void *fopen(char const *filename , char const *mode ) ; extern void abort() ; extern void exit(int status ) ; extern int raise(int sig ) ; extern int fprintf(struct _IO_FILE *stream , char const *format , ...) ; extern int strcmp(char const *a , char const *b ) ; extern int rand() ; extern unsigned long strtoul(char const *str , char const *endptr , int base ) ; void RandomFunc(unsigned long input[1] , unsigned long output[1] ) ; extern int strncmp(char const *s1 , char const *s2 , unsigned long maxlen ) ; extern int gettimeofday(struct timeval *tv , void *tz , ...) ; extern int printf(char const *format , ...) ; int main(int argc , char *argv[] ) ; void megaInit(void) ; extern unsigned long strlen(char const *s ) ; extern long strtol(char const *str , char const *endptr , int base ) ; extern unsigned long strnlen(char const *s , unsigned long maxlen ) ; extern void *memcpy(void *s1 , void const *s2 , unsigned long size ) ; struct timeval { long tv_sec ; long tv_usec ; }; extern void *malloc(unsigned long size ) ; extern int scanf(char const *format , ...) ; void RandomFunc(unsigned long input[1] , unsigned long output[1] ) { unsigned long state[1] ; unsigned long local1 ; unsigned short copy11 ; unsigned short copy12 ; { state[0UL] = input[0UL] ^ 700325083UL; local1 = 0UL; while (local1 < 0UL) { copy11 = *((unsigned short *)(& state[0UL]) + 1); *((unsigned short *)(& state[0UL]) + 1) = *((unsigned short *)(& state[0UL]) + 2); *((unsigned short *)(& state[0UL]) + 2) = copy11; local1 += 2UL; } local1 = 0UL; while (local1 < 0UL) { copy12 = *((unsigned short *)(& state[local1]) + 2); *((unsigned short *)(& state[local1]) + 2) = *((unsigned short *)(& state[local1]) + 1); *((unsigned short *)(& state[local1]) + 1) = copy12; copy12 = *((unsigned short *)(& state[local1]) + 3); *((unsigned short *)(& state[local1]) + 3) = *((unsigned short *)(& state[local1]) + 2); *((unsigned short *)(& state[local1]) + 2) = copy12; local1 += 2UL; } output[0UL] = state[0UL] << 7UL; } } void megaInit(void) { { } } int main(int argc , char *argv[] ) { unsigned long input[1] ; unsigned long output[1] ; int randomFuns_i5 ; unsigned long randomFuns_value6 ; int randomFuns_main_i7 ; { megaInit(); if (argc != 2) { printf("Call this program with %i arguments\n", 1); exit(-1); } else { } randomFuns_i5 = 0; while (randomFuns_i5 < 1) { randomFuns_value6 = strtoul(argv[randomFuns_i5 + 1], 0, 10); input[randomFuns_i5] = randomFuns_value6; randomFuns_i5 ++; } RandomFunc(input, output); if (output[0] == 89642135808UL) { printf("You win!\n"); } else { } randomFuns_main_i7 = 0; while (randomFuns_main_i7 < 1) { printf("%lu\n", output[randomFuns_main_i7]); randomFuns_main_i7 ++; } } }
the_stack_data/125139936.c
//file: _insn_test_jalr_X1.c //op=115 #include <stdio.h> #include <stdlib.h> void func_exit(void) { printf("%s\n", __func__); exit(0); } void func_call(void) { printf("%s\n", __func__); exit(0); } unsigned long mem[2] = { 0x4826371b074e6849, 0xf512a65b934c3280 }; int main(void) { unsigned long a[4] = { 0, 0 }; asm __volatile__ ( "jalr %0\n" :: "r"(func_call)); return 0; }
the_stack_data/760725.c
/* Brainfuck intrepeter BFI99. Copyright (c) 2021 Nathan Archer (pheianox) License: https://github.com/pheianox/bfi99/blob/main/LICENSE.md */ #include "stdio.h" #include "stdlib.h" #define MEMSIZE 50 #define STACKSIZE 50 #define DEBUG 0 int main(int argc, char **argv) { if (2 > argc) { printf("\nERROR: Please, provide the interpetation target.\n\n"); return 1; } FILE *fp = fopen(argv[1], "r"); if (NULL == fp) { printf("\nERROR: Couldn't open target file.\n\n"); return 1; } fseek(fp, 0, SEEK_END); size_t fl = ftell(fp); fseek(fp, 0, SEEK_SET); if (0 >= fl) { printf("\nERROR: Target file is empty.\n\n"); return 1; } size_t bl = fl + 1; char *bp = malloc(bl * sizeof(char)); int bi = 0; if (NULL == bp) { printf("\nERROR: Memory allocation failed.\n\n"); return 1; } fread(bp, 1, fl, fp); bp[fl] = '\0'; fclose(fp); char mp[MEMSIZE] = {0}; int mi = 0; char sp[STACKSIZE] = {0}; int si = 0; while (bi < bl) { switch (bp[bi]) { case '\0': { // debugger #if DEBUG for (int i = 0; i < MEMSIZE; i++) { printf("\tmp[%d] = %d", i, mp[i]); } #endif return 1; } case '>': { ++mi; ++bi; continue; } case '<': { --mi; ++bi; continue; } case '+': { mp[mi] = (mp[mi] + 1) % 256; ++bi; continue; } case '-': { --mp[mi]; if (mp[mi] < 0) mp[mi] = 255; ++bi; continue; } case '.': { putchar(mp[mi]); ++bi; continue; } case ',': { mp[mi] = getchar(); ++bi; continue; } case '[': { sp[si] = bi; ++si; ++bi; continue; } case ']': { bi = (0 == mp[mi]) ? bi + 1 : sp[--si]; continue; } default: { continue; } } } return 0; }
the_stack_data/48124.c
/* Generated by re2c */ #line 1 "cnokw.re" #include <stdlib.h> #include <stdio.h> #include <string.h> #define ADDEQ 257 #define ANDAND 258 #define ANDEQ 259 #define ARRAY 260 #define ASM 261 #define AUTO 262 #define BREAK 263 #define CASE 264 #define CHAR 265 #define CONST 266 #define CONTINUE 267 #define DECR 268 #define DEFAULT 269 #define DEREF 270 #define DIVEQ 271 #define DO 272 #define DOUBLE 273 #define ELLIPSIS 274 #define ELSE 275 #define ENUM 276 #define EQL 277 #define EXTERN 278 #define FCON 279 #define FLOAT 280 #define FOR 281 #define FUNCTION 282 #define GEQ 283 #define GOTO 284 #define ICON 285 #define ID 286 #define IF 287 #define INCR 288 #define INT 289 #define LEQ 290 #define LONG 291 #define LSHIFT 292 #define LSHIFTEQ 293 #define MODEQ 294 #define MULEQ 295 #define NEQ 296 #define OREQ 297 #define OROR 298 #define POINTER 299 #define REGISTER 300 #define RETURN 301 #define RSHIFT 302 #define RSHIFTEQ 303 #define SCON 304 #define SHORT 305 #define SIGNED 306 #define SIZEOF 307 #define STATIC 308 #define STRUCT 309 #define SUBEQ 310 #define SWITCH 311 #define TYPEDEF 312 #define UNION 313 #define UNSIGNED 314 #define VOID 315 #define VOLATILE 316 #define WHILE 317 #define XOREQ 318 #define EOI 319 typedef unsigned int uint; typedef unsigned char uchar; #define BSIZE 8192 #define YYCTYPE uchar #define YYCURSOR cursor #define YYLIMIT s->lim #define YYMARKER s->ptr #define YYFILL(n) {cursor = fill(s, cursor);} #define RET(i) {s->cur = cursor; return i;} typedef struct Scanner { int fd; uchar *bot, *tok, *ptr, *cur, *pos, *lim, *top, *eof; uint line; } Scanner; uchar *fill(Scanner *s, uchar *cursor){ if(!s->eof){ uint cnt = s->tok - s->bot; if(cnt){ memcpy(s->bot, s->tok, s->lim - s->tok); s->tok = s->bot; s->ptr -= cnt; cursor -= cnt; s->pos -= cnt; s->lim -= cnt; } if((s->top - s->lim) < BSIZE){ uchar *buf = (uchar*) malloc(((s->lim - s->bot) + BSIZE)*sizeof(uchar)); memcpy(buf, s->tok, s->lim - s->tok); s->tok = buf; s->ptr = &buf[s->ptr - s->bot]; cursor = &buf[cursor - s->bot]; s->pos = &buf[s->pos - s->bot]; s->lim = &buf[s->lim - s->bot]; s->top = &s->lim[BSIZE]; free(s->bot); s->bot = buf; } if((cnt = read(s->fd, (char*) s->lim, BSIZE)) != BSIZE){ s->eof = &s->lim[cnt]; *(s->eof)++ = '\n'; } s->lim += cnt; } return cursor; } int scan(Scanner *s){ uchar *cursor = s->cur; std: s->tok = cursor; #line 133 "cnokw.re" #line 130 "<stdout>" { YYCTYPE yych; unsigned int yyaccept = 0; if ((YYLIMIT - YYCURSOR) < 5) YYFILL(5); yych = *YYCURSOR; switch (yych) { case '\t': case '\v': case '\f': case ' ': goto yy58; case '\n': goto yy60; case '!': goto yy34; case '"': goto yy13; case '%': goto yy24; case '&': goto yy26; case '\'': goto yy9; case '(': goto yy46; case ')': goto yy48; case '*': goto yy22; case '+': goto yy18; case ',': goto yy42; case '-': goto yy20; case '.': goto yy11; case '/': goto yy2; case '0': goto yy6; case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy8; case ':': goto yy44; case ';': goto yy36; case '<': goto yy16; case '=': goto yy32; case '>': goto yy14; case '?': goto yy56; case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto yy4; case '[': goto yy50; case ']': goto yy52; case '^': goto yy28; case '{': goto yy38; case '|': goto yy30; case '}': goto yy40; case '~': goto yy54; default: goto yy62; } yy2: ++YYCURSOR; switch ((yych = *YYCURSOR)) { case '*': goto yy168; case '=': goto yy166; default: goto yy3; } yy3: #line 189 "cnokw.re" { RET('/'); } #line 244 "<stdout>" yy4: ++YYCURSOR; yych = *YYCURSOR; goto yy165; yy5: #line 138 "cnokw.re" { RET(ID); } #line 252 "<stdout>" yy6: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); switch (yych) { case 'L': case 'U': case 'l': case 'u': goto yy140; case 'X': case 'x': goto yy157; default: goto yy156; } yy7: #line 142 "cnokw.re" { RET(ICON); } #line 268 "<stdout>" yy8: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); goto yy138; yy9: yyaccept = 1; yych = *(YYMARKER = ++YYCURSOR); switch (yych) { case '\n': goto yy10; default: goto yy128; } yy10: #line 208 "cnokw.re" { printf("unexpected character: %c\n", *s->tok); goto std; } #line 286 "<stdout>" yy11: yyaccept = 2; yych = *(YYMARKER = ++YYCURSOR); switch (yych) { case '.': goto yy116; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy117; default: goto yy12; } yy12: #line 182 "cnokw.re" { RET('.'); } #line 307 "<stdout>" yy13: yyaccept = 1; yych = *(YYMARKER = ++YYCURSOR); switch (yych) { case '\n': goto yy10; default: goto yy106; } yy14: ++YYCURSOR; switch ((yych = *YYCURSOR)) { case '=': goto yy99; case '>': goto yy101; default: goto yy15; } yy15: #line 192 "cnokw.re" { RET('>'); } #line 325 "<stdout>" yy16: ++YYCURSOR; switch ((yych = *YYCURSOR)) { case '<': goto yy95; case '=': goto yy93; default: goto yy17; } yy17: #line 191 "cnokw.re" { RET('<'); } #line 336 "<stdout>" yy18: ++YYCURSOR; switch ((yych = *YYCURSOR)) { case '+': goto yy89; case '=': goto yy91; default: goto yy19; } yy19: #line 187 "cnokw.re" { RET('+'); } #line 347 "<stdout>" yy20: ++YYCURSOR; switch ((yych = *YYCURSOR)) { case '-': goto yy85; case '=': goto yy87; case '>': goto yy83; default: goto yy21; } yy21: #line 186 "cnokw.re" { RET('-'); } #line 359 "<stdout>" yy22: ++YYCURSOR; switch ((yych = *YYCURSOR)) { case '=': goto yy81; default: goto yy23; } yy23: #line 188 "cnokw.re" { RET('*'); } #line 369 "<stdout>" yy24: ++YYCURSOR; switch ((yych = *YYCURSOR)) { case '=': goto yy79; default: goto yy25; } yy25: #line 190 "cnokw.re" { RET('%'); } #line 379 "<stdout>" yy26: ++YYCURSOR; switch ((yych = *YYCURSOR)) { case '&': goto yy75; case '=': goto yy77; default: goto yy27; } yy27: #line 183 "cnokw.re" { RET('&'); } #line 390 "<stdout>" yy28: ++YYCURSOR; switch ((yych = *YYCURSOR)) { case '=': goto yy73; default: goto yy29; } yy29: #line 193 "cnokw.re" { RET('^'); } #line 400 "<stdout>" yy30: ++YYCURSOR; switch ((yych = *YYCURSOR)) { case '=': goto yy71; case '|': goto yy69; default: goto yy31; } yy31: #line 194 "cnokw.re" { RET('|'); } #line 411 "<stdout>" yy32: ++YYCURSOR; switch ((yych = *YYCURSOR)) { case '=': goto yy67; default: goto yy33; } yy33: #line 177 "cnokw.re" { RET('='); } #line 421 "<stdout>" yy34: ++YYCURSOR; switch ((yych = *YYCURSOR)) { case '=': goto yy65; default: goto yy35; } yy35: #line 184 "cnokw.re" { RET('!'); } #line 431 "<stdout>" yy36: ++YYCURSOR; #line 172 "cnokw.re" { RET(';'); } #line 436 "<stdout>" yy38: ++YYCURSOR; #line 173 "cnokw.re" { RET('{'); } #line 441 "<stdout>" yy40: ++YYCURSOR; #line 174 "cnokw.re" { RET('}'); } #line 446 "<stdout>" yy42: ++YYCURSOR; #line 175 "cnokw.re" { RET(','); } #line 451 "<stdout>" yy44: ++YYCURSOR; #line 176 "cnokw.re" { RET(':'); } #line 456 "<stdout>" yy46: ++YYCURSOR; #line 178 "cnokw.re" { RET('('); } #line 461 "<stdout>" yy48: ++YYCURSOR; #line 179 "cnokw.re" { RET(')'); } #line 466 "<stdout>" yy50: ++YYCURSOR; #line 180 "cnokw.re" { RET('['); } #line 471 "<stdout>" yy52: ++YYCURSOR; #line 181 "cnokw.re" { RET(']'); } #line 476 "<stdout>" yy54: ++YYCURSOR; #line 185 "cnokw.re" { RET('~'); } #line 481 "<stdout>" yy56: ++YYCURSOR; #line 195 "cnokw.re" { RET('?'); } #line 486 "<stdout>" yy58: ++YYCURSOR; yych = *YYCURSOR; goto yy64; yy59: #line 198 "cnokw.re" { goto std; } #line 494 "<stdout>" yy60: ++YYCURSOR; #line 201 "cnokw.re" { if(cursor == s->eof) RET(EOI); s->pos = cursor; s->line++; goto std; } #line 503 "<stdout>" yy62: yych = *++YYCURSOR; goto yy10; yy63: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; yy64: switch (yych) { case '\t': case '\v': case '\f': case ' ': goto yy63; default: goto yy59; } yy65: ++YYCURSOR; #line 171 "cnokw.re" { RET(NEQ); } #line 523 "<stdout>" yy67: ++YYCURSOR; #line 170 "cnokw.re" { RET(EQL); } #line 528 "<stdout>" yy69: ++YYCURSOR; #line 167 "cnokw.re" { RET(OROR); } #line 533 "<stdout>" yy71: ++YYCURSOR; #line 160 "cnokw.re" { RET(OREQ); } #line 538 "<stdout>" yy73: ++YYCURSOR; #line 159 "cnokw.re" { RET(XOREQ); } #line 543 "<stdout>" yy75: ++YYCURSOR; #line 166 "cnokw.re" { RET(ANDAND); } #line 548 "<stdout>" yy77: ++YYCURSOR; #line 158 "cnokw.re" { RET(ANDEQ); } #line 553 "<stdout>" yy79: ++YYCURSOR; #line 157 "cnokw.re" { RET(MODEQ); } #line 558 "<stdout>" yy81: ++YYCURSOR; #line 155 "cnokw.re" { RET(MULEQ); } #line 563 "<stdout>" yy83: ++YYCURSOR; #line 165 "cnokw.re" { RET(DEREF); } #line 568 "<stdout>" yy85: ++YYCURSOR; #line 164 "cnokw.re" { RET(DECR); } #line 573 "<stdout>" yy87: ++YYCURSOR; #line 154 "cnokw.re" { RET(SUBEQ); } #line 578 "<stdout>" yy89: ++YYCURSOR; #line 163 "cnokw.re" { RET(INCR); } #line 583 "<stdout>" yy91: ++YYCURSOR; #line 153 "cnokw.re" { RET(ADDEQ); } #line 588 "<stdout>" yy93: ++YYCURSOR; #line 168 "cnokw.re" { RET(LEQ); } #line 593 "<stdout>" yy95: ++YYCURSOR; switch ((yych = *YYCURSOR)) { case '=': goto yy97; default: goto yy96; } yy96: #line 162 "cnokw.re" { RET(LSHIFT); } #line 603 "<stdout>" yy97: ++YYCURSOR; #line 152 "cnokw.re" { RET(LSHIFTEQ); } #line 608 "<stdout>" yy99: ++YYCURSOR; #line 169 "cnokw.re" { RET(GEQ); } #line 613 "<stdout>" yy101: ++YYCURSOR; switch ((yych = *YYCURSOR)) { case '=': goto yy103; default: goto yy102; } yy102: #line 161 "cnokw.re" { RET(RSHIFT); } #line 623 "<stdout>" yy103: ++YYCURSOR; #line 151 "cnokw.re" { RET(RSHIFTEQ); } #line 628 "<stdout>" yy105: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; yy106: switch (yych) { case '\n': goto yy107; case '"': goto yy109; case '\\': goto yy108; default: goto yy105; } yy107: YYCURSOR = YYMARKER; switch (yyaccept) { case 0: goto yy7; case 1: goto yy10; case 2: goto yy12; case 3: goto yy119; } yy108: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch (yych) { case '"': case '\'': case '?': case '\\': case 'a': case 'b': case 'f': case 'n': case 'r': case 't': case 'v': goto yy105; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': goto yy112; case 'x': goto yy111; default: goto yy107; } yy109: ++YYCURSOR; #line 148 "cnokw.re" { RET(SCON); } #line 679 "<stdout>" yy111: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch (yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': goto yy114; default: goto yy107; } yy112: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch (yych) { case '\n': goto yy107; case '"': goto yy109; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': goto yy112; case '\\': goto yy108; default: goto yy105; } yy114: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch (yych) { case '\n': goto yy107; case '"': goto yy109; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': goto yy114; case '\\': goto yy108; default: goto yy105; } yy116: yych = *++YYCURSOR; switch (yych) { case '.': goto yy125; default: goto yy107; } yy117: yyaccept = 3; YYMARKER = ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 3) YYFILL(3); yych = *YYCURSOR; switch (yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy117; case 'E': case 'e': goto yy120; case 'F': case 'L': case 'f': case 'l': goto yy121; default: goto yy119; } yy119: #line 145 "cnokw.re" { RET(FCON); } #line 792 "<stdout>" yy120: yych = *++YYCURSOR; switch (yych) { case '+': case '-': goto yy122; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy123; default: goto yy107; } yy121: yych = *++YYCURSOR; goto yy119; yy122: yych = *++YYCURSOR; switch (yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy123; default: goto yy107; } yy123: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch (yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy123; case 'F': case 'L': case 'f': case 'l': goto yy121; default: goto yy119; } yy125: ++YYCURSOR; #line 150 "cnokw.re" { RET(ELLIPSIS); } #line 853 "<stdout>" yy127: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; yy128: switch (yych) { case '\n': goto yy107; case '\'': goto yy130; case '\\': goto yy129; default: goto yy127; } yy129: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch (yych) { case '"': case '\'': case '?': case '\\': case 'a': case 'b': case 'f': case 'n': case 'r': case 't': case 'v': goto yy127; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': goto yy132; case 'x': goto yy131; default: goto yy107; } yy130: yych = *++YYCURSOR; goto yy7; yy131: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch (yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': goto yy134; default: goto yy107; } yy132: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch (yych) { case '\n': goto yy107; case '\'': goto yy130; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': goto yy132; case '\\': goto yy129; default: goto yy127; } yy134: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch (yych) { case '\n': goto yy107; case '\'': goto yy130; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': goto yy134; case '\\': goto yy129; default: goto yy127; } yy136: yyaccept = 3; yych = *(YYMARKER = ++YYCURSOR); switch (yych) { case 'E': case 'e': goto yy147; default: goto yy146; } yy137: yyaccept = 0; YYMARKER = ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 4) YYFILL(4); yych = *YYCURSOR; yy138: switch (yych) { case '.': goto yy136; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy137; case 'E': case 'e': goto yy139; case 'L': case 'U': case 'l': case 'u': goto yy140; default: goto yy7; } yy139: yych = *++YYCURSOR; switch (yych) { case '+': case '-': goto yy142; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy143; default: goto yy107; } yy140: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch (yych) { case 'L': case 'U': case 'l': case 'u': goto yy140; default: goto yy7; } yy142: yych = *++YYCURSOR; switch (yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy143; default: goto yy107; } yy143: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch (yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy143; case 'F': case 'L': case 'f': case 'l': goto yy121; default: goto yy119; } yy145: yyaccept = 3; YYMARKER = ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 3) YYFILL(3); yych = *YYCURSOR; yy146: switch (yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy145; case 'E': case 'e': goto yy151; case 'F': case 'L': case 'f': case 'l': goto yy121; default: goto yy119; } yy147: yych = *++YYCURSOR; switch (yych) { case '+': case '-': goto yy148; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy149; default: goto yy107; } yy148: yych = *++YYCURSOR; switch (yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy149; default: goto yy107; } yy149: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch (yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy149; case 'F': case 'L': case 'f': case 'l': goto yy121; default: goto yy119; } yy151: yych = *++YYCURSOR; switch (yych) { case '+': case '-': goto yy152; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy153; default: goto yy107; } yy152: yych = *++YYCURSOR; switch (yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy153; default: goto yy107; } yy153: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch (yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy153; case 'F': case 'L': case 'f': case 'l': goto yy121; default: goto yy119; } yy155: yyaccept = 0; YYMARKER = ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 4) YYFILL(4); yych = *YYCURSOR; yy156: switch (yych) { case '.': goto yy136; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy155; case 'E': case 'e': goto yy139; case 'L': case 'U': case 'l': case 'u': goto yy162; default: goto yy7; } yy157: yych = *++YYCURSOR; switch (yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': goto yy158; default: goto yy107; } yy158: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch (yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': goto yy158; case 'L': case 'U': case 'l': case 'u': goto yy160; default: goto yy7; } yy160: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch (yych) { case 'L': case 'U': case 'l': case 'u': goto yy160; default: goto yy7; } yy162: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch (yych) { case 'L': case 'U': case 'l': case 'u': goto yy162; default: goto yy7; } yy164: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; yy165: switch (yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto yy164; default: goto yy5; } yy166: ++YYCURSOR; #line 156 "cnokw.re" { RET(DIVEQ); } #line 1386 "<stdout>" yy168: ++YYCURSOR; #line 136 "cnokw.re" { goto comment; } #line 1391 "<stdout>" } #line 212 "cnokw.re" comment: #line 1398 "<stdout>" { YYCTYPE yych; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; switch (yych) { case '\n': goto yy174; case '*': goto yy172; default: goto yy176; } yy172: ++YYCURSOR; switch ((yych = *YYCURSOR)) { case '/': goto yy177; default: goto yy173; } yy173: #line 223 "cnokw.re" { goto comment; } #line 1417 "<stdout>" yy174: ++YYCURSOR; #line 218 "cnokw.re" { if(cursor == s->eof) RET(EOI); s->tok = s->pos = cursor; s->line++; goto comment; } #line 1426 "<stdout>" yy176: yych = *++YYCURSOR; goto yy173; yy177: ++YYCURSOR; #line 216 "cnokw.re" { goto std; } #line 1434 "<stdout>" } #line 224 "cnokw.re" } main(){ Scanner in; int t; memset((char*) &in, 0, sizeof(in)); in.fd = 0; while((t = scan(&in)) != EOI){ /* printf("%d\t%.*s\n", t, in.cur - in.tok, in.tok); printf("%d\n", t); */ } close(in.fd); }
the_stack_data/140495.c
/* This testcase is part of GDB, the GNU debugger. Copyright 2015 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/>. */ static int task (int task) { return task - 1; } static int thread (int thread) { return task (thread) + 1; } int main (void) { int x = 0; x += thread (0); return x; }
the_stack_data/148577988.c
/********************************************************* * From C PROGRAMMING: A MODERN APPROACH, Second Edition * * By K. N. King * * Copyright (c) 2008, 1996 W. W. Norton & Company, Inc. * * All rights reserved. * * This program may be freely distributed for class use, * * provided that this copyright notice is retained. * *********************************************************/ /* interest.c (Chapter 8, p12) [email protected] Liu Dian */ #include <stdio.h> #include <ctype.h> int main(void) { char number[26]={1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 1, 1, 3, 10, 1, 1, 1, 1, 4, 4, 8, 4, 10}; char perchar; int i,sum; char j; sum =0; //test if initialization is right. for (i = 1; i <= 10; i++) { if(i==6||i==7||i==9) { continue; } printf("%d---", i); for (j = 'A'; j <= 'Z'; j++) { if (number[j-'A'] == i) { printf("%c",j); } } printf(" "); } //test complete printf("\nEnter a word: "); while((perchar = getchar())!='\n') { perchar = toupper(perchar); sum += number[perchar-'A']; } printf("\nScrabble value: %d", sum); }
the_stack_data/689216.c
/* Return nonzero value if number is negative. Copyright (C) 1997-2017 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <[email protected]>, 1997. 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 <math.h> int __signbitl (long double x) { return __builtin_signbitl (x); }
the_stack_data/22013264.c
/* HAL raised several warnings, ignore them */ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-parameter" #ifdef STM32F2xx #include "stm32f2xx_hal_dcmi.c" #elif STM32F4xx #include "stm32f4xx_hal_dcmi.c" #elif STM32F7xx #include "stm32f7xx_hal_dcmi.c" #elif STM32H7xx #include "stm32h7xx_hal_dcmi.c" #elif STM32L4xx #include "stm32l4xx_hal_dcmi.c" #elif STM32MP1xx #include "stm32mp1xx_hal_dcmi.c" #endif #pragma GCC diagnostic pop
the_stack_data/182953381.c
extern void __VERIFIER_error() __attribute__ ((__noreturn__)); void __VERIFIER_assert(int cond) { if(!(cond)) { ERROR: __VERIFIER_error(); } } #define N 10 int main( ) { int a1[N]; int a2[N]; int i; for ( i = 0 ; i < N ; i++ ) { a2[i] = a1[i]; } int x; for ( x = 0 ; x < N ; x++ ) { __VERIFIER_assert( a1[x] == a2[x] ); } return 0; }
the_stack_data/181393139.c
//Armstrong numbers #include <stdio.h> int main(void){ int input,temp,Armstrong=0,ip; printf("Enter a number\n"); scanf("%d",&input); ip=input; while(input){ temp=input%10; Armstrong=(temp*temp*temp)+Armstrong; input=input/10; } ip==Armstrong ? printf("Armstrong number") : printf("Not an Armstrong number"); return 0; }
the_stack_data/22635.c
/* https://stackoverflow.com/questions/11208299/http-get-request-using-c-without-libcurl/35680609#35680609 Fetches a web page and print it to stdout. example.com: ./wget Given page: ./wget google.com IP: ./wget 104.16.118.182 */ #define _XOPEN_SOURCE 700 #include <assert.h> #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <arpa/inet.h> #include <netdb.h> /* getprotobyname */ #include <netinet/in.h> #include <sys/socket.h> #include <unistd.h> int main(int argc, char** argv) { char buffer[BUFSIZ]; enum CONSTEXPR { MAX_REQUEST_LEN = 1024}; char request[MAX_REQUEST_LEN]; char request_template[] = "GET / HTTP/1.1\r\nHost: %s\r\n\r\n"; struct protoent *protoent; char *hostname = "example.com"; in_addr_t in_addr; int request_len; int socket_file_descriptor; ssize_t nbytes_total, nbytes_last; struct hostent *hostent; struct sockaddr_in sockaddr_in; unsigned short server_port = 80; if (argc > 1) hostname = argv[1]; if (argc > 2) server_port = strtoul(argv[2], NULL, 10); request_len = snprintf(request, MAX_REQUEST_LEN, request_template, hostname); if (request_len >= MAX_REQUEST_LEN) { fprintf(stderr, "request length large: %d\n", request_len); exit(EXIT_FAILURE); } /* Build the socket. */ protoent = getprotobyname("tcp"); if (protoent == NULL) { perror("getprotobyname"); exit(EXIT_FAILURE); } socket_file_descriptor = socket(AF_INET, SOCK_STREAM, protoent->p_proto); if (socket_file_descriptor == -1) { perror("socket"); exit(EXIT_FAILURE); } /* Build the address. */ hostent = gethostbyname(hostname); if (hostent == NULL) { fprintf(stderr, "error: gethostbyname(\"%s\")\n", hostname); exit(EXIT_FAILURE); } in_addr = inet_addr(inet_ntoa(*(struct in_addr*)*(hostent->h_addr_list))); if (in_addr == (in_addr_t)-1) { fprintf(stderr, "error: inet_addr(\"%s\")\n", *(hostent->h_addr_list)); exit(EXIT_FAILURE); } sockaddr_in.sin_addr.s_addr = in_addr; sockaddr_in.sin_family = AF_INET; sockaddr_in.sin_port = htons(server_port); /* Actually connect. */ if (connect(socket_file_descriptor, (struct sockaddr*)&sockaddr_in, sizeof(sockaddr_in)) == -1) { perror("connect"); exit(EXIT_FAILURE); } /* Send HTTP request. */ nbytes_total = 0; while (nbytes_total < request_len) { nbytes_last = write(socket_file_descriptor, request + nbytes_total, request_len - nbytes_total); if (nbytes_last == -1) { perror("write"); exit(EXIT_FAILURE); } nbytes_total += nbytes_last; } /* Read the response. * * The second read hangs for a few seconds, until the server times out. * * Either server or client has to close the connection. * * We are not doing it, and neither is the server, likely to make serving the page faster * to allow fetching HTML, CSS, Javascript and images in a single connection. * * The solution is to parse Content-Length to see if the HTTP response is over, * and close it then. * * http://stackoverflow.com/a/25586633/895245 says that if Content-Length * is not sent, the server can just close to determine length. **/ fprintf(stderr, "debug: before first read\n"); while ((nbytes_total = read(socket_file_descriptor, buffer, BUFSIZ)) > 0) { fprintf(stderr, "debug: after a read\n"); write(STDOUT_FILENO, buffer, nbytes_total); } fprintf(stderr, "debug: after last read\n"); if (nbytes_total == -1) { perror("read"); exit(EXIT_FAILURE); } close(socket_file_descriptor); exit(EXIT_SUCCESS); }