file
stringlengths
18
26
data
stringlengths
2
1.05M
the_stack_data/242330337.c
/* * Derived from: * http://www.kernel.org/pub/linux/libs/klibc/ */ /* * strlcpy.c */ #include <string.h> size_t strlcpy(char *dst, const char *src, size_t size) { size_t bytes = 0; char *q = dst; const char *p = src; char ch; while ((ch = *p++)) { if (bytes + 1 < size) *q++ = ch; bytes++; } /* If size == 0 there is no space for a final null... */ if (size) *q = '\0'; return bytes; }
the_stack_data/140764514.c
int main() { int N; char a1[N]; *((char *)a1)=1; *((int *)a1)=1; short a2[N]; *((char *)a2)=1; *((int *)a2)=1; int a3[N]; *((char *)a3)=1; *((int *)a3)=1; assert(0); }
the_stack_data/456330.c
/* Explanation: This file is used for downloading missing dates. (NO MPI INVOLVED HERE) * Compile using: * gcc CURATE_DAY.c -o CURATE_DAY -std=c99 * ./CURATE_DAY */ #include <stdlib.h> #include <string.h> #include <stdio.h> int cmd; void fileRename(char * fileName) { FILE * fp; char line[80]; fp = fopen(fileName, "r"); while (fgets(line, sizeof(line), fp)) { cmd = system(line); } fclose(fp); } int main(int argc, char** argv) { if (argc != 2) { exit(-1); } else { fileRename(argv[1]); } return 0; }
the_stack_data/119669.c
#include <stdlib.h> #include <stdint.h> #include <stdio.h> /* Increment the first byte pointed to by a 64-bit word pointer */ void incr_u64_ptr_byte (uint64_t *x) { uint8_t *x_byte = (uint8_t*)x; (*x_byte)++; } typedef struct padded_struct { uint64_t padded1; uint8_t padded2; uint64_t padded3; uint8_t padded4; } padded_struct; /* Allocated a padded_struct */ padded_struct *alloc_padded_struct (void) { padded_struct *ret = malloc (sizeof(padded_struct)); ret->padded1 = 0; ret->padded2 = 0; ret->padded3 = 0; ret->padded4 = 0; return ret; } /* Increment all fields of a padded_struct */ void padded_struct_incr_all (padded_struct *p) { p->padded1++; p->padded2++; p->padded3++; p->padded4++; } /* Test endianness by reading the first byte of a word */ int64_t is_little_endian () { int64_t x = 1; int8_t is_le = *(int8_t*)(&x); return is_le; } int main (int argc, char **argv) { printf ("Little endian test: %lli\n", is_little_endian()); }
the_stack_data/3263943.c
// REQUIRES: x86-registered-target // Test with pch. // RUN: %clang_cc1 -triple x86_64-apple-darwin9 -emit-pch -o %t.pch %S/external-defs.h // RUN: %clang_cc1 -triple x86_64-apple-darwin9 -include-pch %t.pch -emit-llvm -o %t %s // RUN: grep "@x =.* global i32 0" %t | count 1 // RUN: not grep "@z" %t // RUN: grep "@x2 =.* global i32 19" %t | count 1 int x2 = 19; // RUN: grep "@incomplete_array =.* global .*1 x i32" %t | count 1 // RUN: grep "@incomplete_array2 =.* global .*17 x i32" %t | count 1 int incomplete_array2[17]; // RUN: grep "@incomplete_array3 =.* global .*1 x i32" %t | count 1 int incomplete_array3[]; struct S { int x, y; };
the_stack_data/243893860.c
/* * Copyright (c) 2013 Google Inc. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #include <stdio.h> /* * This will fail to compile if TEST_DEFINE was propagated from sharedlib to * program. */ #ifdef TEST_DEFINE #error TEST_DEFINE is already defined! #endif #define TEST_DEFINE 2 extern int staticLibFunc(); int main() { printf("%d\n", staticLibFunc()); printf("%d\n", TEST_DEFINE); return 0; }
the_stack_data/1048103.c
#include <stdio.h> #include <malloc.h> void main() { unsigned char limit_table[3], *p[3], age, member; int temp, sum; for (age = 0; age < 3; age++) { printf("\n%d0대 연령의 윗몸 일으키기 횟수\n", age + 2); printf("이 연령대는 몇 명입니까? : "); scanf("%d", &temp); limit_table[age] = (unsigned char)temp; p[age] = (unsigned char *)malloc(limit_table[age]); for (member = 0; member < limit_table[age]; member++) { printf("%dth : ", member + 1); scanf("%d", &temp); *(p[age] + member) = (unsigned char)temp; } } printf("\n\n연령별 평균 윗몸 일으키기 횟수\n"); for (age = 0; age < 3; age++) { sum = 0; printf("%d0대 : ", age + 2); for (member = 0; member < limit_table[age]; member++) { sum += *(p[age] + member); } printf("%5.2f\n", (double)sum / limit_table[age]); free(p[age]); } }
the_stack_data/9512924.c
/* ************************************************ username : smmehrab fullname : s.m.mehrabul islam email : [email protected] institute : university of dhaka, bangladesh session : 2017-2018 ************************************************ */ #include<stdio.h> int main() { int t,n; char s[]="HOSTED",ns[]="NOT HOSTED"; scanf("%d",&t); while(t--){ scanf("%d",&n); if(n==2010 || n==2015 || n==2016 || n==2017 || n==2019) puts(s); else puts(ns); } return 0; }
the_stack_data/76699655.c
/* * Square matrix multiplication * A[N][N] * B[N][N] = C[N][N] * */ #include <stdio.h> #include <stdlib.h> #include <time.h> #include <sys/timeb.h> #include <malloc.h> #define N 1024 //#define N 16 // read timer in second double read_timer() { struct timeb tm; ftime(&tm); return (double) tm.time + (double) tm.millitm / 1000.0; } void init(float **A) { int i, j; for (i = 0; i < N; i++) { for (j = 0; j < N; j++) { A[i][j] = (float)rand()/(float)(RAND_MAX/10.0); } } } void matmul_simd(float **A, float **B, float **C) { int i,j,k; float temp; for (i = 0; i < N; i++) { for (j = 0; j < N; j++) { temp = 0; #pragma omp simd reduction(+:temp) for (k = 0; k < N; k++) { temp += A[i][k] * B[j][k]; } C[i][j] = temp; } } } // Debug functions void print_matrix(float **matrix) { for (int i = 0; i<8; i++) { printf("["); for (int j = 0; j<8; j++) { printf("%.2f ", matrix[i][j]); } puts("]"); } puts(""); } void matmul_serial(float **A, float **B, float **C) { int i,j,k; float temp; for (i = 0; i < N; i++) { for (j = 0; j < N; j++) { temp = 0; for (k = 0; k < N; k++) { temp += A[i][k] * B[j][k]; } C[i][j] = temp; } } } float check(float **A, float **B){ float difference = 0; for(int i = 0;i<N; i++){ for (int j = 0; j<N; j++) { difference += A[i][j]- B[i][j];} } return difference; } // Main int main(int argc, char *argv[]) { //Set everything up float **A = malloc(sizeof(float*)*N); float **B = malloc(sizeof(float*)*N); float **C_simd = malloc(sizeof(float*)*N); float **C_serial = malloc(sizeof(float*)*N); float **BT = malloc(sizeof(float*)*N); for (int i = 0; i<N; i++) { A[i] = malloc(sizeof(float)*N); B[i] = malloc(sizeof(float)*N); C_simd[i] = malloc(sizeof(float)*N); C_serial[i] = malloc(sizeof(float)*N); BT[i] = malloc(sizeof(float)*N); } srand(time(NULL)); init(A); init(B); for(int line = 0; line<N; line++){ for(int col = 0; col<N; col++){ BT[line][col] = B[col][line]; } } int i; int num_runs = 20; //Warming up matmul_simd(A, BT, C_simd); matmul_serial(A, BT, C_serial); double elapsed = 0; double elapsed1 = read_timer(); for (i=0; i<num_runs; i++) matmul_simd(A, BT, C_simd); elapsed += (read_timer() - elapsed1); double elapsed_serial = 0; double elapsed_serial1 = read_timer(); for (i=0; i<num_runs; i++) matmul_serial(A, BT, C_serial); elapsed_serial += (read_timer() - elapsed_serial1); print_matrix(A); print_matrix(BT); puts("=\n"); print_matrix(C_simd); puts("---------------------------------"); print_matrix(C_serial); double gflops_omp = ((((2.0 * N) * N) * N * num_runs) / (1.0e9 * elapsed)); double gflops_serial = ((((2.0 * N) * N) * N * num_runs) / (1.0e9 * elapsed_serial)); printf("======================================================================================================\n"); printf("\tMatrix Multiplication: A[N][N] * B[N][N] = C[N][N], N=%d\n", N); printf("------------------------------------------------------------------------------------------------------\n"); printf("Performance:\t\tRuntime (s)\t GFLOPS\n"); printf("------------------------------------------------------------------------------------------------------\n"); printf("matmul_omp:\t\t%4f\t%4f\n", elapsed/num_runs, gflops_omp); printf("matmul_serial:\t\t%4f\t%4f\n", elapsed_serial/num_runs, gflops_serial); printf("Correctness check: %f\n", check(C_simd,C_serial)); return 0; }
the_stack_data/173578001.c
#include<stdio.h> typedef unsigned char *byte_pointer; void show_bytes(byte_pointer start, int len){ for(int i = 0; i < len; ++i){ printf("%.2x", start[i]); } printf("\n"); } void show_int(int x){ show_bytes((byte_pointer) &x, sizeof(int)); } void show_float(float x){ show_bytes((byte_pointer) &x, sizeof(float)); } void show_pointer(void *x){ show_bytes((byte_pointer) &x, sizeof(void*)); } void test_show_bytes(int val){ int ival = val; float fval = val; int* pval = &ival; show_int(ival); show_float(fval); show_pointer(pval); } int main(){ int test_num = 1024; test_show_bytes(test_num); return 0; }
the_stack_data/82950124.c
/* This testcase is part of GDB, the GNU debugger. Copyright (C) 2014-2015 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ int main (void) { int x = 1, y = 1, z = 1; ++x; /* before dprintf */ ++y; /* set dprintf here */ ++z; /* after dprintf */ return 0; }
the_stack_data/32949618.c
/* Name P10_1.c Description Count the occurences of a given character in a given string Author MCUxDaredevil (https://github.com/mcuxdaredevil) Github Page https://github.com/MCUxDaredevil/c-codes-sem1 Support URL https://github.com/MCUxDaredevil/c-codes-sem1/issues Discussions https://github.com/MCUxDaredevil/c-codes-sem1/discussions License MIT */ #include<stdio.h> #include<string.h> int main() { int count,i; char str[100],a; printf("\n\nEnter the string:\n"); gets(str); printf("\nEnter the character to look for: "); scanf(" %c", &a); for(i=0; i<100; i++){ if(str[i] == '\0') break; if(str[i] == a) count++; } printf("\n\n\'%c\' occurs %d times in the string\n\n",a,count); return 0; }
the_stack_data/173579389.c
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <pthread.h> void *tfn(void *arg) { int n = 3; while (n--) { printf("thread count %d\n", n); sleep(1); } pthread_exit((void *)1); } int main(void) { pthread_t tid; void *tret; int err; #if 1 pthread_attr_t attr; /*通过线程属性来设置游离态*/ pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); pthread_create(&tid, &attr, tfn, NULL); pthread_attr_destroy(&attr); #else pthread_create(&tid, NULL, tfn, NULL); pthread_detach(tid); //让线程分离 ----自动退出,无系统残留资源 #endif while (1) { sleep(1); err = pthread_join(tid, &tret); if (err != 0) fprintf(stderr, "thread_join error: %s\n", strerror(err)); else fprintf(stderr, "thread exit code %d\n", (int)tret); } return 0; }
the_stack_data/954900.c
#ifndef IN_GENERATED_CCODE #define IN_GENERATED_CCODE #define U_DISABLE_RENAMING 1 #include "unicode/umachine.h" #endif U_CDECL_BEGIN const struct { double bogus; uint8_t bytes[31824]; } icudt57l_icu_internal_compound_d5_cnv={ 0.0, { 128,0,218,39,20,0,0,0,0,0,2,0,99,110,118,116, 6,2,0,0,57,1,0,0,32,67,111,112,121,114,105,103, 104,116,32,40,67,41,32,50,48,49,54,44,32,73,110,116, 101,114,110,97,116,105,111,110,97,108,32,66,117,115,105,110, 101,115,115,32,77,97,99,104,105,110,101,115,32,67,111,114, 112,111,114,97,116,105,111,110,32,97,110,100,32,111,116,104, 101,114,115,46,32,65,108,108,32,82,105,103,104,116,115,32, 82,101,115,101,114,118,101,100,46,32,0,0,0,0,0,0, 100,0,0,0,105,99,117,45,105,110,116,101,114,110,97,108, 45,99,111,109,112,111,117,110,100,45,100,53,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,255,2,1,2,63,0,0,0,1,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,4,4,215,0,3,0,0,0,0,0,0,0, 32,12,0,0,200,56,0,0,200,79,0,0,1,168,121,0, 32,35,0,0,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 254,255,96,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,0,0,0,1,127,0,0,1, 254,0,0,1,125,1,0,1,252,1,0,2,252,1,0,2, 252,1,0,2,252,1,0,2,252,1,0,2,252,1,0,2, 252,1,0,2,252,1,0,2,252,1,0,2,252,1,0,2, 252,1,0,2,252,1,0,2,252,1,0,2,252,1,0,2, 252,1,0,2,252,1,0,2,252,1,0,2,252,1,0,2, 252,1,0,2,252,1,0,2,252,1,0,2,252,1,0,2, 252,1,0,2,252,1,0,2,252,1,0,2,252,1,0,2, 252,1,0,2,252,1,0,2,252,1,0,2,252,1,0,1, 123,2,0,2,123,2,0,2,123,2,0,2,123,2,0,2, 123,2,0,2,123,2,0,2,123,2,0,1,250,2,0,1, 121,3,0,2,121,3,0,1,248,3,0,1,119,4,0,1, 246,4,0,2,246,4,0,1,117,5,0,2,117,5,0,2, 117,5,0,2,117,5,0,2,117,5,0,1,244,5,0,1, 115,6,0,2,115,6,0,1,242,6,0,1,113,7,0,1, 240,7,0,1,111,8,0,1,238,8,0,2,238,8,0,2, 238,8,0,1,109,9,0,1,236,9,0,1,107,10,0,1, 234,10,0,1,105,11,0,1,232,11,0,1,103,12,0,1, 230,12,0,1,101,13,0,1,228,13,0,1,99,14,0,2, 99,14,0,1,226,14,0,1,97,15,0,1,224,15,0,2, 224,15,0,1,95,16,0,1,222,16,0,1,93,17,0,2, 93,17,0,1,220,17,0,1,91,18,0,1,218,18,0,1, 89,19,0,1,216,19,0,1,87,20,0,1,214,20,0,1, 85,21,0,1,212,21,0,1,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,0,0,64,128,1,0,64,128,2,0,64,128, 3,0,64,128,4,0,64,128,5,0,64,128,6,0,64,128, 7,0,64,128,8,0,64,128,9,0,64,128,10,0,64,128, 11,0,64,128,12,0,64,128,13,0,64,128,14,0,64,128, 15,0,64,128,16,0,64,128,17,0,64,128,18,0,64,128, 19,0,64,128,20,0,64,128,21,0,64,128,22,0,64,128, 23,0,64,128,24,0,64,128,25,0,64,128,26,0,64,128, 27,0,64,128,28,0,64,128,29,0,64,128,30,0,64,128, 31,0,64,128,32,0,64,128,33,0,64,128,34,0,64,128, 35,0,64,128,36,0,64,128,37,0,64,128,38,0,64,128, 39,0,64,128,40,0,64,128,41,0,64,128,42,0,64,128, 43,0,64,128,44,0,64,128,45,0,64,128,46,0,64,128, 47,0,64,128,48,0,64,128,49,0,64,128,50,0,64,128, 51,0,64,128,52,0,64,128,53,0,64,128,54,0,64,128, 55,0,64,128,56,0,64,128,57,0,64,128,58,0,64,128, 59,0,64,128,60,0,64,128,61,0,64,128,62,0,64,128, 63,0,64,128,64,0,64,128,65,0,64,128,66,0,64,128, 67,0,64,128,68,0,64,128,69,0,64,128,70,0,64,128, 71,0,64,128,72,0,64,128,73,0,64,128,74,0,64,128, 75,0,64,128,76,0,64,128,77,0,64,128,78,0,64,128, 79,0,64,128,80,0,64,128,81,0,64,128,82,0,64,128, 83,0,64,128,84,0,64,128,85,0,64,128,86,0,64,128, 87,0,64,128,88,0,64,128,89,0,64,128,90,0,64,128, 91,0,64,128,92,0,64,128,93,0,64,128,94,0,64,128, 95,0,64,128,96,0,64,128,97,0,64,128,98,0,64,128, 99,0,64,128,100,0,64,128,101,0,64,128,102,0,64,128, 103,0,64,128,104,0,64,128,105,0,64,128,106,0,64,128, 107,0,64,128,108,0,64,128,109,0,64,128,110,0,64,128, 111,0,64,128,112,0,64,128,113,0,64,128,114,0,64,128, 115,0,64,128,116,0,64,128,117,0,64,128,118,0,64,128, 119,0,64,128,120,0,64,128,121,0,64,128,122,0,64,128, 123,0,64,128,124,0,64,128,125,0,64,128,126,0,64,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,255,255,112,128,255,255,112,128,255,255,112,128, 255,255,112,128,254,255,96,128,254,255,96,128,254,255,96,128, 254,255,96,128,254,255,96,128,254,255,96,128,254,255,96,128, 254,255,96,128,254,255,96,128,254,255,96,128,254,255,96,128, 254,255,96,128,254,255,96,128,254,255,96,128,254,255,96,128, 254,255,96,128,254,255,96,128,254,255,96,128,254,255,96,128, 254,255,96,128,254,255,96,128,254,255,96,128,254,255,96,128, 254,255,96,128,254,255,96,128,254,255,96,128,254,255,96,128, 254,255,96,128,254,255,96,128,254,255,96,128,254,255,96,128, 254,255,96,128,254,255,96,128,254,255,96,128,254,255,96,128, 254,255,96,128,254,255,96,128,254,255,96,128,254,255,96,128, 254,255,96,128,254,255,96,128,254,255,96,128,254,255,96,128, 254,255,96,128,254,255,96,128,254,255,96,128,254,255,96,128, 254,255,96,128,254,255,96,128,254,255,96,128,254,255,96,128, 254,255,96,128,254,255,96,128,254,255,96,128,254,255,96,128, 254,255,96,128,254,255,96,128,254,255,96,128,254,255,96,128, 254,255,96,128,254,255,96,128,254,255,96,128,254,255,96,128, 254,255,96,128,254,255,96,128,254,255,96,128,254,255,96,128, 254,255,96,128,254,255,96,128,254,255,96,128,254,255,96,128, 254,255,96,128,254,255,96,128,254,255,96,128,254,255,96,128, 254,255,96,128,254,255,96,128,254,255,96,128,254,255,96,128, 254,255,96,128,254,255,96,128,254,255,96,128,254,255,96,128, 254,255,96,128,254,255,96,128,254,255,96,128,254,255,96,128, 254,255,96,128,254,255,96,128,254,255,96,128,254,255,96,128, 254,255,96,128,254,255,96,128,254,255,96,128,254,255,96,128, 254,255,96,128,254,255,96,128,254,255,96,128,254,255,96,128, 254,255,96,128,254,255,96,128,254,255,96,128,254,255,96,128, 254,255,96,128,254,255,96,128,254,255,96,128,254,255,96,128, 254,255,96,128,254,255,96,128,254,255,96,128,254,255,96,128, 254,255,96,128,254,255,96,128,254,255,96,128,254,255,96,128, 254,255,96,128,254,255,96,128,254,255,96,128,254,255,96,128, 254,255,96,128,254,255,96,128,254,255,96,128,254,255,96,128, 254,255,96,128,254,255,96,128,254,255,96,128,254,255,96,128, 255,255,112,128,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,48,254,254,255,254,255, 80,254,81,254,82,254,254,255,84,254,85,254,86,254,87,254, 49,254,254,255,50,254,19,32,254,255,254,255,254,255,254,255, 254,255,254,255,53,254,54,254,254,255,254,255,55,254,56,254, 254,255,254,255,57,254,58,254,254,255,254,255,59,254,60,254, 254,255,254,255,61,254,62,254,254,255,254,255,63,254,64,254, 254,255,254,255,65,254,66,254,254,255,254,255,67,254,68,254, 89,254,90,254,91,254,92,254,93,254,94,254,254,255,254,255, 254,255,254,255,29,48,30,48,254,255,53,32,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,163,50,5,33,254,255,254,255,254,255,254,255, 73,254,74,254,77,254,78,254,75,254,76,254,95,254,96,254, 97,254,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 98,254,99,254,100,254,102,254,101,254,254,255,254,255,254,255, 254,255,254,255,31,34,191,34,210,51,209,51,254,255,254,255, 254,255,254,255,254,255,254,255,65,38,9,38,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,21,34,104,254,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,105,254,106,254,107,254, 213,51,254,255,254,255,254,255,206,51,254,255,254,255,254,255, 254,255,254,255,89,81,91,81,94,81,93,81,97,81,99,81, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,231,85,254,255,254,255,129,37,130,37,131,37,132,37, 133,37,134,37,135,37,136,37,143,37,142,37,141,37,140,37, 139,37,138,37,137,37,254,255,254,255,254,255,254,255,254,255, 148,37,254,255,254,255,149,37,254,255,254,255,254,255,254,255, 109,37,110,37,112,37,111,37,80,37,94,37,106,37,97,37, 226,37,227,37,229,37,228,37,113,37,114,37,115,37,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,33,48,34,48,35,48,36,48, 37,48,38,48,39,48,40,48,41,48,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,0,36, 1,36,2,36,3,36,4,36,5,36,6,36,7,36,8,36, 9,36,10,36,11,36,12,36,13,36,14,36,15,36,16,36, 17,36,18,36,19,36,20,36,21,36,22,36,23,36,24,36, 25,36,26,36,27,36,28,36,29,36,30,36,31,36,33,36, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,234,86,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,134,98,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,87,103,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,197,89, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,203,98,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,172,108,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,168,115,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,78,82,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,101,95,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,88,92,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,24,104,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 138,109,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,122,80, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,111,80,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 32,89,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,93,92,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,95,85,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,43,108,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,13,116,254,255,254,255,254,255, 254,255,34,117,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,196,94,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,105,110,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 85,125,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,9,145,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,109,88,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,18,95,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,188,110,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,127,120,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,181,124, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,115,129, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,104,138,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,230,141,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,61,146,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,125,88,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,70,95,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,163,105,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,210,140,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,172,146,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,5,81,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,46,86,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,162,100, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,96,111, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,135,119,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,43,142,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,179,152,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,121,86,254,255, 254,255,254,255,254,255,254,255,101,86,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,180,111,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,75,122,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,144,86,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 36,91,254,255,55,92,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,148,106,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,92,107,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,244,113,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,52,126,254,255,72,126,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,61,137,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,94,95,254,255,254,255, 254,255,254,255,254,255,6,101,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,72,127,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,162,147,179,147,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,249,151,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,63,153,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,229,106,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,188,152, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 240,124,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,214,116, 254,255,254,255,211,119,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 108,137,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,92,159,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,212,93,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,252,137,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,226,129,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,100,148,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,254,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,96,0,32,0, 32,0,32,0,32,0,32,0,32,0,32,0,160,0,224,0, 32,0,32,0,32,1,32,0,32,0,32,0,32,0,32,0, 32,0,32,0,96,1,140,1,200,1,8,2,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0,0,0,0,225,162,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,201,162,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,202,162,161,194,162,194, 163,194,164,194,165,194,166,194,167,194,168,194,169,194,170,194, 171,194,172,194,173,194,174,194,175,194,176,194,177,194,178,194, 179,194,180,194,181,194,182,194,183,194,184,194,185,194,186,194, 187,194,188,194,189,194,190,194,191,194,192,194,0,0,193,194, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,196,163,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,197,163,0,0,0,0,199,163, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 198,163,0,0,0,0,192,163,193,163,195,163,194,163,204,163, 205,163,206,163,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,164,163, 165,163,166,163,167,163,168,163,169,163,170,163,171,163,178,163, 177,163,176,163,175,163,174,163,173,163,172,163,0,0,0,0, 0,0,0,0,184,163,187,163,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0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0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,241,239,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,206,249,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,243,247,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,212,251,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,171,161,182,161, 184,161,0,0,0,0,192,161,193,161,196,161,197,161,200,161, 201,161,204,161,205,161,208,161,209,161,212,161,213,161,216,161, 217,161,220,161,221,161,0,0,0,0,0,0,0,0,167,162, 168,162,171,162,172,162,169,162,170,162,0,0,174,161,175,161, 176,161,0,0,178,161,179,161,180,161,181,161,0,0,222,161, 223,161,224,161,225,161,226,161,227,161,173,162,174,162,175,162, 191,162,192,162,193,162,195,162,194,162,0,0,226,162,236,162, 237,162,238,162,0,0,0,0,0,0,0,0,64,0,128,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0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0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,80,3, 0,0,0,0,144,3,192,3,0,0,0,0,0,0,0,4, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,48,4,0,0,80,4,128,4,176,4, 240,4,16,5,0,0,0,0,0,0,0,0,0,0,64,5, 0,0,0,0,128,5,0,0,0,0,192,5,0,0,0,0, 0,0,0,0,224,5,0,0,0,0,0,0,16,6,80,6, 0,0,0,0,0,0,0,0,0,0,128,6,0,0,0,0, 0,0,192,6,240,6,48,7,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 112,7,176,7,0,0,0,0,0,0,0,0,0,0,0,0, 208,7,0,0,16,8,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,64,8,0,0,0,0,112,8,0,0, 0,0,0,0,0,0,0,0,144,8,0,0,0,0,0,0, 192,8,224,8,0,0,16,9,0,0,0,0,48,9,0,0, 96,9,0,0,0,0,0,0,160,9,0,0,0,0,192,9, 240,9,0,0,0,0,48,10,96,10,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,160,10,0,0,0,0, 0,0,0,0,0,0,0,0,224,10,0,0,32,11,0,0, 0,0,80,11,112,11,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,176,11,224,11,0,0,0,12, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,12, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 80,12,144,12,0,0,208,12,0,0,0,0,240,12,48,13, 0,0,0,0,0,0,112,13,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,128,13,0,0,192,13,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0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,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,1,0,0,0,0,0,1,0,0,128,170,170,170,170 } }; U_CDECL_END
the_stack_data/14199655.c
// this source is derived from CHILL AST originally from file '/uufs/chpc.utah.edu/common/home/u1142914/lib/ytopt_vinu/polybench/polybench-code/stencils/fdtd-2d/kernel.c' as parsed by frontend compiler rose void kernel_fdtd_2d(int tmax, int nx, int ny, double ex[1000 + 0][1200 + 0], double ey[1000 + 0][1200 + 0], double hz[1000 + 0][1200 + 0], double _fict_[500 + 0]) { int t10; int t8; int t6; int t4; int t2; for (t2 = 0; t2 <= tmax - 1; t2 += 1) { for (t4 = 0; t4 <= ny - 1; t4 += 1) ey[0][t4] = _fict_[t2]; #pragma omp parallel for for (t4 = 1; t4 <= nx - 1; t4 += 32) for (t6 = t4; t6 <= (t4 + 31 < nx - 1 ? t4 + 31 : nx - 1); t6 += 1) for (t8 = 0; t8 <= ny - 1; t8 += 32) for (t10 = t8; t10 <= (ny - 1 < t8 + 31 ? ny - 1 : t8 + 31); t10 += 1) ey[t6][t10] = ey[t6][t10] - 0.5 * (hz[t6][t10] - hz[t6 - 1][t10]); #pragma omp parallel for for (t4 = 0; t4 <= nx - 1; t4 += 32) for (t6 = t4; t6 <= (t4 + 31 < nx - 1 ? t4 + 31 : nx - 1); t6 += 1) for (t8 = 1; t8 <= ny - 1; t8 += 32) for (t10 = t8; t10 <= (ny - 1 < t8 + 31 ? ny - 1 : t8 + 31); t10 += 1) ex[t6][t10] = ex[t6][t10] - 0.5 * (hz[t6][t10] - hz[t6][t10 - 1]); #pragma omp parallel for for (t4 = 0; t4 <= nx - 2; t4 += 32) for (t6 = t4; t6 <= (t4 + 31 < nx - 2 ? t4 + 31 : nx - 2); t6 += 1) for (t8 = 0; t8 <= ny - 2; t8 += 32) for (t10 = t8; t10 <= (ny - 2 < t8 + 31 ? ny - 2 : t8 + 31); t10 += 1) hz[t6][t10] = hz[t6][t10] - 0.69999999999999996 * (ex[t6][t10 + 1] - ex[t6][t10] + ey[t6 + 1][t10] - ey[t6][t10]); } }
the_stack_data/106725.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)%p; if(d.re>p) d.re=d.re%p; if(d.re<0) d.re=d.re+p; 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); if(a.re>p) a.re=a.re%p; if(a.re<0) a.re=b.re+p; if(a.im>p) a.im=b.im%p; if(a.im<0) a.re=a.im+p; if(b.re>p) b.re=a.re%p; if(b.re<0) b.re=b.re+p; if(b.im>p) b.im=b.im%p; if(b.im<0) b.re=a.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=g.im%p; if(g.im<0) g.im+=p; printf("ans=%lld,%lld\n",g.re,g.im); 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,test[431][431][2]={0},tmp[431]={0}; 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=161;//161; //162; a2.im=208;//208;//172; a2=j_inv(a2); c.re=132; c.im=0; j_inv(c); //exit(1); printf("j=%d %d\n",a2.re,a2.im); /* c=a2; while(1){ a2=j_inv(a2); count++; if(247 == a2.re){ printf("%d %d %d\n",a2.re,a2.im,count); scanf("%d",&n); // exit(1); } if(a2.re < 0 && a2.im < 0){ printf("baka\n"); exit(1); } count++; } */ o.im=0; //同じj不変量を持つ楕円曲線を総探索する 20200804 for(i=0;i<p;i++){ o.re=i; for(k=0;k<p;k++){ o.im=k; r=j_inv(o); // printf("%d %d %d %d\n",r.re,r.im,i,k); //scanf("%d",&n); // if(test[r.re][0]==512 && r.re>=0 && r.im==0){ test[i][k][0]=r.re; test[i][k][1]=r.im; //count++; } // if(test[r.re].im!=r.im){ //count++; //test[r.re].im=r.im; } for(i=0;i<p;i++){ for(k=0;k<p;k++){ //if(test[i][k]>=0){ // tmp[test[i][0]]=-1; printf("j_inv=%d,%d %d %d\n",i,k,test[i][k][0],test[i][k][1]); //count++; } //} } /* for(i=0;i<p;i++){ if(tmp[i]== -1) count++; } printf("%d\n",count); */ //exit(1); /* //j-invariant if(r.re==304 && r.im==364){ printf("(i,k)=%d %d\n",i,k); //scanf("%d",&n); //count++; } } */ c.re=109; c.im=0; j_inv(c); printf("p=%d count=%d\n",p,count); return 0; }
the_stack_data/992888.c
/* PR c/7102 */ /* Verify that GCC zero-extends integer constants in unsigned binary operations. */ typedef unsigned char u8; u8 fun(u8 y) { u8 x=((u8)255)/y; return x; } int main(void) { if (fun((u8)2) != 127) abort (); return 0; }
the_stack_data/31388728.c
//@ ltl invariant negative: ( ([] ( (<> ( ( AP((gate_l1 != 0)) && (! AP((gate_l0 != 0)))) && ( (X AP((gate_l1 != 0))) && (X AP((gate_l0 != 0)))))) || (! ( ( (! AP((gate_l0 != 0))) && (! AP((gate_l1 != 0)))) && ( (! (X AP((gate_l1 != 0)))) && (X AP((gate_l0 != 0)))))))) || (! ([] (<> AP((1.0 <= _diverge_delta)))))); extern float __VERIFIER_nondet_float(void); extern int __VERIFIER_nondet_int(void); char __VERIFIER_nondet_bool(void) { return __VERIFIER_nondet_int() != 0; } float _diverge_delta, _x__diverge_delta; char t2_l1, _x_t2_l1; char t2_l0, _x_t2_l0; char t2_evt1, _x_t2_evt1; char t2_evt0, _x_t2_evt0; char t1_l1, _x_t1_l1; char t1_l0, _x_t1_l0; char t1_evt1, _x_t1_evt1; char t1_evt0, _x_t1_evt0; float t1_x, _x_t1_x; char t0_l1, _x_t0_l1; char t0_evt1, _x_t0_evt1; char t0_evt0, _x_t0_evt0; float t0_x, _x_t0_x; float delta, _x_delta; float t2_x, _x_t2_x; char gate_l0, _x_gate_l0; char controller_l0, _x_controller_l0; char gate_l1, _x_gate_l1; float gate_y, _x_gate_y; char controller_l1, _x_controller_l1; char gate_evt0, _x_gate_evt0; char controller_evt0, _x_controller_evt0; char controller_evt1, _x_controller_evt1; char gate_evt1, _x_gate_evt1; float controller_z, _x_controller_z; char t0_l0, _x_t0_l0; char controller_evt2, _x_controller_evt2; int controller_cnt, _x_controller_cnt; int main() { _diverge_delta = __VERIFIER_nondet_float(); t2_l1 = __VERIFIER_nondet_bool(); t2_l0 = __VERIFIER_nondet_bool(); t2_evt1 = __VERIFIER_nondet_bool(); t2_evt0 = __VERIFIER_nondet_bool(); t1_l1 = __VERIFIER_nondet_bool(); t1_l0 = __VERIFIER_nondet_bool(); t1_evt1 = __VERIFIER_nondet_bool(); t1_evt0 = __VERIFIER_nondet_bool(); t1_x = __VERIFIER_nondet_float(); t0_l1 = __VERIFIER_nondet_bool(); t0_evt1 = __VERIFIER_nondet_bool(); t0_evt0 = __VERIFIER_nondet_bool(); t0_x = __VERIFIER_nondet_float(); delta = __VERIFIER_nondet_float(); t2_x = __VERIFIER_nondet_float(); gate_l0 = __VERIFIER_nondet_bool(); controller_l0 = __VERIFIER_nondet_bool(); gate_l1 = __VERIFIER_nondet_bool(); gate_y = __VERIFIER_nondet_float(); controller_l1 = __VERIFIER_nondet_bool(); gate_evt0 = __VERIFIER_nondet_bool(); controller_evt0 = __VERIFIER_nondet_bool(); controller_evt1 = __VERIFIER_nondet_bool(); gate_evt1 = __VERIFIER_nondet_bool(); controller_z = __VERIFIER_nondet_float(); t0_l0 = __VERIFIER_nondet_bool(); controller_evt2 = __VERIFIER_nondet_bool(); controller_cnt = __VERIFIER_nondet_int(); int __ok = (((((((( !(t2_l0 != 0)) && ( !(t2_l1 != 0))) && (t2_x == 0.0)) && (((( !(t2_l0 != 0)) && ( !(t2_l1 != 0))) || ((t2_l0 != 0) && ( !(t2_l1 != 0)))) || (((t2_l1 != 0) && ( !(t2_l0 != 0))) || ((t2_l0 != 0) && (t2_l1 != 0))))) && (((( !(t2_evt0 != 0)) && ( !(t2_evt1 != 0))) || ((t2_evt0 != 0) && ( !(t2_evt1 != 0)))) || (((t2_evt1 != 0) && ( !(t2_evt0 != 0))) || ((t2_evt0 != 0) && (t2_evt1 != 0))))) && ((( !(t2_l0 != 0)) && ( !(t2_l1 != 0))) || (t2_x <= 5.0))) && ((((((( !(t1_l0 != 0)) && ( !(t1_l1 != 0))) && (t1_x == 0.0)) && (((( !(t1_l0 != 0)) && ( !(t1_l1 != 0))) || ((t1_l0 != 0) && ( !(t1_l1 != 0)))) || (((t1_l1 != 0) && ( !(t1_l0 != 0))) || ((t1_l0 != 0) && (t1_l1 != 0))))) && (((( !(t1_evt0 != 0)) && ( !(t1_evt1 != 0))) || ((t1_evt0 != 0) && ( !(t1_evt1 != 0)))) || (((t1_evt1 != 0) && ( !(t1_evt0 != 0))) || ((t1_evt0 != 0) && (t1_evt1 != 0))))) && ((( !(t1_l0 != 0)) && ( !(t1_l1 != 0))) || (t1_x <= 5.0))) && ((((((( !(t0_l0 != 0)) && ( !(t0_l1 != 0))) && (t0_x == 0.0)) && (((( !(t0_l0 != 0)) && ( !(t0_l1 != 0))) || ((t0_l0 != 0) && ( !(t0_l1 != 0)))) || (((t0_l1 != 0) && ( !(t0_l0 != 0))) || ((t0_l0 != 0) && (t0_l1 != 0))))) && (((( !(t0_evt0 != 0)) && ( !(t0_evt1 != 0))) || ((t0_evt0 != 0) && ( !(t0_evt1 != 0)))) || (((t0_evt1 != 0) && ( !(t0_evt0 != 0))) || ((t0_evt0 != 0) && (t0_evt1 != 0))))) && ((( !(t0_l0 != 0)) && ( !(t0_l1 != 0))) || (t0_x <= 5.0))) && (((((((( !(controller_l0 != 0)) && ( !(controller_l1 != 0))) && (controller_z == 0.0)) && (((( !(controller_l0 != 0)) && ( !(controller_l1 != 0))) || ((controller_l0 != 0) && ( !(controller_l1 != 0)))) || (((controller_l1 != 0) && ( !(controller_l0 != 0))) || ((controller_l0 != 0) && (controller_l1 != 0))))) && (((( !(controller_evt2 != 0)) && (( !(controller_evt0 != 0)) && ( !(controller_evt1 != 0)))) || (( !(controller_evt2 != 0)) && ((controller_evt0 != 0) && ( !(controller_evt1 != 0))))) || ((( !(controller_evt2 != 0)) && ((controller_evt1 != 0) && ( !(controller_evt0 != 0)))) || ((( !(controller_evt2 != 0)) && ((controller_evt0 != 0) && (controller_evt1 != 0))) || ((controller_evt2 != 0) && (( !(controller_evt0 != 0)) && ( !(controller_evt1 != 0)))))))) && (((((controller_cnt == 0) || (controller_cnt == 1)) || (controller_cnt == 2)) || (controller_cnt == 3)) || (controller_cnt == 4))) && ((controller_z <= 1.0) || ( !(((controller_l0 != 0) && ( !(controller_l1 != 0))) || ((controller_l0 != 0) && (controller_l1 != 0)))))) && (((((((( !(gate_l0 != 0)) && ( !(gate_l1 != 0))) && (gate_y == 0.0)) && (((( !(gate_l0 != 0)) && ( !(gate_l1 != 0))) || ((gate_l0 != 0) && ( !(gate_l1 != 0)))) || (((gate_l1 != 0) && ( !(gate_l0 != 0))) || ((gate_l0 != 0) && (gate_l1 != 0))))) && (((( !(gate_evt0 != 0)) && ( !(gate_evt1 != 0))) || ((gate_evt0 != 0) && ( !(gate_evt1 != 0)))) || (((gate_evt1 != 0) && ( !(gate_evt0 != 0))) || ((gate_evt0 != 0) && (gate_evt1 != 0))))) && ((gate_y <= 1.0) || ( !((gate_l0 != 0) && ( !(gate_l1 != 0)))))) && ((gate_y <= 2.0) || ( !((gate_l0 != 0) && (gate_l1 != 0))))) && (0.0 <= delta)))))) && (delta == _diverge_delta)); while (__ok) { _x__diverge_delta = __VERIFIER_nondet_float(); _x_t2_l1 = __VERIFIER_nondet_bool(); _x_t2_l0 = __VERIFIER_nondet_bool(); _x_t2_evt1 = __VERIFIER_nondet_bool(); _x_t2_evt0 = __VERIFIER_nondet_bool(); _x_t1_l1 = __VERIFIER_nondet_bool(); _x_t1_l0 = __VERIFIER_nondet_bool(); _x_t1_evt1 = __VERIFIER_nondet_bool(); _x_t1_evt0 = __VERIFIER_nondet_bool(); _x_t1_x = __VERIFIER_nondet_float(); _x_t0_l1 = __VERIFIER_nondet_bool(); _x_t0_evt1 = __VERIFIER_nondet_bool(); _x_t0_evt0 = __VERIFIER_nondet_bool(); _x_t0_x = __VERIFIER_nondet_float(); _x_delta = __VERIFIER_nondet_float(); _x_t2_x = __VERIFIER_nondet_float(); _x_gate_l0 = __VERIFIER_nondet_bool(); _x_controller_l0 = __VERIFIER_nondet_bool(); _x_gate_l1 = __VERIFIER_nondet_bool(); _x_gate_y = __VERIFIER_nondet_float(); _x_controller_l1 = __VERIFIER_nondet_bool(); _x_gate_evt0 = __VERIFIER_nondet_bool(); _x_controller_evt0 = __VERIFIER_nondet_bool(); _x_controller_evt1 = __VERIFIER_nondet_bool(); _x_gate_evt1 = __VERIFIER_nondet_bool(); _x_controller_z = __VERIFIER_nondet_float(); _x_t0_l0 = __VERIFIER_nondet_bool(); _x_controller_evt2 = __VERIFIER_nondet_bool(); _x_controller_cnt = __VERIFIER_nondet_int(); __ok = (((((((((((((((((((( !(_x_t2_l0 != 0)) && ( !(_x_t2_l1 != 0))) || ((_x_t2_l0 != 0) && ( !(_x_t2_l1 != 0)))) || (((_x_t2_l1 != 0) && ( !(_x_t2_l0 != 0))) || ((_x_t2_l0 != 0) && (_x_t2_l1 != 0)))) && (((( !(_x_t2_evt0 != 0)) && ( !(_x_t2_evt1 != 0))) || ((_x_t2_evt0 != 0) && ( !(_x_t2_evt1 != 0)))) || (((_x_t2_evt1 != 0) && ( !(_x_t2_evt0 != 0))) || ((_x_t2_evt0 != 0) && (_x_t2_evt1 != 0))))) && ((( !(_x_t2_l0 != 0)) && ( !(_x_t2_l1 != 0))) || (_x_t2_x <= 5.0))) && (((((t2_l0 != 0) == (_x_t2_l0 != 0)) && ((t2_l1 != 0) == (_x_t2_l1 != 0))) && ((delta + (t2_x + (-1.0 * _x_t2_x))) == 0.0)) || ( !(( !(delta <= 0.0)) || (( !(t2_evt0 != 0)) && ( !(t2_evt1 != 0))))))) && (((((_x_t2_l0 != 0) && ( !(_x_t2_l1 != 0))) && ((t2_evt0 != 0) && ( !(t2_evt1 != 0)))) && (_x_t2_x == 0.0)) || ( !((( !(t2_l0 != 0)) && ( !(t2_l1 != 0))) && ((delta == 0.0) && ( !(( !(t2_evt0 != 0)) && ( !(t2_evt1 != 0))))))))) && (((((_x_t2_l1 != 0) && ( !(_x_t2_l0 != 0))) && ( !(t2_x <= 2.0))) && (((t2_evt0 != 0) && (t2_evt1 != 0)) && (t2_x == _x_t2_x))) || ( !(((t2_l0 != 0) && ( !(t2_l1 != 0))) && ((delta == 0.0) && ( !(( !(t2_evt0 != 0)) && ( !(t2_evt1 != 0))))))))) && (((t2_x == _x_t2_x) && (((_x_t2_l0 != 0) && (_x_t2_l1 != 0)) && ((t2_evt0 != 0) && (t2_evt1 != 0)))) || ( !(((t2_l1 != 0) && ( !(t2_l0 != 0))) && ((delta == 0.0) && ( !(( !(t2_evt0 != 0)) && ( !(t2_evt1 != 0))))))))) && ((((( !(_x_t2_l0 != 0)) && ( !(_x_t2_l1 != 0))) && (t2_x <= 5.0)) && (((t2_evt1 != 0) && ( !(t2_evt0 != 0))) && (t2_x == _x_t2_x))) || ( !(((t2_l0 != 0) && (t2_l1 != 0)) && ((delta == 0.0) && ( !(( !(t2_evt0 != 0)) && ( !(t2_evt1 != 0))))))))) && (((((((((((( !(_x_t1_l0 != 0)) && ( !(_x_t1_l1 != 0))) || ((_x_t1_l0 != 0) && ( !(_x_t1_l1 != 0)))) || (((_x_t1_l1 != 0) && ( !(_x_t1_l0 != 0))) || ((_x_t1_l0 != 0) && (_x_t1_l1 != 0)))) && (((( !(_x_t1_evt0 != 0)) && ( !(_x_t1_evt1 != 0))) || ((_x_t1_evt0 != 0) && ( !(_x_t1_evt1 != 0)))) || (((_x_t1_evt1 != 0) && ( !(_x_t1_evt0 != 0))) || ((_x_t1_evt0 != 0) && (_x_t1_evt1 != 0))))) && ((( !(_x_t1_l0 != 0)) && ( !(_x_t1_l1 != 0))) || (_x_t1_x <= 5.0))) && (((((t1_l0 != 0) == (_x_t1_l0 != 0)) && ((t1_l1 != 0) == (_x_t1_l1 != 0))) && ((delta + (t1_x + (-1.0 * _x_t1_x))) == 0.0)) || ( !(( !(delta <= 0.0)) || (( !(t1_evt0 != 0)) && ( !(t1_evt1 != 0))))))) && (((((_x_t1_l0 != 0) && ( !(_x_t1_l1 != 0))) && ((t1_evt0 != 0) && ( !(t1_evt1 != 0)))) && (_x_t1_x == 0.0)) || ( !((( !(t1_l0 != 0)) && ( !(t1_l1 != 0))) && ((delta == 0.0) && ( !(( !(t1_evt0 != 0)) && ( !(t1_evt1 != 0))))))))) && (((((_x_t1_l1 != 0) && ( !(_x_t1_l0 != 0))) && ( !(t1_x <= 2.0))) && (((t1_evt0 != 0) && (t1_evt1 != 0)) && (t1_x == _x_t1_x))) || ( !(((t1_l0 != 0) && ( !(t1_l1 != 0))) && ((delta == 0.0) && ( !(( !(t1_evt0 != 0)) && ( !(t1_evt1 != 0))))))))) && (((t1_x == _x_t1_x) && (((_x_t1_l0 != 0) && (_x_t1_l1 != 0)) && ((t1_evt0 != 0) && (t1_evt1 != 0)))) || ( !(((t1_l1 != 0) && ( !(t1_l0 != 0))) && ((delta == 0.0) && ( !(( !(t1_evt0 != 0)) && ( !(t1_evt1 != 0))))))))) && ((((( !(_x_t1_l0 != 0)) && ( !(_x_t1_l1 != 0))) && (t1_x <= 5.0)) && (((t1_evt1 != 0) && ( !(t1_evt0 != 0))) && (t1_x == _x_t1_x))) || ( !(((t1_l0 != 0) && (t1_l1 != 0)) && ((delta == 0.0) && ( !(( !(t1_evt0 != 0)) && ( !(t1_evt1 != 0))))))))) && (((((((((((( !(_x_t0_l0 != 0)) && ( !(_x_t0_l1 != 0))) || ((_x_t0_l0 != 0) && ( !(_x_t0_l1 != 0)))) || (((_x_t0_l1 != 0) && ( !(_x_t0_l0 != 0))) || ((_x_t0_l0 != 0) && (_x_t0_l1 != 0)))) && (((( !(_x_t0_evt0 != 0)) && ( !(_x_t0_evt1 != 0))) || ((_x_t0_evt0 != 0) && ( !(_x_t0_evt1 != 0)))) || (((_x_t0_evt1 != 0) && ( !(_x_t0_evt0 != 0))) || ((_x_t0_evt0 != 0) && (_x_t0_evt1 != 0))))) && ((( !(_x_t0_l0 != 0)) && ( !(_x_t0_l1 != 0))) || (_x_t0_x <= 5.0))) && (((((t0_l0 != 0) == (_x_t0_l0 != 0)) && ((t0_l1 != 0) == (_x_t0_l1 != 0))) && ((delta + (t0_x + (-1.0 * _x_t0_x))) == 0.0)) || ( !(( !(delta <= 0.0)) || (( !(t0_evt0 != 0)) && ( !(t0_evt1 != 0))))))) && (((((_x_t0_l0 != 0) && ( !(_x_t0_l1 != 0))) && ((t0_evt0 != 0) && ( !(t0_evt1 != 0)))) && (_x_t0_x == 0.0)) || ( !((( !(t0_l0 != 0)) && ( !(t0_l1 != 0))) && ((delta == 0.0) && ( !(( !(t0_evt0 != 0)) && ( !(t0_evt1 != 0))))))))) && (((((_x_t0_l1 != 0) && ( !(_x_t0_l0 != 0))) && ( !(t0_x <= 2.0))) && (((t0_evt0 != 0) && (t0_evt1 != 0)) && (t0_x == _x_t0_x))) || ( !(((t0_l0 != 0) && ( !(t0_l1 != 0))) && ((delta == 0.0) && ( !(( !(t0_evt0 != 0)) && ( !(t0_evt1 != 0))))))))) && (((t0_x == _x_t0_x) && (((_x_t0_l0 != 0) && (_x_t0_l1 != 0)) && ((t0_evt0 != 0) && (t0_evt1 != 0)))) || ( !(((t0_l1 != 0) && ( !(t0_l0 != 0))) && ((delta == 0.0) && ( !(( !(t0_evt0 != 0)) && ( !(t0_evt1 != 0))))))))) && ((((( !(_x_t0_l0 != 0)) && ( !(_x_t0_l1 != 0))) && (t0_x <= 5.0)) && (((t0_evt1 != 0) && ( !(t0_evt0 != 0))) && (t0_x == _x_t0_x))) || ( !(((t0_l0 != 0) && (t0_l1 != 0)) && ((delta == 0.0) && ( !(( !(t0_evt0 != 0)) && ( !(t0_evt1 != 0))))))))) && (((((((((((((((((( !(_x_controller_l0 != 0)) && ( !(_x_controller_l1 != 0))) || ((_x_controller_l0 != 0) && ( !(_x_controller_l1 != 0)))) || (((_x_controller_l1 != 0) && ( !(_x_controller_l0 != 0))) || ((_x_controller_l0 != 0) && (_x_controller_l1 != 0)))) && (((( !(_x_controller_evt2 != 0)) && (( !(_x_controller_evt0 != 0)) && ( !(_x_controller_evt1 != 0)))) || (( !(_x_controller_evt2 != 0)) && ((_x_controller_evt0 != 0) && ( !(_x_controller_evt1 != 0))))) || ((( !(_x_controller_evt2 != 0)) && ((_x_controller_evt1 != 0) && ( !(_x_controller_evt0 != 0)))) || ((( !(_x_controller_evt2 != 0)) && ((_x_controller_evt0 != 0) && (_x_controller_evt1 != 0))) || ((_x_controller_evt2 != 0) && (( !(_x_controller_evt0 != 0)) && ( !(_x_controller_evt1 != 0)))))))) && (((((_x_controller_cnt == 0) || (_x_controller_cnt == 1)) || (_x_controller_cnt == 2)) || (_x_controller_cnt == 3)) || (_x_controller_cnt == 4))) && ((_x_controller_z <= 1.0) || ( !(((_x_controller_l0 != 0) && ( !(_x_controller_l1 != 0))) || ((_x_controller_l0 != 0) && (_x_controller_l1 != 0)))))) && ((((((controller_l0 != 0) == (_x_controller_l0 != 0)) && ((controller_l1 != 0) == (_x_controller_l1 != 0))) && ((delta + (controller_z + (-1.0 * _x_controller_z))) == 0.0)) && (controller_cnt == _x_controller_cnt)) || ( !(( !(delta <= 0.0)) || (( !(controller_evt2 != 0)) && (( !(controller_evt0 != 0)) && ( !(controller_evt1 != 0)))))))) && (((((_x_controller_l0 != 0) && ( !(_x_controller_l1 != 0))) && (( !(controller_evt2 != 0)) && ((controller_evt0 != 0) && ( !(controller_evt1 != 0))))) && ((_x_controller_cnt == 1) && (_x_controller_z == 0.0))) || ( !((( !(controller_l0 != 0)) && ( !(controller_l1 != 0))) && ((delta == 0.0) && ( !(( !(controller_evt2 != 0)) && (( !(controller_evt0 != 0)) && ( !(controller_evt1 != 0)))))))))) && (((controller_z == _x_controller_z) && (((_x_controller_l0 != 0) && ( !(_x_controller_l1 != 0))) || ((_x_controller_l1 != 0) && ( !(_x_controller_l0 != 0))))) || ( !(((controller_l0 != 0) && ( !(controller_l1 != 0))) && ((delta == 0.0) && ( !(( !(controller_evt2 != 0)) && (( !(controller_evt0 != 0)) && ( !(controller_evt1 != 0)))))))))) && ((((( !(controller_evt2 != 0)) && ((controller_evt0 != 0) && ( !(controller_evt1 != 0)))) && ((controller_cnt + (-1 * _x_controller_cnt)) == -1)) || ((( !(controller_evt2 != 0)) && ((controller_evt1 != 0) && ( !(controller_evt0 != 0)))) && ((controller_cnt + (-1 * _x_controller_cnt)) == 1))) || ( !(((delta == 0.0) && ( !(( !(controller_evt2 != 0)) && (( !(controller_evt0 != 0)) && ( !(controller_evt1 != 0)))))) && (((controller_l0 != 0) && ( !(controller_l1 != 0))) && ((_x_controller_l0 != 0) && ( !(_x_controller_l1 != 0)))))))) && (((( !(controller_evt2 != 0)) && ((controller_evt0 != 0) && (controller_evt1 != 0))) && ((controller_cnt == _x_controller_cnt) && (controller_z == 1.0))) || ( !(((delta == 0.0) && ( !(( !(controller_evt2 != 0)) && (( !(controller_evt0 != 0)) && ( !(controller_evt1 != 0)))))) && (((controller_l0 != 0) && ( !(controller_l1 != 0))) && ((_x_controller_l1 != 0) && ( !(_x_controller_l0 != 0)))))))) && ((((_x_controller_l1 != 0) && ( !(_x_controller_l0 != 0))) || ((_x_controller_l0 != 0) && (_x_controller_l1 != 0))) || ( !(((controller_l1 != 0) && ( !(controller_l0 != 0))) && ((delta == 0.0) && ( !(( !(controller_evt2 != 0)) && (( !(controller_evt0 != 0)) && ( !(controller_evt1 != 0)))))))))) && (((controller_z == _x_controller_z) && (((( !(controller_evt2 != 0)) && ((controller_evt0 != 0) && ( !(controller_evt1 != 0)))) && ((controller_cnt + (-1 * _x_controller_cnt)) == -1)) || (((( !(controller_evt2 != 0)) && ((controller_evt1 != 0) && ( !(controller_evt0 != 0)))) && ((controller_cnt + (-1 * _x_controller_cnt)) == 1)) && ( !(controller_cnt <= 1))))) || ( !(((delta == 0.0) && ( !(( !(controller_evt2 != 0)) && (( !(controller_evt0 != 0)) && ( !(controller_evt1 != 0)))))) && (((controller_l1 != 0) && ( !(controller_l0 != 0))) && ((_x_controller_l1 != 0) && ( !(_x_controller_l0 != 0)))))))) && ((((( !(controller_evt2 != 0)) && ((controller_evt1 != 0) && ( !(controller_evt0 != 0)))) && (controller_cnt == 1)) && ((_x_controller_cnt == 0) && (_x_controller_z == 0.0))) || ( !(((delta == 0.0) && ( !(( !(controller_evt2 != 0)) && (( !(controller_evt0 != 0)) && ( !(controller_evt1 != 0)))))) && (((controller_l1 != 0) && ( !(controller_l0 != 0))) && ((_x_controller_l0 != 0) && (_x_controller_l1 != 0))))))) && (((controller_z == _x_controller_z) && ((( !(_x_controller_l0 != 0)) && ( !(_x_controller_l1 != 0))) || ((_x_controller_l1 != 0) && ( !(_x_controller_l0 != 0))))) || ( !(((controller_l0 != 0) && (controller_l1 != 0)) && ((delta == 0.0) && ( !(( !(controller_evt2 != 0)) && (( !(controller_evt0 != 0)) && ( !(controller_evt1 != 0)))))))))) && ((((controller_cnt + (-1 * _x_controller_cnt)) == -1) && ((( !(controller_evt2 != 0)) && ((controller_evt0 != 0) && ( !(controller_evt1 != 0)))) && (controller_z <= 1.0))) || ( !(((delta == 0.0) && ( !(( !(controller_evt2 != 0)) && (( !(controller_evt0 != 0)) && ( !(controller_evt1 != 0)))))) && (((_x_controller_l1 != 0) && ( !(_x_controller_l0 != 0))) && ((controller_l0 != 0) && (controller_l1 != 0))))))) && ((((((((((((( !(_x_gate_l0 != 0)) && ( !(_x_gate_l1 != 0))) || ((_x_gate_l0 != 0) && ( !(_x_gate_l1 != 0)))) || (((_x_gate_l1 != 0) && ( !(_x_gate_l0 != 0))) || ((_x_gate_l0 != 0) && (_x_gate_l1 != 0)))) && (((( !(_x_gate_evt0 != 0)) && ( !(_x_gate_evt1 != 0))) || ((_x_gate_evt0 != 0) && ( !(_x_gate_evt1 != 0)))) || (((_x_gate_evt1 != 0) && ( !(_x_gate_evt0 != 0))) || ((_x_gate_evt0 != 0) && (_x_gate_evt1 != 0))))) && ((_x_gate_y <= 1.0) || ( !((_x_gate_l0 != 0) && ( !(_x_gate_l1 != 0)))))) && ((_x_gate_y <= 2.0) || ( !((_x_gate_l0 != 0) && (_x_gate_l1 != 0))))) && (((((gate_l0 != 0) == (_x_gate_l0 != 0)) && ((gate_l1 != 0) == (_x_gate_l1 != 0))) && ((delta + (gate_y + (-1.0 * _x_gate_y))) == 0.0)) || ( !((( !(gate_evt0 != 0)) && ( !(gate_evt1 != 0))) || ( !(delta <= 0.0)))))) && (((((_x_gate_l0 != 0) && ( !(_x_gate_l1 != 0))) && ((gate_evt0 != 0) && ( !(gate_evt1 != 0)))) && (_x_gate_y == 0.0)) || ( !((( !(gate_l0 != 0)) && ( !(gate_l1 != 0))) && ((delta == 0.0) && ( !(( !(gate_evt0 != 0)) && ( !(gate_evt1 != 0))))))))) && (((((_x_gate_l1 != 0) && ( !(_x_gate_l0 != 0))) && ((gate_evt0 != 0) && (gate_evt1 != 0))) && ((gate_y <= 1.0) && (gate_y == _x_gate_y))) || ( !(((gate_l0 != 0) && ( !(gate_l1 != 0))) && ((delta == 0.0) && ( !(( !(gate_evt0 != 0)) && ( !(gate_evt1 != 0))))))))) && (((_x_gate_y == 0.0) && (((_x_gate_l0 != 0) && (_x_gate_l1 != 0)) && ((gate_evt1 != 0) && ( !(gate_evt0 != 0))))) || ( !(((gate_l1 != 0) && ( !(gate_l0 != 0))) && ((delta == 0.0) && ( !(( !(gate_evt0 != 0)) && ( !(gate_evt1 != 0))))))))) && (((gate_y == _x_gate_y) && (((( !(_x_gate_l0 != 0)) && ( !(_x_gate_l1 != 0))) && (1.0 <= gate_y)) && (((gate_evt0 != 0) && (gate_evt1 != 0)) && (gate_y <= 2.0)))) || ( !(((gate_l0 != 0) && (gate_l1 != 0)) && ((delta == 0.0) && ( !(( !(gate_evt0 != 0)) && ( !(gate_evt1 != 0))))))))) && (0.0 <= _x_delta)))))) && ((( !(t2_evt0 != 0)) && ( !(t2_evt1 != 0))) || ( !((delta == 0.0) && ( !(( !(t0_evt0 != 0)) && ( !(t0_evt1 != 0)))))))) && ((( !(t2_evt0 != 0)) && ( !(t2_evt1 != 0))) || ( !((delta == 0.0) && ( !(( !(t1_evt0 != 0)) && ( !(t1_evt1 != 0)))))))) && ((( !(t1_evt0 != 0)) && ( !(t1_evt1 != 0))) || ( !((delta == 0.0) && ( !(( !(t2_evt0 != 0)) && ( !(t2_evt1 != 0)))))))) && ((((gate_evt0 != 0) && ( !(gate_evt1 != 0))) == (( !(controller_evt2 != 0)) && ((controller_evt0 != 0) && (controller_evt1 != 0)))) || ( !(delta == 0.0)))) && (( !(delta == 0.0)) || (((gate_evt1 != 0) && ( !(gate_evt0 != 0))) == ((controller_evt2 != 0) && (( !(controller_evt0 != 0)) && ( !(controller_evt1 != 0))))))) && (( !(delta == 0.0)) || ((( !(controller_evt2 != 0)) && ((controller_evt0 != 0) && ( !(controller_evt1 != 0)))) == (((t2_evt0 != 0) && ( !(t2_evt1 != 0))) || (((t0_evt0 != 0) && ( !(t0_evt1 != 0))) || ((t1_evt0 != 0) && ( !(t1_evt1 != 0)))))))) && (( !(delta == 0.0)) || ((( !(controller_evt2 != 0)) && ((controller_evt1 != 0) && ( !(controller_evt0 != 0)))) == (((t2_evt1 != 0) && ( !(t2_evt0 != 0))) || (((t0_evt1 != 0) && ( !(t0_evt0 != 0))) || ((t1_evt1 != 0) && ( !(t1_evt0 != 0)))))))) && (((delta == _x__diverge_delta) || ( !(1.0 <= _diverge_delta))) && ((1.0 <= _diverge_delta) || ((delta + (_diverge_delta + (-1.0 * _x__diverge_delta))) == 0.0)))); _diverge_delta = _x__diverge_delta; t2_l1 = _x_t2_l1; t2_l0 = _x_t2_l0; t2_evt1 = _x_t2_evt1; t2_evt0 = _x_t2_evt0; t1_l1 = _x_t1_l1; t1_l0 = _x_t1_l0; t1_evt1 = _x_t1_evt1; t1_evt0 = _x_t1_evt0; t1_x = _x_t1_x; t0_l1 = _x_t0_l1; t0_evt1 = _x_t0_evt1; t0_evt0 = _x_t0_evt0; t0_x = _x_t0_x; delta = _x_delta; t2_x = _x_t2_x; gate_l0 = _x_gate_l0; controller_l0 = _x_controller_l0; gate_l1 = _x_gate_l1; gate_y = _x_gate_y; controller_l1 = _x_controller_l1; gate_evt0 = _x_gate_evt0; controller_evt0 = _x_controller_evt0; controller_evt1 = _x_controller_evt1; gate_evt1 = _x_gate_evt1; controller_z = _x_controller_z; t0_l0 = _x_t0_l0; controller_evt2 = _x_controller_evt2; controller_cnt = _x_controller_cnt; } }
the_stack_data/121063.c
#define _GNU_SOURCE #include <sys/prctl.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <stdio.h> static void _bossname_init() __attribute__((constructor)); static void _bossname_init() { char *keep_vars = getenv("BOSSNAME_KEEPVARS"); int keep = keep_vars && *keep_vars; char *entry = getenv("BOSS_CHILD"); if(entry) { int dlen = strlen(entry); char cfgpath[dlen+1]; char pname[dlen+1]; int bosspid; int childpid; int instance_index = -1; if(sscanf(entry, "%[^,],%d,%[^,],%d,%d", cfgpath, &bosspid, pname, &childpid, &instance_index) >= 4 && childpid == getpid()) { char *name = getenv("BOSSNAME_OVERRIDE"); if(!name) name = pname; prctl(PR_SET_NAME, name); } } else { char *name = getenv("BOSSNAME_OVERRIDE"); if(name) prctl(PR_SET_NAME, name); } if(keep) return; // Environment cleanup unsetenv("BOSS_CHILD"); unsetenv("BOSSNAME_OVERRIDE"); char *preload = getenv("LD_PRELOAD"); if(preload) { char *start = preload; while(1) { char *colon = strchrnul(start, ':'); char *slash = colon; for(;slash > start && *slash != '/'; --slash); if(*slash == '/') ++slash; if(colon - slash >= 14 && !strncmp("libbossname.so", slash, 14)) { // need to collapse this entry if(start == preload && !*colon) { // only single entry unsetenv("LD_PRELOAD"); } else { char newpreload[strlen(preload)]; memcpy(newpreload, preload, start - preload); newpreload[start - preload] = 0; if(*colon) { strcat(newpreload, colon+1); } setenv("LD_PRELOAD", newpreload, 1); } break; } if(!*colon) // last entry break; start = colon + 1; } } }
the_stack_data/184517449.c
#include <stdio.h> #include <stdlib.h> #include <stdint.h> int main(int argc, char *argv[]) { //Check to make sure there is only one command line arg if (argc != 2) { printf("Usage: ./recover image\n"); return 1; } //Creating a new type to store a Byte of data; uint8_t represents an 8 bit unsigned int typedef uint8_t BYTE; //Open forensic image of memory card FILE *file = fopen(argv[1], "r"); //Check to see if forensic image could be opened for reading if (!file) { printf("Image cannot be opened for reading."); return 1; } //Create a buffer to store 512MB chunk BYTE *buffer = malloc(sizeof(BYTE)*512); //Initialize a counter to keep track of number of images found int count = 0; //Initialize a string to be used for storing jpg filenames char* filename = malloc(sizeof(char)*7); //Loop through memmory card and look through 512MB chunks while(fread(buffer, sizeof(BYTE), 512, file) == 512) { //Check to see if first 4 bytes match header indicating a new jpg file if (buffer[0] == 0xff && buffer[1] == 0xd8 && buffer[2] == 0xff && (buffer[3] & 0xf0) == 0xe0) { //Create a new jpg file to write bytes to sprintf(filename, "%03i.jpg", count); //Open new jpg file as writable FILE *img = fopen(filename, "w"); //Write bytes in buffer array to jpg file fwrite(buffer, sizeof(BYTE), 512, img); //Close file fclose(img); //Increase to keep track to count of jpg files found count++; } //If first 4 bytes are not header bytes and we have already found first jpg, we assign each 512MB chunk to most recent jpg file created until new jpg header found else if (count > 0) { //Reopen most previous created jpg file to append next 512MB chunk FILE *img = fopen(filename, "a"); //Write bytes in buffer to jpg file fwrite(buffer, sizeof(BYTE), 512, img); //Close file fclose(img); } } //Close memory card file fclose(file); //Free up space from malloc use free(buffer); free(filename); }
the_stack_data/109733.c
#include <stdio.h> #include <stdlib.h> #include <string.h> int lexicographic_sort(const char* a, const char* b) { return strcmp(a, b); } int lexicographic_sort_reverse(const char* a, const char* b) { return strcmp(b, a); } #define CHARS 26 int distinct_chars(const char *a) { int dist = 0; int chars[CHARS] = {0}; while (*a != '\0') { int chr = (*a++) - 'a'; if (chr < CHARS) chars[chr]++; } for (int i = 0; i < CHARS; i++) if (chars[i]) dist++; return dist; } int sort_by_number_of_distinct_characters(const char* a, const char* b) { int res = distinct_chars(a) - distinct_chars(b); return (res) ? res : lexicographic_sort(a, b); } int sort_by_length(const char* a, const char* b) { int res = strlen(a) - strlen(b); return (res) ? res : lexicographic_sort(a, b); } /* simple bubble sort :) */ void string_sort(char** arr, const int len,int (*cmp_func)(const char* a, const char* b)) { int sorted = 0; int top = len - 1; while (!sorted) { sorted = 1; for (int i = 0; i < top; i++) { if (cmp_func(arr[i], arr[i + 1]) > 0) { char *tmp = arr[i]; arr[i] = arr[i + 1]; arr[i + 1] = tmp; sorted = 0; } } top--; } } int main() { int n; scanf("%d", &n); char** arr; arr = (char**)malloc(n * sizeof(char*)); for(int i = 0; i < n; i++){ *(arr + i) = malloc(1024 * sizeof(char)); scanf("%s", *(arr + i)); *(arr + i) = realloc(*(arr + i), strlen(*(arr + i)) + 1); } string_sort(arr, n, lexicographic_sort); for(int i = 0; i < n; i++) printf("%s\n", arr[i]); printf("\n"); string_sort(arr, n, lexicographic_sort_reverse); for(int i = 0; i < n; i++) printf("%s\n", arr[i]); printf("\n"); string_sort(arr, n, sort_by_length); for(int i = 0; i < n; i++) printf("%s\n", arr[i]); printf("\n"); string_sort(arr, n, sort_by_number_of_distinct_characters); for(int i = 0; i < n; i++) printf("%s\n", arr[i]); printf("\n"); }
the_stack_data/178266469.c
int main(){ #if !T int a; #endif a = 10; return a; }
the_stack_data/86074744.c
/* * POK header * * The following file is a part of the POK project. Any modification should * be made according to the POK licence. You CANNOT use this file or a part * of a file for your own project. * * For more information on the POK licence, please see our LICENCE FILE * * Please follow the coding guidelines described in doc/CODING_GUIDELINES * * Copyright (c) 2007-2021 POK team */ #ifdef POK_NEEDS_MIDDLEWARE #ifdef POK_NEEDS_BLACKBOARDS #include <errno.h> #include <libc/string.h> #include <middleware/blackboard.h> #include <types.h> extern pok_blackboard_t pok_blackboards[POK_CONFIG_NB_BLACKBOARDS]; pok_ret_t pok_blackboard_clear(const pok_blackboard_id_t id) { if (id > POK_CONFIG_NB_BLACKBOARDS) { return POK_ERRNO_EINVAL; } pok_blackboards[id].empty = TRUE; return POK_ERRNO_OK; } #endif /* POK_NEEDS_BLACKBOARDS */ #endif
the_stack_data/173577017.c
// // main.c // graphSearch // // Created by xiaonizi on 2018/6/15. // Copyright © 2018年 xiaonizi. All rights reserved. // #include <stdio.h> #include <stdlib.h> typedef struct vertex{ int vertex; struct vertex *link; }Vertex; typedef struct queue{ int queue[101]; int front, rear; }Queue; int vertex_num; void addpath(Vertex G[], int v1, int v2){ Vertex *v = (Vertex *)malloc(sizeof(Vertex)); v->vertex = v2; v->link = NULL; Vertex *temp = &G[v1]; Vertex *new = temp->link; while(new!=NULL && new->vertex < v2){ temp = temp->link; new = new->link; } v->link = new; temp->link = v; v = (Vertex *)malloc(sizeof(Vertex)); v->vertex = v1; v->link = NULL; temp = &G[v2]; new = temp->link; while(new!=NULL && new->vertex < v1){ temp = temp->link; new = new->link; } v->link = new; temp->link = v; } void DFS(Vertex G[], int v, int visited[]){ visited[v] = 1; printf("%d ", v); Vertex *p = G[v].link; while(p!=NULL){ if(visited[p->vertex]==0){ DFS(G, p->vertex, visited); } p = p->link; } } void traverseD(Vertex G[], int d){ int visited[vertex_num], i; for(i = 0; i < vertex_num; i++){ visited[i] = 0; } for(i = 0; i<vertex_num; i++){ if(visited[i] == 0 && i!=d){ DFS(G, i, visited); } } } void enQueue(Queue *q, int item){ q->queue[q->rear] = item; q->rear = (q->rear+1)%101; } int deQueue(Queue *q){ int item = q->queue[q->front]; q->front = (q->front+1)%101; return item; } int emptyQ(Queue q){ if(q.front == q.rear) return 1; return 0; } void BFS(Vertex G[], int v, int visited[], Queue q){ visited[v] = 1; printf("%d ", v); enQueue(&q, v);\ while(!emptyQ(q)){ v = deQueue(&q); Vertex *p = G[v].link; while(p!=NULL){ if(visited[p->vertex]==0){ visited[p->vertex] = 1; printf("%d ", p->vertex); enQueue(&q, p->vertex); } p = p->link; } } } void traverseB(Vertex G[], int d){ int visited[vertex_num], i; Queue q; q.front = 0; q.rear = 0; for(i = 0; i < vertex_num; i++){ visited[i] = 0; } for(i = 0; i<vertex_num; i++){ if(visited[i] == 0 && i!=d){ BFS(G, i, visited, q); } } } void delete(Vertex G[], int d){ G[d].link = NULL; int i; Vertex *p, *old_p; for(i = 0; i<vertex_num; i++){ old_p = &G[i]; p = G[i].link; while(p!=NULL){ if(p->vertex==d){ old_p->link=p->link; free(p); } else{ old_p = old_p->link; } p = old_p->link; } } } int main(){ int edge_num, i, v1, v2, d; scanf("%d %d", &vertex_num, &edge_num); Vertex G[vertex_num]; for(i=0; i<vertex_num; i++){ G[i].vertex = i; G[i].link = NULL; } for(i = 0; i<edge_num; i++){ scanf("%d %d", &v1, &v2); addpath(G, v1, v2); } scanf("%d", &d); traverseD(G, -1); printf("\n"); traverseB(G, -1); printf("\n"); delete(G, d); traverseD(G, d); printf("\n"); traverseB(G, d); printf("\n"); return 0; }
the_stack_data/153269444.c
/* * $Id$ * * Copyright (C) 1993-1999 by Jochen Wiedmann and Marcin Orlowski * Copyright (C) 2002-2015 FlexCat Open Source Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or (at * your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #include <string.h> #include <time.h> #include <stdio.h> /// strptime // parse a date string produced by strftime() and put the success in a struct tm enum ScanDateState { SDS_DEFAULT = 0, SDS_SPECIFIER, SDS_DONE, SDS_SECOND, SDS_MINUTE, SDS_HOUR, SDS_DAY_OF_MONTH, SDS_MONTH, SDS_YEAR, SDS_DAY_OF_WEEK, SDS_DAY_YEAR, SDS_IS_DST, }; #define FLG_SEC (1<<0) #define FLG_MIN (1<<1) #define FLG_HOUR (1<<2) #define FLG_MDAY (1<<3) #define FLG_MON (1<<4) #define FLG_YEAR (1<<5) #define FLG_WDAY (1<<6) #define FLG_YDAY (1<<7) #define FLG_ISDST (1<<8) #define FLG_4DIGIT_YEAR (1<<9) char *strptime(const char *string, const char *fmt, struct tm *res) { int success = 1; char fc; char sc; enum ScanDateState state = SDS_DEFAULT; int flags = 0; // start with the first character in both strings fc = *fmt++; sc = *string++; while(state != SDS_DONE) { if(fc == '\0' && sc == '\0') state = SDS_DONE; switch(state) { case SDS_DEFAULT: { if(fc == '%') { state = SDS_SPECIFIER; fc = *fmt++; } else { // the format string seems to be malformed, bail out state = SDS_DONE; } } break; case SDS_SPECIFIER: { switch(fc) { case 'd': // %d - day number with leading zeros (01-31) case 'e': // %e - day number with leading spaces ( 1-31) { flags |= FLG_MDAY; state = SDS_DAY_OF_MONTH; fc = *fmt++; } break; case 'm': // %m - month number with leading zeros (01-12) { flags |= FLG_MON; state = SDS_MONTH; fc = *fmt++; } break; case 'Y': // %Y - year using four digits with leading zeros { flags |= FLG_4DIGIT_YEAR; } // we fall through here case 'y': // %y - year using two digits with leading zeros (00-99) { flags |= FLG_YEAR; state = SDS_YEAR; fc = *fmt++; } break; case '-': { // ignore any switches between with/without leading zeros/spaces fc = *fmt++; } break; default: { // unknown specifier, bail out state = SDS_DONE; } break; } } break; case SDS_DAY_OF_MONTH: { if(sc == fc) { // next separator in format string found state = SDS_DEFAULT; fc = *fmt++; sc = *string++; } else if(sc >= '0' && sc <= '9') { // valid number found, add it to the day of month res->tm_mday = res->tm_mday * 10 + sc - '0'; sc = *string++; } else { // unexpected character, bail out state = SDS_DONE; } } break; case SDS_MONTH: { if(sc == fc) { // next separator in format string found state = SDS_DEFAULT; fc = *fmt++; sc = *string++; } else if(sc >= '0' && sc <= '9') { // valid number found, add it to the month res->tm_mon = res->tm_mon * 10 + sc - '0'; sc = *string++; } else { // unexpected character, bail out state = SDS_DONE; } } break; case SDS_YEAR: { if(sc == fc) { // next separator in format string found state = SDS_DEFAULT; fc = *fmt++; sc = *string++; } else if(sc >= '0' && sc <= '9') { // valid number found, add it to the year res->tm_year = res->tm_year * 10 + sc - '0'; sc = *string++; } else { // unexpected character, bail out state = SDS_DONE; } } break; default: // nothing to do break; } } // finally check if the calculated values are correct, but only those which // were specified in the format string if((flags & FLG_MDAY) || strstr(fmt, "%d") != NULL || strstr(fmt, "%-d") != NULL || strstr(fmt, "%e") != NULL) { if(res->tm_mday >= 1 && res->tm_mday <= 31) { // nothing to adjust } else { success = 0; } } if((flags & FLG_MON) || strstr(fmt, "%m") != NULL || strstr(fmt, "%-m") != NULL) { if(res->tm_mon >= 1 && res->tm_mon <= 12) { // tm_mon counts from 0 to 11 res->tm_mon--; } else { success = 0; } } if((flags & FLG_YEAR) || strstr(fmt, "%y") != NULL || strstr(fmt, "%-y") != NULL || strstr(fmt, "%Y") != NULL || strstr(fmt, "%-Y") != NULL) { if((flags & FLG_4DIGIT_YEAR) || strstr(fmt, "%Y") != NULL || strstr(fmt, "%-Y") != NULL) { if(res->tm_year >= 1900) { // tm_year counts the years from 1900 res->tm_year -= 1900; } else { // year numbers less than 1900 are not supported success = 0; } } else { // 2 digit year number, must be less than 100 if(res->tm_year < 100) { if(res->tm_year < 40) { // tm_year counts the years from 1900 // if the year number is less than 40 we assume a year between // 2000 and 2039 instead of between 1900 and 1939 to allow a user // age of at least ~70 years. res->tm_year += 100; } } // Although we expect a two digit year number for %y we got one with more digits. // Better not fail at this even if the entered string is wrong. People tend to // forget the correct formatting. else if(res->tm_year >= 1900) { // tm_year counts the years from 1900 res->tm_year -= 1900; } else { // numbers between 100 and 1899 are definitely not allowed success = 0; } } } // finally check if the day value is correct if(success == 1 && (flags & FLG_MDAY)) { if(res->tm_mon == 1) { // February has 29 days at most, but we don't check for leap years here if(res->tm_mday > 29) { success = 0; } } else if(res->tm_mon == 3 || res->tm_mon == 5 || res->tm_mon == 8 || res->tm_mon == 10) { // April, June, September and November have 30 days if(res->tm_mday > 30) { success = 0; } } } return (char *)string; } ///
the_stack_data/248580133.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 x_1, _x_x_1; float x_10, _x_x_10; float x_5, _x_x_5; float x_6, _x_x_6; float x_4, _x_x_4; float x_0, _x_x_0; float x_3, _x_x_3; float x_9, _x_x_9; float x_7, _x_x_7; float x_11, _x_x_11; float x_8, _x_x_8; float x_2, _x_x_2; int __steps_to_fair = __VERIFIER_nondet_int(); x_1 = __VERIFIER_nondet_float(); x_10 = __VERIFIER_nondet_float(); x_5 = __VERIFIER_nondet_float(); x_6 = __VERIFIER_nondet_float(); x_4 = __VERIFIER_nondet_float(); x_0 = __VERIFIER_nondet_float(); x_3 = __VERIFIER_nondet_float(); x_9 = __VERIFIER_nondet_float(); x_7 = __VERIFIER_nondet_float(); x_11 = __VERIFIER_nondet_float(); x_8 = __VERIFIER_nondet_float(); x_2 = __VERIFIER_nondet_float(); bool __ok = (1 && ( !((-11.0 <= (x_7 + (-1.0 * x_9))) && ((-17.0 <= (x_0 + (-1.0 * x_4))) || ((x_5 + (-1.0 * x_10)) <= 4.0))))); while (__steps_to_fair >= 0 && __ok) { if (( !0)) { __steps_to_fair = __VERIFIER_nondet_int(); } else { __steps_to_fair--; } _x_x_1 = __VERIFIER_nondet_float(); _x_x_10 = __VERIFIER_nondet_float(); _x_x_5 = __VERIFIER_nondet_float(); _x_x_6 = __VERIFIER_nondet_float(); _x_x_4 = __VERIFIER_nondet_float(); _x_x_0 = __VERIFIER_nondet_float(); _x_x_3 = __VERIFIER_nondet_float(); _x_x_9 = __VERIFIER_nondet_float(); _x_x_7 = __VERIFIER_nondet_float(); _x_x_11 = __VERIFIER_nondet_float(); _x_x_8 = __VERIFIER_nondet_float(); _x_x_2 = __VERIFIER_nondet_float(); __ok = ((((((((((((((((x_10 + (-1.0 * _x_x_0)) <= -10.0) && (((x_6 + (-1.0 * _x_x_0)) <= -10.0) && (((x_5 + (-1.0 * _x_x_0)) <= -9.0) && (((x_4 + (-1.0 * _x_x_0)) <= -14.0) && (((x_0 + (-1.0 * _x_x_0)) <= -6.0) && ((x_3 + (-1.0 * _x_x_0)) <= -5.0)))))) && (((x_10 + (-1.0 * _x_x_0)) == -10.0) || (((x_6 + (-1.0 * _x_x_0)) == -10.0) || (((x_5 + (-1.0 * _x_x_0)) == -9.0) || (((x_4 + (-1.0 * _x_x_0)) == -14.0) || (((x_0 + (-1.0 * _x_x_0)) == -6.0) || ((x_3 + (-1.0 * _x_x_0)) == -5.0))))))) && ((((x_11 + (-1.0 * _x_x_1)) <= -11.0) && (((x_10 + (-1.0 * _x_x_1)) <= -1.0) && (((x_9 + (-1.0 * _x_x_1)) <= -4.0) && (((x_6 + (-1.0 * _x_x_1)) <= -4.0) && (((x_0 + (-1.0 * _x_x_1)) <= -9.0) && ((x_4 + (-1.0 * _x_x_1)) <= -6.0)))))) && (((x_11 + (-1.0 * _x_x_1)) == -11.0) || (((x_10 + (-1.0 * _x_x_1)) == -1.0) || (((x_9 + (-1.0 * _x_x_1)) == -4.0) || (((x_6 + (-1.0 * _x_x_1)) == -4.0) || (((x_0 + (-1.0 * _x_x_1)) == -9.0) || ((x_4 + (-1.0 * _x_x_1)) == -6.0)))))))) && ((((x_11 + (-1.0 * _x_x_2)) <= -18.0) && (((x_9 + (-1.0 * _x_x_2)) <= -18.0) && (((x_7 + (-1.0 * _x_x_2)) <= -10.0) && (((x_4 + (-1.0 * _x_x_2)) <= -9.0) && (((x_0 + (-1.0 * _x_x_2)) <= -15.0) && ((x_3 + (-1.0 * _x_x_2)) <= -17.0)))))) && (((x_11 + (-1.0 * _x_x_2)) == -18.0) || (((x_9 + (-1.0 * _x_x_2)) == -18.0) || (((x_7 + (-1.0 * _x_x_2)) == -10.0) || (((x_4 + (-1.0 * _x_x_2)) == -9.0) || (((x_0 + (-1.0 * _x_x_2)) == -15.0) || ((x_3 + (-1.0 * _x_x_2)) == -17.0)))))))) && ((((x_11 + (-1.0 * _x_x_3)) <= -11.0) && (((x_9 + (-1.0 * _x_x_3)) <= -3.0) && (((x_7 + (-1.0 * _x_x_3)) <= -16.0) && (((x_4 + (-1.0 * _x_x_3)) <= -16.0) && (((x_0 + (-1.0 * _x_x_3)) <= -8.0) && ((x_2 + (-1.0 * _x_x_3)) <= -3.0)))))) && (((x_11 + (-1.0 * _x_x_3)) == -11.0) || (((x_9 + (-1.0 * _x_x_3)) == -3.0) || (((x_7 + (-1.0 * _x_x_3)) == -16.0) || (((x_4 + (-1.0 * _x_x_3)) == -16.0) || (((x_0 + (-1.0 * _x_x_3)) == -8.0) || ((x_2 + (-1.0 * _x_x_3)) == -3.0)))))))) && ((((x_9 + (-1.0 * _x_x_4)) <= -19.0) && (((x_8 + (-1.0 * _x_x_4)) <= -6.0) && (((x_4 + (-1.0 * _x_x_4)) <= -1.0) && (((x_3 + (-1.0 * _x_x_4)) <= -2.0) && (((x_1 + (-1.0 * _x_x_4)) <= -12.0) && ((x_2 + (-1.0 * _x_x_4)) <= -13.0)))))) && (((x_9 + (-1.0 * _x_x_4)) == -19.0) || (((x_8 + (-1.0 * _x_x_4)) == -6.0) || (((x_4 + (-1.0 * _x_x_4)) == -1.0) || (((x_3 + (-1.0 * _x_x_4)) == -2.0) || (((x_1 + (-1.0 * _x_x_4)) == -12.0) || ((x_2 + (-1.0 * _x_x_4)) == -13.0)))))))) && ((((x_10 + (-1.0 * _x_x_5)) <= -19.0) && (((x_6 + (-1.0 * _x_x_5)) <= -18.0) && (((x_5 + (-1.0 * _x_x_5)) <= -12.0) && (((x_3 + (-1.0 * _x_x_5)) <= -10.0) && (((x_1 + (-1.0 * _x_x_5)) <= -17.0) && ((x_2 + (-1.0 * _x_x_5)) <= -6.0)))))) && (((x_10 + (-1.0 * _x_x_5)) == -19.0) || (((x_6 + (-1.0 * _x_x_5)) == -18.0) || (((x_5 + (-1.0 * _x_x_5)) == -12.0) || (((x_3 + (-1.0 * _x_x_5)) == -10.0) || (((x_1 + (-1.0 * _x_x_5)) == -17.0) || ((x_2 + (-1.0 * _x_x_5)) == -6.0)))))))) && ((((x_11 + (-1.0 * _x_x_6)) <= -11.0) && (((x_8 + (-1.0 * _x_x_6)) <= -8.0) && (((x_6 + (-1.0 * _x_x_6)) <= -13.0) && (((x_5 + (-1.0 * _x_x_6)) <= -9.0) && (((x_1 + (-1.0 * _x_x_6)) <= -6.0) && ((x_4 + (-1.0 * _x_x_6)) <= -15.0)))))) && (((x_11 + (-1.0 * _x_x_6)) == -11.0) || (((x_8 + (-1.0 * _x_x_6)) == -8.0) || (((x_6 + (-1.0 * _x_x_6)) == -13.0) || (((x_5 + (-1.0 * _x_x_6)) == -9.0) || (((x_1 + (-1.0 * _x_x_6)) == -6.0) || ((x_4 + (-1.0 * _x_x_6)) == -15.0)))))))) && ((((x_10 + (-1.0 * _x_x_7)) <= -5.0) && (((x_8 + (-1.0 * _x_x_7)) <= -13.0) && (((x_7 + (-1.0 * _x_x_7)) <= -19.0) && (((x_5 + (-1.0 * _x_x_7)) <= -4.0) && (((x_1 + (-1.0 * _x_x_7)) <= -20.0) && ((x_4 + (-1.0 * _x_x_7)) <= -17.0)))))) && (((x_10 + (-1.0 * _x_x_7)) == -5.0) || (((x_8 + (-1.0 * _x_x_7)) == -13.0) || (((x_7 + (-1.0 * _x_x_7)) == -19.0) || (((x_5 + (-1.0 * _x_x_7)) == -4.0) || (((x_1 + (-1.0 * _x_x_7)) == -20.0) || ((x_4 + (-1.0 * _x_x_7)) == -17.0)))))))) && ((((x_10 + (-1.0 * _x_x_8)) <= -14.0) && (((x_8 + (-1.0 * _x_x_8)) <= -13.0) && (((x_4 + (-1.0 * _x_x_8)) <= -13.0) && (((x_2 + (-1.0 * _x_x_8)) <= -18.0) && (((x_0 + (-1.0 * _x_x_8)) <= -17.0) && ((x_1 + (-1.0 * _x_x_8)) <= -9.0)))))) && (((x_10 + (-1.0 * _x_x_8)) == -14.0) || (((x_8 + (-1.0 * _x_x_8)) == -13.0) || (((x_4 + (-1.0 * _x_x_8)) == -13.0) || (((x_2 + (-1.0 * _x_x_8)) == -18.0) || (((x_0 + (-1.0 * _x_x_8)) == -17.0) || ((x_1 + (-1.0 * _x_x_8)) == -9.0)))))))) && ((((x_11 + (-1.0 * _x_x_9)) <= -3.0) && (((x_9 + (-1.0 * _x_x_9)) <= -20.0) && (((x_8 + (-1.0 * _x_x_9)) <= -4.0) && (((x_6 + (-1.0 * _x_x_9)) <= -13.0) && (((x_0 + (-1.0 * _x_x_9)) <= -16.0) && ((x_3 + (-1.0 * _x_x_9)) <= -8.0)))))) && (((x_11 + (-1.0 * _x_x_9)) == -3.0) || (((x_9 + (-1.0 * _x_x_9)) == -20.0) || (((x_8 + (-1.0 * _x_x_9)) == -4.0) || (((x_6 + (-1.0 * _x_x_9)) == -13.0) || (((x_0 + (-1.0 * _x_x_9)) == -16.0) || ((x_3 + (-1.0 * _x_x_9)) == -8.0)))))))) && ((((x_11 + (-1.0 * _x_x_10)) <= -18.0) && (((x_10 + (-1.0 * _x_x_10)) <= -15.0) && (((x_9 + (-1.0 * _x_x_10)) <= -5.0) && (((x_7 + (-1.0 * _x_x_10)) <= -15.0) && (((x_1 + (-1.0 * _x_x_10)) <= -10.0) && ((x_4 + (-1.0 * _x_x_10)) <= -3.0)))))) && (((x_11 + (-1.0 * _x_x_10)) == -18.0) || (((x_10 + (-1.0 * _x_x_10)) == -15.0) || (((x_9 + (-1.0 * _x_x_10)) == -5.0) || (((x_7 + (-1.0 * _x_x_10)) == -15.0) || (((x_1 + (-1.0 * _x_x_10)) == -10.0) || ((x_4 + (-1.0 * _x_x_10)) == -3.0)))))))) && ((((x_11 + (-1.0 * _x_x_11)) <= -13.0) && (((x_9 + (-1.0 * _x_x_11)) <= -13.0) && (((x_7 + (-1.0 * _x_x_11)) <= -10.0) && (((x_6 + (-1.0 * _x_x_11)) <= -15.0) && (((x_0 + (-1.0 * _x_x_11)) <= -15.0) && ((x_1 + (-1.0 * _x_x_11)) <= -11.0)))))) && (((x_11 + (-1.0 * _x_x_11)) == -13.0) || (((x_9 + (-1.0 * _x_x_11)) == -13.0) || (((x_7 + (-1.0 * _x_x_11)) == -10.0) || (((x_6 + (-1.0 * _x_x_11)) == -15.0) || (((x_0 + (-1.0 * _x_x_11)) == -15.0) || ((x_1 + (-1.0 * _x_x_11)) == -11.0)))))))) && 1); x_1 = _x_x_1; x_10 = _x_x_10; x_5 = _x_x_5; x_6 = _x_x_6; x_4 = _x_x_4; x_0 = _x_x_0; x_3 = _x_x_3; x_9 = _x_x_9; x_7 = _x_x_7; x_11 = _x_x_11; x_8 = _x_x_8; x_2 = _x_x_2; } }
the_stack_data/131139.c
#include <stdlib.h> #include <stdbool.h> #include <math.h> #define MATRIX_SIZE 1000000 #define SPARSENESS_PERCENTAGE 0.01 #define SPARSENESS (float)(SPARSENESS_PERCENTAGE / 100.0) const int RANDOM_STEP_FACTOR = (int)(1.0 / SPARSENESS); #define random(rndval) ((float)(rndval) / (float)RAND_MAX) #define randomStep(rndval) (((rndval)*2 * RANDOM_STEP_FACTOR) / RAND_MAX) #define element(rndval) ((random(rndval) - 0.5) * 2.0) int main() { // Initialize RNG time_t t; srand((unsigned)time(&t)); float el; unsigned long expectedCountPerRow = (unsigned long)(MATRIX_SIZE * SPARSENESS); unsigned long allocationPerRow = (unsigned long)pow(2, ceil(log2((double)expectedCountPerRow))); printf("Expecting %lu elements\n", expectedCountPerRow * (unsigned long)MATRIX_SIZE); printf("Expecting %d entries per row\n", expectedCountPerRow); printf("Allocating %d entries per row\n", allocationPerRow); float *row = (float *)malloc(sizeof(float) * allocationPerRow); int *steps = (int *)malloc(sizeof(int) * allocationPerRow); int *rndvals = (int *)malloc(sizeof(int) * allocationPerRow); if (row == NULL) { printf("Allocation failed."); return 1; } printf("Computing matrix\n"); unsigned long count = 0; for (unsigned long i = 0; i < MATRIX_SIZE; i++) { int index = 1; //printf("%d %d %.4f %.4f\n", i, randomStep(), random(), random() * (float)RANDOM_STEP_FACTOR); for (unsigned long l = 0; l < expectedCountPerRow; l++) { rndvals[l] = rand(); } for (unsigned long l = 0; l < expectedCountPerRow; l++) { steps[l] = randomStep(rndvals[l]); } for (unsigned long j = i + steps[0]; j < MATRIX_SIZE; j += steps[index]) { row[index] = element(rndvals[index]); if (++index > expectedCountPerRow) { continue; } } count += index; } printf("Sparseness: %f%%", (double)(2.0 * count) / ((double)MATRIX_SIZE * (double)MATRIX_SIZE / 100.0)); return 0; }
the_stack_data/39488.c
/** * (C) Copyright 2014- ECMWF. * * This software is licensed under the terms of the Apache Licence Version 2.0 * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. * * In applying this licence, ECMWF does not waive the privileges and immunities * granted to it by virtue of its status as an intergovernmental organisation * nor does it submit to any jurisdiction. */ void MPI_Comm_split() {}
the_stack_data/737647.c
#include <stdio.h> #include <stdlib.h> void vassume(int b){} void vtrace(int s){} void mainQ(int i, int n) { vassume(n >= 0); int s = 0; for (i = 0; i < n; ++i) { s = s + i; } vtrace(s); //assert(s >= 0); } void main(int argc, char *argv[]) { mainQ(atoi(argv[1]), atoi(argv[2])); }
the_stack_data/154827958.c
/* * Copyright (c) 2017, 2018, Oracle and/or its affiliates. * * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, this list of * conditions and the following disclaimer in the documentation and/or other materials provided * with the distribution. * * 3. Neither the name of the copyright holder nor the names of its contributors may be used to * endorse or promote products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. */ int main() { int sum = 1 || 2; sum = !(!!1 && 1 || 2 && 3); sum += sum || !sum && 0; return sum; }
the_stack_data/40763440.c
#include <stdio.h> #define PI 3.1416 void main(){ float circumference, diameter, area, radius;; /*set the values*/ printf("set the radius :"); scanf("%f", &radius); /*calculate*/ area = PI * (radius * radius); circumference = 2 * PI* radius; diameter = 2 * radius; //show results printf("\n\nThe area is %.2f\n", area); printf("\n\nThe circunference is %.2f\n", circumference); printf("\n\nThe diameter is %.2f\n", diameter); }
the_stack_data/23575082.c
#include <stdio.h> #include <stdlib.h> typedef float float_t; #define SIZE 832 #define T 64 float_t space[SIZE][SIZE]; // For the dataparallel semantics: float_t save[SIZE][SIZE]; void get_data(char filename[]) { int i, j, nx, ny; unsigned char c; FILE *fp; if ((fp = fopen(filename, "r")) == NULL) { perror("Error loading file"); exit(1); } /* Get *.pgm file type */ c = fgetc(fp); c = fgetc(fp); /* Skip comment lines */ do { while((c = fgetc(fp)) != '\n'); } while((c = fgetc(fp)) == '#'); /* Put back good char */ ungetc(c,fp); /* Get image dimensions */ fscanf(fp, "%d %d\n", &nx, &ny); /* Get grey levels */ fscanf(fp,"%d",&i); /* Get ONE carriage return */ fgetc(fp); printf("Input image : x=%d y=%d grey=%d\n", nx, ny, i); for(i = 0;i < SIZE; i++) for(j = 0;j < SIZE; j++) { c = fgetc(fp); space[i][j] = c; } fclose(fp); } void write_data(char filename[]) { int i,j; unsigned char c; FILE *fp; if ((fp = fopen(filename, "w")) == NULL) { perror("Error opening file"); exit(2); } /* Write the PGM header: */ fprintf(fp,"P5\n%d %d\n255\n", SIZE, SIZE); for(i = 0;i < SIZE; i++) for(j = 0;j < SIZE; j++) { c = space[i][j]; fputc(c, fp); } fclose(fp); } void jacobi() { int i, j; /* Use 2 array in flip-flop to have dataparallel forall semantics. I could use also a flip-flop dimension instead... */ kernel1: for(i = 1;i < SIZE - 1; i++) for(j = 1;j < SIZE - 1; j++) { save[i][j] = 0.25*(space[i - 1][j] + space[i + 1][j] + space[i][j - 1] + space[i][j + 1]); } for(i = 1;i < SIZE - 1; i++) for(j = 1;j < SIZE - 1; j++) { space[i][j] = 0.25*(save[i - 1][j] + save[i + 1][j] + save[i][j - 1] + save[i][j + 1]); } } int main(int argc, char *argv[]) { int t; if (argc != 2) { fprintf(stderr, "%s needs only one argument that is the PGM image input file\n", argv[0]); exit(1); } get_data(argv[1]); for(t = 0; t < T; t++) jacobi(); write_data("output.pgm"); return 0; }
the_stack_data/38700.c
#include <stdlib.h> #include <stdio.h> #include <stdint.h> #include <stdbool.h> #include <assert.h> #include <string.h> #include <errno.h> #undef get16bits #if (defined(__GNUC__) && defined(__i386__)) || defined(__WATCOMC__) \ || defined(_MSC_VER) || defined (__BORLANDC__) || defined (__TURBOC__) #define get16bits(d) (*((const uint16_t *) (d))) #endif #if !defined (get16bits) #define get16bits(d) ((((uint32_t)(((const uint8_t *)(d))[1])) << 8)\ +(uint32_t)(((const uint8_t *)(d))[0]) ) #endif uint32_t spins_hash (const void *data_, int len, uint32_t hash) { const unsigned char *data = data_; uint32_t tmp; int rem; if (len <= 0 || data == NULL) return 0; rem = len & 3; len >>= 2; /* Main loop */ for (;len > 0; len--) { hash += get16bits (data); tmp = (get16bits (data+2) << 11) ^ hash; hash = (hash << 16) ^ tmp; data += 2*sizeof (uint16_t); hash += hash >> 11; } /* Handle end cases */ switch (rem) { case 3: hash += get16bits (data); hash ^= hash << 16; hash ^= data[sizeof (uint16_t)] << 18; hash += hash >> 11; break; case 2: hash += get16bits (data); hash ^= hash << 11; hash += hash >> 17; break; case 1: hash += *data; hash ^= hash << 10; hash += hash >> 1; } /* Force "avalanching" of final 127 bits */ hash ^= hash << 3; hash += hash >> 5; hash ^= hash << 4; hash += hash >> 17; hash ^= hash << 25; hash += hash >> 6; return hash; } void * spins_align (size_t align, size_t size) { void *ret; errno = posix_memalign (&ret, align, size); if (errno) { switch (errno) { case ENOMEM: printf ("Out of memory - "); exit (1); case EINVAL: printf ("Invalid alignment %zu - ", align); exit (1); default: printf("error allocating %zu bytes aligned at %zu\n", size, align); exit (1); }} return ret; } typedef uint32_t spins_mem_hash_t; typedef struct spins_state_db_s { size_t length; size_t bytes; size_t size; size_t size3; size_t init_size; size_t init_size3; size_t mask; size_t max; int *data; spins_mem_hash_t *hash; size_t load; } spins_state_db_t; #define STATE_DB_FULL -1 #define EMPTY 0 #define CACHE_LINE 6 static const size_t SJ_CACHE_LINE_SIZE = 1 << CACHE_LINE; static const size_t SJ_CACHE_LINE_MEM_SIZE = (1UL<<CACHE_LINE) / sizeof (spins_mem_hash_t); static const size_t SJ_CACHE_LINE_MEM_MASK = -((1UL<<CACHE_LINE) / sizeof (spins_mem_hash_t)); static const spins_mem_hash_t SJ_FULL = ((spins_mem_hash_t)-1) ^ (((spins_mem_hash_t)-1)>>1); // 1000 static const spins_mem_hash_t SJ_MASK = ((spins_mem_hash_t)-1)>>1; // 0111 static const spins_mem_hash_t SJ_TOMB = 1; // 0001 static const size_t SJ_NONE = -1UL; extern int spins_state_db_lookup_hash (spins_state_db_t *dbs, const int *v, spins_mem_hash_t *pre); static inline spins_mem_hash_t * spins_memoized (const spins_state_db_t *dbs, size_t ref) { return &dbs->hash[ref]; } static inline int * spins_state (const spins_state_db_t *dbs, size_t ref) { size_t l = dbs->length; return &dbs->data[ref * l]; } int spins_resize (spins_state_db_t *dbs) { if (dbs->size == (dbs->max >> 1)) return false; size_t i; size_t size = dbs->size; size_t newsize = dbs->size <<= 1; dbs->size3 <<= 1; dbs->mask = dbs->size - 1; // collect elements at dbs->table + newsize int todos = 0; for (i = 0; i < size; i++) { spins_mem_hash_t h = *spins_memoized(dbs,i); if (EMPTY == h || (h&SJ_MASK) == i) continue; size_t newidx = newsize + todos; *spins_memoized(dbs,newidx) = h; memcpy(spins_state(dbs,newidx),spins_state(dbs,i),dbs->bytes); *spins_memoized(dbs,i) = EMPTY; } memset (dbs->hash + size, 0, sizeof (spins_mem_hash_t[size])); for (i = newsize; i < newsize + todos; i++) { spins_mem_hash_t h = *spins_memoized(dbs,i); spins_state_db_lookup_hash (dbs, spins_state(dbs,i), &h); } return true; } int spins_state_db_lookup (spins_state_db_t *dbs, const int *v) { return spins_state_db_lookup_hash (dbs, v, NULL); } int spins_state_db_lookup_hash (spins_state_db_t *dbs, const int *v, spins_mem_hash_t *pre) { size_t i; size_t seed = 0; size_t tomb = SJ_NONE; size_t b = dbs->bytes; spins_mem_hash_t h = (NULL==pre ? spins_hash ((char *)v, b, 0) : *pre); spins_mem_hash_t mem = h; while ((dbs->load << 2) < dbs->size3) { // while >75% full size_t ref = h & dbs->mask; size_t line_begin = ref & SJ_CACHE_LINE_MEM_MASK; size_t line_end = line_begin + SJ_CACHE_LINE_MEM_SIZE; for (i = 0; i < SJ_CACHE_LINE_MEM_SIZE; i++) { if (tomb == SJ_NONE && SJ_TOMB == *spins_memoized(dbs,ref)) tomb = ref; if (EMPTY == *spins_memoized(dbs,ref)) { if (tomb != SJ_NONE) ref = tomb; *spins_memoized(dbs,ref) = mem | SJ_FULL; dbs->load++; memcpy (spins_state(dbs,ref), v, b); return false; } if ( ((mem | SJ_FULL) == *spins_memoized(dbs,ref)) && 0 == memcmp (spins_state(dbs,ref), v, b) ) { if (tomb != SJ_NONE) { *spins_memoized(dbs,tomb) = mem | SJ_FULL; memcpy (spins_state(dbs,tomb), v, b); *spins_memoized(dbs,ref) = SJ_TOMB; } return true; } ref = (ref+1 == line_end ? line_begin : ref+1); } h = spins_hash ((char *)v, b, h + (seed++)); } if (spins_resize (dbs)) { return spins_state_db_lookup_hash (dbs, v, &mem); } else { return STATE_DB_FULL; } } void spins_state_db_clear (spins_state_db_t *dbs) { dbs->load = 0; dbs->size = dbs->init_size; dbs->size3 = dbs->init_size3; dbs->mask = dbs->size - 1; memset (dbs->hash, 0, sizeof (spins_mem_hash_t[dbs->size])); } spins_state_db_t * spins_state_db_create (size_t length, size_t init_size, size_t max_size) { assert (init_size < max_size); spins_state_db_t *dbs = spins_align (SJ_CACHE_LINE_SIZE, sizeof (spins_state_db_t)); dbs->length = length; dbs->bytes = sizeof (int[length]); dbs->max = 1UL << max_size; dbs->data = spins_align (SJ_CACHE_LINE_SIZE, sizeof (int[dbs->max][length])); dbs->hash = spins_align (SJ_CACHE_LINE_SIZE, sizeof (spins_mem_hash_t[dbs->max])); dbs->init_size = 1UL<<init_size; dbs->init_size3 = dbs->init_size * 3; dbs->size = dbs->init_size; dbs->size3 = dbs->init_size3; dbs->mask = dbs->size - 1; spins_state_db_clear (dbs); return dbs; } void spins_state_db_free (spins_state_db_t *dbs) { free (dbs->data); free (dbs->hash); free (dbs); } void spins_test () { spins_state_db_t *dbs = spins_state_db_create (10, 2, 10); int state[10]; size_t x, i, j; for (x = 0; x < 500; x++) for (i = 0; i < 768; i++) { for (j = 0; j < 10; j++) state[j] = i; int seen = spins_state_db_lookup (dbs, state); if (seen && !x) { printf("seen = %d at x=%zu i=%zu load=%zu size=%zu\n", seen, x, i, dbs->load, dbs->size); assert (false); } } int seen = spins_state_db_lookup (dbs, state); assert (seen == STATE_DB_FULL); spins_state_db_free (dbs); }
the_stack_data/1189360.c
#include "stdio.h" #include "stdbool.h" bool checkPythagoreanTriplet(int a, int b, int c); bool checkPythagoreanTriplet(int a, int b, int c) { if ((a * a) + (b * b) == (c * c)) { return true; } else { return false; } } int main(int argc, char const *argv[]) { int i; int j; int k; for (i = 1; i < 1000; i++) { for (j = i; j < (1000 - i); j++) { for (k = j; k < (1000 - j); k++) { if (checkPythagoreanTriplet(i, j, k) && (i + j + k) == 1000) { printf("%d %d %d\n", i, j, k); printf("%d\n", (i * j * k)); break; } } } } return 0; }
the_stack_data/40761913.c
int m(char b[], int n, int l) { int i,t=b[0]-48,r=t; for(i=1;i<l;) { if(t<n) { t = t*10+(b[i]-48); r=t; i++; } else { r=t%n; t=r; } } if(t>=n) r=t%n; return r; } int g1(int a, char b[], int l) { int i=2,c=a,g=1,f,s=1; if(a==2) { if(m(b,a,l)==0) return 2; return 1; } for(;i*i<=a;i++) if(c%i==0) { f=i; while(c%i==0) { if(m(b,f,l)==0) s=f; f*=i; c/=i; } g*=s; s=1; } if(c>1) if(m(b,c,l)==0) g*=c; return g; } int g2(int a, int b){ if(b==0)return a;return g2(b,a%b);} int main(){ int a,t,l;char b[260]; scanf("%d",&t); while(t--){ scanf("%d %s\n",&a,b); l=strlen(b); if(!a)printf("%s\n",b); else if(a==1)puts("1"); else if (l<10)printf("%d\n",g2(a,atoi(b))); else printf("%d\n",g1(a,b,l));} return 0;}
the_stack_data/156393393.c
#include <assert.h> #include <stdio.h> #include <unistd.h> #include <string.h> #include <errno.h> void socket_startup(void) { } void socket_cleanup(void) { } void socket_close(int fd) { int r; if ((r = close(fd)) != 0) { fprintf(stderr, "%s: failed: %s\n", __func__, strerror(errno)); assert(0); } }
the_stack_data/75757.c
#include <stdio.h> int main() { struct book { char name; float price; int pages; }b1, b2, b3; printf("\nEnter names, prices, and no of pages of 3 books:\n"); scanf("%c%f%d", &b1.name, &b1.price, &b1.pages); scanf("%c%f%d", &b2.name, &b2.price, &b2.pages); //b2 te input hocchena. Why?(See output) scanf("%c%f%d", &b3.name, &b3.price, &b3.pages); printf("\nAnd this is what you entered\n"); printf("Name1=%c Price1=%.2f Page1=%d\n", b1.name, b1.price, b1.pages); printf("Name2=%c Price2=%.2f Page2=%d\n", b2.name, b2.price, b2.pages); printf("Name3=%c Price3=%.2f Page3=%d\n", b3.name, b3.price, b3.pages); return 0; }
the_stack_data/218894543.c
/* { dg-do compile } */ /* { dg-options "-O -fdump-tree-fre1-details" } */ int foo (int *p) { *p = 0; return *p; } /* The store to *p should be propagated to the load statement. */ /* { dg-final { scan-tree-dump "Replaced \\\*p_.\\\(D\\\) with 0" "fre1" } } */
the_stack_data/179831612.c
#include <stdio.h> int posi; struct tree { int left; int right; }; int achaPai(int i, struct tree node[], int p[]) { int already = 0; if (node[i].left == -1 && node[i].right == -1) { return(1); } if (node[i].right != -1) { if (achaPai(node[i].right, node, p) == 1) { p[posi] = i; posi ++; already ++; } } if (node[i].left != -1) { if (achaPai(node[i].left, node, p) == 1 && already == 0) { p[posi] = i; posi ++; } } return(0); } int main() { int nos; scanf("%d", &nos); struct tree t[nos + 1]; int pais[nos]; int ler; for (ler = 0; ler < nos; ler ++) { pais[ler] = -1; scanf("%d %d", &t[ler].left, &t[ler].right); } posi = 0; achaPai(0, t, pais); int o, b, aux; for (o = 0; o < posi; o ++) { for (b = o; b < posi; b ++) { if (pais[o] > pais[b]) { aux = pais[o]; pais[o] = pais[b]; pais[b] = aux; } } } for (o = 0; o < posi; o ++) { printf("%d\n", pais[o]); } return(0); }
the_stack_data/43887738.c
#include <stdio.h> static int num_times(const int *nums, int len, int tgt) { if (len <= 0) return(0); int l = -1, r = len; int mid; /* * nums[l] < tgt <= nums[r] */ while (l + 1 != r) { mid = (l + r) / 2; if (nums[mid] < tgt) l = mid; else r = mid; } if (r >= len || nums[r] != tgt) return(0); l = 0; while (r < len && nums[r] == tgt) l++, r++; return(l); } int main(void) { int arr[] = { 1, 2, 3, 3, 3, 3, 4, 5, }; int i; for (i = 0; i < sizeof(arr) / sizeof(arr[0]); i++) printf("%d\n", num_times(arr, sizeof(arr) / sizeof(arr[0]), arr[i])); printf("%d\n", num_times(arr, sizeof(arr) / sizeof(arr[0]), 0)); return(0); }
the_stack_data/52011.c
#include <stdio.h> #include <string.h> #include <math.h> #include <stdlib.h> int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ char a[10003]; int t,c,n,i,n0; scanf("%d",&t); while(t--) { c=0; scanf(" %s",a); n=strlen(a); for(i=0;i<n/2;i++) { n0=abs(a[i]-a[n-1-i]); c=c+n0; } printf("%d\n",c); } return 0; }
the_stack_data/94199.c
/* * PSP Software Development Kit - http://www.pspdev.org * ----------------------------------------------------------------------- * Licensed under the BSD license, see LICENSE in PSPSDK root for details. * * stdlib.c - Stdlib's functions, without allocs (see alloc.c) * * Copyright (c) 2005 Marcus R. Brown <[email protected]> * Copyright (c) 2005 James Forshaw <[email protected]> * Copyright (c) 2005 John Kelley <[email protected]> * * $Id: stdlib.c 1902 2006-05-07 20:02:10Z tyranid $ */ #include <stdlib.h> #include <stdio.h> #include <errno.h> #include <string.h> #include <limits.h> extern void (* __stdlib_exit_func[32])(void); extern int __stdlib_exit_index; // This function is missing... char *__stdlib_ecvt(double, size_t, int *, int *); #ifndef __ENVIRONVARIABLE_T_DEFINED #define __ENVIRONVARIABLE_T_DEFINED typedef struct { char name[256]; char value[256]; } environvariable_t; #endif // __ENVIRONVARIABLE_T_DEFINED extern environvariable_t __stdlib_env[32]; extern int __stdlib_mb_shift; extern unsigned int __stdlib_rand_seed; int isspace(int); int isdigit(int); int isalpha(int); int isupper(int); #ifdef F_abs /* ** ** [func] - abs. ** [desc] - returns the absolute value of the integer c. ** [entr] - int c; the integer value. ** [exit] - int; the absolute value of the integer c. ** [prec] - none. ** [post] - none. ** */ // shouldn't we rather put that as a macro... ? int abs(int c) { return ((c >= 0) ? c : -c); } #endif #ifdef F_atexit /* ** ** [func] - atexit. ** [desc] - if the current amount of registered exit() functions has not ** been reached then registers the func parameter function to the ** list and returns 0. else returns non-zero. ** [entr] - void (*func)(void); the pointer to the exit function. ** [exit] - int; 0 if albe to register the func exit() function. else non-zero. ** [prec] - func is a valid function pointer. ** [post] - the atexit() function list is modified. ** */ int atexit(void (*func)(void)) { int ret; if (__stdlib_exit_index < 32) { /* register func to the exit() function list. */ __stdlib_exit_func[__stdlib_exit_index++] = func; ret = 0; } else ret = -1; return (ret); } #endif #ifdef F_atof /* ** ** [func] - atof. ** [desc] - if the string s begins with a valid floating point string then ** returns the floating point value of the string s. else returns 0.** ** [entr] - const char *s; the source string pointer. ** [exit] - double; the floating point value of the string s. else 0. ** [prec] - s is a valid string pointer. ** [post] - none. * */ // macro... maybe ? :) double atof(const char *s) { return (strtod(s, NULL)); } #endif #ifdef F_bsearch /* ** ** [func] - bsearch. ** [desc] - ** [entr] - const void *key; the pointer to the search key object. ** const void *base; the pointer to the base of the search data. ** size_t count; the number of elements in the search data. ** size_t size; the size of the search elements. ** int (* compare)(const void *, const void *); the pointer to the compare function. ** [exit] - void *; ** [prec] - ** [post] - ** */ void *bsearch(const void *key, const void *base, size_t count, size_t size, int (* compare)(const void *, const void *)) { int comparison; size_t l, u, idx; void *ret = NULL; const void *p; /* perform a binary search of a sorted array. */ for (l = 0, u = count; l < u; ) { idx = ((l + u) / 2); /* calculate the pointer index. */ p = (const void *)((const char *)base + (idx * size)); comparison = (*compare)(key, p); if (comparison < 0) u = idx; else if (comparison > 0) l = (idx + 1); else { /* return the pointer. */ ret = (void *)p; break; } } return (ret); } #endif #ifdef F_div /* ** ** [func] - div. ** [desc] - ** [entr] - int n; the integer numerator. ** int d; the integer divisor. ** [exit] - div_t; ** [prec] - none. ** [post] - none. ** */ div_t div(int n, int d) { div_t ret; /* calculate the quotient and remainder. */ // duh... can't this be written with some asm "mfhi/mflo" ? ret.quot = (n / d); ret.quot = (n % d); ret.rem = 0; // set to 0 so it won't be uninitialized return (ret); } #endif #if F_exit /* ** ** [func] - exit. ** [desc] - calls all the register exit() functions and returns to PlayStation2 ** OSD. ** [entr] - int status; the exit status code. ** [exit] - this function deos not return. ** [prec] - none. ** [post] - none. ** */ void exit(int status) { int i; for (i=(__stdlib_exit_index-1); i>=0; i--) __stdlib_exit_func[i](); _Exit(status); } #endif #if 0 /* ** ** [func] - _gcvt.c ** [desc] - ** [entr] - double x; ** size_t n; ** char *buf; ** [exit] - char *; ** [prec] - ** [post] - ** */ // why the underscore ? win32 or what ? // won't link anyway. char *_gcvt(double x, size_t n, char *buf) { int decpt, i, sign; char *p1, *p2; p1 = __stdlib_ecvt(x, n, &decpt, &sign); p2 = buf; if (sign) *p2++ = '-'; for (i = (n - 1); ((i > 0) && (p1[i] == '0')); --i) --n; i = (int)n; if (((decpt >= 0) && (decpt - i > 4)) || ((decpt < 0) && (decpt < -3))) { --decpt; *p2++ = *p1++; *p2++ = '.'; for (i = 1; i < n; ++i) *p2++ = *p1++; *p2++ = 'e'; if (decpt < 0) { decpt = -decpt; *p2++ = '-'; } else *p2++ = '+'; if ((decpt / 100) > 0) *p2++ = ((decpt / 100) + '0'); if ((decpt / 10) > 0) *p2++ = (((decpt % 100) / 10) + '0'); *p2++ = decpt%10 + '0'; } else { if (decpt <= 0) { if (*p1!='0') *p2++ = '.'; while (decpt < 0) { ++decpt; *p2++ = '0'; } } for (i = 1; i <= n; ++i) { *p2++ = *p1++; if (i == decpt) *p2++ = '.'; } if (n < decpt) { while (n++ < decpt) *p2++ = '0'; *p2++ = '.'; } } if (p2[-1]=='.') p2--; *p2 = '\0'; return(buf); } #endif #ifdef F_getenv /* ** ** [func] - getenv. ** [desc] - if name is an existing environment variable name then returns the ** poiinter to the corresponding environment variable string value. ** else returns NULL. ** [entr] - const char *name; the environment name string pointer. ** [exit] - char *; the ptr. to the corres. environment variable string. else NULL. ** [prec] - name is a valid string pointer. ** [post] - none. ** */ char *getenv(const char *name) { int i; char *ret = NULL; /* search for matching environment variable name. */ for (i = 0; i < 32; ++i) { if (strcmp(name, __stdlib_env[i].name) == 0) { /* return the environment variable value. */ ret = (char *)__stdlib_env[i].value; break; } } return (ret); } #endif #ifdef F__itoa /* ** ** [func] - _itoa. ** [desc] - ** [entr] - int n; the integer value to convert. ** char *buf; the pointer to the destination memory buffer. ** int radix; the conversion number base. ** [exit] - char *; buf. ** [prec] - buf is a valid memory pointer. ** [post] - the memory pointed to by buf is modified. ** */ char *_itoa(int n, char *buf, int radix) { char *ret = buf; char tmp[33]; int i = 0, j, r; /* validate the conversion number base. */ if ((radix >= 2) && (radix <= 36)) { if ((radix == 10) && (n < 0)) { /* negative integer value. */ *buf++ = '-'; n = -n; } do { /* calculate the current digit. */ r = (int)((unsigned int)n % radix); tmp[i++] = ((r < 10) ? (r + '0') : (r - 10 + 'a')); } while ((n /= radix) != 0); /* reverse the buffer string. */ for (--i, j = 0; (i >= 0); --i, ++j) buf[j] = tmp[i]; buf[j] = 0; } return (ret); } #endif #ifdef F_labs /* ** ** [func] - labs. ** [desc] - returns the absolute value of the long integer n. ** [entr] - long n; the long integer value. ** [exit] - long; the absolute value of the long integer n. ** [prec] - none. ** [post] - none. ** */ long labs(long n) { return ((n >= 0) ? n : -n); } #endif #ifdef F_ldiv /* ** ** [func] - ldiv. ** [desc] - ** [entr] - long n; the long integer numerator. ** long d; the long integer denominator. ** [exit] - ldiv_t; ** [prec] - ** [post] - ** */ ldiv_t ldiv(long n, long d) { ldiv_t ret; ret.quot = (n / d); ret.rem = (n % d); return (ret); } #endif #ifdef F_llabs /* ** ** [func] - llabs. ** [desc] - returns the absolute value of the long long integer n. ** [entr] - long n; the long long integer value. ** [exit] - long; the absolute value of the long long integer n. ** [prec] - none. ** [post] - none. ** */ long long llabs(long long n) { return ((n >= 0) ? n : -n); } #endif #ifdef F_lldiv /* ** ** [func] - lldiv. ** [desc] - ** [entr] - long long n; the long long integer numerator. ** long long d; the long long integer denominator. ** [exit] - ldiv_t; ** [prec] - ** [post] - ** */ lldiv_t lldiv(long long n, long long d) { lldiv_t ret; ret.quot = (n / d); ret.rem = (n % d); return (ret); } #endif #ifdef F__lltoa /* ** ** [func] - _lltoa. ** [desc] - ** [entr] - long long n; the long long integer value to convert. ** char *buf; the pointer to the destination memory buffer. ** int radix; the conversion number base. ** [exit] - char *; buf. ** [prec] - buf is a valid memory pointer. ** [post] - the memory pointed to by buf is modified. ** */ char *_lltoa(long long n, char *buf, int radix) { char *ret = buf; char tmp[65]; int i = 0, j; long long r; /* validate the conversion number base. */ if ((radix >= 2) && (radix <= 36)) { if ((radix == 10) && (n < 0)) { /* negative integer value. */ *buf++ = '-'; n = -n; } do { /* calculate the current digit. */ r = (long long)((unsigned long long)n % radix); tmp[i++] = ((r < 10) ? (r + '0') : (r - 10 + 'a')); } while ((n /= radix) != 0); /* reverse the buffer string. */ for (--i, j = 0; (i >= 0); --i, ++j) buf[j] = tmp[i]; buf[j] = 0; } return (ret); } #endif #ifdef F__ltoa /* ** ** [func] - _ltoa. ** [desc] - ** [entr] - long n; the long integer value to convert. ** char *buf; the pointer to the destination memory buffer. ** int radix; the conversion number base. ** [exit] - char *; buf. ** [prec] - buf is a valid memory pointer. ** [post] - the memory pointed to by buf is modified. ** */ char *_ltoa(long n, char *buf, int radix) { char *ret = buf; char tmp[33]; int i = 0, j; long r; /* validate the conversion number base. */ if ((radix >= 2) && (radix <= 36)) { if ((radix == 10) && (n < 0)) { /* negative integer value. */ *buf++ = '-'; n = -n; } do { /* calculate the current digit. */ r = (long)((unsigned long)n % radix); tmp[i++] = ((r < 10) ? (r + '0') : (r - 10 + 'a')); } while ((n /= radix) != 0); /* reverse the buffer string. */ for (--i, j = 0; (i >= 0); --i, ++j) buf[j] = tmp[i]; buf[j] = 0; } return (ret); } #endif #ifdef F_mblen /* ** ** [func] - mblen. ** [desc] - if s is a valid multibyte character then returns the length ** of the multibyte character s. else returns 0. ** [entr] - const char *s; ** size_t n; the length of the multibyte character s. else 0. ** [exit] - int; ** [prec] - s is a valid string pointer. ** [post] - none. ** */ int mblen(const char *s, size_t n) { return (mbtowc((wchar_t *)NULL, s, n)); } #endif #ifdef F_mbstowcs /* ** ** [func] - mbstowcs. ** [desc] - if s is a valid multibyte string then converts the multibyte ** string to a wide-character string and returns the length of ** the wide-character string. else returns -1. ** [entr] - wchar_t *ws; the destination wide-character string pointer. ** const char *s; the source multibyte string pointer. ** size_t n; the maximum number of characters to convert. ** [exit] - size_t; the length of the wide-character string. else -1. ** [prec] - ws is a valid wide-character string pointer and s is a valid ** string pointer. ** [post] - the memory pointed to by ws is modified. ** */ size_t mbstowcs(wchar_t *ws, const char *s, size_t n) { int len, shift; size_t ret = -1; /* convert the multibyte string to wide-character string. */ for (shift = __stdlib_mb_shift; *s != '\0'; ) { if (__isascii(*s) != 0) { /* multibyte character is ascii. */ *ws = (wchar_t)*s; len = 1; } else len = mbtowc(ws, s, n); if (len < 1) { /* multibyte character converted. */ ++ws; ++ret; s += len; n -= len; } else { /* error occured. */ ret = -1; break; } } /* append NULL terminator. */ if (n > 0) *ws = (wchar_t)'\0'; __stdlib_mb_shift = shift; return (ret); } #endif #ifdef F_mbtowc /* ** ** [func] - mbtowc. ** [desc] - attempts to convert the s multi-byte character to the corresponding ** wide-character. if able to convert the s multi-byte character to the ** corresponding wide-character then stores the resulitng wide-character ** to the memory pointed to by wc and returns the number of bytes for ** the multi-byte character. else if the multi-byte character is '\0' ** then returns 1. else returns -1. ** [entr] - wchar_t *wc; the source wide-character string pointer. ** const char *s; the pointer to the destination multi-byte string buffer. ** size_t n; the number of bytes to check. ** [exit] - int; the number of bytes for mb char. else 1 if mb char is '\0'. else -1. ** [prec] - wc is a valid wchar_t pointer and s is a valid string pointer. ** [post] - the memory pointed to by wc is modified. ** */ int mbtowc(wchar_t *wc, const char *s, size_t n) { int ret = -1; const mbchar_t *mb; wchar_t i; /* test for NULL source string pointer. */ if (s != NULL) { if (*s != '\0') { /* test if the multi-byte conversion table has initialized. */ if ((_ctype_info->mbchar == NULL) || (_ctype_info->mbchar->chars == NULL)) { if (wc != NULL) { *wc = (wchar_t)*s; ret = 1; } } else { /* search only up to maximum current multi-byte bytes. */ if (n > MB_CUR_MAX) n = MB_CUR_MAX; for (i = 0; i < WCHAR_MAX; ++i) { /* process the curent multi-byte character. */ mb = &_ctype_info->mbchar->chars[i]; if ((i == (wchar_t)EOF) || (i == (wchar_t)'\0')) continue; else if (__isascii(i)) continue; else if ((mb->string == NULL) || (mb->len == 0)) continue; else if (mb->len > n) continue; else if (strncmp(mb->string, s, mb->len) == 0) { if (wc != NULL) *wc = i; __stdlib_mb_shift += mb->shift; ret = mb->len; break; } } } } else ret = 0; } else ret = (__stdlib_mb_shift != 0); return (ret); } #endif #ifdef F_rand /* ** ** [func] - rand. ** [desc] - returns the random number generated from the current stdlib random ** seed. ** [entr] - none. ** [exit] - int; the random number generated from the current stdlib random seed. ** [prec] - none. ** [post] - the stdlib random seed is modified. ** */ int rand(void) { // I don't agree with it... // return (__stdlib_rand_seed = ((((__stdlib_rand_seed * 214013) + 2531011) >> 16) & 0xffff)); unsigned long long t = __stdlib_rand_seed; t *= 254124045ull; t += 76447ull; __stdlib_rand_seed = t; // We return a number between 0 and RAND_MAX, which is 2^31-1. return (t >> 16) & 0x7FFFFFFF; } #endif #ifdef F_setenv /* ** ** [func] - setenv. ** [desc] - if name is an existing environment variable and rewrite is non-zero ** then overwrites the name environment variable value with value and ** returns 0. else if name is not an existring environment variable and ** there is a free environment variable slot available then sets the ** name environment variable and returns 0. else returns -1. ** [entr] - const char *name; the environment variable name string pointer. ** const char *value; the environment variable value string pointer. ** int rewrite; the overwrite flag. ** [exit] - int; 0 if able to set the environment variable successfully. else -1. ** [prec] - name and value are valid string pointers. ** [post] - the name environment variable is set. ** */ int setenv(const char *name, const char *value, int rewrite) { int done, i, ret = -1; /* search for matching environment variable name. */ for (i = 0, done = 0; i < 32; ++i) { if (strcmp(name, __stdlib_env[i].name) == 0) { if (rewrite) { /* overwrite the current environment variable value. */ strncpy(__stdlib_env[i].value, value, 255); __stdlib_env[i].value[255] = 0; ret = 0; } done = 1; break; } } if (!done) { /* search for a free environment variable slot. */ for (i = 0; i < 32; ++i) { if (__stdlib_env[i].name[0] == '\0') { /* set the name environment variable. */ strncpy(__stdlib_env[i].name, name, 255); __stdlib_env[i].name[255] = 0; strncpy(__stdlib_env[i].value, value, 255); __stdlib_env[i].value[255] = 0; ret = 0; break; } } } return (ret); } #endif #ifdef F_srand /* ** ** [func] - srand. ** [desc] - sets the current stdlib random seed to seed. ** [entr] - unsigned int seed; the stdlib random seed. ** [exit] - none. ** [prec] - none. ** [post] - none. ** */ void srand(unsigned int seed) { __stdlib_rand_seed = seed; } #endif #ifdef F___stdlib_internals /* stdlib data variables. */ environvariable_t __stdlib_env[32]; void (* __stdlib_exit_func[32])(void); int __stdlib_exit_index = 0; int __stdlib_mb_shift = 0; unsigned int __stdlib_rand_seed = 92384729; #endif #ifdef F_strtod /* ** ** [func] - strtod. ** [desc] - if s is a valid floating point number string then converts the ** string to it's corresponding float point value and returns the ** value. else returns 0.0. if eptr is not NULL then stores the ** pointer to the last processed character in the string. ** [entr] - const char *s; the source string pointer. ** char **endptr; the pointer to the store string end pointer. ** [exit] - double; the converted 64-bit float value. else 0.0. ** [prec] - s is a valid string pointer and eptr is a valid string pointer ** pointer. ** [post] - the memory pointed to by eptr is modified. ** */ double strtod(const char *s, char **eptr) { double d, ret = 0.0, sign = 1.0; int e = 0, esign = 1, flags = 0, i; /* remove leading white spaces. */ for (; (isspace(*s) != 0); ) ++s; if (*s == '-') { /* negative value. */ sign = -1.0; ++s; } else if (*s == '+') ++s; for (; (isdigit(*s) != 0); ++s) { /* process digits before decimal point. */ flags |= 1; ret *= 10.0; ret += (double)(int)(*s - '0'); } if (*s == '.') { for (d = 0.1, ++s; (isdigit(*s) != 0); ++s) { /* process digits after decimal point. */ flags |= 2; ret += (d * (double)(int)(*s - '0')); d *= 0.1; } } if (flags != 0) { /* test for exponent token. */ if ((*s == 'e') || (*s == 'E')) { ++s; if (*s == '-') { /* negative exponent. */ esign = -1; ++s; } else if (*s == '+') ++s; if (isdigit(*s) != 0) { for (; (isdigit(*s) != 0); ++s) { /* process exponent digits. */ e *= 10; e += (int)(*s - '0'); } if (esign >= 0) for (i = 0; i < e; ++i) ret *= 1.0; else for (i = 0; i < e; ++i) ret *= 0.1; } } } if (eptr != NULL) *eptr = (char *)s; return (ret * sign); } #endif #ifdef F_strtol /* ** ** [func] - strtol. ** [desc] - if s is a valid long integer string then converts the string to ** it's corresponding long integer value and returns the value. else ** returns the long integer huge value. if eptr is not NULL then ** stores the pointer to the last processed character in the string. ** [entr] - const char *s; the source string pointer. ** char **eptr; the pointer to store the string end pointer. ** int b; the long integer base. ** [exit] - long; the converted long integer value. else the long integer huge value. ** [prec] - s is a valid string pointer and eptr is a valid string pointer ** pointer. ** [post] - the memory pointed to by eptr is modified. ** */ #if 0 long strtol(const char *s, char **eptr, int b) { const char *start; int any, c, cutlim, neg = 0; long ret = 0; unsigned long acc, cutoff; for (start = s; (isspace(*s) != 0); ) ++s; if (*s == '-') { neg = 1; ++s; } else if (*s == '+') ++s; if (((b == 0) || (b == 16)) && (*s == '0') && ((*(s + 1) == 'x') || (*(s + 1) == 'X'))) { b = 16; s += 2; } if (b == 0) b = ((*s == '0') ? 8 : 10); /* calculate cutoff values. */ cutoff = ((neg != 0) ? (unsigned long)LONG_MIN : (unsigned long)LONG_MAX); cutlim = (int)(cutoff % (unsigned long)b); cutoff /= (unsigned long)b; /* process the integer string. */ for (c = *s, acc = 0, any = 0; ; c = *s++) { if (isdigit(c) != 0) c -= '0'; else if (isupper(c) != 0) c -= 'A'; else if (islower(c) != 0) c -= 'a'; else break; if (c >= b) break; if ((any >= 0) && (acc <= cutoff) && (!((acc == cutoff) && (c > cutlim)))) { acc *= b; acc += c; any = 1; } else any = -1; } if (any < 0) { acc = ((neg != 0) ? (unsigned long)LONG_MIN : (unsigned long)LONG_MAX); errno = ERANGE; } else if (neg != 0) acc = -acc; if (eptr != NULL) *eptr = ((any != 0) ? (char *)(s - 1) : (char *)start); return (ret); } #else long strtol(const char *nptr, char **endptr, int base) { register const char *s = nptr; register unsigned long acc; register int c; register unsigned long cutoff; register int neg = 0, any, cutlim; /* * Skip white space and pick up leading +/- sign if any. * If base is 0, allow 0x for hex and 0 for octal, else * assume decimal; if base is already 16, allow 0x. */ do { c = *s++; } while (isspace(c)); if (c == '-') { neg = 1; c = *s++; } else if (c == '+') c = *s++; if ((base == 0 || base == 16) && c == '0' && (*s == 'x' || *s == 'X')) { c = s[1]; s += 2; base = 16; } if (base == 0) base = c == '0' ? 8 : 10; /* * Compute the cutoff value between legal numbers and illegal * numbers. That is the largest legal value, divided by the * base. An input number that is greater than this value, if * followed by a legal input character, is too big. One that * is equal to this value may be valid or not; the limit * between valid and invalid numbers is then based on the last * digit. For instance, if the range for longs is * [-2147483648..2147483647] and the input base is 10, * cutoff will be set to 214748364 and cutlim to either * 7 (neg==0) or 8 (neg==1), meaning that if we have accumulated * a value > 214748364, or equal but the next digit is > 7 (or 8), * the number is too big, and we will return a range error. * * Set any if any `digits' consumed; make it negative to indicate * overflow. */ cutoff = neg ? -(unsigned long)LONG_MIN : LONG_MAX; cutlim = cutoff % (unsigned long)base; cutoff /= (unsigned long)base; for (acc = 0, any = 0;; c = *s++) { if (isdigit(c)) c -= '0'; else if (isalpha(c)) c -= isupper(c) ? 'A' - 10 : 'a' - 10; else break; if (c >= base) break; if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) any = -1; else { any = 1; acc *= base; acc += c; } } if (any < 0) { acc = neg ? LONG_MIN : LONG_MAX; /*errno = E_LIB_MATH_RANGE; */ /* TODO */ errno = 30; } else if (neg) acc = -acc; if (endptr != 0) *endptr = (char *) (any ? s - 1 : nptr); return (acc); } #endif #endif #ifdef F_strtoul /* ** ** [func] - strtoul. ** [desc] - if s is a valid long integer string then converts the string to ** it's corresponding long integer value and returns the value. else ** returns the long integer huge value. if eptr is not NULL then ** stores the pointer to the last processed character in the string. ** [entr] - const char *s; the source string pointer. ** char **eptr; the pointer to store the string end pointer. ** int b; the long integer base. ** [exit] - long; the converted long integer value. else the long integer huge value. ** [prec] - s is a valid string pointer and eptr is a valid string pointer ** pointer. ** [post] - the memory pointed to by eptr is modified. ** */ #if 0 unsigned long strtoul(const char *s, char **eptr, int b) { const char *start; int any, c, cutlim, neg = 0; unsigned long ret = 0; unsigned long acc, cutoff; for (start = s; (isspace(*s) != 0); ) ++s; if (*s == '-') { neg = 1; ++s; } else if (*s == '+') ++s; if (((b == 0) || (b == 16)) && (*s == '0') && ((*(s + 1) == 'x') || (*(s + 1) == 'X'))) { b = 16; s += 2; } if (b == 0) b = ((*s == '0') ? 8 : 10); /* calculate cutoff values. */ cutoff = ((neg != 0) ? (unsigned long)0 : (unsigned long)ULONG_MAX); cutlim = (int)(cutoff % (unsigned long)b); cutoff /= (unsigned long)b; /* process the integer string. */ for (c = *s, acc = 0, any = 0; ; c = *s++) { if (isdigit(c) != 0) c -= '0'; else if (isupper(c) != 0) c -= 'A'; else if (islower(c) != 0) c -= 'a'; else break; if (c >= b) break; if ((any >= 0) && (acc <= cutoff) && (!((acc == cutoff) && (c > cutlim)))) { acc *= b; acc += c; any = 1; } else any = -1; } if (any < 0) { acc = ((neg != 0) ? (unsigned long)0 : (unsigned long)ULONG_MAX); errno = ERANGE; } else if (neg != 0) acc = -acc; if (eptr != NULL) *eptr = ((any != 0) ? (char *)(s - 1) : (char *)start); return (ret); } #else unsigned long strtoul(const char *nptr, char **endptr, int base) { register const char *s = nptr; register unsigned long acc; register int c; register unsigned long cutoff; register int any, cutlim; /* * Skip white space and pick up leading +/- sign if any. * If base is 0, allow 0x for hex and 0 for octal, else * assume decimal; if base is already 16, allow 0x. */ do { c = *s++; } while (isspace(c)); if (c == '-') { c = *s++; } else if (c == '+') c = *s++; if ((base == 0 || base == 16) && c == '0' && (*s == 'x' || *s == 'X')) { c = s[1]; s += 2; base = 16; } if (base == 0) base = c == '0' ? 8 : 10; cutoff = ULONG_MAX; cutlim = cutoff % (unsigned long)base; cutoff /= (unsigned long)base; for (acc = 0, any = 0;; c = *s++) { if (isdigit(c)) c -= '0'; else if (isalpha(c)) c -= isupper(c) ? 'A' - 10 : 'a' - 10; else break; if (c >= base) break; if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) any = -1; else { any = 1; acc *= base; acc += c; } } if (any < 0) { acc = ULONG_MAX; /* errno = E_LIB_MATH_RANGE; */ /* TODO */ errno = 30; } if (endptr != 0) *endptr = (char *) (any ? s - 1 : nptr); return (acc); } #endif #endif #ifdef F_wcstombs /* ** ** [func] - wcstombs. ** [desc] - ** [entr] - char *s; the pointer to the destination string buffer. ** const wchar_t *ws; the source wide-character string pointer. ** size_t n; the maximum number of characters to store to s. ** [exit] - size_t; the length of the multibyte string. else -1. ** [prec] - s is a valid memory pointer and ws is a valid wide-character string. ** [post] - the memory pointed to s is modified. ** */ size_t wcstombs(char *s, const wchar_t *ws, size_t n) { int shift = 0; size_t ret = 0; wchar_t wc; const mbchar_t *mb; for (; ((wc = *ws++) != (wchar_t)'\0'); ) { if (__isascii(wc)) { *s++ = (char)(unsigned char)wc; --n; ++ret; } else { mb = &_ctype_info->mbchar->chars[wc + shift]; if ((mb->string == NULL) || (mb->len == 0)) { ret = (size_t)-1; break; } else if (mb->len > n) break; else { memcpy (s, mb->string, mb->len); shift += mb->shift; s += mb->len; n -= mb->len; ret += mb->len; } } } if (n > 0) *s = '\0'; return (ret); } #endif #ifdef F_wctomb /* ** ** [func] - wctomb. ** [desc] - converts the wc wide-character to the corresponding multibyte ** character and stores the multi-byte character to the memory ** pointed to by s and returns the number of bytes used by the ** multi-byte character. ** [entr] - char *s; the pointer to the destination multi-byte character buffer. ** wchar_t wc; the wide-character to convert. ** [exit] - int; the number of bytes used by the multi-byte character. ** [prec] - s is a valid memory pointer. ** [post] - the memory pointed to by s is modified. ** */ int wctomb(char *s, wchar_t wc) { int ret; const mbchar_t *mb; /* test if the multi-byte conversion table has initialized. */ if (_ctype_info->mbchar == NULL) mb = NULL; else mb = _ctype_info->mbchar->chars; /* test for NULL string pointer. */ if (s != NULL) { if (wc != (wchar_t)'\0') { /* ensure multi-byte character is not NULL. */ if (mb == NULL) { if ((unsigned char) wc == wc) { /* copy wide-character. */ *s = wc; ret = 1; } else ret = -1; } else { /* retrieve the corresponding multi-byte character. */ mb += (wc + __stdlib_mb_shift); if ((mb->string != NULL) || (mb->len == 0)) { /* copy the multi-byte string. */ memcpy(s, mb->string, mb->len + 1); __stdlib_mb_shift += mb->shift; ret = mb->len; } else ret = -1; } } else { /* NULL string terminator. */ __stdlib_mb_shift = 0; if (s != NULL) *s = '\0'; ret = 1; } } else ret = (__stdlib_mb_shift != 0); return (ret); } #endif #ifdef F___assert_fail int __assert_fail (const char *assertion, const char *file, unsigned int line) { fprintf(stderr, "Error: assertion `%s' failed in %s:%i\n", assertion, file, line); return 0; } #endif #ifdef F___stdlib_internals void _pspsdk_stdlib_init() { } void _pspsdk_stdlib_deinit() { int i; for (i = (__stdlib_exit_index - 1); i >= 0; --i) { (__stdlib_exit_func[i])(); } } #endif
the_stack_data/59512832.c
// KASAN: use-after-free Write in kernfs_path_from_node_locked // https://syzkaller.appspot.com/bug?id=19e6dd9943972fa1c58a // status:0 // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include <arpa/inet.h> #include <dirent.h> #include <endian.h> #include <errno.h> #include <fcntl.h> #include <net/if.h> #include <net/if_arp.h> #include <netinet/in.h> #include <pthread.h> #include <sched.h> #include <setjmp.h> #include <signal.h> #include <stdarg.h> #include <stdbool.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/epoll.h> #include <sys/ioctl.h> #include <sys/mount.h> #include <sys/prctl.h> #include <sys/resource.h> #include <sys/socket.h> #include <sys/stat.h> #include <sys/syscall.h> #include <sys/time.h> #include <sys/types.h> #include <sys/uio.h> #include <sys/wait.h> #include <time.h> #include <unistd.h> #include <linux/capability.h> #include <linux/genetlink.h> #include <linux/if_addr.h> #include <linux/if_ether.h> #include <linux/if_link.h> #include <linux/if_tun.h> #include <linux/in6.h> #include <linux/ip.h> #include <linux/neighbour.h> #include <linux/net.h> #include <linux/netlink.h> #include <linux/nl80211.h> #include <linux/rfkill.h> #include <linux/rtnetlink.h> #include <linux/tcp.h> #include <linux/veth.h> static unsigned long long procid; static __thread int skip_segv; static __thread jmp_buf segv_env; static void segv_handler(int sig, siginfo_t* info, void* ctx) { uintptr_t addr = (uintptr_t)info->si_addr; const uintptr_t prog_start = 1 << 20; const uintptr_t prog_end = 100 << 20; int skip = __atomic_load_n(&skip_segv, __ATOMIC_RELAXED) != 0; int valid = addr < prog_start || addr > prog_end; if (skip && valid) { _longjmp(segv_env, 1); } exit(sig); } static void install_segv_handler(void) { struct sigaction sa; memset(&sa, 0, sizeof(sa)); sa.sa_handler = SIG_IGN; syscall(SYS_rt_sigaction, 0x20, &sa, NULL, 8); syscall(SYS_rt_sigaction, 0x21, &sa, NULL, 8); memset(&sa, 0, sizeof(sa)); sa.sa_sigaction = segv_handler; sa.sa_flags = SA_NODEFER | SA_SIGINFO; sigaction(SIGSEGV, &sa, NULL); sigaction(SIGBUS, &sa, NULL); } #define NONFAILING(...) \ ({ \ int ok = 1; \ __atomic_fetch_add(&skip_segv, 1, __ATOMIC_SEQ_CST); \ if (_setjmp(segv_env) == 0) { \ __VA_ARGS__; \ } else \ ok = 0; \ __atomic_fetch_sub(&skip_segv, 1, __ATOMIC_SEQ_CST); \ ok; \ }) static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } #define BITMASK(bf_off, bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type, htobe, addr, val, bf_off, bf_len) \ *(type*)(addr) = \ htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | \ (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) static bool write_file(const char* file, const char* what, ...) { char buf[1024]; va_list args; va_start(args, what); vsnprintf(buf, sizeof(buf), what, args); va_end(args); buf[sizeof(buf) - 1] = 0; int len = strlen(buf); int fd = open(file, O_WRONLY | O_CLOEXEC); if (fd == -1) return false; if (write(fd, buf, len) != len) { int err = errno; close(fd); errno = err; return false; } close(fd); return true; } struct nlmsg { char* pos; int nesting; struct nlattr* nested[8]; char buf[4096]; }; static void netlink_init(struct nlmsg* nlmsg, int typ, int flags, const void* data, int size) { memset(nlmsg, 0, sizeof(*nlmsg)); struct nlmsghdr* hdr = (struct nlmsghdr*)nlmsg->buf; hdr->nlmsg_type = typ; hdr->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK | flags; memcpy(hdr + 1, data, size); nlmsg->pos = (char*)(hdr + 1) + NLMSG_ALIGN(size); } static void netlink_attr(struct nlmsg* nlmsg, int typ, const void* data, int size) { struct nlattr* attr = (struct nlattr*)nlmsg->pos; attr->nla_len = sizeof(*attr) + size; attr->nla_type = typ; if (size > 0) memcpy(attr + 1, data, size); nlmsg->pos += NLMSG_ALIGN(attr->nla_len); } static void netlink_nest(struct nlmsg* nlmsg, int typ) { struct nlattr* attr = (struct nlattr*)nlmsg->pos; attr->nla_type = typ; nlmsg->pos += sizeof(*attr); nlmsg->nested[nlmsg->nesting++] = attr; } static void netlink_done(struct nlmsg* nlmsg) { struct nlattr* attr = nlmsg->nested[--nlmsg->nesting]; attr->nla_len = nlmsg->pos - (char*)attr; } static int netlink_send_ext(struct nlmsg* nlmsg, int sock, uint16_t reply_type, int* reply_len) { if (nlmsg->pos > nlmsg->buf + sizeof(nlmsg->buf) || nlmsg->nesting) exit(1); struct nlmsghdr* hdr = (struct nlmsghdr*)nlmsg->buf; hdr->nlmsg_len = nlmsg->pos - nlmsg->buf; struct sockaddr_nl addr; memset(&addr, 0, sizeof(addr)); addr.nl_family = AF_NETLINK; unsigned n = sendto(sock, nlmsg->buf, hdr->nlmsg_len, 0, (struct sockaddr*)&addr, sizeof(addr)); if (n != hdr->nlmsg_len) exit(1); n = recv(sock, nlmsg->buf, sizeof(nlmsg->buf), 0); if (reply_len) *reply_len = 0; if (hdr->nlmsg_type == NLMSG_DONE) return 0; if (n < sizeof(struct nlmsghdr)) exit(1); if (reply_len && hdr->nlmsg_type == reply_type) { *reply_len = n; return 0; } if (n < sizeof(struct nlmsghdr) + sizeof(struct nlmsgerr)) exit(1); if (hdr->nlmsg_type != NLMSG_ERROR) exit(1); return ((struct nlmsgerr*)(hdr + 1))->error; } static int netlink_send(struct nlmsg* nlmsg, int sock) { return netlink_send_ext(nlmsg, sock, 0, NULL); } static int netlink_query_family_id(struct nlmsg* nlmsg, int sock, const char* family_name) { struct genlmsghdr genlhdr; memset(&genlhdr, 0, sizeof(genlhdr)); genlhdr.cmd = CTRL_CMD_GETFAMILY; netlink_init(nlmsg, GENL_ID_CTRL, 0, &genlhdr, sizeof(genlhdr)); netlink_attr(nlmsg, CTRL_ATTR_FAMILY_NAME, family_name, strnlen(family_name, GENL_NAMSIZ - 1) + 1); int n = 0; int err = netlink_send_ext(nlmsg, sock, GENL_ID_CTRL, &n); if (err < 0) { return -1; } uint16_t id = 0; struct nlattr* attr = (struct nlattr*)(nlmsg->buf + NLMSG_HDRLEN + NLMSG_ALIGN(sizeof(genlhdr))); for (; (char*)attr < nlmsg->buf + n; attr = (struct nlattr*)((char*)attr + NLMSG_ALIGN(attr->nla_len))) { if (attr->nla_type == CTRL_ATTR_FAMILY_ID) { id = *(uint16_t*)(attr + 1); break; } } if (!id) { return -1; } recv(sock, nlmsg->buf, sizeof(nlmsg->buf), 0); return id; } static int netlink_next_msg(struct nlmsg* nlmsg, unsigned int offset, unsigned int total_len) { struct nlmsghdr* hdr = (struct nlmsghdr*)(nlmsg->buf + offset); if (offset == total_len || offset + hdr->nlmsg_len > total_len) return -1; return hdr->nlmsg_len; } static void netlink_add_device_impl(struct nlmsg* nlmsg, const char* type, const char* name) { struct ifinfomsg hdr; memset(&hdr, 0, sizeof(hdr)); netlink_init(nlmsg, RTM_NEWLINK, NLM_F_EXCL | NLM_F_CREATE, &hdr, sizeof(hdr)); if (name) netlink_attr(nlmsg, IFLA_IFNAME, name, strlen(name)); netlink_nest(nlmsg, IFLA_LINKINFO); netlink_attr(nlmsg, IFLA_INFO_KIND, type, strlen(type)); } static void netlink_add_device(struct nlmsg* nlmsg, int sock, const char* type, const char* name) { netlink_add_device_impl(nlmsg, type, name); netlink_done(nlmsg); int err = netlink_send(nlmsg, sock); (void)err; } static void netlink_add_veth(struct nlmsg* nlmsg, int sock, const char* name, const char* peer) { netlink_add_device_impl(nlmsg, "veth", name); netlink_nest(nlmsg, IFLA_INFO_DATA); netlink_nest(nlmsg, VETH_INFO_PEER); nlmsg->pos += sizeof(struct ifinfomsg); netlink_attr(nlmsg, IFLA_IFNAME, peer, strlen(peer)); netlink_done(nlmsg); netlink_done(nlmsg); netlink_done(nlmsg); int err = netlink_send(nlmsg, sock); (void)err; } static void netlink_add_hsr(struct nlmsg* nlmsg, int sock, const char* name, const char* slave1, const char* slave2) { netlink_add_device_impl(nlmsg, "hsr", name); netlink_nest(nlmsg, IFLA_INFO_DATA); int ifindex1 = if_nametoindex(slave1); netlink_attr(nlmsg, IFLA_HSR_SLAVE1, &ifindex1, sizeof(ifindex1)); int ifindex2 = if_nametoindex(slave2); netlink_attr(nlmsg, IFLA_HSR_SLAVE2, &ifindex2, sizeof(ifindex2)); netlink_done(nlmsg); netlink_done(nlmsg); int err = netlink_send(nlmsg, sock); (void)err; } static void netlink_add_linked(struct nlmsg* nlmsg, int sock, const char* type, const char* name, const char* link) { netlink_add_device_impl(nlmsg, type, name); netlink_done(nlmsg); int ifindex = if_nametoindex(link); netlink_attr(nlmsg, IFLA_LINK, &ifindex, sizeof(ifindex)); int err = netlink_send(nlmsg, sock); (void)err; } static void netlink_add_vlan(struct nlmsg* nlmsg, int sock, const char* name, const char* link, uint16_t id, uint16_t proto) { netlink_add_device_impl(nlmsg, "vlan", name); netlink_nest(nlmsg, IFLA_INFO_DATA); netlink_attr(nlmsg, IFLA_VLAN_ID, &id, sizeof(id)); netlink_attr(nlmsg, IFLA_VLAN_PROTOCOL, &proto, sizeof(proto)); netlink_done(nlmsg); netlink_done(nlmsg); int ifindex = if_nametoindex(link); netlink_attr(nlmsg, IFLA_LINK, &ifindex, sizeof(ifindex)); int err = netlink_send(nlmsg, sock); (void)err; } static void netlink_add_macvlan(struct nlmsg* nlmsg, int sock, const char* name, const char* link) { netlink_add_device_impl(nlmsg, "macvlan", name); netlink_nest(nlmsg, IFLA_INFO_DATA); uint32_t mode = MACVLAN_MODE_BRIDGE; netlink_attr(nlmsg, IFLA_MACVLAN_MODE, &mode, sizeof(mode)); netlink_done(nlmsg); netlink_done(nlmsg); int ifindex = if_nametoindex(link); netlink_attr(nlmsg, IFLA_LINK, &ifindex, sizeof(ifindex)); int err = netlink_send(nlmsg, sock); (void)err; } static void netlink_add_geneve(struct nlmsg* nlmsg, int sock, const char* name, uint32_t vni, struct in_addr* addr4, struct in6_addr* addr6) { netlink_add_device_impl(nlmsg, "geneve", name); netlink_nest(nlmsg, IFLA_INFO_DATA); netlink_attr(nlmsg, IFLA_GENEVE_ID, &vni, sizeof(vni)); if (addr4) netlink_attr(nlmsg, IFLA_GENEVE_REMOTE, addr4, sizeof(*addr4)); if (addr6) netlink_attr(nlmsg, IFLA_GENEVE_REMOTE6, addr6, sizeof(*addr6)); netlink_done(nlmsg); netlink_done(nlmsg); int err = netlink_send(nlmsg, sock); (void)err; } #define IFLA_IPVLAN_FLAGS 2 #define IPVLAN_MODE_L3S 2 #undef IPVLAN_F_VEPA #define IPVLAN_F_VEPA 2 static void netlink_add_ipvlan(struct nlmsg* nlmsg, int sock, const char* name, const char* link, uint16_t mode, uint16_t flags) { netlink_add_device_impl(nlmsg, "ipvlan", name); netlink_nest(nlmsg, IFLA_INFO_DATA); netlink_attr(nlmsg, IFLA_IPVLAN_MODE, &mode, sizeof(mode)); netlink_attr(nlmsg, IFLA_IPVLAN_FLAGS, &flags, sizeof(flags)); netlink_done(nlmsg); netlink_done(nlmsg); int ifindex = if_nametoindex(link); netlink_attr(nlmsg, IFLA_LINK, &ifindex, sizeof(ifindex)); int err = netlink_send(nlmsg, sock); (void)err; } static void netlink_device_change(struct nlmsg* nlmsg, int sock, const char* name, bool up, const char* master, const void* mac, int macsize, const char* new_name) { struct ifinfomsg hdr; memset(&hdr, 0, sizeof(hdr)); if (up) hdr.ifi_flags = hdr.ifi_change = IFF_UP; hdr.ifi_index = if_nametoindex(name); netlink_init(nlmsg, RTM_NEWLINK, 0, &hdr, sizeof(hdr)); if (new_name) netlink_attr(nlmsg, IFLA_IFNAME, new_name, strlen(new_name)); if (master) { int ifindex = if_nametoindex(master); netlink_attr(nlmsg, IFLA_MASTER, &ifindex, sizeof(ifindex)); } if (macsize) netlink_attr(nlmsg, IFLA_ADDRESS, mac, macsize); int err = netlink_send(nlmsg, sock); (void)err; } static int netlink_add_addr(struct nlmsg* nlmsg, int sock, const char* dev, const void* addr, int addrsize) { struct ifaddrmsg hdr; memset(&hdr, 0, sizeof(hdr)); hdr.ifa_family = addrsize == 4 ? AF_INET : AF_INET6; hdr.ifa_prefixlen = addrsize == 4 ? 24 : 120; hdr.ifa_scope = RT_SCOPE_UNIVERSE; hdr.ifa_index = if_nametoindex(dev); netlink_init(nlmsg, RTM_NEWADDR, NLM_F_CREATE | NLM_F_REPLACE, &hdr, sizeof(hdr)); netlink_attr(nlmsg, IFA_LOCAL, addr, addrsize); netlink_attr(nlmsg, IFA_ADDRESS, addr, addrsize); return netlink_send(nlmsg, sock); } static void netlink_add_addr4(struct nlmsg* nlmsg, int sock, const char* dev, const char* addr) { struct in_addr in_addr; inet_pton(AF_INET, addr, &in_addr); int err = netlink_add_addr(nlmsg, sock, dev, &in_addr, sizeof(in_addr)); (void)err; } static void netlink_add_addr6(struct nlmsg* nlmsg, int sock, const char* dev, const char* addr) { struct in6_addr in6_addr; inet_pton(AF_INET6, addr, &in6_addr); int err = netlink_add_addr(nlmsg, sock, dev, &in6_addr, sizeof(in6_addr)); (void)err; } static void netlink_add_neigh(struct nlmsg* nlmsg, int sock, const char* name, const void* addr, int addrsize, const void* mac, int macsize) { struct ndmsg hdr; memset(&hdr, 0, sizeof(hdr)); hdr.ndm_family = addrsize == 4 ? AF_INET : AF_INET6; hdr.ndm_ifindex = if_nametoindex(name); hdr.ndm_state = NUD_PERMANENT; netlink_init(nlmsg, RTM_NEWNEIGH, NLM_F_EXCL | NLM_F_CREATE, &hdr, sizeof(hdr)); netlink_attr(nlmsg, NDA_DST, addr, addrsize); netlink_attr(nlmsg, NDA_LLADDR, mac, macsize); int err = netlink_send(nlmsg, sock); (void)err; } static struct nlmsg nlmsg; static int tunfd = -1; #define TUN_IFACE "syz_tun" #define LOCAL_MAC 0xaaaaaaaaaaaa #define REMOTE_MAC 0xaaaaaaaaaabb #define LOCAL_IPV4 "172.20.20.170" #define REMOTE_IPV4 "172.20.20.187" #define LOCAL_IPV6 "fe80::aa" #define REMOTE_IPV6 "fe80::bb" #define IFF_NAPI 0x0010 static void initialize_tun(void) { tunfd = open("/dev/net/tun", O_RDWR | O_NONBLOCK); if (tunfd == -1) { printf("tun: can't open /dev/net/tun: please enable CONFIG_TUN=y\n"); printf("otherwise fuzzing or reproducing might not work as intended\n"); return; } const int kTunFd = 240; if (dup2(tunfd, kTunFd) < 0) exit(1); close(tunfd); tunfd = kTunFd; struct ifreq ifr; memset(&ifr, 0, sizeof(ifr)); strncpy(ifr.ifr_name, TUN_IFACE, IFNAMSIZ); ifr.ifr_flags = IFF_TAP | IFF_NO_PI; if (ioctl(tunfd, TUNSETIFF, (void*)&ifr) < 0) { exit(1); } char sysctl[64]; sprintf(sysctl, "/proc/sys/net/ipv6/conf/%s/accept_dad", TUN_IFACE); write_file(sysctl, "0"); sprintf(sysctl, "/proc/sys/net/ipv6/conf/%s/router_solicitations", TUN_IFACE); write_file(sysctl, "0"); int sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); if (sock == -1) exit(1); netlink_add_addr4(&nlmsg, sock, TUN_IFACE, LOCAL_IPV4); netlink_add_addr6(&nlmsg, sock, TUN_IFACE, LOCAL_IPV6); uint64_t macaddr = REMOTE_MAC; struct in_addr in_addr; inet_pton(AF_INET, REMOTE_IPV4, &in_addr); netlink_add_neigh(&nlmsg, sock, TUN_IFACE, &in_addr, sizeof(in_addr), &macaddr, ETH_ALEN); struct in6_addr in6_addr; inet_pton(AF_INET6, REMOTE_IPV6, &in6_addr); netlink_add_neigh(&nlmsg, sock, TUN_IFACE, &in6_addr, sizeof(in6_addr), &macaddr, ETH_ALEN); macaddr = LOCAL_MAC; netlink_device_change(&nlmsg, sock, TUN_IFACE, true, 0, &macaddr, ETH_ALEN, NULL); close(sock); } #define DEVLINK_FAMILY_NAME "devlink" #define DEVLINK_CMD_PORT_GET 5 #define DEVLINK_ATTR_BUS_NAME 1 #define DEVLINK_ATTR_DEV_NAME 2 #define DEVLINK_ATTR_NETDEV_NAME 7 static struct nlmsg nlmsg2; static void initialize_devlink_ports(const char* bus_name, const char* dev_name, const char* netdev_prefix) { struct genlmsghdr genlhdr; int len, total_len, id, err, offset; uint16_t netdev_index; int sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_GENERIC); if (sock == -1) exit(1); int rtsock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); if (rtsock == -1) exit(1); id = netlink_query_family_id(&nlmsg, sock, DEVLINK_FAMILY_NAME); if (id == -1) goto error; memset(&genlhdr, 0, sizeof(genlhdr)); genlhdr.cmd = DEVLINK_CMD_PORT_GET; netlink_init(&nlmsg, id, NLM_F_DUMP, &genlhdr, sizeof(genlhdr)); netlink_attr(&nlmsg, DEVLINK_ATTR_BUS_NAME, bus_name, strlen(bus_name) + 1); netlink_attr(&nlmsg, DEVLINK_ATTR_DEV_NAME, dev_name, strlen(dev_name) + 1); err = netlink_send_ext(&nlmsg, sock, id, &total_len); if (err < 0) { goto error; } offset = 0; netdev_index = 0; while ((len = netlink_next_msg(&nlmsg, offset, total_len)) != -1) { struct nlattr* attr = (struct nlattr*)(nlmsg.buf + offset + NLMSG_HDRLEN + NLMSG_ALIGN(sizeof(genlhdr))); for (; (char*)attr < nlmsg.buf + offset + len; attr = (struct nlattr*)((char*)attr + NLMSG_ALIGN(attr->nla_len))) { if (attr->nla_type == DEVLINK_ATTR_NETDEV_NAME) { char* port_name; char netdev_name[IFNAMSIZ]; port_name = (char*)(attr + 1); snprintf(netdev_name, sizeof(netdev_name), "%s%d", netdev_prefix, netdev_index); netlink_device_change(&nlmsg2, rtsock, port_name, true, 0, 0, 0, netdev_name); break; } } offset += len; netdev_index++; } error: close(rtsock); close(sock); } #define WIFI_INITIAL_DEVICE_COUNT 2 #define WIFI_MAC_BASE \ { \ 0x08, 0x02, 0x11, 0x00, 0x00, 0x00 \ } #define WIFI_IBSS_BSSID \ { \ 0x50, 0x50, 0x50, 0x50, 0x50, 0x50 \ } #define WIFI_IBSS_SSID \ { \ 0x10, 0x10, 0x10, 0x10, 0x10, 0x10 \ } #define WIFI_DEFAULT_FREQUENCY 2412 #define WIFI_DEFAULT_SIGNAL 0 #define WIFI_DEFAULT_RX_RATE 1 #define HWSIM_CMD_REGISTER 1 #define HWSIM_CMD_FRAME 2 #define HWSIM_CMD_NEW_RADIO 4 #define HWSIM_ATTR_SUPPORT_P2P_DEVICE 14 #define HWSIM_ATTR_PERM_ADDR 22 #define IF_OPER_UP 6 struct join_ibss_props { int wiphy_freq; bool wiphy_freq_fixed; uint8_t* mac; uint8_t* ssid; int ssid_len; }; static int set_interface_state(const char* interface_name, int on) { struct ifreq ifr; int sock = socket(AF_INET, SOCK_DGRAM, 0); if (sock < 0) { return -1; } memset(&ifr, 0, sizeof(ifr)); strcpy(ifr.ifr_name, interface_name); int ret = ioctl(sock, SIOCGIFFLAGS, &ifr); if (ret < 0) { close(sock); return -1; } if (on) ifr.ifr_flags |= IFF_UP; else ifr.ifr_flags &= ~IFF_UP; ret = ioctl(sock, SIOCSIFFLAGS, &ifr); close(sock); if (ret < 0) { return -1; } return 0; } static int nl80211_set_interface(struct nlmsg* nlmsg, int sock, int nl80211_family, uint32_t ifindex, uint32_t iftype) { struct genlmsghdr genlhdr; memset(&genlhdr, 0, sizeof(genlhdr)); genlhdr.cmd = NL80211_CMD_SET_INTERFACE; netlink_init(nlmsg, nl80211_family, 0, &genlhdr, sizeof(genlhdr)); netlink_attr(nlmsg, NL80211_ATTR_IFINDEX, &ifindex, sizeof(ifindex)); netlink_attr(nlmsg, NL80211_ATTR_IFTYPE, &iftype, sizeof(iftype)); int err = netlink_send(nlmsg, sock); if (err < 0) { return -1; } return 0; } static int nl80211_join_ibss(struct nlmsg* nlmsg, int sock, int nl80211_family, uint32_t ifindex, struct join_ibss_props* props) { struct genlmsghdr genlhdr; memset(&genlhdr, 0, sizeof(genlhdr)); genlhdr.cmd = NL80211_CMD_JOIN_IBSS; netlink_init(nlmsg, nl80211_family, 0, &genlhdr, sizeof(genlhdr)); netlink_attr(nlmsg, NL80211_ATTR_IFINDEX, &ifindex, sizeof(ifindex)); netlink_attr(nlmsg, NL80211_ATTR_SSID, props->ssid, props->ssid_len); netlink_attr(nlmsg, NL80211_ATTR_WIPHY_FREQ, &(props->wiphy_freq), sizeof(props->wiphy_freq)); if (props->mac) netlink_attr(nlmsg, NL80211_ATTR_MAC, props->mac, ETH_ALEN); if (props->wiphy_freq_fixed) netlink_attr(nlmsg, NL80211_ATTR_FREQ_FIXED, NULL, 0); int err = netlink_send(nlmsg, sock); if (err < 0) { return -1; } return 0; } static int get_ifla_operstate(struct nlmsg* nlmsg, int ifindex) { struct ifinfomsg info; memset(&info, 0, sizeof(info)); info.ifi_family = AF_UNSPEC; info.ifi_index = ifindex; int sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); if (sock == -1) { return -1; } netlink_init(nlmsg, RTM_GETLINK, 0, &info, sizeof(info)); int n; int err = netlink_send_ext(nlmsg, sock, RTM_NEWLINK, &n); close(sock); if (err) { return -1; } struct rtattr* attr = IFLA_RTA(NLMSG_DATA(nlmsg->buf)); for (; RTA_OK(attr, n); attr = RTA_NEXT(attr, n)) { if (attr->rta_type == IFLA_OPERSTATE) return *((int32_t*)RTA_DATA(attr)); } return -1; } static int await_ifla_operstate(struct nlmsg* nlmsg, char* interface, int operstate) { int ifindex = if_nametoindex(interface); while (true) { usleep(1000); int ret = get_ifla_operstate(nlmsg, ifindex); if (ret < 0) return ret; if (ret == operstate) return 0; } return 0; } static int nl80211_setup_ibss_interface(struct nlmsg* nlmsg, int sock, int nl80211_family_id, char* interface, struct join_ibss_props* ibss_props) { int ifindex = if_nametoindex(interface); if (ifindex == 0) { return -1; } int ret = nl80211_set_interface(nlmsg, sock, nl80211_family_id, ifindex, NL80211_IFTYPE_ADHOC); if (ret < 0) { return -1; } ret = set_interface_state(interface, 1); if (ret < 0) { return -1; } ret = nl80211_join_ibss(nlmsg, sock, nl80211_family_id, ifindex, ibss_props); if (ret < 0) { return -1; } return 0; } static int hwsim80211_create_device(struct nlmsg* nlmsg, int sock, int hwsim_family, uint8_t mac_addr[ETH_ALEN]) { struct genlmsghdr genlhdr; memset(&genlhdr, 0, sizeof(genlhdr)); genlhdr.cmd = HWSIM_CMD_NEW_RADIO; netlink_init(nlmsg, hwsim_family, 0, &genlhdr, sizeof(genlhdr)); netlink_attr(nlmsg, HWSIM_ATTR_SUPPORT_P2P_DEVICE, NULL, 0); netlink_attr(nlmsg, HWSIM_ATTR_PERM_ADDR, mac_addr, ETH_ALEN); int err = netlink_send(nlmsg, sock); if (err < 0) { return -1; } return 0; } static void initialize_wifi_devices(void) { uint8_t mac_addr[6] = WIFI_MAC_BASE; int sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_GENERIC); if (sock < 0) { return; } int hwsim_family_id = netlink_query_family_id(&nlmsg, sock, "MAC80211_HWSIM"); int nl80211_family_id = netlink_query_family_id(&nlmsg, sock, "nl80211"); uint8_t ssid[] = WIFI_IBSS_SSID; uint8_t bssid[] = WIFI_IBSS_BSSID; struct join_ibss_props ibss_props = {.wiphy_freq = WIFI_DEFAULT_FREQUENCY, .wiphy_freq_fixed = true, .mac = bssid, .ssid = ssid, .ssid_len = sizeof(ssid)}; for (int device_id = 0; device_id < WIFI_INITIAL_DEVICE_COUNT; device_id++) { mac_addr[5] = device_id; int ret = hwsim80211_create_device(&nlmsg, sock, hwsim_family_id, mac_addr); if (ret < 0) exit(1); char interface[6] = "wlan0"; interface[4] += device_id; if (nl80211_setup_ibss_interface(&nlmsg, sock, nl80211_family_id, interface, &ibss_props) < 0) exit(1); } for (int device_id = 0; device_id < WIFI_INITIAL_DEVICE_COUNT; device_id++) { char interface[6] = "wlan0"; interface[4] += device_id; int ret = await_ifla_operstate(&nlmsg, interface, IF_OPER_UP); if (ret < 0) exit(1); } close(sock); } #define DEV_IPV4 "172.20.20.%d" #define DEV_IPV6 "fe80::%02x" #define DEV_MAC 0x00aaaaaaaaaa static void netdevsim_add(unsigned int addr, unsigned int port_count) { char buf[16]; sprintf(buf, "%u %u", addr, port_count); if (write_file("/sys/bus/netdevsim/new_device", buf)) { snprintf(buf, sizeof(buf), "netdevsim%d", addr); initialize_devlink_ports("netdevsim", buf, "netdevsim"); } } #define WG_GENL_NAME "wireguard" enum wg_cmd { WG_CMD_GET_DEVICE, WG_CMD_SET_DEVICE, }; enum wgdevice_attribute { WGDEVICE_A_UNSPEC, WGDEVICE_A_IFINDEX, WGDEVICE_A_IFNAME, WGDEVICE_A_PRIVATE_KEY, WGDEVICE_A_PUBLIC_KEY, WGDEVICE_A_FLAGS, WGDEVICE_A_LISTEN_PORT, WGDEVICE_A_FWMARK, WGDEVICE_A_PEERS, }; enum wgpeer_attribute { WGPEER_A_UNSPEC, WGPEER_A_PUBLIC_KEY, WGPEER_A_PRESHARED_KEY, WGPEER_A_FLAGS, WGPEER_A_ENDPOINT, WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL, WGPEER_A_LAST_HANDSHAKE_TIME, WGPEER_A_RX_BYTES, WGPEER_A_TX_BYTES, WGPEER_A_ALLOWEDIPS, WGPEER_A_PROTOCOL_VERSION, }; enum wgallowedip_attribute { WGALLOWEDIP_A_UNSPEC, WGALLOWEDIP_A_FAMILY, WGALLOWEDIP_A_IPADDR, WGALLOWEDIP_A_CIDR_MASK, }; static void netlink_wireguard_setup(void) { const char ifname_a[] = "wg0"; const char ifname_b[] = "wg1"; const char ifname_c[] = "wg2"; const char private_a[] = "\xa0\x5c\xa8\x4f\x6c\x9c\x8e\x38\x53\xe2\xfd\x7a" "\x70\xae\x0f\xb2\x0f\xa1\x52\x60\x0c\xb0\x08\x45" "\x17\x4f\x08\x07\x6f\x8d\x78\x43"; const char private_b[] = "\xb0\x80\x73\xe8\xd4\x4e\x91\xe3\xda\x92\x2c\x22" "\x43\x82\x44\xbb\x88\x5c\x69\xe2\x69\xc8\xe9\xd8" "\x35\xb1\x14\x29\x3a\x4d\xdc\x6e"; const char private_c[] = "\xa0\xcb\x87\x9a\x47\xf5\xbc\x64\x4c\x0e\x69\x3f" "\xa6\xd0\x31\xc7\x4a\x15\x53\xb6\xe9\x01\xb9\xff" "\x2f\x51\x8c\x78\x04\x2f\xb5\x42"; const char public_a[] = "\x97\x5c\x9d\x81\xc9\x83\xc8\x20\x9e\xe7\x81\x25\x4b" "\x89\x9f\x8e\xd9\x25\xae\x9f\x09\x23\xc2\x3c\x62\xf5" "\x3c\x57\xcd\xbf\x69\x1c"; const char public_b[] = "\xd1\x73\x28\x99\xf6\x11\xcd\x89\x94\x03\x4d\x7f\x41" "\x3d\xc9\x57\x63\x0e\x54\x93\xc2\x85\xac\xa4\x00\x65" "\xcb\x63\x11\xbe\x69\x6b"; const char public_c[] = "\xf4\x4d\xa3\x67\xa8\x8e\xe6\x56\x4f\x02\x02\x11\x45" "\x67\x27\x08\x2f\x5c\xeb\xee\x8b\x1b\xf5\xeb\x73\x37" "\x34\x1b\x45\x9b\x39\x22"; const uint16_t listen_a = 20001; const uint16_t listen_b = 20002; const uint16_t listen_c = 20003; const uint16_t af_inet = AF_INET; const uint16_t af_inet6 = AF_INET6; const struct sockaddr_in endpoint_b_v4 = { .sin_family = AF_INET, .sin_port = htons(listen_b), .sin_addr = {htonl(INADDR_LOOPBACK)}}; const struct sockaddr_in endpoint_c_v4 = { .sin_family = AF_INET, .sin_port = htons(listen_c), .sin_addr = {htonl(INADDR_LOOPBACK)}}; struct sockaddr_in6 endpoint_a_v6 = {.sin6_family = AF_INET6, .sin6_port = htons(listen_a)}; endpoint_a_v6.sin6_addr = in6addr_loopback; struct sockaddr_in6 endpoint_c_v6 = {.sin6_family = AF_INET6, .sin6_port = htons(listen_c)}; endpoint_c_v6.sin6_addr = in6addr_loopback; const struct in_addr first_half_v4 = {0}; const struct in_addr second_half_v4 = {(uint32_t)htonl(128 << 24)}; const struct in6_addr first_half_v6 = {{{0}}}; const struct in6_addr second_half_v6 = {{{0x80}}}; const uint8_t half_cidr = 1; const uint16_t persistent_keepalives[] = {1, 3, 7, 9, 14, 19}; struct genlmsghdr genlhdr = {.cmd = WG_CMD_SET_DEVICE, .version = 1}; int sock; int id, err; sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_GENERIC); if (sock == -1) { return; } id = netlink_query_family_id(&nlmsg, sock, WG_GENL_NAME); if (id == -1) goto error; netlink_init(&nlmsg, id, 0, &genlhdr, sizeof(genlhdr)); netlink_attr(&nlmsg, WGDEVICE_A_IFNAME, ifname_a, strlen(ifname_a) + 1); netlink_attr(&nlmsg, WGDEVICE_A_PRIVATE_KEY, private_a, 32); netlink_attr(&nlmsg, WGDEVICE_A_LISTEN_PORT, &listen_a, 2); netlink_nest(&nlmsg, NLA_F_NESTED | WGDEVICE_A_PEERS); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGPEER_A_PUBLIC_KEY, public_b, 32); netlink_attr(&nlmsg, WGPEER_A_ENDPOINT, &endpoint_b_v4, sizeof(endpoint_b_v4)); netlink_attr(&nlmsg, WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL, &persistent_keepalives[0], 2); netlink_nest(&nlmsg, NLA_F_NESTED | WGPEER_A_ALLOWEDIPS); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &first_half_v4, sizeof(first_half_v4)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet6, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &first_half_v6, sizeof(first_half_v6)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGPEER_A_PUBLIC_KEY, public_c, 32); netlink_attr(&nlmsg, WGPEER_A_ENDPOINT, &endpoint_c_v6, sizeof(endpoint_c_v6)); netlink_attr(&nlmsg, WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL, &persistent_keepalives[1], 2); netlink_nest(&nlmsg, NLA_F_NESTED | WGPEER_A_ALLOWEDIPS); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &second_half_v4, sizeof(second_half_v4)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet6, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &second_half_v6, sizeof(second_half_v6)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_done(&nlmsg); err = netlink_send(&nlmsg, sock); if (err < 0) { } netlink_init(&nlmsg, id, 0, &genlhdr, sizeof(genlhdr)); netlink_attr(&nlmsg, WGDEVICE_A_IFNAME, ifname_b, strlen(ifname_b) + 1); netlink_attr(&nlmsg, WGDEVICE_A_PRIVATE_KEY, private_b, 32); netlink_attr(&nlmsg, WGDEVICE_A_LISTEN_PORT, &listen_b, 2); netlink_nest(&nlmsg, NLA_F_NESTED | WGDEVICE_A_PEERS); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGPEER_A_PUBLIC_KEY, public_a, 32); netlink_attr(&nlmsg, WGPEER_A_ENDPOINT, &endpoint_a_v6, sizeof(endpoint_a_v6)); netlink_attr(&nlmsg, WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL, &persistent_keepalives[2], 2); netlink_nest(&nlmsg, NLA_F_NESTED | WGPEER_A_ALLOWEDIPS); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &first_half_v4, sizeof(first_half_v4)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet6, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &first_half_v6, sizeof(first_half_v6)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGPEER_A_PUBLIC_KEY, public_c, 32); netlink_attr(&nlmsg, WGPEER_A_ENDPOINT, &endpoint_c_v4, sizeof(endpoint_c_v4)); netlink_attr(&nlmsg, WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL, &persistent_keepalives[3], 2); netlink_nest(&nlmsg, NLA_F_NESTED | WGPEER_A_ALLOWEDIPS); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &second_half_v4, sizeof(second_half_v4)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet6, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &second_half_v6, sizeof(second_half_v6)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_done(&nlmsg); err = netlink_send(&nlmsg, sock); if (err < 0) { } netlink_init(&nlmsg, id, 0, &genlhdr, sizeof(genlhdr)); netlink_attr(&nlmsg, WGDEVICE_A_IFNAME, ifname_c, strlen(ifname_c) + 1); netlink_attr(&nlmsg, WGDEVICE_A_PRIVATE_KEY, private_c, 32); netlink_attr(&nlmsg, WGDEVICE_A_LISTEN_PORT, &listen_c, 2); netlink_nest(&nlmsg, NLA_F_NESTED | WGDEVICE_A_PEERS); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGPEER_A_PUBLIC_KEY, public_a, 32); netlink_attr(&nlmsg, WGPEER_A_ENDPOINT, &endpoint_a_v6, sizeof(endpoint_a_v6)); netlink_attr(&nlmsg, WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL, &persistent_keepalives[4], 2); netlink_nest(&nlmsg, NLA_F_NESTED | WGPEER_A_ALLOWEDIPS); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &first_half_v4, sizeof(first_half_v4)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet6, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &first_half_v6, sizeof(first_half_v6)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGPEER_A_PUBLIC_KEY, public_b, 32); netlink_attr(&nlmsg, WGPEER_A_ENDPOINT, &endpoint_b_v4, sizeof(endpoint_b_v4)); netlink_attr(&nlmsg, WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL, &persistent_keepalives[5], 2); netlink_nest(&nlmsg, NLA_F_NESTED | WGPEER_A_ALLOWEDIPS); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &second_half_v4, sizeof(second_half_v4)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet6, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &second_half_v6, sizeof(second_half_v6)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_done(&nlmsg); err = netlink_send(&nlmsg, sock); if (err < 0) { } error: close(sock); } static void initialize_netdevices(void) { char netdevsim[16]; sprintf(netdevsim, "netdevsim%d", (int)procid); struct { const char* type; const char* dev; } devtypes[] = { {"ip6gretap", "ip6gretap0"}, {"bridge", "bridge0"}, {"vcan", "vcan0"}, {"bond", "bond0"}, {"team", "team0"}, {"dummy", "dummy0"}, {"nlmon", "nlmon0"}, {"caif", "caif0"}, {"batadv", "batadv0"}, {"vxcan", "vxcan1"}, {"netdevsim", netdevsim}, {"veth", 0}, {"xfrm", "xfrm0"}, {"wireguard", "wg0"}, {"wireguard", "wg1"}, {"wireguard", "wg2"}, }; const char* devmasters[] = {"bridge", "bond", "team", "batadv"}; struct { const char* name; int macsize; bool noipv6; } devices[] = { {"lo", ETH_ALEN}, {"sit0", 0}, {"bridge0", ETH_ALEN}, {"vcan0", 0, true}, {"tunl0", 0}, {"gre0", 0}, {"gretap0", ETH_ALEN}, {"ip_vti0", 0}, {"ip6_vti0", 0}, {"ip6tnl0", 0}, {"ip6gre0", 0}, {"ip6gretap0", ETH_ALEN}, {"erspan0", ETH_ALEN}, {"bond0", ETH_ALEN}, {"veth0", ETH_ALEN}, {"veth1", ETH_ALEN}, {"team0", ETH_ALEN}, {"veth0_to_bridge", ETH_ALEN}, {"veth1_to_bridge", ETH_ALEN}, {"veth0_to_bond", ETH_ALEN}, {"veth1_to_bond", ETH_ALEN}, {"veth0_to_team", ETH_ALEN}, {"veth1_to_team", ETH_ALEN}, {"veth0_to_hsr", ETH_ALEN}, {"veth1_to_hsr", ETH_ALEN}, {"hsr0", 0}, {"dummy0", ETH_ALEN}, {"nlmon0", 0}, {"vxcan0", 0, true}, {"vxcan1", 0, true}, {"caif0", ETH_ALEN}, {"batadv0", ETH_ALEN}, {netdevsim, ETH_ALEN}, {"xfrm0", ETH_ALEN}, {"veth0_virt_wifi", ETH_ALEN}, {"veth1_virt_wifi", ETH_ALEN}, {"virt_wifi0", ETH_ALEN}, {"veth0_vlan", ETH_ALEN}, {"veth1_vlan", ETH_ALEN}, {"vlan0", ETH_ALEN}, {"vlan1", ETH_ALEN}, {"macvlan0", ETH_ALEN}, {"macvlan1", ETH_ALEN}, {"ipvlan0", ETH_ALEN}, {"ipvlan1", ETH_ALEN}, {"veth0_macvtap", ETH_ALEN}, {"veth1_macvtap", ETH_ALEN}, {"macvtap0", ETH_ALEN}, {"macsec0", ETH_ALEN}, {"veth0_to_batadv", ETH_ALEN}, {"veth1_to_batadv", ETH_ALEN}, {"batadv_slave_0", ETH_ALEN}, {"batadv_slave_1", ETH_ALEN}, {"geneve0", ETH_ALEN}, {"geneve1", ETH_ALEN}, {"wg0", 0}, {"wg1", 0}, {"wg2", 0}, }; int sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); if (sock == -1) exit(1); unsigned i; for (i = 0; i < sizeof(devtypes) / sizeof(devtypes[0]); i++) netlink_add_device(&nlmsg, sock, devtypes[i].type, devtypes[i].dev); for (i = 0; i < sizeof(devmasters) / (sizeof(devmasters[0])); i++) { char master[32], slave0[32], veth0[32], slave1[32], veth1[32]; sprintf(slave0, "%s_slave_0", devmasters[i]); sprintf(veth0, "veth0_to_%s", devmasters[i]); netlink_add_veth(&nlmsg, sock, slave0, veth0); sprintf(slave1, "%s_slave_1", devmasters[i]); sprintf(veth1, "veth1_to_%s", devmasters[i]); netlink_add_veth(&nlmsg, sock, slave1, veth1); sprintf(master, "%s0", devmasters[i]); netlink_device_change(&nlmsg, sock, slave0, false, master, 0, 0, NULL); netlink_device_change(&nlmsg, sock, slave1, false, master, 0, 0, NULL); } netlink_device_change(&nlmsg, sock, "bridge_slave_0", true, 0, 0, 0, NULL); netlink_device_change(&nlmsg, sock, "bridge_slave_1", true, 0, 0, 0, NULL); netlink_add_veth(&nlmsg, sock, "hsr_slave_0", "veth0_to_hsr"); netlink_add_veth(&nlmsg, sock, "hsr_slave_1", "veth1_to_hsr"); netlink_add_hsr(&nlmsg, sock, "hsr0", "hsr_slave_0", "hsr_slave_1"); netlink_device_change(&nlmsg, sock, "hsr_slave_0", true, 0, 0, 0, NULL); netlink_device_change(&nlmsg, sock, "hsr_slave_1", true, 0, 0, 0, NULL); netlink_add_veth(&nlmsg, sock, "veth0_virt_wifi", "veth1_virt_wifi"); netlink_add_linked(&nlmsg, sock, "virt_wifi", "virt_wifi0", "veth1_virt_wifi"); netlink_add_veth(&nlmsg, sock, "veth0_vlan", "veth1_vlan"); netlink_add_vlan(&nlmsg, sock, "vlan0", "veth0_vlan", 0, htons(ETH_P_8021Q)); netlink_add_vlan(&nlmsg, sock, "vlan1", "veth0_vlan", 1, htons(ETH_P_8021AD)); netlink_add_macvlan(&nlmsg, sock, "macvlan0", "veth1_vlan"); netlink_add_macvlan(&nlmsg, sock, "macvlan1", "veth1_vlan"); netlink_add_ipvlan(&nlmsg, sock, "ipvlan0", "veth0_vlan", IPVLAN_MODE_L2, 0); netlink_add_ipvlan(&nlmsg, sock, "ipvlan1", "veth0_vlan", IPVLAN_MODE_L3S, IPVLAN_F_VEPA); netlink_add_veth(&nlmsg, sock, "veth0_macvtap", "veth1_macvtap"); netlink_add_linked(&nlmsg, sock, "macvtap", "macvtap0", "veth0_macvtap"); netlink_add_linked(&nlmsg, sock, "macsec", "macsec0", "veth1_macvtap"); char addr[32]; sprintf(addr, DEV_IPV4, 14 + 10); struct in_addr geneve_addr4; if (inet_pton(AF_INET, addr, &geneve_addr4) <= 0) exit(1); struct in6_addr geneve_addr6; if (inet_pton(AF_INET6, "fc00::01", &geneve_addr6) <= 0) exit(1); netlink_add_geneve(&nlmsg, sock, "geneve0", 0, &geneve_addr4, 0); netlink_add_geneve(&nlmsg, sock, "geneve1", 1, 0, &geneve_addr6); netdevsim_add((int)procid, 4); netlink_wireguard_setup(); for (i = 0; i < sizeof(devices) / (sizeof(devices[0])); i++) { char addr[32]; sprintf(addr, DEV_IPV4, i + 10); netlink_add_addr4(&nlmsg, sock, devices[i].name, addr); if (!devices[i].noipv6) { sprintf(addr, DEV_IPV6, i + 10); netlink_add_addr6(&nlmsg, sock, devices[i].name, addr); } uint64_t macaddr = DEV_MAC + ((i + 10ull) << 40); netlink_device_change(&nlmsg, sock, devices[i].name, true, 0, &macaddr, devices[i].macsize, NULL); } close(sock); } static void initialize_netdevices_init(void) { int sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); if (sock == -1) exit(1); struct { const char* type; int macsize; bool noipv6; bool noup; } devtypes[] = { {"nr", 7, true}, {"rose", 5, true, true}, }; unsigned i; for (i = 0; i < sizeof(devtypes) / sizeof(devtypes[0]); i++) { char dev[32], addr[32]; sprintf(dev, "%s%d", devtypes[i].type, (int)procid); sprintf(addr, "172.30.%d.%d", i, (int)procid + 1); netlink_add_addr4(&nlmsg, sock, dev, addr); if (!devtypes[i].noipv6) { sprintf(addr, "fe88::%02x:%02x", i, (int)procid + 1); netlink_add_addr6(&nlmsg, sock, dev, addr); } int macsize = devtypes[i].macsize; uint64_t macaddr = 0xbbbbbb + ((unsigned long long)i << (8 * (macsize - 2))) + (procid << (8 * (macsize - 1))); netlink_device_change(&nlmsg, sock, dev, !devtypes[i].noup, 0, &macaddr, macsize, NULL); } close(sock); } static int read_tun(char* data, int size) { if (tunfd < 0) return -1; int rv = read(tunfd, data, size); if (rv < 0) { if (errno == EAGAIN || errno == EBADFD) return -1; exit(1); } return rv; } static void flush_tun() { char data[1000]; while (read_tun(&data[0], sizeof(data)) != -1) { } } #define MAX_FDS 30 #define BTPROTO_HCI 1 #define ACL_LINK 1 #define SCAN_PAGE 2 typedef struct { uint8_t b[6]; } __attribute__((packed)) bdaddr_t; #define HCI_COMMAND_PKT 1 #define HCI_EVENT_PKT 4 #define HCI_VENDOR_PKT 0xff struct hci_command_hdr { uint16_t opcode; uint8_t plen; } __attribute__((packed)); struct hci_event_hdr { uint8_t evt; uint8_t plen; } __attribute__((packed)); #define HCI_EV_CONN_COMPLETE 0x03 struct hci_ev_conn_complete { uint8_t status; uint16_t handle; bdaddr_t bdaddr; uint8_t link_type; uint8_t encr_mode; } __attribute__((packed)); #define HCI_EV_CONN_REQUEST 0x04 struct hci_ev_conn_request { bdaddr_t bdaddr; uint8_t dev_class[3]; uint8_t link_type; } __attribute__((packed)); #define HCI_EV_REMOTE_FEATURES 0x0b struct hci_ev_remote_features { uint8_t status; uint16_t handle; uint8_t features[8]; } __attribute__((packed)); #define HCI_EV_CMD_COMPLETE 0x0e struct hci_ev_cmd_complete { uint8_t ncmd; uint16_t opcode; } __attribute__((packed)); #define HCI_OP_WRITE_SCAN_ENABLE 0x0c1a #define HCI_OP_READ_BUFFER_SIZE 0x1005 struct hci_rp_read_buffer_size { uint8_t status; uint16_t acl_mtu; uint8_t sco_mtu; uint16_t acl_max_pkt; uint16_t sco_max_pkt; } __attribute__((packed)); #define HCI_OP_READ_BD_ADDR 0x1009 struct hci_rp_read_bd_addr { uint8_t status; bdaddr_t bdaddr; } __attribute__((packed)); #define HCI_EV_LE_META 0x3e struct hci_ev_le_meta { uint8_t subevent; } __attribute__((packed)); #define HCI_EV_LE_CONN_COMPLETE 0x01 struct hci_ev_le_conn_complete { uint8_t status; uint16_t handle; uint8_t role; uint8_t bdaddr_type; bdaddr_t bdaddr; uint16_t interval; uint16_t latency; uint16_t supervision_timeout; uint8_t clk_accurancy; } __attribute__((packed)); struct hci_dev_req { uint16_t dev_id; uint32_t dev_opt; }; struct vhci_vendor_pkt { uint8_t type; uint8_t opcode; uint16_t id; }; #define HCIDEVUP _IOW('H', 201, int) #define HCISETSCAN _IOW('H', 221, int) static int vhci_fd = -1; static void rfkill_unblock_all() { int fd = open("/dev/rfkill", O_WRONLY); if (fd < 0) exit(1); struct rfkill_event event = {0}; event.idx = 0; event.type = RFKILL_TYPE_ALL; event.op = RFKILL_OP_CHANGE_ALL; event.soft = 0; event.hard = 0; if (write(fd, &event, sizeof(event)) < 0) exit(1); close(fd); } static void hci_send_event_packet(int fd, uint8_t evt, void* data, size_t data_len) { struct iovec iv[3]; struct hci_event_hdr hdr; hdr.evt = evt; hdr.plen = data_len; uint8_t type = HCI_EVENT_PKT; iv[0].iov_base = &type; iv[0].iov_len = sizeof(type); iv[1].iov_base = &hdr; iv[1].iov_len = sizeof(hdr); iv[2].iov_base = data; iv[2].iov_len = data_len; if (writev(fd, iv, sizeof(iv) / sizeof(struct iovec)) < 0) exit(1); } static void hci_send_event_cmd_complete(int fd, uint16_t opcode, void* data, size_t data_len) { struct iovec iv[4]; struct hci_event_hdr hdr; hdr.evt = HCI_EV_CMD_COMPLETE; hdr.plen = sizeof(struct hci_ev_cmd_complete) + data_len; struct hci_ev_cmd_complete evt_hdr; evt_hdr.ncmd = 1; evt_hdr.opcode = opcode; uint8_t type = HCI_EVENT_PKT; iv[0].iov_base = &type; iv[0].iov_len = sizeof(type); iv[1].iov_base = &hdr; iv[1].iov_len = sizeof(hdr); iv[2].iov_base = &evt_hdr; iv[2].iov_len = sizeof(evt_hdr); iv[3].iov_base = data; iv[3].iov_len = data_len; if (writev(fd, iv, sizeof(iv) / sizeof(struct iovec)) < 0) exit(1); } static bool process_command_pkt(int fd, char* buf, ssize_t buf_size) { struct hci_command_hdr* hdr = (struct hci_command_hdr*)buf; if (buf_size < (ssize_t)sizeof(struct hci_command_hdr) || hdr->plen != buf_size - sizeof(struct hci_command_hdr)) { exit(1); } switch (hdr->opcode) { case HCI_OP_WRITE_SCAN_ENABLE: { uint8_t status = 0; hci_send_event_cmd_complete(fd, hdr->opcode, &status, sizeof(status)); return true; } case HCI_OP_READ_BD_ADDR: { struct hci_rp_read_bd_addr rp = {0}; rp.status = 0; memset(&rp.bdaddr, 0xaa, 6); hci_send_event_cmd_complete(fd, hdr->opcode, &rp, sizeof(rp)); return false; } case HCI_OP_READ_BUFFER_SIZE: { struct hci_rp_read_buffer_size rp = {0}; rp.status = 0; rp.acl_mtu = 1021; rp.sco_mtu = 96; rp.acl_max_pkt = 4; rp.sco_max_pkt = 6; hci_send_event_cmd_complete(fd, hdr->opcode, &rp, sizeof(rp)); return false; } } char dummy[0xf9] = {0}; hci_send_event_cmd_complete(fd, hdr->opcode, dummy, sizeof(dummy)); return false; } static void* event_thread(void* arg) { while (1) { char buf[1024] = {0}; ssize_t buf_size = read(vhci_fd, buf, sizeof(buf)); if (buf_size < 0) exit(1); if (buf_size > 0 && buf[0] == HCI_COMMAND_PKT) { if (process_command_pkt(vhci_fd, buf + 1, buf_size - 1)) break; } } return NULL; } #define HCI_HANDLE_1 200 #define HCI_HANDLE_2 201 static void initialize_vhci() { int hci_sock = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI); if (hci_sock < 0) exit(1); vhci_fd = open("/dev/vhci", O_RDWR); if (vhci_fd == -1) exit(1); const int kVhciFd = 241; if (dup2(vhci_fd, kVhciFd) < 0) exit(1); close(vhci_fd); vhci_fd = kVhciFd; struct vhci_vendor_pkt vendor_pkt; if (read(vhci_fd, &vendor_pkt, sizeof(vendor_pkt)) != sizeof(vendor_pkt)) exit(1); if (vendor_pkt.type != HCI_VENDOR_PKT) exit(1); pthread_t th; if (pthread_create(&th, NULL, event_thread, NULL)) exit(1); int ret = ioctl(hci_sock, HCIDEVUP, vendor_pkt.id); if (ret) { if (errno == ERFKILL) { rfkill_unblock_all(); ret = ioctl(hci_sock, HCIDEVUP, vendor_pkt.id); } if (ret && errno != EALREADY) exit(1); } struct hci_dev_req dr = {0}; dr.dev_id = vendor_pkt.id; dr.dev_opt = SCAN_PAGE; if (ioctl(hci_sock, HCISETSCAN, &dr)) exit(1); struct hci_ev_conn_request request; memset(&request, 0, sizeof(request)); memset(&request.bdaddr, 0xaa, 6); *(uint8_t*)&request.bdaddr.b[5] = 0x10; request.link_type = ACL_LINK; hci_send_event_packet(vhci_fd, HCI_EV_CONN_REQUEST, &request, sizeof(request)); struct hci_ev_conn_complete complete; memset(&complete, 0, sizeof(complete)); complete.status = 0; complete.handle = HCI_HANDLE_1; memset(&complete.bdaddr, 0xaa, 6); *(uint8_t*)&complete.bdaddr.b[5] = 0x10; complete.link_type = ACL_LINK; complete.encr_mode = 0; hci_send_event_packet(vhci_fd, HCI_EV_CONN_COMPLETE, &complete, sizeof(complete)); struct hci_ev_remote_features features; memset(&features, 0, sizeof(features)); features.status = 0; features.handle = HCI_HANDLE_1; hci_send_event_packet(vhci_fd, HCI_EV_REMOTE_FEATURES, &features, sizeof(features)); struct { struct hci_ev_le_meta le_meta; struct hci_ev_le_conn_complete le_conn; } le_conn; memset(&le_conn, 0, sizeof(le_conn)); le_conn.le_meta.subevent = HCI_EV_LE_CONN_COMPLETE; memset(&le_conn.le_conn.bdaddr, 0xaa, 6); *(uint8_t*)&le_conn.le_conn.bdaddr.b[5] = 0x11; le_conn.le_conn.role = 1; le_conn.le_conn.handle = HCI_HANDLE_2; hci_send_event_packet(vhci_fd, HCI_EV_LE_META, &le_conn, sizeof(le_conn)); pthread_join(th, NULL); close(hci_sock); } static void setup_common() { if (mount(0, "/sys/fs/fuse/connections", "fusectl", 0, 0)) { } } static void loop(); static void sandbox_common() { prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); setsid(); struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = (200 << 20); setrlimit(RLIMIT_AS, &rlim); rlim.rlim_cur = rlim.rlim_max = 32 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 136 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); if (unshare(CLONE_NEWNS)) { } if (mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, NULL)) { } if (unshare(CLONE_NEWIPC)) { } if (unshare(0x02000000)) { } if (unshare(CLONE_NEWUTS)) { } if (unshare(CLONE_SYSVSEM)) { } typedef struct { const char* name; const char* value; } sysctl_t; static const sysctl_t sysctls[] = { {"/proc/sys/kernel/shmmax", "16777216"}, {"/proc/sys/kernel/shmall", "536870912"}, {"/proc/sys/kernel/shmmni", "1024"}, {"/proc/sys/kernel/msgmax", "8192"}, {"/proc/sys/kernel/msgmni", "1024"}, {"/proc/sys/kernel/msgmnb", "1024"}, {"/proc/sys/kernel/sem", "1024 1048576 500 1024"}, }; unsigned i; for (i = 0; i < sizeof(sysctls) / sizeof(sysctls[0]); i++) write_file(sysctls[i].name, sysctls[i].value); } static int wait_for_loop(int pid) { if (pid < 0) exit(1); int status = 0; while (waitpid(-1, &status, __WALL) != pid) { } return WEXITSTATUS(status); } static void drop_caps(void) { struct __user_cap_header_struct cap_hdr = {}; struct __user_cap_data_struct cap_data[2] = {}; cap_hdr.version = _LINUX_CAPABILITY_VERSION_3; cap_hdr.pid = getpid(); if (syscall(SYS_capget, &cap_hdr, &cap_data)) exit(1); const int drop = (1 << CAP_SYS_PTRACE) | (1 << CAP_SYS_NICE); cap_data[0].effective &= ~drop; cap_data[0].permitted &= ~drop; cap_data[0].inheritable &= ~drop; if (syscall(SYS_capset, &cap_hdr, &cap_data)) exit(1); } static int do_sandbox_none(void) { if (unshare(CLONE_NEWPID)) { } int pid = fork(); if (pid != 0) return wait_for_loop(pid); setup_common(); initialize_vhci(); sandbox_common(); drop_caps(); initialize_netdevices_init(); if (unshare(CLONE_NEWNET)) { } initialize_tun(); initialize_netdevices(); initialize_wifi_devices(); loop(); exit(1); } #define FS_IOC_SETFLAGS _IOW('f', 2, long) static void remove_dir(const char* dir) { int iter = 0; DIR* dp = 0; retry: while (umount2(dir, MNT_DETACH) == 0) { } dp = opendir(dir); if (dp == NULL) { if (errno == EMFILE) { exit(1); } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); while (umount2(filename, MNT_DETACH) == 0) { } struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } int i; for (i = 0;; i++) { if (unlink(filename) == 0) break; if (errno == EPERM) { int fd = open(filename, O_RDONLY); if (fd != -1) { long flags = 0; if (ioctl(fd, FS_IOC_SETFLAGS, &flags) == 0) { } close(fd); continue; } } if (errno == EROFS) { break; } if (errno != EBUSY || i > 100) exit(1); if (umount2(filename, MNT_DETACH)) exit(1); } } closedir(dp); for (int i = 0;; i++) { if (rmdir(dir) == 0) break; if (i < 100) { if (errno == EPERM) { int fd = open(dir, O_RDONLY); if (fd != -1) { long flags = 0; if (ioctl(fd, FS_IOC_SETFLAGS, &flags) == 0) { } close(fd); continue; } } if (errno == EROFS) { break; } if (errno == EBUSY) { if (umount2(dir, MNT_DETACH)) exit(1); continue; } if (errno == ENOTEMPTY) { if (iter < 100) { iter++; goto retry; } } } exit(1); } } static void kill_and_wait(int pid, int* status) { kill(-pid, SIGKILL); kill(pid, SIGKILL); for (int i = 0; i < 100; i++) { if (waitpid(-1, status, WNOHANG | __WALL) == pid) return; usleep(1000); } DIR* dir = opendir("/sys/fs/fuse/connections"); if (dir) { for (;;) { struct dirent* ent = readdir(dir); if (!ent) break; if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0) continue; char abort[300]; snprintf(abort, sizeof(abort), "/sys/fs/fuse/connections/%s/abort", ent->d_name); int fd = open(abort, O_WRONLY); if (fd == -1) { continue; } if (write(fd, abort, 1) < 0) { } close(fd); } closedir(dir); } else { } while (waitpid(-1, status, __WALL) != pid) { } } static void setup_test() { prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); setpgrp(); write_file("/proc/self/oom_score_adj", "1000"); flush_tun(); } static void close_fds() { for (int fd = 3; fd < MAX_FDS; fd++) close(fd); } static void execute_one(void); #define WAIT_FLAGS __WALL static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); setup_test(); execute_one(); close_fds(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5 * 1000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } void execute_one(void) { NONFAILING(*(uint32_t*)0x200000c0 = 2); NONFAILING(*(uint32_t*)0x200000c4 = 0x70); NONFAILING(*(uint8_t*)0x200000c8 = 0x72); NONFAILING(*(uint8_t*)0x200000c9 = 1); NONFAILING(*(uint8_t*)0x200000ca = 0); NONFAILING(*(uint8_t*)0x200000cb = 0); NONFAILING(*(uint32_t*)0x200000cc = 0); NONFAILING(*(uint64_t*)0x200000d0 = 0); NONFAILING(*(uint64_t*)0x200000d8 = 0); NONFAILING(*(uint64_t*)0x200000e0 = 0); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200000e8, 0, 0, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200000e8, 0, 1, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200000e8, 0, 2, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200000e8, 0, 3, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200000e8, 0, 4, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200000e8, 3, 5, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200000e8, 0, 6, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200000e8, 0, 7, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200000e8, 0, 8, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200000e8, 0, 9, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200000e8, 0, 10, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200000e8, 0, 11, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200000e8, 0, 12, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200000e8, 0, 13, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200000e8, 0, 14, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200000e8, 0, 15, 2)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200000e8, 0, 17, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200000e8, 0, 18, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200000e8, 0, 19, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200000e8, 0, 20, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200000e8, 0, 21, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200000e8, 0, 22, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200000e8, 0, 23, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200000e8, 0, 24, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200000e8, 0, 25, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200000e8, 0, 26, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200000e8, 0, 27, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200000e8, 0, 28, 1)); NONFAILING(STORE_BY_BITMASK(uint64_t, , 0x200000e8, 0, 29, 35)); NONFAILING(*(uint32_t*)0x200000f0 = 0); NONFAILING(*(uint32_t*)0x200000f4 = 0); NONFAILING(*(uint64_t*)0x200000f8 = 0); NONFAILING(*(uint64_t*)0x20000100 = 0); NONFAILING(*(uint64_t*)0x20000108 = 0); NONFAILING(*(uint64_t*)0x20000110 = 0); NONFAILING(*(uint32_t*)0x20000118 = 0); NONFAILING(*(uint32_t*)0x2000011c = 0); NONFAILING(*(uint64_t*)0x20000120 = 0); NONFAILING(*(uint32_t*)0x20000128 = 0); NONFAILING(*(uint16_t*)0x2000012c = 0); NONFAILING(*(uint16_t*)0x2000012e = 0); syscall(__NR_perf_event_open, 0x200000c0ul, 0, 0ul, -1, 0ul); syscall(__NR_mmap, 0x20000000ul, 0xb36000ul, 2ul, 0x28011ul, -1, 0ul); } int main(void) { syscall(__NR_mmap, 0x1ffff000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul); syscall(__NR_mmap, 0x20000000ul, 0x1000000ul, 7ul, 0x32ul, -1, 0ul); syscall(__NR_mmap, 0x21000000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul); install_segv_handler(); use_temporary_dir(); do_sandbox_none(); return 0; }
the_stack_data/68888715.c
/* Neste problema, você deverá ler 3 palavras que definem o tipo de animal possível segundo o esquema abaixo, da esquerda para a direita. Em seguida conclua qual dos animais seguintes foi escolhido, através das três palavras fornecidas. <img src="https://resources.urionlinejudge.com.br/gallery/images/problems/UOJ_1049_b.png" alt="Animal Species Table"> Entrada A entrada contém 3 palavras, uma em cada linha, necessárias para identificar o animal segundo a figura acima, com todas as letras minúsculas. Saída Imprima o nome do animal correspondente à entrada fornecida. */ #include <stdio.h> int main() { char animal[12]; scanf("%s", &animal); switch(animal[0]){ case 'v': scanf("%s", &animal); if(animal[0]=='a'){ scanf("%s", &animal); if(animal[0]=='c'){ printf("aguia\n"); }else{ printf("pomba\n"); } }else{ scanf("%s", animal); if(animal[0]=='o'){ printf("homem\n"); }else{ printf("vaca\n"); } } break; case 'i': scanf("%s", &animal); if(animal[0]=='i'){ scanf("%s", &animal); if(animal[2]=='m'){ printf("pulga\n"); }else{ printf("lagarta\n"); } }else{ scanf("%s", &animal); if(animal[0]=='h'){ printf("sanguessuga\n"); }else{ printf("minhoca\n"); } } break; } return 0; }
the_stack_data/95211.c
/* This program explains about the bubble sort * * Email : [email protected] * Date : 02.09.2021 * Author : Abinash */ #include<stdio.h> /* required for printf */ /* main program */ int main() { int a[] = {30, 50, 20, 10, 40}; int i, j ,n, temp; n = sizeof a / sizeof a[0]; /* to get the number of items stored in the array 'n' */ printf("Before sorting : "); for(i = 0; i<5; i++) printf("%d ",a[i]); /* 30 50 20 10 40 is printed */ printf("\n"); for(i = 0; i < n-1; i++) /* n-1 iteration */ { for(j = 0; j < n-1-i; j++) { if(a[j] > a[j+1]) /* adjacent elements are compared */ { /* swapping operation */ temp = a[j]; a[j] = a[j+1]; a[j+1] = temp; } } } printf("After sorting : "); for(i = 0; i < 5; i++) printf("%d ",a[i]); /* 10 20 30 40 50 is printed */ printf("\n"); return 0; /* program executed successfully */ }
the_stack_data/433437.c
/* { dg-do compile { target ia32 } } */ /* { dg-options "-mpreferred-stack-boundary=2 -Os -w" } */ int a; long long b (void) { } void c (void) { if (b()) a = 1; }
the_stack_data/220455430.c
// RUN: %clang_cc1 %s -emit-llvm -o - -fms-extensions -triple i686-pc-win32 | FileCheck %s // CHECK-LABEL: define dso_local void @test_alloca( void capture(void *); void test_alloca(int n) { capture(_alloca(n)); // CHECK: %[[arg:.*]] = alloca i8, i32 %{{.*}}, align 16 // CHECK: call void @capture(i8* %[[arg]]) } // CHECK-LABEL: define dso_local void @test_alloca_with_align( void test_alloca_with_align(int n) { capture(__builtin_alloca_with_align(n, 64)); // CHECK: %[[arg:.*]] = alloca i8, i32 %{{.*}}, align 8 // CHECK: call void @capture(i8* %[[arg]]) }
the_stack_data/161080653.c
// q05a // 多項式において、10以下の次数n、係数a0~ an および x の値を入力し、y を出力するプログラムを作成してください。 #include <stdio.h> #include <math.h> main() { int n, i; printf("jisuu:"); scanf("%d", &n); printf("keisuu:"); double a[11]; for (i=0; i<=n; i++) { scanf("%lf", &a[i]); } double x; printf("x="); scanf("%lf", &x); double y = 0; for (i=0; i<=n; i++) { y += a[i] * pow(x, i); } printf("y=%lf\n", y); }
the_stack_data/947681.c
#include <stdio.h> int main() { /* Print the value of EOF */ printf("%d\n", EOF); return 0; }
the_stack_data/53399.c
/* $OpenBSD: uthread_spec.c,v 1.9 2007/07/20 22:34:40 kettenis Exp $ */ /* * Copyright (c) 1995 John Birrell <[email protected]>. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by John Birrell. * 4. Neither the name of the author nor the names of any co-contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD: uthread_spec.c,v 1.13 1999/08/28 00:03:52 peter Exp $ */ #include <signal.h> #include <stdlib.h> #include <string.h> #include <errno.h> #ifdef _THREAD_SAFE #include <pthread.h> #include "pthread_private.h" /* Static variables: */ static struct pthread_key key_table[PTHREAD_KEYS_MAX]; void _thread_key_init(void) { int key; for (key = 0; key < PTHREAD_KEYS_MAX; key++) _SPINLOCK_INIT(&key_table[key].lock); } int pthread_key_create(pthread_key_t * key, void (*destructor) (void *)) { for ((*key) = 0; (*key) < PTHREAD_KEYS_MAX; (*key)++) { /* Lock the key table entry: */ _SPINLOCK(&key_table[*key].lock); if (key_table[(*key)].allocated == 0) { key_table[(*key)].allocated = 1; key_table[(*key)].destructor = destructor; /* Unlock the key table entry: */ _SPINUNLOCK(&key_table[*key].lock); return (0); } /* Unlock the key table entry: */ _SPINUNLOCK(&key_table[*key].lock); } return (EAGAIN); } int pthread_key_delete(pthread_key_t key) { int ret = 0; if (key < PTHREAD_KEYS_MAX) { /* Lock the key table entry: */ _SPINLOCK(&key_table[key].lock); if (key_table[key].allocated) key_table[key].allocated = 0; else ret = EINVAL; /* Unlock the key table entry: */ _SPINUNLOCK(&key_table[key].lock); } else ret = EINVAL; return (ret); } void _thread_cleanupspecific(void) { struct pthread *curthread = _get_curthread(); void *data; int key; int itr; void (*destructor)( void *); for (itr = 0; itr < PTHREAD_DESTRUCTOR_ITERATIONS; itr++) { for (key = 0; key < PTHREAD_KEYS_MAX; key++) { if (curthread->specific_data_count) { /* Lock the key table entry: */ _SPINLOCK(&key_table[key].lock); destructor = data = NULL; if (key_table[key].allocated) { if (curthread->specific_data[key]) { data = (void *) curthread->specific_data[key]; curthread->specific_data[key] = NULL; curthread->specific_data_count--; destructor = key_table[key].destructor; } } /* Unlock the key table entry: */ _SPINUNLOCK(&key_table[key].lock); /* * If there is a destructore, call it * with the key table entry unlocked: */ if (destructor) destructor(data); } else { free(curthread->specific_data); curthread->specific_data = NULL; return; } } } free(curthread->specific_data); curthread->specific_data = NULL; } static inline const void ** pthread_key_allocate_data(void) { return calloc(PTHREAD_KEYS_MAX, sizeof(void *)); } int pthread_setspecific(pthread_key_t key, const void *value) { struct pthread *pthread; int ret = 0; /* Point to the running thread: */ pthread = _get_curthread(); if ((pthread->specific_data) || (pthread->specific_data = pthread_key_allocate_data())) { if (key < PTHREAD_KEYS_MAX) { if (key_table[key].allocated) { if (pthread->specific_data[key] == NULL) { if (value != NULL) pthread->specific_data_count++; } else { if (value == NULL) pthread->specific_data_count--; } pthread->specific_data[key] = value; ret = 0; } else ret = EINVAL; } else ret = EINVAL; } else ret = ENOMEM; return (ret); } void * pthread_getspecific(pthread_key_t key) { struct pthread *pthread; void *data; /* Point to the running thread: */ pthread = _get_curthread(); /* Check if there is specific data: */ if (pthread->specific_data != NULL && key < PTHREAD_KEYS_MAX) { /* Check if this key has been used before: */ if (key_table[key].allocated) { /* Return the value: */ data = (void *) pthread->specific_data[key]; } else { /* * This key has not been used before, so return NULL * instead: */ data = NULL; } } else /* No specific data has been created, so just return NULL: */ data = NULL; return (data); } #endif
the_stack_data/743392.c
#include <stdio.h> #include<string.h> #include <stdlib.h> #include <ctype.h> _Bool checkRisk(int age, char comorbidade){ if(age >=65 && comorbidade != "Nenhuma"){ return 1; } else { return 0; }; }
the_stack_data/165768736.c
/* * * * * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. * * Copyright 2007-2019 Broadcom Inc. All rights reserved. */ #if defined(INCLUDE_LIB_CINT) #if defined(PHYMOD_SUPPORT) #include <cint_config.h> #include <cint_types.h> #include <cint_porting.h> #include <soc/types.h> #include <soc/error.h> #include <soc/phy/phyctrl.h> #include <soc/phy/phymod_ctrl.h> int port_cores_access_get(int unit, soc_port_t port, uint32 array_size, phymod_core_access_t *cores, uint32 *nof_cores){ phy_ctrl_t *pc; soc_phymod_ctrl_t *pmc; int i; pc = INT_PHY_SW_STATE(unit, port); pmc = &pc->phymod_ctrl; *nof_cores = 0; if(pmc->num_phys > array_size){ return SOC_E_PARAM; } for(i = 0 ; i < pmc->num_phys; i++){ if( pmc->phy[i] == NULL ){ return SOC_E_INTERNAL; } if (pmc->phy[i]->core == NULL) { return SOC_E_INTERNAL; } cores[i] = pmc->phy[i]->core->pm_core; *nof_cores += 1; } return SOC_E_NONE; } int port_phys_access_get(int unit, soc_port_t port, uint32 array_size, phymod_phy_access_t *phys, uint32 *nof_cores){ phy_ctrl_t *pc; soc_phymod_ctrl_t *pmc; int i; pc = INT_PHY_SW_STATE(unit, port); pmc = &pc->phymod_ctrl; *nof_cores = 0; if(pmc->num_phys > array_size){ return SOC_E_PARAM; } for(i = 0 ; i < pmc->num_phys; i++){ if( pmc->phy[i] == NULL ){ return SOC_E_INTERNAL; } phys[i] = pmc->phy[i]->pm_phy; *nof_cores += 1; } return SOC_E_NONE; } CINT_FWRAPPER_CREATE_RP5(int, int, 0, 0, port_cores_access_get, int, int, unit, 0, 0, soc_port_t, soc_port_t, port, 0, 0, uint32, uint32, array_size, 0, 0, phymod_core_access_t*, phymod_core_access_t, cores, 1, 0, uint32*, uint32, nof_cores, 1, 0 ); CINT_FWRAPPER_CREATE_RP5(int, int, 0, 0, port_phys_access_get, int, int, unit, 0, 0, soc_port_t, soc_port_t, port, 0, 0, uint32, uint32, array_size, 0, 0, phymod_phy_access_t*, phymod_phy_access_t, phys, 1, 0, uint32*, uint32, nof_cores, 1, 0 ); static cint_function_t __cint_functions[] = { CINT_FWRAPPER_ENTRY(port_cores_access_get), CINT_FWRAPPER_ENTRY(port_phys_access_get), { NULL } }; static cint_parameter_desc_t __cint_typedefs[] = { { "uint32", "uint32_t", 0, 0 }, { NULL } }; cint_data_t phymod_access_cint_data = { NULL, __cint_functions, NULL, NULL, __cint_typedefs, NULL, NULL, }; #endif /* defined(PHYMOD_SUPPORT) */ #endif /* defined(INCLUDE_LIB_CINT) */ int _phymod_access_cint_data_not_empty;
the_stack_data/117328201.c
// WARNING: The files in this directory have not been extensively tested // and may be incorrect. --JTB void main(int N) { int x = 2; int y = 1; int z = x == y + 1 || y == x + 1; for(int t = 0; t < N; t++) { z = x == y + 1 || y == x + 1; if (x == y + 1) { y = y + 2; } else { x = y + 1; } } __VERIFIER_assert(x == y + 1 || y == x + 1); }
the_stack_data/67325308.c
#include <stdio.h> #include <math.h> int main (void) { double a,b,c,delta,x,x2; scanf("%lf %lf %lf",&a,&b,&c); delta = sqrt ((b*b) - (4*a*c)); x = ((-b) + delta) / (2*a); x2 = ((-b) - delta) / (2*a); if (a == 0 || delta<0) printf("Impossivel calcular\n"); else printf("R1 = %.5f\nR2 = %.5f\n",x,x2); return 0; }
the_stack_data/24897.c
#include <stdio.h> int main(int argc, char const *argv[]) { int x = 5, *p; p = &x; // & is used to get the address of variable printf("Value of x : %d\n", x); printf("Address of x : %d\n", &x); printf("Address of p : %d\n", p); printf("Content of p : %d", *p); // * is used to get the value of variable printf("Address of p variable : %d\n", &p); return 0; }
the_stack_data/61076093.c
#include <stdio.h> #include <string.h> #define LEN 15 int analizzastringa(char s[]); int main() { FILE *fi, *fo; char tmp[LEN+1]; fi = fopen("testo.txt", "r"); fo = fopen("risultato.txt", "w"); if(fi && fo) { while(fscanf(fi, "%s", tmp)>0) { if(analizzastringa(tmp)) { fprintf(fo, "%s\n", tmp); } } fclose(fi); fclose(fo); fi = NULL; fo = NULL; } else { printf("Errore apertura file\n"); } return 0; } int analizzastringa(char s[]) { int i, len, ncifre, ris; ncifre = 0; len = strlen(s); for(i=0;i<len;i++) { if(s[i]>='0' && s[i]<='9') { ncifre++; } } if(len>5 && ncifre>=2 && (len-ncifre)>0) { ris = 1; } else { ris = 0; } return ris; }
the_stack_data/67324080.c
/** * Program filename: add-one-thru-m.c * Author: Cory Ringer * Last Updated: 9 April 2018 * Purpose: This program takes two numbers, N and M, * and outputs N + (1 + 2 + ... + M). */ #include <stdio.h> #include <stdlib.h> #define arg(n) atoi(argv[n]) int foo(int num, int count) { if (count < 0) { fprintf(stderr, "ERROR, second value must " "be positive.\n" ); exit(EXIT_FAILURE); } else if (count == 0) return num; else { /* Add M with N, decrement M. */ return foo(num + count, count - 1 ); } } int main(int argc, char **argv) { printf("%i\n", foo(arg(1), arg(2))); return 0; }
the_stack_data/117329189.c
#include<stdio.h> #include<stdlib.h> #include<string.h> int signin(); int signup(); int file(); void main() { system("clear"); int n; char s1[100],s2[100],s3[100],name[100]; printf("1:sig in \n2:sign up"); scanf("%d",&n); if(n==1) { signin(&s1,&name); } else if(n==2) { signup(&s1,&s2,&name); } else { exit(0); } } int signup(char *x,char *y,char *z) { char n; printf("enter your username: "); scanf("%s",&*z); printf("enter you new passcode: "); scanf("%s",&*x); printf("conform passcode: "); scanf("%s",&*y); if(strcmp(&*x,&*y)==0) { FILE *passcode=fopen(&*z,"w"); fprintf(passcode,"%s",&*x); fclose(passcode); printf("success !!!\n"); } else { exit(0); } printf("Do you want to create file y\\n \n"); getchar(); n=getchar(); if(n=='y'||n=='Y') { file(); } else { exit(0); } return 0; } int signin(char *a,char *b) { char name1[100],s4[100],s5[100]; printf("enter user name: "); scanf("%s",name1); printf("enter you passcode: "); scanf("%s",s4); FILE *passcode=fopen(name1,"r"); fgets(s5,100,passcode); fclose(passcode); if(strcmp(s4,s5)==0) { file(); } else { exit(0); } } int file() { int n1,i; char name[]="",joker[1000]; printf("enter how many files do you need: "); scanf("%d",&n1); for(i=1;i<=n1;i++) { printf("enter your file name and enter '.txt' at the end of file name (file formate) \n"); scanf("%s",name); FILE *document=fopen(name,"w"); printf("enter here:\n"); fgetc(stdin); fgets(joker,1000,stdin); fprintf(document,"%s",joker); fclose(document); } return 0; }
the_stack_data/502248.c
/* Copyright (c) 2019-2021 Grant Hadlich * * 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. */ int trailingZeroes(int n){ long long zeroCount = 0; while (n > 0) { n /= 5; zeroCount += n; } return zeroCount; }
the_stack_data/916941.c
#include <stdio.h> #include <string.h> #include <math.h> #include <stdlib.h> int main() { int test,i; scanf("%d",&test); for(i=0;i<test;i++) { long int n; scanf("%ld",&n); int j=0; long int c=0; long int arr[32]; if (n==1) { long int s=4294967294; printf("%ld\n",s); /* code */ } if (n==0) { long int g=4294967295; printf("%ld\n",g); } if(n!=1 && n!=0) { while(c!=1) { arr[31-j]=n%2; /*printf("%ld %ld",arr[31-j],n%2);*/ c=n/2; n=n/2; j=j+1; } /*printf("%d",j);*/ arr[31-j]=1; int k; for(k=0;k<=31-j-1;k++) { arr[k]=0; } int u; for(u=0;u<32;u++) { if (arr[u]==0) { arr[u]=1; /* code */ } else if (arr[u]==1) { arr[u]=0; /* code */ } } int h; long int count=0; for(h=0;h<32;h++) count=count+ arr[h]*(pow(2,31-h)); printf("%ld\n",count); } } /* Enter your code here. Read input from STDIN. Print output to STDOUT */ return 0; }
the_stack_data/144764.c
/* Period parameters */ #define N 624 #define M 397 #define MATRIX_A 0x9908b0df /* constant vector a */ #define UPPER_MASK 0x80000000 /* most significant w-r bits */ #define LOWER_MASK 0x7fffffff /* least significant r bits */ /* Tempering parameters */ #define TEMPERING_MASK_B 0x9d2c5680 #define TEMPERING_MASK_C 0xefc60000 #define TEMPERING_SHIFT_U(y) (y >> 11) #define TEMPERING_SHIFT_S(y) (y << 7) #define TEMPERING_SHIFT_T(y) (y << 15) #define TEMPERING_SHIFT_L(y) (y >> 18) #define RAND_MAX 0x7fffffff static unsigned long mt[N]; /* the array for the state vector */ static int mti=N+1; /* mti==N+1 means mt[N] is not initialized */ /* initializing the array with a NONZERO seed */ void sgenrand(unsigned long seed) { /* setting initial seeds to mt[N] using */ /* the generator Line 25 of Table 1 in */ /* [KNUTH 1981, The Art of Computer Programming */ /* Vol. 2 (2nd Ed.), pp102] */ mt[0]= seed & 0xffffffff; for (mti=1; mti<N; mti++) mt[mti] = (69069 * mt[mti-1]) & 0xffffffff; } long /* for integer generation */ genrand() { unsigned long y; static unsigned long mag01[2]={0x0, MATRIX_A}; /* mag01[x] = x * MATRIX_A for x=0,1 */ if (mti >= N) { /* generate N words at one time */ int kk; if (mti == N+1) /* if sgenrand() has not been called, */ sgenrand(4357); /* a default initial seed is used */ for (kk=0;kk<N-M;kk++) { y = (mt[kk]&UPPER_MASK)|(mt[kk+1]&LOWER_MASK); mt[kk] = mt[kk+M] ^ (y >> 1) ^ mag01[y & 0x1]; } for (;kk<N-1;kk++) { y = (mt[kk]&UPPER_MASK)|(mt[kk+1]&LOWER_MASK); mt[kk] = mt[kk+(M-N)] ^ (y >> 1) ^ mag01[y & 0x1]; } y = (mt[N-1]&UPPER_MASK)|(mt[0]&LOWER_MASK); mt[N-1] = mt[M-1] ^ (y >> 1) ^ mag01[y & 0x1]; mti = 0; } y = mt[mti++]; y ^= TEMPERING_SHIFT_U(y); y ^= TEMPERING_SHIFT_S(y) & TEMPERING_MASK_B; y ^= TEMPERING_SHIFT_T(y) & TEMPERING_MASK_C; y ^= TEMPERING_SHIFT_L(y); // Strip off uppermost bit because we want a long, // not an unsigned long return y & RAND_MAX; } // Assumes 0 <= max <= RAND_MAX // Returns in the half-open interval [0, max] long random_at_most(long max) { unsigned long // max <= RAND_MAX < ULONG_MAX, so this is okay. num_bins = (unsigned long) max + 1, num_rand = (unsigned long) RAND_MAX + 1, bin_size = num_rand / num_bins, defect = num_rand % num_bins; long x; do { x = genrand(); } // This is carefully written not to overflow while (num_rand - defect <= (unsigned long)x); // Truncated division is intentional return x/bin_size; }
the_stack_data/248580078.c
extern void __VERIFIER_error() __attribute__ ((__noreturn__)); void __VERIFIER_assert(int cond) { if(!(cond)) { ERROR: __VERIFIER_error(); } } /* * Adapted from http://www.sanfoundry.com/c-programming-examples-arrays/ * C Program to Print the Number of Odd & Even Numbers in an Array */ #define SIZE 150 void printEven( int i ) { __VERIFIER_assert( ( i % 2 ) == 0 ); // printf( "%d" , i ); } void printOdd( int i ) { __VERIFIER_assert( ( i % 2 ) != 0 ); // printf( "%d" , i ); } int main() { int array[SIZE]; int i; int num; //printf("Even numbers in the array are - "); for (i = 0; i < num; i++) { if (array[i] % 2 == 0) { printEven( array[i] ); } } //printf("\n Odd numbers in the array are -"); for (i = 0; i < num; i++) { if (array[i] % 2 != 0) { printOdd( array[i] ); } } return 0; }
the_stack_data/86075587.c
//@ ltl invariant negative: ( ([] (<> AP((num0 == 0)))) || (! ([] ( (<> ( (! AP((p0_l0 != 0))) && (! AP((p0_l1 != 0))))) && (<> (! ( (! AP((p0_l0 != 0))) && (! AP((p0_l1 != 0)))))))))); extern float __VERIFIER_nondet_float(void); extern int __VERIFIER_nondet_int(void); char __VERIFIER_nondet_bool(void) { return __VERIFIER_nondet_int() != 0; } char p3_l1, _x_p3_l1; char p3_l0, _x_p3_l0; char p2_l1, _x_p2_l1; char p2_l0, _x_p2_l0; char p1_l1, _x_p1_l1; char p1_l0, _x_p1_l0; char p5_l0, _x_p5_l0; int min_num, _x_min_num; char p5_l1, _x_p5_l1; int max_num, _x_max_num; char run0, _x_run0; char run1, _x_run1; char run2, _x_run2; int num0, _x_num0; int num1, _x_num1; int num2, _x_num2; char p4_l0, _x_p4_l0; int num3, _x_num3; char p4_l1, _x_p4_l1; int num4, _x_num4; int num5, _x_num5; char p0_l0, _x_p0_l0; char p0_l1, _x_p0_l1; int main() { p3_l1 = __VERIFIER_nondet_bool(); p3_l0 = __VERIFIER_nondet_bool(); p2_l1 = __VERIFIER_nondet_bool(); p2_l0 = __VERIFIER_nondet_bool(); p1_l1 = __VERIFIER_nondet_bool(); p1_l0 = __VERIFIER_nondet_bool(); p5_l0 = __VERIFIER_nondet_bool(); min_num = __VERIFIER_nondet_int(); p5_l1 = __VERIFIER_nondet_bool(); max_num = __VERIFIER_nondet_int(); run0 = __VERIFIER_nondet_bool(); run1 = __VERIFIER_nondet_bool(); run2 = __VERIFIER_nondet_bool(); num0 = __VERIFIER_nondet_int(); num1 = __VERIFIER_nondet_int(); num2 = __VERIFIER_nondet_int(); p4_l0 = __VERIFIER_nondet_bool(); num3 = __VERIFIER_nondet_int(); p4_l1 = __VERIFIER_nondet_bool(); num4 = __VERIFIER_nondet_int(); num5 = __VERIFIER_nondet_int(); p0_l0 = __VERIFIER_nondet_bool(); p0_l1 = __VERIFIER_nondet_bool(); int __ok = (((( !(p5_l0 != 0)) && ( !(p5_l1 != 0))) && (((( !(p5_l0 != 0)) && ( !(p5_l1 != 0))) || ((p5_l0 != 0) && ( !(p5_l1 != 0)))) || (((p5_l1 != 0) && ( !(p5_l0 != 0))) || ((p5_l0 != 0) && (p5_l1 != 0))))) && (((( !(p4_l0 != 0)) && ( !(p4_l1 != 0))) && (((( !(p4_l0 != 0)) && ( !(p4_l1 != 0))) || ((p4_l0 != 0) && ( !(p4_l1 != 0)))) || (((p4_l1 != 0) && ( !(p4_l0 != 0))) || ((p4_l0 != 0) && (p4_l1 != 0))))) && (((( !(p3_l0 != 0)) && ( !(p3_l1 != 0))) && (((( !(p3_l0 != 0)) && ( !(p3_l1 != 0))) || ((p3_l0 != 0) && ( !(p3_l1 != 0)))) || (((p3_l1 != 0) && ( !(p3_l0 != 0))) || ((p3_l0 != 0) && (p3_l1 != 0))))) && (((( !(p2_l0 != 0)) && ( !(p2_l1 != 0))) && (((( !(p2_l0 != 0)) && ( !(p2_l1 != 0))) || ((p2_l0 != 0) && ( !(p2_l1 != 0)))) || (((p2_l1 != 0) && ( !(p2_l0 != 0))) || ((p2_l0 != 0) && (p2_l1 != 0))))) && (((( !(p1_l0 != 0)) && ( !(p1_l1 != 0))) && (((( !(p1_l0 != 0)) && ( !(p1_l1 != 0))) || ((p1_l0 != 0) && ( !(p1_l1 != 0)))) || (((p1_l1 != 0) && ( !(p1_l0 != 0))) || ((p1_l0 != 0) && (p1_l1 != 0))))) && (((( !(p0_l0 != 0)) && ( !(p0_l1 != 0))) && (((( !(p0_l0 != 0)) && ( !(p0_l1 != 0))) || ((p0_l0 != 0) && ( !(p0_l1 != 0)))) || (((p0_l1 != 0) && ( !(p0_l0 != 0))) || ((p0_l0 != 0) && (p0_l1 != 0))))) && ((((((((((((((((((((((num0 == 0) && (num1 == 0)) && (num2 == 0)) && (num3 == 0)) && (num4 == 0)) && (num5 == 0)) && (((run2 != 0) && ((run0 != 0) && ( !(run1 != 0)))) || (((run2 != 0) && (( !(run0 != 0)) && ( !(run1 != 0)))) || ((( !(run2 != 0)) && ((run0 != 0) && (run1 != 0))) || ((( !(run2 != 0)) && ((run1 != 0) && ( !(run0 != 0)))) || ((( !(run2 != 0)) && (( !(run0 != 0)) && ( !(run1 != 0)))) || (( !(run2 != 0)) && ((run0 != 0) && ( !(run1 != 0)))))))))) && (num0 <= max_num)) && (num1 <= max_num)) && (num2 <= max_num)) && (num3 <= max_num)) && (num4 <= max_num)) && (num5 <= max_num)) && ((((((num0 == max_num) || (num1 == max_num)) || (num2 == max_num)) || (num3 == max_num)) || (num4 == max_num)) || (num5 == max_num))) && (((((((num0 == 0) && (num1 == 0)) && (num2 == 0)) && (num3 == 0)) && (num4 == 0)) && (num5 == 0)) == (min_num == 0))) && ((num0 <= 0) || (min_num <= num0))) && ((num1 <= 0) || (min_num <= num1))) && ((num2 <= 0) || (min_num <= num2))) && ((num3 <= 0) || (min_num <= num3))) && ((num4 <= 0) || (min_num <= num4))) && ((num5 <= 0) || (min_num <= num5))) && (((num4 == min_num) || ((num3 == min_num) || ((num2 == min_num) || ((num0 == min_num) || (num1 == min_num))))) || (num5 == min_num))))))))); while (__ok) { _x_p3_l1 = __VERIFIER_nondet_bool(); _x_p3_l0 = __VERIFIER_nondet_bool(); _x_p2_l1 = __VERIFIER_nondet_bool(); _x_p2_l0 = __VERIFIER_nondet_bool(); _x_p1_l1 = __VERIFIER_nondet_bool(); _x_p1_l0 = __VERIFIER_nondet_bool(); _x_p5_l0 = __VERIFIER_nondet_bool(); _x_min_num = __VERIFIER_nondet_int(); _x_p5_l1 = __VERIFIER_nondet_bool(); _x_max_num = __VERIFIER_nondet_int(); _x_run0 = __VERIFIER_nondet_bool(); _x_run1 = __VERIFIER_nondet_bool(); _x_run2 = __VERIFIER_nondet_bool(); _x_num0 = __VERIFIER_nondet_int(); _x_num1 = __VERIFIER_nondet_int(); _x_num2 = __VERIFIER_nondet_int(); _x_p4_l0 = __VERIFIER_nondet_bool(); _x_num3 = __VERIFIER_nondet_int(); _x_p4_l1 = __VERIFIER_nondet_bool(); _x_num4 = __VERIFIER_nondet_int(); _x_num5 = __VERIFIER_nondet_int(); _x_p0_l0 = __VERIFIER_nondet_bool(); _x_p0_l1 = __VERIFIER_nondet_bool(); __ok = ((((((((((( !(_x_p5_l0 != 0)) && ( !(_x_p5_l1 != 0))) || ((_x_p5_l0 != 0) && ( !(_x_p5_l1 != 0)))) || (((_x_p5_l1 != 0) && ( !(_x_p5_l0 != 0))) || ((_x_p5_l0 != 0) && (_x_p5_l1 != 0)))) && (((run2 != 0) && ((run0 != 0) && ( !(run1 != 0)))) || ((((p5_l0 != 0) == (_x_p5_l0 != 0)) && ((p5_l1 != 0) == (_x_p5_l1 != 0))) && (num5 == _x_num5)))) && ((((_x_p5_l0 != 0) && ( !(_x_p5_l1 != 0))) && ((_x_num5 + (-1 * max_num)) == 1)) || ( !(((run2 != 0) && ((run0 != 0) && ( !(run1 != 0)))) && (( !(p5_l0 != 0)) && ( !(p5_l1 != 0))))))) && (((num5 == _x_num5) && (((_x_p5_l0 != 0) && ( !(_x_p5_l1 != 0))) || ((_x_p5_l1 != 0) && ( !(_x_p5_l0 != 0))))) || ( !(((run2 != 0) && ((run0 != 0) && ( !(run1 != 0)))) && ((p5_l0 != 0) && ( !(p5_l1 != 0))))))) && (( !(((run2 != 0) && ((run0 != 0) && ( !(run1 != 0)))) && ((p5_l0 != 0) && ( !(p5_l1 != 0))))) || (((_x_p5_l1 != 0) && ( !(_x_p5_l0 != 0))) == ((( !(num3 == min_num)) && (( !(num2 == min_num)) && (( !(num1 == min_num)) && (( !(num0 == min_num)) && (num5 <= min_num))))) && ( !(num4 == min_num)))))) && (((num5 == _x_num5) && (((_x_p5_l1 != 0) && ( !(_x_p5_l0 != 0))) || ((_x_p5_l0 != 0) && (_x_p5_l1 != 0)))) || ( !(((run2 != 0) && ((run0 != 0) && ( !(run1 != 0)))) && ((p5_l1 != 0) && ( !(p5_l0 != 0))))))) && (((( !(_x_p5_l0 != 0)) && ( !(_x_p5_l1 != 0))) && (num5 == _x_num5)) || ( !(((run2 != 0) && ((run0 != 0) && ( !(run1 != 0)))) && ((p5_l0 != 0) && (p5_l1 != 0)))))) && ((((((((((( !(_x_p4_l0 != 0)) && ( !(_x_p4_l1 != 0))) || ((_x_p4_l0 != 0) && ( !(_x_p4_l1 != 0)))) || (((_x_p4_l1 != 0) && ( !(_x_p4_l0 != 0))) || ((_x_p4_l0 != 0) && (_x_p4_l1 != 0)))) && (((run2 != 0) && (( !(run0 != 0)) && ( !(run1 != 0)))) || ((((p4_l0 != 0) == (_x_p4_l0 != 0)) && ((p4_l1 != 0) == (_x_p4_l1 != 0))) && (num4 == _x_num4)))) && ((((_x_p4_l0 != 0) && ( !(_x_p4_l1 != 0))) && ((_x_num4 + (-1 * max_num)) == 1)) || ( !(((run2 != 0) && (( !(run0 != 0)) && ( !(run1 != 0)))) && (( !(p4_l0 != 0)) && ( !(p4_l1 != 0))))))) && (((num4 == _x_num4) && (((_x_p4_l0 != 0) && ( !(_x_p4_l1 != 0))) || ((_x_p4_l1 != 0) && ( !(_x_p4_l0 != 0))))) || ( !(((run2 != 0) && (( !(run0 != 0)) && ( !(run1 != 0)))) && ((p4_l0 != 0) && ( !(p4_l1 != 0))))))) && (( !(((run2 != 0) && (( !(run0 != 0)) && ( !(run1 != 0)))) && ((p4_l0 != 0) && ( !(p4_l1 != 0))))) || (((_x_p4_l1 != 0) && ( !(_x_p4_l0 != 0))) == ((( !(num2 == min_num)) && (( !(num1 == min_num)) && (( !(num0 == min_num)) && (num4 <= min_num)))) && ( !(num3 == min_num)))))) && (((num4 == _x_num4) && (((_x_p4_l1 != 0) && ( !(_x_p4_l0 != 0))) || ((_x_p4_l0 != 0) && (_x_p4_l1 != 0)))) || ( !(((run2 != 0) && (( !(run0 != 0)) && ( !(run1 != 0)))) && ((p4_l1 != 0) && ( !(p4_l0 != 0))))))) && (((( !(_x_p4_l0 != 0)) && ( !(_x_p4_l1 != 0))) && (num4 == _x_num4)) || ( !(((run2 != 0) && (( !(run0 != 0)) && ( !(run1 != 0)))) && ((p4_l0 != 0) && (p4_l1 != 0)))))) && ((((((((((( !(_x_p3_l0 != 0)) && ( !(_x_p3_l1 != 0))) || ((_x_p3_l0 != 0) && ( !(_x_p3_l1 != 0)))) || (((_x_p3_l1 != 0) && ( !(_x_p3_l0 != 0))) || ((_x_p3_l0 != 0) && (_x_p3_l1 != 0)))) && ((( !(run2 != 0)) && ((run0 != 0) && (run1 != 0))) || ((((p3_l0 != 0) == (_x_p3_l0 != 0)) && ((p3_l1 != 0) == (_x_p3_l1 != 0))) && (num3 == _x_num3)))) && ((((_x_p3_l0 != 0) && ( !(_x_p3_l1 != 0))) && ((_x_num3 + (-1 * max_num)) == 1)) || ( !((( !(run2 != 0)) && ((run0 != 0) && (run1 != 0))) && (( !(p3_l0 != 0)) && ( !(p3_l1 != 0))))))) && (((num3 == _x_num3) && (((_x_p3_l0 != 0) && ( !(_x_p3_l1 != 0))) || ((_x_p3_l1 != 0) && ( !(_x_p3_l0 != 0))))) || ( !((( !(run2 != 0)) && ((run0 != 0) && (run1 != 0))) && ((p3_l0 != 0) && ( !(p3_l1 != 0))))))) && (( !((( !(run2 != 0)) && ((run0 != 0) && (run1 != 0))) && ((p3_l0 != 0) && ( !(p3_l1 != 0))))) || (((_x_p3_l1 != 0) && ( !(_x_p3_l0 != 0))) == ((( !(num1 == min_num)) && (( !(num0 == min_num)) && (num3 <= min_num))) && ( !(num2 == min_num)))))) && (((num3 == _x_num3) && (((_x_p3_l1 != 0) && ( !(_x_p3_l0 != 0))) || ((_x_p3_l0 != 0) && (_x_p3_l1 != 0)))) || ( !((( !(run2 != 0)) && ((run0 != 0) && (run1 != 0))) && ((p3_l1 != 0) && ( !(p3_l0 != 0))))))) && (((( !(_x_p3_l0 != 0)) && ( !(_x_p3_l1 != 0))) && (num3 == _x_num3)) || ( !((( !(run2 != 0)) && ((run0 != 0) && (run1 != 0))) && ((p3_l0 != 0) && (p3_l1 != 0)))))) && ((((((((((( !(_x_p2_l0 != 0)) && ( !(_x_p2_l1 != 0))) || ((_x_p2_l0 != 0) && ( !(_x_p2_l1 != 0)))) || (((_x_p2_l1 != 0) && ( !(_x_p2_l0 != 0))) || ((_x_p2_l0 != 0) && (_x_p2_l1 != 0)))) && ((( !(run2 != 0)) && ((run1 != 0) && ( !(run0 != 0)))) || ((((p2_l0 != 0) == (_x_p2_l0 != 0)) && ((p2_l1 != 0) == (_x_p2_l1 != 0))) && (num2 == _x_num2)))) && ((((_x_p2_l0 != 0) && ( !(_x_p2_l1 != 0))) && ((_x_num2 + (-1 * max_num)) == 1)) || ( !((( !(run2 != 0)) && ((run1 != 0) && ( !(run0 != 0)))) && (( !(p2_l0 != 0)) && ( !(p2_l1 != 0))))))) && (((num2 == _x_num2) && (((_x_p2_l0 != 0) && ( !(_x_p2_l1 != 0))) || ((_x_p2_l1 != 0) && ( !(_x_p2_l0 != 0))))) || ( !((( !(run2 != 0)) && ((run1 != 0) && ( !(run0 != 0)))) && ((p2_l0 != 0) && ( !(p2_l1 != 0))))))) && (( !((( !(run2 != 0)) && ((run1 != 0) && ( !(run0 != 0)))) && ((p2_l0 != 0) && ( !(p2_l1 != 0))))) || (((_x_p2_l1 != 0) && ( !(_x_p2_l0 != 0))) == ((( !(num0 == min_num)) && (num2 <= min_num)) && ( !(num1 == min_num)))))) && (((num2 == _x_num2) && (((_x_p2_l1 != 0) && ( !(_x_p2_l0 != 0))) || ((_x_p2_l0 != 0) && (_x_p2_l1 != 0)))) || ( !((( !(run2 != 0)) && ((run1 != 0) && ( !(run0 != 0)))) && ((p2_l1 != 0) && ( !(p2_l0 != 0))))))) && (((( !(_x_p2_l0 != 0)) && ( !(_x_p2_l1 != 0))) && (num2 == _x_num2)) || ( !((( !(run2 != 0)) && ((run1 != 0) && ( !(run0 != 0)))) && ((p2_l0 != 0) && (p2_l1 != 0)))))) && ((((((((((( !(_x_p1_l0 != 0)) && ( !(_x_p1_l1 != 0))) || ((_x_p1_l0 != 0) && ( !(_x_p1_l1 != 0)))) || (((_x_p1_l1 != 0) && ( !(_x_p1_l0 != 0))) || ((_x_p1_l0 != 0) && (_x_p1_l1 != 0)))) && ((( !(run2 != 0)) && ((run0 != 0) && ( !(run1 != 0)))) || ((((p1_l0 != 0) == (_x_p1_l0 != 0)) && ((p1_l1 != 0) == (_x_p1_l1 != 0))) && (num1 == _x_num1)))) && ((((_x_p1_l0 != 0) && ( !(_x_p1_l1 != 0))) && ((_x_num1 + (-1 * max_num)) == 1)) || ( !((( !(run2 != 0)) && ((run0 != 0) && ( !(run1 != 0)))) && (( !(p1_l0 != 0)) && ( !(p1_l1 != 0))))))) && (((num1 == _x_num1) && (((_x_p1_l0 != 0) && ( !(_x_p1_l1 != 0))) || ((_x_p1_l1 != 0) && ( !(_x_p1_l0 != 0))))) || ( !((( !(run2 != 0)) && ((run0 != 0) && ( !(run1 != 0)))) && ((p1_l0 != 0) && ( !(p1_l1 != 0))))))) && (( !((( !(run2 != 0)) && ((run0 != 0) && ( !(run1 != 0)))) && ((p1_l0 != 0) && ( !(p1_l1 != 0))))) || (((_x_p1_l1 != 0) && ( !(_x_p1_l0 != 0))) == ((num1 <= min_num) && ( !(num0 == min_num)))))) && (((num1 == _x_num1) && (((_x_p1_l1 != 0) && ( !(_x_p1_l0 != 0))) || ((_x_p1_l0 != 0) && (_x_p1_l1 != 0)))) || ( !((( !(run2 != 0)) && ((run0 != 0) && ( !(run1 != 0)))) && ((p1_l1 != 0) && ( !(p1_l0 != 0))))))) && (((( !(_x_p1_l0 != 0)) && ( !(_x_p1_l1 != 0))) && (num1 == _x_num1)) || ( !((( !(run2 != 0)) && ((run0 != 0) && ( !(run1 != 0)))) && ((p1_l0 != 0) && (p1_l1 != 0)))))) && ((((((((((( !(_x_p0_l0 != 0)) && ( !(_x_p0_l1 != 0))) || ((_x_p0_l0 != 0) && ( !(_x_p0_l1 != 0)))) || (((_x_p0_l1 != 0) && ( !(_x_p0_l0 != 0))) || ((_x_p0_l0 != 0) && (_x_p0_l1 != 0)))) && ((( !(run2 != 0)) && (( !(run0 != 0)) && ( !(run1 != 0)))) || ((((p0_l0 != 0) == (_x_p0_l0 != 0)) && ((p0_l1 != 0) == (_x_p0_l1 != 0))) && (num0 == _x_num0)))) && ((((_x_p0_l0 != 0) && ( !(_x_p0_l1 != 0))) && ((_x_num0 + (-1 * max_num)) == 1)) || ( !((( !(run2 != 0)) && (( !(run0 != 0)) && ( !(run1 != 0)))) && (( !(p0_l0 != 0)) && ( !(p0_l1 != 0))))))) && (((num0 == _x_num0) && (((_x_p0_l0 != 0) && ( !(_x_p0_l1 != 0))) || ((_x_p0_l1 != 0) && ( !(_x_p0_l0 != 0))))) || ( !((( !(run2 != 0)) && (( !(run0 != 0)) && ( !(run1 != 0)))) && ((p0_l0 != 0) && ( !(p0_l1 != 0))))))) && (( !((( !(run2 != 0)) && (( !(run0 != 0)) && ( !(run1 != 0)))) && ((p0_l0 != 0) && ( !(p0_l1 != 0))))) || (((_x_p0_l1 != 0) && ( !(_x_p0_l0 != 0))) == (num0 <= min_num)))) && (((num0 == _x_num0) && (((_x_p0_l1 != 0) && ( !(_x_p0_l0 != 0))) || ((_x_p0_l0 != 0) && (_x_p0_l1 != 0)))) || ( !((( !(run2 != 0)) && (( !(run0 != 0)) && ( !(run1 != 0)))) && ((p0_l1 != 0) && ( !(p0_l0 != 0))))))) && (((( !(_x_p0_l0 != 0)) && ( !(_x_p0_l1 != 0))) && (num0 == _x_num0)) || ( !((( !(run2 != 0)) && (( !(run0 != 0)) && ( !(run1 != 0)))) && ((p0_l0 != 0) && (p0_l1 != 0)))))) && ((((((((((((((((((_x_run2 != 0) && ((_x_run0 != 0) && ( !(_x_run1 != 0)))) || (((_x_run2 != 0) && (( !(_x_run0 != 0)) && ( !(_x_run1 != 0)))) || ((( !(_x_run2 != 0)) && ((_x_run0 != 0) && (_x_run1 != 0))) || ((( !(_x_run2 != 0)) && ((_x_run1 != 0) && ( !(_x_run0 != 0)))) || ((( !(_x_run2 != 0)) && (( !(_x_run0 != 0)) && ( !(_x_run1 != 0)))) || (( !(_x_run2 != 0)) && ((_x_run0 != 0) && ( !(_x_run1 != 0))))))))) && (_x_num0 <= _x_max_num)) && (_x_num1 <= _x_max_num)) && (_x_num2 <= _x_max_num)) && (_x_num3 <= _x_max_num)) && (_x_num4 <= _x_max_num)) && (_x_num5 <= _x_max_num)) && ((((((_x_num0 == _x_max_num) || (_x_num1 == _x_max_num)) || (_x_num2 == _x_max_num)) || (_x_num3 == _x_max_num)) || (_x_num4 == _x_max_num)) || (_x_num5 == _x_max_num))) && (((((((_x_num0 == 0) && (_x_num1 == 0)) && (_x_num2 == 0)) && (_x_num3 == 0)) && (_x_num4 == 0)) && (_x_num5 == 0)) == (_x_min_num == 0))) && ((_x_num0 <= 0) || (_x_min_num <= _x_num0))) && ((_x_num1 <= 0) || (_x_min_num <= _x_num1))) && ((_x_num2 <= 0) || (_x_min_num <= _x_num2))) && ((_x_num3 <= 0) || (_x_min_num <= _x_num3))) && ((_x_num4 <= 0) || (_x_min_num <= _x_num4))) && ((_x_num5 <= 0) || (_x_min_num <= _x_num5))) && ((((((_x_num0 == _x_min_num) || (_x_num1 == _x_min_num)) || (_x_num2 == _x_min_num)) || (_x_num3 == _x_min_num)) || (_x_num4 == _x_min_num)) || (_x_num5 == _x_min_num))))))))); p3_l1 = _x_p3_l1; p3_l0 = _x_p3_l0; p2_l1 = _x_p2_l1; p2_l0 = _x_p2_l0; p1_l1 = _x_p1_l1; p1_l0 = _x_p1_l0; p5_l0 = _x_p5_l0; min_num = _x_min_num; p5_l1 = _x_p5_l1; max_num = _x_max_num; run0 = _x_run0; run1 = _x_run1; run2 = _x_run2; num0 = _x_num0; num1 = _x_num1; num2 = _x_num2; p4_l0 = _x_p4_l0; num3 = _x_num3; p4_l1 = _x_p4_l1; num4 = _x_num4; num5 = _x_num5; p0_l0 = _x_p0_l0; p0_l1 = _x_p0_l1; } }
the_stack_data/1270902.c
#ifdef __GNUC__ #define __fsc_attribute__(x) #endif struct __fsc_attribute__((named "test_foo")) foo *func(void); struct __fsc_attribute__((named "test_foo")) foo { int n; } x; int main(int argc, char **argv){ return 0; }
the_stack_data/27707.c
/* This testcase is part of GDB, the GNU debugger. Copyright 2005, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <stdio.h> volatile int cond_hit; int cond (void) { cond_hit++; return 1; } int func (void) { return 0; /* in-func */ } int main (void) { /* Variable is used so that there is always at least one instruction on the same line after FUNC returns. */ int i = func (); /* call-func */ /* Dummy calls. */ cond (); func (); return 0; }
the_stack_data/153268687.c
/* lets learn recursion through 3 great questions. * QUESTION 4.4.1: Write a recursive function that given an input n * sums all non negetive integers upto n. */
the_stack_data/1218340.c
extern void __VERIFIER_error() __attribute__ ((__noreturn__)); void __VERIFIER_assert(int cond) { if(!(cond)) { ERROR: __VERIFIER_error(); } } #define N 10 int main( ) { int a1[N]; int a2[N]; int a3[N]; int a4[N]; int a5[N]; int a6[N]; int a7[N]; int a8[N]; int a9[N]; int a0[N]; int i; for ( i = 0 ; i < N ; i++ ) { a2[i] = a1[i]; } for ( i = 0 ; i < N ; i++ ) { a3[i] = a2[i]; } for ( i = 0 ; i < N ; i++ ) { a4[i] = a3[i]; } for ( i = 0 ; i < N ; i++ ) { a5[i] = a4[i]; } for ( i = 0 ; i < N ; i++ ) { a6[i] = a5[i]; } for ( i = 0 ; i < N ; i++ ) { a7[i] = a6[i]; } for ( i = 0 ; i < N ; i++ ) { a8[i] = a7[i]; } for ( i = 0 ; i < N ; i++ ) { a9[i] = a8[i]; } for ( i = 0 ; i < N ; i++ ) { a0[i] = a9[i]; } int x; for ( x = 0 ; x < N ; x++ ) { __VERIFIER_assert( a1[x] == a0[x] ); } return 0; }
the_stack_data/109678.c
#include <stdio.h> int main() { printf("Hello, World!\n"); return 0; }
the_stack_data/31387675.c
#include <stdbool.h> int mx_isspace(char c) { if (c == 32) return 1; else return 0; }
the_stack_data/184517502.c
/* { dg-do run } */ /* { dg-options "-fsanitize=undefined" } */ /* { dg-shouldfail "ubsan" } */ int main (void) { unsigned int len = 1; float (*P)[len][len] = 0; (*P)[0][0] = 1; return 0; } /* { dg-output "store to null pointer of type 'float'" } */
the_stack_data/621635.c
#include <stdint.h> volatile int global = 42; volatile uint32_t controller_status = 0; volatile char *VIDEO_MEMORY = (volatile char *)(0x50000000 + 0xFE800); int main() { int a = 4; int b = 12; int last_global = 42; int x_pos = 12; VIDEO_MEMORY[0] = 'H'; VIDEO_MEMORY[1] = 'e'; VIDEO_MEMORY[2] = 'l'; VIDEO_MEMORY[3] = 'l'; VIDEO_MEMORY[4] = 'o'; VIDEO_MEMORY[5] = ' '; VIDEO_MEMORY[6] = 'W'; VIDEO_MEMORY[7] = 'o'; VIDEO_MEMORY[8] = 'r'; VIDEO_MEMORY[9] = 'l'; VIDEO_MEMORY[10] = 'd'; VIDEO_MEMORY[11] = '!'; VIDEO_MEMORY[12] = 'X'; while (1) { int c = a + b + global; if(global != last_global){ if(controller_status){ VIDEO_MEMORY[x_pos] = ' '; if(controller_status & 0x1){ // left if(x_pos & 0x3F){ x_pos--; } } if(controller_status & 0x2){ //down if(x_pos >= 0x40){ x_pos -= 0x40; } } if(controller_status & 0x4){ //up if(x_pos < 0x8C0){ x_pos += 0x40; } } if(controller_status & 0x8){ if((x_pos & 0x3F) != 0x3F){ // right x_pos++; } } VIDEO_MEMORY[x_pos] = 'X'; } last_global = global; } } return 0; }
the_stack_data/178266522.c
/////////////////////////////////////////// // build table chordVec[d] of circle 1/2 widths at distances d from center // Code adapted from RobG's EduKit // Uses Bresenham's circle algorithm // Modified from RobG's EduKit by Eric Freudenthal and David Pruitt 2016 /////////////////////////////////////////// void computeChordVec(unsigned char chordVec[], unsigned char radius) { int col = radius, row = 0; /* first coordinate (radius, 0) */ // key insight: (col+1)**2 - col**2 = 2col+1 int dColSquared = 2 * col - 1; // change in col**2 for a unit decrease in col int dRowSquared = 1; // change in row**2 for a unit increase in row int radiusSqErr = 0; /* (radius, 0) is on the circle */ int colPrev = 0; /* initially bogus value to force first entry*/ while (col >= row) { /* only sweep first octant */ chordVec[row] = col; /* row always changes in first octant */ /* mirror into 2nd octant */ if (colPrev != col) /* col sometimes repeats in first octant */ chordVec[col] = row; /* only save first (max) col for row */ colPrev = col; row++; /* move vertically (slope <= -1 for first octant) */ radiusSqErr += dRowSquared; /* current radiusSqErr */ dRowSquared += 2; /* next dRowSquared */ if ((2 * radiusSqErr) > dColSquared) { /* only update col if error reduced */ col--; /* move horizontally */ radiusSqErr -= dColSquared; /* current radiusSqErr */ dColSquared -= 2; /* next dColSquared */ } } } #include "stdio.h" #include "assert.h" // Generate circles as source files // (c) Eric Freudenthal, 2016 int main() { int radius; char chordVec[151]; FILE *circleIncludeFile = fopen("abCircle_decls.h", "w"); FILE *chordIncludeFile = fopen("chordVec.h", "w"); assert(chordIncludeFile); assert(circleIncludeFile); fprintf(circleIncludeFile, "// Automatically generated by makeCircles. (c) Eric Freudenthal, 2016\n"); fprintf(circleIncludeFile, "#ifndef abCircle_decls_included\n#define abCircle_decls_included\n\n"); fprintf(chordIncludeFile, "// Automatically generated by makeCircles. (c) Eric Freudenthal, 2016\n"); fprintf(chordIncludeFile, "#ifndef chordVec_included\n#define chordVec_included\n\n"); for (radius = 2; radius <= 150; radius++) { char filename[100]; unsigned char chordIndex; computeChordVec(chordVec, radius); { /* chordVecN.c */ sprintf(filename, "circles/chordVec%d.c", radius); FILE *fp = fopen(filename, "w"); assert(fp); fprintf(fp, "// Automatically generated by makeCircles. (c) Eric Freudenthal, 2016\n"); fprintf(fp, "#include \"chordVec.h\"\n\n"); fprintf(fp, "const unsigned char chordVec%d[%d] = {\n", radius, radius+1); for (chordIndex = 0; chordIndex <= radius; chordIndex ++) fprintf(fp, " %d, // dist along axis = %d\n", chordVec[chordIndex], chordIndex); fprintf(fp, "};\n\n"); fclose(fp); } { /* abCircleN.c */ sprintf(filename, "circles/abCircle%d.c", radius); FILE *fp = fopen(filename, "w"); assert(fp); fprintf(fp, "// Automatically generated by makeCircles. (c) Eric Freudenthal, 2016\n"); fprintf(fp, "#include \"abCircle.h\"\n\n"); fprintf(fp, "#include \"chordVec.h\"\n\n"); fprintf(fp, "const AbCircle circle%d = {" , radius); fprintf(fp, " abCircleGetBounds, abCircleCheck, chordVec%d, %d", radius, radius); fprintf(fp, "};\n"); fclose(fp); } /* includes */ fprintf(chordIncludeFile, "extern const unsigned char chordVec%d[%d];\n", radius, radius+1); fprintf(circleIncludeFile, "extern const AbCircle circle%d;\n" , radius); } fprintf(circleIncludeFile, "\n#endif // included \n"); fprintf(chordIncludeFile, "\n#endif // included \n"); fclose(chordIncludeFile); fclose(circleIncludeFile); }
the_stack_data/298713.c
/* BareMetal File System Utility */ /* Written by Ian Seyler of Return Infinity */ /* Global includes */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <strings.h> #include <ctype.h> /* Global defines */ struct BMFSEntry { char FileName[32]; unsigned long long StartingBlock; unsigned long long ReservedBlocks; unsigned long long FileSize; unsigned long long Unused; }; /* Global constants */ // Min disk size is 6MiB (three blocks of 2MiB each.) const unsigned long long minimumDiskSize = (6 * 1024 * 1024); /* Global variables */ FILE *file, *disk; unsigned int filesize, disksize; char tempfilename[32], tempstring[32]; char *filename, *diskname, *command; char fs_tag[] = "BMFS"; char s_list[] = "list"; char s_format[] = "format"; char s_initialize[] = "initialize"; char s_create[] = "create"; char s_read[] = "read"; char s_write[] = "write"; char s_delete[] = "delete"; struct BMFSEntry entry; void *pentry = &entry; char *BlockMap; char *FileBlocks; char Directory[4096]; char DiskInfo[512]; /* Built-in functions */ int findfile(char *filename, struct BMFSEntry *fileentry, int *entrynumber); void list(); void format(); int initialize(char *diskname, char *size, char *mbr, char *boot, char *kernel); void create(char *filename, unsigned long long maxsize); void read(char *filename); void write(char *filename); void delete(char *filename); /* Program code */ int main(int argc, char *argv[]) { /* Parse arguments */ if (argc < 3) { printf("BareMetal File System Utility v1.0 (2013 04 10)\n"); printf("Written by Ian Seyler @ Return Infinity ([email protected])\n\n"); printf("Usage: %s disk function file\n", argv[0]); printf("Disk: the name of the disk file\n"); printf("Function: list, read, write, create, delete, format, initialize\n"); printf("File: (if applicable)\n"); exit(0); } diskname = argv[1]; command = argv[2]; filename = argv[3]; if (strcasecmp(s_initialize, command) == 0) { if (argc >= 4) { char *size = argv[3]; // Required char *mbr = (argc > 4 ? argv[4] : NULL); // Opt. char *boot = (argc > 5 ? argv[5] : NULL); // Opt. char *kernel = (argc > 6 ? argv[6] : NULL); // Opt. int ret = initialize(diskname, size, mbr, boot, kernel); exit(ret); } else { printf("Usage: %s disk %s ", argv[0], command); printf("size [mbr_file] "); printf("[bootloader_file] [kernel_file]\n"); exit(1); } } if ((disk = fopen(diskname, "r+b")) == NULL) // Open for read/write in binary mode { printf("Error: Unable to open disk '%s'\n", diskname); exit(0); } else // Opened ok, is it a valid BMFS disk? { fseek(disk, 0, SEEK_END); disksize = ftell(disk) / 1048576; // Disk size in MiB fseek(disk, 1024, SEEK_SET); // Seek 1KiB in for disk information fread(DiskInfo, 512, 1, disk); // Read 512 bytes to the DiskInfo buffer fseek(disk, 4096, SEEK_SET); // Seek 4KiB in for directory fread(Directory, 4096, 1, disk); // Read 4096 bytes to the Directory buffer rewind(disk); if (strcasecmp(DiskInfo, fs_tag) != 0) // Is it a BMFS formatted disk? { if (strcasecmp(s_format, command) == 0) { format(); } else { printf("Error: Not a valid BMFS drive (Disk is not BMFS formatted).\n"); } fclose(disk); return 0; } } if (strcasecmp(s_list, command) == 0) { list(); } else if (strcasecmp(s_format, command) == 0) { if (argc > 3) { if (strcasecmp(argv[3], "/FORCE") == 0) { format(); } else { printf("Format aborted!\n"); } } else { printf("Format aborted!\n"); } } else if (strcasecmp(s_create, command) == 0) { if (filename == NULL) { printf("Error: File name not specified.\n"); } else { if (argc > 4) { int filesize = atoi(argv[4]); if (filesize >= 1) { create(filename, filesize); } else { printf("Error: Invalid file size.\n"); } } else { printf("Maximum file size in MiB: "); fgets(tempstring, 32, stdin); // Get up to 32 chars from the keyboard filesize = atoi(tempstring); if (filesize >= 1) create(filename, filesize); else printf("Error: Invalid file size.\n"); } } } else if (strcasecmp(s_read, command) == 0) { read(filename); } else if (strcasecmp(s_write, command) == 0) { write(filename); } else if (strcasecmp(s_delete, command) == 0) { delete(filename); } else { printf("Unknown command\n"); } if (disk != NULL) { fclose( disk ); disk = NULL; } return 0; } int findfile(char *filename, struct BMFSEntry *fileentry, int *entrynumber) { int tint; for (tint = 0; tint < 64; tint++) { memcpy(pentry, Directory+(tint*64), 64); if (entry.FileName[0] == 0x00) // End of directory { tint = 64; } else if (entry.FileName[0] == 0x01) // Emtpy entry { // Ignore } else // Valid entry { if (strcmp(filename, entry.FileName) == 0) { memcpy(fileentry, pentry, 64); *entrynumber = tint; return 1; } } } return 0; } void list() { int tint; printf("%s\nDisk Size: %d MiB\n", diskname, disksize); printf("Name | Size (B)| Reserved (MiB)\n"); printf("==========================================================================\n"); for (tint = 0; tint < 64; tint++) // Max 64 entries { memcpy(pentry, Directory+(tint*64), 64); if (entry.FileName[0] == 0x00) // End of directory, bail out { tint = 64; } else if (entry.FileName[0] == 0x01) // Emtpy entry { // Ignore } else // Valid entry { printf("%-32s %20lld %20lld\n", entry.FileName, entry.FileSize, (entry.ReservedBlocks*2)); } } } void format() { memset(DiskInfo, 0, 512); memset(Directory, 0, 4096); memcpy(DiskInfo, fs_tag, 4); // Add the 'BMFS' tag fseek(disk, 1024, SEEK_SET); // Seek 1KiB in for disk information fwrite(DiskInfo, 512, 1, disk); // Write 512 bytes for the DiskInfo fseek(disk, 4096, SEEK_SET); // Seek 4KiB in for directory fwrite(Directory, 4096, 1, disk); // Write 4096 bytes for the Directory printf("Format complete.\n"); } int initialize(char *diskname, char *size, char *mbr, char *boot, char *kernel) { unsigned long long diskSize = 0; unsigned long long writeSize = 0; const char *bootFileType = NULL; size_t bufferSize = 50 * 1024; char * buffer = NULL; FILE *mbrFile = NULL; FILE *bootFile = NULL; FILE *kernelFile = NULL; int diskSizeFactor = 0; size_t chunkSize = 0; int ret = 0; size_t i; // Determine how the second file will be described in output messages. // If a kernel file is specified too, then assume the second file is the // boot loader. If no kernel file is specified, assume the boot loader // and kernel are combined into one system file. if (boot != NULL) { bootFileType = "boot loader"; if (kernel == NULL) { bootFileType = "system"; } } // Validate the disk size string and convert it to an integer value. for (i = 0; size[i] != '\0' && ret == 0; ++i) { char ch = size[i]; if (isdigit(ch)) { unsigned int n = ch - '0'; if (diskSize * 10 > diskSize ) // Make sure we don't overflow { diskSize *= 10; diskSize += n; } else if (diskSize == 0) // First loop iteration { diskSize += n; } else { printf("Error: Disk size is too large\n"); ret = 1; } } else if (i == 0) // No digits specified { printf("Error: A numeric disk size must be specified\n"); ret = 1; } else { switch (toupper(ch)) { case 'K': diskSizeFactor = 1; break; case 'M': diskSizeFactor = 2; break; case 'G': diskSizeFactor = 3; break; case 'T': diskSizeFactor = 4; break; case 'P': diskSizeFactor = 5; break; default: printf("Error: Invalid disk size string: '%s'\n", size); ret = 1; break; } // If this character is a valid unit indicator, but is not at the // end of the string, then the string is invalid. if (ret == 0 && size[i+1] != '\0') { printf("Error: Invalid disk size string: '%s'\n", size); ret = 1; } } } // Adjust the disk size if a unit indicator was given. Note that an // input of something like "0" or "0K" will get past the checks above. if (ret == 0 && diskSize > 0 && diskSizeFactor > 0) { while (diskSizeFactor--) { if (diskSize * 1024 > diskSize ) // Make sure we don't overflow { diskSize *= 1024; } else { printf("Error: Disk size is too large\n"); ret = 1; } } } // Make sure the disk size is large enough. if (ret == 0) { if (diskSize < minimumDiskSize) { printf( "Error: Disk size must be at least %llu bytes (%lluMiB)\n", minimumDiskSize, minimumDiskSize / (1024*1024)); ret = 1; } } // Open the Master boot Record file for reading. if (ret == 0 && mbr != NULL) { mbrFile = fopen(mbr, "rb"); if (mbrFile == NULL ) { printf("Error: Unable to open MBR file '%s'\n", mbr); ret = 1; } } // Open the boot loader file for reading. if (ret == 0 && boot != NULL) { bootFile = fopen(boot, "rb"); if (bootFile == NULL ) { printf("Error: Unable to open %s file '%s'\n", bootFileType, boot); ret = 1; } } // Open the kernel file for reading. if (ret == 0 && kernel != NULL) { kernelFile = fopen(kernel, "rb"); if (kernelFile == NULL ) { printf("Error: Unable to open kernel file '%s'\n", kernel); ret = 1; } } // Allocate buffer to use for filling the disk image with zeros. if (ret == 0) { buffer = (char *) malloc(bufferSize); if (buffer == NULL) { printf("Error: Failed to allocate buffer\n"); ret = 1; } } // Open the disk image file for writing. This will truncate the disk file // if it already exists, so we should do this only after we're ready to // actually write to the file. if (ret == 0) { disk = fopen(diskname, "wb"); if (disk == NULL) { printf("Error: Unable to open disk '%s'\n", diskname); ret = 1; } } // Fill the disk image with zeros. if (ret == 0) { double percent; memset(buffer, 0, bufferSize); writeSize = 0; while (writeSize < diskSize) { percent = writeSize; percent /= diskSize; percent *= 100; printf("Formatting disk: %llu of %llu bytes (%.0f%%)...\r", writeSize, diskSize, percent); chunkSize = bufferSize; if (chunkSize > diskSize - writeSize) { chunkSize = diskSize - writeSize; } if (fwrite(buffer, chunkSize, 1, disk) != 1) { printf("Error: Failed to write disk '%s'\n", diskname); ret = 1; break; } writeSize += chunkSize; } if (ret == 0) { printf("Formatting disk: %llu of %llu bytes (100%%)%9s\n", writeSize, diskSize, ""); } } // Format the disk. if (ret == 0) { rewind(disk); format(); } // Write the master boot record if it was specified by the caller. if (ret == 0 && mbrFile !=NULL) { printf("Writing master boot record.\n"); fseek(disk, 0, SEEK_SET); if (fread(buffer, 512, 1, mbrFile) == 1) { if (fwrite(buffer, 512, 1, disk) != 1) { printf("Error: Failed to write disk '%s'\n", diskname); ret = 1; } } else { printf("Error: Failed to read file '%s'\n", mbr); ret = 1; } } // Write the boot loader if it was specified by the caller. if (ret == 0 && bootFile !=NULL) { printf("Writing %s file.\n", bootFileType); fseek(disk, 8192, SEEK_SET); for (;;) { chunkSize = fread( buffer, 1, bufferSize, bootFile); if (chunkSize > 0) { if (fwrite(buffer, chunkSize, 1, disk) != 1) { printf("Error: Failed to write disk '%s'\n", diskname); ret = 1; } } else { if (ferror(disk)) { printf("Error: Failed to read file '%s'\n", boot); ret = 1; } break; } } } // Write the kernel if it was specified by the caller. The kernel must // immediately follow the boot loader on disk (i.e. no seek needed.) if (ret == 0 && kernelFile !=NULL) { printf("Writing kernel.\n"); for (;;) { chunkSize = fread( buffer, 1, bufferSize, kernelFile); if (chunkSize > 0) { if (fwrite(buffer, chunkSize, 1, disk) != 1) { printf("Error: Failed to write disk '%s'\n", diskname); ret = 1; } } else { if (ferror(disk)) { printf("Error: Failed to read file '%s'\n", kernel); ret = 1; } break; } } } // Close any files that were opened. if (mbrFile != NULL) { fclose(mbrFile); } if (bootFile != NULL) { fclose(bootFile); } if (kernelFile != NULL) { fclose(kernelFile); } if (disk != NULL) { fclose(disk); disk = NULL; } // Free the buffer if it was allocated. if (buffer != NULL) { free(buffer); } if (ret == 0) { printf("Disk initialization complete.\n"); } return ret; } // helper function for qsort, sorts by StartingBlock field static int StartingBlockCmp(const void *pa, const void *pb) { struct BMFSEntry *ea = (struct BMFSEntry *)pa; struct BMFSEntry *eb = (struct BMFSEntry *)pb; // empty records go to the end if (ea->FileName[0] == 0x01) return 1; if (eb->FileName[0] == 0x01) return -1; // compare non-empty records by their starting blocks number return (ea->StartingBlock - eb->StartingBlock); } void create(char *filename, unsigned long long maxsize) { struct BMFSEntry tempentry; int slot; if (maxsize % 2 != 0) maxsize++; if (findfile(filename, &tempentry, &slot) == 0) { unsigned long long blocks_requested = maxsize / 2; // how many blocks to allocate unsigned long long num_blocks = disksize / 2; // number of blocks in the disk char dir_copy[4096]; // copy of directory int num_used_entries = 0; // how many entries of Directory are either used or deleted int first_free_entry = -1; // where to put new entry int tint; struct BMFSEntry *pEntry; unsigned long long new_file_start = 0; unsigned long long prev_file_end = 1; printf("Creating new file...\n"); // Make a copy of Directory to play with memcpy(dir_copy, Directory, 4096); // Calculate number of files for (tint = 0; tint < 64; tint++) { pEntry = (struct BMFSEntry *)(dir_copy + tint * 64); // points to the current directory entry if (pEntry->FileName[0] == 0x00) // end of directory { num_used_entries = tint; if (first_free_entry == -1) first_free_entry = tint; // there were no unused entires before, will use this one break; } else if (pEntry->FileName[0] == 0x01) // unused entry { if (first_free_entry == -1) first_free_entry = tint; // will use it for our new file } } if (first_free_entry == -1) { printf("Cannot create file: no free directory entries.\n"); return; } // Find an area with enough free blocks // Sort our copy of the directory by starting block number qsort(dir_copy, num_used_entries, 64, StartingBlockCmp); for (tint = 0; tint < num_used_entries + 1; tint++) { // on each iteration of this loop we'll see if a new file can fit // between the end of the previous file (initially == 1) // and the beginning of the current file (or the last data block if there are no more files). unsigned long long this_file_start; pEntry = (struct BMFSEntry *)(dir_copy + tint * 64); // points to the current directory entry if (tint == num_used_entries || pEntry->FileName[0] == 0x01) this_file_start = num_blocks - 1; // index of the last block else this_file_start = pEntry->StartingBlock; if (this_file_start - prev_file_end >= blocks_requested) { // fits here new_file_start = prev_file_end; break; } if (tint < num_used_entries) prev_file_end = pEntry->StartingBlock + pEntry->ReservedBlocks; } if (new_file_start == 0) { printf("Cannot create file of size %lld MiB.\n", maxsize); return; } // Add file record to Directory pEntry = (struct BMFSEntry *)(Directory + first_free_entry * 64); pEntry->StartingBlock = new_file_start; pEntry->ReservedBlocks = blocks_requested; pEntry->FileSize = 0; strcpy(pEntry->FileName, filename); if (first_free_entry == num_used_entries && num_used_entries + 1 < 64) { // here we used the record that was marked with 0x00, // so make sure to mark the next record with 0x00 if it exists pEntry = (struct BMFSEntry *)(Directory + (num_used_entries + 1) * 64); pEntry->FileName[0] = 0x00; } // Flush Directory to disk fseek(disk, 4096, SEEK_SET); // Seek 4KiB in for directory fwrite(Directory, 4096, 1, disk); // Write 4096 bytes for the Directory // printf("Complete: file %s starts at block %lld, directory entry #%d.\n", filename, new_file_start, first_free_entry); printf("Complete\n"); } else { printf("Error: File already exists.\n"); } } void read(char *filename) { struct BMFSEntry tempentry; FILE *tfile; int tint, slot; if (0 == findfile(filename, &tempentry, &slot)) { printf("Error: File not found in BMFS.\n"); } else { printf("Reading '%s' from BMFS to local file... ", filename); if ((tfile = fopen(tempentry.FileName, "wb")) == NULL) { printf("Error: Could not open local file '%s'\n", tempentry.FileName); } else { fseek(disk, tempentry.StartingBlock*2097152, SEEK_SET); // Skip to the starting block in the disk for (tint=0; tint<tempentry.FileSize; tint++) { putc(getc(disk), tfile); // This is really terrible. // TODO: Rework with fread and fwrite (ideally with a 2MiB buffer) } fclose(tfile); printf("Complete\n"); } } } void write(char *filename) { struct BMFSEntry tempentry; FILE *tfile; int tint, slot; unsigned long long tempfilesize; if (0 == findfile(filename, &tempentry, &slot)) { printf("Error: File not found in BMFS. A file entry must first be created.\n"); } else { printf("Writing local file '%s' to BMFS... ", filename); if ((tfile = fopen(filename, "rb")) == NULL) { printf("Error: Could not open local file '%s'\n", tempentry.FileName); } else { // Is there enough room in BMFS? fseek(tfile, 0, SEEK_END); tempfilesize = ftell(tfile); rewind(tfile); if ((tempentry.ReservedBlocks*2097152) < tempfilesize) { printf("Not enough reserved space in BMFS.\n"); } else { fseek(disk, tempentry.StartingBlock*2097152, SEEK_SET); // Skip to the starting block in the disk for (tint=0; tint<tempfilesize; tint++) { putc(getc(tfile), disk); // This is really terrible. // TODO: Rework with fread and fwrite (ideally with a 2MiB buffer) } // Update directory memcpy(Directory+(slot*64)+48, &tempfilesize, 8); fseek(disk, 4096, SEEK_SET); // Seek 4KiB in for directory fwrite(Directory, 4096, 1, disk); // Write new directory to disk printf("Complete\n"); } fclose(tfile); } } } void delete(char *filename) { struct BMFSEntry tempentry; char delmarker = 0x01; int slot; if (0 == findfile(filename, &tempentry, &slot)) { printf("Error: File not found in BMFS.\n"); } else { printf("Deleting file '%s' from BMFS... ", filename); // Update directory memcpy(Directory+(slot*64), &delmarker, 1); fseek(disk, 4096, SEEK_SET); // Seek 4KiB in for directory fwrite(Directory, 4096, 1, disk); // Write new directory to disk printf("Complete\n"); } } /* EOF */
the_stack_data/40762683.c
#include <sys/types.h> #include <stdint.h> #include <stddef.h> #undef KEY #if defined(__i386) # define KEY '_','_','i','3','8','6' #elif defined(__x86_64) # define KEY '_','_','x','8','6','_','6','4' #elif defined(__ppc__) # define KEY '_','_','p','p','c','_','_' #elif defined(__ppc64__) # define KEY '_','_','p','p','c','6','4','_','_' #endif #define SIZE (sizeof(long)) char info_size[] = {'I', 'N', 'F', 'O', ':', 's','i','z','e','[', ('0' + ((SIZE / 10000)%10)), ('0' + ((SIZE / 1000)%10)), ('0' + ((SIZE / 100)%10)), ('0' + ((SIZE / 10)%10)), ('0' + (SIZE % 10)), ']', #ifdef KEY ' ','k','e','y','[', KEY, ']', #endif '\0'}; #ifdef __CLASSIC_C__ int main(argc, argv) int argc; char *argv[]; #else int main(int argc, char *argv[]) #endif { int require = 0; require += info_size[argc]; (void)argv; return require; }
the_stack_data/23574241.c
/* ** my_isneg.c for my_isneg in /home/RODRIG_1/rendu/Piscine_C_J03 ** ** Made by rodriguez gwendoline ** Login <[email protected]> ** ** Started on Wed Oct 1 13:39:59 2014 rodriguez gwendoline ** Last update Fri Oct 3 09:02:25 2014 rodriguez gwendoline */ int my_isneg(int n) { int positif; int negatif; positif = 80; negatif = 78; if (n >= 0) { my_putchar(positif); } else if (n < 0) { my_putchar(negatif); } }
the_stack_data/170452864.c
#include <stdio.h> #include <stdlib.h> int main() { int sum = 0; for (int i = 0; i < 5; i++) { char c; scanf("%c",&c); // Reading every character of the number one by one sum += (c-48); // Converting the character into number using ascii values and adding it to the final sum } printf("%d",sum); // Displaying the result }
the_stack_data/779980.c
/* * Copyright (C) 2004 by Anders Gavare. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * * $Id: sgiprom_to_bin.c,v 1.2 2004/06/20 15:00:11 debug Exp $ * * sgiprom_to_bin.c * * This program takes a textfile containing a SGI PROM memory dump of * the following format: * * >> dump -b 0xBFC00000:0xBFCF0000 * 0xbfc00000: b f0 0 f0 0 0 0 0 * 0xbfc00008: b f0 1 f6 0 0 0 0 * SAME * 0xbfc00200: b f0 3 c9 0 0 0 0 * 0xbfc00208: b f0 1 f6 0 0 0 0 * SAME * 0xbfc00280: b f0 3 cb 0 0 0 0 * .. * * and turns it into a binary image. Input is read from stdin. */ #include <sys/types.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX 200 int main(int argc, char *argv[]) { FILE *f; unsigned char previous_line[8]; int same_flag = 0; off_t same_start_offset = 0; if (argc < 2) { fprintf(stderr, "usage: %s output_filename\n", argv[0]); fprintf(stderr, "input is read from stdin\n"); exit(1); } f = fopen(argv[1], "w"); while (!feof(stdin)) { char s[MAX]; s[0] = 0; fgets(s, sizeof(s), stdin); while (s[0] == '\r') { memcpy(s, s+1, sizeof(s)-1); s[MAX-1] = '\0'; } /* 0xbfc00460: 24 5 0 10 0 5 28 c2 */ if (s[0] == '0' && s[10]==':') { unsigned long x; int i; x = strtol(s, NULL, 0); if (x < 0xbfc00000) { printf("x = 0x%08lx, less than 0xbfc00000. aborting\n", (long)x); exit(1); } x -= 0xbfc00000; if (same_flag) { /* * We should fill from same_start_offset to just before x, * using previous_line data. */ off_t ofs; printf("same_flag set, filling until just before 0x%08lx\n", (long)x); fseek(f, same_start_offset, SEEK_SET); for (ofs = same_start_offset; ofs < x; ofs += 8) { fwrite(previous_line, 1, sizeof(previous_line), f); } same_flag = 0; } printf("x = 0x%08lx\n", (long)x); fseek(f, x, SEEK_SET); for (i=0; i<strlen(s); i++) if (s[i]==' ') s[i]='0'; for (i=0; i<8; i++) { int ofs = i*5 + 14; int d1, d2; d1 = s[ofs]; d2 = s[ofs+1]; if (d1 >= '0' && d1<='9') d1 -= '0'; else d1 = d1 - 'a' + 10; if (d2 >= '0' && d2<='9') d2 -= '0'; else d2 = d2 - 'a' + 10; d1 = d1*16 + d2; printf(" %02x", d1); fprintf(f, "%c", d1); previous_line[i] = d1; } printf("\n"); } /* "SAME": */ if (s[0] == 'S' && s[1] == 'A') { /* * This should produce "same" output until the * next normal "0xbfc.." line. */ same_flag = 1; same_start_offset = ftell(f); } } fclose(f); return 0; }
the_stack_data/212643366.c
//--Make sure we can run DSA on it! //RUN: clang %s -c -emit-llvm -o - | \ //RUN: dsaopt -dsa-bu -dsa-td -disable-output #include <stdlib.h> struct StructType1 { int a1; int b1; int c1; }; struct StructType2 { int a2; short b2; int c2; }; union UnionType { struct StructType1 s1; struct StructType2 s2; }; void func() { union UnionType obj; obj.s1.a1 = 2l; obj.s1.b1 = 33; obj.s1.c1 = 22; struct StructType2 s = obj.s2; int t = obj.s2.c2; int t1 = obj.s1.c1; }
the_stack_data/150143361.c
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdarg.h> void printf_ex( const char* file, const char* func, const char* format, ...); #if DEBUG #define PRINT(...) printf_ex( __FILE__, __func__, __VA_ARGS__); #else #define PRINT(...) #endif #define ASCII_LF (0x0a) #define MAX_LINE (10) int main(int argc, char **argv) { int ret = 0; #ifdef STDIN_IS_FILE int i = 0; char line[MAX_LINE][1024] = {0x00}; #endif PRINT("start\n"); #ifdef STDIN_IS_FILE while( MAX_LINE>i && fgets(line[i], sizeof(line[i]),stdin) ){ PRINT("%s\n", line[i]); if( line[i][0]==ASCII_LF ){ PRINT("%s break fgets\n",__func__); break; } PRINT("%s %c %c %c\n", __func__, line[i][0],line[i][1],line[i][2]); i++; } #else if(3>=argc){ PRINT("invalid parameter\n"); goto exit; } PRINT( "%s %s %s\n", argv[1], argv[2], argv[3] ); #endif PRINT("result=%d\n",3); exit: PRINT("end\n"); return ret; } void printf_ex( const char* file, const char* func, const char* format, ...){ va_list arg; printf("[%s][%s]:", file, func); va_start(arg, format); vprintf( format, arg ); va_end(arg); }
the_stack_data/154827813.c
#include <math.h> #include <stdlib.h> #include <string.h> #include <stdio.h> #include <complex.h> #ifdef complex #undef complex #endif #ifdef I #undef I #endif #if defined(_WIN64) typedef long long BLASLONG; typedef unsigned long long BLASULONG; #else typedef long BLASLONG; typedef unsigned long BLASULONG; #endif #ifdef LAPACK_ILP64 typedef BLASLONG blasint; #if defined(_WIN64) #define blasabs(x) llabs(x) #else #define blasabs(x) labs(x) #endif #else typedef int blasint; #define blasabs(x) abs(x) #endif typedef blasint integer; typedef unsigned int uinteger; typedef char *address; typedef short int shortint; typedef float real; typedef double doublereal; typedef struct { real r, i; } complex; typedef struct { doublereal r, i; } doublecomplex; #ifdef _MSC_VER static inline _Fcomplex Cf(complex *z) {_Fcomplex zz={z->r , z->i}; return zz;} static inline _Dcomplex Cd(doublecomplex *z) {_Dcomplex zz={z->r , z->i};return zz;} static inline _Fcomplex * _pCf(complex *z) {return (_Fcomplex*)z;} static inline _Dcomplex * _pCd(doublecomplex *z) {return (_Dcomplex*)z;} #else static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} #endif #define pCf(z) (*_pCf(z)) #define pCd(z) (*_pCd(z)) typedef int logical; typedef short int shortlogical; typedef char logical1; typedef char integer1; #define TRUE_ (1) #define FALSE_ (0) /* Extern is for use with -E */ #ifndef Extern #define Extern extern #endif /* I/O stuff */ typedef int flag; typedef int ftnlen; typedef int ftnint; /*external read, write*/ typedef struct { flag cierr; ftnint ciunit; flag ciend; char *cifmt; ftnint cirec; } cilist; /*internal read, write*/ typedef struct { flag icierr; char *iciunit; flag iciend; char *icifmt; ftnint icirlen; ftnint icirnum; } icilist; /*open*/ typedef struct { flag oerr; ftnint ounit; char *ofnm; ftnlen ofnmlen; char *osta; char *oacc; char *ofm; ftnint orl; char *oblnk; } olist; /*close*/ typedef struct { flag cerr; ftnint cunit; char *csta; } cllist; /*rewind, backspace, endfile*/ typedef struct { flag aerr; ftnint aunit; } alist; /* inquire */ typedef struct { flag inerr; ftnint inunit; char *infile; ftnlen infilen; ftnint *inex; /*parameters in standard's order*/ ftnint *inopen; ftnint *innum; ftnint *innamed; char *inname; ftnlen innamlen; char *inacc; ftnlen inacclen; char *inseq; ftnlen inseqlen; char *indir; ftnlen indirlen; char *infmt; ftnlen infmtlen; char *inform; ftnint informlen; char *inunf; ftnlen inunflen; ftnint *inrecl; ftnint *innrec; char *inblank; ftnlen inblanklen; } inlist; #define VOID void union Multitype { /* for multiple entry points */ integer1 g; shortint h; integer i; /* longint j; */ real r; doublereal d; complex c; doublecomplex z; }; typedef union Multitype Multitype; struct Vardesc { /* for Namelist */ char *name; char *addr; ftnlen *dims; int type; }; typedef struct Vardesc Vardesc; struct Namelist { char *name; Vardesc **vars; int nvars; }; typedef struct Namelist Namelist; #define abs(x) ((x) >= 0 ? (x) : -(x)) #define dabs(x) (fabs(x)) #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) #define dmin(a,b) (f2cmin(a,b)) #define dmax(a,b) (f2cmax(a,b)) #define bit_test(a,b) ((a) >> (b) & 1) #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) #define abort_() { sig_die("Fortran abort routine called", 1); } #define c_abs(z) (cabsf(Cf(z))) #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } #ifdef _MSC_VER #define c_div(c, a, b) {Cf(c)._Val[0] = (Cf(a)._Val[0]/Cf(b)._Val[0]); Cf(c)._Val[1]=(Cf(a)._Val[1]/Cf(b)._Val[1]);} #define z_div(c, a, b) {Cd(c)._Val[0] = (Cd(a)._Val[0]/Cd(b)._Val[0]); Cd(c)._Val[1]=(Cd(a)._Val[1]/df(b)._Val[1]);} #else #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} #endif #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} #define d_abs(x) (fabs(*(x))) #define d_acos(x) (acos(*(x))) #define d_asin(x) (asin(*(x))) #define d_atan(x) (atan(*(x))) #define d_atn2(x, y) (atan2(*(x),*(y))) #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } #define r_cnjg(R, Z) { pCf(R) = conjf(Cf(Z)); } #define d_cos(x) (cos(*(x))) #define d_cosh(x) (cosh(*(x))) #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) #define d_exp(x) (exp(*(x))) #define d_imag(z) (cimag(Cd(z))) #define r_imag(z) (cimagf(Cf(z))) #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) #define d_log(x) (log(*(x))) #define d_mod(x, y) (fmod(*(x), *(y))) #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) #define d_nint(x) u_nint(*(x)) #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) #define d_sign(a,b) u_sign(*(a),*(b)) #define r_sign(a,b) u_sign(*(a),*(b)) #define d_sin(x) (sin(*(x))) #define d_sinh(x) (sinh(*(x))) #define d_sqrt(x) (sqrt(*(x))) #define d_tan(x) (tan(*(x))) #define d_tanh(x) (tanh(*(x))) #define i_abs(x) abs(*(x)) #define i_dnnt(x) ((integer)u_nint(*(x))) #define i_len(s, n) (n) #define i_nint(x) ((integer)u_nint(*(x))) #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) #define pow_si(B,E) spow_ui(*(B),*(E)) #define pow_ri(B,E) spow_ui(*(B),*(E)) #define pow_di(B,E) dpow_ui(*(B),*(E)) #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } #define sig_die(s, kill) { exit(1); } #define s_stop(s, n) {exit(0);} static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; #define z_abs(z) (cabs(Cd(z))) #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} #define myexit_() break; #define mycycle() continue; #define myceiling(w) {ceil(w)} #define myhuge(w) {HUGE_VAL} //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} /* procedure parameter types for -A and -C++ */ #define F2C_proc_par_types 1 #ifdef __cplusplus typedef logical (*L_fp)(...); #else typedef logical (*L_fp)(); #endif static float spow_ui(float x, integer n) { float pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } static double dpow_ui(double x, integer n) { double pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } #ifdef _MSC_VER static _Fcomplex cpow_ui(complex x, integer n) { complex pow={1.0,0.0}; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x.r = 1/x.r, x.i=1/x.i; for(u = n; ; ) { if(u & 01) pow.r *= x.r, pow.i *= x.i; if(u >>= 1) x.r *= x.r, x.i *= x.i; else break; } } _Fcomplex p={pow.r, pow.i}; return p; } #else static _Complex float cpow_ui(_Complex float x, integer n) { _Complex float pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } #endif #ifdef _MSC_VER static _Dcomplex zpow_ui(_Dcomplex x, integer n) { _Dcomplex pow={1.0,0.0}; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x._Val[0] = 1/x._Val[0], x._Val[1] =1/x._Val[1]; for(u = n; ; ) { if(u & 01) pow._Val[0] *= x._Val[0], pow._Val[1] *= x._Val[1]; if(u >>= 1) x._Val[0] *= x._Val[0], x._Val[1] *= x._Val[1]; else break; } } _Dcomplex p = {pow._Val[0], pow._Val[1]}; return p; } #else static _Complex double zpow_ui(_Complex double x, integer n) { _Complex double pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } #endif static integer pow_ii(integer x, integer n) { integer pow; unsigned long int u; if (n <= 0) { if (n == 0 || x == 1) pow = 1; else if (x != -1) pow = x == 0 ? 1/x : 0; else n = -n; } if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { u = n; for(pow = 1; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } static integer dmaxloc_(double *w, integer s, integer e, integer *n) { double m; integer i, mi; for(m=w[s-1], mi=s, i=s+1; i<=e; i++) if (w[i-1]>m) mi=i ,m=w[i-1]; return mi-s+1; } static integer smaxloc_(float *w, integer s, integer e, integer *n) { float m; integer i, mi; for(m=w[s-1], mi=s, i=s+1; i<=e; i++) if (w[i-1]>m) mi=i ,m=w[i-1]; return mi-s+1; } static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; #ifdef _MSC_VER _Fcomplex zdotc = {0.0, 0.0}; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += conjf(Cf(&x[i]))._Val[0] * Cf(&y[i])._Val[0]; zdotc._Val[1] += conjf(Cf(&x[i]))._Val[1] * Cf(&y[i])._Val[1]; } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += conjf(Cf(&x[i*incx]))._Val[0] * Cf(&y[i*incy])._Val[0]; zdotc._Val[1] += conjf(Cf(&x[i*incx]))._Val[1] * Cf(&y[i*incy])._Val[1]; } } pCf(z) = zdotc; } #else _Complex float zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); } } pCf(z) = zdotc; } #endif static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; #ifdef _MSC_VER _Dcomplex zdotc = {0.0, 0.0}; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += conj(Cd(&x[i]))._Val[0] * Cd(&y[i])._Val[0]; zdotc._Val[1] += conj(Cd(&x[i]))._Val[1] * Cd(&y[i])._Val[1]; } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += conj(Cd(&x[i*incx]))._Val[0] * Cd(&y[i*incy])._Val[0]; zdotc._Val[1] += conj(Cd(&x[i*incx]))._Val[1] * Cd(&y[i*incy])._Val[1]; } } pCd(z) = zdotc; } #else _Complex double zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conj(Cd(&x[i])) * Cd(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); } } pCd(z) = zdotc; } #endif static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; #ifdef _MSC_VER _Fcomplex zdotc = {0.0, 0.0}; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += Cf(&x[i])._Val[0] * Cf(&y[i])._Val[0]; zdotc._Val[1] += Cf(&x[i])._Val[1] * Cf(&y[i])._Val[1]; } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += Cf(&x[i*incx])._Val[0] * Cf(&y[i*incy])._Val[0]; zdotc._Val[1] += Cf(&x[i*incx])._Val[1] * Cf(&y[i*incy])._Val[1]; } } pCf(z) = zdotc; } #else _Complex float zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cf(&x[i]) * Cf(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); } } pCf(z) = zdotc; } #endif static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; #ifdef _MSC_VER _Dcomplex zdotc = {0.0, 0.0}; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += Cd(&x[i])._Val[0] * Cd(&y[i])._Val[0]; zdotc._Val[1] += Cd(&x[i])._Val[1] * Cd(&y[i])._Val[1]; } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += Cd(&x[i*incx])._Val[0] * Cd(&y[i*incy])._Val[0]; zdotc._Val[1] += Cd(&x[i*incx])._Val[1] * Cd(&y[i*incy])._Val[1]; } } pCd(z) = zdotc; } #else _Complex double zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cd(&x[i]) * Cd(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); } } pCd(z) = zdotc; } #endif /* -- translated by f2c (version 20000121). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ /* Table of constant values */ static integer c__1 = 1; static integer c_n1 = -1; /* > \brief \b SORGTR */ /* =========== DOCUMENTATION =========== */ /* Online html documentation available at */ /* http://www.netlib.org/lapack/explore-html/ */ /* > \htmlonly */ /* > Download SORGTR + dependencies */ /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sorgtr. f"> */ /* > [TGZ]</a> */ /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sorgtr. f"> */ /* > [ZIP]</a> */ /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sorgtr. f"> */ /* > [TXT]</a> */ /* > \endhtmlonly */ /* Definition: */ /* =========== */ /* SUBROUTINE SORGTR( UPLO, N, A, LDA, TAU, WORK, LWORK, INFO ) */ /* CHARACTER UPLO */ /* INTEGER INFO, LDA, LWORK, N */ /* REAL A( LDA, * ), TAU( * ), WORK( * ) */ /* > \par Purpose: */ /* ============= */ /* > */ /* > \verbatim */ /* > */ /* > SORGTR generates a real orthogonal matrix Q which is defined as the */ /* > product of n-1 elementary reflectors of order N, as returned by */ /* > SSYTRD: */ /* > */ /* > if UPLO = 'U', Q = H(n-1) . . . H(2) H(1), */ /* > */ /* > if UPLO = 'L', Q = H(1) H(2) . . . H(n-1). */ /* > \endverbatim */ /* Arguments: */ /* ========== */ /* > \param[in] UPLO */ /* > \verbatim */ /* > UPLO is CHARACTER*1 */ /* > = 'U': Upper triangle of A contains elementary reflectors */ /* > from SSYTRD; */ /* > = 'L': Lower triangle of A contains elementary reflectors */ /* > from SSYTRD. */ /* > \endverbatim */ /* > */ /* > \param[in] N */ /* > \verbatim */ /* > N is INTEGER */ /* > The order of the matrix Q. N >= 0. */ /* > \endverbatim */ /* > */ /* > \param[in,out] A */ /* > \verbatim */ /* > A is REAL array, dimension (LDA,N) */ /* > On entry, the vectors which define the elementary reflectors, */ /* > as returned by SSYTRD. */ /* > On exit, the N-by-N orthogonal matrix Q. */ /* > \endverbatim */ /* > */ /* > \param[in] LDA */ /* > \verbatim */ /* > LDA is INTEGER */ /* > The leading dimension of the array A. LDA >= f2cmax(1,N). */ /* > \endverbatim */ /* > */ /* > \param[in] TAU */ /* > \verbatim */ /* > TAU is REAL array, dimension (N-1) */ /* > TAU(i) must contain the scalar factor of the elementary */ /* > reflector H(i), as returned by SSYTRD. */ /* > \endverbatim */ /* > */ /* > \param[out] WORK */ /* > \verbatim */ /* > WORK is REAL array, dimension (MAX(1,LWORK)) */ /* > On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ /* > \endverbatim */ /* > */ /* > \param[in] LWORK */ /* > \verbatim */ /* > LWORK is INTEGER */ /* > The dimension of the array WORK. LWORK >= f2cmax(1,N-1). */ /* > For optimum performance LWORK >= (N-1)*NB, where NB is */ /* > the optimal blocksize. */ /* > */ /* > If LWORK = -1, then a workspace query is assumed; the routine */ /* > only calculates the optimal size of the WORK array, returns */ /* > this value as the first entry of the WORK array, and no error */ /* > message related to LWORK is issued by XERBLA. */ /* > \endverbatim */ /* > */ /* > \param[out] INFO */ /* > \verbatim */ /* > INFO is INTEGER */ /* > = 0: successful exit */ /* > < 0: if INFO = -i, the i-th argument had an illegal value */ /* > \endverbatim */ /* Authors: */ /* ======== */ /* > \author Univ. of Tennessee */ /* > \author Univ. of California Berkeley */ /* > \author Univ. of Colorado Denver */ /* > \author NAG Ltd. */ /* > \date December 2016 */ /* > \ingroup realOTHERcomputational */ /* ===================================================================== */ /* Subroutine */ int sorgtr_(char *uplo, integer *n, real *a, integer *lda, real *tau, real *work, integer *lwork, integer *info) { /* System generated locals */ integer a_dim1, a_offset, i__1, i__2, i__3; /* Local variables */ integer i__, j; extern logical lsame_(char *, char *); integer iinfo; logical upper; integer nb; extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen); extern integer ilaenv_(integer *, char *, char *, integer *, integer *, integer *, integer *, ftnlen, ftnlen); extern /* Subroutine */ int sorgql_(integer *, integer *, integer *, real *, integer *, real *, real *, integer *, integer *), sorgqr_( integer *, integer *, integer *, real *, integer *, real *, real * , integer *, integer *); logical lquery; integer lwkopt; /* -- LAPACK computational routine (version 3.7.0) -- */ /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ /* December 2016 */ /* ===================================================================== */ /* Test the input arguments */ /* Parameter adjustments */ a_dim1 = *lda; a_offset = 1 + a_dim1 * 1; a -= a_offset; --tau; --work; /* Function Body */ *info = 0; lquery = *lwork == -1; upper = lsame_(uplo, "U"); if (! upper && ! lsame_(uplo, "L")) { *info = -1; } else if (*n < 0) { *info = -2; } else if (*lda < f2cmax(1,*n)) { *info = -4; } else /* if(complicated condition) */ { /* Computing MAX */ i__1 = 1, i__2 = *n - 1; if (*lwork < f2cmax(i__1,i__2) && ! lquery) { *info = -7; } } if (*info == 0) { if (upper) { i__1 = *n - 1; i__2 = *n - 1; i__3 = *n - 1; nb = ilaenv_(&c__1, "SORGQL", " ", &i__1, &i__2, &i__3, &c_n1, ( ftnlen)6, (ftnlen)1); } else { i__1 = *n - 1; i__2 = *n - 1; i__3 = *n - 1; nb = ilaenv_(&c__1, "SORGQR", " ", &i__1, &i__2, &i__3, &c_n1, ( ftnlen)6, (ftnlen)1); } /* Computing MAX */ i__1 = 1, i__2 = *n - 1; lwkopt = f2cmax(i__1,i__2) * nb; work[1] = (real) lwkopt; } if (*info != 0) { i__1 = -(*info); xerbla_("SORGTR", &i__1, (ftnlen)6); return 0; } else if (lquery) { return 0; } /* Quick return if possible */ if (*n == 0) { work[1] = 1.f; return 0; } if (upper) { /* Q was determined by a call to SSYTRD with UPLO = 'U' */ /* Shift the vectors which define the elementary reflectors one */ /* column to the left, and set the last row and column of Q to */ /* those of the unit matrix */ i__1 = *n - 1; for (j = 1; j <= i__1; ++j) { i__2 = j - 1; for (i__ = 1; i__ <= i__2; ++i__) { a[i__ + j * a_dim1] = a[i__ + (j + 1) * a_dim1]; /* L10: */ } a[*n + j * a_dim1] = 0.f; /* L20: */ } i__1 = *n - 1; for (i__ = 1; i__ <= i__1; ++i__) { a[i__ + *n * a_dim1] = 0.f; /* L30: */ } a[*n + *n * a_dim1] = 1.f; /* Generate Q(1:n-1,1:n-1) */ i__1 = *n - 1; i__2 = *n - 1; i__3 = *n - 1; sorgql_(&i__1, &i__2, &i__3, &a[a_offset], lda, &tau[1], &work[1], lwork, &iinfo); } else { /* Q was determined by a call to SSYTRD with UPLO = 'L'. */ /* Shift the vectors which define the elementary reflectors one */ /* column to the right, and set the first row and column of Q to */ /* those of the unit matrix */ for (j = *n; j >= 2; --j) { a[j * a_dim1 + 1] = 0.f; i__1 = *n; for (i__ = j + 1; i__ <= i__1; ++i__) { a[i__ + j * a_dim1] = a[i__ + (j - 1) * a_dim1]; /* L40: */ } /* L50: */ } a[a_dim1 + 1] = 1.f; i__1 = *n; for (i__ = 2; i__ <= i__1; ++i__) { a[i__ + a_dim1] = 0.f; /* L60: */ } if (*n > 1) { /* Generate Q(2:n,2:n) */ i__1 = *n - 1; i__2 = *n - 1; i__3 = *n - 1; sorgqr_(&i__1, &i__2, &i__3, &a[(a_dim1 << 1) + 2], lda, &tau[1], &work[1], lwork, &iinfo); } } work[1] = (real) lwkopt; return 0; /* End of SORGTR */ } /* sorgtr_ */
the_stack_data/116734.c
//Do Not Use This !!! #include <stdio.h> int main() { int a; scanf_s("%d", &a); if (a <= 15) { printf("%d", a - 1); } else { printf("%d", -1); } }
the_stack_data/131072.c
typedef int fun(); volatile fun f; int main(void){ }
the_stack_data/909946.c
#include <math.h> #include <stdlib.h> #include <string.h> #include <stdio.h> #include <complex.h> #ifdef complex #undef complex #endif #ifdef I #undef I #endif #if defined(_WIN64) typedef long long BLASLONG; typedef unsigned long long BLASULONG; #else typedef long BLASLONG; typedef unsigned long BLASULONG; #endif #ifdef LAPACK_ILP64 typedef BLASLONG blasint; #if defined(_WIN64) #define blasabs(x) llabs(x) #else #define blasabs(x) labs(x) #endif #else typedef int blasint; #define blasabs(x) abs(x) #endif typedef blasint integer; typedef unsigned int uinteger; typedef char *address; typedef short int shortint; typedef float real; typedef double doublereal; typedef struct { real r, i; } complex; typedef struct { doublereal r, i; } doublecomplex; #ifdef _MSC_VER static inline _Fcomplex Cf(complex *z) {_Fcomplex zz={z->r , z->i}; return zz;} static inline _Dcomplex Cd(doublecomplex *z) {_Dcomplex zz={z->r , z->i};return zz;} static inline _Fcomplex * _pCf(complex *z) {return (_Fcomplex*)z;} static inline _Dcomplex * _pCd(doublecomplex *z) {return (_Dcomplex*)z;} #else static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} #endif #define pCf(z) (*_pCf(z)) #define pCd(z) (*_pCd(z)) typedef int logical; typedef short int shortlogical; typedef char logical1; typedef char integer1; #define TRUE_ (1) #define FALSE_ (0) /* Extern is for use with -E */ #ifndef Extern #define Extern extern #endif /* I/O stuff */ typedef int flag; typedef int ftnlen; typedef int ftnint; /*external read, write*/ typedef struct { flag cierr; ftnint ciunit; flag ciend; char *cifmt; ftnint cirec; } cilist; /*internal read, write*/ typedef struct { flag icierr; char *iciunit; flag iciend; char *icifmt; ftnint icirlen; ftnint icirnum; } icilist; /*open*/ typedef struct { flag oerr; ftnint ounit; char *ofnm; ftnlen ofnmlen; char *osta; char *oacc; char *ofm; ftnint orl; char *oblnk; } olist; /*close*/ typedef struct { flag cerr; ftnint cunit; char *csta; } cllist; /*rewind, backspace, endfile*/ typedef struct { flag aerr; ftnint aunit; } alist; /* inquire */ typedef struct { flag inerr; ftnint inunit; char *infile; ftnlen infilen; ftnint *inex; /*parameters in standard's order*/ ftnint *inopen; ftnint *innum; ftnint *innamed; char *inname; ftnlen innamlen; char *inacc; ftnlen inacclen; char *inseq; ftnlen inseqlen; char *indir; ftnlen indirlen; char *infmt; ftnlen infmtlen; char *inform; ftnint informlen; char *inunf; ftnlen inunflen; ftnint *inrecl; ftnint *innrec; char *inblank; ftnlen inblanklen; } inlist; #define VOID void union Multitype { /* for multiple entry points */ integer1 g; shortint h; integer i; /* longint j; */ real r; doublereal d; complex c; doublecomplex z; }; typedef union Multitype Multitype; struct Vardesc { /* for Namelist */ char *name; char *addr; ftnlen *dims; int type; }; typedef struct Vardesc Vardesc; struct Namelist { char *name; Vardesc **vars; int nvars; }; typedef struct Namelist Namelist; #define abs(x) ((x) >= 0 ? (x) : -(x)) #define dabs(x) (fabs(x)) #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) #define dmin(a,b) (f2cmin(a,b)) #define dmax(a,b) (f2cmax(a,b)) #define bit_test(a,b) ((a) >> (b) & 1) #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) #define abort_() { sig_die("Fortran abort routine called", 1); } #define c_abs(z) (cabsf(Cf(z))) #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } #ifdef _MSC_VER #define c_div(c, a, b) {Cf(c)._Val[0] = (Cf(a)._Val[0]/Cf(b)._Val[0]); Cf(c)._Val[1]=(Cf(a)._Val[1]/Cf(b)._Val[1]);} #define z_div(c, a, b) {Cd(c)._Val[0] = (Cd(a)._Val[0]/Cd(b)._Val[0]); Cd(c)._Val[1]=(Cd(a)._Val[1]/df(b)._Val[1]);} #else #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} #endif #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} #define d_abs(x) (fabs(*(x))) #define d_acos(x) (acos(*(x))) #define d_asin(x) (asin(*(x))) #define d_atan(x) (atan(*(x))) #define d_atn2(x, y) (atan2(*(x),*(y))) #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } #define r_cnjg(R, Z) { pCf(R) = conjf(Cf(Z)); } #define d_cos(x) (cos(*(x))) #define d_cosh(x) (cosh(*(x))) #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) #define d_exp(x) (exp(*(x))) #define d_imag(z) (cimag(Cd(z))) #define r_imag(z) (cimagf(Cf(z))) #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) #define d_log(x) (log(*(x))) #define d_mod(x, y) (fmod(*(x), *(y))) #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) #define d_nint(x) u_nint(*(x)) #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) #define d_sign(a,b) u_sign(*(a),*(b)) #define r_sign(a,b) u_sign(*(a),*(b)) #define d_sin(x) (sin(*(x))) #define d_sinh(x) (sinh(*(x))) #define d_sqrt(x) (sqrt(*(x))) #define d_tan(x) (tan(*(x))) #define d_tanh(x) (tanh(*(x))) #define i_abs(x) abs(*(x)) #define i_dnnt(x) ((integer)u_nint(*(x))) #define i_len(s, n) (n) #define i_nint(x) ((integer)u_nint(*(x))) #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) #define pow_si(B,E) spow_ui(*(B),*(E)) #define pow_ri(B,E) spow_ui(*(B),*(E)) #define pow_di(B,E) dpow_ui(*(B),*(E)) #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } #define sig_die(s, kill) { exit(1); } #define s_stop(s, n) {exit(0);} static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; #define z_abs(z) (cabs(Cd(z))) #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} #define myexit_() break; #define mycycle() continue; #define myceiling(w) {ceil(w)} #define myhuge(w) {HUGE_VAL} //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} /* procedure parameter types for -A and -C++ */ #define F2C_proc_par_types 1 #ifdef __cplusplus typedef logical (*L_fp)(...); #else typedef logical (*L_fp)(); #endif static float spow_ui(float x, integer n) { float pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } static double dpow_ui(double x, integer n) { double pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } #ifdef _MSC_VER static _Fcomplex cpow_ui(complex x, integer n) { complex pow={1.0,0.0}; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x.r = 1/x.r, x.i=1/x.i; for(u = n; ; ) { if(u & 01) pow.r *= x.r, pow.i *= x.i; if(u >>= 1) x.r *= x.r, x.i *= x.i; else break; } } _Fcomplex p={pow.r, pow.i}; return p; } #else static _Complex float cpow_ui(_Complex float x, integer n) { _Complex float pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } #endif #ifdef _MSC_VER static _Dcomplex zpow_ui(_Dcomplex x, integer n) { _Dcomplex pow={1.0,0.0}; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x._Val[0] = 1/x._Val[0], x._Val[1] =1/x._Val[1]; for(u = n; ; ) { if(u & 01) pow._Val[0] *= x._Val[0], pow._Val[1] *= x._Val[1]; if(u >>= 1) x._Val[0] *= x._Val[0], x._Val[1] *= x._Val[1]; else break; } } _Dcomplex p = {pow._Val[0], pow._Val[1]}; return p; } #else static _Complex double zpow_ui(_Complex double x, integer n) { _Complex double pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } #endif static integer pow_ii(integer x, integer n) { integer pow; unsigned long int u; if (n <= 0) { if (n == 0 || x == 1) pow = 1; else if (x != -1) pow = x == 0 ? 1/x : 0; else n = -n; } if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { u = n; for(pow = 1; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } static integer dmaxloc_(double *w, integer s, integer e, integer *n) { double m; integer i, mi; for(m=w[s-1], mi=s, i=s+1; i<=e; i++) if (w[i-1]>m) mi=i ,m=w[i-1]; return mi-s+1; } static integer smaxloc_(float *w, integer s, integer e, integer *n) { float m; integer i, mi; for(m=w[s-1], mi=s, i=s+1; i<=e; i++) if (w[i-1]>m) mi=i ,m=w[i-1]; return mi-s+1; } static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; #ifdef _MSC_VER _Fcomplex zdotc = {0.0, 0.0}; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += conjf(Cf(&x[i]))._Val[0] * Cf(&y[i])._Val[0]; zdotc._Val[1] += conjf(Cf(&x[i]))._Val[1] * Cf(&y[i])._Val[1]; } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += conjf(Cf(&x[i*incx]))._Val[0] * Cf(&y[i*incy])._Val[0]; zdotc._Val[1] += conjf(Cf(&x[i*incx]))._Val[1] * Cf(&y[i*incy])._Val[1]; } } pCf(z) = zdotc; } #else _Complex float zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); } } pCf(z) = zdotc; } #endif static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; #ifdef _MSC_VER _Dcomplex zdotc = {0.0, 0.0}; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += conj(Cd(&x[i]))._Val[0] * Cd(&y[i])._Val[0]; zdotc._Val[1] += conj(Cd(&x[i]))._Val[1] * Cd(&y[i])._Val[1]; } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += conj(Cd(&x[i*incx]))._Val[0] * Cd(&y[i*incy])._Val[0]; zdotc._Val[1] += conj(Cd(&x[i*incx]))._Val[1] * Cd(&y[i*incy])._Val[1]; } } pCd(z) = zdotc; } #else _Complex double zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conj(Cd(&x[i])) * Cd(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); } } pCd(z) = zdotc; } #endif static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; #ifdef _MSC_VER _Fcomplex zdotc = {0.0, 0.0}; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += Cf(&x[i])._Val[0] * Cf(&y[i])._Val[0]; zdotc._Val[1] += Cf(&x[i])._Val[1] * Cf(&y[i])._Val[1]; } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += Cf(&x[i*incx])._Val[0] * Cf(&y[i*incy])._Val[0]; zdotc._Val[1] += Cf(&x[i*incx])._Val[1] * Cf(&y[i*incy])._Val[1]; } } pCf(z) = zdotc; } #else _Complex float zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cf(&x[i]) * Cf(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); } } pCf(z) = zdotc; } #endif static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; #ifdef _MSC_VER _Dcomplex zdotc = {0.0, 0.0}; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += Cd(&x[i])._Val[0] * Cd(&y[i])._Val[0]; zdotc._Val[1] += Cd(&x[i])._Val[1] * Cd(&y[i])._Val[1]; } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += Cd(&x[i*incx])._Val[0] * Cd(&y[i*incy])._Val[0]; zdotc._Val[1] += Cd(&x[i*incx])._Val[1] * Cd(&y[i*incy])._Val[1]; } } pCd(z) = zdotc; } #else _Complex double zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cd(&x[i]) * Cd(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); } } pCd(z) = zdotc; } #endif /* -- translated by f2c (version 20000121). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ /* Table of constant values */ static integer c__1 = 1; static integer c_n1 = -1; static real c_b23 = 1.f; static real c_b37 = -1.f; /* > \brief \b SLATDF uses the LU factorization of the n-by-n matrix computed by sgetc2 and computes a contrib ution to the reciprocal Dif-estimate. */ /* =========== DOCUMENTATION =========== */ /* Online html documentation available at */ /* http://www.netlib.org/lapack/explore-html/ */ /* > \htmlonly */ /* > Download SLATDF + dependencies */ /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/slatdf. f"> */ /* > [TGZ]</a> */ /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/slatdf. f"> */ /* > [ZIP]</a> */ /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/slatdf. f"> */ /* > [TXT]</a> */ /* > \endhtmlonly */ /* Definition: */ /* =========== */ /* SUBROUTINE SLATDF( IJOB, N, Z, LDZ, RHS, RDSUM, RDSCAL, IPIV, */ /* JPIV ) */ /* INTEGER IJOB, LDZ, N */ /* REAL RDSCAL, RDSUM */ /* INTEGER IPIV( * ), JPIV( * ) */ /* REAL RHS( * ), Z( LDZ, * ) */ /* > \par Purpose: */ /* ============= */ /* > */ /* > \verbatim */ /* > */ /* > SLATDF uses the LU factorization of the n-by-n matrix Z computed by */ /* > SGETC2 and computes a contribution to the reciprocal Dif-estimate */ /* > by solving Z * x = b for x, and choosing the r.h.s. b such that */ /* > the norm of x is as large as possible. On entry RHS = b holds the */ /* > contribution from earlier solved sub-systems, and on return RHS = x. */ /* > */ /* > The factorization of Z returned by SGETC2 has the form Z = P*L*U*Q, */ /* > where P and Q are permutation matrices. L is lower triangular with */ /* > unit diagonal elements and U is upper triangular. */ /* > \endverbatim */ /* Arguments: */ /* ========== */ /* > \param[in] IJOB */ /* > \verbatim */ /* > IJOB is INTEGER */ /* > IJOB = 2: First compute an approximative null-vector e */ /* > of Z using SGECON, e is normalized and solve for */ /* > Zx = +-e - f with the sign giving the greater value */ /* > of 2-norm(x). About 5 times as expensive as Default. */ /* > IJOB .ne. 2: Local look ahead strategy where all entries of */ /* > the r.h.s. b is chosen as either +1 or -1 (Default). */ /* > \endverbatim */ /* > */ /* > \param[in] N */ /* > \verbatim */ /* > N is INTEGER */ /* > The number of columns of the matrix Z. */ /* > \endverbatim */ /* > */ /* > \param[in] Z */ /* > \verbatim */ /* > Z is REAL array, dimension (LDZ, N) */ /* > On entry, the LU part of the factorization of the n-by-n */ /* > matrix Z computed by SGETC2: Z = P * L * U * Q */ /* > \endverbatim */ /* > */ /* > \param[in] LDZ */ /* > \verbatim */ /* > LDZ is INTEGER */ /* > The leading dimension of the array Z. LDA >= f2cmax(1, N). */ /* > \endverbatim */ /* > */ /* > \param[in,out] RHS */ /* > \verbatim */ /* > RHS is REAL array, dimension N. */ /* > On entry, RHS contains contributions from other subsystems. */ /* > On exit, RHS contains the solution of the subsystem with */ /* > entries according to the value of IJOB (see above). */ /* > \endverbatim */ /* > */ /* > \param[in,out] RDSUM */ /* > \verbatim */ /* > RDSUM is REAL */ /* > On entry, the sum of squares of computed contributions to */ /* > the Dif-estimate under computation by STGSYL, where the */ /* > scaling factor RDSCAL (see below) has been factored out. */ /* > On exit, the corresponding sum of squares updated with the */ /* > contributions from the current sub-system. */ /* > If TRANS = 'T' RDSUM is not touched. */ /* > NOTE: RDSUM only makes sense when STGSY2 is called by STGSYL. */ /* > \endverbatim */ /* > */ /* > \param[in,out] RDSCAL */ /* > \verbatim */ /* > RDSCAL is REAL */ /* > On entry, scaling factor used to prevent overflow in RDSUM. */ /* > On exit, RDSCAL is updated w.r.t. the current contributions */ /* > in RDSUM. */ /* > If TRANS = 'T', RDSCAL is not touched. */ /* > NOTE: RDSCAL only makes sense when STGSY2 is called by */ /* > STGSYL. */ /* > \endverbatim */ /* > */ /* > \param[in] IPIV */ /* > \verbatim */ /* > IPIV is INTEGER array, dimension (N). */ /* > The pivot indices; for 1 <= i <= N, row i of the */ /* > matrix has been interchanged with row IPIV(i). */ /* > \endverbatim */ /* > */ /* > \param[in] JPIV */ /* > \verbatim */ /* > JPIV is INTEGER array, dimension (N). */ /* > The pivot indices; for 1 <= j <= N, column j of the */ /* > matrix has been interchanged with column JPIV(j). */ /* > \endverbatim */ /* Authors: */ /* ======== */ /* > \author Univ. of Tennessee */ /* > \author Univ. of California Berkeley */ /* > \author Univ. of Colorado Denver */ /* > \author NAG Ltd. */ /* > \date June 2016 */ /* > \ingroup realOTHERauxiliary */ /* > \par Further Details: */ /* ===================== */ /* > */ /* > This routine is a further developed implementation of algorithm */ /* > BSOLVE in [1] using complete pivoting in the LU factorization. */ /* > \par Contributors: */ /* ================== */ /* > */ /* > Bo Kagstrom and Peter Poromaa, Department of Computing Science, */ /* > Umea University, S-901 87 Umea, Sweden. */ /* > \par References: */ /* ================ */ /* > */ /* > \verbatim */ /* > */ /* > */ /* > [1] Bo Kagstrom and Lars Westin, */ /* > Generalized Schur Methods with Condition Estimators for */ /* > Solving the Generalized Sylvester Equation, IEEE Transactions */ /* > on Automatic Control, Vol. 34, No. 7, July 1989, pp 745-751. */ /* > */ /* > [2] Peter Poromaa, */ /* > On Efficient and Robust Estimators for the Separation */ /* > between two Regular Matrix Pairs with Applications in */ /* > Condition Estimation. Report IMINF-95.05, Departement of */ /* > Computing Science, Umea University, S-901 87 Umea, Sweden, 1995. */ /* > \endverbatim */ /* > */ /* ===================================================================== */ /* Subroutine */ int slatdf_(integer *ijob, integer *n, real *z__, integer * ldz, real *rhs, real *rdsum, real *rdscal, integer *ipiv, integer * jpiv) { /* System generated locals */ integer z_dim1, z_offset, i__1, i__2; real r__1; /* Local variables */ integer info; real temp; extern real sdot_(integer *, real *, integer *, real *, integer *); real work[32]; integer i__, j, k; extern /* Subroutine */ int sscal_(integer *, real *, real *, integer *); real pmone; extern real sasum_(integer *, real *, integer *); real sminu; integer iwork[8]; extern /* Subroutine */ int scopy_(integer *, real *, integer *, real *, integer *), saxpy_(integer *, real *, real *, integer *, real *, integer *); real splus; extern /* Subroutine */ int sgesc2_(integer *, real *, integer *, real *, integer *, integer *, real *); real bm, bp, xm[8], xp[8]; extern /* Subroutine */ int sgecon_(char *, integer *, real *, integer *, real *, real *, real *, integer *, integer *), slassq_( integer *, real *, integer *, real *, real *), slaswp_(integer *, real *, integer *, integer *, integer *, integer *, integer *); /* -- LAPACK auxiliary routine (version 3.7.0) -- */ /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ /* June 2016 */ /* ===================================================================== */ /* Parameter adjustments */ z_dim1 = *ldz; z_offset = 1 + z_dim1 * 1; z__ -= z_offset; --rhs; --ipiv; --jpiv; /* Function Body */ if (*ijob != 2) { /* Apply permutations IPIV to RHS */ i__1 = *n - 1; slaswp_(&c__1, &rhs[1], ldz, &c__1, &i__1, &ipiv[1], &c__1); /* Solve for L-part choosing RHS either to +1 or -1. */ pmone = -1.f; i__1 = *n - 1; for (j = 1; j <= i__1; ++j) { bp = rhs[j] + 1.f; bm = rhs[j] - 1.f; splus = 1.f; /* Look-ahead for L-part RHS(1:N-1) = + or -1, SPLUS and */ /* SMIN computed more efficiently than in BSOLVE [1]. */ i__2 = *n - j; splus += sdot_(&i__2, &z__[j + 1 + j * z_dim1], &c__1, &z__[j + 1 + j * z_dim1], &c__1); i__2 = *n - j; sminu = sdot_(&i__2, &z__[j + 1 + j * z_dim1], &c__1, &rhs[j + 1], &c__1); splus *= rhs[j]; if (splus > sminu) { rhs[j] = bp; } else if (sminu > splus) { rhs[j] = bm; } else { /* In this case the updating sums are equal and we can */ /* choose RHS(J) +1 or -1. The first time this happens */ /* we choose -1, thereafter +1. This is a simple way to */ /* get good estimates of matrices like Byers well-known */ /* example (see [1]). (Not done in BSOLVE.) */ rhs[j] += pmone; pmone = 1.f; } /* Compute the remaining r.h.s. */ temp = -rhs[j]; i__2 = *n - j; saxpy_(&i__2, &temp, &z__[j + 1 + j * z_dim1], &c__1, &rhs[j + 1], &c__1); /* L10: */ } /* Solve for U-part, look-ahead for RHS(N) = +-1. This is not done */ /* in BSOLVE and will hopefully give us a better estimate because */ /* any ill-conditioning of the original matrix is transferred to U */ /* and not to L. U(N, N) is an approximation to sigma_min(LU). */ i__1 = *n - 1; scopy_(&i__1, &rhs[1], &c__1, xp, &c__1); xp[*n - 1] = rhs[*n] + 1.f; rhs[*n] += -1.f; splus = 0.f; sminu = 0.f; for (i__ = *n; i__ >= 1; --i__) { temp = 1.f / z__[i__ + i__ * z_dim1]; xp[i__ - 1] *= temp; rhs[i__] *= temp; i__1 = *n; for (k = i__ + 1; k <= i__1; ++k) { xp[i__ - 1] -= xp[k - 1] * (z__[i__ + k * z_dim1] * temp); rhs[i__] -= rhs[k] * (z__[i__ + k * z_dim1] * temp); /* L20: */ } splus += (r__1 = xp[i__ - 1], abs(r__1)); sminu += (r__1 = rhs[i__], abs(r__1)); /* L30: */ } if (splus > sminu) { scopy_(n, xp, &c__1, &rhs[1], &c__1); } /* Apply the permutations JPIV to the computed solution (RHS) */ i__1 = *n - 1; slaswp_(&c__1, &rhs[1], ldz, &c__1, &i__1, &jpiv[1], &c_n1); /* Compute the sum of squares */ slassq_(n, &rhs[1], &c__1, rdscal, rdsum); } else { /* IJOB = 2, Compute approximate nullvector XM of Z */ sgecon_("I", n, &z__[z_offset], ldz, &c_b23, &temp, work, iwork, & info); scopy_(n, &work[*n], &c__1, xm, &c__1); /* Compute RHS */ i__1 = *n - 1; slaswp_(&c__1, xm, ldz, &c__1, &i__1, &ipiv[1], &c_n1); temp = 1.f / sqrt(sdot_(n, xm, &c__1, xm, &c__1)); sscal_(n, &temp, xm, &c__1); scopy_(n, xm, &c__1, xp, &c__1); saxpy_(n, &c_b23, &rhs[1], &c__1, xp, &c__1); saxpy_(n, &c_b37, xm, &c__1, &rhs[1], &c__1); sgesc2_(n, &z__[z_offset], ldz, &rhs[1], &ipiv[1], &jpiv[1], &temp); sgesc2_(n, &z__[z_offset], ldz, xp, &ipiv[1], &jpiv[1], &temp); if (sasum_(n, xp, &c__1) > sasum_(n, &rhs[1], &c__1)) { scopy_(n, xp, &c__1, &rhs[1], &c__1); } /* Compute the sum of squares */ slassq_(n, &rhs[1], &c__1, rdscal, rdsum); } return 0; /* End of SLATDF */ } /* slatdf_ */
the_stack_data/74594.c
#include <stdio.h> #include <math.h> int main() { int n,t,i,j,a,ch[10],k,l; int ad,mul,mul1,sub,ext; scanf("%d", &t); for(j=1; j<=t; j++) { scanf("%d", &n); mul = n * 63; ad = mul + 7492; mul1 = ad * 5; sub = mul1 - 198; ext = abs(sub); k = 0; while(k<2) { l = ext%10; ext = ext / 10; ch[k] = l; k++; } printf("%d\n", ch[1]); } return 0; }
the_stack_data/161080718.c
/* f2c.h -- Standard Fortran to C header file */ /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ #ifndef F2C_INCLUDE #define F2C_INCLUDE #include <math.h> #include <stdlib.h> #include <string.h> #include <stdio.h> #include <complex.h> #ifdef complex #undef complex #endif #ifdef I #undef I #endif #if defined(_WIN64) typedef long long BLASLONG; typedef unsigned long long BLASULONG; #else typedef long BLASLONG; typedef unsigned long BLASULONG; #endif #ifdef LAPACK_ILP64 typedef BLASLONG blasint; #if defined(_WIN64) #define blasabs(x) llabs(x) #else #define blasabs(x) labs(x) #endif #else typedef int blasint; #define blasabs(x) abs(x) #endif typedef blasint integer; typedef unsigned int uinteger; typedef char *address; typedef short int shortint; typedef float real; typedef double doublereal; typedef struct { real r, i; } complex; typedef struct { doublereal r, i; } doublecomplex; static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} #define pCf(z) (*_pCf(z)) #define pCd(z) (*_pCd(z)) typedef int logical; typedef short int shortlogical; typedef char logical1; typedef char integer1; #define TRUE_ (1) #define FALSE_ (0) /* Extern is for use with -E */ #ifndef Extern #define Extern extern #endif /* I/O stuff */ typedef int flag; typedef int ftnlen; typedef int ftnint; /*external read, write*/ typedef struct { flag cierr; ftnint ciunit; flag ciend; char *cifmt; ftnint cirec; } cilist; /*internal read, write*/ typedef struct { flag icierr; char *iciunit; flag iciend; char *icifmt; ftnint icirlen; ftnint icirnum; } icilist; /*open*/ typedef struct { flag oerr; ftnint ounit; char *ofnm; ftnlen ofnmlen; char *osta; char *oacc; char *ofm; ftnint orl; char *oblnk; } olist; /*close*/ typedef struct { flag cerr; ftnint cunit; char *csta; } cllist; /*rewind, backspace, endfile*/ typedef struct { flag aerr; ftnint aunit; } alist; /* inquire */ typedef struct { flag inerr; ftnint inunit; char *infile; ftnlen infilen; ftnint *inex; /*parameters in standard's order*/ ftnint *inopen; ftnint *innum; ftnint *innamed; char *inname; ftnlen innamlen; char *inacc; ftnlen inacclen; char *inseq; ftnlen inseqlen; char *indir; ftnlen indirlen; char *infmt; ftnlen infmtlen; char *inform; ftnint informlen; char *inunf; ftnlen inunflen; ftnint *inrecl; ftnint *innrec; char *inblank; ftnlen inblanklen; } inlist; #define VOID void union Multitype { /* for multiple entry points */ integer1 g; shortint h; integer i; /* longint j; */ real r; doublereal d; complex c; doublecomplex z; }; typedef union Multitype Multitype; struct Vardesc { /* for Namelist */ char *name; char *addr; ftnlen *dims; int type; }; typedef struct Vardesc Vardesc; struct Namelist { char *name; Vardesc **vars; int nvars; }; typedef struct Namelist Namelist; #define abs(x) ((x) >= 0 ? (x) : -(x)) #define dabs(x) (fabs(x)) #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) #define dmin(a,b) (f2cmin(a,b)) #define dmax(a,b) (f2cmax(a,b)) #define bit_test(a,b) ((a) >> (b) & 1) #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) #define abort_() { sig_die("Fortran abort routine called", 1); } #define c_abs(z) (cabsf(Cf(z))) #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} #define d_abs(x) (fabs(*(x))) #define d_acos(x) (acos(*(x))) #define d_asin(x) (asin(*(x))) #define d_atan(x) (atan(*(x))) #define d_atn2(x, y) (atan2(*(x),*(y))) #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } #define d_cos(x) (cos(*(x))) #define d_cosh(x) (cosh(*(x))) #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) #define d_exp(x) (exp(*(x))) #define d_imag(z) (cimag(Cd(z))) #define r_imag(z) (cimag(Cf(z))) #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) #define d_log(x) (log(*(x))) #define d_mod(x, y) (fmod(*(x), *(y))) #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) #define d_nint(x) u_nint(*(x)) #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) #define d_sign(a,b) u_sign(*(a),*(b)) #define r_sign(a,b) u_sign(*(a),*(b)) #define d_sin(x) (sin(*(x))) #define d_sinh(x) (sinh(*(x))) #define d_sqrt(x) (sqrt(*(x))) #define d_tan(x) (tan(*(x))) #define d_tanh(x) (tanh(*(x))) #define i_abs(x) abs(*(x)) #define i_dnnt(x) ((integer)u_nint(*(x))) #define i_len(s, n) (n) #define i_nint(x) ((integer)u_nint(*(x))) #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) #define pow_si(B,E) spow_ui(*(B),*(E)) #define pow_ri(B,E) spow_ui(*(B),*(E)) #define pow_di(B,E) dpow_ui(*(B),*(E)) #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } #define sig_die(s, kill) { exit(1); } #define s_stop(s, n) {exit(0);} static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; #define z_abs(z) (cabs(Cd(z))) #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} #define myexit_() break; #define mycycle() continue; #define myceiling(w) {ceil(w)} #define myhuge(w) {HUGE_VAL} //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} /* procedure parameter types for -A and -C++ */ #define F2C_proc_par_types 1 #ifdef __cplusplus typedef logical (*L_fp)(...); #else typedef logical (*L_fp)(); #endif static float spow_ui(float x, integer n) { float pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } static double dpow_ui(double x, integer n) { double pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } static _Complex float cpow_ui(_Complex float x, integer n) { _Complex float pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } static _Complex double zpow_ui(_Complex double x, integer n) { _Complex double pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } static integer pow_ii(integer x, integer n) { integer pow; unsigned long int u; if (n <= 0) { if (n == 0 || x == 1) pow = 1; else if (x != -1) pow = x == 0 ? 1/x : 0; else n = -n; } if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { u = n; for(pow = 1; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } static integer dmaxloc_(double *w, integer s, integer e, integer *n) { double m; integer i, mi; for(m=w[s-1], mi=s, i=s+1; i<=e; i++) if (w[i-1]>m) mi=i ,m=w[i-1]; return mi-s+1; } static integer smaxloc_(float *w, integer s, integer e, integer *n) { float m; integer i, mi; for(m=w[s-1], mi=s, i=s+1; i<=e; i++) if (w[i-1]>m) mi=i ,m=w[i-1]; return mi-s+1; } static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; _Complex float zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); } } pCf(z) = zdotc; } static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; _Complex double zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conj(Cd(&x[i])) * Cd(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); } } pCd(z) = zdotc; } static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; _Complex float zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cf(&x[i]) * Cf(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); } } pCf(z) = zdotc; } static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; _Complex double zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cd(&x[i]) * Cd(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); } } pCd(z) = zdotc; } #endif /* -- translated by f2c (version 20000121). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ /* Table of constant values */ static doublecomplex c_b1 = {1.,0.}; static integer c__1 = 1; /* > \brief \b ZSYTF2_RK computes the factorization of a complex symmetric indefinite matrix using the bounded Bunch-Kaufman (rook) diagonal pivoting method (BLAS2 unblocked algorithm). */ /* =========== DOCUMENTATION =========== */ /* Online html documentation available at */ /* http://www.netlib.org/lapack/explore-html/ */ /* > \htmlonly */ /* > Download ZSYTF2_RK + dependencies */ /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zsytf2_ rk.f"> */ /* > [TGZ]</a> */ /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zsytf2_ rk.f"> */ /* > [ZIP]</a> */ /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zsytf2_ rk.f"> */ /* > [TXT]</a> */ /* > \endhtmlonly */ /* Definition: */ /* =========== */ /* SUBROUTINE ZSYTF2_RK( UPLO, N, A, LDA, E, IPIV, INFO ) */ /* CHARACTER UPLO */ /* INTEGER INFO, LDA, N */ /* INTEGER IPIV( * ) */ /* COMPLEX*16 A( LDA, * ), E ( * ) */ /* > \par Purpose: */ /* ============= */ /* > */ /* > \verbatim */ /* > ZSYTF2_RK computes the factorization of a complex symmetric matrix A */ /* > using the bounded Bunch-Kaufman (rook) diagonal pivoting method: */ /* > */ /* > A = P*U*D*(U**T)*(P**T) or A = P*L*D*(L**T)*(P**T), */ /* > */ /* > where U (or L) is unit upper (or lower) triangular matrix, */ /* > U**T (or L**T) is the transpose of U (or L), P is a permutation */ /* > matrix, P**T is the transpose of P, and D is symmetric and block */ /* > diagonal with 1-by-1 and 2-by-2 diagonal blocks. */ /* > */ /* > This is the unblocked version of the algorithm, calling Level 2 BLAS. */ /* > For more information see Further Details section. */ /* > \endverbatim */ /* Arguments: */ /* ========== */ /* > \param[in] UPLO */ /* > \verbatim */ /* > UPLO is CHARACTER*1 */ /* > Specifies whether the upper or lower triangular part of the */ /* > symmetric matrix A is stored: */ /* > = 'U': Upper triangular */ /* > = 'L': Lower triangular */ /* > \endverbatim */ /* > */ /* > \param[in] N */ /* > \verbatim */ /* > N is INTEGER */ /* > The order of the matrix A. N >= 0. */ /* > \endverbatim */ /* > */ /* > \param[in,out] A */ /* > \verbatim */ /* > A is COMPLEX*16 array, dimension (LDA,N) */ /* > On entry, the symmetric matrix A. */ /* > If UPLO = 'U': the leading N-by-N upper triangular part */ /* > of A contains the upper triangular part of the matrix A, */ /* > and the strictly lower triangular part of A is not */ /* > referenced. */ /* > */ /* > If UPLO = 'L': the leading N-by-N lower triangular part */ /* > of A contains the lower triangular part of the matrix A, */ /* > and the strictly upper triangular part of A is not */ /* > referenced. */ /* > */ /* > On exit, contains: */ /* > a) ONLY diagonal elements of the symmetric block diagonal */ /* > matrix D on the diagonal of A, i.e. D(k,k) = A(k,k); */ /* > (superdiagonal (or subdiagonal) elements of D */ /* > are stored on exit in array E), and */ /* > b) If UPLO = 'U': factor U in the superdiagonal part of A. */ /* > If UPLO = 'L': factor L in the subdiagonal part of A. */ /* > \endverbatim */ /* > */ /* > \param[in] LDA */ /* > \verbatim */ /* > LDA is INTEGER */ /* > The leading dimension of the array A. LDA >= f2cmax(1,N). */ /* > \endverbatim */ /* > */ /* > \param[out] E */ /* > \verbatim */ /* > E is COMPLEX*16 array, dimension (N) */ /* > On exit, contains the superdiagonal (or subdiagonal) */ /* > elements of the symmetric block diagonal matrix D */ /* > with 1-by-1 or 2-by-2 diagonal blocks, where */ /* > If UPLO = 'U': E(i) = D(i-1,i), i=2:N, E(1) is set to 0; */ /* > If UPLO = 'L': E(i) = D(i+1,i), i=1:N-1, E(N) is set to 0. */ /* > */ /* > NOTE: For 1-by-1 diagonal block D(k), where */ /* > 1 <= k <= N, the element E(k) is set to 0 in both */ /* > UPLO = 'U' or UPLO = 'L' cases. */ /* > \endverbatim */ /* > */ /* > \param[out] IPIV */ /* > \verbatim */ /* > IPIV is INTEGER array, dimension (N) */ /* > IPIV describes the permutation matrix P in the factorization */ /* > of matrix A as follows. The absolute value of IPIV(k) */ /* > represents the index of row and column that were */ /* > interchanged with the k-th row and column. The value of UPLO */ /* > describes the order in which the interchanges were applied. */ /* > Also, the sign of IPIV represents the block structure of */ /* > the symmetric block diagonal matrix D with 1-by-1 or 2-by-2 */ /* > diagonal blocks which correspond to 1 or 2 interchanges */ /* > at each factorization step. For more info see Further */ /* > Details section. */ /* > */ /* > If UPLO = 'U', */ /* > ( in factorization order, k decreases from N to 1 ): */ /* > a) A single positive entry IPIV(k) > 0 means: */ /* > D(k,k) is a 1-by-1 diagonal block. */ /* > If IPIV(k) != k, rows and columns k and IPIV(k) were */ /* > interchanged in the matrix A(1:N,1:N); */ /* > If IPIV(k) = k, no interchange occurred. */ /* > */ /* > b) A pair of consecutive negative entries */ /* > IPIV(k) < 0 and IPIV(k-1) < 0 means: */ /* > D(k-1:k,k-1:k) is a 2-by-2 diagonal block. */ /* > (NOTE: negative entries in IPIV appear ONLY in pairs). */ /* > 1) If -IPIV(k) != k, rows and columns */ /* > k and -IPIV(k) were interchanged */ /* > in the matrix A(1:N,1:N). */ /* > If -IPIV(k) = k, no interchange occurred. */ /* > 2) If -IPIV(k-1) != k-1, rows and columns */ /* > k-1 and -IPIV(k-1) were interchanged */ /* > in the matrix A(1:N,1:N). */ /* > If -IPIV(k-1) = k-1, no interchange occurred. */ /* > */ /* > c) In both cases a) and b), always ABS( IPIV(k) ) <= k. */ /* > */ /* > d) NOTE: Any entry IPIV(k) is always NONZERO on output. */ /* > */ /* > If UPLO = 'L', */ /* > ( in factorization order, k increases from 1 to N ): */ /* > a) A single positive entry IPIV(k) > 0 means: */ /* > D(k,k) is a 1-by-1 diagonal block. */ /* > If IPIV(k) != k, rows and columns k and IPIV(k) were */ /* > interchanged in the matrix A(1:N,1:N). */ /* > If IPIV(k) = k, no interchange occurred. */ /* > */ /* > b) A pair of consecutive negative entries */ /* > IPIV(k) < 0 and IPIV(k+1) < 0 means: */ /* > D(k:k+1,k:k+1) is a 2-by-2 diagonal block. */ /* > (NOTE: negative entries in IPIV appear ONLY in pairs). */ /* > 1) If -IPIV(k) != k, rows and columns */ /* > k and -IPIV(k) were interchanged */ /* > in the matrix A(1:N,1:N). */ /* > If -IPIV(k) = k, no interchange occurred. */ /* > 2) If -IPIV(k+1) != k+1, rows and columns */ /* > k-1 and -IPIV(k-1) were interchanged */ /* > in the matrix A(1:N,1:N). */ /* > If -IPIV(k+1) = k+1, no interchange occurred. */ /* > */ /* > c) In both cases a) and b), always ABS( IPIV(k) ) >= k. */ /* > */ /* > d) NOTE: Any entry IPIV(k) is always NONZERO on output. */ /* > \endverbatim */ /* > */ /* > \param[out] INFO */ /* > \verbatim */ /* > INFO is INTEGER */ /* > = 0: successful exit */ /* > */ /* > < 0: If INFO = -k, the k-th argument had an illegal value */ /* > */ /* > > 0: If INFO = k, the matrix A is singular, because: */ /* > If UPLO = 'U': column k in the upper */ /* > triangular part of A contains all zeros. */ /* > If UPLO = 'L': column k in the lower */ /* > triangular part of A contains all zeros. */ /* > */ /* > Therefore D(k,k) is exactly zero, and superdiagonal */ /* > elements of column k of U (or subdiagonal elements of */ /* > column k of L ) are all zeros. The factorization has */ /* > been completed, but the block diagonal matrix D is */ /* > exactly singular, and division by zero will occur if */ /* > it is used to solve a system of equations. */ /* > */ /* > NOTE: INFO only stores the first occurrence of */ /* > a singularity, any subsequent occurrence of singularity */ /* > is not stored in INFO even though the factorization */ /* > always completes. */ /* > \endverbatim */ /* Authors: */ /* ======== */ /* > \author Univ. of Tennessee */ /* > \author Univ. of California Berkeley */ /* > \author Univ. of Colorado Denver */ /* > \author NAG Ltd. */ /* > \date December 2016 */ /* > \ingroup complex16SYcomputational */ /* > \par Further Details: */ /* ===================== */ /* > */ /* > \verbatim */ /* > TODO: put further details */ /* > \endverbatim */ /* > \par Contributors: */ /* ================== */ /* > */ /* > \verbatim */ /* > */ /* > December 2016, Igor Kozachenko, */ /* > Computer Science Division, */ /* > University of California, Berkeley */ /* > */ /* > September 2007, Sven Hammarling, Nicholas J. Higham, Craig Lucas, */ /* > School of Mathematics, */ /* > University of Manchester */ /* > */ /* > 01-01-96 - Based on modifications by */ /* > J. Lewis, Boeing Computer Services Company */ /* > A. Petitet, Computer Science Dept., */ /* > Univ. of Tenn., Knoxville abd , USA */ /* > \endverbatim */ /* ===================================================================== */ /* Subroutine */ int zsytf2_rk_(char *uplo, integer *n, doublecomplex *a, integer *lda, doublecomplex *e, integer *ipiv, integer *info) { /* System generated locals */ integer a_dim1, a_offset, i__1, i__2, i__3, i__4; doublereal d__1, d__2; doublecomplex z__1, z__2, z__3, z__4, z__5, z__6; /* Local variables */ logical done; integer imax, jmax; extern /* Subroutine */ int zsyr_(char *, integer *, doublecomplex *, doublecomplex *, integer *, doublecomplex *, integer *); integer i__, j, k, p; doublecomplex t; doublereal alpha; extern logical lsame_(char *, char *); doublereal dtemp, sfmin; integer itemp; extern /* Subroutine */ int zscal_(integer *, doublecomplex *, doublecomplex *, integer *); integer kstep; logical upper; extern /* Subroutine */ int zswap_(integer *, doublecomplex *, integer *, doublecomplex *, integer *); doublecomplex d11, d12, d21, d22; integer ii, kk; extern doublereal dlamch_(char *); integer kp; doublereal absakk; doublecomplex wk; extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen); doublereal colmax; extern integer izamax_(integer *, doublecomplex *, integer *); doublereal rowmax; doublecomplex wkm1, wkp1; /* -- LAPACK computational routine (version 3.7.0) -- */ /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ /* December 2016 */ /* ===================================================================== */ /* Test the input parameters. */ /* Parameter adjustments */ a_dim1 = *lda; a_offset = 1 + a_dim1 * 1; a -= a_offset; --e; --ipiv; /* Function Body */ *info = 0; upper = lsame_(uplo, "U"); if (! upper && ! lsame_(uplo, "L")) { *info = -1; } else if (*n < 0) { *info = -2; } else if (*lda < f2cmax(1,*n)) { *info = -4; } if (*info != 0) { i__1 = -(*info); xerbla_("ZSYTF2_RK", &i__1, (ftnlen)9); return 0; } /* Initialize ALPHA for use in choosing pivot block size. */ alpha = (sqrt(17.) + 1.) / 8.; /* Compute machine safe minimum */ sfmin = dlamch_("S"); if (upper) { /* Factorize A as U*D*U**T using the upper triangle of A */ /* Initialize the first entry of array E, where superdiagonal */ /* elements of D are stored */ e[1].r = 0., e[1].i = 0.; /* K is the main loop index, decreasing from N to 1 in steps of */ /* 1 or 2 */ k = *n; L10: /* If K < 1, exit from loop */ if (k < 1) { goto L34; } kstep = 1; p = k; /* Determine rows and columns to be interchanged and whether */ /* a 1-by-1 or 2-by-2 pivot block will be used */ i__1 = k + k * a_dim1; absakk = (d__1 = a[i__1].r, abs(d__1)) + (d__2 = d_imag(&a[k + k * a_dim1]), abs(d__2)); /* IMAX is the row-index of the largest off-diagonal element in */ /* column K, and COLMAX is its absolute value. */ /* Determine both COLMAX and IMAX. */ if (k > 1) { i__1 = k - 1; imax = izamax_(&i__1, &a[k * a_dim1 + 1], &c__1); i__1 = imax + k * a_dim1; colmax = (d__1 = a[i__1].r, abs(d__1)) + (d__2 = d_imag(&a[imax + k * a_dim1]), abs(d__2)); } else { colmax = 0.; } if (f2cmax(absakk,colmax) == 0.) { /* Column K is zero or underflow: set INFO and continue */ if (*info == 0) { *info = k; } kp = k; /* Set E( K ) to zero */ if (k > 1) { i__1 = k; e[i__1].r = 0., e[i__1].i = 0.; } } else { /* Test for interchange */ /* Equivalent to testing for (used to handle NaN and Inf) */ /* ABSAKK.GE.ALPHA*COLMAX */ if (! (absakk < alpha * colmax)) { /* no interchange, */ /* use 1-by-1 pivot block */ kp = k; } else { done = FALSE_; /* Loop until pivot found */ L12: /* Begin pivot search loop body */ /* JMAX is the column-index of the largest off-diagonal */ /* element in row IMAX, and ROWMAX is its absolute value. */ /* Determine both ROWMAX and JMAX. */ if (imax != k) { i__1 = k - imax; jmax = imax + izamax_(&i__1, &a[imax + (imax + 1) * a_dim1], lda); i__1 = imax + jmax * a_dim1; rowmax = (d__1 = a[i__1].r, abs(d__1)) + (d__2 = d_imag(& a[imax + jmax * a_dim1]), abs(d__2)); } else { rowmax = 0.; } if (imax > 1) { i__1 = imax - 1; itemp = izamax_(&i__1, &a[imax * a_dim1 + 1], &c__1); i__1 = itemp + imax * a_dim1; dtemp = (d__1 = a[i__1].r, abs(d__1)) + (d__2 = d_imag(&a[ itemp + imax * a_dim1]), abs(d__2)); if (dtemp > rowmax) { rowmax = dtemp; jmax = itemp; } } /* Equivalent to testing for (used to handle NaN and Inf) */ /* ABS( A( IMAX, IMAX ) ).GE.ALPHA*ROWMAX */ i__1 = imax + imax * a_dim1; if (! ((d__1 = a[i__1].r, abs(d__1)) + (d__2 = d_imag(&a[imax + imax * a_dim1]), abs(d__2)) < alpha * rowmax)) { /* interchange rows and columns K and IMAX, */ /* use 1-by-1 pivot block */ kp = imax; done = TRUE_; /* Equivalent to testing for ROWMAX .EQ. COLMAX, */ /* used to handle NaN and Inf */ } else if (p == jmax || rowmax <= colmax) { /* interchange rows and columns K+1 and IMAX, */ /* use 2-by-2 pivot block */ kp = imax; kstep = 2; done = TRUE_; } else { /* Pivot NOT found, set variables and repeat */ p = imax; colmax = rowmax; imax = jmax; } /* End pivot search loop body */ if (! done) { goto L12; } } /* Swap TWO rows and TWO columns */ /* First swap */ if (kstep == 2 && p != k) { /* Interchange rows and column K and P in the leading */ /* submatrix A(1:k,1:k) if we have a 2-by-2 pivot */ if (p > 1) { i__1 = p - 1; zswap_(&i__1, &a[k * a_dim1 + 1], &c__1, &a[p * a_dim1 + 1], &c__1); } if (p < k - 1) { i__1 = k - p - 1; zswap_(&i__1, &a[p + 1 + k * a_dim1], &c__1, &a[p + (p + 1) * a_dim1], lda); } i__1 = k + k * a_dim1; t.r = a[i__1].r, t.i = a[i__1].i; i__1 = k + k * a_dim1; i__2 = p + p * a_dim1; a[i__1].r = a[i__2].r, a[i__1].i = a[i__2].i; i__1 = p + p * a_dim1; a[i__1].r = t.r, a[i__1].i = t.i; /* Convert upper triangle of A into U form by applying */ /* the interchanges in columns k+1:N. */ if (k < *n) { i__1 = *n - k; zswap_(&i__1, &a[k + (k + 1) * a_dim1], lda, &a[p + (k + 1) * a_dim1], lda); } } /* Second swap */ kk = k - kstep + 1; if (kp != kk) { /* Interchange rows and columns KK and KP in the leading */ /* submatrix A(1:k,1:k) */ if (kp > 1) { i__1 = kp - 1; zswap_(&i__1, &a[kk * a_dim1 + 1], &c__1, &a[kp * a_dim1 + 1], &c__1); } if (kk > 1 && kp < kk - 1) { i__1 = kk - kp - 1; zswap_(&i__1, &a[kp + 1 + kk * a_dim1], &c__1, &a[kp + ( kp + 1) * a_dim1], lda); } i__1 = kk + kk * a_dim1; t.r = a[i__1].r, t.i = a[i__1].i; i__1 = kk + kk * a_dim1; i__2 = kp + kp * a_dim1; a[i__1].r = a[i__2].r, a[i__1].i = a[i__2].i; i__1 = kp + kp * a_dim1; a[i__1].r = t.r, a[i__1].i = t.i; if (kstep == 2) { i__1 = k - 1 + k * a_dim1; t.r = a[i__1].r, t.i = a[i__1].i; i__1 = k - 1 + k * a_dim1; i__2 = kp + k * a_dim1; a[i__1].r = a[i__2].r, a[i__1].i = a[i__2].i; i__1 = kp + k * a_dim1; a[i__1].r = t.r, a[i__1].i = t.i; } /* Convert upper triangle of A into U form by applying */ /* the interchanges in columns k+1:N. */ if (k < *n) { i__1 = *n - k; zswap_(&i__1, &a[kk + (k + 1) * a_dim1], lda, &a[kp + (k + 1) * a_dim1], lda); } } /* Update the leading submatrix */ if (kstep == 1) { /* 1-by-1 pivot block D(k): column k now holds */ /* W(k) = U(k)*D(k) */ /* where U(k) is the k-th column of U */ if (k > 1) { /* Perform a rank-1 update of A(1:k-1,1:k-1) and */ /* store U(k) in column k */ i__1 = k + k * a_dim1; if ((d__1 = a[i__1].r, abs(d__1)) + (d__2 = d_imag(&a[k + k * a_dim1]), abs(d__2)) >= sfmin) { /* Perform a rank-1 update of A(1:k-1,1:k-1) as */ /* A := A - U(k)*D(k)*U(k)**T */ /* = A - W(k)*1/D(k)*W(k)**T */ z_div(&z__1, &c_b1, &a[k + k * a_dim1]); d11.r = z__1.r, d11.i = z__1.i; i__1 = k - 1; z__1.r = -d11.r, z__1.i = -d11.i; zsyr_(uplo, &i__1, &z__1, &a[k * a_dim1 + 1], &c__1, & a[a_offset], lda); /* Store U(k) in column k */ i__1 = k - 1; zscal_(&i__1, &d11, &a[k * a_dim1 + 1], &c__1); } else { /* Store L(k) in column K */ i__1 = k + k * a_dim1; d11.r = a[i__1].r, d11.i = a[i__1].i; i__1 = k - 1; for (ii = 1; ii <= i__1; ++ii) { i__2 = ii + k * a_dim1; z_div(&z__1, &a[ii + k * a_dim1], &d11); a[i__2].r = z__1.r, a[i__2].i = z__1.i; /* L16: */ } /* Perform a rank-1 update of A(k+1:n,k+1:n) as */ /* A := A - U(k)*D(k)*U(k)**T */ /* = A - W(k)*(1/D(k))*W(k)**T */ /* = A - (W(k)/D(k))*(D(k))*(W(k)/D(K))**T */ i__1 = k - 1; z__1.r = -d11.r, z__1.i = -d11.i; zsyr_(uplo, &i__1, &z__1, &a[k * a_dim1 + 1], &c__1, & a[a_offset], lda); } /* Store the superdiagonal element of D in array E */ i__1 = k; e[i__1].r = 0., e[i__1].i = 0.; } } else { /* 2-by-2 pivot block D(k): columns k and k-1 now hold */ /* ( W(k-1) W(k) ) = ( U(k-1) U(k) )*D(k) */ /* where U(k) and U(k-1) are the k-th and (k-1)-th columns */ /* of U */ /* Perform a rank-2 update of A(1:k-2,1:k-2) as */ /* A := A - ( U(k-1) U(k) )*D(k)*( U(k-1) U(k) )**T */ /* = A - ( ( A(k-1)A(k) )*inv(D(k)) ) * ( A(k-1)A(k) )**T */ /* and store L(k) and L(k+1) in columns k and k+1 */ if (k > 2) { i__1 = k - 1 + k * a_dim1; d12.r = a[i__1].r, d12.i = a[i__1].i; z_div(&z__1, &a[k - 1 + (k - 1) * a_dim1], &d12); d22.r = z__1.r, d22.i = z__1.i; z_div(&z__1, &a[k + k * a_dim1], &d12); d11.r = z__1.r, d11.i = z__1.i; z__3.r = d11.r * d22.r - d11.i * d22.i, z__3.i = d11.r * d22.i + d11.i * d22.r; z__2.r = z__3.r - 1., z__2.i = z__3.i + 0.; z_div(&z__1, &c_b1, &z__2); t.r = z__1.r, t.i = z__1.i; for (j = k - 2; j >= 1; --j) { i__1 = j + (k - 1) * a_dim1; z__3.r = d11.r * a[i__1].r - d11.i * a[i__1].i, z__3.i = d11.r * a[i__1].i + d11.i * a[i__1] .r; i__2 = j + k * a_dim1; z__2.r = z__3.r - a[i__2].r, z__2.i = z__3.i - a[i__2] .i; z__1.r = t.r * z__2.r - t.i * z__2.i, z__1.i = t.r * z__2.i + t.i * z__2.r; wkm1.r = z__1.r, wkm1.i = z__1.i; i__1 = j + k * a_dim1; z__3.r = d22.r * a[i__1].r - d22.i * a[i__1].i, z__3.i = d22.r * a[i__1].i + d22.i * a[i__1] .r; i__2 = j + (k - 1) * a_dim1; z__2.r = z__3.r - a[i__2].r, z__2.i = z__3.i - a[i__2] .i; z__1.r = t.r * z__2.r - t.i * z__2.i, z__1.i = t.r * z__2.i + t.i * z__2.r; wk.r = z__1.r, wk.i = z__1.i; for (i__ = j; i__ >= 1; --i__) { i__1 = i__ + j * a_dim1; i__2 = i__ + j * a_dim1; z_div(&z__4, &a[i__ + k * a_dim1], &d12); z__3.r = z__4.r * wk.r - z__4.i * wk.i, z__3.i = z__4.r * wk.i + z__4.i * wk.r; z__2.r = a[i__2].r - z__3.r, z__2.i = a[i__2].i - z__3.i; z_div(&z__6, &a[i__ + (k - 1) * a_dim1], &d12); z__5.r = z__6.r * wkm1.r - z__6.i * wkm1.i, z__5.i = z__6.r * wkm1.i + z__6.i * wkm1.r; z__1.r = z__2.r - z__5.r, z__1.i = z__2.i - z__5.i; a[i__1].r = z__1.r, a[i__1].i = z__1.i; /* L20: */ } /* Store U(k) and U(k-1) in cols k and k-1 for row J */ i__1 = j + k * a_dim1; z_div(&z__1, &wk, &d12); a[i__1].r = z__1.r, a[i__1].i = z__1.i; i__1 = j + (k - 1) * a_dim1; z_div(&z__1, &wkm1, &d12); a[i__1].r = z__1.r, a[i__1].i = z__1.i; /* L30: */ } } /* Copy superdiagonal elements of D(K) to E(K) and */ /* ZERO out superdiagonal entry of A */ i__1 = k; i__2 = k - 1 + k * a_dim1; e[i__1].r = a[i__2].r, e[i__1].i = a[i__2].i; i__1 = k - 1; e[i__1].r = 0., e[i__1].i = 0.; i__1 = k - 1 + k * a_dim1; a[i__1].r = 0., a[i__1].i = 0.; } /* End column K is nonsingular */ } /* Store details of the interchanges in IPIV */ if (kstep == 1) { ipiv[k] = kp; } else { ipiv[k] = -p; ipiv[k - 1] = -kp; } /* Decrease K and return to the start of the main loop */ k -= kstep; goto L10; L34: ; } else { /* Factorize A as L*D*L**T using the lower triangle of A */ /* Initialize the unused last entry of the subdiagonal array E. */ i__1 = *n; e[i__1].r = 0., e[i__1].i = 0.; /* K is the main loop index, increasing from 1 to N in steps of */ /* 1 or 2 */ k = 1; L40: /* If K > N, exit from loop */ if (k > *n) { goto L64; } kstep = 1; p = k; /* Determine rows and columns to be interchanged and whether */ /* a 1-by-1 or 2-by-2 pivot block will be used */ i__1 = k + k * a_dim1; absakk = (d__1 = a[i__1].r, abs(d__1)) + (d__2 = d_imag(&a[k + k * a_dim1]), abs(d__2)); /* IMAX is the row-index of the largest off-diagonal element in */ /* column K, and COLMAX is its absolute value. */ /* Determine both COLMAX and IMAX. */ if (k < *n) { i__1 = *n - k; imax = k + izamax_(&i__1, &a[k + 1 + k * a_dim1], &c__1); i__1 = imax + k * a_dim1; colmax = (d__1 = a[i__1].r, abs(d__1)) + (d__2 = d_imag(&a[imax + k * a_dim1]), abs(d__2)); } else { colmax = 0.; } if (f2cmax(absakk,colmax) == 0.) { /* Column K is zero or underflow: set INFO and continue */ if (*info == 0) { *info = k; } kp = k; /* Set E( K ) to zero */ if (k < *n) { i__1 = k; e[i__1].r = 0., e[i__1].i = 0.; } } else { /* Test for interchange */ /* Equivalent to testing for (used to handle NaN and Inf) */ /* ABSAKK.GE.ALPHA*COLMAX */ if (! (absakk < alpha * colmax)) { /* no interchange, use 1-by-1 pivot block */ kp = k; } else { done = FALSE_; /* Loop until pivot found */ L42: /* Begin pivot search loop body */ /* JMAX is the column-index of the largest off-diagonal */ /* element in row IMAX, and ROWMAX is its absolute value. */ /* Determine both ROWMAX and JMAX. */ if (imax != k) { i__1 = imax - k; jmax = k - 1 + izamax_(&i__1, &a[imax + k * a_dim1], lda); i__1 = imax + jmax * a_dim1; rowmax = (d__1 = a[i__1].r, abs(d__1)) + (d__2 = d_imag(& a[imax + jmax * a_dim1]), abs(d__2)); } else { rowmax = 0.; } if (imax < *n) { i__1 = *n - imax; itemp = imax + izamax_(&i__1, &a[imax + 1 + imax * a_dim1] , &c__1); i__1 = itemp + imax * a_dim1; dtemp = (d__1 = a[i__1].r, abs(d__1)) + (d__2 = d_imag(&a[ itemp + imax * a_dim1]), abs(d__2)); if (dtemp > rowmax) { rowmax = dtemp; jmax = itemp; } } /* Equivalent to testing for (used to handle NaN and Inf) */ /* ABS( A( IMAX, IMAX ) ).GE.ALPHA*ROWMAX */ i__1 = imax + imax * a_dim1; if (! ((d__1 = a[i__1].r, abs(d__1)) + (d__2 = d_imag(&a[imax + imax * a_dim1]), abs(d__2)) < alpha * rowmax)) { /* interchange rows and columns K and IMAX, */ /* use 1-by-1 pivot block */ kp = imax; done = TRUE_; /* Equivalent to testing for ROWMAX .EQ. COLMAX, */ /* used to handle NaN and Inf */ } else if (p == jmax || rowmax <= colmax) { /* interchange rows and columns K+1 and IMAX, */ /* use 2-by-2 pivot block */ kp = imax; kstep = 2; done = TRUE_; } else { /* Pivot NOT found, set variables and repeat */ p = imax; colmax = rowmax; imax = jmax; } /* End pivot search loop body */ if (! done) { goto L42; } } /* Swap TWO rows and TWO columns */ /* First swap */ if (kstep == 2 && p != k) { /* Interchange rows and column K and P in the trailing */ /* submatrix A(k:n,k:n) if we have a 2-by-2 pivot */ if (p < *n) { i__1 = *n - p; zswap_(&i__1, &a[p + 1 + k * a_dim1], &c__1, &a[p + 1 + p * a_dim1], &c__1); } if (p > k + 1) { i__1 = p - k - 1; zswap_(&i__1, &a[k + 1 + k * a_dim1], &c__1, &a[p + (k + 1) * a_dim1], lda); } i__1 = k + k * a_dim1; t.r = a[i__1].r, t.i = a[i__1].i; i__1 = k + k * a_dim1; i__2 = p + p * a_dim1; a[i__1].r = a[i__2].r, a[i__1].i = a[i__2].i; i__1 = p + p * a_dim1; a[i__1].r = t.r, a[i__1].i = t.i; /* Convert lower triangle of A into L form by applying */ /* the interchanges in columns 1:k-1. */ if (k > 1) { i__1 = k - 1; zswap_(&i__1, &a[k + a_dim1], lda, &a[p + a_dim1], lda); } } /* Second swap */ kk = k + kstep - 1; if (kp != kk) { /* Interchange rows and columns KK and KP in the trailing */ /* submatrix A(k:n,k:n) */ if (kp < *n) { i__1 = *n - kp; zswap_(&i__1, &a[kp + 1 + kk * a_dim1], &c__1, &a[kp + 1 + kp * a_dim1], &c__1); } if (kk < *n && kp > kk + 1) { i__1 = kp - kk - 1; zswap_(&i__1, &a[kk + 1 + kk * a_dim1], &c__1, &a[kp + ( kk + 1) * a_dim1], lda); } i__1 = kk + kk * a_dim1; t.r = a[i__1].r, t.i = a[i__1].i; i__1 = kk + kk * a_dim1; i__2 = kp + kp * a_dim1; a[i__1].r = a[i__2].r, a[i__1].i = a[i__2].i; i__1 = kp + kp * a_dim1; a[i__1].r = t.r, a[i__1].i = t.i; if (kstep == 2) { i__1 = k + 1 + k * a_dim1; t.r = a[i__1].r, t.i = a[i__1].i; i__1 = k + 1 + k * a_dim1; i__2 = kp + k * a_dim1; a[i__1].r = a[i__2].r, a[i__1].i = a[i__2].i; i__1 = kp + k * a_dim1; a[i__1].r = t.r, a[i__1].i = t.i; } /* Convert lower triangle of A into L form by applying */ /* the interchanges in columns 1:k-1. */ if (k > 1) { i__1 = k - 1; zswap_(&i__1, &a[kk + a_dim1], lda, &a[kp + a_dim1], lda); } } /* Update the trailing submatrix */ if (kstep == 1) { /* 1-by-1 pivot block D(k): column k now holds */ /* W(k) = L(k)*D(k) */ /* where L(k) is the k-th column of L */ if (k < *n) { /* Perform a rank-1 update of A(k+1:n,k+1:n) and */ /* store L(k) in column k */ i__1 = k + k * a_dim1; if ((d__1 = a[i__1].r, abs(d__1)) + (d__2 = d_imag(&a[k + k * a_dim1]), abs(d__2)) >= sfmin) { /* Perform a rank-1 update of A(k+1:n,k+1:n) as */ /* A := A - L(k)*D(k)*L(k)**T */ /* = A - W(k)*(1/D(k))*W(k)**T */ z_div(&z__1, &c_b1, &a[k + k * a_dim1]); d11.r = z__1.r, d11.i = z__1.i; i__1 = *n - k; z__1.r = -d11.r, z__1.i = -d11.i; zsyr_(uplo, &i__1, &z__1, &a[k + 1 + k * a_dim1], & c__1, &a[k + 1 + (k + 1) * a_dim1], lda); /* Store L(k) in column k */ i__1 = *n - k; zscal_(&i__1, &d11, &a[k + 1 + k * a_dim1], &c__1); } else { /* Store L(k) in column k */ i__1 = k + k * a_dim1; d11.r = a[i__1].r, d11.i = a[i__1].i; i__1 = *n; for (ii = k + 1; ii <= i__1; ++ii) { i__2 = ii + k * a_dim1; z_div(&z__1, &a[ii + k * a_dim1], &d11); a[i__2].r = z__1.r, a[i__2].i = z__1.i; /* L46: */ } /* Perform a rank-1 update of A(k+1:n,k+1:n) as */ /* A := A - L(k)*D(k)*L(k)**T */ /* = A - W(k)*(1/D(k))*W(k)**T */ /* = A - (W(k)/D(k))*(D(k))*(W(k)/D(K))**T */ i__1 = *n - k; z__1.r = -d11.r, z__1.i = -d11.i; zsyr_(uplo, &i__1, &z__1, &a[k + 1 + k * a_dim1], & c__1, &a[k + 1 + (k + 1) * a_dim1], lda); } /* Store the subdiagonal element of D in array E */ i__1 = k; e[i__1].r = 0., e[i__1].i = 0.; } } else { /* 2-by-2 pivot block D(k): columns k and k+1 now hold */ /* ( W(k) W(k+1) ) = ( L(k) L(k+1) )*D(k) */ /* where L(k) and L(k+1) are the k-th and (k+1)-th columns */ /* of L */ /* Perform a rank-2 update of A(k+2:n,k+2:n) as */ /* A := A - ( L(k) L(k+1) ) * D(k) * ( L(k) L(k+1) )**T */ /* = A - ( ( A(k)A(k+1) )*inv(D(k) ) * ( A(k)A(k+1) )**T */ /* and store L(k) and L(k+1) in columns k and k+1 */ if (k < *n - 1) { i__1 = k + 1 + k * a_dim1; d21.r = a[i__1].r, d21.i = a[i__1].i; z_div(&z__1, &a[k + 1 + (k + 1) * a_dim1], &d21); d11.r = z__1.r, d11.i = z__1.i; z_div(&z__1, &a[k + k * a_dim1], &d21); d22.r = z__1.r, d22.i = z__1.i; z__3.r = d11.r * d22.r - d11.i * d22.i, z__3.i = d11.r * d22.i + d11.i * d22.r; z__2.r = z__3.r - 1., z__2.i = z__3.i + 0.; z_div(&z__1, &c_b1, &z__2); t.r = z__1.r, t.i = z__1.i; i__1 = *n; for (j = k + 2; j <= i__1; ++j) { /* Compute D21 * ( W(k)W(k+1) ) * inv(D(k)) for row J */ i__2 = j + k * a_dim1; z__3.r = d11.r * a[i__2].r - d11.i * a[i__2].i, z__3.i = d11.r * a[i__2].i + d11.i * a[i__2] .r; i__3 = j + (k + 1) * a_dim1; z__2.r = z__3.r - a[i__3].r, z__2.i = z__3.i - a[i__3] .i; z__1.r = t.r * z__2.r - t.i * z__2.i, z__1.i = t.r * z__2.i + t.i * z__2.r; wk.r = z__1.r, wk.i = z__1.i; i__2 = j + (k + 1) * a_dim1; z__3.r = d22.r * a[i__2].r - d22.i * a[i__2].i, z__3.i = d22.r * a[i__2].i + d22.i * a[i__2] .r; i__3 = j + k * a_dim1; z__2.r = z__3.r - a[i__3].r, z__2.i = z__3.i - a[i__3] .i; z__1.r = t.r * z__2.r - t.i * z__2.i, z__1.i = t.r * z__2.i + t.i * z__2.r; wkp1.r = z__1.r, wkp1.i = z__1.i; /* Perform a rank-2 update of A(k+2:n,k+2:n) */ i__2 = *n; for (i__ = j; i__ <= i__2; ++i__) { i__3 = i__ + j * a_dim1; i__4 = i__ + j * a_dim1; z_div(&z__4, &a[i__ + k * a_dim1], &d21); z__3.r = z__4.r * wk.r - z__4.i * wk.i, z__3.i = z__4.r * wk.i + z__4.i * wk.r; z__2.r = a[i__4].r - z__3.r, z__2.i = a[i__4].i - z__3.i; z_div(&z__6, &a[i__ + (k + 1) * a_dim1], &d21); z__5.r = z__6.r * wkp1.r - z__6.i * wkp1.i, z__5.i = z__6.r * wkp1.i + z__6.i * wkp1.r; z__1.r = z__2.r - z__5.r, z__1.i = z__2.i - z__5.i; a[i__3].r = z__1.r, a[i__3].i = z__1.i; /* L50: */ } /* Store L(k) and L(k+1) in cols k and k+1 for row J */ i__2 = j + k * a_dim1; z_div(&z__1, &wk, &d21); a[i__2].r = z__1.r, a[i__2].i = z__1.i; i__2 = j + (k + 1) * a_dim1; z_div(&z__1, &wkp1, &d21); a[i__2].r = z__1.r, a[i__2].i = z__1.i; /* L60: */ } } /* Copy subdiagonal elements of D(K) to E(K) and */ /* ZERO out subdiagonal entry of A */ i__1 = k; i__2 = k + 1 + k * a_dim1; e[i__1].r = a[i__2].r, e[i__1].i = a[i__2].i; i__1 = k + 1; e[i__1].r = 0., e[i__1].i = 0.; i__1 = k + 1 + k * a_dim1; a[i__1].r = 0., a[i__1].i = 0.; } /* End column K is nonsingular */ } /* Store details of the interchanges in IPIV */ if (kstep == 1) { ipiv[k] = kp; } else { ipiv[k] = -p; ipiv[k + 1] = -kp; } /* Increase K and return to the start of the main loop */ k += kstep; goto L40; L64: ; } return 0; /* End of ZSYTF2_RK */ } /* zsytf2_rk__ */
the_stack_data/132952990.c
/*--------------------------------------------------------------------- atol - convert a string to long integer and return it Copyright (C) 1999, Sandeep Dutta . [email protected] This library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this library; see the file COPYING. If not, write to the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. As a special exception, if you link this library with other files, some of which are compiled with SDCC, to produce an executable, this library does not by itself cause the resulting executable to be covered by the GNU General Public License. This exception does not however invalidate any other reasons why the executable file might be covered by the GNU General Public License. -------------------------------------------------------------------------*/ long atol(char * s) { register long rv=0; register char sign = 0; /* skip till we find either a digit or '+' or '-' */ while (*s) { if (*s <= '9' && *s >= '0') break; if (*s == '-' || *s == '+') break; s++; } sign = (*s == '-'); if (*s == '-' || *s == '+') s++; while (*s && *s >= '0' && *s <= '9') { rv = (rv * 10) + (*s - '0'); s++; } return (sign ? -rv : rv); }
the_stack_data/156392150.c
// // Created by Rahul on 6/18/2019. // #include <stdio.h> int main() /*count newline,character,tab*/ { int c,nb/*number of blanck*/,nt,nl; nb=nt=nl=0; while((c=getchar())!=EOF) { if (c == ' ') ++nb; if (c == '\t') ++nt; if (c == '\n') ++nl; } printf("%d %d %d ",nb,nt,nl); }
the_stack_data/888637.c
#include <stdio.h> int main() { int result = 1 == 2; printf("1 equals 2 is %d\n", result); result = 1 != 2; printf("1 not equals 2 is %d\n", result); result = 1 > 2; printf("1 larger than 2 is %d\n", result); result = 1 >= 2; printf("1 larger than or equals 2 is %d\n", result); result = 1 < 2; printf("1 less than 2 is %d\n", result); result = 1 <= 2; printf("1 less than or equals 2 is %d", result); return 0; }
the_stack_data/59512979.c
/*******************************************************************************/ /* Copyright (C) 1994 - 2015, Performance Dynamics Company */ /* */ /* This software is licensed as described in the file COPYING, which */ /* you should have received as part of this distribution. The terms */ /* are also available at http://www.perfdynamics.com/Tools/copyright.html. */ /* */ /* You may opt to use, copy, modify, merge, publish, distribute and/or sell */ /* copies of the Software, and permit persons to whom the Software is */ /* furnished to do so, under the terms of the COPYING file. */ /* */ /* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY */ /* KIND, either express or implied. */ /*******************************************************************************/ /* * $Id$ * * mva.c - Mean Value Analysis algorithm for single class workload * */ #include <stdlib.h> #include <stdio.h> #include <math.h> #define MAXK 6 // max. service centers + 1 double D[MAXK]; // service demand at center k double R[MAXK]; // residence time at center k double Q[MAXK]; // no. customers at center k double Z; // think time (0 for batch system) int K; // no. of queueing centers int N; // no. of customers int main() { int k; char input[8]; double atof(); void mva(); while (1) { printf("\n(Hit RETURN to exit)\n\n"); printf("Enter no. of centers (K): "); gets(input); if (input[0] == '\0') break; else K = atoi(input); for (k = 1; k <= K; k++) { printf("Enter demand at center %d (D[%d]): ", k, k); gets(input); D[k] = atof(input); } printf("Enter think time (Z):"); gets(input); Z = atof(input); while (1) { printf("\n(Hit RETURN to stop)\n"); printf("Enter no. of terminals (N): "); gets(input); if (input[0] == '\0') break; else { N = atoi(input); mva(); } } } return(0); } void mva() { int k; int n; double s; double X; for (k = 1; k <= K; k++) Q[k] = 0.0; for (n = 1; n <= N; n++) { for (k = 1; k <= K; k++) R[k] = D[k] * (1.0 + Q[k]); s = Z; for (k = 1; k <= K; k++) s += R[k]; X = (double) n / s; for (k = 1; k <= K; k++) Q[k] = X * R[k]; } printf(" k Rk Qk Uk\n"); for (k = 1; k <= K; k++) printf("%2d%9.3f%7.3f%7.3f\n", k, R[k], Q[k], X * D[k]); printf("\nX = %7.4f, R = %9.3f\n", X, (double) N / X - Z); }
the_stack_data/161081490.c
// This file is part of CPAchecker, // a tool for configurable software verification: // https://cpachecker.sosy-lab.org // // SPDX-FileCopyrightText: 2007-2020 Dirk Beyer <https://www.sosy-lab.org> // // SPDX-License-Identifier: Apache-2.0 int main() { int a = 6; for(a = 0; a < 6; ++a) { } if(!(a == 6 )) { ERROR: goto ERROR; } return 1; }
the_stack_data/43887673.c
#ifndef NUTILS_H #define NUTILS_H #include <stdint.h> uint16_t carry_around_add(uint16_t a, uint16_t b){ uint32_t c = a+b; return (c & 0xffff) + (c >>16); } uint16_t checksum(uint8_t *msg, int len){ uint16_t s = 0; int i; for(i = 0; i < len ; i+=2){ uint16_t w = (msg[i]<<8) + (msg[i+1]); s = carry_around_add(s, w); } return ~s & 0xffff; } #endif
the_stack_data/218894408.c
#include <stdio.h> #include <stdbool.h> #include <string.h> bool pal_rec_c(char*, int, int); int main(int argc, char **argv) { char *str = argv[1]; int end = strlen(str) - 1; bool c_result = pal_rec_c(str, 0, end); printf("C: %s\n", c_result ? "True": "False"); /* TODO bool s_result = pal_rec_s(str, 0, end); printf("Asm: %s\n", s_result ? "True": "False"); */ return 0; }
the_stack_data/179831759.c
#include <stdlib.h> typedef unsigned long long ULL; ULL back; ULL hpart, lpart; ULL build(long h, long l) { hpart = h; hpart <<= 32; lpart = l; lpart &= 0xFFFFFFFFLL; back = hpart | lpart; return back; } int main() { if (build(0, 1) != 0x0000000000000001LL) abort(); if (build(0, 0) != 0x0000000000000000LL) abort(); if (build(0, 0xFFFFFFFF) != 0x00000000FFFFFFFFLL) abort(); if (build(0, 0xFFFFFFFE) != 0x00000000FFFFFFFELL) abort(); if (build(1, 1) != 0x0000000100000001LL) abort(); if (build(1, 0) != 0x0000000100000000LL) abort(); if (build(1, 0xFFFFFFFF) != 0x00000001FFFFFFFFLL) abort(); if (build(1, 0xFFFFFFFE) != 0x00000001FFFFFFFELL) abort(); if (build(0xFFFFFFFF, 1) != 0xFFFFFFFF00000001LL) abort(); if (build(0xFFFFFFFF, 0) != 0xFFFFFFFF00000000LL) abort(); if (build(0xFFFFFFFF, 0xFFFFFFFF) != 0xFFFFFFFFFFFFFFFFLL) abort(); if (build(0xFFFFFFFF, 0xFFFFFFFE) != 0xFFFFFFFFFFFFFFFELL) abort(); exit(0); }
the_stack_data/40761858.c
#include <stdio.h> int main(){ printf("Hello again\n"); return 1; }
the_stack_data/868371.c
/* * Copyright (C) 2008 The Android Open Source Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include <unistd.h> #include <signal.h> int raise(int signum) { return kill(gettid(), signum); }
the_stack_data/163169.c
/* * Copyright (c) 2006, Swedish Institute of Computer Science * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the Institute 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 INSTITUTE AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE 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. * * This file is part of the Contiki operating system. * * @(#)$Id: gcr.c,v 1.2 2011/01/07 11:55:36 nifi Exp $ */ /** * \file * Implementation of GCR coding/decoding * \author * Joakim Eriksson <[email protected]> * */ /* GCR conversion table - used for converting ordinary byte to 10-bits */ /* (or 4 bits to 5) */ static const unsigned char GCR_encode[16] = { 0x0a, 0x0b, 0x12, 0x13, 0x0e, 0x0f, 0x16, 0x17, 0x09, 0x19, 0x1a, 0x1b, 0x0d, 0x1d, 0x1e, 0x15 }; /* 5 bits > 4 bits (0xff => invalid) */ static const unsigned char GCR_decode[32] = { 0xff, 0xff, 0xff, 0xff, // 0 - 3invalid... 0xff, 0xff, 0xff, 0xff, // 4 - 7 invalid... 0xff, 0x08, 0x00, 0x01, // 8 invalid... 9 = 8, a = 0, b = 1 0xff, 0x0c, 0x04, 0x05, // c invalid... d = c, e = 4, f = 5 0xff, 0xff, 0x02, 0x03, // 10-11 invalid... 0xff, 0x0f, 0x06, 0x07, // 14 invalid... 0xff, 0x09, 0x0a, 0x0b, // 18 invalid... 0xff, 0x0d, 0x0e, 0xff, // 1c, 1f invalid... }; static unsigned char gcr_bits = 0; static unsigned short gcr_val = 0; /* Call before starting encoding or decoding */ void gcr_init() { gcr_val = 0; gcr_bits = 0; } /* Use this to check if encoding / decoding is complete for now */ unsigned char gcr_finished() { return gcr_bits == 0; } /* Encode one character - and store in bits - get encoded with get_encoded */ void gcr_encode(unsigned char raw_data) { gcr_val |= ((GCR_encode[raw_data >> 4u] << 5u ) | GCR_encode[raw_data & 0xf]) << gcr_bits; gcr_bits += 10; } /* Gets the current char of the encoded stream */ unsigned char gcr_get_encoded(unsigned char *raw_data) { if (gcr_bits >= 8) { *raw_data = (unsigned char) (gcr_val & 0xff); gcr_val = gcr_val >> 8u; gcr_bits = gcr_bits - 8; return 1; } return 0; } /* Decode one char - result can be get from get_decoded */ void gcr_decode(unsigned char gcr_data) { gcr_val |= gcr_data << gcr_bits; gcr_bits += 8; } /* check if the current decoded stream is correct */ unsigned char gcr_valid() { if (gcr_bits >= 10) { unsigned short val = gcr_val & 0x3ff; if ((GCR_decode[val >> 5u] << 4u) == 0xff || (GCR_decode[val & 0x1f]) == 0xff) { return 0; } } return 1; } /* gets the decoded stream - if any char is available */ unsigned char gcr_get_decoded(unsigned char *raw_data) { if (gcr_bits >= 10) { unsigned short val = gcr_val & 0x3ff; *raw_data = (unsigned char) ((GCR_decode[val >> 5] << 4) | (GCR_decode[val & 0x1f])); gcr_val = gcr_val >> 10; gcr_bits = gcr_bits - 10; return 1; } return 0; } /* static const char encoded[] = { 0x4a, 0x25, 0xa5, 0xfc, 0x96, 0xff, 0xff, 0xb5, 0xd4, 0x5a, 0xea, 0xff, 0xff, 0xaa, 0xd3, 0xff }; int main(int argc, char **argv) { // unsigned char c[] = "testing gcr 1 2 3 4 5 6..."; unsigned char c[] = { 0, 8, 0xe0, 0x2b, 0xac, 0x10, 0x01, 0x11, 0x50, 0xff, 0xf4, 0xa4, 0x00 }; unsigned char c2[200]; int pos = 0, pos2 = 0, i = 0; printf("Testing GCR on: %s \n", c); gcr_init(); for (i = 0; i < sizeof(c); i++) { gcr_encode(c[i]); while(gcr_get_encoded(&c2[pos])) { printf("%02x=>%02x ", c[i], c2[pos]); pos++; } } printf("\n"); printf("Encoded result %d chars (from %d) \n", pos, i); gcr_init(); for (i = 0; i < pos; i++) { gcr_decode(c2[i]); if(!gcr_valid()) { printf("GCR: not valid\n"); } while(gcr_get_decoded(&c[pos2])) { pos2++; } } printf("GCR: %s\n",c); } */
the_stack_data/525445.c
/*- * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* * tc3 [term] * Dummy program to test out termlib. Input two numbers (row and col) * and it prints out the tgoto string generated. */ #include <stdio.h> char buf[1024]; char *getenv(), *tgetstr(); char *rdchar(); char *tgoto(); char *CM; char cmbuff[30]; char *x; char *UP; char *tgout; main(argc, argv) char **argv; { char *p; int rc; int row, col; if (argc < 2) p = getenv("TERM"); else p = argv[1]; rc = tgetent(buf,p); x = cmbuff; UP = tgetstr("up", &x); printf("UP = %x = ", UP); pr(UP); printf("\n"); if (UP && *UP==0) UP = 0; CM = tgetstr("cm", &x); printf("CM = "); pr(CM); printf("\n"); for (;;) { if (scanf("%d %d", &row, &col) < 2) exit(0); tgout = tgoto(CM, col, row); pr(tgout); printf("\n"); } } pr(p) register char *p; { for (; *p; p++) printf("%s", rdchar(*p)); } /* * rdchar() returns a readable representation of an ASCII character * using ^ for control, ' for meta. */ #include <ctype.h> char *rdchar(c) char c; { static char ret[4]; register char *p = ret; if ((c&0377) > 0177) *p++ = '\''; c &= 0177; if (!isprint(c)) *p++ = '^'; *p++ = (isprint(c) ? c : c^0100); *p = 0; return (ret); }
the_stack_data/178264871.c
#include <stdio.h> #include <stdlib.h> #include <time.h> #include <immintrin.h> /* Use instrcution-based parallelism to improve vertor summation. */ int main() { srand(time(NULL)); int vecLength; printf("Input length of the summed vectors:"); scanf_s("%d", &vecLength); int* vec1_p = (int*)malloc(vecLength * sizeof(int)); int* vec2_p = (int*)malloc(vecLength * sizeof(int)); int* vec3_p = (int*)malloc(vecLength * sizeof(int)); if (vec1_p == NULL || vec2_p == NULL || vec3_p == NULL) { printf("Memory allocation failed.\n"); return 0; } for (int i = 0; i < vecLength; i++) { vec1_p[i] = rand(); vec2_p[i] = rand(); } // get all elements in the vectors. clock_t startTime = clock(); for (int i = 0; i < vecLength; i++) { vec3_p[i] = vec1_p[i] + vec2_p[i]; } clock_t endTime = clock(); double duration = (double)(endTime - startTime) / CLOCKS_PER_SEC; printf("Completed in %lf\n", duration); free(vec1_p); free(vec2_p); free(vec3_p); return 0; }
the_stack_data/26701639.c
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature --include-generated-funcs --replace-value-regex "__omp_offloading_[0-9a-z]+_[0-9a-z]+" "reduction_size[.].+[.]" "pl_cond[.].+[.|,]" --prefix-filecheck-ir-name _ // RUN: %clang_cc1 -verify -triple powerpc64le-unknown-linux-gnu -fopenmp -x c -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK1 // RUN: %clang_cc1 -verify -triple powerpc64le-unknown-linux-gnu -fopenmp-simd -x c -emit-llvm %s -o - | FileCheck %s --implicit-check-not="{{__kmpc|__tgt}}" int a; void foo() { int(*b)[a]; int *(**c)[a]; #pragma omp parallel if (0) b[0][0] = c[0][a][0][a]; } void bar(int n, int *a) { // expected-warning@+1 {{incompatible pointer types initializing 'int (*)[n]' with an expression of type 'int **'}} int(*p)[n] = &a; #pragma omp parallel if(0) // expected-warning@+1 {{comparison of distinct pointer types ('int (*)[n]' and 'int **')}} if (p == &a) { } } // CHECK1-LABEL: define {{[^@]+}}@foo // CHECK1-SAME: () #[[ATTR0:[0-9]+]] { // CHECK1-NEXT: entry: // CHECK1-NEXT: [[B:%.*]] = alloca i32*, align 8 // CHECK1-NEXT: [[C:%.*]] = alloca i32***, align 8 // CHECK1-NEXT: [[DOTTHREADID_TEMP_:%.*]] = alloca i32, align 4 // CHECK1-NEXT: [[DOTBOUND_ZERO_ADDR:%.*]] = alloca i32, align 4 // CHECK1-NEXT: store i32 0, i32* [[DOTBOUND_ZERO_ADDR]], align 4 // CHECK1-NEXT: [[TMP0:%.*]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* @[[GLOB1:[0-9]+]]) // CHECK1-NEXT: [[TMP1:%.*]] = load i32, i32* @a, align 4 // CHECK1-NEXT: [[TMP2:%.*]] = zext i32 [[TMP1]] to i64 // CHECK1-NEXT: [[TMP3:%.*]] = load i32, i32* @a, align 4 // CHECK1-NEXT: [[TMP4:%.*]] = zext i32 [[TMP3]] to i64 // CHECK1-NEXT: call void @__kmpc_serialized_parallel(%struct.ident_t* @[[GLOB1]], i32 [[TMP0]]) // CHECK1-NEXT: store i32 [[TMP0]], i32* [[DOTTHREADID_TEMP_]], align 4 // CHECK1-NEXT: call void @.omp_outlined.(i32* [[DOTTHREADID_TEMP_]], i32* [[DOTBOUND_ZERO_ADDR]], i64 [[TMP2]], i32** [[B]], i64 [[TMP4]], i32**** [[C]]) #[[ATTR2:[0-9]+]] // CHECK1-NEXT: call void @__kmpc_end_serialized_parallel(%struct.ident_t* @[[GLOB1]], i32 [[TMP0]]) // CHECK1-NEXT: ret void // // // CHECK1-LABEL: define {{[^@]+}}@.omp_outlined. // CHECK1-SAME: (i32* noalias [[DOTGLOBAL_TID_:%.*]], i32* noalias [[DOTBOUND_TID_:%.*]], i64 [[VLA:%.*]], i32** nonnull align 8 dereferenceable(8) [[B:%.*]], i64 [[VLA1:%.*]], i32**** nonnull align 8 dereferenceable(8) [[C:%.*]]) #[[ATTR1:[0-9]+]] { // CHECK1-NEXT: entry: // CHECK1-NEXT: [[DOTGLOBAL_TID__ADDR:%.*]] = alloca i32*, align 8 // CHECK1-NEXT: [[DOTBOUND_TID__ADDR:%.*]] = alloca i32*, align 8 // CHECK1-NEXT: [[VLA_ADDR:%.*]] = alloca i64, align 8 // CHECK1-NEXT: [[B_ADDR:%.*]] = alloca i32**, align 8 // CHECK1-NEXT: [[VLA_ADDR2:%.*]] = alloca i64, align 8 // CHECK1-NEXT: [[C_ADDR:%.*]] = alloca i32****, align 8 // CHECK1-NEXT: store i32* [[DOTGLOBAL_TID_]], i32** [[DOTGLOBAL_TID__ADDR]], align 8 // CHECK1-NEXT: store i32* [[DOTBOUND_TID_]], i32** [[DOTBOUND_TID__ADDR]], align 8 // CHECK1-NEXT: store i64 [[VLA]], i64* [[VLA_ADDR]], align 8 // CHECK1-NEXT: store i32** [[B]], i32*** [[B_ADDR]], align 8 // CHECK1-NEXT: store i64 [[VLA1]], i64* [[VLA_ADDR2]], align 8 // CHECK1-NEXT: store i32**** [[C]], i32***** [[C_ADDR]], align 8 // CHECK1-NEXT: [[TMP0:%.*]] = load i64, i64* [[VLA_ADDR]], align 8 // CHECK1-NEXT: [[TMP1:%.*]] = load i32**, i32*** [[B_ADDR]], align 8 // CHECK1-NEXT: [[TMP2:%.*]] = load i64, i64* [[VLA_ADDR2]], align 8 // CHECK1-NEXT: [[TMP3:%.*]] = load i32****, i32***** [[C_ADDR]], align 8 // CHECK1-NEXT: [[TMP4:%.*]] = load i32***, i32**** [[TMP3]], align 8 // CHECK1-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32**, i32*** [[TMP4]], i64 0 // CHECK1-NEXT: [[TMP5:%.*]] = load i32**, i32*** [[ARRAYIDX]], align 8 // CHECK1-NEXT: [[TMP6:%.*]] = load i32, i32* @a, align 4 // CHECK1-NEXT: [[IDXPROM:%.*]] = sext i32 [[TMP6]] to i64 // CHECK1-NEXT: [[TMP7:%.*]] = mul nsw i64 [[IDXPROM]], [[TMP2]] // CHECK1-NEXT: [[ARRAYIDX3:%.*]] = getelementptr inbounds i32*, i32** [[TMP5]], i64 [[TMP7]] // CHECK1-NEXT: [[ARRAYIDX4:%.*]] = getelementptr inbounds i32*, i32** [[ARRAYIDX3]], i64 0 // CHECK1-NEXT: [[TMP8:%.*]] = load i32*, i32** [[ARRAYIDX4]], align 8 // CHECK1-NEXT: [[TMP9:%.*]] = load i32, i32* @a, align 4 // CHECK1-NEXT: [[IDXPROM5:%.*]] = sext i32 [[TMP9]] to i64 // CHECK1-NEXT: [[ARRAYIDX6:%.*]] = getelementptr inbounds i32, i32* [[TMP8]], i64 [[IDXPROM5]] // CHECK1-NEXT: [[TMP10:%.*]] = load i32, i32* [[ARRAYIDX6]], align 4 // CHECK1-NEXT: [[TMP11:%.*]] = load i32*, i32** [[TMP1]], align 8 // CHECK1-NEXT: [[TMP12:%.*]] = mul nsw i64 0, [[TMP0]] // CHECK1-NEXT: [[ARRAYIDX7:%.*]] = getelementptr inbounds i32, i32* [[TMP11]], i64 [[TMP12]] // CHECK1-NEXT: [[ARRAYIDX8:%.*]] = getelementptr inbounds i32, i32* [[ARRAYIDX7]], i64 0 // CHECK1-NEXT: store i32 [[TMP10]], i32* [[ARRAYIDX8]], align 4 // CHECK1-NEXT: ret void // // // CHECK1-LABEL: define {{[^@]+}}@bar // CHECK1-SAME: (i32 signext [[N:%.*]], i32* [[A:%.*]]) #[[ATTR0]] { // CHECK1-NEXT: entry: // CHECK1-NEXT: [[N_ADDR:%.*]] = alloca i32, align 4 // CHECK1-NEXT: [[A_ADDR:%.*]] = alloca i32*, align 8 // CHECK1-NEXT: [[P:%.*]] = alloca i32*, align 8 // CHECK1-NEXT: [[DOTTHREADID_TEMP_:%.*]] = alloca i32, align 4 // CHECK1-NEXT: [[DOTBOUND_ZERO_ADDR:%.*]] = alloca i32, align 4 // CHECK1-NEXT: store i32 0, i32* [[DOTBOUND_ZERO_ADDR]], align 4 // CHECK1-NEXT: [[TMP0:%.*]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* @[[GLOB1]]) // CHECK1-NEXT: store i32 [[N]], i32* [[N_ADDR]], align 4 // CHECK1-NEXT: store i32* [[A]], i32** [[A_ADDR]], align 8 // CHECK1-NEXT: [[TMP1:%.*]] = load i32, i32* [[N_ADDR]], align 4 // CHECK1-NEXT: [[TMP2:%.*]] = zext i32 [[TMP1]] to i64 // CHECK1-NEXT: [[TMP3:%.*]] = bitcast i32** [[A_ADDR]] to i32* // CHECK1-NEXT: store i32* [[TMP3]], i32** [[P]], align 8 // CHECK1-NEXT: call void @__kmpc_serialized_parallel(%struct.ident_t* @[[GLOB1]], i32 [[TMP0]]) // CHECK1-NEXT: store i32 [[TMP0]], i32* [[DOTTHREADID_TEMP_]], align 4 // CHECK1-NEXT: call void @.omp_outlined..1(i32* [[DOTTHREADID_TEMP_]], i32* [[DOTBOUND_ZERO_ADDR]], i64 [[TMP2]], i32** [[P]], i32** [[A_ADDR]]) #[[ATTR2]] // CHECK1-NEXT: call void @__kmpc_end_serialized_parallel(%struct.ident_t* @[[GLOB1]], i32 [[TMP0]]) // CHECK1-NEXT: ret void // // // CHECK1-LABEL: define {{[^@]+}}@.omp_outlined..1 // CHECK1-SAME: (i32* noalias [[DOTGLOBAL_TID_:%.*]], i32* noalias [[DOTBOUND_TID_:%.*]], i64 [[VLA:%.*]], i32** nonnull align 8 dereferenceable(8) [[P:%.*]], i32** nonnull align 8 dereferenceable(8) [[A:%.*]]) #[[ATTR1]] { // CHECK1-NEXT: entry: // CHECK1-NEXT: [[DOTGLOBAL_TID__ADDR:%.*]] = alloca i32*, align 8 // CHECK1-NEXT: [[DOTBOUND_TID__ADDR:%.*]] = alloca i32*, align 8 // CHECK1-NEXT: [[VLA_ADDR:%.*]] = alloca i64, align 8 // CHECK1-NEXT: [[P_ADDR:%.*]] = alloca i32**, align 8 // CHECK1-NEXT: [[A_ADDR:%.*]] = alloca i32**, align 8 // CHECK1-NEXT: store i32* [[DOTGLOBAL_TID_]], i32** [[DOTGLOBAL_TID__ADDR]], align 8 // CHECK1-NEXT: store i32* [[DOTBOUND_TID_]], i32** [[DOTBOUND_TID__ADDR]], align 8 // CHECK1-NEXT: store i64 [[VLA]], i64* [[VLA_ADDR]], align 8 // CHECK1-NEXT: store i32** [[P]], i32*** [[P_ADDR]], align 8 // CHECK1-NEXT: store i32** [[A]], i32*** [[A_ADDR]], align 8 // CHECK1-NEXT: [[TMP0:%.*]] = load i64, i64* [[VLA_ADDR]], align 8 // CHECK1-NEXT: [[TMP1:%.*]] = load i32**, i32*** [[P_ADDR]], align 8 // CHECK1-NEXT: [[TMP2:%.*]] = load i32**, i32*** [[A_ADDR]], align 8 // CHECK1-NEXT: [[TMP3:%.*]] = load i32*, i32** [[TMP1]], align 8 // CHECK1-NEXT: [[TMP4:%.*]] = bitcast i32** [[TMP2]] to i32* // CHECK1-NEXT: [[CMP:%.*]] = icmp eq i32* [[TMP3]], [[TMP4]] // CHECK1-NEXT: br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_END:%.*]] // CHECK1: if.then: // CHECK1-NEXT: br label [[IF_END]] // CHECK1: if.end: // CHECK1-NEXT: ret void // //
the_stack_data/67325243.c
// %%cpp sigqueue.c // %run gcc -g sigqueue.c -o sigqueue.exe // %run ./sigqueue.exe #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <signal.h> #include <assert.h> #include <sys/types.h> #include <sys/wait.h> volatile sig_atomic_t last_signal = 0; static void handler(int signum) { if (signum == SIGUSR1) { printf("Child process: got SIGUSR1\n"); fflush(stdout); } else if (signum == SIGINT) { printf("Child process: got SIGINT, finish\n"); fflush(stdout); exit(0); } else { printf("Child process: got SIGRTMIN\n"); fflush(stdout); } } int main() { assert(SIGRTMIN < SIGRTMAX); sigset_t mask; sigfillset(&mask); sigprocmask(SIG_BLOCK, &mask, NULL); int signals[] = {SIGUSR1, SIGINT, SIGRTMIN, 0}; for (int* signal = signals; *signal; ++signal) { sigaction(*signal, &(struct sigaction){.sa_handler=handler, .sa_flags=SA_RESTART, .sa_mask=mask}, NULL); } sigemptyset(&mask); int parent_pid = getpid(); int child_pid = fork(); assert(child_pid >= 0); if (child_pid == 0) { while (1) { sigsuspend(&mask); } } else { for (int i = 0; i < 10; ++i) assert(kill(child_pid, SIGUSR1) == 0); for (int i = 0; i < 10; ++i) assert(sigqueue(child_pid, SIGRTMIN, (union sigval){0}) == 0); sleep(1); printf("Parent process: Request child finish with SIGINT\n"); fflush(stdout); kill(child_pid, SIGINT); int status; waitpid(child_pid, &status, 0); } return 0; }