file
stringlengths 18
26
| data
stringlengths 3
1.04M
|
---|---|
the_stack_data/184519374.c
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#define false 0
#define true 1
typedef uint8_t BYTE;
typedef uint16_t WORD;
typedef uint32_t DWORD;
int hlpFileVersion; // for future use: version
int hlpLanguage; // language for help file
char hlpFileCompressed[2]; // help file is compressed?
int topic_count ; // # of topic's
int topic_number ; // #num index of topic size
int topic_index ; // index of topic
int topic_size ; // name of topic
char topic_text[1024]; // content of topic
int main(int argc, char **argv)
{
int res = 0;
int len = 0;
int chr = 0;
int pos = 0;
hlpFileCompressed[0] = 'n';
hlpFileCompressed[1] = 0x0;
// open source file in read-mode ...
FILE *src = fopen("help.txt","r");
if (!src) {
fprintf(stderr,"help.txt can't be opened.\n");
fflush (stderr);
return 1;
}
// temp file for index names storage ...
FILE *tmp1 = fopen("tmp1.dat","wb");
if (!tmp1) {
fprintf(stderr,"tmp1.dat can't be openend.\n");
fflush (stderr);
fclose(src);
return 1;
}
// temp file for index names storage ...
FILE *tmp2 = fopen("tmp2.dat","wb");
if (!tmp2) {
fprintf(stderr,"tmp2.dat can't be openend.\n");
fflush (stderr);
fclose(tmp1);
fclose(src );
return 1;
}
// help header content ...
FILE *tmp3 = fopen("tmp3.dat","wb");
if (!tmp3) {
fprintf(stderr,"tmp3.dat can't be openend.\n");
fflush (stderr);
fclose(tmp1);
fclose(tmp2);
fclose(src );
return 1;
}
// help header content index len ...
FILE *tmp4 = fopen("tmp4.dat","wb");
if (!tmp4) {
fprintf(stderr,"tmp4.dat can't be openend.\n");
fflush (stderr);
fclose(tmp1);
fclose(tmp2);
fclose(tmp3);
fclose(src );
return 1;
}
// first line is always the version
res = fscanf(src,"version: 0x%x\n", &hlpFileVersion );
res = fscanf(src,"hlplang: %d\n" , &hlpLanguage );
res = fscanf(src,"packed: %1s\n" , (char*) &hlpFileCompressed);
res = fscanf(src,"topics: %d\n" , &topic_count);
fprintf( stdout, "version: 0x%x\n", hlpFileVersion );
fprintf( stdout, "hlplang: %d\n" , hlpLanguage );
fprintf( stdout, "packed: %1s\n" , (char*) hlpFileCompressed );
fprintf( stdout, "topics: %d\n" , topic_count );
fflush ( stdout );
// header
fwrite( &hlpFileVersion , sizeof(int), 1, tmp2 );
fwrite( &hlpLanguage , sizeof(int), 1, tmp2 );
fwrite( &hlpFileCompressed, 2, 1, tmp2 );
fwrite( &topic_count , sizeof(int), 1, tmp2 );
// header length ...
pos = ((3 * sizeof(int)) + 2);
fwrite( &pos, sizeof(int), 1, tmp2 );
int endmark = 0;
topic_size = 0;
while (1) {
if (++endmark > topic_count)
break;
res = fscanf(src,"[begin 0x%x ", &topic_number);
res = fscanf(src,"%1023s ]\n" , topic_text);
// cut: first & last ...
char *p = topic_text;
p++;
p[strlen(p)-1] = 0x00;
uint8_t po = strlen(p)+ 1;
fwrite(&po,1,1, tmp1 ); // length of string (topic)
fwrite(p, po,1, tmp1 ); // the string itself
len = 0;
// topic content text ...
while (1) {
res = fscanf(src,"%1023s\n", topic_text);
len += strlen(topic_text);
if (topic_text[0] == '['
&& topic_text[1] == 'e'
&& topic_text[2] == 'n'
&& topic_text[3] == 'd'
&& topic_text[4] == ']')
{
len -= 5;
break;
}
fwrite(topic_text,strlen(topic_text),1,tmp3);
} fwrite(&len,sizeof(len),1,tmp4);
}
fclose(src );
fclose(tmp1);
fclose(tmp2);
fclose(tmp3);
fclose(tmp4);
res = system("./merge.sh");
return 0;
}
|
the_stack_data/25138263.c
|
#include <stdio.h>
#include <math.h>
int main() {
int a, b, c;
double x1, x2;
printf("a = ");
scanf("%d", &a);
printf("b = ");
scanf("%d", &b);
printf("c = ");
scanf("%d", &c);
if (a == 0 && b == 0) {
printf("Изродено уравнение");
} else if (a == 0) {
double x = (double)(-c) / b;
printf("x = %lf", x);
} else {
double d = pow(b, 2) - 4 * a * c;
double re = (double)(-b) / (2 * a);
double im = (double)(sqrt(fabs(d))) / (2 * a);
if (d > 0) {
x1 = re + im;
x2 = re - im;
printf("x1 = %lf\n", x1);
printf("x2 = %lf\n", x2);
} else if (d == 0) {
x1 = re;
x2 = re;
printf("x1 = %lf\n", x1);
printf("x2 = %lf\n", x2);
} else {
printf("x1 = %lf + %lf*i\n", re, im);
printf("x2 = %lf - %lf*i\n", re, im);
}
}
return 0;
}
|
the_stack_data/646989.c
|
#include <stdio.h>
#include <math.h>
int main() {
int n;
do {
printf("Unesite broj clanova reda: ");
scanf("%d", &n);
} while(n<1);
int i, j;
double brojilac, imenilac, clan;
double sum = 0;
for(i=0; i<n; i++) {
brojilac = pow(-1, i);
double fakt = 1;
for(j=2; j<=i; j++) {
fakt *= j;
}
imenilac = fakt;
clan = brojilac/imenilac;
printf("clan[i=%d] = % lf\n", i, clan);
sum += clan;
}
printf("\nsum = %lf\n", sum);
double e = 1 / sum;
printf("\ne = %lf\n", e);
return n;
}
|
the_stack_data/82950587.c
|
// RUN: %clang -### -target arm-none-none-eabi -march=armv8a+sb %s 2>&1 | FileCheck %s
// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8a+sb %s 2>&1 | FileCheck %s
// CHECK: "-target-feature" "+sb"
// CHECK-NOT: "-target-feature" "-sb"
// RUN: %clang -### -target arm-none-none-eabi -march=armv8.5a+nosb %s 2>&1 | FileCheck %s --check-prefix=NOSB
// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.5a+nosb %s 2>&1 | FileCheck %s --check-prefix=NOSB
// NOSB: "-target-feature" "-sb"
// NOSB-NOT: "-target-feature" "+sb"
// RUN: %clang -### -target arm-none-none-eabi %s 2>&1 | FileCheck %s --check-prefix=ABSENT
// RUN: %clang -### -target aarch64-none-none-eabi %s 2>&1 | FileCheck %s --check-prefix=ABSENT
// ABSENT-NOT: "-target-feature" "+sb"
// ABSENT-NOT: "-target-feature" "-sb"
|
the_stack_data/835794.c
|
#include<stdio.h>
#include<stdlib.h>
#define rep(i, n) for(i=0;i<n;i++)
int main(void){
int nn, n, m, t, i, c=0;
scanf("%d", &nn);
scanf("%d", &m);
scanf("%d", &t);
n = nn;
rep(i, m){
int a, b;
scanf("%d", &a);
scanf("%d", &b);
//printf("now: %d\n", n);
n -= (a-c);
//printf("arrive: %d\n", n);
if( n<=0 ) break;
else{ n+=(b-a); c=b; }
if( n>nn ) n=nn;
//printf("leave: %d\n", n);
}
n -= (t-c);
//printf("result: %d\n", n);
if( n<=0 ) printf("No\n");
else printf("Yes\n");
return 0;
}
|
the_stack_data/86933.c
|
const char* mt32_pi_ctl_version = "\0$VER: mt32-pi-ctl 1.0.0 (10.02.2021)";
|
the_stack_data/106386.c
|
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <getopt.h>
#include <ctype.h>
#include <string.h>
#include <stdbool.h>
#include <fcntl.h>
const struct option longopts[] = {
{"chdir", no_argument, NULL, 'd'},
{"noclose", no_argument, NULL, 'n'},
{"log-stdout", required_argument, NULL, '1'},
{"log-stderr", required_argument, NULL, '2'},
{0, 0, 0, 0}
};
const char* optstring = "dn1:2:";
void q (char* m) {
fprintf(stderr, "%s\n", m);
exit(1);
}
void qusage () {
q("[daemonize] Usage: daemonize [-d|--chdir] [-n|--noclose] [-1|--log-stdout /path/to/log] [-2|--log-stderr /path/to/log] <command>");
}
void qtoofewargs () {
fprintf(stderr, "[daemonize] Too few arguments.\n");
qusage();
}
void qinvalidarg (char* arg) {
fprintf(stderr, "[daemonize] Unrecognized argument: %s\n", arg);
qusage();
}
char* lowerdup (char* a) {
char* b = strdup(a);
int i;
for (i = 0; b[i] != 0; i++) {
b[i] = tolower(b[i]);
}
return b;
}
struct opts {
int nochdir;
int noclose;
FILE* stdlog;
FILE* errlog;
};
void parseargs(int argc, char** argv, struct opts* savedopts) {
if (argc < 2) qtoofewargs();
int c;
while ((c = getopt_long(argc, argv, optstring, longopts, NULL)) != -1) {
switch (c) {
case 'd':
savedopts->nochdir = false;
break;
case 'n':
savedopts->noclose = true;
break;
case '1':
savedopts->stdlog = fopen(optarg, "a");
if (!savedopts->stdlog) q("[daemonize] Unable to open stdout log, quitting.");
break;
case '2':
savedopts->errlog = fopen(optarg, "a");
if (!savedopts->errlog) q("[daemonize] Unable to open stderr log, quitting.");
break;
default:
// getopt will have printed an error already
qusage();
}
}
}
int main (int argc, char** argv) {
struct opts options = {true, false, NULL, NULL};
parseargs(argc, argv, &options);
int cmdlen = 0, buff_size = 256;
char* buffer = malloc(buff_size);
while (optind < argc) {
int arglen = strlen(argv[optind]);
while (cmdlen+arglen+1 > buff_size) {
buff_size *= 2;
}
buffer = realloc(buffer, buff_size);
if (buffer == NULL) q("[daemonize] Out of memory parsing arguments.");
strncpy(&buffer[cmdlen], argv[optind++], arglen);
cmdlen += arglen+1;
buffer[cmdlen-1] = ' ';
}
buffer[cmdlen-1] = 0;
char cmd[cmdlen];
memcpy(cmd, buffer, cmdlen);
free(buffer);
if (cmdlen < 1) qtoofewargs();
// Set up logs as appropriate
int logs = options.stdlog || options.errlog;
if (options.stdlog) {
dup2(fileno(options.stdlog), STDOUT_FILENO);
fclose(options.stdlog);
}
if (options.errlog) {
dup2(fileno(options.errlog), STDERR_FILENO);
fclose(options.errlog);
}
if (logs && !options.noclose) {
int devnull_out = open("/dev/null", O_WRONLY);
int devnull_in = open("/dev/null", O_RDONLY);
if (!options.errlog)
dup2(devnull_out, STDERR_FILENO);
if (!options.stdlog)
dup2(devnull_out, STDOUT_FILENO);
dup2(devnull_in, STDIN_FILENO);
close(devnull_in);
close(devnull_out);
}
daemon(options.nochdir, options.noclose | logs);
char* args[] = {"/bin/sh", "-c", cmd, NULL};
execv(args[0], args);
}
|
the_stack_data/29171.c
|
// RUN: mlir-clang %s -S --function=foo | FileCheck %s
float foo(int i, int j) {
// multiple dims with array fillers
float A[][4] = {
{1.0f, 2.0, 3.0, 4.0},
{3.33333f},
{0.1f, 0.2f, 0.3, 0.4},
};
// single dim
float B[4] = {1.23f};
float sum = 0.0f;
// dynamic initialization
for (int k = 0; k < 3; ++k) {
float C[2] = {i + k, k - j};
sum += C[i];
}
return A[i][j] + B[j] + sum;
}
// CHECK-LABEL: func @foo
// CHECK-DAG: %[[CST3:.*]] = arith.constant 3.33
// CHECK-DAG: %[[CST1_23:.*]] = arith.constant 1.23
// CHECK-DAG: %[[MEM_A:.*]] = memref.alloca() : memref<3x4xf32>
// CHECK-DAG: %[[MEM_B:.*]] = memref.alloca() : memref<4xf32>
// CHECK-DAG: %[[MEM_C:.*]] = memref.alloca() : memref<2xf32>
// CHECK: affine.store %{{.*}}, %[[MEM_A]][0, 0]
// CHECK: affine.store %{{.*}}, %[[MEM_A]][0, 1]
// CHECK: affine.store %{{.*}}, %[[MEM_A]][0, 2]
// CHECK: affine.store %{{.*}}, %[[MEM_A]][0, 3]
// CHECK: affine.store %[[CST3]], %[[MEM_A]][1, 0]
// CHECK: affine.store %[[CST3]], %[[MEM_A]][1, 1]
// CHECK: affine.store %[[CST3]], %[[MEM_A]][1, 2]
// CHECK: affine.store %[[CST3]], %[[MEM_A]][1, 3]
// CHECK: affine.store %{{.*}}, %[[MEM_A]][2, 0]
// CHECK: affine.store %{{.*}}, %[[MEM_A]][2, 1]
// CHECK: affine.store %{{.*}}, %[[MEM_A]][2, 2]
// CHECK: affine.store %{{.*}}, %[[MEM_A]][2, 3]
// CHECK: affine.store %[[CST1_23]], %[[MEM_B]][0]
// CHECK: affine.store %[[CST1_23]], %[[MEM_B]][1]
// CHECK: affine.store %[[CST1_23]], %[[MEM_B]][2]
// CHECK: affine.store %[[CST1_23]], %[[MEM_B]][3]
// CHECK: scf.for
// CHECK: affine.store %{{.*}}, %[[MEM_C]][0]
// CHECK: affine.store %{{.*}}, %[[MEM_C]][1]
|
the_stack_data/153267379.c
|
// 8.2.3
asm(".symver add, add@VERS_1.1");
int add(int a, int b) {
return a + b;
}
asm(".symver old_printf, printf@VERS_1.1");
asm(".symver new_printf, printf@VERS_1.2");
int old_printf() {
return 0;
}
int new_printf() {
return 1;
}
|
the_stack_data/26167.c
|
// RUN: %clang_cc1 -triple x86_64-apple-macos11 -darwin-target-variant-triple x86_64-apple-ios14-macabi -target-sdk-version=11.1 -darwin-target-variant-sdk-version=14.1 -emit-llvm -o - %s | FileCheck %s
// CHECK: !llvm.module.flags = !{!0, !1, !2
// CHECK: !0 = !{i32 2, !"SDK Version", [2 x i32] [i32 11, i32 1]}
// CHECK: !1 = !{i32 4, !"darwin.target_variant.triple", !"x86_64-apple-ios14-macabi"}
// CHECK: !2 = !{i32 2, !"darwin.target_variant.SDK Version", [2 x i32] [i32 14, i32 1]}
|
the_stack_data/61074963.c
|
int ft_str_is_alpha(char *str)
{
int flag;
int i;
flag = 1;
i = 0;
while (str[i] != '\0')
{
if (str[i] < 'A' || str[i] > 'z')
{
flag = 0;
}
if (str[i] > 'Z' && str[i] < 'a')
{
flag = 0;
}
i++;
}
return (flag);
}
|
the_stack_data/109390.c
|
#include<stdio.h>
const double pi=3.14159;
int main(){
double r,h,v,a;
scanf("%lf%lf", &r, &h);
v = pi * r * r * h;
a = 2 * pi * r * (r+h);
printf("volume=%.3lf, area=%.3lf", v, a);
return 0;
}
|
the_stack_data/89925.c
|
/*
************************************************
username : smmehrab
fullname : s.m.mehrabul islam
email : [email protected]
institute : university of dhaka, bangladesh
session : 2017-2018
************************************************
*/
#include<stdio.h>
int main()
{
int x=0; char s[100];
int n,i=0;
scanf("%d",&n);
for(i=0;i<=n;i++)
{
gets(s);
if((s[0]=='X' && s[1]=='+' && s[2]=='+')||(s[0]=='+' && s[1]=='+' && s[2]=='X'))
{
x++;
}
if((s[0]=='X' && s[1]=='-' && s[2]=='-')||(s[0]=='-' && s[1]=='-' && s[2]=='X'))
{
x--;
}
}
printf("%d\n",x);
return 0;
}
|
the_stack_data/1256824.c
|
#include <stdio.h>
#include <stdlib.h>
#define TYPE int
#define TRUE 1
#define FALSE 0
typedef struct Node
{
TYPE key;
struct Node* next;
struct Node* previos;
} Node;
typedef struct{
Node* node;
}Queue;
void initQueue(Queue* queue){
Node* node = malloc(sizeof(Node));
node->next = node;
node->previos = node;
queue->node = node;
}
void showQueue(Queue* queue){
Node* node = queue->node;
//find last node
while(node != node->next){
node = node->next;
}
printf("Queue = [");
while(node->previos != NULL){
printf("%d, ", node->previos->key);
node = node->previos;
}
printf(" ]\n");
}
void enqueue(Queue* queue, TYPE value){
Node* newNode = malloc(sizeof(Node));
newNode->key = value;
Node* node = queue->node;
newNode->next = node;
newNode->previos = NULL;
node->previos = newNode;
queue->node = newNode;
}
TYPE dequeue(Queue* queue){
Node* temp = queue->node;
Node* deleted;
while(temp->next != temp){
temp = temp->next;
}
temp = temp->previos;
deleted = temp;
temp->previos->next = temp->next;
temp->next->previos = temp->previos;
return deleted->key;
}
int main(){
Queue queue;
initQueue(&queue);
enqueue(&queue, 4);
enqueue(&queue, 10);
enqueue(&queue, 12);
enqueue(&queue, 14);
showQueue(&queue);
printf("Dequeue=> %d\n", dequeue(&queue) );
printf("Dequeue=> %d\n", dequeue(&queue) );
showQueue(&queue);
return EXIT_SUCCESS;
}
|
the_stack_data/248581618.c
|
char a[]={4,5};f(n){return a[n<2?n:0];}
|
the_stack_data/25137275.c
|
/* $OpenBSD: pem_all.c,v 1.14 2014/07/10 22:45:57 jsing Exp $ */
/* 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.]
*/
/* ====================================================================
* Copyright (c) 1998-2002 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.
* ====================================================================
*
* This product includes cryptographic software written by Eric Young
* ([email protected]). This product includes software written by Tim
* Hudson ([email protected]).
*
*/
#include <stdio.h>
#include <openssl/opensslconf.h>
#include <openssl/bio.h>
#include <openssl/evp.h>
#include <openssl/pem.h>
#include <openssl/pkcs7.h>
#include <openssl/x509.h>
#ifndef OPENSSL_NO_DH
#include <openssl/dh.h>
#endif
#ifndef OPENSSL_NO_DSA
#include <openssl/dsa.h>
#endif
#ifndef OPENSSL_NO_RSA
#include <openssl/rsa.h>
#endif
#ifndef OPENSSL_NO_RSA
static RSA *pkey_get_rsa(EVP_PKEY *key, RSA **rsa);
#endif
#ifndef OPENSSL_NO_DSA
static DSA *pkey_get_dsa(EVP_PKEY *key, DSA **dsa);
#endif
#ifndef OPENSSL_NO_EC
static EC_KEY *pkey_get_eckey(EVP_PKEY *key, EC_KEY **eckey);
#endif
IMPLEMENT_PEM_rw(X509_REQ, X509_REQ, PEM_STRING_X509_REQ, X509_REQ)
IMPLEMENT_PEM_write(X509_REQ_NEW, X509_REQ, PEM_STRING_X509_REQ_OLD, X509_REQ)
IMPLEMENT_PEM_rw(X509_CRL, X509_CRL, PEM_STRING_X509_CRL, X509_CRL)
IMPLEMENT_PEM_rw(PKCS7, PKCS7, PEM_STRING_PKCS7, PKCS7)
IMPLEMENT_PEM_rw(NETSCAPE_CERT_SEQUENCE, NETSCAPE_CERT_SEQUENCE,
PEM_STRING_X509, NETSCAPE_CERT_SEQUENCE)
#ifndef OPENSSL_NO_RSA
/* We treat RSA or DSA private keys as a special case.
*
* For private keys we read in an EVP_PKEY structure with
* PEM_read_bio_PrivateKey() and extract the relevant private
* key: this means can handle "traditional" and PKCS#8 formats
* transparently.
*/
static RSA *
pkey_get_rsa(EVP_PKEY *key, RSA **rsa)
{
RSA *rtmp;
if (!key)
return NULL;
rtmp = EVP_PKEY_get1_RSA(key);
EVP_PKEY_free(key);
if (!rtmp)
return NULL;
if (rsa) {
RSA_free(*rsa);
*rsa = rtmp;
}
return rtmp;
}
RSA *
PEM_read_bio_RSAPrivateKey(BIO *bp, RSA **rsa, pem_password_cb *cb, void *u)
{
EVP_PKEY *pktmp;
pktmp = PEM_read_bio_PrivateKey(bp, NULL, cb, u);
return pkey_get_rsa(pktmp, rsa);
}
RSA *
PEM_read_RSAPrivateKey(FILE *fp, RSA **rsa, pem_password_cb *cb, void *u)
{
EVP_PKEY *pktmp;
pktmp = PEM_read_PrivateKey(fp, NULL, cb, u);
return pkey_get_rsa(pktmp, rsa);
}
IMPLEMENT_PEM_write_cb_const(RSAPrivateKey, RSA, PEM_STRING_RSA, RSAPrivateKey)
IMPLEMENT_PEM_rw_const(RSAPublicKey, RSA, PEM_STRING_RSA_PUBLIC, RSAPublicKey)
IMPLEMENT_PEM_rw(RSA_PUBKEY, RSA, PEM_STRING_PUBLIC, RSA_PUBKEY)
#endif
#ifndef OPENSSL_NO_DSA
static DSA *
pkey_get_dsa(EVP_PKEY *key, DSA **dsa)
{
DSA *dtmp;
if (!key)
return NULL;
dtmp = EVP_PKEY_get1_DSA(key);
EVP_PKEY_free(key);
if (!dtmp)
return NULL;
if (dsa) {
DSA_free(*dsa);
*dsa = dtmp;
}
return dtmp;
}
DSA *
PEM_read_bio_DSAPrivateKey(BIO *bp, DSA **dsa, pem_password_cb *cb, void *u)
{
EVP_PKEY *pktmp;
pktmp = PEM_read_bio_PrivateKey(bp, NULL, cb, u);
return pkey_get_dsa(pktmp, dsa); /* will free pktmp */
}
IMPLEMENT_PEM_write_cb_const(DSAPrivateKey, DSA, PEM_STRING_DSA, DSAPrivateKey)
IMPLEMENT_PEM_rw(DSA_PUBKEY, DSA, PEM_STRING_PUBLIC, DSA_PUBKEY)
DSA *
PEM_read_DSAPrivateKey(FILE *fp, DSA **dsa, pem_password_cb *cb, void *u)
{
EVP_PKEY *pktmp;
pktmp = PEM_read_PrivateKey(fp, NULL, cb, u);
return pkey_get_dsa(pktmp, dsa); /* will free pktmp */
}
IMPLEMENT_PEM_rw_const(DSAparams, DSA, PEM_STRING_DSAPARAMS, DSAparams)
#endif
#ifndef OPENSSL_NO_EC
static EC_KEY *
pkey_get_eckey(EVP_PKEY *key, EC_KEY **eckey)
{
EC_KEY *dtmp;
if (!key)
return NULL;
dtmp = EVP_PKEY_get1_EC_KEY(key);
EVP_PKEY_free(key);
if (!dtmp)
return NULL;
if (eckey) {
EC_KEY_free(*eckey);
*eckey = dtmp;
}
return dtmp;
}
EC_KEY *
PEM_read_bio_ECPrivateKey(BIO *bp, EC_KEY **key, pem_password_cb *cb, void *u)
{
EVP_PKEY *pktmp;
pktmp = PEM_read_bio_PrivateKey(bp, NULL, cb, u);
return pkey_get_eckey(pktmp, key); /* will free pktmp */
}
IMPLEMENT_PEM_rw_const(ECPKParameters, EC_GROUP, PEM_STRING_ECPARAMETERS,
ECPKParameters)
IMPLEMENT_PEM_write_cb(ECPrivateKey, EC_KEY, PEM_STRING_ECPRIVATEKEY,
ECPrivateKey)
IMPLEMENT_PEM_rw(EC_PUBKEY, EC_KEY, PEM_STRING_PUBLIC, EC_PUBKEY)
EC_KEY *
PEM_read_ECPrivateKey(FILE *fp, EC_KEY **eckey, pem_password_cb *cb, void *u)
{
EVP_PKEY *pktmp;
pktmp = PEM_read_PrivateKey(fp, NULL, cb, u);
return pkey_get_eckey(pktmp, eckey); /* will free pktmp */
}
#endif
#ifndef OPENSSL_NO_DH
IMPLEMENT_PEM_rw_const(DHparams, DH, PEM_STRING_DHPARAMS, DHparams)
#endif
IMPLEMENT_PEM_rw(PUBKEY, EVP_PKEY, PEM_STRING_PUBLIC, PUBKEY)
|
the_stack_data/108018.c
|
/*****************************************************************************
*
* Size-sorted list/tree functions.
*
* Author: Daniel Stenberg
* Date: March 7, 1997
* Version: 2.0
* Email: [email protected]
*
*
* v2.0
* - Added SPLAY TREE functionality.
*
* Adds and removes CHUNKS from a list or tree.
*
****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#define SPLAY /* we use the splay version as that is much faster */
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#ifndef SPLAY /* these routines are for the non-splay version */
struct ChunkInfo {
struct ChunkInfo *larger;
struct ChunkInfo *smaller;
size_t size;
};
/* the CHUNK list anchor */
struct ChunkInfo *chunkHead=NULL;
/***********************************************************************
findchunkbysize()
Find the chunk that is smaller than the input size. Returns
NULL if none is.
**********************************************************************/
static struct ChunkInfo *findchunkbysize(size_t size)
{
struct ChunkInfo *test = chunkHead;
struct ChunkInfo *smaller = NULL;
while(test && (test->size < size)) {
smaller = test;
test = test->larger;
}
return smaller;
}
/***********************************************************************
remove_chunksize()
Remove the chunk from the size-sorted list.
***********************************************************************/
void remove_chunksize(void *data)
{
struct ChunkInfo *chunk = (struct ChunkInfo *)data;
if(chunk->smaller)
chunk->smaller->larger = chunk->larger;
else {
/* if this has no smaller, this is the head */
chunkHead = chunk->larger; /* new head */
}
if(chunk->larger)
chunk->larger->smaller = chunk->smaller;
}
void insert_bysize(char *data, size_t size)
{
struct ChunkInfo *newchunk = (struct ChunkInfo *)data;
struct ChunkInfo *chunk = findchunkbysize ( size );
newchunk->size = size;
if(chunk) {
/* 'chunk' is smaller than size, append the new chunk ahead of this */
newchunk->smaller = chunk;
newchunk->larger = chunk->larger;
if(chunk->larger)
chunk->larger->smaller = newchunk;
chunk->larger = newchunk;
}
else {
/* smallest CHUNK around, append first in the list */
newchunk->larger = chunkHead;
newchunk->smaller = NULL;
if(chunkHead)
chunkHead->smaller = newchunk;
chunkHead = newchunk;
}
}
char *obtainbysize( size_t size)
{
struct ChunkInfo *chunk = findchunkbysize( size );
if(!chunk) {
if(size <= (chunkHead->size))
/* there is no smaller CHUNK, use the first one (if we fit within that)
*/
chunk = chunkHead;
}
else
/* we're on the last CHUNK that is smaller than requested, step onto
the bigger one */
chunk = chunk->larger;
if(chunk) {
remove_chunksize( chunk ); /* unlink size-wise */
return (char *)chunk;
}
else
return NULL;
}
void print_sizes(void)
{
struct ChunkInfo *chunk = chunkHead;
printf("List of CHUNKS (in size order):\n");
#if 1
while(chunk) {
printf(" START %p END %p SIZE %d\n",
chunk, (char *)chunk+chunk->size, chunk->size);
chunk = chunk->larger;
}
#endif
printf("End of CHUNKS:\n");
}
#else /* Here follows all routines dealing with the SPLAY TREES */
typedef struct tree_node Tree;
struct tree_node {
Tree *smaller; /* smaller node */
Tree *larger; /* larger node */
Tree *same; /* points to a node with identical key */
int key; /* the "sort" key */
};
Tree *chunkHead = NULL; /* the root */
#define compare(i,j) ((i)-(j))
/* Set this to a key value that will *NEVER* appear otherwise */
#define KEY_NOTUSED -1
/*
* Splay using the key i (which may or may not be in the tree.) The starting
* root is t. Weight fields are maintained.
*/
Tree * splay (int i, Tree *t)
{
Tree N, *l, *r, *y;
int comp;
if (t == NULL)
return t;
N.smaller = N.larger = NULL;
l = r = &N;
for (;;) {
comp = compare(i, t->key);
if (comp < 0) {
if (t->smaller == NULL)
break;
if (compare(i, t->smaller->key) < 0) {
y = t->smaller; /* rotate smaller */
t->smaller = y->larger;
y->larger = t;
t = y;
if (t->smaller == NULL)
break;
}
r->smaller = t; /* link smaller */
r = t;
t = t->smaller;
}
else if (comp > 0) {
if (t->larger == NULL)
break;
if (compare(i, t->larger->key) > 0) {
y = t->larger; /* rotate larger */
t->larger = y->smaller;
y->smaller = t;
t = y;
if (t->larger == NULL)
break;
}
l->larger = t; /* link larger */
l = t;
t = t->larger;
}
else {
break;
}
}
l->larger = t->smaller; /* assemble */
r->smaller = t->larger;
t->smaller = N.larger;
t->larger = N.smaller;
return t;
}
/* Insert key i into the tree t. Return a pointer to the resulting tree or
NULL if something went wrong. */
Tree *insert(int i, Tree *t, Tree *new)
{
if (new == NULL) {
return t;
}
if (t != NULL) {
t = splay(i,t);
if (compare(i, t->key)==0) {
/* it already exists one of this size */
new->same = t;
new->key = i;
new->smaller = t->smaller;
new->larger = t->larger;
t->smaller = new;
t->key = KEY_NOTUSED;
return new; /* new root node */
}
}
if (t == NULL) {
new->smaller = new->larger = NULL;
}
else if (compare(i, t->key) < 0) {
new->smaller = t->smaller;
new->larger = t;
t->smaller = NULL;
}
else {
new->larger = t->larger;
new->smaller = t;
t->larger = NULL;
}
new->key = i;
new->same = NULL; /* no identical node (yet) */
return new;
}
/* Finds and deletes the best-fit node from the tree. Return a pointer to the
resulting tree. best-fit means the smallest node that fits the requested
size. */
Tree *removebestfit(int i, Tree *t, Tree **removed)
{
Tree *x;
if (t==NULL)
return NULL;
t = splay(i,t);
if(compare(i, t->key) > 0) {
/* too small node, try the larger chain */
if(t->larger)
t=splay(t->larger->key, t);
else {
/* fail */
*removed = NULL;
return t;
}
}
if (compare(i, t->key) <= 0) { /* found it */
/* FIRST! Check if there is a list with identical sizes */
x = t->same;
if(x) {
/* there is, pick one from the list */
/* 'x' is the new root node */
x->key = t->key;
x->larger = t->larger;
x->smaller = t->smaller;
*removed = t;
return x; /* new root */
}
if (t->smaller == NULL) {
x = t->larger;
}
else {
x = splay(i, t->smaller);
if(x->larger)
x = splay(x->larger->key, x);
x->larger = t->larger;
}
*removed = t;
return x;
}
else {
*removed = NULL; /* no match */
return t; /* It wasn't there */
}
}
/* Deletes the node we point out from the tree if it's there. Return a pointer
to the resulting tree. */
Tree *removebyaddr(Tree *t, Tree *remove)
{
Tree *x;
if (!t || !remove)
return NULL;
if(KEY_NOTUSED == remove->key) {
/* just unlink ourselves nice and quickly: */
remove->smaller->same = remove->same;
if(remove->same)
remove->same->smaller = remove->smaller;
/* voila, we're done! */
return t;
}
t = splay(remove->key,t);
/* Check if there is a list with identical sizes */
x = t->same;
if(x) {
/* 'x' is the new root node */
x->key = t->key;
x->larger = t->larger;
x->smaller = t->smaller;
return x; /* new root */
}
/* Remove the actualy root node: */
if (t->smaller == NULL) {
x = t->larger;
}
else {
x = splay(remove->key, t->smaller);
x->larger = t->larger;
}
return x;
}
int printtree(Tree * t, int d, char output)
{
int distance=0;
Tree *node;
int i;
if (t == NULL)
return 0;
distance += printtree(t->larger, d+1, output);
for (i=0; i<d; i++)
if(output)
printf(" ");
if(output) {
printf("%d[%d]", t->key, i);
}
for(node = t->same; node; node = node->same) {
distance += i; /* this has the same "virtual" distance */
if(output)
printf(" [+]");
}
if(output)
puts("");
distance += i;
distance += printtree(t->smaller, d+1, output);
return distance;
}
/* Here follow the look-alike interface so that the tree-function names are
the same as the list-ones to enable easy interchange */
void remove_chunksize(void *data)
{
chunkHead = removebyaddr(chunkHead, data);
}
void insert_bysize(char *data, size_t size)
{
chunkHead = insert(size, chunkHead, (Tree *)data);
}
char *obtainbysize( size_t size)
{
Tree *receive;
chunkHead = removebestfit(size, chunkHead, &receive);
return (char *)receive;
}
void print_sizes(void)
{
printtree(chunkHead, 0, 1);
}
#endif
|
the_stack_data/248580590.c
|
typedef struct colorbox {
struct colorbox *next, *prev;
int rmin, rmax;
int gmin, gmax;
int bmin, bmax;
int total;
} Colorbox;
#pragma hmpp astex_codelet__6 codelet &
#pragma hmpp astex_codelet__6 , args[__astex_addr__astex_do_return].io=out &
#pragma hmpp astex_codelet__6 , args[__astex_addr__astex_what_return].io=out &
#pragma hmpp astex_codelet__6 , args[b].io=in &
#pragma hmpp astex_codelet__6 , target=C &
#pragma hmpp astex_codelet__6 , version=1.4.0
void astex_codelet__6(Colorbox *usedboxes, Colorbox *b, int size, Colorbox *__astex_addr__astex_what_return[1], int __astex_addr__astex_do_return[1])
{
int astex_do_return;
astex_do_return = 0;
Colorbox *astex_what_return;
Colorbox *p;
astex_thread_begin: {
for (p = usedboxes ; p != ((void *) 0) ; p = p->next)
if ((p->rmax > p->rmin || p->gmax > p->gmin || p->bmax > p->bmin) && p->total > size)
size = (b = p)->total;
{
astex_what_return = (b);
astex_do_return = 1;
goto astex_thread_end;
}
}
astex_thread_end:;
__astex_addr__astex_what_return[0] = astex_what_return;
__astex_addr__astex_do_return[0] = astex_do_return;
}
|
the_stack_data/1059772.c
|
/*
Copyright 1985, 1986, 1987,1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall
not be used in advertising or otherwise to promote the sale, use or
other dealings in this Software without prior written authorization
from The Open Group.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "X11/Xlibint.h"
#include "X11/Xutil.h"
/*
* XParseGeometry parses strings of the form
* "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where
* width, height, xoffset, and yoffset are unsigned integers.
* Example: "=80x24+300-49"
* The equal sign is optional.
* It returns a bitmask that indicates which of the four values
* were actually found in the string. For each value found,
* the corresponding argument is updated; for each value
* not found, the corresponding argument is left unchanged.
*/
static int
ReadInteger(char *string, char **NextString)
{
register int Result = 0;
int Sign = 1;
if (*string == '+')
string++;
else if (*string == '-')
{
string++;
Sign = -1;
}
for (; (*string >= '0') && (*string <= '9'); string++)
{
Result = (Result * 10) + (*string - '0');
}
*NextString = string;
if (Sign >= 0)
return (Result);
else
return (-Result);
}
int
XParseGeometry (
_Xconst char *string,
int *x,
int *y,
unsigned int *width, /* RETURN */
unsigned int *height) /* RETURN */
{
int mask = NoValue;
register char *strind;
unsigned int tempWidth = 0, tempHeight = 0;
int tempX = 0, tempY = 0;
char *nextCharacter;
if ( (string == NULL) || (*string == '\0')) return(mask);
if (*string == '=')
string++; /* ignore possible '=' at beg of geometry spec */
strind = (char *)string;
if (*strind != '+' && *strind != '-' && *strind != 'x') {
tempWidth = ReadInteger(strind, &nextCharacter);
if (strind == nextCharacter)
return (0);
strind = nextCharacter;
mask |= WidthValue;
}
if (*strind == 'x' || *strind == 'X') {
strind++;
tempHeight = ReadInteger(strind, &nextCharacter);
if (strind == nextCharacter)
return (0);
strind = nextCharacter;
mask |= HeightValue;
}
if ((*strind == '+') || (*strind == '-')) {
if (*strind == '-') {
strind++;
tempX = -ReadInteger(strind, &nextCharacter);
if (strind == nextCharacter)
return (0);
strind = nextCharacter;
mask |= XNegative;
}
else
{ strind++;
tempX = ReadInteger(strind, &nextCharacter);
if (strind == nextCharacter)
return(0);
strind = nextCharacter;
}
mask |= XValue;
if ((*strind == '+') || (*strind == '-')) {
if (*strind == '-') {
strind++;
tempY = -ReadInteger(strind, &nextCharacter);
if (strind == nextCharacter)
return(0);
strind = nextCharacter;
mask |= YNegative;
}
else
{
strind++;
tempY = ReadInteger(strind, &nextCharacter);
if (strind == nextCharacter)
return(0);
strind = nextCharacter;
}
mask |= YValue;
}
}
/* If strind isn't at the end of the string the it's an invalid
geometry specification. */
if (*strind != '\0') return (0);
if (mask & XValue)
*x = tempX;
if (mask & YValue)
*y = tempY;
if (mask & WidthValue)
*width = tempWidth;
if (mask & HeightValue)
*height = tempHeight;
return (mask);
}
|
the_stack_data/417909.c
|
#include <stdlib.h>
#include <stdio.h>
int main()
{
FILE *fp = fopen("/bin/ls","r");
if(fp!=NULL) {
printf("yes\n");
fclose(fp);
} else
printf("no\n");
exit(0);
}
|
the_stack_data/96869.c
|
extern void __VERIFIER_error() __attribute__ ((__noreturn__));
void __VERIFIER_assert(int expression) { if (!expression) { ERROR: __VERIFIER_error(); }; return; }
int __global_lock;
void __VERIFIER_atomic_begin() { __VERIFIER_assume(__global_lock==0); __global_lock=1; return; }
void __VERIFIER_atomic_end() { __VERIFIER_assume(__global_lock==1); __global_lock=0; return; }
#include <assert.h>
#include <pthread.h>
#ifndef TRUE
#define TRUE (_Bool)1
#endif
#ifndef FALSE
#define FALSE (_Bool)0
#endif
#ifndef NULL
#define NULL ((void*)0)
#endif
#ifndef FENCE
#define FENCE(x) ((void)0)
#endif
#ifndef IEEE_FLOAT_EQUAL
#define IEEE_FLOAT_EQUAL(x,y) (x==y)
#endif
#ifndef IEEE_FLOAT_NOTEQUAL
#define IEEE_FLOAT_NOTEQUAL(x,y) (x!=y)
#endif
void * P0(void *arg);
void * P1(void *arg);
void * P2(void *arg);
void fence();
void isync();
void lwfence();
int __unbuffered_cnt;
int __unbuffered_cnt = 0;
int __unbuffered_p2_EAX;
int __unbuffered_p2_EAX = 0;
_Bool main$tmp_guard0;
_Bool main$tmp_guard1;
int x;
int x = 0;
int y;
int y = 0;
_Bool y$flush_delayed;
int y$mem_tmp;
_Bool y$r_buff0_thd0;
_Bool y$r_buff0_thd1;
_Bool y$r_buff0_thd2;
_Bool y$r_buff0_thd3;
_Bool y$r_buff1_thd0;
_Bool y$r_buff1_thd1;
_Bool y$r_buff1_thd2;
_Bool y$r_buff1_thd3;
_Bool y$read_delayed;
int *y$read_delayed_var;
int y$w_buff0;
_Bool y$w_buff0_used;
int y$w_buff1;
_Bool y$w_buff1_used;
int z;
int z = 0;
_Bool weak$$choice0;
_Bool weak$$choice2;
void * P0(void *arg)
{
__VERIFIER_atomic_begin();
z = 1;
__VERIFIER_atomic_end();
__VERIFIER_atomic_begin();
x = 1;
__VERIFIER_atomic_end();
__VERIFIER_atomic_begin();
__VERIFIER_atomic_end();
__VERIFIER_atomic_begin();
__unbuffered_cnt = __unbuffered_cnt + 1;
__VERIFIER_atomic_end();
return nondet_0();
}
void * P1(void *arg)
{
__VERIFIER_atomic_begin();
x = 2;
__VERIFIER_atomic_end();
__VERIFIER_atomic_begin();
y = 1;
__VERIFIER_atomic_end();
__VERIFIER_atomic_begin();
y = y$w_buff0_used && y$r_buff0_thd2 ? y$w_buff0 : (y$w_buff1_used && y$r_buff1_thd2 ? y$w_buff1 : y);
y$w_buff0_used = y$w_buff0_used && y$r_buff0_thd2 ? FALSE : y$w_buff0_used;
y$w_buff1_used = y$w_buff0_used && y$r_buff0_thd2 || y$w_buff1_used && y$r_buff1_thd2 ? FALSE : y$w_buff1_used;
y$r_buff0_thd2 = y$w_buff0_used && y$r_buff0_thd2 ? FALSE : y$r_buff0_thd2;
y$r_buff1_thd2 = y$w_buff0_used && y$r_buff0_thd2 || y$w_buff1_used && y$r_buff1_thd2 ? FALSE : y$r_buff1_thd2;
__VERIFIER_atomic_end();
__VERIFIER_atomic_begin();
__unbuffered_cnt = __unbuffered_cnt + 1;
__VERIFIER_atomic_end();
return nondet_0();
}
void * P2(void *arg)
{
__VERIFIER_atomic_begin();
y$w_buff1 = y$w_buff0;
y$w_buff0 = 2;
y$w_buff1_used = y$w_buff0_used;
y$w_buff0_used = TRUE;
__VERIFIER_assert(!(y$w_buff1_used && y$w_buff0_used));
y$r_buff1_thd0 = y$r_buff0_thd0;
y$r_buff1_thd1 = y$r_buff0_thd1;
y$r_buff1_thd2 = y$r_buff0_thd2;
y$r_buff1_thd3 = y$r_buff0_thd3;
y$r_buff0_thd3 = TRUE;
__VERIFIER_atomic_end();
__VERIFIER_atomic_begin();
__unbuffered_p2_EAX = z;
__VERIFIER_atomic_end();
__VERIFIER_atomic_begin();
y = y$w_buff0_used && y$r_buff0_thd3 ? y$w_buff0 : (y$w_buff1_used && y$r_buff1_thd3 ? y$w_buff1 : y);
y$w_buff0_used = y$w_buff0_used && y$r_buff0_thd3 ? FALSE : y$w_buff0_used;
y$w_buff1_used = y$w_buff0_used && y$r_buff0_thd3 || y$w_buff1_used && y$r_buff1_thd3 ? FALSE : y$w_buff1_used;
y$r_buff0_thd3 = y$w_buff0_used && y$r_buff0_thd3 ? FALSE : y$r_buff0_thd3;
y$r_buff1_thd3 = y$w_buff0_used && y$r_buff0_thd3 || y$w_buff1_used && y$r_buff1_thd3 ? FALSE : y$r_buff1_thd3;
__VERIFIER_atomic_end();
__VERIFIER_atomic_begin();
__unbuffered_cnt = __unbuffered_cnt + 1;
__VERIFIER_atomic_end();
return nondet_0();
}
void fence()
{
}
void isync()
{
}
void lwfence()
{
}
int main()
{
pthread_create(NULL, NULL, P0, NULL);
pthread_create(NULL, NULL, P1, NULL);
pthread_create(NULL, NULL, P2, NULL);
__VERIFIER_atomic_begin();
main$tmp_guard0 = __unbuffered_cnt == 3;
__VERIFIER_atomic_end();
__VERIFIER_assume(main$tmp_guard0);
__VERIFIER_atomic_begin();
y = y$w_buff0_used && y$r_buff0_thd0 ? y$w_buff0 : (y$w_buff1_used && y$r_buff1_thd0 ? y$w_buff1 : y);
y$w_buff0_used = y$w_buff0_used && y$r_buff0_thd0 ? FALSE : y$w_buff0_used;
y$w_buff1_used = y$w_buff0_used && y$r_buff0_thd0 || y$w_buff1_used && y$r_buff1_thd0 ? FALSE : y$w_buff1_used;
y$r_buff0_thd0 = y$w_buff0_used && y$r_buff0_thd0 ? FALSE : y$r_buff0_thd0;
y$r_buff1_thd0 = y$w_buff0_used && y$r_buff0_thd0 || y$w_buff1_used && y$r_buff1_thd0 ? FALSE : y$r_buff1_thd0;
__VERIFIER_atomic_end();
__VERIFIER_atomic_begin();
/* Program proven to be relaxed for X86, model checker says YES. */
weak$$choice0 = nondet_1();
/* Program proven to be relaxed for X86, model checker says YES. */
weak$$choice2 = nondet_1();
/* Program proven to be relaxed for X86, model checker says YES. */
y$flush_delayed = weak$$choice2;
/* Program proven to be relaxed for X86, model checker says YES. */
y$mem_tmp = y;
/* Program proven to be relaxed for X86, model checker says YES. */
y = !y$w_buff0_used || !y$r_buff0_thd0 && !y$w_buff1_used || !y$r_buff0_thd0 && !y$r_buff1_thd0 ? y : (y$w_buff0_used && y$r_buff0_thd0 ? y$w_buff0 : y$w_buff1);
/* Program proven to be relaxed for X86, model checker says YES. */
y$w_buff0 = weak$$choice2 ? y$w_buff0 : (!y$w_buff0_used || !y$r_buff0_thd0 && !y$w_buff1_used || !y$r_buff0_thd0 && !y$r_buff1_thd0 ? y$w_buff0 : (y$w_buff0_used && y$r_buff0_thd0 ? y$w_buff0 : y$w_buff0));
/* Program proven to be relaxed for X86, model checker says YES. */
y$w_buff1 = weak$$choice2 ? y$w_buff1 : (!y$w_buff0_used || !y$r_buff0_thd0 && !y$w_buff1_used || !y$r_buff0_thd0 && !y$r_buff1_thd0 ? y$w_buff1 : (y$w_buff0_used && y$r_buff0_thd0 ? y$w_buff1 : y$w_buff1));
/* Program proven to be relaxed for X86, model checker says YES. */
y$w_buff0_used = weak$$choice2 ? y$w_buff0_used : (!y$w_buff0_used || !y$r_buff0_thd0 && !y$w_buff1_used || !y$r_buff0_thd0 && !y$r_buff1_thd0 ? y$w_buff0_used : (y$w_buff0_used && y$r_buff0_thd0 ? FALSE : y$w_buff0_used));
/* Program proven to be relaxed for X86, model checker says YES. */
y$w_buff1_used = weak$$choice2 ? y$w_buff1_used : (!y$w_buff0_used || !y$r_buff0_thd0 && !y$w_buff1_used || !y$r_buff0_thd0 && !y$r_buff1_thd0 ? y$w_buff1_used : (y$w_buff0_used && y$r_buff0_thd0 ? FALSE : FALSE));
/* Program proven to be relaxed for X86, model checker says YES. */
y$r_buff0_thd0 = weak$$choice2 ? y$r_buff0_thd0 : (!y$w_buff0_used || !y$r_buff0_thd0 && !y$w_buff1_used || !y$r_buff0_thd0 && !y$r_buff1_thd0 ? y$r_buff0_thd0 : (y$w_buff0_used && y$r_buff0_thd0 ? FALSE : y$r_buff0_thd0));
/* Program proven to be relaxed for X86, model checker says YES. */
y$r_buff1_thd0 = weak$$choice2 ? y$r_buff1_thd0 : (!y$w_buff0_used || !y$r_buff0_thd0 && !y$w_buff1_used || !y$r_buff0_thd0 && !y$r_buff1_thd0 ? y$r_buff1_thd0 : (y$w_buff0_used && y$r_buff0_thd0 ? FALSE : FALSE));
/* Program proven to be relaxed for X86, model checker says YES. */
main$tmp_guard1 = !(x == 2 && y == 2 && __unbuffered_p2_EAX == 0);
/* Program proven to be relaxed for X86, model checker says YES. */
y = y$flush_delayed ? y$mem_tmp : y;
/* Program proven to be relaxed for X86, model checker says YES. */
y$flush_delayed = FALSE;
__VERIFIER_atomic_end();
/* Program proven to be relaxed for X86, model checker says YES. */
__VERIFIER_assert(main$tmp_guard1);
return 0;
}
|
the_stack_data/23575421.c
|
/* Copyright (c) 2017, Piotr Durlej
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <string.h>
int strcmp(const char *s1, const char *s2)
{
const unsigned char *u1 = (const unsigned char *)s1,
*u2 = (const unsigned char *)s2;
for (;;)
{
if (*u1 < *u2)
return -1;
if (*u1 > *u2)
return 1;
if (!*u1)
return 0;
u1++;
u2++;
}
}
|
the_stack_data/150143689.c
|
#if 0 /* in case someone actually tries to compile this */
/* example.c - an example of using libpng
* Last changed in libpng 1.2.1 December 7, 2001.
* This file has been placed in the public domain by the authors.
* Maintained 1998-2007 Glenn Randers-Pehrson
* Maintained 1996, 1997 Andreas Dilger)
* Written 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*/
/* This is an example of how to use libpng to read and write PNG files.
* The file libpng.txt is much more verbose then this. If you have not
* read it, do so first. This was designed to be a starting point of an
* implementation. This is not officially part of libpng, is hereby placed
* in the public domain, and therefore does not require a copyright notice.
*
* This file does not currently compile, because it is missing certain
* parts, like allocating memory to hold an image. You will have to
* supply these parts to get it to compile. For an example of a minimal
* working PNG reader/writer, see pngtest.c, included in this distribution;
* see also the programs in the contrib directory.
*/
#include "png.h"
/* The png_jmpbuf() macro, used in error handling, became available in
* libpng version 1.0.6. If you want to be able to run your code with older
* versions of libpng, you must define the macro yourself (but only if it
* is not already defined by libpng!).
*/
#ifndef png_jmpbuf
# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf)
#endif
/* Check to see if a file is a PNG file using png_sig_cmp(). png_sig_cmp()
* returns zero if the image is a PNG and nonzero if it isn't a PNG.
*
* The function check_if_png() shown here, but not used, returns nonzero (true)
* if the file can be opened and is a PNG, 0 (false) otherwise.
*
* If this call is successful, and you are going to keep the file open,
* you should call png_set_sig_bytes(png_ptr, PNG_BYTES_TO_CHECK); once
* you have created the png_ptr, so that libpng knows your application
* has read that many bytes from the start of the file. Make sure you
* don't call png_set_sig_bytes() with more than 8 bytes read or give it
* an incorrect number of bytes read, or you will either have read too
* many bytes (your fault), or you are telling libpng to read the wrong
* number of magic bytes (also your fault).
*
* Many applications already read the first 2 or 4 bytes from the start
* of the image to determine the file type, so it would be easiest just
* to pass the bytes to png_sig_cmp() or even skip that if you know
* you have a PNG file, and call png_set_sig_bytes().
*/
#define PNG_BYTES_TO_CHECK 4
int check_if_png(char *file_name, FILE **fp)
{
char buf[PNG_BYTES_TO_CHECK];
/* Open the prospective PNG file. */
if ((*fp = fopen(file_name, "rb")) == NULL)
return 0;
/* Read in some of the signature bytes */
if (fread(buf, 1, PNG_BYTES_TO_CHECK, *fp) != PNG_BYTES_TO_CHECK)
return 0;
/* Compare the first PNG_BYTES_TO_CHECK bytes of the signature.
Return nonzero (true) if they match */
return(!png_sig_cmp(buf, (png_size_t)0, PNG_BYTES_TO_CHECK));
}
/* Read a PNG file. You may want to return an error code if the read
* fails (depending upon the failure). There are two "prototypes" given
* here - one where we are given the filename, and we need to open the
* file, and the other where we are given an open file (possibly with
* some or all of the magic bytes read - see comments above).
*/
#ifdef open_file /* prototype 1 */
void read_png(char *file_name) /* We need to open the file */
{
png_structp png_ptr;
png_infop info_ptr;
unsigned int sig_read = 0;
png_uint_32 width, height;
int bit_depth, color_type, interlace_type;
FILE *fp;
if ((fp = fopen(file_name, "rb")) == NULL)
return (ERROR);
#else no_open_file /* prototype 2 */
void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
{
png_structp png_ptr;
png_infop info_ptr;
png_uint_32 width, height;
int bit_depth, color_type, interlace_type;
#endif no_open_file /* only use one prototype! */
/* Create and initialize the png_struct with the desired error handler
* functions. If you want to use the default stderr and longjump method,
* you can supply NULL for the last three parameters. We also supply the
* the compiler header file version, so that we know if the application
* was compiled with a compatible version of the library. REQUIRED
*/
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
png_voidp user_error_ptr, user_error_fn, user_warning_fn);
if (png_ptr == NULL)
{
fclose(fp);
return (ERROR);
}
/* Allocate/initialize the memory for image information. REQUIRED. */
info_ptr = png_create_info_struct(png_ptr);
if (info_ptr == NULL)
{
fclose(fp);
png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL);
return (ERROR);
}
/* Set error handling if you are using the setjmp/longjmp method (this is
* the normal method of doing things with libpng). REQUIRED unless you
* set up your own error handlers in the png_create_read_struct() earlier.
*/
if (setjmp(png_jmpbuf(png_ptr)))
{
/* Free all of the memory associated with the png_ptr and info_ptr */
png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL);
fclose(fp);
/* If we get here, we had a problem reading the file */
return (ERROR);
}
/* One of the following I/O initialization methods is REQUIRED */
#ifdef streams /* PNG file I/O method 1 */
/* Set up the input control if you are using standard C streams */
png_init_io(png_ptr, fp);
#else no_streams /* PNG file I/O method 2 */
/* If you are using replacement read functions, instead of calling
* png_init_io() here you would call:
*/
png_set_read_fn(png_ptr, (void *)user_io_ptr, user_read_fn);
/* where user_io_ptr is a structure you want available to the callbacks */
#endif no_streams /* Use only one I/O method! */
/* If we have already read some of the signature */
png_set_sig_bytes(png_ptr, sig_read);
#ifdef hilevel
/*
* If you have enough memory to read in the entire image at once,
* and you need to specify only transforms that can be controlled
* with one of the PNG_TRANSFORM_* bits (this presently excludes
* dithering, filling, setting background, and doing gamma
* adjustment), then you can read the entire image (including
* pixels) into the info structure with this call:
*/
png_read_png(png_ptr, info_ptr, png_transforms, png_voidp_NULL);
#else
/* OK, you're doing it the hard way, with the lower-level functions */
/* The call to png_read_info() gives us all of the information from the
* PNG file before the first IDAT (image data chunk). REQUIRED
*/
png_read_info(png_ptr, info_ptr);
png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type,
&interlace_type, int_p_NULL, int_p_NULL);
/* Set up the data transformations you want. Note that these are all
* optional. Only call them if you want/need them. Many of the
* transformations only work on specific types of images, and many
* are mutually exclusive.
*/
/* tell libpng to strip 16 bit/color files down to 8 bits/color */
png_set_strip_16(png_ptr);
/* Strip alpha bytes from the input data without combining with the
* background (not recommended).
*/
png_set_strip_alpha(png_ptr);
/* Extract multiple pixels with bit depths of 1, 2, and 4 from a single
* byte into separate bytes (useful for paletted and grayscale images).
*/
png_set_packing(png_ptr);
/* Change the order of packed pixels to least significant bit first
* (not useful if you are using png_set_packing). */
png_set_packswap(png_ptr);
/* Expand paletted colors into true RGB triplets */
if (color_type == PNG_COLOR_TYPE_PALETTE)
png_set_palette_to_rgb(png_ptr);
/* Expand grayscale images to the full 8 bits from 1, 2, or 4 bits/pixel */
if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8)
png_set_gray_1_2_4_to_8(png_ptr);
/* Expand paletted or RGB images with transparency to full alpha channels
* so the data will be available as RGBA quartets.
*/
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
png_set_tRNS_to_alpha(png_ptr);
/* Set the background color to draw transparent and alpha images over.
* It is possible to set the red, green, and blue components directly
* for paletted images instead of supplying a palette index. Note that
* even if the PNG file supplies a background, you are not required to
* use it - you should use the (solid) application background if it has one.
*/
png_color_16 my_background, *image_background;
if (png_get_bKGD(png_ptr, info_ptr, &image_background))
png_set_background(png_ptr, image_background,
PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
else
png_set_background(png_ptr, &my_background,
PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
/* Some suggestions as to how to get a screen gamma value */
/* Note that screen gamma is the display_exponent, which includes
* the CRT_exponent and any correction for viewing conditions */
if (/* We have a user-defined screen gamma value */)
{
screen_gamma = user-defined screen_gamma;
}
/* This is one way that applications share the same screen gamma value */
else if ((gamma_str = getenv("SCREEN_GAMMA")) != NULL)
{
screen_gamma = atof(gamma_str);
}
/* If we don't have another value */
else
{
screen_gamma = 2.2; /* A good guess for a PC monitors in a dimly
lit room */
screen_gamma = 1.7 or 1.0; /* A good guess for Mac systems */
}
/* Tell libpng to handle the gamma conversion for you. The final call
* is a good guess for PC generated images, but it should be configurable
* by the user at run time by the user. It is strongly suggested that
* your application support gamma correction.
*/
int intent;
if (png_get_sRGB(png_ptr, info_ptr, &intent))
png_set_gamma(png_ptr, screen_gamma, 0.45455);
else
{
double image_gamma;
if (png_get_gAMA(png_ptr, info_ptr, &image_gamma))
png_set_gamma(png_ptr, screen_gamma, image_gamma);
else
png_set_gamma(png_ptr, screen_gamma, 0.45455);
}
/* Dither RGB files down to 8 bit palette or reduce palettes
* to the number of colors available on your screen.
*/
if (color_type & PNG_COLOR_MASK_COLOR)
{
int num_palette;
png_colorp palette;
/* This reduces the image to the application supplied palette */
if (/* we have our own palette */)
{
/* An array of colors to which the image should be dithered */
png_color std_color_cube[MAX_SCREEN_COLORS];
png_set_dither(png_ptr, std_color_cube, MAX_SCREEN_COLORS,
MAX_SCREEN_COLORS, png_uint_16p_NULL, 0);
}
/* This reduces the image to the palette supplied in the file */
else if (png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette))
{
png_uint_16p histogram = NULL;
png_get_hIST(png_ptr, info_ptr, &histogram);
png_set_dither(png_ptr, palette, num_palette,
max_screen_colors, histogram, 0);
}
}
/* invert monochrome files to have 0 as white and 1 as black */
png_set_invert_mono(png_ptr);
/* If you want to shift the pixel values from the range [0,255] or
* [0,65535] to the original [0,7] or [0,31], or whatever range the
* colors were originally in:
*/
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_sBIT))
{
png_color_8p sig_bit;
png_get_sBIT(png_ptr, info_ptr, &sig_bit);
png_set_shift(png_ptr, sig_bit);
}
/* flip the RGB pixels to BGR (or RGBA to BGRA) */
if (color_type & PNG_COLOR_MASK_COLOR)
png_set_bgr(png_ptr);
/* swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */
png_set_swap_alpha(png_ptr);
/* swap bytes of 16 bit files to least significant byte first */
png_set_swap(png_ptr);
/* Add filler (or alpha) byte (before/after each RGB triplet) */
png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER);
/* Turn on interlace handling. REQUIRED if you are not using
* png_read_image(). To see how to handle interlacing passes,
* see the png_read_row() method below:
*/
number_passes = png_set_interlace_handling(png_ptr);
/* Optional call to gamma correct and add the background to the palette
* and update info structure. REQUIRED if you are expecting libpng to
* update the palette for you (ie you selected such a transform above).
*/
png_read_update_info(png_ptr, info_ptr);
/* Allocate the memory to hold the image using the fields of info_ptr. */
/* The easiest way to read the image: */
png_bytep row_pointers[height];
for (row = 0; row < height; row++)
{
row_pointers[row] = png_malloc(png_ptr, png_get_rowbytes(png_ptr,
info_ptr));
}
/* Now it's time to read the image. One of these methods is REQUIRED */
#ifdef entire /* Read the entire image in one go */
png_read_image(png_ptr, row_pointers);
#else no_entire /* Read the image one or more scanlines at a time */
/* The other way to read images - deal with interlacing: */
for (pass = 0; pass < number_passes; pass++)
{
#ifdef single /* Read the image a single row at a time */
for (y = 0; y < height; y++)
{
png_read_rows(png_ptr, &row_pointers[y], png_bytepp_NULL, 1);
}
#else no_single /* Read the image several rows at a time */
for (y = 0; y < height; y += number_of_rows)
{
#ifdef sparkle /* Read the image using the "sparkle" effect. */
png_read_rows(png_ptr, &row_pointers[y], png_bytepp_NULL,
number_of_rows);
#else no_sparkle /* Read the image using the "rectangle" effect */
png_read_rows(png_ptr, png_bytepp_NULL, &row_pointers[y],
number_of_rows);
#endif no_sparkle /* use only one of these two methods */
}
/* if you want to display the image after every pass, do
so here */
#endif no_single /* use only one of these two methods */
}
#endif no_entire /* use only one of these two methods */
/* read rest of file, and get additional chunks in info_ptr - REQUIRED */
png_read_end(png_ptr, info_ptr);
#endif hilevel
/* At this point you have read the entire image */
/* clean up after the read, and free any memory allocated - REQUIRED */
png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL);
/* close the file */
fclose(fp);
/* that's it */
return (OK);
}
/* progressively read a file */
int
initialize_png_reader(png_structp *png_ptr, png_infop *info_ptr)
{
/* Create and initialize the png_struct with the desired error handler
* functions. If you want to use the default stderr and longjump method,
* you can supply NULL for the last three parameters. We also check that
* the library version is compatible in case we are using dynamically
* linked libraries.
*/
*png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
png_voidp user_error_ptr, user_error_fn, user_warning_fn);
if (*png_ptr == NULL)
{
*info_ptr = NULL;
return (ERROR);
}
*info_ptr = png_create_info_struct(png_ptr);
if (*info_ptr == NULL)
{
png_destroy_read_struct(png_ptr, info_ptr, png_infopp_NULL);
return (ERROR);
}
if (setjmp(png_jmpbuf((*png_ptr))))
{
png_destroy_read_struct(png_ptr, info_ptr, png_infopp_NULL);
return (ERROR);
}
/* This one's new. You will need to provide all three
* function callbacks, even if you aren't using them all.
* If you aren't using all functions, you can specify NULL
* parameters. Even when all three functions are NULL,
* you need to call png_set_progressive_read_fn().
* These functions shouldn't be dependent on global or
* static variables if you are decoding several images
* simultaneously. You should store stream specific data
* in a separate struct, given as the second parameter,
* and retrieve the pointer from inside the callbacks using
* the function png_get_progressive_ptr(png_ptr).
*/
png_set_progressive_read_fn(*png_ptr, (void *)stream_data,
info_callback, row_callback, end_callback);
return (OK);
}
int
process_data(png_structp *png_ptr, png_infop *info_ptr,
png_bytep buffer, png_uint_32 length)
{
if (setjmp(png_jmpbuf((*png_ptr))))
{
/* Free the png_ptr and info_ptr memory on error */
png_destroy_read_struct(png_ptr, info_ptr, png_infopp_NULL);
return (ERROR);
}
/* This one's new also. Simply give it chunks of data as
* they arrive from the data stream (in order, of course).
* On Segmented machines, don't give it any more than 64K.
* The library seems to run fine with sizes of 4K, although
* you can give it much less if necessary (I assume you can
* give it chunks of 1 byte, but I haven't tried with less
* than 256 bytes yet). When this function returns, you may
* want to display any rows that were generated in the row
* callback, if you aren't already displaying them there.
*/
png_process_data(*png_ptr, *info_ptr, buffer, length);
return (OK);
}
info_callback(png_structp png_ptr, png_infop info)
{
/* do any setup here, including setting any of the transformations
* mentioned in the Reading PNG files section. For now, you _must_
* call either png_start_read_image() or png_read_update_info()
* after all the transformations are set (even if you don't set
* any). You may start getting rows before png_process_data()
* returns, so this is your last chance to prepare for that.
*/
}
row_callback(png_structp png_ptr, png_bytep new_row,
png_uint_32 row_num, int pass)
{
/*
* This function is called for every row in the image. If the
* image is interlaced, and you turned on the interlace handler,
* this function will be called for every row in every pass.
*
* In this function you will receive a pointer to new row data from
* libpng called new_row that is to replace a corresponding row (of
* the same data format) in a buffer allocated by your application.
*
* The new row data pointer new_row may be NULL, indicating there is
* no new data to be replaced (in cases of interlace loading).
*
* If new_row is not NULL then you need to call
* png_progressive_combine_row() to replace the corresponding row as
* shown below:
*/
/* Check if row_num is in bounds. */
if((row_num >= 0) && (row_num < height))
{
/* Get pointer to corresponding row in our
* PNG read buffer.
*/
png_bytep old_row = ((png_bytep *)our_data)[row_num];
/* If both rows are allocated then copy the new row
* data to the corresponding row data.
*/
if((old_row != NULL) && (new_row != NULL))
png_progressive_combine_row(png_ptr, old_row, new_row);
}
/*
* The rows and passes are called in order, so you don't really
* need the row_num and pass, but I'm supplying them because it
* may make your life easier.
*
* For the non-NULL rows of interlaced images, you must call
* png_progressive_combine_row() passing in the new row and the
* old row, as demonstrated above. You can call this function for
* NULL rows (it will just return) and for non-interlaced images
* (it just does the png_memcpy for you) if it will make the code
* easier. Thus, you can just do this for all cases:
*/
png_progressive_combine_row(png_ptr, old_row, new_row);
/* where old_row is what was displayed for previous rows. Note
* that the first pass (pass == 0 really) will completely cover
* the old row, so the rows do not have to be initialized. After
* the first pass (and only for interlaced images), you will have
* to pass the current row as new_row, and the function will combine
* the old row and the new row.
*/
}
end_callback(png_structp png_ptr, png_infop info)
{
/* this function is called when the whole image has been read,
* including any chunks after the image (up to and including
* the IEND). You will usually have the same info chunk as you
* had in the header, although some data may have been added
* to the comments and time fields.
*
* Most people won't do much here, perhaps setting a flag that
* marks the image as finished.
*/
}
/* write a png file */
void write_png(char *file_name /* , ... other image information ... */)
{
FILE *fp;
png_structp png_ptr;
png_infop info_ptr;
png_colorp palette;
/* open the file */
fp = fopen(file_name, "wb");
if (fp == NULL)
return (ERROR);
/* Create and initialize the png_struct with the desired error handler
* functions. If you want to use the default stderr and longjump method,
* you can supply NULL for the last three parameters. We also check that
* the library version is compatible with the one used at compile time,
* in case we are using dynamically linked libraries. REQUIRED.
*/
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
png_voidp user_error_ptr, user_error_fn, user_warning_fn);
if (png_ptr == NULL)
{
fclose(fp);
return (ERROR);
}
/* Allocate/initialize the image information data. REQUIRED */
info_ptr = png_create_info_struct(png_ptr);
if (info_ptr == NULL)
{
fclose(fp);
png_destroy_write_struct(&png_ptr, png_infopp_NULL);
return (ERROR);
}
/* Set error handling. REQUIRED if you aren't supplying your own
* error handling functions in the png_create_write_struct() call.
*/
if (setjmp(png_jmpbuf(png_ptr)))
{
/* If we get here, we had a problem reading the file */
fclose(fp);
png_destroy_write_struct(&png_ptr, &info_ptr);
return (ERROR);
}
/* One of the following I/O initialization functions is REQUIRED */
#ifdef streams /* I/O initialization method 1 */
/* set up the output control if you are using standard C streams */
png_init_io(png_ptr, fp);
#else no_streams /* I/O initialization method 2 */
/* If you are using replacement read functions, instead of calling
* png_init_io() here you would call */
png_set_write_fn(png_ptr, (void *)user_io_ptr, user_write_fn,
user_IO_flush_function);
/* where user_io_ptr is a structure you want available to the callbacks */
#endif no_streams /* only use one initialization method */
#ifdef hilevel
/* This is the easy way. Use it if you already have all the
* image info living info in the structure. You could "|" many
* PNG_TRANSFORM flags into the png_transforms integer here.
*/
png_write_png(png_ptr, info_ptr, png_transforms, png_voidp_NULL);
#else
/* This is the hard way */
/* Set the image information here. Width and height are up to 2^31,
* bit_depth is one of 1, 2, 4, 8, or 16, but valid values also depend on
* the color_type selected. color_type is one of PNG_COLOR_TYPE_GRAY,
* PNG_COLOR_TYPE_GRAY_ALPHA, PNG_COLOR_TYPE_PALETTE, PNG_COLOR_TYPE_RGB,
* or PNG_COLOR_TYPE_RGB_ALPHA. interlace is either PNG_INTERLACE_NONE or
* PNG_INTERLACE_ADAM7, and the compression_type and filter_type MUST
* currently be PNG_COMPRESSION_TYPE_BASE and PNG_FILTER_TYPE_BASE. REQUIRED
*/
png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, PNG_COLOR_TYPE_???,
PNG_INTERLACE_????, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
/* set the palette if there is one. REQUIRED for indexed-color images */
palette = (png_colorp)png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH
* png_sizeof (png_color));
/* ... set palette colors ... */
png_set_PLTE(png_ptr, info_ptr, palette, PNG_MAX_PALETTE_LENGTH);
/* You must not free palette here, because png_set_PLTE only makes a link to
the palette that you malloced. Wait until you are about to destroy
the png structure. */
/* optional significant bit chunk */
/* if we are dealing with a grayscale image then */
sig_bit.gray = true_bit_depth;
/* otherwise, if we are dealing with a color image then */
sig_bit.red = true_red_bit_depth;
sig_bit.green = true_green_bit_depth;
sig_bit.blue = true_blue_bit_depth;
/* if the image has an alpha channel then */
sig_bit.alpha = true_alpha_bit_depth;
png_set_sBIT(png_ptr, info_ptr, sig_bit);
/* Optional gamma chunk is strongly suggested if you have any guess
* as to the correct gamma of the image.
*/
png_set_gAMA(png_ptr, info_ptr, gamma);
/* Optionally write comments into the image */
text_ptr[0].key = "Title";
text_ptr[0].text = "Mona Lisa";
text_ptr[0].compression = PNG_TEXT_COMPRESSION_NONE;
text_ptr[1].key = "Author";
text_ptr[1].text = "Leonardo DaVinci";
text_ptr[1].compression = PNG_TEXT_COMPRESSION_NONE;
text_ptr[2].key = "Description";
text_ptr[2].text = "<long text>";
text_ptr[2].compression = PNG_TEXT_COMPRESSION_zTXt;
#ifdef PNG_iTXt_SUPPORTED
text_ptr[0].lang = NULL;
text_ptr[1].lang = NULL;
text_ptr[2].lang = NULL;
#endif
png_set_text(png_ptr, info_ptr, text_ptr, 3);
/* other optional chunks like cHRM, bKGD, tRNS, tIME, oFFs, pHYs, */
/* note that if sRGB is present the gAMA and cHRM chunks must be ignored
* on read and must be written in accordance with the sRGB profile */
/* Write the file header information. REQUIRED */
png_write_info(png_ptr, info_ptr);
/* If you want, you can write the info in two steps, in case you need to
* write your private chunk ahead of PLTE:
*
* png_write_info_before_PLTE(write_ptr, write_info_ptr);
* write_my_chunk();
* png_write_info(png_ptr, info_ptr);
*
* However, given the level of known- and unknown-chunk support in 1.1.0
* and up, this should no longer be necessary.
*/
/* Once we write out the header, the compression type on the text
* chunks gets changed to PNG_TEXT_COMPRESSION_NONE_WR or
* PNG_TEXT_COMPRESSION_zTXt_WR, so it doesn't get written out again
* at the end.
*/
/* set up the transformations you want. Note that these are
* all optional. Only call them if you want them.
*/
/* invert monochrome pixels */
png_set_invert_mono(png_ptr);
/* Shift the pixels up to a legal bit depth and fill in
* as appropriate to correctly scale the image.
*/
png_set_shift(png_ptr, &sig_bit);
/* pack pixels into bytes */
png_set_packing(png_ptr);
/* swap location of alpha bytes from ARGB to RGBA */
png_set_swap_alpha(png_ptr);
/* Get rid of filler (OR ALPHA) bytes, pack XRGB/RGBX/ARGB/RGBA into
* RGB (4 channels -> 3 channels). The second parameter is not used.
*/
png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE);
/* flip BGR pixels to RGB */
png_set_bgr(png_ptr);
/* swap bytes of 16-bit files to most significant byte first */
png_set_swap(png_ptr);
/* swap bits of 1, 2, 4 bit packed pixel formats */
png_set_packswap(png_ptr);
/* turn on interlace handling if you are not using png_write_image() */
if (interlacing)
number_passes = png_set_interlace_handling(png_ptr);
else
number_passes = 1;
/* The easiest way to write the image (you may have a different memory
* layout, however, so choose what fits your needs best). You need to
* use the first method if you aren't handling interlacing yourself.
*/
png_uint_32 k, height, width;
png_byte image[height][width*bytes_per_pixel];
png_bytep row_pointers[height];
if (height > PNG_UINT_32_MAX/png_sizeof(png_bytep))
png_error (png_ptr, "Image is too tall to process in memory");
for (k = 0; k < height; k++)
row_pointers[k] = image + k*width*bytes_per_pixel;
/* One of the following output methods is REQUIRED */
#ifdef entire /* write out the entire image data in one call */
png_write_image(png_ptr, row_pointers);
/* the other way to write the image - deal with interlacing */
#else no_entire /* write out the image data by one or more scanlines */
/* The number of passes is either 1 for non-interlaced images,
* or 7 for interlaced images.
*/
for (pass = 0; pass < number_passes; pass++)
{
/* Write a few rows at a time. */
png_write_rows(png_ptr, &row_pointers[first_row], number_of_rows);
/* If you are only writing one row at a time, this works */
for (y = 0; y < height; y++)
{
png_write_rows(png_ptr, &row_pointers[y], 1);
}
}
#endif no_entire /* use only one output method */
/* You can write optional chunks like tEXt, zTXt, and tIME at the end
* as well. Shouldn't be necessary in 1.1.0 and up as all the public
* chunks are supported and you can use png_set_unknown_chunks() to
* register unknown chunks into the info structure to be written out.
*/
/* It is REQUIRED to call this to finish writing the rest of the file */
png_write_end(png_ptr, info_ptr);
#endif hilevel
/* If you png_malloced a palette, free it here (don't free info_ptr->palette,
as recommended in versions 1.0.5m and earlier of this example; if
libpng mallocs info_ptr->palette, libpng will free it). If you
allocated it with malloc() instead of png_malloc(), use free() instead
of png_free(). */
png_free(png_ptr, palette);
palette=NULL;
/* Similarly, if you png_malloced any data that you passed in with
png_set_something(), such as a hist or trans array, free it here,
when you can be sure that libpng is through with it. */
png_free(png_ptr, trans);
trans=NULL;
/* clean up after the write, and free any memory allocated */
png_destroy_write_struct(&png_ptr, &info_ptr);
/* close the file */
fclose(fp);
/* that's it */
return (OK);
}
#endif /* if 0 */
|
the_stack_data/130612.c
|
#include <stdio.h>
#include <unistd.h>
#include <termios.h>
// http://shtrom.ssji.net/skb/getc.html
int main()
{
struct termios old_tio, new_tio;
unsigned char c;
/* get the terminal settings for stdin */
tcgetattr(STDIN_FILENO, &old_tio);
/* we want to keep the old setting to restore them a the end */
new_tio = old_tio;
/* disable canonical mode (buffered i/o) and local echo */
new_tio.c_lflag &= (~ICANON & ~ECHO);
printf("c_lflag: %ld\n", new_tio.c_lflag);
/* set the new settings immediately */
tcsetattr(STDIN_FILENO, TCSANOW, &new_tio);
do {
c = getchar();
printf("*");
printf("%d ",c);
} while (c != 'q');
/* restore the former settings */
tcsetattr(STDIN_FILENO, TCSANOW, &old_tio);
return 0;
}
|
the_stack_data/117154.c
|
#include <stdio.h>
int main ()
{
int d1, d2, d3, d4;
d1= 65;
d2= 66;
d3= d2++ + ++d1;
d4= d3++;
printf ("%d %d %d %d\n", d1, d2, d3, d4);
return 0;
}
|
the_stack_data/150142501.c
|
/*
* Copyright (c) 2014 Jan-Piet Mens <jpmens()gmail.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of mosquitto nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef BE_POSTGRES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <mosquitto.h>
#include "be-postgres.h"
#include "log.h"
#include "hash.h"
#include "backends.h"
#include <arpa/inet.h>
struct pg_backend {
PGconn *conn;
char *host;
char *port;
char *dbname;
char *user;
char *pass;
char *userquery; // MUST return 1 row, 1 column
char *superquery; // MUST return 1 row, 1 column, [0, 1]
char *aclquery; // MAY return n rows, 1 column, string
};
void *be_pg_init()
{
struct pg_backend *conf;
char *host, *user, *pass, *dbname, *p, *port;
char *userquery;
_log(LOG_DEBUG, "}}}} POSTGRES");
host = p_stab("host");
p = p_stab("port");
user = p_stab("user");
pass = p_stab("pass");
dbname = p_stab("dbname");
host = (host) ? host : strdup("");
port = (p) ? p : strdup("");
userquery = p_stab("userquery");
if (!userquery) {
_fatal("Mandatory option 'userquery' is missing");
return (NULL);
}
if ((conf = (struct pg_backend *)malloc(sizeof(struct pg_backend))) == NULL)
return (NULL);
conf->conn = NULL;
conf->host = host;
conf->port = port;
conf->user = user;
conf->pass = pass;
conf->dbname = dbname;
conf->userquery = userquery;
conf->superquery = p_stab("superquery");
conf->aclquery = p_stab("aclquery");
_log( LOG_DEBUG, "HERE: %s", conf->superquery );
_log( LOG_DEBUG, "HERE: %s", conf->aclquery );
char *connect_string = NULL;
conf->conn = PQsetdbLogin(conf->host, conf->port, NULL, NULL, conf->dbname, conf->user, conf->pass );
if (PQstatus(conf->conn) == CONNECTION_BAD) {
free(conf);
free(connect_string);
_fatal("We were unable to connect to the database");
return (NULL);
}
free(connect_string);
return ((void *)conf);
}
void be_pg_destroy(void *handle)
{
struct pg_backend *conf = (struct pg_backend *)handle;
if (conf) {
PQfinish(conf->conn);
if (conf->userquery)
free(conf->userquery);
if (conf->superquery)
free(conf->superquery);
if (conf->aclquery)
free(conf->aclquery);
free(conf);
}
}
char *be_pg_getuser(void *handle, const char *username, const char *password, int *authenticated)
{
struct pg_backend *conf = (struct pg_backend *)handle;
char *value = NULL, *v = NULL;
long nrows;
PGresult *res = NULL;
_log(LOG_DEBUG, "GETTING USERS: %s", username );
if (!conf || !conf->userquery || !username || !*username)
return (NULL);
const char *values[1] = {username};
int lengths[1] = {strlen(username)};
int binary[1] = {0};
res = PQexecParams(conf->conn, conf->userquery, 1, NULL, values, lengths, binary, 0);
if ( PQresultStatus(res) != PGRES_TUPLES_OK )
{
_log(LOG_DEBUG, "%s\n", PQresultErrorMessage(res));
goto out;
}
if ((nrows = PQntuples(res)) != 1) {
// DEBUG fprintf(stderr, "rowcount = %ld; not ok\n", nrows);
goto out;
}
if (PQnfields(res) != 1) {
// DEBUG fprintf(stderr, "numfields not ok\n");
goto out;
}
if ((v = PQgetvalue(res,0,0)) == NULL) {
goto out;
}
value = (v) ? strdup(v) : NULL;
out:
PQclear(res);
return (value);
}
/*
* Return T/F if user is superuser
*/
int be_pg_superuser(void *handle, const char *username)
{
struct pg_backend *conf = (struct pg_backend *)handle;
char *v = NULL;
long nrows;
int issuper = FALSE;
PGresult *res = NULL;
_log( LOG_DEBUG, "SUPERUSER: %s", username );
if (!conf || !conf->superquery || !username || !*username)
return (FALSE);
// query for postgres $1 instead of %s
const char *values[1] = {username};
int lengths[1] = {strlen(username)};
int binary[1] = {0};
res = PQexecParams(conf->conn, conf->superquery, 1, NULL, values, lengths, binary, 0);
if ( PQresultStatus(res) != PGRES_TUPLES_OK )
{
fprintf(stderr, "%s\n", PQresultErrorMessage(res));
issuper = BACKEND_ERROR;
goto out;
}
if ((nrows = PQntuples(res)) != 1) {
goto out;
}
if (PQnfields(res) != 1) {
// DEBUG fprintf(stderr, "numfields not ok\n");
goto out;
}
if ((v = PQgetvalue(res,0,0)) == NULL) {
goto out;
}
issuper = atoi(v);
out:
_log(LOG_DEBUG, "user is %d", issuper );
PQclear(res);
return (issuper);
}
/*
* Check ACL.
* username is the name of the connected user attempting
* to access
* topic is the topic user is trying to access (may contain
* wildcards)
* acc is desired type of access: read/write
* for subscriptions (READ) (1)
* for publish (WRITE) (2)
*
* SELECT topic FROM table WHERE username = '%s' AND (acc & %d) // may user SUB or PUB topic?
* SELECT topic FROM table WHERE username = '%s' // ignore ACC
*/
int be_pg_aclcheck(void *handle, const char *clientid, const char *username, const char *topic, int acc)
{
struct pg_backend *conf = (struct pg_backend *)handle;
char *v = NULL;
int match = 0;
bool bf;
PGresult *res = NULL;
_log( LOG_DEBUG, "USERNAME: %s, TOPIC: %s, acc: %d", username, topic, acc );
if (!conf || !conf->aclquery)
return (FALSE);
const int buflen = 11; // 10 for 2^32 + 1
char accbuffer[buflen];
snprintf(accbuffer, buflen, "%d", acc);
const char *values[2] = {username, accbuffer};
int lengths[2] = {strlen(username), buflen};
res = PQexecParams(conf->conn, conf->aclquery, 2, NULL, values, lengths, NULL, 0);
if ( PQresultStatus(res) != PGRES_TUPLES_OK )
{
fprintf(stderr, "%s\n", PQresultErrorMessage(res));
match = BACKEND_ERROR;
goto out;
}
if (PQnfields(res) != 1) {
fprintf(stderr, "numfields not ok\n");
goto out;
}
int rec_count = PQntuples(res);
int row = 0;
for ( row = 0; row < rec_count; row++ ) {
if ( (v = PQgetvalue(res,row,0) ) != NULL) {
/* Check mosquitto_match_topic. If true,
* if true, set match and break out of loop. */
char *expanded;
t_expand(clientid, username, v, &expanded);
if (expanded && *expanded) {
mosquitto_topic_matches_sub(expanded, topic, &bf);
match |= bf;
_log(LOG_DEBUG, " postgres: topic_matches(%s, %s) == %d",
expanded, v, bf);
free(expanded);
}
}
if ( match != 0 )
{
break;
}
}
out:
PQclear(res);
return (match);
}
#endif /* BE_POSTGRES */
|
the_stack_data/212642506.c
|
#include <stdio.h>
int main(void) {
int n, bag = 0;
scanf("%d", &n);
while (n % 5 && n >= 3) {
n -= 3;
bag++;
}
printf("%d", n % 5 ? -1 : bag + n / 5);
return 0;
}
|
the_stack_data/156393730.c
|
#include <stdlib.h>
#include <stdio.h>
int main()
{
printf("Running test 2 to exercise malloc and free\n");
char * ptr = ( char * ) malloc ( 65535 );
char * ptr_array[1024];
int i;
for ( i = 0; i < 1024; i++ )
{
ptr_array[i] = ( char * ) malloc ( 1024 );
ptr_array[i] = ptr_array[i];
}
free( ptr );
for ( i = 0; i < 1024; i++ )
{
if( i % 2 == 0 )
{
free( ptr_array[i] );
}
}
ptr = ( char * ) malloc ( 65535 );
free( ptr );
return 0;
}
|
the_stack_data/161081178.c
|
/*
* Copyright (C) 2015-2018 Alibaba Group Holding Limited
*/
#ifdef SUPPORT_TLS
#if !defined(MBEDTLS_CONFIG_FILE)
#include "mbedtls/config.h"
#else
#include MBEDTLS_CONFIG_FILE
#endif
#if defined(MBEDTLS_PLATFORM_C)
#include "mbedtls/platform.h"
#if defined(MBEDTLS_PLATFORM_MEMORY)
#if !defined(MBEDTLS_PLATFORM_STD_CALLOC)
static void *platform_calloc_uninit( size_t n, size_t size )
{
((void) n);
((void) size);
return( NULL );
}
#define MBEDTLS_PLATFORM_STD_CALLOC platform_calloc_uninit
#endif /* !MBEDTLS_PLATFORM_STD_CALLOC */
#if !defined(MBEDTLS_PLATFORM_STD_FREE)
static void platform_free_uninit( void *ptr )
{
((void) ptr);
}
#define MBEDTLS_PLATFORM_STD_FREE platform_free_uninit
#endif /* !MBEDTLS_PLATFORM_STD_FREE */
void * (*mbedtls_calloc)( size_t, size_t ) = MBEDTLS_PLATFORM_STD_CALLOC;
void (*mbedtls_free)( void * ) = MBEDTLS_PLATFORM_STD_FREE;
int mbedtls_platform_set_calloc_free( void * (*calloc_func)( size_t, size_t ),
void (*free_func)( void * ) )
{
mbedtls_calloc = calloc_func;
mbedtls_free = free_func;
return( 0 );
}
#endif /* MBEDTLS_PLATFORM_MEMORY */
#if defined(_WIN32)
#include <stdarg.h>
int mbedtls_platform_win32_snprintf( char *s, size_t n, const char *fmt, ... )
{
int ret;
va_list argp;
/* Avoid calling the invalid parameter handler by checking ourselves */
if( s == NULL || n == 0 || fmt == NULL )
return( -1 );
va_start( argp, fmt );
#if defined(_TRUNCATE)
ret = _vsnprintf_s( s, n, _TRUNCATE, fmt, argp );
#else
ret = _vsnprintf( s, n, fmt, argp );
if( ret < 0 || (size_t) ret == n )
{
s[n-1] = '\0';
ret = -1;
}
#endif
va_end( argp );
return( ret );
}
#endif
#if defined(MBEDTLS_PLATFORM_SNPRINTF_ALT)
#if !defined(MBEDTLS_PLATFORM_STD_SNPRINTF)
/*
* Make dummy function to prevent NULL pointer dereferences
*/
static int platform_snprintf_uninit( char * s, size_t n,
const char * format, ... )
{
((void) s);
((void) n);
((void) format);
return( 0 );
}
#define MBEDTLS_PLATFORM_STD_SNPRINTF platform_snprintf_uninit
#endif /* !MBEDTLS_PLATFORM_STD_SNPRINTF */
int (*mbedtls_snprintf)( char * s, size_t n,
const char * format,
... ) = MBEDTLS_PLATFORM_STD_SNPRINTF;
int mbedtls_platform_set_snprintf( int (*snprintf_func)( char * s, size_t n,
const char * format,
... ) )
{
mbedtls_snprintf = snprintf_func;
return( 0 );
}
#endif /* MBEDTLS_PLATFORM_SNPRINTF_ALT */
#if defined(MBEDTLS_PLATFORM_PRINTF_ALT)
#if !defined(MBEDTLS_PLATFORM_STD_PRINTF)
/*
* Make dummy function to prevent NULL pointer dereferences
*/
static int platform_printf_uninit( const char *format, ... )
{
((void) format);
return( 0 );
}
#define MBEDTLS_PLATFORM_STD_PRINTF platform_printf_uninit
#endif /* !MBEDTLS_PLATFORM_STD_PRINTF */
int (*mbedtls_printf)( const char *, ... ) = MBEDTLS_PLATFORM_STD_PRINTF;
int mbedtls_platform_set_printf( int (*printf_func)( const char *, ... ) )
{
mbedtls_printf = printf_func;
return( 0 );
}
#endif /* MBEDTLS_PLATFORM_PRINTF_ALT */
#if defined(MBEDTLS_PLATFORM_FPRINTF_ALT)
#if !defined(MBEDTLS_PLATFORM_STD_FPRINTF)
/*
* Make dummy function to prevent NULL pointer dereferences
*/
static int platform_fprintf_uninit( FILE *stream, const char *format, ... )
{
((void) stream);
((void) format);
return( 0 );
}
#define MBEDTLS_PLATFORM_STD_FPRINTF platform_fprintf_uninit
#endif /* !MBEDTLS_PLATFORM_STD_FPRINTF */
int (*mbedtls_fprintf)( FILE *, const char *, ... ) =
MBEDTLS_PLATFORM_STD_FPRINTF;
int mbedtls_platform_set_fprintf( int (*fprintf_func)( FILE *, const char *, ... ) )
{
mbedtls_fprintf = fprintf_func;
return( 0 );
}
#endif /* MBEDTLS_PLATFORM_FPRINTF_ALT */
#if defined(MBEDTLS_PLATFORM_EXIT_ALT)
#if !defined(MBEDTLS_PLATFORM_STD_EXIT)
/*
* Make dummy function to prevent NULL pointer dereferences
*/
static void platform_exit_uninit( int status )
{
((void) status);
}
#define MBEDTLS_PLATFORM_STD_EXIT platform_exit_uninit
#endif /* !MBEDTLS_PLATFORM_STD_EXIT */
void (*mbedtls_exit)( int status ) = MBEDTLS_PLATFORM_STD_EXIT;
int mbedtls_platform_set_exit( void (*exit_func)( int status ) )
{
mbedtls_exit = exit_func;
return( 0 );
}
#endif /* MBEDTLS_PLATFORM_EXIT_ALT */
#if defined(MBEDTLS_HAVE_TIME)
#if defined(MBEDTLS_PLATFORM_TIME_ALT)
#if !defined(MBEDTLS_PLATFORM_STD_TIME)
/*
* Make dummy function to prevent NULL pointer dereferences
*/
static mbedtls_time_t platform_time_uninit( mbedtls_time_t* timer )
{
((void) timer);
return( 0 );
}
#define MBEDTLS_PLATFORM_STD_TIME platform_time_uninit
#endif /* !MBEDTLS_PLATFORM_STD_TIME */
mbedtls_time_t (*mbedtls_time)( mbedtls_time_t* timer ) = MBEDTLS_PLATFORM_STD_TIME;
int mbedtls_platform_set_time( mbedtls_time_t (*time_func)( mbedtls_time_t* timer ) )
{
mbedtls_time = time_func;
return( 0 );
}
#endif /* MBEDTLS_PLATFORM_TIME_ALT */
#endif /* MBEDTLS_HAVE_TIME */
#if defined(MBEDTLS_ENTROPY_NV_SEED)
#if !defined(MBEDTLS_PLATFORM_NO_STD_FUNCTIONS) && defined(MBEDTLS_FS_IO)
/* Default implementations for the platform independent seed functions use
* standard libc file functions to read from and write to a pre-defined filename
*/
int mbedtls_platform_std_nv_seed_read( unsigned char *buf, size_t buf_len )
{
FILE *file;
size_t n;
if( ( file = fopen( MBEDTLS_PLATFORM_STD_NV_SEED_FILE, "rb" ) ) == NULL )
return -1;
if( ( n = fread( buf, 1, buf_len, file ) ) != buf_len )
{
fclose( file );
return -1;
}
fclose( file );
return( (int)n );
}
int mbedtls_platform_std_nv_seed_write( unsigned char *buf, size_t buf_len )
{
FILE *file;
size_t n;
if( ( file = fopen( MBEDTLS_PLATFORM_STD_NV_SEED_FILE, "w" ) ) == NULL )
return -1;
if( ( n = fwrite( buf, 1, buf_len, file ) ) != buf_len )
{
fclose( file );
return -1;
}
fclose( file );
return( (int)n );
}
#endif /* MBEDTLS_PLATFORM_NO_STD_FUNCTIONS */
#if defined(MBEDTLS_PLATFORM_NV_SEED_ALT)
#if !defined(MBEDTLS_PLATFORM_STD_NV_SEED_READ)
/*
* Make dummy function to prevent NULL pointer dereferences
*/
static int platform_nv_seed_read_uninit( unsigned char *buf, size_t buf_len )
{
((void) buf);
((void) buf_len);
return( -1 );
}
#define MBEDTLS_PLATFORM_STD_NV_SEED_READ platform_nv_seed_read_uninit
#endif /* !MBEDTLS_PLATFORM_STD_NV_SEED_READ */
#if !defined(MBEDTLS_PLATFORM_STD_NV_SEED_WRITE)
/*
* Make dummy function to prevent NULL pointer dereferences
*/
static int platform_nv_seed_write_uninit( unsigned char *buf, size_t buf_len )
{
((void) buf);
((void) buf_len);
return( -1 );
}
#define MBEDTLS_PLATFORM_STD_NV_SEED_WRITE platform_nv_seed_write_uninit
#endif /* !MBEDTLS_PLATFORM_STD_NV_SEED_WRITE */
int (*mbedtls_nv_seed_read)( unsigned char *buf, size_t buf_len ) =
MBEDTLS_PLATFORM_STD_NV_SEED_READ;
int (*mbedtls_nv_seed_write)( unsigned char *buf, size_t buf_len ) =
MBEDTLS_PLATFORM_STD_NV_SEED_WRITE;
int mbedtls_platform_set_nv_seed(
int (*nv_seed_read_func)( unsigned char *buf, size_t buf_len ),
int (*nv_seed_write_func)( unsigned char *buf, size_t buf_len ) )
{
mbedtls_nv_seed_read = nv_seed_read_func;
mbedtls_nv_seed_write = nv_seed_write_func;
return( 0 );
}
#endif /* MBEDTLS_PLATFORM_NV_SEED_ALT */
#endif /* MBEDTLS_ENTROPY_NV_SEED */
#endif /* MBEDTLS_PLATFORM_C */
#endif
|
the_stack_data/150140852.c
|
/* Crie um programa que recebe dois valores do tipo double como inputs e calcula a hipotenusa do triângulo retângulo e exibe a saída(output) */
#include <stdio.h>
#include <math.h> // Biblioteca matemática
int main(void)
{
double a, b, c, output;
printf("Digite dois valores: ");
scanf("%lf%lf", &a, &b);
// Calcula o quadrado de a e o quadrado de b e soma ambos
c = pow(a, 2) + pow(b, 2);
// output recebe a raiz quadrada de c
output = sqrt(c);
printf("A hipotenusa é: %f\n", output);
return 0;
}
|
the_stack_data/179830139.c
|
/*
FFTE: A FAST FOURIER TRANSFORM PACKAGE
(C) COPYRIGHT SOFTWARE, 2000-2004, 2008-2014, ALL RIGHTS RESERVED
BY
DAISUKE TAKAHASHI
FACULTY OF ENGINEERING, INFORMATION AND SYSTEMS
UNIVERSITY OF TSUKUBA
1-1-1 TENNODAI, TSUKUBA, IBARAKI 305-8573, JAPAN
E-MAIL: [email protected]
WRITTEN BY DAISUKE TAKAHASHI
THIS KERNEL WAS GENERATED BY SPIRAL 8.2.0a03
*/
void dft6a_(double *Y, double *X, double *TW1, int *lp1) {
double a600, a601, a602, a603, a604, a605, a606, a607,
a608, a609, s211, s212, s213, s214, s215, s216,
s217, s218, s219, s220, s221, s222, s223, s224,
s225, s226, s227, s228, s229, s230, s231, s232,
s233, s234, s235, s236, s237, s238, s239, s240,
t494, t495, t496, t497, t498, t499, t500, t501,
t502, t503, t504, t505, t506, t507, t508, t509,
t510, t511, t512, t513;
int a593, a594, a595, a596, a597, a598, a599, a610,
l1;
l1 = *(lp1);
for(int j1 = 0; j1 < l1; j1++) {
l1 = *(lp1);
a593 = (2*j1);
s211 = X[a593];
s212 = X[(a593 + 1)];
a594 = (a593 + (2*l1));
s213 = X[a594];
s214 = X[(a594 + 1)];
a595 = (a593 + (4*l1));
s215 = X[a595];
s216 = X[(a595 + 1)];
a596 = (a593 + (6*l1));
s217 = X[a596];
s218 = X[(a596 + 1)];
a597 = (a593 + (8*l1));
s219 = X[a597];
s220 = X[(a597 + 1)];
a598 = (a593 + (10*l1));
s221 = X[a598];
s222 = X[(a598 + 1)];
t494 = (s215 + s219);
t495 = (s216 + s220);
t496 = (s211 + t494);
t497 = (s212 + t495);
t498 = (s211 - (0.5*t494));
t499 = (s212 - (0.5*t495));
s223 = (0.8660254037844386*(s216 - s220));
s224 = (0.8660254037844386*(s215 - s219));
t500 = (t498 + s223);
t501 = (t499 - s224);
t502 = (t498 - s223);
t503 = (t499 + s224);
t504 = (s217 + s221);
t505 = (s218 + s222);
t506 = (s213 + t504);
t507 = (s214 + t505);
t508 = (s213 - (0.5*t504));
t509 = (s214 - (0.5*t505));
s225 = (0.8660254037844386*(s218 - s222));
s226 = (0.8660254037844386*(s217 - s221));
t510 = (t508 + s225);
t511 = (t509 - s226);
t512 = (t508 - s225);
t513 = (t509 + s226);
s227 = ((0.5*t510) + (0.8660254037844386*t511));
s228 = ((0.5*t511) - (0.8660254037844386*t510));
s229 = ((0.8660254037844386*t513) - (0.5*t512));
s230 = ((0.8660254037844386*t512) + (0.5*t513));
s231 = (t496 - t506);
s232 = (t497 - t507);
s233 = (t500 + s227);
s234 = (t501 + s228);
s235 = (t500 - s227);
s236 = (t501 - s228);
s237 = (t502 + s229);
s238 = (t503 - s230);
s239 = (t502 - s229);
s240 = (t503 + s230);
a599 = (10*j1);
a600 = TW1[a599];
a601 = TW1[(a599 + 1)];
a602 = TW1[(a599 + 2)];
a603 = TW1[(a599 + 3)];
a604 = TW1[(a599 + 4)];
a605 = TW1[(a599 + 5)];
a606 = TW1[(a599 + 6)];
a607 = TW1[(a599 + 7)];
a608 = TW1[(a599 + 8)];
a609 = TW1[(a599 + 9)];
a610 = (12*j1);
Y[a610] = (t496 + t506);
Y[(a610 + 1)] = (t497 + t507);
Y[(a610 + 2)] = ((a600*s233) - (a601*s234));
Y[(a610 + 3)] = ((a601*s233) + (a600*s234));
Y[(a610 + 4)] = ((a602*s237) - (a603*s238));
Y[(a610 + 5)] = ((a603*s237) + (a602*s238));
Y[(a610 + 6)] = ((a604*s231) - (a605*s232));
Y[(a610 + 7)] = ((a605*s231) + (a604*s232));
Y[(a610 + 8)] = ((a606*s235) - (a607*s236));
Y[(a610 + 9)] = ((a607*s235) + (a606*s236));
Y[(a610 + 10)] = ((a608*s239) - (a609*s240));
Y[(a610 + 11)] = ((a609*s239) + (a608*s240));
}
}
|
the_stack_data/960564.c
|
#include <stdio.h>
int get_height () {
char line[5];
int height;
do {
printf("Height: ");
fgets(line, sizeof(line), stdin);
} while (sscanf(line, "%i", &height) != 1 || height < 1 || height > 8);
return height;
}
int main (void) {
int height = get_height();
char bricks[10] = "########";
char padding[10] = " ";
for (int i = 1; i <= height; i++) {
printf("%.*s%.*s %.*s\n", height - i, padding, i, bricks, i, bricks);
}
}
|
the_stack_data/220455093.c
|
/* -*- mode: c; c-file-style: "k&r" -*-
natsort.c -- Example strnatcmp application.
Copyright (C) 2000 by Martin Pool <[email protected]>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Originally from http://sourcefrog.net/projects/natsort/
*/
/* Partial change history:
*
* 2003-03-18: Add --reverse option, from Alessandro Pisani.
*/
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
extern ssize_t getline(char **linep, size_t *np, FILE *fp);
extern ssize_t getdelim(char **linep, size_t *np, int delim, FILE *fp);
extern int strnatcmp(const char *s1, const char *s2);
extern int strnatcasecmp(const char *s1, const char *s2);
#if defined(__GNUC__)
# define UNUSED __attribute__((__unused__))
#endif
static int fold_case = 0, verbose = 0, reverse = 0;
static void trace_result(char const *a, char const *b, int ret)
{
char const *op;
if (ret < 0)
op = "<";
else if (ret > 0)
op = ">";
else
op = "==";
fprintf(stderr, "\tstrncatcmp: \"%s\" %s \"%s\"\n",
a, op, b);
}
static int compare_strings(const void *a, const void *b)
{
char const *pa = *(char const **)a, *pb = *(char const **)b;
int ret;
if (fold_case)
ret = strnatcasecmp(pa, pb);
else
ret = strnatcmp(pa, pb);
if (reverse)
ret *= -1;
if (verbose)
trace_result(pa, pb, ret);
return ret;
}
static char usage[] =
"usage: natsort [-irv] <input >output\n"
"\n"
"-i\t\tignore case\n"
"-r\t\treverse sort order\n"
"-v\t\tverbose debug info\n"
"\n"
;
int
main(int argc, char **argv)
{
int nlines = 0;
char *line;
char **list = 0;
int linelen = 0, i;
int c;
size_t bufsize;
/* process arguments */
while ((c = getopt(argc, argv, "irv")) != -1) {
switch (c) {
case 'i':
fold_case = 1;
break;
case 'r':
reverse = 1;
break;
case 'v':
verbose = 1;
break;
default:
fprintf(stderr, usage);
return 2;
}
}
/* read lines into an array */
while (1) {
char **replace;
line = NULL;
bufsize = 0;
if ((linelen = getline(&line, &bufsize, stdin)) <= 0)
break;
if (line[linelen-1] == '\n')
line[--linelen] = 0;
nlines++;
replace = (char **) realloc(list, nlines * sizeof list[0]);
if (replace == NULL) {
perror("allocate list");
free(list);
return 1;
}
list = replace;
list[nlines-1] = line;
}
if (ferror(stdin)) {
perror("input");
return 1;
}
fclose(stdin);
/* quicksort */
qsort(list, nlines, sizeof list[0], compare_strings);
/* and output */
for (i = 0; i < nlines; i++) {
puts(list[i]);
}
if (ferror(stdout)) {
perror("output");
return 1;
}
return 0;
}
|
the_stack_data/165768395.c
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_striteri.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lteresia <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/10/05 20:39:06 by lteresia #+# #+# */
/* Updated: 2021/10/05 20:42:16 by lteresia ### ########.fr */
/* */
/* ************************************************************************** */
void ft_striteri(char *s, void (*f)(unsigned int, char*))
{
int i;
i = 0;
while (s[i])
{
f(i, s + i);
i++;
}
}
|
the_stack_data/61076430.c
|
void not_required_by_rtems( void ) {}
|
the_stack_data/15764114.c
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int a, b, i, n, m, ans, id[1005], sz[1005];
int root(int i) {
while(i != id[i]) {
id[i] = id[id[i]];
i = id[i];
}
return i;
}
int find(int p, int q) {
return root(p) == root(q);
}
void unite(int p, int q) {
int i = root(p);
int j = root(q);
if(i == j) return;
if(sz[i] < sz[j]) {
id[i] = j;
sz[j] += sz[i];
} else {
id[j] = i;
sz[i] += sz[j];
}
}
int main(void) {
while(scanf("%d%d", &n, &m) == 2) {
for(i = 1; i <= n; i++) { id[i] = i; sz[i] = 1; }
ans = n;
for(i = 0; i < m; i++) {
scanf("%d%d", &a, &b);
if(!find(a, b)) {
unite(a, b); ans--;
}
}
printf("%d\n", ans);
}
return 0;
}
|
the_stack_data/67324423.c
|
#define F(v,h)for(v=0;v<h;v++)
#define I F(y,22)F(x,80)
#define U M[y][x]
#define R rand()%
#define Z 106>U&U>96
M[22][80],y,x,Y,X,c,t=0,m=0,h=20,r,i,l,T,W,H;S(){r=0;I r+=Z?1:0;i=r?1:printf("Score:%i\n",(m*10)-t+(h*10)),0;}L(){l=t;while(U!=46){x=R 80;y=R 22;};U=64;M[Y][X]=46;Y=y;X=x;}main(int a,char*A[]){F(i,a){r=*A[i];r==84?T=1:r==72?H=1:r==87?W=1:0;};srand(time(0));initscr();I U=35;y=11;x=40;F(i,2000){U=R 20?46:97+R 8,m++;r=R 4;!r&y>1?y--:r==1&y<20?y++:r==2&x>1?x--:x<78?x++:0;}U=64;Y=y;X=x;do{I mvaddch(y,x,U);r=t>l+19;mvprintw(22,0,"Bewof\nHp:%i %c ",h,r?94:32);c=getch();t++;l+=!T;c==94&r?L():0;y=Y;x=X;F(r,2){c==119?r?W?U-=R 3+R 3:U--,U<97?U=46:0:y--:c==115?r?M[y+1][x]!=35?M[y+1][x]=U-9,U=46:0:y++:c==100?r?M[Y][X]=U-9,U=64,X++:x++:c==97?r?M[Y-2][X]!=35&Y>1?M[Y-2][X]=U-9,U=46:0:x--:0;r?0:U==46?M[Y][X]=46,U=64,X=x,Y=y:0;Z?0:r++;}I{Z&(H&(X-x>5|x-X>5|Y-y>5|y-Y>5)?0:1)?i=y,r=x,X==x?Y>y?i++:i--:Y==y?X>x?r++:r--:0,M[i][r]==46?M[i][r]=U-9,U=46:M[i][r]==64?h--:0:0;}I -9+Z-9?U+=9:0;S();}while(c!=81&h>0&i);endwin();}
|
the_stack_data/304195.c
|
/**
******************************************************************************
* @file : main.c
* @author : Auto-generated by STM32CubeIDE
* @brief : Main program body
******************************************************************************
* @attention
*
* <h2><center>© Copyright (c) 2019 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
#if !defined(__SOFT_FP__) && defined(__ARM_FP)
#warning "FPU is not initialized, but the project is compiling for an FPU. Please initialize the FPU before use."
#endif
int main(void)
{
int p1, *p2;
p2 = (int*)0x20000008;
__asm volatile("LDR %0, [%1]" : "=r"(p1) : "r"(p2)); // p1 = *p2;
for(;;);
}
|
the_stack_data/26700059.c
|
const unsigned char logo_gw[] = {
0x59, 0xce, 0x39, 0xc6, 0x79, 0xce, 0x9a, 0xce, 0x9a, 0xd6, 0x7a, 0xce,
0x9a, 0xd6, 0x7a, 0xce, 0x9a, 0xd6, 0x7a, 0xce, 0x9a, 0xd6, 0x7a, 0xce,
0x9a, 0xd6, 0x7a, 0xce, 0x9a, 0xd6, 0x7a, 0xce, 0x9a, 0xd6, 0x7a, 0xce,
0x9a, 0xd6, 0x7a, 0xce, 0x9a, 0xd6, 0x7a, 0xce, 0x9a, 0xd6, 0x7a, 0xce,
0x9a, 0xd6, 0x7a, 0xce, 0x9a, 0xd6, 0x7a, 0xce, 0x9a, 0xd6, 0x7a, 0xce,
0x9a, 0xd6, 0x7a, 0xce, 0x9a, 0xd6, 0x7a, 0xce, 0x9a, 0xd6, 0x7a, 0xce,
0x9a, 0xd6, 0x7a, 0xce, 0x9a, 0xd6, 0x7a, 0xce, 0x9a, 0xd6, 0x7a, 0xce,
0x9a, 0xd6, 0x5a, 0xce, 0x59, 0xce, 0x59, 0xc6, 0x59, 0xce, 0x39, 0xce,
0xba, 0xde, 0x7e, 0xef, 0xde, 0xff, 0xbf, 0xff, 0xde, 0xff, 0xbf, 0xff,
0xde, 0xff, 0xbf, 0xff, 0xde, 0xff, 0xbf, 0xff, 0xde, 0xff, 0xbf, 0xff,
0xde, 0xff, 0xbf, 0xff, 0xde, 0xff, 0xbf, 0xff, 0xde, 0xff, 0xbf, 0xff,
0xde, 0xff, 0xbf, 0xff, 0xde, 0xff, 0xbf, 0xff, 0xde, 0xff, 0xbf, 0xff,
0xde, 0xff, 0xbf, 0xff, 0xde, 0xff, 0xbf, 0xff, 0xde, 0xff, 0xbf, 0xff,
0xde, 0xff, 0xbf, 0xff, 0xde, 0xff, 0xbf, 0xff, 0xde, 0xff, 0xbf, 0xff,
0xde, 0xff, 0xbf, 0xff, 0xde, 0xff, 0xbf, 0xff, 0xde, 0xff, 0xbf, 0xff,
0x7d, 0xf7, 0xbb, 0xd6, 0xd2, 0x9c, 0x21, 0x00, 0x79, 0xce, 0x7e, 0xef,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x9e, 0xf7, 0x55, 0xad, 0x45, 0x29, 0x7a, 0xd6, 0xde, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xdf, 0xff,
0xb6, 0xbd, 0xc3, 0x18, 0x9a, 0xd6, 0xdf, 0xf7, 0xff, 0xff, 0xdf, 0xff,
0x7e, 0xe7, 0x5f, 0xdf, 0xdf, 0xff, 0xff, 0xff, 0xdf, 0xf7, 0x5e, 0xe7,
0x7e, 0xe7, 0x5f, 0xdf, 0xff, 0xff, 0xbf, 0xf7, 0x7e, 0xe7, 0x5f, 0xdf,
0x7e, 0xe7, 0x5f, 0xdf, 0x5d, 0xe7, 0xbf, 0xef, 0xff, 0xf7, 0x5e, 0xe7,
0x5e, 0xe7, 0x7f, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xdf, 0xf7, 0x5e, 0xe7,
0x7e, 0xef, 0xff, 0xf7, 0xff, 0xff, 0xbf, 0xf7, 0x7e, 0xe7, 0x5f, 0xdf,
0xdf, 0xff, 0xdf, 0xf7, 0x7e, 0xe7, 0x5f, 0xdf, 0x5e, 0xe7, 0xff, 0xf7,
0xdf, 0xf7, 0x5e, 0xe7, 0x7e, 0xe7, 0x7f, 0xdf, 0xbf, 0xff, 0xb7, 0xb5,
0xe3, 0x18, 0x7a, 0xd6, 0xde, 0xff, 0xff, 0xf7, 0xdc, 0xd6, 0x5c, 0xae,
0x7c, 0xb6, 0x9c, 0xc6, 0xbf, 0xef, 0x5c, 0xae, 0x7c, 0xb6, 0x9d, 0xbe,
0xbc, 0xbe, 0x5f, 0xdf, 0x9b, 0xbe, 0x5c, 0xb6, 0xfd, 0xc6, 0x7d, 0xb6,
0x9c, 0xbe, 0x7c, 0xb6, 0xfd, 0xc6, 0xde, 0xc6, 0x7b, 0xb6, 0x5c, 0xae,
0xbd, 0xbe, 0xff, 0xff, 0xbe, 0xff, 0x9d, 0xbe, 0x5b, 0xb6, 0x5c, 0xb6,
0x1e, 0xcf, 0xbf, 0xef, 0x9b, 0xc6, 0x7d, 0xae, 0x1b, 0xa6, 0x3f, 0xcf,
0x7b, 0xbe, 0x5c, 0xb6, 0x9c, 0xbe, 0x9c, 0xc6, 0x5e, 0xdf, 0xbd, 0xbe,
0x5b, 0xb6, 0x7c, 0xb6, 0x9c, 0xbe, 0x5e, 0xef, 0xd7, 0xbd, 0xc3, 0x18,
0x99, 0xd6, 0xdf, 0xff, 0x5e, 0xd7, 0xbd, 0xc6, 0xdd, 0xc6, 0x3f, 0xcf,
0xbc, 0xce, 0xbf, 0xef, 0x9f, 0xe7, 0x3e, 0xdf, 0x9c, 0xb6, 0xde, 0xbe,
0xdd, 0xc6, 0x9d, 0xb6, 0xdd, 0xc6, 0xdd, 0xc6, 0xbc, 0xbe, 0xde, 0xbe,
0xbd, 0xbe, 0xbd, 0xbe, 0x3b, 0xae, 0xfe, 0xc6, 0x7e, 0xef, 0xdf, 0xf7,
0xff, 0xff, 0xfd, 0xd6, 0xbc, 0xbe, 0x1f, 0xcf, 0xfd, 0xce, 0xdd, 0xc6,
0xbd, 0xbe, 0x9d, 0xb6, 0x5e, 0xdf, 0x7f, 0xdf, 0xdf, 0xf7, 0x7f, 0xe7,
0x7f, 0xdf, 0x7c, 0xb6, 0xdd, 0xc6, 0xbd, 0xbe, 0x9c, 0xbe, 0xde, 0xc6,
0x7c, 0xae, 0x7d, 0xae, 0xbe, 0xf7, 0xb7, 0xb5, 0xe3, 0x18, 0x7a, 0xd6,
0xde, 0xff, 0xfe, 0xce, 0xfd, 0xce, 0xfe, 0xce, 0xdd, 0xce, 0x1a, 0xae,
0x3f, 0xd7, 0xde, 0xc6, 0x9c, 0xbe, 0xbd, 0xc6, 0xbc, 0xc6, 0xbd, 0xc6,
0xfd, 0xce, 0x3f, 0xd7, 0xdc, 0xce, 0x3e, 0xd7, 0xfd, 0xd6, 0xbd, 0xc6,
0xbc, 0xc6, 0xfe, 0xc6, 0x7b, 0xbe, 0x5b, 0xb6, 0x7f, 0xdf, 0xff, 0xf7,
0xdc, 0xd6, 0xdd, 0xc6, 0xfd, 0xce, 0xbe, 0xbe, 0xd9, 0x9d, 0x5c, 0xb6,
0xfd, 0xce, 0x9d, 0xb6, 0x5b, 0xb6, 0x5f, 0xdf, 0xfc, 0xd6, 0x9d, 0xb6,
0xbd, 0xbe, 0x9d, 0xbe, 0xbc, 0xbe, 0xfe, 0xc6, 0x7c, 0xbe, 0x1a, 0xae,
0x9f, 0xdf, 0xdf, 0xff, 0xb6, 0xbd, 0xc3, 0x18, 0x9a, 0xd6, 0x9f, 0xf7,
0x9c, 0xbe, 0xde, 0xbe, 0xbc, 0xbe, 0xbd, 0xbe, 0xdd, 0xc6, 0xbd, 0xbe,
0x5b, 0xae, 0x9d, 0xae, 0x9d, 0xb6, 0xfb, 0x9d, 0xbc, 0xbe, 0x1f, 0xcf,
0xbc, 0xc6, 0xdd, 0xc6, 0x3e, 0xd7, 0x7c, 0xbe, 0xbc, 0xc6, 0xdd, 0xc6,
0xbd, 0xbe, 0xde, 0xbe, 0xdc, 0xce, 0xdf, 0xef, 0x9f, 0xe7, 0x7c, 0xbe,
0xfd, 0xc6, 0x7c, 0xb6, 0x1e, 0xcf, 0x7c, 0xb6, 0xfe, 0xc6, 0x3c, 0xae,
0xfd, 0xce, 0xfe, 0xc6, 0xfe, 0xc6, 0x3b, 0xae, 0x7c, 0xb6, 0x7d, 0xae,
0xfa, 0x9d, 0x7d, 0xae, 0xdd, 0xc6, 0xbd, 0xbe, 0x7b, 0xbe, 0x9f, 0xdf,
0xff, 0xff, 0xb7, 0xb5, 0xe3, 0x18, 0x9a, 0xce, 0x7d, 0xef, 0x7c, 0xb6,
0xdd, 0xc6, 0x7c, 0xb6, 0xfd, 0xce, 0x9d, 0xb6, 0xbd, 0xbe, 0x7d, 0xae,
0x1b, 0xa6, 0x9d, 0xb6, 0x3b, 0xae, 0x5b, 0xb6, 0x1e, 0xcf, 0x7d, 0xb6,
0x7c, 0xb6, 0x3f, 0xcf, 0x5b, 0xb6, 0x3b, 0xae, 0xbd, 0xbe, 0xbd, 0xbe,
0x9c, 0xbe, 0x5b, 0xbe, 0xdf, 0xef, 0x3f, 0xd7, 0xbc, 0xc6, 0x9d, 0xbe,
0x7c, 0xb6, 0xfe, 0xc6, 0x7b, 0xbe, 0xfe, 0xc6, 0x7b, 0xb6, 0x9d, 0xb6,
0x7c, 0xb6, 0x9d, 0xbe, 0x9c, 0xbe, 0x1b, 0xa6, 0x9c, 0xb6, 0x1c, 0xa6,
0x7c, 0xae, 0xfd, 0xce, 0x1d, 0xd7, 0x7c, 0xbe, 0x5e, 0xd7, 0xdf, 0xff,
0xb6, 0xbd, 0xc3, 0x18, 0x9a, 0xd6, 0x9e, 0xef, 0x1d, 0xcf, 0x1e, 0xcf,
0x1d, 0xd7, 0xfe, 0xce, 0x5e, 0xdf, 0xfe, 0xce, 0x1e, 0xcf, 0xdd, 0xc6,
0xfd, 0xce, 0x3f, 0xd7, 0xdc, 0xce, 0x9f, 0xe7, 0x3e, 0xd7, 0xfe, 0xce,
0xbf, 0xef, 0xdd, 0xce, 0x1d, 0xcf, 0xfe, 0xc6, 0x1d, 0xd7, 0xfe, 0xce,
0x1c, 0xd7, 0xff, 0xf7, 0xbf, 0xe7, 0xfd, 0xce, 0x1d, 0xd7, 0x1e, 0xcf,
0x1d, 0xd7, 0x3f, 0xd7, 0x1d, 0xcf, 0x1e, 0xcf, 0x1d, 0xcf, 0x3e, 0xd7,
0x1d, 0xd7, 0x1e, 0xcf, 0xfd, 0xce, 0xde, 0xc6, 0x5e, 0xdf, 0xdd, 0xc6,
0x9f, 0xef, 0x5f, 0xdf, 0xdc, 0xce, 0xbf, 0xe7, 0xff, 0xff, 0xb7, 0xb5,
0xe3, 0x18, 0x7a, 0xd6, 0xde, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xdf, 0xff, 0xb6, 0xbd, 0xc3, 0x18,
0x9a, 0xd6, 0xdf, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb7, 0xb5, 0xe3, 0x18, 0x7a, 0xd6,
0xde, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x9d, 0xf7, 0x1c, 0xe7, 0x1c, 0xe7, 0x1c, 0xe7, 0x1c, 0xe7, 0x1c, 0xe7,
0x1c, 0xe7, 0x1c, 0xe7, 0x1c, 0xe7, 0x1c, 0xe7, 0x1c, 0xe7, 0x1c, 0xe7,
0x1c, 0xe7, 0x1c, 0xe7, 0x1c, 0xe7, 0x1c, 0xe7, 0x1c, 0xe7, 0x1c, 0xe7,
0x1c, 0xe7, 0x1c, 0xe7, 0x1c, 0xe7, 0x1c, 0xe7, 0x1c, 0xe7, 0x1c, 0xe7,
0x1c, 0xe7, 0x1c, 0xe7, 0x1c, 0xe7, 0x1c, 0xe7, 0x1c, 0xe7, 0x1c, 0xe7,
0x1c, 0xe7, 0x7e, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xdf, 0xff, 0xb6, 0xbd, 0xc3, 0x18, 0x9a, 0xd6, 0xdf, 0xf7,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3c, 0xef, 0xcb, 0x5a,
0x04, 0x21, 0x25, 0x21, 0x45, 0x29, 0x46, 0x29, 0x65, 0x29, 0x46, 0x29,
0x65, 0x29, 0x46, 0x29, 0x65, 0x29, 0x46, 0x29, 0x65, 0x29, 0x46, 0x29,
0x65, 0x29, 0x46, 0x29, 0x65, 0x29, 0x46, 0x29, 0x65, 0x29, 0x46, 0x29,
0x65, 0x29, 0x46, 0x29, 0x65, 0x29, 0x46, 0x29, 0x65, 0x29, 0x46, 0x29,
0x65, 0x29, 0x46, 0x29, 0x65, 0x29, 0x45, 0x21, 0x25, 0x29, 0xe4, 0x18,
0xeb, 0x5a, 0x3d, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xb7, 0xb5, 0xe3, 0x18, 0x7a, 0xd6, 0xde, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x52, 0x8c, 0x61, 0x10, 0x67, 0x29,
0x09, 0x42, 0x0a, 0x3a, 0x29, 0x42, 0x0a, 0x3a, 0x29, 0x42, 0x0a, 0x3a,
0x29, 0x42, 0x0a, 0x3a, 0x29, 0x42, 0x0a, 0x3a, 0x29, 0x42, 0x0a, 0x3a,
0x29, 0x42, 0x0a, 0x3a, 0x29, 0x42, 0x0a, 0x3a, 0x29, 0x42, 0x0a, 0x3a,
0x29, 0x42, 0x0a, 0x3a, 0x29, 0x42, 0x0a, 0x3a, 0x29, 0x42, 0x0a, 0x3a,
0x29, 0x42, 0x0a, 0x3a, 0x29, 0x42, 0x0a, 0x3a, 0x87, 0x31, 0x42, 0x08,
0xef, 0x83, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xdf, 0xff,
0xb6, 0xbd, 0xc3, 0x18, 0x9a, 0xd6, 0xdf, 0xf7, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0x10, 0x84, 0xe4, 0x18, 0x4a, 0x42, 0x2a, 0x3a,
0x29, 0x3a, 0xea, 0x31, 0x09, 0x3a, 0xe9, 0x31, 0xc8, 0x31, 0xa8, 0x29,
0x86, 0x29, 0x67, 0x21, 0x66, 0x29, 0x67, 0x21, 0x66, 0x29, 0x67, 0x21,
0x66, 0x29, 0x67, 0x21, 0x66, 0x29, 0x67, 0x21, 0x66, 0x29, 0x67, 0x21,
0x66, 0x29, 0x67, 0x29, 0xc8, 0x31, 0xa8, 0x31, 0xe9, 0x39, 0xe9, 0x31,
0x09, 0x3a, 0x0a, 0x3a, 0x2a, 0x42, 0x2b, 0x3a, 0xe4, 0x18, 0x0d, 0x63,
0x5d, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb7, 0xb5,
0xe3, 0x18, 0x7a, 0xd6, 0xde, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xf0, 0x7b, 0xa2, 0x18, 0xe9, 0x31, 0x09, 0x3a, 0xe9, 0x39,
0xa7, 0x31, 0x46, 0x21, 0x46, 0x29, 0x46, 0x29, 0x66, 0x29, 0x46, 0x29,
0x45, 0x29, 0x26, 0x21, 0x45, 0x29, 0x26, 0x21, 0x45, 0x29, 0x26, 0x21,
0x45, 0x29, 0x26, 0x21, 0x45, 0x29, 0x26, 0x21, 0x45, 0x29, 0x26, 0x21,
0x46, 0x29, 0x67, 0x29, 0x66, 0x29, 0x46, 0x21, 0x66, 0x29, 0xc8, 0x31,
0x09, 0x3a, 0xe9, 0x39, 0xe8, 0x39, 0xa3, 0x10, 0x0c, 0x63, 0x3d, 0xe7,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xdf, 0xff, 0xb6, 0xbd, 0xc3, 0x18,
0x9a, 0xd6, 0xdf, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x10, 0x84, 0xc4, 0x18, 0xc8, 0x31, 0xea, 0x39, 0x09, 0x3a, 0x88, 0x29,
0x49, 0x4a, 0x46, 0x29, 0xc3, 0x10, 0xc4, 0x10, 0x87, 0x29, 0xc4, 0x10,
0xc3, 0x10, 0xa3, 0x10, 0xc4, 0x08, 0xc5, 0x08, 0x04, 0x11, 0xc4, 0x08,
0xc4, 0x08, 0xc4, 0x08, 0xc4, 0x08, 0xc4, 0x08, 0xe4, 0x10, 0x87, 0x21,
0xa3, 0x10, 0x62, 0x08, 0x25, 0x21, 0x29, 0x42, 0xa7, 0x31, 0x09, 0x3a,
0x09, 0x3a, 0xc9, 0x31, 0xe3, 0x18, 0x0d, 0x63, 0x5c, 0xef, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb7, 0xb5, 0xe3, 0x18, 0x7a, 0xd6,
0xde, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x7b,
0x45, 0x29, 0xe9, 0x39, 0x09, 0x42, 0xc8, 0x39, 0x49, 0x4a, 0x00, 0x51,
0xe2, 0x71, 0xad, 0x1a, 0x88, 0x01, 0x8d, 0x22, 0x0f, 0x33, 0x2e, 0x3b,
0x6e, 0x43, 0xd6, 0x13, 0xfa, 0x3c, 0x3a, 0x5d, 0x96, 0x4c, 0x58, 0x1c,
0x58, 0x24, 0x19, 0x04, 0x18, 0x04, 0x31, 0x2b, 0xaf, 0x1a, 0x42, 0x08,
0x00, 0x00, 0x00, 0x00, 0xc3, 0x18, 0x4a, 0x4a, 0xe7, 0x39, 0xe9, 0x39,
0x09, 0x3a, 0x46, 0x29, 0x0c, 0x63, 0x3d, 0xe7, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xdf, 0xff, 0xb6, 0xbd, 0xc3, 0x18, 0x9a, 0xd6, 0xdf, 0xf7,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x10, 0x7c, 0x66, 0x29,
0x6b, 0x42, 0xe9, 0x31, 0x08, 0x3a, 0xa8, 0x29, 0x80, 0x20, 0x22, 0x31,
0x26, 0x09, 0xc6, 0x00, 0xce, 0x1a, 0xd3, 0x3b, 0x51, 0x54, 0xb3, 0x64,
0x3f, 0x46, 0xdf, 0x35, 0xbf, 0x1d, 0x9f, 0x15, 0x7f, 0x0d, 0x7f, 0x0d,
0xbf, 0x25, 0xdf, 0x25, 0x55, 0x4c, 0xb0, 0x12, 0x61, 0x08, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xa7, 0x31, 0x09, 0x3a, 0xea, 0x31, 0x0b, 0x32,
0x45, 0x29, 0x0d, 0x5b, 0x5c, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xb7, 0xb5, 0xe3, 0x18, 0x7a, 0xd6, 0xde, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x7b, 0x45, 0x29, 0x4b, 0x42,
0x09, 0x3a, 0xc8, 0x31, 0x46, 0x29, 0x62, 0x08, 0x00, 0x00, 0x00, 0x00,
0x61, 0x10, 0xae, 0x1a, 0xd2, 0x43, 0x11, 0x54, 0x13, 0x75, 0x7f, 0x5e,
0xde, 0x45, 0x9f, 0x1d, 0x9f, 0x1d, 0xbe, 0x3d, 0x7f, 0x5e, 0x1f, 0x3e,
0x7e, 0x2d, 0x15, 0x3c, 0xaf, 0x12, 0x42, 0x08, 0x00, 0x00, 0x00, 0x00,
0x61, 0x10, 0x46, 0x21, 0xc7, 0x39, 0xef, 0x31, 0x71, 0x42, 0x83, 0x10,
0x0c, 0x63, 0x3d, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xdf, 0xff,
0xb6, 0xbd, 0xc3, 0x18, 0x9a, 0xd6, 0xdf, 0xf7, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xf0, 0x7b, 0x46, 0x21, 0x4a, 0x42, 0x2a, 0x3a,
0x09, 0x3a, 0x67, 0x21, 0x24, 0x21, 0x01, 0x00, 0x00, 0x00, 0x62, 0x08,
0xae, 0x1a, 0xb3, 0x3b, 0x52, 0x54, 0x73, 0x54, 0x7f, 0x0d, 0x3f, 0x05,
0xde, 0x0c, 0x7f, 0x1d, 0x1f, 0x4e, 0x1f, 0x4e, 0x1f, 0x46, 0x7f, 0x2d,
0xd4, 0x43, 0xb0, 0x12, 0x61, 0x08, 0x00, 0x00, 0x00, 0x00, 0x05, 0x21,
0x67, 0x29, 0xe9, 0x31, 0x52, 0x3a, 0x52, 0x32, 0xe4, 0x18, 0x0d, 0x63,
0x5c, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb7, 0xb5,
0xe3, 0x18, 0x7a, 0xd6, 0xde, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xf0, 0x7b, 0x45, 0x29, 0x0a, 0x3a, 0x2a, 0x42, 0xe9, 0x39,
0xc8, 0x39, 0x25, 0x21, 0x62, 0x08, 0x00, 0x00, 0x61, 0x10, 0x6f, 0x22,
0x11, 0x3b, 0xf2, 0x4b, 0x52, 0x5c, 0xbf, 0x0c, 0x3e, 0x04, 0xdf, 0x03,
0x5f, 0x0c, 0xbf, 0x0c, 0x3e, 0x04, 0xbf, 0x04, 0x9f, 0x04, 0xf3, 0x22,
0x91, 0x1a, 0x42, 0x08, 0x00, 0x00, 0x62, 0x08, 0x45, 0x29, 0xa8, 0x31,
0x87, 0x31, 0x8a, 0x29, 0xeb, 0x39, 0x46, 0x29, 0x0c, 0x63, 0x3d, 0xe7,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xdf, 0xff, 0xb6, 0xbd, 0xc3, 0x18,
0x9a, 0xd6, 0xdf, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xf0, 0x7b, 0x46, 0x21, 0x2a, 0x42, 0x0a, 0x3a, 0x2a, 0x42, 0x0a, 0x3a,
0x45, 0x21, 0xa4, 0x10, 0x00, 0x00, 0x42, 0x08, 0xc9, 0x2a, 0xcd, 0x43,
0x69, 0x5d, 0x49, 0x55, 0x70, 0x35, 0xef, 0x24, 0xef, 0x2c, 0xf0, 0x2c,
0x50, 0x35, 0x10, 0x25, 0x50, 0x2d, 0x30, 0x25, 0xad, 0x43, 0xaa, 0x22,
0x61, 0x08, 0x00, 0x00, 0xa3, 0x10, 0x26, 0x21, 0x09, 0x3a, 0x0a, 0x3a,
0xe9, 0x39, 0x2a, 0x3a, 0x65, 0x29, 0x0d, 0x5b, 0x5c, 0xef, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb7, 0xb5, 0xe3, 0x18, 0x7a, 0xd6,
0xde, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x7b,
0x45, 0x29, 0x2a, 0x3a, 0x09, 0x3a, 0x2a, 0x42, 0x09, 0x3a, 0xc8, 0x31,
0xe4, 0x18, 0x21, 0x00, 0x61, 0x10, 0x64, 0x4a, 0x46, 0x6b, 0x61, 0x94,
0x40, 0x8c, 0x61, 0x94, 0x40, 0x8c, 0x61, 0x94, 0x40, 0x8c, 0x61, 0x94,
0x40, 0x8c, 0x61, 0x94, 0x40, 0x8c, 0x67, 0x6b, 0x83, 0x52, 0x42, 0x08,
0x21, 0x08, 0xc4, 0x18, 0xc7, 0x39, 0xe9, 0x39, 0x4a, 0x42, 0xe9, 0x39,
0x2a, 0x42, 0x46, 0x29, 0x0c, 0x63, 0x3d, 0xe7, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xdf, 0xff, 0xb6, 0xbd, 0xc3, 0x18, 0x9a, 0xd6, 0xdf, 0xf7,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x10, 0x84, 0x26, 0x21,
0xe8, 0x39, 0xa8, 0x31, 0x09, 0x3a, 0x2a, 0x3a, 0x09, 0x3a, 0x06, 0x19,
0x41, 0x08, 0x62, 0x08, 0x23, 0x62, 0x89, 0x93, 0x42, 0xdc, 0x42, 0xdc,
0x42, 0xdc, 0x42, 0xdc, 0x42, 0xdc, 0x42, 0xdc, 0x42, 0xdc, 0x42, 0xdc,
0x42, 0xdc, 0x42, 0xdc, 0xa9, 0x93, 0x23, 0x62, 0x62, 0x08, 0x42, 0x00,
0x25, 0x21, 0x09, 0x3a, 0x4a, 0x42, 0xe9, 0x31, 0xc8, 0x31, 0x2a, 0x3a,
0x65, 0x29, 0x0d, 0x5b, 0x5c, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xb7, 0xb5, 0xe3, 0x18, 0x7a, 0xd6, 0xde, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x7b, 0x61, 0x10, 0x26, 0x21,
0x25, 0x21, 0x05, 0x19, 0x09, 0x42, 0xe9, 0x39, 0xc8, 0x39, 0x62, 0x08,
0x62, 0x10, 0x23, 0x62, 0xa8, 0x9b, 0x42, 0xdc, 0x42, 0xdc, 0x42, 0xdc,
0x42, 0xdc, 0x42, 0xdc, 0x42, 0xdc, 0x42, 0xdc, 0x42, 0xdc, 0x42, 0xdc,
0x42, 0xdc, 0xa9, 0x93, 0x22, 0x6a, 0x62, 0x08, 0x62, 0x10, 0xa8, 0x31,
0x09, 0x42, 0x09, 0x3a, 0x87, 0x31, 0x46, 0x21, 0xa7, 0x31, 0x46, 0x29,
0x0c, 0x63, 0x3d, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xdf, 0xff,
0xb6, 0xbd, 0xc3, 0x18, 0x9a, 0xd6, 0xdf, 0xf7, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0x10, 0x84, 0x42, 0x08, 0xc8, 0x31, 0xa8, 0x29,
0xe4, 0x18, 0x05, 0x19, 0x29, 0x42, 0xea, 0x39, 0x04, 0x19, 0x62, 0x08,
0x06, 0x4a, 0xa5, 0x39, 0x02, 0x62, 0xa1, 0x51, 0x02, 0x62, 0xa1, 0x51,
0x02, 0x62, 0xa1, 0x51, 0x02, 0x62, 0xa1, 0x51, 0x02, 0x62, 0xa1, 0x51,
0x05, 0x4a, 0x06, 0x4a, 0x62, 0x08, 0xe4, 0x18, 0x09, 0x3a, 0x2a, 0x3a,
0x87, 0x29, 0xc8, 0x31, 0x46, 0x29, 0x26, 0x21, 0x24, 0x21, 0x0d, 0x63,
0x5c, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb7, 0xb5,
0xe3, 0x18, 0x7a, 0xd6, 0xde, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xf0, 0x7b, 0xe3, 0x20, 0x0a, 0x3a, 0x29, 0x42, 0xe9, 0x39,
0x25, 0x21, 0xe9, 0x39, 0x09, 0x3a, 0xa8, 0x31, 0x41, 0x08, 0xa3, 0x10,
0x61, 0x08, 0x42, 0x08, 0x61, 0x08, 0x42, 0x08, 0x61, 0x08, 0x42, 0x08,
0x61, 0x08, 0x42, 0x08, 0x61, 0x08, 0x42, 0x08, 0x41, 0x08, 0x42, 0x08,
0xc3, 0x18, 0x42, 0x08, 0xc7, 0x39, 0xe9, 0x39, 0x4a, 0x42, 0x87, 0x29,
0x25, 0x21, 0x25, 0x21, 0x66, 0x29, 0x25, 0x21, 0x0c, 0x63, 0x3d, 0xe7,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xdf, 0xff, 0xb6, 0xbd, 0xc3, 0x18,
0x9a, 0xd6, 0xdf, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x10, 0x84, 0xa3, 0x10, 0xe9, 0x39, 0xc9, 0x31, 0xc7, 0x31, 0x05, 0x19,
0xc8, 0x31, 0x2a, 0x3a, 0x09, 0x3a, 0x05, 0x19, 0x62, 0x10, 0x41, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x08, 0x62, 0x08,
0x25, 0x21, 0xe9, 0x39, 0x2a, 0x42, 0xa8, 0x29, 0x66, 0x29, 0x46, 0x21,
0x46, 0x21, 0xe9, 0x39, 0x66, 0x29, 0x0d, 0x5b, 0x5c, 0xef, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb7, 0xb5, 0xe3, 0x18, 0x7a, 0xd6,
0xde, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x7b,
0x41, 0x08, 0x87, 0x29, 0x87, 0x31, 0xc4, 0x18, 0x04, 0x21, 0xc9, 0x31,
0x2a, 0x42, 0xe9, 0x39, 0xe9, 0x39, 0x25, 0x21, 0xc3, 0x18, 0xe4, 0x18,
0x25, 0x21, 0x05, 0x21, 0x25, 0x21, 0x05, 0x21, 0x25, 0x21, 0x05, 0x21,
0x25, 0x21, 0x05, 0x21, 0xe4, 0x20, 0xc4, 0x18, 0x25, 0x29, 0xe9, 0x39,
0xe9, 0x39, 0xc8, 0x31, 0xc8, 0x39, 0x67, 0x29, 0x05, 0x21, 0xc9, 0x31,
0x2a, 0x42, 0x46, 0x29, 0x0c, 0x63, 0x3d, 0xe7, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xdf, 0xff, 0xb6, 0xbd, 0xc3, 0x18, 0x9a, 0xd6, 0xdf, 0xf7,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x10, 0x84, 0x62, 0x08,
0x05, 0x21, 0xe5, 0x18, 0x05, 0x19, 0xc8, 0x31, 0x09, 0x3a, 0x0a, 0x3a,
0x2a, 0x42, 0xe9, 0x31, 0x09, 0x3a, 0xc9, 0x31, 0xc8, 0x31, 0xe9, 0x31,
0xe8, 0x39, 0xc9, 0x31, 0xe8, 0x39, 0xc9, 0x31, 0xe8, 0x39, 0xc9, 0x31,
0xe8, 0x39, 0xa8, 0x31, 0xc8, 0x31, 0xe9, 0x39, 0x09, 0x3a, 0x2a, 0x3a,
0x66, 0x29, 0x67, 0x29, 0x25, 0x21, 0x05, 0x19, 0xc8, 0x31, 0x2a, 0x3a,
0x65, 0x29, 0x0d, 0x5b, 0x5c, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xb7, 0xb5, 0xe3, 0x18, 0x7a, 0xd6, 0xde, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x7b, 0x45, 0x29, 0xe9, 0x39,
0x66, 0x29, 0x87, 0x29, 0xa7, 0x31, 0x87, 0x29, 0xa7, 0x31, 0xc9, 0x31,
0x29, 0x42, 0xe9, 0x39, 0xe8, 0x39, 0xe9, 0x31, 0xe8, 0x39, 0xe9, 0x31,
0xe8, 0x39, 0xe9, 0x31, 0xe8, 0x39, 0xe9, 0x31, 0xe8, 0x39, 0xe9, 0x31,
0xe8, 0x39, 0xc9, 0x31, 0x09, 0x42, 0x2a, 0x3a, 0x09, 0x3a, 0xc8, 0x31,
0x05, 0x21, 0x05, 0x19, 0x86, 0x31, 0xe9, 0x39, 0x2a, 0x42, 0x46, 0x29,
0x0c, 0x63, 0x3d, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xdf, 0xff,
0xb6, 0xbd, 0xc3, 0x18, 0x9a, 0xd6, 0xdf, 0xf7, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0x10, 0x7c, 0x46, 0x21, 0xe8, 0x39, 0x87, 0x29,
0x87, 0x29, 0x67, 0x29, 0x87, 0x29, 0x67, 0x29, 0x87, 0x29, 0xc9, 0x31,
0x2a, 0x42, 0x4b, 0x42, 0x4a, 0x42, 0x4b, 0x42, 0x4a, 0x42, 0x4b, 0x42,
0x4a, 0x42, 0x4b, 0x42, 0x4a, 0x42, 0x4b, 0x42, 0x4a, 0x42, 0x4b, 0x42,
0x4a, 0x42, 0x2a, 0x3a, 0x09, 0x3a, 0xea, 0x31, 0x09, 0x3a, 0xc9, 0x31,
0xc8, 0x31, 0xe9, 0x31, 0x09, 0x3a, 0x2a, 0x3a, 0x65, 0x29, 0x0d, 0x5b,
0x5c, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb7, 0xb5,
0xe3, 0x18, 0x7a, 0xd6, 0xde, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xf0, 0x7b, 0x45, 0x29, 0xa8, 0x31, 0x66, 0x29, 0x67, 0x29,
0x86, 0x29, 0x67, 0x29, 0x86, 0x29, 0x67, 0x29, 0xc8, 0x39, 0xe9, 0x39,
0x09, 0x3a, 0xe9, 0x39, 0x09, 0x3a, 0xe9, 0x39, 0x09, 0x3a, 0xe9, 0x39,
0x09, 0x3a, 0xe9, 0x39, 0x09, 0x3a, 0xe9, 0x39, 0x09, 0x3a, 0xe9, 0x39,
0x09, 0x3a, 0xe9, 0x39, 0x09, 0x3a, 0xe9, 0x39, 0x09, 0x3a, 0xe9, 0x39,
0x09, 0x3a, 0xe9, 0x39, 0x29, 0x42, 0x46, 0x29, 0x0c, 0x63, 0x3d, 0xe7,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xdf, 0xff, 0xb6, 0xbd, 0xc3, 0x18,
0x9a, 0xd6, 0xdf, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x10, 0x84, 0xa3, 0x10, 0xc8, 0x31, 0x88, 0x29, 0x87, 0x29, 0x67, 0x29,
0x87, 0x29, 0x67, 0x29, 0xc8, 0x31, 0xe9, 0x39, 0x09, 0x3a, 0xea, 0x31,
0x09, 0x3a, 0xea, 0x31, 0x09, 0x3a, 0xea, 0x31, 0x09, 0x3a, 0xea, 0x31,
0x09, 0x3a, 0xea, 0x31, 0x09, 0x3a, 0xea, 0x31, 0x09, 0x3a, 0xea, 0x31,
0x09, 0x3a, 0xea, 0x31, 0x09, 0x3a, 0xea, 0x31, 0x09, 0x3a, 0xea, 0x31,
0x09, 0x3a, 0xc9, 0x31, 0xc3, 0x18, 0x0d, 0x63, 0x5c, 0xef, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb7, 0xb5, 0xe3, 0x18, 0x7a, 0xd6,
0xde, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x7b,
0x41, 0x08, 0x05, 0x21, 0x66, 0x29, 0x46, 0x29, 0x66, 0x29, 0x46, 0x29,
0x66, 0x29, 0x67, 0x29, 0x87, 0x31, 0x67, 0x29, 0x87, 0x31, 0x67, 0x29,
0x87, 0x31, 0x67, 0x29, 0x87, 0x31, 0x67, 0x29, 0x87, 0x31, 0x67, 0x29,
0x87, 0x31, 0x67, 0x29, 0x87, 0x31, 0x67, 0x29, 0x87, 0x31, 0x67, 0x29,
0x87, 0x31, 0x67, 0x29, 0x87, 0x31, 0x67, 0x29, 0x87, 0x31, 0x67, 0x29,
0x25, 0x21, 0x42, 0x08, 0x0c, 0x63, 0x3d, 0xe7, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xdf, 0xff, 0xb6, 0xbd, 0xc3, 0x18, 0x9a, 0xd6, 0xdf, 0xf7,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb6, 0xb5, 0xc4, 0x18,
0x61, 0x08, 0x62, 0x08, 0x62, 0x08, 0x62, 0x08, 0x62, 0x08, 0x62, 0x08,
0x62, 0x08, 0x62, 0x08, 0x62, 0x08, 0x62, 0x08, 0x62, 0x08, 0x62, 0x08,
0x62, 0x08, 0x62, 0x08, 0x62, 0x08, 0x62, 0x08, 0x62, 0x08, 0x62, 0x08,
0x62, 0x08, 0x62, 0x08, 0x62, 0x08, 0x62, 0x08, 0x62, 0x08, 0x62, 0x08,
0x62, 0x08, 0x62, 0x08, 0x62, 0x08, 0x62, 0x08, 0x62, 0x08, 0x42, 0x08,
0xc2, 0x18, 0x72, 0x8c, 0x3c, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xb7, 0xb5, 0xe3, 0x18, 0x7a, 0xd6, 0xde, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x96, 0xb5, 0x2d, 0x6b,
0x0c, 0x6b, 0x0c, 0x63, 0x2c, 0x6b, 0x0c, 0x63, 0x2c, 0x6b, 0x0c, 0x63,
0x2c, 0x6b, 0x0c, 0x63, 0x2c, 0x6b, 0x0c, 0x63, 0x2c, 0x6b, 0x0c, 0x63,
0x2c, 0x6b, 0x0c, 0x63, 0x2c, 0x6b, 0x0c, 0x63, 0x2c, 0x6b, 0x0c, 0x63,
0x2c, 0x6b, 0x0c, 0x63, 0x2c, 0x6b, 0x0c, 0x63, 0x2c, 0x6b, 0x0c, 0x63,
0x2c, 0x6b, 0x0c, 0x63, 0x2c, 0x6b, 0x0c, 0x63, 0x0c, 0x63, 0x51, 0x8c,
0x79, 0xd6, 0x7e, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xdf, 0xff,
0xb6, 0xbd, 0xc3, 0x18, 0x9a, 0xd6, 0xdf, 0xf7, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xbe, 0xf7, 0x3d, 0xe7,
0x5d, 0xef, 0x3d, 0xe7, 0x5d, 0xef, 0x3d, 0xe7, 0x5d, 0xef, 0x3d, 0xe7,
0x5d, 0xef, 0x3d, 0xe7, 0x5d, 0xef, 0x3d, 0xe7, 0x5d, 0xef, 0x3d, 0xe7,
0x5d, 0xef, 0x3d, 0xe7, 0x5d, 0xef, 0x3d, 0xe7, 0x5d, 0xef, 0x3d, 0xe7,
0x5d, 0xef, 0x3d, 0xe7, 0x5d, 0xef, 0x3d, 0xe7, 0x5d, 0xef, 0x3d, 0xe7,
0x5d, 0xef, 0x3d, 0xe7, 0x5d, 0xef, 0x3d, 0xe7, 0x5c, 0xef, 0x7e, 0xef,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb7, 0xb5,
0xe3, 0x18, 0x7a, 0xce, 0x7d, 0xf7, 0x9e, 0xf7, 0x9e, 0xf7, 0x9e, 0xf7,
0x9e, 0xf7, 0x9e, 0xf7, 0x9e, 0xf7, 0x9e, 0xf7, 0x9e, 0xf7, 0x9e, 0xf7,
0x9e, 0xf7, 0x9e, 0xf7, 0x9e, 0xf7, 0x9e, 0xf7, 0x9e, 0xf7, 0x9e, 0xf7,
0x9e, 0xf7, 0x9e, 0xf7, 0x9e, 0xf7, 0x9e, 0xf7, 0x9e, 0xf7, 0x9e, 0xf7,
0x9e, 0xf7, 0x9e, 0xf7, 0x9e, 0xf7, 0x9e, 0xf7, 0xbe, 0xff, 0x9e, 0xf7,
0xbe, 0xff, 0x9e, 0xf7, 0xbe, 0xff, 0x9e, 0xf7, 0xbe, 0xff, 0x9e, 0xf7,
0xbe, 0xff, 0x9e, 0xf7, 0xbe, 0xff, 0x9e, 0xf7, 0xbe, 0xff, 0x9e, 0xf7,
0xbe, 0xff, 0x9e, 0xf7, 0x9d, 0xff, 0x7e, 0xef, 0xb6, 0xbd, 0xc3, 0x18,
0x79, 0xce, 0xfc, 0xde, 0x3c, 0xe7, 0x1d, 0xe7, 0x3c, 0xe7, 0x1d, 0xe7,
0x3c, 0xe7, 0x1d, 0xe7, 0x3c, 0xe7, 0x1d, 0xe7, 0x3c, 0xe7, 0x1d, 0xe7,
0x3c, 0xe7, 0x1d, 0xe7, 0x3c, 0xe7, 0x1d, 0xe7, 0x3c, 0xe7, 0x1d, 0xe7,
0x3c, 0xe7, 0x1d, 0xe7, 0x3c, 0xe7, 0x1d, 0xe7, 0x3c, 0xe7, 0x1d, 0xe7,
0x3c, 0xe7, 0x1d, 0xe7, 0xdf, 0xbe, 0x7b, 0x8d, 0x5e, 0x75, 0x5e, 0x6d,
0x5e, 0x75, 0x5e, 0x6d, 0x5d, 0x75, 0x5e, 0x6d, 0x5d, 0x75, 0x5e, 0x6d,
0x5d, 0x75, 0x5e, 0x6d, 0x5d, 0x75, 0x5e, 0x6d, 0x5d, 0x75, 0x5e, 0x6d,
0x5c, 0x7d, 0x1f, 0x96, 0x1c, 0xe7, 0x96, 0xb5, 0xe3, 0x18, 0x59, 0xce,
0x1c, 0xe7, 0x1c, 0xe7, 0x3c, 0xef, 0x1c, 0xe7, 0x3c, 0xef, 0x1c, 0xe7,
0x3c, 0xef, 0x1c, 0xe7, 0xfb, 0xe6, 0xbb, 0xd6, 0x1c, 0xe7, 0x1c, 0xe7,
0x3c, 0xef, 0x1c, 0xe7, 0x3c, 0xef, 0x1c, 0xe7, 0x3c, 0xef, 0x1c, 0xe7,
0x3c, 0xef, 0x1c, 0xe7, 0x3c, 0xef, 0x1c, 0xe7, 0x3c, 0xef, 0x1c, 0xe7,
0x3c, 0xef, 0xbf, 0x65, 0x79, 0x1b, 0xfd, 0x2b, 0x7f, 0x5d, 0xdf, 0x13,
0x1f, 0x1c, 0x3f, 0x65, 0x5f, 0x65, 0xdf, 0x3c, 0x1d, 0x2c, 0x3f, 0x65,
0x5f, 0x65, 0xdf, 0x3c, 0x9c, 0x13, 0xff, 0x4c, 0xbf, 0x44, 0x7e, 0x0b,
0x3f, 0x24, 0x9b, 0xd6, 0xb7, 0xb5, 0xc3, 0x18, 0x79, 0xce, 0x1c, 0xe7,
0x3c, 0xe7, 0x1d, 0xe7, 0x3c, 0xe7, 0x1d, 0xe7, 0x3c, 0xe7, 0x1d, 0xe7,
0x1b, 0xe7, 0xb7, 0xb5, 0xd7, 0xbd, 0xbb, 0xd6, 0xf7, 0xbd, 0xbb, 0xd6,
0x79, 0xce, 0xd7, 0xbd, 0xba, 0xd6, 0xd8, 0xbd, 0x79, 0xce, 0x3d, 0xe7,
0x3c, 0xe7, 0x1d, 0xe7, 0x3c, 0xe7, 0x1d, 0xe7, 0x3c, 0xe7, 0x3d, 0xe7,
0x9f, 0x5d, 0x7b, 0x13, 0xba, 0x64, 0x5f, 0xb7, 0x1c, 0x2c, 0x7f, 0x5d,
0x5f, 0x96, 0x1d, 0x65, 0xff, 0xb6, 0xde, 0x95, 0x7f, 0x96, 0x1d, 0x65,
0x1f, 0xa7, 0x1a, 0x44, 0x9f, 0xa6, 0xde, 0x8d, 0x9e, 0x0b, 0x1f, 0x14,
0xbb, 0xce, 0xb8, 0xad, 0xe3, 0x18, 0x59, 0xce, 0x1c, 0xe7, 0x1c, 0xe7,
0x3c, 0xef, 0x1c, 0xe7, 0x3c, 0xef, 0x1c, 0xe7, 0x3c, 0xef, 0x1c, 0xe7,
0xf7, 0xc5, 0xb7, 0xbd, 0xb6, 0xbd, 0xf4, 0x9c, 0x17, 0xc6, 0xb7, 0xb5,
0x75, 0xb5, 0x96, 0xb5, 0xb6, 0xbd, 0xb7, 0xb5, 0x3c, 0xef, 0x1c, 0xe7,
0x3c, 0xef, 0x1c, 0xe7, 0x3c, 0xef, 0x1c, 0xe7, 0x3c, 0xef, 0x7f, 0x5d,
0x7a, 0x1b, 0xf9, 0x43, 0x1f, 0xaf, 0x1f, 0x24, 0x1f, 0x24, 0x3e, 0x6d,
0xdf, 0x85, 0x1f, 0xaf, 0x7a, 0x5c, 0x3e, 0x65, 0xdf, 0x7d, 0x3f, 0xa7,
0xd8, 0x3b, 0xbf, 0x85, 0xdf, 0x8d, 0x7e, 0x03, 0x1f, 0x1c, 0x9b, 0xce,
0xb7, 0xb5, 0xc3, 0x18, 0x79, 0xce, 0x1c, 0xe7, 0x3c, 0xe7, 0x1d, 0xe7,
0x3c, 0xe7, 0x1d, 0xe7, 0x3c, 0xe7, 0x1d, 0xe7, 0x1b, 0xe7, 0xf8, 0xbd,
0x79, 0xce, 0xbb, 0xd6, 0xf7, 0xc5, 0xfc, 0xde, 0x38, 0xc6, 0x15, 0xa5,
0x79, 0xd6, 0xd8, 0xbd, 0x79, 0xce, 0x3d, 0xe7, 0x3c, 0xe7, 0x1d, 0xe7,
0x3c, 0xe7, 0x1d, 0xe7, 0x3c, 0xe7, 0x3d, 0xe7, 0x7f, 0x5d, 0x9b, 0x1b,
0x5c, 0x7d, 0x1f, 0xaf, 0x7f, 0x5d, 0xdd, 0x23, 0xfd, 0x5c, 0x1f, 0x7e,
0x3f, 0x4d, 0xbd, 0x1b, 0xfd, 0x5c, 0xff, 0x7d, 0x1f, 0x4d, 0x5e, 0x34,
0x7f, 0xa6, 0x5f, 0xa6, 0x7f, 0x2c, 0xff, 0x1b, 0xbb, 0xce, 0xb8, 0xad,
0xe3, 0x18, 0x59, 0xce, 0xfb, 0xe6, 0x1c, 0xe7, 0x3c, 0xef, 0x1c, 0xe7,
0x3c, 0xef, 0x1c, 0xe7, 0x3c, 0xef, 0x1c, 0xe7, 0x3c, 0xef, 0x1c, 0xe7,
0x3c, 0xef, 0x1c, 0xe7, 0x3c, 0xef, 0x7a, 0xce, 0x59, 0xce, 0x1c, 0xe7,
0x3c, 0xef, 0x1c, 0xe7, 0x3c, 0xef, 0x1c, 0xe7, 0x3c, 0xef, 0x1c, 0xe7,
0x3c, 0xef, 0x1c, 0xe7, 0x3c, 0xef, 0x3f, 0x8e, 0x19, 0x44, 0x9f, 0x3c,
0xbf, 0x44, 0x9f, 0x34, 0x3e, 0x2c, 0x9f, 0x3c, 0x9f, 0x3c, 0xff, 0x1b,
0x1f, 0x24, 0x9f, 0x3c, 0x9f, 0x3c, 0xfe, 0x23, 0x5f, 0x2c, 0x9f, 0x3c,
0x9e, 0x44, 0x3d, 0x34, 0x1f, 0x55, 0xbb, 0xd6, 0x55, 0xad, 0xa3, 0x18,
0x59, 0xce, 0x7a, 0xce, 0xfb, 0xde, 0x1c, 0xe7, 0x1c, 0xe7, 0x1c, 0xe7,
0x1c, 0xe7, 0x1c, 0xe7, 0x1c, 0xe7, 0x1c, 0xe7, 0x1c, 0xe7, 0x1c, 0xe7,
0x1c, 0xe7, 0x1c, 0xe7, 0x3c, 0xe7, 0x1c, 0xe7, 0x1c, 0xe7, 0x1c, 0xe7,
0x1c, 0xe7, 0x1c, 0xe7, 0x1c, 0xe7, 0x1c, 0xe7, 0x1c, 0xe7, 0x1c, 0xe7,
0x1c, 0xe7, 0x1c, 0xe7, 0x1d, 0xdf, 0xbc, 0xce, 0xbc, 0xc6, 0x9d, 0xc6,
0xbc, 0xc6, 0xbd, 0xc6, 0xbc, 0xc6, 0x9d, 0xc6, 0xbc, 0xce, 0x9d, 0xc6,
0xbc, 0xc6, 0x9d, 0xc6, 0xbc, 0xce, 0x9d, 0xc6, 0xbc, 0xc6, 0x9d, 0xc6,
0xbb, 0xce, 0xbd, 0xce, 0x9a, 0xd6, 0x0c, 0x63, 0x00, 0x00, 0x9a, 0xce,
0xb3, 0x9c, 0x55, 0xa5, 0x96, 0xb5, 0x96, 0xb5, 0x96, 0xb5, 0x96, 0xb5,
0x96, 0xb5, 0x96, 0xb5, 0x96, 0xb5, 0x96, 0xb5, 0x96, 0xb5, 0x96, 0xb5,
0x96, 0xb5, 0x96, 0xb5, 0x96, 0xb5, 0x96, 0xb5, 0x96, 0xb5, 0x96, 0xb5,
0x96, 0xb5, 0x96, 0xb5, 0x96, 0xb5, 0x96, 0xb5, 0x96, 0xb5, 0x96, 0xb5,
0x96, 0xb5, 0x96, 0xb5, 0x96, 0xb5, 0xb6, 0xb5, 0x96, 0xb5, 0xb6, 0xb5,
0x96, 0xb5, 0xb6, 0xb5, 0x96, 0xb5, 0xb6, 0xb5, 0x96, 0xb5, 0xb6, 0xb5,
0x96, 0xb5, 0xb6, 0xb5, 0x96, 0xb5, 0xb6, 0xb5, 0x96, 0xb5, 0xb7, 0xb5,
0x35, 0xad, 0x2d, 0x63, 0x82, 0x10, 0x00, 0x00, 0x24, 0x29, 0xe3, 0x18,
0x45, 0x29, 0xe4, 0x18, 0xc3, 0x20, 0xe3, 0x18, 0xc3, 0x20, 0xe3, 0x18,
0xc3, 0x20, 0xe3, 0x18, 0xc3, 0x20, 0xe3, 0x18, 0xc3, 0x20, 0xe3, 0x18,
0xc3, 0x20, 0xe3, 0x18, 0xc3, 0x20, 0xe3, 0x18, 0xc3, 0x20, 0xe3, 0x18,
0xc3, 0x20, 0xe3, 0x18, 0xc3, 0x20, 0xe3, 0x18, 0xc3, 0x20, 0xe3, 0x18,
0xc3, 0x20, 0xe3, 0x18, 0xc3, 0x20, 0xe3, 0x18, 0xc3, 0x20, 0xe3, 0x18,
0xc3, 0x20, 0xe3, 0x18, 0xc3, 0x20, 0xe3, 0x18, 0xc3, 0x20, 0xe3, 0x18,
0xc3, 0x20, 0xe3, 0x18, 0xc3, 0x20, 0xe3, 0x18, 0xc3, 0x20, 0xc3, 0x18,
0x00, 0x08, 0x00, 0x00, 0x00, 0x00
};
|
the_stack_data/1000296.c
|
/*
* Function declaration, the semicolon makes the line too long.
*/
static int __test_lexer_read(const char *, const char *, const char *,
int);
|
the_stack_data/18886702.c
|
/* Test for <tgmath.h> in C99. */
/* Origin: Matt Austern <[email protected]>
/* { dg-do compile { target c99_runtime } } */
/* { dg-options "-std=iso9899:1999" } */
/* { dg-add-options c99_runtime } */
/* { dg-require-effective-target tgmath_h } */
/* Test that invoking type-generic sin on a float invokes sinf. */
#include <tgmath.h>
float foo(float x)
{
return sin(x);
}
/* { dg-final { scan-assembler "sinf" } } */
|
the_stack_data/256957.c
|
// RUN: %clang_tsan -O1 %s -o %t && not %t 2>&1 | FileCheck %s
#include <pthread.h>
#include <stdio.h>
#include <stddef.h>
#include <unistd.h>
pthread_barrier_t B;
int Global;
void *Thread1(void *x) {
pthread_barrier_init(&B, 0, 2);
pthread_barrier_wait(&B);
return NULL;
}
void *Thread2(void *x) {
sleep(1);
pthread_barrier_wait(&B);
return NULL;
}
int main() {
pthread_t t;
pthread_create(&t, NULL, Thread1, NULL);
Thread2(0);
pthread_join(t, NULL);
pthread_barrier_destroy(&B);
return 0;
}
// CHECK: WARNING: ThreadSanitizer: data race
|
the_stack_data/1267782.c
|
#include <stdio.h>
#include <stdlib.h>
//protótipos das funções que serão usadas:
long int **ALLOC_Matrix(long int n); //função para alocar a matriz
long int **DEALLOC_Matrix(long int n, long int **mat); //função para desalocar matriz
long int MP2(long int n); //calcular tamanho das matrizes auxiliares
void matSum(long int n, long int **mat_a, long int **mat_b, long int **mat_c); //função que soma matrizes
void matSubtract(long int n, long int **mat_a, long int **mat_b, long int **mat_c); //função que subtrai matrizes
void MatCpy(long int beginline, long int begincolumn, long int maxline, long int maxcolumn, long int **mat_a, long int **mat_destiny); //função que copia matrizes
long int **Strassen(long int n, long int **mat_a, long int **mat_b); //função que multiplica as matrizes
void unionMatrix(long int **mat, long int **mat11, long int **mat12, long int **mat21, long int **mat22, int size); //função que une matrizes
//Função que expõe matrizes
void matrix_show(long int **mat,int n){
long int i;
long int j;
for (i = 0; i < n; i++)
{
for (j = 0; j < n; j++)
{
printf("%li", mat[i][j]);
if (j < n - 1)
{
printf(" ");
}
}
printf("\n");
}
}
int main()
{
long int n; //número de linhas e colunas das matrizes
long int **matrix_A; //criação da matriz A
long int **matrix_B; //criação da matriz B
long int **matrix_C;
long int i, j; //variáveis auxiliares
//inserção de n (número de colunas e linhas)
scanf("%li", &n);
//chamada da função para alocar as matrizes
matrix_A = ALLOC_Matrix(n);
matrix_B = ALLOC_Matrix(n);
//entrada com os valores da primeira matriz
for (i = 0; i < n; i++)
{
for (j = 0; j < n; j++)
{
scanf("%li", &matrix_A[i][j]);
}
}
//entrada com os valores da segunda matriz
for (i = 0; i < n; i++)
{
for (j = 0; j < n; j++)
{
scanf("%li", &matrix_B[i][j]);
}
}
long int a = MP2(n); //variável auxiliar para guardar a menor potência de 2 maior que N
if (a > 0)
{ //caso da matriz não ser uma potência de 2
//criação de todas as matrizes auxiliares
long int **matrix_AAUX;
long int **matrix_BAUX;
long int **matrix_CAUX;
matrix_AAUX = ALLOC_Matrix(a);
matrix_BAUX = ALLOC_Matrix(a);
matrix_C = ALLOC_Matrix(n);
for (i = 0; i < a; i++)
{
for (j = 0; j < a; j++)
{
if (i >= n || j >= n)
{
matrix_AAUX[i][j] = 0;
matrix_BAUX[i][j] = 0;
}
else
{
matrix_AAUX[i][j] = matrix_A[i][j];
matrix_BAUX[i][j] = matrix_B[i][j];
}
}
}
matrix_CAUX = Strassen(a, matrix_AAUX, matrix_BAUX);
for (i = 0; i < n; i++)
{
for (j = 0; j < n; j++)
{
matrix_C[i][j] = matrix_CAUX[i][j]; //transferindo valores da matriz produto auxiliar para a real
}
}
matrix_show(matrix_C,n);
//desalocando matrizes auxiliares
matrix_AAUX = DEALLOC_Matrix(a, matrix_AAUX);
matrix_BAUX = DEALLOC_Matrix(a, matrix_BAUX);
matrix_CAUX = DEALLOC_Matrix(a, matrix_CAUX);
}
else
{ //caso de n ser uma potência de 2 (dispensa uso de matrizes auxiliares)
matrix_C = Strassen(n, matrix_A, matrix_B);
}
//Desalocando matrizes
matrix_A = DEALLOC_Matrix(n, matrix_A);
matrix_B = DEALLOC_Matrix(n, matrix_B);
matrix_C = DEALLOC_Matrix(n, matrix_C);
}
long int **ALLOC_Matrix(long int n) //função que aloca as matrizes
{
long int **mat; //ponteiro para a matriz
//caso de entrada menor que 1
if (n < 1)
{
exit(0);
}
mat = (long int **)calloc(n, sizeof(long int *)); //alocação das linhas da matriz
if (!mat)
{
exit(0);
}
long int i; //variável auxiliar
for (i = 0; i < n; i++)
{
mat[i] = (long int *)calloc(n, sizeof(long int));
if (!mat[i]) //checagem quanto ao armazenamento
{
exit(0);
}
}
return mat;
}
long int MP2(long int n) //corpo da função para calcular o tamanho das matrizes auxiliares
{
long int a = 1;
while (a < n)
{
a = a << 1;
if (a == n)
{
return 0;
}
}
return a;
}
long int **Strassen(long int n, long int **mat_a, long int **mat_b)
{
long int **mat_c;
mat_c = ALLOC_Matrix(n);
if (n == 1)
{
mat_c[0][0] = mat_a[0][0] * mat_b[0][0];
return mat_c;
}
long int **A11;
long int **A12;
long int **A21;
long int **A22;
long int **B11;
long int **B12;
long int **B21;
long int **B22;
long int mid = n / 2;
A11 = ALLOC_Matrix(mid);
A12 = ALLOC_Matrix(mid);
A21 = ALLOC_Matrix(mid);
A22 = ALLOC_Matrix(mid);
B11 = ALLOC_Matrix(mid);
B12 = ALLOC_Matrix(mid);
B21 = ALLOC_Matrix(mid);
B22 = ALLOC_Matrix(mid);
MatCpy(0, 0, mid, mid, mat_a, A11);
MatCpy(0, mid, mid, n, mat_a, A12);
MatCpy(mid, 0, n, mid, mat_a, A21);
MatCpy(mid, mid, n, n, mat_a, A22);
MatCpy(0, 0, mid, mid, mat_b, B11);
MatCpy(0, mid, mid, n, mat_b, B12);
MatCpy(mid, 0, n, mid, mat_b, B21);
MatCpy(mid, mid, n, n, mat_b, B22);
long int **M1;
long int **M2;
long int **M3;
long int **M4;
long int **M5;
long int **M6;
long int **M7;
//Matrizes auxiliares de soma
long int **MatAux;
long int **MatAux2;
MatAux = ALLOC_Matrix(mid);
MatAux2 = ALLOC_Matrix(mid);
//Calculando M1 a M7
matSum(mid, A11, A22, MatAux);
matSum(mid, B11, B22, MatAux2);
M1 = Strassen(mid, MatAux, MatAux2);
matSum(mid, A21, A22, MatAux);
M2 = Strassen(mid, MatAux, B11);
matSubtract(mid, B12, B22, MatAux);
M3 = Strassen(mid, A11, MatAux);
matSubtract(mid, B21, B11, MatAux);
M4 = Strassen(mid, A22, MatAux);
matSum(mid, A11, A12, MatAux);
M5 = Strassen(mid, MatAux, B22);
matSubtract(mid, A21, A11, MatAux);
matSum(mid, B11, B12, MatAux2);
M6 = Strassen(mid, MatAux, MatAux2);
matSubtract(mid, A12, A22, MatAux);
matSum(mid, B21, B22, MatAux2);
M7 = Strassen(mid, MatAux, MatAux2);
//criando submatrizes C
long int **C11;
long int **C12;
long int **C21;
long int **C22;
//alocando submatrizes de C
C11 = ALLOC_Matrix(mid);
C12 = ALLOC_Matrix(mid);
C21 = ALLOC_Matrix(mid);
C22 = ALLOC_Matrix(mid);
//atribuindo valores as submatrizes de C
//C1,1
matSum(mid, M1, M4, C11);
matSubtract(mid, C11, M5, C11);
matSum(mid, C11, M7, C11);
//C1,2
matSum(mid, M3, M5, C12);
//C2,1
matSum(mid, M2, M4, C21);
//C2,2
matSubtract(mid, M1, M2, C22);
matSum(mid, C22, M3, C22);
matSum(mid, C22, M6, C22);
unionMatrix(mat_c, C11, C12, C21, C22, mid);
A11 = DEALLOC_Matrix(mid, A11);
A12 = DEALLOC_Matrix(mid, A12);
A21 = DEALLOC_Matrix(mid, A21);
A22 = DEALLOC_Matrix(mid, A22);
B11 = DEALLOC_Matrix(mid, B11);
B12 = DEALLOC_Matrix(mid, B12);
B21 = DEALLOC_Matrix(mid, B21);
B22 = DEALLOC_Matrix(mid, B22);
M1 = DEALLOC_Matrix(mid, M1);
M2 = DEALLOC_Matrix(mid, M2);
M3 = DEALLOC_Matrix(mid, M3);
M4 = DEALLOC_Matrix(mid, M4);
M5 = DEALLOC_Matrix(mid, M5);
M6 = DEALLOC_Matrix(mid, M6);
M7 = DEALLOC_Matrix(mid, M7);
C11 = DEALLOC_Matrix(mid, C11);
C12 = DEALLOC_Matrix(mid, C12);
C21 = DEALLOC_Matrix(mid, C21);
C22 = DEALLOC_Matrix(mid, C22);
MatAux = DEALLOC_Matrix(mid,MatAux);
MatAux2 = DEALLOC_Matrix(mid,MatAux2);
return mat_c;
}
//corpo da função que soma matrizes
void matSum(long int n, long int **mat_a, long int **mat_b, long int **mat_c)
{
long int i;
long int j;
for (i = 0; i < n; i++)
{
for (j = 0; j < n; j++)
{
mat_c[i][j] = mat_a[i][j] + mat_b[i][j];
}
}
}
void matSubtract(long int n, long int **mat_a, long int **mat_b, long int **mat_c)
{
long int i;
long int j;
for (i = 0; i < n; i++)
{
for (j = 0; j < n; j++)
{
mat_c[i][j] = mat_a[i][j] - mat_b[i][j];
}
}
}
//corpo da função que copia matrizes
void MatCpy(long int beginline, long int begincolumn, long int maxline, long int maxcolumn, long int **mat_a, long int **mat_destiny)
{
int i = 0;
int j = 0;
int deltaLine = maxline - beginline;
int deltaCol = maxcolumn - begincolumn;
for (i = 0; i < deltaLine; i++)
{
for (j = 0; j < deltaCol; j++)
{
mat_destiny[i][j] = mat_a[beginline + i][begincolumn + j];
}
}
}
//recebe 4 matrizes de tamanho size x size, e faz a união de todas em uma única matriz de tamanho (size * 2) x (size * 2)
void unionMatrix(long int **mat, long int **mat11, long int **mat12, long int **mat21, long int **mat22, int size)
{
int i = 0;
int j = 0;
for (i = 0; i < size * 2; i++)
{
for (j = 0; j < size * 2; j++)
{
if (i < size && j < size)
{ //Quadrante superior esquerdo (11)
mat[i][j] = mat11[i][j];
}
else if (i < size && j >= size)
{ //quadrante superior direita (12)
mat[i][j] = mat12[i][j - size];
}
else if (i >= size && j < size)
{ //inferior esquerda (21)
mat[i][j] = mat21[i - size][j];
}
else
{ //inferior direito (22)
mat[i][j] = mat22[i - size][j - size];
}
}
}
}
//corpo da função que desaloca a matriz
long int **DEALLOC_Matrix(long int n, long int **mat) //função que desaloca as matrizes
{
long int i; //auxiliar
for (i = 0; i < n; i++)
{
free(mat[i]);
}
free(mat);
return (NULL);
}
|
the_stack_data/215768532.c
|
/*
* Copyright (c) 1988 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.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)waitpid.c 5.4 (Berkeley) 2/23/91";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
#include <sys/time.h>
#include <sys/wait.h>
#include <sys/resource.h>
int
waitpid(pid, istat, options)
int pid;
int *istat;
int options;
{
return (wait4(pid, istat, options, (struct rusage *)0));
}
|
the_stack_data/30987.c
|
#include <sys/time.h>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
int char2digit(char c) {
return c - '0';
}
char digit2char(int d) {
return d + '0';
}
size_t max(size_t a, size_t b) {
return a > b ? a : b;
}
char *skipZeros(char *s) {
while (*s == '0') {
s++;
}
return s;
}
char *checkZero(char *s) {
if (strcmp(s, "") == 0) {
free(s); // all string is allocated, must free it.
s = strdup("0");
}
return s;
}
// return pointer to chaining function call
char *reverse(char *p) {
size_t len = strlen(p), i;
for (i = 0; i != len / 2; i++) {
size_t r = len - i - 1;
char t = p[i];
p[i] = p[r];
p[r] = t;
}
return p;
}
char *add_scaler_in(char *a, char *b, int scaler) {
size_t la = strlen(a), lb = strlen(b);
size_t m = max(la, lb);
char *c = malloc(sizeof(char) * (m + 2));
size_t i;
int carry;
for (i = 0, carry = 0; i != m; i++) {
int v, v0, v1;
v0 = i < la ? char2digit(a[i]) : 0;
v1 = i < lb ? char2digit(b[i]) : 0;
v = v0 + scaler * v1 + carry;
carry = (v >= 10) - (v < 0);
v -= 10 * carry;
c[i] = digit2char(v % 10);
}
if (carry > 0) {
c[i++] = digit2char(carry);
} else if (carry == 0) {
} else {
printf("'%s' '%s' %d %d %d => carry=%d ", a, b, la, lb, scaler, carry);
printf("unexpected carray is negative\n");
assert(0);
}
c[i] = '\0';
return c;
}
char *add_in(char *a, char *b) {
return add_scaler_in(a, b, 1);
}
char *sub_in(char *a, char *b) {
return add_scaler_in(a, b, -1);
}
char *muls_in(char a, char *b) {
size_t l = strlen(b), i;
char *c = malloc(sizeof(char) * (l + 2));
int carry, va = char2digit(a);
for (i = 0, carry = 0; i != l; i++) {
int v = carry + va * char2digit(b[i]);
carry = v / 10;
c[i] = digit2char(v % 10);
}
if (carry != 0) {
c[i++] = digit2char(carry);
}
c[i] = '\0';
return c;
}
char *shift_in(char *s, size_t n) {
char *r = malloc(strlen(s) + n + 1);
size_t i;
for (i = 0; i != n; i++) {
r[i] = '0';
}
strcpy(r + n, s);
return r;
}
char *multiply_in(char *a, char *b) {
size_t i, l = strlen(a);
char *sum = strdup("");
for (i = 0; i != l; i++) {
// (a[0] + .. + a[i] * 10 ^ i + ..) * b
// = a[0] * b + .. + a[i] * b * 10 ^ i + ..
char *s0 = muls_in(a[i], b);
char *s1 = shift_in(s0, i);
char *s2 = add_in(sum, s1);
free(s0);
free(s1);
free(sum);
sum = s2;
}
return sum;
}
void halve(char *a, int l0, int l1, char **pa0, char **pa1) {
char *a0 = malloc(sizeof(char) * (l0 + 1));
char *a1 = malloc(sizeof(char) * (l1 + 1));
strncpy(a0, a, l0);
a0[l0] = '\0';
strncpy(a1, a + l0, l1);
a1[l1] = '\0';
*pa0 = a0;
*pa1 = a1;
}
char *multiply_rec(char *a, char *b) {
int la = strlen(a);
int lb = strlen(b);
if (la < lb) {
return multiply_rec(b, a);
} else if (lb == 0) {
return strdup("");
} else if (la == 1) {
char *c = malloc(3);
int v = char2digit(a[0]) * char2digit(b[0]);
int offset = 0;
c[offset++] = digit2char(v % 10);
if (v >= 10) {
c[offset++] = digit2char(v / 10);
}
c[offset] = '\0';
return c;
} else if (la >= 2 * lb) {
char *a0, *a1;
halve(a, la - la / 2, la / 2, &a1, &a0);
char *c0 = multiply_rec(a0, b);
char *c1 = multiply_rec(a1, b);
char *c2 = shift_in(c0, la - la / 2);
char *sum = add_in(c2, c1);
free(a0);
free(a1);
free(c0);
free(c1);
free(c2);
return sum;
} else {
char *a0, *a1, *b0, *b1;
int half = lb / 2;
halve(a, half, la - half, &a1, &a0);
halve(b, half, lb - half, &b1, &b0);
// Karatsuba algo from O(N^2) to O(N^log(3)) = O(N^1.585)
// (a0 *B + a1) * (b0 * B + b1) = a0b0 * B2 + (a0b1 + a1b0) * B + a1b1
char *t[10];
char *a0b0 = multiply_rec(a0, b0);
char *a1b1 = multiply_rec(a1, b1);
// (a0 + a1)(b0 + b1) - a0b0 - a1b1
t[0] = add_in(a0, a1);
t[1] = add_in(b0, b1);
t[2] = multiply_rec(t[0], t[1]);
t[3] = sub_in(t[2], a0b0);
t[4] = sub_in(t[3], a1b1);
char *a0b0_ = shift_in(a0b0, half * 2);
char *mid_ = shift_in(t[4], half);
t[5] = add_in(a0b0_, mid_);
char *ret = add_in(t[5], a1b1);
free(a0);
free(a1);
free(b0);
free(b1);
free(a0b0);
free(a1b1);
free(a0b0_);
free(mid_);
int i;
for (i = 0; i != 6; i++) {
free(t[i]);
}
#if 0
char *tt = multiply_in(a, b);
if (strcmp(tt, ret) != 0) {
printf("calc %s*%s =%s != %s\n", a, b, ret, tt);
// assert(0);
}
free(tt);
#endif
return ret;
}
}
char *multiply_mix(char *a, char *b) {
int la = strlen(a);
int lb = strlen(b);
if (la < lb) {
return multiply_mix(b, a);
} else if (lb == 0 || la == 1 || la <= 2048) {
// cross point is 2K~4K
return multiply_in(a, b);
} else if (la >= 2 * lb) {
char *a0, *a1;
halve(a, la - la / 2, la / 2, &a1, &a0);
char *c0 = multiply_mix(a0, b);
char *c1 = multiply_mix(a1, b);
char *c2 = shift_in(c0, la - la / 2);
char *sum = add_in(c2, c1);
free(a0);
free(a1);
free(c0);
free(c1);
free(c2);
return sum;
} else {
char *a0, *a1, *b0, *b1;
int half = lb / 2;
halve(a, half, la - half, &a1, &a0);
halve(b, half, lb - half, &b1, &b0);
// (a0 *B + a1) * (b0 * B + b1) = a0b0 * B2 + (a0b1 + a1b0) * B + a1b1
char *t[10];
char *a0b0 = multiply_mix(a0, b0);
char *a1b1 = multiply_mix(a1, b1);
// (a0 + a1)(b0 + b1) - a0b0 - a1b1
t[0] = add_in(a0, a1);
t[1] = add_in(b0, b1);
t[2] = multiply_mix(t[0], t[1]);
t[3] = sub_in(t[2], a0b0);
t[4] = sub_in(t[3], a1b1);
char *a0b0_ = shift_in(a0b0, half * 2);
char *mid_ = shift_in(t[4], half);
t[5] = add_in(a0b0_, mid_);
char *ret = add_in(t[5], a1b1);
free(a0);
free(a1);
free(b0);
free(b1);
free(a0b0);
free(a1b1);
free(a0b0_);
free(mid_);
int i;
for (i = 0; i != 6; i++) {
free(t[i]);
}
return ret;
}
}
/** 内部处理的格式为reverse(skipZeros(n)) 处理过后的数据
* 也就是没有前导的零符号(直接使用空字符表示0)
* 按照进位顺序排列的数字数组,该数组以'\0'为结束
*/
char *funcOnString(char *(f)(char *, char *), char *a, char *b) {
// haskell style :)
// (checkZero . reverse) .: f `on` (reverse . skipZeros)
return checkZero(reverse(f(reverse(skipZeros(a)), reverse(skipZeros(b)))));
}
char *add(char *a, char *b) {
a = strdup(a);
b = strdup(b);
char *c = funcOnString(add_in, a, b);
free(a);
free(b);
return c;
}
char *muls(char a, char *b) {
return checkZero(reverse(muls_in(a, reverse(skipZeros(b)))));
}
char *multiply_on_func(char *(*f)(char *, char *),
char *a, char *b) {
// to accept string in static segment, duplicate it in enterance of code
a = strdup(a);
b = strdup(b);
char *c = funcOnString(f, a, b);
free(a);
free(b);
return c;
}
char *multiply(char *a, char *b) {
return multiply_on_func(multiply_in, a, b);
}
char *multiply_rec_ex(char *a, char *b) {
return multiply_on_func(multiply_rec, a, b);
}
char *multiply_mix_ex(char *a, char *b) {
return multiply_on_func(multiply_mix, a, b);
}
// test code
#ifndef INCLUDED_MULTIPLYSTRING
bool unit_reverse(char *a, char *expect) {
a = strdup(a);
char *ret = reverse(a);
bool r = strcmp(ret, expect) == 0;
printf("reverse(%s) = %s %s\n", a, ret, expect);
free(a);
return r;
}
int test_reverse() {
unit_reverse("", "");
unit_reverse("1", "1");
unit_reverse("12", "21");
unit_reverse("123", "321");
unit_reverse("1234", "4321");
return 0;
}
char *symbol(bool r) {
return r ? "==" : "/=";
}
bool unit(char *(*f)(char *, char *), char *funcName,
const char *a, const char *b, const char *expect) {
char *na = strdup(a), *nb = strdup(b);
printf("%s(%s, %s) ====>\n", funcName, a, b);
char *c = f(na, nb);
bool r = strcmp(c, expect) == 0;
printf("%s(%s, %s) = %s %s %s\n", funcName, a, b, c, symbol(r), expect);
if (!r) {
assert(0);
}
free(na);
free(nb);
free(c);
return r;
}
bool test_func_commutative(char *(*f)(char *, char *), char *funcName,
const char *a, const char *b, const char *expect) {
if (strcmp(a, b) == 0) {
return unit(f, funcName, a, b, expect);
} else {
return unit(f, funcName, a, b, expect) && unit(f, funcName, b, a, expect);
}
}
#define TEST_FUNC(f, a, b, c) test_func_commutative(f, #f, a, b, c)
#define TEST_ADD(a, b, c) TEST_FUNC(add, a, b, c)
bool test_add() {
TEST_ADD("12", "3", "15");
TEST_ADD("56", "789", "845");
TEST_ADD("2", "0", "2");
TEST_ADD("0", "0", "0");
return true;
}
bool unit_muls(char a, const char *b, const char *expect) {
char *nb = strdup(b);
char *c = muls(a, nb);
bool r = strcmp(c, expect) == 0;
printf("muls(%c, %s) = %s %s %s\n", a, b, c, symbol(r), expect);
free(c);
free(nb);
return r;
}
bool test_muls() {
unit_muls('8', "123", "984");
unit_muls('4', "123", "492");
return true;
}
bool test_mul_func(char *(*f)(char *, char *), char *funcName) {
#define TEST_MUL(a, b, c) test_func_commutative(f, funcName, a, b, c)
TEST_MUL("5", "13", "65");
TEST_MUL("8", "18", "144");
TEST_MUL("23", "56", "1288");
TEST_MUL("123", "456", "56088");
TEST_MUL("1234567890", "1234567890", "1524157875019052100");
TEST_MUL("2", "3", "6");
TEST_MUL("30", "69", "2070");
TEST_MUL("11", "85", "935");
TEST_MUL("2", "0", "0");
TEST_MUL("0", "30", "0");
TEST_MUL("0000001", "3", "3");
TEST_MUL("1009", "03", "3027");
TEST_MUL("98765", "56894", "5619135910");
TEST_MUL("1020303004875647366210", "2774537626200857473632627613",
"2830869077153280552556547081187254342445169156730");
TEST_MUL("1395", "5861209", "8176386555");
TEST_MUL("58608473622772837728372827", "7586374672263726736374",
"444625839871840560024489175424316205566214109298");
TEST_MUL("9007199254740991", "9007199254740991",
"81129638414606663681390495662081");
return true;
}
char *str_init_rnd(int len) {
char *na = malloc(sizeof(char) * (len + 1));
int i;
for (i = 0; i != len; i++) {
na[i] = digit2char(rand() % 10);
}
na[len] = '\0';
return na;
}
bool test_perf(char *(*f)(char *, char *), int len) {
char *na = str_init_rnd(len), *nb = str_init_rnd(len);
struct timeval start, stop;
gettimeofday(&start, NULL);
char *nc = f(na, nb);
gettimeofday(&stop, NULL);
printf("%lu",
(stop.tv_sec - start.tv_sec) * 1000 * 1000 +
stop.tv_usec - start.tv_usec);
// printf("mul(%s, %s) = %s\n", na, nb, nc);
free(na);
free(nb);
free(nc);
return true;
}
bool basic_group() {
test_reverse();
test_add();
test_muls();
test_mul_func(multiply, "mul");
test_mul_func(multiply_rec_ex, "mul_rec");
test_mul_func(multiply_mix_ex, "mul_mix");
return true;
}
bool perf_group() {
int i;
for (i = 4; i != 64 * 1024; i *= 2) {
printf("%d\t", i);
test_perf(multiply, i);
printf("\t");
test_perf(multiply_rec_ex, i);
printf("\t");
test_perf(multiply_mix_ex, i);
printf("\n");
}
return true;
}
int main() {
basic_group();
perf_group();
return 0;
}
#endif
|
the_stack_data/54826515.c
|
//随机访问文件
#include <stdio.h>
#include <stdlib.h>
#define SIZE 1000
int main(void){
double DAT[SIZE];
const char *fileName="target/numbers.dat";
FILE *fp;
for(int i=0;i<SIZE;i++){
DAT[i]=100*i+1/(i+1.0);
}
if( (fp=fopen(fileName,"wb")) ==NULL){//二进制只写模式
fprintf(stderr,"Can not open file: %s.\n",fileName);
exit(EXIT_FAILURE);
}
fwrite(DAT,sizeof(double),SIZE,fp);
if (fclose(fp) != 0){
fprintf(stderr,"Error in closing file %s\n", fileName);
exit(EXIT_FAILURE);
}
if( (fp=fopen(fileName,"rb")) ==NULL){//二进制只读模式
fprintf(stderr,"Can not open file: %s.\n",fileName);
exit(EXIT_FAILURE);
}
printf("input file index in [0,%d].\n",SIZE-1);
int i;
long pos;
double value;
while( scanf("%d",&i)==1 && i>=0 && i<SIZE ){
pos=(long)i*sizeof(double);
fseek(fp,pos,SEEK_SET);
fread(&value,sizeof(double),1,fp);
printf("there's value is:%f.\n",value);
puts("Next index:");
}
puts("==>over!");
if (fclose(fp) != 0){
fprintf(stderr,"Error in closing file %s\n", fileName);
exit(EXIT_FAILURE);
}
return 0;
}
|
the_stack_data/76701571.c
|
#include "../string.h"
char* __stpncpy(char*, const char*, size_t);
char* strncpy(char* restrict d, const char* restrict s, size_t n) {
__stpncpy(d, s, n);
return d;
}
|
the_stack_data/125141195.c
|
extern int bar1_from_bar3(void);
int bar3(void)
{
return bar1_from_bar3();
}
|
the_stack_data/150674.c
|
/* atoi.c - ascii-to-integer ncc standard library
Copyright (c) 1977-1995 by Robert Swartz. All rights reserved.
Copyright (c) 2021 Charles E. Youse ([email protected]).
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the copyright holder nor the names of the contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
#include <stdlib.h>
#include <ctype.h>
int atoi(const char *nptr)
{
int val;
int c;
int sign;
val = sign = 0;
while (isspace(c = *nptr++)) /* leading whitespace */
;
if (c == '-') { /* optional sign */
sign = 1;
c = *nptr++;
} else if (c == '+')
c = *nptr++;
for (; isdigit(c); c = *nptr++) /* digits */
val = val * 10 + c - '0';
return (sign ? -val : val);
}
/* vi: set ts=4 expandtab: */
|
the_stack_data/61647.c
|
#include <stdio.h>
struct twoxtwomat {
double a1;
double a2;
double b1;
double b2;
};
struct twoxtwomat inverse(struct twoxtwomat a)
{
struct twoxtwomat ret;
double det = a.a1 * a.b2 - a.a2 * a.b1;
ret.a1 = a.b2 / det;
ret.a2 = -a.a2 / det;
ret.b1 = -a.b1 / det;
ret.b2 = a.a1 / det;
return (ret);
}
int main()
{
struct twoxtwomat co;
struct twoxtwomat co_inv;
double x, y;
co.a1 = 3;
co.a2 = 5;
co.b1 = 2;
co.b2 = 7;
co_inv = inverse(co);
x = co_inv.a1 * 7500 + co_inv.a2 * 8850;
y = co_inv.b1 * 7500 + co_inv.b2 * 8850;
printf("武: %f, 景子: %f", x, y);
return (0);
}
|
the_stack_data/46101.c
|
int main() {
char s[256];
int i;
int c = getchar();
for (i = 0; c != -1 && i < 256; i++) {
s[i] = c;
c = getchar();
}
for (; i > 0; i--) {
putchar(s[i-1]);
}
putchar('\n');
return 0;
}
|
the_stack_data/187643426.c
|
/**
* Copyright (c) 2021 Wavious LLC.
*
* SPDX-License-Identifier: Apache-2.0
*/
void board_init(void)
{
// Setup MTVEC
// TODO: Decouple from FreeRTOS
__asm__ __volatile__ (
"la t0, freertos_risc_v_trap_handler\n"
"csrw mtvec, t0"
);
}
|
the_stack_data/80089.c
|
// This file is part of CPAchecker,
// a tool for configurable software verification:
// https://cpachecker.sosy-lab.org
//
// SPDX-FileCopyrightText: 2007-2020 Dirk Beyer <https://www.sosy-lab.org>
//
// SPDX-License-Identifier: Apache-2.0
int main() {
int __BLAST_NONDET;
int x;
int y;
x = __BLAST_NONDET;
y = __BLAST_NONDET;
if (x != y) {
ERROR:
goto ERROR;
}
}
|
the_stack_data/115766721.c
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void badpass()
{
printf("\nwrong password. try again!\n");
}
void goodpass()
{
printf("\ncorrect password. bye!\n");
}
int main(int argc, char *argv[])
{
//pass = "Audere est Facere"
// e @ 3,5,7,14,16
// space @ 6, 10
// ere @ 3, 14
// Aud @ 0
// Fac @ 11
// st @ 8
char password[31]; // = "Audere est Facere";
unsigned int x;
int e[] = { 3,5,7,14,16 };
int esize;
int i;
printf("what is the password? ");
scanf("%30[0-9a-zA-Z ]", &password);
if (strlen(password) == 17)
{
esize = sizeof(e) / sizeof(e[0]);
for (i = esize; i > 0; i--)
{
if (password[e[i - 1]] != 'e')
{
badpass();
return 0;
}
}
x = *((unsigned int*)(password + 3)) & *((unsigned int*)(password + 14));
x &= 0x0ffffff;
if (0 == strcmp((char*)&x, "ere"))
{
if (0 == (password[6] ^ password[10]))
{
if (0x40 == (password[6] + password[10]))
{
if ((*((unsigned int*)password) & ~(0xff << 24)) == 'duA')
{
if ((*((unsigned int*)(password + 11)) & ~(0xff << 24)) == 'caF')
{
if ((*((unsigned int*)(password + 8)) & ~(0xffff << 16)) == 'ts')
{
goodpass();
return 0;
}
}
}
}
}
}
}
badpass();
return 0;
}
|
the_stack_data/122015303.c
|
#include <stdio.h>
#include <math.h>
void prime_factors(int n)
{
int i;
int count = 0;
while (n % 2 == 0){
printf("%d ", 2);
n = n / 2;
count = 1;
}
if (count != 0){
printf("\n");
count = 0;
}
for (i=3; i <= sqrt(n); i += 2){
while (n % i == 0){
printf("%d ", i);
n = n / i;
count = 1;
}
if (count != 0){
printf("\n");
count = 0;
}
}
if (n > 2){
printf("%d\n", n);
}
}
int main(){
int n;
printf("Enter n: ");
scanf("%d", &n);
prime_factors(n);
return 0;
}
|
the_stack_data/154830693.c
|
/* { dg-do run } */
/* Verify we do not get a bogus access function pairs with
exchanged dimensions, 0, {1, +, 1}_1 vs. {2B, +, 1}_1, 0 which
disambiguates both accesses and leads to vectorization. */
extern int memcmp(const void *, const void *, __SIZE_TYPE__);
extern void abort (void);
short a[33] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 };
short b[33] = { 0, };
char * volatile ap_ = (char *)&a[0];
int main()
{
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
int i;
char *ap = ap_;
if (sizeof (short) == 2)
{
for (i = 0; i < 64; ++i)
{
(*((char(*)[])&ap[i+2]))[0] = (*((char(*)[])&ap[0]))[i+1];
}
if (memcmp (&a, &b, sizeof (a)) != 0)
abort ();
}
#endif
return 0;
}
|
the_stack_data/211080457.c
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_print_bits.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jjourne <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/09/22 22:19:35 by jjourne #+# #+# */
/* Updated: 2016/09/22 23:29:06 by jjourne ### ########.fr */
/* */
/* ************************************************************************** */
void ft_putchar(char c);
void ft_print_bits(unsigned char octet)
{
int i;
int tmp;
i = 7;
while (i >= 0)
{
tmp = octet >> i;
ft_putchar((tmp & 1) + '0');
i--;
}
}
|
the_stack_data/81301.c
|
#define ROW_ARGS (unsigned char *source_row_start, unsigned char *source_row_end, unsigned char *destination_row_start, int srcMask, int destMask)
extern void _left_right_solid ROW_ARGS
{
unsigned char *source_row_ptr;
unsigned char *destination_row_ptr = destination_row_start;
for ( source_row_ptr = source_row_start; source_row_ptr < source_row_end ; source_row_ptr++ )
{
*destination_row_ptr= *source_row_ptr;
destination_row_ptr++;
}
}
extern void _right_left_solid ROW_ARGS
{
unsigned char *source_row_ptr;
unsigned char *destination_row_ptr = destination_row_start;
for ( source_row_ptr = source_row_end-1; source_row_ptr >= source_row_start ; source_row_ptr-- )
{
*destination_row_ptr= *source_row_ptr;
destination_row_ptr++;
}
}
|
the_stack_data/190768926.c
|
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
/// time_stamp(): funcion returns current date and time in format of 'YYYYMMDDhhmmss'.
///
char *time_stamp(char *time_S){
time_t currentTime;
time(¤tTime);
struct tm *myTime = localtime(¤tTime);
sprintf(time_S, "%i%i%i%i%i%i", myTime->tm_year + 1900, myTime->tm_mon + 1, myTime->tm_mday,
myTime->tm_hour, myTime->tm_min, myTime->tm_sec );
return time_S;
}
/// backup_file(): funtion creates a backup copy of each modified file.
///
/// Backup copy is created as gzip archive that folows name convention <original_file_name>.<timestamp>.gz
///
int backup_file(char path[]){
char command[256];
char time_S[14];
int status;
char pathS[100];
time_stamp(time_S);
strncpy(pathS, path, strlen(path)-1);
sprintf(command, "cp %s %s.%s && gzip %s.%s", pathS, pathS, time_S, pathS, time_S);
status = system(command);
return status;
}
/// get_file_list(): function to prepare list of files that have pattern in them.
///* @path[]: path to file or folder to search in. Respective value provided by user in GUI as 'Path'.
///* @pattern[]: regular expression provided by user in GUI as 'Find'.
///
/// Return: function returnes *FILE that points to command's output which is list of required files.
///
FILE *get_file_list(char path[], char pattern[]) {
FILE *output;
char command[256];
sprintf(command, "grep -rl '%s' %s 2>/dev/null", pattern, path);
// Open the command's output as file for reading.
output = popen(command, "r");
if (output == NULL) {
printf("Command failed\n" );
exit(1);
}
return output;
}
/// substitution(): function that substitutes each pattern inclusion whith replacement.
///
///* @file_list: pointer to list of files that need to be modified.
///* @pattern[]: pattern to be replaced in form of regular expression.
///* @replacement[]: string that should replace each pattern inclusion.
///
int substitution(FILE *file_list, char pattern[], char replacement[]){
char path[100];
char *line;
char command[256];
int status;
// Read file from list. Modify file.
while(fgets (path, sizeof(path), file_list) != NULL ) {
backup_file(path);
sprintf(command, "sed -i 's/%s/%s/g' %s", pattern, replacement, path);
status = system(command);
}
return 0;
}
|
the_stack_data/47289.c
|
/******************************************************************************
* @from azrael.digipen.edu/~mmead/www/Courses/CS180/getopt.html
* @brief
* read option without arguments
*
* | command line options | output |
* | ---------------------------------------------- |
* | -b | Option 'b' was provided |
* | ---------------------------------------------- |
* | -b -X -a | Option 'b' was provided |
* | | Option 'X' was provided |
* | | Option 'a' was provided |
* | ---------------------------------------------- |
* | -bXa | Option 'b' was provided |
* | | Option 'X' was provided |
* | | Option 'a' was provided |
* | ---------------------------------------------- |
* | -t | Invalid option -- 't' |
*****************************************************************************/
#include <unistd.h>
#include <getopt.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
for (int i = 0; i < argc; i++)
{
printf("arg#%d = %s\n", i, argv[i]);
}
int opt;
while ((opt = getopt(argc, argv, "abX")) != -1)
{
switch (opt)
{
case 'a':
{
printf("Option 'a' was provided\n");
}break;
case 'b':
{
printf("Option 'b' was provided\n");
}break;
case 'X':
{
printf("Option 'X' was provided\n");
}break;
}
}
printf("bye bye\n");
return 0;
}
|
the_stack_data/37638549.c
|
#include <stdio.h>
#define MAX 10
/*
ES4 - Scrivere un programma che chiede all'utente la dimensione m di due
matrici quadrate di interi A e B (un valore intero compreso tra 1 e 10 e nel
caso non sia valido va richiesto) e poi i dati per popolare le due matrici.
Per ogni valore n compreso tra 2 e m (estremi inclusi), il programma calcola
e stampa le coordinate (i,j) dell'angolo in alto a sinistra di tutte le
sottomatrici quadrate nxn di A e B che soddisfano entrambe le seguenti
condizioni:
- hanno la stessa posizione (i,j) in entrambe le matrici A e B
- la sottomatrice definita su A e la sottomatrice definita su B sono uguali
(contengono gli stessi elementi, posizione per posizione)
Esempio:
Date le matrici
A: B:
5 3 7 1 8 0 3 7 0 1
3 9 2 7 1 0 9 2 7 0
3 9 7 5 6 3 9 7 5 1
4 5 7 1 3 4 5 7 1 0
8 6 2 9 9 1 0 0 9 1
L'output del programma sarà
N=2
(0, 1) (1, 1) (1, 2) (2, 0) (2, 1) (2, 2)
N=3
(1, 1)
N=4
Nessuna sottomatrice soddisfa le condizioni
N=5
Nessuna sottomatrice soddisfa le condizioni
*/
int main() {
int m, i, j, n, almenoUna, valida, ii, jj;
int A[MAX][MAX], B[MAX][MAX];
do {
printf("Dimensione: ");
scanf("%d", &m);
} while (m < 1 || m > MAX);
printf("\nDati A:\n");
for (i = 0; i < m; i++)
for (j = 0; j < m; j++)
scanf("%d", &A[i][j]);
printf("\nDati B:\n");
for (i = 0; i < m; i++)
for (j = 0; j < m; j++)
scanf("%d", &B[i][j]);
for (n = 2; n <= m; n++) {
printf("\nN = %d\n", n);
almenoUna = 0;
for (i = 0; i <= m - n; i++) {
for (j = 0; j <= m - n; j++) {
valida = 1;
for (ii = 0; ii < n && valida; ii++)
for (jj = 0; jj < n && valida; jj++)
if (A[i + ii][j + jj] != B[i + ii][j + jj])
valida = 0;
if (valida) {
printf("(%d, %d) ", i, j);
almenoUna = 1;
}
}
}
if (!almenoUna)
printf("Nessuna sottomatrice soddisfa le condizioni");
printf("\n\n");
}
return 0;
}
|
the_stack_data/125029.c
|
#include <stdio.h>
int especies[100010];
int main(){
int n;
scanf("%d", &n);
int vet[n];
for(int i = 0; i < n; i++){
scanf("%d", &vet[i]);
}
for(int i = 0; i < n; i++){
especies[vet[i]]++;
}
for(int i = 1; i < 50; i++){
if(especies[i] != 0 ){
printf("%d ", i);
}
}
return 0;
}
|
the_stack_data/162643029.c
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void LCS(char X[], char Y[])
{
int m = strlen(X)+1;
int n = strlen(Y)+1;
int c[m][n];
char b[m][n];
for(int i=0;i<m;i++) c[i][0] = 0;
for(int i=0;i<n;i++) c[0][i] = 0;
for(int i=1;i<m;i++)
{
for(int j=1;j<n;j++)
{
if(X[i-1] == Y[j-1])
{
c[i][j] = c[i-1][j-1]+1;
b[i][j] = '\\';
}
else if(c[i-1][j] >= c[i][j-1])
{
c[i][j] = c[i-1][j];
b[i][j] = '|';
}
else
{
c[i][j] = c[i][j-1];
b[i][j] = '-';
}
}
}
printf("\n");
printf(" - ");
for(int i=0;i<n;i++) printf("%c ", Y[i]);
printf("\n");
for(int i=0;i<m;i++)
{
printf(" ");
for(int j=0;j<n;j++)
{
printf("%c ", b[i][j]);
}
printf("\n");
if(i == 0) printf("- ");
else printf("%c ", X[i-1]);
for(int j=0;j<n;j++)
{
printf("%d ", c[i][j]);
}
printf("\n");
}
printf("\n");
char lcs[c[m-1][n-1]+1];
int i=m-1, j=n-1, k=c[m-1][n-1]-1;
while(i!=0 && j!=0)
{
if(X[i-1] == Y[j-1])
{
lcs[k] = X[i-1];
k--;
i--;
j--;
}
else if(c[i-1][j] >= c[i][j-1])
{
i--;
}
else j--;
}
lcs[c[m-1][n-1]] = '\0';
printf("The lcs of %s and %s is %s.", X, Y, lcs);
}
int main()
{
char A[] = "tirthasheshpatel";
char B[] = "letaphsehsahtrit";
LCS(A,B);
}
|
the_stack_data/90762537.c
|
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<string.h>
void init() {
setvbuf(stdin, NULL, _IONBF, 0);
setvbuf(stdout, NULL, _IONBF, 0);
setvbuf(stderr, NULL, _IONBF, 0);
}
int vuln(void){
char buf[72];
puts("YOU ONLY GET ONE CHANCE SO....");
puts("| 👊 Punch harder 👊 |");
fgets(buf,124,stdin);
printf(buf);
return 0;
}
int main(void) {
init();
vuln();
return 0;
}
//gcc chall.c -o chall -Wl,-z,norelro -no-pie
|
the_stack_data/73574109.c
|
/* This testcase is part of GDB, the GNU debugger.
Copyright 2013-2020 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <stdlib.h>
void funca(void);
int count = 0;
typedef struct
{
char *nothing;
int f;
short s;
} foobar;
void end_func (int foo, char *bar, foobar *fb, foobar bf)
{
const char *str = "The End";
const char *st2 = "Is Near";
int b = 12;
short c = 5;
{
int d = 15;
int e = 14;
const char *foo = "Inside block";
{
int f = 42;
int g = 19;
const char *bar = "Inside block x2";
{
short h = 9;
h = h +1; /* Inner test breakpoint */
}
}
}
return; /* Backtrace end breakpoint */
}
void funcb(int j)
{
struct foo
{
int a;
int b;
};
struct foo bar;
bar.a = 42;
bar.b = 84;
funca();
return;
}
void funca(void)
{
foobar fb;
foobar *bf;
if (count < 10)
{
count++;
funcb(count);
}
fb.nothing = "Foo Bar";
fb.f = 42;
fb.s = 19;
bf = malloc (sizeof (foobar));
bf->nothing = malloc (128);
bf->nothing = "Bar Foo";
bf->f = 24;
bf->s = 91;
end_func(21, "Param", bf, fb);
free (bf->nothing);
free (bf);
return;
}
void func1(void)
{
funca();
return;
}
int func2(void)
{
func1();
return 1;
}
void func3(int i)
{
func2();
return;
}
int func4(int j)
{
func3(j);
return 2;
}
int func5(int f, int d)
{
int i = 0;
char *random = "random";
i=i+f;
func4(i);
return i;
}
int
main()
{
func5(3,5);
return 0;
}
|
the_stack_data/187641975.c
|
#ifndef TH_GENERIC_FILE
#define TH_GENERIC_FILE "generic/SpatialReflectionPadding.c"
#else
static void THNN_(SpatialReflectionPadding_updateOutput_frame)(
real *input_p, real *output_p,
int64_t nslices,
int64_t iwidth, int64_t iheight,
int64_t owidth, int64_t oheight,
int pad_l, int pad_r,
int pad_t, int pad_b)
{
int iStartX = fmax(0, -pad_l);
int iStartY = fmax(0, -pad_t);
int oStartX = fmax(0, pad_l);
int oStartY = fmax(0, pad_t);
int64_t k, ip_x, ip_y;
#pragma omp parallel for private(k, ip_x, ip_y)
for (k = 0; k < nslices; k++)
{
int64_t i, j;
for (i = 0; i < oheight; i++) {
for (j = 0; j < owidth; j++) {
if (j < pad_l) {
ip_x = pad_l * 2 - j;
} else if (j >= pad_l && j < iwidth + pad_l) {
ip_x = j;
} else {
ip_x = (iwidth + pad_l - 1) * 2 - j;
}
ip_x = ip_x - oStartX + iStartX;
if (i < pad_t) {
ip_y = pad_t * 2 - i;
} else if (i >= pad_t && i < iheight + pad_t) {
ip_y = i;
} else {
ip_y = (iheight + pad_t - 1) * 2 - i;
}
ip_y = ip_y - oStartY + iStartY;
real *dest_p = output_p + k*owidth*oheight + i * owidth + j;
real *src_p = input_p + k*iwidth*iheight + ip_y * iwidth + ip_x;
*dest_p = *src_p;
}
}
}
}
void THNN_(SpatialReflectionPadding_updateOutput)(THNNState *state,
THTensor *input,
THTensor *output,
int pad_l, int pad_r,
int pad_t, int pad_b)
{
int dimw = 2;
int dimh = 1;
int dimslices = 0;
int64_t nbatch = 1;
int64_t nslices;
int64_t iheight;
int64_t iwidth;
int64_t oheight;
int64_t owidth;
real *input_data;
real *output_data;
THNN_ARGCHECK(!input->is_empty() && (input->dim() == 3 || input->dim() == 4), 2, input,
"non-empty 3D or 4D (batch mode) tensor expected for input, but got: %s");
if (input->dim() == 4)
{
nbatch = input->size(0);
dimw++;
dimh++;
dimslices++;
}
/* input sizes */
nslices = input->size(dimslices);
iheight = input->size(dimh);
iwidth = input->size(dimw);
AT_CHECK(pad_l < iwidth && pad_r < iwidth,
"Argument #4: Padding size should be less than the corresponding input dimension, "
"but got: padding (", pad_l, ", ", pad_r, ") at dimension ", dimw, " of input ", input->sizes());
AT_CHECK(pad_t < iheight && pad_b < iheight,
"Argument #6: Padding size should be less than the corresponding input dimension, "
"but got: padding (", pad_t, ", ", pad_b, ") at dimension ", dimh, " of input ", input->sizes());
/* output sizes */
oheight = iheight + pad_t + pad_b;
owidth = iwidth + pad_l + pad_r;
THArgCheck(owidth >= 1 || oheight >= 1 , 2,
"input (H: %d, W: %d)is too small."
" Calculated output H: %d W: %d",
iheight, iwidth, oheight, owidth);
/* get contiguous input */
input = THTensor_(newContiguous)(input);
/* resize output */
if (input->dim() == 3)
{
THTensor_(resize3d)(output, nslices, oheight, owidth);
input_data = THTensor_(data)(input);
output_data = THTensor_(data)(output);
THNN_(SpatialReflectionPadding_updateOutput_frame)(input_data, output_data,
nslices,
iwidth, iheight,
owidth, oheight,
pad_l, pad_r,
pad_t, pad_b);
}
else
{
int64_t p;
THTensor_(resize4d)(output, nbatch, nslices, oheight, owidth);
input_data = THTensor_(data)(input);
output_data = THTensor_(data)(output);
#pragma omp parallel for private(p)
for (p = 0; p < nbatch; p++)
{
THNN_(SpatialReflectionPadding_updateOutput_frame)(
input_data+p*nslices*iwidth*iheight,
output_data+p*nslices*owidth*oheight,
nslices,
iwidth, iheight,
owidth, oheight,
pad_l, pad_r,
pad_t, pad_b);
}
}
/* cleanup */
THTensor_(free)(input);
}
static void THNN_(SpatialReflectionPadding_updateGradInput_frame)(
real *ginput_p, real *goutput_p,
int64_t nslices,
int64_t iwidth, int64_t iheight,
int64_t owidth, int64_t oheight,
int pad_l, int pad_r,
int pad_t, int pad_b)
{
int iStartX = fmax(0, -pad_l);
int iStartY = fmax(0, -pad_t);
int oStartX = fmax(0, pad_l);
int oStartY = fmax(0, pad_t);
int64_t k, ip_x, ip_y;
#pragma omp parallel for private(k, ip_x, ip_y)
for (k = 0; k < nslices; k++)
{
int64_t i, j;
for (i = 0; i < oheight; i++) {
for (j = 0; j < owidth; j++) {
if (j < pad_l) {
ip_x = pad_l * 2 - j;
} else if (j >= pad_l && j < iwidth + pad_l) {
ip_x = j;
} else {
ip_x = (iwidth + pad_l - 1) * 2 - j;
}
ip_x = ip_x - oStartX + iStartX;
if (i < pad_t) {
ip_y = pad_t * 2 - i;
} else if (i >= pad_t && i < iheight + pad_t) {
ip_y = i;
} else {
ip_y = (iheight + pad_t - 1) * 2 - i;
}
ip_y = ip_y - oStartY + iStartY;
real *src_p = goutput_p + k*owidth*oheight + i * owidth + j;
real *dest_p = ginput_p + k*iwidth*iheight + ip_y * iwidth + ip_x;
*dest_p += *src_p;
}
}
}
}
void THNN_(SpatialReflectionPadding_updateGradInput)(THNNState *state,
THTensor *input,
THTensor *gradOutput,
THTensor *gradInput,
int pad_l, int pad_r,
int pad_t, int pad_b)
{
int dimw = 2;
int dimh = 1;
int dimslices = 0;
int64_t nbatch = 1;
int64_t nslices;
int64_t iheight;
int64_t iwidth;
int64_t oheight;
int64_t owidth;
if (input->dim() == 4)
{
nbatch = input->size(0);
dimw++;
dimh++;
dimslices++;
}
/* sizes */
nslices = input->size(dimslices);
iheight = input->size(dimh);
iwidth = input->size(dimw);
oheight = iheight + pad_t + pad_b;
owidth = iwidth + pad_l + pad_r;
THArgCheck(owidth == THTensor_(size)(gradOutput, dimw), 3,
"gradOutput width unexpected. Expected: %d, Got: %d",
owidth, THTensor_(size)(gradOutput, dimw));
THArgCheck(oheight == THTensor_(size)(gradOutput, dimh), 3,
"gradOutput height unexpected. Expected: %d, Got: %d",
oheight, THTensor_(size)(gradOutput, dimh));
/* get contiguous gradOutput */
gradOutput = THTensor_(newContiguous)(gradOutput);
/* resize */
THTensor_(resizeAs)(gradInput, input);
THTensor_(zero)(gradInput);
/* backprop */
if (input->dim() == 3) {
THNN_(SpatialReflectionPadding_updateGradInput_frame)(
THTensor_(data)(gradInput),
THTensor_(data)(gradOutput),
nslices,
iwidth, iheight,
owidth, oheight,
pad_l, pad_r,
pad_t, pad_b);
} else {
int64_t p;
#pragma omp parallel for private(p)
for (p = 0; p < nbatch; p++) {
THNN_(SpatialReflectionPadding_updateGradInput_frame)(
THTensor_(data)(gradInput) + p * nslices * iheight * iwidth,
THTensor_(data)(gradOutput) + p * nslices * oheight * owidth,
nslices,
iwidth, iheight,
owidth, oheight,
pad_l, pad_r,
pad_t, pad_b);
}
}
/* cleanup */
THTensor_(free)(gradOutput);
}
#endif
|
the_stack_data/1234511.c
|
/*
version 20080912
D. J. Bernstein
Public domain.
*/
#define ROUNDS 20
typedef unsigned int uint32;
static uint32 rotate(uint32 u,int c)
{
return (u << c) | (u >> (32 - c));
}
static uint32 load_littleendian(const unsigned char *x)
{
return
(uint32) (x[0]) \
| (((uint32) (x[1])) << 8) \
| (((uint32) (x[2])) << 16) \
| (((uint32) (x[3])) << 24)
;
}
static void store_littleendian(unsigned char *x,uint32 u)
{
x[0] = u; u >>= 8;
x[1] = u; u >>= 8;
x[2] = u; u >>= 8;
x[3] = u;
}
int crypto_core_salsa20(
unsigned char *out,
const unsigned char *in,
const unsigned char *k,
const unsigned char *c
)
{
uint32 x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15;
uint32 j0, j1, j2, j3, j4, j5, j6, j7, j8, j9, j10, j11, j12, j13, j14, j15;
int i;
j0 = x0 = load_littleendian(c + 0);
j1 = x1 = load_littleendian(k + 0);
j2 = x2 = load_littleendian(k + 4);
j3 = x3 = load_littleendian(k + 8);
j4 = x4 = load_littleendian(k + 12);
j5 = x5 = load_littleendian(c + 4);
j6 = x6 = load_littleendian(in + 0);
j7 = x7 = load_littleendian(in + 4);
j8 = x8 = load_littleendian(in + 8);
j9 = x9 = load_littleendian(in + 12);
j10 = x10 = load_littleendian(c + 8);
j11 = x11 = load_littleendian(k + 16);
j12 = x12 = load_littleendian(k + 20);
j13 = x13 = load_littleendian(k + 24);
j14 = x14 = load_littleendian(k + 28);
j15 = x15 = load_littleendian(c + 12);
for (i = ROUNDS;i > 0;i -= 2) {
x4 ^= rotate( x0+x12, 7);
x8 ^= rotate( x4+ x0, 9);
x12 ^= rotate( x8+ x4,13);
x0 ^= rotate(x12+ x8,18);
x9 ^= rotate( x5+ x1, 7);
x13 ^= rotate( x9+ x5, 9);
x1 ^= rotate(x13+ x9,13);
x5 ^= rotate( x1+x13,18);
x14 ^= rotate(x10+ x6, 7);
x2 ^= rotate(x14+x10, 9);
x6 ^= rotate( x2+x14,13);
x10 ^= rotate( x6+ x2,18);
x3 ^= rotate(x15+x11, 7);
x7 ^= rotate( x3+x15, 9);
x11 ^= rotate( x7+ x3,13);
x15 ^= rotate(x11+ x7,18);
x1 ^= rotate( x0+ x3, 7);
x2 ^= rotate( x1+ x0, 9);
x3 ^= rotate( x2+ x1,13);
x0 ^= rotate( x3+ x2,18);
x6 ^= rotate( x5+ x4, 7);
x7 ^= rotate( x6+ x5, 9);
x4 ^= rotate( x7+ x6,13);
x5 ^= rotate( x4+ x7,18);
x11 ^= rotate(x10+ x9, 7);
x8 ^= rotate(x11+x10, 9);
x9 ^= rotate( x8+x11,13);
x10 ^= rotate( x9+ x8,18);
x12 ^= rotate(x15+x14, 7);
x13 ^= rotate(x12+x15, 9);
x14 ^= rotate(x13+x12,13);
x15 ^= rotate(x14+x13,18);
}
x0 += j0;
x1 += j1;
x2 += j2;
x3 += j3;
x4 += j4;
x5 += j5;
x6 += j6;
x7 += j7;
x8 += j8;
x9 += j9;
x10 += j10;
x11 += j11;
x12 += j12;
x13 += j13;
x14 += j14;
x15 += j15;
store_littleendian(out + 0,x0);
store_littleendian(out + 4,x1);
store_littleendian(out + 8,x2);
store_littleendian(out + 12,x3);
store_littleendian(out + 16,x4);
store_littleendian(out + 20,x5);
store_littleendian(out + 24,x6);
store_littleendian(out + 28,x7);
store_littleendian(out + 32,x8);
store_littleendian(out + 36,x9);
store_littleendian(out + 40,x10);
store_littleendian(out + 44,x11);
store_littleendian(out + 48,x12);
store_littleendian(out + 52,x13);
store_littleendian(out + 56,x14);
store_littleendian(out + 60,x15);
return 0;
}
|
the_stack_data/73575281.c
|
#include <stdio.h>
#include "string.h"
void extractGpsInfo(char* menuStr, char* gpsInfo)
{
strncpy(gpsInfo, menuStr+7, 10);
gpsInfo[10] = '\0';
}
void decode64(char *RxdBuffer, unsigned char *ptrOut, int len)
{
unsigned char a,b,c,d;
unsigned char ptr = 0;
unsigned char x,y,z;
int ptrIn;
ptrIn = 3; // skip first 3 chrs (#)[TYPE][Addr] 1234567893
len = len-5;
while (len) {
//printf("ptr : %d => chr: %d \n",ptrIn,RxdBuffer[ptrIn]);
a = RxdBuffer[ptrIn++] - '=';
b = RxdBuffer[ptrIn++] - '=';
c = RxdBuffer[ptrIn++] - '=';
d = RxdBuffer[ptrIn++] - '=';
x = (a << 2) | (b >> 4);
y = ((b & 0x0f) << 4) | (c >> 2);
z = ((c & 0x03) << 6) | d;
// if(ptrIn > len - 2) break;
if (len--) ptrOut[ptr++] = x; else break;
if (len--) ptrOut[ptr++] = y; else break;
if (len--) ptrOut[ptr++] = z; else break;
}
}
void encode64(char *Data, char *TX_Buff, int Length)
{
unsigned int pt = 0;
unsigned char a,b,c;
unsigned char ptr = 0;
while (Length > 0) {
if (Length) { a = Data[ptr++]; Length--;} else a = 0;
if (Length) { b = Data[ptr++]; Length--;} else b = 0;
if (Length) { c = Data[ptr++]; Length--;} else c = 0;
TX_Buff[pt++] = '=' + (a >> 2);
TX_Buff[pt++] = '=' + (((a & 0x03) << 4) | ((b & 0xf0) >> 4));
TX_Buff[pt++] = '=' + (((b & 0x0f) << 2) | ((c & 0xc0) >> 6));
TX_Buff[pt++] = '=' + ( c & 0x3f);
}
TX_Buff[pt] = 0;
}
void addCRC(char *TXBuff, char *CRC)
{
unsigned int tmpCRC = 0;
unsigned int i;
for (i = 0; i < strlen(TXBuff); i++) {
tmpCRC += TXBuff[i];
}
tmpCRC %= 4096;
CRC[0] = '=' + tmpCRC / 64;
CRC[1] = '=' + tmpCRC % 64;
CRC[2] = '\r';
CRC[3] = '\n';
CRC[4] = '\0';
}
int checkCRC(char *t_InData, int Length)
{
int CRC = 0;
int i;
if (t_InData[1] == 127) {
t_InData[1] = 0;
}
for (i=0; i < Length-2; i++) {
CRC+=t_InData[i];
}
CRC = CRC % 4096;
if (t_InData[Length - 2] != ('=' + (CRC / 64))) {
return 0;
}
if (t_InData[Length - 1] != ('=' + CRC % 64)) {
return 0;
}
return 1;
}
#if 0
char *ftoa(char *a, double f, int precision)
{
long p[] = {0,10,100,1000,10000,100000,1000000,10000000,100000000};
char *ret = a;
long heiltal = (long)f;
_itoa(heiltal, a, 10);
while (*a != '\0') a++;
*a++ = '.';
long desimal = abs((long)((f - heiltal) * p[precision]));
_itoa(desimal, a, 10);
return ret;
}
#endif
|
the_stack_data/15392.c
|
/* Example code for Exercises in C.
Copyright 2014 Allen Downey
License: MIT License
Based on an example from
https://raw.githubusercontent.com/twcamper/head-first-c/master/10/math-master.c
Based on an example in Head First C.
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#include <string.h>
#include <errno.h>
#include <signal.h>
int score = 0;
int ended = 0;
/* Set up a signal handler.
sig: signal number
handler: signal handler function
*/
int catch_signal(int sig, void (*handler) (int)) {
struct sigaction action;
action.sa_handler = handler;
sigemptyset(&action.sa_mask);
action.sa_flags = 0;
return sigaction(sig, &action, NULL);
}
/* Signal handler: End the game.
*/
void end_game(int sig)
{
printf("\nFinal score: %i\n", score);
exit(EXIT_SUCCESS);
}
/* Signal handler: Notify the user and raise SIGINT.
*/
void times_up(int sig) {
puts("TIME'S UP! Finish up now...");
ended = 1;
}
int main(void) {
int a, b, answer;
char txt[4];
// when the alarm goes off, call times_up
catch_signal(SIGALRM, times_up);
// if we get interrupted, end the game
catch_signal(SIGINT, end_game);
// seed the random number generator
srandom((unsigned int) time(NULL));
while(1) {
// pose the question
a = rand() % 11;
b = rand() % 11;
printf("\nWhat is %d times %d? ", a, b);
// set (or reset) the alarm
alarm(5);
// get the answer
while (1) {
char *ret = fgets(txt, 4, stdin);
if (ret) break;
}
answer = atoi(txt);
// check the answer
if (answer == a * b) {
printf("\nRight!\n");
score++;
} else {
printf("\nWrong!\n");
}
if (ended)
raise(SIGINT);
else
printf("Score: %i\n", score);
}
return 0;
}
|
the_stack_data/192330045.c
|
// RUN: %clang -S -emit-llvm %s -o - \
// RUN: | opt -load %shlibdir/libProfiler%shlibext -legacy-profiler -S -o %t.ll
// RUN: %clang %t.ll -o %t.bin
// RUN: %t.bin | FileCheck --check-prefix=CHECK-UNPROFILED %s
// CHECK-UNPROFILED-NOT: BB_EXEC
// CHECK: is at index
// RUN: %clang -shared -fPIC %S/ProfilerRoutine.c -o %T/libProfilerRoutine%shlibext
// RUN: LD_PRELOAD=%T/libProfilerRoutine%shlibext %t.bin | FileCheck --check-prefix=CHECK-PROFILED %s
// CHECK-PROFILED: BB_EXEC
#include <stdio.h>
int bsearch(int *a, int n, int x) {
int i = 0, j = n - 1;
while (i <= j) {
int k = i + ((j - i) / 2);
if (a[k] == x) {
return k;
} else if (a[k] < x) {
i = k + 1;
} else {
j = k - 1;
}
}
return -1;
}
int main() {
int a[] = {-31, 0, 1, 2, 2, 4, 65, 83, 99, 782};
int n = sizeof a / sizeof a[0];
int x = 2;
int i = bsearch(a, n, x);
printf("%d is at index %d\n", x, i);
return 0;
}
|
the_stack_data/772897.c
|
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <stdlib.h>
//Linked list structure and functions
typedef struct ListNode
{
int item;
struct ListNode *next;
} ListNode;
typedef struct List
{
int size;
struct ListNode *head;
} List;
List * make_list()
{
List *l = (List *)malloc(sizeof(List));
l->size = 0;
l->head = 0;
return l;
}
int get_list(List *l, int index)
{
ListNode *curr = l->head;
for (int i = 0; i < index; i++)
curr = curr->next;
return curr->item;
}
void insert_list(List *l, int index, int val)
{
ListNode *node = (ListNode *)malloc(sizeof(ListNode));
node->item = val;
if (index == 0)
{
node->next = l->head;
l->head = node;
}
else
{
ListNode *curr = l->head;
for (int i=0; i<index-1; ++i)
curr = curr->next;
node->next = curr->next;
curr->next = node;
}
l->size++;
}
void remove_list(List *l, int index)
{
ListNode *del;
if (index == 0) {
del = l->head;
l->head = del->next;
}
else
{
ListNode *curr = l->head;
for (int i=0; i<index-1; ++i)
curr = curr->next;
del = curr->next;
curr->next = del->next;
}
if (del)
free(del);
l->size--;
}
int get_length(List *l)
{
return l->size;
}
void print_list(List *l)
{
for (ListNode *n = l->head; n; n = n->next)
printf("%d ", n->item);
}
//----------------
// Stack functions
typedef List Stack;
Stack * make_stack()
{ return (Stack *)make_list();
}
void push(Stack *s, int val)
{ insert_list(s, 0, val);
}
int peek(Stack *s)
{ return get_list(s, 0);
}
int pop(Stack *s)
{ int value = peek(s);
remove_list(s, 0);
return value;
}
bool empty_stack(Stack *s)
{ return s->size == 0;
}
int size_stack(Stack *s)
{ return s->size;
}
//-------------------------
// Functions to check signs
int precedenceToken(char c)
{
if( c=='^' )
return 3;
else if ( c=='*' || c=='/' || c=='%' )
return 2;
else if ( c=='+' || c=='-' )
return 1;
else
return 0;
}
int precedenceStack(Stack *s)
{
char c = peek(s);
if( c=='^' )
return 3;
else if ( c=='*' || c=='/' || c=='%' )
return 2;
else if ( c=='+' || c=='-' )
return 1;
else
return 0;
}
bool operatorToken(char c)
{
return ( c=='^' || c=='*' || c=='/' || c=='%' || c=='+' || c=='-' );
}
bool openBracketToken (char c)
{
return ( c=='(' || c=='[' || c=='{' );
}
bool closeBracketToken (char c)
{
return ( c==')' || c==']' || c=='}' );
}
bool openBracketStack (Stack *s)
{
char c = peek(s);
return ( c=='(' || c=='[' || c=='{' );
}
//---------------------------------------------------------
// Function checks that brackets {[( )]} match in an expression
// Returns true if the expression is valid
bool match_bracket(FILE *in)
{
int flag;
int d;
char c;
Stack *sOpen = make_stack(); //stack for open brackets
while ( (flag = fscanf(in, "%d", &d)) != EOF )
{
if (flag == 0) //if not integer
{
c = getc(in);
if ( openBracketToken(c) ) //character is an open bracket
{ push(sOpen, c);
}
if ( closeBracketToken(c) ) //character is a close bracket
{
if ( size_stack(sOpen) > 0 )
{ //pop one open bracket to check for match with close bracket
int bOpen = pop(sOpen);
if( (bOpen=='(' && c!=')') ||
(bOpen=='[' && c!=']') ||
(bOpen=='{' && c!='}') )
{ return false;
}
}
//else if size_stack(sOpen) == 0.
//There are no open brackets before this close bracket
else
{ return false;
}
}
}
}
//if num of open brackets exceeds num of close brackets
if( size_stack(sOpen) > 0)
{ return false;
}
return true;
}
//-------------------------------------------------------------
//Function converts an infix expression to a postfix expression
//Function does not check validity of bracket matching in infix expression.
//A valid input is assumed.
void in_to_post(FILE *in)
{
int flag;
int d;
char c;
Stack *s = make_stack();
while ( (flag = fscanf(in, "%d", &d)) != EOF )
{
if (flag == 1)
{ printf("%d ", d); //print operand
}
else //flag == 0
{ c=getc(in);
if ( operatorToken(c) ) //if token is an operator
{
if ( size_stack(s)==0 ||
(openBracketStack(s) == true) ||
precedenceStack(s) < precedenceToken(c) )
{ push(s, c);
}
else
{ while ( size_stack(s) > 0 &&
( (openBracketStack(s) == false) ||
precedenceStack(s) >= precedenceToken(c)) )
{ printf("%c ", pop(s));
}
push(s, c);
}
}
else if ( openBracketToken(c) ) //if token is an open bracket
{ push(s, c);
}
else if ( closeBracketToken(c) ) //if token is a close bracket
{
while ( size_stack(s) > 0 &&
openBracketStack(s) == false )
{ printf("%c ", pop(s));
}
if ( openBracketStack(s) )
{ pop(s);
}
}
}
}
while ( size_stack(s) > 0 ) //print remaining operators
{ printf("%c ", pop(s));
}
}
//------------------------------------------------------
//Function calculates the result of a postfix expression
//Function does not check validity of postfix expression.
//A valid input is assumed.
int calculate(FILE *in)
{
int flag = 0;
int d;
char c;
Stack *s = make_stack();
int result;
while ((flag = fscanf(in, "%d", &d)) != EOF)
{
if (flag == 1)
{ push(s, d);
}
else
{ c = getc(in);
if(c == ' ') //if character is a space, get the next character
{ c = getc(in);
}
int x = pop(s);
int y = pop(s);
if( c == '^' )
{ result = 1;
for(int i=1; i<=x; i++)
result *= y;
}
else if( c == '*' )
result = y * x;
else if( c == '/' )
result = y / x;
else if( c == '%' )
result = y % x;
else if( c == '+' )
result = y + x;
else if( c == '-' )
result = y - x;
push(s, result);
}
}
return pop(s);
}
|
the_stack_data/89201251.c
|
#include <stdio.h>
int N, M;
int num[10];
void p(int w)
{
int i;
if(w==M)
{
for(i=0;i<M;i++)
printf("%d ", num[i]);
printf("\n");
return;
}
for(i=1;i<N+1;i++)
{
num[w] = i;
p(w+1);
}
}
int main(void)
{
scanf("%d %d", &N, &M);
p(0);
return 0;
}
|
the_stack_data/34512327.c
|
///
/// Perform several driver tests for OpenMP offloading
///
// REQUIRES: clang-driver
// REQUIRES: x86-registered-target
// REQUIRES: powerpc-registered-target
// REQUIRES: nvptx-registered-target
// REQUIRES: amdgpu-registered-target
// UNSUPPORTED: aix
/// ###########################################################################
/// Check -Xopenmp-target uses one of the archs provided when several archs are used.
// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
// RUN: -Xopenmp-target -march=sm_35 -Xopenmp-target -march=sm_60 %s 2>&1 \
// RUN: | FileCheck -check-prefix=CHK-FOPENMP-TARGET-ARCHS %s
// CHK-FOPENMP-TARGET-ARCHS: ptxas{{.*}}" "--gpu-name" "sm_60"
// CHK-FOPENMP-TARGET-ARCHS: nvlink{{.*}}" "-arch" "sm_60"
/// ###########################################################################
/// Check -Xopenmp-target -march=sm_35 works as expected when two triples are present.
// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp \
// RUN: -fopenmp-targets=powerpc64le-ibm-linux-gnu,nvptx64-nvidia-cuda \
// RUN: -Xopenmp-target=nvptx64-nvidia-cuda -march=sm_35 %s 2>&1 \
// RUN: | FileCheck -check-prefix=CHK-FOPENMP-TARGET-COMPILATION %s
// CHK-FOPENMP-TARGET-COMPILATION: ptxas{{.*}}" "--gpu-name" "sm_35"
// CHK-FOPENMP-TARGET-COMPILATION: nvlink{{.*}}" "-arch" "sm_35"
/// ###########################################################################
/// Check cubin file generation and usage by nvlink
// RUN: %clang -### -no-canonical-prefixes -target powerpc64le-unknown-linux-gnu -fopenmp=libomp \
// RUN: -fopenmp-targets=nvptx64-nvidia-cuda -save-temps %s 2>&1 \
// RUN: | FileCheck -check-prefix=CHK-CUBIN-NVLINK %s
/// Check cubin file generation and usage by nvlink when toolchain has BindArchAction
// RUN: %clang -### -no-canonical-prefixes -target x86_64-apple-darwin17.0.0 -fopenmp=libomp \
// RUN: -fopenmp-targets=nvptx64-nvidia-cuda %s 2>&1 \
// RUN: | FileCheck -check-prefix=CHK-CUBIN-NVLINK %s
// CHK-CUBIN-NVLINK: clang{{.*}}" {{.*}}"-fopenmp-is-device" {{.*}}"-o" "[[PTX:.*\.s]]"
// CHK-CUBIN-NVLINK-NEXT: ptxas{{.*}}" "--output-file" "[[CUBIN:.*\.cubin]]" {{.*}}"[[PTX]]"
// CHK-CUBIN-NVLINK-NEXT: nvlink{{.*}}" {{.*}}"[[CUBIN]]"
/// ###########################################################################
/// Check unbundlink of assembly file, cubin file generation and usage by nvlink
// RUN: touch %t.s
// RUN: %clang -### -target powerpc64le-unknown-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
// RUN: -no-canonical-prefixes -save-temps %t.s 2>&1 \
// RUN: | FileCheck -check-prefix=CHK-UNBUNDLING-PTXAS-CUBIN-NVLINK %s
/// Use DAG to ensure that assembly file has been unbundled.
// CHK-UNBUNDLING-PTXAS-CUBIN-NVLINK-DAG: ptxas{{.*}}" "--output-file" "[[CUBIN:.*\.cubin]]" {{.*}}"[[PTX:.*\.s]]"
// CHK-UNBUNDLING-PTXAS-CUBIN-NVLINK-DAG: clang-offload-bundler{{.*}}" "-type=s" {{.*}}"-outputs={{.*}}[[PTX]]
// CHK-UNBUNDLING-PTXAS-CUBIN-NVLINK-DAG-SAME: "-unbundle"
// CHK-UNBUNDLING-PTXAS-CUBIN-NVLINK: nvlink{{.*}}" {{.*}}"[[CUBIN]]"
/// ###########################################################################
/// Check cubin file generation and bundling
// RUN: %clang -### -target powerpc64le-unknown-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
// RUN: -no-canonical-prefixes -save-temps %s -c 2>&1 \
// RUN: | FileCheck -check-prefix=CHK-PTXAS-CUBIN-BUNDLING %s
// CHK-PTXAS-CUBIN-BUNDLING: clang{{.*}}" "-o" "[[PTX:.*\.s]]"
// CHK-PTXAS-CUBIN-BUNDLING-NEXT: ptxas{{.*}}" "--output-file" "[[CUBIN:.*\.cubin]]" {{.*}}"[[PTX]]"
// CHK-PTXAS-CUBIN-BUNDLING: clang-offload-bundler{{.*}}" "-type=o" {{.*}}"-inputs={{.*}}[[CUBIN]]
/// ###########################################################################
/// Check cubin file unbundling and usage by nvlink
// RUN: touch %t.o
// RUN: %clang -### -target powerpc64le-unknown-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
// RUN: -no-canonical-prefixes -save-temps %t.o %S/Inputs/in.so 2>&1 \
// RUN: | FileCheck -check-prefix=CHK-CUBIN-UNBUNDLING-NVLINK %s
/// Use DAG to ensure that cubin file has been unbundled.
// CHK-CUBIN-UNBUNDLING-NVLINK-NOT: clang-offload-bundler{{.*}}" "-type=o"{{.*}}in.so
// CHK-CUBIN-UNBUNDLING-NVLINK-DAG: nvlink{{.*}}" {{.*}}"[[CUBIN:.*\.cubin]]"
// CHK-CUBIN-UNBUNDLING-NVLINK-DAG: clang-offload-bundler{{.*}}" "-type=o" {{.*}}"-outputs={{.*}}[[CUBIN]]
// CHK-CUBIN-UNBUNDLING-NVLINK-DAG-SAME: "-unbundle"
// CHK-CUBIN-UNBUNDLING-NVLINK-NOT: clang-offload-bundler{{.*}}" "-type=o"{{.*}}in.so
/// ###########################################################################
/// Check cubin file generation and usage by nvlink
// RUN: touch %t1.o
// RUN: touch %t2.o
// RUN: %clang -### -no-canonical-prefixes -target powerpc64le-unknown-linux-gnu -fopenmp=libomp \
// RUN: -fopenmp-targets=nvptx64-nvidia-cuda %t1.o %t2.o 2>&1 \
// RUN: | FileCheck -check-prefix=CHK-TWOCUBIN %s
/// Check cubin file generation and usage by nvlink when toolchain has BindArchAction
// RUN: %clang -### -no-canonical-prefixes -target x86_64-apple-darwin17.0.0 -fopenmp=libomp \
// RUN: -fopenmp-targets=nvptx64-nvidia-cuda %t1.o %t2.o 2>&1 \
// RUN: | FileCheck -check-prefix=CHK-TWOCUBIN %s
// CHK-TWOCUBIN: nvlink{{.*}}openmp-offload-{{.*}}.cubin" "{{.*}}openmp-offload-{{.*}}.cubin"
/// ###########################################################################
/// Check PTXAS is passed -c flag when offloading to an NVIDIA device using OpenMP.
// RUN: %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -no-canonical-prefixes %s 2>&1 \
// RUN: | FileCheck -check-prefix=CHK-PTXAS-DEFAULT %s
// CHK-PTXAS-DEFAULT: ptxas{{.*}}" "-c"
/// ###########################################################################
/// PTXAS is passed -c flag by default when offloading to an NVIDIA device using OpenMP - disable it.
// RUN: %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -fnoopenmp-relocatable-target \
// RUN: -save-temps -no-canonical-prefixes %s 2>&1 \
// RUN: | FileCheck -check-prefix=CHK-PTXAS-NORELO %s
// CHK-PTXAS-NORELO-NOT: ptxas{{.*}}" "-c"
/// ###########################################################################
/// PTXAS is passed -c flag by default when offloading to an NVIDIA device using OpenMP
/// Check that the flag is passed when -fopenmp-relocatable-target is used.
// RUN: %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -fopenmp-relocatable-target \
// RUN: -save-temps -no-canonical-prefixes %s 2>&1 \
// RUN: | FileCheck -check-prefix=CHK-PTXAS-RELO %s
// CHK-PTXAS-RELO: ptxas{{.*}}" "-c"
/// ###########################################################################
/// Check that error is not thrown by toolchain when no cuda lib flag is used.
/// Check that the flag is passed when -fopenmp-relocatable-target is used.
// RUN: %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 \
// RUN: -nocudalib -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 2>&1 \
// RUN: | FileCheck -check-prefix=CHK-FLAG-NOLIBDEVICE %s
// CHK-FLAG-NOLIBDEVICE-NOT: error:{{.*}}sm_60
/// ###########################################################################
/// Check that error is not thrown by toolchain when no cuda lib device is found when using -S.
/// Check that the flag is passed when -fopenmp-relocatable-target is used.
// RUN: %clang -### -S -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 \
// RUN: -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 2>&1 \
// RUN: | FileCheck -check-prefix=CHK-NOLIBDEVICE %s
// CHK-NOLIBDEVICE-NOT: error:{{.*}}sm_60
/// ###########################################################################
/// Check that the runtime bitcode library is part of the compile line.
/// Create a bogus bitcode library and specify it with libomptarget-nvptx-bc-path
// RUN: %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
// RUN: --libomptarget-nvptx-bc-path=%S/Inputs/libomptarget/libomptarget-nvptx-test.bc \
// RUN: -Xopenmp-target -march=sm_35 --cuda-path=%S/Inputs/CUDA_102/usr/local/cuda \
// RUN: -fopenmp-relocatable-target -fopenmp-target-new-runtime -save-temps -no-canonical-prefixes %s 2>&1 \
// RUN: | FileCheck -check-prefix=CHK-BCLIB %s
/// Specify the directory containing the bitcode lib, check clang picks the right one
// RUN: %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
// RUN: --libomptarget-nvptx-bc-path=%S/Inputs/libomptarget \
// RUN: -Xopenmp-target -march=sm_35 --cuda-path=%S/Inputs/CUDA_102/usr/local/cuda \
// RUN: -fopenmp-relocatable-target -fno-openmp-target-new-runtime -save-temps \
// RUN: -no-canonical-prefixes %s 2>&1 | FileCheck -check-prefix=CHK-BCLIB-DIR %s
/// Check with the new runtime enabled
// RUN: %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
// RUN: -Xopenmp-target -march=sm_35 --cuda-path=%S/Inputs/CUDA_102/usr/local/cuda \
// RUN: -fopenmp-relocatable-target -fopenmp-target-new-runtime \
// RUN: --libomptarget-nvptx-bc-path=%S/Inputs/libomptarget/libomptarget-new-nvptx-test.bc \
// RUN: -save-temps -no-canonical-prefixes %s 2>&1 \
// RUN: | FileCheck -check-prefix=CHK-BCLIB-NEW %s
/// Check with new runtime and specifying the directory
// RUN: %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
// RUN: -Xopenmp-target -march=sm_35 --cuda-path=%S/Inputs/CUDA_102/usr/local/cuda \
// RUN: -fopenmp-relocatable-target -fopenmp-target-new-runtime \
// RUN: --libomptarget-nvptx-bc-path=%S/Inputs/libomptarget -save-temps \
// RUN: -no-canonical-prefixes %s 2>&1 \
// RUN: | FileCheck -check-prefix=CHK-BCLIB-NEW-DIR %s
/// Create a bogus bitcode library and find it with LIBRARY_PATH
// RUN: env LIBRARY_PATH=%S/Inputs/libomptarget/subdir %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
// RUN: -Xopenmp-target -march=sm_35 --cuda-path=%S/Inputs/CUDA_102/usr/local/cuda \
// RUN: -fopenmp-relocatable-target -fno-openmp-target-new-runtime -save-temps \
// RUN: -no-canonical-prefixes %s 2>&1 | FileCheck -check-prefix=CHK-ENV-BCLIB %s
// CHK-BCLIB: clang{{.*}}-triple{{.*}}nvptx64-nvidia-cuda{{.*}}-mlink-builtin-bitcode{{.*}}libomptarget-nvptx-test.bc
// CHK-BCLIB-DIR: clang{{.*}}-triple{{.*}}nvptx64-nvidia-cuda{{.*}}-mlink-builtin-bitcode{{.*}}libomptarget{{/|\\\\}}libomptarget-nvptx-sm_35.bc
// CHK-BCLIB-NEW: clang{{.*}}-triple{{.*}}nvptx64-nvidia-cuda{{.*}}-mlink-builtin-bitcode{{.*}}libomptarget-new-nvptx-test.bc
// CHK-BCLIB-NEW-DIR: clang{{.*}}-triple{{.*}}nvptx64-nvidia-cuda{{.*}}-mlink-builtin-bitcode{{.*}}libomptarget{{/|\\\\}}libomptarget-new-nvptx-sm_35.bc
// CHK-ENV-BCLIB: clang{{.*}}-triple{{.*}}nvptx64-nvidia-cuda{{.*}}-mlink-builtin-bitcode{{.*}}subdir{{/|\\\\}}libomptarget-nvptx-sm_35.bc
// CHK-BCLIB-NOT: {{error:|warning:}}
/// ###########################################################################
/// Check that the warning is thrown when the libomptarget bitcode library is not found.
/// Libomptarget requires sm_35 or newer so an sm_35 bitcode library should never exist.
// RUN: %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
// RUN: -Xopenmp-target -march=sm_35 --cuda-path=%S/Inputs/CUDA_102/usr/local/cuda \
// RUN: -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 2>&1 \
// RUN: | FileCheck -check-prefix=CHK-BCLIB-WARN %s
// CHK-BCLIB-WARN: no library 'libomptarget-new-nvptx-sm_35.bc' found in the default clang lib directory or in LIBRARY_PATH; use '--libomptarget-nvptx-bc-path' to specify nvptx bitcode library
/// ###########################################################################
/// Check that the error is thrown when the libomptarget bitcode library does not exist.
// RUN: %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
// RUN: -Xopenmp-target -march=sm_35 --cuda-path=%S/Inputs/CUDA_102/usr/local/cuda \
// RUN: --libomptarget-nvptx-bc-path=not-exist.bc \
// RUN: -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 2>&1 \
// RUN: | FileCheck -check-prefix=CHK-BCLIB-ERROR %s
// CHK-BCLIB-ERROR: bitcode library 'not-exist.bc' does not exist
/// ###########################################################################
/// Check that the error is thrown when CUDA 9.1 or lower version is used.
// RUN: %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
// RUN: -Xopenmp-target -march=sm_35 --cuda-path=%S/Inputs/CUDA_90/usr/local/cuda \
// RUN: -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 2>&1 \
// RUN: | FileCheck -check-prefix=CHK-CUDA-VERSION-ERROR %s
// CHK-CUDA-VERSION-ERROR: NVPTX target requires CUDA 9.2 or above; CUDA 9.0 detected
/// Check that debug info is emitted in dwarf-2
// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g -O1 --no-cuda-noopt-device-debug 2>&1 \
// RUN: | FileCheck -check-prefix=DEBUG_DIRECTIVES %s
// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g -O3 2>&1 \
// RUN: | FileCheck -check-prefix=DEBUG_DIRECTIVES %s
// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g -O3 --no-cuda-noopt-device-debug 2>&1 \
// RUN: | FileCheck -check-prefix=DEBUG_DIRECTIVES %s
// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g0 2>&1 \
// RUN: | FileCheck -check-prefix=NO_DEBUG %s
// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -ggdb0 -O3 --cuda-noopt-device-debug 2>&1 \
// RUN: | FileCheck -check-prefix=NO_DEBUG %s
// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -gline-directives-only 2>&1 \
// RUN: | FileCheck -check-prefix=DEBUG_DIRECTIVES %s
// DEBUG_DIRECTIVES-NOT: warning: debug
// NO_DEBUG-NOT: warning: debug
// NO_DEBUG: "-fopenmp-is-device"
// NO_DEBUG-NOT: "-debug-info-kind=
// NO_DEBUG: ptxas
// DEBUG_DIRECTIVES: "-triple" "nvptx64-nvidia-cuda"
// DEBUG_DIRECTIVES-SAME: "-debug-info-kind=line-directives-only"
// DEBUG_DIRECTIVES-SAME: "-fopenmp-is-device"
// DEBUG_DIRECTIVES: ptxas
// DEBUG_DIRECTIVES: "-lineinfo"
// NO_DEBUG-NOT: "-g"
// NO_DEBUG: nvlink
// NO_DEBUG-NOT: "-g"
// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g -O0 --no-cuda-noopt-device-debug 2>&1 \
// RUN: | FileCheck -check-prefix=HAS_DEBUG %s
// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g 2>&1 \
// RUN: | FileCheck -check-prefix=HAS_DEBUG %s
// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g -O0 --cuda-noopt-device-debug 2>&1 \
// RUN: | FileCheck -check-prefix=HAS_DEBUG %s
// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g -O3 --cuda-noopt-device-debug 2>&1 \
// RUN: | FileCheck -check-prefix=HAS_DEBUG %s
// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g2 2>&1 \
// RUN: | FileCheck -check-prefix=HAS_DEBUG %s
// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -ggdb2 -O0 --cuda-noopt-device-debug 2>&1 \
// RUN: | FileCheck -check-prefix=HAS_DEBUG %s
// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g3 -O3 --cuda-noopt-device-debug 2>&1 \
// RUN: | FileCheck -check-prefix=HAS_DEBUG %s
// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -ggdb3 -O2 --cuda-noopt-device-debug 2>&1 \
// RUN: | FileCheck -check-prefix=HAS_DEBUG %s
// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -gline-tables-only 2>&1 \
// RUN: | FileCheck -check-prefix=HAS_DEBUG %s
// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -ggdb1 -O2 --cuda-noopt-device-debug 2>&1 \
// RUN: | FileCheck -check-prefix=HAS_DEBUG %s
// HAS_DEBUG-NOT: warning: debug
// HAS_DEBUG: "-triple" "nvptx64-nvidia-cuda"
// HAS_DEBUG-SAME: "-debug-info-kind={{constructor|line-tables-only}}"
// HAS_DEBUG-SAME: "-dwarf-version=2"
// HAS_DEBUG-SAME: "-fopenmp-is-device"
// HAS_DEBUG: ptxas
// HAS_DEBUG-SAME: "-g"
// HAS_DEBUG-SAME: "--dont-merge-basicblocks"
// HAS_DEBUG-SAME: "--return-at-end"
// HAS_DEBUG: nvlink
// HAS_DEBUG-SAME: "-g"
// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -fopenmp-cuda-mode 2>&1 \
// RUN: | FileCheck -check-prefix=CUDA_MODE %s
// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -fno-openmp-cuda-mode -fopenmp-cuda-mode 2>&1 \
// RUN: | FileCheck -check-prefix=CUDA_MODE %s
// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target -march=gfx906 %s -fopenmp-cuda-mode 2>&1 \
// RUN: | FileCheck -check-prefix=CUDA_MODE %s
// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target -march=gfx906 %s -fno-openmp-cuda-mode -fopenmp-cuda-mode 2>&1 \
// RUN: | FileCheck -check-prefix=CUDA_MODE %s
// CUDA_MODE: clang{{.*}}"-cc1"{{.*}}"-triple" "{{nvptx64-nvidia-cuda|amdgcn-amd-amdhsa}}"
// CUDA_MODE-SAME: "-fopenmp-cuda-mode"
// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -fno-openmp-cuda-mode 2>&1 \
// RUN: | FileCheck -check-prefix=NO_CUDA_MODE %s
// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -fopenmp-cuda-mode -fno-openmp-cuda-mode 2>&1 \
// RUN: | FileCheck -check-prefix=NO_CUDA_MODE %s
// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target -march=gfx906 %s -fno-openmp-cuda-mode 2>&1 \
// RUN: | FileCheck -check-prefix=NO_CUDA_MODE %s
// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target -march=gfx906 %s -fopenmp-cuda-mode -fno-openmp-cuda-mode 2>&1 \
// RUN: | FileCheck -check-prefix=NO_CUDA_MODE %s
// NO_CUDA_MODE-NOT: "-{{fno-|f}}openmp-cuda-mode"
// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -fopenmp-cuda-force-full-runtime 2>&1 \
// RUN: | FileCheck -check-prefix=FULL_RUNTIME %s
// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -fno-openmp-cuda-force-full-runtime -fopenmp-cuda-force-full-runtime 2>&1 \
// RUN: | FileCheck -check-prefix=FULL_RUNTIME %s
// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target -march=gfx906 %s -fopenmp-cuda-force-full-runtime 2>&1 \
// RUN: | FileCheck -check-prefix=FULL_RUNTIME %s
// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target -march=gfx906 %s -fno-openmp-cuda-force-full-runtime -fopenmp-cuda-force-full-runtime 2>&1 \
// RUN: | FileCheck -check-prefix=FULL_RUNTIME %s
// FULL_RUNTIME: clang{{.*}}"-cc1"{{.*}}"-triple" "{{nvptx64-nvidia-cuda|amdgcn-amd-amdhsa}}"
// FULL_RUNTIME-SAME: "-fopenmp-cuda-force-full-runtime"
// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -fno-openmp-cuda-force-full-runtime 2>&1 \
// RUN: | FileCheck -check-prefix=NO_FULL_RUNTIME %s
// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -fopenmp-cuda-force-full-runtime -fno-openmp-cuda-force-full-runtime 2>&1 \
// RUN: | FileCheck -check-prefix=NO_FULL_RUNTIME %s
// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target -march=gfx906 %s -fno-openmp-cuda-force-full-runtime 2>&1 \
// RUN: | FileCheck -check-prefix=NO_FULL_RUNTIME %s
// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target -march=gfx906 %s -fopenmp-cuda-force-full-runtime -fno-openmp-cuda-force-full-runtime 2>&1 \
// RUN: | FileCheck -check-prefix=NO_FULL_RUNTIME %s
// NO_FULL_RUNTIME-NOT: "-{{fno-|f}}openmp-cuda-force-full-runtime"
// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -fopenmp-cuda-teams-reduction-recs-num=2048 2>&1 \
// RUN: | FileCheck -check-prefix=CUDA_RED_RECS %s
// CUDA_RED_RECS: clang{{.*}}"-cc1"{{.*}}"-triple" "nvptx64-nvidia-cuda"
// CUDA_RED_RECS-SAME: "-fopenmp-cuda-teams-reduction-recs-num=2048"
// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda %s 2>&1 \
// RUN: | FileCheck -check-prefix=OPENMP_NVPTX_WRAPPERS %s
// OPENMP_NVPTX_WRAPPERS: clang{{.*}}"-cc1"{{.*}}"-triple" "nvptx64-nvidia-cuda"
// OPENMP_NVPTX_WRAPPERS-SAME: "-internal-isystem" "{{.*}}openmp_wrappers"
// RUN: %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
// RUN: -save-temps -no-canonical-prefixes -ccc-print-bindings %s -o openmp-offload-gpu 2>&1 \
// RUN: | FileCheck -check-prefix=SAVE_TEMPS_NAMES %s
// SAVE_TEMPS_NAMES-NOT: "GNU::Linker"{{.*}}["[[SAVE_TEMPS_INPUT1:.*\.o]]", "[[SAVE_TEMPS_INPUT1]]"]
|
the_stack_data/54824846.c
|
/*===-- floatundisf.c - Implement __floatundisf ---------------------------===
*
* The LLVM Compiler Infrastructure
*
* This file is distributed under the University of Illinois Open Source
* License. See LICENSE.TXT for details.
*
* ===----------------------------------------------------------------------===
*
* This file implements __floatundisf for the compiler_rt library.
*
*===----------------------------------------------------------------------===
*/
#if !defined(__GNUC__) || __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 7) || defined(ARCH_X86)
// ARM gcc >= 4.7 implements this in libgcc
#include "int_lib.h"
#include <float.h>
/* Returns: convert a to a float, rounding toward even. */
/* Assumption: float is a IEEE 32 bit floating point type
* du_int is a 64 bit integral type
*/
/* seee eeee emmm mmmm mmmm mmmm mmmm mmmm */
float
__floatundisf(du_int a)
{
if (a == 0)
return 0.0F;
const unsigned N = sizeof(du_int) * CHAR_BIT;
int sd = N - __builtin_clzll(a); /* number of significant digits */
int e = sd - 1; /* 8 exponent */
if (sd > FLT_MANT_DIG)
{
/* start: 0000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQxxxxxxxxxxxxxxxxxx
* finish: 000000000000000000000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQR
* 12345678901234567890123456
* 1 = msb 1 bit
* P = bit FLT_MANT_DIG-1 bits to the right of 1
* Q = bit FLT_MANT_DIG bits to the right of 1
* R = "or" of all bits to the right of Q
*/
switch (sd)
{
case FLT_MANT_DIG + 1:
a <<= 1;
break;
case FLT_MANT_DIG + 2:
break;
default:
a = (a >> (sd - (FLT_MANT_DIG+2))) |
((a & ((du_int)(-1) >> ((N + FLT_MANT_DIG+2) - sd))) != 0);
};
/* finish: */
a |= (a & 4) != 0; /* Or P into R */
++a; /* round - this step may add a significant bit */
a >>= 2; /* dump Q and R */
/* a is now rounded to FLT_MANT_DIG or FLT_MANT_DIG+1 bits */
if (a & ((du_int)1 << FLT_MANT_DIG))
{
a >>= 1;
++e;
}
/* a is now rounded to FLT_MANT_DIG bits */
}
else
{
a <<= (FLT_MANT_DIG - sd);
/* a is now rounded to FLT_MANT_DIG bits */
}
float_bits fb;
fb.u = ((e + 127) << 23) | /* exponent */
((su_int)a & 0x007FFFFF); /* mantissa */
return fb.f;
}
#endif
|
the_stack_data/98576481.c
|
#include <assert.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdio.h>
#include <string.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[512] = "";
// 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[1024] = "";
fgets(lineBuffer, sizeof lineBuffer, inputStream);)
{
const char* matrix[32] = {0};
size_t matrixWidth = 0;
for(const char* row = strtok(lineBuffer, "| \n");
row; row = strtok(NULL, "| \n"))
{
assert(matrixWidth < (sizeof matrix / sizeof *matrix));
matrix[matrixWidth++] = row;
}
// As per the problem statement.
assert((matrixWidth >= 2) && (matrixWidth <= 25));
struct {size_t width; unsigned sum;} result = {0};
// Expand the (square) search submatrix until we find one where the sums
// of all such submatrices are equal.
for(size_t scope = 1; scope <= matrixWidth; ++scope)
{
bool isFirstSubmatrix = true;
for(size_t yMajor = 0; yMajor <= (matrixWidth - scope); ++yMajor)
for(size_t xMajor = 0; xMajor <= (matrixWidth - scope); ++xMajor)
{
unsigned cellSum = 0;
for(size_t y = yMajor; y < (yMajor + scope); ++y)
for(size_t x = xMajor; x < (xMajor + scope); ++x)
{
cellSum += (matrix[y][x] - '0');
if(!isFirstSubmatrix && (cellSum > result.sum)) goto next;
}
if(isFirstSubmatrix)
{
result.sum = cellSum;
isFirstSubmatrix = false;
}
else if(result.sum != cellSum) goto next;
}
result.width = scope;
goto dump;
next:;
}
dump: printf("%zux%zu, %u\n", result.width, result.width, result.sum);
}
// The CRT takes care of cleanup.
}
|
the_stack_data/806561.c
|
#include <stdio.h>
#include <sys/socket.h>
#include <stdlib.h>
#include <string.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#define PORT 8888
int main(int argc, char **argv)
{
printf("hello from tcpclient!\n");
int sock;
struct sockaddr_in my_addr;
int len;
char buf[100];
char recbuf[100];
if (argc <2)
{
printf("Usage: %s <ip>\n", argv[0]);
exit(1);
}
if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0)
{
perror("socket create error!\n");
exit(1);
}
memset(&my_addr, 0, sizeof(my_addr)); //内存初始化
my_addr.sin_family = AF_INET;
my_addr.sin_port = htons(PORT);
if (inet_aton(argv[1], (struct in_addr*)&my_addr.sin_addr.s_addr) == 0)
{
perror("change error!\n");
exit(1);
}
if (connect(sock,(struct sockaddr*)&my_addr, sizeof(struct sockaddr)) < 0)
{
printf("connect error!\n");
exit(1);
}
printf("connected!\n"); //连接成功
printf("Input data to send:\n");
fgets(buf, 100, stdin);
//strcpy(buf, "456");
printf("%s\n", buf);
printf("strlen(buf):%d\n", strlen(buf));
len = send(sock,buf,strlen(buf)-1,0);
printf("len:%d\n", len);
if (len < 0)
{
perror("send error!\n");
exit(1);
}
sleep(1);
len = recv(sock, recbuf, 100, 0);
recbuf[len] = '\0';
if (len < 0)
{
perror("recv error!\n");
exit(1);
}
printf("the reccived data from server is %s\n", recbuf);
close(sock);
return 0;
}
|
the_stack_data/821227.c
|
#include <stdio.h>
#include <stdlib.h>
#define MAXTAM 10
typedef struct Cliente {
int codigo;
char nome[MAXTAM];
} Cliente;
int main (int argc, char** argv){
Cliente c;
c.codigo = 5;
Cliente *p = NULL;
p = (Cliente*) malloc (sizeof(Cliente));
p->codigo = 6;
Cliente *p2 = &c;
p2->codigo = 7;
return 0;
}
|
the_stack_data/940810.c
|
/**
* ppjC je programski jezik podskup jezika C definiran u dokumentu
* https://github.com/fer-ppj/ppj-labosi/raw/master/upute/ppj-labos-upute.pdf
*
* ova skripta poziva ppjC kompajler (za sada samo analizator) pritiskom
* na tipku [Ctrl+S], [Shift+Enter] ili [Alt+3] i prikazuje rezultat analize.
*
* ne garantiram tocnost leksera, sintaksnog niti semantickog analizatora koji
* se ovdje pokrece.
*
* URL skripte prati verzije izvornog programa, tako da je moguca razmjena
* izvornih programa u timu putem URL-ova.
*/
int printf(const char format[]) {
/* i wish i could printf */
return 0;
}
int main(void) {
int b;
return printf("hello world!\n");
}
|
the_stack_data/103266651.c
|
/**
******************************************************************************
* @file stm32l4xx_ll_gpio.c
* @author MCD Application Team
* @version V1.7.0
* @date 17-February-2017
* @brief GPIO LL module driver.
******************************************************************************
* @attention
*
* <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of STMicroelectronics nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************
*/
#if defined(USE_FULL_LL_DRIVER)
/* Includes ------------------------------------------------------------------*/
#include "stm32l4xx_ll_gpio.h"
#include "stm32l4xx_ll_bus.h"
#ifdef USE_FULL_ASSERT
#include "stm32_assert.h"
#else
#define assert_param(expr) ((void)0U)
#endif
/** @addtogroup STM32L4xx_LL_Driver
* @{
*/
#if defined (GPIOA) || defined (GPIOB) || defined (GPIOC) || defined (GPIOD) || defined (GPIOE) || defined (GPIOF) || defined (GPIOG) || defined (GPIOH) || defined (GPIOI)
/** @addtogroup GPIO_LL
* @{
*/
/* Private types -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private constants ---------------------------------------------------------*/
/* Private macros ------------------------------------------------------------*/
/** @addtogroup GPIO_LL_Private_Macros
* @{
*/
#define IS_LL_GPIO_PIN(__VALUE__) (((0x00000000U) < (__VALUE__)) && ((__VALUE__) <= (LL_GPIO_PIN_ALL)))
#define IS_LL_GPIO_MODE(__VALUE__) (((__VALUE__) == LL_GPIO_MODE_INPUT) ||\
((__VALUE__) == LL_GPIO_MODE_OUTPUT) ||\
((__VALUE__) == LL_GPIO_MODE_ALTERNATE) ||\
((__VALUE__) == LL_GPIO_MODE_ANALOG))
#define IS_LL_GPIO_OUTPUT_TYPE(__VALUE__) (((__VALUE__) == LL_GPIO_OUTPUT_PUSHPULL) ||\
((__VALUE__) == LL_GPIO_OUTPUT_OPENDRAIN))
#define IS_LL_GPIO_SPEED(__VALUE__) (((__VALUE__) == LL_GPIO_SPEED_FREQ_LOW) ||\
((__VALUE__) == LL_GPIO_SPEED_FREQ_MEDIUM) ||\
((__VALUE__) == LL_GPIO_SPEED_FREQ_HIGH) ||\
((__VALUE__) == LL_GPIO_SPEED_FREQ_VERY_HIGH))
#define IS_LL_GPIO_PULL(__VALUE__) (((__VALUE__) == LL_GPIO_PULL_NO) ||\
((__VALUE__) == LL_GPIO_PULL_UP) ||\
((__VALUE__) == LL_GPIO_PULL_DOWN))
#define IS_LL_GPIO_ALTERNATE(__VALUE__) (((__VALUE__) == LL_GPIO_AF_0 ) ||\
((__VALUE__) == LL_GPIO_AF_1 ) ||\
((__VALUE__) == LL_GPIO_AF_2 ) ||\
((__VALUE__) == LL_GPIO_AF_3 ) ||\
((__VALUE__) == LL_GPIO_AF_4 ) ||\
((__VALUE__) == LL_GPIO_AF_5 ) ||\
((__VALUE__) == LL_GPIO_AF_6 ) ||\
((__VALUE__) == LL_GPIO_AF_7 ) ||\
((__VALUE__) == LL_GPIO_AF_8 ) ||\
((__VALUE__) == LL_GPIO_AF_9 ) ||\
((__VALUE__) == LL_GPIO_AF_10 ) ||\
((__VALUE__) == LL_GPIO_AF_11 ) ||\
((__VALUE__) == LL_GPIO_AF_12 ) ||\
((__VALUE__) == LL_GPIO_AF_13 ) ||\
((__VALUE__) == LL_GPIO_AF_14 ) ||\
((__VALUE__) == LL_GPIO_AF_15 ))
/**
* @}
*/
/* Private function prototypes -----------------------------------------------*/
/* Exported functions --------------------------------------------------------*/
/** @addtogroup GPIO_LL_Exported_Functions
* @{
*/
/** @addtogroup GPIO_LL_EF_Init
* @{
*/
/**
* @brief De-initialize GPIO registers (Registers restored to their default values).
* @param GPIOx GPIO Port
* @retval An ErrorStatus enumeration value:
* - SUCCESS: GPIO registers are de-initialized
* - ERROR: Wrong GPIO Port
*/
ErrorStatus LL_GPIO_DeInit(GPIO_TypeDef *GPIOx)
{
ErrorStatus status = SUCCESS;
/* Check the parameters */
assert_param(IS_GPIO_ALL_INSTANCE(GPIOx));
/* Force and Release reset on clock of GPIOx Port */
if (GPIOx == GPIOA)
{
LL_AHB2_GRP1_ForceReset(LL_AHB2_GRP1_PERIPH_GPIOA);
LL_AHB2_GRP1_ReleaseReset(LL_AHB2_GRP1_PERIPH_GPIOA);
}
else if (GPIOx == GPIOB)
{
LL_AHB2_GRP1_ForceReset(LL_AHB2_GRP1_PERIPH_GPIOB);
LL_AHB2_GRP1_ReleaseReset(LL_AHB2_GRP1_PERIPH_GPIOB);
}
else if (GPIOx == GPIOC)
{
LL_AHB2_GRP1_ForceReset(LL_AHB2_GRP1_PERIPH_GPIOC);
LL_AHB2_GRP1_ReleaseReset(LL_AHB2_GRP1_PERIPH_GPIOC);
}
#if defined(GPIOD)
else if (GPIOx == GPIOD)
{
LL_AHB2_GRP1_ForceReset(LL_AHB2_GRP1_PERIPH_GPIOD);
LL_AHB2_GRP1_ReleaseReset(LL_AHB2_GRP1_PERIPH_GPIOD);
}
#endif /* GPIOD */
#if defined(GPIOE)
else if (GPIOx == GPIOE)
{
LL_AHB2_GRP1_ForceReset(LL_AHB2_GRP1_PERIPH_GPIOE);
LL_AHB2_GRP1_ReleaseReset(LL_AHB2_GRP1_PERIPH_GPIOE);
}
#endif /* GPIOE */
#if defined(GPIOF)
else if (GPIOx == GPIOF)
{
LL_AHB2_GRP1_ForceReset(LL_AHB2_GRP1_PERIPH_GPIOF);
LL_AHB2_GRP1_ReleaseReset(LL_AHB2_GRP1_PERIPH_GPIOF);
}
#endif /* GPIOF */
#if defined(GPIOG)
else if (GPIOx == GPIOG)
{
LL_AHB2_GRP1_ForceReset(LL_AHB2_GRP1_PERIPH_GPIOG);
LL_AHB2_GRP1_ReleaseReset(LL_AHB2_GRP1_PERIPH_GPIOG);
}
#endif /* GPIOG */
#if defined(GPIOH)
else if (GPIOx == GPIOH)
{
LL_AHB2_GRP1_ForceReset(LL_AHB2_GRP1_PERIPH_GPIOH);
LL_AHB2_GRP1_ReleaseReset(LL_AHB2_GRP1_PERIPH_GPIOH);
}
#endif /* GPIOH */
#if defined(GPIOI)
else if (GPIOx == GPIOI)
{
LL_AHB2_GRP1_ForceReset(LL_AHB2_GRP1_PERIPH_GPIOI);
LL_AHB2_GRP1_ReleaseReset(LL_AHB2_GRP1_PERIPH_GPIOI);
}
#endif /* GPIOI */
else
{
status = ERROR;
}
return (status);
}
/**
* @brief Initialize GPIO registers according to the specified parameters in GPIO_InitStruct.
* @param GPIOx GPIO Port
* @param GPIO_InitStruct: pointer to a @ref LL_GPIO_InitTypeDef structure
* that contains the configuration information for the specified GPIO peripheral.
* @retval An ErrorStatus enumeration value:
* - SUCCESS: GPIO registers are initialized according to GPIO_InitStruct content
* - ERROR: Not applicable
*/
ErrorStatus LL_GPIO_Init(GPIO_TypeDef *GPIOx, LL_GPIO_InitTypeDef *GPIO_InitStruct)
{
uint32_t pinpos = 0x00000000U;
uint32_t currentpin = 0x00000000U;
/* Check the parameters */
assert_param(IS_GPIO_ALL_INSTANCE(GPIOx));
assert_param(IS_LL_GPIO_PIN(GPIO_InitStruct->Pin));
assert_param(IS_LL_GPIO_MODE(GPIO_InitStruct->Mode));
assert_param(IS_LL_GPIO_PULL(GPIO_InitStruct->Pull));
/* ------------------------- Configure the port pins ---------------- */
/* Initialize pinpos on first pin set */
pinpos = POSITION_VAL(GPIO_InitStruct->Pin);
/* Configure the port pins */
while (((GPIO_InitStruct->Pin) >> pinpos) != 0x00000000U)
{
/* Get current io position */
currentpin = (GPIO_InitStruct->Pin) & (0x00000001U << pinpos);
if (currentpin)
{
/* Pin Mode configuration */
LL_GPIO_SetPinMode(GPIOx, currentpin, GPIO_InitStruct->Mode);
if ((GPIO_InitStruct->Mode == LL_GPIO_MODE_OUTPUT) || (GPIO_InitStruct->Mode == LL_GPIO_MODE_ALTERNATE))
{
/* Check Speed mode parameters */
assert_param(IS_LL_GPIO_SPEED(GPIO_InitStruct->Speed));
/* Speed mode configuration */
LL_GPIO_SetPinSpeed(GPIOx, currentpin, GPIO_InitStruct->Speed);
}
/* Pull-up Pull down resistor configuration*/
LL_GPIO_SetPinPull(GPIOx, currentpin, GPIO_InitStruct->Pull);
if (GPIO_InitStruct->Mode == LL_GPIO_MODE_ALTERNATE)
{
/* Check Alternate parameter */
assert_param(IS_LL_GPIO_ALTERNATE(GPIO_InitStruct->Alternate));
/* Speed mode configuration */
if (POSITION_VAL(currentpin) < 0x00000008U)
{
LL_GPIO_SetAFPin_0_7(GPIOx, currentpin, GPIO_InitStruct->Alternate);
}
else
{
LL_GPIO_SetAFPin_8_15(GPIOx, currentpin, GPIO_InitStruct->Alternate);
}
}
}
pinpos++;
}
if ((GPIO_InitStruct->Mode == LL_GPIO_MODE_OUTPUT) || (GPIO_InitStruct->Mode == LL_GPIO_MODE_ALTERNATE))
{
/* Check Output mode parameters */
assert_param(IS_LL_GPIO_OUTPUT_TYPE(GPIO_InitStruct->OutputType));
/* Output mode configuration*/
LL_GPIO_SetPinOutputType(GPIOx, GPIO_InitStruct->Pin, GPIO_InitStruct->OutputType);
}
return (SUCCESS);
}
/**
* @brief Set each @ref LL_GPIO_InitTypeDef field to default value.
* @param GPIO_InitStruct: pointer to a @ref LL_GPIO_InitTypeDef structure
* whose fields will be set to default values.
* @retval None
*/
void LL_GPIO_StructInit(LL_GPIO_InitTypeDef *GPIO_InitStruct)
{
/* Reset GPIO init structure parameters values */
GPIO_InitStruct->Pin = LL_GPIO_PIN_ALL;
GPIO_InitStruct->Mode = LL_GPIO_MODE_ANALOG;
GPIO_InitStruct->Speed = LL_GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct->OutputType = LL_GPIO_OUTPUT_PUSHPULL;
GPIO_InitStruct->Pull = LL_GPIO_PULL_NO;
GPIO_InitStruct->Alternate = LL_GPIO_AF_0;
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#endif /* defined (GPIOA) || defined (GPIOB) || defined (GPIOC) || defined (GPIOD) || defined (GPIOE) || defined (GPIOF) || defined (GPIOG) || defined (GPIOH) || defined (GPIOI) */
/**
* @}
*/
#endif /* USE_FULL_LL_DRIVER */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
the_stack_data/112635.c
|
#include <setjmp.h>
#include <signal.h>
#include <stdio.h>
#ifdef SLANG_DRIVER
#include <slang.h>
#ifdef GPM_MOUSEDRIVER
#include <gpm.h>
#endif
#include "aalib.h"
#include "aaint.h"
__AA_CONST struct aa_driver slang_d;
int __slang_is_up = 0;
int __resized_slang = 0;
static int uninitslang;
static int slang_init(__AA_CONST struct aa_hardware_params *p,__AA_CONST void *none, struct aa_hardware_params *dest, void **params)
{
struct aa_hardware_params def={NULL, AA_NORMAL_MASK | AA_BOLD_MASK | AA_REVERSE_MASK | AA_BOLDFONT_MASK | AA_DIM_MASK};
*dest=def;
fflush(stdout);
if (!__slang_is_up) {
SLtt_get_terminfo();
__slang_is_up = 1;
uninitslang = 1;
}
if (SLsmg_init_smg() != 0)
return 0;
if (SLtt_Use_Ansi_Colors) {
dest->supported &= ~AA_BOLDFONT_MASK;
}
SLsmg_Display_Eight_Bit = 128;
dest->supported |= AA_EIGHT;
#ifdef GPM_MOUSEDRIVER
aa_recommendlowmouse("gpm");
#endif
aa_recommendlowkbd ("linux");
aa_recommendlowkbd("slang");
return 1;
}
static void slang_uninit(aa_context * c)
{
SLsmg_reset_smg();
if (uninitslang) {
uninitslang = 0;
__slang_is_up = 0;
}
}
static void slang_getsize(aa_context * c, int *width, int *height)
{
SLtt_get_screen_size();
SLsmg_reset_smg();
if (SLsmg_init_smg() != 0)
printf("Internal error!\n");
SLtt_set_mono(AA_NORMAL, "normal", 0);
SLtt_set_mono(AA_BOLD, "bold", SLTT_BOLD_MASK);
SLtt_set_mono(AA_DIM, "dim", SLTT_ALTC_MASK);
SLtt_set_mono(AA_REVERSE, "reverse", SLTT_REV_MASK);
SLtt_set_mono(AA_SPECIAL, "special", 0);
SLtt_set_mono(AA_BOLDFONT, "boldfont", SLTT_BOLD_MASK);
SLtt_set_color(AA_NORMAL, "normal", "lightgray", "black");
SLtt_set_color(AA_BOLD, "bold", "white", "black");
SLtt_set_color(AA_DIM, "dim", "gray", "black");
SLtt_set_color(AA_REVERSE, "bold", "black", "lightgray");
SLtt_set_color(AA_SPECIAL, "dim", "lightgray", "blue");
SLtt_set_color(AA_BOLDFONT, "bold", "white", "black");
*width = SLtt_Screen_Cols;
*height = SLtt_Screen_Rows;
/*if(i==2) exit(1); */
#ifdef GPM_MOUSEDRIVER
gpm_mx = *width;
gpm_my = *height;
#endif
}
static void slang_setattr(aa_context * c, int attr)
{
SLsmg_set_color(attr);
}
static void slang_print(aa_context * c, __AA_CONST char *text)
{
SLsmg_write_string(text);
}
static void slang_flush(aa_context * c)
{
SLsmg_refresh();
}
static void slang_gotoxy(aa_context * c, int x, int y)
{
SLsmg_gotorc(y, x);
}
static void slang_cursor(aa_context * c, int mode)
{
SLtt_set_cursor_visibility(mode);
}
__AA_CONST struct aa_driver slang_d =
{
"slang", "Slang driver 1.0",
slang_init,
slang_uninit,
slang_getsize,
slang_setattr,
slang_print,
slang_gotoxy,
slang_flush,
slang_cursor,
};
#endif
|
the_stack_data/135173.c
|
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/shm.h>
void die(char *s)
{
perror(s);
exit(1);
}
int main(int argc, char **argv)
{
int key = 1234;
int shmid;
int *pizza;
if((shmid = shmget(key, sizeof(int), IPC_CREAT | 0666)) < 0)
die("shmget");
if((pizza = shmat(shmid, NULL, 0)) < 0)
die("shmat");
while(1){
(*pizza)--;
printf("Waitor delivered a pizza! (%d)\n", *pizza);
sleep(2);
if(pizza < 0)
break;
}
printf("Mamma mia! We are out of pizza!\n");
shmctl(shmid, IPC_RMID, (struct shmid_ds*) 0);
return 0;
}
|
the_stack_data/176704976.c
|
/*
* Copyright(C) 1999-2020 National Technology & Engineering Solutions
* of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
* NTESS, the U.S. Government retains certain rights in this software.
*
* See packages/seacas/LICENSE for details
*/
/* Eigensolution of real symmetric tridiagonal matrix using the algorithm
of Numerical Recipes p. 380. Removed eigenvector calculation and added
return codes: 1 if maximum number of iterations is exceeded, 0 otherwise.
NOTE CAREFULLY: the vector e is used as workspace, the eigenvals are
returned in the vector d. */
#include <math.h>
#define SIGN(a, b) ((b) < 0 ? -fabs(a) : fabs(a))
int ql(double d[], double e[], int n)
{
int m, l, iter, i;
double s, r, p, g, f, dd, c, b;
e[n] = 0.0;
for (l = 1; l <= n; l++) {
iter = 0;
do {
for (m = l; m <= n - 1; m++) {
dd = fabs(d[m]) + fabs(d[m + 1]);
if (fabs(e[m]) + dd == dd) {
break;
}
}
if (m != l) {
if (iter++ == 50) {
return (1);
/* ... not converging; bail out with error code. */
}
g = (d[l + 1] - d[l]) / (2.0 * e[l]);
r = sqrt((g * g) + 1.0);
g = d[m] - d[l] + e[l] / (g + SIGN(r, g));
s = c = 1.0;
p = 0.0;
for (i = m - 1; i >= l; i--) {
f = s * e[i];
b = c * e[i];
if (fabs(f) >= fabs(g)) {
c = g / f;
r = sqrt((c * c) + 1.0);
e[i + 1] = f * r;
c *= (s = 1.0 / r);
}
else {
s = f / g;
r = sqrt((s * s) + 1.0);
e[i + 1] = g * r;
s *= (c = 1.0 / r);
}
g = d[i + 1] - p;
r = (d[i] - g) * s + 2.0 * c * b;
p = s * r;
d[i + 1] = g + p;
g = c * r - b;
}
d[l] = d[l] - p;
e[l] = g;
e[m] = 0.0;
}
} while (m != l);
}
return (0); /* ... things seem ok */
}
|
the_stack_data/592291.c
|
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
double L;
double N;
double I;
double X0;
double Y0;
double Z0;
const double U = pow(10,-7);
printf("L = ");
scanf("%lf", &L);
printf("\n");
printf("N = ");
scanf("%lf", &N);
printf("\n");
printf("I = ");
scanf("%lf", &I);
printf("\n");
printf("X = ");
scanf("%lf", &X0);
printf("Y = ");
scanf("%lf", &Y0);
printf("Z = ");
scanf("%lf", &Z0);
printf("\n");
double valueX = 0;
double valueY;
double valueZ;
double sumX = 0;
double sumY = 0;
double sumZ = 0;
int j;
double startPointX = -L/2;
double currentPointX;
double currentPointY;
double currentPointZ;
double dL = L/N;
double RX;
double RY = Y0;
double RZ = Z0;
double length;
for(j = 0; j < N; j++)
{
currentPointX = startPointX + ((j + 0.5)*dL);
RX = X0 - currentPointX;
length = pow(sqrt(RX*RX + RY*RY + RZ*RZ),3);
valueY = (-1 * dL * RZ)/length;
valueZ = (dL * RY)/length;
sumY = sumY + valueY;
sumZ = sumZ + valueZ;
}
sumY = sumY * I * U;
sumZ = sumZ * I * U;
printf("Output vector:\n");
printf("X = %.15lf\n",sumX);
printf("Y = %.15lf\n",sumY);
printf("Z = %.15lf\n",sumZ);
}
|
the_stack_data/26699456.c
|
/*
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the OpenSSL license (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
* in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html
*/
#include <stdio.h>
#include <openssl/buffer.h>
#include <openssl/err.h>
#include <openssl/evp.h>
#include <openssl/objects.h>
#include <openssl/pem.h>
#include <openssl/rand.h>
#include <openssl/x509.h>
/* Handle 'other' PEMs: not private keys */
void *PEM_ASN1_read_bio(d2i_of_void *d2i, const char *name, BIO *bp, void **x,
pem_password_cb *cb, void *u)
{
const uint8_t *p = NULL;
uint8_t *data = NULL;
long len;
char *ret = NULL;
if (!PEM_bytes_read_bio(&data, &len, NULL, name, bp, cb, u))
return NULL;
p = data;
ret = d2i(x, &p, len);
if (ret == NULL)
PEMerr(PEM_F_PEM_ASN1_READ_BIO, ERR_R_ASN1_LIB);
free(data);
return (ret);
}
|
the_stack_data/554319.c
|
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
enum { buf_max = 32 };
int main(int argc, char const *argv[argc + 1]) {
int ret = EXIT_FAILURE;
char buffer[buf_max] = { 0 };
if(argc == 1) {
while(fgets(buffer, buf_max, stdin)) {
fputs(buffer, stdout);
}
ret = EXIT_SUCCESS;
} else {
for(int i = 1; i < argc; ++i) {
FILE* instream = fopen(argv[i], "r");
if(instream) {
size_t line_number = 1;
size_t flag = 0;
while(fgets(buffer, buf_max, instream)) {
if(!flag) {
printf("%zu ", line_number++);
}
if(!strchr(buffer, '\n')) {
flag = 1;
} else {
flag = 0;
}
fputs(buffer, stdout);
}
fclose(instream);
ret = EXIT_SUCCESS;
} else {
fprintf(stderr, "Could not open %s: ", argv[1]);
perror(0);
errno = 0;
}
}
}
return ret;
}
|
the_stack_data/910458.c
|
#include <stdio.h>
#define MAX 30
int main()
{
int a[MAX][MAX], b[MAX][MAX], result[MAX][MAX], r1, c1, r2, c2, i, j, k;
// printf("Enter rows and column for first matrix: ");
// scanf("%d %d", &r1, &c1);
// printf("Enter rows and column for second matrix: ");
// scanf("%d %d",&r2, &c2);
// // Column of first matrix should be equal to column of second matrix and
// while (c1 != r2)
// {
// printf("Error! column of first matrix not equal to row of second.\n\n");
// printf("Enter rows and column for first matrix: ");
// scanf("%d %d", &r1, &c1);
// printf("Enter rows and column for second matrix: ");
// scanf("%d %d",&r2, &c2);
// }
// Storing elements of first matrix.
printf("\nEnter elements of matrix 1:\n");
for(i=0; i<MAX; ++i)
for(j=0; j<MAX; ++j)
{
a[i][j] = 2;
}
// Storing elements of second matrix.
printf("\nEnter elements of matrix 2:\n");
for(i=0; i<MAX; ++i)
for(j=0; j<MAX; ++j)
{
b[i][j] = 3;
}
// Initializing all elements of result matrix to 0
for(i=0; i<MAX; ++i)
for(j=0; j<MAX; ++j)
{
result[i][j] = 0;
}
// Multiplying matrices a and b and
// storing result in result matrix
for(i=0; i<MAX; ++i)
for(j=0; j<MAX; ++j)
for(k=0; k<MAX; ++k)
{
result[i][j]+=a[i][k]*b[k][j];
}
// Displaying the result
printf("\nOutput Matrix:\n");
for(i=0; i<MAX; ++i)
for(j=0; j<MAX; ++j)
{
printf("%d ", result[i][j]);
if(j == MAX-1)
printf("\n\n");
}
return 0;
}
|
the_stack_data/23606.c
|
#include <math.h>
#define PI 3.14159265359
// http://stackoverflow.com/questions/10029588/python-implementation-of-the-wilson-score-interval
int sign(float x);
float normcdfi(float p, float mu, float sigma2);
float binconf(int positive, int negative, float c, double *theta_low, double *theta_high)
{
// default: c=0.95
float N = positive + negative;
if (N == 0.0) return (0.0, 1.0);
float p = positive / N;
float z = normcdfi(1 - 0.5 * (1-c), 0.0, 1.0); //default: mu=0.0, sigma2=1.0
float a1 = 1.0 / (1.0 + z * z / N);
float a2 = p + z * z / (2 * N);
float a3 = z * sqrt(p * (1-p) / N + z * z / (4 * N * N));
*theta_low = a1 * (a2 - a3);
*theta_high = a1 * (a2 + a3);
}
float erfi(float x)
{
//Approximation to inverse error function
float a = 0.147; // MAGIC!!!
float a1 = log(1 - x * x);
float a2 = (2.0 / (PI * a) + a1 / 2.0);
return (sign(x) * sqrt( sqrt(a2 * a2 - a1 / a) - a2 ));
}
int sign(float x)
{
if (x < 0) return -1;
if (x == 0) return 0;
if (x > 0) return 1;
}
float normcdfi(float p, float mu, float sigma2)
{
//Inverse CDF of normal distribution
//default: mu=0.0, sigma2=1.0
if (mu == 0.0 && sigma2 == 1.0)
//return sqrt(2) * erfi(2 * p - 1);
return 1.4142135623730951 * erfi(2 * p - 1);
else
return mu + sqrt(sigma2) * normcdfi(p, mu, sigma2); //default: mu=0.0, sigma2=1.0
}
|
the_stack_data/151706641.c
|
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <netdb.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <arpa/inet.h>
#define MSG_LEN_SIZE 8
#define MSG_END_MARKER "done."
#define MSG_END_MARKER_SIZE strlen(MSG_END_MARKER)
int quip_recv_data(char *ip, int port, int client_id, char *request_code, char *data, int *data_len)
{
int sockfd = 0, n = 0;
char id_str[MSG_LEN_SIZE+1], msg_len_buff[MSG_LEN_SIZE+1], marker[MSG_END_MARKER_SIZE+1];
int msg_len;
int sent, totalsent, received, totalreceived, status;
struct sockaddr_in serv_addr;
if((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
{
printf("Could not create socket \n");
return 1;
}
memset(&serv_addr, 0, sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
serv_addr.sin_port = htons(port);
if(inet_pton(AF_INET, ip, &serv_addr.sin_addr)<=0)
{
printf("\n inet_pton error occured\n");
return 1;
}
if((status = connect(sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr))) < 0)
{
printf("Connect Failed: status %d, errno=%d\n", status, errno);
return 1;
}
/* say hello
identify ourselves with an ID number, formatted as an 8-byte ascii string */
sprintf(id_str, "%c%7d", *request_code, client_id);
totalsent = 0;
while (totalsent < MSG_LEN_SIZE) {
sent = send(sockfd, id_str+totalsent, MSG_LEN_SIZE - totalsent, 0);
if (sent == 0) {
printf("socket connection broken while sending client ID\n");
return 1;
}
totalsent += sent;
}
/* now receive the length of the data, formatted as an 8-byte ascii string */
memset(msg_len_buff, 0, sizeof(msg_len_buff));
totalreceived = 0;
while (totalreceived < MSG_LEN_SIZE)
{
received = recv(sockfd, msg_len_buff+totalreceived, MSG_LEN_SIZE-totalreceived, 0);
if (received == 0) {
printf("socket connection broken while reading length\n");
return 1;
}
totalreceived += received;
}
sscanf(msg_len_buff, "%d", &msg_len);
if (msg_len > *data_len) {
printf("data to be sent is too large for receiver buffer\n");
return 1;
}
*data_len = msg_len; // return the actual size of the data string
/* now receive the data itself */
memset(data, 0, sizeof(data));
totalreceived = 0;
while (totalreceived < msg_len)
{
received = recv(sockfd, data+totalreceived, msg_len-totalreceived, 0);
if (received == 0) {
printf("socket connection broken while reading data\n");
return 1;
}
totalreceived += received;
}
/* and finally wait to receive the end marker */
memset(marker, 0, sizeof(marker));
totalreceived = 0;
while (totalreceived < MSG_END_MARKER_SIZE)
{
received = recv(sockfd, marker+totalreceived, MSG_END_MARKER_SIZE-totalreceived, 0);
if (received == 0) {
printf("socket connection broken while reading data\n");
return 1;
}
totalreceived += received;
}
close(sockfd);
return 0;
}
int quip_send_data(char *ip, int port, int client_id, char *request_code, char *data, int data_len)
{
int sockfd = 0, n = 0;
char id_str[MSG_LEN_SIZE+1], msg_len_buff[MSG_LEN_SIZE+1], marker[MSG_END_MARKER_SIZE+1];
int msg_len;
int sent, totalsent, received, totalreceived, status;
struct sockaddr_in serv_addr;
if((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
{
printf("Could not create socket \n");
return 1;
}
memset(&serv_addr, 0, sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
serv_addr.sin_port = htons(port);
if(inet_pton(AF_INET, ip, &serv_addr.sin_addr)<=0)
{
printf("\n inet_pton error occured\n");
return 1;
}
if((status = connect(sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr))) < 0)
{
printf("Connect Failed status=%d, errno=%d \n", status, errno);
return 1;
}
/* say hello.
identify ourselves with an ID number, formatted as an 8-byte ascii string */
sprintf(id_str, "%c%7d", *request_code, client_id);
totalsent = 0;
while (totalsent < MSG_LEN_SIZE) {
sent = send(sockfd, id_str+totalsent, MSG_LEN_SIZE - totalsent, 0);
if (sent == 0) {
printf("socket connection broken while sending client ID\n");
return 1;
}
totalsent += sent;
}
/* Now send the length of the data, as an 8-byte string */
sprintf(id_str, "%8d", data_len);
totalsent = 0;
while (totalsent < MSG_LEN_SIZE) {
sent = send(sockfd, id_str+totalsent, MSG_LEN_SIZE - totalsent, 0);
if (sent == 0) {
printf("socket connection broken while sending data_len\n");
return 1;
}
totalsent += sent;
}
/* send the data string itself */
totalsent = 0;
while (totalsent < data_len) {
sent = send(sockfd, data+totalsent, data_len - totalsent, 0);
if (sent == 0) {
printf("socket connection broken while sending data\n");
return 1;
}
totalsent += sent;
}
/* and finally wait to receive the end marker */
memset(marker, 0, sizeof(marker));
totalreceived = 0;
while (totalreceived < MSG_END_MARKER_SIZE)
{
received = recv(sockfd, marker+totalreceived, MSG_END_MARKER_SIZE-totalreceived, 0);
if (received == 0) {
printf("socket connection broken while reading data\n");
return 1;
}
totalreceived += received;
}
close(sockfd);
return 0;
}
|
the_stack_data/602072.c
|
/* This testcase is part of GDB, the GNU debugger.
Copyright 2009-2016 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <pthread.h>
#include <unistd.h>
#include <stdlib.h>
#include <signal.h>
unsigned int args[2];
pthread_barrier_t barrier;
pthread_t child_thread_2, child_thread_3;
void
sigusr1_handler (int signo)
{
}
void
callme (void)
{
}
void *
child_function_3 (void *arg)
{
int my_number = (long) arg;
volatile int *myp = (int *) &args[my_number];
pthread_barrier_wait (&barrier);
while (*myp > 0)
{
(*myp) ++;
callme (); /* set breakpoint thread 3 here */
}
pthread_exit (NULL);
}
void *
child_function_2 (void *arg)
{
int my_number = (long) arg;
volatile int *myp = (int *) &args[my_number];
pthread_barrier_wait (&barrier);
while (*myp > 0)
{
(*myp) ++;
callme (); /* set breakpoint thread 2 here */
}
pthread_exit (NULL);
}
static int
wait_threads (void)
{
return 1; /* in wait_threads */
}
int
main ()
{
int res;
long i;
signal (SIGUSR1, sigusr1_handler);
/* Call these early so that PLTs for these are resolved soon,
instead of in the threads. RTLD_NOW should work as well. */
usleep (0);
pthread_barrier_init (&barrier, NULL, 1);
pthread_barrier_wait (&barrier);
pthread_barrier_init (&barrier, NULL, 2);
i = 0;
args[i] = 1;
res = pthread_create (&child_thread_2,
NULL, child_function_2, (void *) i);
pthread_barrier_wait (&barrier);
callme ();
i = 1;
args[i] = 1;
res = pthread_create (&child_thread_3,
NULL, child_function_3, (void *) i);
pthread_barrier_wait (&barrier);
wait_threads (); /* set wait-threads breakpoint here */
pthread_join (child_thread_2, NULL);
pthread_join (child_thread_3, NULL);
exit(EXIT_SUCCESS);
}
|
the_stack_data/181393282.c
|
#include <stdio.h>
/**
* C-examples/intro/cp1.c
*
* Test using file redirection in the terminal.
*
* gcc -Wall -o cp1 cp1.c
* cp1 < file1 > file1.copy
*/
int main(int argc, char *argv[])
{
int c; // why is this int and not char?
c = getchar();
while (c != EOF ) {
putchar(c);
c = getchar();
}
return 0;
}
|
the_stack_data/198580241.c
|
/*
* ROM Basic analyzer, by Stefano Bodrato, APR 2016
*
* This tool looks for known 'fingerprints' in the code and tries to identify
* function entry points and to provide a cross-reference for further ROM analysis.
*
* It works with either Sinclair or Microsoft ROMs, giving hints to set-up a brand new
* target port or to just extend it with an alternative shortcuts (i.e. in the FP package).
*
* $Id: basck.c,v 1.19 2017/01/09 09:35:42 stefano Exp $
*/
unsigned char *img;
long len, pos, pos2;
long jptab;
int l;
char token[1000];
int address;
/* For the SKOOL mode, refer to: http://pythonhosted.org/skoolkit */
/* usage example in skool mode:
basck -ctl p2000.bin > p2000.ctl
---> we look into the created file and see: "(Detected position for ORG: 4096)"
python sna2skool.py p2000.bin -o 4096 -h > p2000.skool <-- it will pick the "ctl" file automatically, use '.bin' extension for the original binary file
python skool2asm.py -H -c p2000.skool > p2000.asm
Getting the most from the SkoolKit automations:
(always use '.bin' extension for the original binary file)
python sna2skool.py p2000.bin -g p2000.ct -o 4096 -h > /dev/null <- prepare a control file automatically (use basck to check the position for ORG)
basck -ctl p2000.bin > p2000.ctl <- get extra infos from the basck tools
cat p2000.ct >> p2000.ctl <- merge it all
python sna2skool.py p2000.bin -o 4096 -h > p2000.skool <- do the final run
python skool2asm.py -H -c p2000.skool > p2000.asm
If you wish you may add more detail using the already existing z88dk DEF files, e.g.:
awk {'print "@ " $4 " label="$2'} /z88dk/lib/msxbios.def >> msx.ctl
awk -F "[=;]" {'print "D " $2 $3'} /z88dk/lib/msxbios.def >> msx.ctl
*/
int SKOOLMODE = -1;
#include <stdio.h>
#include <string.h>
/* stdlib.h MUST be included to really open files as binary */
#include <stdlib.h>
#include <malloc.h>
#define SKIP -1
#define CATCH -2
#define ADDR -3
#define CATCH_CALL -4
#define SKIP_CALL -5
#define SKIP_JP_RET -6
#define ZX80 1
#define ZX81 2
#define LAMBDA 3
#define SPECTRUM 4
#define TS2068 5
/* CPU detection */
int ldir_skel[]={11, 33, CATCH, CATCH, 17, SKIP, SKIP, 1, SKIP, SKIP, 0xED, 0xB0};
int ldir_skel2[]={11, 17, CATCH, CATCH, 33, SKIP, SKIP, 1, SKIP, SKIP, 0xED, 0xB0};
/* Sinclair BASIC detection */
int makeroom_skel[]={7, 0x2A, CATCH, CATCH, 0xEB,0xEd, 0xB8, 0xC9};
int sinclair_skel[]={8, CATCH, 'i', 'n', 'c', 'l', 'a', 'i', 'r'};
int amstrad_skel[]={7, CATCH, 'm', 's', 't', 'r', 'a' ,'d'};
/* Sinclair BASIC code inspection */
int stk_st_skel[]={11, CATCH_CALL, SKIP, SKIP, SKIP, SKIP, 0x28, SKIP, 0xED, 0xB0, 0xC1, 0xE1};
int intfp_skel[]={15, 0x21, SKIP, SKIP, 0x22, SKIP, SKIP, CATCH_CALL, 0xCD, SKIP, SKIP, 0x38, SKIP, 0x21, 0xf0, 0xd8};
int intfp_skel2[]={13, 0x21, SKIP, SKIP, 0x22, SKIP, SKIP, CATCH_CALL, 0xCD, SKIP, SKIP, 0x21, 0xf0, 0xd8};
int fpbc_skel[]={15, 0x21, SKIP, SKIP, 0x22, SKIP, SKIP, 0xCD, SKIP, SKIP, CATCH_CALL, 0x38, SKIP, 0x21, 0xf0, 0xd8};
int fpbc_skel2[]={13, 0x21, SKIP, SKIP, 0x22, SKIP, SKIP, 0xCD, SKIP, SKIP, CATCH_CALL, 0x21, 0xf0, 0xd8};
int prog_skel[]={14, CATCH, CATCH, 0x5D, 0x54, 0xCD, SKIP, SKIP, 0xD0, 0xC5, 0xCD, SKIP, SKIP, 0xC1, 0xEB};
int prog_skel2[]={14, CATCH, CATCH, 0x54, 0x5D, 0xC1, 0xCD, SKIP, SKIP, 0xD0, 0xC5, 0xCD, SKIP, SKIP, 0xEB};
int next_one_skel[]={12, SKIP, SKIP, 0x5D, 0x54, 0xCD, SKIP, SKIP, 0xD0, 0xC5, CATCH_CALL, 0xC1, 0xEB};
int next_one_skel2[]={12, SKIP, SKIP, 0x54, 0x5D, 0xC1, 0xCD, SKIP, SKIP, 0xD0, 0xC5, CATCH_CALL, 0xEB};
int vars_skel[]={10, 0x2A, CATCH, CATCH, 0x36, 0x80, 0x23, 0x22, SKIP, SKIP, 0x2A};
int eline_skel[]={10, 0x2A, SKIP, SKIP, 0x36, 0x80, 0x23, 0x22, CATCH, CATCH, 0x2A};
int vars_skel2[]={10, 0x22, CATCH, CATCH, 0x36, 0x80, 0x23, 0x22, SKIP, SKIP, 0x36};
int eline_skel2[]={10, 0x22, SKIP, SKIP, 0x36, 0x80, 0x23, 0x22, CATCH, CATCH, 0x36};
int stk_pntr_skel[]={12, 0xED, 0xB0, 0x2A, CATCH, CATCH, 0x11, 0xFB, 0xFF, 0xE5, 0x19, 0xD1, 0xC9};
int test5fp_skel[]={8, CATCH_CALL, 0XD9, 0xE5, 0xD9, 0xE3, 0xC5, 0x7E, 0xE6};
int test5fp_skel2[]={9, 0x62, 0x6B, CATCH_CALL, 0XD9, 0xD5, 0xD9, 0xE3, 0xC5, 0x7E};
int stkftch_skel[]={10, 0x0F, 0xF5, CATCH_CALL, 0xD5, 0xC5, 0xCD, SKIP, SKIP, 0xE1, 0x7C};
int stkftch_skel2[]={13, CATCH_CALL, 0x78, 0xB1, 0x28, SKIP, 0x1A, 0xC3, SKIP, SKIP, 0xCD, SKIP, SKIP, 0xC3};
int stkbc_skel[]={11, 0xCD, SKIP, SKIP, 0x28, SKIP, 0xED, 0x4B, SKIP, SKIP, CATCH_CALL, 0xEF};
int seed_skel[]={13, 0xCD, SKIP, SKIP, 0x28, SKIP, 0xED, 0x4B, CATCH, CATCH, 0xCD, SKIP, SKIP, 0xEF};
int rnd_skel[]={13, 0xCD, SKIP, SKIP, 0x28, SKIP, 0xED, 0x4B, SKIP, SKIP, 0xCD, SKIP, SKIP, ADDR};
int restack_skel[]={11, CATCH_CALL, 0xEB, 0x7E, 0xA7, 0xC0, 0xD5, 0xCD, SKIP, SKIP, 0xAF, 0x23};
int stkstr_skel[]={8, 0xF7, CATCH_CALL, 0xC1, 0xE1, 0x78, 0xB1, 0x28, SKIP};
int stka_skel[]={15, 0xCD, SKIP, SKIP, 0x78, 0xB1, 0x28, SKIP, 0x1A, 0xC3, CATCH, CATCH, 0xCD, SKIP, SKIP, 0xC3};
int decfp_skel[]={11, 0xCD, SKIP, SKIP, 0x20, SKIP, CATCH_CALL, SKIP, 1, 0, 6, 0xCD};
/* Sinclair BASIC token extraction */
int tklambda_skel[]={12, 0xB7, 0xF2, SKIP, SKIP, 0xE6, 0x3F, 0x21, CATCH, CATCH, 0xFE, 0x49, 0x30};
int tkzx81_skel[]={12, 0xE5, 0x21, CATCH, CATCH, 0xCB, 0x7F, 0x28, SKIP, 0xE6, 0x3F, 0xFE, 0x43};
int tkspectrum_skel[]={13, 0x11, CATCH, CATCH, 0xF5, 0xCD, SKIP, SKIP, 0x38, SKIP, 0x3E, 0x20, 0xFD, 0xCB};
int tk2068_skel[]={15, 0x11, CATCH, CATCH, 0xFE,0x5B, 0x38, SKIP, 0xD6, 0x1F, 0xF5, 0xCD, SKIP, SKIP, 0x38, SKIP};
int tkzx128_skel[]={15, 0xD8, 0x06, 0xF9, 0x11, SKIP, SKIP , 0x21, CATCH, CATCH, 0xCD, SKIP, SKIP, 0xD0, 0xFE, 0xFF};
/* Sinclair BASIC error messages */
int zxerr_skel[]={16, 0xFE, 0x0A, 0x38, 2, 0xC6, 7, 0xCD, SKIP, SKIP, 0X3E, 0x20, SKIP, 0x78, 0x11, CATCH, CATCH};
int zxfpmod_skel[]={10, 0x1A, 0xA7, 0x20, SKIP, 0xD9, 0x23, 0xD9, 0xC9, 0xEF, ADDR};
int zxfpmod_skel2[]={11, 0xD9, 0x23, 0xD9, 0xC9, 0xF1, 0xD9, 0xE3, 0xD9, 0xC9, 0xEF, ADDR};
/* ZX Spectrum Shadow ROM detection (ATM only Disciple and IF1 are known) */
int zxshadow_end[]={26, ADDR, 33, 0x38, 0x00, 0x22, 0x8D, 0x5C, 0x22, 0x8F, 0x5C, 0xFD, 0x75, 0x0E, 0xFD, 0x74, 0x57, 0x3E, 7, 0xD3, 254, SKIP_CALL, SKIP, SKIP, 0xC3, CATCH, CATCH };
/* Microsoft BASIC detection */
int restore_bastxt_skel[]={14, 0xEB, 0x2A, CATCH, CATCH, 0x28, 0x0E, 0xEB, SKIP_CALL, 0xE5, SKIP_CALL, 0x60, 0x69, 0xD1, 0xD2};
int microsoft_skel[]={9, CATCH, 'i', 'c', 'r', 'o', 's', 'o', 'f', 't'};
int bastxt_skel[]={8, 0x2A, CATCH, CATCH, 0x44, 0x4D, 0x7E, 0x23, 0xB6, 0x2B, 0xC8, 0x23, 0x23, 0x7E, 0x23, 0x66};
int bastxt_skel2[]={11, SKIP_JP_RET, 0xC0, 0x2A, CATCH, CATCH, 0xAF, 0x77, 0x23, 0x77, 0x23, 0x22 };
int microsoft_extended_skel[]={11, ADDR, 0xFE, '%', 0xC8, 0x14, 0xFE, '$', 0xC8, 0x14, 0xFE, '!'};
int microsoft_defdbl_skel[]={7, ADDR, 'D', 'E', 'F', 'D', 'B', 'L'};
int microsoft_defdbl_skel2[]={7, ADDR, 'D'+0x80, 'E', 'F', 'D', 'B', 'L'};
int microsoft_defdbl_skel3[]={6, ADDR, 'E', 'F', 'D', 'B', 'L'+0x80};
/* Microsoft BASIC code inspection */
int ulerr_skel[]={9, SKIP_CALL, 0xE5, SKIP_CALL, 0x60, 0x69, 0xD1, 0xD2, CATCH, CATCH};
int prognd_skel[]={8, 0xEB, 0x2A, CATCH, CATCH, 0x1A, 0x02, 0x03, 0x13};
int prognd_skel2[]={13, SKIP_JP_RET, 0xC0, 0x2A, SKIP, SKIP, 0xAF, 0x77, 0x23, 0x77, 0x23, 0x22, CATCH, CATCH };
int errtab_skel[]={11, ADDR, 0x1E, 2, 1, 0x1E, SKIP, 1, 0x1E, SKIP, 1, 0x1E};
int cmpnum_skel[]={7, 1, 0x74, 0x94, 17, SKIP, SKIP, CATCH_CALL};
int fpint_skel[]={7, 0x7E, CATCH_CALL, 0x36, 0x98, 0x7B, 0xF5, 0x79};
int flgrel_skel[]={11, ADDR, 6, 0x88, 17, 0, 0, 33, SKIP, SKIP, 0x4F, 0x70};
int fpreg_skel[]={10, 0x21, SKIP, SKIP, 0x7E, 0xFE, 0x98, 0x3A, CATCH, CATCH, 0xD0};
int fpexp_skel[]={10, 0x21, CATCH, CATCH, 0x7E, 0xFE, 0x98, 0x3A, SKIP, SKIP, 0xD0};
int bcdefp_skel[]={11, ADDR, 0x21, SKIP, SKIP, 0x5E, 0x23, 0x56, 0x23, 0x4E, 0x23, 0x46};
int loadfp_skel[]={8, ADDR, 0x5E, 0x23, 0x56, 0x23, 0x4E, 0x23, 0x46, 0xC9};
int fpbcde_skel[]={8, ADDR, SKIP_CALL, 0xEB, 0x22, SKIP, SKIP, 0x60, 0x69, 0x22, SKIP, SKIP, 0xEB};
int fpreg_skel2[]={7, SKIP_CALL, 0xEB, 0x22, CATCH, CATCH, 0x60, 0x69, 0x22, SKIP, SKIP, 0xEB};
int stakfp_skel[]={10, ADDR, 0xEB, 0x2A, SKIP, SKIP, 0xE3, 0xE5, 0x2A, SKIP, SKIP, 0xE3, 0xEB, 0xC9};
int tstsgn_skel[]={12, ADDR, 0x3A, SKIP, SKIP, 0xB7, 0xC8, 0x3A, SKIP, SKIP, 0xFE, 0x2F, 0x17};
int tstsgn_skel2[]={13, ADDR, 0x3A, SKIP, SKIP, 0xB7, 0xC8, 0x3A, SKIP, SKIP, 0x18, 1, 0x2F, 0x17};
int tstsgn_skel3[]={10, ADDR, 0x3A, SKIP, SKIP, 0xB7, 0xC8, 0x3A, SKIP, SKIP, 0xC3};
int fpexp_skel2[]={12, 0x3A, CATCH, CATCH, 0xB7, 0xC8, 0x3A, SKIP, SKIP, 0x18, 1, 0x2F, 0x17};
int mlsp10_skel[]={11, ADDR, SKIP_CALL, 0x78, 0xB7, 0xC8, 0xC6, 2, 0xDA, SKIP, SKIP, 0x47};
int mlsp10_skel2[]={10, ADDR, SKIP_CALL, 0x78, 0xB7, 0xC8, 0xC6, 2, 0x38, SKIP, 0x47};
/* nxtopr_skel2 checked in OPNPAR first */
int nxtopr_skel2[]={8, 0x16, 0x7D, SKIP_CALL, 0x2A, CATCH, CATCH, 0xE5, 0xCD};
/* chkstk_skel checked in OPNPAR first */
int chkstk_skel2[]={10, ADDR, 0xE5, 0x2A, SKIP, SKIP, 6, 0, 9, 9, 0x3E};
int arrend_skel3[]={9, 0xE5, 0x2A, CATCH, CATCH, 6, 0, 9, 9, 0x3E};
int arrend_skel[]={13, 0x22, CATCH, CATCH, 0x60, 0x69, 0x22, SKIP, SKIP, 6, 6, 0x2B, 0x36, 0};
int varend_skel[]={13, 0x22, SKIP, SKIP, 0x60, 0x69, 0x22, CATCH, CATCH, 6, 6, 0x2B, 0x36, 0};
int arrend_skel2[]={13, 0xE1, 0x22, CATCH, CATCH, 0x60, 0x69, 0x22, SKIP, SKIP, 0x2B, 0x36, 0, SKIP_CALL};
int varend_skel2[]={13, 0xE1, 0x22, SKIP, SKIP, 0x60, 0x69, 0x22, CATCH, CATCH, 0x2B, 0x36, 0, SKIP_CALL};
int fpadd_skel[]={14, 0xCD, SKIP, ADDR, 0x3A, SKIP, SKIP, 0xB7, 0xC8, 0x3A, SKIP, SKIP, 0x18, 1, 0x2F};
int fpadd_skel2[]={14, 0xCD, SKIP, ADDR, 0x78, 0xB7, 0xC8, 0x3A, SKIP, SKIP, 0xB7, 0xCA, SKIP, SKIP, 0x90};
int last_fpreg_skel[]={11, 0x3A, CATCH, CATCH, 0xB7, 0xC8, 0x3A, SKIP, SKIP, 0x18, 1, 0x2F};
int getvar_skel[]={4, SKIP_CALL, ',', CATCH_CALL, 0xE3};
int getvar_skel2[]={6, CATCH_CALL, 0xE3, 0xD5, 0x7E, 0xFE, ','};
/* chksyn_skel checked in OPNPAR first */
int chksyn_skel2[]={4, CATCH_CALL, ',', SKIP_CALL, 0xE3};
int chksyn_skel3[]={4, CATCH_CALL, ',', SKIP_CALL, 0x28};
int lfrgnm_skel[]={10, 0x3E, '(', 0x18, ADDR, 0x3E, ')', 0x18, 0x0a, 0x3E, 0x88};
int lfrgnm_skel2[]={9, ADDR, 0xEB, SKIP_CALL, ')', 0xC1, 0xD1, 0xC5, 0x43, 0xC9};
int midnum_skel[]={8, 0xEB, SKIP_CALL, ')', ADDR, 0xD1, 0xC5, 0x43, 0xC9};
int getchr_skel3[]={12, ADDR, 0x23, 0x7E, 0xFE, ':', 0xD0, 0xFE, ' ', 0xCA, SKIP, SKIP, 0xFE};
int getchr_skel4[]={11, ADDR, 0x23, 0x7E, 0xFE, ':', 0xD0, 0xFE, ' ', 0x28, SKIP, 0xFE};
int getchr_skel5[]={10, ADDR, 0x23, 0x7E, 0xFE, ' ', 0x28, SKIP, 0xFE, ':', 0xD0};
int getchr_skel[]={12, CATCH_CALL, SKIP_CALL, SKIP_CALL, 0x7A, 0xB7, 0xC2, SKIP, SKIP, 0x2B, SKIP_CALL, 0x7B, 0xC9};
int getchr_skel2[]={11, CATCH_CALL, SKIP_CALL, SKIP_CALL, 0x7A, 0xB7, 0xC4, SKIP, SKIP, SKIP_CALL, 0x7B, 0xC9};
/* 'EVAL' in later BASIC versions */
int getnum_skel[]={11, CATCH_CALL, SKIP_CALL, 0x7A, 0xB7, 0xC2, SKIP, SKIP, 0x2B, SKIP_CALL, 0x7B, 0xC9};
int getnum_skel2[]={10, CATCH_CALL, SKIP_CALL, 0x7A, 0xB7, 0xC4, SKIP, SKIP, SKIP_CALL, 0x7B, 0xC9};
int getnum_skel3[]={9, SKIP_CALL, CATCH_CALL, SKIP_CALL, 0xC2, SKIP, SKIP, 0x2B, SKIP_CALL, 0x7B, 0xC9};
int eval3_ex_skel[]={13, ADDR, 0x2A, SKIP, SKIP, 0xC1, 0x7E, 0x22, SKIP, SKIP, 0xFE, SKIP, 0xD8, 0xFE};
int eval3_body_skel[]={14, ADDR, 0x3A, SKIP, SKIP, 0xFE, 3, 0x7B, 0xCA, SKIP, SKIP, 0xFE, SKIP, 0xD0, 33};
int depint_skel[]={11, SKIP_CALL, CATCH_CALL, 0x7A, 0xB7, 0xC2, SKIP, SKIP, 0x2B, SKIP_CALL, 0x7B, 0xC9};
int depint_skel2[]={10, SKIP_CALL, CATCH_CALL, 0x7A, 0xB7, 0xC4, SKIP, SKIP, SKIP_CALL, 0x7B, 0xC9};
int depint_skel3[]={9, SKIP_CALL, SKIP_CALL, CATCH_CALL, 0xC2, SKIP, SKIP, 0x2B, SKIP_CALL, 0x7B, 0xC9};
int getk_skel[]={12, CATCH_CALL, 0x2A, SKIP, SKIP, 0xC5, SKIP_CALL, 0xC1, 0xC0, 0x2A, SKIP, SKIP, 0x85};
int rinput_skel[]={9, 0x3E, '?', SKIP_CALL, 0x3E, ' ', SKIP_CALL, 0xC3, CATCH, CATCH};
int rinput_skel2[]={7, 0x3E, '?', SKIP_CALL, 0x3E, ' ', SKIP_CALL, CATCH_CALL};
int rinput_skel3[]={7, 0x3E, '?', SKIP, 0x3E, ' ', SKIP, CATCH_CALL};
int rinput_skel4[]={14, 0x3E, '?', SKIP_CALL, 0x3E, ' ', SKIP_CALL, 0x18, SKIP, SKIP, SKIP, 0xC3, SKIP, SKIP, ADDR};
/* High precision BASIC constants present only in the latest versions*/
int log10eval_skel[]={9, ADDR, 0x40,0x43,0x42,0x94,0x48,0x19,0x03,0x24};
int halfval_skel[]={11, ADDR, 0x40,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
int unityval_skel[]={9, ADDR, 0x41,0x10,0x00,0x00,0x00,0x00,0x00,0x00};
int quarterval_skel[]={9, ADDR, 0x40,0x25,0x00,0x00,0x00,0x00,0x00,0x00};
int tenhalfval_skel[]={9, ADDR, 0x41,0x31,0x62,0x27,0x76,0x60,0x16,0x84};
int twoln10val_skel[]={9, ADDR, 0x40,0x86,0x85,0x88,0x96,0x38,0x06,0x50};
int ln10val_skel[]={9, ADDR, 0x41,0x23,0x02,0x58,0x50,0x92,0x99,0x40};
int tan15val_skel[]={9, ADDR, 0x40,0x26,0x79,0x49,0x19,0x24,0x31,0x12};
int sqr3val_skel[]={9, ADDR, 0x41,0x17,0x32,0x05,0x08,0x07,0x56,0x89};
int sixthpival_skel[]={9, ADDR, 0x40,0x52,0x35,0x98,0x77,0x55,0x98,0x30};
int halfpival_skel[]={9, ADDR, 0x41, 0x15, 0x70, 0x79, 0x63, 0x26, 0x79, 0x49};
int epsilonval_skel[]={9, ADDR, 0x40, 0x15, 0x91, 0x54, 0x94, 0x30, 0x91, 0x90};
int logtabval_skel[]={10, ADDR, 4,0xc0,0x71,0x43,0x33,0x82,0x15,0x32,0x26};
int sintabval_skel[]={10, ADDR, 8,0xC0,0x69,0x21,0x56,0x92,0x29,0x18,0x09};
int atntabval_skel[]={10, ADDR, 8,0xBF,0x52,0x08,0x69,0x39,0x04,0x00,0x00};
int halfpi_skel[]={11, 0x21, CATCH, CATCH, SKIP_CALL, SKIP_CALL, 1, 0x49, 0x83, SKIP, 0xDB, 0x0F};
int addphl_skel[]={11, 0x21, SKIP, SKIP, CATCH_CALL, SKIP_CALL, 0X01, 0x49, 0x83, SKIP, 0xDB, 0x0F};
int cos_skel[]={11, ADDR, SKIP, SKIP, SKIP_CALL, SKIP_CALL, 0X01, 0x49, 0x83, SKIP, 0xDB, 0x0F};
int sin_skel[]={13, 0x21, SKIP, SKIP, SKIP_CALL, ADDR, SKIP, SKIP, 0X01, 0x49, 0x83, SKIP, 0xDB, 0x0F};
int cos_skel3[]={20, ADDR, SKIP, SKIP, SKIP_CALL, 0x21, SKIP, SKIP, SKIP_CALL, SKIP_CALL, SKIP_CALL, SKIP_CALL, SKIP_CALL, SKIP_CALL, 33, SKIP, SKIP, SKIP_CALL, SKIP_CALL, 0xF5, 0xFA};
int sin_skel3[]={22, 0x21, SKIP, SKIP, SKIP_CALL, 0x21, SKIP, SKIP, ADDR, SKIP, SKIP, SKIP_CALL, SKIP_CALL, SKIP_CALL, SKIP_CALL, SKIP_CALL, 33, SKIP, SKIP, SKIP_CALL, SKIP_CALL, 0xF5, 0xFA};
int halfpi_skel3[]={13, 0x21, CATCH, CATCH, SKIP_CALL, 0x3A, SKIP, SKIP, 0xE6, 0x7F, 0x32, SKIP, SKIP, 33};
int addphl_skel3[]={12, SKIP, SKIP, CATCH_CALL, 0x3A, SKIP, SKIP, 0xE6, 0x7F, 0x32, SKIP, SKIP, 33};
int cos_skel4[]={13, ADDR, SKIP, SKIP, SKIP_CALL, 0x3A, SKIP, SKIP, 0xE6, 0x7F, 0x32, SKIP, SKIP, 33};
int sin_skel4[]={20, 0x21, SKIP, SKIP, SKIP_CALL, 0x3A, SKIP, SKIP, 0xE6, 0x7F, 0x32, SKIP, SKIP, 33, SKIP, SKIP, SKIP_CALL, SKIP_CALL, 0x18, SKIP, ADDR};
int halfpi_skel2[]={20, 0x21, CATCH, CATCH, SKIP_CALL, 0x21, SKIP, SKIP, SKIP_CALL, SKIP_CALL, SKIP_CALL, SKIP_CALL, SKIP_CALL, SKIP_CALL, 33, SKIP, SKIP, SKIP_CALL, SKIP_CALL, 0xF5, 0xFA};
int addphl_skel2[]={20, 0x21, SKIP, SKIP, CATCH_CALL, 0x21, SKIP, SKIP, SKIP_CALL, SKIP_CALL, SKIP_CALL, SKIP_CALL, SKIP_CALL, SKIP_CALL, 33, SKIP, SKIP, SKIP_CALL, SKIP_CALL, 0xF5, 0xFA};
int atn_skel[]={13, ADDR, SKIP_CALL, 0xFC, SKIP, SKIP, 0xFC, SKIP, SKIP, 0X3A, SKIP, SKIP, 0xFE, 0x81};
int negaft_skel[]={12, SKIP_CALL, 0xFC, CATCH, CATCH, 0xFC, SKIP, SKIP, 0X3A, SKIP, SKIP, 0xFE, 0x81};
int invsgn_skel[]={12, SKIP_CALL, 0xFC, SKIP, SKIP, 0xFC, CATCH, CATCH, 0X3A, SKIP, SKIP, 0xFE, 0x81};
int invsgn_skel2[]={8, 0x16, 0x7D, SKIP_CALL, 0x2A, SKIP, SKIP, 0xE5, CATCH_CALL};
int atn_skel2[]={15, ADDR, 0x3A, SKIP, SKIP, 0xB7, 0xC8, 0xFC, SKIP, SKIP, 0xFE, 0x41, 0xDA, SKIP, SKIP, SKIP_CALL};
int negaft_skel2[]={14, 0x3A, SKIP, SKIP, 0xB7, 0xC8, 0xFC, CATCH, CATCH, 0xFE, 0x41, 0xDA, SKIP, SKIP, SKIP_CALL};
int dbldiv_skel[]={16, 0xB7, 0xC8, 0xFC, SKIP, SKIP, 0xFE, 0x41, 0xDA, SKIP, SKIP, SKIP_CALL, 33, SKIP, SKIP, SKIP_CALL, CATCH_CALL};
int exp_skel[]={9, ADDR, SKIP_CALL, 1, 0x38, 0x81, 17, 0X3B, 0xAA, SKIP_CALL};
int fpmult_skel[]={7, 1, 0x38, 0x81, 17, 0X3B, 0xAA, CATCH_CALL};
int abs_skel[]={10, ADDR, SKIP_CALL, 0xF0, 33, SKIP, SKIP, 0x7E, 0xEE, 0x80, 0x77};
int abs_skel2[]={10, ADDR, SKIP, 0xF0, 33, SKIP, SKIP, 0x7E, 0xEE, 0x80, 0x77};
int abs_skel3[]={14, ADDR, SKIP_CALL, 0xF0, SKIP, 0xFA, SKIP, SKIP, 0xCA, SKIP, SKIP, 33, SKIP, SKIP, 0x7E};
int tstsgn_loc_skel[]={9, CATCH_CALL, 0xF0, 33, SKIP, SKIP, 0x7E, 0xEE, 0x80, 0x77};
int tstsgn_loc_skel2[]={13, CATCH_CALL, 0xF0, SKIP, 0xFA, SKIP, SKIP, 0xCA, SKIP, SKIP, 33, SKIP, SKIP, 0x7E};
int ms_rnd_skel[]={11, ADDR, SKIP_CALL, 0xFA, SKIP, SKIP, 33, SKIP, SKIP, SKIP_CALL, 0xC8, 1};
int ms_rnd_skel2[]={16, ADDR, SKIP_CALL, 33, SKIP, SKIP, 0xFA, SKIP, SKIP, 33, SKIP, SKIP, SKIP_CALL, 33, SKIP, SKIP, 0xC8};
int ms_rnd_seed[]={15, SKIP_CALL, 33, CATCH, CATCH, 0xFA, SKIP, SKIP, 33, SKIP, SKIP, SKIP_CALL, 33, SKIP, SKIP, 0xC8};
int ms_lstrnd[]={15, SKIP_CALL, 33, SKIP, SKIP, 0xFA, SKIP, SKIP, 33, CATCH, CATCH, SKIP_CALL, 33, SKIP, SKIP, 0xC8};
int ms_lstrnd2[]={10, SKIP_CALL, 0xFA, SKIP, SKIP, 33, CATCH, CATCH, SKIP_CALL, 0xC8, 1};
int last_fpreg_skel2[]={13, SKIP_CALL, 0xF0, SKIP, 0xFA, SKIP, SKIP, 0xCA, SKIP, SKIP, 33, CATCH, CATCH, 0x7E};
int dblabs_skel[]={13, SKIP_CALL, 0xF0, SKIP, 0xFA, CATCH, CATCH, 0xCA, SKIP, SKIP, 33, SKIP, SKIP, 0x7E};
int dblabs_skel2[]={10, ADDR, 0x2A, SKIP, SKIP, SKIP_CALL, 0x7C, 0xEE, 0x80, 0xB5, 0xC0};
int dblfpreg_skel[]={9, 0x2A, CATCH, CATCH, SKIP_CALL, 0x7C, 0xEE, 0x80, 0xB5, 0xC0};
int dbl_tstsgn_skel3[]={6, CATCH_CALL, 0x6F, 0x17, 0x9F, 0x67, 0xC3};
int dbl_tstsgn_skel[]={13, CATCH_CALL, 0xF0, SKIP, 0xFA, SKIP, SKIP ,0xCA, SKIP, SKIP, 33, SKIP, SKIP, 0x7E};
int dbl_tstsgn_skel2[]={9, CATCH_CALL, 0xF0, 33, SKIP, SKIP, 0x7E, 0xEE, 0x80, 0x77};
int test_type_skel[]={9, CATCH_CALL, 0xCA, SKIP, SKIP, 0xF2, SKIP, SKIP, 0x2A, SKIP, SKIP, 0x7C, 0xB5, 0xC8 ,0x7C, 0x18};
int log_skel[]={13, ADDR, SKIP_CALL, 0xB7, 0xEA, SKIP, SKIP, 33, SKIP, SKIP, 0x7E, 1, SKIP, 0x80};
int log_skel2[]={10, ADDR, SKIP_CALL, 0xB7, 0xEA, SKIP, SKIP, SKIP_CALL, 1, SKIP, 0x80};
int log_skel3[]={13, ADDR, SKIP_CALL, 0xB7, 0xEC, SKIP, SKIP, 33, SKIP, SKIP, 0x7E, 1, SKIP, 0x80};
int log_skel4[]={10, ADDR, SKIP, 0xB7, 0xEA, SKIP, SKIP, SKIP_CALL, 1, SKIP, 0x80};
int log_skel5[]={13, ADDR, SKIP, 0xB7, 0xEA, SKIP, SKIP, 33, SKIP, SKIP, 0x7E, 1, SKIP, 0x80};
int log_skel6[]={14, ADDR, SKIP_CALL, 0xFA, SKIP, SKIP, 0xCA, SKIP, SKIP, 33, SKIP, SKIP, 0x7E, 0xF5, 0x36};
int fcerr_skel[]={12, SKIP_CALL, 0xB7, 0xEA, CATCH, CATCH, 33, SKIP, SKIP, 0x7E, 1, SKIP, 0x80};
int fcerr_skel2[]={12, SKIP_CALL, 0xB7, 0xEA, CATCH, CATCH, 33, SKIP, SKIP, 0x7E, 1, SKIP, 0x80};
int fcerr_skel3[]={12, SKIP_CALL, 0xB7, 0xEC, CATCH, CATCH, 33, SKIP, SKIP, 0x7E, 1, SKIP, 0x80};
int fcerr_skel4[]={13, SKIP_CALL, 0xFA, CATCH, CATCH, 0xCA, SKIP, SKIP, 33, SKIP, SKIP, 0x7E, 0xF5, 0x36};
int fpadd_skel3[]={13, CATCH_CALL, 0xC1, 0xD1, 0x04, SKIP_CALL, 33, SKIP, SKIP, SKIP_CALL, 33, SKIP, SKIP, 0xCD};
int fpadd_skel4[]={12, ADDR, 0xB7, 0xC8, 0x3A, SKIP, SKIP, 0xB7, 0xCA, SKIP, SKIP, 0x90, 0x30};
int dvbcde_skel[]={13, SKIP_CALL, 0xC1, 0xD1, 0x04, CATCH_CALL, 33, SKIP, SKIP, SKIP_CALL, 33, SKIP, SKIP, 0xCD};
int unity_skel[]={13, SKIP_CALL, 0xC1, 0xD1, 0x04, SKIP_CALL, 33, CATCH, CATCH, SKIP_CALL, 33, SKIP, SKIP, 0xCD};
int subphl_skel[]={13, SKIP_CALL, 0xC1, 0xD1, 0x04, SKIP_CALL, 33, SKIP, SKIP, CATCH_CALL, 33, SKIP, SKIP, 0xCD};
int logtab_skel[]={13, SKIP_CALL, 0xC1, 0xD1, 0x04, SKIP_CALL, 33, SKIP, SKIP, SKIP_CALL, 33, CATCH, CATCH, 0xCD};
int sumser_skel[]={13, SKIP_CALL, 0xC1, 0xD1, 0x04, SKIP_CALL, 33, SKIP, SKIP, SKIP_CALL, 33, SKIP, SKIP, CATCH_CALL};
int dvbcde_org_skel[]={13, ADDR, SKIP_CALL, 0xC1, 0xD1, SKIP_CALL, 1, 0x38, 0x81, 17, SKIP, SKIP, SKIP_CALL, 33};
int tan_skel[]={10, ADDR, SKIP_CALL, SKIP_CALL, 0xC1, 0xE1, SKIP_CALL, 0xEB, SKIP_CALL, SKIP_CALL, 0xC3};
int tan_skel2[]={11, ADDR, SKIP_CALL, SKIP_CALL, 0xC1, 0xD1, 0xEB, SKIP_CALL, 0xEB, SKIP_CALL, SKIP_CALL, 0xC3};
int tan_skel3[]={12, ADDR, SKIP_CALL, SKIP_CALL, 0xC1, 0xDD, 0xE1, 0xD1, SKIP_CALL, 0xEB, SKIP_CALL, SKIP_CALL, 0xC3};
/* Removed to avoid false positive results */
//int sin_skel2[]={9, SKIP_CALL, CATCH_CALL, 0xC1, 0xE1, SKIP_CALL, 0xEB, SKIP_CALL, SKIP_CALL, 0xC3};
//int cos_skel2[]={9, SKIP_CALL, SKIP_CALL, 0xC1, 0xE1, SKIP_CALL, 0xEB, SKIP_CALL, CATCH_CALL, 0xC3};
int div_skel[]={11, SKIP_CALL, SKIP_CALL, 0xC1, 0xE1, SKIP_CALL, 0xEB, SKIP_CALL, SKIP_CALL, 0xC3, CATCH, CATCH};
int div_skel2[]={17, 1, 0x20, 0x84, 0xDD, 0x21, 0, 0, 17, 0, 0, 0xCD, SKIP, ADDR, 0xC1, 0xDD, 0xE1, 0xD1};
int fpbcde_skel2[]={10, SKIP_CALL, SKIP_CALL, 0xC1, 0xD1, 0xEB, SKIP_CALL, 0xEB, CATCH_CALL, SKIP_CALL, 0xC3};
int fpbcde_skel3[]={12, SKIP_CALL, 1, 0x20, 0x84, 0xDD, 0x21, 0, 0, 17, 0, 0, CATCH_CALL};
int fpbcde_skel4[]={11, SKIP_CALL, SKIP_CALL, 0xC1, 0xDD, 0xE1, 0xD1, SKIP_CALL, 0xEB, CATCH_CALL, SKIP_CALL, 0xC3};
int phltfp_skel[]={9, SKIP_CALL, 33, SKIP, SKIP, CATCH_CALL, 0xC1, 0xD1, SKIP_CALL, 0x78};
int phltfp_skel2[]={12, SKIP_CALL, 33, SKIP, SKIP, CATCH_CALL, 0x18, 3, SKIP_CALL, 0xC1, 0xD1, SKIP_CALL, 0x78};
int phltfp_skel3[]={13, SKIP_CALL, 33, SKIP, SKIP, CATCH_CALL, 0xC3, SKIP, SKIP, SKIP_CALL, 0xC1, 0xD1, SKIP_CALL, 0x78};
int phltfp_skel4[]={11, SKIP_CALL, 33, SKIP, SKIP, CATCH_CALL, 0xC1, 0xD1, SKIP_CALL, 0x28, SKIP, 0x78};
int phltfp_skel5[]={15, SKIP_CALL, 33, SKIP, SKIP, 0xFA, SKIP, SKIP, 33, SKIP, SKIP, CATCH_CALL, 33, SKIP, SKIP, 0xC8};
int phltfp_skel6[]={10, SKIP_CALL, 0xFA, SKIP, SKIP, 33, SKIP, SKIP, CATCH_CALL, 0xC8, 1};
int div10_skel[]={17, ADDR, SKIP_CALL, 1, SKIP, SKIP, 17, SKIP, SKIP, SKIP_CALL, 0xC1, 0xD1, SKIP_CALL, 0xCA, SKIP, SKIP, 0x2E, 0xFF};
int div10_skel2[]={17, ADDR, SKIP_CALL, 1, SKIP, SKIP, 17, SKIP, SKIP, SKIP_CALL, 0xC1, 0xD1, SKIP_CALL, 0xCC, SKIP, SKIP, 0x2E, 0xFF};
int div10_skel3[]={14, ADDR, SKIP_CALL, 33, SKIP, SKIP, SKIP_CALL, 0xC1, 0xD1, SKIP_CALL, 0xCA, SKIP, SKIP, 0x2E, 0xFF};
int div10_skel4[]={14, ADDR, SKIP_CALL, 33, SKIP, SKIP, SKIP_CALL, 0xC1, 0xD1, SKIP_CALL, 0xCC, SKIP, SKIP, 0x2E, 0xFF};
int div10_skel5[]={13, ADDR, SKIP_CALL, 1, 0x20, 0x84, 0xDD, 0x21, 0, 0, 17, 0, 0, SKIP_CALL};
int sqr_skel[]={10, ADDR, SKIP_CALL, 33, SKIP, SKIP, SKIP_CALL, 0xC1, 0xD1, SKIP_CALL, 0x78};
int sqr_skel2[]={13, ADDR, SKIP_CALL, 33, SKIP, SKIP, SKIP_CALL, 0x18, 3, SKIP_CALL, 0xC1, 0xD1, SKIP_CALL, 0x78};
int sqr_skel3[]={14, ADDR, SKIP_CALL, 33, SKIP, SKIP, SKIP_CALL, 0xC3, SKIP, SKIP, SKIP_CALL, 0xC1, 0xD1, SKIP_CALL, 0x78};
int sqr_skel4[]={12, ADDR, SKIP_CALL, 33, SKIP, SKIP, SKIP_CALL, 0xC1, 0xD1, SKIP_CALL, 0x28, SKIP, 0x78};
int sqr_skel5[]={12, ADDR, SKIP_CALL, 0xC8, 0xFA, SKIP, SKIP, SKIP_CALL, 0x3A, SKIP, SKIP, 0xB7, 0x1F};
int power_skel[]={11, SKIP_CALL, 33, SKIP, SKIP, 0xCD, SKIP, ADDR, 0xC1, 0xD1, SKIP_CALL, 0x78};
int power_skel2[]={12, SKIP_CALL, 33, SKIP, SKIP, SKIP_CALL, 0x18, ADDR, SKIP_CALL, 0xC1, 0xD1, SKIP_CALL, 0x78};
int power_skel3[]={13, SKIP_CALL, 33, SKIP, SKIP, SKIP_CALL, 0xC3, SKIP, ADDR, SKIP_CALL, 0xC1, 0xD1, SKIP_CALL, 0x78};
int power_skel4[]={13, SKIP_CALL, 33, SKIP, SKIP, 0xCD, SKIP, ADDR, 0xC1, 0xD1, SKIP_CALL, 0x28, SKIP, 0x78};
int half_skel[]={9, SKIP_CALL, 33, CATCH, CATCH, SKIP_CALL, 0xC1, 0xD1, SKIP_CALL, 0x78};
int half_skel2[]={12, SKIP_CALL, 33, CATCH, CATCH, SKIP_CALL, 0x18, 3, SKIP_CALL, 0xC1, 0xD1, SKIP_CALL, 0x78};
int half_skel3[]={13, SKIP_CALL, 33, CATCH, CATCH, SKIP_CALL, 0xc3, SKIP, SKIP, SKIP_CALL, 0xC1, 0xD1, SKIP_CALL, 0x78};
int half_skel4[]={11, SKIP_CALL, 33, CATCH, CATCH, SKIP_CALL, 0xC1, 0xD1, SKIP_CALL, 0x28, SKIP, 0x78};
int bnorm_skel[]={12, ADDR, 0x68, 0x63, 0xAF, 0x47, 0x79, 0xB7, 0xC2, SKIP, SKIP, 0x4A, 0x54};
int bnorm_skel2[]={11, ADDR, 0x68, 0x63, 0xAF, 0x47, 0x79, 0xB7, 0x28, SKIP, 0x4A, 0x54};
int plucde_skel[]={11, ADDR, 0x7E, 0x83, 0x5F, 0x23, 0x7E, 0x8A, 0x57, 0x23, 0x7E, 0x89};
int compl_skel[]={12, ADDR, 33, SKIP, SKIP, 0x7E, 0x2F, 0x77, 0xAF, 0x6F, 0x90, 0x47, 0x7D};
int sgnres_skel[]={11, 33, CATCH, CATCH, 0x7E, 0x2F, 0x77, 0xAF, 0x6F, 0x90, 0x47, 0x7D};
int shrite_skel[]={13, 6, 0, 0xD6, 8, 0xDA, CATCH, CATCH, 0x43, 0x5A, 0x51, 0x0E, 0, 0xC3};
int shrite_skel2[]={9, ADDR, 0xC6, 9, 0x6F, 0xAF, 0x2D, 0xC8, 0x79, 0x1F};
int scale_skel[]={11, ADDR, 6, 0, 0xD6, 8, 0x38, SKIP, 0x43, 0x5A, 0x51, 0x0E, 0, 0xC3};
int scale_skel2[]={14, ADDR, 6, 0, 0xD6, 8, 0xDA, CATCH, CATCH, 0x43, 0x5A, 0x51, 0x0E, 0, 0xC3};
/*
SHRITE: ADD A,8+1 ; Adjust count
LD L,A ; Save bits to shift
SHRLP: XOR A ; Flag for all done
DEC L ; All shifting done?
RET Z ; Yes - Return
LD A,C ; Get MSB
SHRT1: RRA ; Shift it right
*/
int fpthl_skel[]={10, ADDR, 17, SKIP, SKIP, 6, 4, 0x1A, 0x77, 0x13, 0x23};
/* connected to 'ASCTFP' */
int fpthl_skel2[]={9, SKIP_JP_RET, SKIP_CALL, SKIP_CALL, 0xE3, CATCH_CALL, 0xE1, 0xDD, 0xE1, SKIP_CALL};
int fpthl_skel3[]={12, SKIP_JP_RET, SKIP_CALL, SKIP_CALL, 0xE3, CATCH_CALL, 0xE1, 0x25, SKIP_CALL, 0xCA, SKIP, SKIP, 0xE3};
int for_skel[]={10, ADDR, 62, 0x64, 0x32, SKIP, SKIP, SKIP_CALL, 0xE3, SKIP_CALL, 0xD1};
int for_skel2[]={10, ADDR, 62, 0x64, 0x32, SKIP, SKIP, SKIP_CALL, 0xE3, 0xD1, 0xC2};
int for_skel3[]={12, ADDR, SKIP_CALL, SKIP_CALL, SKIP_CALL, 0xED, 0x53, SKIP, SKIP, 0xE3, SKIP_CALL, 0xD1, 0x20};
int for_skel4[]={10, ADDR, 62, 0x64, 0x32, SKIP, SKIP, SKIP_CALL, 0xC1, 0xE5, SKIP_CALL};
int fdtlp_skel[]={10, ADDR, SKIP_CALL, 0xB7, 0xC2, SKIP, SKIP, 0x23, 0x7E, 0x23, 0xB6, 0x5E};
int fdtlp_skel2[]={9, ADDR, SKIP_CALL, 0xB7, 0x20, SKIP, 0x23, 0x7E, 0x23, 0xB6, 0x5E};
int fdtlp_skel3[]={9, ADDR, SKIP_CALL, 0xB7, 0xC2, SKIP, SKIP, 0x23, SKIP_CALL, 0x79, 0xB0};
int data_skel[]={9, CATCH_CALL, 0xB7, 0xC2, SKIP, SKIP, 0x23, 0x7E, 0x23, 0xB6, 0x5E};
int data_skel2[]={8, CATCH_CALL, 0xB7, 0x20, SKIP, 0x23, 0x7E, 0x23, 0xB6, 0x5E};
int data_skel3[]={9, CATCH_CALL, 0xB7, 0xC2, SKIP, SKIP, 0x23, SKIP_CALL, 0x79, 0xB0};
int restore_skel[]={14, ADDR, 0xEB, 0x2A, SKIP, SKIP, 0x28, 0x0E, 0xEB, SKIP_CALL, 0xE5, SKIP_CALL, 0x60, 0x69, 0xD1, 0xD2};
int dcbde_skel[]={8, ADDR, 0x1B, 0x7A, 0xA3, 0x3C, 0xC0, 0x0B, 0xC9};
int dblint_skel[]={9, ADDR, SKIP, 0xF8, 0x30, SKIP, 0x28, SKIP, SKIP_CALL, 33, SKIP, SKIP, 0x7E, 0xFE, 0x98};
int dblint_skel2[]={16, ADDR, SKIP_CALL, 0xF8, 0xD2, SKIP, SKIP, 0xCA, SKIP, SKIP, SKIP_CALL, 33, SKIP, SKIP, 0x7E, 0xFE, 0x98};
int fix_skel[]={10, ADDR, SKIP_CALL, 0xF8, SKIP_CALL, 0xF2, SKIP, SKIP, SKIP_CALL, SKIP_CALL, 0xC3};
int dblsub_skel[]={14, ADDR, 33, SKIP, SKIP, 0x7E, 0xEE, 0x80, 0x77, 33, SKIP, SKIP, 0x7E, 0xB7, 0xC8};
int dblsub_skel2[]={15, ADDR, 33, SKIP, SKIP, SKIP_CALL, 33, SKIP, SKIP, 0x7E, 0xB7, 0xC8, 0x47, 0x2B, 0x4E, 17};
int dbllast_fpreg_skel[]={13, 33, CATCH, CATCH, 0x7E, 0xEE, 0x80, 0x77, 33, SKIP, SKIP, 0x7E, 0xB7, 0xC8};
int dbladd_skel[]={13, 33, SKIP, SKIP, 0x7E, 0xEE, 0x80, ADDR, 33, SKIP, SKIP, 0x7E, 0xB7, 0xC8};
int dblmul_skel[]={9, ADDR, SKIP_CALL, 0xC8, SKIP_CALL, SKIP_CALL, 0x71, 0x13, 6, 7};
int dbldiv_skel2[]={13, ADDR, 0x3A, SKIP, SKIP, 0xB7, 0xCA, SKIP, SKIP, SKIP_CALL, 0x34, 0x34, SKIP_CALL, 33};
int int_skel[]={11, ADDR, 33, SKIP, SKIP, 0x7E, 0xFE, 0x98, 0x3A, SKIP, SKIP, 0xD0};
int mldebc_skel[]={10, 0xC1, 3, 0x71, 0xF5, 0x23, 0x70, 0x23, CATCH_CALL, 0xF1, 0x3D};
int mldebc_skel2[]={10, 0xC1, 3, 0x71, 0x23, 0x70, 0x23, 0xF5, CATCH_CALL, 0xF1, 0x3D};
int mldebc_skel3[]={9, ADDR, 33, 0, 0, 0x78, 0xB1, 0xC8, 0x3E, 0x10};
int intmul_skel[]={17, ADDR, 0x7C, 0xB5, 0xCA, SKIP, SKIP, 0xE5, 0xD5, SKIP_CALL, 0xC5, 0x44, 0x4D, 33, 0, 0, 0x3E, 0x10};
int asctfp_skel[]={10, ADDR, 0xFE, '-', 0xF5, 0xCA, SKIP, SKIP, 0xFE, '+', 0xCA};
int asctfp_skel2[]={9, ADDR, 0xFE, '-', 0xF5, 0x28, SKIP, 0xFE, '+', 0x28};
int hextfp_skel[]={12, ADDR, 17, 0, 0, SKIP_CALL, SKIP_CALL, 1, SKIP, SKIP, 0xFE, 0x42, 0x28};
int hex_asctfp_skel[]={15, ADDR, 0xFE, '&', 0xCA, SKIP, SKIP, 0xFE, '-', 0xF5, 0xCA, SKIP, SKIP, 0xFE, '+', 0xCA};
int hex_asctfp_skel2[]={14, ADDR, 0xFE, '&', 0xCA, SKIP, SKIP, 0xFE, '-', 0xF5, 0x28, SKIP, 0xFE, '+', 0x28};
int dblasctfp_skel[]={11, ADDR, SKIP_CALL, SKIP_CALL, 0xF6, 0xAF, 0xEB, 1, 255, 0, 0x60, 0x68};
int dblasctfp_skel2[]={11, ADDR, 0xEB, 1, 0xFF, 0, 0x60, 0x68, SKIP_CALL, 0xEB, 0x7E, 0xFE};
int prnthl_skel[]={10, ADDR, 0xEB, 0xAF, 6, 0x98, SKIP_CALL, 33, SKIP, SKIP, 0xE5};
int prnthl_skel2[]={10, 0xE5, 33, SKIP, SKIP, SKIP_CALL, ADDR, 0xEB, 0xAF, 6, 0x98};
int prnthl_skel3[]={10, 0xE5, 33, SKIP, SKIP, SKIP_CALL, 17, SKIP, SKIP, ADDR, 0xEB, 0xAF, 6, 0x98};
int prs_skel[]={14, 0xE5, 33, SKIP, SKIP, CATCH_CALL, 0xE1, 17, SKIP, SKIP, 0xD5, 0xEB, 0xAF, 6, 0x98};
int prs_skel3[]={11, 0xE5, 33, SKIP, SKIP, CATCH_CALL, 0xE1, 17, 0xEB, 0xAF, 6, 0x98};
int str_skel[]={15, ADDR, SKIP_CALL, SKIP_CALL, SKIP_CALL, SKIP_CALL, 1, SKIP, SKIP, 0xC5, 0x7E, 0x23, 0x23, 0xE5, SKIP_CALL, 0xE1, 0x4E};
int str_skel2[]={14, ADDR, SKIP_CALL, SKIP_CALL, SKIP_CALL, 1, SKIP, SKIP, 0xC5, 0x7E, 0x23, 0xE5, SKIP_CALL, 0xE1, 0x4E};
int tstopl_skel[]={15, ADDR, 17, SKIP, SKIP, 0x2A, SKIP, SKIP, 0x22, SKIP, SKIP, 0x3E, 1, 0x32, SKIP_CALL, SKIP_CALL};
int tstopl_skel2[]={14, ADDR, 17, SKIP, SKIP, 0x3E, 0xD5, 0x2A, SKIP, SKIP, 0x22, SKIP, SKIP, 0x3E, 3};
int tmstpt_skel[]={14, 17, SKIP, SKIP, 0x2A, CATCH, CATCH, 0x22, SKIP, SKIP, 0x3E, 1, 0x32, SKIP_CALL, SKIP_CALL};
int tmstpt_skel2[]={13, 17, SKIP, SKIP, 0x3E, 0xD5, 0x2A, CATCH, CATCH, 0x22, SKIP, SKIP, 0x3E, 3};
int tmpstr_skel[]={14, 17, CATCH, CATCH, 0x2A, SKIP, SKIP, 0x22, SKIP, SKIP, 0x3E, 1, 0x32, SKIP_CALL, SKIP_CALL};
int tmpstr_skel2[]={13, 17, CATCH, CATCH, 0x3E, 0xD5, 0x2A, SKIP, SKIP, 0x22, SKIP, SKIP, 0x3E, 3};
int tmpstr_skel3[]={13, SKIP_CALL, 33, CATCH, CATCH, 0xE5, 0x77, 0x23, 0x23, 0x73, 0x23, 0x72, 0xE1, 0xC9};
int fpreg_skel3[]={14, 17, SKIP, SKIP, 0x2A, SKIP, SKIP, 0x22, CATCH, CATCH, 0x3E, 1, 0x32, SKIP_CALL, SKIP_CALL};
int fpreg_skel4[]={13, 17, SKIP, SKIP, 0x3E, 0xD5, 0x2A, SKIP, SKIP, 0x22, CATCH, CATCH, 0x3E, 3};
int savstr_skel[]={17, SKIP_CALL, SKIP_CALL, SKIP_CALL, 0xCD, SKIP, ADDR, 1, SKIP, SKIP, 0xC5, 0x7E, 0x23, 0x23, 0xE5, SKIP_CALL, 0xE1, 0x4E};
int savstr_skel2[]={15, SKIP_CALL, SKIP_CALL, 0xCD, SKIP, ADDR, 1, SKIP, SKIP, 0xC5, 0x7E, 0x23, 0xE5, SKIP_CALL, 0xE1, 0x4E};
int testr_skel[]={15, SKIP_CALL, SKIP_CALL, SKIP_CALL, SKIP_CALL, 1, SKIP, SKIP, 0xC5, 0x7E, 0x23, 0x23, 0xE5, CATCH_CALL, 0xE1, 0x4E};
int testr_skel2[]={13, SKIP_CALL, SKIP_CALL, SKIP_CALL, 1, SKIP, SKIP, 0xC5, 0x7E, 0x23, 0xE5, CATCH_CALL, 0xE1, 0x4E};
int testr_skel3[]={13, CATCH_CALL, 33, SKIP, SKIP, 0xE5, 0x77, 0x23, 0x23, 0x73, 0x23, 0x72, 0xE1, 0xC9};
int mktmst_skel[]={14, ADDR, SKIP_CALL, 33, SKIP, SKIP, 0xE5, 0x77, 0x23, 0x23, 0x73, 0x23, 0x72, 0xE1, 0xC9};
int mktmst_skel2[]={9, 0x3E, 1 , CATCH_CALL, SKIP_CALL, 0x2A, SKIP, SKIP, 0x73, 0xC1};
int makint_skel[]={9, 0x3E, 1 , SKIP_CALL, CATCH_CALL, 0x2A, SKIP, SKIP, 0x73, 0xC1};
int tstopl_skel3[]={12, 0x3E, 1, SKIP_CALL, SKIP_CALL, 0x2A, SKIP, SKIP, 0x73, 0xC1, 0xC3, CATCH, CATCH};
int tstopl_skel4[]={12, 0x3E, 1, SKIP_CALL, SKIP_CALL, 0x2A, SKIP, SKIP, 0x73, 0xC1, 0xE1, 0xC3, CATCH, CATCH};
int chr_skel[]={10, ADDR, 0x3E, 1 , SKIP_CALL, SKIP_CALL, 0x2A, SKIP, SKIP, 0x73, 0xC1};
int new_skel[]={13, 0xC3, SKIP, ADDR, 0xC0, 0x2A, SKIP, SKIP, 0xAF, 0x77, 0x23, 0x77, 0x23, 0x22 };
int new_skel2[]={12, 0x18, ADDR, 0xC0, 0x2A, SKIP, SKIP, 0xAF, 0x77, 0x23, 0x77, 0x23, 0x22 };
int new_skel3[]={14, ADDR, 0xC0, 0x2A, SKIP, SKIP, SKIP_CALL, 0x32, SKIP, SKIP, 0x77, 0x23, 0x77, 0x23, 0x22 };
int concat_skel[]={13, ADDR, 0xC5, 0xE5, 0x2A, SKIP, SKIP, 0xE3, SKIP_CALL, 0xE3, SKIP_CALL, 0x7E, 0xE5, 0x2A};
int oprnd_skel[]={12, 0xC5, 0xE5, 0x2A, SKIP, SKIP, 0xE3, CATCH_CALL, 0xE3, SKIP_CALL, 0x7E, 0xE5, 0x2A};
int tststr_skel[]={12, 0xC5, 0xE5, 0x2A, SKIP, SKIP, 0xE3, SKIP_CALL, 0xE3, CATCH_CALL, 0x7E, 0xE5, 0x2A};
int mktmst2_skel[]={13, CATCH_CALL, 0xD1, SKIP_CALL, 0xE3, SKIP_CALL, 0xE5, 0x2A, SKIP, SKIP, 0xEB, SKIP_CALL, SKIP_CALL, 33};
int sstsa_skel[]={13, SKIP_CALL, 0xD1, SKIP_CALL, 0xE3, SKIP_CALL, 0xE5, 0x2A, SKIP, SKIP, 0xEB, CATCH_CALL, SKIP_CALL, 33};
int tostra_skel[]={9, 0x46, 0x6F, ADDR, 0x2D, 0xC8, 0x0A, 0x12, 0x03, 0x13};
int topool_skel[]={15, SKIP_CALL, SKIP_CALL, SKIP_CALL, SKIP_CALL, 1, CATCH, CATCH, 0xC5, 0x7E, 0x23, 0x23, 0xE5, SKIP_CALL, 0xE1, 0x4E};
int topool_skel2[]={14, ADDR, SKIP_CALL, SKIP_CALL, SKIP_CALL, 1, CATCH, CATCH, 0xC5, 0x7E, 0x23, 0xE5, SKIP_CALL, 0xE1, 0x4E};
int opnpar_skel[]={12, ADDR, SKIP_CALL, '(', 0x2B, 0x16, 0, 0xD5, 0x0E, 1, SKIP_CALL, SKIP_CALL, 0x22};
int stkths_skel[]={15, ADDR, 0xC5, 1, SKIP, SKIP, 0xC5, 0x43, 0x4A, SKIP_CALL, 0x58, 0x51, 0x4E, 0x23, 0x46, 0x23};
int eval_skel[]={13, ADDR, 0x2B, 0x16, 0, 0xD5, 0x0E, 1, SKIP_CALL, SKIP_CALL, 0x22, SKIP, SKIP, 0x2A};
int eval_skel2[]={14, ADDR, 0x2B, 0x16, 0, 0xD5, 0x0E, 1, SKIP_CALL, SKIP_CALL, SKIP_CALL, 0x22, SKIP, SKIP, 0x2A};
int eval_skel3[]={18, ADDR, 0x2B, 0x16, 0, 0xD5, 0x0E, 1, SKIP_CALL, SKIP_CALL, SKIP_CALL, 0xAF, 0x32, SKIP, SKIP, 0x22, SKIP, SKIP, 0x2A};
int chksyn_skel[]={11, CATCH_CALL, '(', 0x2B, 0x16, 0, 0xD5, 0x0E, 1, SKIP_CALL, SKIP_CALL, 0x22};
int chkstk_skel[]={11, SKIP_CALL, '(', 0x2B, 0x16, 0, 0xD5, 0x0E, 1, CATCH_CALL, SKIP_CALL, 0x22};
int oprnd_skel2[]={11, SKIP_CALL, '(', 0x2B, 0x16, 0, 0xD5, 0x0E, 1, SKIP_CALL, CATCH_CALL, 0x22};
int nxtopr_skel[]={13, SKIP_CALL, '(', 0x2B, 0x16, 0, 0xD5, 0x0E, 1, SKIP_CALL, SKIP_CALL, 0x22, CATCH, CATCH};
int curpos_skel[]={15, 0x3A, CATCH, CATCH, 0x86, 0x3D, 0xB8, 0xD4, SKIP, SKIP, SKIP_CALL, 0xAF, 0xC4, SKIP, SKIP, 0xE1};
int curpos_skel2[]={11, 0x3A, CATCH, CATCH, 0x86, 0xB8, 0xD4, SKIP, SKIP, SKIP_CALL, 0x3E, 0x20};
int getint_skel[]={13, CATCH_CALL, 0x32, SKIP, SKIP, 0x32, SKIP, SKIP, SKIP_CALL, ',', 0xC3, SKIP, SKIP, SKIP_CALL};
int getint_skel2[]={12, CATCH_CALL, 0x32, SKIP, SKIP, 0x32, SKIP, SKIP, SKIP_CALL, ',', 0x18, SKIP, SKIP_CALL};
int getint_skel3[]={12, CATCH_CALL, 0x32, SKIP, SKIP, 0x32, SKIP, SKIP, SKIP_CALL, ',', 0x2B, 0x23, SKIP_CALL};
int getint_skel4[]={14, SKIP_CALL, ADDR, SKIP, SKIP, SKIP_CALL, 0x7A, 0xB7, 0xC2, SKIP, SKIP, 0x2B, SKIP_CALL, 0x7B, 0xC9};
int getint_skel5[]={13, SKIP_CALL, ADDR, SKIP, SKIP, SKIP_CALL, 0x7A, 0xB7, 0xC4, SKIP, SKIP, SKIP_CALL, 0x7B, 0xC9};
int getint_skel6[]={12, SKIP_CALL, ADDR, SKIP, SKIP, SKIP_CALL, 0xC2, SKIP, SKIP, 0x2B, SKIP_CALL, 0x7B, 0xC9};
int fndnum_skel[]={13, ADDR, SKIP_CALL, SKIP_CALL, SKIP_CALL, 0x7A, 0xB7, 0xC2, SKIP, SKIP, 0x2B, SKIP_CALL, 0x7B, 0xC9};
int fndnum_skel2[]={12, ADDR, SKIP_CALL, SKIP_CALL, SKIP_CALL, 0x7A, 0xB7, 0xC4, SKIP, SKIP, SKIP_CALL, 0x7B, 0xC9};
int fndnum_skel3[]={11, ADDR, SKIP_CALL, SKIP_CALL, SKIP_CALL, 0xC2, SKIP, SKIP, 0x2B, SKIP_CALL, 0x7B, 0xC9};
int makint_skel2[]={14, SKIP_CALL, SKIP_CALL, ADDR, SKIP, SKIP, 0x7A, 0xB7, 0xC2, SKIP, SKIP, 0x2B, SKIP_CALL, 0x7B, 0xC9};
int makint_skel3[]={13, SKIP_CALL, SKIP_CALL, ADDR, SKIP, SKIP, 0x7A, 0xB7, 0xC4, SKIP, SKIP, SKIP_CALL, 0x7B, 0xC9};
int makint_skel4[]={12, SKIP_CALL, SKIP_CALL, ADDR, SKIP, SKIP, 0xC2, SKIP, SKIP, 0x2B, SKIP_CALL, 0x7B, 0xC9};
int getword_skel[]={8, CATCH_CALL, 0xD5, SKIP_CALL, ',', SKIP_CALL, 0xD1, 0x12, 0xc9};
/*
__POKE:
CALL L542F ; GETWORD <--
PUSH DE
RST SYNCHR ; Check syntax: next byte holds the byte to be found
INC L
CALL GETINT
POP DE
LD (DE),A
RET
*/
int inport_skel[]={13, SKIP_CALL, 0x32, CATCH, CATCH, 0x32, SKIP, SKIP, SKIP_CALL, ',', 0xC3, SKIP, SKIP, SKIP_CALL};
int otport_skel[]={13, SKIP_CALL, 0x32, SKIP, SKIP, 0x32, CATCH, CATCH, SKIP_CALL, ',', 0xC3, SKIP, SKIP, SKIP_CALL};
int inport_skel2[]={12, SKIP_CALL, 0x32, CATCH, CATCH, 0x32, SKIP, SKIP, SKIP_CALL, ',', 0x18, SKIP, SKIP_CALL};
int otport_skel2[]={12, SKIP_CALL, 0x32, SKIP, SKIP, 0x32, CATCH, CATCH, SKIP_CALL, ',', 0x18, SKIP, SKIP_CALL};
int inport_skel3[]={12, SKIP_CALL, 0x32, CATCH, CATCH, 0x32, SKIP, SKIP, SKIP_CALL, ',', 0x2B, 0x23, SKIP_CALL};
int otport_skel3[]={12, SKIP_CALL, 0x32, SKIP, SKIP, 0x32, CATCH, CATCH, SKIP_CALL, ',', 0x2B, 0x23, SKIP_CALL};
int outc_skel[]={15, 0x3A, SKIP, SKIP, 0x86, 0x3D, 0xB8, 0xD4, CATCH, CATCH, SKIP_CALL, 0xAF, 0xC4, SKIP, SKIP, 0xE1};
int prs_skel2[]={15, 0x3A, SKIP, SKIP, 0x86, 0x3D, 0xB8, 0xD4, SKIP, SKIP, CATCH_CALL, 0xAF, 0xC4, SKIP, SKIP, 0xE1};
int outc_skel2[]={12, 0x3A, SKIP, SKIP, 0x86, 0xB8, 0xD4, SKIP, SKIP, SKIP_CALL, 0x3E, 0x20, CATCH_CALL};
int prnums_skel[]={12, ADDR, 0x23, SKIP_CALL, SKIP_CALL, SKIP_CALL, 0x1C, 0x1D, 0xC8, 0x0A, SKIP_CALL, 0xFE, 13};
int prnums_skel2[]={12, ADDR, 0x23, SKIP_CALL, SKIP_CALL, SKIP_CALL, 0x14, 0x15, 0xC8, 0x0A, SKIP_CALL, 0xFE, 13};
int outc_skel3[]={11, 0x23, SKIP_CALL, SKIP_CALL, SKIP_CALL, 0x1C, 0x1D, 0xC8, 0x0A, CATCH_CALL, 0xFE, 13};
int outc_skel4[]={11, 0x23, SKIP_CALL, SKIP_CALL, SKIP_CALL, 0x14, 0x15, 0xC8, 0x0A, CATCH_CALL, 0xFE, 13};
int outc_skel5[]={6 ,0x3E, '?', CATCH_CALL, 0x3E, ' ', 0xCD};
int outc_skel6[]={11 ,0x4F, 0xF1, 0xB7, 0x28, SKIP, 0x79, 0xFE, ' ', 0xD4, CATCH, CATCH};
int numasc_skel[]={15, SKIP_CALL, CATCH_CALL, SKIP_CALL, SKIP_CALL, 1, SKIP, SKIP, 0xC5, 0x7E, 0x23, 0x23, 0xE5, SKIP_CALL, 0xE1, 0x4E};
int fpsint_skel[]={12, ADDR, SKIP_CALL, SKIP_CALL, SKIP_CALL, 0xFA, SKIP, SKIP, 0x3A, SKIP, SKIP, 0xFE, 0x91};
int fpsint_skel2[]={12, ADDR, SKIP_CALL, SKIP_CALL, SKIP_CALL, 0xFC, SKIP, SKIP, 0x3A, SKIP, SKIP, 0xFE, 0x91};
int ex_fpsint_skel[]={11, ADDR, SKIP_CALL, SKIP_CALL, 0xE5, SKIP_CALL, 0xEB, 0xE1, 0x7A, 0xB7, 0xC9};
int ex_fpsint_skel2[]={14, 0xF2, SKIP, SKIP, SKIP_CALL, 0xE3, 17, 1, 0, 0x7E, 0xFE, SKIP, 0xCC, CATCH, CATCH};
int ex_posint_skel[]={10, 0x7E, 0xFE, SKIP, 0xC0, SKIP_CALL, 0x18, SKIP, SKIP_CALL, CATCH_CALL, 0xF0};
int abpass_skel[]={11, ADDR, 0x50, 0x1E, 0, 33, SKIP, SKIP, 0x73, 6, 0x90, 0xC3};
int abpass_skel2[]={8, 0x47, ADDR, 0x50, 0x1E, 0, 6, 0x90, 0xC3};
int hlpass_skel[]={8, ADDR, 0x7C, 0x55, 0x1E, 0, 6, 0x90, 0xC3};
int atoh_skel[]={12, ADDR, 0x2B, 17, 0, 0, SKIP_CALL, 0xD0, 0xE5, 0xF5, 33, 0x98, 0x19};
int atoh_skel2[]={10, ADDR, 0x2B, 0xC5, SKIP_CALL, 0xC1, 0xD0, SKIP_CALL, 17, 0, 0};
int crtst_skel[]={10, ADDR, 0x2B, 6, 0x22, 0x50, 0xE5, 0x0E ,0xFF, 0x23, 0x7E};
int getstr_skel[]={12, ADDR, SKIP_CALL, 0x2A, SKIP, SKIP, 0xEB, SKIP_CALL, 0xEB, 0xC0, 0xD5, 0x50, 0x59};
int tststr_skel2[]={10, CATCH_CALL, 0x2A, SKIP, SKIP, 0xEB, SKIP_CALL, 0xEB, 0xC0, 0xD5};
int baktmp_skel[]={12, ADDR, 0x2A, SKIP, SKIP, 0x2B, 0x46, 0x2B, 0x4E, 0x2B, 0x2B, SKIP_CALL, 0xC0};
int baktmp_skel2[]={13, ADDR, 0x2A, SKIP, SKIP, 0x2B, 0x46, 0x2B, 0x4E, 0x2B, 0x2B, 0x7C, 0x92, 0xC0};
int tmstpt_skel3[]={11, 0x2A, CATCH, CATCH, 0x2B, 0x46, 0x2B, 0x4E, 0x2B, 0x2B, SKIP_CALL, 0xC0};
int tmstpt_skel4[]={12, 0x2A, CATCH, CATCH, 0x2B, 0x46, 0x2B, 0x4E, 0x2B, 0x2B, 0x7C, 0x92, 0xC0};
int datsnr_skel[]={15, ADDR, 0x2A, SKIP, SKIP, 0x22, SKIP, SKIP, 0x1E, 2, 1, 0x1E, SKIP, 1, 0x1E, SKIP};
int ucase_skel[]={9, ADDR, 0x7E, 0xFE, 0x61, 0xD8, 0xFE, 0x7B, 0xD0, 0xE6, 0x5F, 0xC9};
/* Later Extended BASIC versions (MSX BASIC, Otrona Attache', Triumph Adler.. */
int ttypos_skel[] ={10, 0x3A, CATCH, CATCH, 0x6F, 0xAF, 0x67, 0xC3, SKIP, SKIP, 0xCD};
int ttypos_skel2[]={11, 0x3A, CATCH, CATCH, 0x3C, 0x6F, 0xAF, 0x67, 0xC3, SKIP, SKIP, 0xCD};
int lpos_skel[] ={12, 0x3A, CATCH, CATCH, 0x18, 0x03, 0x3A, SKIP, SKIP, 0x6F, 0xAF, 0x67, 0xC3};
int lpos_skel2[]={12, 0x3A, CATCH, CATCH, 0x18, 0x03, 0x3A, SKIP, SKIP, 0x3C, 0x6F, 0xAF, 0x67};
int unsigned_a_skel[] ={10, 0x3A, SKIP, SKIP, ADDR, 0xAF, 0x67, 0xC3, SKIP, SKIP, 0xCD};
int unsigned_a_skel2[]={11, 0x3A, SKIP, SKIP, 0x3C, ADDR, 0xAF, 0x67, 0xC3, SKIP, SKIP, 0xCD};
int int_hl_skel[] ={10, 0x3A, SKIP, SKIP, 0x6F, 0xAF, 0x67, 0xC3, CATCH, CATCH, 0xCD};
int int_hl_skel2[]={11, 0x3A, SKIP, SKIP, 0x3C, 0x6F, 0xAF, 0x67, 0xC3, CATCH, CATCH, 0xCD};
int int_a_skel[]={8, 0x77, 0xC9, SKIP_CALL, ADDR, 0x17, 0x9F, 0x67, 0xC3};
int faccu_skel[]={9, 33, CATCH, CATCH, 0x7E, 0xEE, 0x80, 0x77, 0xC9, 0xCD};
int chrgtb2_skel[]={15, 0x07, 0x4F, 6, 0, 0xEB, 33, SKIP, SKIP, 9, 0x4E, 0x23, 0x46, 0xC5, 0xEB, ADDR};
int chrckb2_skel[]={13, ADDR, 0x7E, 0xFE, ':', 0xD0, 0xFE, ' ', 0x28, SKIP, 0x30, SKIP, 0xB7, 0xC8};
int newstmt_skel[]={14, 0xFE, 0x0E, 0x28, SKIP, 0xFE, 0x0D, 0xC2, SKIP, SKIP, SKIP_CALL, 1, CATCH, CATCH, 0x18};
int goto_skel[]={15, 0xFE, 0x0E, 0x28, SKIP, 0xFE, 0x0D, 0xC2, SKIP, SKIP, SKIP_CALL, 1, SKIP, SKIP, 0x18, ADDR};
int dim_skel[]={12, ADDR, ',', 1, SKIP, SKIP, 0xC5, 0xF6, 0xAF, 0x32, SKIP, SKIP, 0x4E};
/* Microsoft BASIC token extraction */
int tkmsbasic_skel[]={12, 17, CATCH, CATCH, 0x1A, 0x13, 0xB7, 0xF2, SKIP, SKIP, 0x0D, 0x20, 0xF7};
int tkmsbasic_skel2[]={15, 33, CATCH, CATCH, 0x7E, 0xB7, 0x23, 0xF2, SKIP, SKIP, 0x1D, 0xC2, SKIP, SKIP, 0xA6, 0x7F};
int tkmsbasic_skel3[]={12, 0xD5, 17, CATCH, CATCH, 0xC5, 1, SKIP, SKIP, 0xC5, 0x06, SKIP, 0x7E};
int tkmsbasic_skel4[]={12, 0xC5, 33, CATCH, CATCH, 1, SKIP, SKIP, 0x1E, 0x41, 0x56, 0xED, 0xA1};
/* Last resort attempt, we look for the text ! */
int tkmsbasic_old_skel[]={8, ADDR, 'E', 'N', 0xC4, 'F', 'O', 0xd2, 'N'};
/* Odd extended BASIC (i.e. MSX) tokens*/
int tkmsbasic_ex_skel[]={11, 33, CATCH, CATCH, 0x47, 0x0e, 0x40, 0x0C, 0x23, 0x54, 0x5D, 0x7E};
int tkrange_ex_skel[]={14, 0xD6, 129, 0xDA, SKIP, SKIP, 0xFE, CATCH, 0xD2, SKIP, SKIP, 7, 0x4F, 6, 0};
int tok_ex_skel[]={12, 0x3C, 0xCA, SKIP, SKIP, 0x3D, 0xFE, ADDR, 0x28, SKIP, 0xFE, SKIP, 0xCA};
int lnum_tokens_skel[]={11, 17, CATCH, CATCH, 0x4F, 0x1A, 0xB7, 0x28, SKIP, 0x13, 0xB9, 0x20};
int equal_tk_skel[]={8, 0xF1, 0xC6, 3, 0x18, SKIP, SKIP_CALL, SKIP_CALL, CATCH};
int using_tokens_skel[]={18, 0xFE, ADDR, 0xCA, SKIP, SKIP, 0xFE, SKIP, 0xCA, SKIP, SKIP, 0xFE, SKIP, 0xCA, SKIP, SKIP, 0xE5, 0xFE, ','};
int lnum_range_skel[]={9, 0x73, 0x23, 0x72, 0x18, ADDR, 17, 0, 0, 0xD5};
int ex_warm_skel[]={17, ADDR, 0xF9, 33, SKIP, SKIP, 0x22, SKIP, SKIP, SKIP_CALL, SKIP_CALL, 0xAF, 0x67, 0x6F, 0x22, SKIP, SKIP, 0x32};
int ex_warm_skel2[]={18, ADDR, 0xF9, 33, SKIP, SKIP, 0x22, SKIP, SKIP, SKIP_CALL, SKIP_CALL, SKIP_CALL, 0xAF, 0x67, 0x6F, 0x22, SKIP, SKIP, 0x32};
int ex_end1_skel[]={14, ADDR, 0x22, SKIP, SKIP, 33, SKIP, SKIP, 0x22, SKIP, SKIP, 33, 0xF6, 0xFF, 0xC1};
int tkmsbasic_code_skel[]={12, 0xD5, 17, SKIP, SKIP, 0xC5, 1, SKIP, SKIP, 0xC5, 0x06, CATCH, 0x7E};
int jptab_msbasic_skel[]={10, 0x07, 0x4F, 6, 0, 0xEB, 33, CATCH, CATCH, 9, 0x4E};
//int jptab_msbasic_skel[]={13, 0x07, 0x4F, 6, 0, 0xEB, 33, CATCH, CATCH, 0x09, 0x4E, 0x23, 0x46, 0xC5};
int jptab_msbasic_skel3[]={11, 17, CATCH, CATCH, 0xD4, SKIP,SKIP, 7, 0x4f, 6, 0, 0xEB};
int jptab_msbasic_skel2[]={12, 17, CATCH, CATCH, 0x07, 0x4F, 6, 0, 0xEB, 0x09, 0x4E, 0x23, 0x46};
int else_token_skel[]={13, 0x32, SKIP, SKIP,0xF1, 0xC1, 0xD1, 0xFE, CATCH, 0xF5, 0xCC, SKIP, SKIP, 0xF1};
int fnctab_msbasic_skel[]={10, 0xD5, 1, CATCH, CATCH, 9, 0x4E, 0x23, 0x66, 0x69, 0xE9};
int fnctab_msbasic_skel2[]={9, 1, CATCH, CATCH, 9, 0x4E, 0x23, 0x66, 0x69, 0xE9};
int fnctab_msbasic_skel3[]={14, 0xE5, 33, SKIP, SKIP, 0xE5, 33, CATCH, CATCH, 9, 0x4E, 0x23, 0x66, 0x69, 0xE9};
int pc6001_60_page[]={12, 33, CATCH, CATCH, 17, 0 ,0xFA, 1, SKIP, SKIP, 0xED, 0xB0, 17};
//int pc6001_page[]={11, 33, CATCH, CATCH, 17, 0 ,0xFA, 1, SKIP, SKIP, 0xED, 0xB0};
int cpdehl_skel[]={7, ADDR, 0x7C, 0x92, 0xC0, 0x7D, 0x93, 0xC9};
int cpdehl_loc_skel[]={9, 0xEB, 0x2A, SKIP, SKIP, 0x1A, 0x02, 0x03, 0x13, CATCH_CALL};
int cpdehl_loc_skel2[]={7, 0xD0, 0xE5, 0xF5, 0x21, 0x98, 0x19, CATCH_CALL};
int buffer_loc_skel[]={9, 0x21, CATCH, CATCH, 0x12, 0x13, 0x12, 0x13, 0x12, 0xC9,};
int buffer_loc_skel2[]={10, 0x21, CATCH, CATCH, 0xAF, 0x12, 0x13, 0x12, 0x13, 0x12, 0xC9,};
/* byte to signed offset conversion */
long signed_byte(long byt)
{
if (byt <128)
return (byt);
return (-256+byt);
}
/* DATA label declaration */
int dlbl(char *label, long position, char *comment) {
if (SKOOLMODE) {
printf("@ $%04x label=%s\n", position, label);
printf("D $%04x %s\n", position, comment);
} else
printf("%s \t= $%04X ; %s\n", label, position, comment);
}
/* CODE label declaration */
int clbl(char *label, long position, char *comment) {
if (SKOOLMODE) {
printf("@ $%04x label=%s\n", position, label);
printf("c $%04x %s\n", position, comment);
} else
printf("%s \t= $%04X ; %s\n", label, position, comment);
}
void clear_token () {
//sprintf (token,"");
token[0] = '\0';
token[1] = '\0';
}
void append_c(char c) {
int sl;
sl=strlen(token);
switch (c) {
case '(':
token[sl] = '_';
token[sl+1] = '\0';
break;
/*
case '$':
token[sl] = '_';
token[sl+1] = 'S';
token[sl+2] = '\0';
break;
*/
default:
token[sl] = c;
token[sl+1] = '\0';
break;
}
}
/* This is the core engine of the tool.. peep into the code, identify a known fingerprint,
and extract its position, a value, or a referred address */
int find_in_skel (int *skel, int p) {
int i, j, retval;
retval = -2;
i = p;
for (j=1; j<=l; j++) {
if (skel[j] == CATCH) {
retval = img[j+i];
if(skel[j+1] == CATCH) {
retval += 256 * img[i+j+1];
j++;}
} else {
if (skel[j] != SKIP)
if (skel[j] == ADDR)
retval=j+i;
else
if ((skel[j] == CATCH_CALL) || (skel[j] == SKIP_CALL))
switch (img[j+i]) {
case 0xC7: /* RST 0 */
case 0xCF: /* RST 8 */
case 0xD7: /* RST 10 */
case 0xDF: /* RST 18 */
case 0xE7: /* RST 20 */
case 0xEF: /* RST 28 */
case 0xF7: /* RST 30 */
case 0xFF: /* RST 38 */
if (skel[j] == CATCH_CALL)
retval = img[j+i] & 0x38;
break;
case 0xCD:
i++;
if (skel[j] == CATCH_CALL)
retval = img[i+j] + 256 * img[i+j+1];
i++;
break;
default:
return (-1);
break;
} else if (skel[j] == SKIP_JP_RET)
switch (img[j+i]) {
case 0xC9: /* RET */
break;
case 0xC3: /* JP nn */
i++;
i++;
break;
case 0x18: /* JR n */
i++;
break;
} else if (img[j+i] != skel[j]) return (-1);
}
}
return (retval);
}
int find_skel (int *skel) {
int i,retval;
l=skel[0];
for (i=0; i<(len-l);i++) {
retval=find_in_skel (skel, i);
if (retval >= 0)
return (retval);
}
return (-1);
}
int zx81char(int c) {
int a;
switch (c) {
case 11:
a='"';
break;
case 13:
a='$';
break;
case 15:
a='?';
break;
case 18:
a='>';
break;
case 19:
a='<';
break;
case 20:
a='=';
break;
case 23:
a='*';
break;
case 27:
a='.';
break;
default:
a=c+27;
break;
}
return (a);
}
int main(int argc, char *argv[])
{
FILE *fpin;
int c, chr;
int i;
long res, res2, res3;
int token_range;
int brand;
int new_tk_found;
if (argc !=3) {
printf("USAGE:\n");
printf("basck <-ctl|-map> basic.bin\n");
exit(1);
}
if (!strcmp(argv[1], "-ctl"))
SKOOLMODE=1;
if (!strcmp(argv[1], "-map"))
SKOOLMODE=0;
if ( (fpin=fopen(argv[2],"rb") ) == NULL ) {
printf("Can't open input file\n");
exit(1);
}
if (SKOOLMODE<0) {
printf("Invalid parameter. Usage:\n");
printf("basck <-ctl|-map> basic.bin\n");
exit(1);
}
/*
* Now we try to determine the size of the file
* to be converted
*/
if (fseek(fpin,0,SEEK_END)) {
printf("Couldn't determine size of file\n");
fclose(fpin);
exit(1);
}
len=ftell(fpin);
fseek(fpin,0L,SEEK_SET);
/* We add 64K to prevent overflows in the token decoding tricks */
img=malloc(len*sizeof(unsigned char)+65536);
/* We load the binary file */
for (i=0; i<len;i++) {
img[i]=getc(fpin);
}
printf("\n# File size: %d\n",i);
res=find_skel(ldir_skel);
if (res<0)
res=find_skel(ldir_skel2);
if (res>0)
printf("\n# Specific Z80 CPU code detected\n\n");
/***********************************/
/* Microsoft BASIC related section */
/***********************************/
res=find_skel(restore_bastxt_skel);
if (res<0)
res=find_skel(bastxt_skel);
if (res<0)
res=find_skel(bastxt_skel2);
if (res<0) {
res=find_skel(errtab_skel);
if (res>0) res =0xFFFF;
}
if (res>0) {
printf("\n# Microsoft 8080/Z80 BASIC found\n");
brand=find_skel(tkmsbasic_ex_skel);
if (brand<0)
printf("# Extended BASIC detected\n");
else {
brand=find_skel(microsoft_extended_skel);
if (brand>0)
printf("# Extended syntax detected (classic version)\n");
else printf("# Earlier version\n");
}
brand=find_skel(microsoft_defdbl_skel);
if (brand<0)
brand=find_skel(microsoft_defdbl_skel2);
if (brand<0)
brand=find_skel(microsoft_defdbl_skel3);
if (brand>0)
printf("# Double precision maths detected\n");
brand=find_skel(microsoft_skel);
if (brand>0)
printf("# Microsoft signature found\n");
else printf("# Microsoft signature not found\n");
printf("\n");
/* We refer to a common ROM subroutine to determine the correct code position */
printf("\n");
dlbl("BASTXT", res, "BASIC program start ptr (aka TXTTAB)");
printf("\n");
pos=find_skel(cpdehl_skel);
if (pos>0) {
printf ("\n# CPDEHL (compare DE and HL), code found at $%04X", pos);
/* Canon X-07 hack */
if (pos==0x3E44) {
pos=0xB000;
printf("\n# (Canon X-07 hack.. shifting to position $%04X, *work in progress*)",pos);
}
else {
res=find_skel(cpdehl_loc_skel);
if (res<0)
res=find_skel(cpdehl_loc_skel2);
if (res>0) {
pos=res-pos-1;
if (pos>=0) {
if (pos==8434) {
printf("\n# ...patching MS SoftCard HR GBASIC, gap size: $%04X",pos-256);
pos=256;
}
printf("\n# (Detected position for ORG: %d)",pos);
}
else pos=0;
} else pos=0;
}
}
res=find_skel(tstsgn_skel);
if (res<0)
res=find_skel(tstsgn_skel2);
if (res<0)
res=find_skel(tstsgn_skel3);
pos2=find_skel(tstsgn_loc_skel);
if (pos2<0)
pos2=find_skel(tstsgn_loc_skel);
if ((res>0) && (pos2>0)) {
pos=pos2-res-1;
printf("\n# (Detected position basing on TSTSGN: %d)",pos);
//pos=-pos;
}
res=find_skel(dvbcde_skel);
pos2=find_skel(dvbcde_org_skel);
if ((res>0) && (pos2>0)) {
pos=pos2-res+1;
if (pos <0)
pos=res-pos2+1; // probably wrong
printf("\n# (Detected position basing on DVBCDE: %d)",pos);
}
if (pos==-1) pos=0;
printf("\n\n");
res=find_skel(inport_skel);
if (res<0)
res=find_skel(inport_skel2);
if (res<0)
res=find_skel(inport_skel3);
if (res>0)
dlbl("INPORT", res, "Current port for 'INP' function");
res=find_skel(otport_skel);
if (res<0)
res=find_skel(otport_skel2);
if (res<0)
res=find_skel(otport_skel3);
if (res>0)
dlbl("OTPORT", res, "Current port for 'OUT' statement");
res=find_skel(ms_rnd_seed);
if (res>0)
dlbl("SEED", res+2, "Seed for RND numbers");
res=find_skel(ms_lstrnd);
if (res<0)
res=find_skel(ms_lstrnd2);
if (res>0)
dlbl("LSTRND2", res+2, "Last RND number");
res=find_skel(buffer_loc_skel);
if (res<0)
res=find_skel(buffer_loc_skel2);
if (res>0)
dlbl("BUFFER", res, "Start of input buffer");
res=find_skel(tmstpt_skel);
if (res<0)
res=find_skel(tmstpt_skel2);
if (res<0)
res=find_skel(tmstpt_skel3);
if (res<0)
res=find_skel(tmstpt_skel4);
if (res>0)
dlbl("TMSTPT", res, "Temporary string pool pointer");
res=find_skel(tmpstr_skel);
if (res<0)
res=find_skel(tmpstr_skel2);
if (res<0)
res=find_skel(tmpstr_skel3);
if (res>0)
dlbl("TMPSTR", res, "Temporary string");
res=find_skel(nxtopr_skel);
if (res<0)
res=find_skel(nxtopr_skel2);
if (res>0)
dlbl("NXTOPR", res, "Address ptr to next operator");
res=find_skel(curpos_skel);
if (res<0)
res=find_skel(curpos_skel2);
if (res<0)
res=find_skel(ttypos_skel); /* Extended Basic versions..*/
if (res<0)
res=find_skel(ttypos_skel2);
if (res>0)
dlbl("CURPOS", res, "Character position on line (TTYPOS on Ext. Basic)");
res=find_skel(lpos_skel); /* Extended Basic versions..*/
if (res<0)
res=find_skel(lpos_skel2);
if (res>0)
dlbl("LPTPOS", res, "Character position on printer");
res=find_skel(prognd_skel);
if (res<0)
res=find_skel(prognd_skel2);
if (res>0)
dlbl("PROGND", res, "BASIC program end ptr (aka VARTAB)");
res=find_skel(varend_skel);
if (res<0)
res=find_skel(varend_skel2);
if (res>0)
dlbl("VAREND", res, "End of variables");
res=find_skel(arrend_skel);
if (res<0)
res=find_skel(arrend_skel2);
if (res<0)
res=find_skel(arrend_skel3);
if (res>0)
dlbl("ARREND", res, "End of arrays (lowest free mem)");
res=find_skel(sgnres_skel);
if (res>0)
dlbl("SGNRES", res, "Sign of result");
res=find_skel(ex_warm_skel);
if (res>0) {
dlbl("TEMPST", img[res+3] + 256*img[res+4], "(word), temporary descriptors");
dlbl("TEMPPT", img[res+6] + 256*img[res+7], "(word), start of free area of temporary descriptor");
//
dlbl("PRMLEN", img[res+18] + 256*img[res+19], "(word), number of bytes of obj table");
dlbl("NOFUNS", img[res+21] + 256*img[res+22], "(byte), 0 if no function active");
dlbl("PRMLN2", img[res+24] + 256*img[res+25], "(word), size of parameter block");
dlbl("FUNACT", img[res+27] + 256*img[res+28], "(word), active functions counter");
dlbl("PRMSTK", img[res+30] + 256*img[res+31], "(word), previous block definition on stack");
dlbl("SUBFLG", img[res+33] + 256*img[res+34], "(byte), flag for USR fn. array");
dlbl("TEMP", img[res+38] + 256*img[res+39], "(word) temp. reservation for st.code");
}
res=find_skel(ex_warm_skel2);
if (res>0) {
dlbl("TEMPST", img[res+3] + 256*img[res+4], "(word), temporary descriptors");
dlbl("TEMPPT", img[res+6] + 256*img[res+7], "(word), start of free area of temporary descriptor");
//
dlbl("PRMLEN", img[res+21] + 256*img[res+22], "(word), number of bytes of obj table");
dlbl("NOFUNS", img[res+24] + 256*img[res+25], "(byte), 0 if no function active");
dlbl("PRMLN2", img[res+27] + 256*img[res+28], "(word), size of parameter block");
dlbl("FUNACT", img[res+30] + 256*img[res+31], "(word), active functions counter");
dlbl("PRMSTK", img[res+33] + 256*img[res+34], "(word), previous block definition on stack");
dlbl("SUBFLG", img[res+36] + 256*img[res+37], "(byte), flag for USR fn. array");
dlbl("TEMP", img[res+41] + 256*img[res+42], "(word) temp. reservation for st.code");
}
res=find_skel(eval3_body_skel);
if (res>0) {
dlbl("VALTYP", img[res+2] + 256*img[res+3], "(word) type indicator");
dlbl("PRITAB", img[res+14] + 256*img[res+15], "(word) Arithmetic precedence table");
}
res=find_skel(eval3_ex_skel);
if (res>0) {
dlbl("TEMP2", img[res+2] + 256*img[res+3], "(word) temp. storage used by EVAL");
dlbl("TEMP3", img[res+7] + 256*img[res+8], "(word) used for garbage collection or by USR function");
}
res=find_skel(ex_end1_skel);
if (res>0) {
dlbl("SAVTXT", img[res+2] + 256*img[res+3], "(word), prg pointer for resume");
dlbl("TEMPST", img[res+5] + 256*img[res+6], "(word), temporary descriptors");
dlbl("TEMPPT", img[res+8] + 256*img[res+9], "(word), start of free area of temporary descriptor");
//
dlbl("CURLIN", img[res+15] + 256*img[res+16], "(word), line number being interpreted");
//
dlbl("OLDLIN", img[res+25] + 256*img[res+26], "(word), old line number set up ^C ...");
dlbl("SAVTXT", img[res+28] + 256*img[res+29], "(word), prg pointer for resume");
dlbl("OLDTXT", img[res+31] + 256*img[res+32], "(word), prg pointer for CONT");
}
printf("\n");
res=find_skel(log10eval_skel);
if (res>0)
clbl("FP_LOG10E", res+pos+1, "Constant ptr for LOG(e)");
res=find_skel(halfpival_skel);
if (res>0)
clbl("FP_HALFPI", res+pos+1, "Half PI constant ptr");
else {
res=find_skel(halfpi_skel);
if (res<0)
res=find_skel(halfpi_skel2);
if (res<0)
res=find_skel(halfpi_skel3);
if (res>0)
dlbl("HALFPI", res, "Half PI constant ptr");
}
res=find_skel(halfval_skel);
if (res>0) {
clbl("FP_HALF", res+pos+1, "Constant ptr for 0.5 in FP");
clbl("FP_ZERO", res+pos+3, "Constant ptr for 'zero' in FP");
} else {
res=find_skel(half_skel);
if (res<0)
res=find_skel(half_skel2);
if (res<0)
res=find_skel(half_skel3);
if (res<0)
res=find_skel(half_skel4);
if (res>0)
dlbl("HALF", res, "Constant ptr for 0.5 in FP");
}
res=find_skel(unityval_skel);
if (res>0) {
clbl("FP_UNITY", res+pos+1, "Constant ptr for 1 in FP");
} else {
res=find_skel(unity_skel);
if (res>0)
dlbl("UNITY", res, "Constant ptr for number 1 in FP");
}
res=find_skel(quarterval_skel);
if (res>0)
clbl("FP_QUARTER", res+pos+1, "Constant ptr for 0.25 in FP");
res=find_skel(tenhalfval_skel);
if (res>0)
clbl("FP_10EXHALF", res+pos+1, "Constant ptr for 10^(1/2) in FP");
res=find_skel(twoln10val_skel);
if (res>0)
clbl("FP_TWODLN10", res+pos+1, "Constant ptr for 2/LN(10) in FP");
res=find_skel(ln10val_skel);
if (res>0)
clbl("FP_LN10", res+pos+1, "Constant ptr for LN(10) in FP");
res=find_skel(tan15val_skel);
if (res>0)
clbl("FP_TAN15", res+pos+1, "Constant ptr for TAN(15) in FP");
res=find_skel(sqr3val_skel);
if (res>0)
clbl("FP_SQR3", res+pos+1, "Constant ptr for SQR(3) in FP");
res=find_skel(sixthpival_skel);
if (res>0)
clbl("FP_SIXTHPI", res+pos+1, "Constant ptr for PI/6 in FP");
res=find_skel(epsilonval_skel);
if (res>0) {
clbl("FP_EPSILON", res+pos+1, "Epsilon constant ptr");
if (img[res+9]==4)
clbl("FP_EXPTAB1", res+pos+9, "Ptr to first exponent table");
if (img[res+42]==3)
clbl("FP_EXPTAB2", res+pos+42, "Ptr to second exponent table");
}
res=find_skel(logtab_skel);
if (res>0)
dlbl("LOGTAB", res, "Table used by LOG");
else {
res=find_skel(logtabval_skel);
if (res>0)
clbl("FP_LOGTAB", res+pos+1, "First table used by LOG");
if (img[res+34]==5)
clbl("FP_LOGTAB2", res+pos+34, "Second table used by LOG");
}
res=find_skel(sintabval_skel);
if (res>0)
clbl("FP_SINTAB", res+pos+1, "Table used by SIN/COS/TAN");
res=find_skel(atntabval_skel);
if (res>0)
clbl("FP_ATNTAB", res+pos+1, "Table used by ATN/TAN");
printf("\n");
res=find_skel(fpreg_skel);
if (res<0)
res=find_skel(fpreg_skel2);
if (res<0)
res=find_skel(fpreg_skel3);
if (res<0)
res=find_skel(fpreg_skel4);
if (res>0)
dlbl("FPREG", res, "Floating Point Register (FACCU, FACLOW on Ext. BASIC)");
res=find_skel(last_fpreg_skel);
if (res<0)
res=find_skel(last_fpreg_skel2);
if (res>0)
dlbl("LAST_FPREG", res, "Last byte in Single Precision FP Register (+sign bit)");
res=find_skel(fpexp_skel);
if (res<0)
res=find_skel(fpexp_skel2);
if (res>0)
dlbl("FPEXP", res, "Floating Point Exponent");
res=find_skel(dblfpreg_skel);
if (res>0)
dlbl("DBL_FPREG", res, "Double Precision Floating Point Register (aka FACLOW)");
res=find_skel(dbllast_fpreg_skel);
if (res>0)
dlbl("DBL_LAST_FPREG", res, "Last byte in Double Precision FP register (+sign bit)");
printf("\n");
res=find_skel(cpdehl_skel);
if (res>0)
clbl("CPDEHL", res+pos+1, "compare DE and HL");
res=find_skel(fndnum_skel);
if (res<0)
res=find_skel(fndnum_skel2);
if (res<0)
res=find_skel(fndnum_skel3);
if (res>0)
clbl("FNDNUM", res+pos+1, "Load 'A' with the next number in BASIC program");
res=find_skel(getint_skel);
if (res<0)
res=find_skel(getint_skel2);
if (res<0)
res=find_skel(getint_skel3);
if (res<0)
res=find_skel(getint_skel4);
if (res<0)
res=find_skel(getint_skel5);
if (res<0)
res=find_skel(getint_skel6);
if (res>0)
clbl("GETINT", res, "Get a number to 'A'");
res=find_skel(getword_skel);
if (res>0)
clbl("GETWORD", res, "Get a number to DE (0..65535)");
res=find_skel(depint_skel);
if (res<0)
res=find_skel(depint_skel2);
if (res<0)
res=find_skel(depint_skel3);
if (res>0)
clbl("DEPINT", res, "Get integer variable to DE, error if negative");
res=find_skel(fpsint_skel);
if (res<0)
res=find_skel(fpsint_skel2);
if (res>0) {
clbl("FPSINT", res+pos+1, "Get subscript (0-32767)");
clbl("POSINT", res+pos+4, "Get integer 0 to 32767");
clbl("DEINT", res+pos+13, "Get integer variable (-32768 to 32767) to DE");
}
res=find_skel(ex_fpsint_skel);
if (res>0) {
clbl("FPSINT", res+pos+1, "Get subscript");
} else {
res=find_skel(ex_fpsint_skel2);
if (res>0)
clbl("FPSINT", res, "Get subscript");
}
res=find_skel(ex_posint_skel);
if (res>0)
clbl("POSINT", res, "Get positive integer");
res=find_skel(getvar_skel);
if (res<0)
res=find_skel(getvar_skel2);
if (res>0)
clbl("GETVAR", res, "Get variable address to DE");
res=find_skel(dim_skel);
if (res>0)
clbl("DIM", res+pos+2, "DIM command");
res=find_skel(chkstk_skel);
if (res>0)
clbl("CHKSTK", res, "Check for C levels of stack");
else {
res=find_skel(chkstk_skel2);
if (res>0)
clbl("CHKSTK", res+pos+1, "Check for C levels of stack");
}
res=find_skel(oprnd_skel);
if (res<0)
res=find_skel(oprnd_skel2);
if (res>0)
clbl("OPRND", res, "Get next expression value");
res=find_skel(chksyn_skel);
if (res<0)
res=find_skel(chksyn_skel2);
if (res<0)
res=find_skel(chksyn_skel3);
if (res>0)
clbl("SYNCHR", res, "Check syntax, 1 byte follows to be compared");
res=find_skel(lfrgnm_skel);
if (res<0)
res=find_skel(lfrgnm_skel2);
if (res>0)
clbl("LFRGNM", res+pos+1, "number in program listing and check for ending ')'");
res=find_skel(abpass_skel);
if (res<0)
res=find_skel(abpass_skel2);
if (res>0)
clbl("ABPASS", res+pos+2, "Get back from function passing an INT value in A+B registers");
res=find_skel(hlpass_skel);
if (res>0)
clbl("HLPASS", res+pos+1, "Get back from function passing an INT value HL");
res=find_skel(midnum_skel);
if (res>0)
clbl("MIDNUM", res+pos, "Get number in program listing");
res=find_skel(int_a_skel);
if (res>0)
clbl("INT_RESULT_A", res+pos, "Get back from function, result in A (signed)");
res=find_skel(int_hl_skel);
if (res<0)
res=find_skel(int_hl_skel2);
if (res>0)
clbl("INT_RESULT_HL", res, "Get back from function, result in HL");
res=find_skel(unsigned_a_skel);
if (res<0)
res=find_skel(unsigned_a_skel2);
if (res>0)
clbl("UNSIGNED_RES_A", res+pos, "Get back from function, result in A");
printf("\n");
res=find_skel(test_type_skel);
if (res>0)
clbl("GETYPR", res, "Test number FAC type (Precision mode, etc..)");
res=find_skel(tstsgn_skel);
if (res<0)
res=find_skel(tstsgn_skel2);
if (res<0)
res=find_skel(tstsgn_skel3);
if (res>0)
clbl("TSTSGN", res+pos+1, "Test sign of FPREG");
res=find_skel(dbl_tstsgn_skel);
if (res<0)
res=find_skel(dbl_tstsgn_skel2);
if (res<0)
res=find_skel(dbl_tstsgn_skel3);
if (res>0)
clbl("_TSTSGN", res, "Test sign in number");
res=find_skel(invsgn_skel);
if (res<0)
res=find_skel(invsgn_skel2);
if (res>0)
clbl("INVSGN", res, "Invert number sign");
res=find_skel(stakfp_skel);
if (res>0) {
clbl("STAKFP", res+pos+1, "Put FP value on stack");
}
res=find_skel(negaft_skel);
if (res<0)
res=find_skel(negaft_skel2);
if (res>0)
clbl("NEGAFT", res, "Negate number");
res=find_skel(log_skel);
if (res<0)
res=find_skel(log_skel2);
if (res<0)
res=find_skel(log_skel3);
if (res<0)
res=find_skel(log_skel4);
if (res<0)
res=find_skel(log_skel5);
if (res<0)
res=find_skel(log_skel6);
if (res>0)
clbl("LOG", res+pos+1, "LOG");
res=find_skel(sqr_skel);
if (res<0)
res=find_skel(sqr_skel2);
if (res<0)
res=find_skel(sqr_skel3);
if (res<0)
res=find_skel(sqr_skel4);
if (res<0)
res=find_skel(sqr_skel5);
if (res>0)
clbl("SQR", res+pos+1, "SQR");
res=find_skel(power_skel);
if (res<0)
res=find_skel(power_skel2);
if (res<0)
res=find_skel(power_skel3);
if (res<0)
res=find_skel(power_skel4);
if (res>0)
clbl("POWER", res+pos+1, "POWER");
res=find_skel(exp_skel);
if (res>0)
clbl("EXP",res+pos+1, "EXP");
res=find_skel(cos_skel);
if (res<0)
res=find_skel(cos_skel3);
if (res<0)
res=find_skel(cos_skel4);
if (res>0)
clbl("COS", res+pos, "COS");
res=find_skel(sin_skel);
if (res<0)
res=find_skel(sin_skel3);
if (res<0)
res=find_skel(sin_skel4);
if (res>0)
clbl("SIN", res+pos, "SIN");
res=find_skel(tan_skel);
if (res<0)
res=find_skel(tan_skel2);
if (res<0)
res=find_skel(tan_skel3);
if (res>0)
clbl("TAN", res+pos+1, "TAN");
res=find_skel(atn_skel);
if (res<0)
res=find_skel(atn_skel2);
if (res>0)
clbl("ATN", res+pos+1, "ATN");
res=find_skel(abs_skel);
if (res<0)
res=find_skel(abs_skel2);
if (res<0)
res=find_skel(abs_skel3);
if (res>0)
clbl("ABS", res+pos+1, "ATN");
res=find_skel(dblabs_skel);
if (res>0)
clbl("DBL_ABS", res, "ABS (double precision BASIC variant)");
else {
res=find_skel(dblabs_skel2);
if (res>0)
clbl("DBL_ABS", res+pos+1, "ABS (double precision BASIC variant)");
}
res=find_skel(ms_rnd_skel);
if (res<0)
res=find_skel(ms_rnd_skel2);
if (res>0)
clbl("RND", res+pos+1, "RND");
res=find_skel(fpadd_skel);
if (res<0)
res=find_skel(fpadd_skel2);
if (res>0) {
clbl("SUBCDE",res+pos+1-3, "Subtract BCDE from FP reg");
clbl("FPADD", res+pos+1, "Add BCDE to FP reg");
}
else {
res=find_skel(fpadd_skel3);
if (res<0)
res=find_skel(fpadd_skel4);
if (res>0) {
clbl("SUBCDE",res-3, "Subtract BCDE from FP reg");
clbl("FPADD", res, "Add BCDE to FP reg");
}
}
res=find_skel(bnorm_skel);
if (res<0)
res=find_skel(bnorm_skel2);
if (res>0)
clbl("BNORM", res+pos+1, "Normalise number");
res=find_skel(scale_skel);
if (res<0)
res=find_skel(scale_skel2);
if (res>0)
clbl("SCALE", res+pos+1, "Scale number in BCDE for A exponent (bits)");
res=find_skel(plucde_skel);
if (res>0)
clbl("PLUCDE", res+pos+1, "Add number pointed by HL to CDE");
res=find_skel(compl_skel);
if (res>0)
clbl("COMPL", res+pos+1, "Convert a negative number to positive");
res=find_skel(fpthl_skel);
if (res>0)
clbl("FPTHL", res+pos+1, "Copy number in FPREG to HL ptr");
else {
res=find_skel(fpthl_skel2);
if (res<0)
res=find_skel(fpthl_skel3);
if (res>0)
clbl("FPTHL", res, "Copy number in FPREG to HL ptr");
}
res=find_skel(fpbcde_skel);
if (res>0) {
clbl("PHLTFP", res+pos+1, "Number at HL to BCDE");
clbl("FPBCDE", res+pos+4, "Move BCDE to FPREG");
} else {
res=find_skel(fpbcde_skel2);
if (res<0)
res=find_skel(fpbcde_skel3);
if (res<0)
res=find_skel(fpbcde_skel4);
if (res>0)
clbl("FPBCDE", res, "Move BCDE to FPREG");
res=find_skel(phltfp_skel);
if (res<0)
res=find_skel(phltfp_skel2);
if (res<0)
res=find_skel(phltfp_skel3);
if (res<0)
res=find_skel(phltfp_skel4);
if (res<0)
res=find_skel(phltfp_skel5);
if (res<0)
res=find_skel(phltfp_skel6);
if (res>0)
clbl("PHLTFP", res, "Number at HL to BCDE");
}
res=find_skel(addphl_skel);
if (res<0)
res=find_skel(addphl_skel2);
if (res<0)
res=find_skel(addphl_skel3);
if (res>0)
clbl("ADDPHL", res, "ADD number at HL to BCDE");
res=find_skel(subphl_skel);
if (res>0)
clbl("SUBPHL", res, "SUBTRACT number at HL from BCDE");
res=find_skel(mlsp10_skel);
if (res<0)
res=find_skel(mlsp10_skel2);
if (res>0)
clbl("MLSP10", res+pos+1, "Multiply number in FPREG by 10");
res=find_skel(fpmult_skel);
if (res>0)
clbl("FPMULT", res, "Multiply BCDE to FP reg");
res=find_skel(div10_skel);
if (res<0)
res=find_skel(div10_skel2);
if (res<0)
res=find_skel(div10_skel3);
if (res<0)
res=find_skel(div10_skel4);
if (res<0)
res=find_skel(div10_skel5);
if (res>0)
clbl("DIV10", res+pos+1, "Divide FP by 10");
res=find_skel(div_skel);
if (res>0)
clbl("DIV", res, "Divide FP by number on stack");
else {
res=find_skel(div_skel2);
if (res>0)
clbl("DIV", res+pos+1, "Divide FP by number on stack");
}
res=find_skel(dvbcde_org_skel);
if (res>0)
clbl("DVBCDE", res+pos+1, "Divide FP by BCDE");
else {
res=find_skel(dvbcde_skel);
if (res>0)
clbl("DVBCDE", res, "Divide FP by BCDE");
}
res=find_skel(dcbde_skel);
if (res>0)
clbl("DCBCDE", res+pos+1, "Decrement FP value in BCDE");
res=find_skel(bcdefp_skel);
if (res>0) {
clbl("BCDEFP", res+pos+1, "Load FP reg to BCDE");
}
res=find_skel(loadfp_skel);
if (res>0)
clbl("LOADFP", res+pos+1, "Load FP value pointed by HL to BCDE");
res=find_skel(shrite_skel);
if (res>0)
clbl("SHRITE", res, "Shift right number in BCDE");
else {
res=find_skel(shrite_skel2);
if (res>0)
clbl("SHRITE", res+pos+1, "Shift right number in BCDE");
}
res=find_skel(cmpnum_skel);
if (res>0)
clbl("CMPNUM", res, "Compare FP reg to BCDE");
res=find_skel(fpint_skel);
if (res>0)
clbl("FPINT", res, "Floating Point to Integer");
res=find_skel(flgrel_skel);
if (res>0)
clbl("FLGREL", res+pos+1, "CY and A to FP, & normalise");
res=find_skel(sumser_skel);
if (res>0)
clbl("SUMSER", res, "Evaluate sum of series");
res=find_skel(int_skel);
if (res>0)
clbl("INT", res+pos+1, "INT");
res=find_skel(dblint_skel);
if (res<0)
res=find_skel(dblint_skel2);
if (res>0)
clbl("DBL_INT", res+pos+1, "INT (double precision BASIC variant)");
res=find_skel(dblsub_skel);
if (res>0)
clbl("DBL_SUB", res+pos+1, "Double precision SUB (formerly SUBCDE)");
res=find_skel(dbladd_skel);
if (res>0)
clbl("DBL_ADD", res+pos+1, "Double precision ADD (formerly FPADD)");
res=find_skel(dblsub_skel2);
if (res>0) {
clbl("DBL_SUB", res+pos+1, "Double precision SUB (formerly SUBCDE)");
clbl("DBL_ADD", res+pos+7, "Double precision ADD (formerly FPADD)");
}
res=find_skel(dblmul_skel);
if (res>0)
clbl("DBL_MUL", res+pos+1, "Double precision MULTIPLY");
res=find_skel(dbldiv_skel);
if (res>0)
clbl("DBL_DIV", res, "Double precision DIVIDE");
else {
res=find_skel(dbldiv_skel2);
if (res>0)
clbl("DBL_DIV", res+pos+1, "Double precision DIVIDE");
}
res=find_skel(fix_skel);
if (res>0)
clbl("FIX", res+pos+1, "Double Precision to Integer conversion");
res=find_skel(intmul_skel);
if (res>0)
clbl("INT_MUL", res+pos+1, "Integer MULTIPLY");
res=find_skel(mldebc_skel);
if (res<0)
res=find_skel(mldebc_skel2);
if (res>0)
clbl("MLDEBC", res, "Multiply DE by BC");
else {
res=find_skel(mldebc_skel3);
if (res>0)
clbl("MLDEBC", res+pos+1, "Multiply DE by BC");
}
res=find_skel(asctfp_skel);
if (res<0)
res=find_skel(asctfp_skel2);
if (res>0)
clbl("_ASCTFP", res+pos+1, "ASCII to FP number");
res=find_skel(hex_asctfp_skel);
if (res<0)
res=find_skel(hex_asctfp_skel2);
if (res>0)
clbl("H_ASCTFP", res+pos+1, "ASCII to FP number (also '&' prefixes)");
res=find_skel(hextfp_skel);
if (res>0)
clbl("HEXTFP", res+pos+1, "HEX(ASCII) to FP number");
res=find_skel(dblasctfp_skel);
if (res>0) {
clbl("ASCTFP", res+pos+8, "ASCII to FP number (New version)");
clbl("DBL_ASCTFP", res+pos+1, "ASCII to Double precision FP number");
} else {
res=find_skel(dblasctfp_skel2);
if (res>0)
clbl("DBL_ASCTFP", res+pos+1, "ASCII to Double precision FP number");
}
res=find_skel(prnthl_skel);
if (res<0)
res=find_skel(prnthl_skel2);
if (res<0)
res=find_skel(prnthl_skel3);
if (res>0)
clbl("PRNTHL", res+pos+1, "Print number in HL");
res=find_skel(prs_skel);
if (res<0)
res=find_skel(prs_skel2);
if (res<0)
res=find_skel(prs_skel3);
if (res>0) {
clbl("PRNUMS", res-1, "Print number string");
clbl("PRS", res, "Create string entry and print it");
clbl("PRS1", res+3, "Print string at HL");
} else {
res=find_skel(prnums_skel);
if (res<0)
res=find_skel(prnums_skel2);
if (res>0) {
clbl("PRNUMS", res+pos+1, "Print number string");
clbl("PRS", res+pos+2, "Create string entry and print it");
clbl("PRS1", res+pos+5, "Print string at HL");
}
}
res=find_skel(str_skel);
if (res<0)
res=find_skel(str_skel2);
if (res>0)
clbl("STR", res+pos+1, "STR BASIC function entry");
res=find_skel(savstr_skel);
if (res<0)
res=find_skel(savstr_skel2);
if (res>0)
clbl("SAVSTR", res+pos+1, "Save string in string area");
res=find_skel(mktmst_skel);
if (res>0) {
clbl("MKTMST", res+pos+1, "Make temporary string");
clbl("CRTMST", res+pos+1+3, "Create temporary string entry");
}
else {
res=find_skel(mktmst_skel2);
if (res>0) {
clbl("MKTMST", res, "Make temporary string");
clbl("CRTMST", res+3, "Create temporary string entry");
} else {
res=find_skel(mktmst2_skel);
if (res>0) {
clbl("MKTMST", res, "Make temporary string");
clbl("CRTMST", res+3, "Create temporary string entry");
}
}
}
res=find_skel(sstsa_skel);
if (res>0) {
clbl("SSTSA", res, "Move string on stack to string area");
}
res=find_skel(tostra_skel);
if (res>0) {
clbl("TOSTRA", res+pos, "Move string in BC, (len in L) to string area");
clbl("TSALP", res+pos+1, "TOSTRA loop");
}
res=find_skel(for_skel);
if (res<0)
res=find_skel(for_skel2);
if (res<0)
res=find_skel(for_skel3);
if (res<0)
res=find_skel(for_skel4);
if (res>0)
clbl("FOR", res+pos+1, "'FOR' BASIC instruction");
res=find_skel(fdtlp_skel);
if (res<0)
res=find_skel(fdtlp_skel2);
if (res<0)
res=find_skel(fdtlp_skel3);
if (res>0)
clbl("FDTLP", res+pos+1, "Find next DATA statement");
res=find_skel(data_skel);
if (res<0)
res=find_skel(data_skel2);
if (res<0)
res=find_skel(data_skel3);
if (res>0)
clbl("DATA", res, "DATA statement: find next DATA program line..");
res=find_skel(restore_skel);
if (res>0)
clbl("RESTOR", res+pos+1, "'RESTORE' stmt, init ptr to DATA program line..");
res=find_skel(new_skel);
if (res<0)
res=find_skel(new_skel2);
if (res<0)
res=find_skel(new_skel3);
if (res>0)
clbl("NEW", res+pos+1, "'NEW' statement");
res=find_skel(newstmt_skel);
if (res>0)
clbl("NEW_STMT", res+pos+1, "Interprete next statement");
res=find_skel(goto_skel);
if (res>0) {
res=signed_byte(img[res])+res;
clbl("GO_TO", res+pos+1, "Go To..");
}
res=find_skel(chr_skel);
if (res>0)
clbl("CHR", res+pos+1, "CHR$ BASIC function");
res=find_skel(makint_skel);
if (res<0)
res=find_skel(makint_skel2);
if (res<0)
res=find_skel(makint_skel3);
if (res<0)
res=find_skel(makint_skel4);
if (res>0)
clbl("MAKINT", res, "Convert tmp string to int in A register");
res=find_skel(concat_skel);
if (res>0)
clbl("CONCAT", res+pos+1, "String concatenation");
res=find_skel(testr_skel);
if (res<0)
res=find_skel(testr_skel2);
if (res<0)
res=find_skel(testr_skel3);
if (res>0)
clbl("TESTR", res, "Test if enough room for string");
res=find_skel(topool_skel);
if (res<0)
res=find_skel(topool_skel2);
if (res>0)
clbl("TOPOOL", res, "Save in string pool");
res=find_skel(tstopl_skel);
if (res<0)
res=find_skel(tstopl_skel2);
if (res>0)
clbl("TSTOPL", res+pos+1, "Temporary string to pool");
else {
res=find_skel(tstopl_skel3);
if (res<0)
res=find_skel(tstopl_skel4);
if (res>0)
clbl("TSTOPL", res, "Temporary string to pool");
}
res=find_skel(opnpar_skel);
if (res>0)
clbl("OPNPAR", res+pos+1, "Chk Syntax, make sure '(' follows");
res=find_skel(eval_skel);
if (res>0) {
clbl("EVAL", res+pos+1, "a.k.a. GETNUM, evaluate expression");
clbl("EVAL1", res+pos+1+3, "Save precedence and eval until precedence break");
clbl("EVAL2", res+pos+1+12, "Evaluate expression until precedence break");
clbl("EVAL3", res+pos+1+15, "Evaluate expression until precedence break");
}
res=find_skel(eval_skel2);
if (res>0) {
clbl("EVAL", res+pos+1, "a.k.a. GETNUM, evaluate expression");
clbl("EVAL1", res+pos+1+3, "Save precedence and eval until precedence break");
clbl("EVAL2", res+pos+1+15, "Evaluate expression until precedence break");
clbl("EVAL3", res+pos+1+18, "Evaluate expression until precedence break");
}
res=find_skel(eval_skel3);
if (res>0) {
clbl("EVAL", res+pos+1, "a.k.a. GETNUM, evaluate expression");
clbl("EVAL1", res+pos+1+3, "Save precedence and eval until precedence break");
clbl("EVAL2", res+pos+1+19, "Evaluate expression until precedence break");
clbl("EVAL3", res+pos+1+22, "Evaluate expression until precedence break");
}
res=find_skel(getnum_skel);
if (res<0)
res=find_skel(getnum_skel2);
if (res<0)
res=find_skel(getnum_skel3);
if (res>0) {
//clbl("GETNUM", res, "BASIC interpreter entry to get a number (EVAL on recent versions)");
clbl("EVAL", res+pos+1, "(a.k.a. GETNUM, evaluate expression (GETNUM)");
clbl("EVAL1", res+pos+1+3, "Save precedence and eval until precedence break");
}
res=find_skel(eval3_ex_skel);
if (res>0) {
clbl("EVAL3", res+pos+1+3, "Evaluate expression until precedence break");
}
res=find_skel(stkths_skel);
if (res>0)
clbl("STKTHS", res+pos+1, "Stack expression item and get next one");
res=find_skel(crtst_skel);
if (res>0) {
clbl("CRTST", res+pos+1, "Create String");
clbl("QTSTR", res+pos+2, "Create quote terminated String");
clbl("DTSTR", res+pos+5, "Create String, termination char in D");
}
res=find_skel(baktmp_skel);
if (res<0)
res=find_skel(baktmp_skel2);
if (res>0)
clbl("BAKTMP", res+pos+1, "Back to last tmp-str entry");
res=find_skel(getstr_skel);
if (res>0) {
clbl("GETSTR", res+pos+1, "Get string pointed by FPREG 'Type Error' if it is not");
clbl("GSTRCU", res+pos+1+3, "Get string pointed by FPREG");
clbl("GSTRHL", res+pos+1+6, "Get string pointed by HL");
clbl("GSTRDE", res+pos+1+7, "Get string pointed by DE");
}
res=find_skel(tststr_skel);
if (res>0)
clbl("TSTSTR", res, "Test a string, 'Type Error' if it is not");
res=find_skel(numasc_skel);
if (res>0)
clbl("NUMASC", res, "Number to ASCII conversion");
res=find_skel(atoh_skel);
if (res<0)
res=find_skel(atoh_skel2);
if (res>0)
clbl("ATOH", res+pos+1, "ASCII to Integer, result in DE");
printf("\n");
res=find_skel(lnum_range_skel);
if (res>0) {
clbl("LNUM_RANGE", res+pos+1, "Read numeric range function parameters");
dlbl("LNUM_PARM", img[res+9] + 256*img[res+10], "Read numeric function parameter");
}
res=find_skel(getchr_skel);
if (res<0)
res=find_skel(getchr_skel2);
if (res>0) {
clbl("CHRGTB", res, "(a.k.a. GETCHR, GETNEXT), pick next char from program");
} else {
res=find_skel(getchr_skel3);
if (res<0)
res=find_skel(getchr_skel4);
if (res<0)
res=find_skel(getchr_skel5);
if (res>0)
clbl("CHRGTB", res+pos+1, "(a.k.a. GETCHR, GETNEXT), pick next char from program");
}
res=find_skel(chrgtb2_skel);
if (res>0)
clbl("_CHRGTB", res+pos, "Pick next char from program");
res=find_skel(chrckb2_skel);
if (res>0)
clbl("_CHRCKB", res+pos+1, "Pick current char (or token) on program");
res=find_skel(ucase_skel);
if (res>0) {
clbl("UCASE_HL", res+pos+1, "Get char from (HL) and make upper case");
clbl("UCASE", res+pos+2, "Make char in 'A' upper case");
}
res=find_skel(getk_skel);
if (res>0)
clbl("GETK", res, "Get key in 'A'");
res=find_skel(rinput_skel);
if (res<0)
res=find_skel(rinput_skel2);
if (res<0)
res=find_skel(rinput_skel3);
if (res>0)
clbl("RINPUT", res, "Line input");
else {
res=find_skel(rinput_skel4);
if (res>0)
clbl("RINPUT", res+pos, "Line input");
}
res=find_skel(outc_skel);
if (res<0)
res=find_skel(outc_skel2);
if (res<0)
res=find_skel(outc_skel3);
if (res<0)
res=find_skel(outc_skel4);
if (res<0)
res=find_skel(outc_skel5);
if (res<0)
res=find_skel(outc_skel6);
if (res>0)
clbl("OUTC", res, "Output char in 'A' to console");
/* MS BASIC errors */
printf("\n");
res=find_skel(datsnr_skel);
if (res>0) {
clbl("DATSNR", res+pos+1, "'SN err' entry for Input STMT");
clbl("SNERR", res+pos+1+6, "entry for '?SN ERROR'");
}
res=find_skel(fcerr_skel);
if (res<0)
res=find_skel(fcerr_skel2);
if (res<0)
res=find_skel(fcerr_skel3);
if (res<0)
res=find_skel(fcerr_skel4);
if (res>0)
clbl("FCERR", res, "entry for '?FC ERROR'");
res=find_skel(ulerr_skel);
if (res>0)
clbl("ULERR", res, "entry for '?UL ERROR'");
printf("\n\n");
/* MS BASIC commands */
jptab=find_skel(jptab_msbasic_skel);
if (jptab<0)
jptab=find_skel(jptab_msbasic_skel2);
if (jptab<0)
jptab=find_skel(jptab_msbasic_skel3);
if (jptab>0) {
printf("\n# JP table for statements = $%04X\n",jptab);
if (SKOOLMODE) {
printf("@ $%04x label=%s\n", jptab, "FNCTAB");
printf("w $%04x %s\n", jptab, "Jump table for statements and functions");
}
printf("\n");
/* hack for PC-6001 ROM v.60 */
res=find_skel(pc6001_60_page);
if (res>0) {
jptab=0x134+0x61;
printf("\n# (applying a PC-6001 table shift hack, new pos: $%04X)\n",jptab);
}
}
res=find_skel(tkmsbasic_ex_skel);
if (res>0) {
res+=1;
printf("\n# TOKEN table position = $%04X, word list in 'extended BASIC' mode.\n",res);
if (SKOOLMODE) {
printf("@ $%04x label=%s\n", res-1, "WORDS");
printf("t $%04x %s\n", res-1, "BASIC keyword list");
}
res-=pos;
token_range=find_skel(tkrange_ex_skel);
if (token_range>0)
printf("#\tToken range: %d\n",token_range);
else token_range=81;
printf("\n# -- STATEMENTS --\n");
res2=find_skel(lnum_tokens_skel);
if ((res2>0) && (img[res2+14]==0)) {
printf("\n#\tRESTORE\t\t[%d]\t",img[res2++]);
printf("\n#\tAUTO\t\t[%d]\t",img[res2++]);
printf("\n#\tRENUM\t\t[%d]\t",img[res2++]);
printf("\n#\tDELETE\t\t[%d]\t",img[res2++]);
printf("\n#\tRESUME\t\t[%d]\t",img[res2++]);
printf("\n#\tERL\t\t[%d]\t",img[res2++]);
printf("\n#\tELSE\t\t[%d]\t",img[res2++]);
printf("\n#\tRUN\t\t[%d]\t",img[res2++]);
printf("\n#\tLIST\t\t[%d]\t",img[res2++]);
printf("\n#\tLLIST\t\t[%d]\t",img[res2++]);
printf("\n#\tGOTO\t\t[%d]\t",img[res2++]);
printf("\n#\tRETURN\t\t[%d]\t",img[res2++]);
printf("\n#\tTHEN\t\t[%d]\t",img[res2++]);
printf("\n#\tGOSUB\t\t[%d]\t",img[res2++]);
}
res2=find_skel(using_tokens_skel);
if (res2>0) {
if (SKOOLMODE) {
res2 += 2;
printf("\n@ $%04x label=__%s\n", img[res2] + 256*img[res2+1], "USING");
printf("w $%04x %s\n", img[res2] + 256*img[res2+1], "PRINT USING");
} else {
printf("\n#\tUSING\t\t[%d]\t",img[res2]);
res2 +=2;
printf("- $%04X",img[res2] + 256*img[res2+1] );
}
res2 += 3;
if (SKOOLMODE) {
res2 += 2;
printf("\n@ $%04x label=__%s\n", img[res2] + 256*img[res2+1], "TAB(");
printf("w $%04x %s\n", img[res2] + 256*img[res2+1], "PRINT TAB(");
} else {
printf("\n#\tTAB(\t\t[%d]\t",img[res2]);
res2 +=2;
printf("- $%04X",img[res2] + 256*img[res2+1] );
}
res2 += 3;
printf("\n#\tSPC(\t\t[%d]\t",img[res2]);
printf("- same as TAB(");
}
res2=find_skel(equal_tk_skel);
if (res2>0)
printf("\n#\t= assignment\t\t[%d]\t",res2);
res2=find_skel(tok_ex_skel);
if (res2>0) {
if (SKOOLMODE) {
res2 += 2;
printf("\n@ $%04x label=__%s\n", signed_byte(img[res2])+res2+1, "OPRND");
printf("w $%04x %s\n", signed_byte(img[res2])+res2+1, "'+' operand evaluation");
} else {
printf("\n#\t+ operand\t\t[%d]\t",img[res2]);
res2 += 2;
printf("- $%04X",signed_byte(img[res2])+res2+1);
}
res2 += 2;
if (SKOOLMODE) {
res2 += 2;
printf("\n@ $%04x label=__%s\n", img[res2] + 256*img[res2+1], "SUB_OPRND");
printf("w $%04x %s\n", img[res2] + 256*img[res2+1], "'-' operand evaluation");
} else {
printf("\n#\t- operand\t\t[%d]\t",img[res2]);
res2 += 2;
printf("- $%04X",img[res2] + 256*img[res2+1] );
}
res2 += 3;
if (SKOOLMODE) {
res2 += 2;
printf("\n@ $%04x label=__%s\n", img[res2] + 256*img[res2+1], "QTSTR");
printf("w $%04x %s\n", img[res2] + 256*img[res2+1], "quoted string evaluation");
} else {
printf("\n#\t\" string\t\t[%d]\t",img[res2]);
res2 += 2;
printf("- $%04X",img[res2] + 256*img[res2+1] );
}
res2 += 3;
if (SKOOLMODE) {
res2 += 2;
printf("\n@ $%04x label=__%s\n", img[res2] + 256*img[res2+1], "NOT");
printf("w $%04x %s\n", img[res2] + 256*img[res2+1], "eval NOT boolean operation");
} else {
printf("\n#\tNOT\t\t[%d]\t",img[res2]);
res2 += 2;
printf("- $%04X",img[res2] + 256*img[res2+1] );
}
res2 += 3;
if (SKOOLMODE) {
res2 += 2;
printf("\n@ $%04x label=__%s\n", img[res2] + 256*img[res2+1], "HEXTFP");
printf("w $%04x %s\n", img[res2] + 256*img[res2+1], "Convert HEX to FP");
} else {
printf("\n#\t& specifier\t\t[%d]\t",img[res2]);
res2 += 2;
printf("- $%04X",img[res2] + 256*img[res2+1] );
}
res2 += 3;
if (img[res2+1] == 0x20) {
if (SKOOLMODE) {
printf("\n@ $%04x label=__%s\n", res2+3, "ERR");
printf("w $%04x %s\n", res2+3, "ERR function evaluation");
} else {
printf("\n#\tERR\t\t[%d]\t",img[res2]);
printf("- $%04X",res2+3);
}
/* JR to next OPCODE group */
res2 += 2;
res2=signed_byte(img[res2])+res2+1;
if ((img[res2] == 0xFE)&&(img[res2+2] == 0x20)) {
res2++;
if (SKOOLMODE) {
printf("\n@ $%04x label=__%s\n", res2+3, "ERL");
printf("w $%04x %s\n", res2+3, "ERL function evaluation");
} else {
printf("\n#\tERL\t\t[%d]\t",img[res2]);
printf("- $%04X",res2+3);
}
/* JR to next OPCODE group */
res2 += 2;
res2=signed_byte(img[res2])+res2+1;
if (img[res2] == 0xFE)
if (img[res2+2]==0xCA) {
/* Extra commands only in latest versions (MSX, SVI..) */
res2++;
while (img[res2+1]==0xCA) {
printf("\n#\tTOKEN_?\t\t[%d]\t",img[res2]);
res2 += 2;
printf("- $%04X",img[res2] + 256*img[res2+1] );
res2 += 3;
}
res2--;
}
if (img[res2+2]==0x20) {
/* This should be present also on all the later Ext. Basic variants */
res2++;
if (SKOOLMODE) {
printf("\n@ $%04x label=__%s\n", res2+3, "VARPTR");
printf("w $%04x %s\n", res2+3, "VARPTR function evaluation");
} else {
printf("\n#\tVARPTR\t\t[%d]\t",img[res2]);
printf("- $%04X",res2+3);
}
/* JR to next OPCODE group */
res2 += 2;
res2=signed_byte(img[res2])+res2+1;
if ((img[res2] == 0xFE) && (img[res2+2]==0xCA)) {
res2++;
if (SKOOLMODE) {
res2 += 2;
printf("\n@ $%04x label=__%s\n", img[res2] + 256*img[res2+1], "USR");
printf("w $%04x %s\n", img[res2] + 256*img[res2+1], "eval user M/C functions");
} else {
printf("\n#\tUSR\t\t[%d]\t",img[res2]);
res2 += 2;
printf("- $%04X",img[res2] + 256*img[res2+1] );
}
res2 += 3;
if (SKOOLMODE) {
res2 += 2;
printf("\n@ $%04x label=__%s\n", img[res2] + 256*img[res2+1], "INSTR");
printf("w $%04x %s\n", img[res2] + 256*img[res2+1], "INSTR function");
} else {
printf("\n#\tINSTR\t\t[%d]\t",img[res2]);
res2 += 2;
printf("- $%04X",img[res2] + 256*img[res2+1] );
}
res2 += 3;
/* TOKEN list order here changes depending on the implementation,
e.g. POINT on TA Alphatronics, INKEY$ on SVI and MSX */
while (img[res2+1]==0xCA) {
printf("\n#\tTOKEN_?\t\t[%d]\t",img[res2]);
res2 += 2;
printf("- $%04X",img[res2] + 256*img[res2+1] );
res2 += 3;
}
res2--;
}
}
}
}
}
printf("\n");
res2=find_skel(else_token_skel);
if (res2>0)
printf("\n#\tELSE\t\t[%d]\n",res2);
chr='A';
clear_token();
append_c(chr);
printf("\n#\t%c", chr);
for (i=res; img[i+8]!='<'; i++) {
if ((img[i-1]==0)&&(img[i]==0)) {chr++; i++;}
if (img[i-1]==0) {
if (token[1] == '\0')
printf("\n#");
chr++; printf("\t%c", chr); clear_token(); append_c(chr);
}
c=img[i];
if (c>=128) {
c-=128;
printf("%c",c);
append_c(c);
i++;
if (jptab>0) {
if (img[i]>128) {
/* MSX/SVI: to be excluded codes between 217 and 220 */
/* Depending on "token_range" other cases may be different !! (e.g. Triumph Adler Alphatronic..) */
if (img[i]<(129+token_range)) {
address=img[jptab+2*(img[i]-129)-pos]+256*img[jptab+2*(img[i]-129)-pos+1];
if (SKOOLMODE)
printf("\n@ $%04x label=__%s\n#", address, token);
else
printf(" \t[%d]\t- $%04X\n#",img[i],address);
} else
printf(" \t[%d]\n#",img[i]);
} else {
address=img[jptab+2*(img[i]+token_range-1)-pos]+256*img[jptab+2*(img[i]+token_range-1)-pos+1];
if (SKOOLMODE)
printf("\n@ $%04x label=__%s\n#", address, token);
else
printf(" \t[%d]\t- $%04X\n#",img[i],address);
}
} else
printf(" \t[%d]\n#",img[i]);
if (img[i+1]!=0) {printf("\t%c", chr); clear_token(); append_c(chr);}
} else if (c!=0) {printf("%c",c); append_c(c);}
}
} else {
/* Classic MS BASIC MODE */
res=find_skel(tkmsbasic_skel)-1;
if (res<0)
res=find_skel(tkmsbasic_skel2);
if (res<0)
res=find_skel(tkmsbasic_skel3);
if (res<0)
res=find_skel(tkmsbasic_skel4)+1;
if (res>0) {
res=res+1-pos;
printf("\n\n\n# TOKEN table position = $%04X, word list in classic encoding mode\n",res+pos);
if (SKOOLMODE) {
printf("@ $%04x label=%s\n", res+pos-1, "WORDS");
printf("t $%04x %s\n", res+pos-1, "BASIC keyword list");
}
new_tk_found=0;
printf("\n# -- STATEMENTS --\n");
printf("\n#\t --- ");
chr=find_skel(tkmsbasic_code_skel)+1;
for (i=res; img[i]!=128; i++) {
if ((new_tk_found!=1) && (((c == 'W') && (img[i-2] == 'E') && ((img[i-3] == 'N') || (img[i-3] == ('N'+0x80)))) && (img[i+1] != 'L'))) {
new_tk_found=1;
printf("\n\n# -- OPERATORS & extras --\n");
}
if ((c == '<') && ((img[i-2] != '=') || (img[i-2] != ('='+0x80)))) {
jptab=find_skel(fnctab_msbasic_skel);
if (jptab<0)
jptab=find_skel(fnctab_msbasic_skel2);
if (jptab<0)
jptab=find_skel(fnctab_msbasic_skel3);
if (jptab>0) {
printf("\n\n# JP table for functions = $%04X\n",jptab);
if (SKOOLMODE) {
printf("@ $%04x label=%s\n", jptab, "FNCTAB_FN");
printf("w $%04x %s\n", jptab, "Extra jump table for functions");
}
/* hack for PC-6001 ROM v.60 */
res=find_skel(pc6001_60_page);
if (res>0) {
jptab=0x134+0xB7;
printf("\n\n# (applying a PC-6001 table shift hack, new pos: $%04X)\n\n",jptab);
}
}
new_tk_found=0;
printf("\n# -- FUNCTIONS --\n");
}
c=img[i];
if (c>=128) {
c-=128;
if (((jptab-pos)>0) && !(new_tk_found)) {
address=img[jptab-pos]+256*img[jptab-pos+1];
if (SKOOLMODE)
printf("\n@ $%04x label=__%s", address, token);
//printf("t $%04x %s\n", img[jptab-pos]+256*img[jptab-pos+1], token);
else
printf("\n$%04X - [%d] ", address, chr);
jptab+=2;
} else {
printf("\n#\t %d ",chr);
}
chr++;
}
printf("%c",c);
if ((new_tk_found!=1) && (
((img[i+1] == 'T'+0x80) && (img[i+2] == 'A') && ((img[i+3] == 'B') || (img[i+3] == ('B'))))
|| ((img[i+2] == 'S') && (img[i+3] == 'I') && (img[i+4] == 'N') && ((img[i+5] == 'G')||(img[i+5] == 'G'+0x80)))
)) {
new_tk_found=1;
printf("\n\n# -- OPERATORS & extras --\n");
}
}
} else {
res=find_skel(tkmsbasic_old_skel);
if (res<0)
res=find_skel(tkmsbasic_old_skel);
if (res>0) {
res=res+1;
printf("\n\n\n# TOKEN table position = $%04X, word list in earlier encoding mode.\n",res+pos);
new_tk_found=0;
printf("\n# -- STATEMENTS --\n");
printf("\n#\t --- ");
chr=128;
if ((jptab-pos)>0) {
address=img[jptab-pos]+256*img[jptab-pos+1];
if (SKOOLMODE)
printf("\n@ $%04x label=__%s", address, token);
else
printf("\n$%04X - [%d] ", address, chr);
jptab+=2;
}
else
printf("\n#\t %d ",chr);
for (i=res; ((img[i]!=128)&&(img[i]!=0)); i++) {
c=img[i];
if (c>=128) c-=128;
if (!new_tk_found && (
(img[i+1] == '@') || ((img[i+1] == 'T') && (img[i+2] == 'A') && ((img[i+3] == 'B') || (img[i+3] == ('B'+0x80))))
|| ((img[i+1] == 'T') && (img[i+2] == 'O'+0x80) && (img[i+3] == 'F') && (img[i+4] == 'N'+0x80))
|| ((img[i+2] == 'S') && (img[i+3] == 'I') && (img[i+4] == 'N') && (img[i+5] == 'G'+0x80))
)) {
printf("%c",c);
new_tk_found=1;
printf("\n\n# -- OPERATORS & extras --\n");
} else {
if ((img[i+1] == 'S') && (img[i+2] == 'G') && ((img[i+3] == 'N') || (img[i+3] == ('N'+0x80)))) {
printf("%c",c);
jptab=find_skel(fnctab_msbasic_skel);
if (jptab<0)
jptab=find_skel(fnctab_msbasic_skel2);
if (jptab<0)
jptab=find_skel(fnctab_msbasic_skel3);
if ((jptab-pos)>0) {
printf("\n\n# JP table for functions = $%04X\n",jptab);
if (SKOOLMODE) {
printf("@ $%04x label=%s\n", jptab, "FNCTAB_FN");
printf("w $%04x %s\n", jptab, "Extra jump table for functions");
}
}
new_tk_found=0;
printf("\n# -- FUNCTIONS --\n");
} else printf("%c",c);
}
if (img[i]>=128) {
if (((jptab-pos)>0) && !(new_tk_found)) {
address=img[jptab-pos]+256*img[jptab-pos+1];
if (SKOOLMODE)
printf("\n@ $%04x label=__%s", address, token);
else
printf("\n$%04X - [%d] ", address, chr);
jptab+=2;
} else
printf("\n#\t %d ",chr);
chr++;
}
}
}
}
}
}
/**************************/
/* Sinclair BASIC section */
/**************************/
res=find_skel(makeroom_skel);
if (res>0) {
printf("\nSinclair BASIC found\n");
brand=find_skel(sinclair_skel);
if (brand>0)
printf(" Sinclair signature found\n");
else {
brand=find_skel(amstrad_skel);
if (brand>0)
printf(" Amstrad signature found\n");
}
brand=0;
printf("\n\tSTKEND system variable = %d ; ",res);
switch (res) {
case 16400:
printf ("ZX80 System Variables mode\n");
brand=ZX80;
break;
case 16412:
printf ("ZX81 System Variables mode\n");
brand=ZX81;
break;
case 23653:
res=find_skel(tk2068_skel);
if (res < 0) {
printf ("ZX Spectrum System Variables mode\n");
brand=SPECTRUM;
} else {
printf ("TS2068 System Variables mode\n");
brand=TS2068;
}
break;
default:
printf ("Unknown System Variables mode\n");
break;
}
res=find_skel(prog_skel);
if (res<0)
res=find_skel(prog_skel2);
if (res>0)
printf("\n\tPROG = $%04X ; BASIC program start",res);
switch (res) {
case 0x4396:
printf (" - LAMBDA style addressing");
brand=LAMBDA;
break;
case 0x407d:
printf (" - ZX81 style addressing");
brand=ZX81;
break;
case 23653:
printf (" ptr - ZX Spectrum style addressing");
brand=SPECTRUM;
break;
default:
break;
}
res=find_skel(vars_skel);
if (res<0)
res=find_skel(vars_skel2);
if (res>0)
printf("\n\tVARS = $%04X ; BASIC variables ptr",res);
res=find_skel(eline_skel);
if (res<0)
res=find_skel(eline_skel2);
if (res>0)
printf("\n\tE-LINE = $%04X ; Ptr to line being edited",res);
res=find_skel(seed_skel);
if (res>0)
printf("\n\tSEED = $%04X ; 'SEED' for RND function",res);
printf("\n");
res=find_skel(next_one_skel);
if (res<0)
res=find_skel(next_one_skel2);
if (res>0)
printf("\n\tNEXT-ONE = $%04X ; Find next variable or program line",res);
res=find_skel(restack_skel);
if (res>0)
printf("\n\tZXFP_DO_RESTACK = $%04X ; Not on ZX81",res+1);
printf("\n");
res=find_skel(stk_pntr_skel);
if (res>0)
printf("\n\tZXFP_STK_PTR = $%04X\n",res);
res=find_skel(stk_st_skel);
if (res>0)
printf("\n\tZXFP_STK_STORE = $%04X",res);
res=find_skel(test5fp_skel);
if (res<0)
res=find_skel(test5fp_skel2);
if (res>0)
printf("\n\tZXFP_TEST_5_FP = $%04X",res);
res=find_skel(stkstr_skel);
if (res>0)
printf("\n\tZXFP_STK_STR = $%04X",res);
res=find_skel(stkftch_skel);
if (res<0)
res=find_skel(stkftch_skel2);
if (res>0)
printf("\n\tZXFP_STK_FETCH = $%04X",res);
res=find_skel(stka_skel);
if (res>0)
printf("\n\tZXFP_STACK_A = $%04X",res);
res=find_skel(stkbc_skel);
if (res>0)
printf("\n\tZXFP_STACK_BC = $%04X",res);
res=find_skel(fpbc_skel);
if (res<0)
res=find_skel(fpbc_skel2);
if (res>0)
printf("\n\tZXFP_FP_TO_BC = $%04X",res);
res=find_skel(intfp_skel);
if (res<0)
res=find_skel(intfp_skel2);
if (res>0)
printf("\n\tZXFP_INT_TO_FP = $%04X",res);
res=find_skel(decfp_skel);
if (res>0)
printf("\n\tZXFP_DEC_TO_FP = $%04X",res);
printf("\n");
res=find_skel(zxfpmod_skel);
if (res<0)
res=find_skel(zxfpmod_skel2);
if (res>0) {
if (img[res-1] & 0xC7 == 0xC7)
printf("\n\tZXFP_BEGIN_CALC = $%02X\n",img[res-1] & 0x38);
if (img[res+12]==img[res+33]) {
printf("\n\tZXFP_END_CALC = $%02X",img[res+12]);
printf("\n\tZXFP_DELETE = $%02X",img[res+1]);
printf("\n\tZXFP_DUPLICATE = $%02X",img[res+2]);
printf("\n\tZXFP_SUBTRACT = $%02X",img[res+11]);
printf("\n\tZXFP_DIVISION = $%02X",img[res+4]);
printf("\n\tZXFP_MULTIPLY = $%02X",img[res+9]);
printf("\n\tZXFP_EXCHANGE = $%02X",img[res+7]);
printf("\n\tZXFP_INT = $%02X",img[res+5]);
printf("\n\tZXFP_ST_MEM_0 = $%02X",img[res]);
printf("\n\tZXFP_GET_MEM_0 = $%02X",img[res+3]);
printf("\n\tZXFP_LESS_0 = $%02X",img[res+16]);
printf("\n\tZXFP_JUMP_TRUE = $%02X",img[res+17]);
printf("\n\tZXFP_TRUNCATE = $%02X",img[res+19]);
printf("\n\tZXFP_NOT = $%02X",img[res+28]);
printf("\n\tZXFP_STK_ONE = $%02X",img[res+31]);
}
if (img[res+12]==img[res+87]) {
printf("\n\tZXFP_ADDITION = $%02X",img[res+49]);
printf("\n\tZXFP_STK_DATA = $%02X",img[res+36]);
printf("\n\tZXFP_ST_MEM_3 = $%02X",img[res+46]);
printf("\n\tZXFP_GET_MEM_3 = $%02X",img[res+86]);
printf("\n\tZXFP_SERIES_08 = $%02X",img[res+52]);
printf("\n");
printf("\n\tZXFP_FP_TO_A = $%04X",img[res+89]+256*img[res+90]);
}
}
res=find_skel(rnd_skel);
if (res>0) {
printf("\n");
printf("\n\tZXFP_STK_ONE = $%02X",img[res+1]);
printf("\n\tZXFP_STK_DATA = $%02X",img[res+3]);
printf("\n\tZXFP_N_MOD_M = $%02X",img[res+13]);
if (img[res+18]==img[res+42]) {
printf("\n\tZXFP_STK_PI_D_2 = $%02X",img[res+13]);
}
}
/* Sinclair BASIC Commands */
switch (brand) {
case LAMBDA:
res=find_skel(tklambda_skel);
if (res>0) {
printf("\n\n\nTOKEN table position = $%04X\n",res);
printf("\n\t--- ");
chr=192;
for (i=res; (img[i]!=0xCD)!=0; i++) {
c=img[i] & 0xBF;
if (chr==256) chr=64;
if (c>=128) { c-=128; printf("%c \n\t%d ",zx81char(c), chr++); }
else printf("%c",zx81char(c));
}
}
break;
case ZX81:
res=find_skel(tkzx81_skel);
if (res>0) {
printf("\n\n\nTOKEN table position = $%04X\n",res);
printf("\n\t--- ");
chr=192;
for (i=res; (img[i]!=0x23)!=0; i++) {
c=img[i] & 0xBF;
if (chr==256) chr=64;
if (c>=128) { c-=128; printf("%c \n\t%d ",zx81char(c), chr++); }
else printf("%c",zx81char(c));
}
}
break;
case TS2068:
res=find_skel(tk2068_skel);
if (res>0) {
printf("\n\n\nTOKEN table position = $%04X\n",res);
printf("\n\t--- ");
chr=165;
for (i=res; (chr<263)!=0; i++) {
c=img[i];
if (c>=128) {
c-=128;
if (chr<=255)
printf("%c \n\t%d ",c, chr++);
else {
printf("%c \n\t ",c);
chr++;
}
}
else printf("%c",c);
}
}
default:
res=find_skel(tkspectrum_skel);
if (res>0) {
printf("\n\n\nTOKEN table position = $%04X\n",res);
printf("\n\t--- ");
chr=165;
if (len>16384) res+=16384;
if (len>32768) res+=32768;
for (i=res; (chr<=256)!=0; i++) {
c=img[i];
if (c>=128) { c-=128; printf("%c \n\t%d ",c, chr++); }
else printf("%c",c);
}
res=find_skel(tkzx128_skel);
printf("\n\t ");
if (res>0) {
for (i=res; (img[i]>2); i++) {
c=img[i];
if (c>=128) { c-=128; printf("%c\n\t ",c); }
else printf("%c",c);
}
}
}
break;
}
}
res=find_skel(zxshadow_end);
if (res>0) {
printf("\nShadow memory for ZX Spectrum ROM found\n");
printf("\n\tZX_SHADOW_END = $%04X ; Return to the BASIC interpreter\n",res);
}
printf("\n\n");
fclose(fpin);
}
|
the_stack_data/237644053.c
|
int while_break_return()
{
int x, y, z;
while (x > 0)
{
break;
return 10;
}
return 1;
}
|
the_stack_data/175144054.c
|
#include <stdio.h>
#include <math.h>
int main(void)
{
printf("Введите E: ");
float E;
scanf("%f",&E);
float lastc=1, lastz=1;
float ch = 1;
float zn = 1;
float q = 1;
float Sum = 1;
while(1){
lastc += 2;
lastz += 3;
ch *= lastc;
zn *= lastz;
q = ch/zn;
if(fabs(q)<=E)
break;
Sum += q;
}
printf("Sum = %f\n", Sum);
return 0;
}
|
the_stack_data/190767930.c
|
// https://en.cppreference.com/w/c/atomic/atomic_fetch_add
#include <stdio.h>
#include <threads.h>
#include <stdatomic.h>
atomic_int acnt;
int cnt;
int f(void* thr_data)
{
for(int n = 0; n < 1000; ++n) {
++acnt; // atomic
++cnt; // undefined behavior, in practice some updates missed
}
return 0;
}
int main(void)
{
thrd_t thr[10];
for(int n = 0; n < 10; ++n)
thrd_create(&thr[n], f, NULL);
for(int n = 0; n < 10; ++n)
thrd_join(thr[n], NULL);
printf("The atomic counter is %u\n", acnt);
printf("The non-atomic counter is %u\n", cnt);
return 0;
}
|
the_stack_data/15761675.c
|
#include <stdio.h>
int main(int argc, char *argv[]) {
int x,y,n;
scanf("%d",&n);
scanf("%d",&x);
int count = 0;
int a[x];
for (int i = 0 ; i < x ; i ++ ){
scanf("%d",&a[i]);
}
scanf("%d",&y);
int b[y];
int c[n+1];
for (int i = 0 ; i < y ; i++ ) {
scanf("%d",&b[i]);
}
for (int i = 0 ; i < n+1 ; i++ ) {
c[i]=0;
}
for ( int j = 0 ; j < n+1 ; j++ ) {
for (int i = 0 ; i < x ; i++){
if (a[i] == j)
c[j] = 1;
}
for (int i = 0 ; i < y ; i++) {
if (b[i] == j)
c[j] = 1;
}
}
for (int i = 1 ; i < n+1 ; i++ ){
if ( c[i] == 0 ){
printf("Oh, my keyboard!");
return 0;
}
}
printf("I become the guy.");
return 0;
}
|
the_stack_data/22012257.c
|
// RUN: %clang_cc1 -fsyntax-only -fopenmp -fopenmp-version=45 -verify=expected,omp45 %s -Wuninitialized
// RUN: %clang_cc1 -fsyntax-only -fopenmp -fopenmp-version=50 -verify=expected,omp50 %s -Wuninitialized
// RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -fopenmp-version=45 -verify=expected,omp45 %s -Wuninitialized
// RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -fopenmp-version=50 -verify=expected,omp50 %s -Wuninitialized
// expected-error@+1 {{unexpected OpenMP directive '#pragma omp target parallel for simd'}}
#pragma omp target parallel for simd
// expected-error@+1 {{unexpected OpenMP directive '#pragma omp target parallel for simd'}}
#pragma omp target parallel for simd foo
void test_no_clause() {
int i;
#pragma omp target parallel for simd
for (i = 0; i < 16; ++i)
;
// expected-error@+2 {{statement after '#pragma omp target parallel for simd' must be a for loop}}
#pragma omp target parallel for simd
++i;
}
void test_branch_protected_scope() {
int i = 0;
L1:
++i;
int x[24];
#pragma omp target parallel for simd
for (i = 0; i < 16; ++i) {
if (i == 5)
goto L1; // expected-error {{use of undeclared label 'L1'}}
else if (i == 6)
return; // expected-error {{cannot return from OpenMP region}}
else if (i == 7)
goto L2;
else if (i == 8) {
L2:
x[i]++;
}
}
if (x[0] == 0)
goto L2; // expected-error {{use of undeclared label 'L2'}}
else if (x[1] == 1)
goto L1;
}
void test_invalid_clause() {
int i;
// expected-warning@+1 {{extra tokens at the end of '#pragma omp target parallel for simd' are ignored}}
#pragma omp target parallel for simd foo bar
for (i = 0; i < 16; ++i)
;
}
void test_non_identifiers() {
int i, x;
// expected-warning@+1 {{extra tokens at the end of '#pragma omp target parallel for simd' are ignored}}
#pragma omp target parallel for simd;
for (i = 0; i < 16; ++i)
;
// expected-warning@+1 {{extra tokens at the end of '#pragma omp target parallel for simd' are ignored}}
#pragma omp target parallel for simd private(x);
for (i = 0; i < 16; ++i)
;
// expected-warning@+1 {{extra tokens at the end of '#pragma omp target parallel for simd' are ignored}}
#pragma omp target parallel for simd, private(x);
for (i = 0; i < 16; ++i)
;
}
extern int foo();
void test_collapse() {
int i;
// expected-error@+1 {{expected '('}}
#pragma omp target parallel for simd collapse
for (i = 0; i < 16; ++i)
;
// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
#pragma omp target parallel for simd collapse(
for (i = 0; i < 16; ++i)
;
// expected-error@+1 {{expected expression}}
#pragma omp target parallel for simd collapse()
for (i = 0; i < 16; ++i)
;
// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
#pragma omp target parallel for simd collapse(,
for (i = 0; i < 16; ++i)
;
// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
#pragma omp target parallel for simd collapse(, )
for (i = 0; i < 16; ++i)
;
// expected-warning@+2 {{extra tokens at the end of '#pragma omp target parallel for simd' are ignored}}
// expected-error@+1 {{expected '('}}
#pragma omp target parallel for simd collapse 4)
for (i = 0; i < 16; ++i)
;
// expected-error@+2 {{expected ')'}}
// expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
#pragma omp target parallel for simd collapse(4
for (i = 0; i < 16; ++i)
; // expected-error {{expected 4 for loops after '#pragma omp target parallel for simd', but found only 1}}
// expected-error@+2 {{expected ')'}}
// expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
#pragma omp target parallel for simd collapse(4,
for (i = 0; i < 16; ++i)
; // expected-error {{expected 4 for loops after '#pragma omp target parallel for simd', but found only 1}}
// expected-error@+2 {{expected ')'}}
// expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
#pragma omp target parallel for simd collapse(4, )
for (i = 0; i < 16; ++i)
; // expected-error {{expected 4 for loops after '#pragma omp target parallel for simd', but found only 1}}
// expected-note@+1 {{as specified in 'collapse' clause}}
#pragma omp target parallel for simd collapse(4)
for (i = 0; i < 16; ++i)
; // expected-error {{expected 4 for loops after '#pragma omp target parallel for simd', but found only 1}}
// expected-error@+2 {{expected ')'}}
// expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
#pragma omp target parallel for simd collapse(4 4)
for (i = 0; i < 16; ++i)
; // expected-error {{expected 4 for loops after '#pragma omp target parallel for simd', but found only 1}}
// expected-error@+2 {{expected ')'}}
// expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
#pragma omp target parallel for simd collapse(4, , 4)
for (i = 0; i < 16; ++i)
; // expected-error {{expected 4 for loops after '#pragma omp target parallel for simd', but found only 1}}
#pragma omp target parallel for simd collapse(4)
for (int i1 = 0; i1 < 16; ++i1)
for (int i2 = 0; i2 < 16; ++i2)
for (int i3 = 0; i3 < 16; ++i3)
for (int i4 = 0; i4 < 16; ++i4)
foo();
// expected-error@+2 {{expected ')'}}
// expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
#pragma omp target parallel for simd collapse(4, 8)
for (i = 0; i < 16; ++i)
; // expected-error {{expected 4 for loops after '#pragma omp target parallel for simd', but found only 1}}
// expected-error@+1 {{expression is not an integer constant expression}}
#pragma omp target parallel for simd collapse(2.5)
for (i = 0; i < 16; ++i)
;
// expected-error@+1 {{expression is not an integer constant expression}}
#pragma omp target parallel for simd collapse(foo())
for (i = 0; i < 16; ++i)
;
// expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}}
#pragma omp target parallel for simd collapse(-5)
for (i = 0; i < 16; ++i)
;
// expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}}
#pragma omp target parallel for simd collapse(0)
for (i = 0; i < 16; ++i)
;
// expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}}
#pragma omp target parallel for simd collapse(5 - 5)
for (i = 0; i < 16; ++i)
;
// expected-note@+1 {{defined as firstprivate}}
#pragma omp target parallel for simd collapse(2) firstprivate(i) // expected-note {{defined as firstprivate}}
for (i = 0; i < 16; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp target parallel for simd' directive may not be firstprivate, predetermined as lastprivate}}
// expected-note@+1 {{variable with automatic storage duration is predetermined as private; perhaps you forget to enclose 'omp for' directive into a parallel or another task region?}}
for (int j = 0; j < 16; ++j)
// expected-error@+2 2 {{reduction variable must be shared}}
// expected-error@+1 {{OpenMP constructs may not be nested inside a simd region}}
#pragma omp for reduction(+ : i, j)
for (int k = 0; k < 16; ++k)
i += j;
}
void test_private() {
int i;
// expected-error@+2 {{expected expression}}
// expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
#pragma omp target parallel for simd private(
for (i = 0; i < 16; ++i)
;
// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
// expected-error@+1 2 {{expected expression}}
#pragma omp target parallel for simd private(,
for (i = 0; i < 16; ++i)
;
// expected-error@+1 2 {{expected expression}}
#pragma omp target parallel for simd private(, )
for (i = 0; i < 16; ++i)
;
// expected-error@+1 {{expected expression}}
#pragma omp target parallel for simd private()
for (i = 0; i < 16; ++i)
;
// expected-error@+1 {{expected expression}}
#pragma omp target parallel for simd private(int)
for (i = 0; i < 16; ++i)
;
// expected-error@+1 {{expected variable name}}
#pragma omp target parallel for simd private(0)
for (i = 0; i < 16; ++i)
;
int x, y, z;
#pragma omp target parallel for simd private(x)
for (i = 0; i < 16; ++i)
;
#pragma omp target parallel for simd private(x, y)
for (i = 0; i < 16; ++i)
;
#pragma omp target parallel for simd private(x, y, z)
for (i = 0; i < 16; ++i) {
x = y * i + z;
}
}
void test_lastprivate() {
int i;
// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
// expected-error@+1 {{expected expression}}
#pragma omp target parallel for simd lastprivate(
for (i = 0; i < 16; ++i)
;
// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
// expected-error@+1 2 {{expected expression}}
#pragma omp target parallel for simd lastprivate(,
for (i = 0; i < 16; ++i)
;
// expected-error@+1 2 {{expected expression}}
#pragma omp target parallel for simd lastprivate(, )
for (i = 0; i < 16; ++i)
;
// expected-error@+1 {{expected expression}}
#pragma omp target parallel for simd lastprivate()
for (i = 0; i < 16; ++i)
;
// expected-error@+1 {{expected expression}}
#pragma omp target parallel for simd lastprivate(int)
for (i = 0; i < 16; ++i)
;
// expected-error@+1 {{expected variable name}}
#pragma omp target parallel for simd lastprivate(0)
for (i = 0; i < 16; ++i)
;
int x, y, z;
#pragma omp target parallel for simd lastprivate(x)
for (i = 0; i < 16; ++i)
;
#pragma omp target parallel for simd lastprivate(x, y)
for (i = 0; i < 16; ++i)
;
#pragma omp target parallel for simd lastprivate(x, y, z)
for (i = 0; i < 16; ++i)
;
}
void test_firstprivate() {
int i;
// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
// expected-error@+1 {{expected expression}}
#pragma omp target parallel for simd firstprivate(
for (i = 0; i < 16; ++i)
;
// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
// expected-error@+1 2 {{expected expression}}
#pragma omp target parallel for simd firstprivate(,
for (i = 0; i < 16; ++i)
;
// expected-error@+1 2 {{expected expression}}
#pragma omp target parallel for simd firstprivate(, )
for (i = 0; i < 16; ++i)
;
// expected-error@+1 {{expected expression}}
#pragma omp target parallel for simd firstprivate()
for (i = 0; i < 16; ++i)
;
// expected-error@+1 {{expected expression}}
#pragma omp target parallel for simd firstprivate(int)
for (i = 0; i < 16; ++i)
;
// expected-error@+1 {{expected variable name}}
#pragma omp target parallel for simd firstprivate(0)
for (i = 0; i < 16; ++i)
;
int x, y, z;
#pragma omp target parallel for simd lastprivate(x) firstprivate(x)
for (i = 0; i < 16; ++i)
;
#pragma omp target parallel for simd lastprivate(x, y) firstprivate(x, y)
for (i = 0; i < 16; ++i)
;
#pragma omp target parallel for simd lastprivate(x, y, z) firstprivate(x, y, z)
for (i = 0; i < 16; ++i)
;
}
void test_loop_messages() {
float a[100], b[100], c[100];
// expected-error@+2 {{variable must be of integer or pointer type}}
#pragma omp target parallel for simd
for (float fi = 0; fi < 10.0; fi++) {
c[(int)fi] = a[(int)fi] + b[(int)fi];
}
// expected-error@+2 {{variable must be of integer or pointer type}}
#pragma omp target parallel for simd
for (double fi = 0; fi < 10.0; fi++) {
c[(int)fi] = a[(int)fi] + b[(int)fi];
}
}
void test_safelen() {
int i;
// expected-error@+1 {{expected '('}}
#pragma omp target parallel for simd safelen
for (i = 0; i < 16; ++i)
;
// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
#pragma omp target parallel for simd safelen(
for (i = 0; i < 16; ++i)
;
// expected-error@+1 {{expected expression}}
#pragma omp target parallel for simd safelen()
for (i = 0; i < 16; ++i)
;
// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
#pragma omp target parallel for simd safelen(,
for (i = 0; i < 16; ++i)
;
// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
#pragma omp target parallel for simd safelen(, )
for (i = 0; i < 16; ++i)
;
// expected-warning@+2 {{extra tokens at the end of '#pragma omp target parallel for simd' are ignored}}
// expected-error@+1 {{expected '('}}
#pragma omp target parallel for simd safelen 4)
for (i = 0; i < 16; ++i)
;
// expected-error@+2 {{expected ')'}}
// expected-note@+1 {{to match this '('}}
#pragma omp target parallel for simd safelen(4
for (i = 0; i < 16; ++i)
;
// expected-error@+2 {{expected ')'}}
// expected-note@+1 {{to match this '('}}
#pragma omp target parallel for simd safelen(4,
for (i = 0; i < 16; ++i)
;
// expected-error@+2 {{expected ')'}}
// expected-note@+1 {{to match this '('}}
#pragma omp target parallel for simd safelen(4, )
for (i = 0; i < 16; ++i)
;
#pragma omp target parallel for simd safelen(4)
for (i = 0; i < 16; ++i)
;
// expected-error@+2 {{expected ')'}}
// expected-note@+1 {{to match this '('}}
#pragma omp target parallel for simd safelen(4 4)
for (i = 0; i < 16; ++i)
;
// expected-error@+2 {{expected ')'}}
// expected-note@+1 {{to match this '('}}
#pragma omp target parallel for simd safelen(4, , 4)
for (i = 0; i < 16; ++i)
;
#pragma omp target parallel for simd safelen(4)
for (i = 0; i < 16; ++i)
;
// expected-error@+2 {{expected ')'}}
// expected-note@+1 {{to match this '('}}
#pragma omp target parallel for simd safelen(4, 8)
for (i = 0; i < 16; ++i)
;
// expected-error@+1 {{expression is not an integer constant expression}}
#pragma omp target parallel for simd safelen(2.5)
for (i = 0; i < 16; ++i)
;
// expected-error@+1 {{expression is not an integer constant expression}}
#pragma omp target parallel for simd safelen(foo())
for (i = 0; i < 16; ++i)
;
// expected-error@+1 {{argument to 'safelen' clause must be a strictly positive integer value}}
#pragma omp target parallel for simd safelen(-5)
for (i = 0; i < 16; ++i)
;
// expected-error@+1 {{argument to 'safelen' clause must be a strictly positive integer value}}
#pragma omp target parallel for simd safelen(0)
for (i = 0; i < 16; ++i)
;
// expected-error@+1 {{argument to 'safelen' clause must be a strictly positive integer value}}
#pragma omp target parallel for simd safelen(5 - 5)
for (i = 0; i < 16; ++i)
;
}
void test_simdlen() {
int i;
// expected-error@+1 {{expected '('}}
#pragma omp target parallel for simd simdlen
for (i = 0; i < 16; ++i)
;
// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
#pragma omp target parallel for simd simdlen(
for (i = 0; i < 16; ++i)
;
// expected-error@+1 {{expected expression}}
#pragma omp target parallel for simd simdlen()
for (i = 0; i < 16; ++i)
;
// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
#pragma omp target parallel for simd simdlen(,
for (i = 0; i < 16; ++i)
;
// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
#pragma omp target parallel for simd simdlen(, )
for (i = 0; i < 16; ++i)
;
// expected-warning@+2 {{extra tokens at the end of '#pragma omp target parallel for simd' are ignored}}
// expected-error@+1 {{expected '('}}
#pragma omp target parallel for simd simdlen 4)
for (i = 0; i < 16; ++i)
;
// expected-error@+2 {{expected ')'}}
// expected-note@+1 {{to match this '('}}
#pragma omp target parallel for simd simdlen(4
for (i = 0; i < 16; ++i)
;
// expected-error@+2 {{expected ')'}}
// expected-note@+1 {{to match this '('}}
#pragma omp target parallel for simd simdlen(4,
for (i = 0; i < 16; ++i)
;
// expected-error@+2 {{expected ')'}}
// expected-note@+1 {{to match this '('}}
#pragma omp target parallel for simd simdlen(4, )
for (i = 0; i < 16; ++i)
;
#pragma omp target parallel for simd simdlen(4)
for (i = 0; i < 16; ++i)
;
// expected-error@+2 {{expected ')'}}
// expected-note@+1 {{to match this '('}}
#pragma omp target parallel for simd simdlen(4 4)
for (i = 0; i < 16; ++i)
;
// expected-error@+2 {{expected ')'}}
// expected-note@+1 {{to match this '('}}
#pragma omp target parallel for simd simdlen(4, , 4)
for (i = 0; i < 16; ++i)
;
#pragma omp target parallel for simd simdlen(4)
for (i = 0; i < 16; ++i)
;
// expected-error@+2 {{expected ')'}}
// expected-note@+1 {{to match this '('}}
#pragma omp target parallel for simd simdlen(4, 8)
for (i = 0; i < 16; ++i)
;
// expected-error@+1 {{expression is not an integer constant expression}}
#pragma omp target parallel for simd simdlen(2.5)
for (i = 0; i < 16; ++i)
;
// expected-error@+1 {{expression is not an integer constant expression}}
#pragma omp target parallel for simd simdlen(foo())
for (i = 0; i < 16; ++i)
;
// expected-error@+1 {{argument to 'simdlen' clause must be a strictly positive integer value}}
#pragma omp target parallel for simd simdlen(-5)
for (i = 0; i < 16; ++i)
;
// expected-error@+1 {{argument to 'simdlen' clause must be a strictly positive integer value}}
#pragma omp target parallel for simd simdlen(0)
for (i = 0; i < 16; ++i)
;
// expected-error@+1 {{argument to 'simdlen' clause must be a strictly positive integer value}}
#pragma omp target parallel for simd simdlen(5 - 5)
for (i = 0; i < 16; ++i)
;
}
void test_safelen_simdlen() {
int i;
// expected-error@+1 {{the value of 'simdlen' parameter must be less than or equal to the value of the 'safelen' parameter}}
#pragma omp target parallel for simd simdlen(6) safelen(5)
for (i = 0; i < 16; ++i)
;
// expected-error@+1 {{the value of 'simdlen' parameter must be less than or equal to the value of the 'safelen' parameter}}
#pragma omp target parallel for simd safelen(5) simdlen(6)
for (i = 0; i < 16; ++i)
;
}
void test_nontemporal() {
int i;
// omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp target parallel for simd'}} expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
#pragma omp target parallel for simd nontemporal(
for (i = 0; i < 16; ++i)
;
// omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp target parallel for simd'}} expected-error@+1 2 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
#pragma omp target parallel for simd nontemporal(,
for (i = 0; i < 16; ++i)
;
// omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp target parallel for simd'}} expected-error@+1 2 {{expected expression}}
#pragma omp target parallel for simd nontemporal(, )
for (i = 0; i < 16; ++i)
;
// omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp target parallel for simd'}} expected-error@+1 {{expected expression}}
#pragma omp target parallel for simd nontemporal()
for (i = 0; i < 16; ++i)
;
// omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp target parallel for simd'}} expected-error@+1 {{expected expression}}
#pragma omp target parallel for simd nontemporal(int)
for (i = 0; i < 16; ++i)
;
// omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp target parallel for simd'}} omp50-error@+1 {{expected variable name}}
#pragma omp target parallel for simd nontemporal(0)
for (i = 0; i < 16; ++i)
;
// omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp target parallel for simd'}} expected-error@+1 {{use of undeclared identifier 'x'}}
#pragma omp target parallel for simd nontemporal(x)
for (i = 0; i < 16; ++i)
;
// expected-error@+2 {{use of undeclared identifier 'x'}}
// omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp target parallel for simd'}} expected-error@+1 {{use of undeclared identifier 'y'}}
#pragma omp target parallel for simd nontemporal(x, y)
for (i = 0; i < 16; ++i)
;
// expected-error@+3 {{use of undeclared identifier 'x'}}
// expected-error@+2 {{use of undeclared identifier 'y'}}
// omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp target parallel for simd'}} expected-error@+1 {{use of undeclared identifier 'z'}}
#pragma omp target parallel for simd nontemporal(x, y, z)
for (i = 0; i < 16; ++i)
;
int x, y;
// omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp target parallel for simd'}} expected-error@+1 {{expected ',' or ')' in 'nontemporal' clause}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
#pragma omp target parallel for simd nontemporal(x :)
for (i = 0; i < 16; ++i)
;
// omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp target parallel for simd'}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} expected-error@+1 {{expected ',' or ')' in 'nontemporal' clause}}
#pragma omp target parallel for simd nontemporal(x :, )
for (i = 0; i < 16; ++i)
;
// omp50-note@+2 {{defined as nontemporal}}
// omp45-error@+1 2 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp target parallel for simd'}} omp50-error@+1 {{a variable cannot appear in more than one nontemporal clause}}
#pragma omp target parallel for simd nontemporal(x) nontemporal(x)
for (i = 0; i < 16; ++i)
;
// omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp target parallel for simd'}}
#pragma omp target parallel for simd private(x) nontemporal(x)
for (i = 0; i < 16; ++i)
;
// omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp target parallel for simd'}}
#pragma omp target parallel for simd nontemporal(x) private(x)
for (i = 0; i < 16; ++i)
;
// omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp target parallel for simd'}} expected-note@+1 {{to match this '('}} expected-error@+1 {{expected ',' or ')' in 'nontemporal' clause}} expected-error@+1 {{expected ')'}}
#pragma omp target parallel for simd nontemporal(x, y : 0)
for (i = 0; i < 16; ++i)
;
// omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp target parallel for simd'}}
#pragma omp target parallel for simd nontemporal(x) lastprivate(x)
for (i = 0; i < 16; ++i)
;
// omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp target parallel for simd'}}
#pragma omp target parallel for simd lastprivate(x) nontemporal(x)
for (i = 0; i < 16; ++i)
;
}
|
the_stack_data/49117.c
|
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define USAGE "./burgers.x"
void copyT(double *origen, double *destino,int T);
double *reservar(int puntos);
void resolver(double *u, double *v);
void guardar(double *x,char *filename);
void iniciar(double *u,double*v);
int nx;
int ny;
int nt;
double dx;
double dy;
double sigma;
double nu;
double dt;
main(){
nx = 41;
ny = 41;
nt = 12;
dx = 2.0/(nx-1);
dy = 2.0/(ny-1);
sigma = .0009;
nu = 0.01;
dt = sigma*dx*dy/nu;
double *u;
double *v;
double *un;
double *uv;
u = reservar(nx*ny*nt);
v = reservar(nx*ny*nt);
iniciar(u,v);
printf("error en resolver");
resolver(u,v);
printf("error en guardar");
guardar(u,"solBurgersU.dat");
guardar(v,"solBurgersV.dat");
}
double *reservar(int puntos){
double *array=malloc(puntos*sizeof(double));
int i;
for(i=0;i<puntos;i++){
array[i]=1.0;
}
return array;
}
void iniciar(double *u, double *v){
int x;
int y;
for(x=11;x<=21;x++){
for (y=11;y<=21;y++){
u[x+nx*y]=2;
v[x+nx*y]=2;
/*prueba */
u[x]=3;
}
}
}
void resolver(double *u, double *v){
double *un;
double *vn;
un = reservar(nx*ny);
vn = reservar(nx*ny);
int t;
int x;
int y;
for (t=0;t<nt-1;t++){
copyT(u,un,t);
copyT(v,vn,t);
for(y=1;y<ny-1;y++){
for (x=1;x<nx-1;x++){
u[(t+1)*nx*ny+y*nx+x]=un[x+y*nx]
-dt/dx*un[x+y*nx]*(un[x+y*nx]-un[x-1+y*nx])
-dt/dy*vn[x+y*nx]*(un[x+y*nx]-un[x+(y-1)*nx])
+nu*dt/(dx*dx)*(un[x+1+y*nx]-2*un[x+y*nx]+un[x-1+y*nx])
+nu*dt/(dy*dy)*(un[x+(y+1)*nx]-2*un[x+y*nx]+un[x+(y-1)*nx]);
v[(t+1)*nx*ny+y*nx+x]=vn[x+y*nx]
-dt/dx*un[x+y*nx]*(vn[x+y*nx]-vn[x-1+y*nx])
-dt/dy*vn[x+y*nx]*(vn[x+y*nx]-vn[x+(y-1)*nx])
+nu*dt/(dx*dx)*(vn[x+1+y*nx]-2*vn[x+y*nx]+vn[x-1+y*nx])
+nu*dt/(dy*dy)*(vn[x+(y+1)*nx]-2*vn[x+y*nx]+vn[x+(y-1)*nx]);
}
}
/*
for (x=0;x<nx;x++){
u[(t+1)*nx*ny+x]=1;
u[(t+1)*nx*ny+x+(nx*(ny-1))]=1;
v[(t+1)*nx*ny+x]=1;
v[(t+1)*nx*ny+x+(nx*(ny-1))]=1;
}
for (y=0;y<ny;y++){
u[(t+1)*nx*ny+y*nx]=1;
u[(t+1)*nx*ny+nx-1+y*nx]=1;
v[(t+1)*nx*ny+y*nx]=1;
v[(t+1)*nx*ny+nx-1+y*nx]=1;
}
*/
}
}
void guardar(double *u,char *filename){
FILE *in;
int t;
int x;
int y;
for(t=0; t<nt;t++){
char str[80];
sprintf(str,"%s%d",filename,t);
in = fopen(str,"w");
for(y=0;y<ny;y++){
for(x=0;x<nx;x++){
fprintf(in,"%f, ",u[t*nx*ny+y*nx+x]);
}
fprintf(in,"\n");
}
fclose(in);
}
}
void copyT(double *origen, double *destino, int T){
int i;
for(i=0;i<=nx*ny;i++){
destino[i] = origen[T*nx*ny+i];
}
}
|
the_stack_data/70495.c
|
#include <stdio.h>
int main()
{
int n,i,j;
scanf("%d",&n);
for(i=n+1;;i++)
{for(j=2;j<i;j++)
{if(i%j==0)
break;}
if(j==i)
{printf("%d",j);
break;}}
return 0;
}
|
the_stack_data/248579820.c
|
/* { dg-do run } */
#include "cpuid.h"
int
main ()
{
__builtin_cpu_init ();
if (__builtin_cpu_supports ("avx2"))
{
unsigned int eax, ebx, ecx, edx;
if (!__get_cpuid_count (7, 0, &eax, &ebx, &ecx, &edx))
__builtin_abort ();
if (!(ebx & bit_AVX2))
__builtin_abort ();
}
return 0;
}
|
the_stack_data/206392395.c
|
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<unistd.h>
char* re2post(char *re)
{
int nalt, natom;
static char buf[8000];
char *dst;
struct {
int nalt;
int natom;
} paren[100], *p;
p = paren;
dst = buf;
nalt = 0;
natom = 0;
if(strlen(re) >= sizeof buf/2)
return NULL;
for(; *re; re++){
switch(*re){
case '(':
if(natom > 1){
--natom;
*dst++ = '.';
}
if(p >= paren+100)
return NULL;
p->nalt = nalt;
p->natom = natom;
p++;
nalt = 0;
natom = 0;
break;
case '|':
if(natom == 0)
return NULL;
while(--natom > 0)
*dst++ = '.';
nalt++;
break;
case ')':
if(p == paren)
return NULL;
if(natom == 0)
return NULL;
while(--natom > 0)
*dst++ = '.';
for(; nalt > 0; nalt--)
*dst++ = '|';
--p;
nalt = p->nalt;
natom = p->natom;
natom++;
break;
case '*':
case '+':
case '?':
if(natom == 0)
return NULL;
*dst++ = *re;
break;
default:
if(natom > 1){
--natom;
*dst++ = '.';
}
*dst++ = *re;
natom++;
break;
}
}
if(p != paren)
return NULL;
while(--natom > 0)
*dst++ = '.';
for(; nalt > 0; nalt--)
*dst++ = '|';
*dst = 0;
return buf;
}
enum
{
Match = 256,
Split = 257
};
typedef struct State State;
struct State
{
int c;
State *out;
State *out1;
int lastlist;
};
State matchstate = { Match }; /* matching state */
int nstate;
State* state(int c, State *out, State *out1)
{
State *s;
nstate++;
s = malloc(sizeof *s);
s->lastlist = 0;
s->c = c;
s->out = out;
s->out1 = out1;
return s;
}
typedef struct Frag Frag;
typedef union Ptrlist Ptrlist;
struct Frag
{
State *start;
Ptrlist *out;
};
/* Initialize Frag struct. */
Frag frag(State *start, Ptrlist *out)
{
Frag n = { start, out };
return n;
}
union Ptrlist
{
Ptrlist *next;
State *s;
};
Ptrlist* list1(State **outp)
{
Ptrlist *l;
l = (Ptrlist*)outp;
l->next = NULL;
return l;
}
void patch(Ptrlist *l, State *s)
{
Ptrlist *next;
for(; l; l=next){
next = l->next;
l->s = s;
}
}
Ptrlist* append(Ptrlist *l1, Ptrlist *l2)
{
Ptrlist *oldl1;
oldl1 = l1;
while(l1->next)
l1 = l1->next;
l1->next = l2;
return oldl1;
}
State* post2nfa(char *postfix)
{
char *p;
Frag stack[1000], *stackp, e1, e2, e;
State *s;
// fprintf(stderr, "postfix: %s\n", postfix);
if(postfix == NULL)
return NULL;
#define push(s) *stackp++ = s
#define pop() *--stackp
stackp = stack;
for(p=postfix; *p; p++){
switch(*p){
default:
s = state(*p, NULL, NULL);
push(frag(s, list1(&s->out)));
break;
case '.': /* catenate */
e2 = pop();
e1 = pop();
patch(e1.out, e2.start);
push(frag(e1.start, e2.out));
break;
case '|': /* alternate */
e2 = pop();
e1 = pop();
s = state(Split, e1.start, e2.start);
push(frag(s, append(e1.out, e2.out)));
break;
case '?': /* zero or one */
e = pop();
s = state(Split, e.start, NULL);
push(frag(s, append(e.out, list1(&s->out1))));
break;
case '*': /* zero or more */
e = pop();
s = state(Split, e.start, NULL);
patch(e.out, s);
push(frag(s, list1(&s->out1)));
break;
case '+': /* one or more */
e = pop();
s = state(Split, e.start, NULL);
patch(e.out, s);
push(frag(e.start, list1(&s->out1)));
break;
}
}
e = pop();
if(stackp != stack)
return NULL;
patch(e.out, &matchstate);
return e.start;
#undef pop
#undef push
}
typedef struct List List;
struct List
{
State **s;
int n;
};
List l1, l2;
static int listid;
void addstate(List*, State*);
void step(List*, int, List*);
List* startlist(State *start, List *l)
{
l->n = 0;
listid++;
addstate(l, start);
return l;
}
int ismatch(List *l)
{
int i;
for(i=0; i<l->n; i++)
if(l->s[i] == &matchstate)
return 1;
return 0;
}
void addstate(List *l, State *s)
{
if(s == NULL || s->lastlist == listid)
return;
s->lastlist = listid;
if(s->c == Split){
/* follow unlabeled arrows */
addstate(l, s->out);
addstate(l, s->out1);
return;
}
l->s[l->n++] = s;
}
void step(List *clist, int c, List *nlist)
{
int i;
State *s;
listid++;
nlist->n = 0;
for(i=0; i<clist->n; i++){
s = clist->s[i];
if(s->c == c)
addstate(nlist, s->out);
}
}
int match(State *start, char *s)
{
int i, c;
List *clist, *nlist, *t;
clist = startlist(start, &l1);
nlist = &l2;
for(; *s; s++){
c = *s & 0xFF;
step(clist, c, nlist);
t = clist; clist = nlist; nlist = t; /* swap clist, nlist */
}
return ismatch(clist);
}
int main(int argc, char **argv)
{
int i;
char *post;
State *start;
if(argc < 3){
fprintf(stderr, "usage: nfa regexp string...\n");
return 1;
}
printf("regexp: %s\n", argv[1]);
for (i=2; i<argc; i++)
printf("string[%d]: %s\n", i, argv[i]);
post = re2post(argv[1]);
if(post == NULL){
fprintf(stderr, "bad regexp %s\n", argv[1]);
return 1;
}
start = post2nfa(post);
if(start == NULL){
fprintf(stderr, "error in post2nfa %s\n", post);
return 1;
}
l1.s = malloc(nstate*sizeof l1.s[0]);
l2.s = malloc(nstate*sizeof l2.s[0]);
for(i=2; i<argc; i++)
if(match(start, argv[i]))
printf("%s Matches\n", argv[i]);
return 0;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.