file
stringlengths
18
26
data
stringlengths
3
1.04M
the_stack_data/135534.c
/* gcc -std=c17 -lc -lm -pthread -o ../_build/c/numeric_math_fabs.exe ./c/numeric_math_fabs.c && (cd ../_build/c/;./numeric_math_fabs.exe) https://en.cppreference.com/w/c/numeric/math/fabs */ #include <stdio.h> #include <math.h> /* This numerical integration assumes all area is positive. */ #define PI 3.14159 double num_int (double a, double b, double f(double), unsigned n) { if (a == b) return 0.0; if (n == 0) n=1; /* avoid division by zero */ double h = (b-a)/n; double sum = 0.0; for (unsigned k=0; k < n; ++k) sum += h*fabs(f(a+k*h)); return sum; } int main(void) { printf("fabs(+3) = %f\n", fabs(+3.0)); printf("fabs(-3) = %f\n", fabs(-3.0)); // special values printf("fabs(-0) = %f\n", fabs(-0.0)); printf("fabs(-Inf) = %f\n", fabs(-INFINITY)); printf("%f\n", num_int(0.0,2*PI,sin,100000)); }
the_stack_data/112272.c
#include<stdio.h> int main() { int n; while(1){ scanf("%d",&n); if(n==2002){ printf("Acesso Permitido\n"); break; } else printf("Senha Invalida\n"); } return 0; }
the_stack_data/103266216.c
#include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { int i; for (i = 1; i < argc; i++) { FILE *f; int c; int cnt = 0; f = fopen(argv[i], "r"); if (!f) { perror(argv[i]); exit(1); } while ((c = fgetc(f)) != EOF) { if (c == '\n') { cnt++; } } printf("%s: %d lines\n", argv[i], cnt); fclose(f); } exit(0); }
the_stack_data/715684.c
/* Author: David Anderle Github: https://github.com/Andergonan/ LICENSE: https://github.com/Andergonan/C_language/blob/main/LICENSE File name: c-files.c */ #include <stdio.h> int main () { int hodnota; printf("Zadejte kladne ci zaporne realne cislo: "); scanf("%d", &hodnota); FILE *fw; fw = fopen("c-files.txt", "w"); fprintf(fw, "Vami zadane cislo: %d", hodnota); fclose(fw); return 0; }
the_stack_data/132954185.c
/*------------------------------------------------------------------------- _strcmp.c - part of string library functions Copyright (C) 2011, Philipp Klaus Krause . [email protected] This library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this library; see the file COPYING. If not, write to the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. As a special exception, if you link this library with other files, some of which are compiled with SDCC, to produce an executable, this library does not by itself cause the resulting executable to be covered by the GNU General Public License. This exception does not however invalidate any other reasons why the executable file might be covered by the GNU General Public License. -------------------------------------------------------------------------*/ #include "string.h" size_t strxfrm(char *dest, const char *src, size_t n) { strncpy(dest, src, n); return(strlen(src) + 1); }
the_stack_data/206391909.c
/* Name: Programeringsstil Program til at udregne gennemsnittet af 3 tal. Svagheder: Programmet tager ikke højde for om hvilken type der bliver indtastet, og der kan komme forkerte outputs. */ #include <stdio.h> int main(void) { float firstNumber, secondNumber, thirdNumber; printf("Find the average of 3 numbers.\nType in three numbers: "); scanf("%f %f %f", &firstNumber, &secondNumber, &thirdNumber); printf("The result: %f\n", (firstNumber + secondNumber + thirdNumber) / 3.0); return 0; }
the_stack_data/198580606.c
typedef unsigned int UINT32; int main(void) { UINT32 u32ValidFrameCount; UINT32 u32SampleIndex; UINT32 u32SamplesPerFrame; while (u32ValidFrameCount--) { for (u32SampleIndex=0; u32SampleIndex+1<u32SamplesPerFrame; u32SampleIndex += 2) { ; } } return 0; }
the_stack_data/282091.c
#include <stdio.h> int main() { printf("Hello World\n"); }
the_stack_data/37637118.c
/* * 30-Jun-95 tjh applied the security patch from the CERT advisory * ................. that I'd missed earlier */ /*- * Copyright (c) 1991 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifndef lint #ifdef __GNUC__ __attribute__ ((unused)) #endif /* __GNUC__ */ static char sccsid[] = "@(#)auth.c 5.2 (Berkeley) 3/22/91"; #endif /* not lint */ /* * Copyright (C) 1990 by the Massachusetts Institute of Technology * * Export of this software from the United States of America is assumed * to require a specific license from the United States Government. * It is the responsibility of any person or organization contemplating * export to obtain such a license before exporting. * * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and * distribute this software and its documentation for any purpose and * without fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright notice and * this permission notice appear in supporting documentation, and that * the name of M.I.T. not be used in advertising or publicity pertaining * to distribution of the software without specific, written prior * permission. M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" without express * or implied warranty. */ #if defined(AUTHENTICATE) #include <stdio.h> #include <sys/types.h> #include <signal.h> #define AUTH_NAMES #include <arpa/telnet.h> #ifdef __STDC__ #include <stdlib.h> #endif #ifdef NO_STRING_H #include <strings.h> #else #include <string.h> #endif #include "encrypt.h" #include "auth.h" #include "misc-proto.h" #include "auth-proto.h" #define typemask(x) (1<<((x)-1)) int auth_onoff(const char *type, int on); int auth_debug_mode = 0; static char *Name = "Noname"; static int Server = 0; static Authenticator *authenticated = 0; static int authenticating = 0; static int validuser = 0; static unsigned char _auth_send_data[256]; static unsigned char *auth_send_data; static int auth_send_cnt = 0; /* * Authentication types supported. Plese note that these are stored * in priority order, i.e. try the first one first. */ Authenticator authenticators[] = { #ifdef USE_SSL { AUTHTYPE_SSL, AUTH_WHO_CLIENT|AUTH_HOW_ONE_WAY, auth_ssl_init, auth_ssl_send, auth_ssl_is, auth_ssl_reply, auth_ssl_status, auth_ssl_printsub }, #endif /* USE_SSL */ #ifdef SRA { AUTHTYPE_SRA, AUTH_WHO_CLIENT|AUTH_HOW_ONE_WAY, sra_init, sra_send, sra_is, sra_reply, sra_status, sra_printsub }, #endif #ifdef KRB5 { AUTHTYPE_KERBEROS_V5, AUTH_WHO_CLIENT|AUTH_HOW_MUTUAL, kerberos5_init, kerberos5_send, kerberos5_is, kerberos5_reply, kerberos5_status, kerberos5_printsub }, { AUTHTYPE_KERBEROS_V5, AUTH_WHO_CLIENT|AUTH_HOW_ONE_WAY, kerberos5_init, kerberos5_send, kerberos5_is, kerberos5_reply, kerberos5_status, kerberos5_printsub }, #endif #ifdef KRB4 { AUTHTYPE_KERBEROS_V4, AUTH_WHO_CLIENT|AUTH_HOW_MUTUAL, kerberos4_init, kerberos4_send, kerberos4_is, kerberos4_reply, kerberos4_status, kerberos4_printsub }, { AUTHTYPE_KERBEROS_V4, AUTH_WHO_CLIENT|AUTH_HOW_ONE_WAY, kerberos4_init, kerberos4_send, kerberos4_is, kerberos4_reply, kerberos4_status, kerberos4_printsub }, #endif { 0, }, }; static Authenticator NoAuth = { 0 }; static int i_support = 0; static int i_wont_support = 0; Authenticator * findauthenticator(type, way) int type; int way; { Authenticator *ap = authenticators; while (ap->type && (ap->type != type || ap->way != way)) ++ap; return(ap->type ? ap : 0); } void auth_init(name, server) char *name; int server; { Authenticator *ap = authenticators; Server = server; Name = name; i_support = 0; authenticated = 0; authenticating = 0; while (ap->type) { if (!ap->init || (*ap->init)(ap, server)) { i_support |= typemask(ap->type); if (auth_debug_mode) printf(">>>%s: I support auth type %d %d\r\n", Name, ap->type, ap->way); } ++ap; } } void auth_disable_name(name) char *name; { int x; for (x = 0; x < N_AUTHTYPE; ++x) { if (!strcasecmp(name, AUTHTYPE_NAME(x))) { i_wont_support |= typemask(x); break; } } } int getauthmask(type, maskp) char *type; int *maskp; { register int x; if (!strcasecmp(type, AUTHTYPE_NAME(0))) { *maskp = -1; return(1); } for (x = 1; x < N_AUTHTYPE; ++x) { if (!strcasecmp(type, AUTHTYPE_NAME(x))) { *maskp = typemask(x); return(1); } } return(0); } int auth_enable(const char *type, const char *a) { return(auth_onoff(type, 1)); } int auth_disable(const char *type, const char *a) { return(auth_onoff(type, 0)); } int auth_onoff(type, on) const char *type; int on; { int i, mask = -1; Authenticator *ap; if (!strcasecmp(type, "?") || !strcasecmp(type, "help")) { printf("auth %s 'type'\n", on ? "enable" : "disable"); printf("Where 'type' is one of:\n"); printf("\t%s\n", AUTHTYPE_NAME(0)); mask = 0; for (ap = authenticators; ap->type; ap++) { if ((mask & (i = typemask(ap->type))) != 0) continue; mask |= i; printf("\t%s\n", AUTHTYPE_NAME(ap->type)); } return(0); } if (!getauthmask(type, &mask)) { printf("%s: invalid authentication type\n", type); return(0); } if (on) i_wont_support &= ~mask; else i_wont_support |= mask; return(1); } int auth_togdebug(on) int on; { if (on < 0) auth_debug_mode ^= 1; else auth_debug_mode = on; printf("auth debugging %s\n", auth_debug_mode ? "enabled" : "disabled"); return(1); } int auth_status(const char *type, const char *a) { Authenticator *ap; int i, mask; if (i_wont_support == -1) printf("Authentication disabled\n"); else printf("Authentication enabled\n"); mask = 0; for (ap = authenticators; ap->type; ap++) { if ((mask & (i = typemask(ap->type))) != 0) continue; mask |= i; printf("%s: %s\n", AUTHTYPE_NAME(ap->type), (i_wont_support & typemask(ap->type)) ? "disabled" : "enabled"); } return(1); } /* * This routine is called by the server to start authentication * negotiation. */ void auth_request() { static unsigned char str_request[64] = { IAC, SB, TELOPT_AUTHENTICATION, TELQUAL_SEND, }; Authenticator *ap = authenticators; unsigned char *e = str_request + 4; if (!authenticating) { authenticating = 1; while (ap->type) { if (i_support & ~i_wont_support & typemask(ap->type)) { if (auth_debug_mode) { printf(">>>%s: Sending type %d %d\r\n", Name, ap->type, ap->way); } *e++ = ap->type; *e++ = ap->way; } ++ap; } *e++ = IAC; *e++ = SE; writenet(str_request, e - str_request); printsub('>', &str_request[2], e - str_request - 2); } } /* * This is called when an AUTH SEND is received. * It should never arrive on the server side (as only the server can * send an AUTH SEND). * You should probably respond to it if you can... * * If you want to respond to the types out of order (i.e. even * if he sends LOGIN KERBEROS and you support both, you respond * with KERBEROS instead of LOGIN (which is against what the * protocol says)) you will have to hack this code... */ void auth_send(data, cnt) unsigned char *data; int cnt; { Authenticator *ap; static unsigned char str_none[] = { IAC, SB, TELOPT_AUTHENTICATION, TELQUAL_IS, AUTHTYPE_NULL, 0, IAC, SE }; if (Server) { if (auth_debug_mode) { printf(">>>%s: auth_send called!\r\n", Name); } return; } if (auth_debug_mode) { printf(">>>%s: auth_send got:", Name); printd(data, cnt); printf("\r\n"); } /* * Save the data, if it is new, so that we can continue looking * at it if the authorization we try doesn't work */ if (data < _auth_send_data || data > _auth_send_data + sizeof(_auth_send_data)) { auth_send_cnt = cnt > sizeof(_auth_send_data) ? sizeof(_auth_send_data) : cnt; memcpy((void *)_auth_send_data,(void *)data, auth_send_cnt); auth_send_data = _auth_send_data; } else { /* * This is probably a no-op, but we just make sure */ auth_send_data = data; auth_send_cnt = cnt; } while ((auth_send_cnt -= 2) >= 0) { if (auth_debug_mode) printf(">>>%s: He supports %d\r\n", Name, *auth_send_data); if ((i_support & ~i_wont_support) & typemask(*auth_send_data)) { ap = findauthenticator(auth_send_data[0], auth_send_data[1]); if (!ap) { printf("Internal state error: cannot find authentication type %d a second time\r\n", *auth_send_data); } else if (ap->send) { if (auth_debug_mode) printf(">>>%s: Trying %d %d\r\n", Name, auth_send_data[0], auth_send_data[1]); if ((*ap->send)(ap)) { /* * Okay, we found one we like * and did it. * we can go home now. */ if (auth_debug_mode) printf(">>>%s: Using type %d\r\n", Name, *auth_send_data); auth_send_data += 2; return; } } /* else * just continue on and look for the * next one if we didn't do anything. */ } auth_send_data += 2; } writenet(str_none, sizeof(str_none)); printsub('>', &str_none[2], sizeof(str_none) - 2); if (auth_debug_mode) printf(">>>%s: Sent failure message\r\n", Name); auth_finished(0, AUTH_REJECT); } void auth_send_retry() { /* * if auth_send_cnt <= 0 then auth_send will end up rejecting * the authentication and informing the other side of this. */ auth_send(auth_send_data, auth_send_cnt); } void auth_is(data, cnt) unsigned char *data; int cnt; { Authenticator *ap; if (cnt < 2) return; if (data[0] == AUTHTYPE_NULL) { auth_finished(0, AUTH_REJECT); return; } if ((ap = findauthenticator(data[0], data[1]))) { if (ap->is) (*ap->is)(ap, data+2, cnt-2); } else if (auth_debug_mode) printf(">>>%s: Invalid authentication in IS: %d\r\n", Name, *data); } void auth_reply(data, cnt) unsigned char *data; int cnt; { Authenticator *ap; if (cnt < 2) return; if ((ap = findauthenticator(data[0], data[1]))) { if (ap->reply) (*ap->reply)(ap, data+2, cnt-2); } else if (auth_debug_mode) printf(">>>%s: Invalid authentication in SEND: %d\r\n", Name, *data); } void auth_name(data, cnt) unsigned char *data; int cnt; { /* Authenticator *ap; */ unsigned char savename[256]; if (cnt < 1) { if (auth_debug_mode) printf(">>>%s: Empty name in NAME\r\n", Name); return; } if (cnt > sizeof(savename) - 1) { if (auth_debug_mode) printf(">>>%s: Name in NAME (%d) exceeds %d length\r\n", Name, cnt, sizeof(savename)-1); return; } memcpy((void *)savename, (void *)data,cnt); savename[cnt] = '\0'; /* Null terminate */ if (auth_debug_mode) printf(">>>%s: Got NAME [%s]\r\n", Name, savename); auth_encrypt_user(savename); } int auth_sendname(cp, len) unsigned char *cp; int len; { static unsigned char str_request[256+6] = { IAC, SB, TELOPT_AUTHENTICATION, TELQUAL_NAME, }; register unsigned char *e = str_request + 4; register unsigned char *ee = &str_request[sizeof(str_request)-2]; while (--len >= 0) { if ((*e++ = *cp++) == IAC) *e++ = IAC; if (e >= ee) return(0); } *e++ = IAC; *e++ = SE; writenet(str_request, e - str_request); printsub('>', &str_request[2], e - &str_request[2]); return(1); } void auth_finished(ap, result) Authenticator *ap; int result; { if (!(authenticated = ap)) authenticated = &NoAuth; validuser = result; } /* ARGSUSED */ #ifdef __GNUC__ __attribute__ ((used)) #endif /* __GNUC__ */ static void auth_intr(sig) int sig; { auth_finished(0, AUTH_REJECT); } int auth_wait(name) char *name; { if (auth_debug_mode) printf(">>>%s: in auth_wait.\r\n", Name); if (Server && !authenticating) return(0); /* (void) signal(SIGALRM, auth_intr); alarm(30); */ while (!authenticated) if (telnet_spin()) break; /* alarm(0); (void) signal(SIGALRM, SIG_DFL); */ /* * Now check to see if the user is valid or not */ if (!authenticated || authenticated == &NoAuth) return(AUTH_REJECT); if (validuser == AUTH_VALID) validuser = AUTH_USER; if (authenticated->status) validuser = (*authenticated->status)(authenticated, name, validuser); return(validuser); } void auth_debug(mode) int mode; { auth_debug_mode = mode; } void auth_printsub(data, cnt, buf, buflen) unsigned char *data, *buf; int cnt, buflen; { Authenticator *ap; if ((ap = findauthenticator(data[1], data[2])) && ap->printsub) (*ap->printsub)(data, cnt, buf, buflen); else auth_gen_printsub(data, cnt, buf, buflen); } void auth_gen_printsub(data, cnt, buf, buflen) unsigned char *data, *buf; int cnt, buflen; { register unsigned char *cp; unsigned char tbuf[16]; cnt -= 3; data += 3; buf[buflen-1] = '\0'; buf[buflen-2] = '*'; buflen -= 2; for (; cnt > 0; cnt--, data++) { sprintf((char *)tbuf, " %d", *data); for (cp = tbuf; *cp && buflen > 0; --buflen) *buf++ = *cp++; if (buflen <= 0) return; } *buf = '\0'; } #endif
the_stack_data/151706206.c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_print_comb.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: mmasstou <[email protected]> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/06/24 14:51:00 by mmasstou #+# #+# */ /* Updated: 2021/06/25 10:15:58 by mmasstou ### ########.fr */ /* */ /* ************************************************************************** */ #include <unistd.h> void ft_putchar(char c) { write(1, &c, 1); } void conditionsFunction(int nb1, int nb2, int nb3) { if (nb1 < nb2 && nb2 < nb3) { ft_putchar(nb1 + 48); ft_putchar(nb2 + 48); ft_putchar(nb3 + 48); if (nb1 != 7 ) { ft_putchar(','); ft_putchar(' '); } } } void whileFunc(int nb1) { int nb2 ; int nb3 ; while (nb1 < 9) { nb2 = nb1 + 1; while (nb2 < 9) { nb3 = nb1 + 1; while (nb3 <= 9) { conditionsFunction(nb1, nb2, nb3); nb3++; } nb2++; } nb1++; } } void ft_print_comb(void) { int nb1; nb1 = 0; whileFunc(nb1); }
the_stack_data/23241.c
#include <stdio.h> int main() { int n, i, j, cnt=0; while(scanf("%d", &n) != EOF) { int num = 1; cnt++; num += ((n*(n + 1)) / 2); if(n == 0) printf("Caso %d: %d numero\n", cnt, num); else printf("Caso %d: %d numeros\n", cnt, num); printf("0"); for(i=1; i<=n; i++) { for(j=1; j<=i; j++) printf(" %d", i); } printf("\n\n"); } return 0; }
the_stack_data/937759.c
#include <stdio.h> #include <stdlib.h> #include <string.h> void bubble_sort(int n, int h[n]); int main(int argc, char** argv){ int nc, n; scanf("%d", &nc); for(int i = 0; i < nc; i++){ scanf("%d", &n); int h[n]; for(int j = 0; j < n; j++) scanf("%d", &h[j]); bubble_sort(n, h); for(int j = 0; j < n; j++) printf("%d ", h[j]); printf("\n"); } return EXIT_SUCCESS; } void bubble_sort(int n, int h[n]){ int t; for(int i = 0; i < n; i++){ for(int j = i + 1; j < n; j++){ if(h[i] > h[j]){ t = h[i]; h[i] = h[j]; h[j] = t; } } } }
the_stack_data/11075986.c
#include <stdio.h> #include <stdlib.h> struct node { int data; struct node* next; }*top = NULL; typedef struct node Node; Node* insert(int data){ Node* newNode = (Node*)malloc(sizeof(Node)); newNode->data = data; if (top == NULL) { newNode->next = NULL; } else { newNode->next = top; } top = newNode; return newNode; } void display(Node* stack){ Node* p = stack; while (p != NULL) { printf("%d -> ", p->data); p = p->next; } } int GrandTheAuto(Node* stack){ Node* p = top; Node* maior = (Node*)malloc(sizeof(Node)); maior->data = p->data; while ( p != NULL ) { if (p->data > maior->data) { maior->data = p->data; } p = p->next; } printf("%d", maior->data); return maior; } int main(int argc, char const *argv[]) { Node* newNode; Node* maior; newNode = insert(6); newNode = insert(8); newNode = insert(4); //display(newNode); GrandTheAuto(newNode); return 0; } /*Problema 2 Escrever uma função que receba como parâmetro uma pilha. A função deve retornar o maior elemento da pilha. A passagem deve ser por valor ou referência?*/
the_stack_data/49550.c
/* * this is free and unencumbered software released into the public domain. * refer to the attached UNLICENSE or http://unlicense.org/ * -- usage: --------------------------------------------------------------- * #define OPPAI_IMPLEMENTATION * #include "../oppai.c" * * int main() { * ezpp_t ez = ezpp_new(); * ezpp_set_mods(ez, MODS_HD | MODS_DT); * ezpp(ez, "-"); * printf("%gpp\n", ezpp_pp(ez)); * return 0; * } * ------------------------------------------------------------------------ * $ gcc test.c * $ cat /path/to/file.osu | ./a.out */ #if defined(_WIN32) && !defined(OPPAI_IMPLEMENTATION) #ifdef OPPAI_EXPORT #define OPPAIAPI __declspec(dllexport) #elif defined(OPPAI_STATIC_HEADER) #define OPPAIAPI #else #define OPPAIAPI __declspec(dllimport) #endif #else #define OPPAIAPI #endif typedef struct ezpp* ezpp_t; /* opaque handle */ OPPAIAPI ezpp_t ezpp_new(void); OPPAIAPI void ezpp_free(ezpp_t ez); OPPAIAPI int ezpp(ezpp_t ez, char* map); OPPAIAPI float ezpp_pp(ezpp_t ez); OPPAIAPI float ezpp_stars(ezpp_t ez); /* * the above is all you need for basic usage. below are some advanced api's * and usage examples * * - if map is "-" the map is read from standard input * - you can use ezpp_data if you already have raw beatmap data in memory * - if autocalc is set to 1, the results will be automatically refreshed * when you change parameters. if reparsing is required, the last passed * map or map data will be used * - if map is 0 (NULL), difficulty calculation and map parsing are skipped * and you must set at least mode, aim_stars, speed_stars, nobjects, * base_ar, base_od, max_combo, nsliders, ncircles * - if aim_stars or speed_stars are set difficulty calculation is also * skipped but values are taken from map * - setting mods or cs resets aim_stars and speed_stars, set those last * = setting end resets accuracy_percent * - if mode_override is set, std maps are converted to other modes * - mode defaults to MODE_STD or the map's mode * - mods default to MODS_NOMOD * - combo defaults to full combo * - nmiss defaults to 0 * - score_version defaults to scorev1 * - if accuracy_percent is set, n300/100/50 are automatically * calculated and stored * - if n300/100/50 are set, accuracy_percent is automatically * calculated and stored * - if none of the above are set, SS (100%) is assumed * - if end is set, the map will be cut to this object index * - if base_ar/od/cs are set, they will override the map's values * - when you change map and you're reusing the handle, you should reset * ar/od/cs/hp to -1 otherwise it will override them with the previous * map's values * - in autocalc mode, calling ezpp with a non-NULL map always resets * ar/od/cs/hp overrides to -1 so you don't have to */ OPPAIAPI void ezpp_set_autocalc(ezpp_t ez, int autocalc); OPPAIAPI int ezpp_autocalc(ezpp_t ez); OPPAIAPI int ezpp_data(ezpp_t ez, char* data, int data_size); OPPAIAPI float ezpp_aim_stars(ezpp_t ez); OPPAIAPI float ezpp_speed_stars(ezpp_t ez); OPPAIAPI float ezpp_aim_pp(ezpp_t ez); OPPAIAPI float ezpp_speed_pp(ezpp_t ez); OPPAIAPI float ezpp_acc_pp(ezpp_t ez); OPPAIAPI float ezpp_accuracy_percent(ezpp_t ez); OPPAIAPI int ezpp_n300(ezpp_t ez); OPPAIAPI int ezpp_n100(ezpp_t ez); OPPAIAPI int ezpp_n50(ezpp_t ez); OPPAIAPI int ezpp_nmiss(ezpp_t ez); OPPAIAPI float ezpp_ar(ezpp_t ez); OPPAIAPI float ezpp_cs(ezpp_t ez); OPPAIAPI float ezpp_od(ezpp_t ez); OPPAIAPI float ezpp_hp(ezpp_t ez); OPPAIAPI char* ezpp_artist(ezpp_t ez); OPPAIAPI char* ezpp_artist_unicode(ezpp_t ez); OPPAIAPI char* ezpp_title(ezpp_t ez); OPPAIAPI char* ezpp_title_unicode(ezpp_t ez); OPPAIAPI char* ezpp_version(ezpp_t ez); OPPAIAPI char* ezpp_creator(ezpp_t ez); OPPAIAPI int ezpp_ncircles(ezpp_t ez); OPPAIAPI int ezpp_nsliders(ezpp_t ez); OPPAIAPI int ezpp_nspinners(ezpp_t ez); OPPAIAPI int ezpp_nobjects(ezpp_t ez); OPPAIAPI float ezpp_odms(ezpp_t ez); OPPAIAPI int ezpp_mode(ezpp_t ez); OPPAIAPI int ezpp_combo(ezpp_t ez); OPPAIAPI int ezpp_max_combo(ezpp_t ez); OPPAIAPI int ezpp_mods(ezpp_t ez); OPPAIAPI int ezpp_score_version(ezpp_t ez); OPPAIAPI float ezpp_time_at(ezpp_t ez, int i); /* milliseconds */ OPPAIAPI float ezpp_strain_at(ezpp_t ez, int i, int difficulty_type); OPPAIAPI int ezpp_ntiming_points(ezpp_t ez); OPPAIAPI float ezpp_timing_time(ezpp_t ez, int i); /* milliseconds */ OPPAIAPI float ezpp_timing_ms_per_beat(ezpp_t ez, int i); OPPAIAPI int ezpp_timing_change(ezpp_t ez, int i); OPPAIAPI void ezpp_set_aim_stars(ezpp_t ez, float aim_stars); OPPAIAPI void ezpp_set_speed_stars(ezpp_t ez, float speed_stars); OPPAIAPI void ezpp_set_base_ar(ezpp_t ez, float ar); OPPAIAPI void ezpp_set_base_od(ezpp_t ez, float od); OPPAIAPI void ezpp_set_base_cs(ezpp_t ez, float cs); OPPAIAPI void ezpp_set_base_hp(ezpp_t ez, float hp); OPPAIAPI void ezpp_set_mode_override(ezpp_t ez, int mode_override); OPPAIAPI void ezpp_set_mode(ezpp_t ez, int mode); OPPAIAPI void ezpp_set_mods(ezpp_t ez, int mods); OPPAIAPI void ezpp_set_combo(ezpp_t ez, int combo); OPPAIAPI void ezpp_set_nmiss(ezpp_t ez, int nmiss); OPPAIAPI void ezpp_set_score_version(ezpp_t ez, int score_version); OPPAIAPI void ezpp_set_accuracy_percent(ezpp_t ez, float accuracy_percent); OPPAIAPI void ezpp_set_accuracy(ezpp_t ez, int n100, int n50); OPPAIAPI void ezpp_set_end(ezpp_t ez, int end); OPPAIAPI void ezpp_set_end_time(ezpp_t ez, float end); /* * these will make a copy of mapfile/data and free it automatically. this * is slow but useful when working with bindings in other langs where * pointers to strings aren't guaranteed to persist like python3 */ OPPAIAPI int ezpp_dup(ezpp_t ez, char* mapfile); OPPAIAPI int ezpp_data_dup(ezpp_t ez, char* data, int data_size); /* errors -------------------------------------------------------------- */ /* * all functions that return int can return errors in the form * of a negative value. check if the return value is < 0 and call * errstr to get the error message */ #define ERR_MORE (-1) #define ERR_SYNTAX (-2) #define ERR_TRUNCATED (-3) #define ERR_NOTIMPLEMENTED (-4) #define ERR_IO (-5) #define ERR_FORMAT (-6) #define ERR_OOM (-7) OPPAIAPI char* errstr(int err); /* version info -------------------------------------------------------- */ OPPAIAPI void oppai_version(int* major, int* minor, int* patch); OPPAIAPI char* oppai_version_str(void); /* --------------------------------------------------------------------- */ #define MODE_STD 0 #define MODE_TAIKO 1 #define DIFF_SPEED 0 #define DIFF_AIM 1 #define MODS_NOMOD 0 #define MODS_NF (1<<0) #define MODS_EZ (1<<1) #define MODS_TD (1<<2) #define MODS_HD (1<<3) #define MODS_HR (1<<4) #define MODS_SD (1<<5) #define MODS_DT (1<<6) #define MODS_RX (1<<7) #define MODS_HT (1<<8) #define MODS_NC (1<<9) #define MODS_FL (1<<10) #define MODS_AT (1<<11) #define MODS_SO (1<<12) #define MODS_AP (1<<13) #define MODS_PF (1<<14) #define MODS_KEY4 (1<<15) /* TODO: what are these abbreviated to? */ #define MODS_KEY5 (1<<16) #define MODS_KEY6 (1<<17) #define MODS_KEY7 (1<<18) #define MODS_KEY8 (1<<19) #define MODS_FADEIN (1<<20) #define MODS_RANDOM (1<<21) #define MODS_CINEMA (1<<22) #define MODS_TARGET (1<<23) #define MODS_KEY9 (1<<24) #define MODS_KEYCOOP (1<<25) #define MODS_KEY1 (1<<26) #define MODS_KEY3 (1<<27) #define MODS_KEY2 (1<<28) #define MODS_SCOREV2 (1<<29) #define MODS_TOUCH_DEVICE MODS_TD #define MODS_NOVIDEO MODS_TD /* never forget */ #define MODS_SPEED_CHANGING (MODS_DT | MODS_HT | MODS_NC) #define MODS_MAP_CHANGING (MODS_HR | MODS_EZ | MODS_SPEED_CHANGING) /* this is all you need to know for normal usage. internals below */ /* ##################################################################### */ /* ##################################################################### */ /* ##################################################################### */ #ifdef OPPAI_EXPORT #define OPPAI_IMPLEMENTATION #endif #ifdef OPPAI_IMPLEMENTATION #include <stdio.h> #include <stdarg.h> #include <stdlib.h> #include <string.h> #include <math.h> #define OPPAI_VERSION_MAJOR 4 #define OPPAI_VERSION_MINOR 1 #define OPPAI_VERSION_PATCH 0 #define STRINGIFY_(x) #x #define STRINGIFY(x) STRINGIFY_(x) #define OPPAI_VERSION_STRING \ STRINGIFY(OPPAI_VERSION_MAJOR) "." \ STRINGIFY(OPPAI_VERSION_MINOR) "." \ STRINGIFY(OPPAI_VERSION_PATCH) OPPAIAPI void oppai_version(int* major, int* minor, int* patch) { *major = OPPAI_VERSION_MAJOR; *minor = OPPAI_VERSION_MINOR; *patch = OPPAI_VERSION_PATCH; } OPPAIAPI char* oppai_version_str() { return OPPAI_VERSION_STRING; } /* error utils --------------------------------------------------------- */ int info(char* fmt, ...) { int res; va_list va; va_start(va, fmt); res = vfprintf(stderr, fmt, va); va_end(va); return res; } OPPAIAPI char* errstr(int err) { switch (err) { case ERR_MORE: return "call me again with more data"; case ERR_SYNTAX: return "syntax error"; case ERR_TRUNCATED: return "data was truncated, possibly because it was too big"; case ERR_NOTIMPLEMENTED: return "requested a feature that isn't implemented"; case ERR_IO: return "i/o error"; case ERR_FORMAT: return "invalid input format"; case ERR_OOM: return "out of memory"; } info("W: got unknown error %d\n", err); return "unknown error"; } /* math ---------------------------------------------------------------- */ #define log10f (float)log10 #define al_round(x) (float)floor((x) + 0.5f) #define al_min(a, b) ((a) < (b) ? (a) : (b)) #define al_max(a, b) ((a) > (b) ? (a) : (b)) #ifndef M_PI #define M_PI 3.14159265358979323846 #endif float get_inf(void) { static unsigned raw = 0x7F800000; float* p = (float*)&raw; return *p; } float get_nan(void) { static unsigned raw = 0x7FFFFFFF; float* p = (float*)&raw; return *p; } /* dst = a - b */ void v2f_sub(float* dst, float* a, float* b) { dst[0] = a[0] - b[0]; dst[1] = a[1] - b[1]; } float v2f_len(float* v) { return (float)sqrt(v[0] * v[0] + v[1] * v[1]); } float v2f_dot(float* a, float* b) { return a[0] * b[0] + a[1] * b[1]; } /* https://www.doc.ic.ac.uk/%7Eeedwards/compsys/float/nan.html */ int is_nan(float b) { unsigned* p = (void*)&b; return ( (*p > 0x7F800000 && *p < 0x80000000) || (*p > 0x7FBFFFFF && *p <= 0xFFFFFFFF) ); } /* https://www.doc.ic.ac.uk/%7Eeedwards/compsys/float/nan.html */ int is_inf(float b) { int* p = (int*)&b; return *p == 0x7F800000 || *p == 0xFF800000; } /* string utils -------------------------------------------------------- */ int whitespace(char c) { switch (c) { case '\r': case '\n': case '\t': case ' ': return 1; } return 0; } /* non-null terminated string, used internally for parsing */ typedef struct slice { char* start; char* end; /* *(end - 1) is the last character */ } slice_t; int slice_write(slice_t* s, FILE* f) { return (int)fwrite(s->start, 1, s->end - s->start, f); } int slice_whitespace(slice_t* s) { char* p = s->start; for (; p < s->end; ++p) { if (!whitespace(*p)) { return 0; } } return 1; } /* trims leading and trailing whitespace */ void slice_trim(slice_t* s) { for (; s->start < s->end && whitespace(*s->start); ++s->start); for (; s->end > s->start && whitespace(*(s->end-1)); --s->end); } int slice_cmp(slice_t* s, char* str) { int len = (int)strlen(str); int s_len = (int)(s->end - s->start); if (len < s_len) { return -1; } if (len > s_len) { return 1; } return strncmp(s->start, str, len); } int slice_len(slice_t* s) { return (int)(s->end - s->start); } /* * splits s at any of the separators in separator_list and stores * pointers to the strings in arr. * returns the number of elements written to arr. * if more elements than nmax are found, err is set to * ERR_TRUNCATED */ int slice_split(slice_t* s, char* separator_list, slice_t* arr, int nmax, int* err) { int res = 0; char* p = s->start; char* pprev = p; if (!nmax) { return 0; } if (!*separator_list) { *arr = *s; return 1; } for (; p <= s->end; ++p) { char* sep = separator_list; for (; *sep; ++sep) { if (p >= s->end || *sep == *p) { if (res >= nmax) { *err = ERR_TRUNCATED; goto exit; } arr[res].start = pprev; arr[res].end = p; pprev = p + 1; ++res; break; } } } exit: return res; } /* array --------------------------------------------------------------- */ #define array_t(type) \ struct { \ int cap; \ int len; \ type* data; \ } #define array_reserve(arr, n) \ array_reserve_i(n, array_unpack(arr)) #define array_free(arr) \ array_free_i(array_unpack(arr)) #define array_alloc(arr) \ (array_reserve((arr), (arr)->len + 1) \ ? &(arr)->data[(arr)->len++] \ : 0) #define array_append(arr, x) \ (array_reserve((arr), (arr)->len + 1) \ ? ((arr)->data[(arr)->len++] = (x), 1) \ : 0) /* internal helpers, not to be used directly */ #define array_unpack(arr) \ &(arr)->cap, \ &(arr)->len, \ (void**)&(arr)->data, \ (int)sizeof((arr)->data[0]) int array_reserve_i(int n, int* cap, int* len, void** data, int esize) { (void)len; if (*cap <= n) { void* newdata; int newcap = *cap ? *cap * 2 : 16; newdata = realloc(*data, esize * newcap); if (!newdata) { return 0; } *data = newdata; *cap = newcap; } return 1; } void array_free_i(int* cap, int* len, void** data, int esize) { (void)esize; free(*data); *cap = 0; *len = 0; *data = 0; } /* --------------------------------------------------------------------- */ #define OBJ_CIRCLE (1<<0) #define OBJ_SLIDER (1<<1) #define OBJ_SPINNER (1<<3) #define SOUND_NONE 0 #define SOUND_NORMAL (1<<0) #define SOUND_WHISTLE (1<<1) #define SOUND_FINISH (1<<2) #define SOUND_CLAP (1<<3) typedef struct timing { float time; /* milliseconds */ float ms_per_beat; int change; /* if 0, ms_per_beat is -100.0f * sv_multiplier */ float px_per_beat; /* taiko stuff */ float beat_len; float velocity; } timing_t; typedef struct object { float time; /* milliseconds */ int type; /* only for taiko maps */ int nsound_types; int* sound_types; /* only used by d_calc */ float normpos[2]; float angle; float strains[2]; int is_single; /* 1 if diff calc sees this as a singletap */ float delta_time; float d_distance; int timing_point; float pos[2]; float distance; /* only for sliders */ int repetitions; /* taiko stuff */ float duration; float tick_spacing; int slider_is_drum_roll; } object_t; /* * exposing the struct would cut down lines of code but makes it harder * to use from langs that aren't c/c++ or don't have the same memory * alignment etc */ #define AUTOCALC_BIT (1<<0) #define OWNS_MAP_BIT (1<<1) /* map/data freed on ezpp{,_data}, ezpp_free */ struct ezpp { char* map; char* data; int data_size; int flags; int format_version; int mode, mode_override, original_mode; int score_version; int mods, combo; float accuracy_percent; int n300, n100, n50, nmiss; int end; float end_time; float base_ar, base_cs, base_od, base_hp; int max_combo; char* title; char* title_unicode; char* artist; char* artist_unicode; char* creator; char* version; int ncircles, nsliders, nspinners, nobjects; float ar, od, cs, hp, odms, sv, tick_rate, speed_mul; float stars; float aim_stars, aim_difficulty, aim_length_bonus; float speed_stars, speed_difficulty, speed_length_bonus; float pp, aim_pp, speed_pp, acc_pp; /* parser */ char section[64]; char buf[0xFFFF]; int p_flags; array_t(object_t) objects; array_t(timing_t) timing_points; /* diffcalc */ float interval_end; float max_strain; array_t(float) highest_strains; /* allocator */ char* block; char* end_of_block; array_t(char*) blocks; }; /* memory arena (allocator) -------------------------------------------- */ #define M_ALIGN sizeof(void*) #define M_BLOCK_SIZE 4096 /* aligns x down to a power-of-two value a */ #define bit_align_down(x, a) \ ((x) & ~((a) - 1)) /* aligns x up to a power-of-two value a */ #define bit_align_up(x, a) \ bit_align_down((x) + (a) - 1, a) int m_reserve(ezpp_t ez, int min_size) { int size; char* new_block; if (ez->end_of_block - ez->block >= min_size) { return 1; } size = bit_align_up(al_max(min_size, M_BLOCK_SIZE), M_ALIGN); new_block = malloc(size); if (!new_block) { return 0; } ez->block = new_block; ez->end_of_block = new_block + size; array_append(&ez->blocks, ez->block); return 1; } void* m_alloc(ezpp_t ez, int size) { void* res; if (!m_reserve(ez, size)) { return 0; } size = bit_align_up(size, M_ALIGN); res = ez->block; ez->block += size; return res; } char* m_strndup(ezpp_t ez, char* s, int n) { char* res = m_alloc(ez, n + 1); if (res) { memcpy(res, s, n); res[n] = 0; } return res; } void m_free(ezpp_t ez) { int i; for (i = 0; i < ez->blocks.len; ++i) { free(ez->blocks.data[i]); } array_free(&ez->blocks); ez->block = 0; ez->end_of_block = 0; } /* mods ---------------------------------------------------------------- */ float od10_ms[] = { 20, 20 }; /* std, taiko */ float od0_ms[] = { 80, 50 }; #define AR0_MS 1800.0f #define AR5_MS 1200.0f #define AR10_MS 450.0f float od_ms_step[] = { 6.0f, 3.0f }; #define AR_MS_STEP1 120.f /* ar0-5 */ #define AR_MS_STEP2 150.f /* ar5-10 */ /* * stats must be capped to 0-10 before HT/DT which brings them to a range * of -4.42f to 11.08f for OD and -5 to 11 for AR */ int mods_apply(ezpp_t ez) { float od_ar_hp_multiplier, cs_multiplier, arms; switch (ez->mode) { case MODE_STD: case MODE_TAIKO: break; default: info("this gamemode is not yet supported for mods calc\n"); return ERR_NOTIMPLEMENTED; } ez->speed_mul = 1; if (!(ez->mods & MODS_MAP_CHANGING)) { ez->odms = od0_ms[ez->mode] - (float)ceil(od_ms_step[ez->mode] * ez->od); return 0; } if (ez->mods & (MODS_DT | MODS_NC)) { ez->speed_mul *= 1.5f; } if (ez->mods & MODS_HT) { ez->speed_mul *= 0.75f; } /* global multipliers */ od_ar_hp_multiplier = 1; if (ez->mods & MODS_HR) od_ar_hp_multiplier *= 1.4f; if (ez->mods & MODS_EZ) od_ar_hp_multiplier *= 0.5f; ez->od *= od_ar_hp_multiplier; ez->odms = od0_ms[ez->mode] - (float)ceil(od_ms_step[ez->mode] * ez->od); ez->odms = al_min(od0_ms[ez->mode], al_max(od10_ms[ez->mode], ez->odms)); ez->odms /= ez->speed_mul; ez->od = (od0_ms[ez->mode] - ez->odms) / od_ms_step[ez->mode]; ez->ar *= od_ar_hp_multiplier; arms = ez->ar <= 5 ? (AR0_MS - AR_MS_STEP1 * (ez->ar - 0)) : (AR5_MS - AR_MS_STEP2 * (ez->ar - 5)); arms = al_min(AR0_MS, al_max(AR10_MS, arms)); arms /= ez->speed_mul; ez->ar = arms > AR5_MS ? (0 + (AR0_MS - arms) / AR_MS_STEP1) : (5 + (AR5_MS - arms) / AR_MS_STEP2); cs_multiplier = 1; if (ez->mods & MODS_HR) cs_multiplier = 1.3f; if (ez->mods & MODS_EZ) cs_multiplier = 0.5f; ez->cs *= cs_multiplier; ez->cs = al_max(0.0f, al_min(10.0f, ez->cs)); ez->hp = al_min(ez->hp * od_ar_hp_multiplier, 10); return 0; } /* beatmap parser ------------------------------------------------------ */ /* * comments in beatmaps can only be an entire line because * some properties such as author can contain // * * all p_* functions expect s to be a single line and trimmed * on errors, p_* functions return < 0 error codes otherwise they * return n bytes consumed */ #define P_OVERRIDE_MODE (1<<0) /* mode_override */ #define P_FOUND_AR (1<<1) #define CIRCLESIZE_BUFF_TRESHOLD 30.0f /* non-normalized diameter */ #define PLAYFIELD_WIDTH 512.0f /* in osu!pixels */ #define PLAYFIELD_HEIGHT 384.0f float playfield_center[] = { PLAYFIELD_WIDTH / 2.0f, PLAYFIELD_HEIGHT / 2.0f }; void print_line(slice_t* line) { info("in line: "); slice_write(line, stderr); info("\n"); } int p_warn(char* e, slice_t* line) { info(e); info("\n"); print_line(line); return 0; } /* consume until any of the characters in separators is found */ int p_consume_til(slice_t* s, char* separators, slice_t* dst) { char* p = s->start; dst->start = s->start; for (; p < s->end; ++p) { char* sep; for (sep = separators; *sep; ++sep) { if (*p == *sep) { dst->start = s->start; dst->end = p; return (int)(p - s->start); } } } dst->end = p; return ERR_MORE; } float p_float(slice_t* value) { float res; char* p = value->start; if (*p == '-') { res = -1; ++p; } else { res = 1; } /* infinity symbol */ if (!strncmp(p, "\xe2\x88\x9e", 3)) { res *= get_inf(); } else { if (sscanf(value->start, "%f", &res) != 1) { info("W: failed to parse float "); slice_write(value, stderr); info("\n"); res = 0; } } return res; } /* [name] */ int p_section_name(slice_t* s, slice_t* name) { int n; slice_t p = *s; if (*p.start++ != '[') { return ERR_SYNTAX; } n = p_consume_til(&p, "]", name); if (n < 0) { return n; } p.start += n; if (p.start != p.end - 1) { /* must end in ] */ return ERR_SYNTAX; } return (int)(p.start - s->start); } /* name: value (results are trimmed) */ int p_property(slice_t* s, slice_t* name, slice_t* value) { int n; char* p = s->start; n = p_consume_til(s, ":", name); if (n < 0) { return n; } p += n; ++p; /* skip : */ value->start = p; value->end = s->end; slice_trim(name); slice_trim(value); return (int)(s->end - s->start); } char* p_slicedup(ezpp_t ez, slice_t* s) { return m_strndup(ez, s->start, slice_len(s)); } int p_metadata(ezpp_t ez, slice_t* line) { slice_t name, value; int n = p_property(line, &name, &value); if (n < 0) { return p_warn("W: malformed metadata line", line); } if (!slice_cmp(&name, "Title")) { ez->title = p_slicedup(ez, &value); } else if (!slice_cmp(&name, "TitleUnicode")) { ez->title_unicode = p_slicedup(ez, &value); } else if (!slice_cmp(&name, "Artist")) { ez->artist = p_slicedup(ez, &value); } else if (!slice_cmp(&name, "ArtistUnicode")) { ez->artist_unicode = p_slicedup(ez, &value); } else if (!slice_cmp(&name, "Creator")) { ez->creator = p_slicedup(ez, &value); } else if (!slice_cmp(&name, "Version")) { ez->version = p_slicedup(ez, &value); } return n; } int p_general(ezpp_t ez, slice_t* line) { slice_t name, value; int n; n = p_property(line, &name, &value); if (n < 0) { return p_warn("W: malformed general line", line); } if (!slice_cmp(&name, "Mode")) { if (sscanf(value.start, "%d", &ez->original_mode) != 1){ return ERR_SYNTAX; } if (ez->p_flags & P_OVERRIDE_MODE) { ez->mode = ez->mode_override; } else { ez->mode = ez->original_mode; } switch (ez->mode) { case MODE_STD: case MODE_TAIKO: break; default: return ERR_NOTIMPLEMENTED; } } return n; } int p_difficulty(ezpp_t ez, slice_t* line) { slice_t name, value; int n = p_property(line, &name, &value); if (n < 0) { return p_warn("W: malformed difficulty line", line); } if (!slice_cmp(&name, "CircleSize")) { ez->cs = p_float(&value); } else if (!slice_cmp(&name, "OverallDifficulty")) { ez->od = p_float(&value); } else if (!slice_cmp(&name, "ApproachRate")) { ez->ar = p_float(&value); ez->p_flags |= P_FOUND_AR; } else if (!slice_cmp(&name, "HPDrainRate")) { ez->hp = p_float(&value); } else if (!slice_cmp(&name, "SliderMultiplier")) { ez->sv = p_float(&value); } else if (!slice_cmp(&name, "SliderTickRate")) { ez->tick_rate = p_float(&value); } return n; } /* * time, ms_per_beat, time_signature_id, sample_set_id, * sample_bank_id, sample_volume, is_timing_change, effect_flags * * everything after ms_per_beat is optional */ int p_timing(ezpp_t ez, slice_t* line) { int res = 0; int n, i; int err = 0; slice_t split[8]; timing_t* t = array_alloc(&ez->timing_points); if (!t) { return ERR_OOM; } t->change = 1; n = slice_split(line, ",", split, 8, &err); if (err < 0) { if (err == ERR_TRUNCATED) { info("W: timing point with trailing values"); print_line(line); } else { return err; } } if (n < 2) { return p_warn("W: malformed timing point", line); } res = (int)(split[n - 1].end - line->start); for (i = 0; i < n; ++i) { slice_trim(&split[i]); } t->time = p_float(&split[0]); t->ms_per_beat = p_float(&split[1]); if (n >= 7) { if (slice_len(&split[6]) < 1) { t->change = 1; } else { t->change = *split[6].start != '0'; } } return res; } int p_objects(ezpp_t ez, slice_t* line) { object_t* o; int err = 0; int ne; slice_t e[11]; if (ez->end > 0 && ez->objects.len >= ez->end) { return 0; } o = array_alloc(&ez->objects); if (o) { memset(o, 0, sizeof(*o)); } else { return ERR_OOM; } ne = slice_split(line, ",", e, 11, &err); if (err < 0) { if (err == ERR_TRUNCATED) { info("W: object with trailing values\n"); print_line(line); } else { return err; } } if (ne < 5) { return p_warn("W: malformed hitobject", line); } o->time = p_float(&e[2]); if (is_inf(o->time)) { o->time = 0.0f; info("W: object with infinite time\n"); print_line(line); } if (ez->end_time > 0 && o->time >= ez->end_time) { --ez->objects.len; return 0; } if (sscanf(e[3].start, "%d", &o->type) != 1) { p_warn("W: malformed hitobject type", line); o->type = OBJ_CIRCLE; } if (ez->mode == MODE_TAIKO) { int* sound_type = m_alloc(ez, sizeof(int)); if (!sound_type) { return ERR_OOM; } if (sscanf(e[4].start, "%d", sound_type) != 1) { p_warn("W: malformed hitobject sound type", line); *sound_type = SOUND_NORMAL; } o->nsound_types = 1; o->sound_types = sound_type; /* wastes 4 bytes when you have per-node sounds but w/e */ } if (o->type & OBJ_CIRCLE) { ++ez->ncircles; o->pos[0] = p_float(&e[0]); o->pos[1] = p_float(&e[1]); } /* ?,?,?,?,?,end_time,custom_sample_banks */ else if (o->type & OBJ_SPINNER) { ++ez->nspinners; } /* * x,y,time,type,sound_type,points,repetitions,distance, * per_node_sounds,per_node_samples,custom_sample_banks */ else if (o->type & OBJ_SLIDER) { ++ez->nsliders; if (ne < 7) { return p_warn("W: malformed slider", line); } o->pos[0] = p_float(&e[0]); o->pos[1] = p_float(&e[1]); if (sscanf(e[6].start, "%d", &o->repetitions) != 1) { o->repetitions = 1; p_warn("W: malformed slider repetitions", line); } if (ne > 7) { o->distance = p_float(&e[7]); } else { o->distance = 0; } /* per-node sound types */ if (ez->mode == MODE_TAIKO && ne > 8 && slice_len(&e[8]) > 0) { slice_t p = e[8]; int i, nodes; int sound_type = o->sound_types[0]; /* * TODO: there's probably something subtly wrong with this. * sometimes we get less sound types than nodes * also I don't know if I'm supposed to include the previous * sound type from the single sound_type field */ /* repeats + head and tail. no repeats is 0 repetition */ nodes = o->repetitions + 1; if (nodes < 0 || nodes > 1000) { /* TODO: not sure if 1000 limit is enough */ p_warn("W: malformed node count", line); return ERR_SYNTAX; } o->sound_types = m_alloc(ez, sizeof(int) * nodes); if (!o->sound_types) { return ERR_OOM; } o->nsound_types = nodes; for (i = 0; i < nodes; ++i) { o->sound_types[i] = sound_type; } for (i = 0; i < nodes; ++i) { slice_t node; int n; int type; node.start = node.end = 0; n = p_consume_til(&p, "|", &node); if (n < 0 && n != ERR_MORE) { return n; } if (node.start >= node.end || !node.start) { break; } p.start += n + 1; if (sscanf(node.start, "%d", &type) != 1) { p_warn("W: malformed sound type", line); break; } o->sound_types[i] = type; if (p.start >= p.end) { break; } } } } return (int)(e[ne - 1].end - line->start); } int p_line(ezpp_t ez, slice_t* line) { int n = 0; if (line->start >= line->end) { /* empty line */ return 0; } if (slice_whitespace(line)) { return (int)(line->end - line->start); } /* comments (according to lazer) */ switch (*line->start) { case ' ': case '_': return (int)(line->end - line->start); } /* from here on we don't care about leading or trailing whitespace */ slice_trim(line); /* C++ style comments */ if (!strncmp(line->start, "//", 2)) { return 0; } /* new section */ if (*line->start == '[') { slice_t section; int len; n = p_section_name(line, &section); if (n < 0) { return n; } if ((int)(section.end - section.start) >= (int)sizeof(ez->section)) { p_warn("W: truncated long section name", line); } len = al_min((int)sizeof(ez->section) - 1, (int)(section.end - section.start)); memcpy(ez->section, section.start, len); ez->section[len] = 0; return n; } if (!strcmp(ez->section, "Metadata")) { n = p_metadata(ez, line); } else if (!strcmp(ez->section, "General")) { n = p_general(ez, line); } else if (!strcmp(ez->section, "Difficulty")) { n = p_difficulty(ez, line); } else if (!strcmp(ez->section, "TimingPoints")) { n = p_timing(ez, line); } else if (!strcmp(ez->section, "HitObjects")) { n = p_objects(ez, line); } else { char* p = line->start; char* fmt_str = "file format v"; for (; p < line->end && strncmp(p, fmt_str, 13); ++p); p += 13; if (p < line->end) { if (sscanf(p, "%d", &ez->format_version) == 1) { return (int)(line->end - line->start); } } } return n; } void p_end(ezpp_t ez) { int i; float infinity = get_inf(); float tnext = -infinity; int tindex = -1; float ms_per_beat = infinity; float radius, scaling_factor; float legacy_multiplier = 1; if (!(ez->p_flags & P_FOUND_AR)) { /* in old maps ar = od */ ez->ar = ez->od; } if (!ez->title_unicode) { ez->title_unicode = ez->title; } if (!ez->artist_unicode) { ez->artist_unicode = ez->artist; } #define s(x) ez->x = ez->x ? ez->x : "(null)" s(title); s(title_unicode); s(artist); s(artist_unicode); s(creator); s(version); #undef s if (ez->base_ar < 0) ez->base_ar = ez->ar; else ez->ar = ez->base_ar; if (ez->base_cs < 0) ez->base_cs = ez->cs; else ez->cs = ez->base_cs; if (ez->base_od < 0) ez->base_od = ez->od; else ez->od = ez->base_od; if (ez->base_hp < 0) ez->base_hp = ez->hp; else ez->hp = ez->base_hp; mods_apply(ez); if (ez->mode == MODE_TAIKO && ez->mode != ez->original_mode) { legacy_multiplier = 1.4f; ez->sv *= legacy_multiplier; } for (i = 0; i < ez->timing_points.len; ++i) { timing_t* t = &ez->timing_points.data[i]; float sv_multiplier = 1.0f; if (t->change) { ms_per_beat = t->ms_per_beat; } if (!t->change && t->ms_per_beat < 0) { sv_multiplier = -100.0f / t->ms_per_beat; } t->beat_len = ms_per_beat / sv_multiplier; t->px_per_beat = ez->sv * 100.0f; t->velocity = 100.0f * ez->sv / t->beat_len; if (ez->format_version >= 8) { t->beat_len *= sv_multiplier; t->px_per_beat *= sv_multiplier; } } /* * sliders get 2 + ticks combo (head, tail and ticks) each repetition adds * an extra combo and an extra set of ticks * * calculate the number of slider ticks for one repetition * --- * example: a 3.75f beats slider at 1x tick rate will go: * beat0 (head), beat1 (tick), beat2(tick), beat3(tick), * beat3.75f(tail) * so all we have to do is ceil the number of beats and subtract 1 to take * out the tail * --- * the -0.1f is there to prevent ceil from ceiling whole values like 1.0f to * 2.0f randomly */ ez->nobjects = ez->objects.len; ez->max_combo = ez->nobjects; /* spinners don't give combo in taiko */ if (ez->mode == MODE_TAIKO) { ez->max_combo -= ez->nspinners + ez->nsliders; } /* * positions are normalized on circle radius so that we * can calc as if everything was the same circlesize * this should really be in diffcalc functions but putting it here * makes it so that i only traverse the hitobjects twice in total */ radius = ( (PLAYFIELD_WIDTH / 16.0f) * (1.0f - 0.7f * ((float)ez->cs - 5.0f) / 5.0f) ); scaling_factor = 52.0f / radius; /* cs buff (originally from osuElements) */ if (radius < CIRCLESIZE_BUFF_TRESHOLD) { scaling_factor *= 1.0f + al_min((CIRCLESIZE_BUFF_TRESHOLD - radius), 5.0f) / 50.0f; } for (i = 0; i < ez->objects.len; ++i) { object_t* o = &ez->objects.data[i]; timing_t* t; int ticks; float num_beats; float* pos; float dot, det; if (o->type & OBJ_SPINNER) { pos = playfield_center; } else { /* sliders also begin with pos so it's fine */ pos = o->pos; } o->normpos[0] = pos[0] * scaling_factor; o->normpos[1] = pos[1] * scaling_factor; /* angle data */ if (i >= 2) { object_t* prev1 = &ez->objects.data[i - 1]; object_t* prev2 = &ez->objects.data[i - 2]; float v1[2], v2[2]; v2f_sub(v1, prev2->normpos, prev1->normpos); v2f_sub(v2, o->normpos, prev1->normpos); dot = v2f_dot(v1, v2); det = v1[0] * v2[1] - v1[1] * v2[0]; o->angle = (float)fabs(atan2(det, dot)); } else { o->angle = get_nan(); } /* keep track of the current timing point */ while (o->time >= tnext) { ++tindex; if (tindex + 1 < ez->timing_points.len) { tnext = ez->timing_points.data[tindex + 1].time; } else { tnext = infinity; } } o->timing_point = tindex; t = &ez->timing_points.data[tindex]; if (!(o->type & OBJ_SLIDER)) { continue; } o->duration = o->distance * o->repetitions / t->velocity; o->duration *= legacy_multiplier; o->tick_spacing = al_min(t->beat_len / ez->tick_rate, o->duration / o->repetitions); o->slider_is_drum_roll = ( o->tick_spacing > 0 && o->duration < 2 * t->beat_len ); /* slider ticks for max_combo */ switch (ez->mode) { case MODE_TAIKO: { if (o->slider_is_drum_roll && ez->mode != ez->original_mode) { ez->max_combo += (int)( ceil((o->duration + o->tick_spacing / 8) / o->tick_spacing) ); } break; } case MODE_STD: /* std slider ticks */ num_beats = (o->distance * o->repetitions) / t->px_per_beat; ticks = (int)ceil( (num_beats - 0.1f) / o->repetitions * ez->tick_rate ); --ticks; ticks *= o->repetitions; /* account for repetitions */ ticks += o->repetitions + 1; /* add heads and tails */ /* * actually doesn't include first head because we already * added it by setting res = nobjects */ ez->max_combo += al_max(0, ticks - 1); break; } } } void p_reset(ezpp_t ez) { ez->ncircles = ez->nsliders = ez->nspinners = ez->nobjects = 0; ez->objects.len = 0; ez->timing_points.len = 0; m_free(ez); memset(ez->section, 0, sizeof(ez->section)); } int p_map(ezpp_t ez, FILE* f) { char* p; char* bufend; int c, n; slice_t line; if (!f) { return ERR_IO; } p_reset(ez); /* reading loop */ bufend = ez->buf + sizeof(ez->buf) - 1; do { p = ez->buf; for (;;) { if (p >= bufend) { return ERR_TRUNCATED; } c = fgetc(f); if (c == '\n' || c == EOF) { break; } *p++ = (char)c; } *p = 0; line.start = ez->buf; line.end = p; n = p_line(ez, &line); if (n < 0) { return n; } } while (c != EOF); p_end(ez); ez->nobjects = ez->objects.len; return (int)(p - ez->buf); } /* TODO: see if i can shrink this function */ int p_map_mem(ezpp_t ez, char* data, int data_size) { int res = 0; int n; int nlines = 0; /* complete lines in the current chunk */ slice_t s; /* points to the remaining data in buf */ if (!data || data_size == 0) { return ERR_IO; } p_reset(ez); s.start = data; s.end = data + data_size; /* parsing loop */ for (; s.start < s.end; ) { slice_t line; n = p_consume_til(&s, "\n", &line); if (n < 0) { if (n != ERR_MORE) { return n; } if (!nlines) { /* line doesn't fit the entire buffer */ return ERR_TRUNCATED; } /* EOF, so we must process the remaining data as a line */ line = s; n = (int)(s.end - s.start); } else { ++n; /* also skip the \n */ } res += n; s.start += n; ++nlines; n = p_line(ez, &line); if (n < 0) { return n; } res += n; } p_end(ez); return res; } /* diff calc ----------------------------------------------------------- */ /* based on tom94's osu!tp aimod and osuElements */ #define SINGLE_SPACING 125.0f #define STAR_SCALING_FACTOR 0.0675f /* star rating multiplier */ #define EXTREME_SCALING_FACTOR 0.5f /* used to mix aim/speed stars */ #define STRAIN_STEP 400.0f /* diffcalc uses peak strains of 400ms chunks */ #define DECAY_WEIGHT 0.9f /* peak strains are added in a weighed sum */ #define MAX_SPEED_BONUS 45.0f /* ~330BPM 1/4 streams */ #define MIN_SPEED_BONUS 75.0f /* ~200BPM 1/4 streams */ #define ANGLE_BONUS_SCALE 90 #define AIM_TIMING_THRESHOLD 107 #define SPEED_ANGLE_BONUS_BEGIN (5 * M_PI / 6) #define AIM_ANGLE_BONUS_BEGIN (M_PI / 3) float decay_base[] = { 0.3f, 0.15f }; /* strains decay per interval */ float weight_scaling[] = { 1400.0f, 26.25f }; /* balances aim/speed */ /* * TODO: unbloat these params * this function has become a mess with the latest changes, I should split * it into separate funcs for speed and im */ float d_spacing_weight(float distance, float delta_time, float prev_distance, float prev_delta_time, float angle, int type, int* is_single) { float angle_bonus; float strain_time = al_max(delta_time, 50.0f); switch (type) { case DIFF_SPEED: { float speed_bonus; *is_single = distance > SINGLE_SPACING; distance = al_min(distance, SINGLE_SPACING); delta_time = al_max(delta_time, MAX_SPEED_BONUS); speed_bonus = 1.0f; if (delta_time < MIN_SPEED_BONUS) { speed_bonus += (float) pow((MIN_SPEED_BONUS - delta_time) / 40.0f, 2); } angle_bonus = 1.0f; if (!is_nan(angle) && angle < SPEED_ANGLE_BONUS_BEGIN) { float s = (float)sin(1.5 * (SPEED_ANGLE_BONUS_BEGIN - angle)); angle_bonus += (float)pow(s, 2) / 3.57f; if (angle < M_PI / 2) { angle_bonus = 1.28f; if (distance < ANGLE_BONUS_SCALE && angle < M_PI / 4) { angle_bonus += (1 - angle_bonus) * al_min((ANGLE_BONUS_SCALE - distance) / 10, 1); } else if (distance < ANGLE_BONUS_SCALE) { angle_bonus += (1 - angle_bonus) * al_min((ANGLE_BONUS_SCALE - distance) / 10, 1) * (float)sin((M_PI / 2 - angle) * 4 / M_PI); } } } return ( (1 + (speed_bonus - 1) * 0.75f) * angle_bonus * (0.95f + speed_bonus * (float)pow(distance / SINGLE_SPACING, 3.5)) ) / strain_time; } case DIFF_AIM: { float result = 0; float weighted_distance; float prev_strain_time = al_max(prev_delta_time, 50.0f); if (!is_nan(angle) && angle > AIM_ANGLE_BONUS_BEGIN) { angle_bonus = (float)sqrt( al_max(prev_distance - ANGLE_BONUS_SCALE, 0) * pow(sin(angle - AIM_ANGLE_BONUS_BEGIN), 2) * al_max(distance - ANGLE_BONUS_SCALE, 0) ); result = 1.5f * (float)pow(al_max(0, angle_bonus), 0.99) / al_max(AIM_TIMING_THRESHOLD, prev_strain_time); } weighted_distance = (float)pow(distance, 0.99); return al_max( result + weighted_distance / al_max(AIM_TIMING_THRESHOLD, strain_time), weighted_distance / strain_time ); } } return 0.0f; } void d_calc_strain(int type, object_t* o, object_t* prev, float speedmul) { float res = 0; float time_elapsed = (o->time - prev->time) / speedmul; float decay = (float)pow(decay_base[type], time_elapsed / 1000.0f); float scaling = weight_scaling[type]; o->delta_time = time_elapsed; /* this implementation doesn't account for sliders */ if (o->type & (OBJ_SLIDER | OBJ_CIRCLE)) { float diff[2]; v2f_sub(diff, o->normpos, prev->normpos); o->d_distance = v2f_len(diff); res = d_spacing_weight(o->d_distance, time_elapsed, prev->d_distance, prev->delta_time, o->angle, type, &o->is_single); res *= scaling; } o->strains[type] = prev->strains[type] * decay + res; } #if defined(_WIN32) #define FORCECDECL __cdecl #else #define FORCECDECL #endif int FORCECDECL dbl_desc(void const* a, void const* b) { float x = *(float const*)a; float y = *(float const*)b; if (x < y) return 1; if (x == y) return 0; return -1; } int d_update_max_strains(ezpp_t ez, float decay_factor, float cur_time, float prev_time, float cur_strain, float prev_strain, int first_obj) { /* make previous peak strain decay until the current obj */ while (cur_time > ez->interval_end) { if (!array_append(&ez->highest_strains, ez->max_strain)) { return ERR_OOM; } if (first_obj) { ez->max_strain = 0; } else { float decay; decay = (float)pow(decay_factor, (ez->interval_end - prev_time) / 1000.0f); ez->max_strain = prev_strain * decay; } ez->interval_end += STRAIN_STEP * ez->speed_mul; } ez->max_strain = al_max(ez->max_strain, cur_strain); return 0; } void d_weigh_strains(ezpp_t ez, float* pdiff, float* ptotal) { int i; int nstrains = 0; float* strains; float total = 0; float difficulty = 0; float weight = 1.0f; strains = (float*)ez->highest_strains.data; nstrains = ez->highest_strains.len; /* sort strains from highest to lowest */ qsort(strains, nstrains, sizeof(float), dbl_desc); for (i = 0; i < nstrains; ++i) { total += (float)pow(strains[i], 1.2); difficulty += strains[i] * weight; weight *= DECAY_WEIGHT; } *pdiff = difficulty; if (ptotal) { *ptotal = total; } } int d_calc_individual(ezpp_t ez, int type) { int i; /* * the first object doesn't generate a strain, * so we begin with an incremented interval end */ ez->max_strain = 0.0f; ez->interval_end = ( (float)ceil(ez->objects.data[0].time / (STRAIN_STEP * ez->speed_mul)) * STRAIN_STEP * ez->speed_mul ); ez->highest_strains.len = 0; for (i = 0; i < ez->objects.len; ++i) { int err; object_t* o = &ez->objects.data[i]; object_t* prev = 0; float prev_time = 0, prev_strain = 0; if (i > 0) { prev = &ez->objects.data[i - 1]; d_calc_strain(type, o, prev, ez->speed_mul); prev_time = prev->time; prev_strain = prev->strains[type]; } err = d_update_max_strains(ez, decay_base[type], o->time, prev_time, o->strains[type], prev_strain, i == 0); if (err < 0) { return err; } } /* * the peak strain will not be saved for * the last section in the above loop */ if (!array_append(&ez->highest_strains, ez->max_strain)) { return ERR_OOM; } switch (type) { case DIFF_SPEED: d_weigh_strains(ez, &ez->speed_stars, &ez->speed_difficulty); break; case DIFF_AIM: d_weigh_strains(ez, &ez->aim_stars, &ez->aim_difficulty); break; } return 0; } float d_length_bonus(float stars, float difficulty) { return 0.32f + 0.5f * (log10f(difficulty + stars) - log10f(stars)); } int d_std(ezpp_t ez) { int res; res = d_calc_individual(ez, DIFF_SPEED); if (res < 0) { return res; } res = d_calc_individual(ez, DIFF_AIM); if (res < 0) { return res; } ez->aim_length_bonus = d_length_bonus(ez->aim_stars, ez->aim_difficulty); ez->speed_length_bonus = d_length_bonus(ez->speed_stars, ez->speed_difficulty); ez->aim_stars = (float)sqrt(ez->aim_stars) * STAR_SCALING_FACTOR; ez->speed_stars = (float)sqrt(ez->speed_stars) * STAR_SCALING_FACTOR; if (ez->mods & MODS_TOUCH_DEVICE) { ez->aim_stars = (float)pow(ez->aim_stars, 0.8f); } /* calculate total star rating */ ez->stars = ez->aim_stars + ez->speed_stars + (float)fabs(ez->speed_stars - ez->aim_stars) * EXTREME_SCALING_FACTOR; return 0; } /* taiko diff calc ----------------------------------------------------- */ #define TAIKO_STAR_SCALING_FACTOR 0.04125f #define TAIKO_TYPE_CHANGE_BONUS 0.75f /* object type change bonus */ #define TAIKO_RHYTHM_CHANGE_BONUS 1.0f #define TAIKO_RHYTHM_CHANGE_BASE_THRESHOLD 0.2f #define TAIKO_RHYTHM_CHANGE_BASE 2.0f typedef struct taiko_object { int hit; float strain; float time; float time_elapsed; int rim; int same_since; /* streak of hits of the same type (rim/center) */ /* * was the last hit type change at an even same_since count? * -1 if there is no previous switch (for example if the * previous object was not a hit */ int last_switch_even; } taiko_object_t; /* object type change bonus */ float taiko_change_bonus(taiko_object_t* cur, taiko_object_t* prev) { if (prev->rim != cur->rim) { cur->last_switch_even = prev->same_since % 2 == 0; if (prev->last_switch_even != cur->last_switch_even && prev->last_switch_even != -1) { return TAIKO_TYPE_CHANGE_BONUS; } } else { cur->last_switch_even = prev->last_switch_even; cur->same_since = prev->same_since + 1; } return 0; } /* rhythm change bonus */ float taiko_rhythm_bonus(taiko_object_t* cur, taiko_object_t* prev) { float ratio; float diff; if (cur->time_elapsed == 0 || prev->time_elapsed == 0) { return 0; } ratio = al_max(prev->time_elapsed / cur->time_elapsed, cur->time_elapsed / prev->time_elapsed); if (ratio >= 8) { return 0; } /* this is log base TAIKO_RHYTHM_CHANGE_BASE of ratio */ diff = (float)fmod(log(ratio) / log(TAIKO_RHYTHM_CHANGE_BASE), 1.0f); /* * threshold that determines whether the rhythm changed enough * to be worthy of the bonus */ if (diff > TAIKO_RHYTHM_CHANGE_BASE_THRESHOLD && diff < 1 - TAIKO_RHYTHM_CHANGE_BASE_THRESHOLD) { return TAIKO_RHYTHM_CHANGE_BONUS; } return 0; } void taiko_strain(taiko_object_t* cur, taiko_object_t* prev) { float decay; float addition = 1.0f; float factor = 1.0f; decay = (float)pow(decay_base[0], cur->time_elapsed / 1000.0f); /* * we only have strains for hits, also ignore objects that are * more than 1 second apart */ if (prev->hit && cur->hit && cur->time - prev->time < 1000.0f) { addition += taiko_change_bonus(cur, prev); addition += taiko_rhythm_bonus(cur, prev); } /* 300+bpm streams nerf? */ if (cur->time_elapsed < 50.0f) { factor = 0.4f + 0.6f * cur->time_elapsed / 50.0f; } cur->strain = prev->strain * decay + addition * factor; } void swap_ptrs(void** a, void** b) { void* tmp; tmp = *a; *a = *b; *b = tmp; } int d_taiko(ezpp_t ez) { int i, result; /* this way we can swap cur and prev without copying */ taiko_object_t curprev[2]; taiko_object_t* cur = &curprev[0]; taiko_object_t* prev = &curprev[1]; ez->highest_strains.len = 0; ez->max_strain = 0.0f; ez->interval_end = STRAIN_STEP * ez->speed_mul; /* * TODO: separate taiko conversion into its own function * so that it can be reused? probably slower, but cleaner, * more modular and more readable */ for (i = 0; i < ez->nobjects; ++i) { object_t* o = &ez->objects.data[i]; cur->hit = (o->type & OBJ_CIRCLE) != 0; cur->time = o->time; if (i > 0) { cur->time_elapsed = (cur->time - prev->time) / ez->speed_mul; } else { cur->time_elapsed = 0; } if (!o->sound_types) { return ERR_SYNTAX; } cur->strain = 1; cur->same_since = 1; cur->last_switch_even = -1; cur->rim = (o->sound_types[0] & (SOUND_CLAP|SOUND_WHISTLE)) != 0; if (ez->original_mode == MODE_TAIKO) { goto continue_loop; } if (o->type & OBJ_SLIDER) { /* TODO: too much indentation, pull this out */ int isound = 0; float j; /* drum roll, ignore */ if (!o->slider_is_drum_roll || i == 0) { goto continue_loop; } /* * sliders that meet the requirements will * become streams of the slider's tick rate */ for (j = o->time; j < o->time + o->duration + o->tick_spacing / 8; j += o->tick_spacing) { int sound_type = o->sound_types[isound]; cur->rim = (sound_type & (SOUND_CLAP | SOUND_WHISTLE)) != 0; cur->hit = 1; cur->time = j; cur->time_elapsed = (cur->time - prev->time) / ez->speed_mul; cur->strain = 1; cur->same_since = 1; cur->last_switch_even = -1; /* update strains for this hit */ if (i > 0 || j > o->time) { taiko_strain(cur, prev); } result = d_update_max_strains(ez, decay_base[0], cur->time, prev->time, cur->strain, prev->strain, i == 0 && j == o->time); /* warning: j check might fail, floatcheck this */ if (result < 0) { return result; } /* loop through the slider's sounds */ ++isound; isound %= o->nsound_types; swap_ptrs((void**)&prev, (void**)&cur); } /* * since we processed the slider as multiple hits, * we must skip the prev/cur swap which we already did * in the above loop */ continue; } continue_loop: /* update strains for hits and other object types */ if (i > 0) { taiko_strain(cur, prev); } result = d_update_max_strains(ez, decay_base[0], cur->time, prev->time, cur->strain, prev->strain, i == 0); if (result < 0) { return result; } swap_ptrs((void**)&prev, (void**)&cur); } d_weigh_strains(ez, &ez->speed_stars, 0); ez->speed_stars *= TAIKO_STAR_SCALING_FACTOR; ez->stars = ez->speed_stars; return 0; } int d_calc(ezpp_t ez) { switch (ez->mode) { case MODE_STD: return d_std(ez); case MODE_TAIKO: return d_taiko(ez); } info("this gamemode is not yet supported\n"); return ERR_NOTIMPLEMENTED; } /* acc calc ------------------------------------------------------------ */ float acc_calc(int n300, int n100, int n50, int misses) { int total_hits = n300 + n100 + n50 + misses; float acc = 0; if (total_hits > 0) { acc = (n50 * 50.0f + n100 * 100.0f + n300 * 300.0f) / (total_hits * 300.0f); } return acc; } void acc_round(float acc_percent, int nobjects, int misses, int* n300, int* n100, int* n50) { int max300; float maxacc; misses = al_min(nobjects, misses); max300 = nobjects - misses; maxacc = acc_calc(max300, 0, 0, misses) * 100.0f; acc_percent = al_max(0.0f, al_min(maxacc, acc_percent)); *n50 = 0; /* just some black magic maths from wolfram alpha */ *n100 = (int)al_round( -3.0f * ((acc_percent * 0.01f - 1.0f) * nobjects + misses) * 0.5f ); if (*n100 > nobjects - misses) { /* acc lower than all 100s, use 50s */ *n100 = 0; *n50 = (int)al_round( -6.0f * ((acc_percent * 0.01f - 1.0f) * nobjects + misses) * 0.2f ); *n50 = al_min(max300, *n50); } else { *n100 = al_min(max300, *n100); } *n300 = nobjects - *n100 - *n50 - misses; } float taiko_acc_calc(int n300, int n150, int nmiss) { int total_hits = n300 + n150 + nmiss; float acc = 0; if (total_hits > 0) { acc = (n150 * 150.0f + n300 * 300.0f) / (total_hits * 300.0f); } return acc; } void taiko_acc_round(float acc_percent, int nobjects, int nmisses, int* n300, int* n150) { int max300; float maxacc; nmisses = al_min(nobjects, nmisses); max300 = nobjects - nmisses; maxacc = acc_calc(max300, 0, 0, nmisses) * 100.0f; acc_percent = al_max(0.0f, al_min(maxacc, acc_percent)); /* just some black magic maths from wolfram alpha */ *n150 = (int)al_round( -2.0f * ((acc_percent * 0.01f - 1.0f) * nobjects + nmisses) ); *n150 = al_min(max300, *n150); *n300 = nobjects - *n150 - nmisses; } /* std pp calc --------------------------------------------------------- */ /* some kind of formula to get a base pp value from stars */ float base_pp(float stars) { return (float)pow(5.0f * al_max(1.0f, stars / 0.0675f) - 4.0f, 3.0f) / 100000.0f; } int pp_std(ezpp_t ez) { int ncircles = ez->ncircles; float nobjects_over_2k = ez->nobjects / 2000.0f; float length_bonus = ( 0.95f + 0.4f * al_min(1.0f, nobjects_over_2k) + (ez->nobjects > 2000 ? (float)log10(nobjects_over_2k) * 0.5f : 0.0f) ); float miss_penality_aim = 0.97 * pow(1 - pow((double)ez->nmiss / ez->nobjects, 0.775), ez->nmiss); float miss_penality_speed = 0.97 * pow(1 - pow((double)ez->nmiss / ez->nobjects, 0.775f), pow(ez->nmiss, 0.875f)); float combo_break = ( (float)pow(ez->combo, 0.8f) / (float)pow(ez->max_combo, 0.8f) ); float ar_bonus; float final_multiplier; float acc_bonus, od_bonus; float od_squared; float hd_bonus; /* acc used for pp is different in scorev1 because it ignores sliders */ float real_acc; float accuracy; ez->nspinners = ez->nobjects - ez->nsliders - ez->ncircles; if (ez->max_combo <= 0) { info("W: max_combo <= 0, changing to 1\n"); ez->max_combo = 1; } accuracy = acc_calc(ez->n300, ez->n100, ez->n50, ez->nmiss); /* * scorev1 ignores sliders and spinners since they are free 300s * can go negative if we miss everything so we must clamp it */ switch (ez->score_version) { case 1: real_acc = acc_calc( al_max(0, ez->n300 - ez->nsliders - ez->nspinners), ez->n100, ez->n50, ez->nmiss); break; case 2: real_acc = accuracy; ncircles = ez->nobjects; break; default: info("unsupported scorev%d\n", ez->score_version); return ERR_NOTIMPLEMENTED; } /* ar bonus -------------------------------------------------------- */ ar_bonus = 0.0f; if (ez->mods & MODS_RX) { if (ez->ar > 10.67f) { ar_bonus += pow(ez->ar - 10.67f, 1.75f); } else if (ez->ar < 9.5f) { ar_bonus += 0.05f * (9.5f - ez->ar); } } else { if (ez->ar > 10.33f) { ar_bonus += 0.3f * (ez->ar - 10.33f); } else if (ez->ar < 8.0f) { ar_bonus += 0.01f * (8.0f - ez->ar); } } /* aim pp ---------------------------------------------------------- */ ez->aim_pp = base_pp(ez->aim_stars); ez->aim_pp *= length_bonus; if (ez->nmiss > 0) { ez->aim_pp *= miss_penality_aim; } ez->aim_pp *= combo_break; ez->aim_pp *= 1.0f + (float)al_min(ar_bonus, ar_bonus * (ez->nobjects / 1000.0f)); /* hidden */ hd_bonus = 1.0f; if (ez->mods & MODS_HD) { hd_bonus += ez->mods & MODS_RX ? 0.05f * (11.0f - ez->ar) : 0.04f * (12.0f - ez->ar); } ez->aim_pp *= hd_bonus; /* flashlight */ if (ez->mods & MODS_FL) { float fl_bonus = 1.0f + 0.35f * al_min(1.0f, ez->nobjects / 200.0f); if (ez->nobjects > 200) { fl_bonus += 0.3f * al_min(1, (ez->nobjects - 200) / 300.0f); } if (ez->nobjects > 500) { fl_bonus += (ez->nobjects - 500) / 1200.0f; } ez->aim_pp *= fl_bonus; } /* acc bonus (bad aim can lead to bad acc) */ acc_bonus = 0.5f + accuracy / 2.0f; /* od bonus (high od requires better aim timing to acc) */ od_squared = (float)pow(ez->od, 2); od_bonus = 0.98f + od_squared / 2500.0f; ez->aim_pp *= acc_bonus; ez->aim_pp *= od_bonus; /* speed pp -------------------------------------------------------- */ ez->speed_pp = base_pp(ez->speed_stars); ez->speed_pp *= length_bonus; if (ez->nmiss > 0) { ez->speed_pp *= miss_penality_speed; } ez->speed_pp *= combo_break; if (ez->ar > 10.33f) { ez->speed_pp *= 1.0f + (float)al_min(ar_bonus, ar_bonus * (ez->nobjects / 1000.0f));; } ez->speed_pp *= hd_bonus; /* scale the speed value with accuracy slightly */ ez->speed_pp *= (0.95f + od_squared / 750) * (float)pow(accuracy, (14.5 - al_max(ez->od, 8)) / 2); /* it's important to also consider accuracy difficulty when doing that */ ez->speed_pp *= (float) pow(0.98f, ez->n50 < ez->nobjects / 500.0f ? 0.00 : ez->n50 - ez->nobjects / 500.0f); /* acc pp ---------------------------------------------------------- */ /* arbitrary values tom crafted out of trial and error */ ez->acc_pp = (float)pow(1.52163f, ez->od) * (float)pow(real_acc, 24.0f) * 2.83f; /* length bonus (not the same as speed/aim length bonus) */ ez->acc_pp *= al_min(1.15f, (float)pow(ncircles / 1000.0f, 0.3f)); if (ez->mods & MODS_HD) ez->acc_pp *= 1.08f; if (ez->mods & MODS_FL) ez->acc_pp *= 1.02f; /* total pp -------------------------------------------------------- */ final_multiplier = 1.12f; if (ez->mods & MODS_NF) final_multiplier *= (float) al_max(0.9f, 1.0f - 0.2f * ez->nmiss); if (ez->mods & MODS_SO) final_multiplier *= 1.0 - pow((double)ez->nspinners / ez->nobjects, 0.85); if (ez->mods & MODS_RX) { /* aim & acc */ ez->pp = (float)pow( pow(ez->aim_pp, 1.1f) + pow(ez->acc_pp, 1.1f), 1.0f / 1.1f ); } else if (ez->mods & MODS_AP) { /* speed & acc */ ez->pp = (float)pow( pow(ez->speed_pp, 1.1f) + pow(ez->acc_pp, 1.1f), 1.0f / 1.1f ); } else { ez->pp = (float)pow( /* aim, speed & acc */ pow(ez->aim_pp, 1.1f) + pow(ez->speed_pp, 1.1f) + pow(ez->acc_pp, 1.1f), 1.0f / 1.1f ); } ez->pp *= final_multiplier; ez->accuracy_percent = accuracy * 100.0f; return 0; } /* taiko pp calc ------------------------------------------------------- */ int pp_taiko(ezpp_t ez) { float length_bonus; float final_multiplier; float accuracy; ez->n300 = al_max(0, ez->max_combo - ez->n100 - ez->nmiss); accuracy = taiko_acc_calc(ez->n300, ez->n100, ez->nmiss); /* base acc pp */ ez->acc_pp = (float)pow(150.0f / ez->odms, 1.1f); ez->acc_pp *= (float)pow(accuracy, 15.0f) * 22.0f; /* length bonus */ ez->acc_pp *= al_min(1.15f, (float)pow(ez->max_combo / 1500.0f, 0.3f)); /* base speed pp */ ez->speed_pp = ( (float)pow(5.0f * al_max(1.0f, ez->stars / 0.0075f) - 4.0f, 2.0f) ) / 100000.0f; /* length bonus (not the same as acc length bonus) */ length_bonus = 1.0f + 0.1f * al_min(1.0f, ez->max_combo / 1500.0f); ez->speed_pp *= length_bonus; /* miss penality */ ez->speed_pp *= (float)pow(0.985f, ez->nmiss); if (ez->max_combo > 0) { ez->speed_pp *= ( al_min((float)pow(ez->combo - ez->nmiss, 0.5f) / (float)pow(ez->max_combo, 0.5f), 1.0f) ); } /* speed mod bonuses */ if (ez->mods & MODS_HD) { ez->speed_pp *= 1.025f; } if (ez->mods & MODS_FL) { ez->speed_pp *= 1.05f * length_bonus; } /* acc scaling */ ez->speed_pp *= accuracy; /* overall multipliers */ final_multiplier = 1.1f; if (ez->mods & MODS_NF) final_multiplier *= 0.90f; if (ez->mods & MODS_HD) final_multiplier *= 1.10f; ez->pp = ( (float)pow( pow(ez->speed_pp, 1.1f) + pow(ez->acc_pp, 1.1f), 1.0f / 1.1f ) * final_multiplier ); ez->accuracy_percent = accuracy * 100.0f; return 0; } /* main interface ------------------------------------------------------ */ int params_from_map(ezpp_t ez) { int res; ez->ar = ez->cs = ez->hp = ez->od = 5.0f; ez->sv = ez->tick_rate = 1.0f; ez->p_flags = 0; if (ez->mode_override) { ez->p_flags |= P_OVERRIDE_MODE; } if (ez->data) { res = p_map_mem(ez, ez->data, ez->data_size); } else if (!strcmp(ez->map, "-")) { res = p_map(ez, stdin); } else { FILE* f = fopen(ez->map, "rb"); if (!f) { perror("fopen"); res = ERR_IO; } else { res = p_map(ez, f); fclose(f); } } if (res < 0) { goto cleanup; } if (!ez->aim_stars && !ez->speed_stars) { res = d_calc(ez); if (res < 0) { goto cleanup; } } cleanup: return res; } int calc(ezpp_t ez) { int res; if (!ez->max_combo && (ez->map || ez->data)) { if (ez->flags & AUTOCALC_BIT) { ez->base_ar = ez->base_od = ez->base_cs = ez->base_hp = -1; } res = params_from_map(ez); if (res < 0) { return res; } } else { if (ez->base_ar >= 0) ez->ar = ez->base_ar; if (ez->base_od >= 0) ez->od = ez->base_od; if (ez->base_cs >= 0) ez->cs = ez->base_cs; if (ez->base_hp >= 0) ez->hp = ez->base_hp; mods_apply(ez); } if (ez->mode == MODE_TAIKO) { ez->stars = ez->speed_stars; } if (ez->accuracy_percent >= 0) { switch (ez->mode) { case MODE_STD: acc_round(ez->accuracy_percent, ez->nobjects, ez->nmiss, &ez->n300, &ez->n100, &ez->n50); break; case MODE_TAIKO: taiko_acc_round(ez->accuracy_percent, ez->max_combo, ez->nmiss, &ez->n300, &ez->n100); break; } } if (ez->combo < 0) { ez->combo = ez->max_combo - ez->nmiss; } ez->n300 = ez->nobjects - ez->n100 - ez->n50 - ez->nmiss; switch (ez->mode) { case MODE_STD: res = pp_std(ez); break; case MODE_TAIKO: res = pp_taiko(ez); break; default: info("pp calc for this mode is not yet supported\n"); return ERR_NOTIMPLEMENTED; } if (res < 0) { return res; } return 0; } OPPAIAPI ezpp_t ezpp_new(void) { ezpp_t ez = calloc(sizeof(struct ezpp), 1); if (ez) { ez->mode = MODE_STD; ez->mods = MODS_NOMOD; ez->combo = -1; ez->score_version = 1; ez->accuracy_percent = -1; ez->base_ar = ez->base_od = ez->base_cs = ez->base_hp = -1; array_reserve(&ez->objects, 600); array_reserve(&ez->timing_points, 16); array_reserve(&ez->highest_strains, 600); } return ez; } void free_owned_map(ezpp_t ez) { if (ez->flags & OWNS_MAP_BIT) { free(ez->map); free(ez->data); ez->flags &= ~OWNS_MAP_BIT; } ez->map = 0; ez->data = 0; ez->data_size = 0; if (ez->flags & AUTOCALC_BIT) { ez->max_combo = 0; /* force re-parse */ } } OPPAIAPI void ezpp_free(ezpp_t ez) { free_owned_map(ez); array_free(&ez->objects); array_free(&ez->timing_points); array_free(&ez->highest_strains); m_free(ez); free(ez); } OPPAIAPI int ezpp(ezpp_t ez, char* mapfile) { free_owned_map(ez); ez->map = mapfile; return calc(ez); } OPPAIAPI int ezpp_data(ezpp_t ez, char* data, int data_size) { free_owned_map(ez); ez->data = data; ez->data_size = data_size; return calc(ez); } void* memclone(void* p, int size) { void* res = malloc(size); if (res) memcpy(res, p, size); return res; } char* strclone(char* s) { int len = (int)strlen(s) + 1; return memclone(s, len); } OPPAIAPI int ezpp_dup(ezpp_t ez, char* mapfile) { free_owned_map(ez); ez->flags |= OWNS_MAP_BIT; ez->map = strclone(mapfile); return calc(ez); } OPPAIAPI int ezpp_data_dup(ezpp_t ez, char* data, int data_size) { free_owned_map(ez); ez->flags |= OWNS_MAP_BIT; ez->data = memclone(data, data_size); ez->data_size = data_size; return calc(ez); } OPPAIAPI float ezpp_pp(ezpp_t ez) { return ez->pp; } OPPAIAPI float ezpp_stars(ezpp_t ez) { return ez->stars; } OPPAIAPI int ezpp_mode(ezpp_t ez) { return ez->mode; } OPPAIAPI int ezpp_combo(ezpp_t ez) { return ez->combo; } OPPAIAPI int ezpp_max_combo(ezpp_t ez) { return ez->max_combo; } OPPAIAPI int ezpp_mods(ezpp_t ez) { return ez->mods; } OPPAIAPI int ezpp_score_version(ezpp_t ez) { return ez->score_version; } OPPAIAPI float ezpp_aim_stars(ezpp_t ez) { return ez->aim_stars; } OPPAIAPI float ezpp_speed_stars(ezpp_t ez) { return ez->speed_stars; } OPPAIAPI float ezpp_aim_pp(ezpp_t ez) { return ez->aim_pp; } OPPAIAPI float ezpp_speed_pp(ezpp_t ez) { return ez->speed_pp; } OPPAIAPI float ezpp_acc_pp(ezpp_t ez) { return ez->acc_pp; } OPPAIAPI float ezpp_accuracy_percent(ezpp_t ez) { return ez->accuracy_percent; } OPPAIAPI int ezpp_n300(ezpp_t ez) { return ez->n300; } OPPAIAPI int ezpp_n100(ezpp_t ez) { return ez->n100; } OPPAIAPI int ezpp_n50(ezpp_t ez) { return ez->n50; } OPPAIAPI int ezpp_nmiss(ezpp_t ez) { return ez->nmiss; } OPPAIAPI char* ezpp_title(ezpp_t ez) { return ez->title; } OPPAIAPI char* ezpp_title_unicode(ezpp_t ez) { return ez->title_unicode; } OPPAIAPI char* ezpp_artist(ezpp_t ez) { return ez->artist; } OPPAIAPI char* ezpp_artist_unicode(ezpp_t ez) { return ez->artist_unicode; } OPPAIAPI char* ezpp_creator(ezpp_t ez) { return ez->creator; } OPPAIAPI char* ezpp_version(ezpp_t ez) { return ez->version; } OPPAIAPI int ezpp_ncircles(ezpp_t ez) { return ez->ncircles; } OPPAIAPI int ezpp_nsliders(ezpp_t ez) { return ez->nsliders; } OPPAIAPI int ezpp_nspinners(ezpp_t ez) { return ez->nspinners; } OPPAIAPI int ezpp_nobjects(ezpp_t ez) { return ez->nobjects; } OPPAIAPI float ezpp_ar(ezpp_t ez) { return ez->ar; } OPPAIAPI float ezpp_cs(ezpp_t ez) { return ez->cs; } OPPAIAPI float ezpp_od(ezpp_t ez) { return ez->od; } OPPAIAPI float ezpp_hp(ezpp_t ez) { return ez->hp; } OPPAIAPI float ezpp_odms(ezpp_t ez) { return ez->odms; } OPPAIAPI int ezpp_autocalc(ezpp_t ez) { return ez->flags & AUTOCALC_BIT; } OPPAIAPI float ezpp_time_at(ezpp_t ez, int i) { return ez->objects.len ? ez->objects.data[i].time : 0; } OPPAIAPI float ezpp_strain_at(ezpp_t ez, int i, int difficulty_type) { return ez->objects.len ? ez->objects.data[i].strains[difficulty_type] : 0; } OPPAIAPI int ezpp_ntiming_points(ezpp_t ez) { return ez->timing_points.len; } OPPAIAPI float ezpp_timing_time(ezpp_t ez, int i) { return ez->timing_points.len ? ez->timing_points.data[i].time : 0; } OPPAIAPI float ezpp_timing_ms_per_beat(ezpp_t ez, int i) { return ez->timing_points.len ? ez->timing_points.data[i].ms_per_beat : 0; } OPPAIAPI int ezpp_timing_change(ezpp_t ez, int i) { return ez->timing_points.len ? ez->timing_points.data[i].change : 0; } #define setter(t, x) \ OPPAIAPI void ezpp_set_##x(ezpp_t ez, t x) { \ ez->x = x; \ if (ez->flags & AUTOCALC_BIT) { \ calc(ez); \ } \ } setter(float, aim_stars) setter(float, speed_stars) setter(float, base_ar) setter(float, base_od) setter(float, base_hp) setter(int, mode) setter(int, combo) setter(int, score_version) setter(float, accuracy_percent) #undef setter OPPAIAPI void ezpp_set_autocalc(ezpp_t ez, int autocalc) { if (autocalc) { ez->flags |= AUTOCALC_BIT; } else { ez->flags &= ~AUTOCALC_BIT; } } OPPAIAPI void ezpp_set_mods(ezpp_t ez, int mods) { if ((mods ^ ez->mods) & (MODS_MAP_CHANGING | MODS_SPEED_CHANGING)) { /* force map reparse */ ez->aim_stars = ez->speed_stars = ez->stars = 0; ez->max_combo = 0; } ez->mods = mods; if (ez->flags & AUTOCALC_BIT) { calc(ez); } } #define clobber_setter(t, x) \ OPPAIAPI \ void ezpp_set_##x(ezpp_t ez, t x) { \ ez->aim_stars = ez->speed_stars = ez->stars = 0; \ ez->max_combo = 0; \ ez->x = x; \ if (ez->flags & AUTOCALC_BIT) { \ calc(ez); \ } \ } clobber_setter(float, base_cs) clobber_setter(int, mode_override) #undef clobber_setter #define acc_clobber_setter(t, x) \ OPPAIAPI \ void ezpp_set_##x(ezpp_t ez, t x) { \ ez->accuracy_percent = -1; \ ez->aim_stars = ez->speed_stars = ez->stars = 0; \ ez->max_combo = 0; \ ez->x = x; \ if (ez->flags & AUTOCALC_BIT) { \ calc(ez); \ } \ } acc_clobber_setter(int, nmiss) acc_clobber_setter(int, end) acc_clobber_setter(float, end_time) OPPAIAPI void ezpp_set_accuracy(ezpp_t ez, int n100, int n50) { ez->accuracy_percent = -1; ez->n100 = n100; ez->n50 = n50; if (ez->flags & AUTOCALC_BIT) { calc(ez); } } #endif /* OPPAI_IMPLEMENTATION */
the_stack_data/22012610.c
void foo() { int x = -5; return; /*x is out of scope, but foo is not called*/ } int main() { int y = -5; return 0; /*y is out of scope*/ }
the_stack_data/140369.c
#define _GNU_SOURCE #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <fcntl.h> #include <unistd.h> #include <sys/mman.h> #define FILEPATH "/tmp/mmapped3.bin" #define NUMINTS (90) #define FILESIZE (NUMINTS * sizeof(int)) #define __NR_nv_mmap_pgoff 301 #define __NR_copydirtpages 304 #define MAP_SIZE 1024 * 1024 * 500 #define SEEK_BYTES 1024 * 10 #define PAGE_SIZE 4096 #define INVALID_INPUT -2; #define INTERGER_BUFF 1000 void * realloc_map (void *addr, size_t len, size_t old_size) { void *p; p = mremap (addr, old_size, len, MREMAP_MAYMOVE); return p; } struct nvmap_arg_struct{ unsigned long fd; unsigned long offset; int chunk_id; int proc_id; int pflags; int noPersist; int refcount; }; //Method to generate random data int generate_random_text( char *addr, unsigned long len, unsigned long num_words ) { unsigned long idxa =0, idxb =0; unsigned long cntr =0; int wordsize; int maxwordsize = 0 ; int idxc =0; maxwordsize = len / num_words; static const char alphanum[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; for (idxa = 0; idxa < num_words; idxa++) { wordsize = rand()% maxwordsize; for (idxb = 0; idxb < wordsize; idxb++) { if( cntr >= len) break; idxc = rand()% (sizeof(alphanum)/sizeof(alphanum[0]) - 1); addr[cntr] = alphanum[idxc]; cntr++; } addr[cntr] = ' '; cntr++; } return cntr; } int str_cmp( char *addr1, char *addr2, size_t len) { size_t idx = 0; if(len < 1 || !addr1 || !addr2) { printf("invalud len or addr \n"); return INVALID_INPUT; } while(idx < len) { if( *addr1 != *addr2) { printf("string not equal: addr1 %c, addr2 %c \n", *addr1 , *addr2); return -1; } printf ("addr1 %c, addr2 %c \n", *addr1 , *addr2); addr1++; addr2++; idx++; } return 0; } int main(int argc, char *argv[]) { int i; int fd; int result; char *map, *map2, *map_read; /* mmapped array of int's */ void *start_addr; int count =0; unsigned long offset = 0; if(argc < 4){ printf("usage:read mode:1/0, procid, chunkid \n"); exit(0); } int proc_id = atoi(argv[2]); int chunk_id =atoi(argv[3]);; struct nvmap_arg_struct a; fd = open(FILEPATH, O_RDWR | O_CREAT | O_TRUNC, (mode_t)0600); if (fd == -1) { perror("Error opening file for writing"); exit(EXIT_FAILURE); } result = lseek(fd, SEEK_BYTES, SEEK_SET); if (result == -1) { close(fd); perror("Error calling lseek() to 'stretch' the file"); exit(EXIT_FAILURE); } result = write(fd, "", 1); if (result != 1) { close(fd); perror("Error writing last byte of the file"); exit(EXIT_FAILURE); } i =0; a.fd = fd; a.offset = offset; a.chunk_id =chunk_id; a.proc_id = proc_id; a.pflags = 1; a.noPersist = 0; if ((atoi(argv[1])) == 0) { printf("going to mmap write \n"); for(count =0; count < 1; count++) { map = (char *) syscall(__NR_nv_mmap_pgoff, 0, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE| MAP_ANONYMOUS, &a); //map = (char *)mmap( 0, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0); if (map == MAP_FAILED) { close(fd); perror("Error mmapping the file"); exit(EXIT_FAILURE); } printf("map %lu\n", (unsigned long)map); if( generate_random_text( map, MAP_SIZE, MAP_SIZE/10) == -1){ printf("random text generation failed \n"); exit(0); } } //fprintf(stdout, "%s \n", map); }else { printf("going to mmap readd for proc %d" "vmaid %d\n", a.proc_id, a.chunk_id); unsigned int *dest = (unsigned int *)malloc(INTERGER_BUFF * sizeof(unsigned int)); //unsigned int numpages = syscall(__NR_copydirtpages, &a, dest); size_t bytes = MAP_SIZE; //numpages * PAGE_SIZE; map_read = (char *) syscall(__NR_nv_mmap_pgoff, 0, bytes, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS , &a ); if (map_read == MAP_FAILED) { close(fd); perror("Error mmapping the file"); exit(EXIT_FAILURE); } printf("map %lu\n", (unsigned long)map_read); int j =0; char s; for (j = 0; j < bytes; j++) s = (char)map_read[j]; //fprintf(stdout, "%c", (char)map_read[j] ); #if 0 int j = 0; for( i = 0; i < numpages; i++){ memcpy(temp, map_read, PAGE_SIZE); for ( j = 0; j < 4096; j++) fprintf(stdout, "%c", (char)temp[j] ); map_read += PAGE_SIZE; temp += PAGE_SIZE; } #endif } fprintf(stdout,"exiting \n"); return 0; }
the_stack_data/175144413.c
/* Make ncurses(3f) macros available to Fortran */ #include <ncurses.h> #include <stdio.h> /*----------------------------------------------------------------------------*/ void macro_getyx(WINDOW *win, int *y, int *x){ getyx(win,*y,*x); } /*----------------------------------------------------------------------------*/ void macro_getparyx(WINDOW *win, int *y, int *x){ getparyx(win,*y,*x); } /*----------------------------------------------------------------------------*/ void macro_getbegyx(WINDOW *win, int *y, int *x){ getbegyx(win,*y,*x); } /*----------------------------------------------------------------------------*/ void macro_getmaxyx(WINDOW *win, int *y, int *x){ getmaxyx(win,*y,*x); /* fprintf(stderr,"MAXX=%d\n",*x); fprintf(stderr,"MAXY=%d\n",*y); */ } /*----------------------------------------------------------------------------*/ void macro_getcolor(int *CURSES_COLORS, int *CURSES_COLOR_PAIRS){ *CURSES_COLORS=COLORS; *CURSES_COLOR_PAIRS=COLOR_PAIRS; /* fprintf(stderr,"COLORS=%d\n",COLOR_PAIRS); fprintf(stderr,"COLOR_PAIRS=%d\n",COLORS); */ /* FILE *fp; fp=fopen("c.20","w"); fprintf(fp,"COLORS=%ld\n",COLORS); fprintf(fp,"COLOR_PAIRS=%ld\n",COLOR_PAIRS); */ } /*----------------------------------------------------------------------------*/ int macro_PAIR_NUMBER( attr_t attrs){ return(PAIR_NUMBER(attrs)); } /*----------------------------------------------------------------------------*/ WINDOW *returnstd(void){ return(stdscr); } /*----------------------------------------------------------------------------*/ WINDOW *returncur(void){ return(curscr); } /*----------------------------------------------------------------------------*/ WINDOW *macro_getwin(const char *filename){ FILE *filep; WINDOW *newwin; filep=fopen(filename,"r"); newwin=getwin(filep); fclose(filep); return(newwin); } /*----------------------------------------------------------------------------*/ int macro_putwin(WINDOW *win, const char *filename){ FILE *filep; int ierr; filep=fopen(filename,"w"); ierr=putwin(win,filep); fclose(filep); return(ierr); } /*----------------------------------------------------------------------------*/ int macro_debug(WINDOW *win, const char *filename){ FILE *fp2; int ierr; fprintf(fp2,"got here A\n"); fp2=fopen("c.20","w"); fprintf(fp2,"filename=%s\n",filename); fprintf(fp2,"win=%ld\n",(long)win); //added cast to suppress warning fprintf(fp2,"got here B\n"); fflush(fp2); fclose(fp2); return(ierr); } /*----------------------------------------------------------------------------*/ /*><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><*/ /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/ /* At least using the ISO_C_BINDING standard there seems to be a problem passing a variable argument list so ... */ /* printw group with one integer argument */ /*----------------------------------------------------------------------------*/ int i_printw(const char *fmt, int i) { return(printw(fmt,i)); } int i_wprintw(WINDOW *win, const char *fmt, int i) { return(wprintw(win,fmt,i)); } int i_mvprintw(int y, int x, const char *fmt, int i) { return(mvprintw(y,x,fmt,i)); } int i_mvwprintw(WINDOW *win, int y, int x, const char *fmt, int i){ return(mvwprintw(win,y,x,fmt,i)); } /*----------------------------------------------------------------------------*/ int l_printw(const char *fmt, long i) { return(printw(fmt,i)); } int l_wprintw(WINDOW *win, const char *fmt, long i) { return(wprintw(win,fmt,i)); } int l_mvprintw(int y, int x, const char *fmt, long i) { return(mvprintw(y,x,fmt,i)); } int l_mvwprintw(WINDOW *win, int y, int x, const char *fmt, long i){ return(mvwprintw(win,y,x,fmt,i)); } /*----------------------------------------------------------------------------*/ int i2_printw(const char *fmt, short i) { return(printw(fmt,i)); } int i2_wprintw(WINDOW *win, const char *fmt, short i) { return(wprintw(win,fmt,i)); } int i2_mvprintw(int y, int x, const char *fmt, short i) { return(mvprintw(y,x,fmt,i)); } int i2_mvwprintw(WINDOW *win, int y, int x, const char *fmt, short i){ return(mvwprintw(win,y,x,fmt,i)); } /*----------------------------------------------------------------------------*/ /* printw group with no arguments after format */ int n_printw(const char *fmt) { return(printw(fmt)); } int n_wprintw(WINDOW *win, const char *fmt) { return(wprintw(win,fmt)); } int n_mvprintw(int y, int x, const char *fmt) { return(mvprintw(y,x,fmt)); } int n_mvwprintw(WINDOW *win, int y, int x, const char *fmt) { return(mvwprintw(win,y,x,fmt)); } /*----------------------------------------------------------------------------*/ /* printw group with one real argument */ int r_printw(const char *fmt, float r) { return(printw(fmt,r)); } int r_wprintw(WINDOW *win, const char *fmt, float r) { return(wprintw(win,fmt,r)); } int r_mvprintw(int y, int x, const char *fmt, float r) { return(mvprintw(y,x,fmt,r)); } int r_mvwprintw(WINDOW *win, int y, int x, const char *fmt, float r){ return(mvwprintw(win,y,x,fmt,r)); } /*----------------------------------------------------------------------------*/ /* printw group with one string argument */ int s_printw(const char *fmt, char *string) { return(printw(fmt,string)); } int s_wprintw(WINDOW *win, const char *fmt, char *string) { return(wprintw(win,fmt,string)); } int s_mvprintw(int y, int x, const char *fmt, char *string) { return(mvprintw(y,x,fmt,string)); } int s_mvwprintw(WINDOW *win, int y, int x, const char *fmt, char *string){ return(mvwprintw(win,y,x,fmt,string)); } /*----------------------------------------------------------------------------*/ /* printw group with two integer arguments */ int ii_printw(const char *fmt, int i, int j) { return(printw(fmt,i,j)); } int ii_wprintw(WINDOW *win, const char *fmt, int i, int j) { return(wprintw(win,fmt,i,j)); } int ii_mvprintw(int y, int x, const char *fmt, int i, int j) { return(mvprintw(y,x,fmt,i,j)); /* \n and other escaped characters do not appear to work */ /* fprintf(stderr,"Y=%d X=%d I=%d J=%d FORMAT=%s\n",y,x,i,j,fmt); */ } int ii_mvwprintw(WINDOW *win, int y, int x, const char *fmt, int i, int j){ return(mvwprintw(win,y,x,fmt,i,j)); } /*----------------------------------------------------------------------------*/ /*><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><*/ /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/ int i_scanw(char *fmt, int *i) { return(scanw(fmt,i)); } int i_wscanw(WINDOW *win, char *fmt, int *i) { return(wscanw(win,fmt,i)); } int i_mvscanw(int y, int x, char *fmt, int *i) { return(mvscanw(y,x,fmt,i)); } int i_mvwscanw(WINDOW *win, int y, int x, char *fmt, int *i){ return(mvwscanw(win,y,x,fmt,i)); } /*----------------------------------------------------------------------------*/ int l_scanw(char *fmt, long *i) { return(scanw(fmt,i)); } int l_wscanw(WINDOW *win, char *fmt, long *i) { return(wscanw(win,fmt,i)); } int l_mvscanw(int y, int x, char *fmt, long *i) { return(mvscanw(y,x,fmt,i)); } int l_mvwscanw(WINDOW *win, int y, int x, char *fmt, long *i){ return(mvwscanw(win,y,x,fmt,i)); } /*----------------------------------------------------------------------------*/ int i2_scanw(char *fmt, short *i) { return(scanw(fmt,i)); } int i2_wscanw(WINDOW *win, char *fmt, short *i) { return(wscanw(win,fmt,i)); } int i2_mvscanw(int y, int x, char *fmt, short *i) { return(mvscanw(y,x,fmt,i)); } int i2_mvwscanw(WINDOW *win, int y, int x, char *fmt, short *i){ return(mvwscanw(win,y,x,fmt,i)); } /*----------------------------------------------------------------------------*/ /* scanw group with one real argument */ int r_scanw(char *fmt, float *r) { return(scanw(fmt,r)); } int r_wscanw(WINDOW *win, char *fmt, float *r) { return(wscanw(win,fmt,r)); } int r_mvscanw(int y, int x, char *fmt, float *r) { return(mvscanw(y,x,fmt,r)); } int r_mvwscanw(WINDOW *win, int y, int x, char *fmt, float *r){ return(mvwscanw(win,y,x,fmt,r)); } /*----------------------------------------------------------------------------*/ /* scanw group with one string argument */ int s_scanw(char *fmt, char *string) { return(scanw(fmt,string)); } int s_wscanw(WINDOW *win, char *fmt, char *string) { return(wscanw(win,fmt,string)); } int s_mvscanw(int y, int x, char *fmt, char *string) { return(mvscanw(y,x,fmt,string)); } int s_mvwscanw(WINDOW *win, int y, int x, char *fmt, char *string){ return(mvwscanw(win,y,x,fmt,string)); } /*----------------------------------------------------------------------------*/ /* scanw group with two integer arguments */ int ii_scanw(char *fmt, int *i, int *j) { return(scanw(fmt,i,j)); } int ii_wscanw(WINDOW *win, char *fmt, int *i, int *j) { return(wscanw(win,fmt,i,j)); } int ii_mvscanw(int y, int x, char *fmt, int *i, int *j) { return(mvscanw(y,x,fmt,i,j)); /* \n and other escaped characters do not appear to work */ /* fprintf(stderr,"Y=%d X=%d I=%d J=%d FORMAT=%s\n",y,x,*i,*j,fmt); */ } int ii_mvwscanw(WINDOW *win, int y, int x, char *fmt, int *i, int *j){ return(mvwscanw(win,y,x,fmt,i,j)); } /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/ /*><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><*/ /*----------------------------------------------------------------------------*/
the_stack_data/93888196.c
/* ******************************************************************************* * Copyright (c) 2020-2021, STMicroelectronics * All rights reserved. * * This software component is licensed by ST under BSD 3-Clause license, * the "License"; You may not use this file except in compliance with the * License. You may obtain a copy of the License at: * opensource.org/licenses/BSD-3-Clause * ******************************************************************************* */ #if defined(ARDUINO_GENERIC_F048C6UX) #include "pins_arduino.h" /** * @brief System Clock Configuration * @param None * @retval None */ WEAK void SystemClock_Config(void) { /* SystemClock_Config can be generated by STM32CubeMX */ #warning "SystemClock_Config() is empty. Default clock at reset is used." } #endif /* ARDUINO_GENERIC_* */
the_stack_data/167329647.c
#include<assert.h> extern int __VERIFIER_nondet_int(); int main() { int x = 5; int y = 10; int nondet = __VERIFIER_nondet_int(); int p; if (nondet) { y = 100; p = 1; } else { p = 2; } while (__VERIFIER_nondet_int()) { x++; y++; } assert((nondet && p == 1) || (!nondet && p == 2)); }
the_stack_data/746417.c
/* Unwinding of DW_CFA_GNU_negative_offset_extended test program. Copyright 2007-2020 Free Software Foundation, Inc. This file is part of GDB. 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> /* i386-gnu-cfi-asm.S: */ extern void *gate (void *(*gate) (void *data), void *data); int main (void) { gate ((void *(*) (void *data)) abort, NULL); return 0; }
the_stack_data/22013598.c
#include <stdio.h> void mySmallFunction(int array[]); void mySmallerFunction(int* array); int main() { int array[5]; mySmallFunction(array); return 0; } void mySmallFunction(int array[]) { printf("Calling sub-function...\n"); mySmallerFunction(array); } void mySmallerFunction(int* array) { *array = 10; }
the_stack_data/237644414.c
// Moisés Fernández Zárate A01197049 // Hour Of Code 3 // 28/04/2020 #include <stdio.h> #include <stdlib.h> #include <string.h> // Struct to store a coordinate with its latitude and longitude. typedef struct Coord { char cLat[100]; double dLat; char cLong[100]; double dLong; } Coord; /* * Function to store the coordinates and sort them in ascending order. * Parameters: file, the file from where the coordinates are read. * coordinatesList, the list where the coordinates will be stored. * numberCoordinates, the number coordinates in the file. * Return value: None. */ void storeCoordinates(FILE *file, Coord* coordinatesList, int numberCoordinates); /* * Function to compare two coordinates' values (latitude and longitude) and * it is used to sort the list of coordinates. * Parameters: c1, one coordinate that will be compared. * c2, the other coordinate that will be compared with c1. * Return value: an integer that means which one is smaller. */ int compare(const void * c1, const void * c2); /* * Function to change the characters for cardinal points to words. * Parameters: cardinal, the character that will be changed to a word. * Return value: a string, the word to which the character was changed. */ char* changeCardinals(const char cardinal); /* * Function to search for the characters of the cardinals in a coordinate. * Parameters: the coordinate to search in for the character of the cardinal. * Return value: None. */ void searchCardinals(char coordinate[]); /* * Function to generate the new files. * Parameters: coordinatesList, to send the information to the files. * numberCoordinates, the number of coordinates in the list. * Return value: None. */ void generateFiles(Coord *coordinatesList, int numberCoordinates); // Main function. int main(int argc, char *argv[]) { if (argc != 2) { printf("Usage: %s (name of the file)\n", argv[0]); exit(1); } // Get the name of the file and store it with the var type FILE. char *nameFile = argv[1]; FILE *file = fopen(nameFile, "r"); // To store the number of coordinates that the file has. char input[300]; int numberCoordinates = 0; while (fscanf(file, "%s", input) == 1) { numberCoordinates++; } rewind(file); // Divide by 6 because of the coordinate format: // Latitude: a b // Longitude: c d numberCoordinates /= 6; Coord* coordinatesList = (Coord *) malloc(sizeof(Coord)*numberCoordinates); storeCoordinates(file, coordinatesList, numberCoordinates); generateFiles(coordinatesList, numberCoordinates); fclose(file); free(coordinatesList); } void storeCoordinates(FILE *file, Coord* coordinatesList, int numberCoordinates) { char cLong[50]; double dLong; char cLat[50]; double dLat; char temp[50]; for (int i = 0; i < numberCoordinates; i++) { fscanf(file, "%s", temp); fscanf(file, "%s", cLat); fscanf(file, "%lf", &dLat); fscanf(file, "%s", temp); fscanf(file, "%s", cLong); fscanf(file, "%lf", &dLong); Coord coordinate; strcpy(coordinate.cLat, cLat); strcpy(coordinate.cLong, cLong); coordinate.dLat = dLat; coordinate.dLong = dLong; coordinatesList[i] = coordinate; } rewind(file); qsort(coordinatesList, numberCoordinates, sizeof(Coord), compare); } int compare(const void * c1, const void * c2) { struct Coord *coord1 = (struct Coord *)c1; struct Coord *coord2 = (struct Coord *)c2; if (coord1->dLat < coord2->dLat) { return -1; } else if(coord1->dLat > coord2->dLat) { return 1; } else if(coord1->dLong < coord2->dLong) { return -1; } else if(coord1->dLong > coord2->dLong) { return 1; } return 0; } char* changeCardinals(const char cardinal) { if (cardinal == 'N') { return "North"; } if (cardinal == 'E') { return "East"; } if (cardinal == 'S') { return "South"; } if (cardinal == 'W') { return "West"; } } void searchCardinals(char coordinate[]) { char *quote = strstr(coordinate, "″"); strcpy(quote + 3, changeCardinals(*(quote + 3))); } void generateFiles(Coord *coordinatesList, int numberCoordinates) { FILE *file1 = fopen("file1.txt", "w"); FILE *file2 = fopen("file2.txt", "w"); for (int i = 0; i < numberCoordinates; i++) { searchCardinals(coordinatesList[i].cLat); searchCardinals(coordinatesList[i].cLong); fprintf(file1, "%s %s\n", coordinatesList[i].cLat, coordinatesList[i].cLong); fprintf(file2, "%lf %lf\n", coordinatesList[i].dLat, coordinatesList[i].dLong); } fclose(file1); fclose(file2); }
the_stack_data/1011403.c
/* Micro Scheme (C) A. Carl Douglas */ #include <stdint.h> #if defined(BSD) #include <stdio.h> #else #include <bsd/stdio.h> #endif #include <stdlib.h> #include <string.h> #define debug(m,e) fprintf(default_output_port->value.stream, "%s:%d: %s:",__FILE__,__LINE__,m); print_obj(default_output_port, e); fprintf(default_output_port->value.stream, "\n"); typedef struct Object { enum { _Symbol, _Pair, _Primitive, _Closure, _Macro, _Syntax, _Char, _String, _Integer, _Port } tag; union Value { long mword; const char * string; FILE *stream; struct Object * (*pfn) (struct Object *); struct Object * (*psyn) (struct Object *, struct Object *); struct List { struct Object * next; struct Object * data; } pair; struct Closure { struct Object * params; struct Object * body; struct Object * env; } closure; } value; } Object; static Object *default_input_port = 0, *default_output_port = 0, *symbols = 0; static int look; /* look ahead character */ #define TOKEN_MAX 32 static char token[TOKEN_MAX]; /* token */ int is_space(char x) { return x == ' ' || x == '\n'; } int is_parens(char x) { return x == '(' || x == ')'; } int is_syntaxquote(char x) { return x == '\'' || x == '`' || x == ','; } int is_doublequote(char x) { return x == '"'; } int is_digit(char x) { return x >= '0' && x <= '9'; } int is_op(char x) { return x == '-' || x == '+' || x == '*' || x == '/' || x == '=' || x == '%' || x == '^' || x == '&' || x == '|' || x == '!' ; } int freadmem(void *cookie, char *buf, int size) { /* funopen enables parsing of memory as well as files */ char **position = (char **) cookie, *mem = * (char **) position; int num_read = 0; for( ; num_read < size && *mem != '\0'; num_read++) *buf++ = *mem++; if (*mem == '\0') *buf++ = EOF; /* printf("Read %d bytes of %d: %s\n", num_read, size, *position); */ *position = mem; /* move the stream pointer */ return num_read; } int fwritemem(void *cookie, char *buf, int size) { /* funopen write */ char **position = (char **) cookie, *mem = * (char **) position; int num_written = 0; for( ; num_written < size && *buf != '\0' ; num_written++) *mem++ = *buf++; *position = mem; return num_written; } void lookahead(Object *port) { look = getc(port->value.stream); } void gettoken(Object *port) { int index = 0; while(is_space(look)) { lookahead(port); } if (is_parens(look) || is_syntaxquote(look) || is_op(look)) { /* parens, quoting, quasiquoting */ token[index++] = look, lookahead(port); if (token[0] == ',' && look == '@') { token[index++] = look, lookahead(port); } } else if (is_doublequote(look)) { /* string */ token[index++] = look, lookahead(port); /* " */ while(index < TOKEN_MAX - 1 && look != EOF && !is_doublequote(look)) { token[index++] = look, lookahead(port); } lookahead(port); /* don't keep closing double quote */ } else if (is_digit(look)) { /* number */ while(index < TOKEN_MAX - 1 && look != EOF && is_digit(look)) { token[index++] = look, lookahead(port); } } else { /* symbol */ while(index < TOKEN_MAX - 1 && look != EOF && !is_space(look) && !is_parens(look)) { token[index++] = look, lookahead(port); } } token[index] = '\0'; } Object * tagalloc(int type) { Object *obj = calloc( 1, sizeof (Object) ); obj->tag = type; return obj; } Object * cons(Object * _car, Object * _cdr) { Object *_pair = tagalloc(_Pair); _pair->value.pair.data = _car, _pair->value.pair.next = _cdr; return _pair; } Object * newsymbol(const char *str) { Object *obj = tagalloc(_Symbol); obj->value.string = strdup(str); return obj; } Object *newnumber(long num) { Object *obj = tagalloc(_Integer); obj->value.mword = num; return obj; } Object * newstring(const char *str) { Object *obj = tagalloc(_String); obj->value.string = str; return obj; } Object * newprimop( Object * (*fn) (Object *) ) { Object *obj = tagalloc(_Primitive); obj->value.pfn = fn; return obj; } Object * newclosure( Object *params, Object *body, Object *env ) { Object *obj = tagalloc(_Closure); obj->value.closure.params = params, obj->value.closure.body = body, obj->value.closure.env = env; return obj; } Object * newsyntax( Object * (*fn) (Object *, Object *) ) { Object *obj = tagalloc(_Syntax); obj->value.psyn = fn; return obj; } Object * newmacro( Object *params, Object *body, Object *env ) { Object *obj = tagalloc(_Macro); obj->value.closure.params = params, obj->value.closure.body = body, obj->value.closure.env = env; return obj; } Object * newchar(char ch) { Object *obj = tagalloc(_Char); obj->value.mword = ch; return obj; } Object * newport(FILE *stream) { Object *obj = tagalloc(_Port); obj->value.stream = stream; return obj; } Object *car(Object *x) { return x ? x->value.pair.data : 0; } Object *cdr(Object *x) { return x ? x->value.pair.next : 0; } #define e_true intern("#t") #define e_false 0 Object * intern(const char *sym) { Object *_pair = symbols; for ( ; _pair ; _pair = cdr(_pair)) if (strncmp(sym, car(_pair)->value.string, TOKEN_MAX)==0) return car(_pair); symbols = cons(newsymbol(sym), symbols); return car(symbols); } Object * getlist(Object *port); Object * getobj(Object *port); Object * gettokenobj(Object *port) { gettoken(port); return getobj(port); } Object * getobj(Object *port) { /* reader macros */ if (token[0] == ',' && token[1] == '@') return cons(intern("unquote-splicing"), cons(gettokenobj(port), 0)); if (token[0] == ',') return cons(intern("unquote"), cons(gettokenobj(port), 0)); if (token[0] == '`') return cons(intern("quasiquote"), cons(gettokenobj(port), 0)); if (token[0] == '\'') return cons(intern("quote"), cons(gettokenobj(port), 0)); if (token[0] == '(') return getlist(port); if (is_doublequote(token[0])) return newstring(token+1); /* drop opening double quote */ if (is_digit(token[0])) return newnumber(atoi(token)); return intern(token); } Object * getlist(Object *port) { Object *tmp; gettoken(port); if (token[0] == ')') return (Object *) 0; tmp = getobj(port); return cons(tmp, getlist(port)); } void newline(Object *port) { fprintf(port->value.stream, "\n"); } void print_obj(Object *port, Object *ob); Object * format(Object *port, Object *control, Object *args); void err(const char *msg, Object *exp) { fprintf(default_output_port->value.stream, "%s", msg); print_obj(default_output_port, exp); newline(default_output_port); exit(1); } void print_obj_list(Object *port, Object *ob) { print_obj(port, car(ob)); if (cdr(ob) != 0) { if(cdr(ob)->tag == _Pair) { fprintf(port->value.stream, " "); print_obj_list(port, cdr(ob)); } else { fprintf(port->value.stream, " . "); print_obj(port, cdr(ob)); } } } void print_obj(Object *port, Object *ob) { if (ob == 0) { fprintf(port->value.stream, "()"); } else if (ob->tag == _Symbol) { fprintf(port->value.stream, "%s", ob->value.string); } else if (ob->tag == _Pair) { /* todo print '`, instead of quote */ fprintf(port->value.stream, "("); print_obj_list(port, ob); fprintf(port->value.stream, ")"); } else if (ob->tag == _Closure) { fprintf(port->value.stream, "<CLOSURE>"); print_obj(port, ob->value.closure.params); print_obj(port, ob->value.closure.body); } else if (ob->tag == _Primitive) { fprintf(port->value.stream, "<PRIMOP>"); } else if (ob->tag == _Macro) { fprintf(port->value.stream, "<MACRO>"); print_obj(port, ob->value.closure.params); print_obj(port, ob->value.closure.body); } else if (ob->tag == _Syntax) { fprintf(port->value.stream, "<SYNTAX>"); } else if (ob->tag == _Char) { fprintf(port->value.stream, "%c", (int) ob->value.mword); } else if (ob->tag == _String) { fprintf(port->value.stream, "\"%s\"", ob->value.string); } else if (ob->tag == _Integer) { fprintf(port->value.stream, "%ld", ob->value.mword); } } Object * format(Object *port, Object *control, Object *args) { const char *fmt = control->value.string; while(*fmt) { if (*fmt == '~') {/* ~s write, ~a display, ~% newline, ~~ tilde */ fmt++; if (*fmt == 's') { print_obj(port, car(args)); args = cdr(args); } else if (*fmt == '%') { fputc('\n', port->value.stream); } else if (*fmt == '~') { fputc('~', port->value.stream); } fmt++; } else { fputc(*fmt++, port->value.stream); } } return e_true; } Object * eval(Object *exp, Object *env); Object * apply(Object *fun, Object *args); Object * expand(Object *fun, Object *exp); Object * map_(Object *list, Object * (*function) (Object *, Object *), Object *context) { Object *head = 0, **args = &head; for ( ; list ; list = cdr(list) ) { *args = cons( function(car(list), context), 0); args = &(*args)->value.pair.next; } return head; } Object *fcons(Object *a) { return cons(car(a), car(cdr(a))); } Object *fcar(Object *a) { return car(car(a)); } Object *fcdr(Object *a) { return cdr(car(a)); } Object *feq(Object *a) { return car(a) == car(cdr(a)) ? e_true : e_false; } Object *fnot(Object *a) { return car(a) == e_false ? e_true : e_false; } Object *fpair(Object *a) { return car(a)->tag == _Pair ? e_true : e_false; } Object *fatom(Object *a) { return car(a)->tag == _Symbol ? e_true : e_false; } Object *fnull(Object *a) { return car(a) == 0 ? e_true : e_false; } Object *freadobj(Object *a) { return gettokenobj(default_input_port); } Object *fwriteobj(Object *a){ print_obj(default_output_port, car(a)); newline(default_output_port); return e_true; } Object *fputch(Object *a) { putchar(car(a)->value.mword); return e_true; } Object *fgetch(Object *a) { return newchar(getchar()); } Object *fformat(Object *a) { return format(default_output_port, car(a), cdr(a)); } Object *feval(Object *a) { return eval(car(a), car(cdr(a))); } Object *fquote(Object *exp, Object *env){ return car(cdr(exp)); } Object *flambda(Object *exp, Object *env){ return newclosure(car(cdr(exp)), car(cdr(cdr(exp))), env); } Object *fenv(Object *exp, Object *env) { return env; } #define DEFMATH(OP,NAME) \ Object * NAME (Object *args) { \ Object *result = newnumber( car(args)->value.mword ); \ for ( args = cdr(args); args; args = cdr(args)) \ result->value.mword = result->value.mword OP car(args)->value.mword; \ return result; \ } #define DEFCMP(OP,NAME,FIELD) Object * NAME (Object *args) { return car(args)->value.FIELD OP car(cdr(args))->value.FIELD ? e_true : e_false; } DEFMATH(+,fadd) DEFMATH(-,fsub) DEFMATH(*,fmul) DEFMATH(/,fdiv) DEFMATH(%,fmodulo) DEFMATH(^,fexp) DEFCMP(==,fmeq,mword) Object *fapply(Object *exp, Object *env) { Object *head = 0, **args = &head, *tmp = cdr(cdr(exp)); for ( ; cdr(tmp); tmp = cdr(tmp) ) { *args = cons( eval(car(tmp), env), 0); args = &(*args)->value.pair.next; } *args = eval(car(tmp), env); /* last argument to apply must be a list */ return apply(eval(car(cdr(exp)), env), head); } Object *fexpand(Object *exp, Object *env) { Object *fun = eval(car(car(cdr(exp))), env); if (fun->tag == _Macro) { return expand(fun, cdr(car(cdr(exp)))); } err("cannot expand: ", exp); return 0; } Object *fmacro(Object *exp, Object *env) { Object *lambda = eval(car(cdr(exp)), env); if (lambda->tag == _Closure) { return newmacro(lambda->value.closure.params, lambda->value.closure.body, lambda->value.closure.env); } err("cannot make macro from: ", exp); return 0; } Object *fif(Object *exp, Object *env) { if (eval(car(cdr(exp)), env) != e_false) /* anything not false is true */ return eval(car(cdr(cdr(exp))), env); else return eval(car(cdr(cdr(cdr(exp)))), env); } Object * bind_append(Object *names, Object *values, Object *tail) { Object *head = tail, **args = &head; if (names && names->tag == _Symbol) { /* (lambda args (do args)) */ return cons( cons(names, cons(values, 0)), tail); } for ( ; names && values ; values = cdr(values), names = cdr(names) ) { if (car(names) == intern(".")) { /* variadic lambda syntax */ *args = cons( cons(car(cdr(names)), cons(values, 0)), tail); break; } *args = cons( cons(car(names), cons(car(values), 0)) , tail); args = &( *args )->value.pair.next; } return head; } Object *expand(Object *fun, Object *exp) { if (fun->tag == _Macro) { return eval( fun->value.closure.body, bind_append(fun->value.closure.params, exp, fun->value.closure.env) ); } err("cannot expand: ", fun); return 0; } Object * apply(Object *fun, Object *args) { if (fun->tag == _Primitive) { return fun->value.pfn(args); } else if (fun->tag == _Closure) { return eval( fun->value.closure.body, bind_append(fun->value.closure.params, args, fun->value.closure.env) ); } err("cannot apply: ", fun); return 0; } #define evlist(ex,en) map_(ex, eval, en) Object * eval(Object *exp, Object *env) { if (exp->tag == _Symbol ) { for ( ; env != 0; env = cdr(env) ) { if (exp == car(car(env))) return car(cdr(car(env))); } err("cannot lookup: ", exp); return 0; } else if (exp->tag == _Integer) { return exp; } else if (exp->tag == _String) { return exp; } else if (exp->tag == _Closure) { return eval( exp->value.closure.body, env ); } else if (exp->tag == _Pair) { /* prepare for apply */ Object *fun = eval(car(exp), env); if (fun->tag == _Macro) { /* expand and evaluate */ return eval(expand(fun, cdr(exp)), env); } else if (fun->tag == _Syntax) { /* special forms */ return fun->value.psyn(exp, env); } else { return apply(fun, evlist(cdr(exp), env)); } } err("cannot evaluate: ", exp); return 0; } /* A limitation of the macro stringizing # is being able to use a single quote 'x use (quote x) instead */ #define LISP(code) #code static const char * env_src[][2] = { { "Y", LISP((lambda (fn) ((lambda (h) (h h)) (lambda (g) (fn (lambda args (apply (g g) args))))))) }, { "list", LISP((lambda args args)) }, { "foldr", LISP((lambda (fn0 acc0 lst0) ((Y (lambda (foldr0) (lambda (acc lst) (if (null? lst) acc (fn0 (car lst) (foldr0 acc (cdr lst))))))) acc0 lst0 ))) }, { "foldl", LISP((lambda (fn0 acc0 lst0) ((Y (lambda (foldl0) (lambda (acc lst) (if (null? lst) acc (foldl0 (fn0 (car lst) acc) (cdr lst)))))) acc0 lst0 ))) }, { "cond", LISP((macro (lambda exp0 ((Y (lambda (condr) (lambda (exp) (if (null? exp) (quote (quote ())) (list (quote if) (car (car exp)) (car (cdr (car exp))) (condr (cdr exp))))))) exp0 )))) }, { "append", LISP((Y (lambda (append0) (lambda (x y) (cond ((null? x) y) ((quote #t) (cons (car x) (append0 (cdr x) y)))))))) }, { "quasiquote", LISP((macro (lambda (exp0) (cons (quote list) ((Y (lambda (expand-qq) (lambda (exp) (cond ((null? exp) (quote ())) ((pair? exp) (cond ((eq? (car exp) (quote unquote)) (car (cdr exp))) ((eq? (car exp) (quote unquote-splicing)) (append (car (cdr exp)) (expand-qq (cdr (cdr exp))))) ((quote #t) (cons (expand-qq (car exp)) (expand-qq (cdr exp)))))) ((quote #t) (cons (quote quote) (cons exp (quote ()) ))))))) exp0 ))))) }, { "map", LISP((lambda (fn l0) ((Y (lambda (mapr) (lambda (l1 l2) (if (null? l1) l2 (cons (fn (car l1)) (mapr (cdr l1) l2)))))) l0 (quote ()) ))) }, { "let", LISP((macro (lambda (args body) (append (list (list (quote lambda) (map (lambda (x) (car x)) args) body)) (map (lambda (x) (car (cdr x))) args))))) }, { "let*", LISP((macro (lambda (args body) (foldr (lambda (x y) (list (quote let) (list x) y)) body args )))) }, { "letrec", LISP((macro (lambda (args body) (list (quote let) (map (lambda (x) (let ((var (car x)) (val (car (cdr x)))) (list var (list (quote Y) (list (quote lambda) (list var) val))))) args) body )))) }, { "letrec*", LISP((macro (lambda (args body) (foldr (lambda (x y) (list (quote letrec) (list x) y)) body args )))) }, { "curry", LISP((lambda (func arg1) (lambda (arg) (apply func (cons arg1 (list arg)))))) }, { "compose", LISP((lambda (f g) (lambda arg (f (apply g arg))))) }, { 0, 0 } }; Object *eval_string(const char *str, Object *env) { Object *port = newport( funopen(&str, freadmem, NULL, NULL, NULL) ); lookahead(port); return eval(gettokenobj(port), env); } Object *extend_env(Object *env, const char *src[][2]) { for ( ; (*src)[0] ; src++) { env = cons(cons(intern( (*src)[0] ), cons(eval_string( (*src)[1] , env), 0)), env); } return env; } int main(int argc, char *argv[]) { Object *env = cons (cons(intern("car"), cons(newprimop(fcar), 0)), cons (cons(intern("cdr"), cons(newprimop(fcdr), 0)), cons (cons(intern("cons"), cons(newprimop(fcons), 0)), cons (cons(intern("eq?"), cons(newprimop(feq), 0)), cons (cons(intern("not"), cons(newprimop(fnot), 0)), cons (cons(intern("pair?"), cons(newprimop(fpair), 0)), cons (cons(intern("symbol?"), cons(newprimop(fatom), 0)), cons (cons(intern("null?"), cons(newprimop(fnull), 0)), cons (cons(intern("read"), cons(newprimop(freadobj), 0)), cons (cons(intern("write"), cons(newprimop(fwriteobj), 0)), cons (cons(intern("format"), cons(newprimop(fformat), 0)), cons (cons(intern("eval"), cons(newprimop(feval), 0)), cons (cons(intern("apply"), cons(newsyntax(fapply), 0)), cons (cons(intern("quote"), cons(newsyntax(fquote), 0)), cons (cons(intern("lambda"), cons(newsyntax(flambda), 0)), cons (cons(intern("if"), cons(newsyntax(fif), 0)), cons (cons(intern("macro"), cons(newsyntax(fmacro), 0)), cons (cons(intern("expand"), cons(newsyntax(fexpand), 0)), cons (cons(intern("environment"), cons(newsyntax(fenv), 0)), cons (cons(intern("+"), cons(newprimop(fadd), 0)), cons (cons(intern("-"), cons(newprimop(fsub), 0)), cons (cons(intern("*"), cons(newprimop(fmul), 0)), cons (cons(intern("/"), cons(newprimop(fdiv), 0)), cons (cons(intern("="), cons(newprimop(fmeq), 0)), 0)))))))))))))))))))))))); env = extend_env(env, env_src); default_input_port = newport(stdin), default_output_port = newport(stdout); lookahead(default_input_port); print_obj(default_output_port, eval(gettokenobj(default_input_port), env) ); newline(default_output_port); return 0; }
the_stack_data/1036345.c
#include<stdio.h> #define x 3 #define y 3 int main() { int arr[x][y]; int i,j; int *ptr=arr; int Sum=0; int Sum1=0; printf(" Enter elements in matrix of size %dx%d \n", x, y); for(i=0; i<x; i++) { for(j=0; j<y; j++) { printf(" element[%d][%d] : ",i,j); scanf(" %d", ptr); ptr++; } } ptr=arr; printf(" The matrix is :\t"); for(i=0; i<x; i++) { for(j=0; j<y; j++) { printf("%d ", *ptr); ptr++; } } //since we know diagonal matrix or the elements are a[0][0],a[1][1],a[2][2] and a[0][2],a[1][1],a[2][0] for(i=0; i<x; i++) { Sum = Sum + arr[i][i]; } printf("\n It's the sum of diagonal a[0][0],a[1][1],a[2][2]"); printf("\n The Sum of 1st Diagonal Elements of a Matrix = %d", Sum ); int size=x; for(i=0; i<=size+1; i++) { Sum1 = Sum1 + arr[i][size-1]; size--; } printf("\n It's the sum of diagonal a[0][2],a[1][1],a[2][0]"); printf("\n The Sum of 2st Diagonal Elements of a Matrix = %d", Sum1 ); return 0; }
the_stack_data/215767163.c
/** * @license Apache-2.0 * * Copyright (c) 2020 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Benchmark `signbit`. */ #include <stdlib.h> #include <stdio.h> #include <math.h> #include <time.h> #include <sys/time.h> #define NAME "signbit" #define ITERATIONS 1000000 #define REPEATS 3 /** * Prints the TAP version. */ void print_version() { printf( "TAP version 13\n" ); } /** * Prints the TAP summary. * * @param total total number of tests * @param passing total number of passing tests */ void print_summary( int total, int passing ) { printf( "#\n" ); printf( "1..%d\n", total ); // TAP plan printf( "# total %d\n", total ); printf( "# pass %d\n", passing ); printf( "#\n" ); printf( "# ok\n" ); } /** * Prints benchmarks results. * * @param elapsed elapsed time in seconds */ void print_results( double elapsed ) { double rate = (double)ITERATIONS / elapsed; printf( " ---\n" ); printf( " iterations: %d\n", ITERATIONS ); printf( " elapsed: %0.9f\n", elapsed ); printf( " rate: %0.9f\n", rate ); printf( " ...\n" ); } /** * Returns a clock time. * * @return clock time */ double tic() { struct timeval now; gettimeofday( &now, NULL ); return (double)now.tv_sec + (double)now.tv_usec/1.0e6; } /** * Generates a random number on the interval [0,1]. * * @return random number */ float rand_float() { int r = rand(); return (float)r / ( (float)RAND_MAX + 1.0f ); } /** * Runs a benchmark. * * @return elapsed time in seconds */ double benchmark() { double elapsed; float x; float y; double t; int i; t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { x = ( 1000.0f * rand_float() ) - 500.0f; y = signbit( x ); if ( y != y ) { printf( "should not return NaN\n" ); break; } } elapsed = tic() - t; if ( y != y ) { printf( "should not return NaN\n" ); } return elapsed; } /** * Main execution sequence. */ int main( void ) { double elapsed; int i; // Use the current time to seed the random number generator: srand( time( NULL ) ); print_version(); for ( i = 0; i < REPEATS; i++ ) { printf( "# c::%s\n", NAME ); elapsed = benchmark(); print_results( elapsed ); printf( "ok %d benchmark finished\n", i+1 ); } print_summary( REPEATS, REPEATS ); }
the_stack_data/137867.c
#include<stdio.h> #include<math.h> #include<stdlib.h> #include<malloc.h> #include<string.h> #define g 9.80 //gravidade (m/s²) #define l 2.00 //tamanho da corda (m) #define Vo 5.0 //velocidade incial (m/s) #define time 10 //tempo total (s) #define dt 0.0001 //intervalo de tempo (s) #define gamma 10.0 //amortecido 1/s #define pi 180 #define w sqrt(g/l) #define OA Vo/sqrt(g*l) int main() { int n; double N,t,Ot,Ot_1,Ot_2; double O,Oa,T; FILE *fpm; fpm=fopen("pendulo_amortecido_v5_b10.txt","w"); if(!fpm) exit(0); //fprintf(fpm,"#tempo\t\t\t\t #teta\t\t\t\t\t#Periodo\t\t\t\t\t\t#Amplitude"); fprintf(fpm,"#tempo\t\t\t\t #teta"); Ot=0.0; t=0.0; //T=2.0*3.1415926*sqrt(l/g); Oa=Vo/sqrt(g*l); //fprintf(fpm,"\n%.6f\t\t\t\t%.6f\t\t\t\t%.6f\t\t\t\t\t\t%.6f",t,Ot,T,Oa); fprintf(fpm,"\n%.6f\t\t\t\t%.6f",t,Ot); Ot_1=(Vo*dt)/l; fprintf(fpm,"\n%.6f\t\t\t\t%.6f",dt,Ot_1); N=time/dt; //número de iterações for(n=1;n<=N;n++){ t=n*dt; //contator de tempo //O=OA*sin(w*(n+1)*dt);//solução analítica pequenas oscilações do pendulo simples //O=OA*exp(-(gamma/2.0)*t)sin(w*(n+1)*dt) Ot_2=((2.0+gamma*dt)*Ot_1-(g/l)*(dt*dt)*sin(Ot_1)-Ot)/(1.0+dt*gamma); fprintf(fpm,"\n%.6lf\t\t\t\t%.6lf",(n+1)*dt,Ot_2); Ot=Ot_1; Ot_1=Ot_2; } fclose(fpm); }
the_stack_data/90594.c
#include <stdio.h> #if defined(_WIN32) #include <direct.h> #define getcwd _getcwd #else #include <unistd.h> #endif int main() { char working_directory[8096]; if (getcwd(working_directory, sizeof(working_directory)) == NULL) { return 1; } printf("%s", working_directory); return 0; }
the_stack_data/100139225.c
# include<stdio.h> # include<string.h> int main() { int a,b,c,i,j,k,test,n,d,count; scanf("%d",&test); fflush(stdin); while(test--) { scanf("%d",&n); b=n; fflush(stdin); char str[b][50]; char sh[10000]; //gets(sh); scanf("%[^\n]s",sh); a=strlen(sh); printf("%d",a); k=0; j=0; for(i=0;i<a;i++) { if(sh[i]!=' ') { str[k][j]=sh[i]; j++; } else { k++; j=0; // i++; str[k][j]=sh[i]; } } for(i=0;i<b;i++) { printf("%s",str[i]); } d=0; for(i=0;i<b;i++) { count=1; for(j=i;j<b;j++) { c=strcmp(str[i],str[j]); if(c==0) { count++; } } if(count==2) { d++; } } printf("\nTotal no of doubly repeated strings is %d",d); } }
the_stack_data/1028181.c
#include <stdio.h> #include <stdlib.h> #include <unistd.h> int main(int argc, char **argv) { int mem; char *array; if (argc != 2) { fprintf(stderr, "use: ./memory-user membytes\n"); exit(1); } printf("pid: %u\n", (int)getpid()); mem = atoi(argv[1]); array = malloc(mem); while (1) { for (int i = 0; i < mem; i++) { array[i] = 'b'; } } free(array); return 0; }
the_stack_data/176706062.c
#include <stdlib.h> float ** create_array(int n, int m) { float ** a = malloc(n * sizeof(float *)); float * a_ = malloc(n * m * sizeof(float)); int i, j; for (i = 0; i < n; i++) { a[i] = a_ + i * m; for (j = 0; j < m; j++) { a[i][j] = i+j; } } return a; } void free_array(float ** a) { free(a[0]); free(a); } void kernel_0(int n, int m, int p, int q, float ** a, float ** b, float ** c, float ** d) { int i, j, k; float ** e = create_array(n, q); #pragma tilek kernel data(a[0:n][0:p], b[0:p][0:q], c[0:q][0:m], d[0:n][0:m], e[0:n][0:q]) { #pragma tilek loop tile[0](dynamic) for (i = 0; i < n; i++) #pragma tilek loop tile[1](dynamic) for (j = 0; j < q; j++) { e[i][j] = 0; #pragma tilek loop tile[2](dynamic) for (k = 0; k < p; k++) e[i][j] += a[i][k] * b[k][j]; } #pragma tilek loop tile[0](dynamic) for (i = 0; i < n; i++) #pragma tilek loop tile[1](dynamic) for (j = 0; j < m; j++) { d[i][j] = 0; #pragma tilek loop tile[2](dynamic) for (k = 0; k < q; k++) d[i][j] += e[i][k] * c[k][j]; } } free_array(e); } void kernel_1(int n, int m, int p, int q, float ** a, float ** b, float ** c, float ** d) { int i, j, k; float ** e = create_array(n, q); #pragma tilek kernel data(a[0:n][0:p], b[0:p][0:q], c[0:q][0:m], d[0:n][0:m], e[0:n][0:q]) { #pragma tilek loop tile[0](dynamic) for (i = 0; i < n; i++) #pragma tilek loop tile[1](dynamic) for (j = 0; j < q; j++) { e[i][j] = 0; #pragma tilek loop tile[0](dynamic) for (k = 0; k < p; k++) e[i][j] += a[i][k] * b[k][j]; } #pragma tilek loop tile[0](dynamic) for (i = 0; i < n; i++) #pragma tilek loop tile[1](dynamic) for (j = 0; j < m; j++) { d[i][j] = 0; #pragma tilek loop tile[0](dynamic) for (k = 0; k < q; k++) d[i][j] += e[i][k] * c[k][j]; } } free_array(e); } void kernel_2(int n, int m, int p, int q, float ** a, float ** b, float ** c, float ** d) { int i, j, k; float ** e = create_array(n, q); #pragma tilek kernel data(a[0:n][0:p], b[0:p][0:q], c[0:q][0:m], d[0:n][0:m], e[0:n][0:q]) { #pragma tilek loop tile[10](dynamic) for (i = 0; i < n; i++) #pragma tilek loop tile[11](dynamic) for (j = 0; j < q; j++) { e[i][j] = 0; #pragma tilek loop tile[0](dynamic) for (k = 0; k < p; k++) e[i][j] += a[i][k] * b[k][j]; } #pragma tilek loop tile[0](dynamic) for (i = 0; i < n; i++) #pragma tilek loop tile[1](dynamic) for (j = 0; j < m; j++) { d[i][j] = 0; #pragma tilek loop tile[0](dynamic) for (k = 0; k < q; k++) d[i][j] += e[i][k] * c[k][j]; } } free_array(e); } void kernel_3(int n, int m, int p, int q, float ** a, float ** b, float ** c, float ** d) { int i, j, k; float ** e = create_array(n, q); #pragma tilek kernel data(a[0:n][0:p], b[0:p][0:q], c[0:q][0:m], d[0:n][0:m], e[0:n][0:q]) { #pragma tilek loop tile[1](dynamic) for (i = 0; i < n; i++) #pragma tilek loop tile[0](dynamic) for (j = 0; j < q; j++) { e[i][j] = 0; #pragma tilek loop tile[0](dynamic) for (k = 0; k < p; k++) e[i][j] += a[i][k] * b[k][j]; } #pragma tilek loop tile[1](dynamic) for (i = 0; i < n; i++) #pragma tilek loop tile[0](dynamic) for (j = 0; j < m; j++) { d[i][j] = 0; #pragma tilek loop tile[0](dynamic) for (k = 0; k < q; k++) d[i][j] += e[i][k] * c[k][j]; } } free_array(e); } void kernel_4(int n, int m, int p, int q, float ** a, float ** b, float ** c, float ** d) { int i, j, k; float ** e = create_array(n, q); #pragma tilek kernel data(a[0:n][0:p], b[0:p][0:q], c[0:q][0:m], d[0:n][0:m], e[0:n][0:q]) { #pragma tilek loop tile[0](dynamic) tile[2](static, 4) for (i = 0; i < n; i++) #pragma tilek loop tile[1](static, 4) tile[3](dynamic) for (j = 0; j < q; j++) { e[i][j] = 0; #pragma tilek loop tile[0](dynamic) for (k = 0; k < p; k++) e[i][j] += a[i][k] * b[k][j]; } #pragma tilek loop tile[0](dynamic) tile[2](static, 4) for (i = 0; i < n; i++) #pragma tilek loop tile[1](dynamic) tile[3](static, 4) for (j = 0; j < m; j++) { d[i][j] = 0; #pragma tilek loop tile[0](dynamic) for (k = 0; k < q; k++) d[i][j] += e[i][k] * c[k][j]; } } free_array(e); } int main() { const int n = 16; const int m = 16; const int p = 16; const int q = 16; float ** a; float ** b; float ** c; float ** d; { a = create_array(n, p); b = create_array(p, q); c = create_array(q, m); d = create_array(n, m); kernel_0(n, m, p, q, a, b, c, d); free_array(a); free_array(b); free_array(c); free_array(d); } { a = create_array(n, p); b = create_array(p, q); c = create_array(q, m); d = create_array(n, m); kernel_1(n, m, p, q, a, b, c, d); free_array(a); free_array(b); free_array(c); free_array(d); } { a = create_array(n, p); b = create_array(p, q); c = create_array(q, m); d = create_array(n, m); kernel_2(n, m, p, q, a, b, c, d); free_array(a); free_array(b); free_array(c); free_array(d); } { a = create_array(n, p); b = create_array(p, q); c = create_array(q, m); d = create_array(n, m); kernel_3(n, m, p, q, a, b, c, d); free_array(a); free_array(b); free_array(c); free_array(d); } { a = create_array(n, p); b = create_array(p, q); c = create_array(q, m); d = create_array(n, m); kernel_4(n, m, p, q, a, b, c, d); free_array(a); free_array(b); free_array(c); free_array(d); } return 0; }
the_stack_data/985304.c
/*** * This code is a part of EvoApproxLib library (ehw.fit.vutbr.cz/approxlib) distributed under The MIT License. * When used, please cite the following article(s): V. Mrazek, R. Hrbacek, Z. Vasicek and L. Sekanina, "EvoApprox8b: Library of approximate adders and multipliers for circuit design and benchmarking of approximation methods". Design, Automation & Test in Europe Conference & Exhibition (DATE), 2017, Lausanne, 2017, pp. 258-261. doi: 10.23919/DATE.2017.7926993 * This file contains a circuit from evoapprox8b dataset. Note that a new version of library was already published. ***/ #include <stdint.h> #include <stdlib.h> /// Approximate function add8_437 /// Library = EvoApprox8b /// Circuit = add8_437 /// Area (180) = 976 /// Delay (180) = 1.720 /// Power (180) = 349.60 /// Area (45) = 72 /// Delay (45) = 0.650 /// Power (45) = 33.72 /// Nodes = 10 /// HD = 0 /// MAE = 0.00000 /// MSE = 0.00000 /// MRE = 0.00 % /// WCE = 0 /// WCRE = 0 % /// EP = 0.0 % uint16_t add8_437(uint8_t a, uint8_t b) { uint16_t c = 0; uint8_t n0 = (a >> 0) & 0x1; uint8_t n2 = (a >> 1) & 0x1; uint8_t n4 = (a >> 2) & 0x1; uint8_t n6 = (a >> 3) & 0x1; uint8_t n8 = (a >> 4) & 0x1; uint8_t n10 = (a >> 5) & 0x1; uint8_t n12 = (a >> 6) & 0x1; uint8_t n14 = (a >> 7) & 0x1; uint8_t n16 = (b >> 0) & 0x1; uint8_t n18 = (b >> 1) & 0x1; uint8_t n20 = (b >> 2) & 0x1; uint8_t n22 = (b >> 3) & 0x1; uint8_t n24 = (b >> 4) & 0x1; uint8_t n26 = (b >> 5) & 0x1; uint8_t n28 = (b >> 6) & 0x1; uint8_t n30 = (b >> 7) & 0x1; uint8_t n32; uint8_t n50; uint8_t n76; uint8_t n82; uint8_t n83; uint8_t n132; uint8_t n133; uint8_t n182; uint8_t n183; uint8_t n232; uint8_t n233; uint8_t n282; uint8_t n283; uint8_t n332; uint8_t n333; uint8_t n382; uint8_t n383; n32 = n0 & n16; n50 = n32; n76 = n0 ^ n16; n82 = (n2 ^ n18) ^ n50; n83 = (n2 & n18) | (n18 & n50) | (n2 & n50); n132 = (n4 ^ n20) ^ n83; n133 = (n4 & n20) | (n20 & n83) | (n4 & n83); n182 = (n6 ^ n22) ^ n133; n183 = (n6 & n22) | (n22 & n133) | (n6 & n133); n232 = (n8 ^ n24) ^ n183; n233 = (n8 & n24) | (n24 & n183) | (n8 & n183); n282 = (n10 ^ n26) ^ n233; n283 = (n10 & n26) | (n26 & n233) | (n10 & n233); n332 = (n12 ^ n28) ^ n283; n333 = (n12 & n28) | (n28 & n283) | (n12 & n283); n382 = (n14 ^ n30) ^ n333; n383 = (n14 & n30) | (n30 & n333) | (n14 & n333); c |= (n76 & 0x1) << 0; c |= (n82 & 0x1) << 1; c |= (n132 & 0x1) << 2; c |= (n182 & 0x1) << 3; c |= (n232 & 0x1) << 4; c |= (n282 & 0x1) << 5; c |= (n332 & 0x1) << 6; c |= (n382 & 0x1) << 7; c |= (n383 & 0x1) << 8; return c; }
the_stack_data/19918.c
#include <stdio.h> int max(int a,int b){return (a>b)?a:b;} int min(int a,int b){return (a<b)?a:b;} int q,n; void Main(){ scanf("%d",&q); while(q--){ scanf("%d",&n); int l = -1e5, r = 1e5; int d = -1e5, u = 1e5; int x,y,f1,f2,f3,f4; for(int i = 0;i<n;i++) { scanf("%d%d%d%d%d%d",&x,&y,&f1,&f2,&f3,&f4); if(!f1) l = max(l,x); if(!f2) u = min(u,y); if(!f3) r = min(r,x); if(!f4) d = max(d,y); } if(l>r || u<d) puts("0"); else{ printf("1 %d %d\n",(l+r)/2, (d+u)/2); } } return ; } int main(){ Main(); return 0; }
the_stack_data/162639225.c
/* crypto/pkcs7/sign.c */ /* Copyright (C) 1995-1998 Eric Young ([email protected]) * All rights reserved. * * This package is an SSL implementation written * by Eric Young ([email protected]). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson ([email protected]). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * 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 copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young ([email protected])" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson ([email protected])" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 AUTHOR 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include <stdio.h> #include <string.h> #include <openssl/bio.h> #include <openssl/x509.h> #include <openssl/pem.h> #include <openssl/err.h> int main(argc,argv) int argc; char *argv[]; { X509 *x509; EVP_PKEY *pkey; PKCS7 *p7; PKCS7_SIGNER_INFO *si; BIO *in; BIO *data,*p7bio; char buf[1024*4]; int i; int nodetach=0; #ifndef OPENSSL_NO_MD2 EVP_add_digest(EVP_md2()); #endif #ifndef OPENSSL_NO_MD5 EVP_add_digest(EVP_md5()); #endif #ifndef OPENSSL_NO_SHA1 EVP_add_digest(EVP_sha1()); #endif #ifndef OPENSSL_NO_MDC2 EVP_add_digest(EVP_mdc2()); #endif data=BIO_new(BIO_s_file()); again: if (argc > 1) { if (strcmp(argv[1],"-nd") == 0) { nodetach=1; argv++; argc--; goto again; } if (!BIO_read_filename(data,argv[1])) goto err; } else BIO_set_fp(data,stdin,BIO_NOCLOSE); if ((in=BIO_new_file("server.pem","r")) == NULL) goto err; if ((x509=PEM_read_bio_X509(in,NULL,NULL,NULL)) == NULL) goto err; BIO_reset(in); if ((pkey=PEM_read_bio_PrivateKey(in,NULL,NULL,NULL)) == NULL) goto err; BIO_free(in); p7=PKCS7_new(); PKCS7_set_type(p7,NID_pkcs7_signed); si=PKCS7_add_signature(p7,x509,pkey,EVP_sha1()); if (si == NULL) goto err; /* If you do this then you get signing time automatically added */ PKCS7_add_signed_attribute(si, NID_pkcs9_contentType, V_ASN1_OBJECT, OBJ_nid2obj(NID_pkcs7_data)); /* we may want to add more */ PKCS7_add_certificate(p7,x509); /* Set the content of the signed to 'data' */ PKCS7_content_new(p7,NID_pkcs7_data); if (!nodetach) PKCS7_set_detached(p7,1); if ((p7bio=PKCS7_dataInit(p7,NULL)) == NULL) goto err; for (;;) { i=BIO_read(data,buf,sizeof(buf)); if (i <= 0) break; BIO_write(p7bio,buf,i); } if (!PKCS7_dataFinal(p7,p7bio)) goto err; BIO_free(p7bio); PEM_write_PKCS7(stdout,p7); PKCS7_free(p7); exit(0); err: ERR_load_crypto_strings(); ERR_print_errors_fp(stderr); exit(1); }
the_stack_data/57794.c
#include <quadmath.h> #include <stdio.h> int main(void) { __float128 f = 1.23456; char buf[128]; snprintf(buf, 128, "%g", f); printf("snprintf=%s\n", buf); quadmath_snprintf(buf, 128, "%Qg", f); printf("snprintf=%s\n", buf); return 0; }
the_stack_data/170454071.c
/* Write a function reverse(s) that reverses the character string s. Use it to * write a program that reverses its input a line at a time. */ #include <stdio.h> #define SIZE 1000 /* maximum input line size */ int get_line_size(char buffer[], int size); void reverse(char buffer[]); int main() { int size; /* current line size */ char line[SIZE]; /* current input line */ while ((size = get_line_size(line, SIZE)) > 0) { reverse(line); printf("%s", line); } return 0; } /* get_line_size: read a line into buffer, return size */ int get_line_size(char buffer[], int size) { int input, index; for (index = 0; index < size - 1 && (input = getchar()) != EOF && input != '\n'; index++) { buffer[index] = input; } if (input == '\n') { buffer[index++] = input; } buffer[index] = '\0'; return index; } /* reverse: read a line into buffer, reverse its content */ void reverse(char buffer[]) { int index = 0, size; while ((buffer[index] != '\n') && (buffer[index] != '\0')) { index++; } index--; if (index > 0) { size = index; while (index > (size / 2)) { int origin = buffer[size - index]; buffer[size - index] = buffer[index]; buffer[index] = origin; index--; } } if (buffer[++size] == '\0') { buffer[size] = '\n'; buffer[++size] = '\0'; } }
the_stack_data/557985.c
/* * Copyright (c) 1998,2001 * Traakan, Inc., Los Altos, CA * 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 unmodified, 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 AUTHOR 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 AUTHOR 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. */ /* * Project: NDMJOB * Ident: $Id: $ * * Description: * This contains code fragments common between the * O/S (Operating System) portions of NDMJOBLIB. * * This file is #include'd by the O/S specific ndmos_*.c * file, and fragments are selected by #ifdef's. * * There are four major portions: * 1) Misc support routines: password check, local info, etc * 2) Non-blocking I/O support routines * 3) Tape interfacs ndmos_tape_xxx() * 4) OS Specific NDMP request dispatcher which intercepts * requests implemented here, such as SCSI operations * and system configuration queries. */ /* * CONFIG SUPPORT **************************************************************** */ #ifdef NDMOS_COMMON_SYNC_CONFIG_INFO /* * Get local info. Supports NDMPx_CONFIG_GET_HOST_INFO, * NDMP3_CONFIG_GET_SERVER_INFO, and NDMPx_CONFIG_GET_SCSI_INFO. */ void ndmos_sync_config_info (struct ndm_session *sess) { static struct utsname unam; static char osbuf[100]; static char idbuf[30]; static char revbuf[100]; char obuf[5]; if (sess->config_info.hostname) { /* already set */ return; } obuf[0] = (char)(NDMOS_ID >> 24); obuf[1] = (char)(NDMOS_ID >> 16); obuf[2] = (char)(NDMOS_ID >> 8); obuf[3] = (char)(NDMOS_ID >> 0); obuf[4] = 0; uname (&unam); sprintf (idbuf, "%lu", gethostid()); /* * give CONTROL via NDMPv2 a chance to recognize this * implementation (no ndmp2_config_get_server). */ sprintf (osbuf, "%s (running %s from %s)", unam.sysname, NDMOS_CONST_PRODUCT_NAME, NDMOS_CONST_VENDOR_NAME); sess->config_info.hostname = unam.nodename; sess->config_info.os_type = osbuf; sess->config_info.os_vers = unam.release; sess->config_info.hostid = idbuf; sess->config_info.vendor_name = NDMOS_CONST_VENDOR_NAME; sess->config_info.product_name = NDMOS_CONST_PRODUCT_NAME; sprintf (revbuf, "%s LIB:%d.%d/%s OS:%s (%s)", NDMOS_CONST_PRODUCT_REVISION, NDMJOBLIB_VERSION, NDMJOBLIB_RELEASE, NDMOS_CONST_NDMJOBLIB_REVISION, NDMOS_CONST_NDMOS_REVISION, obuf); sess->config_info.revision_number = revbuf; /* best effort; note that this loads scsi and tape config */ ndmcfg_load (sess->param.config_file_name, &sess->config_info); } #endif /* NDMOS_COMMON_SYNC_CONFIG_INFO */ /* * AUTHENTICATION SUPPORT **************************************************************** */ #ifdef NDMOS_COMMON_OK_NAME_PASSWORD /* * Determine whether the clear-text account name and password * are valid. Supports NDMPx_CONNECT_CLIENT_AUTH requests. */ int ndmos_ok_name_password (struct ndm_session *sess, char *name, char *pass) { if (strcmp (name, "ndmp") != 0) return 0; if (strcmp (pass, "ndmp") != 0) return 0; return 1; /* OK */ } #endif /* NDMOS_COMMON_OK_NAME_PASSWORD */ #ifdef NDMOS_COMMON_MD5 /* * MD5 authentication support * * See ndml_md5.c */ int ndmos_get_md5_challenge (struct ndm_session *sess) { ndmmd5_generate_challenge (sess->md5_challenge); sess->md5_challenge_valid = 1; return 0; } int ndmos_ok_name_md5_digest (struct ndm_session *sess, char *name, char digest[16]) { if (strcmp (name, "ndmp") != 0) return 0; if (!ndmmd5_ok_digest (sess->md5_challenge, "ndmp", digest)) return 0; return 1; /* OK */ } #endif /* NDMOS_COMMON_MD5 */ #ifdef NDMOS_COMMON_NONBLOCKING_IO_SUPPORT /* * NON-BLOCKING I/O SUPPORT **************************************************************** * As support non-blocking I/O for NDMCHAN, condition different * types of file descriptors to not block. */ void ndmos_condition_listen_socket (struct ndm_session *sess, int sock) { int flag; flag = 1; setsockopt (sock, SOL_SOCKET, SO_REUSEADDR, (void*)&flag, sizeof flag); } void ndmos_condition_control_socket (struct ndm_session *sess, int sock) { /* nothing */ } void ndmos_condition_image_stream_socket (struct ndm_session *sess, int sock) { fcntl (sock, F_SETFL, O_NONBLOCK); signal (SIGPIPE, SIG_IGN); } void ndmos_condition_pipe_fd (struct ndm_session *sess, int fd) { fcntl (fd, F_SETFL, O_NONBLOCK); signal (SIGPIPE, SIG_IGN); } #endif /* NDMOS_COMMON_NONBLOCKING_IO_SUPPORT */ #ifdef NDMOS_COMMON_TAPE_INTERFACE #ifndef NDMOS_OPTION_NO_TAPE_AGENT #ifndef NDMOS_OPTION_TAPE_SIMULATOR /* * TAPE INTERFACE **************************************************************** * These interface to the O/S specific tape drivers and subsystem. * They must result in functionality equivalent to the reference * tape simulator. The NDMP TAPE model is demanding, and it is * often necessary to workaround the native device driver(s) * to achieve NDMP TAPE model conformance. * * It's easy to test this ndmos_tape_xxx() implementation * using the ndmjob(1) command in test-tape conformance mode. * The tape simulator passes this test. To test this implementation, * rebuild ndmjob, then use this command: * * ndmjob -o test-tape -T. -f /dev/whatever * * These ndmos_tape_xxx() interfaces must maintain the tape state * (sess->tape_agent.tape_state). In particular, the position * information (file_num and blockno) must be accurate at all * times. A typical workaround is to maintain these here rather * than relying on the native device drivers. Another workaround * is to implement NDMP MTIO operations using repeated native MTIO * operations with count=1, then interpret the results and errors * to maintain accurate position and residual information. * * Workarounds in this implementation (please keep this updated): * */ int ndmos_tape_initialize (struct ndm_session *sess) { return -1; } void ndmos_tape_sync_state (struct ndm_session *sess) { the_tape_state.error = NDMP9_DEV_NOT_OPEN_ERR; } ndmp9_error ndmos_tape_open (struct ndm_session *sess, char *name, int will_write) { return NDMP9_NOT_SUPPORTED_ERR; } ndmp9_error ndmos_tape_close (struct ndm_session *sess) { return NDMP9_NOT_SUPPORTED_ERR; } ndmp9_error ndmos_tape_write (struct ndm_session *sess, char *data, unsigned long count, unsigned long * done_count) { return NDMP9_NOT_SUPPORTED_ERR; } ndmp9_error ndmos_tape_read (struct ndm_session *sess, char *data, unsigned long count, unsigned long * done_count) { return NDMP9_NOT_SUPPORTED_ERR; } ndmp9_error ndmos_tape_mtio (struct ndm_session *sess, ndmp9_tape_mtio_op op, unsigned long count, unsigned long * done_count) { return NDMP9_NOT_SUPPORTED_ERR; } ndmp9_error ndmos_tape_execute_cdb (struct ndm_session *sess, ndmp9_execute_cdb_request *request, ndmp9_execute_cdb_reply *reply) { return NDMP9_NOT_SUPPORTED_ERR; } #endif /* !NDMOS_OPTION_TAPE_SIMULATOR */ #else /* !NDMOS_OPTION_NO_TAPE_AGENT */ /* tape interfaces implemented in ndma_tape_simulator.c */ #endif /* !NDMOS_OPTION_NO_TAPE_AGENT */ #endif /* NDMOS_COMMON_TAPE_INTERFACE */ #ifdef NDMOS_COMMON_ROBOT_INTERFACE #ifndef NDMOS_OPTION_NO_ROBOT_AGENT #ifndef NDMOS_OPTION_ROBOT_SIMULATOR /* ndmos_robot_* functions here */ #endif /* !NDMOS_OPTION_ROBOT_SIMULATOR */ #else /* !NDMOS_OPTION_NO_ROBOT_AGENT */ /* robot interfaces implemented in ndma_robot_simulator.c */ #endif /* !NDMOS_OPTION_NO_ROBOT_AGENT */ #endif /* NDMOS_COMMON_ROBOT_INTERFACE */ #ifdef NDMOS_COMMON_SCSI_INTERFACE #ifndef NDMOS_OPTION_NO_ROBOT_AGENT /* Surrounds all SCSI intfs */ #ifndef NDMOS_OPTION_ROBOT_SIMULATOR /* * SCSI INTERFACE **************************************************************** */ int ndmos_scsi_initialize (struct ndm_session *sess) { return -1; } void ndmos_scsi_sync_state (struct ndm_session *sess) { sess->robot_acb.scsi_state.error = NDMP9_DEV_NOT_OPEN_ERR; } ndmp9_error ndmos_scsi_open (struct ndm_session *sess, char *name) { return NDMP9_NOT_SUPPORTED_ERR; } ndmp9_error ndmos_scsi_close (struct ndm_session *sess) { return NDMP9_NOT_SUPPORTED_ERR; } /* deprecated */ ndmp9_error ndmos_scsi_set_target (struct ndm_session *sess) { return NDMP9_NOT_SUPPORTED_ERR; } ndmp9_error ndmos_scsi_reset_device (struct ndm_session *sess) { return NDMP9_NOT_SUPPORTED_ERR; } /* deprecated */ ndmp9_error ndmos_scsi_reset_bus (struct ndm_session *sess) { return NDMP9_NOT_SUPPORTED_ERR; } ndmp9_error ndmos_scsi_execute_cdb (struct ndm_session *sess, ndmp9_execute_cdb_request *request, ndmp9_execute_cdb_reply *reply) { return NDMP9_NOT_SUPPORTED_ERR; } #endif /* NDMOS_OPTION_ROBOT_SIMULATOR */ #endif /* NDMOS_OPTION_NO_ROBOT_AGENT Surrounds all SCSI intfs */ #endif /* NDMOS_COMMON_SCSI_INTERFACE */ #ifdef NDMOS_COMMON_DISPATCH_REQUEST /* * ndmos_dispatch_request() -- O/S Specific Agent Dispatch Request (ADR) **************************************************************** * Some NDMP requests can only be handled as O/S specific portions, * and are implemented here. * * The more generic NDMP requests may be re-implemented here rather * than modifying the main body of code. Extensions to the NDMP protocol * may also be implemented here. Neither is ever a good idea beyond * experimentation. The structures in ndmagents.h provide for O/S * specific extensions. Such extensions are #define'd in the ndmos_xxx.h. * * The return value from ndmos_dispatch_request() tells the main * dispatcher, ndma_dispatch_request(), whether or not the request * was intercepted. ndmos_dispatch_request() is called after basic * reply setup is done (message headers and buffers), but before * the request is interpretted. */ #ifndef I_HAVE_DISPATCH_REQUEST /* * If we're not intercepting, keep it simple */ int ndmos_dispatch_request (struct ndm_session *sess, struct ndmp_xa_buf *xa, struct ndmconn *ref_conn) { return -1; /* not intercepted */ } #else /* !I_HAVE_DISPATCH_REQUEST */ /* * The following fragment is here for reference. * If the O/S module intercepts requests, copy * all this into the module source file and * #undef NDMOS_COMMON_DISPATCH_REQUEST. */ extern struct ndm_dispatch_version_table ndmos_dispatch_version_table[]; int ndmos_dispatch_request (struct ndm_session *sess, struct ndmp_xa_buf *xa, struct ndmconn *ref_conn) { struct ndm_dispatch_request_table *drt; unsigned protocol_version = ref_conn->protocol_version; unsigned msg = xa->request.header.message; int rc; drt = ndma_drt_lookup (ndmos_dispatch_version_table, protocol_version, msg); if (!drt) { return -1; /* not intercepted */ } /* * Replicate the ndma_dispatch_request() permission checks */ if (!sess->conn_open && !(drt->flags & NDM_DRT_FLAG_OK_NOT_CONNECTED)) { xa->reply.header.error = NDMP0_PERMISSION_ERR; return 0; } if (!sess->conn_authorized && !(drt->flags & NDM_DRT_FLAG_OK_NOT_AUTHORIZED)) { xa->reply.header.error = NDMP9_NOT_AUTHORIZED_ERR; return 0; } rc = (*drt->dispatch_request)(sess, xa, ref_conn); if (rc < 0) { xa->reply.header.error = NDMP0_NOT_SUPPORTED_ERR; } return 0; } /* * Dispatch Version Table and Dispatch Request Tables (DVT/DRT) **************************************************************** */ struct ndm_dispatch_request_table ndmos_dispatch_request_table_v0[] = { {0} }; #ifndef NDMOS_OPTION_NO_NDMP2 struct ndm_dispatch_request_table ndmos_dispatch_request_table_v2[] = { {0} }; #endif /* !NDMOS_OPTION_NO_NDMP2 */ #ifndef NDMOS_OPTION_NO_NDMP3 struct ndm_dispatch_request_table ndmos_dispatch_request_table_v3[] = { {0} }; #endif /* !NDMOS_OPTION_NO_NDMP3 */ #ifndef NDMOS_OPTION_NO_NDMP4 struct ndm_dispatch_request_table ndmos_dispatch_request_table_v4[] = { {0} }; #endif /* !NDMOS_OPTION_NO_NDMP4 */ struct ndm_dispatch_version_table ndmos_dispatch_version_table[] = { { 0, ndmos_dispatch_request_table_v0 }, #ifndef NDMOS_OPTION_NO_NDMP2 { NDMP2VER, ndmos_dispatch_request_table_v2 }, #endif /* !NDMOS_OPTION_NO_NDMP2 */ #ifndef NDMOS_OPTION_NO_NDMP3 { NDMP3VER, ndmos_dispatch_request_table_v3 }, #endif /* !NDMOS_OPTION_NO_NDMP2 */ #ifndef NDMOS_OPTION_NO_NDMP4 { NDMP4VER, ndmos_dispatch_request_table_v4 }, #endif /* !NDMOS_OPTION_NO_NDMP4 */ { -1 } }; #endif /* !I_HAVE_DISPATCH_REQUEST */ #endif /* NDMOS_COMMON_DISPATCH_REQUEST */
the_stack_data/150233.c
#include <stdio.h> #include <stdlib.h> struct TreeNode { int val; struct TreeNode *left; struct TreeNode *right; }; void queueTraverse(struct TreeNode* node) { if (node == NULL) return; struct TreeNode* nodes[100]; int start = 0, stop = 0; nodes[0] = node; stop++; while (start < stop) { node = nodes[start++]; if (node == NULL) { printf("NULL "); } else { printf("%d ", node->val); if (node->left || node->right) { nodes[stop++] = node->left; nodes[stop++] = node->right; } } } printf("\n"); } // -------- struct TreeNode* bstFromPreorder(int* preorder, int preorderSize) { struct TreeNode* root = malloc(sizeof(struct TreeNode)); root->val = preorder[0]; root->left = root->right = NULL; struct TreeNode* path[100]; int topIndex = 0; path[topIndex] = root; for (int i = 1; i < preorderSize; i++) { struct TreeNode* node = malloc(sizeof(struct TreeNode)); node->val = preorder[i]; node->left = node->right = NULL; if (preorder[i] < path[topIndex]->val) { path[topIndex]->left = node; topIndex++; path[topIndex] = node; } else { while (topIndex-1 >= 0 && path[topIndex-1]->val < preorder[i]) { topIndex--; } if (topIndex-1 >= 0) { path[topIndex]->right = node; path[topIndex] = node; } else { path[0]->right = node; path[0] = node; } } } return root; } int main() { /* 8 / \ 5 10 / \ \ 1 7 12 */ int arr[] = {8, 5, 1, 7, 10, 12}; struct TreeNode* root = bstFromPreorder(arr, 6); queueTraverse(root); return 0; }
the_stack_data/58782.c
#include <stdio.h> #include <stdlib.h> int main(int argc, char **argv) { char s[128]; scanf("%[^\n]", s); printf("%s\n", s); return 0; }
the_stack_data/76701136.c
#include <stdio.h> #include <memory.h> #include <stdlib.h> #define SIZE_CHAR sizeof(char) char *createTriangle(int n) { const int MAX_WIDTH = 2 * n - 1; char *triangle = malloc(((n + 1) * MAX_WIDTH + 1) * SIZE_CHAR); int index = 0; for (int depth = 1; depth <= n; ++depth) { const int CURRENT_WIDTH = 2 * depth - 1; for (int spaceWidth = 0; spaceWidth < (MAX_WIDTH - CURRENT_WIDTH) / 2; ++spaceWidth) { triangle[index] = ' '; ++index; } for (int stars = 0; stars < CURRENT_WIDTH; ++stars) { triangle[index] = '*'; ++index; } for (int spaces = 0; spaces < (MAX_WIDTH - CURRENT_WIDTH) / 2; ++spaces) { triangle[index] = ' '; ++index; } triangle[index] = '\n'; ++index; } triangle[index] = '\0'; return triangle; } int main(int argc, char *argv[]) { printf("%s", createTriangle(atoi(argv[1]))); return 0; }
the_stack_data/219014.c
// // Sample Code: // #include <stdio.h> #include <stdlib.h> #include <string.h> void pre_Initializing_Input_Tensors(); void post_Correctness(); int main(int argc, char** argv) { // for sd2 double *host_t3, *host_t3_chk; double *host_t2_1, *host_t2_2, *host_t2_3, *host_t2_4, *host_t2_5, *host_t2_6, *host_t2_7, *host_t2_8, *host_t2_9; double *host_v2_1, *host_v2_2, *host_v2_3, *host_v2_4, *host_v2_5, *host_v2_6, *host_v2_7, *host_v2_8, *host_v2_9; int size_h3, size_h2, size_h1, size_p6, size_p5, size_p4, size_h7; int opt_register_transpose; // Problem Size size_h3 = 16; size_h2 = 16; size_h1 = 16; size_p6 = 16; size_p5 = 16; size_p4 = 16; size_h7 = 16; opt_register_transpose = 1; // if (argc == 9) { size_h3 = atoi(argv[1]); size_h2 = atoi(argv[2]); size_h1 = atoi(argv[3]); size_p6 = atoi(argv[4]); size_p5 = atoi(argv[5]); size_p4 = atoi(argv[6]); size_h7 = atoi(argv[7]); opt_register_transpose = atoi(argv[8]); } printf (">>> Problem Size (h3,h2,h1,p6,p5,p4) and (h7): (%2d,%2d,%2d,%2d,%2d,%2d) and (%2d)\n", size_h3, size_h2, size_h1, size_p6, size_p5, size_p4, size_h7); printf (">>> Option for Register Transpose: %2d\n", opt_register_transpose); int size_T3; int size_T2_1, size_T2_2, size_T2_3, size_T2_4, size_T2_5, size_T2_6, size_T2_7, size_T2_8, size_T2_9; int size_V2_1, size_V2_2, size_V2_3, size_V2_4, size_V2_5, size_V2_6, size_V2_7, size_V2_8, size_V2_9; int size_internal; // size_internal = size_h7; size_T3 = size_h3 * size_h2 * size_h1 * size_p6 * size_p5 * size_p4; /* >> sd1 << 1: t3 [h3,16,h2,16,h1,16,p6,16,p5,16,p4,16] -= sum(h7,16) * t2_1 [h7,p4,p5,h1] * v2_1 [h3,h2,p6,h7]; 2: t3 [h3,16,h2,16,h1,16,p6,16,p5,16,p4,16] += sum(h7,16) * t2_2 [h7,p4,p5,h2] * v2_2 [h3,h1,p6,h7]; 3: t3 [h3,16,h2,16,h1,16,p6,16,p5,16,p4,16] -= sum(h7,16) * t2_3 [h7,p4,p5,h3] * v2_3 [h2,h1,p6,h7]; 4: t3 [h3,16,h2,16,h1,16,p6,16,p5,16,p4,16] -= sum(h7,16) * t2_4 [h7,p5,p6,h1] * v2_4 [h3,h2,p4,h7]; 5: t3 [h3,16,h2,16,h1,16,p6,16,p5,16,p4,16] += sum(h7,16) * t2_5 [h7,p5,p6,h2] * v2_5 [h3,h1,p4,h7]; 6: t3 [h3,16,h2,16,h1,16,p6,16,p5,16,p4,16] -= sum(h7,16) * t2_6 [h7,p5,p6,h3] * v2_6 [h2,h1,p4,h7]; 7: t3 [h3,16,h2,16,h1,16,p6,16,p5,16,p4,16] += sum(h7,16) * t2_7 [h7,p4,p6,h1] * v2_7 [h3,h2,p5,h7]; 8: t3 [h3,16,h2,16,h1,16,p6,16,p5,16,p4,16] -= sum(h7,16) * t2_8 [h7,p4,p6,h2] * v2_8 [h3,h1,p5,h7]; 9: t3 [h3,16,h2,16,h1,16,p6,16,p5,16,p4,16] += sum(h7,16) * t2_8 [h7,p4,p6,h3] * v2_9 [h2,h1,p5,h7]; */ // size_T2_1 = size_h7 * size_p4 * size_p5 * size_h1; size_V2_1 = size_h3 * size_h2 * size_p6 * size_h7; size_T2_2 = size_h7 * size_p4 * size_p5 * size_h2; size_V2_2 = size_h3 * size_h1 * size_p6 * size_h7; size_T2_3 = size_h7 * size_p4 * size_p5 * size_h3; size_V2_3 = size_h2 * size_h1 * size_p6 * size_h7; size_T2_4 = size_h7 * size_p5 * size_p6 * size_h1; size_V2_4 = size_h3 * size_h2 * size_p4 * size_h7; size_T2_5 = size_h7 * size_p5 * size_p6 * size_h2; size_V2_5 = size_h3 * size_h1 * size_p4 * size_h7; size_T2_6 = size_h7 * size_p5 * size_p6 * size_h3; size_V2_6 = size_h2 * size_h1 * size_p4 * size_h7; size_T2_7 = size_h7 * size_p4 * size_p6 * size_h1; size_V2_7 = size_h3 * size_h2 * size_p5 * size_h7; size_T2_8 = size_h7 * size_p4 * size_p6 * size_h2; size_V2_8 = size_h3 * size_h1 * size_p5 * size_h7; size_T2_9 = size_h7 * size_p4 * size_p6 * size_h3; size_V2_9 = size_h2 * size_h1 * size_p5 * size_h7; host_t3 = (double*)malloc(sizeof(double) * size_T3); host_t3_chk = (double*)malloc(sizeof(double) * size_T3); host_t2_1 = (double*)malloc(sizeof(double) * size_T2_1); host_t2_2 = (double*)malloc(sizeof(double) * size_T2_2); host_t2_3 = (double*)malloc(sizeof(double) * size_T2_3); host_t2_4 = (double*)malloc(sizeof(double) * size_T2_4); host_t2_5 = (double*)malloc(sizeof(double) * size_T2_5); host_t2_6 = (double*)malloc(sizeof(double) * size_T2_6); host_t2_7 = (double*)malloc(sizeof(double) * size_T2_7); host_t2_8 = (double*)malloc(sizeof(double) * size_T2_8); host_t2_9 = (double*)malloc(sizeof(double) * size_T2_9); host_v2_1 = (double*)malloc(sizeof(double) * size_V2_1); host_v2_2 = (double*)malloc(sizeof(double) * size_V2_2); host_v2_3 = (double*)malloc(sizeof(double) * size_V2_3); host_v2_4 = (double*)malloc(sizeof(double) * size_V2_4); host_v2_5 = (double*)malloc(sizeof(double) * size_V2_5); host_v2_6 = (double*)malloc(sizeof(double) * size_V2_6); host_v2_7 = (double*)malloc(sizeof(double) * size_V2_7); host_v2_8 = (double*)malloc(sizeof(double) * size_V2_8); host_v2_9 = (double*)malloc(sizeof(double) * size_V2_9); printf ("==========================================================================================================\n"); printf (" >>> %s <<<\n", __func__); printf (" T3: %'12d\n", size_T3); printf (" T2_1: %'12d, V2_1: %'12d\n", size_T2_1, size_V2_1); printf (" T2_2: %'12d, V2_2: %'12d\n", size_T2_2, size_V2_2); printf (" T2_3: %'12d, V2_3: %'12d\n", size_T2_3, size_V2_3); printf (" T2_4: %'12d, V2_4: %'12d\n", size_T2_4, size_V2_4); printf (" T2_5: %'12d, V2_5: %'12d\n", size_T2_5, size_V2_5); printf (" T2_6: %'12d, V2_6: %'12d\n", size_T2_6, size_V2_6); printf (" T2_7: %'12d, V2_7: %'12d\n", size_T2_7, size_V2_7); printf (" T2_8: %'12d, V2_8: %'12d\n", size_T2_8, size_V2_8); printf (" T2_9: %'12d, V2_9: %'12d\n", size_T2_9, size_V2_9); printf ("==========================================================================================================\n"); // // Initialze "1" Output and "2 x 9" Inputs pre_Initializing_Input_Tensors(host_t3, host_t3_chk, host_t2_1, host_v2_1, host_t2_2, host_v2_2, host_t2_3, host_v2_3, host_t2_4, host_v2_4, host_t2_5, host_v2_5, host_t2_6, host_v2_6, host_t2_7, host_v2_7, host_t2_8, host_v2_8, host_t2_9, host_v2_9, size_h3, size_h2, size_h1, size_p6, size_p5, size_p4, size_h7); // Run the Kernels sd_t_d2_fusion_(size_h3, size_h2, size_h1, size_p6, size_p5, size_p4, size_h7, host_t3, host_t2_4, host_v2_4, 1, opt_register_transpose); // Correctness-Check post_Correctness(host_t3, host_t3_chk, host_t2_1, host_v2_1, host_t2_2, host_v2_2, host_t2_3, host_v2_3, host_t2_4, host_v2_4, host_t2_5, host_v2_5, host_t2_6, host_v2_6, host_t2_7, host_v2_7, host_t2_8, host_v2_8, host_t2_9, host_v2_9, 1, 1, 1, 1, 1, 1, 1, 1, 1, size_h3, size_h2, size_h1, size_p6, size_p5, size_p4, size_h7); // Free free(host_t3); free(host_t3_chk); free(host_t2_1); free(host_t2_2); free(host_t2_3); free(host_t2_4); free(host_t2_5); free(host_t2_6); free(host_t2_7); free(host_t2_8); free(host_t2_9); free(host_v2_1); free(host_v2_2); free(host_v2_3); free(host_v2_4); free(host_v2_5); free(host_v2_6); free(host_v2_7); free(host_v2_8); free(host_v2_9); return 0; } // Initialize t3 (t3_temp), 9 t2 and 9 v2. void pre_Initializing_Input_Tensors(double* h_t3, double* h_t3_chk, double* h_t2_1, double* h_v2_1, double* h_t2_2, double* h_v2_2, double* h_t2_3, double* h_v2_3, double* h_t2_4, double* h_v2_4, double* h_t2_5, double* h_v2_5, double* h_t2_6, double* h_v2_6, double* h_t2_7, double* h_v2_7, double* h_t2_8, double* h_v2_8, double* h_t2_9, double* h_v2_9, int size_idx_h3, int size_idx_h2, int size_idx_h1, int size_idx_p6, int size_idx_p5, int size_idx_p4, int size_idx_h7) { int size_T3; int size_T2_1, size_T2_2, size_T2_3, size_T2_4, size_T2_5, size_T2_6, size_T2_7, size_T2_8, size_T2_9; int size_V2_1, size_V2_2, size_V2_3, size_V2_4, size_V2_5, size_V2_6, size_V2_7, size_V2_8, size_V2_9; int size_internal; // size_internal = size_idx_h7; size_T3 = size_idx_h3 * size_idx_h2 * size_idx_h1 * size_idx_p6 * size_idx_p5 * size_idx_p4; /* >> sd1 << 1: t3 [h3,16,h2,16,h1,16,p6,16,p5,16,p4,16] -= sum(h7,16) * t2_1 [h7,p4,p5,h1] * v2_1 [h3,h2,p6,h7]; 2: t3 [h3,16,h2,16,h1,16,p6,16,p5,16,p4,16] += sum(h7,16) * t2_2 [h7,p4,p5,h2] * v2_2 [h3,h1,p6,h7]; 3: t3 [h3,16,h2,16,h1,16,p6,16,p5,16,p4,16] -= sum(h7,16) * t2_3 [h7,p4,p5,h3] * v2_3 [h2,h1,p6,h7]; 4: t3 [h3,16,h2,16,h1,16,p6,16,p5,16,p4,16] -= sum(h7,16) * t2_4 [h7,p5,p6,h1] * v2_4 [h3,h2,p4,h7]; 5: t3 [h3,16,h2,16,h1,16,p6,16,p5,16,p4,16] += sum(h7,16) * t2_5 [h7,p5,p6,h2] * v2_5 [h3,h1,p4,h7]; 6: t3 [h3,16,h2,16,h1,16,p6,16,p5,16,p4,16] -= sum(h7,16) * t2_6 [h7,p5,p6,h3] * v2_6 [h2,h1,p4,h7]; 7: t3 [h3,16,h2,16,h1,16,p6,16,p5,16,p4,16] += sum(h7,16) * t2_7 [h7,p4,p6,h1] * v2_7 [h3,h2,p5,h7]; 8: t3 [h3,16,h2,16,h1,16,p6,16,p5,16,p4,16] -= sum(h7,16) * t2_8 [h7,p4,p6,h2] * v2_8 [h3,h1,p5,h7]; 9: t3 [h3,16,h2,16,h1,16,p6,16,p5,16,p4,16] += sum(h7,16) * t2_8 [h7,p4,p6,h3] * v2_9 [h2,h1,p5,h7]; */ // size_T2_1 = size_idx_h7 * size_idx_p4 * size_idx_p5 * size_idx_h1; size_V2_1 = size_idx_h3 * size_idx_h2 * size_idx_p6 * size_idx_h7; size_T2_2 = size_idx_h7 * size_idx_p4 * size_idx_p5 * size_idx_h2; size_V2_2 = size_idx_h3 * size_idx_h1 * size_idx_p6 * size_idx_h7; size_T2_3 = size_idx_h7 * size_idx_p4 * size_idx_p5 * size_idx_h3; size_V2_3 = size_idx_h2 * size_idx_h1 * size_idx_p6 * size_idx_h7; size_T2_4 = size_idx_h7 * size_idx_p5 * size_idx_p6 * size_idx_h1; size_V2_4 = size_idx_h3 * size_idx_h2 * size_idx_p4 * size_idx_h7; size_T2_5 = size_idx_h7 * size_idx_p5 * size_idx_p6 * size_idx_h2; size_V2_5 = size_idx_h3 * size_idx_h1 * size_idx_p4 * size_idx_h7; size_T2_6 = size_idx_h7 * size_idx_p5 * size_idx_p6 * size_idx_h3; size_V2_6 = size_idx_h2 * size_idx_h1 * size_idx_p4 * size_idx_h7; size_T2_7 = size_idx_h7 * size_idx_p4 * size_idx_p6 * size_idx_h1; size_V2_7 = size_idx_h3 * size_idx_h2 * size_idx_p5 * size_idx_h7; size_T2_8 = size_idx_h7 * size_idx_p4 * size_idx_p6 * size_idx_h2; size_V2_8 = size_idx_h3 * size_idx_h1 * size_idx_p5 * size_idx_h7; size_T2_9 = size_idx_h7 * size_idx_p4 * size_idx_p6 * size_idx_h3; size_V2_9 = size_idx_h2 * size_idx_h1 * size_idx_p5 * size_idx_h7; // t3 int i, j; for (i = 0; i < size_T3; i++) { h_t3[i] = 0.0; h_t3_chk[i] = 0.0; } for (j = 0; j < size_T2_1; j++) { h_t2_1[j] = ((double)rand() / RAND_MAX); } for (j = 0; j < size_V2_1; j++) { h_v2_1[j] = ((double)rand() / RAND_MAX); } for (j = 0; j < size_T2_2; j++) { h_t2_2[j] = ((double)rand() / RAND_MAX); } for (j = 0; j < size_V2_2; j++) { h_v2_2[j] = ((double)rand() / RAND_MAX); } for (j = 0; j < size_T2_3; j++) { h_t2_3[j] = ((double)rand() / RAND_MAX); } for (j = 0; j < size_V2_3; j++) { h_v2_3[j] = ((double)rand() / RAND_MAX); } for (j = 0; j < size_T2_4; j++) { h_t2_4[j] = ((double)rand() / RAND_MAX); } for (j = 0; j < size_V2_4; j++) { h_v2_4[j] = ((double)rand() / RAND_MAX); } for (j = 0; j < size_T2_5; j++) { h_t2_5[j] = ((double)rand() / RAND_MAX); } for (j = 0; j < size_V2_5; j++) { h_v2_5[j] = ((double)rand() / RAND_MAX); } for (j = 0; j < size_T2_6; j++) { h_t2_6[j] = ((double)rand() / RAND_MAX); } for (j = 0; j < size_V2_6; j++) { h_v2_6[j] = ((double)rand() / RAND_MAX); } for (j = 0; j < size_T2_7; j++) { h_t2_7[j] = ((double)rand() / RAND_MAX); } for (j = 0; j < size_V2_7; j++) { h_v2_7[j] = ((double)rand() / RAND_MAX); } for (j = 0; j < size_T2_8; j++) { h_t2_8[j] = ((double)rand() / RAND_MAX); } for (j = 0; j < size_V2_8; j++) { h_v2_8[j] = ((double)rand() / RAND_MAX); } for (j = 0; j < size_T2_9; j++) { h_t2_9[j] = ((double)rand() / RAND_MAX); } for (j = 0; j < size_V2_9; j++) { h_v2_9[j] = ((double)rand() / RAND_MAX); } printf ("==========================================================================================================\n"); printf (" >>> %s <<<\n", __func__); printf (" T3: %'12d\n", size_T3); printf (" T2_1: %'12d, V2_1: %'12d\n", size_T2_1, size_V2_1); printf (" T2_2: %'12d, V2_2: %'12d\n", size_T2_2, size_V2_2); printf (" T2_3: %'12d, V2_3: %'12d\n", size_T2_3, size_V2_3); printf (" T2_4: %'12d, V2_4: %'12d\n", size_T2_4, size_V2_4); printf (" T2_5: %'12d, V2_5: %'12d\n", size_T2_5, size_V2_5); printf (" T2_6: %'12d, V2_6: %'12d\n", size_T2_6, size_V2_6); printf (" T2_7: %'12d, V2_7: %'12d\n", size_T2_7, size_V2_7); printf (" T2_8: %'12d, V2_8: %'12d\n", size_T2_8, size_V2_8); printf (" T2_9: %'12d, V2_9: %'12d\n", size_T2_9, size_V2_9); printf ("==========================================================================================================\n"); } // void post_Correctness(double* h_t3, double* h_t3_chk, double* h_t2_1, double* h_v2_1, double* h_t2_2, double* h_v2_2, double* h_t2_3, double* h_v2_3, double* h_t2_4, double* h_v2_4, double* h_t2_5, double* h_v2_5, double* h_t2_6, double* h_v2_6, double* h_t2_7, double* h_v2_7, double* h_t2_8, double* h_v2_8, double* h_t2_9, double* h_v2_9, int kernel_1, int kernel_2, int kernel_3, int kernel_4, int kernel_5, int kernel_6, int kernel_7, int kernel_8, int kernel_9, int size_idx_h3, int size_idx_h2, int size_idx_h1, int size_idx_p6, int size_idx_p5, int size_idx_p4, int size_idx_h7) { int SIZE_IDX_H3; int SIZE_IDX_H2; int SIZE_IDX_H1; int SIZE_IDX_P6; int SIZE_IDX_P5; int SIZE_IDX_P4; int SIZE_IDX_H7; int STR_SD2_T3_H3; int STR_SD2_T3_H2;// STR_SD2_T3_H3 * SIZE_IDX_H3 int STR_SD2_T3_H1;// STR_SD2_T3_H2 * SIZE_IDX_H2 int STR_SD2_T3_P6;// STR_SD2_T3_H1 * SIZE_IDX_H1 int STR_SD2_T3_P5;// STR_SD2_T3_P6 * SIZE_IDX_P6 int STR_SD2_T3_P4;// STR_SD2_T3_P5 * SIZE_IDX_P5 // t2 for inputs int STR_SD2_T2_4_H7;// 1 int STR_SD2_T2_4_P5;// STR_SD2_T2_4_H7 * SIZE_IDX_H7 int STR_SD2_T2_4_P6;// STR_SD2_T2_4_P5 * SIZE_IDX_P5 int STR_SD2_T2_4_H1;// STR_SD2_T2_4_P6 * SIZE_IDX_P6 // v2 for inputs int STR_SD2_V2_4_H3;// 1 int STR_SD2_V2_4_H2;// STR_SD2_V2_4_H3 * SIZE_IDX_H3 int STR_SD2_V2_4_P4;// STR_SD2_V2_4_H2 * SIZE_IDX_H2 int STR_SD2_V2_4_H7;// STR_SD2_V2_4_P4 * SIZE_IDX_P4 // t2 for inputs int STR_SD2_T2_5_H7;// 1 int STR_SD2_T2_5_P5;// STR_SD2_T2_5_H7 * SIZE_IDX_H7 int STR_SD2_T2_5_P6;// STR_SD2_T2_5_P5 * SIZE_IDX_P5 int STR_SD2_T2_5_H2;// STR_SD2_T2_5_P6 * SIZE_IDX_P6 // v2 for inputs int STR_SD2_V2_5_H3;// 1 int STR_SD2_V2_5_H1;// STR_SD2_V2_5_H3 * SIZE_IDX_H3 int STR_SD2_V2_5_P4;// STR_SD2_V2_5_H1 * SIZE_IDX_H1 int STR_SD2_V2_5_H7;// STR_SD2_V2_5_P4 * SIZE_IDX_P4 // t2 for inputs int STR_SD2_T2_6_H7;// 1 int STR_SD2_T2_6_P5;// STR_SD2_T2_6_H7 * SIZE_IDX_H7 int STR_SD2_T2_6_P6;// STR_SD2_T2_6_P5 * SIZE_IDX_P5 int STR_SD2_T2_6_H3;// STR_SD2_T2_6_P6 * SIZE_IDX_P6 // v2 for inputs int STR_SD2_V2_6_H2;// 1 int STR_SD2_V2_6_H1;// STR_SD2_V2_6_H2 * SIZE_IDX_H2 int STR_SD2_V2_6_P4;// STR_SD2_V2_6_H1 * SIZE_IDX_H1 int STR_SD2_V2_6_H7;// STR_SD2_V2_6_P4 * SIZE_IDX_P4 // t2 for inputs int STR_SD2_T2_7_H7;// 1 int STR_SD2_T2_7_P4;// STR_SD2_T2_7_H7 * SIZE_IDX_H7 int STR_SD2_T2_7_P6;// STR_SD2_T2_7_P4 * SIZE_IDX_P4 int STR_SD2_T2_7_H1;// STR_SD2_T2_7_P6 * SIZE_IDX_P6 // v2 for inputs int STR_SD2_V2_7_H3;// 1 int STR_SD2_V2_7_H2;// STR_SD2_V2_7_H3 * SIZE_IDX_H3 int STR_SD2_V2_7_P5;// STR_SD2_V2_7_H2 * SIZE_IDX_H2 int STR_SD2_V2_7_H7;// STR_SD2_V2_7_P5 * SIZE_IDX_P5 // t2 for inputs int STR_SD2_T2_8_H7;// 1 int STR_SD2_T2_8_P4;// STR_SD2_T2_8_H7 * SIZE_IDX_H7 int STR_SD2_T2_8_P6;// STR_SD2_T2_8_P4 * SIZE_IDX_P4 int STR_SD2_T2_8_H2;// STR_SD2_T2_8_P6 * SIZE_IDX_P6 // v2 for inputs int STR_SD2_V2_8_H3;// 1 int STR_SD2_V2_8_H1;// STR_SD2_V2_8_H3 * SIZE_IDX_H3 int STR_SD2_V2_8_P5;// STR_SD2_V2_8_H1 * SIZE_IDX_H1 int STR_SD2_V2_8_H7;// STR_SD2_V2_8_P5 * SIZE_IDX_P5 // t2 for inputs int STR_SD2_T2_9_H7;// 1 int STR_SD2_T2_9_P4;// STR_SD2_T2_9_H7 * SIZE_IDX_H7 int STR_SD2_T2_9_P6;// STR_SD2_T2_9_P4 * SIZE_IDX_P4 int STR_SD2_T2_9_H3;// STR_SD2_T2_9_P6 * SIZE_IDX_P6 // v2 for inputs int STR_SD2_V2_9_H2;// 1 int STR_SD2_V2_9_H1;// STR_SD2_V2_9_H2 * SIZE_IDX_H2 int STR_SD2_V2_9_P5;// STR_SD2_V2_9_H1 * SIZE_IDX_H1 int STR_SD2_V2_9_H7;// STR_SD2_V2_9_P5 * SIZE_IDX_P5 // t2 for inputs int STR_SD2_T2_1_H7;// 1 int STR_SD2_T2_1_P4;// STR_SD2_T2_1_H7 * SIZE_IDX_H7 int STR_SD2_T2_1_P5;// STR_SD2_T2_1_P4 * SIZE_IDX_P4 int STR_SD2_T2_1_H1;// STR_SD2_T2_1_P5 * SIZE_IDX_P5 // v2 for inputs int STR_SD2_V2_1_H3;// 1 int STR_SD2_V2_1_H2;// STR_SD2_V2_1_H3 * SIZE_IDX_H3 int STR_SD2_V2_1_P6;// STR_SD2_V2_1_H2 * SIZE_IDX_H2 int STR_SD2_V2_1_H7;// STR_SD2_V2_1_P6 * SIZE_IDX_P6 // t2 for inputs int STR_SD2_T2_2_H7;// 1 int STR_SD2_T2_2_P4;// STR_SD2_T2_2_H7 * SIZE_IDX_H7 int STR_SD2_T2_2_P5;// STR_SD2_T2_2_P4 * SIZE_IDX_P4 int STR_SD2_T2_2_H2;// STR_SD2_T2_2_P5 * SIZE_IDX_P5 // v2 for inputs int STR_SD2_V2_2_H3;// 1 int STR_SD2_V2_2_H1;// STR_SD2_V2_2_H3 * SIZE_IDX_H3 int STR_SD2_V2_2_P6;// STR_SD2_V2_2_H1 * SIZE_IDX_H1 int STR_SD2_V2_2_H7;// STR_SD2_V2_2_P6 * SIZE_IDX_P6 // t2 for inputs int STR_SD2_T2_3_H7;// 1 int STR_SD2_T2_3_P4;// STR_SD2_T2_3_H7 * SIZE_IDX_H7 int STR_SD2_T2_3_P5;// STR_SD2_T2_3_P4 * SIZE_IDX_P4 int STR_SD2_T2_3_H3;// STR_SD2_T2_3_P5 * SIZE_IDX_P5 // v2 for inputs int STR_SD2_V2_3_H2;// 1 int STR_SD2_V2_3_H1;// STR_SD2_V2_3_H2 * SIZE_IDX_H2 int STR_SD2_V2_3_P6;// STR_SD2_V2_3_H1 * SIZE_IDX_H1 int STR_SD2_V2_3_H7;// STR_SD2_V2_3_P6 * SIZE_IDX_P6 // Indices SIZE_IDX_H3 = size_idx_h3; SIZE_IDX_H2 = size_idx_h2; SIZE_IDX_H1 = size_idx_h1; SIZE_IDX_P6 = size_idx_p6; SIZE_IDX_P5 = size_idx_p5; SIZE_IDX_P4 = size_idx_p4; SIZE_IDX_H7 = size_idx_h7; // t3 STR_SD2_T3_H3 = 1; STR_SD2_T3_H2 = STR_SD2_T3_H3 * SIZE_IDX_H3; STR_SD2_T3_H1 = STR_SD2_T3_H2 * SIZE_IDX_H2; STR_SD2_T3_P6 = STR_SD2_T3_H1 * SIZE_IDX_H1; STR_SD2_T3_P5 = STR_SD2_T3_P6 * SIZE_IDX_P6; STR_SD2_T3_P4 = STR_SD2_T3_P5 * SIZE_IDX_P5; /* >> sd1 << 1: t3 [h3,16,h2,16,h1,16,p6,16,p5,16,p4,16] -= sum(h7,16) * t2_1 [h7,p4,p5,h1] * v2_1 [h3,h2,p6,h7]; 2: t3 [h3,16,h2,16,h1,16,p6,16,p5,16,p4,16] += sum(h7,16) * t2_2 [h7,p4,p5,h2] * v2_2 [h3,h1,p6,h7]; 3: t3 [h3,16,h2,16,h1,16,p6,16,p5,16,p4,16] -= sum(h7,16) * t2_3 [h7,p4,p5,h3] * v2_3 [h2,h1,p6,h7]; 4: t3 [h3,16,h2,16,h1,16,p6,16,p5,16,p4,16] -= sum(h7,16) * t2_4 [h7,p5,p6,h1] * v2_4 [h3,h2,p4,h7]; 5: t3 [h3,16,h2,16,h1,16,p6,16,p5,16,p4,16] += sum(h7,16) * t2_5 [h7,p5,p6,h2] * v2_5 [h3,h1,p4,h7]; 6: t3 [h3,16,h2,16,h1,16,p6,16,p5,16,p4,16] -= sum(h7,16) * t2_6 [h7,p5,p6,h3] * v2_6 [h2,h1,p4,h7]; 7: t3 [h3,16,h2,16,h1,16,p6,16,p5,16,p4,16] += sum(h7,16) * t2_7 [h7,p4,p6,h1] * v2_7 [h3,h2,p5,h7]; 8: t3 [h3,16,h2,16,h1,16,p6,16,p5,16,p4,16] -= sum(h7,16) * t2_8 [h7,p4,p6,h2] * v2_8 [h3,h1,p5,h7]; 9: t3 [h3,16,h2,16,h1,16,p6,16,p5,16,p4,16] += sum(h7,16) * t2_8 [h7,p4,p6,h3] * v2_9 [h2,h1,p5,h7]; */ // t2 for inputs STR_SD2_T2_4_H7 = 1; STR_SD2_T2_4_P5 = STR_SD2_T2_4_H7 * SIZE_IDX_H7; STR_SD2_T2_4_P6 = STR_SD2_T2_4_P5 * SIZE_IDX_P5; STR_SD2_T2_4_H1 = STR_SD2_T2_4_P6 * SIZE_IDX_P6; // v2 for inputs STR_SD2_V2_4_H3 = 1; STR_SD2_V2_4_H2 = STR_SD2_V2_4_H3 * SIZE_IDX_H3; STR_SD2_V2_4_P4 = STR_SD2_V2_4_H2 * SIZE_IDX_H2; STR_SD2_V2_4_H7 = STR_SD2_V2_4_P4 * SIZE_IDX_P4; // t2 for inputs STR_SD2_T2_5_H7 = 1; STR_SD2_T2_5_P5 = STR_SD2_T2_5_H7 * SIZE_IDX_H7; STR_SD2_T2_5_P6 = STR_SD2_T2_5_P5 * SIZE_IDX_P5; STR_SD2_T2_5_H2 = STR_SD2_T2_5_P6 * SIZE_IDX_P6; // v2 for inputs STR_SD2_V2_5_H3 = 1; STR_SD2_V2_5_H1 = STR_SD2_V2_5_H3 * SIZE_IDX_H3; STR_SD2_V2_5_P4 = STR_SD2_V2_5_H1 * SIZE_IDX_H1; STR_SD2_V2_5_H7 = STR_SD2_V2_5_P4 * SIZE_IDX_P4; // t2 for inputs STR_SD2_T2_6_H7 = 1; STR_SD2_T2_6_P5 = STR_SD2_T2_6_H7 * SIZE_IDX_H7; STR_SD2_T2_6_P6 = STR_SD2_T2_6_P5 * SIZE_IDX_P5; STR_SD2_T2_6_H3 = STR_SD2_T2_6_P6 * SIZE_IDX_P6; // v2 for inputs STR_SD2_V2_6_H2 = 1; STR_SD2_V2_6_H1 = STR_SD2_V2_6_H2 * SIZE_IDX_H2; STR_SD2_V2_6_P4 = STR_SD2_V2_6_H1 * SIZE_IDX_H1; STR_SD2_V2_6_H7 = STR_SD2_V2_6_P4 * SIZE_IDX_P4; // t2 for inputs STR_SD2_T2_7_H7 = 1; STR_SD2_T2_7_P4 = STR_SD2_T2_7_H7 * SIZE_IDX_H7; STR_SD2_T2_7_P6 = STR_SD2_T2_7_P4 * SIZE_IDX_P4; STR_SD2_T2_7_H1 = STR_SD2_T2_7_P6 * SIZE_IDX_P6; // v2 for inputs STR_SD2_V2_7_H3 = 1; STR_SD2_V2_7_H2 = STR_SD2_V2_7_H3 * SIZE_IDX_H3; STR_SD2_V2_7_P5 = STR_SD2_V2_7_H2 * SIZE_IDX_H2; STR_SD2_V2_7_H7 = STR_SD2_V2_7_P5 * SIZE_IDX_P5; // t2 for inputs STR_SD2_T2_8_H7 = 1; STR_SD2_T2_8_P4 = STR_SD2_T2_8_H7 * SIZE_IDX_H7; STR_SD2_T2_8_P6 = STR_SD2_T2_8_P4 * SIZE_IDX_P4; STR_SD2_T2_8_H2 = STR_SD2_T2_8_P6 * SIZE_IDX_P6; // v2 for inputs STR_SD2_V2_8_H3 = 1; STR_SD2_V2_8_H1 = STR_SD2_V2_8_H3 * SIZE_IDX_H3; STR_SD2_V2_8_P5 = STR_SD2_V2_8_H1 * SIZE_IDX_H1; STR_SD2_V2_8_H7 = STR_SD2_V2_8_P5 * SIZE_IDX_P5; // t2 for inputs STR_SD2_T2_9_H7 = 1; STR_SD2_T2_9_P4 = STR_SD2_T2_9_H7 * SIZE_IDX_H7; STR_SD2_T2_9_P6 = STR_SD2_T2_9_P4 * SIZE_IDX_P4; STR_SD2_T2_9_H3 = STR_SD2_T2_9_P6 * SIZE_IDX_P6; // v2 for inputs STR_SD2_V2_9_H2 = 1; STR_SD2_V2_9_H1 = STR_SD2_V2_9_H2 * SIZE_IDX_H2; STR_SD2_V2_9_P5 = STR_SD2_V2_9_H1 * SIZE_IDX_H1; STR_SD2_V2_9_H7 = STR_SD2_V2_9_P5 * SIZE_IDX_P5; // t2 for inputs STR_SD2_T2_1_H7 = 1; STR_SD2_T2_1_P4 = STR_SD2_T2_1_H7 * SIZE_IDX_H7; STR_SD2_T2_1_P5 = STR_SD2_T2_1_P4 * SIZE_IDX_P4; STR_SD2_T2_1_H1 = STR_SD2_T2_1_P5 * SIZE_IDX_P5;; // v2 for inputs STR_SD2_V2_1_H3 = 1; STR_SD2_V2_1_H2 = STR_SD2_V2_1_H3 * SIZE_IDX_H3; STR_SD2_V2_1_P6 = STR_SD2_V2_1_H2 * SIZE_IDX_H2; STR_SD2_V2_1_H7 = STR_SD2_V2_1_P6 * SIZE_IDX_P6; // t2 for inputs STR_SD2_T2_2_H7 = 1; STR_SD2_T2_2_P4 = STR_SD2_T2_2_H7 * SIZE_IDX_H7; STR_SD2_T2_2_P5 = STR_SD2_T2_2_P4 * SIZE_IDX_P4; STR_SD2_T2_2_H2 = STR_SD2_T2_2_P5 * SIZE_IDX_P5; // v2 for inputs STR_SD2_V2_2_H3 = 1; STR_SD2_V2_2_H1 = STR_SD2_V2_2_H3 * SIZE_IDX_H3; STR_SD2_V2_2_P6 = STR_SD2_V2_2_H1 * SIZE_IDX_H1; STR_SD2_V2_2_H7 = STR_SD2_V2_2_P6 * SIZE_IDX_P6; // t2 for inputs STR_SD2_T2_3_H7 = 1; STR_SD2_T2_3_P4 = STR_SD2_T2_3_H7 * SIZE_IDX_H7; STR_SD2_T2_3_P5 = STR_SD2_T2_3_P4 * SIZE_IDX_P4; STR_SD2_T2_3_H3 = STR_SD2_T2_3_P5 * SIZE_IDX_P5; // v2 for inputs STR_SD2_V2_3_H2 = 1; STR_SD2_V2_3_H1 = STR_SD2_V2_3_H2 * SIZE_IDX_H2; STR_SD2_V2_3_P6 = STR_SD2_V2_3_H1 * SIZE_IDX_H1; STR_SD2_V2_3_H7 = STR_SD2_V2_3_P6 * SIZE_IDX_P6; long long int tmp_ops = 0; int ops = 0; int t3_h3, t3_h2, t3_h1, t3_p6, t3_p5, t3_p4, t3_h7; for (t3_h3 = 0; t3_h3 < SIZE_IDX_H3; t3_h3++) for (t3_h2 = 0; t3_h2 < SIZE_IDX_H2; t3_h2++) for (t3_h1 = 0; t3_h1 < SIZE_IDX_H1; t3_h1++) for (t3_p6 = 0; t3_p6 < SIZE_IDX_P6; t3_p6++) for (t3_p5 = 0; t3_p5 < SIZE_IDX_P5; t3_p5++) for (t3_p4 = 0; t3_p4 < SIZE_IDX_P4; t3_p4++) { int tmp_r_idx = t3_h3 * STR_SD2_T3_H3 + t3_h2 * STR_SD2_T3_H2 + t3_h1 * STR_SD2_T3_H1 + t3_p6 * STR_SD2_T3_P6 + t3_p5 * STR_SD2_T3_P5 + t3_p4 * STR_SD2_T3_P4; for (t3_h7 = 0; t3_h7 < SIZE_IDX_H7; t3_h7++, ops = 0) { h_t3_chk[tmp_r_idx] += h_t2_4[t3_h7 * STR_SD2_T2_4_H7 + t3_p5 * STR_SD2_T2_4_P5 + t3_p6 * STR_SD2_T2_4_P6 + t3_h1 * STR_SD2_T2_4_H1] * h_v2_4[t3_h3 * STR_SD2_V2_4_H3 + t3_h2 * STR_SD2_V2_4_H2 + t3_p4 * STR_SD2_V2_4_P4 + t3_h7 * STR_SD2_V2_4_H7]; ops++; /* if (kernel_5 == 1) { h_t3_chk[tmp_r_idx] += h_t2_5[t3_h7 * STR_SD2_T2_5_H7 + t3_p5 * STR_SD2_T2_5_P5 + t3_p6 * STR_SD2_T2_5_P6 + t3_h2 * STR_SD2_T2_5_H2] * h_v2_5[t3_h3 * STR_SD2_V2_5_H3 + t3_h1 * STR_SD2_V2_5_H1 + t3_p4 * STR_SD2_V2_5_P4 + t3_h7 * STR_SD2_V2_5_H7]; ops++; }*/ /* h_t3_chk[tmp_r_idx] -= h_t2_6[t3_h7 * STR_SD2_T2_6_H7 + t3_p5 * STR_SD2_T2_6_P5 + t3_p6 * STR_SD2_T2_6_P6 + t3_h3 * STR_SD2_T2_6_H3] * h_v2_6[t3_h2 * STR_SD2_V2_6_H2 + t3_h1 * STR_SD2_V2_6_H1 + t3_p4 * STR_SD2_V2_6_P4 + t3_h7 * STR_SD2_V2_6_H7]; ops++; */ /* h_t3_chk[tmp_r_idx] += h_t2_7[t3_h7 * STR_SD2_T2_7_H7 + t3_p4 * STR_SD2_T2_7_P4 + t3_p6 * STR_SD2_T2_7_P6 + t3_h1 * STR_SD2_T2_7_H1] * h_v2_7[t3_h3 * STR_SD2_V2_7_H3 + t3_h2 * STR_SD2_V2_7_H2 + t3_p5 * STR_SD2_V2_7_P5 + t3_h7 * STR_SD2_V2_7_H7]; ops++; */ /* if (kernel_8 == 1) { h_t3_chk[tmp_r_idx] -= h_t2_8[t3_h7 * STR_SD2_T2_8_H7 + t3_p4 * STR_SD2_T2_8_P4 + t3_p6 * STR_SD2_T2_8_P6 + t3_h2 * STR_SD2_T2_8_H2] * h_v2_8[t3_h3 * STR_SD2_V2_8_H3 + t3_h1 * STR_SD2_V2_8_H1 + t3_p5 * STR_SD2_V2_8_P5 + t3_h7 * STR_SD2_V2_8_H7]; ops++; } if (kernel_9 == 1) { h_t3_chk[tmp_r_idx] += h_t2_9[t3_h7 * STR_SD2_T2_9_H7 + t3_p4 * STR_SD2_T2_9_P4 + t3_p6 * STR_SD2_T2_9_P6 + t3_h3 * STR_SD2_T2_9_H3] * h_v2_9[t3_h2 * STR_SD2_V2_9_H2 + t3_h1 * STR_SD2_V2_9_H1 + t3_p5 * STR_SD2_V2_9_P5 + t3_h7 * STR_SD2_V2_9_H7]; ops++; } */ /* h_t3_chk[tmp_r_idx] -= h_t2_1[t3_h7 * STR_SD2_T2_1_H7 + t3_p4 * STR_SD2_T2_1_P4 + t3_p5 * STR_SD2_T2_1_P5 + t3_h1 * STR_SD2_T2_1_H1] * h_v2_1[t3_h3 * STR_SD2_V2_1_H3 + t3_h2 * STR_SD2_V2_1_H2 + t3_p6 * STR_SD2_V2_1_P6 + t3_h7 * STR_SD2_V2_1_H7]; ops++; */ /* h_t3_chk[tmp_r_idx] += h_t2_2[t3_h7 * STR_SD2_T2_2_H7 + t3_p4 * STR_SD2_T2_2_P4 + t3_p5 * STR_SD2_T2_2_P5 + t3_h2 * STR_SD2_T2_2_H2] * h_v2_2[t3_h3 * STR_SD2_V2_2_H3 + t3_h1 * STR_SD2_V2_2_H1 + t3_p6 * STR_SD2_V2_2_P6 + t3_h7 * STR_SD2_V2_2_H7]; ops++; */ /* if (tmp_r_idx == 0) { printf ("[%d][%2d] t2_2: %f (%d), v2_2: %f (%d)\n", tmp_r_idx, t3_h7, h_t2_2[t3_h7 * STR_SD2_T2_2_H7 + t3_p4 * STR_SD2_T2_2_P4 + t3_p5 * STR_SD2_T2_2_P5 + t3_h2 * STR_SD2_T2_2_H2], t3_h7 * STR_SD2_T2_2_H7 + t3_p4 * STR_SD2_T2_2_P4 + t3_p5 * STR_SD2_T2_2_P5 + t3_h2 * STR_SD2_T2_2_H2, h_v2_2[t3_h3 * STR_SD2_V2_2_H3 + t3_h1 * STR_SD2_V2_2_H1 + t3_p6 * STR_SD2_V2_2_P6 + t3_h7 * STR_SD2_V2_2_H7], t3_h3 * STR_SD2_V2_2_H3 + t3_h1 * STR_SD2_V2_2_H1 + t3_p6 * STR_SD2_V2_2_P6 + t3_h7 * STR_SD2_V2_2_H7); } */ /* h_t3_chk[tmp_r_idx] -= h_t2_3[t3_h7 * STR_SD2_T2_3_H7 + t3_p4 * STR_SD2_T2_3_P4 + t3_p5 * STR_SD2_T2_3_P5 + t3_h3 * STR_SD2_T2_3_H3] * h_v2_3[t3_h2 * STR_SD2_V2_3_H2 + t3_h1 * STR_SD2_V2_3_H1 + t3_p6 * STR_SD2_V2_3_P6 + t3_h7 * STR_SD2_V2_3_H7]; ops++; */ tmp_ops = tmp_ops + ops; } } printf ("======================================= Correctness Check ==========================================\n"); double epsilon = 0.00000001; int diff = 0; int same = 0; int i; for (i = 0; i < size_idx_h3 * size_idx_h2 * size_idx_h1 * size_idx_p6 * size_idx_p5 * size_idx_p4; i++) { double check = h_t3_chk[i] - h_t3[i]; if (check < 0) check *= -1; if (check > epsilon) { diff++; if (diff < 8) printf ("Index: %5d, (Host) %8.4f, (Dev.) %8.4f >> (Diff.) %8.4f\n", i, h_t3_chk[i], h_t3[i], check); } else { same++; } } printf (" >>> PASSED: %'10d among %'10d in t3\n", same, size_idx_h3 * size_idx_h2 * size_idx_h1 * size_idx_p6 * size_idx_p5 * size_idx_p4); printf (" >>> ERROR : %'10d among %'10d in t3\n", diff, size_idx_h3 * size_idx_h2 * size_idx_h1 * size_idx_p6 * size_idx_p5 * size_idx_p4); printf (" >>> Total Operations: %'lld\n", tmp_ops * 2); printf ("====================================================================================================\n"); }
the_stack_data/54826152.c
/* Dummy nop functions to elicit link-time warnings. Copyright (C) 2005-2020 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. In addition to the permissions in the GNU Lesser General Public License, the Free Software Foundation gives you unlimited permission to link the compiled version of this file with other programs, and to distribute those programs without any restriction coming from the use of this file. (The GNU Lesser General Public License restrictions do apply in other respects; for example, they cover modification of the file, and distribution when not linked into another program.) Note that people who make modified versions of this file are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ #include <sys/cdefs.h> static void __attribute__ ((used)) nop (void) { } /* Don't insert any other #include's before this #undef! */ #undef __warndecl #define __warndecl(name, msg) \ extern void name (void) __attribute__ ((alias ("nop"))) attribute_hidden; \ link_warning (name, msg) #undef __USE_FORTIFY_LEVEL #define __USE_FORTIFY_LEVEL 99 /* Following here we need an #include for each public header file that uses __warndecl. */ /* Define away to avoid warnings with compilers that do not have these builtins. */ #define __builtin___memcpy_chk(dest, src, len, bos) NULL #define __builtin___memmove_chk(dest, src, len, bos) NULL #define __builtin___mempcpy_chk(dest, src, len, bos) NULL #define __builtin___memset_chk(dest, ch, len, bos) NULL #define __builtin___stpcpy_chk(dest, src, bos) NULL #define __builtin___strcat_chk(dest, src, bos) NULL #define __builtin___strcpy_chk(dest, src, bos) NULL #define __builtin___strncat_chk(dest, src, len, bos) NULL #define __builtin___strncpy_chk(dest, src, len, bos) NULL #define __builtin_object_size(bos, level) 0 #include <string.h>
the_stack_data/82949936.c
/* crypto/camellia/camellia_cfb.c -*- mode:C; c-file-style: "eay" -*- */ /* ==================================================================== * Copyright (c) 2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * [email protected]. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 OpenSSL PROJECT OR * ITS 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. * ==================================================================== * */ /* Copyright (C) 1995-1998 Eric Young ([email protected]) * All rights reserved. * * This package is an SSL implementation written * by Eric Young ([email protected]). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson ([email protected]). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * 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 copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young ([email protected])" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson ([email protected])" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 AUTHOR 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include <openssl/camellia.h> #include <openssl/modes.h> /* The input and output encrypted as though 128bit cfb mode is being * used. The extra state information to record how much of the * 128bit block we have used is contained in *num; */ void Camellia_cfb128_encrypt(const unsigned char *in, unsigned char *out, size_t length, const CAMELLIA_KEY *key, unsigned char *ivec, int *num, const int enc) { CRYPTO_cfb128_encrypt(in,out,length,key,ivec,num,enc,(block128_f)Camellia_encrypt); } /* N.B. This expects the input to be packed, MS bit first */ void Camellia_cfb1_encrypt(const unsigned char *in, unsigned char *out, size_t length, const CAMELLIA_KEY *key, unsigned char *ivec, int *num, const int enc) { CRYPTO_cfb128_1_encrypt(in,out,length,key,ivec,num,enc,(block128_f)Camellia_encrypt); } void Camellia_cfb8_encrypt(const unsigned char *in, unsigned char *out, size_t length, const CAMELLIA_KEY *key, unsigned char *ivec, int *num, const int enc) { CRYPTO_cfb128_8_encrypt(in,out,length,key,ivec,num,enc,(block128_f)Camellia_encrypt); }
the_stack_data/558993.c
#include<string.h> #include<stdio.h> int main(){ char s[100]="hello world"; puts(s); printf("%d\n",strlen(s)); s[5]=0; puts(s); printf("%d\n",strlen(s)); return 0; }
the_stack_data/138871.c
/* Taxonomy Classification: 0000300604130000000210 */ /* * WRITE/READ 0 write * WHICH BOUND 0 upper * DATA TYPE 0 char * MEMORY LOCATION 0 stack * SCOPE 3 inter-file/inter-proc * CONTAINER 0 no * POINTER 0 no * INDEX COMPLEXITY 6 N/A * ADDRESS COMPLEXITY 0 constant * LENGTH COMPLEXITY 4 linear expr * ADDRESS ALIAS 1 yes, one level * INDEX ALIAS 3 N/A * LOCAL CONTROL FLOW 0 none * SECONDARY CONTROL FLOW 0 none * LOOP STRUCTURE 0 no * LOOP COMPLEXITY 0 N/A * ASYNCHRONY 0 no * TAINT 0 no * RUNTIME ENV. DEPENDENCE 0 no * MAGNITUDE 2 8 bytes * CONTINUOUS/DISCRETE 1 continuous * SIGNEDNESS 0 no */ /* Copyright 2004 M.I.T. Permission is hereby granted, without written agreement or royalty fee, to use, copy, modify, and distribute this software and its documentation for any purpose, provided that the above copyright notice and the following three paragraphs appear in all copies of this software. IN NO EVENT SHALL M.I.T. BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF M.I.T. HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMANGE. M.I.T. SPECIFICALLY DISCLAIMS ANY WARRANTIES INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THE SOFTWARE IS PROVIDED ON AN "AS-IS" BASIS AND M.I.T. HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. */ #include <string.h> int main(int argc, char *argv[]) { int i; char src[18]; char buf[10]; memset(src, 'A', 18); src[18 - 1] = '\0'; i = 4; /* BAD */ strncpy(buf, src, (4 * i) + 2); return 0; }
the_stack_data/197033.c
// RUN: %clang -target aarch64-none-linux-gnu -x c -E -dM %s -o - | FileCheck %s // RUN: %clang -target arm64-none-linux-gnu -x c -E -dM %s -o - | FileCheck %s // CHECK: __AARCH64EL__ 1 // CHECK: __ARM_64BIT_STATE 1 // CHECK-NOT: __ARM_32BIT_STATE // CHECK: __ARM_ACLE 200 // CHECK: __ARM_ALIGN_MAX_STACK_PWR 4 // CHECK: __ARM_ARCH 8 // CHECK: __ARM_ARCH_ISA_A64 1 // CHECK-NOT: __ARM_ARCH_ISA_ARM // CHECK-NOT: __ARM_ARCH_ISA_THUMB // CHECK-NOT: __ARM_FEATURE_QBIT // CHECK-NOT: __ARM_FEATURE_DSP // CHECK-NOT: __ARM_FEATURE_SAT // CHECK-NOT: __ARM_FEATURE_SIMD32 // CHECK: __ARM_ARCH_PROFILE 'A' // CHECK-NOT: __ARM_FEATURE_BIG_ENDIAN // CHECK: __ARM_FEATURE_CLZ 1 // CHECK-NOT: __ARM_FEATURE_CRC32 1 // CHECK-NOT: __ARM_FEATURE_CRYPTO 1 // CHECK: __ARM_FEATURE_DIRECTED_ROUNDING 1 // CHECK: __ARM_FEATURE_DIV 1 // CHECK: __ARM_FEATURE_FMA 1 // CHECK: __ARM_FEATURE_IDIV 1 // CHECK: __ARM_FEATURE_LDREX 0xF // CHECK: __ARM_FEATURE_NUMERIC_MAXMIN 1 // CHECK: __ARM_FEATURE_UNALIGNED 1 // CHECK: __ARM_FP 0xE // CHECK: __ARM_FP16_ARGS 1 // CHECK: __ARM_FP16_FORMAT_IEEE 1 // CHECK-NOT: __ARM_FP_FAST 1 // CHECK: __ARM_NEON 1 // CHECK: __ARM_NEON_FP 0xE // CHECK: __ARM_PCS_AAPCS64 1 // CHECK-NOT: __ARM_PCS 1 // CHECK-NOT: __ARM_PCS_VFP 1 // CHECK-NOT: __ARM_SIZEOF_MINIMAL_ENUM 1 // CHECK-NOT: __ARM_SIZEOF_WCHAR_T 2 // CHECK-NOT: __ARM_FEATURE_SVE // CHECK-NOT: __ARM_FEATURE_DOTPROD // CHECK-NOT: __ARM_FEATURE_PAC_DEFAULT // CHECK-NOT: __ARM_FEATURE_BTI_DEFAULT // CHECK-NOT: __ARM_BF16_FORMAT_ALTERNATIVE 1 // CHECK-NOT: __ARM_FEATURE_BF16 1 // CHECK-NOT: __ARM_FEATURE_BF16_VECTOR_ARITHMETIC 1 // CHECK-NOT: __ARM_FEATURE_SVE_BITS 0 // CHECK-NOT: __ARM_FEATURE_SVE_BITS 128 // CHECK-NOT: __ARM_FEATURE_SVE_BITS 256 // CHECK-NOT: __ARM_FEATURE_SVE_BITS 512 // CHECK-NOT: __ARM_FEATURE_SVE_BITS 1024 // CHECK-NOT: __ARM_FEATURE_SVE_BITS 2048 // RUN: %clang -target aarch64_be-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-BIGENDIAN // CHECK-BIGENDIAN: __ARM_BIG_ENDIAN 1 // RUN: %clang -target aarch64-none-linux-gnu -march=armv8-a+crypto -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-CRYPTO %s // RUN: %clang -target arm64-none-linux-gnu -march=armv8-a+crypto -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-CRYPTO %s // CHECK-CRYPTO: __ARM_FEATURE_CRYPTO 1 // RUN: %clang -target aarch64-none-linux-gnu -mcrc -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-CRC32 %s // RUN: %clang -target arm64-none-linux-gnu -mcrc -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-CRC32 %s // RUN: %clang -target aarch64-none-linux-gnu -march=armv8-a+crc -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-CRC32 %s // RUN: %clang -target arm64-none-linux-gnu -march=armv8-a+crc -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-CRC32 %s // RUN: %clang -target aarch64-none-linux-gnu -march=armv8.1-a -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-CRC32 %s // RUN: %clang -target arm64-none-linux-gnu -march=armv8.1-a -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-CRC32 %s // CHECK-CRC32: __ARM_FEATURE_CRC32 1 // RUN: %clang -target aarch64-none-linux-gnu -fno-math-errno -fno-signed-zeros\ // RUN: -fno-trapping-math -fassociative-math -freciprocal-math\ // RUN: -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-FASTMATH %s // RUN: %clang -target aarch64-none-linux-gnu -ffast-math -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-FASTMATH %s // RUN: %clang -target arm64-none-linux-gnu -ffast-math -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-FASTMATH %s // CHECK-FASTMATH: __ARM_FP_FAST 1 // RUN: %clang -target aarch64-none-linux-gnu -fshort-wchar -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SHORTWCHAR %s // RUN: %clang -target arm64-none-linux-gnu -fshort-wchar -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SHORTWCHAR %s // CHECK-SHORTWCHAR: __ARM_SIZEOF_WCHAR_T 2 // RUN: %clang -target aarch64-none-linux-gnu -fshort-enums -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SHORTENUMS %s // RUN: %clang -target arm64-none-linux-gnu -fshort-enums -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SHORTENUMS %s // CHECK-SHORTENUMS: __ARM_SIZEOF_MINIMAL_ENUM 1 // RUN: %clang -target aarch64-none-linux-gnu -march=armv8-a+simd -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-NEON %s // RUN: %clang -target arm64-none-linux-gnu -march=armv8-a+simd -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-NEON %s // CHECK-NEON: __ARM_NEON 1 // CHECK-NEON: __ARM_NEON_FP 0xE // RUN: %clang -target aarch64-none-eabi -march=armv8.1-a -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-QRDMX %s // RUN: %clang -target aarch64-none-eabi -march=armv8.2-a -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-QRDMX %s // CHECK-QRDMX: __ARM_FEATURE_QRDMX 1 // RUN: %clang -target aarch64 -march=arm64 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-ARCH-NOT-ACCEPT %s // RUN: %clang -target aarch64 -march=aarch64 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-ARCH-NOT-ACCEPT %s // CHECK-ARCH-NOT-ACCEPT: error: the clang compiler does not support // RUN: %clang -target aarch64 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-GENERIC %s // RUN: %clang -target aarch64 -march=armv8-a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-GENERIC %s // CHECK-GENERIC: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" // RUN: %clang -target aarch64 -mtune=cyclone -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MTUNE-CYCLONE %s // RUN: %clang -target aarch64-none-linux-gnu -march=armv8-a+sve -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SVE %s // CHECK-SVE: __ARM_FEATURE_SVE 1 // RUN: %clang -target aarch64-none-linux-gnu -march=armv8-a+sve+bf16 -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SVE-BF16 %s // CHECK-SVE-BF16: __ARM_FEATURE_BF16_SCALAR_ARITHMETIC 1 // CHECK-SVE-BF16: __ARM_FEATURE_SVE 1 // CHECK-SVE-BF16: __ARM_FEATURE_SVE_BF16 1 // RUN: %clang -target aarch64-none-linux-gnu -march=armv8-a+sve+i8mm -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SVE-I8MM %s // CHECK-SVE-I8MM: __ARM_FEATURE_SVE 1 // CHECK-SVE-I8MM: __ARM_FEATURE_SVE_MATMUL_INT8 1 // RUN: %clang -target aarch64-none-linux-gnu -march=armv8-a+sve+f32mm -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SVE-F32MM %s // CHECK-SVE-F32MM: __ARM_FEATURE_SVE 1 // CHECK-SVE-F32MM: __ARM_FEATURE_SVE_MATMUL_FP32 1 // RUN: %clang -target aarch64-none-linux-gnu -march=armv8-a+sve+f64mm -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SVE-F64MM %s // CHECK-SVE-F64MM: __ARM_FEATURE_SVE 1 // CHECK-SVE-F64MM: __ARM_FEATURE_SVE_MATMUL_FP64 1 // RUN: %clang -target aarch64-none-linux-gnu -march=armv8.5-a+sve -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SVE-8_5 %s // CHECK-SVE-8_5-NOT: __ARM_FEATURE_SVE_BF16 1 // CHECK-SVE-8_5-NOT: __ARM_FEATURE_SVE_MATMUL_FP32 1 // CHECK-SVE-8_5-NOT: __ARM_FEATURE_SVE_MATMUL_INT8 1 // CHECK-SVE-8_5: __ARM_FEATURE_SVE 1 // RUN: %clang -target aarch64-none-linux-gnu -march=armv8.6-a+sve -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SVE-8_6 %s // CHECK-SVE-8_6: __ARM_FEATURE_SVE 1 // CHECK-SVE-8_6: __ARM_FEATURE_SVE_BF16 1 // CHECK-SVE-8_6: __ARM_FEATURE_SVE_MATMUL_FP32 1 // CHECK-SVE-8_6: __ARM_FEATURE_SVE_MATMUL_INT8 1 // RUN: %clang -target aarch64-none-linux-gnu -march=armv8.6-a+sve+noi8mm+nobf16+nof32mm -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SVE-8_6-NOFEATURES %s // CHECK-SVE-8_6-NOFEATURES-NOT: __ARM_FEATURE_SVE_BF16 1 // CHECK-SVE-8_6-NOFEATURES-NOT: __ARM_FEATURE_SVE_MATMUL_FP32 1 // CHECK-SVE-8_6-NOFEATURES-NOT: __ARM_FEATURE_SVE_MATMUL_INT8 1 // CHECK-SVE-8_6-NOFEATURES: __ARM_FEATURE_SVE 1 // The following tests may need to be revised in the future since // SVE2 is currently still part of Future Architecture Technologies // (https://developer.arm.com/docs/ddi0602/latest) // // RUN: %clang -target aarch64-none-linux-gnu -march=armv8-a+sve2 -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SVE2 %s // CHECK-SVE2: __ARM_FEATURE_SVE2 1 // RUN: %clang -target aarch64-none-linux-gnu -march=armv8-a+sve2-aes -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SVE2AES %s // CHECK-SVE2AES: __ARM_FEATURE_SVE2_AES 1 // RUN: %clang -target aarch64-none-linux-gnu -march=armv8-a+sve2-sha3 -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SVE2SHA3 %s // CHECK-SVE2SHA3: __ARM_FEATURE_SVE2_SHA3 1 // RUN: %clang -target aarch64-none-linux-gnu -march=armv8-a+sve2-sm4 -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SVE2SM4 %s // CHECK-SVE2SM4: __ARM_FEATURE_SVE2_SM4 1 // RUN: %clang -target aarch64-none-linux-gnu -march=armv8-a+sve2-bitperm -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SVE2BITPERM %s // CHECK-SVE2BITPERM: __ARM_FEATURE_SVE2_BITPERM 1 // RUN: %clang -target aarch64-none-linux-gnu -march=armv8.2a+dotprod -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-DOTPROD %s // CHECK-DOTPROD: __ARM_FEATURE_DOTPROD 1 // On ARMv8.2-A and above, +fp16fml implies +fp16. // On ARMv8.4-A and above, +fp16 implies +fp16fml. // RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8.2-a+nofp16fml+fp16 -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-FULLFP16-NOFML --check-prefix=CHECK-FULLFP16-VECTOR-SCALAR %s // RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8.2-a+nofp16+fp16fml -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-FULLFP16-FML --check-prefix=CHECK-FULLFP16-VECTOR-SCALAR %s // RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8.2-a+fp16+nofp16fml -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-FULLFP16-NOFML --check-prefix=CHECK-FULLFP16-VECTOR-SCALAR %s // RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8-a+fp16fml -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-FULLFP16-FML --check-prefix=CHECK-FULLFP16-VECTOR-SCALAR %s // RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8-a+fp16 -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-FULLFP16-NOFML --check-prefix=CHECK-FULLFP16-VECTOR-SCALAR %s // RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8.4-a+nofp16fml+fp16 -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-FULLFP16-FML --check-prefix=CHECK-FULLFP16-VECTOR-SCALAR %s // RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8.4-a+nofp16+fp16fml -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-FULLFP16-FML --check-prefix=CHECK-FULLFP16-VECTOR-SCALAR %s // RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8.4-a+fp16+nofp16fml -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-FULLFP16-NOFML --check-prefix=CHECK-FULLFP16-VECTOR-SCALAR %s // RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8.4-a+fp16fml -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-FULLFP16-FML --check-prefix=CHECK-FULLFP16-VECTOR-SCALAR %s // RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8.4-a+fp16 -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-FULLFP16-FML --check-prefix=CHECK-FULLFP16-VECTOR-SCALAR %s // CHECK-FULLFP16-FML: #define __ARM_FEATURE_FP16FML 1 // CHECK-FULLFP16-NOFML-NOT: #define __ARM_FEATURE_FP16FML 1 // CHECK-FULLFP16-VECTOR-SCALAR: #define __ARM_FEATURE_FP16_SCALAR_ARITHMETIC 1 // CHECK-FULLFP16-VECTOR-SCALAR: #define __ARM_FEATURE_FP16_VECTOR_ARITHMETIC 1 // CHECK-FULLFP16-VECTOR-SCALAR: #define __ARM_FP 0xE // CHECK-FULLFP16-VECTOR-SCALAR: #define __ARM_FP16_FORMAT_IEEE 1 // +fp16fml+nosimd doesn't make sense as the fp16fml instructions all require SIMD. // However, as +fp16fml implies +fp16 there is a set of defines that we would expect. // RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8-a+fp16fml+nosimd -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-FULLFP16-SCALAR %s // RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8-a+fp16+nosimd -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-FULLFP16-SCALAR %s // RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8.4-a+fp16fml+nosimd -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-FULLFP16-SCALAR %s // RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8.4-a+fp16+nosimd -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-FULLFP16-SCALAR %s // CHECK-FULLFP16-SCALAR-NOT: #define __ARM_FEATURE_FP16FML 1 // CHECK-FULLFP16-SCALAR: #define __ARM_FEATURE_FP16_SCALAR_ARITHMETIC 1 // CHECK-FULLFP16-SCALAR-NOT: #define __ARM_FEATURE_FP16_VECTOR_ARITHMETIC 1 // CHECK-FULLFP16-SCALAR: #define __ARM_FP 0xE // CHECK-FULLFP16-SCALAR: #define __ARM_FP16_FORMAT_IEEE 1 // RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8.2-a -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-FULLFP16-NOFML-VECTOR-SCALAR %s // RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8.2-a+nofp16 -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-FULLFP16-NOFML-VECTOR-SCALAR %s // RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8.2-a+nofp16fml -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-FULLFP16-NOFML-VECTOR-SCALAR %s // RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8.2-a+fp16fml+nofp16 -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-FULLFP16-NOFML-VECTOR-SCALAR %s // RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8.4-a -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-FULLFP16-NOFML-VECTOR-SCALAR %s // RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8.4-a+nofp16 -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-FULLFP16-NOFML-VECTOR-SCALAR %s // RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8.4-a+nofp16fml -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-FULLFP16-NOFML-VECTOR-SCALAR %s // RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8.4-a+fp16fml+nofp16 -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-FULLFP16-NOFML-VECTOR-SCALAR %s // CHECK-FULLFP16-NOFML-VECTOR-SCALAR-NOT: #define __ARM_FEATURE_FP16FML 1 // CHECK-FULLFP16-NOFML-VECTOR-SCALAR-NOT: #define __ARM_FEATURE_FP16_SCALAR_ARITHMETIC 1 // CHECK-FULLFP16-NOFML-VECTOR-SCALAR-NOT: #define __ARM_FEATURE_FP16_VECTOR_ARITHMETIC 1 // CHECK-FULLFP16-NOFML-VECTOR-SCALAR: #define __ARM_FP 0xE // CHECK-FULLFP16-NOFML-VECTOR-SCALAR: #define __ARM_FP16_FORMAT_IEEE 1 // ================== Check whether -mtune accepts mixed-case features. // RUN: %clang -target aarch64 -mtune=CYCLONE -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MTUNE-CYCLONE %s // CHECK-MTUNE-CYCLONE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+zcm" "-target-feature" "+zcz" // RUN: %clang -target aarch64 -mcpu=apple-a7 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-APPLE-A7 %s // RUN: %clang -target aarch64 -mcpu=apple-a8 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-APPLE-A7 %s // RUN: %clang -target aarch64 -mcpu=apple-a9 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-APPLE-A7 %s // RUN: %clang -target aarch64 -mcpu=apple-a10 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-APPLE-A10 %s // RUN: %clang -target aarch64 -mcpu=apple-a11 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-APPLE-A11 %s // RUN: %clang -target aarch64 -mcpu=apple-a12 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-APPLE-A12 %s // RUN: %clang -target aarch64 -mcpu=apple-a13 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-APPLE-A13 %s // RUN: %clang -target aarch64 -mcpu=apple-s4 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-APPLE-A12 %s // RUN: %clang -target aarch64 -mcpu=apple-s5 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-APPLE-A12 %s // RUN: %clang -target aarch64 -mcpu=cyclone -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-APPLE-A7 %s // RUN: %clang -target aarch64 -mcpu=cortex-a34 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-A34 %s // RUN: %clang -target aarch64 -mcpu=cortex-a35 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-A35 %s // RUN: %clang -target aarch64 -mcpu=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-A53 %s // RUN: %clang -target aarch64 -mcpu=cortex-a57 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-A57 %s // RUN: %clang -target aarch64 -mcpu=cortex-a72 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-A72 %s // RUN: %clang -target aarch64 -mcpu=cortex-a73 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-CORTEX-A73 %s // RUN: %clang -target aarch64 -mcpu=cortex-r82 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-CORTEX-R82 %s // RUN: %clang -target aarch64 -mcpu=exynos-m3 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-M1 %s // RUN: %clang -target aarch64 -mcpu=exynos-m4 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-M4 %s // RUN: %clang -target aarch64 -mcpu=exynos-m5 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-M4 %s // RUN: %clang -target aarch64 -mcpu=kryo -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-KRYO %s // RUN: %clang -target aarch64 -mcpu=thunderx2t99 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-THUNDERX2T99 %s // RUN: %clang -target aarch64 -mcpu=a64fx -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-A64FX %s // RUN: %clang -target aarch64 -mcpu=carmel -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-CARMEL %s // CHECK-MCPU-APPLE-A7: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+fp-armv8" "-target-feature" "+neon" "-target-feature" "+crypto" "-target-feature" "+zcm" "-target-feature" "+zcz" "-target-feature" "+sha2" "-target-feature" "+aes" // CHECK-MCPU-APPLE-A10: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+fp-armv8" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" "+rdm" "-target-feature" "+zcm" "-target-feature" "+zcz" "-target-feature" "+sha2" "-target-feature" "+aes" // CHECK-MCPU-APPLE-A11: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+v8.2a" "-target-feature" "+fp-armv8" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" "+ras" "-target-feature" "+lse" "-target-feature" "+rdm" "-target-feature" "+zcm" "-target-feature" "+zcz" "-target-feature" "+sha2" "-target-feature" "+aes" // CHECK-MCPU-APPLE-A12: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+v8.3a" "-target-feature" "+fp-armv8" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" "+fullfp16" "-target-feature" "+ras" "-target-feature" "+lse" "-target-feature" "+rdm" "-target-feature" "+rcpc" "-target-feature" "+zcm" "-target-feature" "+zcz" "-target-feature" "+sha2" "-target-feature" "+aes" // CHECK-MCPU-A34: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+crc" // CHECK-MCPU-APPLE-A13: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+v8.4a" "-target-feature" "+fp-armv8" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" "+dotprod" "-target-feature" "+fullfp16" "-target-feature" "+ras" "-target-feature" "+lse" "-target-feature" "+rdm" "-target-feature" "+rcpc" "-target-feature" "+zcm" "-target-feature" "+zcz" "-target-feature" "+fp16fml" "-target-feature" "+sm4" "-target-feature" "+sha3" "-target-feature" "+sha2" "-target-feature" "+aes" // CHECK-MCPU-A35: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto" // CHECK-MCPU-A53: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto" // CHECK-MCPU-A57: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto" // CHECK-MCPU-A72: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto" // CHECK-MCPU-CORTEX-A73: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto" // CHECK-MCPU-CORTEX-R82: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+v8r" "-target-feature" "+fp-armv8" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+dotprod" "-target-feature" "+fp16fml" "-target-feature" "+ras" "-target-feature" "+lse" "-target-feature" "+rdm" "-target-feature" "+rcpc" "-target-feature" "+fullfp16" // CHECK-MCPU-M1: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto" // CHECK-MCPU-M4: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" "+dotprod" "-target-feature" "+fullfp16" // CHECK-MCPU-KRYO: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto" // CHECK-MCPU-THUNDERX2T99: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto" // CHECK-MCPU-A64FX: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+v8.2a" "-target-feature" "+fp-armv8" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" "+fullfp16" "-target-feature" "+ras" "-target-feature" "+lse" "-target-feature" "+rdm" "-target-feature" "+sve" "-target-feature" "+sha2" // CHECK-MCPU-CARMEL: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+v8.2a" "-target-feature" "+fp-armv8" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" "+fullfp16" "-target-feature" "+ras" "-target-feature" "+lse" "-target-feature" "+rdm" "-target-feature" "+sha2" "-target-feature" "+aes" // RUN: %clang -target x86_64-apple-macosx -arch arm64 -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-ARCH-ARM64 %s // CHECK-ARCH-ARM64: "-target-cpu" "apple-a12" "-target-feature" "+v8.3a" "-target-feature" "+fp-armv8" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" "+fullfp16" "-target-feature" "+ras" "-target-feature" "+lse" "-target-feature" "+rdm" "-target-feature" "+rcpc" "-target-feature" "+zcm" "-target-feature" "+zcz" // RUN: %clang -target x86_64-apple-macosx -arch arm64_32 -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-ARCH-ARM64_32 %s // CHECK-ARCH-ARM64_32: "-target-cpu" "apple-s4" "-target-feature" "+v8.3a" "-target-feature" "+fp-armv8" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" "+fullfp16" "-target-feature" "+ras" "-target-feature" "+lse" "-target-feature" "+rdm" "-target-feature" "+rcpc" "-target-feature" "+zcm" "-target-feature" "+zcz" "-target-feature" "+sha2" "-target-feature" "+aes" // RUN: %clang -target aarch64 -march=armv8-a+fp+simd+crc+crypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MARCH-1 %s // RUN: %clang -target aarch64 -march=armv8-a+nofp+nosimd+nocrc+nocrypto+fp+simd+crc+crypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MARCH-1 %s // RUN: %clang -target aarch64 -march=armv8-a+nofp+nosimd+nocrc+nocrypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MARCH-2 %s // RUN: %clang -target aarch64 -march=armv8-a+fp+simd+crc+crypto+nofp+nosimd+nocrc+nocrypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MARCH-2 %s // RUN: %clang -target aarch64 -march=armv8-a+nosimd -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MARCH-3 %s // CHECK-MARCH-1: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+fp-armv8" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto" // CHECK-MARCH-2: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "-fp-armv8" "-target-feature" "-neon" "-target-feature" "-crc" "-target-feature" "-crypto" // CHECK-MARCH-3: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "-neon" // Check +sm4: // // RUN: %clang -target aarch64 -march=armv8.2a+sm4 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-SM4 %s // CHECK-SM4: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+v8.2a" "-target-feature" "+sm4" // // Check +sha3: // // RUN: %clang -target aarch64 -march=armv8.2a+sha3 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-SHA3 %s // CHECK-SHA3: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+v8.2a" "-target-feature" "+sha3" // // Check +sha2: // // RUN: %clang -target aarch64 -march=armv8.3a+sha2 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-SHA2 %s // CHECK-SHA2: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+v8.{{.}}a" "-target-feature" "+sha2" // // Check +aes: // // RUN: %clang -target aarch64 -march=armv8.3a+aes -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-AES %s // CHECK-AES: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+v8.{{.}}a" "-target-feature" "+aes" // // Check -sm4: // // RUN: %clang -target aarch64 -march=armv8.2a+noSM4 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NO-SM4 %s // CHECK-NO-SM4: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+v8.2a" "-target-feature" "-sm4" // // Check -sha3: // // RUN: %clang -target aarch64 -march=armv8.2a+noSHA3 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NO-SHA3 %s // CHECK-NO-SHA3: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+v8.2a" "-target-feature" "-sha3" // // Check -sha2: // // RUN: %clang -target aarch64 -march=armv8.2a+noSHA2 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NO-SHA2 %s // CHECK-NO-SHA2: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+v8.2a" "-target-feature" "-sha2" // // Check -aes: // // RUN: %clang -target aarch64 -march=armv8.2a+noAES -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NO-AES %s // CHECK-NO-AES: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+v8.2a" "-target-feature" "-aes" // // // Arch <= ARMv8.3: crypto = sha2 + aes // ------------------------------------- // // Check +crypto: // // RUN: %clang -target aarch64 -march=armv8a+crypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CRYPTO83 %s // RUN: %clang -target aarch64 -march=armv8.1a+crypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CRYPTO83 %s // RUN: %clang -target aarch64 -march=armv8.2a+crypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CRYPTO83 %s // RUN: %clang -target aarch64 -march=armv8.3a+crypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CRYPTO83 %s // RUN: %clang -target aarch64 -march=armv8a+crypto+nocrypto+crypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CRYPTO83 %s // CHECK-CRYPTO83: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+crypto" "-target-feature" "+sha2" "-target-feature" "+aes" // // Check -crypto: // // RUN: %clang -target aarch64 -march=armv8a+nocrypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NOCRYPTO8A %s // RUN: %clang -target aarch64 -march=armv8.1a+nocrypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NOCRYPTO81 %s // RUN: %clang -target aarch64 -march=armv8.2a+nocrypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NOCRYPTO82 %s // RUN: %clang -target aarch64 -march=armv8.3a+nocrypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NOCRYPTO82 %s // RUN: %clang -target aarch64 -march=armv8.3a+nocrypto+crypto+nocrypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NOCRYPTO82 %s // CHECK-NOCRYPTO8A: "-target-feature" "+neon" "-target-feature" "-crypto" "-target-feature" "-sha2" "-target-feature" "-aes" "-target-abi" "aapcs" // CHECK-NOCRYPTO81: "-target-feature" "+neon" "-target-feature" "+v8.1a" "-target-feature" "-crypto" "-target-feature" "-sha2" "-target-feature" "-aes" "-target-abi" "aapcs" // CHECK-NOCRYPTO82: "-target-feature" "+neon" "-target-feature" "+v8.{{.}}a" "-target-feature" "-crypto" "-target-feature" "-sha2" "-target-feature" "-aes" "-target-feature" "-sm4" "-target-feature" "-sha3" "-target-abi" "aapcs" // // Check +crypto -sha2 -aes: // // RUN: %clang -target aarch64 -march=armv8.1a+crypto+nosha2+noaes -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CRYPTO83-NOSHA2-NOAES %s // CHECK-CRYPTO83-NOSHA2-NOAES-NOT: "-target-feature" "+sha2" "-target-feature" "+aes" // // Check -crypto +sha2 +aes: // // RUN: %clang -target aarch64 -march=armv8.1a+nocrypto+sha2+aes -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NOCRYPTO83-SHA2-AES %s // CHECK-NOCRYPTO83-SHA2-AES: "-target-feature" "+sha2" "-target-feature" "+aes" // // // Arch >= ARMv8.4: crypto = sm4 + sha3 + sha2 + aes // -------------------------------------------------- // // Check +crypto: // // RUN: %clang -target aarch64 -march=armv8.4a+crypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CRYPTO84 %s // CHECK-CRYPTO84: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+v8.4a" "-target-feature" "+crypto" "-target-feature" "+sm4" "-target-feature" "+sha3" "-target-feature" "+sha2" "-target-feature" "+aes" // // Check -crypto: // // RUN: %clang -target aarch64 -march=armv8.4a+nocrypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NOCRYPTO84 %s // CHECK-NOCRYPTO84-NOT: "-target-feature" "+crypto" "-target-feature" "+sm4" "-target-feature" "+sha3" "-target-feature" "+sha2" "-target-feature" "+aes" // // Check +crypto -sm4 -sha3: // // RUN: %clang -target aarch64 -march=armv8.4a+crypto+sm4+nosm4+sha3+nosha3 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CRYPTO84-NOSMSHA %s // CHECK-CRYPTO84-NOSMSHA: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+v8.4a" "-target-feature" "+crypto" "-target-feature" "-sm4" "-target-feature" "-sha3" "-target-feature" "+sha2" "-target-feature" "+aes" // // // RUN: %clang -target aarch64 -mcpu=cyclone+nocrypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-1 %s // RUN: %clang -target aarch64 -mcpu=cyclone+crypto+nocrypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-1 %s // RUN: %clang -target aarch64 -mcpu=generic+crc -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-2 %s // RUN: %clang -target aarch64 -mcpu=generic+nocrc+crc -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-2 %s // RUN: %clang -target aarch64 -mcpu=cortex-a53+nosimd -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-3 %s // ================== Check whether -mcpu accepts mixed-case features. // RUN: %clang -target aarch64 -mcpu=cyclone+NOCRYPTO -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-1 %s // RUN: %clang -target aarch64 -mcpu=cyclone+CRYPTO+nocrypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-1 %s // RUN: %clang -target aarch64 -mcpu=generic+Crc -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-2 %s // RUN: %clang -target aarch64 -mcpu=GENERIC+nocrc+CRC -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-2 %s // RUN: %clang -target aarch64 -mcpu=cortex-a53+noSIMD -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-3 %s // CHECK-MCPU-1: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "-crypto" "-target-feature" "+zcm" "-target-feature" "+zcz" // CHECK-MCPU-2: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+crc" // CHECK-MCPU-3: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "-neon" // RUN: %clang -target aarch64 -mcpu=cyclone+nocrc+nocrypto -march=armv8-a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-MARCH %s // RUN: %clang -target aarch64 -march=armv8-a -mcpu=cyclone+nocrc+nocrypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-MARCH %s // CHECK-MCPU-MARCH: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+zcm" "-target-feature" "+zcz" // RUN: %clang -target aarch64 -mcpu=cortex-a53 -mtune=cyclone -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-MTUNE %s // RUN: %clang -target aarch64 -mtune=cyclone -mcpu=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-MTUNE %s // ================== Check whether -mtune accepts mixed-case features. // RUN: %clang -target aarch64 -mcpu=cortex-a53 -mtune=CYCLONE -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-MTUNE %s // RUN: %clang -target aarch64 -mtune=CyclonE -mcpu=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-MTUNE %s // CHECK-MCPU-MTUNE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" "+zcm" "-target-feature" "+zcz" // RUN: %clang -target aarch64 -mcpu=generic+neon -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-ERROR-NEON %s // RUN: %clang -target aarch64 -mcpu=generic+noneon -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-ERROR-NEON %s // RUN: %clang -target aarch64 -march=armv8-a+neon -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-ERROR-NEON %s // RUN: %clang -target aarch64 -march=armv8-a+noneon -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-ERROR-NEON %s // CHECK-ERROR-NEON: error: [no]neon is not accepted as modifier, please use [no]simd instead // RUN: %clang -target aarch64 -march=armv8.1a+crypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V81A-FEATURE-1 %s // RUN: %clang -target aarch64 -march=armv8.1a+nocrypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V81A-FEATURE-2 %s // RUN: %clang -target aarch64 -march=armv8.1a+nosimd -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V81A-FEATURE-3 %s // ================== Check whether -march accepts mixed-case features. // RUN: %clang -target aarch64 -march=ARMV8.1A+CRYPTO -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V81A-FEATURE-1 %s // RUN: %clang -target aarch64 -march=Armv8.1a+NOcrypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V81A-FEATURE-2 %s // RUN: %clang -target aarch64 -march=armv8.1a+noSIMD -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V81A-FEATURE-3 %s // CHECK-V81A-FEATURE-1: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+v8.1a" "-target-feature" "+crypto" // CHECK-V81A-FEATURE-2: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+v8.1a" "-target-feature" "-crypto" // CHECK-V81A-FEATURE-3: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+v8.1a" "-target-feature" "-neon" // ================== Check Memory Tagging Extensions (MTE). // RUN: %clang -target arm64-none-linux-gnu -march=armv8.5-a+memtag -x c -E -dM %s -o - 2>&1 | FileCheck -check-prefix=CHECK-MEMTAG %s // CHECK-MEMTAG: __ARM_FEATURE_MEMORY_TAGGING 1 // ================== Check Pointer Authentication Extension (PAuth). // RUN: %clang -target arm64-none-linux-gnu -march=armv8-a -x c -E -dM %s -o - | FileCheck -check-prefix=CHECK-PAUTH-OFF %s // RUN: %clang -target arm64-none-linux-gnu -march=armv8.5-a -x c -E -dM %s -o - | FileCheck -check-prefix=CHECK-PAUTH-OFF %s // RUN: %clang -target arm64-none-linux-gnu -march=armv8-a -mbranch-protection=none -x c -E -dM %s -o - | FileCheck -check-prefix=CHECK-PAUTH-OFF %s // RUN: %clang -target arm64-none-linux-gnu -march=armv8-a -mbranch-protection=bti -x c -E -dM %s -o - | FileCheck -check-prefix=CHECK-PAUTH-OFF %s // RUN: %clang -target arm64-none-linux-gnu -march=armv8-a -mbranch-protection=standard -x c -E -dM %s -o - | FileCheck -check-prefix=CHECK-PAUTH %s // RUN: %clang -target arm64-none-linux-gnu -march=armv8-a -mbranch-protection=pac-ret -x c -E -dM %s -o - | FileCheck -check-prefix=CHECK-PAUTH %s // RUN: %clang -target arm64-none-linux-gnu -march=armv8-a -mbranch-protection=pac-ret+b-key -x c -E -dM %s -o - | FileCheck -check-prefix=CHECK-PAUTH-BKEY %s // RUN: %clang -target arm64-none-linux-gnu -march=armv8-a -mbranch-protection=pac-ret+leaf -x c -E -dM %s -o - | FileCheck -check-prefix=CHECK-PAUTH-ALL %s // RUN: %clang -target arm64-none-linux-gnu -march=armv8-a -mbranch-protection=pac-ret+leaf+b-key -x c -E -dM %s -o - | FileCheck -check-prefix=CHECK-PAUTH-BKEY-ALL %s // CHECK-PAUTH-OFF-NOT: __ARM_FEATURE_PAC_DEFAULT // CHECK-PAUTH: #define __ARM_FEATURE_PAC_DEFAULT 1 // CHECK-PAUTH-BKEY: #define __ARM_FEATURE_PAC_DEFAULT 2 // CHECK-PAUTH-ALL: #define __ARM_FEATURE_PAC_DEFAULT 5 // CHECK-PAUTH-BKEY-ALL: #define __ARM_FEATURE_PAC_DEFAULT 6 // ================== Check Branch Target Identification (BTI). // RUN: %clang -target arm64-none-linux-gnu -march=armv8-a -x c -E -dM %s -o - | FileCheck -check-prefix=CHECK-BTI-OFF %s // RUN: %clang -target arm64-none-linux-gnu -march=armv8.5-a -x c -E -dM %s -o - | FileCheck -check-prefix=CHECK-BTI-OFF %s // RUN: %clang -target arm64-none-linux-gnu -march=armv8-a -mbranch-protection=none -x c -E -dM %s -o - | FileCheck -check-prefix=CHECK-BTI-OFF %s // RUN: %clang -target arm64-none-linux-gnu -march=armv8-a -mbranch-protection=pac-ret -x c -E -dM %s -o - | FileCheck -check-prefix=CHECK-BTI-OFF %s // RUN: %clang -target arm64-none-linux-gnu -march=armv8-a -mbranch-protection=pac-ret+leaf -x c -E -dM %s -o - | FileCheck -check-prefix=CHECK-BTI-OFF %s // RUN: %clang -target arm64-none-linux-gnu -march=armv8-a -mbranch-protection=pac-ret+b-key -x c -E -dM %s -o - | FileCheck -check-prefix=CHECK-BTI-OFF %s // RUN: %clang -target arm64-none-linux-gnu -march=armv8-a -mbranch-protection=pac-ret+leaf+b-key -x c -E -dM %s -o - | FileCheck -check-prefix=CHECK-BTI-OFF %s // RUN: %clang -target arm64-none-linux-gnu -march=armv8-a -mbranch-protection=standard -x c -E -dM %s -o - | FileCheck -check-prefix=CHECK-BTI %s // RUN: %clang -target arm64-none-linux-gnu -march=armv8-a -mbranch-protection=bti -x c -E -dM %s -o - | FileCheck -check-prefix=CHECK-BTI %s // RUN: %clang -target arm64-none-linux-gnu -march=armv8-a -mbranch-protection=pac-ret+bti -x c -E -dM %s -o - | FileCheck -check-prefix=CHECK-BTI %s // CHECK-BTI-OFF-NOT: __ARM_FEATURE_BTI_DEFAULT // CHECK-BTI: #define __ARM_FEATURE_BTI_DEFAULT 1 // ================== Check BFloat16 Extensions. // RUN: %clang -target aarch64-arm-none-eabi -march=armv8.6-a+bf16 -x c -E -dM %s -o - 2>&1 | FileCheck -check-prefix=CHECK-BFLOAT %s // CHECK-BFLOAT: __ARM_BF16_FORMAT_ALTERNATIVE 1 // CHECK-BFLOAT: __ARM_FEATURE_BF16 1 // CHECK-BFLOAT: __ARM_FEATURE_BF16_VECTOR_ARITHMETIC 1 // ================== Check sve-vector-bits flag. // RUN: %clang -target aarch64-arm-none-eabi -march=armv8-a+sve -msve-vector-bits=128 -x c -E -dM %s -o - 2>&1 | FileCheck -check-prefix=CHECK-SVE-VECTOR-BITS -D#VBITS=128 %s // RUN: %clang -target aarch64-arm-none-eabi -march=armv8-a+sve -msve-vector-bits=256 -x c -E -dM %s -o - 2>&1 | FileCheck -check-prefix=CHECK-SVE-VECTOR-BITS -D#VBITS=256 %s // RUN: %clang -target aarch64-arm-none-eabi -march=armv8-a+sve -msve-vector-bits=512 -x c -E -dM %s -o - 2>&1 | FileCheck -check-prefix=CHECK-SVE-VECTOR-BITS -D#VBITS=512 %s // RUN: %clang -target aarch64-arm-none-eabi -march=armv8-a+sve -msve-vector-bits=1024 -x c -E -dM %s -o - 2>&1 | FileCheck -check-prefix=CHECK-SVE-VECTOR-BITS -D#VBITS=1024 %s // RUN: %clang -target aarch64-arm-none-eabi -march=armv8-a+sve -msve-vector-bits=2048 -x c -E -dM %s -o - 2>&1 | FileCheck -check-prefix=CHECK-SVE-VECTOR-BITS -D#VBITS=2048 %s // CHECK-SVE-VECTOR-BITS: __ARM_FEATURE_SVE_BITS [[#VBITS:]] // CHECK-SVE-VECTOR-BITS: __ARM_FEATURE_SVE_VECTOR_OPERATORS 1 // ================== Check Largse System Extensions (LSE) // RUN: %clang -target aarch64-none-linux-gnu -march=armv8-a+lse -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-LSE %s // RUN: %clang -target arm64-none-linux-gnu -march=armv8-a+lse -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-LSE %s // RUN: %clang -target aarch64-none-linux-gnu -march=armv8.1-a -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-LSE %s // RUN: %clang -target arm64-none-linux-gnu -march=armv8.1-a -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-LSE %s // CHECK-LSE: __ARM_FEATURE_ATOMICS 1
the_stack_data/215768175.c
#include <ctype.h> #include <errno.h> #include <limits.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> #define xstr(s) str(s) #define str(s) #s #define ARRAY_ELEMENTS(x) (sizeof(x) / sizeof(x[0])) #define CALL_ARGUMENTS_LIMIT UINT_MAX static jmp_buf ex_buf; enum s_expr_type { ATOM, CELL, }; typedef struct s_expr { enum s_expr_type type; void *expr; } S_Expr; typedef struct cell { struct s_expr *left; struct s_expr *right; } Cell; enum atomic_val_types { STRING, NUMBER, BOOLEAN, NIL, EXPR, FEXPR, SUBR, FSUBR, }; enum param_types { PTYPE_ANY, PTYPE_ATOM, PTYPE_CELL, }; typedef struct atom { enum atomic_val_types type; unsigned int len; /* additional length info for strings, and expr/subr params */ enum param_types ptype; struct s_expr *args_bind_names; char *pname; void *apval; struct s_expr *expr; struct s_expr *fexpr; void *subr; struct s_expr *(*fsubr)(struct s_expr *symbol_table, struct s_expr *e); } Atom; // NIL expr & atom static Atom nil_atom = { .len = 0, .apval = NULL, .type = NIL, }; static S_Expr nil_s_expr = { .type = ATOM, .expr = (void *)&nil_atom, }; // Boolean constants // static const bool true_val = true; static const bool false_val = false; static Atom true_atom = { .apval = (void *)&true_val, .type = BOOLEAN, }; static S_Expr true_s_expr = { .type = ATOM, .expr = (void *)&true_atom, }; static Atom false_atom = { .apval = (void *)&false_val, .type = BOOLEAN, }; static S_Expr false_s_expr = { .type = ATOM, .expr = (void *)&false_atom, }; // system function declarations S_Expr *cons(S_Expr *left, S_Expr *right); S_Expr *cons2(S_Expr *left, S_Expr *right); S_Expr *car(S_Expr *e); S_Expr *cdr(S_Expr *e); S_Expr *eq(S_Expr *e1, S_Expr *e2); S_Expr *equal(S_Expr *e1, S_Expr *e2); S_Expr *atom(S_Expr *e); S_Expr *quote(S_Expr *e); S_Expr *append(S_Expr *list, S_Expr *new_elem); S_Expr *label(S_Expr **table, S_Expr *lab, S_Expr *e); S_Expr *lambda(S_Expr *args, S_Expr *e); S_Expr *flambda(S_Expr *args, S_Expr *e); S_Expr *cond(S_Expr *symbol_table, S_Expr *args); S_Expr *assoc(S_Expr *x, S_Expr *a); // other user-accessible functions S_Expr *plus(S_Expr *numbers_l); S_Expr *minus(S_Expr *numbers_l); S_Expr *multiply(S_Expr *numbers_l); S_Expr *divide(S_Expr *numbers_l); S_Expr *lt(S_Expr *numbers_l); S_Expr *gt(S_Expr *numbers_l); S_Expr *print(S_Expr *e); // other function declarations: S_Expr *setq(S_Expr *expr, S_Expr *val); void print_s_expr(S_Expr *se); enum print_parent_t { PRINT_PARENT_NONE, PRINT_PARENT_CELL_LEFT, PRINT_PARENT_CELL_RIGHT }; void __print_s_expr(S_Expr *se, enum print_parent_t pr_parent); // evaluation functions: // S_Expr * apply(S_Expr * fn, S_Expr * args, S_Expr * symbol_table); S_Expr *apply(S_Expr *fn, S_Expr *args, S_Expr *symbol_table, bool maybe_from_list_constructor, bool args_were_list); S_Expr *eval(S_Expr *e, S_Expr **symbol_table); // S_Expr * evcon(S_Expr * c, S_Expr * a); S_Expr *evlis(S_Expr *e, S_Expr *symbol_table); // // global symbols static S_Expr *global_symbols_table; enum sym_defs { /* fundamental functions */ CAR_SYM_DEF, CDR_SYM_DEF, CONS_SYM_DEF, ATOM_SYM_DEF, EQ_SYM_DEF, /* other functions */ QUOTE_SYM_DEF, LABEL_SYM_DEF, LAMBDA_SYM_DEF, FLAMBDA_SYM_DEF, COND_SYM_DEF, /* */ EVAL_SYM_DEF, /* */ PLUS_SYM_DEF, MINUS_SYM_DEF, MULTIPLY_SYM_DEF, DIVIDE_SYM_DEF, LT_SYM_DEF, GT_SYM_DEF, PRINT_SYM_DEF, /* end */ MAX_SYM_DEF }; Atom car_atom_sym_def = { .pname = "CAR", .subr = car, .type = SUBR, .len = CALL_ARGUMENTS_LIMIT, .ptype = PTYPE_CELL, }; Atom cdr_atom_sym_def = { .pname = "CDR", .subr = cdr, .type = SUBR, .len = CALL_ARGUMENTS_LIMIT, .ptype = PTYPE_CELL, }; Atom cons_atom_sym_def = { .pname = "CONS", .subr = cons2, .type = SUBR, .len = 2, .ptype = PTYPE_ANY, }; Atom atom_atom_sym_def = { .pname = "ATOM", .subr = atom, .type = SUBR, .len = CALL_ARGUMENTS_LIMIT, .ptype = PTYPE_ANY, }; Atom eq_atom_sym_def = { .pname = "EQ", .subr = eq, .type = SUBR, .len = 2, }; Atom quote_atom_sym_def = { .pname = "QUOTE", .subr = quote, .type = SUBR, .len = 1, // CALL_ARGUMENTS_LIMIT, }; Atom label_atom_sym_def = { .pname = "LABEL", .subr = atom, .type = SUBR, .len = 2, }; Atom lambda_atom_sym_def = { .pname = "LAMBDA", .subr = lambda, .type = SUBR, .len = 2, }; Atom flambda_atom_sym_def = { .pname = "FLAMBDA", .subr = flambda, .type = SUBR, .len = 2, }; Atom cond_atom_sym_def = { /** * COND here is an FSUBR, as it is a special form. * remember: a special form has an arbitrary number of * arguments, and its arguments are not evaluated * beforehand. */ .pname = "COND", .fsubr = cond, .type = FSUBR, }; Atom eval_atom_sym_def = { .pname = "EVAL", .subr = eval, .type = SUBR, .len = CALL_ARGUMENTS_LIMIT, }; // --------------------------------- // // --------------------------------- Atom plus_atom_sym_def = { .pname = "+", .subr = plus, .type = SUBR, .len = CALL_ARGUMENTS_LIMIT, }; Atom minus_atom_sym_def = { .pname = "-", .subr = minus, .type = SUBR, .len = CALL_ARGUMENTS_LIMIT, }; Atom multiply_atom_sym_def = { .pname = "*", .subr = multiply, .type = SUBR, .len = CALL_ARGUMENTS_LIMIT, }; Atom divide_atom_sym_def = { .pname = "/", .subr = divide, .type = SUBR, .len = CALL_ARGUMENTS_LIMIT, }; Atom lt_atom_sym_def = { .pname = "<", .subr = lt, .type = SUBR, .len = 2, }; Atom gt_atom_sym_def = { .pname = ">", .subr = gt, .type = SUBR, .len = 2, }; Atom print_atom_sym_def = { .pname = "print", .subr = print, .type = SUBR, .len = 1, }; S_Expr subr_symbol_defs[MAX_SYM_DEF] = { [CAR_SYM_DEF] = { .type = ATOM, .expr = &car_atom_sym_def, }, [CDR_SYM_DEF] = { .type = ATOM, .expr = &cdr_atom_sym_def, }, [CONS_SYM_DEF] = { .type = ATOM, .expr = &cons_atom_sym_def, }, [ATOM_SYM_DEF] = { .type = ATOM, .expr = &atom_atom_sym_def, }, [EQ_SYM_DEF] = { .type = ATOM, .expr = &eq_atom_sym_def, }, /* --- */ [QUOTE_SYM_DEF] = { .type = ATOM, .expr = &quote_atom_sym_def, }, [LABEL_SYM_DEF] = { .type = ATOM, .expr = &label_atom_sym_def, }, [LAMBDA_SYM_DEF] = { .type = ATOM, .expr = &lambda_atom_sym_def, }, [FLAMBDA_SYM_DEF] = { .type = ATOM, .expr = &flambda_atom_sym_def, }, [COND_SYM_DEF] = { .type = ATOM, .expr = &cond_atom_sym_def, }, [EVAL_SYM_DEF] = { .type = ATOM, .expr = &eval_atom_sym_def, }, [PLUS_SYM_DEF] = { .type = ATOM, .expr = &plus_atom_sym_def, }, [MINUS_SYM_DEF] = { .type = ATOM, .expr = &minus_atom_sym_def, }, [MULTIPLY_SYM_DEF] = { .type = ATOM, .expr = &multiply_atom_sym_def, }, [DIVIDE_SYM_DEF] = { .type = ATOM, .expr = &divide_atom_sym_def, }, [LT_SYM_DEF] = { .type = ATOM, .expr = &lt_atom_sym_def, }, [GT_SYM_DEF] = { .type = ATOM, .expr = &gt_atom_sym_def, }, [PRINT_SYM_DEF] = { .type = ATOM, .expr = &print_atom_sym_def, }, }; S_Expr *car_fn_symbol = 0; S_Expr *cdr_fn_symbol = 0; S_Expr *cons_fn_symbol = 0; S_Expr *atom_fn_symbol = 0; S_Expr *eq_fn_symbol = 0; S_Expr *quote_fn_symbol = 0; S_Expr *label_fn_symbol = 0; S_Expr *lambda_fn_symbol = 0; S_Expr *flambda_fn_symbol = 0; S_Expr *cond_fn_symbol = 0; S_Expr *eval_fn_symbol = 0; S_Expr *plus_fn_symbol = 0; S_Expr *minus_fn_symbol = 0; S_Expr *multiply_fn_symbol = 0; S_Expr *divide_fn_symbol = 0; S_Expr *lt_fn_symbol = 0; S_Expr *gt_fn_symbol = 0; S_Expr *print_fn_symbol = 0; // VM memory definitions // #define MEM_SEGMENT_SIZE (1024 * 16) // 16k per segment size #define MEM_NUM_SEGMENTS 64 static uint8_t mem_segments[MEM_NUM_SEGMENTS][MEM_SEGMENT_SIZE]; static unsigned int mem_segments_ixs[MEM_NUM_SEGMENTS] = {0}; static uint8_t mem_segment_i = 0; //----------------------------------------------------------------------------- // Exception handling //----------------------------------------------------------------------------- void jinni_exception_no_msg(void) { mem_segment_i = 0; longjmp(ex_buf, 1); } void jinni_exception(const char *fmt, ...) { printf("\nException: "); va_list args; va_start(args, fmt); vprintf(fmt, args); va_end(args); printf("\n"); fflush(stdout); jinni_exception_no_msg(); } //----------------------------------------------------------------------------- // VM //----------------------------------------------------------------------------- void free_mem_segment(int s) { mem_segments_ixs[s] = 0; return; } void free_mem_segments(int from, int to) { for (int i = from; i < to; i++) mem_segments_ixs[i] = 0; return; } void *jinni_malloc(size_t size) { if (mem_segment_i >= MEM_NUM_SEGMENTS || (mem_segments_ixs[mem_segment_i] + size) >= MEM_SEGMENT_SIZE) { jinni_exception("jinni_malloc -- size: %lu, mem_segment_i: %u. " "mem_segments_ixs[mem_segment_i]: %u\n", size, mem_segment_i, mem_segments_ixs[mem_segment_i]); } void *p = (void *)(&mem_segments[mem_segment_i][mem_segments_ixs[mem_segment_i]]); memset(p, 0x0, size); mem_segments_ixs[mem_segment_i] += size; return p; } //void *jinni_malloc_dbg(size_t size, char const *caller_name) //{ //printf("jinni_malloc was called from %s\n", caller_name); //return jinni_malloc(size); //} //#define jinni_malloc(x) jinni_malloc_dbg(x, __func__) void jinni_free(void *ptr) { // Not implemented :-P return; } //----------------------------------------------------------------------------- // misc. helpers //----------------------------------------------------------------------------- //#define PRINT_DBG_INFO static void print_debug_info(const char *dbg_msg, S_Expr *e) { #ifdef PRINT_DBG_INFO fprintf(stdout, "\n======\n"); if (dbg_msg && dbg_msg[0] != 0) printf("%s\n", dbg_msg); if (e) print_s_expr(e); fprintf(stdout, "\n======\n"); fflush(stdout); #endif // PRINT_DBG_INFO return; } static unsigned int list_len(S_Expr *args); bool is_atom(S_Expr *e) { return (e->type == ATOM); } static S_Expr *copy_list(S_Expr *l) { #define COPY_PNAME \ if (a2->pname) { \ a->pname = jinni_malloc(sizeof(char) * (strlen(a2->pname) + 1)); \ strcpy(a->pname, a2->pname); \ } if (!l) // <-- why? return NULL; S_Expr *se = jinni_malloc(sizeof(S_Expr)); if (l->type == ATOM) { Atom *a = jinni_malloc(sizeof(Atom)); Atom *a2 = (Atom *)(l->expr); a->type = a2->type; switch (a->type) { case STRING: a->apval = jinni_malloc(sizeof(char) * (strlen((char *)a2->apval) + 1)); strcpy((char *)a->apval, (char *)a2->apval); break; case NUMBER: a->apval = jinni_malloc(sizeof(double)); *((double *)(a->apval)) = *((double *)(a2->apval)); break; case BOOLEAN: a->apval = jinni_malloc(sizeof(bool)); *((bool *)(a->apval)) = *((bool *)(a2->apval)); break; case NIL: a->apval = NULL; break; case EXPR: a->expr = copy_list(a2->expr); COPY_PNAME a->len = a2->len; if (a2->args_bind_names) a->args_bind_names = copy_list(a2->args_bind_names); break; case FEXPR: a->fexpr = copy_list(a2->fexpr); COPY_PNAME a->len = a2->len; if (a2->args_bind_names) a->args_bind_names = copy_list(a2->args_bind_names); break; case SUBR: COPY_PNAME a->len = a2->len; if (a2->pname) { a->pname = jinni_malloc(sizeof(char) * (strlen(a2->pname) + 1)); strcpy(a->pname, a2->pname); } a->subr = a2->subr; break; case FSUBR: COPY_PNAME a->len = a2->len; a->fsubr = a2->fsubr; break; default: jinni_exception("unknown atom type: %d", a->type); } a->len = a2->len; se->expr = (void *)a; } else if (l->type == CELL) { Cell *c = jinni_malloc(sizeof(Cell)); if ((Cell *)(l->expr) != NULL) { if (((Cell *)(l->expr))->left != NULL) c->left = copy_list(((Cell *)(l->expr))->left); if (((Cell *)(l->expr))->right != NULL) c->right = copy_list(((Cell *)(l->expr))->right); } else { ; // maybe this is ok for the plist entry edge case } se->expr = (void *)c; } else { // this should never happen // but ok for plist entry edge case ; } se->type = l->type; return se; } S_Expr *make_atom() { S_Expr *se = jinni_malloc(sizeof(S_Expr)); Atom *a = jinni_malloc(sizeof(Atom)); a->len = 0; a->apval = NULL; a->type = NIL; se->type = ATOM; se->expr = (void *)a; return se; } S_Expr *make_bool_atom(bool v) { S_Expr *se = make_atom(); ((Atom *)(se->expr))->type = BOOLEAN; ((Atom *)(se->expr))->apval = jinni_malloc(sizeof(bool)); *(bool *)(((Atom *)(se->expr))->apval) = v; return se; } S_Expr *make_number_atom(double v) { S_Expr *se = make_atom(); ((Atom *)(se->expr))->type = NUMBER; ((Atom *)(se->expr))->apval = jinni_malloc(sizeof(double)); *(double *)(((Atom *)(se->expr))->apval) = v; return se; } S_Expr *make_string_atom(const char *s, unsigned int s_len) { S_Expr *se = make_atom(); ((Atom *)(se->expr))->type = STRING; ((Atom *)(se->expr))->apval = jinni_malloc((s_len + 1) * sizeof(char)); ((Atom *)(se->expr))->len = s_len; strcpy(((Atom *)(se->expr))->apval, s); return se; } bool equal_internal(S_Expr *e1, S_Expr *e2) { if (e1 == NULL && e2 == NULL) return true; else if (e1 == NULL) return false; else if (e1->type != e2->type) return false; switch (e1->type) { case ATOM:; // NOP Atom *a1 = (Atom *)e1->expr; Atom *a2 = e2->expr; if (a1->type != a2->type) { return false; } else if (a1->len != a2->len) { return false; } else { switch (a1->type) { case STRING: case NUMBER: case BOOLEAN: case NIL: if (sizeof(a1->apval) != sizeof(a2->apval)) return false; else if (a1->apval == NULL && a2->apval == NULL) return true; else if (a1->apval == NULL) return false; else if (0 != memcmp(a1->apval, a2->apval, sizeof(*a1->apval))) return false; return true; case EXPR: return equal_internal(a1->expr, a2->expr); case FEXPR: return equal_internal(a1->fexpr, a2->fexpr); case SUBR: if (a1->subr == a2->subr) return true; return false; case FSUBR: if (a1->fsubr == a2->fsubr) return true; return false; } } break; case CELL:; // NOP Cell *c1 = e1->expr; Cell *c2 = e2->expr; return (equal_internal(c1->left, c2->left) && equal_internal(c1->right, c2->right)); default: jinni_exception("inconsistent element type in %s", __FUNCTION__); } return false; } bool is_nil_atom(S_Expr *s_expr_a) { bool res = equal_internal(s_expr_a, &nil_s_expr); return res; } S_Expr *setq(S_Expr *expr, S_Expr *val) { expr->expr = copy_list(val); expr->type = val->type; return expr->expr; } //----------------------------------------------------------------------------- // ??? //----------------------------------------------------------------------------- void __print_s_expr(S_Expr *se, enum print_parent_t pr_parent) { if (!se) jinni_exception("unexpected null s-expression"); if (se->type == ATOM) { { Atom *a = (Atom *)se->expr; switch (a->type) { case STRING: printf("%s", (char *)a->apval); break; case NUMBER:; double val = *((double *)a->apval); if ((val - (int)val) != 0) printf("%f", val); else printf("%d", (int)val); break; case BOOLEAN: printf("%c", *((bool *)a->apval) ? 'T' : 'F'); break; case NIL: printf("NIL"); break; case EXPR: printf("%s", a->pname); break; case FEXPR: printf("%s", a->pname); break; case SUBR: printf("%s", a->pname); break; case FSUBR: printf("%s", a->pname); break; default: jinni_exception("inconsistent type in atom (%d)", a->type); } } } else if (se->type == CELL) { Cell *c = (Cell *)se->expr; if (pr_parent == PRINT_PARENT_NONE || pr_parent == PRINT_PARENT_CELL_LEFT) printf("("); __print_s_expr(c->left, PRINT_PARENT_CELL_LEFT); if (is_atom(c->right)) { if (!is_nil_atom(c->right)) { printf(" . "); __print_s_expr(c->right, PRINT_PARENT_CELL_RIGHT); } } else { printf(" "); __print_s_expr(c->right, PRINT_PARENT_CELL_RIGHT); } if (pr_parent == PRINT_PARENT_NONE || pr_parent == PRINT_PARENT_CELL_LEFT) printf(")"); } else { jinni_exception("undefined type for s-expression"); } return; } void print_s_expr(S_Expr *se) { if (!se) { printf("NIL (null s-expr)\n"); return; } if (se->type == ATOM) { printf("atom: "); Atom *a = (Atom *)se->expr; if (a->pname) printf("(:pname %s) ", a->pname); switch (a->type) { case STRING: printf("%s ", (char *)a->apval); break; case NUMBER: printf("%f ", *((double *)a->apval)); break; case BOOLEAN: printf("%c ", *((bool *)a->apval) ? 'T' : 'F'); break; case NIL: printf("NIL "); break; case EXPR: printf("EXPR: %s - ", a->pname); print_s_expr(a->expr); if (a->args_bind_names) { printf("bind_names: "); print_s_expr(a->args_bind_names); } break; case FEXPR: printf("FEXPR: %s - ", a->pname); print_s_expr(a->fexpr); if (a->args_bind_names) { printf("bind_names: "); print_s_expr(a->args_bind_names); } break; case SUBR: printf("SUBR: %s - %p", a->pname, a->subr); break; case FSUBR: printf("FSUBR: %s - %p", a->pname, (void *)a->fsubr); break; default: printf("err: inconsistent type in atom (%d)\n", a->type); } } else if (se->type == CELL) { printf("[cell: "); Cell *c = (Cell *)se->expr; print_s_expr(c->left); printf(", "); print_s_expr(c->right); printf("] "); } else { printf("undefined type for s-expression\n"); } return; } //----------------------------------------------------------------------------- // system functions //----------------------------------------------------------------------------- /** * `cons` has two arguments and is in fact the function that is used * to build S-expressions from smaller S-expressions. * */ S_Expr *cons(S_Expr *left, S_Expr *right) { S_Expr *se = jinni_malloc(sizeof(S_Expr)); se->type = CELL; Cell *c = jinni_malloc(sizeof(Cell)); c->left = left; c->right = right; se->expr = c; return se; } S_Expr *cons2(S_Expr *left, S_Expr *right) { S_Expr *l = left, *r = right; if (!is_atom(left) && list_len(left) == 1 && is_nil_atom(((Cell *)left->expr)->right)) { l = ((Cell *)left->expr)->left; } if (!is_atom(right) && list_len(right) == 1 && is_nil_atom(((Cell *)right->expr)->left) && is_nil_atom(((Cell *)right->expr)->right)) { // this means that, differently from CL, given // the expresion `(cons nil (cons nil nil))` // we will evaluate to `(NIL)` instead of `(NIL NIL)`. // // I am not totally convinced this is wrong per se, // so leaving it like this for now. // r = &nil_s_expr; } S_Expr *se = jinni_malloc(sizeof(S_Expr)); se->type = CELL; Cell *c = jinni_malloc(sizeof(Cell)); c->left = copy_list(l); c->right = copy_list(r); se->expr = c; return se; } /** * `car` has one argument. Its value is the first part of its * composite argument. `car` of an atomic symbol is undefined. * */ S_Expr *car(S_Expr *e) { if (is_atom(e)) { return e; } return (((Cell *)(e->expr))->left); } /** * `cdr` has one argument. Its value is the second part of its * composite argument. `cdr` is also undefined if its argument is atomic. * */ S_Expr *cdr(S_Expr *e) { if (is_atom(e)) { return &nil_s_expr; } return (((Cell *)(e->expr))->right); } /** * the predicate `eq` is a test for equality on atomic symbols. * It is undefined for non-atomic arguments. */ S_Expr *eq(S_Expr *e1, S_Expr *e2) { if (!is_atom(e1) || !is_atom(e2)) { jinni_exception("eq called on non-atomic arguments"); } return make_bool_atom(equal_internal(e1, e2)); } /** * * */ S_Expr *equal(S_Expr *e1, S_Expr *e2) { return make_bool_atom(equal_internal(e1, e2)); } /** * the predicate `atom` is true if its argument is an atomic symbol, * and false if its arguments is composite. */ S_Expr *atom(S_Expr *e) { return make_bool_atom(is_atom(e)); } S_Expr *quote(S_Expr *e) { S_Expr *qe = e; return qe; } S_Expr *quote_internal(S_Expr *e) { S_Expr *qe = make_atom(); ((Atom *)(qe->expr))->type = EXPR; ((Atom *)(qe->expr))->expr = e; return qe; } S_Expr *append(S_Expr *list, S_Expr *new_elem) { if (is_nil_atom(list)) return new_elem; return (cons(car(list), append(cdr(list), new_elem))); } S_Expr *label(S_Expr **table, S_Expr *lab, S_Expr *e) { // `lab` here is expected to be an identifier atom if (!is_atom(lab)) jinni_exception("expected an identifier atom in %s", __FUNCTION__); Atom *a = (Atom *)lab->expr; if (a->type != STRING) jinni_exception("identifier atom is not a label in %s", __FUNCTION__); S_Expr *lc = lab; S_Expr *ec = e; S_Expr *t2 = append((*table), cons(cons(lc, ec), &nil_s_expr)); *table = t2; return lc; } static unsigned int list_len(S_Expr *args) { if (is_atom(args)) { return 0; } int len = 0; Cell *c = (Cell *)args->expr; while (c->right && !is_atom(c->right)) { len++; c = (Cell *)c->right; } // for a cell, len is always _at least_ 1 if (len == 0) len = 1; // plus if right side is not nil... although this is questionable... if (c->right && !is_nil_atom(c->right)) len++; return len; } S_Expr *lambda(S_Expr *args, S_Expr *e) { if (is_atom(e)) // e MUST be a cell (cons'ed atoms) jinni_exception("expression MUST be a cell in %s", __FUNCTION__); /** * * an example from the manual: * * (LABEL EQUAL (LAMBDA (X Y) (COND * ((ATOM X) (COND ((ATOM Y) (EQ X Y)) ((QUOTE T) (QUOTE F)))) * ((EQUAL (CAR X) (CAR Y)) (EQUAL (CDR X) (CDR Y))) * ((QUOTE T) (QUOTE F))))) **/ // meaning lambda returns something quoted (or the current implementation // of label in jq is wrong... either way... :P ) S_Expr *l_ex = make_atom(); Atom *l_at = (Atom *)l_ex->expr; l_at->type = EXPR; l_at->expr = e; if (is_nil_atom(args)) return l_ex; else if (is_atom(args)) // args MUST be a cell (a list!) jinni_exception("arguments expected to be a list in %s", __FUNCTION__); l_at->len = list_len(args); // args has the name of the arguments that will need to be bound, // so make sure to save them somewhere in the l_at atom here... l_at->args_bind_names = args; // lambda needs to do nothing else, the expression e that uses // potentially unbound values is not evaluated here, and when // an atom with type EXPR is found by `apply` it will try // to find and bind the arguments for the expr. return l_ex; } S_Expr *flambda(S_Expr *args, S_Expr *e) { if (is_atom(args)) // args MUST be a cell (a list!) jinni_exception("arguments expected to be a list in %s", __FUNCTION__); if (is_atom(e)) // e MUST be a cell (cons'ed atoms) jinni_exception("expression MUST be a cell (cons'ed atoms) in %s", __FUNCTION__); S_Expr *fl_ex = make_atom(); Atom *fl_at = (Atom *)fl_ex->expr; fl_at->type = FEXPR; fl_at->fexpr = e; fl_at->len = list_len(args); fl_at->args_bind_names = args; return fl_ex; } S_Expr *cond(S_Expr *symbol_table, S_Expr *args) { if (!args || is_nil_atom(args)) return &nil_s_expr; else if (is_atom(args)) return eval(args, &symbol_table); S_Expr *ev_res = eval(car(car(args)), &symbol_table); // NIL translates to `false` for conditionals. // // Note that `cond` is the only function that really // has to know this, for all the rest this shouldn't // ever matter. if (is_nil_atom(ev_res)) { ev_res = &false_s_expr; } // Everything that's not explicitly `false` (or NIL) // is true for cond... if (!equal_internal(ev_res, &false_s_expr)) { S_Expr *r = eval(cdr(car(args)), &symbol_table); return r; } return cond(symbol_table, cdr(args)); } //----------------------------------------------------------------------------- // other user-accessible functions //----------------------------------------------------------------------------- double plus_internal(double acc, S_Expr *numbers_l) { if (is_nil_atom(numbers_l)) return acc; Atom *atom_val; if (is_atom(numbers_l)) { atom_val = numbers_l->expr; } else { if (is_atom(car(numbers_l))) { atom_val = (Atom *)(car(numbers_l)->expr); } else { jinni_exception("invalid arguments passed to +"); } } if (atom_val->type != NUMBER) { jinni_exception("non-number passed to plus"); } acc += *((double *)atom_val->apval); return plus_internal(acc, cdr(numbers_l)); } S_Expr *plus(S_Expr *numbers_l) { return make_number_atom(plus_internal(0, numbers_l)); } double minus_internal(double acc, S_Expr *numbers_l) { if (is_nil_atom(numbers_l)) return acc; Atom *atom_val; if (is_atom(numbers_l)) { atom_val = numbers_l->expr; } else { if (is_atom(car(numbers_l))) { atom_val = (Atom *)(car(numbers_l)->expr); } else { jinni_exception("invalid arguments passed to -"); } } if (atom_val->type != NUMBER) { jinni_exception("non-number passed to minus"); } acc -= *((double *)atom_val->apval); return minus_internal(acc, cdr(numbers_l)); } S_Expr *minus(S_Expr *numbers_l) { S_Expr *n = car(numbers_l); if (!is_atom(n)) { jinni_exception("invalid arguments passed to minus"); } Atom *a = n->expr; if (a->type != NUMBER) { jinni_exception("non-number passed to minus"); } return make_number_atom( minus_internal(*((double *)a->apval), cdr(numbers_l))); } double multiply_internal(double acc, S_Expr *numbers_l) { if (is_nil_atom(numbers_l)) return acc; Atom *atom_val; if (is_atom(numbers_l)) { atom_val = numbers_l->expr; } else { if (is_atom(car(numbers_l))) { atom_val = (Atom *)(car(numbers_l)->expr); } else { jinni_exception("invalid arguments passed to *"); } } if (atom_val->type != NUMBER) { jinni_exception("non-number passed to multiply"); } acc *= *((double *)atom_val->apval); return multiply_internal(acc, cdr(numbers_l)); } S_Expr *multiply(S_Expr *numbers_l) { S_Expr *n = car(numbers_l); if (!is_atom(n)) { jinni_exception("invalid arguments passed to multiply"); } Atom *a = n->expr; if (a->type != NUMBER) { jinni_exception("non-number passed to multiply"); } return make_number_atom( multiply_internal(*((double *)a->apval), cdr(numbers_l))); } double divide_internal(double acc, S_Expr *numbers_l) { if (is_nil_atom(numbers_l)) return acc; Atom *atom_val; if (is_atom(numbers_l)) { atom_val = numbers_l->expr; } else { if (is_atom(car(numbers_l))) { atom_val = (Atom *)(car(numbers_l)->expr); } else { jinni_exception("invalid arguments passed to /"); } } if (atom_val->type != NUMBER) { jinni_exception("non-number passed to divide"); } acc /= *((double *)atom_val->apval); return divide_internal(acc, cdr(numbers_l)); } S_Expr *divide(S_Expr *numbers_l) { S_Expr *n = car(numbers_l); if (!is_atom(n)) { jinni_exception("invalid arguments passed to divide"); } Atom *a = n->expr; if (a->type != NUMBER) { jinni_exception("non-number passed to divide"); } return make_number_atom( divide_internal(*((double *)a->apval), cdr(numbers_l))); } S_Expr *lt(S_Expr *numbers_l) { S_Expr *n1 = car(numbers_l); S_Expr *n2 = car(cdr(numbers_l)); if (!is_atom(n1) || !is_atom(n2)) { jinni_exception("invalid arguments passed to lt"); } Atom *a1 = n1->expr; Atom *a2 = n2->expr; if (a1->type != NUMBER || a2->type != NUMBER) { jinni_exception("non-number passed to lt"); } return make_bool_atom(*((double *)a1->apval) < *((double *)a2->apval)); } S_Expr *gt(S_Expr *numbers_l) { S_Expr *n1 = car(numbers_l); S_Expr *n2 = car(cdr(numbers_l)); if (!is_atom(n1) || !is_atom(n2)) { jinni_exception("invalid arguments passed to gt"); } Atom *a1 = n1->expr; Atom *a2 = n2->expr; if (a1->type != NUMBER || a2->type != NUMBER) { jinni_exception("non-number passed to gt"); } return make_bool_atom(*((double *)a1->apval) > *((double *)a2->apval)); } S_Expr *print(S_Expr *e) { if (!is_atom(e)) { jinni_exception("print can only print atomic primitive types!!!"); } Atom *a = (Atom *)e->expr; switch (a->type) { case STRING: printf("%s", (char *)a->apval); break; case NUMBER: printf("%f", *(double *)a->apval); break; case BOOLEAN: printf("%c", (*(bool *)a->apval) ? 'T' : 'F'); break; case NIL: printf("NIL"); break; default: jinni_exception("print can only print atomic primitive types!!!"); } printf("\n"); fflush(stdout); return e; } //----------------------------------------------------------------------------- // additional supporting system functions //----------------------------------------------------------------------------- /** * If `a` is an association list such as the one formed by pairlis, * then assoc will produce the first pair whose first term is x. * Thus it is a table searching function. */ S_Expr *assoc(S_Expr *x, S_Expr *a) { if (is_nil_atom(a)) return a; return (equal_internal(car(car(a)), x) ? car(a) : assoc(x, cdr(a))); } S_Expr *lookup_symbol_table(char *pname, S_Expr *symbol_table, S_Expr *last) { if (is_nil_atom(symbol_table)) return last; if (is_atom(symbol_table)) { // i'm not sure if this should be allowed at all... // // Atom * a = (Atom *)symbol_table->expr; // if (0 == strcmp(a->pname, pname)) // return symbol_table; // else // return NULL; // // huh? ...as-if ;-) jinni_exception("corrupt symbol table"); } Cell *c = (Cell *)symbol_table->expr; // on the cell's left side we expect a cell with two // atoms: (left: label - right: expression) if (!is_atom(c->left)) { // just what we expected... Cell *symbol = (Cell *)c->left->expr; if (is_atom(symbol->left)) { Atom *label = symbol->left->expr; #ifdef PRINT_DBG_INFO printf("\ncomparing %s and %s\n", (char *)label->apval, pname); #endif if (label->type == STRING && 0 == strcmp((char *)label->apval, pname)) { last = symbol->right; // fallthrough to return ... } else { if (label->type != STRING) printf("warning: label in symbol has invalid type\n"); } } else { printf("warning: symbol left-side expression is not a label\n"); print_s_expr(symbol->left); } } else { printf("warning: left side of symbol table element is not a cell... " "ignoring it"); } return lookup_symbol_table(pname, cdr(symbol_table), last); } S_Expr *bind(S_Expr *st, S_Expr *names, S_Expr *values, uint16_t len) { print_debug_info("bind - names", names); print_debug_info("bind - values", values); // here names is supposed to be a list of strings // and values a list of expressions // to-do: validate all of this? if (len == 0) return st; len--; print_debug_info("bind st", st); ; Atom *a_sym_label = (Atom *)(car(names)->expr); S_Expr *new_st = append(st, cons(cons(make_string_atom(a_sym_label->pname, strlen(a_sym_label->pname)), car(values)), &nil_s_expr)); print_debug_info("bind new_st", new_st); return bind(new_st, cdr(names), cdr(values), len); } S_Expr *bind_quoting(S_Expr *st, S_Expr *names, S_Expr *values, uint16_t len) { if (len == 0) return st; len--; Atom *a_sym_label = (Atom *)(car(names)->expr); S_Expr *new_st = append( st, cons(cons(make_string_atom(a_sym_label->pname, strlen(a_sym_label->pname)), cons(quote_fn_symbol, cons(car(values), &nil_s_expr))), &nil_s_expr)); return bind_quoting(new_st, cdr(names), cdr(values), len); } //----------------------------------------------------------------------------- // evaluation functions //----------------------------------------------------------------------------- S_Expr *apply(S_Expr *fn, S_Expr *args, S_Expr *symbol_table, bool maybe_from_list_constructor, bool args_were_list) { print_debug_info("apply fn: ", fn); print_debug_info("apply args: ", args); S_Expr *r = NULL; if (is_atom(fn)) { Atom *fn_atom = (Atom *)fn->expr; // for unnamed literal primitives if (!fn_atom->pname) { if (fn_atom->type == STRING || fn_atom->type == NUMBER || fn_atom->type == BOOLEAN || fn_atom->type == NIL) { if (is_nil_atom(args)) { return eval(fn, &symbol_table); } jinni_exception( "trying to eval non-function symbol with args in apply"); } } // check that the (f)subr/(f)expr with this pname exists in the environment // and retrieve the complete expr atom (as fn_atom here is expected // to have only the pname, which is what we can get from the parsing) S_Expr *e = lookup_symbol_table(fn_atom->pname, symbol_table, NULL); if (!e) { // nuke it jinni_exception("unbound expression: %s", fn_atom->pname); } print_debug_info("lookup result:", e); if (!is_atom(e)) return eval(e, &symbol_table); Atom *e_atom = (Atom *)e->expr; switch (e_atom->ptype) { case PTYPE_ATOM: if (list_len(args) > 1 || !is_atom(((Cell *)args->expr)->right)) { jinni_exception("expected an atom but argument is a cell"); } break; case PTYPE_CELL: if (is_atom(args)) { jinni_exception("expected arity (%d) differs from " "number of arguments (1) \n", e_atom->len); } if (!maybe_from_list_constructor) { jinni_exception("expected a list but got (%d) " "atoms as arguments", list_len(args)); } if (e_atom->len != CALL_ARGUMENTS_LIMIT && list_len(args) != e_atom->len) { jinni_exception("expected arity (%d) differs from " "number of arguments (%d) \n", e_atom->len, list_len(args)); } break; case PTYPE_ANY: if (e_atom->len != CALL_ARGUMENTS_LIMIT) { if (e_atom->len == 2) { // if args. num are 2 can be either two atoms // or a list // if (is_atom(args)) { if (args_were_list) { // we are going to allow this because // evlis does something crazy at the end // which it shouldn't and i don't want to // fix it now... but this is wrong! ; // ok, fallthrough } else { jinni_exception("expecting a list but got an atom as argument"); } } else if (is_atom(((Cell *)args->expr)->left) && is_atom(((Cell *)args->expr)->right)) { ; // ok, fallthrough } else if (!is_atom(((Cell *)args->expr)->right)) { // then this has to follow the list, cannot be // two atoms as well... S_Expr *look_ahead = ((Cell *)args->expr)->right; Cell *look_ahead_c = (Cell *)look_ahead->expr; if (is_atom(look_ahead_c->right) && !is_nil_atom(look_ahead_c->right)) { // printf("\nargs: "); //__print_s_expr(args, PRINT_PARENT_NONE); // printf("\n\n"); jinni_exception("impromer argument list"); } } } } break; } /* if (e_atom->len != CALL_ARGUMENTS_LIMIT) { if (list_len(args) == 1 && is_atom(((Cell *)args->expr)->right)) { ; // Nothing // make sure fn_atom->len matches n of args } else if (list_len(args) != e_atom->len) { //#ifdef PRINT_DBG_INFO printf("expected arity (%d) differs from number of arguments (%d) \n", e_atom->len, list_len(args)); printf("fn_atom pname: %s\n", fn_atom->pname); printf("atom pname: %s\n", e_atom->pname); printf("e: "); __print_s_expr(e, PRINT_PARENT_NONE); printf("\nargs: "); __print_s_expr(args, PRINT_PARENT_NONE); printf("\n\n"); //#endif } else { printf("\nargs ok 1: "); print_s_expr(args); printf("\nargs ok 2: "); __print_s_expr(args, PRINT_PARENT_NONE); printf("\n\n"); } } */ switch (e_atom->type) { case SUBR: if (equal_internal(e, car_fn_symbol)) { r = car(args); } else if (equal_internal(e, cdr_fn_symbol)) { r = cdr(args); } else if (equal_internal(e, cons_fn_symbol)) { r = cons2(car(args), (cdr(args))); } else if (equal_internal(e, atom_fn_symbol)) { r = atom(args); } else if (equal_internal(e, eq_fn_symbol)) { r = eq(car(args), car(cdr(args))); } else if (equal_internal(e, cond_fn_symbol)) { r = cond(symbol_table, args); } else if (equal_internal(e, eval_fn_symbol)) { r = eval(args, &symbol_table); } else { if (e_atom->subr) { S_Expr *(*fn_subr)(S_Expr * e); fn_subr = e_atom->subr; print_debug_info("args: ", args); r = fn_subr(args); } else { // nuke it jinni_exception("undefined subr: %s", e_atom->pname); } } break; case EXPR: // at this point args- should be a list of values to bind if (!e_atom->args_bind_names) { // but we have no names to bind the args r = eval(car(e_atom->expr), &symbol_table); break; } // bind each arg from args with each var from name // from fn_atom->sowewhere-i-saved-the-var-names mem_segment_i++; S_Expr *new_symbol_table = bind(symbol_table, // not necessary to copy the symbol table! (see // other comment on new_symbol_table) e_atom->args_bind_names, args, e_atom->len); // values are bound already, the expr defined in the lambda doesn't need // any parameters as it takes everything it needs from bound variables, // then we call eval on the expr with the new symbol table r = eval(car(e_atom->expr), &new_symbol_table); mem_segment_i--; // copy the result value over to a higher // memory segment before freeing S_Expr *r2 = copy_list(r); free_mem_segment(mem_segment_i + 1); r = r2; break; case FEXPR: case FSUBR: // this should not happen jinni_exception("unexpected case in %s", __FUNCTION__); break; default: #ifdef PRINT_DBG_INFO printf("evaluating atom primitive at apply()"); print_s_expr(e); printf("\n===\n"); #endif // PRINT_DBG_INFO r = eval(e, &symbol_table); break; } } else { r = eval(fn, &symbol_table); } print_debug_info("apply (r): ", r); return r; } S_Expr *eval(S_Expr *e, S_Expr **symbol_table) { print_debug_info("eval: ", e); S_Expr *r = NULL; if (is_atom(e)) { // check for pname, if it's anonymous // must be primitive, otherwise lookup // in the symbol table and eval it Atom *a = (Atom *)e->expr; if (!a->pname || 0 == strcmp(a->pname, "")) { if (a->type != STRING && a->type != NUMBER && a->type != BOOLEAN && a->type != NIL) { jinni_exception("unbound expression: %s\n", a->pname); } print_debug_info("non-pr: ", e); // all good, primitives eval to themselves, // just copy and return r = e; } else { S_Expr *found_e = lookup_symbol_table(a->pname, *symbol_table, NULL); // here we check not only that we found the expression, but also // that if it is an atom it doesn't have any args, otherwise we would // loop forever in `eval` (e.g. if one would enter an invalid expression // like `( CDR CONS T F )` if (!found_e || (is_atom(found_e) && ((Atom *)found_e->expr)->len)) { jinni_exception("unbound expression: %s\n", a->pname); } r = eval(found_e, symbol_table); } } else { // We need to check for special forms and other rather exceptional // stuff here, as in some cases it'll have to be dealt with now // before evaluating arguments... Atom *maybe_fn = (Atom *)(car(e)->expr); if (car(e)->type == ATOM && maybe_fn && maybe_fn->pname) { S_Expr *fn = lookup_symbol_table(maybe_fn->pname, *symbol_table, NULL); if (fn) { Atom *fn_atom = (Atom *)fn->expr; if (fn_atom->type == SUBR) { if (equal_internal(fn, quote_fn_symbol)) { struct s_expr *args = cdr(e); if (list_len(args) != 1) { jinni_exception( "expected arity (1) differs from number of args %d\n", list_len(args)); } r = quote(car(args)); goto end_eval; } else if (equal_internal(fn, label_fn_symbol)) { S_Expr *args = cdr(e); print_debug_info("label args:", car(args)); print_debug_info("", eval(car(cdr(args)), symbol_table)); r = label(symbol_table, car(args), eval(car(cdr(args)), symbol_table)); goto end_eval; } else if (equal_internal(fn, lambda_fn_symbol)) { S_Expr *args = cdr(e); print_debug_info("lambda args:", car(args)); print_debug_info("", cdr(args)); r = lambda(car(args), cdr(args)); print_debug_info("", r); goto end_eval; } else if (equal_internal(fn, flambda_fn_symbol)) { S_Expr *args = cdr(e); r = flambda(car(args), cdr(args)); goto end_eval; } } else if (fn_atom->type == FSUBR) { S_Expr *args = cdr(e); print_debug_info("fsubr args:", args); print_debug_info("", car(args)); r = fn_atom->fsubr(*symbol_table, args); goto end_eval; } else if (fn_atom->type == FEXPR) { S_Expr *args = cdr(e); print_debug_info("fexpr (e):", e); print_debug_info("", fn_atom->fexpr); S_Expr *new_symbol_table = *symbol_table; bool with_new_table = false; if (fn_atom->args_bind_names) { with_new_table = true; // Note: the reason we don't need to copy the symbol // table here, is because bind and bind_quoting will // call append, which in turn will call cons and always // return a NEW s expr, with pointers to the same // pre-existing entries in the symbol table, and to the // new elements as well... mem_segment_i++; new_symbol_table = bind_quoting( *symbol_table, fn_atom->args_bind_names, args, fn_atom->len); } r = eval(car(fn_atom->fexpr), &new_symbol_table); if (with_new_table) { mem_segment_i--; // copy the result value over to a higher // memory segment before freeing S_Expr *r2 = copy_list(r); free_mem_segment(mem_segment_i + 1); r = r2; } goto end_eval; } } } // Note: maybe we want to validate the num of params for CAR and CDR // here, and only allow lists with a something like CONS or QUOTE as // first element, but not a literal list, since that may actually be // just a bunch of atoms coming from the parser and not a properly // constructed list. // // But it is already implemented in `apply`, so as a quick fix we can // check here and pass the info. to it, whether it was created during // `evlis`, that is, if the first element was either CONS or QUOTE. // printf("\n===\nargs before evlis:\n"); // print_s_expr(cdr(e)); // printf("\n===\n"); bool maybe_from_list_constructor = false; if (is_atom(car(car(cdr(e))))) { Atom *check_a = (Atom *)car(car(cdr(e)))->expr; if (check_a->type == EXPR) { maybe_from_list_constructor = true; // if (check_a->pname // && (0 == strcmp(check_a->pname, "CONS") || 0 == // strcmp(check_a->pname, "QUOTE"))) maybe_from_list_constructor = // true; } } bool args_were_list = (false == is_atom(cdr(e)) && false == is_atom(cdr(cdr(e)))); print_debug_info("eval - cdr(e):", cdr(e)); S_Expr *args = evlis(cdr(e), *symbol_table); print_debug_info("args:", args); r = apply(car(e), args, *symbol_table, maybe_from_list_constructor, args_were_list); } end_eval: print_debug_info("eval (r):", r); return r; } S_Expr *evlis(S_Expr *e, S_Expr *symbol_table) { print_debug_info("evlis:", e); if (!e || is_nil_atom(e)) return &nil_s_expr; S_Expr *evlis_r = evlis(cdr(e), symbol_table); print_debug_info("evlis returning:", evlis_r); // The following little block takes care of the case // when the first element of the list being evaluated // is actually a function, so it should not be cons'ed // with NIL but rather just evaluated. // S_Expr *e_cared = car(e); print_debug_info("e cared:", e_cared); if (!is_atom(e_cared)) { S_Expr *head = ((Cell *)e_cared->expr)->left; Atom *head_a = (Atom *)head->expr; if (head_a->pname) { S_Expr *l = lookup_symbol_table(head_a->pname, symbol_table, NULL); if (l != NULL) { Atom *l_a = (Atom *)l->expr; if (l_a->len > 0) { S_Expr *e2 = eval(e_cared, &symbol_table); { // Additional debug info // char dbg_msg[256]; // sprintf(dbg_msg, "evlis -- function %s evaluated to: ", // head_a->pname); print_debug_info(dbg_msg, e2); // print_debug_info("evlis_r: ", evlis_r); } if (is_nil_atom(evlis_r)) return e2; else return cons(e2, evlis_r); } } } } S_Expr *c = (false == is_nil_atom(evlis_r)) ? cons(eval(car(e), &symbol_table), evlis_r) : eval(car(e), &symbol_table); print_debug_info("evlis consed: ", c); return c; } //----------------------------------------------------------------------------- void init(void) { memset(mem_segments, 0x00, MEM_NUM_SEGMENTS * MEM_SEGMENT_SIZE); car_fn_symbol = &subr_symbol_defs[CAR_SYM_DEF]; cdr_fn_symbol = &subr_symbol_defs[CDR_SYM_DEF]; cons_fn_symbol = &subr_symbol_defs[CONS_SYM_DEF]; atom_fn_symbol = &subr_symbol_defs[ATOM_SYM_DEF]; eq_fn_symbol = &subr_symbol_defs[EQ_SYM_DEF]; quote_fn_symbol = &subr_symbol_defs[QUOTE_SYM_DEF]; label_fn_symbol = &subr_symbol_defs[LABEL_SYM_DEF]; lambda_fn_symbol = &subr_symbol_defs[LAMBDA_SYM_DEF]; flambda_fn_symbol = &subr_symbol_defs[FLAMBDA_SYM_DEF]; cond_fn_symbol = &subr_symbol_defs[COND_SYM_DEF]; eval_fn_symbol = &subr_symbol_defs[EVAL_SYM_DEF]; plus_fn_symbol = &subr_symbol_defs[PLUS_SYM_DEF]; minus_fn_symbol = &subr_symbol_defs[MINUS_SYM_DEF]; multiply_fn_symbol = &subr_symbol_defs[MULTIPLY_SYM_DEF]; divide_fn_symbol = &subr_symbol_defs[DIVIDE_SYM_DEF]; lt_fn_symbol = &subr_symbol_defs[LT_SYM_DEF]; gt_fn_symbol = &subr_symbol_defs[GT_SYM_DEF]; print_fn_symbol = &subr_symbol_defs[PRINT_SYM_DEF]; global_symbols_table = cons(cons(make_string_atom("CAR", 3), car_fn_symbol), cons(cons(make_string_atom("CDR", 3), cdr_fn_symbol), cons(cons(make_string_atom("CONS", 4), cons_fn_symbol), cons(cons(make_string_atom("ATOM", 4), atom_fn_symbol), cons(cons(make_string_atom("EQ", 2), eq_fn_symbol), cons(cons(make_string_atom("QUOTE", 5), quote_fn_symbol), cons(cons(make_string_atom("LABEL", 5), label_fn_symbol), cons(cons(make_string_atom("LAMBDA", 6), lambda_fn_symbol), cons(cons(make_string_atom("COND", 4), cond_fn_symbol), cons(cons(make_string_atom("EVAL", 4), eval_fn_symbol), cons(cons(make_string_atom("FLAMBDA", 7), flambda_fn_symbol), cons(cons(make_string_atom("PRINT", 5), print_fn_symbol), cons(cons(make_string_atom("+", 1), plus_fn_symbol), cons(cons(make_string_atom("+", 1), plus_fn_symbol), cons(cons(make_string_atom("-", 1), minus_fn_symbol), cons(cons(make_string_atom("*", 1), multiply_fn_symbol), cons(cons(make_string_atom("/", 1), divide_fn_symbol), cons(cons(make_string_atom("<", 1), lt_fn_symbol), cons(cons(make_string_atom(">", 1), gt_fn_symbol), cons(cons(make_string_atom("NIL", 3), &nil_s_expr), &nil_s_expr)))))))))))))))))))); return; } //----------------------------------------------------------------------------- // PARSER //----------------------------------------------------------------------------- S_Expr *parse_number(char *number_str, int *consumed); S_Expr *parse_string(char *string_str, int *consumed); S_Expr *parse_symbol(char *symbol_str, int *consumed); S_Expr *parse_bool_atom(char *input_str, int *consumed); S_Expr *parse_list(char *input_str, int *consumed); S_Expr *parse_input(char *input_str, int *consumed); //----------------------------------------------------------------------------- S_Expr *parse_number(char *number_str, int *consumed) { if (*number_str == '\0') return NULL; #define NUM_MAX_LEN 10 //+1 int number = 0; char *p = number_str; bool is_negative = false; // for negatives advance the initial '-' if (p[0] == '-') { p++; (*consumed)++; is_negative = true; } while (*p && (*p >= '0' && *p <= '9') && (p - number_str < NUM_MAX_LEN)) { number = (number * 10) + ((*p) - '0'); p++; } if ((p - number_str) == NUM_MAX_LEN) { jinni_exception("integer out of range!"); } if (is_negative) number *= -1; S_Expr *se = make_number_atom(number); *consumed = p - number_str; double *d = (double *)(((Atom *)(se->expr))->apval); return se; } S_Expr *parse_string(char *string_str, int *consumed) { if (*string_str == '\0') return NULL; #define STR_MAX_LEN 1024 char string[STR_MAX_LEN] = {0}; char *p = string_str; // advance the initial '"' p++; (*consumed)++; while (*p && *p != '"' && strlen(string) < STR_MAX_LEN - 1) { sprintf(&string[strlen(string)], "%c", *p); p++; } // make a STRING atom with an apval for this symbol S_Expr *se = make_string_atom(string, strlen(string)); *consumed = p - string_str; // advance the '"' char. p++; (*consumed)++; return se; } S_Expr *parse_symbol(char *symbol_str, int *consumed) { if (*symbol_str == '\0') return NULL; #define SYMBOL_NAME_MAX_LEN 256 char symbol_name[SYMBOL_NAME_MAX_LEN] = {0}; char *p = symbol_str; while (*p && *p != ' ' && *p != '(' && *p != ')' && strlen(symbol_name) < SYMBOL_NAME_MAX_LEN - 1) { sprintf(&symbol_name[strlen(symbol_name)], "%c", (char)toupper(*p)); p++; } *consumed = p - symbol_str; if (strcmp(symbol_name, "NIL") == 0) { return &nil_s_expr; } // make an EXPR atom with a pname for this symbol S_Expr *se = make_atom(); ((Atom *)(se->expr))->type = EXPR; ((Atom *)(se->expr))->pname = jinni_malloc(sizeof(char) * (strlen(symbol_name) + 1)); strcpy((((Atom *)(se->expr))->pname), symbol_name); return se; } S_Expr *parse_bool_atom(char *input_str, int *consumed) { if (*input_str == '\0') return NULL; if (*input_str == 'T') { *consumed = 1; return &true_s_expr; // make_bool_atom(true); } else if (*input_str == 'F') { *consumed = 1; return &false_s_expr; // make_bool_atom(false); } else { jinni_exception("in %s", __FUNCTION__); } return NULL; } S_Expr *parse_list(char *input_str, int *consumed) { if (*input_str == '\0') return NULL; S_Expr *list = NULL; S_Expr *new_list = NULL; char *p = input_str; p++; // advance the '(' character (*consumed)++; int consumed_loop = 0; int consumed_local = 0; while (*p && *p != ')') { if (*p == ' ') { p++; consumed_local++; continue; } S_Expr *elem = parse_input(p, &consumed_loop); if (elem == NULL) { elem = &nil_s_expr; } if (!list) { list = cons(elem, &nil_s_expr); } else { S_Expr *new_elem = cons(elem, &nil_s_expr); new_list = append(list, new_elem); list = new_list; } p += consumed_loop; *consumed += (consumed_loop + consumed_local); consumed_loop = 0; consumed_local = 0; } if (*p && *p != ')') jinni_exception("error: unexpected end of list"); p++; *consumed += consumed_local; (*consumed)++; print_debug_info("returning list: ", list); return list; } /** * Parse input until it finds a whitespace (not in a string), * a newline char or end of input. */ S_Expr *parse_input(char *input_str, int *consumed) { if (*input_str == '\0') return NULL; char *p = input_str; if ((*p == 'T' || *p == 'F') && ((*(p + 1) == '\0' || *(p + 1) == '\n') || *(p + 1) == ' ')) { return parse_bool_atom(p, consumed); } else if (*p == '(') { return parse_list(p, consumed); } else if (*p == '"') { return parse_string(p, consumed); } else if (*p >= '0' && *p <= '9') { return parse_number(p, consumed); } else { // catch-all for symbols return parse_symbol(p, consumed); } return NULL; } //----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- void exit_print_msg(void) { printf("Bye bye!\n\n"); } void exit_on_signal(int sig_num) { exit_print_msg(); exit(0); } void init_signals(void) { int sigs[] = {SIGINT, SIGHUP, SIGTERM}; struct sigaction sact; for (int i = 0; i < ARRAY_ELEMENTS(sigs); i++) { sact.sa_handler = exit_on_signal; sigemptyset(&sact.sa_mask); sact.sa_flags = 0; if (sigaction(sigs[i], &sact, NULL)) { printf("sigaction() failed (%s)", strerror(errno)); exit(1); } } return; } int main(void) { init(); init_signals(); #define INPUT_MAX_SZ 4096 char input[INPUT_MAX_SZ] = {0}; printf("* "); while (fgets(input, sizeof input, stdin) && !feof(stdin)) { S_Expr *se; int consumed = 0; if (input[strlen(input) - 1] == '\n') input[strlen(input) - 1] = '\0'; se = parse_input(input, &consumed); if (!setjmp(ex_buf) && se != NULL) { S_Expr *res = eval(se, &global_symbols_table); printf("\n"); __print_s_expr(res, PRINT_PARENT_NONE); } else { printf("evaluation ended abnormally\n\n"); } free_mem_segments(1, MEM_NUM_SEGMENTS); printf("\n* "); } exit_print_msg(); return 0; }
the_stack_data/1240483.c
extern float __VERIFIER_nondet_float(void); extern int __VERIFIER_nondet_int(void); typedef enum {false, true} bool; bool __VERIFIER_nondet_bool(void) { return __VERIFIER_nondet_int() != 0; } int main() { bool _EL_X_4698, _x__EL_X_4698; bool _EL_U_4708, _x__EL_U_4708; float x_26, _x_x_26; float x_23, _x_x_23; float x_4, _x_x_4; float x_3, _x_x_3; float x_16, _x_x_16; float x_1, _x_x_1; float x_5, _x_x_5; float x_2, _x_x_2; float x_0, _x_x_0; float x_8, _x_x_8; float x_9, _x_x_9; float x_6, _x_x_6; float x_10, _x_x_10; float x_7, _x_x_7; float x_11, _x_x_11; float x_14, _x_x_14; float x_20, _x_x_20; float x_12, _x_x_12; float x_15, _x_x_15; float x_13, _x_x_13; float x_37, _x_x_37; float x_18, _x_x_18; float x_17, _x_x_17; float x_24, _x_x_24; float x_19, _x_x_19; float x_25, _x_x_25; float x_21, _x_x_21; float x_28, _x_x_28; float x_22, _x_x_22; float x_29, _x_x_29; float x_27, _x_x_27; float x_33, _x_x_33; float x_30, _x_x_30; float x_34, _x_x_34; float x_31, _x_x_31; float x_35, _x_x_35; float x_32, _x_x_32; float x_39, _x_x_39; float x_36, _x_x_36; float x_38, _x_x_38; int __steps_to_fair = __VERIFIER_nondet_int(); _EL_X_4698 = __VERIFIER_nondet_bool(); _EL_U_4708 = __VERIFIER_nondet_bool(); x_26 = __VERIFIER_nondet_float(); x_23 = __VERIFIER_nondet_float(); x_4 = __VERIFIER_nondet_float(); x_3 = __VERIFIER_nondet_float(); x_16 = __VERIFIER_nondet_float(); x_1 = __VERIFIER_nondet_float(); x_5 = __VERIFIER_nondet_float(); x_2 = __VERIFIER_nondet_float(); x_0 = __VERIFIER_nondet_float(); x_8 = __VERIFIER_nondet_float(); x_9 = __VERIFIER_nondet_float(); x_6 = __VERIFIER_nondet_float(); x_10 = __VERIFIER_nondet_float(); x_7 = __VERIFIER_nondet_float(); x_11 = __VERIFIER_nondet_float(); x_14 = __VERIFIER_nondet_float(); x_20 = __VERIFIER_nondet_float(); x_12 = __VERIFIER_nondet_float(); x_15 = __VERIFIER_nondet_float(); x_13 = __VERIFIER_nondet_float(); x_37 = __VERIFIER_nondet_float(); x_18 = __VERIFIER_nondet_float(); x_17 = __VERIFIER_nondet_float(); x_24 = __VERIFIER_nondet_float(); x_19 = __VERIFIER_nondet_float(); x_25 = __VERIFIER_nondet_float(); x_21 = __VERIFIER_nondet_float(); x_28 = __VERIFIER_nondet_float(); x_22 = __VERIFIER_nondet_float(); x_29 = __VERIFIER_nondet_float(); x_27 = __VERIFIER_nondet_float(); x_33 = __VERIFIER_nondet_float(); x_30 = __VERIFIER_nondet_float(); x_34 = __VERIFIER_nondet_float(); x_31 = __VERIFIER_nondet_float(); x_35 = __VERIFIER_nondet_float(); x_32 = __VERIFIER_nondet_float(); x_39 = __VERIFIER_nondet_float(); x_36 = __VERIFIER_nondet_float(); x_38 = __VERIFIER_nondet_float(); bool __ok = (1 && ( !((((x_23 + (-1.0 * x_26)) <= 5.0) || _EL_U_4708) || ( !_EL_X_4698)))); while (__steps_to_fair >= 0 && __ok) { if ((((x_23 + (-1.0 * x_26)) <= 5.0) || ( !(((x_23 + (-1.0 * x_26)) <= 5.0) || _EL_U_4708)))) { __steps_to_fair = __VERIFIER_nondet_int(); } else { __steps_to_fair--; } _x__EL_X_4698 = __VERIFIER_nondet_bool(); _x__EL_U_4708 = __VERIFIER_nondet_bool(); _x_x_26 = __VERIFIER_nondet_float(); _x_x_23 = __VERIFIER_nondet_float(); _x_x_4 = __VERIFIER_nondet_float(); _x_x_3 = __VERIFIER_nondet_float(); _x_x_16 = __VERIFIER_nondet_float(); _x_x_1 = __VERIFIER_nondet_float(); _x_x_5 = __VERIFIER_nondet_float(); _x_x_2 = __VERIFIER_nondet_float(); _x_x_0 = __VERIFIER_nondet_float(); _x_x_8 = __VERIFIER_nondet_float(); _x_x_9 = __VERIFIER_nondet_float(); _x_x_6 = __VERIFIER_nondet_float(); _x_x_10 = __VERIFIER_nondet_float(); _x_x_7 = __VERIFIER_nondet_float(); _x_x_11 = __VERIFIER_nondet_float(); _x_x_14 = __VERIFIER_nondet_float(); _x_x_20 = __VERIFIER_nondet_float(); _x_x_12 = __VERIFIER_nondet_float(); _x_x_15 = __VERIFIER_nondet_float(); _x_x_13 = __VERIFIER_nondet_float(); _x_x_37 = __VERIFIER_nondet_float(); _x_x_18 = __VERIFIER_nondet_float(); _x_x_17 = __VERIFIER_nondet_float(); _x_x_24 = __VERIFIER_nondet_float(); _x_x_19 = __VERIFIER_nondet_float(); _x_x_25 = __VERIFIER_nondet_float(); _x_x_21 = __VERIFIER_nondet_float(); _x_x_28 = __VERIFIER_nondet_float(); _x_x_22 = __VERIFIER_nondet_float(); _x_x_29 = __VERIFIER_nondet_float(); _x_x_27 = __VERIFIER_nondet_float(); _x_x_33 = __VERIFIER_nondet_float(); _x_x_30 = __VERIFIER_nondet_float(); _x_x_34 = __VERIFIER_nondet_float(); _x_x_31 = __VERIFIER_nondet_float(); _x_x_35 = __VERIFIER_nondet_float(); _x_x_32 = __VERIFIER_nondet_float(); _x_x_39 = __VERIFIER_nondet_float(); _x_x_36 = __VERIFIER_nondet_float(); _x_x_38 = __VERIFIER_nondet_float(); __ok = ((((((((((((((((((((((((((((((((((((((((((((x_37 + (-1.0 * _x_x_0)) <= -13.0) && (((x_35 + (-1.0 * _x_x_0)) <= -1.0) && (((x_33 + (-1.0 * _x_x_0)) <= -11.0) && (((x_30 + (-1.0 * _x_x_0)) <= -18.0) && (((x_29 + (-1.0 * _x_x_0)) <= -8.0) && (((x_28 + (-1.0 * _x_x_0)) <= -7.0) && (((x_27 + (-1.0 * _x_x_0)) <= -8.0) && (((x_22 + (-1.0 * _x_x_0)) <= -9.0) && (((x_19 + (-1.0 * _x_x_0)) <= -2.0) && (((x_18 + (-1.0 * _x_x_0)) <= -15.0) && (((x_17 + (-1.0 * _x_x_0)) <= -14.0) && (((x_16 + (-1.0 * _x_x_0)) <= -11.0) && (((x_15 + (-1.0 * _x_x_0)) <= -19.0) && (((x_14 + (-1.0 * _x_x_0)) <= -6.0) && (((x_10 + (-1.0 * _x_x_0)) <= -17.0) && (((x_9 + (-1.0 * _x_x_0)) <= -1.0) && (((x_8 + (-1.0 * _x_x_0)) <= -11.0) && (((x_7 + (-1.0 * _x_x_0)) <= -9.0) && (((x_2 + (-1.0 * _x_x_0)) <= -10.0) && ((x_5 + (-1.0 * _x_x_0)) <= -1.0)))))))))))))))))))) && (((x_37 + (-1.0 * _x_x_0)) == -13.0) || (((x_35 + (-1.0 * _x_x_0)) == -1.0) || (((x_33 + (-1.0 * _x_x_0)) == -11.0) || (((x_30 + (-1.0 * _x_x_0)) == -18.0) || (((x_29 + (-1.0 * _x_x_0)) == -8.0) || (((x_28 + (-1.0 * _x_x_0)) == -7.0) || (((x_27 + (-1.0 * _x_x_0)) == -8.0) || (((x_22 + (-1.0 * _x_x_0)) == -9.0) || (((x_19 + (-1.0 * _x_x_0)) == -2.0) || (((x_18 + (-1.0 * _x_x_0)) == -15.0) || (((x_17 + (-1.0 * _x_x_0)) == -14.0) || (((x_16 + (-1.0 * _x_x_0)) == -11.0) || (((x_15 + (-1.0 * _x_x_0)) == -19.0) || (((x_14 + (-1.0 * _x_x_0)) == -6.0) || (((x_10 + (-1.0 * _x_x_0)) == -17.0) || (((x_9 + (-1.0 * _x_x_0)) == -1.0) || (((x_8 + (-1.0 * _x_x_0)) == -11.0) || (((x_7 + (-1.0 * _x_x_0)) == -9.0) || (((x_2 + (-1.0 * _x_x_0)) == -10.0) || ((x_5 + (-1.0 * _x_x_0)) == -1.0))))))))))))))))))))) && ((((x_39 + (-1.0 * _x_x_1)) <= -14.0) && (((x_38 + (-1.0 * _x_x_1)) <= -12.0) && (((x_37 + (-1.0 * _x_x_1)) <= -16.0) && (((x_36 + (-1.0 * _x_x_1)) <= -20.0) && (((x_32 + (-1.0 * _x_x_1)) <= -12.0) && (((x_30 + (-1.0 * _x_x_1)) <= -8.0) && (((x_28 + (-1.0 * _x_x_1)) <= -6.0) && (((x_26 + (-1.0 * _x_x_1)) <= -10.0) && (((x_24 + (-1.0 * _x_x_1)) <= -9.0) && (((x_22 + (-1.0 * _x_x_1)) <= -5.0) && (((x_19 + (-1.0 * _x_x_1)) <= -4.0) && (((x_18 + (-1.0 * _x_x_1)) <= -17.0) && (((x_15 + (-1.0 * _x_x_1)) <= -16.0) && (((x_10 + (-1.0 * _x_x_1)) <= -3.0) && (((x_9 + (-1.0 * _x_x_1)) <= -14.0) && (((x_8 + (-1.0 * _x_x_1)) <= -8.0) && (((x_3 + (-1.0 * _x_x_1)) <= -13.0) && (((x_2 + (-1.0 * _x_x_1)) <= -20.0) && (((x_0 + (-1.0 * _x_x_1)) <= -1.0) && ((x_1 + (-1.0 * _x_x_1)) <= -1.0)))))))))))))))))))) && (((x_39 + (-1.0 * _x_x_1)) == -14.0) || (((x_38 + (-1.0 * _x_x_1)) == -12.0) || (((x_37 + (-1.0 * _x_x_1)) == -16.0) || (((x_36 + (-1.0 * _x_x_1)) == -20.0) || (((x_32 + (-1.0 * _x_x_1)) == -12.0) || (((x_30 + (-1.0 * _x_x_1)) == -8.0) || (((x_28 + (-1.0 * _x_x_1)) == -6.0) || (((x_26 + (-1.0 * _x_x_1)) == -10.0) || (((x_24 + (-1.0 * _x_x_1)) == -9.0) || (((x_22 + (-1.0 * _x_x_1)) == -5.0) || (((x_19 + (-1.0 * _x_x_1)) == -4.0) || (((x_18 + (-1.0 * _x_x_1)) == -17.0) || (((x_15 + (-1.0 * _x_x_1)) == -16.0) || (((x_10 + (-1.0 * _x_x_1)) == -3.0) || (((x_9 + (-1.0 * _x_x_1)) == -14.0) || (((x_8 + (-1.0 * _x_x_1)) == -8.0) || (((x_3 + (-1.0 * _x_x_1)) == -13.0) || (((x_2 + (-1.0 * _x_x_1)) == -20.0) || (((x_0 + (-1.0 * _x_x_1)) == -1.0) || ((x_1 + (-1.0 * _x_x_1)) == -1.0)))))))))))))))))))))) && ((((x_39 + (-1.0 * _x_x_2)) <= -6.0) && (((x_37 + (-1.0 * _x_x_2)) <= -11.0) && (((x_28 + (-1.0 * _x_x_2)) <= -3.0) && (((x_27 + (-1.0 * _x_x_2)) <= -14.0) && (((x_26 + (-1.0 * _x_x_2)) <= -2.0) && (((x_25 + (-1.0 * _x_x_2)) <= -10.0) && (((x_24 + (-1.0 * _x_x_2)) <= -10.0) && (((x_23 + (-1.0 * _x_x_2)) <= -4.0) && (((x_22 + (-1.0 * _x_x_2)) <= -3.0) && (((x_21 + (-1.0 * _x_x_2)) <= -11.0) && (((x_19 + (-1.0 * _x_x_2)) <= -16.0) && (((x_14 + (-1.0 * _x_x_2)) <= -1.0) && (((x_13 + (-1.0 * _x_x_2)) <= -16.0) && (((x_12 + (-1.0 * _x_x_2)) <= -18.0) && (((x_11 + (-1.0 * _x_x_2)) <= -10.0) && (((x_10 + (-1.0 * _x_x_2)) <= -8.0) && (((x_9 + (-1.0 * _x_x_2)) <= -19.0) && (((x_7 + (-1.0 * _x_x_2)) <= -18.0) && (((x_1 + (-1.0 * _x_x_2)) <= -7.0) && ((x_5 + (-1.0 * _x_x_2)) <= -13.0)))))))))))))))))))) && (((x_39 + (-1.0 * _x_x_2)) == -6.0) || (((x_37 + (-1.0 * _x_x_2)) == -11.0) || (((x_28 + (-1.0 * _x_x_2)) == -3.0) || (((x_27 + (-1.0 * _x_x_2)) == -14.0) || (((x_26 + (-1.0 * _x_x_2)) == -2.0) || (((x_25 + (-1.0 * _x_x_2)) == -10.0) || (((x_24 + (-1.0 * _x_x_2)) == -10.0) || (((x_23 + (-1.0 * _x_x_2)) == -4.0) || (((x_22 + (-1.0 * _x_x_2)) == -3.0) || (((x_21 + (-1.0 * _x_x_2)) == -11.0) || (((x_19 + (-1.0 * _x_x_2)) == -16.0) || (((x_14 + (-1.0 * _x_x_2)) == -1.0) || (((x_13 + (-1.0 * _x_x_2)) == -16.0) || (((x_12 + (-1.0 * _x_x_2)) == -18.0) || (((x_11 + (-1.0 * _x_x_2)) == -10.0) || (((x_10 + (-1.0 * _x_x_2)) == -8.0) || (((x_9 + (-1.0 * _x_x_2)) == -19.0) || (((x_7 + (-1.0 * _x_x_2)) == -18.0) || (((x_1 + (-1.0 * _x_x_2)) == -7.0) || ((x_5 + (-1.0 * _x_x_2)) == -13.0)))))))))))))))))))))) && ((((x_38 + (-1.0 * _x_x_3)) <= -13.0) && (((x_37 + (-1.0 * _x_x_3)) <= -19.0) && (((x_32 + (-1.0 * _x_x_3)) <= -12.0) && (((x_31 + (-1.0 * _x_x_3)) <= -11.0) && (((x_30 + (-1.0 * _x_x_3)) <= -13.0) && (((x_28 + (-1.0 * _x_x_3)) <= -4.0) && (((x_27 + (-1.0 * _x_x_3)) <= -1.0) && (((x_25 + (-1.0 * _x_x_3)) <= -10.0) && (((x_24 + (-1.0 * _x_x_3)) <= -10.0) && (((x_23 + (-1.0 * _x_x_3)) <= -8.0) && (((x_22 + (-1.0 * _x_x_3)) <= -8.0) && (((x_19 + (-1.0 * _x_x_3)) <= -17.0) && (((x_18 + (-1.0 * _x_x_3)) <= -6.0) && (((x_13 + (-1.0 * _x_x_3)) <= -2.0) && (((x_11 + (-1.0 * _x_x_3)) <= -6.0) && (((x_9 + (-1.0 * _x_x_3)) <= -14.0) && (((x_8 + (-1.0 * _x_x_3)) <= -17.0) && (((x_5 + (-1.0 * _x_x_3)) <= -10.0) && (((x_1 + (-1.0 * _x_x_3)) <= -18.0) && ((x_2 + (-1.0 * _x_x_3)) <= -14.0)))))))))))))))))))) && (((x_38 + (-1.0 * _x_x_3)) == -13.0) || (((x_37 + (-1.0 * _x_x_3)) == -19.0) || (((x_32 + (-1.0 * _x_x_3)) == -12.0) || (((x_31 + (-1.0 * _x_x_3)) == -11.0) || (((x_30 + (-1.0 * _x_x_3)) == -13.0) || (((x_28 + (-1.0 * _x_x_3)) == -4.0) || (((x_27 + (-1.0 * _x_x_3)) == -1.0) || (((x_25 + (-1.0 * _x_x_3)) == -10.0) || (((x_24 + (-1.0 * _x_x_3)) == -10.0) || (((x_23 + (-1.0 * _x_x_3)) == -8.0) || (((x_22 + (-1.0 * _x_x_3)) == -8.0) || (((x_19 + (-1.0 * _x_x_3)) == -17.0) || (((x_18 + (-1.0 * _x_x_3)) == -6.0) || (((x_13 + (-1.0 * _x_x_3)) == -2.0) || (((x_11 + (-1.0 * _x_x_3)) == -6.0) || (((x_9 + (-1.0 * _x_x_3)) == -14.0) || (((x_8 + (-1.0 * _x_x_3)) == -17.0) || (((x_5 + (-1.0 * _x_x_3)) == -10.0) || (((x_1 + (-1.0 * _x_x_3)) == -18.0) || ((x_2 + (-1.0 * _x_x_3)) == -14.0)))))))))))))))))))))) && ((((x_39 + (-1.0 * _x_x_4)) <= -12.0) && (((x_34 + (-1.0 * _x_x_4)) <= -17.0) && (((x_33 + (-1.0 * _x_x_4)) <= -6.0) && (((x_31 + (-1.0 * _x_x_4)) <= -17.0) && (((x_27 + (-1.0 * _x_x_4)) <= -16.0) && (((x_25 + (-1.0 * _x_x_4)) <= -9.0) && (((x_23 + (-1.0 * _x_x_4)) <= -8.0) && (((x_22 + (-1.0 * _x_x_4)) <= -16.0) && (((x_21 + (-1.0 * _x_x_4)) <= -7.0) && (((x_19 + (-1.0 * _x_x_4)) <= -1.0) && (((x_15 + (-1.0 * _x_x_4)) <= -18.0) && (((x_14 + (-1.0 * _x_x_4)) <= -13.0) && (((x_12 + (-1.0 * _x_x_4)) <= -9.0) && (((x_11 + (-1.0 * _x_x_4)) <= -4.0) && (((x_9 + (-1.0 * _x_x_4)) <= -8.0) && (((x_6 + (-1.0 * _x_x_4)) <= -7.0) && (((x_5 + (-1.0 * _x_x_4)) <= -12.0) && (((x_4 + (-1.0 * _x_x_4)) <= -3.0) && (((x_1 + (-1.0 * _x_x_4)) <= -17.0) && ((x_2 + (-1.0 * _x_x_4)) <= -10.0)))))))))))))))))))) && (((x_39 + (-1.0 * _x_x_4)) == -12.0) || (((x_34 + (-1.0 * _x_x_4)) == -17.0) || (((x_33 + (-1.0 * _x_x_4)) == -6.0) || (((x_31 + (-1.0 * _x_x_4)) == -17.0) || (((x_27 + (-1.0 * _x_x_4)) == -16.0) || (((x_25 + (-1.0 * _x_x_4)) == -9.0) || (((x_23 + (-1.0 * _x_x_4)) == -8.0) || (((x_22 + (-1.0 * _x_x_4)) == -16.0) || (((x_21 + (-1.0 * _x_x_4)) == -7.0) || (((x_19 + (-1.0 * _x_x_4)) == -1.0) || (((x_15 + (-1.0 * _x_x_4)) == -18.0) || (((x_14 + (-1.0 * _x_x_4)) == -13.0) || (((x_12 + (-1.0 * _x_x_4)) == -9.0) || (((x_11 + (-1.0 * _x_x_4)) == -4.0) || (((x_9 + (-1.0 * _x_x_4)) == -8.0) || (((x_6 + (-1.0 * _x_x_4)) == -7.0) || (((x_5 + (-1.0 * _x_x_4)) == -12.0) || (((x_4 + (-1.0 * _x_x_4)) == -3.0) || (((x_1 + (-1.0 * _x_x_4)) == -17.0) || ((x_2 + (-1.0 * _x_x_4)) == -10.0)))))))))))))))))))))) && ((((x_35 + (-1.0 * _x_x_5)) <= -18.0) && (((x_29 + (-1.0 * _x_x_5)) <= -16.0) && (((x_28 + (-1.0 * _x_x_5)) <= -15.0) && (((x_26 + (-1.0 * _x_x_5)) <= -12.0) && (((x_25 + (-1.0 * _x_x_5)) <= -20.0) && (((x_23 + (-1.0 * _x_x_5)) <= -6.0) && (((x_21 + (-1.0 * _x_x_5)) <= -5.0) && (((x_20 + (-1.0 * _x_x_5)) <= -13.0) && (((x_19 + (-1.0 * _x_x_5)) <= -13.0) && (((x_18 + (-1.0 * _x_x_5)) <= -10.0) && (((x_17 + (-1.0 * _x_x_5)) <= -5.0) && (((x_16 + (-1.0 * _x_x_5)) <= -6.0) && (((x_15 + (-1.0 * _x_x_5)) <= -16.0) && (((x_14 + (-1.0 * _x_x_5)) <= -5.0) && (((x_13 + (-1.0 * _x_x_5)) <= -5.0) && (((x_6 + (-1.0 * _x_x_5)) <= -3.0) && (((x_5 + (-1.0 * _x_x_5)) <= -1.0) && (((x_3 + (-1.0 * _x_x_5)) <= -20.0) && (((x_0 + (-1.0 * _x_x_5)) <= -13.0) && ((x_1 + (-1.0 * _x_x_5)) <= -1.0)))))))))))))))))))) && (((x_35 + (-1.0 * _x_x_5)) == -18.0) || (((x_29 + (-1.0 * _x_x_5)) == -16.0) || (((x_28 + (-1.0 * _x_x_5)) == -15.0) || (((x_26 + (-1.0 * _x_x_5)) == -12.0) || (((x_25 + (-1.0 * _x_x_5)) == -20.0) || (((x_23 + (-1.0 * _x_x_5)) == -6.0) || (((x_21 + (-1.0 * _x_x_5)) == -5.0) || (((x_20 + (-1.0 * _x_x_5)) == -13.0) || (((x_19 + (-1.0 * _x_x_5)) == -13.0) || (((x_18 + (-1.0 * _x_x_5)) == -10.0) || (((x_17 + (-1.0 * _x_x_5)) == -5.0) || (((x_16 + (-1.0 * _x_x_5)) == -6.0) || (((x_15 + (-1.0 * _x_x_5)) == -16.0) || (((x_14 + (-1.0 * _x_x_5)) == -5.0) || (((x_13 + (-1.0 * _x_x_5)) == -5.0) || (((x_6 + (-1.0 * _x_x_5)) == -3.0) || (((x_5 + (-1.0 * _x_x_5)) == -1.0) || (((x_3 + (-1.0 * _x_x_5)) == -20.0) || (((x_0 + (-1.0 * _x_x_5)) == -13.0) || ((x_1 + (-1.0 * _x_x_5)) == -1.0)))))))))))))))))))))) && ((((x_38 + (-1.0 * _x_x_6)) <= -18.0) && (((x_33 + (-1.0 * _x_x_6)) <= -17.0) && (((x_32 + (-1.0 * _x_x_6)) <= -6.0) && (((x_31 + (-1.0 * _x_x_6)) <= -1.0) && (((x_27 + (-1.0 * _x_x_6)) <= -9.0) && (((x_23 + (-1.0 * _x_x_6)) <= -17.0) && (((x_21 + (-1.0 * _x_x_6)) <= -3.0) && (((x_20 + (-1.0 * _x_x_6)) <= -12.0) && (((x_17 + (-1.0 * _x_x_6)) <= -10.0) && (((x_14 + (-1.0 * _x_x_6)) <= -17.0) && (((x_13 + (-1.0 * _x_x_6)) <= -19.0) && (((x_12 + (-1.0 * _x_x_6)) <= -15.0) && (((x_11 + (-1.0 * _x_x_6)) <= -15.0) && (((x_10 + (-1.0 * _x_x_6)) <= -8.0) && (((x_8 + (-1.0 * _x_x_6)) <= -13.0) && (((x_5 + (-1.0 * _x_x_6)) <= -8.0) && (((x_4 + (-1.0 * _x_x_6)) <= -5.0) && (((x_2 + (-1.0 * _x_x_6)) <= -19.0) && (((x_0 + (-1.0 * _x_x_6)) <= -3.0) && ((x_1 + (-1.0 * _x_x_6)) <= -6.0)))))))))))))))))))) && (((x_38 + (-1.0 * _x_x_6)) == -18.0) || (((x_33 + (-1.0 * _x_x_6)) == -17.0) || (((x_32 + (-1.0 * _x_x_6)) == -6.0) || (((x_31 + (-1.0 * _x_x_6)) == -1.0) || (((x_27 + (-1.0 * _x_x_6)) == -9.0) || (((x_23 + (-1.0 * _x_x_6)) == -17.0) || (((x_21 + (-1.0 * _x_x_6)) == -3.0) || (((x_20 + (-1.0 * _x_x_6)) == -12.0) || (((x_17 + (-1.0 * _x_x_6)) == -10.0) || (((x_14 + (-1.0 * _x_x_6)) == -17.0) || (((x_13 + (-1.0 * _x_x_6)) == -19.0) || (((x_12 + (-1.0 * _x_x_6)) == -15.0) || (((x_11 + (-1.0 * _x_x_6)) == -15.0) || (((x_10 + (-1.0 * _x_x_6)) == -8.0) || (((x_8 + (-1.0 * _x_x_6)) == -13.0) || (((x_5 + (-1.0 * _x_x_6)) == -8.0) || (((x_4 + (-1.0 * _x_x_6)) == -5.0) || (((x_2 + (-1.0 * _x_x_6)) == -19.0) || (((x_0 + (-1.0 * _x_x_6)) == -3.0) || ((x_1 + (-1.0 * _x_x_6)) == -6.0)))))))))))))))))))))) && ((((x_39 + (-1.0 * _x_x_7)) <= -3.0) && (((x_38 + (-1.0 * _x_x_7)) <= -11.0) && (((x_35 + (-1.0 * _x_x_7)) <= -6.0) && (((x_34 + (-1.0 * _x_x_7)) <= -14.0) && (((x_33 + (-1.0 * _x_x_7)) <= -16.0) && (((x_30 + (-1.0 * _x_x_7)) <= -2.0) && (((x_29 + (-1.0 * _x_x_7)) <= -15.0) && (((x_28 + (-1.0 * _x_x_7)) <= -19.0) && (((x_27 + (-1.0 * _x_x_7)) <= -13.0) && (((x_26 + (-1.0 * _x_x_7)) <= -2.0) && (((x_25 + (-1.0 * _x_x_7)) <= -16.0) && (((x_22 + (-1.0 * _x_x_7)) <= -3.0) && (((x_17 + (-1.0 * _x_x_7)) <= -9.0) && (((x_16 + (-1.0 * _x_x_7)) <= -14.0) && (((x_12 + (-1.0 * _x_x_7)) <= -3.0) && (((x_11 + (-1.0 * _x_x_7)) <= -20.0) && (((x_10 + (-1.0 * _x_x_7)) <= -8.0) && (((x_4 + (-1.0 * _x_x_7)) <= -16.0) && (((x_2 + (-1.0 * _x_x_7)) <= -20.0) && ((x_3 + (-1.0 * _x_x_7)) <= -15.0)))))))))))))))))))) && (((x_39 + (-1.0 * _x_x_7)) == -3.0) || (((x_38 + (-1.0 * _x_x_7)) == -11.0) || (((x_35 + (-1.0 * _x_x_7)) == -6.0) || (((x_34 + (-1.0 * _x_x_7)) == -14.0) || (((x_33 + (-1.0 * _x_x_7)) == -16.0) || (((x_30 + (-1.0 * _x_x_7)) == -2.0) || (((x_29 + (-1.0 * _x_x_7)) == -15.0) || (((x_28 + (-1.0 * _x_x_7)) == -19.0) || (((x_27 + (-1.0 * _x_x_7)) == -13.0) || (((x_26 + (-1.0 * _x_x_7)) == -2.0) || (((x_25 + (-1.0 * _x_x_7)) == -16.0) || (((x_22 + (-1.0 * _x_x_7)) == -3.0) || (((x_17 + (-1.0 * _x_x_7)) == -9.0) || (((x_16 + (-1.0 * _x_x_7)) == -14.0) || (((x_12 + (-1.0 * _x_x_7)) == -3.0) || (((x_11 + (-1.0 * _x_x_7)) == -20.0) || (((x_10 + (-1.0 * _x_x_7)) == -8.0) || (((x_4 + (-1.0 * _x_x_7)) == -16.0) || (((x_2 + (-1.0 * _x_x_7)) == -20.0) || ((x_3 + (-1.0 * _x_x_7)) == -15.0)))))))))))))))))))))) && ((((x_39 + (-1.0 * _x_x_8)) <= -15.0) && (((x_37 + (-1.0 * _x_x_8)) <= -16.0) && (((x_35 + (-1.0 * _x_x_8)) <= -18.0) && (((x_32 + (-1.0 * _x_x_8)) <= -3.0) && (((x_29 + (-1.0 * _x_x_8)) <= -16.0) && (((x_26 + (-1.0 * _x_x_8)) <= -1.0) && (((x_25 + (-1.0 * _x_x_8)) <= -20.0) && (((x_24 + (-1.0 * _x_x_8)) <= -18.0) && (((x_23 + (-1.0 * _x_x_8)) <= -10.0) && (((x_22 + (-1.0 * _x_x_8)) <= -3.0) && (((x_18 + (-1.0 * _x_x_8)) <= -4.0) && (((x_17 + (-1.0 * _x_x_8)) <= -17.0) && (((x_16 + (-1.0 * _x_x_8)) <= -10.0) && (((x_15 + (-1.0 * _x_x_8)) <= -9.0) && (((x_11 + (-1.0 * _x_x_8)) <= -17.0) && (((x_8 + (-1.0 * _x_x_8)) <= -12.0) && (((x_7 + (-1.0 * _x_x_8)) <= -19.0) && (((x_6 + (-1.0 * _x_x_8)) <= -16.0) && (((x_4 + (-1.0 * _x_x_8)) <= -9.0) && ((x_5 + (-1.0 * _x_x_8)) <= -18.0)))))))))))))))))))) && (((x_39 + (-1.0 * _x_x_8)) == -15.0) || (((x_37 + (-1.0 * _x_x_8)) == -16.0) || (((x_35 + (-1.0 * _x_x_8)) == -18.0) || (((x_32 + (-1.0 * _x_x_8)) == -3.0) || (((x_29 + (-1.0 * _x_x_8)) == -16.0) || (((x_26 + (-1.0 * _x_x_8)) == -1.0) || (((x_25 + (-1.0 * _x_x_8)) == -20.0) || (((x_24 + (-1.0 * _x_x_8)) == -18.0) || (((x_23 + (-1.0 * _x_x_8)) == -10.0) || (((x_22 + (-1.0 * _x_x_8)) == -3.0) || (((x_18 + (-1.0 * _x_x_8)) == -4.0) || (((x_17 + (-1.0 * _x_x_8)) == -17.0) || (((x_16 + (-1.0 * _x_x_8)) == -10.0) || (((x_15 + (-1.0 * _x_x_8)) == -9.0) || (((x_11 + (-1.0 * _x_x_8)) == -17.0) || (((x_8 + (-1.0 * _x_x_8)) == -12.0) || (((x_7 + (-1.0 * _x_x_8)) == -19.0) || (((x_6 + (-1.0 * _x_x_8)) == -16.0) || (((x_4 + (-1.0 * _x_x_8)) == -9.0) || ((x_5 + (-1.0 * _x_x_8)) == -18.0)))))))))))))))))))))) && ((((x_39 + (-1.0 * _x_x_9)) <= -8.0) && (((x_35 + (-1.0 * _x_x_9)) <= -10.0) && (((x_33 + (-1.0 * _x_x_9)) <= -16.0) && (((x_32 + (-1.0 * _x_x_9)) <= -13.0) && (((x_30 + (-1.0 * _x_x_9)) <= -5.0) && (((x_27 + (-1.0 * _x_x_9)) <= -16.0) && (((x_25 + (-1.0 * _x_x_9)) <= -5.0) && (((x_24 + (-1.0 * _x_x_9)) <= -10.0) && (((x_23 + (-1.0 * _x_x_9)) <= -9.0) && (((x_21 + (-1.0 * _x_x_9)) <= -10.0) && (((x_20 + (-1.0 * _x_x_9)) <= -20.0) && (((x_18 + (-1.0 * _x_x_9)) <= -13.0) && (((x_16 + (-1.0 * _x_x_9)) <= -9.0) && (((x_11 + (-1.0 * _x_x_9)) <= -18.0) && (((x_6 + (-1.0 * _x_x_9)) <= -19.0) && (((x_5 + (-1.0 * _x_x_9)) <= -12.0) && (((x_3 + (-1.0 * _x_x_9)) <= -4.0) && (((x_2 + (-1.0 * _x_x_9)) <= -12.0) && (((x_0 + (-1.0 * _x_x_9)) <= -2.0) && ((x_1 + (-1.0 * _x_x_9)) <= -3.0)))))))))))))))))))) && (((x_39 + (-1.0 * _x_x_9)) == -8.0) || (((x_35 + (-1.0 * _x_x_9)) == -10.0) || (((x_33 + (-1.0 * _x_x_9)) == -16.0) || (((x_32 + (-1.0 * _x_x_9)) == -13.0) || (((x_30 + (-1.0 * _x_x_9)) == -5.0) || (((x_27 + (-1.0 * _x_x_9)) == -16.0) || (((x_25 + (-1.0 * _x_x_9)) == -5.0) || (((x_24 + (-1.0 * _x_x_9)) == -10.0) || (((x_23 + (-1.0 * _x_x_9)) == -9.0) || (((x_21 + (-1.0 * _x_x_9)) == -10.0) || (((x_20 + (-1.0 * _x_x_9)) == -20.0) || (((x_18 + (-1.0 * _x_x_9)) == -13.0) || (((x_16 + (-1.0 * _x_x_9)) == -9.0) || (((x_11 + (-1.0 * _x_x_9)) == -18.0) || (((x_6 + (-1.0 * _x_x_9)) == -19.0) || (((x_5 + (-1.0 * _x_x_9)) == -12.0) || (((x_3 + (-1.0 * _x_x_9)) == -4.0) || (((x_2 + (-1.0 * _x_x_9)) == -12.0) || (((x_0 + (-1.0 * _x_x_9)) == -2.0) || ((x_1 + (-1.0 * _x_x_9)) == -3.0)))))))))))))))))))))) && ((((x_39 + (-1.0 * _x_x_10)) <= -15.0) && (((x_38 + (-1.0 * _x_x_10)) <= -11.0) && (((x_36 + (-1.0 * _x_x_10)) <= -2.0) && (((x_35 + (-1.0 * _x_x_10)) <= -7.0) && (((x_33 + (-1.0 * _x_x_10)) <= -2.0) && (((x_32 + (-1.0 * _x_x_10)) <= -15.0) && (((x_30 + (-1.0 * _x_x_10)) <= -12.0) && (((x_25 + (-1.0 * _x_x_10)) <= -13.0) && (((x_22 + (-1.0 * _x_x_10)) <= -16.0) && (((x_21 + (-1.0 * _x_x_10)) <= -17.0) && (((x_20 + (-1.0 * _x_x_10)) <= -9.0) && (((x_15 + (-1.0 * _x_x_10)) <= -15.0) && (((x_14 + (-1.0 * _x_x_10)) <= -14.0) && (((x_12 + (-1.0 * _x_x_10)) <= -17.0) && (((x_10 + (-1.0 * _x_x_10)) <= -19.0) && (((x_8 + (-1.0 * _x_x_10)) <= -14.0) && (((x_7 + (-1.0 * _x_x_10)) <= -14.0) && (((x_6 + (-1.0 * _x_x_10)) <= -7.0) && (((x_2 + (-1.0 * _x_x_10)) <= -11.0) && ((x_4 + (-1.0 * _x_x_10)) <= -19.0)))))))))))))))))))) && (((x_39 + (-1.0 * _x_x_10)) == -15.0) || (((x_38 + (-1.0 * _x_x_10)) == -11.0) || (((x_36 + (-1.0 * _x_x_10)) == -2.0) || (((x_35 + (-1.0 * _x_x_10)) == -7.0) || (((x_33 + (-1.0 * _x_x_10)) == -2.0) || (((x_32 + (-1.0 * _x_x_10)) == -15.0) || (((x_30 + (-1.0 * _x_x_10)) == -12.0) || (((x_25 + (-1.0 * _x_x_10)) == -13.0) || (((x_22 + (-1.0 * _x_x_10)) == -16.0) || (((x_21 + (-1.0 * _x_x_10)) == -17.0) || (((x_20 + (-1.0 * _x_x_10)) == -9.0) || (((x_15 + (-1.0 * _x_x_10)) == -15.0) || (((x_14 + (-1.0 * _x_x_10)) == -14.0) || (((x_12 + (-1.0 * _x_x_10)) == -17.0) || (((x_10 + (-1.0 * _x_x_10)) == -19.0) || (((x_8 + (-1.0 * _x_x_10)) == -14.0) || (((x_7 + (-1.0 * _x_x_10)) == -14.0) || (((x_6 + (-1.0 * _x_x_10)) == -7.0) || (((x_2 + (-1.0 * _x_x_10)) == -11.0) || ((x_4 + (-1.0 * _x_x_10)) == -19.0)))))))))))))))))))))) && ((((x_39 + (-1.0 * _x_x_11)) <= -5.0) && (((x_38 + (-1.0 * _x_x_11)) <= -19.0) && (((x_36 + (-1.0 * _x_x_11)) <= -10.0) && (((x_34 + (-1.0 * _x_x_11)) <= -15.0) && (((x_31 + (-1.0 * _x_x_11)) <= -15.0) && (((x_30 + (-1.0 * _x_x_11)) <= -20.0) && (((x_29 + (-1.0 * _x_x_11)) <= -1.0) && (((x_27 + (-1.0 * _x_x_11)) <= -6.0) && (((x_26 + (-1.0 * _x_x_11)) <= -18.0) && (((x_22 + (-1.0 * _x_x_11)) <= -7.0) && (((x_16 + (-1.0 * _x_x_11)) <= -12.0) && (((x_14 + (-1.0 * _x_x_11)) <= -13.0) && (((x_13 + (-1.0 * _x_x_11)) <= -19.0) && (((x_10 + (-1.0 * _x_x_11)) <= -16.0) && (((x_7 + (-1.0 * _x_x_11)) <= -11.0) && (((x_6 + (-1.0 * _x_x_11)) <= -10.0) && (((x_5 + (-1.0 * _x_x_11)) <= -12.0) && (((x_4 + (-1.0 * _x_x_11)) <= -17.0) && (((x_2 + (-1.0 * _x_x_11)) <= -1.0) && ((x_3 + (-1.0 * _x_x_11)) <= -8.0)))))))))))))))))))) && (((x_39 + (-1.0 * _x_x_11)) == -5.0) || (((x_38 + (-1.0 * _x_x_11)) == -19.0) || (((x_36 + (-1.0 * _x_x_11)) == -10.0) || (((x_34 + (-1.0 * _x_x_11)) == -15.0) || (((x_31 + (-1.0 * _x_x_11)) == -15.0) || (((x_30 + (-1.0 * _x_x_11)) == -20.0) || (((x_29 + (-1.0 * _x_x_11)) == -1.0) || (((x_27 + (-1.0 * _x_x_11)) == -6.0) || (((x_26 + (-1.0 * _x_x_11)) == -18.0) || (((x_22 + (-1.0 * _x_x_11)) == -7.0) || (((x_16 + (-1.0 * _x_x_11)) == -12.0) || (((x_14 + (-1.0 * _x_x_11)) == -13.0) || (((x_13 + (-1.0 * _x_x_11)) == -19.0) || (((x_10 + (-1.0 * _x_x_11)) == -16.0) || (((x_7 + (-1.0 * _x_x_11)) == -11.0) || (((x_6 + (-1.0 * _x_x_11)) == -10.0) || (((x_5 + (-1.0 * _x_x_11)) == -12.0) || (((x_4 + (-1.0 * _x_x_11)) == -17.0) || (((x_2 + (-1.0 * _x_x_11)) == -1.0) || ((x_3 + (-1.0 * _x_x_11)) == -8.0)))))))))))))))))))))) && ((((x_37 + (-1.0 * _x_x_12)) <= -10.0) && (((x_35 + (-1.0 * _x_x_12)) <= -2.0) && (((x_34 + (-1.0 * _x_x_12)) <= -15.0) && (((x_32 + (-1.0 * _x_x_12)) <= -4.0) && (((x_30 + (-1.0 * _x_x_12)) <= -7.0) && (((x_27 + (-1.0 * _x_x_12)) <= -6.0) && (((x_26 + (-1.0 * _x_x_12)) <= -18.0) && (((x_23 + (-1.0 * _x_x_12)) <= -1.0) && (((x_21 + (-1.0 * _x_x_12)) <= -13.0) && (((x_20 + (-1.0 * _x_x_12)) <= -17.0) && (((x_19 + (-1.0 * _x_x_12)) <= -20.0) && (((x_13 + (-1.0 * _x_x_12)) <= -20.0) && (((x_11 + (-1.0 * _x_x_12)) <= -10.0) && (((x_8 + (-1.0 * _x_x_12)) <= -13.0) && (((x_7 + (-1.0 * _x_x_12)) <= -13.0) && (((x_6 + (-1.0 * _x_x_12)) <= -2.0) && (((x_3 + (-1.0 * _x_x_12)) <= -13.0) && (((x_2 + (-1.0 * _x_x_12)) <= -19.0) && (((x_0 + (-1.0 * _x_x_12)) <= -2.0) && ((x_1 + (-1.0 * _x_x_12)) <= -5.0)))))))))))))))))))) && (((x_37 + (-1.0 * _x_x_12)) == -10.0) || (((x_35 + (-1.0 * _x_x_12)) == -2.0) || (((x_34 + (-1.0 * _x_x_12)) == -15.0) || (((x_32 + (-1.0 * _x_x_12)) == -4.0) || (((x_30 + (-1.0 * _x_x_12)) == -7.0) || (((x_27 + (-1.0 * _x_x_12)) == -6.0) || (((x_26 + (-1.0 * _x_x_12)) == -18.0) || (((x_23 + (-1.0 * _x_x_12)) == -1.0) || (((x_21 + (-1.0 * _x_x_12)) == -13.0) || (((x_20 + (-1.0 * _x_x_12)) == -17.0) || (((x_19 + (-1.0 * _x_x_12)) == -20.0) || (((x_13 + (-1.0 * _x_x_12)) == -20.0) || (((x_11 + (-1.0 * _x_x_12)) == -10.0) || (((x_8 + (-1.0 * _x_x_12)) == -13.0) || (((x_7 + (-1.0 * _x_x_12)) == -13.0) || (((x_6 + (-1.0 * _x_x_12)) == -2.0) || (((x_3 + (-1.0 * _x_x_12)) == -13.0) || (((x_2 + (-1.0 * _x_x_12)) == -19.0) || (((x_0 + (-1.0 * _x_x_12)) == -2.0) || ((x_1 + (-1.0 * _x_x_12)) == -5.0)))))))))))))))))))))) && ((((x_34 + (-1.0 * _x_x_13)) <= -20.0) && (((x_32 + (-1.0 * _x_x_13)) <= -6.0) && (((x_30 + (-1.0 * _x_x_13)) <= -1.0) && (((x_28 + (-1.0 * _x_x_13)) <= -20.0) && (((x_24 + (-1.0 * _x_x_13)) <= -4.0) && (((x_22 + (-1.0 * _x_x_13)) <= -10.0) && (((x_20 + (-1.0 * _x_x_13)) <= -2.0) && (((x_17 + (-1.0 * _x_x_13)) <= -1.0) && (((x_16 + (-1.0 * _x_x_13)) <= -10.0) && (((x_15 + (-1.0 * _x_x_13)) <= -12.0) && (((x_14 + (-1.0 * _x_x_13)) <= -11.0) && (((x_13 + (-1.0 * _x_x_13)) <= -19.0) && (((x_12 + (-1.0 * _x_x_13)) <= -16.0) && (((x_11 + (-1.0 * _x_x_13)) <= -10.0) && (((x_10 + (-1.0 * _x_x_13)) <= -3.0) && (((x_6 + (-1.0 * _x_x_13)) <= -13.0) && (((x_3 + (-1.0 * _x_x_13)) <= -14.0) && (((x_2 + (-1.0 * _x_x_13)) <= -12.0) && (((x_0 + (-1.0 * _x_x_13)) <= -19.0) && ((x_1 + (-1.0 * _x_x_13)) <= -19.0)))))))))))))))))))) && (((x_34 + (-1.0 * _x_x_13)) == -20.0) || (((x_32 + (-1.0 * _x_x_13)) == -6.0) || (((x_30 + (-1.0 * _x_x_13)) == -1.0) || (((x_28 + (-1.0 * _x_x_13)) == -20.0) || (((x_24 + (-1.0 * _x_x_13)) == -4.0) || (((x_22 + (-1.0 * _x_x_13)) == -10.0) || (((x_20 + (-1.0 * _x_x_13)) == -2.0) || (((x_17 + (-1.0 * _x_x_13)) == -1.0) || (((x_16 + (-1.0 * _x_x_13)) == -10.0) || (((x_15 + (-1.0 * _x_x_13)) == -12.0) || (((x_14 + (-1.0 * _x_x_13)) == -11.0) || (((x_13 + (-1.0 * _x_x_13)) == -19.0) || (((x_12 + (-1.0 * _x_x_13)) == -16.0) || (((x_11 + (-1.0 * _x_x_13)) == -10.0) || (((x_10 + (-1.0 * _x_x_13)) == -3.0) || (((x_6 + (-1.0 * _x_x_13)) == -13.0) || (((x_3 + (-1.0 * _x_x_13)) == -14.0) || (((x_2 + (-1.0 * _x_x_13)) == -12.0) || (((x_0 + (-1.0 * _x_x_13)) == -19.0) || ((x_1 + (-1.0 * _x_x_13)) == -19.0)))))))))))))))))))))) && ((((x_36 + (-1.0 * _x_x_14)) <= -20.0) && (((x_34 + (-1.0 * _x_x_14)) <= -15.0) && (((x_33 + (-1.0 * _x_x_14)) <= -4.0) && (((x_31 + (-1.0 * _x_x_14)) <= -4.0) && (((x_30 + (-1.0 * _x_x_14)) <= -16.0) && (((x_28 + (-1.0 * _x_x_14)) <= -17.0) && (((x_26 + (-1.0 * _x_x_14)) <= -16.0) && (((x_22 + (-1.0 * _x_x_14)) <= -11.0) && (((x_21 + (-1.0 * _x_x_14)) <= -10.0) && (((x_18 + (-1.0 * _x_x_14)) <= -15.0) && (((x_17 + (-1.0 * _x_x_14)) <= -10.0) && (((x_15 + (-1.0 * _x_x_14)) <= -14.0) && (((x_13 + (-1.0 * _x_x_14)) <= -11.0) && (((x_10 + (-1.0 * _x_x_14)) <= -2.0) && (((x_8 + (-1.0 * _x_x_14)) <= -8.0) && (((x_7 + (-1.0 * _x_x_14)) <= -6.0) && (((x_6 + (-1.0 * _x_x_14)) <= -14.0) && (((x_5 + (-1.0 * _x_x_14)) <= -2.0) && (((x_3 + (-1.0 * _x_x_14)) <= -6.0) && ((x_4 + (-1.0 * _x_x_14)) <= -18.0)))))))))))))))))))) && (((x_36 + (-1.0 * _x_x_14)) == -20.0) || (((x_34 + (-1.0 * _x_x_14)) == -15.0) || (((x_33 + (-1.0 * _x_x_14)) == -4.0) || (((x_31 + (-1.0 * _x_x_14)) == -4.0) || (((x_30 + (-1.0 * _x_x_14)) == -16.0) || (((x_28 + (-1.0 * _x_x_14)) == -17.0) || (((x_26 + (-1.0 * _x_x_14)) == -16.0) || (((x_22 + (-1.0 * _x_x_14)) == -11.0) || (((x_21 + (-1.0 * _x_x_14)) == -10.0) || (((x_18 + (-1.0 * _x_x_14)) == -15.0) || (((x_17 + (-1.0 * _x_x_14)) == -10.0) || (((x_15 + (-1.0 * _x_x_14)) == -14.0) || (((x_13 + (-1.0 * _x_x_14)) == -11.0) || (((x_10 + (-1.0 * _x_x_14)) == -2.0) || (((x_8 + (-1.0 * _x_x_14)) == -8.0) || (((x_7 + (-1.0 * _x_x_14)) == -6.0) || (((x_6 + (-1.0 * _x_x_14)) == -14.0) || (((x_5 + (-1.0 * _x_x_14)) == -2.0) || (((x_3 + (-1.0 * _x_x_14)) == -6.0) || ((x_4 + (-1.0 * _x_x_14)) == -18.0)))))))))))))))))))))) && ((((x_39 + (-1.0 * _x_x_15)) <= -14.0) && (((x_38 + (-1.0 * _x_x_15)) <= -1.0) && (((x_36 + (-1.0 * _x_x_15)) <= -16.0) && (((x_35 + (-1.0 * _x_x_15)) <= -7.0) && (((x_34 + (-1.0 * _x_x_15)) <= -2.0) && (((x_33 + (-1.0 * _x_x_15)) <= -11.0) && (((x_20 + (-1.0 * _x_x_15)) <= -8.0) && (((x_18 + (-1.0 * _x_x_15)) <= -8.0) && (((x_16 + (-1.0 * _x_x_15)) <= -2.0) && (((x_15 + (-1.0 * _x_x_15)) <= -14.0) && (((x_14 + (-1.0 * _x_x_15)) <= -16.0) && (((x_12 + (-1.0 * _x_x_15)) <= -9.0) && (((x_11 + (-1.0 * _x_x_15)) <= -11.0) && (((x_9 + (-1.0 * _x_x_15)) <= -18.0) && (((x_8 + (-1.0 * _x_x_15)) <= -1.0) && (((x_7 + (-1.0 * _x_x_15)) <= -17.0) && (((x_6 + (-1.0 * _x_x_15)) <= -16.0) && (((x_5 + (-1.0 * _x_x_15)) <= -16.0) && (((x_1 + (-1.0 * _x_x_15)) <= -20.0) && ((x_2 + (-1.0 * _x_x_15)) <= -9.0)))))))))))))))))))) && (((x_39 + (-1.0 * _x_x_15)) == -14.0) || (((x_38 + (-1.0 * _x_x_15)) == -1.0) || (((x_36 + (-1.0 * _x_x_15)) == -16.0) || (((x_35 + (-1.0 * _x_x_15)) == -7.0) || (((x_34 + (-1.0 * _x_x_15)) == -2.0) || (((x_33 + (-1.0 * _x_x_15)) == -11.0) || (((x_20 + (-1.0 * _x_x_15)) == -8.0) || (((x_18 + (-1.0 * _x_x_15)) == -8.0) || (((x_16 + (-1.0 * _x_x_15)) == -2.0) || (((x_15 + (-1.0 * _x_x_15)) == -14.0) || (((x_14 + (-1.0 * _x_x_15)) == -16.0) || (((x_12 + (-1.0 * _x_x_15)) == -9.0) || (((x_11 + (-1.0 * _x_x_15)) == -11.0) || (((x_9 + (-1.0 * _x_x_15)) == -18.0) || (((x_8 + (-1.0 * _x_x_15)) == -1.0) || (((x_7 + (-1.0 * _x_x_15)) == -17.0) || (((x_6 + (-1.0 * _x_x_15)) == -16.0) || (((x_5 + (-1.0 * _x_x_15)) == -16.0) || (((x_1 + (-1.0 * _x_x_15)) == -20.0) || ((x_2 + (-1.0 * _x_x_15)) == -9.0)))))))))))))))))))))) && ((((x_39 + (-1.0 * _x_x_16)) <= -4.0) && (((x_36 + (-1.0 * _x_x_16)) <= -1.0) && (((x_35 + (-1.0 * _x_x_16)) <= -16.0) && (((x_33 + (-1.0 * _x_x_16)) <= -10.0) && (((x_31 + (-1.0 * _x_x_16)) <= -11.0) && (((x_30 + (-1.0 * _x_x_16)) <= -12.0) && (((x_29 + (-1.0 * _x_x_16)) <= -12.0) && (((x_28 + (-1.0 * _x_x_16)) <= -14.0) && (((x_23 + (-1.0 * _x_x_16)) <= -10.0) && (((x_22 + (-1.0 * _x_x_16)) <= -20.0) && (((x_20 + (-1.0 * _x_x_16)) <= -16.0) && (((x_17 + (-1.0 * _x_x_16)) <= -20.0) && (((x_15 + (-1.0 * _x_x_16)) <= -10.0) && (((x_13 + (-1.0 * _x_x_16)) <= -9.0) && (((x_11 + (-1.0 * _x_x_16)) <= -7.0) && (((x_8 + (-1.0 * _x_x_16)) <= -20.0) && (((x_5 + (-1.0 * _x_x_16)) <= -16.0) && (((x_4 + (-1.0 * _x_x_16)) <= -10.0) && (((x_1 + (-1.0 * _x_x_16)) <= -14.0) && ((x_2 + (-1.0 * _x_x_16)) <= -7.0)))))))))))))))))))) && (((x_39 + (-1.0 * _x_x_16)) == -4.0) || (((x_36 + (-1.0 * _x_x_16)) == -1.0) || (((x_35 + (-1.0 * _x_x_16)) == -16.0) || (((x_33 + (-1.0 * _x_x_16)) == -10.0) || (((x_31 + (-1.0 * _x_x_16)) == -11.0) || (((x_30 + (-1.0 * _x_x_16)) == -12.0) || (((x_29 + (-1.0 * _x_x_16)) == -12.0) || (((x_28 + (-1.0 * _x_x_16)) == -14.0) || (((x_23 + (-1.0 * _x_x_16)) == -10.0) || (((x_22 + (-1.0 * _x_x_16)) == -20.0) || (((x_20 + (-1.0 * _x_x_16)) == -16.0) || (((x_17 + (-1.0 * _x_x_16)) == -20.0) || (((x_15 + (-1.0 * _x_x_16)) == -10.0) || (((x_13 + (-1.0 * _x_x_16)) == -9.0) || (((x_11 + (-1.0 * _x_x_16)) == -7.0) || (((x_8 + (-1.0 * _x_x_16)) == -20.0) || (((x_5 + (-1.0 * _x_x_16)) == -16.0) || (((x_4 + (-1.0 * _x_x_16)) == -10.0) || (((x_1 + (-1.0 * _x_x_16)) == -14.0) || ((x_2 + (-1.0 * _x_x_16)) == -7.0)))))))))))))))))))))) && ((((x_38 + (-1.0 * _x_x_17)) <= -9.0) && (((x_37 + (-1.0 * _x_x_17)) <= -2.0) && (((x_36 + (-1.0 * _x_x_17)) <= -16.0) && (((x_35 + (-1.0 * _x_x_17)) <= -14.0) && (((x_32 + (-1.0 * _x_x_17)) <= -12.0) && (((x_31 + (-1.0 * _x_x_17)) <= -8.0) && (((x_28 + (-1.0 * _x_x_17)) <= -12.0) && (((x_26 + (-1.0 * _x_x_17)) <= -5.0) && (((x_25 + (-1.0 * _x_x_17)) <= -3.0) && (((x_22 + (-1.0 * _x_x_17)) <= -1.0) && (((x_20 + (-1.0 * _x_x_17)) <= -2.0) && (((x_19 + (-1.0 * _x_x_17)) <= -10.0) && (((x_16 + (-1.0 * _x_x_17)) <= -8.0) && (((x_14 + (-1.0 * _x_x_17)) <= -8.0) && (((x_11 + (-1.0 * _x_x_17)) <= -8.0) && (((x_10 + (-1.0 * _x_x_17)) <= -11.0) && (((x_8 + (-1.0 * _x_x_17)) <= -4.0) && (((x_5 + (-1.0 * _x_x_17)) <= -14.0) && (((x_0 + (-1.0 * _x_x_17)) <= -3.0) && ((x_4 + (-1.0 * _x_x_17)) <= -10.0)))))))))))))))))))) && (((x_38 + (-1.0 * _x_x_17)) == -9.0) || (((x_37 + (-1.0 * _x_x_17)) == -2.0) || (((x_36 + (-1.0 * _x_x_17)) == -16.0) || (((x_35 + (-1.0 * _x_x_17)) == -14.0) || (((x_32 + (-1.0 * _x_x_17)) == -12.0) || (((x_31 + (-1.0 * _x_x_17)) == -8.0) || (((x_28 + (-1.0 * _x_x_17)) == -12.0) || (((x_26 + (-1.0 * _x_x_17)) == -5.0) || (((x_25 + (-1.0 * _x_x_17)) == -3.0) || (((x_22 + (-1.0 * _x_x_17)) == -1.0) || (((x_20 + (-1.0 * _x_x_17)) == -2.0) || (((x_19 + (-1.0 * _x_x_17)) == -10.0) || (((x_16 + (-1.0 * _x_x_17)) == -8.0) || (((x_14 + (-1.0 * _x_x_17)) == -8.0) || (((x_11 + (-1.0 * _x_x_17)) == -8.0) || (((x_10 + (-1.0 * _x_x_17)) == -11.0) || (((x_8 + (-1.0 * _x_x_17)) == -4.0) || (((x_5 + (-1.0 * _x_x_17)) == -14.0) || (((x_0 + (-1.0 * _x_x_17)) == -3.0) || ((x_4 + (-1.0 * _x_x_17)) == -10.0)))))))))))))))))))))) && ((((x_39 + (-1.0 * _x_x_18)) <= -2.0) && (((x_37 + (-1.0 * _x_x_18)) <= -10.0) && (((x_36 + (-1.0 * _x_x_18)) <= -8.0) && (((x_35 + (-1.0 * _x_x_18)) <= -18.0) && (((x_33 + (-1.0 * _x_x_18)) <= -3.0) && (((x_31 + (-1.0 * _x_x_18)) <= -6.0) && (((x_29 + (-1.0 * _x_x_18)) <= -20.0) && (((x_28 + (-1.0 * _x_x_18)) <= -6.0) && (((x_25 + (-1.0 * _x_x_18)) <= -6.0) && (((x_24 + (-1.0 * _x_x_18)) <= -3.0) && (((x_20 + (-1.0 * _x_x_18)) <= -18.0) && (((x_19 + (-1.0 * _x_x_18)) <= -19.0) && (((x_17 + (-1.0 * _x_x_18)) <= -1.0) && (((x_15 + (-1.0 * _x_x_18)) <= -20.0) && (((x_12 + (-1.0 * _x_x_18)) <= -12.0) && (((x_11 + (-1.0 * _x_x_18)) <= -15.0) && (((x_6 + (-1.0 * _x_x_18)) <= -18.0) && (((x_2 + (-1.0 * _x_x_18)) <= -20.0) && (((x_0 + (-1.0 * _x_x_18)) <= -13.0) && ((x_1 + (-1.0 * _x_x_18)) <= -8.0)))))))))))))))))))) && (((x_39 + (-1.0 * _x_x_18)) == -2.0) || (((x_37 + (-1.0 * _x_x_18)) == -10.0) || (((x_36 + (-1.0 * _x_x_18)) == -8.0) || (((x_35 + (-1.0 * _x_x_18)) == -18.0) || (((x_33 + (-1.0 * _x_x_18)) == -3.0) || (((x_31 + (-1.0 * _x_x_18)) == -6.0) || (((x_29 + (-1.0 * _x_x_18)) == -20.0) || (((x_28 + (-1.0 * _x_x_18)) == -6.0) || (((x_25 + (-1.0 * _x_x_18)) == -6.0) || (((x_24 + (-1.0 * _x_x_18)) == -3.0) || (((x_20 + (-1.0 * _x_x_18)) == -18.0) || (((x_19 + (-1.0 * _x_x_18)) == -19.0) || (((x_17 + (-1.0 * _x_x_18)) == -1.0) || (((x_15 + (-1.0 * _x_x_18)) == -20.0) || (((x_12 + (-1.0 * _x_x_18)) == -12.0) || (((x_11 + (-1.0 * _x_x_18)) == -15.0) || (((x_6 + (-1.0 * _x_x_18)) == -18.0) || (((x_2 + (-1.0 * _x_x_18)) == -20.0) || (((x_0 + (-1.0 * _x_x_18)) == -13.0) || ((x_1 + (-1.0 * _x_x_18)) == -8.0)))))))))))))))))))))) && ((((x_39 + (-1.0 * _x_x_19)) <= -16.0) && (((x_36 + (-1.0 * _x_x_19)) <= -9.0) && (((x_35 + (-1.0 * _x_x_19)) <= -17.0) && (((x_34 + (-1.0 * _x_x_19)) <= -10.0) && (((x_33 + (-1.0 * _x_x_19)) <= -1.0) && (((x_32 + (-1.0 * _x_x_19)) <= -2.0) && (((x_31 + (-1.0 * _x_x_19)) <= -15.0) && (((x_30 + (-1.0 * _x_x_19)) <= -16.0) && (((x_27 + (-1.0 * _x_x_19)) <= -10.0) && (((x_26 + (-1.0 * _x_x_19)) <= -9.0) && (((x_23 + (-1.0 * _x_x_19)) <= -17.0) && (((x_22 + (-1.0 * _x_x_19)) <= -2.0) && (((x_21 + (-1.0 * _x_x_19)) <= -9.0) && (((x_18 + (-1.0 * _x_x_19)) <= -16.0) && (((x_17 + (-1.0 * _x_x_19)) <= -9.0) && (((x_13 + (-1.0 * _x_x_19)) <= -3.0) && (((x_11 + (-1.0 * _x_x_19)) <= -1.0) && (((x_7 + (-1.0 * _x_x_19)) <= -4.0) && (((x_1 + (-1.0 * _x_x_19)) <= -9.0) && ((x_4 + (-1.0 * _x_x_19)) <= -4.0)))))))))))))))))))) && (((x_39 + (-1.0 * _x_x_19)) == -16.0) || (((x_36 + (-1.0 * _x_x_19)) == -9.0) || (((x_35 + (-1.0 * _x_x_19)) == -17.0) || (((x_34 + (-1.0 * _x_x_19)) == -10.0) || (((x_33 + (-1.0 * _x_x_19)) == -1.0) || (((x_32 + (-1.0 * _x_x_19)) == -2.0) || (((x_31 + (-1.0 * _x_x_19)) == -15.0) || (((x_30 + (-1.0 * _x_x_19)) == -16.0) || (((x_27 + (-1.0 * _x_x_19)) == -10.0) || (((x_26 + (-1.0 * _x_x_19)) == -9.0) || (((x_23 + (-1.0 * _x_x_19)) == -17.0) || (((x_22 + (-1.0 * _x_x_19)) == -2.0) || (((x_21 + (-1.0 * _x_x_19)) == -9.0) || (((x_18 + (-1.0 * _x_x_19)) == -16.0) || (((x_17 + (-1.0 * _x_x_19)) == -9.0) || (((x_13 + (-1.0 * _x_x_19)) == -3.0) || (((x_11 + (-1.0 * _x_x_19)) == -1.0) || (((x_7 + (-1.0 * _x_x_19)) == -4.0) || (((x_1 + (-1.0 * _x_x_19)) == -9.0) || ((x_4 + (-1.0 * _x_x_19)) == -4.0)))))))))))))))))))))) && ((((x_36 + (-1.0 * _x_x_20)) <= -4.0) && (((x_32 + (-1.0 * _x_x_20)) <= -12.0) && (((x_30 + (-1.0 * _x_x_20)) <= -19.0) && (((x_29 + (-1.0 * _x_x_20)) <= -10.0) && (((x_24 + (-1.0 * _x_x_20)) <= -6.0) && (((x_23 + (-1.0 * _x_x_20)) <= -4.0) && (((x_20 + (-1.0 * _x_x_20)) <= -10.0) && (((x_19 + (-1.0 * _x_x_20)) <= -2.0) && (((x_16 + (-1.0 * _x_x_20)) <= -10.0) && (((x_15 + (-1.0 * _x_x_20)) <= -8.0) && (((x_14 + (-1.0 * _x_x_20)) <= -19.0) && (((x_13 + (-1.0 * _x_x_20)) <= -8.0) && (((x_12 + (-1.0 * _x_x_20)) <= -20.0) && (((x_10 + (-1.0 * _x_x_20)) <= -3.0) && (((x_9 + (-1.0 * _x_x_20)) <= -11.0) && (((x_7 + (-1.0 * _x_x_20)) <= -1.0) && (((x_6 + (-1.0 * _x_x_20)) <= -12.0) && (((x_4 + (-1.0 * _x_x_20)) <= -10.0) && (((x_0 + (-1.0 * _x_x_20)) <= -19.0) && ((x_2 + (-1.0 * _x_x_20)) <= -8.0)))))))))))))))))))) && (((x_36 + (-1.0 * _x_x_20)) == -4.0) || (((x_32 + (-1.0 * _x_x_20)) == -12.0) || (((x_30 + (-1.0 * _x_x_20)) == -19.0) || (((x_29 + (-1.0 * _x_x_20)) == -10.0) || (((x_24 + (-1.0 * _x_x_20)) == -6.0) || (((x_23 + (-1.0 * _x_x_20)) == -4.0) || (((x_20 + (-1.0 * _x_x_20)) == -10.0) || (((x_19 + (-1.0 * _x_x_20)) == -2.0) || (((x_16 + (-1.0 * _x_x_20)) == -10.0) || (((x_15 + (-1.0 * _x_x_20)) == -8.0) || (((x_14 + (-1.0 * _x_x_20)) == -19.0) || (((x_13 + (-1.0 * _x_x_20)) == -8.0) || (((x_12 + (-1.0 * _x_x_20)) == -20.0) || (((x_10 + (-1.0 * _x_x_20)) == -3.0) || (((x_9 + (-1.0 * _x_x_20)) == -11.0) || (((x_7 + (-1.0 * _x_x_20)) == -1.0) || (((x_6 + (-1.0 * _x_x_20)) == -12.0) || (((x_4 + (-1.0 * _x_x_20)) == -10.0) || (((x_0 + (-1.0 * _x_x_20)) == -19.0) || ((x_2 + (-1.0 * _x_x_20)) == -8.0)))))))))))))))))))))) && ((((x_37 + (-1.0 * _x_x_21)) <= -9.0) && (((x_36 + (-1.0 * _x_x_21)) <= -5.0) && (((x_35 + (-1.0 * _x_x_21)) <= -6.0) && (((x_33 + (-1.0 * _x_x_21)) <= -6.0) && (((x_32 + (-1.0 * _x_x_21)) <= -3.0) && (((x_29 + (-1.0 * _x_x_21)) <= -15.0) && (((x_28 + (-1.0 * _x_x_21)) <= -19.0) && (((x_26 + (-1.0 * _x_x_21)) <= -8.0) && (((x_23 + (-1.0 * _x_x_21)) <= -4.0) && (((x_22 + (-1.0 * _x_x_21)) <= -3.0) && (((x_21 + (-1.0 * _x_x_21)) <= -16.0) && (((x_20 + (-1.0 * _x_x_21)) <= -10.0) && (((x_19 + (-1.0 * _x_x_21)) <= -2.0) && (((x_18 + (-1.0 * _x_x_21)) <= -13.0) && (((x_17 + (-1.0 * _x_x_21)) <= -13.0) && (((x_16 + (-1.0 * _x_x_21)) <= -17.0) && (((x_12 + (-1.0 * _x_x_21)) <= -2.0) && (((x_11 + (-1.0 * _x_x_21)) <= -2.0) && (((x_4 + (-1.0 * _x_x_21)) <= -14.0) && ((x_10 + (-1.0 * _x_x_21)) <= -1.0)))))))))))))))))))) && (((x_37 + (-1.0 * _x_x_21)) == -9.0) || (((x_36 + (-1.0 * _x_x_21)) == -5.0) || (((x_35 + (-1.0 * _x_x_21)) == -6.0) || (((x_33 + (-1.0 * _x_x_21)) == -6.0) || (((x_32 + (-1.0 * _x_x_21)) == -3.0) || (((x_29 + (-1.0 * _x_x_21)) == -15.0) || (((x_28 + (-1.0 * _x_x_21)) == -19.0) || (((x_26 + (-1.0 * _x_x_21)) == -8.0) || (((x_23 + (-1.0 * _x_x_21)) == -4.0) || (((x_22 + (-1.0 * _x_x_21)) == -3.0) || (((x_21 + (-1.0 * _x_x_21)) == -16.0) || (((x_20 + (-1.0 * _x_x_21)) == -10.0) || (((x_19 + (-1.0 * _x_x_21)) == -2.0) || (((x_18 + (-1.0 * _x_x_21)) == -13.0) || (((x_17 + (-1.0 * _x_x_21)) == -13.0) || (((x_16 + (-1.0 * _x_x_21)) == -17.0) || (((x_12 + (-1.0 * _x_x_21)) == -2.0) || (((x_11 + (-1.0 * _x_x_21)) == -2.0) || (((x_4 + (-1.0 * _x_x_21)) == -14.0) || ((x_10 + (-1.0 * _x_x_21)) == -1.0)))))))))))))))))))))) && ((((x_39 + (-1.0 * _x_x_22)) <= -14.0) && (((x_35 + (-1.0 * _x_x_22)) <= -1.0) && (((x_34 + (-1.0 * _x_x_22)) <= -12.0) && (((x_31 + (-1.0 * _x_x_22)) <= -5.0) && (((x_29 + (-1.0 * _x_x_22)) <= -14.0) && (((x_25 + (-1.0 * _x_x_22)) <= -11.0) && (((x_24 + (-1.0 * _x_x_22)) <= -15.0) && (((x_22 + (-1.0 * _x_x_22)) <= -20.0) && (((x_21 + (-1.0 * _x_x_22)) <= -13.0) && (((x_18 + (-1.0 * _x_x_22)) <= -5.0) && (((x_17 + (-1.0 * _x_x_22)) <= -19.0) && (((x_16 + (-1.0 * _x_x_22)) <= -7.0) && (((x_13 + (-1.0 * _x_x_22)) <= -20.0) && (((x_12 + (-1.0 * _x_x_22)) <= -12.0) && (((x_10 + (-1.0 * _x_x_22)) <= -16.0) && (((x_7 + (-1.0 * _x_x_22)) <= -14.0) && (((x_6 + (-1.0 * _x_x_22)) <= -14.0) && (((x_5 + (-1.0 * _x_x_22)) <= -7.0) && (((x_2 + (-1.0 * _x_x_22)) <= -4.0) && ((x_3 + (-1.0 * _x_x_22)) <= -11.0)))))))))))))))))))) && (((x_39 + (-1.0 * _x_x_22)) == -14.0) || (((x_35 + (-1.0 * _x_x_22)) == -1.0) || (((x_34 + (-1.0 * _x_x_22)) == -12.0) || (((x_31 + (-1.0 * _x_x_22)) == -5.0) || (((x_29 + (-1.0 * _x_x_22)) == -14.0) || (((x_25 + (-1.0 * _x_x_22)) == -11.0) || (((x_24 + (-1.0 * _x_x_22)) == -15.0) || (((x_22 + (-1.0 * _x_x_22)) == -20.0) || (((x_21 + (-1.0 * _x_x_22)) == -13.0) || (((x_18 + (-1.0 * _x_x_22)) == -5.0) || (((x_17 + (-1.0 * _x_x_22)) == -19.0) || (((x_16 + (-1.0 * _x_x_22)) == -7.0) || (((x_13 + (-1.0 * _x_x_22)) == -20.0) || (((x_12 + (-1.0 * _x_x_22)) == -12.0) || (((x_10 + (-1.0 * _x_x_22)) == -16.0) || (((x_7 + (-1.0 * _x_x_22)) == -14.0) || (((x_6 + (-1.0 * _x_x_22)) == -14.0) || (((x_5 + (-1.0 * _x_x_22)) == -7.0) || (((x_2 + (-1.0 * _x_x_22)) == -4.0) || ((x_3 + (-1.0 * _x_x_22)) == -11.0)))))))))))))))))))))) && ((((x_39 + (-1.0 * _x_x_23)) <= -9.0) && (((x_37 + (-1.0 * _x_x_23)) <= -17.0) && (((x_36 + (-1.0 * _x_x_23)) <= -19.0) && (((x_35 + (-1.0 * _x_x_23)) <= -15.0) && (((x_34 + (-1.0 * _x_x_23)) <= -13.0) && (((x_33 + (-1.0 * _x_x_23)) <= -2.0) && (((x_26 + (-1.0 * _x_x_23)) <= -19.0) && (((x_23 + (-1.0 * _x_x_23)) <= -13.0) && (((x_21 + (-1.0 * _x_x_23)) <= -17.0) && (((x_20 + (-1.0 * _x_x_23)) <= -11.0) && (((x_19 + (-1.0 * _x_x_23)) <= -18.0) && (((x_17 + (-1.0 * _x_x_23)) <= -9.0) && (((x_16 + (-1.0 * _x_x_23)) <= -14.0) && (((x_15 + (-1.0 * _x_x_23)) <= -10.0) && (((x_13 + (-1.0 * _x_x_23)) <= -7.0) && (((x_10 + (-1.0 * _x_x_23)) <= -16.0) && (((x_6 + (-1.0 * _x_x_23)) <= -8.0) && (((x_4 + (-1.0 * _x_x_23)) <= -7.0) && (((x_0 + (-1.0 * _x_x_23)) <= -19.0) && ((x_3 + (-1.0 * _x_x_23)) <= -17.0)))))))))))))))))))) && (((x_39 + (-1.0 * _x_x_23)) == -9.0) || (((x_37 + (-1.0 * _x_x_23)) == -17.0) || (((x_36 + (-1.0 * _x_x_23)) == -19.0) || (((x_35 + (-1.0 * _x_x_23)) == -15.0) || (((x_34 + (-1.0 * _x_x_23)) == -13.0) || (((x_33 + (-1.0 * _x_x_23)) == -2.0) || (((x_26 + (-1.0 * _x_x_23)) == -19.0) || (((x_23 + (-1.0 * _x_x_23)) == -13.0) || (((x_21 + (-1.0 * _x_x_23)) == -17.0) || (((x_20 + (-1.0 * _x_x_23)) == -11.0) || (((x_19 + (-1.0 * _x_x_23)) == -18.0) || (((x_17 + (-1.0 * _x_x_23)) == -9.0) || (((x_16 + (-1.0 * _x_x_23)) == -14.0) || (((x_15 + (-1.0 * _x_x_23)) == -10.0) || (((x_13 + (-1.0 * _x_x_23)) == -7.0) || (((x_10 + (-1.0 * _x_x_23)) == -16.0) || (((x_6 + (-1.0 * _x_x_23)) == -8.0) || (((x_4 + (-1.0 * _x_x_23)) == -7.0) || (((x_0 + (-1.0 * _x_x_23)) == -19.0) || ((x_3 + (-1.0 * _x_x_23)) == -17.0)))))))))))))))))))))) && ((((x_39 + (-1.0 * _x_x_24)) <= -1.0) && (((x_37 + (-1.0 * _x_x_24)) <= -11.0) && (((x_36 + (-1.0 * _x_x_24)) <= -8.0) && (((x_35 + (-1.0 * _x_x_24)) <= -16.0) && (((x_28 + (-1.0 * _x_x_24)) <= -19.0) && (((x_24 + (-1.0 * _x_x_24)) <= -3.0) && (((x_23 + (-1.0 * _x_x_24)) <= -20.0) && (((x_22 + (-1.0 * _x_x_24)) <= -12.0) && (((x_21 + (-1.0 * _x_x_24)) <= -4.0) && (((x_20 + (-1.0 * _x_x_24)) <= -11.0) && (((x_18 + (-1.0 * _x_x_24)) <= -15.0) && (((x_17 + (-1.0 * _x_x_24)) <= -7.0) && (((x_15 + (-1.0 * _x_x_24)) <= -15.0) && (((x_13 + (-1.0 * _x_x_24)) <= -16.0) && (((x_10 + (-1.0 * _x_x_24)) <= -10.0) && (((x_6 + (-1.0 * _x_x_24)) <= -17.0) && (((x_5 + (-1.0 * _x_x_24)) <= -20.0) && (((x_3 + (-1.0 * _x_x_24)) <= -4.0) && (((x_0 + (-1.0 * _x_x_24)) <= -15.0) && ((x_1 + (-1.0 * _x_x_24)) <= -17.0)))))))))))))))))))) && (((x_39 + (-1.0 * _x_x_24)) == -1.0) || (((x_37 + (-1.0 * _x_x_24)) == -11.0) || (((x_36 + (-1.0 * _x_x_24)) == -8.0) || (((x_35 + (-1.0 * _x_x_24)) == -16.0) || (((x_28 + (-1.0 * _x_x_24)) == -19.0) || (((x_24 + (-1.0 * _x_x_24)) == -3.0) || (((x_23 + (-1.0 * _x_x_24)) == -20.0) || (((x_22 + (-1.0 * _x_x_24)) == -12.0) || (((x_21 + (-1.0 * _x_x_24)) == -4.0) || (((x_20 + (-1.0 * _x_x_24)) == -11.0) || (((x_18 + (-1.0 * _x_x_24)) == -15.0) || (((x_17 + (-1.0 * _x_x_24)) == -7.0) || (((x_15 + (-1.0 * _x_x_24)) == -15.0) || (((x_13 + (-1.0 * _x_x_24)) == -16.0) || (((x_10 + (-1.0 * _x_x_24)) == -10.0) || (((x_6 + (-1.0 * _x_x_24)) == -17.0) || (((x_5 + (-1.0 * _x_x_24)) == -20.0) || (((x_3 + (-1.0 * _x_x_24)) == -4.0) || (((x_0 + (-1.0 * _x_x_24)) == -15.0) || ((x_1 + (-1.0 * _x_x_24)) == -17.0)))))))))))))))))))))) && ((((x_35 + (-1.0 * _x_x_25)) <= -8.0) && (((x_33 + (-1.0 * _x_x_25)) <= -5.0) && (((x_32 + (-1.0 * _x_x_25)) <= -5.0) && (((x_30 + (-1.0 * _x_x_25)) <= -7.0) && (((x_29 + (-1.0 * _x_x_25)) <= -10.0) && (((x_28 + (-1.0 * _x_x_25)) <= -11.0) && (((x_27 + (-1.0 * _x_x_25)) <= -14.0) && (((x_24 + (-1.0 * _x_x_25)) <= -13.0) && (((x_23 + (-1.0 * _x_x_25)) <= -11.0) && (((x_22 + (-1.0 * _x_x_25)) <= -10.0) && (((x_21 + (-1.0 * _x_x_25)) <= -20.0) && (((x_20 + (-1.0 * _x_x_25)) <= -8.0) && (((x_18 + (-1.0 * _x_x_25)) <= -8.0) && (((x_16 + (-1.0 * _x_x_25)) <= -7.0) && (((x_14 + (-1.0 * _x_x_25)) <= -1.0) && (((x_12 + (-1.0 * _x_x_25)) <= -3.0) && (((x_8 + (-1.0 * _x_x_25)) <= -14.0) && (((x_6 + (-1.0 * _x_x_25)) <= -12.0) && (((x_1 + (-1.0 * _x_x_25)) <= -16.0) && ((x_3 + (-1.0 * _x_x_25)) <= -1.0)))))))))))))))))))) && (((x_35 + (-1.0 * _x_x_25)) == -8.0) || (((x_33 + (-1.0 * _x_x_25)) == -5.0) || (((x_32 + (-1.0 * _x_x_25)) == -5.0) || (((x_30 + (-1.0 * _x_x_25)) == -7.0) || (((x_29 + (-1.0 * _x_x_25)) == -10.0) || (((x_28 + (-1.0 * _x_x_25)) == -11.0) || (((x_27 + (-1.0 * _x_x_25)) == -14.0) || (((x_24 + (-1.0 * _x_x_25)) == -13.0) || (((x_23 + (-1.0 * _x_x_25)) == -11.0) || (((x_22 + (-1.0 * _x_x_25)) == -10.0) || (((x_21 + (-1.0 * _x_x_25)) == -20.0) || (((x_20 + (-1.0 * _x_x_25)) == -8.0) || (((x_18 + (-1.0 * _x_x_25)) == -8.0) || (((x_16 + (-1.0 * _x_x_25)) == -7.0) || (((x_14 + (-1.0 * _x_x_25)) == -1.0) || (((x_12 + (-1.0 * _x_x_25)) == -3.0) || (((x_8 + (-1.0 * _x_x_25)) == -14.0) || (((x_6 + (-1.0 * _x_x_25)) == -12.0) || (((x_1 + (-1.0 * _x_x_25)) == -16.0) || ((x_3 + (-1.0 * _x_x_25)) == -1.0)))))))))))))))))))))) && ((((x_39 + (-1.0 * _x_x_26)) <= -7.0) && (((x_38 + (-1.0 * _x_x_26)) <= -15.0) && (((x_37 + (-1.0 * _x_x_26)) <= -18.0) && (((x_32 + (-1.0 * _x_x_26)) <= -7.0) && (((x_30 + (-1.0 * _x_x_26)) <= -3.0) && (((x_29 + (-1.0 * _x_x_26)) <= -8.0) && (((x_28 + (-1.0 * _x_x_26)) <= -6.0) && (((x_26 + (-1.0 * _x_x_26)) <= -8.0) && (((x_25 + (-1.0 * _x_x_26)) <= -4.0) && (((x_24 + (-1.0 * _x_x_26)) <= -10.0) && (((x_23 + (-1.0 * _x_x_26)) <= -9.0) && (((x_21 + (-1.0 * _x_x_26)) <= -11.0) && (((x_19 + (-1.0 * _x_x_26)) <= -19.0) && (((x_18 + (-1.0 * _x_x_26)) <= -11.0) && (((x_17 + (-1.0 * _x_x_26)) <= -15.0) && (((x_16 + (-1.0 * _x_x_26)) <= -16.0) && (((x_9 + (-1.0 * _x_x_26)) <= -9.0) && (((x_7 + (-1.0 * _x_x_26)) <= -12.0) && (((x_0 + (-1.0 * _x_x_26)) <= -6.0) && ((x_1 + (-1.0 * _x_x_26)) <= -20.0)))))))))))))))))))) && (((x_39 + (-1.0 * _x_x_26)) == -7.0) || (((x_38 + (-1.0 * _x_x_26)) == -15.0) || (((x_37 + (-1.0 * _x_x_26)) == -18.0) || (((x_32 + (-1.0 * _x_x_26)) == -7.0) || (((x_30 + (-1.0 * _x_x_26)) == -3.0) || (((x_29 + (-1.0 * _x_x_26)) == -8.0) || (((x_28 + (-1.0 * _x_x_26)) == -6.0) || (((x_26 + (-1.0 * _x_x_26)) == -8.0) || (((x_25 + (-1.0 * _x_x_26)) == -4.0) || (((x_24 + (-1.0 * _x_x_26)) == -10.0) || (((x_23 + (-1.0 * _x_x_26)) == -9.0) || (((x_21 + (-1.0 * _x_x_26)) == -11.0) || (((x_19 + (-1.0 * _x_x_26)) == -19.0) || (((x_18 + (-1.0 * _x_x_26)) == -11.0) || (((x_17 + (-1.0 * _x_x_26)) == -15.0) || (((x_16 + (-1.0 * _x_x_26)) == -16.0) || (((x_9 + (-1.0 * _x_x_26)) == -9.0) || (((x_7 + (-1.0 * _x_x_26)) == -12.0) || (((x_0 + (-1.0 * _x_x_26)) == -6.0) || ((x_1 + (-1.0 * _x_x_26)) == -20.0)))))))))))))))))))))) && ((((x_39 + (-1.0 * _x_x_27)) <= -18.0) && (((x_37 + (-1.0 * _x_x_27)) <= -18.0) && (((x_33 + (-1.0 * _x_x_27)) <= -4.0) && (((x_32 + (-1.0 * _x_x_27)) <= -17.0) && (((x_30 + (-1.0 * _x_x_27)) <= -10.0) && (((x_28 + (-1.0 * _x_x_27)) <= -13.0) && (((x_25 + (-1.0 * _x_x_27)) <= -19.0) && (((x_23 + (-1.0 * _x_x_27)) <= -1.0) && (((x_21 + (-1.0 * _x_x_27)) <= -15.0) && (((x_20 + (-1.0 * _x_x_27)) <= -14.0) && (((x_19 + (-1.0 * _x_x_27)) <= -14.0) && (((x_17 + (-1.0 * _x_x_27)) <= -4.0) && (((x_16 + (-1.0 * _x_x_27)) <= -13.0) && (((x_15 + (-1.0 * _x_x_27)) <= -6.0) && (((x_13 + (-1.0 * _x_x_27)) <= -18.0) && (((x_10 + (-1.0 * _x_x_27)) <= -8.0) && (((x_9 + (-1.0 * _x_x_27)) <= -15.0) && (((x_8 + (-1.0 * _x_x_27)) <= -17.0) && (((x_0 + (-1.0 * _x_x_27)) <= -12.0) && ((x_4 + (-1.0 * _x_x_27)) <= -11.0)))))))))))))))))))) && (((x_39 + (-1.0 * _x_x_27)) == -18.0) || (((x_37 + (-1.0 * _x_x_27)) == -18.0) || (((x_33 + (-1.0 * _x_x_27)) == -4.0) || (((x_32 + (-1.0 * _x_x_27)) == -17.0) || (((x_30 + (-1.0 * _x_x_27)) == -10.0) || (((x_28 + (-1.0 * _x_x_27)) == -13.0) || (((x_25 + (-1.0 * _x_x_27)) == -19.0) || (((x_23 + (-1.0 * _x_x_27)) == -1.0) || (((x_21 + (-1.0 * _x_x_27)) == -15.0) || (((x_20 + (-1.0 * _x_x_27)) == -14.0) || (((x_19 + (-1.0 * _x_x_27)) == -14.0) || (((x_17 + (-1.0 * _x_x_27)) == -4.0) || (((x_16 + (-1.0 * _x_x_27)) == -13.0) || (((x_15 + (-1.0 * _x_x_27)) == -6.0) || (((x_13 + (-1.0 * _x_x_27)) == -18.0) || (((x_10 + (-1.0 * _x_x_27)) == -8.0) || (((x_9 + (-1.0 * _x_x_27)) == -15.0) || (((x_8 + (-1.0 * _x_x_27)) == -17.0) || (((x_0 + (-1.0 * _x_x_27)) == -12.0) || ((x_4 + (-1.0 * _x_x_27)) == -11.0)))))))))))))))))))))) && ((((x_39 + (-1.0 * _x_x_28)) <= -4.0) && (((x_38 + (-1.0 * _x_x_28)) <= -5.0) && (((x_37 + (-1.0 * _x_x_28)) <= -18.0) && (((x_36 + (-1.0 * _x_x_28)) <= -17.0) && (((x_35 + (-1.0 * _x_x_28)) <= -1.0) && (((x_34 + (-1.0 * _x_x_28)) <= -15.0) && (((x_33 + (-1.0 * _x_x_28)) <= -13.0) && (((x_32 + (-1.0 * _x_x_28)) <= -12.0) && (((x_29 + (-1.0 * _x_x_28)) <= -19.0) && (((x_28 + (-1.0 * _x_x_28)) <= -10.0) && (((x_27 + (-1.0 * _x_x_28)) <= -5.0) && (((x_26 + (-1.0 * _x_x_28)) <= -4.0) && (((x_24 + (-1.0 * _x_x_28)) <= -14.0) && (((x_23 + (-1.0 * _x_x_28)) <= -20.0) && (((x_17 + (-1.0 * _x_x_28)) <= -8.0) && (((x_10 + (-1.0 * _x_x_28)) <= -4.0) && (((x_9 + (-1.0 * _x_x_28)) <= -12.0) && (((x_4 + (-1.0 * _x_x_28)) <= -16.0) && (((x_2 + (-1.0 * _x_x_28)) <= -10.0) && ((x_3 + (-1.0 * _x_x_28)) <= -11.0)))))))))))))))))))) && (((x_39 + (-1.0 * _x_x_28)) == -4.0) || (((x_38 + (-1.0 * _x_x_28)) == -5.0) || (((x_37 + (-1.0 * _x_x_28)) == -18.0) || (((x_36 + (-1.0 * _x_x_28)) == -17.0) || (((x_35 + (-1.0 * _x_x_28)) == -1.0) || (((x_34 + (-1.0 * _x_x_28)) == -15.0) || (((x_33 + (-1.0 * _x_x_28)) == -13.0) || (((x_32 + (-1.0 * _x_x_28)) == -12.0) || (((x_29 + (-1.0 * _x_x_28)) == -19.0) || (((x_28 + (-1.0 * _x_x_28)) == -10.0) || (((x_27 + (-1.0 * _x_x_28)) == -5.0) || (((x_26 + (-1.0 * _x_x_28)) == -4.0) || (((x_24 + (-1.0 * _x_x_28)) == -14.0) || (((x_23 + (-1.0 * _x_x_28)) == -20.0) || (((x_17 + (-1.0 * _x_x_28)) == -8.0) || (((x_10 + (-1.0 * _x_x_28)) == -4.0) || (((x_9 + (-1.0 * _x_x_28)) == -12.0) || (((x_4 + (-1.0 * _x_x_28)) == -16.0) || (((x_2 + (-1.0 * _x_x_28)) == -10.0) || ((x_3 + (-1.0 * _x_x_28)) == -11.0)))))))))))))))))))))) && ((((x_38 + (-1.0 * _x_x_29)) <= -17.0) && (((x_36 + (-1.0 * _x_x_29)) <= -15.0) && (((x_35 + (-1.0 * _x_x_29)) <= -14.0) && (((x_34 + (-1.0 * _x_x_29)) <= -19.0) && (((x_30 + (-1.0 * _x_x_29)) <= -2.0) && (((x_29 + (-1.0 * _x_x_29)) <= -2.0) && (((x_26 + (-1.0 * _x_x_29)) <= -8.0) && (((x_23 + (-1.0 * _x_x_29)) <= -11.0) && (((x_22 + (-1.0 * _x_x_29)) <= -10.0) && (((x_21 + (-1.0 * _x_x_29)) <= -6.0) && (((x_18 + (-1.0 * _x_x_29)) <= -10.0) && (((x_16 + (-1.0 * _x_x_29)) <= -3.0) && (((x_14 + (-1.0 * _x_x_29)) <= -20.0) && (((x_13 + (-1.0 * _x_x_29)) <= -15.0) && (((x_12 + (-1.0 * _x_x_29)) <= -4.0) && (((x_11 + (-1.0 * _x_x_29)) <= -19.0) && (((x_10 + (-1.0 * _x_x_29)) <= -15.0) && (((x_3 + (-1.0 * _x_x_29)) <= -19.0) && (((x_0 + (-1.0 * _x_x_29)) <= -16.0) && ((x_1 + (-1.0 * _x_x_29)) <= -8.0)))))))))))))))))))) && (((x_38 + (-1.0 * _x_x_29)) == -17.0) || (((x_36 + (-1.0 * _x_x_29)) == -15.0) || (((x_35 + (-1.0 * _x_x_29)) == -14.0) || (((x_34 + (-1.0 * _x_x_29)) == -19.0) || (((x_30 + (-1.0 * _x_x_29)) == -2.0) || (((x_29 + (-1.0 * _x_x_29)) == -2.0) || (((x_26 + (-1.0 * _x_x_29)) == -8.0) || (((x_23 + (-1.0 * _x_x_29)) == -11.0) || (((x_22 + (-1.0 * _x_x_29)) == -10.0) || (((x_21 + (-1.0 * _x_x_29)) == -6.0) || (((x_18 + (-1.0 * _x_x_29)) == -10.0) || (((x_16 + (-1.0 * _x_x_29)) == -3.0) || (((x_14 + (-1.0 * _x_x_29)) == -20.0) || (((x_13 + (-1.0 * _x_x_29)) == -15.0) || (((x_12 + (-1.0 * _x_x_29)) == -4.0) || (((x_11 + (-1.0 * _x_x_29)) == -19.0) || (((x_10 + (-1.0 * _x_x_29)) == -15.0) || (((x_3 + (-1.0 * _x_x_29)) == -19.0) || (((x_0 + (-1.0 * _x_x_29)) == -16.0) || ((x_1 + (-1.0 * _x_x_29)) == -8.0)))))))))))))))))))))) && ((((x_38 + (-1.0 * _x_x_30)) <= -13.0) && (((x_37 + (-1.0 * _x_x_30)) <= -11.0) && (((x_35 + (-1.0 * _x_x_30)) <= -8.0) && (((x_34 + (-1.0 * _x_x_30)) <= -18.0) && (((x_32 + (-1.0 * _x_x_30)) <= -18.0) && (((x_31 + (-1.0 * _x_x_30)) <= -11.0) && (((x_29 + (-1.0 * _x_x_30)) <= -7.0) && (((x_28 + (-1.0 * _x_x_30)) <= -10.0) && (((x_23 + (-1.0 * _x_x_30)) <= -12.0) && (((x_21 + (-1.0 * _x_x_30)) <= -15.0) && (((x_20 + (-1.0 * _x_x_30)) <= -18.0) && (((x_18 + (-1.0 * _x_x_30)) <= -14.0) && (((x_16 + (-1.0 * _x_x_30)) <= -6.0) && (((x_14 + (-1.0 * _x_x_30)) <= -4.0) && (((x_13 + (-1.0 * _x_x_30)) <= -13.0) && (((x_11 + (-1.0 * _x_x_30)) <= -4.0) && (((x_6 + (-1.0 * _x_x_30)) <= -19.0) && (((x_4 + (-1.0 * _x_x_30)) <= -3.0) && (((x_1 + (-1.0 * _x_x_30)) <= -10.0) && ((x_2 + (-1.0 * _x_x_30)) <= -12.0)))))))))))))))))))) && (((x_38 + (-1.0 * _x_x_30)) == -13.0) || (((x_37 + (-1.0 * _x_x_30)) == -11.0) || (((x_35 + (-1.0 * _x_x_30)) == -8.0) || (((x_34 + (-1.0 * _x_x_30)) == -18.0) || (((x_32 + (-1.0 * _x_x_30)) == -18.0) || (((x_31 + (-1.0 * _x_x_30)) == -11.0) || (((x_29 + (-1.0 * _x_x_30)) == -7.0) || (((x_28 + (-1.0 * _x_x_30)) == -10.0) || (((x_23 + (-1.0 * _x_x_30)) == -12.0) || (((x_21 + (-1.0 * _x_x_30)) == -15.0) || (((x_20 + (-1.0 * _x_x_30)) == -18.0) || (((x_18 + (-1.0 * _x_x_30)) == -14.0) || (((x_16 + (-1.0 * _x_x_30)) == -6.0) || (((x_14 + (-1.0 * _x_x_30)) == -4.0) || (((x_13 + (-1.0 * _x_x_30)) == -13.0) || (((x_11 + (-1.0 * _x_x_30)) == -4.0) || (((x_6 + (-1.0 * _x_x_30)) == -19.0) || (((x_4 + (-1.0 * _x_x_30)) == -3.0) || (((x_1 + (-1.0 * _x_x_30)) == -10.0) || ((x_2 + (-1.0 * _x_x_30)) == -12.0)))))))))))))))))))))) && ((((x_39 + (-1.0 * _x_x_31)) <= -7.0) && (((x_38 + (-1.0 * _x_x_31)) <= -10.0) && (((x_34 + (-1.0 * _x_x_31)) <= -5.0) && (((x_33 + (-1.0 * _x_x_31)) <= -15.0) && (((x_29 + (-1.0 * _x_x_31)) <= -15.0) && (((x_28 + (-1.0 * _x_x_31)) <= -9.0) && (((x_27 + (-1.0 * _x_x_31)) <= -11.0) && (((x_25 + (-1.0 * _x_x_31)) <= -9.0) && (((x_24 + (-1.0 * _x_x_31)) <= -18.0) && (((x_22 + (-1.0 * _x_x_31)) <= -14.0) && (((x_21 + (-1.0 * _x_x_31)) <= -17.0) && (((x_20 + (-1.0 * _x_x_31)) <= -13.0) && (((x_19 + (-1.0 * _x_x_31)) <= -20.0) && (((x_18 + (-1.0 * _x_x_31)) <= -1.0) && (((x_15 + (-1.0 * _x_x_31)) <= -3.0) && (((x_10 + (-1.0 * _x_x_31)) <= -6.0) && (((x_9 + (-1.0 * _x_x_31)) <= -11.0) && (((x_6 + (-1.0 * _x_x_31)) <= -8.0) && (((x_0 + (-1.0 * _x_x_31)) <= -10.0) && ((x_5 + (-1.0 * _x_x_31)) <= -8.0)))))))))))))))))))) && (((x_39 + (-1.0 * _x_x_31)) == -7.0) || (((x_38 + (-1.0 * _x_x_31)) == -10.0) || (((x_34 + (-1.0 * _x_x_31)) == -5.0) || (((x_33 + (-1.0 * _x_x_31)) == -15.0) || (((x_29 + (-1.0 * _x_x_31)) == -15.0) || (((x_28 + (-1.0 * _x_x_31)) == -9.0) || (((x_27 + (-1.0 * _x_x_31)) == -11.0) || (((x_25 + (-1.0 * _x_x_31)) == -9.0) || (((x_24 + (-1.0 * _x_x_31)) == -18.0) || (((x_22 + (-1.0 * _x_x_31)) == -14.0) || (((x_21 + (-1.0 * _x_x_31)) == -17.0) || (((x_20 + (-1.0 * _x_x_31)) == -13.0) || (((x_19 + (-1.0 * _x_x_31)) == -20.0) || (((x_18 + (-1.0 * _x_x_31)) == -1.0) || (((x_15 + (-1.0 * _x_x_31)) == -3.0) || (((x_10 + (-1.0 * _x_x_31)) == -6.0) || (((x_9 + (-1.0 * _x_x_31)) == -11.0) || (((x_6 + (-1.0 * _x_x_31)) == -8.0) || (((x_0 + (-1.0 * _x_x_31)) == -10.0) || ((x_5 + (-1.0 * _x_x_31)) == -8.0)))))))))))))))))))))) && ((((x_38 + (-1.0 * _x_x_32)) <= -3.0) && (((x_37 + (-1.0 * _x_x_32)) <= -17.0) && (((x_36 + (-1.0 * _x_x_32)) <= -13.0) && (((x_35 + (-1.0 * _x_x_32)) <= -8.0) && (((x_34 + (-1.0 * _x_x_32)) <= -11.0) && (((x_33 + (-1.0 * _x_x_32)) <= -19.0) && (((x_31 + (-1.0 * _x_x_32)) <= -15.0) && (((x_30 + (-1.0 * _x_x_32)) <= -16.0) && (((x_29 + (-1.0 * _x_x_32)) <= -16.0) && (((x_28 + (-1.0 * _x_x_32)) <= -15.0) && (((x_27 + (-1.0 * _x_x_32)) <= -1.0) && (((x_22 + (-1.0 * _x_x_32)) <= -15.0) && (((x_18 + (-1.0 * _x_x_32)) <= -12.0) && (((x_17 + (-1.0 * _x_x_32)) <= -15.0) && (((x_15 + (-1.0 * _x_x_32)) <= -1.0) && (((x_11 + (-1.0 * _x_x_32)) <= -1.0) && (((x_10 + (-1.0 * _x_x_32)) <= -11.0) && (((x_7 + (-1.0 * _x_x_32)) <= -3.0) && (((x_3 + (-1.0 * _x_x_32)) <= -6.0) && ((x_5 + (-1.0 * _x_x_32)) <= -4.0)))))))))))))))))))) && (((x_38 + (-1.0 * _x_x_32)) == -3.0) || (((x_37 + (-1.0 * _x_x_32)) == -17.0) || (((x_36 + (-1.0 * _x_x_32)) == -13.0) || (((x_35 + (-1.0 * _x_x_32)) == -8.0) || (((x_34 + (-1.0 * _x_x_32)) == -11.0) || (((x_33 + (-1.0 * _x_x_32)) == -19.0) || (((x_31 + (-1.0 * _x_x_32)) == -15.0) || (((x_30 + (-1.0 * _x_x_32)) == -16.0) || (((x_29 + (-1.0 * _x_x_32)) == -16.0) || (((x_28 + (-1.0 * _x_x_32)) == -15.0) || (((x_27 + (-1.0 * _x_x_32)) == -1.0) || (((x_22 + (-1.0 * _x_x_32)) == -15.0) || (((x_18 + (-1.0 * _x_x_32)) == -12.0) || (((x_17 + (-1.0 * _x_x_32)) == -15.0) || (((x_15 + (-1.0 * _x_x_32)) == -1.0) || (((x_11 + (-1.0 * _x_x_32)) == -1.0) || (((x_10 + (-1.0 * _x_x_32)) == -11.0) || (((x_7 + (-1.0 * _x_x_32)) == -3.0) || (((x_3 + (-1.0 * _x_x_32)) == -6.0) || ((x_5 + (-1.0 * _x_x_32)) == -4.0)))))))))))))))))))))) && ((((x_37 + (-1.0 * _x_x_33)) <= -12.0) && (((x_34 + (-1.0 * _x_x_33)) <= -7.0) && (((x_33 + (-1.0 * _x_x_33)) <= -14.0) && (((x_32 + (-1.0 * _x_x_33)) <= -5.0) && (((x_30 + (-1.0 * _x_x_33)) <= -7.0) && (((x_29 + (-1.0 * _x_x_33)) <= -8.0) && (((x_28 + (-1.0 * _x_x_33)) <= -18.0) && (((x_25 + (-1.0 * _x_x_33)) <= -6.0) && (((x_24 + (-1.0 * _x_x_33)) <= -4.0) && (((x_23 + (-1.0 * _x_x_33)) <= -14.0) && (((x_21 + (-1.0 * _x_x_33)) <= -2.0) && (((x_16 + (-1.0 * _x_x_33)) <= -3.0) && (((x_15 + (-1.0 * _x_x_33)) <= -14.0) && (((x_14 + (-1.0 * _x_x_33)) <= -10.0) && (((x_13 + (-1.0 * _x_x_33)) <= -11.0) && (((x_8 + (-1.0 * _x_x_33)) <= -11.0) && (((x_7 + (-1.0 * _x_x_33)) <= -6.0) && (((x_4 + (-1.0 * _x_x_33)) <= -2.0) && (((x_2 + (-1.0 * _x_x_33)) <= -15.0) && ((x_3 + (-1.0 * _x_x_33)) <= -20.0)))))))))))))))))))) && (((x_37 + (-1.0 * _x_x_33)) == -12.0) || (((x_34 + (-1.0 * _x_x_33)) == -7.0) || (((x_33 + (-1.0 * _x_x_33)) == -14.0) || (((x_32 + (-1.0 * _x_x_33)) == -5.0) || (((x_30 + (-1.0 * _x_x_33)) == -7.0) || (((x_29 + (-1.0 * _x_x_33)) == -8.0) || (((x_28 + (-1.0 * _x_x_33)) == -18.0) || (((x_25 + (-1.0 * _x_x_33)) == -6.0) || (((x_24 + (-1.0 * _x_x_33)) == -4.0) || (((x_23 + (-1.0 * _x_x_33)) == -14.0) || (((x_21 + (-1.0 * _x_x_33)) == -2.0) || (((x_16 + (-1.0 * _x_x_33)) == -3.0) || (((x_15 + (-1.0 * _x_x_33)) == -14.0) || (((x_14 + (-1.0 * _x_x_33)) == -10.0) || (((x_13 + (-1.0 * _x_x_33)) == -11.0) || (((x_8 + (-1.0 * _x_x_33)) == -11.0) || (((x_7 + (-1.0 * _x_x_33)) == -6.0) || (((x_4 + (-1.0 * _x_x_33)) == -2.0) || (((x_2 + (-1.0 * _x_x_33)) == -15.0) || ((x_3 + (-1.0 * _x_x_33)) == -20.0)))))))))))))))))))))) && ((((x_37 + (-1.0 * _x_x_34)) <= -20.0) && (((x_36 + (-1.0 * _x_x_34)) <= -1.0) && (((x_33 + (-1.0 * _x_x_34)) <= -12.0) && (((x_32 + (-1.0 * _x_x_34)) <= -3.0) && (((x_30 + (-1.0 * _x_x_34)) <= -11.0) && (((x_29 + (-1.0 * _x_x_34)) <= -12.0) && (((x_25 + (-1.0 * _x_x_34)) <= -16.0) && (((x_22 + (-1.0 * _x_x_34)) <= -4.0) && (((x_21 + (-1.0 * _x_x_34)) <= -2.0) && (((x_19 + (-1.0 * _x_x_34)) <= -19.0) && (((x_17 + (-1.0 * _x_x_34)) <= -2.0) && (((x_13 + (-1.0 * _x_x_34)) <= -13.0) && (((x_12 + (-1.0 * _x_x_34)) <= -6.0) && (((x_11 + (-1.0 * _x_x_34)) <= -4.0) && (((x_10 + (-1.0 * _x_x_34)) <= -5.0) && (((x_8 + (-1.0 * _x_x_34)) <= -5.0) && (((x_4 + (-1.0 * _x_x_34)) <= -2.0) && (((x_3 + (-1.0 * _x_x_34)) <= -12.0) && (((x_0 + (-1.0 * _x_x_34)) <= -6.0) && ((x_2 + (-1.0 * _x_x_34)) <= -1.0)))))))))))))))))))) && (((x_37 + (-1.0 * _x_x_34)) == -20.0) || (((x_36 + (-1.0 * _x_x_34)) == -1.0) || (((x_33 + (-1.0 * _x_x_34)) == -12.0) || (((x_32 + (-1.0 * _x_x_34)) == -3.0) || (((x_30 + (-1.0 * _x_x_34)) == -11.0) || (((x_29 + (-1.0 * _x_x_34)) == -12.0) || (((x_25 + (-1.0 * _x_x_34)) == -16.0) || (((x_22 + (-1.0 * _x_x_34)) == -4.0) || (((x_21 + (-1.0 * _x_x_34)) == -2.0) || (((x_19 + (-1.0 * _x_x_34)) == -19.0) || (((x_17 + (-1.0 * _x_x_34)) == -2.0) || (((x_13 + (-1.0 * _x_x_34)) == -13.0) || (((x_12 + (-1.0 * _x_x_34)) == -6.0) || (((x_11 + (-1.0 * _x_x_34)) == -4.0) || (((x_10 + (-1.0 * _x_x_34)) == -5.0) || (((x_8 + (-1.0 * _x_x_34)) == -5.0) || (((x_4 + (-1.0 * _x_x_34)) == -2.0) || (((x_3 + (-1.0 * _x_x_34)) == -12.0) || (((x_0 + (-1.0 * _x_x_34)) == -6.0) || ((x_2 + (-1.0 * _x_x_34)) == -1.0)))))))))))))))))))))) && ((((x_39 + (-1.0 * _x_x_35)) <= -8.0) && (((x_31 + (-1.0 * _x_x_35)) <= -12.0) && (((x_30 + (-1.0 * _x_x_35)) <= -12.0) && (((x_29 + (-1.0 * _x_x_35)) <= -14.0) && (((x_28 + (-1.0 * _x_x_35)) <= -11.0) && (((x_25 + (-1.0 * _x_x_35)) <= -7.0) && (((x_24 + (-1.0 * _x_x_35)) <= -2.0) && (((x_23 + (-1.0 * _x_x_35)) <= -7.0) && (((x_21 + (-1.0 * _x_x_35)) <= -18.0) && (((x_18 + (-1.0 * _x_x_35)) <= -4.0) && (((x_15 + (-1.0 * _x_x_35)) <= -10.0) && (((x_14 + (-1.0 * _x_x_35)) <= -8.0) && (((x_13 + (-1.0 * _x_x_35)) <= -10.0) && (((x_12 + (-1.0 * _x_x_35)) <= -4.0) && (((x_9 + (-1.0 * _x_x_35)) <= -7.0) && (((x_7 + (-1.0 * _x_x_35)) <= -17.0) && (((x_5 + (-1.0 * _x_x_35)) <= -16.0) && (((x_4 + (-1.0 * _x_x_35)) <= -1.0) && (((x_0 + (-1.0 * _x_x_35)) <= -15.0) && ((x_2 + (-1.0 * _x_x_35)) <= -6.0)))))))))))))))))))) && (((x_39 + (-1.0 * _x_x_35)) == -8.0) || (((x_31 + (-1.0 * _x_x_35)) == -12.0) || (((x_30 + (-1.0 * _x_x_35)) == -12.0) || (((x_29 + (-1.0 * _x_x_35)) == -14.0) || (((x_28 + (-1.0 * _x_x_35)) == -11.0) || (((x_25 + (-1.0 * _x_x_35)) == -7.0) || (((x_24 + (-1.0 * _x_x_35)) == -2.0) || (((x_23 + (-1.0 * _x_x_35)) == -7.0) || (((x_21 + (-1.0 * _x_x_35)) == -18.0) || (((x_18 + (-1.0 * _x_x_35)) == -4.0) || (((x_15 + (-1.0 * _x_x_35)) == -10.0) || (((x_14 + (-1.0 * _x_x_35)) == -8.0) || (((x_13 + (-1.0 * _x_x_35)) == -10.0) || (((x_12 + (-1.0 * _x_x_35)) == -4.0) || (((x_9 + (-1.0 * _x_x_35)) == -7.0) || (((x_7 + (-1.0 * _x_x_35)) == -17.0) || (((x_5 + (-1.0 * _x_x_35)) == -16.0) || (((x_4 + (-1.0 * _x_x_35)) == -1.0) || (((x_0 + (-1.0 * _x_x_35)) == -15.0) || ((x_2 + (-1.0 * _x_x_35)) == -6.0)))))))))))))))))))))) && ((((x_39 + (-1.0 * _x_x_36)) <= -17.0) && (((x_37 + (-1.0 * _x_x_36)) <= -17.0) && (((x_35 + (-1.0 * _x_x_36)) <= -12.0) && (((x_34 + (-1.0 * _x_x_36)) <= -10.0) && (((x_33 + (-1.0 * _x_x_36)) <= -5.0) && (((x_32 + (-1.0 * _x_x_36)) <= -5.0) && (((x_31 + (-1.0 * _x_x_36)) <= -4.0) && (((x_29 + (-1.0 * _x_x_36)) <= -17.0) && (((x_28 + (-1.0 * _x_x_36)) <= -10.0) && (((x_26 + (-1.0 * _x_x_36)) <= -19.0) && (((x_21 + (-1.0 * _x_x_36)) <= -1.0) && (((x_20 + (-1.0 * _x_x_36)) <= -5.0) && (((x_19 + (-1.0 * _x_x_36)) <= -2.0) && (((x_17 + (-1.0 * _x_x_36)) <= -8.0) && (((x_16 + (-1.0 * _x_x_36)) <= -3.0) && (((x_14 + (-1.0 * _x_x_36)) <= -19.0) && (((x_12 + (-1.0 * _x_x_36)) <= -15.0) && (((x_8 + (-1.0 * _x_x_36)) <= -9.0) && (((x_3 + (-1.0 * _x_x_36)) <= -6.0) && ((x_4 + (-1.0 * _x_x_36)) <= -20.0)))))))))))))))))))) && (((x_39 + (-1.0 * _x_x_36)) == -17.0) || (((x_37 + (-1.0 * _x_x_36)) == -17.0) || (((x_35 + (-1.0 * _x_x_36)) == -12.0) || (((x_34 + (-1.0 * _x_x_36)) == -10.0) || (((x_33 + (-1.0 * _x_x_36)) == -5.0) || (((x_32 + (-1.0 * _x_x_36)) == -5.0) || (((x_31 + (-1.0 * _x_x_36)) == -4.0) || (((x_29 + (-1.0 * _x_x_36)) == -17.0) || (((x_28 + (-1.0 * _x_x_36)) == -10.0) || (((x_26 + (-1.0 * _x_x_36)) == -19.0) || (((x_21 + (-1.0 * _x_x_36)) == -1.0) || (((x_20 + (-1.0 * _x_x_36)) == -5.0) || (((x_19 + (-1.0 * _x_x_36)) == -2.0) || (((x_17 + (-1.0 * _x_x_36)) == -8.0) || (((x_16 + (-1.0 * _x_x_36)) == -3.0) || (((x_14 + (-1.0 * _x_x_36)) == -19.0) || (((x_12 + (-1.0 * _x_x_36)) == -15.0) || (((x_8 + (-1.0 * _x_x_36)) == -9.0) || (((x_3 + (-1.0 * _x_x_36)) == -6.0) || ((x_4 + (-1.0 * _x_x_36)) == -20.0)))))))))))))))))))))) && ((((x_36 + (-1.0 * _x_x_37)) <= -14.0) && (((x_35 + (-1.0 * _x_x_37)) <= -19.0) && (((x_34 + (-1.0 * _x_x_37)) <= -9.0) && (((x_32 + (-1.0 * _x_x_37)) <= -10.0) && (((x_31 + (-1.0 * _x_x_37)) <= -5.0) && (((x_29 + (-1.0 * _x_x_37)) <= -9.0) && (((x_27 + (-1.0 * _x_x_37)) <= -2.0) && (((x_26 + (-1.0 * _x_x_37)) <= -12.0) && (((x_25 + (-1.0 * _x_x_37)) <= -1.0) && (((x_24 + (-1.0 * _x_x_37)) <= -13.0) && (((x_21 + (-1.0 * _x_x_37)) <= -9.0) && (((x_20 + (-1.0 * _x_x_37)) <= -10.0) && (((x_18 + (-1.0 * _x_x_37)) <= -8.0) && (((x_15 + (-1.0 * _x_x_37)) <= -18.0) && (((x_14 + (-1.0 * _x_x_37)) <= -9.0) && (((x_10 + (-1.0 * _x_x_37)) <= -2.0) && (((x_9 + (-1.0 * _x_x_37)) <= -6.0) && (((x_7 + (-1.0 * _x_x_37)) <= -16.0) && (((x_0 + (-1.0 * _x_x_37)) <= -4.0) && ((x_2 + (-1.0 * _x_x_37)) <= -18.0)))))))))))))))))))) && (((x_36 + (-1.0 * _x_x_37)) == -14.0) || (((x_35 + (-1.0 * _x_x_37)) == -19.0) || (((x_34 + (-1.0 * _x_x_37)) == -9.0) || (((x_32 + (-1.0 * _x_x_37)) == -10.0) || (((x_31 + (-1.0 * _x_x_37)) == -5.0) || (((x_29 + (-1.0 * _x_x_37)) == -9.0) || (((x_27 + (-1.0 * _x_x_37)) == -2.0) || (((x_26 + (-1.0 * _x_x_37)) == -12.0) || (((x_25 + (-1.0 * _x_x_37)) == -1.0) || (((x_24 + (-1.0 * _x_x_37)) == -13.0) || (((x_21 + (-1.0 * _x_x_37)) == -9.0) || (((x_20 + (-1.0 * _x_x_37)) == -10.0) || (((x_18 + (-1.0 * _x_x_37)) == -8.0) || (((x_15 + (-1.0 * _x_x_37)) == -18.0) || (((x_14 + (-1.0 * _x_x_37)) == -9.0) || (((x_10 + (-1.0 * _x_x_37)) == -2.0) || (((x_9 + (-1.0 * _x_x_37)) == -6.0) || (((x_7 + (-1.0 * _x_x_37)) == -16.0) || (((x_0 + (-1.0 * _x_x_37)) == -4.0) || ((x_2 + (-1.0 * _x_x_37)) == -18.0)))))))))))))))))))))) && ((((x_39 + (-1.0 * _x_x_38)) <= -11.0) && (((x_38 + (-1.0 * _x_x_38)) <= -9.0) && (((x_35 + (-1.0 * _x_x_38)) <= -20.0) && (((x_34 + (-1.0 * _x_x_38)) <= -12.0) && (((x_33 + (-1.0 * _x_x_38)) <= -11.0) && (((x_32 + (-1.0 * _x_x_38)) <= -4.0) && (((x_29 + (-1.0 * _x_x_38)) <= -2.0) && (((x_28 + (-1.0 * _x_x_38)) <= -9.0) && (((x_27 + (-1.0 * _x_x_38)) <= -5.0) && (((x_25 + (-1.0 * _x_x_38)) <= -5.0) && (((x_24 + (-1.0 * _x_x_38)) <= -7.0) && (((x_18 + (-1.0 * _x_x_38)) <= -13.0) && (((x_13 + (-1.0 * _x_x_38)) <= -1.0) && (((x_12 + (-1.0 * _x_x_38)) <= -16.0) && (((x_11 + (-1.0 * _x_x_38)) <= -7.0) && (((x_10 + (-1.0 * _x_x_38)) <= -2.0) && (((x_7 + (-1.0 * _x_x_38)) <= -8.0) && (((x_6 + (-1.0 * _x_x_38)) <= -13.0) && (((x_1 + (-1.0 * _x_x_38)) <= -8.0) && ((x_3 + (-1.0 * _x_x_38)) <= -16.0)))))))))))))))))))) && (((x_39 + (-1.0 * _x_x_38)) == -11.0) || (((x_38 + (-1.0 * _x_x_38)) == -9.0) || (((x_35 + (-1.0 * _x_x_38)) == -20.0) || (((x_34 + (-1.0 * _x_x_38)) == -12.0) || (((x_33 + (-1.0 * _x_x_38)) == -11.0) || (((x_32 + (-1.0 * _x_x_38)) == -4.0) || (((x_29 + (-1.0 * _x_x_38)) == -2.0) || (((x_28 + (-1.0 * _x_x_38)) == -9.0) || (((x_27 + (-1.0 * _x_x_38)) == -5.0) || (((x_25 + (-1.0 * _x_x_38)) == -5.0) || (((x_24 + (-1.0 * _x_x_38)) == -7.0) || (((x_18 + (-1.0 * _x_x_38)) == -13.0) || (((x_13 + (-1.0 * _x_x_38)) == -1.0) || (((x_12 + (-1.0 * _x_x_38)) == -16.0) || (((x_11 + (-1.0 * _x_x_38)) == -7.0) || (((x_10 + (-1.0 * _x_x_38)) == -2.0) || (((x_7 + (-1.0 * _x_x_38)) == -8.0) || (((x_6 + (-1.0 * _x_x_38)) == -13.0) || (((x_1 + (-1.0 * _x_x_38)) == -8.0) || ((x_3 + (-1.0 * _x_x_38)) == -16.0)))))))))))))))))))))) && ((((x_38 + (-1.0 * _x_x_39)) <= -19.0) && (((x_36 + (-1.0 * _x_x_39)) <= -14.0) && (((x_32 + (-1.0 * _x_x_39)) <= -9.0) && (((x_31 + (-1.0 * _x_x_39)) <= -7.0) && (((x_30 + (-1.0 * _x_x_39)) <= -3.0) && (((x_27 + (-1.0 * _x_x_39)) <= -12.0) && (((x_26 + (-1.0 * _x_x_39)) <= -10.0) && (((x_22 + (-1.0 * _x_x_39)) <= -20.0) && (((x_21 + (-1.0 * _x_x_39)) <= -4.0) && (((x_19 + (-1.0 * _x_x_39)) <= -3.0) && (((x_17 + (-1.0 * _x_x_39)) <= -9.0) && (((x_15 + (-1.0 * _x_x_39)) <= -10.0) && (((x_14 + (-1.0 * _x_x_39)) <= -8.0) && (((x_11 + (-1.0 * _x_x_39)) <= -16.0) && (((x_10 + (-1.0 * _x_x_39)) <= -15.0) && (((x_9 + (-1.0 * _x_x_39)) <= -6.0) && (((x_8 + (-1.0 * _x_x_39)) <= -16.0) && (((x_5 + (-1.0 * _x_x_39)) <= -6.0) && (((x_1 + (-1.0 * _x_x_39)) <= -19.0) && ((x_3 + (-1.0 * _x_x_39)) <= -2.0)))))))))))))))))))) && (((x_38 + (-1.0 * _x_x_39)) == -19.0) || (((x_36 + (-1.0 * _x_x_39)) == -14.0) || (((x_32 + (-1.0 * _x_x_39)) == -9.0) || (((x_31 + (-1.0 * _x_x_39)) == -7.0) || (((x_30 + (-1.0 * _x_x_39)) == -3.0) || (((x_27 + (-1.0 * _x_x_39)) == -12.0) || (((x_26 + (-1.0 * _x_x_39)) == -10.0) || (((x_22 + (-1.0 * _x_x_39)) == -20.0) || (((x_21 + (-1.0 * _x_x_39)) == -4.0) || (((x_19 + (-1.0 * _x_x_39)) == -3.0) || (((x_17 + (-1.0 * _x_x_39)) == -9.0) || (((x_15 + (-1.0 * _x_x_39)) == -10.0) || (((x_14 + (-1.0 * _x_x_39)) == -8.0) || (((x_11 + (-1.0 * _x_x_39)) == -16.0) || (((x_10 + (-1.0 * _x_x_39)) == -15.0) || (((x_9 + (-1.0 * _x_x_39)) == -6.0) || (((x_8 + (-1.0 * _x_x_39)) == -16.0) || (((x_5 + (-1.0 * _x_x_39)) == -6.0) || (((x_1 + (-1.0 * _x_x_39)) == -19.0) || ((x_3 + (-1.0 * _x_x_39)) == -2.0)))))))))))))))))))))) && ((_EL_U_4708 == (_x__EL_U_4708 || ((_x_x_23 + (-1.0 * _x_x_26)) <= 5.0))) && (_EL_X_4698 == ((_x_x_34 + (-1.0 * _x_x_39)) <= -6.0)))); _EL_X_4698 = _x__EL_X_4698; _EL_U_4708 = _x__EL_U_4708; x_26 = _x_x_26; x_23 = _x_x_23; x_4 = _x_x_4; x_3 = _x_x_3; x_16 = _x_x_16; x_1 = _x_x_1; x_5 = _x_x_5; x_2 = _x_x_2; x_0 = _x_x_0; x_8 = _x_x_8; x_9 = _x_x_9; x_6 = _x_x_6; x_10 = _x_x_10; x_7 = _x_x_7; x_11 = _x_x_11; x_14 = _x_x_14; x_20 = _x_x_20; x_12 = _x_x_12; x_15 = _x_x_15; x_13 = _x_x_13; x_37 = _x_x_37; x_18 = _x_x_18; x_17 = _x_x_17; x_24 = _x_x_24; x_19 = _x_x_19; x_25 = _x_x_25; x_21 = _x_x_21; x_28 = _x_x_28; x_22 = _x_x_22; x_29 = _x_x_29; x_27 = _x_x_27; x_33 = _x_x_33; x_30 = _x_x_30; x_34 = _x_x_34; x_31 = _x_x_31; x_35 = _x_x_35; x_32 = _x_x_32; x_39 = _x_x_39; x_36 = _x_x_36; x_38 = _x_x_38; } }
the_stack_data/29826058.c
// REQUIRES: system-linux // RUN: clang -o %t %s -O2 // RUN: llvm-mctoll -d %t // RUN: clang -o %t-dis %t-dis.ll // RUN: %t-dis 2>&1 | FileCheck %s // CHECK: EDCBA #include <stdio.h> int __attribute__((noinline)) display_backward(char *string) { if (*string) { display_backward(string + 1); putchar(*string); } return 0; } int main(void) { display_backward("ABCDE"); printf("\n"); return 0; }
the_stack_data/60188.c
#include <stdint.h> const uint8_t gf16mul_lut[] = { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0x0, 0x2, 0x3, 0x1, 0x8, 0xa, 0xb, 0x9, 0xc, 0xe, 0xf, 0xd, 0x4, 0x6, 0x7, 0x5, 0x0, 0x3, 0x1, 0x2, 0xc, 0xf, 0xd, 0xe, 0x4, 0x7, 0x5, 0x6, 0x8, 0xb, 0x9, 0xa, 0x0, 0x4, 0x8, 0xc, 0x6, 0x2, 0xe, 0xa, 0xb, 0xf, 0x3, 0x7, 0xd, 0x9, 0x5, 0x1, 0x0, 0x5, 0xa, 0xf, 0x2, 0x7, 0x8, 0xd, 0x3, 0x6, 0x9, 0xc, 0x1, 0x4, 0xb, 0xe, 0x0, 0x6, 0xb, 0xd, 0xe, 0x8, 0x5, 0x3, 0x7, 0x1, 0xc, 0xa, 0x9, 0xf, 0x2, 0x4, 0x0, 0x7, 0x9, 0xe, 0xa, 0xd, 0x3, 0x4, 0xf, 0x8, 0x6, 0x1, 0x5, 0x2, 0xc, 0xb, 0x0, 0x8, 0xc, 0x4, 0xb, 0x3, 0x7, 0xf, 0xd, 0x5, 0x1, 0x9, 0x6, 0xe, 0xa, 0x2, 0x0, 0x9, 0xe, 0x7, 0xf, 0x6, 0x1, 0x8, 0x5, 0xc, 0xb, 0x2, 0xa, 0x3, 0x4, 0xd, 0x0, 0xa, 0xf, 0x5, 0x3, 0x9, 0xc, 0x6, 0x1, 0xb, 0xe, 0x4, 0x2, 0x8, 0xd, 0x7, 0x0, 0xb, 0xd, 0x6, 0x7, 0xc, 0xa, 0x1, 0x9, 0x2, 0x4, 0xf, 0xe, 0x5, 0x3, 0x8, 0x0, 0xc, 0x4, 0x8, 0xd, 0x1, 0x9, 0x5, 0x6, 0xa, 0x2, 0xe, 0xb, 0x7, 0xf, 0x3, 0x0, 0xd, 0x6, 0xb, 0x9, 0x4, 0xf, 0x2, 0xe, 0x3, 0x8, 0x5, 0x7, 0xa, 0x1, 0xc, 0x0, 0xe, 0x7, 0x9, 0x5, 0xb, 0x2, 0xc, 0xa, 0x4, 0xd, 0x3, 0xf, 0x1, 0x8, 0x6, 0x0, 0xf, 0x5, 0xa, 0x1, 0xe, 0x4, 0xb, 0x2, 0xd, 0x7, 0x8, 0x3, 0xc, 0x6, 0x9};
the_stack_data/1130326.c
#include <stdio.h> int main( ){ printf("Ola mundo\n"); return 0; }
the_stack_data/81746.c
/* Test that registers used by out of line restore functions does not get renamed. AIX, and 64 bit targets uses r1, which rnreg stays away from. Linux 32 bits targets uses r11, which is susceptible to be renamed */ /* { dg-do compile } */ /* { dg-require-effective-target ilp32 } */ /* { dg-options "-Os -frename-registers -fdump-rtl-rnreg" } */ /* "* renamed" or "* no available better choice" results are not acceptable */ /* { dg-final { scan-rtl-dump-not "Register 11 in insn *" "rnreg" { target powerpc*-*-linux* } } } */ int calc (int j) { if (j<=1) return 1; return calc(j-1)*(j+1); }
the_stack_data/581957.c
//Structures #include <stdio.h> #include <math.h> int main () { int i; int n = 3; for (i=1; i <= 100; i++) { printf("%d^%d: %lld\n",n ,i ,(unsigned long long)pow(n,i)); if ((unsigned long long)pow(n, i) >= 9223372036854775807) { printf("Too Big for an unsigned long long!"); return 0; } } }
the_stack_data/145453810.c
int foo() { return 91; } int main() { int x = 0; { { /* foo() is inlined below */ int R0; #pragma spf assert nomacro { R0 = 91; } x += R0; } } return 0; }
the_stack_data/211080010.c
#if 0 /* largeint.c Large (64 bits) integer arithmetics library Written by Anders Norlander <[email protected]> This file is part of a free library for the Win32 API. This 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. */ #define __COMPILING_LARGEINT #include <largeint.h> __int64 WINAPI LargeIntegerAdd (__int64 i1, __int64 i2) { return i1 + i2; } __int64 WINAPI LargeIntegerSubtract (__int64 i1, __int64 i2) { return i1 - i2; } __int64 WINAPI LargeIntegerArithmeticShift (__int64 i, int n) { return i >> n; } __int64 WINAPI LargeIntegerShiftLeft (__int64 i, int n) { return i << n; } __int64 WINAPI LargeIntegerShiftRight (__int64 i, int n) { return i >> n; } __int64 WINAPI LargeIntegerNegate (__int64 i) { return -i; } __int64 WINAPI ConvertLongToLargeInteger (LONG l) { return (__int64) l; } __int64 WINAPI ConvertUlongToLargeInteger (ULONG ul) { return _toi(_toui(ul)); } __int64 WINAPI EnlargedIntegerMultiply (LONG l1, LONG l2) { return _toi(l1) * _toi(l2); } __int64 WINAPI EnlargedUnsignedMultiply (ULONG ul1, ULONG ul2) { return _toi(_toui(ul1) * _toui(ul2)); } __int64 WINAPI ExtendedIntegerMultiply (__int64 i, LONG l) { return i * _toi(l); } __int64 WINAPI LargeIntegerMultiply (__int64 i1, __int64 i2) { return i1 * i2; } __int64 WINAPI LargeIntegerDivide (__int64 i1, __int64 i2, __int64 *remainder) { if (remainder) *remainder = i1 % i2; return i1 / i2; } ULONG WINAPI EnlargedUnsignedDivide (unsigned __int64 i1, ULONG i2, PULONG remainder) { if (remainder) *remainder = i1 % _toi(i2); return i1 / _toi(i2); } __int64 WINAPI ExtendedLargeIntegerDivide (__int64 i1, ULONG i2, PULONG remainder) { if (remainder) *remainder = i1 % _toi(i2); return i1 / _toi(i2); } /* FIXME: what is this function supposed to do? */ __int64 WINAPI ExtendedMagicDivide (__int64 i1, __int64 i2, int n) { return 0; } #endif
the_stack_data/122015744.c
/* hw8_32 */ #include <stdio.h> #include <stdlib.h> #define CUBIC(X) X*X*X int main(void) { int n1=5; double n2=2.2; printf("%d^3=%d\n%.1lf^3=%lf\n",n1,CUBIC(n1),n2,CUBIC(n2)); system("pause"); return 0; } /* 5^3=125 2.2^3=10.648000 Press any key to continue . . . */
the_stack_data/206158.c
/* Output: for n =3 1 10 101 */ #include <stdio.h> int main() { int n, i, j; scanf("%d", &n); for (i = 1; i <= n; i++) { for (j = 1; j <= i; j++) { if (j % 2 != 0) { printf("1"); } else { printf("0"); } } printf("\n"); } }
the_stack_data/115766366.c
#include "time.h" #ifdef WIN32 #define MSDOS #endif #ifdef MSDOS #undef USE_CLOCK #define USE_CLOCK #endif #ifndef USE_CLOCK #define _INCLUDE_POSIX_SOURCE /* for HP-UX */ #define _INCLUDE_XOPEN_SOURCE /* for HP-UX */ #include "sys/types.h" #include "sys/times.h" #endif #undef Hz #ifdef CLK_TCK #define Hz CLK_TCK #else #ifdef HZ #define Hz HZ #else #define Hz 60 #endif #endif double #ifdef KR_headers etime_(tarray) float *tarray; #else etime_(float *tarray) #endif { #ifdef USE_CLOCK #ifndef CLOCKS_PER_SECOND #define CLOCKS_PER_SECOND Hz #endif double t = clock(); tarray[1] = 0; return tarray[0] = t / CLOCKS_PER_SECOND; #else struct tms t; times(&t); return (tarray[0] = t.tms_utime/Hz) + (tarray[1] = t.tms_stime/Hz); #endif }
the_stack_data/234516962.c
/* ヘッダファイルのインクルード */ #include <stdio.h> /* 標準入出力 */ #include <string.h> /* 文字列操作 */ #include <ctype.h> /* 文字操作 */ /* main関数の定義 */ int main(void){ /* 変数, 配列の初期化 */ int len = 0; /* textの長さlenを0に初期化. */ int i = 0; /* iを0に初期化. */ char text[256] = {'\0'}; /* textを'\0'で埋める. */ /* 文字列の取得 */ fgets(text, 256, stdin); /* 標準入力stdinからfgetsで1行読み込み, textに格納. */ /* 最後の文字をチェック. */ len = strlen(text); /* textの長さを取得. */ if (text[len - 1] == '\n'){ /* 最後の文字が'\n'. */ text[len - 1] = '\0'; /* '\0'を代入. */ } len = strlen(text); /* もう一度長さを取得.(改行がなくなった分減っている.) */ /* 文字列が16進数であるかどうかをチェック. */ for (i = 0; i < len; i++){ /* lenの分だけ繰り返す. */ if (!isxdigit(text[i])){ /* textのi番目がisxdigitによって16進数でないことがわかった時. */ printf("Not Hexadecimal.\n"); /* "Not Hexadecimal."と出力. */ return 0; /* 0を返して正常終了. */ } } /* 16進数の場合. */ printf("Hexadecimal.\n"); /* "Hexadecimal."と出力. */ /* プログラムの終了 */ return 0; /* 0を返して正常終了. */ }
the_stack_data/93887180.c
#include <string.h> int memcmp(const void *src1, const void *src2, size_t bytes) { const unsigned char *s1, *s2; int result; s1 = src1; s2 = src2; result = 0; while ((bytes > 0) && (result == 0)) { result = *s1 - *s2; bytes--; s1++; s2++; } return result; }
the_stack_data/187643061.c
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdint.h> #include <stdbool.h> #include <assert.h> #include <math.h> #define RELEASE(ptr) do { if (ptr) free(ptr); } while (0) typedef struct { uint8_t R; uint8_t G; uint8_t B; } RgbColor; typedef enum { PPM_MODE_P1, PPM_MODE_P3, PPM_MODE_P6 } PPM_MODE; typedef struct { uint32_t Width; uint32_t Heigth; RgbColor* Pixels; PPM_MODE Mode; } PpmImage; typedef RgbColor (*UnaryPredicate)(RgbColor color); RgbColor DefaultAct(RgbColor color) { return color; } /** * @brief Peek next character * * @param hStream The I/O stream * * @return Returns the next character in the input sequence, without * extracting it: The character is left as the next character to be * extracted from the stream. */ int fpeek(FILE* restrict hStream); /** * @brief Clear all white-spaces and comment's of stream * * @param hFile The I/O stream */ void ClearComment(FILE* restrict hFile); /** * @brief Gets pixel color in the position (x, y). * * @param[in] x The x-coordinate of the pixel to retrieve. * @param[in] y The y-coordinate of the pixel to retrieve. * @param pImage pointer to PpmImage Structure * * @return A RgbColor structure that represents the color of the specified * pixel. */ RgbColor GetPixel(uint32_t x, uint32_t y, PpmImage* pImage); /** * @brief Load PPM image format into memory * * @param[in] filename the image path in the system * * @return A pointer to PpmImage Structure containing the content and * information of the image */ PpmImage* LoadImage(const char* filename); /** * @brief Writes PPM image into archive with filename specified. * * @param[in] filename The filename * @param pImage pointer to PpmImage * @param[in] mode PPM Image Mode (P1, P3, P6) * @param[in] pfnTransform pointer to the function that applies the * transformations to the pixels */ void WriteToPpm(const char* filename, PpmImage* pImage, PPM_MODE mode, UnaryPredicate pfnTransform); /** * @brief Convert PPM image to grayscale * * @param[in] PixelColor The pixel color * * @return The new pixel color */ RgbColor ToGrayScale(RgbColor PixelColor); /** * @brief Convert PPM image to grayscale image P1 * * @param[in] PixelColor The pixel color * * @return The new pixel color */ RgbColor ToGrayScaleP3(RgbColor PixelColor); #define LOAD_PPM_IMAGE(file) LoadImage(file) #define WRITE_PPM_FILE(filename, ptr, mode) WriteToPpm(filename, ptr, mode, DefaultAct) #define WRITE_PPM_GRAY_P3_FILE(filename, ptr) WriteToPpm(filename, ptr, PPM_MODE_P1, ToGrayScaleP3) #define WRITE_PPM_GRAY_FILE(filename, ptr) WriteToPpm(filename, ptr, PPM_MODE_P6, ToGrayScale) #define RELEASE_PPM(pImage) do { RELEASE(pImage->Pixels); RELEASE(pImage); } while(0) int main() { PpmImage* pImage = LOAD_PPM_IMAGE("../samples/sample.ppm"); assert(pImage); WRITE_PPM_GRAY_FILE("resultGray.ppm", pImage); RELEASE_PPM(pImage); return 0; } int fpeek(FILE* restrict hStream) { int c = fgetc(hStream); ungetc(c, hStream); return c; } void ClearComment(FILE* restrict hFile) { if (!hFile) return; enum { MAX_BUFFER_SIZE = 1024 }; int c = EOF; while (c = fpeek(hFile), c == '\n' || c == '\r') (void) fgetc(hFile); if (c == '#') { char line[MAX_BUFFER_SIZE] = {0}; fgets(line, MAX_BUFFER_SIZE - 1, hFile); } } RgbColor GetPixel(uint32_t x, uint32_t y, PpmImage* pImage) { assert(pImage); assert(x < pImage->Width && y < pImage->Heigth); return pImage->Pixels[y * pImage->Width + x]; } PpmImage* LoadImage(const char* filename) { if (!filename || !filename[0]) return NULL; FILE* hFile = fopen(filename, "rb"); if (!hFile) return NULL; ClearComment(hFile); int mode = 0; // Get Header char szImageSign[3] = {0}; fgets(szImageSign, sizeof szImageSign, hFile); mode = szImageSign[1] - '0'; if (mode != 3 && mode != 6) { perror("Invalid image mode"); fclose(hFile); return NULL; } uint32_t imgWidth = 0; uint32_t imgHeigth = 0; uint32_t maxColor = 0; // Get Image Width ClearComment(hFile); fscanf(hFile, "%u", &imgWidth); // Get Image Height ClearComment(hFile); fscanf(hFile, "%u", &imgHeigth); // Get Image max color bit ClearComment(hFile); fscanf(hFile, "%u", &maxColor); // Allocate image structure into memory PpmImage* pImage = (PpmImage*) malloc(sizeof(PpmImage)); if (!pImage) { fprintf(stderr, "[-] memory exausted"); exit(EXIT_FAILURE); } // setup image information pImage->Width = imgWidth; pImage->Heigth = imgHeigth; // calculate image size const size_t imgSize = imgWidth * imgHeigth * sizeof(RgbColor); // Allocate the image into memory RgbColor* ColorBuffer = (RgbColor *) malloc(imgSize); assert(ColorBuffer); RgbColor* pColorBuffer = ColorBuffer; uint8_t r = 0, g = 0, b = 0; if (mode == 3) { for (size_t y = 0; y < imgHeigth; ++y) { for (size_t x = 0; x < imgWidth; ++x) { if (fscanf(hFile, "%hhu%hhu%hhu\n", &r, &g, &b) == 3U) { pColorBuffer[y * imgWidth + x] = (RgbColor){r, g, b}; } } } } else { size_t nBytesRead = fread(pColorBuffer, imgSize, sizeof(uint8_t), hFile); assert(nBytesRead == sizeof(uint8_t)); (void)nBytesRead; } pImage->Pixels = ColorBuffer; pImage->Mode = (mode == 3U) ? PPM_MODE_P3 : PPM_MODE_P6; fclose(hFile); return pImage; } void WriteToPpm(const char* filename, PpmImage* pImage, PPM_MODE mode, UnaryPredicate pfnTransform) { if (!filename || !*filename || !pImage || !pfnTransform) return; const char* szOpenMode = (mode == PPM_MODE_P3) ? "w" : "wb"; FILE* hFile = fopen(filename, szOpenMode); if (!hFile) return; const char* szSignature = NULL; switch (mode) { case PPM_MODE_P1: szSignature = "P1"; break; case PPM_MODE_P3: szSignature = "P3"; break; case PPM_MODE_P6: szSignature = "P6"; break; default: break; } fprintf(hFile, "%s\n%u %u\n255\n", szSignature, pImage->Width, pImage->Heigth); for (uint32_t y = 0; y < pImage->Heigth; ++y) { for (uint32_t x = 0; x < pImage->Width; ++x) { RgbColor Pixel = GetPixel(x, y, pImage); Pixel = pfnTransform(Pixel); if (mode == PPM_MODE_P3) { fprintf(hFile, "%u %u %u\n", Pixel.R, Pixel.G, Pixel.B); assert(!ferror(hFile)); } else if (mode == PPM_MODE_P1) { fprintf(hFile, "%u\n", Pixel.R); assert(!ferror(hFile)); } else { size_t sz = fwrite(&Pixel, sizeof(RgbColor), sizeof(uint8_t), hFile); assert(sz == sizeof(uint8_t)); (void)sz; } } } fclose(hFile); } RgbColor ToGrayScale(RgbColor PixelColor) { uint8_t r = (uint8_t)(PixelColor.R * 0.299); uint8_t g = (uint8_t)(PixelColor.G * 0.587); uint8_t b = (uint8_t)(PixelColor.B * 0.144); uint8_t gray = (uint8_t) floor(r + g + b + 0.5); return (RgbColor){gray, gray, gray}; } RgbColor ToGrayScaleP3(RgbColor PixelColor) { uint8_t gray = (uint8_t)((PixelColor.R + PixelColor.G + PixelColor.B) / 3U); return (RgbColor){gray, gray, gray}; }
the_stack_data/46546.c
#include <stdio.h> #include <stdlib.h> #define NUM 40 void fillarray(double ar[], int n); void showarray(const double ar[], int n); int comp(const void * p1, const void * p2); int main(void) { double vals[NUM]; fillarray(vals, NUM); puts("Random list:"); showarray(vals, NUM); qsort(vals, NUM, sizeof(double), comp); puts("Sorted list:"); showarray(vals, NUM); return 0; } void fillarray(double ar[], int n) { for (int i = 0; i < n; i++) ar[i] = (double) rand() / ((double) rand() + 0.1); } void showarray(const double ar[], int n) { int i = 0; for (; i < n; i++) { printf("%9.4f ", ar[i]); if (i % 6 == 5) printf("\n"); } if (i % 6 != 0) printf("\n"); } int comp(const void * p1, const void * p2) { const double * a1 = (const double *) p1; const double * a2 = (const double *) p2; if (*a1 < *a2) return -1; else if (*a1 == *a2) return 0; else return 1; }
the_stack_data/61200.c
// INFO: rcu detected stall in corrupted // https://syzkaller.appspot.com/bug?id=0b4e390333d84f20af6c8a894cb6a5119aca3d75 // status:open // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include <dirent.h> #include <endian.h> #include <errno.h> #include <fcntl.h> #include <pthread.h> #include <sched.h> #include <signal.h> #include <stdarg.h> #include <stdbool.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/mount.h> #include <sys/prctl.h> #include <sys/resource.h> #include <sys/stat.h> #include <sys/syscall.h> #include <sys/time.h> #include <sys/types.h> #include <sys/wait.h> #include <time.h> #include <unistd.h> #include <linux/futex.h> static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i; for (i = 0; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } #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); } static void event_wait(event_t* ev) { while (!__atomic_load_n(&ev->state, __ATOMIC_ACQUIRE)) syscall(SYS_futex, &ev->state, FUTEX_WAIT | FUTEX_PRIVATE_FLAG, 0, 0); } static int event_isset(event_t* ev) { return __atomic_load_n(&ev->state, __ATOMIC_ACQUIRE); } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; for (;;) { uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; syscall(SYS_futex, &ev->state, FUTEX_WAIT | FUTEX_PRIVATE_FLAG, 0, &ts); if (__atomic_load_n(&ev->state, __ATOMIC_RELAXED)) return 1; now = current_time_ms(); if (now - start > timeout) return 0; } } static bool write_file(const char* file, const char* what, ...) { char buf[1024]; va_list args; va_start(args, what); vsnprintf(buf, sizeof(buf), what, args); va_end(args); buf[sizeof(buf) - 1] = 0; int len = strlen(buf); int fd = open(file, O_WRONLY | O_CLOEXEC); if (fd == -1) return false; if (write(fd, buf, len) != len) { int err = errno; close(fd); errno = err; return false; } close(fd); return true; } static void setup_common() { if (mount(0, "/sys/fs/fuse/connections", "fusectl", 0, 0)) { } } static void loop(); static void sandbox_common() { prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); setpgrp(); setsid(); struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = (200 << 20); setrlimit(RLIMIT_AS, &rlim); rlim.rlim_cur = rlim.rlim_max = 32 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 136 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); if (unshare(CLONE_NEWNS)) { } if (unshare(CLONE_NEWIPC)) { } if (unshare(0x02000000)) { } if (unshare(CLONE_NEWUTS)) { } if (unshare(CLONE_SYSVSEM)) { } typedef struct { const char* name; const char* value; } sysctl_t; static const sysctl_t sysctls[] = { {"/proc/sys/kernel/shmmax", "16777216"}, {"/proc/sys/kernel/shmall", "536870912"}, {"/proc/sys/kernel/shmmni", "1024"}, {"/proc/sys/kernel/msgmax", "8192"}, {"/proc/sys/kernel/msgmni", "1024"}, {"/proc/sys/kernel/msgmnb", "1024"}, {"/proc/sys/kernel/sem", "1024 1048576 500 1024"}, }; unsigned i; for (i = 0; i < sizeof(sysctls) / sizeof(sysctls[0]); i++) write_file(sysctls[i].name, sysctls[i].value); } int wait_for_loop(int pid) { if (pid < 0) exit(1); int status = 0; while (waitpid(-1, &status, __WALL) != pid) { } return WEXITSTATUS(status); } static int do_sandbox_none(void) { if (unshare(CLONE_NEWPID)) { } int pid = fork(); if (pid != 0) return wait_for_loop(pid); setup_common(); sandbox_common(); if (unshare(CLONE_NEWNET)) { } loop(); exit(1); } static void kill_and_wait(int pid, int* status) { kill(-pid, SIGKILL); kill(pid, SIGKILL); int i; for (i = 0; i < 100; i++) { if (waitpid(-1, status, WNOHANG | __WALL) == pid) return; usleep(1000); } DIR* dir = opendir("/sys/fs/fuse/connections"); if (dir) { for (;;) { struct dirent* ent = readdir(dir); if (!ent) break; if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0) continue; char abort[300]; snprintf(abort, sizeof(abort), "/sys/fs/fuse/connections/%s/abort", ent->d_name); int fd = open(abort, O_WRONLY); if (fd == -1) { continue; } if (write(fd, abort, 1) < 0) { } close(fd); } closedir(dir); } else { } while (waitpid(-1, status, __WALL) != pid) { } } #define SYZ_HAVE_SETUP_TEST 1 static void setup_test() { prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); setpgrp(); write_file("/proc/self/oom_score_adj", "1000"); } #define SYZ_HAVE_CLOSE_FDS 1 static void close_fds() { int fd; for (fd = 3; fd < 30; fd++) close(fd); } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { int i, call, thread; for (call = 0; call < 7; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); event_timedwait(&th->done, 45); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); close_fds(); } static void execute_one(void); #define WAIT_FLAGS __WALL static void loop(void) { int iter; for (iter = 0;; iter++) { int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { setup_test(); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5 * 1000) continue; kill_and_wait(pid, &status); break; } } } uint64_t r[3] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; void execute_call(int call) { long res; switch (call) { case 0: *(uint32_t*)0x2001d000 = 1; *(uint32_t*)0x2001d004 = 0x70; *(uint8_t*)0x2001d008 = 0; *(uint8_t*)0x2001d009 = 0; *(uint8_t*)0x2001d00a = 0; *(uint8_t*)0x2001d00b = 0; *(uint32_t*)0x2001d00c = 0; *(uint64_t*)0x2001d010 = 0x7f; *(uint64_t*)0x2001d018 = 0; *(uint64_t*)0x2001d020 = 0; STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 0, 1); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 1, 1); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 2, 1); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 3, 1); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 4, 1); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 5, 1); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 6, 1); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 7, 1); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 8, 1); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 9, 1); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 10, 1); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 11, 1); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 12, 1); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 13, 1); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 14, 1); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 15, 2); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 17, 1); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 18, 1); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 19, 1); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 20, 1); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 21, 1); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 22, 1); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 23, 1); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 24, 1); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 25, 1); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 26, 1); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 27, 1); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 28, 1); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 29, 35); *(uint32_t*)0x2001d030 = 0; *(uint32_t*)0x2001d034 = 0; *(uint64_t*)0x2001d038 = 0; *(uint64_t*)0x2001d040 = 0; *(uint64_t*)0x2001d048 = 0; *(uint64_t*)0x2001d050 = 0; *(uint32_t*)0x2001d058 = 0; *(uint32_t*)0x2001d05c = 0; *(uint64_t*)0x2001d060 = 0; *(uint32_t*)0x2001d068 = 0; *(uint16_t*)0x2001d06c = 0; *(uint16_t*)0x2001d06e = 0; syscall(__NR_perf_event_open, 0x2001d000, 0, 0, -1, 0); break; case 1: *(uint32_t*)0x20000300 = 1; *(uint32_t*)0x20000304 = 0x70; *(uint8_t*)0x20000308 = 5; *(uint8_t*)0x20000309 = 0; *(uint8_t*)0x2000030a = 0; *(uint8_t*)0x2000030b = 0; *(uint32_t*)0x2000030c = 0; *(uint64_t*)0x20000310 = 1; *(uint64_t*)0x20000318 = 0x8090; *(uint64_t*)0x20000320 = 0xf; STORE_BY_BITMASK(uint64_t, , 0x20000328, 0, 0, 1); STORE_BY_BITMASK(uint64_t, , 0x20000328, 0, 1, 1); STORE_BY_BITMASK(uint64_t, , 0x20000328, 0, 2, 1); STORE_BY_BITMASK(uint64_t, , 0x20000328, 0, 3, 1); STORE_BY_BITMASK(uint64_t, , 0x20000328, 0, 4, 1); STORE_BY_BITMASK(uint64_t, , 0x20000328, 0, 5, 1); STORE_BY_BITMASK(uint64_t, , 0x20000328, 0, 6, 1); STORE_BY_BITMASK(uint64_t, , 0x20000328, 0, 7, 1); STORE_BY_BITMASK(uint64_t, , 0x20000328, 0, 8, 1); STORE_BY_BITMASK(uint64_t, , 0x20000328, 0, 9, 1); STORE_BY_BITMASK(uint64_t, , 0x20000328, 0, 10, 1); STORE_BY_BITMASK(uint64_t, , 0x20000328, 0, 11, 1); STORE_BY_BITMASK(uint64_t, , 0x20000328, 0, 12, 1); STORE_BY_BITMASK(uint64_t, , 0x20000328, 0, 13, 1); STORE_BY_BITMASK(uint64_t, , 0x20000328, 0, 14, 1); STORE_BY_BITMASK(uint64_t, , 0x20000328, 0, 15, 2); STORE_BY_BITMASK(uint64_t, , 0x20000328, 0, 17, 1); STORE_BY_BITMASK(uint64_t, , 0x20000328, 0, 18, 1); STORE_BY_BITMASK(uint64_t, , 0x20000328, 0, 19, 1); STORE_BY_BITMASK(uint64_t, , 0x20000328, 0, 20, 1); STORE_BY_BITMASK(uint64_t, , 0x20000328, 0, 21, 1); STORE_BY_BITMASK(uint64_t, , 0x20000328, 0, 22, 1); STORE_BY_BITMASK(uint64_t, , 0x20000328, 0, 23, 1); STORE_BY_BITMASK(uint64_t, , 0x20000328, 0, 24, 1); STORE_BY_BITMASK(uint64_t, , 0x20000328, 0, 25, 1); STORE_BY_BITMASK(uint64_t, , 0x20000328, 0, 26, 1); STORE_BY_BITMASK(uint64_t, , 0x20000328, 0, 27, 1); STORE_BY_BITMASK(uint64_t, , 0x20000328, 0, 28, 1); STORE_BY_BITMASK(uint64_t, , 0x20000328, 0, 29, 35); *(uint32_t*)0x20000330 = 0; *(uint32_t*)0x20000334 = 0; *(uint64_t*)0x20000338 = 0; *(uint64_t*)0x20000340 = 0; *(uint64_t*)0x20000348 = 0; *(uint64_t*)0x20000350 = 0; *(uint32_t*)0x20000358 = 0; *(uint32_t*)0x2000035c = 0; *(uint64_t*)0x20000360 = 0; *(uint32_t*)0x20000368 = 0; *(uint16_t*)0x2000036c = 0; *(uint16_t*)0x2000036e = 0; res = syscall(__NR_perf_event_open, 0x20000300, 0, -1, -1, 0); if (res != -1) r[0] = res; break; case 2: *(uint32_t*)0x2001d000 = 1; *(uint32_t*)0x2001d004 = 0x70; *(uint8_t*)0x2001d008 = 1; *(uint8_t*)0x2001d009 = 0; *(uint8_t*)0x2001d00a = 0; *(uint8_t*)0x2001d00b = 0; *(uint32_t*)0x2001d00c = 0; *(uint64_t*)0x2001d010 = 0; *(uint64_t*)0x2001d018 = 0; *(uint64_t*)0x2001d020 = 0; STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 0, 1); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 1, 1); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 2, 1); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 3, 1); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 4, 1); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 5, 1); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 6, 1); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 7, 1); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 8, 1); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 9, 1); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 10, 1); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 11, 1); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 12, 1); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 13, 1); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 14, 1); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 15, 2); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 17, 1); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 18, 1); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 19, 1); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 20, 1); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 21, 1); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 22, 1); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 23, 1); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 24, 1); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 25, 1); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 26, 1); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 27, 1); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 28, 1); STORE_BY_BITMASK(uint64_t, , 0x2001d028, 0, 29, 35); *(uint32_t*)0x2001d030 = 0; *(uint32_t*)0x2001d034 = 0; *(uint64_t*)0x2001d038 = 0; *(uint64_t*)0x2001d040 = 0; *(uint64_t*)0x2001d048 = 0; *(uint64_t*)0x2001d050 = 0; *(uint32_t*)0x2001d058 = 0; *(uint32_t*)0x2001d05c = 0; *(uint64_t*)0x2001d060 = 0; *(uint32_t*)0x2001d068 = 0; *(uint16_t*)0x2001d06c = 0; *(uint16_t*)0x2001d06e = 0; syscall(__NR_perf_event_open, 0x2001d000, 0, -1, r[0], 0); break; case 3: syscall(__NR_mmap, 0x2094f000, 0x3000, 0, 0x11, r[0], 0); break; case 4: res = syscall(__NR_pipe, 0x20000000); if (res != -1) { r[1] = *(uint32_t*)0x20000000; r[2] = *(uint32_t*)0x20000004; } break; case 5: syscall(__NR_write, r[2], 0x200001c0, 0x100000073); break; case 6: syscall(__NR_read, r[1], 0x20000200, 0x50c7e3e3); break; } } int main(void) { syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0); do_sandbox_none(); return 0; }
the_stack_data/168894300.c
struct { int f; } s; static int f(void) { return 0; } int x = 5 - 5; int a[5]; int* p1 = (int*)0; int* p2 = &a[2]; int* p3 = &s.f; int main(void){ return *p2; }
the_stack_data/211081398.c
/* * POK header * * The following file is a part of the POK project. Any modification should * made according to the POK licence. You CANNOT use this file or a part of * this file is this part of a file for your own project * * For more information on the POK licence, please see our LICENCE FILE * * Please follow the coding guidelines described in doc/CODING_GUIDELINES * * Copyright (c) 2007-2009 POK team * * Created by julien on Fri Jan 16 17:13:16 2009 */ #if defined (POK_NEEDS_ERROR_HANDLING) && ( ! defined (POK_USE_GENERATED_ERROR_HANDLER)) #include <core/error.h> #include <core/thread.h> #include <core/partition.h> /* * This is a default error handler and it is used * when no error handled is defined. * Most of the time, the generated code provides * its own error handler. */ void pok_error_handler_worker () { uint32_t thread = 0; uint32_t error = 0; pok_error_handler_set_ready (&thread, &error); while (1) { pok_partition_set_mode (POK_PARTITION_STATE_STOPPED); } } #endif
the_stack_data/51701352.c
//RSA.c //A basic implementation of the RSA encryption protocol. //Includes #include <stdio.h> //Function Prototypes long encrypt(long message, int e, int n); long decrypt(long ciphertext, int d, int n); long modPower(long num, int pow, int mod); long extGCD(int a, int b, int *s, int *t); long multInv(int x, int n); //Main function int main() { int p, q; //Prime numbers int n, e; //Public key int rho, d; //Private key //Hardcoded sample prime numbers //Easy to bruteforce; don't use these for anything secret! p = 5; q = 11; e = 37; //Calculate public key n = p * q; //Calculate private key rho = (p-1) * (q-1); d = multInv(e, rho); //Display values printf("Using primes: p=%d, q=%d\n", p, q); printf("Public key: e=%d, N=%d\n", e, n); printf("Private key: d=%d\n", d); //Main menu long input = 0; printf("Enter number to encrypt/decrypt: "); scanf("%lld", &input); if(input >= n) { printf("Input number too large!\n"); printf("Message must be less than N.\n"); return 0; } printf("RSA encrypted message: %ld\n", encrypt((long)input, e, n)); printf("RSA decrypted message: %ld\n", decrypt((long)input, d, n)); return 0; } //Encrypt a numeric message with RSA long encrypt(long message, int e, int n) { return modPower(message, e, n); } //Decrypt a numeric message with RSA long decrypt(long ciphertext, int d, int n) { return modPower(ciphertext, d, n); } //Recursive integer modular exponentiation function long modPower(long num, int pow, int mod) { if(pow == 1) { return num; } //Mod at each level prevents integer overflow return ((num % mod) * (modPower(num, pow - 1, mod) % mod)) % mod; } //Calculate greatest common divisor (extended Euclidean algorithm) long extGCD(int a, int b, int *s, int *t) { if(a == 0) { *s = 0; *t = 1; return b; } int stmp = 0; int ttmp = 0; long gcd = extGCD(b % a, a, &stmp, &ttmp); *s = ttmp - (b/a)*stmp; *t = stmp; return gcd; } //Calculate multiplicative inverse of x mod(n) long multInv(int x, int n) { int s = 0; int t = 0; int gcd = extGCD(x, n, &s, &t); if(gcd != 1) { printf("Multiplicative inverse of %d mod %d does not exist! Exiting.\n", x, n); } //Handle negative values return ((s % n) + n) % n; }
the_stack_data/1053442.c
#include <stdio.h> #define MOD 100003 #define NO -1 #define YES 0 int a[1005][1005],N,M; void read(){ scanf("%d%d",&N,&M); while(M--){ int x,y; scanf("%d%d",&x,&y); a[x][y]=NO; } } int main(){ read(); for(int i=N;i>0;i--) for(int j=N;j>0;j--) if(a[i][j]==NO) a[i][j]=0; else { if(i==N && j==N) a[i][j]=1; else if(i==N) a[i][j]=a[i][j+1]%MOD; else if(j==N) a[i][j]=a[i+1][j]%MOD; else a[i][j]=(a[i+1][j]+a[i][j+1])%MOD; } #ifdef DEBUG for(int i=1;i<=N;i++){ for(int j=1;j<=N;j++) printf("%d ",a[i][j]); putchar('\n'); } #endif printf("%d\n",a[1][1]); return 0; }
the_stack_data/44815.c
/* * lib/str.c */ /* # license--start # # Copyright 2012-2013 John Marshall # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # license--end */ #include <stdio.h> #include <stdlib.h> #include <string.h> /* prototypes */ char *russ_sarray0_get_suffix(char **, char *); void *russ_free(void *); /** * Count the number of substrings in the string. * * @param s string * @param ss substring * @return # of instances found */ int russ_str_count_sub(const char *s, const char *ss) { int ss_len, n; ss_len = strlen(ss); for (n = 0; s != NULL; n++) { if ((s = strstr(s, ss)) == NULL) { break; } s += ss_len; } return n; } /** * Find the idx-th component from the string as divided by a * separator and return a duplicate of it (which must be freed by the * caller). * * If string starts with separator, then component at index 0 returns * "" (empty string). * * @param s string * @param sep separator character * @param idx index of the desired component * @return copy of component string; NULL on error/unavailable */ char * russ_str_dup_comp(const char *s, char sep, int idx) { char *p = NULL; for (; idx > 0; idx--) { if ((s = strchr(s, sep)) == NULL) { return NULL; } s++; } if ((p = strchr(s, sep)) == NULL) { s = strdup(s); } else { s = strndup(s, p-s); } return (char *)s; } /** * Like russ_str_dup_comp() except the component is copied into a * supplied (and known-sized) buffer. The buffer is safely null- * terminated. * * @param s string * @param sep separator character * @param idx index of the desired component * @param b buffer * @param sz buffer size * @return 0 on success; -1 on failure */ int russ_str_get_comp(const char *s, char sep, int idx, char *b, int sz) { char *p = NULL; for(; idx > 0; idx--) { if ((s = strchr(s, sep)) == NULL) { return -1; } s++; } if ((p = strchr(s, sep)) == NULL) { p = (char *)s+strlen(s); } if ((p-s > sz-1) || (strncpy(b, s, p-s) == NULL)) { return -1; } b[p-s] = '\0'; return 0; } /** * Replace character in string. * * @param s string * @param oldch old character * @param newch new character * @return string */ char * russ_str_replace_char(char *s, char oldch, char newch) { if (s != NULL) { for (; *s != '\0'; s++) { if (*s == oldch) { *s = newch; } } } return s; } /** * Resolve a format string using a NULL-terminated list of strings of * the form name=value, and return a new string. * * Resolving is done for references in a string with the format * ${name}. If the name exists in the list, its value replaces the * ${name} string; otherwise an empty string is used. * * A failure occurs *only* if the size of the working space is * exceeded. * * The return value must be freed by the caller. * * @param s * @return resolved string; NULL on failure */ char * russ_str_resolve(const char *s, char **vars) { const char *start = NULL, *end = NULL; const char *sp = NULL, *spend = NULL; char *fp = NULL, *fpend = NULL; char *value = NULL; int valuelen; char final[16000], name[256], prefix[256]; sp = s; spend = s+strlen(s)+1; fp = final; fpend = final+sizeof(final); final[0] = '\0'; while (sp < spend) { if ((start = strstr(sp, "${")) == NULL) { // nothing left to resolve break; } // leading part if (start > sp) { if (start-sp > fpend-fp) { return NULL; } strncpy(fp, sp, start-sp); fp += start-sp; } // to resolve part start += 2; if ((end = strchr(start+1, '}')) == NULL) { // cannot find terminator return NULL; } if (end-start+1 > sizeof(name)) { // name too long return NULL; } strncpy(name, start, end-start); name[end-start] = '\0'; strcpy(prefix, name); prefix[end-start] = '='; prefix[end-start+1] = '\0'; if ((value = russ_sarray0_get_suffix(vars, prefix)) != NULL) { valuelen = strlen(value); if (fp+valuelen+1 > fpend) { value = russ_free(value); return NULL; } strcpy(fp, value); fp += valuelen; //value = russ_free(value); } sp = end+1; } // trailing part if (spend-sp > fpend-fp) { return NULL; } strncpy(fp, sp, spend-sp); fp += spend-sp; return strdup(final); }
the_stack_data/232955380.c
#include<stdio.h> int main() { char name[30]; float a,b,total; gets(name); scanf("%f%f",&a,&b); total=a+(b*15)/100; printf("TOTAL = R$ %0.2f\n",total); return 0; }
the_stack_data/90762170.c
/* * Copyright (C) 2015 The CyanogenMod Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* void __android_logPower_print(void) { } */ void __android_logPower_print(int a1, const char *a2, int *a3, int a4) { } void __android_log_exception_write(void){ } void __android_log_exception_msg_write(void){ } void __android_janklog_print(void) { } void __android_janklog_buf_write(void){ } void __android_logPower_buf_write(void){ } void __android_log_buf_print(void){ } void __android_log_pmsg_file_read(void){ } int isLogEnabled(void) { return 0; } void __hi_log_print(void){ } void __android_log_pmsg_file_write(void){ }
the_stack_data/102328.c
#include <stdio.h> #include <string.h> const int MAX_SIZE = 10000; int main(int argc, char *argv[]) { if (argc != 3) return 1; FILE *old = fopen(argv[1], "r"); char buffer[MAX_SIZE]; fread(buffer, MAX_SIZE, 1, old); fclose(old); FILE *new = fopen(argv[2], "w"); fwrite(buffer, strlen(buffer), 1, new); fclose(new); return 0; }
the_stack_data/92326784.c
const int dbg = 0; #include <stdio.h> #include <stdarg.h> #include <stdlib.h> #include <string.h> #define MAX_SEGS 20 #define MAX_CHKS 5 typedef struct { char name[17]; long fileofs; unsigned base; unsigned limit; int nameidx; int segidx; } seg_t; typedef enum { CHKS_SUM8 } checksumtype; typedef struct { long firstofs; long lastofs; long sumofs; checksumtype type; } chks_t; // the code USES the property that globals are zero-initialized, // and relies on nameidx and segidx being zero (an invalid obj index) seg_t segtable[MAX_SEGS]; chks_t checksums[MAX_CHKS]; unsigned segs; unsigned chks; unsigned nameidx = 0; unsigned segidx = 0; void DIE(const char* msg, ...) { va_list va; va_start(va, msg); vfprintf(stderr, msg, va); exit(1); } void load_segs(const char* fname) { char linebuf[80]; FILE* f = fopen(fname, "r"); if (!f) DIE("Can't open segment map %s\n", fname); while (fgets(linebuf, sizeof linebuf, f)) { char dummy; seg_t *s = &segtable[segs]; unsigned linelen = strlen(linebuf); if (!linelen || (linelen == 1 && linebuf[0] == '\n')) continue; if (linebuf[0] == '#') continue; if (linebuf[0] == '!') { if (strncmp(linebuf + 1, "CHKSUM", 6) == 0) { char typebuf[9]; chks_t *c = &checksums[chks]; if (sscanf(linebuf + 7, "%8s %li %li %li %c", typebuf, &c->firstofs, &c->lastofs, &c->sumofs, &dummy) != 4) DIE("malformed checksum specification\n%s\n", linebuf); if (c->firstofs > c->lastofs) DIE("checksum area start %lx after end %lx\n", c->firstofs, c->lastofs); if(strcmp(typebuf, "SUM8") == 0) c->type = CHKS_SUM8; else DIE("unknown checksum algorithm %s\n", typebuf); chks++; } else DIE("unknown directive\n%s\n", linebuf); continue; } if (segs == MAX_SEGS) DIE("Too many segments\n"); if (linebuf[linelen-1] != '\n' && linelen == sizeof(linebuf) - 1) DIE("Overly long map file line starting with\n%s\n", linebuf); if (sscanf(linebuf, "%16s %li %i %i %c", s->name, &s->fileofs, &s->base, &s->limit, &dummy) != 4) DIE("Syntax error in line\n%s\n", linebuf); if (s->base > s->limit) DIE("Segment %s: limit %x below base %x\n", s->name, s->limit, s->base); segs++; } } typedef struct { unsigned char data[1024]; unsigned len; unsigned readidx; unsigned char type; } record_t; int read_record(FILE *obj, record_t *r) { int chksum_byte; unsigned char buf[3]; if (fread(buf, 1, 3, obj) != 3) return 0; r->type = buf[0]; r->len = buf[1] | (buf[2] << 8); if (r->len == 0) DIE("malformed object record - doesn't have a checksum\n"); r->len--; if (r->len > 1024) DIE("malformed object record - size %d exceeds 1K\n", r->len); if (fread(r->data, 1, r->len, obj) != r->len) DIE("unexpected end of file reading object record\n"); chksum_byte = getc(obj); if (chksum_byte == EOF) DIE("unexpected end of file reading object record checksum\n"); if (chksum_byte != 0) { unsigned i; for (i = 0; i < r->len; i++) chksum_byte += r->data[i]; for (i = 0; i < 3; i++) chksum_byte += buf[i]; if ((chksum_byte & 0xFF) != 0) DIE("checksum error in object file record"); } r->readidx = 0; return 1; } #define len_remaining(r) ((r)->len - (r)->readidx) #define at_end(r) (len_remaining(r) == 0) unsigned char getc_or_die(record_t *r) { if (at_end(r)) DIE("unexpected end of record\n"); return r->data[r->readidx++]; } unsigned getw_or_die(record_t *r) { unsigned temp = getc_or_die(r); return temp | (getc_or_die(r) << 8); } unsigned get_idx(record_t *r) { unsigned temp = getc_or_die(r); if (temp & 0x80) return ((temp & 0x7F) << 8) | getc_or_die(r); else return temp; } void record_read(void *target, size_t len, record_t *r) { if (len_remaining(r) < len) DIE("unexpected end of record trying to read %d bytes\n", len); memcpy(target, &r->data[r->readidx], len); r->readidx += len; } void record_copyto(FILE *target, size_t len, record_t *r) { if (len_remaining(r) < len) DIE("unexpected record end in copy\n"); if (fwrite(&r->data[r->readidx], 1, len, target) != len) DIE("data write error\n"); r->readidx += len; } void assign_nameidx(const char *name, int idx) { int s; for (s = 0; s < segs; s++) if (strcmp(name, segtable[s].name) == 0) segtable[s].nameidx = idx; } seg_t *seg_by_nameidx(int nameidx) { int s; for (s = 0; s < segs; s++) if (segtable[s].nameidx == nameidx) return &segtable[s]; return NULL; } seg_t *seg_by_segidx(int segidx) { int s; for (s = 0; s < segs; s++) if (segtable[s].segidx == segidx) return &segtable[s]; return NULL; } void handle_names(record_t *r) { char namebuf[256]; while (!at_end(r)) { unsigned namelen = getc_or_die(r); record_read(namebuf, namelen, r); namebuf[namelen] = 0; nameidx++; if (dbg) printf("Name %d: %s\n", nameidx, namebuf); assign_nameidx(namebuf, nameidx); } } void handle_segment(record_t *r) { unsigned char type_byte = getc_or_die(r); unsigned seglimit; seg_t *s; segidx++; if ((type_byte & 0xE0) == 0) // 'AT' segment, defines stuff already present return; seglimit = (getw_or_die(r) - 1) & 0xFFFF; s = seg_by_nameidx(get_idx(r)); if (s) { s->segidx = segidx; if (dbg) printf("Segment %s has index %d\n", s->name, s->segidx); if (s->limit < seglimit) DIE("Segment %s overflow (maplimit = %04x, objlimit = %04x\n", s->name, s->limit, seglimit); } else { // we don't store names of segments not in the map, // so we can't tell the user the name of the segment fprintf(stderr, "WARNING: ignoring a non-AT segment not in the map\n"); } } void handle_fixupp(record_t *r) { while(!at_end(r)) { unsigned char headbyte = getc_or_die(r); if ((headbyte & 0x80) == 0) { // "thread": common frame or target if ((headbyte & 0x1C) == 0) // T0 or F0 get_idx(r); else if((headbyte & 0x58) == 0x50) // F4 or F4 ; // no-index types else DIE("FIXUPP thread type %02x unsupported\n", headbyte); } else { // actual fixup getc_or_die(r); // skip low location byte if ((headbyte & 0x7C) == 0x44) { // segment relative 16-bit offset fixup int has_framedatum = 0; int has_targetdatum = 0; unsigned char fixdata = getc_or_die(r); if ((fixdata & 0x80) == 0) { // explit F type if ((fixdata & 0x70) == 0) has_framedatum = 1; // relative to explicit segment else if ((fixdata & 0x60) == 0x40) ; // frame is implicit else DIE("unsupported frame type %d\n", fixdata >> 4); } // threaded frames are always OK (thread would have been // rejected on unhandled types) and never have frame datum if ((fixdata & 8) == 0) { // explicit T type if ((fixdata & 3) != 0) DIE("unsupported target type %d\n", fixdata & 3); has_targetdatum = 1; } if (has_framedatum) get_idx(r); if (has_targetdatum) get_idx(r); if ((fixdata & 4) == 0) { unsigned displacement = getw_or_die(r); if (displacement != 0) DIE("non-zero displacement %x\n", displacement); } } else DIE("FIXUPP fixup type %02x unsupported\n", headbyte); } } } void handle_ledata(record_t *r, FILE *bin) { unsigned ofs; unsigned segidx; seg_t *seg; segidx = get_idx(r); ofs = getw_or_die(r); if (!at_end(r)) { unsigned len = len_remaining(r); seg = seg_by_segidx(segidx); if (!seg) DIE("LEDATA in missing section"); if (ofs < seg->base) DIE("LEDATA for segment %s at %04x below base (%04x)", seg->name, ofs, seg->base); if (((ofs + len - 1) & 0xFFFF) < ofs) DIE("LEDATA for segment %s with start %04x, len %04x" " overflows 64K\n", seg->name, ofs, len); if (ofs + len - 1 > seg->limit) DIE("LEDATA for segment %s at %04x, len %04x exceeds" " segment limit %04x\n", seg->name, ofs, len, seg->limit); fseek(bin, seg->fileofs + ofs - seg->base, SEEK_SET); record_copyto(bin, len, r); } } void expand_lidata(record_t *r, FILE *bin, unsigned *maxexpand) { unsigned int repeat_count = getw_or_die(r); unsigned int item_count = getw_or_die(r); unsigned int i; unsigned mark = r->readidx; while (repeat_count--) { r->readidx = mark; if (!item_count) { unsigned char blobsize = getc_or_die(r); if (blobsize > *maxexpand) DIE("segment limit exceeded in LIDATA expansion"); *maxexpand -= blobsize; // blob payload record_copyto(bin, blobsize, r); } else for (i = 0; i < item_count; i++) expand_lidata(r, bin, maxexpand); } } void skip_lidata(record_t *r) { unsigned int item_count; getw_or_die(r); // ignore repeat count item_count = getw_or_die(r); if (!item_count) { // blob payload unsigned char bloblen = getc_or_die(r); while(bloblen--) if (getc_or_die(r) != 0) DIE("non-NUL LIDATA in nonpresent section"); } else { while (item_count--) skip_lidata(r); } } void handle_lidata(record_t *r, FILE *bin) { unsigned ofs; unsigned segidx; unsigned maxexpand; seg_t *seg; segidx = get_idx(r); ofs = getw_or_die(r); if (!at_end(r)) { seg = seg_by_segidx(segidx); if (seg) { if(ofs < seg->base) DIE("LIDATA for segment %s at %04x below base (%04x)", seg->name, ofs, seg->base); if(ofs > seg->limit) DIE("LIDATA for segment %s at %04x above limit (%04x)", seg->name, ofs, seg->limit); fseek(bin, seg->fileofs + ofs - seg->base, SEEK_SET); maxexpand = seg->limit - ofs; expand_lidata(r, bin, &maxexpand); } else skip_lidata(r); } } void fix_checksum(chks_t *dtor, FILE *bin) { long current = dtor->firstofs; long bytes = dtor->lastofs - current + 1; fseek(bin, current, SEEK_SET); switch(dtor->type) { case CHKS_SUM8: { unsigned char sum = 0; while (bytes--) { int next = getc(bin); if (next == EOF) DIE("can't read data for checksum\n"); if (current == dtor->sumofs) // mask byte to be overwritten next = 0; sum += (unsigned char)next; current++; } fseek(bin, dtor->sumofs, SEEK_SET); putc((unsigned char)-sum, bin); } } } void apply_patch(FILE *bin, FILE *obj) { int c; record_t r; if (!read_record(obj, &r) || r.type != 0x80) DIE("patch file doesn't start with a THEADR record\n"); while (read_record(obj, &r)) { switch (r.type) { case 0x88: // comment record break; case 0x8A: goto done; case 0x96: handle_names(&r); break; case 0x98: handle_segment(&r); break; case 0x9C: handle_fixupp(&r); break; case 0xa0: handle_ledata(&r, bin); break; case 0xa2: handle_lidata(&r, bin); break; default: fprintf(stderr, "WARNING: unhandle record %02x, size %d\n", r.type, r.len); break; } } fprintf(stderr, "WARNING: no end of module record encountered\n"); done: for (c = 0; c < chks; c++) fix_checksum(checksums + c, bin); } int main(int argc, char *argv[]) { FILE *binary; FILE *obj; if (argc != 4) DIE("omfpatch <bin> <seglist> <obj>\n"); binary = fopen(argv[1], "r+b"); if (!binary) DIE("Can't open binary %s for patching\n", argv[1]); obj = fopen(argv[3], "rb"); if (!obj) DIE("Can't open object file %s\n", argv[3]); load_segs(argv[2]); apply_patch(binary, obj); printf("patched %s using %s - OK\n", argv[1], argv[3]); return 0; }
the_stack_data/809130.c
/* UNIX V7 source code: see /COPYRIGHT or www.tuhs.org for details. */ /* join F1 F2 on stuff */ #include <stdio.h> #define F1 0 #define F2 1 #define NFLD 20 /* max field per line */ #define comp() cmp(ppi[F1][j1],ppi[F2][j2]) FILE *f[2]; char buf[2][BUFSIZ]; /*input lines */ char *ppi[2][NFLD]; /* pointers to fields in lines */ char *s1,*s2; int j1 = 1; /* join of this field of file 1 */ int j2 = 1; /* join of this field of file 2 */ int olist[2*NFLD]; /* output these fields */ int olistf[2*NFLD]; /* from these files */ int no; /* number of entries in olist */ int sep1 = ' '; /* default field separator */ int sep2 = '\t'; char* null = ""; int unpub1; int unpub2; int aflg; main(argc, argv) char *argv[]; { int i; int n1, n2; long top2, bot2; long ftell(); while (argc > 1 && argv[1][0] == '-') { if (argv[1][1] == '\0') break; switch (argv[1][1]) { case 'a': switch(argv[1][2]) { case '1': aflg |= 1; break; case '2': aflg |= 2; break; default: aflg |= 3; } break; case 'e': null = argv[2]; argv++; argc--; break; case 't': sep1 = sep2 = argv[1][2]; break; case 'o': for (no = 0; no < 2*NFLD; no++) { if (argv[2][0] == '1' && argv[2][1] == '.') { olistf[no] = F1; olist[no] = atoi(&argv[2][2]); } else if (argv[2][0] == '2' && argv[2][1] == '.') { olist[no] = atoi(&argv[2][2]); olistf[no] = F2; } else break; argc--; argv++; } break; case 'j': if (argv[1][2] == '1') j1 = atoi(argv[2]); else if (argv[1][2] == '2') j2 = atoi(argv[2]); else j1 = j2 = atoi(argv[2]); argc--; argv++; break; } argc--; argv++; } for (i = 0; i < no; i++) olist[i]--; /* 0 origin */ if (argc != 3) error("usage: join [-j1 x -j2 y] [-o list] file1 file2"); j1--; j2--; /* everyone else believes in 0 origin */ s1 = ppi[F1][j1]; s2 = ppi[F2][j2]; if (argv[1][0] == '-') f[F1] = stdin; else if ((f[F1] = fopen(argv[1], "r")) == NULL) error("can't open %s", argv[1]); if ((f[F2] = fopen(argv[2], "r")) == NULL) error("can't open %s", argv[2]); #define get1() n1=input(F1) #define get2() n2=input(F2) get1(); bot2 = ftell(f[F2]); get2(); while(n1>0 && n2>0 || aflg!=0 && n1+n2>0) { if(n1>0 && n2>0 && comp()>0 || n1==0) { if(aflg&2) output(0, n2); bot2 = ftell(f[F2]); get2(); } else if(n1>0 && n2>0 && comp()<0 || n2==0) { if(aflg&1) output(n1, 0); get1(); } else /*(n1>0 && n2>0 && comp()==0)*/ { while(n2>0 && comp()==0) { output(n1, n2); top2 = ftell(f[F2]); get2(); } fseek(f[F2], bot2, 0); get2(); get1(); for(;;) { if(n1>0 && n2>0 && comp()==0) { output(n1, n2); get2(); } else if(n1>0 && n2>0 && comp()<0 || n2==0) { fseek(f[F2], bot2, 0); get2(); get1(); } else /*(n1>0 && n2>0 && comp()>0 || n1==0)*/{ fseek(f[F2], top2, 0); bot2 = top2; get2(); break; } } } } return(0); } input(n) /* get input line and split into fields */ { register int i, c; char *bp; char **pp; bp = buf[n]; pp = ppi[n]; if (fgets(bp, BUFSIZ, f[n]) == NULL) return(0); for (i = 0; ; i++) { if (sep1 == ' ') /* strip multiples */ while ((c = *bp) == sep1 || c == sep2) bp++; /* skip blanks */ else c = *bp; if (c == '\n' || c == '\0') break; *pp++ = bp; /* record beginning */ while ((c = *bp) != sep1 && c != '\n' && c != sep2 && c != '\0') bp++; *bp++ = '\0'; /* mark end by overwriting blank */ /* fails badly if string doesn't have \n at end */ } *pp = 0; return(i); } output(on1, on2) /* print items from olist */ int on1, on2; { int i; char *temp; if (no <= 0) { /* default case */ printf("%s", on1? ppi[F1][j1]: ppi[F2][j2]); for (i = 0; i < on1; i++) if (i != j1) printf("%c%s", sep1, ppi[F1][i]); for (i = 0; i < on2; i++) if (i != j2) printf("%c%s", sep1, ppi[F2][i]); printf("\n"); } else { for (i = 0; i < no; i++) { temp = ppi[olistf[i]][olist[i]]; if(olistf[i]==F1 && on1<=olist[i] || olistf[i]==F2 && on2<=olist[i] || *temp==0) temp = null; printf("%s", temp); if (i == no - 1) printf("\n"); else printf("%c", sep1); } } } error(s1, s2, s3, s4, s5) char *s1; { fprintf(stderr, "join: "); fprintf(stderr, s1, s2, s3, s4, s5); fprintf(stderr, "\n"); exit(1); } cmp(s1, s2) char *s1, *s2; { return(strcmp(s1, s2)); }
the_stack_data/34512760.c
/****************************************************************************** * Copyright (c) 2004, 2008 IBM Corporation * All rights reserved. * This program and the accompanying materials * are made available under the terms of the BSD License * which accompanies this distribution, and is available at * http://www.opensource.org/licenses/bsd-license.php * * Contributors: * IBM Corporation - initial implementation *****************************************************************************/ #include <string.h> char * strchr(const char *s, int c) { char cb = c; while (*s != 0) { if (*s == cb) { return (char *)s; } s += 1; } return NULL; }
the_stack_data/89201616.c
#include <stdio.h> #include <stdlib.h> #include <time.h> #include <math.h> #include <omp.h> #include <string.h> #define TOTAL 500000000 long inc(){ unsigned int seed=time(NULL); float x = rand_r(&seed)/ (float) RAND_MAX; float y = rand_r(&seed)/ (float) RAND_MAX; if (sqrt((x*x) + (y*y)) < 1 ) return 1; return 0; } int main(int argc, char* argv[]){ if (argc!=2) return 1; const int threads_num=atoi(argv[1]); printf("Theads: %d\n",threads_num); long sum=0; #pragma omp parallel num_threads(threads_num) { #pragma omp for reduction(+:sum) for(long i=0;i<TOTAL;i++){ sum = inc()+sum; } } //printf("Pi is : %f\n",4*sum/(float)TOTAL); }
the_stack_data/75137092.c
///TAFFO_TEST_ARGS -Xvra -propagate-all float oven(int stuff, int baked, float cherry) { float __attribute__((annotate("scalar(range(-32767, 32767))"))) cake = baked + stuff; return cake + cherry; }
the_stack_data/32093.c
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <CL/cl.h> unsigned char *read_buffer(char *file_name, size_t *size_ptr) { FILE *f; unsigned char *buf; size_t size; /* Open file */ f = fopen(file_name, "rb"); if (!f) return NULL; /* Obtain file size */ fseek(f, 0, SEEK_END); size = ftell(f); fseek(f, 0, SEEK_SET); /* Allocate and read buffer */ buf = malloc(size + 1); fread(buf, 1, size, f); buf[size] = '\0'; /* Return size of buffer */ if (size_ptr) *size_ptr = size; /* Return buffer */ return buf; } void write_buffer(char *file_name, const char *buffer, size_t buffer_size) { FILE *f; /* Open file */ f = fopen(file_name, "w+"); /* Write buffer */ if(buffer) fwrite(buffer, 1, buffer_size, f); /* Close file */ fclose(f); } int main(int argc, char const *argv[]) { /* Get platform */ cl_platform_id platform; cl_uint num_platforms; cl_int ret = clGetPlatformIDs(1, &platform, &num_platforms); if (ret != CL_SUCCESS) { printf("error: call to 'clGetPlatformIDs' failed\n"); exit(1); } printf("Number of platforms: %d\n", num_platforms); printf("platform=%p\n", platform); /* Get platform name */ char platform_name[100]; ret = clGetPlatformInfo(platform, CL_PLATFORM_NAME, sizeof(platform_name), platform_name, NULL); if (ret != CL_SUCCESS) { printf("error: call to 'clGetPlatformInfo' failed\n"); exit(1); } printf("platform.name='%s'\n\n", platform_name); /* Get device */ cl_device_id device; cl_uint num_devices; ret = clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 1, &device, &num_devices); if (ret != CL_SUCCESS) { printf("error: call to 'clGetDeviceIDs' failed\n"); exit(1); } printf("Number of devices: %d\n", num_devices); printf("device=%p\n", device); /* Get device name */ char device_name[100]; ret = clGetDeviceInfo(device, CL_DEVICE_NAME, sizeof(device_name), device_name, NULL); if (ret != CL_SUCCESS) { printf("error: call to 'clGetDeviceInfo' failed\n"); exit(1); } printf("device.name='%s'\n", device_name); printf("\n"); /* Create a Context Object */ cl_context context; context = clCreateContext(NULL, 1, &device, NULL, NULL, &ret); if (ret != CL_SUCCESS) { printf("error: call to 'clCreateContext' failed\n"); exit(1); } printf("context=%p\n", context); /* Create a Command Queue Object*/ cl_command_queue command_queue; command_queue = clCreateCommandQueue(context, device, 0, &ret); if (ret != CL_SUCCESS) { printf("error: call to 'clCreateCommandQueue' failed\n"); exit(1); } printf("command_queue=%p\n", command_queue); printf("\n"); /* Program source */ unsigned char *source_code; size_t source_length; /* Read program from 'add_ushort8ushort8.cl' */ source_code = read_buffer("add_ushort8ushort8.cl", &source_length); /* Create a program */ cl_program program; program = clCreateProgramWithSource(context, 1, (const char **)&source_code, &source_length, &ret); if (ret != CL_SUCCESS) { printf("error: call to 'clCreateProgramWithSource' failed\n"); exit(1); } printf("program=%p\n", program); /* Build program */ ret = clBuildProgram(program, 1, &device, NULL, NULL, NULL); if (ret != CL_SUCCESS ) { size_t size; char *log; /* Get log size */ clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG,0, NULL, &size); /* Allocate log and print */ log = malloc(size); clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG,size, log, NULL); printf("error: call to 'clBuildProgram' failed:\n%s\n", log); /* Free log and exit */ free(log); exit(1); } printf("program built\n"); printf("\n"); /* Create a Kernel Object */ cl_kernel kernel; kernel = clCreateKernel(program, "add_ushort8ushort8", &ret); if (ret != CL_SUCCESS) { printf("error: call to 'clCreateKernel' failed\n"); exit(1); } /* Create and allocate host buffers */ size_t num_elem = 10; /* Create and init host side src buffer 0 */ cl_ushort8 *src_0_host_buffer; src_0_host_buffer = malloc(num_elem * sizeof(cl_ushort8)); for (int i = 0; i < num_elem; i++) src_0_host_buffer[i] = (cl_ushort8){{2, 2, 2, 2, 2, 2, 2, 2}}; /* Create and init device side src buffer 0 */ cl_mem src_0_device_buffer; src_0_device_buffer = clCreateBuffer(context, CL_MEM_READ_ONLY, num_elem * sizeof(cl_ushort8), NULL, &ret); if (ret != CL_SUCCESS) { printf("error: could not create source buffer\n"); exit(1); } ret = clEnqueueWriteBuffer(command_queue, src_0_device_buffer, CL_TRUE, 0, num_elem * sizeof(cl_ushort8), src_0_host_buffer, 0, NULL, NULL); if (ret != CL_SUCCESS) { printf("error: call to 'clEnqueueWriteBuffer' failed\n"); exit(1); } /* Create and init host side src buffer 1 */ cl_ushort8 *src_1_host_buffer; src_1_host_buffer = malloc(num_elem * sizeof(cl_ushort8)); for (int i = 0; i < num_elem; i++) src_1_host_buffer[i] = (cl_ushort8){{2, 2, 2, 2, 2, 2, 2, 2}}; /* Create and init device side src buffer 1 */ cl_mem src_1_device_buffer; src_1_device_buffer = clCreateBuffer(context, CL_MEM_READ_ONLY, num_elem * sizeof(cl_ushort8), NULL, &ret); if (ret != CL_SUCCESS) { printf("error: could not create source buffer\n"); exit(1); } ret = clEnqueueWriteBuffer(command_queue, src_1_device_buffer, CL_TRUE, 0, num_elem * sizeof(cl_ushort8), src_1_host_buffer, 0, NULL, NULL); if (ret != CL_SUCCESS) { printf("error: call to 'clEnqueueWriteBuffer' failed\n"); exit(1); } /* Create host dst buffer */ cl_ushort8 *dst_host_buffer; dst_host_buffer = malloc(num_elem * sizeof(cl_ushort8)); memset((void *)dst_host_buffer, 1, num_elem * sizeof(cl_ushort8)); /* Create device dst buffer */ cl_mem dst_device_buffer; dst_device_buffer = clCreateBuffer(context, CL_MEM_WRITE_ONLY, num_elem *sizeof(cl_ushort8), NULL, &ret); if (ret != CL_SUCCESS) { printf("error: could not create dst buffer\n"); exit(1); } /* Set kernel arguments */ ret = CL_SUCCESS; ret |= clSetKernelArg(kernel, 0, sizeof(cl_mem), &src_0_device_buffer); ret |= clSetKernelArg(kernel, 1, sizeof(cl_mem), &src_1_device_buffer); ret |= clSetKernelArg(kernel, 2, sizeof(cl_mem), &dst_device_buffer); if (ret != CL_SUCCESS) { printf("error: call to 'clSetKernelArg' failed\n"); exit(1); } /* Launch the kernel */ size_t global_work_size = num_elem; size_t local_work_size = num_elem; ret = clEnqueueNDRangeKernel(command_queue, kernel, 1, NULL, &global_work_size, &local_work_size, 0, NULL, NULL); if (ret != CL_SUCCESS) { printf("error: call to 'clEnqueueNDRangeKernel' failed\n"); exit(1); } /* Wait for it to finish */ clFinish(command_queue); /* Read results from GPU */ ret = clEnqueueReadBuffer(command_queue, dst_device_buffer, CL_TRUE,0, num_elem * sizeof(cl_ushort8), dst_host_buffer, 0, NULL, NULL); if (ret != CL_SUCCESS) { printf("error: call to 'clEnqueueReadBuffer' failed\n"); exit(1); } /* Dump dst buffer to file */ char dump_file[100]; sprintf((char *)&dump_file, "%s.result", argv[0]); write_buffer(dump_file, (const char *)dst_host_buffer, num_elem * sizeof(cl_ushort8)); printf("Result dumped to %s\n", dump_file); /* Free host dst buffer */ free(dst_host_buffer); /* Free device dst buffer */ ret = clReleaseMemObject(dst_device_buffer); if (ret != CL_SUCCESS) { printf("error: call to 'clReleaseMemObject' failed\n"); exit(1); } /* Free host side src buffer 0 */ free(src_0_host_buffer); /* Free device side src buffer 0 */ ret = clReleaseMemObject(src_0_device_buffer); if (ret != CL_SUCCESS) { printf("error: call to 'clReleaseMemObject' failed\n"); exit(1); } /* Free host side src buffer 1 */ free(src_1_host_buffer); /* Free device side src buffer 1 */ ret = clReleaseMemObject(src_1_device_buffer); if (ret != CL_SUCCESS) { printf("error: call to 'clReleaseMemObject' failed\n"); exit(1); } /* Release kernel */ ret = clReleaseKernel(kernel); if (ret != CL_SUCCESS) { printf("error: call to 'clReleaseKernel' failed\n"); exit(1); } /* Release program */ ret = clReleaseProgram(program); if (ret != CL_SUCCESS) { printf("error: call to 'clReleaseProgram' failed\n"); exit(1); } /* Release command queue */ ret = clReleaseCommandQueue(command_queue); if (ret != CL_SUCCESS) { printf("error: call to 'clReleaseCommandQueue' failed\n"); exit(1); } /* Release context */ ret = clReleaseContext(context); if (ret != CL_SUCCESS) { printf("error: call to 'clReleaseContext' failed\n"); exit(1); } return 0; }
the_stack_data/192330402.c
/* { dg-do preprocess } */ /* Test for crash with indented empty definitions. */ #define _LIBC_LIMITS_H_ /* nothing */
the_stack_data/29826113.c
#include <assert.h> #include <stdbool.h> #include <stddef.h> #include <stdio.h> int main(const int argc, const char* const argv[]) { // Getting away with no error checking throughout because CodeEval makes some // strong guarantees about our runtime environment. No need to pay when we're // being benchmarked. Don't forget to define NDEBUG prior to submitting! assert(argc >= 2 && "Expecting at least one command-line argument."); static char stdoutBuffer[1536] = ""; // Turn on full output buffering for stdout. setvbuf(stdout, stdoutBuffer, _IOFBF, sizeof stdoutBuffer); FILE* inputStream = fopen(argv[1], "r"); assert(inputStream && "Failed to open input stream."); for(char lineBuffer[256] = ""; fgets(lineBuffer, sizeof lineBuffer, inputStream);) { // Size of the minefield: M rows by N columns. size_t m = 0, n = 0; char* line = lineBuffer; // Get M. for(;*line != ','; ++line) { assert(*line >= '0' && *line <= '9'); m = (m * 10) + (*line - '0'); } // Get N. for(++line; *line != ';'; ++line) { assert(*line >= '0' && *line <= '9'); n = (n * 10) + (*line - '0'); } assert(*line == ';'); // Eat the delimiter. ++line; bool minefield[10][10] = {{false}}; assert(m < sizeof minefield / sizeof *minefield); assert(n < sizeof *minefield / sizeof **minefield); // Reconstruct the minefield. Asterisks represent mines. for(size_t y = 0; y < m; ++y) for(size_t x = 0; x < n; ++x) { assert(*line == '.' || *line == '*'); minefield[y][x] = (*line++ == '*'); } // Reuse the input buffer for output. line = lineBuffer; line[m * n] = '\0'; for(size_t y = 0; y < m; ++y) for(size_t x = 0; x < n; ++x, ++line) { // Mines get dumped verbatim. if(minefield[y][x]) *line = '*'; // Empty cells display the total number of mines in all eight of // their adjacent fields. else { #define IS_MINE(xOffset, yOffset) \ (((!x && (xOffset) < 0) || (x + (xOffset) >= n) || \ ( !y && (yOffset) < 0) || (y + (yOffset) >= m)) ? \ (0) : (minefield[y + (yOffset)][x + (xOffset)])) /* Possible neighbor position offsets. <A> -1 + + + <B> 0 + @ + <C> 1 + + + -1 0 1 */ const unsigned adjacentMineCount = IS_MINE(-1, -1) + IS_MINE(0, -1) + IS_MINE(+1, -1) + // <A> IS_MINE(-1, 0) + (000000000000) + IS_MINE(+1, 0) + // <B> IS_MINE(-1, +1) + IS_MINE(0, +1) + IS_MINE(+1, +1); // <C> *line = adjacentMineCount + '0'; #undef IS_MINE } } puts(lineBuffer); } // The CRT takes care of cleanup. }
the_stack_data/125140711.c
/*translation of the well-known f477.f to C actually this source is folklore d.ineiev<[email protected]> wrote down and put under zlib/libpng license (see README.txt)*/ /* this program is designed for the calculation of a geoid undulation at a point whose latitude and longitude is specified. the program is designed to use the potential coefficient model egm96 and a set of spherical harmonic coefficients of a correction term. the correction term is composed of several different components the primary one being the conversion of a height anomaly to a geoid undulation. the principles of this procedure were initially described in the paper: use of potential coefficient models for geoid undulation determination using a spherical harmonic representation of the height anomaly/geoid undulation difference by R.H. Rapp, Journal of Geodesy, 1996. this program is designed to be used with the constants of egm96 and those of the wgs84(g873) system. the undulation will refer to the wgs84 ellipsoid. specific details on the undulation computation will be found in the joint project report describing the development of egm96. this program is a modification of the program described in the following report: a fortran program for the computation of gravimetric quantities from high degree spherical harmonic expansions, Richard H. Rapp, report 334, Department of Geodetic Science and Surveying, the Ohio State University, Columbus, 1982 this program was put in this form in Dec 1996. rhrapp.f477.nonly ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc the input files consist of: correction coefficient set ("CORRCOEF") => unit = 1 potential coefficient set ("EGM96") => unit = 12 points at which to compute ("INPUT.dat") => unit = 14 the output file is: computed geoid heights ("OUTF477") => unit = 20 file assignment revisions at NIMA, December 1996. ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc dimensions of p,q,hc,hs must be at least ((maxn+1)*(maxn+2))/2, dimensions of sinml,cosml must be at least maxn, where maxn is maximum order of computation the current dimensions are set for a maximum degree of 360*/ #include<stdio.h> #include<math.h> static FILE*f_1,*f_14,*f_12,*f_20; #define l_value (65341) #define _361 (361) double hundu(unsigned nmax,double p[l_value+1], double hc[l_value+1],double hs[l_value+1], double sinml[_361+1],double cosml[_361+1],double gr,double re, double cc[l_value+1],double cs[l_value+1]) {/*constants for wgs84(g873);gm in units of m**3/s**2*/ const double gm=.3986004418e15,ae=6378137.; double arn,ar,ac,a,b,sum,sumc,sum2,tempc,temp;int k,n,m; ar=ae/re;arn=ar;ac=a=b=0;k=3; for(n=2;n<=nmax;n++) {arn*=ar;k++;sum=p[k]*hc[k];sumc=p[k]*cc[k];sum2=0; for(m=1;m<=n;m++) {k++;tempc=cc[k]*cosml[m]+cs[k]*sinml[m]; temp=hc[k]*cosml[m]+hs[k]*sinml[m];sumc+=p[k]*tempc;sum+=p[k]*temp; }ac+=sumc;a+=sum*arn; }ac+=cc[1]+p[2]*cc[2]+p[3]*(cc[3]*cosml[1]+cs[3]*sinml[1]); /*add haco=ac/100 to convert height anomaly on the ellipsoid to the undulation add -0.53m to make undulation refer to the wgs84 ellipsoid.*/ return a*gm/(gr*re)+ac/100-.53; } void dscml(double rlon,unsigned nmax,double sinml[_361+1],double cosml[_361+1]) {double a,b;int m;a=sin(rlon);b=cos(rlon); sinml[1]=a;cosml[1]=b;sinml[2]=2*b*a;cosml[2]=2*b*b-1; for(m=3;m<=nmax;m++) {sinml[m]=2*b*sinml[m-1]-sinml[m-2];cosml[m]=2*b*cosml[m-1]-cosml[m-2];} } void dhcsin(unsigned nmax,double hc[l_value+1],double hs[l_value+1]) {int n,m;double j2,j4,j6,j8,j10,c,s,ec,es; /*the even degree zonal coefficients given below were computed for the wgs84(g873) system of constants and are identical to those values used in the NIMA gridding procedure. computed using subroutine grs written by N.K. PAVLIS*/ j2=0.108262982131e-2;j4=-.237091120053e-05;j6=0.608346498882e-8; j8=-0.142681087920e-10;j10=0.121439275882e-13;m=((nmax+1)*(nmax+2))/2; for(n=1;n<=m;n++)hc[n]=hs[n]=0; while(6==fscanf(f_12,"%i %i %lf %lf %lf %lf",&n,&m,&c,&s,&ec,&es)) {if(n>nmax)continue;n=(n*(n+1))/2+m+1;hc[n]=c;hs[n]=s;} hc[4]+=j2/sqrt(5);hc[11]+=j4/3;hc[22]+=j6/sqrt(13);hc[37]+=j8/sqrt(17); hc[56]+=j10/sqrt(21); } void legfdn(unsigned m,double theta,double rleg[_361+1],unsigned nmx) /*this subroutine computes all normalized legendre function in "rleg". order is always m, and colatitude is always theta (radians). maximum deg is nmx. all calculations in double precision. ir must be set to zero before the first call to this sub. the dimensions of arrays rleg must be at least equal to nmx+1. Original programmer :Oscar L. Colombo, Dept. of Geodetic Science the Ohio State University, August 1980 ineiev: I removed the derivatives, for they are never computed here*/ {static double drts[1301],dirt[1301],cothet,sithet,rlnn[_361+1]; static int ir;int nmx1=nmx+1,nmx2p=2*nmx+1,m1=m+1,m2=m+2,m3=m+3,n,n1,n2; if(!ir){ir=1;for(n=1;n<=nmx2p;n++){drts[n]=sqrt(n);dirt[n]=1/drts[n];}} cothet=cos(theta);sithet=sin(theta); /*compute the legendre functions*/ rlnn[1]=1;rlnn[2]=sithet*drts[3]; for(n1=3;n1<=m1;n1++) {n=n1-1;n2=2*n;rlnn[n1]=drts[n2+1]*dirt[n2]*sithet*rlnn[n];} switch(m) {case 1:rleg[2]=rlnn[2];rleg[3]=drts[5]*cothet*rleg[2];break; case 0:rleg[1]=1;rleg[2]=cothet*drts[3];break; }rleg[m1]=rlnn[m1]; if(m2<=nmx1) {rleg[m2]=drts[m1*2+1]*cothet*rleg[m1]; if(m3<=nmx1)for(n1=m3;n1<=nmx1;n1++) {n=n1-1;if((!m&&n<2)||(m==1&&n<3))continue; n2=2*n;rleg[n1]=drts[n2+1]*dirt[n+m]*dirt[n-m]* (drts[n2-1]*cothet*rleg[n1-1]-drts[n+m-1]*drts[n-m-1]*dirt[n2-3]*rleg[n1-2]); } } } void radgra(double lat,double lon,double*rlat,double*gr,double*re) /*this subroutine computes geocentric distance to the point, the geocentric latitude,and an approximate value of normal gravity at the point based the constants of the wgs84(g873) system are used*/ {const double a=6378137.,e2=.00669437999013,geqt=9.7803253359,k=.00193185265246; double n,t1=sin(lat)*sin(lat),t2,x,y,z; n=a/sqrt(1-e2*t1);t2=n*cos(lat);x=t2*cos(lon);y=t2*sin(lon); z=(n*(1-e2))*sin(lat); *re=sqrt(x*x+y*y+z*z);/*compute the geocentric radius*/ *rlat=atan(z/sqrt(x*x+y*y));/*compute the geocentric latitude*/ *gr=geqt*(1+k*t1)/sqrt(1-e2*t1);/*compute normal gravity:units are m/sec**2*/ } static double cc[l_value+1],cs[l_value+1],hc[l_value+1],hs[l_value+1], p[l_value+1],sinml[_361+1],cosml[_361+1],rleg[_361+1]; static int nmax; double undulation(double lat,double lon,int nmax,int k) {double rlat,gr,re;int i,j,m; radgra(lat,lon,&rlat,&gr,&re);rlat=M_PI/2-rlat; for(j=1;j<=k;j++) {m=j-1;legfdn(m,rlat,rleg,nmax);for(i=j;i<=k;i++)p[(i-1)*i/2+m+1]=rleg[i];} dscml(lon,nmax,sinml,cosml);return hundu(nmax,p,hc,hs,sinml,cosml,gr,re,cc,cs); } void init_arrays(char* corrcoef_filename, char* egm96_filename) {int ig,i,n,m;double t1,t2; f_1=fopen(corrcoef_filename,"rb");/*correction coefficient file: modified with 'sed -e"s/D/e/g"' to be read with fscanf*/ f_12=fopen(egm96_filename,"rb");/*potential coefficient file*/ nmax=360;for(i=1;i<=l_value;i++)cc[i]=cs[i]=0; while(4==fscanf(f_1,"%i %i %lg %lg",&n,&m,&t1,&t2)) {ig=(n*(n+1))/2+m+1;cc[ig]=t1;cs[ig]=t2;} /*the correction coefficients are now read in*/ /*the potential coefficients are now read in and the reference even degree zonal harmonic coefficients removed to degree 6*/ dhcsin(nmax,hc,hs);fclose(f_1);fclose(f_12); }
the_stack_data/1446.c
/* * Copyright (c) 2021-2022 Nordic Semiconductor ASA * * SPDX-License-Identifier: Apache-2.0 */ #if defined(CONFIG_BT_AUDIO_UNICAST_CLIENT) #include <bluetooth/bluetooth.h> #include <bluetooth/audio/audio.h> #include <bluetooth/audio/capabilities.h> #include "common.h" #include "unicast_common.h" extern enum bst_result_t bst_result; static struct bt_audio_stream g_streams[CONFIG_BT_AUDIO_UNICAST_CLIENT_ASE_SNK_COUNT]; static struct bt_codec *g_remote_codecs[CONFIG_BT_AUDIO_UNICAST_CLIENT_PAC_COUNT]; static struct bt_audio_ep *g_sinks[CONFIG_BT_AUDIO_UNICAST_CLIENT_ASE_SNK_COUNT]; /* Mandatory support preset by both client and server */ static struct bt_audio_lc3_preset preset_16_2_1 = BT_AUDIO_LC3_UNICAST_PRESET_16_2_1; CREATE_FLAG(flag_connected); CREATE_FLAG(flag_mtu_exchanged); CREATE_FLAG(flag_sink_discovered); CREATE_FLAG(flag_stream_configured); CREATE_FLAG(flag_stream_qos); CREATE_FLAG(flag_stream_enabled); CREATE_FLAG(flag_stream_released); static void stream_configured(struct bt_audio_stream *stream, const struct bt_codec_qos_pref *pref) { printk("Configured stream %p\n", stream); /* TODO: The preference should be used/taken into account when * setting the QoS */ SET_FLAG(flag_stream_configured); } static void stream_qos_set(struct bt_audio_stream *stream) { printk("QoS set stream %p\n", stream); SET_FLAG(flag_stream_qos); } static void stream_enabled(struct bt_audio_stream *stream) { printk("Enabled stream %p\n", stream); SET_FLAG(flag_stream_enabled); } static void stream_started(struct bt_audio_stream *stream) { printk("Started stream %p\n", stream); } static void stream_metadata_updated(struct bt_audio_stream *stream) { printk("Metadata updated stream %p\n", stream); } static void stream_disabled(struct bt_audio_stream *stream) { printk("Disabled stream %p\n", stream); } static void stream_stopped(struct bt_audio_stream *stream) { printk("Stopped stream %p\n", stream); } static void stream_released(struct bt_audio_stream *stream) { printk("Released stream %p\n", stream); SET_FLAG(flag_stream_released); } static struct bt_audio_stream_ops stream_ops = { .configured = stream_configured, .qos_set = stream_qos_set, .enabled = stream_enabled, .started = stream_started, .metadata_updated = stream_metadata_updated, .disabled = stream_disabled, .stopped = stream_stopped, .released = stream_released, }; static void add_remote_sink(struct bt_audio_ep *ep, uint8_t index) { printk("Sink #%u: ep %p\n", index, ep); g_sinks[index] = ep; } static void add_remote_codec(struct bt_codec *codec, int index, uint8_t type) { printk("#%u: codec %p type 0x%02x\n", index, codec, type); print_codec(codec); if (type != BT_AUDIO_SINK && type != BT_AUDIO_SOURCE) { return; } if (index < CONFIG_BT_AUDIO_UNICAST_CLIENT_PAC_COUNT) { g_remote_codecs[index] = codec; } } static void discover_sink_cb(struct bt_conn *conn, struct bt_codec *codec, struct bt_audio_ep *ep, struct bt_audio_discover_params *params) { static bool codec_found; static bool endpoint_found; if (params->err != 0) { FAIL("Discovery failed: %d\n", params->err); return; } if (codec != NULL) { add_remote_codec(codec, params->num_caps, params->type); codec_found = true; return; } if (ep != NULL) { if (params->type == BT_AUDIO_SINK) { add_remote_sink(ep, params->num_eps); endpoint_found = true; } else { FAIL("Invalid param type: %u\n", params->type); } return; } printk("Discover complete\n"); (void)memset(params, 0, sizeof(*params)); if (endpoint_found && codec_found) { SET_FLAG(flag_sink_discovered); } else { FAIL("Did not discover endpoint and codec\n"); } } static void connected(struct bt_conn *conn, uint8_t err) { char addr[BT_ADDR_LE_STR_LEN]; (void)bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr)); if (err != 0) { bt_conn_unref(default_conn); default_conn = NULL; FAIL("Failed to connect to %s (%u)\n", addr, err); return; } printk("Connected to %s\n", addr); SET_FLAG(flag_connected); } BT_CONN_CB_DEFINE(conn_callbacks) = { .connected = connected, .disconnected = disconnected, }; static void att_mtu_updated(struct bt_conn *conn, uint16_t tx, uint16_t rx) { printk("MTU exchanged\n"); SET_FLAG(flag_mtu_exchanged); } static struct bt_gatt_cb gatt_callbacks = { .att_mtu_updated = att_mtu_updated, }; static void init(void) { int err; err = bt_enable(NULL); if (err != 0) { FAIL("Bluetooth enable failed (err %d)\n", err); return; } for (size_t i = 0; i < ARRAY_SIZE(g_streams); i++) { g_streams[i].ops = &stream_ops; } bt_gatt_cb_register(&gatt_callbacks); } static void scan_and_connect(void) { int err; err = bt_le_scan_start(BT_LE_SCAN_PASSIVE, device_found); if (err != 0) { FAIL("Scanning failed to start (err %d)\n", err); return; } printk("Scanning successfully started\n"); WAIT_FOR_FLAG(flag_connected); } static void exchange_mtu(void) { WAIT_FOR_FLAG(flag_mtu_exchanged); } static void discover_sink(void) { static struct bt_audio_discover_params params; int err; params.func = discover_sink_cb; params.type = BT_AUDIO_SINK; err = bt_audio_discover(default_conn, &params); if (err != 0) { printk("Failed to discover sink: %d\n", err); return; } WAIT_FOR_FLAG(flag_sink_discovered); } static int configure_stream(struct bt_audio_stream *stream, struct bt_audio_ep *ep) { int err; UNSET_FLAG(flag_stream_configured); err = bt_audio_stream_config(default_conn, stream, ep, &preset_16_2_1.codec); if (err != 0) { FAIL("Could not configure stream: %d\n", err); return err; } WAIT_FOR_FLAG(flag_stream_configured); return 0; } static size_t configure_streams(void) { size_t stream_cnt; for (stream_cnt = 0; stream_cnt < ARRAY_SIZE(g_sinks); stream_cnt++) { int err; if (g_sinks[stream_cnt] == NULL) { break; } err = configure_stream(&g_streams[stream_cnt], g_sinks[stream_cnt]); if (err != 0) { FAIL("Unable to configure stream[%zu]: %d", stream_cnt, err); return 0; } } return stream_cnt; } static size_t release_streams(size_t stream_cnt) { for (size_t i = 0; i < stream_cnt; i++) { int err; if (g_sinks[i] == NULL) { break; } UNSET_FLAG(flag_stream_released); err = bt_audio_stream_release(&g_streams[i], false); if (err != 0) { FAIL("Unable to release stream[%zu]: %d", i, err); return 0; } WAIT_FOR_FLAG(flag_stream_released); } return stream_cnt; } static void create_unicast_group(struct bt_audio_unicast_group **unicast_group, size_t stream_cnt) { int err; err = bt_audio_unicast_group_create(g_streams, 1, unicast_group); if (err != 0) { FAIL("Unable to create unicast group: %d", err); return; } /* Test removing streams from group before adding them */ if (stream_cnt > 1) { err = bt_audio_unicast_group_remove_streams(*unicast_group, g_streams + 1, stream_cnt - 1); if (err == 0) { FAIL("Able to remove stream not in group"); return; } /* Test adding streams to group after creation */ err = bt_audio_unicast_group_add_streams(*unicast_group, g_streams + 1, stream_cnt - 1); if (err != 0) { FAIL("Unable to add streams to unicast group: %d", err); return; } } } static void delete_unicast_group(struct bt_audio_unicast_group *unicast_group, size_t stream_cnt) { int err; if (stream_cnt > 1) { err = bt_audio_unicast_group_remove_streams(unicast_group, g_streams + 1, stream_cnt - 1); if (err != 0) { FAIL("Unable to remove streams from unicast group: %d", err); return; } } err = bt_audio_unicast_group_delete(unicast_group); if (err != 0) { FAIL("Unable to delete unicast group: %d", err); return; } } static void test_main(void) { const unsigned int iterations = 3; struct bt_audio_unicast_group *unicast_group; size_t stream_cnt; init(); scan_and_connect(); exchange_mtu(); discover_sink(); /* Run the stream setup multiple time to ensure states are properly * set and reset */ for (unsigned int i = 0U; i < iterations; i++) { printk("\n########### Running iteration #%u\n\n", i); printk("Configuring streams\n"); stream_cnt = configure_streams(); printk("Creating unicast group\n"); create_unicast_group(&unicast_group, stream_cnt); /* TODO: When babblesim supports ISO setup Audio streams */ release_streams(stream_cnt); /* Test removing streams from group after creation */ printk("Deleting unicast group\n"); delete_unicast_group(unicast_group, stream_cnt); unicast_group = NULL; } PASS("Unicast client passed\n"); } static const struct bst_test_instance test_unicast_client[] = { { .test_id = "unicast_client", .test_post_init_f = test_init, .test_tick_f = test_tick, .test_main_f = test_main }, BSTEST_END_MARKER }; struct bst_test_list *test_unicast_client_install(struct bst_test_list *tests) { return bst_add_tests(tests, test_unicast_client); } #else /* !(CONFIG_BT_AUDIO_UNICAST_CLIENT) */ struct bst_test_list *test_unicast_client_install(struct bst_test_list *tests) { return tests; } #endif /* CONFIG_BT_AUDIO_UNICAST_CLIENT */
the_stack_data/59541.c
int j;
the_stack_data/18887186.c
/* 12-3. 포인터는 영희이다! (포인터) - 포인터의 포인터 */ // 포인터의 포인터 #include <stdio.h> int main() { int a; int *pa; int **ppa; // int를 가리키는 포인터를 가리키는 포인터 pa = &a; ppa = &pa; a = 3; printf("a : %d // *pa : %d // **ppa : %d \n", a, *pa, **ppa); printf("&a : %p // pa : %p // *ppa : %p \n", &a, pa, *ppa); printf("&pa : %p // ppa : %p \n", &pa, ppa); return 0; }
the_stack_data/54826019.c
#include <stdio.h> #include <stdlib.h> int main() { int a[99][99]; int i, j, m, n, sum; sum = 0; printf("Enter size for rows and columns\n"); scanf("%d %d", &m, &n); printf("Enter Matrix Elements of %d x %d\n", m, n); for (i = 0; i < m; i++) { for (j = 0; j < n; j++) { scanf("%d", &a[i][j]); } } printf("Elements of Matrix \n"); for (i = 0; i < m; i++) { for (j = 0; j < n; j++) { printf("%d\t", a[i][j]); } printf("\n"); } for (i = 0; i < m; i++) { for (j = 0; j < n; j++) { sum += a[i][j]; } } printf("Sum of Matrix Elements is %d\n", sum); return 0; }
the_stack_data/150378.c
// RUN: %clang_cc1 -triple sparc-unknown-unknown -emit-llvm %s -o - | FileCheck %s // CHECK-LABEL: define{{.*}} { float, float } @p({ float, float }* byval({ float, float }) align 4 %a, { float, float }* byval({ float, float }) align 4 %b) #0 { float __complex__ p (float __complex__ a, float __complex__ b) { } // CHECK-LABEL: define{{.*}} { double, double } @q({ double, double }* byval({ double, double }) align 8 %a, { double, double }* byval({ double, double }) align 8 %b) #0 { double __complex__ q (double __complex__ a, double __complex__ b) { } // CHECK-LABEL: define{{.*}} { i64, i64 } @r({ i64, i64 }* byval({ i64, i64 }) align 8 %a, { i64, i64 }* byval({ i64, i64 }) align 8 %b) #0 { long long __complex__ r (long long __complex__ a, long long __complex__ b) { }
the_stack_data/125141499.c
//in binary search tree node deletion operation. #include<stdio.h> #include<stdlib.h> struct treeNode{ int value; struct treeNode *left; struct treeNode *right; }; void insert_val(struct treeNode ** root,int val){ struct treeNode * newNode,*temp; temp = (*root); newNode = (struct treeNode*)malloc(sizeof(struct treeNode)); if(newNode == NULL) printf("Error in malloc creation"); newNode->value = val; newNode->left = NULL; newNode->right = NULL; if((*root) == NULL){ (*root) = newNode; return; } while(1){ if(val < temp->value){ if(temp->left == NULL){ temp->left = newNode; break; } temp = temp->left; } else{ if(temp->right == NULL){ temp->right = newNode; break; } temp = temp->right; } } } struct treeNode* findMin(struct treeNode* r){ //follow left branch while(r->left != NULL) r = r->left; return r; } /* struct treeNode* findMax(struct treeNode* r){ //follow right branch while(r->right != NULL) r = r->right; return r; } */ struct treeNode * delete_val(struct treeNode * r,int val){ struct treeNode * temp; if(r == NULL) return r; if(val < r->value) r->left = delete_val(r->left,val); else if(val > r->value) r->right = delete_val(r->right,val); else{ //root->value == val // if(r->left == NULL && r->right == NULL){ free(r); return NULL; } if(r->left == NULL){ temp = r->right; free(r); return temp; } if(r->right == NULL){ temp = r->left; free(r); return temp; } //Root has two children// temp = findMin(r->right); //we can also use findMax(r->left); r->value = temp->value; r->right = delete_val(r->right,temp->value); } return r; } void inorder(struct treeNode * r){ if(r != NULL){ inorder(r->left); printf("%d ",r->value); inorder(r->right); } } void main(){ int n,val; struct treeNode * root = NULL; printf("Enter 1 for Insert value\n"); printf("Enter 2 for Delete value\n"); printf("Enter 3 for inorder traversal\n"); printf("Enter 4 for EXIT\n"); scanf("%d",&n); while(n!=4){ switch(n){ case 1: printf("Enter value you want to insert: \n"); scanf("%d",&val); insert_val(&root,val); break; case 2: printf("Enter value you want to delete\n"); scanf("%d",&val); root = delete_val(root,val); break; case 3: inorder(root); break; default: printf("Enter proper value\n"); } printf("\nEnter 1/2/3/4\n"); scanf("%d",&n); } }
the_stack_data/16845.c
#include <stdio.h> int main() { for (int i = 5; i >= 1; i--) { for (int j = 1; j <= (5 - i); j++) { printf("*"); } for (int j = i; j >= 1; j--) { printf("%c", j + 64); } printf("\n"); } return 0; }
the_stack_data/154831017.c
/* { dg-do compile } */ /* { dg-options "-Wimplicit-fallthrough=0" } */ void bar (int); void foo (int i) { switch (i) { case 1: /* { dg-bogus "this statement may \[fla\]* through" "" { target *-*-* } .+1 } */ bar (1); case 2: /* { dg-bogus "this statement may \[fla\]* through" "" { target *-*-* } .+1 } */ bar (2); /* Some comment. */ case 3: /* { dg-bogus "this statement may \[fla\]* through" "" { target *-*-* } .+1 } */ bar (3); /* Here we really do want to fALl tHRoUgh and we mean it! */ case 4: /* { dg-bogus "this statement may \[fla\]* through" "" { target *-*-* } .+1 } */ bar (4); /* Intentionally fall through. */ case 5: /* { dg-bogus "this statement may \[fla\]* through" "" { target *-*-* } .+1 } */ bar (5); /* FALLTHROUGH */ case 6: /* { dg-bogus "this statement may \[fla\]* through" "" { target *-*-* } .+1 } */ bar (6); __attribute__((fallthrough)); case 7: /* { dg-bogus "this statement may \[fla\]* through" "" { target *-*-* } .+1 } */ bar (7); default: break; } }
the_stack_data/122014587.c
//1179 - Preenchimento de Vetor IV #include <stdio.h> int main(){ int par[5] = {0}, impar[5] = {0}, i = 0,cP = 0, cI = 0, num; int p = 0; for(i = 0; i < 15; i++){ scanf("%d", &num); if(num % 2 == 0){ // par if(cP == 5){ // se lista ta cheia for(p = 0; p < 5; p++){ printf("par[%d] = %d\n", p, par[p]); } cP = 0; } else{ par[cP] = num; cP++; } } else{ // impar if(cI == 5){ // se lista ta cheia for(p = 0; p < 5; p++){ printf("impar[%d] = %d\n", p, impar[p]); } cI = 0; } else{ impar[cI] = num; cI++; } } } for(p = 0; p < 5; p++){ printf("impar[%d] = %d\n", p, impar[p]); } for(p = 0; p < 5; p++){ printf("par[%d] = %d\n", p, par[p]); } return 0; }
the_stack_data/127876.c
#define _XOPEN_SOURCE #define _GNU_SOURCE #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> #include <sys/stat.h> #include <time.h> #include <unistd.h> #include <wait.h> volatile bool running = true; int child_PID = -1; void react_to_SIGINT (int signal_number) { printf ("\nReceived termination signal.\n"); exit(0); } void react_to_SIGTSTP (int signal_number) { if (running) { printf ("\nWaiting for CTRL+Z (continuation) or CTRL+C (termination).\n"); running = !running; } else { printf("\n"); running = !running; } } void react_to_SIGINT_child (int signal_number) { kill (child_PID, SIGKILL); printf ("\nReceived termination signal.\n"); exit(0); } void react_to_SIGTSTP_child (int signal_number) { if (running) { printf ("\nWaiting for CTRL+Z (continuation) or CTRL+C (termination).\n"); running = !running; kill (child_PID, SIGKILL); child_PID = -1; } else running = !running; } int print_date_with_shell (char *shell_script) { int status = execlp ("bash", "bash", shell_script, NULL); if (status == -1) return 1; else return 0; } int main (int argc, char **argv) { if (argc == 1) { signal (SIGTSTP, react_to_SIGTSTP); struct sigaction act; act.sa_handler = react_to_SIGINT; sigemptyset (&act.sa_mask); act.sa_flags = 0; sigaction (SIGINT, &act, NULL); while (true) { if (running) { time_t current_time; time (&current_time); char time_buffer[32]; strftime (time_buffer, 32, "_%Y-%m-%d_%H-%M-%S", localtime (&current_time)); printf ("%s\n", time_buffer); sleep (1); } else pause (); } } else if (argc == 2) { signal (SIGTSTP, react_to_SIGTSTP); struct sigaction act; act.sa_handler = react_to_SIGINT; sigemptyset (&act.sa_mask); act.sa_flags = 0; sigaction (SIGINT, &act, NULL); while (true) { if (running) { if (child_PID == -1) { int print_result = print_date_with_shell (argv[1]); if (print_result == 1) { perror ("Error: could not use shell script!"); exit (1); } } } else { pause (); } } } else { perror ("Error: wrong number of arguments!"); exit (1); } return 0; }
the_stack_data/80585.c
#include<stdio.h> void main(){ int ar[10][10],r,c,i,j,row,column; int newarr[10][10]; int finalarray[10][10]; int temp; int t; printf("Enter the rows of the array"); scanf("%d",&r); printf("Enter the column of the array"); scanf("%d",&c); printf("Enter the array elements"); for(i=0;i<r;i++){ for(j=0;j<c;j++){ scanf("%d",&ar[i][j]); } printf("\n"); } printf("Original array is:\n"); for(i=0;i<r;i++){ for(j=0;j<c;j++){ printf("%d \t",ar[i][j]); } printf("\n"); } //Transposeof the matrix for(i=0;i<r;i++){ for(j=0;j<c;j++){ if(j>c-1){ newarr[j+1][i]=ar[i][j+1]; } else newarr[j][i]=ar[i][j]; } } t=r; r=c; c=t; for(i=0;i<r;i++){ temp=c-1; for(j=0;j<c;j++){ finalarray[i][j]=newarr[i][temp]; temp--; } } printf("Rotated array is: \n"); for(i=0;i<r;i++){ for(j=0;j<c;j++){ printf("%d \t",finalarray[i][j]); } printf("\n"); } }
the_stack_data/162641876.c
#include <stdio.h> #include <stdlib.h> int main() { FILE *f1 = fopen("/tmp/f1.txt", "a+"); FILE *f2 = fopen("/tmp/f2.txt", "a+"); FILE *f3 = fopen("/tmp/f3.txt", "a+"); fclose(f2); getchar(); fprintf(f1, "%s", "foo"); char *c = malloc(2); fread(c, 1, 1, f3); return 0; }
the_stack_data/126702360.c
#include <stdio.h> int main() { printf("Mockup mex\n"); return 0; }
the_stack_data/47785.c
void proc(long x1, long *x2p, int x3, int *x4p, short x5, short *x6p, char x7, char *x8p) { *x2p += x1; *x4p += x3; *x6p += x5; *x8p += x7; } long call_proc() { long x1 = 1; int x2 = 2; short x3 = 3; char x4 = 4; proc(x1, &x1, x2, &x2, x3, &x3, x4, &x4); return (x1 + x2) * (x3 - x4); }
the_stack_data/92325814.c
#include <stdio.h> int a[1001][1001]; int main(void) { int vertex = 5; int edge = 3; int vertexAry[3] = { 1, 3, 4 }; int edgeAry[3] = { 2, 4, 5 }; for (int i = 0; i < edge; i++) { int x = vertexAry[i]; int y = edgeAry[i]; a[x][y] = 1; a[y][x] = 1; } for (int i = 1; i <= vertex; i++) { for (int j = 1; j <= vertex; j++) { printf("%d", a[i][j]); } printf("\n"); } return 0; }
the_stack_data/9514131.c
#include <stdlib.h> extern int foo(int n); int bar; int main(int argc, char *argv[]) { int n; bar = argc; while (argc-- > 1) { n = atoi(argv[argc]); foo(n); } return bar; }
the_stack_data/73574405.c
/* ------------------------------------------------------------------------------------ Tutorial: float is a datatype which is used to represent the floating point numbers. It has 6 decimal digits of precision. For example, 10.327, -3.14, 11.234. ------------------------------------------------------------------------------------ */ #include <stdio.h> #include <string.h> int main() { float x = 50.621; int y = 40; printf("The float value : %f\n", x); printf("The sum of float and int variable : %f\n", (x + y)); return 0; } /* ------------------------------------------------------------------------------------ Challenge: Make a program that reads a salesperson's name, his fixed salary and the total sales made by him in the month (in cash). Knowing that this seller earns 15% commission on his sales made, inform the total receivable at the end of the month, with two decimal places. ------------------------------------------------------------------------------------ */
the_stack_data/365777.c
#include<stdio.h> int k(int,int); int main() { int n,m; scanf("%d%d",&m,&n); printf("%d",k(m,n)); return 0; } int k(int m,int n) { if(n==1) return m; if(m==n) return 1; return k(m-1,n-1)+k(m-1,n); }
the_stack_data/37638045.c
#include <time.h> double gettime(void) { struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); return ts.tv_sec + ts.tv_nsec * 1e-9; }
the_stack_data/125525.c
#include <stdlib.h> typedef struct kvnode { int key; int value; struct kvnode* next; } KVMAP; /*@ pred KVMap(+o, kvs, keys) { (o == NULL) * (kvs == -{ }-) * (keys == -{ }-); (o -m> struct kvnode { int(#k); int(#v); #next }) * (not (#next == NULL)) * (kvs == -u- (-{ [ #k, #v ] }-, #rkvs)) * (keys == -u- (-{ #k }-, #rkeys)) * (not (#k --e-- #rkeys)) * (not ([#k, #v] --e-- #rkvs)) * (forall #kp : Num, #vp : Num. [#kp, #vp] --e-- #rkvs => (not (#kp == #k))) * KVMap(#next, #rkvs, #rkeys); (o -m> struct kvnode { int(#k); int(#v); NULL }) * (kvs == -{ [ #k, #v ] }-) * (keys == -{ #k }-) } */ /*@ spec makeNode(k, v) { requires: (k == int(#k)) * (v == int(#v)) ensures: KVMap(ret, -{ [ #k, #v ] }-, -{ #k }-) } */ KVMAP* makeNode(int k, int v) { KVMAP* new_node = malloc(sizeof(KVMAP)); new_node->key = k; new_node->value = v; new_node->next = NULL; return new_node; } /*@ spec put(k, v, kvm) { requires: (kvm == #kvm) * (k == int(#k)) * (v == int(#v)) * KVMap(#kvm, #kvs, #keys) * (not (#k --e-- #keys)) ensures: KVMap(ret, -u- (-{ [#k, #v] }-, #kvs), -u-(-{ #k }-, #keys)) } */ /* // For some reason, the following doesn't really work ? OR [key_exists: #w : Num, #rkvs : Set] requires: (kvm == #kvm) * (k == int(#k)) * (v == int(#v)) * KVMap(#kvm, #kvs, #keys) * (#k --e-- #keys) * (#kvs == -u-(-{ [#k, #w] }-, #rkvs)) ensures: KVMap(ret, -u- (-{ [#k, #v] }-, #rkvs), #keys) } */ KVMAP* put(int k, int v, KVMAP* kvm) { if (kvm == NULL) { return makeNode(k, v); } else if (kvm->key == k) { kvm->value = v; return kvm; } else { __builtin_annot("assert [[exists #next]] #kvm -m> struct kvnode { #somekey; #somevalue; #next }"); __builtin_annot("if (! (#next = NULL)) { unfold KVMap(#next, #nextkvs, #nextkeys) }"); KVMAP* rec = put(k, v, kvm->next); __builtin_annot("unfold KVMap(rec, #reckvs, #reckeys)"); kvm->next = rec; return kvm; } } /*@ spec get(k, kvm) { requires: (kvm == #kvm) * (k == int(#k)) * KVMap(#kvm, #kvs, #keys) * (not (#k --e-- #keys)) ensures: KVMap(#kvm, #kvs, #keys) * (ret == NULL) OR [key_exists: #v : Num] requires: (kvm == #kvm) * (k == int(#k)) * KVMap(#kvm, #kvs, #keys) * (#k --e-- #keys) * ([#k, #v] --e-- #kvs) ensures: KVMap(#kvm, #kvs, #keys) * (ret -m> int(#v)) } */ int* get (int k, KVMAP* kvm) { if (kvm == NULL) { return NULL; } else if (kvm->key == k) { int* r = malloc(sizeof(int)); *r = kvm->value; return r; } else { return get(k, kvm->next); } }
the_stack_data/51700191.c
#include <stddef.h> #include <grp.h> extern int _getpw(int *, char **, char **); extern char **_grpmems(char *); static struct group holdgroup; struct group * getgrgid(gid_t gid) { int num; char *nam, *mem; num = gid; nam = 0; mem = 0; if(_getpw(&num, &nam, &mem)){ holdgroup.gr_name = nam; holdgroup.gr_gid = num; holdgroup.gr_mem = _grpmems(mem); return &holdgroup; } return NULL; }