file
stringlengths
18
26
data
stringlengths
3
1.04M
the_stack_data/45451188.c
/* Copyright (c) 2018, Electrux All rights reserved. Using the BSD 3-Clause license for the project, main LICENSE file resides in project's root directory. Please read that file and understand the license terms before using or altering the project. */ #include <stdio.h> #include <stdbool.h> #include <string.h> #include <strings.h> #include <time.h> static inline bool is_whitespc( const char c ) { return c == ',' || c == ' ' || c == '\0'; } bool find_in( const char * of, const char * values, bool is_exact_match ) { int len_val = strlen( values ); char tmp_str[ 100 ]; int tmp_ctr = 0; for( int i = 0; i <= len_val; ++i ) { if( is_whitespc( values[ i ] ) ) { if( tmp_ctr == 0 ) continue; tmp_str[ tmp_ctr ] = '\0'; if( is_exact_match ) { if( strcasecmp( of, tmp_str ) == 0 ) return true; } else { if( strncasecmp( of, tmp_str, strlen( tmp_str ) ) == 0 ) return true; } strcpy( tmp_str, "\0" ); tmp_ctr = 0; continue; } tmp_str[ tmp_ctr++ ] = values[ i ]; } return false; } void get_time( char * str ) { time_t t = time( NULL ); struct tm tm = * localtime( & t ); sprintf( str, "%d-%d-%d, %d:%d:%d", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec ); }
the_stack_data/178264673.c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_strdup.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: jwinthei <[email protected]> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2018/10/24 18:26:29 by jwinthei #+# #+# */ /* Updated: 2019/03/27 17:17:50 by jwinthei ### ########.fr */ /* */ /* ************************************************************************** */ #include <stdlib.h> char *ft_strdup(const char *src) { size_t i; char *str; if (!src) return (NULL); i = 0; while (src[i]) i++; if (!(str = (char*)malloc(sizeof(*str) * (i + 1)))) return (NULL); i = 0; while (src[i]) { str[i] = src[i]; i++; } str[i] = '\0'; return (str); }
the_stack_data/45450200.c
// RUN: clang %loadLLOV %s -o /dev/null 2>&1 | FileCheck %s #include <omp.h> #define N 100 int main() { int A[N]; #pragma omp for for (int i = 1; i < N; i++) { A[i] = A[i] + A[i - 1]; } return 0; } // CHECK: Data Race detected // END
the_stack_data/237642203.c
/* * File : app.c * This file is part of RT-Thread RTOS * COPYRIGHT (C) 2006, RT-Thread Development Team * * The license and distribution terms for this file may be * found in the file LICENSE in this distribution or at * http://openlab.rt-thread.com/license/LICENSE * * Change Logs: * Date Author Notes * 2006-10-08 Bernard the first version */ /** * @addtogroup wh44b0 */ /** @{ */ /* application start function */ int rt_application_init() { return 0; /* empty */ } /** @} */
the_stack_data/175142204.c
// https://codecast.france-ioi.org/v5/player?stepperControls=_undo,_redo,_expr,_out,_over&base=https%3A%2F%2Ffioi-recordings.s3.amazonaws.com%2Fdartmouth%2F1518459007239 #include <stdio.h> int main(void) { int sunny = 0; // 0: cloudy, other value (1 for example): sunny int vacation = 0; // 0: working , other value (1 for example): vacation int NOTsunnyANDNOTvacation = !sunny && !vacation; if (NOTsunnyANDNOTvacation) { printf("It's neither sunny nor am I on vacation!\n"); } return 0; }
the_stack_data/569998.c
#include <stdio.h> #include <stdlib.h> void DieWithUserMessage(const char *msg, const char *detail) { fputs(msg, stderr); fputs(": ", stderr); fputs(detail, stderr); fputc('\n', stderr); exit(1); } void DieWithSystemMessage(const char *msg) { perror(msg); exit(1); }
the_stack_data/69789.c
int main(int argc, char* argv[]) { return 0; }
the_stack_data/27905.c
//Balancing parentheses in an Arithmetic Expression. #include<stdio.h> #include<stdlib.h> #include<string.h> #define size 100 int top = -1; int expression[size]; void push(char); char pop(void); void find_top(void); int check_paranthesis(char *); int main() { int i, val=0; char expression[size]; printf("\nEnter an expression :\t"); scanf("%s", expression); val = check_paranthesis(expression); if(val == 1) printf("\nExpression is valid and balanced\n"); else printf("\nExpression is invalid and unbalanced\n"); return 0; } int match_paranthesis(char a, char b) { if(a == '[' && b == ']') return 1; else if(a == '{' && b == '}') return 1; else if(a == '(' && b == ')') return 1; return 0; } int check_paranthesis(char *expression) { int i; char temp; for(i=0; i < strlen(expression); i++) { if((expression[i] == '(') || (expression[i] == '{') || (expression[i] == '[')) push(expression[i]); if((expression[i] == ')') || (expression[i] == '}') || (expression[i] == ']')) { if(top == -1) { printf("\nThe right paranthesis are more than the left paranthesis..\n"); return 0; } else { temp = pop(); if(!match_paranthesis(temp, expression[i])) return 0; } } } if(top == -1) return 1; else return 0; } void push(char a) { if(top == size-1) { printf("\nError: expression overflow..\n"); return; } top++; expression[top] = a; } char pop(void) { if(top == -1) { printf("\nstack is empty\n"); exit(1); } else return (expression[top--]); }
the_stack_data/61075101.c
#include <stdio.h> #define MAX 1024 int arm_strlen(char *s); int main(){ char s[MAX]; scanf("%s", s); printf("%d\n", arm_strlen(s)); return 0; }
the_stack_data/111078008.c
#include<stdio.h> int main() { printf("hello"); return 0; }
the_stack_data/88147.c
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ____ ___ __ _ // / __// o |,'_/ .' \ // / _/ / _,'/ /_n / o / _ __ _ ___ _ _ __ // /_/ /_/ |__,'/_n_/ / \,' /.' \ ,' _/,' \ / |/ / // / \,' // o /_\ `./ o // || / // /_/ /_//_n_//___,'|_,'/_/|_/ // //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Author : Wesley Taylor-Rendal (WTR) // Design history : Review git logs. // Description : Writing a Function in C // Concepts : Program_3.1 is now a function // : - and it's *called* in main // : - no arguements and returns for printMsg //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #include <stdio.h> void printMsg (void) { printf("Programming is fun\n"); } int main(void) { printMsg(); return 0; }
the_stack_data/184516888.c
/* * Benchmarks contributed by Divyesh Unadkat[1,2], Supratik Chakraborty[1], Ashutosh Gupta[1] * [1] Indian Institute of Technology Bombay, Mumbai * [2] TCS Innovation labs, Pune * */ extern void __VERIFIER_error() __attribute__ ((__noreturn__)); extern void __VERIFIER_assume(int); void __VERIFIER_assert(int cond) { if(!(cond)) { ERROR: __VERIFIER_error(); } } extern int __VERIFIER_nondet_int(void); int N; int main() { N = __VERIFIER_nondet_int(); if(N <= 0) return 1; __VERIFIER_assume(N <= 2147483647/sizeof(int)); int i, j; int sum[1]; int a[N]; int b[N]; for (i = 0; i < N; i++) { a[i] = 1; } for (i = 0; i < N; i++) { b[i] = 0; } sum[0] = 0; for (i = 0; i < N; i++) { sum[0] = sum[0] + a[i]; } for (i = 0; i < N; i++) { for (j = 0; j < i; j++) { b[i] = b[i] + sum[0]; } b[i] = b[i] + 1; } for (i = 0; i < N; i++) { __VERIFIER_assert(b[i] == N * i + 1); } }
the_stack_data/153268885.c
/* * Name: Matt Hamrick * ID: 1000433109 * * Description: * runs, in parallel, a user-provided number of child mandel processes to generate * mandel images, starting with a scale of 2, down to the desired scale amount. * * Mandel command for the final image: * ./mandel -s .000025 -y -1.03265 -m 7000 -x -.163013 -W 600 -H 600 * */ #define _GNU_SOURCE #include <stdio.h> #include <unistd.h> #include <sys/wait.h> #include <stdlib.h> #include <errno.h> #include <string.h> #include <stdbool.h> #include <float.h> #include <sys/time.h> // how many total times to run the mandel program. // this can be tweaked to change the number of output images. // If tweaking this, no other changes are needed, and the program // logic will still work as expected. const int maxMandelRuns = 50; // create the mandel program parameters // the 's' param changes for each instance of mandel, // so create a var for its initial and final values char * mandelParamX = "-0.163013"; char * mandelParamY = "-1.03265"; float initialMandelParamS = 2; float finalMandelParamS = 0.000025; char * mandelParamM = "7000"; char * mandelParamW = "600"; char * mandelParamH = "600"; // enable/disable debug output bool DBG = false; // enable/disable timing output bool TIMING = true; // function declarations (implementations after main()) bool validCommand( int, char * ); void runSeries( int ); int main ( int argc, char * argv[] ) { // check the validity of the command, bail-out if it's bad if( !validCommand( argc, argv[1] ) ) { printf("error: please enter a valid number argument, for example: \n"); printf("'mandelseries 10' will run 10 processes\n"); exit(EXIT_FAILURE); } // declare the vars that hold time values, just in case timing has been enabled struct timeval seriesStart; struct timeval seriesEnd; // if this is being timed, get the time value before the series and store it if(TIMING) { gettimeofday( &seriesStart, NULL ); } // user command has been validated, so start the series runSeries( atoi( argv[1] ) ); // if this is being timed, get the time value after series and store it if(TIMING) { gettimeofday( &seriesEnd, NULL ); // if this is being timed, calculate & output the time taken in microseconds to run the computation int computationTime = ( ( seriesEnd.tv_sec - seriesStart.tv_sec ) * 1000000 + ( seriesEnd.tv_usec - seriesStart.tv_usec ) ); printf( "mandelseries: Computed time taken (in usec): %d\n", computationTime ); } if(DBG) { printf("DEBUG: main() exiting...\n"); } exit(EXIT_SUCCESS); } /* * function: * validCommand * * description: * short function that does a couple simple checks on the user input to ensure * it's what is expected (only one actual argument that can be converted to a number). * * parameters: * - int argCount: the count of arguments, including the program name, used to run this program * - char * firstParam, the first parameter provided after the program name on the command line * * returns: * bool: whether the command used to run the program is valid (true) or not (false) */ bool validCommand( int argCount, char * firstParam ) { if( argCount != 2 ) { return false; } if( atoi( firstParam ) < 1 ) { return false; } return true; } /* * function: * runSeries * * description: * primary function that contains all the child process and mandel program logic * * parameters: * - int maxRunningProcs: the number of child processes to run, passed-in via command-line param * * returns: * void */ void runSeries( int maxRunningProcs ) { if(DBG) { printf("DEBUG: in runSeries()\n"); } // calculate the S amount to subtract for each subsequent mandel run // using maxMandelRuns-1 because our first S value is set, so we have max-1 available iterations // to get to our final value float mandelParamSFactor = (initialMandelParamS - finalMandelParamS) / (maxMandelRuns - 1); // create vars to hold the beginning and end of the output bmp filename char * bmpName = "mandel"; char * bmpExtension = ".bmp"; // this string will hold the output image filename // allocate enough bytes to hold the longest filename: mandel##.bmp\0 = 12 chars + \0 char bmpFilename[13]; // initialize counter to track how many images have been created int bmpCount = 0; // initialize counter for how many child procs are running at a time int runningProcs = 0; // this flag controls if the final output string telling the user that we're just waiting // for all child procs to exit will be displayed. We only want to display it once, so this // flag is flipped once the string has been displayed on the console. bool waitingForAllToFinishOutputOnce = false; // begin the outer loop that encompasses all child process creation and mandel runs while(true) { // since this outer loop waits for any children, we only want to break out // if we've reached the max # of images AND there are no more children running if( bmpCount == maxMandelRuns && runningProcs == 0) { if(DBG) { printf("DEBUG->parent: all output files created & and child procs have exited..\n"); printf("DEBUG->parent: exiting outer loop in runSeries()..\n"); } break; } // this inner loop contains the logic for managing the # of active children while(true) { // since the outer loop manages the waiting and iterates until all children // have exited, this condition makes sure this inner loop doesn't create // any more children if the required amount of output files have already // been created, or are being created. // this logic also is what allows the user to enter an amount of child // processes > how many images will be created, and still work properly. // In other words, even if the user requested 60 processes when only 50 are needed, // the logic will not allow any more children to be created once 50 have been reached. if( bmpCount == maxMandelRuns ) { // at this point, we're just waiting for existing children to finish, // so inform the user one time if ( !waitingForAllToFinishOutputOnce ) { // sleep to give the 50th child a little extra time to get started // the sleep helps make sure the printf outputs the string at the very end sleep(1); printf("The last mandel child process has been started. Waiting for all to exit...\n\n"); waitingForAllToFinishOutputOnce = true; } break; } // check if the # of children is the amount the user requested // if not, create another one to do the bidding // if yes, then we break out of this inner while loop and // return control to the outer loop if( runningProcs != maxRunningProcs ) { // do the fork thing errno = 0; pid_t pid = fork(); if( pid == -1 ) { // the call to fork() failed if pid == -1 if(DBG) { printf("ERROR -> after fork(): %d: %s.. exiting...\n", errno, strerror(errno) ); } printf("An error occurred. Please try again\n"); // since fork failed, the logic to exit these loops may never be satisfied, so hard exit exit(EXIT_FAILURE); } else if( pid == 0 ) { // we're in the child process // calculate the new S value each time the loop is run float currentMandelParamS = initialMandelParamS - ( bmpCount * mandelParamSFactor ); // build the filename to be created and sent to the mandel program strcpy( bmpFilename, bmpName ); char bmpNum[2]; sprintf( bmpNum, "%d", bmpCount+1 ); strcat( bmpFilename, bmpNum ); strcat( bmpFilename, bmpExtension ); // command for reference: // mandel -s .000025 -y -1.03265 -m 7000 -x -.163013 -W 600 -H 600 mandel##.bmp // construct the mandel argument list, starting with the less complicated ones char * mandelArgList[16]; mandelArgList[0] = "mandel"; mandelArgList[1] = "-y"; mandelArgList[2] = mandelParamY; mandelArgList[3] = "-m"; mandelArgList[4] = mandelParamM; mandelArgList[5] = "-x"; mandelArgList[6] = mandelParamX; mandelArgList[7] = "-W"; mandelArgList[8] = mandelParamW; mandelArgList[9] = "-H"; mandelArgList[10] = mandelParamH; // since the -s argument value is a calculated float, we need to convert it to char *, // then it can be added to the arg list mandelArgList[11] = "-s"; char argSBuffer[20]; snprintf( argSBuffer, 20, "%f", currentMandelParamS ); mandelArgList[12] = argSBuffer; // finally, add the filename to be output as the 14th and last argument mandelArgList[13] = "-o"; mandelArgList[14] = bmpFilename; // the execvp command expects the argument array to be terminated by a NULL pointer mandelArgList[15] = NULL; if(DBG) { printf("DEBUG->child: command to be run: %s %s %s ",mandelArgList[0],mandelArgList[1],mandelArgList[2]); printf("%s %s %s %s %s ",mandelArgList[3],mandelArgList[4],mandelArgList[5],mandelArgList[6],mandelArgList[7]); printf("%s %s %s %s %s %s\n",mandelArgList[8],mandelArgList[9],mandelArgList[10],mandelArgList[11],mandelArgList[12],mandelArgList[13]); printf("DEBUG->child: calling execv()..\n"); } // reset errno in case of any issues, then run the execvp command, // passing-in the name of the mandel file and the argument list // we just built errno = 0; execvp("./mandel", mandelArgList); if(DBG || errno != 0) { printf( "ERROR -> after execv: %d: %s\n", errno, strerror(errno) ); exit(EXIT_FAILURE); } // the below code was used during testing of the loop logic to force the child processes // to sleep for a varying amount of time, to simulate wait time /*sleep(runningProcs); if(DBG) { printf("DEBUG->child: process for bmp %s exiting..\n", bmpFilename); } exit(EXIT_SUCCESS);*/ } else { // we're in the parent process // increment the running proc count and the bmp count // these are what keep track of how many children are currently running, // and how many output images have been created runningProcs++; bmpCount++; if(DBG) { printf("DEBUG->parent: child %d spawned to create bmp #%d..\n", pid, bmpCount); } } } else { // if we've reached the maximum amount of children procs per the user input, // then break out of the inner loop and give control back to the outer loop break; } // if( runningProcs != maxRunningProcs )..else } // inner while // the outer loop waits for any children processes to exit. // once one has exited, we decrement the counter of running children and the // loop continues, at which point the inner loop will be entered and the check // for how many children are running and how many images have been created will take place // to decide if more need to be created, or if the inner loop exits and returns to this wait() wait(NULL); runningProcs--; } // outer while } // runSeries()
the_stack_data/22014007.c
// Modifies the volume of an audio file #include <stdint.h> #include <stdio.h> #include <stdlib.h> // Number of bytes in .wav header const int HEADER_SIZE = 44; int main(int argc, char *argv[]) { // Check command-line arguments if (argc != 4) { printf("Usage: ./volume input.wav output.wav factor\n"); return 1; } // Open files and determine scaling factor FILE *input = fopen(argv[1], "r"); if (input == NULL) { printf("Could not open file.\n"); return 1; } FILE *output = fopen(argv[2], "w"); if (output == NULL) { printf("Could not open file.\n"); return 1; } float factor = atof(argv[3]); // Copy header from input file to output file uint8_t header[HEADER_SIZE]; // Read 44 bytes from input's header fread(header, HEADER_SIZE, 1, input); // Write 44 new bytes to output's header fwrite(header, HEADER_SIZE, 1, output); // Read samples from input file and write updated data to output file int16_t buffer; // sizeof == size, & == address of while (fread(&buffer, sizeof(int16_t), 1, input)) { // *= == multiply and assign buffer *= factor; fwrite(&buffer, sizeof(int16_t), 1, output); } // Close files fclose(input); fclose(output); }
the_stack_data/111079380.c
/* booksave.c -- saves structure contents in a file */ #include <stdio.h> #include <stdlib.h> #define MAXTITL 40 #define MAXAUTL 40 #define MAXBKS 10 /* maximum number of books */ struct book { /* set up book template */ char title[MAXTITL]; char author[MAXAUTL]; float value; }; int main(void) { struct book library[MAXBKS]; /* array of structures */ int count = 0; int index, filecount; FILE * pbooks; int size = sizeof (struct book); if ((pbooks = fopen("book.dat", "a+b")) == NULL) { fputs("Can't open book.dat file\n",stderr); exit(1); } rewind(pbooks); /* go to start of file */ while (count < MAXBKS && fread(&library[count], size, 1, pbooks) == 1) { if (count == 0) puts("Current contents of book.dat:"); printf("%s by %s: $%.2f\n",library[count].title, library[count].author, library[count].value); count++; } filecount = count; if (count == MAXBKS) { fputs("The book.dat file is full.", stderr); exit(2); } puts("Please add new book titles."); puts("Press [enter] at the start of a line to stop."); while (count < MAXBKS && gets(library[count].title) != NULL && library[count].title[0] != '\0') { puts("Now enter the author."); gets(library[count].author); puts("Now enter the value."); scanf("%f", &library[count++].value); while (getchar() != '\n') continue; /* clear input line */ if (count < MAXBKS) puts("Enter the next title."); } if (count > 0) { puts("Here is the list of your books:"); for (index = 0; index < count; index++) printf("%s by %s: $%.2f\n",library[index].title, library[index].author, library[index].value); fwrite(&library[filecount], size, count - filecount, pbooks); } else puts("No books? Too bad.\n"); puts("Bye.\n"); fclose(pbooks); return 0; }
the_stack_data/61074289.c
/** * @file tst_utils_rtos.c * @author NXP Semiconductors * @version 1.0 * @par License * Copyright 2017,2018 NXP * * This software is owned or controlled by NXP and may only be used * strictly in accordance with the applicable license terms. By expressly * accepting such terms or by downloading, installing, activating and/or * otherwise using the software, you are agreeing that you have read, and * that you agree to comply with and are bound by, such license terms. If * you do not agree to be bound by the applicable license terms, then you * may not retain, install, activate or otherwise use the software. * * @par Description * vApplicationGetIdleTaskMemory and vApplicationGetTimerTaskMemory */ /******************************************************************************* * includes ******************************************************************************/ #ifdef USE_RTOS #include "FreeRTOS.h" #include "task.h" /******************************************************************************* * Definitions ******************************************************************************/ /******************************************************************************* * Static variables ******************************************************************************/ /******************************************************************************* * Global variables ******************************************************************************/ /******************************************************************************* * Global Function Definitions ******************************************************************************/ /* configUSE_STATIC_ALLOCATION is set to 1, so the application must provide an * implementation of vApplicationGetIdleTaskMemory() to provide the memory that is * used by the Idle task. */ void vApplicationGetIdleTaskMemory(StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize) { /* If the buffers to be provided to the Idle task are declared inside this * function then they must be declared static - otherwise they will be allocated on * the stack and so not exists after this function exits. */ static StaticTask_t xIdleTaskTCB; static StackType_t uxIdleTaskStack[configMINIMAL_STACK_SIZE]; /* Pass out a pointer to the StaticTask_t structure in which the Idle * task's state will be stored. */ *ppxIdleTaskTCBBuffer = &xIdleTaskTCB; /* Pass out the array that will be used as the Idle task's stack. */ *ppxIdleTaskStackBuffer = uxIdleTaskStack; /* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer. * Note that, as the array is necessarily of type StackType_t, * configMINIMAL_STACK_SIZE is specified in words, not bytes. */ *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE; } /* configUSE_STATIC_ALLOCATION and configUSE_TIMERS are both set to 1, so the * application must provide an implementation of vApplicationGetTimerTaskMemory() * to provide the memory that is used by the Timer service task. */ void vApplicationGetTimerTaskMemory(StaticTask_t **ppxTimerTaskTCBBuffer, StackType_t **ppxTimerTaskStackBuffer, uint32_t *pulTimerTaskStackSize) { /* If the buffers to be provided to the Timer task are declared inside this * function then they must be declared static - otherwise they will be allocated on * the stack and so not exists after this function exits. */ static StaticTask_t xTimerTaskTCB; static StackType_t uxTimerTaskStack[configTIMER_TASK_STACK_DEPTH]; /* Pass out a pointer to the StaticTask_t structure in which the Timer * task's state will be stored. */ *ppxTimerTaskTCBBuffer = &xTimerTaskTCB; /* Pass out the array that will be used as the Timer task's stack. */ *ppxTimerTaskStackBuffer = uxTimerTaskStack; /* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer. * Note that, as the array is necessarily of type StackType_t, * configTIMER_TASK_STACK_DEPTH is specified in words, not bytes. */ *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH; } #endif /* USE_RTOS */
the_stack_data/31387877.c
/* * Copyright 2015 Frank Hunleth * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <err.h> #include <stdio.h> #include <stdlib.h> #include <string.h> extern int gpio_main(int argc, char *argv[]); extern int i2c_main(int argc, char *argv[]); extern int spi_main(int argc, char *argv[]); int main(int argc, char *argv[]) { if (argc < 2) errx(EXIT_FAILURE, "Must pass mode (e.g. gpio, i2c, spi)"); if (strcmp(argv[1], "gpio") == 0) return gpio_main(argc, argv); else if (strcmp(argv[1], "i2c") == 0) return i2c_main(argc, argv); else if (strcmp(argv[1], "spi") == 0) return spi_main(argc, argv); else errx(EXIT_FAILURE, "Unknown mode '%s'", argv[1]); return 1; }
the_stack_data/68401.c
#include <stdio.h> void replaceAll(char arr[], char oldChar, char newChar) { int i = 0; while(arr[i] != '\0') { if(arr[i] == oldChar) { arr[i] = newChar; } i++; } } int main() { char arr[1000], oldChar, newChar; printf("Enter any string: "); gets(arr); printf("Enter character to replace: "); oldChar = getchar(); getchar(); printf("Enter character to replace \'%c\' with: ", oldChar); newChar = getchar(); printf("\nString before replacing: \n%s", arr); replaceAll(arr, oldChar, newChar); printf("\n\nString after replacing \'%c\' with \'%c\' : \n%s", oldChar, newChar, arr); return 0; }
the_stack_data/40762881.c
/* OpenCL built-in library: printf_constant() Copyright (c) 2013 Pekka Jääskeläinen 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. */ /** * Implementation of printf where the format string * (note, later also %s) reside in the constant address space. * * Implemented as a wrapper that copies the format string to * the private space (0) and calls a system vprintf. */ #include <stdarg.h> #ifdef __TCE_V1__ /* TCE includes need tceops.h to be generated just for _TCE_STDOUT in the stdio.h header. Work around this by hiding the __TCE_V1__ macro. */ #undef __TCE_V1__ /* The newlib headers of TCE expect to see valid long and double (which in 32bit TCE are defined to be 32bit). */ #undef long #define long long #undef double #define double double #endif #include <stdio.h> #define OCL_CONSTANT_AS __attribute__((address_space(3))) int vprintf(const char *, __builtin_va_list); int fflush(FILE *stream); #undef printf #define MAX_FORMAT_STR_SIZE 2048 int _cl_printf(OCL_CONSTANT_AS char* restrict fmt, ...) { /* http://www.pagetable.com/?p=298 */ int retval = 0; va_list ap; va_start(ap, fmt); char format_private[MAX_FORMAT_STR_SIZE]; for (int i = 0; i < MAX_FORMAT_STR_SIZE; ++i) { format_private[i] = fmt[i]; if (fmt[i] == '\0') { break; } } retval = vprintf(format_private, ap); fflush(NULL); va_end(ap); return retval; }
the_stack_data/51183.c
/* This testcase is part of GDB, the GNU debugger. Copyright 2014-2020 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <string.h> struct s { int m; }; struct ss { struct s a; struct s b; }; void init_s (struct s *s, int m) { s->m = m; } void init_ss (struct ss *s, int a, int b) { init_s (&s->a, a); init_s (&s->b, b); } void foo (int x, struct ss ss) { x = ss.a.m; /* break-here */ } int main () { struct ss ss; init_ss (&ss, 1, 2); foo (42, ss); return 0; }
the_stack_data/170452666.c
/* Filename: gtbwtd5.c (the decoder to gtbwt5.c) Description: A Burrows-Wheeler Transform (BWT) Implementation Author: Gerald Tamayo Date: December 22, 2004 This code does not use a *stable* sorting method at all, but simply constructs the index table (while maintaining the stable sort idea) by filling in the index table with the correct indices. */ #include <stdio.h> #include <stdlib.h> #define BWT_SIZE (1<<15) unsigned char *bwt_buf; /* holds the Last Column to process. */ unsigned int index_table[ BWT_SIZE ]; unsigned int freq[ 256 ]; /* the frequency table. */ unsigned int nread = 0; /* function declarations. */ void copyright ( void ); void bwt_decode ( FILE *in, FILE *out ); int main ( int argc, char *argv[] ) { FILE *in, *out; if ( argc != 3 ){ fprintf(stderr, "\n ----[ A Burrows-Wheeler Transform (BWT) Implementation ]----\n"); fprintf(stderr, "\n Usage : gtbwtd5 inputfile outputfile\n"); copyright(); return 0; } in = fopen( argv[1], "rb" ); if ( !in ){ fprintf(stderr, "\n Error opening input file!\n"); return 0; } out = fopen( argv[2], "wb" ); if ( !out ){ fprintf(stderr, "\n Error opening output file!\n"); return 0; } /* dynamically allocate memory for the Last "column" buffer. */ bwt_buf = (unsigned char *) malloc( BWT_SIZE * sizeof(unsigned char)); if ( bwt_buf == NULL ) { fprintf(stderr, "\nAlloc error!"); return (0); } fprintf(stderr, "\n --[ A Burrows-Wheeler Transform (BWT) Implementation ]--\n"); fprintf(stderr, "\n Input filename: %s", argv[1] ); fprintf(stderr, "\n Output filename: %s\n", argv[2] ); fprintf(stderr, "\n BWT Decoding..."); bwt_decode( in, out ); fprintf(stderr, "done.\n" ); copyright(); if ( bwt_buf ) free( bwt_buf ); if ( in ) fclose( in ); if ( out ) fclose( out ); return 0; } /* The decoding function gets a "column" of bytes; records the frequency of the individual bytes; and transforms the frequency table into a *cumulative frequency* table. The index table is then filled in with the correct values (i.e. the indices of the bytes in the Last column), and outputs the corresponding bytes in the First column. */ void bwt_decode ( FILE *in, FILE *out ) { unsigned int i, findex, last_index; unsigned int sum, temp; while ( 1 ) { /* get the size of the block. */ fread ( &nread, sizeof(int), 1, in ); if ( nread == 0 ) break; /* get character input (the last column). */ nread = fread( bwt_buf, 1, nread, in ); /* get the last index "pointer." */ fread ( &last_index, sizeof(int), 1, in ); /* initialize frequency array. */ for ( i = 0; i < 256; i++ ) { freq[i] = 0; } /* ---- count frequency of characters. ---- */ for ( i = 0; i < nread; i++ ) { freq[ bwt_buf[i] ]++; } /* ---- cumulative sum. ---- */ sum = 0; /* after the index_table is filled in, the freq[] array will contain the cumulative sum for all bytes. */ for ( i = 0; i < 256; i++ ) { if ( freq[i] ) { /* only if existent in the last column! */ temp = freq[i]; /* save. */ freq[i] = sum; /* the cumulative sum. */ sum += temp; /* add the current byte's frequency. */ } } /* ---- finally, fill in the index_table. ---- */ for ( i = 0; i < nread; i++ ) { index_table[ freq[bwt_buf[i]]++ ] = i; } /* NOTE: last_index is the row index of the original string in the *sorted* matrix (see gtbwt5.c). */ findex = index_table[last_index]; fprintf(stderr, "\n--[ last index = %6d ]-- ", last_index ); /* output the bytes; reverse BWT. */ while ( nread-- ){ putc( bwt_buf[ findex ], out ); findex = index_table[ findex ]; } } } void copyright ( void ) { fprintf(stderr, "\n Written by: Gerald Tamayo, 2004\n"); }
the_stack_data/656339.c
#include <arpa/inet.h> #include <sys/socket.h> #include <netdb.h> #include <sys/types.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> void setup_addrinfo(struct addrinfo **servinfo, char *hostname, char *port, int flags){ struct addrinfo hints; int rv; memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_INET; hints.ai_socktype = SOCK_STREAM; hints.ai_flags = flags; if((rv = getaddrinfo(hostname, port, &hints, servinfo)) != 0){ fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(rv)); freeaddrinfo(*servinfo); exit(1); } } int get_socket_file_descriptor(char *hostname, char *port){ int sockfd; struct addrinfo *servinfo, *p; char s[INET_ADDRSTRLEN]; setup_addrinfo(&servinfo, hostname, port, 0); // Connect to the first possible result for(p = servinfo; p != NULL; p = p->ai_next){ if((sockfd = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) == -1){ perror("socket"); continue; } if(connect(sockfd, p->ai_addr, p->ai_addrlen) == -1){ close(sockfd); perror("connection"); continue; } break; } if(p == NULL){ fprintf(stderr, "failed to connect\n"); freeaddrinfo(servinfo); exit(1); } inet_ntop(p->ai_family, &(((struct sockaddr_in *)p->ai_addr)->sin_addr), s, sizeof(s)); printf("connecting to %s\n", s); freeaddrinfo(servinfo); return sockfd; } int get_listener_socket_file_descriptor(char *port){ int sockfd; struct addrinfo *servinfo, *p; char s[INET_ADDRSTRLEN]; int yes = 1; setup_addrinfo(&servinfo, NULL, port, AI_PASSIVE); // Bind to the first possible result for(p = servinfo; p != NULL; p = p->ai_next){ if((sockfd = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) == -1){ perror("socket"); continue; } // Allow this port to be reused later if(setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1){ perror("setsockopt"); exit(1); } if(bind(sockfd, p->ai_addr, p->ai_addrlen) == -1){ close(sockfd); perror("connection"); continue; } break; } if(p == NULL){ fprintf(stderr, "%s\n", "server: failed to bind"); exit(1); } inet_ntop(p->ai_family, &(((struct sockaddr_in *)p->ai_addr)->sin_addr), s, sizeof(s)); printf("listening on %s\n", s); freeaddrinfo(servinfo); return sockfd; }
the_stack_data/9084.c
// Some Example C Code #include <stdio.h> int bar(int n) { return n + 20; } int foo(int n) { return bar(n) * 2; } int main(int argc, char ** argv) { printf("%d\n", foo(10)); }
the_stack_data/38849.c
#include <stddef.h> extern void hostcall_test_func_hostcall_error_unwind(void); int main(void) { hostcall_test_func_hostcall_error_unwind(); return 0; }
the_stack_data/319660.c
#include <stdio.h> int compare(unsigned char *x, unsigned char *y, unsigned long long l) { int i; for (i = 0; i < l; ++i) { if(x[i] != y[i]) { return 1; } } return 0; } int run_bench(int (*test_fun)(void), char* description) { printf("%s\n", description); int err = (*test_fun)(); if(err) { printf("Fail in: %s: %d\n", description, err); } return err; } void print_cycles(const char* desc, unsigned long start, unsigned long end) { int cycle_width = 40; unsigned char bar[cycle_width]; unsigned char clear[cycle_width]; int i = 0; for(; i < cycle_width; i++) { bar[i] = ((i+1) % 5) ? '-' : '+'; clear[i] = ' '; } bar[cycle_width - 1] = 0; clear[cycle_width - 1] = 0; int log_2 = 0; unsigned long cycles = end - start; while(cycles >>= 1) { log_2++; } cycles = end - start; double frac = (double) cycles / (double)((unsigned long)1 << log_2); printf("%24s: %.*s%.*s %4.2f * 2^%2d cycles\n", desc, log_2, bar, cycle_width - log_2, clear, frac, log_2); } void print_bytes(const char* desc, unsigned long bytes) { printf("%24s: %24lu B\n", desc, bytes); } void print_number(const char* desc, unsigned long n) { printf("%24s: %24lu\n", desc, n); }
the_stack_data/167331294.c
// License: 0BSD // // Copyright 2022 Raymond Gardner // // Permission to use, copy, modify, and/or distribute this software for any // purpose with or without fee is hereby granted. // // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY // SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR // IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. // #if COUNTSWAPS extern unsigned long long tot_swaps; #endif #define SWAP_INTS // qsort from snippets 1991-10, modified //********************************************************************** // qsort.c -- ANSI Quicksort function // // Public domain by Raymond Gardner, Englewood CO February 1991 // 2021-01-26 rdg revised but should be funtionally the same // // Usage: // qsort(base, nbr_elements, width_bytes, compare_function); // void *base; // size_t nbr_elements, width_bytes; // int (*compare_function)(const void *, const void *); // // Sorts an array starting at base, of length nbr_elements, each // element of size width_bytes, ordered via compare_function, which is // called as (*compare_function)(ptr_to_element1, ptr_to_element2) and // returns < 0 if element1 < element2, 0 if element1 = element2, > 0 // if element1 > element2. Most refinements are due to R. Sedgewick. // See "Implementing Quicksort Programs", Comm. ACM, Oct. 1978, and // Corrigendum, Comm. ACM, June 1979, p. 368. //********************************************************************** #include <stddef.h> // for size_t definition /* ** Compile with -DSWAP_INTS if your machine can access an int at an ** arbitrary location with reasonable efficiency. (Some machines ** cannot access an int at an odd address at all, so be careful.) */ // swap n bytes between a and b static void swap_bytes(char *a, char *b, size_t n) { #if COUNTSWAPS tot_swaps += n; #endif char tmp; do { tmp = *a; *a++ = *b; *b++ = tmp; } while (--n); } #ifdef SWAP_INTS // swap n ints between a and b static void swap_ints(char *ap, char *bp, size_t n) { #if COUNTSWAPS tot_swaps += sizeof(int) * n; #endif int *a = (int *)ap, *b = (int *)bp; int tmp; do { tmp = *a; *a++ = *b; *b++ = tmp; } while (--n); } #define SWAP(a, b) (swap_func((char *)(a), (char *)(b), width)) #else #define SWAP(a, b) (swap_bytes((char *)(a), (char *)(b), size)) #endif #define COMP(a, b) ((*comp)((void *)(a), (void *)(b))) #define T 15 // subfiles of T or fewer elements will // be sorted by a simple insertion sort // Note! T must be at least 3 void qsort(void *basep, size_t nelems, size_t size, int (*comp)(const void *, const void *)) { char *stack[2*8*sizeof(size_t)], **sp; // stack and stack pointer char *i, *j, *limit; // scan and limit pointers char *base; // base pointer as char * #ifdef SWAP_INTS size_t width; // width of array element void (*swap_func)(char *, char *, size_t); // swap function pointer width = size; // save size for swap routine swap_func = swap_bytes; // choose swap function if (size % sizeof(int) == 0) { // size is multiple of ints width /= sizeof(int); // set width in ints swap_func = swap_ints; // use int swap function } #endif base = (char *)basep; // set up char * base pointer sp = stack; // init stack pointer limit = base + nelems * size; // pointer past end of array for (;;) { if ((size_t)(limit - base) / size > T) { // if > T elements // swap base with middle SWAP((((limit - base) / size) / 2) * size + base, base); i = base + size; // i scans left to right j = limit - size; // j scans right to left if (COMP(i, j) > 0) // Sedgewick's SWAP(i, j); // three-element sort if (COMP(base, j) > 0) // sets things up SWAP(base, j); // so that if (COMP(i, base) > 0) // *i <= *base <= *j SWAP(i, base); // *base is pivot element for (;;) { while (COMP(i += size, base) < 0) // move i right until ; // *i >= pivot while (COMP(j -= size, base) > 0) // move j left until ; // *j <= pivot if (i > j) // if pointers crossed break; // break loop SWAP(i, j); // else swap elements, keep scanning } SWAP(base, j); // move pivot into correct place if (j - base > limit - i) { // if left subfile larger sp[0] = base; // stack left subfile base sp[1] = j; // and limit base = i; // sort the right subfile } else { // else right subfile larger sp[0] = i; // stack right subfile base sp[1] = limit; // and limit limit = j; // sort the left subfile } sp += 2; // increment stack pointer } else { // else subfile is small, use insertion sort for (i = base + size; i < limit; i += size) for (j = i; j != base && COMP(j - size, j) > 0; j -= size) SWAP(j - size, j); if (sp != stack) { // if any entries on stack sp -= 2; // pop the base and limit base = sp[0]; limit = sp[1]; } else // else stack empty, done break; } } }
the_stack_data/132951949.c
int blah(void); ; // empty! struct some { ; // empty }; int main() { }
the_stack_data/154827611.c
#include<stdio.h> #include<stdlib.h> #include<string.h> #include<omp.h> #define NUM_THREADS 4 int count=0; void search(char *t,int start,int end,char *p) { int i,j; int n=end-start+1; int m=strlen(p); for(i=start;i<=end-m;i++) { for(j=0;j<m;j++) if(t[i+j]!=p[j]) break; if(j==m){ printf("pattern found at index %d\n",i); count++; } } return; } int main() { char pat[10]; char *text; int n,m,i=0; size_t size = 0; FILE *fp = fopen("gene.txt", "r"); fseek(fp, 0, SEEK_END); size = ftell(fp); rewind(fp); text = malloc((size + 1) * sizeof(*text)); fread(text, size, 1, fp); text[size] = '\0'; scanf("%s",pat); int lenp=strlen(pat); int bs=strlen(text)/NUM_THREADS; int rem=strlen(text)%NUM_THREADS; int tid,start,end; #pragma omp parallel num_threads(NUM_THREADS) private(tid,start,end) shared(text,pat,rem,bs,m) { tid=omp_get_thread_num(); if(tid==0) { #pragma omp critical (part1) { start=tid; end=bs-1; search(text,start,end,pat); } } else { #pragma omp critical (part2) { start=(tid*bs)-lenp; end=(tid*bs)+bs-1; search(text,start,end,pat); } } } if(rem!=0) search(text,(NUM_THREADS+1)*bs,strlen(text),pat); printf("Total number of matches = %d\n",count ); return 0; }
the_stack_data/116936.c
#include <stdio.h> #include <stdlib.h> /* Plinth additions */ void mps_lib_abort(void) { fflush(stdout); abort(); } int mps_lib_fputs_(const char *s, int end, FILE *stream) { // We know that on Unix, stream is just a FILE*. int i = 0; char c; while ((i < end) && (c = s[i++])) { fputc(c, (FILE *)stream); } return 1; }
the_stack_data/96383.c
#include <string.h> void* memmove(void* dstptr, const void* srcptr, size_t size) { unsigned char* dst = (unsigned char*) dstptr; const unsigned char* src = (const unsigned char*) srcptr; if (dst < src) { for (size_t i = 0; i < size; i++) dst[i] = src[i]; } else { for (size_t i = size; i != 0; i--) dst[i-1] = src[i-1]; } return dstptr; }
the_stack_data/62637570.c
// ----------------------------------------------------------------------------- // Test case for probabilistic symbolic simulation. sort.c // C program to sort the array in an // ascending order using selection sort // Created by Ferhat Erata <[email protected]> on November 09, 2020. // Copyright (c) 2021 Yale University. All rights reserved. // ----------------------------------------------------------------------------- #include <stdio.h> __attribute__((always_inline)) inline void swap(int* xp, int* yp) { int temp = *xp; *xp = *yp; *yp = temp; } /* Function to perform Selection Sort */ __attribute__((always_inline)) inline void selectionSort(int arr[], int n) { //#pragma distribution parameter "arr <- env(`0`=5, `1`=14, `2`=18, `3`=9)" #pragma distribution parameter "arr <- galloc(\"[4 x i32]\", 5, 14, 18, 9)" #pragma distribution parameter "n <- 4" // One by one move boundary of unsorted subarray for (int i = 0; i < n - 1; i++) { // Find the minimum element in unsorted array int min_idx = i; for (int j = i + 1; j < n; j++) if (arr[j] < arr[min_idx]) min_idx = j; // Swap the found minimum element with the first element swap(&arr[min_idx], &arr[i]); } } /* Function to sort an array using insertion sort*/ __attribute__((always_inline)) inline void insertionSort(int arr[], int n) { //#pragma distribution parameter "arr <- env(`0`=5, `1`=14, `2`=18, `3`=9)" #pragma distribution parameter "arr <- galloc(\"[4 x i32]\", 5, 14, 18, 9)" #pragma distribution parameter "n <- 4" int key, j; for (int i = 1; i < n; i++) { key = arr[i]; j = i - 1; /* Move elements of arr[0..i-1], that are greater than key, to one position ahead of their current position */ while (j >= 0 && arr[j] > key) { arr[j + 1] = arr[j]; j = j - 1; } arr[j + 1] = key; } } __attribute__((always_inline)) inline int partition(int arr[], int l, int h) { int x = arr[h]; int i = (l - 1); for (int j = l; j <= h - 1; j++) { if (arr[j] <= x) { i++; swap(&arr[i], &arr[j]); } } swap(&arr[i + 1], &arr[h]); return (i + 1); } __attribute__((always_inline)) inline void quickSort(int arr[], int l, int h) { // Create an auxiliary stack int stack[h - l + 1]; // initialize top of stack int top = -1; // push initial values of l and h to stack stack[++top] = l; stack[++top] = h; // Keep popping from stack while is not empty while (top >= 0) { // Pop h and l h = stack[top--]; l = stack[top--]; // Set pivot element at its correct position in sorted array int p = partition(arr, l, h); // If there are elements on left side of pivot, then push left side to stack if (p - 1 > l) { stack[++top] = l; stack[++top] = p - 1; } // If there are elements on right side of pivot, then push right side to // stack if (p + 1 < h) { stack[++top] = p + 1; stack[++top] = h; } } } // Function to print an array __attribute__((always_inline)) inline void printArray(int arr[], int size) { for (int i = 0; i < size; i++) printf("%d ", arr[i]); printf("\n"); } // Driver code int main() { int arr1[] = {87, 13, 55, 43, 41, 71, 76, 69, 69, 85, 61, 80, 58, 77, 96, 38, 8, 45, 98, 35, 77, 93, 7, 2, 55, 56, 73, 47, 8, 27, 28, 12, 39, 4, 43, 40, 18, 90, 68, 17, 13, 99, 80, 23, 97, 25, 85, 2, 22, 71, 56, 12, 1, 82, 77, 50, 5, 40, 88, 63, 83, 33, 84, 2, 95, 63, 40, 37, 16, 51, 21, 18, 45, 14, 97, 45, 5, 16, 57, 26, 37, 1, 59, 66, 46, 21, 93, 69, 52, 80, 81, 84, 60, 31, 41, 4, 6, 79, 80, 2, 32, 21, 58, 85, 13, 17, 25, 76, 91, 47, 74, 83, 81, 25, 27, 48, 91, 44, 10, 58, 70, 30, 7, 98, 64, 84, 66, 86, 87, 39, 5, 90, 15, 4, 60, 88, 26, 16, 33, 42, 85, 99, 93, 22, 97, 20, 45, 59, 47, 77, 4, 11, 79, 58, 20, 34, 92, 27, 95, 97, 74, 23, 9, 1, 40, 90, 83, 39, 58, 27, 20, 83, 57, 69, 40, 85, 49, 89, 63, 64, 81, 89, 37, 74, 83, 81, 31, 21, 87, 6, 55, 65, 77, 90, 75, 45, 26, 69, 42, 69, 77, 78, 18, 34, 18, 99, 81, 96, 39, 50, 85, 36, 90, 6, 33, 46, 16, 92, 84, 41, 13, 56, 13, 14, 55, 72, 30, 74, 45, 35, 63, 44, 17, 48, 76, 80, 85, 39, 94, 1, 72, 97, 41, 59, 73, 79, 12, 90, 5, 6, 41, 4, 75, 64, 8, 16}; int arr2[] = { 60, 25, 53, 7, 18, 90, 54, 40, 35, 63, 9, 68, 31, 32, 79, 83, 45, 37, 92, 53, 78, 77, 27, 90, 57, 96, 8, 14, 30, 44, 64, 61, 81, 31, 12, 73, 46, 66, 77, 6, 54, 44, 11, 41, 80, 48, 77, 78, 31, 38, 65, 97, 98, 17, 16, 8, 32, 82, 30, 40, 24, 93, 22, 53, 10, 65, 38, 46, 44, 3, 26, 42, 22, 85, 97, 19, 19, 8, 65, 72, 70, 22, 36, 30, 82, 22, 53, 53, 25, 83, 59, 58, 24, 92, 13, 67, 55, 53, 56, 3, 86, 48, 83, 95, 27, 67, 74, 16, 38, 30, 97, 26, 16, 93, 18, 6, 70, 98, 48, 34, 41, 50, 5, 35, 77, 35, 54, 21, 6, 80, 96, 64, 14, 77, 99, 94, 60, 68, 81, 40, 38, 54, 69, 73, 72, 19, 23, 2, 49, 97, 75, 58, 94, 6, 87, 81, 9, 5, 86, 76, 25, 13, 10, 28, 29, 64, 96, 6, 35, 64, 84, 96, 77, 38, 65, 48, 83, 11, 97, 18, 94, 84, 2, 94, 46, 42, 86, 84, 89, 2, 70, 10, 75, 55, 30, 62, 50, 66, 76, 31, 99, 56, 84, 51, 23, 99, 65, 85, 46, 7, 23, 51, 11, 14, 72, 81, 56, 60, 100, 93, 100, 83, 78, 27, 31, 73, 50, 45, 30, 41, 69, 63, 52, 24, 1, 8, 4, 76, 27, 51, 61, 17, 94, 47, 50, 62, 59, 63, 75, 41, 49, 59, 64, 5, 18, 21}; int arr3[] = { 78, 99, 94, 81, 65, 61, 88, 3, 34, 37, 71, 24, 13, 16, 16, 90, 55, 52, 84, 36, 59, 77, 44, 88, 15, 15, 70, 64, 21, 93, 30, 96, 65, 83, 40, 98, 89, 29, 28, 64, 35, 20, 61, 18, 18, 83, 89, 34, 57, 4, 81, 33, 94, 96, 20, 83, 52, 57, 36, 35, 87, 49, 79, 35, 49, 83, 16, 74, 63, 79, 73, 14, 97, 13, 2, 29, 36, 20, 60, 61, 59, 45, 16, 36, 97, 35, 85, 98, 59, 23, 76, 44, 80, 36, 13, 22, 65, 45, 47, 86, 43, 99, 77, 25, 4, 45, 32, 10, 37, 29, 71, 28, 95, 4, 1, 8, 54, 43, 77, 94, 87, 65, 83, 98, 24, 99, 27, 68, 17, 80, 98, 50, 30, 2, 35, 19, 89, 39, 84, 21, 43, 53, 97, 60, 36, 27, 73, 80, 37, 98, 17, 43, 75, 27, 21, 52, 17, 38, 1, 93, 27, 84, 41, 19, 89, 98, 27, 15, 3, 60, 43, 21, 7, 95, 33, 27, 52, 79, 18, 94, 53, 17, 56, 2, 40, 97, 82, 14, 81, 37, 10, 21, 70, 69, 40, 48, 68, 9, 60, 88, 62, 91, 70, 32, 21, 72, 29, 81, 17, 16, 43, 71, 98, 20, 100, 65, 80, 56, 76, 87, 93, 64, 71, 48, 14, 60, 36, 68, 6, 82, 77, 23, 58, 68, 9, 24, 13, 91, 51, 10, 16, 30, 18, 78, 45, 42, 93, 93, 13, 94, 14, 63, 88, 30, 59, 17}; int n = sizeof(arr1) / sizeof(arr1[0]); printf("Original array: \n"); printArray(arr1, n); selectionSort(arr1, n); printf("\nInsertion Sorted array in Ascending order: \n"); printArray(arr1, n); printArray(arr2, n); insertionSort(arr2, n); printf("\nSelection Sorted array in Ascending order: \n"); printArray(arr2, n); printArray(arr3, n); quickSort(arr3, 0, n - 1); printf("\nQuick Sorted array in Ascending order: \n"); printArray(arr3, n); // return the last element which should be the biggest one return arr1[n - 1]; // 0 9 12 14 23 }
the_stack_data/154828607.c
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> #include <sys/mman.h> #include <sys/stat.h> int main (void) { int i; i = shm_open ("/tmp/shared", O_CREAT | O_EXCL, S_IRUSR | S_IWUSR); printf ("shm_open rc = %d\n", i); shm_unlink ("/tmp/shared"); return (0); }
the_stack_data/243893729.c
/* 输入学生成绩,如果大于等于80输出“优秀”,70~79输出“良好”,60~69输出“及格”,低于60输出“不及格”。 */ #include <stdio.h> int main(void) { double score; printf("请输入学生成绩:"); scanf("%lf", &score); if (score >= 80) { printf("优秀\n"); } else if (score >= 70) { printf("良好\n"); } else if (score >= 60) { printf("及格\n"); } else { printf("不及格\n"); } return 0; }
the_stack_data/62638566.c
#include <stdbool.h> void suspend_power_down(void) {} bool suspend_wakeup_condition(void) { return true; } void suspend_wakeup_init(void) {}
the_stack_data/99395.c
#include <stdio.h> #include <memory.h> int arr[501][501]; int dp[501][501]; int x, y; int dfs(int n, int m) { if(dp[n][m] != -1) return dp[n][m]; if(n < 0 || m < 0 || n >= x || m >= y) return 0; if(n == 0 && m == 0) return 1; dp[n][m] = 0; if(arr[n][m] < arr[n+1][m]) dp[n][m] += dfs(n+1, m); if(arr[n][m] < arr[n][m+1]) dp[n][m] += dfs(n, m+1); if(arr[n][m] < arr[n][m-1]) dp[n][m] += dfs(n, m-1); if(arr[n][m] < arr[n-1][m]) dp[n][m] += dfs(n-1, m); return dp[n][m]; } int main() { scanf("%d%d", &x, &y); for(int i = 0; i < x; i++) { for(int j = 0; j < y; j++) { scanf("%d", &arr[i][j]); } } memset(dp, -1, sizeof(dp)); printf("%d", dfs(x-1, y-1)); return 0; }
the_stack_data/119920.c
// RUN: rm -rf %t* // RUN: 3c -base-dir=%S -addcr -alltypes %s -- | FileCheck -match-full-lines -check-prefixes="CHECK_ALL","CHECK" %s // RUN: 3c -base-dir=%S -addcr %s -- | FileCheck -match-full-lines -check-prefixes="CHECK_NOALL","CHECK" %s // RUN: 3c -base-dir=%S -addcr %s -- | %clang -c -fcheckedc-extension -x c -o /dev/null - // RUN: 3c -base-dir=%S -alltypes -output-dir=%t.checked %s -- // RUN: 3c -base-dir=%t.checked -alltypes %t.checked/multivardecls.c -- | diff %t.checked/multivardecls.c - #include <stddef.h> #include <stdlib.h> void test() { int *a = (int *)0, *b = (int *)0; //CHECK: _Ptr<int> a = (_Ptr<int>)0; //CHECK: _Ptr<int> b = (_Ptr<int>)0; int *c = (int *)1, *d = (int *){0}; //CHECK: int *c = (int *)1; //CHECK: _Ptr<int> d = (_Ptr<int>){0}; int *e, *f = malloc(sizeof(int)); //CHECK: _Ptr<int> e = ((void *)0); //CHECK: _Ptr<int> f = malloc<int>(sizeof(int)); int g[1] = {*&(int){1}}, *h; //CHECK_ALL: int g _Checked[1] = {*&(int){1}}; //CHECK_NOALL: int g[1] = {*&(int){1}}; //CHECK: _Ptr<int> h = ((void *)0); float *i = 1, j = 0, *k = (float *){0}, l; //CHECK: float *i = 1; //CHECK: float j = 0; //CHECK: _Ptr<float> k = (_Ptr<float>){0}; //CHECK: float l; int m = 1, *n = &m; //CHECK: int m = 1, *n = &m; n++; int o, p[1], q[] = {1, 2}, r[1][1], *s; //CHECK: int o; //CHECK_ALL: int p _Checked[1]; //CHECK_NOALL: int p[1]; //CHECK_ALL: int q _Checked[] = {1, 2}; //CHECK_NOALL: int q[] = {1, 2}; //CHECK_ALL: int r _Checked[1] _Checked[1]; //CHECK_NOALL: int r[1][1]; //CHECK: _Ptr<int> s = ((void *)0); int *t[1], *u = malloc(2 * sizeof(int)), *v; //CHECK_ALL: _Ptr<int> t _Checked[1] = {((void *)0)}; //CHECK_NOALL: int *t[1]; //CHECK_ALL: _Ptr<int> u = malloc<int>(2 * sizeof(int)); //CHECK_NOALL: int *u = malloc<int>(2 * sizeof(int)); //CHECK: _Ptr<int> v = ((void *)0); int *w = (int *)0, *x = (int *)0, *z = (int *)1; //CHECK: _Ptr<int> w = (_Ptr<int>)0; //CHECK: int *x = (int *)0; //CHECK: int *z = (int *)1; x = (int *)1; //CHECK: x = (int *)1; } void test2() { int a, b[1][1], *c; // CHECK: int a; // CHECK_ALL: int b _Checked[1] _Checked[1]; // CHECK_NOALL: int b[1][1]; // CHECK: _Ptr<int> c = ((void *)0); int e[1][1], *f, *g[1] = {(int *)0}; // CHECK_ALL: int e _Checked[1] _Checked[1]; // CHECK_NOALL: int e[1][1]; // CHECK: _Ptr<int> f = ((void *)0); // CHECK_ALL: _Ptr<int> g _Checked[1] = {(_Ptr<int>)0}; // CHECK_NOALL: int *g[1] = {(int *)0}; int h, (*i)(int), *j, (*k)(int); // CHECK: int h; // CHECK: _Ptr<int (int)> i = ((void *)0); // CHECK: _Ptr<int> j = ((void *)0); // CHECK: int (*k)(int); k = 1; } void test3() { int *a, b; // CHECK: _Ptr<int> a = ((void *)0); // CHECK: int b; int *c, d; // CHECK: _Ptr<int> c = ((void *)0); // CHECK: int d; int *e, f; // CHECK: _Ptr<int> e = ((void *)0); // CHECK: int f; int *h, g; // CHECK: _Ptr<int> h = ((void *)0); // CHECK: int g; } void test4() { struct foo { int *a, b; // CHECK: _Ptr<int> a; // CHECK: int b; int c, *d; // CHECK: int c; // CHECK: _Ptr<int> d; int *f, **g; // CHECK: _Ptr<int> f; // CHECK: _Ptr<_Ptr<int>> g; }; } int *a; int b; int **c; // CHECK: _Ptr<int> a = ((void *)0); // CHECK: int b; // CHECK: _Ptr<_Ptr<int>> c = ((void *)0); int *d, e, **f; // CHECK: _Ptr<int> d = ((void *)0); // CHECK: int e; // CHECK: _Ptr<_Ptr<int>> f = ((void *)0); void test5() { int *a, *b; int *c, *e; struct foo { int a, *b; int *c, *d; }; } // CHECK: _Ptr<int> a = ((void *)0); // CHECK: _Ptr<int> b = ((void *)0); // CHECK: _Ptr<int> c = ((void *)0); // CHECK: _Ptr<int> e = ((void *)0); // CHECK: struct foo { // CHECK: int a; // CHECK: _Ptr<int> b; // CHECK: _Ptr<int> c; // CHECK: _Ptr<int> d; // CHECK: };
the_stack_data/6092.c
#define NULL ((void*)0) typedef unsigned long size_t; // Customize by platform. typedef long intptr_t; typedef unsigned long uintptr_t; typedef long scalar_t__; // Either arithmetic or pointer type. /* By default, we understand bool (as a convenience). */ typedef int bool; #define false 0 #define true 1 /* Forward declarations */ /* Type definitions */ typedef scalar_t__ tree ; typedef enum tree_code { ____Placeholder_tree_code } tree_code ; /* Variables and functions */ int COMPLEX_TYPE ; scalar_t__ DECIMAL_FLOAT_TYPE_P (scalar_t__) ; int INTEGER_TYPE ; scalar_t__ NULL_TREE ; int REAL_TYPE ; int TREE_CODE (scalar_t__) ; scalar_t__ TREE_TYPE (scalar_t__) ; scalar_t__ TYPE_ATTRIBUTES (scalar_t__) ; scalar_t__ TYPE_MAIN_VARIANT (scalar_t__) ; scalar_t__ TYPE_PRECISION (scalar_t__) ; scalar_t__ TYPE_QUALS (scalar_t__) ; scalar_t__ TYPE_UNQUALIFIED ; scalar_t__ TYPE_UNSIGNED (scalar_t__) ; int VECTOR_TYPE ; scalar_t__ build_complex_type (scalar_t__) ; scalar_t__ build_type_attribute_variant (scalar_t__,scalar_t__) ; scalar_t__ dfloat128_type_node ; scalar_t__ dfloat32_type_node ; scalar_t__ dfloat64_type_node ; int /*<<< orphan*/ error (char*) ; scalar_t__ error_mark_node ; int /*<<< orphan*/ gcc_assert (int) ; scalar_t__ long_double_type_node ; scalar_t__ long_integer_type_node ; scalar_t__ long_long_integer_type_node ; scalar_t__ long_long_unsigned_type_node ; scalar_t__ long_unsigned_type_node ; __attribute__((used)) static tree c_common_type (tree t1, tree t2) { enum tree_code code1; enum tree_code code2; /* If one type is nonsense, use the other. */ if (t1 == error_mark_node) return t2; if (t2 == error_mark_node) return t1; if (TYPE_QUALS (t1) != TYPE_UNQUALIFIED) t1 = TYPE_MAIN_VARIANT (t1); if (TYPE_QUALS (t2) != TYPE_UNQUALIFIED) t2 = TYPE_MAIN_VARIANT (t2); if (TYPE_ATTRIBUTES (t1) != NULL_TREE) t1 = build_type_attribute_variant (t1, NULL_TREE); if (TYPE_ATTRIBUTES (t2) != NULL_TREE) t2 = build_type_attribute_variant (t2, NULL_TREE); /* Save time if the two types are the same. */ if (t1 == t2) return t1; code1 = TREE_CODE (t1); code2 = TREE_CODE (t2); gcc_assert (code1 == VECTOR_TYPE || code1 == COMPLEX_TYPE || code1 == REAL_TYPE || code1 == INTEGER_TYPE); gcc_assert (code2 == VECTOR_TYPE || code2 == COMPLEX_TYPE || code2 == REAL_TYPE || code2 == INTEGER_TYPE); /* When one operand is a decimal float type, the other operand cannot be a generic float type or a complex type. We also disallow vector types here. */ if ((DECIMAL_FLOAT_TYPE_P (t1) || DECIMAL_FLOAT_TYPE_P (t2)) && !(DECIMAL_FLOAT_TYPE_P (t1) && DECIMAL_FLOAT_TYPE_P (t2))) { if (code1 == VECTOR_TYPE || code2 == VECTOR_TYPE) { error ("can%'t mix operands of decimal float and vector types"); return error_mark_node; } if (code1 == COMPLEX_TYPE || code2 == COMPLEX_TYPE) { error ("can%'t mix operands of decimal float and complex types"); return error_mark_node; } if (code1 == REAL_TYPE && code2 == REAL_TYPE) { error ("can%'t mix operands of decimal float and other float types"); return error_mark_node; } } /* If one type is a vector type, return that type. (How the usual arithmetic conversions apply to the vector types extension is not precisely specified.) */ if (code1 == VECTOR_TYPE) return t1; if (code2 == VECTOR_TYPE) return t2; /* If one type is complex, form the common type of the non-complex components, then make that complex. Use T1 or T2 if it is the required type. */ if (code1 == COMPLEX_TYPE || code2 == COMPLEX_TYPE) { tree subtype1 = code1 == COMPLEX_TYPE ? TREE_TYPE (t1) : t1; tree subtype2 = code2 == COMPLEX_TYPE ? TREE_TYPE (t2) : t2; tree subtype = c_common_type (subtype1, subtype2); if (code1 == COMPLEX_TYPE && TREE_TYPE (t1) == subtype) return t1; else if (code2 == COMPLEX_TYPE && TREE_TYPE (t2) == subtype) return t2; else return build_complex_type (subtype); } /* If only one is real, use it as the result. */ if (code1 == REAL_TYPE && code2 != REAL_TYPE) return t1; if (code2 == REAL_TYPE && code1 != REAL_TYPE) return t2; /* If both are real and either are decimal floating point types, use the decimal floating point type with the greater precision. */ if (code1 == REAL_TYPE && code2 == REAL_TYPE) { if (TYPE_MAIN_VARIANT (t1) == dfloat128_type_node || TYPE_MAIN_VARIANT (t2) == dfloat128_type_node) return dfloat128_type_node; else if (TYPE_MAIN_VARIANT (t1) == dfloat64_type_node || TYPE_MAIN_VARIANT (t2) == dfloat64_type_node) return dfloat64_type_node; else if (TYPE_MAIN_VARIANT (t1) == dfloat32_type_node || TYPE_MAIN_VARIANT (t2) == dfloat32_type_node) return dfloat32_type_node; } /* Both real or both integers; use the one with greater precision. */ if (TYPE_PRECISION (t1) > TYPE_PRECISION (t2)) return t1; else if (TYPE_PRECISION (t2) > TYPE_PRECISION (t1)) return t2; /* Same precision. Prefer long longs to longs to ints when the same precision, following the C99 rules on integer type rank (which are equivalent to the C90 rules for C90 types). */ if (TYPE_MAIN_VARIANT (t1) == long_long_unsigned_type_node || TYPE_MAIN_VARIANT (t2) == long_long_unsigned_type_node) return long_long_unsigned_type_node; if (TYPE_MAIN_VARIANT (t1) == long_long_integer_type_node || TYPE_MAIN_VARIANT (t2) == long_long_integer_type_node) { if (TYPE_UNSIGNED (t1) || TYPE_UNSIGNED (t2)) return long_long_unsigned_type_node; else return long_long_integer_type_node; } if (TYPE_MAIN_VARIANT (t1) == long_unsigned_type_node || TYPE_MAIN_VARIANT (t2) == long_unsigned_type_node) return long_unsigned_type_node; if (TYPE_MAIN_VARIANT (t1) == long_integer_type_node || TYPE_MAIN_VARIANT (t2) == long_integer_type_node) { /* But preserve unsignedness from the other type, since long cannot hold all the values of an unsigned int. */ if (TYPE_UNSIGNED (t1) || TYPE_UNSIGNED (t2)) return long_unsigned_type_node; else return long_integer_type_node; } /* Likewise, prefer long double to double even if same size. */ if (TYPE_MAIN_VARIANT (t1) == long_double_type_node || TYPE_MAIN_VARIANT (t2) == long_double_type_node) return long_double_type_node; /* Otherwise prefer the unsigned one. */ if (TYPE_UNSIGNED (t1)) return t1; else return t2; }
the_stack_data/3262582.c
void marker1 (void) { } /* misc. function params */ int qux1 (const char cc, const char /*&*/ccr, const char *ccp, char *const cpc) { return 33; } int qux2 (volatile unsigned char vuc, const volatile int cvi, volatile short /*&*/vsr, volatile long *vlp, float *volatile fpv, const volatile signed char *const volatile cvscpcv) { return 400; } int main (void) { char lave = 'B'; unsigned char lavish = 10; short lax = 20; unsigned short lecherous = 30; long lechery = 40; unsigned long lectern = 50; float leeway = 60; double legacy = 70; signed char lemonade = 35; const char laconic = 'A'; const unsigned char laggard = 1; const short lagoon = 2; const unsigned short laity = 3; const long lambent = 4; const unsigned long laminated = 5; const float lampoon = 6; const double languid = 7; /* pointers to constant variables */ const char *legend = &lave; const unsigned char *legerdemain = &lavish; const short *leniency = &lax; const unsigned short *leonine = &lecherous; const long *lesion = &lechery; const unsigned long *lethal = &lectern; const float *lethargic = &leeway; const double *levity = &legacy; /* constant pointers to constant variables */ const char *const lewd = &laconic; const unsigned char *const lexicographer = &laggard; const short *const lexicon = &lagoon; const unsigned short *const liaison = &laity; const long *const libation = &lambent; const unsigned long *const libelous = &laminated; const float *const libertine = &lampoon; const double *const libidinous = &languid; /* this is the same as const char * legend .... */ char const *languish = &laconic; unsigned char const *languor = &laggard; short const *lank = &lagoon; unsigned short const *lapidary = &laity; long const *larceny = &lambent; unsigned long const *largess = &laminated; float const *lascivious = &lampoon; double const *lassitude = &languid; /* constant pointers to variable */ char *const lamprey = &lave; unsigned char *const lariat = &lavish; short *const laudanum = &lax; unsigned short *const lecithin = &lecherous; long *const leviathan = &lechery; unsigned long *const libretto = &lectern; float *const lissome = &leeway; double *const locust = &legacy; /* constant arrays */ const char logical[2] = {laconic, laconic}; const unsigned char lugged[2] = {laggard, laggard}; const short luck[2] = {lagoon, lagoon}; const unsigned short lunar[2] = {laity, laity}; const long lumen[2] = {lambent, lambent}; const unsigned long lurk[2] = {laminated, laminated}; const float lush[2] = {lampoon, lampoon}; const double lynx[2] = {languid, languid}; /* volatile variables */ volatile char vox = 'X'; volatile unsigned char victuals = 13; volatile short vixen = 200; volatile unsigned short vitriol = 300; volatile long vellum = 1000; volatile unsigned long valve = 2000; volatile float vacuity = 3.0; volatile double vertigo = 10.3; /* pointers to volatile variables */ volatile char * vampire = &vox; volatile unsigned char * viper = &victuals; volatile short * vigour = &vixen; volatile unsigned short * vapour = &vitriol; volatile long * ventricle = &vellum; volatile unsigned long * vigintillion = &valve; volatile float * vocation = &vacuity; volatile double * veracity = &vertigo; /* volatile pointers to volatile variables */ volatile char * volatile vapidity = &vox; volatile unsigned char * volatile velocity = &victuals; volatile short * volatile veneer = &vixen; volatile unsigned short * volatile video = &vitriol; volatile long * volatile vacuum = &vellum; volatile unsigned long * volatile veniality = &valve; volatile float * volatile vitality = &vacuity; volatile double * volatile voracity = &vertigo; /* volatile arrays */ volatile char violent[2] = {vox, vox}; volatile unsigned char violet[2] = {victuals, victuals}; volatile short vips[2] = {vixen, vixen}; volatile unsigned short virgen[2] = {vitriol, vitriol}; volatile long vulgar[2] = {vellum, vellum}; volatile unsigned long vulture[2] = {valve, valve}; volatile float vilify[2] = {vacuity, vacuity}; volatile double villar[2] = {vertigo, vertigo}; /* const volatile vars */ const volatile char victor = 'Y'; const volatile unsigned char vicar = 11; /* pointers to const volatiles */ const volatile char * victory = &victor; const volatile unsigned char * vicarage = &vicar; /* const pointers to volatile vars */ volatile char * const vein = &vox; volatile unsigned char * const vogue = &victuals; /* const pointers to const volatile vars */ const volatile char * const cavern = &victor; const volatile unsigned char * const coverlet = &vicar; /* volatile pointers to const vars */ const char * volatile caveat = &laconic; const unsigned char * volatile covenant = &laggard; /* volatile pointers to const volatile vars */ const volatile char * volatile vizier = &victor; const volatile unsigned char * volatile vanadium = &vicar; /* const volatile pointers */ char * const volatile vane = &lave; unsigned char * const volatile veldt = &lavish; /* const volatile pointers to const vars */ const char * const volatile cove = &laconic; const unsigned char * const volatile cavity = &laggard; /* const volatile pointers to volatile vars */ volatile char * const volatile vagus = &vox; volatile unsigned char * const volatile vagrancy = &victuals; /* const volatile pointers to const volatile */ const volatile char * const volatile vagary = &victor; const volatile unsigned char * const volatile vendor = &vicar; /* const volatile arrays */ const volatile char vindictive[2] = {victor, victor}; const volatile unsigned char vegetation[2] = {vicar, vicar}; /* various structs with const members */ struct crass { char * const ptr; } crass = { lamprey }; struct crisp { char * const *ptr; } crisp = { &lamprey }; /* Reference the structs so that they are not discarded. */ struct crass *creed = &crass; struct crisp *crow = &crisp; /* misc. references */ /* const char & radiation = laconic; volatile signed char & remuneration = lemonade; */ marker1 (); return 0; }
the_stack_data/168892517.c
/****************************************************************** * Memory allocator Test ******************************************************************/ #include "stdlib.h" void *mems[10]; int main(void) { mems[0] = malloc(11); mems[1] = malloc(22); mems[2] = malloc(33); mems[3] = malloc(65); mems[4] = malloc(55); mems[5] = malloc(72); mems[6] = malloc(0); free(mems[0]); mems[0]=NULL; free(mems[1]); mems[1]=NULL; free(mems[3]); mems[3]=NULL; free(mems[2]); mems[2]=NULL; free(mems[5]); mems[5]=NULL; return(0); }
the_stack_data/153267893.c
/* * @file generic.c * @brief PSEC Library * Constant Time [Memory Operations] interface * * Date: 11-09-2014 * * Copyright 2014 Pedro A. Hortas ([email protected]) * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ #include <stdio.h> int memcmp_timec(const void *s1, const void *s2, size_t n) { size_t i = 0, match = 0; const unsigned char *a1 = s1, *a2 = s2; for (i = 0, match = 0; i < n; i ++) match += (a1[i] == a2[i]) + 1; /* Avoid add 0, reg */ return match != (n << 1); } void *memcpy_timec(void *dest, const void *src, size_t n) { unsigned char *d = dest; const unsigned char *s = src; while (n --) d[n] = s[n]; return dest; } static void *_memmove_fw_timec(void *dest, const void *src, size_t n) { unsigned char *d = dest; const unsigned char *s = src; int i = 0, z = 0; for (i = 0, z = n - 1; i <= z; i ++) d[i] = s[i]; return dest; } static void *_memmove_bw_timec(void *dest, const void *src, size_t n) { unsigned char *d = dest; const unsigned char *s = src; int i = 0, z = 0; for (i = n - 1, z = 0; z <= i; i --) d[i] = s[i]; return dest; } void *memmove_timec(void *dest, const void *src, size_t n) { void *(*f[2]) (void *, const void *, size_t) = { _memmove_bw_timec, _memmove_fw_timec }; return f[dest <= src](dest, src, n); } void *memset_timec(void *s, int c, size_t n) { unsigned char *d = s; while (n --) d[n] = (unsigned char) c; return s; } void *memxor_timec(void *dest, const void *src, size_t n) { unsigned char *d = dest; const unsigned char *s = src; unsigned int i = 0; for (i = 0; i < n; i ++) d[i] ^= s[i]; return d; }
the_stack_data/40351.c
//s1只进不出,入栈=入队;s2只出不进,出栈=出队。 typedef struct { int len; int top1; int top2; int *s1;//栈1,入栈=入队 int *s2;//栈2,出栈=出队 } CQueue; CQueue* cQueueCreate() { CQueue *queue = malloc(sizeof(CQueue)); queue->len = 10000; queue->top1 = -1; queue->top2 = -1; queue->s1 = malloc(queue->len * sizeof(int)); queue->s2 = malloc(queue->len * sizeof(int)); return queue; } void cQueueAppendTail(CQueue* obj, int value) { if(obj->top1 == -1) while(obj->top2 != -1) obj->s1[++(obj->top1)] = obj->s2[obj->top2--]; obj->s1[++(obj->top1)] = value; } int cQueueDeleteHead(CQueue* obj) { if(obj->top2 == -1) while(obj->top1 != -1) obj->s2[++(obj->top2)] = obj->s1[obj->top1--]; return obj->top2==-1 ? -1 : obj->s2[obj->top2--]; } void cQueueFree(CQueue* obj) { free(obj->s1); free(obj->s2); free(obj); } /** * Your CQueue struct will be instantiated and called as such: * CQueue* obj = cQueueCreate(); * cQueueAppendTail(obj, value); * int param_2 = cQueueDeleteHead(obj); * cQueueFree(obj); */
the_stack_data/67417.c
/*BEGIN_LEGAL Intel Open Source License Copyright (c) 2002-2015 Intel Corporation. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the Intel Corporation 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 INTEL OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. END_LEGAL */ /* * Call the iret assembler stubs. */ #include <stdlib.h> #include <stdio.h> #include <signal.h> #define __USE_GNU #if defined(TARGET_ANDROID) #include "android_ucontext.h" #else #include <ucontext.h> #endif typedef unsigned int UINT32; extern int iretdTest(); #if (0) /* Enable this if you're trying to debug failure of the iret instruction! * Not enabled all the time becuase the details are OS version dependent, * and we don't actually need it for the purposes of the test. */ static void segvHandler(int sigNo, siginfo_t *si, void * extra) { ucontext_t * uctx = (ucontext_t *)extra; UINT32 * esp = (UINT32 *)uctx->uc_mcontext.gregs[REG_ESP]; int i; fprintf (stderr, "SEGV: IP %p, fault address 0x%lx, SP %p\n", uctx->uc_mcontext.gregs[REG_EIP], si->si_addr, esp); esp -= 4; for (i=0; i<3; i++) { fprintf (stderr, "%p: %08x, %08x, %08x, %08x\n", esp, esp[0], esp[1], esp[2], esp[3]); esp += 4; } exit(-1); } static UINT32 altStack[16384]; static void registerSegvHandler() { struct sigaction sa; stack_t sigStack; sigStack.ss_flags = 0; sigStack.ss_sp = &altStack[0]; sigStack.ss_size = sizeof(altStack); if (sigaltstack(&sigStack, 0)) { fprintf (stderr, "sigaltsack failed\n"); } else { fprintf (stderr, "Altstack established\n"); } if (sigaction (SIGSEGV, 0, &sa)) { fprintf(stderr, "sigaction read failed\n"); } else { fprintf (stderr, "sigaction read OK\n"); } sa.sa_sigaction = segvHandler; sa.sa_flags = SA_SIGINFO | SA_ONSTACK; if (sigaction (SIGSEGV, &sa, 0)) { fprintf(stderr, "sigaction write failed\n"); } else { fprintf (stderr, "sigaction write OK\n"); } } #else # define registerSegvHandler() ((void)0) #endif int main (int argc, char ** argv) { int result; int ok = 0; int tests = 0; registerSegvHandler(); tests++; fprintf(stderr, "Calling iret\n"); result = iretdTest(); fprintf(stderr, "iretd result = %d %s\n", result, result == -1 ? "OK" : "***ERROR***"); ok += (result == -1); return (ok == tests) ? 0 : -1; }
the_stack_data/31388861.c
#include<stdio.h> #include<stdlib.h> #include<time.h> int roll(int x, int y, int mode, int cn){ int num,count; int x2 = x; int sum = 0,flg = 0,fc = 1; srand((unsigned int)time(NULL)); while(flg == 0){ count = 0; if(mode == 1) printf("////%d times///\n",fc); for(int i = 0; i < x2; i++){ num = rand() % y + 1; printf("[%d times] ... %d\n",i + 1,num); sum += num; if(mode == 1 && cn <= num){ count++; puts("critical!"); } } if(mode == 0){ flg++; } if(mode == 1){ x2 = count; fc++; if(count == 0){ flg++; } } } return sum; } int main(){ int mode,x,y,cn = 10; char d; puts("-----xdy-----\n x ... number of dice(s)\n y ... number of face(s)\n-------------"); while(mode != 0 && mode != 1){ puts("Choise a mode\n0 ... no mantion\n1 ... for DX3rd"); scanf("%d",&mode); if(mode != 0 && mode != 1) puts("ERROR. PUT AGAIN."); } while(1){ switch (mode){ case 0:puts("Enter in the form of xdy"); scanf("%*c%d %c %d",&x,&d,&y); break; case 1:puts("Set the critical number"); scanf("%d",&cn); printf("critical number is ... %d\n",cn); puts("Enter in the form of xd"); scanf("%*c%d %c",&x,&d); y = 10; break; } printf("Roll %d %d-sided dice\n",x,y); printf("Roll is ... %d\n",roll(x,y,mode,cn)); } return 0; }
the_stack_data/681063.c
/* * Copyright(c) 2012-2021 Intel Corporation * SPDX-License-Identifier: BSD-3-Clause-Clear */ #if defined(CAS_NVME_PARTIAL) #include "cas_cache.h" #include "utils_nvme.h" #include "utils_blk.h" #include <linux/ioctl.h> #include <linux/file.h> int cas_nvme_get_nsid(struct block_device *bdev, unsigned int *nsid) { int ret = 0; /* * Maximum NSID is 0xFFFFFFFF, so theoretically there is no free * room for error code. However it's unlikely that there will ever * be device with such number of namespaces, so we treat this value * as it was signed. Then in case of negative value we interpret it * as an error code. Moreover in case of error we can be sure, that * we deal with non-NVMe device, because this ioctl should never * fail with NVMe driver. */ ret = ioctl_by_bdev(bdev, NVME_IOCTL_ID, (unsigned long)NULL); if (ret < 0) return ret; *nsid = (unsigned int)ret; return 0; } #define NVME_ID_CNS_NS 0x00 #define NVME_ID_CNS_CTRL 0x01 int cas_nvme_identify_ns(struct block_device *bdev, unsigned int nsid, struct nvme_id_ns *ns) { struct nvme_admin_cmd cmd = { }; unsigned long __user buffer; int ret = 0; buffer = cas_vm_mmap(NULL, 0, sizeof(*ns)); if (IS_ERR((void *)buffer)) return PTR_ERR((void *)buffer); cmd.opcode = nvme_admin_identify; cmd.nsid = cpu_to_le32(nsid); cmd.addr = (__u64)buffer; cmd.data_len = sizeof(*ns); cmd.cdw10 = NVME_ID_CNS_NS; ret = ioctl_by_bdev(bdev, NVME_IOCTL_ADMIN_CMD, (unsigned long)&cmd); if (ret < 0) goto out; ret = copy_from_user(ns, (void *)buffer, sizeof(*ns)); if (ret > 0) ret = -EINVAL; out: cas_vm_munmap(buffer, sizeof(*ns)); return ret; } #endif
the_stack_data/32949951.c
#define max(a, b) (((a) > (b)) ? (a) : (b)) int findTheLongestSubstring(char* s) { int vowels[26] = {0}, hash[64] = {0}; //{mask,index} vowels['a' - 'a'] = 1; vowels['e' - 'a'] = 2; vowels['i' - 'a'] = 3; vowels['o' - 'a'] = 4; vowels['u' - 'a'] = 5; for (int i = 0; i < 64; ++i) hash[i] = -2; hash[0] = -1; int mask = 0, res = 0; for (int i = 0; s[i]; ++i) { if (vowels[s[i] - 'a'] != 0) { mask ^= 1 << vowels[s[i] - 'a']; if (hash[mask] == -2) hash[mask] = i; } res = max(res, i - hash[mask]); } return res; }
the_stack_data/227009.c
/* Generated by CIL v. 1.7.0 */ /* print_CIL_Input is false */ struct _IO_FILE; struct timeval; extern float strtof(char const *str , char const *endptr ) ; extern void signal(int sig , void *func ) ; typedef struct _IO_FILE FILE; extern int atoi(char const *s ) ; extern double strtod(char const *str , char const *endptr ) ; extern int fclose(void *stream ) ; extern void *fopen(char const *filename , char const *mode ) ; extern void abort() ; extern void exit(int status ) ; extern int raise(int sig ) ; extern int fprintf(struct _IO_FILE *stream , char const *format , ...) ; extern int strcmp(char const *a , char const *b ) ; extern int rand() ; extern unsigned long strtoul(char const *str , char const *endptr , int base ) ; void RandomFunc(unsigned short input[1] , unsigned short output[1] ) ; extern int strncmp(char const *s1 , char const *s2 , unsigned long maxlen ) ; extern int gettimeofday(struct timeval *tv , void *tz , ...) ; extern int printf(char const *format , ...) ; int main(int argc , char *argv[] ) ; void megaInit(void) ; extern unsigned long strlen(char const *s ) ; extern long strtol(char const *str , char const *endptr , int base ) ; extern unsigned long strnlen(char const *s , unsigned long maxlen ) ; extern void *memcpy(void *s1 , void const *s2 , unsigned long size ) ; struct timeval { long tv_sec ; long tv_usec ; }; extern void *malloc(unsigned long size ) ; extern int scanf(char const *format , ...) ; void megaInit(void) { { } } void RandomFunc(unsigned short input[1] , unsigned short output[1] ) { unsigned short state[1] ; unsigned short local1 ; { state[0UL] = input[0UL] + (unsigned short)11483; local1 = 0UL; while (local1 < input[1UL]) { if (state[0UL] == local1) { if (state[0UL] < local1) { state[local1] = state[0UL] + state[local1]; } else { state[local1] |= ((state[0UL] - state[local1]) & (unsigned short)31) << 4UL; } } local1 ++; } output[0UL] = ((state[0UL] << (unsigned short)7) | (state[0UL] >> (unsigned short)9)) * (unsigned short)49709; } } int main(int argc , char *argv[] ) { unsigned short input[1] ; unsigned short output[1] ; int randomFuns_i5 ; unsigned short randomFuns_value6 ; int randomFuns_main_i7 ; { megaInit(); if (argc != 2) { printf("Call this program with %i arguments\n", 1); exit(-1); } else { } randomFuns_i5 = 0; while (randomFuns_i5 < 1) { randomFuns_value6 = (unsigned short )strtoul(argv[randomFuns_i5 + 1], 0, 10); input[randomFuns_i5] = randomFuns_value6; randomFuns_i5 ++; } RandomFunc(input, output); if (output[0] == 9750) { printf("You win!\n"); } else { } randomFuns_main_i7 = 0; while (randomFuns_main_i7 < 1) { printf("%u\n", output[randomFuns_main_i7]); randomFuns_main_i7 ++; } } }
the_stack_data/87151.c
//C program to implement Binary Search sorting algorithm #include<stdio.h> void main() { int a[5],i,search,first,last,middle,c = 0; printf("\nAditya Gor 190303105006\n"); printf("enter 5 elements in ascending order\n"); for (i=0;i<5;i++) { scanf("%d",&a[i]); } printf("\nenter number you want to search\t"); scanf("%d",&search); first = 0; last = 4; middle = (first + last)/2; while(first <= last) { if (a[middle] < search) { first = middle + 1; } else if (a[middle] == search) { printf("\nnumber is loacted at %dth position",middle + 1); c++; break; } else { last = middle - 1; } middle = (first + last)/2; } if (c == 0) { printf("\nnumber not found"); } }
the_stack_data/406031.c
// INFO: task hung in console_device // https://syzkaller.appspot.com/bug?id=f940dca538f2169dd7dcdd4ef016f6c935a723e0 // status:open // autogenerated by syzkaller (http://github.com/google/syzkaller) #define _GNU_SOURCE #include <dirent.h> #include <endian.h> #include <errno.h> #include <fcntl.h> #include <signal.h> #include <stdarg.h> #include <stdio.h> #include <string.h> #include <sys/mount.h> #include <sys/prctl.h> #include <sys/stat.h> #include <sys/syscall.h> #include <sys/time.h> #include <sys/wait.h> #include <time.h> #include <unistd.h> __attribute__((noreturn)) static void doexit(int status) { volatile unsigned i; syscall(__NR_exit_group, status); for (i = 0;; i++) { } } #include <errno.h> #include <setjmp.h> #include <signal.h> #include <stdarg.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string.h> #include <sys/stat.h> const int kFailStatus = 67; const int kRetryStatus = 69; static void fail(const char* msg, ...) { int e = errno; va_list args; va_start(args, msg); vfprintf(stderr, msg, args); va_end(args); fprintf(stderr, " (errno %d)\n", e); doexit((e == ENOMEM || e == EAGAIN) ? kRetryStatus : kFailStatus); } static void exitf(const char* msg, ...) { int e = errno; va_list args; va_start(args, msg); vfprintf(stderr, msg, args); va_end(args); fprintf(stderr, " (errno %d)\n", e); doexit(kRetryStatus); } static __thread int skip_segv; static __thread jmp_buf segv_env; static void segv_handler(int sig, siginfo_t* info, void* uctx) { uintptr_t addr = (uintptr_t)info->si_addr; const uintptr_t prog_start = 1 << 20; const uintptr_t prog_end = 100 << 20; if (__atomic_load_n(&skip_segv, __ATOMIC_RELAXED) && (addr < prog_start || addr > prog_end)) { _longjmp(segv_env, 1); } doexit(sig); } static void install_segv_handler() { 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(...) \ { \ __atomic_fetch_add(&skip_segv, 1, __ATOMIC_SEQ_CST); \ if (_setjmp(segv_env) == 0) { \ __VA_ARGS__; \ } \ __atomic_fetch_sub(&skip_segv, 1, __ATOMIC_SEQ_CST); \ } static uint64_t current_time_ms() { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) fail("clock_gettime failed"); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir() { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) fail("failed to mkdtemp"); if (chmod(tmpdir, 0777)) fail("failed to chmod"); if (chdir(tmpdir)) fail("failed to chdir"); } static uintptr_t syz_open_dev(uintptr_t a0, uintptr_t a1, uintptr_t a2) { if (a0 == 0xc || a0 == 0xb) { char buf[128]; sprintf(buf, "/dev/%s/%d:%d", a0 == 0xc ? "char" : "block", (uint8_t)a1, (uint8_t)a2); return open(buf, O_RDWR, 0); } else { char buf[1024]; char* hash; NONFAILING(strncpy(buf, (char*)a0, sizeof(buf) - 1)); buf[sizeof(buf) - 1] = 0; while ((hash = strchr(buf, '#'))) { *hash = '0' + (char)(a1 % 10); a1 /= 10; } return open(buf, a2, 0); } } static void remove_dir(const char* dir) { DIR* dp; struct dirent* ep; int iter = 0; retry: while (umount2(dir, MNT_DETACH) == 0) { } dp = opendir(dir); if (dp == NULL) { if (errno == EMFILE) { exitf("opendir(%s) failed due to NOFILE, exiting", dir); } exitf("opendir(%s) failed", dir); } while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); while (umount2(filename, MNT_DETACH) == 0) { } struct stat st; if (lstat(filename, &st)) exitf("lstat(%s) failed", filename); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } int i; for (i = 0;; i++) { if (unlink(filename) == 0) break; if (errno == EROFS) { break; } if (errno != EBUSY || i > 100) exitf("unlink(%s) failed", filename); if (umount2(filename, MNT_DETACH)) exitf("umount(%s) failed", filename); } } closedir(dp); int i; for (i = 0;; i++) { if (rmdir(dir) == 0) break; if (i < 100) { if (errno == EROFS) { break; } if (errno == EBUSY) { if (umount2(dir, MNT_DETACH)) exitf("umount(%s) failed", dir); continue; } if (errno == ENOTEMPTY) { if (iter < 100) { iter++; goto retry; } } } exitf("rmdir(%s) failed", dir); } } static void execute_one(); extern unsigned long long procid; static void loop() { int iter; for (iter = 0;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) fail("failed to mkdir"); int pid = fork(); if (pid < 0) fail("clone failed"); if (pid == 0) { prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); setpgrp(); if (chdir(cwdbuf)) fail("failed to chdir"); execute_one(); int fd; for (fd = 3; fd < 30; fd++) close(fd); doexit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { int res = waitpid(-1, &status, __WALL | WNOHANG); if (res == pid) { break; } usleep(1000); if (current_time_ms() - start < 5 * 1000) continue; kill(-pid, SIGKILL); kill(pid, SIGKILL); while (waitpid(-1, &status, __WALL) != pid) { } break; } remove_dir(cwdbuf); } } uint64_t r[1] = {0xffffffffffffffff}; void execute_one() { long res = 0; NONFAILING(memcpy((void*)0x20000000, "./bus", 6)); syscall(__NR_open, 0x20000000, 0, 0); NONFAILING(memcpy((void*)0x20000000, "./file0", 8)); syscall(__NR_unlink, 0x20000000); NONFAILING(memcpy((void*)0x20d59ff3, "/dev/binder#", 13)); res = syz_open_dev(0x20d59ff3, 0, 0); if (res != -1) r[0] = res; syscall(__NR_mmap, 0x20001000, 0x3000, 0, 0x20011, -1, 0); syscall(__NR_ioctl, -1, 0x40046207, 0); NONFAILING(*(uint64_t*)0x20000440 = 0x44); NONFAILING(*(uint64_t*)0x20000448 = 0); NONFAILING(*(uint64_t*)0x20000450 = 0x20000300); NONFAILING(memcpy((void*)0x20000300, "\x00\x63\x40\x40\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x18\x00\x00\x00\x00\x00" "\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00", 52)); NONFAILING(*(uint64_t*)0x20000334 = 0x20000200); NONFAILING(*(uint64_t*)0x20000200 = 0); NONFAILING(*(uint64_t*)0x2000033c = 0x20000080); NONFAILING(*(uint64_t*)0x20000458 = 0); NONFAILING(*(uint64_t*)0x20000460 = 0); NONFAILING(*(uint64_t*)0x20000468 = 0x200003c0); syscall(__NR_ioctl, r[0], 0xc0306201, 0x20000440); } int main() { syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0); install_segv_handler(); char* cwd = get_current_dir_name(); for (;;) { if (chdir(cwd)) fail("failed to chdir"); use_temporary_dir(); loop(); } }
the_stack_data/28913.c
int funcOBJ2(void) { return 2; }
the_stack_data/149568.c
#include <stdio.h> int entry() { printf("I am module one!\n"); return 0; }
the_stack_data/25138989.c
#ifdef MACRO garbage #endif #ifndef MORE garbage #endif
the_stack_data/90764767.c
void x3 (void) { }
the_stack_data/192329359.c
#include <stdio.h> #include <stdlib.h> #include <string.h> void cov_serialize(long double, unsigned char*, int); long double cov_deserialize(char*, int); void cov_log(long double, char*, char*); void cov_spec_log(long double, long double, char*); void cov_arr_log(long double[], int, char*, char*); void cov_spec_arr_log(long double[], int, long double, char*); void cov_check(char*, char*, char*); void cov_arr_check(char*, char*, int length); int main(int argc, char *argv[]) { float a = 2.2L; float b = 2.2L; long double c = a + b; cov_spec_log(c, 0, argv[1]); printf("%1.15Le\n", c); printf("%1.15Le\n", (long double)a); return 0; } void cov_serialize(long double f, unsigned char* buf, int length) { int i; union { unsigned char bytes[10]; long double val; } bfconvert; bfconvert.val = f; for (i = 0; i < length; i++) { buf[i] = bfconvert.bytes[i]; } } long double cov_deserialize(char* buf, int length) { int i; unsigned int u; union { unsigned char bytes[10]; long double val; } bfconvert; for (i = 0; i < length; i++) { sscanf(buf, "%02X", &u); bfconvert.bytes[i] = u; buf += 2; } return bfconvert.val; } void cov_log(long double ld, char* msg, char* fn) { int ld_size, i; unsigned char* buf; FILE* file; file = fopen(fn, "a"); ld_size = 10; buf = malloc(ld_size); if (strlen(msg) > 0) fprintf(file, "#%s\n", msg); cov_serialize(ld, buf, ld_size); for (i = 0; i < ld_size; i++) { fprintf(file, "%02X", buf[i]); } fprintf(file, "\n"); fclose(file); } void cov_spec_log(long double ideal, long double delta, char* fn) { cov_log(ideal, "ideal", fn); cov_log(delta, "delta", fn); } void cov_arr_log(long double lds[], int size, char* msg, char* fn) { int ld_size, i, j; unsigned char* buf; FILE *file; file = fopen(fn, "a"); ld_size = 10; buf = malloc(ld_size); if (strlen(msg) > 0) fprintf(file, "#%s\n", msg); for (i = 0; i < size; i++) { long double ld = lds[i]; cov_serialize(ld, buf, ld_size); if (i > 0) fprintf(file, " "); for (j = 0; j < ld_size; j++) { fprintf(file, "%02X", buf[j]); } } fprintf(file, "\n"); fclose(file); } void cov_spec_arr_log(long double ideal[], int size, long double delta, char* fn) { cov_arr_log(ideal, size, "ideal", fn); cov_log(delta, "delta", fn); } void cov_check(char* log, char* spec, char* result) { char line[80], estimate_hex[80], ideal_hex[80], delta_hex[80]; long double estimate, ideal, delta, diff; FILE *log_file, *spec_file, *result_file; int ld_size; ld_size = 10; // reading log file log_file = fopen(log, "rt"); while (fgets(line, 80, log_file) != NULL) { if (line[0] != '#') strcpy(estimate_hex, line); } fclose(log_file); spec_file = fopen(spec, "rt"); while (fgets(line, 80, spec_file) != NULL) { if (strncmp(line, "#ideal", 6) == 0) { fgets(ideal_hex, 80, spec_file); } else if (strncmp(line, "#delta", 6) == 0) { fgets(delta_hex, 80, spec_file); } } fclose(spec_file); // compare log and spec results estimate = cov_deserialize(estimate_hex, ld_size); ideal = cov_deserialize(ideal_hex, ld_size); delta = cov_deserialize(delta_hex, ld_size); if (estimate > ideal) diff = estimate - ideal; else diff = ideal - estimate; result_file = fopen(result, "w"); if (delta >= diff) fprintf(result_file, "true\n"); else fprintf(result_file, "false\n"); fclose(result_file); } void cov_arr_check(char* log, char* spec, int length) { char line[1000]; char *word, *sep, *brkt, *brkb; long double estimate[length], ideal[length], delta; FILE *log_file, *spec_file; int ld_size, cnt, i, predicate; sep = " "; ld_size = 10; // reading log file log_file = fopen(log, "rt"); while (fgets(line, 1000, log_file) != NULL) { if (line[0] != '#') { cnt = 0; for (word = strtok_r(line, sep, &brkt); word; word = strtok_r(NULL, sep, &brkt)){ estimate[cnt] = cov_deserialize(word, ld_size); cnt++; } } } fclose(log_file); // reading spec file spec_file = fopen(spec, "rt"); while (fgets(line, 1000, log_file) != NULL) { if (strncmp(line, "#ideal", 6) == 0) { cnt = 0; fgets(line, 1000, spec_file); for (word = strtok_r(line, sep, &brkb); word; word = strtok_r(NULL, sep, &brkb)){ ideal[cnt] = cov_deserialize(word, ld_size); cnt++; } } else if (strncmp(line, "#delta", 6) == 0) { fgets(line, 80, spec_file); delta = cov_deserialize(line, ld_size); } } fclose(spec_file); predicate = 1; for (i = 0; i < length; i++) { long double diff; if (estimate[i] > ideal[i]) diff = estimate[i] - ideal[i]; else diff = ideal[i] - estimate[i]; if (delta < diff) { predicate = 0; break; } } if (predicate) printf("true\n"); else printf("false\n"); }
the_stack_data/123279.c
#include <stdio.h> #include <math.h> #include <stdlib.h> #include <string.h> #define ll long long int main(void) { char* series = "7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319528532088055111254069874715852386305071569329096329522744304355766896648950445244523161731856403098711121722383113622298934233803081353362766142828064444866452387493035890729629049156044077239071381051585930796086670172427121883998797908792274921901699720888093776657273330010533678812202354218097512545405947522435258490771167055601360483958644670632441572215539753697817977846174064955149290862569321978468622482839722413756570560574902614079729686524145351004748216637048440319989000889524345065854122758866688116427171479924442928230863465674813919123162824586178664583591245665294765456828489128831426076900422421902267105562632111110937054421750694165896040807198403850962455444362981230987879927244284909188845801561660979191338754992005240636899125607176060588611646710940507754100225698315520005593572972571636269561882670428252483600823257530420752963450"; ll largest = 0; int length = strlen(series); for (int i = 0; i < length - 13; ++i) { ll product = 1; for (int j = 0; j < 13; ++j) { product *= (*(char*)(series + i + j)) - '0'; if (product > largest) { largest = product; } else if (product == 0) { continue; } } } printf("%lld", largest); return 0; }
the_stack_data/48574464.c
a; b() { if (c()) a = 9; d(a); }
the_stack_data/65944.c
// no output from test machine // https://syzkaller.appspot.com/bug?id=8bf9a9a2638fc9e95348d4398decb1b5c80beecb // status:invalid // autogenerated by syzkaller (http://github.com/google/syzkaller) #define _GNU_SOURCE #include <arpa/inet.h> #include <errno.h> #include <errno.h> #include <fcntl.h> #include <linux/if.h> #include <linux/if_ether.h> #include <linux/if_tun.h> #include <linux/ip.h> #include <linux/tcp.h> #include <net/if_arp.h> #include <pthread.h> #include <signal.h> #include <stdarg.h> #include <stdarg.h> #include <stdbool.h> #include <stdint.h> #include <stdio.h> #include <stdio.h> #include <stdlib.h> #include <stdlib.h> #include <string.h> #include <sys/ioctl.h> #include <sys/prctl.h> #include <sys/stat.h> #include <sys/syscall.h> #include <sys/time.h> #include <sys/wait.h> #include <time.h> #include <unistd.h> const int kFailStatus = 67; const int kRetryStatus = 69; __attribute__((noreturn)) static void doexit(int status) { volatile unsigned i; syscall(__NR_exit_group, status); for (i = 0;; i++) { } } __attribute__((noreturn)) static void fail(const char* msg, ...) { int e = errno; fflush(stdout); va_list args; va_start(args, msg); vfprintf(stderr, msg, args); va_end(args); fprintf(stderr, " (errno %d)\n", e); doexit((e == ENOMEM || e == EAGAIN) ? kRetryStatus : kFailStatus); } __attribute__((noreturn)) static void exitf(const char* msg, ...) { int e = errno; fflush(stdout); va_list args; va_start(args, msg); vfprintf(stderr, msg, args); va_end(args); fprintf(stderr, " (errno %d)\n", e); doexit(kRetryStatus); } #define BITMASK_LEN(type, bf_len) (type)((1ull << (bf_len)) - 1) #define BITMASK_LEN_OFF(type, bf_off, bf_len) \ (type)(BITMASK_LEN(type, (bf_len)) << (bf_off)) #define STORE_BY_BITMASK(type, addr, val, bf_off, bf_len) \ if ((bf_off) == 0 && (bf_len) == 0) { \ *(type*)(addr) = (type)(val); \ } else { \ type new_val = *(type*)(addr); \ new_val &= ~BITMASK_LEN_OFF(type, (bf_off), (bf_len)); \ new_val |= ((type)(val)&BITMASK_LEN(type, (bf_len))) << (bf_off); \ *(type*)(addr) = new_val; \ } static void vsnprintf_check(char* str, size_t size, const char* format, va_list args) { int rv; rv = vsnprintf(str, size, format, args); if (rv < 0) fail("tun: snprintf failed"); if ((size_t)rv >= size) fail("tun: string '%s...' doesn't fit into buffer", str); } static void snprintf_check(char* str, size_t size, const char* format, ...) { va_list args; va_start(args, format); vsnprintf_check(str, size, format, args); va_end(args); } #define COMMAND_MAX_LEN 128 static void execute_command(const char* format, ...) { va_list args; char command[COMMAND_MAX_LEN]; int rv; va_start(args, format); vsnprintf_check(command, sizeof(command), format, args); rv = system(command); if (rv != 0) fail("tun: command \"%s\" failed with code %d", &command[0], rv); va_end(args); } static int tunfd = -1; #define SYZ_TUN_MAX_PACKET_SIZE 1000 #define MAX_PIDS 32 #define ADDR_MAX_LEN 32 #define LOCAL_MAC "aa:aa:aa:aa:aa:%02hx" #define REMOTE_MAC "bb:bb:bb:bb:bb:%02hx" #define LOCAL_IPV4 "172.20.%d.170" #define REMOTE_IPV4 "172.20.%d.187" #define LOCAL_IPV6 "fe80::%02hxaa" #define REMOTE_IPV6 "fe80::%02hxbb" static void initialize_tun(uint64_t pid) { if (pid >= MAX_PIDS) fail("tun: no more than %d executors", MAX_PIDS); int id = pid; tunfd = open("/dev/net/tun", O_RDWR | O_NONBLOCK); if (tunfd == -1) fail("tun: can't open /dev/net/tun"); char iface[IFNAMSIZ]; snprintf_check(iface, sizeof(iface), "syz%d", id); struct ifreq ifr; memset(&ifr, 0, sizeof(ifr)); strncpy(ifr.ifr_name, iface, IFNAMSIZ); ifr.ifr_flags = IFF_TAP | IFF_NO_PI; if (ioctl(tunfd, TUNSETIFF, (void*)&ifr) < 0) fail("tun: ioctl(TUNSETIFF) failed"); char local_mac[ADDR_MAX_LEN]; snprintf_check(local_mac, sizeof(local_mac), LOCAL_MAC, id); char remote_mac[ADDR_MAX_LEN]; snprintf_check(remote_mac, sizeof(remote_mac), REMOTE_MAC, id); char local_ipv4[ADDR_MAX_LEN]; snprintf_check(local_ipv4, sizeof(local_ipv4), LOCAL_IPV4, id); char remote_ipv4[ADDR_MAX_LEN]; snprintf_check(remote_ipv4, sizeof(remote_ipv4), REMOTE_IPV4, id); char local_ipv6[ADDR_MAX_LEN]; snprintf_check(local_ipv6, sizeof(local_ipv6), LOCAL_IPV6, id); char remote_ipv6[ADDR_MAX_LEN]; snprintf_check(remote_ipv6, sizeof(remote_ipv6), REMOTE_IPV6, id); execute_command("sysctl -w net.ipv6.conf.%s.accept_dad=0", iface); execute_command("sysctl -w net.ipv6.conf.%s.router_solicitations=0", iface); execute_command("ip link set dev %s address %s", iface, local_mac); execute_command("ip addr add %s/24 dev %s", local_ipv4, iface); execute_command("ip -6 addr add %s/120 dev %s", local_ipv6, iface); execute_command("ip neigh add %s lladdr %s dev %s nud permanent", remote_ipv4, remote_mac, iface); execute_command("ip -6 neigh add %s lladdr %s dev %s nud permanent", remote_ipv6, remote_mac, iface); execute_command("ip link set dev %s up", iface); } static void setup_tun(uint64_t pid, bool enable_tun) { if (enable_tun) initialize_tun(pid); } static int read_tun(char* data, int size) { int rv = read(tunfd, data, size); if (rv < 0) { if (errno == EAGAIN) return -1; fail("tun: read failed with %d, errno: %d", rv, errno); } return rv; } struct csum_inet { uint32_t acc; }; static void csum_inet_init(struct csum_inet* csum) { csum->acc = 0; } static void csum_inet_update(struct csum_inet* csum, const uint8_t* data, size_t length) { if (length == 0) return; size_t i; for (i = 0; i < length - 1; i += 2) csum->acc += *(uint16_t*)&data[i]; if (length & 1) csum->acc += (uint16_t)data[length - 1]; while (csum->acc > 0xffff) csum->acc = (csum->acc & 0xffff) + (csum->acc >> 16); } static uint16_t csum_inet_digest(struct csum_inet* csum) { return ~csum->acc; } static uintptr_t syz_emit_ethernet(uintptr_t a0, uintptr_t a1) { if (tunfd < 0) return (uintptr_t)-1; int64_t length = a0; char* data = (char*)a1; return write(tunfd, data, length); } static void flush_tun() { char data[SYZ_TUN_MAX_PACKET_SIZE]; while (read_tun(&data[0], sizeof(data)) != -1) ; } static uint64_t current_time_ms() { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) fail("clock_gettime failed"); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void test(); void loop() { int iter; for (iter = 0;; iter++) { int pid = fork(); if (pid < 0) fail("clone failed"); if (pid == 0) { prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); setpgrp(); flush_tun(); test(); doexit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { int res = waitpid(-1, &status, __WALL | WNOHANG); if (res == pid) break; usleep(1000); if (current_time_ms() - start > 5 * 1000) { kill(-pid, SIGKILL); kill(pid, SIGKILL); while (waitpid(-1, &status, __WALL) != pid) { } break; } } } } long r[105]; void* thr(void* arg) { switch ((long)arg) { case 0: r[0] = syscall(__NR_mmap, 0x20000000ul, 0xf07000ul, 0x3ul, 0x32ul, 0xfffffffffffffffful, 0x0ul); break; case 1: r[1] = syscall(__NR_socket, 0x2ul, 0x2ul, 0x0ul); break; case 2: *(uint16_t*)0x20f01000 = (uint16_t)0x2; *(uint16_t*)0x20f01002 = (uint16_t)0x224e; *(uint32_t*)0x20f01004 = (uint32_t)0x10000e0; *(uint8_t*)0x20f01008 = (uint8_t)0x0; *(uint8_t*)0x20f01009 = (uint8_t)0x0; *(uint8_t*)0x20f0100a = (uint8_t)0x0; *(uint8_t*)0x20f0100b = (uint8_t)0x0; *(uint8_t*)0x20f0100c = (uint8_t)0x0; *(uint8_t*)0x20f0100d = (uint8_t)0x0; *(uint8_t*)0x20f0100e = (uint8_t)0x0; *(uint8_t*)0x20f0100f = (uint8_t)0x0; r[13] = syscall(__NR_bind, r[1], 0x20f01000ul, 0x10ul); break; case 3: *(uint16_t*)0x20647000 = (uint16_t)0x2; *(uint16_t*)0x20647002 = (uint16_t)0x204e; *(uint32_t*)0x20647004 = (uint32_t)0xfeffffff; *(uint8_t*)0x20647008 = (uint8_t)0x0; *(uint8_t*)0x20647009 = (uint8_t)0x0; *(uint8_t*)0x2064700a = (uint8_t)0x0; *(uint8_t*)0x2064700b = (uint8_t)0x0; *(uint8_t*)0x2064700c = (uint8_t)0x0; *(uint8_t*)0x2064700d = (uint8_t)0x0; *(uint8_t*)0x2064700e = (uint8_t)0x0; *(uint8_t*)0x2064700f = (uint8_t)0x0; r[25] = syscall(__NR_recvfrom, r[1], 0x20f04000ul, 0x0ul, 0x2ul, 0x20647000ul, 0x10ul); break; case 4: *(uint8_t*)0x20df2fce = (uint8_t)0xbb; *(uint8_t*)0x20df2fcf = (uint8_t)0xbb; *(uint8_t*)0x20df2fd0 = (uint8_t)0xbb; *(uint8_t*)0x20df2fd1 = (uint8_t)0xbb; *(uint8_t*)0x20df2fd2 = (uint8_t)0xbb; *(uint8_t*)0x20df2fd3 = (uint8_t)0x0; *(uint8_t*)0x20df2fd4 = (uint8_t)0xbb; *(uint8_t*)0x20df2fd5 = (uint8_t)0xbb; *(uint8_t*)0x20df2fd6 = (uint8_t)0xbb; *(uint8_t*)0x20df2fd7 = (uint8_t)0xbb; *(uint8_t*)0x20df2fd8 = (uint8_t)0xbb; *(uint8_t*)0x20df2fd9 = (uint8_t)0x0; *(uint16_t*)0x20df2fda = (uint16_t)0x8; STORE_BY_BITMASK(uint8_t, 0x20df2fdc, 0x5, 0, 4); STORE_BY_BITMASK(uint8_t, 0x20df2fdc, 0x4, 4, 4); STORE_BY_BITMASK(uint8_t, 0x20df2fdd, 0x101, 0, 2); STORE_BY_BITMASK(uint8_t, 0x20df2fdd, 0x0, 2, 6); *(uint16_t*)0x20df2fde = (uint16_t)0x2310; *(uint16_t*)0x20df2fe0 = (uint16_t)0x6400; *(uint16_t*)0x20df2fe2 = (uint16_t)0x0; *(uint8_t*)0x20df2fe4 = (uint8_t)0x2; *(uint8_t*)0x20df2fe5 = (uint8_t)0x11; *(uint16_t*)0x20df2fe6 = (uint16_t)0x0; *(uint8_t*)0x20df2fe8 = (uint8_t)0xac; *(uint8_t*)0x20df2fe9 = (uint8_t)0x14; *(uint8_t*)0x20df2fea = (uint8_t)0x0; *(uint8_t*)0x20df2feb = (uint8_t)0xbb; *(uint32_t*)0x20df2fec = (uint32_t)0x10000e0; *(uint16_t*)0x20df2ff0 = (uint16_t)0x204e; *(uint16_t*)0x20df2ff2 = (uint16_t)0x224e; *(uint8_t*)0x20df2ff4 = (uint8_t)0x4; STORE_BY_BITMASK(uint8_t, 0x20df2ff5, 0x1, 0, 4); STORE_BY_BITMASK(uint8_t, 0x20df2ff5, 0x51, 4, 4); *(uint16_t*)0x20df2ff6 = (uint16_t)0x0; STORE_BY_BITMASK(uint8_t, 0x20df2ff8, 0x0, 0, 1); STORE_BY_BITMASK(uint8_t, 0x20df2ff8, 0xb, 1, 4); STORE_BY_BITMASK(uint8_t, 0x20df2ff8, 0x6, 5, 3); memcpy((void*)0x20df2ff9, "\xd2\x2b\x30", 3); *(uint8_t*)0x20df2ffc = (uint8_t)0x10000; memcpy((void*)0x20df2ffd, "\x29\x9d\x28", 3); memcpy( (void*)0x20df3000, "\x06\x29\x9a\x9b\x46\x91\x35\xfa\xec\x24\x89\x45\x34\xaf\xf5" "\x6d\xe2\x6a\xd5\x40\x2e\xe0\xe7\x20\x04\x4e\x3d\x78\xe1\x61" "\x23\xb9\xd9\xb8\xca\x3d\xc8\xc2\xfe\xa5\xff\x3d\x08\xf4\x09" "\x8d\x53\x62\xf0\xb8\x1b\x8b\x7f\x04\x28\x64\x89\x03\x18\x3e" "\x20\x2e\x69\xfd\x7a\x75\xdc\x05\x79\xab\x10\xb9\x65\x54\x01" "\xd9\x30\x81\x26\xae\x0b\x65\x12\x95\xc3\x24\xe2\xfc\xaf\xa9" "\xc8\x49\x21\x32\xdf\x00\x3f\x4d\x04\x7d\xa7\x19\xaa\x28\x9f" "\x55\x9f\xf2\x34\x82\x11\x20\xec\xf5\x5e\xf0\x64\x6e\xf3\x64" "\x8b\x20\x27\x79\x92\xd2\xb0\xe6\xe0\xb1\x45\xec\x61\x54\x6b" "\xf2\x6f\x2c\xdb\xa0\x2f\x46\x9f\xef\xec\x03\x69\x83\xe3\x9e" "\x02\xb0\xd7\x06\xc2\x24\xfa\x44\x6b\x9d\x1d\xb3\xed\xb8\x08" "\xdf\x9a\x1e\x79\xa2\x69\xb3\x06\x3f\x67\x1c\xc8\xc2\xad\x25" "\x6b\x11\x56\x28\x7f\x7a\x7d\x74\xfc\x77\x57\x29\x7b\xd3\x00" "\x51\x09\x51\x02\x94\x3f\x6e\xb4\x87\x45\x68\xa4\xe1\x28\x9e" "\xb4\x04\x37\xdf\x08\xc6\x03\x31\x80\xc1\x89\x0d\x5e\x0c\x80" "\x58\xac\xfa\x56\x63\xb5\x7c\x10\x1f\x3c\xdc\x45\xae\xb4\x3c" "\x0b\xe1\xfa\xd9\xad\x2b\x27\x41\x96\xd1\xa5\xf7\xd1\xc0\x1d" "\x3a\xdb\x4a\x1a\xbe\x54\xf5\xd5\xf6\xe6\xa0\x2c\xc7\x59\x07" "\x81\xe3\xd6\x2f\xc1\x52\x74\x31\x5d\x24\x69\x61\xfc\x44\x8d" "\x74\x2b\x85\xe0\x22\x9a\xf7\xcb\xd5\x01\xd6\x38\x4c\x00\x9d" "\x9c\xd2\xfa\xfc\x9d\xfc\xfb\xbf\x4c\x63\x3c\x3e\xd4\xed\x68" "\xb1\xbf\x2a\xeb\xaf\x35\x24\xe2\x14\x5f\x84\x14\xaf\xb9\x42" "\xa8\x7c\xe9\x49\xaa\x8d\x42\xf7\x0f\x4a\x81\xdb\x54\x0d\xd7" "\x37\x53\x16\xb5\x14\x4f\x1b\x97\xd6\xb4\x4b\xf9\xd2\x4b\x2d" "\x0f\xf3\xaa\xbf\x78\xb3\xf9\x50\xcc\xf4\x9f\x3a\x2e\x9f\xd9" "\x1a\x8e\x37\x7e\xd5\x20\x9e\xfd\x42\x34\xc2\x11\x82\x66\x91" "\x3d\x36\x41\x6f\xcc\x39\x4b\xd2\xd1\x6d\xfb\xd2\x5b\x84\x12" "\x4e\x86\x3c\xcb\xe8\x7d\xde\xcc\xd1\x90\xb8\xc7\xa1\x42\xe0" "\xcd\x8c\xa5\xfe\xd7\xbb\x21\x6e\x59\x84\x35\xc9\xf5\x8d\x16" "\xe2\x6b\xad\xf7\x38\xa7\x80\x5b\xb6\x07\xe7\x87\x1a\x84\xeb" "\xb2\xcc\xc2\x1b\x08\x90\x9f\xaa\xa0\x79\x34\xe4\x29\xd9\x95" "\xa5\xb8\x62\x98\x1a\xd6\x92\xa9\x07\x67\xb3\x12\xed\xc6\x2d" "\x05\x6f\xe6\x27\xbf\xba\x4a\xf7\x26\x52\xae\x4f\x78\x49\xce" "\x19\x12\xab\xec\x3a\x2f\x3f\x73\xba\x44\x67\xf5\x95\xd7\x6d" "\x27\xb2\x1a\x86\xe2\xcc\x05\x67\x1a\x29\x8c\x1a\x83\x5d\xbb" "\x98\xd5\x35\x4f\x97\x52\xf0\x29\x6c\x9d\xe6\x69\x81\x86\x91" "\xda\xff\x8b\xde\xdd\x58\x50\xda\x12\x44\xa7\xec\xab\xdb\x3d" "\x9e\x0d\x8a\xd3\x6d\x4f\xb9\x1d\x12\xab\x40\x55\xb6\x0c\xbe" "\xf4\xeb\x6a\x8f\x67\x4c\x25\xab\xe6\xa0\x43\x24\xbc\x14\x65" "\x16\x6f\xfc\x22\x2e\xfd\x17\xe0\x74\xb2\x35\x90\xf5\x21\xb9" "\x5e\x6e\x6c\x45\xa4\x10\x1e\xb1\xb7\xdd\x93\x56\xdb\xb6\xd5" "\x40\x31\x61\x7c\x88\xc5\xaa\x82\x32\x86\x6c\x17\xe2\x2b\xe0" "\xf2\x4f\x7c\x4d\x6c\x8b\x21\x9c\x6d\xd3\x09\x96\x32\x67\xfc" "\x2d\x45\xd8\x58\x96\x2c\x88\x63\x74\x00\xee\xfa\x50\x4d\x90" "\x87\x8e\xf6\xc7\x3a\x59\xae\xed\x68\xb4\xd0\x4b\xe3\xd7\xd8" "\xd5\x2f\x22\x07\xec\x91\xcd\xc1\xae\x5f\xf3\x80\x9b\x1d\xda" "\x36\x06\x04\xaf\x88\x54\xa8\x9f\x05\x42\xa0\x39\x84\x75\x17" "\xf9\x0b\xbd\xfb\x16\xd6\x97\x8e\x46\x72\x90\x38\x19\x07\x74" "\x0f\xe3\xdb\x16\x3b\xb6\x7f\x93\xb1\xc7\x24\x33\x4b\xe4\xcb" "\x09\x8b\xda\x91\x1a\xb6\x03\x0c\x46\xbe\x85\xa8\x97\xf9\xb1" "\xdd\xb3\x30\x6f\xf2\xca\xc6\xc2\x6a\x21\xfd\xe8\x76\xa8\x94" "\xe3\xe7\xeb\xcc\x00\x63\xf4\x19\xc9\x5d\xed\x5d\xad\x1b\xfb" "\xd5\x3f\x89\xef\x75\xc7\xac\x4d\xdd\x5b\x90\x9a\xa4\x09\x8f" "\x80\xd4\x12\xc2\x51\x08\x50\xe8\x5c\x41\x2c\x01\xdd\x54\x1e" "\x08\xcc\xf9\x7f\xe0\xb4\x7d\x91\x5c\x87\xb9\x1b\x0b\xab\x1d" "\x2b\x9c\xc7\xac\x6b\x96\x53\xc5\xfc\xb4\x74\x75\x60\xbd\x65" "\xd6\x49\x9a\x39\x99\x1e\xcc\x72\x2d\x20\x84\x94\xcc\x6a\x66" "\x53\xe5\x0a\x0d\x41\xbc\x40\x68\xd9\x61\xfa\x32\x07\x2b\x65" "\xec\x07\x5a\x8a\x35\xc5\x4d\x25\xf3\xf4\xe1\x78\x2f\x08\x87" "\x39\xdb\x3e\xa2\x2d\xa5\x09\xfc\xf1\x2f\x63\x54\x20\x64\xe2" "\xb7\x2d\xb6\x2a\x9c\x7c\xea\x08\x5e\x1c\x98\x0a\xcf\x05\x56" "\x7e\xca\x39\x6b\x19\xc6\xc1\x48\xeb\xb2\x4f\x23\x36\x12\xdc" "\x65\xad\x15\x9c\x3d\xb0\x09\xe2\xd5\x98\x37\x13\x42\x13\x43" "\xf2\x22\x59\xb0\x84\x2f\xdf\x24\xe5\xe3\x76\xc3\xaf\x0e\x17" "\x71\xd2\x25\x2f\xd8\x4f\xdd\x98\x48\x52\x5f\x7e\xf6\x9a\x89" "\x51\x6a\xb6\x34\x39\x5d\xd5\x31\x64\xce\x0c\x1b\x92\x2e\x35" "\x5b\x3c\x36\x20\x66\x41\xa8\x79\xed\xc0\x03\x7d\x01\x6f\x06" "\x1d\x52\xc6\xdc\xe7\x5e\xa3\x69\x3d\x40\xd8\x2e\x3c\x63\x75" "\x68\x8a\x6a\xa4\x54\x72\x4f\xbf\x56\x6b\xc1\x41\xdd\x1f\x57" "\xd0\x2d\xca\xad\xdc\x79\xe3\xe2\xce\xa2\x10\x02\x04\x6d\xb8" "\x63\x22\xe3\x5c\x59\x0d\xdb\x27\x94\x6f\x69\xe6\xec\x30\x45" "\x44\x83\xc3\x65\xfd\xec\x58\xf6\xc1\xb3\x80\x76\x18\xbe\xaa" "\xe5\xbc\xd2\x1b\xb9\xbf\xac\xe5\x23\x64\xb9\x1c\x42\x03\x12" "\x31\xfd\xcc\x7b\x15\x11\x7a\x84\xa9\xff\xb1\x36\xe3\xb4\xe9" "\x1b\x01\xcd\xcb\xdf\x72\xa6\xc0\xd1\xe6\xf9\x0f\xec\x8a\xfc" "\xe7\x94\xf2\x6d\x69\x67\xc8\xda\x92\x75\xb8\x70\xb3\xea\x5c" "\x73\xc8\x4b\x56\x89\xe1\x1b\x10\xc4\xd8\x04\xd1\x4d\x31\x52" "\x42\x4d\x2f\x25\x86\x19\xe0\xcc\xb3\x94\xd0\x5e\x7f\x1d\x72" "\x33\x0f\x23\x0d\xe4\xc3\xe8\x90\x68\x55\x98\xc5\x68\xbe\xb6" "\xb5\xa6\x99\xa2\x87\x4d\xd0\x30\x36\xbd\x6a\x19\xb0\x66\x03" "\xaa\xc4\x12\xf5\xa2\x37\x55\x9c\x1e\x76\x28\x79\xa8\x55\xc4" "\xf9\xf0\xd7\x48\xfd\x0f\x85\xc4\x60\x40\xa1\x6d\xa9\x21\x45" "\xe1\x95\x84\x88\xb4\x50\x10\xcb\x9f\x59\xe5\xb4\xde\x80\x1b" "\x63\x6d\x93\xe8\x9c\x1e\x30\x67\xa2\xae\x89\xfa\xfb\x94\x7f" "\x07\x2f\x23\x56\x8c\x84\xb1\xed\xd0\x9f\x41\x28\x1a\xb1\x6b" "\x69\x23\xd6\x69\x35\x9e\xb4\xbc\x8d\xc6\x70\x2a\xd1\xa6\xf0" "\xea\xc2\x68\xe8\x25\x88\x7f\x8b\x78\x54\x6f\xdf\xc0\x69\xe1" "\xe2\x62\xf8\x09\xb2\x40\xc5\xd6\x84\xa0\xde\xe5\x78\xa7\x90" "\x4b\xe0\x49\x9b\x3b\xeb\xd0\x69\xf1\xb7\x3e\xd0\x25\xe8\x79" "\x9d\xf7\x69\x78\xcf\xa7\x30\x07\x77\x32\x88\xdc\x6a\x83\x83" "\x5f\x7d\x2f\x8d\x53\xcc\xcd\x97\x73\xdc\x55\x16\x2e\x7f\xde" "\xac\x24\x10\x19\x74\x75\x10\xf8\xf8\x66\x51\xa9\x62\xa5\x4f" "\xad\x12\xd6\x78\xae\xe9\xc6\xb4\xb1\x30\xb0\x46\xad\xa6\x5d" "\xca\xe6\x8c\x81\x38\xfc\xfd\xea\x3b\xdb\x9c\xe3\x7d\x08\x59" "\x0f\x2c\x88\x75\xa5\x9f\x74\x91\xae\x15\x8f\xa4\x8c\x82\x62" "\xa9\xb8\x0c\x5e\x58\xdb\x43\xb2\xb6\xa8\x79\x1e\x2b\x24\x23" "\x7b\xd1\xe7\xa8\x6f\xe0\x72\xba\x0c\x83\xca\x02\x74\x64\x38" "\x95\xdf\x3b\x4a\x73\x04\x09\xda\x33\xdb\x3d\x77\x7a\xaa\x81" "\x89\xc7\xfe\xdd\xcb\x3d\x5a\x8e\x3f\xb0\x27\x54\x3b\x75\x9f" "\x9c\x49\xa5\x72\x20\xe0\xd0\x37\xea\xc4\x67\x8e\xe6\xab\x6a" "\x9a\x50\xa8\x35\xb5\xe8\x6b\x6c\x7e\xc7\xf5\x3c\xd6\xd0\xbc" "\x3c\x9c\xb4\x6e\x3c\x98\x3f\x1a\xe9\x6a\xd2\xbc\x75\x4a\x42" "\xe6\x47\xce\x2a\x65\x36\x33\xf1\x31\xc6\x89\x0e\x4f\x4b\x0b" "\xef\x4a\xa2\x7c\x65\xe9\xad\x28\xc0\x0e\x6c\x11\xf5\x50\x4f" "\xb6\x8a\x67\xad\x71\x77\x00\x96\x5a\xa4\xbb\x51\xa4\x4c\x77" "\x08\xbc\x40\x61\x58\x92\x93\x04\xaa\x7c\x0a\xbe\xfe\xb4\x16" "\xdc\x76\x9d\x66\x72\x77\xd1\x97\x27\x07\x8a\x57\xe7\x49\x12" "\xa9\x7d\x1b\xf8\xd8\x7e\xed\xfa\xf7\xe4\x5f\x90\x2b\x45\xa7" "\xc3\x5c\x8e\xb9\x92\x02\xbc\x56\x37\x3c\xc8\x4f\xa5\xd6\x85" "\xeb\x9f\xee\x01\x30\x71\x44\xa3\xda\xa6\xd5\xdf\x34\x8c\x31" "\x48\x60\xaf\x17\x43\x31\x12\x0b\xaa\x10\x0b\x3e\x8c\x6e\x41" "\x15\xc6\xb0\xd2\xbc\xc7\x7c\x7f\xc0\x4f\x39\xc7\xf5\xda\x3f" "\xbb\xd9\x86\x45\x47\x1f\x8a\x5c\x46\xad\x68\xd5\x3b\x8a\xb0" "\xe6\x1b\xc6\xfb\x0f\x70\x89\xd8\x10\x2d\xcb\xb9\xf3\xa3\xd4" "\x23\xd5\xb1\xb5\x9b\x92\x8b\xe2\x40\x85\xec\xf6\x71\xc2\x45" "\x4b\x31\xa5\xcb\xc5\x46\x5a\x98\xfb\x48\x9d\x42\x06\x51\x0c" "\x1f\x39\xfa\x7b\xe9\x39\x3f\x06\xa5\xe4\xc8\x92\x43\x65\xff" "\x4e\xa4\x6d\x97\xd6\xc4\x62\x2d\x00\x5c\x71\xde\x47\x5a\x99" "\x3f\x3b\xf9\xcf\xc5\xa8\xe8\xf8\x8f\x79\x62\x8a\xde\xcc\x3e" "\x25\x55\x02\x05\x73\x24\xf2\x3f\xd8\xbd\x70\xb8\xa3\xed\xab" "\x08\xad\xff\xf7\x35\x2e\x0f\xfb\x45\xe6\xd3\xfd\xdf\xaa\x6e" "\xc1\x33\x69\xf2\xf8\x40\x5f\xda\x84\x70\xbe\x1d\xf2\xd6\x56" "\x91\xf0\x24\x33\x89\xf3\x52\x0c\x84\x1f\x0f\xf5\xcb\x1c\x44" "\xa5\x5d\xbc\x9b\xc1\x7c\xbc\x00\x26\xec\x46\x9a\x3b\x25\xa1" "\x62\xa0\xd7\x72\x31\xe6\x7a\xa6\xf4\xed\xb3\x8b\x3b\x44\xca" "\x86\x8a\x3a\xc3\x2f\x86\x62\xfc\x55\x56\x2f\x96\x99\x1b\x1e" "\xf1\xb6\xd2\x95\x03\x7f\xa4\x55\x6a\xa4\x7b\xbf\xbb\x53\xc8" "\xfa\x46\x65\xab\x09\xd0\xe4\x92\x69\x4e\x55\x1a\x6b\xab\x64" "\xd5\x6b\x16\xc0\x08\x3f\x62\x23\x7a\xad\x47\x95\xe1\x75\x2f" "\x44\xac\x11\x3a\xaf\x2a\x6f\xb4\x30\xf5\x4f\x68\x7f\x41\x3e" "\x27\x62\x1b\x25\x5d\x0a\xa5\xc4\x4f\x17\xaf\x13\x7a\xff\x48" "\x18\xe0\xc6\x15\x9b\xa4\xa8\x34\x81\xa3\x4d\x86\x3d\xc4\xb1" "\x5a\xf4\x7e\x86\x7b\x00\x62\xae\x68\x03\x90\x29\x4c\xa0\xa8" "\xa1\x73\x8c\xf8\xd7\x03\x96\xab\xd2\xdc\xd0\xf7\x45\x87\x7e" "\xe1\xee\xf0\x9d\x42\x53\x8b\x15\xc1\xb4\xab\x45\x59\x5a\x40" "\x58\xf5\xa4\xda\x26\xd0\x40\x8f\xd0\xc0\x85\xdb\xa0\x23\x94" "\xef\xd3\xb8\x6a\x60\x1c\x4a\x97\x8f\x91\x68\x70\xec\x1c\x97" "\x62\x97\x40\x99\xb9\x3a\x9b\x52\x60\x3c\xb2\xdc\xc6\x4a\xec" "\x7e\x2a\x22\x82\x57\x81\x81\xfd\x2c\xed\xc6\x83\x41\x62\x3c" "\x90\xd1\xc2\xfc\xa9\x09\x8f\x42\xe6\xd1\xfa\x65\x41\xf5\x08" "\xb6\x3d\xe5\x77\x9b\x8f\xce\xd9\x9c\x88\xc1\x6d\x8b\x7b\x73" "\x92\x12\x80\x7c\x2e\x79\xd7\x5d\x30\x2a\x3d\xbf\x2b\x60\x84" "\xa5\xf8\x5d\xd7\xeb\x1a\x58\x79\xb5\xa4\x0c\x2b\x20\xa5\xbc" "\x01\xce\xd8\xd5\xd6\x45\xb3\x79\x29\xde\x62\x3f\x04\x57\x57" "\xa7\x88\x2f\xe7\x07\x21\x4c\x8d\xe7\x52\xc7\xe1\xa5\x12\x19" "\x5f\x0f\x19\x9e\x92\xdd\xb3\xc5\x10\x46\xea\xfc\xe1\x59\xc4" "\xe8\xb6\x22\xd3\x1f\x2d\x9d\x7f\xdc\xc9\x96\xf2\x7e\xdf\xbc" "\xe8\xff\x86\x3d\x93\x5b\x4d\x59\xa7\x8a\xad\x09\x73\x3c\x62" "\x77\x25\x9d\xb7\x8d\x61\xcd\x21\x67\x34\x7e\xe2\x1a\x6b\x69" "\xb1\x3b\x10\x68\x85\x9c\x9b\x86\x44\x96\x36\xb1\x15\x92\x29" "\x18\x6a\x86\x39\x28\x0b\xb8\xc3\x60\x12\xc5\xac\x35\xa3\x35" "\xf6\xb1\xb3\xdf\x00\xfb\x3a\xed\xca\x46\x7d\x8f\xa3\x4d\x77" "\x05\xd7\xb8\xa8\xe3\xca\xdd\xfe\x2d\x12\x5b\x08\xd4\x36\xa1" "\xa0\x07\xa8\x2d\x31\x2f\x8a\x0d\xec\x07\x8a\xe0\x31\x0f\xb4" "\xb1\x51\x60\xa8\xc7\x5b\x3f\x83\xf2\xfb\x4d\x2a\x24\xf3\x52" "\x2c\xa1\x83\x58\x08\x03\xdf\x04\x6c\x40\x1e\x25\x83\x0c\x74" "\xc2\x93\x89\xc1\x31\x74\x8f\x77\xbb\x7b\x78\x15\x26\x06\x89" "\xe7\x47\x04\x22\x14\x28\xfc\xf7\xae\xfc\xd9\xbc\x95\x5d\x92" "\x42\x52\x7a\x94\x85\x3f\x11\xdb\xca\xc7\xa8\x62\x30\xaa\x66" "\x1a\xf4\xd5\x1d\xf1\x4d\xba\x53\xce\xda\x63\xa4\x4f\x30\xfe" "\x04\x1d\xf4\x5e\x9c\x4a\x83\xf3\xc7\x58\x71\xea\xd2\x1b\x26" "\x66\x8c\x90\xfe\xae\x82\x43\x97\x79\x1d\x6c\x21\x1f\xc1\x19" "\x89\xc8\x15\xc4\x7a\x06\x3e\x98\x11\x71\xc0\x70\x45\x19\xed" "\x2a\x31\x28\x54\xda\x36\xe3\x38\x3a\x70\x60\xd1\xc2\xa7\xfc" "\x08\x46\x0b\x82\xf2\x48\x74\x82\xce\x74\xf1\x0e\xaf\x11\x99" "\x73\xcc\x70\x73\x3a\xcb\x07\x1a\xe6\x88\x1d\xd6\x11\x0f\x06" "\xc9\x93\x92\x0d\xbf\xb9\xd6\x7f\x17\x9f\xb7\x6a\xb4\x23\x37" "\x84\x10\xe4\x70\xf6\x64\x30\x7f\xe3\x01\x31\x4d\x67\x1a\x43" "\x7e\xe0\x7f\x32\xd6\x32\x9d\xfd\x77\xcf\x84\x69\x52\x28\xd0" "\xb0\x50\x7d\x8b\x92\x28\x0e\x44\xa8\x4c\x27\x79\x70\xed\x44" "\xd4\x42\xc6\x6e\x57\xfa\xe7\x0a\x2c\xf8\x23\x8b\x1d\x01\xcd" "\x24\x4e\x51\xb3\x81\xa7\x76\x49\x0f\x51\x23\x87\xab\x32\x14" "\xb3\xb3\x01\x37\x8f\x24\x5a\x21\x50\xbe\x0a\x6d\xfc\xb0\xd9" "\x8d\xf7\xe3\x56\xee\x24\x00\xaa\x76\x6c\xfd\x44\x44\xb4\xd1" "\x56\xe8\x45\xb9\xd8\x11\x40\x12\x62\x80\x15\xfe\xcf\x04\x2b" "\xe7\xbb\x34\x2c\xa1\x5e\x62\x6d\x1d\xa0\xd2\xd5\xcd\x1a\x4c" "\x66\x1e\x18\x1d\xf3\x9d\x29\x75\x13\xc9\x46\x2a\xe4\xf3\xfa" "\xbf\x3c\xce\x8b\xe1\xf1\xb5\x53\xe4\xfb\xed\x88\x14\xfe\xf6" "\xaf\x6d\xb0\xe1\xe4\x3f\x4a\x1b\x75\xa5\x76\x1e\xda\xf2\xe7" "\xff\x08\xed\xe9\xcd\xf2\x3b\x3e\x54\x06\x93\x23\x27\xfb\x64" "\x06\x92\x14\xee\x0a\x0b\xcd\x31\x43\x23\x0f\xad\x00\x8f\x4a" "\xe2\xa2\xaf\x97\xbd\xa4\xc7\x6d\x48\x64\xb4\x68\xea\x38\x2f" "\xf3\xd1\x3a\xc8\x71\x6b\x06\x98\x40\xd2\x5a\xb9\x8e\x49\x88" "\x65\xb5\xa5\x9f\xed\x16\x30\x3c\x9a\xe0\xf0\xbc\xce\xd1\x50" "\x3a\xee\x68\x08\x97\xea\x64\x66\x41\x05\x67\x1e\xc1\x03\xf7" "\x9c\x75\xff\x66\xb5\xf7\x8a\x55\x73\x49\x1e\x75\xde\xe5\x13" "\x77\x60\x2e\x7a\xc2\xd9\xf7\xbe\xe9\xc0\xd1\x97\xfc\x21\xe8" "\x2f\xf1\x67\xa2\xcf\x5c\x48\x7b\x28\x95\x81\x3c\xa7\x75\xd3" "\x17\x78\xf1\xde\xb6\x02\xd1\xce\x1f\x85\xc2\xba\x59\xf1\xad" "\x84\x35\x4b\x06\x68\xbd\x1d\x32\xe2\x87\xb1\x95\xee\xbf\x0d" "\xf0\xc9\x4a\x64\xc8\x93\x61\xa7\x8f\xe0\x5b\x78\xc9\xc2\x31" "\x5d\xc2\x9e\x39\x2c\x86\x8c\xe4\xd5\xb4\x89\x76\x67\x37\x31" "\x0e\xfa\x4f\xe5\x8c\x92\x31\xde\xe8\xf9\xbb\x46\x4a\xf2\xfc" "\xfc\x16\x87\xf0\x90\x6b\xce\x41\x66\x0a\x9b\x4e\xd0\x5d\xe2" "\xb9\x21\xd6\x47\x50\x28\xd1\xa4\xee\x89\x1d\xdb\x25\x85\xae" "\xd6\xef\x47\xea\x60\xc1\xdd\x0e\x93\x38\xac\xec\xfe\xcc\x8d" "\x81\x3e\x15\xd4\xf0\xbc\x56\xa6\xd2\xd3\xdc\xa7\x1a\x06\x96" "\x95\x6e\x60\x15\x2f\xf3\x72\xb5\x3a\x3f\x60\x69\x2f\x90\x1b" "\xd5\xf8\x3d\xc3\x28\x72\x80\x4c\x5d\x47\xc6\xc9\x63\x21\x88" "\xcb\x56\xf2\x44\xd2\x5a\xfd\xd8\x99\x9d\x8b\x39\xb2\x6f\xbc" "\xb9\x12\x92\x97\x20\x6a\xc6\x76\x89\xfb\xf6\xdc\x1d\xdd\xad" "\x55\xa2\xf9\x50\x88\xc1\xc5\x53\xa2\xc0\x3a\x48\x63\x34\x53" "\x48\xee\xbd\x5c\x0e\x2a\x22\x20\xb3\x7a\x2b\xbc\x0c\xa5\xb6" "\xd2\x75\xb8\x0c\xbb\x18\x54\xdf\x28\xb3\xaa\x4e\x7f\x02\xae" "\x18\x56\x74\x49\x23\xd5\x77\xcb\x1f\x02\x41\xdb\x08\x46\x19" "\xcb\x95\xd9\x3e\xa1\x78\x3b\x43\x29\xb8\xef\x62\x60\x89\x56" "\x8d\xfe\xf0\xee\x89\x01\xe4\x7f\x96\x63\xdc\xde\x3e\x98\x39" "\x71\x91\x64\xef\xea\x6f\x3e\xec\xcd\x01\xa3\xd9\xec\xe2\x14" "\xd1\xc0\x3f\x3d\x30\x65\xa8\x47\x74\xe0\xd9\x66\x13\xf9\x76" "\x41\x92\xb5\xc6\x14\xc7\x0a\xdc\xd7\x09\x70\x67\xdd\x98\xbb" "\x0f\x83\x59\x88\x6b\x3c\x2a\x61\xd5\xf8\x4c\x40\xf3\xa2\x50" "\x77\xeb\x20\x88\x33\x88\xbd\xb4\xb9\x1f\xf5\xe7\xb1\x11\x98" "\xdf\xae\x06\x40\xcc\x09\x5c\x03\xdc\xd3\xdc\x7d\xae\x78\xfd" "\x75\x44\xb9\x44\xeb\xf7\xc3\xed\xb8\xc1\x64\x81\x5c\xac\x96" "\x75\x39\x8b\xc6\x83\xc9\xa6\x46\xa5\x9b\x60\xab\xe5\x1d\xb9" "\x7c\x86\xab\x93\x3d\x64\x40\x17\xaf\xa7\xe1\xdb\x9e\xc2\xd6" "\x4c\x31\xed\xaa\xc5\x57\x0f\x8f\x90\x99\x69\x50\xe5\xef\x3e" "\x77\xea\xce\xf6\x3a\xe6\x3e\x92\x97\xcc\x63\x7a\x8e\x40\x8d" "\x96\x6a\xa9\x42\x27\x91\x8e\xcf\xd7\x76\x57\x6d\x3b\x40\xf7" "\x93\x83\x23\x74\x7c\xec\x37\x88\xca\xb2\x3d\x70\xb3\x76\x86" "\xb8\x3a\xe7\x6b\x16\xb8\xc0\x14\xbc\x37\x0e\xbd\x85\xf8\xed" "\x50\xc9\xc6\x80\x75\x48\x56\x9d\xba\x04\x77\xe6\x57\x72\xbc" "\xc8\x66\x63\x81\x41\xac\x79\x17\xa7\xb1\x93\x91\x6e\x48\x74" "\x49\x18\x73\x84\x24\x23\xc6\x07\x2e\xe0\xe2\x16\xce\x1f\x9f" "\xfb\x6a\x46\x49\xcc\xc1\x3f\xc4\xef\x4d\x88\x2d\x4e\x40\x45" "\x80\x9e\xa0\x90\x52\x68\xe7\x86\xe4\x3d\x53\x82\xf9\x2d\x2f" "\x5f\x2b\x32\x47\x9e\x25\x51\xa8\xc6\xd6\xc1\x37\xb9\xd1\x25" "\xfc\xba\x48\xd8\x8f\xd6\xae\x44\xb8\x72\x7f\xa7\x65\xb8\xe2" "\x05\x2d\x3d\x4b\x2b\xcf\x5b\x83\xb4\x1b\x3f\x8b\xfb\x1e\x0e" "\x13\x28\x13\x31\x45\x11\x35\xb8\xbe\x09\xbb\x21\xdc\x12\x1a" "\x94\x99\x4a\x74\x9c\xc6\x4e\xbd\xd2\xa6\x68\xa5\x67\x3e\x25" "\x3d\x58\x59\xee\x0e\x7c\x75\x48\xb9\x62\x27\xe5\x48\xf0\x66" "\x31\x61\x20\xec\xa0\xc3\xf7\x91\xc4\xf5\x2c\x32\x2e\x91\x89" "\xce\x16\x75\xc2\xd1\x9e\x90\x3a\x7b\xc8\x07\x3f\x12\xb0\x1d" "\x04\xcc\x72\x9b\x01\x4a\x8d\x7e\x78\xe6\xd6\xe0\xc1\x3b\xf5" "\xd4\x78\x5c\x53\x0f\x54\xa4\x11\xd5\x85\x7c\xf7\x8d\x41\x88" "\x22\x79\x39\x83\x68\x76\xd0\xa9\xd0\xa3\xa4\xc8\x33\xad\x13" "\x0e\x14\xd4\x3a\x9d\x2a\x0b\x12\x5b\x98\x9d\xf9\xa6\xb0\x25" "\xed\xb5\xe7\x21\x69\x77\x87\xec\xb1\xfe\xd7\xe5\xa9\x8f\x09" "\xe2\x40\xb3\x19\x2c\xe7\x08\x40\x9e\x49\xe1\x8d\x5e\x75\xbe" "\xf1\x0f\x47\x02\x18\xd2\x3d\xfa\xbf\x0c\xaf\xc7\x1c\x59\x07" "\xf8\x44\x6a\x26\x35\x51\x31\x7a\xc5\xbf\x57\xb7\xa1\xa8\x6a" "\x71\xe0\xd9\x43\xcd\x7a\x9d\x15\xb0\xfc\x21\xfe\x78\xab\x4d" "\x01\xba\x70\x3c\xaa\x46\x47\x25\xdd\xa0\x93\x9f\x56\xa7\x62" "\x21\xe1\xd9\xae\xab\x35\xf5\xb7\x7c\xc5\xf2\xea\xac\x39\x02" "\xd9\xd4\x66\xd8\xc2\x8e\xf1\x5a\x6c\x87\x82\x5a\xeb\xbb\xeb" "\x8f\x71\xd2\x68\x8e\xc7\xa2\xb8\xcd\x4b\x72\x3e\x1d\x24\x0b" "\x91\x82\xeb\xf1\x66\xac\x6b\xb6\xa2\x9a\xa7\xa8\x79\xf9\x0d" "\xaa\x14\xbd\x6d\x85\x2c\x89\x6d\x86\x8e\xfa\x03\x0c\x10\xec" "\xdb\x1e\xff\xa4\x6b\x52\x65\x4f\x0e\x2b\x0f\xce\x29\x32\xc2" "\x1f\xfa\xd7\x99\x3e\xb9\xa7\xb0\x47\x51\x1a\x2f\x32\x56\x93" "\x03\x89\xd6\x0e\x09\x18\x13\x48\x8a\xb0\xc2\xae\x50\xc5\xf3" "\xcb\xd0\x13\xec\x7e\x83\x34\xe1\xf9\x94\xbf\x45\xf0\x32\xe4" "\x9e\x0f\xd2\x52\x27\xd4\x51\x85\x99\x5e\x55\xc0\x7d\x40\xe5" "\x46\x02\xed\xa4\xd6\xe6\x1a\xde\xaf\x5b\x6f\x53\x6c\x4b\x0e" "\xd9\x49\x74\xb9\xf9\xf2\xf3\x19\xb1\xb7\xa6\x98\xfc\xde\x10" "\x55\x57\x07\xc9\x54\xa9\xf8\xb6\xa8\x75\x96\x76\x56\xe7\x74" "\x39\x28\x73\x33\x25\xa3\x57\xa4\xd2\xd7\x36\xd9\x2f\x20\x1f" "\xf5\x41\x21\x6b\x9e\x88\x8f\xaf\x3d\xe7\x3d\xe7\x9d\x3d\x97" "\xf4\xd0\x5e\x65\x7f\xaa\x1e\xc9\xd4\x55\xee\x42\xac\x8e\x3f" "\x6b\x5a\xa8\xe2\x93\x50\xca\x85\xb5\x84\x80\xc6\xb5\xe2\x12" "\x34\xe2\x5b\xbe\x40\x68\x2a\xfb\x0f\x0d\xa5\x53\xe8\xe9\x3c" "\x11\xab\xd9\x08\x38\x4c\x6b\x74\x9b\x58\x39\xbe\x72\x6b\x01" "\x53\xea\x95\x6a\x43\xaf\x4c\x0c\xa6\x65\xde\x90\xaa\x48\x61" "\x19\x9b\xce\xa6\x40\xf1\x07\x89\x31\xe8\x02\x9a\x0d\xb1\x02" "\x0c\x72\x93\xbe\xd0\x2b\x37\xe6\x4b\x0b\x47\xf4\x03\x8e\x2f" "\x5d\x37\x61\x2d\x0d\xeb\x9c\xe5\x58\xbc\xb4\x25\xb4\x4c\xab" "\xd3\xe7\xae\x13\xd8\xd0\xc9\x68\x0c\xad\x27\x9d\x01\xbd\x12" "\xe2\xa5\x42\xc7\x60\x90\x7c\x44\xe7\xe4\xfc\x72\x20\x75\xb2" "\xe7\x72\xd3\x8e\x84\xf4\x1d\x1c\x40\x27\x7a\xcf\xc1\xf8\x66" "\x0f\xcf\xaf\xec\xac\x26\x06\x12\x1d\x7e\x56\x96\x5a\x0e\x02" "\xc2\xd9\x4c\x43\x76\x10\x77\x65\x2d\xaa\x73\xa7\xda\xcb\x09" "\x36\xa2\x0d\x2c\x4a\xde\x0b\x08\x47\x3b\xca\x50\x1f\x67\xe4", 4095); struct csum_inet csum_67; csum_inet_init(&csum_67); csum_inet_update(&csum_67, (const uint8_t*)0x20df2fe8, 4); csum_inet_update(&csum_67, (const uint8_t*)0x20df2fec, 4); uint16_t csum_67_chunk_2 = 0x2100; csum_inet_update(&csum_67, (const uint8_t*)&csum_67_chunk_2, 2); uint16_t csum_67_chunk_3 = 0x1000; csum_inet_update(&csum_67, (const uint8_t*)&csum_67_chunk_3, 2); csum_inet_update(&csum_67, (const uint8_t*)0x20df2ff0, 16); *(uint16_t*)0x20df2ff6 = csum_inet_digest(&csum_67); struct csum_inet csum_68; csum_inet_init(&csum_68); csum_inet_update(&csum_68, (const uint8_t*)0x20df2fdc, 20); *(uint16_t*)0x20df2fe6 = csum_inet_digest(&csum_68); r[69] = syz_emit_ethernet(0x1031ul, 0x20df2fceul); break; case 5: *(uint8_t*)0x20df2fce = (uint8_t)0xbb; *(uint8_t*)0x20df2fcf = (uint8_t)0xbb; *(uint8_t*)0x20df2fd0 = (uint8_t)0xbb; *(uint8_t*)0x20df2fd1 = (uint8_t)0xbb; *(uint8_t*)0x20df2fd2 = (uint8_t)0xbb; *(uint8_t*)0x20df2fd3 = (uint8_t)0x0; *(uint8_t*)0x20df2fd4 = (uint8_t)0xbb; *(uint8_t*)0x20df2fd5 = (uint8_t)0xbb; *(uint8_t*)0x20df2fd6 = (uint8_t)0xbb; *(uint8_t*)0x20df2fd7 = (uint8_t)0xbb; *(uint8_t*)0x20df2fd8 = (uint8_t)0xbb; *(uint8_t*)0x20df2fd9 = (uint8_t)0x0; *(uint16_t*)0x20df2fda = (uint16_t)0x8; STORE_BY_BITMASK(uint8_t, 0x20df2fdc, 0x5, 0, 4); STORE_BY_BITMASK(uint8_t, 0x20df2fdc, 0x4, 4, 4); STORE_BY_BITMASK(uint8_t, 0x20df2fdd, 0x0, 0, 2); STORE_BY_BITMASK(uint8_t, 0x20df2fdd, 0x0, 2, 6); *(uint16_t*)0x20df2fde = (uint16_t)0x1c00; *(uint16_t*)0x20df2fe0 = (uint16_t)0x6400; *(uint16_t*)0x20df2fe2 = (uint16_t)0x0; *(uint8_t*)0x20df2fe4 = (uint8_t)0x0; *(uint8_t*)0x20df2fe5 = (uint8_t)0x11; *(uint16_t*)0x20df2fe6 = (uint16_t)0x0; *(uint8_t*)0x20df2fe8 = (uint8_t)0xac; *(uint8_t*)0x20df2fe9 = (uint8_t)0x14; *(uint8_t*)0x20df2fea = (uint8_t)0x0; *(uint8_t*)0x20df2feb = (uint8_t)0xbb; *(uint32_t*)0x20df2fec = (uint32_t)0x10000e0; *(uint16_t*)0x20df2ff0 = (uint16_t)0x204e; *(uint16_t*)0x20df2ff2 = (uint16_t)0x224e; *(uint16_t*)0x20df2ff4 = (uint16_t)0x800; *(uint16_t*)0x20df2ff6 = (uint16_t)0x0; struct csum_inet csum_102; csum_inet_init(&csum_102); csum_inet_update(&csum_102, (const uint8_t*)0x20df2fe8, 4); csum_inet_update(&csum_102, (const uint8_t*)0x20df2fec, 4); uint16_t csum_102_chunk_2 = 0x1100; csum_inet_update(&csum_102, (const uint8_t*)&csum_102_chunk_2, 2); uint16_t csum_102_chunk_3 = 0x800; csum_inet_update(&csum_102, (const uint8_t*)&csum_102_chunk_3, 2); csum_inet_update(&csum_102, (const uint8_t*)0x20df2ff0, 8); *(uint16_t*)0x20df2ff6 = csum_inet_digest(&csum_102); struct csum_inet csum_103; csum_inet_init(&csum_103); csum_inet_update(&csum_103, (const uint8_t*)0x20df2fdc, 20); *(uint16_t*)0x20df2fe6 = csum_inet_digest(&csum_103); r[104] = syz_emit_ethernet(0x2aul, 0x20df2fceul); break; } return 0; } void test() { long i; pthread_t th[12]; memset(r, -1, sizeof(r)); srand(getpid()); for (i = 0; i < 6; i++) { pthread_create(&th[i], 0, thr, (void*)i); usleep(rand() % 10000); } for (i = 0; i < 6; i++) { pthread_create(&th[6 + i], 0, thr, (void*)i); if (rand() % 2) usleep(rand() % 10000); } usleep(rand() % 100000); } int main() { setup_tun(0, true); loop(); return 0; }
the_stack_data/165767869.c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_str_is_lowercase.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: bbatumik <[email protected]> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/09/13 13:51:17 by bbatumik #+# #+# */ /* Updated: 2019/09/14 16:14:00 by bbatumik ### ########.fr */ /* */ /* ************************************************************************** */ int ft_str_is_lowercase(char *str) { int i; i = 0; while (str[i]) { if (str[i] < 'a' || str[i] > 'z') { return (0); } i++; } return (1); }
the_stack_data/542013.c
#include <stdio.h> #define SIZE 5 int main() { int score[SIZE]; score[0] = 70; score[1] = 90; score[2] = 80; score[3] = 60; score[4] = 50; for (int i = 0; i < SIZE; i++) { printf("%d", score[i]); printf("\n"); } return 0; }
the_stack_data/34684.c
/* { dg-do compile } */ /* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */ typedef void (*dispatch_t)(long offset); dispatch_t dispatch; int male_indirect_jump (long offset) { dispatch(offset); return 0; } /* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?dispatch" { target { { ! x32 } && *-*-linux* } } } } */ /* { dg-final { scan-assembler-times "jmp\[ \t\]*\.LIND" 2 } } */ /* { dg-final { scan-assembler-times "call\[ \t\]*\.LIND" 2 } } */ /* { dg-final { scan-assembler-times {\tpause} 1 } } */ /* { dg-final { scan-assembler-times {\tlfence} 1 } } */ /* { dg-final { scan-assembler-not "__x86_indirect_thunk" } } */ /* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" { target x32 } } } */
the_stack_data/87638169.c
#include <threads.h> #include "syscall.h" void thrd_yield() { __syscall(SYS_sched_yield); }
the_stack_data/6387319.c
#include <stdlib.h> int64_t update (int64_t orig, int64_t round) { return orig + round ; } void incr_array (int64_t *arr, int64_t len, int64_t round) { int64_t i ; for (i = 0 ; i < len ; i ++) arr[i] = update (arr[i], round) ; } int main (int argc, char **argv) { int64_t nrounds, len, r, *arr ; if (argc != 3) exit (1) ; nrounds = atol (argv[1]) ; len = atol (argv[2]) ; if (NULL == (arr = calloc (len, sizeof (long)))) exit (1) ; for (r = 1 ; r <= nrounds ; r ++) incr_array (arr, len, r) ; return 0 ; }
the_stack_data/43888867.c
#include <stdio.h> #include <stdlib.h> #include <locale.h> #include <math.h> int absol(int x){ int y; if (x < 0){ y = x * (-1); } else{ y = x; } return y; } void main(){ setlocale(LC_ALL,"Portuguese"); int seq = 0; printf("Digite o tamanho da sequencia:"); scanf("%d", &seq); int tot_num_abs = 0; for (int i = 1; i <= seq; i++){ int num = 0; printf("Digite o %do numero:", i); scanf("%d", &num); tot_num_abs = tot_num_abs + absol(num); } printf("O somatorio dos numeros absolutos da seq e igual a %d", tot_num_abs); }
the_stack_data/154977.c
//@ ltl invariant negative: (([] AP(x_0 - x_7 >= -4)) U (X AP(x_4 - x_2 > -3))); float x_0; float x_1; float x_2; float x_3; float x_4; float x_5; float x_6; float x_7; int main() { float x_0_; float x_1_; float x_2_; float x_3_; float x_4_; float x_5_; float x_6_; float x_7_; while(1) { x_0_ = (((13.0 + x_1) > (14.0 + x_2)? (13.0 + x_1) : (14.0 + x_2)) > ((19.0 + x_6) > (16.0 + x_7)? (19.0 + x_6) : (16.0 + x_7))? ((13.0 + x_1) > (14.0 + x_2)? (13.0 + x_1) : (14.0 + x_2)) : ((19.0 + x_6) > (16.0 + x_7)? (19.0 + x_6) : (16.0 + x_7))); x_1_ = (((12.0 + x_0) > (8.0 + x_1)? (12.0 + x_0) : (8.0 + x_1)) > ((6.0 + x_3) > (14.0 + x_5)? (6.0 + x_3) : (14.0 + x_5))? ((12.0 + x_0) > (8.0 + x_1)? (12.0 + x_0) : (8.0 + x_1)) : ((6.0 + x_3) > (14.0 + x_5)? (6.0 + x_3) : (14.0 + x_5))); x_2_ = (((19.0 + x_0) > (5.0 + x_3)? (19.0 + x_0) : (5.0 + x_3)) > ((14.0 + x_6) > (5.0 + x_7)? (14.0 + x_6) : (5.0 + x_7))? ((19.0 + x_0) > (5.0 + x_3)? (19.0 + x_0) : (5.0 + x_3)) : ((14.0 + x_6) > (5.0 + x_7)? (14.0 + x_6) : (5.0 + x_7))); x_3_ = (((4.0 + x_0) > (2.0 + x_1)? (4.0 + x_0) : (2.0 + x_1)) > ((4.0 + x_2) > (11.0 + x_4)? (4.0 + x_2) : (11.0 + x_4))? ((4.0 + x_0) > (2.0 + x_1)? (4.0 + x_0) : (2.0 + x_1)) : ((4.0 + x_2) > (11.0 + x_4)? (4.0 + x_2) : (11.0 + x_4))); x_4_ = (((9.0 + x_0) > (11.0 + x_2)? (9.0 + x_0) : (11.0 + x_2)) > ((9.0 + x_5) > (15.0 + x_6)? (9.0 + x_5) : (15.0 + x_6))? ((9.0 + x_0) > (11.0 + x_2)? (9.0 + x_0) : (11.0 + x_2)) : ((9.0 + x_5) > (15.0 + x_6)? (9.0 + x_5) : (15.0 + x_6))); x_5_ = (((11.0 + x_0) > (20.0 + x_3)? (11.0 + x_0) : (20.0 + x_3)) > ((5.0 + x_5) > (4.0 + x_6)? (5.0 + x_5) : (4.0 + x_6))? ((11.0 + x_0) > (20.0 + x_3)? (11.0 + x_0) : (20.0 + x_3)) : ((5.0 + x_5) > (4.0 + x_6)? (5.0 + x_5) : (4.0 + x_6))); x_6_ = (((20.0 + x_1) > (14.0 + x_3)? (20.0 + x_1) : (14.0 + x_3)) > ((3.0 + x_6) > (4.0 + x_7)? (3.0 + x_6) : (4.0 + x_7))? ((20.0 + x_1) > (14.0 + x_3)? (20.0 + x_1) : (14.0 + x_3)) : ((3.0 + x_6) > (4.0 + x_7)? (3.0 + x_6) : (4.0 + x_7))); x_7_ = (((4.0 + x_1) > (2.0 + x_2)? (4.0 + x_1) : (2.0 + x_2)) > ((16.0 + x_3) > (6.0 + x_5)? (16.0 + x_3) : (6.0 + x_5))? ((4.0 + x_1) > (2.0 + x_2)? (4.0 + x_1) : (2.0 + x_2)) : ((16.0 + x_3) > (6.0 + x_5)? (16.0 + x_3) : (6.0 + x_5))); x_0 = x_0_; x_1 = x_1_; x_2 = x_2_; x_3 = x_3_; x_4 = x_4_; x_5 = x_5_; x_6 = x_6_; x_7 = x_7_; } return 0; }
the_stack_data/887823.c
/* ************************************************ username : smmehrab fullname : s.m.mehrabul islam email : [email protected] institute : university of dhaka, bangladesh session : 2017-2018 ************************************************ */ #include<stdio.h> #include<string.h> typedef struct { char first[20]; char last[20]; } nametype; typedef struct { int id; nametype name; char grade[3]; } studenttype; void calculate_grade(studenttype s, int mark) { if(mark>=80) strcpy(s.grade,"A+"); else if(mark>=70) strcpy(s.grade,"A"); else if(mark>=60) strcpy(s.grade,"A-"); else if(mark>=50) strcpy(s.grade,"B"); else if(mark>=40) strcpy(s.grade,"C"); else strcpy(s.grade,"F"); } int main() { studenttype student[3]; int i,n=3; int marks[]={72,82,60}; for(i=0;i<n;i++) { printf("Enter the ID for student %d: ",i+1); scanf("%d",&student[i].id); printf("Enter the first name for student %d: ",i+1); scanf("%s", student[i].name.first); printf("Enter the last name for student %d: ",i+1); scanf("%s", student[i].name.last); strcpy(student[i].grade,""); printf("\n"); } for(i=0;i<n;i++) { calculate_grade(student[i],marks[i]); } printf("OUTPUT: \n\n"); for(i=0;i<n;i++) { printf("ID: %d\n",student[i].id); printf("Name: %s %s\n",student[i].name.first,student[i].name.last); printf("Grade: %s\n",student[i].grade); } return 0; } // We have called the function by value. That's why the value of local variable has changed inside function. But outside the function, //the value of global variable has remained same. That's why, the grades are not being showed up.
the_stack_data/135684.c
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <sys/wait.h> #define MAXCHILD 5 int main(){ pid_t child [MAXCHILD]; int inChild=0; int status=0; for (int i=0;i<MAXCHILD;i++){ child[i]=fork(); if(child[i]==0){ inChild=1; break; } } while (inChild==1){ srand(getpid()); int r = rand()%10; printf("message from child %d : sleeping %d seconds\n",getpid(), r); sleep(r); inChild=-1; } while(inChild==0){ sleep(1); for(int i=0;i<MAXCHILD;i++){ int child_d; //**comment from next line child_d = wait(&status); if (child_d>0) printf("child[%d] is dead now \n",child_d); else if(child_d==-1) printf("no child to wait for \n"); //**comment till this line // child_d = waitpid(child[i],&status,0); // if(child_d==0) // printf("child[%d] is still alive\n",child[i]); // else if(child_d>0) // printf("child[%d] is dead now \n",child[i]); // else // printf("no specified child to wait for \n"); } } return 0; }
the_stack_data/75138334.c
#include <stdio.h> int main () { int a,b,c; scanf("%d:%d:%d",&a,&b,&c); printf("%d",b); return 0; }
the_stack_data/592566.c
#include <stdio.h> #include <stdlib.h> int main(void) { FILE * file; int num; char ch; file = fopen("sample.txt", "r+w"); if (file == NULL) { printf("\nUnable to open file.\n"); printf("Please check if file exists and you have read privilege.\n"); exit(EXIT_FAILURE); } printf("Enter num: "); scanf("%d",&num); fprintf(file,"%d",num); fscanf(file,"%d",&num); printf("value = %d",num); fclose(file); return 0; }
the_stack_data/55977.c
/* Wrapper for __log1p that handles setting errno. Copyright (C) 2015-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ /* Nothing to do. errno is set in sysdeps/ia64/fpu/s_log1p.S. */
the_stack_data/395190.c
/* t40f.c * * Test timing * * Select works on regular files, (pseudo) terminal devices, streams-based * files, FIFOs, pipes, and sockets. This test verifies selecting with a time * out set. */ #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <sys/select.h> #include <sys/wait.h> #include <sys/time.h> #include <time.h> #include <errno.h> #include <string.h> #include <signal.h> #define DO_HANDLEDATA 1 #define DO_PAUSE 3 #define DO_TIMEOUT 7 #define DO_DELTA 0.5 #define MAX_ERROR 5 #define DELTA(x,y) (x.tv_sec - y.tv_sec) * CLOCKS_PER_SEC \ + (x.tv_usec - y.tv_usec) * CLOCKS_PER_SEC / 1000000 int errct = 0, subtest = -1, got_signal = 0; int fd_ap[2]; void catch_signal(int sig_no) { got_signal = 1; } void e(int n, char *s) { printf("Subtest %d, error %d, %s\n", subtest, n, s); if (errct++ > MAX_ERROR) { printf("Too many errors; test aborted\n"); exit(errct); } } float compute_diff(struct timeval start, struct timeval end, float compare) { /* Compute time difference. It is assumed that the value of start <= end. */ clock_t delta; int seconds, hundreths; float diff; delta = DELTA(end, start); /* delta is in ticks */ seconds = (int) (delta / CLOCKS_PER_SEC); hundreths = (int) (delta * 100 / CLOCKS_PER_SEC) - (seconds * 100); diff = seconds + (hundreths / 100.0); diff -= compare; if(diff < 0) diff *= -1; /* Make diff a positive value */ return diff; } void do_child(void) { struct timeval tv; int retval; /* Let the parent do initial read and write tests from and to the pipe. */ tv.tv_sec = DO_PAUSE + DO_PAUSE + DO_PAUSE + 1; tv.tv_usec = 0; retval = select(0, NULL, NULL, NULL, &tv); /* At this point the parent has a pending select with a DO_TIMEOUT timeout. We're going to interrupt by sending a signal */ if(kill(getppid(), SIGUSR1) < 0) perror("Failed to send signal"); exit(0); } void do_parent(int child) { fd_set fds_read; struct timeval tv, start_time, end_time; int retval; /* Install signal handler for SIGUSR1 */ signal(SIGUSR1, catch_signal); /* Parent and child share an anonymous pipe. Select for read and wait for the timeout to occur. We wait for DO_PAUSE seconds. Let's see if that's approximately right.*/ FD_ZERO(&fds_read); FD_SET(fd_ap[0], &fds_read); tv.tv_sec = DO_PAUSE; tv.tv_usec = 0; (void) gettimeofday(&start_time, NULL); /* Record starting time */ retval = select(fd_ap[0]+1, &fds_read, NULL, NULL, &tv); (void) gettimeofday(&end_time, NULL); /* Record ending time */ /* Did we time out? */ if(retval != 0) e(1, "Should have timed out"); /* Approximately right? The standard does not specify how precise the timeout should be. Instead, the granularity is implementation-defined. In this test we assume that the difference should be no more than half a second.*/ if(compute_diff(start_time, end_time, DO_PAUSE) > DO_DELTA) e(2, "Time difference too large"); /* Let's wait for another DO_PAUSE seconds, expressed as microseconds */ FD_ZERO(&fds_read); FD_SET(fd_ap[0], &fds_read); tv.tv_sec = 0; tv.tv_usec = DO_PAUSE * 1000000L; (void) gettimeofday(&start_time, NULL); /* Record starting time */ retval = select(fd_ap[0]+1, &fds_read, NULL, NULL, &tv); (void) gettimeofday(&end_time, NULL); /* Record ending time */ if(retval != 0) e(3, "Should have timed out"); if(compute_diff(start_time, end_time, DO_PAUSE) > DO_DELTA) e(4, "Time difference too large"); /* Let's wait for another DO_PAUSE seconds, expressed in seconds and micro seconds. */ FD_ZERO(&fds_read); FD_SET(fd_ap[0], &fds_read); tv.tv_sec = DO_PAUSE - 1; tv.tv_usec = (DO_PAUSE - tv.tv_sec) * 1000000L; (void) gettimeofday(&start_time, NULL); /* Record starting time */ retval = select(fd_ap[0]+1, &fds_read, NULL, NULL, &tv); (void) gettimeofday(&end_time, NULL); /* Record ending time */ if(retval != 0) e(5, "Should have timed out"); if(compute_diff(start_time, end_time, DO_PAUSE) > DO_DELTA) e(6, "Time difference too large"); /* Finally, we test if our timeout is interrupted by a signal */ FD_ZERO(&fds_read); FD_SET(fd_ap[0], &fds_read); tv.tv_sec = DO_TIMEOUT; tv.tv_usec = 0; (void) gettimeofday(&start_time, NULL); /* Record starting time */ retval = select(fd_ap[0]+1, &fds_read, NULL, NULL, &tv); (void) gettimeofday(&end_time, NULL); /* Record ending time */ if(retval != -1) e(7, "Should have been interrupted"); if(compute_diff(start_time, end_time, DO_TIMEOUT) < DO_DELTA) e(8, "Failed to get interrupted by a signal"); if(!got_signal) e(9, "Failed to get interrupted by a signal"); waitpid(child, &retval, 0); exit(errct); } int main(int argc, char **argv) { int forkres; /* Get subtest number */ if(argc != 2) { printf("Usage: %s subtest_no\n", argv[0]); exit(-2); } else if(sscanf(argv[1], "%d", &subtest) != 1) { printf("Usage: %s subtest_no\n", argv[0]); exit(-2); } /* Set up anonymous pipe */ if(pipe(fd_ap) < 0) { perror("Could not create anonymous pipe"); exit(-1); } forkres = fork(); if(forkres == 0) do_child(); else if(forkres > 0) do_parent(forkres); else { /* Fork failed */ perror("Unable to fork"); exit(-1); } exit(-2); /* We're not supposed to get here. Both do_* routines should exit*/ }
the_stack_data/98576376.c
/* This testcase is part of GDB, the GNU debugger. Copyright 2004-2014 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 <signal.h> #include <stdlib.h> #include <string.h> extern void keeper (int sig) { } volatile long v1 = 0; volatile long v2 = 0; volatile long v3 = 0; extern long bowler (void) { /* Try to read address zero. Do it in a slightly convoluted way so that more than one instruction is used. */ return *(char *) (v1 + v2 + v3); } int main () { static volatile int i; struct sigaction act; memset (&act, 0, sizeof act); act.sa_handler = keeper; sigaction (SIGSEGV, &act, NULL); sigaction (SIGBUS, &act, NULL); bowler (); return 0; }
the_stack_data/200143653.c
/* * Copyright (C) 2001 Free Software Foundation, Inc. * Contributed by Richard Henderson ([email protected]) * * This file 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. * * In addition to the permissions in the GNU General Public License, the * Free Software Foundation gives you unlimited permission to link the * compiled version of this file with other programs, and to distribute * those programs without any restriction coming from the use of this * file. (The General Public License restrictions do apply in other * respects; for example, they cover modification of the file, and * distribution when not linked into another program.) * * This file 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; see the file COPYING. If not, write to * the Free Software Foundation, 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * * As a special exception, if you link this library with files * compiled with GCC to produce an executable, this does not 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. */ /* Assume OSF/1 compatible interfaces. */ extern void __ieee_set_fp_control (unsigned long int); #define IEEE_MAP_DMZ (1UL<<12) /* Map denorm inputs to zero */ #define IEEE_MAP_UMZ (1UL<<13) /* Map underflowed outputs to zero */ static void __attribute__((constructor)) set_fast_math (void) { __ieee_set_fp_control (IEEE_MAP_DMZ | IEEE_MAP_UMZ); }
the_stack_data/132954235.c
/* Multiple declarations of global variables check in one file */ /* but this is OK with C... */ int a; int k; int a;
the_stack_data/22279.c
/*===-- bcmp.c ------------------------------------------------------------===// // // The KLEE Symbolic Virtual Machine // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===*/ #include <strings.h> int bcmp(const void *s1, const void *s2, size_t n) { const unsigned char *p1 = s1, *p2 = s2; while (--n != 0) { if (*p1++ != *p2++) return 1; } return 0; }
the_stack_data/181393575.c
// #include <stdio.h> int main(){ int x, y, z, t, a; printf("Please enter 4 numbers separated by spaces > "); scanf("%d %d %d %d", &x, &y, &z, &t); if (x>=y) a = y; else a = x; if (y>=z) a = z; if (z>=t) a = t; printf("%d is the smallest\n", a); return 0; }
the_stack_data/164944.c
#include <stdio.h> #include <stdlib.h> struct some_struct { int elem1; int elem2; int *ptrelem; struct some_struct *next; }; typedef struct some_struct MyStruct; void case10(MyStruct *ptr) { printf("%d\n", ptr ? 1 : 2); printf("%d\n", ptr->elem1); // XXX: null-pointer-dereference } int main() { int val = 10; MyStruct* ptr = malloc(sizeof(MyStruct)); ptr->elem1 = 1; ptr->elem2 = 1; ptr->ptrelem = &val; case10(NULL); }
the_stack_data/225142934.c
/* *File name: *Source file name: *Author: Tamkien Cao *Last modified: Tue, Feb 26th, 2019 *Other info: exercise 3.6b *Version: 1.0 */ #include<stdio.h> #include<stdlib.h> int fac(int n) { int i, s = 1; for (i = 1; i <= n; i++) { s *= i; } return s; } main() { int n, k, C; printf("This program can help you calculate a Combination ( C k/n).\n"); do { printf("Enter k here, enter 0 to exit:\n"); scanf_s("%d", &k); if (k == 0) { printf("C= 1\n"); break; } else { printf("Enter n here:\n"); scanf_s("%d", &n); if (k > n) { printf("Remember, k is never greater than n. Please try again.\n"); } else { C = (fac(n)) / (fac(k)*fac(n - k)); printf("C = %d\n", C); } } } while (1); printf("Written by Tamkien Cao. Thank you for using my application!\n"); system("pause"); }
the_stack_data/182952445.c
#include <stdio.h> int main() { return -1; }
the_stack_data/1250669.c
// This file is part of CPAchecker, // a tool for configurable software verification: // https://cpachecker.sosy-lab.org // // SPDX-FileCopyrightText: 2007-2020 Dirk Beyer <https://www.sosy-lab.org> // // SPDX-License-Identifier: Apache-2.0 #include <limits.h> // macro simplifies test code #define shouldBeTrue(a) \ if (!(a)) \ { \ goto ERROR; \ } // Test whether the side effect (=third parameter) is calculated correctly int main() { // __builtin_add_overflow { int a; long long c; // no overflow in type of c __builtin_add_overflow(INT_MAX, INT_MAX, &c); shouldBeTrue(c == 2LL * INT_MAX) int x = INT_MAX, y = INT_MAX; __builtin_add_overflow(x, y, &c); shouldBeTrue(c == 1LL*x + y) // overflow __builtin_add_overflow(INT_MAX, 1, &a); shouldBeTrue(a == INT_MIN) } // // __builtin_sadd_overflow { int a; // no overflow __builtin_sadd_overflow(INT_MAX-1ll, 1, &a); shouldBeTrue(a == INT_MAX) // overflow __builtin_sadd_overflow(INT_MAX, 4, &a); shouldBeTrue(a == INT_MIN+3) // overflow during parameter conversion and calculation __builtin_sadd_overflow(INT_MAX + 1ll, -100, &a); shouldBeTrue(a == INT_MAX - 99) } // __builtin_saddl_overflow { long a; __builtin_saddl_overflow(LONG_MAX - 1ll, 1l, &a); shouldBeTrue(a == LONG_MAX) __builtin_saddl_overflow(LONG_MAX, 4l, &a); shouldBeTrue(a == LONG_MIN + 3l) __builtin_saddl_overflow(LONG_MAX + 1LL, -100l, &a); shouldBeTrue(a == LONG_MAX - 99l) } // __builtin_saddll_overflow { long long a; __builtin_saddll_overflow(LLONG_MAX - 1LL, 1LL, &a); shouldBeTrue(a == LLONG_MAX) long c; __builtin_saddll_overflow(LLONG_MAX - 1ll, 1l, &c); shouldBeTrue(c == -1) // type conversion when writing to c __builtin_saddll_overflow(LLONG_MAX, 4LL, &a); shouldBeTrue(a == LLONG_MIN + 3LL) } // __builtin_uadd_overflow { unsigned int a; __builtin_uadd_overflow(UINT_MAX - 1ull, 1u, &a); shouldBeTrue(a == UINT_MAX) __builtin_uadd_overflow(UINT_MAX, 4u, &a); shouldBeTrue(a == 3u) __builtin_uadd_overflow(UINT_MAX + 1ull, -100u, &a); shouldBeTrue(a == UINT_MAX - 99u) } // __builtin_uaddl_overflow { unsigned long a; __builtin_uaddl_overflow(ULONG_MAX - 1ull, 1ul, &a); shouldBeTrue(a == ULONG_MAX) __builtin_uaddl_overflow(ULONG_MAX, 4ul, &a); shouldBeTrue(a == 3ul) __builtin_uaddl_overflow(ULONG_MAX + 1ull, -100ul, &a); shouldBeTrue(a == ULONG_MAX - 99ul) } // __builtin_uaddll_overflow { unsigned long long a; __builtin_uaddll_overflow(ULLONG_MAX - 1uLL, 1uLL, &a); shouldBeTrue(a == ULLONG_MAX) __builtin_uaddll_overflow(ULLONG_MAX, 4uLL, &a); shouldBeTrue(a == 0uLL + 3uLL) } // __builtin_sub_overflow { int a; long long c; // no overflow in type of c __builtin_sub_overflow(INT_MIN, 100, &c); shouldBeTrue(c == INT_MIN - 100ll) // overflow __builtin_sub_overflow(INT_MIN, 1, &a); shouldBeTrue(a == INT_MAX) } // __builtin_ssub_overflow { int a; __builtin_ssub_overflow(INT_MIN + 1ll, 1, &a); shouldBeTrue(a == INT_MIN) __builtin_ssub_overflow(INT_MIN, 4, &a); shouldBeTrue(a == INT_MAX - 3) __builtin_ssub_overflow(INT_MAX + 1ll, 100, &a); shouldBeTrue(a == INT_MAX - 99) } // __builtin_ssubl_overflow { long a; __builtin_ssubl_overflow(LONG_MIN + 1ll, 1l, &a); shouldBeTrue(a == LONG_MIN) __builtin_ssubl_overflow(LONG_MIN, 4l, &a); shouldBeTrue(a == LONG_MAX - 3l) __builtin_ssubl_overflow(LONG_MAX + 1ll, 100l, &a); shouldBeTrue(a == LONG_MAX - 99l) } // __builtin_ssubll_overflow { long long a; __builtin_ssubll_overflow(LLONG_MIN + 1ll, 1ll, &a); shouldBeTrue(a == LLONG_MIN) __builtin_ssubll_overflow(LLONG_MIN, 4ll, &a); shouldBeTrue(a == LLONG_MAX - 3ll) } // __builtin_usub_overflow { unsigned int a; __builtin_usub_overflow(1u, 1u, &a); shouldBeTrue(a == 0u) __builtin_usub_overflow(0u, 4u, &a); shouldBeTrue(a == UINT_MAX - 3u) __builtin_usub_overflow(UINT_MAX + 1ull, 100u, &a); shouldBeTrue(a == UINT_MAX - 99u) } // __builtin_usubl_overflow { unsigned long int a; __builtin_usubl_overflow(1ul, 1ul, &a); shouldBeTrue(a == 0ul) __builtin_usubl_overflow(0ul, 4ul, &a); shouldBeTrue(a == ULONG_MAX - 3ul) __builtin_usubl_overflow(ULONG_MAX + 1ull, 100ul, &a); shouldBeTrue(a == ULONG_MAX - 99ul) } // __builtin_usubll_overflow { unsigned long long int a; __builtin_usubll_overflow(1ull, 1ull, &a); shouldBeTrue(a == 0ull) __builtin_usubll_overflow(0ull, 4ull, &a); shouldBeTrue(a == ULLONG_MAX - 3ull) } // __builtin_mul_overflow { int a; long long c; // no overflow in type of c __builtin_mul_overflow(INT_MAX, 2, &c); shouldBeTrue(c == INT_MAX * 2ll) // overflow __builtin_mul_overflow(INT_MAX, 2, &a); shouldBeTrue(a == -2) } // __builtin_smul_overflow { int a; __builtin_smul_overflow(5, 2, &a); shouldBeTrue(a == 10) __builtin_smul_overflow(INT_MAX, 2, &a); shouldBeTrue(a == -2) } // __builtin_smull_overflow { long a; __builtin_smull_overflow(5, 2, &a); shouldBeTrue(a == 10) __builtin_smull_overflow(LONG_MAX, 2, &a); shouldBeTrue(a == -2) } // __builtin_smulll_overflow { long long a; __builtin_smulll_overflow(5, 2, &a); shouldBeTrue(a == 10) __builtin_smulll_overflow(LLONG_MAX, 2, &a); shouldBeTrue(a == -2) } // __builtin_umul_overflow { unsigned int a; __builtin_umul_overflow(5, 2, &a); shouldBeTrue(a == 10) __builtin_umul_overflow(UINT_MAX, 2, &a); shouldBeTrue(a == UINT_MAX - 1) } // __builtin_umull_overflow { unsigned long a; __builtin_umull_overflow(5, 2, &a); shouldBeTrue(a == 10) __builtin_umull_overflow(ULONG_MAX, 2, &a); shouldBeTrue(a == ULONG_MAX - 1) } // __builtin_umulll_overflow { unsigned long long a; __builtin_umulll_overflow(5, 2, &a); shouldBeTrue(a == 10) __builtin_umulll_overflow(ULLONG_MAX, 2, &a); shouldBeTrue(a == ULLONG_MAX - 1) } return 0; ERROR: return 1; }
the_stack_data/141351.c
/* Auto-generated, do not edit. */ const char *build_id = "20190817-084215"; const char *build_timestamp = "2019-08-17T08:42:15Z"; const char *build_version = "1.0";
the_stack_data/93888226.c
/*Title_Program for Student Information using Sequential File Roll_No_75 Batch_A4 */ #include <stdio.h> #include<stdlib.h> typedef struct { int roll; char name[25]; int m1,m2,m3; }stud; stud s; void display(FILE *); int search(FILE *,int); int main() { int i, n, key, ch; FILE *fp; char ans; printf("\nHow many Records ? "); scanf("%d",&n); fp=fopen("stud.dat","w"); for (i=0;i<n;i++) { printf("\nRead the Info for Student: %d (Roll No,Name,m1,m2,m3) \n",i+1); scanf("%d%s%d%d%d",&s.roll,s.name,&s.m1,&s.m2,&s.m3); fwrite(&s,sizeof(s),1,fp); } fclose(fp); fp=fopen("stud.dat","r"); do { printf("\n\t***MENU****"); printf("\n1.Display\n2.Search\n3.Exit"); printf("\nEnter Your choice"); scanf("%d",&ch); switch(ch) { case 1: printf("\nStudent Records in the File \n"); display(fp); break; case 2: printf("\nRead the Roll No of the student to be searched ?"); scanf("%d",&key); if(search(fp, key)) { printf("\nSuccess ! Record found in the file\n"); printf("\n%d\t%s\t%d\t%d\t%d\n",s.roll,s.name,s.m1,s.m2,s.m3); } else { printf("\nFailure!! Record with USN %d not found\n",key); } break; case 3: exit(0); default: printf("\nInvalid Option!!! Try again !!!\n"); } printf("\nDo you want to continue..."); scanf("\n%c",&ans); }while(ans== 'y'); fclose(fp); } void display(FILE *fp) { rewind(fp); printf("\nRoll\tName\tM1\tM2\tM3"); printf("\n--------------------------------------------------------------"); while(fread(&s,sizeof(s),1,fp)) { printf("\n%d\t%s\t%d\t%d\t%d\n",s.roll,s.name,s.m1,s.m2,s.m3); } } int search(FILE *fp, int key) { rewind(fp); while(fread(&s,sizeof(s),1,fp)) { if( s.roll == key) { return 1; } } return 0; } /* OUTPUT sitrc@sitrc-OptiPlex-380:~$ cd Desktop sitrc@sitrc-OptiPlex-380:~/Desktop$ gcc 9.c sitrc@sitrc-OptiPlex-380:~/Desktop$ ./a.out How many Records ? 5 Read the Info for Student: 1 (Roll No,Name,m1,m2,m3) 1 Kushal 55 65 75 Read the Info for Student: 2 (Roll No,Name,m1,m2,m3) 2 Kalpesh 75 85 89 Read the Info for Student: 3 (Roll No,Name,m1,m2,m3) 3 Harish 75 65 75 Read the Info for Student: 4 (Roll No,Name,m1,m2,m3) 4 Sudhir 55 65 75 Read the Info for Student: 5 (Roll No,Name,m1,m2,m3) 5 Anil 55 66 77 ***MENU**** 1.Display 2.Search 3.Exit Enter Your choice1 Student Records in the File Roll Name M1 M2 M3 -------------------------------------------------------------- 1 Kushal 55 65 75 2 Kalpesh 75 85 89 3 Harish 75 65 75 4 Sudhir 55 65 75 5 Anil 55 66 77 Do you want to continue...y ***MENU**** 1.Display 2.Search 3.Exit Enter Your choice2 Read the Roll No of the student to be searched ?3 Success ! Record found in the file 3 Harish 75 65 75 Do you want to continue...y ***MENU**** 1.Display 2.Search 3.Exit Enter Your choice3 */
the_stack_data/855005.c
/* dummy file */
the_stack_data/22013628.c
#include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <string.h> #include <unistd.h> #include <sys/types.h> #include <pwd.h> typedef struct { char *string; int length; }SaneString; void SaneString_alloc(SaneString *target, size_t size) { if (!target->string) // if we need to allocate a new string target->string = malloc(sizeof(char) * size); else target->string = realloc(target->string, sizeof(char) * size); target->length = size / sizeof(char); } void skipSpaces(FILE *fp) // stdin, usually { char c; while ((c = getc(fp)) == ' ') {} ungetc(c, fp); } int main(int argc, char **argv) { uid_t usr; struct passwd *pw = NULL; SaneString lineBuf; lineBuf.string = malloc(512); lineBuf.length = 512; usr = geteuid(); pw = getpwuid(usr); setenv("USER", pw->pw_name, true); setenv("HOME", pw->pw_dir, true); while (true) { char *cwd = malloc(512); char *arg = malloc(512); getcwd(cwd, 511); printf("%s\n", cwd); memset(lineBuf.string, 0, 512); // printf("%s:%s$ ", pw->pw_name, cwd); fgets(lineBuf.string, 511, stdin); lineBuf.length = strlen(lineBuf.string); if (lineBuf.string[0] == 'c' && lineBuf.string[1] == 'd') { printf("Changing directory from: "); int i = 3; for(;lineBuf.string[i] != ' '; i++); strncpy(arg, lineBuf.string + 3, 511); printf("%s\n to: %s\n", getenv("PWD"), arg); chdir(arg); } } return 0; }
the_stack_data/129913.c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_isdigit.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: dbanfi <[email protected]> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/02/26 16:46:52 by dbanfi #+# #+# */ /* Updated: 2022/02/26 16:46:52 by dbanfi ### ########.fr */ /* */ /* ************************************************************************** */ /* DESCRIPTION isdigit() checks for a digit (0 through 9). RETURN VALUE The values returned are nonzero if the character c falls into the tested class, and zero if not. */ int ft_isdigit(int c) { return (c > 47 && c < 58); }
the_stack_data/48568.c
/* PR middle-end/29584 */ /* { dg-do compile } */ extern void *foo1 (void); extern void foo2 (void); extern void foo3 (void *, void *); extern int foo4 (void); void bar (void) { int i; void *s; for (i = 1; i < 4; i++) { if (foo4 ()) foo2 (); switch (0x8000000UL + i * 0x400) { case 0x80000000UL ... 0x80000000UL + 0x3a000000UL - 1: s = 0; break; default: s = foo1 (); } foo3 ((void *) (0x8000000UL + i * 0x400), s); } }
the_stack_data/20449218.c
#include <stdlib.h> char *skipzero(char *s, int *value) //if s is empty value is set to 0 { char *p = s; while (*p && *p != '.') ++p; if (*p != '\0') *p++ = '\0'; *value = atoi(s); return p; } int compareVersion(char *version1, char *version2) { int value1, value2, res = 0; while (*version1 || *version2) { version1 = skipzero(version1, &value1); version2 = skipzero(version2, &value2); if (value1 != value2) return value1 < value2 ? -1 : 1; } return res; }
the_stack_data/206392462.c
/*Exercise 2 - Selection Write a program to calculate the amount to be paid for a rented vehicle. • Input the distance the van has travelled • The first 30 km is at a rate of 50/= per km. • The remaining distance is calculated at the rate of 40/= per km. e.g. Distance -> 20 Amount = 20 x 50 = 1000 Distance -> 50 Amount = 30 x 50 + (50-30) x 40 = 2300*/ #include <stdio.h> int main() { int distance, amount; printf("Enter distance travelled:"); scanf("%d", &distance); if(distance<30){ amount= distance* 50; } else{ amount= 30*50 + (distance-30)*40; } printf("Amount is %d", amount); return 0; }
the_stack_data/90624.c
#include<stdio.h> #include<stdlib.h> struct node { int data; struct node *nxt; }; struct node *graph[100]; int front=-1; int rear=-1; int top=-1; int a[100];//stack int b[100];//queue void enqueue(int x) { if(front==-1 && rear==-1) { front=0; rear=0; b[front]=x; } else { rear=rear+1; b[rear]=x; }} int dequeue() { int an; if(front==rear) { an=b[front]; rear=-1; front=-1; return an; } else { an=b[front]; front=front+1; return an; }} void push(int x) { top=top+1; a[top]=x; } int pop() { int q; q=a[top]; top=top-1; return q; } int visit[100]; int visit2[100]; int sd=1; int sd2=1; int search(int item) { int i,flag; flag=0; for(i=1;i<=sd;i++) { if(visit[i]==item) { flag=1; } } return flag; } int search2(int item) { int i,flag; flag=0; for(i=1;i<=sd2;i++) { if(visit2[i]==item) { flag=1; } } return flag; } void insertion(int i) { struct node *temp,*q,*p; int j,d,pt; printf("Enter number of nodes adj to %dth node\n",i ); scanf("%d",&pt); for(j=0;j<pt;j++) { temp=(struct node *)malloc(sizeof(struct node)); printf("Enter data\n"); scanf("%d",&d); temp->data=d; temp->nxt=NULL; if(graph[i]==NULL) { graph[i]=temp; } else { p=graph[i]; while(p->nxt!=NULL) { p=p->nxt; } p->nxt=temp; } } } void bfs(int q) { int n,x,u,c; struct node *ptr; sd2=1; front=-1; rear=-1; if(graph==NULL) { printf("Graph is empty\n"); } else { n=q; enqueue(n); while(front!=-1&& rear!=-1) { n=dequeue(); x=search2(n); if(x==0) { visit2[sd2]=n; printf("%d\t",visit2[sd2]); sd2=sd2+1; ptr=graph[n]; while(ptr!=NULL) { c=ptr->data; enqueue(c); ptr=ptr->nxt; } } } } } void dfs(int q) { top=-1; sd=1; struct node *ptr; int u,x,c,i; if(graph==NULL) { printf("Graph is empty\n"); } else { u=q; push(u); while(top!=-1) { u=pop(); x=search(u); if(x==0) { visit[sd]=u; printf("%d\t",visit[sd]); sd=sd+1; ptr=graph[u]; while(ptr!=NULL) { c=ptr->data; push(c); ptr=ptr->nxt; } } } } } void main() { int h; int n,data,v,i,q; do { printf("Menu\n1.create\n2.traversal bfs\n3.traversal dfs\n4.exit\nEnter your choice\n"); scanf("%d",&n); switch(n) { case 1: printf("Enter the number of vertices\n"); scanf("%d",&v); for(h=1;h<=n;h++) { graph[h]=NULL; } for(i=1;i<=v;i++) { insertion(i); } break; case 2: printf("Enter starting value\n"); scanf("%d",&q); bfs(q); break; case 3: printf("Enter the starting value\n"); scanf("%d",&q); dfs(q); break; case 4: exit(0); }}while(n!=4); }
the_stack_data/100139195.c
/* Given an integer number, write a program that displays the number as follows: First line: all digits Second line: all except first digit Third line: all except first two digits ………… Last line: The last digit For example the number 5678 will be displayed as: 5 6 7 8 6 7 8 7 8 8 */ #include<stdio.h> void main() { int n , num , m , i , d = 1; printf("Enter number of digits:"); scanf("%d",&num); printf("Enter the number:"); scanf("%d",&m); n = num ; while(num != 0) { d = 10 * d ; num--; } for(i = 1 ; i <= n ;i++) { m = m % d; d = d / 10 ; printf("%d\n",m); } }
the_stack_data/18920.c
#ifdef __cplusplus extern "C" { #endif #include <stdarg.h> #if defined(_MSC_VER) #define J99STDCALL_ATTR __stdcall #else #define J99STDCALL_ATTR __attribute__((stdcall)) #endif struct TJsonWrStruct { // For internal usage int _break; // Options int isFlat; // Used internally int level; char lastChar; int bufLength; char buf[260]; // used for custom type prints only // User set variables void* userData; // Functions int (*jsonwr_putc) (int character, void* userData); int (J99STDCALL_ATTR* jsonwr_vsprintf) (char* s, const char* format, va_list arg); }; struct TJsonMemBuffer { int _break; int size; int pos; char* data; // Functions void* (*jsonwr_realloc) (void* ptr, unsigned int size); }; void JSymbFunc(struct TJsonWrStruct* jwr, char c); void JNewLineFunc(struct TJsonWrStruct* jwr); void JAddCommaFunc(struct TJsonWrStruct* jwr); void JPrintStrFunc(struct TJsonWrStruct* jwr, const char* str, int maxLength); void JCustomFunc(struct TJsonWrStruct* jwr, const char * format, ...); int stat_mem_putc(int character, void* userData); int dyn_mem_putc(int character, void* userData); // Each JSON should start from this. Defines `_JWrInternal` object for this scope of view for usage inside of all other macroses #define JStart(isFlatParam, putcFunc, vsprintfFunc) \ for (struct TJsonWrStruct _JWrInternal = { \ ._break = 1, \ .isFlat = isFlatParam, \ .level = 0, \ .lastChar = 0, \ .bufLength = 0, \ .buf = {0}, \ .userData = 0, \ .jsonwr_putc = putcFunc, \ .jsonwr_vsprintf = vsprintfFunc }; \ _JWrInternal._break; \ JSymb(0),_JWrInternal._break = 0) #define JStartObj(...) JStart(__VA_ARGS__)JObjBlock #define JStartArr(...) JStart(__VA_ARGS__)JArrBlock #define JNewLine JNewLineFunc(&_JWrInternal) #define JSymb(c) JSymbFunc(&_JWrInternal, c) #define JAddComma JAddCommaFunc(&_JWrInternal) #define JBlockInternal(startSymb, endSymb) \ for (int _break = (JAddComma,JSymb(startSymb), 1); _break; \ _break = 0, JSymb(endSymb)) #define JObjBlock JBlockInternal('{','}') #define JArrBlock JBlockInternal('[',']') #define JInt(x) JAddComma;JCustomFunc(&_JWrInternal, "%d", x);_JWrInternal.lastChar=1 #define JStr(str) JAddComma;JSymb('"');JPrintStrFunc(&_JWrInternal, str, 2147483647);JSymb('"') #define JCustom(...) JAddComma;JSymb('"');JCustomFunc(&_JWrInternal, __VA_ARGS__);JSymb('"') #define JParamStart(name) JAddComma;JNewLine;JStr(name);JSymb(':'); #define JObj(name) JParamStart(name);JObjBlock #define JArr(name) JParamStart(name);JArrBlock #define JParam(name, value) JParamStart(name);JStr(value) #define JIntParam(name, value) JParamStart(name);JInt(value) #define JCustomParam(name, ...) JParamStart(name);JCustom(__VA_ARGS__) #define JPrepareStruct(PointerToStructure) struct TJsonWrStruct _JWrInternal = *PointerToStructure #define JStaticMemOpen(JsonBuffer, MaxSize) \ for (struct TJsonMemBuffer _JMemBufInternal = { ._break = 1, .size = MaxSize, .pos = 0, .data = JsonBuffer, .jsonwr_realloc = 0}; \ _JMemBufInternal._break; \ _JMemBufInternal._break=0) \ for (int _break = ((_JWrInternal.userData = &_JMemBufInternal), 1); _break; _break = 0) #if defined(JWRITER99_EXAMPLE) && !defined(JWRITER99_IMPLEMENTATION) #define JWRITER99_IMPLEMENTATION #endif #ifdef JWRITER99_IMPLEMENTATION void JNewLineFunc(struct TJsonWrStruct* jwr) { const int JsonWr_Indent_Spaces = 2; if ((jwr->isFlat == 0) && (jwr->lastChar != '\n')) { JSymbFunc(jwr, '\n'); for(int i=0; i< JsonWr_Indent_Spaces*(jwr->level); i++) JSymbFunc(jwr, ' '); } } void JSymbFunc(struct TJsonWrStruct* jwr, char c) { if ((c == '}') || (c == ']')) { jwr->level--; JNewLineFunc(jwr); } if ((c == '{') || (c == '[')) { if (jwr->lastChar != 0) JNewLineFunc(jwr); jwr->level++; } jwr->jsonwr_putc(c, jwr->userData); if ((c != ' ') && (c != '\t')) { jwr->lastChar = c; } if ((c == '{') || (c == '[')) { if (jwr->lastChar != 0) JNewLineFunc(jwr); } if ((c == ':') && (jwr->isFlat == 0) ) { JSymbFunc(jwr, ' '); } } void JAddCommaFunc(struct TJsonWrStruct* jwr) { char c = jwr->lastChar; if (0 == c) return; if ('[' == c) return; if ('{' == c) return; if (':' == c) return; if (',' == c) return; if ('\n' == c) return; JSymbFunc(jwr, ','); if (jwr->isFlat == 0) JSymbFunc(jwr, ' '); } void JPrintStrFunc(struct TJsonWrStruct* jwr, const char* str, int maxLength) { #define JSlashedSymbInternal(c) JSymbFunc(jwr, '\\');JSymbFunc(jwr, c) for (int i=0; (str[i] != 0) && (i < maxLength); i++) { switch (str[i]) { case '\\': JSlashedSymbInternal('\\'); break; case '"' : JSlashedSymbInternal('"'); break; case '\n': JSlashedSymbInternal('n'); break; case '\r': JSlashedSymbInternal('r'); break; case '\t': JSlashedSymbInternal('t'); break; case '\b': JSlashedSymbInternal('b'); break; case '\f': JSlashedSymbInternal('f'); break; default: jwr->jsonwr_putc(str[i], jwr->userData); break; } } } void JCustomFunc(struct TJsonWrStruct* jwr, const char * format, ...) { va_list args; va_start (args, format); jwr->bufLength = jwr->jsonwr_vsprintf(jwr->buf, format, args); va_end (args); jwr->buf[ jwr->bufLength ] = 0; JPrintStrFunc(jwr, jwr->buf, jwr->bufLength); } int stat_mem_putc(int character, void* userData) { struct TJsonMemBuffer* jbuf = (struct TJsonMemBuffer*)userData; if (jbuf->pos < jbuf->size) { jbuf->data[ jbuf->pos++ ] = (char)character; jbuf->data[ jbuf->pos ] = 0; return character; } else return -1; } int dyn_mem_putc(int character, void* userData) { struct TJsonMemBuffer* jbuf = (struct TJsonMemBuffer*)userData; char* data = jbuf->data; if ((0 == data) || ((jbuf->pos+1) >= jbuf->size)) { // Allocation of bigger memory required char* newbuf = 0; jbuf->size *= 2; // Grow 2 times per step if (0 == jbuf->size) jbuf->size = 1024; // Initial size newbuf = (char*) jbuf->jsonwr_realloc(data, jbuf->size); if (0 != newbuf) { data = newbuf; jbuf->data = newbuf; } // TODO: reallocation error handling } data[ jbuf->pos++ ] = (char)character; data[ jbuf->pos ] = 0; return character; } #endif // JWRITER99_IMPLEMENTATION // Backends: stdlib and WinAPI #ifndef JWRITER99_NO_STDLIB // STDLIB backend #include <stdio.h> #include <stdlib.h> #define JPuts puts #define JFree free #define STDLIB_VSPRINTF (int (J99STDCALL_ATTR*)(char *, const char *, va_list))vsprintf int console_jputc(int character, void* userData); int file_jputc(int character, void* userData); int file_jclose(void* userData); #define JMemOpen(JsonBuffer) \ for (struct TJsonMemBuffer _JMemBufInternal = { ._break = 1, .pos = 0, .size = 0, .data = NULL, .jsonwr_realloc = realloc}; \ _JMemBufInternal._break; \ _JMemBufInternal._break=0, JsonBuffer=_JMemBufInternal.data) \ for (int _break = ((_JWrInternal.userData = &_JMemBufInternal), 1); _break; _break = 0) #define JFileOpen(fileName) \ for (int _break = ((_JWrInternal.userData = fopen(fileName, "w+")), 1); _break; \ _break = 0,file_jclose(_JWrInternal.userData)) \ if (NULL != _JWrInternal.userData) #define JStartConsole JStart(0, console_jputc, STDLIB_VSPRINTF) #define JStartStaticMemEx(JsonBuffer, MaxSize, isFlat) JStart(isFlat, stat_mem_putc, STDLIB_VSPRINTF)JStaticMemOpen(JsonBuffer, MaxSize) #define JStartMemEx(JsonBuffer, isFlat) JStart(isFlat, dyn_mem_putc, STDLIB_VSPRINTF)JMemOpen(JsonBuffer) #define JStartFileEx(fileName, isFlat) JStart(isFlat, file_jputc, STDLIB_VSPRINTF)JFileOpen(fileName) #ifdef JWRITER99_IMPLEMENTATION int console_jputc(int character, void* userData) { (void)userData; return putchar(character); } int file_jputc(int character, void* userData) { return fputc(character, (FILE *)userData); } int file_jclose(void* userData) { if (NULL != userData) { fclose((FILE *)userData); return 0; } return 1; } #endif // JWRITER99_IMPLEMENTATION #endif // JWRITER99_NO_STDLIB #if !defined(JFree) && defined(_WIN32) // WinAPI backend #include <windows.h> #define JFree GlobalFree #define JPuts(str) WJPutsEx(str, 1) int WJPutsEx(const char* str, int appendNewLine); void* winapi_jrealloc(void* ptr, unsigned int size); int winapi_jfile_puts(const char* filename, const char* buf); #define JStartConsole \ for (char _break = 1, *_WinAPIBufInternal = 0; _break; \ _break = 0, JPuts(_WinAPIBufInternal), JFree(_WinAPIBufInternal) ) \ JStartMem(_WinAPIBufInternal) #define JMemOpen(JsonBuffer) \ for (struct TJsonMemBuffer _JMemBufInternal = { ._break = 1, .size = 0, .pos = 0, .data = NULL, .jsonwr_realloc = winapi_jrealloc}; \ _JMemBufInternal._break; \ _JMemBufInternal._break=0, JsonBuffer=_JMemBufInternal.data) \ for (int _break = ((_JWrInternal.userData = &_JMemBufInternal), 1); _break; _break = 0) #define JStartFileEx(fileName, isFlat) \ for (char _break = 1, *_WinAPIBufInternal = 0; _break; \ _break = 0, winapi_jfile_puts(fileName, _WinAPIBufInternal), JFree(_WinAPIBufInternal) ) \ JStartMemEx(_WinAPIBufInternal, isFlat) #define JStartStaticMemEx(JsonBuffer, MaxSize, isFlat) JStart(isFlat, stat_mem_putc, wvsprintf)JStaticMemOpen(JsonBuffer, MaxSize) #define JStartMemEx(JsonBuffer, isFlat) JStart(isFlat, dyn_mem_putc, wvsprintf)JMemOpen(JsonBuffer) #ifdef JWRITER99_IMPLEMENTATION int WJPutsEx(const char* str, int appendNewLine) { DWORD written = 0, writtenLn = 0, len = 0; while (str[len] != 0) len++; // get rid of reference to lstrlen() WriteConsoleA(GetStdHandle(STD_OUTPUT_HANDLE), str, len, &written, NULL); if (appendNewLine) { WriteConsoleA(GetStdHandle(STD_OUTPUT_HANDLE), "\n", 1, &writtenLn, NULL); } return (int)(written + writtenLn); } void* winapi_jrealloc(void* ptr, unsigned int size) { if (0 == ptr) return GlobalAlloc(GMEM_MOVEABLE, (SIZE_T)size); else return GlobalReAlloc((HGLOBAL)ptr, (SIZE_T)size, GMEM_MOVEABLE); } int winapi_jfile_puts(const char* filename, const char* buf) { unsigned long bufsize = 0; while (buf[bufsize] != 0) bufsize++; HANDLE out = CreateFile(filename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (out != INVALID_HANDLE_VALUE) { DWORD written = 0; WriteFile(out, buf, bufsize, &written, NULL); CloseHandle(out); if (written < bufsize) return bufsize - written; } return 0; } #endif // JWRITER99_IMPLEMENTATION #endif // WINAPI backend /// Helper macroses for end-user usage // Console #define JStartConsoleObj JStartConsole JObjBlock #define JStartConsoleArr JStartConsole JArrBlock // Static memory macroses #define JStartStaticMemObjEx(JsonBuffer, MaxSize, isFlat) JStartStaticMemEx(JsonBuffer, MaxSize, isFlat)JObjBlock #define JStartStaticMemArrEx(JsonBuffer, MaxSize, isFlat) JStartStaticMemEx(JsonBuffer, MaxSize, isFlat)JArrBlock #define JStartStaticMem(JsonBuffer, MaxSize) JStartStaticMemEx(JsonBuffer, MaxSize, 0) #define JStartStaticMemObj(JsonBuffer, MaxSize) JStartStaticMem(JsonBuffer, MaxSize)JObjBlock #define JStartStaticMemArr(JsonBuffer, MaxSize) JStartStaticMem(JsonBuffer, MaxSize)JArrBlock #define JStartStaticMemCompact(JsonBuffer, MaxSize) JStartStaticMemEx(JsonBuffer, MaxSize, 1) #define JStartStaticMemObjCompact(JsonBuffer, MaxSize) JStartStaticMemCompact(JsonBuffer, MaxSize)JObjBlock #define JStartStaticMemArrCompact(JsonBuffer, MaxSize) JStartStaticMemCompact(JsonBuffer, MaxSize)JArrBlock //Dynamic memory macroses #define JStartMemObjEx(JsonBuffer, isFlat) JStartMemEx(JsonBuffer, isFlat)JObjBlock #define JStartMemArrEx(JsonBuffer, isFlat) JStartMemEx(JsonBuffer, isFlat)JArrBlock #define JStartMem(JsonBuffer) JStartMemEx(JsonBuffer, 0) #define JStartMemObj(JsonBuffer) JStartMem(JsonBuffer)JObjBlock #define JStartMemArr(JsonBuffer) JStartMem(JsonBuffer)JArrBlock #define JStartMemCompact(JsonBuffer) JStartMemEx(JsonBuffer, 1) #define JStartMemObjCompact(JsonBuffer) JStartMemCompact(JsonBuffer)JObjBlock #define JStartMemArrCompact(JsonBuffer) JStartMemCompact(JsonBuffer)JArrBlock // File-based macro defines #define JStartFileObjEx(fileName, isFlat) JStartFileEx(fileName, isFlat)JObjBlock #define JStartFileArrEx(fileName, isFlat) JStartFileEx(fileName, isFlat)JArrBlock #define JStartFile(fileName) JStartFileEx(fileName, 0) #define JStartFileObj(fileName) JStartFile(fileName)JObjBlock #define JStartFileArr(fileName) JStartFile(fileName)JArrBlock #define JStartFileCompact(fileName) JStartFileEx(fileName, 1) #define JStartFileObjCompact(fileName) JStartFileCompact(fileName)JObjBlock #define JStartFileArrCompact(fileName) JStartFileCompact(fileName)JArrBlock // Example start #ifdef JWRITER99_EXAMPLE // http://stackoverflow.com/questions/1167253/implementation-of-rand unsigned int myrand(void) { static unsigned int m_w = 12345; static unsigned int m_z = 54321; m_z = 36969 * (m_z & 65535) + (m_z >> 16); m_w = 18000 * (m_w & 65535) + (m_w >> 16); return (m_z << 16) + m_w; } void json_example(void) { char* mybuf = NULL; // Used for dynamic memory only char staticMemory[1024] = {0}; int staticMemorySize = sizeof(staticMemory) / sizeof(staticMemory[0]); (void)staticMemorySize; JPuts("-= Start example =-"); //JStartStaticMemObj(staticMemory, staticMemorySize) { //JStartMemObj(mybuf) { //JStartFileObj("file.json") { JStartConsoleObj { JParam("Title", "My \"JSON\n demo"); JCustomParam("Date", "%d.%02d.%d", 31, 2, 2019); JParam("Cool string", "={^_^}=\n\r\t\b\f \" /(\\_/)\\"); JObj("Window") { JParam("state", "maximized"); JIntParam("left", 120); JIntParam("top", 70); JArr("IntegerArray") { int n = 3 + myrand() % 10; for (int i = 0; i < n; i++) { int value = myrand() % 100; JInt(value); } JStr("Ha ha! Not int"); JInt(n); } JArr("ObjectsArray") { int n = 1 + myrand() % 3; for (int i = 0; i < n; i++) { JObjBlock { JIntParam("ID", myrand() % 10000); JParam("visible", myrand()%2 ? "true": "false"); } } } JParam("author", "DeXPeriX"); }; }; if (NULL != mybuf) { JPuts(mybuf); JFree(mybuf); } if (0 != staticMemory[0]) { JPuts(staticMemory); } } #ifndef JWRITER99_NO_STDLIB int main(void) { json_example(); return 0; } #else int dx_start() { json_example(); ExitProcess(0); return 0; } #if !defined(_MSC_VER) __asm__( ".globl __main\n" "__main:\n" #if defined(WIN64) || defined(__amd64__) "call dx_start\n" #else "call _dx_start\n" #endif "movl $1, %eax\n" "xorl %ebx, %ebx\n" "int $0x80" ); #endif // _MSC_VER #endif // JWRITER99_NO_STDLIB #endif // JWRITER99_EXAMPLE #ifdef __cplusplus } #endif
the_stack_data/36075852.c
#include <stdio.h> #define MSG1 "Sao Multiplos" #define MSG2 "Nao sao Multiplos" int main(void) {int a, b; scanf("%d %d", &a, &b); if(b % a == 0) {puts(MSG1);} else {puts(MSG2);} return 0; }
the_stack_data/696716.c
/* { dg-do run { target openacc_nvidia_accel_selected } } */ /* { dg-additional-options "-lcuda" } */ #include <openacc.h> #include <stdlib.h> #include "cuda.h" #include <stdio.h> #include <sys/time.h> int main (int argc, char **argv) { CUresult r; CUstream stream1; int N = 128; //1024 * 1024; float *a, *b, *c, *d, *e; int i; int nbytes; acc_init (acc_device_nvidia); nbytes = N * sizeof (float); a = (float *) malloc (nbytes); b = (float *) malloc (nbytes); c = (float *) malloc (nbytes); d = (float *) malloc (nbytes); e = (float *) malloc (nbytes); for (i = 0; i < N; i++) { a[i] = 3.0; b[i] = 0.0; } #pragma acc data copy (a[0:N]) copy (b[0:N]) copyin (N) { #pragma acc parallel async { int ii; for (ii = 0; ii < N; ii++) b[ii] = a[ii]; } #pragma acc wait } for (i = 0; i < N; i++) { if (a[i] != 3.0) abort (); if (b[i] != 3.0) abort (); } for (i = 0; i < N; i++) { a[i] = 2.0; b[i] = 0.0; } #pragma acc data copy (a[0:N]) copy (b[0:N]) copyin (N) { #pragma acc parallel async (1) { int ii; for (ii = 0; ii < N; ii++) b[ii] = a[ii]; } #pragma acc wait (1) } for (i = 0; i < N; i++) { if (a[i] != 2.0) abort (); if (b[i] != 2.0) abort (); } for (i = 0; i < N; i++) { a[i] = 3.0; b[i] = 0.0; c[i] = 0.0; d[i] = 0.0; } #pragma acc data copy (a[0:N]) copy (b[0:N]) copy (c[0:N]) copy (d[0:N]) copyin (N) { #pragma acc parallel async (1) { int ii; for (ii = 0; ii < N; ii++) b[ii] = (a[ii] * a[ii] * a[ii]) / a[ii]; } #pragma acc parallel async (1) { int ii; for (ii = 0; ii < N; ii++) c[ii] = (a[ii] + a[ii] + a[ii] + a[ii]) / a[ii]; } #pragma acc parallel async (1) { int ii; for (ii = 0; ii < N; ii++) d[ii] = ((a[ii] * a[ii] + a[ii]) / a[ii]) - a[ii]; } #pragma acc wait (1) } for (i = 0; i < N; i++) { if (a[i] != 3.0) abort (); if (b[i] != 9.0) abort (); if (c[i] != 4.0) abort (); if (d[i] != 1.0) abort (); } for (i = 0; i < N; i++) { a[i] = 2.0; b[i] = 0.0; c[i] = 0.0; d[i] = 0.0; e[i] = 0.0; } #pragma acc data copy (a[0:N], b[0:N], c[0:N], d[0:N], e[0:N]) copyin (N) { #pragma acc parallel async (1) { int ii; for (ii = 0; ii < N; ii++) b[ii] = (a[ii] * a[ii] * a[ii]) / a[ii]; } #pragma acc parallel async (1) { int ii; for (ii = 0; ii < N; ii++) c[ii] = (a[ii] + a[ii] + a[ii] + a[ii]) / a[ii]; } #pragma acc parallel async (1) { int ii; for (ii = 0; ii < N; ii++) d[ii] = ((a[ii] * a[ii] + a[ii]) / a[ii]) - a[ii]; } #pragma acc parallel wait (1) async (1) { int ii; for (ii = 0; ii < N; ii++) e[ii] = a[ii] + b[ii] + c[ii] + d[ii]; } #pragma acc wait (1) } for (i = 0; i < N; i++) { if (a[i] != 2.0) abort (); if (b[i] != 4.0) abort (); if (c[i] != 4.0) abort (); if (d[i] != 1.0) abort (); if (e[i] != 11.0) abort (); } r = cuStreamCreate (&stream1, CU_STREAM_NON_BLOCKING); if (r != CUDA_SUCCESS) { fprintf (stderr, "cuStreamCreate failed: %d\n", r); abort (); } acc_set_cuda_stream (1, stream1); for (i = 0; i < N; i++) { a[i] = 5.0; b[i] = 0.0; } #pragma acc data copy (a[0:N], b[0:N]) copyin (N) { #pragma acc parallel async (1) { int ii; for (ii = 0; ii < N; ii++) b[ii] = a[ii]; } #pragma acc wait (1) } for (i = 0; i < N; i++) { if (a[i] != 5.0) abort (); if (b[i] != 5.0) abort (); } for (i = 0; i < N; i++) { a[i] = 7.0; b[i] = 0.0; c[i] = 0.0; d[i] = 0.0; } #pragma acc data copy (a[0:N]) copy (b[0:N]) copy (c[0:N]) copy (d[0:N]) copyin (N) { #pragma acc parallel async (1) { int ii; for (ii = 0; ii < N; ii++) b[ii] = (a[ii] * a[ii] * a[ii]) / a[ii]; } #pragma acc parallel async (1) { int ii; for (ii = 0; ii < N; ii++) c[ii] = (a[ii] + a[ii] + a[ii] + a[ii]) / a[ii]; } #pragma acc parallel async (1) { int ii; for (ii = 0; ii < N; ii++) d[ii] = ((a[ii] * a[ii] + a[ii]) / a[ii]) - a[ii]; } #pragma acc wait (1) } for (i = 0; i < N; i++) { if (a[i] != 7.0) abort (); if (b[i] != 49.0) abort (); if (c[i] != 4.0) abort (); if (d[i] != 1.0) abort (); } for (i = 0; i < N; i++) { a[i] = 3.0; b[i] = 0.0; c[i] = 0.0; d[i] = 0.0; e[i] = 0.0; } #pragma acc data copy (a[0:N], b[0:N], c[0:N], d[0:N], e[0:N]) copyin (N) { #pragma acc parallel async (1) { int ii; for (ii = 0; ii < N; ii++) b[ii] = (a[ii] * a[ii] * a[ii]) / a[ii]; } #pragma acc parallel async (1) { int ii; for (ii = 0; ii < N; ii++) c[ii] = (a[ii] + a[ii] + a[ii] + a[ii]) / a[ii]; } #pragma acc parallel async (1) { int ii; for (ii = 0; ii < N; ii++) d[ii] = ((a[ii] * a[ii] + a[ii]) / a[ii]) - a[ii]; } #pragma acc parallel wait (1) async (1) { int ii; for (ii = 0; ii < N; ii++) e[ii] = a[ii] + b[ii] + c[ii] + d[ii]; } #pragma acc wait (1) } for (i = 0; i < N; i++) { if (a[i] != 3.0) abort (); if (b[i] != 9.0) abort (); if (c[i] != 4.0) abort (); if (d[i] != 1.0) abort (); if (e[i] != 17.0) abort (); } for (i = 0; i < N; i++) { a[i] = 4.0; b[i] = 0.0; c[i] = 0.0; d[i] = 0.0; e[i] = 0.0; } #pragma acc data copyin (a[0:N], b[0:N], c[0:N]) copyin (N) { #pragma acc parallel async (1) { int ii; for (ii = 0; ii < N; ii++) b[ii] = (a[ii] * a[ii] * a[ii]) / a[ii]; } #pragma acc parallel async (1) { int ii; for (ii = 0; ii < N; ii++) c[ii] = (a[ii] + a[ii] + a[ii] + a[ii]) / a[ii]; } #pragma acc update host (a[0:N], b[0:N], c[0:N]) wait (1) } for (i = 0; i < N; i++) { if (a[i] != 4.0) abort (); if (b[i] != 16.0) abort (); if (c[i] != 4.0) abort (); } for (i = 0; i < N; i++) { a[i] = 5.0; b[i] = 0.0; c[i] = 0.0; d[i] = 0.0; e[i] = 0.0; } #pragma acc data copyin (a[0:N], b[0:N], c[0:N]) copyin (N) { #pragma acc parallel async (1) { int ii; for (ii = 0; ii < N; ii++) b[ii] = (a[ii] * a[ii] * a[ii]) / a[ii]; } #pragma acc parallel async (1) { int ii; for (ii = 0; ii < N; ii++) c[ii] = (a[ii] + a[ii] + a[ii] + a[ii]) / a[ii]; } #pragma acc update host (a[0:N], b[0:N], c[0:N]) async (1) #pragma acc wait (1) } for (i = 0; i < N; i++) { if (a[i] != 5.0) abort (); if (b[i] != 25.0) abort (); if (c[i] != 4.0) abort (); } for (i = 0; i < N; i++) { a[i] = 3.0; b[i] = 0.0; } #pragma acc data copy (a[0:N]) copy (b[0:N]) copyin (N) { #pragma acc kernels async { int ii; for (ii = 0; ii < N; ii++) b[ii] = a[ii]; } #pragma acc wait } for (i = 0; i < N; i++) { if (a[i] != 3.0) abort (); if (b[i] != 3.0) abort (); } for (i = 0; i < N; i++) { a[i] = 2.0; b[i] = 0.0; } #pragma acc data copy (a[0:N]) copy (b[0:N]) copyin (N) { #pragma acc kernels async (1) { int ii; for (ii = 0; ii < N; ii++) b[ii] = a[ii]; } #pragma acc wait (1) } for (i = 0; i < N; i++) { if (a[i] != 2.0) abort (); if (b[i] != 2.0) abort (); } for (i = 0; i < N; i++) { a[i] = 3.0; b[i] = 0.0; c[i] = 0.0; d[i] = 0.0; } #pragma acc data copy (a[0:N]) copy (b[0:N]) copy (c[0:N]) copy (d[0:N]) copyin (N) { #pragma acc kernels async (1) { int ii; for (ii = 0; ii < N; ii++) b[ii] = (a[ii] * a[ii] * a[ii]) / a[ii]; } #pragma acc kernels async (1) { int ii; for (ii = 0; ii < N; ii++) c[ii] = (a[ii] + a[ii] + a[ii] + a[ii]) / a[ii]; } #pragma acc kernels async (1) { int ii; for (ii = 0; ii < N; ii++) d[ii] = ((a[ii] * a[ii] + a[ii]) / a[ii]) - a[ii]; } #pragma acc wait (1) } for (i = 0; i < N; i++) { if (a[i] != 3.0) abort (); if (b[i] != 9.0) abort (); if (c[i] != 4.0) abort (); if (d[i] != 1.0) abort (); } for (i = 0; i < N; i++) { a[i] = 2.0; b[i] = 0.0; c[i] = 0.0; d[i] = 0.0; e[i] = 0.0; } #pragma acc data copy (a[0:N], b[0:N], c[0:N], d[0:N], e[0:N]) copyin (N) { #pragma acc kernels async (1) { int ii; for (ii = 0; ii < N; ii++) b[ii] = (a[ii] * a[ii] * a[ii]) / a[ii]; } #pragma acc kernels async (1) { int ii; for (ii = 0; ii < N; ii++) c[ii] = (a[ii] + a[ii] + a[ii] + a[ii]) / a[ii]; } #pragma acc kernels async (1) { int ii; for (ii = 0; ii < N; ii++) d[ii] = ((a[ii] * a[ii] + a[ii]) / a[ii]) - a[ii]; } #pragma acc kernels wait (1) async (1) { int ii; for (ii = 0; ii < N; ii++) e[ii] = a[ii] + b[ii] + c[ii] + d[ii]; } #pragma acc wait (1) } for (i = 0; i < N; i++) { if (a[i] != 2.0) abort (); if (b[i] != 4.0) abort (); if (c[i] != 4.0) abort (); if (d[i] != 1.0) abort (); if (e[i] != 11.0) abort (); } r = cuStreamCreate (&stream1, CU_STREAM_NON_BLOCKING); if (r != CUDA_SUCCESS) { fprintf (stderr, "cuStreamCreate failed: %d\n", r); abort (); } acc_set_cuda_stream (1, stream1); for (i = 0; i < N; i++) { a[i] = 5.0; b[i] = 0.0; } #pragma acc data copy (a[0:N], b[0:N]) copyin (N) { #pragma acc kernels async (1) { int ii; for (ii = 0; ii < N; ii++) b[ii] = a[ii]; } #pragma acc wait (1) } for (i = 0; i < N; i++) { if (a[i] != 5.0) abort (); if (b[i] != 5.0) abort (); } for (i = 0; i < N; i++) { a[i] = 7.0; b[i] = 0.0; c[i] = 0.0; d[i] = 0.0; } #pragma acc data copy (a[0:N]) copy (b[0:N]) copy (c[0:N]) copy (d[0:N]) copyin (N) { #pragma acc kernels async (1) { int ii; for (ii = 0; ii < N; ii++) b[ii] = (a[ii] * a[ii] * a[ii]) / a[ii]; } #pragma acc kernels async (1) { int ii; for (ii = 0; ii < N; ii++) c[ii] = (a[ii] + a[ii] + a[ii] + a[ii]) / a[ii]; } #pragma acc kernels async (1) { int ii; for (ii = 0; ii < N; ii++) d[ii] = ((a[ii] * a[ii] + a[ii]) / a[ii]) - a[ii]; } #pragma acc wait (1) } for (i = 0; i < N; i++) { if (a[i] != 7.0) abort (); if (b[i] != 49.0) abort (); if (c[i] != 4.0) abort (); if (d[i] != 1.0) abort (); } for (i = 0; i < N; i++) { a[i] = 3.0; b[i] = 0.0; c[i] = 0.0; d[i] = 0.0; e[i] = 0.0; } #pragma acc data copy (a[0:N], b[0:N], c[0:N], d[0:N], e[0:N]) copyin (N) { #pragma acc kernels async (1) { int ii; for (ii = 0; ii < N; ii++) b[ii] = (a[ii] * a[ii] * a[ii]) / a[ii]; } #pragma acc kernels async (1) { int ii; for (ii = 0; ii < N; ii++) c[ii] = (a[ii] + a[ii] + a[ii] + a[ii]) / a[ii]; } #pragma acc kernels async (1) { int ii; for (ii = 0; ii < N; ii++) d[ii] = ((a[ii] * a[ii] + a[ii]) / a[ii]) - a[ii]; } #pragma acc kernels wait (1) async (1) { int ii; for (ii = 0; ii < N; ii++) e[ii] = a[ii] + b[ii] + c[ii] + d[ii]; } #pragma acc wait (1) } for (i = 0; i < N; i++) { if (a[i] != 3.0) abort (); if (b[i] != 9.0) abort (); if (c[i] != 4.0) abort (); if (d[i] != 1.0) abort (); if (e[i] != 17.0) abort (); } for (i = 0; i < N; i++) { a[i] = 4.0; b[i] = 0.0; c[i] = 0.0; d[i] = 0.0; e[i] = 0.0; } #pragma acc data copyin (a[0:N], b[0:N], c[0:N]) copyin (N) { #pragma acc kernels async (1) { int ii; for (ii = 0; ii < N; ii++) b[ii] = (a[ii] * a[ii] * a[ii]) / a[ii]; } #pragma acc kernels async (1) { int ii; for (ii = 0; ii < N; ii++) c[ii] = (a[ii] + a[ii] + a[ii] + a[ii]) / a[ii]; } #pragma acc update host (a[0:N], b[0:N], c[0:N]) wait (1) } for (i = 0; i < N; i++) { if (a[i] != 4.0) abort (); if (b[i] != 16.0) abort (); if (c[i] != 4.0) abort (); } for (i = 0; i < N; i++) { a[i] = 5.0; b[i] = 0.0; c[i] = 0.0; d[i] = 0.0; e[i] = 0.0; } #pragma acc data copyin (a[0:N], b[0:N], c[0:N]) copyin (N) { #pragma acc kernels async (1) { int ii; for (ii = 0; ii < N; ii++) b[ii] = (a[ii] * a[ii] * a[ii]) / a[ii]; } #pragma acc kernels async (1) { int ii; for (ii = 0; ii < N; ii++) c[ii] = (a[ii] + a[ii] + a[ii] + a[ii]) / a[ii]; } #pragma acc update host (a[0:N], b[0:N], c[0:N]) async (1) #pragma acc wait (1) } for (i = 0; i < N; i++) { if (a[i] != 5.0) abort (); if (b[i] != 25.0) abort (); if (c[i] != 4.0) abort (); } acc_shutdown (acc_device_nvidia); return 0; }
the_stack_data/214.c
#include <stdio.h> #include <stdlib.h> struct node { int value; struct node *next; }; void print_list(struct node *list) { struct node *p = NULL; printf("list: "); p = list; while(p) { printf("%d ", p->value); p = p->next; } printf("\n"); } struct node *insert_into_ordered_list(struct node *list, struct node *new_node) { struct node *cur = list, *prev = NULL; // empty list if(cur == NULL) { return new_node; } // find where to put while(cur != NULL && cur->value <= new_node->value) { prev = cur; cur = cur->next; } // first if(prev == NULL) { list = new_node; new_node->next = cur; } // middle or last else { prev->next = new_node; new_node->next = cur; } return list; } int main(void) { struct node *first = NULL, *p = NULL, *new = NULL; // empty, first, middle, last int a[4] = { 3, 1, 2, 4 }; for(int x = 0; x < 4; x++) { new = malloc(sizeof(struct node)); if(new == NULL) { printf("Error: malloc failed to create new\n"); exit(EXIT_FAILURE); } new->value = a[x]; first = insert_into_ordered_list(first, new); print_list(first); } while(first) { p = first; first = first->next; free(p); } return 0; }
the_stack_data/70362.c
/* * 水仙花数 * ABC = A^3 + B^3 + C^3 * */ #include <stdio.h> #include <math.h> int main() { int i = 100; for (i=100; i<1000; i++) { int A = i/100 %10; int B = i/10 %10; int C = i%10; if (i == pow(A,3)+pow(B,3)+pow(C,3)) printf ("%d\n",i); } return 0; }
the_stack_data/162639195.c
#include <stdio.h> #include <stdlib.h> int main(int argc, char const *argv[]) { char cardName[3]; puts("Enter the name of the card: "); gets(cardName); // Value of the card int val; if (cardName[0] == 'K' || cardName[0] == 'Q' || cardName[0] == 'J') val = 10; else if (cardName[0] == 'A') val = 11; else val = atoi(cardName); // Card Count if (val >= 3 && val <= 6) puts("The card count has gone up\n"); else puts("The card count has gone down\n"); return 0; }
the_stack_data/57424.c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* main.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: gasantos <[email protected]> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/02/10 20:04:48 by gasantos #+# #+# */ /* Updated: 2022/02/12 00:31:34 by gasantos ### ########.fr */ /* */ /* ************************************************************************** */ #include <stdio.h> void ft_swap(int *a, int *b); int main(void) { int a; int b; a = 10; b = 5; ft_swap(&a, &b); printf("a %d, b %d", a, b); }
the_stack_data/76701286.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(void *)) 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/790775.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; /* > \brief \b CGETSQRHRT */ /* =========== DOCUMENTATION =========== */ /* Online html documentation available at */ /* http://www.netlib.org/lapack/explore-html/ */ /* > \htmlonly */ /* > Download CGETSQRHRT + dependencies */ /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgetsqr hrt.f"> */ /* > [TGZ]</a> */ /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgetsqr hrt.f"> */ /* > [ZIP]</a> */ /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgetsqr hrt.f"> */ /* > [TXT]</a> */ /* > \endhtmlonly */ /* Definition: */ /* =========== */ /* SUBROUTINE CGETSQRHRT( M, N, MB1, NB1, NB2, A, LDA, T, LDT, WORK, */ /* $ LWORK, INFO ) */ /* IMPLICIT NONE */ /* INTEGER INFO, LDA, LDT, LWORK, M, N, NB1, NB2, MB1 */ /* COMPLEX*16 A( LDA, * ), T( LDT, * ), WORK( * ) */ /* > \par Purpose: */ /* ============= */ /* > */ /* > \verbatim */ /* > */ /* > CGETSQRHRT computes a NB2-sized column blocked QR-factorization */ /* > of a complex M-by-N matrix A with M >= N, */ /* > */ /* > A = Q * R. */ /* > */ /* > The routine uses internally a NB1-sized column blocked and MB1-sized */ /* > row blocked TSQR-factorization and perfors the reconstruction */ /* > of the Householder vectors from the TSQR output. The routine also */ /* > converts the R_tsqr factor from the TSQR-factorization output into */ /* > the R factor that corresponds to the Householder QR-factorization, */ /* > */ /* > A = Q_tsqr * R_tsqr = Q * R. */ /* > */ /* > The output Q and R factors are stored in the same format as in CGEQRT */ /* > (Q is in blocked compact WY-representation). See the documentation */ /* > of CGEQRT for more details on the format. */ /* > \endverbatim */ /* Arguments: */ /* ========== */ /* > \param[in] M */ /* > \verbatim */ /* > M is INTEGER */ /* > The number of rows of the matrix A. M >= 0. */ /* > \endverbatim */ /* > */ /* > \param[in] N */ /* > \verbatim */ /* > N is INTEGER */ /* > The number of columns of the matrix A. M >= N >= 0. */ /* > \endverbatim */ /* > */ /* > \param[in] MB1 */ /* > \verbatim */ /* > MB1 is INTEGER */ /* > The row block size to be used in the blocked TSQR. */ /* > MB1 > N. */ /* > \endverbatim */ /* > */ /* > \param[in] NB1 */ /* > \verbatim */ /* > NB1 is INTEGER */ /* > The column block size to be used in the blocked TSQR. */ /* > N >= NB1 >= 1. */ /* > \endverbatim */ /* > */ /* > \param[in] NB2 */ /* > \verbatim */ /* > NB2 is INTEGER */ /* > The block size to be used in the blocked QR that is */ /* > output. NB2 >= 1. */ /* > \endverbatim */ /* > */ /* > \param[in,out] A */ /* > \verbatim */ /* > A is COMPLEX*16 array, dimension (LDA,N) */ /* > */ /* > On entry: an M-by-N matrix A. */ /* > */ /* > On exit: */ /* > a) the elements on and above the diagonal */ /* > of the array contain the N-by-N upper-triangular */ /* > matrix R corresponding to the Householder QR; */ /* > b) the elements below the diagonal represent Q by */ /* > the columns of blocked V (compact WY-representation). */ /* > \endverbatim */ /* > */ /* > \param[in] LDA */ /* > \verbatim */ /* > LDA is INTEGER */ /* > The leading dimension of the array A. LDA >= f2cmax(1,M). */ /* > \endverbatim */ /* > */ /* > \param[out] T */ /* > \verbatim */ /* > T is COMPLEX array, dimension (LDT,N)) */ /* > The upper triangular block reflectors stored in compact form */ /* > as a sequence of upper triangular blocks. */ /* > \endverbatim */ /* > */ /* > \param[in] LDT */ /* > \verbatim */ /* > LDT is INTEGER */ /* > The leading dimension of the array T. LDT >= NB2. */ /* > \endverbatim */ /* > */ /* > \param[out] WORK */ /* > \verbatim */ /* > (workspace) COMPLEX array, dimension (MAX(1,LWORK)) */ /* > On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ /* > \endverbatim */ /* > */ /* > \param[in] LWORK */ /* > \verbatim */ /* > The dimension of the array WORK. */ /* > LWORK >= MAX( LWT + LW1, MAX( LWT+N*N+LW2, LWT+N*N+N ) ), */ /* > where */ /* > NUM_ALL_ROW_BLOCKS = CEIL((M-N)/(MB1-N)), */ /* > NB1LOCAL = MIN(NB1,N). */ /* > LWT = NUM_ALL_ROW_BLOCKS * N * NB1LOCAL, */ /* > LW1 = NB1LOCAL * N, */ /* > LW2 = NB1LOCAL * MAX( NB1LOCAL, ( N - NB1LOCAL ) ), */ /* > 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. */ /* > \ingroup comlpexOTHERcomputational */ /* > \par Contributors: */ /* ================== */ /* > */ /* > \verbatim */ /* > */ /* > November 2020, Igor Kozachenko, */ /* > Computer Science Division, */ /* > University of California, Berkeley */ /* > */ /* > \endverbatim */ /* > */ /* ===================================================================== */ /* Subroutine */ int cgetsqrhrt_(integer *m, integer *n, integer *mb1, integer *nb1, integer *nb2, complex *a, integer *lda, complex *t, integer *ldt, complex *work, integer *lwork, integer *info) { /* System generated locals */ integer a_dim1, a_offset, t_dim1, t_offset, i__1, i__2, i__3, i__4; real r__1, r__2, r__3; complex q__1, q__2; /* Local variables */ integer ldwt, lworkopt, i__, j; extern /* Subroutine */ int cungtsqr_row_(integer *, integer *, integer * , integer *, complex *, integer *, complex *, integer *, complex * , integer *, integer *); integer iinfo; extern /* Subroutine */ int ccopy_(integer *, complex *, integer *, complex *, integer *), cunhr_col_(integer *, integer *, integer * , complex *, integer *, complex *, integer *, complex *, integer * ), xerbla_(char *, integer *, ftnlen); logical lquery; integer lw1, lw2, num_all_row_blocks__, lwt; extern /* Subroutine */ int clatsqr_(integer *, integer *, integer *, integer *, complex *, integer *, complex *, integer *, complex *, integer *, integer *); integer nb1local, nb2local; /* -- LAPACK computational routine -- */ /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ /* ===================================================================== */ /* Test the input arguments */ /* Parameter adjustments */ a_dim1 = *lda; a_offset = 1 + a_dim1 * 1; a -= a_offset; t_dim1 = *ldt; t_offset = 1 + t_dim1 * 1; t -= t_offset; --work; /* Function Body */ *info = 0; lquery = *lwork == -1; if (*m < 0) { *info = -1; } else if (*n < 0 || *m < *n) { *info = -2; } else if (*mb1 <= *n) { *info = -3; } else if (*nb1 < 1) { *info = -4; } else if (*nb2 < 1) { *info = -5; } else if (*lda < f2cmax(1,*m)) { *info = -7; } else /* if(complicated condition) */ { /* Computing MAX */ i__1 = 1, i__2 = f2cmin(*nb2,*n); if (*ldt < f2cmax(i__1,i__2)) { *info = -9; } else { /* Test the input LWORK for the dimension of the array WORK. */ /* This workspace is used to store array: */ /* a) Matrix T and WORK for CLATSQR; */ /* b) N-by-N upper-triangular factor R_tsqr; */ /* c) Matrix T and array WORK for CUNGTSQR_ROW; */ /* d) Diagonal D for CUNHR_COL. */ if (*lwork < *n * *n + 1 && ! lquery) { *info = -11; } else { /* Set block size for column blocks */ nb1local = f2cmin(*nb1,*n); /* Computing MAX */ r__3 = (real) (*m - *n) / (real) (*mb1 - *n) + .5f; r__1 = 1.f, r__2 = r_int(&r__3); num_all_row_blocks__ = f2cmax(r__1,r__2); /* Length and leading dimension of WORK array to place */ /* T array in TSQR. */ lwt = num_all_row_blocks__ * *n * nb1local; ldwt = nb1local; /* Length of TSQR work array */ lw1 = nb1local * *n; /* Length of CUNGTSQR_ROW work array. */ /* Computing MAX */ i__1 = nb1local, i__2 = *n - nb1local; lw2 = nb1local * f2cmax(i__1,i__2); /* Computing MAX */ /* Computing MAX */ i__3 = lwt + *n * *n + lw2, i__4 = lwt + *n * *n + *n; i__1 = lwt + lw1, i__2 = f2cmax(i__3,i__4); lworkopt = f2cmax(i__1,i__2); if (*lwork < f2cmax(1,lworkopt) && ! lquery) { *info = -11; } } } } /* Handle error in the input parameters and return workspace query. */ if (*info != 0) { i__1 = -(*info); xerbla_("CGETSQRHRT", &i__1, (ftnlen)10); return 0; } else if (lquery) { q__1.r = (real) lworkopt, q__1.i = 0.f; work[1].r = q__1.r, work[1].i = q__1.i; return 0; } /* Quick return if possible */ if (f2cmin(*m,*n) == 0) { q__1.r = (real) lworkopt, q__1.i = 0.f; work[1].r = q__1.r, work[1].i = q__1.i; return 0; } nb2local = f2cmin(*nb2,*n); /* (1) Perform TSQR-factorization of the M-by-N matrix A. */ clatsqr_(m, n, mb1, &nb1local, &a[a_offset], lda, &work[1], &ldwt, &work[ lwt + 1], &lw1, &iinfo); /* (2) Copy the factor R_tsqr stored in the upper-triangular part */ /* of A into the square matrix in the work array */ /* WORK(LWT+1:LWT+N*N) column-by-column. */ i__1 = *n; for (j = 1; j <= i__1; ++j) { ccopy_(&j, &a[j * a_dim1 + 1], &c__1, &work[lwt + *n * (j - 1) + 1], & c__1); } /* (3) Generate a M-by-N matrix Q with orthonormal columns from */ /* the result stored below the diagonal in the array A in place. */ cungtsqr_row_(m, n, mb1, &nb1local, &a[a_offset], lda, &work[1], &ldwt, & work[lwt + *n * *n + 1], &lw2, &iinfo); /* (4) Perform the reconstruction of Householder vectors from */ /* the matrix Q (stored in A) in place. */ cunhr_col_(m, n, &nb2local, &a[a_offset], lda, &t[t_offset], ldt, &work[ lwt + *n * *n + 1], &iinfo); /* (5) Copy the factor R_tsqr stored in the square matrix in the */ /* work array WORK(LWT+1:LWT+N*N) into the upper-triangular */ /* part of A. */ /* (6) Compute from R_tsqr the factor R_hr corresponding to */ /* the reconstructed Householder vectors, i.e. R_hr = S * R_tsqr. */ /* This multiplication by the sign matrix S on the left means */ /* changing the sign of I-th row of the matrix R_tsqr according */ /* to sign of the I-th diagonal element DIAG(I) of the matrix S. */ /* DIAG is stored in WORK( LWT+N*N+1 ) from the CUNHR_COL output. */ /* (5) and (6) can be combined in a single loop, so the rows in A */ /* are accessed only once. */ i__1 = *n; for (i__ = 1; i__ <= i__1; ++i__) { i__2 = lwt + *n * *n + i__; q__1.r = -1.f, q__1.i = 0.f; if (work[i__2].r == q__1.r && work[i__2].i == q__1.i) { i__2 = *n; for (j = i__; j <= i__2; ++j) { i__3 = i__ + j * a_dim1; q__2.r = -1.f, q__2.i = 0.f; i__4 = lwt + *n * (j - 1) + i__; q__1.r = q__2.r * work[i__4].r - q__2.i * work[i__4].i, q__1.i = q__2.r * work[i__4].i + q__2.i * work[i__4] .r; a[i__3].r = q__1.r, a[i__3].i = q__1.i; } } else { i__2 = *n - i__ + 1; ccopy_(&i__2, &work[lwt + *n * (i__ - 1) + i__], n, &a[i__ + i__ * a_dim1], lda); } } q__1.r = (real) lworkopt, q__1.i = 0.f; work[1].r = q__1.r, work[1].i = q__1.i; return 0; /* End of CGETSQRHRT */ } /* cgetsqrhrt_ */
the_stack_data/243894106.c
#include <stdio.h> char square[10] = { 'o', '1', '2', '3', '4', '5', '6', '7', '8', '9' }; int checkwin(); int main() { int player = 1, i, choice; char ch=':', ch1=')'; char mark; do { board(); player = (player % 2) ? 1 : 2; //The line (player % 2) ? 1 : 2 basically evaluates if (player % 2) is true. If it's true, the 1 is selected, otherwise, if it's false, the 2 is selected. The selected value is then assigned to player printf("Player %d, enter a number: ", player); scanf("%d", &choice); mark = (player == 1) ? 'X' : 'O'; if(choice==1 && square[1]=='1') square[1]=mark; else if(choice==2 && square[2]=='2') square[2]=mark; else if(choice==3 && square[3]=='3') square[3]=mark; else if(choice==4 && square[4]=='4') square[4]=mark; else if(choice==5 && square[5]=='5') square[5]=mark; else if(choice==6 && square[6]=='6') square[6]=mark; else if(choice==7 && square[7]=='7') square[7]=mark; else if(choice==8 && square[8]=='8') square[8]=mark; else if(choice==9 && square[9]=='9') square[9]=mark; else { printf("Invalid move! Try Again %c%c ", ch, ch1); player--; getch(); } i = checkwin(); player++; } while (i == - 1); board(); if (i == 1) { printf("==>\aPlayer %d win ", --player); } else { printf("==>\aGame draw"); } getch(); return 0; } //Function to return gaming : 1 for game is over with result, -1 for game still is in progress and 0 is for that game is over and no result int checkwin() { if(square[1]==square[2] && square[2]==square[3]) { return 1; } else if(square[4]==square[5] && square[5]==square[6]) { return 1; } else if(square[7]==square[8] && square[8]==square[9]) { return 1; } else if(square[1]==square[4]&& square[4]== square[7]) { return 1; } else if(square[2]==square[5] && square[5]==square[8]) { return 1; } else if(square[3]==square[6] && square[6]==square[9]) { return 1; } else if(square[1]==square[5] && square[5]==square[9]) { return 1; } else if(square[3]==square[5] && square[5]==square[7]) { return 1; } else if (square[1]!='1' && square[2]!='2' && square[3]!='3' && square[4]!='4' && square[5]!='5' && square[6]!='6' && square[7]!='7' && square[8]!='8' && square[9]!='9') { return 0; } else { return - 1; } } //drawing board with player marking void board() { system("cls"); printf("\n\n\ Tic Tac Toe [FBA]\n\n"); printf("Player 1 (X) - Player 2 (O)\n\n\n"); printf(" | | \n"); printf(" %c | %c | %c \n", square[1], square[2], square[3]); printf("_____|_____|_____\n"); printf(" | | \n"); printf(" %c | %c | %c \n", square[4], square[5], square[6]); printf("_____|_____|_____\n"); printf(" | | \n"); printf(" %c | %c | %c \n", square[7], square[8], square[9]); printf(" | | \n\n"); }
the_stack_data/58432.c
/* * This file and its contents are supplied under the terms of the * Common Development and Distribution License ("CDDL"), version 1.0. * You may only use this file in accordance with the terms of version * 1.0 of the CDDL. * * A full copy of the text of the CDDL should have accompanied this * source. A copy of the CDDL is also available via the Internet at * http://www.illumos.org/license/CDDL. */ /* * Copyright 2019 OmniOS Community Edition (OmniOSce) Association. */ #include <stdlib.h> void * reallocf(void *ptr, size_t size) { void *nptr = realloc(ptr, size); /* If size is zero, realloc will have already freed ptr. */ if (nptr == NULL && size != 0) free(ptr); return (nptr); }
the_stack_data/150183.c
float a; int b; void main() { a = cos(0); assert(abs(a - 1) < 0.000001, "a must be 1"); a = sin(3.14 / 2); assert(abs(a - 1) < 0.000001, "a must be 1"); a = sqrt(1.e2); assert(abs(a - 10) < 0.000001, "a must be 10.000000"); a = abs(-2.72); assert(abs(a - 2.72) < 0.000001, "a must be 2.720000"); a = abs(-3); assert(abs(a - 3) < 0.000001, "a must be 3.000000"); /* sin(3.14/2)=1, cos(0)=1, sqrt(1.e2)=10, abs(-2.72)=2.72, abs(-3)=3 */ print(rand()); print(rand()); }